original_code:
void remove_job(int sig, siginfo_t *sip, void* nosed) {
    pid_t pid;
    struct pid_node* p, *temp;
    int found;
    joblist j, pre_j;
    if (sip->si_code != CLD_EXITED)
        return;
    pid = sip->_sifields._kill.si_pid;
    j = jlist;
    found = 0;
    while (j != ((void *)0)) {
        if (j->plist == ((void *)0))
            break;
        p = j->plist;
        if (p->pid == pid) {
            j->plist = j->plist->next;
            free(p);
            found = 1;
        } else {
            while (p->next != ((void *)0)) {
                if (p->next->pid == pid) {
                    temp = p->next;
                    p->next = temp->next;
                    free(temp);
                    found = 1;
                    break;
                }
                p = p->next;
            }
        }
        if (found) break;
        j = j->next;
    }
    j = jlist;
    while (j != ((void *)0)) {
        if (j->plist == ((void *)0))
            j->state = -1;
        j = j->next;
    }
}

canonical_original_code:
void remove_job(int sig, struct siginfo_t *sip, void *nosed) {
    int pid;
    struct pid_node *p; struct pid_node *temp;
    int found;
    struct jobs_node *j; struct jobs_node *pre_j;
    if (sip->si_code != CLD_EXITED)
        return;
    pid = sip->_sifields._kill.si_pid;
    j = jlist;
    found = 0;
    while (j != ((void *)0)) {
        if (j->plist == ((void *)0))
            break;
        p = j->plist;
        if (p->pid == pid) {
            j->plist = j->plist->next;
            free(p);
            found = 1;
        } else {
            while (p->next != ((void *)0)) {
                if (p->next->pid == pid) {
                    temp = p->next;
                    p->next = temp->next;
                    free(temp);
                    found = 1;
                    break;
                }
                p = p->next;
            }
        }
        if (found) break;
        j = j->next;
    }
    j = jlist;
    while (j != ((void *)0)) {
        if (j->plist == ((void *)0))
            j->state = -1;
        j = j->next;
    }
}

variable_types: sig int

variable_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *

variable_types:
nosed
void *

variable_types: pid int

variable_types: found int


decompiled_code:
void clear_plist()
{
_QWORD *i; // rdi

for ( i = plist; plist; i = plist )
{
plist = (void *)i[1];
free(i);
}
}

canonical_decompiled_code:
void func5()
{
_QWORD *i; // rdi

for ( i = plist; plist; i = plist )
{
plist = (void *)i[1];
free(i);
}
}

original_code:
void clear_plist() {
    struct pid_node* p;
    while (plist != ((void *)0)) {
        p = plist;
        plist = plist->next;
        free(p);
    }
}

canonical_original_code:
void clear_plist() {
    struct pid_node *p;
    while (plist != ((void *)0)) {
        p = plist;
        plist = plist->next;
        free(p);
    }
}

variable_types: struct pid_node { int pid; struct pid_node *next; } *

return_type: void


decompiled_code:
void sigstp_handler()
{
__pid_t *v0; // rbx
__int64 v1; // rbx
__int64 v2; // rax
char *v3; // rbp
size_t v4; // rax
const char *v5; // rax

v0 = (__pid_t *)plist;
if ( plist )
{
do
{
kill(*v0, 19);
v0 = (__pid_t *)*((_QWORD *)v0 + 1);
}
while ( v0 );
v1 = jlist;
if ( jlist )
{
while ( 1 )
{
v2 = *(_QWORD *)v1;
if ( *(_QWORD *)v1 )
break;
LABEL_12:
v1 = *(_QWORD *)(v1 + 24);
if ( !v1 )
goto LABEL_13;
}
while ( *(_DWORD *)v2 != *(_DWORD *)plist )
{
v2 = *(_QWORD *)(v2 + 8);
if ( !v2 )
goto LABEL_12;
}
}
else
{
LABEL_13:
v1 = add_job((int *)plist, cmd_input);
}
v3 = *(char **)(v1 + 8);
*(_DWORD *)(v1 + 16) = 0;
v4 = strlen(v3);
v5 = (const char *)realloc(v3, v4 + 1);
*(_QWORD *)(v1 + 8) = v5;
*(_WORD *)&v5[strlen(v5)] = 38;
if ( jlist && v1 != jlist )
{
while ( 1 )
;
}
printf("[%d]\tStopped\t\t%s\n", 1LL, *(const char **)(v1 + 8));
clear_plist();
}
}

canonical_decompiled_code:
void func6()
{
__pid_t *v0; // rbx
__int64 v1; // rbx
__int64 v2; // rax
char *v3; // rbp
size_t v4; // rax
const char *v5; // rax

v0 = (__pid_t *)plist;
if ( plist )
{
do
{
kill(*v0, 19);
v0 = (__pid_t *)*((_QWORD *)v0 + 1);
}
while ( v0 );
v1 = jlist;
if ( jlist )
{
while ( 1 )
{
v2 = *(_QWORD *)v1;
if ( *(_QWORD *)v1 )
break;
LABEL_12:
v1 = *(_QWORD *)(v1 + 24);
if ( !v1 )
goto LABEL_13;
}
while ( *(_DWORD *)v2 != *(_DWORD *)plist )
{
v2 = *(_QWORD *)(v2 + 8);
if ( !v2 )
goto LABEL_12;
}
}
else
{
LABEL_13:
v1 = func3((int *)plist, cmd_input);
}
v3 = *(char **)(v1 + 8);
*(_DWORD *)(v1 + 16) = 0;
v4 = strlen(v3);
v5 = (const char *)realloc(v3, v4 + 1);
*(_QWORD *)(v1 + 8) = v5;
*(_WORD *)&v5[strlen(v5)] = 38;
if ( jlist && v1 != jlist )
{
while ( 1 )
;
}
printf("[%d]\tStopped\t\t%s\n", 1LL, *(const char **)(v1 + 8));
func5();
}
}

original_code:
void sigstp_handler() {
    struct pid_node* p;
    joblist j, job;
    int found = 0, jid;
    if (plist == ((void *)0))
        return;
    for (p = plist; p != ((void *)0); p = p->next)
        kill(p->pid, 19);
    job = ((void *)0);
    j = jlist;
    while (j != ((void *)0)) {
        for (p = j->plist; p != ((void *)0); p = p->next)
            if (p->pid == plist->pid) {
                found = 1;
                break;
            }
        if (found) {
            job = j;
            break;
        }
        j = j->next;
    }
    if (job == ((void *)0))
        job = add_job(plist, cmd_input);
    job->state = 0;
    job->cmd = realloc(job->cmd, (strlen(job->cmd) + 1) * sizeof(char));
    strcat(job->cmd, "&");
    j = jlist;
    jid = 1;
    while (j != ((void *)0) && j != job) jid++;
    printf("[%d]\tStopped\t\t%s\n", jid, job->cmd);
    clear_plist();
}

canonical_original_code:
void sigstp_handler() {
    struct pid_node *p;
    struct jobs_node *j; struct jobs_node *job;
    int found = 0; int jid;
    if (plist == ((void *)0))
        return;
    for (p = plist; p != ((void *)0); p = p->next)
        kill(p->pid, 19);
    job = ((void *)0);
    j = jlist;
    while (j != ((void *)0)) {
        for (p = j->plist; p != ((void *)0); p = p->next)
            if (p->pid == plist->pid) {
                found = 1;
                break;
            }
        if (found) {
            job = j;
            break;
        }
        j = j->next;
    }
    if (job == ((void *)0))
        job = add_job(plist, cmd_input);
    job->state = 0;
    job->cmd = realloc(job->cmd, (strlen(job->cmd) + 1) * sizeof(char));
    strcat(job->cmd, "&");
    j = jlist;
    jid = 1;
    while (j != ((void *)0) && j != job) jid++;
    printf("[%d]\tStopped\t\t%s\n", jid, job->cmd);
    clear_plist();
}

variable_types: struct jobs_node { struct pid_node { int pid; struct pid_node *next; } *plist; char *cmd; int state; struct jobs_node *next; } *

variable_types: jid int

user_defined_types: struct jobs_node { struct pid_node *plist; char *cmd; int state; struct jobs_node *next; }


fg

decompiled_code:
int __fastcall fg(unsigned int a1)
{
__int64 v1; // rbx
int i; // eax
int result; // eax
_QWORD *v4; // rax
const char *v5; // rbp
char *v6; // rbp
size_t v7; // rax
const char *v8; // rax
__pid_t *v9; // rbx
_QWORD *v10; // rbx
int stat_loc[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = jlist;
if ( !jlist )
return printf("fg: %d: There is no this task!\n", a1);
if ( a1 != 1 )
{
for ( i = 1; i != a1; ++i )
{
v1 = *(_QWORD *)(v1 + 24);
if ( !v1 )
return printf("fg: %d: There is no this task!\n", a1);
}
}
v4 = plistdup(*(int **)v1);
v5 = *(const char **)(v1 + 8);
*(_DWORD *)(v1 + 16) = 1;
plist = v4;
v5[strlen(v5) - 1] = 0;
v6 = *(char **)(v1 + 8);
v7 = strlen(v6);
v8 = (const char *)realloc(v6, v7 - 1);
*(_QWORD *)(v1 + 8) = v8;
result = puts(v8);
v9 = (__pid_t *)plist;
if ( plist )
{
do
{
result = kill(*v9, 18);
v9 = (__pid_t *)*((_QWORD *)v9 + 1);
}
while ( v9 );
v10 = plist;
if ( plist )
{
do
{
result = waitpid(*(_DWORD *)v10, stat_loc, 2);
v10 = (_QWORD *)v10[1];
}
while ( v10 );
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(unsigned int a1)
{
__int64 v1; // rbx
int i; // eax
int result; // eax
_QWORD *v4; // rax
const char *v5; // rbp
char *v6; // rbp
size_t v7; // rax
const char *v8; // rax
__pid_t *v9; // rbx
_QWORD *v10; // rbx
int stat_loc[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = jlist;
if ( !jlist )
return printf("fg: %d: There is no this task!\n", a1);
if ( a1 != 1 )
{
for ( i = 1; i != a1; ++i )
{
v1 = *(_QWORD *)(v1 + 24);
if ( !v1 )
return printf("fg: %d: There is no this task!\n", a1);
}
}
v4 = plistdup(*(int **)v1);
v5 = *(const char **)(v1 + 8);
*(_DWORD *)(v1 + 16) = 1;
plist = v4;
v5[strlen(v5) - 1] = 0;
v6 = *(char **)(v1 + 8);
v7 = strlen(v6);
v8 = (const char *)realloc(v6, v7 - 1);
*(_QWORD *)(v1 + 8) = v8;
result = puts(v8);
v9 = (__pid_t *)plist;
if ( plist )
{
do
{
result = kill(*v9, 18);
v9 = (__pid_t *)*((_QWORD *)v9 + 1);
}
while ( v9 );
v10 = plist;
if ( plist )
{
do
{
result = waitpid(*(_DWORD *)v10, stat_loc, 2);
v10 = (_QWORD *)v10[1];
}
while ( v10 );
}
}
return result;
}

original_code:
void fg(int jid) {
    joblist j, job;
    struct pid_node* p, h;
    int count, found = 0;
    for (count = 1, j = jlist; j != ((void *)0); count++, j = j->next) {
        if (count == jid) {
            job = j;
            found = 1;
            break;
        }
    }
    if (!found)
        printf("fg: %d: There is no this task!\n", jid);
    else {
        plist = plistdup(job->plist);
        job->state = 1;
        job->cmd[strlen(job->cmd) - 1] = '\0';
        job->cmd = realloc(job->cmd, (strlen(job->cmd) - 1) * sizeof(char));
        printf("%s\n", job->cmd);
        for (p = plist; p != ((void *)0); p = p->next) {
            kill(p->pid, 18);
        }
        for (p = plist; p != ((void *)0); p = p->next) {
            int status;
            waitpid(p->pid, &status, 2);
        }
    }
}

canonical_original_code:
void fg(int jid) {
    struct jobs_node *j; struct jobs_node *job;
    struct pid_node *p; struct pid_node h;
    int count; int found = 0;
    for (count = 1, j = jlist; j != ((void *)0); count++, j = j->next) {
        if (count == jid) {
            job = j;
            found = 1;
            break;
        }
    }
    if (!found)
        printf("fg: %d: There is no this task!\n", jid);
    else {
        plist = plistdup(job->plist);
        job->state = 1;
        job->cmd[strlen(job->cmd) - 1] = '\0';
        job->cmd = realloc(job->cmd, (strlen(job->cmd) - 1) * sizeof(char));
        printf("%s\n", job->cmd);
        for (p = plist; p != ((void *)0); p = p->next) {
            kill(p->pid, 18);
        }
        for (p = plist; p != ((void *)0); p = p->next) {
            int status;
            waitpid(p->pid, &status, 2);
        }
    }
}

variable_types: struct pid_node { int pid; struct pid_node *next; }

variable_types: count int

variable_types: status int


bg

decompiled_code:
int __fastcall bg(unsigned int a1)
{
__int64 v1; // rbx
int i; // eax
int result; // eax
__int64 j; // rbx

v1 = jlist;
if ( !jlist )
return printf("bg: %d: Theres is no this task!\n", a1);
if ( a1 != 1 )
{
for ( i = 1; i != a1; ++i )
{
v1 = *(_QWORD *)(v1 + 24);
if ( !v1 )
return printf("bg: %d: Theres is no this task!\n", a1);
}
}
*(_DWORD *)(v1 + 16) = 1;
result = printf("[%d]\t%s\n", a1, *(const char **)(v1 + 8));
for ( j = *(_QWORD *)v1; j; j = *(_QWORD *)(j + 8) )
result = kill(*(_DWORD *)j, 18);
return result;
}

canonical_decompiled_code:
int __fastcall func8(unsigned int a1)
{
__int64 v1; // rbx
int i; // eax
int result; // eax
__int64 j; // rbx

v1 = jlist;
if ( !jlist )
return printf("bg: %d: Theres is no this task!\n", a1);
if ( a1 != 1 )
{
for ( i = 1; i != a1; ++i )
{
v1 = *(_QWORD *)(v1 + 24);
if ( !v1 )
return printf("bg: %d: Theres is no this task!\n", a1);
}
}
*(_DWORD *)(v1 + 16) = 1;
result = printf("[%d]\t%s\n", a1, *(const char **)(v1 + 8));
for ( j = *(_QWORD *)v1; j; j = *(_QWORD *)(j + 8) )
result = kill(*(_DWORD *)j, 18);
return result;
}

original_code:
void bg(int jid) {
    joblist j, job;
    struct pid_node* p;
    int count, found = 0;
    for (count = 1, j = jlist; j != ((void *)0); count++, j = j->next) {
        if (count == jid) {
            job = j;
            found = 1;
            break;
        }
    }
    if (!found)
        printf("bg: %d: Theres is no this task!\n", jid);
    else {
        job->state = 1;
        printf("[%d]\t%s\n", jid, job->cmd);
        for (p = job->plist; p != ((void *)0); p = p->next) {
            int status;
            kill(p->pid, 18);
        }
    }
}

canonical_original_code:
void bg(int jid) {
    struct jobs_node *j; struct jobs_node *job;
    struct pid_node *p;
    int count; int found = 0;
    for (count = 1, j = jlist; j != ((void *)0); count++, j = j->next) {
        if (count == jid) {
            job = j;
            found = 1;
            break;
        }
    }
    if (!found)
        printf("bg: %d: Theres is no this task!\n", jid);
    else {
        job->state = 1;
        printf("[%d]\t%s\n", jid, job->cmd);
        for (p = job->plist; p != ((void *)0); p = p->next) {
            int status;
            kill(p->pid, 18);
        }
    }
}

user_defined_types: struct pid_node { int pid; struct pid_node *next; }


pwd

decompiled_code:
int pwd()
{
char v1[120]; // [rsp+0h] [rbp-78h] BYREF

getcwd(v1, 0x64uLL);
return puts(v1);
}

canonical_decompiled_code:
int func9()
{
char v1[120]; // [rsp+0h] [rbp-78h] BYREF

getcwd(v1, 0x64uLL);
return puts(v1);
}

original_code:
void pwd()
{
    char curdir[100];
    getcwd(curdir,sizeof(curdir));
    printf("%s\n",curdir);
}

variable_types:
curdir
char [100]


decompiled_code:
_QWORD *init_cmd_list()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

original_code:
cmd_list init_cmd_list() {
    cmd_list node;
    node = malloc(sizeof(struct command_list));
    node->cmd = ((void *)0);
    node->next = ((void *)0);
    return node;
}

canonical_original_code:
struct command_list *init_cmd_list() {
    struct command_list *node;
    node = malloc(sizeof(struct command_list));
    node->cmd = ((void *)0);
    node->next = ((void *)0);
    return node;
}

variable_types: struct command_list { struct simple_cmd { int argc; int append; char **args; char *input; char *output; } *cmd; struct command_list *next; } *

user_defined_types: struct command_list { struct simple_cmd *cmd; struct command_list *next; }


insert

decompiled_code:
__int64 __fastcall insert(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 result; // rax

do
{
v2 = a1;
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
*(_QWORD *)(v2 + 8) = a2;
result = 0LL;
*(_QWORD *)(a2 + 8) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 result; // rax

do
{
v2 = a1;
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
*(_QWORD *)(v2 + 8) = a2;
result = 0LL;
*(_QWORD *)(a2 + 8) = 0LL;
return result;
}

original_code:
int insert(cmd_list head, cmd_list node) {
    cmd_list p = head;
    while (p->next)
 p = p->next;
    p->next = node;
    node->next = ((void *)0);
    return 0;
}

canonical_original_code:
int insert(struct command_list *head, struct command_list *node) {
    struct command_list *p = head;
    while (p->next)
 p = p->next;
    p->next = node;
    node->next = ((void *)0);
    return 0;
}

variable_types:
node
struct command_list *

return_type: int

user_defined_types: struct simple_cmd { int argc; int append; char **args; char *input; char *output; }


decompiled_code:
__int64 __fastcall clear_list(__int64 a1)
{
void **v2; // rbx
void *v3; // rdi
void **v4; // rbp

v2 = *(void ***)(a1 + 8);
while ( v2 )
{
v3 = *v2;
v4 = v2;
v2 = (void **)v2[1];
free(v3);
free(v4);
}
*(_QWORD *)(a1 + 8) = 0LL;
return 0LL;
}

original_code:
int clear_list(cmd_list head) {
    cmd_list h, p;
    command cmd;
    h = head->next;
    while (h != ((void *)0)) {
 p = h;
 cmd = p->cmd;
 h = h->next;
 free(cmd);
 free(p);
    }
    head->next = ((void *)0);
    return 0;
}

canonical_original_code:
int clear_list(struct command_list *head) {
    struct command_list *h; struct command_list *p;
    struct simple_cmd *cmd;
    h = head->next;
    while (h != ((void *)0)) {
 p = h;
 cmd = p->cmd;
 h = h->next;
 free(cmd);
 free(p);
    }
    head->next = ((void *)0);
    return 0;
}

variable_types: struct simple_cmd { int argc; int append; char **args; char *input; char *output; } *


length

decompiled_code:
__int64 __fastcall length(__int64 a1)
{
__int64 v1; // rax
unsigned int i; // er8

v1 = *(_QWORD *)(a1 + 8);
for ( i = 0; v1; ++i )
v1 = *(_QWORD *)(v1 + 8);
return i;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rax
unsigned int i; // er8

v1 = *(_QWORD *)(a1 + 8);
for ( i = 0; v1; ++i )
v1 = *(_QWORD *)(v1 + 8);
return i;
}

original_code:
int length(cmd_list head) {
    cmd_list p = head;
    int count = 0;
    while (p->next) {
 p = p->next;
 count++;
    }
    return count;
}

canonical_original_code:
int length(struct command_list *head) {
    struct command_list *p = head;
    int count = 0;
    while (p->next) {
 p = p->next;
 count++;
    }
    return count;
}


main

canonical_name: main

repo: popwarfour/HackVtProject

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbp
char *v4; // rbp
void *v5; // rbp
char *v6; // rbp
void *v7; // rbp
char *v8; // rbp

v3 = (void *)gh_build_get_query("greenupapi.appspot.com", "/api/comments", envp);
gh_get_ip("greenupapi.appspot.com");
v4 = (char *)gh_make_request(v3);
puts(v4);
free(v4);
v5 = (void *)gh_build_post_query(
"greenupapi.appspot.com",
4202501LL,
"{\"type\" : \"forum\", \"message\" : \"Have you guys heard about the free cookies on Pearl St and South"
" Winooski? Bring your green bags down there and get one!\"}");
gh_get_ip("greenupapi.appspot.com");
v6 = (char *)gh_make_request(v5);
puts(v6);
free(v6);
v7 = (void *)gh_build_put_query(
"greenupapi.appspot.com",
"api/heatmap",
"[{\"latDegrees\" : 24.53, \"lonDegrees\" : 43.2, \"secondsWorked\" : 120}]");
gh_get_ip("greenupapi.appspot.com");
v8 = (char *)gh_make_request(v7);
puts(v8);
free(v8);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbp
char *v4; // rbp
void *v5; // rbp
char *v6; // rbp
void *v7; // rbp
char *v8; // rbp

v3 = (void *)func8("greenupapi.appspot.com", "/api/comments", envp);
func13("greenupapi.appspot.com");
v4 = (char *)func12(v3);
puts(v4);
free(v4);
v5 = (void *)func9(
"greenupapi.appspot.com",
4202501LL,
"{\"type\" : \"forum\", \"message\" : \"Have you guys heard about the free cookies on Pearl St and South"
" Winooski? Bring your green bags down there and get one!\"}");
func13("greenupapi.appspot.com");
v6 = (char *)func12(v5);
puts(v6);
free(v6);
v7 = (void *)func10(
"greenupapi.appspot.com",
"api/heatmap",
"[{\"latDegrees\" : 24.53, \"lonDegrees\" : 43.2, \"secondsWorked\" : 120}]");
func13("greenupapi.appspot.com");
v8 = (char *)func12(v7);
puts(v8);
free(v8);
return 0;
}

original_code:
int main() {
 char * request;
 char * request2;
 char * request3;
 char * returned_content1;
 char * returned_content2;
 char * returned_content3;
 request = gh_build_get_query("greenupapi.appspot.com","/api/comments");
 returned_content1 = gh_make_request(request,"greenupapi.appspot.com",_gh_get_ip("greenupapi.appspot.com"),80);
 printf("%s\n", returned_content1 );
 free(returned_content1);
 request2 = gh_build_post_query("greenupapi.appspot.com","api/comments", "{\"type\" : \"forum\", \"message\" : \"Have you guys heard about the free cookies on Pearl St and South Winooski? Bring your green bags down there and get one!\"}");
 returned_content2 = gh_make_request(request2,"greenupapi.appspot.com",_gh_get_ip("greenupapi.appspot.com"),80);
 printf("%s\n", returned_content2 );
 free(returned_content2);
 request3 = gh_build_put_query("greenupapi.appspot.com","api/heatmap","[{\"latDegrees\" : 24.53, \"lonDegrees\" : 43.2, \"secondsWorked\" : 120}]");
 returned_content3 = gh_make_request(request3,"greenupapi.appspot.com",_gh_get_ip("greenupapi.appspot.com"),80);
 printf("%s\n", returned_content3 );
 free(returned_content3);
 return 0;
}

canonical_original_code:
int main() {
 char *request;
 char *request2;
 char *request3;
 char *returned_content1;
 char *returned_content2;
 char *returned_content3;
 request = gh_build_get_query("greenupapi.appspot.com","/api/comments");
 returned_content1 = gh_make_request(request,"greenupapi.appspot.com",_gh_get_ip("greenupapi.appspot.com"),80);
 printf("%s\n", returned_content1 );
 free(returned_content1);
 request2 = gh_build_post_query("greenupapi.appspot.com","api/comments", "{\"type\" : \"forum\", \"message\" : \"Have you guys heard about the free cookies on Pearl St and South Winooski? Bring your green bags down there and get one!\"}");
 returned_content2 = gh_make_request(request2,"greenupapi.appspot.com",_gh_get_ip("greenupapi.appspot.com"),80);
 printf("%s\n", returned_content2 );
 free(returned_content2);
 request3 = gh_build_put_query("greenupapi.appspot.com","api/heatmap","[{\"latDegrees\" : 24.53, \"lonDegrees\" : 43.2, \"secondsWorked\" : 120}]");
 returned_content3 = gh_make_request(request3,"greenupapi.appspot.com",_gh_get_ip("greenupapi.appspot.com"),80);
 printf("%s\n", returned_content3 );
 free(returned_content3);
 return 0;
}

variable_types:
request
char *


inserirAntes

repo: porthunt/memory-management-simulator

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

result = *(_QWORD *)(a2 + 16);
*(_QWORD *)(a2 + 16) = a3;
*(_QWORD *)(a3 + 8) = a2;
*(_QWORD *)(result + 8) = a3;
*(_QWORD *)(a3 + 16) = result;
return result;
}

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

result = *(_QWORD *)(a2 + 16);
*(_QWORD *)(a2 + 16) = a3;
*(_QWORD *)(a3 + 8) = a2;
*(_QWORD *)(result + 8) = a3;
*(_QWORD *)(a3 + 16) = result;
return result;
}

original_code:
void inserirAntes (Lista * lst, No * no, No * novoNo)
{
    No * ant = no->ant;
    no->ant = novoNo;
    novoNo->prox = no;
    ant->prox = novoNo;
    novoNo->ant = ant;
}

canonical_original_code:
void inserirAntes(struct lista *lst, struct no *no, struct no *novoNo)
{
    struct no *ant = no->ant;
    no->ant = novoNo;
    novoNo->prox = no;
    ant->prox = novoNo;
    novoNo->ant = ant;
}

variable_types: struct lista { struct no { struct QuadroPagina { int addrReal; int numQuadro; int R; char M; char MemFisica; } *info; struct no *prox; struct no *ant; } *prim; struct no *ult; int tam; } *

variable_types:
no
struct no *

variable_types:
novoNo
struct no *

user_defined_types: struct lista { struct no *prim; struct no *ult; int tam; }

user_defined_types: struct no { struct QuadroPagina *info; struct no *prox; struct no *ant; }


pegarPorID

decompiled_code:
__int64 __fastcall pegarPorID(__int64 a1, int a2)
{
int v2; // eax
_QWORD *v4; // rdx
int i; // eax

v2 = *(_DWORD *)(a1 + 16);
if ( !v2 )
return 0LL;
if ( v2 <= a2 )
{
printf(format);
exit(0);
}
if ( !a2 )
return **(_QWORD **)a1;
if ( v2 - 1 == a2 )
return **(_QWORD **)(a1 + 8);
v4 = *(_QWORD **)a1;
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
v4 = (_QWORD *)v4[1];
}
return *v4;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2)
{
int v2; // eax
_QWORD *v4; // rdx
int i; // eax

v2 = *(_DWORD *)(a1 + 16);
if ( !v2 )
return 0LL;
if ( v2 <= a2 )
{
printf(format);
exit(0);
}
if ( !a2 )
return **(_QWORD **)a1;
if ( v2 - 1 == a2 )
return **(_QWORD **)(a1 + 8);
v4 = *(_QWORD **)a1;
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
v4 = (_QWORD *)v4[1];
}
return *v4;
}

original_code:
QuadroPagina* pegarPorID (Lista * lst, int posicao)
{
 QuadroPagina* retorno;
 No * no;
    if (lst->tam == 0)
        retorno = ((void *)0);
    else
  {
        if (posicao >= lst->tam)
        {
            printf("Indice de lista não existente.");
            exit(0);
        }
     if (posicao == 0)
         retorno = lst->prim->info;
     else
   {
          if (posicao == lst->tam-1)
             retorno = lst->ult->info;
          else
          {
             no = lst->prim;
             int i = 0;
             while (i < posicao)
             {
                 no = no->prox;
                 i++;
             }
             retorno= no->info;
          }
    }
    }
  return retorno;
}

canonical_original_code:
struct QuadroPagina *pegarPorID(struct lista *lst, int posicao)
{
 struct QuadroPagina *retorno;
 struct no *no;
    if (lst->tam == 0)
        retorno = ((void *)0);
    else
  {
        if (posicao >= lst->tam)
        {
            printf("Indice de lista não existente.");
            exit(0);
        }
     if (posicao == 0)
         retorno = lst->prim->info;
     else
   {
          if (posicao == lst->tam-1)
             retorno = lst->ult->info;
          else
          {
             no = lst->prim;
             int i = 0;
             while (i < posicao)
             {
                 no = no->prox;
                 i++;
             }
             retorno= no->info;
          }
    }
    }
  return retorno;
}

variable_types: struct lista { struct no { struct QuadroPagina *info; struct no *prox; struct no *ant; } *prim; struct no *ult; int tam; } *

variable_types: posicao int

variable_types: struct no { struct QuadroPagina { int addrReal; int numQuadro; int R; char M; char MemFisica; } *info; struct no *prox; struct no *ant; } *

variable_types: i int


pegarIndiceNo

decompiled_code:
__int64 __fastcall pegarIndiceNo(_QWORD **a1, __int64 a2)
{
_QWORD *v2; // rax
unsigned int v3; // er8
unsigned int v4; // edx

v2 = *a1;
v3 = -1;
if ( *a1 )
{
v4 = 0;
do
{
while ( *v2 != a2 )
{
v2 = (_QWORD *)v2[1];
++v4;
if ( !v2 )
return v3;
}
v2 = (_QWORD *)v2[1];
v3 = v4;
}
while ( v2 );
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD **a1, __int64 a2)
{
_QWORD *v2; // rax
unsigned int v3; // er8
unsigned int v4; // edx

v2 = *a1;
v3 = -1;
if ( *a1 )
{
v4 = 0;
do
{
while ( *v2 != a2 )
{
v2 = (_QWORD *)v2[1];
++v4;
if ( !v2 )
return v3;
}
v2 = (_QWORD *)v2[1];
v3 = v4;
}
while ( v2 );
}
return v3;
}

original_code:
int pegarIndiceNo(Lista * lst, QuadroPagina* tb)
{
    No * atual = lst->prim;
    int i=0,indice=-1;
    for(; atual!=((void *)0) ; atual = atual->prox)
  {
       if(atual->info==tb)
           indice=i;
   else
   {
    i++;
   }
  }
    return indice;
}

canonical_original_code:
int pegarIndiceNo(struct lista *lst, struct QuadroPagina *tb)
{
    struct no *atual = lst->prim;
    int i = 0; int indice = -1;
    for(; atual!=((void *)0) ; atual = atual->prox)
  {
       if(atual->info==tb)
           indice=i;
   else
   {
    i++;
   }
  }
    return indice;
}

variable_types:
tb
struct QuadroPagina *

variable_types: indice int

user_defined_types: struct QuadroPagina { int addrReal; int numQuadro; int R; char M; char MemFisica; }


removerPrimeiro

original_code:
QuadroPagina* removerPrimeiro (Lista * lst)
{
    No * cabeca = lst->prim;
    QuadroPagina* retorno;
    if (cabeca == ((void *)0))
        retorno = ((void *)0);
    else
  {
     lst->prim = cabeca->prox;
     if (lst->prim != ((void *)0))
         lst->prim->ant = ((void *)0);
   retorno = cabeca->info;
     free(cabeca);
     lst->tam--;
     if (lst->tam <= 1)
         lst->ult = ((void *)0);
  }
    return retorno;
}

canonical_original_code:
struct QuadroPagina *removerPrimeiro(struct lista *lst)
{
    struct no *cabeca = lst->prim;
    struct QuadroPagina *retorno;
    if (cabeca == ((void *)0))
        retorno = ((void *)0);
    else
  {
     lst->prim = cabeca->prox;
     if (lst->prim != ((void *)0))
         lst->prim->ant = ((void *)0);
   retorno = cabeca->info;
     free(cabeca);
     lst->tam--;
     if (lst->tam <= 1)
         lst->ult = ((void *)0);
  }
    return retorno;
}

variable_types: struct QuadroPagina { int addrReal; int numQuadro; int R; char M; char MemFisica; } *


limparLista

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

if ( *(int *)(a1 + 16) > 0 )
{
do
{
removerPrimeiro(a1);
result = *(unsigned int *)(a1 + 16);
}
while ( (int)result > 0 );
}
return result;
}

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

if ( *(int *)(a1 + 16) > 0 )
{
do
{
func4(a1);
result = *(unsigned int *)(a1 + 16);
}
while ( (int)result > 0 );
}
return result;
}

original_code:
void limparLista (Lista * lst)
{
    while(lst->tam > 0)
  removerPrimeiro(lst);
}

canonical_original_code:
void limparLista(struct lista *lst)
{
    while(lst->tam > 0)
  removerPrimeiro(lst);
}


removerUltimo

original_code:
QuadroPagina* removerUltimo (Lista * lst)
{
 QuadroPagina * retorno;
   No * cauda = lst->ult;
    if (lst->tam == 0)
        retorno = ((void *)0);
    else
  {
     if (lst->tam == 1)
         retorno = lst->ult->info;
     else
     {
         retorno = cauda->info;
         cauda->ant->prox= ((void *)0);
         if (lst->tam > 1)
             lst->ult = cauda->ant;
         if (lst->tam <= 1)
             lst->ult = ((void *)0);
     lst->tam--;
     }
  }
  return retorno;
}

canonical_original_code:
struct QuadroPagina *removerUltimo(struct lista *lst)
{
 struct QuadroPagina *retorno;
   struct no *cauda = lst->ult;
    if (lst->tam == 0)
        retorno = ((void *)0);
    else
  {
     if (lst->tam == 1)
         retorno = lst->ult->info;
     else
     {
         retorno = cauda->info;
         cauda->ant->prox= ((void *)0);
         if (lst->tam > 1)
             lst->ult = cauda->ant;
         if (lst->tam <= 1)
             lst->ult = ((void *)0);
     lst->tam--;
     }
  }
  return retorno;
}

return_type: struct QuadroPagina { int addrReal; int numQuadro; int R; char M; char MemFisica; } *


removerPorID

original_code:
QuadroPagina* removerPorID (Lista * lst, int posicao)
{
 QuadroPagina * retorno;
 No * node,*ant,*prox;
 int i = 0;
    if (lst->tam == 0)
        retorno = ((void *)0);
    else
 {
        if (posicao >= lst->tam)
        {
            printf("LIST: Index out of bound \n");
            exit(0);
        }
      if (posicao == 0)
          retorno = removerPrimeiro(lst);
     else
  {
         if (posicao == lst->tam-1)
             retorno = removerUltimo(lst);
         else
         {
            node = lst->prim;
             while (i < posicao)
             {
                 node = node->prox;
                 i++;
             }
             ant = node->ant;
             prox = node->prox;
             ant->prox = prox;
             prox->ant = ant;
             retorno = node->info;
             free(node);
             lst->tam--;
       }
  }
   }
 return retorno;
}

canonical_original_code:
struct QuadroPagina *removerPorID(struct lista *lst, int posicao)
{
 struct QuadroPagina *retorno;
 struct no *node; struct no *ant; struct no *prox;
 int i = 0;
    if (lst->tam == 0)
        retorno = ((void *)0);
    else
 {
        if (posicao >= lst->tam)
        {
            printf("LIST: Index out of bound \n");
            exit(0);
        }
      if (posicao == 0)
          retorno = removerPrimeiro(lst);
     else
  {
         if (posicao == lst->tam-1)
             retorno = removerUltimo(lst);
         else
         {
            node = lst->prim;
             while (i < posicao)
             {
                 node = node->prox;
                 i++;
             }
             ant = node->ant;
             prox = node->prox;
             ant->prox = prox;
             prox->ant = ant;
             retorno = node->info;
             free(node);
             lst->tam--;
       }
  }
   }
 return retorno;
}


removerNo

decompiled_code:
__int64 __fastcall removerNo(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rbx
int v3; // ebp
__int64 result; // rax

v2 = (_QWORD *)*a1;
if ( !*a1 )
return 0LL;
v3 = 0;
result = 0LL;
do
{
while ( *v2 != a2 )
{
v2 = (_QWORD *)v2[1];
++v3;
if ( !v2 )
return result;
}
result = removerPorID((__int64)a1, v3);
v2 = (_QWORD *)v2[1];
}
while ( v2 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rbx
int v3; // ebp
__int64 result; // rax

v2 = (_QWORD *)*a1;
if ( !*a1 )
return 0LL;
v3 = 0;
result = 0LL;
do
{
while ( *v2 != a2 )
{
v2 = (_QWORD *)v2[1];
++v3;
if ( !v2 )
return result;
}
result = func7((__int64)a1, v3);
v2 = (_QWORD *)v2[1];
}
while ( v2 );
return result;
}

original_code:
QuadroPagina* removerNo(Lista * lst, QuadroPagina* tb)
{
 QuadroPagina* retorno=((void *)0);
   No * atual=lst->prim;
   int i=0;
   for(; atual!=((void *)0) ; atual = atual->prox)
 {
      if(atual->info==tb)
   retorno = removerPorID(lst, i);
  else
  {
   i++;
  }
 }
   return retorno ;
}

canonical_original_code:
struct QuadroPagina *removerNo(struct lista *lst, struct QuadroPagina *tb)
{
 struct QuadroPagina *retorno = ((void *)0);
   struct no *atual = lst->prim;
   int i = 0;
   for(; atual!=((void *)0) ; atual = atual->prox)
 {
      if(atual->info==tb)
   retorno = removerPorID(lst, i);
  else
  {
   i++;
  }
 }
   return retorno ;
}


colocar

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

*(_QWORD *)(memVirtual + 8LL * a1) = a2;
*(_WORD *)(a2 + 12) = 256;
result = (unsigned int)TAM_PAG;
*(_DWORD *)(a2 + 8) = 0;
memOcupada += result;
return result;
}

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

*(_QWORD *)(memVirtual + 8LL * a1) = a2;
*(_WORD *)(a2 + 12) = 256;
result = (unsigned int)TAM_PAG;
*(_DWORD *)(a2 + 8) = 0;
memOcupada += result;
return result;
}

original_code:
void colocar(int quadro, QuadroPagina * criarPagina)
{
  memVirtual[quadro] = criarPagina;
    memVirtual[quadro]->R = 0;
    memVirtual[quadro]->M = 0;
    memVirtual[quadro]->MemFisica = 1;
    memOcupada = memOcupada + TAM_PAG;
}

canonical_original_code:
void colocar(int quadro, struct QuadroPagina *criarPagina)
{
  memVirtual[quadro] = criarPagina;
    memVirtual[quadro]->R = 0;
    memVirtual[quadro]->M = 0;
    memVirtual[quadro]->MemFisica = 1;
    memOcupada = memOcupada + TAM_PAG;
}

variable_types: quadro int


retirar

decompiled_code:
__int64 __fastcall retirar(int a1, int a2)
{
__int64 result; // rax
__int64 v3; // rbx
char *v4; // rdi
int v5; // eax

result = memVirtual;
v3 = a1;
v4 = *(char **)(memVirtual + 8LL * a1);
if ( v4 )
{
v5 = v4[12];
++Relatorio[a2 + 4];
Relatorio[a2 + 6] += v5;
free(v4);
*(_QWORD *)(memVirtual + 8 * v3) = 0LL;
result = (unsigned int)TAM_PAG;
memOcupada -= TAM_PAG;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, int a2)
{
__int64 result; // rax
__int64 v3; // rbx
char *v4; // rdi
int v5; // eax

result = memVirtual;
v3 = a1;
v4 = *(char **)(memVirtual + 8LL * a1);
if ( v4 )
{
v5 = v4[12];
++Relatorio[a2 + 4];
Relatorio[a2 + 6] += v5;
free(v4);
*(_QWORD *)(memVirtual + 8 * v3) = 0LL;
result = (unsigned int)TAM_PAG;
memOcupada -= TAM_PAG;
}
return result;
}

original_code:
void retirar(int quadro, int tipo)
{
   if(memVirtual[quadro] != ((void *)0))
   {
      Relatorio.Sujas[tipo]+=memVirtual[quadro]->M;
      Relatorio.Trocas[tipo]++;
      memVirtual[quadro]->M = 0;
      memVirtual[quadro]->MemFisica = 0;
      free(memVirtual[quadro]);
      memVirtual[quadro] = ((void *)0);
      memOcupada -= TAM_PAG;
   }
 }

variable_types: tipo int


decompiled_code:
// attributes: thunk
__int64 __fastcall ts_lua_decode_base64(_BYTE *a1, _QWORD *a2, unsigned __int8 *a3, __int64 a4)
{
return ts_lua_decode_base64_internal_constprop_0(a1, a2, a3, a4);
}

canonical_decompiled_code:
__int64 __fastcall func3(_BYTE *a1, _QWORD *a2, unsigned __int8 *a3, __int64 a4)
{
return func0(a1, a2, a3, a4);
}

variable_types:
dst
unsigned char *

variable_types:
src
unsigned char *


decompiled_code:
unsigned __int8 *__fastcall ts_lua_escape_internal(unsigned __int8 *a1, unsigned __int8 *a2, __int64 a3, int a4)
{
__int64 v4; // r8
unsigned __int8 *v5; // r11
unsigned __int8 v6; // cl
unsigned __int8 *result; // rax
unsigned __int8 *v8; // rdx

v4 = (__int64)*(&map_6 + a4);
if ( a1 )
{
v5 = &a2[a3];
if ( a3 )
{
do
{
while ( 1 )
{
v6 = *a2++;
if ( (*(_DWORD *)(v4 + 4LL * (v6 >> 5)) & (1 << v6)) == 0 )
break;
*a1 = 37;
a1 += 3;
*(a1 - 2) = hex_9[(*(a2 - 1) >> 4) & 0xF];
*(a1 - 1) = hex_9[*(a2 - 1) & 0xF];
if ( v5 == a2 )
goto LABEL_7;
}
*a1++ = v6;
}
while ( v5 != a2 );
}
LABEL_7:
result = a1;
}
else if ( a3 )
{
v8 = &a2[a3];
LODWORD(result) = 0;
do
{
result = (unsigned __int8 *)((unsigned int)result - ((((1 << *a2) & *(_DWORD *)(v4 + 4LL * (*a2 >> 5))) == 0) - 1));
++a2;
}
while ( a2 != v8 );
}
else
{
result = 0LL;
}
return result;
}

original_code:
uintptr_t
ts_lua_escape_internal(u_char *dst, u_char *src, size_t size, int type)
{
    uint32_t n;
    uint32_t *escape;
    static u_char hex[] = "0123456789abcdef";
    static uint32_t uri[] = {
        0xffffffff,
        0xfc00886d,
        0x78000000,
        0xa8000000,
        0xffffffff,
        0xffffffff,
        0xffffffff,
        0xffffffff
    };
    static uint32_t args[] = {
        0xffffffff,
        0x80000829,
        0x00000000,
        0x80000000,
        0xffffffff,
        0xffffffff,
        0xffffffff,
        0xffffffff
    };
    static uint32_t html[] = {
        0xffffffff,
        0x000000ad,
        0x00000000,
        0x80000000,
        0xffffffff,
        0xffffffff,
        0xffffffff,
        0xffffffff
    };
    static uint32_t refresh[] = {
        0xffffffff,
        0x00000085,
        0x00000000,
        0x80000000,
        0xffffffff,
        0xffffffff,
        0xffffffff,
        0xffffffff
    };
    static uint32_t memcached[] = {
        0xffffffff,
        0x00000021,
        0x00000000,
        0x00000000,
        0x00000000,
        0x00000000,
        0x00000000,
        0x00000000,
    };
    static uint32_t *map[] =
        { uri, args, html, refresh, memcached, memcached };
    escape = map[type];
    if (dst == ((void *)0)) {
        n = 0;
        while (size) {
            if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
                n++;
            }
            src++;
            size--;
        }
        return (uintptr_t) n;
    }
    while (size) {
        if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
            *dst++ = '%';
            *dst++ = hex[*src >> 4];
            *dst++ = hex[*src & 0xf];
            src++;
        } else {
            *dst++ = *src++;
        }
        size--;
    }
    return (uintptr_t) dst;
}

canonical_original_code:
unsigned long ts_lua_escape_internal(unsigned char *dst, unsigned char *src, unsigned long size, int type)
{
    unsigned int n;
    unsigned int *escape;
    static unsigned char hex[] = "0123456789abcdef";
    static unsigned int uri[] = {
        0xffffffff,
        0xfc00886d,
        0x78000000,
        0xa8000000,
        0xffffffff,
        0xffffffff,
        0xffffffff,
        0xffffffff
    };
    static unsigned int args[] = {
        0xffffffff,
        0x80000829,
        0x00000000,
        0x80000000,
        0xffffffff,
        0xffffffff,
        0xffffffff,
        0xffffffff
    };
    static unsigned int html[] = {
        0xffffffff,
        0x000000ad,
        0x00000000,
        0x80000000,
        0xffffffff,
        0xffffffff,
        0xffffffff,
        0xffffffff
    };
    static unsigned int refresh[] = {
        0xffffffff,
        0x00000085,
        0x00000000,
        0x80000000,
        0xffffffff,
        0xffffffff,
        0xffffffff,
        0xffffffff
    };
    static unsigned int memcached[] = {
        0xffffffff,
        0x00000021,
        0x00000000,
        0x00000000,
        0x00000000,
        0x00000000,
        0x00000000,
        0x00000000,
    };
    static unsigned int *map[] = { uri, args, html, refresh, memcached, memcached };
    escape = map[type];
    if (dst == ((void *)0)) {
        n = 0;
        while (size) {
            if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
                n++;
            }
            src++;
            size--;
        }
        return (unsigned long) n;
    }
    while (size) {
        if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
            *dst++ = '%';
            *dst++ = hex[*src >> 4];
            *dst++ = hex[*src & 0xf];
            src++;
        } else {
            *dst++ = *src++;
        }
        size--;
    }
    return (unsigned long) dst;
}

variable_types:
size
unsigned long

variable_types: type int

variable_types:
n
unsigned int

variable_types:
escape
unsigned int *

variable_types:
hex
unsigned char []

variable_types:
uri
unsigned int []

variable_types:
args
unsigned int []

variable_types:
html
unsigned int []

variable_types:
refresh
unsigned int []

variable_types:
memcached
unsigned int []

variable_types:
map
unsigned int *[]

return_type: unsigned long


original_code:
void
ts_lua_unescape_internal(u_char **dst, u_char **src, size_t size, int type)
{
    u_char *d, *s, ch, c, decoded;
    enum {
        sw_usual = 0,
        sw_quoted,
        sw_quoted_second
    } state;
    d = *dst;
    s = *src;
    state = 0;
    decoded = 0;
    while (size--) {
        ch = *s++;
        switch (state) {
        case sw_usual:
            if (ch == '?'
                && (type & (1|2)))
            {
                *d++ = ch;
                goto done;
            }
            if (ch == '%') {
                state = sw_quoted;
                break;
            }
            if (ch == '+') {
                *d++ = ' ';
                break;
            }
            *d++ = ch;
            break;
        case sw_quoted:
            if (ch >= '0' && ch <= '9') {
                decoded = (u_char) (ch - '0');
                state = sw_quoted_second;
                break;
            }
            c = (u_char) (ch | 0x20);
            if (c >= 'a' && c <= 'f') {
                decoded = (u_char) (c - 'a' + 10);
                state = sw_quoted_second;
                break;
            }
            state = sw_usual;
            *d++ = ch;
            break;
        case sw_quoted_second:
            state = sw_usual;
            if (ch >= '0' && ch <= '9') {
                ch = (u_char) ((decoded << 4) + ch - '0');
                if (type & 2) {
                    if (ch > '%' && ch < 0x7f) {
                        *d++ = ch;
                        break;
                    }
                    *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
                    break;
                }
                *d++ = ch;
                break;
            }
            c = (u_char) (ch | 0x20);
            if (c >= 'a' && c <= 'f') {
                ch = (u_char) ((decoded << 4) + c - 'a' + 10);
                if (type & 1) {
                    if (ch == '?') {
                        *d++ = ch;
                        goto done;
                    }
                    *d++ = ch;
                    break;
                }
                if (type & 2) {
                    if (ch == '?') {
                        *d++ = ch;
                        goto done;
                    }
                    if (ch > '%' && ch < 0x7f) {
                        *d++ = ch;
                        break;
                    }
                    *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
                    break;
                }
                *d++ = ch;
                break;
            }
            break;
        }
    }
done:
    *dst = d;
    *src = s;
}

canonical_original_code:
void ts_lua_unescape_internal(unsigned char **dst, unsigned char **src, unsigned long size, int type)
{
    unsigned char *d; unsigned char *s; unsigned char ch; unsigned char c; unsigned char decoded;
    enum { sw_usual=0, sw_quoted=1, sw_quoted_second=2 } state;
    d = *dst;
    s = *src;
    state = 0;
    decoded = 0;
    while (size--) {
        ch = *s++;
        switch (state) {
        case sw_usual:
            if (ch == '?'
                && (type & (1|2)))
            {
                *d++ = ch;
                goto done;
            }
            if (ch == '%') {
                state = sw_quoted;
                break;
            }
            if (ch == '+') {
                *d++ = ' ';
                break;
            }
            *d++ = ch;
            break;
        case sw_quoted:
            if (ch >= '0' && ch <= '9') {
                decoded = (u_char) (ch - '0');
                state = sw_quoted_second;
                break;
            }
            c = (u_char) (ch | 0x20);
            if (c >= 'a' && c <= 'f') {
                decoded = (u_char) (c - 'a' + 10);
                state = sw_quoted_second;
                break;
            }
            state = sw_usual;
            *d++ = ch;
            break;
        case sw_quoted_second:
            state = sw_usual;
            if (ch >= '0' && ch <= '9') {
                ch = (u_char) ((decoded << 4) + ch - '0');
                if (type & 2) {
                    if (ch > '%' && ch < 0x7f) {
                        *d++ = ch;
                        break;
                    }
                    *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
                    break;
                }
                *d++ = ch;
                break;
            }
            c = (u_char) (ch | 0x20);
            if (c >= 'a' && c <= 'f') {
                ch = (u_char) ((decoded << 4) + c - 'a' + 10);
                if (type & 1) {
                    if (ch == '?') {
                        *d++ = ch;
                        goto done;
                    }
                    *d++ = ch;
                    break;
                }
                if (type & 2) {
                    if (ch == '?') {
                        *d++ = ch;
                        goto done;
                    }
                    if (ch > '%' && ch < 0x7f) {
                        *d++ = ch;
                        break;
                    }
                    *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
                    break;
                }
                *d++ = ch;
                break;
            }
            break;
        }
    }
done:
    *dst = d;
    *src = s;
}

variable_types:
dst
unsigned char **

variable_types:
src
unsigned char **

variable_types:
d
unsigned char *

variable_types:
s
unsigned char *

variable_types:
ch
unsigned char

variable_types:
c
unsigned char

variable_types:
decoded
unsigned char


original_code:
my_bool
jfget_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
 if (args->arg_count != 2) {
  strcpy(message, "jfget() requires two arguments");
  return 1;
 }
 if (args->arg_type[0] != STRING_RESULT) {
  strcpy(message, "jfget() requires a string for first argument");
  return 1;
 }
 if (args->arg_type[1] != STRING_RESULT) {
  strcpy(message, "jfget() requires a string for second argument");
  return 1;
 }
 args->maybe_null[0] = 0;
 args->maybe_null[1] = 0;
 initid->ptr = ((void *)0);
 return 0;
}

canonical_original_code:
char jfget_init(struct st_udf_init *initid, struct st_udf_args *args, char *message)
{
 if (args->arg_count != 2) {
  strcpy(message, "jfget() requires two arguments");
  return 1;
 }
 if (args->arg_type[0] != STRING_RESULT) {
  strcpy(message, "jfget() requires a string for first argument");
  return 1;
 }
 if (args->arg_type[1] != STRING_RESULT) {
  strcpy(message, "jfget() requires a string for second argument");
  return 1;
 }
 args->maybe_null[0] = 0;
 args->maybe_null[1] = 0;
 initid->ptr = ((void *)0);
 return 0;
}

variable_types: struct st_udf_init { char maybe_null; unsigned int decimals; unsigned int max_length; char *ptr; char const_item; } *

variable_types: struct st_udf_args { unsigned int arg_count; enum Item_result { STRING_RESULT=0, REAL_RESULT=1, INT_RESULT=2, ROW_RESULT=3, DECIMAL_RESULT=4 } *arg_type; char **args; unsigned long *lengths; char *maybe_null; } *

variable_types:
message
char *

return_type: char

user_defined_types: struct st_udf_args { unsigned int arg_count; enum Item_result *arg_type; char **args; unsigned long *lengths; char *maybe_null; }


jfget

decompiled_code:
void *__fastcall jfget(__int64 a1, __int64 a2, void *a3, _QWORD *a4, _BYTE *a5, _BYTE *a6)
{
int v10; // eax
void *result; // rax
__int64 v12; // rbp
void *v13; // [rsp+0h] [rbp-68h] BYREF
__int64 v14; // [rsp+8h] [rbp-60h] BYREF
int v15; // [rsp+10h] [rbp-58h] BYREF
void *src; // [rsp+18h] [rbp-50h]
size_t n; // [rsp+20h] [rbp-48h]
char v18; // [rsp+28h] [rbp-40h]

v10 = json_finder_find(
&v15,
**(_QWORD **)(a2 + 16),
**(_QWORD **)(a2 + 24),
*(_QWORD *)(*(_QWORD *)(a2 + 16) + 8LL),
*(_QWORD *)(*(_QWORD *)(a2 + 24) + 8LL),
0LL,
0LL);
if ( v10 == -1 )
{
LABEL_4:
*a5 = 1;
result = 0LL;
}
else if ( v10 == 1 )
{
LABEL_6:
*a6 = 1;
result = 0LL;
}
else
{
switch ( v18 )
{
case 1:
goto LABEL_4;
case 2:
if ( (unsigned int)json_finder_unescape_strdup(&v13, &v14, &v15) )
goto LABEL_6;
*a4 = v14 - 1;
result = v13;
*(_QWORD *)(a1 + 16) = v13;
break;
case 3:
case 4:
v12 = (unsigned int)n;
result = memcpy(a3, src, (unsigned int)n);
*((_BYTE *)a3 + v12) = 0;
*a4 = v12;
break;
case 5:
if ( v15 )
{
strcpy((char *)a3, "true");
result = a3;
*a4 = 4LL;
}
else
{
strcpy((char *)a3, "false");
result = a3;
*a4 = 5LL;
}
break;
default:
goto LABEL_6;
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func2(__int64 a1, __int64 a2, void *a3, _QWORD *a4, _BYTE *a5, _BYTE *a6)
{
int v10; // eax
void *result; // rax
__int64 v12; // rbp
void *v13; // [rsp+0h] [rbp-68h] BYREF
__int64 v14; // [rsp+8h] [rbp-60h] BYREF
int v15; // [rsp+10h] [rbp-58h] BYREF
void *src; // [rsp+18h] [rbp-50h]
size_t n; // [rsp+20h] [rbp-48h]
char v18; // [rsp+28h] [rbp-40h]

v10 = json_finder_find(
&v15,
**(_QWORD **)(a2 + 16),
**(_QWORD **)(a2 + 24),
*(_QWORD *)(*(_QWORD *)(a2 + 16) + 8LL),
*(_QWORD *)(*(_QWORD *)(a2 + 24) + 8LL),
0LL,
0LL);
if ( v10 == -1 )
{
LABEL_4:
*a5 = 1;
result = 0LL;
}
else if ( v10 == 1 )
{
LABEL_6:
*a6 = 1;
result = 0LL;
}
else
{
switch ( v18 )
{
case 1:
goto LABEL_4;
case 2:
if ( (unsigned int)json_finder_unescape_strdup(&v13, &v14, &v15) )
goto LABEL_6;
*a4 = v14 - 1;
result = v13;
*(_QWORD *)(a1 + 16) = v13;
break;
case 3:
case 4:
v12 = (unsigned int)n;
result = memcpy(a3, src, (unsigned int)n);
*((_BYTE *)a3 + v12) = 0;
*a4 = v12;
break;
case 5:
if ( v15 )
{
strcpy((char *)a3, "true");
result = a3;
*a4 = 4LL;
}
else
{
strcpy((char *)a3, "false");
result = a3;
*a4 = 5LL;
}
break;
default:
goto LABEL_6;
}
}
return result;
}

original_code:
char *
jfget(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *length, char *is_null, char *error)
{
 json_elem_t elem;
 char *uestr;
 size_t uestr_size;
 switch (json_finder_find(
     &elem,
     (const char *)args->args[0],
     (ssize_t)args->lengths[0],
     (char *)args->args[1],
     (ssize_t)args->lengths[1],
     ((void *)0),
     ((void *)0),
     ((void *)0))) {
 case 1:
  *error = 1;
  return ((void *)0);
 case -1:
  *is_null = 1;
  return ((void *)0);
 default:
  break;
 }
 switch (elem.type) {
 case 5:
  if (elem.value.b) {
   strcpy(result, "true");
   *length = sizeof("true") - 1;
   return result;
  } else {
   strcpy(result, "false");
   *length = sizeof("false") - 1;
   return result;
  }
 case 3:
  memcpy(result, elem.value.ll.s.ptr, elem.value.ll.s.len);
  result[elem.value.ll.s.len] = '\0';
  *length = elem.value.ll.s.len;
  return result;
 case 4:
  memcpy(result, elem.value.d.s.ptr, elem.value.d.s.len);
  result[elem.value.d.s.len] = '\0';
  *length = elem.value.d.s.len;
  return result;
 case 2:
  if (json_finder_unescape_strdup(&uestr, &uestr_size, &elem.value.s)) {
   *error = 1;
   return ((void *)0);
  }
  *length = uestr_size - 1;
  initid->ptr = uestr;
  return uestr;
 case 1:
  *is_null = 1;
  return ((void *)0);
 default:
  *error = 1;
  return ((void *)0);
 }
}

canonical_original_code:
char *jfget(struct st_udf_init *initid, struct st_udf_args *args, char *result, unsigned long *length, char *is_null, char *error)
{
 struct json_elem elem;
 char *uestr;
 unsigned long uestr_size;
 switch (json_finder_find(
     &elem,
     (char *)args->args[0],
     (long)args->lengths[0],
     (char *)args->args[1],
     (long)args->lengths[1],
     ((void *)0),
     ((void *)0),
     ((void *)0))) {
 case 1:
  *error = 1;
  return ((void *)0);
 case -1:
  *is_null = 1;
  return ((void *)0);
 default:
  break;
 }
 switch (elem.type) {
 case 5:
  if (elem.value.b) {
   strcpy(result, "true");
   *length = sizeof("true") - 1;
   return result;
  } else {
   strcpy(result, "false");
   *length = sizeof("false") - 1;
   return result;
  }
 case 3:
  memcpy(result, elem.value.ll.s.ptr, elem.value.ll.s.len);
  result[elem.value.ll.s.len] = '\0';
  *length = elem.value.ll.s.len;
  return result;
 case 4:
  memcpy(result, elem.value.d.s.ptr, elem.value.d.s.len);
  result[elem.value.d.s.len] = '\0';
  *length = elem.value.d.s.len;
  return result;
 case 2:
  if (json_finder_unescape_strdup(&uestr, &uestr_size, &elem.value.s)) {
   *error = 1;
   return ((void *)0);
  }
  *length = uestr_size - 1;
  initid->ptr = uestr;
  return uestr;
 case 1:
  *is_null = 1;
  return ((void *)0);
 default:
  *error = 1;
  return ((void *)0);
 }
}

variable_types:
result
char *

variable_types:
length
unsigned long *

variable_types:
error
char *

variable_types: struct json_elem { union json_value { int b; struct json_string { char *ptr; unsigned int len; } s; struct json_integer { long long v; struct json_string s; } ll; struct json_double { double v; struct json_string s; } d; } value; unsigned char type; }

variable_types:
uestr
char *

return_type: char *

user_defined_types: struct json_elem { union json_value value; unsigned char type; }

user_defined_types: struct st_udf_init { char maybe_null; unsigned int decimals; unsigned int max_length; char *ptr; char const_item; }

user_defined_types: union json_value { int b; struct json_string s; struct json_integer ll; struct json_double d; }

user_defined_types: enum Item_result { STRING_RESULT=0, REAL_RESULT=1, INT_RESULT=2, ROW_RESULT=3, DECIMAL_RESULT=4 }


jfgetint

original_code:
long long
jfgetint(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
{
 json_elem_t elem;
 switch (json_finder_find(
     &elem,
     (const char *)args->args[0],
     (ssize_t)args->lengths[0],
     (char *)args->args[1],
     (ssize_t)args->lengths[1],
     ((void *)0),
     ((void *)0),
     ((void *)0))) {
 case 1:
  *error = 1;
  return 0;
 case -1:
  *is_null = 1;
  return 0;
 default:
  break;
 }
 switch (elem.type) {
 case 5:
  return (long long)elem.value.b;
 case 3:
  return elem.value.ll.v;
 case 4:
  *error = 1;
  return 0;
 case 2:
  *error = 1;
  return 0;
 case 1:
  *is_null = 1;
  return 0;
 default:
  *error = 1;
  return 0;
 }
}

canonical_original_code:
long long jfgetint(struct st_udf_init *initid, struct st_udf_args *args, char *is_null, char *error)
{
 struct json_elem elem;
 switch (json_finder_find(
     &elem,
     (char *)args->args[0],
     (long)args->lengths[0],
     (char *)args->args[1],
     (long)args->lengths[1],
     ((void *)0),
     ((void *)0),
     ((void *)0))) {
 case 1:
  *error = 1;
  return 0;
 case -1:
  *is_null = 1;
  return 0;
 default:
  break;
 }
 switch (elem.type) {
 case 5:
  return (long long)elem.value.b;
 case 3:
  return elem.value.ll.v;
 case 4:
  *error = 1;
  return 0;
 case 2:
  *error = 1;
  return 0;
 case 1:
  *is_null = 1;
  return 0;
 default:
  *error = 1;
  return 0;
 }
}

return_type: long long

user_defined_types: struct json_string { char *ptr; unsigned int len; }

user_defined_types: struct json_integer { long long v; struct json_string s; }

user_defined_types: struct json_double { double v; struct json_string s; }


decompiled_code:
// attributes: thunk
__int64 __fastcall jfgetreal_init(__int64 a1, __int64 a2, __m128i *a3)
{
return jfgetint_init_localalias(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __m128i *a3)
{
return func3(a1, a2, a3);
}

original_code:
my_bool
jfgetreal_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
 if (args->arg_count != 2) {
  strcpy(message, "jfget() requires two arguments");
  return 1;
 }
 if (args->arg_type[0] != STRING_RESULT) {
  strcpy(message, "jfget() requires a string for first argument");
  return 1;
 }
 if (args->arg_type[1] != STRING_RESULT) {
  strcpy(message, "jfget() requires a string for second argument");
  return 1;
 }
 args->maybe_null[0] = 0;
 args->maybe_null[1] = 0;
 return 0;
}

canonical_original_code:
char jfgetreal_init(struct st_udf_init *initid, struct st_udf_args *args, char *message)
{
 if (args->arg_count != 2) {
  strcpy(message, "jfget() requires two arguments");
  return 1;
 }
 if (args->arg_type[0] != STRING_RESULT) {
  strcpy(message, "jfget() requires a string for first argument");
  return 1;
 }
 if (args->arg_type[1] != STRING_RESULT) {
  strcpy(message, "jfget() requires a string for second argument");
  return 1;
 }
 args->maybe_null[0] = 0;
 args->maybe_null[1] = 0;
 return 0;
}


decompiled_code:
void jfgetreal_deinit()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void
jfgetreal_deinit(UDF_INIT *initid)
{
 return;
}

canonical_original_code:
void jfgetreal_deinit(struct st_udf_init *initid)
{
 return;
}


jfgetreal

decompiled_code:
double __fastcall jfgetreal(__int64 a1, __int64 a2, _BYTE *a3, _BYTE *a4)
{
int v6; // eax
double result; // xmm0_8
double v8[3]; // [rsp+0h] [rbp-38h] BYREF
char v9; // [rsp+18h] [rbp-20h]

v6 = json_finder_find(
v8,
**(_QWORD **)(a2 + 16),
**(_QWORD **)(a2 + 24),
*(_QWORD *)(*(_QWORD *)(a2 + 16) + 8LL),
*(_QWORD *)(*(_QWORD *)(a2 + 24) + 8LL),
0LL,
0LL);
if ( v6 == -1 )
goto LABEL_6;
if ( v6 == 1 )
{
LABEL_5:
*a4 = 1;
return 0.0;
}
if ( v9 == 1 )
{
LABEL_6:
*a3 = 1;
result = 0.0;
}
else
{
if ( v9 != 4 )
goto LABEL_5;
result = v8[0];
}
return result;
}

canonical_decompiled_code:
double __fastcall func8(__int64 a1, __int64 a2, _BYTE *a3, _BYTE *a4)
{
int v6; // eax
double result; // xmm0_8
double v8[3]; // [rsp+0h] [rbp-38h] BYREF
char v9; // [rsp+18h] [rbp-20h]

v6 = json_finder_find(
v8,
**(_QWORD **)(a2 + 16),
**(_QWORD **)(a2 + 24),
*(_QWORD *)(*(_QWORD *)(a2 + 16) + 8LL),
*(_QWORD *)(*(_QWORD *)(a2 + 24) + 8LL),
0LL,
0LL);
if ( v6 == -1 )
goto LABEL_6;
if ( v6 == 1 )
{
LABEL_5:
*a4 = 1;
return 0.0;
}
if ( v9 == 1 )
{
LABEL_6:
*a3 = 1;
result = 0.0;
}
else
{
if ( v9 != 4 )
goto LABEL_5;
result = v8[0];
}
return result;
}

original_code:
double
jfgetreal(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
{
 json_elem_t elem;
 switch (json_finder_find(
     &elem,
     (const char *)args->args[0],
     (ssize_t)args->lengths[0],
     (char *)args->args[1],
     (ssize_t)args->lengths[1],
     ((void *)0),
     ((void *)0),
     ((void *)0))) {
 case 1:
  *error = 1;
  return 0;
 case -1:
  *is_null = 1;
  return 0;
 default:
  break;
 }
 switch (elem.type) {
 case 5:
  *error = 1;
  return 0;
 case 3:
  *error = 1;
  return 0;
 case 4:
  return elem.value.d.v;
 case 2:
  *error = 1;
  return 0;
 case 1:
  *is_null = 1;
  return 0;
 default:
  *error = 1;
  return 0;
 }
}

canonical_original_code:
double jfgetreal(struct st_udf_init *initid, struct st_udf_args *args, char *is_null, char *error)
{
 struct json_elem elem;
 switch (json_finder_find(
     &elem,
     (char *)args->args[0],
     (long)args->lengths[0],
     (char *)args->args[1],
     (long)args->lengths[1],
     ((void *)0),
     ((void *)0),
     ((void *)0))) {
 case 1:
  *error = 1;
  return 0;
 case -1:
  *is_null = 1;
  return 0;
 default:
  break;
 }
 switch (elem.type) {
 case 5:
  *error = 1;
  return 0;
 case 3:
  *error = 1;
  return 0;
 case 4:
  return elem.value.d.v;
 case 2:
  *error = 1;
  return 0;
 case 1:
  *is_null = 1;
  return 0;
 default:
  *error = 1;
  return 0;
 }
}

return_type: double


decompiled_code:
__int64 __fastcall jfmin_init(__int64 a1, __int64 a2, __m128i *a3)
{
__int64 result; // rax

if ( *(_DWORD *)a2 == 1 )
{
if ( **(_DWORD **)(a2 + 8) )
{
strcpy(a3[1].m128i_i8, " a string");
result = 1LL;
*a3 = _mm_load_si128((const __m128i *)&LC0);
}
else
{
**(_BYTE **)(a2 + 32) = 0;
result = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
}
}
else
{
strcpy(a3[1].m128i_i8, " one arguments");
result = 1LL;
*a3 = _mm_load_si128((const __m128i *)&LC0);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2, __m128i *a3)
{
__int64 result; // rax

if ( *(_DWORD *)a2 == 1 )
{
if ( **(_DWORD **)(a2 + 8) )
{
strcpy(a3[1].m128i_i8, " a string");
result = 1LL;
*a3 = _mm_load_si128((const __m128i *)&LC0);
}
else
{
**(_BYTE **)(a2 + 32) = 0;
result = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
}
}
else
{
strcpy(a3[1].m128i_i8, " one arguments");
result = 1LL;
*a3 = _mm_load_si128((const __m128i *)&LC0);
}
return result;
}

original_code:
my_bool
jfmin_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
 if (args->arg_count != 1) {
  strcpy(message, "jfget() requires one arguments");
  return 1;
 }
 if (args->arg_type[0] != STRING_RESULT) {
  strcpy(message, "jfget() requires a string");
  return 1;
 }
 args->maybe_null[0] = 0;
 initid->ptr = ((void *)0);
 return 0;
}

canonical_original_code:
char jfmin_init(struct st_udf_init *initid, struct st_udf_args *args, char *message)
{
 if (args->arg_count != 1) {
  strcpy(message, "jfget() requires one arguments");
  return 1;
 }
 if (args->arg_type[0] != STRING_RESULT) {
  strcpy(message, "jfget() requires a string");
  return 1;
 }
 args->maybe_null[0] = 0;
 initid->ptr = ((void *)0);
 return 0;
}


decompiled_code:
// attributes: thunk
void __fastcall jfmin_deinit(__int64 a1)
{
jfget_deinit_localalias(a1);
}

canonical_decompiled_code:
void __fastcall func10(__int64 a1)
{
func1(a1);
}

original_code:
void
jfmin_deinit(UDF_INIT *initid)
{
 free(initid->ptr);
 return;
}

canonical_original_code:
void jfmin_deinit(struct st_udf_init *initid)
{
 free(initid->ptr);
 return;
}


jfmin

original_code:
char *
jfmin(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *length, char *is_null, char *error)
{
        char *json_min;
        ssize_t json_min_size;
        if (json_finder_minimize(
            &json_min,
            &json_min_size,
     (const char *)args->args[0],
            (ssize_t)args->lengths[0])) {
  *error = 1;
                return ((void *)0);
        }
 initid->ptr = json_min;
 *length = json_min_size - 1;
 return json_min;
}

canonical_original_code:
char *jfmin(struct st_udf_init *initid, struct st_udf_args *args, char *result, unsigned long *length, char *is_null, char *error)
{
        char *json_min;
        long json_min_size;
        if (json_finder_minimize(
            &json_min,
            &json_min_size,
     (char *)args->args[0],
            (long)args->lengths[0])) {
  *error = 1;
                return ((void *)0);
        }
 initid->ptr = json_min;
 *length = json_min_size - 1;
 return json_min;
}


decompiled_code:
void ingame_level1_render()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void ingame_level1_render(Game* game){
}

canonical_original_code:
void ingame_level1_render(struct Game *game){
}

variable_types: struct Game { struct Camera { struct Game *game; double theta; double phi; double rho; double dtheta; double dphi; double drho; double ddtheta; double ddphi; double ddrho; double x; double y; double z; double fake_y; double fake_z; double dx; double dy; double dz; double ddx; double ddy; double ddz; double mConvergence; double mEyeSeparation; double mAspectRatio; double mFOV; double mNearClippingDistance; double mFarClippingDistance; int avance; double angle; double x_culling; double y_culling; } *player; struct Arrow { double x; double y; double z; double dx; double dy; double dz; struct Arrow *next; struct Arrow *prev; struct Arrow *next_update; double v; double dist; double alpha; double beta; } *arrows; struct Arrow *arrows_last; struct Arrow *arrows_to_update; struct Arrow *sorting_arrow; struct Arrow *sorting_next; int color_debug; int sorting; double world_x_size; double world_y_size; double speed_custom; struct Mechant { double x; double y; double z; double dx; double dy; double dz; double phi; double theta; double rho; double dphi; double dtheta; double drho; int type; struct Mechant *next; struct Mechant *prev; void (*update)(struct Mechant *mechant); double dist; } *mechants; struct Mechant *mechants_last; struct Particle { double x; double y; double z; double z_destination; double dx; double dy; double dz; int good; struct Particle *next; struct Particle *prev; struct Particle *next_update; struct Particle *prev_update; } *particles; struct Particle *particles_update; struct AudioPlayer { struct SoundSample { char *data; char *old_data; int size; int old_read_size; int read_size; int freq; int format; int bitStream; union soundFile { struct OggVorbis_File { void *datasource; int seekable; long offset; long end; struct ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; } oy; int links; long *offsets; long *dataoffsets; long *serialnos; long *pcmlengths; struct vorbis_info { int version; int channels; long rate; long bitrate_upper; long bitrate_nominal; long bitrate_lower; long bitrate_window; void *codec_setup; } *vi; struct vorbis_comment { char **user_comments; int *comment_lengths; int comments; char *vendor; } *vc; long pcm_offset; int ready_state; long current_serialno; int current_link; double bittrack; double samptrack; struct ogg_stream_state { unsigned char *body_data; long body_storage; long body_fill; long body_returned; int *lacing_vals; long *granule_vals; long lacing_storage; long lacing_fill; long lacing_packet; long lacing_returned; unsigned char header[282]; int header_fill; int e_o_s; int b_o_s; long serialno; long pageno; long packetno; long granulepos; } os; struct vorbis_dsp_state { int analysisp; struct vorbis_info *vi; float **pcm; float **pcmret; int pcm_storage; int pcm_current; int pcm_returned; int preextrapolate; int eofflag; long lW; long W; long nW; long centerW; long granulepos; long sequence; long glue_bits; long time_bits; long floor_bits; long res_bits; void *backend_state; } vd; struct vorbis_block { float **pcm; struct oggpack_buffer { long endbyte; int endbit; unsigned char *buffer; unsigned char *ptr; long storage; } opb; long lW; long W; long nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; struct vorbis_dsp_state *vd; void *localstore; long localtop; long localalloc; long totaluse; struct alloc_chain { void *ptr; struct alloc_chain *next; } *reap; long glue_bits; long time_bits; long floor_bits; long res_bits; void *internal; } vb; struct ov_callbacks { unsigned long (*read_func)(void *ptr, unsigned long size, unsigned long nmemb, void *datasource); int (*seek_func)(void *datasource, long offset, int whence); int (*close_func)(void *datasource); long (*tell_func)(void *datasource); } callbacks; } oggFile; } s_file; } *s1; char *next_file_path; char *now_playing; double time_buffer_offset; unsigned int source_id; unsigned int buffer_id[2]; unsigned int sound_buffer; } *audio; double audio_amplitude; double heart_beat; double heart_beat_time; double heart_beat_time_normalized; void (*update)(struct Game *game, int dt); void (*render)(struct Game *game); void (*HUD_render)(struct Game *game); int (*mechant_regeneration_type)(); double fire_value; int fire_state; double trigger_value; int trigger_state; int FIRST_SHOT; int weapon; int stereo; void (*trigger)(struct Game *game, int state); void (*fire)(struct Game *game, int state); } *

user_defined_types: struct Game { struct Camera *player; struct Arrow *arrows; struct Arrow *arrows_last; struct Arrow *arrows_to_update; struct Arrow *sorting_arrow; struct Arrow *sorting_next; int color_debug; int sorting; double world_x_size; double world_y_size; double speed_custom; struct Mechant *mechants; struct Mechant *mechants_last; struct Particle *particles; struct Particle *particles_update; struct AudioPlayer *audio; double audio_amplitude; double heart_beat; double heart_beat_time; double heart_beat_time_normalized; void (*update)(struct Game *game, int dt); void (*render)(struct Game *game); void (*HUD_render)(struct Game *game); int (*mechant_regeneration_type)(); double fire_value; int fire_state; double trigger_value; int trigger_state; int FIRST_SHOT; int weapon; int stereo; void (*trigger)(struct Game *game, int state); void (*fire)(struct Game *game, int state); }

user_defined_types: struct AudioPlayer { struct SoundSample *s1; char *next_file_path; char *now_playing; double time_buffer_offset; unsigned int source_id; unsigned int buffer_id[2]; unsigned int sound_buffer; }

user_defined_types: struct SoundSample { char *data; char *old_data; int size; int old_read_size; int read_size; int freq; int format; int bitStream; union soundFile s_file; }

user_defined_types: union soundFile { struct OggVorbis_File oggFile; }

user_defined_types: struct OggVorbis_File { void *datasource; int seekable; long offset; long end; struct ogg_sync_state oy; int links; long *offsets; long *dataoffsets; long *serialnos; long *pcmlengths; struct vorbis_info *vi; struct vorbis_comment *vc; long pcm_offset; int ready_state; long current_serialno; int current_link; double bittrack; double samptrack; struct ogg_stream_state os; struct vorbis_dsp_state vd; struct vorbis_block vb; struct ov_callbacks callbacks; }

user_defined_types: struct vorbis_block { float **pcm; struct oggpack_buffer opb; long lW; long W; long nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; struct vorbis_dsp_state *vd; void *localstore; long localtop; long localalloc; long totaluse; struct alloc_chain *reap; long glue_bits; long time_bits; long floor_bits; long res_bits; void *internal; }


original_code:
void ingame_level1_update(Game* game,int dt){
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_loop_far.ogg")){
  game->player->z=-100;
  game->player->dz=0;
 }
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level1.ogg")){
  audioplayer_set_next(game->audio,"music/Goto80_gopho_level2.ogg");
  if(audioplayer_getTime(game->audio)<6.7){
  }else if(audioplayer_getTime(game->audio)<7.65){
   double t=(audioplayer_getTime(game->audio)-6.7)/(7.65-6.7);
   glFogf(0x0B63, 20);
   glFogf(0x0B64, 50+t*250);
  }else{
   if(!landed){
    for(int i=0;i<20;i++){
     game_add_explosion(game,1,50,
      -game->player->x + random(0,20),
      -game->player->y + random(0,20),
      -game->player->z + random(0,20),
      -0.003*game->player->dx,
      -0.003*game->player->dy,
      0.);
    }
    landed=1;
   }
  }
  if (audioplayer_getTime(game->audio)>37.30 &&
   audioplayer_getTime(game->audio)<37.60){
   GLfloat fogColor[4]= {0,0, 0, 1};
   glFogfv(0x0B66, fogColor);
   glClearColor(0,0,0,1);
  }else
  if (audioplayer_getTime(game->audio)>37.60 &&
   audioplayer_getTime(game->audio)<37.85){
   GLfloat fogColor[4]= {1,0, 0, 1};
   glFogfv(0x0B66, fogColor);
   glClearColor(1,0,0,1);
  }else
  if (audioplayer_getTime(game->audio)>37.85){
   GLfloat fogColor[4]= {0,0, 0, 1};
   glFogfv(0x0B66, fogColor);
   game->weapon=4;
   glClearColor(0,0,0,1);
  }
 }
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level2.ogg")){
  ingame_level2_setup(game);
 }
}

canonical_original_code:
void ingame_level1_update(struct Game *game, int dt){
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_loop_far.ogg")){
  game->player->z=-100;
  game->player->dz=0;
 }
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level1.ogg")){
  audioplayer_set_next(game->audio,"music/Goto80_gopho_level2.ogg");
  if(audioplayer_getTime(game->audio)<6.7){
  }else if(audioplayer_getTime(game->audio)<7.65){
   double t = (audioplayer_getTime(game->audio)-6.7)/(7.65-6.7);
   glFogf(0x0B63, 20);
   glFogf(0x0B64, 50+t*250);
  }else{
   if(!landed){
    for(int i = 0;i<20;i++){
     game_add_explosion(game,1,50,
      -game->player->x + random(0,20),
      -game->player->y + random(0,20),
      -game->player->z + random(0,20),
      -0.003*game->player->dx,
      -0.003*game->player->dy,
      0.);
    }
    landed=1;
   }
  }
  if (audioplayer_getTime(game->audio)>37.30 &&
   audioplayer_getTime(game->audio)<37.60){
   float fogColor[4] = {0,0, 0, 1};
   glFogfv(0x0B66, fogColor);
   glClearColor(0,0,0,1);
  }else
  if (audioplayer_getTime(game->audio)>37.60 &&
   audioplayer_getTime(game->audio)<37.85){
   float fogColor[4] = {1,0, 0, 1};
   glFogfv(0x0B66, fogColor);
   glClearColor(1,0,0,1);
  }else
  if (audioplayer_getTime(game->audio)>37.85){
   float fogColor[4] = {0,0, 0, 1};
   glFogfv(0x0B66, fogColor);
   game->weapon=4;
   glClearColor(0,0,0,1);
  }
 }
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level2.ogg")){
  ingame_level2_setup(game);
 }
}

variable_types: dt int

variable_types: t double

variable_types: i int

variable_types:
fogColor
float [4]

user_defined_types: struct Camera { struct Game *game; double theta; double phi; double rho; double dtheta; double dphi; double drho; double ddtheta; double ddphi; double ddrho; double x; double y; double z; double fake_y; double fake_z; double dx; double dy; double dz; double ddx; double ddy; double ddz; double mConvergence; double mEyeSeparation; double mAspectRatio; double mFOV; double mNearClippingDistance; double mFarClippingDistance; int avance; double angle; double x_culling; double y_culling; }

user_defined_types: struct Arrow { double x; double y; double z; double dx; double dy; double dz; struct Arrow *next; struct Arrow *prev; struct Arrow *next_update; double v; double dist; double alpha; double beta; }

user_defined_types: struct Mechant { double x; double y; double z; double dx; double dy; double dz; double phi; double theta; double rho; double dphi; double dtheta; double drho; int type; struct Mechant *next; struct Mechant *prev; void (*update)(struct Mechant *mechant); double dist; }

user_defined_types: struct Particle { double x; double y; double z; double z_destination; double dx; double dy; double dz; int good; struct Particle *next; struct Particle *prev; struct Particle *next_update; struct Particle *prev_update; }

user_defined_types: struct ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; }

user_defined_types: struct ogg_stream_state { unsigned char *body_data; long body_storage; long body_fill; long body_returned; int *lacing_vals; long *granule_vals; long lacing_storage; long lacing_fill; long lacing_packet; long lacing_returned; unsigned char header[282]; int header_fill; int e_o_s; int b_o_s; long serialno; long pageno; long packetno; long granulepos; }

user_defined_types: struct vorbis_dsp_state { int analysisp; struct vorbis_info *vi; float **pcm; float **pcmret; int pcm_storage; int pcm_current; int pcm_returned; int preextrapolate; int eofflag; long lW; long W; long nW; long centerW; long granulepos; long sequence; long glue_bits; long time_bits; long floor_bits; long res_bits; void *backend_state; }

user_defined_types: struct ov_callbacks { unsigned long (*read_func)(void *ptr, unsigned long size, unsigned long nmemb, void *datasource); int (*seek_func)(void *datasource, long offset, int whence); int (*close_func)(void *datasource); long (*tell_func)(void *datasource); }

user_defined_types: struct vorbis_info { int version; int channels; long rate; long bitrate_upper; long bitrate_nominal; long bitrate_lower; long bitrate_window; void *codec_setup; }

user_defined_types: struct vorbis_comment { char **user_comments; int *comment_lengths; int comments; char *vendor; }

user_defined_types: struct oggpack_buffer { long endbyte; int endbit; unsigned char *buffer; unsigned char *ptr; long storage; }

user_defined_types: struct alloc_chain { void *ptr; struct alloc_chain *next; }


original_code:
void level1_spawn_mechants(Game* game){
 Mechant * mechant;
 for(int i=-10;i<10;i++){
  for(int j=-10;j<10;j++){
   mechant = malloc(sizeof(Mechant));
   double rayon = random(200,120);
   double angle = random(0,2*3.14159265359);
   mechant->x=rayon*cos(angle);
   mechant->y=rayon*sin(angle);
   mechant->z=0;
   mechant->dx=random(0,.05);
   mechant->dy=random(0,.05);
   mechant->dz=0;
   mechant->rho=0;
   mechant->theta=0;
   mechant->phi=random(0,360);
   mechant->drho=0;
   mechant->dtheta=0;
   mechant->dphi=random(0,.5);
   mechant->update=mechant_update_dummy;
   mechant->type=0;
   game_insert_Mechant(game, mechant);
  }
 }
}

canonical_original_code:
void level1_spawn_mechants(struct Game *game){
 struct Mechant *mechant;
 for(int i = -10;i<10;i++){
  for(int j = -10;j<10;j++){
   mechant = malloc(sizeof(Mechant));
   double rayon = random(200,120);
   double angle = random(0,2*3.14159265359);
   mechant->x=rayon*cos(angle);
   mechant->y=rayon*sin(angle);
   mechant->z=0;
   mechant->dx=random(0,.05);
   mechant->dy=random(0,.05);
   mechant->dz=0;
   mechant->rho=0;
   mechant->theta=0;
   mechant->phi=random(0,360);
   mechant->drho=0;
   mechant->dtheta=0;
   mechant->dphi=random(0,.5);
   mechant->update=mechant_update_dummy;
   mechant->type=0;
   game_insert_Mechant(game, mechant);
  }
 }
}

variable_types: struct Mechant { double x; double y; double z; double dx; double dy; double dz; double phi; double theta; double rho; double dphi; double dtheta; double drho; int type; struct Mechant *next; struct Mechant *prev; void (*update)(struct Mechant *mechant); double dist; } *

variable_types: j int

variable_types: rayon double

variable_types: angle double

user_defined_types: struct Game { struct Camera *player; struct Arrow *arrows; struct Arrow *arrows_last; struct Arrow *arrows_to_update; struct Arrow *sorting_arrow; struct Arrow *sorting_next; int color_debug; int sorting; double world_x_size; double world_y_size; double speed_custom; struct Mechant *mechants; struct Mechant *mechants_last; struct Particle *particles; struct Particle *particles_update; struct AudioPlayer *audio; double audio_amplitude; double heart_beat; double heart_beat_time; double heart_beat_time_normalized; void (*update)(struct Game *game, int dt); void (*render)(struct Game *game); void (*HUD_render)(struct Game *game); int (*mechant_regeneration_type)(); double fire_value; int fire_state; double trigger_value; int trigger_state; int FIRST_SHOT; int weapon; int stereo; void (*trigger)(struct Game *game, int state); void (*fire)(struct Game *game, int state); }

user_defined_types: struct AudioPlayer { struct SoundSample *s1; char *next_file_path; char *now_playing; double time_buffer_offset; unsigned int source_id; unsigned int buffer_id[2]; unsigned int sound_buffer; }


decompiled_code:
__int64 __fastcall ingame_level1_setup(__int64 a1)
{
__int64 v2[3]; // [rsp+0h] [rbp-20h] BYREF

audioplayer_set_next(*(_QWORD *)(a1 + 112), "music/Goto80_gopho_level1.ogg");
glClearColor(1.0, COERCE_DOUBLE((unsigned __int64)LC15));
*(_QWORD *)(a1 + 152) = ingame_level1_update;
*(_QWORD *)(a1 + 160) = ingame_level1_render;
*(_DWORD *)(a1 + 216) = 1;
set_time_(0.0, 1.0, 1.0);
glEnable(2912LL);
glFogi(2917LL, 9729LL);
glFogf(2915LL, 20.0);
glFogf(2916LL, 300.0);
v2[0] = 0x3F8000003F800000LL;
v2[1] = 0x3F8000003F800000LL;
glFogfv(2918LL, v2);
glFogf(2914LL, 0.34999999);
glHint(3156LL, 4352LL);
glFogf(2915LL, 20.0);
glFogf(2916LL, 50.0);
return level1_spawn_mechants(a1);
}

original_code:
void ingame_level1_setup(Game* game){
 audioplayer_set_next(game->audio,"music/Goto80_gopho_level1.ogg");
 glClearColor(1,1,1,1);
 game->update=ingame_level1_update;
 game->render=ingame_level1_render;
 game->weapon=1;
 set_time_(0);
 glEnable(0x0B60);
 glFogi(0x0B65, 0x2601);
 glFogf(0x0B63, 20);
 glFogf(0x0B64, 300);
 GLfloat fogColor[4]= {1,1, 1, 1};
 glFogfv(0x0B66, fogColor);
 glFogf(0x0B62, 0.35f);
 glHint(0x0C54, 0x1100);
 glFogf(0x0B63, 20);
 glFogf(0x0B64, 50);
 level1_spawn_mechants(game);
}

canonical_original_code:
void ingame_level1_setup(struct Game *game){
 audioplayer_set_next(game->audio,"music/Goto80_gopho_level1.ogg");
 glClearColor(1,1,1,1);
 game->update=ingame_level1_update;
 game->render=ingame_level1_render;
 game->weapon=1;
 set_time_(0);
 glEnable(0x0B60);
 glFogi(0x0B65, 0x2601);
 glFogf(0x0B63, 20);
 glFogf(0x0B64, 300);
 float fogColor[4] = {1,1, 1, 1};
 glFogfv(0x0B66, fogColor);
 glFogf(0x0B62, 0.35f);
 glHint(0x0C54, 0x1100);
 glFogf(0x0B63, 20);
 glFogf(0x0B64, 50);
 level1_spawn_mechants(game);
}

user_defined_types: struct SoundSample { char *data; char *old_data; int size; int old_read_size; int read_size; int freq; int format; int bitStream; union soundFile s_file; }

user_defined_types: union soundFile { struct OggVorbis_File oggFile; }


variable_types: struct Camera { struct Game { struct Camera *player; struct Arrow { double x; double y; double z; double dx; double dy; double dz; struct Arrow *next; struct Arrow *prev; struct Arrow *next_update; double v; double dist; double alpha; double beta; } *arrows; struct Arrow *arrows_last; struct Arrow *arrows_to_update; struct Arrow *sorting_arrow; struct Arrow *sorting_next; int color_debug; int sorting; double world_x_size; double world_y_size; double speed_custom; struct Mechant { double x; double y; double z; double dx; double dy; double dz; double phi; double theta; double rho; double dphi; double dtheta; double drho; int type; struct Mechant *next; struct Mechant *prev; void (*update)(struct Mechant *mechant); double dist; } *mechants; struct Mechant *mechants_last; struct Particle { double x; double y; double z; double z_destination; double dx; double dy; double dz; int good; struct Particle *next; struct Particle *prev; struct Particle *next_update; struct Particle *prev_update; } *particles; struct Particle *particles_update; struct AudioPlayer { struct SoundSample { char *data; char *old_data; int size; int old_read_size; int read_size; int freq; int format; int bitStream; union soundFile { struct OggVorbis_File { void *datasource; int seekable; long offset; long end; struct ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; } oy; int links; long *offsets; long *dataoffsets; long *serialnos; long *pcmlengths; struct vorbis_info { int version; int channels; long rate; long bitrate_upper; long bitrate_nominal; long bitrate_lower; long bitrate_window; void *codec_setup; } *vi; struct vorbis_comment { char **user_comments; int *comment_lengths; int comments; char *vendor; } *vc; long pcm_offset; int ready_state; long current_serialno; int current_link; double bittrack; double samptrack; struct ogg_stream_state { unsigned char *body_data; long body_storage; long body_fill; long body_returned; int *lacing_vals; long *granule_vals; long lacing_storage; long lacing_fill; long lacing_packet; long lacing_returned; unsigned char header[282]; int header_fill; int e_o_s; int b_o_s; long serialno; long pageno; long packetno; long granulepos; } os; struct vorbis_dsp_state { int analysisp; struct vorbis_info *vi; float **pcm; float **pcmret; int pcm_storage; int pcm_current; int pcm_returned; int preextrapolate; int eofflag; long lW; long W; long nW; long centerW; long granulepos; long sequence; long glue_bits; long time_bits; long floor_bits; long res_bits; void *backend_state; } vd; struct vorbis_block { float **pcm; struct oggpack_buffer { long endbyte; int endbit; unsigned char *buffer; unsigned char *ptr; long storage; } opb; long lW; long W; long nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; struct vorbis_dsp_state *vd; void *localstore; long localtop; long localalloc; long totaluse; struct alloc_chain { void *ptr; struct alloc_chain *next; } *reap; long glue_bits; long time_bits; long floor_bits; long res_bits; void *internal; } vb; struct ov_callbacks { unsigned long (*read_func)(void *ptr, unsigned long size, unsigned long nmemb, void *datasource); int (*seek_func)(void *datasource, long offset, int whence); int (*close_func)(void *datasource); long (*tell_func)(void *datasource); } callbacks; } oggFile; } s_file; } *s1; char *next_file_path; char *now_playing; double time_buffer_offset; unsigned int source_id; unsigned int buffer_id[2]; unsigned int sound_buffer; } *audio; double audio_amplitude; double heart_beat; double heart_beat_time; double heart_beat_time_normalized; void (*update)(struct Game *game, int dt); void (*render)(struct Game *game); void (*HUD_render)(struct Game *game); int (*mechant_regeneration_type)(); double fire_value; int fire_state; double trigger_value; int trigger_state; int FIRST_SHOT; int weapon; int stereo; void (*trigger)(struct Game *game, int state); void (*fire)(struct Game *game, int state); } *game; double theta; double phi; double rho; double dtheta; double dphi; double drho; double ddtheta; double ddphi; double ddrho; double x; double y; double z; double fake_y; double fake_z; double dx; double dy; double dz; double ddx; double ddy; double ddz; double mConvergence; double mEyeSeparation; double mAspectRatio; double mFOV; double mNearClippingDistance; double mFarClippingDistance; int avance; double angle; double x_culling; double y_culling; } *

variable_types: ddx double

variable_types: ddy double

variable_types: ddz double

user_defined_types: struct OggVorbis_File { void *datasource; int seekable; long offset; long end; struct ogg_sync_state oy; int links; long *offsets; long *dataoffsets; long *serialnos; long *pcmlengths; struct vorbis_info *vi; struct vorbis_comment *vc; long pcm_offset; int ready_state; long current_serialno; int current_link; double bittrack; double samptrack; struct ogg_stream_state os; struct vorbis_dsp_state vd; struct vorbis_block vb; struct ov_callbacks callbacks; }

user_defined_types: struct vorbis_block { float **pcm; struct oggpack_buffer opb; long lW; long W; long nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; struct vorbis_dsp_state *vd; void *localstore; long localtop; long localalloc; long totaluse; struct alloc_chain *reap; long glue_bits; long time_bits; long floor_bits; long res_bits; void *internal; }


decompiled_code:
void __fastcall camera_rotate(double *a1, double a2, double a3, double a4)
{
a1[4] = a2 + a1[4];
a1[5] = a1[5] + a3;
a1[6] = a3 * 0.25 + a4 + a1[6];
}

original_code:
void camera_rotate (Camera* c,double dtheta ,double dphi ,double drho ){
 c->dtheta+=dtheta;
 c->dphi+=dphi;
 c->drho+=drho + dphi/4.;
}

canonical_original_code:
void camera_rotate(struct Camera *c, double dtheta, double dphi, double drho){
 c->dtheta+=dtheta;
 c->dphi+=dphi;
 c->drho+=drho + dphi/4.;
}

variable_types: dtheta double

variable_types: dphi double

variable_types: drho double

user_defined_types: struct Camera { struct Game *game; double theta; double phi; double rho; double dtheta; double dphi; double drho; double ddtheta; double ddphi; double ddrho; double x; double y; double z; double fake_y; double fake_z; double dx; double dy; double dz; double ddx; double ddy; double ddz; double mConvergence; double mEyeSeparation; double mAspectRatio; double mFOV; double mNearClippingDistance; double mFarClippingDistance; int avance; double angle; double x_culling; double y_culling; }

user_defined_types: struct Arrow { double x; double y; double z; double dx; double dy; double dz; struct Arrow *next; struct Arrow *prev; struct Arrow *next_update; double v; double dist; double alpha; double beta; }


decompiled_code:
void __fastcall camera_rotate_acc(double *a1, double a2, double a3, double a4)
{
a1[7] = a2 + a1[7];
a1[8] = a1[8] + a3;
a1[9] = a3 * 0.25 + a4 + a1[9];
}

original_code:
void camera_rotate_acc(Camera* c,double ddtheta,double ddphi,double ddrho){
 c->ddtheta+=ddtheta;
 c->ddphi+=ddphi;
 c->ddrho+=ddrho + ddphi/4.;
}

canonical_original_code:
void camera_rotate_acc(struct Camera *c, double ddtheta, double ddphi, double ddrho){
 c->ddtheta+=ddtheta;
 c->ddphi+=ddphi;
 c->ddrho+=ddrho + ddphi/4.;
}

variable_types: ddtheta double

variable_types: ddphi double

variable_types: ddrho double

user_defined_types: struct Mechant { double x; double y; double z; double dx; double dy; double dz; double phi; double theta; double rho; double dphi; double dtheta; double drho; int type; struct Mechant *next; struct Mechant *prev; void (*update)(struct Mechant *mechant); double dist; }

user_defined_types: struct Particle { double x; double y; double z; double z_destination; double dx; double dy; double dz; int good; struct Particle *next; struct Particle *prev; struct Particle *next_update; struct Particle *prev_update; }


decompiled_code:
_QWORD *new_Camera()
{
_QWORD *result; // rax

result = malloc(0xF8uLL);
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
result[4] = 0LL;
result[5] = 0LL;
result[6] = 0LL;
result[7] = 0LL;
result[8] = 0LL;
result[9] = 0LL;
result[10] = 0LL;
result[11] = 0LL;
result[12] = 0LL;
result[15] = 0LL;
result[16] = 0LL;
result[17] = 0LL;
result[13] = 0LL;
result[14] = 0LL;
result[18] = 0LL;
result[19] = 0LL;
result[20] = 0LL;
result[22] = LC8;
result[23] = LC9;
result[24] = LC10;
result[25] = LC11;
*((_DWORD *)result + 54) = 0;
result[21] = LC7;
result[26] = LC7;
return result;
}

canonical_decompiled_code:
_QWORD *func3()
{
_QWORD *result; // rax

result = malloc(0xF8uLL);
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
result[4] = 0LL;
result[5] = 0LL;
result[6] = 0LL;
result[7] = 0LL;
result[8] = 0LL;
result[9] = 0LL;
result[10] = 0LL;
result[11] = 0LL;
result[12] = 0LL;
result[15] = 0LL;
result[16] = 0LL;
result[17] = 0LL;
result[13] = 0LL;
result[14] = 0LL;
result[18] = 0LL;
result[19] = 0LL;
result[20] = 0LL;
result[22] = LC8;
result[23] = LC9;
result[24] = LC10;
result[25] = LC11;
*((_DWORD *)result + 54) = 0;
result[21] = LC7;
result[26] = LC7;
return result;
}

original_code:
Camera* new_Camera(){
 Camera* c= malloc(sizeof(Camera));
 c->theta=0;
 c->phi=0;
 c->rho=0;
 c->dtheta=0;
 c->dphi=0;
 c->drho=0;
 c->ddtheta=0;
 c->ddphi=0;
 c->ddrho=0;
 c->x=0;
 c->y=0;
 c->z=0;
 c->dx=0;
 c->dy=0;
 c->dz=0;
 c->fake_y=0;
 c->fake_z=0;
 c->ddx=0;
 c->ddy=0;
 c->ddz=0;
 c->mConvergence=1000;
 c->mEyeSeparation=.3;
 c->mAspectRatio=4./3;
 c->mFOV=90;
 c->mNearClippingDistance=.01;
 c->mFarClippingDistance=1000.;
 c->avance=0;
 return c;
}

canonical_original_code:
struct Camera *new_Camera(){
 struct Camera *c = malloc(sizeof(Camera));
 c->theta=0;
 c->phi=0;
 c->rho=0;
 c->dtheta=0;
 c->dphi=0;
 c->drho=0;
 c->ddtheta=0;
 c->ddphi=0;
 c->ddrho=0;
 c->x=0;
 c->y=0;
 c->z=0;
 c->dx=0;
 c->dy=0;
 c->dz=0;
 c->fake_y=0;
 c->fake_z=0;
 c->ddx=0;
 c->ddy=0;
 c->ddz=0;
 c->mConvergence=1000;
 c->mEyeSeparation=.3;
 c->mAspectRatio=4./3;
 c->mFOV=90;
 c->mNearClippingDistance=.01;
 c->mFarClippingDistance=1000.;
 c->avance=0;
 return c;
}

return_type: struct Camera { struct Game { struct Camera *player; struct Arrow { double x; double y; double z; double dx; double dy; double dz; struct Arrow *next; struct Arrow *prev; struct Arrow *next_update; double v; double dist; double alpha; double beta; } *arrows; struct Arrow *arrows_last; struct Arrow *arrows_to_update; struct Arrow *sorting_arrow; struct Arrow *sorting_next; int color_debug; int sorting; double world_x_size; double world_y_size; double speed_custom; struct Mechant { double x; double y; double z; double dx; double dy; double dz; double phi; double theta; double rho; double dphi; double dtheta; double drho; int type; struct Mechant *next; struct Mechant *prev; void (*update)(struct Mechant *mechant); double dist; } *mechants; struct Mechant *mechants_last; struct Particle { double x; double y; double z; double z_destination; double dx; double dy; double dz; int good; struct Particle *next; struct Particle *prev; struct Particle *next_update; struct Particle *prev_update; } *particles; struct Particle *particles_update; struct AudioPlayer { struct SoundSample { char *data; char *old_data; int size; int old_read_size; int read_size; int freq; int format; int bitStream; union soundFile { struct OggVorbis_File { void *datasource; int seekable; long offset; long end; struct ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; } oy; int links; long *offsets; long *dataoffsets; long *serialnos; long *pcmlengths; struct vorbis_info { int version; int channels; long rate; long bitrate_upper; long bitrate_nominal; long bitrate_lower; long bitrate_window; void *codec_setup; } *vi; struct vorbis_comment { char **user_comments; int *comment_lengths; int comments; char *vendor; } *vc; long pcm_offset; int ready_state; long current_serialno; int current_link; double bittrack; double samptrack; struct ogg_stream_state { unsigned char *body_data; long body_storage; long body_fill; long body_returned; int *lacing_vals; long *granule_vals; long lacing_storage; long lacing_fill; long lacing_packet; long lacing_returned; unsigned char header[282]; int header_fill; int e_o_s; int b_o_s; long serialno; long pageno; long packetno; long granulepos; } os; struct vorbis_dsp_state { int analysisp; struct vorbis_info *vi; float **pcm; float **pcmret; int pcm_storage; int pcm_current; int pcm_returned; int preextrapolate; int eofflag; long lW; long W; long nW; long centerW; long granulepos; long sequence; long glue_bits; long time_bits; long floor_bits; long res_bits; void *backend_state; } vd; struct vorbis_block { float **pcm; struct oggpack_buffer { long endbyte; int endbit; unsigned char *buffer; unsigned char *ptr; long storage; } opb; long lW; long W; long nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; struct vorbis_dsp_state *vd; void *localstore; long localtop; long localalloc; long totaluse; struct alloc_chain { void *ptr; struct alloc_chain *next; } *reap; long glue_bits; long time_bits; long floor_bits; long res_bits; void *internal; } vb; struct ov_callbacks { unsigned long (*read_func)(void *ptr, unsigned long size, unsigned long nmemb, void *datasource); int (*seek_func)(void *datasource, long offset, int whence); int (*close_func)(void *datasource); long (*tell_func)(void *datasource); } callbacks; } oggFile; } s_file; } *s1; char *next_file_path; char *now_playing; double time_buffer_offset; unsigned int source_id; unsigned int buffer_id[2]; unsigned int sound_buffer; } *audio; double audio_amplitude; double heart_beat; double heart_beat_time; double heart_beat_time_normalized; void (*update)(struct Game *game, int dt); void (*render)(struct Game *game); void (*HUD_render)(struct Game *game); int (*mechant_regeneration_type)(); double fire_value; int fire_state; double trigger_value; int trigger_state; int FIRST_SHOT; int weapon; int stereo; void (*trigger)(struct Game *game, int state); void (*fire)(struct Game *game, int state); } *game; double theta; double phi; double rho; double dtheta; double dphi; double drho; double ddtheta; double ddphi; double ddrho; double x; double y; double z; double fake_y; double fake_z; double dx; double dy; double dz; double ddx; double ddy; double ddz; double mConvergence; double mEyeSeparation; double mAspectRatio; double mFOV; double mNearClippingDistance; double mFarClippingDistance; int avance; double angle; double x_culling; double y_culling; } *


decompiled_code:
__int64 __fastcall camera_HUD(double *a1, __int64 a2)
{
glMatrixMode(5889LL);
glLoadIdentity();
gluPerspective(a1[24], a1[23], a1[25], a1[26]);
glMatrixMode(5888LL);
glLoadIdentity();
gluLookAt(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
return (*(__int64 (__fastcall **)(_QWORD, __int64))(*(_QWORD *)a1 + 168LL))(*(_QWORD *)a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(double *a1, __int64 a2)
{
glMatrixMode(5889LL);
glLoadIdentity();
gluPerspective(a1[24], a1[23], a1[25], a1[26]);
glMatrixMode(5888LL);
glLoadIdentity();
gluLookAt(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
return (*(__int64 (__fastcall **)(_QWORD, __int64))(*(_QWORD *)a1 + 168LL))(*(_QWORD *)a1, a2);
}

original_code:
void camera_HUD(Camera* c){
 glMatrixMode(0x1701);
 glLoadIdentity();
 gluPerspective(c->mFOV, c->mAspectRatio, c->mNearClippingDistance, c->mFarClippingDistance);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 c->game->HUD_render(c->game);
}

canonical_original_code:
void camera_HUD(struct Camera *c){
 glMatrixMode(0x1701);
 glLoadIdentity();
 gluPerspective(c->mFOV, c->mAspectRatio, c->mNearClippingDistance, c->mFarClippingDistance);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 c->game->HUD_render(c->game);
}

user_defined_types: struct ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; }

user_defined_types: struct ogg_stream_state { unsigned char *body_data; long body_storage; long body_fill; long body_returned; int *lacing_vals; long *granule_vals; long lacing_storage; long lacing_fill; long lacing_packet; long lacing_returned; unsigned char header[282]; int header_fill; int e_o_s; int b_o_s; long serialno; long pageno; long packetno; long granulepos; }


original_code:
void camera_look(Camera* c){
 double vitesse_avant =
      sqrt(
       pow(
        c->dx*cos(-c->phi/360*2*3.14159265359)
        ,2)
       +
       pow(
        c->dx*sin(-c->phi/360*2*3.14159265359)
        ,2)
       );
 glMatrixMode(0x1701);
 glLoadIdentity();
 gluPerspective(c->mFOV-hyperbolicLimit(.06*vitesse_avant,60), c->mAspectRatio, c->mNearClippingDistance, c->mFarClippingDistance);
}

canonical_original_code:
void camera_look(struct Camera *c){
 double vitesse_avant = sqrt(
       pow(
        c->dx*cos(-c->phi/360*2*3.14159265359)
        ,2)
       +
       pow(
        c->dx*sin(-c->phi/360*2*3.14159265359)
        ,2)
       );
 glMatrixMode(0x1701);
 glLoadIdentity();
 gluPerspective(c->mFOV-hyperbolicLimit(.06*vitesse_avant,60), c->mAspectRatio, c->mNearClippingDistance, c->mFarClippingDistance);
}

user_defined_types: struct vorbis_dsp_state { int analysisp; struct vorbis_info *vi; float **pcm; float **pcmret; int pcm_storage; int pcm_current; int pcm_returned; int preextrapolate; int eofflag; long lW; long W; long nW; long centerW; long granulepos; long sequence; long glue_bits; long time_bits; long floor_bits; long res_bits; void *backend_state; }

user_defined_types: struct ov_callbacks { unsigned long (*read_func)(void *ptr, unsigned long size, unsigned long nmemb, void *datasource); int (*seek_func)(void *datasource, long offset, int whence); int (*close_func)(void *datasource); long (*tell_func)(void *datasource); }