main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v4; // rbx
const char **v5; // r13
int v6; // ebp
const char *v7; // r12
bool v8; // dl
bool v9; // cf
bool v10; // zf
const char *v11; // rsi
__int64 v12; // rcx
const char *v13; // rdi
bool v14; // cf
bool v15; // zf
__int64 v16; // rcx
const char *v17; // rdi
char v18; // al
__int64 v19; // rax
unsigned int v20; // eax
const char *v21; // rax
int v22; // eax
unsigned int v23; // ebx
__int64 v24; // rsi
char v26[1024]; // [rsp+0h] [rbp-538h] BYREF
char s1[4]; // [rsp+400h] [rbp-138h] BYREF
char s[308]; // [rsp+404h] [rbp-134h] BYREF

if ( argc <= 1 )
{
if ( !(unsigned int)SDL_Init(33LL, argv, envp) )
{
wd_of_ants_init();
init_gui();
goto LABEL_23;
}
LABEL_24:
v21 = (const char *)SDL_GetError();
printf("fail: %s\n", v21);
return -1;
}
v4 = argv + 1;
v5 = &argv[(unsigned int)(argc - 2) + 2];
v6 = 0;
v7 = 0LL;
do
{
if ( v6 )
{
v7 = *v4;
v18 = **v4;
if ( !v18 || v18 == 45 )
{
puts("Invalid filename.");
return -1;
}
v11 = *v4;
printf("Image file: '%s'.\n", *v4);
v6 = 0;
}
else
{
if ( !strcmp("-h", *v4) || (v8 = strcmp("--help", *v4) != 0, v9 = 0, v10 = !v8) )
{
print_usage(*argv);
print_help();
return v6;
}
v11 = "-i";
v12 = 3LL;
v13 = *v4;
do
{
if ( !v12 )
break;
v9 = *v11 < (unsigned int)*v13;
v10 = *v11++ == *v13++;
--v12;
}
while ( v10 );
LOBYTE(envp) = (!v9 && !v10) - v9;
v6 = 1;
v14 = 0;
v15 = (_BYTE)envp == 0;
if ( (_BYTE)envp )
{
v11 = "--image";
v16 = 8LL;
v17 = *v4;
do
{
if ( !v16 )
break;
v14 = *v11 < (unsigned int)*v17;
v15 = *v11++ == *v17++;
--v16;
}
while ( v15 );
v6 = (!v14 && !v15) == v14;
}
}
++v4;
}
while ( v4 != v5 );
if ( (unsigned int)SDL_Init(33LL, v11, envp) )
goto LABEL_24;
wd_of_ants_init();
init_gui();
if ( v7 )
{
v19 = get_world();
load_image(v7, v19 + 16);
}
LABEL_23:
v20 = fcntl(0, 3, 0LL);
BYTE1(v20) |= 8u;
fcntl(0, 4, v20);
while ( 1 )
{
do
{
printf("cmd: ");
v23 = 0;
while ( 1 )
{
v22 = getchar();
if ( v22 == 10 )
break;
if ( v22 != -1 )
{
s1[v23++] = v22;
if ( v23 > 0xFE )
break;
}
if ( main_done )
goto LABEL_48;
usleep(0x3E8u);
}
s1[v23] = 0;
}
while ( !v23 );
if ( main_done )
break;
if ( !strcmp(s1, "h") )
{
puts("List of supported commands:");
puts(" h - Print help information.");
puts(" fs - Start fast simulation.");
puts(" rs - Start realtime simulation.");
puts(" cb - Clear barriers.");
puts(" arb - Add random stubs.");
puts(" ab1 - Add 2 horizontal walls.");
puts(" ab2 - Add vertical walls.");
printf(" img <filename> - Load image.\n ");
puts(" q - Quit.");
putchar(10);
}
else if ( !strncmp(s1, "img ", 4uLL) )
{
if ( sscanf(s, "%s", v26) == 1 )
{
printf("Load file '%s'\n", v26);
v24 = get_world() + 16;
load_image(v26, v24);
}
else
{
puts("Invalid filename.");
}
}
else
{
if ( !strcmp(s1, "q") )
{
main_done = 1;
break;
}
if ( !strcmp(s1, "fs") )
{
do
wd_of_ants_run();
while ( !main_done );
break;
}
if ( !strcmp(s1, "rs") )
{
run_rtime_sim();
break;
}
if ( !strcmp(s1, "cb") )
{
reset_barriers();
}
else if ( !strcmp(s1, "arb") )
{
add_random_barriers();
}
else if ( !strcmp(s1, "ab1") )
{
add_barriers_1();
}
else if ( !strcmp(s1, "ab2") )
{
add_barriers_2();
}
else
{
printf("Unknown command `%s`. Enter `h` for help.\n\n", s1);
}
}
}
LABEL_48:
close_gui();
wd_of_ants_destroy();
SDL_Quit();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v4; // rbx
const char **v5; // r13
int v6; // ebp
const char *v7; // r12
bool v8; // dl
bool v9; // cf
bool v10; // zf
const char *v11; // rsi
__int64 v12; // rcx
const char *v13; // rdi
bool v14; // cf
bool v15; // zf
__int64 v16; // rcx
const char *v17; // rdi
char v18; // al
__int64 v19; // rax
unsigned int v20; // eax
const char *v21; // rax
int v22; // eax
unsigned int v23; // ebx
__int64 v24; // rsi
char v26[1024]; // [rsp+0h] [rbp-538h] BYREF
char s1[4]; // [rsp+400h] [rbp-138h] BYREF
char s[308]; // [rsp+404h] [rbp-134h] BYREF

if ( argc <= 1 )
{
if ( !(unsigned int)SDL_Init(33LL, argv, envp) )
{
wd_of_ants_init();
init_gui();
goto LABEL_23;
}
LABEL_24:
v21 = (const char *)SDL_GetError();
printf("fail: %s\n", v21);
return -1;
}
v4 = argv + 1;
v5 = &argv[(unsigned int)(argc - 2) + 2];
v6 = 0;
v7 = 0LL;
do
{
if ( v6 )
{
v7 = *v4;
v18 = **v4;
if ( !v18 || v18 == 45 )
{
puts("Invalid filename.");
return -1;
}
v11 = *v4;
printf("Image file: '%s'.\n", *v4);
v6 = 0;
}
else
{
if ( !strcmp("-h", *v4) || (v8 = strcmp("--help", *v4) != 0, v9 = 0, v10 = !v8) )
{
func1(*argv);
func2();
return v6;
}
v11 = "-i";
v12 = 3LL;
v13 = *v4;
do
{
if ( !v12 )
break;
v9 = *v11 < (unsigned int)*v13;
v10 = *v11++ == *v13++;
--v12;
}
while ( v10 );
LOBYTE(envp) = (!v9 && !v10) - v9;
v6 = 1;
v14 = 0;
v15 = (_BYTE)envp == 0;
if ( (_BYTE)envp )
{
v11 = "--image";
v16 = 8LL;
v17 = *v4;
do
{
if ( !v16 )
break;
v14 = *v11 < (unsigned int)*v17;
v15 = *v11++ == *v17++;
--v16;
}
while ( v15 );
v6 = (!v14 && !v15) == v14;
}
}
++v4;
}
while ( v4 != v5 );
if ( (unsigned int)SDL_Init(33LL, v11, envp) )
goto LABEL_24;
wd_of_ants_init();
init_gui();
if ( v7 )
{
v19 = get_world();
func3(v7, v19 + 16);
}
LABEL_23:
v20 = fcntl(0, 3, 0LL);
BYTE1(v20) |= 8u;
fcntl(0, 4, v20);
while ( 1 )
{
do
{
printf("cmd: ");
v23 = 0;
while ( 1 )
{
v22 = getchar();
if ( v22 == 10 )
break;
if ( v22 != -1 )
{
s1[v23++] = v22;
if ( v23 > 0xFE )
break;
}
if ( main_done )
goto LABEL_48;
usleep(0x3E8u);
}
s1[v23] = 0;
}
while ( !v23 );
if ( main_done )
break;
if ( !strcmp(s1, "h") )
{
puts("List of supported commands:");
puts(" h - Print help information.");
puts(" fs - Start fast simulation.");
puts(" rs - Start realtime simulation.");
puts(" cb - Clear barriers.");
puts(" arb - Add random stubs.");
puts(" ab1 - Add 2 horizontal walls.");
puts(" ab2 - Add vertical walls.");
printf(" img <filename> - Load image.\n ");
puts(" q - Quit.");
putchar(10);
}
else if ( !strncmp(s1, "img ", 4uLL) )
{
if ( sscanf(s, "%s", v26) == 1 )
{
printf("Load file '%s'\n", v26);
v24 = get_world() + 16;
func3(v26, v24);
}
else
{
puts("Invalid filename.");
}
}
else
{
if ( !strcmp(s1, "q") )
{
main_done = 1;
break;
}
if ( !strcmp(s1, "fs") )
{
do
wd_of_ants_run();
while ( !main_done );
break;
}
if ( !strcmp(s1, "rs") )
{
run_rtime_sim();
break;
}
if ( !strcmp(s1, "cb") )
{
reset_barriers();
}
else if ( !strcmp(s1, "arb") )
{
add_random_barriers();
}
else if ( !strcmp(s1, "ab1") )
{
add_barriers_1();
}
else if ( !strcmp(s1, "ab2") )
{
add_barriers_2();
}
else
{
printf("Unknown command `%s`. Enter `h` for help.\n\n", s1);
}
}
}
LABEL_48:
close_gui();
wd_of_ants_destroy();
SDL_Quit();
return 0;
}

original_code:
int main( int argc, char ** argv )
{
 char * arg_image_name = 0;
 int vn;
 int arg_state = 0;
 for( vn = 1; vn < argc; vn++ )
 {
  switch( arg_state )
  {
  case 0:
   if( !strcmp( "-h", argv[ vn ] ) || !strcmp( "--help", argv[ vn ] ) )
   {
    print_usage( argv[0] );
    print_help();
    return 0;
   }
   else if( !strcmp( "-i", argv[ vn ] ) || !strcmp( "--image", argv[ vn ] ) )
   {
    arg_state = 1;
   }
   break;
  case 1:
   if( ( !argv[ vn ][ 0 ] ) || ( argv[ vn ][ 0 ] == '-' ) )
   {
    printf( "Invalid filename.\n" );
    return -1;
   }
   arg_image_name = argv[ vn ];
   printf( "Image file: '%s'.\n", arg_image_name );
   arg_state = 0;
   break;
  default:
   break;
  }
 }
 if( SDL_Init( 0x00000020 | 0x00000001 ) )
 {
  printf( "fail: %s\n", SDL_GetError() );
  return -1;
 }
 wd_of_ants_init();
 init_gui();
 if( arg_image_name ) load_image( arg_image_name, &( get_world()->plan ) );
 int flags = fcntl(0, 3, 0);
 fcntl(0, 4, flags | 04000);
 char cmd[ 256 ];
 while( 1 )
 {
  int clen = 0;
  while( !clen )
  {
   printf( "cmd: " );
   while( 1 )
   {
    int c = getchar();
    if( c == '\n' ) break;
    if( c != (-1) )
    {
     cmd[ clen ] = c;
     clen++;
     if( clen >= ( sizeof( cmd ) - 1 ) ) break;
    }
    if( main_done ) goto exit;
    usleep( 1000 );
   }
   cmd[ clen ] = 0;
  }
  if( main_done ) goto exit;
  if( !strcmp( cmd, "h" ) )
  {
   printf( "List of supported commands:\n" );
   printf( "     h - Print help information.\n" );
   printf( "    fs - Start fast simulation.\n" );
   printf( "    rs - Start realtime simulation.\n" );
   printf( "    cb - Clear barriers.\n" );
   printf( "   arb - Add random stubs.\n" );
   printf( "   ab1 - Add 2 horizontal walls.\n" );
   printf( "   ab2 - Add vertical walls.\n" );
   printf( "   img <filename> - Load image.\n " );
   printf( "     q - Quit.\n" );
   printf( "\n" );
  }
  else if( !strncmp( cmd, "img ", 4 ) )
  {
   char buf[1024];
   if( sscanf( cmd + 4, "%s", buf ) == 1 )
   {
    printf( "Load file '%s'\n", buf );
    load_image( buf, &( get_world()->plan ) );
   }
   else
   {
    printf( "Invalid filename.\n" );
   }
  }
  else if( !strcmp( cmd, "q" ) )
  {
   main_done++;
   break;
  }
  else if( !strcmp( cmd, "fs" ) )
  {
   while( !main_done ) { wd_of_ants_run(); }
   break;
  }
  else if( !strcmp( cmd, "rs" ) )
  {
   run_rtime_sim();
   break;
  }
  else if( !strcmp( cmd, "cb" ) )
  {
   reset_barriers();
  }
  else if( !strcmp( cmd, "arb" ) )
  {
   add_random_barriers();
  }
  else if( !strcmp( cmd, "ab1" ) )
  {
   add_barriers_1();
  }
  else if( !strcmp( cmd, "ab2" ) )
  {
   add_barriers_2();
  }
  else
  {
   printf( "Unknown command `%s`. Enter `h` for help.\n\n", cmd );
  }
 }
exit:
 close_gui();
 wd_of_ants_destroy();
 SDL_Quit();
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 char *arg_image_name = 0;
 int vn;
 int arg_state = 0;
 for( vn = 1; vn < argc; vn++ )
 {
  switch( arg_state )
  {
  case 0:
   if( !strcmp( "-h", argv[ vn ] ) || !strcmp( "--help", argv[ vn ] ) )
   {
    print_usage( argv[0] );
    print_help();
    return 0;
   }
   else if( !strcmp( "-i", argv[ vn ] ) || !strcmp( "--image", argv[ vn ] ) )
   {
    arg_state = 1;
   }
   break;
  case 1:
   if( ( !argv[ vn ][ 0 ] ) || ( argv[ vn ][ 0 ] == '-' ) )
   {
    printf( "Invalid filename.\n" );
    return -1;
   }
   arg_image_name = argv[ vn ];
   printf( "Image file: '%s'.\n", arg_image_name );
   arg_state = 0;
   break;
  default:
   break;
  }
 }
 if( SDL_Init( 0x00000020 | 0x00000001 ) )
 {
  printf( "fail: %s\n", SDL_GetError() );
  return -1;
 }
 wd_of_ants_init();
 init_gui();
 if( arg_image_name ) load_image( arg_image_name, &( get_world()->plan ) );
 int flags = fcntl(0, 3, 0);
 fcntl(0, 4, flags | 04000);
 char cmd[256];
 while( 1 )
 {
  int clen = 0;
  while( !clen )
  {
   printf( "cmd: " );
   while( 1 )
   {
    int c = getchar();
    if( c == '\n' ) break;
    if( c != (-1) )
    {
     cmd[ clen ] = c;
     clen++;
     if( clen >= ( sizeof( cmd ) - 1 ) ) break;
    }
    if( main_done ) goto exit;
    usleep( 1000 );
   }
   cmd[ clen ] = 0;
  }
  if( main_done ) goto exit;
  if( !strcmp( cmd, "h" ) )
  {
   printf( "List of supported commands:\n" );
   printf( "     h - Print help information.\n" );
   printf( "    fs - Start fast simulation.\n" );
   printf( "    rs - Start realtime simulation.\n" );
   printf( "    cb - Clear barriers.\n" );
   printf( "   arb - Add random stubs.\n" );
   printf( "   ab1 - Add 2 horizontal walls.\n" );
   printf( "   ab2 - Add vertical walls.\n" );
   printf( "   img <filename> - Load image.\n " );
   printf( "     q - Quit.\n" );
   printf( "\n" );
  }
  else if( !strncmp( cmd, "img ", 4 ) )
  {
   char buf[1024];
   if( sscanf( cmd + 4, "%s", buf ) == 1 )
   {
    printf( "Load file '%s'\n", buf );
    load_image( buf, &( get_world()->plan ) );
   }
   else
   {
    printf( "Invalid filename.\n" );
   }
  }
  else if( !strcmp( cmd, "q" ) )
  {
   main_done++;
   break;
  }
  else if( !strcmp( cmd, "fs" ) )
  {
   while( !main_done ) { wd_of_ants_run(); }
   break;
  }
  else if( !strcmp( cmd, "rs" ) )
  {
   run_rtime_sim();
   break;
  }
  else if( !strcmp( cmd, "cb" ) )
  {
   reset_barriers();
  }
  else if( !strcmp( cmd, "arb" ) )
  {
   add_random_barriers();
  }
  else if( !strcmp( cmd, "ab1" ) )
  {
   add_barriers_1();
  }
  else if( !strcmp( cmd, "ab2" ) )
  {
   add_barriers_2();
  }
  else
  {
   printf( "Unknown command `%s`. Enter `h` for help.\n\n", cmd );
  }
 }
exit:
 close_gui();
 wd_of_ants_destroy();
 SDL_Quit();
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: vn int

variable_types: flags int

variable_types:
cmd
char [256]

variable_types: clen int

variable_types: c int

variable_types:
buf
char [1024]


repo: sanXVII/sima

decompiled_code:
__int64 *get_world()
{
return &my_world;
}

canonical_decompiled_code:
__int64 *func0()
{
return &my_world;
}

original_code:
wd_of_ants * get_world( void )
{
 return &my_world;
}

canonical_original_code:
struct wd_of_ants *get_world()
{
 return &my_world;
}

return_type: struct wd_of_ants { struct rtree { struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } *adam; struct rtree_nblk { struct rtree_n node[-1]; struct rtree_nblk *next; } first_blk; struct rtree_nblk *cur_blk; int cur_cnt; int not_del_cnt; } *stub; struct ant { struct pix { float red; float green; float blue; int state; } cpix; float pos_x; float pos_ang; float left_angle; float right_angle; float left_speed; float right_speed; float axis_len; float tire_radius; float nose_len; struct ant *next; } *muvis; struct genplan { float left_up_x; float left_up_y; float pix_side; int width; int hight; struct pix *pixs; int last_tasked; } plan; struct free_pixels { int pix_cnt; struct free_pix_blk { struct free_pix { float x; float red; float green; float blue; float angle; float state; } pix[100]; struct free_pix_blk *next; } *last_blk; struct rtree *tree; } *free_pixs; struct free_pixels *free_pixs_4del; unsigned long sim_cnt; } *

user_defined_types: struct wd_of_ants { struct rtree *stub; struct ant *muvis; struct genplan plan; struct free_pixels *free_pixs; struct free_pixels *free_pixs_4del; unsigned long sim_cnt; }

user_defined_types: struct rtree { struct rtree_n *adam; struct rtree_nblk first_blk; struct rtree_nblk *cur_blk; int cur_cnt; int not_del_cnt; }

user_defined_types: struct ant { struct pix cpix; float pos_x; float pos_ang; float left_angle; float right_angle; float left_speed; float right_speed; float axis_len; float tire_radius; float nose_len; struct ant *next; }

user_defined_types: struct free_pixels { int pix_cnt; struct free_pix_blk *last_blk; struct rtree *tree; }

user_defined_types: struct free_pix_blk { struct free_pix pix[100]; struct free_pix_blk *next; }


decompiled_code:
__int64 reset_barriers()
{
__int64 v0; // rbx

v0 = my_world;
my_world = new_rtree();
if ( !my_world )
_assert_fail("my_world.stub", "wd_of_ants.c", 0x34u, "reset_barriers");
return del_rtree(v0);
}

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

v0 = my_world;
my_world = new_rtree();
if ( !my_world )
_assert_fail("my_world.stub", "wd_of_ants.c", 0x34u, "reset_barriers");
return del_rtree(v0);
}

original_code:
void reset_barriers( void )
{
 rtree * ob = my_world.stub;
 my_world.stub = new_rtree();
 ((void) sizeof ((my_world.stub) ? 1 : 0), __extension__ ({ if (my_world.stub) ; else __assert_fail ("my_world.stub", "wd_of_ants.c", 52, __extension__ __PRETTY_FUNCTION__); }));
 del_rtree( ob );
}

canonical_original_code:
void reset_barriers()
{
 struct rtree *ob = my_world.stub;
 my_world.stub = new_rtree();
 ((void) sizeof ((my_world.stub) ? 1 : 0), __extension__ ({ if (my_world.stub) ; else __assert_fail ("my_world.stub", "wd_of_ants.c", 52, __extension__ __PRETTY_FUNCTION__); }));
 del_rtree( ob );
}

variable_types: struct rtree { struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } *adam; struct rtree_nblk { struct rtree_n node[-1]; struct rtree_nblk *next; } first_blk; struct rtree_nblk *cur_blk; int cur_cnt; int not_del_cnt; } *

return_type: void


decompiled_code:
__int64 add_random_barriers()
{
int v0; // ebx
float v1; // xmm0_4
float v2; // xmm1_4
__int64 result; // rax

v0 = 10;
do
{
v1 = (float)(rand() % 100) / 25.0 - 2.0;
v2 = (float)(rand() % 100) / 25.0 - 2.0;
result = to_rtree(my_world, 1LL, v1, v2);
--v0;
}
while ( v0 );
return result;
}

canonical_decompiled_code:
__int64 func2()
{
int v0; // ebx
float v1; // xmm0_4
float v2; // xmm1_4
__int64 result; // rax

v0 = 10;
do
{
v1 = (float)(rand() % 100) / 25.0 - 2.0;
v2 = (float)(rand() % 100) / 25.0 - 2.0;
result = to_rtree(my_world, 1LL, v1, v2);
--v0;
}
while ( v0 );
return result;
}

original_code:
void add_random_barriers( void )
{
 int i;
 for( i = 0; i < 10; i++ )
 {
  float xx = ( float )( rand() % 100 ) / 25.0 - 2.0;
  float yy = ( float )( rand() % 100 ) / 25.0 - 2.0;
  to_rtree( my_world.stub, xx, yy, ( void * )1 );
 }
}

canonical_original_code:
void add_random_barriers()
{
 int i;
 for( i = 0; i < 10; i++ )
 {
  float xx = ( float )( rand() % 100 ) / 25.0 - 2.0;
  float yy = ( float )( rand() % 100 ) / 25.0 - 2.0;
  to_rtree( my_world.stub, xx, yy, ( void * )1 );
 }
}

variable_types: i int

variable_types: xx float

variable_types: yy float


decompiled_code:
__int64 add_barriers_1()
{
int v0; // ebp
double v1; // rbx
__int64 result; // rax
float v3; // xmm2_4
float v4; // [rsp+Ch] [rbp-1Ch]

v0 = 15;
v4 = *(float *)&LC7;
v1 = *(double *)&LC8;
do
{
to_rtree(my_world, 1LL, v4, 0.69999999);
result = to_rtree(my_world, 1LL, v4, -0.69999999);
v3 = v1 + 0.08;
v4 = v3;
v1 = v3;
--v0;
}
while ( v0 );
return result;
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // ebp
double v1; // rbx
__int64 result; // rax
float v3; // xmm2_4
float v4; // [rsp+Ch] [rbp-1Ch]

v0 = 15;
v4 = *(float *)&LC7;
v1 = *(double *)&LC8;
do
{
to_rtree(my_world, 1LL, v4, 0.69999999);
result = to_rtree(my_world, 1LL, v4, -0.69999999);
v3 = v1 + 0.08;
v4 = v3;
v1 = v3;
--v0;
}
while ( v0 );
return result;
}

original_code:
void add_barriers_1( void )
{
 float xx;
 for( xx = -0.6; xx < 0.6; xx += 0.08 )
 {
  to_rtree( my_world.stub, xx, 0.7, ( void * )1 );
  to_rtree( my_world.stub, xx, -0.7, ( void * )1 );
 }
}

canonical_original_code:
void add_barriers_1()
{
 float xx;
 for( xx = -0.6; xx < 0.6; xx += 0.08 )
 {
  to_rtree( my_world.stub, xx, 0.7, ( void * )1 );
  to_rtree( my_world.stub, xx, -0.7, ( void * )1 );
 }
}


decompiled_code:
__int64 add_barriers_2()
{
int v0; // ebp
double v1; // rbx
__int64 result; // rax
float v3; // xmm4_4
float v4; // [rsp+Ch] [rbp-1Ch]

v0 = 15;
v4 = *(float *)&LC7;
v1 = *(double *)&LC8;
do
{
to_rtree(my_world, 1LL, 0.0, v4 + 1.0);
result = to_rtree(my_world, 1LL, 0.0, v4 - 1.0);
v3 = v1 + 0.08;
v4 = v3;
v1 = v3;
--v0;
}
while ( v0 );
return result;
}

canonical_decompiled_code:
__int64 func4()
{
int v0; // ebp
double v1; // rbx
__int64 result; // rax
float v3; // xmm4_4
float v4; // [rsp+Ch] [rbp-1Ch]

v0 = 15;
v4 = *(float *)&LC7;
v1 = *(double *)&LC8;
do
{
to_rtree(my_world, 1LL, 0.0, v4 + 1.0);
result = to_rtree(my_world, 1LL, 0.0, v4 - 1.0);
v3 = v1 + 0.08;
v4 = v3;
v1 = v3;
--v0;
}
while ( v0 );
return result;
}

original_code:
void add_barriers_2( void )
{
 float yy;
 for( yy = -0.6; yy < 0.6; yy += 0.08 )
 {
  to_rtree( my_world.stub, 0.0, yy + 1.0, ( void * )1 );
  to_rtree( my_world.stub, 0.0, yy - 1.0, ( void * )1 );
 }
}

canonical_original_code:
void add_barriers_2()
{
 float yy;
 for( yy = -0.6; yy < 0.6; yy += 0.08 )
 {
  to_rtree( my_world.stub, 0.0, yy + 1.0, ( void * )1 );
  to_rtree( my_world.stub, 0.0, yy - 1.0, ( void * )1 );
 }
}


decompiled_code:
__int64 wd_of_ants_init()
{
_QWORD *v0; // rax
void *v1; // rdi
__int64 i; // rdx
__int64 v3; // rax
float v4; // xmm0_4

my_world = 0LL;
qword_9E8 = 0LL;
qword_9F0 = 0LL;
qword_9F8 = 0LL;
qword_A00 = 0LL;
ptr = 0LL;
qword_A10 = 0LL;
qword_A18 = 0LL;
qword_A20 = 0LL;
qword_A28 = 0LL;
v0 = add_muvi_ant((__int64)&my_world, (__m128i)0LL, (__m128i)0LL, (__m128i)0LL);
add_sim_drv(&my_world, v0);
my_world = new_rtree();
if ( !my_world )
_assert_fail("my_world.stub", "wd_of_ants.c", 0x63u, "wd_of_ants_init");
qword_9F0 = 0x40A33333C0E33333LL;
qword_9F8 = 0x12C3CA3D70ALL;
LODWORD(qword_A00) = 200;
v1 = malloc(0xEA600uLL);
ptr = v1;
if ( !v1 )
_assert_fail("my_world.plan.pixs", "wd_of_ants.c", 0x6Eu, "wd_of_ants_init");
memset(v1, 0, 0xEA600uLL);
for ( i = 0LL; i != 60000; ++i )
{
v3 = 16 * i;
v4 = (float)(int)i / 60000.0;
*(float *)((char *)ptr + v3) = v4;
*(float *)((char *)ptr + v3 + 4) = 1.0 - v4;
*((float *)ptr + 4 * i + 2) = *((float *)ptr + 4 * i) * *((float *)ptr + 4 * i + 1);
}
puts("I am happy say you that: Make the World of Ants complete!");
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
_QWORD *v0; // rax
void *v1; // rdi
__int64 i; // rdx
__int64 v3; // rax
float v4; // xmm0_4

my_world = 0LL;
qword_9E8 = 0LL;
qword_9F0 = 0LL;
qword_9F8 = 0LL;
qword_A00 = 0LL;
ptr = 0LL;
qword_A10 = 0LL;
qword_A18 = 0LL;
qword_A20 = 0LL;
qword_A28 = 0LL;
v0 = add_muvi_ant((__int64)&my_world, (__m128i)0LL, (__m128i)0LL, (__m128i)0LL);
add_sim_drv(&my_world, v0);
my_world = new_rtree();
if ( !my_world )
_assert_fail("my_world.stub", "wd_of_ants.c", 0x63u, "wd_of_ants_init");
qword_9F0 = 0x40A33333C0E33333LL;
qword_9F8 = 0x12C3CA3D70ALL;
LODWORD(qword_A00) = 200;
v1 = malloc(0xEA600uLL);
ptr = v1;
if ( !v1 )
_assert_fail("my_world.plan.pixs", "wd_of_ants.c", 0x6Eu, "wd_of_ants_init");
memset(v1, 0, 0xEA600uLL);
for ( i = 0LL; i != 60000; ++i )
{
v3 = 16 * i;
v4 = (float)(int)i / 60000.0;
*(float *)((char *)ptr + v3) = v4;
*(float *)((char *)ptr + v3 + 4) = 1.0 - v4;
*((float *)ptr + 4 * i + 2) = *((float *)ptr + 4 * i) * *((float *)ptr + 4 * i + 1);
}
puts("I am happy say you that: Make the World of Ants complete!");
return 0LL;
}

original_code:
int wd_of_ants_init( void )
{
 memset( &my_world, 0, sizeof( my_world ) );
 ant * first_ant = add_muvi_ant( &my_world, 0, 0, 0 );
 add_sim_drv( &my_world, first_ant );
 my_world.stub = new_rtree();
 ((void) sizeof ((my_world.stub) ? 1 : 0), __extension__ ({ if (my_world.stub) ; else __assert_fail ("my_world.stub", "wd_of_ants.c", 99, __extension__ __PRETTY_FUNCTION__); }));
 my_world.plan.left_up_x = -7.1 ;
 my_world.plan.left_up_y = 5.1;
 my_world.plan.pix_side = 0.02;
 my_world.plan.width = 300;
 my_world.plan.hight = 200;
 int pix_num = my_world.plan.width * my_world.plan.hight;
 my_world.plan.pixs = ( pix * )malloc( sizeof( pix ) * pix_num );
 ((void) sizeof ((my_world.plan.pixs) ? 1 : 0), __extension__ ({ if (my_world.plan.pixs) ; else __assert_fail ("my_world.plan.pixs", "wd_of_ants.c", 110, __extension__ __PRETTY_FUNCTION__); }));
 memset( my_world.plan.pixs, 0, pix_num * sizeof( pix ) );
 int i;
 for( i = 0; i < pix_num; i++ )
 {
  my_world.plan.pixs[ i ].red = ( float )i / ( float )pix_num;
  my_world.plan.pixs[ i ].green = 1.0 - ( float )i / ( float )pix_num;
  my_world.plan.pixs[ i ].blue =
   my_world.plan.pixs[ i ].red * my_world.plan.pixs[ i ].green;
 }
 printf( "I am happy say you that: Make the World of Ants complete!\n" );
 return 0;
}

canonical_original_code:
int wd_of_ants_init()
{
 memset( &my_world, 0, sizeof( my_world ) );
 struct ant *first_ant = add_muvi_ant( &my_world, 0, 0, 0 );
 add_sim_drv( &my_world, first_ant );
 my_world.stub = new_rtree();
 ((void) sizeof ((my_world.stub) ? 1 : 0), __extension__ ({ if (my_world.stub) ; else __assert_fail ("my_world.stub", "wd_of_ants.c", 99, __extension__ __PRETTY_FUNCTION__); }));
 my_world.plan.left_up_x = -7.1 ;
 my_world.plan.left_up_y = 5.1;
 my_world.plan.pix_side = 0.02;
 my_world.plan.width = 300;
 my_world.plan.hight = 200;
 int pix_num = my_world.plan.width * my_world.plan.hight;
 my_world.plan.pixs = ( struct pix * )malloc( sizeof( pix ) * pix_num );
 ((void) sizeof ((my_world.plan.pixs) ? 1 : 0), __extension__ ({ if (my_world.plan.pixs) ; else __assert_fail ("my_world.plan.pixs", "wd_of_ants.c", 110, __extension__ __PRETTY_FUNCTION__); }));
 memset( my_world.plan.pixs, 0, pix_num * sizeof( pix ) );
 int i;
 for( i = 0; i < pix_num; i++ )
 {
  my_world.plan.pixs[ i ].red = ( float )i / ( float )pix_num;
  my_world.plan.pixs[ i ].green = 1.0 - ( float )i / ( float )pix_num;
  my_world.plan.pixs[ i ].blue =
   my_world.plan.pixs[ i ].red * my_world.plan.pixs[ i ].green;
 }
 printf( "I am happy say you that: Make the World of Ants complete!\n" );
 return 0;
}

variable_types: struct ant { struct pix { float red; float green; float blue; int state; } cpix; float pos_x; float pos_ang; float left_angle; float right_angle; float left_speed; float right_speed; float axis_len; float tire_radius; float nose_len; struct ant *next; } *

return_type: int


decompiled_code:
void wd_of_ants_destroy()
{
void *v0; // rbx
void *v1; // rdi

if ( qword_A20 )
del_free_pixels();
if ( qword_A18 )
del_free_pixels();
free(ptr);
del_rtree(my_world);
close_sim_drv();
v0 = qword_9E8;
while ( v0 )
{
v1 = v0;
v0 = (void *)*((_QWORD *)v0 + 7);
free(v1);
}
}

canonical_decompiled_code:
void func6()
{
void *v0; // rbx
void *v1; // rdi

if ( qword_A20 )
del_free_pixels();
if ( qword_A18 )
del_free_pixels();
free(ptr);
del_rtree(my_world);
close_sim_drv();
v0 = qword_9E8;
while ( v0 )
{
v1 = v0;
v0 = (void *)*((_QWORD *)v0 + 7);
free(v1);
}
}

original_code:
void wd_of_ants_destroy( void )
{
 if( my_world.free_pixs_4del ) del_free_pixels( my_world.free_pixs_4del );
 if( my_world.free_pixs ) del_free_pixels( my_world.free_pixs );
 free( my_world.plan.pixs );
 del_rtree( my_world.stub );
 close_sim_drv();
 ant * cant = my_world.muvis;
 while( cant )
 {
  ant * rip = cant;
  cant = cant->next;
  free( rip );
 }
}

canonical_original_code:
void wd_of_ants_destroy()
{
 if( my_world.free_pixs_4del ) del_free_pixels( my_world.free_pixs_4del );
 if( my_world.free_pixs ) del_free_pixels( my_world.free_pixs );
 free( my_world.plan.pixs );
 del_rtree( my_world.stub );
 close_sim_drv();
 struct ant *cant = my_world.muvis;
 while( cant )
 {
  struct ant *rip = cant;
  cant = cant->next;
  free( rip );
 }
}

user_defined_types: struct pix { float red; float green; float blue; int state; }


original_code:
void wd_of_ants_run( void )
{
 exec_sim_drv();
 ant * cant = my_world.muvis;
 while( cant )
 {
  float lrotate = cant->left_speed * 0.0002;
  float rrotate = cant->right_speed * 0.0002;
  cant->left_angle += lrotate;
  cant->right_angle += rrotate;
  cant->left_angle = (cant->left_angle > 2*3.14159265358979323846) ? cant->left_angle-2*3.14159265358979323846 : cant->left_angle;
  cant->right_angle = (cant->right_angle > 2*3.14159265358979323846) ? cant->right_angle-2*3.14159265358979323846 : cant->right_angle;
  float lmove = lrotate * cant->tire_radius;
  float rmove = rrotate * cant->tire_radius;
  float move = ( lmove + rmove ) / 2.0;
  cant->pos_x += cos( cant->pos_ang ) * move;
  cant->pos_y += sin( cant->pos_ang ) * move;
  cant->pos_ang += ( rmove - lmove ) / cant->axis_len;
  cant->pos_ang = (cant->pos_ang > 2*3.14159265358979323846) ? cant->pos_ang-2*3.14159265358979323846 : cant->pos_ang;
  cant->pos_ang = (cant->pos_ang < -2*3.14159265358979323846) ? cant->pos_ang+2*3.14159265358979323846 : cant->pos_ang;
  cant = cant->next;
 }
 if( !( my_world.sim_cnt % 16000 ) )
 {
  free_pixels * new_data = new_free_pixels();
  int i;
  for( i = 0; i < 1600; i++ )
  {
   float x = ( float )( rand() % 100 ) / 25.0 - 2.0;
   float y = ( float )( rand() % 100 ) / 25.0 - 2.0;
   float r = ( float )( rand() % 100 ) / 100.0;
   float g = ( float )( rand() % 100 ) / 100.0;
   float b = ( float )( rand() % 100 ) / 100.0;
   float ang = ( float )( rand() % 628 ) / 100.0;
   if( ( x < 0.1 ) && ( y > -0.1 ) ) continue;
   if( get_next_near( my_world.stub->adam, x, y, 0.45 ) )
    continue;
   add_pixel( new_data, x, y, r, g, b, ang );
  }
  if( my_world.free_pixs_4del ) del_free_pixels( my_world.free_pixs_4del );
  my_world.free_pixs_4del = my_world.free_pixs;
  my_world.free_pixs = new_data;
 }
 my_world.sim_cnt++;
}

canonical_original_code:
void wd_of_ants_run()
{
 exec_sim_drv();
 struct ant *cant = my_world.muvis;
 while( cant )
 {
  float lrotate = cant->left_speed * 0.0002;
  float rrotate = cant->right_speed * 0.0002;
  cant->left_angle += lrotate;
  cant->right_angle += rrotate;
  cant->left_angle = (cant->left_angle > 2*3.14159265358979323846) ? cant->left_angle-2*3.14159265358979323846 : cant->left_angle;
  cant->right_angle = (cant->right_angle > 2*3.14159265358979323846) ? cant->right_angle-2*3.14159265358979323846 : cant->right_angle;
  float lmove = lrotate * cant->tire_radius;
  float rmove = rrotate * cant->tire_radius;
  float move = ( lmove + rmove ) / 2.0;
  cant->pos_x += cos( cant->pos_ang ) * move;
  cant->pos_y += sin( cant->pos_ang ) * move;
  cant->pos_ang += ( rmove - lmove ) / cant->axis_len;
  cant->pos_ang = (cant->pos_ang > 2*3.14159265358979323846) ? cant->pos_ang-2*3.14159265358979323846 : cant->pos_ang;
  cant->pos_ang = (cant->pos_ang < -2*3.14159265358979323846) ? cant->pos_ang+2*3.14159265358979323846 : cant->pos_ang;
  cant = cant->next;
 }
 if( !( my_world.sim_cnt % 16000 ) )
 {
  struct free_pixels *new_data = new_free_pixels();
  int i;
  for( i = 0; i < 1600; i++ )
  {
   float x = ( float )( rand() % 100 ) / 25.0 - 2.0;
   float y = ( float )( rand() % 100 ) / 25.0 - 2.0;
   float r = ( float )( rand() % 100 ) / 100.0;
   float g = ( float )( rand() % 100 ) / 100.0;
   float b = ( float )( rand() % 100 ) / 100.0;
   float ang = ( float )( rand() % 628 ) / 100.0;
   if( ( x < 0.1 ) && ( y > -0.1 ) ) continue;
   if( get_next_near( my_world.stub->adam, x, y, 0.45 ) )
    continue;
   add_pixel( new_data, x, y, r, g, b, ang );
  }
  if( my_world.free_pixs_4del ) del_free_pixels( my_world.free_pixs_4del );
  my_world.free_pixs_4del = my_world.free_pixs;
  my_world.free_pixs = new_data;
 }
 my_world.sim_cnt++;
}

variable_types: lrotate float

variable_types: rrotate float

variable_types: lmove float

variable_types: rmove float

variable_types: move float

variable_types: struct free_pixels { int pix_cnt; struct free_pix_blk { struct free_pix { float x; float red; float green; float blue; float angle; float state; } pix[100]; struct free_pix_blk *next; } *last_blk; struct rtree { struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } *adam; struct rtree_nblk { struct rtree_n node[-1]; struct rtree_nblk *next; } first_blk; struct rtree_nblk *cur_blk; int cur_cnt; int not_del_cnt; } *tree; } *

variable_types: x float

variable_types: y float

variable_types: r float

variable_types: g float

variable_types: b float

variable_types: ang float


decompiled_code:
__int64 __fastcall ant_catch_pix(__int64 a1, __int64 a2, float a3, float a4, float a5)
{
double v5; // xmm0_8
double v6; // xmm1_8
__int64 result; // rax
double cosx; // [rsp+10h] [rbp-28h] BYREF
double sinx[4]; // [rsp+18h] [rbp-20h] BYREF

*(_DWORD *)(a2 + 12) = 0;
sincos(*(float *)(a2 + 24), sinx, &cosx);
v5 = *(float *)(a2 + 52);
v6 = *(float *)(a2 + 20) + v5 * sinx[0];
*(float *)&v5 = v5 * cosx + *(float *)(a2 + 16);
*(float *)&v6 = v6;
result = booking_free_pix(*(_QWORD *)(a1 + 56), 13LL, *(float *)&v5, *(float *)&v6, 0.0099999998, a3, a4, a5);
if ( result )
{
*(_DWORD *)a2 = *(_DWORD *)(result + 8);
*(_DWORD *)(a2 + 4) = *(_DWORD *)(result + 12);
*(_DWORD *)(a2 + 8) = *(_DWORD *)(result + 16);
++*(_DWORD *)(a2 + 12);
*(float *)(result + 24) = *(float *)(result + 24) + 1.0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, float a3, float a4, float a5)
{
double v5; // xmm0_8
double v6; // xmm1_8
__int64 result; // rax
double cosx; // [rsp+10h] [rbp-28h] BYREF
double sinx[4]; // [rsp+18h] [rbp-20h] BYREF

*(_DWORD *)(a2 + 12) = 0;
sincos(*(float *)(a2 + 24), sinx, &cosx);
v5 = *(float *)(a2 + 52);
v6 = *(float *)(a2 + 20) + v5 * sinx[0];
*(float *)&v5 = v5 * cosx + *(float *)(a2 + 16);
*(float *)&v6 = v6;
result = booking_free_pix(*(_QWORD *)(a1 + 56), 13LL, *(float *)&v5, *(float *)&v6, 0.0099999998, a3, a4, a5);
if ( result )
{
*(_DWORD *)a2 = *(_DWORD *)(result + 8);
*(_DWORD *)(a2 + 4) = *(_DWORD *)(result + 12);
*(_DWORD *)(a2 + 8) = *(_DWORD *)(result + 16);
++*(_DWORD *)(a2 + 12);
*(float *)(result + 24) = *(float *)(result + 24) + 1.0;
}
return result;
}

original_code:
void ant_catch_pix( wd_of_ants * wd, ant * at, float r, float g, float b )
{
 at->cpix.state = 0;
 float nx = at->pos_x + cos( at->pos_ang ) * at->nose_len;
 float ny = at->pos_y + sin( at->pos_ang ) * at->nose_len;
 free_pix * bpix = 0l;
 bpix = booking_free_pix( wd->free_pixs, nx, ny,
  0.01 , r, g, b, 13 );
 if( !bpix ) return;
 at->cpix.red = bpix->red;
 at->cpix.green = bpix->green;
 at->cpix.blue = bpix->blue;
 at->cpix.state++;
 bpix->state++;
}

canonical_original_code:
void ant_catch_pix(struct wd_of_ants *wd, struct ant *at, float r, float g, float b)
{
 at->cpix.state = 0;
 float nx = at->pos_x + cos( at->pos_ang ) * at->nose_len;
 float ny = at->pos_y + sin( at->pos_ang ) * at->nose_len;
 struct free_pix *bpix = 0l;
 bpix = booking_free_pix( wd->free_pixs, nx, ny,
  0.01 , r, g, b, 13 );
 if( !bpix ) return;
 at->cpix.red = bpix->red;
 at->cpix.green = bpix->green;
 at->cpix.blue = bpix->blue;
 at->cpix.state++;
 bpix->state++;
}

variable_types: struct wd_of_ants { struct rtree { struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } *adam; struct rtree_nblk { struct rtree_n node[-1]; struct rtree_nblk *next; } first_blk; struct rtree_nblk *cur_blk; int cur_cnt; int not_del_cnt; } *stub; struct ant { struct pix { float red; float green; float blue; int state; } cpix; float pos_x; float pos_ang; float left_angle; float right_angle; float left_speed; float right_speed; float axis_len; float tire_radius; float nose_len; struct ant *next; } *muvis; struct genplan { float left_up_x; float left_up_y; float pix_side; int width; int hight; struct pix *pixs; int last_tasked; } plan; struct free_pixels { int pix_cnt; struct free_pix_blk { struct free_pix { float x; float red; float green; float blue; float angle; float state; } pix[100]; struct free_pix_blk *next; } *last_blk; struct rtree *tree; } *free_pixs; struct free_pixels *free_pixs_4del; unsigned long sim_cnt; } *

variable_types:
at
struct ant *

variable_types: nx float

variable_types: ny float

variable_types: struct free_pix { float x; float red; float green; float blue; float angle; float state; } *


decompiled_code:
_BOOL8 __fastcall is_good_xy(float *a1, float a2, float a3, float a4)
{
_BOOL8 result; // rax

result = 0LL;
if ( (float)(a1[1] - a4) <= a2 && a2 <= (float)(a4 + *a1) && (float)(a1[3] - a4) <= a3 )
result = a3 <= (float)(a4 + a1[2]);
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(float *a1, float a2, float a3, float a4)
{
_BOOL8 result; // rax

result = 0LL;
if ( (float)(a1[1] - a4) <= a2 && a2 <= (float)(a4 + *a1) && (float)(a1[3] - a4) <= a3 )
result = a3 <= (float)(a4 + a1[2]);
return result;
}

original_code:
static int is_good_xy( rtree_n * n, float x, float y, float delta )
{
 if( x < ( n->min_x - delta ) ) return 0;
 if( x > ( n->max_x + delta ) ) return 0;
 if( y < ( n->min_y - delta ) ) return 0;
 if( y > ( n->max_y + delta ) ) return 0;
 return 1;
}

canonical_original_code:
static int is_good_xy(struct rtree_n *n, float x, float y, float delta)
{
 if( x < ( n->min_x - delta ) ) return 0;
 if( x > ( n->max_x + delta ) ) return 0;
 if( y < ( n->min_y - delta ) ) return 0;
 if( y > ( n->max_y + delta ) ) return 0;
 return 1;
}

variable_types: struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } *

variable_types: delta float


decompiled_code:
float *__fastcall get_down(__int64 a1, float a2, float a3, float a4)
{
float *v5; // rbp

do
{
v5 = (float *)a1;
a1 = *(_QWORD *)(a1 + 32);
}
while ( a1 && is_good_xy(v5, a2, a3, a4) );
return v5;
}

canonical_decompiled_code:
float *__fastcall func8(__int64 a1, float a2, float a3, float a4)
{
float *v5; // rbp

do
{
v5 = (float *)a1;
a1 = *(_QWORD *)(a1 + 32);
}
while ( a1 && func7(v5, a2, a3, a4) );
return v5;
}

original_code:
static rtree_n * get_down( rtree_n * cur_n, float x, float y, float delta )
{
 while( cur_n->child )
 {
  if( !is_good_xy( cur_n, x, y, delta ) ) break;
  cur_n = cur_n->child;
 }
 return cur_n;
}

canonical_original_code:
static struct rtree_n *get_down(struct rtree_n *cur_n, float x, float y, float delta)
{
 while( cur_n->child )
 {
  if( !is_good_xy( cur_n, x, y, delta ) ) break;
  cur_n = cur_n->child;
 }
 return cur_n;
}

return_type: struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } *


decompiled_code:
__int64 __fastcall get_right(__int64 a1)
{
__int64 result; // rax

if ( !a1 )
return 0LL;
while ( 1 )
{
result = *(_QWORD *)(a1 + 40);
if ( result )
break;
a1 = *(_QWORD *)(a1 + 24);
if ( !a1 )
return 0LL;
}
return result;
}

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

if ( !a1 )
return 0LL;
while ( 1 )
{
result = *(_QWORD *)(a1 + 40);
if ( result )
break;
a1 = *(_QWORD *)(a1 + 24);
if ( !a1 )
return 0LL;
}
return result;
}

original_code:
static rtree_n * get_right( rtree_n * cur_n )
{
 while( cur_n )
 {
  if( cur_n->sister )
  {
   return cur_n->sister;
  }
  cur_n = cur_n->parent;
 }
 return cur_n;
}

canonical_original_code:
static struct rtree_n *get_right(struct rtree_n *cur_n)
{
 while( cur_n )
 {
  if( cur_n->sister )
  {
   return cur_n->sister;
  }
  cur_n = cur_n->parent;
 }
 return cur_n;
}

user_defined_types: struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; }


original_code:
static void to_rtree_node( rtree * rt, rtree_n * parent, rtree_n * child )
{
 if( parent->val )
 {
  rtree_n * nn = get_new_node( rt );
  nn->max_x = nn->min_x = parent->max_x;
  nn->max_y = nn->min_y = parent->max_y;
  nn->val = parent->val;
  nn->parent = parent;
  parent->val = 0l;
  parent->child = nn;
 }
 parent->max_x = ( child->max_x > parent->max_x ) ? child->max_x : parent->max_x;
 parent->max_y = ( child->max_y > parent->max_y ) ? child->max_y : parent->max_y;
 parent->min_x = ( child->min_x < parent->min_x ) ? child->min_x : parent->min_x;
 parent->min_y = ( child->min_y < parent->min_y ) ? child->min_y : parent->min_y;
 float min_dS;
 rtree_n * best_child = parent->child;
 int i;
 rtree_n * tnod = parent->child;
 for( i = 0; i < (4); i++ )
 {
  if( !tnod )
  {
   child->sister = parent->child;
   parent->child = child;
   child->parent = parent;
   return;
  }
  float max_x = ( child->max_x > tnod->max_x ) ? child->max_x : tnod->max_x;
  float max_y = ( child->max_y > tnod->max_y ) ? child->max_y : tnod->max_y;
  float min_x = ( child->min_x < tnod->min_x ) ? child->min_x : tnod->min_x;
  float min_y = ( child->min_y < tnod->min_y ) ? child->min_y : tnod->min_y;
  float dS = ( max_x - min_x ) * ( max_y - min_y );
  dS -= ( tnod->max_x - tnod->min_x ) * ( tnod->max_y - tnod->min_y );
  min_dS = !i ? dS : min_dS;
  if( min_dS > dS )
  {
   min_dS = dS;
   best_child = tnod;
  }
  tnod = tnod->sister;
 }
 to_rtree_node( rt, best_child, child );
}

canonical_original_code:
static void to_rtree_node(struct rtree *rt, struct rtree_n *parent, struct rtree_n *child)
{
 if( parent->val )
 {
  struct rtree_n *nn = get_new_node( rt );
  nn->max_x = nn->min_x = parent->max_x;
  nn->max_y = nn->min_y = parent->max_y;
  nn->val = parent->val;
  nn->parent = parent;
  parent->val = 0l;
  parent->child = nn;
 }
 parent->max_x = ( child->max_x > parent->max_x ) ? child->max_x : parent->max_x;
 parent->max_y = ( child->max_y > parent->max_y ) ? child->max_y : parent->max_y;
 parent->min_x = ( child->min_x < parent->min_x ) ? child->min_x : parent->min_x;
 parent->min_y = ( child->min_y < parent->min_y ) ? child->min_y : parent->min_y;
 float min_dS;
 struct rtree_n *best_child = parent->child;
 int i;
 struct rtree_n *tnod = parent->child;
 for( i = 0; i < (4); i++ )
 {
  if( !tnod )
  {
   child->sister = parent->child;
   parent->child = child;
   child->parent = parent;
   return;
  }
  float max_x = ( child->max_x > tnod->max_x ) ? child->max_x : tnod->max_x;
  float max_y = ( child->max_y > tnod->max_y ) ? child->max_y : tnod->max_y;
  float min_x = ( child->min_x < tnod->min_x ) ? child->min_x : tnod->min_x;
  float min_y = ( child->min_y < tnod->min_y ) ? child->min_y : tnod->min_y;
  float dS = ( max_x - min_x ) * ( max_y - min_y );
  dS -= ( tnod->max_x - tnod->min_x ) * ( tnod->max_y - tnod->min_y );
  min_dS = !i ? dS : min_dS;
  if( min_dS > dS )
  {
   min_dS = dS;
   best_child = tnod;
  }
  tnod = tnod->sister;
 }
 to_rtree_node( rt, best_child, child );
}

variable_types: struct rtree { struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } *adam; struct rtree_nblk { struct rtree_n node[-1]; struct rtree_nblk *next; } first_blk; struct rtree_nblk *cur_blk; int cur_cnt; int not_del_cnt; } *

variable_types:
parent
struct rtree_n *

variable_types:
child
struct rtree_n *

variable_types: i int

variable_types: dS float


original_code:
static void print_node( rtree_n * n )
{
 if( n->val )
 {
  rtree_n * show = n;
  while( show )
  {
   printf( "(x:%0.2f..%0.2f y:%0.2f..%0.2f)[%p] -> ", show->min_x,
    show->max_x, show->min_y, show->max_y, show->val );
   show = show->parent;
  }
  printf( "\n" );
  return;
 }
 rtree_n * cur_n = n->child;;
 while( cur_n )
 {
  print_node( cur_n );
  cur_n = cur_n->sister;
 }
}

canonical_original_code:
static void print_node(struct rtree_n *n)
{
 if( n->val )
 {
  struct rtree_n *show = n;
  while( show )
  {
   printf( "(x:%0.2f..%0.2f y:%0.2f..%0.2f)[%p] -> ", show->min_x,
    show->max_x, show->min_y, show->max_y, show->val );
   show = show->parent;
  }
  printf( "\n" );
  return;
 }
 struct rtree_n *cur_n = n->child;;
 while( cur_n )
 {
  print_node( cur_n );
  cur_n = cur_n->sister;
 }
}


decompiled_code:
_QWORD *new_rtree()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx

v0 = malloc(0x3A9A0uLL);
if ( !v0 )
__assert_fail(assertion, "rtree.c", 0xCu, "new_rtree");
v1 = v0;
memset(v0, 0, 0x3A9A0uLL);
v1[30002] = v1 + 1;
*((_DWORD *)v1 + 60007) = 1;
return v1;
}

canonical_decompiled_code:
_QWORD *func13()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx

v0 = malloc(0x3A9A0uLL);
if ( !v0 )
__assert_fail(assertion, "rtree.c", 0xCu, "new_rtree");
v1 = v0;
memset(v0, 0, 0x3A9A0uLL);
v1[30002] = v1 + 1;
*((_DWORD *)v1 + 60007) = 1;
return v1;
}

original_code:
rtree * new_rtree( void )
{
 rtree * new = ( rtree * )malloc( sizeof( struct rtree ) );
 ((void) sizeof ((new) ? 1 : 0), __extension__ ({ if (new) ; else __assert_fail ("new", "rtree.c", 12, __extension__ __PRETTY_FUNCTION__); }));
 memset( new, 0, sizeof( struct rtree ) );
 new->cur_blk = &( new->first_blk );
 new->not_del_cnt++;
 return new;
}

canonical_original_code:
struct rtree *new_rtree()
{
 struct rtree *new = ( rtree * )malloc( sizeof( struct rtree ) );
 ((void) sizeof ((new) ? 1 : 0), __extension__ ({ if (new) ; else __assert_fail ("new", "rtree.c", 12, __extension__ __PRETTY_FUNCTION__); }));
 memset( new, 0, sizeof( struct rtree ) );
 new->cur_blk = &( new->first_blk );
 new->not_del_cnt++;
 return new;
}

return_type: struct rtree { struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } *adam; struct rtree_nblk { struct rtree_n node[-1]; struct rtree_nblk *next; } first_blk; struct rtree_nblk *cur_blk; int cur_cnt; int not_del_cnt; } *


original_code:
void del_rtree( rtree * rt )
{
 rt->not_del_cnt--;
 if( rt->not_del_cnt )return;
 rtree_nblk * ct = rt->first_blk.next;
 while( ct )
 {
  rtree_nblk * kill = ct;
  ct = ct->next;
  free( kill );
 }
 free( rt );
}

canonical_original_code:
void del_rtree(struct rtree *rt)
{
 rt->not_del_cnt--;
 if( rt->not_del_cnt )return;
 struct rtree_nblk *ct = rt->first_blk.next;
 while( ct )
 {
  struct rtree_nblk *kill = ct;
  ct = ct->next;
  free( kill );
 }
 free( rt );
}

variable_types: struct rtree_nblk { struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } node[-1]; struct rtree_nblk *next; } *

user_defined_types: struct rtree_nblk { struct rtree_n node[-1]; struct rtree_nblk *next; }


decompiled_code:
void __fastcall not_del_rtree_pls(__int64 a1)
{
++*(_DWORD *)(a1 + 240028);
}

original_code:
void not_del_rtree_pls( rtree * rt )
{
 rt->not_del_cnt++;
}

canonical_original_code:
void not_del_rtree_pls(struct rtree *rt)
{
 rt->not_del_cnt++;
}


decompiled_code:
void __fastcall thx_may_del_rtree(void *a1)
{
del_rtree(a1);
}

canonical_decompiled_code:
void __fastcall func16(void *a1)
{
func14(a1);
}

original_code:
void thx_may_del_rtree( rtree * rt )
{
 del_rtree( rt );
}

canonical_original_code:
void thx_may_del_rtree(struct rtree *rt)
{
 del_rtree( rt );
}


decompiled_code:
__int64 __fastcall get_next_near(__int64 a1, float a2, float a3, float a4)
{
__int64 v4; // rbx
int v5; // ebp

if ( !a1 )
return 0LL;
v4 = a1;
v5 = 0;
do
{
if ( v5 )
v4 = get_right(v4);
else
v4 = (__int64)get_down(v4, a2, a3, a4);
v5 = ~v5;
}
while ( v4 && (!*(_QWORD *)(v4 + 16) || v4 == a1 || !is_good_xy((float *)v4, a2, a3, a4)) );
return v4;
}

original_code:
rtree_n * get_next_near( rtree_n * cur_n, float x, float y, float delta )
{
 if( !cur_n ) return 0l;
 rtree_n * next = cur_n;
 int to_right = 0;
 while( 1 )
 {
  next = to_right ? get_right( next ) : get_down( next, x, y, delta );
  to_right = ~to_right;
  if( !next ) break;
  if( next->val && ( next != cur_n ) )
  {
   if( is_good_xy( next, x, y, delta ) ) break;
  }
 }
 return next;
}

canonical_original_code:
struct rtree_n *get_next_near(struct rtree_n *cur_n, float x, float y, float delta)
{
 if( !cur_n ) return 0l;
 struct rtree_n *next = cur_n;
 int to_right = 0;
 while( 1 )
 {
  next = to_right ? get_right( next ) : get_down( next, x, y, delta );
  to_right = ~to_right;
  if( !next ) break;
  if( next->val && ( next != cur_n ) )
  {
   if( is_good_xy( next, x, y, delta ) ) break;
  }
 }
 return next;
}

variable_types: x float

variable_types: y float


decompiled_code:
int __fastcall print_rtree(__int64 *a1)
{
return print_node(*a1);
}

canonical_decompiled_code:
int __fastcall func19(__int64 *a1)
{
return func12(*a1);
}

original_code:
void print_rtree( rtree * rt )
{
 print_node( rt->adam );
}

canonical_original_code:
void print_rtree(struct rtree *rt)
{
 print_node( rt->adam );
}


original_code:
static rtree_n * get_new_node( rtree * rt )
{
 rtree_n * rval = rt->cur_blk->node + rt->cur_cnt;
 rt->cur_cnt++;
 if( rt->cur_cnt == (5000) )
 {
  rt->cur_cnt = 0;
  rtree_nblk * new = ( rtree_nblk * )malloc( sizeof( rtree_nblk ) );
  ((void) sizeof ((new) ? 1 : 0), __extension__ ({ if (new) ; else __assert_fail ("new", "rtree.c", 56, __extension__ __PRETTY_FUNCTION__); }));
  memset( new, 0, sizeof( rtree_nblk ) );
  rt->cur_blk->next = new;
  rt->cur_blk = new;
 }
 return rval;
}

canonical_original_code:
static struct rtree_n *get_new_node(struct rtree *rt)
{
 struct rtree_n *rval = rt->cur_blk->node + rt->cur_cnt;
 rt->cur_cnt++;
 if( rt->cur_cnt == (5000) )
 {
  rt->cur_cnt = 0;
  struct rtree_nblk *new = ( rtree_nblk * )malloc( sizeof( rtree_nblk ) );
  ((void) sizeof ((new) ? 1 : 0), __extension__ ({ if (new) ; else __assert_fail ("new", "rtree.c", 56, __extension__ __PRETTY_FUNCTION__); }));
  memset( new, 0, sizeof( rtree_nblk ) );
  rt->cur_blk->next = new;
  rt->cur_blk = new;
 }
 return rval;
}

variable_types: struct rtree { struct rtree_n *adam; struct rtree_nblk { struct rtree_n node[-1]; struct rtree_nblk *next; } first_blk; struct rtree_nblk *cur_blk; int cur_cnt; int not_del_cnt; } *


decompiled_code:
_QWORD *new_free_pixels()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
__int64 v2; // rax

v0 = malloc(0x18uLL);
if ( !v0 )
_assert_fail("new", "wd_free_pix.c", 0x10u, "new_free_pixels");
v1 = v0;
*v0 = 0LL;
v0[1] = 0LL;
v0[2] = 0LL;
v2 = new_rtree();
v1[2] = v2;
if ( !v2 )
_assert_fail("new->tree", "wd_free_pix.c", 0x14u, "new_free_pixels");
return v1;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
__int64 v2; // rax

v0 = malloc(0x18uLL);
if ( !v0 )
_assert_fail("new", "wd_free_pix.c", 0x10u, "new_free_pixels");
v1 = v0;
*v0 = 0LL;
v0[1] = 0LL;
v0[2] = 0LL;
v2 = new_rtree();
v1[2] = v2;
if ( !v2 )
_assert_fail("new->tree", "wd_free_pix.c", 0x14u, "new_free_pixels");
return v1;
}

original_code:
free_pixels * new_free_pixels( void )
{
 free_pixels * new = ( free_pixels * )malloc( sizeof( free_pixels ) );
 ((void) sizeof ((new) ? 1 : 0), __extension__ ({ if (new) ; else __assert_fail ("new", "wd_free_pix.c", 16, __extension__ __PRETTY_FUNCTION__); }));
 memset( new, 0, sizeof( free_pixels ) );
 new->tree = new_rtree();
 ((void) sizeof ((new->tree) ? 1 : 0), __extension__ ({ if (new->tree) ; else __assert_fail ("new->tree", "wd_free_pix.c", 20, __extension__ __PRETTY_FUNCTION__); }));
 return new;
}

canonical_original_code:
struct free_pixels *new_free_pixels()
{
 struct free_pixels *new = ( free_pixels * )malloc( sizeof( free_pixels ) );
 ((void) sizeof ((new) ? 1 : 0), __extension__ ({ if (new) ; else __assert_fail ("new", "wd_free_pix.c", 16, __extension__ __PRETTY_FUNCTION__); }));
 memset( new, 0, sizeof( free_pixels ) );
 new->tree = new_rtree();
 ((void) sizeof ((new->tree) ? 1 : 0), __extension__ ({ if (new->tree) ; else __assert_fail ("new->tree", "wd_free_pix.c", 20, __extension__ __PRETTY_FUNCTION__); }));
 return new;
}

variable_types: struct free_pixels { int pix_cnt; struct free_pix_blk { struct free_pix { float x; float red; float green; float blue; float angle; float state; } pix[100]; struct free_pix_blk *next; } *last_blk; struct rtree { struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } *adam; struct rtree_nblk { struct rtree_n node[-1]; struct rtree_nblk *next; } first_blk; struct rtree_nblk *cur_blk; int cur_cnt; int not_del_cnt; } *tree; } *


decompiled_code:
void __fastcall del_free_pixels(void *ptr)
{
_QWORD *v2; // rbx
void *v3; // rdi

del_rtree(*((_QWORD *)ptr + 2));
v2 = (_QWORD *)*((_QWORD *)ptr + 1);
while ( v2 )
{
v3 = v2;
v2 = (_QWORD *)v2[350];
free(v3);
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
_QWORD *v2; // rbx
void *v3; // rdi

del_rtree(*((_QWORD *)ptr + 2));
v2 = (_QWORD *)*((_QWORD *)ptr + 1);
while ( v2 )
{
v3 = v2;
v2 = (_QWORD *)v2[350];
free(v3);
}
free(ptr);
}

original_code:
void del_free_pixels( free_pixels * das )
{
 del_rtree( das->tree );
 free_pix_blk * cblk = das->last_blk;
 while( cblk )
 {
  free_pix_blk * kill_that = cblk;
  cblk = cblk->next;
  free( kill_that );
 }
 free( das );
}

canonical_original_code:
void del_free_pixels(struct free_pixels *das)
{
 del_rtree( das->tree );
 struct free_pix_blk *cblk = das->last_blk;
 while( cblk )
 {
  struct free_pix_blk *kill_that = cblk;
  cblk = cblk->next;
  free( kill_that );
 }
 free( das );
}

variable_types: struct free_pix_blk { struct free_pix { float x; float red; float green; float blue; float angle; float state; } pix[100]; struct free_pix_blk *next; } *


original_code:
void add_pixel( free_pixels * das, float x, float y,
                        float r, float g, float b, float angle )
{
 int b_in = das->pix_cnt % 100;
 if( !( b_in ) )
 {
  free_pix_blk * new = ( free_pix_blk * )malloc( sizeof( free_pix_blk ) );
  ((void) sizeof ((new) ? 1 : 0), __extension__ ({ if (new) ; else __assert_fail ("new", "wd_free_pix.c", 52, __extension__ __PRETTY_FUNCTION__); }));
  memset( new, 0, sizeof( free_pix_blk ) );
  new->next = das->last_blk;
  das->last_blk = new;
 }
 free_pix * pix = das->last_blk->pix + b_in;
 pix->red = r;
 pix->green = g;
 pix->blue = b;
 pix->angle = angle;
 pix->x = x;
 pix->y = y;
 to_rtree( das->tree, x, y, pix );
 das->pix_cnt++;
}

canonical_original_code:
void add_pixel(struct free_pixels *das, float x, float y, float r, float g, float b, float angle)
{
 int b_in = das->pix_cnt % 100;
 if( !( b_in ) )
 {
  struct free_pix_blk *new = ( free_pix_blk * )malloc( sizeof( free_pix_blk ) );
  ((void) sizeof ((new) ? 1 : 0), __extension__ ({ if (new) ; else __assert_fail ("new", "wd_free_pix.c", 52, __extension__ __PRETTY_FUNCTION__); }));
  memset( new, 0, sizeof( free_pix_blk ) );
  new->next = das->last_blk;
  das->last_blk = new;
 }
 struct free_pix *pix = das->last_blk->pix + b_in;
 pix->red = r;
 pix->green = g;
 pix->blue = b;
 pix->angle = angle;
 pix->x = x;
 pix->y = y;
 to_rtree( das->tree, x, y, pix );
 das->pix_cnt++;
}

variable_types: r float

variable_types: g float

variable_types: b float

variable_types: angle float

user_defined_types: struct free_pix { float x; float red; float green; float blue; float angle; float state; }


decompiled_code:
__int64 __fastcall find_next_pixel(__int64 a1, __int64 *a2)
{
__int64 *v3; // rbx
__int64 v4; // rdi
__int64 result; // rax
__int64 v6; // [rsp+8h] [rbp-10h] BYREF

v3 = a2;
v6 = 0LL;
if ( !a2 )
v3 = &v6;
v4 = *v3;
if ( !*v3 )
v4 = **(_QWORD **)(a1 + 16);
*v3 = v4;
result = get_next_near();
*v3 = result;
if ( result )
result = *(_QWORD *)(result + 16);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 *a2)
{
__int64 *v3; // rbx
__int64 v4; // rdi
__int64 result; // rax
__int64 v6; // [rsp+8h] [rbp-10h] BYREF

v3 = a2;
v6 = 0LL;
if ( !a2 )
v3 = &v6;
v4 = *v3;
if ( !*v3 )
v4 = **(_QWORD **)(a1 + 16);
*v3 = v4;
result = get_next_near();
*v3 = result;
if ( result )
result = *(_QWORD *)(result + 16);
return result;
}

original_code:
free_pix * find_next_pixel( free_pixels * das, rtree_n ** search,
                                float x, float y, float delta )
{
 rtree_n * cn = 0l;
 search = !search ? &cn : search;
 *search = !( *search ) ? das->tree->adam : ( *search );
 *search = get_next_near( *search, x, y, delta );
 free_pix * rv = ( *search ) ? ( free_pix * )( *search )->val : 0l;
 return rv;
}

canonical_original_code:
struct free_pix *find_next_pixel(struct free_pixels *das, struct rtree_n **search, float x, float y, float delta)
{
 struct rtree_n *cn = 0l;
 search = !search ? &cn : search;
 *search = !( *search ) ? das->tree->adam : ( *search );
 *search = get_next_near( *search, x, y, delta );
 struct free_pix *rv = ( *search ) ? ( free_pix * )( *search )->val : 0l;
 return rv;
}

variable_types: struct free_pixels { int pix_cnt; struct free_pix_blk { struct free_pix pix[100]; struct free_pix_blk *next; } *last_blk; struct rtree { struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } *adam; struct rtree_nblk { struct rtree_n node[-1]; struct rtree_nblk *next; } first_blk; struct rtree_nblk *cur_blk; int cur_cnt; int not_del_cnt; } *tree; } *

variable_types:
search
struct rtree_n **

variable_types: struct free_pix { float x; float red; float green; float blue; float angle; float state; } *


original_code:
free_pix * booking_free_pix( free_pixels * das, float x, float y,
                        float delta, float r, float g, float b, int only_free )
{
 free_pix * select = 0l;
 float color_distance = 999.99;
 rtree_n * search = 0l;
 free_pix * pix;
 while( ( pix = find_next_pixel( das, &search, x, y, delta ) ) )
 {
  if( only_free && pix->state ) continue;
  float c_dist = sqrt( ( r - pix->red ) * ( r - pix->red ) +
   ( g - pix->green ) * ( g - pix->green ) +
   ( b - pix->blue ) * ( b - pix->blue ) );
  if( c_dist < color_distance )
  {
   color_distance = c_dist;
   select = pix;
  }
 }
 if( color_distance > 0.2 ) return 0l;
 return select;
}

canonical_original_code:
struct free_pix *booking_free_pix(struct free_pixels *das, float x, float y, float delta, float r, float g, float b, int only_free)
{
 struct free_pix *select = 0l;
 float color_distance = 999.99;
 struct rtree_n *search = 0l;
 struct free_pix *pix;
 while( ( pix = find_next_pixel( das, &search, x, y, delta ) ) )
 {
  if( only_free && pix->state ) continue;
  float c_dist = sqrt( ( r - pix->red ) * ( r - pix->red ) +
   ( g - pix->green ) * ( g - pix->green ) +
   ( b - pix->blue ) * ( b - pix->blue ) );
  if( c_dist < color_distance )
  {
   color_distance = c_dist;
   select = pix;
  }
 }
 if( color_distance > 0.2 ) return 0l;
 return select;
}

variable_types: delta float

variable_types: struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } *

return_type: struct free_pix { float x; float red; float green; float blue; float angle; float state; } *


original_code:
int get_next_task( task * pt, ant * pa, wd_of_ants * wd )
{
 free_pix * bpix = 0l;
 if( !wd->free_pixs ) return -1;
 if( wd->plan.width * wd->plan.hight <= wd->plan.last_tasked ) return -1;
 pt->dst_pix = wd->plan.pixs + wd->plan.last_tasked;
 pt->dst_x = wd->plan.left_up_x
  + ( wd->plan.last_tasked % wd->plan.width ) * wd->plan.pix_side;
 pt->dst_y = wd->plan.left_up_y
  - ( wd->plan.last_tasked / wd->plan.width ) * wd->plan.pix_side - pa->nose_len;
 pt->dst_ang = 3.14159265358979323846/2.0;
 bpix = booking_free_pix( wd->free_pixs, 0.0, 0.0,
                   100.0 , pt->dst_pix->red, pt->dst_pix->green, pt->dst_pix->blue, 13 );
 if( !bpix ) return -1;
 pt->tg_x = bpix->x - cos( bpix->angle ) * pa->nose_len;
 pt->tg_y = bpix->y - sin( bpix->angle ) * pa->nose_len;
 pt->tg_ang = bpix->angle;
 pt->tg_r = bpix->red;
 pt->tg_g = bpix->green;
 pt->tg_b = bpix->blue;
 wd->plan.last_tasked++;
        return 0;
}

canonical_original_code:
int get_next_task(struct task *pt, struct ant *pa, struct wd_of_ants *wd)
{
 struct free_pix *bpix = 0l;
 if( !wd->free_pixs ) return -1;
 if( wd->plan.width * wd->plan.hight <= wd->plan.last_tasked ) return -1;
 pt->dst_pix = wd->plan.pixs + wd->plan.last_tasked;
 pt->dst_x = wd->plan.left_up_x
  + ( wd->plan.last_tasked % wd->plan.width ) * wd->plan.pix_side;
 pt->dst_y = wd->plan.left_up_y
  - ( wd->plan.last_tasked / wd->plan.width ) * wd->plan.pix_side - pa->nose_len;
 pt->dst_ang = 3.14159265358979323846/2.0;
 bpix = booking_free_pix( wd->free_pixs, 0.0, 0.0,
                   100.0 , pt->dst_pix->red, pt->dst_pix->green, pt->dst_pix->blue, 13 );
 if( !bpix ) return -1;
 pt->tg_x = bpix->x - cos( bpix->angle ) * pa->nose_len;
 pt->tg_y = bpix->y - sin( bpix->angle ) * pa->nose_len;
 pt->tg_ang = bpix->angle;
 pt->tg_r = bpix->red;
 pt->tg_g = bpix->green;
 pt->tg_b = bpix->blue;
 wd->plan.last_tasked++;
        return 0;
}

variable_types: struct task { float tg_r; float tg_g; float tg_b; float tg_x; float tg_y; float tg_ang; float dst_x; float dst_y; float dst_ang; struct pix { float red; float green; float blue; int state; } *dst_pix; } *

variable_types: struct ant { struct pix cpix; float pos_x; float pos_ang; float left_angle; float right_angle; float left_speed; float right_speed; float axis_len; float tire_radius; float nose_len; struct ant *next; } *

variable_types: struct wd_of_ants { struct rtree { struct rtree_n { float max_x; float min_x; float max_y; float min_y; void *val; struct rtree_n *parent; struct rtree_n *child; struct rtree_n *sister; } *adam; struct rtree_nblk { struct rtree_n node[-1]; struct rtree_nblk *next; } first_blk; struct rtree_nblk *cur_blk; int cur_cnt; int not_del_cnt; } *stub; struct ant *muvis; struct genplan { float left_up_x; float left_up_y; float pix_side; int width; int hight; struct pix *pixs; int last_tasked; } plan; struct free_pixels { int pix_cnt; struct free_pix_blk { struct free_pix { float x; float red; float green; float blue; float angle; float state; } pix[100]; struct free_pix_blk *next; } *last_blk; struct rtree *tree; } *free_pixs; struct free_pixels *free_pixs_4del; unsigned long sim_cnt; } *

user_defined_types: struct task { float tg_r; float tg_g; float tg_b; float tg_x; float tg_y; float tg_ang; float dst_x; float dst_y; float dst_ang; struct pix *dst_pix; }


original_code:
int reset_task( task * pt, ant * pa, wd_of_ants * wd )
{
 if( !wd->free_pixs ) return -1;
 free_pix * bpix = 0l;
 bpix = booking_free_pix( wd->free_pixs, pt->tg_x + cos( pt->tg_ang ) * pa->nose_len,
  pt->tg_y + sin( pt->tg_ang ) * pa->nose_len, 0.02 , pt->tg_r, pt->tg_g, pt->tg_b, 13 );
 if( bpix )
 {
  bpix->state++;
 }
 bpix = booking_free_pix( wd->free_pixs, 0.0, 0.0,
  100.0 , pt->dst_pix->red, pt->dst_pix->green, pt->dst_pix->blue, 13 );
 if( !bpix ) return -1;
 pt->tg_x = bpix->x - cos( bpix->angle ) * pa->nose_len;
 pt->tg_y = bpix->y - sin( bpix->angle ) * pa->nose_len;
 pt->tg_ang = bpix->angle;
 pt->tg_r = bpix->red;
 pt->tg_g = bpix->green;
 pt->tg_b = bpix->blue;
 return 0;
}

canonical_original_code:
int reset_task(struct task *pt, struct ant *pa, struct wd_of_ants *wd)
{
 if( !wd->free_pixs ) return -1;
 struct free_pix *bpix = 0l;
 bpix = booking_free_pix( wd->free_pixs, pt->tg_x + cos( pt->tg_ang ) * pa->nose_len,
  pt->tg_y + sin( pt->tg_ang ) * pa->nose_len, 0.02 , pt->tg_r, pt->tg_g, pt->tg_b, 13 );
 if( bpix )
 {
  bpix->state++;
 }
 bpix = booking_free_pix( wd->free_pixs, 0.0, 0.0,
  100.0 , pt->dst_pix->red, pt->dst_pix->green, pt->dst_pix->blue, 13 );
 if( !bpix ) return -1;
 pt->tg_x = bpix->x - cos( bpix->angle ) * pa->nose_len;
 pt->tg_y = bpix->y - sin( bpix->angle ) * pa->nose_len;
 pt->tg_ang = bpix->angle;
 pt->tg_r = bpix->red;
 pt->tg_g = bpix->green;
 pt->tg_b = bpix->blue;
 return 0;
}

user_defined_types: struct genplan { float left_up_x; float left_up_y; float pix_side; int width; int hight; struct pix *pixs; int last_tasked; }


die

repo: sanbeg/fisher-price-keyboard

decompiled_code:
void __fastcall __noreturn die(const char *a1)
{
perror(a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func8(const char *a1)
{
perror(a1);
exit(1);
}

original_code:
void die(const char * msg)
{
  perror(msg);
  exit(1);
}

canonical_original_code:
void die(char *msg)
{
  perror(msg);
  exit(1);
}

variable_types:
msg
char *


decompiled_code:
int print_nodelist_to_file()
{
_QWORD *v0; // rbx

v0 = head;
fptr = fopen("S_malloc_logs.txt", "w");
if ( !fptr )
{
puts("\nFailure: Cannot Open Log-File for Writing\n");
exit(1);
}
for ( ; v0; v0 = (_QWORD *)v0[2] )
fprintf(fptr, "\nHeap Memory Address: %ld, Size = %d Bytes\n", *v0, *((unsigned int *)v0 + 2));
return fclose(fptr);
}

canonical_decompiled_code:
int func0()
{
_QWORD *v0; // rbx

v0 = head;
fptr = fopen("S_malloc_logs.txt", "w");
if ( !fptr )
{
puts("\nFailure: Cannot Open Log-File for Writing\n");
exit(1);
}
for ( ; v0; v0 = (_QWORD *)v0[2] )
fprintf(fptr, "\nHeap Memory Address: %ld, Size = %d Bytes\n", *v0, *((unsigned int *)v0 + 2));
return fclose(fptr);
}

original_code:
void print_nodelist_to_file ()
{
 ListNode *temp = head;
 fptr = fopen ("S_malloc_logs.txt", "w");
 if (((void *)0)==fptr)
 {
  printf ("\nFailure: Cannot Open Log-File for Writing\n\n");
  exit (1);
 }
 while (temp)
 {
  fprintf (fptr, "\nHeap Memory Address: %ld, Size = %d Bytes\n", (long)temp->memaddress, temp->memsize);
  temp = temp->next;
 }
 fclose (fptr);
}

canonical_original_code:
void print_nodelist_to_file()
{
 struct node *temp = head;
 fptr = fopen ("S_malloc_logs.txt", "w");
 if (((void *)0)==fptr)
 {
  printf ("\nFailure: Cannot Open Log-File for Writing\n\n");
  exit (1);
 }
 while (temp)
 {
  fprintf (fptr, "\nHeap Memory Address: %ld, Size = %d Bytes\n", (long)temp->memaddress, temp->memsize);
  temp = temp->next;
 }
 fclose (fptr);
}

variable_types: struct node { void *memaddress; int memsize; struct node *next; } *


decompiled_code:
int __fastcall add_allocated_node(__int64 a1, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbx
_DWORD *v4; // rax
_QWORD *v6; // rax

v2 = head;
if ( head )
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[2];
}
while ( v2 );
v4 = malloc(0x18uLL);
v3[2] = v4;
if ( !v4 )
{
puts("\nMemory Allocation Failure !");
exit(1);
}
v4[2] = a2;
*(_QWORD *)v3[2] = a1;
*(_QWORD *)(v3[2] + 16LL) = 0LL;
}
else
{
v6 = malloc(0x18uLL);
head = v6;
*((_DWORD *)v6 + 2) = a2;
*v6 = a1;
v6[2] = 0LL;
}
return print_nodelist_to_file();
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbx
_DWORD *v4; // rax
_QWORD *v6; // rax

v2 = head;
if ( head )
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[2];
}
while ( v2 );
v4 = malloc(0x18uLL);
v3[2] = v4;
if ( !v4 )
{
puts("\nMemory Allocation Failure !");
exit(1);
}
v4[2] = a2;
*(_QWORD *)v3[2] = a1;
*(_QWORD *)(v3[2] + 16LL) = 0LL;
}
else
{
v6 = malloc(0x18uLL);
head = v6;
*((_DWORD *)v6 + 2) = a2;
*v6 = a1;
v6[2] = 0LL;
}
return func0();
}

original_code:
void add_allocated_node (void *address, int size)
{
 ListNode *temp = ((void *)0);
 if (((void *)0)==head)
 {
   head = malloc(sizeof(ListNode));
  (head)->memsize = size;
  (head)->memaddress = address;
  (head)->next = ((void *)0);
 }
 else
 {
  temp = head;
  while (temp->next!=((void *)0))
  {
   temp=temp->next;
  }
  temp->next = malloc(sizeof(ListNode));
  if (temp->next == ((void *)0))
  {
   printf ("\nMemory Allocation Failure !\n");
   exit (1);
  }
  (temp->next)->memsize = size;
  (temp->next)->memaddress = address;
  (temp->next)->next = ((void *)0);
 }
 print_nodelist_to_file ();
}

canonical_original_code:
void add_allocated_node(void *address, int size)
{
 struct node *temp = ((void *)0);
 if (((void *)0)==head)
 {
   head = malloc(sizeof(ListNode));
  (head)->memsize = size;
  (head)->memaddress = address;
  (head)->next = ((void *)0);
 }
 else
 {
  temp = head;
  while (temp->next!=((void *)0))
  {
   temp=temp->next;
  }
  temp->next = malloc(sizeof(ListNode));
  if (temp->next == ((void *)0))
  {
   printf ("\nMemory Allocation Failure !\n");
   exit (1);
  }
  (temp->next)->memsize = size;
  (temp->next)->memaddress = address;
  (temp->next)->next = ((void *)0);
 }
 print_nodelist_to_file ();
}

variable_types:
address
void *

variable_types: size int

user_defined_types: struct node { void *memaddress; int memsize; struct node *next; }


decompiled_code:
int __fastcall remove_allocated_node(__int64 a1)
{
_QWORD *v2; // rdi
_QWORD *v3; // rbp
int result; // eax

v2 = head;
if ( head )
{
if ( *(_QWORD *)head == a1 )
{
head = (void *)*((_QWORD *)head + 2);
free(v2);
}
else
{
while ( 1 )
{
v3 = v2;
v2 = (_QWORD *)v2[2];
if ( !v2 )
break;
if ( *v2 == a1 )
{
v3[2] = v2[2];
free(v2);
break;
}
}
if ( *v3 == a1 )
free(v3);
}
result = print_nodelist_to_file();
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
_QWORD *v2; // rdi
_QWORD *v3; // rbp
int result; // eax

v2 = head;
if ( head )
{
if ( *(_QWORD *)head == a1 )
{
head = (void *)*((_QWORD *)head + 2);
free(v2);
}
else
{
while ( 1 )
{
v3 = v2;
v2 = (_QWORD *)v2[2];
if ( !v2 )
break;
if ( *v2 == a1 )
{
v3[2] = v2[2];
free(v2);
break;
}
}
if ( *v3 == a1 )
free(v3);
}
result = func0();
}
return result;
}

original_code:
void remove_allocated_node (void *key_address)
{
 ListNode *temp = ((void *)0);
 ListNode *deletenode = ((void *)0);
 if (((void *)0)==head)
 {
  return;
 }
 if ((head)->memaddress == key_address)
 {
   deletenode = head;
   head = (head)->next;
   free(deletenode);
   deletenode = ((void *)0);
 }
 else
 {
  temp = head;
  while (temp->next != ((void *)0))
  {
   if ((temp->next)->memaddress == key_address)
   {
    deletenode = temp->next;
    temp->next = (temp->next)->next;
    free (deletenode);
    deletenode = ((void *)0);
    break;
   }
   temp = temp->next;
  }
  if (temp->memaddress == key_address)
  {
   free (temp);
  }
 }
 print_nodelist_to_file ();
}

canonical_original_code:
void remove_allocated_node(void *key_address)
{
 struct node *temp = ((void *)0);
 struct node *deletenode = ((void *)0);
 if (((void *)0)==head)
 {
  return;
 }
 if ((head)->memaddress == key_address)
 {
   deletenode = head;
   head = (head)->next;
   free(deletenode);
   deletenode = ((void *)0);
 }
 else
 {
  temp = head;
  while (temp->next != ((void *)0))
  {
   if ((temp->next)->memaddress == key_address)
   {
    deletenode = temp->next;
    temp->next = (temp->next)->next;
    free (deletenode);
    deletenode = ((void *)0);
    break;
   }
   temp = temp->next;
  }
  if (temp->memaddress == key_address)
  {
   free (temp);
  }
 }
 print_nodelist_to_file ();
}


conversation

repo: sangeeths/SimplePAM

decompiled_code:
__int64 __fastcall conversation(int a1, __int64 a2, _QWORD *a3, const char *a4)
{
__int64 result; // rax
char *v7; // rax
char *v8; // r13
char *v9; // rbx
char *v10; // rbp

result = 19LL;
if ( (unsigned int)(a1 - 1) <= 0x1F )
{
v7 = (char *)calloc(a1, 0x10uLL);
v8 = v7;
if ( v7 )
{
v9 = v7;
v10 = &v7[16 * (a1 - 1) + 16];
do
{
*((_DWORD *)v9 + 2) = 0;
*(_QWORD *)v9 = strdup(a4);
v9 += 16;
}
while ( v9 != v10 );
*a3 = v8;
result = 0LL;
}
else
{
result = 5LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, __int64 a2, _QWORD *a3, const char *a4)
{
__int64 result; // rax
char *v7; // rax
char *v8; // r13
char *v9; // rbx
char *v10; // rbp

result = 19LL;
if ( (unsigned int)(a1 - 1) <= 0x1F )
{
v7 = (char *)calloc(a1, 0x10uLL);
v8 = v7;
if ( v7 )
{
v9 = v7;
v10 = &v7[16 * (a1 - 1) + 16];
do
{
*((_DWORD *)v9 + 2) = 0;
*(_QWORD *)v9 = strdup(a4);
v9 += 16;
}
while ( v9 != v10 );
*a3 = v8;
result = 0LL;
}
else
{
result = 5LL;
}
}
return result;
}

original_code:
int conversation(int msg_count,
                 const struct pam_message **msg,
                 struct pam_response **resp,
                 void *pw)
{
    struct pam_response *r = ((void *)0);
    int i = 0;
    if (msg_count <= 0 || msg_count > 32)
        return 19;
    if ((r = (struct pam_response *) calloc(msg_count,
              sizeof(struct pam_response))) == ((void *)0))
        return 5;
    for(i=0; i<msg_count; ++i) {
        r[i].resp_retcode = 0;
        r[i].resp = strdup(pw);
    }
    *resp = r;
    return 0;
}

canonical_original_code:
int conversation(int msg_count, struct pam_message **msg, struct pam_response **resp, void *pw)
{
    struct pam_response *r = ((void *)0);
    int i = 0;
    if (msg_count <= 0 || msg_count > 32)
        return 19;
    if ((r = (struct pam_response *) calloc(msg_count,
              sizeof(struct pam_response))) == ((void *)0))
        return 5;
    for(i=0; i<msg_count; ++i) {
        r[i].resp_retcode = 0;
        r[i].resp = strdup(pw);
    }
    *resp = r;
    return 0;
}

variable_types: struct pam_message { int msg_style; char *msg; } **

variable_types: struct pam_response { char *resp; int resp_retcode; } **

variable_types:
pw
void *

variable_types: i int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
return 0;
}

original_code:
int main(int agrc, char *argv[])
{
    return 0;
}

variable_types: agrc int

variable_types:
argv
char *[]


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
__int64 v4; // rbx

if ( argc == 2 )
{
v4 = get_results(argv[1]);
result = -1;
if ( v4 )
{
g_slist_foreach(v4, &print_result_info, 0LL);
g_slist_free_full(v4, &result_cleanup);
result = 0;
}
}
else
{
printf("usage: %s <url>\n", *argv);
result = 0;
}
return result;
}

original_code:
int main(int argc, char **argv )
{
 GSList *results = ((void *)0);
 int err;
 if ( argc == 2) {
  results = get_results(argv[1]);
  if (results) {
   g_slist_foreach(results, (GFunc)print_result_info, ((void *)0));
   g_slist_free_full(results, (GDestroyNotify) result_cleanup);
   err = 0;
  } else
   err = -1;
  return err;
 }
 else
  printf( "usage: %s <url>\n", argv[0] );
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct _GSList *results = ((void *)0);
 int err;
 if ( argc == 2) {
  results = get_results(argv[1]);
  if (results) {
   g_slist_foreach(results, (void (*)(void *data, void *user_data))print_result_info, ((void *)0));
   g_slist_free_full(results, (void (*)(void *data)) result_cleanup);
   err = 0;
  } else
   err = -1;
  return err;
 }
 else
  printf( "usage: %s <url>\n", argv[0] );
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct _GSList { void *data; struct _GSList *next; } *

variable_types: err int


receive

repo: sangyye/recursorscanner

decompiled_code:
void __fastcall __noreturn receive(void *a1)
{
char *v1; // rax
struct sockaddr v2; // [rsp+0h] [rbp-10028h] BYREF
socklen_t addr_len; // [rsp+1Ch] [rbp-1000Ch] BYREF
char s[6]; // [rsp+20h] [rbp-10008h] BYREF
__int16 v5; // [rsp+26h] [rbp-10002h]

addr_len = 16;
while ( 1 )
{
do
memset(s, 0, 0x10000uLL);
while ( recvfrom(sockfd, s, 0x10000uLL, 0, &v2, &addr_len) < 0 );
if ( _bswap_16(v5) )
{
v1 = inet_ntoa(*(struct in_addr *)&v2.sa_data[2]);
puts(v1);
}
}
}

canonical_decompiled_code:
void __fastcall __noreturn func8(void *a1)
{
char *v1; // rax
struct sockaddr v2; // [rsp+0h] [rbp-10028h] BYREF
socklen_t addr_len; // [rsp+1Ch] [rbp-1000Ch] BYREF
char s[6]; // [rsp+20h] [rbp-10008h] BYREF
__int16 v5; // [rsp+26h] [rbp-10002h]

addr_len = 16;
while ( 1 )
{
do
memset(s, 0, 0x10000uLL);
while ( recvfrom(sockfd, s, 0x10000uLL, 0, &v2, &addr_len) < 0 );
if ( func7(v5) )
{
v1 = inet_ntoa(*(struct in_addr *)&v2.sa_data[2]);
puts(v1);
}
}
}

original_code:
void *receive(void *arg) {
 char buffer[65536];
 socklen_t addrlen;
 struct sockaddr_in rsystem;
 struct DNS_HEADER *dns = ((void *)0);
 addrlen = sizeof(rsystem);
 for(;;) {
  memset(buffer, 0x00, 65536);
  if (recvfrom(sockfd, (char*)buffer, 65536, 0, (struct sockaddr*)&rsystem, &addrlen) >= 0) {
   dns = (struct DNS_HEADER*) buffer;
   if (ntohs(dns->ans_count) > 0) {
    printf("%s\n", inet_ntoa(rsystem.sin_addr));
   }
  }
 }
}

canonical_original_code:
void *receive(void *arg) {
 char buffer[65536];
 unsigned int addrlen;
 struct sockaddr_in rsystem;
 struct DNS_HEADER *dns = ((void *)0);
 addrlen = sizeof(rsystem);
 for(;;) {
  memset(buffer, 0x00, 65536);
  if (recvfrom(sockfd, (char *)buffer, 65536, 0, (struct sockaddr *)&rsystem, &addrlen) >= 0) {
   dns = (struct DNS_HEADER *) buffer;
   if (ntohs(dns->ans_count) > 0) {
    printf("%s\n", inet_ntoa(rsystem.sin_addr));
   }
  }
 }
}

variable_types:
arg
void *

variable_types:
buffer
char [65536]

variable_types:
addrlen
unsigned int

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

variable_types: struct DNS_HEADER { unsigned short id; unsigned char rd; unsigned char tc; unsigned char aa; unsigned char opcode; unsigned char qr; unsigned char rcode; unsigned char cd; unsigned char ad; unsigned char z; unsigned char ra; unsigned short q_count; unsigned short ans_count; unsigned short auth_count; unsigned short add_count; } *

return_type: void *

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

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


usage

decompiled_code:
int __fastcall usage(const char *a1)
{
return printf("Usage: %s <address/mask> <bandwith in kbps>\n", a1);
}

canonical_decompiled_code:
int __fastcall func10(const char *a1)
{
return printf("Usage: %s <address/mask> <bandwith in kbps>\n", a1);
}

original_code:
void usage(char *cmd) {
 printf("Usage: %s <address/mask> <bandwith in kbps>\n", cmd);
}

variable_types:
cmd
char *


error

decompiled_code:
void __fastcall __noreturn error(const char *a1)
{
fprintf(stderr, "Fatal Error: %s\n", a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func11(const char *a1)
{
fprintf(stderr, "Fatal Error: %s\n", a1);
exit(1);
}

original_code:
void error (char * msg) {
 fprintf(stderr, "Fatal Error: %s\n", msg);
 exit(1);
}

canonical_original_code:
void error(char *msg) {
 fprintf(stderr, "Fatal Error: %s\n", msg);
 exit(1);
}

variable_types:
msg
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
const char *v4; // rbx
int v5; // er14
const char *v6; // r13
__int64 v7; // rax
char v8; // dl
int v9; // ebx
int v10; // er12
int v11; // ebp
char *v12; // rax
int v13; // ebx
size_t v14; // rax
int v15; // eax
struct sockaddr v17; // [rsp+0h] [rbp-10068h] BYREF
__int16 v18; // [rsp+10h] [rbp-10058h] BYREF
char v19; // [rsp+12h] [rbp-10056h]
char v20; // [rsp+13h] [rbp-10055h]
__int16 v21; // [rsp+14h] [rbp-10054h]
__int16 v22; // [rsp+16h] [rbp-10052h]
__int16 v23; // [rsp+18h] [rbp-10050h]
__int16 v24; // [rsp+1Ah] [rbp-1004Eh]
char s[65529]; // [rsp+1Ch] [rbp-1004Ch] BYREF
char v26[11]; // [rsp+10015h] [rbp-53h] BYREF
_QWORD v27[3]; // [rsp+10020h] [rbp-48h] BYREF
pthread_t newthread[6]; // [rsp+10038h] [rbp-30h] BYREF

strcpy(v26, "google.com");
if ( argc != 3 )
{
usage(*argv);
exit(1);
}
v4 = argv[1];
v5 = strlen(v4);
v6 = (const char *)malloc(v5);
if ( !v6 )
error("Could not allocate memory\n");
v7 = 0LL;
if ( v5 > 0 )
{
while ( 1 )
{
v8 = v4[v7];
if ( v8 == 47 )
break;
v6[v7] = v8;
if ( v7 == v5 - 1 )
goto LABEL_12;
++v7;
}
v6[v7] = 0;
v3 = atoi(&v4[v7 + 1]);
}
LABEL_12:
sockfd = socket(2, 2, 0);
if ( sockfd < 0 )
error("Could not open socket\n");
v9 = atoi(argv[2]);
v10 = (int)pow(2.0, (double)(32 - v3));
v11 = 1000 * (1000000 / v9) / 576;
v17.sa_family = 2;
*(_WORD *)v17.sa_data = _bswap_16(53);
v19 = 1;
v20 = 0;
LOWORD(v9) = _bswap_16(1);
v21 = v9;
v22 = 0;
v23 = 0;
v24 = 0;
dns_convert_hostname(s, v26);
v12 = &s[strlen(s) + 1];
*(_WORD *)v12 = v9;
*((_WORD *)v12 + 1) = v9;
v13 = pthread_create(newthread, 0LL, (void *(*)(void *))receive, 0LL);
if ( v13 )
error("Could not create thread\n");
*(_DWORD *)&v17.sa_data[2] = inet_addr(v6);
if ( v10 > 0 )
{
do
{
v18 = v13;
v27[0] = 0LL;
v27[1] = 0LL;
inet_ntop(2, &v17.sa_data[2], (char *)v27, 0x10u);
do
v14 = strlen(s);
while ( sendto(sockfd, &v18, v14 + 17, 0, &v17, 0x10u) < 0 );
v15 = _bswap_32(*(unsigned int *)&v17.sa_data[2]);
*(_DWORD *)&v17.sa_data[2] = _bswap_32(v15 + 1);
usleep(v11);
++v13;
}
while ( v10 != v13 );
}
sleep(5u);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
const char *v4; // rbx
int v5; // er14
const char *v6; // r13
__int64 v7; // rax
char v8; // dl
int v9; // ebx
int v10; // er12
int v11; // ebp
char *v12; // rax
int v13; // ebx
size_t v14; // rax
int v15; // eax
struct sockaddr v17; // [rsp+0h] [rbp-10068h] BYREF
__int16 v18; // [rsp+10h] [rbp-10058h] BYREF
char v19; // [rsp+12h] [rbp-10056h]
char v20; // [rsp+13h] [rbp-10055h]
__int16 v21; // [rsp+14h] [rbp-10054h]
__int16 v22; // [rsp+16h] [rbp-10052h]
__int16 v23; // [rsp+18h] [rbp-10050h]
__int16 v24; // [rsp+1Ah] [rbp-1004Eh]
char s[65529]; // [rsp+1Ch] [rbp-1004Ch] BYREF
char v26[11]; // [rsp+10015h] [rbp-53h] BYREF
_QWORD v27[3]; // [rsp+10020h] [rbp-48h] BYREF
pthread_t newthread[6]; // [rsp+10038h] [rbp-30h] BYREF

strcpy(v26, "google.com");
if ( argc != 3 )
{
func10(*argv);
exit(1);
}
v4 = argv[1];
v5 = strlen(v4);
v6 = (const char *)malloc(v5);
if ( !v6 )
func11("Could not allocate memory\n");
v7 = 0LL;
if ( v5 > 0 )
{
while ( 1 )
{
v8 = v4[v7];
if ( v8 == 47 )
break;
v6[v7] = v8;
if ( v7 == v5 - 1 )
goto LABEL_12;
++v7;
}
v6[v7] = 0;
v3 = atoi(&v4[v7 + 1]);
}
LABEL_12:
sockfd = socket(2, 2, 0);
if ( sockfd < 0 )
func11("Could not open socket\n");
v9 = atoi(argv[2]);
v10 = (int)pow(2.0, (double)(32 - v3));
v11 = 1000 * (1000000 / v9) / 576;
v17.sa_family = 2;
*(_WORD *)v17.sa_data = func7(53);
v19 = 1;
v20 = 0;
LOWORD(v9) = func7(1);
v21 = v9;
v22 = 0;
v23 = 0;
v24 = 0;
func12(s, v26);
v12 = &s[strlen(s) + 1];
*(_WORD *)v12 = v9;
*((_WORD *)v12 + 1) = v9;
v13 = pthread_create(newthread, 0LL, (void *(*)(void *))receive, 0LL);
if ( v13 )
func11("Could not create thread\n");
*(_DWORD *)&v17.sa_data[2] = inet_addr(v6);
if ( v10 > 0 )
{
do
{
v18 = v13;
v27[0] = 0LL;
v27[1] = 0LL;
inet_ntop(2, &v17.sa_data[2], (char *)v27, 0x10u);
do
v14 = strlen(s);
while ( sendto(sockfd, &v18, v14 + 17, 0, &v17, 0x10u) < 0 );
v15 = func9(*(unsigned int *)&v17.sa_data[2]);
*(_DWORD *)&v17.sa_data[2] = func9(v15 + 1);
usleep(v11);
++v13;
}
while ( v10 != v13 );
}
sleep(5u);
return 0;
}

original_code:
int main(int argc, char **argv) {
 pthread_t tid;
 int query_type;
 int end_ip;
 int sleeptime;
 int len;
 int bandwith;
 int mask;
 char buffer[16];
 unsigned char hostname[] = "google.com";
 char *start_ip;
 unsigned char buf[65536];
 unsigned char *qname;
 struct sockaddr_in addr;
 struct DNS_HEADER *dns = ((void *)0);
 struct QUESTION *qinfo = ((void *)0);
 if (argc != 3) {
  usage(argv[0]);
  exit(1);
 }
 len = strlen(argv[1]);
 start_ip = (char *)malloc(sizeof(char) * len);
 if (start_ip == ((void *)0)) {
  error("Could not allocate memory\n");
 }
 for (int i = 0; i < len; i++) {
  if (argv[1][i] != '/') {
   start_ip[i] = argv[1][i];
  }
  else {
   start_ip[i] = '\0';
   mask = atoi(&argv[1][i + 1]);
   break;
  }
 }
 if ((sockfd = socket(2, SOCK_DGRAM, 0)) < 0) {
  error("Could not open socket\n");
 }
 bandwith = atoi(argv[2]);
 end_ip = pow(2, 32 - mask);
 sleeptime = 1000000 / bandwith * 1000 / (72 * 8);
 addr.sin_family = 2;
    addr.sin_port = htons(53);
 dns = (struct DNS_HEADER *)&buf;
 dns->qr = 0;
 dns->opcode = 0;
 dns->aa = 0;
 dns->tc = 0;
 dns->rd = 1;
 dns->ra = 0;
 dns->z = 0;
 dns->ad = 0;
 dns->cd = 0;
 dns->rcode = 0;
 dns->q_count = htons(1);
 dns->ans_count = 0;
 dns->auth_count = 0;
 dns->add_count = 0;
 qname = (unsigned char *)&buf[sizeof(struct DNS_HEADER)];
 query_type = 1;
 dns_convert_hostname(qname , hostname);
 qinfo = (struct QUESTION *)&buf[sizeof(struct DNS_HEADER) + (strlen((const char *)qname) + 1)];
 qinfo->qtype = htons(query_type);
 qinfo->qclass = htons(1);
 if (pthread_create(&tid, ((void *)0), receive, ((void *)0))) {
  error("Could not create thread\n");
 }
 addr.sin_addr.s_addr = inet_addr(start_ip);
 for (int i = 0; i < end_ip; i++) {
  dns->id = (unsigned short)i;
  memset(buffer, 0x00, 16);
  inet_ntop(2, &addr.sin_addr.s_addr, buffer, 16);
  do {
  } while (sendto(sockfd, (char*)buf,sizeof(struct DNS_HEADER) + (strlen((const char*)qname)+1) + sizeof(struct QUESTION), 0, (struct sockaddr*)&addr, sizeof(addr)) < 0);
  addr.sin_addr.s_addr = htonl(addr.sin_addr.s_addr);
  addr.sin_addr.s_addr++;
  addr.sin_addr.s_addr = ntohl(addr.sin_addr.s_addr);
  usleep(sleeptime);
 }
 sleep(5);
 return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
 unsigned long tid;
 int query_type;
 int end_ip;
 int sleeptime;
 int len;
 int bandwith;
 int mask;
 char buffer[16];
 unsigned char hostname[] = "google.com";
 char *start_ip;
 unsigned char buf[65536];
 unsigned char *qname;
 struct sockaddr_in addr;
 struct DNS_HEADER *dns = ((void *)0);
 struct QUESTION *qinfo = ((void *)0);
 if (argc != 3) {
  usage(argv[0]);
  exit(1);
 }
 len = strlen(argv[1]);
 start_ip = (char *)malloc(sizeof(char) * len);
 if (start_ip == ((void *)0)) {
  error("Could not allocate memory\n");
 }
 for (int i = 0; i < len; i++) {
  if (argv[1][i] != '/') {
   start_ip[i] = argv[1][i];
  }
  else {
   start_ip[i] = '\0';
   mask = atoi(&argv[1][i + 1]);
   break;
  }
 }
 if ((sockfd = socket(2, SOCK_DGRAM, 0)) < 0) {
  error("Could not open socket\n");
 }
 bandwith = atoi(argv[2]);
 end_ip = pow(2, 32 - mask);
 sleeptime = 1000000 / bandwith * 1000 / (72 * 8);
 addr.sin_family = 2;
    addr.sin_port = htons(53);
 dns = (struct DNS_HEADER *)&buf;
 dns->qr = 0;
 dns->opcode = 0;
 dns->aa = 0;
 dns->tc = 0;
 dns->rd = 1;
 dns->ra = 0;
 dns->z = 0;
 dns->ad = 0;
 dns->cd = 0;
 dns->rcode = 0;
 dns->q_count = htons(1);
 dns->ans_count = 0;
 dns->auth_count = 0;
 dns->add_count = 0;
 qname = (unsigned char *)&buf[sizeof(struct DNS_HEADER)];
 query_type = 1;
 dns_convert_hostname(qname , hostname);
 qinfo = (struct QUESTION *)&buf[sizeof(struct DNS_HEADER) + (strlen((char *)qname) + 1)];
 qinfo->qtype = htons(query_type);
 qinfo->qclass = htons(1);
 if (pthread_create(&tid, ((void *)0), receive, ((void *)0))) {
  error("Could not create thread\n");
 }
 addr.sin_addr.s_addr = inet_addr(start_ip);
 for (int i = 0; i < end_ip; i++) {
  dns->id = (unsigned short)i;
  memset(buffer, 0x00, 16);
  inet_ntop(2, &addr.sin_addr.s_addr, buffer, 16);
  do {
  } while (sendto(sockfd, (char *)buf,sizeof(struct DNS_HEADER) + (strlen((char *)qname)+1) + sizeof(struct QUESTION), 0, (struct sockaddr *)&addr, sizeof(addr)) < 0);
  addr.sin_addr.s_addr = htonl(addr.sin_addr.s_addr);
  addr.sin_addr.s_addr++;
  addr.sin_addr.s_addr = ntohl(addr.sin_addr.s_addr);
  usleep(sleeptime);
 }
 sleep(5);
 return 0;
}

variable_types:
tid
unsigned long

variable_types: sleeptime int

variable_types: len int

variable_types: bandwith int

variable_types: mask int

variable_types:
buffer
char [16]

variable_types:
hostname
unsigned char []

variable_types:
buf
unsigned char [65536]

variable_types:
qname
unsigned char *

variable_types: struct QUESTION { unsigned short qtype; unsigned short qclass; } *

user_defined_types: struct DNS_HEADER { unsigned short id; unsigned char rd; unsigned char tc; unsigned char aa; unsigned char opcode; unsigned char qr; unsigned char rcode; unsigned char cd; unsigned char ad; unsigned char z; unsigned char ra; unsigned short q_count; unsigned short ans_count; unsigned short auth_count; unsigned short add_count; }


repo: sanjoy/CmdArgs

decompiled_code:
_BOOL8 __fastcall almost_equal_eps(double a1, double a2, double a3)
{
if ( a1 == 0.0 )
return a3 > COERCE_DOUBLE(*(_QWORD *)&a1 & LC1);
if ( a2 == 0.0 )
return a3 > COERCE_DOUBLE(*(_QWORD *)&a2 & LC1);
return a3 > COERCE_DOUBLE(COERCE_UNSIGNED_INT64(a1 - a2) & LC1)
/ fmax(COERCE_DOUBLE(*(_QWORD *)&a1 & LC1), COERCE_DOUBLE(LC1 & *(_QWORD *)&a2));
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(double a1, double a2, double a3)
{
if ( a1 == 0.0 )
return a3 > COERCE_DOUBLE(*(_QWORD *)&a1 & LC1);
if ( a2 == 0.0 )
return a3 > COERCE_DOUBLE(*(_QWORD *)&a2 & LC1);
return a3 > COERCE_DOUBLE(COERCE_UNSIGNED_INT64(a1 - a2) & LC1)
/ fmax(COERCE_DOUBLE(*(_QWORD *)&a1 & LC1), COERCE_DOUBLE(LC1 & *(_QWORD *)&a2));
}

original_code:
int
almost_equal_eps (double x, double y, double eps)
{
    if (x == 0) return fabs (x) < eps;
    if (y == 0) return fabs (y) < eps;
    double max = (fabs (x) > fabs (y)) ? fabs (x) : fabs (y);
    return (fabs (x - y) / max) < eps;
}

canonical_original_code:
int almost_equal_eps(double x, double y, double eps)
{
    if (x == 0) return fabs (x) < eps;
    if (y == 0) return fabs (y) < eps;
    double max = (fabs (x) > fabs (y)) ? fabs (x) : fabs (y);
    return (fabs (x - y) / max) < eps;
}

variable_types: x double

variable_types: y double

variable_types: eps double

variable_types: max double


repo: sanjoy/L

original_code:
static int
is_memblock_free_slow (MempoolNode *block)
{
 int i;
 size_t sz = ((size_t) ((block)->real_end - (block)->begin)) / (sizeof (void *));
 if (sz % 8 != 0)
  sz = sz / 8 + 1;
 else
  sz = sz / 8;
 for (i = 0; i < sz; i++)
  if (((char *) (block->begin)) [i])
   return 0;
 block->begin = ((void *) (((unsigned long) block->begin) | (unsigned long) 1));
 return 1;
}

canonical_original_code:
static int is_memblock_free_slow(struct _MempoolNode *block)
{
 int i;
 unsigned long sz = ((size_t) ((block)->real_end - (block)->begin)) / (sizeof (void *));
 if (sz % 8 != 0)
  sz = sz / 8 + 1;
 else
  sz = sz / 8;
 for (i = 0; i < sz; i++)
  if (((char *) (block->begin)) [i])
   return 0;
 block->begin = ((void *) (((unsigned long) block->begin) | (unsigned long) 1));
 return 1;
}

variable_types: struct _MempoolNode { void *begin; int offset; struct _MempoolNode *next; } *

variable_types: i int

variable_types:
sz
unsigned long


decompiled_code:
__int64 __fastcall find_and_mark(unsigned __int64 *a1, unsigned __int64 a2, int a3)
{
__int64 result; // rax
unsigned __int64 v5; // rax
unsigned __int64 v6; // rdx
unsigned __int64 v7; // r10
unsigned __int64 v8; // rcx
bool v9; // sf
int v10; // ecx
int v11; // eax
int v12; // eax

if ( !a1 )
return 0LL;
while ( 1 )
{
v5 = *a1;
if ( *a1 <= a2 && a1[1] > a2 )
break;
a1 = (unsigned __int64 *)a1[4];
if ( !a1 )
return 0LL;
}
v6 = ((_BYTE)a2 - (_BYTE)v5) & 7;
if ( (((_BYTE)a2 - (_BYTE)v5) & 7) != 0 )
_assert_fail("(((size_t) (to_find - iter->begin)) % SIZEOF_PTR) == 0", "src/l-mempool.c", 0x98u, "find_and_mark");
v7 = (unsigned __int64)a3 >> 3;
result = 1LL;
if ( (unsigned __int64)a3 > 7 )
{
do
{
v8 = (a2 - *a1) >> 3;
v9 = (int)v6 + (int)v8 < 0;
v10 = v6 + v8;
v11 = v10 + 7;
if ( !v9 )
v11 = v10;
v12 = v11 >> 3;
if ( v12 >= *((_DWORD *)a1 + 6) )
_assert_fail("(n / 8 + 1) <= (iter)->offset", "src/l-mempool.c", 0x9Au, "find_and_mark");
*(_BYTE *)(*a1 + v12) |= 1 << (v10 % 8);
++v6;
}
while ( v6 < v7 );
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int64 *a1, unsigned __int64 a2, int a3)
{
__int64 result; // rax
unsigned __int64 v5; // rax
unsigned __int64 v6; // rdx
unsigned __int64 v7; // r10
unsigned __int64 v8; // rcx
bool v9; // sf
int v10; // ecx
int v11; // eax
int v12; // eax

if ( !a1 )
return 0LL;
while ( 1 )
{
v5 = *a1;
if ( *a1 <= a2 && a1[1] > a2 )
break;
a1 = (unsigned __int64 *)a1[4];
if ( !a1 )
return 0LL;
}
v6 = ((_BYTE)a2 - (_BYTE)v5) & 7;
if ( (((_BYTE)a2 - (_BYTE)v5) & 7) != 0 )
_assert_fail("(((size_t) (to_find - iter->begin)) % SIZEOF_PTR) == 0", "src/l-mempool.c", 0x98u, "find_and_mark");
v7 = (unsigned __int64)a3 >> 3;
result = 1LL;
if ( (unsigned __int64)a3 > 7 )
{
do
{
v8 = (a2 - *a1) >> 3;
v9 = (int)v6 + (int)v8 < 0;
v10 = v6 + v8;
v11 = v10 + 7;
if ( !v9 )
v11 = v10;
v12 = v11 >> 3;
if ( v12 >= *((_DWORD *)a1 + 6) )
_assert_fail("(n / 8 + 1) <= (iter)->offset", "src/l-mempool.c", 0x9Au, "find_and_mark");
*(_BYTE *)(*a1 + v12) |= 1 << (v10 % 8);
++v6;
}
while ( v6 < v7 );
result = 1LL;
}
return result;
}

original_code:
static int
find_and_mark (MempoolNode *blocks, void *to_find, int sz)
{
 MempoolNode *iter;
 int i;
 for (iter = blocks; iter; iter = iter->next) {
  if (to_find >= iter->begin && to_find < iter->end) {
   ((void) sizeof (((((size_t) (to_find - iter->begin)) % (sizeof (void *))) == 0) ? 1 : 0), __extension__ ({ if ((((size_t) (to_find - iter->begin)) % (sizeof (void *))) == 0) ; else __assert_fail ("(((size_t) (to_find - iter->begin)) % SIZEOF_PTR) == 0", "src/l-mempool.c", 152, __extension__ __PRETTY_FUNCTION__); }));
   for (i = 0; i < sz / (sizeof (void *)); i++) {
    do { char *__tmp = (char *) ((iter)->begin); int n = (((size_t) (to_find - iter->begin)) / (sizeof (void *)) + i); ((void) sizeof (((n / 8 + 1) <= (iter)->offset) ? 1 : 0), __extension__ ({ if ((n / 8 + 1) <= (iter)->offset) ; else __assert_fail ("(n / 8 + 1) <= (iter)->offset", "src/l-mempool.c", 154, __extension__ __PRETTY_FUNCTION__); })); __tmp [n / 8] |= 1 << (n % 8); } while (0);
   }
   return 1;
  }
 }
 return 0;
}

canonical_original_code:
static int find_and_mark(struct _MempoolNode *blocks, void *to_find, int sz)
{
 struct _MempoolNode *iter;
 int i;
 for (iter = blocks; iter; iter = iter->next) {
  if (to_find >= iter->begin && to_find < iter->end) {
   ((void) sizeof (((((unsigned long) (to_find - iter->begin)) % (sizeof (void *))) == 0) ? 1 : 0), __extension__ ({ if ((((unsigned long) (to_find - iter->begin)) % (sizeof (void *))) == 0) ; else __assert_fail ("(((size_t) (to_find - iter->begin)) % SIZEOF_PTR) == 0", "src/l-mempool.c", 152, __extension__ __PRETTY_FUNCTION__); }));
   for (i = 0; i < sz / (sizeof (void *)); i++) {
    do { char *__tmp = (char *) ((iter)->begin); int n = (((size_t) (to_find - iter->begin)) / (sizeof (void *)) + i); ((void) sizeof (((n / 8 + 1) <= (iter)->offset) ? 1 : 0), __extension__ ({ if ((n / 8 + 1) <= (iter)->offset) ; else __assert_fail ("(n / 8 + 1) <= (iter)->offset", "src/l-mempool.c", 154, __extension__ __PRETTY_FUNCTION__); })); __tmp [n / 8] |= 1 << (n % 8); } while (0);
   }
   return 1;
  }
 }
 return 0;
}

variable_types: sz int

variable_types: n int

user_defined_types: struct _MempoolNode { void *begin; int offset; struct _MempoolNode *next; }


decompiled_code:
void __fastcall mark_mark_list(__int64 a1, unsigned __int64 *a2)
{
unsigned __int64 *i; // rbx

for ( i = a2; i; i = (unsigned __int64 *)i[1] )
{
if ( !(unsigned int)find_and_mark(*(unsigned __int64 **)(a1 + 24), (unsigned __int64)i, 16) )
_assert_fail(
"find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))",
"src/l-mempool-scan.inc",
0x20u,
"mark_mark_list");
if ( !(unsigned int)find_and_mark(*(unsigned __int64 **)(a1 + 24), *i, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))",
"src/l-mempool-scan.inc",
0x21u,
"mark_mark_list");
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, unsigned __int64 *a2)
{
unsigned __int64 *i; // rbx

for ( i = a2; i; i = (unsigned __int64 *)i[1] )
{
if ( !(unsigned int)func1(*(unsigned __int64 **)(a1 + 24), (unsigned __int64)i, 16) )
_assert_fail(
"find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))",
"src/l-mempool-scan.inc",
0x20u,
"mark_mark_list");
if ( !(unsigned int)func1(*(unsigned __int64 **)(a1 + 24), *i, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))",
"src/l-mempool-scan.inc",
0x21u,
"mark_mark_list");
}
}

original_code:
static void
mark_mark_list (LMempool *pool, LListNode *iter)
{
 for (; iter; iter = iter->next) {
  ((void) sizeof ((find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))", "src/l-mempool-scan.inc", 32, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))", "src/l-mempool-scan.inc", 33, __extension__ __PRETTY_FUNCTION__); }));
 }
}

canonical_original_code:
static void mark_mark_list(struct _LMempool *pool, struct _LListNode *iter)
{
 for (; iter; iter = iter->next) {
  ((void) sizeof ((find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))", "src/l-mempool-scan.inc", 32, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))", "src/l-mempool-scan.inc", 33, __extension__ __PRETTY_FUNCTION__); }));
 }
}

variable_types: struct _LMempool { unsigned long page_size; int dev_zero_fd; unsigned long total_bytes; struct _MempoolNode { void *begin; int offset; struct _MempoolNode *next; } *blocks; } *

variable_types: struct _LListNode { struct LToken { char *name; int idx; struct _LLambda { struct _LListNode *args; struct _LTreeNode { struct LToken *token; struct _LLambda *lambda; struct _LTreeNode *left; } *body; struct _LLambda *next; } *parent; } *token; struct _LListNode *next; } *

user_defined_types: struct _LMempool { unsigned long page_size; int dev_zero_fd; unsigned long total_bytes; struct _MempoolNode *blocks; }

user_defined_types: struct _LListNode { struct LToken *token; struct _LListNode *next; }

user_defined_types: struct LToken { char *name; int idx; struct _LLambda *parent; }

user_defined_types: struct _LLambda { struct _LListNode *args; struct _LTreeNode *body; struct _LLambda *next; }


decompiled_code:
void __fastcall mark_recursive_lambda(__int64 a1, unsigned __int64 a2)
{
if ( a2 )
{
if ( !(unsigned int)find_and_mark(*(unsigned __int64 **)(a1 + 24), a2, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))",
"src/l-mempool-scan.inc",
0x2Au,
"mark_recursive_lambda");
mark_mark_list(a1, *(unsigned __int64 **)a2);
mark_recursive_tree(a1, *(_QWORD *)(a2 + 8));
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, unsigned __int64 a2)
{
if ( a2 )
{
if ( !(unsigned int)func1(*(unsigned __int64 **)(a1 + 24), a2, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))",
"src/l-mempool-scan.inc",
0x2Au,
"mark_recursive_lambda");
func2(a1, *(unsigned __int64 **)a2);
func4(a1, *(_QWORD *)(a2 + 8));
}
}

original_code:
static void
mark_recursive_lambda (LMempool *pool, LLambda *lambda)
{
 if (lambda == ((void *)0))
  return;
 ((void) sizeof ((find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))", "src/l-mempool-scan.inc", 42, __extension__ __PRETTY_FUNCTION__); }));
 mark_mark_list (pool, lambda->args);
 mark_recursive_tree (pool, lambda->body);
}

canonical_original_code:
static void mark_recursive_lambda(struct _LMempool *pool, struct _LLambda *lambda)
{
 if (lambda == ((void *)0))
  return;
 ((void) sizeof ((find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))", "src/l-mempool-scan.inc", 42, __extension__ __PRETTY_FUNCTION__); }));
 mark_mark_list (pool, lambda->args);
 mark_recursive_tree (pool, lambda->body);
}

variable_types: struct _LLambda { struct _LListNode { struct LToken { char *name; int idx; struct _LLambda *parent; } *token; struct _LListNode *next; } *args; struct _LTreeNode { struct LToken *token; struct _LLambda *lambda; struct _LTreeNode *left; } *body; struct _LLambda *next; } *