original_code:
int mms_continue(const fm_index *fmi, const char *pattern, int len,
   int *len_p, int cutoff, int lastpos) {
  int start, end, i, j, pos;
  start = fmi->C[pattern[len-1]];
  end = fmi->C[pattern[len-1]+1];
  for (i = len-2; i >= 0; --i) {
    if (end <= start) {
      *len_p = len - i + 1;
      if (len - i > cutoff) {
 for (j = start; j < end; ++j) {
   pos = unc_sa(fmi, j) + 1;
   if (lastpos - (pos + (len - i)) > 3) {
     return pos;
   }
 }
      }
      return -1;
    }
    if (len - i == cutoff) {
      for (j = start; j < end; ++j) {
 pos = unc_sa(fmi, j);
 fprintf(stderr, "%d\n", lastpos - (pos+cutoff));
 if ((pos < lastpos) && (lastpos - (pos + cutoff) <= 6)) {
   start = j;
   end = j+1;
   printf("Should be right?\n");
   break;
 }
      }
    }
    start = fmi->C[pattern[i]] + rank(fmi, pattern[i], start);
    end = fmi->C[pattern[i]] + rank(fmi, pattern[i], end);
  }
  *len_p = len;
  return unc_sa(fmi, start);
}

canonical_original_code:
int mms_continue(struct _fmi *fmi, char *pattern, int len, int *len_p, int cutoff, int lastpos) {
  int start; int end; int i; int j; int pos;
  start = fmi->C[pattern[len-1]];
  end = fmi->C[pattern[len-1]+1];
  for (i = len-2; i >= 0; --i) {
    if (end <= start) {
      *len_p = len - i + 1;
      if (len - i > cutoff) {
 for (j = start; j < end; ++j) {
   pos = unc_sa(fmi, j) + 1;
   if (lastpos - (pos + (len - i)) > 3) {
     return pos;
   }
 }
      }
      return -1;
    }
    if (len - i == cutoff) {
      for (j = start; j < end; ++j) {
 pos = unc_sa(fmi, j);
 fprintf(stderr, "%d\n", lastpos - (pos+cutoff));
 if ((pos < lastpos) && (lastpos - (pos + cutoff) <= 6)) {
   start = j;
   end = j+1;
   printf("Should be right?\n");
   break;
 }
      }
    }
    start = fmi->C[pattern[i]] + rank(fmi, pattern[i], start);
    end = fmi->C[pattern[i]] + rank(fmi, pattern[i], end);
  }
  *len_p = len;
  return unc_sa(fmi, start);
}

variable_types: struct _fmi { char *bwt; int *idxs; int **rank_index; unsigned char *lookup; int endloc; int C[5]; int len; } *

variable_types:
pattern
char *

variable_types: len int


repo: yichizhng/bwt

decompiled_code:
int __fastcall rna_seq(__int64 a1, __int64 a2, int a3)
{
int v3; // ebx
unsigned int i; // er13
int v5; // ebx
int v7; // ebx
int v8[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v3 = a3;
for ( i = mms_search(a1, a2, a3, v8, 14); i == -1 && v3 > 14; i = mms_search(a1, a2, v3, v8, 14) )
--v3;
v5 = v3 - v8[0];
if ( v5 > 18 )
{
while ( 1 )
{
v7 = v5 - 3;
if ( (unsigned int)mms_continue(a1, a2, v7, v8, 10, i) == -1 )
break;
v5 = v7 - v8[0];
LABEL_10:
if ( v5 <= 18 )
return printf("%d ", i);
}
while ( v7 > 14 )
{
if ( (unsigned int)mms_gap(a1, a2, --v7, v8) != -1 )
{
v5 = v7 - v8[0];
goto LABEL_10;
}
}
}
return printf("%d ", i);
}

original_code:
void rna_seq(const fm_index *fmi, const char *pattern, int len) {
  int i, mmslen, mmspos, genpos, nextpos;
  i = len;
  mmspos = mms_search(fmi, pattern, i, &mmslen, 14);
  while ((mmspos == -1) && i > 14) {
    --i;
    mmspos = mms_search(fmi, pattern, i, &mmslen, 14);
  }
  i -= mmslen;
  while (i > 18) {
    genpos = mmspos;
    i -= 3;
    nextpos = mms_continue(fmi, pattern, i, &mmslen, 10, genpos);
    if (nextpos != -1) {
      i -= mmslen;
    }
    else {
      while (i > 14) {
 --i;
 nextpos = mms_gap(fmi, pattern, i, &mmslen, 14, genpos);
 if (nextpos != -1) {
   i -= mmslen;
   break;
 }
      }
    }
  }
  printf("%d ", mmspos);
}

canonical_original_code:
void rna_seq(struct _fmi *fmi, char *pattern, int len) {
  int i; int mmslen; int mmspos; int genpos; int nextpos;
  i = len;
  mmspos = mms_search(fmi, pattern, i, &mmslen, 14);
  while ((mmspos == -1) && i > 14) {
    --i;
    mmspos = mms_search(fmi, pattern, i, &mmslen, 14);
  }
  i -= mmslen;
  while (i > 18) {
    genpos = mmspos;
    i -= 3;
    nextpos = mms_continue(fmi, pattern, i, &mmslen, 10, genpos);
    if (nextpos != -1) {
      i -= mmslen;
    }
    else {
      while (i > 14) {
 --i;
 nextpos = mms_gap(fmi, pattern, i, &mmslen, 14, genpos);
 if (nextpos != -1) {
   i -= mmslen;
   break;
 }
      }
    }
  }
  printf("%d ", mmspos);
}

variable_types: i int

variable_types: mmslen int

variable_types: mmspos int

variable_types: genpos int

variable_types: nextpos int

return_type: void

user_defined_types: struct _fmi { char *bwt; int *idxs; int **rank_index; unsigned char *lookup; int endloc; int C[5]; int len; }


decompiled_code:
_QWORD *stack_make()
{
_DWORD *v0; // rax
_QWORD *v1; // rbx
void *v2; // rbp
void *v3; // r12

v0 = malloc(0x18uLL);
v1 = v0;
if ( v0 )
{
*v0 = 0;
v0[1] = 10;
v2 = malloc(0x28uLL);
v1[1] = v2;
if ( v2 )
{
v3 = malloc(0xAuLL);
v1[2] = v3;
if ( !v3 )
{
free(v2);
free(v1);
v1 = 0LL;
}
}
else
{
free(v1);
v1 = 0LL;
}
}
return v1;
}

canonical_decompiled_code:
_QWORD *func0()
{
_DWORD *v0; // rax
_QWORD *v1; // rbx
void *v2; // rbp
void *v3; // r12

v0 = malloc(0x18uLL);
v1 = v0;
if ( v0 )
{
*v0 = 0;
v0[1] = 10;
v2 = malloc(0x28uLL);
v1[1] = v2;
if ( v2 )
{
v3 = malloc(0xAuLL);
v1[2] = v3;
if ( !v3 )
{
free(v2);
free(v1);
v1 = 0LL;
}
}
else
{
free(v1);
v1 = 0LL;
}
}
return v1;
}

original_code:
stack *stack_make() {
  stack *s = malloc(sizeof(stack));
  if (!s)
    return 0;
  s->size = 0;
  s->cap = 10;
  s->counts = malloc(s->cap * sizeof(int));
  if (!s->counts) {
    free(s);
    return 0;
  }
  s->chars = malloc(s->cap);
  if (!s->chars) {
    free(s->counts);
    free(s);
    return 0;
  }
  return s;
}

canonical_original_code:
struct stack_ *stack_make() {
  struct stack_ *s = malloc(sizeof(stack));
  if (!s)
    return 0;
  s->size = 0;
  s->cap = 10;
  s->counts = malloc(s->cap * sizeof(int));
  if (!s->counts) {
    free(s);
    return 0;
  }
  s->chars = malloc(s->cap);
  if (!s->chars) {
    free(s->counts);
    free(s);
    return 0;
  }
  return s;
}

variable_types: struct stack_ { int size; int cap; int *counts; char *chars; } *


decompiled_code:
void __fastcall stack_print_destroy(void *ptr)
{
int i; // eax
int v2; // eax

putchar(32);
for ( i = *(_DWORD *)ptr; *(_DWORD *)ptr; i = *(_DWORD *)ptr )
{
v2 = i - 1;
*(_DWORD *)ptr = v2;
printf(
"%d%c",
*(unsigned int *)(*((_QWORD *)ptr + 1) + 4LL * v2),
(unsigned int)*(char *)(*((_QWORD *)ptr + 2) + v2));
}
putchar(10);
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
int i; // eax
int v2; // eax

putchar(32);
for ( i = *(_DWORD *)ptr; *(_DWORD *)ptr; i = *(_DWORD *)ptr )
{
v2 = i - 1;
*(_DWORD *)ptr = v2;
printf(
"%d%c",
*(unsigned int *)(*((_QWORD *)ptr + 1) + 4LL * v2),
(unsigned int)*(char *)(*((_QWORD *)ptr + 2) + v2));
}
putchar(10);
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(ptr);
}

original_code:
void stack_print_destroy(stack *s) {
  putchar(' ');
  while(s->size) {
    s->size--;
    printf("%d%c", s->counts[s->size], s->chars[s->size]);
  }
  printf("\n");
  free(s->counts);
  free(s->chars);
  free(s);
}

canonical_original_code:
void stack_print_destroy(struct stack_ *s) {
  putchar(' ');
  while(s->size) {
    s->size--;
    printf("%d%c", s->counts[s->size], s->chars[s->size]);
  }
  printf("\n");
  free(s->counts);
  free(s->chars);
  free(s);
}

user_defined_types: struct stack_ { int size; int cap; int *counts; char *chars; }


decompiled_code:
void __fastcall stack_destroy(void *ptr)
{
int i; // eax

for ( i = *(_DWORD *)ptr; i; --i )
;
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
int i; // eax

for ( i = *(_DWORD *)ptr; i; --i )
;
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(ptr);
}

original_code:
void stack_destroy(stack *s) {
  while(s->size) {
    s->size--;
  }
  free(s->counts);
  free(s->chars);
  free(s);
}

canonical_original_code:
void stack_destroy(struct stack_ *s) {
  while(s->size) {
    s->size--;
  }
  free(s->counts);
  free(s->chars);
  free(s);
}


decompiled_code:
void __fastcall stack_flip(void *ptr, int *a2)
{
int i; // eax
int v3; // eax

for ( i = *(_DWORD *)ptr; *(_DWORD *)ptr; i = *(_DWORD *)ptr )
{
v3 = i - 1;
*(_DWORD *)ptr = v3;
stack_push(a2, *(_BYTE *)(*((_QWORD *)ptr + 2) + v3), *(_DWORD *)(*((_QWORD *)ptr + 1) + 4LL * v3));
}
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr, int *a2)
{
int i; // eax
int v3; // eax

for ( i = *(_DWORD *)ptr; *(_DWORD *)ptr; i = *(_DWORD *)ptr )
{
v3 = i - 1;
*(_DWORD *)ptr = v3;
func3(a2, *(_BYTE *)(*((_QWORD *)ptr + 2) + v3), *(_DWORD *)(*((_QWORD *)ptr + 1) + 4LL * v3));
}
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(ptr);
}

original_code:
void stack_flip(stack *s1, stack *s2) {
  while (s1->size) {
    s1->size--;
    stack_push(s2, s1->chars[s1->size], s1->counts[s1->size]);
  }
  free(s1->counts);
  free(s1->chars);
  free(s1);
}

canonical_original_code:
void stack_flip(struct stack_ *s1, struct stack_ *s2) {
  while (s1->size) {
    s1->size--;
    stack_push(s2, s1->chars[s1->size], s1->counts[s1->size]);
  }
  free(s1->counts);
  free(s1->chars);
  free(s1);
}


compar

decompiled_code:
int __fastcall compar(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

canonical_decompiled_code:
int __fastcall func7(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

original_code:
static int compar(const void * a, const void * b) {
 return strcmp(*(char **)a, *(char **)b);
}

canonical_original_code:
static int compar(void *a, void *b) {
 return strcmp(*(char **)a, *(char **)b);
}

variable_types:
a
void *

variable_types:
b
void *

return_type: int


main

canonical_name: main

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

if ( argc == 1 )
return 0;
v3 = argv[1];
v4 = strlen(v3);
v5 = (char *)malloc(v4 + 2);
strcpy(v5 + 1, v3);
*v5 = 0;
v6 = bwt(v5, v4 + 1);
v7 = v6;
if ( v4 >= 0 )
{
v8 = 0;
while ( *v6 )
{
++v8;
++v6;
if ( v4 < v8 )
goto LABEL_8;
}
*v6 = 36;
}
LABEL_8:
puts(v7);
free(v5);
free(v7);
return 0;
}

original_code:
int main(int argc, char **argv) {
 char *str, *out;
 int i, len;
 if (argc == 1)
   return 0;
 len = strlen(argv[1]);
 str = malloc(len+2);
 strcpy(str+1, argv[1]);
 *str = 0;
 out = bwt(str, len+1);
 for (i = 0; i < len+1; ++i)
  if (!out[i]) {
   out[i] = '$';
   break;
  }
 puts(out);
 free(str);
 free(out);
 return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
 char *str; char *out;
 int i; int len;
 if (argc == 1)
   return 0;
 len = strlen(argv[1]);
 str = malloc(len+2);
 strcpy(str+1, argv[1]);
 *str = 0;
 out = bwt(str, len+1);
 for (i = 0; i < len+1; ++i)
  if (!out[i]) {
   out[i] = '$';
   break;
  }
 puts(out);
 free(str);
 free(out);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
str
char *

variable_types:
out
char *


decompiled_code:
ssize_t __fastcall run_splice(int fdin, int fdout, int *a3)
{
int v4; // ebp
int v5; // eax
int v6; // ebx
ssize_t result; // rax
int *v8; // rax
int *v9; // rax
int *v10; // rax
int v11; // esi
void *v12; // rdx

if ( lseek(fdin, 0LL, 0) < 0 )
{
v8 = __errno_location();
error_at_line(-1, *v8, "bench.c", 0x1Au, 0LL);
goto LABEL_9;
}
if ( lseek(fdout, 0LL, 0) < 0 )
{
LABEL_9:
v9 = __errno_location();
error_at_line(-1, *v9, "bench.c", 0x1Bu, 0LL);
goto LABEL_10;
}
v4 = 0;
while ( 1 )
{
v5 = splice(fdin, 0LL, a3[1], 0LL, (size_t)&dword_400000, 1u);
v6 = v5;
if ( v5 < 0 )
break;
result = splice(*a3, 0LL, fdout, 0LL, v5, 1u);
if ( result < 0 )
goto LABEL_11;
v4 += v6;
if ( v4 > 0x3FFFFF )
return result;
}
LABEL_10:
v10 = __errno_location();
error_at_line(-1, *v10, "bench.c", 0x21u, 0LL);
LABEL_11:
v11 = *__errno_location();
error_at_line(-1, v11, "bench.c", 0x23u, 0LL);
return run_readwrite(-1, v11, v12);
}

canonical_decompiled_code:
ssize_t __fastcall func8(int fdin, int fdout, int *a3)
{
int v4; // ebp
int v5; // eax
int v6; // ebx
ssize_t result; // rax
int *v8; // rax
int *v9; // rax
int *v10; // rax
int v11; // esi
void *v12; // rdx

if ( lseek(fdin, 0LL, 0) < 0 )
{
v8 = __errno_location();
error_at_line(-1, *v8, "bench.c", 0x1Au, 0LL);
goto LABEL_9;
}
if ( lseek(fdout, 0LL, 0) < 0 )
{
LABEL_9:
v9 = __errno_location();
error_at_line(-1, *v9, "bench.c", 0x1Bu, 0LL);
goto LABEL_10;
}
v4 = 0;
while ( 1 )
{
v5 = splice(fdin, 0LL, a3[1], 0LL, (size_t)&dword_400000, 1u);
v6 = v5;
if ( v5 < 0 )
break;
result = splice(*a3, 0LL, fdout, 0LL, v5, 1u);
if ( result < 0 )
goto LABEL_11;
v4 += v6;
if ( v4 > 0x3FFFFF )
return result;
}
LABEL_10:
v10 = __errno_location();
error_at_line(-1, *v10, "bench.c", 0x21u, 0LL);
LABEL_11:
v11 = *__errno_location();
error_at_line(-1, v11, "bench.c", 0x23u, 0LL);
return func9(-1, v11, v12);
}

original_code:
void run_splice(int fd_in, int fd_out, int *pipefd)
{
        if ((lseek(fd_in, 0, 0)) < 0) { error_at_line((-1), (*__errno_location ()), "bench.c", 26, ((void *)0)); };
        if ((lseek(fd_out, 0, 0)) < 0) { error_at_line((-1), (*__errno_location ()), "bench.c", 27, ((void *)0)); };
        int finished = 0;
        while (finished < 4096*1024) {
                int ret = splice(fd_in, ((void *)0), pipefd[1], ((void *)0), 4096*1024, 1);
                if (ret < 0) {
                        error_at_line(-1, (*__errno_location ()), "bench.c", 33, ((void *)0));
                }
                if ((splice(pipefd[0], ((void *)0), fd_out, ((void *)0), ret, 1)) < 0) { error_at_line((-1), (*__errno_location ()), "bench.c", 35, ((void *)0)); };
                finished += ret;
        }
}

variable_types:
pipefd
int *

variable_types: finished int

variable_types: ret int


decompiled_code:
ssize_t __fastcall run_readwrite(int fd, int a2, void *buf)
{
ssize_t result; // rax
int *v5; // rax
int *v6; // rax
int *v7; // rax
int v8; // esi

if ( lseek(fd, 0LL, 0) < 0 )
{
v5 = __errno_location();
error_at_line(-1, *v5, "bench.c", 0x2Au, 0LL);
goto LABEL_7;
}
if ( lseek(a2, 0LL, 0) < 0 )
{
LABEL_7:
v6 = __errno_location();
error_at_line(-1, *v6, "bench.c", 0x2Bu, 0LL);
goto LABEL_8;
}
if ( read(fd, buf, (size_t)&dword_400000) < 0 )
{
LABEL_8:
v7 = __errno_location();
error_at_line(-1, *v7, "bench.c", 0x2Du, 0LL);
goto LABEL_9;
}
result = write(a2, buf, (size_t)&dword_400000);
if ( result < 0 )
{
LABEL_9:
v8 = *__errno_location();
error_at_line(-1, v8, "bench.c", 0x2Eu, 0LL);
result = run_sendfile(-1, v8);
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func9(int fd, int a2, void *buf)
{
ssize_t result; // rax
int *v5; // rax
int *v6; // rax
int *v7; // rax
int v8; // esi

if ( lseek(fd, 0LL, 0) < 0 )
{
v5 = __errno_location();
error_at_line(-1, *v5, "bench.c", 0x2Au, 0LL);
goto LABEL_7;
}
if ( lseek(a2, 0LL, 0) < 0 )
{
LABEL_7:
v6 = __errno_location();
error_at_line(-1, *v6, "bench.c", 0x2Bu, 0LL);
goto LABEL_8;
}
if ( read(fd, buf, (size_t)&dword_400000) < 0 )
{
LABEL_8:
v7 = __errno_location();
error_at_line(-1, *v7, "bench.c", 0x2Du, 0LL);
goto LABEL_9;
}
result = write(a2, buf, (size_t)&dword_400000);
if ( result < 0 )
{
LABEL_9:
v8 = *__errno_location();
error_at_line(-1, v8, "bench.c", 0x2Eu, 0LL);
result = func10(-1, v8);
}
return result;
}

original_code:
void run_readwrite(int fd_in, int fd_out, char *buf)
{
        if ((lseek(fd_in, 0, 0)) < 0) { error_at_line((-1), (*__errno_location ()), "bench.c", 42, ((void *)0)); };
        if ((lseek(fd_out, 0, 0)) < 0) { error_at_line((-1), (*__errno_location ()), "bench.c", 43, ((void *)0)); };
        if ((read(fd_in, buf, 4096*1024)) < 0) { error_at_line((-1), (*__errno_location ()), "bench.c", 45, ((void *)0)); };
        if ((write(fd_out, buf, 4096*1024)) < 0) { error_at_line((-1), (*__errno_location ()), "bench.c", 46, ((void *)0)); };
}

variable_types:
buf
char *


decompiled_code:
ssize_t __fastcall run_sendfile(int in_fd, int out_fd)
{
ssize_t result; // rax
int *v3; // rax
int *v4; // rax
int *v5; // rax

if ( lseek(in_fd, 0LL, 0) < 0 )
{
v3 = __errno_location();
error_at_line(-1, *v3, "bench.c", 0x33u, 0LL);
goto LABEL_6;
}
if ( lseek(out_fd, 0LL, 0) < 0 )
{
LABEL_6:
v4 = __errno_location();
error_at_line(-1, *v4, "bench.c", 0x34u, 0LL);
goto LABEL_7;
}
result = sendfile(out_fd, in_fd, 0LL, (size_t)&dword_400000);
if ( result < 0 )
{
LABEL_7:
v5 = __errno_location();
error_at_line(-1, *v5, "bench.c", 0x36u, 0LL);
result = get_diff();
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func10(int in_fd, int out_fd)
{
ssize_t result; // rax
int *v3; // rax
int *v4; // rax
int *v5; // rax

if ( lseek(in_fd, 0LL, 0) < 0 )
{
v3 = __errno_location();
error_at_line(-1, *v3, "bench.c", 0x33u, 0LL);
goto LABEL_6;
}
if ( lseek(out_fd, 0LL, 0) < 0 )
{
LABEL_6:
v4 = __errno_location();
error_at_line(-1, *v4, "bench.c", 0x34u, 0LL);
goto LABEL_7;
}
result = sendfile(out_fd, in_fd, 0LL, (size_t)&dword_400000);
if ( result < 0 )
{
LABEL_7:
v5 = __errno_location();
error_at_line(-1, *v5, "bench.c", 0x36u, 0LL);
result = func11();
}
return result;
}

original_code:
void run_sendfile(int fd_in, int fd_out)
{
        if ((lseek(fd_in, 0, 0)) < 0) { error_at_line((-1), (*__errno_location ()), "bench.c", 51, ((void *)0)); };
        if ((lseek(fd_out, 0, 0)) < 0) { error_at_line((-1), (*__errno_location ()), "bench.c", 52, ((void *)0)); };
        if ((sendfile(fd_out, fd_in, ((void *)0), 4096*1024)) < 0) { error_at_line((-1), (*__errno_location ()), "bench.c", 54, ((void *)0)); };
}


decompiled_code:
__int64 __fastcall get_diff(_DWORD *a1, _DWORD *a2)
{
return (unsigned int)(a2[2] + 1000000 * (*a2 - *a1) - a1[2]);
}

original_code:
int get_diff(struct timeval *before, struct timeval *later)
{
        return ((later->tv_sec - before->tv_sec) * (1000000)) + (later->tv_usec - before->tv_usec);
}

variable_types: struct timeval { long tv_sec; long tv_usec; } *

variable_types:
later
struct timeval *


decompiled_code:
int __fastcall print_result(int a1)
{
printf("Time: %d us / %d ops\n", (unsigned int)a1, 1000LL);
return printf("Throughput: %.0f MB/s\n", (float)((float)(4.0 / (float)((float)a1 / 1000000.0)) * 1000.0));
}

canonical_decompiled_code:
int __fastcall func12(int a1)
{
printf("Time: %d us / %d ops\n", (unsigned int)a1, 1000LL);
return printf("Throughput: %.0f MB/s\n", (float)((float)(4.0 / (float)((float)a1 / 1000000.0)) * 1000.0));
}

original_code:
void print_result(int diff)
{
        printf("Time: %d us / %d ops\n", diff, 1000);
        printf("Throughput: %.0f MB/s\n", (float)4096*1024 / (float)(1024 * 1024) / ((float)diff / (float)(1000000)) * (float)1000);
}

variable_types: diff int


interrupt

repo: yiminlong/chat

decompiled_code:
void interrupt()
{
quit = 1;
}

canonical_decompiled_code:
void func7()
{
quit = 1;
}

original_code:
void interrupt(int signal_type) {
  quit = 1;
}


decompiled_code:
void *__fastcall display_responses(void *a1)
{
char v2[96]; // [rsp+0h] [rbp-88h] BYREF
int v3; // [rsp+60h] [rbp-28h]

while ( !quit )
{
memset(v2, 0, sizeof(v2));
v3 = 0;
if ( recv((int)a1, v2, 0x63uLL, 0) )
puts(v2);
}
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func9(void *a1)
{
char v2[96]; // [rsp+0h] [rbp-88h] BYREF
int v3; // [rsp+60h] [rbp-28h]

while ( !quit )
{
memset(v2, 0, sizeof(v2));
v3 = 0;
if ( recv((int)a1, v2, 0x63uLL, 0) )
puts(v2);
}
return 0LL;
}

original_code:
void *display_responses(void *_sd) {
  char receive_buffer[100];
  size_t bytes_received;
  long sd = (long)_sd;
  while (quit == 0) {
    memset(receive_buffer, 0, 100);
    bytes_received = recv(sd, receive_buffer, 100 - 1, 0);
    if (bytes_received > 0) {
      printf("%s\n", receive_buffer);
    }
  }
  return 0;
}

canonical_original_code:
void *display_responses(void *_sd) {
  char receive_buffer[100];
  unsigned long bytes_received;
  long sd = (long)_sd;
  while (quit == 0) {
    memset(receive_buffer, 0, 100);
    bytes_received = recv(sd, receive_buffer, 100 - 1, 0);
    if (bytes_received > 0) {
      printf("%s\n", receive_buffer);
    }
  }
  return 0;
}

variable_types: sd long

return_type: void *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
void *v4; // rbp
int v5; // ebx
unsigned int v6; // eax
size_t v8; // rax
struct sigaction v9; // [rsp+0h] [rbp-138h] BYREF
struct sockaddr addr; // [rsp+A0h] [rbp-98h] BYREF
char s[96]; // [rsp+B0h] [rbp-88h] BYREF
int v12; // [rsp+110h] [rbp-28h]
pthread_t newthread[4]; // [rsp+118h] [rbp-20h] BYREF

quit = 0;
v3 = socket(2, 1, 6);
v4 = (void *)v3;
if ( v3 < 0LL )
{
perror("socket");
exit(1);
}
v5 = v3;
addr.sa_family = 2;
*(_QWORD *)&addr.sa_data[6] = 0LL;
*(_DWORD *)&addr.sa_data[2] = inet_addr("127.0.0.1");
*(_WORD *)addr.sa_data = _bswap_16(4485);
if ( connect(v5, &addr, 0x10u) < 0 )
{
perror("connect");
close(v5);
exit(1);
}
v9.sa_handler = (__sighandler_t)interrupt;
if ( sigfillset(&v9.sa_mask) < 0 )
{
perror("sigfillset");
close(v5);
exit(1);
}
v9.sa_flags = 0;
if ( sigaction(2, &v9, 0LL) < 0 )
{
perror("sigaction");
close(v5);
exit(1);
}
v6 = pthread_create(newthread, 0LL, display_responses, v4);
if ( v6 )
{
fprintf(stderr, "error: unable to create new thread. return code: %d\n", v6);
close(v5);
exit(1);
}
memset(s, 0, sizeof(s));
v12 = 0;
while ( !quit )
{
if ( s[0] )
{
v8 = strlen(s);
send(v5, s, v8, 0);
}
fgets(s, 100, _bss_start);
}
close(v5);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
void *v4; // rbp
int v5; // ebx
unsigned int v6; // eax
size_t v8; // rax
struct sigaction v9; // [rsp+0h] [rbp-138h] BYREF
struct sockaddr addr; // [rsp+A0h] [rbp-98h] BYREF
char s[96]; // [rsp+B0h] [rbp-88h] BYREF
int v12; // [rsp+110h] [rbp-28h]
pthread_t newthread[4]; // [rsp+118h] [rbp-20h] BYREF

quit = 0;
v3 = socket(2, 1, 6);
v4 = (void *)v3;
if ( v3 < 0LL )
{
perror("socket");
exit(1);
}
v5 = v3;
addr.sa_family = 2;
*(_QWORD *)&addr.sa_data[6] = 0LL;
*(_DWORD *)&addr.sa_data[2] = inet_addr("127.0.0.1");
*(_WORD *)addr.sa_data = func8(4485);
if ( connect(v5, &addr, 0x10u) < 0 )
{
perror("connect");
close(v5);
exit(1);
}
v9.sa_handler = (__sighandler_t)interrupt;
if ( sigfillset(&v9.sa_mask) < 0 )
{
perror("sigfillset");
close(v5);
exit(1);
}
v9.sa_flags = 0;
if ( sigaction(2, &v9, 0LL) < 0 )
{
perror("sigaction");
close(v5);
exit(1);
}
v6 = pthread_create(newthread, 0LL, display_responses, v4);
if ( v6 )
{
fprintf(stderr, "error: unable to create new thread. return code: %d\n", v6);
close(v5);
exit(1);
}
memset(s, 0, sizeof(s));
v12 = 0;
while ( !quit )
{
if ( s[0] )
{
v8 = strlen(s);
send(v5, s, v8, 0);
}
fgets(s, 100, _bss_start);
}
close(v5);
return 0;
}

original_code:
int main() {
  long sd;
  int port, result, return_code;
  pthread_t receive_thread;
  char send_buffer[100];
  struct sockaddr_in server_addr;
  struct sigaction handler;
  const char *server = "127.0.0.1";
  quit = 0;
  port = 4485;
  sd = socket(2, SOCK_STREAM, IPPROTO_TCP);
  if (sd < 0) {
    perror("socket");
    exit(1);
  }
  memset(&server_addr, 0, sizeof(struct sockaddr_in));
  server_addr.sin_family = 2;
  server_addr.sin_addr.s_addr = inet_addr(server);
  server_addr.sin_port = htons(port);
  result = connect(sd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr_in));
  if (result < 0) {
    perror("connect");
    close(sd);
    exit(1);
  }
  handler.__sigaction_handler.sa_handler = interrupt;
  result = sigfillset(&handler.sa_mask);
  if (result < 0) {
    perror("sigfillset");
    close(sd);
    exit(1);
  }
  handler.sa_flags = 0;
  result = sigaction(2, &handler, 0);
  if (result < 0) {
    perror("sigaction");
    close(sd);
    exit(1);
  }
  return_code = pthread_create(&receive_thread, 0, display_responses, (void *)sd);
  if (return_code != 0) {
    fprintf(stderr, "error: unable to create new thread. return code: %d\n", return_code);
    close(sd);
    exit(1);
  }
  memset(send_buffer, 0, 100);
  while (quit == 0) {
    if (strlen(send_buffer) > 0) {
      send(sd, send_buffer, strlen(send_buffer), 0);
    }
    fgets(send_buffer, 100, stdin);
  }
  close(sd);
  return 0;
}

canonical_original_code:
int main() {
  long sd;
  int port; int result; int return_code;
  unsigned long receive_thread;
  char send_buffer[100];
  struct sockaddr_in server_addr;
  struct sigaction handler;
  char *server = "127.0.0.1";
  quit = 0;
  port = 4485;
  sd = socket(2, SOCK_STREAM, IPPROTO_TCP);
  if (sd < 0) {
    perror("socket");
    exit(1);
  }
  memset(&server_addr, 0, sizeof(struct sockaddr_in));
  server_addr.sin_family = 2;
  server_addr.sin_addr.s_addr = inet_addr(server);
  server_addr.sin_port = htons(port);
  result = connect(sd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr_in));
  if (result < 0) {
    perror("connect");
    close(sd);
    exit(1);
  }
  handler.__sigaction_handler.sa_handler = interrupt;
  result = sigfillset(&handler.sa_mask);
  if (result < 0) {
    perror("sigfillset");
    close(sd);
    exit(1);
  }
  handler.sa_flags = 0;
  result = sigaction(2, &handler, 0);
  if (result < 0) {
    perror("sigaction");
    close(sd);
    exit(1);
  }
  return_code = pthread_create(&receive_thread, 0, display_responses, (void *)sd);
  if (return_code != 0) {
    fprintf(stderr, "error: unable to create new thread. return code: %d\n", return_code);
    close(sd);
    exit(1);
  }
  memset(send_buffer, 0, 100);
  while (quit == 0) {
    if (strlen(send_buffer) > 0) {
      send(sd, send_buffer, strlen(send_buffer), 0);
    }
    fgets(send_buffer, 100, stdin);
  }
  close(sd);
  return 0;
}

variable_types: port int

variable_types: result int

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, 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; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

variable_types:
server
char *

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }

user_defined_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 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; }


yywrap

decompiled_code:
void yywrap()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code: void yywrap() {}

canonical_original_code: void yywrap() {}


counter

decompiled_code:
__int64 __fastcall counter(_DWORD *a1)
{
__int64 result; // rax

while ( (unsigned int)yylex() )
;
*a1 = fee_count;
a1[1] = fie_count;
a1[2] = foe_count;
result = fum_count;
a1[3] = fum_count;
return result;
}

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

while ( (unsigned int)yylex() )
;
*a1 = fee_count;
a1[1] = fie_count;
a1[2] = foe_count;
result = fum_count;
a1[3] = fum_count;
return result;
}

original_code:
void counter(int counts[4])
{
 while (yylex())
  ;
 counts[0] = fee_count;
 counts[1] = fie_count;
 counts[2] = foe_count;
 counts[3] = fum_count;
}

variable_types:
counts
int [4]


repo: yinyanghu/C--Compiler

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

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

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

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

original_code:
void IRChain_Delete(struct IRChain *ptr)
{
 ptr -> prev -> next = ptr -> next;
 ptr -> next -> prev = ptr -> prev;
}

variable_types: struct IRChain { struct IRCode { enum IRCodeType { LABEL=0, FUNCTION=1, ASSIGN=2, ADD=3, SUB=4, MUL=5, DIVDIV=6, ValueAddress=7, AddressValueL=8, AddressValueR=9, GOTO=10, CONDGOTO=11, RETURNRETURN=12, DEC=13, ARG=14, CALL=15, PARAM=16, READ=17, WRITE=18 } type; union { int label; char func[40]; struct Operand { enum OperandType { VARIABLE=0, CONSTANT=1, ADDRESS=2, TEMP=3 } type; union { int var_no; int temp_no; int constant; unsigned int addr; }; } *single; struct { char func[40]; struct Operand *ret; } call; struct { struct Operand *left; } lr; struct { struct Operand *result; } binary; struct { enum BinaryOP_Relop { OP_EQ=0, OP_NE=1, OP_LT=2, OP_GT=3, OP_GE=4, OP_LE=5 } op; struct Operand *left; int next; } condjump; struct { struct Operand *x; int size; } dec; }; } *code; struct IRChain *prev; } *

user_defined_types: struct IRChain { struct IRCode *code; struct IRChain *prev; }

user_defined_types: struct IRCode { enum IRCodeType type; union { int label; char func[40]; struct Operand *single; struct { char func[40]; struct Operand *ret; } call; struct { struct Operand *left; } lr; struct { struct Operand *result; } binary; struct { enum BinaryOP_Relop op; struct Operand *left; int next; } condjump; struct { struct Operand *x; int size; } dec; }; }

user_defined_types: struct Operand { enum OperandType type; union { int var_no; int temp_no; int constant; unsigned int addr; }; }


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

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

original_code:
void IRChain_Insert(struct IRChain *ptr, struct IRChain *new)
{
 new -> next = ptr -> next;
 new -> prev = ptr;
 ptr -> next -> prev = new;
 ptr -> next = new;
}

variable_types:
new
struct IRChain *

user_defined_types: enum IRCodeType { LABEL=0, FUNCTION=1, ASSIGN=2, ADD=3, SUB=4, MUL=5, DIVDIV=6, ValueAddress=7, AddressValueL=8, AddressValueR=9, GOTO=10, CONDGOTO=11, RETURNRETURN=12, DEC=13, ARG=14, CALL=15, PARAM=16, READ=17, WRITE=18 }

user_defined_types: enum BinaryOP_Relop { OP_EQ=0, OP_NE=1, OP_LT=2, OP_GT=3, OP_GE=4, OP_LE=5 }

user_defined_types: enum OperandType { VARIABLE=0, CONSTANT=1, ADDRESS=2, TEMP=3 }


original_code:
void IRChain_Split(struct IRChain *A, struct IRChain *B)
{
 if (A == ((void *)0) || B == ((void *)0)) return;
 A -> prev -> next = B;
 B -> prev -> next = A;
 struct IRChain *temp = B -> prev;
 B -> prev = A -> prev;
 A -> prev = temp;
}

variable_types:
B
struct IRChain *


decompiled_code:
_BOOL8 __fastcall Checking_Constant(_DWORD *a1)
{
return *a1 == 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(_DWORD *a1)
{
return *a1 == 1;
}

original_code:
int Checking_Constant(struct Operand *A)
{
 return ((A -> type == CONSTANT) ? 1 : 0);
}

variable_types: struct Operand { enum OperandType { VARIABLE=0, CONSTANT=1, ADDRESS=2, TEMP=3 } type; union { int var_no; int temp_no; int constant; unsigned int addr; }; } *


decompiled_code:
__int64 __fastcall Checking_JUMP(_DWORD *a1)
{
if ( *a1 == 10 )
return (unsigned int)a1[2];
if ( *a1 == 11 )
return (unsigned int)a1[8];
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func4(_DWORD *a1)
{
if ( *a1 == 10 )
return (unsigned int)a1[2];
if ( *a1 == 11 )
return (unsigned int)a1[8];
return 0xFFFFFFFFLL;
}

original_code:
int Checking_JUMP(struct IRCode *A)
{
 if (A -> type == GOTO)
  return (A -> label);
 else if (A -> type == CONDGOTO)
  return (A -> condjump.next);
 else
  return -1;
}

variable_types: struct IRCode { enum IRCodeType { LABEL=0, FUNCTION=1, ASSIGN=2, ADD=3, SUB=4, MUL=5, DIVDIV=6, ValueAddress=7, AddressValueL=8, AddressValueR=9, GOTO=10, CONDGOTO=11, RETURNRETURN=12, DEC=13, ARG=14, CALL=15, PARAM=16, READ=17, WRITE=18 } type; union { int label; char func[40]; struct Operand { enum OperandType { VARIABLE=0, CONSTANT=1, ADDRESS=2, TEMP=3 } type; union { int var_no; int temp_no; int constant; unsigned int addr; }; } *single; struct { char func[40]; struct Operand *ret; } call; struct { struct Operand *left; } lr; struct { struct Operand *result; } binary; struct { enum BinaryOP_Relop { OP_EQ=0, OP_NE=1, OP_LT=2, OP_GT=3, OP_GE=4, OP_LE=5 } op; struct Operand *left; int next; } condjump; struct { struct Operand *x; int size; } dec; }; } *


decompiled_code:
_BOOL8 __fastcall Checking_Operand(_DWORD *a1, _DWORD *a2)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == *a2 )
result = a1[1] == a2[1];
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(_DWORD *a1, _DWORD *a2)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == *a2 )
result = a1[1] == a2[1];
return result;
}

original_code:
int Checking_Operand(struct Operand *A, struct Operand *B)
{
 return ((A -> type == B -> type && A -> var_no == B -> var_no) ? 1 : 0);
}

variable_types:
B
struct Operand *


decompiled_code:
_BOOL8 __fastcall Checking_DefaultJUMP(_DWORD *a1)
{
return ((*a1 - 10) & 0xFFFFFFFD) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(_DWORD *a1)
{
return ((*a1 - 10) & 0xFFFFFFFD) != 0;
}

original_code:
int Checking_DefaultJUMP(struct IRCode *A)
{
 return ((A -> type == GOTO || A -> type == RETURNRETURN) ? 0 : 1);
}


original_code:
struct IRChain *Get_Block(struct IRChain **head)
{
 if ((*head) == ((void *)0)) return ((void *)0);
 struct IRChain *ptr = (*head) -> next;
 struct IRChain *ret = (*head);
 while (ptr != (*head))
 {
  if (ptr -> code -> type == LABEL)
  {
   IRChain_Split(*head, ptr);
   *head = ptr;
   return ret;
  }
  ptr = ptr -> next;
 }
 *head = ((void *)0);
 return ret;
}

variable_types:
head
struct IRChain **

return_type: struct IRChain { struct IRCode { enum IRCodeType { LABEL=0, FUNCTION=1, ASSIGN=2, ADD=3, SUB=4, MUL=5, DIVDIV=6, ValueAddress=7, AddressValueL=8, AddressValueR=9, GOTO=10, CONDGOTO=11, RETURNRETURN=12, DEC=13, ARG=14, CALL=15, PARAM=16, READ=17, WRITE=18 } type; union { int label; char func[40]; struct Operand { enum OperandType { VARIABLE=0, CONSTANT=1, ADDRESS=2, TEMP=3 } type; union { int var_no; int temp_no; int constant; unsigned int addr; }; } *single; struct { char func[40]; struct Operand *ret; } call; struct { struct Operand *left; } lr; struct { struct Operand *result; } binary; struct { enum BinaryOP_Relop { OP_EQ=0, OP_NE=1, OP_LT=2, OP_GT=3, OP_GE=4, OP_LE=5 } op; struct Operand *left; int next; } condjump; struct { struct Operand *x; int size; } dec; }; } *code; struct IRChain *prev; } *


decompiled_code:
void __fastcall CFG_build(__int64 a1)
{
__int64 v1; // rbp
__int64 i; // rbx
int v3; // eax

v1 = *(_QWORD *)(a1 + 8);
for ( i = *(_QWORD *)(v1 + 16); v1 != i; i = *(_QWORD *)(i + 16) )
{
v3 = Checking_JUMP(*(_DWORD **)i);
if ( v3 != -1 )
CFG_insert(a1, BlockPool[v3]);
}
}

original_code:
void CFG_build(struct CodeBlock *ptr)
{
 struct IRChain *code = ptr -> code;
 struct IRChain *currentcode = code -> next;
 while (currentcode != code)
 {
  int target = Checking_JUMP(currentcode -> code);
  if (target != -1)
   CFG_insert(ptr, BlockPool[target]);
  currentcode = currentcode -> next;
 }
}

variable_types: struct CodeBlock { int label; struct IRChain { struct IRCode { enum IRCodeType { LABEL=0, FUNCTION=1, ASSIGN=2, ADD=3, SUB=4, MUL=5, DIVDIV=6, ValueAddress=7, AddressValueL=8, AddressValueR=9, GOTO=10, CONDGOTO=11, RETURNRETURN=12, DEC=13, ARG=14, CALL=15, PARAM=16, READ=17, WRITE=18 } type; union { int label; char func[40]; struct Operand { enum OperandType { VARIABLE=0, CONSTANT=1, ADDRESS=2, TEMP=3 } type; union { int var_no; int temp_no; int constant; unsigned int addr; }; } *single; struct { char func[40]; struct Operand *ret; } call; struct { struct Operand *left; } lr; struct { struct Operand *result; } binary; struct { enum BinaryOP_Relop { OP_EQ=0, OP_NE=1, OP_LT=2, OP_GT=3, OP_GE=4, OP_LE=5 } op; struct Operand *left; int next; } condjump; struct { struct Operand *x; int size; } dec; }; } *code; struct IRChain *prev; } *code; struct NextBlock { struct CodeBlock *target; struct NextBlock *next; } *out; } *

variable_types: target int

user_defined_types: struct CodeBlock { int label; struct IRChain *code; struct NextBlock *out; }


decompiled_code:
void OPT_RETURN()
{
;
}

canonical_decompiled_code:
void func10()
{
;
}

original_code:
struct IRChain *OPT_RETURN(struct IRChain *head)
{
}

variable_types:
head
struct IRChain *


original_code:
struct IRChain *Get_Function(struct IRChain **head)
{
 if ((*head) == ((void *)0)) return ((void *)0);
 if ((*head) -> code -> type != FUNCTION)
 {
  fprintf(stderr, "OPT 005!\n");
  return ((void *)0);
 }
 struct IRChain *ptr = (*head) -> next;
 struct IRChain *ret = (*head);
 while (ptr != (*head))
 {
  if (ptr -> code -> type == FUNCTION)
  {
   IRChain_Split(*head, ptr);
   *head = ptr;
   return ret;
  }
  ptr = ptr -> next;
 }
 *head = ((void *)0);
 return ret;
}


decompiled_code:
void DFL_clear()
{
DFL = 0LL;
}

canonical_decompiled_code:
void func0()
{
DFL = 0LL;
}

original_code:
void DFL_clear(void)
{
 DFL = ((void *)0);
}

canonical_original_code:
void DFL_clear()
{
 DFL = ((void *)0);
}


decompiled_code:
void *__fastcall DFL_insert(__int64 a1, const char *a2, int a3)
{
void *v4; // rbx

v4 = malloc(0x38uLL);
*((_QWORD *)v4 + 6) = a1;
*(_DWORD *)v4 = a3;
strcpy((char *)v4 + 4, a2);
return v4;
}

canonical_decompiled_code:
void *__fastcall func1(__int64 a1, const char *a2, int a3)
{
void *v4; // rbx

v4 = malloc(0x38uLL);
*((_QWORD *)v4 + 6) = a1;
*(_DWORD *)v4 = a3;
strcpy((char *)v4 + 4, a2);
return v4;
}

original_code:
struct DeclaredFunctionList *DFL_insert(struct DeclaredFunctionList *dfl, char *name, int lineno)
{
 struct DeclaredFunctionList *ptr = (struct DeclaredFunctionList *)malloc(sizeof(struct DeclaredFunctionList));
 ptr -> next = dfl;
 ptr -> lineno = lineno;
 strcpy(ptr -> name, name);
 return ptr;
}

variable_types:
dfl
struct DeclaredFunctionList *

variable_types:
name
char *

variable_types: lineno int

variable_types: struct DeclaredFunctionList { int lineno; char name[40]; struct DeclaredFunctionList *next; } *


decompiled_code:
_BOOL8 __fastcall DFL_check(__int64 a1)
{
return a1 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1)
{
return a1 == 0;
}

original_code:
int DFL_check(struct DeclaredFunctionList *dfl)
{
 return (dfl == ((void *)0) ? 1 : 0);
}

user_defined_types: struct DeclaredFunctionList { int lineno; char name[40]; struct DeclaredFunctionList *next; }


StringHashing

decompiled_code:
__int64 __fastcall StringHashing(char *a1)
{
char v1; // al
int v2; // edx

v1 = *a1;
if ( *a1 )
{
v2 = 0;
do
{
++a1;
v2 = v1 + 131 * v2;
v1 = *a1;
}
while ( *a1 );
}
else
{
v2 = 0;
}
return (v2 & 0x7FFFFFFFu) % 0x3E5;
}

original_code:
int StringHashing(char *str)
{
 unsigned int seed = 131;
 unsigned int hash = 0;
 while (*str)
  hash = hash * seed + (*str ++);
 return ((hash & 0x7FFFFFFF) % 997);
}

variable_types:
str
char *

variable_types:
seed
unsigned int

variable_types:
hash
unsigned int


original_code:
void ST_remove(struct SymbolsTable *ptr)
{
 ptr -> prev -> next = ptr -> next;
 if (ptr -> next != ((void *)0))
  ptr -> next -> prev = ptr -> prev;
 free(ptr);
}

variable_types: struct SymbolsTable { int scope; char name[40]; struct Attribute { enum AttributeType { Variable=0, Function=1, Struct=2 } type; union { struct FunctionAttribute { struct TYPE { enum { Basic=0, Array=1, Structure=2 } level; union { enum DataType { TYPE_INT=0, TYPE_FLOAT=1 } basic; struct ArrayType { struct TYPE *next; int size; } *array; struct StructureType { char name[40]; struct TYPE *type; struct StructureType *next; } *structure; }; } *return_type; struct Argument { struct TYPE *type; char name[40]; struct Argument *next; } *args; unsigned int address; int size; enum FuncStatus { Declared=0, Defined=1 } status; } *func; struct VariableAttribute { struct TYPE *type; union { int v_int; float v_float; }; unsigned int address; int size; int no; int is_ptr; } *var; struct StructureAttribute { struct StructureType *type; int size; } *structure; }; } *attr; struct SymbolsTable *next; } *

user_defined_types: struct SymbolsTable { int scope; char name[40]; struct Attribute *attr; struct SymbolsTable *next; }

user_defined_types: struct Attribute { enum AttributeType type; union { struct FunctionAttribute *func; struct VariableAttribute *var; struct StructureAttribute *structure; }; }

user_defined_types: struct FunctionAttribute { struct TYPE *return_type; struct Argument *args; unsigned int address; int size; enum FuncStatus status; }

user_defined_types: struct TYPE { enum { Basic=0, Array=1, Structure=2 } level; union { enum DataType basic; struct ArrayType *array; struct StructureType *structure; }; }


decompiled_code:
__int64 __fastcall ST_find(__int64 a1, char *a2)
{
__int64 i; // rbx

for ( i = *(_QWORD *)(*(_QWORD *)(a1 + 8LL * (int)StringHashing(a2)) + 56LL); i; i = *(_QWORD *)(i + 56) )
{
if ( !strcmp(a2, (const char *)(i + 4)) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, char *a2)
{
__int64 i; // rbx

for ( i = *(_QWORD *)(*(_QWORD *)(a1 + 8LL * (int)func4(a2)) + 56LL); i; i = *(_QWORD *)(i + 56) )
{
if ( !strcmp(a2, (const char *)(i + 4)) )
break;
}
return i;
}

original_code:
struct SymbolsTable *ST_find(struct SymbolsTable **List, char *id)
{
 int f = StringHashing(id);
 struct SymbolsTable *ptr;
 for (ptr = List[f] -> next; ptr != ((void *)0); ptr = ptr -> next)
  if (strcmp(id, ptr -> name) == 0) return ptr;
 return ((void *)0);
}

variable_types:
List
struct SymbolsTable **

variable_types:
id
char *

variable_types: f int

return_type: struct SymbolsTable { int scope; char name[40]; struct Attribute { enum AttributeType { Variable=0, Function=1, Struct=2 } type; union { struct FunctionAttribute { struct TYPE { enum { Basic=0, Array=1, Structure=2 } level; union { enum DataType { TYPE_INT=0, TYPE_FLOAT=1 } basic; struct ArrayType { struct TYPE *next; int size; } *array; struct StructureType { char name[40]; struct TYPE *type; struct StructureType *next; } *structure; }; } *return_type; struct Argument { struct TYPE *type; char name[40]; struct Argument *next; } *args; unsigned int address; int size; enum FuncStatus { Declared=0, Defined=1 } status; } *func; struct VariableAttribute { struct TYPE *type; union { int v_int; float v_float; }; unsigned int address; int size; int no; int is_ptr; } *var; struct StructureAttribute { struct StructureType *type; int size; } *structure; }; } *attr; struct SymbolsTable *next; } *


original_code:
int ST_Test(struct SymbolsTable **List)
{
 int i, ret = 0;
 struct SymbolsTable *ptr;
 for (i = 0; i < 997; ++ i)
 {
  int len = 0;
  for (ptr = List[i] -> next; ptr != ((void *)0); ptr = ptr -> next)
   ++ len;
  if (len > ret) ret = len;
 }
 return ret;
}

canonical_original_code:
int ST_Test(struct SymbolsTable **List)
{
 int i; int ret = 0;
 struct SymbolsTable *ptr;
 for (i = 0; i < 997; ++ i)
 {
  int len = 0;
  for (ptr = List[i] -> next; ptr != ((void *)0); ptr = ptr -> next)
   ++ len;
  if (len > ret) ret = len;
 }
 return ret;
}

variable_types: struct SymbolsTable { int scope; char name[40]; struct Attribute { enum AttributeType { Variable=0, Function=1, Struct=2 } type; union { struct FunctionAttribute { struct TYPE { enum { Basic=0, Array=1, Structure=2 } level; union { enum DataType { TYPE_INT=0, TYPE_FLOAT=1 } basic; struct ArrayType { struct TYPE *next; int size; } *array; struct StructureType { char name[40]; struct TYPE *type; struct StructureType *next; } *structure; }; } *return_type; struct Argument { struct TYPE *type; char name[40]; struct Argument *next; } *args; unsigned int address; int size; enum FuncStatus { Declared=0, Defined=1 } status; } *func; struct VariableAttribute { struct TYPE *type; union { int v_int; float v_float; }; unsigned int address; int size; int no; int is_ptr; } *var; struct StructureAttribute { struct StructureType *type; int size; } *structure; }; } *attr; struct SymbolsTable *next; } **

variable_types: i int

variable_types: ret int

variable_types: len int


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

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

original_code:
int Scope_current(struct ScopeType *scope)
{
 return scope -> top;
}

variable_types: struct ScopeType { int top; struct ScopeList { struct SymbolsTable { int scope; char name[40]; struct Attribute { enum AttributeType { Variable=0, Function=1, Struct=2 } type; union { struct FunctionAttribute { struct TYPE { enum { Basic=0, Array=1, Structure=2 } level; union { enum DataType { TYPE_INT=0, TYPE_FLOAT=1 } basic; struct ArrayType { struct TYPE *next; int size; } *array; struct StructureType { char name[40]; struct TYPE *type; struct StructureType *next; } *structure; }; } *return_type; struct Argument { struct TYPE *type; char name[40]; struct Argument *next; } *args; unsigned int address; int size; enum FuncStatus { Declared=0, Defined=1 } status; } *func; struct VariableAttribute { struct TYPE *type; union { int v_int; float v_float; }; unsigned int address; int size; int no; int is_ptr; } *var; struct StructureAttribute { struct StructureType *type; int size; } *structure; }; } *attr; struct SymbolsTable *next; } *pearl; struct ScopeList *next; } *Stack[15]; } *

user_defined_types: struct ScopeType { int top; struct ScopeList *Stack[15]; }

user_defined_types: struct ScopeList { struct SymbolsTable *pearl; struct ScopeList *next; }


decompiled_code:
__int64 __fastcall ST_find_scope(__int64 a1, char *a2, unsigned int *a3)
{
int v3; // ebp
__int64 i; // rbx

v3 = Scope_current(a3);
for ( i = *(_QWORD *)(*(_QWORD *)(a1 + 8LL * (int)StringHashing(a2)) + 56LL); i; i = *(_QWORD *)(i + 56) )
{
if ( *(_DWORD *)i == v3 && !strcmp(a2, (const char *)(i + 4)) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, char *a2, unsigned int *a3)
{
int v3; // ebp
__int64 i; // rbx

v3 = func9(a3);
for ( i = *(_QWORD *)(*(_QWORD *)(a1 + 8LL * (int)func4(a2)) + 56LL); i; i = *(_QWORD *)(i + 56) )
{
if ( *(_DWORD *)i == v3 && !strcmp(a2, (const char *)(i + 4)) )
break;
}
return i;
}

original_code:
struct SymbolsTable *ST_find_scope(struct SymbolsTable **List, char *id, struct ScopeType *scope)
{
 int current = Scope_current(scope);
 int f = StringHashing(id);
 struct SymbolsTable *ptr;
 for (ptr = List[f] -> next; ptr != ((void *)0); ptr = ptr -> next)
  if (ptr -> scope == current && strcmp(id, ptr -> name) == 0) return ptr;
 return ((void *)0);
}

variable_types: struct ScopeType { int top; struct ScopeList { struct SymbolsTable *pearl; struct ScopeList *next; } *Stack[15]; } *

variable_types: current int

user_defined_types: enum AttributeType { Variable=0, Function=1, Struct=2 }

user_defined_types: struct VariableAttribute { struct TYPE *type; union { int v_int; float v_float; }; unsigned int address; int size; int no; int is_ptr; }

user_defined_types: struct StructureAttribute { struct StructureType *type; int size; }

user_defined_types: enum FuncStatus { Declared=0, Defined=1 }

user_defined_types: struct Argument { struct TYPE *type; char name[40]; struct Argument *next; }

user_defined_types: enum DataType { TYPE_INT=0, TYPE_FLOAT=1 }

user_defined_types: struct ArrayType { struct TYPE *next; int size; }

user_defined_types: struct StructureType { char name[40]; struct TYPE *type; struct StructureType *next; }


decompiled_code:
__int64 __fastcall Scope_push(int *a1)
{
int v1; // eax
__int64 result; // rax

v1 = *a1;
*(_QWORD *)&a1[2 * *a1 + 2] = 0LL;
result = (unsigned int)(v1 + 1);
*a1 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(int *a1)
{
int v1; // eax
__int64 result; // rax

v1 = *a1;
*(_QWORD *)&a1[2 * *a1 + 2] = 0LL;
result = (unsigned int)(v1 + 1);
*a1 = result;
return result;
}

original_code:
void Scope_push(struct ScopeType *scope)
{
 scope -> Stack[scope -> top] = ((void *)0);
 ++ scope -> top;
}


decompiled_code:
void __fastcall Scope_pop(_DWORD *a1)
{
__int64 v1; // rbx
_QWORD **v2; // rbp

if ( *a1 )
{
v1 = *(_QWORD *)&a1[2 * *a1];
while ( v1 )
{
v2 = (_QWORD **)v1;
v1 = *(_QWORD *)(v1 + 8);
ST_remove(*v2);
free(v2);
}
--*a1;
}
else
{
fwrite("Stack Error!\n", 1uLL, 0xDuLL, stderr);
}
}

canonical_decompiled_code:
void __fastcall func12(_DWORD *a1)
{
__int64 v1; // rbx
_QWORD **v2; // rbp

if ( *a1 )
{
v1 = *(_QWORD *)&a1[2 * *a1];
while ( v1 )
{
v2 = (_QWORD **)v1;
v1 = *(_QWORD *)(v1 + 8);
func5(*v2);
free(v2);
}
--*a1;
}
else
{
fwrite("Stack Error!\n", 1uLL, 0xDuLL, stderr);
}
}

original_code:
void Scope_pop(struct ScopeType *scope)
{
 if (scope -> top == 0)
 {
  fprintf(stderr, "Stack Error!\n");
  return;
 }
 struct ScopeList *ptr = scope -> Stack[scope -> top - 1];
 while (ptr)
 {
  struct ScopeList *next = ptr -> next;
  ST_remove(ptr -> pearl);
  free(ptr);
  ptr = next;
 }
 -- scope -> top;
}

variable_types: struct ScopeList { struct SymbolsTable { int scope; char name[40]; struct Attribute { enum AttributeType { Variable=0, Function=1, Struct=2 } type; union { struct FunctionAttribute { struct TYPE { enum { Basic=0, Array=1, Structure=2 } level; union { enum DataType { TYPE_INT=0, TYPE_FLOAT=1 } basic; struct ArrayType { struct TYPE *next; int size; } *array; struct StructureType { char name[40]; struct TYPE *type; struct StructureType *next; } *structure; }; } *return_type; struct Argument { struct TYPE *type; char name[40]; struct Argument *next; } *args; unsigned int address; int size; enum FuncStatus { Declared=0, Defined=1 } status; } *func; struct VariableAttribute { struct TYPE *type; union { int v_int; float v_float; }; unsigned int address; int size; int no; int is_ptr; } *var; struct StructureAttribute { struct StructureType *type; int size; } *structure; }; } *attr; struct SymbolsTable *next; } *pearl; struct ScopeList *next; } *


original_code:
struct SymbolsTable *ST_insert(struct SymbolsTable **List, char *id, struct ScopeType *Scope)
{
 struct SymbolsTable *ptr = (struct SymbolsTable *)malloc(sizeof(struct SymbolsTable));
 strcpy(ptr -> name, id);
 ptr -> scope = Scope_current(Scope);
 ptr -> attr = ((void *)0);
 int f = StringHashing(id);
 ptr -> next = List[f] -> next;
 ptr -> prev = List[f];
 if (List[f] -> next != ((void *)0))
  List[f] -> next -> prev = ptr;
 List[f] -> next = ptr;
 Scope_insert(Scope, ptr);
 return ptr;
}


decompiled_code:
__int64 __fastcall ScopeList_print(unsigned int **a1)
{
unsigned int **i; // rbx
unsigned int *v2; // rbp
__int64 result; // rax

for ( i = a1; i; i = (unsigned int **)i[1] )
{
v2 = *i;
printf("%s(%d): \n", (const char *)*i + 4, **i);
result = Attribute_print(*((_QWORD *)v2 + 6));
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(unsigned int **a1)
{
unsigned int **i; // rbx
unsigned int *v2; // rbp
__int64 result; // rax

for ( i = a1; i; i = (unsigned int **)i[1] )
{
v2 = *i;
printf("%s(%d): \n", (const char *)*i + 4, **i);
result = Attribute_print(*((_QWORD *)v2 + 6));
}
return result;
}

original_code:
void ScopeList_print(struct ScopeList *list)
{
 struct SymbolsTable *entry;
 for (; list; list = list -> next)
 {
  entry = list -> pearl;
  printf("%s(%d): \n", entry -> name, entry -> scope);
  Attribute_print(entry -> attr);
 }
}


decompiled_code:
__int64 __fastcall Scope_print(int *a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( *a1 > 0 )
{
v1 = 0LL;
do
{
printf("Scope %d: \n", (unsigned int)v1);
result = ScopeList_print(*(unsigned int ***)&a1[2 * v1++ + 2]);
}
while ( *a1 > (int)v1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(int *a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( *a1 > 0 )
{
v1 = 0LL;
do
{
printf("Scope %d: \n", (unsigned int)v1);
result = func14(*(unsigned int ***)&a1[2 * v1++ + 2]);
}
while ( *a1 > (int)v1 );
}
return result;
}

original_code:
void Scope_print(struct ScopeType *scope)
{
 int i;
 for (i = 0; i < scope -> top; ++ i)
 {
  printf("Scope %d: \n", i);
  ScopeList_print(scope -> Stack[i]);
 }
}


decompiled_code:
int __fastcall DST_check_name(__int64 a1, const char *a2)
{
__int64 v2; // rbx
int result; // eax

v2 = a1;
if ( !a1 )
return 1;
while ( 1 )
{
result = strcmp((const char *)(v2 + 4), a2);
if ( !result )
break;
v2 = *(_QWORD *)(v2 + 56);
if ( !v2 )
return 1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func16(__int64 a1, const char *a2)
{
__int64 v2; // rbx
int result; // eax

v2 = a1;
if ( !a1 )
return 1;
while ( 1 )
{
result = strcmp((const char *)(v2 + 4), a2);
if ( !result )
break;
v2 = *(_QWORD *)(v2 + 56);
if ( !v2 )
return 1;
}
return result;
}

original_code:
int DST_check_name(struct DynamicStructureTable *dst, char *name)
{
 for (; dst != ((void *)0); dst = dst -> next)
  if (strcmp(dst -> name, name) == 0) return 0;
 return 1;
}

variable_types: struct DynamicStructureTable { int scope; char name[40]; struct StructureType { char name[40]; struct TYPE { enum { Basic=0, Array=1, Structure=2 } level; union { enum DataType { TYPE_INT=0, TYPE_FLOAT=1 } basic; struct ArrayType { struct TYPE *next; int size; } *array; struct StructureType *structure; }; } *type; struct StructureType *next; } *attr; struct DynamicStructureTable *next; } *

variable_types:
name
char *

user_defined_types: struct DynamicStructureTable { int scope; char name[40]; struct StructureType *attr; struct DynamicStructureTable *next; }


decompiled_code:
__int64 __fastcall DST_find(__int64 a1, const char *a2)
{
__int64 v2; // rbx

v2 = a1;
if ( !a1 )
return 0LL;
while ( strcmp((const char *)(v2 + 4), a2) )
{
v2 = *(_QWORD *)(v2 + 56);
if ( !v2 )
return 0LL;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, const char *a2)
{
__int64 v2; // rbx

v2 = a1;
if ( !a1 )
return 0LL;
while ( strcmp((const char *)(v2 + 4), a2) )
{
v2 = *(_QWORD *)(v2 + 56);
if ( !v2 )
return 0LL;
}
return v2;
}

original_code:
struct DynamicStructureTable *DST_find(struct DynamicStructureTable *dst, char *name)
{
 for (; dst != ((void *)0); dst = dst -> next)
  if (strcmp(dst -> name, name) == 0) return dst;
 return ((void *)0);
}

variable_types:
dst
struct DynamicStructureTable *

return_type: struct DynamicStructureTable { int scope; char name[40]; struct StructureType { char name[40]; struct TYPE { enum { Basic=0, Array=1, Structure=2 } level; union { enum DataType { TYPE_INT=0, TYPE_FLOAT=1 } basic; struct ArrayType { struct TYPE *next; int size; } *array; struct StructureType *structure; }; } *type; struct StructureType *next; } *attr; struct DynamicStructureTable *next; } *


decompiled_code:
void DST_Global()
{
DST_Scope = 0;
DST_remove((_QWORD **)&DST, 1);
}

canonical_decompiled_code:
void func20()
{
DST_Scope = 0;
func18((_QWORD **)&DST, 1);
}

original_code:
void DST_Global(void)
{
 DST_Scope = 0;
 DST_remove(&DST, 1);
}

canonical_original_code:
void DST_Global()
{
 DST_Scope = 0;
 DST_remove(&DST, 1);
}


decompiled_code:
void DST_Local()
{
DST_Scope = 1;
}

canonical_decompiled_code:
void func21()
{
DST_Scope = 1;
}

original_code:
void DST_Local(void)
{
 DST_Scope = 1;
}

canonical_original_code:
void DST_Local()
{
 DST_Scope = 1;
}


decompiled_code:
void DST_clear()
{
DST = 0LL;
DST_Global();
}

canonical_decompiled_code:
void func22()
{
DST = 0LL;
func20();
}

original_code:
void DST_clear(void)
{
 DST = ((void *)0);
 DST_Global();
}

canonical_original_code:
void DST_clear()
{
 DST = ((void *)0);
 DST_Global();
}


decompiled_code:
int __fastcall DST_print(const char *a1)
{
const char *i; // rbx
int result; // eax

for ( i = a1; i; i = (const char *)*((_QWORD *)i + 7) )
{
printf("Name: %s, Scope: %d\n", i + 4, *(unsigned int *)i);
Structure_print(*((_QWORD *)i + 6));
result = putchar(10);
}
return result;
}

canonical_decompiled_code:
int __fastcall func23(const char *a1)
{
const char *i; // rbx
int result; // eax

for ( i = a1; i; i = (const char *)*((_QWORD *)i + 7) )
{
printf("Name: %s, Scope: %d\n", i + 4, *(unsigned int *)i);
Structure_print(*((_QWORD *)i + 6));
result = putchar(10);
}
return result;
}

original_code:
void DST_print(struct DynamicStructureTable *dst)
{
 for (; dst != ((void *)0); dst = dst -> next)
 {
  printf("Name: %s, Scope: %d\n", dst -> name, dst -> scope);
  Structure_print(dst -> attr);
  printf("\n");
 }
}


decompiled_code:
int __fastcall print_indent(int a1)
{
int i; // ebx
int result; // eax

for ( i = a1; i; --i )
result = putchar(32);
return result;
}

canonical_decompiled_code:
int __fastcall func0(int a1)
{
int i; // ebx
int result; // eax

for ( i = a1; i; --i )
result = putchar(32);
return result;
}

original_code:
void print_indent(int x)
{
 while (x --)
 {
  printf(" ");
 }
}

variable_types: x int


decompiled_code:
__int64 __fastcall String_to_Int(int a1, __int64 a2)
{
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

switch ( a1 )
{
case 8:
_isoc99_sscanf(a2, &unk_B1, v3);
break;
case 10:
_isoc99_sscanf(a2, &unk_B4, v3);
break;
case 16:
_isoc99_sscanf(a2, &unk_B7, v3);
break;
default:
perror("Error: (Function)String_to_UnsignedInt\n");
break;
}
return (unsigned int)v3[0];
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, __int64 a2)
{
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

switch ( a1 )
{
case 8:
_isoc99_sscanf(a2, &unk_B1, v3);
break;
case 10:
_isoc99_sscanf(a2, &unk_B4, v3);
break;
case 16:
_isoc99_sscanf(a2, &unk_B7, v3);
break;
default:
perror("Error: (Function)String_to_UnsignedInt\n");
break;
}
return (unsigned int)v3[0];
}

original_code:
int String_to_Int(int string_type, char *string_digit)
{
  int ret;
 if (string_type == 8)
  sscanf(string_digit, "%o", &ret);
 else if (string_type == 10)
  sscanf(string_digit, "%d", &ret);
 else if (string_type == 16)
  sscanf(string_digit, "%x", &ret);
 else
  perror("Error: (Function)String_to_UnsignedInt\n");
 return ret;
}


decompiled_code:
float __fastcall String_to_Float(__int64 a1)
{
float v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

_isoc99_sscanf(a1, &unk_BA, v2);
return v2[0];
}

canonical_decompiled_code:
float __fastcall func2(__int64 a1)
{
float v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

_isoc99_sscanf(a1, &unk_BA, v2);
return v2[0];
}

original_code:
float String_to_Float(char *string_digit)
{
 float ret;
 sscanf(string_digit, "%f", &ret);
 return ret;
}

variable_types: ret float

return_type: float


SyntaxErrorReport

decompiled_code:
int __fastcall SyntaxErrorReport(int a1, const char *a2)
{
int result; // eax

if ( LastErrorReport != a1 )
{
LastErrorReport = a1;
result = fprintf(stderr, "\t%s\n", a2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(int a1, const char *a2)
{
int result; // eax

if ( LastErrorReport != a1 )
{
LastErrorReport = a1;
result = fprintf(stderr, "\t%s\n", a2);
}
return result;
}

original_code:
void SyntaxErrorReport(int lineno, char *message)
{
 if (lineno == LastErrorReport) return;
 LastErrorReport = lineno;
 fprintf(stderr, "\t%s\n", message);
}

variable_types: lineno int

variable_types:
message
char *


SyntaxChecker

decompiled_code:
int __fastcall SyntaxChecker(unsigned int a1, const char *a2)
{
int result; // eax

++ErrorCounter;
if ( LastErrorLineno != a1 )
{
LastErrorLineno = a1;
if ( a2 )
result = fprintf(stderr, "Error type B at line %d: Syntax Error, %s\n", a1, a2);
else
result = fprintf(stderr, "Error type B at line %d: Syntax Error\n", a1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(unsigned int a1, const char *a2)
{
int result; // eax

++ErrorCounter;
if ( LastErrorLineno != a1 )
{
LastErrorLineno = a1;
if ( a2 )
result = fprintf(stderr, "Error type B at line %d: Syntax Error, %s\n", a1, a2);
else
result = fprintf(stderr, "Error type B at line %d: Syntax Error\n", a1);
}
return result;
}

original_code:
void SyntaxChecker(int lineno, char *message)
{
 ++ ErrorCounter;
 if (lineno == LastErrorLineno) return;
 LastErrorLineno = lineno;
 if (message == ((void *)0))
  fprintf(stderr, "Error type B at line %d: Syntax Error\n", lineno);
 else
  fprintf(stderr, "Error type B at line %d: Syntax Error, %s\n", lineno, message);
}


LexChecker

decompiled_code:
int __fastcall LexChecker(unsigned int a1, const char *a2, const char *a3, const char *a4)
{
int result; // eax

++ErrorCounter;
if ( a4 )
result = fprintf(stderr, "Error type A at line %d: %s '%s', %s\n", a1, a3, a2, a4);
else
result = fprintf(stderr, "Error type A at line %d: %s '%s'\n", a1, a3, a2);
return result;
}

canonical_decompiled_code:
int __fastcall func0(unsigned int a1, const char *a2, const char *a3, const char *a4)
{
int result; // eax

++ErrorCounter;
if ( a4 )
result = fprintf(stderr, "Error type A at line %d: %s '%s', %s\n", a1, a3, a2, a4);
else
result = fprintf(stderr, "Error type A at line %d: %s '%s'\n", a1, a3, a2);
return result;
}

original_code:
void LexChecker(int lineno, char *text, char *error_type, char *message)
{
 ++ ErrorCounter;
 if (message != ((void *)0))
  fprintf(stderr, "Error type A at line %d: %s \'%s\', %s\n", lineno, error_type, text, message);
 else
  fprintf(stderr, "Error type A at line %d: %s \'%s\'\n", lineno, error_type, text);
}

variable_types:
text
char *


main

repo: yinyin/coderunner

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
const char *v4; // rax
unsigned int v5; // ebx
__uid_t v6; // eax
struct passwd *v7; // rax
const char *v8; // rsi
__uid_t v9; // eax
struct passwd *v10; // rax
const char *v11; // rsi
char *v13; // rsi
char *v14; // rsi
char v15[4120]; // [rsp+0h] [rbp-1018h] BYREF

if ( argc <= 1 )
goto LABEL_5;
v3 = argv + 1;
do
printf("A: %s\n", *v3++);
while ( v3 != &argv[(unsigned int)(argc - 2) + 2] );
v4 = argv[1];
if ( *v4 == 78 )
{
v5 = v4[1] - 48;
printf("NPRT: %d\n", v5);
if ( (v5 & 1) != 0 )
goto LABEL_12;
}
else
{
LABEL_5:
LOBYTE(v5) = 0;
}
v6 = getuid();
v7 = getpwuid(v6);
if ( v7 )
v8 = v7->pw_name;
else
v8 = (const char *)&unk_402004;
printf("Un: %s\n", v8);
v9 = geteuid();
v10 = getpwuid(v9);
if ( v10 )
v11 = v10->pw_name;
else
v11 = (const char *)&unk_402004;
printf("Ue: %s\n", v11);
LABEL_12:
if ( (v5 & 2) == 0 )
{
v13 = getenv("ENV1");
if ( !v13 )
v13 = (char *)"-";
printf("E1: %s\n", v13);
v14 = getenv("ENV2");
if ( !v14 )
v14 = (char *)"-";
printf("E2: %s\n", v14);
}
if ( (v5 & 4) == 0 )
{
if ( getcwd(v15, 0x1000uLL) )
{
v15[4095] = 0;
printf("PWD: %s\n", v15);
}
else
{
puts("PWD: -");
}
}
fwrite("Output to STDERR.\n", 1uLL, 0x12uLL, stderr);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
 int noprint_flag;
 noprint_flag = 0;
 {
  int i;
  for(i = 1; i < argc; i++) {
   printf("A: %s\n", argv[i]);
  }
  if( (argc > 1) && ('N' == argv[1][0]) )
  {
   noprint_flag = (int)(argv[1][1] - '0');
   printf("NPRT: %d\n", noprint_flag);
  }
 }
 if(0 == (noprint_flag & 1))
 {
  struct passwd *w;
  w = getpwuid(getuid());
  printf("Un: %s\n", (((void *)0) == w) ? "?" : w->pw_name);
  w = getpwuid(geteuid());
  printf("Ue: %s\n", (((void *)0) == w) ? "?" : w->pw_name);
 }
 if(0 == (noprint_flag & 2))
 {
  char *p;
  p = getenv("ENV1");
  printf("E1: %s\n", (((void *)0) == p) ? "-" : p);
  p = getenv("ENV2");
  printf("E2: %s\n", (((void *)0) == p) ? "-" : p);
 }
 if(0 == (noprint_flag & 4))
 {
  char buf[4096];
  if(((void *)0) == getcwd(buf, 4096))
  { printf("PWD: -\n"); }
  else
  {
   buf[4096 -1] = '\0';
   printf("PWD: %s\n", buf);
  }
 }
 fprintf(stderr, "Output to STDERR.\n");
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct passwd { char *pw_name; char *pw_passwd; unsigned int pw_uid; unsigned int pw_gid; char *pw_gecos; char *pw_dir; char *pw_shell; } *

variable_types:
p
char *

variable_types:
buf
char [4096]


EnemyInit

repo: yippee-ki-yay/ShootToKill

decompiled_code:
__int64 EnemyInit()
{
__int64 *v0; // rbx
__int64 result; // rax

v0 = &enemies;
do
{
AnimLoad("../../Resource/brainmonster.png", v0);
AnimFrameSize(v0, 32LL, 64LL);
result = AnimSet(v0, "trci", 1LL, 3LL, 0LL);
*((_DWORD *)v0 + 266) = 1;
*((_DWORD *)v0 + 264) = 0;
*((_DWORD *)v0 + 265) = 0;
v0 += 134;
}
while ( v0 != (__int64 *)(unsigned int)((_DWORD)&enemies + 107200) );
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 *v0; // rbx
__int64 result; // rax

v0 = &enemies;
do
{
AnimLoad("../../Resource/brainmonster.png", v0);
AnimFrameSize(v0, 32LL, 64LL);
result = AnimSet(v0, "trci", 1LL, 3LL, 0LL);
*((_DWORD *)v0 + 266) = 1;
*((_DWORD *)v0 + 264) = 0;
*((_DWORD *)v0 + 265) = 0;
v0 += 134;
}
while ( v0 != (__int64 *)(unsigned int)((_DWORD)&enemies + 107200) );
return result;
}

original_code:
void EnemyInit()
{
    int i;
    for(i = 0; i < 100; ++i)
    {
        AnimLoad( "../../Resource/brainmonster.png", &enemies[i].anim_enemy);
        AnimFrameSize(&enemies[i].anim_enemy, 32, 64);
        AnimSet(&enemies[i].anim_enemy, "trci", 1, 3, 0);
        enemies[i].state = 1;
        enemies[i].vel.x = 0;
        enemies[i].vel.y = 0;
    }
}

variable_types: i int


EnemyDelete

decompiled_code:
__int64 EnemyDelete()
{
__int64 *v0; // rbx
__int64 result; // rax

v0 = &enemies;
do
{
result = AnimDelete(v0);
v0 += 134;
}
while ( v0 != (__int64 *)(unsigned int)((_DWORD)&enemies + 107200) );
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 *v0; // rbx
__int64 result; // rax

v0 = &enemies;
do
{
result = AnimDelete(v0);
v0 += 134;
}
while ( v0 != (__int64 *)(unsigned int)((_DWORD)&enemies + 107200) );
return result;
}

original_code:
void EnemyDelete()
{
    int i;
    for(i = 0; i < 100; ++i)
    {
        AnimDelete(&enemies[i].anim_enemy);
    }
}


EnemySpawn

decompiled_code:
__int64 EnemySpawn()
{
unsigned __int64 v0; // rax
int v1; // ebx
int v2; // eax
char v3; // dl
__int64 result; // rax

v0 = (unsigned int)((_DWORD)enemies + 1064);
v1 = 0;
while ( *(_DWORD *)v0 != 1 )
{
++v1;
v0 += 1072LL;
if ( v1 == 100 )
goto LABEL_6;
}
LODWORD(enemies[134 * v1 + 133]) = 2;
LABEL_6:
if ( rand() % 3 == 1 )
HIDWORD(enemies[134 * v1 + 132]) = -1072902963;
SetPos(enemies[134 * v1 + 128], 800LL, 485LL);
v2 = rand();
v3 = v2;
result = (unsigned int)(v2 % 2);
if ( (_DWORD)result == 1 )
{
result = 1072LL * v1;
*(float *)((char *)&enemies[132] + result) = *(float *)((char *)&enemies[132] + result) - 2.0;
}
else if ( (v3 & 1) == 0 )
{
result = 1072LL * v1;
**(_DWORD **)((char *)&enemies[128] + result) = 0;
*(float *)((char *)&enemies[132] + result) = *(float *)((char *)&enemies[132] + result) + 2.0;
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
unsigned __int64 v0; // rax
int v1; // ebx
int v2; // eax
char v3; // dl
__int64 result; // rax

v0 = (unsigned int)((_DWORD)enemies + 1064);
v1 = 0;
while ( *(_DWORD *)v0 != 1 )
{
++v1;
v0 += 1072LL;
if ( v1 == 100 )
goto LABEL_6;
}
LODWORD(enemies[134 * v1 + 133]) = 2;
LABEL_6:
if ( rand() % 3 == 1 )
HIDWORD(enemies[134 * v1 + 132]) = -1072902963;
SetPos(enemies[134 * v1 + 128], 800LL, 485LL);
v2 = rand();
v3 = v2;
result = (unsigned int)(v2 % 2);
if ( (_DWORD)result == 1 )
{
result = 1072LL * v1;
*(float *)((char *)&enemies[132] + result) = *(float *)((char *)&enemies[132] + result) - 2.0;
}
else if ( (v3 & 1) == 0 )
{
result = 1072LL * v1;
**(_DWORD **)((char *)&enemies[128] + result) = 0;
*(float *)((char *)&enemies[132] + result) = *(float *)((char *)&enemies[132] + result) + 2.0;
}
return result;
}

original_code:
void EnemySpawn()
{
    int i;
    for(i = 0; i < 100; ++i)
    {
         if(enemies[i].state == 1)
         {
             enemies[i].state = 2;
             break;
         }
    }
    int p = rand()%3;
    if(p == 1)
    {
        enemies[i].vel.y = -2.2;
    }
    SetPos(enemies[i].anim_enemy.img_anim, 800, 600 - 115);
    int k = rand()%2;
    if(k == 1)
    {
         enemies[i].vel.x -= 2;
    }
    else if(k == 0)
    {
        enemies[i].anim_enemy.img_anim->x = 0;
        enemies[i].vel.x += 2;
    }
}

variable_types: p int

variable_types: k int


EnemyLost

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

result = (unsigned int)((_DWORD)enemies + 1024);
do
{
if ( *(_DWORD *)(result + 40) == 2 && **(float **)result < -20.0 )
{
*(_DWORD *)(result + 40) = 1;
*(_DWORD *)(result + 32) = 0;
}
result += 1072LL;
}
while ( result != (_DWORD)enemies + 108224 );
return result;
}

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

result = (unsigned int)((_DWORD)enemies + 1024);
do
{
if ( *(_DWORD *)(result + 40) == 2 && **(float **)result < -20.0 )
{
*(_DWORD *)(result + 40) = 1;
*(_DWORD *)(result + 32) = 0;
}
result += 1072LL;
}
while ( result != (_DWORD)enemies + 108224 );
return result;
}

original_code:
void EnemyLost()
{
      int i;
    for(i = 0; i < 100; ++i)
    {
        if(enemies[i].state == 2)
        {
            if(enemies[i].anim_enemy.img_anim->x < -20)
            {
                enemies[i].state = 1;
                enemies[i].vel.x = 0;
            }
        }
    }
}


EnemyDie

decompiled_code:
unsigned __int64 EnemyDie()
{
unsigned __int64 result; // rax

result = (unsigned int)((_DWORD)enemies + 1056);
do
{
*(_DWORD *)(result + 8) = 1;
*(_DWORD *)result = 0;
result += 1072LL;
}
while ( result != (_DWORD)enemies + 108256 );
return result;
}

canonical_decompiled_code:
unsigned __int64 func5()
{
unsigned __int64 result; // rax

result = (unsigned int)((_DWORD)enemies + 1056);
do
{
*(_DWORD *)(result + 8) = 1;
*(_DWORD *)result = 0;
result += 1072LL;
}
while ( result != (_DWORD)enemies + 108256 );
return result;
}

original_code:
void EnemyDie()
{
 int i;
 for(i = 0; i < 100; ++i)
 {
     enemies[i].state = 1;
     enemies[i].vel.x = 0;
 }
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
Init(800LL, 600LL, "Distro war");
while ( (unsigned int)IsRunning() )
{
Update();
Draw();
}
Destroy();
return 0;
}

original_code:
int main(int argc, char* argv[])
{
 Init(800, 600, "Distro war");
 while(IsRunning())
 {
  Update();
  Draw();
 }
 Destroy();
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 Init(800, 600, "Distro war");
 while(IsRunning())
 {
  Update();
  Draw();
 }
 Destroy();
 return 0;
}


GameInit

decompiled_code:
__int64 GameInit()
{
unsigned int v0; // eax
__int64 result; // rax

ImageLoad("../../Resource/skyhorizon01.png", &sky);
ImageLoad("../../Resource/grass.png", &ground);
SetPos(&ground, 0LL, 550LL);
v0 = time(0LL);
srand(v0);
Int2String((unsigned int)score, &score_str);
TextLoad(&tekst, "../../Resource/alien.ttf", 36LL);
TextPos(&tekst, 720LL, 10LL);
PlayerInit();
result = EnemyInit();
percent = 142;
game_active = 1;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // eax
__int64 result; // rax

ImageLoad("../../Resource/skyhorizon01.png", &sky);
ImageLoad("../../Resource/grass.png", &ground);
SetPos(&ground, 0LL, 550LL);
v0 = time(0LL);
srand(v0);
Int2String((unsigned int)score, &score_str);
TextLoad(&tekst, "../../Resource/alien.ttf", 36LL);
TextPos(&tekst, 720LL, 10LL);
PlayerInit();
result = EnemyInit();
percent = 142;
game_active = 1;
return result;
}

original_code:
void GameInit()
{
    ImageLoad("../../Resource/skyhorizon01.png", &sky);
    ImageLoad("../../Resource/grass.png", &ground);
    SetPos(&ground, 0, 550);
    srand(time(((void *)0)));
    Int2String(score, score_str);
    TextLoad(&tekst, "../../Resource/alien.ttf", 36);
    TextPos(&tekst, 720,10);
    PlayerInit();
    EnemyInit();
    percent = 142;
    game_active = 1;
}


GameDelete

decompiled_code:
__int64 GameDelete()
{
ImageDelete(&sky);
ImageDelete(&ground);
PlayerDelete();
TextDelete(&tekst);
return EnemyDelete();
}

canonical_decompiled_code:
__int64 func1()
{
ImageDelete(&sky);
ImageDelete(&ground);
PlayerDelete();
TextDelete(&tekst);
return EnemyDelete();
}

original_code:
void GameDelete()
{
    ImageDelete(&sky);
    ImageDelete(&ground);
    PlayerDelete();
    TextDelete(&tekst);
    EnemyDelete();
}


CollEnemyWithBullets

decompiled_code:
void __fastcall CollEnemyWithBullets(_DWORD *a1)
{
_DWORD *v1; // r14
_DWORD *v2; // rbx

v1 = &enemies;
do
{
if ( v1[266] == 2 && (unsigned int)AnimCollision(v1, (unsigned int)((_DWORD)&player + 16)) )
{
game_active = 0;
EnemyDie();
PlayerRestart();
score_str = 48;
EndGetScore((unsigned int)score);
score = 0;
SDL_Delay(300LL);
*a1 = 5;
}
v2 = &bullets;
do
{
if ( v1[266] == 2 && v2[4] == 2 && (unsigned int)RecCollision(*(_QWORD *)v2, *((_QWORD *)v1 + 128), 32LL, 64LL) )
{
v1[266] = 1;
v1[264] = 0;
v2[4] = 1;
v2[2] = 0;
score += 20;
Int2String((unsigned int)score, &score_str);
if ( score <= 139 )
percent -= score;
if ( percent <= 9 )
percent = 20;
}
v2 += 6;
}
while ( v2 != (_DWORD *)(unsigned int)((_DWORD)&bullets + 2400) );
v1 += 268;
}
while ( v1 != (_DWORD *)(unsigned int)((_DWORD)&enemies + 107200) );
}

canonical_decompiled_code:
void __fastcall func3(_DWORD *a1)
{
_DWORD *v1; // r14
_DWORD *v2; // rbx

v1 = &enemies;
do
{
if ( v1[266] == 2 && (unsigned int)AnimCollision(v1, (unsigned int)((_DWORD)&player + 16)) )
{
game_active = 0;
EnemyDie();
PlayerRestart();
score_str = 48;
EndGetScore((unsigned int)score);
score = 0;
SDL_Delay(300LL);
*a1 = 5;
}
v2 = &bullets;
do
{
if ( v1[266] == 2 && v2[4] == 2 && (unsigned int)RecCollision(*(_QWORD *)v2, *((_QWORD *)v1 + 128), 32LL, 64LL) )
{
v1[266] = 1;
v1[264] = 0;
v2[4] = 1;
v2[2] = 0;
score += 20;
Int2String((unsigned int)score, &score_str);
if ( score <= 139 )
percent -= score;
if ( percent <= 9 )
percent = 20;
}
v2 += 6;
}
while ( v2 != (_DWORD *)(unsigned int)((_DWORD)&bullets + 2400) );
v1 += 268;
}
while ( v1 != (_DWORD *)(unsigned int)((_DWORD)&enemies + 107200) );
}

original_code:
void CollEnemyWithBullets(int* state)
{
    int i, j;
    for(i = 0; i < 100; ++i)
    {
        if((enemies[i].state == 2))
        {
            if(AnimCollision(&enemies[i].anim_enemy, &(player.anim_player)))
            {
                  game_active = 0;
                  EnemyDie();
                  PlayerRestart();
                  score_str[0] = '0';
                  EndGetScore(score);
                  score = 0;
                  SDL_Delay(300);
                *state = 5;
            }
        }
        for(j = 0; j < 100; ++j)
        {
            if(enemies[i].state == 2 && bullets[j].state == 2)
            {
                if(RecCollision(bullets[j].img_bullet, enemies[i].anim_enemy.img_anim, 32, 64))
                {
                    enemies[i].state = 1;
                    enemies[i].vel.x = 0;
                    bullets[j].state = 1;
                    bullets[j].vel.x = 0;
                    score += 20;
                    Int2String(score, score_str);
                     if(score < 140)
                     {
                         percent -= score;
                     }
                     if(percent < 10) percent = 20;
                }
            }
        }
    }
}

canonical_original_code:
void CollEnemyWithBullets(int *state)
{
    int i; int j;
    for(i = 0; i < 100; ++i)
    {
        if((enemies[i].state == 2))
        {
            if(AnimCollision(&enemies[i].anim_enemy, &(player.anim_player)))
            {
                  game_active = 0;
                  EnemyDie();
                  PlayerRestart();
                  score_str[0] = '0';
                  EndGetScore(score);
                  score = 0;
                  SDL_Delay(300);
                *state = 5;
            }
        }
        for(j = 0; j < 100; ++j)
        {
            if(enemies[i].state == 2 && bullets[j].state == 2)
            {
                if(RecCollision(bullets[j].img_bullet, enemies[i].anim_enemy.img_anim, 32, 64))
                {
                    enemies[i].state = 1;
                    enemies[i].vel.x = 0;
                    bullets[j].state = 1;
                    bullets[j].vel.x = 0;
                    score += 20;
                    Int2String(score, score_str);
                     if(score < 140)
                     {
                         percent -= score;
                     }
                     if(percent < 10) percent = 20;
                }
            }
        }
    }
}

variable_types:
state
int *

variable_types: j int


decompiled_code:
char *__fastcall Int2String(unsigned int a1, char *a2)
{
char v3[40]; // [rsp+0h] [rbp-28h] BYREF

sprintf(v3, "%d", a1);
return strcpy(a2, v3);
}

canonical_decompiled_code:
char *__fastcall func7(unsigned int a1, char *a2)
{
char v3[40]; // [rsp+0h] [rbp-28h] BYREF

sprintf(v3, "%d", a1);
return strcpy(a2, v3);
}

original_code:
void Int2String(int p, char* str)
{
    char int_string[32];
    sprintf(int_string, "%d", p);
    strcpy(str, int_string);
}

canonical_original_code:
void Int2String(int p, char *str)
{
    char int_string[32];
    sprintf(int_string, "%d", p);
    strcpy(str, int_string);
}

variable_types:
str
char *


EndSceneInit

decompiled_code:
__int64 EndSceneInit()
{
__int64 result; // rax
char v1[12]; // [rsp+Ch] [rbp-Ch] BYREF

SDL_EnableUNICODE(1LL);
ImageLoad("../../Resource/matrix.png", &end_background);
*(_QWORD *)ime = 0LL;
*(_QWORD *)&ime[8] = 0LL;
v1[3] = 0;
v1[0] = -1;
v1[1] = 65;
v1[2] = -1;
TextLoad(&vase_ime, "../../Resource/alien.ttf", 30LL);
TextColor(&vase_ime, v1);
result = TTF_OpenFont("../../Resource/alien.ttf", 30LL);
font = result;
text = 0LL;
i = 0;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
char v1[12]; // [rsp+Ch] [rbp-Ch] BYREF

SDL_EnableUNICODE(1LL);
ImageLoad("../../Resource/matrix.png", &end_background);
*(_QWORD *)ime = 0LL;
*(_QWORD *)&ime[8] = 0LL;
v1[3] = 0;
v1[0] = -1;
v1[1] = 65;
v1[2] = -1;
TextLoad(&vase_ime, "../../Resource/alien.ttf", 30LL);
TextColor(&vase_ime, v1);
result = TTF_OpenFont("../../Resource/alien.ttf", 30LL);
font = result;
text = 0LL;
i = 0;
return result;
}

original_code:
void EndSceneInit()
{
    SDL_EnableUNICODE( 1);
    ImageLoad("../../Resource/matrix.png", &end_background);
    memset(ime, 0, 16);
    SDL_Color color = {255, 65, 255};
    TextLoad(&vase_ime, "../../Resource/alien.ttf",30);
    TextColor(&vase_ime, &color);
    font = TTF_OpenFont("../../Resource/alien.ttf", 30);
    text = ((void *)0);
    i = 0;
}

canonical_original_code:
void EndSceneInit()
{
    SDL_EnableUNICODE( 1);
    ImageLoad("../../Resource/matrix.png", &end_background);
    memset(ime, 0, 16);
    struct SDL_Color color = {255, 65, 255};
    TextLoad(&vase_ime, "../../Resource/alien.ttf",30);
    TextColor(&vase_ime, &color);
    font = TTF_OpenFont("../../Resource/alien.ttf", 30);
    text = ((void *)0);
    i = 0;
}

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


EndSceneDelete

decompiled_code:
__int64 EndSceneDelete()
{
SDL_EnableUNICODE(0LL);
ImageDelete(&end_background);
TextDelete(&vase_ime);
return SDL_FreeSurface(text);
}

canonical_decompiled_code:
__int64 func1()
{
SDL_EnableUNICODE(0LL);
ImageDelete(&end_background);
TextDelete(&vase_ime);
return SDL_FreeSurface(text);
}

original_code:
void EndSceneDelete()
{
    SDL_EnableUNICODE(0);
    ImageDelete(&end_background);
    TextDelete(&vase_ime);
    SDL_FreeSurface(text);
}


EndGetScore

decompiled_code:
void __fastcall EndGetScore(int a1)
{
player_score = a1;
}

canonical_decompiled_code:
void __fastcall func5(int a1)
{
player_score = a1;
}

original_code:
void EndGetScore(int score)
{
    player_score = score;
}

variable_types: score int


MenuInit

decompiled_code:
__int64 MenuInit()
{
ButtonInit(&start, "../../Resource/start.png", 290LL, 100LL);
ButtonInit(&quit, "../../Resource/quit.png", 290LL, 400LL);
ButtonInit(&highscore, "../../Resource/highscore.png", 290LL, 200LL);
ButtonInit(&credits, "../../Resource/credits.png", 290LL, 300LL);
return ImageLoad("../../Resource/matrix.png", &background);
}

canonical_decompiled_code:
__int64 func0()
{
ButtonInit(&start, "../../Resource/start.png", 290LL, 100LL);
ButtonInit(&quit, "../../Resource/quit.png", 290LL, 400LL);
ButtonInit(&highscore, "../../Resource/highscore.png", 290LL, 200LL);
ButtonInit(&credits, "../../Resource/credits.png", 290LL, 300LL);
return ImageLoad("../../Resource/matrix.png", &background);
}

original_code:
void MenuInit()
{
    ButtonInit(&start, "../../Resource/start.png", 290, 100);
    ButtonInit(&quit, "../../Resource/quit.png", 290, 400);
    ButtonInit(&highscore, "../../Resource/highscore.png", 290, 200);
    ButtonInit(&credits, "../../Resource/credits.png", 290, 300);
    ImageLoad("../../Resource/matrix.png", &background);
}


MenuDelete

decompiled_code:
__int64 MenuDelete()
{
ButtonDelete(&start);
ButtonDelete(&quit);
ButtonDelete(&highscore);
ButtonDelete(&credits);
return ImageDelete(&background);
}

canonical_decompiled_code:
__int64 func1()
{
ButtonDelete(&start);
ButtonDelete(&quit);
ButtonDelete(&highscore);
ButtonDelete(&credits);
return ImageDelete(&background);
}

original_code:
void MenuDelete()
{
    ButtonDelete(&start);
    ButtonDelete(&quit);
    ButtonDelete(&highscore);
    ButtonDelete(&credits);
    ImageDelete(&background);
}


compare

decompiled_code:
__int64 __fastcall compare(const void *a1, const void *a2)
{
int v2; // ecx
int v3; // edx
__int64 result; // rax

v2 = *((_DWORD *)a1 + 4);
v3 = *((_DWORD *)a2 + 4);
result = 0xFFFFFFFFLL;
if ( v2 <= v3 )
result = v2 < v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const void *a1, const void *a2)
{
int v2; // ecx
int v3; // edx
__int64 result; // rax

v2 = *((_DWORD *)a1 + 4);
v3 = *((_DWORD *)a2 + 4);
result = 0xFFFFFFFFLL;
if ( v2 <= v3 )
result = v2 < v3;
return result;
}

original_code:
int compare(const void *a, const void *b)
{
  Score* f = (Score*)a;
  Score* s = (Score*)b;
    if(f->score > s->score)
        return -1;
    else if(f->score < s->score)
        return 1;
       return 0;
}

canonical_original_code:
int compare(void *a, void *b)
{
  struct Score *f = (Score*)a;
  struct Score *s = (Score*)b;
    if(f->score > s->score)
        return -1;
    else if(f->score < s->score)
        return 1;
       return 0;
}

variable_types:
a
void *

variable_types:
b
void *

variable_types: struct Score { char name[16]; int score; } *


HighScoreDelete

decompiled_code:
__int64 HighScoreDelete()
{
char *v0; // rbx
char *v1; // rbx
__int64 result; // rax

ImageDelete(&h_background);
ButtonDelete(&h_back);
TextDelete(&h_text);
fclose(fp);
v0 = (char *)&high;
do
{
TextDelete(v0);
v0 += 24;
}
while ( v0 != (char *)(unsigned int)((_DWORD)&high + 240) );
v1 = (char *)&names;
do
{
result = TextDelete(v1);
v1 += 24;
}
while ( v1 != (char *)(unsigned int)((_DWORD)&names + 240) );
return result;
}

canonical_decompiled_code:
__int64 func2()
{
char *v0; // rbx
char *v1; // rbx
__int64 result; // rax

ImageDelete(&h_background);
ButtonDelete(&h_back);
TextDelete(&h_text);
fclose(fp);
v0 = (char *)&high;
do
{
TextDelete(v0);
v0 += 24;
}
while ( v0 != (char *)(unsigned int)((_DWORD)&high + 240) );
v1 = (char *)&names;
do
{
result = TextDelete(v1);
v1 += 24;
}
while ( v1 != (char *)(unsigned int)((_DWORD)&names + 240) );
return result;
}

original_code:
void HighScoreDelete()
{
    ImageDelete(&h_background);
    ButtonDelete(&h_back);
    TextDelete(&h_text);
      fclose(fp);
    int i = 0;
    for(; i < 10; ++i)
    {
        TextDelete(&high[i]);
    }
    for(i = 0; i < 10; ++i)
    {
        TextDelete(&names[i]);
    }
}


HighScoreAdd

decompiled_code:
int __fastcall HighScoreAdd(char *src, unsigned int a2, int a3)
{
int result; // eax
char v5[40]; // [rsp+0h] [rbp-28h] BYREF

strncpy(v5, src, a3);
v5[a3 - 1] = 0;
fprintf(fp, "%s %d\n", v5, a2);
result = fflush(fp);
++n_lines;
return result;
}

canonical_decompiled_code:
int __fastcall func3(char *src, unsigned int a2, int a3)
{
int result; // eax
char v5[40]; // [rsp+0h] [rbp-28h] BYREF

strncpy(v5, src, a3);
v5[a3 - 1] = 0;
fprintf(fp, "%s %d\n", v5, a2);
result = fflush(fp);
++n_lines;
return result;
}

original_code:
void HighScoreAdd(char* name, int score, int size)
{
    char tmp[16];
    strncpy(tmp, name, size);
    tmp[size - 1] = '\0';
    fprintf(fp,"%s %d\n", tmp, score);
    fflush(fp);
    n_lines++;
}

canonical_original_code:
void HighScoreAdd(char *name, int score, int size)
{
    char tmp[16];
    strncpy(tmp, name, size);
    tmp[size - 1] = '\0';
    fprintf(fp,"%s %d\n", tmp, score);
    fflush(fp);
    n_lines++;
}

variable_types:
name
char *

variable_types: size int

variable_types:
tmp
char [16]


HighScoreRead

decompiled_code:
void HighScoreRead()
{
char *v0; // rbx
int i; // ebp
int v2; // eax
char v3[28]; // [rsp+0h] [rbp-38h] BYREF
int v4; // [rsp+1Ch] [rbp-1Ch] BYREF

fp = fopen("../../Resource/highscore.txt", "a+");
v0 = scores;
for ( i = 0; ; ++i )
{
v2 = fscanf(fp, "%s %d", v3, &v4);
if ( i > 199 || v2 == -1 )
break;
*((_DWORD *)v0 + 4) = v4;
strcpy(v0, v3);
v0 += 20;
}
qsort(scores, i, 0x14uLL, (__compar_fn_t)compare);
tt = i;
}

canonical_decompiled_code:
void func6()
{
char *v0; // rbx
int i; // ebp
int v2; // eax
char v3[28]; // [rsp+0h] [rbp-38h] BYREF
int v4; // [rsp+1Ch] [rbp-1Ch] BYREF

fp = fopen("../../Resource/highscore.txt", "a+");
v0 = scores;
for ( i = 0; ; ++i )
{
v2 = fscanf(fp, "%s %d", v3, &v4);
if ( i > 199 || v2 == -1 )
break;
*((_DWORD *)v0 + 4) = v4;
strcpy(v0, v3);
v0 += 20;
}
qsort(scores, i, 0x14uLL, (__compar_fn_t)compare);
tt = i;
}

original_code:
void HighScoreRead()
{
    int i = 0, skor;
    char ime[16];
    fp = fopen("../../Resource/highscore.txt", "a+");
    while(fscanf(fp, "%s %d", ime, &skor) != (-1) && i < 200)
    {
        scores[i].score = skor;
        strcpy(scores[i].name, ime);
        i++;
    }
    qsort(scores, i, sizeof(Score), compare);
    tt= i;
}

canonical_original_code:
void HighScoreRead()
{
    int i = 0; int skor;
    char ime[16];
    fp = fopen("../../Resource/highscore.txt", "a+");
    while(fscanf(fp, "%s %d", ime, &skor) != (-1) && i < 200)
    {
        scores[i].score = skor;
        strcpy(scores[i].name, ime);
        i++;
    }
    qsort(scores, i, sizeof(Score), compare);
    tt= i;
}

variable_types: skor int

variable_types:
ime
char [16]


HighScoreInit

decompiled_code:
void HighScoreInit()
{
char *v0; // rbx
char *v1; // rbx
char v2[4]; // [rsp+8h] [rbp-20h] BYREF
char v3[28]; // [rsp+Ch] [rbp-1Ch] BYREF

v3[3] = 0;
v3[0] = -1;
v3[1] = -1;
v3[2] = -1;
ImageLoad("../../Resource/matrix.png", &h_background);
TextLoad(&h_text, "../../Resource/alien.ttf", 46LL);
TextPos(&h_text, 200LL, 50LL);
TextColor(&h_text, v3);
ButtonInit(&h_back, "../../Resource/back.png", 700LL, 500LL);
n_lines = 0;
tt = 0;
v2[3] = 0;
v2[0] = -1;
v2[1] = -1;
v2[2] = -1;
v0 = (char *)&high;
do
{
TextLoad(v0, "../../Resource/alien.ttf", 30LL);
TextColor(v0, v2);
v0 += 24;
}
while ( v0 != (char *)(unsigned int)((_DWORD)&high + 240) );
v1 = (char *)&names;
do
{
TextLoad(v1, "../../Resource/alien.ttf", 30LL);
TextColor(v1, v2);
v1 += 24;
}
while ( v1 != (char *)(unsigned int)((_DWORD)&names + 240) );
HighScoreRead();
}

canonical_decompiled_code:
void func7()
{
char *v0; // rbx
char *v1; // rbx
char v2[4]; // [rsp+8h] [rbp-20h] BYREF
char v3[28]; // [rsp+Ch] [rbp-1Ch] BYREF

v3[3] = 0;
v3[0] = -1;
v3[1] = -1;
v3[2] = -1;
ImageLoad("../../Resource/matrix.png", &h_background);
TextLoad(&h_text, "../../Resource/alien.ttf", 46LL);
TextPos(&h_text, 200LL, 50LL);
TextColor(&h_text, v3);
ButtonInit(&h_back, "../../Resource/back.png", 700LL, 500LL);
n_lines = 0;
tt = 0;
v2[3] = 0;
v2[0] = -1;
v2[1] = -1;
v2[2] = -1;
v0 = (char *)&high;
do
{
TextLoad(v0, "../../Resource/alien.ttf", 30LL);
TextColor(v0, v2);
v0 += 24;
}
while ( v0 != (char *)(unsigned int)((_DWORD)&high + 240) );
v1 = (char *)&names;
do
{
TextLoad(v1, "../../Resource/alien.ttf", 30LL);
TextColor(v1, v2);
v1 += 24;
}
while ( v1 != (char *)(unsigned int)((_DWORD)&names + 240) );
func6();
}

original_code:
void HighScoreInit()
{
    SDL_Color textColor = { 255, 255, 255 };
    ImageLoad("../../Resource/matrix.png", &h_background);
    TextLoad(&h_text, "../../Resource/alien.ttf", 46);
    TextPos(&h_text, 200, 50);
    TextColor(&h_text, &textColor);
    ButtonInit(&h_back, "../../Resource/back.png", 700, 500);
    n_lines = 0;
      tt = 0;
    SDL_Color color = {255, 255, 255};
    int i = 0;
    for(; i < 10; ++i)
    {
        TextLoad(&high[i], "../../Resource/alien.ttf", 30);
        TextColor(&high[i], &color);
    }
     for(i = 0; i < 10; ++i)
    {
        TextLoad(&names[i], "../../Resource/alien.ttf", 30);
        TextColor(&names[i], &color);
    }
    HighScoreRead();
}

canonical_original_code:
void HighScoreInit()
{
    struct SDL_Color textColor = { 255, 255, 255 };
    ImageLoad("../../Resource/matrix.png", &h_background);
    TextLoad(&h_text, "../../Resource/alien.ttf", 46);
    TextPos(&h_text, 200, 50);
    TextColor(&h_text, &textColor);
    ButtonInit(&h_back, "../../Resource/back.png", 700, 500);
    n_lines = 0;
      tt = 0;
    struct SDL_Color color = {255, 255, 255};
    int i = 0;
    for(; i < 10; ++i)
    {
        TextLoad(&high[i], "../../Resource/alien.ttf", 30);
        TextColor(&high[i], &color);
    }
     for(i = 0; i < 10; ++i)
    {
        TextLoad(&names[i], "../../Resource/alien.ttf", 30);
        TextColor(&names[i], &color);
    }
    HighScoreRead();
}

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


BulletDelete

decompiled_code:
__int64 BulletDelete()
{
void **v0; // rbx
__int64 result; // rax

v0 = (void **)&bullets;
do
{
free(*v0);
result = ImageDelete(*v0);
v0 += 3;
}
while ( v0 != (void **)(unsigned int)((_DWORD)&bullets + 2400) );
return result;
}

canonical_decompiled_code:
__int64 func1()
{
void **v0; // rbx
__int64 result; // rax

v0 = (void **)&bullets;
do
{
free(*v0);
result = ImageDelete(*v0);
v0 += 3;
}
while ( v0 != (void **)(unsigned int)((_DWORD)&bullets + 2400) );
return result;
}

original_code:
void BulletDelete()
{
    int i;
    for(i = 0; i < 100; ++i)
    {
        free(bullets[i].img_bullet);
        ImageDelete(bullets[i].img_bullet);
    }
}


BulletFire

decompiled_code:
__int64 __fastcall BulletFire(int a1, int a2, int a3)
{
unsigned __int64 v4; // rdx
__int64 result; // rax

v4 = (unsigned int)((_DWORD)bullets + 16);
result = 0LL;
while ( *(_DWORD *)v4 != 1 )
{
result = (unsigned int)(result + 1);
v4 += 24LL;
if ( (_DWORD)result == 100 )
goto LABEL_6;
}
LODWORD(bullets[3 * (int)result + 2]) = 2;
LABEL_6:
*(float *)bullets[3 * (int)result] = (float)a1;
*(float *)(bullets[3 * (int)result] + 4) = (float)a2;
if ( a3 )
{
if ( a3 == 2 )
{
result = (int)result;
*(float *)&bullets[3 * (int)result + 1] = *(float *)&bullets[3 * (int)result + 1] - 10.0;
}
}
else
{
*(float *)&bullets[3 * (int)result + 1] = *(float *)&bullets[3 * (int)result + 1] + 10.0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2, int a3)
{
unsigned __int64 v4; // rdx
__int64 result; // rax

v4 = (unsigned int)((_DWORD)bullets + 16);
result = 0LL;
while ( *(_DWORD *)v4 != 1 )
{
result = (unsigned int)(result + 1);
v4 += 24LL;
if ( (_DWORD)result == 100 )
goto LABEL_6;
}
LODWORD(bullets[3 * (int)result + 2]) = 2;
LABEL_6:
*(float *)bullets[3 * (int)result] = (float)a1;
*(float *)(bullets[3 * (int)result] + 4) = (float)a2;
if ( a3 )
{
if ( a3 == 2 )
{
result = (int)result;
*(float *)&bullets[3 * (int)result + 1] = *(float *)&bullets[3 * (int)result + 1] - 10.0;
}
}
else
{
*(float *)&bullets[3 * (int)result + 1] = *(float *)&bullets[3 * (int)result + 1] + 10.0;
}
return result;
}

original_code:
void BulletFire(int x, int y, int side)
{
    int i;
    for(i = 0; i < 100; ++i)
    {
        if(bullets[i].state == 1)
        {
            bullets[i].state = 2;
            break;
        }
    }
    bullets[i].img_bullet->x = x;
    bullets[i].img_bullet->y = y;
    if(side == 0)
    bullets[i].vel.x += 10;
    else if(side == 2)
    bullets[i].vel.x -= 10;
}

variable_types: x int

variable_types: y int

variable_types: side int


BulletMiss

decompiled_code:
__int64 *BulletMiss()
{
__int64 *result; // rax

result = bullets;
do
{
if ( *((_DWORD *)result + 4) == 2 && *(float *)*result > 800.0 )
{
*((_DWORD *)result + 4) = 1;
*((_DWORD *)result + 2) = 0;
}
result += 3;
}
while ( result != (__int64 *)(unsigned int)((_DWORD)bullets + 2400) );
return result;
}

canonical_decompiled_code:
__int64 *func4()
{
__int64 *result; // rax

result = bullets;
do
{
if ( *((_DWORD *)result + 4) == 2 && *(float *)*result > 800.0 )
{
*((_DWORD *)result + 4) = 1;
*((_DWORD *)result + 2) = 0;
}
result += 3;
}
while ( result != (__int64 *)(unsigned int)((_DWORD)bullets + 2400) );
return result;
}

original_code:
void BulletMiss()
{
    int i;
    for(i = 0; i < 100; ++i)
    {
        if(bullets[i].state == 2)
        {
            if(bullets[i].img_bullet->x > 800)
            {
                bullets[i].state = 1;
                bullets[i].vel.x = 0;
            }
        }
    }
}

variable_types: i int


PlayerInit

decompiled_code:
__int64 PlayerInit()
{
AnimLoad("../../Resource/hero0.png", (unsigned int)((_DWORD)&player + 16));
AnimFrameSize((unsigned int)((_DWORD)&player + 16), 49LL, 65LL);
AnimSet((unsigned int)((_DWORD)&player + 16), "trci desno", 1LL, 3LL, 0LL);
AnimSet((unsigned int)((_DWORD)&player + 16), "trci levo", 1LL, 3LL, 1LL);
AnimSet((unsigned int)((_DWORD)&player + 16), "pucaj desno", 1LL, 3LL, 2LL);
AnimSet((unsigned int)((_DWORD)&player + 16), "stoji desno", 1LL, 1LL, 0LL);
AnimSet((unsigned int)((_DWORD)&player + 16), "stoji levo", 1LL, 1LL, 1LL);
AnimSet((unsigned int)((_DWORD)&player + 16), "pucaj levo", 1LL, 3LL, 3LL);
*((_DWORD *)&player + 2) = 0;
*((_DWORD *)&player + 3) = 0;
player_state = 0;
player_side = 2;
**((_DWORD **)&player + 130) = 1135542272;
*(_DWORD *)(*((_QWORD *)&player + 130) + 4LL) = 1137180672;
return BulletInit("../../Resource/fireball.png");
}

canonical_decompiled_code:
__int64 func0()
{
AnimLoad("../../Resource/hero0.png", (unsigned int)((_DWORD)&player + 16));
AnimFrameSize((unsigned int)((_DWORD)&player + 16), 49LL, 65LL);
AnimSet((unsigned int)((_DWORD)&player + 16), "trci desno", 1LL, 3LL, 0LL);
AnimSet((unsigned int)((_DWORD)&player + 16), "trci levo", 1LL, 3LL, 1LL);
AnimSet((unsigned int)((_DWORD)&player + 16), "pucaj desno", 1LL, 3LL, 2LL);
AnimSet((unsigned int)((_DWORD)&player + 16), "stoji desno", 1LL, 1LL, 0LL);
AnimSet((unsigned int)((_DWORD)&player + 16), "stoji levo", 1LL, 1LL, 1LL);
AnimSet((unsigned int)((_DWORD)&player + 16), "pucaj levo", 1LL, 3LL, 3LL);
*((_DWORD *)&player + 2) = 0;
*((_DWORD *)&player + 3) = 0;
player_state = 0;
player_side = 2;
**((_DWORD **)&player + 130) = 1135542272;
*(_DWORD *)(*((_QWORD *)&player + 130) + 4LL) = 1137180672;
return BulletInit("../../Resource/fireball.png");
}

original_code:
void PlayerInit()
{
    AnimLoad("../../Resource/hero0.png", &(player.anim_player));
    AnimFrameSize(&(player.anim_player), 49, 65);
    AnimSet(&(player.anim_player), "trci desno", 1, 3, 0);
    AnimSet(&(player.anim_player), "trci levo", 1, 3, 1);
    AnimSet(&(player.anim_player), "pucaj desno", 1, 3, 2);
    AnimSet(&(player.anim_player), "stoji desno", 1, 1, 0);
    AnimSet(&(player.anim_player), "stoji levo", 1, 1, 1);
    AnimSet(&(player.anim_player), "pucaj levo", 1, 3, 3);
    player.vel.x = 0;
    player.vel.y = 0;
    player_state = 0;
    player_side = 2;
    player.anim_player.img_anim->x = 350;
    player.anim_player.img_anim->y = 400;
    BulletInit("../../Resource/fireball.png");
}


PlayerDelete

decompiled_code:
__int64 PlayerDelete()
{
AnimDelete((unsigned int)((_DWORD)&player + 16));
return BulletDelete();
}

canonical_decompiled_code:
__int64 func1()
{
AnimDelete((unsigned int)((_DWORD)&player + 16));
return BulletDelete();
}

original_code:
void PlayerDelete()
{
    AnimDelete(&(player.anim_player));
    BulletDelete();
}


PlayerUpdate

decompiled_code:
float *PlayerUpdate()
{
float v0; // xmm0_4
float *v1; // rax
float *result; // rax

**((float **)&player + 130) = **((float **)&player + 130) + *((float *)&player + 2);
*(float *)(*((_QWORD *)&player + 130) + 4LL) = *(float *)(*((_QWORD *)&player + 130) + 4LL) + *((float *)&player + 3);
v0 = 0.0;
if ( *(float *)(*((_QWORD *)&player + 130) + 4LL) < 490.0 )
v0 = *((float *)&player + 3) + 0.03;
*((float *)&player + 3) = v0;
BulletMiss();
v1 = (float *)*((_QWORD *)&player + 130);
if ( *v1 >= 760.0 )
*v1 = 760.0;
result = (float *)*((_QWORD *)&player + 130);
if ( *result <= 0.0 )
*result = 0.0;
return result;
}

original_code:
void PlayerUpdate()
{
    player.anim_player.img_anim->x += player.vel.x;
    player.anim_player.img_anim->y += player.vel.y;
    if(player.anim_player.img_anim->y < 490)
    {
        player.vel.y += 0.03;
    }
    else
        player.vel.y = 0;
    BulletMiss();
    if(player.anim_player.img_anim->x >= 800 - 40)
            player.anim_player.img_anim->x = 800 - 40;
    if(player.anim_player.img_anim->x <= 0)
            player.anim_player.img_anim->x = 0;
}


PlayerRestart

original_code:
void PlayerRestart()
{
     player.vel.x = 0;
    player.vel.y = 0;
    player.anim_player.img_anim->x = 350;
    player.anim_player.img_anim->y = 400;
}