Inserisci

decompiled_code:
void __fastcall __noreturn Inserisci(void *a1)
{
int v1; // ebx
unsigned int v2; // ebp

v1 = 4;
do
{
v2 = rand() % 11;
StackPush((__int64)a1, v2);
printf("Inserimento: %d\n", v2);
sleep(1u);
--v1;
}
while ( v1 );
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func12(void *a1)
{
int v1; // ebx
unsigned int v2; // ebp

v1 = 4;
do
{
v2 = rand() % 11;
func9((__int64)a1, v2);
printf("Inserimento: %d\n", v2);
sleep(1u);
--v1;
}
while ( v1 );
pthread_exit(0LL);
}

original_code:
void *Inserisci(void * s)
{
 int i;
 Elem v;
 for(i=0; i<4; i++) {
  v = rand() % 11;
  StackPush(s, v);
  printf("Inserimento: %d\n", v);
  sleep(1);
 }
 pthread_exit(((void *)0));
}

canonical_original_code:
void *Inserisci(void *s)
{
 int i;
 int v;
 for(i=0; i<4; i++) {
  v = rand() % 11;
  StackPush(s, v);
  printf("Inserimento: %d\n", v);
  sleep(1);
 }
 pthread_exit(((void *)0));
}

variable_types:
s
void *

variable_types: v int


Preleva

repo: robertovela/sisop

decompiled_code:
void __fastcall __noreturn Preleva(void *a1)
{
int v1; // er12
__int64 v2; // rbx
__int64 v3; // rbp

v1 = 10;
do
{
v2 = (unsigned int)StackPop((__int64 *)a1);
printf("Prelievo: %d\n", v2);
v3 = (unsigned int)StackPop((__int64 *)a1);
printf("Prelievo: %d\n", v3);
printf("Somma: %d\n", (unsigned int)(v2 + v3));
sleep(3u);
--v1;
}
while ( v1 );
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func13(void *a1)
{
int v1; // er12
__int64 v2; // rbx
__int64 v3; // rbp

v1 = 10;
do
{
v2 = (unsigned int)func10((__int64 *)a1);
printf("Prelievo: %d\n", v2);
v3 = (unsigned int)func10((__int64 *)a1);
printf("Prelievo: %d\n", v3);
printf("Somma: %d\n", (unsigned int)(v2 + v3));
sleep(3u);
--v1;
}
while ( v1 );
pthread_exit(0LL);
}

original_code:
void *Preleva(void * s)
{
 int i;
 Elem v1, v2;
 for(i=0; i<10; i++) {
  v1=StackPop(s);
  printf("Prelievo: %d\n", v1);
  v2=StackPop(s);
  printf("Prelievo: %d\n", v2);
  printf("Somma: %d\n", v1+v2);
  sleep(3);
 }
 pthread_exit(((void *)0));
}

canonical_original_code:
void *Preleva(void *s)
{
 int i;
 int v1; int v2;
 for(i=0; i<10; i++) {
  v1=StackPop(s);
  printf("Prelievo: %d\n", v1);
  v2=StackPop(s);
  printf("Prelievo: %d\n", v2);
  printf("Somma: %d\n", v1+v2);
  sleep(3);
 }
 pthread_exit(((void *)0));
}

variable_types: i int

return_type: void *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
pthread_attr_t *v4; // rbx
pthread_t *v5; // rbp
void *v6; // r12
pthread_t v7; // rdi
_BYTE v9[40]; // [rsp+0h] [rbp-98h] BYREF
char v10; // [rsp+28h] [rbp-70h] BYREF
pthread_attr_t attr; // [rsp+30h] [rbp-68h] BYREF

v3 = time(0LL);
v4 = (pthread_attr_t *)v9;
v5 = (pthread_t *)v9;
srand(v3);
v6 = malloc(0x98uLL);
StackInit(v6, 4LL);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, 0);
do
pthread_create(v5++, 0LL, Inserisci, v6);
while ( v5 != (pthread_t *)&v10 );
pthread_create(v5, 0LL, Preleva, v6);
do
{
v7 = v4->__align;
v4 = (pthread_attr_t *)((char *)v4 + 8);
pthread_join(v7, 0LL);
}
while ( v4 != &attr );
StackRemove(v6);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
pthread_attr_t *v4; // rbx
pthread_t *v5; // rbp
void *v6; // r12
pthread_t v7; // rdi
_BYTE v9[40]; // [rsp+0h] [rbp-98h] BYREF
char v10; // [rsp+28h] [rbp-70h] BYREF
pthread_attr_t attr; // [rsp+30h] [rbp-68h] BYREF

v3 = time(0LL);
v4 = (pthread_attr_t *)v9;
v5 = (pthread_t *)v9;
srand(v3);
v6 = malloc(0x98uLL);
func7(v6, 4LL);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, 0);
do
pthread_create(v5++, 0LL, Inserisci, v6);
while ( v5 != (pthread_t *)&v10 );
pthread_create(v5, 0LL, Preleva, v6);
do
{
v7 = v4->__align;
v4 = (pthread_attr_t *)((char *)v4 + 8);
pthread_join(v7, 0LL);
}
while ( v4 != &attr );
func8(v6);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
 pthread_t threads[6];
 pthread_attr_t attr;
 int rc;
 int i;
 srand(time(((void *)0)));
 Stack * stack = (Stack *)malloc(sizeof(Stack));
 StackInit(stack, 4);
 pthread_attr_init(&attr);
 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 for(i=0; i<5; i++) {
  pthread_create(&threads[i], ((void *)0), Inserisci, (void *)stack);
 }
 pthread_create(&threads[5], ((void *)0), Preleva, (void *)stack);
 for(i=0; i<6; i++) {
  pthread_join(threads[i], ((void *)0));
 }
 StackRemove(stack);
}

canonical_original_code:
int main(int argc, char *argv[])
{
 unsigned long threads[6];
 union pthread_attr_t attr;
 int rc;
 int i;
 srand(time(((void *)0)));
 struct Stack *stack = (Stack *)malloc(sizeof(Stack));
 StackInit(stack, 4);
 pthread_attr_init(&attr);
 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 for(i=0; i<5; i++) {
  pthread_create(&threads[i], ((void *)0), Inserisci, (void *)stack);
 }
 pthread_create(&threads[5], ((void *)0), Preleva, (void *)stack);
 for(i=0; i<6; i++) {
  pthread_join(threads[i], ((void *)0));
 }
 StackRemove(stack);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
threads
unsigned long [6]

variable_types: union pthread_attr_t { char __size[56]; long __align; }

variable_types: rc int

variable_types: struct Stack { int *dati; int dim; int testa; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } m; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } ok_push; union pthread_cond_t ok_pop; } *

return_type: int

user_defined_types: struct Stack { int *dati; int dim; int testa; union pthread_mutex_t m; union pthread_cond_t ok_push; union pthread_cond_t ok_pop; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
__int64 __fastcall produci_alta_prio(__int64 a1)
{
__int64 v1; // rbp
unsigned int v2; // er12
int v3; // eax
unsigned int v4; // eax

v1 = a1 + 16;
enter_monitor(a1 + 16);
puts("Produttore 1 entrato nel monitor...");
while ( *(_DWORD *)(a1 + 48) == 3 )
wait_condition(v1, 0LL);
v2 = rand() % 12;
v3 = *(_DWORD *)(a1 + 40);
*(_DWORD *)(a1 + 4LL * v3) = v2;
++*(_DWORD *)(a1 + 48);
*(_DWORD *)(a1 + 40) = (v3 + 1) % 3;
v4 = getpid();
printf("Produttore 1 con pid %d ha prodotto %d\n", v4, v2);
signal_condition(v1, 2LL);
return leave_monitor(v1);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 v1; // rbp
unsigned int v2; // er12
int v3; // eax
unsigned int v4; // eax

v1 = a1 + 16;
func15(a1 + 16);
puts("Produttore 1 entrato nel monitor...");
while ( *(_DWORD *)(a1 + 48) == 3 )
func18(v1, 0LL);
v2 = rand() % 12;
v3 = *(_DWORD *)(a1 + 40);
*(_DWORD *)(a1 + 4LL * v3) = v2;
++*(_DWORD *)(a1 + 48);
*(_DWORD *)(a1 + 40) = (v3 + 1) % 3;
v4 = getpid();
printf("Produttore 1 con pid %d ha prodotto %d\n", v4, v2);
func19(v1, 2LL);
return func16(v1);
}

original_code:
void produci_alta_prio(PriorityProdCons* p){
 int value;
 enter_monitor(&p->m);
 printf("Produttore 1 entrato nel monitor...\n");
 while(p->count == 3) {
  wait_condition(&p->m,0);
 }
 value = rand() % 12 ;
 p->buffer[p->testa] = value;
 p->testa = ++(p->testa) % 3;
 p->count++;
 printf("Produttore 1 con pid %d ha prodotto %d\n",getpid(),value);
 signal_condition(&p->m,2);
 leave_monitor(&p->m);
}

canonical_original_code:
void produci_alta_prio(struct PriorityProdCons *p){
 int value;
 enter_monitor(&p->m);
 printf("Produttore 1 entrato nel monitor...\n");
 while(p->count == 3) {
  wait_condition(&p->m,0);
 }
 value = rand() % 12 ;
 p->buffer[p->testa] = value;
 p->testa = ++(p->testa) % 3;
 p->count++;
 printf("Produttore 1 con pid %d ha prodotto %d\n",getpid(),value);
 signal_condition(&p->m,2);
 leave_monitor(&p->m);
}

variable_types: struct PriorityProdCons { int buffer[3]; struct Monitor { int mutex; int num_var_cond; int id_conds; int id_shared; int *cond_counts; } m; int testa; int coda; int count; } *

variable_types: value int

return_type: void

user_defined_types: struct PriorityProdCons { int buffer[3]; struct Monitor m; int testa; int coda; int count; }


decompiled_code:
__int64 __fastcall produci_bassa_prio(__int64 a1)
{
__int64 v1; // rbp
unsigned int v2; // er12
int v3; // eax
unsigned int v4; // eax

v1 = a1 + 16;
enter_monitor(a1 + 16);
puts("Produttore 2 entrato nel monitor...");
while ( *(_DWORD *)(a1 + 48) == 3 )
wait_condition(v1, 1LL);
v2 = rand() % 12 + 13;
v3 = *(_DWORD *)(a1 + 40);
*(_DWORD *)(a1 + 4LL * v3) = v2;
++*(_DWORD *)(a1 + 48);
*(_DWORD *)(a1 + 40) = (v3 + 1) % 3;
v4 = getpid();
printf("Produttore 2 con pid %d ha prodotto %d\n", v4, v2);
signal_condition(v1, 2LL);
return leave_monitor(v1);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
__int64 v1; // rbp
unsigned int v2; // er12
int v3; // eax
unsigned int v4; // eax

v1 = a1 + 16;
func15(a1 + 16);
puts("Produttore 2 entrato nel monitor...");
while ( *(_DWORD *)(a1 + 48) == 3 )
func18(v1, 1LL);
v2 = rand() % 12 + 13;
v3 = *(_DWORD *)(a1 + 40);
*(_DWORD *)(a1 + 4LL * v3) = v2;
++*(_DWORD *)(a1 + 48);
*(_DWORD *)(a1 + 40) = (v3 + 1) % 3;
v4 = getpid();
printf("Produttore 2 con pid %d ha prodotto %d\n", v4, v2);
func19(v1, 2LL);
return func16(v1);
}

original_code:
void produci_bassa_prio(PriorityProdCons* p){
 int value;
 enter_monitor(&p->m);
 printf("Produttore 2 entrato nel monitor...\n");
 while(p->count == 3) {
  wait_condition(&p->m,1);
 }
 value = 13 + (rand() % 12) ;
 p->buffer[p->testa] = value;
 p->testa = ++(p->testa) % 3;
 p->count++;
 printf("Produttore 2 con pid %d ha prodotto %d\n",getpid(),value);
 signal_condition(&p->m,2);
 leave_monitor(&p->m);
}

canonical_original_code:
void produci_bassa_prio(struct PriorityProdCons *p){
 int value;
 enter_monitor(&p->m);
 printf("Produttore 2 entrato nel monitor...\n");
 while(p->count == 3) {
  wait_condition(&p->m,1);
 }
 value = 13 + (rand() % 12) ;
 p->buffer[p->testa] = value;
 p->testa = ++(p->testa) % 3;
 p->count++;
 printf("Produttore 2 con pid %d ha prodotto %d\n",getpid(),value);
 signal_condition(&p->m,2);
 leave_monitor(&p->m);
}

user_defined_types: struct Monitor { int mutex; int num_var_cond; int id_conds; int id_shared; int *cond_counts; }


consuma

decompiled_code:
__int64 __fastcall consuma(__int64 a1)
{
__int64 v1; // rbp
int i; // eax
int v3; // edx
unsigned int v4; // er12
unsigned int v5; // eax

v1 = a1 + 16;
enter_monitor(a1 + 16);
for ( i = *(_DWORD *)(a1 + 48); !i; i = *(_DWORD *)(a1 + 48) )
wait_condition(v1, 2LL);
v3 = *(_DWORD *)(a1 + 44);
v4 = *(_DWORD *)(a1 + 4LL * v3);
*(_DWORD *)(a1 + 48) = i - 1;
*(_DWORD *)(a1 + 44) = (v3 + 1) % 3;
v5 = getpid();
printf("Consumatore con pid %d ha consumato valore %d\n", v5, v4);
if ( (int)queue_condition(v1, 0LL) <= 0 )
signal_condition(v1, 1LL);
else
signal_condition(v1, 0LL);
return leave_monitor(v1);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
__int64 v1; // rbp
int i; // eax
int v3; // edx
unsigned int v4; // er12
unsigned int v5; // eax

v1 = a1 + 16;
func15(a1 + 16);
for ( i = *(_DWORD *)(a1 + 48); !i; i = *(_DWORD *)(a1 + 48) )
func18(v1, 2LL);
v3 = *(_DWORD *)(a1 + 44);
v4 = *(_DWORD *)(a1 + 4LL * v3);
*(_DWORD *)(a1 + 48) = i - 1;
*(_DWORD *)(a1 + 44) = (v3 + 1) % 3;
v5 = getpid();
printf("Consumatore con pid %d ha consumato valore %d\n", v5, v4);
if ( (int)func20(v1, 0LL) <= 0 )
func19(v1, 1LL);
else
func19(v1, 0LL);
return func16(v1);
}

original_code:
void consuma(PriorityProdCons* p){
 int value;
 enter_monitor(&p->m);
 while(p->count == 0){
  wait_condition(&p->m,2);
 }
 value = p->buffer[p->coda];
 p->coda = ++(p->coda) % 3;
 p->count--;
 printf("Consumatore con pid %d ha consumato valore %d\n",getpid(),value);
 if(queue_condition(&p->m,0) > 0)
  signal_condition(&p->m,0);
 else
  signal_condition(&p->m,1);
 leave_monitor(&p->m);
}

canonical_original_code:
void consuma(struct PriorityProdCons *p){
 int value;
 enter_monitor(&p->m);
 while(p->count == 0){
  wait_condition(&p->m,2);
 }
 value = p->buffer[p->coda];
 p->coda = ++(p->coda) % 3;
 p->count--;
 printf("Consumatore con pid %d ha consumato valore %d\n",getpid(),value);
 if(queue_condition(&p->m,0) > 0)
  signal_condition(&p->m,0);
 else
  signal_condition(&p->m,1);
 leave_monitor(&p->m);
}


decompiled_code:
__int64 __fastcall queue_condition(__int64 a1, int a2)
{
return *(unsigned int *)(*(_QWORD *)(a1 + 16) + 4LL * a2);
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, int a2)
{
return *(unsigned int *)(*(_QWORD *)(a1 + 16) + 4LL * a2);
}

original_code:
int queue_condition(Monitor * M, int id_var){
 return M->cond_counts[id_var];
}

canonical_original_code:
int queue_condition(struct Monitor *M, int id_var){
 return M->cond_counts[id_var];
}

variable_types: struct Monitor { int mutex; int num_var_cond; int id_conds; int id_shared; int *cond_counts; } *


PrintHello

decompiled_code:
void __fastcall __noreturn PrintHello(void *a1)
{
printf("\n%d: Hello World!\n", a1);
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(void *a1)
{
printf("\n%d: Hello World!\n", a1);
pthread_exit(0LL);
}

original_code:
void *PrintHello(void *threadid)
{
   printf("\n%d: Hello World!\n", threadid);
   pthread_exit(((void *)0));
}

variable_types:
threadid
void *


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
char *v3; // rbx
unsigned int v4; // eax
_BYTE savedregs[72]; // [rsp+0h] [rbp+0h] BYREF

v3 = 0LL;
while ( 1 )
{
printf("Creating thread %d\n", (unsigned int)v3);
v4 = pthread_create((pthread_t *)savedregs, 0LL, PrintHello, v3);
if ( v4 )
break;
if ( ++v3 == (char *)5 )
pthread_exit(0LL);
}
printf("ERROR; return code from pthread_create() is %d\n", v4);
exit(-1);
}

original_code:
int main(int argc, char *argv[])
{
pthread_t threads[5];
int rc, t;
for(t=0;t<5;t++){
  printf("Creating thread %d\n", t);
  rc = pthread_create(&threads[t], ((void *)0), PrintHello, (void *)t);
  if (rc){
    printf("ERROR; return code from pthread_create() is %d\n", rc);
    exit(-1);
    }
  }
pthread_exit(((void *)0));
}

canonical_original_code:
int main(int argc, char *argv[])
{
unsigned long threads[5];
int rc; int t;
for(t=0;t<5;t++){
  printf("Creating thread %d\n", t);
  rc = pthread_create(&threads[t], ((void *)0), PrintHello, (void *)t);
  if (rc){
    printf("ERROR; return code from pthread_create() is %d\n", rc);
    exit(-1);
    }
  }
pthread_exit(((void *)0));
}

variable_types:
threads
unsigned long [5]

variable_types: t int


decompiled_code:
int __fastcall Leggi_Sem(int a1, int a2)
{
return semctl(a1, a2, 12);
}

canonical_decompiled_code:
int __fastcall func3(int a1, int a2)
{
return semctl(a1, a2, 12);
}

original_code:
int Leggi_Sem(int id_sem, int numsem) {
  return semctl(id_sem,numsem,12);
}

variable_types: numsem int


decompiled_code:
int __fastcall Wait_Sem(int a1, unsigned __int16 a2)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

sops.sem_num = a2;
*(_DWORD *)&sops.sem_op = 0xFFFF;
return semop(a1, &sops, 1uLL);
}

canonical_decompiled_code:
int __fastcall func0(int a1, unsigned __int16 a2)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

sops.sem_num = a2;
*(_DWORD *)&sops.sem_op = 0xFFFF;
return semop(a1, &sops, 1uLL);
}

original_code:
void Wait_Sem(int id_sem, int numsem) {
       struct sembuf sem_buf;
       sem_buf.sem_num=numsem;
       sem_buf.sem_flg=0;
       sem_buf.sem_op=-1;
       semop(id_sem,&sem_buf,1);
}

variable_types: struct sembuf { unsigned short sem_num; short sem_op; short sem_flg; }


decompiled_code:
int __fastcall Signal_Sem(int a1, unsigned __int16 a2)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

sops.sem_num = a2;
*(_DWORD *)&sops.sem_op = 1;
return semop(a1, &sops, 1uLL);
}

canonical_decompiled_code:
int __fastcall func1(int a1, unsigned __int16 a2)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

sops.sem_num = a2;
*(_DWORD *)&sops.sem_op = 1;
return semop(a1, &sops, 1uLL);
}

original_code:
void Signal_Sem (int id_sem,int numsem) {
       struct sembuf sem_buf;
       sem_buf.sem_num=numsem;
       sem_buf.sem_flg=0;
       sem_buf.sem_op=1;
       semop(id_sem,&sem_buf,1);
}

canonical_original_code:
void Signal_Sem(int id_sem, int numsem) {
       struct sembuf sem_buf;
       sem_buf.sem_num=numsem;
       sem_buf.sem_flg=0;
       sem_buf.sem_op=1;
       semop(id_sem,&sem_buf,1);
}

user_defined_types: struct sembuf { unsigned short sem_num; short sem_op; short sem_flg; }


decompiled_code:
int __fastcall Queue_Sem(int a1, int a2)
{
return semctl(a1, a2, 14, 0LL);
}

canonical_decompiled_code:
int __fastcall func2(int a1, int a2)
{
return semctl(a1, a2, 14, 0LL);
}

original_code:
int Queue_Sem(int id_sem, int numsem) {
 return semctl(id_sem,numsem,14,((void *)0));
}


canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1, int a2)
{
return *(unsigned int *)(*(_QWORD *)(a1 + 16) + 4LL * a2);
}


repo: robertqingsong/shine

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

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

original_code:
CData *create_data( const CDataHeader *pDataHeader )
{
 CData *pRetCode = ((void *)0);
 return pRetCode;
}

canonical_original_code:
struct CData_t *create_data(struct CDataHeader_t *pDataHeader)
{
 struct CData_t *pRetCode = ((void *)0);
 return pRetCode;
}

variable_types:
pDataHeader
struct CDataHeader_t *

variable_types: struct CData_t { struct CDataSlice_t { struct CDataHeader_t { unsigned short iDataId; unsigned char iDataSubId; unsigned char iDataSubIdRange; } stDataHeader; unsigned short iTotalDataSize; unsigned int iCurrentSliceSize; } *pDataSliceArray; unsigned short iDataSliceArraySize; unsigned char *pDataBuf; unsigned short iDataBufSize; } *

user_defined_types: struct CData_t { struct CDataSlice_t *pDataSliceArray; unsigned short iDataSliceArraySize; unsigned char *pDataBuf; unsigned short iDataBufSize; }

user_defined_types: struct CDataSlice_t { struct CDataHeader_t stDataHeader; unsigned short iTotalDataSize; unsigned int iCurrentSliceSize; }


decompiled_code:
void destroy_data()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void destroy_data( CData *pData )
{
}

canonical_original_code:
void destroy_data(struct CData_t *pData)
{
}

user_defined_types: struct CDataHeader_t { unsigned short iDataId; unsigned char iDataSubId; unsigned char iDataSubIdRange; }


decompiled_code:
__int64 add_data_slice()
{
return 0xFFFFFFFFLL;
}

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

original_code:
int32_t add_data_slice( CData *pData, const CDataSlice *pDataSlice )
{
 int32_t iRetCode = -1;
 return iRetCode;
}

canonical_original_code:
int add_data_slice(struct CData_t *pData, struct CDataSlice_t *pDataSlice)
{
 int iRetCode = -1;
 return iRetCode;
}

variable_types:
pDataSlice
struct CDataSlice_t *

variable_types: iRetCode int


decompiled_code:
__int64 is_shine_manager_ready()
{
return (unsigned int)-(fg_ShineManager == 0);
}

canonical_decompiled_code:
__int64 func0()
{
return (unsigned int)-(fg_ShineManager == 0);
}

original_code:
static int32_t is_shine_manager_ready( void )
{
 int32_t iRetCode = -1;
 if ( fg_ShineManager.iInitFlag )
  iRetCode = 0;
 return iRetCode;
}

canonical_original_code:
static int is_shine_manager_ready()
{
 int iRetCode = -1;
 if ( fg_ShineManager.iInitFlag )
  iRetCode = 0;
 return iRetCode;
}


decompiled_code:
__int64 shine_session_event()
{
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func1()
{
return 0xFFFFFFFFLL;
}

original_code:
static int32_t shine_session_event( const struct CSession_t *pThis,
     const C_SESSION_EVENT eEvent,
     const CEventParam *pEventParam,
     const int32_t iEventParamSize,
     void *pUserData )
{
 int32_t iRetCode = -1;
 return iRetCode;
}

canonical_original_code:
static int shine_session_event(struct CSession_t *pThis, enum CSessionEvent_t eEvent, struct CEventParam_t *pEventParam, int iEventParamSize, void *pUserData)
{
 int iRetCode = -1;
 return iRetCode;
}

variable_types: struct CSession_t { int (*init)(struct CSession_t *pThis, struct CSessionParam_t { char pIP[32]; unsigned short iPort; char pLocalIP[32]; unsigned short iLocalPort; } *pParam); void (*release)(struct CSession_t *pThis); int (*handle_input)(struct CSession_t *pThis, struct CSocket_t { int iSocketId; struct CReactor_t { struct CNetEngine_t { int iEngineId; int iIsRunning; struct CThread_t { struct CPine_t { struct CBTreeNode_t {  } BTNode; } PineSuper; void *(*thread)(void *pParam); enum C_THREAD_PRIORITY { OS_THREAD_PRIORITY_LOW=0, OS_THREAD_PRIORITY_NORMAL=1, OS_THREAD_PRIORITY_HIGH=2 } ePriority; void *pParam; unsigned long long iTid; int iQuitFlag; } *pEngineThread; } *pEngine; int (*fReactorCallback)(struct CReactor_t *pReactorId, struct CSocket_t *pSocketId, void *pUserData); struct CQueue_t { struct CQueueNode_t { struct CListNode_t { void *pData; struct CListNode_t *Prev; struct CListNode_t *Next; } LNode; } *Front; struct CQueueNode_t *Rear; int iMaxQueueWaterLevel; int iCurrentQueueWaterLevel; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } Locker; } stSocketRemoveQ; union pthread_mutex_t Locker; void *pUserData; } *pOwnerReactor; void *pUserData; } *pSocket); int (*handle_output)(struct CSession_t *pThis, unsigned char *pOutDatabuf, int iOutDataLen, struct CNetAddr_t { char pIP[32]; unsigned short iPort; unsigned short iLocalPort; } *pNetAddr); int (*handle_business)(struct CSession_t *pThis, struct CSocket_t *pSocket, unsigned char *pInData, int iInDataLen, struct CNetAddr_t *pNetAddr, void *pUserData); int (*handle_event)(struct CSession_t *pThis, enum CSessionEvent_t { EVENT_READ_ERROR=0, EVENT_WRITE_ERROR=1, EVENT_ACCEPT_ERROR=2, EVENT_ACCEPT_NEW_STREAM_CLIENT_NOTIFY=3 } eEvent, struct CEventParam_t { struct CSocket_t *pSocket; struct CNetAddr_t stNetAddr; } *pEventParam, int iEventParamSize, void *pUserData); struct CSessionParam_t stSessionParam; struct CReactor_t *pOwnerReactor; struct CSocket_t *pSocket; struct CNetAddr_t stPeerAddr; int iBlockId; void *pResultCode; void *pUserData; union pthread_mutex_t Locker; } *

variable_types:
pEventParam
struct CEventParam_t *

variable_types: iEventParamSize int

variable_types:
pUserData
void *

user_defined_types: struct CSession_t { int (*init)(struct CSession_t *pThis, struct CSessionParam_t *pParam); void (*release)(struct CSession_t *pThis); int (*handle_input)(struct CSession_t *pThis, struct CSocket_t *pSocket); int (*handle_output)(struct CSession_t *pThis, unsigned char *pOutDatabuf, int iOutDataLen, struct CNetAddr_t *pNetAddr); int (*handle_business)(struct CSession_t *pThis, struct CSocket_t *pSocket, unsigned char *pInData, int iInDataLen, struct CNetAddr_t *pNetAddr, void *pUserData); int (*handle_event)(struct CSession_t *pThis, enum CSessionEvent_t eEvent, struct CEventParam_t *pEventParam, int iEventParamSize, void *pUserData); struct CSessionParam_t stSessionParam; struct CReactor_t *pOwnerReactor; struct CSocket_t *pSocket; struct CNetAddr_t stPeerAddr; int iBlockId; void *pResultCode; void *pUserData; union pthread_mutex_t Locker; }

user_defined_types: struct CSocket_t { int iSocketId; struct CReactor_t *pOwnerReactor; void *pUserData; }

user_defined_types: struct CReactor_t { struct CNetEngine_t *pEngine; int (*fReactorCallback)(struct CReactor_t *pReactorId, struct CSocket_t *pSocketId, void *pUserData); struct CQueue_t stSocketRemoveQ; union pthread_mutex_t Locker; void *pUserData; }

user_defined_types: struct CQueue_t { struct CQueueNode_t *Front; struct CQueueNode_t *Rear; int iMaxQueueWaterLevel; int iCurrentQueueWaterLevel; union pthread_mutex_t Locker; }

user_defined_types: struct CNetEngine_t { int iEngineId; int iIsRunning; struct CThread_t *pEngineThread; }

user_defined_types: struct CQueueNode_t { struct CListNode_t LNode; }

user_defined_types: struct CThread_t { struct CPine_t PineSuper; void *(*thread)(void *pParam); enum C_THREAD_PRIORITY ePriority; void *pParam; unsigned long long iTid; int iQuitFlag; }

user_defined_types: struct CPine_t { struct CBTreeNode_t BTNode; }


decompiled_code:
__int64 __fastcall shine_session_business(__int64 a1, __int64 a2, __int64 a3, int a4, __int64 a5, __int64 a6)
{
__int64 result; // rax
size_t v10; // rax
const char *v11; // rax
__int64 v12; // rdx

log_print("shine session business calling..................");
if ( a4 <= 0 || a3 == 0 || !a6 )
{
log_print("param is invalid???????????????????????????");
result = 0xFFFFFFFFLL;
}
else if ( *(_QWORD *)(a6 + 536) )
{
block_exiting();
if ( *(_DWORD *)a3 == 2 )
{
v10 = strlen((const char *)(a3 + 8));
v11 = (const char *)memcpy((void *)(a6 + 548), (const void *)(a3 + 8), v10);
v12 = *(unsigned __int16 *)(a3 + 40);
*(_DWORD *)(a6 + 544) = 0;
*(_WORD *)(a6 + 580) = v12;
log_print("peer ip:%s, port:%d", v11, v12);
}
else
{
log_print("unknown msg id?????????????????????");
}
block_post(*(_QWORD *)(a6 + 536));
result = 0xFFFFFFFFLL;
}
else
{
log_print("shine block is NULL???????????????????");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, int a4, __int64 a5, __int64 a6)
{
__int64 result; // rax
size_t v10; // rax
const char *v11; // rax
__int64 v12; // rdx

log_print("shine session business calling..................");
if ( a4 <= 0 || a3 == 0 || !a6 )
{
log_print("param is invalid???????????????????????????");
result = 0xFFFFFFFFLL;
}
else if ( *(_QWORD *)(a6 + 536) )
{
block_exiting();
if ( *(_DWORD *)a3 == 2 )
{
v10 = strlen((const char *)(a3 + 8));
v11 = (const char *)memcpy((void *)(a6 + 548), (const void *)(a3 + 8), v10);
v12 = *(unsigned __int16 *)(a3 + 40);
*(_DWORD *)(a6 + 544) = 0;
*(_WORD *)(a6 + 580) = v12;
log_print("peer ip:%s, port:%d", v11, v12);
}
else
{
log_print("unknown msg id?????????????????????");
}
block_post(*(_QWORD *)(a6 + 536));
result = 0xFFFFFFFFLL;
}
else
{
log_print("shine block is NULL???????????????????");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
static int32_t shine_session_business( const struct CSession_t *pThis,
      const CSocket *pSocket,
        const int8u_t *pInData,
        const int32_t iInDataLen,
        const CNetAddr *pNetAddr,
        void *pUserData )
{
 int32_t iRetCode = -1;
 CShine *pShine = (CShine *)pUserData;
 CCommonHeader *pMsgHeader = ((void *)0);
 log_print( "shine session business calling.................." );
 if ( !pShine || !pInData || iInDataLen <= 0 )
 {
  log_print( "param is invalid???????????????????????????" );
  return iRetCode;
 }
 if ( pShine->pBlock )
 {
  block_exiting( pShine->pBlock );
  pMsgHeader = (CCommonHeader *)pInData;
  switch ( pMsgHeader->iMsgId )
  {
  case (0x02):
  {
   AckTellPeer *pAckTellPeerMsg = (AckTellPeer *)pInData;
   memcpy( pShine->pPeerIP, pAckTellPeerMsg->pPeerIP, strlen(pAckTellPeerMsg->pPeerIP) );
   pShine->iPeerPort = pAckTellPeerMsg->iPeerPort;
   pShine->iState = (0);
   log_print( "peer ip:%s, port:%d", pShine->pPeerIP, pShine->iPeerPort );
  }break ;
  default:
  {
   log_print( "unknown msg id?????????????????????" );
  }break ;
  }
  block_post( pShine->pBlock );
 }
 else
  log_print( "shine block is NULL???????????????????" );
 return iRetCode;
}

canonical_original_code:
static int shine_session_business(struct CSession_t *pThis, struct CSocket_t *pSocket, unsigned char *pInData, int iInDataLen, struct CNetAddr_t *pNetAddr, void *pUserData)
{
 int iRetCode = -1;
 struct CShine_t *pShine = (CShine *)pUserData;
 struct CCommonHeader_t *pMsgHeader = ((void *)0);
 log_print( "shine session business calling.................." );
 if ( !pShine || !pInData || iInDataLen <= 0 )
 {
  log_print( "param is invalid???????????????????????????" );
  return iRetCode;
 }
 if ( pShine->pBlock )
 {
  block_exiting( pShine->pBlock );
  pMsgHeader = (struct CCommonHeader_t *)pInData;
  switch ( pMsgHeader->iMsgId )
  {
  case (0x02):
  {
   struct CAckTellPeer_t *pAckTellPeerMsg = (AckTellPeer *)pInData;
   memcpy( pShine->pPeerIP, pAckTellPeerMsg->pPeerIP, strlen(pAckTellPeerMsg->pPeerIP) );
   pShine->iPeerPort = pAckTellPeerMsg->iPeerPort;
   pShine->iState = (0);
   log_print( "peer ip:%s, port:%d", pShine->pPeerIP, pShine->iPeerPort );
  }break ;
  default:
  {
   log_print( "unknown msg id?????????????????????" );
  }break ;
  }
  block_post( pShine->pBlock );
 }
 else
  log_print( "shine block is NULL???????????????????" );
 return iRetCode;
}

variable_types:
pSocket
struct CSocket_t *

variable_types:
pInData
unsigned char *

variable_types: iInDataLen int

variable_types:
pNetAddr
struct CNetAddr_t *

variable_types: struct CShine_t { struct CShineParam_t { char pShineId[-1]; char pServerIP[32]; unsigned short iServerPort; char pLocalIP[-1]; unsigned short iLocalPort; char pUserName[64]; char pUserPassword[64]; int iIsReliable; } stShineParam; struct CTunnel_t { struct CSession_t { int (*init)(struct CSession_t *pThis, struct CSessionParam_t { char pIP[32]; unsigned short iPort; char pLocalIP[32]; unsigned short iLocalPort; } *pParam); void (*release)(struct CSession_t *pThis); int (*handle_input)(struct CSession_t *pThis, struct CSocket_t { int iSocketId; struct CReactor_t { struct CNetEngine_t { int iEngineId; int iIsRunning; struct CThread_t { struct CPine_t { struct CBTreeNode_t {  } BTNode; } PineSuper; void *(*thread)(void *pParam); enum C_THREAD_PRIORITY { OS_THREAD_PRIORITY_LOW=0, OS_THREAD_PRIORITY_NORMAL=1, OS_THREAD_PRIORITY_HIGH=2 } ePriority; void *pParam; unsigned long long iTid; int iQuitFlag; } *pEngineThread; } *pEngine; int (*fReactorCallback)(struct CReactor_t *pReactorId, struct CSocket_t *pSocketId, void *pUserData); struct CQueue_t { struct CQueueNode_t { struct CListNode_t { void *pData; struct CListNode_t *Prev; struct CListNode_t *Next; } LNode; } *Front; struct CQueueNode_t *Rear; int iMaxQueueWaterLevel; int iCurrentQueueWaterLevel; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } Locker; } stSocketRemoveQ; union pthread_mutex_t Locker; void *pUserData; } *pOwnerReactor; void *pUserData; } *pSocket); int (*handle_output)(struct CSession_t *pThis, unsigned char *pOutDatabuf, int iOutDataLen, struct CNetAddr_t { char pIP[32]; unsigned short iPort; unsigned short iLocalPort; } *pNetAddr); int (*handle_business)(struct CSession_t *pThis, struct CSocket_t *pSocket, unsigned char *pInData, int iInDataLen, struct CNetAddr_t *pNetAddr, void *pUserData); int (*handle_event)(struct CSession_t *pThis, enum CSessionEvent_t { EVENT_READ_ERROR=0, EVENT_WRITE_ERROR=1, EVENT_ACCEPT_ERROR=2, EVENT_ACCEPT_NEW_STREAM_CLIENT_NOTIFY=3 } eEvent, struct CEventParam_t { struct CSocket_t *pSocket; struct CNetAddr_t stNetAddr; } *pEventParam, int iEventParamSize, void *pUserData); struct CSessionParam_t stSessionParam; struct CReactor_t *pOwnerReactor; struct CSocket_t *pSocket; struct CNetAddr_t stPeerAddr; int iBlockId; void *pResultCode; void *pUserData; union pthread_mutex_t Locker; } *pSession; } *ppTunnelArray[-1]; int iCurrentTunnelIndex; struct CSession_t *pServerSession; void *pBlock; int iState; char pPeerIP[-1]; unsigned short iPeerPort; union pthread_mutex_t Locker; } *

variable_types: struct CCommonHeader_t { int iMsgId; int iMsgSize; } *

variable_types: struct CAckTellPeer_t { struct CCommonHeader_t { int iMsgId; int iMsgSize; } header; char pPeerIP[-1]; unsigned short iPeerPort; } *

user_defined_types: struct CShine_t { struct CShineParam_t stShineParam; struct CTunnel_t *ppTunnelArray[-1]; int iCurrentTunnelIndex; struct CSession_t *pServerSession; void *pBlock; int iState; char pPeerIP[-1]; unsigned short iPeerPort; union pthread_mutex_t Locker; }

user_defined_types: struct CAckTellPeer_t { struct CCommonHeader_t header; char pPeerIP[-1]; unsigned short iPeerPort; }

user_defined_types: struct CTunnel_t { struct CSession_t *pSession; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }


decompiled_code:
__int64 init_shine()
{
if ( fg_ShineManager )
return 0LL;
word_8BC = -13606;
if ( (int)init_session() < 0 )
return 0xFFFFFFFFLL;
fg_ShineManager = 1;
return init_block();
}

canonical_decompiled_code:
__int64 func4()
{
if ( fg_ShineManager )
return 0LL;
word_8BC = -13606;
if ( (int)init_session() < 0 )
return 0xFFFFFFFFLL;
fg_ShineManager = 1;
return init_block();
}

original_code:
int32_t init_shine( void )
{
 int32_t iRetCode = -1;
 if ( !fg_ShineManager.iInitFlag )
 {
  fg_ShineManager.iLocalPortIndex = 51930;
  if ( init_session( ) >= 0 )
  {
   fg_ShineManager.iInitFlag = 1;
   iRetCode = init_block( );
  }
 }
 else
  iRetCode = 0;
 return iRetCode;
}

canonical_original_code:
int init_shine()
{
 int iRetCode = -1;
 if ( !fg_ShineManager.iInitFlag )
 {
  fg_ShineManager.iLocalPortIndex = 51930;
  if ( init_session( ) >= 0 )
  {
   fg_ShineManager.iInitFlag = 1;
   iRetCode = init_block( );
  }
 }
 else
  iRetCode = 0;
 return iRetCode;
}


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

result = (unsigned int)fg_ShineManager;
if ( fg_ShineManager )
{
release_block();
result = release_session();
fg_ShineManager = 0;
}
return result;
}

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

result = (unsigned int)fg_ShineManager;
if ( fg_ShineManager )
{
release_block();
result = release_session();
fg_ShineManager = 0;
}
return result;
}

original_code:
void release_shine( void )
{
 if ( fg_ShineManager.iInitFlag )
 {
  release_block( );
  release_session( );
  fg_ShineManager.iInitFlag = 0;
 }
}

canonical_original_code:
void release_shine()
{
 if ( fg_ShineManager.iInitFlag )
 {
  release_block( );
  release_session( );
  fg_ShineManager.iInitFlag = 0;
 }
}


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

result = is_shine_manager_ready();
if ( a1 )
{
if ( (int)result >= 0 )
{
lock(a1 + 584);
destroy_session(*(_QWORD *)(a1 + 528));
*(_QWORD *)(a1 + 528) = 0LL;
result = unlock(a1 + 584);
}
}
return result;
}

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

result = func0();
if ( a1 )
{
if ( (int)result >= 0 )
{
lock(a1 + 584);
destroy_session(*(_QWORD *)(a1 + 528));
*(_QWORD *)(a1 + 528) = 0LL;
result = unlock(a1 + 584);
}
}
return result;
}

original_code:
void close_shine( void *pHandle )
{
 if ( is_shine_manager_ready( ) < 0 )
  return ;
 if ( pHandle )
 {
  CShine *pShine = (CShine *)pHandle;
  int32_t i = 0;
  CTunnel *pTunnel = ((void *)0);
  lock( &( pShine->Locker ) );
  for ( i = 0; i < pShine->iCurrentTunnelIndex; i++ )
  {
   pTunnel = pShine->ppTunnelArray[i];
   destroy_tunnel( pTunnel );
  }
  destroy_session( pShine->pServerSession );
  pShine->pServerSession = ((void *)0);
  unlock( &( pShine->Locker ) );
 }
}

canonical_original_code:
void close_shine(void *pHandle)
{
 if ( is_shine_manager_ready( ) < 0 )
  return ;
 if ( pHandle )
 {
  struct CShine_t *pShine = (CShine *)pHandle;
  int i = 0;
  struct CTunnel_t *pTunnel = ((void *)0);
  lock( &( pShine->Locker ) );
  for ( i = 0; i < pShine->iCurrentTunnelIndex; i++ )
  {
   pTunnel = pShine->ppTunnelArray[i];
   destroy_tunnel( pTunnel );
  }
  destroy_session( pShine->pServerSession );
  pShine->pServerSession = ((void *)0);
  unlock( &( pShine->Locker ) );
 }
}

variable_types:
pHandle
void *

variable_types: i int

variable_types: struct CTunnel_t { struct CSession_t { int (*init)(struct CSession_t *pThis, struct CSessionParam_t { char pIP[32]; unsigned short iPort; char pLocalIP[32]; unsigned short iLocalPort; } *pParam); void (*release)(struct CSession_t *pThis); int (*handle_input)(struct CSession_t *pThis, struct CSocket_t { int iSocketId; struct CReactor_t { struct CNetEngine_t { int iEngineId; int iIsRunning; struct CThread_t { struct CPine_t { struct CBTreeNode_t {  } BTNode; } PineSuper; void *(*thread)(void *pParam); enum C_THREAD_PRIORITY { OS_THREAD_PRIORITY_LOW=0, OS_THREAD_PRIORITY_NORMAL=1, OS_THREAD_PRIORITY_HIGH=2 } ePriority; void *pParam; unsigned long long iTid; int iQuitFlag; } *pEngineThread; } *pEngine; int (*fReactorCallback)(struct CReactor_t *pReactorId, struct CSocket_t *pSocketId, void *pUserData); struct CQueue_t { struct CQueueNode_t { struct CListNode_t { void *pData; struct CListNode_t *Prev; struct CListNode_t *Next; } LNode; } *Front; struct CQueueNode_t *Rear; int iMaxQueueWaterLevel; int iCurrentQueueWaterLevel; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } Locker; } stSocketRemoveQ; union pthread_mutex_t Locker; void *pUserData; } *pOwnerReactor; void *pUserData; } *pSocket); int (*handle_output)(struct CSession_t *pThis, unsigned char *pOutDatabuf, int iOutDataLen, struct CNetAddr_t { char pIP[32]; unsigned short iPort; unsigned short iLocalPort; } *pNetAddr); int (*handle_business)(struct CSession_t *pThis, struct CSocket_t *pSocket, unsigned char *pInData, int iInDataLen, struct CNetAddr_t *pNetAddr, void *pUserData); int (*handle_event)(struct CSession_t *pThis, enum CSessionEvent_t { EVENT_READ_ERROR=0, EVENT_WRITE_ERROR=1, EVENT_ACCEPT_ERROR=2, EVENT_ACCEPT_NEW_STREAM_CLIENT_NOTIFY=3 } eEvent, struct CEventParam_t { struct CSocket_t *pSocket; struct CNetAddr_t stNetAddr; } *pEventParam, int iEventParamSize, void *pUserData); struct CSessionParam_t stSessionParam; struct CReactor_t *pOwnerReactor; struct CSocket_t *pSocket; struct CNetAddr_t stPeerAddr; int iBlockId; void *pResultCode; void *pUserData; union pthread_mutex_t Locker; } *pSession; } *

user_defined_types: struct CShineParam_t { char pShineId[-1]; char pServerIP[32]; unsigned short iServerPort; char pLocalIP[-1]; unsigned short iLocalPort; char pUserName[64]; char pUserPassword[64]; int iIsReliable; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


original_code:
int32_t open_shine_tunnel( void *pHandle, int8_t *pPeerShineId )
{
 int32_t iRetCode = -1;
 if ( is_shine_manager_ready( ) < 0 )
  return iRetCode;
 if ( pHandle && pPeerShineId )
 {
  CShine *pShine = (CShine *)pHandle;
  lock( &( pShine->Locker ) );
  if ( pShine->iCurrentTunnelIndex < (32) )
  {
   pShine->ppTunnelArray[pShine->iCurrentTunnelIndex] = create_tunnel( pShine, pPeerShineId, SHINE_ROLE_SHARE_SERVICE );
   if ( pShine->ppTunnelArray[pShine->iCurrentTunnelIndex] )
   {
    (pShine->iCurrentTunnelIndex)++;
    log_print( "create tunnel ok!!!!!!!!!!!!!!!!!!" );
    iRetCode = 0;
   }
   else
    log_print( "create tunnel failed?????????????????" );
  }
  unlock( &( pShine->Locker ) );
 }
 return iRetCode;
}

canonical_original_code:
int open_shine_tunnel(void *pHandle, char *pPeerShineId)
{
 int iRetCode = -1;
 if ( is_shine_manager_ready( ) < 0 )
  return iRetCode;
 if ( pHandle && pPeerShineId )
 {
  struct CShine_t *pShine = (CShine *)pHandle;
  lock( &( pShine->Locker ) );
  if ( pShine->iCurrentTunnelIndex < (32) )
  {
   pShine->ppTunnelArray[pShine->iCurrentTunnelIndex] = create_tunnel( pShine, pPeerShineId, SHINE_ROLE_SHARE_SERVICE );
   if ( pShine->ppTunnelArray[pShine->iCurrentTunnelIndex] )
   {
    (pShine->iCurrentTunnelIndex)++;
    log_print( "create tunnel ok!!!!!!!!!!!!!!!!!!" );
    iRetCode = 0;
   }
   else
    log_print( "create tunnel failed?????????????????" );
  }
  unlock( &( pShine->Locker ) );
 }
 return iRetCode;
}

variable_types:
pPeerShineId
char *

user_defined_types: enum CSessionEvent_t { EVENT_READ_ERROR=0, EVENT_WRITE_ERROR=1, EVENT_ACCEPT_ERROR=2, EVENT_ACCEPT_NEW_STREAM_CLIENT_NOTIFY=3 }

user_defined_types: struct CSessionParam_t { char pIP[32]; unsigned short iPort; char pLocalIP[32]; unsigned short iLocalPort; }

user_defined_types: struct CNetAddr_t { char pIP[32]; unsigned short iPort; unsigned short iLocalPort; }

user_defined_types: struct CEventParam_t { struct CSocket_t *pSocket; struct CNetAddr_t stNetAddr; }

user_defined_types: struct CListNode_t { void *pData; struct CListNode_t *Prev; struct CListNode_t *Next; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }

user_defined_types: enum C_THREAD_PRIORITY { OS_THREAD_PRIORITY_LOW=0, OS_THREAD_PRIORITY_NORMAL=1, OS_THREAD_PRIORITY_HIGH=2 }


decompiled_code:
__int64 close_shine_tunnel()
{
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func8()
{
return 0xFFFFFFFFLL;
}

original_code:
int32_t close_shine_tunnel( void *pHandle, int32_t iTunnelId )
{
 int32_t iRetCode = -1;
 if ( is_shine_manager_ready( ) < 0 )
  return iRetCode;
 return iRetCode;
}

canonical_original_code:
int close_shine_tunnel(void *pHandle, int iTunnelId)
{
 int iRetCode = -1;
 if ( is_shine_manager_ready( ) < 0 )
  return iRetCode;
 return iRetCode;
}

variable_types: iTunnelId int


decompiled_code:
__int64 start_shine_tunnel()
{
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func9()
{
return 0xFFFFFFFFLL;
}

original_code:
int32_t start_shine_tunnel( void *pHandle )
{
 int32_t iRetCode = -1;
 if ( is_shine_manager_ready( ) < 0 )
  return iRetCode;
 return iRetCode;
}

canonical_original_code:
int start_shine_tunnel(void *pHandle)
{
 int iRetCode = -1;
 if ( is_shine_manager_ready( ) < 0 )
  return iRetCode;
 return iRetCode;
}

variable_types: iRetCode int


decompiled_code:
// attributes: thunk
__int64 stop_shine_tunnel()
{
return close_shine_tunnel();
}

canonical_decompiled_code:
__int64 func10()
{
return func8();
}

original_code:
int32_t stop_shine_tunnel( void *pHandle, const int32_t iTunnelId )
{
 int32_t iRetCode = -1;
 if ( is_shine_manager_ready( ) < 0 )
  return iRetCode;
 return iRetCode;
}

canonical_original_code:
int stop_shine_tunnel(void *pHandle, int iTunnelId)
{
 int iRetCode = -1;
 if ( is_shine_manager_ready( ) < 0 )
  return iRetCode;
 return iRetCode;
}


decompiled_code:
__int64 read_shine_data()
{
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func11()
{
return 0xFFFFFFFFLL;
}

original_code:
int32_t read_shine_data( const void *pHandle, int8u_t *pRecvBuf, const int32_t iRecvBufSize )
{
 int32_t iRetCode = -1;
 if ( is_shine_manager_ready( ) < 0 )
  return iRetCode;
 return iRetCode;
}

canonical_original_code:
int read_shine_data(void *pHandle, unsigned char *pRecvBuf, int iRecvBufSize)
{
 int iRetCode = -1;
 if ( is_shine_manager_ready( ) < 0 )
  return iRetCode;
 return iRetCode;
}

variable_types:
pRecvBuf
unsigned char *

variable_types: iRecvBufSize int


decompiled_code:
// attributes: thunk
__int64 write_shine_data()
{
return read_shine_data_constprop_0();
}

canonical_decompiled_code:
__int64 func12()
{
return func3();
}

original_code:
int32_t write_shine_data( const void *pHandle, const int8u_t *pSendBuf, const int32_t iSendBufSize )
{
 int32_t iRetCode = -1;
 if ( is_shine_manager_ready( ) < 0 )
  return iRetCode;
 return iRetCode;
}

canonical_original_code:
int write_shine_data(void *pHandle, unsigned char *pSendBuf, int iSendBufSize)
{
 int iRetCode = -1;
 if ( is_shine_manager_ready( ) < 0 )
  return iRetCode;
 return iRetCode;
}

variable_types:
pSendBuf
unsigned char *

variable_types: iSendBufSize int


InitAll

repo: robn/tinysid

decompiled_code:
__int64 InitAll()
{
PrefsInit();
MemoryInit();
SIDInit();
return CPUInit();
}

canonical_decompiled_code:
__int64 func0()
{
PrefsInit();
MemoryInit();
SIDInit();
return CPUInit();
}

original_code:
void InitAll(int argc, char **argv)
{
    PrefsInit(argc, argv);
    MemoryInit();
    SIDInit();
    CPUInit();
}

variable_types: argc int

variable_types:
argv
char **


ExitAll

decompiled_code:
__int64 ExitAll()
{
CPUExit();
SIDExit();
MemoryExit();
return PrefsExit();
}

canonical_decompiled_code:
__int64 func1()
{
CPUExit();
SIDExit();
MemoryExit();
return PrefsExit();
}

original_code:
void ExitAll()
{
    CPUExit();
    SIDExit();
    MemoryExit();
    PrefsExit();
}


SelectSong

decompiled_code:
__int64 __fastcall SelectSong(int a1)
{
int v1; // eax
__int64 v2; // rdi

if ( number_of_songs > a1 )
{
current_song = a1;
SIDReset(0LL);
if ( a1 > 31 )
goto LABEL_4;
v1 = 1 << a1;
}
else
{
current_song = 0;
SIDReset(0LL);
v1 = 1;
}
if ( (speed_flags & v1) != 0 )
{
v2 = 60LL;
goto LABEL_5;
}
LABEL_4:
v2 = 50LL;
LABEL_5:
SIDSetReplayFreq(v2);
SIDAdjustSpeed(100LL);
return CPUExecute((unsigned __int16)init_adr, (unsigned __int8)current_song, 0LL, 0LL, 1000000LL);
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
int v1; // eax
__int64 v2; // rdi

if ( number_of_songs > a1 )
{
current_song = a1;
SIDReset(0LL);
if ( a1 > 31 )
goto LABEL_4;
v1 = 1 << a1;
}
else
{
current_song = 0;
SIDReset(0LL);
v1 = 1;
}
if ( (speed_flags & v1) != 0 )
{
v2 = 60LL;
goto LABEL_5;
}
LABEL_4:
v2 = 50LL;
LABEL_5:
SIDSetReplayFreq(v2);
SIDAdjustSpeed(100LL);
return CPUExecute((unsigned __int16)init_adr, (unsigned __int8)current_song, 0LL, 0LL, 1000000LL);
}

original_code:
void SelectSong(int num)
{
    if (num >= number_of_songs)
        num = 0;
    current_song = num;
    SIDReset(0);
    int freq = 50;
    if (num < 32)
        freq = speed_flags & (1 << num) ? 60 : 50;
    SIDSetReplayFreq(freq);
    SIDAdjustSpeed(100);
    CPUExecute(init_adr, current_song, 0, 0, 1000000);
}

variable_types: num int

variable_types: freq int


UpdatePlayAdr

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

result = (unsigned int)play_adr_from_irq_vec;
if ( play_adr_from_irq_vec )
{
if ( (*((_BYTE *)&ram + 1) & 2) != 0 )
{
result = *((unsigned __int16 *)&ram + 394);
play_adr = *((_WORD *)&ram + 394);
}
else
{
result = *((unsigned __int16 *)&ram + 0x7FFF);
play_adr = *((_WORD *)&ram + 0x7FFF);
}
}
return result;
}

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

result = (unsigned int)play_adr_from_irq_vec;
if ( play_adr_from_irq_vec )
{
if ( (*((_BYTE *)&ram + 1) & 2) != 0 )
{
result = *((unsigned __int16 *)&ram + 394);
play_adr = *((_WORD *)&ram + 394);
}
else
{
result = *((unsigned __int16 *)&ram + 0x7FFF);
play_adr = *((_WORD *)&ram + 0x7FFF);
}
}
return result;
}

original_code:
void UpdatePlayAdr()
{
    if (play_adr_from_irq_vec) {
        if (ram[1] & 2)
            play_adr = (ram[0x0315] << 8) | ram[0x0314];
        else
            play_adr = (ram[0xffff] << 8) | ram[0xfffe];
    }
}


MemoryExit

decompiled_code:
void MemoryExit()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void MemoryExit()
{
}

canonical_original_code:
void MemoryExit()
{
}


MemoryClear

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

memset(&ram, 0, 0xE000uLL);
*((_BYTE *)&ram + 1) = 7;
memset((void *)(unsigned int)((_DWORD)&ram + 57344), 0x40u, 0x2000uLL);
result = 4294961713LL;
*((_WORD *)&ram + 394) = -5583;
return result;
}

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

memset(&ram, 0, 0xE000uLL);
*((_BYTE *)&ram + 1) = 7;
memset((void *)(unsigned int)((_DWORD)&ram + 57344), 0x40u, 0x2000uLL);
result = 4294961713LL;
*((_WORD *)&ram + 394) = -5583;
return result;
}


MemoryInit

decompiled_code:
__int64 MemoryInit()
{
return MemoryClear();
}

canonical_decompiled_code:
__int64 func2()
{
return func1();
}

original_code:
void MemoryInit()
{
    MemoryClear();
}

canonical_original_code:
void MemoryInit()
{
    MemoryClear();
}


PrefsPrintUsage

decompiled_code:
int PrefsPrintUsage()
{
puts("\nGeneral options:");
print_options_constprop_0();
return puts("\nBoolean options are specified as '--OPTION true|on|yes' or\n'--OPTION false|off|no'.");
}

canonical_decompiled_code:
int func9()
{
puts("\nGeneral options:");
func8();
return puts("\nBoolean options are specified as '--OPTION true|on|yes' or\n'--OPTION false|off|no'.");
}

original_code:
void PrefsPrintUsage()
{
    printf("\nGeneral options:\n");
    print_options(common_prefs_items);
    printf("\nBoolean options are specified as '--OPTION true|on|yes' or\n'--OPTION false|off|no'.\n");
}


PrefsSetCallbackString

decompiled_code:
// attributes: thunk
const char **__fastcall PrefsSetCallbackString(char *a1, const char *a2)
{
return set_callback(a1, a2);
}

canonical_decompiled_code:
const char **__fastcall func11(char *a1, const char *a2)
{
return func2(a1, a2);
}

original_code:
void PrefsSetCallbackString(const char *name, prefs_func_string f)
{
    set_callback(name, (prefs_func)f);
}

canonical_original_code:
void PrefsSetCallbackString(char *name, void (*f)(char *, char *, char *))
{
    set_callback(name, (void (*)(char *, int, int))f);
}

variable_types:
name
char *

variable_types:
f
void (*)(char *, char *, char *)


decompiled_code:
// attributes: thunk
const char **__fastcall PrefsSetCallbackInt32(char *a1, const char *a2)
{
return PrefsSetCallbackString(a1, a2);
}

canonical_decompiled_code:
const char **__fastcall func13(char *a1, const char *a2)
{
return func11(a1, a2);
}

original_code:
void PrefsSetCallbackInt32(const char *name, prefs_func_int32 f)
{
    set_callback(name, (prefs_func)f);
}

canonical_original_code:
void PrefsSetCallbackInt32(char *name, void (*f)(char *, int, int))
{
    set_callback(name, (void (*)(char *, int, int))f);
}

variable_types:
f
void (*)(char *, int, int)


quit

decompiled_code:
void quit(void)
{
ExitAll();
SDL_Quit();
}

canonical_decompiled_code:
void func0(void)
{
ExitAll();
SDL_Quit();
}

original_code:
static void quit()
{
    ExitAll();
    SDL_Quit();
}


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


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

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()
{
__int64 result; // rax

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);
result = 1LL;
ubo_ok = 1;
return result;
}

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

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);
result = 1LL;
ubo_ok = 1;
return result;
}

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


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

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

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

result = 0LL;
v2 = *(_DWORD *)(a1 + 4);
if ( v2 )
{
states_bindBuffer(35345LL, *(unsigned int *)(a1 + 28));
_glewBufferData(35345LL, v2, *(_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 __int64 v6; // rdi
unsigned int v7; // ebp
unsigned __int64 v8; // rax

if ( !a2 )
return 0xFFFFFFFFLL;
if ( !a3 )
return 0xFFFFFFFFLL;
v4 = *(_DWORD *)(a1 + 4);
v6 = *(_QWORD *)(a1 + 16);
v7 = ((ubo_alignment + a2 - 1) & -ubo_alignment) + v4;
v8 = v4;
if ( *(_DWORD *)(a1 + 8) < v7 )
{
v8 = (unsigned __int64)realloc((void *)v6, v7);
*(_DWORD *)(a1 + 8) = v7;
v6 = v4;
*(_QWORD *)(a1 + 16) = v8;
}
memcpy((void *)(v8 + v6), a3, a2);
*(_DWORD *)(a1 + 4) = v7;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int a2, const void *a3)
{
unsigned int v4; // er13
unsigned __int64 v6; // rdi
unsigned int v7; // ebp
unsigned __int64 v8; // rax

if ( !a2 )
return 0xFFFFFFFFLL;
if ( !a3 )
return 0xFFFFFFFFLL;
v4 = *(_DWORD *)(a1 + 4);
v6 = *(_QWORD *)(a1 + 16);
v7 = ((ubo_alignment + a2 - 1) & -ubo_alignment) + v4;
v8 = v4;
if ( *(_DWORD *)(a1 + 8) < v7 )
{
v8 = (unsigned __int64)realloc((void *)v6, v7);
*(_DWORD *)(a1 + 8) = v7;
v6 = v4;
*(_QWORD *)(a1 + 16) = v8;
}
memcpy((void *)(v8 + v6), a3, a2);
*(_DWORD *)(a1 + 4) = v7;
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 __int64 v6; // rdi
unsigned int v7; // er14
unsigned __int64 v8; // rax

if ( !a2 )
return 0xFFFFFFFFLL;
if ( !a3 )
return 0xFFFFFFFFLL;
v4 = *(_DWORD *)(a1 + 4);
v6 = *(_QWORD *)(a1 + 16);
v7 = a2 + v4;
v8 = v4;
if ( *(_DWORD *)(a1 + 8) < a2 + v4 )
{
v8 = (unsigned __int64)realloc((void *)v6, v7);
*(_DWORD *)(a1 + 8) = v7;
v6 = v4;
*(_QWORD *)(a1 + 16) = v8;
}
memcpy((void *)(v8 + v6), a3, a2);
*(_DWORD *)(a1 + 4) = v7;
return v4;
}

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

if ( !a2 )
return 0xFFFFFFFFLL;
if ( !a3 )
return 0xFFFFFFFFLL;
v4 = *(_DWORD *)(a1 + 4);
v6 = *(_QWORD *)(a1 + 16);
v7 = a2 + v4;
v8 = v4;
if ( *(_DWORD *)(a1 + 8) < a2 + v4 )
{
v8 = (unsigned __int64)realloc((void *)v6, v7);
*(_DWORD *)(a1 + 8) = v7;
v6 = v4;
*(_QWORD *)(a1 + 16) = v8;
}
memcpy((void *)(v8 + v6), a3, a2);
*(_DWORD *)(a1 + 4) = v7;
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; // er12
__int64 result; // rax
void *v3; // rax

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

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
unsigned int v1; // er12
__int64 result; // rax
void *v3; // rax

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

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


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)
{
size_t v1; // rsi

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

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
size_t v1; // rsi

v1 = *(unsigned int *)(a1 + 4);
*(_DWORD *)(a1 + 8) = v1;
*(_QWORD *)(a1 + 16) = realloc(*(void **)(a1 + 16), v1);
return (unsigned int)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)
{
__int64 result; // rax
char *v2; // rbx
bool v3; // cc
int v4; // eax
char v5; // si
__int64 v6; // rdx
_BYTE *v7; // r8
int v8; // er9
int v9; // er10

result = 0LL;
v2 = (char *)ubo_list + 32 * (unsigned __int16)a1;
if ( *(_DWORD *)v2 != a1 )
return result;
_glewDeleteBuffers(1LL, v2 + 28);
*(_OWORD *)v2 = 0LL;
v3 = ubo_arrayfirstopen <= (unsigned __int16)a1;
*((_OWORD *)v2 + 1) = 0LL;
if ( !v3 )
ubo_arrayfirstopen = (unsigned __int16)a1;
v4 = ubo_arraylasttaken;
if ( ubo_arraylasttaken <= 0 )
return 1LL;
v5 = 0;
v6 = 32LL * ubo_arraylasttaken;
v7 = (char *)ubo_list + v6 + 24;
v8 = ubo_arraylasttaken & 7;
if ( (ubo_arraylasttaken & 7) == 0 )
goto LABEL_26;
if ( v8 != 1 )
{
switch ( v8 )
{
case 2:
LABEL_22:
if ( *v7 )
goto LABEL_37;
--v4;
v7 -= 32;
v5 = 1;
goto LABEL_24;
case 3:
LABEL_20:
if ( *v7 )
goto LABEL_37;
--v4;
v7 -= 32;
v5 = 1;
goto LABEL_22;
case 4:
LABEL_18:
if ( *v7 )
goto LABEL_37;
--v4;
v7 -= 32;
v5 = 1;
goto LABEL_20;
case 5:
LABEL_16:
if ( *v7 )
goto LABEL_37;
--v4;
v7 -= 32;
v5 = 1;
goto LABEL_18;
case 6:
LABEL_14:
if ( *v7 )
goto LABEL_37;
--v4;
v7 -= 32;
v5 = 1;
goto LABEL_16;
}
if ( !*v7 )
{
v4 = ubo_arraylasttaken - 1;
v7 = (char *)ubo_list + v6 - 8;
v5 = 1;
goto LABEL_14;
}
return 1LL;
}
LABEL_24:
if ( *v7 )
goto LABEL_37;
v7 -= 32;
v5 = 1;
if ( --v4 )
{
LABEL_26:
while ( !*v7 )
{
v9 = --v4;
if ( *(v7 - 32) )
goto LABEL_38;
--v4;
if ( *(v7 - 64) )
goto LABEL_38;
v4 = v9 - 2;
if ( *(v7 - 96) )
goto LABEL_38;
v4 = v9 - 3;
if ( *(v7 - 128) )
goto LABEL_38;
v4 = v9 - 4;
if ( *(v7 - 160) )
goto LABEL_38;
v4 = v9 - 5;
if ( *(v7 - 192) )
goto LABEL_38;
v4 = v9 - 6;
if ( *(v7 - 224) )
goto LABEL_38;
v7 -= 256;
v5 = 1;
v4 = v9 - 7;
if ( v9 == 7 )
goto LABEL_35;
}
LABEL_37:
if ( v5 )
LABEL_38:
ubo_arraylasttaken = v4;
return 1LL;
}
LABEL_35:
ubo_arraylasttaken = 0;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
__int64 result; // rax
char *v2; // rbx
bool v3; // cc
int v4; // eax
char v5; // si
__int64 v6; // rdx
_BYTE *v7; // r8
int v8; // er9
int v9; // er10

result = 0LL;
v2 = (char *)ubo_list + 32 * (unsigned __int16)a1;
if ( *(_DWORD *)v2 != a1 )
return result;
_glewDeleteBuffers(1LL, v2 + 28);
*(_OWORD *)v2 = 0LL;
v3 = ubo_arrayfirstopen <= (unsigned __int16)a1;
*((_OWORD *)v2 + 1) = 0LL;
if ( !v3 )
ubo_arrayfirstopen = (unsigned __int16)a1;
v4 = ubo_arraylasttaken;
if ( ubo_arraylasttaken <= 0 )
return 1LL;
v5 = 0;
v6 = 32LL * ubo_arraylasttaken;
v7 = (char *)ubo_list + v6 + 24;
v8 = ubo_arraylasttaken & 7;
if ( (ubo_arraylasttaken & 7) == 0 )
goto LABEL_26;
if ( v8 != 1 )
{
switch ( v8 )
{
case 2:
LABEL_22:
if ( *v7 )
goto LABEL_37;
--v4;
v7 -= 32;
v5 = 1;
goto LABEL_24;
case 3:
LABEL_20:
if ( *v7 )
goto LABEL_37;
--v4;
v7 -= 32;
v5 = 1;
goto LABEL_22;
case 4:
LABEL_18:
if ( *v7 )
goto LABEL_37;
--v4;
v7 -= 32;
v5 = 1;
goto LABEL_20;
case 5:
LABEL_16:
if ( *v7 )
goto LABEL_37;
--v4;
v7 -= 32;
v5 = 1;
goto LABEL_18;
case 6:
LABEL_14:
if ( *v7 )
goto LABEL_37;
--v4;
v7 -= 32;
v5 = 1;
goto LABEL_16;
}
if ( !*v7 )
{
v4 = ubo_arraylasttaken - 1;
v7 = (char *)ubo_list + v6 - 8;
v5 = 1;
goto LABEL_14;
}
return 1LL;
}
LABEL_24:
if ( *v7 )
goto LABEL_37;
v7 -= 32;
v5 = 1;
if ( --v4 )
{
LABEL_26:
while ( !*v7 )
{
v9 = --v4;
if ( *(v7 - 32) )
goto LABEL_38;
--v4;
if ( *(v7 - 64) )
goto LABEL_38;
v4 = v9 - 2;
if ( *(v7 - 96) )
goto LABEL_38;
v4 = v9 - 3;
if ( *(v7 - 128) )
goto LABEL_38;
v4 = v9 - 4;
if ( *(v7 - 160) )
goto LABEL_38;
v4 = v9 - 5;
if ( *(v7 - 192) )
goto LABEL_38;
v4 = v9 - 6;
if ( *(v7 - 224) )
goto LABEL_38;
v7 -= 256;
v5 = 1;
v4 = v9 - 7;
if ( v9 == 7 )
goto LABEL_35;
}
LABEL_37:
if ( v5 )
LABEL_38:
ubo_arraylasttaken = v4;
return 1LL;
}
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; // edi
int v9; // esi
int v10; // ecx
char v11; // bl
char *v12; // r8
char *v13; // rdx
int v14; // er10
__m128i *v15; // rax
int v16; // er10
__m128i v17; // xmm1
unsigned int v18; // esi
bool v19; // cc

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

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int128 a7, __int128 a8)
{
int v8; // edi
int v9; // esi
int v10; // ecx
char v11; // bl
char *v12; // r8
char *v13; // rdx
int v14; // er10
__m128i *v15; // rax
int v16; // er10
__m128i v17; // xmm1
unsigned int v18; // esi
bool v19; // cc

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

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

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
double v4; // xmm8_8
double v5; // xmm0_8
double v6; // xmm1_8
double v7; // r14
double v8; // xmm0_8
double v9; // [rsp+8h] [rbp-30h]
double v10; // [rsp+10h] [rbp-28h]
double v11; // [rsp+18h] [rbp-20h]

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() )
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");
v3 = 0;
v11 = glfwGetTime();
v9 = 0.0;
v10 = 0.0;
while ( 1 )
{
v5 = glfwGetTime();
v6 = v5 - v11;
v7 = v5;
v10 = v10 + v5 - v11;
if ( v10 <= 10.0 )
{
v9 = v6 + v9;
glfw_checkEvent();
if ( 1000.0 * v9 <= 16.66666603088379 )
goto LABEL_14;
}
else
{
v8 = (double)v3 / v10;
v3 = 0;
console_printf("%f fps\n", v8);
v10 = v10 - 10.0;
v9 = v6 + v9;
glfw_checkEvent();
if ( 1000.0 * v9 <= 16.66666603088379 )
goto LABEL_14;
}
do
{
gameCodeTick();
v4 = 1000.0 * (v9 - 0.01666666666666667);
v9 = v9 - 0.01666666666666667;
}
while ( v4 > 16.66666603088379 );
LABEL_14:
glMainDraw();
v11 = v7;
++v3;
}
}

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()
{
__int64 result; // rax

memset(&cvarhashtable, 0, 0xC00uLL);
if ( cvar_list )
{
free(cvar_list);
result = 1LL;
cvar_list = 0LL;
cvar_ok = 1;
}
else
{
cvar_ok = 1;
result = 1LL;
}
return result;
}

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

memset(&cvarhashtable, 0, 0xC00uLL);
if ( cvar_list )
{
free(cvar_list);
result = 1LL;
cvar_list = 0LL;
cvar_ok = 1;
}
else
{
cvar_ok = 1;
result = 1LL;
}
return result;
}

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; // rbx
_DWORD *v2; // r12
__int64 result; // rax
int v5; // er13
__int64 v6; // rdi
char v7; // r14
void *v8; // rdi
void *v9; // rdi
char *v10; // rdx
bool v11; // cc
int v12; // ebx
char v13; // si
char *v14; // r9
int v15; // er10
int v16; // er11

v1 = (unsigned __int16)a1;
v2 = (_DWORD *)*((_QWORD *)cvar_list + (unsigned __int16)a1);
if ( !v2 )
return 0LL;
result = 0LL;
if ( v2[19] == a1 )
{
v5 = (unsigned __int16)a1;
v6 = *((_QWORD *)v2 + 1);
if ( v6 )
{
v7 = *(_BYTE *)v2;
if ( (*(_BYTE *)v2 & 1) != 0 )
{
if ( *((_QWORD *)v2 + 8) )
{
free(*((void **)v2 + 8));
v6 = *((_QWORD *)v2 + 1);
}
deleteFromHashTable(v6, a1, &cvarhashtable);
*(_BYTE *)v2 &= 0xFEu;
if ( (v7 & 2) != 0 )
{
v8 = (void *)*((_QWORD *)v2 + 1);
if ( v8 )
free(v8);
v9 = (void *)*((_QWORD *)v2 + 2);
if ( v9 )
free(v9);
free(v2);
}
v10 = (char *)cvar_list;
v11 = cvar_arrayfirstopen <= v5;
*((_QWORD *)cvar_list + v1) = 0LL;
if ( !v11 )
cvar_arrayfirstopen = v5;
v12 = cvar_arraylasttaken;
if ( cvar_arraylasttaken > 0 )
{
v13 = 0;
v14 = &v10[8 * cvar_arraylasttaken];
v15 = cvar_arraylasttaken & 7;
if ( (cvar_arraylasttaken & 7) == 0 )
goto LABEL_37;
switch ( v15 )
{
case 1:
LABEL_35:
if ( *(_QWORD *)v14 )
goto LABEL_48;
v14 -= 8;
v13 = 1;
if ( --v12 )
{
LABEL_37:
while ( !*(_QWORD *)v14 )
{
v16 = v12 - 1;
v13 = 1;
--v12;
if ( *((_QWORD *)v14 - 1) )
goto LABEL_49;
--v12;
if ( *((_QWORD *)v14 - 2) )
goto LABEL_49;
v12 = v16 - 2;
if ( *((_QWORD *)v14 - 3) )
goto LABEL_49;
v12 = v16 - 3;
if ( *((_QWORD *)v14 - 4) )
goto LABEL_49;
v12 = v16 - 4;
if ( *((_QWORD *)v14 - 5) )
goto LABEL_49;
v12 = v16 - 5;
if ( *((_QWORD *)v14 - 6) )
goto LABEL_49;
v12 = v16 - 6;
if ( *((_QWORD *)v14 - 7) )
goto LABEL_49;
v14 -= 64;
v12 = v16 - 7;
if ( v16 == 7 )
goto LABEL_46;
}
LABEL_48:
if ( v13 )
LABEL_49:
cvar_arraylasttaken = v12;
return 1LL;
}
LABEL_46:
cvar_arraylasttaken = 0;
return 1LL;
case 2:
LABEL_33:
if ( *(_QWORD *)v14 )
goto LABEL_48;
--v12;
v14 -= 8;
v13 = 1;
goto LABEL_35;
case 3:
LABEL_31:
if ( *(_QWORD *)v14 )
goto LABEL_48;
--v12;
v14 -= 8;
v13 = 1;
goto LABEL_33;
case 4:
LABEL_29:
if ( *(_QWORD *)v14 )
goto LABEL_48;
--v12;
v14 -= 8;
v13 = 1;
goto LABEL_31;
case 5:
LABEL_27:
if ( *(_QWORD *)v14 )
goto LABEL_48;
--v12;
v14 -= 8;
v13 = 1;
goto LABEL_29;
case 6:
LABEL_25:
if ( *(_QWORD *)v14 )
goto LABEL_48;
--v12;
v14 -= 8;
v13 = 1;
goto LABEL_27;
}
if ( !*(_QWORD *)v14 )
{
v12 = cvar_arraylasttaken - 1;
v14 -= 8;
v13 = 1;
goto LABEL_25;
}
}
return 1LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1)
{
__int64 v1; // rbx
_DWORD *v2; // r12
__int64 result; // rax
int v5; // er13
__int64 v6; // rdi
char v7; // r14
void *v8; // rdi
void *v9; // rdi
char *v10; // rdx
bool v11; // cc
int v12; // ebx
char v13; // si
char *v14; // r9
int v15; // er10
int v16; // er11

v1 = (unsigned __int16)a1;
v2 = (_DWORD *)*((_QWORD *)cvar_list + (unsigned __int16)a1);
if ( !v2 )
return 0LL;
result = 0LL;
if ( v2[19] == a1 )
{
v5 = (unsigned __int16)a1;
v6 = *((_QWORD *)v2 + 1);
if ( v6 )
{
v7 = *(_BYTE *)v2;
if ( (*(_BYTE *)v2 & 1) != 0 )
{
if ( *((_QWORD *)v2 + 8) )
{
free(*((void **)v2 + 8));
v6 = *((_QWORD *)v2 + 1);
}
deleteFromHashTable(v6, a1, &cvarhashtable);
*(_BYTE *)v2 &= 0xFEu;
if ( (v7 & 2) != 0 )
{
v8 = (void *)*((_QWORD *)v2 + 1);
if ( v8 )
free(v8);
v9 = (void *)*((_QWORD *)v2 + 2);
if ( v9 )
free(v9);
free(v2);
}
v10 = (char *)cvar_list;
v11 = cvar_arrayfirstopen <= v5;
*((_QWORD *)cvar_list + v1) = 0LL;
if ( !v11 )
cvar_arrayfirstopen = v5;
v12 = cvar_arraylasttaken;
if ( cvar_arraylasttaken > 0 )
{
v13 = 0;
v14 = &v10[8 * cvar_arraylasttaken];
v15 = cvar_arraylasttaken & 7;
if ( (cvar_arraylasttaken & 7) == 0 )
goto LABEL_37;
switch ( v15 )
{
case 1:
LABEL_35:
if ( *(_QWORD *)v14 )
goto LABEL_48;
v14 -= 8;
v13 = 1;
if ( --v12 )
{
LABEL_37:
while ( !*(_QWORD *)v14 )
{
v16 = v12 - 1;
v13 = 1;
--v12;
if ( *((_QWORD *)v14 - 1) )
goto LABEL_49;
--v12;
if ( *((_QWORD *)v14 - 2) )
goto LABEL_49;
v12 = v16 - 2;
if ( *((_QWORD *)v14 - 3) )
goto LABEL_49;
v12 = v16 - 3;
if ( *((_QWORD *)v14 - 4) )
goto LABEL_49;
v12 = v16 - 4;
if ( *((_QWORD *)v14 - 5) )
goto LABEL_49;
v12 = v16 - 5;
if ( *((_QWORD *)v14 - 6) )
goto LABEL_49;
v12 = v16 - 6;
if ( *((_QWORD *)v14 - 7) )
goto LABEL_49;
v14 -= 64;
v12 = v16 - 7;
if ( v16 == 7 )
goto LABEL_46;
}
LABEL_48:
if ( v13 )
LABEL_49:
cvar_arraylasttaken = v12;
return 1LL;
}
LABEL_46:
cvar_arraylasttaken = 0;
return 1LL;
case 2:
LABEL_33:
if ( *(_QWORD *)v14 )
goto LABEL_48;
--v12;
v14 -= 8;
v13 = 1;
goto LABEL_35;
case 3:
LABEL_31:
if ( *(_QWORD *)v14 )
goto LABEL_48;
--v12;
v14 -= 8;
v13 = 1;
goto LABEL_33;
case 4:
LABEL_29:
if ( *(_QWORD *)v14 )
goto LABEL_48;
--v12;
v14 -= 8;
v13 = 1;
goto LABEL_31;
case 5:
LABEL_27:
if ( *(_QWORD *)v14 )
goto LABEL_48;
--v12;
v14 -= 8;
v13 = 1;
goto LABEL_29;
case 6:
LABEL_25:
if ( *(_QWORD *)v14 )
goto LABEL_48;
--v12;
v14 -= 8;
v13 = 1;
goto LABEL_27;
}
if ( !*(_QWORD *)v14 )
{
v12 = cvar_arraylasttaken - 1;
v14 -= 8;
v13 = 1;
goto LABEL_25;
}
}
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 v3; // eax
void *v4; // rdi
size_t v5; // r13
int v6; // ebx
float v7; // xmm0_4
int v8; // eax
void (__fastcall *v9)(__int64); // rcx
int v10; // eax
void *v11; // rax

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

canonical_decompiled_code:
void __fastcall func5(__int64 a1, const char *a2)
{
int v3; // eax
void *v4; // rdi
size_t v5; // r13
int v6; // ebx
float v7; // xmm0_4
int v8; // eax
void (__fastcall *v9)(__int64); // rcx
int v10; // eax
void *v11; // rax

if ( a1 )
{
if ( *(_DWORD *)(a1 + 72) )
{
if ( (unsigned int)string_testEqual(a2, *(_QWORD *)(a1 + 64)) )
return;
v10 = strlen(a2);
v4 = *(void **)(a1 + 64);
v5 = (unsigned int)(v10 + 1);
v6 = v5;
if ( *(_DWORD *)(a1 + 72) == (_DWORD)v5 )
goto LABEL_9;
}
else
{
v3 = strlen(a2);
v4 = *(void **)(a1 + 64);
v5 = (unsigned int)(v3 + 1);
v6 = v3 + 1;
if ( v3 == -1 )
goto LABEL_4;
}
v11 = realloc(v4, v5);
*(_DWORD *)(a1 + 72) = v6;
*(_QWORD *)(a1 + 64) = v11;
v4 = v11;
LABEL_9:
memcpy(v4, a2, v5);
LABEL_4:
v7 = atof(a2);
*(float *)(a1 + 44) = v7;
*(_DWORD *)(a1 + 40) = (int)v7;
string_toVec(a2, a1 + 48, 3LL);
v8 = string_testEqual(a2, *(_QWORD *)(a1 + 24));
v9 = *(void (__fastcall **)(__int64))(a1 + 32);
*(_BYTE *)(a1 + 80) = v8 == 0;
if ( v9 )
v9(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