putrr

original_code:
int putrr(struct assstack_entry **stack, struct berval *name, char *type, char *ttl, struct berval *val) {
    struct string key;
    struct assstack_entry *rr, *rrdata;
    if (!name->bv_len || !val->bv_len)
 return 0;
    key.len = name->bv_len;
    key.data = name->bv_val;
    rr = assstack_find(*stack, &key);
    if (!rr) {
 rr = (struct assstack_entry *) malloc(sizeof(struct assstack_entry));
 if (!rr)
     return -1;
 rr->key.len = name->bv_len;
 rr->key.data = (void *) malloc(rr->key.len);
 if (!rr->key.data) {
     free(rr);
     return -1;
 }
 memcpy(rr->key.data, name->bv_val, name->bv_len);
 rr->val.len = sizeof(void *);
 rr->val.data = ((void *)0);
 if (name->bv_len == 1 && *(char *)name->bv_val == '@')
     assstack_push(stack, rr);
 else
     assstack_insertsorted(stack, rr);
    }
    rrdata = (struct assstack_entry *) malloc(sizeof(struct assstack_entry));
    if (!rrdata) {
 free(rr->key.data);
 free(rr);
 return -1;
    }
    rrdata->key.len = strlen(type) + strlen(ttl) + 2;
    rrdata->key.data = (void *) malloc(rrdata->key.len);
    if (!rrdata->key.data) {
 free(rrdata);
 free(rr->key.data);
 free(rr);
 return -1;
    }
    sprintf((char *)rrdata->key.data, "%s %s", ttl, type);
    rrdata->val.len = val->bv_len;
    rrdata->val.data = (void *) malloc(val->bv_len);
    if (!rrdata->val.data) {
 free(rrdata->key.data);
 free(rrdata);
 free(rr->key.data);
 free(rr);
 return -1;
    }
    memcpy(rrdata->val.data, val->bv_val, val->bv_len);
    if (!strcmp(type, "SOA"))
 assstack_push((struct assstack_entry **) &(rr->val.data), rrdata);
    else
 assstack_insertsorted((struct assstack_entry **) &(rr->val.data), rrdata);
    return 0;
}

canonical_original_code:
int putrr(struct assstack_entry **stack, struct berval *name, char *type, char *ttl, struct berval *val) {
    struct string key;
    struct assstack_entry *rr; struct assstack_entry *rrdata;
    if (!name->bv_len || !val->bv_len)
 return 0;
    key.len = name->bv_len;
    key.data = name->bv_val;
    rr = assstack_find(*stack, &key);
    if (!rr) {
 rr = (struct assstack_entry *) malloc(sizeof(struct assstack_entry));
 if (!rr)
     return -1;
 rr->key.len = name->bv_len;
 rr->key.data = (void *) malloc(rr->key.len);
 if (!rr->key.data) {
     free(rr);
     return -1;
 }
 memcpy(rr->key.data, name->bv_val, name->bv_len);
 rr->val.len = sizeof(void *);
 rr->val.data = ((void *)0);
 if (name->bv_len == 1 && *(char *)name->bv_val == '@')
     assstack_push(stack, rr);
 else
     assstack_insertsorted(stack, rr);
    }
    rrdata = (struct assstack_entry *) malloc(sizeof(struct assstack_entry));
    if (!rrdata) {
 free(rr->key.data);
 free(rr);
 return -1;
    }
    rrdata->key.len = strlen(type) + strlen(ttl) + 2;
    rrdata->key.data = (void *) malloc(rrdata->key.len);
    if (!rrdata->key.data) {
 free(rrdata);
 free(rr->key.data);
 free(rr);
 return -1;
    }
    sprintf((char *)rrdata->key.data, "%s %s", ttl, type);
    rrdata->val.len = val->bv_len;
    rrdata->val.data = (void *) malloc(val->bv_len);
    if (!rrdata->val.data) {
 free(rrdata->key.data);
 free(rrdata);
 free(rr->key.data);
 free(rr);
 return -1;
    }
    memcpy(rrdata->val.data, val->bv_val, val->bv_len);
    if (!strcmp(type, "SOA"))
 assstack_push((struct assstack_entry **) &(rr->val.data), rrdata);
    else
 assstack_insertsorted((struct assstack_entry **) &(rr->val.data), rrdata);
    return 0;
}

variable_types: struct assstack_entry { struct string { void *data; unsigned long len; } key; struct string val; struct assstack_entry *next; } **

variable_types: struct berval { unsigned long bv_len; char *bv_val; } *

variable_types:
val
struct berval *


main

canonical_name: main

repo: Fredspohr/algoritimos-geneticos

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rbx
_QWORD *v4; // rbp
unsigned int *v5; // r12
__int64 v6; // rsi
unsigned int *v7; // rbp
unsigned int *v8; // rbx
unsigned int *v9; // rax
unsigned int *v10; // r12
__int64 v11; // rsi

v3 = malloc(0x28uLL);
v4 = v3 + 4;
v5 = (unsigned int *)malloc(0x20uLL);
*v3 = 0x100000000LL;
v3[1] = 0x300000002LL;
v3[2] = 0x500000004LL;
v3[3] = 0x700000006LL;
do
{
v6 = *(unsigned int *)v3;
v3 = (_QWORD *)((char *)v3 + 4);
printf("Valor: %d\n", v6);
}
while ( v4 != v3 );
v7 = v5 + 7;
v8 = v5;
do
{
*v7 = random_number(0LL, 1LL);
v9 = v7--;
}
while ( v5 != v9 );
v10 = v5 + 8;
do
{
v11 = *v8++;
printf("Peso: %d\n", v11);
}
while ( v8 != v10 );
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rbx
_QWORD *v4; // rbp
unsigned int *v5; // r12
__int64 v6; // rsi
unsigned int *v7; // rbp
unsigned int *v8; // rbx
unsigned int *v9; // rax
unsigned int *v10; // r12
__int64 v11; // rsi

v3 = malloc(0x28uLL);
v4 = v3 + 4;
v5 = (unsigned int *)malloc(0x20uLL);
*v3 = 0x100000000LL;
v3[1] = 0x300000002LL;
v3[2] = 0x500000004LL;
v3[3] = 0x700000006LL;
do
{
v6 = *(unsigned int *)v3;
v3 = (_QWORD *)((char *)v3 + 4);
printf("Valor: %d\n", v6);
}
while ( v4 != v3 );
v7 = v5 + 7;
v8 = v5;
do
{
*v7 = func7(0LL, 1LL);
v9 = v7--;
}
while ( v5 != v9 );
v10 = v5 + 8;
do
{
v11 = *v8++;
printf("Peso: %d\n", v11);
}
while ( v8 != v10 );
return 0;
}

original_code:
int main(int arg, char* args[]){
 Cromossomo *cromossomo;
 int i;
 cromossomo = malloc(sizeof(Cromossomo));
 cromossomo->genes = malloc(8 * sizeof(Gene));
 for(i = 0;i < 8; i++){
  cromossomo->valor[i] = i;
 }
 for(i = 0;i < 8; i++){
  printf("Valor: %d\n",cromossomo->valor[i]);
 }
 for(i = 7; i >= 0; i--){
  cromossomo->genes[i].peso = random_number(0,1) ;
 }
 for(i = 0;i < 8; i++){
  printf("Peso: %d\n",cromossomo->genes[i].peso);
 }
 return 0;
}

canonical_original_code:
int main(int arg, char *args[]){
 struct Cromossomo *cromossomo;
 int i;
 cromossomo = malloc(sizeof(Cromossomo));
 cromossomo->genes = malloc(8 * sizeof(Gene));
 for(i = 0;i < 8; i++){
  cromossomo->valor[i] = i;
 }
 for(i = 0;i < 8; i++){
  printf("Valor: %d\n",cromossomo->valor[i]);
 }
 for(i = 7; i >= 0; i--){
  cromossomo->genes[i].peso = random_number(0,1) ;
 }
 for(i = 0;i < 8; i++){
  printf("Peso: %d\n",cromossomo->genes[i].peso);
 }
 return 0;
}

variable_types: arg int

variable_types:
args
char *[]

variable_types: struct Cromossomo { int valor[8]; struct Gene { int peso; } *genes; } *

variable_types: i int

return_type: int

user_defined_types: struct Cromossomo { int valor[8]; struct Gene *genes; }


decompiled_code:
__int64 __fastcall random_number(int a1, int a2)
{
int v2; // ebp
int v3; // ebx
int v4; // er12
int v5; // eax

v2 = a2 + 1;
v3 = a1;
if ( a1 >= a2 )
{
v3 = a2 + 1;
v2 = a1;
}
v4 = rand();
v5 = time(0LL);
srand(v5 * v4);
return (unsigned int)(rand() % (v2 - v3) + v3);
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, int a2)
{
int v2; // ebp
int v3; // ebx
int v4; // er12
int v5; // eax

v2 = a2 + 1;
v3 = a1;
if ( a1 >= a2 )
{
v3 = a2 + 1;
v2 = a1;
}
v4 = rand();
v5 = time(0LL);
srand(v5 * v4);
return (unsigned int)(rand() % (v2 - v3) + v3);
}

original_code:
int random_number(int min_num, int max_num)
        {
            int result=0,low_num=0,hi_num=0;
            if(min_num<max_num)
            {
                low_num=min_num;
                hi_num=max_num+1;
            }else{
                low_num=max_num+1;
                hi_num=min_num;
            }
            srand(rand()*time(((void *)0)));
            result = (rand()%(hi_num-low_num))+low_num;
            return result;
        }

canonical_original_code:
int random_number(int min_num, int max_num)
        {
            int result = 0; int low_num = 0; int hi_num = 0;
            if(min_num<max_num)
            {
                low_num=min_num;
                hi_num=max_num+1;
            }else{
                low_num=max_num+1;
                hi_num=min_num;
            }
            srand(rand()*time(((void *)0)));
            result = (rand()%(hi_num-low_num))+low_num;
            return result;
        }

variable_types: result int


iniciarPopulacao

decompiled_code:
void iniciarPopulacao()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
void iniciarPopulacao(int numeroinicial){
}

variable_types: numeroinicial int

return_type: void


crossover

decompiled_code:
void crossover()
{
;
}

canonical_decompiled_code:
void func9()
{
;
}

original_code:
void crossover(){
}

canonical_original_code:
void crossover(){
}


mutacao

decompiled_code:
void mutacao()
{
;
}

canonical_decompiled_code:
void func10()
{
;
}

original_code:
void mutacao(){
}

canonical_original_code:
void mutacao(){
}


avaliacao

decompiled_code:
void avaliacao()
{
;
}

canonical_decompiled_code:
void func11()
{
;
}

original_code:
void avaliacao(){
}

canonical_original_code:
void avaliacao(){
}


imprime

decompiled_code:
int imprime()
{
return puts("Imprime algoritimogenetico.h");
}

canonical_decompiled_code:
int func12()
{
return puts("Imprime algoritimogenetico.h");
}

original_code:
void imprime(){
 printf("Imprime algoritimogenetico.h\n");
}


pollKeyboard

repo: FrostTree-Games/PrinceProtect

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

result = SDL_GetKeyState(0LL);
keyList = result;
return result;
}

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

result = SDL_GetKeyState(0LL);
keyList = result;
return result;
}

original_code:
void pollKeyboard()
{
 keyList = SDL_GetKeyState(((void *)0));
}


setKey

decompiled_code:
void __fastcall setKey(int a1, int a2)
{
switch ( a2 )
{
case 1:
p1_up = a1;
break;
case 2:
p1_down = a1;
break;
case 3:
p1_left = a1;
break;
case 4:
p1_right = a1;
break;
case 5:
p1_a = a1;
break;
case 6:
p1_b = a1;
break;
case 7:
p1_start = a1;
break;
case 8:
p1_select = a1;
break;
case 9:
p2_up = a1;
break;
case 10:
p2_down = a1;
break;
case 11:
p2_left = a1;
break;
case 12:
p2_right = a1;
break;
case 13:
p2_a = a1;
break;
case 14:
p2_b = a1;
break;
case 15:
p2_start = a1;
break;
case 16:
p2_select = a1;
break;
default:
return;
}
}

canonical_decompiled_code:
void __fastcall func1(int a1, int a2)
{
switch ( a2 )
{
case 1:
p1_up = a1;
break;
case 2:
p1_down = a1;
break;
case 3:
p1_left = a1;
break;
case 4:
p1_right = a1;
break;
case 5:
p1_a = a1;
break;
case 6:
p1_b = a1;
break;
case 7:
p1_start = a1;
break;
case 8:
p1_select = a1;
break;
case 9:
p2_up = a1;
break;
case 10:
p2_down = a1;
break;
case 11:
p2_left = a1;
break;
case 12:
p2_right = a1;
break;
case 13:
p2_a = a1;
break;
case 14:
p2_b = a1;
break;
case 15:
p2_start = a1;
break;
case 16:
p2_select = a1;
break;
default:
return;
}
}

original_code:
void setKey(SDLKey input, gameKey key)
{
 switch (key)
 {
  case P1_UP:
  p1_up = input;
  break;
  case P1_DOWN:
  p1_down = input;
  break;
  case P1_LEFT:
  p1_left = input;
  break;
  case P1_RIGHT:
  p1_right = input;
  break;
  case P1_A:
  p1_a = input;
  break;
  case P1_B:
  p1_b = input;
  break;
  case P1_START:
  p1_start = input;
  break;
  case P1_SELECT:
  p1_select = input;
  break;
  case P2_UP:
  p2_up = input;
  break;
  case P2_DOWN:
  p2_down = input;
  break;
  case P2_LEFT:
  p2_left = input;
  break;
  case P2_RIGHT:
  p2_right = input;
  break;
  case P2_A:
  p2_a = input;
  break;
  case P2_B:
  p2_b = input;
  break;
  case P2_START:
  p2_start = input;
  break;
  case P2_SELECT:
  p2_select = input;
  break;
  default:
  break;
 }
}

canonical_original_code:
void setKey(enum SDLKey input, enum gameKey key)
{
 switch (key)
 {
  case P1_UP:
  p1_up = input;
  break;
  case P1_DOWN:
  p1_down = input;
  break;
  case P1_LEFT:
  p1_left = input;
  break;
  case P1_RIGHT:
  p1_right = input;
  break;
  case P1_A:
  p1_a = input;
  break;
  case P1_B:
  p1_b = input;
  break;
  case P1_START:
  p1_start = input;
  break;
  case P1_SELECT:
  p1_select = input;
  break;
  case P2_UP:
  p2_up = input;
  break;
  case P2_DOWN:
  p2_down = input;
  break;
  case P2_LEFT:
  p2_left = input;
  break;
  case P2_RIGHT:
  p2_right = input;
  break;
  case P2_A:
  p2_a = input;
  break;
  case P2_B:
  p2_b = input;
  break;
  case P2_START:
  p2_start = input;
  break;
  case P2_SELECT:
  p2_select = input;
  break;
  default:
  break;
 }
}

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 }

variable_types: enum gameKey { ESCAPE_KEY=0, P1_UP=1, P1_DOWN=2, P1_LEFT=3, P1_RIGHT=4, P1_A=5, P1_B=6, P1_START=7, P1_SELECT=8, P2_UP=9, P2_DOWN=10, P2_LEFT=11, P2_RIGHT=12, P2_A=13, P2_B=14, P2_START=15, P2_SELECT=16 }


isEnterKey

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

if ( keyList )
result = *(unsigned __int8 *)(keyList + 13);
else
result = 0LL;
return result;
}

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

if ( keyList )
result = *(unsigned __int8 *)(keyList + 13);
else
result = 0LL;
return result;
}

original_code:
int isEnterKey()
{
 if (keyList == ((void *)0))
 {
  return 0;
 }
 return keyList[SDLK_RETURN];
}


getKey

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

if ( !keyList )
return 0LL;
switch ( a1 )
{
case 0:
result = *(unsigned __int8 *)(keyList + 27);
break;
case 1:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_up);
break;
case 2:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_down);
break;
case 3:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_left);
break;
case 4:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_right);
break;
case 5:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_a);
break;
case 6:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_b);
break;
case 7:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_start);
break;
case 8:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_select);
break;
case 9:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_up);
break;
case 10:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_down);
break;
case 11:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_left);
break;
case 12:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_right);
break;
case 13:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_a);
break;
case 14:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_b);
break;
case 15:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_start);
break;
case 16:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_select);
break;
default:
puts("STRANGE KEYBOARD CODE FOUND");
result = 0LL;
break;
}
return result;
}

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

if ( !keyList )
return 0LL;
switch ( a1 )
{
case 0:
result = *(unsigned __int8 *)(keyList + 27);
break;
case 1:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_up);
break;
case 2:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_down);
break;
case 3:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_left);
break;
case 4:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_right);
break;
case 5:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_a);
break;
case 6:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_b);
break;
case 7:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_start);
break;
case 8:
result = *(unsigned __int8 *)(keyList + (unsigned int)p1_select);
break;
case 9:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_up);
break;
case 10:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_down);
break;
case 11:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_left);
break;
case 12:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_right);
break;
case 13:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_a);
break;
case 14:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_b);
break;
case 15:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_start);
break;
case 16:
result = *(unsigned __int8 *)(keyList + (unsigned int)p2_select);
break;
default:
puts("STRANGE KEYBOARD CODE FOUND");
result = 0LL;
break;
}
return result;
}

original_code:
int getKey(gameKey key)
{
 if (keyList == ((void *)0))
 {
  return 0;
 }
 switch (key)
 {
  case ESCAPE_KEY:
  return keyList[SDLK_ESCAPE];
  break;
  case P1_UP:
  return keyList[p1_up];
  break;
  case P1_DOWN:
  return keyList[p1_down];
  break;
  case P1_LEFT:
  return keyList[p1_left];
  break;
  case P1_RIGHT:
  return keyList[p1_right];
  break;
  case P1_A:
  return keyList[p1_a];
  break;
  case P1_B:
  return keyList[p1_b];
  break;
  case P1_START:
  return keyList[p1_start];
  break;
  case P1_SELECT:
  return keyList[p1_select];
  break;
  case P2_UP:
  return keyList[p2_up];
  break;
  case P2_DOWN:
  return keyList[p2_down];
  break;
  case P2_LEFT:
  return keyList[p2_left];
  break;
  case P2_RIGHT:
  return keyList[p2_right];
  break;
  case P2_A:
  return keyList[p2_a];
  break;
  case P2_B:
  return keyList[p2_b];
  break;
  case P2_START:
  return keyList[p2_start];
  break;
  case P2_SELECT:
  return keyList[p2_select];
  break;
  default:
  printf("STRANGE KEYBOARD CODE FOUND\n");
  return 0;
 }
 return 0;
}

canonical_original_code:
int getKey(enum gameKey key)
{
 if (keyList == ((void *)0))
 {
  return 0;
 }
 switch (key)
 {
  case ESCAPE_KEY:
  return keyList[SDLK_ESCAPE];
  break;
  case P1_UP:
  return keyList[p1_up];
  break;
  case P1_DOWN:
  return keyList[p1_down];
  break;
  case P1_LEFT:
  return keyList[p1_left];
  break;
  case P1_RIGHT:
  return keyList[p1_right];
  break;
  case P1_A:
  return keyList[p1_a];
  break;
  case P1_B:
  return keyList[p1_b];
  break;
  case P1_START:
  return keyList[p1_start];
  break;
  case P1_SELECT:
  return keyList[p1_select];
  break;
  case P2_UP:
  return keyList[p2_up];
  break;
  case P2_DOWN:
  return keyList[p2_down];
  break;
  case P2_LEFT:
  return keyList[p2_left];
  break;
  case P2_RIGHT:
  return keyList[p2_right];
  break;
  case P2_A:
  return keyList[p2_a];
  break;
  case P2_B:
  return keyList[p2_b];
  break;
  case P2_START:
  return keyList[p2_start];
  break;
  case P2_SELECT:
  return keyList[p2_select];
  break;
  default:
  printf("STRANGE KEYBOARD CODE FOUND\n");
  return 0;
 }
 return 0;
}

user_defined_types: enum gameKey { ESCAPE_KEY=0, P1_UP=1, P1_DOWN=2, P1_LEFT=3, P1_RIGHT=4, P1_A=5, P1_B=6, P1_START=7, P1_SELECT=8, P2_UP=9, P2_DOWN=10, P2_LEFT=11, P2_RIGHT=12, P2_A=13, P2_B=14, P2_START=15, P2_SELECT=16 }


getSDLKeyValue

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

if ( !keyList )
return 0LL;
switch ( a1 )
{
case 0:
result = 27LL;
break;
case 1:
result = (unsigned int)p1_up;
break;
case 2:
result = (unsigned int)p1_down;
break;
case 3:
result = (unsigned int)p1_left;
break;
case 4:
result = (unsigned int)p1_right;
break;
case 5:
result = (unsigned int)p1_a;
break;
case 6:
result = (unsigned int)p1_b;
break;
case 7:
result = (unsigned int)p1_start;
break;
case 8:
result = (unsigned int)p1_select;
break;
case 9:
result = (unsigned int)p2_up;
break;
case 10:
result = (unsigned int)p2_down;
break;
case 11:
result = (unsigned int)p2_left;
break;
case 12:
result = (unsigned int)p2_right;
break;
case 13:
result = (unsigned int)p2_a;
break;
case 14:
result = (unsigned int)p2_b;
break;
case 15:
result = (unsigned int)p2_start;
break;
case 16:
result = (unsigned int)p2_select;
break;
default:
puts("STRANGE KEYBOARD CODE FOUND");
result = 0LL;
break;
}
return result;
}

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

if ( !keyList )
return 0LL;
switch ( a1 )
{
case 0:
result = 27LL;
break;
case 1:
result = (unsigned int)p1_up;
break;
case 2:
result = (unsigned int)p1_down;
break;
case 3:
result = (unsigned int)p1_left;
break;
case 4:
result = (unsigned int)p1_right;
break;
case 5:
result = (unsigned int)p1_a;
break;
case 6:
result = (unsigned int)p1_b;
break;
case 7:
result = (unsigned int)p1_start;
break;
case 8:
result = (unsigned int)p1_select;
break;
case 9:
result = (unsigned int)p2_up;
break;
case 10:
result = (unsigned int)p2_down;
break;
case 11:
result = (unsigned int)p2_left;
break;
case 12:
result = (unsigned int)p2_right;
break;
case 13:
result = (unsigned int)p2_a;
break;
case 14:
result = (unsigned int)p2_b;
break;
case 15:
result = (unsigned int)p2_start;
break;
case 16:
result = (unsigned int)p2_select;
break;
default:
puts("STRANGE KEYBOARD CODE FOUND");
result = 0LL;
break;
}
return result;
}

original_code:
SDLKey getSDLKeyValue(gameKey key)
{
 if (keyList == ((void *)0))
 {
  return 0;
 }
 switch (key)
 {
  case ESCAPE_KEY:
  return SDLK_ESCAPE;
  break;
  case P1_UP:
  return p1_up;
  break;
  case P1_DOWN:
  return p1_down;
  break;
  case P1_LEFT:
  return p1_left;
  break;
  case P1_RIGHT:
  return p1_right;
  break;
  case P1_A:
  return p1_a;
  break;
  case P1_B:
  return p1_b;
  break;
  case P1_START:
  return p1_start;
  break;
  case P1_SELECT:
  return p1_select;
  break;
  case P2_UP:
  return p2_up;
  break;
  case P2_DOWN:
  return p2_down;
  break;
  case P2_LEFT:
  return p2_left;
  break;
  case P2_RIGHT:
  return p2_right;
  break;
  case P2_A:
  return p2_a;
  break;
  case P2_B:
  return p2_b;
  break;
  case P2_START:
  return p2_start;
  break;
  case P2_SELECT:
  return p2_select;
  break;
  default:
  printf("STRANGE KEYBOARD CODE FOUND\n");
  return 0;
 }
 return 0;
}

canonical_original_code:
enum SDLKey getSDLKeyValue(enum gameKey key)
{
 if (keyList == ((void *)0))
 {
  return 0;
 }
 switch (key)
 {
  case ESCAPE_KEY:
  return SDLK_ESCAPE;
  break;
  case P1_UP:
  return p1_up;
  break;
  case P1_DOWN:
  return p1_down;
  break;
  case P1_LEFT:
  return p1_left;
  break;
  case P1_RIGHT:
  return p1_right;
  break;
  case P1_A:
  return p1_a;
  break;
  case P1_B:
  return p1_b;
  break;
  case P1_START:
  return p1_start;
  break;
  case P1_SELECT:
  return p1_select;
  break;
  case P2_UP:
  return p2_up;
  break;
  case P2_DOWN:
  return p2_down;
  break;
  case P2_LEFT:
  return p2_left;
  break;
  case P2_RIGHT:
  return p2_right;
  break;
  case P2_A:
  return p2_a;
  break;
  case P2_B:
  return p2_b;
  break;
  case P2_START:
  return p2_start;
  break;
  case P2_SELECT:
  return p2_select;
  break;
  default:
  printf("STRANGE KEYBOARD CODE FOUND\n");
  return 0;
 }
 return 0;
}

return_type: 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 }


xrand

decompiled_code:
__int64 xrand()
{
int v0; // ebx

v0 = rand();
return (unsigned int)((v0 << 31) + rand());
}

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

v0 = rand();
return (unsigned int)((v0 << 31) + rand());
}

original_code:
unsigned int xrand(void)
{
 return rand () * (2147483647 + 1) + rand ();
}

canonical_original_code:
unsigned int xrand()
{
 return rand () * (2147483647 + 1) + rand ();
}

return_type: unsigned int


randomizeWaveTypes

decompiled_code:
__int64 randomizeWaveTypes()
{
char v0; // al
int v1; // ecx
int v2; // eax
int v3; // edx
char v4; // al
int v5; // ecx
int v6; // eax
int v7; // edx
__int64 result; // rax

v0 = xrand();
v1 = initalBlockList[3];
v2 = v0 & 3;
v3 = initalBlockList[v2];
initalBlockList[3] = v3;
waveTypeBlock1 = v3;
initalBlockList[v2] = v1;
waveTypeBlock2 = initalBlockList[(unsigned int)xrand() % 3];
v4 = xrand();
v5 = initalEnemyList[3];
v6 = v4 & 3;
v7 = initalEnemyList[v6];
initalEnemyList[3] = v7;
waveTypeEnemy1 = v7;
initalEnemyList[v6] = v5;
result = (unsigned int)initalEnemyList[(unsigned int)xrand() % 3];
waveTypeEnemy2 = result;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
char v0; // al
int v1; // ecx
int v2; // eax
int v3; // edx
char v4; // al
int v5; // ecx
int v6; // eax
int v7; // edx
__int64 result; // rax

v0 = func0();
v1 = initalBlockList[3];
v2 = v0 & 3;
v3 = initalBlockList[v2];
initalBlockList[3] = v3;
waveTypeBlock1 = v3;
initalBlockList[v2] = v1;
waveTypeBlock2 = initalBlockList[(unsigned int)func0() % 3];
v4 = func0();
v5 = initalEnemyList[3];
v6 = v4 & 3;
v7 = initalEnemyList[v6];
initalEnemyList[3] = v7;
waveTypeEnemy1 = v7;
initalEnemyList[v6] = v5;
result = (unsigned int)initalEnemyList[(unsigned int)func0() % 3];
waveTypeEnemy2 = result;
return result;
}

original_code:
void randomizeWaveTypes()
{
 int val = xrand() % 4;
 waveTypeBlock1 = initalBlockList[val];
 BlockType holdType = initalBlockList[3];
 initalBlockList[3] = waveTypeBlock1;
 initalBlockList[val] = holdType;
 val = xrand() % 3;
 waveTypeBlock2 = initalBlockList[val];
 val = xrand() % 4;
 waveTypeEnemy1 = initalEnemyList[val];
 EntityType holdType2 = initalEnemyList[3];
 initalEnemyList[3] = waveTypeEnemy1;
 initalEnemyList[val] = holdType2;
 val = xrand() % 3;
 waveTypeEnemy2 = initalEnemyList[val];
}

canonical_original_code:
void randomizeWaveTypes()
{
 int val = xrand() % 4;
 waveTypeBlock1 = initalBlockList[val];
 enum BlockType holdType = initalBlockList[3];
 initalBlockList[3] = waveTypeBlock1;
 initalBlockList[val] = holdType;
 val = xrand() % 3;
 waveTypeBlock2 = initalBlockList[val];
 val = xrand() % 4;
 waveTypeEnemy1 = initalEnemyList[val];
 enum EntityType holdType2 = initalEnemyList[3];
 initalEnemyList[3] = waveTypeEnemy1;
 initalEnemyList[val] = holdType2;
 val = xrand() % 3;
 waveTypeEnemy2 = initalEnemyList[val];
}

variable_types: val int

variable_types: enum BlockType { NO_BLOCK=0, RED_BLOCK=1, BLUE_BLOCK=2, GREEN_BLOCK=3, YELLOW_BLOCK=4 }

variable_types: enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 }


randomizeBGM

decompiled_code:
__int64 __fastcall randomizeBGM(int a1)
{
__int64 result; // rax
char v2; // r8

if ( (unsigned int)(a1 - 2) > 2 )
return 2LL;
if ( a1 == 2 )
return (unsigned int)(xrand() & 1) + 3;
if ( a1 != 3 )
return (unsigned int)(xrand() & 1) + 2;
v2 = xrand();
result = 4LL;
if ( (v2 & 1) == 0 )
result = 2LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 result; // rax
char v2; // r8

if ( (unsigned int)(a1 - 2) > 2 )
return 2LL;
if ( a1 == 2 )
return (unsigned int)(func0() & 1) + 3;
if ( a1 != 3 )
return (unsigned int)(func0() & 1) + 2;
v2 = func0();
result = 4LL;
if ( (v2 & 1) == 0 )
result = 2LL;
return result;
}

original_code:
BGMType randomizeBGM(BGMType bg)
{
 if (bg != BGM_1 && bg != BGM_2 && bg != BGM_3)
 {
  return BGM_1;
 }
 if (bg == BGM_1)
 {
  switch (xrand() % 2)
  {
   case 0:
   return BGM_2;
   case 1:
   return BGM_3;
   default:
   return BGM_1;
  }
 }
 else if (bg == BGM_2)
 {
  switch (xrand() % 2)
  {
   case 0:
   return BGM_1;
   case 1:
   return BGM_3;
   default:
   return BGM_2;
  }
 }
 else if (bg == BGM_3)
 {
  switch (xrand() % 2)
  {
   case 0:
   return BGM_1;
   case 1:
   return BGM_2;
   default:
   return BGM_3;
  }
 }
 return BGM_1;
}

canonical_original_code:
enum BGMType randomizeBGM(enum BGMType bg)
{
 if (bg != BGM_1 && bg != BGM_2 && bg != BGM_3)
 {
  return BGM_1;
 }
 if (bg == BGM_1)
 {
  switch (xrand() % 2)
  {
   case 0:
   return BGM_2;
   case 1:
   return BGM_3;
   default:
   return BGM_1;
  }
 }
 else if (bg == BGM_2)
 {
  switch (xrand() % 2)
  {
   case 0:
   return BGM_1;
   case 1:
   return BGM_3;
   default:
   return BGM_2;
  }
 }
 else if (bg == BGM_3)
 {
  switch (xrand() % 2)
  {
   case 0:
   return BGM_1;
   case 1:
   return BGM_2;
   default:
   return BGM_3;
  }
 }
 return BGM_1;
}

variable_types: enum BGMType { BGM_NONE=0, BGM_ANGSTY=1, BGM_1=2, BGM_2=3, BGM_3=4, BGM_TITLE=5, BGM_KEYCONFIG=6 }


updateRestPeriod

decompiled_code:
__int64 updateRestPeriod()
{
__int64 v0; // rdx
__int64 result; // rax
__int64 v2; // rbx
__int64 v3; // rbp
int *v4; // rax
int v5; // edx
int v6; // eax
int v7; // eax
char v8[88]; // [rsp+0h] [rbp-58h] BYREF

if ( !restPeriodStart )
{
result = getTimeSingleton();
restPeriodStart = result;
return result;
}
if ( !player1Health )
{
if ( gameEnding )
goto LABEL_4;
goto LABEL_20;
}
if ( !player2Health && !gameEnding )
{
LABEL_20:
v2 = 0LL;
v3 = getEntityList();
if ( !v3 )
goto LABEL_6;
while ( 1 )
{
if ( (int)getEntityListSize() <= (int)v2 )
goto LABEL_6;
v4 = *(int **)(v3 + 8 * v2);
v5 = *v4;
if ( !*v4 )
{
if ( v4[17] != 2 )
goto LABEL_23;
v4[17] = 0;
reloadingHealth = 1;
v7 = getTimeSingleton();
++player1Health;
reloadingDelayEffectTime = v7;
playSFX(22LL);
v4 = *(int **)(v3 + 8 * v2);
v5 = *v4;
}
if ( v5 == 1 && v4[17] == 2 )
{
v4[17] = 0;
reloadingHealth = 2;
v6 = getTimeSingleton();
++player2Health;
reloadingDelayEffectTime = v6;
playSFX(22LL);
}
LABEL_23:
++v2;
}
}
LABEL_4:
if ( reloadingHealth == 1 )
{
if ( (unsigned int)getTimeSingleton() - reloadingDelayEffectTime > 0x1F4 )
{
++player1Health;
playSFX(22LL);
reloadingDelayEffectTime = getTimeSingleton();
if ( player1Health == 3 )
goto LABEL_31;
}
}
else if ( reloadingHealth == 2 && (unsigned int)getTimeSingleton() - reloadingDelayEffectTime > 0x1F4 )
{
++player2Health;
playSFX(22LL);
reloadingDelayEffectTime = getTimeSingleton();
if ( player2Health == 3 )
{
LABEL_31:
reloadingHealth = 0;
goto LABEL_6;
}
}
LABEL_6:
if ( (unsigned int)getTimeSingleton() - restPeriodStart > 0x157C && waveNumber > 0 )
{
restPeriod = 0;
v0 = (unsigned int)(waveNumber + 1);
waveNumber = v0;
enemiesLeftToPush = 10;
if ( (_DWORD)v0 != 2 )
maxOnScreenRobots += 3;
goto LABEL_10;
}
result = (unsigned int)getTimeSingleton() - restPeriodStart;
if ( (unsigned int)result > 0x2AF8 )
{
result = (unsigned int)waveNumber;
if ( !waveNumber )
{
waveNumber = 1;
v0 = 1LL;
restPeriod = 0;
enemiesLeftToPush = 10;
LABEL_10:
sprintf(v8, "WAVE %.2d", v0);
pushNewMessage(v8);
result = randomizeWaveTypes();
if ( waveNumber > 1 )
{
currentBGM = randomizeBGM(currentBGM);
result = playBGM((unsigned int)currentBGM);
}
return result;
}
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rdx
__int64 result; // rax
__int64 v2; // rbx
__int64 v3; // rbp
int *v4; // rax
int v5; // edx
int v6; // eax
int v7; // eax
char v8[88]; // [rsp+0h] [rbp-58h] BYREF

if ( !restPeriodStart )
{
result = getTimeSingleton();
restPeriodStart = result;
return result;
}
if ( !player1Health )
{
if ( gameEnding )
goto LABEL_4;
goto LABEL_20;
}
if ( !player2Health && !gameEnding )
{
LABEL_20:
v2 = 0LL;
v3 = getEntityList();
if ( !v3 )
goto LABEL_6;
while ( 1 )
{
if ( (int)getEntityListSize() <= (int)v2 )
goto LABEL_6;
v4 = *(int **)(v3 + 8 * v2);
v5 = *v4;
if ( !*v4 )
{
if ( v4[17] != 2 )
goto LABEL_23;
v4[17] = 0;
reloadingHealth = 1;
v7 = getTimeSingleton();
++player1Health;
reloadingDelayEffectTime = v7;
playSFX(22LL);
v4 = *(int **)(v3 + 8 * v2);
v5 = *v4;
}
if ( v5 == 1 && v4[17] == 2 )
{
v4[17] = 0;
reloadingHealth = 2;
v6 = getTimeSingleton();
++player2Health;
reloadingDelayEffectTime = v6;
playSFX(22LL);
}
LABEL_23:
++v2;
}
}
LABEL_4:
if ( reloadingHealth == 1 )
{
if ( (unsigned int)getTimeSingleton() - reloadingDelayEffectTime > 0x1F4 )
{
++player1Health;
playSFX(22LL);
reloadingDelayEffectTime = getTimeSingleton();
if ( player1Health == 3 )
goto LABEL_31;
}
}
else if ( reloadingHealth == 2 && (unsigned int)getTimeSingleton() - reloadingDelayEffectTime > 0x1F4 )
{
++player2Health;
playSFX(22LL);
reloadingDelayEffectTime = getTimeSingleton();
if ( player2Health == 3 )
{
LABEL_31:
reloadingHealth = 0;
goto LABEL_6;
}
}
LABEL_6:
if ( (unsigned int)getTimeSingleton() - restPeriodStart > 0x157C && waveNumber > 0 )
{
restPeriod = 0;
v0 = (unsigned int)(waveNumber + 1);
waveNumber = v0;
enemiesLeftToPush = 10;
if ( (_DWORD)v0 != 2 )
maxOnScreenRobots += 3;
goto LABEL_10;
}
result = (unsigned int)getTimeSingleton() - restPeriodStart;
if ( (unsigned int)result > 0x2AF8 )
{
result = (unsigned int)waveNumber;
if ( !waveNumber )
{
waveNumber = 1;
v0 = 1LL;
restPeriod = 0;
enemiesLeftToPush = 10;
LABEL_10:
sprintf(v8, "WAVE %.2d", v0);
pushNewMessage(v8);
result = func1();
if ( waveNumber > 1 )
{
currentBGM = func2(currentBGM);
result = playBGM((unsigned int)currentBGM);
}
return result;
}
}
return result;
}

original_code:
void updateRestPeriod()
{
 int i;
 if (restPeriodStart == 0)
 {
  restPeriodStart = getTimeSingleton();
  return;
 }
 if ((player1Health == 0 || player2Health == 0) && gameEnding == 0)
 {
  Entity** entList = getEntityList();
  if (entList != ((void *)0))
  {
   for (i = 0; i < getEntityListSize(); i++)
   {
    if (entList[i]->base.type == PLAYER1)
    {
     if (entList[i]->player.dead == 2)
     {
      entList[i]->player.dead = 0;
      reloadingHealth = 1;
      reloadingDelayEffectTime = getTimeSingleton();
      player1Health++;
      playSFX(SFX_LIFEUP);
     }
    }
    if (entList[i]->base.type == PLAYER2)
    {
     if (entList[i]->player.dead == 2)
     {
      entList[i]->player.dead = 0;
      reloadingHealth = 2;
      reloadingDelayEffectTime = getTimeSingleton();
      player2Health++;
      playSFX(SFX_LIFEUP);
     }
    }
   }
  }
 }
 else if (reloadingHealth == 1)
 {
  if (getTimeSingleton() - reloadingDelayEffectTime > 500)
  {
   player1Health++;
   playSFX(SFX_LIFEUP);
   reloadingDelayEffectTime = getTimeSingleton();
   if (player1Health == 3)
   {
    reloadingHealth = 0;
   }
  }
 }
 else if (reloadingHealth == 2)
 {
  if (getTimeSingleton() - reloadingDelayEffectTime > 500)
  {
   player2Health++;
   playSFX(SFX_LIFEUP);
   reloadingDelayEffectTime = getTimeSingleton();
   if (player2Health == 3)
   {
    reloadingHealth = 0;
   }
  }
 }
 if ((getTimeSingleton() - restPeriodStart > 5500 && waveNumber > 0) || (getTimeSingleton() - restPeriodStart > 2 * 5500 && waveNumber == 0))
 {
  waveNumber++;
  restPeriod = 0;
  enemiesLeftToPush = 10;
  if (waveNumber >= 3)
  {
   maxOnScreenRobots += 3;
  }
  char msg[49];
  sprintf(msg, "WAVE %.2d", waveNumber);
  pushNewMessage(msg);
  randomizeWaveTypes();
  if (waveNumber > 1)
  {
   currentBGM = randomizeBGM(currentBGM);
   playBGM(currentBGM);
  }
 }
}

canonical_original_code:
void updateRestPeriod()
{
 int i;
 if (restPeriodStart == 0)
 {
  restPeriodStart = getTimeSingleton();
  return;
 }
 if ((player1Health == 0 || player2Health == 0) && gameEnding == 0)
 {
  union Entity **entList = getEntityList();
  if (entList != ((void *)0))
  {
   for (i = 0; i < getEntityListSize(); i++)
   {
    if (entList[i]->base.type == PLAYER1)
    {
     if (entList[i]->player.dead == 2)
     {
      entList[i]->player.dead = 0;
      reloadingHealth = 1;
      reloadingDelayEffectTime = getTimeSingleton();
      player1Health++;
      playSFX(SFX_LIFEUP);
     }
    }
    if (entList[i]->base.type == PLAYER2)
    {
     if (entList[i]->player.dead == 2)
     {
      entList[i]->player.dead = 0;
      reloadingHealth = 2;
      reloadingDelayEffectTime = getTimeSingleton();
      player2Health++;
      playSFX(SFX_LIFEUP);
     }
    }
   }
  }
 }
 else if (reloadingHealth == 1)
 {
  if (getTimeSingleton() - reloadingDelayEffectTime > 500)
  {
   player1Health++;
   playSFX(SFX_LIFEUP);
   reloadingDelayEffectTime = getTimeSingleton();
   if (player1Health == 3)
   {
    reloadingHealth = 0;
   }
  }
 }
 else if (reloadingHealth == 2)
 {
  if (getTimeSingleton() - reloadingDelayEffectTime > 500)
  {
   player2Health++;
   playSFX(SFX_LIFEUP);
   reloadingDelayEffectTime = getTimeSingleton();
   if (player2Health == 3)
   {
    reloadingHealth = 0;
   }
  }
 }
 if ((getTimeSingleton() - restPeriodStart > 5500 && waveNumber > 0) || (getTimeSingleton() - restPeriodStart > 2 * 5500 && waveNumber == 0))
 {
  waveNumber++;
  restPeriod = 0;
  enemiesLeftToPush = 10;
  if (waveNumber >= 3)
  {
   maxOnScreenRobots += 3;
  }
  char msg[49];
  sprintf(msg, "WAVE %.2d", waveNumber);
  pushNewMessage(msg);
  randomizeWaveTypes();
  if (waveNumber > 1)
  {
   currentBGM = randomizeBGM(currentBGM);
   playBGM(currentBGM);
  }
 }
}

variable_types: union Entity { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; struct entityBase { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; } base; struct Player { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; int offsetX; int offsetY; unsigned char direction; unsigned char upKeyDown; unsigned char downKeyDown; unsigned char leftKeyDown; unsigned char rightKeyDown; unsigned char aKeyDown; unsigned char bKeyDown; unsigned int swordTimer; int isThrusting; int thrustHit; struct GameBlock { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; int height; unsigned int lastUpdateTime; unsigned int startTime; enum BlockType { NO_BLOCK=0, RED_BLOCK=1, BLUE_BLOCK=2, GREEN_BLOCK=3, YELLOW_BLOCK=4 } bType; } *holding; unsigned int lastUpdate; unsigned char knockBackDirection; unsigned int lastFrameUpdate; int frame; int holdingSuperHammer; int dead; } player; struct PermaBlock { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; } permaBlock; struct GameBlock gBlock; struct IceBlock { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; int moving; unsigned char direction; int offsetX; int offsetY; unsigned int lastMovementUpdate; int health; unsigned int startTime; } iBlock; struct Explosion { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; unsigned int startTime; } exp; struct Laser { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; unsigned char direction; int offsetX; int offsetY; unsigned int lastMovementUpdate; unsigned char allegiance; int frame; unsigned int lastFrameUpdate; } laser; struct TeleBlock { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; unsigned int startTime; int side; struct TeleBlock *twin; unsigned int lastClickTime; int frame; } tBlock; struct IceCream { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; int frame; unsigned int lastFrameUpdateTime; int decoy; unsigned int decoyTime; } iceCream; struct SuperHammer { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; } hammer; struct Shiruken { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; } shiruken; struct FloorGlue { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; unsigned int startTime; int population; } glue; struct Enemy { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; int direction; int offsetX; int offsetY; int health; unsigned int lastMovementUpdate; unsigned char knockBackDirection; struct IceCream *cream; int AISlot1; int AISlot2; int AISlot3; unsigned int timer; unsigned int lastFrameUpdate; int frame; } enemy; struct Poof { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; unsigned int startTime; int offsetX; int offsetY; int colour; int birthed; } poof; } **

variable_types:
msg
char [49]

user_defined_types: union Entity { enum EntityType type; struct entityBase base; struct Player player; struct PermaBlock permaBlock; struct GameBlock gBlock; struct IceBlock iBlock; struct Explosion exp; struct Laser laser; struct TeleBlock tBlock; struct IceCream iceCream; struct SuperHammer hammer; struct Shiruken shiruken; struct FloorGlue glue; struct Enemy enemy; struct Poof poof; }

user_defined_types: struct entityBase { enum EntityType type; int x; int y; }

user_defined_types: struct Player { enum EntityType type; int x; int y; int offsetX; int offsetY; unsigned char direction; unsigned char upKeyDown; unsigned char downKeyDown; unsigned char leftKeyDown; unsigned char rightKeyDown; unsigned char aKeyDown; unsigned char bKeyDown; unsigned int swordTimer; int isThrusting; int thrustHit; struct GameBlock *holding; unsigned int lastUpdate; unsigned char knockBackDirection; unsigned int lastFrameUpdate; int frame; int holdingSuperHammer; int dead; }

user_defined_types: struct PermaBlock { enum EntityType type; int x; int y; }

user_defined_types: struct IceBlock { enum EntityType type; int x; int y; int moving; unsigned char direction; int offsetX; int offsetY; unsigned int lastMovementUpdate; int health; unsigned int startTime; }

user_defined_types: struct Explosion { enum EntityType type; int x; int y; unsigned int startTime; }

user_defined_types: struct Laser { enum EntityType type; int x; int y; unsigned char direction; int offsetX; int offsetY; unsigned int lastMovementUpdate; unsigned char allegiance; int frame; unsigned int lastFrameUpdate; }

user_defined_types: struct TeleBlock { enum EntityType type; int x; int y; unsigned int startTime; int side; struct TeleBlock *twin; unsigned int lastClickTime; int frame; }

user_defined_types: struct IceCream { enum EntityType type; int x; int y; int frame; unsigned int lastFrameUpdateTime; int decoy; unsigned int decoyTime; }

user_defined_types: struct SuperHammer { enum EntityType type; int x; int y; }

user_defined_types: struct Shiruken { enum EntityType type; int x; int y; }

user_defined_types: struct FloorGlue { enum EntityType type; int x; int y; unsigned int startTime; int population; }

user_defined_types: struct Enemy { enum EntityType type; int x; int y; int direction; int offsetX; int offsetY; int health; unsigned int lastMovementUpdate; unsigned char knockBackDirection; struct IceCream *cream; int AISlot1; int AISlot2; int AISlot3; unsigned int timer; unsigned int lastFrameUpdate; int frame; }

user_defined_types: struct Poof { enum EntityType type; int x; int y; unsigned int startTime; int offsetX; int offsetY; int colour; int birthed; }

user_defined_types: struct GameBlock { enum EntityType type; int x; int y; int height; unsigned int lastUpdateTime; unsigned int startTime; enum BlockType bType; }


updateWave

decompiled_code:
__int64 updateWave()
{
int v0; // er13
int v1; // er12
int v2; // ebp
__int64 v3; // rbx
__int64 v4; // r14
_DWORD *v5; // rax
int v6; // ebx
__int64 result; // rax
unsigned int v8; // ebx
int v9; // ebx
unsigned int v10; // er12
char v11; // al
unsigned int v12; // er14
char v13; // al
__int64 v14; // r14
int v15; // eax
char v16; // al
int v17; // [rsp+Ch] [rbp-5Ch] BYREF
char v18[88]; // [rsp+10h] [rbp-58h] BYREF

v0 = 0;
v1 = 0;
v2 = 0;
v3 = 0LL;
v4 = getEntityList();
while ( (int)getEntityListSize() > (int)v3 )
{
if ( v2 > 299 || (unsigned int)(**(_DWORD **)(v4 + 8 * v3) - 8) > 3 )
{
if ( v0 <= 29 )
{
v5 = *(_DWORD **)(v4 + 8 * v3);
if ( *v5 == 12 )
{
v0 += v5[5] == 0;
goto LABEL_6;
}
}
}
else
{
++v2;
}
if ( v1 <= 299 )
v1 += **(_DWORD **)(v4 + 8 * v3) == 3;
LABEL_6:
++v3;
}
v6 = lastUpdateTime;
result = getTimeSingleton();
if ( (unsigned int)(v6 - result) > 0x3E8 )
{
v8 = (unsigned int)xrand() % 0x2710;
if ( maxOnScreenRobots > v2
&& enemiesLeftToPush > 0
&& (unsigned int)getTimeSingleton() - sinceLastEnemyOutput > enemyPushInterval )
{
if ( (xrand() & 1) != 0 )
{
v13 = xrand();
v14 = pushEntity((unsigned int)waveTypeEnemy1, 0xFFFFFFFFLL, (v13 & 7u) + 6);
}
else
{
v16 = xrand();
v14 = pushEntity((unsigned int)waveTypeEnemy2, 0xFFFFFFFFLL, (v16 & 7u) + 6);
}
*(_DWORD *)(v14 + 12) = 1;
if ( (xrand() & 1) == 0 )
{
*(_DWORD *)(v14 + 4) += 21;
*(_DWORD *)(v14 + 12) = 3;
}
v15 = getTimeSingleton();
--enemiesLeftToPush;
sinceLastEnemyOutput = v15;
}
if ( v8 <= 0x4F && v1 <= 19 )
{
v9 = 5;
while ( 1 )
{
v10 = (xrand() & 0xF) + 2;
v11 = xrand();
v17 = 0;
v12 = (v11 & 7) + 6;
occupyingOnHere(v10, v12, v18, 5LL, &v17);
if ( !v17 )
break;
if ( !--v9 )
goto LABEL_24;
}
if ( (xrand() & 1) != 0 )
*(_DWORD *)(pushEntity(3LL, v10, v12) + 24) = waveTypeBlock2;
else
*(_DWORD *)(pushEntity(3LL, v10, v12) + 24) = waveTypeBlock1;
}
LABEL_24:
result = getTimeSingleton();
lastUpdateTime = result;
}
if ( !(enemiesLeftToPush | v2) )
{
restPeriod = 1;
restPeriodStart = getTimeSingleton();
switch ( rand() % 10 )
{
case 0:
pushNewMessage("NICE ONE! WAVE COMPLETE!");
break;
case 1:
pushNewMessage("WAVE COMPLETE! PARTY ROCK!");
break;
case 2:
pushNewMessage("SO MUCH WAVE COMPLETE RIGHT NOW!");
break;
case 3:
pushNewMessage("BOYFRIENDS SAFE! WAVE COMPLETE!");
break;
case 4:
pushNewMessage("WAVE COMPLETE! MOMS LOVE YOU!");
break;
case 5:
pushNewMessage("HARDCORE WAVE COMPLETE!");
break;
case 6:
pushNewMessage("YOU JUST COMPLETED THAT WAVE!");
break;
case 7:
pushNewMessage("WAVE OF BADDIES BUSTED!");
break;
case 8:
pushNewMessage("THIS WAVE IS SO OVER YOU GUYS!");
break;
case 9:
pushNewMessage("WAVE CONQUERED AND STUFF!");
break;
default:
pushNewMessage("WAVE COMPLETE!");
break;
}
result = fadeBGM();
}
if ( numberOfIceCreams > v0 && v0 > 0 )
{
pushNewMessage("PRINCE BOYFRIEND LOST!");
result = playSFX(21LL);
}
numberOfIceCreams = v0;
return result;
}

canonical_decompiled_code:
__int64 func4()
{
int v0; // er13
int v1; // er12
int v2; // ebp
__int64 v3; // rbx
__int64 v4; // r14
_DWORD *v5; // rax
int v6; // ebx
__int64 result; // rax
unsigned int v8; // ebx
int v9; // ebx
unsigned int v10; // er12
char v11; // al
unsigned int v12; // er14
char v13; // al
__int64 v14; // r14
int v15; // eax
char v16; // al
int v17; // [rsp+Ch] [rbp-5Ch] BYREF
char v18[88]; // [rsp+10h] [rbp-58h] BYREF

v0 = 0;
v1 = 0;
v2 = 0;
v3 = 0LL;
v4 = getEntityList();
while ( (int)getEntityListSize() > (int)v3 )
{
if ( v2 > 299 || (unsigned int)(**(_DWORD **)(v4 + 8 * v3) - 8) > 3 )
{
if ( v0 <= 29 )
{
v5 = *(_DWORD **)(v4 + 8 * v3);
if ( *v5 == 12 )
{
v0 += v5[5] == 0;
goto LABEL_6;
}
}
}
else
{
++v2;
}
if ( v1 <= 299 )
v1 += **(_DWORD **)(v4 + 8 * v3) == 3;
LABEL_6:
++v3;
}
v6 = lastUpdateTime;
result = getTimeSingleton();
if ( (unsigned int)(v6 - result) > 0x3E8 )
{
v8 = (unsigned int)func0() % 0x2710;
if ( maxOnScreenRobots > v2
&& enemiesLeftToPush > 0
&& (unsigned int)getTimeSingleton() - sinceLastEnemyOutput > enemyPushInterval )
{
if ( (func0() & 1) != 0 )
{
v13 = func0();
v14 = pushEntity((unsigned int)waveTypeEnemy1, 0xFFFFFFFFLL, (v13 & 7u) + 6);
}
else
{
v16 = func0();
v14 = pushEntity((unsigned int)waveTypeEnemy2, 0xFFFFFFFFLL, (v16 & 7u) + 6);
}
*(_DWORD *)(v14 + 12) = 1;
if ( (func0() & 1) == 0 )
{
*(_DWORD *)(v14 + 4) += 21;
*(_DWORD *)(v14 + 12) = 3;
}
v15 = getTimeSingleton();
--enemiesLeftToPush;
sinceLastEnemyOutput = v15;
}
if ( v8 <= 0x4F && v1 <= 19 )
{
v9 = 5;
while ( 1 )
{
v10 = (func0() & 0xF) + 2;
v11 = func0();
v17 = 0;
v12 = (v11 & 7) + 6;
occupyingOnHere(v10, v12, v18, 5LL, &v17);
if ( !v17 )
break;
if ( !--v9 )
goto LABEL_24;
}
if ( (func0() & 1) != 0 )
*(_DWORD *)(pushEntity(3LL, v10, v12) + 24) = waveTypeBlock2;
else
*(_DWORD *)(pushEntity(3LL, v10, v12) + 24) = waveTypeBlock1;
}
LABEL_24:
result = getTimeSingleton();
lastUpdateTime = result;
}
if ( !(enemiesLeftToPush | v2) )
{
restPeriod = 1;
restPeriodStart = getTimeSingleton();
switch ( rand() % 10 )
{
case 0:
pushNewMessage("NICE ONE! WAVE COMPLETE!");
break;
case 1:
pushNewMessage("WAVE COMPLETE! PARTY ROCK!");
break;
case 2:
pushNewMessage("SO MUCH WAVE COMPLETE RIGHT NOW!");
break;
case 3:
pushNewMessage("BOYFRIENDS SAFE! WAVE COMPLETE!");
break;
case 4:
pushNewMessage("WAVE COMPLETE! MOMS LOVE YOU!");
break;
case 5:
pushNewMessage("HARDCORE WAVE COMPLETE!");
break;
case 6:
pushNewMessage("YOU JUST COMPLETED THAT WAVE!");
break;
case 7:
pushNewMessage("WAVE OF BADDIES BUSTED!");
break;
case 8:
pushNewMessage("THIS WAVE IS SO OVER YOU GUYS!");
break;
case 9:
pushNewMessage("WAVE CONQUERED AND STUFF!");
break;
default:
pushNewMessage("WAVE COMPLETE!");
break;
}
result = fadeBGM();
}
if ( numberOfIceCreams > v0 && v0 > 0 )
{
pushNewMessage("PRINCE BOYFRIEND LOST!");
result = playSFX(21LL);
}
numberOfIceCreams = v0;
return result;
}

original_code:
void updateWave()
{
 int i;
 int gameBlockCount = 0;
 int enemyCount = 0;
 int iceCreamCount = 0;
 Entity** entList = getEntityList();
 for (i = 0; i < getEntityListSize(); i++)
 {
  if (enemyCount < 300 && (entList[i]->type == ENEMY_FAST || entList[i]->type == ENEMY_SHOOTER || entList[i]->type == ENEMY_CRAWLER || entList[i]->type == ENEMY_BOXERGREG))
  {
   enemyCount++;
  }
  if (iceCreamCount < 30 && entList[i]->type == ICECREAM && entList[i]->iceCream.decoy == 0)
  {
   iceCreamCount++;
  }
  if (gameBlockCount < 300 && entList[i]->type == GAMEBLOCK)
  {
   gameBlockCount++;
  }
 }
 if (lastUpdateTime - getTimeSingleton() > 1000)
 {
  unsigned int val = xrand() % 10000;
  if (enemyCount < maxOnScreenRobots && enemiesLeftToPush > 0)
  {
   if (getTimeSingleton() - sinceLastEnemyOutput > enemyPushInterval)
   {
    Enemy* en;
    switch (xrand() % 2)
    {
     case 1:
     en = (Enemy*)pushEntity(waveTypeEnemy1, -1, (xrand() % 8) + 6);
     break;
     case 0:
     default:
     en = (Enemy*)pushEntity(waveTypeEnemy2, -1, (xrand() % 8) + 6);
     break;
    }
    en->direction = 1;
    if (xrand() % 2 == 0)
    {
     en->x += 20 + 1;
     en->direction = 3;
    }
    sinceLastEnemyOutput = getTimeSingleton();
    enemiesLeftToPush--;
   }
  }
  if (gameBlockCount < 20)
  {
   if(val / 20 < 4)
   {
    int i;
    int xSpot = -1;
    int ySpot = -1;
    for (i = 0; i < 5; i++)
    {
     xSpot = (xrand() % (20 - 4)) + 2;
     ySpot = (xrand() % 8) + 6;
     Entity* checkList[5];
     int checkResultSize = 0;
     occupyingOnHere(xSpot, ySpot, checkList, 5, &checkResultSize);
     if (checkResultSize == 0)
     {
      Entity* newBlock;
      switch (xrand() % 2)
      {
       case 0:
       newBlock = pushEntity(GAMEBLOCK, xSpot, ySpot);
                     newBlock->gBlock.bType = waveTypeBlock1;
                     break;
       case 1:
       newBlock = pushEntity(GAMEBLOCK, xSpot, ySpot);
                     newBlock->gBlock.bType = waveTypeBlock2;
                     break;
       default:
       break;
      }
      break;
     }
    }
   }
  }
  lastUpdateTime = getTimeSingleton();
 }
 if (enemiesLeftToPush == 0 && enemyCount == 0)
 {
  restPeriod = 1;
  restPeriodStart = getTimeSingleton();
  switch (rand() % 10)
  {
   case 0:
   pushNewMessage("NICE ONE! WAVE COMPLETE!");
   break;
   case 1:
   pushNewMessage("WAVE COMPLETE! PARTY ROCK!");
   break;
   case 2:
   pushNewMessage("SO MUCH WAVE COMPLETE RIGHT NOW!");
   break;
   case 3:
   pushNewMessage("BOYFRIENDS SAFE! WAVE COMPLETE!");
   break;
   case 4:
   pushNewMessage("WAVE COMPLETE! MOMS LOVE YOU!");
   break;
                        case 5:
   pushNewMessage("HARDCORE WAVE COMPLETE!");
   break;
   case 6:
   pushNewMessage("YOU JUST COMPLETED THAT WAVE!");
   break;
   case 7:
   pushNewMessage("WAVE OF BADDIES BUSTED!");
   break;
   case 8:
   pushNewMessage("THIS WAVE IS SO OVER YOU GUYS!");
   break;
   case 9:
   pushNewMessage("WAVE CONQUERED AND STUFF!");
   break;
   default:
   pushNewMessage("WAVE COMPLETE!");
   break;
  }
  fadeBGM();
 }
 if (iceCreamCount < numberOfIceCreams && iceCreamCount > 0)
 {
  pushNewMessage("PRINCE BOYFRIEND LOST!");
  playSFX(SFX_LOSE_PRINCESS);
 }
 numberOfIceCreams = iceCreamCount;
}

canonical_original_code:
void updateWave()
{
 int i;
 int gameBlockCount = 0;
 int enemyCount = 0;
 int iceCreamCount = 0;
 union Entity **entList = getEntityList();
 for (i = 0; i < getEntityListSize(); i++)
 {
  if (enemyCount < 300 && (entList[i]->type == ENEMY_FAST || entList[i]->type == ENEMY_SHOOTER || entList[i]->type == ENEMY_CRAWLER || entList[i]->type == ENEMY_BOXERGREG))
  {
   enemyCount++;
  }
  if (iceCreamCount < 30 && entList[i]->type == ICECREAM && entList[i]->iceCream.decoy == 0)
  {
   iceCreamCount++;
  }
  if (gameBlockCount < 300 && entList[i]->type == GAMEBLOCK)
  {
   gameBlockCount++;
  }
 }
 if (lastUpdateTime - getTimeSingleton() > 1000)
 {
  unsigned int val = xrand() % 10000;
  if (enemyCount < maxOnScreenRobots && enemiesLeftToPush > 0)
  {
   if (getTimeSingleton() - sinceLastEnemyOutput > enemyPushInterval)
   {
    struct Enemy *en;
    switch (xrand() % 2)
    {
     case 1:
     en = (struct Enemy *)pushEntity(waveTypeEnemy1, -1, (xrand() % 8) + 6);
     break;
     case 0:
     default:
     en = (struct Enemy *)pushEntity(waveTypeEnemy2, -1, (xrand() % 8) + 6);
     break;
    }
    en->direction = 1;
    if (xrand() % 2 == 0)
    {
     en->x += 20 + 1;
     en->direction = 3;
    }
    sinceLastEnemyOutput = getTimeSingleton();
    enemiesLeftToPush--;
   }
  }
  if (gameBlockCount < 20)
  {
   if(val / 20 < 4)
   {
    int i;
    int xSpot = -1;
    int ySpot = -1;
    for (i = 0; i < 5; i++)
    {
     xSpot = (xrand() % (20 - 4)) + 2;
     ySpot = (xrand() % 8) + 6;
     union Entity *checkList[5];
     int checkResultSize = 0;
     occupyingOnHere(xSpot, ySpot, checkList, 5, &checkResultSize);
     if (checkResultSize == 0)
     {
      union Entity *newBlock;
      switch (xrand() % 2)
      {
       case 0:
       newBlock = pushEntity(GAMEBLOCK, xSpot, ySpot);
                     newBlock->gBlock.bType = waveTypeBlock1;
                     break;
       case 1:
       newBlock = pushEntity(GAMEBLOCK, xSpot, ySpot);
                     newBlock->gBlock.bType = waveTypeBlock2;
                     break;
       default:
       break;
      }
      break;
     }
    }
   }
  }
  lastUpdateTime = getTimeSingleton();
 }
 if (enemiesLeftToPush == 0 && enemyCount == 0)
 {
  restPeriod = 1;
  restPeriodStart = getTimeSingleton();
  switch (rand() % 10)
  {
   case 0:
   pushNewMessage("NICE ONE! WAVE COMPLETE!");
   break;
   case 1:
   pushNewMessage("WAVE COMPLETE! PARTY ROCK!");
   break;
   case 2:
   pushNewMessage("SO MUCH WAVE COMPLETE RIGHT NOW!");
   break;
   case 3:
   pushNewMessage("BOYFRIENDS SAFE! WAVE COMPLETE!");
   break;
   case 4:
   pushNewMessage("WAVE COMPLETE! MOMS LOVE YOU!");
   break;
                        case 5:
   pushNewMessage("HARDCORE WAVE COMPLETE!");
   break;
   case 6:
   pushNewMessage("YOU JUST COMPLETED THAT WAVE!");
   break;
   case 7:
   pushNewMessage("WAVE OF BADDIES BUSTED!");
   break;
   case 8:
   pushNewMessage("THIS WAVE IS SO OVER YOU GUYS!");
   break;
   case 9:
   pushNewMessage("WAVE CONQUERED AND STUFF!");
   break;
   default:
   pushNewMessage("WAVE COMPLETE!");
   break;
  }
  fadeBGM();
 }
 if (iceCreamCount < numberOfIceCreams && iceCreamCount > 0)
 {
  pushNewMessage("PRINCE BOYFRIEND LOST!");
  playSFX(SFX_LOSE_PRINCESS);
 }
 numberOfIceCreams = iceCreamCount;
}

variable_types: gameBlockCount int

variable_types: enemyCount int

variable_types: iceCreamCount int

variable_types:
val
unsigned int

variable_types: struct Enemy { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; int direction; int offsetX; int offsetY; int health; unsigned int lastMovementUpdate; unsigned char knockBackDirection; struct IceCream { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; int frame; unsigned int lastFrameUpdateTime; int decoy; unsigned int decoyTime; } *cream; int AISlot1; int AISlot2; int AISlot3; unsigned int timer; unsigned int lastFrameUpdate; int frame; } *

variable_types: xSpot int

variable_types: ySpot int

variable_types: union Entity { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; struct entityBase { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; } base; struct Player { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; int offsetX; int offsetY; unsigned char direction; unsigned char upKeyDown; unsigned char downKeyDown; unsigned char leftKeyDown; unsigned char rightKeyDown; unsigned char aKeyDown; unsigned char bKeyDown; unsigned int swordTimer; int isThrusting; int thrustHit; struct GameBlock { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; int height; unsigned int lastUpdateTime; unsigned int startTime; enum BlockType { NO_BLOCK=0, RED_BLOCK=1, BLUE_BLOCK=2, GREEN_BLOCK=3, YELLOW_BLOCK=4 } bType; } *holding; unsigned int lastUpdate; unsigned char knockBackDirection; unsigned int lastFrameUpdate; int frame; int holdingSuperHammer; int dead; } player; struct PermaBlock { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; } permaBlock; struct GameBlock gBlock; struct IceBlock { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; int moving; unsigned char direction; int offsetX; int offsetY; unsigned int lastMovementUpdate; int health; unsigned int startTime; } iBlock; struct Explosion { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; unsigned int startTime; } exp; struct Laser { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; unsigned char direction; int offsetX; int offsetY; unsigned int lastMovementUpdate; unsigned char allegiance; int frame; unsigned int lastFrameUpdate; } laser; struct TeleBlock { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; unsigned int startTime; int side; struct TeleBlock *twin; unsigned int lastClickTime; int frame; } tBlock; struct IceCream { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; int frame; unsigned int lastFrameUpdateTime; int decoy; unsigned int decoyTime; } iceCream; struct SuperHammer { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; } hammer; struct Shiruken { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; } shiruken; struct FloorGlue { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; unsigned int startTime; int population; } glue; struct Enemy { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; int direction; int offsetX; int offsetY; int health; unsigned int lastMovementUpdate; unsigned char knockBackDirection; struct IceCream *cream; int AISlot1; int AISlot2; int AISlot3; unsigned int timer; unsigned int lastFrameUpdate; int frame; } enemy; struct Poof { enum EntityType { PLAYER1=0, PLAYER2=1, PERMABLOCK=2, GAMEBLOCK=3, ICEBLOCK=4, EXPLOSION=5, LASER=6, TELEBLOCK=7, ENEMY_CRAWLER=8, ENEMY_SHOOTER=9, ENEMY_BOXERGREG=10, ENEMY_FAST=11, ICECREAM=12, SUPERHAMMER=13, SHIRUKEN=14, GLUE=15, POOF=16, HEART=17, DELETE_ME_PLEASE=18 } type; int x; int y; unsigned int startTime; int offsetX; int offsetY; int colour; int birthed; } poof; } *[5]

variable_types: checkResultSize int


updateGameLogic

decompiled_code:
void updateGameLogic()
{
if ( gameState )
{
if ( !lastUpdateTime )
{
lastUpdateTime = getTimeSingleton();
return;
}
if ( player1Health <= 0 && (!is2PlayerGame || player2Health <= 0 && is2PlayerGame == 1) )
{
if ( gameEnding )
{
if ( gameEnding != 1 )
{
LABEL_5:
if ( restPeriod )
{
if ( restPeriod == 1 )
updateRestPeriod();
}
else
{
updateWave();
}
return;
}
if ( (unsigned int)getTimeSingleton() - endGameDelta > 0x1388 )
gameState = 2;
}
else
{
gameEnding = 1;
endGameDelta = getTimeSingleton();
}
}
if ( numberOfIceCreams <= 0 )
{
if ( gameEnding )
{
if ( gameEnding == 1 && (unsigned int)getTimeSingleton() - endGameDelta > 0x1B58 )
gameState = 3;
}
else
{
pushNewMessage("no more princes!");
gameEnding = 1;
endGameDelta = getTimeSingleton();
}
}
goto LABEL_5;
}
}

canonical_decompiled_code:
void func5()
{
if ( gameState )
{
if ( !lastUpdateTime )
{
lastUpdateTime = getTimeSingleton();
return;
}
if ( player1Health <= 0 && (!is2PlayerGame || player2Health <= 0 && is2PlayerGame == 1) )
{
if ( gameEnding )
{
if ( gameEnding != 1 )
{
LABEL_5:
if ( restPeriod )
{
if ( restPeriod == 1 )
func3();
}
else
{
func4();
}
return;
}
if ( (unsigned int)getTimeSingleton() - endGameDelta > 0x1388 )
gameState = 2;
}
else
{
gameEnding = 1;
endGameDelta = getTimeSingleton();
}
}
if ( numberOfIceCreams <= 0 )
{
if ( gameEnding )
{
if ( gameEnding == 1 && (unsigned int)getTimeSingleton() - endGameDelta > 0x1B58 )
gameState = 3;
}
else
{
pushNewMessage("no more princes!");
gameEnding = 1;
endGameDelta = getTimeSingleton();
}
}
goto LABEL_5;
}
}

original_code:
void updateGameLogic()
{
 if (gameState == 0)
 {
  return;
 }
 if (lastUpdateTime == 0)
 {
  lastUpdateTime = getTimeSingleton();
  return;
 }
 if ( (player1Health < 1 && is2PlayerGame == 0) || (player1Health < 1 && player2Health < 1 && is2PlayerGame == 1) )
 {
  if (gameEnding == 0)
  {
   gameEnding = 1;
   endGameDelta = getTimeSingleton();
  }
  else if (gameEnding == 1)
  {
   if (getTimeSingleton() - endGameDelta > 5 * 1000)
   {
    gameState = 2;
   }
  }
 }
 if (numberOfIceCreams < 1)
 {
  if (gameEnding == 0)
  {
   pushNewMessage("no more princes!");
   gameEnding = 1;
   endGameDelta = getTimeSingleton();
  }
  else if (gameEnding == 1)
  {
   if (getTimeSingleton() - endGameDelta > 7 * 1000)
   {
    gameState = 3;
   }
  }
 }
 if (restPeriod == 0)
 {
  updateWave();
 }
 else if (restPeriod == 1)
 {
  updateRestPeriod();
 }
}


clearResetGame

decompiled_code:
__int64 __fastcall clearResetGame(int a1)
{
unsigned int v1; // ebx
__int64 v2; // rsi
unsigned int i; // ebx
__int64 v4; // rdx
__int64 result; // rax

gameState = 0;
if ( a1 == 2 )
{
player1Health = 5;
player2Health = 5;
player1MaxHealth = 5;
}
else
{
player1Health = 10;
player2Health = 10;
player1MaxHealth = 10;
}
player2MaxHealth = 5;
gameScore = 0;
gameEnding = 0;
waveNumber = 0;
currentBGM = 0;
maxOnScreenRobots = 5;
enemyPushInterval = 3000;
if ( getEntityList() )
freeEntityList();
v1 = -2;
initEntityList();
do
{
pushEntity(2LL, v1, 5LL);
v2 = v1++;
pushEntity(2LL, v2, 14LL);
}
while ( v1 != 23 );
for ( i = 5; i != 20; ++i )
{
pushEntity(2LL, 4294967294LL, i);
v4 = i;
pushEntity(2LL, 21LL, v4);
}
pushEntity(12LL, 9LL, 7LL);
pushEntity(12LL, 9LL, 8LL);
pushEntity(12LL, 9LL, 11LL);
pushEntity(12LL, 9LL, 12LL);
pushEntity(12LL, 10LL, 7LL);
pushEntity(12LL, 10LL, 8LL);
pushEntity(12LL, 10LL, 11LL);
pushEntity(12LL, 10LL, 12LL);
if ( a1 != 1 )
{
if ( a1 == 2 )
{
pushEntity(0LL, 10LL, 9LL);
pushEntity(1LL, 11LL, 9LL);
result = 0LL;
is2PlayerGame = 1;
return result;
}
printf("ODD PLAYER COUNT; FIX THIS AND MAKE IT ATOMIC");
}
pushEntity(0LL, 10LL, 9LL);
result = 0LL;
is2PlayerGame = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
unsigned int v1; // ebx
__int64 v2; // rsi
unsigned int i; // ebx
__int64 v4; // rdx
__int64 result; // rax

gameState = 0;
if ( a1 == 2 )
{
player1Health = 5;
player2Health = 5;
player1MaxHealth = 5;
}
else
{
player1Health = 10;
player2Health = 10;
player1MaxHealth = 10;
}
player2MaxHealth = 5;
gameScore = 0;
gameEnding = 0;
waveNumber = 0;
currentBGM = 0;
maxOnScreenRobots = 5;
enemyPushInterval = 3000;
if ( getEntityList() )
freeEntityList();
v1 = -2;
initEntityList();
do
{
pushEntity(2LL, v1, 5LL);
v2 = v1++;
pushEntity(2LL, v2, 14LL);
}
while ( v1 != 23 );
for ( i = 5; i != 20; ++i )
{
pushEntity(2LL, 4294967294LL, i);
v4 = i;
pushEntity(2LL, 21LL, v4);
}
pushEntity(12LL, 9LL, 7LL);
pushEntity(12LL, 9LL, 8LL);
pushEntity(12LL, 9LL, 11LL);
pushEntity(12LL, 9LL, 12LL);
pushEntity(12LL, 10LL, 7LL);
pushEntity(12LL, 10LL, 8LL);
pushEntity(12LL, 10LL, 11LL);
pushEntity(12LL, 10LL, 12LL);
if ( a1 != 1 )
{
if ( a1 == 2 )
{
pushEntity(0LL, 10LL, 9LL);
pushEntity(1LL, 11LL, 9LL);
result = 0LL;
is2PlayerGame = 1;
return result;
}
printf("ODD PLAYER COUNT; FIX THIS AND MAKE IT ATOMIC");
}
pushEntity(0LL, 10LL, 9LL);
result = 0LL;
is2PlayerGame = 0;
return result;
}

original_code:
int clearResetGame(int playerCount)
{
 int i;
 gameState = 0;
 if (playerCount == 2)
 {
  player1Health = 5;
  player2Health = 5;
  player1MaxHealth = 5;
  player2MaxHealth = 5;
 }
 else
 {
  player1Health = 10;
  player2Health = 10;
  player1MaxHealth = 10;
  player2MaxHealth = 5;
 }
 gameScore = 0;
 gameEnding = 0;
 waveNumber = 0;
 currentBGM = BGM_NONE;
 maxOnScreenRobots = 5;
 enemyPushInterval = 3000;
 if (getEntityList() != ((void *)0))
 {
  freeEntityList();
 }
 initEntityList();
 for (i = -2; i < 20 + 3; i++)
 {
  pushEntity(PERMABLOCK, i, 5);
  pushEntity(PERMABLOCK, i, 14);
 }
 for (i = 0; i < 13 + 2; i++)
 {
  pushEntity(PERMABLOCK, -2, 5 + i);
  pushEntity(PERMABLOCK, 20 + 1, 5 + i);
 }
 for (i = 0; i < 2; i++)
 {
  pushEntity(ICECREAM, 9 + i, 7);
  pushEntity(ICECREAM, 9 + i, 8);
  pushEntity(ICECREAM, 9 + i, 11);
  pushEntity(ICECREAM, 9 + i, 12);
 }
 switch (playerCount)
 {
  case 1:
  pushEntity(PLAYER1, 20/2, 9);
  is2PlayerGame = 0;
  break;
  case 2:
  pushEntity(PLAYER1, 20/2, 9);
                pushEntity(PLAYER2, 20/2 + 1, 9);
                is2PlayerGame = 1;
                break;
                default:
                printf("ODD PLAYER COUNT; FIX THIS AND MAKE IT ATOMIC");
                pushEntity(PLAYER1, 20/2, 9);
  is2PlayerGame = 0;
  break;
 }
 return 0;
}

variable_types: playerCount int

variable_types: i int


beginGame

decompiled_code:
__int64 beginGame()
{
unsigned int v0; // er12
unsigned int v2; // eax
unsigned int v3; // eax
const char *v4; // r13
unsigned int v5; // eax
const char *v6; // rax
unsigned int v7; // eax
const char *v8; // r13
unsigned int v9; // eax
const char *v10; // rax
char v11[88]; // [rsp+0h] [rbp-58h] BYREF

v0 = gameState;
if ( gameState )
return 1LL;
gameState = 1;
restPeriod = 1;
numberOfIceCreams = 8;
v2 = SDL_GetTicks();
setTimeSingleton(v2);
pushNewMessage("NINJAS WANT YOUR BOYFRIENDS!");
pushNewMessage("YOU MUST PROTECT THEM!");
v3 = getSDLKeyValue(5LL);
v4 = (const char *)SDL_GetKeyName(v3);
v5 = getSDLKeyValue(6LL);
v6 = (const char *)SDL_GetKeyName(v5);
sprintf(v11, "P1 Keys: %s=Strike, %s=grab block", v6, v4);
pushNewMessage(v11);
if ( is2PlayerGame )
{
v7 = getSDLKeyValue(13LL);
v8 = (const char *)SDL_GetKeyName(v7);
v9 = getSDLKeyValue(14LL);
v10 = (const char *)SDL_GetKeyName(v9);
sprintf(v11, "P2 Keys: %s=Strike, %s=grab block", v10, v8);
pushNewMessage(v11);
}
currentBGM = 2;
playBGM(2LL);
return v0;
}

canonical_decompiled_code:
__int64 func7()
{
unsigned int v0; // er12
unsigned int v2; // eax
unsigned int v3; // eax
const char *v4; // r13
unsigned int v5; // eax
const char *v6; // rax
unsigned int v7; // eax
const char *v8; // r13
unsigned int v9; // eax
const char *v10; // rax
char v11[88]; // [rsp+0h] [rbp-58h] BYREF

v0 = gameState;
if ( gameState )
return 1LL;
gameState = 1;
restPeriod = 1;
numberOfIceCreams = 8;
v2 = SDL_GetTicks();
setTimeSingleton(v2);
pushNewMessage("NINJAS WANT YOUR BOYFRIENDS!");
pushNewMessage("YOU MUST PROTECT THEM!");
v3 = getSDLKeyValue(5LL);
v4 = (const char *)SDL_GetKeyName(v3);
v5 = getSDLKeyValue(6LL);
v6 = (const char *)SDL_GetKeyName(v5);
sprintf(v11, "P1 Keys: %s=Strike, %s=grab block", v6, v4);
pushNewMessage(v11);
if ( is2PlayerGame )
{
v7 = getSDLKeyValue(13LL);
v8 = (const char *)SDL_GetKeyName(v7);
v9 = getSDLKeyValue(14LL);
v10 = (const char *)SDL_GetKeyName(v9);
sprintf(v11, "P2 Keys: %s=Strike, %s=grab block", v10, v8);
pushNewMessage(v11);
}
currentBGM = 2;
playBGM(2LL);
return v0;
}

original_code:
int beginGame()
{
 char playerControlsMessage[50];
 if (gameState != 0)
 {
  return 1;
 }
 gameState = 1;
 restPeriod = 1;
 numberOfIceCreams = 8;
 setTimeSingleton(SDL_GetTicks());
 pushNewMessage("NINJAS WANT YOUR BOYFRIENDS!");
 pushNewMessage("YOU MUST PROTECT THEM!");
 sprintf(playerControlsMessage, "P1 Keys: %s=Strike, %s=grab block", SDL_GetKeyName(getSDLKeyValue(P1_B)), SDL_GetKeyName(getSDLKeyValue(P1_A)));
 pushNewMessage(playerControlsMessage);
 if (is2PlayerGame)
 {
  sprintf(playerControlsMessage, "P2 Keys: %s=Strike, %s=grab block", SDL_GetKeyName(getSDLKeyValue(P2_B)), SDL_GetKeyName(getSDLKeyValue(P2_A)));
  pushNewMessage(playerControlsMessage);
 }
 currentBGM = BGM_1;
 playBGM(currentBGM);
 return 0;
}

variable_types:
playerControlsMessage
char [50]


getPlayerHealth

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

result = (unsigned int)player1Health;
if ( a1 != 1 )
{
result = 0xFFFFFFFFLL;
if ( a1 == 2 )
result = (unsigned int)player2Health;
}
return result;
}

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

result = (unsigned int)player1Health;
if ( a1 != 1 )
{
result = 0xFFFFFFFFLL;
if ( a1 == 2 )
result = (unsigned int)player2Health;
}
return result;
}

original_code:
int getPlayerHealth(int playerNo)
{
 switch (playerNo)
 {
  case 1:
  return player1Health;
  case 2:
  return player2Health;
  default:
  return -1;
 }
}

variable_types: playerNo int


getPlayerMaxHealth

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

result = (unsigned int)player1MaxHealth;
if ( a1 != 1 )
{
result = 0xFFFFFFFFLL;
if ( a1 == 2 )
result = (unsigned int)player2MaxHealth;
}
return result;
}

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

result = (unsigned int)player1MaxHealth;
if ( a1 != 1 )
{
result = 0xFFFFFFFFLL;
if ( a1 == 2 )
result = (unsigned int)player2MaxHealth;
}
return result;
}

original_code:
int getPlayerMaxHealth(int playerNo)
{
 switch (playerNo)
 {
  case 1:
  return player1MaxHealth;
  case 2:
  return player2MaxHealth;
  default:
  return -1;
 }
}


modPlayerHealth

decompiled_code:
__int64 __fastcall modPlayerHealth(int a1, int a2)
{
int v2; // edx
__int64 result; // rax
int v4; // edx

if ( a2 < 0 )
playSFX(3LL);
v2 = player1Health;
result = (unsigned int)player2Health;
if ( a1 == 1 )
{
v2 = a2 + player1Health;
player1Health += a2;
}
else if ( a1 == 2 )
{
result = (unsigned int)(a2 + player2Health);
player2Health += a2;
}
if ( player1MaxHealth >= v2 )
{
if ( v2 < 0 )
{
player1Health = 0;
v4 = player2MaxHealth;
if ( player2MaxHealth < (int)result )
goto LABEL_9;
goto LABEL_13;
}
}
else
{
player1Health = player1MaxHealth;
}
v4 = player2MaxHealth;
if ( player2MaxHealth < (int)result )
{
LABEL_9:
player2Health = v4;
return result;
}
LABEL_13:
if ( (int)result < 0 )
player2Health = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, int a2)
{
int v2; // edx
__int64 result; // rax
int v4; // edx

if ( a2 < 0 )
playSFX(3LL);
v2 = player1Health;
result = (unsigned int)player2Health;
if ( a1 == 1 )
{
v2 = a2 + player1Health;
player1Health += a2;
}
else if ( a1 == 2 )
{
result = (unsigned int)(a2 + player2Health);
player2Health += a2;
}
if ( player1MaxHealth >= v2 )
{
if ( v2 < 0 )
{
player1Health = 0;
v4 = player2MaxHealth;
if ( player2MaxHealth < (int)result )
goto LABEL_9;
goto LABEL_13;
}
}
else
{
player1Health = player1MaxHealth;
}
v4 = player2MaxHealth;
if ( player2MaxHealth < (int)result )
{
LABEL_9:
player2Health = v4;
return result;
}
LABEL_13:
if ( (int)result < 0 )
player2Health = 0;
return result;
}

original_code:
void modPlayerHealth(int playerNo, int delta)
{
 if (delta < 0)
 {
  playSFX(SFX_PLAYER_HURT);
 }
 switch (playerNo)
 {
  case 1:
  player1Health += delta;
  break;
  case 2:
  player2Health += delta;
  break;
  default:
  break;
 }
 if (player1Health > player1MaxHealth)
 {
  player1Health = player1MaxHealth;
 }
 else if (player1Health < 0)
 {
  player1Health = 0;
 }
 if (player2Health > player2MaxHealth)
 {
  player2Health = player2MaxHealth;
 }
 else if (player2Health < 0)
 {
  player2Health = 0;
 }
}

variable_types: delta int


modPlayermaxHealth

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

v2 = player1MaxHealth;
result = (unsigned int)player2MaxHealth;
if ( a1 == 1 )
{
v2 = a2 + player1MaxHealth;
player1MaxHealth += a2;
}
else if ( a1 == 2 )
{
result = (unsigned int)(a2 + player2MaxHealth);
player2MaxHealth += a2;
}
if ( v2 <= 99 )
{
if ( v2 < 0 )
{
player1MaxHealth = 0;
if ( (int)result > 99 )
goto LABEL_7;
goto LABEL_10;
}
}
else
{
player1MaxHealth = 99;
}
if ( (int)result > 99 )
{
LABEL_7:
player2MaxHealth = 99;
return result;
}
LABEL_10:
if ( (int)result < 0 )
player2MaxHealth = 0;
return result;
}

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

v2 = player1MaxHealth;
result = (unsigned int)player2MaxHealth;
if ( a1 == 1 )
{
v2 = a2 + player1MaxHealth;
player1MaxHealth += a2;
}
else if ( a1 == 2 )
{
result = (unsigned int)(a2 + player2MaxHealth);
player2MaxHealth += a2;
}
if ( v2 <= 99 )
{
if ( v2 < 0 )
{
player1MaxHealth = 0;
if ( (int)result > 99 )
goto LABEL_7;
goto LABEL_10;
}
}
else
{
player1MaxHealth = 99;
}
if ( (int)result > 99 )
{
LABEL_7:
player2MaxHealth = 99;
return result;
}
LABEL_10:
if ( (int)result < 0 )
player2MaxHealth = 0;
return result;
}

original_code:
void modPlayermaxHealth(int playerNo, int delta)
{
 switch (playerNo)
 {
  case 1:
  player1MaxHealth += delta;
  break;
  case 2:
  player2MaxHealth += delta;
  break;
  default:
  break;
 }
 if (player1MaxHealth > 99)
 {
  player1MaxHealth = 99;
 }
 else if (player1MaxHealth < 0)
 {
  player1MaxHealth = 0;
 }
 if (player2MaxHealth > 99)
 {
  player2MaxHealth = 99;
 }
 else if (player2MaxHealth < 0)
 {
  player2MaxHealth = 0;
 }
}


getIceCreamCount

decompiled_code:
__int64 getIceCreamCount()
{
return (unsigned int)numberOfIceCreams;
}

canonical_decompiled_code:
__int64 func12()
{
return (unsigned int)numberOfIceCreams;
}

original_code:
int getIceCreamCount()
{
 return numberOfIceCreams;
}


getGameState

decompiled_code:
__int64 getGameState()
{
return (unsigned int)gameState;
}

canonical_decompiled_code:
__int64 func13()
{
return (unsigned int)gameState;
}

original_code:
int getGameState()
{
 return gameState;
}


getPlayerCount

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

result = (unsigned int)gameState;
if ( gameState )
result = 1 - ((unsigned int)(is2PlayerGame == 0) - 1);
return result;
}

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

result = (unsigned int)gameState;
if ( gameState )
result = 1 - ((unsigned int)(is2PlayerGame == 0) - 1);
return result;
}

original_code:
int getPlayerCount()
{
 if (gameState == 0)
 {
  return 0;
 }
 if (is2PlayerGame)
 {
  return 2;
 }
 else
 {
  return 1;
 }
}


getScore

decompiled_code:
__int64 getScore()
{
return (unsigned int)gameScore;
}

canonical_decompiled_code:
__int64 func15()
{
return (unsigned int)gameScore;
}

original_code:
int getScore()
{
 return gameScore;
}

canonical_original_code:
int getScore()
{
 return gameScore;
}


addScore

decompiled_code:
void __fastcall addScore(int a1)
{
gameScore += a1;
}

canonical_decompiled_code:
void __fastcall func16(int a1)
{
gameScore += a1;
}

original_code:
void addScore(int delta)
{
 gameScore += delta;
}


GetNextFactPatternNode

repo: jarcec/rbclips

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

*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 8LL) = 0;
if ( a2 || (result = *(_QWORD *)(a3 + 56)) == 0 )
{
do
{
result = *(_QWORD *)(a3 + 80);
if ( result )
break;
a3 = *(_QWORD *)(a3 + 64);
if ( !a3 )
break;
}
while ( (*(_BYTE *)(a3 + 24) & 2) == 0 );
}
return result;
}

original_code:
static struct factPatternNode *GetNextFactPatternNode(
  void *theEnv,
  int finishedMatching,
  struct factPatternNode *thePattern)
  {
   ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->EvaluationError = 0;
   if (finishedMatching == 0)
     { if (thePattern->nextLevel != ((void *)0)) return(thePattern->nextLevel); }
   while (thePattern->rightNode == ((void *)0))
     {
      thePattern = thePattern->lastLevel;
      if (thePattern == ((void *)0)) return(((void *)0));
      if (thePattern->header.multifieldNode) return(((void *)0));
     }
   return(thePattern->rightNode);
  }

canonical_original_code:
static struct factPatternNode *GetNextFactPatternNode(void *theEnv, int finishedMatching, struct factPatternNode *thePattern)
  {
   ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->EvaluationError = 0;
   if (finishedMatching == 0)
     { if (thePattern->nextLevel != ((void *)0)) return(thePattern->nextLevel); }
   while (thePattern->rightNode == ((void *)0))
     {
      thePattern = thePattern->lastLevel;
      if (thePattern == ((void *)0)) return(((void *)0));
      if (thePattern->header.multifieldNode) return(((void *)0));
     }
   return(thePattern->rightNode);
  }

variable_types:
theEnv
void *

variable_types: finishedMatching int

variable_types:
thePattern
struct factPatternNode *

return_type: struct factPatternNode { struct patternNodeHeader { struct partialMatch { unsigned int betaMemory; unsigned int busy; unsigned int activationf; unsigned int dependentsf; unsigned int notOriginf; unsigned int counterf; unsigned int bcount; struct partialMatch *next; struct genericMatch { union { void *theValue; struct alphaMatch { struct patternEntity { struct patternEntityRecord { struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject { void *supplementalInfo; unsigned short type; void *value; long begin; long end; struct dataObject *next; } *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData { unsigned char dataID; struct userData *next; } *usrData; } base; void (*decrementBasisCount)(void *, void *); void (*incrementBasisCount)(void *, void *); void (*matchFunction)(void *, void *); int (*synchronized)(void *, void *); } *theInfo; void *dependents; unsigned int busyCount; long timeTag; } *matchingItem; struct multifieldMarker { int whichField; union { void *whichSlot; short whichSlotNumber; } where; long startPosition; long endPosition; struct multifieldMarker *next; } *markers; struct alphaMatch *next; } *theMatch; } gm; } binds[1]; } *alphaMemory; struct partialMatch *endOfQueue; struct joinNode { unsigned int firstJoin; unsigned int logicalJoin; unsigned int joinFromTheRight; unsigned int patternIsNegated; unsigned int initialize; unsigned int marked; unsigned int rhsType; unsigned int depth; long bsaveID; struct partialMatch *beta; struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *networkTest; void *rightSideEntryStructure; struct joinNode *nextLevel; struct joinNode *lastLevel; struct joinNode *rightDriveNode; struct joinNode *rightMatchNode; struct defrule { struct constructHeader { struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *name; char *ppForm; struct defmoduleItemHeader { struct defmodule { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader **itemsArray; struct portItem { struct symbolHashNode *moduleName; struct symbolHashNode *constructType; struct symbolHashNode *constructName; struct portItem *next; } *importList; struct portItem *exportList; unsigned int visitedFlag; long bsaveID; struct userData *usrData; struct defmodule *next; } *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; } *whichModule; long bsaveID; struct constructHeader *next; struct userData *usrData; } header; int salience; int localVarCnt; unsigned int complexity; unsigned int afterBreakpoint; unsigned int watchActivation; unsigned int watchFiring; unsigned int autoFocus; unsigned int executing; struct expr *dynamicSalience; struct expr *actions; struct joinNode *logicalJoin; struct joinNode *lastJoin; struct defrule *disjunct; } *ruleToActivate; } *entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; } header; long bsaveID; unsigned short whichField; unsigned short whichSlot; unsigned short leaveFields; struct expr *networkTest; struct factPatternNode *nextLevel; struct factPatternNode *lastLevel; struct factPatternNode *leftNode; struct factPatternNode *rightNode; } *

user_defined_types: struct evaluationData { struct expr *CurrentExpression; int EvaluationError; int HaltExecution; int CurrentEvaluationDepth; struct entityRecord *PrimitivesArray[150]; }

user_defined_types: struct environmentData { unsigned int initialized; unsigned long environmentIndex; void *context; void *routerContext; void **theData; void (**cleanupFunctions)(void *); struct environmentCleanupFunction *listOfCleanupEnvironmentFunctions; struct environmentData *next; }

user_defined_types: struct factPatternNode { struct patternNodeHeader header; long bsaveID; unsigned short whichField; unsigned short whichSlot; unsigned short leaveFields; struct expr *networkTest; struct factPatternNode *nextLevel; struct factPatternNode *lastLevel; struct factPatternNode *leftNode; struct factPatternNode *rightNode; }

user_defined_types: struct patternNodeHeader { struct partialMatch *alphaMemory; struct partialMatch *endOfQueue; struct joinNode *entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; }

user_defined_types: struct environmentCleanupFunction { char *name; void (*func)(void *); int priority; struct environmentCleanupFunction *next; }

user_defined_types: struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData *usrData; }

user_defined_types: struct partialMatch { unsigned int betaMemory; unsigned int busy; unsigned int activationf; unsigned int dependentsf; unsigned int notOriginf; unsigned int counterf; unsigned int bcount; struct partialMatch *next; struct genericMatch binds[1]; }

user_defined_types: struct joinNode { unsigned int firstJoin; unsigned int logicalJoin; unsigned int joinFromTheRight; unsigned int patternIsNegated; unsigned int initialize; unsigned int marked; unsigned int rhsType; unsigned int depth; long bsaveID; struct partialMatch *beta; struct expr *networkTest; void *rightSideEntryStructure; struct joinNode *nextLevel; struct joinNode *lastLevel; struct joinNode *rightDriveNode; struct joinNode *rightMatchNode; struct defrule *ruleToActivate; }

user_defined_types: struct genericMatch { union { void *theValue; struct alphaMatch *theMatch; } gm; }

user_defined_types: struct defrule { struct constructHeader header; int salience; int localVarCnt; unsigned int complexity; unsigned int afterBreakpoint; unsigned int watchActivation; unsigned int watchFiring; unsigned int autoFocus; unsigned int executing; struct expr *dynamicSalience; struct expr *actions; struct joinNode *logicalJoin; struct joinNode *lastJoin; struct defrule *disjunct; }

user_defined_types: struct constructHeader { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader *whichModule; long bsaveID; struct constructHeader *next; struct userData *usrData; }

user_defined_types: struct alphaMatch { struct patternEntity *matchingItem; struct multifieldMarker *markers; struct alphaMatch *next; }

user_defined_types: struct defmoduleItemHeader { struct defmodule *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; }

user_defined_types: struct patternEntity { struct patternEntityRecord *theInfo; void *dependents; unsigned int busyCount; long timeTag; }

user_defined_types: struct defmodule { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader **itemsArray; struct portItem *importList; struct portItem *exportList; unsigned int visitedFlag; long bsaveID; struct userData *usrData; struct defmodule *next; }

user_defined_types: struct patternEntityRecord { struct entityRecord base; void (*decrementBasisCount)(void *, void *); void (*incrementBasisCount)(void *, void *); void (*matchFunction)(void *, void *); int (*synchronized)(void *, void *); }