jfget

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

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

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

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

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

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

variable_types:
result
char *

variable_types:
length
unsigned long *

variable_types:
error
char *

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

variable_types:
uestr
char *

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

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

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

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


jfgetint

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

v6 = json_finder_find(
v8,
**(_QWORD **)(a2 + 16),
**(_QWORD **)(a2 + 24),
*(_QWORD *)(*(_QWORD *)(a2 + 16) + 8LL),
*(_QWORD *)(*(_QWORD *)(a2 + 24) + 8LL),
0LL,
0LL,
0LL);
if ( v6 == -1 )
{
*a3 = 1;
result = 0LL;
}
else if ( v6 == 1 )
{
*a4 = 1;
result = 0LL;
}
else
{
switch ( v9 )
{
case 1:
*a3 = 1;
result = 0LL;
break;
case 2:
*a4 = 1;
result = 0LL;
break;
case 3:
result = v8[0];
break;
case 4:
*a4 = 1;
result = 0LL;
break;
case 5:
result = SLODWORD(v8[0]);
break;
default:
*a4 = 1;
result = 0LL;
break;
}
}
return result;
}

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

v6 = json_finder_find(
v8,
**(_QWORD **)(a2 + 16),
**(_QWORD **)(a2 + 24),
*(_QWORD *)(*(_QWORD *)(a2 + 16) + 8LL),
*(_QWORD *)(*(_QWORD *)(a2 + 24) + 8LL),
0LL,
0LL,
0LL);
if ( v6 == -1 )
{
*a3 = 1;
result = 0LL;
}
else if ( v6 == 1 )
{
*a4 = 1;
result = 0LL;
}
else
{
switch ( v9 )
{
case 1:
*a3 = 1;
result = 0LL;
break;
case 2:
*a4 = 1;
result = 0LL;
break;
case 3:
result = v8[0];
break;
case 4:
*a4 = 1;
result = 0LL;
break;
case 5:
result = SLODWORD(v8[0]);
break;
default:
*a4 = 1;
result = 0LL;
break;
}
}
return result;
}

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

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

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

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

return_type: long long

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

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

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

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


decompiled_code:
__int64 __fastcall jfgetreal_init(__int64 a1, __int64 a2, char *a3)
{
_DWORD *v3; // rax
__int64 result; // rax

if ( *(_DWORD *)a2 == 2 )
{
v3 = *(_DWORD **)(a2 + 8);
if ( *v3 )
{
strcpy(a3, "jfget() requires a string for first argument");
result = 1LL;
}
else if ( v3[1] )
{
strcpy(a3, "jfget() requires a string for second argument");
result = 1LL;
}
else
{
**(_BYTE **)(a2 + 32) = 0;
*(_BYTE *)(*(_QWORD *)(a2 + 32) + 1LL) = 0;
result = 0LL;
}
}
else
{
strcpy(a3, "jfget() requires two arguments");
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, char *a3)
{
_DWORD *v3; // rax
__int64 result; // rax

if ( *(_DWORD *)a2 == 2 )
{
v3 = *(_DWORD **)(a2 + 8);
if ( *v3 )
{
strcpy(a3, "jfget() requires a string for first argument");
result = 1LL;
}
else if ( v3[1] )
{
strcpy(a3, "jfget() requires a string for second argument");
result = 1LL;
}
else
{
**(_BYTE **)(a2 + 32) = 0;
*(_BYTE *)(*(_QWORD *)(a2 + 32) + 1LL) = 0;
result = 0LL;
}
}
else
{
strcpy(a3, "jfget() requires two arguments");
result = 1LL;
}
return result;
}

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

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

variable_types:
message
char *

return_type: char


decompiled_code:
void jfgetreal_deinit()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

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

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

return_type: void


jfgetreal

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

v6 = json_finder_find(
v8,
**(_QWORD **)(a2 + 16),
**(_QWORD **)(a2 + 24),
*(_QWORD *)(*(_QWORD *)(a2 + 16) + 8LL),
*(_QWORD *)(*(_QWORD *)(a2 + 24) + 8LL),
0LL,
0LL,
0LL);
if ( v6 == -1 )
{
*a3 = 1;
result = 0.0;
}
else if ( v6 == 1 )
{
*a4 = 1;
result = 0.0;
}
else
{
switch ( v9 )
{
case 1:
*a3 = 1;
result = 0.0;
break;
case 2:
*a4 = 1;
result = 0.0;
break;
case 3:
*a4 = 1;
result = 0.0;
break;
case 4:
result = v8[0];
break;
case 5:
*a4 = 1;
result = 0.0;
break;
default:
*a4 = 1;
result = 0.0;
break;
}
}
return result;
}

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

v6 = json_finder_find(
v8,
**(_QWORD **)(a2 + 16),
**(_QWORD **)(a2 + 24),
*(_QWORD *)(*(_QWORD *)(a2 + 16) + 8LL),
*(_QWORD *)(*(_QWORD *)(a2 + 24) + 8LL),
0LL,
0LL,
0LL);
if ( v6 == -1 )
{
*a3 = 1;
result = 0.0;
}
else if ( v6 == 1 )
{
*a4 = 1;
result = 0.0;
}
else
{
switch ( v9 )
{
case 1:
*a3 = 1;
result = 0.0;
break;
case 2:
*a4 = 1;
result = 0.0;
break;
case 3:
*a4 = 1;
result = 0.0;
break;
case 4:
result = v8[0];
break;
case 5:
*a4 = 1;
result = 0.0;
break;
default:
*a4 = 1;
result = 0.0;
break;
}
}
return result;
}

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

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

return_type: double


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

if ( *(_DWORD *)a2 == 1 )
{
if ( **(_DWORD **)(a2 + 8) )
{
strcpy(a3, "jfget() requires a string");
result = 1LL;
}
else
{
**(_BYTE **)(a2 + 32) = 0;
*(_QWORD *)(a1 + 16) = 0LL;
result = 0LL;
}
}
else
{
strcpy(a3, "jfget() requires one arguments");
result = 1LL;
}
return result;
}

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

if ( *(_DWORD *)a2 == 1 )
{
if ( **(_DWORD **)(a2 + 8) )
{
strcpy(a3, "jfget() requires a string");
result = 1LL;
}
else
{
**(_BYTE **)(a2 + 32) = 0;
*(_QWORD *)(a1 + 16) = 0LL;
result = 0LL;
}
}
else
{
strcpy(a3, "jfget() requires one arguments");
result = 1LL;
}
return result;
}

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

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


decompiled_code:
void __fastcall jfmin_deinit(__int64 a1)
{
free(*(void **)(a1 + 16));
}

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

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

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


jfmin

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

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

return_type: char *


decompiled_code:
void ingame_level1_render()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void ingame_level1_render(Game* game){
}

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

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

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

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

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

user_defined_types: union soundFile { struct OggVorbis_File oggFile; }

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

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


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

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

variable_types: dt int

variable_types: t double

variable_types: i int

variable_types:
fogColor
float [4]

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

variable_types: j int

variable_types: rayon double

variable_types: angle double

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

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


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

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

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
int v2[6]; // [rsp+0h] [rbp-20h] BYREF

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

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

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

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

user_defined_types: union soundFile { struct OggVorbis_File oggFile; }


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

variable_types: ddx double

variable_types: ddy double

variable_types: ddz double

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

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


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

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

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

variable_types: dtheta double

variable_types: dphi double

variable_types: drho double

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

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


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

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

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

variable_types: ddtheta double

variable_types: ddphi double

variable_types: ddrho double

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

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


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

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

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

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

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

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

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


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

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

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

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

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

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


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

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

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

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


decompiled_code:
__int64 __fastcall camera_render(double *a1)
{
glClear(16640LL);
SDL_GetTicks();
camera_look(a1);
glMatrixMode(5888LL);
glLoadIdentity();
gluLookAt(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
glRotated(a1[3], 1.0, 0.0);
glRotated(a1[1], 0.0, 1.0);
glRotated(a1[2], 0.0, 0.0);
glTranslated(a1[10], a1[11] + a1[13], a1[12] + a1[14], 1.0);
game_render(*(_QWORD *)a1);
glClear(256LL);
return camera_HUD(a1);
}

original_code:
void camera_render(Camera* c){
 glClear(0x00004000 | 0x00000100);
 double time_=SDL_GetTicks()*0.001;
 camera_look(c);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 glRotated(c->rho,1,0,0);
 glRotated(c->theta, 0.0, 1.0, 0.0);
 glRotated(c->phi, 0.0, 0.0, 1.0);
 glTranslated(c->x, c->y + c->fake_y, c->z + c->fake_z);
 game_render(c->game);
 glClear(0x00000100);
 camera_HUD(c);
}

canonical_original_code:
void camera_render(struct Camera *c){
 glClear(0x00004000 | 0x00000100);
 double time_ = SDL_GetTicks()*0.001;
 camera_look(c);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 glRotated(c->rho,1,0,0);
 glRotated(c->theta, 0.0, 1.0, 0.0);
 glRotated(c->phi, 0.0, 0.0, 1.0);
 glTranslated(c->x, c->y + c->fake_y, c->z + c->fake_z);
 game_render(c->game);
 glClear(0x00000100);
 camera_HUD(c);
}

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

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


decompiled_code:
__int64 __fastcall camera_ApplyLeftFrustum(__int64 a1, double a2, double a3, double a4, double a5)
{
double v5; // xmm0_8

glTranslated(*(double *)(a1 + 168), 0.0, 0.0, a5);
v5 = atan(*(double *)(a1 + 176) / *(double *)(a1 + 168));
glRotated(v5 * -57.29577951307855, 0.0, 0.0);
return glTranslated(COERCE_DOUBLE(*(_QWORD *)(a1 + 168) ^ LC1), 0.0, 0.0, 1.0);
}

original_code:
void camera_ApplyLeftFrustum(Camera* c){
 glTranslated(c->mConvergence,0,0);
 glRotated( -180/3.14159265359*atan(c->mEyeSeparation/c->mConvergence),0,0,1);
 glTranslated(-c->mConvergence,0,0);
}

canonical_original_code:
void camera_ApplyLeftFrustum(struct Camera *c){
 glTranslated(c->mConvergence,0,0);
 glRotated( -180/3.14159265359*atan(c->mEyeSeparation/c->mConvergence),0,0,1);
 glTranslated(-c->mConvergence,0,0);
}

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

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


decompiled_code:
__int64 __fastcall camera_ApplyRightFrustum(__int64 a1, double a2, double a3, double a4, double a5)
{
double v5; // xmm0_8

glTranslated(*(double *)(a1 + 168), 0.0, 0.0, a5);
v5 = atan(*(double *)(a1 + 176) / *(double *)(a1 + 168));
glRotated(v5 * 57.29577951307855, 0.0, 0.0);
return glTranslated(COERCE_DOUBLE(*(_QWORD *)(a1 + 168) ^ LC1), 0.0, 0.0, 1.0);
}

original_code:
void camera_ApplyRightFrustum(Camera* c){
 glTranslated(c->mConvergence,0,0);
 glRotated( +180/3.14159265359*atan(c->mEyeSeparation/c->mConvergence),0,0,1);
 glTranslated(-c->mConvergence,0,0);
}

canonical_original_code:
void camera_ApplyRightFrustum(struct Camera *c){
 glTranslated(c->mConvergence,0,0);
 glRotated( +180/3.14159265359*atan(c->mEyeSeparation/c->mConvergence),0,0,1);
 glTranslated(-c->mConvergence,0,0);
}

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

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


decompiled_code:
__int64 __fastcall camera_render_stereo(double *a1)
{
double v1; // xmm0_8
double v2; // xmm2_8
double v3; // xmm1_8
double v4; // xmm0_8
double v5; // xmm2_8
double v6; // xmm1_8

glClear(16640LL);
camera_look(a1);
glColorMask(1LL, 0LL, 0LL, 0LL);
glMatrixMode(5888LL);
((void (*)(void))glLoadIdentity)();
gluLookAt(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
glRotated(a1[3], 1.0, 0.0);
glRotated(a1[1], 0.0, 1.0);
glRotated(a1[2], 0.0, 0.0);
v1 = a1[10];
v2 = a1[12];
v3 = a1[11];
glTranslated(v1, v3, v2, 1.0);
camera_ApplyLeftFrustum((__int64)a1, v1, v3, v2, 1.0);
game_render(*(_QWORD *)a1);
glClear(256LL);
camera_look(a1);
glColorMask(0LL, 1LL, 1LL, 0LL);
glMatrixMode(5888LL);
glLoadIdentity(5888LL);
gluLookAt(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
glRotated(a1[3], 1.0, 0.0);
glRotated(a1[1], 0.0, 1.0);
glRotated(a1[2], 0.0, 0.0);
v4 = a1[10];
v5 = a1[12];
v6 = a1[11];
glTranslated(v4, v6, v5, 1.0);
camera_ApplyRightFrustum((__int64)a1, v4, v6, v5, 1.0);
game_render(*(_QWORD *)a1);
glColorMask(1LL, 1LL, 1LL, 1LL);
glClear(256LL);
return camera_HUD(a1);
}

original_code:
void camera_render_stereo(Camera* c){
 glClear(0x00004000 | 0x00000100);
 camera_look(c);
 glColorMask(1, 0, 0, 0);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 glRotated(c->rho,1,0,0);
 glRotated(c->theta, 0.0, 1.0, 0.0);
 glRotated(c->phi, 0.0, 0.0, 1.0);
 glTranslated(c->x, c->y, c->z);
 camera_ApplyLeftFrustum(c);
 game_render(c->game);
 glClear(0x00000100) ;
 camera_look(c);
 glColorMask(0, 1, 1, 0);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 glRotated(c->rho,1,0,0);
 glRotated(c->theta, 0.0, 1.0, 0.0);
 glRotated(c->phi, 0.0, 0.0, 1.0);
 glTranslated(c->x, c->y, c->z);
 camera_ApplyRightFrustum(c);
 game_render(c->game);
 glColorMask(1, 1, 1, 1);
 glClear(0x00000100);
 camera_HUD(c);
}

canonical_original_code:
void camera_render_stereo(struct Camera *c){
 glClear(0x00004000 | 0x00000100);
 camera_look(c);
 glColorMask(1, 0, 0, 0);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 glRotated(c->rho,1,0,0);
 glRotated(c->theta, 0.0, 1.0, 0.0);
 glRotated(c->phi, 0.0, 0.0, 1.0);
 glTranslated(c->x, c->y, c->z);
 camera_ApplyLeftFrustum(c);
 game_render(c->game);
 glClear(0x00000100) ;
 camera_look(c);
 glColorMask(0, 1, 1, 0);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 glRotated(c->rho,1,0,0);
 glRotated(c->theta, 0.0, 1.0, 0.0);
 glRotated(c->phi, 0.0, 0.0, 1.0);
 glTranslated(c->x, c->y, c->z);
 camera_ApplyRightFrustum(c);
 game_render(c->game);
 glColorMask(1, 1, 1, 1);
 glClear(0x00000100);
 camera_HUD(c);
}

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

user_defined_types: union soundFile { struct OggVorbis_File oggFile; }


variable_types: dt int

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

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


original_code:
int sound_nextSample (SoundSample * sample) {
 char array[4096];
 long bytes;
 if(sample->read_size!=0){
  memcpy (sample->old_data, sample->data, sample->read_size);
  sample->old_read_size = sample->read_size;
 }
 sample->read_size = 0;
 do {
  bytes = ov_read (&sample->s_file.oggFile, array, 4096, 0, 2, 1, &sample->bitStream);
  memcpy (&sample->data[sample->read_size], array, bytes);
  sample->read_size += bytes;
 }while ((sample->read_size + 4096) < sample->size && bytes != 0);
 return sample->read_size;
}

canonical_original_code:
int sound_nextSample(struct SoundSample *sample) {
 char array[4096];
 long bytes;
 if(sample->read_size!=0){
  memcpy (sample->old_data, sample->data, sample->read_size);
  sample->old_read_size = sample->read_size;
 }
 sample->read_size = 0;
 do {
  bytes = ov_read (&sample->s_file.oggFile, array, 4096, 0, 2, 1, &sample->bitStream);
  memcpy (&sample->data[sample->read_size], array, bytes);
  sample->read_size += bytes;
 }while ((sample->read_size + 4096) < sample->size && bytes != 0);
 return sample->read_size;
}

variable_types: struct SoundSample { char *data; char *old_data; int size; int old_read_size; int read_size; int freq; int format; int bitStream; union soundFile { struct OggVorbis_File { void *datasource; int seekable; long offset; long end; struct ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; } oy; int links; long *offsets; long *dataoffsets; long *serialnos; long *pcmlengths; struct vorbis_info { int version; int channels; long rate; long bitrate_upper; long bitrate_nominal; long bitrate_lower; long bitrate_window; void *codec_setup; } *vi; struct vorbis_comment { char **user_comments; int *comment_lengths; int comments; char *vendor; } *vc; long pcm_offset; int ready_state; long current_serialno; int current_link; double bittrack; double samptrack; struct ogg_stream_state { unsigned char *body_data; long body_storage; long body_fill; long body_returned; int *lacing_vals; long *granule_vals; long lacing_storage; long lacing_fill; long lacing_packet; long lacing_returned; unsigned char header[282]; int header_fill; int e_o_s; int b_o_s; long serialno; long pageno; long packetno; long granulepos; } os; struct vorbis_dsp_state { int analysisp; struct vorbis_info *vi; float **pcm; float **pcmret; int pcm_storage; int pcm_current; int pcm_returned; int preextrapolate; int eofflag; long lW; long W; long nW; long centerW; long granulepos; long sequence; long glue_bits; long time_bits; long floor_bits; long res_bits; void *backend_state; } vd; struct vorbis_block { float **pcm; struct oggpack_buffer { long endbyte; int endbit; unsigned char *buffer; unsigned char *ptr; long storage; } opb; long lW; long W; long nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; struct vorbis_dsp_state *vd; void *localstore; long localtop; long localalloc; long totaluse; struct alloc_chain { void *ptr; struct alloc_chain *next; } *reap; long glue_bits; long time_bits; long floor_bits; long res_bits; void *internal; } vb; struct ov_callbacks { unsigned long (*read_func)(void *ptr, unsigned long size, unsigned long nmemb, void *datasource); int (*seek_func)(void *datasource, long offset, int whence); int (*close_func)(void *datasource); long (*tell_func)(void *datasource); } callbacks; } oggFile; } s_file; } *

variable_types:
array
char [4096]

variable_types: bytes long

return_type: int


decompiled_code:
__int64 __fastcall sound_seekSample(__int64 a1)
{
return ov_raw_seek(a1 + 40, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return ov_raw_seek(a1 + 40, 0LL);
}

original_code:
void sound_seekSample (SoundSample * sample) {
 ov_raw_seek (&sample->s_file.oggFile, 0);
}

canonical_original_code:
void sound_seekSample(struct SoundSample *sample) {
 ov_raw_seek (&sample->s_file.oggFile, 0);
}


decompiled_code:
void __fastcall sound_closeSample(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 1));
ov_clear((char *)ptr + 40);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 1));
ov_clear((char *)ptr + 40);
free(ptr);
}

original_code:
void sound_closeSample (SoundSample * sample) {
 free (sample->data);
 free (sample->old_data);
 ov_clear (&sample->s_file.oggFile);
 free (sample);
}

canonical_original_code:
void sound_closeSample(struct SoundSample *sample) {
 free (sample->data);
 free (sample->old_data);
 ov_clear (&sample->s_file.oggFile);
 free (sample);
}


decompiled_code:
char __fastcall ingame_level2_update(__int64 a1)
{
__int64 v2; // rdx
bool v3; // al
bool v4; // cf
bool v5; // zf
const char *v6; // rsi
const char *v7; // rdi
__int64 v8; // rcx
char result; // al

v2 = *(_QWORD *)(a1 + 112);
v3 = strcmp(*(const char **)(v2 + 16), "music/Goto80_gopho_level2.ogg") != 0;
v4 = 0;
v5 = !v3;
if ( !v3 )
{
audioplayer_set_next(v2, "music/Goto80_gopho_level3.ogg");
*(double *)&sky_1_x = 0.5 * *(double *)&sky_1_dx + *(double *)&sky_1_x;
*(double *)&sky_1_y = 0.5 * *(double *)&sky_1_dy + *(double *)&sky_1_y;
game_loop_coord(a1, &sky_1_x, &sky_1_y);
*(double *)&sky_2_x = 0.5 * *(double *)&sky_2_dx + *(double *)&sky_2_x;
*(double *)&sky_2_y = 0.5 * *(double *)&sky_2_dy + *(double *)&sky_2_y;
game_loop_coord(a1, &sky_2_x, &sky_2_y);
*(double *)&sky_3_x = 0.5 * *(double *)&sky_3_dx + *(double *)&sky_3_x;
*(double *)&sky_3_y = 0.5 * *(double *)&sky_3_dy + *(double *)&sky_3_y;
game_loop_coord(a1, &sky_3_x, &sky_3_y);
}
v6 = *(const char **)(*(_QWORD *)(a1 + 112) + 16LL);
v7 = "music/Goto80_gopho_level3.ogg";
v8 = 30LL;
do
{
if ( !v8 )
break;
v4 = *v6 < (unsigned int)*v7;
v5 = *v6++ == *v7++;
--v8;
}
while ( v5 );
result = (!v4 && !v5) - v4;
if ( !result )
{
change_bg_color(v7, v6, 0.0, 0.0);
*(_DWORD *)(a1 + 216) = 2;
result = ingame_level3_setup(a1);
}
return result;
}

canonical_decompiled_code:
char __fastcall func0(__int64 a1)
{
__int64 v2; // rdx
bool v3; // al
bool v4; // cf
bool v5; // zf
const char *v6; // rsi
const char *v7; // rdi
__int64 v8; // rcx
char result; // al

v2 = *(_QWORD *)(a1 + 112);
v3 = strcmp(*(const char **)(v2 + 16), "music/Goto80_gopho_level2.ogg") != 0;
v4 = 0;
v5 = !v3;
if ( !v3 )
{
audioplayer_set_next(v2, "music/Goto80_gopho_level3.ogg");
*(double *)&sky_1_x = 0.5 * *(double *)&sky_1_dx + *(double *)&sky_1_x;
*(double *)&sky_1_y = 0.5 * *(double *)&sky_1_dy + *(double *)&sky_1_y;
game_loop_coord(a1, &sky_1_x, &sky_1_y);
*(double *)&sky_2_x = 0.5 * *(double *)&sky_2_dx + *(double *)&sky_2_x;
*(double *)&sky_2_y = 0.5 * *(double *)&sky_2_dy + *(double *)&sky_2_y;
game_loop_coord(a1, &sky_2_x, &sky_2_y);
*(double *)&sky_3_x = 0.5 * *(double *)&sky_3_dx + *(double *)&sky_3_x;
*(double *)&sky_3_y = 0.5 * *(double *)&sky_3_dy + *(double *)&sky_3_y;
game_loop_coord(a1, &sky_3_x, &sky_3_y);
}
v6 = *(const char **)(*(_QWORD *)(a1 + 112) + 16LL);
v7 = "music/Goto80_gopho_level3.ogg";
v8 = 30LL;
do
{
if ( !v8 )
break;
v4 = *v6 < (unsigned int)*v7;
v5 = *v6++ == *v7++;
--v8;
}
while ( v5 );
result = (!v4 && !v5) - v4;
if ( !result )
{
change_bg_color(v7, v6, 0.0, 0.0);
*(_DWORD *)(a1 + 216) = 2;
result = ingame_level3_setup(a1);
}
return result;
}

original_code:
void ingame_level2_update(Game* game,int dt){
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level2.ogg")){
  audioplayer_set_next(game->audio,"music/Goto80_gopho_level3.ogg");
  sky_1_x+=.5*sky_1_dx;
  sky_1_y+=.5*sky_1_dy;
  game_loop_coord(game,&sky_1_x,&sky_1_y);
  sky_2_x+=.5*sky_2_dx;
  sky_2_y+=.5*sky_2_dy;
  game_loop_coord(game,&sky_2_x,&sky_2_y);
  sky_3_x+=.5*sky_3_dx;
  sky_3_y+=.5*sky_3_dy;
  game_loop_coord(game,&sky_3_x,&sky_3_y);
 }
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level3.ogg")){
  change_bg_color(0,0,0);
  game->weapon=2;
  ingame_level3_setup(game);
 }
}

canonical_original_code:
void ingame_level2_update(struct Game *game, int dt){
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level2.ogg")){
  audioplayer_set_next(game->audio,"music/Goto80_gopho_level3.ogg");
  sky_1_x+=.5*sky_1_dx;
  sky_1_y+=.5*sky_1_dy;
  game_loop_coord(game,&sky_1_x,&sky_1_y);
  sky_2_x+=.5*sky_2_dx;
  sky_2_y+=.5*sky_2_dy;
  game_loop_coord(game,&sky_2_x,&sky_2_y);
  sky_3_x+=.5*sky_3_dx;
  sky_3_y+=.5*sky_3_dy;
  game_loop_coord(game,&sky_3_x,&sky_3_y);
 }
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level3.ogg")){
  change_bg_color(0,0,0);
  game->weapon=2;
  ingame_level3_setup(game);
 }
}

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


decompiled_code:
__int64 __fastcall draw_stuff_in_sky(double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8)
{
int i; // er12
int j; // ebx
double v11; // xmm3_8
__int64 result; // rax
double v15; // [rsp+30h] [rbp-40h]
double v16; // [rsp+38h] [rbp-38h]

glLineWidth(5.0);
for ( i = 0; i != 50; ++i )
{
v15 = (0.5 - (double)i / 50.0) * 2000.0 + a1;
for ( j = 0; j != 50; ++j )
{
v16 = (0.5 - (double)j / 50.0) * 2000.0 + a2;
glBegin(1LL);
glColor4d(0.0, 0.0, 0.0);
glVertex3d(v15, v16, a3);
v11 = *(double *)&sky_transparency;
glColor4d(a6, a7, a8);
glVertex3d(v15 + a4, v16 + a5, a3);
result = glEnd(v15 + a4, v16 + a5, a3, v11);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8)
{
int i; // er12
int j; // ebx
double v11; // xmm3_8
__int64 result; // rax
double v15; // [rsp+30h] [rbp-40h]
double v16; // [rsp+38h] [rbp-38h]

glLineWidth(5.0);
for ( i = 0; i != 50; ++i )
{
v15 = (0.5 - (double)i / 50.0) * 2000.0 + a1;
for ( j = 0; j != 50; ++j )
{
v16 = (0.5 - (double)j / 50.0) * 2000.0 + a2;
glBegin(1LL);
glColor4d(0.0, 0.0, 0.0);
glVertex3d(v15, v16, a3);
v11 = *(double *)&sky_transparency;
glColor4d(a6, a7, a8);
glVertex3d(v15 + a4, v16 + a5, a3);
result = glEnd(v15 + a4, v16 + a5, a3, v11);
}
}
return result;
}

original_code:
void draw_stuff_in_sky(double x,double y,double z,double dx,double dy,double r,double g,double b){
 glLineWidth(5);
 for(int i=0;i<50;i++){
  for(int j=0;j<50;j++){
   double xx=.5-i/50.;
   double yy=.5-j/50.;
   xx*=2000;
   yy*=2000;
   xx+=x;
   yy+=y;
   glBegin(0x0001);
    glColor4d(0,0,0,0);
    glVertex3d(xx,yy,z);
    glColor4d(r,g,b,sky_transparency);
    glVertex3d(xx+dx,yy+dy,z);
   glEnd();
  }
 }
}

canonical_original_code:
void draw_stuff_in_sky(double x, double y, double z, double dx, double dy, double r, double g, double b){
 glLineWidth(5);
 for(int i = 0;i<50;i++){
  for(int j = 0;j<50;j++){
   double xx = .5-i/50.;
   double yy = .5-j/50.;
   xx*=2000;
   yy*=2000;
   xx+=x;
   yy+=y;
   glBegin(0x0001);
    glColor4d(0,0,0,0);
    glVertex3d(xx,yy,z);
    glColor4d(r,g,b,sky_transparency);
    glVertex3d(xx+dx,yy+dy,z);
   glEnd();
  }
 }
}

variable_types: x double

variable_types: y double

variable_types: z double

variable_types: dx double

variable_types: dy double

variable_types: r double

variable_types: g double

variable_types: b double

variable_types: i int

variable_types: j int

variable_types: xx double

variable_types: yy double


original_code:
void draw_aurore_boreale(Game * game,double * X, double *Y, double * Z,int partie){
 double time_=SDL_GetTicks()*0.001;
 glDisable( 0x0B10 );
 glPointSize(4);
 glBegin(0x0000);
 glColor4d(.5,0,0,1);
 glDepthFunc(0x0207);
 int i_max = 120;
 int j_max = 7;
 double inverse_i_max=1./i_max;
 double inverse_j_max=1./j_max;
 if(partie){
  while(*X-100+game->player->x+game->world_x_size*.5>0)
   *X-=game->world_x_size;
  while(*X-100+game->player->x+game->world_x_size*.5<0)
   *X+=game->world_x_size;
  while(*Y+game->player->y+game->world_y_size*.5>0)
   *Y-=game->world_y_size;
  while(*Y+game->player->y+game->world_y_size*.5<0)
   *Y+=game->world_y_size;
 }else{
  while(*X-200+game->player->x+game->world_x_size*.5>0)
   *X-=game->world_x_size;
  while(*X-200+game->player->x+game->world_x_size*.5<0)
   *X+=game->world_x_size;
  while(*Y+game->player->y+game->world_y_size*.5>0)
   *Y-=game->world_y_size;
  while(*Y+game->player->y+game->world_y_size*.5<0)
   *Y+=game->world_y_size;
 }
 int i_min=-i_max;
 if(partie){
  i_min=0;
 }else{
  i_max=0;
 }
 for(int i=i_min;i<i_max;i++){
  for(int j=-j_max;j<j_max;j++){
   double x=i*inverse_i_max + .1*random(-.5,1);
   double variation = 40*sin(2*x*(1)+.5*time_) + 10*sin(10*x+time_) + 10*sin(24*x-time_) + 3*sin(45*x-5*time_);
   variation=2*variation;
   double y=j*inverse_j_max + .1*random(-.5,1);
   double dist_factor=1-exp(-1-1*y);
   double super_z = exp(2*(-y+1))*(1+random(-.5,1));
   glColor4d(0,dist_factor*(.5+.5*sin(2*3.14159265359*x+2*3.14159265359*exp(-.1-.1*super_z)-time_)),dist_factor*(.5+.5*cos(2*3.14159265359*exp(-.1-.1*super_z)-time_)),.4);
   glVertex3d(
     *X+x*200 + variation * sin(15*x*(1)+time_)+ 20*random(-.5,1),
     *Y + variation + 20*random(-.5,1),
     *Z+64 + 5*super_z + 20*sin(20*x + time_)
    );
  }
 }
 glEnd();
 glDepthFunc(0x0201);
}

canonical_original_code:
void draw_aurore_boreale(struct Game *game, double *X, double *Y, double *Z, int partie){
 double time_ = SDL_GetTicks()*0.001;
 glDisable( 0x0B10 );
 glPointSize(4);
 glBegin(0x0000);
 glColor4d(.5,0,0,1);
 glDepthFunc(0x0207);
 int i_max = 120;
 int j_max = 7;
 double inverse_i_max = 1./i_max;
 double inverse_j_max = 1./j_max;
 if(partie){
  while(*X-100+game->player->x+game->world_x_size*.5>0)
   *X-=game->world_x_size;
  while(*X-100+game->player->x+game->world_x_size*.5<0)
   *X+=game->world_x_size;
  while(*Y+game->player->y+game->world_y_size*.5>0)
   *Y-=game->world_y_size;
  while(*Y+game->player->y+game->world_y_size*.5<0)
   *Y+=game->world_y_size;
 }else{
  while(*X-200+game->player->x+game->world_x_size*.5>0)
   *X-=game->world_x_size;
  while(*X-200+game->player->x+game->world_x_size*.5<0)
   *X+=game->world_x_size;
  while(*Y+game->player->y+game->world_y_size*.5>0)
   *Y-=game->world_y_size;
  while(*Y+game->player->y+game->world_y_size*.5<0)
   *Y+=game->world_y_size;
 }
 int i_min = -i_max;
 if(partie){
  i_min=0;
 }else{
  i_max=0;
 }
 for(int i = i_min;i<i_max;i++){
  for(int j = -j_max;j<j_max;j++){
   double x = i*inverse_i_max + .1*random(-.5,1);
   double variation = 40*sin(2*x*(1)+.5*time_) + 10*sin(10*x+time_) + 10*sin(24*x-time_) + 3*sin(45*x-5*time_);
   variation=2*variation;
   double y = j*inverse_j_max + .1*random(-.5,1);
   double dist_factor = 1-exp(-1-1*y);
   double super_z = exp(2*(-y+1))*(1+random(-.5,1));
   glColor4d(0,dist_factor*(.5+.5*sin(2*3.14159265359*x+2*3.14159265359*exp(-.1-.1*super_z)-time_)),dist_factor*(.5+.5*cos(2*3.14159265359*exp(-.1-.1*super_z)-time_)),.4);
   glVertex3d(
     *X+x*200 + variation * sin(15*x*(1)+time_)+ 20*random(-.5,1),
     *Y + variation + 20*random(-.5,1),
     *Z+64 + 5*super_z + 20*sin(20*x + time_)
    );
  }
 }
 glEnd();
 glDepthFunc(0x0201);
}

variable_types:
X
double *

variable_types:
Y
double *

variable_types:
Z
double *

variable_types: partie int

variable_types: variation double

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

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


original_code:
void ingame_level2_render(Game* game){
 double music_time=audioplayer_getTime(game->audio);
  if( 07.45<music_time && music_time<07.70){
   change_bg_color(.5,.2,.2);
  }else if(22.70<music_time && music_time<22.95){
   change_bg_color(.5,.2,.2);
  }else if(29.70<music_time && music_time<29.80){
   change_bg_color(1,1,1);
  }else if(29.80<music_time && music_time<30.05){
   change_bg_color(1,0,0);
  }else if(30.05<music_time && music_time<30.30){
   change_bg_color(0,0,0);
  }else if(30.30<music_time && music_time<30.50){
   change_bg_color(1,0,0);
  }else if(44.35<music_time && music_time<45.45){
   double x=(music_time-44.35)/(45.45-44.35);
   change_bg_color(x*.5,0,0);
  }else if(45.45<music_time && music_time<45.75){
   change_bg_color(1,0,0);
  }else{
   change_bg_color(0,0,0);
  }
  if(45.75<music_time){
   game->weapon=2;
  }
 if(music_time<45.75){
  draw_aurore_boreale(game,&X1,&Y1,&Z1,1);
  draw_aurore_boreale(game,&X1,&Y1,&Z1,0);
  draw_aurore_boreale(game,&X2,&Y2,&Z2,1);
  draw_aurore_boreale(game,&X2,&Y2,&Z2,0);
 }else{
  change_bg_color(0,0,0);
  game->weapon=2;
  ingame_level3_setup(game);
 }
 if(music_time+.1>sky_change_counter*(15.325)/64.){
  sky_change_counter++;
  double angle=random(0.,3.14159265359/4.);
  if(angle<0) angle-=3.14159265359/8.;
  else angle+=3.14159265359/8.;
  double newx=cos(angle)*sky_1_dx-sin(angle)*sky_1_dy;
  double newy=sin(angle)*sky_1_dx+cos(angle)*sky_1_dy;
  sky_1_dx=newx;
  sky_1_dy=newy;
  angle=random(0,3.14159265359/4.);
  if(angle<0) angle-=3.14159265359/8.;
  else angle+=3.14159265359/8.;
  newx=cos(angle)*sky_2_dx-sin(angle)*sky_2_dy;
  newy=sin(angle)*sky_2_dx+cos(angle)*sky_2_dy;
  sky_2_dx=newx;
  sky_2_dy=newy;
  angle=random(0,3.14159265359/4.);
  if(angle<0) angle-=3.14159265359/8.;
  else angle+=3.14159265359/8.;
  newx=cos(angle)*sky_3_dx-sin(angle)*sky_3_dy;
  newy=sin(angle)*sky_3_dx+cos(angle)*sky_3_dy;
  sky_3_dx=newx;
  sky_3_dy=newy;
 }
 if(15.50<music_time && music_time<29.65){
  draw_stuff_in_sky(sky_1_x,sky_1_y,sky_1_z,sky_1_dx,sky_1_dy,0,.3,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,sky_2_z,sky_2_dx,sky_2_dy,0,.3,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,sky_3_z,sky_3_dx,sky_3_dy,0,1.,0);
  draw_stuff_in_sky(sky_1_x,sky_1_y,-sky_1_z,sky_1_dx,sky_1_dy,0,.3,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,-sky_2_z,sky_2_dx,sky_2_dy,0,.3,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,-sky_3_z,sky_3_dx,sky_3_dy,0,1.,0);
  if(music_time<19.10){
   sky_transparency=(music_time-15.5)/(19.1-15.50);
  }else if(music_time<23.3){
   sky_transparency=1 - (music_time-19.1)/(23.3-19.1);
  }else if(music_time<26.7){
   sky_transparency=(music_time-23.3)/(26.7-23.3);
  }else{
   sky_transparency=1 - (music_time-26.7)/(29.65-26.7);
  }
 }
 if(30.50<music_time && music_time<44.65){
  draw_stuff_in_sky(sky_1_x,sky_1_y,sky_1_z,sky_1_dx,sky_1_dy,0,1,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,sky_2_z,sky_2_dx,sky_2_dy,0,1,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,sky_3_z,sky_3_dx,sky_3_dy,0,1,0);
  draw_stuff_in_sky(sky_1_x,sky_1_y,-sky_1_z,sky_1_dx,sky_1_dy,0,1,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,-sky_2_z,sky_2_dx,sky_2_dy,0,1,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,-sky_3_z,sky_3_dx,sky_3_dy,0,1,0);
  if(music_time<34.10){
   sky_transparency=(music_time-30.5)/(34.1-30.50);
  }else if(music_time<38.3){
   sky_transparency=1 - (music_time-34.1)/(38.3-34.1);
  }else if(music_time<41.7){
   sky_transparency=(music_time-38.3)/(41.7-38.3);
  }else{
   sky_transparency=1 - (music_time-41.7)/(44.65-41.7);
  }
 }
}

canonical_original_code:
void ingame_level2_render(struct Game *game){
 double music_time = audioplayer_getTime(game->audio);
  if( 07.45<music_time && music_time<07.70){
   change_bg_color(.5,.2,.2);
  }else if(22.70<music_time && music_time<22.95){
   change_bg_color(.5,.2,.2);
  }else if(29.70<music_time && music_time<29.80){
   change_bg_color(1,1,1);
  }else if(29.80<music_time && music_time<30.05){
   change_bg_color(1,0,0);
  }else if(30.05<music_time && music_time<30.30){
   change_bg_color(0,0,0);
  }else if(30.30<music_time && music_time<30.50){
   change_bg_color(1,0,0);
  }else if(44.35<music_time && music_time<45.45){
   double x = (music_time-44.35)/(45.45-44.35);
   change_bg_color(x*.5,0,0);
  }else if(45.45<music_time && music_time<45.75){
   change_bg_color(1,0,0);
  }else{
   change_bg_color(0,0,0);
  }
  if(45.75<music_time){
   game->weapon=2;
  }
 if(music_time<45.75){
  draw_aurore_boreale(game,&X1,&Y1,&Z1,1);
  draw_aurore_boreale(game,&X1,&Y1,&Z1,0);
  draw_aurore_boreale(game,&X2,&Y2,&Z2,1);
  draw_aurore_boreale(game,&X2,&Y2,&Z2,0);
 }else{
  change_bg_color(0,0,0);
  game->weapon=2;
  ingame_level3_setup(game);
 }
 if(music_time+.1>sky_change_counter*(15.325)/64.){
  sky_change_counter++;
  double angle = random(0.,3.14159265359/4.);
  if(angle<0) angle-=3.14159265359/8.;
  else angle+=3.14159265359/8.;
  double newx = cos(angle)*sky_1_dx-sin(angle)*sky_1_dy;
  double newy = sin(angle)*sky_1_dx+cos(angle)*sky_1_dy;
  sky_1_dx=newx;
  sky_1_dy=newy;
  angle=random(0,3.14159265359/4.);
  if(angle<0) angle-=3.14159265359/8.;
  else angle+=3.14159265359/8.;
  newx=cos(angle)*sky_2_dx-sin(angle)*sky_2_dy;
  newy=sin(angle)*sky_2_dx+cos(angle)*sky_2_dy;
  sky_2_dx=newx;
  sky_2_dy=newy;
  angle=random(0,3.14159265359/4.);
  if(angle<0) angle-=3.14159265359/8.;
  else angle+=3.14159265359/8.;
  newx=cos(angle)*sky_3_dx-sin(angle)*sky_3_dy;
  newy=sin(angle)*sky_3_dx+cos(angle)*sky_3_dy;
  sky_3_dx=newx;
  sky_3_dy=newy;
 }
 if(15.50<music_time && music_time<29.65){
  draw_stuff_in_sky(sky_1_x,sky_1_y,sky_1_z,sky_1_dx,sky_1_dy,0,.3,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,sky_2_z,sky_2_dx,sky_2_dy,0,.3,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,sky_3_z,sky_3_dx,sky_3_dy,0,1.,0);
  draw_stuff_in_sky(sky_1_x,sky_1_y,-sky_1_z,sky_1_dx,sky_1_dy,0,.3,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,-sky_2_z,sky_2_dx,sky_2_dy,0,.3,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,-sky_3_z,sky_3_dx,sky_3_dy,0,1.,0);
  if(music_time<19.10){
   sky_transparency=(music_time-15.5)/(19.1-15.50);
  }else if(music_time<23.3){
   sky_transparency=1 - (music_time-19.1)/(23.3-19.1);
  }else if(music_time<26.7){
   sky_transparency=(music_time-23.3)/(26.7-23.3);
  }else{
   sky_transparency=1 - (music_time-26.7)/(29.65-26.7);
  }
 }
 if(30.50<music_time && music_time<44.65){
  draw_stuff_in_sky(sky_1_x,sky_1_y,sky_1_z,sky_1_dx,sky_1_dy,0,1,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,sky_2_z,sky_2_dx,sky_2_dy,0,1,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,sky_3_z,sky_3_dx,sky_3_dy,0,1,0);
  draw_stuff_in_sky(sky_1_x,sky_1_y,-sky_1_z,sky_1_dx,sky_1_dy,0,1,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,-sky_2_z,sky_2_dx,sky_2_dy,0,1,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,-sky_3_z,sky_3_dx,sky_3_dy,0,1,0);
  if(music_time<34.10){
   sky_transparency=(music_time-30.5)/(34.1-30.50);
  }else if(music_time<38.3){
   sky_transparency=1 - (music_time-34.1)/(38.3-34.1);
  }else if(music_time<41.7){
   sky_transparency=(music_time-38.3)/(41.7-38.3);
  }else{
   sky_transparency=1 - (music_time-41.7)/(44.65-41.7);
  }
 }
}

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

variable_types: x double

variable_types: angle double

variable_types: newx double

variable_types: newy double


decompiled_code:
char __fastcall ingame_level3_update(__int64 a1)
{
bool v1; // cf
bool v2; // zf
const char *v4; // rsi
const char *v5; // rdi
__int64 v6; // rcx
char v7; // al
bool v8; // cf
bool v9; // zf
const char *v10; // rsi
const char *v11; // rdi
__int64 v12; // rcx
char result; // al

v4 = *(const char **)(*(_QWORD *)(a1 + 112) + 16LL);
v5 = "music/Goto80_gopho_level3.ogg";
v6 = 30LL;
do
{
if ( !v6 )
break;
v1 = *v4 < (unsigned int)*v5;
v2 = *v4++ == *v5++;
--v6;
}
while ( v2 );
v7 = (!v1 && !v2) - v1;
v8 = 0;
v9 = v7 == 0;
if ( !v7 )
{
if ( !music_started )
{
*(_QWORD *)(a1 + 176) = mechant_regeneration_type_level3_0;
*(double *)&time_offset = (double)(int)SDL_GetTicks(v5, v4) * 0.001 - 0.72;
music_started = 1;
}
audioplayer_set_next(*(_QWORD *)(a1 + 112), "music/Goto80_gopho_level4.ogg");
}
v10 = *(const char **)(*(_QWORD *)(a1 + 112) + 16LL);
v11 = "music/Goto80_gopho_level4.ogg";
v12 = 30LL;
do
{
if ( !v12 )
break;
v8 = *v10 < (unsigned int)*v11;
v9 = *v10++ == *v11++;
--v12;
}
while ( v9 );
result = (!v8 && !v9) - v8;
if ( !result )
result = ingame_level4_setup(a1, v10);
return result;
}

canonical_decompiled_code:
char __fastcall func0(__int64 a1)
{
bool v1; // cf
bool v2; // zf
const char *v4; // rsi
const char *v5; // rdi
__int64 v6; // rcx
char v7; // al
bool v8; // cf
bool v9; // zf
const char *v10; // rsi
const char *v11; // rdi
__int64 v12; // rcx
char result; // al

v4 = *(const char **)(*(_QWORD *)(a1 + 112) + 16LL);
v5 = "music/Goto80_gopho_level3.ogg";
v6 = 30LL;
do
{
if ( !v6 )
break;
v1 = *v4 < (unsigned int)*v5;
v2 = *v4++ == *v5++;
--v6;
}
while ( v2 );
v7 = (!v1 && !v2) - v1;
v8 = 0;
v9 = v7 == 0;
if ( !v7 )
{
if ( !music_started )
{
*(_QWORD *)(a1 + 176) = mechant_regeneration_type_level3_0;
*(double *)&time_offset = (double)(int)SDL_GetTicks(v5, v4) * 0.001 - 0.72;
music_started = 1;
}
audioplayer_set_next(*(_QWORD *)(a1 + 112), "music/Goto80_gopho_level4.ogg");
}
v10 = *(const char **)(*(_QWORD *)(a1 + 112) + 16LL);
v11 = "music/Goto80_gopho_level4.ogg";
v12 = 30LL;
do
{
if ( !v12 )
break;
v8 = *v10 < (unsigned int)*v11;
v9 = *v10++ == *v11++;
--v12;
}
while ( v9 );
result = (!v8 && !v9) - v8;
if ( !result )
result = ingame_level4_setup(a1, v10);
return result;
}

original_code:
void ingame_level3_update(Game* game,int dt){
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level3.ogg")){
  if(!music_started){
   int mechant_regeneration_type_level3(){
    return rand()%2;
   }
   game->mechant_regeneration_type=mechant_regeneration_type_level3;
   time_offset=SDL_GetTicks()*0.001-.960*3./4.;
   music_started=1;
  }
  audioplayer_set_next(game->audio,"music/Goto80_gopho_level4.ogg");
 }
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level4.ogg")){
  ingame_level4_setup(game);
 }
}

canonical_original_code:
void ingame_level3_update(struct Game *game, int dt){
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level3.ogg")){
  if(!music_started){
   int mechant_regeneration_type_level3(){
    return rand()%2;
   }
   game->mechant_regeneration_type=mechant_regeneration_type_level3;
   time_offset=SDL_GetTicks()*0.001-.960*3./4.;
   music_started=1;
  }
  audioplayer_set_next(game->audio,"music/Goto80_gopho_level4.ogg");
 }
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level4.ogg")){
  ingame_level4_setup(game);
 }
}

variable_types: dt int

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

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