decompiled_code:
char *enemies_update_move_delay()
{
char *result; // rax
char v1; // di
int v2; // ecx
int v3; // xmm1_4

result = (char *)enemies;
v1 = 0;
v2 = 0;
enemiesAlive = 0;
do
{
if ( !*(_DWORD *)(*(_QWORD *)result + 48LL) )
{
++v2;
v1 = 1;
}
result += 8;
}
while ( result != (char *)enemies + 240 );
v3 = LC9;
if ( v1 )
{
enemiesAlive = v2;
*(float *)&v3 = (float)((float)((float)v2 / 30.0) * 1.475) + 0.025;
}
moveDelay = v3;
return result;
}

canonical_decompiled_code:
char *func5()
{
char *result; // rax
char v1; // di
int v2; // ecx
int v3; // xmm1_4

result = (char *)enemies;
v1 = 0;
v2 = 0;
enemiesAlive = 0;
do
{
if ( !*(_DWORD *)(*(_QWORD *)result + 48LL) )
{
++v2;
v1 = 1;
}
result += 8;
}
while ( result != (char *)enemies + 240 );
v3 = LC9;
if ( v1 )
{
enemiesAlive = v2;
*(float *)&v3 = (float)((float)((float)v2 / 30.0) * 1.475) + 0.025;
}
moveDelay = v3;
return result;
}

original_code:
void enemies_update_move_delay()
{
 enemiesAlive = 0;
 for (int i = 0; i < MAX_ENEMIES; ++i) {
  if (!enemies[i]->dead) {
   enemiesAlive++;
  }
 }
 moveDelay = MIN_MOVE_DELAY + (MAX_MOVE_DELAY - MIN_MOVE_DELAY) * ((float)enemiesAlive / (float)MAX_ENEMIES);
}

variable_types: i int


repo: tedajax/vaders

decompiled_code:
void *enemies_update()
{
__int64 i; // rbx
void *result; // rax
__int64 v2; // rdi
double v3; // xmm0_8

for ( i = 0LL; i != 240; i += 8LL )
{
while ( 1 )
{
result = enemies;
v2 = *(_QWORD *)((char *)enemies + i);
if ( v2 )
{
result = (void *)*(unsigned int *)(v2 + 48);
if ( !(_DWORD)result )
break;
}
i += 8LL;
if ( i == 240 )
goto LABEL_6;
}
result = enemy_update(v2);
}
LABEL_6:
*(float *)&moveDelayTimer = *(float *)&moveDelayTimer - globals[14];
if ( *(float *)&moveDelayTimer <= 0.0 )
{
moveDelayTimer = moveDelay;
v3 = enemies_calc_move();
result = enemies_move(v3);
}
return result;
}

canonical_decompiled_code:
void *func8()
{
__int64 i; // rbx
void *result; // rax
__int64 v2; // rdi
double v3; // xmm0_8

for ( i = 0LL; i != 240; i += 8LL )
{
while ( 1 )
{
result = enemies;
v2 = *(_QWORD *)((char *)enemies + i);
if ( v2 )
{
result = (void *)*(unsigned int *)(v2 + 48);
if ( !(_DWORD)result )
break;
}
i += 8LL;
if ( i == 240 )
goto LABEL_6;
}
result = func7(v2);
}
LABEL_6:
*(float *)&moveDelayTimer = *(float *)&moveDelayTimer - globals[14];
if ( *(float *)&moveDelayTimer <= 0.0 )
{
moveDelayTimer = moveDelay;
v3 = func2();
result = func4(v3);
}
return result;
}

original_code:
void enemies_update()
{
 for (int i = 0; i < MAX_ENEMIES; ++i) {
  if (enemies[i] && !enemies[i]->dead) {
   enemy_update(enemies[i]);
  }
 }
 moveDelayTimer -= globals.time.deltaf;
 if (moveDelayTimer <= 0.0f) {
  moveDelayTimer = moveDelay;
  enemies_move(enemies_calc_move());
 }
}

return_type: void


decompiled_code:
__int64 enemies_draw()
{
__int64 i; // rbx
__int64 result; // rax
__int64 v2; // rdi

for ( i = 0LL; i != 240; i += 8LL )
{
while ( 1 )
{
result = (__int64)enemies;
v2 = *(_QWORD *)((char *)enemies + i);
if ( v2 )
{
result = *(unsigned int *)(v2 + 48);
if ( !(_DWORD)result )
break;
}
i += 8LL;
if ( i == 240 )
return result;
}
result = enemy_draw(v2);
}
return result;
}

canonical_decompiled_code:
__int64 func11()
{
__int64 i; // rbx
__int64 result; // rax
__int64 v2; // rdi

for ( i = 0LL; i != 240; i += 8LL )
{
while ( 1 )
{
result = (__int64)enemies;
v2 = *(_QWORD *)((char *)enemies + i);
if ( v2 )
{
result = *(unsigned int *)(v2 + 48);
if ( !(_DWORD)result )
break;
}
i += 8LL;
if ( i == 240 )
return result;
}
result = func1(v2);
}
return result;
}

original_code:
void enemies_draw()
{
 int i = 0;
 for (i = 0; i < MAX_ENEMIES; ++i) {
  if (enemies[i] && !enemies[i]->dead) {
   enemy_draw(enemies[i]);
  }
 }
}


decompiled_code:
void enemies_cleanup()
{
char *v0; // r8
__int64 i; // rbx
void *v2; // rdi

v0 = (char *)enemies;
for ( i = 0LL; i != 240; i += 8LL )
{
v2 = *(void **)&v0[i];
if ( v2 )
{
free(v2);
v0 = (char *)enemies;
*(_QWORD *)((char *)enemies + i) = 0LL;
}
}
free(v0);
}

canonical_decompiled_code:
void func12()
{
char *v0; // r8
__int64 i; // rbx
void *v2; // rdi

v0 = (char *)enemies;
for ( i = 0LL; i != 240; i += 8LL )
{
v2 = *(void **)&v0[i];
if ( v2 )
{
free(v2);
v0 = (char *)enemies;
*(_QWORD *)((char *)enemies + i) = 0LL;
}
}
free(v0);
}

original_code:
void enemies_cleanup()
{
 for (int i = 0; i < MAX_ENEMIES; ++i) {
  if (enemies[i]) {
   free(enemies[i]);
   enemies[i] = ((void *)0);
  }
 }
 free(enemies);
}


init

decompiled_code:
__int64 init()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax

if ( (unsigned int)SDL_Init(0xFFFFLL) == -1 )
return 0LL;
init_globals();
SDL_SetVideoMode(globals, *((unsigned int *)&globals + 1), *((unsigned int *)&globals + 2), 1LL);
v0 = SDL_GetVideoSurface();
*((_QWORD *)&globals + 2) = v0;
if ( !v0 )
return 0LL;
SDL_WM_SetCaption("Vaders", 0LL);
input_init();
init_image_assets();
v1 = load_image("assets/tank.png");
push_image_asset("tank", v1);
v2 = load_image("assets/bullet.png");
push_image_asset("bullet", v2);
v3 = load_image("assets/enemy.png");
push_image_asset("enemy1", v3);
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax

if ( (unsigned int)SDL_Init(0xFFFFLL) == -1 )
return 0LL;
init_globals();
SDL_SetVideoMode(globals, *((unsigned int *)&globals + 1), *((unsigned int *)&globals + 2), 1LL);
v0 = SDL_GetVideoSurface();
*((_QWORD *)&globals + 2) = v0;
if ( !v0 )
return 0LL;
SDL_WM_SetCaption("Vaders", 0LL);
input_init();
init_image_assets();
v1 = load_image("assets/tank.png");
push_image_asset("tank", v1);
v2 = load_image("assets/bullet.png");
push_image_asset("bullet", v2);
v3 = load_image("assets/enemy.png");
push_image_asset("enemy1", v3);
return 1LL;
}

original_code:
int init()
{
 if (SDL_Init(0x0000FFFF) == -1)
  return 0;
 init_globals();
 SDL_SetVideoMode(globals.window.width,
      globals.window.height,
      globals.window.bpp,
      0x00000001);
 globals.screen = SDL_GetVideoSurface();
 if (globals.screen == ((void *)0)) {
  return 0;
 }
 SDL_WM_SetCaption("Vaders", ((void *)0));
 input_init();
 init_image_assets();
 push_image_asset("tank", load_image("assets/tank.png"));
 push_image_asset("bullet", load_image("assets/bullet.png"));
 push_image_asset("enemy1", load_image("assets/enemy.png"));
 return 1;
}

return_type: int


cleanup

decompiled_code:
__int64 cleanup()
{
input_cleanup();
SDL_FreeSurface(globals[2]);
free_image_assets();
return SDL_Quit();
}

canonical_decompiled_code:
__int64 func1()
{
input_cleanup();
SDL_FreeSurface(globals[2]);
free_image_assets();
return SDL_Quit();
}

original_code:
void cleanup()
{
 input_cleanup();
 SDL_FreeSurface(globals.screen);
 free_image_assets();
 SDL_Quit();
}


update

decompiled_code:
__int64 update()
{
player_update(player);
enemies_update();
bullets_update();
return colliders_update();
}

canonical_decompiled_code:
__int64 func2()
{
player_update(player);
enemies_update();
bullets_update();
return colliders_update();
}

original_code:
void update()
{
 player_update(player);
 enemies_update();
 bullets_update();
 colliders_update();
}


draw

decompiled_code:
__int64 draw()
{
player_draw(player);
enemies_draw();
return bullets_draw();
}

canonical_decompiled_code:
__int64 func3()
{
player_draw(player);
enemies_draw();
return bullets_draw();
}

original_code:
void draw()
{
 player_draw(player);
 enemies_draw();
 bullets_draw();
}


decompiled_code:
__int64 input_init()
{
__int64 result; // rax

oldKeystates = malloc(0x50CuLL);
result = SDL_GetKeyState(0LL);
newKeystates = result;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

oldKeystates = malloc(0x50CuLL);
result = SDL_GetKeyState(0LL);
newKeystates = result;
return result;
}

original_code:
void input_init()
{
 oldKeystates = (Uint8 *)malloc(sizeof(SDLKey) * SDLK_LAST);
 newKeystates = SDL_GetKeyState(((void *)0));
}

canonical_original_code:
void input_init()
{
 oldKeystates = (unsigned char *)malloc(sizeof(SDLKey) * SDLK_LAST);
 newKeystates = SDL_GetKeyState(((void *)0));
}


decompiled_code:
void input_cleanup()
{
free(oldKeystates);
}

canonical_decompiled_code:
void func1()
{
free(oldKeystates);
}


decompiled_code:
__int64 input_update()
{
__int64 result; // rax

for ( result = 0LL; result != 323; ++result )
*((_BYTE *)oldKeystates + result) = *(_BYTE *)(newKeystates + result);
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax

for ( result = 0LL; result != 323; ++result )
*((_BYTE *)oldKeystates + result) = *(_BYTE *)(newKeystates + result);
return result;
}

original_code:
void input_update()
{
 int i;
 for (i = 0; i < SDLK_LAST; i++)
  oldKeystates[i] = newKeystates[i];
}


decompiled_code:
__int64 __fastcall input_get_key(unsigned int a1)
{
return *(unsigned __int8 *)(newKeystates + a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
return *(unsigned __int8 *)(newKeystates + a1);
}

original_code:
int input_get_key(SDLKey key)
{
 return newKeystates[key];
}

canonical_original_code:
int input_get_key(enum SDLKey key)
{
 return newKeystates[key];
}

variable_types: enum SDLKey { SDLK_UNKNOWN=0, SDLK_FIRST=0, SDLK_BACKSPACE=8, SDLK_TAB=9, SDLK_CLEAR=12, SDLK_RETURN=13, SDLK_PAUSE=19, SDLK_ESCAPE=27, SDLK_SPACE=32, SDLK_EXCLAIM=33, SDLK_QUOTEDBL=34, SDLK_HASH=35, SDLK_DOLLAR=36, SDLK_AMPERSAND=38, SDLK_QUOTE=39, SDLK_LEFTPAREN=40, SDLK_RIGHTPAREN=41, SDLK_ASTERISK=42, SDLK_PLUS=43, SDLK_COMMA=44, SDLK_MINUS=45, SDLK_PERIOD=46, SDLK_SLASH=47, SDLK_0=48, SDLK_1=49, SDLK_2=50, SDLK_3=51, SDLK_4=52, SDLK_5=53, SDLK_6=54, SDLK_7=55, SDLK_8=56, SDLK_9=57, SDLK_COLON=58, SDLK_SEMICOLON=59, SDLK_LESS=60, SDLK_EQUALS=61, SDLK_GREATER=62, SDLK_QUESTION=63, SDLK_AT=64, SDLK_LEFTBRACKET=91, SDLK_BACKSLASH=92, SDLK_RIGHTBRACKET=93, SDLK_CARET=94, SDLK_UNDERSCORE=95, SDLK_BACKQUOTE=96, SDLK_a=97, SDLK_b=98, SDLK_c=99, SDLK_d=100, SDLK_e=101, SDLK_f=102, SDLK_g=103, SDLK_h=104, SDLK_i=105, SDLK_j=106, SDLK_k=107, SDLK_l=108, SDLK_m=109, SDLK_n=110, SDLK_o=111, SDLK_p=112, SDLK_q=113, SDLK_r=114, SDLK_s=115, SDLK_t=116, SDLK_u=117, SDLK_v=118, SDLK_w=119, SDLK_x=120, SDLK_y=121, SDLK_z=122, SDLK_DELETE=127, SDLK_WORLD_0=160, SDLK_WORLD_1=161, SDLK_WORLD_2=162, SDLK_WORLD_3=163, SDLK_WORLD_4=164, SDLK_WORLD_5=165, SDLK_WORLD_6=166, SDLK_WORLD_7=167, SDLK_WORLD_8=168, SDLK_WORLD_9=169, SDLK_WORLD_10=170, SDLK_WORLD_11=171, SDLK_WORLD_12=172, SDLK_WORLD_13=173, SDLK_WORLD_14=174, SDLK_WORLD_15=175, SDLK_WORLD_16=176, SDLK_WORLD_17=177, SDLK_WORLD_18=178, SDLK_WORLD_19=179, SDLK_WORLD_20=180, SDLK_WORLD_21=181, SDLK_WORLD_22=182, SDLK_WORLD_23=183, SDLK_WORLD_24=184, SDLK_WORLD_25=185, SDLK_WORLD_26=186, SDLK_WORLD_27=187, SDLK_WORLD_28=188, SDLK_WORLD_29=189, SDLK_WORLD_30=190, SDLK_WORLD_31=191, SDLK_WORLD_32=192, SDLK_WORLD_33=193, SDLK_WORLD_34=194, SDLK_WORLD_35=195, SDLK_WORLD_36=196, SDLK_WORLD_37=197, SDLK_WORLD_38=198, SDLK_WORLD_39=199, SDLK_WORLD_40=200, SDLK_WORLD_41=201, SDLK_WORLD_42=202, SDLK_WORLD_43=203, SDLK_WORLD_44=204, SDLK_WORLD_45=205, SDLK_WORLD_46=206, SDLK_WORLD_47=207, SDLK_WORLD_48=208, SDLK_WORLD_49=209, SDLK_WORLD_50=210, SDLK_WORLD_51=211, SDLK_WORLD_52=212, SDLK_WORLD_53=213, SDLK_WORLD_54=214, SDLK_WORLD_55=215, SDLK_WORLD_56=216, SDLK_WORLD_57=217, SDLK_WORLD_58=218, SDLK_WORLD_59=219, SDLK_WORLD_60=220, SDLK_WORLD_61=221, SDLK_WORLD_62=222, SDLK_WORLD_63=223, SDLK_WORLD_64=224, SDLK_WORLD_65=225, SDLK_WORLD_66=226, SDLK_WORLD_67=227, SDLK_WORLD_68=228, SDLK_WORLD_69=229, SDLK_WORLD_70=230, SDLK_WORLD_71=231, SDLK_WORLD_72=232, SDLK_WORLD_73=233, SDLK_WORLD_74=234, SDLK_WORLD_75=235, SDLK_WORLD_76=236, SDLK_WORLD_77=237, SDLK_WORLD_78=238, SDLK_WORLD_79=239, SDLK_WORLD_80=240, SDLK_WORLD_81=241, SDLK_WORLD_82=242, SDLK_WORLD_83=243, SDLK_WORLD_84=244, SDLK_WORLD_85=245, SDLK_WORLD_86=246, SDLK_WORLD_87=247, SDLK_WORLD_88=248, SDLK_WORLD_89=249, SDLK_WORLD_90=250, SDLK_WORLD_91=251, SDLK_WORLD_92=252, SDLK_WORLD_93=253, SDLK_WORLD_94=254, SDLK_WORLD_95=255, SDLK_KP0=256, SDLK_KP1=257, SDLK_KP2=258, SDLK_KP3=259, SDLK_KP4=260, SDLK_KP5=261, SDLK_KP6=262, SDLK_KP7=263, SDLK_KP8=264, SDLK_KP9=265, SDLK_KP_PERIOD=266, SDLK_KP_DIVIDE=267, SDLK_KP_MULTIPLY=268, SDLK_KP_MINUS=269, SDLK_KP_PLUS=270, SDLK_KP_ENTER=271, SDLK_KP_EQUALS=272, SDLK_UP=273, SDLK_DOWN=274, SDLK_RIGHT=275, SDLK_LEFT=276, SDLK_INSERT=277, SDLK_HOME=278, SDLK_END=279, SDLK_PAGEUP=280, SDLK_PAGEDOWN=281, SDLK_F1=282, SDLK_F2=283, SDLK_F3=284, SDLK_F4=285, SDLK_F5=286, SDLK_F6=287, SDLK_F7=288, SDLK_F8=289, SDLK_F9=290, SDLK_F10=291, SDLK_F11=292, SDLK_F12=293, SDLK_F13=294, SDLK_F14=295, SDLK_F15=296, SDLK_NUMLOCK=300, SDLK_CAPSLOCK=301, SDLK_SCROLLOCK=302, SDLK_RSHIFT=303, SDLK_LSHIFT=304, SDLK_RCTRL=305, SDLK_LCTRL=306, SDLK_RALT=307, SDLK_LALT=308, SDLK_RMETA=309, SDLK_LMETA=310, SDLK_LSUPER=311, SDLK_RSUPER=312, SDLK_MODE=313, SDLK_COMPOSE=314, SDLK_HELP=315, SDLK_PRINT=316, SDLK_SYSREQ=317, SDLK_BREAK=318, SDLK_MENU=319, SDLK_POWER=320, SDLK_EURO=321, SDLK_UNDO=322, SDLK_LAST=323 }


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

result = 0LL;
if ( *(_BYTE *)(newKeystates + a1) )
result = *((_BYTE *)oldKeystates + a1) == 0;
return result;
}

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

result = 0LL;
if ( *(_BYTE *)(newKeystates + a1) )
result = *((_BYTE *)oldKeystates + a1) == 0;
return result;
}

original_code:
int input_get_key_down(SDLKey key)
{
 return (newKeystates[key] && !oldKeystates[key]);
}

canonical_original_code:
int input_get_key_down(enum SDLKey key)
{
 return (newKeystates[key] && !oldKeystates[key]);
}

user_defined_types: enum SDLKey { SDLK_UNKNOWN=0, SDLK_FIRST=0, SDLK_BACKSPACE=8, SDLK_TAB=9, SDLK_CLEAR=12, SDLK_RETURN=13, SDLK_PAUSE=19, SDLK_ESCAPE=27, SDLK_SPACE=32, SDLK_EXCLAIM=33, SDLK_QUOTEDBL=34, SDLK_HASH=35, SDLK_DOLLAR=36, SDLK_AMPERSAND=38, SDLK_QUOTE=39, SDLK_LEFTPAREN=40, SDLK_RIGHTPAREN=41, SDLK_ASTERISK=42, SDLK_PLUS=43, SDLK_COMMA=44, SDLK_MINUS=45, SDLK_PERIOD=46, SDLK_SLASH=47, SDLK_0=48, SDLK_1=49, SDLK_2=50, SDLK_3=51, SDLK_4=52, SDLK_5=53, SDLK_6=54, SDLK_7=55, SDLK_8=56, SDLK_9=57, SDLK_COLON=58, SDLK_SEMICOLON=59, SDLK_LESS=60, SDLK_EQUALS=61, SDLK_GREATER=62, SDLK_QUESTION=63, SDLK_AT=64, SDLK_LEFTBRACKET=91, SDLK_BACKSLASH=92, SDLK_RIGHTBRACKET=93, SDLK_CARET=94, SDLK_UNDERSCORE=95, SDLK_BACKQUOTE=96, SDLK_a=97, SDLK_b=98, SDLK_c=99, SDLK_d=100, SDLK_e=101, SDLK_f=102, SDLK_g=103, SDLK_h=104, SDLK_i=105, SDLK_j=106, SDLK_k=107, SDLK_l=108, SDLK_m=109, SDLK_n=110, SDLK_o=111, SDLK_p=112, SDLK_q=113, SDLK_r=114, SDLK_s=115, SDLK_t=116, SDLK_u=117, SDLK_v=118, SDLK_w=119, SDLK_x=120, SDLK_y=121, SDLK_z=122, SDLK_DELETE=127, SDLK_WORLD_0=160, SDLK_WORLD_1=161, SDLK_WORLD_2=162, SDLK_WORLD_3=163, SDLK_WORLD_4=164, SDLK_WORLD_5=165, SDLK_WORLD_6=166, SDLK_WORLD_7=167, SDLK_WORLD_8=168, SDLK_WORLD_9=169, SDLK_WORLD_10=170, SDLK_WORLD_11=171, SDLK_WORLD_12=172, SDLK_WORLD_13=173, SDLK_WORLD_14=174, SDLK_WORLD_15=175, SDLK_WORLD_16=176, SDLK_WORLD_17=177, SDLK_WORLD_18=178, SDLK_WORLD_19=179, SDLK_WORLD_20=180, SDLK_WORLD_21=181, SDLK_WORLD_22=182, SDLK_WORLD_23=183, SDLK_WORLD_24=184, SDLK_WORLD_25=185, SDLK_WORLD_26=186, SDLK_WORLD_27=187, SDLK_WORLD_28=188, SDLK_WORLD_29=189, SDLK_WORLD_30=190, SDLK_WORLD_31=191, SDLK_WORLD_32=192, SDLK_WORLD_33=193, SDLK_WORLD_34=194, SDLK_WORLD_35=195, SDLK_WORLD_36=196, SDLK_WORLD_37=197, SDLK_WORLD_38=198, SDLK_WORLD_39=199, SDLK_WORLD_40=200, SDLK_WORLD_41=201, SDLK_WORLD_42=202, SDLK_WORLD_43=203, SDLK_WORLD_44=204, SDLK_WORLD_45=205, SDLK_WORLD_46=206, SDLK_WORLD_47=207, SDLK_WORLD_48=208, SDLK_WORLD_49=209, SDLK_WORLD_50=210, SDLK_WORLD_51=211, SDLK_WORLD_52=212, SDLK_WORLD_53=213, SDLK_WORLD_54=214, SDLK_WORLD_55=215, SDLK_WORLD_56=216, SDLK_WORLD_57=217, SDLK_WORLD_58=218, SDLK_WORLD_59=219, SDLK_WORLD_60=220, SDLK_WORLD_61=221, SDLK_WORLD_62=222, SDLK_WORLD_63=223, SDLK_WORLD_64=224, SDLK_WORLD_65=225, SDLK_WORLD_66=226, SDLK_WORLD_67=227, SDLK_WORLD_68=228, SDLK_WORLD_69=229, SDLK_WORLD_70=230, SDLK_WORLD_71=231, SDLK_WORLD_72=232, SDLK_WORLD_73=233, SDLK_WORLD_74=234, SDLK_WORLD_75=235, SDLK_WORLD_76=236, SDLK_WORLD_77=237, SDLK_WORLD_78=238, SDLK_WORLD_79=239, SDLK_WORLD_80=240, SDLK_WORLD_81=241, SDLK_WORLD_82=242, SDLK_WORLD_83=243, SDLK_WORLD_84=244, SDLK_WORLD_85=245, SDLK_WORLD_86=246, SDLK_WORLD_87=247, SDLK_WORLD_88=248, SDLK_WORLD_89=249, SDLK_WORLD_90=250, SDLK_WORLD_91=251, SDLK_WORLD_92=252, SDLK_WORLD_93=253, SDLK_WORLD_94=254, SDLK_WORLD_95=255, SDLK_KP0=256, SDLK_KP1=257, SDLK_KP2=258, SDLK_KP3=259, SDLK_KP4=260, SDLK_KP5=261, SDLK_KP6=262, SDLK_KP7=263, SDLK_KP8=264, SDLK_KP9=265, SDLK_KP_PERIOD=266, SDLK_KP_DIVIDE=267, SDLK_KP_MULTIPLY=268, SDLK_KP_MINUS=269, SDLK_KP_PLUS=270, SDLK_KP_ENTER=271, SDLK_KP_EQUALS=272, SDLK_UP=273, SDLK_DOWN=274, SDLK_RIGHT=275, SDLK_LEFT=276, SDLK_INSERT=277, SDLK_HOME=278, SDLK_END=279, SDLK_PAGEUP=280, SDLK_PAGEDOWN=281, SDLK_F1=282, SDLK_F2=283, SDLK_F3=284, SDLK_F4=285, SDLK_F5=286, SDLK_F6=287, SDLK_F7=288, SDLK_F8=289, SDLK_F9=290, SDLK_F10=291, SDLK_F11=292, SDLK_F12=293, SDLK_F13=294, SDLK_F14=295, SDLK_F15=296, SDLK_NUMLOCK=300, SDLK_CAPSLOCK=301, SDLK_SCROLLOCK=302, SDLK_RSHIFT=303, SDLK_LSHIFT=304, SDLK_RCTRL=305, SDLK_LCTRL=306, SDLK_RALT=307, SDLK_LALT=308, SDLK_RMETA=309, SDLK_LMETA=310, SDLK_LSUPER=311, SDLK_RSUPER=312, SDLK_MODE=313, SDLK_COMPOSE=314, SDLK_HELP=315, SDLK_PRINT=316, SDLK_SYSREQ=317, SDLK_BREAK=318, SDLK_MENU=319, SDLK_POWER=320, SDLK_EURO=321, SDLK_UNDO=322, SDLK_LAST=323 }


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

result = 0LL;
if ( !*(_BYTE *)(newKeystates + a1) )
result = *((_BYTE *)oldKeystates + a1) != 0;
return result;
}

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

result = 0LL;
if ( !*(_BYTE *)(newKeystates + a1) )
result = *((_BYTE *)oldKeystates + a1) != 0;
return result;
}

original_code:
int input_get_key_up(SDLKey key)
{
 return (!newKeystates[key] && oldKeystates[key]);
}

canonical_original_code:
int input_get_key_up(enum SDLKey key)
{
 return (!newKeystates[key] && oldKeystates[key]);
}


decompiled_code:
__int64 __fastcall bullet_remove(signed int a1)
{
__int64 result; // rax
__int64 v2; // rdi
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

result = a1;
v3[0] = a1;
if ( (unsigned int)a1 > 0x13 )
_assert_fail("index >= 0 && index < MAX_BULLETS", "bullet.c", 0x32u, "bullet_remove");
v2 = *((_QWORD *)bullets + a1);
if ( v2 )
{
colliders_remove(v2 + 16);
free(*((void **)bullets + v3[0]));
*((_QWORD *)bullets + v3[0]) = 0LL;
result = stack_push(&freeIndices, v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(signed int a1)
{
__int64 result; // rax
__int64 v2; // rdi
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

result = a1;
v3[0] = a1;
if ( (unsigned int)a1 > 0x13 )
_assert_fail("index >= 0 && index < MAX_BULLETS", "bullet.c", 0x32u, "bullet_remove");
v2 = *((_QWORD *)bullets + a1);
if ( v2 )
{
colliders_remove(v2 + 16);
free(*((void **)bullets + v3[0]));
*((_QWORD *)bullets + v3[0]) = 0LL;
result = stack_push(&freeIndices, v3);
}
return result;
}

original_code:
void bullet_remove(int index)
{
 ((index >= 0 && index < MAX_BULLETS) ? (void) (0) : __assert_fail ("index >= 0 && index < MAX_BULLETS", "bullet.c", 50, __extension__ __PRETTY_FUNCTION__));
 if (bullets[index]) {
  colliders_remove(&bullets[index]->collider);
  free(bullets[index]);
  bullets[index] = ((void *)0);
  stack_push(&freeIndices, (void *)&index);
 }
}

variable_types: index int


decompiled_code:
__int64 bullet_next_index()
{
int v0; // er8
__int64 result; // rax
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

v0 = stack_size(&freeIndices);
result = 0xFFFFFFFFLL;
if ( v0 )
{
stack_pop(&freeIndices, v2);
result = v2[0];
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // er8
__int64 result; // rax
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

v0 = stack_size(&freeIndices);
result = 0xFFFFFFFFLL;
if ( v0 )
{
stack_pop(&freeIndices, v2);
result = v2[0];
}
return result;
}

original_code:
int bullet_next_index()
{
 int result;
 if (stack_size(&freeIndices) > 0) {
  stack_pop(&freeIndices, &result);
 } else {
  result = -1;
 }
 return result;
}

variable_types: result int


decompiled_code:
__int64 bullets_update()
{
_QWORD *v0; // rax
__int64 i; // rbx
__int64 v2; // rdi
__int64 v3; // rbx
__int64 result; // rax
signed int v5; // edi

v0 = bullets;
for ( i = 0LL; i != 20; ++i )
{
v2 = v0[i];
if ( v2 )
{
bullet_update(v2);
v0 = bullets;
}
}
v3 = 0LL;
while ( 1 )
{
result = v0[v3];
if ( result )
{
result = *(unsigned int *)(result + 64);
if ( (_DWORD)result )
break;
}
if ( ++v3 == 20 )
return result;
LABEL_7:
v0 = bullets;
}
v5 = v3++;
result = bullet_remove(v5);
if ( v3 != 20 )
goto LABEL_7;
return result;
}

canonical_decompiled_code:
__int64 func6()
{
_QWORD *v0; // rax
__int64 i; // rbx
__int64 v2; // rdi
__int64 v3; // rbx
__int64 result; // rax
signed int v5; // edi

v0 = bullets;
for ( i = 0LL; i != 20; ++i )
{
v2 = v0[i];
if ( v2 )
{
func0(v2);
v0 = bullets;
}
}
v3 = 0LL;
while ( 1 )
{
result = v0[v3];
if ( result )
{
result = *(unsigned int *)(result + 64);
if ( (_DWORD)result )
break;
}
if ( ++v3 == 20 )
return result;
LABEL_7:
v0 = bullets;
}
v5 = v3++;
result = func2(v5);
if ( v3 != 20 )
goto LABEL_7;
return result;
}

original_code:
void bullets_update()
{
 int i;
 for (i = 0; i < MAX_BULLETS; ++i) {
  if (bullets[i]) {
   bullet_update(bullets[i]);
  }
 }
 for (i = 0; i < MAX_BULLETS; ++i) {
  if (bullets[i] && bullets[i]->destroy) {
   bullet_remove(i);
  }
 }
}


decompiled_code:
void *bullets_draw()
{
__int64 i; // rbx
void *result; // rax
__int64 v2; // rdi

for ( i = 0LL; i != 160; i += 8LL )
{
result = bullets;
v2 = *(_QWORD *)((char *)bullets + i);
if ( v2 )
result = (void *)bullet_draw(v2);
}
return result;
}

canonical_decompiled_code:
void *func7()
{
__int64 i; // rbx
void *result; // rax
__int64 v2; // rdi

for ( i = 0LL; i != 160; i += 8LL )
{
result = bullets;
v2 = *(_QWORD *)((char *)bullets + i);
if ( v2 )
result = (void *)func1(v2);
}
return result;
}

original_code:
void bullets_draw()
{
 for (int i = 0; i < MAX_BULLETS; ++i) {
  if (bullets[i]) {
   bullet_draw(bullets[i]);
  }
 }
}


decompiled_code:
void bullets_cleanup()
{
char *v0; // r8
__int64 i; // rbx
void *v2; // rdi

v0 = (char *)bullets;
for ( i = 0LL; i != 160; i += 8LL )
{
v2 = *(void **)&v0[i];
if ( v2 )
{
free(v2);
v0 = (char *)bullets;
*(_QWORD *)((char *)bullets + i) = 0LL;
}
}
free(v0);
}

canonical_decompiled_code:
void func8()
{
char *v0; // r8
__int64 i; // rbx
void *v2; // rdi

v0 = (char *)bullets;
for ( i = 0LL; i != 160; i += 8LL )
{
v2 = *(void **)&v0[i];
if ( v2 )
{
free(v2);
v0 = (char *)bullets;
*(_QWORD *)((char *)bullets + i) = 0LL;
}
}
free(v0);
}

original_code:
void bullets_cleanup()
{
 for (int i = 0; i < MAX_BULLETS; ++i) {
  if (bullets[i]) {
   free(bullets[i]);
   bullets[i] = ((void *)0);
  }
 }
 free(bullets);
}


decompiled_code:
void init_image_assets()
{
imageAssetIndex = 0;
}

canonical_decompiled_code:
void func0()
{
imageAssetIndex = 0;
}

original_code:
void init_image_assets()
{
 int i;
 imageAssetIndex = 0;
}


decompiled_code:
__int64 free_image_assets()
{
__int64 result; // rax
__int64 v1; // rbx
__int64 v2; // rax

result = (unsigned int)imageAssetIndex;
if ( imageAssetIndex > 0 )
{
v1 = 0LL;
do
{
v2 = v1++;
result = SDL_FreeSurface(image_assets[2 * v2]);
}
while ( imageAssetIndex > (int)v1 );
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
__int64 v1; // rbx
__int64 v2; // rax

result = (unsigned int)imageAssetIndex;
if ( imageAssetIndex > 0 )
{
v1 = 0LL;
do
{
v2 = v1++;
result = SDL_FreeSurface(image_assets[2 * v2]);
}
while ( imageAssetIndex > (int)v1 );
}
return result;
}

original_code:
void free_image_assets()
{
 int i;
 for (i = 0; i < imageAssetIndex; i++)
 {
  SDL_FreeSurface(image_assets[i].image);
 }
}


decompiled_code:
__int64 init_globals()
{
__int64 result; // rax

*((_DWORD *)&globals + 2) = 32;
globals = 0x25800000320LL;
*(&globals + 2) = 0LL;
*((_DWORD *)&globals + 6) = 1;
LODWORD(result) = SDL_GetTicks();
*(&globals + 5) = 0LL;
*(&globals + 6) = 0LL;
result = (unsigned int)result;
*(&globals + 4) = (unsigned int)result;
*((_DWORD *)&globals + 14) = 0;
*(&globals + 8) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

*((_DWORD *)&globals + 2) = 32;
globals = 0x25800000320LL;
*(&globals + 2) = 0LL;
*((_DWORD *)&globals + 6) = 1;
LODWORD(result) = SDL_GetTicks();
*(&globals + 5) = 0LL;
*(&globals + 6) = 0LL;
result = (unsigned int)result;
*(&globals + 4) = (unsigned int)result;
*((_DWORD *)&globals + 14) = 0;
*(&globals + 8) = 0LL;
return result;
}

original_code:
void init_globals()
{
 globals.window.width = 800;
 globals.window.height = 600;
 globals.window.bpp = 32;
 globals.screen = ((void *)0);
 globals.bRun = 1;
 globals.time.start = SDL_GetTicks();
 globals.time.sinceStart = 0;
 globals.time.delta = 0;
 globals.time.deltaf = 0.0f;
 globals.time.last = 0;
}


main

canonical_name: main

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

if ( argc == 3 )
{
if ( atoi(argv[1]) == 1 && (unsigned int)atoi(argv[2]) <= 1 )
{
rs485_set_model_constprop_0_isra_0();
result = 0;
}
else
{
fwrite(
"Usage: ./rs485 argv[1] argv[2] here argv[1] must specified to 1 and argv[2] must in 0 or 1\n",
1uLL,
0x5BuLL,
stdout);
fwrite("argv[1] = 1,set rs485 work model and argv[2] specified model\n", 1uLL, 0x3DuLL, stdout);
result = -1;
}
}
else if ( argc == 2 )
{
if ( atoi(argv[1]) == 2 )
{
rs485_get_stats_isra_0();
result = 0;
}
else
{
fwrite("Usage: ./rs485 argv[1] argv[1] must to be given 2 to pecified the rs read model\n", 1uLL, 0x50uLL, stdout);
result = -1;
}
}
else
{
fwrite("Usage: ./rs485 [argv[1]] <argv[2]>\n", 1uLL, 0x23uLL, stdout);
result = -1;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax

if ( argc == 3 )
{
if ( atoi(argv[1]) == 1 && (unsigned int)atoi(argv[2]) <= 1 )
{
func10();
result = 0;
}
else
{
fwrite(
"Usage: ./rs485 argv[1] argv[2] here argv[1] must specified to 1 and argv[2] must in 0 or 1\n",
1uLL,
0x5BuLL,
stdout);
fwrite("argv[1] = 1,set rs485 work model and argv[2] specified model\n", 1uLL, 0x3DuLL, stdout);
result = -1;
}
}
else if ( argc == 2 )
{
if ( atoi(argv[1]) == 2 )
{
func9();
result = 0;
}
else
{
fwrite("Usage: ./rs485 argv[1] argv[1] must to be given 2 to pecified the rs read model\n", 1uLL, 0x50uLL, stdout);
result = -1;
}
}
else
{
fwrite("Usage: ./rs485 [argv[1]] <argv[2]>\n", 1uLL, 0x23uLL, stdout);
result = -1;
}
return result;
}

original_code:
int main(int argc,char **argv)
{
 if(argc == 3)
 {
  if(atoi(argv[1]) == 0x1)
  {
   if((atoi(argv[2]) != 0x0) && (atoi(argv[2]) != 0x1))
   {
    fprintf(stdout,"Usage: ./rs485 argv[1] argv[2] here argv[1] must specified to 1 and argv[2] must in 0 or 1\n");
    fprintf(stdout,"argv[1] = 1,set rs485 work model and argv[2] specified model\n");
    return -1;
   }
   else if(argv[2] == 0)
   {
    rs485_set_model(0);
   }
   else
   {
    rs485_set_model(1);
   }
  }
  else
  {
   fprintf(stdout,"Usage: ./rs485 argv[1] argv[2] here argv[1] must specified to 1 and argv[2] must in 0 or 1\n");
   fprintf(stdout,"argv[1] = 1,set rs485 work model and argv[2] specified model\n");
   return -1;
  }
 }
 else if(argc == 2)
 {
  if(atoi(argv[1]) != 0x2)
  {
   fprintf(stdout,"Usage: ./rs485 argv[1] argv[1] must to be given 2 to pecified the rs read model\n");
   return -1;
  }
  else
  {
   rs485_get_stats();
  }
 }
 else
 {
  fprintf(stdout,"Usage: ./rs485 [argv[1]] <argv[2]>\n");
  return -1;
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 if(argc == 3)
 {
  if(atoi(argv[1]) == 0x1)
  {
   if((atoi(argv[2]) != 0x0) && (atoi(argv[2]) != 0x1))
   {
    fprintf(stdout,"Usage: ./rs485 argv[1] argv[2] here argv[1] must specified to 1 and argv[2] must in 0 or 1\n");
    fprintf(stdout,"argv[1] = 1,set rs485 work model and argv[2] specified model\n");
    return -1;
   }
   else if(argv[2] == 0)
   {
    rs485_set_model(0);
   }
   else
   {
    rs485_set_model(1);
   }
  }
  else
  {
   fprintf(stdout,"Usage: ./rs485 argv[1] argv[2] here argv[1] must specified to 1 and argv[2] must in 0 or 1\n");
   fprintf(stdout,"argv[1] = 1,set rs485 work model and argv[2] specified model\n");
   return -1;
  }
 }
 else if(argc == 2)
 {
  if(atoi(argv[1]) != 0x2)
  {
   fprintf(stdout,"Usage: ./rs485 argv[1] argv[1] must to be given 2 to pecified the rs read model\n");
   return -1;
  }
  else
  {
   rs485_get_stats();
  }
 }
 else
 {
  fprintf(stdout,"Usage: ./rs485 [argv[1]] <argv[2]>\n");
  return -1;
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 __fastcall nb_egalites(float *a1, int a2, float a3)
{
__int64 v3; // rdx
__int64 result; // rax

if ( a2 <= 0 )
return 0LL;
v3 = (__int64)&a1[a2 - 1 + 1];
result = 0LL;
do
{
if ( a3 == *a1 )
result = (unsigned int)(result + 1);
++a1;
}
while ( a1 != (float *)v3 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(float *a1, int a2, float a3)
{
__int64 v3; // rdx
__int64 result; // rax

if ( a2 <= 0 )
return 0LL;
v3 = (__int64)&a1[a2 - 1 + 1];
result = 0LL;
do
{
if ( a3 == *a1 )
result = (unsigned int)(result + 1);
++a1;
}
while ( a1 != (float *)v3 );
return result;
}

original_code:
int nb_egalites(float tab[], int longueur, float maximum){
 int i;
 int acc = 0;
 for (i=0; i<longueur; i++)
  if (tab[i] == maximum)
   acc ++;
 return acc;
}

variable_types:
tab
float []

variable_types: longueur int

variable_types: maximum float

variable_types: acc int


max

decompiled_code:
__int64 __fastcall max(__int64 a1, int a2)
{
__int64 v2; // rax
unsigned int v3; // er8

if ( a2 <= 1 )
return 0LL;
v2 = 1LL;
v3 = 0;
do
{
if ( *(float *)(a1 + 4 * v2) > *(float *)(a1 + 4LL * (int)v3) )
v3 = v2;
++v2;
}
while ( v2 != a2 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2)
{
__int64 v2; // rax
unsigned int v3; // er8

if ( a2 <= 1 )
return 0LL;
v2 = 1LL;
v3 = 0;
do
{
if ( *(float *)(a1 + 4 * v2) > *(float *)(a1 + 4LL * (int)v3) )
v3 = v2;
++v2;
}
while ( v2 != a2 );
return v3;
}

original_code:
int max(float tab[], int longueur){
 int acc,i;
  acc = 0;
 for (i = 1; i < longueur; i++){
  if (tab[i] > tab[acc])
  acc = i;
 }
 return acc;
}

canonical_original_code:
int max(float tab[], int longueur){
 int acc; int i;
  acc = 0;
 for (i = 1; i < longueur; i++){
  if (tab[i] > tab[acc])
  acc = i;
 }
 return acc;
}


alea

decompiled_code:
__int64 __fastcall alea(int a1)
{
return (unsigned int)(rand() % (a1 + 1));
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return (unsigned int)(rand() % (a1 + 1));
}

original_code:
int alea (int m){
        return rand() % (m+1) ;
}

canonical_original_code:
int alea(int m){
        return rand() % (m+1) ;
}

variable_types: m int


decompiled_code:
int tracer_ligne()
{
int v0; // ebx

v0 = 7;
putchar(124);
do
{
printf("---|");
--v0;
}
while ( v0 );
return putchar(10);
}

canonical_decompiled_code:
int func0()
{
int v0; // ebx

v0 = 7;
putchar(124);
do
{
printf("---|");
--v0;
}
while ( v0 );
return putchar(10);
}

original_code:
void tracer_ligne( int largeur ){
 int i;
 printf("|");
 for (i=0; i<7; i++)
 {
  printf("---|");
 }
 printf("\n");
}

canonical_original_code:
void tracer_ligne(int largeur){
 int i;
 printf("|");
 for (i=0; i<7; i++)
 {
  printf("---|");
 }
 printf("\n");
}

variable_types: largeur int


decompiled_code:
int effacer_grille()
{
return printf("\n\x1B[%dA", 17LL);
}

canonical_decompiled_code:
int func3()
{
return printf("\n\x1B[%dA", 17LL);
}

original_code:
void effacer_grille(){
  printf("\n\e[%dA",17);
 }


decompiled_code:
__int64 demander_coup_joueur()
{
int v0; // eax

puts(s);
do
v0 = getchar();
while ( (unsigned int)(v0 - 49) > 6 && v0 != 117 );
return (unsigned int)(v0 - 48);
}

canonical_decompiled_code:
__int64 func4()
{
int v0; // eax

puts(s);
do
v0 = getchar();
while ( (unsigned int)(v0 - 49) > 6 && v0 != 117 );
return (unsigned int)(v0 - 48);
}

original_code:
bool demander_coup_joueur(){
 bool coup_valide = -1;
 int indice = 0;
 printf("Rentrez l'indice de la colonne où jouer(entre 1 et 7, inclus) u pour annuler:\n");
 do{
  indice = getchar();
  coup_valide = (((indice>'0')&&(indice<'8'))||(indice == 'u'));
 }while(!(coup_valide));
 return (indice-'0');
  }

canonical_original_code:
int demander_coup_joueur(){
 int coup_valide = -1;
 int indice = 0;
 printf("Rentrez l'indice de la colonne où jouer(entre 1 et 7, inclus) u pour annuler:\n");
 do{
  indice = getchar();
  coup_valide = (((indice>'0')&&(indice<'8'))||(indice == 'u'));
 }while(!(coup_valide));
 return (indice-'0');
  }

variable_types: indice int


repo: tehn/aleph

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

result = a1;
if ( a1 )
{
if ( *(_QWORD *)(a1 + 8) != -1LL )
_InterlockedAdd64((volatile signed __int64 *)(a1 + 8), 1uLL);
}
return result;
}

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

result = a1;
if ( a1 )
{
if ( *(_QWORD *)(a1 + 8) != -1LL )
_InterlockedAdd64((volatile signed __int64 *)(a1 + 8), 1uLL);
}
return result;
}

original_code:
static inline
json_t *json_incref(json_t *json)
{
    if(json && json->refcount != (size_t)-1)
        __atomic_add_fetch(&json->refcount, 1, 2);
    return json;
}

canonical_original_code:
static inline struct json_t *json_incref(struct json_t *json)
{
    if(json && json->refcount != (unsigned long)-1)
        __atomic_add_fetch(&json->refcount, 1, 2);
    return json;
}

variable_types:
json
struct json_t *

return_type: struct json_t { enum json_type { JSON_OBJECT=0, JSON_ARRAY=1, JSON_STRING=2, JSON_INTEGER=3, JSON_REAL=4, JSON_TRUE=5, JSON_FALSE=6, JSON_NULL=7 } type; unsigned long refcount; } *

user_defined_types: struct json_t { enum json_type type; unsigned long refcount; }


decompiled_code:
__int64 net_write_json_presets()
{
__int64 v0; // rbx
unsigned int v1; // er12
__int64 v2; // r13
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // r14
__int64 v7; // rbp
int v8; // eax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
const char *v13; // rsi
__int64 v14; // rdx
__int64 v15; // rax
unsigned int v16; // er15
__int64 v17; // r14
__int64 v18; // rbp
__int64 v19; // r12
int v20; // er14
int v21; // edx
__int64 v22; // rax
__int64 v23; // rax
__int16 v24; // ax
__int64 v25; // rax
__int16 v26; // ax
__int64 v27; // rax
__int64 v28; // rax
__int64 v29; // rdi
__int64 v30; // rax
__int64 v31; // rax
__int64 v33; // rax
__int64 v34; // rax
__int64 v35; // rax
__int64 v36; // rax
__int64 v37; // rax
__int64 v38; // rax
unsigned int v39; // [rsp+Ch] [rbp-4Ch]
__int64 v40; // [rsp+10h] [rbp-48h]
__int64 v41; // [rsp+18h] [rbp-40h]

v0 = 0LL;
v39 = 0;
v41 = json_array();
do
{
v1 = 0;
v40 = json_object();
v2 = json_array();
v3 = preset_name(v39);
v4 = json_string(v3);
json_object_set_isra_0(v40, (__int64)"name", v4);
v5 = presets;
do
{
while ( 1 )
{
v6 = 4LL * (int)v1;
if ( *(_BYTE *)(v0 + v5 + v6 + 2) )
break;
if ( ++v1 == 512 )
goto LABEL_8;
}
v7 = json_object();
v8 = *(unsigned __int16 *)(net + 263182LL);
if ( v8 <= (int)v1 )
{
v12 = get_param_name(v1 - v8);
v13 = "paramName";
}
else
{
v9 = json_integer(*(int *)(net + 8LL * (int)v1 + 263188));
json_object_set_isra_0(v7, (__int64)"opIdx", v9);
v10 = net_op_name((unsigned int)*(__int16 *)(net + 8 * ((int)v1 + 32898LL) + 4));
v11 = json_string(v10);
json_object_set_isra_0(v7, (__int64)"opName", v11);
v12 = net_in_name(v1);
v13 = "opInName";
}
v14 = json_string(v12);
++v1;
json_object_set_isra_0(v7, (__int64)v13, v14);
v15 = json_integer(*(__int16 *)(v6 + presets + v0));
json_object_set_isra_0(v7, (__int64)"value", v15);
json_array_append_isra_0(v2, v7);
v5 = presets;
}
while ( v1 != 512 );
LABEL_8:
v16 = 0;
while ( 1 )
{
v17 = 4LL * (int)v16 + 2048;
if ( !*(_BYTE *)(v0 + v17 + v5 + 2) )
goto LABEL_9;
v18 = json_object();
v19 = json_object();
v20 = *(__int16 *)(v17 + presets + v0);
if ( v20 >= 0 )
break;
v38 = json_integer(-1LL);
json_object_set_isra_0(v19, (__int64)"inIdx", v38);
LABEL_9:
if ( ++v16 == 256 )
goto LABEL_16;
LABEL_10:
v5 = presets;
}
v21 = *(unsigned __int16 *)(net + 263182LL);
if ( v21 > v20 )
{
v33 = json_integer(*(int *)(net + 8LL * v20 + 263188));
json_object_set_isra_0(v19, (__int64)"opIdx", v33);
v34 = net_op_name((unsigned int)*(__int16 *)(net + 8 * (v20 + 32898LL) + 4));
v35 = json_string(v34);
json_object_set_isra_0(v19, (__int64)"opName", v35);
v36 = net_in_name((unsigned int)v20);
v37 = json_string(v36);
json_object_set_isra_0(v19, (__int64)"opInName", v37);
}
else
{
v22 = get_param_name((unsigned int)(v20 - v21));
v23 = json_string(v22);
json_object_set_isra_0(v19, (__int64)"paramName", v23);
}
v24 = net_out_op_idx(v16);
v25 = json_integer(v24);
json_object_set_isra_0(v18, (__int64)"opIdx", v25);
v26 = net_out_op_idx(v16);
v27 = net_op_name((unsigned int)v26);
v28 = json_string(v27);
json_object_set_isra_0(v18, (__int64)"opName", v28);
v29 = v16++;
v30 = net_out_name(v29);
v31 = json_string(v30);
json_object_set_isra_0(v18, (__int64)"opOutName", v31);
json_object_set_isra_0(v18, (__int64)"target", v19);
json_array_append_isra_0(v2, v18);
if ( v16 != 256 )
goto LABEL_10;
LABEL_16:
v0 += 3088LL;
json_object_set_isra_0(v40, (__int64)"entries", v2);
json_array_append_isra_0(v41, v40);
++v39;
}
while ( v39 != 32 );
return v41;
}

original_code:
static json_t* net_write_json_presets(void) {
  json_t* pres = json_array();
  int i, j;
  for(i=0; i<32; i++) {
    json_t* pre = json_object();
    json_t* l = json_array();
    json_t* o;
    json_t* p;
    json_object_set( pre, "name", json_string( preset_name(i)) );
    for(j=0; j<(256 + 256); j++) {
      if(presets[i].ins[j].enabled) {
 o = json_object();
 if(j < net->numIns) {
   json_object_set( o, "opIdx", json_integer( net->ins[j].opIdx ) );
   json_object_set( o, "opName", json_string( net_op_name(net->ins[j].opIdx) ) );
   json_object_set( o, "opInName", json_string( net_in_name(j) ) );
   json_object_set( o, "value", json_integer( presets[i].ins[j].value ) );
 } else {
   int pId = j - net->numIns;
   json_object_set( o, "paramName", json_string ( get_param_name(pId) ) ) ;
   json_object_set( o, "value", json_integer( presets[i].ins[j].value ) );
 }
 json_array_append(l, o);
      }
    }
    for(j=0; j<256; j++) {
      if(presets[i].outs[j].enabled) {
 int target;
 o = json_object();
 p = json_object();
 target = presets[i].outs[j].target;
 if(target < 0) {
   json_object_set(p, "inIdx", json_integer( -1 ) );
 } else {
   if(target >= net->numIns) {
     json_object_set( p, "paramName", json_string( get_param_name(target - net->numIns) ) ) ;
   } else {
     json_object_set( p, "opIdx", json_integer( net->ins[target].opIdx ) ) ;
     json_object_set( p, "opName", json_string( net_op_name(net->ins[target].opIdx) ) );
     json_object_set( p, "opInName", json_string( net_in_name(target) ) );
   }
   json_object_set( o, "opIdx", json_integer( net_out_op_idx(j) ) );
   json_object_set( o, "opName", json_string( net_op_name(net_out_op_idx(j) ) ) );
   json_object_set( o, "opOutName", json_string( net_out_name(j) ) );
   json_object_set( o, "target", p);
   json_array_append( l, o );
 }
      }
    }
    json_object_set(pre, "entries", l);
    json_array_append(pres, pre);
  }
  return pres;
}

canonical_original_code:
static struct json_t *net_write_json_presets() {
  struct json_t *pres = json_array();
  int i; int j;
  for(i=0; i<32; i++) {
    struct json_t *pre = json_object();
    struct json_t *l = json_array();
    struct json_t *o;
    struct json_t *p;
    json_object_set( pre, "name", json_string( preset_name(i)) );
    for(j=0; j<(256 + 256); j++) {
      if(presets[i].ins[j].enabled) {
 o = json_object();
 if(j < net->numIns) {
   json_object_set( o, "opIdx", json_integer( net->ins[j].opIdx ) );
   json_object_set( o, "opName", json_string( net_op_name(net->ins[j].opIdx) ) );
   json_object_set( o, "opInName", json_string( net_in_name(j) ) );
   json_object_set( o, "value", json_integer( presets[i].ins[j].value ) );
 } else {
   int pId = j - net->numIns;
   json_object_set( o, "paramName", json_string ( get_param_name(pId) ) ) ;
   json_object_set( o, "value", json_integer( presets[i].ins[j].value ) );
 }
 json_array_append(l, o);
      }
    }
    for(j=0; j<256; j++) {
      if(presets[i].outs[j].enabled) {
 int target;
 o = json_object();
 p = json_object();
 target = presets[i].outs[j].target;
 if(target < 0) {
   json_object_set(p, "inIdx", json_integer( -1 ) );
 } else {
   if(target >= net->numIns) {
     json_object_set( p, "paramName", json_string( get_param_name(target - net->numIns) ) ) ;
   } else {
     json_object_set( p, "opIdx", json_integer( net->ins[target].opIdx ) ) ;
     json_object_set( p, "opName", json_string( net_op_name(net->ins[target].opIdx) ) );
     json_object_set( p, "opInName", json_string( net_in_name(target) ) );
   }
   json_object_set( o, "opIdx", json_integer( net_out_op_idx(j) ) );
   json_object_set( o, "opName", json_string( net_op_name(net_out_op_idx(j) ) ) );
   json_object_set( o, "opOutName", json_string( net_out_name(j) ) );
   json_object_set( o, "target", p);
   json_array_append( l, o );
 }
      }
    }
    json_object_set(pre, "entries", l);
    json_array_append(pres, pre);
  }
  return pres;
}

variable_types: struct json_t { enum json_type { JSON_OBJECT=0, JSON_ARRAY=1, JSON_STRING=2, JSON_INTEGER=3, JSON_REAL=4, JSON_TRUE=5, JSON_FALSE=6, JSON_NULL=7 } type; unsigned long refcount; } *

variable_types: j int

variable_types: pId int

variable_types: target int


decompiled_code:
__int64 net_write_json_params()
{
__int64 v0; // r13
__int64 v1; // rax
__int64 v2; // r12
__int64 v3; // rdx
__int64 v4; // rbp
__int64 v5; // rbx
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax

v0 = json_array();
v1 = json_integer(*(unsigned __int16 *)(net + 263186LL));
json_object_set_isra_0(v0, (__int64)"count", v1);
if ( *(_WORD *)(net + 263186LL) )
{
v2 = 0LL;
do
{
v4 = json_object();
v5 = (__int64)(int)v2 << 6;
v6 = json_string(net + (v2 << 6) + 267288);
json_object_set_isra_0(v4, (__int64)"name", v6);
v7 = json_integer(*(unsigned int *)(v5 + net + 267304));
json_object_set_isra_0(v4, (__int64)"type", v7);
v8 = json_integer(*(int *)(v5 + net + 267308));
json_object_set_isra_0(v4, (__int64)"min", v8);
v9 = json_integer(*(int *)(v5 + net + 267312));
json_object_set_isra_0(v4, (__int64)"max", v9);
v10 = json_integer(*(unsigned __int8 *)(v5 + net + 267316));
json_object_set_isra_0(v4, (__int64)"radix", v10);
v11 = json_integer(*(int *)(net + v5 + 267317));
json_object_set_isra_0(v4, (__int64)"value", v11);
if ( (unsigned __int8)net_get_in_play((unsigned int)v2 + *(unsigned __int16 *)(net + 263182LL)) )
v3 = json_true();
else
v3 = json_false();
++v2;
json_object_set_isra_0(v4, (__int64)"play", v3);
json_array_append_isra_0(v0, v4);
}
while ( *(unsigned __int16 *)(net + 263186LL) > (int)v2 );
}
return v0;
}

original_code:
static json_t* net_write_json_params(void) {
  json_t *params = json_array();
  json_t* o;
  int i;
  json_object_set(params, "count", json_integer(net->numParams));
  for(i=0; i<net->numParams; i++) {
    o = json_object();
    json_object_set(o, "name", json_string(net->params[i].desc.label));
    json_object_set(o, "type", json_integer(net->params[i].desc.type));
    json_object_set(o, "min", json_integer(net->params[i].desc.min));
    json_object_set(o, "max", json_integer(net->params[i].desc.max));
    json_object_set(o, "radix", json_integer(net->params[i].desc.radix));
    json_object_set(o, "value", json_integer(net->params[i].data.value));
    json_object_set(o, "play", ((net_get_in_play(i + net->numIns)) ? json_true() : json_false()));
    json_array_append(params, o);
  }
  return params;
}

canonical_original_code:
static struct json_t *net_write_json_params() {
  struct json_t *params = json_array();
  struct json_t *o;
  int i;
  json_object_set(params, "count", json_integer(net->numParams));
  for(i=0; i<net->numParams; i++) {
    o = json_object();
    json_object_set(o, "name", json_string(net->params[i].desc.label));
    json_object_set(o, "type", json_integer(net->params[i].desc.type));
    json_object_set(o, "min", json_integer(net->params[i].desc.min));
    json_object_set(o, "max", json_integer(net->params[i].desc.max));
    json_object_set(o, "radix", json_integer(net->params[i].desc.radix));
    json_object_set(o, "value", json_integer(net->params[i].data.value));
    json_object_set(o, "play", ((net_get_in_play(i + net->numIns)) ? json_true() : json_false()));
    json_array_append(params, o);
  }
  return params;
}

variable_types: i int

user_defined_types: enum json_type { JSON_OBJECT=0, JSON_ARRAY=1, JSON_STRING=2, JSON_INTEGER=3, JSON_REAL=4, JSON_TRUE=5, JSON_FALSE=6, JSON_NULL=7 }


decompiled_code:
__int64 net_write_json_ops()
{
__int64 v0; // rax
unsigned __int8 *v1; // r14
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
int v5; // ebx
__int64 v6; // rsi
unsigned int v7; // er12
__int64 v8; // rbp
__int64 v9; // rax
__int64 v10; // rax
__int16 v11; // ax
__int64 v12; // rax
int v13; // ebx
__int16 v14; // ax
__int64 v15; // rax
__int16 v16; // ax
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rax
int v22; // er13
__int64 v23; // rbp
__int64 v24; // r12
__int64 v25; // rax
__int64 v26; // rax
__int64 v27; // rax
__int64 v28; // rax
__int64 v29; // rax
__int64 (__fastcall *v30)(unsigned __int8 *, char *); // rax
char *v31; // rbp
__int64 v32; // rax
char *v33; // rbx
__int64 v34; // rdi
__int64 v35; // rax
unsigned int v37; // [rsp+4h] [rbp-10074h]
__int64 v38; // [rsp+8h] [rbp-10070h]
__int64 v39; // [rsp+18h] [rbp-10060h]
__int64 v40; // [rsp+20h] [rbp-10058h]
__int64 v41; // [rsp+28h] [rbp-10050h]
__int64 v42; // [rsp+30h] [rbp-10048h]
__int64 v43; // [rsp+38h] [rbp-10040h]
char v44[65592]; // [rsp+40h] [rbp-10038h] BYREF

v43 = json_array();
v0 = net;
if ( *(_WORD *)(net + 263180LL) )
{
v39 = 0LL;
do
{
v1 = *(unsigned __int8 **)(v0 + 8LL * (int)v39);
v41 = json_array();
v38 = json_array();
v40 = json_array();
v42 = json_object();
v2 = json_integer(v39);
json_object_set_isra_0(v42, (__int64)"index", v2);
v3 = json_integer(*((unsigned int *)v1 + 20));
json_object_set_isra_0(v42, (__int64)"class", v3);
v4 = json_string(*((_QWORD *)v1 + 7));
json_object_set_isra_0(v42, (__int64)"name", v4);
if ( *v1 )
{
v5 = 0;
do
{
v6 = (unsigned int)v5++;
v7 = (unsigned __int16)net_op_in_idx((unsigned int)v39, v6);
v8 = json_object();
v9 = net_in_name(v7);
v10 = json_string(v9);
json_object_set_isra_0(v8, (__int64)"name", v10);
v11 = net_get_in_value(v7);
v12 = json_integer(v11);
json_object_set_isra_0(v8, (__int64)"value", v12);
json_array_append_isra_0(v41, v8);
}
while ( *v1 > v5 );
}
if ( v1[1] )
{
v13 = 0;
do
{
v37 = (unsigned __int16)net_op_out_idx((unsigned int)v39, (unsigned int)v13);
v22 = (__int16)net_get_target();
v23 = json_object();
v24 = json_object();
v25 = net_out_name(v37);
v26 = json_string(v25);
json_object_set_isra_0(v23, (__int64)"name", v26);
if ( v22 == -1 )
{
v27 = json_integer(-1LL);
json_object_set_isra_0(v24, (__int64)"inIdx", v27);
}
else
{
v14 = net_in_op_idx((unsigned __int16)v22);
if ( v14 < 0 )
{
v28 = net_in_name((unsigned __int16)v22);
v29 = json_string(v28);
json_object_set_isra_0(v24, (__int64)"paramName", v29);
}
else
{
v15 = json_integer(v14);
json_object_set_isra_0(v24, (__int64)"opIdx", v15);
v16 = net_in_op_idx((unsigned __int16)v22);
v17 = net_op_name((unsigned int)v16);
v18 = json_string(v17);
json_object_set_isra_0(v24, (__int64)"opName", v18);
v19 = json_integer(*(unsigned __int8 *)(net + 8LL * v22 + 263192));
json_object_set_isra_0(v24, (__int64)"opInIdx", v19);
v20 = net_in_name((unsigned __int16)v22);
v21 = json_string(v20);
json_object_set_isra_0(v24, (__int64)"opInName", v21);
}
}
++v13;
json_object_set_isra_0(v23, (__int64)"target", v24);
json_array_append_isra_0(v38, v23);
}
while ( v1[1] > v13 );
}
v30 = (__int64 (__fastcall *)(unsigned __int8 *, char *))*((_QWORD *)v1 + 3);
if ( v30 )
{
v31 = v44;
v32 = v30(v1, v44) - (_QWORD)v44;
if ( (int)v32 > 0 )
{
v33 = &v44[(unsigned int)(v32 - 1) + 1];
do
{
v34 = (unsigned __int8)*v31++;
v35 = json_integer(v34);
json_array_append_isra_0(v40, v35);
}
while ( v33 != v31 );
}
}
json_object_set_isra_0(v42, (__int64)"ins", v41);
json_object_set_isra_0(v42, (__int64)"outs", v38);
json_object_set_isra_0(v42, (__int64)"state", v40);
json_array_append_isra_0(v43, v42);
v0 = net;
++v39;
}
while ( *(unsigned __int16 *)(net + 263180LL) > (int)v39 );
}
return v43;
}

original_code:
static json_t* net_write_json_ops(void) {
  json_t* ops = json_array();
  int i, j;
  u8 bin[0x10000];
  u8* dst;
  int binCount;
  for(i=0; i<net->numOps; ++i) {
    op_t* op = net->ops[i];
    json_t* o;
    json_t* p;
    json_t* q;
    json_t* ins = json_array();
    json_t* outs = json_array();
    json_t* state = json_array();
    o = json_object();
    json_object_set(o, "index", json_integer(i));
    json_object_set(o, "class", json_integer(op->type));
    json_object_set(o, "name", json_string(op->opString));
    for(j=0; j< (op->numInputs); ++j) {
      int inIdx = net_op_in_idx(i, j);
      p = json_object();
      json_object_set(p, "name", json_string( net_in_name(inIdx) ) );
      json_object_set(p, "value", json_integer(net_get_in_value(inIdx)) );
      json_array_append(ins, p);
    }
    for(j=0; j<op->numOutputs; ++j) {
      int outIdx = net_op_out_idx(i, j);
      int target = net_get_target(outIdx);
      p = json_object();
      q = json_object();
      json_object_set(p, "name", json_string( net_out_name(outIdx) ) );
      if(target == -1) {
 json_object_set(q, "inIdx", json_integer( -1 ) );
      } else {
 int inOpIdx = net_in_op_idx(target);
 if(inOpIdx < 0) {
   json_object_set( q, "paramName", json_string( net_in_name(target) ) );
 } else {
   json_object_set( q, "opIdx", json_integer( inOpIdx ) );
   json_object_set( q, "opName", json_string( net_op_name(net_in_op_idx(target)) ) );
   json_object_set( q, "opInIdx", json_integer( net->ins[target].opInIdx ) );
   json_object_set( q, "opInName", json_string( net_in_name(target) ) );
 }
      }
      json_object_set(p, "target", q);
      json_array_append(outs, p);
    }
    if(op->pickle == ((void *)0)) {
      binCount = 0;
    } else {
      dst = bin;
      dst = (*(op->pickle))(op, dst);
      binCount = (size_t)dst - (size_t)(bin);
    }
    for(j=0; j<binCount; j++) {
      json_array_append(state, json_integer(bin[j]));
    }
    json_object_set(o, "ins", ins);
    json_object_set(o, "outs", outs);
    json_object_set(o, "state", state);
    json_array_append(ops, o);
  }
  return ops;
}

canonical_original_code:
static struct json_t *net_write_json_ops() {
  struct json_t *ops = json_array();
  int i; int j;
  unsigned char bin[65536];
  unsigned char *dst;
  int binCount;
  for(i=0; i<net->numOps; ++i) {
    struct op_struct *op = net->ops[i];
    struct json_t *o;
    struct json_t *p;
    struct json_t *q;
    struct json_t *ins = json_array();
    struct json_t *outs = json_array();
    struct json_t *state = json_array();
    o = json_object();
    json_object_set(o, "index", json_integer(i));
    json_object_set(o, "class", json_integer(op->type));
    json_object_set(o, "name", json_string(op->opString));
    for(j=0; j< (op->numInputs); ++j) {
      int inIdx = net_op_in_idx(i, j);
      p = json_object();
      json_object_set(p, "name", json_string( net_in_name(inIdx) ) );
      json_object_set(p, "value", json_integer(net_get_in_value(inIdx)) );
      json_array_append(ins, p);
    }
    for(j=0; j<op->numOutputs; ++j) {
      int outIdx = net_op_out_idx(i, j);
      int target = net_get_target(outIdx);
      p = json_object();
      q = json_object();
      json_object_set(p, "name", json_string( net_out_name(outIdx) ) );
      if(target == -1) {
 json_object_set(q, "inIdx", json_integer( -1 ) );
      } else {
 int inOpIdx = net_in_op_idx(target);
 if(inOpIdx < 0) {
   json_object_set( q, "paramName", json_string( net_in_name(target) ) );
 } else {
   json_object_set( q, "opIdx", json_integer( inOpIdx ) );
   json_object_set( q, "opName", json_string( net_op_name(net_in_op_idx(target)) ) );
   json_object_set( q, "opInIdx", json_integer( net->ins[target].opInIdx ) );
   json_object_set( q, "opInName", json_string( net_in_name(target) ) );
 }
      }
      json_object_set(p, "target", q);
      json_array_append(outs, p);
    }
    if(op->pickle == ((void *)0)) {
      binCount = 0;
    } else {
      dst = bin;
      dst = (*(op->pickle))(op, dst);
      binCount = (unsigned long)dst - (unsigned long)(bin);
    }
    for(j=0; j<binCount; j++) {
      json_array_append(state, json_integer(bin[j]));
    }
    json_object_set(o, "ins", ins);
    json_object_set(o, "outs", outs);
    json_object_set(o, "state", state);
    json_array_append(ops, o);
  }
  return ops;
}

variable_types:
bin
unsigned char [65536]

variable_types:
dst
unsigned char *

variable_types: binCount int

variable_types: struct op_struct { unsigned char numInputs; unsigned char numOutputs; void (*inc_fn)(void *op, short idx, short inc); void (**in_fn)(void *op, short input); unsigned char *(*pickle)(void *op, unsigned char *dst); unsigned char *(*unpickle)(void *op, unsigned char *src); short **in_val; short *out; char *opString; char *inString; char *outString; unsigned int type; unsigned int flags; void *child; } *

variable_types: inIdx int

variable_types: outIdx int

variable_types: inOpIdx int


decompiled_code:
__int64 net_write_json_scene()
{
__int64 v0; // r12
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // r13
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // r13
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax

v0 = json_object();
v1 = json_string(sceneData);
json_object_set_isra_0(v0, (__int64)"sceneName", v1);
v2 = json_string(sceneData + 24LL);
json_object_set_isra_0(v0, (__int64)"moduleName", v2);
v3 = json_object();
v4 = json_integer(*(unsigned __int8 *)(sceneData + 48LL));
json_object_set_isra_0(v3, (__int64)"maj", v4);
v5 = json_integer(*(unsigned __int8 *)(sceneData + 49LL));
json_object_set_isra_0(v3, (__int64)"min", v5);
v6 = json_integer(*(unsigned __int16 *)(sceneData + 50LL));
json_object_set_isra_0(v3, (__int64)"rev", v6);
json_object_set_isra_0(v0, (__int64)"moduleVersion", v3);
v7 = json_object();
v8 = json_integer(*(unsigned __int8 *)(sceneData + 52LL));
json_object_set_isra_0(v7, (__int64)"maj", v8);
v9 = json_integer(*(unsigned __int8 *)(sceneData + 53LL));
json_object_set_isra_0(v7, (__int64)"min", v9);
v10 = json_integer(*(unsigned __int16 *)(sceneData + 54LL));
json_object_set_isra_0(v7, (__int64)"rev", v10);
json_object_set_isra_0(v0, (__int64)"beesVersion", v7);
return v0;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 v0; // r12
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // r13
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // r13
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax

v0 = json_object();
v1 = json_string(sceneData);
func2(v0, (__int64)"sceneName", v1);
v2 = json_string(sceneData + 24LL);
func2(v0, (__int64)"moduleName", v2);
v3 = json_object();
v4 = json_integer(*(unsigned __int8 *)(sceneData + 48LL));
func2(v3, (__int64)"maj", v4);
v5 = json_integer(*(unsigned __int8 *)(sceneData + 49LL));
func2(v3, (__int64)"min", v5);
v6 = json_integer(*(unsigned __int16 *)(sceneData + 50LL));
func2(v3, (__int64)"rev", v6);
func2(v0, (__int64)"moduleVersion", v3);
v7 = json_object();
v8 = json_integer(*(unsigned __int8 *)(sceneData + 52LL));
func2(v7, (__int64)"maj", v8);
v9 = json_integer(*(unsigned __int8 *)(sceneData + 53LL));
func2(v7, (__int64)"min", v9);
v10 = json_integer(*(unsigned __int16 *)(sceneData + 54LL));
func2(v7, (__int64)"rev", v10);
func2(v0, (__int64)"beesVersion", v7);
return v0;
}

original_code:
static json_t* net_write_json_scene(void) {
  json_t* o = json_object();
  json_t* p;
  json_object_set(o, "sceneName", json_string(sceneData->desc.sceneName));
  json_object_set(o, "moduleName", json_string(sceneData->desc.moduleName));
  p = json_object();
  json_object_set(p, "maj", json_integer(sceneData->desc.moduleVersion.maj));
  json_object_set(p, "min", json_integer(sceneData->desc.moduleVersion.min));
  json_object_set(p, "rev", json_integer(sceneData->desc.moduleVersion.rev));
  json_object_set(o, "moduleVersion", p);
  p = json_object();
  json_object_set(p, "maj", json_integer(sceneData->desc.beesVersion.maj));
  json_object_set(p, "min", json_integer(sceneData->desc.beesVersion.min));
  json_object_set(p, "rev", json_integer(sceneData->desc.beesVersion.rev));
  json_object_set(o, "beesVersion", p);
  return o;
}

canonical_original_code:
static struct json_t *net_write_json_scene() {
  struct json_t *o = json_object();
  struct json_t *p;
  json_object_set(o, "sceneName", json_string(sceneData->desc.sceneName));
  json_object_set(o, "moduleName", json_string(sceneData->desc.moduleName));
  p = json_object();
  json_object_set(p, "maj", json_integer(sceneData->desc.moduleVersion.maj));
  json_object_set(p, "min", json_integer(sceneData->desc.moduleVersion.min));
  json_object_set(p, "rev", json_integer(sceneData->desc.moduleVersion.rev));
  json_object_set(o, "moduleVersion", p);
  p = json_object();
  json_object_set(p, "maj", json_integer(sceneData->desc.beesVersion.maj));
  json_object_set(p, "min", json_integer(sceneData->desc.beesVersion.min));
  json_object_set(p, "rev", json_integer(sceneData->desc.beesVersion.rev));
  json_object_set(o, "beesVersion", p);
  return o;
}


decompiled_code:
__int64 __fastcall net_write_json_native(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax

v1 = json_object();
v2 = net_write_json_scene();
json_object_set_isra_0(v1, (__int64)"scene", v2);
v3 = net_write_json_ops();
json_object_set_isra_0(v1, (__int64)"operators", v3);
v4 = net_write_json_params();
json_object_set_isra_0(v1, (__int64)"params", v4);
v5 = net_write_json_presets();
json_object_set_isra_0(v1, (__int64)"presets", v5);
return json_dump_file(v1, a1, 1284LL);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax

v1 = json_object();
v2 = func6();
func2(v1, (__int64)"scene", v2);
v3 = func5();
func2(v1, (__int64)"operators", v3);
v4 = func4();
func2(v1, (__int64)"params", v4);
v5 = func3();
func2(v1, (__int64)"presets", v5);
return json_dump_file(v1, a1, 1284LL);
}

original_code:
void net_write_json_native(const char* name) {
  json_t *root;
  root = json_object();
  json_object_set(root, "scene", net_write_json_scene());
  json_object_set(root, "operators", net_write_json_ops());
  json_object_set(root, "params", net_write_json_params());
  json_object_set(root, "presets", net_write_json_presets());
  json_dump_file(root, name, ((4) & 0x1F) | 0x100 | 0x400);
}

canonical_original_code:
void net_write_json_native(char *name) {
  struct json_t *root;
  root = json_object();
  json_object_set(root, "scene", net_write_json_scene());
  json_object_set(root, "operators", net_write_json_ops());
  json_object_set(root, "params", net_write_json_params());
  json_object_set(root, "presets", net_write_json_presets());
  json_dump_file(root, name, ((4) & 0x1F) | 0x100 | 0x400);
}

variable_types:
name
char *


decompiled_code:
size_t __fastcall net_write_dot(FILE *stream)
{
unsigned int v1; // er13
__int64 v3; // rax
unsigned __int8 *v4; // rbp
const char *v5; // rax
unsigned int v6; // ebx
__int64 v7; // rsi
unsigned int v8; // er14
unsigned __int16 v9; // ax
const char *v10; // rax
int v11; // eax
unsigned int v12; // ebx
__int64 v13; // rsi
unsigned int v14; // er14
unsigned __int16 v15; // ax
const char *v16; // rax
int v17; // eax
int v18; // ebx
const char *v19; // rax
__int64 v20; // rcx
unsigned int v21; // er14
int v22; // ebx
int v23; // edi

v1 = 0;
fwrite(
"digraph g { \t\t\t\t\r\n"
"\tgraph[rankdir=\"LR\"]; \t\t\r\n"
"\tnode[ \t\t\t\r\n"
"\tfontsize=\"10\" \t\r\n"
"\tshape= \"ellipse\" ];\t\r\n"
"\tedge[]; \t\t\r\n",
1uLL,
0x6EuLL,
stream);
v3 = net;
if ( *(_WORD *)(net + 263180LL) )
{
do
{
v4 = *(unsigned __int8 **)(v3 + 8LL * (int)v1);
v5 = (const char *)net_op_name(v1);
fprintf(stream, "\r\n \"node%d\" [ \r\n label = \"<f0> %d.%s ", v1, v1, v5);
if ( *v4 )
{
fwrite(" | ", 1uLL, 3uLL, stream);
if ( *v4 )
{
v12 = 0;
do
{
v13 = v12;
v14 = v12++;
v15 = net_op_in_idx(v1, v13);
v16 = (const char *)net_in_name(v15);
fprintf(stream, "<f%d> -- %d.%s ", v12, v14, v16);
v17 = *v4;
if ( v17 - 1 > (int)v14 )
{
fwrite(" | ", 1uLL, 3uLL, stream);
v17 = *v4;
}
}
while ( (int)v12 < v17 );
}
}
if ( v4[1] )
{
fwrite(" | ", 1uLL, 3uLL, stream);
if ( v4[1] )
{
v6 = 0;
do
{
v7 = v6;
v8 = v6++;
v9 = net_op_out_idx(v1, v7);
v10 = (const char *)net_out_name(v9);
fprintf(stream, "<f%d> %d.%s -- ", v6 + *v4, v8, v10);
v11 = v4[1];
if ( v11 - 1 > (int)v8 )
{
fwrite(" | ", 1uLL, 3uLL, stream);
v11 = v4[1];
}
}
while ( (int)v6 < v11 );
}
}
fwrite("\" \r\nshape = \"record\" \r\n]; \r\n", 1uLL, 0x1CuLL, stream);
v3 = net;
++v1;
}
while ( *(unsigned __int16 *)(net + 263180LL) > (int)v1 );
}
v18 = 0;
fwrite("\r\n", 1uLL, 2uLL, stream);
while ( 1 )
{
v21 = v1 + v18;
if ( (unsigned __int16)net_num_params() <= v18 )
break;
v19 = (const char *)get_param_name((unsigned int)v18);
v20 = (unsigned int)v18++;
fprintf(stream, "\r\n\"node%d\" [\r\n label = \"<f0> %d.%s \"\r\nshape = \"record\" \r\n ];", v21, v20, v19);
}
v22 = 0;
fwrite("\r\n", 1uLL, 2uLL, stream);
fwrite("\r\n", 1uLL, 2uLL, stream);
fwrite("\r\n", 1uLL, 2uLL, stream);
if ( *(_WORD *)(net + 263184LL) )
{
do
{
while ( 1 )
{
v23 = (__int16)net_get_target((unsigned int)v22);
if ( v23 >= 0 && *(unsigned __int16 *)(net + 263182LL) > v23 )
break;
if ( *(unsigned __int16 *)(net + 263184LL) <= ++v22 )
return fwrite("\r\n}", 1uLL, 3uLL, stream);
}
net_in_op_idx();
++v22;
}
while ( *(unsigned __int16 *)(net + 263184LL) > v22 );
}
return fwrite("\r\n}", 1uLL, 3uLL, stream);
}

canonical_decompiled_code:
size_t __fastcall func0(FILE *stream)
{
unsigned int v1; // er13
__int64 v3; // rax
unsigned __int8 *v4; // rbp
const char *v5; // rax
unsigned int v6; // ebx
__int64 v7; // rsi
unsigned int v8; // er14
unsigned __int16 v9; // ax
const char *v10; // rax
int v11; // eax
unsigned int v12; // ebx
__int64 v13; // rsi
unsigned int v14; // er14
unsigned __int16 v15; // ax
const char *v16; // rax
int v17; // eax
int v18; // ebx
const char *v19; // rax
__int64 v20; // rcx
unsigned int v21; // er14
int v22; // ebx
int v23; // edi

v1 = 0;
fwrite(
"digraph g { \t\t\t\t\r\n"
"\tgraph[rankdir=\"LR\"]; \t\t\r\n"
"\tnode[ \t\t\t\r\n"
"\tfontsize=\"10\" \t\r\n"
"\tshape= \"ellipse\" ];\t\r\n"
"\tedge[]; \t\t\r\n",
1uLL,
0x6EuLL,
stream);
v3 = net;
if ( *(_WORD *)(net + 263180LL) )
{
do
{
v4 = *(unsigned __int8 **)(v3 + 8LL * (int)v1);
v5 = (const char *)net_op_name(v1);
fprintf(stream, "\r\n \"node%d\" [ \r\n label = \"<f0> %d.%s ", v1, v1, v5);
if ( *v4 )
{
fwrite(" | ", 1uLL, 3uLL, stream);
if ( *v4 )
{
v12 = 0;
do
{
v13 = v12;
v14 = v12++;
v15 = net_op_in_idx(v1, v13);
v16 = (const char *)net_in_name(v15);
fprintf(stream, "<f%d> -- %d.%s ", v12, v14, v16);
v17 = *v4;
if ( v17 - 1 > (int)v14 )
{
fwrite(" | ", 1uLL, 3uLL, stream);
v17 = *v4;
}
}
while ( (int)v12 < v17 );
}
}
if ( v4[1] )
{
fwrite(" | ", 1uLL, 3uLL, stream);
if ( v4[1] )
{
v6 = 0;
do
{
v7 = v6;
v8 = v6++;
v9 = net_op_out_idx(v1, v7);
v10 = (const char *)net_out_name(v9);
fprintf(stream, "<f%d> %d.%s -- ", v6 + *v4, v8, v10);
v11 = v4[1];
if ( v11 - 1 > (int)v8 )
{
fwrite(" | ", 1uLL, 3uLL, stream);
v11 = v4[1];
}
}
while ( (int)v6 < v11 );
}
}
fwrite("\" \r\nshape = \"record\" \r\n]; \r\n", 1uLL, 0x1CuLL, stream);
v3 = net;
++v1;
}
while ( *(unsigned __int16 *)(net + 263180LL) > (int)v1 );
}
v18 = 0;
fwrite("\r\n", 1uLL, 2uLL, stream);
while ( 1 )
{
v21 = v1 + v18;
if ( (unsigned __int16)net_num_params() <= v18 )
break;
v19 = (const char *)get_param_name((unsigned int)v18);
v20 = (unsigned int)v18++;
fprintf(stream, "\r\n\"node%d\" [\r\n label = \"<f0> %d.%s \"\r\nshape = \"record\" \r\n ];", v21, v20, v19);
}
v22 = 0;
fwrite("\r\n", 1uLL, 2uLL, stream);
fwrite("\r\n", 1uLL, 2uLL, stream);
fwrite("\r\n", 1uLL, 2uLL, stream);
if ( *(_WORD *)(net + 263184LL) )
{
do
{
while ( 1 )
{
v23 = (__int16)net_get_target((unsigned int)v22);
if ( v23 >= 0 && *(unsigned __int16 *)(net + 263182LL) > v23 )
break;
if ( *(unsigned __int16 *)(net + 263184LL) <= ++v22 )
return fwrite("\r\n}", 1uLL, 3uLL, stream);
}
net_in_op_idx();
++v22;
}
while ( *(unsigned __int16 *)(net + 263184LL) > v22 );
}
return fwrite("\r\n}", 1uLL, 3uLL, stream);
}

original_code:
void net_write_dot(void* fp) {
  int i, j, k;
  int nId = 0;
  int eId = 0;
  int t;
  fprintf(fp,
   "digraph g { 				\r\n"
   "	graph[rankdir=\"LR\"]; 		\r\n"
   "	node[ 			\r\n"
   "	fontsize=\"10\" 	\r\n"
   "	shape= \"ellipse\" ];	\r\n"
   "	edge[]; 		\r\n"
   );
  for(i=0; i<net->numOps; ++i) {
    op_t* op = net->ops[i];
    fprintf(fp, "\r\n"
     " \"node%d\" [ \r\n"
     " label = \"<f0> %d.%s ",
     i, i, net_op_name(i));
    if(op->numInputs > 0) {
      fprintf(fp, " | ");
    }
    for(j=0; j< (op->numInputs); ++j) {
      fprintf(fp,
       "<f%d> -- %d.%s ",
       j+1, j, net_in_name(net_op_in_idx(i, j)) );
      if(j < ((op->numInputs) - 1)) {
 fprintf(fp, " | ");
      }
    }
    if(op->numOutputs > 0) {
      fprintf(fp, " | ");
    }
    for(j=0; j< (op->numOutputs); ++j) {
      fprintf(fp,
       "<f%d> %d.%s -- ",
       j+1 + op->numInputs, j, net_out_name(net_op_out_idx(i, j)));
      if(j < ((op->numOutputs) - 1)) {
 fprintf(fp, " | ");
      }
    }
    fprintf(fp,
     "\" \r\n"
     "shape = \"record\" \r\n"
     "]; \r\n" );
    nId++;
  }
  fprintf(fp, "\r\n");
  for(i=0; i<net_num_params(); i++ ) {
    fprintf(fp, "\r\n"
     "\"node%d\" [\r\n"
     " label = \"<f0> %d.%s \"\r\n"
     "shape = \"record\" \r\n ];",
     nId, i, get_param_name(i)
     );
    nId++;
  }
  fprintf(fp, "\r\n");
  fprintf(fp, "\r\n");
  fprintf(fp, "\r\n");
  for(i=0; i<net->numOuts; i++) {
    t = net_get_target(i);
    if( t > -1) {
      if( t < net->numIns) {
 j = net_in_op_idx(t);
 k = net->ins[t].opInIdx;
      } else {
      }
    }
    eId++;
  }
  fprintf(fp, "\r\n}");
}

canonical_original_code:
void net_write_dot(void *fp) {
  int i; int j; int k;
  int nId = 0;
  int eId = 0;
  int t;
  fprintf(fp,
   "digraph g { 				\r\n"
   "	graph[rankdir=\"LR\"]; 		\r\n"
   "	node[ 			\r\n"
   "	fontsize=\"10\" 	\r\n"
   "	shape= \"ellipse\" ];	\r\n"
   "	edge[]; 		\r\n"
   );
  for(i=0; i<net->numOps; ++i) {
    struct op_struct *op = net->ops[i];
    fprintf(fp, "\r\n"
     " \"node%d\" [ \r\n"
     " label = \"<f0> %d.%s ",
     i, i, net_op_name(i));
    if(op->numInputs > 0) {
      fprintf(fp, " | ");
    }
    for(j=0; j< (op->numInputs); ++j) {
      fprintf(fp,
       "<f%d> -- %d.%s ",
       j+1, j, net_in_name(net_op_in_idx(i, j)) );
      if(j < ((op->numInputs) - 1)) {
 fprintf(fp, " | ");
      }
    }
    if(op->numOutputs > 0) {
      fprintf(fp, " | ");
    }
    for(j=0; j< (op->numOutputs); ++j) {
      fprintf(fp,
       "<f%d> %d.%s -- ",
       j+1 + op->numInputs, j, net_out_name(net_op_out_idx(i, j)));
      if(j < ((op->numOutputs) - 1)) {
 fprintf(fp, " | ");
      }
    }
    fprintf(fp,
     "\" \r\n"
     "shape = \"record\" \r\n"
     "]; \r\n" );
    nId++;
  }
  fprintf(fp, "\r\n");
  for(i=0; i<net_num_params(); i++ ) {
    fprintf(fp, "\r\n"
     "\"node%d\" [\r\n"
     " label = \"<f0> %d.%s \"\r\n"
     "shape = \"record\" \r\n ];",
     nId, i, get_param_name(i)
     );
    nId++;
  }
  fprintf(fp, "\r\n");
  fprintf(fp, "\r\n");
  fprintf(fp, "\r\n");
  for(i=0; i<net->numOuts; i++) {
    t = net_get_target(i);
    if( t > -1) {
      if( t < net->numIns) {
 j = net_in_op_idx(t);
 k = net->ins[t].opInIdx;
      } else {
      }
    }
    eId++;
  }
  fprintf(fp, "\r\n}");
}

variable_types:
fp
void *

variable_types: k int

variable_types: nId int

variable_types: eId int

variable_types: t int

user_defined_types: struct op_struct { unsigned char numInputs; unsigned char numOutputs; void (*inc_fn)(void *op, short idx, short inc); void (**in_fn)(void *op, short input); unsigned char *(*pickle)(void *op, unsigned char *dst); unsigned char *(*unpickle)(void *op, unsigned char *src); short **in_val; short *out; char *opString; char *inString; char *outString; unsigned int type; unsigned int flags; void *child; }


decompiled_code:
__int64 __fastcall fix16_sin_parabola(int a1)
{
int v1; // ebx
unsigned int v2; // eax
int v3; // ebx
int v4; // eax

v1 = fix16_mul(83443LL, (unsigned int)a1);
v2 = fix16_mul(4294940736LL, (unsigned int)a1);
v3 = fix16_mul(v2, (a1 >> 31) ^ (unsigned int)(a1 + (a1 >> 31))) + v1;
v4 = fix16_mul((unsigned int)v3, (v3 >> 31) ^ (unsigned int)(v3 + (v3 >> 31)));
return v3 + (unsigned int)fix16_mul(14746LL, (unsigned int)(v4 - v3));
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
int v1; // ebx
unsigned int v2; // eax
int v3; // ebx
int v4; // eax

v1 = fix16_mul(83443LL, (unsigned int)a1);
v2 = fix16_mul(4294940736LL, (unsigned int)a1);
v3 = fix16_mul(v2, (a1 >> 31) ^ (unsigned int)(a1 + (a1 >> 31))) + v1;
v4 = fix16_mul((unsigned int)v3, (v3 >> 31) ^ (unsigned int)(v3 + (v3 >> 31)));
return v3 + (unsigned int)fix16_mul(14746LL, (unsigned int)(v4 - v3));
}

original_code:
fix16_t fix16_sin_parabola(fix16_t inAngle)
{
 fix16_t abs_inAngle, abs_retval, retval;
 fix16_t mask;
 mask = (inAngle >> (sizeof(fix16_t)*8 -1));
 abs_inAngle = (inAngle + mask) ^ mask;
 retval = fix16_mul(FOUR_DIV_PI, inAngle) + fix16_mul( fix16_mul(_FOUR_DIV_PI2, inAngle), abs_inAngle );
 mask = (retval >> (sizeof(fix16_t)*8 -1));
 abs_retval = (retval + mask) ^ mask;
 retval += fix16_mul(X4_CORRECTION_COMPONENT, fix16_mul(retval, abs_retval) - retval );
 return retval;
}

canonical_original_code:
int fix16_sin_parabola(int inAngle)
{
 int abs_inAngle; int abs_retval; int retval;
 int mask;
 mask = (inAngle >> (sizeof(fix16_t)*8 -1));
 abs_inAngle = (inAngle + mask) ^ mask;
 retval = fix16_mul(FOUR_DIV_PI, inAngle) + fix16_mul( fix16_mul(_FOUR_DIV_PI2, inAngle), abs_inAngle );
 mask = (retval >> (sizeof(fix16_t)*8 -1));
 abs_retval = (retval + mask) ^ mask;
 retval += fix16_mul(X4_CORRECTION_COMPONENT, fix16_mul(retval, abs_retval) - retval );
 return retval;
}

variable_types: inAngle int

variable_types: retval int

variable_types: mask int


decompiled_code:
__int64 __fastcall fix16_sin(int a1)
{
unsigned int v1; // ebx
__int64 v2; // r12
unsigned int v3; // er14
unsigned int v4; // eax
int v5; // er13
int v6; // eax
unsigned int v7; // er13
int v8; // ebx
int v9; // eax
unsigned int v10; // ebx
int v11; // er13
unsigned int v12; // eax
int v13; // er13
int v14; // eax
__int64 result; // rax

v1 = a1 % 411774;
if ( a1 % 411774 <= 205887 )
{
if ( (int)v1 < -205887 )
v1 += 411774;
}
else
{
v1 -= 411774;
}
v2 = (a1 >> 5) & 0xFFF;
if ( fix16_sin_cache_index[v2] == a1 )
return (unsigned int)fix16_sin_cache_value[v2];
v3 = fix16_mul(v1, v1);
v4 = fix16_mul(v1, v3);
v5 = (int)v4 / -6;
v6 = fix16_mul(v4, v3);
v7 = v1 + v5;
v8 = v6 / 120;
v9 = fix16_mul(v6, v3);
v10 = v7 + v8;
v11 = v9 / -5040;
v12 = fix16_mul(v9, v3);
v13 = (int)v12 / 362880 + v10 + v11;
v14 = fix16_mul(v12, v3);
fix16_sin_cache_index[v2] = a1;
result = (unsigned int)(v13 + v14 / -39916800);
fix16_sin_cache_value[v2] = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
unsigned int v1; // ebx
__int64 v2; // r12
unsigned int v3; // er14
unsigned int v4; // eax
int v5; // er13
int v6; // eax
unsigned int v7; // er13
int v8; // ebx
int v9; // eax
unsigned int v10; // ebx
int v11; // er13
unsigned int v12; // eax
int v13; // er13
int v14; // eax
__int64 result; // rax

v1 = a1 % 411774;
if ( a1 % 411774 <= 205887 )
{
if ( (int)v1 < -205887 )
v1 += 411774;
}
else
{
v1 -= 411774;
}
v2 = (a1 >> 5) & 0xFFF;
if ( fix16_sin_cache_index[v2] == a1 )
return (unsigned int)fix16_sin_cache_value[v2];
v3 = fix16_mul(v1, v1);
v4 = fix16_mul(v1, v3);
v5 = (int)v4 / -6;
v6 = fix16_mul(v4, v3);
v7 = v1 + v5;
v8 = v6 / 120;
v9 = fix16_mul(v6, v3);
v10 = v7 + v8;
v11 = v9 / -5040;
v12 = fix16_mul(v9, v3);
v13 = (int)v12 / 362880 + v10 + v11;
v14 = fix16_mul(v12, v3);
fix16_sin_cache_index[v2] = a1;
result = (unsigned int)(v13 + v14 / -39916800);
fix16_sin_cache_value[v2] = result;
return result;
}

original_code:
fix16_t fix16_sin(fix16_t inAngle) {
 fix16_t tempAngle = inAngle % (fix16_pi << 1);
 if(tempAngle > fix16_pi)
  tempAngle -= (fix16_pi << 1);
 else if(tempAngle < -fix16_pi)
  tempAngle += (fix16_pi << 1);
 fix16_t tempIndex = ((inAngle >> 5) & 0x00000FFF);
 if(_fix16_sin_cache_index[tempIndex] == inAngle)
  return _fix16_sin_cache_value[tempIndex];
 fix16_t tempAngleSq = fix16_mul(tempAngle, tempAngle);
 fix16_t tempOut = tempAngle;
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut -= (tempAngle / 6);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut += (tempAngle / 120);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut -= (tempAngle / 5040);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut += (tempAngle / 362880);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut -= (tempAngle / 39916800);
 _fix16_sin_cache_index[tempIndex] = inAngle;
 _fix16_sin_cache_value[tempIndex] = tempOut;
 return tempOut;
}

canonical_original_code:
int fix16_sin(int inAngle) {
 int tempAngle = inAngle % (fix16_pi << 1);
 if(tempAngle > fix16_pi)
  tempAngle -= (fix16_pi << 1);
 else if(tempAngle < -fix16_pi)
  tempAngle += (fix16_pi << 1);
 int tempIndex = ((inAngle >> 5) & 0x00000FFF);
 if(_fix16_sin_cache_index[tempIndex] == inAngle)
  return _fix16_sin_cache_value[tempIndex];
 int tempAngleSq = fix16_mul(tempAngle, tempAngle);
 int tempOut = tempAngle;
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut -= (tempAngle / 6);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut += (tempAngle / 120);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut -= (tempAngle / 5040);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut += (tempAngle / 362880);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut -= (tempAngle / 39916800);
 _fix16_sin_cache_index[tempIndex] = inAngle;
 _fix16_sin_cache_value[tempIndex] = tempOut;
 return tempOut;
}

variable_types: tempAngle int

variable_types: tempIndex int

variable_types: tempAngleSq int

variable_types: tempOut int


decompiled_code:
__int64 __fastcall fix16_cos(int a1)
{
return fix16_sin(a1 + 102943);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
return func1(a1 + 102943);
}

original_code:
fix16_t fix16_cos(fix16_t inAngle) {
 return fix16_sin(inAngle + (fix16_pi >> 1));
}

canonical_original_code:
int fix16_cos(int inAngle) {
 return fix16_sin(inAngle + (fix16_pi >> 1));
}


decompiled_code:
__int64 __fastcall fix16_tan(int a1)
{
unsigned int v1; // er12
unsigned int v2; // eax

v1 = fix16_cos(a1);
v2 = fix16_sin(a1);
return fix16_sdiv(v2, v1);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1)
{
unsigned int v1; // er12
unsigned int v2; // eax

v1 = func2(a1);
v2 = func1(a1);
return fix16_sdiv(v2, v1);
}

original_code:
fix16_t fix16_tan(fix16_t inAngle) {
 return fix16_sdiv(fix16_sin(inAngle), fix16_cos(inAngle));
}

canonical_original_code:
int fix16_tan(int inAngle) {
 return fix16_sdiv(fix16_sin(inAngle), fix16_cos(inAngle));
}


decompiled_code:
__int64 __fastcall fix16_atan2(int a1, int a2)
{
__int64 v4; // rbp
__int64 v5; // r14
int v6; // esi
__int64 v7; // rdi
unsigned int v8; // er15
unsigned int v9; // eax
unsigned int v10; // eax
int v11; // ebx
__int64 result; // rax
unsigned int v13; // er15
unsigned int v14; // eax
unsigned int v15; // eax
int v16; // ebx

v4 = ((unsigned __int16)(a1 ^ a2) ^ (unsigned __int16)((unsigned __int64)(a1 ^ a2) >> 20)) & 0xFFF;
v5 = v4 + 4096;
if ( fix16_atan_cache_index[v4] == a2 && fix16_atan_cache_index[v5] == a1 )
return (unsigned int)fix16_atan_cache_value[v4];
v6 = (a1 >> 31) ^ (a1 + (a1 >> 31));
v7 = (unsigned int)(a2 + v6);
if ( a2 < 0 )
{
v13 = fix16_div(v7, (unsigned int)(v6 - a2));
v14 = fix16_mul(v13, v13);
v15 = fix16_mul(v14, v13);
v16 = fix16_mul(12864LL, v15);
result = v16 - (unsigned int)fix16_mul(64336LL, v13) + 154415;
}
else
{
v8 = fix16_div((unsigned int)(a2 - v6), (unsigned int)v7);
v9 = fix16_mul(v8, v8);
v10 = fix16_mul(v9, v8);
v11 = fix16_mul(12864LL, v10);
result = v11 - (unsigned int)fix16_mul(64336LL, v8) + 51471;
}
fix16_atan_cache_index[v4] = a2;
fix16_atan_cache_index[v5] = a1;
if ( a1 < 0 )
result = (unsigned int)-(int)result;
fix16_atan_cache_value[v4] = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2)
{
__int64 v4; // rbp
__int64 v5; // r14
int v6; // esi
__int64 v7; // rdi
unsigned int v8; // er15
unsigned int v9; // eax
unsigned int v10; // eax
int v11; // ebx
__int64 result; // rax
unsigned int v13; // er15
unsigned int v14; // eax
unsigned int v15; // eax
int v16; // ebx

v4 = ((unsigned __int16)(a1 ^ a2) ^ (unsigned __int16)((unsigned __int64)(a1 ^ a2) >> 20)) & 0xFFF;
v5 = v4 + 4096;
if ( fix16_atan_cache_index[v4] == a2 && fix16_atan_cache_index[v5] == a1 )
return (unsigned int)fix16_atan_cache_value[v4];
v6 = (a1 >> 31) ^ (a1 + (a1 >> 31));
v7 = (unsigned int)(a2 + v6);
if ( a2 < 0 )
{
v13 = fix16_div(v7, (unsigned int)(v6 - a2));
v14 = fix16_mul(v13, v13);
v15 = fix16_mul(v14, v13);
v16 = fix16_mul(12864LL, v15);
result = v16 - (unsigned int)fix16_mul(64336LL, v13) + 154415;
}
else
{
v8 = fix16_div((unsigned int)(a2 - v6), (unsigned int)v7);
v9 = fix16_mul(v8, v8);
v10 = fix16_mul(v9, v8);
v11 = fix16_mul(12864LL, v10);
result = v11 - (unsigned int)fix16_mul(64336LL, v8) + 51471;
}
fix16_atan_cache_index[v4] = a2;
fix16_atan_cache_index[v5] = a1;
if ( a1 < 0 )
result = (unsigned int)-(int)result;
fix16_atan_cache_value[v4] = result;
return result;
}

original_code:
fix16_t fix16_atan2(fix16_t inY , fix16_t inX) {
 fix16_t abs_inY, mask, angle, r, r_3;
 uintptr_t hash = (inX ^ inY);
 hash ^= hash >> 20;
 hash &= 0x0FFF;
 if((_fix16_atan_cache_index[0][hash] == inX) && (_fix16_atan_cache_index[1][hash] == inY))
  return _fix16_atan_cache_value[hash];
 mask = (inY >> (sizeof(fix16_t)*8 -1));
 abs_inY = (inY + mask) ^ mask;
 if (inX >= 0)
 {
  r = fix16_div( (inX - abs_inY), (inX + abs_inY));
  r_3 = fix16_mul(fix16_mul(r, r),r);
  angle = fix16_mul(0x00003240 , r_3) - fix16_mul(0x0000FB50,r) + PI_DIV_4;
 } else {
  r = fix16_div( (inX + abs_inY), (abs_inY - inX));
  r_3 = fix16_mul(fix16_mul(r, r),r);
  angle = fix16_mul(0x00003240 , r_3) - fix16_mul(0x0000FB50,r) + THREE_PI_DIV_4;
 }
 if (inY < 0)
 {
  angle = -angle;
 }
 _fix16_atan_cache_index[0][hash] = inX;
 _fix16_atan_cache_index[1][hash] = inY;
 _fix16_atan_cache_value[hash] = angle;
 return angle;
}

canonical_original_code:
int fix16_atan2(int inY, int inX) {
 int abs_inY; int mask; int angle; int r; int r_3;
 unsigned long hash = (inX ^ inY);
 hash ^= hash >> 20;
 hash &= 0x0FFF;
 if((_fix16_atan_cache_index[0][hash] == inX) && (_fix16_atan_cache_index[1][hash] == inY))
  return _fix16_atan_cache_value[hash];
 mask = (inY >> (sizeof(fix16_t)*8 -1));
 abs_inY = (inY + mask) ^ mask;
 if (inX >= 0)
 {
  r = fix16_div( (inX - abs_inY), (inX + abs_inY));
  r_3 = fix16_mul(fix16_mul(r, r),r);
  angle = fix16_mul(0x00003240 , r_3) - fix16_mul(0x0000FB50,r) + PI_DIV_4;
 } else {
  r = fix16_div( (inX + abs_inY), (abs_inY - inX));
  r_3 = fix16_mul(fix16_mul(r, r),r);
  angle = fix16_mul(0x00003240 , r_3) - fix16_mul(0x0000FB50,r) + THREE_PI_DIV_4;
 }
 if (inY < 0)
 {
  angle = -angle;
 }
 _fix16_atan_cache_index[0][hash] = inX;
 _fix16_atan_cache_index[1][hash] = inY;
 _fix16_atan_cache_value[hash] = angle;
 return angle;
}

variable_types: inY int

variable_types: inX int

variable_types: angle int

variable_types: r int

variable_types:
hash
unsigned long


decompiled_code:
__int64 __fastcall fix16_atan(int a1)
{
return fix16_atan2(a1, (int)&unk_10000);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
return func4(a1, (int)&unk_10000);
}

original_code:
fix16_t fix16_atan(fix16_t inValue) {
 return fix16_atan2(inValue, fix16_one);
}

canonical_original_code:
int fix16_atan(int inValue) {
 return fix16_atan2(inValue, fix16_one);
}

variable_types: inValue int


decompiled_code:
__int64 __fastcall fix16_asin(__int64 a1)
{
int v1; // eax
unsigned int v2; // eax
int v3; // eax

if ( (unsigned int)((unsigned int)&unk_10000 + a1) > 0x20000 )
return 0LL;
v1 = fix16_mul(a1, (unsigned int)a1);
v2 = fix16_sqrt((unsigned int)((_DWORD)&unk_10000 - v1));
v3 = fix16_div((unsigned int)a1, v2);
return fix16_atan(v3);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
int v1; // eax
unsigned int v2; // eax
int v3; // eax

if ( (unsigned int)((unsigned int)&unk_10000 + a1) > 0x20000 )
return 0LL;
v1 = fix16_mul(a1, (unsigned int)a1);
v2 = fix16_sqrt((unsigned int)((_DWORD)&unk_10000 - v1));
v3 = fix16_div((unsigned int)a1, v2);
return func5(v3);
}

original_code:
fix16_t fix16_asin(fix16_t inValue) {
 if((inValue > fix16_one) || (inValue < -fix16_one))
  return 0;
 fix16_t tempOut;
 tempOut = (fix16_one - fix16_mul(inValue, inValue));
 tempOut = fix16_div(inValue, fix16_sqrt(tempOut));
 tempOut = fix16_atan(tempOut);
 return tempOut;
}

canonical_original_code:
int fix16_asin(int inValue) {
 if((inValue > fix16_one) || (inValue < -fix16_one))
  return 0;
 int tempOut;
 tempOut = (fix16_one - fix16_mul(inValue, inValue));
 tempOut = fix16_div(inValue, fix16_sqrt(tempOut));
 tempOut = fix16_atan(tempOut);
 return tempOut;
}


decompiled_code:
__int64 __fastcall fix16_acos(__int64 a1)
{
return 102943 - (unsigned int)fix16_asin(a1);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return 102943 - (unsigned int)func6(a1);
}

original_code:
fix16_t fix16_acos(fix16_t inValue) {
 return ((fix16_pi >> 1) - fix16_asin(inValue));
}

canonical_original_code:
int fix16_acos(int inValue) {
 return ((fix16_pi >> 1) - fix16_asin(inValue));
}


decompiled_code:
__int64 __fastcall scaler_get_value(__int64 a1, __int16 a2)
{
__int64 (__fastcall *v2)(__int64, _QWORD); // rax

print_dbg("\r\n scaler_get_value, type: ");
print_dbg_ulong(*(unsigned int *)(*(_QWORD *)a1 + 16LL));
v2 = (__int64 (__fastcall *)(__int64, _QWORD))*(&scaler_get_val_pr + *(unsigned int *)(*(_QWORD *)a1 + 16LL));
if ( v2 )
return v2(a1, (unsigned int)a2);
print_dbg("\r\n null function pointer in scaler_get_value");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int16 a2)
{
__int64 (__fastcall *v2)(__int64, _QWORD); // rax

print_dbg("\r\n scaler_get_value, type: ");
print_dbg_ulong(*(unsigned int *)(*(_QWORD *)a1 + 16LL));
v2 = (__int64 (__fastcall *)(__int64, _QWORD))*(&scaler_get_val_pr + *(unsigned int *)(*(_QWORD *)a1 + 16LL));
if ( v2 )
return v2(a1, (unsigned int)a2);
print_dbg("\r\n null function pointer in scaler_get_value");
return 0LL;
}

original_code:
s32 scaler_get_value(ParamScaler* sc, io_t in) {
  print_dbg("\r\n scaler_get_value, type: ");
  print_dbg_ulong(sc->desc->type);
  scaler_get_value_fn fn = scaler_get_val_pr[sc->desc->type];
  if(fn != 0) {
    return (*fn)(sc, in);
  } else {
    print_dbg("\r\n null function pointer in scaler_get_value");
    return 0;
  }
}

canonical_original_code:
int scaler_get_value(struct _paramScaler *sc, short in) {
  print_dbg("\r\n scaler_get_value, type: ");
  print_dbg_ulong(sc->desc->type);
  int (*fn)(void *scaler, short in) = scaler_get_val_pr[sc->desc->type];
  if(fn != 0) {
    return (*fn)(sc, in);
  } else {
    print_dbg("\r\n null function pointer in scaler_get_value");
    return 0;
  }
}

variable_types: struct _paramScaler { struct ParamDescStruct { char label[16]; enum ParamType { eParamTypeBool=0, eParamTypeFix=1, eParamTypeAmp=2, eParamTypeIntegrator=3, eParamTypeNote=4, eParamTypeSvfFreq=5, eParamTypeFract=6, eParamTypeShort=7, eParamTypeIntegratorShort=8, eParamNumTypes=9 } type; int min; int max; unsigned char radix; } *desc; short inMin; short inMax; } *

variable_types: in short

variable_types:
fn
int (*)(void *scaler, short in)

user_defined_types: struct _paramScaler { struct ParamDescStruct *desc; short inMin; short inMax; }

user_defined_types: struct ParamDescStruct { char label[16]; enum ParamType type; int min; int max; unsigned char radix; }


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

v2 = 0;
v3 = (__int64 (*)(void))*(&scaler_get_in_pr + *(unsigned int *)(*(_QWORD *)a1 + 16LL));
if ( v3 )
{
v2 = v3();
print_dbg("\r\n getting input value for scaler. ");
print_dbg(" param type from desc: ");
print_dbg_ulong(*(unsigned int *)(*(_QWORD *)a1 + 16LL));
print_dbg(", default DSP value: 0x");
print_dbg_hex(a2);
print_dbg(", setting input node: 0x");
print_dbg_hex((__int16)v2);
}
return v2;
}

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

v2 = 0;
v3 = (__int64 (*)(void))*(&scaler_get_in_pr + *(unsigned int *)(*(_QWORD *)a1 + 16LL));
if ( v3 )
{
v2 = v3();
print_dbg("\r\n getting input value for scaler. ");
print_dbg(" param type from desc: ");
print_dbg_ulong(*(unsigned int *)(*(_QWORD *)a1 + 16LL));
print_dbg(", default DSP value: 0x");
print_dbg_hex(a2);
print_dbg(", setting input node: 0x");
print_dbg_hex((__int16)v2);
}
return v2;
}

original_code:
io_t scaler_get_in(ParamScaler* sc, s32 value) {
  io_t val;
  scaler_get_in_fn fn = scaler_get_in_pr[sc->desc->type];
  if( fn != 0) {
    val = (*fn)(sc, value);
    print_dbg("\r\n getting input value for scaler. ");
    print_dbg(" param type from desc: ");
    print_dbg_ulong(sc->desc->type);
    print_dbg(", default DSP value: 0x");
    print_dbg_hex(value);
    print_dbg(", setting input node: 0x");
    print_dbg_hex(val);
    return val;
  } else {
    return 0;
  }
}

canonical_original_code:
short scaler_get_in(struct _paramScaler *sc, int value) {
  short val;
  short (*fn)(void *scaler, int value) = scaler_get_in_pr[sc->desc->type];
  if( fn != 0) {
    val = (*fn)(sc, value);
    print_dbg("\r\n getting input value for scaler. ");
    print_dbg(" param type from desc: ");
    print_dbg_ulong(sc->desc->type);
    print_dbg(", default DSP value: 0x");
    print_dbg_hex(value);
    print_dbg(", setting input node: 0x");
    print_dbg_hex(val);
    return val;
  } else {
    return 0;
  }
}

variable_types: value int

variable_types: val short

variable_types:
fn
short (*)(void *scaler, int value)

return_type: short

user_defined_types: enum ParamType { eParamTypeBool=0, eParamTypeFix=1, eParamTypeAmp=2, eParamTypeIntegrator=3, eParamTypeNote=4, eParamTypeSvfFreq=5, eParamTypeFract=6, eParamTypeShort=7, eParamTypeIntegratorShort=8, eParamNumTypes=9 }


decompiled_code:
__int64 __fastcall scaler_inc(__int64 a1, __int64 a2, __int16 a3)
{
__int64 (__fastcall *v4)(__int64, __int64, _QWORD); // r13

v4 = (__int64 (__fastcall *)(__int64, __int64, _QWORD))*(&scaler_inc_pr + *(unsigned int *)(*(_QWORD *)a1 + 16LL));
print_dbg("\r\n incrementing scaler at address 0x");
print_dbg_hex((unsigned int)a1);
print_dbg(" ; type: ");
print_dbg_ulong(*(unsigned int *)(*(_QWORD *)a1 + 16LL));
print_dbg(" ; inc function pointer: 0x");
print_dbg_hex((unsigned int)v4);
if ( v4 )
return v4(a1, a2, (unsigned int)a3);
print_dbg("\r\n error, null scaler increment");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int16 a3)
{
__int64 (__fastcall *v4)(__int64, __int64, _QWORD); // r13

v4 = (__int64 (__fastcall *)(__int64, __int64, _QWORD))*(&scaler_inc_pr + *(unsigned int *)(*(_QWORD *)a1 + 16LL));
print_dbg("\r\n incrementing scaler at address 0x");
print_dbg_hex((unsigned int)a1);
print_dbg(" ; type: ");
print_dbg_ulong(*(unsigned int *)(*(_QWORD *)a1 + 16LL));
print_dbg(" ; inc function pointer: 0x");
print_dbg_hex((unsigned int)v4);
if ( v4 )
return v4(a1, a2, (unsigned int)a3);
print_dbg("\r\n error, null scaler increment");
return 0LL;
}

original_code:
extern s32 scaler_inc(ParamScaler* sc, io_t * pin, io_t inc ) {
  scaler_inc_fn fn = scaler_inc_pr[sc->desc->type];
  print_dbg("\r\n incrementing scaler at address 0x");
  print_dbg_hex((u32)sc);
  print_dbg(" ; type: ");
  print_dbg_ulong((u32)sc->desc->type);
  print_dbg(" ; inc function pointer: 0x");
  print_dbg_hex((u32)fn);
  if( fn != 0) {
    return (*fn)(sc, pin, inc);
  } else {
    print_dbg("\r\n error, null scaler increment");
    return 0;
  }
}

canonical_original_code:
extern int scaler_inc(struct _paramScaler *sc, short *pin, short inc) {
  int (*fn)(void *scaler, short *pin, short inc) = scaler_inc_pr[sc->desc->type];
  print_dbg("\r\n incrementing scaler at address 0x");
  print_dbg_hex((unsigned int)sc);
  print_dbg(" ; type: ");
  print_dbg_ulong((unsigned int)sc->desc->type);
  print_dbg(" ; inc function pointer: 0x");
  print_dbg_hex((unsigned int)fn);
  if( fn != 0) {
    return (*fn)(sc, pin, inc);
  } else {
    print_dbg("\r\n error, null scaler increment");
    return 0;
  }
}

variable_types:
pin
short *

variable_types: inc short

variable_types: int (*)(void *scaler, short *pin, short inc)


decompiled_code:
__int64 __fastcall scaler_get_data_bytes(int a1)
{
return (unsigned int)(4 * scalerDataWords[a1]);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1)
{
return (unsigned int)(4 * scalerDataWords[a1]);
}

original_code:
u32 scaler_get_data_bytes(ParamType p) {
  return scalerDataWords[p] * 4;
}

canonical_original_code:
unsigned int scaler_get_data_bytes(enum ParamType p) {
  return scalerDataWords[p] * 4;
}

variable_types: enum ParamType { eParamTypeBool=0, eParamTypeFix=1, eParamTypeAmp=2, eParamTypeIntegrator=3, eParamTypeNote=4, eParamTypeSvfFreq=5, eParamTypeFract=6, eParamTypeShort=7, eParamTypeIntegratorShort=8, eParamNumTypes=9 }

return_type: unsigned int


decompiled_code:
__int64 __fastcall scaler_get_rep_bytes(int a1)
{
return (unsigned int)(4 * scalerRepWords[a1]);
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
return (unsigned int)(4 * scalerRepWords[a1]);
}

original_code:
u32 scaler_get_rep_bytes(ParamType p) {
  return scalerRepWords[p] * 4;
}

canonical_original_code:
unsigned int scaler_get_rep_bytes(enum ParamType p) {
  return scalerRepWords[p] * 4;
}


decompiled_code:
char *__fastcall scaler_get_data_path(unsigned int a1)
{
return (char *)&scalerDataPath + 32 * a1;
}

canonical_decompiled_code:
char *__fastcall func5(unsigned int a1)
{
return (char *)&scalerDataPath + 32 * a1;
}

original_code:
const char* scaler_get_data_path(ParamType p) {
  return scalerDataPath[p];
}

canonical_original_code:
char *scaler_get_data_path(enum ParamType p) {
  return scalerDataPath[p];
}

return_type: char *


decompiled_code:
char *__fastcall scaler_get_rep_path(unsigned int a1)
{
return (char *)&scalerRepPath + 32 * a1;
}

canonical_decompiled_code:
char *__fastcall func6(unsigned int a1)
{
return (char *)&scalerRepPath + 32 * a1;
}

original_code:
const char* scaler_get_rep_path(ParamType p) {
  return scalerRepPath[p];
}

canonical_original_code:
char *scaler_get_rep_path(enum ParamType p) {
  return scalerRepPath[p];
}


decompiled_code:
__int64 __fastcall scaler_get_data_offset(int a1)
{
return (unsigned int)(4 * scalerDataOffset[a1]);
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
return (unsigned int)(4 * scalerDataOffset[a1]);
}

original_code:
u32 scaler_get_data_offset(ParamType p) {
    return scalerDataOffset[p] * 4;
}

canonical_original_code:
unsigned int scaler_get_data_offset(enum ParamType p) {
    return scalerDataOffset[p] * 4;
}


decompiled_code:
__int64 __fastcall scaler_get_rep_offset(int a1)
{
return (unsigned int)(4 * scalerRepOffset[a1]);
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
return (unsigned int)(4 * scalerRepOffset[a1]);
}

original_code:
u32 scaler_get_rep_offset(ParamType p) {
  return scalerRepOffset[p] * 4;
}

canonical_original_code:
unsigned int scaler_get_rep_offset(enum ParamType p) {
  return scalerRepOffset[p] * 4;
}


decompiled_code:
void **__fastcall scaler_get_nv_data(int a1)
{
__int64 v1; // rdi
void **result; // rax

v1 = (unsigned int)(a1 - 2);
result = 0LL;
if ( (unsigned int)v1 <= 6 )
result = CSWTCH_14[v1];
return result;
}

canonical_decompiled_code:
void **__fastcall func9(int a1)
{
__int64 v1; // rdi
void **result; // rax

v1 = (unsigned int)(a1 - 2);
result = 0LL;
if ( (unsigned int)v1 <= 6 )
result = CSWTCH_14[v1];
return result;
}

original_code:
const s32* scaler_get_nv_data(ParamType p) {
  switch(p) {
  case eParamTypeAmp :
    return (s32*)scaler_amp_val_data;
    break;
  case eParamTypeIntegrator :
    return (s32*)scaler_integrator_val_data;
    break;
  case eParamTypeNote :
    return (s32*)scaler_note_val_data;
    break;
  case eParamTypeSvfFreq :
    return (s32*)scaler_svf_fc_val_data;
    break;
  case eParamTypeIntegratorShort :
    return (s32*)scaler_integrator_short_val_data;
    break;
  default:
    return 0;
  }
}

canonical_original_code:
int *scaler_get_nv_data(enum ParamType p) {
  switch(p) {
  case eParamTypeAmp :
    return (int *)scaler_amp_val_data;
    break;
  case eParamTypeIntegrator :
    return (int *)scaler_integrator_val_data;
    break;
  case eParamTypeNote :
    return (int *)scaler_note_val_data;
    break;
  case eParamTypeSvfFreq :
    return (int *)scaler_svf_fc_val_data;
    break;
  case eParamTypeIntegratorShort :
    return (int *)scaler_integrator_short_val_data;
    break;
  default:
    return 0;
  }
}

return_type: int *


decompiled_code:
void **__fastcall scaler_get_nv_rep(int a1)
{
void **result; // rax

result = (void **)&scaler_amp_rep_data;
if ( a1 != 2 )
{
result = &scaler_integrator_rep_data;
if ( a1 != 3 )
result = 0LL;
}
return result;
}

canonical_decompiled_code:
void **__fastcall func10(int a1)
{
void **result; // rax

result = (void **)&scaler_amp_rep_data;
if ( a1 != 2 )
{
result = &scaler_integrator_rep_data;
if ( a1 != 3 )
result = 0LL;
}
return result;
}

original_code:
const s32* scaler_get_nv_rep(ParamType p) {
  switch(p) {
  case eParamTypeAmp :
    return (s32*)scaler_amp_rep_data;
    break;
  case eParamTypeIntegrator :
    return (s32*)scaler_integrator_rep_data;
    break;
  default:
    return 0;
  }
}

canonical_original_code:
int *scaler_get_nv_rep(enum ParamType p) {
  switch(p) {
  case eParamTypeAmp :
    return (int *)scaler_amp_rep_data;
    break;
  case eParamTypeIntegrator :
    return (int *)scaler_integrator_rep_data;
    break;
  default:
    return 0;
  }
}


decompiled_code:
__int64 __fastcall int64_lo(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return a1;
}

original_code: static inline uint32_t int64_lo(int64_t x) { return (x & ((1ULL << 32) - 1)); }

canonical_original_code: static inline unsigned int int64_lo(long x) { return (x & ((1ULL << 32) - 1)); }

variable_types: x long


decompiled_code:
__int64 __fastcall int64_add(__int64 a1, __int64 a2)
{
return a1 + a2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
return a1 + a2;
}

original_code: static inline int64_t int64_add(int64_t x, int64_t y) { return (x + y); }

canonical_original_code: static inline long int64_add(long x, long y) { return (x + y); }

variable_types: y long

return_type: long


decompiled_code:
__int64 __fastcall int64_mul_i32_i32(int a1, int a2)
{
return a2 * a1;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2)
{
return a2 * a1;
}

original_code: static inline int64_t int64_mul_i32_i32(int32_t x, int32_t y) { return (x * y); }

canonical_original_code: static inline long int64_mul_i32_i32(int x, int y) { return (x * y); }

variable_types: x int

variable_types: y int


decompiled_code:
__int64 __fastcall fix16_add(int a1, int a2)
{
__int64 result; // rax

result = (unsigned int)(a1 + a2);
if ( (a1 ^ a2) >= 0 && (int)(result ^ a1) < 0 )
result = 0x80000000LL;
return result;
}

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

result = (unsigned int)(a1 + a2);
if ( (a1 ^ a2) >= 0 && (int)(result ^ a1) < 0 )
result = 0x80000000LL;
return result;
}

canonical_original_code:
int fix16_add(int a, int b)
{
  unsigned int _a = a; unsigned int _b = b;
  unsigned int sum = _a + _b;
  if (!((_a ^ _b) & 0x80000000) && ((_a ^ sum) & 0x80000000))
    return fix16_overflow;
  return sum;
}

variable_types: a int

variable_types: b int

variable_types:
sum
unsigned int


decompiled_code:
__int64 __fastcall fix16_sub(int a1, int a2)
{
__int64 result; // rax

result = (unsigned int)(a1 - a2);
if ( (a1 ^ a2) < 0 && (int)(result ^ a1) < 0 )
result = 0x80000000LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, int a2)
{
__int64 result; // rax

result = (unsigned int)(a1 - a2);
if ( (a1 ^ a2) < 0 && (int)(result ^ a1) < 0 )
result = 0x80000000LL;
return result;
}

original_code:
fix16_t fix16_sub(fix16_t a, fix16_t b)
{
  uint32_t _a = a, _b = b;
  uint32_t diff = _a - _b;
  if (((_a ^ _b) & 0x80000000) && ((_a ^ diff) & 0x80000000))
    return fix16_overflow;
  return diff;
}

canonical_original_code:
int fix16_sub(int a, int b)
{
  unsigned int _a = a; unsigned int _b = b;
  unsigned int diff = _a - _b;
  if (((_a ^ _b) & 0x80000000) && ((_a ^ diff) & 0x80000000))
    return fix16_overflow;
  return diff;
}

variable_types:
diff
unsigned int


decompiled_code:
__int64 __fastcall fix16_sadd(int a1, int a2)
{
__int64 result; // rax
int v3; // edx

result = fix16_add(a1, a2);
if ( (_DWORD)result == 0x80000000 && v3 > 0 )
result = 0x7FFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, int a2)
{
__int64 result; // rax
int v3; // edx

result = func4(a1, a2);
if ( (_DWORD)result == 0x80000000 && v3 > 0 )
result = 0x7FFFFFFFLL;
return result;
}

original_code:
fix16_t fix16_sadd(fix16_t a, fix16_t b)
{
  fix16_t result = fix16_add(a, b);
  if (result == fix16_overflow)
    return (a > 0) ? fix16_max : fix16_min;
  return result;
}

canonical_original_code:
int fix16_sadd(int a, int b)
{
  int result = fix16_add(a, b);
  if (result == fix16_overflow)
    return (a > 0) ? fix16_max : fix16_min;
  return result;
}

variable_types: result int


decompiled_code:
__int64 __fastcall fix16_ssub(int a1, int a2)
{
__int64 result; // rax
int v3; // edx

result = fix16_sub(a1, a2);
if ( (_DWORD)result == 0x80000000 && v3 > 0 )
result = 0x7FFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, int a2)
{
__int64 result; // rax
int v3; // edx

result = func5(a1, a2);
if ( (_DWORD)result == 0x80000000 && v3 > 0 )
result = 0x7FFFFFFFLL;
return result;
}

original_code:
fix16_t fix16_ssub(fix16_t a, fix16_t b)
{
  fix16_t result = fix16_sub(a, b);
  if (result == fix16_overflow)
    return (a > 0) ? fix16_max : fix16_min;
  return result;
}

canonical_original_code:
int fix16_ssub(int a, int b)
{
  int result = fix16_sub(a, b);
  if (result == fix16_overflow)
    return (a > 0) ? fix16_max : fix16_min;
  return result;
}