usage

decompiled_code:
void __fastcall __noreturn usage(const char *a1)
{
printf("Usage: %s [OPTION...] FILE [song_number]\n", a1);
PrefsPrintUsage();
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(const char *a1)
{
printf("Usage: %s [OPTION...] FILE [song_number]\n", a1);
PrefsPrintUsage();
exit(0);
}

original_code:
static void usage(const char *prg_name)
{
    printf("Usage: %s [OPTION...] FILE [song_number]\n", prg_name);
    PrefsPrintUsage();
    exit(0);
}

canonical_original_code:
static void usage(char *prg_name)
{
    printf("Usage: %s [OPTION...] FILE [song_number]\n", prg_name);
    PrefsPrintUsage();
    exit(0);
}


repo: robn/tinysid

decompiled_code:
__suseconds_t GetTicks_usec()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v1, 0LL);
return v1.tv_usec + 1000000 * v1.tv_sec;
}

canonical_decompiled_code:
__suseconds_t func2()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v1, 0LL);
return v1.tv_usec + 1000000 * v1.tv_sec;
}

original_code:
uint64 GetTicks_usec()
{
    struct timeval t;
    gettimeofday(&t, ((void *)0));
    return t.tv_sec * 1000000 + t.tv_usec;
}

canonical_original_code:
unsigned long GetTicks_usec()
{
    struct timeval t;
    gettimeofday(&t, ((void *)0));
    return t.tv_sec * 1000000 + t.tv_usec;
}

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

return_type: unsigned long


decompiled_code:
int __fastcall Delay_usec(unsigned int a1)
{
int *v1; // rbx
int result; // eax
struct timeval v3; // [rsp+0h] [rbp-18h] BYREF

v3.tv_sec = 0LL;
v3.tv_usec = a1;
v1 = _errno_location();
do
{
*v1 = 0;
result = select(0, 0LL, 0LL, 0LL, &v3);
}
while ( result && *v1 == 4 );
return result;
}

canonical_decompiled_code:
int __fastcall func3(unsigned int a1)
{
int *v1; // rbx
int result; // eax
struct timeval v3; // [rsp+0h] [rbp-18h] BYREF

v3.tv_sec = 0LL;
v3.tv_usec = a1;
v1 = _errno_location();
do
{
*v1 = 0;
result = select(0, 0LL, 0LL, 0LL, &v3);
}
while ( result && *v1 == 4 );
return result;
}

original_code:
void Delay_usec(uint32 usec)
{
    int was_error;
    struct timeval tv;
    tv.tv_sec = 0;
    tv.tv_usec = usec;
    do {
        (*__errno_location ()) = 0;
        was_error = select(0, ((void *)0), ((void *)0), ((void *)0), &tv);
    } while (was_error && ((*__errno_location ()) == 4));
}

canonical_original_code:
void Delay_usec(unsigned int usec)
{
    int was_error;
    struct timeval tv;
    tv.tv_sec = 0;
    tv.tv_usec = usec;
    do {
        (*__errno_location ()) = 0;
        was_error = select(0, ((void *)0), ((void *)0), ((void *)0), &tv);
    } while (was_error && ((*__errno_location ()) == 4));
}

variable_types:
usec
unsigned int

return_type: void

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


AddPrefsDefaults

decompiled_code:
__int64 AddPrefsDefaults()
{
PrefsAddString("victype", "6569");
PrefsAddString("sidtype", "6581");
PrefsAddInt32("samplerate", 44100LL);
PrefsAddBool("audio16bit", 1LL);
PrefsAddBool("stereo", 1LL);
PrefsAddBool("filters", 1LL);
PrefsAddBool("dualsid", 0LL);
PrefsAddInt32("audioeffect", 2LL);
PrefsAddInt32("revdelay", 125LL);
PrefsAddInt32("revfeedback", 80LL);
PrefsAddInt32("volume", 256LL);
PrefsAddInt32("v1volume", 256LL);
PrefsAddInt32("v1pan", 4294967232LL);
PrefsAddInt32("v2volume", 256LL);
PrefsAddInt32("v2pan", 0LL);
PrefsAddInt32("v3volume", 256LL);
PrefsAddInt32("v3pan", 64LL);
PrefsAddInt32("v4volume", 256LL);
PrefsAddInt32("v4pan", 0LL);
PrefsAddInt32("dualsep", 128LL);
return PrefsAddInt32("speed", 100LL);
}

canonical_decompiled_code:
__int64 func0()
{
PrefsAddString("victype", "6569");
PrefsAddString("sidtype", "6581");
PrefsAddInt32("samplerate", 44100LL);
PrefsAddBool("audio16bit", 1LL);
PrefsAddBool("stereo", 1LL);
PrefsAddBool("filters", 1LL);
PrefsAddBool("dualsid", 0LL);
PrefsAddInt32("audioeffect", 2LL);
PrefsAddInt32("revdelay", 125LL);
PrefsAddInt32("revfeedback", 80LL);
PrefsAddInt32("volume", 256LL);
PrefsAddInt32("v1volume", 256LL);
PrefsAddInt32("v1pan", 4294967232LL);
PrefsAddInt32("v2volume", 256LL);
PrefsAddInt32("v2pan", 0LL);
PrefsAddInt32("v3volume", 256LL);
PrefsAddInt32("v3pan", 64LL);
PrefsAddInt32("v4volume", 256LL);
PrefsAddInt32("v4pan", 0LL);
PrefsAddInt32("dualsep", 128LL);
return PrefsAddInt32("speed", 100LL);
}

original_code:
void AddPrefsDefaults()
{
    PrefsAddString("victype", "6569");
    PrefsAddString("sidtype", "6581");
    PrefsAddInt32("samplerate", 44100);
    PrefsAddBool("audio16bit", true);
    PrefsAddBool("stereo", true);
    PrefsAddBool("filters", true);
    PrefsAddBool("dualsid", false);
    PrefsAddInt32("audioeffect", 2);
    PrefsAddInt32("revdelay", 125);
    PrefsAddInt32("revfeedback", 0x50);
    PrefsAddInt32("volume", 0x100);
    PrefsAddInt32("v1volume", 0x100);
    PrefsAddInt32("v1pan", -0x40);
    PrefsAddInt32("v2volume", 0x100);
    PrefsAddInt32("v2pan", 0);
    PrefsAddInt32("v3volume", 0x100);
    PrefsAddInt32("v3pan", 0x40);
    PrefsAddInt32("v4volume", 0x100);
    PrefsAddInt32("v4pan", 0);
    PrefsAddInt32("dualsep", 0x80);
    PrefsAddInt32("speed", 100);
}


decompiled_code:
__int64 ubo_init()
{
if ( ubo_list )
{
free(ubo_list);
ubo_list = 0LL;
}
glGetIntegerv(35376LL, &ubo_maxsize);
console_printf("max uniform size is %i\n", (unsigned int)ubo_maxsize);
glGetIntegerv(35380LL, &ubo_alignment);
console_printf("uniform alignment size is %i\n", (unsigned int)ubo_alignment);
ubo_ok = 1;
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
if ( ubo_list )
{
free(ubo_list);
ubo_list = 0LL;
}
glGetIntegerv(35376LL, &ubo_maxsize);
console_printf("max uniform size is %i\n", (unsigned int)ubo_maxsize);
glGetIntegerv(35380LL, &ubo_alignment);
console_printf("uniform alignment size is %i\n", (unsigned int)ubo_alignment);
ubo_ok = 1;
return 1LL;
}

original_code:
int ubo_init(void){
 if(ubo_list) free(ubo_list);
 ubo_list = 0;
 glGetIntegerv(0x8A30, &ubo_maxsize);
 console_printf("max uniform size is %i\n", ubo_maxsize);
 glGetIntegerv(0x8A34, &ubo_alignment);
 console_printf("uniform alignment size is %i\n", ubo_alignment);
 ubo_ok = 1;
 return 1;
}

canonical_original_code:
int ubo_init(){
 if(ubo_list) free(ubo_list);
 ubo_list = 0;
 glGetIntegerv(0x8A30, &ubo_maxsize);
 console_printf("max uniform size is %i\n", ubo_maxsize);
 glGetIntegerv(0x8A34, &ubo_alignment);
 console_printf("uniform alignment size is %i\n", ubo_alignment);
 ubo_ok = 1;
 return 1;
}

return_type: int


decompiled_code:
__int64 __fastcall ubo_flushData(__int64 a1)
{
unsigned int v1; // ebp
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 4);
result = 0LL;
if ( v1 )
{
states_bindBuffer(35345LL, *(unsigned int *)(a1 + 28));
_glewBufferData(35345LL, v1, *(_QWORD *)(a1 + 16), 35048LL);
*(_DWORD *)(a1 + 4) = 0;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
unsigned int v1; // ebp
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 4);
result = 0LL;
if ( v1 )
{
states_bindBuffer(35345LL, *(unsigned int *)(a1 + 28));
_glewBufferData(35345LL, v1, *(_QWORD *)(a1 + 16), 35048LL);
*(_DWORD *)(a1 + 4) = 0;
result = 1LL;
}
return result;
}

original_code:
char ubo_flushData(ubo_t * u){
 unsigned int place = u->place;
 if(!place) return 0;
 states_bindBuffer(0x8A11, u->id);
 __glewBufferData(0x8A11, place, u->data, 0x88E8);
 u->place = 0;
 return 1;
}

canonical_original_code:
char ubo_flushData(struct ubo_s *u){
 unsigned int place = u->place;
 if(!place) return 0;
 states_bindBuffer(0x8A11, u->id);
 __glewBufferData(0x8A11, place, u->data, 0x88E8);
 u->place = 0;
 return 1;
}

variable_types: struct ubo_s { int myid; unsigned int place; unsigned int size; unsigned char *data; char type; unsigned int id; } *

variable_types:
place
unsigned int

return_type: char


decompiled_code:
__int64 __fastcall ubo_pushData(__int64 a1, unsigned int a2, const void *a3)
{
unsigned int v4; // er13
unsigned int v5; // er12
char *v7; // rax

if ( !a2 )
return 0xFFFFFFFFLL;
if ( !a3 )
return 0xFFFFFFFFLL;
v4 = *(_DWORD *)(a1 + 4);
v5 = ((ubo_alignment + a2 - 1) & -ubo_alignment) + v4;
if ( *(_DWORD *)(a1 + 8) < v5 )
{
v7 = (char *)realloc(*(void **)(a1 + 16), v5);
*(_QWORD *)(a1 + 16) = v7;
*(_DWORD *)(a1 + 8) = v5;
memcpy(&v7[v4], a3, a2);
}
else
{
memcpy((void *)(*(_QWORD *)(a1 + 16) + v4), a3, a2);
}
*(_DWORD *)(a1 + 4) = v5;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int a2, const void *a3)
{
unsigned int v4; // er13
unsigned int v5; // er12
char *v7; // rax

if ( !a2 )
return 0xFFFFFFFFLL;
if ( !a3 )
return 0xFFFFFFFFLL;
v4 = *(_DWORD *)(a1 + 4);
v5 = ((ubo_alignment + a2 - 1) & -ubo_alignment) + v4;
if ( *(_DWORD *)(a1 + 8) < v5 )
{
v7 = (char *)realloc(*(void **)(a1 + 16), v5);
*(_QWORD *)(a1 + 16) = v7;
*(_DWORD *)(a1 + 8) = v5;
memcpy(&v7[v4], a3, a2);
}
else
{
memcpy((void *)(*(_QWORD *)(a1 + 16) + v4), a3, a2);
}
*(_DWORD *)(a1 + 4) = v5;
return v4;
}

original_code:
int ubo_pushData(ubo_t * u, const unsigned int size, const void * data){
 if(!size || !data) return -1;
 unsigned int mysize = (size + ubo_alignment-1) & ~(ubo_alignment-1);
 unsigned int place = u->place;
 unsigned int newsize = place + mysize;
 if(newsize > u->size){
  u->data = realloc(u->data, newsize);
  u->size = newsize;
 }
 memcpy(u->data + place, data, size);
 u->place = newsize;
 return place;
}

canonical_original_code:
int ubo_pushData(struct ubo_s *u, unsigned int size, void *data){
 if(!size || !data) return -1;
 unsigned int mysize = (size + ubo_alignment-1) & ~(ubo_alignment-1);
 unsigned int place = u->place;
 unsigned int newsize = place + mysize;
 if(newsize > u->size){
  u->data = realloc(u->data, newsize);
  u->size = newsize;
 }
 memcpy(u->data + place, data, size);
 u->place = newsize;
 return place;
}

variable_types:
size
unsigned int

variable_types:
data
void *

variable_types:
mysize
unsigned int

variable_types:
newsize
unsigned int

user_defined_types: struct ubo_s { int myid; unsigned int place; unsigned int size; unsigned char *data; char type; unsigned int id; }


decompiled_code:
__int64 __fastcall ubo_pushDataNoAlign(__int64 a1, unsigned int a2, const void *a3)
{
unsigned int v4; // er12
unsigned int v5; // er14
char *v7; // rax

if ( !a2 )
return 0xFFFFFFFFLL;
if ( !a3 )
return 0xFFFFFFFFLL;
v4 = *(_DWORD *)(a1 + 4);
v5 = a2 + v4;
if ( *(_DWORD *)(a1 + 8) < a2 + v4 )
{
v7 = (char *)realloc(*(void **)(a1 + 16), v5);
*(_QWORD *)(a1 + 16) = v7;
*(_DWORD *)(a1 + 8) = v5;
memcpy(&v7[v4], a3, a2);
}
else
{
memcpy((void *)(*(_QWORD *)(a1 + 16) + v4), a3, a2);
}
*(_DWORD *)(a1 + 4) = v5;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2, const void *a3)
{
unsigned int v4; // er12
unsigned int v5; // er14
char *v7; // rax

if ( !a2 )
return 0xFFFFFFFFLL;
if ( !a3 )
return 0xFFFFFFFFLL;
v4 = *(_DWORD *)(a1 + 4);
v5 = a2 + v4;
if ( *(_DWORD *)(a1 + 8) < a2 + v4 )
{
v7 = (char *)realloc(*(void **)(a1 + 16), v5);
*(_QWORD *)(a1 + 16) = v7;
*(_DWORD *)(a1 + 8) = v5;
memcpy(&v7[v4], a3, a2);
}
else
{
memcpy((void *)(*(_QWORD *)(a1 + 16) + v4), a3, a2);
}
*(_DWORD *)(a1 + 4) = v5;
return v4;
}

original_code:
int ubo_pushDataNoAlign(ubo_t * u, const unsigned int size, const void * data){
 if(!size || !data) return -1;
 unsigned int place = u->place;
 unsigned int newsize = place + size;
 if(newsize > u->size){
  u->data = realloc(u->data, newsize);
  u->size = newsize;
 }
 memcpy(u->data + place, data, size);
 u->place = newsize;
 return place;
}

canonical_original_code:
int ubo_pushDataNoAlign(struct ubo_s *u, unsigned int size, void *data){
 if(!size || !data) return -1;
 unsigned int place = u->place;
 unsigned int newsize = place + size;
 if(newsize > u->size){
  u->data = realloc(u->data, newsize);
  u->size = newsize;
 }
 memcpy(u->data + place, data, size);
 u->place = newsize;
 return place;
}


decompiled_code:
__int64 __fastcall ubo_alignData(__int64 a1)
{
unsigned int v1; // ebp

v1 = -ubo_alignment & (ubo_alignment + *(_DWORD *)(a1 + 4) - 1);
if ( *(_DWORD *)(a1 + 8) < v1 )
{
*(_QWORD *)(a1 + 16) = realloc(*(void **)(a1 + 16), v1);
*(_DWORD *)(a1 + 8) = v1;
}
*(_DWORD *)(a1 + 4) = v1;
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
unsigned int v1; // ebp

v1 = -ubo_alignment & (ubo_alignment + *(_DWORD *)(a1 + 4) - 1);
if ( *(_DWORD *)(a1 + 8) < v1 )
{
*(_QWORD *)(a1 + 16) = realloc(*(void **)(a1 + 16), v1);
*(_DWORD *)(a1 + 8) = v1;
}
*(_DWORD *)(a1 + 4) = v1;
return v1;
}

original_code:
unsigned int ubo_alignData(ubo_t * u){
 unsigned int mysize = (u->place + ubo_alignment-1) & ~(ubo_alignment-1);
 if(mysize > u->size){
  u->data = realloc(u->data, mysize);
  u->size = mysize;
 }
 u->place = mysize;
 return mysize;
}

canonical_original_code:
unsigned int ubo_alignData(struct ubo_s *u){
 unsigned int mysize = (u->place + ubo_alignment-1) & ~(ubo_alignment-1);
 if(mysize > u->size){
  u->data = realloc(u->data, mysize);
  u->size = mysize;
 }
 u->place = mysize;
 return mysize;
}

return_type: unsigned int


decompiled_code:
__int64 __fastcall ubo_halfData(__int64 a1)
{
unsigned int v1; // ebp

v1 = *(_DWORD *)(a1 + 8) >> 1;
*(_DWORD *)(a1 + 8) = v1;
*(_QWORD *)(a1 + 16) = realloc(*(void **)(a1 + 16), v1);
return v1;
}

original_code:
unsigned int ubo_halfData(ubo_t *u){
 unsigned int newsize = u->size/2;
 u->size = newsize;
 u->data = realloc(u->data, newsize);
 return newsize;
}

canonical_original_code:
unsigned int ubo_halfData(struct ubo_s *u){
 unsigned int newsize = u->size/2;
 u->size = newsize;
 u->data = realloc(u->data, newsize);
 return newsize;
}


decompiled_code:
__int64 __fastcall ubo_sizeData(__int64 a1, unsigned int a2)
{
*(_DWORD *)(a1 + 8) = a2;
*(_QWORD *)(a1 + 16) = realloc(*(void **)(a1 + 16), a2);
return a2;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned int a2)
{
*(_DWORD *)(a1 + 8) = a2;
*(_QWORD *)(a1 + 16) = realloc(*(void **)(a1 + 16), a2);
return a2;
}

original_code:
unsigned int ubo_sizeData(ubo_t *u, const unsigned int newsize){
 u->size = newsize;
 u->data = realloc(u->data, newsize);
 return newsize;
}

canonical_original_code:
unsigned int ubo_sizeData(struct ubo_s *u, unsigned int newsize){
 u->size = newsize;
 u->data = realloc(u->data, newsize);
 return newsize;
}


decompiled_code:
__int64 __fastcall ubo_pruneData(__int64 a1)
{
unsigned int v1; // ebp

v1 = *(_DWORD *)(a1 + 4);
*(_DWORD *)(a1 + 8) = v1;
*(_QWORD *)(a1 + 16) = realloc(*(void **)(a1 + 16), v1);
return v1;
}

original_code:
unsigned int ubo_pruneData(ubo_t *u){
 unsigned int newsize = u->place;
 u->size = newsize;
 u->data = realloc(u->data, newsize);
 return newsize;
}

canonical_original_code:
unsigned int ubo_pruneData(struct ubo_s *u){
 unsigned int newsize = u->place;
 u->size = newsize;
 u->data = realloc(u->data, newsize);
 return newsize;
}


decompiled_code:
__int64 __fastcall ubo_delete(int a1)
{
char *v1; // rbx
__int64 result; // rax
int v3; // eax
__int64 v4; // rdx
_BYTE *v5; // r10
char v6; // bl
int v7; // edi
int v8; // er9

v1 = (char *)ubo_list + 32 * (unsigned __int16)a1;
result = 0LL;
if ( *(_DWORD *)v1 != a1 )
return result;
_glewDeleteBuffers(1LL, v1 + 28);
*(_QWORD *)v1 = 0LL;
*((_QWORD *)v1 + 1) = 0LL;
*((_QWORD *)v1 + 2) = 0LL;
*((_QWORD *)v1 + 3) = 0LL;
if ( ubo_arrayfirstopen > (unsigned __int16)a1 )
ubo_arrayfirstopen = (unsigned __int16)a1;
v3 = ubo_arraylasttaken;
if ( ubo_arraylasttaken <= 0 )
return 1LL;
v4 = 32LL * ubo_arraylasttaken;
v5 = (char *)ubo_list + v4 + 24;
v6 = 0;
v7 = ubo_arraylasttaken & 7;
if ( (ubo_arraylasttaken & 7) == 0 )
{
LABEL_26:
while ( !*v5 )
{
v8 = --v3;
v6 = 1;
if ( *(v5 - 32) )
break;
v3 = v8 - 1;
if ( *(v5 - 64) )
break;
v3 = v8 - 2;
if ( *(v5 - 96) )
break;
v3 = v8 - 3;
if ( *(v5 - 128) )
break;
v3 = v8 - 4;
if ( *(v5 - 160) )
break;
v3 = v8 - 5;
if ( *(v5 - 192) )
break;
v3 = v8 - 6;
if ( *(v5 - 224) )
break;
v5 -= 256;
v3 = v8 - 7;
if ( v8 == 7 )
goto LABEL_35;
}
goto LABEL_36;
}
if ( v7 != 1 )
{
if ( v7 != 2 )
{
if ( v7 != 3 )
{
if ( v7 != 4 )
{
if ( v7 != 5 )
{
if ( v7 != 6 )
{
if ( *v5 )
goto LABEL_36;
v3 = ubo_arraylasttaken - 1;
v5 = (char *)ubo_list + v4 - 8;
v6 = 1;
}
if ( *v5 )
goto LABEL_36;
--v3;
v5 -= 32;
v6 = 1;
}
if ( *v5 )
goto LABEL_36;
--v3;
v5 -= 32;
v6 = 1;
}
if ( *v5 )
goto LABEL_36;
--v3;
v5 -= 32;
v6 = 1;
}
if ( *v5 )
goto LABEL_36;
--v3;
v5 -= 32;
v6 = 1;
}
if ( !*v5 )
{
--v3;
v5 -= 32;
v6 = 1;
goto LABEL_24;
}
LABEL_36:
if ( v6 )
ubo_arraylasttaken = v3;
return 1LL;
}
LABEL_24:
if ( *v5 )
goto LABEL_36;
v5 -= 32;
v6 = 1;
if ( --v3 )
goto LABEL_26;
LABEL_35:
ubo_arraylasttaken = 0;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
char *v1; // rbx
__int64 result; // rax
int v3; // eax
__int64 v4; // rdx
_BYTE *v5; // r10
char v6; // bl
int v7; // edi
int v8; // er9

v1 = (char *)ubo_list + 32 * (unsigned __int16)a1;
result = 0LL;
if ( *(_DWORD *)v1 != a1 )
return result;
_glewDeleteBuffers(1LL, v1 + 28);
*(_QWORD *)v1 = 0LL;
*((_QWORD *)v1 + 1) = 0LL;
*((_QWORD *)v1 + 2) = 0LL;
*((_QWORD *)v1 + 3) = 0LL;
if ( ubo_arrayfirstopen > (unsigned __int16)a1 )
ubo_arrayfirstopen = (unsigned __int16)a1;
v3 = ubo_arraylasttaken;
if ( ubo_arraylasttaken <= 0 )
return 1LL;
v4 = 32LL * ubo_arraylasttaken;
v5 = (char *)ubo_list + v4 + 24;
v6 = 0;
v7 = ubo_arraylasttaken & 7;
if ( (ubo_arraylasttaken & 7) == 0 )
{
LABEL_26:
while ( !*v5 )
{
v8 = --v3;
v6 = 1;
if ( *(v5 - 32) )
break;
v3 = v8 - 1;
if ( *(v5 - 64) )
break;
v3 = v8 - 2;
if ( *(v5 - 96) )
break;
v3 = v8 - 3;
if ( *(v5 - 128) )
break;
v3 = v8 - 4;
if ( *(v5 - 160) )
break;
v3 = v8 - 5;
if ( *(v5 - 192) )
break;
v3 = v8 - 6;
if ( *(v5 - 224) )
break;
v5 -= 256;
v3 = v8 - 7;
if ( v8 == 7 )
goto LABEL_35;
}
goto LABEL_36;
}
if ( v7 != 1 )
{
if ( v7 != 2 )
{
if ( v7 != 3 )
{
if ( v7 != 4 )
{
if ( v7 != 5 )
{
if ( v7 != 6 )
{
if ( *v5 )
goto LABEL_36;
v3 = ubo_arraylasttaken - 1;
v5 = (char *)ubo_list + v4 - 8;
v6 = 1;
}
if ( *v5 )
goto LABEL_36;
--v3;
v5 -= 32;
v6 = 1;
}
if ( *v5 )
goto LABEL_36;
--v3;
v5 -= 32;
v6 = 1;
}
if ( *v5 )
goto LABEL_36;
--v3;
v5 -= 32;
v6 = 1;
}
if ( *v5 )
goto LABEL_36;
--v3;
v5 -= 32;
v6 = 1;
}
if ( !*v5 )
{
--v3;
v5 -= 32;
v6 = 1;
goto LABEL_24;
}
LABEL_36:
if ( v6 )
ubo_arraylasttaken = v3;
return 1LL;
}
LABEL_24:
if ( *v5 )
goto LABEL_36;
v5 -= 32;
v6 = 1;
if ( --v3 )
goto LABEL_26;
LABEL_35:
ubo_arraylasttaken = 0;
return 1LL;
}

original_code:
int ubo_delete(const int id){
 int index = (id & 0xFFFF);
 ubo_t * ubo = &ubo_list[index];
 if(ubo->myid != id) return 0;
 __glewDeleteBuffers(1, &ubo->id);
 memset(ubo, 0, sizeof(ubo_t));
 if(index < ubo_arrayfirstopen) ubo_arrayfirstopen = index;
 for(; ubo_arraylasttaken > 0 && !ubo_list[ubo_arraylasttaken].type; ubo_arraylasttaken--);
 return 1;
}

canonical_original_code:
int ubo_delete(int id){
 int index = (id & 0xFFFF);
 struct ubo_s *ubo = &ubo_list[index];
 if(ubo->myid != id) return 0;
 __glewDeleteBuffers(1, &ubo->id);
 memset(ubo, 0, sizeof(ubo_t));
 if(index < ubo_arrayfirstopen) ubo_arrayfirstopen = index;
 for(; ubo_arraylasttaken > 0 && !ubo_list[ubo_arraylasttaken].type; ubo_arraylasttaken--);
 return 1;
}

variable_types: id int

variable_types: index int


decompiled_code:
char *__fastcall ubo_returnById(int a1)
{
char *result; // rax

result = (char *)ubo_list + 32 * (unsigned __int16)a1;
if ( !result[24] )
return 0LL;
if ( *(_DWORD *)result != a1 )
result = 0LL;
return result;
}

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

result = (char *)ubo_list + 32 * (unsigned __int16)a1;
if ( !result[24] )
return 0LL;
if ( *(_DWORD *)result != a1 )
result = 0LL;
return result;
}

original_code:
ubo_t * ubo_returnById(int id){
 int index = (id & 0xFFFF);
 ubo_t * ubo = &ubo_list[index];
 if(!ubo->type) return 0;
 if(ubo->myid == id) return ubo;
 return 0;
}

canonical_original_code:
struct ubo_s *ubo_returnById(int id){
 int index = (id & 0xFFFF);
 struct ubo_s *ubo = &ubo_list[index];
 if(!ubo->type) return 0;
 if(ubo->myid == id) return ubo;
 return 0;
}

return_type: struct ubo_s { int myid; unsigned int place; unsigned int size; unsigned char *data; char type; unsigned int id; } *


decompiled_code:
__int64 __fastcall ubo_addRINT(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int128 a7, __int128 a8)
{
int v8; // eax
int v9; // edi
char *v10; // rdx
char v11; // cl
int v12; // er8
int v13; // er10
int v14; // er11
__m128i *v15; // rdi
unsigned int v16; // esi

++ubo_count;
v8 = ubo_arrayfirstopen;
v9 = ubo_arraysize;
if ( ubo_arrayfirstopen >= ubo_arraysize )
goto LABEL_36;
v10 = (char *)ubo_list + 32 * ubo_arrayfirstopen;
v11 = 0;
v12 = ((_BYTE)ubo_arraysize - (_BYTE)ubo_arrayfirstopen) & 7;
if ( (((_BYTE)ubo_arraysize - (_BYTE)ubo_arrayfirstopen) & 7) == 0 )
{
LABEL_23:
while ( v10[24] )
{
v13 = ++v8;
v11 = 1;
if ( !v10[56] )
break;
v8 = v13 + 1;
if ( !v10[88] )
break;
v8 = v13 + 2;
if ( !v10[120] )
break;
v8 = v13 + 3;
if ( !v10[152] )
break;
v8 = v13 + 4;
if ( !v10[184] )
break;
v8 = v13 + 5;
if ( !v10[216] )
break;
v8 = v13 + 6;
if ( !v10[248] )
break;
v8 = v13 + 7;
v10 += 256;
if ( v13 + 7 == ubo_arraysize )
goto LABEL_32;
}
goto LABEL_34;
}
switch ( v12 )
{
case 1:
goto LABEL_21;
case 2:
LABEL_19:
if ( v10[24] )
{
++v8;
v10 += 32;
v11 = 1;
LABEL_21:
if ( v10[24] )
{
++v8;
v10 += 32;
v11 = 1;
if ( v8 != ubo_arraysize )
goto LABEL_23;
LABEL_32:
ubo_arrayfirstopen = ubo_arraysize;
goto LABEL_33;
}
goto LABEL_34;
}
goto LABEL_34;
case 3:
LABEL_17:
if ( !v10[24] )
goto LABEL_34;
++v8;
v10 += 32;
v11 = 1;
goto LABEL_19;
case 4:
LABEL_15:
if ( !v10[24] )
goto LABEL_34;
++v8;
v10 += 32;
v11 = 1;
goto LABEL_17;
case 5:
LABEL_13:
if ( !v10[24] )
goto LABEL_34;
++v8;
v10 += 32;
v11 = 1;
goto LABEL_15;
}
if ( v12 != 6 )
{
if ( !v10[24] )
goto LABEL_34;
v8 = ubo_arrayfirstopen + 1;
v10 += 32;
v11 = 1;
}
if ( v10[24] )
{
++v8;
v10 += 32;
v11 = 1;
goto LABEL_13;
}
LABEL_34:
if ( v11 )
ubo_arrayfirstopen = v8;
LABEL_36:
if ( ubo_arraysize == v8 )
{
LABEL_33:
++ubo_arraysize;
ubo_list = realloc(ubo_list, 32LL * (v9 + 1));
}
v14 = ubo_arrayfirstopen;
v15 = (__m128i *)((char *)ubo_list + 32 * ubo_arrayfirstopen);
*v15 = _mm_loadu_si128((const __m128i *)&a7);
v15[1] = _mm_loadu_si128((const __m128i *)&a8);
v16 = v14 | (ubo_count << 16);
v15->m128i_i32[0] = v16;
if ( v14 > ubo_arraylasttaken )
ubo_arraylasttaken = v14;
return v16;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int128 a7, __int128 a8)
{
int v8; // eax
int v9; // edi
char *v10; // rdx
char v11; // cl
int v12; // er8
int v13; // er10
int v14; // er11
__m128i *v15; // rdi
unsigned int v16; // esi

++ubo_count;
v8 = ubo_arrayfirstopen;
v9 = ubo_arraysize;
if ( ubo_arrayfirstopen >= ubo_arraysize )
goto LABEL_36;
v10 = (char *)ubo_list + 32 * ubo_arrayfirstopen;
v11 = 0;
v12 = ((_BYTE)ubo_arraysize - (_BYTE)ubo_arrayfirstopen) & 7;
if ( (((_BYTE)ubo_arraysize - (_BYTE)ubo_arrayfirstopen) & 7) == 0 )
{
LABEL_23:
while ( v10[24] )
{
v13 = ++v8;
v11 = 1;
if ( !v10[56] )
break;
v8 = v13 + 1;
if ( !v10[88] )
break;
v8 = v13 + 2;
if ( !v10[120] )
break;
v8 = v13 + 3;
if ( !v10[152] )
break;
v8 = v13 + 4;
if ( !v10[184] )
break;
v8 = v13 + 5;
if ( !v10[216] )
break;
v8 = v13 + 6;
if ( !v10[248] )
break;
v8 = v13 + 7;
v10 += 256;
if ( v13 + 7 == ubo_arraysize )
goto LABEL_32;
}
goto LABEL_34;
}
switch ( v12 )
{
case 1:
goto LABEL_21;
case 2:
LABEL_19:
if ( v10[24] )
{
++v8;
v10 += 32;
v11 = 1;
LABEL_21:
if ( v10[24] )
{
++v8;
v10 += 32;
v11 = 1;
if ( v8 != ubo_arraysize )
goto LABEL_23;
LABEL_32:
ubo_arrayfirstopen = ubo_arraysize;
goto LABEL_33;
}
goto LABEL_34;
}
goto LABEL_34;
case 3:
LABEL_17:
if ( !v10[24] )
goto LABEL_34;
++v8;
v10 += 32;
v11 = 1;
goto LABEL_19;
case 4:
LABEL_15:
if ( !v10[24] )
goto LABEL_34;
++v8;
v10 += 32;
v11 = 1;
goto LABEL_17;
case 5:
LABEL_13:
if ( !v10[24] )
goto LABEL_34;
++v8;
v10 += 32;
v11 = 1;
goto LABEL_15;
}
if ( v12 != 6 )
{
if ( !v10[24] )
goto LABEL_34;
v8 = ubo_arrayfirstopen + 1;
v10 += 32;
v11 = 1;
}
if ( v10[24] )
{
++v8;
v10 += 32;
v11 = 1;
goto LABEL_13;
}
LABEL_34:
if ( v11 )
ubo_arrayfirstopen = v8;
LABEL_36:
if ( ubo_arraysize == v8 )
{
LABEL_33:
++ubo_arraysize;
ubo_list = realloc(ubo_list, 32LL * (v9 + 1));
}
v14 = ubo_arrayfirstopen;
v15 = (__m128i *)((char *)ubo_list + 32 * ubo_arrayfirstopen);
*v15 = _mm_loadu_si128((const __m128i *)&a7);
v15[1] = _mm_loadu_si128((const __m128i *)&a8);
v16 = v14 | (ubo_count << 16);
v15->m128i_i32[0] = v16;
if ( v14 > ubo_arraylasttaken )
ubo_arraylasttaken = v14;
return v16;
}

original_code:
int ubo_addRINT(ubo_t ubo){
 ubo_count++;
 for(; ubo_arrayfirstopen < ubo_arraysize && ubo_list[ubo_arrayfirstopen].type; ubo_arrayfirstopen++);
 if(ubo_arrayfirstopen == ubo_arraysize){
  ubo_arraysize++;
  ubo_list = realloc(ubo_list, ubo_arraysize * sizeof(ubo_t));
 }
 ubo_list[ubo_arrayfirstopen] = ubo;
 int returnid = (ubo_count << 16) | ubo_arrayfirstopen;
 ubo_list[ubo_arrayfirstopen].myid = returnid;
 if(ubo_arraylasttaken < ubo_arrayfirstopen) ubo_arraylasttaken = ubo_arrayfirstopen;
 return returnid;
}

canonical_original_code:
int ubo_addRINT(struct ubo_s ubo){
 ubo_count++;
 for(; ubo_arrayfirstopen < ubo_arraysize && ubo_list[ubo_arrayfirstopen].type; ubo_arrayfirstopen++);
 if(ubo_arrayfirstopen == ubo_arraysize){
  ubo_arraysize++;
  ubo_list = realloc(ubo_list, ubo_arraysize * sizeof(ubo_t));
 }
 ubo_list[ubo_arrayfirstopen] = ubo;
 int returnid = (ubo_count << 16) | ubo_arrayfirstopen;
 ubo_list[ubo_arrayfirstopen].myid = returnid;
 if(ubo_arraylasttaken < ubo_arrayfirstopen) ubo_arraylasttaken = ubo_arrayfirstopen;
 return returnid;
}

variable_types: struct ubo_s { int myid; unsigned int place; unsigned int size; unsigned char *data; char type; unsigned int id; }

variable_types: returnid int


decompiled_code:
__int64 __fastcall ubo_createAndAddRINT(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
__int64 v3; // rcx
__int64 v4; // r8
__int64 v5; // r9
__m128i v7[2]; // [rsp+0h] [rbp-28h] BYREF

ubo_create(v7);
return ubo_addRINT((__int64)v7, a2, v2, v3, v4, v5, *(_OWORD *)v7, *(_OWORD *)&v7[1]);
}

original_code:
int ubo_createAndAddRINT(void){
 return ubo_addRINT(ubo_create());
}

canonical_original_code:
int ubo_createAndAddRINT(){
 return ubo_addRINT(ubo_create());
}


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

result = (unsigned int)ubo_arraylasttaken;
if ( ubo_arraylasttaken + 1 != ubo_arraysize )
{
ubo_arraysize = ubo_arraylasttaken + 1;
result = (unsigned __int64)realloc(ubo_list, 32LL * (ubo_arraylasttaken + 1));
ubo_list = (void *)result;
}
return result;
}

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

result = (unsigned int)ubo_arraylasttaken;
if ( ubo_arraylasttaken + 1 != ubo_arraysize )
{
ubo_arraysize = ubo_arraylasttaken + 1;
result = (unsigned __int64)realloc(ubo_list, 32LL * (ubo_arraylasttaken + 1));
ubo_list = (void *)result;
}
return result;
}

original_code:
void ubo_pruneList(void){
 if(ubo_arraysize == ubo_arraylasttaken+1) return;
 ubo_arraysize = ubo_arraylasttaken+1;
 ubo_list = realloc(ubo_list, ubo_arraysize * sizeof(ubo_t));
}

canonical_original_code:
void ubo_pruneList(){
 if(ubo_arraysize == ubo_arraylasttaken+1) return;
 ubo_arraysize = ubo_arraylasttaken+1;
 ubo_list = realloc(ubo_list, ubo_arraysize * sizeof(ubo_t));
}


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
double v3; // r12
int i; // ebp
double v5; // rbx
double v6; // [rsp+8h] [rbp-30h]
double v7; // [rsp+10h] [rbp-28h]

cvar_init(argc, argv, envp);
if ( !cvar_ok )
{
puts("ERROR initializing cvar system!");
exit(1);
}
puts("Cvar system has initialized correctly");
cvar_register(&cvar_gl_vulkan);
cvar_pset(&cvar_gl_vulkan, "1");
console_init();
glfw_init(800LL, 600LL, 24LL, 1LL);
if ( *((_DWORD *)&cvar_gl_vulkan + 10) )
{
puts("Compiled without vulkan support!, reverting to GL");
cvar_pset(&cvar_gl_vulkan, "0");
if ( !(unsigned int)glInit() )
{
LABEL_6:
initWorldSystem();
if ( worldOK )
console_printf("world has initailized correctly\n");
initGameCodeSystem();
if ( gamecodeOK )
console_printf("gamecode has initailized correctly\n");
else
console_printf("gamecode has failed to load\n");
v3 = glfwGetTime();
v6 = 0.0;
v7 = 0.0;
for ( i = 0; ; ++i )
{
v5 = glfwGetTime();
v7 = v7 + v5 - v3;
if ( v7 > 10.0 )
{
console_printf("%f fps\n", (double)i / v7);
v7 = v7 - 10.0;
v6 = v6 + v5 - v3;
glfw_checkEvent();
i = 0;
if ( v6 * 1000.0 <= 16.66666603088379 )
{
i = 0;
goto LABEL_16;
}
}
else
{
v6 = v6 + v5 - v3;
glfw_checkEvent();
if ( v6 * 1000.0 <= 16.66666603088379 )
goto LABEL_16;
}
do
{
gameCodeTick();
v6 = v6 - 0.01666666666666667;
}
while ( v6 * 1000.0 > 16.66666603088379 );
LABEL_16:
glMainDraw();
v3 = v5;
}
}
}
else if ( !(unsigned int)glInit() )
{
goto LABEL_6;
}
console_printf("opengl has initailized correctly\n");
goto LABEL_6;
}

original_code:
int main(int argc, char *argv[]){
 double to, t;
 unsigned int framecount = 0;
 cvar_init();
 if(!cvar_ok){
  printf("ERROR initializing cvar system!\n");
  exit(1);
 } else {
  printf("Cvar system has initialized correctly\n");
 }
 cvar_register(&cvar_gl_vulkan);
        cvar_pset(&cvar_gl_vulkan, "1");
 console_init();
 glfw_init(800, 600, 24,1);
 if(cvar_gl_vulkan.valueint){
  printf("Compiled without vulkan support!, reverting to GL\n");
         cvar_pset(&cvar_gl_vulkan, "0");
  if(glInit()){
   console_printf("opengl has initailized correctly\n");
  }
 } else {
  if(glInit()){
   console_printf("opengl has initailized correctly\n");
  }
 }
 initWorldSystem();
 if(worldOK){
  console_printf("world has initailized correctly\n");
 }
 initGameCodeSystem();
 if(gamecodeOK){
  console_printf("gamecode has initailized correctly\n");
 } else {
  console_printf("gamecode has failed to load\n");
 }
 to = glfwGetTime();
 double timesincelastfpsupdate = 0;
 double accum = 0;
 while(1){
  t = glfwGetTime();
  double delta = (t-to);
  to = t;
  timesincelastfpsupdate += delta;
  if(timesincelastfpsupdate > 10.000){
   console_printf("%f fps\n", (double)framecount/timesincelastfpsupdate);
   timesincelastfpsupdate -=10.0;
   framecount = 0;
  }
  accum+= delta;
  glfw_checkEvent();
  while(accum*1000.0>1000.0f/60.0f){
   gameCodeTick();
   accum-=(double)1000.0f/60.0f/1000.0;
  }
 glMainDraw();
  framecount++;
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
 double to; double t;
 unsigned int framecount = 0;
 cvar_init();
 if(!cvar_ok){
  printf("ERROR initializing cvar system!\n");
  exit(1);
 } else {
  printf("Cvar system has initialized correctly\n");
 }
 cvar_register(&cvar_gl_vulkan);
        cvar_pset(&cvar_gl_vulkan, "1");
 console_init();
 glfw_init(800, 600, 24,1);
 if(cvar_gl_vulkan.valueint){
  printf("Compiled without vulkan support!, reverting to GL\n");
         cvar_pset(&cvar_gl_vulkan, "0");
  if(glInit()){
   console_printf("opengl has initailized correctly\n");
  }
 } else {
  if(glInit()){
   console_printf("opengl has initailized correctly\n");
  }
 }
 initWorldSystem();
 if(worldOK){
  console_printf("world has initailized correctly\n");
 }
 initGameCodeSystem();
 if(gamecodeOK){
  console_printf("gamecode has initailized correctly\n");
 } else {
  console_printf("gamecode has failed to load\n");
 }
 to = glfwGetTime();
 double timesincelastfpsupdate = 0;
 double accum = 0;
 while(1){
  t = glfwGetTime();
  double delta = (t-to);
  to = t;
  timesincelastfpsupdate += delta;
  if(timesincelastfpsupdate > 10.000){
   console_printf("%f fps\n", (double)framecount/timesincelastfpsupdate);
   timesincelastfpsupdate -=10.0;
   framecount = 0;
  }
  accum+= delta;
  glfw_checkEvent();
  while(accum*1000.0>1000.0f/60.0f){
   gameCodeTick();
   accum-=(double)1000.0f/60.0f/1000.0;
  }
 glMainDraw();
  framecount++;
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: to double

variable_types: t double

variable_types:
framecount
unsigned int

variable_types: timesincelastfpsupdate double

variable_types: accum double

variable_types: delta double


decompiled_code:
__int64 cvar_init()
{
memset(&cvarhashtable, 0, 0xC00uLL);
if ( cvar_list )
{
free(cvar_list);
cvar_list = 0LL;
}
cvar_ok = 1;
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
memset(&cvarhashtable, 0, 0xC00uLL);
if ( cvar_list )
{
free(cvar_list);
cvar_list = 0LL;
}
cvar_ok = 1;
return 1LL;
}

original_code:
int cvar_init(void){
 memset(cvarhashtable, 0, 128 * sizeof(hashbucket_t));
 if(cvar_list) free(cvar_list);
 cvar_list = 0;
 cvar_ok = 1;
 return 1;
}

canonical_original_code:
int cvar_init(){
 memset(cvarhashtable, 0, 128 * sizeof(hashbucket_t));
 if(cvar_list) free(cvar_list);
 cvar_list = 0;
 cvar_ok = 1;
 return 1;
}


decompiled_code:
__int64 __fastcall cvar_findByNameRINT(__int64 a1)
{
return findByNameRINT(a1, &cvarhashtable);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return findByNameRINT(a1, &cvarhashtable);
}

original_code:
int cvar_findByNameRINT(char * name){
 return findByNameRINT(name, cvarhashtable);
}

canonical_original_code:
int cvar_findByNameRINT(char *name){
 return findByNameRINT(name, cvarhashtable);
}

variable_types:
name
char *


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

result = *((_QWORD *)cvar_list + (unsigned __int16)a1);
if ( result )
{
if ( *(_DWORD *)(result + 76) != a1 )
result = 0LL;
}
return result;
}

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

result = *((_QWORD *)cvar_list + (unsigned __int16)a1);
if ( result )
{
if ( *(_DWORD *)(result + 76) != a1 )
result = 0LL;
}
return result;
}

original_code:
cvar_t * cvar_returnById(const int id){
 int index = (id & 0xFFFF);
 cvar_t * c = cvar_list[index];
 if(!c) return 0;
 if(c->myid == id) return c;
 return 0;
}

canonical_original_code:
struct cvar_s *cvar_returnById(int id){
 int index = (id & 0xFFFF);
 struct cvar_s *c = cvar_list[index];
 if(!c) return 0;
 if(c->myid == id) return c;
 return 0;
}

variable_types: struct cvar_s { char type; char *name; char *helptext; char *defaultstring; void (*onchange)(struct cvar_s *c); int valueint; float valuefloat; float valuevector[3]; char *valuestring; unsigned int valuestringlength; int myid; char notdefault; } *


decompiled_code:
__int64 __fastcall cvar_findByNameRPOINT(__int64 a1)
{
int v1; // eax

v1 = findByNameRINT(a1, &cvarhashtable);
return cvar_returnById(v1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
int v1; // eax

v1 = findByNameRINT(a1, &cvarhashtable);
return func2(v1);
}

original_code:
cvar_t * cvar_findByNameRPOINT(char * name){
 return cvar_returnById(findByNameRINT(name, cvarhashtable));
}

canonical_original_code:
struct cvar_s *cvar_findByNameRPOINT(char *name){
 return cvar_returnById(findByNameRINT(name, cvarhashtable));
}

return_type: struct cvar_s { char type; char *name; char *helptext; char *defaultstring; void (*onchange)(struct cvar_s *c); int valueint; float valuefloat; float valuevector[3]; char *valuestring; unsigned int valuestringlength; int myid; char notdefault; } *


decompiled_code:
__int64 __fastcall cvar_unregister(unsigned int a1)
{
__int64 v1; // r12
_DWORD *v2; // rbp
int v4; // er13
__int64 result; // rax
__int64 v6; // rdi
char v7; // r14
void *v8; // rdi
void *v9; // rdi
_QWORD *v10; // rcx
int v11; // edx
int v12; // esi
__int64 v13; // r12
__int64 v14; // r9
char v15; // bp
__int64 v16; // r10
__int64 v17; // r11
int v18; // er12

v1 = (unsigned __int16)a1;
v2 = (_DWORD *)*((_QWORD *)cvar_list + (unsigned __int16)a1);
if ( !v2 )
return 0LL;
v4 = (unsigned __int16)a1;
result = 0LL;
if ( v2[19] == a1 )
{
v6 = *((_QWORD *)v2 + 1);
if ( !v6 )
return 0LL;
v7 = *(_BYTE *)v2;
if ( (*(_BYTE *)v2 & 1) != 0 )
{
if ( *((_QWORD *)v2 + 8) )
{
free(*((void **)v2 + 8));
deleteFromHashTable(*((_QWORD *)v2 + 1), a1, &cvarhashtable);
*(_BYTE *)v2 &= 0xFEu;
if ( (v7 & 2) == 0 )
goto LABEL_12;
}
else
{
deleteFromHashTable(v6, a1, &cvarhashtable);
*(_BYTE *)v2 &= 0xFEu;
if ( (v7 & 2) == 0 )
goto LABEL_12;
}
v8 = (void *)*((_QWORD *)v2 + 1);
if ( v8 )
free(v8);
v9 = (void *)*((_QWORD *)v2 + 2);
if ( v9 )
free(v9);
free(v2);
LABEL_12:
v10 = cvar_list;
*((_QWORD *)cvar_list + v1) = 0LL;
if ( cvar_arrayfirstopen > v4 )
cvar_arrayfirstopen = v4;
v11 = cvar_arraylasttaken;
if ( cvar_arraylasttaken <= 0 )
return 1LL;
v12 = cvar_arraylasttaken - 1;
v13 = cvar_arraylasttaken - 1;
v14 = cvar_arraylasttaken - 2LL - (unsigned int)(cvar_arraylasttaken - 1);
v15 = 0;
v16 = (-1 - (-2 - ((_BYTE)cvar_arraylasttaken - 1))) & 7;
if ( ((-1 - (-2 - ((_BYTE)cvar_arraylasttaken - 1))) & 7) == 0 )
{
LABEL_36:
while ( !v10[v13 + 1] )
{
v11 = v13;
v17 = v13 - 1;
v15 = 1;
if ( v10[v13] )
break;
v11 = v13 - 1;
v18 = v13 - 2;
if ( v10[v17] )
break;
v11 = v18;
if ( v10[v17 - 1] )
break;
v11 = v17 - 2;
if ( v10[v17 - 2] )
break;
v11 = v17 - 3;
if ( v10[v17 - 3] )
break;
v11 = v17 - 4;
if ( v10[v17 - 4] )
break;
v11 = v17 - 5;
if ( v10[v17 - 5] )
break;
v11 = v17 - 6;
v13 = v17 - 7;
if ( v17 - 7 == v14 )
goto LABEL_45;
}
goto LABEL_48;
}
if ( v16 != 1 )
{
if ( v16 != 2 )
{
if ( v16 != 3 )
{
if ( v16 != 4 )
{
if ( v16 != 5 )
{
if ( v16 != 6 )
{
if ( v10[v12 + 1] )
goto LABEL_48;
v11 = cvar_arraylasttaken - 1;
v13 = v12 - 1LL;
v15 = 1;
}
if ( v10[v13 + 1] )
goto LABEL_48;
v11 = v13--;
v15 = 1;
}
if ( v10[v13 + 1] )
goto LABEL_48;
v11 = v13--;
v15 = 1;
}
if ( v10[v13 + 1] )
goto LABEL_48;
v11 = v13--;
v15 = 1;
}
if ( v10[v13 + 1] )
goto LABEL_48;
v11 = v13--;
v15 = 1;
}
if ( v10[v13 + 1] )
goto LABEL_48;
v11 = v13--;
v15 = 1;
}
if ( !v10[v13 + 1] )
{
v11 = v13--;
v15 = 1;
if ( v13 != v14 )
goto LABEL_36;
LABEL_45:
cvar_arraylasttaken = v11;
return 1LL;
}
LABEL_48:
if ( v15 )
cvar_arraylasttaken = v11;
return 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1)
{
__int64 v1; // r12
_DWORD *v2; // rbp
int v4; // er13
__int64 result; // rax
__int64 v6; // rdi
char v7; // r14
void *v8; // rdi
void *v9; // rdi
_QWORD *v10; // rcx
int v11; // edx
int v12; // esi
__int64 v13; // r12
__int64 v14; // r9
char v15; // bp
__int64 v16; // r10
__int64 v17; // r11
int v18; // er12

v1 = (unsigned __int16)a1;
v2 = (_DWORD *)*((_QWORD *)cvar_list + (unsigned __int16)a1);
if ( !v2 )
return 0LL;
v4 = (unsigned __int16)a1;
result = 0LL;
if ( v2[19] == a1 )
{
v6 = *((_QWORD *)v2 + 1);
if ( !v6 )
return 0LL;
v7 = *(_BYTE *)v2;
if ( (*(_BYTE *)v2 & 1) != 0 )
{
if ( *((_QWORD *)v2 + 8) )
{
free(*((void **)v2 + 8));
deleteFromHashTable(*((_QWORD *)v2 + 1), a1, &cvarhashtable);
*(_BYTE *)v2 &= 0xFEu;
if ( (v7 & 2) == 0 )
goto LABEL_12;
}
else
{
deleteFromHashTable(v6, a1, &cvarhashtable);
*(_BYTE *)v2 &= 0xFEu;
if ( (v7 & 2) == 0 )
goto LABEL_12;
}
v8 = (void *)*((_QWORD *)v2 + 1);
if ( v8 )
free(v8);
v9 = (void *)*((_QWORD *)v2 + 2);
if ( v9 )
free(v9);
free(v2);
LABEL_12:
v10 = cvar_list;
*((_QWORD *)cvar_list + v1) = 0LL;
if ( cvar_arrayfirstopen > v4 )
cvar_arrayfirstopen = v4;
v11 = cvar_arraylasttaken;
if ( cvar_arraylasttaken <= 0 )
return 1LL;
v12 = cvar_arraylasttaken - 1;
v13 = cvar_arraylasttaken - 1;
v14 = cvar_arraylasttaken - 2LL - (unsigned int)(cvar_arraylasttaken - 1);
v15 = 0;
v16 = (-1 - (-2 - ((_BYTE)cvar_arraylasttaken - 1))) & 7;
if ( ((-1 - (-2 - ((_BYTE)cvar_arraylasttaken - 1))) & 7) == 0 )
{
LABEL_36:
while ( !v10[v13 + 1] )
{
v11 = v13;
v17 = v13 - 1;
v15 = 1;
if ( v10[v13] )
break;
v11 = v13 - 1;
v18 = v13 - 2;
if ( v10[v17] )
break;
v11 = v18;
if ( v10[v17 - 1] )
break;
v11 = v17 - 2;
if ( v10[v17 - 2] )
break;
v11 = v17 - 3;
if ( v10[v17 - 3] )
break;
v11 = v17 - 4;
if ( v10[v17 - 4] )
break;
v11 = v17 - 5;
if ( v10[v17 - 5] )
break;
v11 = v17 - 6;
v13 = v17 - 7;
if ( v17 - 7 == v14 )
goto LABEL_45;
}
goto LABEL_48;
}
if ( v16 != 1 )
{
if ( v16 != 2 )
{
if ( v16 != 3 )
{
if ( v16 != 4 )
{
if ( v16 != 5 )
{
if ( v16 != 6 )
{
if ( v10[v12 + 1] )
goto LABEL_48;
v11 = cvar_arraylasttaken - 1;
v13 = v12 - 1LL;
v15 = 1;
}
if ( v10[v13 + 1] )
goto LABEL_48;
v11 = v13--;
v15 = 1;
}
if ( v10[v13 + 1] )
goto LABEL_48;
v11 = v13--;
v15 = 1;
}
if ( v10[v13 + 1] )
goto LABEL_48;
v11 = v13--;
v15 = 1;
}
if ( v10[v13 + 1] )
goto LABEL_48;
v11 = v13--;
v15 = 1;
}
if ( v10[v13 + 1] )
goto LABEL_48;
v11 = v13--;
v15 = 1;
}
if ( !v10[v13 + 1] )
{
v11 = v13--;
v15 = 1;
if ( v13 != v14 )
goto LABEL_36;
LABEL_45:
cvar_arraylasttaken = v11;
return 1LL;
}
LABEL_48:
if ( v15 )
cvar_arraylasttaken = v11;
return 1LL;
}
}
return result;
}

original_code:
int cvar_unregister(const int id){
 int index = (id & 0xFFFF);
 cvar_t *c = cvar_list[index];
 if(!c) return 0;
 if(c->myid != id) return 0;
 if(!c->name) return 0;
 char flags = c->type;
 if(!(flags & 1)) return 0;
 if(c->valuestring)free(c->valuestring);
 deleteFromHashTable(c->name, id, cvarhashtable);
 c->type = c->type & (~1);
 if(flags & 2){
  if(c->name)free(c->name);
  if(c->helptext)free(c->helptext);
  free(c);
 }
 cvar_list[index] = 0;
 if(index < cvar_arrayfirstopen) cvar_arrayfirstopen = index;
 for(; cvar_arraylasttaken > 0 && !cvar_list[cvar_arraylasttaken]; cvar_arraylasttaken--);
 return 1;
}

canonical_original_code:
int cvar_unregister(int id){
 int index = (id & 0xFFFF);
 struct cvar_s *c = cvar_list[index];
 if(!c) return 0;
 if(c->myid != id) return 0;
 if(!c->name) return 0;
 char flags = c->type;
 if(!(flags & 1)) return 0;
 if(c->valuestring)free(c->valuestring);
 deleteFromHashTable(c->name, id, cvarhashtable);
 c->type = c->type & (~1);
 if(flags & 2){
  if(c->name)free(c->name);
  if(c->helptext)free(c->helptext);
  free(c);
 }
 cvar_list[index] = 0;
 if(index < cvar_arrayfirstopen) cvar_arrayfirstopen = index;
 for(; cvar_arraylasttaken > 0 && !cvar_list[cvar_arraylasttaken]; cvar_arraylasttaken--);
 return 1;
}

variable_types: flags char

user_defined_types: struct cvar_s { char type; char *name; char *helptext; char *defaultstring; void (*onchange)(struct cvar_s *c); int valueint; float valuefloat; float valuevector[3]; char *valuestring; unsigned int valuestringlength; int myid; char notdefault; }


decompiled_code:
void __fastcall cvar_pset(__int64 a1, const char *a2)
{
int v2; // eax
unsigned int v3; // er12
float v4; // xmm0_4
void (__fastcall *v5)(__int64); // rdx
float v6; // xmm1_4
void (__fastcall *v7)(__int64); // rsi

if ( !a1 )
return;
if ( *(_DWORD *)(a1 + 72) )
{
if ( (unsigned int)string_testEqual(a2, *(_QWORD *)(a1 + 64)) )
return;
v3 = strlen(a2) + 1;
if ( *(_DWORD *)(a1 + 72) == v3 )
goto LABEL_9;
}
else
{
v2 = strlen(a2);
v3 = v2 + 1;
if ( v2 == -1 )
{
v4 = atof(a2);
*(_DWORD *)(a1 + 40) = (int)v4;
*(float *)(a1 + 44) = v4;
string_toVec(a2, a1 + 48, 3LL);
*(_BYTE *)(a1 + 80) = (unsigned int)string_testEqual(a2, *(_QWORD *)(a1 + 24)) == 0;
v5 = *(void (__fastcall **)(__int64))(a1 + 32);
if ( v5 )
v5(a1);
return;
}
}
*(_QWORD *)(a1 + 64) = realloc(*(void **)(a1 + 64), v3);
*(_DWORD *)(a1 + 72) = v3;
LABEL_9:
memcpy(*(void **)(a1 + 64), a2, v3);
v6 = atof(a2);
*(_DWORD *)(a1 + 40) = (int)v6;
*(float *)(a1 + 44) = v6;
string_toVec(a2, a1 + 48, 3LL);
*(_BYTE *)(a1 + 80) = (unsigned int)string_testEqual(a2, *(_QWORD *)(a1 + 24)) == 0;
v7 = *(void (__fastcall **)(__int64))(a1 + 32);
if ( v7 )
v7(a1);
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, const char *a2)
{
int v2; // eax
unsigned int v3; // er12
float v4; // xmm0_4
void (__fastcall *v5)(__int64); // rdx
float v6; // xmm1_4
void (__fastcall *v7)(__int64); // rsi

if ( !a1 )
return;
if ( *(_DWORD *)(a1 + 72) )
{
if ( (unsigned int)string_testEqual(a2, *(_QWORD *)(a1 + 64)) )
return;
v3 = strlen(a2) + 1;
if ( *(_DWORD *)(a1 + 72) == v3 )
goto LABEL_9;
}
else
{
v2 = strlen(a2);
v3 = v2 + 1;
if ( v2 == -1 )
{
v4 = atof(a2);
*(_DWORD *)(a1 + 40) = (int)v4;
*(float *)(a1 + 44) = v4;
string_toVec(a2, a1 + 48, 3LL);
*(_BYTE *)(a1 + 80) = (unsigned int)string_testEqual(a2, *(_QWORD *)(a1 + 24)) == 0;
v5 = *(void (__fastcall **)(__int64))(a1 + 32);
if ( v5 )
v5(a1);
return;
}
}
*(_QWORD *)(a1 + 64) = realloc(*(void **)(a1 + 64), v3);
*(_DWORD *)(a1 + 72) = v3;
LABEL_9:
memcpy(*(void **)(a1 + 64), a2, v3);
v6 = atof(a2);
*(_DWORD *)(a1 + 40) = (int)v6;
*(float *)(a1 + 44) = v6;
string_toVec(a2, a1 + 48, 3LL);
*(_BYTE *)(a1 + 80) = (unsigned int)string_testEqual(a2, *(_QWORD *)(a1 + 24)) == 0;
v7 = *(void (__fastcall **)(__int64))(a1 + 32);
if ( v7 )
v7(a1);
}

original_code:
void cvar_pset(cvar_t *c, const char *value){
 if(!c) return;
 if(c->valuestringlength && string_testEqual(value, c->valuestring)) return;
 unsigned int inlength = strlen(value)+1;
 if(c->valuestringlength != inlength){
  c->valuestring = realloc(c->valuestring, inlength * sizeof(char));
  c->valuestringlength = inlength;
 }
 memcpy(c->valuestring, value, inlength);
 float vf = atof(value);
 c->valueint = (int)vf;
 c->valuefloat = vf;
 string_toVec(value, c->valuevector, 3);
 c->notdefault = !string_testEqual(value, c->defaultstring);
 if(c->onchange)c->onchange(c);
}

canonical_original_code:
void cvar_pset(struct cvar_s *c, char *value){
 if(!c) return;
 if(c->valuestringlength && string_testEqual(value, c->valuestring)) return;
 unsigned int inlength = strlen(value)+1;
 if(c->valuestringlength != inlength){
  c->valuestring = realloc(c->valuestring, inlength * sizeof(char));
  c->valuestringlength = inlength;
 }
 memcpy(c->valuestring, value, inlength);
 float vf = atof(value);
 c->valueint = (int)vf;
 c->valuefloat = vf;
 string_toVec(value, c->valuevector, 3);
 c->notdefault = !string_testEqual(value, c->defaultstring);
 if(c->onchange)c->onchange(c);
}

variable_types:
value
char *

variable_types:
inlength
unsigned int

variable_types: vf float


decompiled_code:
__int64 __fastcall cvar_register(__int64 a1)
{
int v2; // ebp
int v3; // edx
int v4; // edi
char v5; // r9
int v6; // esi
int v7; // ecx
__int64 v8; // r11
__int64 v9; // r11
int v10; // ebp
unsigned int v11; // ebp
char v12; // r12
int v13; // esi

v2 = ++cvar_count;
v3 = cvar_arrayfirstopen;
v4 = cvar_arraysize;
if ( cvar_arrayfirstopen >= cvar_arraysize )
{
LABEL_35:
if ( cvar_arraysize != v3 )
goto LABEL_36;
goto LABEL_45;
}
v5 = 0;
v6 = ((_BYTE)cvar_arraysize + ~(_BYTE)cvar_arrayfirstopen) & 7;
v7 = cvar_arrayfirstopen;
if ( *((_QWORD *)cvar_list + cvar_arrayfirstopen) )
{
v3 = cvar_arrayfirstopen + 1;
v8 = cvar_arrayfirstopen + 1LL;
v5 = 1;
if ( cvar_arraysize <= (int)v8 )
{
LABEL_34:
cvar_arrayfirstopen = v3;
goto LABEL_35;
}
if ( (((_BYTE)cvar_arraysize + ~(_BYTE)cvar_arrayfirstopen) & 7) == 0 )
{
LABEL_25:
while ( 1 )
{
v7 = v8;
if ( !*((_QWORD *)cvar_list + v8) )
goto LABEL_39;
v3 = v8 + 1;
v9 = v8 + 1;
v5 = 1;
v7 = v9;
if ( !*((_QWORD *)cvar_list + v9) )
goto LABEL_39;
v3 = v9 + 1;
v7 = v9 + 1;
if ( !*((_QWORD *)cvar_list + v9 + 1) )
goto LABEL_39;
v3 = v9 + 2;
v7 = v9 + 2;
if ( !*((_QWORD *)cvar_list + v9 + 2) )
goto LABEL_39;
v3 = v9 + 3;
v7 = v9 + 3;
if ( !*((_QWORD *)cvar_list + v9 + 3) )
goto LABEL_39;
v3 = v9 + 4;
v7 = v9 + 4;
if ( !*((_QWORD *)cvar_list + v9 + 4) )
goto LABEL_39;
v3 = v9 + 5;
v7 = v9 + 5;
if ( !*((_QWORD *)cvar_list + v9 + 5) )
goto LABEL_39;
v3 = v9 + 6;
v7 = v9 + 6;
if ( !*((_QWORD *)cvar_list + v9 + 6) )
goto LABEL_39;
v3 = v9 + 7;
v8 = v9 + 7;
if ( cvar_arraysize <= (int)v8 )
goto LABEL_34;
}
}
switch ( v6 )
{
case 1:
goto LABEL_23;
case 2:
LABEL_21:
v7 = v8;
if ( !*((_QWORD *)cvar_list + v8) )
goto LABEL_39;
v3 = ++v8;
v5 = 1;
LABEL_23:
v7 = v8;
if ( *((_QWORD *)cvar_list + v8) )
{
v3 = ++v8;
v5 = 1;
if ( cvar_arraysize > (int)v8 )
goto LABEL_25;
goto LABEL_34;
}
goto LABEL_39;
case 3:
LABEL_19:
v7 = v8;
if ( !*((_QWORD *)cvar_list + v8) )
goto LABEL_39;
v3 = ++v8;
v5 = 1;
goto LABEL_21;
case 4:
LABEL_17:
v7 = v8;
if ( !*((_QWORD *)cvar_list + v8) )
goto LABEL_39;
v3 = ++v8;
v5 = 1;
goto LABEL_19;
case 5:
LABEL_15:
v7 = v8;
if ( !*((_QWORD *)cvar_list + v8) )
goto LABEL_39;
v3 = ++v8;
v5 = 1;
goto LABEL_17;
}
if ( v6 != 6 )
{
v7 = cvar_arrayfirstopen + 1;
if ( !*((_QWORD *)cvar_list + v8) )
goto LABEL_39;
v3 = cvar_arrayfirstopen + 2;
v8 = cvar_arrayfirstopen + 2LL;
}
v7 = v8;
if ( *((_QWORD *)cvar_list + v8) )
{
v3 = ++v8;
v5 = 1;
goto LABEL_15;
}
}
LABEL_39:
if ( !v5 )
{
v3 = v7;
goto LABEL_35;
}
cvar_arrayfirstopen = v3;
if ( cvar_arraysize == v7 )
{
LABEL_45:
++cvar_arraysize;
cvar_list = realloc(cvar_list, 88LL * (v4 + 1));
LABEL_36:
v10 = cvar_arrayfirstopen;
*((_QWORD *)cvar_list + cvar_arrayfirstopen) = a1;
v11 = (cvar_count << 16) | v10;
*(_DWORD *)(a1 + 76) = v11;
v12 = *(_BYTE *)a1;
*(_BYTE *)a1 |= 1u;
addToHashTable(*(_QWORD *)(a1 + 8), v11, &cvarhashtable);
v13 = cvar_arrayfirstopen;
if ( cvar_arraylasttaken < cvar_arrayfirstopen )
goto LABEL_37;
LABEL_42:
if ( (v12 & 8) != 0 )
return v11;
LABEL_43:
cvar_pset(a1, *(const char **)(a1 + 24));
return v11;
}
*((_QWORD *)cvar_list + v3) = a1;
v11 = v3 | (v2 << 16);
*(_DWORD *)(a1 + 76) = v11;
v12 = *(_BYTE *)a1;
*(_BYTE *)a1 |= 1u;
addToHashTable(*(_QWORD *)(a1 + 8), v11, &cvarhashtable);
v13 = cvar_arrayfirstopen;
if ( cvar_arraylasttaken >= cvar_arrayfirstopen )
goto LABEL_42;
LABEL_37:
cvar_arraylasttaken = v13;
if ( (v12 & 8) == 0 )
goto LABEL_43;
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
int v2; // ebp
int v3; // edx
int v4; // edi
char v5; // r9
int v6; // esi
int v7; // ecx
__int64 v8; // r11
__int64 v9; // r11
int v10; // ebp
unsigned int v11; // ebp
char v12; // r12
int v13; // esi

v2 = ++cvar_count;
v3 = cvar_arrayfirstopen;
v4 = cvar_arraysize;
if ( cvar_arrayfirstopen >= cvar_arraysize )
{
LABEL_35:
if ( cvar_arraysize != v3 )
goto LABEL_36;
goto LABEL_45;
}
v5 = 0;
v6 = ((_BYTE)cvar_arraysize + ~(_BYTE)cvar_arrayfirstopen) & 7;
v7 = cvar_arrayfirstopen;
if ( *((_QWORD *)cvar_list + cvar_arrayfirstopen) )
{
v3 = cvar_arrayfirstopen + 1;
v8 = cvar_arrayfirstopen + 1LL;
v5 = 1;
if ( cvar_arraysize <= (int)v8 )
{
LABEL_34:
cvar_arrayfirstopen = v3;
goto LABEL_35;
}
if ( (((_BYTE)cvar_arraysize + ~(_BYTE)cvar_arrayfirstopen) & 7) == 0 )
{
LABEL_25:
while ( 1 )
{
v7 = v8;
if ( !*((_QWORD *)cvar_list + v8) )
goto LABEL_39;
v3 = v8 + 1;
v9 = v8 + 1;
v5 = 1;
v7 = v9;
if ( !*((_QWORD *)cvar_list + v9) )
goto LABEL_39;
v3 = v9 + 1;
v7 = v9 + 1;
if ( !*((_QWORD *)cvar_list + v9 + 1) )
goto LABEL_39;
v3 = v9 + 2;
v7 = v9 + 2;
if ( !*((_QWORD *)cvar_list + v9 + 2) )
goto LABEL_39;
v3 = v9 + 3;
v7 = v9 + 3;
if ( !*((_QWORD *)cvar_list + v9 + 3) )
goto LABEL_39;
v3 = v9 + 4;
v7 = v9 + 4;
if ( !*((_QWORD *)cvar_list + v9 + 4) )
goto LABEL_39;
v3 = v9 + 5;
v7 = v9 + 5;
if ( !*((_QWORD *)cvar_list + v9 + 5) )
goto LABEL_39;
v3 = v9 + 6;
v7 = v9 + 6;
if ( !*((_QWORD *)cvar_list + v9 + 6) )
goto LABEL_39;
v3 = v9 + 7;
v8 = v9 + 7;
if ( cvar_arraysize <= (int)v8 )
goto LABEL_34;
}
}
switch ( v6 )
{
case 1:
goto LABEL_23;
case 2:
LABEL_21:
v7 = v8;
if ( !*((_QWORD *)cvar_list + v8) )
goto LABEL_39;
v3 = ++v8;
v5 = 1;
LABEL_23:
v7 = v8;
if ( *((_QWORD *)cvar_list + v8) )
{
v3 = ++v8;
v5 = 1;
if ( cvar_arraysize > (int)v8 )
goto LABEL_25;
goto LABEL_34;
}
goto LABEL_39;
case 3:
LABEL_19:
v7 = v8;
if ( !*((_QWORD *)cvar_list + v8) )
goto LABEL_39;
v3 = ++v8;
v5 = 1;
goto LABEL_21;
case 4:
LABEL_17:
v7 = v8;
if ( !*((_QWORD *)cvar_list + v8) )
goto LABEL_39;
v3 = ++v8;
v5 = 1;
goto LABEL_19;
case 5:
LABEL_15:
v7 = v8;
if ( !*((_QWORD *)cvar_list + v8) )
goto LABEL_39;
v3 = ++v8;
v5 = 1;
goto LABEL_17;
}
if ( v6 != 6 )
{
v7 = cvar_arrayfirstopen + 1;
if ( !*((_QWORD *)cvar_list + v8) )
goto LABEL_39;
v3 = cvar_arrayfirstopen + 2;
v8 = cvar_arrayfirstopen + 2LL;
}
v7 = v8;
if ( *((_QWORD *)cvar_list + v8) )
{
v3 = ++v8;
v5 = 1;
goto LABEL_15;
}
}
LABEL_39:
if ( !v5 )
{
v3 = v7;
goto LABEL_35;
}
cvar_arrayfirstopen = v3;
if ( cvar_arraysize == v7 )
{
LABEL_45:
++cvar_arraysize;
cvar_list = realloc(cvar_list, 88LL * (v4 + 1));
LABEL_36:
v10 = cvar_arrayfirstopen;
*((_QWORD *)cvar_list + cvar_arrayfirstopen) = a1;
v11 = (cvar_count << 16) | v10;
*(_DWORD *)(a1 + 76) = v11;
v12 = *(_BYTE *)a1;
*(_BYTE *)a1 |= 1u;
addToHashTable(*(_QWORD *)(a1 + 8), v11, &cvarhashtable);
v13 = cvar_arrayfirstopen;
if ( cvar_arraylasttaken < cvar_arrayfirstopen )
goto LABEL_37;
LABEL_42:
if ( (v12 & 8) != 0 )
return v11;
LABEL_43:
func5(a1, *(const char **)(a1 + 24));
return v11;
}
*((_QWORD *)cvar_list + v3) = a1;
v11 = v3 | (v2 << 16);
*(_DWORD *)(a1 + 76) = v11;
v12 = *(_BYTE *)a1;
*(_BYTE *)a1 |= 1u;
addToHashTable(*(_QWORD *)(a1 + 8), v11, &cvarhashtable);
v13 = cvar_arrayfirstopen;
if ( cvar_arraylasttaken >= cvar_arrayfirstopen )
goto LABEL_42;
LABEL_37:
cvar_arraylasttaken = v13;
if ( (v12 & 8) == 0 )
goto LABEL_43;
return v11;
}

original_code:
int cvar_register(cvar_t *c){
 cvar_count++;
 for(; cvar_arrayfirstopen < cvar_arraysize && cvar_list[cvar_arrayfirstopen]; cvar_arrayfirstopen++);
 if(cvar_arrayfirstopen == cvar_arraysize){
  cvar_arraysize++;
  cvar_list = realloc(cvar_list, cvar_arraysize * sizeof(cvar_t));
 }
 cvar_list[cvar_arrayfirstopen] = c;
 int returnid = (cvar_count << 16) | cvar_arrayfirstopen;
 c->myid = returnid;
 c->type = c->type | 1;
 char flags = c->type;
 addToHashTable(c->name, returnid, cvarhashtable);
 if(cvar_arraylasttaken < cvar_arrayfirstopen) cvar_arraylasttaken = cvar_arrayfirstopen;
 if(!(flags & 8)){
  cvar_pset(c, c->defaultstring);
 }
 return returnid;
}

canonical_original_code:
int cvar_register(struct cvar_s *c){
 cvar_count++;
 for(; cvar_arrayfirstopen < cvar_arraysize && cvar_list[cvar_arrayfirstopen]; cvar_arrayfirstopen++);
 if(cvar_arrayfirstopen == cvar_arraysize){
  cvar_arraysize++;
  cvar_list = realloc(cvar_list, cvar_arraysize * sizeof(cvar_t));
 }
 cvar_list[cvar_arrayfirstopen] = c;
 int returnid = (cvar_count << 16) | cvar_arrayfirstopen;
 c->myid = returnid;
 c->type = c->type | 1;
 char flags = c->type;
 addToHashTable(c->name, returnid, cvarhashtable);
 if(cvar_arraylasttaken < cvar_arrayfirstopen) cvar_arraylasttaken = cvar_arrayfirstopen;
 if(!(flags & 8)){
  cvar_pset(c, c->defaultstring);
 }
 return returnid;
}


decompiled_code:
void __fastcall cvar_idset(int a1, const char *a2)
{
__int64 v2; // rax

v2 = cvar_returnById(a1);
cvar_pset(v2, a2);
}

canonical_decompiled_code:
void __fastcall func7(int a1, const char *a2)
{
__int64 v2; // rax

v2 = func2(a1);
func5(v2, a2);
}

original_code:
void cvar_idset(const int id, const char *value){
 cvar_pset(cvar_returnById(id), value);
}

canonical_original_code:
void cvar_idset(int id, char *value){
 cvar_pset(cvar_returnById(id), value);
}

variable_types: id int


decompiled_code:
void __fastcall cvar_nameset(__int64 a1, const char *a2)
{
__int64 v2; // rax

v2 = cvar_findByNameRPOINT(a1);
cvar_pset(v2, a2);
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, const char *a2)
{
__int64 v2; // rax

v2 = func3(a1);
func5(v2, a2);
}

original_code:
void cvar_nameset(char * name, const char *value){
 cvar_pset(cvar_findByNameRPOINT(name), value);
}

canonical_original_code:
void cvar_nameset(char *name, char *value){
 cvar_pset(cvar_findByNameRPOINT(name), value);
}


checkBBoxPInBBox

original_code:
unsigned char checkBBoxPInBBox(const vec_t *bbox, const vec_t *bboxp){
 unsigned int j;
 for(j = 0; j < 24; j+=3){ if(bboxp[j] < bbox[0]) break;} if(j==24)return 0;
 for(j = 0; j < 24; j+=3){ if(bboxp[j] > bbox[1]) break;} if(j==24)return 0;
 for(j = 1; j < 24; j+=3){ if(bboxp[j] < bbox[2]) break;} if(j> 24)return 0;
 for(j = 1; j < 24; j+=3){ if(bboxp[j] > bbox[3]) break;} if(j> 24)return 0;
 for(j = 2; j < 24; j+=3){ if(bboxp[j] < bbox[4]) break;} if(j> 24)return 0;
 for(j = 2; j < 24; j+=3){ if(bboxp[j] > bbox[5]) break;} if(j> 24)return 0;
 return 1;
}

canonical_original_code:
unsigned char checkBBoxPInBBox(float *bbox, float *bboxp){
 unsigned int j;
 for(j = 0; j < 24; j+=3){ if(bboxp[j] < bbox[0]) break;} if(j==24)return 0;
 for(j = 0; j < 24; j+=3){ if(bboxp[j] > bbox[1]) break;} if(j==24)return 0;
 for(j = 1; j < 24; j+=3){ if(bboxp[j] < bbox[2]) break;} if(j> 24)return 0;
 for(j = 1; j < 24; j+=3){ if(bboxp[j] > bbox[3]) break;} if(j> 24)return 0;
 for(j = 2; j < 24; j+=3){ if(bboxp[j] < bbox[4]) break;} if(j> 24)return 0;
 for(j = 2; j < 24; j+=3){ if(bboxp[j] > bbox[5]) break;} if(j> 24)return 0;
 return 1;
}

variable_types:
bbox
float *

variable_types:
bboxp
float *

variable_types:
j
unsigned int

return_type: unsigned char


checkVertsInBBox

decompiled_code:
__int64 __fastcall checkVertsInBBox(float *a1, float *a2, int a3)
{
float *v4; // rdi
unsigned int v5; // eax
float *v6; // rcx
unsigned int v7; // edx
unsigned int v8; // er9
unsigned int i; // er11
unsigned int v10; // ecx
unsigned int j; // er10
unsigned int k; // er9
float v13; // xmm7_4
unsigned int l; // er8

v4 = a2;
v5 = 3 * a3;
if ( !(3 * a3) )
return 0;
v6 = a2;
v7 = 0;
do
{
if ( *a1 > *v6 )
break;
v7 += 3;
v6 += 3;
}
while ( v5 > v7 );
if ( v5 == v7 )
return 0;
v8 = 0;
do
{
if ( *a2 > a1[1] )
break;
v8 += 3;
a2 += 3;
}
while ( v5 > v8 );
if ( v5 == v8 )
return 0;
if ( v5 <= 1 )
{
j = 1;
}
else
{
for ( i = 1; i < v5; i += 3 )
{
if ( a1[2] > v4[i] )
break;
}
v10 = 0;
if ( i > v5 )
return v10;
for ( j = 1; j < v5; j += 3 )
{
if ( v4[j] > a1[3] )
break;
}
}
v10 = 0;
if ( v5 >= j )
{
if ( v5 <= 2 )
{
v10 = 0;
l = 2;
if ( v5 <= 1 )
return v10;
goto LABEL_27;
}
for ( k = 2; k < v5; k += 3 )
{
if ( a1[4] > v4[k] )
break;
}
v10 = 0;
if ( k <= v5 )
{
v13 = a1[5];
for ( l = 2; l < v5; l += 3 )
{
if ( v4[l] > v13 )
break;
}
LABEL_27:
LOBYTE(v10) = v5 >= l;
return v10;
}
}
return v10;
}

canonical_decompiled_code:
__int64 __fastcall func2(float *a1, float *a2, int a3)
{
float *v4; // rdi
unsigned int v5; // eax
float *v6; // rcx
unsigned int v7; // edx
unsigned int v8; // er9
unsigned int i; // er11
unsigned int v10; // ecx
unsigned int j; // er10
unsigned int k; // er9
float v13; // xmm7_4
unsigned int l; // er8

v4 = a2;
v5 = 3 * a3;
if ( !(3 * a3) )
return 0;
v6 = a2;
v7 = 0;
do
{
if ( *a1 > *v6 )
break;
v7 += 3;
v6 += 3;
}
while ( v5 > v7 );
if ( v5 == v7 )
return 0;
v8 = 0;
do
{
if ( *a2 > a1[1] )
break;
v8 += 3;
a2 += 3;
}
while ( v5 > v8 );
if ( v5 == v8 )
return 0;
if ( v5 <= 1 )
{
j = 1;
}
else
{
for ( i = 1; i < v5; i += 3 )
{
if ( a1[2] > v4[i] )
break;
}
v10 = 0;
if ( i > v5 )
return v10;
for ( j = 1; j < v5; j += 3 )
{
if ( v4[j] > a1[3] )
break;
}
}
v10 = 0;
if ( v5 >= j )
{
if ( v5 <= 2 )
{
v10 = 0;
l = 2;
if ( v5 <= 1 )
return v10;
goto LABEL_27;
}
for ( k = 2; k < v5; k += 3 )
{
if ( a1[4] > v4[k] )
break;
}
v10 = 0;
if ( k <= v5 )
{
v13 = a1[5];
for ( l = 2; l < v5; l += 3 )
{
if ( v4[l] > v13 )
break;
}
LABEL_27:
LOBYTE(v10) = v5 >= l;
return v10;
}
}
return v10;
}

original_code:
unsigned char checkVertsInBBox(const vec_t *bbox, const vec_t *verts, const unsigned int count){
 unsigned int j;
 unsigned int max = count*3;
 for(j = 0; j < max; j+=3){ if(verts[j] < bbox[0]) break;} if(j==max)return 0;
 for(j = 0; j < max; j+=3){ if(verts[j] > bbox[1]) break;} if(j==max)return 0;
 for(j = 1; j < max; j+=3){ if(verts[j] < bbox[2]) break;} if(j> max)return 0;
 for(j = 1; j < max; j+=3){ if(verts[j] > bbox[3]) break;} if(j> max)return 0;
 for(j = 2; j < max; j+=3){ if(verts[j] < bbox[4]) break;} if(j> max)return 0;
 for(j = 2; j < max; j+=3){ if(verts[j] > bbox[5]) break;} if(j> max)return 0;
 return 1;
}

canonical_original_code:
unsigned char checkVertsInBBox(float *bbox, float *verts, unsigned int count){
 unsigned int j;
 unsigned int max = count*3;
 for(j = 0; j < max; j+=3){ if(verts[j] < bbox[0]) break;} if(j==max)return 0;
 for(j = 0; j < max; j+=3){ if(verts[j] > bbox[1]) break;} if(j==max)return 0;
 for(j = 1; j < max; j+=3){ if(verts[j] < bbox[2]) break;} if(j> max)return 0;
 for(j = 1; j < max; j+=3){ if(verts[j] > bbox[3]) break;} if(j> max)return 0;
 for(j = 2; j < max; j+=3){ if(verts[j] < bbox[4]) break;} if(j> max)return 0;
 for(j = 2; j < max; j+=3){ if(verts[j] > bbox[5]) break;} if(j> max)return 0;
 return 1;
}

variable_types:
verts
float *

variable_types:
count
unsigned int

variable_types:
max
unsigned int


decompiled_code:
float __fastcall vec3distvec(float *a1, float *a2)
{
float v2; // xmm0_4
float result; // xmm0_4

v2 = (float)((float)((float)(a1[1] - a2[1]) * (float)(a1[1] - a2[1]))
+ (float)((float)(*a1 - *a2) * (float)(*a1 - *a2)))
+ (float)((float)(a1[2] - a2[2]) * (float)(a1[2] - a2[2]));
if ( v2 < 0.0 )
result = sqrtf(v2);
else
result = fsqrt(v2);
return result;
}

canonical_decompiled_code:
float __fastcall func3(float *a1, float *a2)
{
float v2; // xmm0_4
float result; // xmm0_4

v2 = (float)((float)((float)(a1[1] - a2[1]) * (float)(a1[1] - a2[1]))
+ (float)((float)(*a1 - *a2) * (float)(*a1 - *a2)))
+ (float)((float)(a1[2] - a2[2]) * (float)(a1[2] - a2[2]));
if ( v2 < 0.0 )
result = sqrtf(v2);
else
result = fsqrt(v2);
return result;
}

variable_types:
b
float [3]

variable_types:
c
float [3]

variable_types:
math
float [3]

return_type: float


decompiled_code:
float __fastcall vec3distfastvec(float *a1, float *a2)
{
return (float)((float)((float)(*a1 - *a2) * (float)(*a1 - *a2))
+ (float)((float)(a1[1] - a2[1]) * (float)(a1[1] - a2[1])))
+ (float)((float)(a1[2] - a2[2]) * (float)(a1[2] - a2[2]));
}


decompiled_code:
float __fastcall vec4distvec(float *a1, float *a2)
{
float v2; // xmm0_4
float v3; // xmm0_4
float result; // xmm0_4

v2 = a1[1] - a2[1];
v3 = (float)((float)((float)(a1[2] - a2[2]) * (float)(a1[2] - a2[2]))
+ (float)((float)((float)(*a1 - *a2) * (float)(*a1 - *a2)) + (float)(v2 * v2)))
+ (float)((float)(a1[3] - a2[3]) * (float)(a1[3] - a2[3]));
if ( v3 < 0.0 )
result = sqrtf(v3);
else
result = fsqrt(v3);
return result;
}

canonical_decompiled_code:
float __fastcall func5(float *a1, float *a2)
{
float v2; // xmm0_4
float v3; // xmm0_4
float result; // xmm0_4

v2 = a1[1] - a2[1];
v3 = (float)((float)((float)(a1[2] - a2[2]) * (float)(a1[2] - a2[2]))
+ (float)((float)((float)(*a1 - *a2) * (float)(*a1 - *a2)) + (float)(v2 * v2)))
+ (float)((float)(a1[3] - a2[3]) * (float)(a1[3] - a2[3]));
if ( v3 < 0.0 )
result = sqrtf(v3);
else
result = fsqrt(v3);
return result;
}

variable_types:
b
float [4]

variable_types:
c
float [4]

variable_types:
math
float [4]


checkSphereInSphere

decompiled_code:
bool __fastcall checkSphereInSphere(float *a1, float *a2, float a3, float a4)
{
return (float)(a3 + a4) > vec3distvec(a1, a2);
}

canonical_decompiled_code:
bool __fastcall func10(float *a1, float *a2, float a3, float a4)
{
return (float)(a3 + a4) > func3(a1, a2);
}

original_code:
unsigned char checkSphereInSphere(const vec3_t sphere1, const vec_t size1, const vec3_t sphere2, const vec_t size2){
 vec_t tots = size1+size2;
 return(vec3distvec(sphere1, sphere2) < tots);
}

canonical_original_code:
unsigned char checkSphereInSphere(float sphere1[3], float size1, float sphere2[3], float size2){
 float tots = size1+size2;
 return(vec3distvec(sphere1, sphere2) < tots);
}

variable_types: tots float


decompiled_code:
void *__fastcall entity_findAllByNameRINT(__int64 a1)
{
unsigned int v1; // ebp
void *v2; // r12
__int64 *v3; // rbx
void *result; // rax
__int64 v5; // rdx

v3 = &entityhashtable[3 * (int)getHash()];
result = 0LL;
v5 = 0LL;
if ( *v3 )
{
do
{
while ( (unsigned int)string_testEqual(*v3, a1, v5) )
{
v2 = realloc(v2, 4LL * (v1 + 1));
*((_DWORD *)v2 + v1) = *((_DWORD *)v3 + 2);
v3 = (__int64 *)v3[2];
if ( !v3 )
goto LABEL_7;
++v1;
}
v3 = (__int64 *)v3[2];
}
while ( v3 );
LABEL_7:
result = v2;
}
return result;
}

canonical_decompiled_code:
void *__fastcall func0(__int64 a1)
{
unsigned int v1; // ebp
void *v2; // r12
__int64 *v3; // rbx
void *result; // rax
__int64 v5; // rdx

v3 = &entityhashtable[3 * (int)getHash()];
result = 0LL;
v5 = 0LL;
if ( *v3 )
{
do
{
while ( (unsigned int)string_testEqual(*v3, a1, v5) )
{
v2 = realloc(v2, 4LL * (v1 + 1));
*((_DWORD *)v2 + v1) = *((_DWORD *)v3 + 2);
v3 = (__int64 *)v3[2];
if ( !v3 )
goto LABEL_7;
++v1;
}
v3 = (__int64 *)v3[2];
}
while ( v3 );
LABEL_7:
result = v2;
}
return result;
}

original_code:
entitylistint_t entity_findAllByNameRINT(const char * name){
 entitylistint_t ret;
 int hash = getHash(name);
 hashbucket_t * hb = &entityhashtable[hash];
 if(!hb->name) return ret;
        for(; hb; hb = hb->next){
  if(string_testEqual(hb->name, name)){
   ret.count++;
   ret.list = realloc(ret.list, ret.count * sizeof(int));
   ret.list[ret.count-1] = hb->id;
  }
        }
 return ret;
}

canonical_original_code:
struct entitylistint_s entity_findAllByNameRINT(char *name){
 struct entitylistint_s ret;
 int hash = getHash(name);
 struct hashbucket_s *hb = &entityhashtable[hash];
 if(!hb->name) return ret;
        for(; hb; hb = hb->next){
  if(string_testEqual(hb->name, name)){
   ret.count++;
   ret.list = realloc(ret.list, ret.count * sizeof(int));
   ret.list[ret.count-1] = hb->id;
  }
        }
 return ret;
}

variable_types:
name
char *

variable_types: struct entitylistint_s { int *list; unsigned int count; }

variable_types: hash int

variable_types: struct hashbucket_s { char *name; int id; struct hashbucket_s *next; } *


decompiled_code:
__int64 __fastcall entity_findByNameRINT(__int64 a1)
{
return findByNameRINT(a1, entityhashtable);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return findByNameRINT(a1, entityhashtable);
}

original_code:
int entity_findByNameRINT(const char * name){
 return findByNameRINT(name, entityhashtable);
}

canonical_original_code:
int entity_findByNameRINT(char *name){
 return findByNameRINT(name, entityhashtable);
}


decompiled_code:
__int64 __fastcall entity_delete(unsigned int a1)
{
char *v1; // rbx
__int64 result; // rax
int v3; // edi
char *v4; // rdx
char v5; // bp
int v6; // er9
int v7; // er10

v1 = (char *)entity_list + 416 * (unsigned __int16)a1;
result = 0LL;
if ( *((_DWORD *)v1 + 2) != a1 || !*(_QWORD *)v1 )
return result;
deleteFromHashTable(*(_QWORD *)v1, a1, entityhashtable);
free(*(void **)v1);
*(_QWORD *)v1 = 0LL;
*((_QWORD *)v1 + 51) = 0LL;
memset(
(void *)((unsigned __int64)(v1 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v1 - (((_DWORD)v1 + 8) & 0xFFFFFFF8) + 416) >> 3));
if ( entity_arrayfirstopen > (unsigned __int16)a1 )
entity_arrayfirstopen = (unsigned __int16)a1;
v3 = entity_arraylasttaken;
if ( entity_arraylasttaken <= 0 )
return 1LL;
v4 = (char *)entity_list + 416 * entity_arraylasttaken;
v5 = 0;
v6 = entity_arraylasttaken & 7;
if ( (entity_arraylasttaken & 7) == 0 )
{
LABEL_27:
while ( !v4[12] )
{
v7 = --v3;
v5 = 1;
if ( *(v4 - 404) )
break;
v3 = v7 - 1;
if ( *(v4 - 820) )
break;
v3 = v7 - 2;
if ( *(v4 - 1236) )
break;
v3 = v7 - 3;
if ( *(v4 - 1652) )
break;
v3 = v7 - 4;
if ( *(v4 - 2068) )
break;
v3 = v7 - 5;
if ( *(v4 - 2484) )
break;
v3 = v7 - 6;
if ( *(v4 - 2900) )
break;
v4 -= 3328;
v3 = v7 - 7;
if ( v7 == 7 )
goto LABEL_36;
}
goto LABEL_37;
}
if ( v6 != 1 )
{
if ( v6 != 2 )
{
if ( v6 != 3 )
{
if ( v6 != 4 )
{
if ( v6 != 5 )
{
if ( v6 != 6 )
{
if ( v4[12] )
goto LABEL_37;
v3 = entity_arraylasttaken - 1;
v4 -= 416;
v5 = 1;
}
if ( v4[12] )
goto LABEL_37;
--v3;
v4 -= 416;
v5 = 1;
}
if ( v4[12] )
goto LABEL_37;
--v3;
v4 -= 416;
v5 = 1;
}
if ( v4[12] )
goto LABEL_37;
--v3;
v4 -= 416;
v5 = 1;
}
if ( v4[12] )
goto LABEL_37;
--v3;
v4 -= 416;
v5 = 1;
}
if ( !v4[12] )
{
--v3;
v4 -= 416;
v5 = 1;
goto LABEL_25;
}
LABEL_37:
if ( v5 )
entity_arraylasttaken = v3;
return 1LL;
}
LABEL_25:
if ( v4[12] )
goto LABEL_37;
v4 -= 416;
v5 = 1;
if ( --v3 )
goto LABEL_27;
LABEL_36:
entity_arraylasttaken = 0;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
char *v1; // rbx
__int64 result; // rax
int v3; // edi
char *v4; // rdx
char v5; // bp
int v6; // er9
int v7; // er10

v1 = (char *)entity_list + 416 * (unsigned __int16)a1;
result = 0LL;
if ( *((_DWORD *)v1 + 2) != a1 || !*(_QWORD *)v1 )
return result;
deleteFromHashTable(*(_QWORD *)v1, a1, entityhashtable);
free(*(void **)v1);
*(_QWORD *)v1 = 0LL;
*((_QWORD *)v1 + 51) = 0LL;
memset(
(void *)((unsigned __int64)(v1 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v1 - (((_DWORD)v1 + 8) & 0xFFFFFFF8) + 416) >> 3));
if ( entity_arrayfirstopen > (unsigned __int16)a1 )
entity_arrayfirstopen = (unsigned __int16)a1;
v3 = entity_arraylasttaken;
if ( entity_arraylasttaken <= 0 )
return 1LL;
v4 = (char *)entity_list + 416 * entity_arraylasttaken;
v5 = 0;
v6 = entity_arraylasttaken & 7;
if ( (entity_arraylasttaken & 7) == 0 )
{
LABEL_27:
while ( !v4[12] )
{
v7 = --v3;
v5 = 1;
if ( *(v4 - 404) )
break;
v3 = v7 - 1;
if ( *(v4 - 820) )
break;
v3 = v7 - 2;
if ( *(v4 - 1236) )
break;
v3 = v7 - 3;
if ( *(v4 - 1652) )
break;
v3 = v7 - 4;
if ( *(v4 - 2068) )
break;
v3 = v7 - 5;
if ( *(v4 - 2484) )
break;
v3 = v7 - 6;
if ( *(v4 - 2900) )
break;
v4 -= 3328;
v3 = v7 - 7;
if ( v7 == 7 )
goto LABEL_36;
}
goto LABEL_37;
}
if ( v6 != 1 )
{
if ( v6 != 2 )
{
if ( v6 != 3 )
{
if ( v6 != 4 )
{
if ( v6 != 5 )
{
if ( v6 != 6 )
{
if ( v4[12] )
goto LABEL_37;
v3 = entity_arraylasttaken - 1;
v4 -= 416;
v5 = 1;
}
if ( v4[12] )
goto LABEL_37;
--v3;
v4 -= 416;
v5 = 1;
}
if ( v4[12] )
goto LABEL_37;
--v3;
v4 -= 416;
v5 = 1;
}
if ( v4[12] )
goto LABEL_37;
--v3;
v4 -= 416;
v5 = 1;
}
if ( v4[12] )
goto LABEL_37;
--v3;
v4 -= 416;
v5 = 1;
}
if ( !v4[12] )
{
--v3;
v4 -= 416;
v5 = 1;
goto LABEL_25;
}
LABEL_37:
if ( v5 )
entity_arraylasttaken = v3;
return 1LL;
}
LABEL_25:
if ( v4[12] )
goto LABEL_37;
v4 -= 416;
v5 = 1;
if ( --v3 )
goto LABEL_27;
LABEL_36:
entity_arraylasttaken = 0;
return 1LL;
}

original_code:
int entity_delete(const int id){
 int entityindex = (id & 0xFFFF);
 entity_t * ent = &entity_list[entityindex];
 if(ent->myid != id) return 0;
 if(!ent->name) return 0;
 deleteFromHashTable(ent->name, id, entityhashtable);
 free(ent->name);
 memset(ent, 0, sizeof(entity_t));
 if(entityindex < entity_arrayfirstopen) entity_arrayfirstopen = entityindex;
 for(; entity_arraylasttaken > 0 && !entity_list[entity_arraylasttaken].type; entity_arraylasttaken--);
 return 1;
}

canonical_original_code:
int entity_delete(int id){
 int entityindex = (id & 0xFFFF);
 struct entity_s *ent = &entity_list[entityindex];
 if(ent->myid != id) return 0;
 if(!ent->name) return 0;
 deleteFromHashTable(ent->name, id, entityhashtable);
 free(ent->name);
 memset(ent, 0, sizeof(entity_t));
 if(entityindex < entity_arrayfirstopen) entity_arrayfirstopen = entityindex;
 for(; entity_arraylasttaken > 0 && !entity_list[entity_arraylasttaken].type; entity_arraylasttaken--);
 return 1;
}

variable_types: id int

variable_types: entityindex int

variable_types: struct entity_s { char *name; int myid; char type; char flags; unsigned char treedepth; float pos[3]; float angle[3]; float anglevel[3]; float vel[3]; float scale; int needsmatupdate; struct matrix4x4_s { float m[4][4]; } mat; double nextthink; void (*spawn)(struct entity_s *e); void (*remove)(struct entity_s *e); void (*think)(struct entity_s *e); void (*touch)(struct entity_s *e, int touchid); int parentid; int attachmentid; int shaderid; int shaderperm; int texturegroupid; int modelid; struct phystype_s { enum { STATIC=0, FLY=1, DYNAMIC=2, ODEFLY=3, ODEDYNAMIC=4 } movetype; enum { NONE=0, AABB=1, ODESPHERE=2, ODEBOX=3, ODECYLINDER=4, ODECAPSULE=5 } collidetype; float mass; void *gid; void *bid; } phys; int needsbboxupdate; float bboxp[24]; float bbox[6]; unsigned int leafpos; void *leaf; struct leaflinkitem_s { int self; char type; float bb[2]; int unext; char unextt; int uprev; char uprevt; int dnext; char dnextt; int dprev; char dprevt; } ll; } *

user_defined_types: struct entity_s { char *name; int myid; char type; char flags; unsigned char treedepth; float pos[3]; float angle[3]; float anglevel[3]; float vel[3]; float scale; int needsmatupdate; struct matrix4x4_s mat; double nextthink; void (*spawn)(struct entity_s *e); void (*remove)(struct entity_s *e); void (*think)(struct entity_s *e); void (*touch)(struct entity_s *e, int touchid); int parentid; int attachmentid; int shaderid; int shaderperm; int texturegroupid; int modelid; struct phystype_s phys; int needsbboxupdate; float bboxp[24]; float bbox[6]; unsigned int leafpos; void *leaf; struct leaflinkitem_s ll; }


decompiled_code:
char *__fastcall entity_returnById(int a1)
{
char *result; // rax

result = (char *)entity_list + 416 * (unsigned __int16)a1;
if ( !result[12] )
return 0LL;
if ( *((_DWORD *)result + 2) != a1 )
result = 0LL;
return result;
}

canonical_decompiled_code:
char *__fastcall func3(int a1)
{
char *result; // rax

result = (char *)entity_list + 416 * (unsigned __int16)a1;
if ( !result[12] )
return 0LL;
if ( *((_DWORD *)result + 2) != a1 )
result = 0LL;
return result;
}

original_code:
entity_t * entity_returnById(const int id){
 int entityindex = (id & 0xFFFF);
 entity_t * ent = &entity_list[entityindex];
 if(!ent->type) return 0;
 if(ent->myid == id) return ent;
 return 0;
}

canonical_original_code:
struct entity_s *entity_returnById(int id){
 int entityindex = (id & 0xFFFF);
 struct entity_s *ent = &entity_list[entityindex];
 if(!ent->type) return 0;
 if(ent->myid == id) return ent;
 return 0;
}

return_type: struct entity_s { char *name; int myid; char type; char flags; unsigned char treedepth; float pos[3]; float angle[3]; float anglevel[3]; float vel[3]; float scale; int needsmatupdate; struct matrix4x4_s { float m[4][4]; } mat; double nextthink; void (*spawn)(struct entity_s *e); void (*remove)(struct entity_s *e); void (*think)(struct entity_s *e); void (*touch)(struct entity_s *e, int touchid); int parentid; int attachmentid; int shaderid; int shaderperm; int texturegroupid; int modelid; struct phystype_s { enum { STATIC=0, FLY=1, DYNAMIC=2, ODEFLY=3, ODEDYNAMIC=4 } movetype; enum { NONE=0, AABB=1, ODESPHERE=2, ODEBOX=3, ODECYLINDER=4, ODECAPSULE=5 } collidetype; float mass; void *gid; void *bid; } phys; int needsbboxupdate; float bboxp[24]; float bbox[6]; unsigned int leafpos; void *leaf; struct leaflinkitem_s { int self; char type; float bb[2]; int unext; char unextt; int uprev; char uprevt; int dnext; char dnextt; int dprev; char dprevt; } ll; } *


decompiled_code:
char *__fastcall entity_findByNameRPOINT(__int64 a1)
{
int v1; // eax

v1 = findByNameRINT(a1, entityhashtable);
return entity_returnById(v1);
}

canonical_decompiled_code:
char *__fastcall func4(__int64 a1)
{
int v1; // eax

v1 = findByNameRINT(a1, entityhashtable);
return func3(v1);
}

original_code:
entity_t * entity_findByNameRPOINT(const char * name){
 return entity_returnById(findByNameRINT(name, entityhashtable));
}

canonical_original_code:
struct entity_s *entity_findByNameRPOINT(char *name){
 return entity_returnById(findByNameRINT(name, entityhashtable));
}

user_defined_types: struct phystype_s { enum { STATIC=0, FLY=1, DYNAMIC=2, ODEFLY=3, ODEDYNAMIC=4 } movetype; enum { NONE=0, AABB=1, ODESPHERE=2, ODEBOX=3, ODECYLINDER=4, ODECAPSULE=5 } collidetype; float mass; void *gid; void *bid; }

user_defined_types: struct leaflinkitem_s { int self; char type; float bb[2]; int unext; char unextt; int uprev; char uprevt; int dnext; char dnextt; int dprev; char dprevt; }


decompiled_code:
void *__fastcall entity_findAllByNameRPOINT(__int64 a1)
{
unsigned int v1; // ebp
void *v2; // r12
__int64 *v3; // rbx
void *result; // rax
__int64 v5; // rdx

v3 = &entityhashtable[3 * (int)getHash()];
result = 0LL;
v5 = 0LL;
if ( *v3 )
{
do
{
while ( (unsigned int)string_testEqual(*v3, a1, v5) )
{
v2 = realloc(v2, 8LL * (v1 + 1));
*((_QWORD *)v2 + v1) = entity_returnById(*((_DWORD *)v3 + 2));
v3 = (__int64 *)v3[2];
if ( !v3 )
goto LABEL_7;
++v1;
}
v3 = (__int64 *)v3[2];
}
while ( v3 );
LABEL_7:
result = v2;
}
return result;
}

canonical_decompiled_code:
void *__fastcall func5(__int64 a1)
{
unsigned int v1; // ebp
void *v2; // r12
__int64 *v3; // rbx
void *result; // rax
__int64 v5; // rdx

v3 = &entityhashtable[3 * (int)getHash()];
result = 0LL;
v5 = 0LL;
if ( *v3 )
{
do
{
while ( (unsigned int)string_testEqual(*v3, a1, v5) )
{
v2 = realloc(v2, 8LL * (v1 + 1));
*((_QWORD *)v2 + v1) = func3(*((_DWORD *)v3 + 2));
v3 = (__int64 *)v3[2];
if ( !v3 )
goto LABEL_7;
++v1;
}
v3 = (__int64 *)v3[2];
}
while ( v3 );
LABEL_7:
result = v2;
}
return result;
}

original_code:
entitylistpoint_t entity_findAllByNameRPOINT(const char * name){
 entitylistpoint_t ret;
 int hash = getHash(name);
 hashbucket_t * hb = &entityhashtable[hash];
 if(!hb->name) return ret;
        for(; hb; hb = hb->next){
  if(string_testEqual(hb->name, name)){
   ret.count++;
   ret.list = realloc(ret.list, ret.count * sizeof(entity_t *));
   ret.list[ret.count-1] = entity_returnById(hb->id);
  }
        }
 return ret;
}

canonical_original_code:
struct entitylistpoint_s entity_findAllByNameRPOINT(char *name){
 struct entitylistpoint_s ret;
 int hash = getHash(name);
 struct hashbucket_s *hb = &entityhashtable[hash];
 if(!hb->name) return ret;
        for(; hb; hb = hb->next){
  if(string_testEqual(hb->name, name)){
   ret.count++;
   ret.list = realloc(ret.list, ret.count * sizeof(struct entity_s *));
   ret.list[ret.count-1] = entity_returnById(hb->id);
  }
        }
 return ret;
}

variable_types: struct entitylistpoint_s { struct entity_s { char *name; int myid; char type; char flags; unsigned char treedepth; float pos[3]; float angle[3]; float anglevel[3]; float vel[3]; float scale; int needsmatupdate; struct matrix4x4_s { float m[4][4]; } mat; double nextthink; void (*spawn)(struct entity_s *e); void (*remove)(struct entity_s *e); void (*think)(struct entity_s *e); void (*touch)(struct entity_s *e, int touchid); int parentid; int attachmentid; int shaderid; int shaderperm; int texturegroupid; int modelid; struct phystype_s { enum { STATIC=0, FLY=1, DYNAMIC=2, ODEFLY=3, ODEDYNAMIC=4 } movetype; enum { NONE=0, AABB=1, ODESPHERE=2, ODEBOX=3, ODECYLINDER=4, ODECAPSULE=5 } collidetype; float mass; void *gid; void *bid; } phys; int needsbboxupdate; float bboxp[24]; float bbox[6]; unsigned int leafpos; void *leaf; struct leaflinkitem_s { int self; char type; float bb[2]; int unext; char unextt; int uprev; char uprevt; int dnext; char dnextt; int dprev; char dprevt; } ll; } **list; unsigned int count; }

user_defined_types: struct entitylistpoint_s { struct entity_s **list; unsigned int count; }

user_defined_types: struct hashbucket_s { char *name; int id; struct hashbucket_s *next; }


decompiled_code:
__int64 __fastcall entity_addRINT(const char *a1)
{
int v1; // eax
int v2; // er8
char *v3; // rdx
char v4; // cl
int v5; // er9
int v6; // ebp
char *v7; // rbp
unsigned int v8; // ebx
char *v9; // r9
int v10; // edx
char *v11; // rbp
char *v12; // r9
__int64 v14[55]; // [rsp+0h] [rbp-1B8h] BYREF

++entity_count;
v1 = entity_arrayfirstopen;
v2 = entity_arraysize;
if ( entity_arrayfirstopen >= entity_arraysize )
goto LABEL_39;
v3 = (char *)entity_list + 416 * entity_arrayfirstopen;
v4 = 0;
v5 = ((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7;
if ( (((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7) == 0 )
{
LABEL_23:
while ( v3[12] )
{
v6 = ++v1;
v4 = 1;
if ( !v3[428] )
break;
v1 = v6 + 1;
if ( !v3[844] )
break;
v1 = v6 + 2;
if ( !v3[1260] )
break;
v1 = v6 + 3;
if ( !v3[1676] )
break;
v1 = v6 + 4;
if ( !v3[2092] )
break;
v1 = v6 + 5;
if ( !v3[2508] )
break;
v1 = v6 + 6;
if ( !v3[2924] )
break;
v1 = v6 + 7;
v3 += 3328;
if ( v6 + 7 == entity_arraysize )
goto LABEL_32;
}
goto LABEL_34;
}
switch ( v5 )
{
case 1:
goto LABEL_21;
case 2:
goto LABEL_19;
case 3:
LABEL_17:
if ( !v3[12] )
goto LABEL_34;
++v1;
v3 += 416;
v4 = 1;
LABEL_19:
if ( v3[12] )
{
++v1;
v3 += 416;
v4 = 1;
LABEL_21:
if ( v3[12] )
{
++v1;
v3 += 416;
v4 = 1;
if ( v1 != entity_arraysize )
goto LABEL_23;
LABEL_32:
entity_arrayfirstopen = entity_arraysize;
goto LABEL_33;
}
goto LABEL_34;
}
goto LABEL_34;
case 4:
LABEL_15:
if ( !v3[12] )
goto LABEL_34;
++v1;
v3 += 416;
v4 = 1;
goto LABEL_17;
case 5:
LABEL_13:
if ( !v3[12] )
goto LABEL_34;
++v1;
v3 += 416;
v4 = 1;
goto LABEL_15;
}
if ( v5 != 6 )
{
if ( !v3[12] )
goto LABEL_34;
v1 = entity_arrayfirstopen + 1;
v3 += 416;
v4 = 1;
}
if ( v3[12] )
{
++v1;
v3 += 416;
v4 = 1;
goto LABEL_13;
}
LABEL_34:
if ( v4 )
{
entity_arrayfirstopen = v1;
if ( entity_arraysize != v1 )
{
v7 = (char *)entity_list + 416 * v1;
createEntity(v14, a1);
qmemcpy(v7, v14, 0x1A0uLL);
v8 = entity_arrayfirstopen | (entity_count << 16);
v9 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v9 + 2) = v8;
addToHashTable(*(_QWORD *)v9, v8, entityhashtable);
v10 = entity_arrayfirstopen;
if ( entity_arraylasttaken < entity_arrayfirstopen )
goto LABEL_41;
goto LABEL_37;
}
goto LABEL_33;
}
LABEL_39:
if ( entity_arraysize == v1 )
{
LABEL_33:
++entity_arraysize;
entity_list = realloc(entity_list, 416LL * (v2 + 1));
}
v11 = (char *)entity_list + 416 * entity_arrayfirstopen;
createEntity(v14, a1);
qmemcpy(v11, v14, 0x1A0uLL);
v8 = entity_arrayfirstopen | (entity_count << 16);
v12 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v12 + 2) = v8;
addToHashTable(*(_QWORD *)v12, v8, entityhashtable);
v10 = entity_arrayfirstopen;
if ( entity_arraylasttaken < entity_arrayfirstopen )
{
LABEL_41:
entity_arraylasttaken = v10;
if ( v8 )
return v8;
goto LABEL_38;
}
LABEL_37:
if ( !v8 )
{
LABEL_38:
puts("yes, i can");
v8 = 0;
}
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func6(const char *a1)
{
int v1; // eax
int v2; // er8
char *v3; // rdx
char v4; // cl
int v5; // er9
int v6; // ebp
char *v7; // rbp
unsigned int v8; // ebx
char *v9; // r9
int v10; // edx
char *v11; // rbp
char *v12; // r9
__int64 v14[55]; // [rsp+0h] [rbp-1B8h] BYREF

++entity_count;
v1 = entity_arrayfirstopen;
v2 = entity_arraysize;
if ( entity_arrayfirstopen >= entity_arraysize )
goto LABEL_39;
v3 = (char *)entity_list + 416 * entity_arrayfirstopen;
v4 = 0;
v5 = ((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7;
if ( (((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7) == 0 )
{
LABEL_23:
while ( v3[12] )
{
v6 = ++v1;
v4 = 1;
if ( !v3[428] )
break;
v1 = v6 + 1;
if ( !v3[844] )
break;
v1 = v6 + 2;
if ( !v3[1260] )
break;
v1 = v6 + 3;
if ( !v3[1676] )
break;
v1 = v6 + 4;
if ( !v3[2092] )
break;
v1 = v6 + 5;
if ( !v3[2508] )
break;
v1 = v6 + 6;
if ( !v3[2924] )
break;
v1 = v6 + 7;
v3 += 3328;
if ( v6 + 7 == entity_arraysize )
goto LABEL_32;
}
goto LABEL_34;
}
switch ( v5 )
{
case 1:
goto LABEL_21;
case 2:
goto LABEL_19;
case 3:
LABEL_17:
if ( !v3[12] )
goto LABEL_34;
++v1;
v3 += 416;
v4 = 1;
LABEL_19:
if ( v3[12] )
{
++v1;
v3 += 416;
v4 = 1;
LABEL_21:
if ( v3[12] )
{
++v1;
v3 += 416;
v4 = 1;
if ( v1 != entity_arraysize )
goto LABEL_23;
LABEL_32:
entity_arrayfirstopen = entity_arraysize;
goto LABEL_33;
}
goto LABEL_34;
}
goto LABEL_34;
case 4:
LABEL_15:
if ( !v3[12] )
goto LABEL_34;
++v1;
v3 += 416;
v4 = 1;
goto LABEL_17;
case 5:
LABEL_13:
if ( !v3[12] )
goto LABEL_34;
++v1;
v3 += 416;
v4 = 1;
goto LABEL_15;
}
if ( v5 != 6 )
{
if ( !v3[12] )
goto LABEL_34;
v1 = entity_arrayfirstopen + 1;
v3 += 416;
v4 = 1;
}
if ( v3[12] )
{
++v1;
v3 += 416;
v4 = 1;
goto LABEL_13;
}
LABEL_34:
if ( v4 )
{
entity_arrayfirstopen = v1;
if ( entity_arraysize != v1 )
{
v7 = (char *)entity_list + 416 * v1;
createEntity(v14, a1);
qmemcpy(v7, v14, 0x1A0uLL);
v8 = entity_arrayfirstopen | (entity_count << 16);
v9 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v9 + 2) = v8;
addToHashTable(*(_QWORD *)v9, v8, entityhashtable);
v10 = entity_arrayfirstopen;
if ( entity_arraylasttaken < entity_arrayfirstopen )
goto LABEL_41;
goto LABEL_37;
}
goto LABEL_33;
}
LABEL_39:
if ( entity_arraysize == v1 )
{
LABEL_33:
++entity_arraysize;
entity_list = realloc(entity_list, 416LL * (v2 + 1));
}
v11 = (char *)entity_list + 416 * entity_arrayfirstopen;
createEntity(v14, a1);
qmemcpy(v11, v14, 0x1A0uLL);
v8 = entity_arrayfirstopen | (entity_count << 16);
v12 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v12 + 2) = v8;
addToHashTable(*(_QWORD *)v12, v8, entityhashtable);
v10 = entity_arrayfirstopen;
if ( entity_arraylasttaken < entity_arrayfirstopen )
{
LABEL_41:
entity_arraylasttaken = v10;
if ( v8 )
return v8;
goto LABEL_38;
}
LABEL_37:
if ( !v8 )
{
LABEL_38:
puts("yes, i can");
v8 = 0;
}
return v8;
}

original_code:
int entity_addRINT(const char * name){
 entity_count++;
 for(; entity_arrayfirstopen < entity_arraysize && entity_list[entity_arrayfirstopen].type; entity_arrayfirstopen++);
 if(entity_arrayfirstopen == entity_arraysize){
  entity_arraysize++;
  entity_list = realloc(entity_list, entity_arraysize * sizeof(entity_t));
 }
 entity_list[entity_arrayfirstopen] = createEntity(name);
 int returnid = (entity_count << 16) | entity_arrayfirstopen;
 entity_list[entity_arrayfirstopen].myid = returnid;
 addToHashTable(entity_list[entity_arrayfirstopen].name, returnid, entityhashtable);
 if(entity_arraylasttaken < entity_arrayfirstopen) entity_arraylasttaken = entity_arrayfirstopen;
 if(returnid == 0) printf("yes, i can\n");
 return returnid;
}

canonical_original_code:
int entity_addRINT(char *name){
 entity_count++;
 for(; entity_arrayfirstopen < entity_arraysize && entity_list[entity_arrayfirstopen].type; entity_arrayfirstopen++);
 if(entity_arrayfirstopen == entity_arraysize){
  entity_arraysize++;
  entity_list = realloc(entity_list, entity_arraysize * sizeof(entity_t));
 }
 entity_list[entity_arrayfirstopen] = createEntity(name);
 int returnid = (entity_count << 16) | entity_arrayfirstopen;
 entity_list[entity_arrayfirstopen].myid = returnid;
 addToHashTable(entity_list[entity_arrayfirstopen].name, returnid, entityhashtable);
 if(entity_arraylasttaken < entity_arrayfirstopen) entity_arraylasttaken = entity_arrayfirstopen;
 if(returnid == 0) printf("yes, i can\n");
 return returnid;
}

variable_types: returnid int


decompiled_code:
__int64 entity_init()
{
memset(entityhashtable, 0, sizeof(entityhashtable));
if ( entity_list )
{
free(entity_list);
entity_list = 0LL;
}
entity_addRINT("default");
entity_ok = 1;
return 1LL;
}

canonical_decompiled_code:
__int64 func7()
{
memset(entityhashtable, 0, sizeof(entityhashtable));
if ( entity_list )
{
free(entity_list);
entity_list = 0LL;
}
func6("default");
entity_ok = 1;
return 1LL;
}

original_code:
int entity_init(void){
 memset(entityhashtable, 0, 128 * sizeof(hashbucket_t));
 if(entity_list) free(entity_list);
 entity_list = 0;
 entity_addRINT("default");
 entity_ok = 1;
 return 1;
}

canonical_original_code:
int entity_init(){
 memset(entityhashtable, 0, 128 * sizeof(hashbucket_t));
 if(entity_list) free(entity_list);
 entity_list = 0;
 entity_addRINT("default");
 entity_ok = 1;
 return 1;
}


decompiled_code:
char *__fastcall entity_addRPOINT(const char *a1)
{
int v1; // eax
int v2; // er8
char *v3; // rdx
char v4; // cl
int v5; // er9
int v6; // ebp
char *v7; // rbp
__int64 v8; // rsi
char *v9; // r8
int v10; // eax
char *v12; // rbp
__int64 v13; // rsi
char *v14; // r8
__int64 v15[55]; // [rsp+0h] [rbp-1B8h] BYREF

++entity_count;
v1 = entity_arrayfirstopen;
v2 = entity_arraysize;
if ( entity_arrayfirstopen >= entity_arraysize )
goto LABEL_39;
v3 = (char *)entity_list + 416 * entity_arrayfirstopen;
v4 = 0;
v5 = ((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7;
if ( (((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7) == 0 )
{
LABEL_23:
while ( v3[12] )
{
v6 = ++v1;
v4 = 1;
if ( !v3[428] )
break;
v1 = v6 + 1;
if ( !v3[844] )
break;
v1 = v6 + 2;
if ( !v3[1260] )
break;
v1 = v6 + 3;
if ( !v3[1676] )
break;
v1 = v6 + 4;
if ( !v3[2092] )
break;
v1 = v6 + 5;
if ( !v3[2508] )
break;
v1 = v6 + 6;
if ( !v3[2924] )
break;
v1 = v6 + 7;
v3 += 3328;
if ( v6 + 7 == entity_arraysize )
goto LABEL_32;
}
goto LABEL_34;
}
switch ( v5 )
{
case 1:
goto LABEL_21;
case 2:
goto LABEL_19;
case 3:
LABEL_17:
if ( !v3[12] )
goto LABEL_34;
++v1;
v3 += 416;
v4 = 1;
LABEL_19:
if ( v3[12] )
{
++v1;
v3 += 416;
v4 = 1;
LABEL_21:
if ( v3[12] )
{
++v1;
v3 += 416;
v4 = 1;
if ( v1 != entity_arraysize )
goto LABEL_23;
LABEL_32:
entity_arrayfirstopen = entity_arraysize;
goto LABEL_33;
}
goto LABEL_34;
}
goto LABEL_34;
case 4:
LABEL_15:
if ( !v3[12] )
goto LABEL_34;
++v1;
v3 += 416;
v4 = 1;
goto LABEL_17;
case 5:
LABEL_13:
if ( !v3[12] )
goto LABEL_34;
++v1;
v3 += 416;
v4 = 1;
goto LABEL_15;
}
if ( v5 != 6 )
{
if ( !v3[12] )
goto LABEL_34;
v1 = entity_arrayfirstopen + 1;
v3 += 416;
v4 = 1;
}
if ( v3[12] )
{
++v1;
v3 += 416;
v4 = 1;
goto LABEL_13;
}
LABEL_34:
if ( v4 )
{
entity_arrayfirstopen = v1;
if ( entity_arraysize != v1 )
{
v7 = (char *)entity_list + 416 * v1;
createEntity(v15, a1);
qmemcpy(v7, v15, 0x1A0uLL);
v8 = entity_arrayfirstopen | (unsigned int)(entity_count << 16);
v9 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v9 + 2) = v8;
addToHashTable(*(_QWORD *)v9, v8, entityhashtable);
v10 = entity_arrayfirstopen;
if ( entity_arraylasttaken < entity_arrayfirstopen )
goto LABEL_41;
LABEL_37:
if ( *((_DWORD *)entity_list + 104 * v10 + 2) )
return (char *)entity_list + 416 * entity_arrayfirstopen;
LABEL_43:
puts("yes, i can");
return (char *)entity_list + 416 * entity_arrayfirstopen;
}
goto LABEL_33;
}
LABEL_39:
if ( entity_arraysize == v1 )
{
LABEL_33:
++entity_arraysize;
entity_list = realloc(entity_list, 416LL * (v2 + 1));
}
v12 = (char *)entity_list + 416 * entity_arrayfirstopen;
createEntity(v15, a1);
qmemcpy(v12, v15, 0x1A0uLL);
v13 = entity_arrayfirstopen | (unsigned int)(entity_count << 16);
v14 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v14 + 2) = v13;
addToHashTable(*(_QWORD *)v14, v13, entityhashtable);
v10 = entity_arrayfirstopen;
if ( entity_arraylasttaken >= entity_arrayfirstopen )
goto LABEL_37;
LABEL_41:
entity_arraylasttaken = v10;
if ( !*((_DWORD *)entity_list + 104 * v10 + 2) )
goto LABEL_43;
return (char *)entity_list + 416 * entity_arrayfirstopen;
}

canonical_decompiled_code:
char *__fastcall func8(const char *a1)
{
int v1; // eax
int v2; // er8
char *v3; // rdx
char v4; // cl
int v5; // er9
int v6; // ebp
char *v7; // rbp
__int64 v8; // rsi
char *v9; // r8
int v10; // eax
char *v12; // rbp
__int64 v13; // rsi
char *v14; // r8
__int64 v15[55]; // [rsp+0h] [rbp-1B8h] BYREF

++entity_count;
v1 = entity_arrayfirstopen;
v2 = entity_arraysize;
if ( entity_arrayfirstopen >= entity_arraysize )
goto LABEL_39;
v3 = (char *)entity_list + 416 * entity_arrayfirstopen;
v4 = 0;
v5 = ((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7;
if ( (((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7) == 0 )
{
LABEL_23:
while ( v3[12] )
{
v6 = ++v1;
v4 = 1;
if ( !v3[428] )
break;
v1 = v6 + 1;
if ( !v3[844] )
break;
v1 = v6 + 2;
if ( !v3[1260] )
break;
v1 = v6 + 3;
if ( !v3[1676] )
break;
v1 = v6 + 4;
if ( !v3[2092] )
break;
v1 = v6 + 5;
if ( !v3[2508] )
break;
v1 = v6 + 6;
if ( !v3[2924] )
break;
v1 = v6 + 7;
v3 += 3328;
if ( v6 + 7 == entity_arraysize )
goto LABEL_32;
}
goto LABEL_34;
}
switch ( v5 )
{
case 1:
goto LABEL_21;
case 2:
goto LABEL_19;
case 3:
LABEL_17:
if ( !v3[12] )
goto LABEL_34;
++v1;
v3 += 416;
v4 = 1;
LABEL_19:
if ( v3[12] )
{
++v1;
v3 += 416;
v4 = 1;
LABEL_21:
if ( v3[12] )
{
++v1;
v3 += 416;
v4 = 1;
if ( v1 != entity_arraysize )
goto LABEL_23;
LABEL_32:
entity_arrayfirstopen = entity_arraysize;
goto LABEL_33;
}
goto LABEL_34;
}
goto LABEL_34;
case 4:
LABEL_15:
if ( !v3[12] )
goto LABEL_34;
++v1;
v3 += 416;
v4 = 1;
goto LABEL_17;
case 5:
LABEL_13:
if ( !v3[12] )
goto LABEL_34;
++v1;
v3 += 416;
v4 = 1;
goto LABEL_15;
}
if ( v5 != 6 )
{
if ( !v3[12] )
goto LABEL_34;
v1 = entity_arrayfirstopen + 1;
v3 += 416;
v4 = 1;
}
if ( v3[12] )
{
++v1;
v3 += 416;
v4 = 1;
goto LABEL_13;
}
LABEL_34:
if ( v4 )
{
entity_arrayfirstopen = v1;
if ( entity_arraysize != v1 )
{
v7 = (char *)entity_list + 416 * v1;
createEntity(v15, a1);
qmemcpy(v7, v15, 0x1A0uLL);
v8 = entity_arrayfirstopen | (unsigned int)(entity_count << 16);
v9 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v9 + 2) = v8;
addToHashTable(*(_QWORD *)v9, v8, entityhashtable);
v10 = entity_arrayfirstopen;
if ( entity_arraylasttaken < entity_arrayfirstopen )
goto LABEL_41;
LABEL_37:
if ( *((_DWORD *)entity_list + 104 * v10 + 2) )
return (char *)entity_list + 416 * entity_arrayfirstopen;
LABEL_43:
puts("yes, i can");
return (char *)entity_list + 416 * entity_arrayfirstopen;
}
goto LABEL_33;
}
LABEL_39:
if ( entity_arraysize == v1 )
{
LABEL_33:
++entity_arraysize;
entity_list = realloc(entity_list, 416LL * (v2 + 1));
}
v12 = (char *)entity_list + 416 * entity_arrayfirstopen;
createEntity(v15, a1);
qmemcpy(v12, v15, 0x1A0uLL);
v13 = entity_arrayfirstopen | (unsigned int)(entity_count << 16);
v14 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v14 + 2) = v13;
addToHashTable(*(_QWORD *)v14, v13, entityhashtable);
v10 = entity_arrayfirstopen;
if ( entity_arraylasttaken >= entity_arrayfirstopen )
goto LABEL_37;
LABEL_41:
entity_arraylasttaken = v10;
if ( !*((_DWORD *)entity_list + 104 * v10 + 2) )
goto LABEL_43;
return (char *)entity_list + 416 * entity_arrayfirstopen;
}

original_code:
entity_t * entity_addRPOINT(const char * name){
 entity_count++;
 for(; entity_arrayfirstopen < entity_arraysize && entity_list[entity_arrayfirstopen].type; entity_arrayfirstopen++);
 if(entity_arrayfirstopen == entity_arraysize){
  entity_arraysize++;
  entity_list = realloc(entity_list, entity_arraysize * sizeof(entity_t));
 }
 entity_list[entity_arrayfirstopen] = createEntity(name);
 int returnid = (entity_count << 16) | entity_arrayfirstopen;
 entity_list[entity_arrayfirstopen].myid = returnid;
 addToHashTable(entity_list[entity_arrayfirstopen].name, returnid, entityhashtable);
 if(entity_arraylasttaken < entity_arrayfirstopen) entity_arraylasttaken = entity_arrayfirstopen;
 if(entity_list[entity_arrayfirstopen].myid == 0) printf("yes, i can\n");
 return &entity_list[entity_arrayfirstopen];
}

canonical_original_code:
struct entity_s *entity_addRPOINT(char *name){
 entity_count++;
 for(; entity_arrayfirstopen < entity_arraysize && entity_list[entity_arrayfirstopen].type; entity_arrayfirstopen++);
 if(entity_arrayfirstopen == entity_arraysize){
  entity_arraysize++;
  entity_list = realloc(entity_list, entity_arraysize * sizeof(entity_t));
 }
 entity_list[entity_arrayfirstopen] = createEntity(name);
 int returnid = (entity_count << 16) | entity_arrayfirstopen;
 entity_list[entity_arrayfirstopen].myid = returnid;
 addToHashTable(entity_list[entity_arrayfirstopen].name, returnid, entityhashtable);
 if(entity_arraylasttaken < entity_arrayfirstopen) entity_arraylasttaken = entity_arrayfirstopen;
 if(entity_list[entity_arrayfirstopen].myid == 0) printf("yes, i can\n");
 return &entity_list[entity_arrayfirstopen];
}


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

result = (unsigned int)(entity_arraylasttaken + 1);
if ( (_DWORD)result != entity_arraysize )
{
entity_arraysize = entity_arraylasttaken + 1;
result = (unsigned __int64)realloc(entity_list, 416LL * (int)result);
entity_list = (void *)result;
}
return result;
}

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

result = (unsigned int)(entity_arraylasttaken + 1);
if ( (_DWORD)result != entity_arraysize )
{
entity_arraysize = entity_arraylasttaken + 1;
result = (unsigned __int64)realloc(entity_list, 416LL * (int)result);
entity_list = (void *)result;
}
return result;
}

original_code:
void entity_pruneList(void){
 if(entity_arraysize == entity_arraylasttaken+1) return;
 entity_arraysize = entity_arraylasttaken+1;
 entity_list = realloc(entity_list, entity_arraysize * sizeof(entity_t));
}

canonical_original_code:
void entity_pruneList(){
 if(entity_arraysize == entity_arraylasttaken+1) return;
 entity_arraysize = entity_arraylasttaken+1;
 entity_list = realloc(entity_list, entity_arraysize * sizeof(entity_t));
}


decompiled_code:
_BOOL8 __fastcall string_testEqual(char *a1, _BYTE *a2)
{
char v2; // al

if ( !a1 || !a2 )
return 0LL;
while ( 1 )
{
v2 = *a1;
if ( !*a1 )
break;
++a1;
if ( *a2++ != v2 )
return 0LL;
}
return *a2 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(char *a1, _BYTE *a2)
{
char v2; // al

if ( !a1 || !a2 )
return 0LL;
while ( 1 )
{
v2 = *a1;
if ( !*a1 )
break;
++a1;
if ( *a2++ != v2 )
return 0LL;
}
return *a2 == 0;
}

original_code:
int string_testEqual(const char * one, const char * two){
 if(!one || !two) return 0;
 char * m1 = (char *)one;
 char * m2 = (char *)two;
 while(*m1) if(*m1++ != *m2++) return 0;
 if(*m2) return 0;
 return 1;
}

canonical_original_code:
int string_testEqual(char *one, char *two){
 if(!one || !two) return 0;
 char *m1 = (char *)one;
 char *m2 = (char *)two;
 while(*m1) if(*m1++ != *m2++) return 0;
 if(*m2) return 0;
 return 1;
}

variable_types:
one
char *

variable_types:
two
char *


decompiled_code:
_BOOL8 __fastcall string_testEqualCI(_BYTE *a1, char *a2)
{
int v2; // eax
char v3; // r8

if ( !a1 || !a2 )
return 0LL;
LOBYTE(v2) = *a1;
if ( !*a1 )
return *a2 == 0;
while ( 1 )
{
while ( (unsigned __int8)(v2 - 65) <= 0x19u )
{
v2 = (char)v2 + 32;
v3 = *a2;
if ( (unsigned __int8)(*a2 - 65) > 0x19u )
goto LABEL_6;
LABEL_10:
if ( v3 + 32 != v2 )
return 0LL;
++a1;
++a2;
LOBYTE(v2) = *a1;
if ( !*a1 )
return *a2 == 0;
}
v2 = (char)v2;
v3 = *a2;
if ( (unsigned __int8)(*a2 - 65) <= 0x19u )
goto LABEL_10;
LABEL_6:
if ( v3 != v2 )
return 0LL;
++a1;
++a2;
LOBYTE(v2) = *a1;
if ( !*a1 )
return *a2 == 0;
}
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(_BYTE *a1, char *a2)
{
int v2; // eax
char v3; // r8

if ( !a1 || !a2 )
return 0LL;
LOBYTE(v2) = *a1;
if ( !*a1 )
return *a2 == 0;
while ( 1 )
{
while ( (unsigned __int8)(v2 - 65) <= 0x19u )
{
v2 = (char)v2 + 32;
v3 = *a2;
if ( (unsigned __int8)(*a2 - 65) > 0x19u )
goto LABEL_6;
LABEL_10:
if ( v3 + 32 != v2 )
return 0LL;
++a1;
++a2;
LOBYTE(v2) = *a1;
if ( !*a1 )
return *a2 == 0;
}
v2 = (char)v2;
v3 = *a2;
if ( (unsigned __int8)(*a2 - 65) <= 0x19u )
goto LABEL_10;
LABEL_6:
if ( v3 != v2 )
return 0LL;
++a1;
++a2;
LOBYTE(v2) = *a1;
if ( !*a1 )
return *a2 == 0;
}
}


original_code:
int string_testEqualN(const char * one, const char * two, const unsigned int n){
 if(!one || !two) return 0;
 char * m1 = (char *)one;
 char * m2 = (char *)two;
 unsigned int i;
 for(i = 0; i < n && *m1; i++) if(*m1++ != *m2++) return 0;
 return 1;
}

canonical_original_code:
int string_testEqualN(char *one, char *two, unsigned int n){
 if(!one || !two) return 0;
 char *m1 = (char *)one;
 char *m2 = (char *)two;
 unsigned int i;
 for(i = 0; i < n && *m1; i++) if(*m1++ != *m2++) return 0;
 return 1;
}

variable_types:
n
unsigned int

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall string_testEqualNCI(__int64 a1, __int64 a2, int a3)
{
__int64 i; // rcx
int v4; // er10
char v5; // r11
char v6; // al

if ( !a1 || !a2 )
return 0LL;
if ( !a3 )
return 1LL;
for ( i = 0LL; i != a3; ++i )
{
while ( 1 )
{
v6 = *(_BYTE *)(a1 + i);
if ( !v6 )
return 1LL;
if ( (unsigned __int8)(v6 - 65) > 0x19u )
break;
v4 = v6 + 32;
v5 = *(_BYTE *)(a2 + i);
if ( (unsigned __int8)(v5 - 65) <= 0x19u )
goto LABEL_6;
LABEL_11:
if ( v5 != v4 )
return 0LL;
if ( ++i == a3 )
return 1LL;
}
v4 = v6;
v5 = *(_BYTE *)(a2 + i);
if ( (unsigned __int8)(v5 - 65) > 0x19u )
goto LABEL_11;
LABEL_6:
if ( v5 + 32 != v4 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, int a3)
{
__int64 i; // rcx
int v4; // er10
char v5; // r11
char v6; // al

if ( !a1 || !a2 )
return 0LL;
if ( !a3 )
return 1LL;
for ( i = 0LL; i != a3; ++i )
{
while ( 1 )
{
v6 = *(_BYTE *)(a1 + i);
if ( !v6 )
return 1LL;
if ( (unsigned __int8)(v6 - 65) > 0x19u )
break;
v4 = v6 + 32;
v5 = *(_BYTE *)(a2 + i);
if ( (unsigned __int8)(v5 - 65) <= 0x19u )
goto LABEL_6;
LABEL_11:
if ( v5 != v4 )
return 0LL;
if ( ++i == a3 )
return 1LL;
}
v4 = v6;
v5 = *(_BYTE *)(a2 + i);
if ( (unsigned __int8)(v5 - 65) > 0x19u )
goto LABEL_11;
LABEL_6:
if ( v5 + 32 != v4 )
return 0LL;
}
return 1LL;
}

original_code:
int string_testEqualNCI(const char * one, const char * two, const unsigned int n){
 if(!one || !two) return 0;
 char * m1 = (char *)one;
 char * m2 = (char *)two;
 unsigned int i;
 for(i = 0; i < n && *m1; i++, m1++, m2++)if(( ( (((*m1)) >= 'A' && ((*m1)) <= 'Z') ) ? (*m1) + 32 : (*m1) ) != ( ( (((*m2)) >= 'A' && ((*m2)) <= 'Z') ) ? (*m2) + 32 : (*m2) )) return 0;
 return 1;
}