yylex

original_code:
int
yylex( void )
    {
    int c, len, i;
    char buf[10000];
    do {
 c = getchar();
 }
    while ( c == ' ' || c == '\t' );
    if ( ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISdigit) )
 {
 buf[0] = c;
 len = 1;
 while ( len < sizeof(buf) )
     {
     c = getchar();
     if ( ! ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISdigit) )
  {
                ungetc( c, stdin );
                break;
                }
            buf[len++] = c;
            }
        buf[len] = '\0';
        yylval = str_to_bi( buf );
        return NUMBER;
        }
    else if ( ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISalpha) )
 {
 buf[0] = c;
 len = 1;
 while ( len < sizeof(buf) )
     {
     c = getchar();
     if ( ! ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISalpha) )
  {
                ungetc( c, stdin );
                break;
                }
            buf[len++] = c;
            }
        buf[len] = '\0';
 for ( i = 0; i < len; ++i )
     if ( ((*__ctype_b_loc ())[(int) ((buf[i]))] & (unsigned short int) _ISupper) )
  buf[i] = tolower( buf[i] );
        if ( strcmp( buf, "sqrt" ) == 0 )
     return SQRT;
        else if ( strcmp( buf, "gcd" ) == 0 )
     return GCD;
        else if ( strcmp( buf, "lcm" ) == 0 )
     return LCM;
        else if ( strcmp( buf, "modpow" ) == 0 )
     return MODPOW;
        else if ( strcmp( buf, "modinv" ) == 0 )
     return MODINV;
        else if ( strcmp( buf, "random" ) == 0 )
     return RANDOM;
        else if ( strcmp( buf, "jacobi" ) == 0 )
     return JACOBI;
        else if ( strcmp( buf, "isprime" ) == 0 )
     return ISPRIME;
        else if ( strcmp( buf, "genprime" ) == 0 )
     return GENPRIME;
        else if ( strcmp( buf, "bits" ) == 0 )
     return BITS;
        else if ( strcmp( buf, "bindiv" ) == 0 )
     return BINDIV;
 else if ( len == 1 )
     {
     yylval = int_to_bi( buf[0] - 'a' );
     return VAR;
     }
 else
     return '.';
        }
    else if ( c == '.' )
 {
 yylval = bi_copy( prev_val );
 return NUMBER;
 }
    else if ( c == (-1) )
 return 0;
    else
 return c;
    }

canonical_original_code:
int yylex()
    {
    int c; int len; int i;
    char buf[10000];
    do {
 c = getchar();
 }
    while ( c == ' ' || c == '\t' );
    if ( ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISdigit) )
 {
 buf[0] = c;
 len = 1;
 while ( len < sizeof(buf) )
     {
     c = getchar();
     if ( ! ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISdigit) )
  {
                ungetc( c, stdin );
                break;
                }
            buf[len++] = c;
            }
        buf[len] = '\0';
        yylval = str_to_bi( buf );
        return NUMBER;
        }
    else if ( ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISalpha) )
 {
 buf[0] = c;
 len = 1;
 while ( len < sizeof(buf) )
     {
     c = getchar();
     if ( ! ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISalpha) )
  {
                ungetc( c, stdin );
                break;
                }
            buf[len++] = c;
            }
        buf[len] = '\0';
 for ( i = 0; i < len; ++i )
     if ( ((*__ctype_b_loc ())[(int) ((buf[i]))] & (unsigned short) _ISupper) )
  buf[i] = tolower( buf[i] );
        if ( strcmp( buf, "sqrt" ) == 0 )
     return SQRT;
        else if ( strcmp( buf, "gcd" ) == 0 )
     return GCD;
        else if ( strcmp( buf, "lcm" ) == 0 )
     return LCM;
        else if ( strcmp( buf, "modpow" ) == 0 )
     return MODPOW;
        else if ( strcmp( buf, "modinv" ) == 0 )
     return MODINV;
        else if ( strcmp( buf, "random" ) == 0 )
     return RANDOM;
        else if ( strcmp( buf, "jacobi" ) == 0 )
     return JACOBI;
        else if ( strcmp( buf, "isprime" ) == 0 )
     return ISPRIME;
        else if ( strcmp( buf, "genprime" ) == 0 )
     return GENPRIME;
        else if ( strcmp( buf, "bits" ) == 0 )
     return BITS;
        else if ( strcmp( buf, "bindiv" ) == 0 )
     return BINDIV;
 else if ( len == 1 )
     {
     yylval = int_to_bi( buf[0] - 'a' );
     return VAR;
     }
 else
     return '.';
        }
    else if ( c == '.' )
 {
 yylval = bi_copy( prev_val );
 return NUMBER;
 }
    else if ( c == (-1) )
 return 0;
    else
 return c;
    }

variable_types: len int

variable_types: i int

variable_types:
buf
char [10000]


repo: sergei/wiiuse

decompiled_code:
__int64 __fastcall calculate_gforce(unsigned __int8 *a1, unsigned __int8 *a2, float *a3)
{
float v3; // xmm2_4
float v4; // xmm1_4
__int64 result; // rax

v3 = (float)a1[4];
v4 = (float)a1[5];
*a3 = (float)((float)*a2 - (float)*a1) / (float)a1[3];
result = a1[1];
a3[1] = (float)((float)a2[1] - (float)(int)result) / v3;
a3[2] = (float)((float)a2[2] - (float)a1[2]) / v4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, unsigned __int8 *a2, float *a3)
{
float v3; // xmm2_4
float v4; // xmm1_4
__int64 result; // rax

v3 = (float)a1[4];
v4 = (float)a1[5];
*a3 = (float)((float)*a2 - (float)*a1) / (float)a1[3];
result = a1[1];
a3[1] = (float)((float)a2[1] - (float)(int)result) / v3;
a3[2] = (float)((float)a2[2] - (float)a1[2]) / v4;
return result;
}

original_code:
void calculate_gforce(struct accel_t* ac, struct vec3b_t* accel, struct gforce_t* gforce) {
 float xg, yg, zg;
 xg = (float)ac->cal_g.x;
 yg = (float)ac->cal_g.y;
 zg = (float)ac->cal_g.z;
 gforce->x = ((float)accel->x - (float)ac->cal_zero.x) / xg;
 gforce->y = ((float)accel->y - (float)ac->cal_zero.y) / yg;
 gforce->z = ((float)accel->z - (float)ac->cal_zero.z) / zg;
}

canonical_original_code:
void calculate_gforce(struct accel_t *ac, struct vec3b_t *accel, struct gforce_t *gforce) {
 float xg; float yg; float zg;
 xg = (float)ac->cal_g.x;
 yg = (float)ac->cal_g.y;
 zg = (float)ac->cal_g.z;
 gforce->x = ((float)accel->x - (float)ac->cal_zero.x) / xg;
 gforce->y = ((float)accel->y - (float)ac->cal_zero.y) / yg;
 gforce->z = ((float)accel->z - (float)ac->cal_zero.z) / zg;
}

variable_types: struct accel_t { struct vec3b_t { unsigned char x; } cal_zero; struct vec3b_t cal_g; float st_roll; float st_pitch; float st_alpha; } *

variable_types:
accel
struct vec3b_t *

variable_types:
gforce
struct gforce_t { float x; } *

variable_types: xg float

variable_types: yg float

variable_types: zg float

return_type: void

user_defined_types: struct accel_t { struct vec3b_t cal_zero; struct vec3b_t cal_g; float st_roll; float st_pitch; float st_alpha; }


original_code:
void calc_joystick_state(struct joystick_t* js, float x, float y) {
 float rx, ry, ang;
 if (x == js->center.x)
  rx = 0;
 else if (x >= js->center.x)
  rx = ((float)(x - js->center.x) / (float)(js->max.x - js->center.x));
 else
  rx = ((float)(x - js->min.x) / (float)(js->center.x - js->min.x)) - 1.0f;
 if (y == js->center.y)
  ry = 0;
 else if (y >= js->center.y)
  ry = ((float)(y - js->center.y) / (float)(js->max.y - js->center.y));
 else
  ry = ((float)(y - js->min.y) / (float)(js->center.y - js->min.y)) - 1.0f;
 ang = ((atanf(ry / rx) * 180.0f) / 3.14159265f);
 ang -= 90.0f;
 if (rx < 0.0f)
  ang -= 180.0f;
 js->ang = ((ang >= 0) ? (ang) : (ang * -1.0f));
 js->mag = (float) sqrt((rx * rx) + (ry * ry));
}

canonical_original_code:
void calc_joystick_state(struct joystick_t *js, float x, float y) {
 float rx; float ry; float ang;
 if (x == js->center.x)
  rx = 0;
 else if (x >= js->center.x)
  rx = ((float)(x - js->center.x) / (float)(js->max.x - js->center.x));
 else
  rx = ((float)(x - js->min.x) / (float)(js->center.x - js->min.x)) - 1.0f;
 if (y == js->center.y)
  ry = 0;
 else if (y >= js->center.y)
  ry = ((float)(y - js->center.y) / (float)(js->max.y - js->center.y));
 else
  ry = ((float)(y - js->min.y) / (float)(js->center.y - js->min.y)) - 1.0f;
 ang = ((atanf(ry / rx) * 180.0f) / 3.14159265f);
 ang -= 90.0f;
 if (rx < 0.0f)
  ang -= 180.0f;
 js->ang = ((ang >= 0) ? (ang) : (ang * -1.0f));
 js->mag = (float) sqrt((rx * rx) + (ry * ry));
}

variable_types: struct joystick_t { struct vec2b_t { unsigned char x; } max; struct vec2b_t min; struct vec2b_t center; float ang; float mag; } *

variable_types: x float

variable_types: y float

variable_types: rx float

variable_types: ry float

variable_types: ang float

user_defined_types: struct joystick_t { struct vec2b_t max; struct vec2b_t min; struct vec2b_t center; float ang; float mag; }


original_code:
void apply_smoothing(struct accel_t* ac, struct orient_t* orient, int type) {
 switch (type) {
  case 0x01:
  {
   if (__builtin_isnan (ac->st_roll) || __builtin_isinf_sign (ac->st_roll))
    ac->st_roll = 0.0f;
   if (((ac->st_roll < 0) && (orient->roll > 0)) || ((ac->st_roll > 0) && (orient->roll < 0))) {
    ac->st_roll = orient->roll;
   } else {
    orient->roll = ac->st_roll + (ac->st_alpha * (orient->a_roll - ac->st_roll));
    ac->st_roll = orient->roll;
   }
   return;
  }
  case 0x02:
  {
   if (__builtin_isnan (ac->st_pitch) || __builtin_isinf_sign (ac->st_pitch))
    ac->st_pitch = 0.0f;
   if (((ac->st_pitch < 0) && (orient->pitch > 0)) || ((ac->st_pitch > 0) && (orient->pitch < 0))) {
    ac->st_pitch = orient->pitch;
   } else {
    orient->pitch = ac->st_pitch + (ac->st_alpha * (orient->a_pitch - ac->st_pitch));
    ac->st_pitch = orient->pitch;
   }
   return;
  }
 }
}

canonical_original_code:
void apply_smoothing(struct accel_t *ac, struct orient_t *orient, int type) {
 switch (type) {
  case 0x01:
  {
   if (__builtin_isnan (ac->st_roll) || __builtin_isinf_sign (ac->st_roll))
    ac->st_roll = 0.0f;
   if (((ac->st_roll < 0) && (orient->roll > 0)) || ((ac->st_roll > 0) && (orient->roll < 0))) {
    ac->st_roll = orient->roll;
   } else {
    orient->roll = ac->st_roll + (ac->st_alpha * (orient->a_roll - ac->st_roll));
    ac->st_roll = orient->roll;
   }
   return;
  }
  case 0x02:
  {
   if (__builtin_isnan (ac->st_pitch) || __builtin_isinf_sign (ac->st_pitch))
    ac->st_pitch = 0.0f;
   if (((ac->st_pitch < 0) && (orient->pitch > 0)) || ((ac->st_pitch > 0) && (orient->pitch < 0))) {
    ac->st_pitch = orient->pitch;
   } else {
    orient->pitch = ac->st_pitch + (ac->st_alpha * (orient->a_pitch - ac->st_pitch));
    ac->st_pitch = orient->pitch;
   }
   return;
  }
 }
}

variable_types: struct orient_t { float roll; float pitch; float yaw; float a_roll; float a_pitch; } *

variable_types: type int


original_code:
void calculate_orientation(struct accel_t* ac, struct vec3b_t* accel, struct orient_t* orient, int smooth) {
 float xg, yg, zg;
 float x, y, z;
 orient->yaw = 0.0f;
 xg = (float)ac->cal_g.x;
 yg = (float)ac->cal_g.y;
 zg = (float)ac->cal_g.z;
 x = ((float)accel->x - (float)ac->cal_zero.x) / xg;
 y = ((float)accel->y - (float)ac->cal_zero.y) / yg;
 z = ((float)accel->z - (float)ac->cal_zero.z) / zg;
 if (x < -1.0f) x = -1.0f;
 else if (x > 1.0f) x = 1.0f;
 if (y < -1.0f) y = -1.0f;
 else if (y > 1.0f) y = 1.0f;
 if (z < -1.0f) z = -1.0f;
 else if (z > 1.0f) z = 1.0f;
 if (abs(accel->x - ac->cal_zero.x) <= ac->cal_g.x) {
  x = ((atan2f(x, z) * 180.0f) / 3.14159265f);
  orient->roll = x;
  orient->a_roll = x;
 }
 if (abs(accel->y - ac->cal_zero.y) <= ac->cal_g.y) {
  y = ((atan2f(y, z) * 180.0f) / 3.14159265f);
  orient->pitch = y;
  orient->a_pitch = y;
 }
 if (smooth) {
  apply_smoothing(ac, orient, 0x01);
  apply_smoothing(ac, orient, 0x02);
 }
}

canonical_original_code:
void calculate_orientation(struct accel_t *ac, struct vec3b_t *accel, struct orient_t *orient, int smooth) {
 float xg; float yg; float zg;
 float x; float y; float z;
 orient->yaw = 0.0f;
 xg = (float)ac->cal_g.x;
 yg = (float)ac->cal_g.y;
 zg = (float)ac->cal_g.z;
 x = ((float)accel->x - (float)ac->cal_zero.x) / xg;
 y = ((float)accel->y - (float)ac->cal_zero.y) / yg;
 z = ((float)accel->z - (float)ac->cal_zero.z) / zg;
 if (x < -1.0f) x = -1.0f;
 else if (x > 1.0f) x = 1.0f;
 if (y < -1.0f) y = -1.0f;
 else if (y > 1.0f) y = 1.0f;
 if (z < -1.0f) z = -1.0f;
 else if (z > 1.0f) z = 1.0f;
 if (abs(accel->x - ac->cal_zero.x) <= ac->cal_g.x) {
  x = ((atan2f(x, z) * 180.0f) / 3.14159265f);
  orient->roll = x;
  orient->a_roll = x;
 }
 if (abs(accel->y - ac->cal_zero.y) <= ac->cal_g.y) {
  y = ((atan2f(y, z) * 180.0f) / 3.14159265f);
  orient->pitch = y;
  orient->a_pitch = y;
 }
 if (smooth) {
  apply_smoothing(ac, orient, 0x01);
  apply_smoothing(ac, orient, 0x02);
 }
}

variable_types: smooth int

variable_types: z float

user_defined_types: struct orient_t { float roll; float pitch; float yaw; float a_roll; float a_pitch; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
unsigned int v4; // eax
unsigned int v5; // er12
unsigned int v6; // eax
__int64 v7; // rbx
__int64 v8; // rdi

v3 = wiiuse_init();
v4 = wiiuse_find();
if ( v4 )
{
v5 = v4;
v6 = wiiuse_connect();
if ( v6 )
{
printf("Connected to %i wiimotes (of %i found).\n", v6, v5);
wiiuse_set_leds();
wiiuse_set_leds();
wiiuse_set_leds();
wiiuse_set_leds();
wiiuse_rumble();
wiiuse_rumble();
usleep(0x30D40u);
wiiuse_rumble();
wiiuse_rumble();
while ( 1 )
{
while ( !(unsigned int)wiiuse_poll() )
;
v7 = v3;
do
{
v8 = *(_QWORD *)v7;
switch ( *(_DWORD *)(*(_QWORD *)v7 + 472LL) )
{
case 1:
handle_event(v8, 4LL);
break;
case 2:
handle_ctrl_status(v8, 4LL);
break;
case 4:
case 5:
handle_disconnect(v8, 4LL);
break;
case 7:
puts("Nunchuk inserted.");
break;
case 8:
case 0xA:
case 0xC:
handle_ctrl_status(v8, 4LL);
puts("An expansion was removed.");
break;
case 9:
puts("Classic controller inserted.");
break;
case 0xB:
handle_ctrl_status(v8, 4LL);
puts("Guitar Hero 3 controller inserted.");
break;
default:
break;
}
v7 += 8LL;
}
while ( v7 != v3 + 32 );
}
}
puts("Failed to connect to any wiimote.");
}
else
{
printf("No wiimotes found.");
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
unsigned int v4; // eax
unsigned int v5; // er12
unsigned int v6; // eax
__int64 v7; // rbx
__int64 v8; // rdi

v3 = wiiuse_init();
v4 = wiiuse_find();
if ( v4 )
{
v5 = v4;
v6 = wiiuse_connect();
if ( v6 )
{
printf("Connected to %i wiimotes (of %i found).\n", v6, v5);
wiiuse_set_leds();
wiiuse_set_leds();
wiiuse_set_leds();
wiiuse_set_leds();
wiiuse_rumble();
wiiuse_rumble();
usleep(0x30D40u);
wiiuse_rumble();
wiiuse_rumble();
while ( 1 )
{
while ( !(unsigned int)wiiuse_poll() )
;
v7 = v3;
do
{
v8 = *(_QWORD *)v7;
switch ( *(_DWORD *)(*(_QWORD *)v7 + 472LL) )
{
case 1:
func7(v8, 4LL);
break;
case 2:
func9(v8, 4LL);
break;
case 4:
case 5:
func10(v8, 4LL);
break;
case 7:
puts("Nunchuk inserted.");
break;
case 8:
case 0xA:
case 0xC:
func9(v8, 4LL);
puts("An expansion was removed.");
break;
case 9:
puts("Classic controller inserted.");
break;
case 0xB:
func9(v8, 4LL);
puts("Guitar Hero 3 controller inserted.");
break;
default:
break;
}
v7 += 8LL;
}
while ( v7 != v3 + 32 );
}
}
puts("Failed to connect to any wiimote.");
}
else
{
printf("No wiimotes found.");
}
return 0;
}

original_code:
int main(int argc, char** argv) {
 wiimote** wiimotes;
 int found, connected;
 wiimotes = wiiuse_init(4);
 found = wiiuse_find(wiimotes, 4, 5);
 if (!found) {
  printf ("No wiimotes found.");
  return 0;
 }
 connected = wiiuse_connect(wiimotes, 4);
 if (connected)
  printf("Connected to %i wiimotes (of %i found).\n", connected, found);
 else {
  printf("Failed to connect to any wiimote.\n");
  return 0;
 }
 wiiuse_set_leds(wiimotes[0], 0x10);
 wiiuse_set_leds(wiimotes[1], 0x20);
 wiiuse_set_leds(wiimotes[2], 0x40);
 wiiuse_set_leds(wiimotes[3], 0x80);
 wiiuse_rumble(wiimotes[0], 1);
 wiiuse_rumble(wiimotes[1], 1);
  usleep(200000);
 wiiuse_rumble(wiimotes[0], 0);
 wiiuse_rumble(wiimotes[1], 0);
 while (1) {
  if (wiiuse_poll(wiimotes, 4)) {
   int i = 0;
   for (; i < 4; ++i) {
    switch (wiimotes[i]->event) {
     case WIIUSE_EVENT:
      handle_event(wiimotes[i]);
      break;
     case WIIUSE_STATUS:
      handle_ctrl_status(wiimotes[i]);
      break;
     case WIIUSE_DISCONNECT:
     case WIIUSE_UNEXPECTED_DISCONNECT:
      handle_disconnect(wiimotes[i]);
      break;
     case WIIUSE_READ_DATA:
      break;
     case WIIUSE_NUNCHUK_INSERTED:
      printf("Nunchuk inserted.\n");
      break;
     case WIIUSE_CLASSIC_CTRL_INSERTED:
      printf("Classic controller inserted.\n");
      break;
     case WIIUSE_GUITAR_HERO_3_CTRL_INSERTED:
      handle_ctrl_status(wiimotes[i]);
      printf("Guitar Hero 3 controller inserted.\n");
      break;
     case WIIUSE_NUNCHUK_REMOVED:
     case WIIUSE_CLASSIC_CTRL_REMOVED:
     case WIIUSE_GUITAR_HERO_3_CTRL_REMOVED:
      handle_ctrl_status(wiimotes[i]);
      printf("An expansion was removed.\n");
      break;
     default:
      break;
    }
   }
  }
 }
 wiiuse_cleanup(wiimotes, 4);
 return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
 struct wiimote_t **wiimotes;
 int found; int connected;
 wiimotes = wiiuse_init(4);
 found = wiiuse_find(wiimotes, 4, 5);
 if (!found) {
  printf ("No wiimotes found.");
  return 0;
 }
 connected = wiiuse_connect(wiimotes, 4);
 if (connected)
  printf("Connected to %i wiimotes (of %i found).\n", connected, found);
 else {
  printf("Failed to connect to any wiimote.\n");
  return 0;
 }
 wiiuse_set_leds(wiimotes[0], 0x10);
 wiiuse_set_leds(wiimotes[1], 0x20);
 wiiuse_set_leds(wiimotes[2], 0x40);
 wiiuse_set_leds(wiimotes[3], 0x80);
 wiiuse_rumble(wiimotes[0], 1);
 wiiuse_rumble(wiimotes[1], 1);
  usleep(200000);
 wiiuse_rumble(wiimotes[0], 0);
 wiiuse_rumble(wiimotes[1], 0);
 while (1) {
  if (wiiuse_poll(wiimotes, 4)) {
   int i = 0;
   for (; i < 4; ++i) {
    switch (wiimotes[i]->event) {
     case WIIUSE_EVENT:
      handle_event(wiimotes[i]);
      break;
     case WIIUSE_STATUS:
      handle_ctrl_status(wiimotes[i]);
      break;
     case WIIUSE_DISCONNECT:
     case WIIUSE_UNEXPECTED_DISCONNECT:
      handle_disconnect(wiimotes[i]);
      break;
     case WIIUSE_READ_DATA:
      break;
     case WIIUSE_NUNCHUK_INSERTED:
      printf("Nunchuk inserted.\n");
      break;
     case WIIUSE_CLASSIC_CTRL_INSERTED:
      printf("Classic controller inserted.\n");
      break;
     case WIIUSE_GUITAR_HERO_3_CTRL_INSERTED:
      handle_ctrl_status(wiimotes[i]);
      printf("Guitar Hero 3 controller inserted.\n");
      break;
     case WIIUSE_NUNCHUK_REMOVED:
     case WIIUSE_CLASSIC_CTRL_REMOVED:
     case WIIUSE_GUITAR_HERO_3_CTRL_REMOVED:
      handle_ctrl_status(wiimotes[i]);
      printf("An expansion was removed.\n");
      break;
     default:
      break;
    }
   }
  }
 }
 wiiuse_cleanup(wiimotes, 4);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct wiimote_t { int unid; struct bdaddr_t { unsigned char b[6]; } bdaddr; char bdaddr_str[18]; int out_sock; int in_sock; int state; unsigned char leds; float battery_level; int flags; unsigned char handshake_state; struct read_req_t { void (*cb)(struct wiimote_t *wm, unsigned char *data, unsigned short len); unsigned char *buf; unsigned int addr; unsigned short size; unsigned short wait; unsigned char dirty; struct read_req_t *next; } *read_req; struct accel_t { struct vec3b_t { unsigned char x; } cal_zero; struct vec3b_t cal_g; float st_roll; float st_pitch; float st_alpha; } accel_calib; struct expansion_t { int type; union { struct nunchuk_t { struct accel_t accel_calib; struct joystick_t { struct vec2b_t { unsigned char x; } max; struct vec2b_t min; struct vec2b_t center; float ang; float mag; } js; int *flags; unsigned char btns; unsigned char btns_held; unsigned char btns_released; float orient_threshold; int accel_threshold; struct vec3b_t accel; struct orient_t { float roll; float pitch; float yaw; float a_roll; float a_pitch; } orient; struct gforce_t { float x; } gforce; } nunchuk; struct classic_ctrl_t { short btns; short btns_held; short btns_released; float r_shoulder; float l_shoulder; struct joystick_t ljs; struct joystick_t rjs; } classic; struct guitar_hero_3_t { short btns; short btns_held; short btns_released; float whammy_bar; struct joystick_t js; } gh3; }; } exp; struct vec3b_t accel; struct orient_t orient; struct gforce_t gforce; struct ir_t { struct ir_dot_t { unsigned char visible; unsigned int x; unsigned int y; short rx; short ry; unsigned char order; unsigned char size; } dot[4]; unsigned char num_dots; enum aspect_t { WIIUSE_ASPECT_4_3=0, WIIUSE_ASPECT_16_9=1 } aspect; enum ir_position_t { WIIUSE_IR_ABOVE=0, WIIUSE_IR_BELOW=1 } pos; unsigned int vres[2]; int offset[2]; int state; int ax; int ay; int x; int y; float distance; float z; } ir; unsigned short btns; unsigned short btns_held; unsigned short btns_released; float orient_threshold; int accel_threshold; struct wiimote_state_t { float exp_ljs_ang; float exp_rjs_ang; float exp_ljs_mag; float exp_rjs_mag; unsigned short exp_btns; struct orient_t exp_orient; struct vec3b_t exp_accel; float exp_r_shoulder; float exp_l_shoulder; int ir_ax; int ir_ay; float ir_distance; struct orient_t orient; unsigned short btns; struct vec3b_t accel; } lstate; enum WIIUSE_EVENT_TYPE { WIIUSE_NONE=0, WIIUSE_EVENT=1, WIIUSE_STATUS=2, WIIUSE_CONNECT=3, WIIUSE_DISCONNECT=4, WIIUSE_UNEXPECTED_DISCONNECT=5, WIIUSE_READ_DATA=6, WIIUSE_NUNCHUK_INSERTED=7, WIIUSE_NUNCHUK_REMOVED=8, WIIUSE_CLASSIC_CTRL_INSERTED=9, WIIUSE_CLASSIC_CTRL_REMOVED=10, WIIUSE_GUITAR_HERO_3_CTRL_INSERTED=11, WIIUSE_GUITAR_HERO_3_CTRL_REMOVED=12 } event; unsigned char event_buf[32]; } **

variable_types: found int

variable_types: connected int

variable_types: i int

return_type: int

user_defined_types: struct wiimote_t { int unid; struct bdaddr_t bdaddr; char bdaddr_str[18]; int out_sock; int in_sock; int state; unsigned char leds; float battery_level; int flags; unsigned char handshake_state; struct read_req_t *read_req; struct accel_t accel_calib; struct expansion_t exp; struct vec3b_t accel; struct orient_t orient; struct gforce_t gforce; struct ir_t ir; unsigned short btns; unsigned short btns_held; unsigned short btns_released; float orient_threshold; int accel_threshold; struct wiimote_state_t lstate; enum WIIUSE_EVENT_TYPE event; unsigned char event_buf[32]; }

user_defined_types: struct expansion_t { int type; union { struct nunchuk_t nunchuk; struct classic_ctrl_t classic; struct guitar_hero_3_t gh3; }; }

user_defined_types: struct ir_t { struct ir_dot_t dot[4]; unsigned char num_dots; enum aspect_t aspect; enum ir_position_t pos; unsigned int vres[2]; int offset[2]; int state; int ax; int ay; int x; int y; float distance; float z; }

user_defined_types: struct nunchuk_t { struct accel_t accel_calib; struct joystick_t js; int *flags; unsigned char btns; unsigned char btns_held; unsigned char btns_released; float orient_threshold; int accel_threshold; struct vec3b_t accel; struct orient_t orient; struct gforce_t gforce; }


original_code:
void handle_event(struct wiimote_t* wm) {
 printf("\n\n--- EVENT [id %i] ---\n", wm->unid);
 if (((wm->btns & 0x0008) == 0x0008)) printf("A pressed\n");
 if (((wm->btns & 0x0004) == 0x0004)) printf("B pressed\n");
 if (((wm->btns & 0x0800) == 0x0800)) printf("UP pressed\n");
 if (((wm->btns & 0x0400) == 0x0400)) printf("DOWN pressed\n");
 if (((wm->btns & 0x0100) == 0x0100)) printf("LEFT pressed\n");
 if (((wm->btns & 0x0200) == 0x0200)) printf("RIGHT pressed\n");
 if (((wm->btns & 0x0010) == 0x0010)) printf("MINUS pressed\n");
 if (((wm->btns & 0x1000) == 0x1000)) printf("PLUS pressed\n");
 if (((wm->btns & 0x0002) == 0x0002)) printf("ONE pressed\n");
 if (((wm->btns & 0x0001) == 0x0001)) printf("TWO pressed\n");
 if (((wm->btns & 0x0080) == 0x0080)) printf("HOME pressed\n");
 if ((((wm->btns & 0x0010) == 0x0010) && !((wm->btns_held & 0x0010) == 0x0010)))
  wiiuse_motion_sensing(wm, 0);
 if ((((wm->btns & 0x1000) == 0x1000) && !((wm->btns_held & 0x1000) == 0x1000)))
  wiiuse_motion_sensing(wm, 1);
 if ((((wm->btns & 0x0004) == 0x0004) && !((wm->btns_held & 0x0004) == 0x0004)))
  wiiuse_toggle_rumble(wm);
 if ((((wm->btns & 0x0800) == 0x0800) && !((wm->btns_held & 0x0800) == 0x0800)))
  wiiuse_set_ir(wm, 1);
 if ((((wm->btns & 0x0400) == 0x0400) && !((wm->btns_held & 0x0400) == 0x0400)))
  wiiuse_set_ir(wm, 0);
 if (((wm->state & 0x020) == 0x020)) {
  printf("wiimote roll  = %f [%f]\n", wm->orient.roll, wm->orient.a_roll);
  printf("wiimote pitch = %f [%f]\n", wm->orient.pitch, wm->orient.a_pitch);
  printf("wiimote yaw   = %f\n", wm->orient.yaw);
 }
 if (((wm->state & 0x080) == 0x080)) {
  int i = 0;
  for (; i < 4; ++i) {
   if (wm->ir.dot[i].visible)
    printf("IR source %i: (%u, %u)\n", i, wm->ir.dot[i].x, wm->ir.dot[i].y);
  }
  printf("IR cursor: (%u, %u)\n", wm->ir.x, wm->ir.y);
  printf("IR z distance: %f\n", wm->ir.z);
 }
 if (wm->exp.type == 1) {
  struct nunchuk_t* nc = (nunchuk_t*)&wm->exp.nunchuk;
  if (((nc->btns & 0x02) == 0x02)) printf("Nunchuk: C pressed\n");
  if (((nc->btns & 0x01) == 0x01)) printf("Nunchuk: Z pressed\n");
  printf("nunchuk roll  = %f\n", nc->orient.roll);
  printf("nunchuk pitch = %f\n", nc->orient.pitch);
  printf("nunchuk yaw   = %f\n", nc->orient.yaw);
  printf("nunchuk joystick angle:     %f\n", nc->js.ang);
  printf("nunchuk joystick magnitude: %f\n", nc->js.mag);
 } else if (wm->exp.type == 2) {
  struct classic_ctrl_t* cc = (classic_ctrl_t*)&wm->exp.classic;
  if (((cc->btns & 0x0080) == 0x0080)) printf("Classic: ZL pressed\n");
  if (((cc->btns & 0x0040) == 0x0040)) printf("Classic: B pressed\n");
  if (((cc->btns & 0x0020) == 0x0020)) printf("Classic: Y pressed\n");
  if (((cc->btns & 0x0010) == 0x0010)) printf("Classic: A pressed\n");
  if (((cc->btns & 0x0008) == 0x0008)) printf("Classic: X pressed\n");
  if (((cc->btns & 0x0004) == 0x0004)) printf("Classic: ZR pressed\n");
  if (((cc->btns & 0x0002) == 0x0002)) printf("Classic: LEFT pressed\n");
  if (((cc->btns & 0x0001) == 0x0001)) printf("Classic: UP pressed\n");
  if (((cc->btns & 0x8000) == 0x8000)) printf("Classic: RIGHT pressed\n");
  if (((cc->btns & 0x4000) == 0x4000)) printf("Classic: DOWN pressed\n");
  if (((cc->btns & 0x2000) == 0x2000)) printf("Classic: FULL L pressed\n");
  if (((cc->btns & 0x1000) == 0x1000)) printf("Classic: MINUS pressed\n");
  if (((cc->btns & 0x0800) == 0x0800)) printf("Classic: HOME pressed\n");
  if (((cc->btns & 0x0400) == 0x0400)) printf("Classic: PLUS pressed\n");
  if (((cc->btns & 0x0200) == 0x0200)) printf("Classic: FULL R pressed\n");
  printf("classic L button pressed:         %f\n", cc->l_shoulder);
  printf("classic R button pressed:         %f\n", cc->r_shoulder);
  printf("classic left joystick angle:      %f\n", cc->ljs.ang);
  printf("classic left joystick magnitude:  %f\n", cc->ljs.mag);
  printf("classic right joystick angle:     %f\n", cc->rjs.ang);
  printf("classic right joystick magnitude: %f\n", cc->rjs.mag);
 } else if (wm->exp.type == 3) {
  struct guitar_hero_3_t* gh3 = (guitar_hero_3_t*)&wm->exp.gh3;
  if (((gh3->btns & 0x0001) == 0x0001)) printf("Guitar: Strum Up pressed\n");
  if (((gh3->btns & 0x4000) == 0x4000)) printf("Guitar: Strum Down pressed\n");
  if (((gh3->btns & 0x0008) == 0x0008)) printf("Guitar: Yellow pressed\n");
  if (((gh3->btns & 0x0010) == 0x0010)) printf("Guitar: Green pressed\n");
  if (((gh3->btns & 0x0020) == 0x0020)) printf("Guitar: Blue pressed\n");
  if (((gh3->btns & 0x0040) == 0x0040)) printf("Guitar: Red pressed\n");
  if (((gh3->btns & 0x0080) == 0x0080)) printf("Guitar: Orange pressed\n");
  if (((gh3->btns & 0x0400) == 0x0400)) printf("Guitar: Plus pressed\n");
  if (((gh3->btns & 0x1000) == 0x1000)) printf("Guitar: Minus pressed\n");
  printf("Guitar whammy bar:          %f\n", gh3->whammy_bar);
  printf("Guitar joystick angle:      %f\n", gh3->js.ang);
  printf("Guitar joystick magnitude:  %f\n", gh3->js.mag);
 }
}

canonical_original_code:
void handle_event(struct wiimote_t *wm) {
 printf("\n\n--- EVENT [id %i] ---\n", wm->unid);
 if (((wm->btns & 0x0008) == 0x0008)) printf("A pressed\n");
 if (((wm->btns & 0x0004) == 0x0004)) printf("B pressed\n");
 if (((wm->btns & 0x0800) == 0x0800)) printf("UP pressed\n");
 if (((wm->btns & 0x0400) == 0x0400)) printf("DOWN pressed\n");
 if (((wm->btns & 0x0100) == 0x0100)) printf("LEFT pressed\n");
 if (((wm->btns & 0x0200) == 0x0200)) printf("RIGHT pressed\n");
 if (((wm->btns & 0x0010) == 0x0010)) printf("MINUS pressed\n");
 if (((wm->btns & 0x1000) == 0x1000)) printf("PLUS pressed\n");
 if (((wm->btns & 0x0002) == 0x0002)) printf("ONE pressed\n");
 if (((wm->btns & 0x0001) == 0x0001)) printf("TWO pressed\n");
 if (((wm->btns & 0x0080) == 0x0080)) printf("HOME pressed\n");
 if ((((wm->btns & 0x0010) == 0x0010) && !((wm->btns_held & 0x0010) == 0x0010)))
  wiiuse_motion_sensing(wm, 0);
 if ((((wm->btns & 0x1000) == 0x1000) && !((wm->btns_held & 0x1000) == 0x1000)))
  wiiuse_motion_sensing(wm, 1);
 if ((((wm->btns & 0x0004) == 0x0004) && !((wm->btns_held & 0x0004) == 0x0004)))
  wiiuse_toggle_rumble(wm);
 if ((((wm->btns & 0x0800) == 0x0800) && !((wm->btns_held & 0x0800) == 0x0800)))
  wiiuse_set_ir(wm, 1);
 if ((((wm->btns & 0x0400) == 0x0400) && !((wm->btns_held & 0x0400) == 0x0400)))
  wiiuse_set_ir(wm, 0);
 if (((wm->state & 0x020) == 0x020)) {
  printf("wiimote roll  = %f [%f]\n", wm->orient.roll, wm->orient.a_roll);
  printf("wiimote pitch = %f [%f]\n", wm->orient.pitch, wm->orient.a_pitch);
  printf("wiimote yaw   = %f\n", wm->orient.yaw);
 }
 if (((wm->state & 0x080) == 0x080)) {
  int i = 0;
  for (; i < 4; ++i) {
   if (wm->ir.dot[i].visible)
    printf("IR source %i: (%u, %u)\n", i, wm->ir.dot[i].x, wm->ir.dot[i].y);
  }
  printf("IR cursor: (%u, %u)\n", wm->ir.x, wm->ir.y);
  printf("IR z distance: %f\n", wm->ir.z);
 }
 if (wm->exp.type == 1) {
  struct nunchuk_t *nc = (nunchuk_t*)&wm->exp.nunchuk;
  if (((nc->btns & 0x02) == 0x02)) printf("Nunchuk: C pressed\n");
  if (((nc->btns & 0x01) == 0x01)) printf("Nunchuk: Z pressed\n");
  printf("nunchuk roll  = %f\n", nc->orient.roll);
  printf("nunchuk pitch = %f\n", nc->orient.pitch);
  printf("nunchuk yaw   = %f\n", nc->orient.yaw);
  printf("nunchuk joystick angle:     %f\n", nc->js.ang);
  printf("nunchuk joystick magnitude: %f\n", nc->js.mag);
 } else if (wm->exp.type == 2) {
  struct classic_ctrl_t *cc = (classic_ctrl_t*)&wm->exp.classic;
  if (((cc->btns & 0x0080) == 0x0080)) printf("Classic: ZL pressed\n");
  if (((cc->btns & 0x0040) == 0x0040)) printf("Classic: B pressed\n");
  if (((cc->btns & 0x0020) == 0x0020)) printf("Classic: Y pressed\n");
  if (((cc->btns & 0x0010) == 0x0010)) printf("Classic: A pressed\n");
  if (((cc->btns & 0x0008) == 0x0008)) printf("Classic: X pressed\n");
  if (((cc->btns & 0x0004) == 0x0004)) printf("Classic: ZR pressed\n");
  if (((cc->btns & 0x0002) == 0x0002)) printf("Classic: LEFT pressed\n");
  if (((cc->btns & 0x0001) == 0x0001)) printf("Classic: UP pressed\n");
  if (((cc->btns & 0x8000) == 0x8000)) printf("Classic: RIGHT pressed\n");
  if (((cc->btns & 0x4000) == 0x4000)) printf("Classic: DOWN pressed\n");
  if (((cc->btns & 0x2000) == 0x2000)) printf("Classic: FULL L pressed\n");
  if (((cc->btns & 0x1000) == 0x1000)) printf("Classic: MINUS pressed\n");
  if (((cc->btns & 0x0800) == 0x0800)) printf("Classic: HOME pressed\n");
  if (((cc->btns & 0x0400) == 0x0400)) printf("Classic: PLUS pressed\n");
  if (((cc->btns & 0x0200) == 0x0200)) printf("Classic: FULL R pressed\n");
  printf("classic L button pressed:         %f\n", cc->l_shoulder);
  printf("classic R button pressed:         %f\n", cc->r_shoulder);
  printf("classic left joystick angle:      %f\n", cc->ljs.ang);
  printf("classic left joystick magnitude:  %f\n", cc->ljs.mag);
  printf("classic right joystick angle:     %f\n", cc->rjs.ang);
  printf("classic right joystick magnitude: %f\n", cc->rjs.mag);
 } else if (wm->exp.type == 3) {
  struct guitar_hero_3_t *gh3 = (guitar_hero_3_t*)&wm->exp.gh3;
  if (((gh3->btns & 0x0001) == 0x0001)) printf("Guitar: Strum Up pressed\n");
  if (((gh3->btns & 0x4000) == 0x4000)) printf("Guitar: Strum Down pressed\n");
  if (((gh3->btns & 0x0008) == 0x0008)) printf("Guitar: Yellow pressed\n");
  if (((gh3->btns & 0x0010) == 0x0010)) printf("Guitar: Green pressed\n");
  if (((gh3->btns & 0x0020) == 0x0020)) printf("Guitar: Blue pressed\n");
  if (((gh3->btns & 0x0040) == 0x0040)) printf("Guitar: Red pressed\n");
  if (((gh3->btns & 0x0080) == 0x0080)) printf("Guitar: Orange pressed\n");
  if (((gh3->btns & 0x0400) == 0x0400)) printf("Guitar: Plus pressed\n");
  if (((gh3->btns & 0x1000) == 0x1000)) printf("Guitar: Minus pressed\n");
  printf("Guitar whammy bar:          %f\n", gh3->whammy_bar);
  printf("Guitar joystick angle:      %f\n", gh3->js.ang);
  printf("Guitar joystick magnitude:  %f\n", gh3->js.mag);
 }
}

variable_types: struct wiimote_t { int unid; struct bdaddr_t { unsigned char b[6]; } bdaddr; char bdaddr_str[18]; int out_sock; int in_sock; int state; unsigned char leds; float battery_level; int flags; unsigned char handshake_state; struct read_req_t { void (*cb)(struct wiimote_t *wm, unsigned char *data, unsigned short len); unsigned char *buf; unsigned int addr; unsigned short size; unsigned short wait; unsigned char dirty; struct read_req_t *next; } *read_req; struct accel_t { struct vec3b_t { unsigned char x; } cal_zero; struct vec3b_t cal_g; float st_roll; float st_pitch; float st_alpha; } accel_calib; struct expansion_t { int type; union { struct nunchuk_t { struct accel_t accel_calib; struct joystick_t { struct vec2b_t { unsigned char x; } max; struct vec2b_t min; struct vec2b_t center; float ang; float mag; } js; int *flags; unsigned char btns; unsigned char btns_held; unsigned char btns_released; float orient_threshold; int accel_threshold; struct vec3b_t accel; struct orient_t { float roll; float pitch; float yaw; float a_roll; float a_pitch; } orient; struct gforce_t { float x; } gforce; } nunchuk; struct classic_ctrl_t { short btns; short btns_held; short btns_released; float r_shoulder; float l_shoulder; struct joystick_t ljs; struct joystick_t rjs; } classic; struct guitar_hero_3_t { short btns; short btns_held; short btns_released; float whammy_bar; struct joystick_t js; } gh3; }; } exp; struct vec3b_t accel; struct orient_t orient; struct gforce_t gforce; struct ir_t { struct ir_dot_t { unsigned char visible; unsigned int x; unsigned int y; short rx; short ry; unsigned char order; unsigned char size; } dot[4]; unsigned char num_dots; enum aspect_t { WIIUSE_ASPECT_4_3=0, WIIUSE_ASPECT_16_9=1 } aspect; enum ir_position_t { WIIUSE_IR_ABOVE=0, WIIUSE_IR_BELOW=1 } pos; unsigned int vres[2]; int offset[2]; int state; int ax; int ay; int x; int y; float distance; float z; } ir; unsigned short btns; unsigned short btns_held; unsigned short btns_released; float orient_threshold; int accel_threshold; struct wiimote_state_t { float exp_ljs_ang; float exp_rjs_ang; float exp_ljs_mag; float exp_rjs_mag; unsigned short exp_btns; struct orient_t exp_orient; struct vec3b_t exp_accel; float exp_r_shoulder; float exp_l_shoulder; int ir_ax; int ir_ay; float ir_distance; struct orient_t orient; unsigned short btns; struct vec3b_t accel; } lstate; enum WIIUSE_EVENT_TYPE { WIIUSE_NONE=0, WIIUSE_EVENT=1, WIIUSE_STATUS=2, WIIUSE_CONNECT=3, WIIUSE_DISCONNECT=4, WIIUSE_UNEXPECTED_DISCONNECT=5, WIIUSE_READ_DATA=6, WIIUSE_NUNCHUK_INSERTED=7, WIIUSE_NUNCHUK_REMOVED=8, WIIUSE_CLASSIC_CTRL_INSERTED=9, WIIUSE_CLASSIC_CTRL_REMOVED=10, WIIUSE_GUITAR_HERO_3_CTRL_INSERTED=11, WIIUSE_GUITAR_HERO_3_CTRL_REMOVED=12 } event; unsigned char event_buf[32]; } *

variable_types: struct nunchuk_t { struct accel_t { struct vec3b_t { unsigned char x; } cal_zero; struct vec3b_t cal_g; float st_roll; float st_pitch; float st_alpha; } accel_calib; struct joystick_t { struct vec2b_t { unsigned char x; } max; struct vec2b_t min; struct vec2b_t center; float ang; float mag; } js; int *flags; unsigned char btns; unsigned char btns_held; unsigned char btns_released; float orient_threshold; int accel_threshold; struct vec3b_t accel; struct orient_t { float roll; float pitch; float yaw; float a_roll; float a_pitch; } orient; struct gforce_t { float x; } gforce; } *

variable_types: struct classic_ctrl_t { short btns; short btns_held; short btns_released; float r_shoulder; float l_shoulder; struct joystick_t { struct vec2b_t { unsigned char x; } max; struct vec2b_t min; struct vec2b_t center; float ang; float mag; } ljs; struct joystick_t rjs; } *

variable_types: struct guitar_hero_3_t { short btns; short btns_held; short btns_released; float whammy_bar; struct joystick_t { struct vec2b_t { unsigned char x; } max; struct vec2b_t min; struct vec2b_t center; float ang; float mag; } js; } *


original_code:
void handle_read(struct wiimote_t* wm, byte* data, unsigned short len) {
 int i = 0;
 printf("\n\n--- DATA READ [wiimote id %i] ---\n", wm->unid);
 printf("finished read of size %i\n", len);
 for (; i < len; ++i) {
  if (!(i%16))
   printf("\n");
  printf("%x ", data[i]);
 }
 printf("\n\n");
}

canonical_original_code:
void handle_read(struct wiimote_t *wm, unsigned char *data, unsigned short len) {
 int i = 0;
 printf("\n\n--- DATA READ [wiimote id %i] ---\n", wm->unid);
 printf("finished read of size %i\n", len);
 for (; i < len; ++i) {
  if (!(i%16))
   printf("\n");
  printf("%x ", data[i]);
 }
 printf("\n\n");
}

variable_types:
data
unsigned char *

variable_types:
len
unsigned short

user_defined_types: struct wiimote_state_t { float exp_ljs_ang; float exp_rjs_ang; float exp_ljs_mag; float exp_rjs_mag; unsigned short exp_btns; struct orient_t exp_orient; struct vec3b_t exp_accel; float exp_r_shoulder; float exp_l_shoulder; int ir_ax; int ir_ay; float ir_distance; struct orient_t orient; unsigned short btns; struct vec3b_t accel; }

user_defined_types: enum WIIUSE_EVENT_TYPE { WIIUSE_NONE=0, WIIUSE_EVENT=1, WIIUSE_STATUS=2, WIIUSE_CONNECT=3, WIIUSE_DISCONNECT=4, WIIUSE_UNEXPECTED_DISCONNECT=5, WIIUSE_READ_DATA=6, WIIUSE_NUNCHUK_INSERTED=7, WIIUSE_NUNCHUK_REMOVED=8, WIIUSE_CLASSIC_CTRL_INSERTED=9, WIIUSE_CLASSIC_CTRL_REMOVED=10, WIIUSE_GUITAR_HERO_3_CTRL_INSERTED=11, WIIUSE_GUITAR_HERO_3_CTRL_REMOVED=12 }

user_defined_types: struct read_req_t { void (*cb)(struct wiimote_t *wm, unsigned char *data, unsigned short len); unsigned char *buf; unsigned int addr; unsigned short size; unsigned short wait; unsigned char dirty; struct read_req_t *next; }

user_defined_types: enum aspect_t { WIIUSE_ASPECT_4_3=0, WIIUSE_ASPECT_16_9=1 }

user_defined_types: enum ir_position_t { WIIUSE_IR_ABOVE=0, WIIUSE_IR_BELOW=1 }

user_defined_types: struct classic_ctrl_t { short btns; short btns_held; short btns_released; float r_shoulder; float l_shoulder; struct joystick_t ljs; struct joystick_t rjs; }

user_defined_types: struct guitar_hero_3_t { short btns; short btns_held; short btns_released; float whammy_bar; struct joystick_t js; }

user_defined_types: struct ir_dot_t { unsigned char visible; unsigned int x; unsigned int y; short rx; short ry; unsigned char order; unsigned char size; }


decompiled_code:
int __fastcall handle_ctrl_status(float *a1)
{
printf("\n\n--- CONTROLLER STATUS [wiimote id %i] ---\n", *(unsigned int *)a1);
printf("attachment: %i\n", *((unsigned int *)a1 + 22));
printf("speaker: %i\n", (*((_DWORD *)a1 + 9) >> 8) & 1);
printf("ir: %i\n", (*((_DWORD *)a1 + 9) >> 7) & 1);
printf(
"leds: %i %i %i %i\n",
((_BYTE)a1[10] & 0x10) != 0,
((_BYTE)a1[10] & 0x20) != 0,
((_BYTE)a1[10] & 0x40) != 0,
(unsigned int)*((char *)a1 + 40) >> 31);
return printf("battery: %f %%\n", a1[11]);
}

canonical_decompiled_code:
int __fastcall func9(float *a1)
{
printf("\n\n--- CONTROLLER STATUS [wiimote id %i] ---\n", *(unsigned int *)a1);
printf("attachment: %i\n", *((unsigned int *)a1 + 22));
printf("speaker: %i\n", (*((_DWORD *)a1 + 9) >> 8) & 1);
printf("ir: %i\n", (*((_DWORD *)a1 + 9) >> 7) & 1);
printf(
"leds: %i %i %i %i\n",
((_BYTE)a1[10] & 0x10) != 0,
((_BYTE)a1[10] & 0x20) != 0,
((_BYTE)a1[10] & 0x40) != 0,
(unsigned int)*((char *)a1 + 40) >> 31);
return printf("battery: %f %%\n", a1[11]);
}

original_code:
void handle_ctrl_status(struct wiimote_t* wm) {
 printf("\n\n--- CONTROLLER STATUS [wiimote id %i] ---\n", wm->unid);
 printf("attachment:      %i\n", wm->exp.type);
 printf("speaker:         %i\n", ((wm->state & 0x100) == 0x100));
 printf("ir:              %i\n", ((wm->state & 0x080) == 0x080));
 printf("leds:            %i %i %i %i\n", ((wm->leds & 0x10) == 0x10), ((wm->leds & 0x20) == 0x20), ((wm->leds & 0x40) == 0x40), ((wm->leds & 0x80) == 0x80));
 printf("battery:         %f %%\n", wm->battery_level);
}

canonical_original_code:
void handle_ctrl_status(struct wiimote_t *wm) {
 printf("\n\n--- CONTROLLER STATUS [wiimote id %i] ---\n", wm->unid);
 printf("attachment:      %i\n", wm->exp.type);
 printf("speaker:         %i\n", ((wm->state & 0x100) == 0x100));
 printf("ir:              %i\n", ((wm->state & 0x080) == 0x080));
 printf("leds:            %i %i %i %i\n", ((wm->leds & 0x10) == 0x10), ((wm->leds & 0x20) == 0x20), ((wm->leds & 0x40) == 0x40), ((wm->leds & 0x80) == 0x80));
 printf("battery:         %f %%\n", wm->battery_level);
}


decompiled_code:
int __fastcall handle_disconnect(unsigned int *a1)
{
return printf("\n\n--- DISCONNECTED [wiimote id %i] ---\n", *a1);
}

canonical_decompiled_code:
int __fastcall func10(unsigned int *a1)
{
return printf("\n\n--- DISCONNECTED [wiimote id %i] ---\n", *a1);
}

original_code:
void handle_disconnect(wiimote* wm) {
 printf("\n\n--- DISCONNECTED [wiimote id %i] ---\n", wm->unid);
}

canonical_original_code:
void handle_disconnect(struct wiimote_t *wm) {
 printf("\n\n--- DISCONNECTED [wiimote id %i] ---\n", wm->unid);
}


test

decompiled_code:
int __fastcall test(__int64 a1, unsigned __int8 *a2, unsigned __int16 a3)
{
return printf("test: %i [%x %x %x %x]\n", a3, *a2, a2[1], a2[2], a2[3]);
}

canonical_decompiled_code:
int __fastcall func11(__int64 a1, unsigned __int8 *a2, unsigned __int16 a3)
{
return printf("test: %i [%x %x %x %x]\n", a3, *a2, a2[1], a2[2], a2[3]);
}

original_code:
void test(struct wiimote_t* wm, byte* data, unsigned short len) {
 printf("test: %i [%x %x %x %x]\n", len, data[0], data[1], data[2], data[3]);
}

canonical_original_code:
void test(struct wiimote_t *wm, unsigned char *data, unsigned short len) {
 printf("test: %i [%x %x %x %x]\n", len, data[0], data[1], data[2], data[3]);
}


original_code:
int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
 int device_id;
 int device_sock;
 int found_devices;
 int found_wiimotes;
 for (found_wiimotes = 0; found_wiimotes < max_wiimotes; ++found_wiimotes)
  wm[found_wiimotes]->bdaddr = *(&(bdaddr_t) {{0, 0, 0, 0, 0, 0}});
 found_wiimotes = 0;
 device_id = hci_get_route(((void *)0));
 if (device_id < 0) {
  perror("hci_get_route");
  return 0;
 }
 device_sock = hci_open_dev(device_id);
 if (device_sock < 0) {
  perror("hci_open_dev");
  return 0;
 }
 inquiry_info scan_info_arr[128];
 inquiry_info* scan_info = scan_info_arr;
 memset(&scan_info_arr, 0, sizeof(scan_info_arr));
 found_devices = hci_inquiry(device_id, timeout, 128, ((void *)0), &scan_info, 0x0001);
 if (found_devices < 0) {
  perror("hci_inquiry");
  return 0;
 }
 fprintf(stderr, "[INFO] " "Found %i bluetooth device(s)." "\n", found_devices);
 int i = 0;
 for (; (i < found_devices) && (found_wiimotes < max_wiimotes); ++i) {
  if ((scan_info[i].dev_class[0] == 0x04) &&
   (scan_info[i].dev_class[1] == 0x25) &&
   (scan_info[i].dev_class[2] == 0x00))
  {
   ba2str(&scan_info[i].bdaddr, wm[found_wiimotes]->bdaddr_str);
   fprintf(stderr, "[INFO] " "Found wiimote (%s) [id %i]." "\n", wm[found_wiimotes]->bdaddr_str, wm[found_wiimotes]->unid);
   wm[found_wiimotes]->bdaddr = scan_info[i].bdaddr;
   (wm[found_wiimotes]->state |= (0x0001));
   ++found_wiimotes;
  }
 }
 close(device_sock);
 return found_wiimotes;
}

canonical_original_code:
int wiiuse_find(struct wiimote_t **wm, int max_wiimotes, int timeout) {
 int device_id;
 int device_sock;
 int found_devices;
 int found_wiimotes;
 for (found_wiimotes = 0; found_wiimotes < max_wiimotes; ++found_wiimotes)
  wm[found_wiimotes]->bdaddr = *(&(struct bdaddr_t) {{0, 0, 0, 0, 0, 0}});
 found_wiimotes = 0;
 device_id = hci_get_route(((void *)0));
 if (device_id < 0) {
  perror("hci_get_route");
  return 0;
 }
 device_sock = hci_open_dev(device_id);
 if (device_sock < 0) {
  perror("hci_open_dev");
  return 0;
 }
 struct inquiry_info scan_info_arr[128];
 struct inquiry_info *scan_info = scan_info_arr;
 memset(&scan_info_arr, 0, sizeof(scan_info_arr));
 found_devices = hci_inquiry(device_id, timeout, 128, ((void *)0), &scan_info, 0x0001);
 if (found_devices < 0) {
  perror("hci_inquiry");
  return 0;
 }
 fprintf(stderr, "[INFO] " "Found %i bluetooth device(s)." "\n", found_devices);
 int i = 0;
 for (; (i < found_devices) && (found_wiimotes < max_wiimotes); ++i) {
  if ((scan_info[i].dev_class[0] == 0x04) &&
   (scan_info[i].dev_class[1] == 0x25) &&
   (scan_info[i].dev_class[2] == 0x00))
  {
   ba2str(&scan_info[i].bdaddr, wm[found_wiimotes]->bdaddr_str);
   fprintf(stderr, "[INFO] " "Found wiimote (%s) [id %i]." "\n", wm[found_wiimotes]->bdaddr_str, wm[found_wiimotes]->unid);
   wm[found_wiimotes]->bdaddr = scan_info[i].bdaddr;
   (wm[found_wiimotes]->state |= (0x0001));
   ++found_wiimotes;
  }
 }
 close(device_sock);
 return found_wiimotes;
}

variable_types: timeout int

variable_types: struct inquiry_info { struct bdaddr_t { unsigned char b[6]; } bdaddr; unsigned char pscan_rep_mode; unsigned char pscan_period_mode; unsigned char pscan_mode; unsigned char dev_class[3]; unsigned short clock_offset; } [128]

variable_types: struct inquiry_info { struct bdaddr_t { unsigned char b[6]; } bdaddr; unsigned char pscan_rep_mode; unsigned char pscan_period_mode; unsigned char pscan_mode; unsigned char dev_class[3]; unsigned short clock_offset; } *

user_defined_types: struct inquiry_info { struct bdaddr_t bdaddr; unsigned char pscan_rep_mode; unsigned char pscan_period_mode; unsigned char pscan_mode; unsigned char dev_class[3]; unsigned short clock_offset; }


decompiled_code:
__int64 __fastcall wiiuse_connect(_QWORD *a1, int a2)
{
_QWORD *v2; // r13
unsigned int **v3; // rbx
unsigned int v4; // er12
__int64 v5; // rbp
__int64 v6; // rax
__int64 v7; // rdi
unsigned int *v8; // rdi
_QWORD *v9; // r13
__int64 v10; // rdi
__int64 v11; // rdi
__int64 v12; // rdi
__int64 v13; // rdi
__int64 v14; // rdi
__int64 v15; // rdi
int v17; // eax
int v18; // eax
int v19; // eax
int v20; // eax
int v21; // eax
int v22; // eax
int v23; // eax

if ( a2 > 0 )
{
v2 = a1;
v3 = (unsigned int **)a1;
v4 = 0;
v5 = (__int64)&a1[(unsigned int)(a2 - 1) + 1];
v6 = a2 & 7;
if ( (a2 & 7) == 0 )
goto LABEL_29;
if ( v6 != 1 )
{
if ( v6 != 2 )
{
if ( v6 != 3 )
{
if ( v6 != 4 )
{
if ( v6 != 5 )
{
if ( v6 != 6 )
{
v7 = *a1;
if ( (*(_BYTE *)(v7 + 36) & 1) != 0 )
v4 = wiiuse_connect_single_constprop_0((unsigned int *)v7) != 0;
v3 = (unsigned int **)(v2 + 1);
}
if ( ((*v3)[9] & 1) != 0 )
v4 -= ((unsigned int)wiiuse_connect_single_constprop_0(*v3) == 0) - 1;
++v3;
}
if ( ((*v3)[9] & 1) != 0 )
v4 -= ((unsigned int)wiiuse_connect_single_constprop_0(*v3) == 0) - 1;
++v3;
}
if ( ((*v3)[9] & 1) != 0 )
v4 -= ((unsigned int)wiiuse_connect_single_constprop_0(*v3) == 0) - 1;
++v3;
}
if ( ((*v3)[9] & 1) != 0 )
v4 -= ((unsigned int)wiiuse_connect_single_constprop_0(*v3) == 0) - 1;
++v3;
}
if ( ((*v3)[9] & 1) != 0 )
v4 -= ((unsigned int)wiiuse_connect_single_constprop_0(*v3) == 0) - 1;
++v3;
}
if ( ((*v3)[9] & 1) == 0 )
{
if ( ++v3 != (unsigned int **)v5 )
goto LABEL_29;
return v4;
}
v4 -= ((unsigned int)wiiuse_connect_single_constprop_0(*v3++) == 0) - 1;
if ( v3 == (unsigned int **)v5 )
return v4;
while ( 1 )
{
LABEL_29:
if ( ((*v3)[9] & 1) != 0 )
{
v23 = wiiuse_connect_single_constprop_0(*v3);
v8 = v3[1];
v9 = v3 + 1;
v4 -= (v23 == 0) - 1;
if ( (v8[9] & 1) != 0 )
goto LABEL_51;
LABEL_31:
v10 = v9[1];
if ( (*(_BYTE *)(v10 + 36) & 1) == 0 )
goto LABEL_32;
LABEL_49:
v21 = wiiuse_connect_single_constprop_0((unsigned int *)v10);
v11 = v9[2];
v4 -= (v21 == 0) - 1;
if ( (*(_BYTE *)(v11 + 36) & 1) != 0 )
goto LABEL_47;
LABEL_33:
v12 = v9[3];
if ( (*(_BYTE *)(v12 + 36) & 1) == 0 )
goto LABEL_34;
LABEL_45:
v19 = wiiuse_connect_single_constprop_0((unsigned int *)v12);
v13 = v9[4];
v4 -= (v19 == 0) - 1;
if ( (*(_BYTE *)(v13 + 36) & 1) != 0 )
goto LABEL_43;
LABEL_35:
v14 = v9[5];
if ( (*(_BYTE *)(v14 + 36) & 1) == 0 )
goto LABEL_36;
LABEL_41:
v17 = wiiuse_connect_single_constprop_0((unsigned int *)v14);
v15 = v9[6];
v4 -= (v17 == 0) - 1;
if ( (*(_BYTE *)(v15 + 36) & 1) == 0 )
goto LABEL_37;
LABEL_39:
v3 = (unsigned int **)(v9 + 7);
v4 -= ((unsigned int)wiiuse_connect_single_constprop_0((unsigned int *)v15) == 0) - 1;
if ( v9 + 7 == (_QWORD *)v5 )
return v4;
}
else
{
v8 = v3[1];
v9 = v3 + 1;
if ( (v8[9] & 1) == 0 )
goto LABEL_31;
LABEL_51:
v22 = wiiuse_connect_single_constprop_0(v8);
v10 = v9[1];
v4 -= (v22 == 0) - 1;
if ( (*(_BYTE *)(v10 + 36) & 1) != 0 )
goto LABEL_49;
LABEL_32:
v11 = v9[2];
if ( (*(_BYTE *)(v11 + 36) & 1) == 0 )
goto LABEL_33;
LABEL_47:
v20 = wiiuse_connect_single_constprop_0((unsigned int *)v11);
v12 = v9[3];
v4 -= (v20 == 0) - 1;
if ( (*(_BYTE *)(v12 + 36) & 1) != 0 )
goto LABEL_45;
LABEL_34:
v13 = v9[4];
if ( (*(_BYTE *)(v13 + 36) & 1) == 0 )
goto LABEL_35;
LABEL_43:
v18 = wiiuse_connect_single_constprop_0((unsigned int *)v13);
v14 = v9[5];
v4 -= (v18 == 0) - 1;
if ( (*(_BYTE *)(v14 + 36) & 1) != 0 )
goto LABEL_41;
LABEL_36:
v15 = v9[6];
if ( (*(_BYTE *)(v15 + 36) & 1) != 0 )
goto LABEL_39;
LABEL_37:
v3 = (unsigned int **)(v9 + 7);
if ( v9 + 7 == (_QWORD *)v5 )
return v4;
}
}
}
return 0LL;
}

original_code:
int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
 int connected = 0;
 int i = 0;
 for (; i < wiimotes; ++i) {
  if (!((wm[i]->state & (0x0001)) == (0x0001)))
   continue;
  if (wiiuse_connect_single(wm[i], ((void *)0)))
   ++connected;
 }
 return connected;
}

canonical_original_code:
int wiiuse_connect(struct wiimote_t **wm, int wiimotes) {
 int connected = 0;
 int i = 0;
 for (; i < wiimotes; ++i) {
  if (!((wm[i]->state & (0x0001)) == (0x0001)))
   continue;
  if (wiiuse_connect_single(wm[i], ((void *)0)))
   ++connected;
 }
 return connected;
}

variable_types: wiimotes int


decompiled_code:
int __fastcall wiiuse_disconnect(int *a1)
{
int result; // eax

if ( a1 )
{
if ( (a1[9] & 8) == 0 )
{
close(a1[7]);
result = close(a1[8]);
a1[9] &= 0xFFFFFFF5;
*(_QWORD *)(a1 + 7) = -1LL;
a1[118] = 0;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(int *a1)
{
int result; // eax

if ( a1 )
{
if ( (a1[9] & 8) == 0 )
{
close(a1[7]);
result = close(a1[8]);
a1[9] &= 0xFFFFFFF5;
*(_QWORD *)(a1 + 7) = -1LL;
a1[118] = 0;
}
}
return result;
}

original_code:
void wiiuse_disconnect(struct wiimote_t* wm) {
 if (!wm || (((wm->state & (0x0008)) == (0x0008))))
  return;
 close(wm->out_sock);
 close(wm->in_sock);
 wm->out_sock = -1;
 wm->in_sock = -1;
 wm->event = WIIUSE_NONE;
 (wm->state &= ~(0x0008));
 (wm->state &= ~(0x0002));
}

canonical_original_code:
void wiiuse_disconnect(struct wiimote_t *wm) {
 if (!wm || (((wm->state & (0x0008)) == (0x0008))))
  return;
 close(wm->out_sock);
 close(wm->in_sock);
 wm->out_sock = -1;
 wm->in_sock = -1;
 wm->event = WIIUSE_NONE;
 (wm->state &= ~(0x0008));
 (wm->state &= ~(0x0002));
}


decompiled_code:
__int64 wiiuse_io_read()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
return 0LL;
}

original_code:
int wiiuse_io_read(struct wiimote_t* wm) {
 return 0;
}

canonical_original_code:
int wiiuse_io_read(struct wiimote_t *wm) {
 return 0;
}


decompiled_code:
ssize_t __fastcall wiiuse_io_write(__int64 a1, const void *a2, int a3)
{
return write(*(_DWORD *)(a1 + 28), a2, a3);
}

canonical_decompiled_code:
ssize_t __fastcall func5(__int64 a1, const void *a2, int a3)
{
return write(*(_DWORD *)(a1 + 28), a2, a3);
}

original_code:
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
 return write(wm->out_sock, buf, len);
}

canonical_original_code:
int wiiuse_io_write(struct wiimote_t *wm, unsigned char *buf, int len) {
 return write(wm->out_sock, buf, len);
}

variable_types:
buf
unsigned char *

variable_types: len int


original_code:
int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, unsigned short len) {
 int i;
 int offset = 0;
 nc->btns = 0;
 nc->btns_held = 0;
 nc->btns_released = 0;
 nc->flags = &wm->flags;
 nc->accel_calib.st_alpha = wm->accel_calib.st_alpha;
 for (i = 0; i < len; ++i)
  data[i] = (data[i] ^ 0x17) + 0x17;
 if (data[offset] == 0xFF) {
  if (data[offset + 16] == 0xFF) {
   byte* handshake_buf = malloc(224 * sizeof(byte));
   ;
   wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, 0x04A40020, 224);
   return 0;
  } else
   offset += 16;
 }
 nc->accel_calib.cal_zero.x = data[offset + 0];
 nc->accel_calib.cal_zero.y = data[offset + 1];
 nc->accel_calib.cal_zero.z = data[offset + 2];
 nc->accel_calib.cal_g.x = data[offset + 4];
 nc->accel_calib.cal_g.y = data[offset + 5];
 nc->accel_calib.cal_g.z = data[offset + 6];
 nc->js.max.x = data[offset + 8];
 nc->js.min.x = data[offset + 9];
 nc->js.center.x = data[offset + 10];
 nc->js.max.y = data[offset + 11];
 nc->js.min.y = data[offset + 12];
 nc->js.center.y = data[offset + 13];
 nc->orient_threshold = wm->orient_threshold;
 nc->accel_threshold = wm->accel_threshold;
 wm->exp.type = 1;
 return 1;
}

canonical_original_code:
int nunchuk_handshake(struct wiimote_t *wm, struct nunchuk_t *nc, unsigned char *data, unsigned short len) {
 int i;
 int offset = 0;
 nc->btns = 0;
 nc->btns_held = 0;
 nc->btns_released = 0;
 nc->flags = &wm->flags;
 nc->accel_calib.st_alpha = wm->accel_calib.st_alpha;
 for (i = 0; i < len; ++i)
  data[i] = (data[i] ^ 0x17) + 0x17;
 if (data[offset] == 0xFF) {
  if (data[offset + 16] == 0xFF) {
   unsigned char *handshake_buf = malloc(224 * sizeof(byte));
   ;
   wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, 0x04A40020, 224);
   return 0;
  } else
   offset += 16;
 }
 nc->accel_calib.cal_zero.x = data[offset + 0];
 nc->accel_calib.cal_zero.y = data[offset + 1];
 nc->accel_calib.cal_zero.z = data[offset + 2];
 nc->accel_calib.cal_g.x = data[offset + 4];
 nc->accel_calib.cal_g.y = data[offset + 5];
 nc->accel_calib.cal_g.z = data[offset + 6];
 nc->js.max.x = data[offset + 8];
 nc->js.min.x = data[offset + 9];
 nc->js.center.x = data[offset + 10];
 nc->js.max.y = data[offset + 11];
 nc->js.min.y = data[offset + 12];
 nc->js.center.y = data[offset + 13];
 nc->orient_threshold = wm->orient_threshold;
 nc->accel_threshold = wm->accel_threshold;
 wm->exp.type = 1;
 return 1;
}

variable_types:
nc
struct nunchuk_t *

variable_types: offset int


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

*a1 = 0LL;
result = 0LL;
a1[11] = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 96) >> 3));
return result;
}

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

*a1 = 0LL;
result = 0LL;
a1[11] = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 96) >> 3));
return result;
}

original_code:
void nunchuk_disconnected(struct nunchuk_t* nc) {
 memset(nc, 0, sizeof(struct nunchuk_t));
}

canonical_original_code:
void nunchuk_disconnected(struct nunchuk_t *nc) {
 memset(nc, 0, sizeof(struct nunchuk_t));
}


original_code:
void nunchuk_event(struct nunchuk_t* nc, byte* msg) {
 int i;
 for (i = 0; i < 6; ++i)
  msg[i] = (msg[i] ^ 0x17) + 0x17;
 nunchuk_pressed_buttons(nc, msg[5]);
 calc_joystick_state(&nc->js, msg[0], msg[1]);
 nc->accel.x = msg[2];
 nc->accel.y = msg[3];
 nc->accel.z = msg[4];
 calculate_orientation(&nc->accel_calib, &nc->accel, &nc->orient, ((*(nc->flags) & (0x01)) == (0x01)));
 calculate_gforce(&nc->accel_calib, &nc->accel, &nc->gforce);
}

canonical_original_code:
void nunchuk_event(struct nunchuk_t *nc, unsigned char *msg) {
 int i;
 for (i = 0; i < 6; ++i)
  msg[i] = (msg[i] ^ 0x17) + 0x17;
 nunchuk_pressed_buttons(nc, msg[5]);
 calc_joystick_state(&nc->js, msg[0], msg[1]);
 nc->accel.x = msg[2];
 nc->accel.y = msg[3];
 nc->accel.z = msg[4];
 calculate_orientation(&nc->accel_calib, &nc->accel, &nc->orient, ((*(nc->flags) & (0x01)) == (0x01)));
 calculate_gforce(&nc->accel_calib, &nc->accel, &nc->gforce);
}

variable_types:
msg
unsigned char *


decompiled_code:
void __fastcall wiiuse_set_nunchuk_orient_threshold(__int64 a1, float a2)
{
if ( a1 )
*(float *)(a1 + 148) = a2;
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1, float a2)
{
if ( a1 )
*(float *)(a1 + 148) = a2;
}

original_code:
void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold) {
 if (!wm) return;
 wm->exp.nunchuk.orient_threshold = threshold;
}

canonical_original_code:
void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t *wm, float threshold) {
 if (!wm) return;
 wm->exp.nunchuk.orient_threshold = threshold;
}

variable_types: threshold float


decompiled_code:
void __fastcall wiiuse_set_nunchuk_accel_threshold(__int64 a1, int a2)
{
if ( a1 )
*(_DWORD *)(a1 + 152) = a2;
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, int a2)
{
if ( a1 )
*(_DWORD *)(a1 + 152) = a2;
}

original_code:
void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold) {
 if (!wm) return;
 wm->exp.nunchuk.accel_threshold = threshold;
}

canonical_original_code:
void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t *wm, int threshold) {
 if (!wm) return;
 wm->exp.nunchuk.accel_threshold = threshold;
}

variable_types: threshold int


original_code:
int guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, byte* data, unsigned short len) {
 int i;
 int offset = 0;
 gh3->btns = 0;
 gh3->btns_held = 0;
 gh3->btns_released = 0;
 gh3->whammy_bar = 0.0f;
 for (i = 0; i < len; ++i)
  data[i] = (data[i] ^ 0x17) + 0x17;
 if (data[offset] == 0xFF) {
  if (data[offset + 16] == 0xFF) {
   byte* handshake_buf = malloc(224 * sizeof(byte));
   ;
   wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, 0x04A40020, 224);
   return 0;
  } else
   offset += 16;
 }
 gh3->js.max.x = 0xFC;
 gh3->js.min.x = 0xC5;
 gh3->js.center.x = 0xE0;
 gh3->js.max.y = 0xFA;
 gh3->js.min.y = 0xC5;
 gh3->js.center.y = 0xE0;
 wm->exp.type = 3;
 return 1;
}

canonical_original_code:
int guitar_hero_3_handshake(struct wiimote_t *wm, struct guitar_hero_3_t *gh3, unsigned char *data, unsigned short len) {
 int i;
 int offset = 0;
 gh3->btns = 0;
 gh3->btns_held = 0;
 gh3->btns_released = 0;
 gh3->whammy_bar = 0.0f;
 for (i = 0; i < len; ++i)
  data[i] = (data[i] ^ 0x17) + 0x17;
 if (data[offset] == 0xFF) {
  if (data[offset + 16] == 0xFF) {
   unsigned char *handshake_buf = malloc(224 * sizeof(byte));
   ;
   wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, 0x04A40020, 224);
   return 0;
  } else
   offset += 16;
 }
 gh3->js.max.x = 0xFC;
 gh3->js.min.x = 0xC5;
 gh3->js.center.x = 0xE0;
 gh3->js.max.y = 0xFA;
 gh3->js.min.y = 0xC5;
 gh3->js.center.y = 0xE0;
 wm->exp.type = 3;
 return 1;
}

variable_types: struct wiimote_t { int unid; struct bdaddr_t { unsigned char b[6]; } bdaddr; char bdaddr_str[18]; int out_sock; int in_sock; int state; unsigned char leds; float battery_level; int flags; unsigned char handshake_state; struct read_req_t { void (*cb)(struct wiimote_t *wm, unsigned char *data, unsigned short len); unsigned char *buf; unsigned int addr; unsigned short size; unsigned short wait; unsigned char dirty; struct read_req_t *next; } *read_req; struct accel_t { struct vec3b_t { unsigned char x; } cal_zero; struct vec3b_t cal_g; float st_roll; float st_pitch; float st_alpha; } accel_calib; struct expansion_t { int type; union { struct nunchuk_t { struct accel_t accel_calib; struct joystick_t { struct vec2b_t { unsigned char x; } max; struct vec2b_t min; struct vec2b_t center; float ang; float mag; } js; int *flags; unsigned char btns; unsigned char btns_held; unsigned char btns_released; float orient_threshold; int accel_threshold; struct vec3b_t accel; struct orient_t { float roll; float pitch; float yaw; float a_roll; float a_pitch; } orient; struct gforce_t { float x; } gforce; } nunchuk; struct classic_ctrl_t { short btns; short btns_held; short btns_released; float r_shoulder; float l_shoulder; struct joystick_t ljs; struct joystick_t rjs; } classic; struct guitar_hero_3_t { short btns; short btns_held; short btns_released; float whammy_bar; struct joystick_t js; } gh3; }; } exp; struct vec3b_t accel; struct orient_t orient; struct gforce_t gforce; struct ir_t { struct ir_dot_t { unsigned char visible; unsigned int x; unsigned int y; short rx; short ry; unsigned char order; unsigned char size; } dot[4]; unsigned char num_dots; enum aspect_t { WIIUSE_ASPECT_4_3=0, WIIUSE_ASPECT_16_9=1 } aspect; enum ir_position_t { WIIUSE_IR_ABOVE=0, WIIUSE_IR_BELOW=1 } pos; unsigned int vres[2]; int offset[2]; int state; int ax; int ay; int x; int y; float distance; float z; } ir; unsigned short btns; unsigned short btns_held; unsigned short btns_released; float orient_threshold; int accel_threshold; struct wiimote_state_t { float exp_ljs_ang; float exp_rjs_ang; float exp_ljs_mag; float exp_rjs_mag; unsigned short exp_btns; struct orient_t exp_orient; struct vec3b_t exp_accel; float exp_r_shoulder; float exp_l_shoulder; int ir_ax; int ir_ay; float ir_distance; struct orient_t orient; unsigned short btns; struct vec3b_t accel; } lstate; enum WIIUSE_EVENT_TYPE { WIIUSE_NONE=0, WIIUSE_EVENT=1, WIIUSE_STATUS=2, WIIUSE_CONNECT=3, WIIUSE_DISCONNECT=4, WIIUSE_UNEXPECTED_DISCONNECT=5, WIIUSE_READ_DATA=6, WIIUSE_NUNCHUK_INSERTED=7, WIIUSE_NUNCHUK_REMOVED=8, WIIUSE_CLASSIC_CTRL_INSERTED=9, WIIUSE_CLASSIC_CTRL_REMOVED=10, WIIUSE_GUITAR_HERO_3_CTRL_INSERTED=11, WIIUSE_GUITAR_HERO_3_CTRL_REMOVED=12 } event; unsigned char event_buf[32]; } *

variable_types: i int


decompiled_code:
void __fastcall guitar_hero_3_disconnected(__int64 a1)
{
*(_QWORD *)(a1 + 16) = 0LL;
*(_DWORD *)(a1 + 24) = 0;
*(_OWORD *)a1 = 0LL;
}

original_code:
void guitar_hero_3_disconnected(struct guitar_hero_3_t* gh3) {
 memset(gh3, 0, sizeof(struct guitar_hero_3_t));
}

canonical_original_code:
void guitar_hero_3_disconnected(struct guitar_hero_3_t *gh3) {
 memset(gh3, 0, sizeof(struct guitar_hero_3_t));
}


original_code:
void guitar_hero_3_event(struct guitar_hero_3_t* gh3, byte* msg) {
 int i;
 for (i = 0; i < 6; ++i)
  msg[i] = (msg[i] ^ 0x17) + 0x17;
 guitar_hero_3_pressed_buttons(gh3, (htons(*(short*)(msg + 4))));
 gh3->whammy_bar = (msg[3] - 0xEF) / (float)(0xFA - 0xEF);
 calc_joystick_state(&gh3->js, msg[0], msg[1]);
}

canonical_original_code:
void guitar_hero_3_event(struct guitar_hero_3_t *gh3, unsigned char *msg) {
 int i;
 for (i = 0; i < 6; ++i)
  msg[i] = (msg[i] ^ 0x17) + 0x17;
 guitar_hero_3_pressed_buttons(gh3, (htons(*(short *)(msg + 4))));
 gh3->whammy_bar = (msg[3] - 0xEF) / (float)(0xFA - 0xEF);
 calc_joystick_state(&gh3->js, msg[0], msg[1]);
}


original_code:
void wiiuse_handshake(struct wiimote_t* wm, byte* data, unsigned short len) {
 if (!wm) return;
 switch (wm->handshake_state) {
  case 0:
  {
   byte* buf;
   (wm->state |= (0x0002));
   wiiuse_set_leds(wm, 0x00);
   buf = (byte*)malloc(sizeof(byte) * 8);
   wiiuse_read_data_cb(wm, wiiuse_handshake, buf, 0x16, 7);
   wm->handshake_state++;
   wiiuse_set_leds(wm, 0x00);
   break;
  }
  case 1:
  {
   struct read_req_t* req = wm->read_req;
   struct accel_t* accel = &wm->accel_calib;
   accel->cal_zero.x = req->buf[0];
   accel->cal_zero.y = req->buf[1];
   accel->cal_zero.z = req->buf[2];
   accel->cal_g.x = req->buf[4] - accel->cal_zero.x;
   accel->cal_g.y = req->buf[5] - accel->cal_zero.y;
   accel->cal_g.z = req->buf[6] - accel->cal_zero.z;
   free(req->buf);
   ;
   wiiuse_status(wm);
   (wm->state &= ~(0x0002));
   (wm->state |= (0x0004));
   wm->handshake_state++;
   if (((wm->state & (0x0080)) == (0x0080))) {
    ;
    (wm->state &= ~(0x0080));
    wiiuse_set_ir(wm, 1);
   }
   break;
  }
  default:
  {
   break;
  }
 }
}

canonical_original_code:
void wiiuse_handshake(struct wiimote_t *wm, unsigned char *data, unsigned short len) {
 if (!wm) return;
 switch (wm->handshake_state) {
  case 0:
  {
   unsigned char *buf;
   (wm->state |= (0x0002));
   wiiuse_set_leds(wm, 0x00);
   buf = (unsigned char *)malloc(sizeof(byte) * 8);
   wiiuse_read_data_cb(wm, wiiuse_handshake, buf, 0x16, 7);
   wm->handshake_state++;
   wiiuse_set_leds(wm, 0x00);
   break;
  }
  case 1:
  {
   struct read_req_t *req = wm->read_req;
   struct accel_t *accel = &wm->accel_calib;
   accel->cal_zero.x = req->buf[0];
   accel->cal_zero.y = req->buf[1];
   accel->cal_zero.z = req->buf[2];
   accel->cal_g.x = req->buf[4] - accel->cal_zero.x;
   accel->cal_g.y = req->buf[5] - accel->cal_zero.y;
   accel->cal_g.z = req->buf[6] - accel->cal_zero.z;
   free(req->buf);
   ;
   wiiuse_status(wm);
   (wm->state &= ~(0x0002));
   (wm->state |= (0x0004));
   wm->handshake_state++;
   if (((wm->state & (0x0080)) == (0x0080))) {
    ;
    (wm->state &= ~(0x0080));
    wiiuse_set_ir(wm, 1);
   }
   break;
  }
  default:
  {
   break;
  }
 }
}

variable_types: struct read_req_t { void (*cb)(struct wiimote_t { int unid; struct bdaddr_t { unsigned char b[6]; } bdaddr; char bdaddr_str[18]; int out_sock; int in_sock; int state; unsigned char leds; float battery_level; int flags; unsigned char handshake_state; struct read_req_t *read_req; struct accel_t { struct vec3b_t { unsigned char x; } cal_zero; struct vec3b_t cal_g; float st_roll; float st_pitch; float st_alpha; } accel_calib; struct expansion_t { int type; union { struct nunchuk_t { struct accel_t accel_calib; struct joystick_t { struct vec2b_t { unsigned char x; } max; struct vec2b_t min; struct vec2b_t center; float ang; float mag; } js; int *flags; unsigned char btns; unsigned char btns_held; unsigned char btns_released; float orient_threshold; int accel_threshold; struct vec3b_t accel; struct orient_t { float roll; float pitch; float yaw; float a_roll; float a_pitch; } orient; struct gforce_t { float x; } gforce; } nunchuk; struct classic_ctrl_t { short btns; short btns_held; short btns_released; float r_shoulder; float l_shoulder; struct joystick_t ljs; struct joystick_t rjs; } classic; struct guitar_hero_3_t { short btns; short btns_held; short btns_released; float whammy_bar; struct joystick_t js; } gh3; }; } exp; struct vec3b_t accel; struct orient_t orient; struct gforce_t gforce; struct ir_t { struct ir_dot_t { unsigned char visible; unsigned int x; unsigned int y; short rx; short ry; unsigned char order; unsigned char size; } dot[4]; unsigned char num_dots; enum aspect_t { WIIUSE_ASPECT_4_3=0, WIIUSE_ASPECT_16_9=1 } aspect; enum ir_position_t { WIIUSE_IR_ABOVE=0, WIIUSE_IR_BELOW=1 } pos; unsigned int vres[2]; int offset[2]; int state; int ax; int ay; int x; int y; float distance; float z; } ir; unsigned short btns; unsigned short btns_held; unsigned short btns_released; float orient_threshold; int accel_threshold; struct wiimote_state_t { float exp_ljs_ang; float exp_rjs_ang; float exp_ljs_mag; float exp_rjs_mag; unsigned short exp_btns; struct orient_t exp_orient; struct vec3b_t exp_accel; float exp_r_shoulder; float exp_l_shoulder; int ir_ax; int ir_ay; float ir_distance; struct orient_t orient; unsigned short btns; struct vec3b_t accel; } lstate; enum WIIUSE_EVENT_TYPE { WIIUSE_NONE=0, WIIUSE_EVENT=1, WIIUSE_STATUS=2, WIIUSE_CONNECT=3, WIIUSE_DISCONNECT=4, WIIUSE_UNEXPECTED_DISCONNECT=5, WIIUSE_READ_DATA=6, WIIUSE_NUNCHUK_INSERTED=7, WIIUSE_NUNCHUK_REMOVED=8, WIIUSE_CLASSIC_CTRL_INSERTED=9, WIIUSE_CLASSIC_CTRL_REMOVED=10, WIIUSE_GUITAR_HERO_3_CTRL_INSERTED=11, WIIUSE_GUITAR_HERO_3_CTRL_REMOVED=12 } event; unsigned char event_buf[32]; } *wm, unsigned char *data, unsigned short len); unsigned char *buf; unsigned int addr; unsigned short size; unsigned short wait; unsigned char dirty; struct read_req_t *next; } *

variable_types: struct accel_t { struct vec3b_t { unsigned char x; } cal_zero; struct vec3b_t cal_g; float st_roll; float st_pitch; float st_alpha; } *


original_code:
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len) {
 int i;
 int offset = 0;
 cc->btns = 0;
 cc->btns_held = 0;
 cc->btns_released = 0;
 cc->r_shoulder = 0;
 cc->l_shoulder = 0;
 for (i = 0; i < len; ++i)
  data[i] = (data[i] ^ 0x17) + 0x17;
 if (data[offset] == 0xFF) {
  if (data[offset + 16] == 0xFF) {
   byte* handshake_buf = malloc(224 * sizeof(byte));
   ;
   wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, 0x04A40020, 224);
   return 0;
  } else
   offset += 16;
 }
 cc->ljs.max.x = data[0 + offset] / 4;
 cc->ljs.min.x = data[1 + offset] / 4;
 cc->ljs.center.x = data[2 + offset] / 4;
 cc->ljs.max.y = data[3 + offset] / 4;
 cc->ljs.min.y = data[4 + offset] / 4;
 cc->ljs.center.y = data[5 + offset] / 4;
 cc->rjs.max.x = data[6 + offset] / 8;
 cc->rjs.min.x = data[7 + offset] / 8;
 cc->rjs.center.x = data[8 + offset] / 8;
 cc->rjs.max.y = data[9 + offset] / 8;
 cc->rjs.min.y = data[10 + offset] / 8;
 cc->rjs.center.y = data[11 + offset] / 8;
 wm->exp.type = 2;
 return 1;
}

canonical_original_code:
int classic_ctrl_handshake(struct wiimote_t *wm, struct classic_ctrl_t *cc, unsigned char *data, unsigned short len) {
 int i;
 int offset = 0;
 cc->btns = 0;
 cc->btns_held = 0;
 cc->btns_released = 0;
 cc->r_shoulder = 0;
 cc->l_shoulder = 0;
 for (i = 0; i < len; ++i)
  data[i] = (data[i] ^ 0x17) + 0x17;
 if (data[offset] == 0xFF) {
  if (data[offset + 16] == 0xFF) {
   unsigned char *handshake_buf = malloc(224 * sizeof(byte));
   ;
   wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, 0x04A40020, 224);
   return 0;
  } else
   offset += 16;
 }
 cc->ljs.max.x = data[0 + offset] / 4;
 cc->ljs.min.x = data[1 + offset] / 4;
 cc->ljs.center.x = data[2 + offset] / 4;
 cc->ljs.max.y = data[3 + offset] / 4;
 cc->ljs.min.y = data[4 + offset] / 4;
 cc->ljs.center.y = data[5 + offset] / 4;
 cc->rjs.max.x = data[6 + offset] / 8;
 cc->rjs.min.x = data[7 + offset] / 8;
 cc->rjs.center.x = data[8 + offset] / 8;
 cc->rjs.max.y = data[9 + offset] / 8;
 cc->rjs.min.y = data[10 + offset] / 8;
 cc->rjs.center.y = data[11 + offset] / 8;
 wm->exp.type = 2;
 return 1;
}

variable_types:
cc
struct classic_ctrl_t *

variable_types:
data
unsigned char *


decompiled_code:
void __fastcall classic_ctrl_disconnected(_OWORD *a1)
{
*a1 = 0LL;
a1[1] = 0LL;
a1[2] = 0LL;
}

canonical_decompiled_code:
void __fastcall func3(_OWORD *a1)
{
*a1 = 0LL;
a1[1] = 0LL;
a1[2] = 0LL;
}

original_code:
void classic_ctrl_disconnected(struct classic_ctrl_t* cc) {
 memset(cc, 0, sizeof(struct classic_ctrl_t));
}

canonical_original_code:
void classic_ctrl_disconnected(struct classic_ctrl_t *cc) {
 memset(cc, 0, sizeof(struct classic_ctrl_t));
}

variable_types: struct classic_ctrl_t { short btns; short btns_held; short btns_released; float r_shoulder; float l_shoulder; struct joystick_t { struct vec2b_t { unsigned char x; } max; struct vec2b_t min; struct vec2b_t center; float ang; float mag; } ljs; struct joystick_t rjs; } *


original_code:
void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg) {
 int i, lx, ly, rx, ry;
 byte l, r;
 for (i = 0; i < 6; ++i)
  msg[i] = (msg[i] ^ 0x17) + 0x17;
 classic_ctrl_pressed_buttons(cc, (htons(*(short*)(msg + 4))));
 l = (((msg[2] & 0x60) >> 2) | ((msg[3] & 0xE0) >> 5));
 r = (msg[3] & 0x1F);
 cc->r_shoulder = ((float)r / 0x1F);
 cc->l_shoulder = ((float)l / 0x1F);
 lx = (msg[0] & 0x3F);
 ly = (msg[1] & 0x3F);
 rx = ((msg[0] & 0xC0) >> 3) | ((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7);
 ry = (msg[2] & 0x1F);
 calc_joystick_state(&cc->ljs, lx, ly);
 calc_joystick_state(&cc->rjs, rx, ry);
}

canonical_original_code:
void classic_ctrl_event(struct classic_ctrl_t *cc, unsigned char *msg) {
 int i; int lx; int ly; int rx; int ry;
 unsigned char l; unsigned char r;
 for (i = 0; i < 6; ++i)
  msg[i] = (msg[i] ^ 0x17) + 0x17;
 classic_ctrl_pressed_buttons(cc, (htons(*(short *)(msg + 4))));
 l = (((msg[2] & 0x60) >> 2) | ((msg[3] & 0xE0) >> 5));
 r = (msg[3] & 0x1F);
 cc->r_shoulder = ((float)r / 0x1F);
 cc->l_shoulder = ((float)l / 0x1F);
 lx = (msg[0] & 0x3F);
 ly = (msg[1] & 0x3F);
 rx = ((msg[0] & 0xC0) >> 3) | ((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7);
 ry = (msg[2] & 0x1F);
 calc_joystick_state(&cc->ljs, lx, ly);
 calc_joystick_state(&cc->rjs, rx, ry);
}

variable_types: lx int

variable_types: ly int

variable_types: rx int

variable_types: ry int

variable_types:
l
unsigned char

variable_types:
r
unsigned char


threadRoutine

repo: sergforce/iscsi

decompiled_code:
__int64 __fastcall threadRoutine(void *a1)
{
pthread_t v1; // rax

v1 = pthread_self();
pthread_detach(v1);
return (int)doClient2((unsigned int)a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(void *a1)
{
pthread_t v1; // rax

v1 = pthread_self();
pthread_detach(v1);
return (int)doClient2((unsigned int)a1);
}

original_code:
void *threadRoutine(void *arg)
{
 int sockfd = (intptr_t)arg;
 pthread_detach(pthread_self());
 return (void *)(intptr_t)doClient2(sockfd);
}

canonical_original_code:
void *threadRoutine(void *arg)
{
 int sockfd = (intptr_t)arg;
 pthread_detach(pthread_self());
 return (void *)(long)doClient2(sockfd);
}

variable_types:
arg
void *

variable_types: sockfd int

return_type: void *


createNewClientThread

decompiled_code:
int __fastcall createNewClientThread(int a1)
{
pthread_t newthread[2]; // [rsp+8h] [rbp-10h] BYREF

return pthread_create(newthread, 0LL, (void *(*)(void *))threadRoutine, (void *)a1);
}

canonical_decompiled_code:
int __fastcall func1(int a1)
{
pthread_t newthread[2]; // [rsp+8h] [rbp-10h] BYREF

return pthread_create(newthread, 0LL, (void *(*)(void *))threadRoutine, (void *)a1);
}

original_code:
int createNewClientThread(SOCKET scli)
{
 pthread_t tid;
 return pthread_create(&tid, ((void *)0), threadRoutine, (void *)(intptr_t)scli);
}

canonical_original_code:
int createNewClientThread(int scli)
{
 unsigned long tid;
 return pthread_create(&tid, ((void *)0), threadRoutine, (void *)(long)scli);
}

variable_types: scli int

variable_types:
tid
unsigned long


initWorldMutex

decompiled_code:
int __fastcall initWorldMutex(__int64 a1)
{
return pthread_mutex_init((pthread_mutex_t *)(a1 + 16), 0LL);
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
return pthread_mutex_init((pthread_mutex_t *)(a1 + 16), 0LL);
}

original_code:
void initWorldMutex(struct World *world)
{
 pthread_mutex_init(&world->platformData.mutex, ((void *)0));
}

variable_types: struct World { struct Session { struct DCirList { struct DCirList *next; struct DCirList *prev; } list; struct ISID_TSIH { unsigned int C; unsigned int B; unsigned int TA; unsigned short tsih; unsigned short D; } sessionID; struct InetConnection { struct DCirList list; struct Session *member; struct World *world; unsigned int connectionID; unsigned int currentITT; int scli; int currentStage; struct Counter { unsigned int count; unsigned int mask; } recvStatSN; unsigned int statSN; struct ResponseTask { struct DCirList list; unsigned int statSN; unsigned int targetTransferTag; unsigned int refITT; unsigned long lun; unsigned int iFlags; struct PDUList { struct DCirList list; struct PDU { struct { struct bhsBase { unsigned char cmd; unsigned char flags; unsigned char res[2]; unsigned char totalAHSLength; struct uint24 { unsigned char b[3]; } dataSegmentLength; unsigned int lun[2]; unsigned int initiatorTaskTag; unsigned int reserved[7]; } bhs; union { unsigned int headerDigest; struct AHS { unsigned char AHSSpecific; unsigned char AHSType; unsigned short AHSLength; unsigned int ahsData[1]; } ahs; }; unsigned int headerDigestWAHS; struct AHS *next; }; unsigned int dataSegmentLength; union { unsigned int *dataDigest; struct Buffer { struct DCirList list; struct BufferAllocator { struct DCirList list; struct Buffer *buffFree; struct Buffer *buffUsed; unsigned int useds; unsigned int frees; struct BufferAllocator *parnetAllocator; int (*parentLock)(struct BufferAllocator *parentAlloc); int (*parentFree)(struct BufferAllocator *parentAlloc); struct AllocParam { unsigned int maxLength; unsigned char nIncrease; unsigned char nDecrease; unsigned char nIntialCount; unsigned char policy; } ap; } *belong; unsigned int maxLength; unsigned int length; unsigned char _data[-1]; unsigned char data[1]; } *dataSeg; }; unsigned char *data; } pdu; } *pdus; struct R2T { struct DCirList list; unsigned int r2tSN; struct Buffer *wBuffer; } r2t; struct Counter dataSN; struct Task { struct DCirList list; unsigned int cmdSN; unsigned int initiatorTaskTag; unsigned long lun; unsigned int nPDU; struct PDUList *pdus; struct Buffer *dataSegment; struct Counter unsolDataSN; unsigned int dataSNr2tSN; struct R2T *r2tRes; struct ResponseTask *intialRes; unsigned int immediate; unsigned int nR2t; struct tfCommand { int cmd; int stage; unsigned long lun; unsigned char *cdbBytes; unsigned int cdbLen; unsigned int residualReadCount; unsigned int writeCount; unsigned int readedCount; unsigned int writedCount; struct Buffer *readBuffer; struct Buffer *imWriteBuffer; struct R2T *writeBuffs; unsigned char response; unsigned char status; unsigned char readUnOv; unsigned char writeUnOv; unsigned char extra[256]; unsigned short senseLen; unsigned char sense[64]; struct Session *ses; void *targetHandle; void *classHandle; } cmd; } *origTask; struct ResponseTask *ackTasks; struct Buffer *dataSegment; } *sending; struct PDUList *sendedPDUs; struct PDUList *pending; struct PDUList *wpending; struct Task *pndTask; unsigned int targetMaxRcvDataSegment; int headerDigest; int dataDigest; unsigned int initiatorMaxRcvDataSegment; unsigned int headerSize; struct ReadWriteOP { int stage; unsigned int expectedLen; unsigned int perfomedLen; unsigned char *buffer; unsigned int dataCRC; } readOP; struct ReadWriteOP writeOP; int sockNeedToWrite; struct Param { union { int ivalue; char *tvalue; }; union { int avalue; void *pvalue; }; } *params; } *connections; int nConnections; unsigned int errorRecoveryLevel; unsigned int intialR2T; unsigned int immediateData; void *tfHandle; struct Param *params; struct Counter cmdSN; struct Task *notAllRecived; struct Task *tasks; struct Task *immediateTasks; struct Task *freeTasks; struct Task *perfTasks; struct Task *perfImTasks; struct PDUList *freePDUs; struct ResponseTask *freeResTasks; struct ResponseTask *resTasks; struct ResponseTask *sended; unsigned int minMaxRcvDataSegment; unsigned int nFreeTasks; unsigned int nFreeResTasks; unsigned int nFreePDUs; struct BufferAllocator buffAlloc[16]; struct Task taskPool[64]; struct ResponseTask resp[64]; struct PDUList pdus[128]; unsigned int targetTaskTag; unsigned int unAckSize; struct tfClass { char *className; void *handle; void *(*tfInit)(); void (*tfCleanup)(void *handle); void *(*tfAttach)(void *handle, struct Session *ses); void (*tfDetach)(void *handle, void *attachedHandle); int (*tfSCSICommand)(struct tfCommand *cmd); int (*tfSCSIManagement)(struct tfManagement { void *handle; void *attachedHandle; int manFunction; struct tfCommand *ref_cmd; unsigned long lun; struct Session *ses; } *tfmc); char *(*tfGetModuleInfo)(int what); unsigned int flags; int (*tfSetPollingDes)(struct Session *ses); int (*tfCheckPollingDes)(struct Session *ses); } cclass; unsigned int pendingCommands; int maxfd; struct fd_set { long __fds_bits[-1]; } rop; struct fd_set wop; int connChanged; long bytes_read; long bytes_write; long pdus_sent; long pdus_recv; } *sesions; unsigned int nSessions; unsigned int nTotalConnections; struct _spec_world_linux { union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; } platformData; struct confElement { struct confElemList { struct confElement *next; struct confElement *prev; } list; struct confElement *parent; struct confElement *childs; int cbName; int cbValue; char name[110]; char value[120]; } *trgs; struct configuration { struct confElement *head; struct confElement *free; struct confElement pool[128]; } cnf; struct BufferAllocator buffAlloc[2]; int nApis; struct tfClass apis[4]; } *

user_defined_types: struct World { struct Session *sesions; unsigned int nSessions; unsigned int nTotalConnections; struct _spec_world_linux platformData; struct confElement *trgs; struct configuration cnf; struct BufferAllocator buffAlloc[2]; int nApis; struct tfClass apis[4]; }

user_defined_types: struct _spec_world_linux { union pthread_mutex_t mutex; }

user_defined_types: struct Session { struct DCirList list; struct ISID_TSIH sessionID; struct InetConnection *connections; int nConnections; unsigned int errorRecoveryLevel; unsigned int intialR2T; unsigned int immediateData; void *tfHandle; struct Param *params; struct Counter cmdSN; struct Task *notAllRecived; struct Task *tasks; struct Task *immediateTasks; struct Task *freeTasks; struct Task *perfTasks; struct Task *perfImTasks; struct PDUList *freePDUs; struct ResponseTask *freeResTasks; struct ResponseTask *resTasks; struct ResponseTask *sended; unsigned int minMaxRcvDataSegment; unsigned int nFreeTasks; unsigned int nFreeResTasks; unsigned int nFreePDUs; struct BufferAllocator buffAlloc[16]; struct Task taskPool[64]; struct ResponseTask resp[64]; struct PDUList pdus[128]; unsigned int targetTaskTag; unsigned int unAckSize; struct tfClass cclass; unsigned int pendingCommands; int maxfd; struct fd_set rop; struct fd_set wop; int connChanged; long bytes_read; long bytes_write; long pdus_sent; long pdus_recv; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct confElement { struct confElemList list; struct confElement *parent; struct confElement *childs; int cbName; int cbValue; char name[110]; char value[120]; }

user_defined_types: struct tfClass { char *className; void *handle; void *(*tfInit)(); void (*tfCleanup)(void *handle); void *(*tfAttach)(void *handle, struct Session *ses); void (*tfDetach)(void *handle, void *attachedHandle); int (*tfSCSICommand)(struct tfCommand *cmd); int (*tfSCSIManagement)(struct tfManagement *tfmc); char *(*tfGetModuleInfo)(int what); unsigned int flags; int (*tfSetPollingDes)(struct Session *ses); int (*tfCheckPollingDes)(struct Session *ses); }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }

user_defined_types: struct InetConnection { struct DCirList list; struct Session *member; struct World *world; unsigned int connectionID; unsigned int currentITT; int scli; int currentStage; struct Counter recvStatSN; unsigned int statSN; struct ResponseTask *sending; struct PDUList *sendedPDUs; struct PDUList *pending; struct PDUList *wpending; struct Task *pndTask; unsigned int targetMaxRcvDataSegment; int headerDigest; int dataDigest; unsigned int initiatorMaxRcvDataSegment; unsigned int headerSize; struct ReadWriteOP readOP; struct ReadWriteOP writeOP; int sockNeedToWrite; struct Param *params; }

user_defined_types: struct ResponseTask { struct DCirList list; unsigned int statSN; unsigned int targetTransferTag; unsigned int refITT; unsigned long lun; unsigned int iFlags; struct PDUList *pdus; struct R2T r2t; struct Counter dataSN; struct Task *origTask; struct ResponseTask *ackTasks; struct Buffer *dataSegment; }

user_defined_types: struct PDUList { struct DCirList list; struct PDU pdu; }

user_defined_types: struct Task { struct DCirList list; unsigned int cmdSN; unsigned int initiatorTaskTag; unsigned long lun; unsigned int nPDU; struct PDUList *pdus; struct Buffer *dataSegment; struct Counter unsolDataSN; unsigned int dataSNr2tSN; struct R2T *r2tRes; struct ResponseTask *intialRes; unsigned int immediate; unsigned int nR2t; struct tfCommand cmd; }

user_defined_types: struct PDU { struct { struct bhsBase bhs; union { unsigned int headerDigest; struct AHS ahs; }; unsigned int headerDigestWAHS; struct AHS *next; }; unsigned int dataSegmentLength; union { unsigned int *dataDigest; struct Buffer *dataSeg; }; unsigned char *data; }

user_defined_types: struct bhsBase { unsigned char cmd; unsigned char flags; unsigned char res[2]; unsigned char totalAHSLength; struct uint24 dataSegmentLength; unsigned int lun[2]; unsigned int initiatorTaskTag; unsigned int reserved[7]; }

user_defined_types: struct Buffer { struct DCirList list; struct BufferAllocator *belong; unsigned int maxLength; unsigned int length; unsigned char _data[-1]; unsigned char data[1]; }

user_defined_types: struct BufferAllocator { struct DCirList list; struct Buffer *buffFree; struct Buffer *buffUsed; unsigned int useds; unsigned int frees; struct BufferAllocator *parnetAllocator; int (*parentLock)(struct BufferAllocator *parentAlloc); int (*parentFree)(struct BufferAllocator *parentAlloc); struct AllocParam ap; }


lockWorld

decompiled_code:
__int64 __fastcall lockWorld(__int64 a1)
{
pthread_mutex_lock((pthread_mutex_t *)(a1 + 16));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
pthread_mutex_lock((pthread_mutex_t *)(a1 + 16));
return 0LL;
}

original_code:
int lockWorld(struct World *world)
{
 pthread_mutex_lock(&world->platformData.mutex);
 return 0;
}

user_defined_types: struct configuration { struct confElement *head; struct confElement *free; struct confElement pool[128]; }

user_defined_types: struct DCirList { struct DCirList *next; struct DCirList *prev; }

user_defined_types: struct ISID_TSIH { unsigned int C; unsigned int B; unsigned int TA; unsigned short tsih; unsigned short D; }

user_defined_types: struct confElemList { struct confElement *next; struct confElement *prev; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }

user_defined_types: struct Counter { unsigned int count; unsigned int mask; }

user_defined_types: struct ReadWriteOP { int stage; unsigned int expectedLen; unsigned int perfomedLen; unsigned char *buffer; unsigned int dataCRC; }

user_defined_types: struct Param { union { int ivalue; char *tvalue; }; union { int avalue; void *pvalue; }; }

user_defined_types: struct R2T { struct DCirList list; unsigned int r2tSN; struct Buffer *wBuffer; }

user_defined_types: struct tfManagement { void *handle; void *attachedHandle; int manFunction; struct tfCommand *ref_cmd; unsigned long lun; struct Session *ses; }

user_defined_types: struct tfCommand { int cmd; int stage; unsigned long lun; unsigned char *cdbBytes; unsigned int cdbLen; unsigned int residualReadCount; unsigned int writeCount; unsigned int readedCount; unsigned int writedCount; struct Buffer *readBuffer; struct Buffer *imWriteBuffer; struct R2T *writeBuffs; unsigned char response; unsigned char status; unsigned char readUnOv; unsigned char writeUnOv; unsigned char extra[256]; unsigned short senseLen; unsigned char sense[64]; struct Session *ses; void *targetHandle; void *classHandle; }

user_defined_types: struct AHS { unsigned char AHSSpecific; unsigned char AHSType; unsigned short AHSLength; unsigned int ahsData[1]; }

user_defined_types: struct AllocParam { unsigned int maxLength; unsigned char nIncrease; unsigned char nDecrease; unsigned char nIntialCount; unsigned char policy; }


releaseWorld

decompiled_code:
__int64 __fastcall releaseWorld(__int64 a1)
{
pthread_mutex_unlock((pthread_mutex_t *)(a1 + 16));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
pthread_mutex_unlock((pthread_mutex_t *)(a1 + 16));
return 0LL;
}

original_code:
int releaseWorld(struct World *world)
{
 pthread_mutex_unlock(&world->platformData.mutex);
 return 0;
}

user_defined_types: struct World { struct Session *sesions; unsigned int nSessions; unsigned int nTotalConnections; struct _spec_world_linux platformData; struct confElement *trgs; struct configuration cnf; struct BufferAllocator buffAlloc[2]; int nApis; struct tfClass apis[4]; }

user_defined_types: struct _spec_world_linux { union pthread_mutex_t mutex; }

user_defined_types: struct Session { struct DCirList list; struct ISID_TSIH sessionID; struct InetConnection *connections; int nConnections; unsigned int errorRecoveryLevel; unsigned int intialR2T; unsigned int immediateData; void *tfHandle; struct Param *params; struct Counter cmdSN; struct Task *notAllRecived; struct Task *tasks; struct Task *immediateTasks; struct Task *freeTasks; struct Task *perfTasks; struct Task *perfImTasks; struct PDUList *freePDUs; struct ResponseTask *freeResTasks; struct ResponseTask *resTasks; struct ResponseTask *sended; unsigned int minMaxRcvDataSegment; unsigned int nFreeTasks; unsigned int nFreeResTasks; unsigned int nFreePDUs; struct BufferAllocator buffAlloc[16]; struct Task taskPool[64]; struct ResponseTask resp[64]; struct PDUList pdus[128]; unsigned int targetTaskTag; unsigned int unAckSize; struct tfClass cclass; unsigned int pendingCommands; int maxfd; struct fd_set rop; struct fd_set wop; int connChanged; long bytes_read; long bytes_write; long pdus_sent; long pdus_recv; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct confElement { struct confElemList list; struct confElement *parent; struct confElement *childs; int cbName; int cbValue; char name[110]; char value[120]; }

user_defined_types: struct tfClass { char *className; void *handle; void *(*tfInit)(); void (*tfCleanup)(void *handle); void *(*tfAttach)(void *handle, struct Session *ses); void (*tfDetach)(void *handle, void *attachedHandle); int (*tfSCSICommand)(struct tfCommand *cmd); int (*tfSCSIManagement)(struct tfManagement *tfmc); char *(*tfGetModuleInfo)(int what); unsigned int flags; int (*tfSetPollingDes)(struct Session *ses); int (*tfCheckPollingDes)(struct Session *ses); }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }

user_defined_types: struct InetConnection { struct DCirList list; struct Session *member; struct World *world; unsigned int connectionID; unsigned int currentITT; int scli; int currentStage; struct Counter recvStatSN; unsigned int statSN; struct ResponseTask *sending; struct PDUList *sendedPDUs; struct PDUList *pending; struct PDUList *wpending; struct Task *pndTask; unsigned int targetMaxRcvDataSegment; int headerDigest; int dataDigest; unsigned int initiatorMaxRcvDataSegment; unsigned int headerSize; struct ReadWriteOP readOP; struct ReadWriteOP writeOP; int sockNeedToWrite; struct Param *params; }

user_defined_types: struct ResponseTask { struct DCirList list; unsigned int statSN; unsigned int targetTransferTag; unsigned int refITT; unsigned long lun; unsigned int iFlags; struct PDUList *pdus; struct R2T r2t; struct Counter dataSN; struct Task *origTask; struct ResponseTask *ackTasks; struct Buffer *dataSegment; }

user_defined_types: struct PDUList { struct DCirList list; struct PDU pdu; }

user_defined_types: struct Task { struct DCirList list; unsigned int cmdSN; unsigned int initiatorTaskTag; unsigned long lun; unsigned int nPDU; struct PDUList *pdus; struct Buffer *dataSegment; struct Counter unsolDataSN; unsigned int dataSNr2tSN; struct R2T *r2tRes; struct ResponseTask *intialRes; unsigned int immediate; unsigned int nR2t; struct tfCommand cmd; }

user_defined_types: struct PDU { struct { struct bhsBase bhs; union { unsigned int headerDigest; struct AHS ahs; }; unsigned int headerDigestWAHS; struct AHS *next; }; unsigned int dataSegmentLength; union { unsigned int *dataDigest; struct Buffer *dataSeg; }; unsigned char *data; }


freeWorldMutex

decompiled_code:
void freeWorldMutex()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void freeWorldMutex(struct World *world)
{
}

user_defined_types: struct configuration { struct confElement *head; struct confElement *free; struct confElement pool[128]; }

user_defined_types: struct DCirList { struct DCirList *next; struct DCirList *prev; }

user_defined_types: struct ISID_TSIH { unsigned int C; unsigned int B; unsigned int TA; unsigned short tsih; unsigned short D; }

user_defined_types: struct confElemList { struct confElement *next; struct confElement *prev; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }

user_defined_types: struct Counter { unsigned int count; unsigned int mask; }

user_defined_types: struct ReadWriteOP { int stage; unsigned int expectedLen; unsigned int perfomedLen; unsigned char *buffer; unsigned int dataCRC; }

user_defined_types: struct Param { union { int ivalue; char *tvalue; }; union { int avalue; void *pvalue; }; }

user_defined_types: struct R2T { struct DCirList list; unsigned int r2tSN; struct Buffer *wBuffer; }

user_defined_types: struct bhsBase { unsigned char cmd; unsigned char flags; unsigned char res[2]; unsigned char totalAHSLength; struct uint24 dataSegmentLength; unsigned int lun[2]; unsigned int initiatorTaskTag; unsigned int reserved[7]; }

user_defined_types: struct Buffer { struct DCirList list; struct BufferAllocator *belong; unsigned int maxLength; unsigned int length; unsigned char _data[-1]; unsigned char data[1]; }

user_defined_types: struct BufferAllocator { struct DCirList list; struct Buffer *buffFree; struct Buffer *buffUsed; unsigned int useds; unsigned int frees; struct BufferAllocator *parnetAllocator; int (*parentLock)(struct BufferAllocator *parentAlloc); int (*parentFree)(struct BufferAllocator *parentAlloc); struct AllocParam ap; }


beginigAcceptConnections

decompiled_code:
__int64 beginigAcceptConnections()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func6()
{
return 0LL;
}

original_code:
int beginigAcceptConnections(struct World *world)
{
 return 0;
}

user_defined_types: struct World { struct Session *sesions; unsigned int nSessions; unsigned int nTotalConnections; struct _spec_world_linux platformData; struct confElement *trgs; struct configuration cnf; struct BufferAllocator buffAlloc[2]; int nApis; struct tfClass apis[4]; }

user_defined_types: struct _spec_world_linux { union pthread_mutex_t mutex; }

user_defined_types: struct Session { struct DCirList list; struct ISID_TSIH sessionID; struct InetConnection *connections; int nConnections; unsigned int errorRecoveryLevel; unsigned int intialR2T; unsigned int immediateData; void *tfHandle; struct Param *params; struct Counter cmdSN; struct Task *notAllRecived; struct Task *tasks; struct Task *immediateTasks; struct Task *freeTasks; struct Task *perfTasks; struct Task *perfImTasks; struct PDUList *freePDUs; struct ResponseTask *freeResTasks; struct ResponseTask *resTasks; struct ResponseTask *sended; unsigned int minMaxRcvDataSegment; unsigned int nFreeTasks; unsigned int nFreeResTasks; unsigned int nFreePDUs; struct BufferAllocator buffAlloc[16]; struct Task taskPool[64]; struct ResponseTask resp[64]; struct PDUList pdus[128]; unsigned int targetTaskTag; unsigned int unAckSize; struct tfClass cclass; unsigned int pendingCommands; int maxfd; struct fd_set rop; struct fd_set wop; int connChanged; long bytes_read; long bytes_write; long pdus_sent; long pdus_recv; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct confElement { struct confElemList list; struct confElement *parent; struct confElement *childs; int cbName; int cbValue; char name[110]; char value[120]; }

user_defined_types: struct tfClass { char *className; void *handle; void *(*tfInit)(); void (*tfCleanup)(void *handle); void *(*tfAttach)(void *handle, struct Session *ses); void (*tfDetach)(void *handle, void *attachedHandle); int (*tfSCSICommand)(struct tfCommand *cmd); int (*tfSCSIManagement)(struct tfManagement *tfmc); char *(*tfGetModuleInfo)(int what); unsigned int flags; int (*tfSetPollingDes)(struct Session *ses); int (*tfCheckPollingDes)(struct Session *ses); }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }

user_defined_types: struct InetConnection { struct DCirList list; struct Session *member; struct World *world; unsigned int connectionID; unsigned int currentITT; int scli; int currentStage; struct Counter recvStatSN; unsigned int statSN; struct ResponseTask *sending; struct PDUList *sendedPDUs; struct PDUList *pending; struct PDUList *wpending; struct Task *pndTask; unsigned int targetMaxRcvDataSegment; int headerDigest; int dataDigest; unsigned int initiatorMaxRcvDataSegment; unsigned int headerSize; struct ReadWriteOP readOP; struct ReadWriteOP writeOP; int sockNeedToWrite; struct Param *params; }

user_defined_types: struct tfManagement { void *handle; void *attachedHandle; int manFunction; struct tfCommand *ref_cmd; unsigned long lun; struct Session *ses; }

user_defined_types: struct tfCommand { int cmd; int stage; unsigned long lun; unsigned char *cdbBytes; unsigned int cdbLen; unsigned int residualReadCount; unsigned int writeCount; unsigned int readedCount; unsigned int writedCount; struct Buffer *readBuffer; struct Buffer *imWriteBuffer; struct R2T *writeBuffs; unsigned char response; unsigned char status; unsigned char readUnOv; unsigned char writeUnOv; unsigned char extra[256]; unsigned short senseLen; unsigned char sense[64]; struct Session *ses; void *targetHandle; void *classHandle; }

user_defined_types: struct AHS { unsigned char AHSSpecific; unsigned char AHSType; unsigned short AHSLength; unsigned int ahsData[1]; }

user_defined_types: struct AllocParam { unsigned int maxLength; unsigned char nIncrease; unsigned char nDecrease; unsigned char nIntialCount; unsigned char policy; }


initConfiguration

decompiled_code:
__int64 __fastcall initConfiguration(__int64 a1)
{
return initConfigurationFromINI(a1, &inifile);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return initConfigurationFromINI(a1, &inifile);
}

original_code:
int initConfiguration(struct configuration *cnf)
{
 return initConfigurationFromINI(cnf, inifile);
}

variable_types: struct configuration { struct confElement { struct confElemList { struct confElement *next; struct confElement *prev; } list; struct confElement *parent; struct confElement *childs; int cbName; int cbValue; char name[110]; char value[120]; } *head; struct confElement *free; struct confElement pool[128]; } *

user_defined_types: struct configuration { struct confElement *head; struct confElement *free; struct confElement pool[128]; }