decompiled_code:
__int64 draw_blocks()
{
__int64 v0; // rbp
__int64 result; // rax
__int64 v2; // rbx
int v3; // edx

v0 = (unsigned int)((_DWORD)&blocks + 160);
do
{
v2 = v0 - 160;
do
{
if ( *(_DWORD *)(v2 + 8) == 1 )
{
v3 = *(_DWORD *)(v2 + 12);
if ( v3 )
{
if ( v3 == 1 )
result = boxRGBA(
screen,
(unsigned int)(__int16)(*(_WORD *)v2 + 2),
(unsigned int)(__int16)(*(_DWORD *)(v2 + 4) + 2),
(unsigned int)(__int16)(*(_DWORD *)v2 + 62),
(unsigned int)(__int16)(*(_DWORD *)(v2 + 4) + 30),
109LL,
90LL,
128LL,
255LL);
}
else
{
result = boxRGBA(
screen,
(unsigned int)(__int16)(*(_DWORD *)v2 + 2),
(unsigned int)(__int16)(*(_DWORD *)(v2 + 4) + 2),
(unsigned int)(__int16)(*(_DWORD *)v2 + 62),
(unsigned int)(__int16)(*(_DWORD *)(v2 + 4) + 30),
90LL,
128LL,
114LL,
255LL);
}
}
v2 += 16LL;
}
while ( v2 != v0 );
v0 += 160LL;
}
while ( v0 != (_DWORD)&blocks + 1120 );
return result;
}

original_code:
void draw_blocks() {
    int i,j;
    const int gap = 2;
    for(i=0;i<6;i++) {
        for(j=0;j<10;j++) {
            if(blocks[i][j].alive == true) {
                if(blocks[i][j].color == 0) {
                    boxRGBA(screen,
                            blocks[i][j].x+gap,
                            blocks[i][j].y+gap,
                            blocks[i][j].x+64 -gap,
                            blocks[i][j].y+32 -gap,
                            90,128,114,255
                            );
                }
                else if(blocks[i][j].color == 1) {
                    boxRGBA(screen,
                            blocks[i][j].x+gap,
                            blocks[i][j].y+gap,
                            blocks[i][j].x+64 -gap,
                            blocks[i][j].y+32 -gap,
                            109,90,128,255
                            );
                }
            }
        }
    }
}

canonical_original_code:
void draw_blocks() {
    int i; int j;
    int gap = 2;
    for(i=0;i<6;i++) {
        for(j=0;j<10;j++) {
            if(blocks[i][j].alive == true) {
                if(blocks[i][j].color == 0) {
                    boxRGBA(screen,
                            blocks[i][j].x+gap,
                            blocks[i][j].y+gap,
                            blocks[i][j].x+64 -gap,
                            blocks[i][j].y+32 -gap,
                            90,128,114,255
                            );
                }
                else if(blocks[i][j].color == 1) {
                    boxRGBA(screen,
                            blocks[i][j].x+gap,
                            blocks[i][j].y+gap,
                            blocks[i][j].x+64 -gap,
                            blocks[i][j].y+32 -gap,
                            109,90,128,255
                            );
                }
            }
        }
    }
}

variable_types: gap int


repo: dorkster/block-breaker

decompiled_code:
__int64 draw_ball()
{
return filledEllipseRGBA(
screen,
(unsigned int)ball,
(unsigned int)*((__int16 *)&ball + 2),
4LL,
4LL,
43LL,
43LL,
43LL,
255LL);
}

canonical_decompiled_code:
__int64 func2()
{
return filledEllipseRGBA(
screen,
(unsigned int)ball,
(unsigned int)*((__int16 *)&ball + 2),
4LL,
4LL,
43LL,
43LL,
43LL,
255LL);
}

original_code:
void draw_ball() {
    filledEllipseRGBA(screen,
                      ball.x,
                      ball.y,
                      4,
                      4,
                      43,43,43,255
                      );
}

return_type: void


decompiled_code:
__int64 draw_info()
{
__int64 result; // rax
char v1[264]; // [rsp+0h] [rbp-108h] BYREF

sprintf(v1, "Score: %-7d Lives: %-2d", player[5], player[6]);
result = TTF_RenderText_Solid(font, v1, 2829099LL);
text_info = result;
if ( result )
{
sys_surfaceapply(8LL, 460LL, 255LL, result, screen, 0LL);
result = SDL_FreeSurface(text_info);
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax
char v1[264]; // [rsp+0h] [rbp-108h] BYREF

sprintf(v1, "Score: %-7d Lives: %-2d", player[5], player[6]);
result = TTF_RenderText_Solid(font, v1, 2829099LL);
text_info = result;
if ( result )
{
sys_surfaceapply(8LL, 460LL, 255LL, result, screen, 0LL);
result = SDL_FreeSurface(text_info);
}
return result;
}

original_code:
void draw_info() {
    char info[256];
    SDL_Color color = {43,43,43};
    sprintf(info,"Score: %-7d    Lives: %-2d",player.score,player.lives);
    text_info = TTF_RenderText_Solid(font,info,color);
    if(text_info == ((void *)0)) return;
    sys_surfaceapply(8,460,255,text_info,screen,((void *)0));
    SDL_FreeSurface(text_info);
}

canonical_original_code:
void draw_info() {
    char info[256];
    struct SDL_Color color = {43,43,43};
    sprintf(info,"Score: %-7d    Lives: %-2d",player.score,player.lives);
    text_info = TTF_RenderText_Solid(font,info,color);
    if(text_info == ((void *)0)) return;
    sys_surfaceapply(8,460,255,text_info,screen,((void *)0));
    SDL_FreeSurface(text_info);
}

variable_types:
info
char [256]

variable_types: struct SDL_Color { unsigned char r; unsigned char g; unsigned char b; unsigned char unused; }


original_code:
void draw_power() {
    if (power.alive == false) return;
    short x[4] = { power.x, power.x+8, power.x, power.x-8 };
    short y[4] = { power.y-8, power.y, power.y+8, power.y };
    filledPolygonRGBA(screen,
                      x, y,
                      4,
                      43, 43, 43, 255);
}

variable_types:
x
short [4]

variable_types:
y
short [4]


decompiled_code:
__int64 draw_everything()
{
SDL_FillRect(screen, 0LL, 14277081LL);
draw_player();
draw_blocks();
draw_ball();
draw_info();
return draw_power();
}

canonical_decompiled_code:
__int64 func5()
{
SDL_FillRect(screen, 0LL, 14277081LL);
func0();
func1();
func2();
func3();
return func4();
}

original_code:
void draw_everything() {
    SDL_FillRect(screen,((void *)0), 0xd9d9d9);
    draw_player();
    draw_blocks();
    draw_ball();
    draw_info();
    draw_power();
}


decompiled_code:
__int64 sys_cleanup()
{
TTF_CloseFont(font);
return SDL_Quit();
}

canonical_decompiled_code:
__int64 func2()
{
TTF_CloseFont(font);
return SDL_Quit();
}

original_code:
void sys_cleanup() {
    TTF_CloseFont(font);
    SDL_Quit();
}


decompiled_code:
__int64 sys_input()
{
int v0; // eax
__int64 result; // rax
char v2; // al
int v3; // eax

SDL_GetMouseState(&mouse_x, &mouse_y);
while ( 1 )
{
result = SDL_PollEvent(&event);
if ( !(_DWORD)result )
return result;
if ( event != 2 )
goto LABEL_14;
v0 = *((_DWORD *)&event + 2);
if ( v0 == 276 || v0 == 122 )
action_moveleft = 1;
if ( v0 == 275 || v0 == 120 )
action_moveright = 1;
if ( v0 == 32 )
{
v2 = event;
if ( !use_mouse )
{
game_balllaunch();
if ( *((_DWORD *)&event + 2) != 27 )
goto LABEL_14;
goto LABEL_21;
}
LABEL_15:
if ( v2 != 5 )
goto LABEL_10;
if ( *(&event + 2) == 1 && use_mouse == 1 )
{
game_balllaunch();
goto LABEL_10;
}
}
else if ( v0 == 27 )
{
LABEL_21:
quit = 1;
LABEL_14:
v2 = event;
if ( event != 3 )
goto LABEL_15;
v3 = *((_DWORD *)&event + 2);
if ( v3 == 276 || v3 == 122 )
action_moveleft = 0;
if ( v3 == 275 || v3 == 120 )
action_moveright = 0;
}
else
{
LABEL_10:
if ( event == 12 )
quit = 1;
}
}
}

canonical_decompiled_code:
__int64 func4()
{
int v0; // eax
__int64 result; // rax
char v2; // al
int v3; // eax

SDL_GetMouseState(&mouse_x, &mouse_y);
while ( 1 )
{
result = SDL_PollEvent(&event);
if ( !(_DWORD)result )
return result;
if ( event != 2 )
goto LABEL_14;
v0 = *((_DWORD *)&event + 2);
if ( v0 == 276 || v0 == 122 )
action_moveleft = 1;
if ( v0 == 275 || v0 == 120 )
action_moveright = 1;
if ( v0 == 32 )
{
v2 = event;
if ( !use_mouse )
{
game_balllaunch();
if ( *((_DWORD *)&event + 2) != 27 )
goto LABEL_14;
goto LABEL_21;
}
LABEL_15:
if ( v2 != 5 )
goto LABEL_10;
if ( *(&event + 2) == 1 && use_mouse == 1 )
{
game_balllaunch();
goto LABEL_10;
}
}
else if ( v0 == 27 )
{
LABEL_21:
quit = 1;
LABEL_14:
v2 = event;
if ( event != 3 )
goto LABEL_15;
v3 = *((_DWORD *)&event + 2);
if ( v3 == 276 || v3 == 122 )
action_moveleft = 0;
if ( v3 == 275 || v3 == 120 )
action_moveright = 0;
}
else
{
LABEL_10:
if ( event == 12 )
quit = 1;
}
}
}

original_code:
void sys_input() {
    SDL_GetMouseState(&mouse_x, &mouse_y);
    while(SDL_PollEvent(&event)) {
        if( event.type == SDL_KEYDOWN ) {
            if(event.key.keysym.sym == SDLK_LEFT || event.key.keysym.sym == 'z')
                action_moveleft = true;
            if(event.key.keysym.sym == SDLK_RIGHT || event.key.keysym.sym == 'x')
                action_moveright = true;
            if(event.key.keysym.sym == ' ')
                if (use_mouse == false) game_balllaunch();
            if(event.key.keysym.sym == SDLK_ESCAPE)
                quit = true;
        }
        if( event.type == SDL_KEYUP ) {
            if(event.key.keysym.sym == SDLK_LEFT || event.key.keysym.sym == 'z')
                action_moveleft = false;
            if(event.key.keysym.sym == SDLK_RIGHT || event.key.keysym.sym == 'x')
                action_moveright = false;
        }
        if( event.type == SDL_MOUSEBUTTONDOWN ) {
            if(event.button.button == 1)
                if (use_mouse == true) game_balllaunch();
        }
        if(event.type == SDL_QUIT) {
            quit = true;
        }
    }
}


repo: dorkster/espada

decompiled_code:
void set_clips()
{
clipPlayerNorm = 0;
*(&clipPlayerNorm + 1) = 0;
*(&clipPlayerNorm + 2) = 64;
*(&clipPlayerNorm + 3) = 64;
*(&clipPlayerNorm + 4) = 64;
*(&clipPlayerNorm + 5) = 0;
*(&clipPlayerNorm + 6) = 64;
*(&clipPlayerNorm + 7) = 64;
clipPlayerInvuln = 0;
*(&clipPlayerInvuln + 1) = 64;
*(&clipPlayerInvuln + 2) = 64;
*(&clipPlayerInvuln + 3) = 64;
*(&clipPlayerInvuln + 4) = 64;
*(&clipPlayerInvuln + 5) = 64;
*(&clipPlayerInvuln + 6) = 64;
*(&clipPlayerInvuln + 7) = 64;
clipEnemyType1 = 0;
*(&clipEnemyType1 + 1) = 0;
*(&clipEnemyType1 + 2) = 64;
*(&clipEnemyType1 + 3) = 32;
*(&clipEnemyType1 + 4) = 64;
*(&clipEnemyType1 + 5) = 0;
*(&clipEnemyType1 + 6) = 64;
*(&clipEnemyType1 + 7) = 32;
clipEnemyType2 = 0;
*(&clipEnemyType2 + 1) = 0;
*(&clipEnemyType2 + 2) = 64;
*(&clipEnemyType2 + 3) = 64;
*(&clipEnemyType2 + 4) = 64;
*(&clipEnemyType2 + 5) = 0;
*(&clipEnemyType2 + 6) = 64;
*(&clipEnemyType2 + 7) = 64;
clipExplosion[0] = 0;
clipExplosion[1] = 0;
clipExplosion[2] = 64;
clipExplosion[3] = 64;
clipExplosion[4] = 64;
clipExplosion[5] = 0;
clipExplosion[6] = 64;
clipExplosion[7] = 64;
clipExplosion[8] = 128;
clipExplosion[9] = 0;
clipExplosion[10] = 64;
clipExplosion[11] = 64;
clipExplosion[12] = 192;
clipExplosion[13] = 0;
clipExplosion[14] = 64;
clipExplosion[15] = 64;
clipExplosion[16] = 64;
clipExplosion[17] = 0;
clipExplosion[18] = 64;
clipExplosion[19] = 64;
clipExplosion[20] = 128;
clipExplosion[21] = 0;
clipExplosion[22] = 64;
clipExplosion[23] = 64;
clipExplosion[24] = 192;
clipExplosion[25] = 0;
clipExplosion[26] = 64;
clipExplosion[27] = 64;
clipExplosion[28] = 192;
clipExplosion[29] = 0;
clipExplosion[30] = 64;
clipExplosion[31] = 64;
}

canonical_decompiled_code:
void func0()
{
clipPlayerNorm = 0;
*(&clipPlayerNorm + 1) = 0;
*(&clipPlayerNorm + 2) = 64;
*(&clipPlayerNorm + 3) = 64;
*(&clipPlayerNorm + 4) = 64;
*(&clipPlayerNorm + 5) = 0;
*(&clipPlayerNorm + 6) = 64;
*(&clipPlayerNorm + 7) = 64;
clipPlayerInvuln = 0;
*(&clipPlayerInvuln + 1) = 64;
*(&clipPlayerInvuln + 2) = 64;
*(&clipPlayerInvuln + 3) = 64;
*(&clipPlayerInvuln + 4) = 64;
*(&clipPlayerInvuln + 5) = 64;
*(&clipPlayerInvuln + 6) = 64;
*(&clipPlayerInvuln + 7) = 64;
clipEnemyType1 = 0;
*(&clipEnemyType1 + 1) = 0;
*(&clipEnemyType1 + 2) = 64;
*(&clipEnemyType1 + 3) = 32;
*(&clipEnemyType1 + 4) = 64;
*(&clipEnemyType1 + 5) = 0;
*(&clipEnemyType1 + 6) = 64;
*(&clipEnemyType1 + 7) = 32;
clipEnemyType2 = 0;
*(&clipEnemyType2 + 1) = 0;
*(&clipEnemyType2 + 2) = 64;
*(&clipEnemyType2 + 3) = 64;
*(&clipEnemyType2 + 4) = 64;
*(&clipEnemyType2 + 5) = 0;
*(&clipEnemyType2 + 6) = 64;
*(&clipEnemyType2 + 7) = 64;
clipExplosion[0] = 0;
clipExplosion[1] = 0;
clipExplosion[2] = 64;
clipExplosion[3] = 64;
clipExplosion[4] = 64;
clipExplosion[5] = 0;
clipExplosion[6] = 64;
clipExplosion[7] = 64;
clipExplosion[8] = 128;
clipExplosion[9] = 0;
clipExplosion[10] = 64;
clipExplosion[11] = 64;
clipExplosion[12] = 192;
clipExplosion[13] = 0;
clipExplosion[14] = 64;
clipExplosion[15] = 64;
clipExplosion[16] = 64;
clipExplosion[17] = 0;
clipExplosion[18] = 64;
clipExplosion[19] = 64;
clipExplosion[20] = 128;
clipExplosion[21] = 0;
clipExplosion[22] = 64;
clipExplosion[23] = 64;
clipExplosion[24] = 192;
clipExplosion[25] = 0;
clipExplosion[26] = 64;
clipExplosion[27] = 64;
clipExplosion[28] = 192;
clipExplosion[29] = 0;
clipExplosion[30] = 64;
clipExplosion[31] = 64;
}

original_code:
void set_clips()
{
    clipPlayerNorm[0].x = 0;
    clipPlayerNorm[0].y = 0;
    clipPlayerNorm[0].w = 64;
    clipPlayerNorm[0].h = 64;
    clipPlayerNorm[1].x = 64;
    clipPlayerNorm[1].y = 0;
    clipPlayerNorm[1].w = 64;
    clipPlayerNorm[1].h = 64;
    clipPlayerInvuln[0].x = 0;
    clipPlayerInvuln[0].y = 64;
    clipPlayerInvuln[0].w = 64;
    clipPlayerInvuln[0].h = 64;
    clipPlayerInvuln[1].x = 64;
    clipPlayerInvuln[1].y = 64;
    clipPlayerInvuln[1].w = 64;
    clipPlayerInvuln[1].h = 64;
    clipEnemyType1[0].x = 0;
    clipEnemyType1[0].y = 0;
    clipEnemyType1[0].w = 64;
    clipEnemyType1[0].h = 32;
    clipEnemyType1[1].x = 64;
    clipEnemyType1[1].y = 0;
    clipEnemyType1[1].w = 64;
    clipEnemyType1[1].h = 32;
    clipEnemyType2[0].x = 0;
    clipEnemyType2[0].y = 0;
    clipEnemyType2[0].w = 64;
    clipEnemyType2[0].h = 64;
    clipEnemyType2[1].x = 64;
    clipEnemyType2[1].y = 0;
    clipEnemyType2[1].w = 64;
    clipEnemyType2[1].h = 64;
    clipExplosion[0].x = 0;
    clipExplosion[0].y = 0;
    clipExplosion[0].w = 64;
    clipExplosion[0].h = 64;
    clipExplosion[1].x = 64;
    clipExplosion[1].y = 0;
    clipExplosion[1].w = 64;
    clipExplosion[1].h = 64;
    clipExplosion[2].x = 128;
    clipExplosion[2].y = 0;
    clipExplosion[2].w = 64;
    clipExplosion[2].h = 64;
    clipExplosion[3].x = 192;
    clipExplosion[3].y = 0;
    clipExplosion[3].w = 64;
    clipExplosion[3].h = 64;
    clipExplosion[4].x = 64;
    clipExplosion[4].y = 0;
    clipExplosion[4].w = 64;
    clipExplosion[4].h = 64;
    clipExplosion[5].x = 128;
    clipExplosion[5].y = 0;
    clipExplosion[5].w = 64;
    clipExplosion[5].h = 64;
    clipExplosion[6].x = 192;
    clipExplosion[6].y = 0;
    clipExplosion[6].w = 64;
    clipExplosion[6].h = 64;
    clipExplosion[7].x = 192;
    clipExplosion[7].y = 0;
    clipExplosion[7].w = 64;
    clipExplosion[7].h = 64;
}


repo: dorktype/LICE

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

result = 0LL;
if ( (unsigned int)(a1 - 48) <= 7 )
{
*a2 = (8 * *a2) | (a1 - 48);
result = 1LL;
}
return result;
}

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

result = 0LL;
if ( (unsigned int)(a1 - 48) <= 7 )
{
*a2 = (8 * *a2) | (a1 - 48);
result = 1LL;
}
return result;
}

original_code:
static _Bool lexer_read_character_octal_brace(int c, int *r) {
    if ('0' <= c && c <= '7') {
        *r = (*r << 3) | (c - '0');
        return 1;
    }
    return 0;
}

variable_types: c int

variable_types:
r
int *


decompiled_code:
int lexer_skip_comment_line()
{
int result; // eax

do
result = getc(stdin);
while ( result != 10 && result != -1 );
return result;
}

canonical_decompiled_code:
int func1()
{
int result; // eax

do
result = getc(stdin);
while ( result != 10 && result != -1 );
return result;
}

original_code:
static void lexer_skip_comment_line(void) {
    for (;;) {
        int c = getc(stdin);
        if (c == '\n' || c == (-1))
            return;
    }
}

canonical_original_code:
static void lexer_skip_comment_line() {
    for (;;) {
        int c = getc(stdin);
        if (c == '\n' || c == (-1))
            return;
    }
}


decompiled_code:
int lexer_skip_comment_block()
{
int i; // ebx
int result; // eax

for ( i = 0; ; i = 0 )
{
while ( 1 )
{
result = getc(stdin);
if ( result != 42 )
break;
i = 1;
}
if ( i && result == 47 )
break;
}
return result;
}

canonical_decompiled_code:
int func2()
{
int i; // ebx
int result; // eax

for ( i = 0; ; i = 0 )
{
while ( 1 )
{
result = getc(stdin);
if ( result != 42 )
break;
i = 1;
}
if ( i && result == 47 )
break;
}
return result;
}

original_code:
static void lexer_skip_comment_block(void) {
    enum {
        comment_outside,
        comment_astrick
    } state = comment_outside;
    for (;;) {
        int c = getc(stdin);
        if (c == '*')
            state = comment_astrick;
        else if (state == comment_astrick && c == '/')
            return;
        else
            state = comment_outside;
    }
}

canonical_original_code:
static void lexer_skip_comment_block() {
    enum { comment_outside=0, comment_astrick=1 } state = comment_outside;
    for (;;) {
        int c = getc(stdin);
        if (c == '*')
            state = comment_astrick;
        else if (state == comment_astrick && c == '/')
            return;
        else
            state = comment_outside;
    }
}


decompiled_code:
__int64 __fastcall lexer_read_character_octal(int a1)
{
int v1; // ebx
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a1 - 48;
v1 = getc(stdin);
if ( !(unsigned __int8)lexer_read_character_octal_brace(v1, v3)
|| (v1 = getc(stdin), !(unsigned __int8)lexer_read_character_octal_brace(v1, v3)) )
{
ungetc(v1, stdin);
}
return (unsigned int)v3[0];
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1)
{
int v1; // ebx
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a1 - 48;
v1 = getc(stdin);
if ( !(unsigned __int8)func0(v1, v3)
|| (v1 = getc(stdin), !(unsigned __int8)func0(v1, v3)) )
{
ungetc(v1, stdin);
}
return (unsigned int)v3[0];
}

original_code:
static int lexer_read_character_octal(int c) {
    int r = c - '0';
    if (lexer_read_character_octal_brace((c = getc(stdin)), &r)) {
        if (!lexer_read_character_octal_brace((c = getc(stdin)), &r))
            ungetc(c, stdin);
    } else
        ungetc(c, stdin);
    return r;
}

variable_types: r int

return_type: int


decompiled_code:
__m128i *lexer_read_character()
{
int v0; // eax
unsigned __int8 v1; // bl

v0 = getc(stdin);
v1 = v0;
if ( v0 == 92 )
v1 = lexer_read_character_escaped();
if ( getc(stdin) != 39 )
compile_error("unterminated character");
return lexer_char(v1);
}

canonical_decompiled_code:
__m128i *func8()
{
int v0; // eax
unsigned __int8 v1; // bl

v0 = getc(stdin);
v1 = v0;
if ( v0 == 92 )
v1 = func6();
if ( getc(stdin) != 39 )
compile_error("unterminated character");
return lexer_char(v1);
}

original_code:
static lexer_token_t *lexer_read_character(void) {
    int c = getc(stdin);
    int r = (c == '\\') ? lexer_read_character_escaped() : c;
    if (getc(stdin) != '\'')
        compile_error("unterminated character");
    return lexer_char((char)r);
}

canonical_original_code:
static struct lexer_token_t *lexer_read_character() {
    int c = getc(stdin);
    int r = (c == '\\') ? lexer_read_character_escaped() : c;
    if (getc(stdin) != '\'')
        compile_error("unterminated character");
    return lexer_char((char)r);
}

return_type: struct lexer_token_t { enum lexer_token_type_t { LEXER_TOKEN_IDENTIFIER=0, LEXER_TOKEN_PUNCT=1, LEXER_TOKEN_CHAR=2, LEXER_TOKEN_STRING=3, LEXER_TOKEN_NUMBER=4, LEXER_TOKEN_EQUAL=512, LEXER_TOKEN_LEQUAL=513, LEXER_TOKEN_GEQUAL=514, LEXER_TOKEN_NEQUAL=515, LEXER_TOKEN_INCREMENT=516, LEXER_TOKEN_DECREMENT=517, LEXER_TOKEN_ARROW=518, LEXER_TOKEN_LSHIFT=519, LEXER_TOKEN_RSHIFT=520, LEXER_TOKEN_COMPOUND_ADD=521, LEXER_TOKEN_COMPOUND_SUB=522, LEXER_TOKEN_COMPOUND_MUL=523, LEXER_TOKEN_COMPOUND_DIV=524, LEXER_TOKEN_COMPOUND_MOD=525, LEXER_TOKEN_COMPOUND_AND=526, LEXER_TOKEN_COMPOUND_OR=527, LEXER_TOKEN_COMPOUND_XOR=528, LEXER_TOKEN_COMPOUND_LSHIFT=529, LEXER_TOKEN_COMPOUND_RSHIFT=530, LEXER_TOKEN_AND=531, LEXER_TOKEN_OR=532 } type; union { long integer; int punct; char *string; char character; }; } *

user_defined_types: struct lexer_token_t { enum lexer_token_type_t type; union { long integer; int punct; char *string; char character; }; }


decompiled_code:
_BOOL8 __fastcall lexer_ispunct(_DWORD *a1, int a2)
{
bool v2; // al

v2 = 0;
if ( a1 && *a1 == 1 )
v2 = a1[2] == a2;
return v2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func10(_DWORD *a1, int a2)
{
bool v2; // al

v2 = 0;
if ( a1 && *a1 == 1 )
v2 = a1[2] == a2;
return v2;
}

original_code:
_Bool lexer_ispunct(lexer_token_t *token, int c) {
    return token && (token->type == LEXER_TOKEN_PUNCT) && (token->punct == c);
}

canonical_original_code:
_Bool lexer_ispunct(struct lexer_token_t *token, int c) {
    return token && (token->type == LEXER_TOKEN_PUNCT) && (token->punct == c);
}

variable_types: struct lexer_token_t { enum lexer_token_type_t { LEXER_TOKEN_IDENTIFIER=0, LEXER_TOKEN_PUNCT=1, LEXER_TOKEN_CHAR=2, LEXER_TOKEN_STRING=3, LEXER_TOKEN_NUMBER=4, LEXER_TOKEN_EQUAL=512, LEXER_TOKEN_LEQUAL=513, LEXER_TOKEN_GEQUAL=514, LEXER_TOKEN_NEQUAL=515, LEXER_TOKEN_INCREMENT=516, LEXER_TOKEN_DECREMENT=517, LEXER_TOKEN_ARROW=518, LEXER_TOKEN_LSHIFT=519, LEXER_TOKEN_RSHIFT=520, LEXER_TOKEN_COMPOUND_ADD=521, LEXER_TOKEN_COMPOUND_SUB=522, LEXER_TOKEN_COMPOUND_MUL=523, LEXER_TOKEN_COMPOUND_DIV=524, LEXER_TOKEN_COMPOUND_MOD=525, LEXER_TOKEN_COMPOUND_AND=526, LEXER_TOKEN_COMPOUND_OR=527, LEXER_TOKEN_COMPOUND_XOR=528, LEXER_TOKEN_COMPOUND_LSHIFT=529, LEXER_TOKEN_COMPOUND_RSHIFT=530, LEXER_TOKEN_AND=531, LEXER_TOKEN_OR=532 } type; union { long integer; int punct; char *string; char character; }; } *


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

if ( a1 )
result = list_push(&_compound_literal_0, a1);
return result;
}

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

if ( a1 )
result = list_push(&_compound_literal_0, a1);
return result;
}

original_code:
void lexer_unget(lexer_token_t *token) {
    if (!token)
        return;
    list_push(lexer_buffer, token);
}

canonical_original_code:
void lexer_unget(struct lexer_token_t *token) {
    if (!token)
        return;
    list_push(lexer_buffer, token);
}

user_defined_types: enum lexer_token_type_t { LEXER_TOKEN_IDENTIFIER=0, LEXER_TOKEN_PUNCT=1, LEXER_TOKEN_CHAR=2, LEXER_TOKEN_STRING=3, LEXER_TOKEN_NUMBER=4, LEXER_TOKEN_EQUAL=512, LEXER_TOKEN_LEQUAL=513, LEXER_TOKEN_GEQUAL=514, LEXER_TOKEN_NEQUAL=515, LEXER_TOKEN_INCREMENT=516, LEXER_TOKEN_DECREMENT=517, LEXER_TOKEN_ARROW=518, LEXER_TOKEN_LSHIFT=519, LEXER_TOKEN_RSHIFT=520, LEXER_TOKEN_COMPOUND_ADD=521, LEXER_TOKEN_COMPOUND_SUB=522, LEXER_TOKEN_COMPOUND_MUL=523, LEXER_TOKEN_COMPOUND_DIV=524, LEXER_TOKEN_COMPOUND_MOD=525, LEXER_TOKEN_COMPOUND_AND=526, LEXER_TOKEN_COMPOUND_OR=527, LEXER_TOKEN_COMPOUND_XOR=528, LEXER_TOKEN_COMPOUND_LSHIFT=529, LEXER_TOKEN_COMPOUND_RSHIFT=530, LEXER_TOKEN_AND=531, LEXER_TOKEN_OR=532 }


decompiled_code:
__m128i *lexer_next()
{
__m128i *result; // rax

if ( (int)list_length(&_compound_literal_0) > 0 )
result = (__m128i *)list_pop(&_compound_literal_0);
else
result = lexer_read_token();
return result;
}

canonical_decompiled_code:
__m128i *func12()
{
__m128i *result; // rax

if ( (int)list_length(&_compound_literal_0) > 0 )
result = (__m128i *)list_pop(&_compound_literal_0);
else
result = func9();
return result;
}

original_code:
lexer_token_t *lexer_next(void) {
    if (list_length(lexer_buffer) > 0)
        return list_pop(lexer_buffer);
    return lexer_read_token();
}

canonical_original_code:
struct lexer_token_t *lexer_next() {
    if (list_length(lexer_buffer) > 0)
        return list_pop(lexer_buffer);
    return lexer_read_token();
}


decompiled_code:
__m128i *lexer_peek()
{
__m128i *v0; // rbx

v0 = lexer_next();
lexer_unget((__int64)v0);
return v0;
}

original_code:
lexer_token_t *lexer_peek(void) {
    lexer_token_t *token = lexer_next();
    lexer_unget(token);
    return token;
}

canonical_original_code:
struct lexer_token_t *lexer_peek() {
    struct lexer_token_t *token = lexer_next();
    lexer_unget(token);
    return token;
}


canonical_decompiled_code:
void func0(void)
{
free(memory_pool);
}

original_code:
static void memory_cleanup(void) {
    free(memory_pool);
}

canonical_original_code:
static void memory_cleanup() {
    free(memory_pool);
}


decompiled_code:
char *__fastcall memory_allocate(__int64 a1)
{
char *result; // rax

if ( !memory_pool )
{
memory_pool = malloc(0x800000uLL);
atexit(memory_cleanup);
}
result = (char *)memory_pool + memory_next;
memory_next += a1;
return result;
}

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

if ( !memory_pool )
{
memory_pool = malloc(0x800000uLL);
atexit(memory_cleanup);
}
result = (char *)memory_pool + memory_next;
memory_next += a1;
return result;
}

original_code:
void *memory_allocate(size_t bytes) {
    void *value;
    if (!memory_pool) {
        memory_pool = malloc(0x800000);
        atexit(memory_cleanup);
    }
    value = &memory_pool[memory_next];
    memory_next += bytes;
    return value;
}

canonical_original_code:
void *memory_allocate(unsigned long bytes) {
    void *value;
    if (!memory_pool) {
        memory_pool = malloc(0x800000);
        atexit(memory_cleanup);
    }
    value = &memory_pool[memory_next];
    memory_next += bytes;
    return value;
}

variable_types:
bytes
unsigned long

variable_types:
value
void *

return_type: void *


decompiled_code:
char *__fastcall string_reallocate(__int64 a1)
{
int v1; // ebp
char *v2; // r12
char *result; // rax

v1 = 2 * *(_DWORD *)(a1 + 8);
v2 = memory_allocate(v1);
result = strcpy(v2, *(const char **)a1);
*(_QWORD *)a1 = v2;
*(_DWORD *)(a1 + 8) = v1;
return result;
}

canonical_decompiled_code:
char *__fastcall func2(__int64 a1)
{
int v1; // ebp
char *v2; // r12
char *result; // rax

v1 = 2 * *(_DWORD *)(a1 + 8);
v2 = func1(v1);
result = strcpy(v2, *(const char **)a1);
*(_QWORD *)a1 = v2;
*(_DWORD *)(a1 + 8) = v1;
return result;
}

original_code:
static void string_reallocate(string_t *string) {
    int size = string->allocated * 2;
    char *buffer = memory_allocate(size);
    strcpy(buffer, string->buffer);
    string->buffer = buffer;
    string->allocated = size;
}

canonical_original_code:
static void string_reallocate(struct string_s *string) {
    int size = string->allocated * 2;
    char *buffer = memory_allocate(size);
    strcpy(buffer, string->buffer);
    string->buffer = buffer;
    string->allocated = size;
}

variable_types: struct string_s { char *buffer; int allocated; int length; } *

variable_types: size int

variable_types:
buffer
char *


decompiled_code:
int string_catf(__int64 a1, const char *a2, ...)
{
int v2; // ebp
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-E0h] BYREF

while ( 1 )
{
va_start(arg, a2);
v2 = *(_DWORD *)(a1 + 8) - *(_DWORD *)(a1 + 12);
result = vsnprintf((char *)(*(_QWORD *)a1 + *(int *)(a1 + 12)), v2, a2, arg);
if ( v2 > result )
break;
string_reallocate(a1);
}
*(_DWORD *)(a1 + 12) += result;
return result;
}

canonical_decompiled_code:
int func3(__int64 a1, const char *a2, ...)
{
int v2; // ebp
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-E0h] BYREF

while ( 1 )
{
va_start(arg, a2);
v2 = *(_DWORD *)(a1 + 8) - *(_DWORD *)(a1 + 12);
result = vsnprintf((char *)(*(_QWORD *)a1 + *(int *)(a1 + 12)), v2, a2, arg);
if ( v2 > result )
break;
func2(a1);
}
*(_DWORD *)(a1 + 12) += result;
return result;
}

original_code:
void string_catf(string_t *string, const char *fmt, ...) {
    va_list va;
    for (;;) {
        int left = string->allocated - string->length;
        int write;
        __builtin_va_start(va,fmt);
        write = vsnprintf(string->buffer + string->length, left, fmt, va);
        __builtin_va_end(va);
        if (left <= write) {
            string_reallocate(string);
            continue;
        }
        string->length += write;
        return;
    }
}

canonical_original_code:
void string_catf(struct string_s *string, char *fmt, ...) {
    __builtin_va_list va;
    for (;;) {
        int left = string->allocated - string->length;
        int write;
        __builtin_va_start(va,fmt);
        write = vsnprintf(string->buffer + string->length, left, fmt, va);
        __builtin_va_end(va);
        if (left <= write) {
            string_reallocate(string);
            continue;
        }
        string->length += write;
        return;
    }
}

variable_types:
fmt
char *

variable_types: left int

variable_types: write int

user_defined_types: struct string_s { char *buffer; int allocated; int length; }


decompiled_code:
char *string_create()
{
char *v0; // rbx
char *v1; // rax

v0 = memory_allocate(16LL);
v1 = memory_allocate(8LL);
*(_QWORD *)v0 = v1;
*((_DWORD *)v0 + 2) = 8;
*((_DWORD *)v0 + 3) = 0;
*v1 = 0;
return v0;
}

original_code:
string_t *string_create(void) {
    string_t *string = memory_allocate(sizeof(string_t));
    string->buffer = memory_allocate(8);
    string->allocated = 8;
    string->length = 0;
    string->buffer[0] = '\0';
    return string;
}

canonical_original_code:
struct string_s *string_create() {
    struct string_s *string = memory_allocate(sizeof(string_t));
    string->buffer = memory_allocate(8);
    string->allocated = 8;
    string->length = 0;
    string->buffer[0] = '\0';
    return string;
}

return_type: struct string_s { char *buffer; int allocated; int length; } *


decompiled_code:
__int64 __fastcall string_buffer(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
char *string_buffer(string_t *string) {
    return string->buffer;
}

canonical_original_code:
char *string_buffer(struct string_s *string) {
    return string->buffer;
}

return_type: char *


decompiled_code:
__int64 __fastcall string_quote(char *a1)
{
char *v1; // rbx
char *v2; // rbp
char i; // si

v1 = a1;
v2 = string_create();
for ( i = *a1; *v1; i = *v1 )
{
if ( i == 34 || i == 92 )
{
string_catf((__int64)v2, "\\%c", (unsigned int)i);
}
else if ( i == 10 )
{
string_catf((__int64)v2, "\\n");
}
else
{
string_cat((__int64)v2, i);
}
++v1;
}
return *(_QWORD *)v2;
}

original_code:
char *string_quote(char *p) {
    string_t *string = string_create();
    while (*p) {
        if (*p == '\"' || *p == '\\')
            string_catf(string, "\\%c", *p);
        else if (*p == '\n')
            string_catf(string, "\\n");
        else
            string_cat(string, *p);
        p++;
    }
    return string->buffer;
}

canonical_original_code:
char *string_quote(char *p) {
    struct string_s *string = string_create();
    while (*p) {
        if (*p == '\"' || *p == '\\')
            string_catf(string, "\\%c", *p);
        else if (*p == '\n')
            string_catf(string, "\\n");
        else
            string_cat(string, *p);
        p++;
    }
    return string->buffer;
}

variable_types:
p
char *


decompiled_code:
char *list_create()
{
char *result; // rax

result = memory_allocate(24LL);
*(_DWORD *)result = 0;
*((_QWORD *)result + 1) = 0LL;
*((_QWORD *)result + 2) = 0LL;
return result;
}

canonical_decompiled_code:
char *func8()
{
char *result; // rax

result = func1(24LL);
*(_DWORD *)result = 0;
*((_QWORD *)result + 1) = 0LL;
*((_QWORD *)result + 2) = 0LL;
return result;
}

original_code:
list_t *list_create(void) {
    list_t *list = memory_allocate(sizeof(list_t));
    list->length = 0;
    list->head = ((void *)0);
    list->tail = ((void *)0);
    return list;
}

canonical_original_code:
struct list_s *list_create() {
    struct list_s *list = memory_allocate(sizeof(list_t));
    list->length = 0;
    list->head = ((void *)0);
    list->tail = ((void *)0);
    return list;
}

variable_types: struct list_s { int length; struct list_node_s { void *element; struct list_node_s *next; struct list_node_s *prev; } *head; struct list_node_s *tail; } *

user_defined_types: struct list_s { int length; struct list_node_s *head; struct list_node_s *tail; }


decompiled_code:
char *__fastcall list_node_create(__int64 a1)
{
char *result; // rax

result = memory_allocate(24LL);
*(_QWORD *)result = a1;
*((_QWORD *)result + 1) = 0LL;
*((_QWORD *)result + 2) = 0LL;
return result;
}

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

result = func1(24LL);
*(_QWORD *)result = a1;
*((_QWORD *)result + 1) = 0LL;
*((_QWORD *)result + 2) = 0LL;
return result;
}

original_code:
void *list_node_create(void *element) {
    list_node_t *node = memory_allocate(sizeof(list_node_t));
    node->element = element;
    node->next = ((void *)0);
    node->prev = ((void *)0);
    return node;
}

canonical_original_code:
void *list_node_create(void *element) {
    struct list_node_s *node = memory_allocate(sizeof(list_node_t));
    node->element = element;
    node->next = ((void *)0);
    node->prev = ((void *)0);
    return node;
}

variable_types:
element
void *

variable_types: struct list_node_s { void *element; struct list_node_s *next; struct list_node_s *prev; } *


decompiled_code:
char *__fastcall list_shiftify(__int64 a1, __int64 a2)
{
char *result; // rax
__int64 v3; // rdx

result = list_node_create(a2);
v3 = *(_QWORD *)(a1 + 8);
*((_QWORD *)result + 1) = v3;
if ( v3 )
*(_QWORD *)(v3 + 16) = result;
*(_QWORD *)(a1 + 8) = result;
if ( !*(_QWORD *)(a1 + 16) )
*(_QWORD *)(a1 + 16) = result;
++*(_DWORD *)a1;
return result;
}

canonical_decompiled_code:
char *__fastcall func10(__int64 a1, __int64 a2)
{
char *result; // rax
__int64 v3; // rdx

result = func9(a2);
v3 = *(_QWORD *)(a1 + 8);
*((_QWORD *)result + 1) = v3;
if ( v3 )
*(_QWORD *)(v3 + 16) = result;
*(_QWORD *)(a1 + 8) = result;
if ( !*(_QWORD *)(a1 + 16) )
*(_QWORD *)(a1 + 16) = result;
++*(_DWORD *)a1;
return result;
}

original_code:
static void list_shiftify(list_t *list, void *element) {
    list_node_t *node = list_node_create(element);
    node->next = list->head;
    if (list->head)
        list->head->prev = node;
    list->head = node;
    if (!list->tail)
        list->tail = node;
    list->length++;
}

canonical_original_code:
static void list_shiftify(struct list_s *list, void *element) {
    struct list_node_s *node = list_node_create(element);
    node->next = list->head;
    if (list->head)
        list->head->prev = node;
    list->head = node;
    if (!list->tail)
        list->tail = node;
    list->length++;
}

user_defined_types: struct list_node_s { void *element; struct list_node_s *next; struct list_node_s *prev; }


decompiled_code:
char *__fastcall list_push(__int64 a1, __int64 a2)
{
char *result; // rax

result = list_node_create(a2);
if ( *(_QWORD *)(a1 + 8) )
{
*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL) = result;
*((_QWORD *)result + 2) = *(_QWORD *)(a1 + 16);
}
else
{
*(_QWORD *)(a1 + 8) = result;
}
*(_QWORD *)(a1 + 16) = result;
++*(_DWORD *)a1;
return result;
}

canonical_decompiled_code:
char *__fastcall func11(__int64 a1, __int64 a2)
{
char *result; // rax

result = func9(a2);
if ( *(_QWORD *)(a1 + 8) )
{
*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL) = result;
*((_QWORD *)result + 2) = *(_QWORD *)(a1 + 16);
}
else
{
*(_QWORD *)(a1 + 8) = result;
}
*(_QWORD *)(a1 + 16) = result;
++*(_DWORD *)a1;
return result;
}

original_code:
void list_push(list_t *list, void *element) {
    list_node_t *node = list_node_create(element);
    if (!list->head)
        list->head = node;
    else {
        list->tail->next = node;
        node->prev = list->tail;
    }
    list->tail = node;
    list->length++;
}

canonical_original_code:
void list_push(struct list_s *list, void *element) {
    struct list_node_s *node = list_node_create(element);
    if (!list->head)
        list->head = node;
    else {
        list->tail->next = node;
        node->prev = list->tail;
    }
    list->tail = node;
    list->length++;
}


original_code:
void *list_pop(list_t *list) {
    if (!list->head)
        return ((void *)0);
    void *element = list->tail->element;
    list->tail = list->tail->prev;
    if (list->tail)
        list->tail->next = ((void *)0);
    else
        list->head = ((void *)0);
    list->length--;
    return element;
}

canonical_original_code:
void *list_pop(struct list_s *list) {
    if (!list->head)
        return ((void *)0);
    void *element = list->tail->element;
    list->tail = list->tail->prev;
    if (list->tail)
        list->tail->next = ((void *)0);
    else
        list->head = ((void *)0);
    list->length--;
    return element;
}


original_code:
void *list_shift(list_t *list) {
    if (!list->head)
        return ((void *)0);
    void *element = list->head->element;
    list->head = list->head->next;
    if (list->head)
        list->head->prev = ((void *)0);
    else
        list->tail = ((void *)0);
    list->length--;
    return element;
}

canonical_original_code:
void *list_shift(struct list_s *list) {
    if (!list->head)
        return ((void *)0);
    void *element = list->head->element;
    list->head = list->head->next;
    if (list->head)
        list->head->prev = ((void *)0);
    else
        list->tail = ((void *)0);
    list->length--;
    return element;
}


decompiled_code:
__int64 __fastcall list_length(unsigned int *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func14(unsigned int *a1)
{
return *a1;
}

original_code:
int list_length(list_t *list) {
    return list->length;
}

canonical_original_code:
int list_length(struct list_s *list) {
    return list->length;
}


decompiled_code:
char *__fastcall list_iterator(__int64 a1)
{
char *result; // rax

result = memory_allocate(8LL);
*(_QWORD *)result = *(_QWORD *)(a1 + 8);
return result;
}

canonical_decompiled_code:
char *__fastcall func15(__int64 a1)
{
char *result; // rax

result = func1(8LL);
*(_QWORD *)result = *(_QWORD *)(a1 + 8);
return result;
}

original_code:
list_iterator_t *list_iterator(list_t *list) {
    list_iterator_t *iter = memory_allocate(sizeof(list_iterator_t));
    iter->pointer = list->head;
    return iter;
}

canonical_original_code:
struct list_iterator_s *list_iterator(struct list_s *list) {
    struct list_iterator_s *iter = memory_allocate(sizeof(list_iterator_t));
    iter->pointer = list->head;
    return iter;
}

variable_types: struct list_s { int length; struct list_node_s *head; struct list_node_s *tail; } *

variable_types: struct list_iterator_s { struct list_node_s { void *element; struct list_node_s *next; struct list_node_s *prev; } *pointer; } *

user_defined_types: struct list_iterator_s { struct list_node_s *pointer; }


decompiled_code:
__int64 __fastcall list_iterator_next(__int64 **a1)
{
__int64 *v1; // rax
__int64 v2; // rdx

v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = *v1;
*a1 = (__int64 *)v1[1];
return v2;
}

original_code:
void *list_iterator_next(list_iterator_t *iter) {
    void *ret;
    if (!iter->pointer)
        return ((void *)0);
    ret = iter->pointer->element;
    iter->pointer = iter->pointer->next;
    return ret;
}

canonical_original_code:
void *list_iterator_next(struct list_iterator_s *iter) {
    void *ret;
    if (!iter->pointer)
        return ((void *)0);
    ret = iter->pointer->element;
    iter->pointer = iter->pointer->next;
    return ret;
}

variable_types:
ret
void *


decompiled_code:
bool __fastcall list_iterator_end(_QWORD *a1)
{
return *a1 == 0LL;
}

canonical_decompiled_code:
bool __fastcall func17(_QWORD *a1)
{
return *a1 == 0LL;
}

original_code:
_Bool list_iterator_end(list_iterator_t *iter) {
    return !iter->pointer;
}

canonical_original_code:
_Bool list_iterator_end(struct list_iterator_s *iter) {
    return !iter->pointer;
}


decompiled_code:
char *__fastcall list_reverse(__int64 a1)
{
char *v1; // rbp
char *v2; // rbx
__int64 v3; // rax

v1 = list_create();
v2 = list_iterator(a1);
while ( !list_iterator_end(v2) )
{
v3 = list_iterator_next((__int64 **)v2);
list_shiftify((__int64)v1, v3);
}
return v1;
}

canonical_decompiled_code:
char *__fastcall func18(__int64 a1)
{
char *v1; // rbp
char *v2; // rbx
__int64 v3; // rax

v1 = func8();
v2 = func15(a1);
while ( !func17(v2) )
{
v3 = func16((__int64 **)v2);
func10((__int64)v1, v3);
}
return v1;
}

original_code:
list_t *list_reverse(list_t *list) {
    list_t *ret = list_create();
    for (list_iterator_t *it = list_iterator(list); !list_iterator_end(it); )
        list_shiftify(ret, list_iterator_next(it));
    return ret;
}

canonical_original_code:
struct list_s *list_reverse(struct list_s *list) {
    struct list_s *ret = list_create();
    for (struct list_iterator_s *it = list_iterator(list); !list_iterator_end(it); )
        list_shiftify(ret, list_iterator_next(it));
    return ret;
}

variable_types:
list
struct list_s *

return_type: struct list_s { int length; struct list_node_s { void *element; struct list_node_s *next; struct list_node_s *prev; } *head; struct list_node_s *tail; } *


decompiled_code:
__int64 __fastcall table_find(__int64 *a1, const char *a2)
{
__int64 *v2; // r13
char *v3; // rbp
__int64 v4; // rbx

v2 = a1;
if ( !a1 )
return 0LL;
do
{
v3 = list_iterator(*v2);
while ( !list_iterator_end(v3) )
{
v4 = list_iterator_next((__int64 **)v3);
if ( !strcmp(a2, *(const char **)v4) )
return *(_QWORD *)(v4 + 8);
}
v2 = (__int64 *)v2[1];
}
while ( v2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 *a1, const char *a2)
{
__int64 *v2; // r13
char *v3; // rbp
__int64 v4; // rbx

v2 = a1;
if ( !a1 )
return 0LL;
do
{
v3 = func15(*v2);
while ( !func17(v3) )
{
v4 = func16((__int64 **)v3);
if ( !strcmp(a2, *(const char **)v4) )
return *(_QWORD *)(v4 + 8);
}
v2 = (__int64 *)v2[1];
}
while ( v2 );
return 0LL;
}

original_code:
void *table_find(table_t *table, const char *key) {
    for (; table; table = table->parent) {
        for (list_iterator_t *it = list_iterator(table->list); !list_iterator_end(it); ) {
            table_entry_t *entry = list_iterator_next(it);
            if (!strcmp(key, entry->key))
                return entry->value;
        }
    }
    return ((void *)0);
}

canonical_original_code:
void *table_find(struct table_s *table, char *key) {
    for (; table; table = table->parent) {
        for (struct list_iterator_s *it = list_iterator(table->list); !list_iterator_end(it); ) {
            struct table_entry_t *entry = list_iterator_next(it);
            if (!strcmp(key, entry->key))
                return entry->value;
        }
    }
    return ((void *)0);
}

variable_types: struct table_s { struct list_s { int length; struct list_node_s { void *element; struct list_node_s *next; struct list_node_s *prev; } *head; struct list_node_s *tail; } *list; struct table_s *parent; } *

variable_types:
key
char *

variable_types: struct table_entry_t { char *key; void *value; } *

user_defined_types: struct table_s { struct list_s *list; struct table_s *parent; }


decompiled_code:
char *__fastcall table_insert(__int64 *a1, __int64 a2, __int64 a3)
{
char *v4; // rax

v4 = memory_allocate(16LL);
*(_QWORD *)v4 = a2;
*((_QWORD *)v4 + 1) = a3;
return list_push(*a1, (__int64)v4);
}

original_code:
void table_insert(table_t *table, char *key, void *value) {
    table_entry_t *entry = memory_allocate(sizeof(table_entry_t));
    entry->key = key;
    entry->value = value;
    list_push(table->list, entry);
}

canonical_original_code:
void table_insert(struct table_s *table, char *key, void *value) {
    struct table_entry_t *entry = memory_allocate(sizeof(table_entry_t));
    entry->key = key;
    entry->value = value;
    list_push(table->list, entry);
}

variable_types:
value
void *

user_defined_types: struct table_entry_t { char *key; void *value; }


decompiled_code:
__int64 __fastcall table_parent(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

original_code:
void *table_parent(table_t *table) {
    return table->parent;
}

canonical_original_code:
void *table_parent(struct table_s *table) {
    return table->parent;
}


decompiled_code:
char *__fastcall table_values(__int64 *a1)
{
__int64 *v1; // r12
char *i; // rbp
__int64 v4; // rax
char *v5; // rbx

v1 = a1;
for ( i = list_create(); v1; v1 = (__int64 *)v1[1] )
{
v5 = list_iterator(*v1);
while ( !list_iterator_end(v5) )
{
v4 = list_iterator_next((__int64 **)v5);
list_push((__int64)i, *(_QWORD *)(v4 + 8));
}
}
return i;
}

original_code:
list_t *table_values(table_t *table) {
    list_t *list = list_create();
    for (; table; table = table->parent)
        for (list_iterator_t *it = list_iterator(table->list); !list_iterator_end(it); )
            list_push(list, ((table_entry_t*)list_iterator_next(it))->value);
    return list;
}

canonical_original_code:
struct list_s *table_values(struct table_s *table) {
    struct list_s *list = list_create();
    for (; table; table = table->parent)
        for (struct list_iterator_s *it = list_iterator(table->list); !list_iterator_end(it); )
            list_push(list, ((struct table_entry_t *)list_iterator_next(it))->value);
    return list;
}

variable_types: struct table_s { struct list_s *list; struct table_s *parent; } *


decompiled_code:
char *__fastcall table_keys(__int64 *a1)
{
__int64 *v1; // r12
char *i; // rbp
__int64 *v4; // rax
char *v5; // rbx

v1 = a1;
for ( i = list_create(); v1; v1 = (__int64 *)v1[1] )
{
v5 = list_iterator(*v1);
while ( !list_iterator_end(v5) )
{
v4 = (__int64 *)list_iterator_next((__int64 **)v5);
list_push((__int64)i, *v4);
}
}
return i;
}

original_code:
list_t *table_keys(table_t *table) {
    list_t *list = list_create();
    for (; table; table = table->parent)
        for (list_iterator_t *it = list_iterator(table->list); !list_iterator_end(it); )
            list_push(list, ((table_entry_t*)list_iterator_next(it))->key);
    return list;
}

canonical_original_code:
struct list_s *table_keys(struct table_s *table) {
    struct list_s *list = list_create();
    for (; table; table = table->parent)
        for (struct list_iterator_s *it = list_iterator(table->list); !list_iterator_end(it); )
            list_push(list, ((struct table_entry_t *)list_iterator_next(it))->key);
    return list;
}


strcasecmp

decompiled_code:
__int64 __fastcall strcasecmp(__int64 a1, __int64 a2)
{
const __int32_t *v4; // rsi
__int64 i; // rax
unsigned __int8 v6; // dl
__int32_t v7; // ecx
__int32_t v8; // edi

v4 = *_ctype_tolower_loc();
for ( i = 0LL; ; ++i )
{
v6 = *(_BYTE *)(a1 + i);
v7 = v4[v6];
v8 = v4[*(unsigned __int8 *)(a2 + i)];
if ( v8 != v7 )
break;
if ( !v6 )
return 0LL;
}
return (unsigned int)(v7 - v8);
}

canonical_decompiled_code:
__int64 __fastcall func25(__int64 a1, __int64 a2)
{
const __int32_t *v4; // rsi
__int64 i; // rax
unsigned __int8 v6; // dl
__int32_t v7; // ecx
__int32_t v8; // edi

v4 = *_ctype_tolower_loc();
for ( i = 0LL; ; ++i )
{
v6 = *(_BYTE *)(a1 + i);
v7 = v4[v6];
v8 = v4[*(unsigned __int8 *)(a2 + i)];
if ( v8 != v7 )
break;
if ( !v6 )
return 0LL;
}
return (unsigned int)(v7 - v8);
}

original_code:
int strcasecmp(const char *s1, const char *s2) {
    const unsigned char *u1 = (const unsigned char *)s1;
    const unsigned char *u2 = (const unsigned char *)s2;
    while (tolower(*u1) == tolower(*u2++))
        if(*u1++ == '\0')
            return 0;
    return tolower(*u1) - tolower(*--u2);
}

canonical_original_code:
int strcasecmp(char *s1, char *s2) {
    unsigned char *u1 = (const unsigned char *)s1;
    unsigned char *u2 = (const unsigned char *)s2;
    while (tolower(*u1) == tolower(*u2++))
        if(*u1++ == '\0')
            return 0;
    return tolower(*u1) - tolower(*--u2);
}


strncasecmp

decompiled_code:
__int64 __fastcall strncasecmp(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
const __int32_t *v7; // rsi
__int64 v8; // rax
unsigned __int8 v9; // dl
__int32_t v10; // ecx
__int32_t v11; // edi

result = 0LL;
if ( a3 )
{
v7 = *_ctype_tolower_loc();
v8 = 0LL;
while ( 1 )
{
v9 = *(_BYTE *)(a1 + v8);
v10 = v7[v9];
v11 = v7[*(unsigned __int8 *)(a2 + v8)];
if ( v11 != v10 )
return (unsigned int)(v10 - v11);
if ( !v9 )
break;
if ( a3 == ++v8 )
return 0LL;
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func26(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
const __int32_t *v7; // rsi
__int64 v8; // rax
unsigned __int8 v9; // dl
__int32_t v10; // ecx
__int32_t v11; // edi

result = 0LL;
if ( a3 )
{
v7 = *_ctype_tolower_loc();
v8 = 0LL;
while ( 1 )
{
v9 = *(_BYTE *)(a1 + v8);
v10 = v7[v9];
v11 = v7[*(unsigned __int8 *)(a2 + v8)];
if ( v11 != v10 )
return (unsigned int)(v10 - v11);
if ( !v9 )
break;
if ( a3 == ++v8 )
return 0LL;
}
result = 0LL;
}
return result;
}

original_code:
int strncasecmp(const char *s1, const char *s2, size_t n) {
    const unsigned char *u1 = (const unsigned char *)s1;
    const unsigned char *u2 = (const unsigned char *)s2;
    if (!n)
        return 0;
    do {
        if (tolower(*u1) != tolower(*u2++))
            return tolower(*u1) - tolower(*--u2);
        if (*u1++ == '\0')
            break;
    } while (--n != 0);
    return 0;
}

canonical_original_code:
int strncasecmp(char *s1, char *s2, unsigned long n) {
    unsigned char *u1 = (const unsigned char *)s1;
    unsigned char *u2 = (const unsigned char *)s2;
    if (!n)
        return 0;
    do {
        if (tolower(*u1) != tolower(*u2++))
            return tolower(*u1) - tolower(*--u2);
        if (*u1++ == '\0')
            break;
    } while (--n != 0);
    return 0;
}

variable_types:
n
unsigned long


decompiled_code:
void __noreturn compile_error(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
vfprintf(stderr, format, arg);
fputc(10, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func0(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
vfprintf(stderr, format, arg);
fputc(10, stderr);
exit(1);
}

original_code:
void compile_error(const char *fmt, ...) {
    va_list a;
    __builtin_va_start(a,fmt);
    vfprintf(stderr, fmt, a);
    fprintf(stderr, "\n");
    __builtin_va_end(a);
    exit(1);
}

canonical_original_code:
void compile_error(char *fmt, ...) {
    __builtin_va_list a;
    __builtin_va_start(a,fmt);
    vfprintf(stderr, fmt, a);
    fprintf(stderr, "\n");
    __builtin_va_end(a);
    exit(1);
}

variable_types:
fmt
char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
bool v4; // di

v4 = 0;
if ( argc != 1 )
v4 = strcmp(argv[1], "--dump-ast") == 0;
return compile_begin(v4) == 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
bool v4; // di

v4 = 0;
if ( argc != 1 )
v4 = strcmp(argv[1], "--dump-ast") == 0;
return func1(v4) == 0;
}

original_code:
int main(int argc, char **argv) {
    argc--;
    argv++;
    return compile_begin(!!(argc && !strcmp(*argv, "--dump-ast")))
            ? 0
            : 1;
}

variable_types: argc int

variable_types:
argv
char **


repo: dormando/mc-crusher

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
unsigned int v4; // ebx
_QWORD *v5; // rdx
__int64 i; // rax

if ( argc <= 1 )
{
fwrite("usage: balloon [megabytes]\n", 1uLL, 0x1BuLL, stderr);
exit(1);
}
setvbuf(stdout, 0LL, 2, 0LL);
v3 = (unsigned int)atoi(argv[1]);
printf("megabytes: %d\n", v3);
if ( (int)v3 > 0 )
{
v4 = 0;
do
{
v5 = calloc(1uLL, 0x100000uLL);
if ( !v5 )
{
fprintf(stderr, "Failed to calloc chunk #%d\n", v4);
exit(1);
}
for ( i = 0LL; i != 0x20000; ++i )
v5[i] = i;
++v4;
}
while ( (_DWORD)v3 != v4 );
}
puts("done.");
pause();
return 0;
}

original_code:
int main(int argc, char **argv) {
    if (argc < 2) {
        fprintf(stderr, "usage: balloon [megabytes]\n");
        exit(1);
    }
    setvbuf(stdout, ((void *)0), 2, 0);
    int size = atoi(argv[1]);
    printf("megabytes: %d\n", size);
    for (int x = 0; x < size; x++) {
        uint64_t *temp = calloc(1, 1024 * 1024);
        if (temp == ((void *)0)) {
            fprintf(stderr, "Failed to calloc chunk #%d\n", x);
            exit(1);
        }
        for (int i = 0; i < (1024*1024) / sizeof(uint64_t); i++) {
            temp[i] = i;
        }
    }
    printf("done.\n");
    pause();
}

canonical_original_code:
int main(int argc, char **argv) {
    if (argc < 2) {
        fprintf(stderr, "usage: balloon [megabytes]\n");
        exit(1);
    }
    setvbuf(stdout, ((void *)0), 2, 0);
    int size = atoi(argv[1]);
    printf("megabytes: %d\n", size);
    for (int x = 0; x < size; x++) {
        unsigned long *temp = calloc(1, 1024 * 1024);
        if (temp == ((void *)0)) {
            fprintf(stderr, "Failed to calloc chunk #%d\n", x);
            exit(1);
        }
        for (int i = 0; i < (1024*1024) / sizeof(unsigned long); i++) {
            temp[i] = i;
        }
    }
    printf("done.\n");
    pause();
}

variable_types: size int

variable_types: x int

variable_types:
temp
unsigned long *

variable_types: i int


timerThread

decompiled_code:
void *__fastcall timerThread(void *a1)
{
sleep(0x10Eu);
processing = 0;
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func0(void *a1)
{
sleep(0x10Eu);
processing = 0;
return 0LL;
}

original_code:
void* timerThread(void *arg) {
 sleep(60*4.5);
 processing = 0;
 return ((void *)0);
}

canonical_original_code:
void *timerThread(void *arg) {
 sleep(60*4.5);
 processing = 0;
 return ((void *)0);
}

variable_types:
arg
void *


original_code:
void S_sort(struct endwindows tab[],int n) {
 unsigned long int i, j, min;
 struct endwindows tmp;
 for(i=0; i<n; i++) {
  min = i;
  for(j=i+1; j<n; j++) {
   if(tab[j].l<tab[min].l)
    min = j;
  }
  tmp = tab[i];
  tab[i] = tab[min];
  tab[min] = tmp;
 }
}

canonical_original_code:
void S_sort(struct endwindows tab[], int n) {
 unsigned long i; unsigned long j; unsigned long min;
 struct endwindows tmp;
 for(i=0; i<n; i++) {
  min = i;
  for(j=i+1; j<n; j++) {
   if(tab[j].l<tab[min].l)
    min = j;
  }
  tmp = tab[i];
  tab[i] = tab[min];
  tab[min] = tmp;
 }
}

variable_types: struct endwindows { int l; struct customerlist { int i; int x; int q; int e; int l; int d; double road0; struct customerlist *next; struct customerlist *prev; } *customer; } []

variable_types: n int

variable_types:
i
unsigned long

variable_types:
j
unsigned long

variable_types:
min
unsigned long

user_defined_types: struct endwindows { int l; struct customerlist *customer; }


FreeList

decompiled_code:
void __fastcall FreeList(_QWORD **a1)
{
_QWORD *v2; // rdi

v2 = *a1;
if ( v2 )
{
do
{
*a1 = (_QWORD *)v2[5];
free(v2);
v2 = *a1;
}
while ( *a1 );
}
}

canonical_decompiled_code:
void __fastcall func3(_QWORD **a1)
{
_QWORD *v2; // rdi

v2 = *a1;
if ( v2 )
{
do
{
*a1 = (_QWORD *)v2[5];
free(v2);
v2 = *a1;
}
while ( *a1 );
}
}

original_code:
void FreeList(struct customerlist** head_reference) {
 struct customerlist* pom;
 while (*head_reference!=((void *)0)) {
  pom=*head_reference;
  *head_reference=(*head_reference)->next;
  free(pom);
 }
}

canonical_original_code:
void FreeList(struct customerlist **head_reference) {
 struct customerlist *pom;
 while (*head_reference!=((void *)0)) {
  pom=*head_reference;
  *head_reference=(*head_reference)->next;
  free(pom);
 }
}

variable_types: struct customerlist { int i; int x; int q; int e; int l; int d; double road0; struct customerlist *next; struct customerlist *prev; } **


generateNext

decompiled_code:
void generateNext()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void generateNext(struct sol_list* track) {
 return;
}

canonical_original_code:
void generateNext(struct sol_list *track) {
 return;
}

variable_types: struct sol_list { struct track { struct customerlist { int i; int x; int q; int e; int l; int d; double road0; struct customerlist *next; struct customerlist *prev; } *customer; float cur_cost; struct track *next; } *start; struct sol_list *next; } *

user_defined_types: struct sol_list { struct track *start; struct sol_list *next; }

user_defined_types: struct track { struct customerlist *customer; float cur_cost; struct track *next; }


repo: dowski/preptime

decompiled_code:
char *__fastcall current_utc_timestamp(char *s)
{
char *v1; // rbx
struct tm *v2; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

v1 = s;
timer = time(0LL);
v2 = gmtime(&timer);
if ( !strftime(s, 0x32uLL, "%Y/%m/%d %H:%M:%S", v2) )
v1 = 0LL;
return v1;
}

canonical_decompiled_code:
char *__fastcall func7(char *s)
{
char *v1; // rbx
struct tm *v2; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

v1 = s;
timer = time(0LL);
v2 = gmtime(&timer);
if ( !strftime(s, 0x32uLL, "%Y/%m/%d %H:%M:%S", v2) )
v1 = 0LL;
return v1;
}

original_code:
char *current_utc_timestamp(char *out)
{
    time_t now;
    struct tm *tm;
    now = time(((void *)0));
    tm = gmtime(&now);
    if (!strftime(out, 50, "%Y/%m/%d %H:%M:%S", tm)) {
        return ((void *)0);
    }
    return out;
}

canonical_original_code:
char *current_utc_timestamp(char *out)
{
    long now;
    struct tm *tm;
    now = time(((void *)0));
    tm = gmtime(&now);
    if (!strftime(out, 50, "%Y/%m/%d %H:%M:%S", tm)) {
        return ((void *)0);
    }
    return out;
}

variable_types:
out
char *

variable_types: now long

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
int v4; // eax
int v5; // ecx
bool v6; // dl
bool v7; // al
char v9[64]; // [rsp+0h] [rbp-458h] BYREF
char v10[1048]; // [rsp+40h] [rbp-418h] BYREF

while ( 2 )
{
v3 = 1LL;
do
{
v4 = getchar();
if ( v4 == -1 )
return 0;
v5 = v3;
v9[v3 + 63] = v4;
v6 = v4 == 10;
v7 = (_DWORD)v3++ == 1024;
}
while ( !v7 && !v6 );
v10[v5] = 0;
if ( current_utc_timestamp(v9) )
{
printf("%s :: %s", v9, v10);
continue;
}
break;
}
printf("%s: Error formatting the timestamp\n", *argv);
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
int v4; // eax
int v5; // ecx
bool v6; // dl
bool v7; // al
char v9[64]; // [rsp+0h] [rbp-458h] BYREF
char v10[1048]; // [rsp+40h] [rbp-418h] BYREF

while ( 2 )
{
v3 = 1LL;
do
{
v4 = getchar();
if ( v4 == -1 )
return 0;
v5 = v3;
v9[v3 + 63] = v4;
v6 = v4 == 10;
v7 = (_DWORD)v3++ == 1024;
}
while ( !v7 && !v6 );
v10[v5] = 0;
if ( func7(v9) )
{
printf("%s :: %s", v9, v10);
continue;
}
break;
}
printf("%s: Error formatting the timestamp\n", *argv);
return 1;
}

original_code:
int main(int argc, char **argv)
{
    char line[1024], timestamp[50];
    int c, idx;
    idx = 0;
    while ((c = getchar()) != (-1)) {
        line[idx++] = c;
        if (c == '\n' || idx == 1024) {
            line[idx] = '\0';
            if (!current_utc_timestamp(timestamp)) {
                printf("%s: Error formatting the timestamp\n", argv[0]);
                return 1;
            }
            printf("%s :: %s", timestamp, line);
            idx = 0;
        }
    }
    return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
    char line[1024]; char timestamp[50];
    int c; int idx;
    idx = 0;
    while ((c = getchar()) != (-1)) {
        line[idx++] = c;
        if (c == '\n' || idx == 1024) {
            line[idx] = '\0';
            if (!current_utc_timestamp(timestamp)) {
                printf("%s: Error formatting the timestamp\n", argv[0]);
                return 1;
            }
            printf("%s :: %s", timestamp, line);
            idx = 0;
        }
    }
    return 0;
}

variable_types: argc int

variable_types:
line
char [1024]

variable_types:
timestamp
char [50]

variable_types: c int

variable_types: idx int


repo: doy/luancurses

decompiled_code:
__int64 __fastcall get_color_enum(const char *a1)
{
return str2enum((__int64)&colors, 8, a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
return func2((__int64)&colors, 8, a1);
}

original_code:
int get_color_enum(const char* str)
{
    return str2enum(colors, (sizeof(colors) / sizeof((colors)[0])), str);
}

canonical_original_code:
int get_color_enum(char *str)
{
    return str2enum(colors, (sizeof(colors) / sizeof((colors)[0])), str);
}

variable_types:
str
char *


decompiled_code:
__int64 __fastcall get_mode_enum(const char *a1)
{
return str2enum((__int64)&modes, 10, a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1)
{
return func2((__int64)&modes, 10, a1);
}

original_code:
int get_mode_enum(const char* str)
{
    return str2enum(modes, (sizeof(modes) / sizeof((modes)[0])), str);
}

canonical_original_code:
int get_mode_enum(char *str)
{
    return str2enum(modes, (sizeof(modes) / sizeof((modes)[0])), str);
}


decompiled_code:
__int64 __fastcall get_key_enum(const char *a1)
{
__int64 result; // rax
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

result = str2enum((__int64)&keys, 13, a1);
if ( (_DWORD)result == -1 )
{
if ( (unsigned int)_isoc99_sscanf(a1, &LC0, v2) == 1 )
result = (unsigned int)(v2[0] + 264);
else
result = (unsigned int)*a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1)
{
__int64 result; // rax
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

result = func2((__int64)&keys, 13, a1);
if ( (_DWORD)result == -1 )
{
if ( (unsigned int)_isoc99_sscanf(a1, &LC0, v2) == 1 )
result = (unsigned int)(v2[0] + 264);
else
result = (unsigned int)*a1;
}
return result;
}

original_code:
int get_key_enum(const char* str)
{
    int ret;
    ret = str2enum(keys, (sizeof(keys) / sizeof((keys)[0])), str);
    if (ret == -1) {
        int fkey;
        if (sscanf(str, "F%d", &fkey) == 1) {
            return (0410 +(fkey));
        }
    }
    return ret == -1 ? (int)str[0] : ret;
}

canonical_original_code:
int get_key_enum(char *str)
{
    int ret;
    ret = str2enum(keys, (sizeof(keys) / sizeof((keys)[0])), str);
    if (ret == -1) {
        int fkey;
        if (sscanf(str, "F%d", &fkey) == 1) {
            return (0410 +(fkey));
        }
    }
    return ret == -1 ? (int)str[0] : ret;
}

variable_types: ret int

variable_types: fkey int


decompiled_code:
__int64 __fastcall get_char_enum(char *a1)
{
return (unsigned int)*a1;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *a1)
{
return (unsigned int)*a1;
}

original_code:
int get_char_enum(const char* str)
{
    return (int)str[0];
}

canonical_original_code:
int get_char_enum(char *str)
{
    return (int)str[0];
}


decompiled_code:
__int64 __fastcall get_color_str(int a1)
{
return enum2str(&colors, 8, a1);
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
return func0(&colors, 8, a1);
}

original_code:
const char* get_color_str(int tag)
{
    return enum2str(colors, (sizeof(colors) / sizeof((colors)[0])), tag);
}

canonical_original_code:
char *get_color_str(int tag)
{
    return enum2str(colors, (sizeof(colors) / sizeof((colors)[0])), tag);
}

variable_types: tag int


decompiled_code:
__int64 __fastcall get_mode_str(int a1)
{
return enum2str(&modes, 10, a1);
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
return func0(&modes, 10, a1);
}

original_code:
const char* get_mode_str(int tag)
{
    return enum2str(modes, (sizeof(modes) / sizeof((modes)[0])), tag);
}

canonical_original_code:
char *get_mode_str(int tag)
{
    return enum2str(modes, (sizeof(modes) / sizeof((modes)[0])), tag);
}


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

if ( (unsigned int)(a1 - 264) <= 0x3F )
result = (__int64)*(&fn_keys + a1 - 264);
else
result = enum2str(&keys, 13, a1);
return result;
}

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

if ( (unsigned int)(a1 - 264) <= 0x3F )
result = (__int64)*(&fn_keys + a1 - 264);
else
result = func0(&keys, 13, a1);
return result;
}

original_code:
const char* get_key_str(int tag)
{
    if (tag >= (0410 +(0)) && tag <= (0410 +(63))) {
        return fn_keys[tag - 0410];
    }
    return enum2str(keys, (sizeof(keys) / sizeof((keys)[0])), tag);
}

canonical_original_code:
char *get_key_str(int tag)
{
    if (tag >= (0410 +(0)) && tag <= (0410 +(63))) {
        return fn_keys[tag - 0410];
    }
    return enum2str(keys, (sizeof(keys) / sizeof((keys)[0])), tag);
}


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

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

original_code:
const char* get_char_str(int tag)
{
    return ((void *)0);
}

canonical_original_code:
char *get_char_str(int tag)
{
    return ((void *)0);
}


decompiled_code:
__int64 __fastcall each_color(__int64 (__fastcall *a1)(_QWORD, _QWORD, __int64), __int64 a2)
{
return each_item((__int64)&colors, 8, a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 (__fastcall *a1)(_QWORD, _QWORD, __int64), __int64 a2)
{
return func1((__int64)&colors, 8, a1, a2);
}

original_code:
void each_color(table_cb cb, void* data)
{
    each_item(colors, (sizeof(colors) / sizeof((colors)[0])), cb, data);
}

canonical_original_code:
void each_color(void (*cb)(char *str, int tag, void *data), void *data)
{
    each_item(colors, (sizeof(colors) / sizeof((colors)[0])), cb, data);
}

variable_types: void (*)(char *str, int tag, void *data)

variable_types:
data
void *


decompiled_code:
__int64 __fastcall each_mode(__int64 (__fastcall *a1)(_QWORD, _QWORD, __int64), __int64 a2)
{
return each_item((__int64)&modes, 10, a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 (__fastcall *a1)(_QWORD, _QWORD, __int64), __int64 a2)
{
return func1((__int64)&modes, 10, a1, a2);
}

original_code:
void each_mode(table_cb cb, void* data)
{
    each_item(modes, (sizeof(modes) / sizeof((modes)[0])), cb, data);
}

canonical_original_code:
void each_mode(void (*cb)(char *str, int tag, void *data), void *data)
{
    each_item(modes, (sizeof(modes) / sizeof((modes)[0])), cb, data);
}


decompiled_code:
__int64 __fastcall each_key(__int64 (__fastcall *a1)(_QWORD, _QWORD, __int64), __int64 a2)
{
return each_item((__int64)&keys, 13, a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 (__fastcall *a1)(_QWORD, _QWORD, __int64), __int64 a2)
{
return func1((__int64)&keys, 13, a1, a2);
}

original_code:
void each_key(table_cb cb, void* data)
{
    each_item(keys, (sizeof(keys) / sizeof((keys)[0])), cb, data);
}

canonical_original_code:
void each_key(void (*cb)(char *str, int tag, void *data), void *data)
{
    each_item(keys, (sizeof(keys) / sizeof((keys)[0])), cb, data);
}


decompiled_code:
void each_char()
{
;
}

canonical_decompiled_code:
void func14()
{
;
}

original_code:
void each_char(table_cb cb, void* data)
{
}

canonical_original_code:
void each_char(void (*cb)(char *str, int tag, void *data), void *data)
{
}


repo: doy/luasignal

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

result = 0LL;
if ( a2 > 0 )
{
v3 = malloc(4LL * a2);
*(_QWORD *)a1 = v3;
if ( v3 )
{
*(_DWORD *)(a1 + 8) = 0;
*(_DWORD *)(a1 + 12) = a2;
*(_DWORD *)(a1 + 16) = 0;
*(_DWORD *)(a1 + 20) = 0;
result = 1LL;
}
else
{
result = 0LL;
}
}
return result;
}

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

result = 0LL;
if ( a2 > 0 )
{
v3 = malloc(4LL * a2);
*(_QWORD *)a1 = v3;
if ( v3 )
{
*(_DWORD *)(a1 + 8) = 0;
*(_DWORD *)(a1 + 12) = a2;
*(_DWORD *)(a1 + 16) = 0;
*(_DWORD *)(a1 + 20) = 0;
result = 1LL;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
int queue_init(queue* q, int cap)
{
    if (cap < 1) {
        return 0;
    }
    if ((q->queue = (int*)malloc(cap * sizeof(int))) == ((void *)0)) {
        return 0;
    }
    q->size = 0;
    q->cap = cap;
    q->front = 0;
    q->back = 0;
    return 1;
}

canonical_original_code:
int queue_init(struct _queue *q, int cap)
{
    if (cap < 1) {
        return 0;
    }
    if ((q->queue = (int *)malloc(cap * sizeof(int))) == ((void *)0)) {
        return 0;
    }
    q->size = 0;
    q->cap = cap;
    q->front = 0;
    q->back = 0;
    return 1;
}

variable_types: struct _queue { int *queue; int size; int cap; int front; int back; } *

variable_types: cap int


enqueue

original_code:
int enqueue(queue* q, int item)
{
    if (q->size == q->cap) {
        if (!_queue_resize(q, 2 * q->cap)) {
            return 0;
        }
    }
    q->queue[q->front++] = item;
    q->front %= q->cap;
    ++q->size;
    return 1;
}

canonical_original_code:
int enqueue(struct _queue *q, int item)
{
    if (q->size == q->cap) {
        if (!_queue_resize(q, 2 * q->cap)) {
            return 0;
        }
    }
    q->queue[q->front++] = item;
    q->front %= q->cap;
    ++q->size;
    return 1;
}

variable_types: item int

user_defined_types: struct _queue { int *queue; int size; int cap; int front; int back; }


dequeue

original_code:
int dequeue(queue* q)
{
    int ret;
    if (q->size == 0) {
        return -1;
    }
    ret = q->queue[q->back++];
    q->back %= q->cap;
    --q->size;
    return ret;
}

canonical_original_code:
int dequeue(struct _queue *q)
{
    int ret;
    if (q->size == 0) {
        return -1;
    }
    ret = q->queue[q->back++];
    q->back %= q->cap;
    --q->size;
    return ret;
}


original_code:
void queue_delete(queue* q)
{
    free(q->queue);
    q->queue = ((void *)0);
    q->size = 0;
    q->cap = 0;
}

canonical_original_code:
void queue_delete(struct _queue *q)
{
    free(q->queue);
    q->queue = ((void *)0);
    q->size = 0;
    q->cap = 0;
}


decompiled_code:
__int64 __fastcall name_to_sig(char *s2)
{
const char **v2; // rbp
int v3; // ebx
__int64 result; // rax
int v5; // ebx

v2 = (const char **)&off_1C8;
v3 = 0;
if ( !memcmp(s2, "RT", 2uLL) )
{
v5 = atoi(s2 + 2);
result = (unsigned int)(v5 + _libc_current_sigrtmin());
}
else
{
while ( strcmp(*v2, s2) )
{
++v3;
v2 += 2;
if ( v3 == 34 )
return 0xFFFFFFFFLL;
}
result = *((unsigned int *)&sigs + 4 * v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s2)
{
const char **v2; // rbp
int v3; // ebx
__int64 result; // rax
int v5; // ebx

v2 = (const char **)&off_1C8;
v3 = 0;
if ( !memcmp(s2, "RT", 2uLL) )
{
v5 = atoi(s2 + 2);
result = (unsigned int)(v5 + _libc_current_sigrtmin());
}
else
{
while ( strcmp(*v2, s2) )
{
++v3;
v2 += 2;
if ( v3 == 34 )
return 0xFFFFFFFFLL;
}
result = *((unsigned int *)&sigs + 4 * v3);
}
return result;
}

original_code:
int name_to_sig(const char* name)
{
    if (strncmp(name, "RT", 2) == 0) {
        int rtsig;
        rtsig = atoi(name + 2);
        return rtsig + (__libc_current_sigrtmin ());
    }
    else {
        int i;
        for (i = 0; i < sizeof(sigs) / sizeof(sigs[0]); ++i) {
            if (strcmp(sigs[i].name, name) == 0) {
                return sigs[i].sig;
            }
        }
        return -1;
    }
}

canonical_original_code:
int name_to_sig(char *name)
{
    if (strncmp(name, "RT", 2) == 0) {
        int rtsig;
        rtsig = atoi(name + 2);
        return rtsig + (__libc_current_sigrtmin ());
    }
    else {
        int i;
        for (i = 0; i < sizeof(sigs) / sizeof(sigs[0]); ++i) {
            if (strcmp(sigs[i].name, name) == 0) {
                return sigs[i].sig;
            }
        }
        return -1;
    }
}

variable_types:
name
char *

variable_types: rtsig int

variable_types: i int


repo: dpapathanasiou/zen-thought

decompiled_code:
__int64 get_mday_today()
{
time_t timer; // [rsp+8h] [rbp-10h] BYREF

time(&timer);
return (unsigned int)localtime(&timer)->tm_mday;
}

canonical_decompiled_code:
__int64 func7()
{
time_t timer; // [rsp+8h] [rbp-10h] BYREF

time(&timer);
return (unsigned int)localtime(&timer)->tm_mday;
}

original_code:
int get_mday_today () {
  time_t rawtime;
  struct tm *timeinfo;
  time( &rawtime );
  timeinfo = localtime( &rawtime );
  return timeinfo->tm_mday;
}

canonical_original_code:
int get_mday_today() {
  long rawtime;
  struct tm *timeinfo;
  time( &rawtime );
  timeinfo = localtime( &rawtime );
  return timeinfo->tm_mday;
}

variable_types: rawtime long

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
size_t v3; // rbp
__int64 v4; // r12
const char *v5; // rbx
char *v6; // rbx
char *s[35]; // [rsp+0h] [rbp-118h] BYREF

if ( argc <= 1 )
load_aphorisms("/usr/local/share/games/zen-thought/jotaiga-aphorisms.txt", s);
else
load_aphorisms(argv[1], s);
v3 = 0LL;
v4 = (int)(get_mday_today() - 1);
while ( 1 )
{
v5 = s[v4];
if ( strlen(v5) <= v3 )
break;
v6 = (char *)&v5[v3];
if ( *v6 == 124 )
*v6 = 10;
++v3;
}
printf("\n%s\n\n", v5);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
size_t v3; // rbp
__int64 v4; // r12
const char *v5; // rbx
char *v6; // rbx
char *s[35]; // [rsp+0h] [rbp-118h] BYREF

if ( argc <= 1 )
func8("/usr/local/share/games/zen-thought/jotaiga-aphorisms.txt", s);
else
func8(argv[1], s);
v3 = 0LL;
v4 = (int)(func7() - 1);
while ( 1 )
{
v5 = s[v4];
if ( strlen(v5) <= v3 )
break;
v6 = (char *)&v5[v3];
if ( *v6 == 124 )
*v6 = 10;
++v3;
}
printf("\n%s\n\n", v5);
return 0;
}

original_code:
int main(int argc, char *argv[]) {
  char *sayings[31];
  if( argc > 1 ) {
    load_aphorisms(argv[1], sayings);
  } else {
 load_aphorisms("/usr/local/share/games/zen-thought/jotaiga-aphorisms.txt", sayings);
  }
  int i,
    today = get_mday_today() - 1;
  for(i=0; i<strlen(sayings[today]); i++) {
    if( sayings[today][i] == '|' ) {
      sayings[today][i] = '\n';
    }
  }
  printf("\n%s\n\n", sayings[today]);
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
  char *sayings[31];
  if( argc > 1 ) {
    load_aphorisms(argv[1], sayings);
  } else {
 load_aphorisms("/usr/local/share/games/zen-thought/jotaiga-aphorisms.txt", sayings);
  }
  int i; int today = get_mday_today() - 1;
  for(i=0; i<strlen(sayings[today]); i++) {
    if( sayings[today][i] == '|' ) {
      sayings[today][i] = '\n';
    }
  }
  printf("\n%s\n\n", sayings[today]);
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
sayings
char *[31]

variable_types: today int


swap

decompiled_code:
__int64 __fastcall swap(__int64 a1, int a2)
{
int v2; // ebp
int i; // eax
int *v4; // rdx
int v5; // ecx
int *v6; // rax

v2 = rand() % a2;
for ( i = rand() % a2; v2 == i; i = rand() % a2 )
;
v4 = (int *)(a1 + 4LL * v2);
v5 = *v4;
v6 = (int *)(a1 + 4LL * i);
*v4 = *v6;
*v6 = v5;
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
int v2; // ebp
int i; // eax
int *v4; // rdx
int v5; // ecx
int *v6; // rax

v2 = rand() % a2;
for ( i = rand() % a2; v2 == i; i = rand() % a2 )
;
v4 = (int *)(a1 + 4LL * v2);
v5 = *v4;
v6 = (int *)(a1 + 4LL * i);
*v4 = *v6;
*v6 = v5;
return a1;
}

original_code:
int * swap(int arr[], int size) {
    int i;
    int j;
    i = (rand()%size);
    j = (rand()%size);
    while( i == j){
        j = (rand()%size);
    }
    int temp;
    temp = arr[i];
    arr[i] = arr[j];
    arr[j] = temp;
    i = 0;
    j = 0;
    return arr;
}

canonical_original_code:
int *swap(int arr[], int size) {
    int i;
    int j;
    i = (rand()%size);
    j = (rand()%size);
    while( i == j){
        j = (rand()%size);
    }
    int temp;
    temp = arr[i];
    arr[i] = arr[j];
    arr[j] = temp;
    i = 0;
    j = 0;
    return arr;
}

variable_types:
arr
int []

variable_types: size int

variable_types: j int

variable_types: temp int

return_type: int *


genInts

decompiled_code:
__int64 __fastcall genInts(int a1, int a2, int a3, int a4)
{
_DWORD *v7; // rax
_DWORD *v8; // rdx
unsigned int v9; // eax
int v10; // ebx

v7 = malloc((size_t)&dword_400000);
arr_0 = (__int64)v7;
if ( a1 > 0 )
{
v8 = &v7[a1];
do
{
*v7 = a2;
a2 += a3;
++v7;
}
while ( v7 != v8 );
}
v9 = time(0LL);
srand(v9);
if ( a4 > 0 )
{
v10 = 0;
do
{
arr_0 = swap(arr_0, a1);
++v10;
}
while ( a4 != v10 );
}
return arr_0;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, int a2, int a3, int a4)
{
_DWORD *v7; // rax
_DWORD *v8; // rdx
unsigned int v9; // eax
int v10; // ebx

v7 = malloc((size_t)&dword_400000);
arr_0 = (__int64)v7;
if ( a1 > 0 )
{
v8 = &v7[a1];
do
{
*v7 = a2;
a2 += a3;
++v7;
}
while ( v7 != v8 );
}
v9 = time(0LL);
srand(v9);
if ( a4 > 0 )
{
v10 = 0;
do
{
arr_0 = func7(arr_0, a1);
++v10;
}
while ( a4 != v10 );
}
return arr_0;
}

original_code:
int * genInts(int count, int start, int step, int swaps) {
    static int* arr;
    arr = malloc(1048576 * sizeof(count));
    int i;
    int j = start;
    for(i = 0; i < count; i++){
        arr[i] = j;
        j += step;
    }
    srand(time(((void *)0)));
    int k = 0;
    while (k < swaps) {
        arr = swap(arr, count);
        k++;
    }
    return arr;
}

canonical_original_code:
int *genInts(int count, int start, int step, int swaps) {
    static int *arr;
    arr = malloc(1048576 * sizeof(count));
    int i;
    int j = start;
    for(i = 0; i < count; i++){
        arr[i] = j;
        j += step;
    }
    srand(time(((void *)0)));
    int k = 0;
    while (k < swaps) {
        arr = swap(arr, count);
        k++;
    }
    return arr;
}

variable_types: count int

variable_types: start int

variable_types: step int

variable_types: swaps int

variable_types:
arr
int *

variable_types: k int


main

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

if ( argc <= 4 )
{
puts("ERROR: Invalid number of arguments");
printf("USAGE: %s <count> <start> <step> <swaps>\n", *argv);
result = 1;
}
else
{
v3 = atoi(argv[1]);
v4 = atoi(argv[2]);
v5 = atoi(argv[3]);
v6 = atoi(argv[4]);
v7 = genInts(v3, v4, v5, v6);
if ( v3 <= 0 )
{
result = 0;
}
else
{
v8 = (unsigned int *)v7;
v9 = v7 + 4LL * (unsigned int)(v3 - 1) + 4;
do
printf("%d\n", *v8++);
while ( v8 != (unsigned int *)v9 );
result = 0;
}
}
return result;
}

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

if ( argc <= 4 )
{
puts("ERROR: Invalid number of arguments");
printf("USAGE: %s <count> <start> <step> <swaps>\n", *argv);
result = 1;
}
else
{
v3 = atoi(argv[1]);
v4 = atoi(argv[2]);
v5 = atoi(argv[3]);
v6 = atoi(argv[4]);
v7 = func8(v3, v4, v5, v6);
if ( v3 <= 0 )
{
result = 0;
}
else
{
v8 = (unsigned int *)v7;
v9 = v7 + 4LL * (unsigned int)(v3 - 1) + 4;
do
printf("%d\n", *v8++);
while ( v8 != (unsigned int *)v9 );
result = 0;
}
}
return result;
}

original_code:
int main(int argc, char *argv[]) {
    if(argc < 5) {
        printf("ERROR:  Invalid number of arguments\n");
        printf("USAGE:  %s <count> <start> <step> <swaps>\n", argv[0]);
        return 1;
    }
    int count = atoi(argv[1]);
    int start = atoi(argv[2]);
    int step = atoi(argv[3]);
    int swaps = atoi(argv[4]);
    int *ints;
    ints = genInts(count, start, step, swaps);
    int j;
    for(j = 0; j < count; j++) {
        printf("%d\n",ints[j]);
    }
    return 0;
}

variable_types:
ints
int *


rule

repo: dpzmick/cells

original_code:
void rule(int rule, char* input, int length, char* output) {
    int left, right, above, left_i, right_i;

#pragma omp for
    for (int i = 0; i < length; i++) {
        left_i = i - 1;
        right_i = i + 1;
        if (left_i < 0) { left = 0; }
        else { left = input[left_i]; }
        if (right_i > length - 1) { right = 0; }
        else { right = input[right_i]; }
        above = input[i];
        switch(left*100 + above*10 + right){
            case 111: output[i] = (rule >> 7) & 1; break;
            case 110: output[i] = (rule >> 6) & 1; break;
            case 101: output[i] = (rule >> 5) & 1; break;
            case 100: output[i] = (rule >> 4) & 1; break;
            case 11: output[i] = (rule >> 3) & 1; break;
            case 10: output[i] = (rule >> 2) & 1; break;
            case 1: output[i] = (rule >> 1) & 1; break;
            case 0: output[i] = (rule >> 0) & 1; break;
            default: output[i] = 0;break;
        }
    }
    return;
}

canonical_original_code:
void rule(int rule, char *input, int length, char *output) {
    int left; int right; int above; int left_i; int right_i;

#pragma omp for
    for (int i = 0; i < length; i++) {
        left_i = i - 1;
        right_i = i + 1;
        if (left_i < 0) { left = 0; }
        else { left = input[left_i]; }
        if (right_i > length - 1) { right = 0; }
        else { right = input[right_i]; }
        above = input[i];
        switch(left*100 + above*10 + right){
            case 111: output[i] = (rule >> 7) & 1; break;
            case 110: output[i] = (rule >> 6) & 1; break;
            case 101: output[i] = (rule >> 5) & 1; break;
            case 100: output[i] = (rule >> 4) & 1; break;
            case 11: output[i] = (rule >> 3) & 1; break;
            case 10: output[i] = (rule >> 2) & 1; break;
            case 1: output[i] = (rule >> 1) & 1; break;
            case 0: output[i] = (rule >> 0) & 1; break;
            default: output[i] = 0;break;
        }
    }
    return;
}

variable_types: rule int

variable_types:
input
char *

variable_types: length int

variable_types:
output
char *

variable_types: left int

variable_types: right int

variable_types: above int

variable_types: i int


usage

decompiled_code:
void __noreturn usage()
{
puts("Usage: cells r l t");
puts("r - base-10 rule to use");
puts("l - length of row");
puts("t - timesteps to simulate");
exit(0);
}

canonical_decompiled_code:
void __noreturn func10()
{
puts("Usage: cells r l t");
puts("r - base-10 rule to use");
puts("l - length of row");
puts("t - timesteps to simulate");
exit(0);
}

original_code:
void usage() {
    printf("Usage: cells r l t\n");
    printf("r - base-10 rule to use\n");
    printf("l - length of row\n");
    printf("t - timesteps to simulate\n");
    exit(0);
}


repo: dr-walfeld/GSA

original_code:
int alignment_add_operation (alignment* a, char operation)
{
  if (a->editlength > 0 && a->edits[a->editlength-1]->operation == operation)
  {
    a->edits[a->editlength-1]->stretch++;
  }
  else if (a->editlength == 0 || a->edits[a->editlength-1]->operation != operation)
  {
    if (a->editlength == a->maxlen)
      return 1;
    a->edits[a->editlength] = multiedit_new (operation);
    a->editlength++;
  }
  a->length++;
  return 0;
}

canonical_original_code:
int alignment_add_operation(struct alignmentStruct *a, char operation)
{
  if (a->editlength > 0 && a->edits[a->editlength-1]->operation == operation)
  {
    a->edits[a->editlength-1]->stretch++;
  }
  else if (a->editlength == 0 || a->edits[a->editlength-1]->operation != operation)
  {
    if (a->editlength == a->maxlen)
      return 1;
    a->edits[a->editlength] = multiedit_new (operation);
    a->editlength++;
  }
  a->length++;
  return 0;
}

variable_types: struct alignmentStruct { char *s1; int len1; char *s2; int len2; int firstindex1; int lastindex1; int firstindex2; int lastindex2; struct multieditStruct { int stretch; char operation; } **edits; int editlength; int length; int maxlen; } *

variable_types: operation char

user_defined_types: struct alignmentStruct { char *s1; int len1; char *s2; int len2; int firstindex1; int lastindex1; int firstindex2; int lastindex2; struct multieditStruct **edits; int editlength; int length; int maxlen; }


decompiled_code:
__int64 __fastcall alignment_add_operations(__int64 a1, char a2, int a3)
{
int v4; // ebx
__int64 result; // rax

if ( a3 <= 0 )
return 0LL;
v4 = 0;
do
{
result = alignment_add_operation(a1, a2);
++v4;
}
while ( a3 > v4 && !(_DWORD)result );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, char a2, int a3)
{
int v4; // ebx
__int64 result; // rax

if ( a3 <= 0 )
return 0LL;
v4 = 0;
do
{
result = func0(a1, a2);
++v4;
}
while ( a3 > v4 && !(_DWORD)result );
return result;
}

original_code:
int alignment_add_operations (alignment *a, char operation, int length)
{
  int i;
  int s = 0;
  for (i = 0; i < length && s == 0; i++)
  {
    s += alignment_add_operation (a, operation);
  }
  return s;
}

canonical_original_code:
int alignment_add_operations(struct alignmentStruct *a, char operation, int length)
{
  int i;
  int s = 0;
  for (i = 0; i < length && s == 0; i++)
  {
    s += alignment_add_operation (a, operation);
  }
  return s;
}

variable_types: s int

user_defined_types: struct multieditStruct { int stretch; char operation; }


decompiled_code:
__int64 __fastcall alignment_add_deletion(__int64 a1)
{
return alignment_add_operation(a1, 68);
}

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

original_code:
int alignment_add_deletion (alignment* a)
{
  return alignment_add_operation (a, 'D');
}

canonical_original_code:
int alignment_add_deletion(struct alignmentStruct *a)
{
  return alignment_add_operation (a, 'D');
}


decompiled_code:
__int64 __fastcall alignment_add_deletions(__int64 a1, int a2)
{
return alignment_add_operations(a1, 68, a2);
}

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

original_code:
int alignment_add_deletions (alignment* a, int length)
{
  return alignment_add_operations (a, 'D', length);
}

canonical_original_code:
int alignment_add_deletions(struct alignmentStruct *a, int length)
{
  return alignment_add_operations (a, 'D', length);
}


decompiled_code:
__int64 __fastcall alignment_add_insertion(__int64 a1)
{
return alignment_add_operation(a1, 73);
}

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

original_code:
int alignment_add_insertion (alignment* a)
{
  return alignment_add_operation (a, 'I');
}

canonical_original_code:
int alignment_add_insertion(struct alignmentStruct *a)
{
  return alignment_add_operation (a, 'I');
}


decompiled_code:
__int64 __fastcall alignment_add_insertions(__int64 a1, int a2)
{
return alignment_add_operations(a1, 73, a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
return func1(a1, 73, a2);
}

original_code:
int alignment_add_insertions (alignment* a, int length)
{
  return alignment_add_operations (a, 'I', length);
}

canonical_original_code:
int alignment_add_insertions(struct alignmentStruct *a, int length)
{
  return alignment_add_operations (a, 'I', length);
}


decompiled_code:
__int64 __fastcall alignment_add_replacement(__int64 a1)
{
return alignment_add_operation(a1, 82);
}

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

original_code:
int alignment_add_replacement (alignment* a)
{
  return alignment_add_operation (a, 'R');
}

canonical_original_code:
int alignment_add_replacement(struct alignmentStruct *a)
{
  return alignment_add_operation (a, 'R');
}


decompiled_code:
__int64 __fastcall alignment_add_replacements(__int64 a1, int a2)
{
return alignment_add_operations(a1, 82, a2);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
return func1(a1, 82, a2);
}

original_code:
int alignment_add_replacements (alignment* a, int length)
{
  return alignment_add_operations (a, 'R', length);
}

canonical_original_code:
int alignment_add_replacements(struct alignmentStruct *a, int length)
{
  return alignment_add_operations (a, 'R', length);
}


decompiled_code:
__int64 __fastcall alignment_reverse(__int64 a1)
{
__int64 result; // rax
int v2; // er9
__int64 v3; // rsi
__int64 *v4; // rcx
__int64 v5; // r8

result = *(unsigned int *)(a1 + 56);
v2 = *(_DWORD *)(a1 + 56) / 2;
if ( (int)result > 1 )
{
result = 0LL;
do
{
v3 = *(_QWORD *)(a1 + 48);
v4 = (__int64 *)(v3 + 8 * result);
v5 = *v4;
*v4 = *(_QWORD *)(v3 + 8LL * (*(_DWORD *)(a1 + 56) + ~(_DWORD)result));
*(_QWORD *)(*(_QWORD *)(a1 + 48) + 8LL * (*(_DWORD *)(a1 + 56) + ~(_DWORD)result++)) = v5;
}
while ( v2 > (int)result );
}
return result;
}

original_code:
void alignment_reverse(alignment* a)
{
  int half = a->editlength/2-1;
  int i;
  multiedit* temp;
  for (i = 0; i <= half; i++)
  {
    temp = a->edits[i];
    a->edits[i] = a->edits[a->editlength-1-i];
    a->edits[a->editlength-1-i] = temp;
  }
}

canonical_original_code:
void alignment_reverse(struct alignmentStruct *a)
{
  int half = a->editlength/2-1;
  int i;
  struct multieditStruct *temp;
  for (i = 0; i <= half; i++)
  {
    temp = a->edits[i];
    a->edits[i] = a->edits[a->editlength-1-i];
    a->edits[a->editlength-1-i] = temp;
  }
}

variable_types: half int

variable_types: struct multieditStruct { int stretch; char operation; } *


original_code:
int alignment_evalscore (alignment* a, scorematrix* sm)
{
  int score = 0;
  int i,j;
  int index1 = a->firstindex1;
  int index2 = a->firstindex2;
  multiedit* me = ((void *)0);
  int gap = get_score (sm, '-', '-');
  for (i = 0; i < a->editlength; i++)
  {
    me = a->edits[i];
    for (j = 0; j < me->stretch; j++)
    {
      if (me->operation == 'R')
      {
        if (a->s1[index1] == '\0' || a->s2[index2] == '\0')
          return -1;
        score += get_score (sm, a->s1[index1], a->s2[index2]);
        index1++;
        index2++;
      }
      else if (me->operation == 'I')
      {
        if (a->s2[index2] == '\0')
          return -1;
        score += gap;
        index2++;
      }
      else
      {
        if (a->s1[index1] == '\0')
          return -1;
        score += gap;
        index1++;
      }
    }
  }
  return score;
}

canonical_original_code:
int alignment_evalscore(struct alignmentStruct *a, struct scorematrixStruct *sm)
{
  int score = 0;
  int i; int j;
  int index1 = a->firstindex1;
  int index2 = a->firstindex2;
  struct multieditStruct *me = ((void *)0);
  int gap = get_score (sm, '-', '-');
  for (i = 0; i < a->editlength; i++)
  {
    me = a->edits[i];
    for (j = 0; j < me->stretch; j++)
    {
      if (me->operation == 'R')
      {
        if (a->s1[index1] == '\0' || a->s2[index2] == '\0')
          return -1;
        score += get_score (sm, a->s1[index1], a->s2[index2]);
        index1++;
        index2++;
      }
      else if (me->operation == 'I')
      {
        if (a->s2[index2] == '\0')
          return -1;
        score += gap;
        index2++;
      }
      else
      {
        if (a->s1[index1] == '\0')
          return -1;
        score += gap;
        index1++;
      }
    }
  }
  return score;
}

variable_types: struct scorematrixStruct { int **matrix; int indel; } *

variable_types: score int

variable_types: j int

variable_types: gap int


firstEDRcolumn

decompiled_code:
__int64 __fastcall firstEDRcolumn(_DWORD *a1, _DWORD *a2, __int64 a3, __int64 a4, int a5, __int64 (__fastcall *a6)(__int64, __int64))
{
__int64 result; // rax
int v8; // ecx

*a1 = 0;
*a2 = 0;
result = a6(45LL, 120LL);
if ( a5 > 0 )
{
v8 = result;
result = 1LL;
do
{
a1[result] = a1[result - 1] + v8;
a2[result++] = 0;
}
while ( result != a5 + 1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1, _DWORD *a2, __int64 a3, __int64 a4, int a5, __int64 (__fastcall *a6)(__int64, __int64))
{
__int64 result; // rax
int v8; // ecx

*a1 = 0;
*a2 = 0;
result = a6(45LL, 120LL);
if ( a5 > 0 )
{
v8 = result;
result = 1LL;
do
{
a1[result] = a1[result - 1] + v8;
a2[result++] = 0;
}
while ( result != a5 + 1 );
}
return result;
}

original_code:
void firstEDRcolumn(int* E, int* R, char* u, int ui, int p, int (*costFunc)(char,char))
{
  E[0] = 0;
  R[0] = 0;
  int gap = costFunc('-','x');
  int i;
  for (i = 1; i <= p; i++)
  {
    E[i] = E[i-1] + gap;
    R[i] = 0;
  }
}

canonical_original_code:
void firstEDRcolumn(int *E, int *R, char *u, int ui, int p, int (*costFunc)(char, char))
{
  E[0] = 0;
  R[0] = 0;
  int gap = costFunc('-','x');
  int i;
  for (i = 1; i <= p; i++)
  {
    E[i] = E[i-1] + gap;
    R[i] = 0;
  }
}

variable_types:
E
int *

variable_types:
R
int *

variable_types:
u
char *

variable_types: ui int

variable_types: p int

variable_types:
costFunc
int (*)(char, char)


nextEDRcolumn

original_code:
void nextEDRcolumn(int* E, int* R, int j0, char* u, int ui, int p, char vci, int j, int (*costFunc)(char,char))
{
  int a,b,c,temp,tempR,cost;
  int newR = 0;
  int in = costFunc('x','-');
  int del = costFunc('-','x');
  temp = E[0];
  tempR = R[0];
  E[0] = E[0] + in;
  int i;
  for (i = 1; i <= p; i++)
  {
    a = temp + costFunc(u[i+ui-2], vci);
    b = E[i] + in;
    c = E[i-1] + del;
    cost = ((a < ((b < c) ? b : c)) ? a : ((b < c) ? b : c));
    if (j == j0)
    {
      newR = i;
    }
    else if (j > j0)
    {
      if (cost == a)
        newR = tempR;
      else if (cost == c)
        newR = R[i-1];
      else
        newR = R[i];
    }
    tempR = R[i];
    R[i] = newR;
    temp = E[i];
    E[i] = cost;
  }
}

canonical_original_code:
void nextEDRcolumn(int *E, int *R, int j0, char *u, int ui, int p, char vci, int j, int (*costFunc)(char, char))
{
  int a; int b; int c; int temp; int tempR; int cost;
  int newR = 0;
  int in = costFunc('x','-');
  int del = costFunc('-','x');
  temp = E[0];
  tempR = R[0];
  E[0] = E[0] + in;
  int i;
  for (i = 1; i <= p; i++)
  {
    a = temp + costFunc(u[i+ui-2], vci);
    b = E[i] + in;
    c = E[i-1] + del;
    cost = ((a < ((b < c) ? b : c)) ? a : ((b < c) ? b : c));
    if (j == j0)
    {
      newR = i;
    }
    else if (j > j0)
    {
      if (cost == a)
        newR = tempR;
      else if (cost == c)
        newR = R[i-1];
      else
        newR = R[i];
    }
    tempR = R[i];
    R[i] = newR;
    temp = E[i];
    E[i] = cost;
  }
}

variable_types: vci char

variable_types: a int

variable_types: b int

variable_types: c int

variable_types: temp int

variable_types: tempR int

variable_types: cost int

variable_types: newR int

variable_types: in int

variable_types: del int


evaluateallcolumns

decompiled_code:
__int64 __fastcall evaluateallcolumns(int *a1, unsigned int *a2, int a3, __int64 a4, unsigned int a5, int a6, __int64 a7, int a8, int a9, __int64 (__fastcall *a10)(__int64, __int64))
{
__int64 result; // rax
__int64 v13; // rbx

result = firstEDRcolumn(a1, a2, a4, a5, a6, a10);
if ( a9 > 0 )
{
v13 = 1LL;
do
{
result = nextEDRcolumn(a1, a2, a3, a4, a5, a6, *(_BYTE *)(a7 + a8 + v13 - 2), v13, a10);
++v13;
}
while ( a9 >= (int)v13 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int *a1, unsigned int *a2, int a3, __int64 a4, unsigned int a5, int a6, __int64 a7, int a8, int a9, __int64 (__fastcall *a10)(__int64, __int64))
{
__int64 result; // rax
__int64 v13; // rbx

result = func1(a1, a2, a4, a5, a6, a10);
if ( a9 > 0 )
{
v13 = 1LL;
do
{
result = func2(a1, a2, a3, a4, a5, a6, *(_BYTE *)(a7 + a8 + v13 - 2), v13, a10);
++v13;
}
while ( a9 >= (int)v13 );
}
return result;
}

original_code:
void evaluateallcolumns(int* E, int* R, int j0, char* u, int ui, int p, char* v, int vj, int q, int (*costFunc)(char,char))
{
  firstEDRcolumn(E,R,u,ui,p,costFunc);
  int j;
  for (j = 1; j <= q; j++)
  {
    nextEDRcolumn(E,R,j0,u,ui,p,v[vj+j-2],j,costFunc);
  }
}

canonical_original_code:
void evaluateallcolumns(int *E, int *R, int j0, char *u, int ui, int p, char *v, int vj, int q, int (*costFunc)(char, char))
{
  firstEDRcolumn(E,R,u,ui,p,costFunc);
  int j;
  for (j = 1; j <= q; j++)
  {
    nextEDRcolumn(E,R,j0,u,ui,p,v[vj+j-2],j,costFunc);
  }
}

variable_types:
v
char *

variable_types: vj int

variable_types: q int

variable_types: j int


evaluatecrosspoints

decompiled_code:
__int64 __fastcall evaluatecrosspoints(int *a1, unsigned int *a2, __int64 a3, __int64 a4, unsigned int a5, int a6, __int64 a7, int a8, int a9, __int64 (__fastcall *a10)(__int64, __int64))
{
unsigned int v10; // er13
int v15; // ebp
unsigned int v17; // edi
int v18; // [rsp+8h] [rbp-50h]
int v19; // [rsp+1Ch] [rbp-3Ch]

v10 = 0;
if ( a9 > 1 )
{
v15 = a9 / 2;
v18 = a4;
evaluateallcolumns(a1, a2, a9 / 2, a4, a5, a6, a7, a8, a9, a10);
v19 = a6;
v17 = a2[a6];
v10 = a1[a6];
*(_DWORD *)(a3 + 4LL * (a8 + v15) - 4) = v17 + a5 - 1;
evaluatecrosspoints((_DWORD)a1, (_DWORD)a2, a3, v18, a5, v17, a7, a8, a9 / 2, (__int64)a10);
evaluatecrosspoints((_DWORD)a1, (_DWORD)a2, a3, v18, v17 + a5, v19 - v17, a7, a8 + v15, a9 - v15, (__int64)a10);
}
return v10;
}

original_code:
int evaluatecrosspoints(int* E, int* R, int* C, char* u, int i, int p, char* v, int j, int q, int (*costFunc)(char,char))
{
  int j0,i0;
  int cost = 0;
  if (q >= 2)
  {
    j0 = q/2;
    evaluateallcolumns(E,R,j0,u,i,p,v,j,q,costFunc);
    i0 = R[p];
    cost = E[p];
    C[j+j0-1] = i+i0-1;
    evaluatecrosspoints(E,R,C,u,i,i0,v,j,j0,costFunc);
    evaluatecrosspoints(E,R,C,u,i+i0,p-i0,v,j+j0,q-j0,costFunc);
  }
  return cost;
}

canonical_original_code:
int evaluatecrosspoints(int *E, int *R, int *C, char *u, int i, int p, char *v, int j, int q, int (*costFunc)(char, char))
{
  int j0; int i0;
  int cost = 0;
  if (q >= 2)
  {
    j0 = q/2;
    evaluateallcolumns(E,R,j0,u,i,p,v,j,q,costFunc);
    i0 = R[p];
    cost = E[p];
    C[j+j0-1] = i+i0-1;
    evaluatecrosspoints(E,R,C,u,i,i0,v,j,j0,costFunc);
    evaluatecrosspoints(E,R,C,u,i+i0,p-i0,v,j+j0,q-j0,costFunc);
  }
  return cost;
}

variable_types:
E
int *

variable_types:
R
int *

variable_types:
C
int *

variable_types:
u
char *

variable_types: i int