main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int v4; // ebx
int result; // eax
int v6; // ebx
int v7; // ebx

fprintf(_bss_start, "%s(%d): ENTERING", "gentest.c", 29LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v3 = 0;
do
{
fputc(46, _bss_start);
++v3;
}
while ( GENUTIL_function_call_depth > v3 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s\n", "main(int argc, char** argv)");
fflush(_bss_start);
++GENUTIL_function_call_depth;
fprintf(_bss_start, "%s(%d): ", "gentest.c", 30LL);
fprintf(_bss_start, "argc: %d", (unsigned int)argc);
fputc(10, _bss_start);
fflush(_bss_start);
fprintf(_bss_start, "%s(%d): ", "gentest.c", 31LL);
fprintf(_bss_start, "argv: %p", argv);
fputc(10, _bss_start);
fflush(_bss_start);
if ( argc == 2 )
{
v6 = atoi(argv[1]);
initialize();
recurse(v6);
--GENUTIL_function_call_depth;
fprintf(_bss_start, "%s(%d): LEAVING", "gentest.c", 50LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v7 = 0;
do
{
fputc(46, _bss_start);
++v7;
}
while ( GENUTIL_function_call_depth > v7 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s [%d]\n", "main(int argc, char** argv)", 0LL);
fflush(_bss_start);
result = 0;
}
else
{
if ( argc <= 0 )
fwrite("usage: program <number>\n", 1uLL, 0x18uLL, stderr);
else
fprintf(stderr, "usage: %s <number>\n", *argv);
--GENUTIL_function_call_depth;
fprintf(_bss_start, "%s(%d): LEAVING", "gentest.c", 42LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v4 = 0;
do
{
fputc(46, _bss_start);
++v4;
}
while ( GENUTIL_function_call_depth > v4 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s [%d]\n", "main(int argc, char** argv)", 1LL);
fflush(_bss_start);
result = 1;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int v4; // ebx
int result; // eax
int v6; // ebx
int v7; // ebx

fprintf(_bss_start, "%s(%d): ENTERING", "gentest.c", 29LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v3 = 0;
do
{
fputc(46, _bss_start);
++v3;
}
while ( GENUTIL_function_call_depth > v3 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s\n", "main(int argc, char** argv)");
fflush(_bss_start);
++GENUTIL_function_call_depth;
fprintf(_bss_start, "%s(%d): ", "gentest.c", 30LL);
fprintf(_bss_start, "argc: %d", (unsigned int)argc);
fputc(10, _bss_start);
fflush(_bss_start);
fprintf(_bss_start, "%s(%d): ", "gentest.c", 31LL);
fprintf(_bss_start, "argv: %p", argv);
fputc(10, _bss_start);
fflush(_bss_start);
if ( argc == 2 )
{
v6 = atoi(argv[1]);
func8();
func7(v6);
--GENUTIL_function_call_depth;
fprintf(_bss_start, "%s(%d): LEAVING", "gentest.c", 50LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v7 = 0;
do
{
fputc(46, _bss_start);
++v7;
}
while ( GENUTIL_function_call_depth > v7 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s [%d]\n", "main(int argc, char** argv)", 0LL);
fflush(_bss_start);
result = 0;
}
else
{
if ( argc <= 0 )
fwrite("usage: program <number>\n", 1uLL, 0x18uLL, stderr);
else
fprintf(stderr, "usage: %s <number>\n", *argv);
--GENUTIL_function_call_depth;
fprintf(_bss_start, "%s(%d): LEAVING", "gentest.c", 42LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v4 = 0;
do
{
fputc(46, _bss_start);
++v4;
}
while ( GENUTIL_function_call_depth > v4 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s [%d]\n", "main(int argc, char** argv)", 1LL);
fflush(_bss_start);
result = 1;
}
return result;
}

original_code:
int main(int argc, char** argv) {
 int number;
 char *GENUTIL_function_name = "main(int argc, char** argv)"; do { int GENUTIL_i; fprintf(stdout, "%s(%d): ENTERING", "gentest.c", 29); if (GENUTIL_function_call_depth < 0) { fprintf(stdout,"genutil: The function call depth indicator fell to %d, this indicates that not\n" "genutil: all of the functions are utilizing the entering_function and\n" "genutil: leaving_function macros correctly.  Make sure that all function\n" "genutil: entrance points contain a call to entering_function and that all\n" "genutil: function exit points contain a call to leaving_function.\n", GENUTIL_function_call_depth); exit(-1); } fprintf(stdout, "(depth:%d)", GENUTIL_function_call_depth); for (GENUTIL_i = 0; GENUTIL_i < GENUTIL_function_call_depth; GENUTIL_i++) { fprintf(stdout, "."); } fprintf(stdout, "> "); fprintf(stdout, "%s\n", GENUTIL_function_name); fflush(stdout); GENUTIL_function_call_depth++; } while (0);
 do { fprintf(stdout, "%s(%d): ", "gentest.c", 30); fprintf(stdout, "argc: %d", argc); fprintf(stdout, "\n"); fflush(stdout); } while (0);
 do { fprintf(stdout, "%s(%d): ", "gentest.c", 31); fprintf(stdout, "argv: %p", argv); fprintf(stdout, "\n"); fflush(stdout); } while (0);
 if (argc != 2) {
  if (argc > 0) {
   fprintf(stderr, "usage: %s <number>\n", argv[0]);
  }
  else {
   fprintf(stderr, "usage: program <number>\n");
  }
  GENUTIL_function_call_depth--; do { int GENUTIL_i; fprintf(stdout, "%s(%d): LEAVING", "gentest.c", 42); if (GENUTIL_function_call_depth < 0) { fprintf(stdout,"genutil: The function call depth indicator fell to %d, this indicates that not\n" "genutil: all of the functions are utilizing the entering_function and\n" "genutil: leaving_function macros correctly.  Make sure that all function\n" "genutil: entrance points contain a call to entering_function and that all\n" "genutil: function exit points contain a call to leaving_function.\n", GENUTIL_function_call_depth); exit(-1); } fprintf(stdout, "(depth:%d)", GENUTIL_function_call_depth); for (GENUTIL_i = 0; GENUTIL_i < GENUTIL_function_call_depth; GENUTIL_i++) { fprintf(stdout, "."); } fprintf(stdout, "> "); fprintf(stdout, "%s [%d]\n", GENUTIL_function_name, (int) 1); fflush(stdout); } while (0);
  return 1;
 }
 number = atoi(argv[1]);
 initialize();
 recurse(number);
 GENUTIL_function_call_depth--; do { int GENUTIL_i; fprintf(stdout, "%s(%d): LEAVING", "gentest.c", 50); if (GENUTIL_function_call_depth < 0) { fprintf(stdout,"genutil: The function call depth indicator fell to %d, this indicates that not\n" "genutil: all of the functions are utilizing the entering_function and\n" "genutil: leaving_function macros correctly.  Make sure that all function\n" "genutil: entrance points contain a call to entering_function and that all\n" "genutil: function exit points contain a call to leaving_function.\n", GENUTIL_function_call_depth); exit(-1); } fprintf(stdout, "(depth:%d)", GENUTIL_function_call_depth); for (GENUTIL_i = 0; GENUTIL_i < GENUTIL_function_call_depth; GENUTIL_i++) { fprintf(stdout, "."); } fprintf(stdout, "> "); fprintf(stdout, "%s [%d]\n", GENUTIL_function_name, (int) 0); fflush(stdout); } while (0);
 return(0);
}

canonical_original_code:
int main(int argc, char **argv) {
 int number;
 char *GENUTIL_function_name = "main(int argc, char** argv)"; do { int GENUTIL_i; fprintf(stdout, "%s(%d): ENTERING", "gentest.c", 29); if (GENUTIL_function_call_depth < 0) { fprintf(stdout,"genutil: The function call depth indicator fell to %d, this indicates that not\n" "genutil: all of the functions are utilizing the entering_function and\n" "genutil: leaving_function macros correctly.  Make sure that all function\n" "genutil: entrance points contain a call to entering_function and that all\n" "genutil: function exit points contain a call to leaving_function.\n", GENUTIL_function_call_depth); exit(-1); } fprintf(stdout, "(depth:%d)", GENUTIL_function_call_depth); for (GENUTIL_i = 0; GENUTIL_i < GENUTIL_function_call_depth; GENUTIL_i++) { fprintf(stdout, "."); } fprintf(stdout, "> "); fprintf(stdout, "%s\n", GENUTIL_function_name); fflush(stdout); GENUTIL_function_call_depth++; } while (0);
 do { fprintf(stdout, "%s(%d): ", "gentest.c", 30); fprintf(stdout, "argc: %d", argc); fprintf(stdout, "\n"); fflush(stdout); } while (0);
 do { fprintf(stdout, "%s(%d): ", "gentest.c", 31); fprintf(stdout, "argv: %p", argv); fprintf(stdout, "\n"); fflush(stdout); } while (0);
 if (argc != 2) {
  if (argc > 0) {
   fprintf(stderr, "usage: %s <number>\n", argv[0]);
  }
  else {
   fprintf(stderr, "usage: program <number>\n");
  }
  GENUTIL_function_call_depth--; do { int GENUTIL_i; fprintf(stdout, "%s(%d): LEAVING", "gentest.c", 42); if (GENUTIL_function_call_depth < 0) { fprintf(stdout,"genutil: The function call depth indicator fell to %d, this indicates that not\n" "genutil: all of the functions are utilizing the entering_function and\n" "genutil: leaving_function macros correctly.  Make sure that all function\n" "genutil: entrance points contain a call to entering_function and that all\n" "genutil: function exit points contain a call to leaving_function.\n", GENUTIL_function_call_depth); exit(-1); } fprintf(stdout, "(depth:%d)", GENUTIL_function_call_depth); for (GENUTIL_i = 0; GENUTIL_i < GENUTIL_function_call_depth; GENUTIL_i++) { fprintf(stdout, "."); } fprintf(stdout, "> "); fprintf(stdout, "%s [%d]\n", GENUTIL_function_name, (int) 1); fflush(stdout); } while (0);
  return 1;
 }
 number = atoi(argv[1]);
 initialize();
 recurse(number);
 GENUTIL_function_call_depth--; do { int GENUTIL_i; fprintf(stdout, "%s(%d): LEAVING", "gentest.c", 50); if (GENUTIL_function_call_depth < 0) { fprintf(stdout,"genutil: The function call depth indicator fell to %d, this indicates that not\n" "genutil: all of the functions are utilizing the entering_function and\n" "genutil: leaving_function macros correctly.  Make sure that all function\n" "genutil: entrance points contain a call to entering_function and that all\n" "genutil: function exit points contain a call to leaving_function.\n", GENUTIL_function_call_depth); exit(-1); } fprintf(stdout, "(depth:%d)", GENUTIL_function_call_depth); for (GENUTIL_i = 0; GENUTIL_i < GENUTIL_function_call_depth; GENUTIL_i++) { fprintf(stdout, "."); } fprintf(stdout, "> "); fprintf(stdout, "%s [%d]\n", GENUTIL_function_name, (int) 0); fflush(stdout); } while (0);
 return(0);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: number int


canonical_name: main

repo: kephas/maru

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
printf("(define %s %d)\n", "__ELF__", 1LL);
printf("(define %s \"%s\")\n", "__USER_LABEL_PREFIX__", "");
printf("(define %s %d)\n", "__linux__", 1LL);
return 0;
}

original_code:
int main()
{
    printf("(define %s %d)\n", "__ELF__", 1);
    printf("(define %s \"%s\")\n", "__USER_LABEL_PREFIX__", "");
    printf("(define %s %d)\n", "__linux__", 1);
    return 0;
}

return_type: int


repo: kepplemr/operatingSystems

decompiled_code:
void __fastcall __noreturn read_user(void *a1)
{
while ( 1 )
{
sem_wait(&reader_lock);
puts("In reader task");
sleep(2u);
sem_post(&writer_lock);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func7(void *a1)
{
while ( 1 )
{
sem_wait(&reader_lock);
puts("In reader task");
sleep(2u);
sem_post(&writer_lock);
}
}

original_code:
void read_user(void) {
  while (1) {
    sem_wait(&reader_lock);
    printf("In reader task\n");
    sleep(2);
    sem_post(&writer_lock);
  }
}

canonical_original_code:
void read_user() {
  while (1) {
    sem_wait(&reader_lock);
    printf("In reader task\n");
    sleep(2);
    sem_post(&writer_lock);
  }
}

return_type: void


decompiled_code:
void __noreturn write_user()
{
while ( 1 )
{
sem_wait(&writer_lock);
puts("In writer task");
sleep(2u);
sem_post(&reader_lock);
}
}

canonical_decompiled_code:
void __noreturn func8()
{
while ( 1 )
{
sem_wait(&writer_lock);
puts("In writer task");
sleep(2u);
sem_post(&reader_lock);
}
}

original_code:
void write_user(void) {
  while (1) {
    sem_wait(&writer_lock);
    printf("In writer task\n");
    sleep(2);
    sem_post(&reader_lock);
  }
}

canonical_original_code:
void write_user() {
  while (1) {
    sem_wait(&writer_lock);
    printf("In writer task\n");
    sleep(2);
    sem_post(&reader_lock);
  }
}


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
pthread_attr_t v3; // [rsp+0h] [rbp-48h] BYREF
pthread_t newthread[2]; // [rsp+38h] [rbp-10h] BYREF

sem_init(&writer_lock, 0, 1u);
sem_init(&reader_lock, 0, 1u);
sem_wait(&reader_lock);
pthread_attr_init(&v3);
pthread_create(newthread, &v3, (void *(*)(void *))read_user, 0LL);
write_user();
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
pthread_attr_t v3; // [rsp+0h] [rbp-48h] BYREF
pthread_t newthread[2]; // [rsp+38h] [rbp-10h] BYREF

sem_init(&writer_lock, 0, 1u);
sem_init(&reader_lock, 0, 1u);
sem_wait(&reader_lock);
pthread_attr_init(&v3);
pthread_create(newthread, &v3, (void *(*)(void *))read_user, 0LL);
func8();
}

original_code:
int main() {
  pthread_t read_thread;
  pthread_attr_t attribute;
  sem_init(&writer_lock, 0, 1);
  sem_init(&reader_lock, 0, 1);
  sem_wait(&reader_lock);
  pthread_attr_init(&attribute);
  pthread_create(&read_thread, &attribute, (void *) &read_user, ((void *)0));
  write_user();
  return 0;
}

canonical_original_code:
int main() {
  unsigned long read_thread;
  union pthread_attr_t attribute;
  sem_init(&writer_lock, 0, 1);
  sem_init(&reader_lock, 0, 1);
  sem_wait(&reader_lock);
  pthread_attr_init(&attribute);
  pthread_create(&read_thread, &attribute, (void *) &read_user, ((void *)0));
  write_user();
  return 0;
}

variable_types: union pthread_attr_t { char __size[56]; long __align; }


repo: kepstin/hajimete

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm2_8
double v6; // xmm3_8
double v7; // xmm6_8
double v8; // xmm7_8
bool v10; // cf
bool v11; // zf
int *v12; // rax
char *v13; // rax
int *v14; // rax
char *v15; // rax
double v16; // xmm4_8
double v17; // xmm5_8
unsigned int v18; // eax
const char *v20; // rdi
__int64 v21; // rcx
char *v22; // rsi
int *v23; // rax
char *v24; // rax
int *v25; // rax
char *v26; // rax
int *v27; // rax
char *v28; // rax
char v29[128]; // [rsp+1h] [rbp-99h]
char v30[152]; // [rsp+2h] [rbp-98h] BYREF

puts("\thajimemasu");
if ( mount("proc", "/proc", "proc", 0LL, 0LL) )
{
v12 = __errno_location();
v13 = strerror(*v12);
printf("Failed to mount /proc: %s\n", v13);
}
if ( mount("sysfs", "/sys", "sysfs", 0LL, 0LL) )
{
v14 = __errno_location();
v15 = strerror(*v14);
printf("Failed to mount /sys: %s\n", v15);
}
read_cmdline(&cmdline);
kernel_param_parse(&cmdline, &params);
udev_init();
printf("Detected root as '%s'\n", src);
strncpy(v30, src, 0x7FuLL);
v30[127] = 0;
while ( 1 )
{
v20 = "shell";
v21 = 6LL;
v22 = v30;
do
{
if ( !v21 )
break;
v10 = (unsigned __int8)*v22 < (unsigned int)*v20;
v11 = *v22++ == *v20++;
--v21;
}
while ( v11 );
if ( (!v10 && !v11) != v10 )
break;
rescue(v20, v22);
LABEL_13:
printf("Try entering another root device, or 'shell' for a rescue shell\nroot> ");
fgets(v30, 128, stdin);
v29[strlen(v30)] = 0;
}
puts("I'm now going to attempt to mount your root device.");
v18 = exec_run_wait(
"/bin/mount",
(__int64)"/bin/mount",
v3,
v4,
v5,
v6,
v16,
v17,
v7,
v8,
"-o",
"ro",
v30,
"/newroot",
0LL);
if ( v18 )
{
printf("Failed to mount root (%d)\n", v18);
goto LABEL_13;
}
puts("Looks good, switching to it.");
udev_kill();
if ( chroot("/newroot") )
{
v23 = __errno_location();
v24 = strerror(*v23);
printf("Failed to chroot: %s\n", v24);
}
else if ( chdir("/") )
{
v25 = __errno_location();
v26 = strerror(*v25);
printf("Failed to chdir to /: %s\n", v26);
}
else
{
puts("And now, running your real init. From now on, it's all you.");
if ( execv(off_4040E8, (char *const *)argv) )
{
v27 = __errno_location();
v28 = strerror(*v27);
printf("Failed to exec %s: %s", off_4040E8, v28);
}
}
puts(
"An unrecoverable error has occurred. Please contact your distribution support\n"
"In your report, include as much of the above text as you can see.");
sleep(5u);
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm2_8
double v6; // xmm3_8
double v7; // xmm6_8
double v8; // xmm7_8
bool v10; // cf
bool v11; // zf
int *v12; // rax
char *v13; // rax
int *v14; // rax
char *v15; // rax
double v16; // xmm4_8
double v17; // xmm5_8
unsigned int v18; // eax
const char *v20; // rdi
__int64 v21; // rcx
char *v22; // rsi
int *v23; // rax
char *v24; // rax
int *v25; // rax
char *v26; // rax
int *v27; // rax
char *v28; // rax
char v29[128]; // [rsp+1h] [rbp-99h]
char v30[152]; // [rsp+2h] [rbp-98h] BYREF

puts("\thajimemasu");
if ( mount("proc", "/proc", "proc", 0LL, 0LL) )
{
v12 = __errno_location();
v13 = strerror(*v12);
printf("Failed to mount /proc: %s\n", v13);
}
if ( mount("sysfs", "/sys", "sysfs", 0LL, 0LL) )
{
v14 = __errno_location();
v15 = strerror(*v14);
printf("Failed to mount /sys: %s\n", v15);
}
func8(&cmdline);
func12(&cmdline, &params);
func14();
printf("Detected root as '%s'\n", src);
strncpy(v30, src, 0x7FuLL);
v30[127] = 0;
while ( 1 )
{
v20 = "shell";
v21 = 6LL;
v22 = v30;
do
{
if ( !v21 )
break;
v10 = (unsigned __int8)*v22 < (unsigned int)*v20;
v11 = *v22++ == *v20++;
--v21;
}
while ( v11 );
if ( (!v10 && !v11) != v10 )
break;
func13(v20, v22);
LABEL_13:
printf("Try entering another root device, or 'shell' for a rescue shell\nroot> ");
fgets(v30, 128, stdin);
v29[strlen(v30)] = 0;
}
puts("I'm now going to attempt to mount your root device.");
v18 = func7(
"/bin/mount",
(__int64)"/bin/mount",
v3,
v4,
v5,
v6,
v16,
v17,
v7,
v8,
"-o",
"ro",
v30,
"/newroot",
0LL);
if ( v18 )
{
printf("Failed to mount root (%d)\n", v18);
goto LABEL_13;
}
puts("Looks good, switching to it.");
func15();
if ( chroot("/newroot") )
{
v23 = __errno_location();
v24 = strerror(*v23);
printf("Failed to chroot: %s\n", v24);
}
else if ( chdir("/") )
{
v25 = __errno_location();
v26 = strerror(*v25);
printf("Failed to chdir to /: %s\n", v26);
}
else
{
puts("And now, running your real init. From now on, it's all you.");
if ( execv(off_4040E8, (char *const *)argv) )
{
v27 = __errno_location();
v28 = strerror(*v27);
printf("Failed to exec %s: %s", off_4040E8, v28);
}
}
puts(
"An unrecoverable error has occurred. Please contact your distribution support\n"
"In your report, include as much of the above text as you can see.");
sleep(5u);
return 1;
}

original_code:
int main(int argc, char *argv[])
{
 int err;
 char root[128];
 int mounted = 0;
 printf("\thajimemasu\n");
 err = mount("proc", "/proc", "proc", 0, ((void *)0));
 if (err)
  printf("Failed to mount /proc: %s\n", strerror((*__errno_location ())));
 err = mount("sysfs", "/sys", "sysfs", 0, ((void *)0));
 if (err)
  printf("Failed to mount /sys: %s\n", strerror((*__errno_location ())));
 err = read_cmdline(cmdline);
 kernel_param_parse(cmdline, params);
 udev_init();
 printf("Detected root as '%s'\n", param_root.value);
 strncpy(root, param_root.value, 128);
 root[127] = '\0';
 while (!mounted) {
  if (strcmp(root, "shell") == 0)
   rescue();
  else {
   printf("I'm now going to attempt to mount your root device.\n");
   err = exec_run_wait("/bin/mount", "/bin/mount",
    "-o", "ro", root, "/newroot", (char *) ((void *)0));
   if (err)
    printf("Failed to mount root (%d)\n", err);
   else
    mounted = 1;
  }
  if (!mounted) {
   printf("Try entering another root device, or 'shell' for a rescue shell\n"
    "root> ");
   fgets(root, 128, stdin);
   root[strlen(root) - 1] = '\0';
  }
 }
 printf("Looks good, switching to it.\n");
 udev_kill();
 err = chroot("/newroot");
 if (err) {
  printf("Failed to chroot: %s\n", strerror((*__errno_location ())));
  goto die_hard;
 }
 err = chdir("/");
 if (err) {
  printf("Failed to chdir to /: %s\n", strerror((*__errno_location ())));
  goto die_hard;
 }
 printf("And now, running your real init. From now on, it's all you.\n");
 err = execv(param_init.value, argv);
 if (err) {
  printf("Failed to exec %s: %s", param_init.value, strerror((*__errno_location ())));
  goto die_hard;
 }
die_hard:
 printf("An unrecoverable error has occurred. Please contact your distribution support\n"
  "In your report, include as much of the above text as you can see.\n");
 sleep(5);
 return 1;
}

variable_types:
argv
char *[]

variable_types: err int

variable_types:
root
char [128]

variable_types: mounted int


decompiled_code:
__int64 __fastcall dash2underscore(unsigned int a1)
{
__int64 result; // rax

result = 95LL;
if ( (_BYTE)a1 != 45 )
result = a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1)
{
__int64 result; // rax

result = 95LL;
if ( (_BYTE)a1 != 45 )
result = a1;
return result;
}

original_code:
static inline char dash2underscore(char c)
{
 if (c == '-')
  return '_';
 return c;
}

variable_types: c char

return_type: char


parameq

decompiled_code:
__int64 __fastcall parameq(__int64 a1, __int64 a2)
{
unsigned int i; // er12
char v3; // bp

for ( i = 0; ; ++i )
{
v3 = *(_BYTE *)(a1 + i);
if ( (unsigned __int8)dash2underscore(v3) != *(_BYTE *)(a2 + i) )
break;
if ( !v3 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2)
{
unsigned int i; // er12
char v3; // bp

for ( i = 0; ; ++i )
{
v3 = *(_BYTE *)(a1 + i);
if ( (unsigned __int8)func9(v3) != *(_BYTE *)(a2 + i) )
break;
if ( !v3 )
return 1LL;
}
return 0LL;
}

original_code:
static inline int parameq(const char *input, const char *paramname)
{
 unsigned int i;
 for (i = 0; dash2underscore(input[i]) == paramname[i]; i++)
  if (input[i] == '\0')
   return 1;
 return 0;
}

canonical_original_code:
static inline int parameq(char *input, char *paramname)
{
 unsigned int i;
 for (i = 0; dash2underscore(input[i]) == paramname[i]; i++)
  if (input[i] == '\0')
   return 1;
 return 0;
}

variable_types:
input
char *

variable_types:
paramname
char *

variable_types:
i
unsigned int


decompiled_code:
void __fastcall parse_one(__int64 a1, __int64 a2, __int64 **a3)
{
__int64 *v3; // rbx
int v5; // ebp

v3 = *a3;
if ( *a3 )
{
v5 = 0;
do
{
if ( (unsigned int)parameq(a1, *v3) )
v3[1] = a2;
v3 = a3[++v5];
}
while ( v3 );
}
}

original_code:
static void parse_one(char *param,
       char *val,
       struct kernel_param *params[])
{
 unsigned int i;
 for (i = 0; params[i]; i++) {
  if (parameq(param, params[i]->name)) {
   params[i]->value = val;
  }
 }
}

variable_types:
param
char *

variable_types:
val
char *

variable_types: struct kernel_param { char *name; char *value; } *[]


decompiled_code:
__int64 __fastcall kernel_param_parse(const char *a1, __int64 **a2)
{
_BYTE *v2; // rbx
__int64 v4; // [rsp+0h] [rbp-28h] BYREF
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

if ( !a2 )
return 0LL;
v2 = a1;
printf("Kernel Parameters: %s\n", a1);
if ( *a1 == 32 )
{
do
++v2;
while ( *v2 == 32 );
}
while ( *v2 )
{
v2 = next_arg(v2, v5, &v4);
parse_one(v5[0], v4, a2);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(const char *a1, __int64 **a2)
{
_BYTE *v2; // rbx
__int64 v4; // [rsp+0h] [rbp-28h] BYREF
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

if ( !a2 )
return 0LL;
v2 = a1;
printf("Kernel Parameters: %s\n", a1);
if ( *a1 == 32 )
{
do
++v2;
while ( *v2 == 32 );
}
while ( *v2 )
{
v2 = next_arg(v2, v5, &v4);
func11(v5[0], v4, a2);
}
return 0LL;
}

original_code:
int kernel_param_parse(char *args,
   struct kernel_param *params[])
{
 char *param, *val;
 if (!params)
  return 0;
 printf("Kernel Parameters: %s\n", args);
 while (*args == ' ')
  args++;
 while (*args) {
  args = next_arg(args, &param, &val);
  parse_one(param, val, params);
 }
 return 0;
}

canonical_original_code:
int kernel_param_parse(char *args, struct kernel_param *params[])
{
 char *param; char *val;
 if (!params)
  return 0;
 printf("Kernel Parameters: %s\n", args);
 while (*args == ' ')
  args++;
 while (*args) {
  args = next_arg(args, &param, &val);
  parse_one(param, val, params);
 }
 return 0;
}

variable_types:
args
char *

user_defined_types: struct kernel_param { char *name; char *value; }


rescue

decompiled_code:
int __fastcall rescue(double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8)
{
return exec_run_wait("/sbin/sulogin", (__int64)"/sbin/sulogin", a1, a2, a3, a4, a5, a6, a7, a8, 0LL);
}

canonical_decompiled_code:
int __fastcall func13(double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8)
{
return func7("/sbin/sulogin", (__int64)"/sbin/sulogin", a1, a2, a3, a4, a5, a6, a7, a8, 0LL);
}

original_code:
int rescue(void)
{
 return exec_run_wait("/sbin/sulogin", "/sbin/sulogin", (char *) ((void *)0));
}

canonical_original_code:
int rescue()
{
 return exec_run_wait("/sbin/sulogin", "/sbin/sulogin", (char *) ((void *)0));
}


repo: kernelhcy/swiftd

decompiled_code:
int __fastcall mm_cache_show(__int64 a1)
{
int result; // eax

if ( a1 )
{
printf("\nMemory cache name: %s\n", (const char *)a1);
printf("Object size: %d Align: %d\n", *(_QWORD *)(a1 + 256), *(unsigned int *)(a1 + 264));
result = printf("Pre %s next %s\n", *(const char **)(a1 + 304), *(const char **)(a1 + 312));
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1)
{
int result; // eax

if ( a1 )
{
printf("\nMemory cache name: %s\n", (const char *)a1);
printf("Object size: %d Align: %d\n", *(_QWORD *)(a1 + 256), *(unsigned int *)(a1 + 264));
result = printf("Pre %s next %s\n", *(const char **)(a1 + 304), *(const char **)(a1 + 312));
}
return result;
}

original_code:
static void mm_cache_show(struct mm_cache *mc)
{
 if(((void *)0) == mc){
  return;
 }
 printf("\nMemory cache name: %s\n", mc -> name);
 printf("Object size: %d  Align: %d\n", mc -> size, mc -> align);
 printf("Pre %s next %s\n", mc -> pre -> name, mc -> next -> name);
}

variable_types: struct mm_cache { char name[256]; unsigned long size; int align; void (*ctor)(void *); void (*dtor)(void *); unsigned long total_objs; unsigned long total_mm; struct mm_cache *pre; } *


original_code:
void mm_cache_destroy(struct mm_cache *mc)
{
 if(((void *)0) == mc){
  return;
 }
 mc -> next -> pre = mc -> pre;
 mc -> pre -> next = mc -> next;
 if(head == mc){
  head = mc -> next;
 }
 free(mc);
}

user_defined_types: struct mm_cache { char name[256]; unsigned long size; int align; void (*ctor)(void *); void (*dtor)(void *); unsigned long total_objs; unsigned long total_mm; struct mm_cache *pre; }


decompiled_code:
__int64 __fastcall mm_cache_alloc(const char *a1)
{
printf("Alloc an object from : %s\n", a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1)
{
printf("Alloc an object from : %s\n", a1);
return 0LL;
}

original_code:
void * mm_cache_alloc(struct mm_cache *mc)
{
 printf("Alloc an object from : %s\n", mc -> name);
 return ((void *)0);
}

canonical_original_code:
void *mm_cache_alloc(struct mm_cache *mc)
{
 printf("Alloc an object from : %s\n", mc -> name);
 return ((void *)0);
}

return_type: void *


decompiled_code:
int __fastcall mm_cache_free(const char *a1)
{
return printf("Free an object to %s\n", a1);
}

canonical_decompiled_code:
int __fastcall func10(const char *a1)
{
return printf("Free an object to %s\n", a1);
}

original_code:
void mm_cache_free(struct mm_cache *mc, void *p)
{
 printf("Free an object to %s\n", mc -> name);
}

variable_types:
p
void *


decompiled_code:
void mm_cache_shrink()
{
;
}

canonical_decompiled_code:
void func11()
{
;
}

original_code:
void mm_cache_shrink()
{
}

canonical_original_code:
void mm_cache_shrink()
{
}


decompiled_code:
int mm_show()
{
int result; // eax
__int64 i; // rbx

if ( !head )
return puts("Memory cache is empty!");
mm_cache_show(head);
result = head;
for ( i = *(_QWORD *)(head + 312); i; i = *(_QWORD *)(i + 312) )
{
if ( head == i )
break;
result = mm_cache_show(i);
}
return result;
}

canonical_decompiled_code:
int func12()
{
int result; // eax
__int64 i; // rbx

if ( !head )
return puts("Memory cache is empty!");
func7(head);
result = head;
for ( i = *(_QWORD *)(head + 312); i; i = *(_QWORD *)(i + 312) )
{
if ( head == i )
break;
result = func7(i);
}
return result;
}

original_code:
void mm_show()
{
 if(((void *)0) == head){
  printf("Memory cache is empty!\n");
  return;
 }
 mm_cache_show(head);
 struct mm_cache *tmp = head -> next;
 while(tmp != ((void *)0) && tmp != head)
 {
  mm_cache_show(tmp);
  tmp = tmp -> next;
 }
}


repo: kernelslacker/trinity

decompiled_code:
char **__fastcall lookup_domain(char *s1)
{
char *v1; // r13
unsigned int v2; // eax
unsigned int v3; // er12
__int64 i; // rbx
const char *v5; // rbp

v1 = s1;
if ( !s1 )
return 0LL;
v2 = strlen(s1);
v3 = v2;
if ( !memcmp(s1, &unk_28A, 3uLL) )
{
v1 += 3;
v3 = v2 - 3;
}
for ( i = 0LL; i != 48; ++i )
{
v5 = (&domains)[2 * i];
if ( v3 == strlen(v5) && !strncmp(v1, v5, v3) )
return &(&domains)[2 * (unsigned int)i];
}
return 0LL;
}

canonical_decompiled_code:
char **__fastcall func0(char *s1)
{
char *v1; // r13
unsigned int v2; // eax
unsigned int v3; // er12
__int64 i; // rbx
const char *v5; // rbp

v1 = s1;
if ( !s1 )
return 0LL;
v2 = strlen(s1);
v3 = v2;
if ( !memcmp(s1, &unk_28A, 3uLL) )
{
v1 += 3;
v3 = v2 - 3;
}
for ( i = 0LL; i != 48; ++i )
{
v5 = (&domains)[2 * i];
if ( v3 == strlen(v5) && !strncmp(v1, v5, v3) )
return &(&domains)[2 * (unsigned int)i];
}
return 0LL;
}

original_code:
static const struct domain *lookup_domain(const char *name)
{
 unsigned int i, len;
 if (!name)
  return ((void *)0);
 len = strlen(name);
 if (strncmp(name, "PF_", 3) == 0) {
  name += 3;
  len-=3;
 }
 for (i = 0; i < (sizeof(domains) / sizeof((domains)[0])); i++) {
  if (len != strlen(domains[i].name))
   continue;
  if (strncmp(name, domains[i].name, len) == 0)
   return &domains[i];
 }
 return ((void *)0);
}

canonical_original_code:
static struct domain *lookup_domain(char *name)
{
 unsigned int i; unsigned int len;
 if (!name)
  return ((void *)0);
 len = strlen(name);
 if (strncmp(name, "PF_", 3) == 0) {
  name += 3;
  len-=3;
 }
 for (i = 0; i < (sizeof(domains) / sizeof((domains)[0])); i++) {
  if (len != strlen(domains[i].name))
   continue;
  if (strncmp(name, domains[i].name, len) == 0)
   return &domains[i];
 }
 return ((void *)0);
}

variable_types:
name
char *

variable_types:
len
unsigned int

return_type: struct domain { char *name; unsigned int domain; } *


decompiled_code:
char *__fastcall get_domain_name(int a1)
{
__int64 v1; // rax

v1 = 0LL;
while ( dword_4A8[4 * v1] != a1 )
{
if ( ++v1 == 48 )
return 0LL;
}
return (&domains)[2 * (unsigned int)v1];
}

canonical_decompiled_code:
char *__fastcall func1(int a1)
{
__int64 v1; // rax

v1 = 0LL;
while ( dword_4A8[4 * v1] != a1 )
{
if ( ++v1 == 48 )
return 0LL;
}
return (&domains)[2 * (unsigned int)v1];
}

original_code:
const char * get_domain_name(unsigned int domain)
{
 unsigned int i;
 for (i = 0; i < (sizeof(domains) / sizeof((domains)[0])); i++)
  if (domains[i].domain == domain)
   return domains[i].name;
 return ((void *)0);
}

canonical_original_code:
char *get_domain_name(unsigned int domain)
{
 unsigned int i;
 for (i = 0; i < (sizeof(domains) / sizeof((domains)[0])); i++)
  if (domains[i].domain == domain)
   return domains[i].name;
 return ((void *)0);
}

variable_types:
domain
unsigned int

return_type: char *


decompiled_code:
__int64 __fastcall find_specific_domain(char *a1)
{
char **v1; // rax
const char **v3; // rbx

v1 = lookup_domain(a1);
if ( !v1 )
{
outputerr("Domain unknown. Pass one of ");
v3 = (const char **)&domains;
do
{
outputerr("%s ", *v3);
v3 += 2;
}
while ( v3 != (const char **)&unk_7A0 );
outputerr("\n");
exit(1);
}
specific_domain = *((_DWORD *)v1 + 2);
return output(2LL, "Using domain %s for all sockets\n", *v1);
}

canonical_decompiled_code:
__int64 __fastcall func2(char *a1)
{
char **v1; // rax
const char **v3; // rbx

v1 = func0(a1);
if ( !v1 )
{
outputerr("Domain unknown. Pass one of ");
v3 = (const char **)&domains;
do
{
outputerr("%s ", *v3);
v3 += 2;
}
while ( v3 != (const char **)&unk_7A0 );
outputerr("\n");
exit(1);
}
specific_domain = *((_DWORD *)v1 + 2);
return output(2LL, "Using domain %s for all sockets\n", *v1);
}

original_code:
void find_specific_domain(const char *domainarg)
{
 const struct domain *p;
 unsigned int i;
 p = lookup_domain(domainarg);
 if (p) {
  specific_domain = p->domain;
  output(2, "Using domain %s for all sockets\n", p->name);
  return;
 }
 outputerr("Domain unknown. Pass one of ");
 for (i = 0; i < (sizeof(domains) / sizeof((domains)[0])); i++)
  outputerr("%s ", domains[i].name);
 outputerr("\n");
 exit(1);
}

canonical_original_code:
void find_specific_domain(char *domainarg)
{
 struct domain *p;
 unsigned int i;
 p = lookup_domain(domainarg);
 if (p) {
  specific_domain = p->domain;
  output(2, "Using domain %s for all sockets\n", p->name);
  return;
 }
 outputerr("Domain unknown. Pass one of ");
 for (i = 0; i < (sizeof(domains) / sizeof((domains)[0])); i++)
  outputerr("%s ", domains[i].name);
 outputerr("\n");
 exit(1);
}

variable_types:
domainarg
char *

variable_types: struct domain { char *name; unsigned int domain; } *


decompiled_code:
__int64 __fastcall find_next_enabled_domain(unsigned int a1)
{
unsigned int v1; // ecx
__int64 v2; // rax
unsigned int v3; // edx
__int64 v4; // rax

v1 = a1 % 0x2D;
v2 = a1 % 0x2D;
while ( 1 )
{
v3 = *((_DWORD *)&no_domains + v2);
if ( !v3 )
break;
if ( (unsigned int)++v2 > 0x2C )
{
if ( !v1 )
return (unsigned int)-1;
v4 = 0LL;
while ( 1 )
{
v3 = *((_DWORD *)&no_domains + v4);
if ( !v3 )
break;
if ( ++v4 == v1 )
return (unsigned int)-1;
}
return v3;
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
unsigned int v1; // ecx
__int64 v2; // rax
unsigned int v3; // edx
__int64 v4; // rax

v1 = a1 % 0x2D;
v2 = a1 % 0x2D;
while ( 1 )
{
v3 = *((_DWORD *)&no_domains + v2);
if ( !v3 )
break;
if ( (unsigned int)++v2 > 0x2C )
{
if ( !v1 )
return (unsigned int)-1;
v4 = 0LL;
while ( 1 )
{
v3 = *((_DWORD *)&no_domains + v4);
if ( !v3 )
break;
if ( ++v4 == v1 )
return (unsigned int)-1;
}
return v3;
}
}
return v3;
}

original_code:
unsigned int find_next_enabled_domain(unsigned int from)
{
 unsigned int i;
 from %= (sizeof(no_domains) / sizeof((no_domains)[0]));
 for (i = from; i < (sizeof(no_domains) / sizeof((no_domains)[0])); i++) {
  if (no_domains[i] == FALSE)
   return no_domains[i];
 }
 for (i = 0; i < from; i++) {
  if (no_domains[i] == FALSE)
   return no_domains[i];
 }
 return -1u;
}

variable_types:
from
unsigned int

return_type: unsigned int


decompiled_code:
void __fastcall parse_exclude_domains(const char *a1)
{
char *v2; // rax
char *v3; // rbx
char *i; // rdi
char **v5; // rax
unsigned int v6; // eax

v2 = strdup(a1);
if ( !v2 )
{
outputerr("No free memory\n");
exit(1);
}
v3 = v2;
for ( i = strtok(v2, ","); i; i = strtok(0LL, ",") )
{
v5 = lookup_domain(i);
if ( !v5 )
{
free(v3);
outputerr("Domain unknown in argument %s\n", a1);
exit(1);
}
v6 = *((_DWORD *)v5 + 2);
if ( v6 > 0x2C )
{
_BUG(
"p->domain >= (sizeof(no_domains) / sizeof((no_domains)[0]))",
"net/domains.c",
"parse_exclude_domains",
156LL);
while ( 1 )
;
}
*((_DWORD *)&no_domains + v6) = 1;
}
free(v3);
}

canonical_decompiled_code:
void __fastcall func4(const char *a1)
{
char *v2; // rax
char *v3; // rbx
char *i; // rdi
char **v5; // rax
unsigned int v6; // eax

v2 = strdup(a1);
if ( !v2 )
{
outputerr("No free memory\n");
exit(1);
}
v3 = v2;
for ( i = strtok(v2, ","); i; i = strtok(0LL, ",") )
{
v5 = func0(i);
if ( !v5 )
{
free(v3);
outputerr("Domain unknown in argument %s\n", a1);
exit(1);
}
v6 = *((_DWORD *)v5 + 2);
if ( v6 > 0x2C )
{
_BUG(
"p->domain >= (sizeof(no_domains) / sizeof((no_domains)[0]))",
"net/domains.c",
"parse_exclude_domains",
156LL);
while ( 1 )
;
}
*((_DWORD *)&no_domains + v6) = 1;
}
free(v3);
}

original_code:
void parse_exclude_domains(const char *arg)
{
 char *_arg = strdup(arg);
 const struct domain *p;
 char *tok;
 if (!_arg) {
  outputerr("No free memory\n");
  exit(1);
 }
 for (tok = strtok(_arg, ","); tok; tok = strtok(((void *)0), ",")) {
  p = lookup_domain(tok);
  if (p) {
   do { if ((p->domain >= (sizeof(no_domains) / sizeof((no_domains)[0])))) { __BUG("p->domain >= (sizeof(no_domains) / sizeof((no_domains)[0]))", "net/domains.c", __func__, 156); do { } while (1); }; } while (0);
   no_domains[p->domain] = TRUE;
  } else
   goto err;
 }
 free(_arg);
 return;
err:
 free(_arg);
 outputerr("Domain unknown in argument %s\n", arg);
 exit(1);
}

canonical_original_code:
void parse_exclude_domains(char *arg)
{
 char *_arg = strdup(arg);
 struct domain *p;
 char *tok;
 if (!_arg) {
  outputerr("No free memory\n");
  exit(1);
 }
 for (tok = strtok(_arg, ","); tok; tok = strtok(((void *)0), ",")) {
  p = lookup_domain(tok);
  if (p) {
   do { if ((p->domain >= (sizeof(no_domains) / sizeof((no_domains)[0])))) { __BUG("p->domain >= (sizeof(no_domains) / sizeof((no_domains)[0]))", "net/domains.c", __func__, 156); do { } while (1); }; } while (0);
   no_domains[p->domain] = TRUE;
  } else
   goto err;
 }
 free(_arg);
 return;
err:
 free(_arg);
 outputerr("Domain unknown in argument %s\n", arg);
 exit(1);
}

variable_types:
arg
char *

variable_types:
tok
char *

user_defined_types: struct domain { char *name; unsigned int domain; }


decompiled_code:
__int64 __fastcall get_interesting_8bit_value(__int64 a1, __int64 a2)
{
int v2; // eax
unsigned int v3; // edx

v2 = (int)((__int64 (*)(void))rnd)() % 5;
if ( v2 == 2 )
return (unsigned int)(1 << (((__int64 (*)(void))rnd)() & 7));
if ( v2 > 2 )
{
v3 = 0;
if ( v2 == 3 )
v3 = rnd(a1, a2, 0LL);
}
else
{
v3 = 1;
if ( v2 )
{
LOBYTE(v3) = v2 == 1;
v3 = -v3;
}
}
return v3;
}

original_code:
static unsigned char get_interesting_8bit_value(void)
{
 switch (rnd() % 5) {
 case 0: return 1;
 case 1: return 0xff;
 case 2: return 1UL << (rnd() & 7);
 case 3: return (rnd() & 0xff);
 default: return 0;
 }
}

canonical_original_code:
static unsigned char get_interesting_8bit_value()
{
 switch (rnd() % 5) {
 case 0: return 1;
 case 1: return 0xff;
 case 2: return 1UL << (rnd() & 7);
 case 3: return (rnd() & 0xff);
 default: return 0;
 }
}

return_type: unsigned char


decompiled_code:
__int16 __fastcall get_interesting_16bit_value(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // eax
__int64 v4; // rdx
int v5; // eax
int v6; // eax

v3 = rnd(a1, a2, a3);
v4 = v3;
v5 = (int)v3 % 4;
if ( v5 == 1 )
{
LOWORD(v6) = rnd(a1, a2, v4);
}
else if ( v5 == 2 )
{
LOWORD(v6) = rnd(a1, a2, v4) | 0xFF00;
}
else
{
LOWORD(v6) = -1;
if ( (v4 & 3) == 0 )
v6 = 0x8000 >> (rnd(a1, a2, v4) & 7);
}
return v6;
}

original_code:
static unsigned short get_interesting_16bit_value(void)
{
 switch (rnd() % 4) {
 case 0: return 0x8000 >> (rnd() & 7);
 case 1: return rnd() & 0xffff;
 case 2: return 0xff00 | (rnd() & 0xff);
 default: return 0xffff;
 }
}

canonical_original_code:
static unsigned short get_interesting_16bit_value()
{
 switch (rnd() % 4) {
 case 0: return 0x8000 >> (rnd() & 7);
 case 1: return rnd() & 0xffff;
 case 2: return 0xff00 | (rnd() & 0xff);
 default: return 0xffff;
 }
}

return_type: unsigned short


decompiled_code:
__int64 __fastcall get_interesting_32bit_value(__int64 a1, __int64 a2, __int64 a3)
{
int v3; // eax
__int64 v4; // rdx
__int64 result; // rax

v3 = rnd(a1, a2, a3);
v4 = (unsigned int)(10 * (v3 / 10));
switch ( v3 % 10 )
{
case 0:
result = 0x80000000 >> rnd(a1, a2, v4);
break;
case 1:
result = rnd(a1, a2, v4);
break;
case 2:
result = (unsigned int)(255 << (4 * ((int)rnd(a1, a2, v4) % 7)));
break;
case 3:
result = 4294901760LL;
break;
case 4:
result = 4294959104LL;
break;
case 5:
result = (unsigned __int8)rnd(a1, a2, v4) | 0xFFFFFF00;
break;
case 6:
result = (unsigned int)~page_size;
break;
case 7:
result = page_size;
break;
case 8:
result = page_size * ((unsigned int)rnd(a1, a2, v4) % (0xFFFFFFFF / page_size) + 1);
break;
default:
result = 0xFFFFFFFFLL;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3)
{
int v3; // eax
__int64 v4; // rdx
__int64 result; // rax

v3 = rnd(a1, a2, a3);
v4 = (unsigned int)(10 * (v3 / 10));
switch ( v3 % 10 )
{
case 0:
result = 0x80000000 >> rnd(a1, a2, v4);
break;
case 1:
result = rnd(a1, a2, v4);
break;
case 2:
result = (unsigned int)(255 << (4 * ((int)rnd(a1, a2, v4) % 7)));
break;
case 3:
result = 4294901760LL;
break;
case 4:
result = 4294959104LL;
break;
case 5:
result = (unsigned __int8)rnd(a1, a2, v4) | 0xFFFFFF00;
break;
case 6:
result = (unsigned int)~page_size;
break;
case 7:
result = page_size;
break;
case 8:
result = page_size * ((unsigned int)rnd(a1, a2, v4) % (0xFFFFFFFF / page_size) + 1);
break;
default:
result = 0xFFFFFFFFLL;
break;
}
return result;
}

original_code:
static unsigned int get_interesting_32bit_value(void)
{
 switch (rnd() % 10) {
 case 0: return 0x80000000 >> (rnd() & 0x1f);
 case 1: return rnd();
 case 2: return (unsigned int) 0xff << (4 * (rnd() % 7));
 case 3: return 0xffff0000;
 case 4: return 0xffffe000;
 case 5: return 0xffffff00 | (rnd() & 0xff);
 case 6: return 0xffffffff - page_size;
 case 7: return page_size;
 case 8: return page_size * ((rnd() % (0xffffffff/page_size)) + 1);
 default: return 0xffffffff;
 }
}

canonical_original_code:
static unsigned int get_interesting_32bit_value()
{
 switch (rnd() % 10) {
 case 0: return 0x80000000 >> (rnd() & 0x1f);
 case 1: return rnd();
 case 2: return (unsigned int) 0xff << (4 * (rnd() % 7));
 case 3: return 0xffff0000;
 case 4: return 0xffffe000;
 case 5: return 0xffffff00 | (rnd() & 0xff);
 case 6: return 0xffffffff - page_size;
 case 7: return page_size;
 case 8: return page_size * ((rnd() % (0xffffffff/page_size)) + 1);
 default: return 0xffffffff;
 }
}


decompiled_code:
__int64 __fastcall plus_minus_two(__int64 a1, __int64 a2, __int64 a3)
{
int v3; // eax
char v4; // dl
int v5; // eax
unsigned int v6; // ecx

v3 = rnd(a1, a2, a3);
v4 = v3;
v5 = v3 % 4;
if ( v5 == 2 )
return (unsigned int)(a1 + 1);
v6 = a1 + 2;
if ( v5 <= 2 )
{
v6 = a1 - 2;
if ( (v4 & 3) != 0 )
{
if ( v5 == 1 )
v6 = a1 - 1;
else
v6 = a1;
}
}
return v6;
}

original_code:
static unsigned int plus_minus_two(unsigned int num)
{
 switch (rnd() % 4) {
 case 0: num -= 2;
  break;
 case 1: num -= 1;
  break;
 case 2: num += 1;
  break;
 case 3: num += 2;
  break;
 }
 return num;
}

variable_types:
num
unsigned int


decompiled_code:
__int64 __fastcall get_interesting_value(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // eax
__int64 v4; // rdx
int v5; // eax
__int64 v6; // rbx
__int64 v7; // rdx

v3 = rnd(a1, a2, a3);
v4 = v3;
v5 = (int)v3 % 3;
if ( v5 == 1 )
{
v6 = (unsigned __int16)get_interesting_16bit_value(a1, a2, v4);
}
else if ( v5 == 2 )
{
v6 = (unsigned int)get_interesting_32bit_value(a1, a2, v4);
}
else
{
v6 = 0LL;
if ( !v5 )
v6 = (unsigned __int8)get_interesting_8bit_value(a1, a2);
}
if ( (rnd(a1, a2, v4) & 0xF) == 0 )
v6 = (unsigned int)plus_minus_two((unsigned int)v6, a2, v7);
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // eax
__int64 v4; // rdx
int v5; // eax
__int64 v6; // rbx
__int64 v7; // rdx

v3 = rnd(a1, a2, a3);
v4 = v3;
v5 = (int)v3 % 3;
if ( v5 == 1 )
{
v6 = (unsigned __int16)func1(a1, a2, v4);
}
else if ( v5 == 2 )
{
v6 = (unsigned int)func2(a1, a2, v4);
}
else
{
v6 = 0LL;
if ( !v5 )
v6 = (unsigned __int8)func0(a1, a2);
}
if ( (rnd(a1, a2, v4) & 0xF) == 0 )
v6 = (unsigned int)func3((unsigned int)v6, a2, v7);
return v6;
}

original_code:
unsigned long get_interesting_value(void)
{
 unsigned long low = 0;
 switch (rnd() % 3) {
 case 0: low = get_interesting_8bit_value();
  break;
 case 1: low = get_interesting_16bit_value();
  break;
 case 2: low = get_interesting_32bit_value();
  break;
 }
 low = (rnd() & 0xf) ? low : plus_minus_two(low);
 return low;
}

canonical_original_code:
unsigned long get_interesting_value()
{
 unsigned long low = 0;
 switch (rnd() % 3) {
 case 0: low = get_interesting_8bit_value();
  break;
 case 1: low = get_interesting_16bit_value();
  break;
 case 2: low = get_interesting_32bit_value();
  break;
 }
 low = (rnd() & 0xf) ? low : plus_minus_two(low);
 return low;
}

variable_types:
low
unsigned long

return_type: unsigned long


decompiled_code:
void dump_stats()
{
unsigned int i; // ebx
unsigned int v1; // ebx
unsigned int v2; // ebx

if ( biarch == 1 )
{
puts("32bit:");
if ( max_nr_32bit_syscalls )
{
v1 = 0;
do
dump_entry(syscalls_32bit, v1++);
while ( max_nr_32bit_syscalls > v1 );
}
puts("64bit:");
if ( max_nr_64bit_syscalls )
{
v2 = 0;
do
dump_entry(syscalls_64bit, v2++);
while ( max_nr_64bit_syscalls > v2 );
}
}
else
{
for ( i = 0; max_nr_syscalls > i; ++i )
dump_entry(syscalls, i);
}
}

canonical_decompiled_code:
void func1()
{
unsigned int i; // ebx
unsigned int v1; // ebx
unsigned int v2; // ebx

if ( biarch == 1 )
{
puts("32bit:");
if ( max_nr_32bit_syscalls )
{
v1 = 0;
do
func0(syscalls_32bit, v1++);
while ( max_nr_32bit_syscalls > v1 );
}
puts("64bit:");
if ( max_nr_64bit_syscalls )
{
v2 = 0;
do
func0(syscalls_64bit, v2++);
while ( max_nr_64bit_syscalls > v2 );
}
}
else
{
for ( i = 0; max_nr_syscalls > i; ++i )
func0(syscalls, i);
}
}

original_code:
void dump_stats(void)
{
 unsigned int i;
 if (biarch == TRUE) {
  printf("32bit:\n");
  for (i = 0; i < max_nr_32bit_syscalls; i++) {
   dump_entry(syscalls_32bit, i);
  }
  printf("64bit:\n");
  for (i = 0; i < max_nr_64bit_syscalls; i++) {
   dump_entry(syscalls_64bit, i);
  }
 } else {
  for (i = 0; i < max_nr_syscalls; i++) {
   dump_entry(syscalls, i);
  }
 }
}

canonical_original_code:
void dump_stats()
{
 unsigned int i;
 if (biarch == TRUE) {
  printf("32bit:\n");
  for (i = 0; i < max_nr_32bit_syscalls; i++) {
   dump_entry(syscalls_32bit, i);
  }
  printf("64bit:\n");
  for (i = 0; i < max_nr_64bit_syscalls; i++) {
   dump_entry(syscalls_64bit, i);
  }
 } else {
  for (i = 0; i < max_nr_syscalls; i++) {
   dump_entry(syscalls, i);
  }
 }
}

variable_types:
i
unsigned int


decompiled_code:
__int64 register_random_grp()
{
return register_ioctl_group(&random_grp);
}

canonical_decompiled_code:
__int64 func0()
{
return register_ioctl_group(&random_grp);
}

original_code: static void __attribute__((constructor)) register_random_grp(void) { register_ioctl_group(&random_grp); }

canonical_original_code: static void register_random_grp() { register_ioctl_group(&random_grp); }


decompiled_code:
__int64 random_ioctl_arg()
{
__int64 v1; // rbx

if ( (rnd() & 1) != 0 )
return rand64();
v1 = get_writable_address(page_size);
generate_random_page(v1);
return v1;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v1; // rbx

if ( (rnd() & 1) != 0 )
return rand64();
v1 = get_writable_address(page_size);
generate_random_page(v1);
return v1;
}

original_code:
static unsigned long random_ioctl_arg(void)
{
 if ((rnd() & 1)) {
  return (unsigned long) rand64();
 } else {
  void *page;
  page = get_writable_address(page_size);
  generate_random_page(page);
  return (unsigned long) page;
 }
}

canonical_original_code:
static unsigned long random_ioctl_arg()
{
 if ((rnd() & 1)) {
  return (unsigned long) rand64();
 } else {
  void *page;
  page = get_writable_address(page_size);
  generate_random_page(page);
  return (unsigned long) page;
 }
}

variable_types:
page
void *


decompiled_code:
void dump_ioctls()
{
__int64 v0; // rbp
int v1; // eax
__int64 v2; // rdx
unsigned __int64 i; // rbx
__int64 v4; // rax
const char *v5; // rdx
__int64 v6; // rax
__int64 v7; // rax
const char *v8; // rdx
unsigned __int64 v9; // rbx
const char *v10; // rsi
__int64 v11; // rax

if ( grps_cnt > 0 )
{
v0 = 0LL;
do
{
v6 = grps[v0];
if ( *(_QWORD *)v6 )
{
outputerr("- %s:\n", *(const char **)v6);
}
else
{
v1 = *(_DWORD *)(v6 + 32);
if ( v1 )
{
switch ( v1 )
{
case 3:
outputerr("- misc devices");
break;
case 1:
outputerr("- char devices");
break;
case 2:
outputerr("- block devices");
break;
}
v7 = grps[v0];
if ( *(_QWORD *)(v7 + 48) )
{
v8 = **(const char ***)(v7 + 40);
v9 = 0LL;
v10 = (const char *)&unk_648;
while ( 1 )
{
outputerr("%s '%s'", v10, v8);
++v9;
v11 = grps[v0];
if ( *(_QWORD *)(v11 + 48) <= v9 )
break;
v8 = *(const char **)(*(_QWORD *)(v11 + 40) + 8 * v9);
v10 = ",";
if ( !v9 )
v10 = (const char *)&unk_648;
}
}
outputerr(":\n");
}
else
{
outputerr("- <unknown>:\n");
}
}
v2 = grps[v0];
for ( i = 0LL; *(_QWORD *)(v2 + 24) > i; v2 = grps[v0] )
{
v4 = *(_QWORD *)(v2 + 16) + 16 * i;
v5 = *(const char **)v4;
if ( !*(_QWORD *)v4 )
v5 = (const char *)&unk_648;
outputerr(" - 0x%08x : %s\n", *(unsigned int *)(v4 + 8), v5);
++i;
}
++v0;
}
while ( grps_cnt > (int)v0 );
}
}

canonical_decompiled_code:
void func6()
{
__int64 v0; // rbp
int v1; // eax
__int64 v2; // rdx
unsigned __int64 i; // rbx
__int64 v4; // rax
const char *v5; // rdx
__int64 v6; // rax
__int64 v7; // rax
const char *v8; // rdx
unsigned __int64 v9; // rbx
const char *v10; // rsi
__int64 v11; // rax

if ( grps_cnt > 0 )
{
v0 = 0LL;
do
{
v6 = grps[v0];
if ( *(_QWORD *)v6 )
{
outputerr("- %s:\n", *(const char **)v6);
}
else
{
v1 = *(_DWORD *)(v6 + 32);
if ( v1 )
{
switch ( v1 )
{
case 3:
outputerr("- misc devices");
break;
case 1:
outputerr("- char devices");
break;
case 2:
outputerr("- block devices");
break;
}
v7 = grps[v0];
if ( *(_QWORD *)(v7 + 48) )
{
v8 = **(const char ***)(v7 + 40);
v9 = 0LL;
v10 = (const char *)&unk_648;
while ( 1 )
{
outputerr("%s '%s'", v10, v8);
++v9;
v11 = grps[v0];
if ( *(_QWORD *)(v11 + 48) <= v9 )
break;
v8 = *(const char **)(*(_QWORD *)(v11 + 40) + 8 * v9);
v10 = ",";
if ( !v9 )
v10 = (const char *)&unk_648;
}
}
outputerr(":\n");
}
else
{
outputerr("- <unknown>:\n");
}
}
v2 = grps[v0];
for ( i = 0LL; *(_QWORD *)(v2 + 24) > i; v2 = grps[v0] )
{
v4 = *(_QWORD *)(v2 + 16) + 16 * i;
v5 = *(const char **)v4;
if ( !*(_QWORD *)v4 )
v5 = (const char *)&unk_648;
outputerr(" - 0x%08x : %s\n", *(unsigned int *)(v4 + 8), v5);
++i;
}
++v0;
}
while ( grps_cnt > (int)v0 );
}
}

original_code:
void dump_ioctls(void)
{
 int i;
 size_t j;
 for (i=0; i < grps_cnt; ++i) {
  if (grps[i]->name)
   outputerr("- %s:\n", grps[i]->name);
  else if (grps[i]->devtype) {
   if (grps[i]->devtype == 3)
    outputerr("- misc devices");
   else if (grps[i]->devtype == 1)
    outputerr("- char devices");
   else if (grps[i]->devtype == 2)
    outputerr("- block devices");
   for (j=0; j < grps[i]->devs_cnt; ++j)
    outputerr("%s '%s'",
     j == 0 ? "" : ",",
     grps[i]->devs[j]);
   outputerr(":\n");
  } else
   outputerr("- <unknown>:\n");
  for (j=0; j < grps[i]->ioctls_cnt; ++j) {
   outputerr("  - 0x%08x : %s\n",
     grps[i]->ioctls[j].request,
     grps[i]->ioctls[j].name ? : "");
  }
 }
}

canonical_original_code:
void dump_ioctls()
{
 int i;
 unsigned long j;
 for (i=0; i < grps_cnt; ++i) {
  if (grps[i]->name)
   outputerr("- %s:\n", grps[i]->name);
  else if (grps[i]->devtype) {
   if (grps[i]->devtype == 3)
    outputerr("- misc devices");
   else if (grps[i]->devtype == 1)
    outputerr("- char devices");
   else if (grps[i]->devtype == 2)
    outputerr("- block devices");
   for (j=0; j < grps[i]->devs_cnt; ++j)
    outputerr("%s '%s'",
     j == 0 ? "" : ",",
     grps[i]->devs[j]);
   outputerr(":\n");
  } else
   outputerr("- <unknown>:\n");
  for (j=0; j < grps[i]->ioctls_cnt; ++j) {
   outputerr("  - 0x%08x : %s\n",
     grps[i]->ioctls[j].request,
     grps[i]->ioctls[j].name ? : "");
  }
 }
}

variable_types: i int

variable_types:
j
unsigned long


decompiled_code:
__int64 register_vsock_grp()
{
return register_ioctl_group(&vsock_grp);
}

canonical_decompiled_code:
__int64 func0()
{
return register_ioctl_group(&vsock_grp);
}

original_code: static void __attribute__((constructor)) register_vsock_grp(void) { register_ioctl_group(&vsock_grp); }

canonical_original_code: static void register_vsock_grp() { register_ioctl_group(&vsock_grp); }


decompiled_code:
__int64 register_sisfb_grp()
{
return register_ioctl_group(&sisfb_grp);
}

canonical_decompiled_code:
__int64 func0()
{
return register_ioctl_group(&sisfb_grp);
}

original_code: static void __attribute__((constructor)) register_sisfb_grp(void) { register_ioctl_group(&sisfb_grp); }

canonical_original_code: static void register_sisfb_grp() { register_ioctl_group(&sisfb_grp); }


decompiled_code:
__int64 __fastcall do_random_sso(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
__int64 v3; // rdx
__int64 result; // rax
__int64 v5; // rax
__int64 (__fastcall *v6)(__int64, __int64); // rax
__int64 v7; // rdx

while ( 1 )
{
v2 = ((__int64 (*)(void))rnd)();
v3 = v2;
result = (unsigned int)((int)v2 % 4);
if ( (_DWORD)result == 2 )
return socket_setsockopt(a1);
if ( (int)result > 2 )
{
*(_DWORD *)a1 = rnd(a1, a2, v3);
result = (unsigned __int8)rnd(a1, a2, v7);
*(_QWORD *)(a1 + 8) = (unsigned __int8)result;
return result;
}
if ( (v3 & 3) != 0 )
break;
v5 = net_protocols[(int)rnd(a1, a2, v3) % 45];
if ( v5 )
{
v6 = *(__int64 (__fastcall **)(__int64, __int64))(v5 + 32);
if ( v6 )
return v6(a1, a2);
}
}
if ( (_DWORD)result == 1 )
result = (*(__int64 (__fastcall **)(__int64, __int64))(net_protocols[2] + 32LL))(a1, a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
__int64 v3; // rdx
__int64 result; // rax
__int64 v5; // rax
__int64 (__fastcall *v6)(__int64, __int64); // rax
__int64 v7; // rdx

while ( 1 )
{
v2 = ((__int64 (*)(void))rnd)();
v3 = v2;
result = (unsigned int)((int)v2 % 4);
if ( (_DWORD)result == 2 )
return func0(a1);
if ( (int)result > 2 )
{
*(_DWORD *)a1 = rnd(a1, a2, v3);
result = (unsigned __int8)rnd(a1, a2, v7);
*(_QWORD *)(a1 + 8) = (unsigned __int8)result;
return result;
}
if ( (v3 & 3) != 0 )
break;
v5 = net_protocols[(int)rnd(a1, a2, v3) % 45];
if ( v5 )
{
v6 = *(__int64 (__fastcall **)(__int64, __int64))(v5 + 32);
if ( v6 )
return v6(a1, a2);
}
}
if ( (_DWORD)result == 1 )
result = (*(__int64 (__fastcall **)(__int64, __int64))(net_protocols[2] + 32LL))(a1, a2);
return result;
}

original_code:
static void do_random_sso(struct sockopt *so, struct socket_triplet *triplet)
{
 unsigned int i;
 const struct netproto *proto;
retry:
 switch (rnd() % 4) {
 case 0:
  i = rnd() % 45;
  proto = net_protocols[i].proto;
  if (proto != ((void *)0)) {
   if (proto->setsockopt != ((void *)0)) {
    proto->setsockopt(so, triplet);
    return;
   }
  }
  goto retry;
 case 1:
  proto = net_protocols[2].proto;
  proto->setsockopt(so, triplet);
  break;
 case 2:
  socket_setsockopt(so, triplet);
  break;
 case 3:
  so->level = rnd();
  so->optname = (rnd() & 0xff);
  break;
 }
}

canonical_original_code:
static void do_random_sso(struct sockopt *so, struct socket_triplet *triplet)
{
 unsigned int i;
 struct netproto *proto;
retry:
 switch (rnd() % 4) {
 case 0:
  i = rnd() % 45;
  proto = net_protocols[i].proto;
  if (proto != ((void *)0)) {
   if (proto->setsockopt != ((void *)0)) {
    proto->setsockopt(so, triplet);
    return;
   }
  }
  goto retry;
 case 1:
  proto = net_protocols[2].proto;
  proto->setsockopt(so, triplet);
  break;
 case 2:
  socket_setsockopt(so, triplet);
  break;
 case 3:
  so->level = rnd();
  so->optname = (rnd() & 0xff);
  break;
 }
}

variable_types: struct netproto { char *name; struct socket_triplet { unsigned int family; unsigned int type; unsigned int protocol; } *valid_triplets; struct socket_triplet *valid_privileged_triplets; void (*socket_setup)(int fd); void (*setsockopt)(struct sockopt { unsigned int level; unsigned long optname; unsigned long optval; unsigned long optlen; } *so, struct socket_triplet *triplet); void (*gen_sockaddr)(struct sockaddr { unsigned short sa_family; char sa_data[14]; } **addr, unsigned int *addrlen); void (*gen_packet)(struct socket_triplet *st, void **ptr, unsigned long *len); unsigned int nr_triplets; unsigned int nr_privileged_triplets; } *

user_defined_types: struct netproto { char *name; struct socket_triplet *valid_triplets; struct socket_triplet *valid_privileged_triplets; void (*socket_setup)(int fd); void (*setsockopt)(struct sockopt *so, struct socket_triplet *triplet); void (*gen_sockaddr)(struct sockaddr **addr, unsigned int *addrlen); void (*gen_packet)(struct socket_triplet *st, void **ptr, unsigned long *len); unsigned int nr_triplets; unsigned int nr_privileged_triplets; }


decompiled_code:
__int64 __fastcall call_sso_ptr(__int64 a1, unsigned int *a2)
{
__int64 v2; // rax
__int64 (*v3)(void); // rax
__int64 result; // rax

v2 = net_protocols[*a2];
if ( v2 && (v3 = *(__int64 (**)(void))(v2 + 32)) != 0LL )
result = v3();
else
result = do_random_sso(a1, (__int64)a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int *a2)
{
__int64 v2; // rax
__int64 (*v3)(void); // rax
__int64 result; // rax

v2 = net_protocols[*a2];
if ( v2 && (v3 = *(__int64 (**)(void))(v2 + 32)) != 0LL )
result = v3();
else
result = func1(a1, (__int64)a2);
return result;
}

original_code:
static void call_sso_ptr(struct sockopt *so, struct socket_triplet *triplet)
{
 const struct netproto *proto;
 proto = net_protocols[triplet->family].proto;
 if (proto != ((void *)0)) {
  if (proto->setsockopt != ((void *)0)) {
   proto->setsockopt(so, triplet);
   return;
  }
 }
 do_random_sso(so, triplet);
}

canonical_original_code:
static void call_sso_ptr(struct sockopt *so, struct socket_triplet *triplet)
{
 struct netproto *proto;
 proto = net_protocols[triplet->family].proto;
 if (proto != ((void *)0)) {
  if (proto->setsockopt != ((void *)0)) {
   proto->setsockopt(so, triplet);
   return;
  }
 }
 do_random_sso(so, triplet);
}

variable_types: struct sockopt { unsigned int level; unsigned long optname; unsigned long optval; unsigned long optlen; } *

variable_types: struct socket_triplet { unsigned int family; unsigned int type; unsigned int protocol; } *

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


sockoptlen

decompiled_code:
__int64 __fastcall sockoptlen(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = (unsigned int)a1;
if ( !(_DWORD)a1 )
result = (rnd(a1, a2, a3) & 1) == 0 ? 4 : 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = (unsigned int)a1;
if ( !(_DWORD)a1 )
result = (rnd(a1, a2, a3) & 1) == 0 ? 4 : 1;
return result;
}

original_code:
unsigned int sockoptlen(unsigned int len)
{
 if (len != 0)
  return len;
 if ((rnd() & 1))
  return sizeof(char);
 else
  return sizeof(int);
}


decompiled_code:
void __fastcall do_setsockopt(__int64 a1, unsigned int *a2, __int64 a3)
{
int v3; // eax
__int64 v4; // rdx
__int64 v5; // rdx
int v6; // eax
__int64 v7; // rdx
unsigned int v8; // eax
__int64 v9; // rdx
int v10; // eax

*(_QWORD *)(a1 + 8) = 0LL;
v3 = rnd(a1, a2, a3);
if ( v3 == 10 * (v3 / 10) )
{
socket_setsockopt(a1);
}
else
{
*(_QWORD *)(a1 + 16) = _zmalloc(page_size, "do_setsockopt");
*(_QWORD *)(a1 + 24) = (unsigned int)sockoptlen(0LL, (__int64)"do_setsockopt", v4);
v6 = rnd(0LL, "do_setsockopt", v5);
if ( v6 == 100 * (v6 / 100) )
{
do_random_sso(a1, (__int64)a2);
}
else if ( a2 )
{
call_sso_ptr(a1, a2);
}
else
{
a2 = 0LL;
do_random_sso(a1, 0LL);
}
v8 = rnd(a1, a2, v7);
v9 = v8;
if ( v8 == 10 * ((int)v8 / 10) )
{
v10 = rnd(a1, a2, v8);
v9 = (unsigned int)(v10 >> 31) >> 27;
*(_QWORD *)(a1 + 8) |= 1LL << (v10 % 32);
}
if ( (rnd(a1, a2, v9) & 1) != 0 )
{
free(*(void **)(a1 + 16));
*(_QWORD *)(a1 + 16) = 0LL;
}
}
}

original_code:
void do_setsockopt(struct sockopt *so, struct socket_triplet *triplet)
{
 so->optname = 0;
 if (((rnd() % 10) == 0)) {
  socket_setsockopt(so, triplet);
  return;
 }
 so->optval = (unsigned long) __zmalloc(page_size, __func__);
 so->optlen = sockoptlen(0);
 if (((rnd() % 100) == 0)) {
  do_random_sso(so, triplet);
 } else {
  if (triplet != ((void *)0)) {
   call_sso_ptr(so, triplet);
  } else {
   do_random_sso(so, triplet);
  }
 }
 if (((rnd() % 10) == 0))
  so->optname |= (1UL << (rnd() % 32));
 if ((rnd() & 1)) {
  free((void *) so->optval);
  so->optval = 0;
 }
}

user_defined_types: struct sockopt { unsigned int level; unsigned long optname; unsigned long optval; unsigned long optlen; }

user_defined_types: struct socket_triplet { unsigned int family; unsigned int type; unsigned int protocol; }


decompiled_code:
void use_fpu()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
static void use_fpu(void)
{
 double x = 0;
 asm volatile("":"+m" (x));
 x += 1;
 asm volatile("":"+m" (x));
}

canonical_original_code:
static void use_fpu()
{
 double x = 0;
 asm volatile("":"+m" (x));
 x += 1;
 asm volatile("":"+m" (x));
}

variable_types: x double


decompiled_code:
int set_make_it_fail()
{
int result; // eax
int v1; // eax
int v2; // ebx
int v3; // edi
char *v4; // rax

result = shm;
if ( *(_DWORD *)(shm + 13028LL) != 1 )
{
v1 = open("/proc/self/make-it-fail", 1);
v2 = v1;
if ( v1 == -1 )
{
result = shm;
*(_DWORD *)(shm + 13028LL) = 1;
}
else
{
if ( write(v1, "1", 1uLL) == -1 )
{
v3 = *_errno_location();
if ( v3 != 1 )
{
v4 = strerror(v3);
outputerr("writing to /proc/self/make-it-fail failed! (%s)\n", v4);
}
*(_DWORD *)(shm + 13028LL) = 1;
}
result = close(v2);
}
}
return result;
}

canonical_decompiled_code:
int func3()
{
int result; // eax
int v1; // eax
int v2; // ebx
int v3; // edi
char *v4; // rax

result = shm;
if ( *(_DWORD *)(shm + 13028LL) != 1 )
{
v1 = open("/proc/self/make-it-fail", 1);
v2 = v1;
if ( v1 == -1 )
{
result = shm;
*(_DWORD *)(shm + 13028LL) = 1;
}
else
{
if ( write(v1, "1", 1uLL) == -1 )
{
v3 = *_errno_location();
if ( v3 != 1 )
{
v4 = strerror(v3);
outputerr("writing to /proc/self/make-it-fail failed! (%s)\n", v4);
}
*(_DWORD *)(shm + 13028LL) = 1;
}
result = close(v2);
}
}
return result;
}

original_code:
static void set_make_it_fail(void)
{
 int fd;
 const char *buf = "1";
 if (shm->dont_make_it_fail == TRUE)
  return;
 fd = open("/proc/self/make-it-fail", 01);
 if (fd == -1) {
  shm->dont_make_it_fail = TRUE;
  return;
 }
 if (write(fd, buf, 1) == -1) {
  if ((*__errno_location ()) != 1)
   outputerr("writing to /proc/self/make-it-fail failed! (%s)\n", strerror((*__errno_location ())));
  shm->dont_make_it_fail = TRUE;
 }
 close(fd);
}

canonical_original_code:
static void set_make_it_fail()
{
 int fd;
 char *buf = "1";
 if (shm->dont_make_it_fail == TRUE)
  return;
 fd = open("/proc/self/make-it-fail", 01);
 if (fd == -1) {
  shm->dont_make_it_fail = TRUE;
  return;
 }
 if (write(fd, buf, 1) == -1) {
  if ((*__errno_location ()) != 1)
   outputerr("writing to /proc/self/make-it-fail failed! (%s)\n", strerror((*__errno_location ())));
  shm->dont_make_it_fail = TRUE;
 }
 close(fd);
}

variable_types: fd int

variable_types:
buf
char *


decompiled_code:
int enable_coredumps()
{
int result; // eax
struct rlimit v1; // [rsp+0h] [rbp-18h] BYREF

v1.rlim_cur = -1LL;
v1.rlim_max = -1LL;
result = shm;
if ( *(_DWORD *)(shm + 13044LL) != 1 )
{
prctl(4, 1LL);
result = setrlimit(RLIMIT_CORE, &v1);
}
return result;
}

canonical_decompiled_code:
int func4()
{
int result; // eax
struct rlimit v1; // [rsp+0h] [rbp-18h] BYREF

v1.rlim_cur = -1LL;
v1.rlim_max = -1LL;
result = shm;
if ( *(_DWORD *)(shm + 13044LL) != 1 )
{
prctl(4, 1LL);
result = setrlimit(RLIMIT_CORE, &v1);
}
return result;
}

original_code:
static void enable_coredumps(void)
{
 struct rlimit limit = {
  .rlim_cur = ((__rlim_t) -1),
  .rlim_max = ((__rlim_t) -1)
 };
 if (shm->debug == TRUE)
  return;
 prctl(4, TRUE);
 (void) setrlimit(RLIMIT_CORE, &limit);
}

canonical_original_code:
static void enable_coredumps()
{
 struct rlimit limit = {
  .rlim_cur = ((__rlim_t) -1),
  .rlim_max = ((__rlim_t) -1)
 };
 if (shm->debug == TRUE)
  return;
 prctl(4, TRUE);
 (void) setrlimit(RLIMIT_CORE, &limit);
}

variable_types: struct rlimit { unsigned long rlim_cur; unsigned long rlim_max; }


decompiled_code:
int disable_coredumps()
{
int result; // eax
struct rlimit v1; // [rsp+0h] [rbp-18h] BYREF

v1.rlim_cur = 0LL;
v1.rlim_max = 0LL;
if ( *(_DWORD *)(shm + 13044LL) == 1 )
{
signal(6, 0LL);
result = (unsigned int)signal(11, 0LL);
}
else
{
if ( setrlimit(RLIMIT_CORE, &v1) )
perror("setrlimit(RLIMIT_CORE)");
result = prctl(4, 0LL);
}
return result;
}

canonical_decompiled_code:
int func5()
{
int result; // eax
struct rlimit v1; // [rsp+0h] [rbp-18h] BYREF

v1.rlim_cur = 0LL;
v1.rlim_max = 0LL;
if ( *(_DWORD *)(shm + 13044LL) == 1 )
{
signal(6, 0LL);
result = (unsigned int)signal(11, 0LL);
}
else
{
if ( setrlimit(RLIMIT_CORE, &v1) )
perror("setrlimit(RLIMIT_CORE)");
result = prctl(4, 0LL);
}
return result;
}

original_code:
static void disable_coredumps(void)
{
 struct rlimit limit = { .rlim_cur = 0, .rlim_max = 0 };
 if (shm->debug == TRUE) {
  (void)signal(6, ((__sighandler_t) 0));
  (void)signal(11, ((__sighandler_t) 0));
  return;
 }
 if (setrlimit(RLIMIT_CORE, &limit) != 0)
  perror( "setrlimit(RLIMIT_CORE)" );
 prctl(4, FALSE);
}

canonical_original_code:
static void disable_coredumps()
{
 struct rlimit limit = { .rlim_cur = 0, .rlim_max = 0 };
 if (shm->debug == TRUE) {
  (void)signal(6, ((void (*)(int)) 0));
  (void)signal(11, ((void (*)(int)) 0));
  return;
 }
 if (setrlimit(RLIMIT_CORE, &limit) != 0)
  perror( "setrlimit(RLIMIT_CORE)" );
 prctl(4, FALSE);
}

user_defined_types: struct rlimit { unsigned long rlim_cur; unsigned long rlim_max; }


decompiled_code:
__pid_t check_parent_pid()
{
__pid_t result; // eax
int v1; // ebx
unsigned int v2; // ebp

result = getppid();
if ( mainpid != result )
{
v1 = result;
v2 = getpid();
if ( v1 != v2 )
{
if ( v1 > 1 )
{
lock(shm + 13016LL);
if ( *(_DWORD *)(shm + 13024LL) != 9 )
{
output(0LL, "BUG!: CHILD (pid:%d) GOT REPARENTED! main pid:%d. ppid=%d\n", v2, mainpid, (unsigned int)v1);
if ( !(unsigned int)pid_alive(mainpid) )
output(0LL, "main pid %d is dead.\n", mainpid);
panic(9LL);
}
unlock(shm + 13016LL);
exit(1);
}
debugf("ppid == %d. pidns? exiting child.\n", (unsigned int)v1);
exit(1);
}
debugf("pid became ppid! exiting child.\n");
exit(1);
}
return result;
}

canonical_decompiled_code:
__pid_t func8()
{
__pid_t result; // eax
int v1; // ebx
unsigned int v2; // ebp

result = getppid();
if ( mainpid != result )
{
v1 = result;
v2 = getpid();
if ( v1 != v2 )
{
if ( v1 > 1 )
{
lock(shm + 13016LL);
if ( *(_DWORD *)(shm + 13024LL) != 9 )
{
output(0LL, "BUG!: CHILD (pid:%d) GOT REPARENTED! main pid:%d. ppid=%d\n", v2, mainpid, (unsigned int)v1);
if ( !(unsigned int)pid_alive(mainpid) )
output(0LL, "main pid %d is dead.\n", mainpid);
panic(9LL);
}
unlock(shm + 13016LL);
exit(1);
}
debugf("ppid == %d. pidns? exiting child.\n", (unsigned int)v1);
exit(1);
}
debugf("pid became ppid! exiting child.\n");
exit(1);
}
return result;
}

original_code:
static void check_parent_pid(void)
{
 pid_t pid, ppid;
 ppid = getppid();
 if (ppid == mainpid)
  return;
 pid = getpid();
 if (pid == ppid) {
  debugf("pid became ppid! exiting child.\n");
  _exit(1);
 }
 if (ppid < 2) {
  debugf("ppid == %d. pidns? exiting child.\n", ppid);
  _exit(1);;
 }
 lock(&shm->buglock);
 if (shm->exit_reason == EXIT_REPARENT_PROBLEM)
  goto out;
 output(0, "BUG!: CHILD (pid:%d) GOT REPARENTED! "
  "main pid:%d. ppid=%d\n",
  pid, mainpid, ppid);
 if (pid_alive(mainpid) == FALSE)
  output(0, "main pid %d is dead.\n", mainpid);
 panic(EXIT_REPARENT_PROBLEM);
out:
 unlock(&shm->buglock);
 _exit(1);
}

canonical_original_code:
static void check_parent_pid()
{
 int pid; int ppid;
 ppid = getppid();
 if (ppid == mainpid)
  return;
 pid = getpid();
 if (pid == ppid) {
  debugf("pid became ppid! exiting child.\n");
  _exit(1);
 }
 if (ppid < 2) {
  debugf("ppid == %d. pidns? exiting child.\n", ppid);
  _exit(1);;
 }
 lock(&shm->buglock);
 if (shm->exit_reason == EXIT_REPARENT_PROBLEM)
  goto out;
 output(0, "BUG!: CHILD (pid:%d) GOT REPARENTED! "
  "main pid:%d. ppid=%d\n",
  pid, mainpid, ppid);
 if (pid_alive(mainpid) == FALSE)
  output(0, "main pid %d is dead.\n", mainpid);
 panic(EXIT_REPARENT_PROBLEM);
out:
 unlock(&shm->buglock);
 _exit(1);
}

variable_types: pid int

variable_types: ppid int


decompiled_code:
unsigned int periodic_work()
{
unsigned int result; // eax

result = periodic_counter_0 + 1;
periodic_counter_0 = result;
if ( result > 9 )
{
if ( result == 10 * (result / 0xA) )
{
result = check_parent_pid();
if ( periodic_counter_0 == 1000 )
periodic_counter_0 = 0;
}
else if ( periodic_counter_0 == 1000 )
{
periodic_counter_0 = 0;
}
}
return result;
}

canonical_decompiled_code:
unsigned int func9()
{
unsigned int result; // eax

result = periodic_counter_0 + 1;
periodic_counter_0 = result;
if ( result > 9 )
{
if ( result == 10 * (result / 0xA) )
{
result = func8();
if ( periodic_counter_0 == 1000 )
periodic_counter_0 = 0;
}
else if ( periodic_counter_0 == 1000 )
{
periodic_counter_0 = 0;
}
}
return result;
}

original_code:
static void periodic_work(void)
{
 static unsigned int periodic_counter = 0;
 periodic_counter++;
 if (periodic_counter < 10)
  return;
 if (!(periodic_counter % 10))
  check_parent_pid();
 if (periodic_counter == 1000)
  periodic_counter = 0;
}

canonical_original_code:
static void periodic_work()
{
 static unsigned int periodic_counter = 0;
 periodic_counter++;
 if (periodic_counter < 10)
  return;
 if (!(periodic_counter % 10))
  check_parent_pid();
 if (periodic_counter == 1000)
  periodic_counter = 0;
}


decompiled_code:
_BOOL8 __fastcall set_exit_code(unsigned int a1)
{
_BOOL8 result; // rax

if ( a1 > 0x10 )
result = 0LL;
else
result = ((1LL << a1) & 0x1FFBA) != 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(unsigned int a1)
{
_BOOL8 result; // rax

if ( a1 > 0x10 )
result = 0LL;
else
result = ((1LL << a1) & 0x1FFBA) != 0;
return result;
}

original_code:
static int set_exit_code(enum exit_reasons reason)
{
 int ret = 0;
 switch (reason) {
 case EXIT_NO_SYSCALLS_ENABLED:
 case EXIT_NO_FDS:
 case EXIT_LOST_CHILD:
 case EXIT_PID_OUT_OF_RANGE:
 case EXIT_KERNEL_TAINTED:
 case EXIT_SHM_CORRUPTION:
 case EXIT_REPARENT_PROBLEM:
 case EXIT_NO_FILES:
 case EXIT_MAIN_DISAPPEARED:
 case EXIT_UID_CHANGED:
 case EXIT_LOCKING_CATASTROPHE:
 case EXIT_FORK_FAILURE:
 case EXIT_FD_INIT_FAILURE:
 case EXIT_LOGFILE_OPEN_ERROR:
  ret = 1;
  break;
 default:
 case STILL_RUNNING:
 case EXIT_REACHED_COUNT:
 case EXIT_SIGINT:
 case NUM_EXIT_REASONS:
  break;
 }
 return ret;
}

variable_types: enum exit_reasons { STILL_RUNNING=0, EXIT_NO_SYSCALLS_ENABLED=1, EXIT_REACHED_COUNT=2, EXIT_NO_FDS=3, EXIT_LOST_CHILD=4, EXIT_PID_OUT_OF_RANGE=5, EXIT_SIGINT=6, EXIT_KERNEL_TAINTED=7, EXIT_SHM_CORRUPTION=8, EXIT_REPARENT_PROBLEM=9, EXIT_NO_FILES=10, EXIT_MAIN_DISAPPEARED=11, EXIT_UID_CHANGED=12, EXIT_FD_INIT_FAILURE=13, EXIT_FORK_FAILURE=14, EXIT_LOCKING_CATASTROPHE=15, EXIT_LOGFILE_OPEN_ERROR=16, NUM_EXIT_REASONS=17 }

variable_types: ret int


decompiled_code:
int change_tmp_dir()
{
int result; // eax
char file[5]; // [rsp+Bh] [rbp-9Dh] BYREF
struct stat buf; // [rsp+10h] [rbp-98h] BYREF

strcpy(file, "tmp/");
result = lstat(file, &buf);
if ( result != -1 )
{
if ( chmod(file, 0x1FFu) == -1 )
output(0LL, "Couldn't chmod %s to 0777.\n", file);
result = chdir(file);
if ( result == -1 )
result = output(0LL, "Couldn't change to %s\n", file);
}
return result;
}

canonical_decompiled_code:
int func1()
{
int result; // eax
char file[5]; // [rsp+Bh] [rbp-9Dh] BYREF
struct stat buf; // [rsp+10h] [rbp-98h] BYREF

strcpy(file, "tmp/");
result = lstat(file, &buf);
if ( result != -1 )
{
if ( chmod(file, 0x1FFu) == -1 )
output(0LL, "Couldn't chmod %s to 0777.\n", file);
result = chdir(file);
if ( result == -1 )
result = output(0LL, "Couldn't change to %s\n", file);
}
return result;
}

original_code:
static void change_tmp_dir(void)
{
 struct stat sb;
 const char tmpdir[]="tmp/";
 int ret;
 ret = (lstat(tmpdir, &sb));
 if (ret == -1)
  return;
 ret = chmod(tmpdir, 0777);
 if (ret == -1)
  output(0, "Couldn't chmod %s to 0777.\n", tmpdir);
 ret = chdir(tmpdir);
 if (ret == -1)
  output(0, "Couldn't change to %s\n", tmpdir);
}

canonical_original_code:
static void change_tmp_dir()
{
 struct stat sb;
 char tmpdir[] = "tmp/";
 int ret;
 ret = (lstat(tmpdir, &sb));
 if (ret == -1)
  return;
 ret = chmod(tmpdir, 0777);
 if (ret == -1)
  output(0, "Couldn't chmod %s to 0777.\n", tmpdir);
 ret = chdir(tmpdir);
 if (ret == -1)
  output(0, "Couldn't change to %s\n", tmpdir);
}

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types:
tmpdir
char []

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // edi
char v4[37]; // [rsp+3h] [rbp-25h] BYREF

strcpy(v4, "trinity-main");
outputstd("Trinity 2023.01 Dave Jones <davej@codemonkey.org.uk>\n", argv, envp);
progname = (__int64)*argv;
mainpid = getpid();
getrlimit(RLIMIT_NOFILE, &max_files_rlimit);
page_size = getpagesize();
num_online_cpus = sysconf(84);
max_children = 4 * num_online_cpus;
select_syscall_tables();
create_shm();
parse_args((unsigned int)argc, argv);
init_uids();
change_tmp_dir();
init_shm();
init_taint_checking();
if ( (unsigned int)munge_tables() )
{
if ( show_syscall_list == 1 )
{
dump_syscall_tables();
v3 = 0;
}
else if ( show_ioctl_list == 1 )
{
dump_ioctls();
v3 = 0;
}
else if ( show_unannotated == 1 )
{
show_unannotated_args();
v3 = 0;
}
else
{
init_syscalls();
do_uid0_check();
if ( do_specific_domain == 1 )
find_specific_domain(specific_domain_optarg);
pids_init();
init_logging();
init_object_lists(1LL);
setup_initial_mappings();
parse_devices();
create_futexes();
create_sysv_shms();
setup_main_signals();
LOBYTE(no_bind_to_cpu) = rnd() & 1;
no_bind_to_cpu = (unsigned __int8)no_bind_to_cpu;
prctl(15, v4);
if ( !(unsigned int)open_fds() )
{
if ( *(_DWORD *)(shm + 13024LL) )
panic(13LL);
exit(1);
}
setup_ftrace();
main_loop();
destroy_global_objects();
if ( (unsigned int)is_tainted() == 1 )
stop_ftrace();
output(
0LL,
"Ran %ld syscalls. Successes: %ld Failures: %ld\n",
*(_QWORD *)(shm + 8LL),
*(_QWORD *)(shm + 16LL),
*(_QWORD *)(shm + 24LL));
if ( show_stats == 1 )
dump_stats();
shutdown_logging();
v3 = set_exit_code(*(_DWORD *)(shm + 13024LL));
}
}
else
{
v3 = 1;
}
exit(v3);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // edi
char v4[37]; // [rsp+3h] [rbp-25h] BYREF

strcpy(v4, "trinity-main");
outputstd("Trinity 2023.01 Dave Jones <davej@codemonkey.org.uk>\n", argv, envp);
progname = (__int64)*argv;
mainpid = getpid();
getrlimit(RLIMIT_NOFILE, &max_files_rlimit);
page_size = getpagesize();
num_online_cpus = sysconf(84);
max_children = 4 * num_online_cpus;
select_syscall_tables();
create_shm();
parse_args((unsigned int)argc, argv);
init_uids();
func1();
init_shm();
init_taint_checking();
if ( (unsigned int)munge_tables() )
{
if ( show_syscall_list == 1 )
{
dump_syscall_tables();
v3 = 0;
}
else if ( show_ioctl_list == 1 )
{
dump_ioctls();
v3 = 0;
}
else if ( show_unannotated == 1 )
{
show_unannotated_args();
v3 = 0;
}
else
{
init_syscalls();
do_uid0_check();
if ( do_specific_domain == 1 )
find_specific_domain(specific_domain_optarg);
pids_init();
init_logging();
init_object_lists(1LL);
setup_initial_mappings();
parse_devices();
create_futexes();
create_sysv_shms();
setup_main_signals();
LOBYTE(no_bind_to_cpu) = rnd() & 1;
no_bind_to_cpu = (unsigned __int8)no_bind_to_cpu;
prctl(15, v4);
if ( !(unsigned int)open_fds() )
{
if ( *(_DWORD *)(shm + 13024LL) )
panic(13LL);
exit(1);
}
setup_ftrace();
main_loop();
destroy_global_objects();
if ( (unsigned int)is_tainted() == 1 )
stop_ftrace();
output(
0LL,
"Ran %ld syscalls. Successes: %ld Failures: %ld\n",
*(_QWORD *)(shm + 8LL),
*(_QWORD *)(shm + 16LL),
*(_QWORD *)(shm + 24LL));
if ( show_stats == 1 )
dump_stats();
shutdown_logging();
v3 = func0(*(_DWORD *)(shm + 13024LL));
}
}
else
{
v3 = 1;
}
exit(v3);
}

original_code:
int main(int argc, char* argv[])
{
 int ret = 0;
 const char taskname[13]="trinity-main";
 outputstd("Trinity " "2023.01" "  Dave Jones <davej@codemonkey.org.uk>\n");
 progname = argv[0];
 mainpid = getpid();
    getrlimit(RLIMIT_NOFILE, &max_files_rlimit);
 page_size = getpagesize();
 num_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
 max_children = num_online_cpus * 4;
 select_syscall_tables();
 create_shm();
 parse_args(argc, argv);
 init_uids();
 change_tmp_dir();
 init_shm();
 init_taint_checking();
 if (munge_tables() == FALSE) {
  ret = 1;
  goto out;
 }
 if (show_syscall_list == TRUE) {
  dump_syscall_tables();
  goto out;
 }
 if (show_ioctl_list == TRUE) {
  dump_ioctls();
  goto out;
 }
 if (show_unannotated == TRUE) {
  show_unannotated_args();
  goto out;
 }
 init_syscalls();
 do_uid0_check();
 if (do_specific_domain == TRUE)
  find_specific_domain(specific_domain_optarg);
 pids_init();
 init_logging();
 init_object_lists(1);
 setup_initial_mappings();
 parse_devices();
 create_futexes();
 create_sysv_shms();
 setup_main_signals();
 no_bind_to_cpu = (rnd() & 1);
 prctl(15, (unsigned long) &taskname);
 if (open_fds() == FALSE) {
  if (shm->exit_reason != STILL_RUNNING)
   panic(EXIT_FD_INIT_FAILURE);
  _exit(1);
 }
 setup_ftrace();
 main_loop();
 destroy_global_objects();
 if (is_tainted() == TRUE)
  stop_ftrace();
 output(0, "Ran %ld syscalls. Successes: %ld  Failures: %ld\n",
  shm->stats.op_count, shm->stats.successes, shm->stats.failures);
 if (show_stats == TRUE)
  dump_stats();
 shutdown_logging();
 ret = set_exit_code(shm->exit_reason);
out:
 exit(ret);
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int ret = 0;
 char taskname[13] = "trinity-main";
 outputstd("Trinity " "2023.01" "  Dave Jones <davej@codemonkey.org.uk>\n");
 progname = argv[0];
 mainpid = getpid();
    getrlimit(RLIMIT_NOFILE, &max_files_rlimit);
 page_size = getpagesize();
 num_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
 max_children = num_online_cpus * 4;
 select_syscall_tables();
 create_shm();
 parse_args(argc, argv);
 init_uids();
 change_tmp_dir();
 init_shm();
 init_taint_checking();
 if (munge_tables() == FALSE) {
  ret = 1;
  goto out;
 }
 if (show_syscall_list == TRUE) {
  dump_syscall_tables();
  goto out;
 }
 if (show_ioctl_list == TRUE) {
  dump_ioctls();
  goto out;
 }
 if (show_unannotated == TRUE) {
  show_unannotated_args();
  goto out;
 }
 init_syscalls();
 do_uid0_check();
 if (do_specific_domain == TRUE)
  find_specific_domain(specific_domain_optarg);
 pids_init();
 init_logging();
 init_object_lists(1);
 setup_initial_mappings();
 parse_devices();
 create_futexes();
 create_sysv_shms();
 setup_main_signals();
 no_bind_to_cpu = (rnd() & 1);
 prctl(15, (unsigned long) &taskname);
 if (open_fds() == FALSE) {
  if (shm->exit_reason != STILL_RUNNING)
   panic(EXIT_FD_INIT_FAILURE);
  _exit(1);
 }
 setup_ftrace();
 main_loop();
 destroy_global_objects();
 if (is_tainted() == TRUE)
  stop_ftrace();
 output(0, "Ran %ld syscalls. Successes: %ld  Failures: %ld\n",
  shm->stats.op_count, shm->stats.successes, shm->stats.failures);
 if (show_stats == TRUE)
  dump_stats();
 shutdown_logging();
 ret = set_exit_code(shm->exit_reason);
out:
 exit(ret);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
taskname
char [13]


decompiled_code:
__int64 __fastcall pppox_gen_sockaddr(__int64 a1, __int64 a2)
{
char v2; // al
__int64 v4[5]; // [rsp+0h] [rbp-28h]

v4[0] = (__int64)pppox_PX_PROTO_OE;
v4[1] = (__int64)pppox_PX_PROTO_OL2TP;
v2 = rnd(a1, a2);
return ((__int64 (__fastcall *)(__int64, __int64))v4[v2 & 1])(a1, a2);
}

original_code:
static void pppox_gen_sockaddr(struct sockaddr **addr, socklen_t *addrlen)
{
 const struct ppp_funcptr pppox_protos[] = {
  { .func = pppox_PX_PROTO_OE },
  { .func = pppox_PX_PROTO_OL2TP },
 };
 pppox_protos[rnd() % (sizeof(pppox_protos) / sizeof((pppox_protos)[0]))].func(addr, addrlen);
}

canonical_original_code:
static void pppox_gen_sockaddr(struct sockaddr **addr, unsigned int *addrlen)
{
 struct ppp_funcptr pppox_protos[] = {
  { .func = pppox_PX_PROTO_OE },
  { .func = pppox_PX_PROTO_OL2TP },
 };
 pppox_protos[rnd() % (sizeof(pppox_protos) / sizeof((pppox_protos)[0]))].func(addr, addrlen);
}

variable_types:
addrlen
unsigned int *

variable_types: struct ppp_funcptr { void (*func)(struct sockaddr { unsigned short sa_family; char sa_data[14]; } **addr, unsigned int *addrlen); } []

user_defined_types: struct ppp_funcptr { void (*func)(struct sockaddr **addr, unsigned int *addrlen); }


decompiled_code:
__int64 __fastcall pppox_PX_PROTO_OL2TP(__int64 a1, __int64 a2)
{
char v2; // al
__int64 v4[7]; // [rsp+0h] [rbp-38h]

v4[0] = (__int64)pppox_PX_PROTO_OL2TP_PPPoL2TP;
v4[1] = (__int64)pppox_PX_PROTO_OL2TP_PPPoL2TPin6;
v4[2] = (__int64)pppox_PX_PROTO_OL2TP_PPPoL2TPv3;
v4[3] = (__int64)pppox_PX_PROTO_OL2TP_PPPoL2TPv3in6;
v2 = rnd(a1, a2);
return ((__int64 (__fastcall *)(__int64, __int64))v4[v2 & 3])(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
char v2; // al
__int64 v4[7]; // [rsp+0h] [rbp-38h]

v4[0] = (__int64)pppox_PX_PROTO_OL2TP_PPPoL2TP;
v4[1] = (__int64)pppox_PX_PROTO_OL2TP_PPPoL2TPin6;
v4[2] = (__int64)pppox_PX_PROTO_OL2TP_PPPoL2TPv3;
v4[3] = (__int64)pppox_PX_PROTO_OL2TP_PPPoL2TPv3in6;
v2 = rnd(a1, a2);
return ((__int64 (__fastcall *)(__int64, __int64))v4[v2 & 3])(a1, a2);
}

original_code:
static void pppox_PX_PROTO_OL2TP(struct sockaddr **addr, socklen_t *addrlen)
{
 const struct ppp_funcptr pppox_px_protos[] = {
  { .func = pppox_PX_PROTO_OL2TP_PPPoL2TP },
  { .func = pppox_PX_PROTO_OL2TP_PPPoL2TPin6 },
  { .func = pppox_PX_PROTO_OL2TP_PPPoL2TPv3 },
  { .func = pppox_PX_PROTO_OL2TP_PPPoL2TPv3in6 },
 };
 pppox_px_protos[rnd() % (sizeof(pppox_px_protos) / sizeof((pppox_px_protos)[0]))].func(addr, addrlen);
}

canonical_original_code:
static void pppox_PX_PROTO_OL2TP(struct sockaddr **addr, unsigned int *addrlen)
{
 struct ppp_funcptr pppox_px_protos[] = {
  { .func = pppox_PX_PROTO_OL2TP_PPPoL2TP },
  { .func = pppox_PX_PROTO_OL2TP_PPPoL2TPin6 },
  { .func = pppox_PX_PROTO_OL2TP_PPPoL2TPv3 },
  { .func = pppox_PX_PROTO_OL2TP_PPPoL2TPv3in6 },
 };
 pppox_px_protos[rnd() % (sizeof(pppox_px_protos) / sizeof((pppox_px_protos)[0]))].func(addr, addrlen);
}

variable_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; } **


decompiled_code:
__int64 __fastcall pppol2tp_setsockopt(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 result; // rax

*(_DWORD *)a1 = 273;
v2 = rnd(a1, a2);
result = (unsigned int)pppol2tp_opts[v2
- (v2 / 5uLL
+ (((0xCCCCCCCCCCCCCCCDLL * (unsigned __int128)(unsigned __int64)v2) >> 64) & 0xFFFFFFFFFFFFFFFCLL))];
*(_QWORD *)(a1 + 8) = result;
*(_QWORD *)(a1 + 24) = 4LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 result; // rax

*(_DWORD *)a1 = 273;
v2 = rnd(a1, a2);
result = (unsigned int)pppol2tp_opts[v2
- (v2 / 5uLL
+ (((0xCCCCCCCCCCCCCCCDLL * (unsigned __int128)(unsigned __int64)v2) >> 64) & 0xFFFFFFFFFFFFFFFCLL))];
*(_QWORD *)(a1 + 8) = result;
*(_QWORD *)(a1 + 24) = 4LL;
return result;
}

original_code:
static void pppol2tp_setsockopt(struct sockopt *so, __attribute((unused)) struct socket_triplet *triplet)
{
 so->level = 273;
 so->optname = pppol2tp_opts[rnd() % (sizeof(pppol2tp_opts) / sizeof((pppol2tp_opts)[0]))];
 so->optlen = sizeof(int);
}

canonical_original_code:
static void pppol2tp_setsockopt(struct sockopt *so, struct socket_triplet *triplet)
{
 so->level = 273;
 so->optname = pppol2tp_opts[rnd() % (sizeof(pppol2tp_opts) / sizeof((pppol2tp_opts)[0]))];
 so->optlen = sizeof(int);
}

variable_types: struct sockopt { unsigned int level; unsigned long optname; unsigned long optval; unsigned long optlen; } *

variable_types: struct socket_triplet { unsigned int family; unsigned int type; unsigned int protocol; } *


decompiled_code:
void show_backtrace()
{
if ( mainpid == getpid() )
_show_backtrace();
else
show_child_backtrace();
}

canonical_decompiled_code:
void func2()
{
if ( mainpid == getpid() )
func0();
else
func1();
}

original_code:
void show_backtrace(void)
{
 pid_t pid = getpid();
 if (pid == mainpid) {
  __show_backtrace();
  return;
 }
 show_child_backtrace();
}

canonical_original_code:
void show_backtrace()
{
 int pid = getpid();
 if (pid == mainpid) {
  __show_backtrace();
  return;
 }
 show_child_backtrace();
}


debugf

decompiled_code:
__int64 debugf(__int64 a1, ...)
{
__int64 result; // rax
gcc_va_list va; // [rsp+8h] [rbp-4D0h] BYREF
char v3[1024]; // [rsp+20h] [rbp-4B8h] BYREF

result = shm;
if ( *(_DWORD *)(shm + 13044LL) )
{
va_start(va, a1);
_vsprintf_chk(v3, 1LL, 1024LL, a1, va);
result = output(0LL, v3);
}
return result;
}

canonical_decompiled_code:
__int64 func6(__int64 a1, ...)
{
__int64 result; // rax
gcc_va_list va; // [rsp+8h] [rbp-4D0h] BYREF
char v3[1024]; // [rsp+20h] [rbp-4B8h] BYREF

result = shm;
if ( *(_DWORD *)(shm + 13044LL) )
{
va_start(va, a1);
_vsprintf_chk(v3, 1LL, 1024LL, a1, va);
result = output(0LL, v3);
}
return result;
}

original_code:
void debugf(const char *fmt, ...)
{
 char debugbuf[1024];
 va_list args;
 if (shm->debug == FALSE)
  return;
 __builtin_va_start(args,fmt);
 vsprintf(debugbuf, fmt, args);
 __builtin_va_end(args);
 output(0, debugbuf);
}

canonical_original_code:
void debugf(char *fmt, ...)
{
 char debugbuf[1024];
 __builtin_va_list args;
 if (shm->debug == FALSE)
  return;
 __builtin_va_start(args,fmt);
 vsprintf(debugbuf, fmt, args);
 __builtin_va_end(args);
 output(0, debugbuf);
}

variable_types:
fmt
char *

variable_types:
debugbuf
char [1024]


syslogf

decompiled_code:
void syslogf(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-4D0h] BYREF
char v2[1024]; // [rsp+20h] [rbp-4B8h] BYREF

va_start(va, a1);
_vsprintf_chk(v2, 1LL, 1024LL, a1, va);
openlog("trinity", 34, 8);
_syslog_chk(2LL, 1LL, "%s", v2);
closelog();
}

canonical_decompiled_code:
void func7(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-4D0h] BYREF
char v2[1024]; // [rsp+20h] [rbp-4B8h] BYREF

va_start(va, a1);
_vsprintf_chk(v2, 1LL, 1024LL, a1, va);
openlog("trinity", 34, 8);
_syslog_chk(2LL, 1LL, "%s", v2);
closelog();
}

original_code:
void syslogf(const char *fmt, ...)
{
 char debugbuf[1024];
 va_list args;
 __builtin_va_start(args,fmt);
 vsprintf(debugbuf, fmt, args);
 __builtin_va_end(args);
 openlog("trinity", 0x02|0x20, (1<<3));
 syslog(2, "%s", debugbuf);
 closelog();
}

canonical_original_code:
void syslogf(char *fmt, ...)
{
 char debugbuf[1024];
 __builtin_va_list args;
 __builtin_va_start(args,fmt);
 vsprintf(debugbuf, fmt, args);
 __builtin_va_end(args);
 openlog("trinity", 0x02|0x20, (1<<3));
 syslog(2, "%s", debugbuf);
 closelog();
}


decompiled_code:
unsigned __int64 __fastcall tcp_setsockopt(_QWORD *a1)
{
unsigned __int64 result; // rax

result = (unsigned int)tcp_opts[(int)rnd() % 0x25uLL];
a1[1] = result;
if ( result == 31 )
{
result = a1[2];
*(_DWORD *)result = 7564404;
a1[3] = 4LL;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(_QWORD *a1)
{
unsigned __int64 result; // rax

result = (unsigned int)tcp_opts[(int)rnd() % 0x25uLL];
a1[1] = result;
if ( result == 31 )
{
result = a1[2];
*(_DWORD *)result = 7564404;
a1[3] = 4LL;
}
return result;
}

original_code:
void tcp_setsockopt(struct sockopt *so, __attribute((unused)) struct socket_triplet *triplet)
{
 so->optname = tcp_opts[rnd() % (sizeof(tcp_opts) / sizeof((tcp_opts)[0]))];
 if (so->optname == 31) {
  char *ptr = (char *) so->optval;
  sprintf(ptr, "tls");
  so->optlen = sizeof("tls");
 }
}

canonical_original_code:
void tcp_setsockopt(struct sockopt *so, struct socket_triplet *triplet)
{
 so->optname = tcp_opts[rnd() % (sizeof(tcp_opts) / sizeof((tcp_opts)[0]))];
 if (so->optname == 31) {
  char *ptr = (char *) so->optval;
  sprintf(ptr, "tls");
  so->optlen = sizeof("tls");
 }
}

variable_types:
ptr
char *


decompiled_code:
void __fastcall free_execve_ptrs(void *ptr, void *a2)
{
void **v2; // rbx
void **v3; // rbp
void **v4; // rbx
char *v5; // rbp
char *v6; // rax

if ( argvcount )
{
v2 = (void **)ptr;
v3 = (void **)((char *)ptr + 8 * (unsigned int)argvcount);
do
free(*v2++);
while ( v2 != v3 );
}
free(ptr);
if ( envpcount )
{
v4 = (void **)a2;
v5 = (char *)a2 + 8 * (unsigned int)(envpcount - 1);
do
{
free(*v4);
v6 = (char *)v4++;
}
while ( v6 != v5 );
}
free(a2);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr, void *a2)
{
void **v2; // rbx
void **v3; // rbp
void **v4; // rbx
char *v5; // rbp
char *v6; // rax

if ( argvcount )
{
v2 = (void **)ptr;
v3 = (void **)((char *)ptr + 8 * (unsigned int)argvcount);
do
free(*v2++);
while ( v2 != v3 );
}
free(ptr);
if ( envpcount )
{
v4 = (void **)a2;
v5 = (char *)a2 + 8 * (unsigned int)(envpcount - 1);
do
{
free(*v4);
v6 = (char *)v4++;
}
while ( v6 != v5 );
}
free(a2);
}

original_code:
static void free_execve_ptrs(void **argv, void **envp)
{
 unsigned int i;
 for (i = 0; i < argvcount; i++)
  free(argv[i]);
 free(argv);
 for (i = 0; i < envpcount; i++)
  free(envp[i]);
 free(envp);
}

variable_types:
argv
void **

variable_types:
envp
void **

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall gen_ptrs_to_crap(unsigned int a1)
{
__int64 v1; // rax
__int64 v2; // r12
_QWORD *v3; // rbx
_QWORD *v4; // rbp
unsigned int v5; // eax

v1 = _zmalloc(8LL * a1, "gen_ptrs_to_crap");
v2 = v1;
if ( a1 )
{
v3 = (_QWORD *)v1;
v4 = (_QWORD *)(v1 + 8LL * a1);
do
{
*v3 = _zmalloc(page_size, "gen_ptrs_to_crap");
v5 = rnd();
generate_rand_bytes(*v3++, v5 % page_size);
}
while ( v3 != v4 );
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
__int64 v1; // rax
__int64 v2; // r12
_QWORD *v3; // rbx
_QWORD *v4; // rbp
unsigned int v5; // eax

v1 = _zmalloc(8LL * a1, "gen_ptrs_to_crap");
v2 = v1;
if ( a1 )
{
v3 = (_QWORD *)v1;
v4 = (_QWORD *)(v1 + 8LL * a1);
do
{
*v3 = _zmalloc(page_size, "gen_ptrs_to_crap");
v5 = rnd();
generate_rand_bytes(*v3++, v5 % page_size);
}
while ( v3 != v4 );
}
return v2;
}

original_code:
static unsigned long ** gen_ptrs_to_crap(unsigned int count)
{
 void **ptr;
 unsigned int i;
 ptr = __zmalloc(count * sizeof(void *), __func__);
 for (i = 0; i < count; i++) {
  ptr[i] = __zmalloc(page_size, __func__);
  generate_rand_bytes((unsigned char *) ptr[i], rnd() % page_size);
 }
 return (unsigned long **) ptr;
}

canonical_original_code:
static unsigned long **gen_ptrs_to_crap(unsigned int count)
{
 void **ptr;
 unsigned int i;
 ptr = __zmalloc(count * sizeof(void *), __func__);
 for (i = 0; i < count; i++) {
  ptr[i] = __zmalloc(page_size, __func__);
  generate_rand_bytes((unsigned char *) ptr[i], rnd() % page_size);
 }
 return (unsigned long **) ptr;
}

variable_types:
count
unsigned int

variable_types:
ptr
void **

return_type: unsigned long **


decompiled_code:
__int64 __fastcall dirty_random_pages(_QWORD *a1)
{
__int64 result; // rax
unsigned int v2; // ebp
int i; // er12
_BYTE *v4; // rbx

result = nr_pages((__int64)a1);
if ( (_DWORD)result )
{
v2 = result;
for ( i = 0; i != v2; ++i )
{
v4 = (_BYTE *)(*a1 + (unsigned int)page_size * ((unsigned int)rnd() % v2));
result = mark_page_rw((__int64)a1, v4);
if ( (_DWORD)result == 1 )
{
result = rnd();
*v4 = result;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
__int64 result; // rax
unsigned int v2; // ebp
int i; // er12
_BYTE *v4; // rbx

result = func0((__int64)a1);
if ( (_DWORD)result )
{
v2 = result;
for ( i = 0; i != v2; ++i )
{
v4 = (_BYTE *)(*a1 + (unsigned int)page_size * ((unsigned int)rnd() % v2));
result = func1((__int64)a1, v4);
if ( (_DWORD)result == 1 )
{
result = rnd();
*v4 = result;
}
}
}
return result;
}

original_code:
static void dirty_random_pages(struct map *map)
{
 unsigned int i, nr;
 nr = nr_pages(map);
 for (i = 0; i < nr; i++) {
  off_t offset = (rnd() % nr) * page_size;
  char *p = map->ptr + offset;
  if (mark_page_rw(map, p) == TRUE)
   *p = rnd();
 }
}

canonical_original_code:
static void dirty_random_pages(struct map *map)
{
 unsigned int i; unsigned int nr;
 nr = nr_pages(map);
 for (i = 0; i < nr; i++) {
  long offset = (rnd() % nr) * page_size;
  char *p = map->ptr + offset;
  if (mark_page_rw(map, p) == TRUE)
   *p = rnd();
 }
}

variable_types: struct map { void *ptr; char *name; unsigned long size; int prot; unsigned char type; } *

variable_types:
nr
unsigned int

variable_types: offset long

variable_types:
p
char *


decompiled_code:
__int64 __fastcall dirty_mapping_reverse(_QWORD *a1)
{
__int64 result; // rax
int i; // ebx
_BYTE *v3; // rbp

result = (unsigned int)nr_pages((__int64)a1) - 1;
for ( i = result; i; --i )
{
v3 = (_BYTE *)(*a1 + (unsigned int)(page_size * i));
result = mark_page_rw((__int64)a1, v3);
if ( (_DWORD)result == 1 )
{
result = rnd();
*v3 = result;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1)
{
__int64 result; // rax
int i; // ebx
_BYTE *v3; // rbp

result = (unsigned int)func0((__int64)a1) - 1;
for ( i = result; i; --i )
{
v3 = (_BYTE *)(*a1 + (unsigned int)(page_size * i));
result = func1((__int64)a1, v3);
if ( (_DWORD)result == 1 )
{
result = rnd();
*v3 = result;
}
}
return result;
}

original_code:
static void dirty_mapping_reverse(struct map *map)
{
 unsigned int i, nr;
 nr = nr_pages(map) - 1;
 for (i = nr; i > 0; i--) {
  char *p = map->ptr + (i * page_size);
  if (mark_page_rw(map, p) == TRUE)
   *p = rnd();
 }
}

canonical_original_code:
static void dirty_mapping_reverse(struct map *map)
{
 unsigned int i; unsigned int nr;
 nr = nr_pages(map) - 1;
 for (i = nr; i > 0; i--) {
  char *p = map->ptr + (i * page_size);
  if (mark_page_rw(map, p) == TRUE)
   *p = rnd();
 }
}

user_defined_types: struct map { void *ptr; char *name; unsigned long size; int prot; unsigned char type; }


decompiled_code:
__int64 __fastcall dirty_every_other_page(_QWORD *a1)
{
unsigned int v1; // er13
__int64 result; // rax
unsigned int i; // ebx
_BYTE *v4; // rbp

v1 = nr_pages((__int64)a1);
result = rnd() & 1;
for ( i = result; v1 > i; i += 2 )
{
v4 = (_BYTE *)(*a1 + (unsigned int)page_size * i);
result = mark_page_rw((__int64)a1, v4);
if ( (_DWORD)result == 1 )
{
result = rnd();
*v4 = result;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1)
{
unsigned int v1; // er13
__int64 result; // rax
unsigned int i; // ebx
_BYTE *v4; // rbp

v1 = func0((__int64)a1);
result = rnd() & 1;
for ( i = result; v1 > i; i += 2 )
{
v4 = (_BYTE *)(*a1 + (unsigned int)page_size * i);
result = func1((__int64)a1, v4);
if ( (_DWORD)result == 1 )
{
result = rnd();
*v4 = result;
}
}
return result;
}

original_code:
static void dirty_every_other_page(struct map *map)
{
 unsigned int i, nr, first;
 nr = nr_pages(map);
 first = (rnd() & 1);
 for (i = first; i < nr; i+=2) {
  char *p = map->ptr + (i * page_size);
  if (mark_page_rw(map, p) == TRUE)
   *p = rnd();
 }
}

canonical_original_code:
static void dirty_every_other_page(struct map *map)
{
 unsigned int i; unsigned int nr; unsigned int first;
 nr = nr_pages(map);
 first = (rnd() & 1);
 for (i = first; i < nr; i+=2) {
  char *p = map->ptr + (i * page_size);
  if (mark_page_rw(map, p) == TRUE)
   *p = rnd();
 }
}

variable_types:
first
unsigned int


decompiled_code:
__int64 __fastcall dirty_one_page(__int64 *a1)
{
__int64 v1; // r12
_BYTE *v2; // r12
__int64 result; // rax

v1 = *a1;
v2 = (_BYTE *)(((unsigned int)-(int)page_size & ((int)rnd() % (unsigned __int64)a1[2])) + v1);
result = mark_page_rw((__int64)a1, v2);
if ( (_DWORD)result == 1 )
{
result = rnd();
*v2 = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 *a1)
{
__int64 v1; // r12
_BYTE *v2; // r12
__int64 result; // rax

v1 = *a1;
v2 = (_BYTE *)(((unsigned int)-(int)page_size & ((int)rnd() % (unsigned __int64)a1[2])) + v1);
result = func1((__int64)a1, v2);
if ( (_DWORD)result == 1 )
{
result = rnd();
*v2 = result;
}
return result;
}

original_code:
static void dirty_one_page(struct map *map)
{
 char *p = map->ptr;
 unsigned long offset = (rnd() % map->size) & (~(page_size - 1));
 if (mark_page_rw(map, p + offset) == TRUE)
  p[offset] = rnd();
}

variable_types:
offset
unsigned long