gcd

decompiled_code:
unsigned __int64 __fastcall gcd(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax
unsigned __int64 i; // rcx

v2 = a1;
for ( i = a1; a2; v2 = i )
{
i = a2;
a2 = v2 % a2;
}
return i;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax
unsigned __int64 i; // rcx

v2 = a1;
for ( i = a1; a2; v2 = i )
{
i = a2;
a2 = v2 % a2;
}
return i;
}

original_code:
unsigned long gcd(unsigned long x, unsigned long y)
{
  unsigned long z;
  for (;;)
    {
      if (y == 0)
 return x;
      z = x % y; x = y; y = z;
    }
}

variable_types:
x
unsigned long

variable_types:
y
unsigned long

variable_types:
z
unsigned long


lcm

repo: dagit/Cyclone-Language

decompiled_code:
unsigned __int64 __fastcall lcm(unsigned __int64 a1, unsigned __int64 a2)
{
return a2 * a1 / gcd(a1, a2);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func7(unsigned __int64 a1, unsigned __int64 a2)
{
return a2 * a1 / func6(a1, a2);
}

original_code:
unsigned long lcm(unsigned long x, unsigned long y)
{
  return (x * y) / gcd(x, y);
}

return_type: unsigned long


decompiled_code:
char *__fastcall ptr_to_ascii(const void *a1)
{
int v1; // eax

v1 = snprintf(addr_1, 0x13uLL, "%p", a1);
if ( v1 == -1 || v1 > 18 )
_fail(
"utils.c",
0xF3u,
(__int64)"ptr_to_ascii",
"Unable to convert ptr to ascii (need %d bytes, have %d)\n",
(unsigned int)v1,
19LL);
return addr_1;
}

canonical_decompiled_code:
char *__fastcall func14(const void *a1)
{
int v1; // eax

v1 = snprintf(addr_1, 0x13uLL, "%p", a1);
if ( v1 == -1 || v1 > 18 )
func8(
"utils.c",
0xF3u,
(__int64)"ptr_to_ascii",
"Unable to convert ptr to ascii (need %d bytes, have %d)\n",
(unsigned int)v1,
19LL);
return addr_1;
}

original_code:
char *ptr_to_ascii(void *ptr) {
  static char addr[((int) (3 + sizeof(void *)*2))];
  int nchars;
  nchars = snprintf(addr, ((int) (3 + sizeof(void *)*2)), "%p", ptr);
  if (nchars == -1 || nchars >= ((int) (3 + sizeof(void *)*2)))
    __fail("utils.c", 243, __FUNCTION__, "Unable to convert ptr to ascii (need %d bytes, have %d)\n", nchars, ((int) (3 + sizeof(void *)*2)));
  return addr;
}

canonical_original_code:
char *ptr_to_ascii(void *ptr) {
  static char addr[-1];
  int nchars;
  nchars = snprintf(addr, ((int) (3 + sizeof(void *)*2)), "%p", ptr);
  if (nchars == -1 || nchars >= ((int) (3 + sizeof(void *)*2)))
    __fail("utils.c", 243, __FUNCTION__, "Unable to convert ptr to ascii (need %d bytes, have %d)\n", nchars, ((int) (3 + sizeof(void *)*2)));
  return addr;
}

variable_types:
ptr
void *

variable_types:
addr
char [-1]

variable_types: nchars int

return_type: char *


decompiled_code:
unsigned __int64 __fastcall ptr_hash(unsigned __int64 a1)
{
return a1 >> 3;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func15(unsigned __int64 a1)
{
return a1 >> 3;
}

original_code:
unsigned long ptr_hash(void *ptr)
{
  return (unsigned long) ptr >> 3;
}


decompiled_code:
bool __fastcall ptr_eq(__int64 a1, __int64 a2)
{
return a2 == a1;
}

canonical_decompiled_code:
bool __fastcall func16(__int64 a1, __int64 a2)
{
return a2 == a1;
}

original_code:
bool ptr_eq(void *ptr1, void *ptr2)
{
  return ptr1 == ptr2;
}

canonical_original_code:
unsigned char ptr_eq(void *ptr1, void *ptr2)
{
  return ptr1 == ptr2;
}

return_type: unsigned char


decompiled_code:
__int64 __fastcall string_hash(char *a1)
{
char v1; // al
__int64 v2; // rcx

if ( !a1 )
return 0LL;
v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = 0LL;
do
{
++a1;
v2 = 33 * v2 + v1 + 720;
v1 = *a1;
}
while ( *a1 );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func17(char *a1)
{
char v1; // al
__int64 v2; // rcx

if ( !a1 )
return 0LL;
v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = 0LL;
do
{
++a1;
v2 = 33 * v2 + v1 + 720;
v1 = *a1;
}
while ( *a1 );
return v2;
}

original_code:
unsigned long string_hash(const char *str)
{
  const char *c;
  unsigned long h;
  c = str;
  h = 0;
  if (!c)
    return 0;
  while (*c)
    h = 33*h + 720 + *c++;
  return h;
}

canonical_original_code:
unsigned long string_hash(char *str)
{
  char *c;
  unsigned long h;
  c = str;
  h = 0;
  if (!c)
    return 0;
  while (*c)
    h = 33*h + 720 + *c++;
  return h;
}

variable_types:
str
char *

variable_types:
c
char *

variable_types:
h
unsigned long


decompiled_code:
bool __fastcall string_eq(const char *a1, const char *a2)
{
bool result; // al

if ( a1 && a2 )
result = strcmp(a1, a2) == 0;
else
result = 0;
return result;
}

canonical_decompiled_code:
bool __fastcall func18(const char *a1, const char *a2)
{
bool result; // al

if ( a1 && a2 )
result = strcmp(a1, a2) == 0;
else
result = 0;
return result;
}

original_code:
bool string_eq(const char *s1, const char *s2)
{
  if (!s1 || !s2)
    return 0;
  return !strcmp(s1, s2);
}

canonical_original_code:
unsigned char string_eq(char *s1, char *s2)
{
  if (!s1 || !s2)
    return 0;
  return !strcmp(s1, s2);
}


decompiled_code:
__int64 __fastcall ptr_cmp(__int64 a1, __int64 a2)
{
return a1 - a2;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, __int64 a2)
{
return a1 - a2;
}

original_code:
int ptr_cmp(void *ptr1, void *ptr2)
{
  return (char *) ptr1 - (char *) ptr2;
}

return_type: int


min

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

result = a2;
if ( (int)a1 <= (int)a2 )
result = a1;
return result;
}

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

result = a2;
if ( (int)a1 <= (int)a2 )
result = a1;
return result;
}

original_code: int min(int a, int b) { if (a < b) return a; else return b; }

variable_types: a int

variable_types: b int


max

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

result = a2;
if ( (int)a1 >= (int)a2 )
result = a1;
return result;
}

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

result = a2;
if ( (int)a1 >= (int)a2 )
result = a1;
return result;
}

original_code: int max(int a, int b) { if (a < b) return b; else return a; }


decompiled_code:
__int64 banshee_serialize_end()
{
return serialize_end();
}

canonical_decompiled_code:
__int64 func5()
{
return serialize_end();
}

original_code:
void banshee_serialize_end()
{
  serialize_end();
}

return_type: void


decompiled_code:
__int64 banshee_deserialize_end()
{
return deserialize_end();
}

canonical_decompiled_code:
__int64 func7()
{
return deserialize_end();
}

original_code:
void banshee_deserialize_end(void)
{
  deserialize_end();
}

canonical_original_code:
void banshee_deserialize_end()
{
  deserialize_end();
}


decompiled_code:
__int64 gen_e_set_fields()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 1LL;
}

original_code:
bool gen_e_set_fields(void *obj)
{
  return 1;
}

canonical_original_code:
unsigned char gen_e_set_fields(void *obj)
{
  return 1;
}

variable_types:
obj
void *


original_code:
void
do_heapsort(int n, double *ra) {
    int i, j;
    int ir = n;
    int l = (n >> 1) + 1;
    double rra;
    for (;;) {
 if (l > 1) {
     rra = ra[--l];
 } else {
     rra = ra[ir];
     ra[ir] = ra[1];
     if (--ir == 1) {
  ra[1] = rra;
  return;
     }
 }
 i = l;
 j = l << 1;
 while (j <= ir) {
     if (j < ir && ra[j] < ra[j+1]) { ++j; }
     if (rra < ra[j]) {
  ra[i] = ra[j];
  j += (i = j);
     } else {
  j = ir + 1;
     }
 }
 ra[i] = rra;
    }
}

canonical_original_code:
void do_heapsort(int n, double *ra) {
    int i; int j;
    int ir = n;
    int l = (n >> 1) + 1;
    double rra;
    for (;;) {
 if (l > 1) {
     rra = ra[--l];
 } else {
     rra = ra[ir];
     ra[ir] = ra[1];
     if (--ir == 1) {
  ra[1] = rra;
  return;
     }
 }
 i = l;
 j = l << 1;
 while (j <= ir) {
     if (j < ir && ra[j] < ra[j+1]) { ++j; }
     if (rra < ra[j]) {
  ra[i] = ra[j];
  j += (i = j);
     } else {
  j = ir + 1;
     }
 }
 ra[i] = rra;
    }
}

variable_types: n int

variable_types:
ra
double *

variable_types: i int

variable_types: j int

variable_types: ir int

variable_types: l int

variable_types: rra double


decompiled_code:
double __fastcall gen_random(double a1)
{
last_0 = (3877 * last_0 + 29573) % 139968;
return (double)(int)last_0 * a1 / 139968.0;
}

canonical_decompiled_code:
double __fastcall func7(double a1)
{
last_0 = (3877 * last_0 + 29573) % 139968;
return (double)(int)last_0 * a1 / 139968.0;
}

original_code:
double
gen_random(double max) {
    static long last = 42;
    return( max * (last = (last * 3877 + 29573) % 139968) / 139968 );
}

variable_types: max double

variable_types: last long

return_type: double


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double *v3; // rbp
int v4; // er12
__time_t v5; // rbp
int v7; // er13
__int64 v8; // rbx
__int64 v9; // rbx
struct timeval v10; // [rsp+0h] [rbp-48h] BYREF
struct timeval tv; // [rsp+10h] [rbp-38h] BYREF

if ( argc == 2 )
{
v4 = atoi(argv[1]);
v10.tv_sec = 0LL;
v10.tv_usec = 0LL;
tv.tv_sec = 0LL;
tv.tv_usec = 0LL;
gettimeofday(&v10, 0LL);
v3 = (double *)malloc(8LL * (v4 + 1));
if ( v4 > 0 )
{
v7 = ((_BYTE)v4 - 1) & 7;
v3[1] = gen_random(1.0);
v8 = 2LL;
if ( v4 >= 2 )
{
if ( (((_BYTE)v4 - 1) & 7) == 0 )
goto LABEL_27;
if ( v7 != 1 )
{
if ( v7 != 2 )
{
if ( v7 != 3 )
{
if ( v7 != 4 )
{
if ( v7 != 5 )
{
if ( v7 != 6 )
{
v3[2] = gen_random(1.0);
v8 = 3LL;
}
v3[v8++] = gen_random(1.0);
}
v3[v8++] = gen_random(1.0);
}
v3[v8++] = gen_random(1.0);
}
v3[v8++] = gen_random(1.0);
}
v3[v8++] = gen_random(1.0);
}
v3[v8++] = gen_random(1.0);
if ( v4 >= (int)v8 )
{
LABEL_27:
do
{
v3[v8] = gen_random(1.0);
v9 = v8 + 1;
v3[v9] = gen_random(1.0);
v3[v9 + 1] = gen_random(1.0);
v3[v9 + 2] = gen_random(1.0);
v3[v9 + 3] = gen_random(1.0);
v3[v9 + 4] = gen_random(1.0);
v3[v9 + 5] = gen_random(1.0);
v3[v9 + 6] = gen_random(1.0);
v8 = v9 + 7;
}
while ( v4 >= (int)v8 );
}
}
}
}
else
{
v10.tv_sec = 0LL;
v10.tv_usec = 0LL;
tv.tv_sec = 0LL;
tv.tv_usec = 0LL;
gettimeofday(&v10, 0LL);
v3 = (double *)malloc(0x10uLL);
v3[1] = gen_random(1.0);
v4 = 1;
}
do_heapsort(v4, (__int64)v3);
printf("%.10f\n", v3[v4]);
free(v3);
gettimeofday(&tv, 0LL);
v5 = tv.tv_sec - v10.tv_sec;
v10.tv_sec = tv.tv_sec - v10.tv_sec;
if ( tv.tv_usec - v10.tv_usec < 0 )
{
v10.tv_usec = tv.tv_usec - v10.tv_usec + 1000000;
v10.tv_sec = v5 - 1;
}
else
{
v10.tv_usec = tv.tv_usec - v10.tv_usec;
}
fprintf(stderr, "%d.%06d\n", v10.tv_sec, v10.tv_usec);
fflush(stderr);
return 0;
}

original_code:
int
main(int argc, char *argv[]) {
    int N = ((argc == 2) ? atoi(argv[1]) : 1);
    double *ary;
    int i;
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    ary = (double *)malloc((N+1) * sizeof(double));
    for (i=1; i<=N; i++) {
 ary[i] = gen_random(1);
    }
    do_heapsort(N, ary);
    printf("%.10f\n", ary[N]);
    free(ary);
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return(0);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: N int

variable_types:
ary
double *

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


original_code:
static unsigned long state_hash(hash_key key)
{
  unsigned long keyval = (unsigned long)key;
  keyval += (keyval << 12);
  keyval ^= (keyval >> 22);
  keyval += (keyval << 4);
  keyval ^= (keyval >> 9);
  keyval += (keyval << 10);
  keyval ^= (keyval >> 2);
  keyval += (keyval << 7);
  keyval ^= (keyval >> 12);
  return keyval;
}

canonical_original_code:
static unsigned long state_hash(void *key)
{
  unsigned long keyval = (unsigned long)key;
  keyval += (keyval << 12);
  keyval ^= (keyval >> 22);
  keyval += (keyval << 4);
  keyval ^= (keyval >> 9);
  keyval += (keyval << 10);
  keyval ^= (keyval >> 2);
  keyval += (keyval << 7);
  keyval ^= (keyval >> 12);
  return keyval;
}

variable_types:
key
void *

variable_types:
keyval
unsigned long


decompiled_code:
bool __fastcall state_eq(__int64 a1, __int64 a2)
{
return a2 == a1;
}

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

original_code:
static bool state_eq(hash_key state1, hash_key state2)
{
  return state1 == state2;
}

canonical_original_code:
static unsigned char state_eq(void *state1, void *state2)
{
  return state1 == state2;
}


decompiled_code:
void *regexp_calloc()
{
return calloc(1uLL, 0x30uLL);
}

canonical_decompiled_code:
void *func2()
{
return calloc(1uLL, 0x30uLL);
}

original_code:
static regexp regexp_calloc() {
  return (regexp) calloc (1, sizeof(struct regexp_));
}

canonical_original_code:
static struct regexp_ *regexp_calloc() {
  return (struct regexp_ *) calloc (1, sizeof(struct regexp_));
}

return_type: struct regexp_ { unsigned char length; unsigned char *expr; unsigned char necessary[32]; } *


decompiled_code:
void *__fastcall regexp_alloc_str(unsigned __int8 a1)
{
return malloc(a1);
}

canonical_decompiled_code:
void *__fastcall func3(unsigned __int8 a1)
{
return malloc(a1);
}

original_code:
static letter* regexp_alloc_str(unsigned char length) {
  return (unsigned char *) malloc (sizeof(letter) * length);
}

canonical_original_code:
static unsigned char *regexp_alloc_str(unsigned char length) {
  return (unsigned char *) malloc (sizeof(letter) * length);
}

variable_types:
length
unsigned char

return_type: unsigned char *


decompiled_code:
__int64 __fastcall regexp_print_subexpr(__int64 a1, unsigned __int8 a2, unsigned __int8 a3)
{
unsigned __int8 v5; // bp
__int64 v6; // rbx
unsigned __int64 v7; // r13
int v8; // edi
__int64 result; // rax

v5 = a2;
if ( a2 >= a3 )
{
LABEL_5:
v6 = v5;
result = *(_QWORD *)(a1 + 8);
if ( *(_BYTE *)(result + v5) != 1 )
return result;
}
else
{
v6 = a2;
v7 = a2 + (unsigned __int64)(unsigned __int8)(a3 - 1 - a2) + 1;
while ( 1 )
{
v5 = v6;
v8 = *(unsigned __int8 *)(*(_QWORD *)(a1 + 8) + v6);
if ( v8 == 1 )
break;
putchar(v8);
v5 = ++v6;
if ( v6 == v7 )
goto LABEL_5;
}
}
putchar(40);
regexp_print_subexpr(a1, (unsigned __int8)(v5 + 2), (unsigned __int8)(*(_BYTE *)(*(_QWORD *)(a1 + 8) + v6 + 1) + v5));
putchar(41);
putchar(42);
return regexp_print_subexpr(a1, (unsigned __int8)(v5 + *(_BYTE *)(*(_QWORD *)(a1 + 8) + v6 + 1) + 1), a3);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned __int8 a2, unsigned __int8 a3)
{
unsigned __int8 v5; // bp
__int64 v6; // rbx
unsigned __int64 v7; // r13
int v8; // edi
__int64 result; // rax

v5 = a2;
if ( a2 >= a3 )
{
LABEL_5:
v6 = v5;
result = *(_QWORD *)(a1 + 8);
if ( *(_BYTE *)(result + v5) != 1 )
return result;
}
else
{
v6 = a2;
v7 = a2 + (unsigned __int64)(unsigned __int8)(a3 - 1 - a2) + 1;
while ( 1 )
{
v5 = v6;
v8 = *(unsigned __int8 *)(*(_QWORD *)(a1 + 8) + v6);
if ( v8 == 1 )
break;
putchar(v8);
v5 = ++v6;
if ( v6 == v7 )
goto LABEL_5;
}
}
putchar(40);
func4(a1, (unsigned __int8)(v5 + 2), (unsigned __int8)(*(_BYTE *)(*(_QWORD *)(a1 + 8) + v6 + 1) + v5));
putchar(41);
putchar(42);
return func4(a1, (unsigned __int8)(v5 + *(_BYTE *)(*(_QWORD *)(a1 + 8) + v6 + 1) + 1), a3);
}

original_code:
static void regexp_print_subexpr(regexp r, unsigned char start,
     unsigned char end) {
  while (start < end && r->expr[start] != STAR) {
    putchar(r->expr[start]);
    start++;
  }
  if (r->expr[start] == STAR) {
    putchar('(');
    regexp_print_subexpr(r, start + 2, start + r->expr[start + 1]);
    putchar(')');
    putchar('*');
    regexp_print_subexpr(r, start + r->expr[start+1] + 1, end);
  }
}

canonical_original_code:
static void regexp_print_subexpr(struct regexp_ *r, unsigned char start, unsigned char end) {
  while (start < end && r->expr[start] != STAR) {
    putchar(r->expr[start]);
    start++;
  }
  if (r->expr[start] == STAR) {
    putchar('(');
    regexp_print_subexpr(r, start + 2, start + r->expr[start + 1]);
    putchar(')');
    putchar('*');
    regexp_print_subexpr(r, start + r->expr[start+1] + 1, end);
  }
}

variable_types: struct regexp_ { unsigned char length; unsigned char *expr; unsigned char necessary[32]; } *

variable_types:
start
unsigned char

variable_types:
end
unsigned char


decompiled_code:
_QWORD *regexp_empty()
{
_QWORD *v0; // rbx
_BYTE *v1; // rax

v0 = regexp_calloc();
*(_BYTE *)v0 = 0;
v1 = regexp_alloc_str(1u);
v0[1] = v1;
*v1 = 0;
return v0;
}

original_code:
regexp regexp_empty() {
  regexp result = regexp_calloc();
  result->length = 0;
  result->expr = regexp_alloc_str(1);
  result->expr[0] = 0;
  return result;
}

canonical_original_code:
struct regexp_ *regexp_empty() {
  struct regexp_ *result = regexp_calloc();
  result->length = 0;
  result->expr = regexp_alloc_str(1);
  result->expr[0] = 0;
  return result;
}

user_defined_types: struct regexp_ { unsigned char length; unsigned char *expr; unsigned char necessary[32]; }


decompiled_code:
__int64 __fastcall regexp_fast_disinclusion(__int64 a1, __int64 a2)
{
return 2 * (unsigned int)(memcmp((const void *)(a1 + 16), (const void *)(a2 + 16), 0x20uLL) > 0) - 1;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
return 2 * (unsigned int)(memcmp((const void *)(a1 + 16), (const void *)(a2 + 16), 0x20uLL) > 0) - 1;
}

original_code:
int regexp_fast_disinclusion(regexp r1, regexp r2) {
  if (memcmp(r1->necessary, r2->necessary, sizeof(unsigned char) * 32) > 0) {
    return 1;
  }
  return -1;
}

canonical_original_code:
int regexp_fast_disinclusion(struct regexp_ *r1, struct regexp_ *r2) {
  if (memcmp(r1->necessary, r2->necessary, sizeof(unsigned char) * 32) > 0) {
    return 1;
  }
  return -1;
}


decompiled_code:
int __fastcall regexp_print_expr(unsigned __int8 *a1)
{
regexp_print_subexpr((__int64)a1, 0, *a1);
return fflush(stdout);
}

canonical_decompiled_code:
int __fastcall func10(unsigned __int8 *a1)
{
func4((__int64)a1, 0, *a1);
return fflush(stdout);
}

original_code:
void regexp_print_expr(regexp r) {
  regexp_print_subexpr(r, 0, r->length);
  fflush(stdout);
}

canonical_original_code:
void regexp_print_expr(struct regexp_ *r) {
  regexp_print_subexpr(r, 0, r->length);
  fflush(stdout);
}


decompiled_code:
int __fastcall regexp_print_necessary(__int64 a1)
{
__int64 v1; // rbx
unsigned int v2; // ebp
__int64 v3; // rax

printf("Necessary characters in %s:\n", *(const char **)(a1 + 8));
v1 = 0LL;
do
{
v2 = v1++;
v3 = bfx(a1 + 16, v1, 1LL);
if ( v3 )
LODWORD(v3) = printf("%c (%d) \n", v2, v2);
}
while ( v1 != 256 );
return v3;
}

canonical_decompiled_code:
int __fastcall func11(__int64 a1)
{
__int64 v1; // rbx
unsigned int v2; // ebp
__int64 v3; // rax

printf("Necessary characters in %s:\n", *(const char **)(a1 + 8));
v1 = 0LL;
do
{
v2 = v1++;
v3 = bfx(a1 + 16, v1, 1LL);
if ( v3 )
LODWORD(v3) = printf("%c (%d) \n", v2, v2);
}
while ( v1 != 256 );
return v3;
}

original_code:
void regexp_print_necessary(regexp r) {
  int i;
  printf("Necessary characters in %s:\n", r->expr);
  for (i = 0; i < 256; i++) {
    if (bfx(r->necessary, i+1, 1)) {
      printf("%c (%d) \n",i, i);
    }
  }
}

canonical_original_code:
void regexp_print_necessary(struct regexp_ *r) {
  int i;
  printf("Necessary characters in %s:\n", r->expr);
  for (i = 0; i < 256; i++) {
    if (bfx(r->necessary, i+1, 1)) {
      printf("%c (%d) \n",i, i);
    }
  }
}

variable_types: i int


member

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

LODWORD(result) = *(_DWORD *)(a1 + 4LL * a3);
if ( !(_DWORD)result )
return 0LL;
while ( a4 != (_DWORD)result )
{
a3 = a2 & (a3 + 5189);
result = *(unsigned int *)(a1 + 4LL * a3);
if ( !(_DWORD)result )
return result;
}
return 1LL;
}

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

LODWORD(result) = *(_DWORD *)(a1 + 4LL * a3);
if ( !(_DWORD)result )
return 0LL;
while ( a4 != (_DWORD)result )
{
a3 = a2 & (a3 + 5189);
result = *(unsigned int *)(a1 + 4LL * a3);
if ( !(_DWORD)result )
return result;
}
return 1LL;
}

original_code:
static bool member(int *table, int ub, int i, int value)
{
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return 1;
      else
 i = ub & (i + prime_2);
    }
  return 0;
}

canonical_original_code:
static unsigned char member(int *table, int ub, int i, int value)
{
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return 1;
      else
 i = ub & (i + prime_2);
    }
  return 0;
}

variable_types:
table
int *

variable_types: ub int

variable_types: value int


reinsert

decompiled_code:
__int64 __fastcall reinsert(__int64 a1, int a2, int a3)
{
__int64 result; // rax
int *v6; // rcx
int v7; // edx

result = a2 & (unsigned int)(83 * a3);
v6 = (int *)(a1 + 4LL * (int)result);
v7 = *v6;
if ( *v6 )
{
while ( a3 != v7 )
{
result = a2 & (unsigned int)(result + 5189);
v6 = (int *)(a1 + 4LL * (int)result);
v7 = *v6;
if ( !*v6 )
goto LABEL_4;
}
}
else
{
LABEL_4:
*v6 = a3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, int a3)
{
__int64 result; // rax
int *v6; // rcx
int v7; // edx

result = a2 & (unsigned int)(83 * a3);
v6 = (int *)(a1 + 4LL * (int)result);
v7 = *v6;
if ( *v6 )
{
while ( a3 != v7 )
{
result = a2 & (unsigned int)(result + 5189);
v6 = (int *)(a1 + 4LL * (int)result);
v7 = *v6;
if ( !*v6 )
goto LABEL_4;
}
}
else
{
LABEL_4:
*v6 = a3;
}
return result;
}

original_code:
static inline void reinsert(int *table, int ub, int value)
{
  int i;
  i = ub & (prime_1 * value);
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return;
      else
 i = ub & (i + prime_2);
    }
  table[i] = value;
}


decompiled_code:
__int64 __fastcall member_or_insert(__int64 a1, int a2, int a3, int a4)
{
int *v6; // rcx
int v7; // eax
__int64 result; // rax

v6 = (int *)(a1 + 4LL * a3);
v7 = *v6;
if ( *v6 )
{
while ( a4 != v7 )
{
a3 = a2 & (a3 + 5189);
v6 = (int *)(a1 + 4LL * a3);
v7 = *v6;
if ( !*v6 )
goto LABEL_4;
}
result = 1LL;
}
else
{
LABEL_4:
*v6 = a4;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2, int a3, int a4)
{
int *v6; // rcx
int v7; // eax
__int64 result; // rax

v6 = (int *)(a1 + 4LL * a3);
v7 = *v6;
if ( *v6 )
{
while ( a4 != v7 )
{
a3 = a2 & (a3 + 5189);
v6 = (int *)(a1 + 4LL * a3);
v7 = *v6;
if ( !*v6 )
goto LABEL_4;
}
result = 1LL;
}
else
{
LABEL_4:
*v6 = a4;
result = 0LL;
}
return result;
}

original_code:
static bool member_or_insert(int *table, int ub, int i, int value)
{
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return 1;
      else
 i = ub & (i + prime_2);
    }
  table[i] = value;
  return 0;
}

canonical_original_code:
static unsigned char member_or_insert(int *table, int ub, int i, int value)
{
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return 1;
      else
 i = ub & (i + prime_2);
    }
  table[i] = value;
  return 0;
}


rehash

original_code:
static void rehash(hash_set hs)
{
  int *old_table;
  int old_capacity, i;
  old_table = hs->table;
  old_capacity = hs->capacity;
  hs->capacity *= 2;
  hs->ub = ((1<<++hs->size)-1);
  hs->table = (int *)calloc(hs->capacity, sizeof(int));
  ((void) (0));
  for (i = 0; i < old_capacity; i++)
    {
      reinsert(hs->table, hs->ub, old_table[i]);
    }
  free(old_table);
}

canonical_original_code:
static void rehash(struct hash_set *hs)
{
  int *old_table;
  int old_capacity; int i;
  old_table = hs->table;
  old_capacity = hs->capacity;
  hs->capacity *= 2;
  hs->ub = ((1<<++hs->size)-1);
  hs->table = (int *)calloc(hs->capacity, sizeof(int));
  ((void) (0));
  for (i = 0; i < old_capacity; i++)
    {
      reinsert(hs->table, hs->ub, old_table[i]);
    }
  free(old_table);
}

variable_types: struct hash_set { int *table; unsigned int ub; unsigned int capacity; unsigned int inserts; unsigned int size; } *


original_code:
static void post_insert(hash_set hs)
{
  int capacity = hs->capacity;
  int inserts = ++hs->inserts;
  float percent_capacity = capacity * .85;
  if ( (float) inserts >= percent_capacity)
    {
      rehash(hs);
    }
}

canonical_original_code:
static void post_insert(struct hash_set *hs)
{
  int capacity = hs->capacity;
  int inserts = ++hs->inserts;
  float percent_capacity = capacity * .85;
  if ( (float) inserts >= percent_capacity)
    {
      rehash(hs);
    }
}

variable_types: capacity int

variable_types: inserts int

user_defined_types: struct hash_set { int *table; unsigned int ub; unsigned int capacity; unsigned int inserts; unsigned int size; }


decompiled_code:
__int64 __fastcall hs_num_items(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

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

original_code:
int hs_num_items(hash_set hs)
{
  return hs->inserts;
}

canonical_original_code:
int hs_num_items(struct hash_set *hs)
{
  return hs->inserts;
}


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

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

original_code:
int *hs_list_items(hash_set hs)
{
  return hs->table;
}

canonical_original_code:
int *hs_list_items(struct hash_set *hs)
{
  return hs->table;
}

return_type: int *


original_code:
bool hs_query(hash_set hs, int entry)
{
  int hash;
  int ub = hs->ub;
  hash = ub & (prime_1 * abs(entry));
  return member(hs->table, ub, hash, entry);
}

canonical_original_code:
unsigned char hs_query(struct hash_set *hs, int entry)
{
  int hash;
  int ub = hs->ub;
  hash = ub & (prime_1 * abs(entry));
  return member(hs->table, ub, hash, entry);
}

variable_types: entry int

variable_types: hash int


decompiled_code:
__int64 __fastcall hs_member(__int64 a1, int a2)
{
unsigned int v2; // eax
unsigned int v3; // ebp

v2 = member_or_insert(*(_QWORD *)a1, *(_DWORD *)(a1 + 8), *(_DWORD *)(a1 + 8) & (83 * abs32(a2)), a2);
v3 = 1;
if ( !(_BYTE)v2 )
{
v3 = v2;
post_insert(a1);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2)
{
unsigned int v2; // eax
unsigned int v3; // ebp

v2 = func2(*(_QWORD *)a1, *(_DWORD *)(a1 + 8), *(_DWORD *)(a1 + 8) & (83 * abs32(a2)), a2);
v3 = 1;
if ( !(_BYTE)v2 )
{
v3 = v2;
func4(a1);
}
return v3;
}

original_code:
bool hs_member(hash_set hs, int entry)
{
  int hash;
  int ub = hs->ub;
  hash = ub & (prime_1 * abs(entry));
  if (member_or_insert(hs->table, ub, hash, entry))
    return 1;
  else
    {
      post_insert(hs);
      return 0;
    }
}

canonical_original_code:
unsigned char hs_member(struct hash_set *hs, int entry)
{
  int hash;
  int ub = hs->ub;
  hash = ub & (prime_1 * abs(entry));
  if (member_or_insert(hs->table, ub, hash, entry))
    return 1;
  else
    {
      post_insert(hs);
      return 0;
    }
}


decompiled_code:
void __fastcall hs_delete(void **a1)
{
free(*a1);
}

canonical_decompiled_code:
void __fastcall func10(void **a1)
{
free(*a1);
}

original_code:
void hs_delete(hash_set hs)
{
  free(hs->table);
}

canonical_original_code:
void hs_delete(struct hash_set *hs)
{
  free(hs->table);
}


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

added_edge_info_region = newregion();
result = newregion();
bounds_region = result;
return result;
}

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

added_edge_info_region = newregion();
result = newregion();
bounds_region = result;
return result;
}

original_code:
void bounds_init()
{
  added_edge_info_region = newregion();
  bounds_region = newregion();
}


decompiled_code:
__int64 bounds_reset()
{
deleteregion(bounds_region);
deleteregion(added_edge_info_region);
return bounds_init();
}

canonical_decompiled_code:
__int64 func20()
{
deleteregion(bounds_region);
deleteregion(added_edge_info_region);
return func19();
}

original_code:
void bounds_reset()
{
  deleteregion(bounds_region);
  deleteregion(added_edge_info_region);
  bounds_init();
}


Mother

original_code:
double Mother(unsigned long *pSeed)
{
 unsigned long number, number1, number2;
 short n, *p;
 unsigned short sNumber;
 if (mStart)
   {
    sNumber= *pSeed&0xFFFF;
    number = *pSeed&0x7FFFFFFF;
    p = mother1;
    for (n=18;n--;)
  {
   number=30903*sNumber+(number>>16);
   *p++=sNumber=number&0xFFFF;
   if (n==9) p = mother2;
  }
    mother1[0]&=0x7FFF;
    mother2[0]&=0x7FFF;
    mStart=0;
   }
 memmove(mother1+2,mother1+1,8*sizeof(short));
 memmove(mother2+2,mother2+1,8*sizeof(short));
 number1=mother1[0];
 number2=mother2[0];
 number1+=1941*mother1[2]+1860*mother1[3]+1812*mother1[4]+
 1776*mother1[5]+1492*mother1[6]+1215*mother1[7]+
 1066*mother1[8]+12013*mother1[9];
 number2+=1111*mother2[2]+2222*mother2[3]+3333*mother2[4]+
 4444*mother2[5]+5555*mother2[6]+6666*mother2[7]+
 7777*mother2[8]+9272*mother2[9];
 mother1[0]=number1/65536L;
 mother2[0]=number2/65536L;
 mother1[1]=0xFFFF&number1;
 mother2[1]=0xFFFF&number2;
 *pSeed=(((long)mother1[1])<<16)+(long)mother2[1];
 return ((double)*pSeed)/4294967295.0;
}

canonical_original_code:
double Mother(unsigned long *pSeed)
{
 unsigned long number; unsigned long number1; unsigned long number2;
 short n; short *p;
 unsigned short sNumber;
 if (mStart)
   {
    sNumber= *pSeed&0xFFFF;
    number = *pSeed&0x7FFFFFFF;
    p = mother1;
    for (n=18;n--;)
  {
   number=30903*sNumber+(number>>16);
   *p++=sNumber=number&0xFFFF;
   if (n==9) p = mother2;
  }
    mother1[0]&=0x7FFF;
    mother2[0]&=0x7FFF;
    mStart=0;
   }
 memmove(mother1+2,mother1+1,8*sizeof(short));
 memmove(mother2+2,mother2+1,8*sizeof(short));
 number1=mother1[0];
 number2=mother2[0];
 number1+=1941*mother1[2]+1860*mother1[3]+1812*mother1[4]+
 1776*mother1[5]+1492*mother1[6]+1215*mother1[7]+
 1066*mother1[8]+12013*mother1[9];
 number2+=1111*mother2[2]+2222*mother2[3]+3333*mother2[4]+
 4444*mother2[5]+5555*mother2[6]+6666*mother2[7]+
 7777*mother2[8]+9272*mother2[9];
 mother1[0]=number1/65536L;
 mother2[0]=number2/65536L;
 mother1[1]=0xFFFF&number1;
 mother2[1]=0xFFFF&number2;
 *pSeed=(((long)mother1[1])<<16)+(long)mother2[1];
 return ((double)*pSeed)/4294967295.0;
}

variable_types:
pSeed
unsigned long *

variable_types:
number
unsigned long

variable_types: n short

variable_types:
p
short *

variable_types:
sNumber
unsigned short


shuffle

original_code:
int shuffle()
{
 int i, j, k, l, m, n;
 unsigned long kr = 3141592;
 double r, scale, Mother();
 scale = 1.0;
 j = 52 * 4;
 r = (double)j * scale;
 k = 10 * j;
 for (i = 1; i <= k; i++)
    {
     m = (int)(r * Mother(&kr));
     n = (int)(r * Mother(&kr));
     l = card[n];
     card[n] = card[m];
     card[m] = l;
    }
 return 0;
}

canonical_original_code:
int shuffle()
{
 int i; int j; int k; int l; int m; int n;
 unsigned long kr = 3141592;
 double r; double scale; double Mother();
 scale = 1.0;
 j = 52 * 4;
 r = (double)j * scale;
 k = 10 * j;
 for (i = 1; i <= k; i++)
    {
     m = (int)(r * Mother(&kr));
     n = (int)(r * Mother(&kr));
     l = card[n];
     card[n] = card[m];
     card[m] = l;
    }
 return 0;
}

variable_types: j int

variable_types: k int

variable_types: l int

variable_types: m int

variable_types: n int

variable_types:
kr
unsigned long

variable_types: r double

variable_types: scale double

variable_types:
Mother
double ()


main

original_code:
int main(int argc, char* argv[])
{
 int i, j, k, m, n;
 int ICard, NCards, NShuf, shuffle();
 double x, y;
 char cname[13][10] = { "ACE", "TWO", "THREE",
    "FOUR", "FIVE", "SIX",
    "SEVEN", "EIGHT", "NINE",
    "TEN", "JACK", "QUEEN",
    "KING"
    };
 NCards = 52 * 4;
 NShuf = 26000;
 ICard = 103;
 if (argc > 1)
  NShuf = atoi(argv[1]);
 for (i = 0; i < 14; i++)
    {
     suit[i] = 0;
    }
 printf("SHUFFLE: Test of Random Number Generator.\n");
 printf("Counts number of occurrences of card type at position\n");
 printf("%d in card deck for %d shuffles. Ideal would be\n",ICard,NShuf);
 printf("%d occurrences for each type of card.\n", NShuf/13);
 printf(" Card   Number    Percent\n");
 printf(" value  observed  from ideal\n");
 for (k = 0; k < 4; k++)
    {
     n = 52 * k;
     for (j = 0; j < 4; j++)
   {
    m = 13 * j + n;
    for (i = 1; i < 14; i++)
  {
   card[i + m - 1] = i;
  }
   }
    }
 shuffle();
 for (i = 1; i <= NShuf; i++)
    {
     shuffle();
     j = card[ICard];
     suit[j] = suit[j] + 1;
    }
 j = 0;
 y = 13.0 / (double)NShuf;
 for (i = 1; i < 14; i++)
    {
     k = suit[i];
     x = 100.0 * ((double)k * y - 1.0);
     printf("%5s   %5d    %5.1f\n",cname[i-1],k,x);
     j = j + k;
    }
 printf("Total Cards = %d\n",j);
 return(0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int i; int j; int k; int m; int n;
 int ICard; int NCards; int NShuf; int shuffle();
 double x; double y;
 char cname[13][10] = { "ACE", "TWO", "THREE",
    "FOUR", "FIVE", "SIX",
    "SEVEN", "EIGHT", "NINE",
    "TEN", "JACK", "QUEEN",
    "KING"
    };
 NCards = 52 * 4;
 NShuf = 26000;
 ICard = 103;
 if (argc > 1)
  NShuf = atoi(argv[1]);
 for (i = 0; i < 14; i++)
    {
     suit[i] = 0;
    }
 printf("SHUFFLE: Test of Random Number Generator.\n");
 printf("Counts number of occurrences of card type at position\n");
 printf("%d in card deck for %d shuffles. Ideal would be\n",ICard,NShuf);
 printf("%d occurrences for each type of card.\n", NShuf/13);
 printf(" Card   Number    Percent\n");
 printf(" value  observed  from ideal\n");
 for (k = 0; k < 4; k++)
    {
     n = 52 * k;
     for (j = 0; j < 4; j++)
   {
    m = 13 * j + n;
    for (i = 1; i < 14; i++)
  {
   card[i + m - 1] = i;
  }
   }
    }
 shuffle();
 for (i = 1; i <= NShuf; i++)
    {
     shuffle();
     j = card[ICard];
     suit[j] = suit[j] + 1;
    }
 j = 0;
 y = 13.0 / (double)NShuf;
 for (i = 1; i < 14; i++)
    {
     k = suit[i];
     x = 100.0 * ((double)k * y - 1.0);
     printf("%5s   %5d    %5.1f\n",cname[i-1],k,x);
     j = j + k;
    }
 printf("Total Cards = %d\n",j);
 return(0);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: i int

variable_types: ICard int

variable_types: NCards int

variable_types: NShuf int

variable_types:
shuffle
int ()

variable_types: x double

variable_types: y double

variable_types:
cname
char [13][10]


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

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

original_code:
static gen_e tv_combine(const gen_e e1,const gen_e e2)
{
  return e1;
}

canonical_original_code:
static struct gen_e_ *tv_combine(struct gen_e_ *e1, struct gen_e_ *e2)
{
  return e1;
}

return_type: struct gen_e_ { enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 } sort; } *


ItemCheck

decompiled_code:
__int64 __fastcall ItemCheck(_QWORD *a1)
{
__int64 v1; // rbp

if ( !*a1 )
return a1[2];
v1 = a1[2] + ((__int64 (*)(void))ItemCheck)();
return v1 - ItemCheck(a1[1]);
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD *a1)
{
__int64 v1; // rbp

if ( !*a1 )
return a1[2];
v1 = a1[2] + ((__int64 (*)(void))ItemCheck)();
return v1 - func7(a1[1]);
}

original_code:
long ItemCheck(treeNode* tree)
{
    if (tree->left == ((void *)0))
        return tree->item;
    else
        return tree->item + ItemCheck(tree->left) - ItemCheck(tree->right);
}

canonical_original_code:
long ItemCheck(struct tn *tree)
{
    if (tree->left == ((void *)0))
        return tree->item;
    else
        return tree->item + ItemCheck(tree->left) - ItemCheck(tree->right);
}

variable_types: struct tn { struct tn *left; struct tn *right; long item; } *

return_type: long


DeleteTree

decompiled_code:
void __fastcall DeleteTree(_QWORD *a1)
{
if ( *a1 )
{
((void (*)(void))DeleteTree)();
DeleteTree(a1[1]);
}
free(a1);
}

canonical_decompiled_code:
void __fastcall func8(_QWORD *a1)
{
if ( *a1 )
{
((void (*)(void))DeleteTree)();
func8(a1[1]);
}
free(a1);
}

original_code:
void DeleteTree(treeNode* tree)
{
    if (tree->left != ((void *)0))
    {
        DeleteTree(tree->left);
        DeleteTree(tree->right);
    }
    free(tree);
}

canonical_original_code:
void DeleteTree(struct tn *tree)
{
    if (tree->left != ((void *)0))
    {
        DeleteTree(tree->left);
        DeleteTree(tree->right);
    }
    free(tree);
}

user_defined_types: struct tn { struct tn *left; struct tn *right; long item; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // edx
int v5; // er15
unsigned int v6; // ebp
_QWORD *v7; // r12
__int64 v8; // rax
int i; // er15
_QWORD *v10; // r13
__int64 v11; // rbp
_QWORD *v12; // r13
__int64 v13; // rbp
__int64 v14; // rbx
_QWORD *v15; // r13
__int64 v16; // rbp
_QWORD *v17; // r13
__int64 v18; // rbp
__int64 v19; // rbx
unsigned int v20; // er12
double v21; // xmm0_8
__int64 v22; // r14
_QWORD *v23; // rbp
_QWORD *v24; // r13
__int64 v25; // rbp
_QWORD *v26; // r13
__int64 v27; // rax
__time_t v28; // rdi
unsigned int v30; // [rsp+4h] [rbp-74h]
__int64 v31; // [rsp+8h] [rbp-70h]
_QWORD *v32; // [rsp+10h] [rbp-68h]
_QWORD *v33; // [rsp+18h] [rbp-60h]
struct timeval tv; // [rsp+20h] [rbp-58h] BYREF
struct timeval v35; // [rsp+30h] [rbp-48h] BYREF

tv.tv_sec = 0LL;
tv.tv_usec = 0LL;
v35.tv_sec = 0LL;
v35.tv_usec = 0LL;
gettimeofday(&tv, 0LL);
v3 = atol(argv[1]);
v4 = 6;
if ( v3 >= 6 )
v4 = v3;
v5 = v4;
v30 = v4;
v6 = v4 + 1;
v7 = BottomUpTree(0LL, v4 + 1);
v8 = ItemCheck(v7);
printf("stretch tree of depth %u\t check: %li\n", v6, v8);
DeleteTree(v7);
v33 = BottomUpTree(0LL, v5);
for ( i = 0; ; i += 2 )
{
v20 = i + 4;
v21 = pow(2.0, (double)(int)(v30 - i));
v22 = (unsigned int)(int)v21;
if ( (int)v21 )
{
v23 = BottomUpTree(1LL, v20);
v31 = ItemCheck(v23);
DeleteTree(v23);
v32 = BottomUpTree(-1LL, v20);
v18 = ItemCheck(v32) + v31;
DeleteTree(v32);
v19 = 2LL;
if ( (unsigned int)(int)v21 >= 2uLL )
{
if ( (((_BYTE)v22 - 1) & 1) == 0
|| (v24 = BottomUpTree(2LL, v20),
v25 = ItemCheck(v24) + v18,
DeleteTree(v24),
v26 = BottomUpTree(-2LL, v20),
v18 = ItemCheck(v26) + v25,
DeleteTree(v26),
v19 = 3LL,
(unsigned int)(int)v21 >= 3uLL) )
{
do
{
v10 = BottomUpTree(v19, v20);
v11 = ItemCheck(v10) + v18;
DeleteTree(v10);
v12 = BottomUpTree(-v19, v20);
v13 = ItemCheck(v12) + v11;
DeleteTree(v12);
v14 = v19 + 1;
v15 = BottomUpTree(v14, v20);
v16 = ItemCheck(v15) + v13;
DeleteTree(v15);
v17 = BottomUpTree(-v14, v20);
v18 = ItemCheck(v17) + v16;
DeleteTree(v17);
v19 = v14 + 1;
}
while ( v22 >= v19 );
}
}
}
else
{
v18 = 0LL;
}
printf("%li\t trees of depth %u\t check: %li\n", 2 * v22, v20, v18);
if ( v30 < i + 6 )
break;
}
v27 = ItemCheck(v33);
printf("long lived tree of depth %u\t check: %li\n", v30, v27);
gettimeofday(&v35, 0LL);
v28 = v35.tv_sec - tv.tv_sec;
tv.tv_sec = v35.tv_sec - tv.tv_sec;
if ( v35.tv_usec - tv.tv_usec < 0 )
{
tv.tv_usec = v35.tv_usec - tv.tv_usec + 1000000;
tv.tv_sec = v28 - 1;
}
else
{
tv.tv_usec = v35.tv_usec - tv.tv_usec;
}
fprintf(stderr, "%d.%06d\n", tv.tv_sec, tv.tv_usec);
fflush(stderr);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // edx
int v5; // er15
unsigned int v6; // ebp
_QWORD *v7; // r12
__int64 v8; // rax
int i; // er15
_QWORD *v10; // r13
__int64 v11; // rbp
_QWORD *v12; // r13
__int64 v13; // rbp
__int64 v14; // rbx
_QWORD *v15; // r13
__int64 v16; // rbp
_QWORD *v17; // r13
__int64 v18; // rbp
__int64 v19; // rbx
unsigned int v20; // er12
double v21; // xmm0_8
__int64 v22; // r14
_QWORD *v23; // rbp
_QWORD *v24; // r13
__int64 v25; // rbp
_QWORD *v26; // r13
__int64 v27; // rax
__time_t v28; // rdi
unsigned int v30; // [rsp+4h] [rbp-74h]
__int64 v31; // [rsp+8h] [rbp-70h]
_QWORD *v32; // [rsp+10h] [rbp-68h]
_QWORD *v33; // [rsp+18h] [rbp-60h]
struct timeval tv; // [rsp+20h] [rbp-58h] BYREF
struct timeval v35; // [rsp+30h] [rbp-48h] BYREF

tv.tv_sec = 0LL;
tv.tv_usec = 0LL;
v35.tv_sec = 0LL;
v35.tv_usec = 0LL;
gettimeofday(&tv, 0LL);
v3 = atol(argv[1]);
v4 = 6;
if ( v3 >= 6 )
v4 = v3;
v5 = v4;
v30 = v4;
v6 = v4 + 1;
v7 = BottomUpTree(0LL, v4 + 1);
v8 = func7(v7);
printf("stretch tree of depth %u\t check: %li\n", v6, v8);
func8(v7);
v33 = BottomUpTree(0LL, v5);
for ( i = 0; ; i += 2 )
{
v20 = i + 4;
v21 = pow(2.0, (double)(int)(v30 - i));
v22 = (unsigned int)(int)v21;
if ( (int)v21 )
{
v23 = BottomUpTree(1LL, v20);
v31 = func7(v23);
func8(v23);
v32 = BottomUpTree(-1LL, v20);
v18 = func7(v32) + v31;
func8(v32);
v19 = 2LL;
if ( (unsigned int)(int)v21 >= 2uLL )
{
if ( (((_BYTE)v22 - 1) & 1) == 0
|| (v24 = BottomUpTree(2LL, v20),
v25 = func7(v24) + v18,
func8(v24),
v26 = BottomUpTree(-2LL, v20),
v18 = func7(v26) + v25,
func8(v26),
v19 = 3LL,
(unsigned int)(int)v21 >= 3uLL) )
{
do
{
v10 = BottomUpTree(v19, v20);
v11 = func7(v10) + v18;
func8(v10);
v12 = BottomUpTree(-v19, v20);
v13 = func7(v12) + v11;
func8(v12);
v14 = v19 + 1;
v15 = BottomUpTree(v14, v20);
v16 = func7(v15) + v13;
func8(v15);
v17 = BottomUpTree(-v14, v20);
v18 = func7(v17) + v16;
func8(v17);
v19 = v14 + 1;
}
while ( v22 >= v19 );
}
}
}
else
{
v18 = 0LL;
}
printf("%li\t trees of depth %u\t check: %li\n", 2 * v22, v20, v18);
if ( v30 < i + 6 )
break;
}
v27 = func7(v33);
printf("long lived tree of depth %u\t check: %li\n", v30, v27);
gettimeofday(&v35, 0LL);
v28 = v35.tv_sec - tv.tv_sec;
tv.tv_sec = v35.tv_sec - tv.tv_sec;
if ( v35.tv_usec - tv.tv_usec < 0 )
{
tv.tv_usec = v35.tv_usec - tv.tv_usec + 1000000;
tv.tv_sec = v28 - 1;
}
else
{
tv.tv_usec = v35.tv_usec - tv.tv_usec;
}
fprintf(stderr, "%d.%06d\n", tv.tv_sec, tv.tv_usec);
fflush(stderr);
return 0;
}

original_code:
int main(int argc, char* argv[])
{
    unsigned N, depth, minDepth, maxDepth, stretchDepth;
    treeNode *stretchTree, *longLivedTree, *tempTree;
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    N = atol(argv[1]);
    minDepth = 4;
    if ((minDepth + 2) > N)
        maxDepth = minDepth + 2;
    else
        maxDepth = N;
    stretchDepth = maxDepth + 1;
    stretchTree = BottomUpTree(0, stretchDepth);
    printf
    (
        "stretch tree of depth %u\t check: %li\n",
        stretchDepth,
        ItemCheck(stretchTree)
    );
    DeleteTree(stretchTree);
    longLivedTree = BottomUpTree(0, maxDepth);
    for (depth = minDepth; depth <= maxDepth; depth += 2)
    {
        long i, iterations, check;
        iterations = pow(2, maxDepth - depth + minDepth);
        check = 0;
        for (i = 1; i <= iterations; i++)
        {
            tempTree = BottomUpTree(i, depth);
            check += ItemCheck(tempTree);
            DeleteTree(tempTree);
            tempTree = BottomUpTree(-i, depth);
            check += ItemCheck(tempTree);
            DeleteTree(tempTree);
        }
        printf
        (
            "%li\t trees of depth %u\t check: %li\n",
            iterations * 2,
            depth,
            check
        );
    }
    printf
    (
        "long lived tree of depth %u\t check: %li\n",
        maxDepth,
        ItemCheck(longLivedTree)
    );
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    unsigned int N; unsigned int depth; unsigned int minDepth; unsigned int maxDepth; unsigned int stretchDepth;
    struct tn *stretchTree; struct tn *longLivedTree; struct tn *tempTree;
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    N = atol(argv[1]);
    minDepth = 4;
    if ((minDepth + 2) > N)
        maxDepth = minDepth + 2;
    else
        maxDepth = N;
    stretchDepth = maxDepth + 1;
    stretchTree = BottomUpTree(0, stretchDepth);
    printf
    (
        "stretch tree of depth %u\t check: %li\n",
        stretchDepth,
        ItemCheck(stretchTree)
    );
    DeleteTree(stretchTree);
    longLivedTree = BottomUpTree(0, maxDepth);
    for (depth = minDepth; depth <= maxDepth; depth += 2)
    {
        long i; long iterations; long check;
        iterations = pow(2, maxDepth - depth + minDepth);
        check = 0;
        for (i = 1; i <= iterations; i++)
        {
            tempTree = BottomUpTree(i, depth);
            check += ItemCheck(tempTree);
            DeleteTree(tempTree);
            tempTree = BottomUpTree(-i, depth);
            check += ItemCheck(tempTree);
            DeleteTree(tempTree);
        }
        printf
        (
            "%li\t trees of depth %u\t check: %li\n",
            iterations * 2,
            depth,
            check
        );
    }
    printf
    (
        "long lived tree of depth %u\t check: %li\n",
        maxDepth,
        ItemCheck(longLivedTree)
    );
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return 0;
}

variable_types:
N
unsigned int

variable_types:
depth
unsigned int

variable_types:
minDepth
unsigned int

variable_types:
maxDepth
unsigned int

variable_types:
stretchDepth
unsigned int

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

variable_types: i long

variable_types: iterations long

variable_types: check long


decompiled_code:
__int64 is_empty_annotation()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 1LL;
}

original_code:
bool is_empty_annotation(annotation a) {
  return 1;
}

canonical_original_code:
unsigned char is_empty_annotation(struct annotation_ *a) {
  return 1;
}

variable_types:
a
struct annotation_ {  } *


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

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

original_code:
annotation get_empty_annotation(void) {
  return ((void *)0);
}

canonical_original_code:
struct annotation_ *get_empty_annotation() {
  return ((void *)0);
}

return_type: struct annotation_ {  } *


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

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

original_code:
annotation concat_annotation(annotation a1, annotation a2) {
  return ((void *)0);
}

canonical_original_code:
struct annotation_ *concat_annotation(struct annotation_ *a1, struct annotation_ *a2) {
  return ((void *)0);
}


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

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

original_code:
annotation star_annotation(annotation a) {
  return ((void *)0);
}

canonical_original_code:
struct annotation_ *star_annotation(struct annotation_ *a) {
  return ((void *)0);
}

variable_types:
a
struct annotation_ *


decompiled_code:
__int64 subsumed_by_annotation()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func5()
{
return 1LL;
}

original_code:
bool subsumed_by_annotation(annotation a1, annotation a2) {
  return 1;
}

canonical_original_code:
unsigned char subsumed_by_annotation(struct annotation_ *a1, struct annotation_ *a2) {
  return 1;
}


decompiled_code:
void print_annotation()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void print_annotation(annotation a) {
}

canonical_original_code:
void print_annotation(struct annotation_ *a) {
}


bfi

decompiled_code:
unsigned __int64 __fastcall bfi(__int64 a1, __int64 a2, char a3, __int64 a4)
{
unsigned __int64 v4; // rsi
char v5; // r8
char v6; // r9
_DWORD *v7; // rsi
unsigned __int64 result; // rax
__int64 v9; // [rsp+0h] [rbp-8h]

v4 = a2 - 1;
v5 = (v4 & 0xF8) - a3 + 32 - v4;
v6 = v4 - (v4 & 0xF8);
v7 = (_DWORD *)(a1 + (v4 >> 3));
LODWORD(v9) = *v7;
result = v9 ^ ((unsigned __int64)(0xFFFFFFFFLL << v5 << v6) >> v6) & (v9 ^ (a4 << v5));
*v7 = result;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(__int64 a1, __int64 a2, char a3, __int64 a4)
{
unsigned __int64 v4; // rsi
char v5; // r8
char v6; // r9
_DWORD *v7; // rsi
unsigned __int64 result; // rax
__int64 v9; // [rsp+0h] [rbp-8h]

v4 = a2 - 1;
v5 = (v4 & 0xF8) - a3 + 32 - v4;
v6 = v4 - (v4 & 0xF8);
v7 = (_DWORD *)(a1 + (v4 >> 3));
LODWORD(v9) = *v7;
result = v9 ^ ((unsigned __int64)(0xFFFFFFFFLL << v5 << v6) >> v6) & (v9 ^ (a4 << v5));
*v7 = result;
return result;
}

original_code:
void
bfi(unsigned char *cptr, unsigned long bit_offset, unsigned long bit_len, long value)
{
   unsigned long l;
   unsigned long mask = 0xffffffff;
   unsigned long byte_offset;
   unsigned long pre_shift;
   unsigned long post_shift;
   byte_offset = (bit_offset-1)/8;
   pre_shift = bit_offset - byte_offset*8 - 1;
   post_shift = 32 - bit_len - pre_shift;
   value <<= post_shift;
   mask <<= post_shift;
   mask <<= pre_shift;
   mask >>= pre_shift;
   value &= mask;
   memmove((unsigned char *)&l, &cptr[byte_offset], 4);
   l = (l & (~mask)) | value;
   memmove(&cptr[byte_offset], (unsigned char *)&l, 4);
}

variable_types:
cptr
unsigned char *

variable_types: value long

variable_types:
l
unsigned long

variable_types:
mask
unsigned long


bfx

original_code:
unsigned long
bfx(const unsigned char *cptr, unsigned long bit_offset, unsigned long bit_len)
{
   unsigned long l;
   unsigned long byte_offset;
   unsigned long left_shift;
   unsigned long right_shift;
   byte_offset = (bit_offset-1)/8;
   left_shift = bit_offset - byte_offset*8 - 1;
   right_shift = 32 - bit_len;
   memmove((unsigned char *)&l, &cptr[byte_offset], 4);
   return ( l << left_shift ) >> right_shift;
}

canonical_original_code:
unsigned long bfx(unsigned char *cptr, unsigned long bit_offset, unsigned long bit_len)
{
   unsigned long l;
   unsigned long byte_offset;
   unsigned long left_shift;
   unsigned long right_shift;
   byte_offset = (bit_offset-1)/8;
   left_shift = bit_offset - byte_offset*8 - 1;
   right_shift = 32 - bit_len;
   memmove((unsigned char *)&l, &cptr[byte_offset], 4);
   return ( l << left_shift ) >> right_shift;
}


decompiled_code:
__int64 __fastcall jcoll_accum(__int64 a1)
{
return gen_e_list_cons(a1, jf_accum);
}

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

original_code:
static void jcoll_accum(void *e) {
 gen_e_list_cons((gen_e) e, jf_accum);
}

canonical_original_code:
static void jcoll_accum(void *e) {
 gen_e_list_cons((struct gen_e_ *) e, jf_accum);
}

variable_types:
e
void *

user_defined_types: enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 }


dfft

canonical_original_code:
int dfft(double x[], double y[], int np)
{
double *px; double *py;
int i; int j; int k; int m; int n; int i0; int i1; int i2; int i3; int is; int id; int n1; int n2; int n4;
double a; double e; double a3; double cc1; double ss1; double cc3; double ss3; double r1; double r2; double s1; double s2; double s3; double xt; double tpi;
  px = x - 1;
  py = y - 1;
  i = 2;
  m = 1;
  while (i < np)
  {
  i = i+i;
  m = m+1;
  }
  n = i;
  if (n != np)
  {
     for (i = np+1; i <= n; i++)
     {
     px[i] = 0.0;
     py[i] = 0.0;
     }
     printf("\nuse %d point fft",n);
  }
  n2 = n+n;
  tpi = 2.0 * 3.14159265358979323846;
  for (k = 1; k <= m-1; k++ )
  {
    n2 = n2 / 2;
    n4 = n2 / 4;
    e = tpi / (double)n2;
    a = 0.0;
    for (j = 1; j<= n4 ; j++)
    {
 a3 = 3.0 * a;
 cc1 = cos(a);
 ss1 = sin(a);
 cc3 = cos(a3);
 ss3 = sin(a3);
 a = e * (double)j;
 is = j;
 id = 2 * n2;
   while ( is < n )
   {
      for (i0 = is; i0 <= n-1; i0 = i0 + id)
      {
      i1 = i0 + n4;
      i2 = i1 + n4;
      i3 = i2 + n4;
      r1 = px[i0] - px[i2];
      px[i0] = px[i0] + px[i2];
      r2 = px[i1] - px[i3];
      px[i1] = px[i1] + px[i3];
      s1 = py[i0] - py[i2];
      py[i0] = py[i0] + py[i2];
      s2 = py[i1] - py[i3];
      py[i1] = py[i1] + py[i3];
      s3 = r1 - s2; r1 = r1 + s2;
      s2 = r2 - s1; r2 = r2 + s1;
      px[i2] = r1*cc1 - s2*ss1;
      py[i2] = -s2*cc1 - r1*ss1;
      px[i3] = s3*cc3 + r2*ss3;
      py[i3] = r2*cc3 - s3*ss3;
      }
   is = 2 * id - n2 + j;
   id = 4 * id;
   }
    }
  }
  is = 1;
  id = 4;
  while ( is < n)
  {
     for (i0 = is; i0 <= n; i0 = i0 + id)
     {
 i1 = i0 + 1;
 r1 = px[i0];
 px[i0] = r1 + px[i1];
 px[i1] = r1 - px[i1];
 r1 = py[i0];
 py[i0] = r1 + py[i1];
 py[i1] = r1 - py[i1];
     }
  is = 2*id - 1;
  id = 4 * id;
  }
  j = 1;
  n1 = n - 1;
  for (i = 1; i <= n1; i++)
  {
    if (i < j)
    {
    xt = px[j];
    px[j] = px[i];
    px[i] = xt;
    xt = py[j];
    py[j] = py[i];
    py[i] = xt;
    }
    k = n / 2;
    while (k < j)
    {
    j = j - k;
    k = k / 2;
    }
    j = j + k;
  }
  return(n);
}

variable_types:
x
double []

variable_types:
y
double []

variable_types: np int

variable_types:
px
double *

variable_types:
py
double *

variable_types: i int

variable_types: j int

variable_types: k int

variable_types: m int

variable_types: n int

variable_types: is int

variable_types: id int

variable_types: a double

variable_types: e double

variable_types: xt double

variable_types: tpi double


main

original_code:
int main(int argc, char* argv[])
{
int i,j,np,npm,lp,n2,kr,ki;
double *pxr,*pxi;
double a,enp,t,y,zr,zi,zm;
np = 8;
pxr = xr;
pxi = xi;
 printf("\nFFT benchmark - Double Precision - V1.0 -  05 Jan 1993\n\n");
 printf("FFT size   max error\n");
 for (lp = 1; lp <= 15; lp++ )
 {
   np = np * 2;
   printf(" %7d ",np);
   enp = np;
   npm = np / 2 - 1;
   t = 3.14159265358979323846 / enp;
   pxr[0] = (enp - 1.0) * 0.5;
   pxi[0] = 0.0;
   n2 = np / 2;
   pxr[n2] = -0.5;
   pxi[n2] = 0.0;
   for (i = 1; i <= npm; i++)
   {
  j = np - i;
  pxr[i] = -0.5;
  pxr[j] = -0.5;
  y = t * (double)i;
  y = -0.5*(cos(y)/sin(y));
  pxi[i] = y;
  pxi[j] = -y;
   }
   dfft(xr,xi,np);
   zr = 0.0;
   zi = 0.0;
   kr = 0;
   ki = 0;
   npm = np-1;
   for (i = 0; i <= npm; i++ )
   {
  a = fabs( xr[i] - i );
  if (zr < a)
  {
   zr = a;
   kr = i;
  }
  a = fabs(xi[i]);
  if (zi < a)
  {
   zi = a;
   ki = i;
  }
   }
   zm = zr;
   if ( fabs(zr) < fabs(zi) ) zm = zi;
   printf(" %10.2g\n",zm);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
int i; int j; int np; int npm; int lp; int n2; int kr; int ki;
double *pxr; double *pxi;
double a; double enp; double t; double y; double zr; double zi; double zm;
np = 8;
pxr = xr;
pxi = xi;
 printf("\nFFT benchmark - Double Precision - V1.0 -  05 Jan 1993\n\n");
 printf("FFT size   max error\n");
 for (lp = 1; lp <= 15; lp++ )
 {
   np = np * 2;
   printf(" %7d ",np);
   enp = np;
   npm = np / 2 - 1;
   t = 3.14159265358979323846 / enp;
   pxr[0] = (enp - 1.0) * 0.5;
   pxi[0] = 0.0;
   n2 = np / 2;
   pxr[n2] = -0.5;
   pxi[n2] = 0.0;
   for (i = 1; i <= npm; i++)
   {
  j = np - i;
  pxr[i] = -0.5;
  pxr[j] = -0.5;
  y = t * (double)i;
  y = -0.5*(cos(y)/sin(y));
  pxi[i] = y;
  pxi[j] = -y;
   }
   dfft(xr,xi,np);
   zr = 0.0;
   zi = 0.0;
   kr = 0;
   ki = 0;
   npm = np-1;
   for (i = 0; i <= npm; i++ )
   {
  a = fabs( xr[i] - i );
  if (zr < a)
  {
   zr = a;
   kr = i;
  }
  a = fabs(xi[i]);
  if (zi < a)
  {
   zi = a;
   ki = i;
  }
   }
   zm = zr;
   if ( fabs(zr) < fabs(zi) ) zm = zi;
   printf(" %10.2g\n",zm);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: npm int

variable_types: lp int

variable_types: kr int

variable_types: ki int

variable_types:
pxr
double *

variable_types:
pxi
double *

variable_types: enp double

variable_types: t double

variable_types: y double

variable_types: zr double

variable_types: zi double

variable_types: zm double


decompiled_code:
__int64 __fastcall decode_symbol(int *a1)
{
__int64 v1; // r9
__int64 v2; // r8
int v3; // ecx
__int64 v4; // rdx
unsigned int v5; // ebx
__int64 v6; // rax
__int64 v7; // rbp

v1 = high - low + 1;
v2 = *a1;
v3 = a1[1];
if ( (int)((v2 * (value - low + 1) - 1) / v1) >= v3 )
{
v5 = 1;
v6 = 1LL;
}
else
{
v4 = 2LL;
do
{
v5 = v4;
v6 = v4++;
v3 = a1[v4 - 1];
}
while ( v3 > (int)((v2 * (value - low + 1) - 1) / v1) );
}
high = low + v1 * a1[v6 - 1] / *a1 - 1;
low += v1 * v3 / v2;
while ( 1 )
{
if ( high <= 0x7FFF )
goto LABEL_9;
if ( low <= 0x7FFF )
break;
value -= 0x8000LL;
low -= 0x8000LL;
high -= 0x8000LL;
LABEL_9:
low *= 2LL;
high = 2 * high + 1;
v7 = 2 * value;
value = v7 + (int)input_bit();
}
if ( high <= 49151 && low > 0x3FFF )
{
value -= 0x4000LL;
low -= 0x4000LL;
high -= 0x4000LL;
goto LABEL_9;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(int *a1)
{
__int64 v1; // r9
__int64 v2; // r8
int v3; // ecx
__int64 v4; // rdx
unsigned int v5; // ebx
__int64 v6; // rax
__int64 v7; // rbp

v1 = high - low + 1;
v2 = *a1;
v3 = a1[1];
if ( (int)((v2 * (value - low + 1) - 1) / v1) >= v3 )
{
v5 = 1;
v6 = 1LL;
}
else
{
v4 = 2LL;
do
{
v5 = v4;
v6 = v4++;
v3 = a1[v4 - 1];
}
while ( v3 > (int)((v2 * (value - low + 1) - 1) / v1) );
}
high = low + v1 * a1[v6 - 1] / *a1 - 1;
low += v1 * v3 / v2;
while ( 1 )
{
if ( high <= 0x7FFF )
goto LABEL_9;
if ( low <= 0x7FFF )
break;
value -= 0x8000LL;
low -= 0x8000LL;
high -= 0x8000LL;
LABEL_9:
low *= 2LL;
high = 2 * high + 1;
v7 = 2 * value;
value = v7 + (int)input_bit();
}
if ( high <= 49151 && low > 0x3FFF )
{
value -= 0x4000LL;
low -= 0x4000LL;
high -= 0x4000LL;
goto LABEL_9;
}
return v5;
}

original_code:
int decode_symbol()
{
    int pContext;
    int symbol;
    startContext();
    pContext = predict();
    symbol = decode_context( pContext );
    Input [inputPos] = symbol;
    update( symbol );
    if (debugLevel > 2)
        dumpRoot( stderr );
    return( symbol );
}

variable_types: pContext int

variable_types: symbol int


SIEVE

original_code:
void SIEVE(long m,long n,long p)
{
char *flags;
long i,prime = -1,k,ci;
long count,size;
long iter,j;
char *ptr;
size = m - 1;
ptr = malloc(m);
   ErrorFlag = 0L;
   N_Prime = 0L;
   L_Prime = 0L;
   if( !ptr )
     {
     ErrorFlag = 2L;
     return;
     }
   flags = ptr;
   j = 0;
   for(iter=1 ; iter<=n ; iter++)
   {
   count = 0;
   for(i=0 ; i<=size ; i++)
   {
   *(flags+i) = 1;
   }
   ci = 0;
     for(i=0 ; i<=size ; i++)
     {
 if(*(flags+i))
 {
 count++;
 prime = i + i + 3;
 for(k = i + prime ; k<=size ; k+=prime)
 {
 ci++;
 *(flags+k)=0;
 }
 }
     }
   j = j + count;
   }
   free(ptr);
   N_Prime = j / n;
   L_Prime = prime;
   if ( p != 0L )
   {
   printf("  %9ld   %8ld     %8ld\n",m,N_Prime,L_Prime);
   }
}

canonical_original_code:
void SIEVE(long m, long n, long p)
{
char *flags;
long i; long prime = -1; long k; long ci;
long count; long size;
long iter; long j;
char *ptr;
size = m - 1;
ptr = malloc(m);
   ErrorFlag = 0L;
   N_Prime = 0L;
   L_Prime = 0L;
   if( !ptr )
     {
     ErrorFlag = 2L;
     return;
     }
   flags = ptr;
   j = 0;
   for(iter=1 ; iter<=n ; iter++)
   {
   count = 0;
   for(i=0 ; i<=size ; i++)
   {
   *(flags+i) = 1;
   }
   ci = 0;
     for(i=0 ; i<=size ; i++)
     {
 if(*(flags+i))
 {
 count++;
 prime = i + i + 3;
 for(k = i + prime ; k<=size ; k+=prime)
 {
 ci++;
 *(flags+k)=0;
 }
 }
     }
   j = j + count;
   }
   free(ptr);
   N_Prime = j / n;
   L_Prime = prime;
   if ( p != 0L )
   {
   printf("  %9ld   %8ld     %8ld\n",m,N_Prime,L_Prime);
   }
}

variable_types: m long

variable_types: n long

variable_types: p long

variable_types:
flags
char *

variable_types: i long

variable_types: prime long

variable_types: k long

variable_types: ci long

variable_types: count long

variable_types: size long

variable_types: iter long

variable_types: j long

variable_types:
ptr
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 i; // rax
size_t v4; // rbp
__int64 v5; // rbx

if ( argc > 1 )
LIMIT = atoi(argv[1]);
puts("\n Sieve of Eratosthenes (Scaled to 10 Iterations)");
puts(" Version 1.2b, 26 Sep 1992\n");
puts(" Array Size Number Last Prime");
puts(" (Bytes) of Primes");
Number_Of_Primes[0] = 1899LL;
qword_404148 = 2261LL;
qword_404150 = 4202LL;
qword_404158 = 7836LL;
qword_404160 = 14683LL;
qword_404168 = 27607LL;
qword_404170 = 52073LL;
qword_404178 = 98609LL;
qword_404180 = 187133LL;
qword_404188 = 356243LL;
qword_404190 = 679460LL;
qword_404198 = 1299068LL;
qword_4041A0 = 2488465LL;
qword_4041A8 = 4774994LL;
qword_4041B0 = 0LL;
qword_4041B8 = 0LL;
SIEVE(0x1FFFuLL, 256LL, 0LL);
for ( i = 1LL; i != 21; ++i )
NLoops[i] = 1LL;
NLoops[0] = 2048LL;
qword_404088 = 2048LL;
qword_404090 = 1024LL;
qword_404098 = 512LL;
qword_4040A0 = 256LL;
qword_4040A8 = 128LL;
qword_4040B0 = 64LL;
qword_4040B8 = 32LL;
qword_4040C0 = 16LL;
qword_4040C8 = 8LL;
qword_4040D0 = 4LL;
qword_4040D8 = 2LL;
SIEVE(0x1FFFuLL, 2048LL, 8LL);
ErrorFlag = 0LL;
if ( LIMIT <= 0 )
return 0;
v4 = 5000LL;
v5 = 1LL;
while ( 1 )
{
v4 *= 2LL;
SIEVE(v4, NLoops[v5], 8LL);
if ( ErrorFlag )
break;
if ( Number_Of_Primes[v5] != N_Prime )
{
printf("\n Error --- Incorrect Number of Primes for Array: %ld\n", v4);
printf(" Number of Primes Found is: %ld\n", N_Prime);
printf(" Correct Number of Primes is: %ld\n", Number_Of_Primes[v5]);
ErrorFlag = 1LL;
return 0;
}
LABEL_8:
if ( LIMIT < ++v5 )
return 0;
}
if ( ErrorFlag <= 0 )
goto LABEL_8;
if ( ErrorFlag != 2 )
return 0;
printf("\n Could Not Allocate Memory for Array Size: %ld\n", v4);
return -1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 i; // rax
size_t v4; // rbp
__int64 v5; // rbx

if ( argc > 1 )
LIMIT = atoi(argv[1]);
puts("\n Sieve of Eratosthenes (Scaled to 10 Iterations)");
puts(" Version 1.2b, 26 Sep 1992\n");
puts(" Array Size Number Last Prime");
puts(" (Bytes) of Primes");
Number_Of_Primes[0] = 1899LL;
qword_404148 = 2261LL;
qword_404150 = 4202LL;
qword_404158 = 7836LL;
qword_404160 = 14683LL;
qword_404168 = 27607LL;
qword_404170 = 52073LL;
qword_404178 = 98609LL;
qword_404180 = 187133LL;
qword_404188 = 356243LL;
qword_404190 = 679460LL;
qword_404198 = 1299068LL;
qword_4041A0 = 2488465LL;
qword_4041A8 = 4774994LL;
qword_4041B0 = 0LL;
qword_4041B8 = 0LL;
func7(0x1FFFuLL, 256LL, 0LL);
for ( i = 1LL; i != 21; ++i )
NLoops[i] = 1LL;
NLoops[0] = 2048LL;
qword_404088 = 2048LL;
qword_404090 = 1024LL;
qword_404098 = 512LL;
qword_4040A0 = 256LL;
qword_4040A8 = 128LL;
qword_4040B0 = 64LL;
qword_4040B8 = 32LL;
qword_4040C0 = 16LL;
qword_4040C8 = 8LL;
qword_4040D0 = 4LL;
qword_4040D8 = 2LL;
func7(0x1FFFuLL, 2048LL, 8LL);
ErrorFlag = 0LL;
if ( LIMIT <= 0 )
return 0;
v4 = 5000LL;
v5 = 1LL;
while ( 1 )
{
v4 *= 2LL;
func7(v4, NLoops[v5], 8LL);
if ( ErrorFlag )
break;
if ( Number_Of_Primes[v5] != N_Prime )
{
printf("\n Error --- Incorrect Number of Primes for Array: %ld\n", v4);
printf(" Number of Primes Found is: %ld\n", N_Prime);
printf(" Correct Number of Primes is: %ld\n", Number_Of_Primes[v5]);
ErrorFlag = 1LL;
return 0;
}
LABEL_8:
if ( LIMIT < ++v5 )
return 0;
}
if ( ErrorFlag <= 0 )
goto LABEL_8;
if ( ErrorFlag != 2 )
return 0;
printf("\n Could Not Allocate Memory for Array Size: %ld\n", v4);
return -1;
}

original_code:
int main(int argc, char* argv[])
{
long i,j,k,p;
if(argc > 1)
  LIMIT = atoi(argv[1]);
printf("\n   Sieve of Eratosthenes (Scaled to 10 Iterations)\n");
printf("   Version 1.2b, 26 Sep 1992\n\n");
printf("   Array Size   Number   Last Prime\n");
printf("    (Bytes)   of Primes\n");
Number_Of_Primes[0] = 1899;
Number_Of_Primes[1] = 2261;
Number_Of_Primes[2] = 4202;
Number_Of_Primes[3] = 7836;
Number_Of_Primes[4] = 14683;
Number_Of_Primes[5] = 27607;
Number_Of_Primes[6] = 52073;
Number_Of_Primes[7] = 98609;
Number_Of_Primes[8] = 187133;
Number_Of_Primes[9] = 356243;
Number_Of_Primes[10]= 679460;
Number_Of_Primes[11]= 1299068;
Number_Of_Primes[12]= 2488465;
Number_Of_Primes[13]= 4774994;
Number_Of_Primes[14]= 0;
Number_Of_Primes[15]= 0;
j = 8191;
k = 256;
p = 0;
SIEVE(j,k,p);
for( i=1 ; i<= 20 ; i++)
{
 NLoops[i] = 1;
}
p = 8;
NLoops[0] = 256 * p;
NLoops[1] = 256 * p;
NLoops[2] = 128 * p;
NLoops[3] = 64 * p;
NLoops[4] = 32 * p;
NLoops[5] = 16 * p;
NLoops[6] = 8 * p;
NLoops[7] = 4 * p;
NLoops[8] = 2 * p;
NLoops[9] = p;
NLoops[10] = p / 2;
NLoops[11] = p / 4;
i = 0;
j = 8191;
k = NLoops[0];
SIEVE(j,k,p);
j = 5000;
ErrorFlag = 0;
for( i=1 ; i<= LIMIT ; i++)
{
   j = 2 * j;
   k = NLoops[i];
   SIEVE(j,k,p);
   if( ErrorFlag == 0L )
   {
   if( N_Prime != Number_Of_Primes[i] )
   {
   printf("\n   Error --- Incorrect Number of Primes for Array: %ld\n",j);
   printf("   Number of  Primes  Found is: %ld\n",N_Prime);
   printf("   Correct Number of Primes is: %ld\n",Number_Of_Primes[i]);
   ErrorFlag = 1L;
   }
   }
   if( ErrorFlag > 0L ) break;
}
if( ErrorFlag == 2L )
{
printf("\n   Could Not Allocate Memory for Array Size: %ld\n",j);
return(-1);
}
return(0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
long i; long j; long k; long p;
if(argc > 1)
  LIMIT = atoi(argv[1]);
printf("\n   Sieve of Eratosthenes (Scaled to 10 Iterations)\n");
printf("   Version 1.2b, 26 Sep 1992\n\n");
printf("   Array Size   Number   Last Prime\n");
printf("    (Bytes)   of Primes\n");
Number_Of_Primes[0] = 1899;
Number_Of_Primes[1] = 2261;
Number_Of_Primes[2] = 4202;
Number_Of_Primes[3] = 7836;
Number_Of_Primes[4] = 14683;
Number_Of_Primes[5] = 27607;
Number_Of_Primes[6] = 52073;
Number_Of_Primes[7] = 98609;
Number_Of_Primes[8] = 187133;
Number_Of_Primes[9] = 356243;
Number_Of_Primes[10]= 679460;
Number_Of_Primes[11]= 1299068;
Number_Of_Primes[12]= 2488465;
Number_Of_Primes[13]= 4774994;
Number_Of_Primes[14]= 0;
Number_Of_Primes[15]= 0;
j = 8191;
k = 256;
p = 0;
SIEVE(j,k,p);
for( i=1 ; i<= 20 ; i++)
{
 NLoops[i] = 1;
}
p = 8;
NLoops[0] = 256 * p;
NLoops[1] = 256 * p;
NLoops[2] = 128 * p;
NLoops[3] = 64 * p;
NLoops[4] = 32 * p;
NLoops[5] = 16 * p;
NLoops[6] = 8 * p;
NLoops[7] = 4 * p;
NLoops[8] = 2 * p;
NLoops[9] = p;
NLoops[10] = p / 2;
NLoops[11] = p / 4;
i = 0;
j = 8191;
k = NLoops[0];
SIEVE(j,k,p);
j = 5000;
ErrorFlag = 0;
for( i=1 ; i<= LIMIT ; i++)
{
   j = 2 * j;
   k = NLoops[i];
   SIEVE(j,k,p);
   if( ErrorFlag == 0L )
   {
   if( N_Prime != Number_Of_Primes[i] )
   {
   printf("\n   Error --- Incorrect Number of Primes for Array: %ld\n",j);
   printf("   Number of  Primes  Found is: %ld\n",N_Prime);
   printf("   Correct Number of Primes is: %ld\n",Number_Of_Primes[i]);
   ErrorFlag = 1L;
   }
   }
   if( ErrorFlag > 0L ) break;
}
if( ErrorFlag == 2L )
{
printf("\n   Could Not Allocate Memory for Array Size: %ld\n",j);
return(-1);
}
return(0);
}

variable_types: argc int

variable_types:
argv
char *[]


decompiled_code:
void start_inputing_bits()
{
bits_to_go = 0;
}

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


decompiled_code:
__int64 input_bit()
{
char v0; // al

if ( --bits_to_go < 0 )
{
buffer = getc(stdin);
bits_to_go = 7;
}
v0 = buffer;
buffer >>= 1;
return v0 & 1;
}

canonical_decompiled_code:
__int64 func1()
{
char v0; // al

if ( --bits_to_go < 0 )
{
buffer = getc(stdin);
bits_to_go = 7;
}
v0 = buffer;
buffer >>= 1;
return v0 & 1;
}

original_code:
int input_bit()
{
  int t;
  bits_to_go -= 1;
  if (bits_to_go<0) {
    buffer = getc(stdin);
    bits_to_go = 7;
  }
  t = buffer&1;
  buffer >>= 1;
  return t;
}

variable_types: t int


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

region_init();
banshee_ptr_region = newregion();
banshee_nonptr_region = newregion();
result = make_hash_table(permanent, 32LL, &ptr_hash, &ptr_eq);
extra_regions = result;
return result;
}

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

region_init();
banshee_ptr_region = newregion();
banshee_nonptr_region = newregion();
result = make_hash_table(permanent, 32LL, &ptr_hash, &ptr_eq);
extra_regions = result;
return result;
}

original_code:
void banshee_region_persistence_init()
{
  region_init();
  banshee_ptr_region = newregion();
  banshee_nonptr_region = newregion();
  extra_regions = make_hash_table(permanent, 32, ptr_hash, ptr_eq);
}


Ack

decompiled_code:
__int64 __fastcall Ack(__int64 a1, int a2)
{
__int64 result; // rax
unsigned int v3; // eax

result = (unsigned int)(a2 + 1);
if ( (_DWORD)a1 )
{
v3 = 1;
if ( a2 )
v3 = Ack(a1, (unsigned int)(a2 - 1));
result = Ack((unsigned int)(a1 - 1), v3);
}
return result;
}

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

result = (unsigned int)(a2 + 1);
if ( (_DWORD)a1 )
{
v3 = 1;
if ( a2 )
v3 = func7(a1, (unsigned int)(a2 - 1));
result = func7((unsigned int)(a1 - 1), v3);
}
return result;
}

original_code: int Ack(int M, int N) { return(M ? (Ack(M-1,N ? Ack(M,(N-1)) : 1)) : N+1); }

variable_types: M int

variable_types: N int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
unsigned int v4; // eax
__time_t v5; // rdx
struct timeval v7; // [rsp+0h] [rbp-28h] BYREF
struct timeval tv; // [rsp+10h] [rbp-18h] BYREF

v3 = 1;
if ( argc == 2 )
v3 = atoi(argv[1]);
v7.tv_sec = 0LL;
v7.tv_usec = 0LL;
tv.tv_sec = 0LL;
tv.tv_usec = 0LL;
gettimeofday(&v7, 0LL);
v4 = Ack(3LL, v3);
printf("Ack(3,%d): %d\n", v3, v4);
gettimeofday(&tv, 0LL);
v5 = tv.tv_sec - v7.tv_sec;
v7.tv_sec = tv.tv_sec - v7.tv_sec;
if ( tv.tv_usec - v7.tv_usec < 0 )
{
v7.tv_usec = tv.tv_usec - v7.tv_usec + 1000000;
v7.tv_sec = v5 - 1;
}
else
{
v7.tv_usec = tv.tv_usec - v7.tv_usec;
}
fprintf(stderr, "%d.%06d\n", v7.tv_sec, v7.tv_usec);
fflush(stderr);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
unsigned int v4; // eax
__time_t v5; // rdx
struct timeval v7; // [rsp+0h] [rbp-28h] BYREF
struct timeval tv; // [rsp+10h] [rbp-18h] BYREF

v3 = 1;
if ( argc == 2 )
v3 = atoi(argv[1]);
v7.tv_sec = 0LL;
v7.tv_usec = 0LL;
tv.tv_sec = 0LL;
tv.tv_usec = 0LL;
gettimeofday(&v7, 0LL);
v4 = func7(3LL, v3);
printf("Ack(3,%d): %d\n", v3, v4);
gettimeofday(&tv, 0LL);
v5 = tv.tv_sec - v7.tv_sec;
v7.tv_sec = tv.tv_sec - v7.tv_sec;
if ( tv.tv_usec - v7.tv_usec < 0 )
{
v7.tv_usec = tv.tv_usec - v7.tv_usec + 1000000;
v7.tv_sec = v5 - 1;
}
else
{
v7.tv_usec = tv.tv_usec - v7.tv_usec;
}
fprintf(stderr, "%d.%06d\n", v7.tv_sec, v7.tv_usec);
fflush(stderr);
return 0;
}

original_code:
int main(int argc, char *argv[]) {
    int n = ((argc == 2) ? atoi(argv[1]) : 1);
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    printf("Ack(3,%d): %d\n", n, Ack(3, n));
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return(0);
}

variable_types: n int

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


kmedian

decompiled_code:
_BOOL8 __fastcall kmedian(__int64 a1, int a2, int a3)
{
__int64 i; // rsi
double v7; // xmm2_8
double *v8; // r10
double v9; // xmm0_8
double *j; // r9
int v11; // edx
int v12; // edx
_BOOL8 result; // rax
int v14; // edi
double v15; // xmm1_8

while ( 2 )
{
while ( 2 )
{
v15 = *(double *)(a1 + 8LL * (int)(random() % a2));
v11 = a2 - 1;
for ( i = 0LL; ; ++i )
{
v7 = *(double *)(a1 + 8 * i);
if ( v15 > v7 )
continue;
v8 = (double *)(a1 + 8LL * v11);
v9 = *v8;
for ( j = v8 - 1; v9 > v15; v9 = j[1] )
{
--v11;
v8 = j--;
}
if ( v11 <= (int)i )
break;
*(double *)(a1 + 8 * i) = v9;
*v8 = v7;
--v11;
}
v12 = (v15 > v9) + v11;
result = v7 > v15;
v14 = i - result;
if ( a3 > (int)i - result )
{
a3 -= v14 + 1;
a2 -= v14 + 1;
a1 += 8LL * v14 + 8;
continue;
}
break;
}
if ( a3 < v12 )
{
a2 = v12;
continue;
}
break;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(__int64 a1, int a2, int a3)
{
__int64 i; // rsi
double v7; // xmm2_8
double *v8; // r10
double v9; // xmm0_8
double *j; // r9
int v11; // edx
int v12; // edx
_BOOL8 result; // rax
int v14; // edi
double v15; // xmm1_8

while ( 2 )
{
while ( 2 )
{
v15 = *(double *)(a1 + 8LL * (int)(random() % a2));
v11 = a2 - 1;
for ( i = 0LL; ; ++i )
{
v7 = *(double *)(a1 + 8 * i);
if ( v15 > v7 )
continue;
v8 = (double *)(a1 + 8LL * v11);
v9 = *v8;
for ( j = v8 - 1; v9 > v15; v9 = j[1] )
{
--v11;
v8 = j--;
}
if ( v11 <= (int)i )
break;
*(double *)(a1 + 8 * i) = v9;
*v8 = v7;
--v11;
}
v12 = (v15 > v9) + v11;
result = v7 > v15;
v14 = i - result;
if ( a3 > (int)i - result )
{
a3 -= v14 + 1;
a2 -= v14 + 1;
a1 += 8LL * v14 + 8;
continue;
}
break;
}
if ( a3 < v12 )
{
a2 = v12;
continue;
}
break;
}
return result;
}

original_code:
void kmedian(double *a, int n, int k)
{
 while (1){
  int j=random()%n;
  double b = a[j];
  int i=0;
         j = n-1;
         while(1) {
             while( a[i]<b ) i++;
             while( a[j]>b ) j--;
             if(i<j) {
                 double tmp=a[i];
                 a[i]=a[j];
                 a[j]=tmp;
                 i++;
                 j--;
             } else {
                 if(a[j]<b) j++;
                 if(a[i]>b) i--;
   break;
             }
         }
  if(i<k) {
   k-=i+1;
   n-=i+1;
   a+=i+1;
  } else if (j>k) {
   n=j;
  } else return;
 }
}

canonical_original_code:
void kmedian(double *a, int n, int k)
{
 while (1){
  int j = random()%n;
  double b = a[j];
  int i = 0;
         j = n-1;
         while(1) {
             while( a[i]<b ) i++;
             while( a[j]>b ) j--;
             if(i<j) {
                 double tmp = a[i];
                 a[i]=a[j];
                 a[j]=tmp;
                 i++;
                 j--;
             } else {
                 if(a[j]<b) j++;
                 if(a[i]>b) i--;
   break;
             }
         }
  if(i<k) {
   k-=i+1;
   n-=i+1;
   a+=i+1;
  } else if (j>k) {
   n=j;
  } else return;
 }
}

variable_types:
a
double *

variable_types: k int

variable_types: j int

variable_types: b double

variable_types: i int

variable_types: tmp double


max

original_code:
double max(double *a, int n)
{
 int j;
 double temp=a[0];
 for(j=1;j<n;j++) {
  if(a[j]>temp) {
   temp=a[j];
  }
 }
 return temp;
}

canonical_original_code:
double max(double *a, int n)
{
 int j;
 double temp = a[0];
 for(j=1;j<n;j++) {
  if(a[j]>temp) {
   temp=a[j];
  }
 }
 return temp;
}

variable_types: temp double


main

original_code:
int
main() {
    char line[128];
    int i, n = 0, mid = 0;
    double sum = 0.0;
    double mean = 0.0;
    double average_deviation = 0.0;
    double standard_deviation = 0.0;
    double variance = 0.0;
    double skew = 0.0;
    double kurtosis = 0.0;
    double median = 0.0;
    double deviation = 0.0;
    int array_size = 4096;
    double *nums;
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    nums = (double *)malloc(array_size * sizeof(double));
    while (fgets(line, 128, stdin)) {
 sum += (nums[n++] = atof(line));
 if (n == array_size) {
     array_size *= 2;
     nums = (double *)realloc(nums, array_size * sizeof(double));
 }
    }
    mean = sum/n;
    for (i=0; i<n; i++) {
 double dev = nums[i] - mean;
 double dev2=dev*dev;
 double dev3=dev2*dev;
 double dev4=dev3*dev;
 average_deviation += fabs(dev);
 variance += dev2 ;
 skew += dev3 ;
 kurtosis += dev4 ;
    }
    average_deviation /= n;
    variance /= (n - 1);
    standard_deviation = sqrt(variance);
    if (variance) {
 skew /= (n * variance * standard_deviation);
 kurtosis = (kurtosis/(n * variance * variance)) - 3.0;
    }
    mid = (n/2);
    kmedian(nums, n, mid);
    median = n % 2 ? nums[mid] : (nums[mid] + max(nums,mid))/2;
    free(nums);
    printf("n:                  %d\n", n);
    printf("median:             %f\n", median);
    printf("mean:               %f\n", mean);
    printf("average_deviation:  %f\n", average_deviation);
    printf("standard_deviation: %f\n", standard_deviation);
    printf("variance:           %f\n", variance);
    printf("skew:               %f\n", skew);
    printf("kurtosis:           %f\n", kurtosis);
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return(0);
}

canonical_original_code:
int main() {
    char line[128];
    int i; int n = 0; int mid = 0;
    double sum = 0.0;
    double mean = 0.0;
    double average_deviation = 0.0;
    double standard_deviation = 0.0;
    double variance = 0.0;
    double skew = 0.0;
    double kurtosis = 0.0;
    double median = 0.0;
    double deviation = 0.0;
    int array_size = 4096;
    double *nums;
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    nums = (double *)malloc(array_size * sizeof(double));
    while (fgets(line, 128, stdin)) {
 sum += (nums[n++] = atof(line));
 if (n == array_size) {
     array_size *= 2;
     nums = (double *)realloc(nums, array_size * sizeof(double));
 }
    }
    mean = sum/n;
    for (i=0; i<n; i++) {
 double dev = nums[i] - mean;
 double dev2 = dev*dev;
 double dev3 = dev2*dev;
 double dev4 = dev3*dev;
 average_deviation += fabs(dev);
 variance += dev2 ;
 skew += dev3 ;
 kurtosis += dev4 ;
    }
    average_deviation /= n;
    variance /= (n - 1);
    standard_deviation = sqrt(variance);
    if (variance) {
 skew /= (n * variance * standard_deviation);
 kurtosis = (kurtosis/(n * variance * variance)) - 3.0;
    }
    mid = (n/2);
    kmedian(nums, n, mid);
    median = n % 2 ? nums[mid] : (nums[mid] + max(nums,mid))/2;
    free(nums);
    printf("n:                  %d\n", n);
    printf("median:             %f\n", median);
    printf("mean:               %f\n", mean);
    printf("average_deviation:  %f\n", average_deviation);
    printf("standard_deviation: %f\n", standard_deviation);
    printf("variance:           %f\n", variance);
    printf("skew:               %f\n", skew);
    printf("kurtosis:           %f\n", kurtosis);
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return(0);
}

variable_types:
line
char [128]

variable_types: mid int

variable_types: sum double

variable_types: mean double

variable_types: variance double

variable_types: skew double

variable_types: kurtosis double

variable_types: median double

variable_types: deviation double

variable_types:
nums
double *

variable_types: dev double

user_defined_types: struct timeval { long tv_sec; long tv_usec; }


mov

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

if ( a1 == 1 )
{
--num[(int)a2];
++num[a3];
++count;
}
else
{
v4 = 6 - (a2 + a3);
mov((unsigned int)(a1 - 1), a2, v4);
mov(1LL, (unsigned int)a2, a3);
result = mov((unsigned int)(a1 - 1), v4, a3);
}
return result;
}

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

if ( a1 == 1 )
{
--num[(int)a2];
++num[a3];
++count;
}
else
{
v4 = 6 - (a2 + a3);
func7((unsigned int)(a1 - 1), a2, v4);
func7(1LL, (unsigned int)a2, a3);
result = func7((unsigned int)(a1 - 1), v4, a3);
}
return result;
}

original_code:
void mov(int n,int f,int t)
{
   int o;
   if(n == 1)
   {
 num[f]--;
 num[t]++;
 count++;
 return;
   }
   o = (6-(f+t));
   mov(n-1,f,o);
   mov(1,f,t);
   mov(n-1,o,t);
   return;
}

canonical_original_code:
void mov(int n, int f, int t)
{
   int o;
   if(n == 1)
   {
 num[f]--;
 num[t]++;
 count++;
 return;
   }
   o = (6-(f+t));
   mov(n-1,f,o);
   mov(1,f,t);
   mov(n-1,o,t);
   return;
}

variable_types: n int

variable_types: f int

variable_types: t int

variable_types: o int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
int i; // ebx

if ( argc <= 1 )
{
puts("Disks Moves");
v3 = 30;
}
else
{
v3 = atoi(argv[1]);
puts("Disks Moves");
if ( v3 <= 0 )
return 0;
}
for ( i = 1; i <= v3; ++i )
{
num[0] = 0;
dword_404064 = i;
dword_404068 = 0;
dword_40406C = 0;
count = 0LL;
mov(i, 1LL, 3u);
printf("%3d %10ld\n", (unsigned int)i, count);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
int i; // ebx

if ( argc <= 1 )
{
puts("Disks Moves");
v3 = 30;
}
else
{
v3 = atoi(argv[1]);
puts("Disks Moves");
if ( v3 <= 0 )
return 0;
}
for ( i = 1; i <= v3; ++i )
{
num[0] = 0;
dword_404064 = i;
dword_404068 = 0;
dword_40406C = 0;
count = 0LL;
func7(i, 1LL, 3u);
printf("%3d %10ld\n", (unsigned int)i, count);
}
return 0;
}

original_code:
int main(int argc, char* argv[])
{
 int disk;
 int max = 30;
 if(argc > 1)
  max = atoi(argv[1]);
 printf("Disks     Moves\n");
 for(disk = 1; disk <= max; disk++)
 {
  num[0] = 0;
  num[1] = disk;
  num[2] = 0;
  num[3] = 0;
  count = 0;
  mov(disk,1,3);
  printf("%3d  %10ld\n",disk,count);
 }
 return(0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int disk;
 int max = 30;
 if(argc > 1)
  max = atoi(argv[1]);
 printf("Disks     Moves\n");
 for(disk = 1; disk <= max; disk++)
 {
  num[0] = 0;
  num[1] = disk;
  num[2] = 0;
  num[3] = 0;
  count = 0;
  mov(disk,1,3);
  printf("%3d  %10ld\n",disk,count);
 }
 return(0);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: disk int

variable_types: max int


decompiled_code:
void __fastcall fill_array(double *a1, int a2, double a3)
{
double *v3; // rax

if ( a2 > 0 )
{
v3 = a1;
do
*v3++ = a3;
while ( v3 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

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

if ( a2 > 0 )
{
v3 = a1;
do
*v3++ = a3;
while ( v3 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

original_code:
void fill_array(double *array, int length, double value)
{
 int a;
 for (a = 0; a < length; a++)
  array[a] = value;
}

variable_types:
array
double *

variable_types: length int

variable_types: value double

variable_types: a int


decompiled_code:
int __fastcall callback_crunched(__int64 a1, __int64 a2)
{
return printf("%ds simulated\n", a2);
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1, __int64 a2)
{
return printf("%ds simulated\n", a2);
}

original_code:
void callback_crunched(void *ptr, int time)
{
 printf("%ds simulated\n", time);
}

variable_types:
ptr
void *

variable_types: time int


original_code:
int main()
{
 struct bio_params *bio_info;
 bio_info = malloc(sizeof(*bio_info));
 bio_info->explicit_scheme = 0;
 bio_info->subs_inh = 1;
 bio_info->prod_inh = 1;
 bio_info->k2 = 1;
 bio_info->km = 0.01 * 1e-3;
 bio_info->ks = 0.001 * 1e-3;
 bio_info->kp = 0.001 * 1e-3;
 bio_info->dt = 1e-3;
 bio_info->n = 200;
 bio_info->resp_t_meth = MIN_TIME;
 bio_info->min_t = 200;
 bio_info->resp_t = 0;
 bio_info->out_file_name = "output.dat";
 bio_info->ne = 1;
 bio_info->s0 = 0.04 * 1e-3;
 bio_info->p0 = 0 * 1e-3;
 bio_info->layer_count = 2;
 bio_info->layers = malloc(sizeof(*(bio_info->layers)) * bio_info->layer_count);
 bio_info->layers[0].enz_layer = 1;
 bio_info->layers[0].Ds = 100 * 1e-8;
 bio_info->layers[0].Dp = 100 * 1e-8;
 bio_info->layers[0].d = 10 * 1e-4;
 bio_info->layers[0].e0 = 0.01 * 1e-3;
 bio_info->layers[1].enz_layer = 0;
 bio_info->layers[1].Ds = 200 * 1e-8;
 bio_info->layers[1].Dp = 200 * 1e-8;
 bio_info->layers[1].d = 300 * 1e-4;
 bio_info->layers[1].e0 = 0 * 1e-3;
 calculate(bio_info, ((void *)0), &callback_crunched);
 free(bio_info->layers);
 free(bio_info);
 return 0;
}

variable_types: struct bio_params { int explicit_scheme; int subs_inh; int prod_inh; double k2; double km; double ks; double kp; double dt; int n; enum resp_method { DEFAULT_TIME=0, MIN_TIME=1, FIXED_TIME=2 } resp_t_meth; double min_t; double resp_t; char *out_file_name; int ne; double s0; double p0; int layer_count; struct layer_params { int enz_layer; double Ds; double Dp; double d; double e0; } *layers; } *

user_defined_types: struct bio_params { int explicit_scheme; int subs_inh; int prod_inh; double k2; double km; double ks; double kp; double dt; int n; enum resp_method resp_t_meth; double min_t; double resp_t; char *out_file_name; int ne; double s0; double p0; int layer_count; struct layer_params *layers; }


calculate

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

if ( *a1 )
result = calculate_explicitly();
else
result = calculate_implicitly();
return result;
}

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

if ( *a1 )
result = calculate_explicitly();
else
result = calculate_implicitly();
return result;
}

original_code:
void calculate(struct bio_params *bio_info, void *ptr, void (*callback_crunched)(void *, int))
{
 if (bio_info->explicit_scheme)
  calculate_explicitly(bio_info, ptr, callback_crunched);
 else
  calculate_implicitly(bio_info, ptr, callback_crunched);
}

user_defined_types: enum resp_method { DEFAULT_TIME=0, MIN_TIME=1, FIXED_TIME=2 }

user_defined_types: struct layer_params { int enz_layer; double Ds; double Dp; double d; double e0; }


canonical_original_code:
void fill_array(double *array, int length, double value)
{
 int a;
 for (a = 0; a < length; a++)
  array[a] = value;
}


canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2)
{
return printf("%ds simulated\n", a2);
}

canonical_original_code:
void callback_crunched(void *ptr, int time)
{
 printf("%ds simulated\n", time);
}