decompiled_code:
__int64 __fastcall simos_memory_alloc(unsigned __int64 *a1, unsigned __int64 a2)
{
unsigned __int64 v4; // r8
int v5; // ecx
int v6; // edx
unsigned __int64 v7; // rsi
unsigned __int64 v8; // r9
unsigned __int64 v9; // rax
__int64 v10; // r10
__int64 v11; // rdx
__int64 result; // rax
unsigned __int64 v13; // rdi

v4 = *a1;
v5 = 0;
v6 = 0;
while ( 1 )
{
while ( 1 )
{
v7 = v6;
if ( v6 >= v4 )
goto LABEL_4;
v8 = a1[1];
if ( !*(_BYTE *)(v8 + v6) )
break;
++v6;
}
v9 = v6;
v10 = v5 - (__int64)v6;
if ( a2 > v5 )
{
while ( 1 )
{
if ( *(_BYTE *)(v8 + v9) )
{
v7 = v9;
goto LABEL_4;
}
++v6;
++v5;
if ( v4 <= ++v9 )
break;
if ( a2 <= v10 + v9 )
{
v7 = v9;
goto LABEL_4;
}
}
v7 = v9;
}
LABEL_4:
if ( v5 == a2 )
break;
if ( v4 < v7 )
return -1LL;
}
LODWORD(v11) = v6 - a2;
result = (int)v11;
v13 = (int)v11 + a2;
if ( (int)v11 < v13 )
{
v11 = (int)v11;
do
*(_BYTE *)(a1[1] + v11++) = 1;
while ( v11 != v13 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func24(unsigned __int64 *a1, unsigned __int64 a2)
{
unsigned __int64 v4; // r8
int v5; // ecx
int v6; // edx
unsigned __int64 v7; // rsi
unsigned __int64 v8; // r9
unsigned __int64 v9; // rax
__int64 v10; // r10
__int64 v11; // rdx
__int64 result; // rax
unsigned __int64 v13; // rdi

v4 = *a1;
v5 = 0;
v6 = 0;
while ( 1 )
{
while ( 1 )
{
v7 = v6;
if ( v6 >= v4 )
goto LABEL_4;
v8 = a1[1];
if ( !*(_BYTE *)(v8 + v6) )
break;
++v6;
}
v9 = v6;
v10 = v5 - (__int64)v6;
if ( a2 > v5 )
{
while ( 1 )
{
if ( *(_BYTE *)(v8 + v9) )
{
v7 = v9;
goto LABEL_4;
}
++v6;
++v5;
if ( v4 <= ++v9 )
break;
if ( a2 <= v10 + v9 )
{
v7 = v9;
goto LABEL_4;
}
}
v7 = v9;
}
LABEL_4:
if ( v5 == a2 )
break;
if ( v4 < v7 )
return -1LL;
}
LODWORD(v11) = v6 - a2;
result = (int)v11;
v13 = (int)v11 + a2;
if ( (int)v11 < v13 )
{
v11 = (int)v11;
do
*(_BYTE *)(a1[1] + v11++) = 1;
while ( v11 != v13 );
}
return result;
}

original_code:
size_t simos_memory_alloc(simos_memory_t *mem, size_t block)
{
    int i = 0, available = 0, pointer;
    while (1) {
        while (i < mem->size && mem->cells[i] != 0) {
            i++;
        }
        while (i < mem->size && available < block && mem->cells[i] == 0) {
            i++;
            available++;
        }
        if (available == block) {
            pointer = i - block;
            for (i = pointer; i < (pointer + block); i++) {
                mem->cells[i] = 1;
            }
            return pointer;
        } else if (i > mem->size) {
            return -1;
        }
    }
}

canonical_original_code:
unsigned long simos_memory_alloc(struct simos_memory_t *mem, unsigned long block)
{
    int i = 0; int available = 0; int pointer;
    while (1) {
        while (i < mem->size && mem->cells[i] != 0) {
            i++;
        }
        while (i < mem->size && available < block && mem->cells[i] == 0) {
            i++;
            available++;
        }
        if (available == block) {
            pointer = i - block;
            for (i = pointer; i < (pointer + block); i++) {
                mem->cells[i] = 1;
            }
            return pointer;
        } else if (i > mem->size) {
            return -1;
        }
    }
}

variable_types:
block
unsigned long

variable_types: i int

variable_types: available int

variable_types: pointer int

return_type: unsigned long


repo: ljr-ifsp/simos

decompiled_code:
unsigned __int64 __fastcall simos_memory_free(__int64 a1, __int64 a2, __int64 a3)
{
unsigned __int64 result; // rax
unsigned __int64 v4; // rsi

result = (int)a2;
v4 = a3 + a2;
if ( result < v4 )
{
do
*(_BYTE *)(*(_QWORD *)(a1 + 8) + result++) = 0;
while ( result != v4 );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func25(__int64 a1, __int64 a2, __int64 a3)
{
unsigned __int64 result; // rax
unsigned __int64 v4; // rsi

result = (int)a2;
v4 = a3 + a2;
if ( result < v4 )
{
do
*(_BYTE *)(*(_QWORD *)(a1 + 8) + result++) = 0;
while ( result != v4 );
}
return result;
}

original_code:
void simos_memory_free(simos_memory_t *mem, size_t pointer, size_t length)
{
    int i;
    for (i = pointer; i < (pointer + length); i++) {
        mem->cells[i] = 0;
    }
}

canonical_original_code:
void simos_memory_free(struct simos_memory_t *mem, unsigned long pointer, unsigned long length)
{
    int i;
    for (i = pointer; i < (pointer + length); i++) {
        mem->cells[i] = 0;
    }
}

variable_types: struct simos_memory_t { unsigned long size; unsigned char *cells; } *

variable_types:
pointer
unsigned long

variable_types:
length
unsigned long

return_type: void


decompiled_code:
_BOOL8 __fastcall simos_list_empty(_QWORD *a1)
{
return *a1 == 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(_QWORD *a1)
{
return *a1 == 0LL;
}

original_code:
int simos_list_empty(simos_list_t *list)
{
 return list->head == ((void *)0);
}

canonical_original_code:
int simos_list_empty(struct simos_list *list)
{
 return list->head == ((void *)0);
}

variable_types: struct simos_list { struct simos_list_node { void *data; struct simos_list_node *next; struct simos_list_node *prev; } *head; struct simos_list_node *tail; } *

return_type: int

user_defined_types: struct simos_list { struct simos_list_node *head; struct simos_list_node *tail; }


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

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

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

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

original_code:
simos_list_t *simos_list_new()
{
 simos_list_t *l = malloc(sizeof(simos_list_t));
 l->head = ((void *)0);
 l->tail = ((void *)0);
 return l;
}

canonical_original_code:
struct simos_list *simos_list_new()
{
 struct simos_list *l = malloc(sizeof(simos_list_t));
 l->head = ((void *)0);
 l->tail = ((void *)0);
 return l;
}

return_type: struct simos_list { struct simos_list_node { void *data; struct simos_list_node *next; struct simos_list_node *prev; } *head; struct simos_list_node *tail; } *


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

v1 = *a1;
if ( simos_list_empty(a1) )
return 0LL;
if ( a1[1] == v1 )
{
*a1 = 0LL;
a1[1] = 0LL;
}
else
{
*(_QWORD *)(*(_QWORD *)(v1 + 8) + 16LL) = 0LL;
*a1 = *(_QWORD *)(*a1 + 8LL);
}
return v1;
}

original_code:
simos_list_node_t *simos_list_del_head(simos_list_t *list)
{
 simos_list_node_t *n = list->head;
 if (simos_list_empty(list)) {
  return ((void *)0);
 }
 if (list->head == list->tail) {
  list->head = ((void *)0);
  list->tail = ((void *)0);
 } else {
  list->head->next->prev = ((void *)0);
  list->head = list->head->next;
 }
 return n;
}

canonical_original_code:
struct simos_list_node *simos_list_del_head(struct simos_list *list)
{
 struct simos_list_node *n = list->head;
 if (simos_list_empty(list)) {
  return ((void *)0);
 }
 if (list->head == list->tail) {
  list->head = ((void *)0);
  list->tail = ((void *)0);
 } else {
  list->head->next->prev = ((void *)0);
  list->head = list->head->next;
 }
 return n;
}

variable_types: struct simos_list { struct simos_list_node *head; struct simos_list_node *tail; } *

variable_types: struct simos_list_node { void *data; struct simos_list_node *next; struct simos_list_node *prev; } *


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

v1 = a1[1];
if ( simos_list_empty(a1) )
return 0LL;
if ( *a1 == v1 )
{
*a1 = 0LL;
a1[1] = 0LL;
}
else
{
*(_QWORD *)(*(_QWORD *)(v1 + 16) + 8LL) = 0LL;
a1[1] = *(_QWORD *)(a1[1] + 16LL);
}
return v1;
}

original_code:
simos_list_node_t *simos_list_del_tail(simos_list_t *list)
{
 simos_list_node_t *n = list->tail;
 if (simos_list_empty(list)) {
  return ((void *)0);
 }
 if (list->head == list->tail) {
  list->head = ((void *)0);
  list->tail = ((void *)0);
 } else {
  list->tail->prev->next = ((void *)0);
  list->tail = list->tail->prev;
 }
 return n;
}

canonical_original_code:
struct simos_list_node *simos_list_del_tail(struct simos_list *list)
{
 struct simos_list_node *n = list->tail;
 if (simos_list_empty(list)) {
  return ((void *)0);
 }
 if (list->head == list->tail) {
  list->head = ((void *)0);
  list->tail = ((void *)0);
 } else {
  list->tail->prev->next = ((void *)0);
  list->tail = list->tail->prev;
 }
 return n;
}

return_type: struct simos_list_node { void *data; struct simos_list_node *next; struct simos_list_node *prev; } *


original_code:
int simos_list_del(simos_list_t *list, simos_list_node_t *node)
{
 simos_list_node_t *n;
 if (simos_list_empty(list)) {
  return 0;
 }
 for ((n) = ((list)->head); (n); (n) = ((n)->next)) {
  if (n->next == node->next && n->prev == node->prev) {
   if (n == list->head) {
    simos_list_del_head(list);
   } else if (n == list->tail) {
    simos_list_del_tail(list);
   } else {
    n->prev->next = n->next;
    n->next->prev = n->prev;
   }
   return 1;
  }
 }
 return 0;
}

canonical_original_code:
int simos_list_del(struct simos_list *list, struct simos_list_node *node)
{
 struct simos_list_node *n;
 if (simos_list_empty(list)) {
  return 0;
 }
 for ((n) = ((list)->head); (n); (n) = ((n)->next)) {
  if (n->next == node->next && n->prev == node->prev) {
   if (n == list->head) {
    simos_list_del_head(list);
   } else if (n == list->tail) {
    simos_list_del_tail(list);
   } else {
    n->prev->next = n->next;
    n->next->prev = n->prev;
   }
   return 1;
  }
 }
 return 0;
}

variable_types:
node
struct simos_list_node *

user_defined_types: struct simos_list_node { void *data; struct simos_list_node *next; struct simos_list_node *prev; }


decompiled_code:
void __fastcall simos_list_free(__int64 *a1)
{
__int64 i; // rbx

for ( i = *a1; i; i = *(_QWORD *)(i + 8) )
{
free(*(void **)i);
free((void *)i);
}
*a1 = 0LL;
a1[1] = 0LL;
}

original_code:
void simos_list_free(simos_list_t *list)
{
 simos_list_node_t *n;
 for ((n) = ((list)->head); (n); (n) = ((n)->next)) {
  free(n->data);
  free(n);
 }
 list->head = ((void *)0);
 list->tail = ((void *)0);
}

canonical_original_code:
void simos_list_free(struct simos_list *list)
{
 struct simos_list_node *n;
 for ((n) = ((list)->head); (n); (n) = ((n)->next)) {
  free(n->data);
  free(n);
 }
 list->head = ((void *)0);
 list->tail = ((void *)0);
}


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

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

original_code:
void simos_process_destroy(simos_process_t *proc)
{
 free(proc);
}

canonical_original_code:
void simos_process_destroy(struct simos_process_t *proc)
{
 free(proc);
}

variable_types: struct simos_process_t { int pid; unsigned long required_execution_time; unsigned long turnaround_time; unsigned long required_memory; unsigned long memory_pointer; unsigned long entry_time; unsigned long out_time; } *


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

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

original_code:
simos_process_t *simos_node_to_process(simos_list_node_t *node)
{
 return ((simos_process_t *) node->data);
}

canonical_original_code:
struct simos_process_t *simos_node_to_process(struct simos_list_node *node)
{
 return ((struct simos_process_t *) node->data);
}

return_type: struct simos_process_t { int pid; unsigned long required_execution_time; unsigned long turnaround_time; unsigned long required_memory; unsigned long memory_pointer; unsigned long entry_time; unsigned long out_time; } *


decompiled_code:
_QWORD *simos_scheduler_new()
{
_QWORD *v0; // rbx

v0 = malloc(8uLL);
*v0 = simos_list_new();
return v0;
}

canonical_decompiled_code:
_QWORD *func18()
{
_QWORD *v0; // rbx

v0 = malloc(8uLL);
*v0 = func9();
return v0;
}

original_code:
simos_scheduler_t *simos_scheduler_new()
{
 simos_scheduler_t *s = malloc(sizeof(simos_scheduler_t));
 s->ready = simos_list_new();
 return s;
}

canonical_original_code:
struct simos_scheduler_t *simos_scheduler_new()
{
 struct simos_scheduler_t *s = malloc(sizeof(simos_scheduler_t));
 s->ready = simos_list_new();
 return s;
}

variable_types: struct simos_scheduler_t { struct simos_list { struct simos_list_node { void *data; struct simos_list_node *next; struct simos_list_node *prev; } *head; struct simos_list_node *tail; } *ready; } *

user_defined_types: struct simos_scheduler_t { struct simos_list *ready; }


decompiled_code:
__int64 __fastcall simos_process_list_del(__int64 *a1, int a2)
{
__int64 v2; // rsi
__int64 result; // rax

v2 = simos_process_list_search(a1, a2);
result = 0LL;
if ( v2 )
result = simos_list_del(a1, v2);
return result;
}

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

v2 = func17(a1, a2);
result = 0LL;
if ( v2 )
result = func13(a1, v2);
return result;
}

original_code:
int simos_process_list_del(simos_list_t *proclist, int pid)
{
 simos_list_node_t *n = simos_process_list_search(proclist, pid);
 if (n != ((void *)0)) {
  return simos_list_del(proclist, n);
 }
 return 0;
}

canonical_original_code:
int simos_process_list_del(struct simos_list *proclist, int pid)
{
 struct simos_list_node *n = simos_process_list_search(proclist, pid);
 if (n != ((void *)0)) {
  return simos_list_del(proclist, n);
 }
 return 0;
}

variable_types: pid int


clip

repo: lkundrak/koules

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

result = 255LL;
if ( a1 <= 255 )
result = (unsigned int)a1;
if ( (int)result < 0 )
result = 0LL;
return result;
}

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

result = 255LL;
if ( a1 <= 255 )
result = (unsigned int)a1;
if ( (int)result < 0 )
result = 0LL;
return result;
}

original_code:
static inline
unsigned char clip(int i)
    {
    return (i<0) ? 0 : ( (i>255) ? 255 : i );
    }

return_type: unsigned char


decompiled_code:
int dump_snd_list()
{
__int64 v0; // rbx
int result; // eax

if ( S_num_sounds > 0 )
{
v0 = 0LL;
do
{
result = printf("snd %d: len = %d \n", (unsigned int)v0, *(unsigned int *)(S_sounds + 16 * v0 + 8));
++v0;
}
while ( S_num_sounds > (int)v0 );
}
return result;
}

canonical_decompiled_code:
int func1()
{
__int64 v0; // rbx
int result; // eax

if ( S_num_sounds > 0 )
{
v0 = 0LL;
do
{
result = printf("snd %d: len = %d \n", (unsigned int)v0, *(unsigned int *)(S_sounds + 16 * v0 + 8));
++v0;
}
while ( S_num_sounds > (int)v0 );
}
return result;
}

original_code:
void dump_snd_list()
 {
 int i=0;
 for(i=0; i<S_num_sounds; i++)
  {
  printf("snd %d: len = %d \n", i, S_sounds[i].len );
  }
 }

canonical_original_code:
void dump_snd_list()
 {
 int i = 0;
 for(i=0; i<S_num_sounds; i++)
  {
  printf("snd %d: len = %d \n", i, S_sounds[i].len );
  }
 }


decompiled_code:
__int64 __fastcall Snd_effect(int a1, int a2)
{
__int64 result; // rax
int v3; // [rsp+8h] [rbp-10h] BYREF
int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
v3 = a2;
result = 1LL;
if ( S_mixerStatus && a1 >= 0 && a1 < S_num_sounds && a2 >= 0 && a2 < S_num_channels )
{
if ( *(_QWORD *)(S_sounds + 16LL * a1) )
{
write(fd, buf, 4uLL);
write(fd, &v3, 4uLL);
result = 0LL;
}
else
{
fwrite("Referencing NULL sound entry\n", 1uLL, 0x1DuLL, stderr);
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2)
{
__int64 result; // rax
int v3; // [rsp+8h] [rbp-10h] BYREF
int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
v3 = a2;
result = 1LL;
if ( S_mixerStatus && a1 >= 0 && a1 < S_num_sounds && a2 >= 0 && a2 < S_num_channels )
{
if ( *(_QWORD *)(S_sounds + 16LL * a1) )
{
write(fd, buf, 4uLL);
write(fd, &v3, 4uLL);
result = 0LL;
}
else
{
fwrite("Referencing NULL sound entry\n", 1uLL, 0x1DuLL, stderr);
result = 1LL;
}
}
return result;
}

original_code:
int Snd_effect( int sound_num, int channel )
 {
 if(! S_mixerStatus )
  return 1;
 if (sound_num<0 || sound_num>=S_num_sounds)
  return 1;
 if (channel<0 || channel>=S_num_channels)
  return 1;
 if(S_sounds[sound_num].data != ((void *)0))
  {
  write(S_fd_pipe[1], &sound_num, sizeof(sound_num));
  write(S_fd_pipe[1], &channel, sizeof(channel));
  }
 else
  {
  fprintf(stderr,"Referencing NULL sound entry\n");
  return 1;
  }
 return 0;
 }

canonical_original_code:
int Snd_effect(int sound_num, int channel)
 {
 if(! S_mixerStatus )
  return 1;
 if (sound_num<0 || sound_num>=S_num_sounds)
  return 1;
 if (channel<0 || channel>=S_num_channels)
  return 1;
 if(S_sounds[sound_num].data != ((void *)0))
  {
  write(S_fd_pipe[1], &sound_num, sizeof(sound_num));
  write(S_fd_pipe[1], &channel, sizeof(channel));
  }
 else
  {
  fprintf(stderr,"Referencing NULL sound entry\n");
  return 1;
  }
 return 0;
 }

variable_types: channel int


decompiled_code:
__int64 Snd_restore_dev()
{
close(S_fd_pipe[0]);
close(fd);
wait(0LL);
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
close(S_fd_pipe[0]);
close(fd);
wait(0LL);
return 0LL;
}

original_code:
int Snd_restore_dev()
 {
 close(S_fd_pipe[0]);
 close(S_fd_pipe[1]);
 wait(((void *)0));
 return 0;
 }


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

result = 1LL;
if ( S_mixerStatus )
{
result = Snd_restore_dev();
S_mixerStatus = 0;
}
return result;
}

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

result = 1LL;
if ( S_mixerStatus )
{
result = func3();
S_mixerStatus = 0;
}
return result;
}

original_code:
int Snd_restore()
 {
 int result;
 if (!S_mixerStatus)
  return 1;
 result=Snd_restore_dev();
 if (result==0)
  {
  S_mixerStatus=0;
  }
 else
  {
  S_mixerStatus=0;
  }
 return result;
 }

variable_types: result int


original_code:
void Chan_reset( Channel *chan )
    {
    chan->Vstart=((void *)0);
    chan->Vcurrent=((void *)0);
    chan->Vlen=0;
    chan->Vleft=0;
    }

canonical_original_code:
void Chan_reset(struct Channel *chan)
    {
    chan->Vstart=((void *)0);
    chan->Vcurrent=((void *)0);
    chan->Vlen=0;
    chan->Vleft=0;
    }

variable_types: struct Channel { unsigned char *Vstart; int Vlen; int Vleft; } *


decompiled_code:
__int64 __fastcall Chan_assign(__int64 a1, __int64 *a2)
{
__int64 v2; // rax
__int64 result; // rax

v2 = *a2;
*(_QWORD *)a1 = *a2;
*(_QWORD *)(a1 + 8) = v2;
result = *((unsigned int *)a2 + 2);
*(_DWORD *)(a1 + 16) = result;
*(_DWORD *)(a1 + 20) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 *a2)
{
__int64 v2; // rax
__int64 result; // rax

v2 = *a2;
*(_QWORD *)a1 = *a2;
*(_QWORD *)(a1 + 8) = v2;
result = *((unsigned int *)a2 + 2);
*(_DWORD *)(a1 + 16) = result;
*(_DWORD *)(a1 + 20) = result;
return result;
}

original_code:
void Chan_assign( Channel *chan, const Sample *snd )
    {
    chan->Vstart = snd->data;
    chan->Vcurrent= chan->Vstart;
    chan->Vlen = snd->len;
    chan->Vleft = snd->len;
    }

canonical_original_code:
void Chan_assign(struct Channel *chan, struct Sample *snd)
    {
    chan->Vstart = snd->data;
    chan->Vcurrent= chan->Vstart;
    chan->Vlen = snd->len;
    chan->Vleft = snd->len;
    }

variable_types: struct Sample { unsigned char *data; int len; } *

user_defined_types: struct Channel { unsigned char *Vstart; int Vlen; int Vleft; }


original_code:
int Chan_copyIn( Channel *chan, Mix *mix )
    {
    int i,*p = mix->Vunclipbuf, result, min;
    result = (chan->Vleft>0) ? 1 : 0;
    min = (chan->Vleft < mix->Vsize) ? chan->Vleft : mix->Vsize;
    for(i=0; i<min; i++)
        {
        *p++ = (int) *chan->Vcurrent++;
        }
    chan->Vleft -= i;
    while (i<mix->Vsize)
            {
            *p++ = 128;
            i++;
            }
    return result;
    }

canonical_original_code:
int Chan_copyIn(struct Channel *chan, struct Mix *mix)
    {
    int i; int *p = mix->Vunclipbuf; int result; int min;
    result = (chan->Vleft>0) ? 1 : 0;
    min = (chan->Vleft < mix->Vsize) ? chan->Vleft : mix->Vsize;
    for(i=0; i<min; i++)
        {
        *p++ = (int) *chan->Vcurrent++;
        }
    chan->Vleft -= i;
    while (i<mix->Vsize)
            {
            *p++ = 128;
            i++;
            }
    return result;
    }

variable_types: struct Mix { unsigned char *Vclippedbuf; int *Vunclipbuf; int Vsize; } *

variable_types: i int

variable_types:
p
int *

variable_types: min int


original_code:
int Chan_mixIn( Channel *chan, Mix *mix )
    {
    int i,*p = mix->Vunclipbuf, result, min;
    result = (chan->Vleft>0) ? 1 : 0;
    min = (chan->Vleft < mix->Vsize) ? chan->Vleft : mix->Vsize;
    for(i=0; i<min; i++)
        {
        *p++ += (int) (*chan->Vcurrent++) - 128;
        }
    chan->Vleft -= i;
    return result;
    }

canonical_original_code:
int Chan_mixIn(struct Channel *chan, struct Mix *mix)
    {
    int i; int *p = mix->Vunclipbuf; int result; int min;
    result = (chan->Vleft>0) ? 1 : 0;
    min = (chan->Vleft < mix->Vsize) ? chan->Vleft : mix->Vsize;
    for(i=0; i<min; i++)
        {
        *p++ += (int) (*chan->Vcurrent++) - 128;
        }
    chan->Vleft -= i;
    return result;
    }

user_defined_types: struct Mix { unsigned char *Vclippedbuf; int *Vunclipbuf; int Vsize; }


original_code:
int Chan_finalMixIn( Channel *chan, Mix *mix )
    {
    register int i;
    int *p = mix->Vunclipbuf, result, min;
    unsigned char *final = mix->Vclippedbuf;
    result = (chan->Vleft>0) ? 1 : 0;
    min = (chan->Vleft < mix->Vsize) ? chan->Vleft : mix->Vsize;
    for(i=0; i<min; i++)
        {
        *p += (int) (*chan->Vcurrent++) - 128;
        *final++ = clip(*p++);
        }
    chan->Vleft -= i;
    while (i<mix->Vsize)
            {
            *final++ = clip(*p++);
            i++;
            }
    return result;
    }

canonical_original_code:
int Chan_finalMixIn(struct Channel *chan, struct Mix *mix)
    {
    register int i;
    int *p = mix->Vunclipbuf; int result; int min;
    unsigned char *final = mix->Vclippedbuf;
    result = (chan->Vleft>0) ? 1 : 0;
    min = (chan->Vleft < mix->Vsize) ? chan->Vleft : mix->Vsize;
    for(i=0; i<min; i++)
        {
        *p += (int) (*chan->Vcurrent++) - 128;
        *final++ = clip(*p++);
        }
    chan->Vleft -= i;
    while (i<mix->Vsize)
            {
            *final++ = clip(*p++);
            i++;
            }
    return result;
    }

variable_types:
final
unsigned char *


decompiled_code:
void *__fastcall Mix_alloc(__int64 a1, int a2)
{
void *v2; // r12
void *result; // rax

v2 = calloc(1uLL, a2);
*(_QWORD *)a1 = v2;
result = calloc(4uLL, a2);
*(_QWORD *)(a1 + 8) = result;
*(_DWORD *)(a1 + 16) = a2;
if ( !result || !v2 )
{
fwrite("Unable to allocate memory for mixer buffer\n", 1uLL, 0x2BuLL, stderr);
exit(-1);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func10(__int64 a1, int a2)
{
void *v2; // r12
void *result; // rax

v2 = calloc(1uLL, a2);
*(_QWORD *)a1 = v2;
result = calloc(4uLL, a2);
*(_QWORD *)(a1 + 8) = result;
*(_DWORD *)(a1 + 16) = a2;
if ( !result || !v2 )
{
fwrite("Unable to allocate memory for mixer buffer\n", 1uLL, 0x2BuLL, stderr);
exit(-1);
}
return result;
}

original_code:
void Mix_alloc(Mix *mix, int size)
    {
    mix->Vclippedbuf = (unsigned char *)calloc( sizeof(char), size);
    mix->Vunclipbuf = (int *)calloc( sizeof(int), size);
    mix->Vsize = size;
    if ((mix->Vclippedbuf==((void *)0))||(mix->Vunclipbuf==((void *)0)))
     {
    fprintf(stderr,"Unable to allocate memory for mixer buffer\n");
     exit(-1);
     }
    }

canonical_original_code:
void Mix_alloc(struct Mix *mix, int size)
    {
    mix->Vclippedbuf = (unsigned char *)calloc( sizeof(char), size);
    mix->Vunclipbuf = (int *)calloc( sizeof(int), size);
    mix->Vsize = size;
    if ((mix->Vclippedbuf==((void *)0))||(mix->Vunclipbuf==((void *)0)))
     {
    fprintf(stderr,"Unable to allocate memory for mixer buffer\n");
     exit(-1);
     }
    }

variable_types: size int


decompiled_code:
void __fastcall Mix_dealloc(__int64 a1)
{
void *v2; // rdi
void *v3; // rdi

v2 = *(void **)a1;
if ( v2 )
free(v2);
v3 = *(void **)(a1 + 8);
if ( v3 )
free(v3);
}

canonical_decompiled_code:
void __fastcall func11(__int64 a1)
{
void *v2; // rdi
void *v3; // rdi

v2 = *(void **)a1;
if ( v2 )
free(v2);
v3 = *(void **)(a1 + 8);
if ( v3 )
free(v3);
}

original_code:
void Mix_dealloc( Mix *mix)
    {
    if (mix->Vclippedbuf) free(mix->Vclippedbuf);
    if (mix->Vunclipbuf) free(mix->Vunclipbuf);
    }

canonical_original_code:
void Mix_dealloc(struct Mix *mix)
    {
    if (mix->Vclippedbuf) free(mix->Vclippedbuf);
    if (mix->Vunclipbuf) free(mix->Vunclipbuf);
    }


decompiled_code:
__int64 __fastcall Chan_mixAll(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
int v3; // ebp
__int64 v4; // r13

v2 = a2;
v3 = Chan_copyIn(a2, a1);
if ( S_num_channels <= 2 )
{
v4 = a2;
}
else
{
v4 = a2 + 24LL * (unsigned int)(S_num_channels - 2);
do
{
v2 += 24LL;
v3 += Chan_mixIn(v2, a1);
}
while ( v2 != v4 );
}
return v3 + (unsigned int)Chan_finalMixIn(v4 + 24, a1);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
int v3; // ebp
__int64 v4; // r13

v2 = a2;
v3 = func7(a2, a1);
if ( S_num_channels <= 2 )
{
v4 = a2;
}
else
{
v4 = a2 + 24LL * (unsigned int)(S_num_channels - 2);
do
{
v2 += 24LL;
v3 += func8(v2, a1);
}
while ( v2 != v4 );
}
return v3 + (unsigned int)func9(v4 + 24, a1);
}

original_code:
int Chan_mixAll( Mix *mix, Channel *chan )
    {
    int result = 0,i=0;
    result = Chan_copyIn( chan, mix);
    for(i=2;i<S_num_channels;i++)
     result += Chan_mixIn( ++chan, mix);
    result += Chan_finalMixIn( ++chan, mix);
    return result;
    }

canonical_original_code:
int Chan_mixAll(struct Mix *mix, struct Channel *chan)
    {
    int result = 0; int i = 0;
    result = Chan_copyIn( chan, mix);
    for(i=2;i<S_num_channels;i++)
     result += Chan_mixIn( ++chan, mix);
    result += Chan_finalMixIn( ++chan, mix);
    return result;
    }


decompiled_code:
__int64 Snd_init_dev()
{
const char *v0; // rbp
unsigned int v1; // ebx
int v2; // edi
__pid_t v3; // eax
int v4; // er12
char *v5; // rax
__int64 v6; // rbp
__int64 v7; // rbx
char *v8; // r12
int v9; // eax
int v10; // ebx
int v12; // edi
int v13; // [rsp+0h] [rbp-158h] BYREF
int v14; // [rsp+4h] [rbp-154h] BYREF
int v15; // [rsp+8h] [rbp-150h] BYREF
int v16; // [rsp+Ch] [rbp-14Ch] BYREF
struct timeval timeout; // [rsp+10h] [rbp-148h] BYREF
void *buf[4]; // [rsp+20h] [rbp-138h] BYREF
fd_set readfds; // [rsp+40h] [rbp-118h] BYREF
__int64 v20[19]; // [rsp+C0h] [rbp-98h] BYREF

S_fd_snddev = -1;
v0 = S_snddev;
if ( access(S_snddev, 2) )
{
perror("No access to sound device");
v1 = 1;
}
else
{
v1 = 0;
v2 = open(v0, 1);
S_fd_snddev = v2;
if ( v2 < 0 )
{
fwrite("int_snddev: Cannot open sound device \n", 1uLL, 0x26uLL, stderr);
v1 = 1;
}
else
{
close(v2);
if ( pipe(S_fd_pipe) < 0 )
{
fwrite("Cannot create pipe for sound control \n", 1uLL, 0x26uLL, stderr);
v1 = 1;
}
else
{
v3 = fork();
if ( v3 < 0 )
{
fwrite("Cannot fork sound driver\n", 1uLL, 0x19uLL, stderr);
v1 = 1;
}
else
{
if ( !v3 )
{
timeout.tv_sec = 0LL;
timeout.tv_usec = 0LL;
v4 = S_num_channels;
v5 = (char *)malloc(24LL * S_num_channels);
v6 = (__int64)v5;
if ( v4 > 0 )
{
v7 = (__int64)v5;
v8 = &v5[24 * v4];
do
{
Chan_reset(v7);
v7 += 24LL;
}
while ( (char *)v7 != v8 );
}
v9 = open(S_snddev, 1);
v10 = v9;
S_fd_snddev = v9;
if ( v9 >= 0 )
{
v15 = 131079;
ioctl(v9, 0xC004500AuLL, &v15);
if ( ioctl(v10, 0xC0045002uLL, &S_playback_freq) == -1 )
perror("Sound driver ioctl ");
v16 = 0;
if ( ioctl(S_fd_snddev, 0xC0045004uLL, &v16) == -1 )
perror("Sound driver ioctl ");
Mix_alloc((__int64)buf, v16);
close(fd);
memset(v20, 0, 0x80uLL);
v20[S_fd_snddev / 64] |= 1LL << (S_fd_snddev % 64);
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[S_fd_pipe[0] / 64] |= 1LL << (S_fd_pipe[0] % 64);
puts("soundIt library v0.04 initialized.");
while ( 1 )
{
v12 = S_fd_pipe[0];
readfds.fds_bits[S_fd_pipe[0] / 64] |= 1LL << (S_fd_pipe[0] % 64);
timeout.tv_sec = 0LL;
timeout.tv_usec = 0LL;
select(v12 + 1, &readfds, 0LL, 0LL, &timeout);
if ( (readfds.fds_bits[S_fd_pipe[0] / 64] & (1LL << (S_fd_pipe[0] % 64))) != 0 )
{
if ( !read(S_fd_pipe[0], &v13, 4uLL) )
{
Mix_dealloc((__int64)buf);
puts("soundIt process exiting..");
close(S_fd_pipe[0]);
close(fd);
exit(0);
}
read(S_fd_pipe[0], &v14, 4uLL);
Chan_assign(v6 + 24LL * v14, (__int64 *)(S_sounds + 16LL * v13));
}
Chan_mixAll((__int64)buf, v6);
write(S_fd_snddev, buf[0], v16);
}
}
perror("Cannot open sound device: ");
exit(1);
}
close(S_fd_pipe[0]);
}
}
}
}
return v1;
}

canonical_decompiled_code:
__int64 func13()
{
const char *v0; // rbp
unsigned int v1; // ebx
int v2; // edi
__pid_t v3; // eax
int v4; // er12
char *v5; // rax
__int64 v6; // rbp
__int64 v7; // rbx
char *v8; // r12
int v9; // eax
int v10; // ebx
int v12; // edi
int v13; // [rsp+0h] [rbp-158h] BYREF
int v14; // [rsp+4h] [rbp-154h] BYREF
int v15; // [rsp+8h] [rbp-150h] BYREF
int v16; // [rsp+Ch] [rbp-14Ch] BYREF
struct timeval timeout; // [rsp+10h] [rbp-148h] BYREF
void *buf[4]; // [rsp+20h] [rbp-138h] BYREF
fd_set readfds; // [rsp+40h] [rbp-118h] BYREF
__int64 v20[19]; // [rsp+C0h] [rbp-98h] BYREF

S_fd_snddev = -1;
v0 = S_snddev;
if ( access(S_snddev, 2) )
{
perror("No access to sound device");
v1 = 1;
}
else
{
v1 = 0;
v2 = open(v0, 1);
S_fd_snddev = v2;
if ( v2 < 0 )
{
fwrite("int_snddev: Cannot open sound device \n", 1uLL, 0x26uLL, stderr);
v1 = 1;
}
else
{
close(v2);
if ( pipe(S_fd_pipe) < 0 )
{
fwrite("Cannot create pipe for sound control \n", 1uLL, 0x26uLL, stderr);
v1 = 1;
}
else
{
v3 = fork();
if ( v3 < 0 )
{
fwrite("Cannot fork sound driver\n", 1uLL, 0x19uLL, stderr);
v1 = 1;
}
else
{
if ( !v3 )
{
timeout.tv_sec = 0LL;
timeout.tv_usec = 0LL;
v4 = S_num_channels;
v5 = (char *)malloc(24LL * S_num_channels);
v6 = (__int64)v5;
if ( v4 > 0 )
{
v7 = (__int64)v5;
v8 = &v5[24 * v4];
do
{
func5(v7);
v7 += 24LL;
}
while ( (char *)v7 != v8 );
}
v9 = open(S_snddev, 1);
v10 = v9;
S_fd_snddev = v9;
if ( v9 >= 0 )
{
v15 = 131079;
ioctl(v9, 0xC004500AuLL, &v15);
if ( ioctl(v10, 0xC0045002uLL, &S_playback_freq) == -1 )
perror("Sound driver ioctl ");
v16 = 0;
if ( ioctl(S_fd_snddev, 0xC0045004uLL, &v16) == -1 )
perror("Sound driver ioctl ");
func10((__int64)buf, v16);
close(fd);
memset(v20, 0, 0x80uLL);
v20[S_fd_snddev / 64] |= 1LL << (S_fd_snddev % 64);
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[S_fd_pipe[0] / 64] |= 1LL << (S_fd_pipe[0] % 64);
puts("soundIt library v0.04 initialized.");
while ( 1 )
{
v12 = S_fd_pipe[0];
readfds.fds_bits[S_fd_pipe[0] / 64] |= 1LL << (S_fd_pipe[0] % 64);
timeout.tv_sec = 0LL;
timeout.tv_usec = 0LL;
select(v12 + 1, &readfds, 0LL, 0LL, &timeout);
if ( (readfds.fds_bits[S_fd_pipe[0] / 64] & (1LL << (S_fd_pipe[0] % 64))) != 0 )
{
if ( !read(S_fd_pipe[0], &v13, 4uLL) )
{
func11((__int64)buf);
puts("soundIt process exiting..");
close(S_fd_pipe[0]);
close(fd);
exit(0);
}
read(S_fd_pipe[0], &v14, 4uLL);
func6(v6 + 24LL * v14, (__int64 *)(S_sounds + 16LL * v13));
}
func12((__int64)buf, v6);
write(S_fd_snddev, buf[0], v16);
}
}
perror("Cannot open sound device: ");
exit(1);
}
close(S_fd_pipe[0]);
}
}
}
}
return v1;
}

original_code:
int Snd_init_dev()
 {
 int whoami;
 S_fd_snddev = -1;
 S_son_pid = 0;
 if(access(S_snddev,2) != 0)
  {
  perror("No access to sound device");
  return 1;
  }
 S_fd_snddev = open(S_snddev,01);
 if(S_fd_snddev < 0)
  {
  fprintf(stderr,"int_snddev: Cannot open sound device \n");
  return 1;
  }
 close(S_fd_snddev);
 if(pipe(S_fd_pipe) < 0)
  {
  fprintf(stderr,"Cannot create pipe for sound control \n");
  return 1;
  }
 if((whoami = fork()) < 0)
  {
  fprintf(stderr,"Cannot fork sound driver\n");
  return 1;
  }
 if(whoami != 0)
  {
  close(S_fd_pipe[0]);
  S_son_pid = whoami;
  return 0;
  }
  {
  int sound_num,ch,i;
  struct timeval tval = {0L,0L};
  fd_set readfds,dsp;
  Mix mix;
  int frag, fragsize;
  Channel *chan = (Channel*)malloc( sizeof(Channel)*S_num_channels );
  for (i=0; i<S_num_channels; i++)
   Chan_reset( chan+i );
  S_fd_snddev = open(S_snddev,01 );
  if(S_fd_snddev < 0)
   {
   perror("Cannot open sound device: ");
   exit(1);
   }
  frag = 0x00020007;
   ioctl(S_fd_snddev, (((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((10)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &frag);
  if ( ioctl(S_fd_snddev,(((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((2)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &S_playback_freq)==-1 )
   perror("Sound driver ioctl ");
  fragsize=0;
  if ( ioctl(S_fd_snddev,(((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((4)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &fragsize)==-1 )
   perror("Sound driver ioctl ");
  Mix_alloc( &mix, fragsize );
  close(S_fd_pipe[1]);
  do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&dsp)->__fds_bits)[0]) : "memory"); } while (0);
  ((void) (((&dsp)->__fds_bits)[((S_fd_snddev) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((S_fd_snddev) % (8 * (int) sizeof (__fd_mask)))))));
  do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&readfds)->__fds_bits)[0]) : "memory"); } while (0);
  ((void) (((&readfds)->__fds_bits)[((S_fd_pipe[0]) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((S_fd_pipe[0]) % (8 * (int) sizeof (__fd_mask)))))));
  printf("soundIt library v""0.04"" initialized.\n");
  for(;;)
   {
   ((void) (((&readfds)->__fds_bits)[((S_fd_pipe[0]) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((S_fd_pipe[0]) % (8 * (int) sizeof (__fd_mask)))))));
   tval.tv_sec=0L;
   tval.tv_usec=0L;
   select(S_fd_pipe[0]+1, &readfds,((void *)0),((void *)0),&tval);
   if (((((&readfds)->__fds_bits)[((S_fd_pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((S_fd_pipe[0]) % (8 * (int) sizeof (__fd_mask)))))) != 0))
    {
    if (read(S_fd_pipe[0], &sound_num, sizeof(int))==0)
     break;
    read(S_fd_pipe[0], &ch, sizeof(int));
    Chan_assign( &(chan[ch]), &(S_sounds[sound_num]) );
    }
   Chan_mixAll(&mix,chan);
   write(S_fd_snddev, mix.Vclippedbuf, fragsize );
   }
  Mix_dealloc( &mix );
  printf("soundIt process exiting..\n");
  close(S_fd_pipe[0]);
  close(S_fd_pipe[1]);
  exit (0);
  }
 }

canonical_original_code:
int Snd_init_dev()
 {
 int whoami;
 S_fd_snddev = -1;
 S_son_pid = 0;
 if(access(S_snddev,2) != 0)
  {
  perror("No access to sound device");
  return 1;
  }
 S_fd_snddev = open(S_snddev,01);
 if(S_fd_snddev < 0)
  {
  fprintf(stderr,"int_snddev: Cannot open sound device \n");
  return 1;
  }
 close(S_fd_snddev);
 if(pipe(S_fd_pipe) < 0)
  {
  fprintf(stderr,"Cannot create pipe for sound control \n");
  return 1;
  }
 if((whoami = fork()) < 0)
  {
  fprintf(stderr,"Cannot fork sound driver\n");
  return 1;
  }
 if(whoami != 0)
  {
  close(S_fd_pipe[0]);
  S_son_pid = whoami;
  return 0;
  }
  {
  int sound_num; int ch; int i;
  struct timeval tval = {0L,0L};
  struct fd_set readfds; struct fd_set dsp;
  struct Mix mix;
  int frag; int fragsize;
  struct Channel *chan = (Channel*)malloc( sizeof(Channel)*S_num_channels );
  for (i=0; i<S_num_channels; i++)
   Chan_reset( chan+i );
  S_fd_snddev = open(S_snddev,01 );
  if(S_fd_snddev < 0)
   {
   perror("Cannot open sound device: ");
   exit(1);
   }
  frag = 0x00020007;
   ioctl(S_fd_snddev, (((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((10)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &frag);
  if ( ioctl(S_fd_snddev,(((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((2)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &S_playback_freq)==-1 )
   perror("Sound driver ioctl ");
  fragsize=0;
  if ( ioctl(S_fd_snddev,(((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((4)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &fragsize)==-1 )
   perror("Sound driver ioctl ");
  Mix_alloc( &mix, fragsize );
  close(S_fd_pipe[1]);
  do { int __d0; int __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&dsp)->__fds_bits)[0]) : "memory"); } while (0);
  ((void) (((&dsp)->__fds_bits)[((S_fd_snddev) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((S_fd_snddev) % (8 * (int) sizeof (__fd_mask)))))));
  do { int __d0; int __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&readfds)->__fds_bits)[0]) : "memory"); } while (0);
  ((void) (((&readfds)->__fds_bits)[((S_fd_pipe[0]) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((S_fd_pipe[0]) % (8 * (int) sizeof (__fd_mask)))))));
  printf("soundIt library v""0.04"" initialized.\n");
  for(;;)
   {
   ((void) (((&readfds)->__fds_bits)[((S_fd_pipe[0]) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((S_fd_pipe[0]) % (8 * (int) sizeof (__fd_mask)))))));
   tval.tv_sec=0L;
   tval.tv_usec=0L;
   select(S_fd_pipe[0]+1, &readfds,((void *)0),((void *)0),&tval);
   if (((((&readfds)->__fds_bits)[((S_fd_pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((S_fd_pipe[0]) % (8 * (int) sizeof (__fd_mask)))))) != 0))
    {
    if (read(S_fd_pipe[0], &sound_num, sizeof(int))==0)
     break;
    read(S_fd_pipe[0], &ch, sizeof(int));
    Chan_assign( &(chan[ch]), &(S_sounds[sound_num]) );
    }
   Chan_mixAll(&mix,chan);
   write(S_fd_snddev, mix.Vclippedbuf, fragsize );
   }
  Mix_dealloc( &mix );
  printf("soundIt process exiting..\n");
  close(S_fd_pipe[0]);
  close(S_fd_pipe[1]);
  exit (0);
  }
 }

variable_types: whoami int

variable_types: ch int

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

variable_types:
readfds
struct fd_set { long __fds_bits[-1]; }

variable_types:
dsp
struct fd_set { long __fds_bits[-1]; }

variable_types: struct Mix { unsigned char *Vclippedbuf; int *Vunclipbuf; int Vsize; }

variable_types: frag int

variable_types: fragsize int


decompiled_code:
__int64 __fastcall Snd_init(int a1, __int64 a2, int a3, int a4, char *a5)
{
__int64 result; // rax

S_num_sounds = a1;
S_sounds = a2;
S_playback_freq = a3;
S_num_channels = a4;
S_snddev = a5;
result = 1LL;
if ( a2 )
{
result = Snd_init_dev();
S_mixerStatus = result == 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(int a1, __int64 a2, int a3, int a4, char *a5)
{
__int64 result; // rax

S_num_sounds = a1;
S_sounds = a2;
S_playback_freq = a3;
S_num_channels = a4;
S_snddev = a5;
result = 1LL;
if ( a2 )
{
result = func13();
S_mixerStatus = result == 0;
}
return result;
}

original_code:
int Snd_init( int num_snd, const Sample *sa, int frequency,
              int channels, const char *dev )
 {
 int result;
 S_num_sounds = num_snd;
 S_sounds = sa;
 S_playback_freq = frequency;
 S_num_channels = channels;
 S_snddev= dev;
 if (S_sounds==((void *)0))
  return 1;
 result=Snd_init_dev();
 if (result==0)
  {
  S_mixerStatus=1;
  }
 else
  {
  S_mixerStatus=0;
  }
 return result;
 }

canonical_original_code:
int Snd_init(int num_snd, struct Sample *sa, int frequency, int channels, char *dev)
 {
 int result;
 S_num_sounds = num_snd;
 S_sounds = sa;
 S_playback_freq = frequency;
 S_num_channels = channels;
 S_snddev= dev;
 if (S_sounds==((void *)0))
  return 1;
 result=Snd_init_dev();
 if (result==0)
  {
  S_mixerStatus=1;
  }
 else
  {
  S_mixerStatus=0;
  }
 return result;
 }

variable_types: frequency int

variable_types: channels int

variable_types:
dev
char *

variable_types: result int

user_defined_types: struct Sample { unsigned char *data; int len; }


sigchld

repo: lkundrak/retty

decompiled_code:
void __noreturn sigchld()
{
_exit(0);
}

canonical_decompiled_code:
void __noreturn func7()
{
_exit(0);
}

original_code:
void
sigchld(int s)
{
 _exit(0);
}

canonical_original_code:
void sigchld(int s)
{
 _exit(0);
}

variable_types: s int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int result; // eax
const char **v5; // rax
__int64 v6; // [rsp+0h] [rbp-428h] BYREF
int amaster[7]; // [rsp+40Ch] [rbp-1Ch] BYREF

if ( argc <= 1 )
{
fwrite("Usage: blindtty CMD [ARG]...\n", 1uLL, 0x1DuLL, stderr);
result = 1;
}
else
{
v3 = forkpty(amaster, 0LL, 0LL, 0LL);
if ( v3 )
{
printf("%s started with pid %d\n", argv[1], v3);
signal(17, (__sighandler_t)sigchld);
while ( read(amaster[0], &v6, 0x400uLL) > 0 )
;
_exit(0);
}
v5 = argv;
do
{
*v5 = v5[1];
++v5;
}
while ( v5 != &argv[(unsigned int)(argc - 1) + 1] );
argv[argc] = 0LL;
execvp(*argv, (char *const *)argv);
perror("execvp() failed");
result = 2;
}
return result;
}

original_code:
int
main(int argc, char *argv[])
{
 int ptm;
 pid_t pid;
 if (argc < 2) {
  fprintf(stderr, "Usage: blindtty CMD [ARG]...\n");
  return 1;
 }
 pid = forkpty(&ptm, ((void *)0), ((void *)0), ((void *)0));
 if (!pid) {
  int i; for (i=0; i<argc; i++) argv[i] = argv[i+1]; argv[i]=((void *)0);
  execvp(argv[0], argv);
  perror("execvp() failed");
  return 2;
 }
 printf("%s started with pid %d\n", argv[1], pid);
 signal(17, sigchld);
 while (1) {
  char buf[1024];
  if (read(ptm, buf, 1024) <= 0)
   _exit(0);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int ptm;
 int pid;
 if (argc < 2) {
  fprintf(stderr, "Usage: blindtty CMD [ARG]...\n");
  return 1;
 }
 pid = forkpty(&ptm, ((void *)0), ((void *)0), ((void *)0));
 if (!pid) {
  int i; for (i=0; i<argc; i++) argv[i] = argv[i+1]; argv[i]=((void *)0);
  execvp(argv[0], argv);
  perror("execvp() failed");
  return 2;
 }
 printf("%s started with pid %d\n", argv[1], pid);
 signal(17, sigchld);
 while (1) {
  char buf[1024];
  if (read(ptm, buf, 1024) <= 0)
   _exit(0);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: ptm int

variable_types: pid int

variable_types: i int

variable_types:
buf
char [1024]


repo: llaaperi/NetController

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
__int64 v4; // rax

TestRunner_start(argc, argv, envp);
v3 = TimeTest_tests();
TestRunner_runTest(v3);
v4 = NetworkTest_tests();
TestRunner_runTest(v4);
TestRunner_end();
return 0;
}

original_code:
int main (int argc, const char* argv[]){
 TestRunner_start();
 TestRunner_runTest(TimeTest_tests());
 TestRunner_runTest(NetworkTest_tests());
 TestRunner_end();
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
 TestRunner_start();
 TestRunner_runTest(TimeTest_tests());
 TestRunner_runTest(NetworkTest_tests());
 TestRunner_end();
 return 0;
}


assertImplementationInt

decompiled_code:
__int64 __fastcall assertImplementationInt(unsigned int a1, unsigned int a2, __int64 a3, __int64 a4)
{
char v7[12]; // [rsp+4h] [rbp-54h] BYREF
char v8[72]; // [rsp+10h] [rbp-48h] BYREF

stdimpl_strcpy(v8, "exp ");
stdimpl_itoa(a1, v7, 10LL);
stdimpl_strncat(v8, v7, 11LL);
stdimpl_strcat(v8, " was ");
stdimpl_itoa(a2, v7, 10LL);
stdimpl_strncat(v8, v7, 11LL);
return addFailure(v8, a3, a4);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, unsigned int a2, __int64 a3, __int64 a4)
{
char v7[12]; // [rsp+4h] [rbp-54h] BYREF
char v8[72]; // [rsp+10h] [rbp-48h] BYREF

stdimpl_strcpy(v8, "exp ");
stdimpl_itoa(a1, v7, 10LL);
stdimpl_strncat(v8, v7, 11LL);
stdimpl_strcat(v8, " was ");
stdimpl_itoa(a2, v7, 10LL);
stdimpl_strncat(v8, v7, 11LL);
return addFailure(v8, a3, a4);
}

original_code:
void assertImplementationInt(int expected,int actual, long line, const char *file)
{
 char buffer[32];
 char numbuf[12];
 stdimpl_strcpy(buffer, "exp ");
 { stdimpl_itoa(expected, numbuf, 10);
  stdimpl_strncat(buffer, numbuf, 11); }
 stdimpl_strcat(buffer, " was ");
 { stdimpl_itoa(actual, numbuf, 10);
  stdimpl_strncat(buffer, numbuf, 11); }
 addFailure(buffer, line, file);
}

canonical_original_code:
void assertImplementationInt(int expected, int actual, long line, char *file)
{
 char buffer[32];
 char numbuf[12];
 stdimpl_strcpy(buffer, "exp ");
 { stdimpl_itoa(expected, numbuf, 10);
  stdimpl_strncat(buffer, numbuf, 11); }
 stdimpl_strcat(buffer, " was ");
 { stdimpl_itoa(actual, numbuf, 10);
  stdimpl_strncat(buffer, numbuf, 11); }
 addFailure(buffer, line, file);
}

variable_types: expected int

variable_types: actual int

variable_types: line long

variable_types:
file
char *

variable_types:
buffer
char [32]

variable_types:
numbuf
char [12]


assertImplementationCStr

decompiled_code:
__int64 __fastcall assertImplementationCStr(const char *a1, const char *a2, __int64 a3, __int64 a4)
{
const char *v4; // rbp
const char *v7; // rbx
int v8; // er13
int v9; // eax
int v10; // er12
_BYTE v12[120]; // [rsp+0h] [rbp-78h] BYREF

v4 = a2;
if ( a1 )
{
v7 = a1;
v8 = stdimpl_strlen(a1);
if ( a2 )
{
v9 = stdimpl_strlen(a2);
v10 = v9;
if ( v8 > 26 )
{
if ( v9 > 26 )
{
v10 = 26;
v8 = 26;
goto LABEL_14;
}
goto LABEL_7;
}
goto LABEL_12;
}
}
else
{
if ( a2 )
{
v10 = stdimpl_strlen(a2);
v8 = 4;
v7 = "null";
goto LABEL_12;
}
v8 = 4;
v7 = "null";
}
if ( v8 > 26 )
{
v10 = 4;
v4 = "null";
LABEL_7:
if ( v8 > 52 - v10 )
v8 = 52 - v10;
goto LABEL_14;
}
v10 = 4;
v4 = "null";
LABEL_12:
if ( v10 > 52 - v8 )
v10 = 52 - v8;
LABEL_14:
stdimpl_strcpy(v12, "exp \"");
stdimpl_strncat(v12, v7, (unsigned int)v8);
stdimpl_strcat(v12, "\" was \"");
stdimpl_strncat(v12, v4, (unsigned int)v10);
stdimpl_strcat(v12, "\"");
return addFailure(v12, a3, a4);
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1, const char *a2, __int64 a3, __int64 a4)
{
const char *v4; // rbp
const char *v7; // rbx
int v8; // er13
int v9; // eax
int v10; // er12
_BYTE v12[120]; // [rsp+0h] [rbp-78h] BYREF

v4 = a2;
if ( a1 )
{
v7 = a1;
v8 = stdimpl_strlen(a1);
if ( a2 )
{
v9 = stdimpl_strlen(a2);
v10 = v9;
if ( v8 > 26 )
{
if ( v9 > 26 )
{
v10 = 26;
v8 = 26;
goto LABEL_14;
}
goto LABEL_7;
}
goto LABEL_12;
}
}
else
{
if ( a2 )
{
v10 = stdimpl_strlen(a2);
v8 = 4;
v7 = "null";
goto LABEL_12;
}
v8 = 4;
v7 = "null";
}
if ( v8 > 26 )
{
v10 = 4;
v4 = "null";
LABEL_7:
if ( v8 > 52 - v10 )
v8 = 52 - v10;
goto LABEL_14;
}
v10 = 4;
v4 = "null";
LABEL_12:
if ( v10 > 52 - v8 )
v10 = 52 - v8;
LABEL_14:
stdimpl_strcpy(v12, "exp \"");
stdimpl_strncat(v12, v7, (unsigned int)v8);
stdimpl_strcat(v12, "\" was \"");
stdimpl_strncat(v12, v4, (unsigned int)v10);
stdimpl_strcat(v12, "\"");
return addFailure(v12, a3, a4);
}

original_code:
void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file)
{
 char buffer[64];
 int el;
 int al;
 if (expected) {
  el = stdimpl_strlen(expected);
 } else {
  el = 4;
  expected = "null";
 }
 if (actual) {
  al = stdimpl_strlen(actual);
 } else {
  al = 4;
  actual = "null";
 }
 if (el > ((64 -11-1)/2)) {
  if (al > ((64 -11-1)/2)) {
   al = ((64 -11-1)/2);
   el = ((64 -11-1)/2);
  } else {
   int w = ((64 -11-1)/2) + (((64 -11-1)/2) - al);
   if (el > w) {
    el = w;
   }
  }
 } else {
  int w = ((64 -11-1)/2) + (((64 -11-1)/2) - el);
  if (al > w) {
   al = w;
  }
 }
 stdimpl_strcpy(buffer, "exp \"");
 stdimpl_strncat(buffer, expected, el);
 stdimpl_strcat(buffer, "\" was \"");
 stdimpl_strncat(buffer, actual, al);
 stdimpl_strcat(buffer, "\"");
 addFailure(buffer, line, file);
}

canonical_original_code:
void assertImplementationCStr(char *expected, char *actual, long line, char *file)
{
 char buffer[64];
 int el;
 int al;
 if (expected) {
  el = stdimpl_strlen(expected);
 } else {
  el = 4;
  expected = "null";
 }
 if (actual) {
  al = stdimpl_strlen(actual);
 } else {
  al = 4;
  actual = "null";
 }
 if (el > ((64 -11-1)/2)) {
  if (al > ((64 -11-1)/2)) {
   al = ((64 -11-1)/2);
   el = ((64 -11-1)/2);
  } else {
   int w = ((64 -11-1)/2) + (((64 -11-1)/2) - al);
   if (el > w) {
    el = w;
   }
  }
 } else {
  int w = ((64 -11-1)/2) + (((64 -11-1)/2) - el);
  if (al > w) {
   al = w;
  }
 }
 stdimpl_strcpy(buffer, "exp \"");
 stdimpl_strncat(buffer, expected, el);
 stdimpl_strcat(buffer, "\" was \"");
 stdimpl_strncat(buffer, actual, al);
 stdimpl_strcat(buffer, "\"");
 addFailure(buffer, line, file);
}

variable_types:
expected
char *

variable_types:
actual
char *

variable_types:
buffer
char [64]

variable_types: el int

variable_types: al int

variable_types: w int


decompiled_code:
void enc28j60_init()
{
recvLen = 0;
sendLen = 0;
}

canonical_decompiled_code:
void func0()
{
recvLen = 0;
sendLen = 0;
}

original_code:
void enc28j60_init(uint8_t* macaddr){
 _recvLen = 0;
 _sendLen = 0;
}

canonical_original_code:
void enc28j60_init(unsigned char *macaddr){
 _recvLen = 0;
 _sendLen = 0;
}

variable_types:
macaddr
unsigned char *


decompiled_code:
void *__fastcall enc28j60_send(unsigned __int16 a1, const void *a2)
{
sendLen = a1;
return memcpy(&sendBuffer, a2, a1);
}

canonical_decompiled_code:
void *__fastcall func1(unsigned __int16 a1, const void *a2)
{
sendLen = a1;
return memcpy(&sendBuffer, a2, a1);
}

original_code:
void enc28j60_send(uint16_t len, uint8_t* packet){
 _sendLen = len;
 memcpy(_sendBuffer, packet, len);
}

canonical_original_code:
void enc28j60_send(unsigned short len, unsigned char *packet){
 _sendLen = len;
 memcpy(_sendBuffer, packet, len);
}

variable_types:
len
unsigned short

variable_types:
packet
unsigned char *


decompiled_code:
__int64 __fastcall enc28j60_recv(unsigned int a1, void *a2)
{
unsigned int v2; // ebx
__int64 result; // rax

v2 = (unsigned __int16)recvLen;
memcpy(a2, &recvBuffer, (unsigned __int16)recvLen);
result = a1;
if ( (unsigned __int16)v2 <= (unsigned __int16)a1 )
result = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, void *a2)
{
unsigned int v2; // ebx
__int64 result; // rax

v2 = (unsigned __int16)recvLen;
memcpy(a2, &recvBuffer, (unsigned __int16)recvLen);
result = a1;
if ( (unsigned __int16)v2 <= (unsigned __int16)a1 )
result = v2;
return result;
}

original_code:
uint16_t enc28j60_recv(uint16_t maxlen, uint8_t* packet){
 uint16_t pktLen = _recvLen;
 if(maxlen < _recvLen){
  pktLen = maxlen;
 }
 memcpy(packet, _recvBuffer, _recvLen);
 return pktLen;
}

canonical_original_code:
unsigned short enc28j60_recv(unsigned short maxlen, unsigned char *packet){
 unsigned short pktLen = _recvLen;
 if(maxlen < _recvLen){
  pktLen = maxlen;
 }
 memcpy(packet, _recvBuffer, _recvLen);
 return pktLen;
}

variable_types:
maxlen
unsigned short

variable_types:
pktLen
unsigned short

return_type: unsigned short


decompiled_code:
int print_recv()
{
__int64 v0; // rbx

putchar(10);
if ( recvLen )
{
v0 = 0LL;
do
printf("%02x ", (unsigned __int8)recvBuffer[v0++]);
while ( (unsigned __int16)recvLen > (int)v0 );
}
return putchar(10);
}

canonical_decompiled_code:
int func3()
{
__int64 v0; // rbx

putchar(10);
if ( recvLen )
{
v0 = 0LL;
do
printf("%02x ", (unsigned __int8)recvBuffer[v0++]);
while ( (unsigned __int16)recvLen > (int)v0 );
}
return putchar(10);
}

original_code:
void print_recv(){
 printf("\n");
 for(int i = 0; i < _recvLen; i++){
  printf("%02x ", _recvBuffer[i]);
 }
 printf("\n");
}

variable_types: i int


decompiled_code:
int print_send()
{
__int64 v0; // rbx

putchar(10);
if ( sendLen )
{
v0 = 0LL;
do
printf("%02x ", (unsigned __int8)sendBuffer[v0++]);
while ( (unsigned __int16)sendLen > (int)v0 );
}
return putchar(10);
}

canonical_decompiled_code:
int func4()
{
__int64 v0; // rbx

putchar(10);
if ( sendLen )
{
v0 = 0LL;
do
printf("%02x ", (unsigned __int8)sendBuffer[v0++]);
while ( (unsigned __int16)sendLen > (int)v0 );
}
return putchar(10);
}

original_code:
void print_send(){
 printf("\n");
 for(int i = 0; i < _sendLen; i++){
  printf("%02x ", _sendBuffer[i]);
 }
 printf("\n");
}


decompiled_code:
void TestRunner_endTest()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
static void TestRunner_endTest(TestListner* self,Test* test)
{
}

canonical_original_code:
static void TestRunner_endTest(struct __TestListner *self, struct __Test *test)
{
}

variable_types: struct __TestListner { struct __TestListnerImplement { void (*startTest)(void *, void *); void (*endTest)(void *, void *); void (*addFailure)(void *, void *, char *, int, char *); } *isa; } *

variable_types: struct __Test { struct __TestImplement { char *(*name)(void *); void (*run)(void *, struct __TestResult { unsigned short runCount; unsigned short failureCount; struct __TestListner *listener; } *); int (*countTestCases)(void *); } *isa; } *

user_defined_types: struct __TestListner { struct __TestListnerImplement *isa; }

user_defined_types: struct __Test { struct __TestImplement *isa; }

user_defined_types: struct __TestImplement { char *(*name)(void *); void (*run)(void *, struct __TestResult *); int (*countTestCases)(void *); }


decompiled_code:
int TestRunner_startTest()
{
return putchar(46);
}

canonical_decompiled_code:
int func1()
{
return putchar(46);
}

original_code:
static void TestRunner_startTest(TestListner* self,Test* test)
{
 printf(".");
}

canonical_original_code:
static void TestRunner_startTest(struct __TestListner *self, struct __Test *test)
{
 printf(".");
}

user_defined_types: struct __TestListnerImplement { void (*startTest)(void *, void *); void (*endTest)(void *, void *); void (*addFailure)(void *, void *, char *, int, char *); }

user_defined_types: struct __TestResult { unsigned short runCount; unsigned short failureCount; struct __TestListner *listener; }


decompiled_code:
int __fastcall TestRunner_addFailure(__int64 a1, __int64 (__fastcall ***a2)(_QWORD), const char *a3, unsigned int a4, const char *a5)
{
const char *v8; // rax
const char *v9; // rax
char v11[56]; // [rsp+0h] [rbp-38h] BYREF

putchar(10);
v8 = (const char *)(**(__int64 (__fastcall ***)(__int64))root_)(root_);
printf(v8);
putchar(46);
v9 = (const char *)(**a2)(a2);
printf(v9);
printf(" (");
printf(a5);
putchar(32);
stdimpl_itoa(a4, v11, 10LL);
printf(v11);
printf(") ");
printf(a3);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, __int64 (__fastcall ***a2)(_QWORD), const char *a3, unsigned int a4, const char *a5)
{
const char *v8; // rax
const char *v9; // rax
char v11[56]; // [rsp+0h] [rbp-38h] BYREF

putchar(10);
v8 = (const char *)(**(__int64 (__fastcall ***)(__int64))root_)(root_);
printf(v8);
putchar(46);
v9 = (const char *)(**a2)(a2);
printf(v9);
printf(" (");
printf(a5);
putchar(32);
stdimpl_itoa(a4, v11, 10LL);
printf(v11);
printf(") ");
printf(a3);
return putchar(10);
}

original_code:
static void TestRunner_addFailure(TestListner* self,Test* test,char* msg,int line,char* file)
{
 printf("\n");
 printf(((Test*)root_)->isa->name(root_));
 printf(".");
 printf(((Test*)test)->isa->name(test));
 {
  char buf[16];
  printf(" (");
  printf(file);
  printf(" ");
  stdimpl_itoa(line, buf, 10);
  printf(buf);
  printf(") ");
 }
 printf(msg);
 printf("\n");
}

canonical_original_code:
static void TestRunner_addFailure(struct __TestListner *self, struct __Test *test, char *msg, int line, char *file)
{
 printf("\n");
 printf(((struct __Test *)root_)->isa->name(root_));
 printf(".");
 printf(((struct __Test *)test)->isa->name(test));
 {
  char buf[16];
  printf(" (");
  printf(file);
  printf(" ");
  stdimpl_itoa(line, buf, 10);
  printf(buf);
  printf(") ");
 }
 printf(msg);
 printf("\n");
}

variable_types:
msg
char *

variable_types: line int

variable_types:
file
char *

variable_types:
buf
char [16]


decompiled_code:
__int64 TestRunner_start()
{
return TestResult_init(&result_, testrunner_);
}

canonical_decompiled_code:
__int64 func3()
{
return TestResult_init(&result_, testrunner_);
}

original_code:
void TestRunner_start(void)
{
 TestResult_init(&result_, (TestListner*)&testrunner_);
}

canonical_original_code:
void TestRunner_start()
{
 TestResult_init(&result_, (struct __TestListner *)&testrunner_);
}


decompiled_code:
__int64 __fastcall TestRunner_runTest(__int64 a1)
{
root_ = a1;
return (*(__int64 (__fastcall **)(__int64, __int16 *))(*(_QWORD *)a1 + 8LL))(a1, &result_);
}

original_code:
void TestRunner_runTest(Test* test)
{
 root_ = test;
 ((Test*)test)->isa->run(test,&result_);
}

canonical_original_code:
void TestRunner_runTest(struct __Test *test)
{
 root_ = test;
 ((struct __Test *)test)->isa->run(test,&result_);
}

variable_types: struct __Test { struct __TestImplement { char *(*name)(void *); void (*run)(void *, struct __TestResult { unsigned short runCount; unsigned short failureCount; struct __TestListner { struct __TestListnerImplement { void (*startTest)(void *, void *); void (*endTest)(void *, void *); void (*addFailure)(void *, void *, char *, int, char *); } *isa; } *listener; } *); int (*countTestCases)(void *); } *isa; } *


decompiled_code:
int TestRunner_end()
{
int result; // eax
char v1[24]; // [rsp+0h] [rbp-18h] BYREF

if ( word_1E2 )
{
printf("\nrun ");
stdimpl_itoa((unsigned __int16)result_, v1, 10LL);
printf(v1);
printf(" failures ");
stdimpl_itoa((unsigned __int16)word_1E2, v1, 10LL);
printf(v1);
result = putchar(10);
}
else
{
printf("\nOK (");
stdimpl_itoa((unsigned __int16)result_, v1, 10LL);
printf(v1);
result = puts(" tests)");
}
return result;
}

canonical_decompiled_code:
int func5()
{
int result; // eax
char v1[24]; // [rsp+0h] [rbp-18h] BYREF

if ( word_1E2 )
{
printf("\nrun ");
stdimpl_itoa((unsigned __int16)result_, v1, 10LL);
printf(v1);
printf(" failures ");
stdimpl_itoa((unsigned __int16)word_1E2, v1, 10LL);
printf(v1);
result = putchar(10);
}
else
{
printf("\nOK (");
stdimpl_itoa((unsigned __int16)result_, v1, 10LL);
printf(v1);
result = puts(" tests)");
}
return result;
}

original_code:
void TestRunner_end(void)
{
 char buf[16];
 if (result_.failureCount) {
  printf("\nrun ");
  stdimpl_itoa(result_.runCount, buf, 10);
  printf(buf);
  printf(" failures ");
  stdimpl_itoa(result_.failureCount, buf, 10);
  printf(buf);
  printf("\n");
 } else {
  printf("\nOK (");
  stdimpl_itoa(result_.runCount, buf, 10);
  printf(buf);
  printf(" tests)\n");
 }
}

canonical_original_code:
void TestRunner_end()
{
 char buf[16];
 if (result_.failureCount) {
  printf("\nrun ");
  stdimpl_itoa(result_.runCount, buf, 10);
  printf(buf);
  printf(" failures ");
  stdimpl_itoa(result_.failureCount, buf, 10);
  printf(buf);
  printf("\n");
 } else {
  printf("\nOK (");
  stdimpl_itoa(result_.runCount, buf, 10);
  printf(buf);
  printf(" tests)\n");
 }
}


decompiled_code:
__int64 __fastcall stdimpl_strlen(_BYTE *a1)
{
_BYTE *v1; // rax

v1 = a1;
while ( *v1++ )
;
return (unsigned int)((_DWORD)v1 - (_DWORD)a1 - 1);
}

canonical_decompiled_code:
__int64 __fastcall func3(_BYTE *a1)
{
_BYTE *v1; // rax

v1 = a1;
while ( *v1++ )
;
return (unsigned int)((_DWORD)v1 - (_DWORD)a1 - 1);
}

original_code:
int stdimpl_strlen(const char *str)
{
    const char *estr = str;
 char c;
 do {
  c = *estr;
  estr++;
 } while (c);
    return ((int)(estr - str - 1));
}

canonical_original_code:
int stdimpl_strlen(char *str)
{
    char *estr = str;
 char c;
 do {
  c = *estr;
  estr++;
 } while (c);
    return ((int)(estr - str - 1));
}

variable_types:
str
char *

variable_types:
estr
char *

variable_types: c char


decompiled_code:
__int64 __fastcall stdimpl_strcmp(__int64 a1, __int64 a2)
{
__int64 v2; // rax
char v3; // dl
char v4; // cl

v2 = 0LL;
do
{
v3 = *(_BYTE *)(a1 + v2);
v4 = *(_BYTE *)(a2 + v2++);
}
while ( v4 != 0 && v3 != 0 && v3 == v4 );
return (unsigned int)(v3 - v4);
}

original_code:
int stdimpl_strcmp(const char *s1, const char *s2)
{
 char c1,c2;
 do {
  c1 = *s1++;
  c2 = *s2++;
 } while ((c1) && (c2) && (c1==c2));
 return c1 - c2;
}

canonical_original_code:
int stdimpl_strcmp(char *s1, char *s2)
{
 char c1; char c2;
 do {
  c1 = *s1++;
  c2 = *s2++;
 } while ((c1) && (c2) && (c1==c2));
 return c1 - c2;
}


tearDown

decompiled_code:
void tearDown()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
static void tearDown(void){
}

canonical_original_code:
static void tearDown(){
}


testTimer

decompiled_code:
__int64 testTimer()
{
int v0; // ebx
unsigned int v1; // eax
int v2; // ebx
unsigned int v3; // eax
int v4; // ebx
unsigned int v5; // eax
int v6; // ebx
unsigned int v7; // eax
__int64 result; // rax
unsigned __int16 v9; // [rsp+Ah] [rbp-Eh] BYREF
unsigned __int8 v10; // [rsp+Ch] [rbp-Ch]
unsigned __int8 v11; // [rsp+Dh] [rbp-Bh]
unsigned __int16 v12; // [rsp+Eh] [rbp-Ah]

time_init(1LL);
timer_start(&v9);
v0 = 500;
do
{
interrupt_handler();
--v0;
}
while ( v0 );
v1 = timer_get_elapsed(&v9);
v2 = 600;
if ( v1 != 500 )
return assertImplementationInt(500LL, v1, 139LL, "TimeTest.c");
do
{
interrupt_handler();
--v2;
}
while ( v2 );
v3 = timer_get_elapsed(&v9);
v4 = 80000;
if ( v3 != 1100 )
return assertImplementationInt(1100LL, v3, 145LL, "TimeTest.c");
do
{
interrupt_handler();
--v4;
}
while ( v4 );
v5 = timer_get_elapsed(&v9);
v6 = 3800000;
if ( v5 != 81100 )
return assertImplementationInt(81100LL, v5, 151LL, "TimeTest.c");
do
{
interrupt_handler();
--v6;
}
while ( v6 );
v7 = timer_get_elapsed(&v9);
if ( v7 != 3881100 )
return assertImplementationInt(3881100LL, v7, 157LL, "TimeTest.c");
timer_stop(&v9);
if ( v9 != 1 )
return assertImplementationInt(1LL, v9, 160LL, "TimeTest.c");
if ( v10 != 4 )
return assertImplementationInt(4LL, v10, 161LL, "TimeTest.c");
if ( v11 != 41 )
return assertImplementationInt(41LL, v11, 162LL, "TimeTest.c");
result = v12;
if ( v12 != 100 )
result = assertImplementationInt(100LL, v12, 163LL, "TimeTest.c");
return result;
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // ebx
unsigned int v1; // eax
int v2; // ebx
unsigned int v3; // eax
int v4; // ebx
unsigned int v5; // eax
int v6; // ebx
unsigned int v7; // eax
__int64 result; // rax
unsigned __int16 v9; // [rsp+Ah] [rbp-Eh] BYREF
unsigned __int8 v10; // [rsp+Ch] [rbp-Ch]
unsigned __int8 v11; // [rsp+Dh] [rbp-Bh]
unsigned __int16 v12; // [rsp+Eh] [rbp-Ah]

time_init(1LL);
timer_start(&v9);
v0 = 500;
do
{
interrupt_handler();
--v0;
}
while ( v0 );
v1 = timer_get_elapsed(&v9);
v2 = 600;
if ( v1 != 500 )
return assertImplementationInt(500LL, v1, 139LL, "TimeTest.c");
do
{
interrupt_handler();
--v2;
}
while ( v2 );
v3 = timer_get_elapsed(&v9);
v4 = 80000;
if ( v3 != 1100 )
return assertImplementationInt(1100LL, v3, 145LL, "TimeTest.c");
do
{
interrupt_handler();
--v4;
}
while ( v4 );
v5 = timer_get_elapsed(&v9);
v6 = 3800000;
if ( v5 != 81100 )
return assertImplementationInt(81100LL, v5, 151LL, "TimeTest.c");
do
{
interrupt_handler();
--v6;
}
while ( v6 );
v7 = timer_get_elapsed(&v9);
if ( v7 != 3881100 )
return assertImplementationInt(3881100LL, v7, 157LL, "TimeTest.c");
timer_stop(&v9);
if ( v9 != 1 )
return assertImplementationInt(1LL, v9, 160LL, "TimeTest.c");
if ( v10 != 4 )
return assertImplementationInt(4LL, v10, 161LL, "TimeTest.c");
if ( v11 != 41 )
return assertImplementationInt(41LL, v11, 162LL, "TimeTest.c");
result = v12;
if ( v12 != 100 )
result = assertImplementationInt(100LL, v12, 163LL, "TimeTest.c");
return result;
}

original_code:
static void testTimer(void){
 time_init(1);
 struct clockval cval;
 timer_start(&cval);
 int i;
 for(i = 0; i < 500; i++){
  interrupt_handler();
 }
 uint32_t time = timer_get_elapsed(&cval);
 if (500 == time) {} else {assertImplementationInt(500,time,139,"TimeTest.c");return;};
 for(i = 0; i < 600; i++){
  interrupt_handler();
 }
 time = timer_get_elapsed(&cval);
 if (1100 == time) {} else {assertImplementationInt(1100,time,145,"TimeTest.c");return;};
 for(i = 0; i < 80000; i++){
  interrupt_handler();
 }
 time = timer_get_elapsed(&cval);
 if (81100 == time) {} else {assertImplementationInt(81100,time,151,"TimeTest.c");return;};
 for(i = 0; i < 3800000; i++){
  interrupt_handler();
 }
 time = timer_get_elapsed(&cval);
 if (3881100 == time) {} else {assertImplementationInt(3881100,time,157,"TimeTest.c");return;};
 timer_stop(&cval);
 if (1 == cval.h) {} else {assertImplementationInt(1,cval.h,160,"TimeTest.c");return;};
 if (4 == cval.m) {} else {assertImplementationInt(4,cval.m,161,"TimeTest.c");return;};
 if (41 == cval.s) {} else {assertImplementationInt(41,cval.s,162,"TimeTest.c");return;};
 if (100 == cval.ms) {} else {assertImplementationInt(100,cval.ms,163,"TimeTest.c");return;};
}

canonical_original_code:
static void testTimer(){
 time_init(1);
 struct clockval cval;
 timer_start(&cval);
 int i;
 for(i = 0; i < 500; i++){
  interrupt_handler();
 }
 unsigned int time = timer_get_elapsed(&cval);
 if (500 == time) {} else {assertImplementationInt(500,time,139,"TimeTest.c");return;};
 for(i = 0; i < 600; i++){
  interrupt_handler();
 }
 time = timer_get_elapsed(&cval);
 if (1100 == time) {} else {assertImplementationInt(1100,time,145,"TimeTest.c");return;};
 for(i = 0; i < 80000; i++){
  interrupt_handler();
 }
 time = timer_get_elapsed(&cval);
 if (81100 == time) {} else {assertImplementationInt(81100,time,151,"TimeTest.c");return;};
 for(i = 0; i < 3800000; i++){
  interrupt_handler();
 }
 time = timer_get_elapsed(&cval);
 if (3881100 == time) {} else {assertImplementationInt(3881100,time,157,"TimeTest.c");return;};
 timer_stop(&cval);
 if (1 == cval.h) {} else {assertImplementationInt(1,cval.h,160,"TimeTest.c");return;};
 if (4 == cval.m) {} else {assertImplementationInt(4,cval.m,161,"TimeTest.c");return;};
 if (41 == cval.s) {} else {assertImplementationInt(41,cval.s,162,"TimeTest.c");return;};
 if (100 == cval.ms) {} else {assertImplementationInt(100,cval.ms,163,"TimeTest.c");return;};
}

variable_types: struct clockval { unsigned short h; unsigned char m; unsigned char s; unsigned short ms; }

variable_types:
time
unsigned int


testClockInterrupt

decompiled_code:
__int64 testClockInterrupt()
{
int v0; // ebx
__int64 result; // rax
unsigned __int8 v2; // [rsp+7h] [rbp-11h] BYREF
unsigned __int8 v3; // [rsp+8h] [rbp-10h]
unsigned __int8 v4; // [rsp+9h] [rbp-Fh]
unsigned __int16 v5; // [rsp+Ah] [rbp-Eh] BYREF
unsigned __int8 v6; // [rsp+Ch] [rbp-Ch]
unsigned __int8 v7; // [rsp+Dh] [rbp-Bh]
unsigned __int16 v8; // [rsp+Eh] [rbp-Ah]

time_init(1LL);
v0 = 3661000;
do
{
interrupt_handler();
--v0;
}
while ( v0 );
clock_get(&v5);
if ( v5 != 1 )
return assertImplementationInt(1LL, v5, 112LL, "TimeTest.c");
if ( v6 != 1 )
return assertImplementationInt(1LL, v6, 113LL, "TimeTest.c");
if ( v7 != 1 )
return assertImplementationInt(1LL, v7, 114LL, "TimeTest.c");
if ( v8 )
return assertImplementationInt(0LL, v8, 115LL, "TimeTest.c");
time_get(&v2);
if ( v2 != 1 )
return assertImplementationInt(1LL, v2, 119LL, "TimeTest.c");
if ( v3 != 1 )
return assertImplementationInt(1LL, v3, 120LL, "TimeTest.c");
result = v4;
if ( v4 != 1 )
result = assertImplementationInt(1LL, v4, 121LL, "TimeTest.c");
return result;
}

canonical_decompiled_code:
__int64 func4()
{
int v0; // ebx
__int64 result; // rax
unsigned __int8 v2; // [rsp+7h] [rbp-11h] BYREF
unsigned __int8 v3; // [rsp+8h] [rbp-10h]
unsigned __int8 v4; // [rsp+9h] [rbp-Fh]
unsigned __int16 v5; // [rsp+Ah] [rbp-Eh] BYREF
unsigned __int8 v6; // [rsp+Ch] [rbp-Ch]
unsigned __int8 v7; // [rsp+Dh] [rbp-Bh]
unsigned __int16 v8; // [rsp+Eh] [rbp-Ah]

time_init(1LL);
v0 = 3661000;
do
{
interrupt_handler();
--v0;
}
while ( v0 );
clock_get(&v5);
if ( v5 != 1 )
return assertImplementationInt(1LL, v5, 112LL, "TimeTest.c");
if ( v6 != 1 )
return assertImplementationInt(1LL, v6, 113LL, "TimeTest.c");
if ( v7 != 1 )
return assertImplementationInt(1LL, v7, 114LL, "TimeTest.c");
if ( v8 )
return assertImplementationInt(0LL, v8, 115LL, "TimeTest.c");
time_get(&v2);
if ( v2 != 1 )
return assertImplementationInt(1LL, v2, 119LL, "TimeTest.c");
if ( v3 != 1 )
return assertImplementationInt(1LL, v3, 120LL, "TimeTest.c");
result = v4;
if ( v4 != 1 )
result = assertImplementationInt(1LL, v4, 121LL, "TimeTest.c");
return result;
}

original_code:
static void testClockInterrupt(void){
 time_init(1);
 int i;
 for(i = 0; i < 3661000; i++){
  interrupt_handler();
 }
 struct clockval cval;
 clock_get(&cval);
 if (1 == cval.h) {} else {assertImplementationInt(1,cval.h,112,"TimeTest.c");return;};
 if (1 == cval.m) {} else {assertImplementationInt(1,cval.m,113,"TimeTest.c");return;};
 if (1 == cval.s) {} else {assertImplementationInt(1,cval.s,114,"TimeTest.c");return;};
 if (0 == cval.ms) {} else {assertImplementationInt(0,cval.ms,115,"TimeTest.c");return;};
 struct timeval tval;
 time_get(&tval);
 if (1 == tval.h) {} else {assertImplementationInt(1,tval.h,119,"TimeTest.c");return;};
 if (1 == tval.m) {} else {assertImplementationInt(1,tval.m,120,"TimeTest.c");return;};
 if (1 == tval.s) {} else {assertImplementationInt(1,tval.s,121,"TimeTest.c");return;};
}

canonical_original_code:
static void testClockInterrupt(){
 time_init(1);
 int i;
 for(i = 0; i < 3661000; i++){
  interrupt_handler();
 }
 struct clockval cval;
 clock_get(&cval);
 if (1 == cval.h) {} else {assertImplementationInt(1,cval.h,112,"TimeTest.c");return;};
 if (1 == cval.m) {} else {assertImplementationInt(1,cval.m,113,"TimeTest.c");return;};
 if (1 == cval.s) {} else {assertImplementationInt(1,cval.s,114,"TimeTest.c");return;};
 if (0 == cval.ms) {} else {assertImplementationInt(0,cval.ms,115,"TimeTest.c");return;};
 struct timeval tval;
 time_get(&tval);
 if (1 == tval.h) {} else {assertImplementationInt(1,tval.h,119,"TimeTest.c");return;};
 if (1 == tval.m) {} else {assertImplementationInt(1,tval.m,120,"TimeTest.c");return;};
 if (1 == tval.s) {} else {assertImplementationInt(1,tval.s,121,"TimeTest.c");return;};
}

variable_types: struct timeval { unsigned char h; unsigned char m; unsigned char s; }

user_defined_types: struct clockval { unsigned short h; unsigned char m; unsigned char s; unsigned short ms; }


testClockSetAndGet

decompiled_code:
__int64 testClockSetAndGet()
{
__int64 result; // rax
unsigned __int16 v1; // [rsp+Ah] [rbp-Eh] BYREF
unsigned __int8 v2; // [rsp+Ch] [rbp-Ch]
unsigned __int8 v3; // [rsp+Dh] [rbp-Bh]
unsigned __int16 v4; // [rsp+Eh] [rbp-Ah]

v1 = 346;
v2 = 17;
v3 = 34;
v4 = 456;
clock_set(&v1);
if ( clock_h != 346 )
return assertImplementationInt(346LL, (unsigned __int16)clock_h, 80LL, "TimeTest.c");
if ( clock_m != 17 )
return assertImplementationInt(17LL, (unsigned __int8)clock_m, 81LL, "TimeTest.c");
if ( clock_s != 34 )
return assertImplementationInt(34LL, (unsigned __int8)clock_s, 82LL, "TimeTest.c");
if ( clock_ms != 456 )
return assertImplementationInt(456LL, (unsigned __int16)clock_ms, 83LL, "TimeTest.c");
v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
clock_get(&v1);
if ( v1 != 346 )
return assertImplementationInt(346LL, v1, 91LL, "TimeTest.c");
if ( v2 != 17 )
return assertImplementationInt(17LL, v2, 92LL, "TimeTest.c");
if ( v3 != 34 )
return assertImplementationInt(34LL, v3, 93LL, "TimeTest.c");
result = v4;
if ( v4 != 456 )
result = assertImplementationInt(456LL, v4, 94LL, "TimeTest.c");
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax
unsigned __int16 v1; // [rsp+Ah] [rbp-Eh] BYREF
unsigned __int8 v2; // [rsp+Ch] [rbp-Ch]
unsigned __int8 v3; // [rsp+Dh] [rbp-Bh]
unsigned __int16 v4; // [rsp+Eh] [rbp-Ah]

v1 = 346;
v2 = 17;
v3 = 34;
v4 = 456;
clock_set(&v1);
if ( clock_h != 346 )
return assertImplementationInt(346LL, (unsigned __int16)clock_h, 80LL, "TimeTest.c");
if ( clock_m != 17 )
return assertImplementationInt(17LL, (unsigned __int8)clock_m, 81LL, "TimeTest.c");
if ( clock_s != 34 )
return assertImplementationInt(34LL, (unsigned __int8)clock_s, 82LL, "TimeTest.c");
if ( clock_ms != 456 )
return assertImplementationInt(456LL, (unsigned __int16)clock_ms, 83LL, "TimeTest.c");
v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
clock_get(&v1);
if ( v1 != 346 )
return assertImplementationInt(346LL, v1, 91LL, "TimeTest.c");
if ( v2 != 17 )
return assertImplementationInt(17LL, v2, 92LL, "TimeTest.c");
if ( v3 != 34 )
return assertImplementationInt(34LL, v3, 93LL, "TimeTest.c");
result = v4;
if ( v4 != 456 )
result = assertImplementationInt(456LL, v4, 94LL, "TimeTest.c");
return result;
}

original_code:
static void testClockSetAndGet(void){
 struct clockval cval;
 cval.h = 346;
 cval.m = 17;
 cval.s = 34;
 cval.ms = 456;
 clock_set(&cval);
 if (346 == _clock_h) {} else {assertImplementationInt(346,_clock_h,80,"TimeTest.c");return;};
 if (17 == _clock_m) {} else {assertImplementationInt(17,_clock_m,81,"TimeTest.c");return;};
 if (34 == _clock_s) {} else {assertImplementationInt(34,_clock_s,82,"TimeTest.c");return;};
 if (456 == _clock_ms) {} else {assertImplementationInt(456,_clock_ms,83,"TimeTest.c");return;};
 cval.h = 0;
 cval.m = 0;
 cval.s = 0;
 cval.ms = 0;
 clock_get(&cval);
 if (346 == cval.h) {} else {assertImplementationInt(346,cval.h,91,"TimeTest.c");return;};
 if (17 == cval.m) {} else {assertImplementationInt(17,cval.m,92,"TimeTest.c");return;};
 if (34 == cval.s) {} else {assertImplementationInt(34,cval.s,93,"TimeTest.c");return;};
 if (456 == cval.ms) {} else {assertImplementationInt(456,cval.ms,94,"TimeTest.c");return;};
}

canonical_original_code:
static void testClockSetAndGet(){
 struct clockval cval;
 cval.h = 346;
 cval.m = 17;
 cval.s = 34;
 cval.ms = 456;
 clock_set(&cval);
 if (346 == _clock_h) {} else {assertImplementationInt(346,_clock_h,80,"TimeTest.c");return;};
 if (17 == _clock_m) {} else {assertImplementationInt(17,_clock_m,81,"TimeTest.c");return;};
 if (34 == _clock_s) {} else {assertImplementationInt(34,_clock_s,82,"TimeTest.c");return;};
 if (456 == _clock_ms) {} else {assertImplementationInt(456,_clock_ms,83,"TimeTest.c");return;};
 cval.h = 0;
 cval.m = 0;
 cval.s = 0;
 cval.ms = 0;
 clock_get(&cval);
 if (346 == cval.h) {} else {assertImplementationInt(346,cval.h,91,"TimeTest.c");return;};
 if (17 == cval.m) {} else {assertImplementationInt(17,cval.m,92,"TimeTest.c");return;};
 if (34 == cval.s) {} else {assertImplementationInt(34,cval.s,93,"TimeTest.c");return;};
 if (456 == cval.ms) {} else {assertImplementationInt(456,cval.ms,94,"TimeTest.c");return;};
}


testTimeSetAndGet

decompiled_code:
__int64 testTimeSetAndGet()
{
__int64 result; // rax
unsigned __int8 v1; // [rsp+Dh] [rbp-Bh] BYREF
unsigned __int8 v2; // [rsp+Eh] [rbp-Ah]
unsigned __int8 v3; // [rsp+Fh] [rbp-9h]

v1 = 13;
v2 = 50;
v3 = 34;
time_set(&v1);
if ( time_h != 13 )
return assertImplementationInt(13LL, (unsigned __int8)time_h, 52LL, "TimeTest.c");
if ( time_m != 50 )
return assertImplementationInt(50LL, (unsigned __int8)time_m, 53LL, "TimeTest.c");
if ( time_s != 34 )
return assertImplementationInt(34LL, (unsigned __int8)time_s, 54LL, "TimeTest.c");
v1 = 0;
v2 = 0;
v3 = 0;
result = time_get(&v1);
if ( v1 != 13 )
return assertImplementationInt(13LL, v1, 61LL, "TimeTest.c");
if ( v2 != 50 )
return assertImplementationInt(50LL, v2, 62LL, "TimeTest.c");
if ( v3 != 34 )
result = assertImplementationInt(34LL, v3, 63LL, "TimeTest.c");
return result;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 result; // rax
unsigned __int8 v1; // [rsp+Dh] [rbp-Bh] BYREF
unsigned __int8 v2; // [rsp+Eh] [rbp-Ah]
unsigned __int8 v3; // [rsp+Fh] [rbp-9h]

v1 = 13;
v2 = 50;
v3 = 34;
time_set(&v1);
if ( time_h != 13 )
return assertImplementationInt(13LL, (unsigned __int8)time_h, 52LL, "TimeTest.c");
if ( time_m != 50 )
return assertImplementationInt(50LL, (unsigned __int8)time_m, 53LL, "TimeTest.c");
if ( time_s != 34 )
return assertImplementationInt(34LL, (unsigned __int8)time_s, 54LL, "TimeTest.c");
v1 = 0;
v2 = 0;
v3 = 0;
result = time_get(&v1);
if ( v1 != 13 )
return assertImplementationInt(13LL, v1, 61LL, "TimeTest.c");
if ( v2 != 50 )
return assertImplementationInt(50LL, v2, 62LL, "TimeTest.c");
if ( v3 != 34 )
result = assertImplementationInt(34LL, v3, 63LL, "TimeTest.c");
return result;
}

original_code:
static void testTimeSetAndGet(void){
 struct timeval tval;
 tval.h = 13;
 tval.m = 50;
 tval.s = 34;
 time_set(&tval);
 if (13 == _time_h) {} else {assertImplementationInt(13,_time_h,52,"TimeTest.c");return;};
 if (50 == _time_m) {} else {assertImplementationInt(50,_time_m,53,"TimeTest.c");return;};
 if (34 == _time_s) {} else {assertImplementationInt(34,_time_s,54,"TimeTest.c");return;};
 tval.h = 0;
 tval.m = 0;
 tval.s = 0;
 time_get(&tval);
 if (13 == tval.h) {} else {assertImplementationInt(13,tval.h,61,"TimeTest.c");return;};
 if (50 == tval.m) {} else {assertImplementationInt(50,tval.m,62,"TimeTest.c");return;};
 if (34 == tval.s) {} else {assertImplementationInt(34,tval.s,63,"TimeTest.c");return;};
}

canonical_original_code:
static void testTimeSetAndGet(){
 struct timeval tval;
 tval.h = 13;
 tval.m = 50;
 tval.s = 34;
 time_set(&tval);
 if (13 == _time_h) {} else {assertImplementationInt(13,_time_h,52,"TimeTest.c");return;};
 if (50 == _time_m) {} else {assertImplementationInt(50,_time_m,53,"TimeTest.c");return;};
 if (34 == _time_s) {} else {assertImplementationInt(34,_time_s,54,"TimeTest.c");return;};
 tval.h = 0;
 tval.m = 0;
 tval.s = 0;
 time_get(&tval);
 if (13 == tval.h) {} else {assertImplementationInt(13,tval.h,61,"TimeTest.c");return;};
 if (50 == tval.m) {} else {assertImplementationInt(50,tval.m,62,"TimeTest.c");return;};
 if (34 == tval.s) {} else {assertImplementationInt(34,tval.s,63,"TimeTest.c");return;};
}

user_defined_types: struct timeval { unsigned char h; unsigned char m; unsigned char s; }


decompiled_code:
void **TimeTest_tests()
{
return &TimeTest_1;
}

canonical_decompiled_code:
void **func7()
{
return &TimeTest_1;
}

original_code:
TestRef TimeTest_tests(void)
{
 static const TestFixture fixtures[] = {
  { "testInit", testInit, },
  { "testTimeSetAndGet", testTimeSetAndGet, },
  { "testClockSetAndGet", testClockSetAndGet, },
  { "testClockInterrupt", testClockInterrupt, },
  { "testTimer", testTimer, },
 };
 static const TestCaller TimeTest = { (TestImplement*)&TestCallerImplement, "TimeTest", setUp, tearDown, sizeof(fixtures)/sizeof(fixtures[0]), (TestFixture*)fixtures, };
 return (TestRef)&TimeTest;
}

canonical_original_code:
struct __Test *TimeTest_tests()
{
 static struct __TestFixture fixtures[] = {
  { "testInit", testInit, },
  { "testTimeSetAndGet", testTimeSetAndGet, },
  { "testClockSetAndGet", testClockSetAndGet, },
  { "testClockInterrupt", testClockInterrupt, },
  { "testTimer", testTimer, },
 };
 static struct __TestCaller TimeTest = { (TestImplement*)&TestCallerImplement, "TimeTest", setUp, tearDown, sizeof(fixtures)/sizeof(fixtures[0]), (TestFixture*)fixtures, };
 return (TestRef)&TimeTest;
}

variable_types: struct __TestFixture { char *name; void (*test)(); } []

variable_types: struct __TestCaller { struct __TestImplement { char *(*name)(void *); void (*run)(void *, struct __TestResult { unsigned short runCount; unsigned short failureCount; struct __TestListner { struct __TestListnerImplement { void (*startTest)(void *, void *); void (*endTest)(void *, void *); void (*addFailure)(void *, void *, char *, int, char *); } *isa; } *listener; } *); int (*countTestCases)(void *); } *isa; char *name; void (*setUp)(); void (*tearDown)(); int numberOfFixtuers; struct __TestFixture { char *name; void (*test)(); } *fixtuers; }

return_type: struct __Test { struct __TestImplement { char *(*name)(void *); void (*run)(void *, struct __TestResult { unsigned short runCount; unsigned short failureCount; struct __TestListner { struct __TestListnerImplement { void (*startTest)(void *, void *); void (*endTest)(void *, void *); void (*addFailure)(void *, void *, char *, int, char *); } *isa; } *listener; } *); int (*countTestCases)(void *); } *isa; } *

user_defined_types: struct __TestCaller { struct __TestImplement *isa; char *name; void (*setUp)(); void (*tearDown)(); int numberOfFixtuers; struct __TestFixture *fixtuers; }


original_code:
void TestResult_init(TestResult* self,TestListner* listner)
{
 self->runCount = 0;
 self->failureCount = 0;
 self->listener = listner;
}

canonical_original_code:
void TestResult_init(struct __TestResult *self, struct __TestListner *listner)
{
 self->runCount = 0;
 self->failureCount = 0;
 self->listener = listner;
}

variable_types: struct __TestResult { unsigned short runCount; unsigned short failureCount; struct __TestListner { struct __TestListnerImplement { void (*startTest)(void *, void *); void (*endTest)(void *, void *); void (*addFailure)(void *, void *, char *, int, char *); } *isa; } *listener; } *

variable_types:
listner
struct __TestListner *


decompiled_code:
__int64 __fastcall TestResult_startTest(__int64 a1)
{
__int64 (__fastcall ***v1)(_QWORD); // rdi
__int64 result; // rax

++*(_WORD *)a1;
v1 = *(__int64 (__fastcall ****)(_QWORD))(a1 + 8);
if ( v1 )
result = (**v1)(v1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 (__fastcall ***v1)(_QWORD); // rdi
__int64 result; // rax

++*(_WORD *)a1;
v1 = *(__int64 (__fastcall ****)(_QWORD))(a1 + 8);
if ( v1 )
result = (**v1)(v1);
return result;
}

original_code:
void TestResult_startTest(TestResult* self,Test* test)
{
 self->runCount++;
 if (self->listener) {
  ((TestListner*)self->listener)->isa->startTest(self->listener,test);
 }
}

canonical_original_code:
void TestResult_startTest(struct __TestResult *self, struct __Test *test)
{
 self->runCount++;
 if (self->listener) {
  ((struct __TestListner *)self->listener)->isa->startTest(self->listener,test);
 }
}

variable_types: struct __Test { struct __TestImplement { char *(*name)(void *); void (*run)(void *, struct __TestResult *); int (*countTestCases)(void *); } *isa; } *


decompiled_code:
__int64 __fastcall TestResult_endTest(__int64 a1)
{
__int64 v1; // rdi
__int64 result; // rax

v1 = *(_QWORD *)(a1 + 8);
if ( v1 )
result = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v1 + 8LL))(v1);
return result;
}

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

v1 = *(_QWORD *)(a1 + 8);
if ( v1 )
result = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v1 + 8LL))(v1);
return result;
}

original_code:
void TestResult_endTest(TestResult* self,Test* test)
{
 if (self->listener) {
  ((TestListner*)self->listener)->isa->endTest(self->listener,test);
 }
}

canonical_original_code:
void TestResult_endTest(struct __TestResult *self, struct __Test *test)
{
 if (self->listener) {
  ((struct __TestListner *)self->listener)->isa->endTest(self->listener,test);
 }
}


decompiled_code:
__int64 __fastcall TestResult_addFailure(__int64 a1)
{
__int64 v1; // rdi
__int64 result; // rax

++*(_WORD *)(a1 + 2);
v1 = *(_QWORD *)(a1 + 8);
if ( v1 )
result = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v1 + 16LL))(v1);
return result;
}

original_code:
void TestResult_addFailure(TestResult* self,Test* test,const char* msg,int line,const char* file)
{
 self->failureCount++;
 if (self->listener) {
  ((TestListner*)self->listener)->isa->addFailure(self->listener,test,msg,line,file);
 }
}

canonical_original_code:
void TestResult_addFailure(struct __TestResult *self, struct __Test *test, char *msg, int line, char *file)
{
 self->failureCount++;
 if (self->listener) {
  ((struct __TestListner *)self->listener)->isa->addFailure(self->listener,test,msg,line,file);
 }
}


repo: llbit/cttf

decompiled_code:
void __fastcall free_font(void ***a1)
{
void **v1; // rbp
__int64 i; // rbx

if ( !a1 )
_assert_fail("font != NULL", "text.c", 0x5Fu, "free_font");
v1 = *a1;
if ( *a1 )
{
free_ttf(*a1);
for ( i = 0LL; i != 0x80000; i += 8LL )
{
free_shape((char *)v1[1] + i);
free_edgelist((char *)v1[2] + i);
}
free(v1[1]);
free(v1[2]);
free(v1);
*a1 = 0LL;
}
}

canonical_decompiled_code:
void __fastcall func0(void ***a1)
{
void **v1; // rbp
__int64 i; // rbx

if ( !a1 )
_assert_fail("font != NULL", "text.c", 0x5Fu, "free_font");
v1 = *a1;
if ( *a1 )
{
free_ttf(*a1);
for ( i = 0LL; i != 0x80000; i += 8LL )
{
free_shape((char *)v1[1] + i);
free_edgelist((char *)v1[2] + i);
}
free(v1[1]);
free(v1[2]);
free(v1);
*a1 = 0LL;
}
}

original_code:
void free_font(font_t** font)
{
 font_t* p;
 int i;
 ((font != ((void *)0)) ? (void) (0) : __assert_fail ("font != NULL", "text.c", 95, __extension__ __PRETTY_FUNCTION__));
 p = *font;
 if (!p) return;
 free_ttf(&p->ttf);
 for (i = 0; i < 0x10000; ++i) {
  free_shape(&p->cshape[i]);
  free_edgelist(&p->cedges[i]);
 }
 free(p->cshape);
 free(p->cedges);
 free(p);
 *font = ((void *)0);
}

canonical_original_code:
void free_font(struct font **font)
{
 struct font *p;
 int i;
 ((font != ((void *)0)) ? (void) (0) : __assert_fail ("font != NULL", "text.c", 95, __extension__ __PRETTY_FUNCTION__));
 p = *font;
 if (!p) return;
 free_ttf(&p->ttf);
 for (i = 0; i < 0x10000; ++i) {
  free_shape(&p->cshape[i]);
  free_edgelist(&p->cedges[i]);
 }
 free(p->cshape);
 free(p->cedges);
 free(p);
 *font = ((void *)0);
}

variable_types: struct font { struct ttf { unsigned int *glyph_table; struct ttf_glyph_data { short *px; short *py; unsigned short *endpoints; int *state; unsigned short npoints; unsigned char ncontours; unsigned short aw; short lsb; unsigned short maxwidth; } *glyph_data; unsigned short nglyphs; unsigned short upem; unsigned short ppem; unsigned short resolution; unsigned char interpolation_level; int zerobase; int zerolsb; unsigned int nhmtx; struct ttf_long_hmetrics { unsigned short aw; short lsb; } *plhmtx; short *plsb; short xmin; short ymin; short xmax; short ymax; unsigned int *idx2loc; struct ttf_horizontal_header { unsigned int version; short ascender; short descender; short linegap; unsigned short advanceWidthMax; short minLeftSideBearing; short minRightSideBearing; short xMaxExtent; short caretSlopeRise; short caretSlopeRun; short reserved01; short reserved02; short reserved03; short reserved04; short reserved05; short metricDataFormat; unsigned short num_h_metrics; } *hh; struct ttf_font_header { unsigned int version; unsigned int font_revision; unsigned int checksumAdjust; unsigned int magic; unsigned short flags; unsigned short upem; unsigned char created[8]; unsigned char modified[8]; short xmin; short ymin; short xmax; short ymax; unsigned short mac_style; unsigned short lowest_rec_ppm; short direction_hint; short index_to_loc_format; short glyph_data_format; } *fh; struct ttf_table_header { unsigned int tag; unsigned int checksum; unsigned int offset; unsigned int length; } *cmap; struct ttf_table_header *glyf; struct ttf_table_header *head; struct ttf_table_header *hhea; struct ttf_table_header *hmtx; struct ttf_table_header *loca; struct ttf_table_header *maxp; } *ttf; struct shape { struct vector { float x; float y; } *vec; int nvec; int maxvec; int *seg; int nseg; int maxseg; } **cshape; struct edge_list { int nvert; struct vertex { enum vtype { START_VERTEX=0, END_VERTEX=1, SPLIT_VERTEX=2, MERGE_VERTEX=3, REGULAR_VERTEX=4, UNCLASSIFIED_VERTEX=5 } vtype; struct vector vec; struct edge { struct vertex *origin; struct face { struct list { struct list *succ; struct list *pred; void *data; } *inner_components; struct edge *outer_component; int is_inside; } *left_face; struct edge *twin; struct edge *succ; struct edge *pred; struct vertex *helper; int cycle; } *incident_edge; int flags; int id; } **vertices; struct list *faces; struct list *cycles; struct binary_search_tree { struct binary_search_tree *parent; void *value; void *rvalue; void *min; void *max; struct binary_search_tree *left; struct binary_search_tree *right; } *etree; struct list *edges; } **cedges; } **

variable_types: i int

user_defined_types: struct font { struct ttf *ttf; struct shape **cshape; struct edge_list **cedges; }

user_defined_types: struct ttf { unsigned int *glyph_table; struct ttf_glyph_data *glyph_data; unsigned short nglyphs; unsigned short upem; unsigned short ppem; unsigned short resolution; unsigned char interpolation_level; int zerobase; int zerolsb; unsigned int nhmtx; struct ttf_long_hmetrics *plhmtx; short *plsb; short xmin; short ymin; short xmax; short ymax; unsigned int *idx2loc; struct ttf_horizontal_header *hh; struct ttf_font_header *fh; struct ttf_table_header *cmap; struct ttf_table_header *glyf; struct ttf_table_header *head; struct ttf_table_header *hhea; struct ttf_table_header *hmtx; struct ttf_table_header *loca; struct ttf_table_header *maxp; }

user_defined_types: struct shape { struct vector *vec; int nvec; int maxvec; int *seg; int nseg; int maxseg; }

user_defined_types: struct edge_list { int nvert; struct vertex **vertices; struct list *faces; struct list *cycles; struct binary_search_tree *etree; struct list *edges; }

user_defined_types: struct vertex { enum vtype vtype; struct vector vec; struct edge *incident_edge; int flags; int id; }

user_defined_types: struct edge { struct vertex *origin; struct face *left_face; struct edge *twin; struct edge *succ; struct edge *pred; struct vertex *helper; int cycle; }

user_defined_types: struct face { struct list *inner_components; struct edge *outer_component; int is_inside; }


decompiled_code:
__int64 __fastcall font_prepare_chr(__int64 *a1, unsigned __int16 a2, int a3)
{
__int64 v5; // rdi
_QWORD *v6; // r14
__int64 result; // rax
__int64 *v8; // r12

if ( !a1 )
_assert_fail("font != NULL", "text.c", 0x6Fu, "font_prepare_chr");
v5 = *a1;
if ( !v5 )
_assert_fail("font->ttf != NULL", "text.c", 0x70u, "font_prepare_chr");
v6 = (_QWORD *)(a1[1] + 8LL * a2);
if ( !*v6 )
*v6 = ttf_export_chr_shape(v5, a2);
result = a1[1];
if ( a3 && *(_QWORD *)(result + 8LL * a2) )
{
v8 = (__int64 *)(a1[2] + 8LL * a2);
if ( !*v8 )
{
result = triangulate();
*v8 = result;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 *a1, unsigned __int16 a2, int a3)
{
__int64 v5; // rdi
_QWORD *v6; // r14
__int64 result; // rax
__int64 *v8; // r12

if ( !a1 )
_assert_fail("font != NULL", "text.c", 0x6Fu, "font_prepare_chr");
v5 = *a1;
if ( !v5 )
_assert_fail("font->ttf != NULL", "text.c", 0x70u, "font_prepare_chr");
v6 = (_QWORD *)(a1[1] + 8LL * a2);
if ( !*v6 )
*v6 = ttf_export_chr_shape(v5, a2);
result = a1[1];
if ( a3 && *(_QWORD *)(result + 8LL * a2) )
{
v8 = (__int64 *)(a1[2] + 8LL * a2);
if ( !*v8 )
{
result = triangulate();
*v8 = result;
}
}
return result;
}

original_code:
void font_prepare_chr(font_t* font, uint16_t chr, int triangulated)
{
 ((font != ((void *)0)) ? (void) (0) : __assert_fail ("font != NULL", "text.c", 111, __extension__ __PRETTY_FUNCTION__));
 ((font->ttf != ((void *)0)) ? (void) (0) : __assert_fail ("font->ttf != NULL", "text.c", 112, __extension__ __PRETTY_FUNCTION__));
 if (!font->cshape[chr]) {
  font->cshape[chr] = ttf_export_chr_shape(font->ttf, chr);
 }
 if (font->cshape[chr] && triangulated && !font->cedges[chr]) {
  font->cedges[chr] = triangulate(font->cshape[chr]);
 }
}

canonical_original_code:
void font_prepare_chr(struct font *font, unsigned short chr, int triangulated)
{
 ((font != ((void *)0)) ? (void) (0) : __assert_fail ("font != NULL", "text.c", 111, __extension__ __PRETTY_FUNCTION__));
 ((font->ttf != ((void *)0)) ? (void) (0) : __assert_fail ("font->ttf != NULL", "text.c", 112, __extension__ __PRETTY_FUNCTION__));
 if (!font->cshape[chr]) {
  font->cshape[chr] = ttf_export_chr_shape(font->ttf, chr);
 }
 if (font->cshape[chr] && triangulated && !font->cedges[chr]) {
  font->cedges[chr] = triangulate(font->cshape[chr]);
 }
}

variable_types: struct font { struct ttf { unsigned int *glyph_table; struct ttf_glyph_data { short *px; short *py; unsigned short *endpoints; int *state; unsigned short npoints; unsigned char ncontours; unsigned short aw; short lsb; unsigned short maxwidth; } *glyph_data; unsigned short nglyphs; unsigned short upem; unsigned short ppem; unsigned short resolution; unsigned char interpolation_level; int zerobase; int zerolsb; unsigned int nhmtx; struct ttf_long_hmetrics { unsigned short aw; short lsb; } *plhmtx; short *plsb; short xmin; short ymin; short xmax; short ymax; unsigned int *idx2loc; struct ttf_horizontal_header { unsigned int version; short ascender; short descender; short linegap; unsigned short advanceWidthMax; short minLeftSideBearing; short minRightSideBearing; short xMaxExtent; short caretSlopeRise; short caretSlopeRun; short reserved01; short reserved02; short reserved03; short reserved04; short reserved05; short metricDataFormat; unsigned short num_h_metrics; } *hh; struct ttf_font_header { unsigned int version; unsigned int font_revision; unsigned int checksumAdjust; unsigned int magic; unsigned short flags; unsigned short upem; unsigned char created[8]; unsigned char modified[8]; short xmin; short ymin; short xmax; short ymax; unsigned short mac_style; unsigned short lowest_rec_ppm; short direction_hint; short index_to_loc_format; short glyph_data_format; } *fh; struct ttf_table_header { unsigned int tag; unsigned int checksum; unsigned int offset; unsigned int length; } *cmap; struct ttf_table_header *glyf; struct ttf_table_header *head; struct ttf_table_header *hhea; struct ttf_table_header *hmtx; struct ttf_table_header *loca; struct ttf_table_header *maxp; } *ttf; struct shape { struct vector { float x; float y; } *vec; int nvec; int maxvec; int *seg; int nseg; int maxseg; } **cshape; struct edge_list { int nvert; struct vertex { enum vtype { START_VERTEX=0, END_VERTEX=1, SPLIT_VERTEX=2, MERGE_VERTEX=3, REGULAR_VERTEX=4, UNCLASSIFIED_VERTEX=5 } vtype; struct vector vec; struct edge { struct vertex *origin; struct face { struct list { struct list *succ; struct list *pred; void *data; } *inner_components; struct edge *outer_component; int is_inside; } *left_face; struct edge *twin; struct edge *succ; struct edge *pred; struct vertex *helper; int cycle; } *incident_edge; int flags; int id; } **vertices; struct list *faces; struct list *cycles; struct binary_search_tree { struct binary_search_tree *parent; void *value; void *rvalue; void *min; void *max; struct binary_search_tree *left; struct binary_search_tree *right; } *etree; struct list *edges; } **cedges; } *

variable_types:
chr
unsigned short

variable_types: triangulated int


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

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

original_code:
float line_width(font_t* font, const char* str)
{
 return ttf_line_width(font->ttf, str);
}

canonical_original_code:
float line_width(struct font *font, char *str)
{
 return ttf_line_width(font->ttf, str);
}

return_type: float

user_defined_types: struct ttf_glyph_data { short *px; short *py; unsigned short *endpoints; int *state; unsigned short npoints; unsigned char ncontours; unsigned short aw; short lsb; unsigned short maxwidth; }

user_defined_types: struct ttf_long_hmetrics { unsigned short aw; short lsb; }

user_defined_types: struct ttf_horizontal_header { unsigned int version; short ascender; short descender; short linegap; unsigned short advanceWidthMax; short minLeftSideBearing; short minRightSideBearing; short xMaxExtent; short caretSlopeRise; short caretSlopeRun; short reserved01; short reserved02; short reserved03; short reserved04; short reserved05; short metricDataFormat; unsigned short num_h_metrics; }

user_defined_types: struct ttf_font_header { unsigned int version; unsigned int font_revision; unsigned int checksumAdjust; unsigned int magic; unsigned short flags; unsigned short upem; unsigned char created[8]; unsigned char modified[8]; short xmin; short ymin; short xmax; short ymax; unsigned short mac_style; unsigned short lowest_rec_ppm; short direction_hint; short index_to_loc_format; short glyph_data_format; }

user_defined_types: struct ttf_table_header { unsigned int tag; unsigned int checksum; unsigned int offset; unsigned int length; }

user_defined_types: struct binary_search_tree { struct binary_search_tree *parent; void *value; void *rvalue; void *min; void *max; struct binary_search_tree *left; struct binary_search_tree *right; }

user_defined_types: enum vtype { START_VERTEX=0, END_VERTEX=1, SPLIT_VERTEX=2, MERGE_VERTEX=3, REGULAR_VERTEX=4, UNCLASSIFIED_VERTEX=5 }

user_defined_types: struct list { struct list *succ; struct list *pred; void *data; }


decompiled_code:
float __fastcall line_height(__int64 a1)
{
if ( !a1 )
_assert_fail("font != NULL", "text.c", 0x81u, "line_height");
return (float)(*(__int16 *)(*(_QWORD *)a1 + 62LL) - *(__int16 *)(*(_QWORD *)a1 + 58LL))
/ (float)*(unsigned __int16 *)(*(_QWORD *)a1 + 18LL);
}

canonical_decompiled_code:
float __fastcall func3(__int64 a1)
{
if ( !a1 )
_assert_fail("font != NULL", "text.c", 0x81u, "line_height");
return (float)(*(__int16 *)(*(_QWORD *)a1 + 62LL) - *(__int16 *)(*(_QWORD *)a1 + 58LL))
/ (float)*(unsigned __int16 *)(*(_QWORD *)a1 + 18LL);
}

original_code:
float line_height(font_t* font)
{
 ((font != ((void *)0)) ? (void) (0) : __assert_fail ("font != NULL", "text.c", 129, __extension__ __PRETTY_FUNCTION__));
 return (font->ttf->ymax - font->ttf->ymin) /
  (float) font->ttf->upem;
}

canonical_original_code:
float line_height(struct font *font)
{
 ((font != ((void *)0)) ? (void) (0) : __assert_fail ("font != NULL", "text.c", 129, __extension__ __PRETTY_FUNCTION__));
 return (font->ttf->ymax - font->ttf->ymin) /
  (float) font->ttf->upem;
}