decompiled_code:
__int64 __fastcall Arr_insert(__int64 a1, int a2, int a3)
{
unsigned int v3; // er12
int v4; // er13
__int64 result; // rax
__int64 v8; // rdi
int *v9; // rax
__int64 v10; // rcx
int v11; // edx

v3 = *(unsigned __int8 *)(a1 + 20);
if ( (_BYTE)v3 != 49 )
Arr_error("Array is not inited yet!!");
if ( a2 < 0 || (v4 = *(_DWORD *)(a1 + 12), v4 <= a2) )
{
puts("the position is over the length of array, please use Arr_add instead");
return 48LL;
}
if ( (unsigned __int8)Arr_is_full(a1) == 49 )
{
if ( (unsigned __int8)Arr_extend(a1, *(_DWORD *)(a1 + 16)) == 48 )
return 48LL;
v4 = *(_DWORD *)(a1 + 12);
}
v8 = *(_QWORD *)a1;
if ( a2 <= v4 - 1 )
{
v9 = (int *)(v8 + 4LL * (v4 - 1));
v10 = (__int64)&v9[-(v4 + ~a2) - 1];
do
{
v11 = *v9--;
v9[2] = v11;
}
while ( v9 != (int *)v10 );
}
*(_DWORD *)(v8 + 4LL * a2) = a3;
result = v3;
++*(_DWORD *)(a1 + 12);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, int a2, int a3)
{
unsigned int v3; // er12
int v4; // er13
__int64 result; // rax
__int64 v8; // rdi
int *v9; // rax
__int64 v10; // rcx
int v11; // edx

v3 = *(unsigned __int8 *)(a1 + 20);
if ( (_BYTE)v3 != 49 )
func1("Array is not inited yet!!");
if ( a2 < 0 || (v4 = *(_DWORD *)(a1 + 12), v4 <= a2) )
{
puts("the position is over the length of array, please use Arr_add instead");
return 48LL;
}
if ( (unsigned __int8)func5(a1) == 49 )
{
if ( (unsigned __int8)func2(a1, *(_DWORD *)(a1 + 16)) == 48 )
return 48LL;
v4 = *(_DWORD *)(a1 + 12);
}
v8 = *(_QWORD *)a1;
if ( a2 <= v4 - 1 )
{
v9 = (int *)(v8 + 4LL * (v4 - 1));
v10 = (__int64)&v9[-(v4 + ~a2) - 1];
do
{
v11 = *v9--;
v9[2] = v11;
}
while ( v9 != (int *)v10 );
}
*(_DWORD *)(v8 + 4LL * a2) = a3;
result = v3;
++*(_DWORD *)(a1 + 12);
return result;
}

original_code:
char Arr_insert(struct Arrlist * pArr, int position, int val){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if((position < 0) || (position >= pArr->cur_len)){
  printf("the position is over the length of array, please use Arr_add instead\n");
  return '0';
 }
 if('1' == Arr_is_full(pArr)){
  if ('0' == Arr_extend(pArr, pArr->increment)){
   return '0';
  }
 }
 int i;
 for (i=(pArr->cur_len -1); i>= position; i--){
  pArr->paddr[i+1] = pArr->paddr[i];
 }
 pArr->paddr[position] = val;
 pArr->cur_len++;
        return '1';
}

canonical_original_code:
char Arr_insert(struct Arrlist *pArr, int position, int val){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if((position < 0) || (position >= pArr->cur_len)){
  printf("the position is over the length of array, please use Arr_add instead\n");
  return '0';
 }
 if('1' == Arr_is_full(pArr)){
  if ('0' == Arr_extend(pArr, pArr->increment)){
   return '0';
  }
 }
 int i;
 for (i=(pArr->cur_len -1); i>= position; i--){
  pArr->paddr[i+1] = pArr->paddr[i];
 }
 pArr->paddr[position] = val;
 pArr->cur_len++;
        return '1';
}

variable_types: position int


decompiled_code:
__int64 __fastcall Arr_delete(__int64 *a1, int a2)
{
unsigned int v2; // er8
__int64 v3; // rdx
int v4; // esi
__int64 v5; // rcx
__int64 v6; // rax
__int64 result; // rax

v2 = *((unsigned __int8 *)a1 + 20);
if ( (_BYTE)v2 != 49 )
Arr_error("Array is not inited yet!!");
if ( a2 < 0 || (v3 = *((int *)a1 + 3), (int)v3 <= a2) )
{
puts("the element is not existed yet");
result = 48LL;
}
else
{
v4 = a2 + 1;
v5 = *a1;
if ( (int)v3 > v4 )
{
v6 = v4;
do
{
*(_DWORD *)(v5 + 4 * v6 - 4) = *(_DWORD *)(v5 + 4 * v6);
v3 = *((int *)a1 + 3);
++v6;
}
while ( (int)v3 > (int)v6 );
}
*(_DWORD *)(v5 + 4 * v3 - 4) = 0;
result = v2;
--*((_DWORD *)a1 + 3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 *a1, int a2)
{
unsigned int v2; // er8
__int64 v3; // rdx
int v4; // esi
__int64 v5; // rcx
__int64 v6; // rax
__int64 result; // rax

v2 = *((unsigned __int8 *)a1 + 20);
if ( (_BYTE)v2 != 49 )
func1("Array is not inited yet!!");
if ( a2 < 0 || (v3 = *((int *)a1 + 3), (int)v3 <= a2) )
{
puts("the element is not existed yet");
result = 48LL;
}
else
{
v4 = a2 + 1;
v5 = *a1;
if ( (int)v3 > v4 )
{
v6 = v4;
do
{
*(_DWORD *)(v5 + 4 * v6 - 4) = *(_DWORD *)(v5 + 4 * v6);
v3 = *((int *)a1 + 3);
++v6;
}
while ( (int)v3 > (int)v6 );
}
*(_DWORD *)(v5 + 4 * v3 - 4) = 0;
result = v2;
--*((_DWORD *)a1 + 3);
}
return result;
}

original_code:
char Arr_delete(struct Arrlist * pArr, int index){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if((index < 0) || (index >= pArr->cur_len)) {
  printf("the element is not existed yet\n");
  return '0';
 }
 int i;
 for(i = (index + 1); i <= (pArr->cur_len -1); i++){
  pArr->paddr[i-1]=pArr->paddr[i];
 }
 pArr->paddr[pArr->cur_len-1]=0;
 pArr->cur_len--;
 return '1';
}

canonical_original_code:
char Arr_delete(struct Arrlist *pArr, int index){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if((index < 0) || (index >= pArr->cur_len)) {
  printf("the element is not existed yet\n");
  return '0';
 }
 int i;
 for(i = (index + 1); i <= (pArr->cur_len -1); i++){
  pArr->paddr[i-1]=pArr->paddr[i];
 }
 pArr->paddr[pArr->cur_len-1]=0;
 pArr->cur_len--;
 return '1';
}

variable_types: struct Arrlist { int *paddr; int len; int cur_len; int increment; char is_inited; } *

variable_types: index int

variable_types: i int

return_type: char


decompiled_code:
__int64 __fastcall Arr_invert(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rcx
__int64 v3; // rdx
int v4; // esi

if ( *(_BYTE *)(a1 + 20) != 49 )
Arr_error("Array is not inited yet!!");
result = Arr_is_empty(a1);
if ( (_BYTE)result != 49 )
{
result = (unsigned int)(*(_DWORD *)(a1 + 12) - 1);
if ( *(_DWORD *)(a1 + 12) - 1 > 0 )
{
v2 = *(_QWORD *)a1;
result = (int)result;
v3 = 0LL;
do
{
v4 = *(_DWORD *)(v2 + 4 * v3);
*(_DWORD *)(v2 + 4 * v3++) = *(_DWORD *)(v2 + 4 * result);
*(_DWORD *)(v2 + 4 * result--) = v4;
}
while ( (int)result > (int)v3 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rcx
__int64 v3; // rdx
int v4; // esi

if ( *(_BYTE *)(a1 + 20) != 49 )
func1("Array is not inited yet!!");
result = func4(a1);
if ( (_BYTE)result != 49 )
{
result = (unsigned int)(*(_DWORD *)(a1 + 12) - 1);
if ( *(_DWORD *)(a1 + 12) - 1 > 0 )
{
v2 = *(_QWORD *)a1;
result = (int)result;
v3 = 0LL;
do
{
v4 = *(_DWORD *)(v2 + 4 * v3);
*(_DWORD *)(v2 + 4 * v3++) = *(_DWORD *)(v2 + 4 * result);
*(_DWORD *)(v2 + 4 * result--) = v4;
}
while ( (int)result > (int)v3 );
}
}
return result;
}

original_code:
void Arr_invert(struct Arrlist * pArr){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if ('1' == Arr_is_empty(pArr)){
  return;
 }
 int i = 0;
 int j = pArr->cur_len -1;
 int m;
 while(i<j){
  m = pArr->paddr[i];
  pArr->paddr[i] = pArr->paddr[j];
  pArr->paddr[j] = m;
  i++;
  j--;
 }
}

canonical_original_code:
void Arr_invert(struct Arrlist *pArr){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if ('1' == Arr_is_empty(pArr)){
  return;
 }
 int i = 0;
 int j = pArr->cur_len -1;
 int m;
 while(i<j){
  m = pArr->paddr[i];
  pArr->paddr[i] = pArr->paddr[j];
  pArr->paddr[j] = m;
  i++;
  j--;
 }
}

variable_types: j int

variable_types: m int

return_type: void

user_defined_types: struct Arrlist { int *paddr; int len; int cur_len; int increment; char is_inited; }


decompiled_code:
void __fastcall Arr_sort(__int64 a1)
{
if ( *(_BYTE *)(a1 + 20) != 49 )
Arr_error("Array is not inited yet!!");
if ( (unsigned __int8)Arr_is_empty(a1) != 49 )
Arr_sort_dtlmaopao(*(_QWORD *)a1, *(_DWORD *)(a1 + 12));
}

canonical_decompiled_code:
void __fastcall func13(__int64 a1)
{
if ( *(_BYTE *)(a1 + 20) != 49 )
func1("Array is not inited yet!!");
if ( (unsigned __int8)func4(a1) != 49 )
func0(*(_QWORD *)a1, *(_DWORD *)(a1 + 12));
}

original_code:
void Arr_sort(struct Arrlist * pArr){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if ('1' == Arr_is_empty(pArr)){
  return;
 }
 Arr_sort_dtlmaopao(pArr->paddr, pArr->cur_len);
}

canonical_original_code:
void Arr_sort(struct Arrlist *pArr){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if ('1' == Arr_is_empty(pArr)){
  return;
 }
 Arr_sort_dtlmaopao(pArr->paddr, pArr->cur_len);
}


decompiled_code:
__int64 __fastcall malloc_41(void **a1, int a2)
{
*a1 = realloc(*a1, 4LL * a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(void **a1, int a2)
{
*a1 = realloc(*a1, 4LL * a2);
return 0LL;
}

original_code:
int malloc_41(int ** pa, int len){
 *pa = (int *)realloc(*pa, sizeof(int)* (len));
 return 0;
}

canonical_original_code:
int malloc_41(int **pa, int len){
 *pa = (int *)realloc(*pa, sizeof(int)* (len));
 return 0;
}

variable_types:
pa
int **

variable_types: len int

return_type: int


decompiled_code:
__int64 array1_1()
{
char v0; // bl
signed int i; // ebx
unsigned int v2; // ebx
unsigned int v3; // eax
__int64 v4; // rsi
__int64 v6; // [rsp+0h] [rbp-28h] BYREF
unsigned int v7; // [rsp+8h] [rbp-20h]
unsigned int v8; // [rsp+Ch] [rbp-1Ch]

Arr_init(&v6, 10LL);
v0 = Arr_is_empty(&v6);
printf("len is %d\n", v7);
printf("is empty is %c\n", (unsigned int)v0);
putchar(10);
if ( (int)v7 > 0 )
{
for ( i = 0; i < (int)v7; Arr_add(&v6, (unsigned int)(3 * i)) )
++i;
}
v2 = 4;
printf("cur_len is %d\n", v8);
putchar(10);
v3 = Arr_get(&v6, 8LL);
Arr_set(&v6, 9LL, v3);
Arr_set(&v6, 10LL, 100LL);
Arr_insert(&v6, 10LL, 11111LL);
Arr_insert(&v6, 3LL, 11111LL);
Arr_insert(&v6, 3LL, 22222LL);
Arr_delete(&v6, 4LL);
Arr_show(&v6);
do
{
v4 = v2;
v2 += 4;
Arr_add(&v6, v4);
}
while ( v2 != 84 );
printf("cur_len is %d\n", v8);
printf("len is %d\n", v7);
putchar(10);
Arr_show(&v6);
putchar(10);
Arr_invert(&v6);
Arr_show(&v6);
putchar(10);
Arr_sort(&v6);
Arr_show(&v6);
putchar(10);
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
char v0; // bl
signed int i; // ebx
unsigned int v2; // ebx
unsigned int v3; // eax
__int64 v4; // rsi
__int64 v6; // [rsp+0h] [rbp-28h] BYREF
unsigned int v7; // [rsp+8h] [rbp-20h]
unsigned int v8; // [rsp+Ch] [rbp-1Ch]

Arr_init(&v6, 10LL);
v0 = Arr_is_empty(&v6);
printf("len is %d\n", v7);
printf("is empty is %c\n", (unsigned int)v0);
putchar(10);
if ( (int)v7 > 0 )
{
for ( i = 0; i < (int)v7; Arr_add(&v6, (unsigned int)(3 * i)) )
++i;
}
v2 = 4;
printf("cur_len is %d\n", v8);
putchar(10);
v3 = Arr_get(&v6, 8LL);
Arr_set(&v6, 9LL, v3);
Arr_set(&v6, 10LL, 100LL);
Arr_insert(&v6, 10LL, 11111LL);
Arr_insert(&v6, 3LL, 11111LL);
Arr_insert(&v6, 3LL, 22222LL);
Arr_delete(&v6, 4LL);
Arr_show(&v6);
do
{
v4 = v2;
v2 += 4;
Arr_add(&v6, v4);
}
while ( v2 != 84 );
printf("cur_len is %d\n", v8);
printf("len is %d\n", v7);
putchar(10);
Arr_show(&v6);
putchar(10);
Arr_invert(&v6);
Arr_show(&v6);
putchar(10);
Arr_sort(&v6);
Arr_show(&v6);
putchar(10);
return 0LL;
}

original_code:
int array1_1(){
 struct Arrlist arr1;
 struct Arrlist * parr1;
 parr1 = &arr1;
 Arr_init(parr1,10);
 char empty =Arr_is_empty(parr1);
 printf("len is %d\n",parr1->len);
 printf("is empty is %c\n",empty);
 printf("\n");
 int i;
 for (i=0;i<parr1->len;i++){
  Arr_add(parr1,(i+1) * 3);
 }
 printf("cur_len is %d\n",parr1->cur_len);
 printf("\n");
 Arr_set(parr1, 9,Arr_get(parr1,8));
 Arr_set(parr1, 10,100);
 Arr_insert(parr1, 10,11111);
 Arr_insert(parr1, 3,11111);
 Arr_insert(parr1, 3,22222);
 Arr_delete(parr1, 4);
 Arr_show(parr1);
 for (i=0; i<20; i++){
  Arr_add(parr1,(i+1)*4);
 }
     printf("cur_len is %d\n",parr1->cur_len);
 printf("len is %d\n",parr1->len);
 printf("\n");
 Arr_show(parr1);
 printf("\n");
 Arr_invert(parr1);
 Arr_show(parr1);
 printf("\n");
 Arr_sort(parr1);
 Arr_show(parr1);
 printf("\n");
 return 0;
}

canonical_original_code:
int array1_1(){
 struct Arrlist arr1;
 struct Arrlist *parr1;
 parr1 = &arr1;
 Arr_init(parr1,10);
 char empty = Arr_is_empty(parr1);
 printf("len is %d\n",parr1->len);
 printf("is empty is %c\n",empty);
 printf("\n");
 int i;
 for (i=0;i<parr1->len;i++){
  Arr_add(parr1,(i+1) * 3);
 }
 printf("cur_len is %d\n",parr1->cur_len);
 printf("\n");
 Arr_set(parr1, 9,Arr_get(parr1,8));
 Arr_set(parr1, 10,100);
 Arr_insert(parr1, 10,11111);
 Arr_insert(parr1, 3,11111);
 Arr_insert(parr1, 3,22222);
 Arr_delete(parr1, 4);
 Arr_show(parr1);
 for (i=0; i<20; i++){
  Arr_add(parr1,(i+1)*4);
 }
     printf("cur_len is %d\n",parr1->cur_len);
 printf("len is %d\n",parr1->len);
 printf("\n");
 Arr_show(parr1);
 printf("\n");
 Arr_invert(parr1);
 Arr_show(parr1);
 printf("\n");
 Arr_sort(parr1);
 Arr_show(parr1);
 printf("\n");
 return 0;
}

variable_types: struct Arrlist { int *paddr; int len; int cur_len; int increment; char is_inited; }

variable_types: empty char


decompiled_code:
__int64 array1_2()
{
_BYTE v1[40]; // [rsp+0h] [rbp-28h] BYREF

Arr_init(v1, 10LL);
Arr_add(v1, 3LL);
Arr_add(v1, 2LL);
Arr_add(v1, 1LL);
Arr_add(v1, 6LL);
Arr_add(v1, 5LL);
Arr_add(v1, 0LL);
Arr_add(v1, 1LL);
Arr_add(v1, 7LL);
Arr_add(v1, 0LL);
Arr_add(v1, 4LL);
Arr_show(v1);
putchar(10);
Arr_sort(v1);
putchar(10);
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
_BYTE v1[40]; // [rsp+0h] [rbp-28h] BYREF

Arr_init(v1, 10LL);
Arr_add(v1, 3LL);
Arr_add(v1, 2LL);
Arr_add(v1, 1LL);
Arr_add(v1, 6LL);
Arr_add(v1, 5LL);
Arr_add(v1, 0LL);
Arr_add(v1, 1LL);
Arr_add(v1, 7LL);
Arr_add(v1, 0LL);
Arr_add(v1, 4LL);
Arr_show(v1);
putchar(10);
Arr_sort(v1);
putchar(10);
return 0LL;
}

original_code:
int array1_2(){
 struct Arrlist arr1;
 struct Arrlist * parr1;
 parr1 = &arr1;
 Arr_init(parr1,10);
 Arr_add(parr1,3);
 Arr_add(parr1,2);
 Arr_add(parr1,1);
 Arr_add(parr1,6);
 Arr_add(parr1,5);
 Arr_add(parr1,0);
 Arr_add(parr1,1);
 Arr_add(parr1,7);
 Arr_add(parr1,0);
 Arr_add(parr1,4);
 Arr_show(parr1);
 printf("\n");
 Arr_sort(parr1);
 printf("\n");
 return 0;
}

canonical_original_code:
int array1_2(){
 struct Arrlist arr1;
 struct Arrlist *parr1;
 parr1 = &arr1;
 Arr_init(parr1,10);
 Arr_add(parr1,3);
 Arr_add(parr1,2);
 Arr_add(parr1,1);
 Arr_add(parr1,6);
 Arr_add(parr1,5);
 Arr_add(parr1,0);
 Arr_add(parr1,1);
 Arr_add(parr1,7);
 Arr_add(parr1,0);
 Arr_add(parr1,4);
 Arr_show(parr1);
 printf("\n");
 Arr_sort(parr1);
 printf("\n");
 return 0;
}


decompiled_code:
__int64 array1_main()
{
array1_1();
puts("array1_main done");
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
func1();
puts("array1_main done");
return 0LL;
}

original_code:
int array1_main(){
 int i=0;
 i=array1_1();
 printf("array1_main done\n");
 return 0;
}

canonical_original_code:
int array1_main(){
 int i = 0;
 i=array1_1();
 printf("array1_main done\n");
 return 0;
}


decompiled_code:
__int64 char_array1()
{
char *v0; // rbx
__int64 v1; // rsi
int v3; // [rsp+Ch] [rbp-1Ch] BYREF
char v4; // [rsp+10h] [rbp-18h] BYREF

printf("char a is %c\n", 97LL);
v3 = 6512994;
v0 = (char *)&v3;
printf("char b is %s\n", (const char *)&v3);
printf("sizeof(b) is %ld\n", 4LL);
do
{
v1 = (unsigned int)*v0++;
printf("%c\n", v1);
}
while ( v0 != &v4 );
puts("char_array1");
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
char *v0; // rbx
__int64 v1; // rsi
int v3; // [rsp+Ch] [rbp-1Ch] BYREF
char v4; // [rsp+10h] [rbp-18h] BYREF

printf("char a is %c\n", 97LL);
v3 = 6512994;
v0 = (char *)&v3;
printf("char b is %s\n", (const char *)&v3);
printf("sizeof(b) is %ld\n", 4LL);
do
{
v1 = (unsigned int)*v0++;
printf("%c\n", v1);
}
while ( v0 != &v4 );
puts("char_array1");
return 0LL;
}

original_code:
int char_array1(){
char a;
a='a';
printf("char a is %c\n",a);
char b[]="bac";
printf("char b is %s\n",b);
printf("sizeof(b) is %ld\n",sizeof(b));
char *p;
p=b;
int i;
for (i=0;i<=3;i++){
 printf("%c\n",*(p+i));
}
printf("char_array1\n");
return 0;
}

canonical_original_code:
int char_array1(){
char a;
a='a';
printf("char a is %c\n",a);
char b[] = "bac";
printf("char b is %s\n",b);
printf("sizeof(b) is %ld\n",sizeof(b));
char *p;
p=b;
int i;
for (i=0;i<=3;i++){
 printf("%c\n",*(p+i));
}
printf("char_array1\n");
return 0;
}

variable_types: a char

variable_types:
b
char []

variable_types:
p
char *


decompiled_code:
__int64 char_array2()
{
int v1[3]; // [rsp+Bh] [rbp-Dh] BYREF

qmemcpy(v1, "abcde", 5);
printf("char c is %s\n", (const char *)v1);
printf("sizeof(c) is %ld\n", 5LL);
puts("char_array2");
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
int v1[3]; // [rsp+Bh] [rbp-Dh] BYREF

qmemcpy(v1, "abcde", 5);
printf("char c is %s\n", (const char *)v1);
printf("sizeof(c) is %ld\n", 5LL);
puts("char_array2");
return 0LL;
}

original_code:
int char_array2(){
 char c[5];
 c[0]='a';c[1]='b';c[2]='c';c[3]='d';c[4]='e';
 printf("char c is %s\n",c);
 printf("sizeof(c) is %ld\n",sizeof(c));
 int d[3][4];
 printf("char_array2\n");
 return 0;
}

variable_types:
c
char [5]


decompiled_code:
__int64 char_array3()
{
__int64 v0; // rdx
__int64 v1; // rbx
__int64 v2; // rsi
__int64 v3; // rbx
__int64 v4; // rdx
__int64 v5; // rsi
_BYTE v7[5]; // [rsp+5h] [rbp-13h] BYREF
char v8[14]; // [rsp+Ah] [rbp-Eh] BYREF

v0 = 99LL;
v1 = 0LL;
qmemcpy(v7, "cdefd", sizeof(v7));
while ( 1 )
{
v2 = (unsigned int)v1++;
printf("c[%d] is %c\n", v2, v0);
if ( v1 == 5 )
break;
v0 = (unsigned int)(char)v7[v1];
}
v3 = 0LL;
printf("char c is %s\n", v7);
printf("sizeof(c) is %ld\n\n", 5LL);
v4 = 99LL;
strcpy(v8, "cdefd");
while ( 1 )
{
v5 = (unsigned int)v3++;
printf("d[%d] is %c\n", v5, v4);
if ( v3 == 6 )
break;
v4 = (unsigned int)v8[v3];
}
printf("char d is %s\n", v8);
printf("sizeof(d) is %ld\n\n", 6LL);
puts("char_array3");
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rdx
__int64 v1; // rbx
__int64 v2; // rsi
__int64 v3; // rbx
__int64 v4; // rdx
__int64 v5; // rsi
_BYTE v7[5]; // [rsp+5h] [rbp-13h] BYREF
char v8[14]; // [rsp+Ah] [rbp-Eh] BYREF

v0 = 99LL;
v1 = 0LL;
qmemcpy(v7, "cdefd", sizeof(v7));
while ( 1 )
{
v2 = (unsigned int)v1++;
printf("c[%d] is %c\n", v2, v0);
if ( v1 == 5 )
break;
v0 = (unsigned int)(char)v7[v1];
}
v3 = 0LL;
printf("char c is %s\n", v7);
printf("sizeof(c) is %ld\n\n", 5LL);
v4 = 99LL;
strcpy(v8, "cdefd");
while ( 1 )
{
v5 = (unsigned int)v3++;
printf("d[%d] is %c\n", v5, v4);
if ( v3 == 6 )
break;
v4 = (unsigned int)v8[v3];
}
printf("char d is %s\n", v8);
printf("sizeof(d) is %ld\n\n", 6LL);
puts("char_array3");
return 0LL;
}

original_code:
int char_array3(){
 char c[]={'c','d','e','f','d'};
 int i;
 for (i=0;i<=(sizeof(c) -1);i++){
  printf("c[%d] is %c\n",i,c[i]);
 }
 printf("char c is %s\n",c);
 printf("sizeof(c) is %ld\n\n",sizeof(c));
 char d[6]={'c','d','e','f','d'};
 char *p;
 p=d;
 for (i=0;i<=(sizeof(d) -1);i++){
  printf("d[%d] is %c\n",i,*(p+i));
 }
 printf("char d is %s\n",d);
 printf("sizeof(d) is %ld\n\n",sizeof(d));
 printf("char_array3\n");
 return 0;
}

canonical_original_code:
int char_array3(){
 char c[] = {'c','d','e','f','d'};
 int i;
 for (i=0;i<=(sizeof(c) -1);i++){
  printf("c[%d] is %c\n",i,c[i]);
 }
 printf("char c is %s\n",c);
 printf("sizeof(c) is %ld\n\n",sizeof(c));
 char d[6] = {'c','d','e','f','d'};
 char *p;
 p=d;
 for (i=0;i<=(sizeof(d) -1);i++){
  printf("d[%d] is %c\n",i,*(p+i));
 }
 printf("char d is %s\n",d);
 printf("sizeof(d) is %ld\n\n",sizeof(d));
 printf("char_array3\n");
 return 0;
}

variable_types:
c
char []

variable_types:
d
char [6]


decompiled_code:
__int64 char_array4()
{
size_t v0; // rax
size_t v1; // rax
size_t v2; // rax
char s[4]; // [rsp+Bh] [rbp-1Dh] BYREF
char v5[9]; // [rsp+Fh] [rbp-19h] BYREF
char v6[15]; // [rsp+19h] [rbp-Fh] BYREF

strcpy(v5, "dg");
strcpy(s, "cde");
printf("char c is %s\n", s);
printf("sizeof(c) is %ld\n", 7LL);
v0 = strlen(s);
printf("strlen(c) is %ld\n\n", v0);
strcpy(&v5[3], "cdefdg");
printf("char d is %s\n", &v5[3]);
printf("sizeof(d) is %ld\n", 7LL);
v1 = strlen(&v5[3]);
printf("strlen(d) is %ld\n\n", v1);
strcpy(v6, "cdefdg");
printf("char e is %s\n", v6);
printf("sizeof(e) is %ld\n", 7LL);
v2 = strlen(v6);
printf("strlen(e) is %ld\n\n", v2);
puts("char_array4");
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
size_t v0; // rax
size_t v1; // rax
size_t v2; // rax
char s[4]; // [rsp+Bh] [rbp-1Dh] BYREF
char v5[9]; // [rsp+Fh] [rbp-19h] BYREF
char v6[15]; // [rsp+19h] [rbp-Fh] BYREF

strcpy(v5, "dg");
strcpy(s, "cde");
printf("char c is %s\n", s);
printf("sizeof(c) is %ld\n", 7LL);
v0 = strlen(s);
printf("strlen(c) is %ld\n\n", v0);
strcpy(&v5[3], "cdefdg");
printf("char d is %s\n", &v5[3]);
printf("sizeof(d) is %ld\n", 7LL);
v1 = strlen(&v5[3]);
printf("strlen(d) is %ld\n\n", v1);
strcpy(v6, "cdefdg");
printf("char e is %s\n", v6);
printf("sizeof(e) is %ld\n", 7LL);
v2 = strlen(v6);
printf("strlen(e) is %ld\n\n", v2);
puts("char_array4");
return 0LL;
}

original_code:
int char_array4(){
 char c[]={'c','d','e','\000','d','g','\000'};
 printf("char c is %s\n",c);
 printf("sizeof(c) is %ld\n",sizeof(c));
        printf("strlen(c) is %ld\n\n",strlen(c));
 char d[]="cdefdg";
 printf("char d is %s\n",d);
 printf("sizeof(d) is %ld\n",sizeof(d));
        printf("strlen(d) is %ld\n\n",strlen(d));
 char e[7]="cdefdg";
 printf("char e is %s\n",e);
 printf("sizeof(e) is %ld\n",sizeof(e));
        printf("strlen(e) is %ld\n\n",strlen(e));
 printf("char_array4\n");
 return 0;
}

canonical_original_code:
int char_array4(){
 char c[] = {'c','d','e','\000','d','g','\000'};
 printf("char c is %s\n",c);
 printf("sizeof(c) is %ld\n",sizeof(c));
        printf("strlen(c) is %ld\n\n",strlen(c));
 char d[] = "cdefdg";
 printf("char d is %s\n",d);
 printf("sizeof(d) is %ld\n",sizeof(d));
        printf("strlen(d) is %ld\n\n",strlen(d));
 char e[7] = "cdefdg";
 printf("char e is %s\n",e);
 printf("sizeof(e) is %ld\n",sizeof(e));
        printf("strlen(e) is %ld\n\n",strlen(e));
 printf("char_array4\n");
 return 0;
}

variable_types:
d
char []

variable_types:
e
char [7]


decompiled_code:
__int64 char_array5()
{
size_t v0; // rax
size_t v1; // rax
char s[15]; // [rsp+9h] [rbp-Fh] BYREF

strcpy(s, "abcdef");
printf("sizeof(c) is %ld\n", 7LL);
v0 = strlen(s);
printf("strlen(c) is %ld\n", v0);
printf("c[0] is %c\n", (unsigned int)s[0]);
printf("c[1] is %c\n", (unsigned int)s[1]);
printf("c[2] is %c\n\n", (unsigned int)s[2]);
s[3] = 107;
printf("char c is %s\n", s);
printf("sizeof(p) is %ld\n", 8LL);
v1 = strlen(s);
printf("strlen(p) is %ld\n", v1);
printf("p[0] is %c\n", (unsigned int)s[0]);
printf("p[1] is %c\n", (unsigned int)s[1]);
printf("p[2] is %c\n\n", (unsigned int)s[2]);
printf("char q is %s\n", "abcdef");
printf("sizeof(q) is %ld\n", 8LL);
printf("strlen(q) is %ld\n\n", 6LL);
printf("q[0] is %c\n", 97LL);
printf("q[1] is %c\n", 98LL);
printf("q[2] is %c\n\n", 99LL);
puts("char_array5");
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
size_t v0; // rax
size_t v1; // rax
char s[15]; // [rsp+9h] [rbp-Fh] BYREF

strcpy(s, "abcdef");
printf("sizeof(c) is %ld\n", 7LL);
v0 = strlen(s);
printf("strlen(c) is %ld\n", v0);
printf("c[0] is %c\n", (unsigned int)s[0]);
printf("c[1] is %c\n", (unsigned int)s[1]);
printf("c[2] is %c\n\n", (unsigned int)s[2]);
s[3] = 107;
printf("char c is %s\n", s);
printf("sizeof(p) is %ld\n", 8LL);
v1 = strlen(s);
printf("strlen(p) is %ld\n", v1);
printf("p[0] is %c\n", (unsigned int)s[0]);
printf("p[1] is %c\n", (unsigned int)s[1]);
printf("p[2] is %c\n\n", (unsigned int)s[2]);
printf("char q is %s\n", "abcdef");
printf("sizeof(q) is %ld\n", 8LL);
printf("strlen(q) is %ld\n\n", 6LL);
printf("q[0] is %c\n", 97LL);
printf("q[1] is %c\n", 98LL);
printf("q[2] is %c\n\n", 99LL);
puts("char_array5");
return 0LL;
}

original_code:
int char_array5(){
 char c[]="abcdef";
 printf("sizeof(c) is %ld\n",sizeof(c));
        printf("strlen(c) is %ld\n",strlen(c));
 printf("c[0] is %c\n",*c );
 printf("c[1] is %c\n",c[1]); printf("c[2] is %c\n\n",*(c+2));
 char *p;
 p=c;
        p[3]='k';
 printf("char c is %s\n",p);
 printf("sizeof(p) is %ld\n",sizeof(p));
        printf("strlen(p) is %ld\n",strlen(p));
 printf("p[0] is %c\n",*p );
 printf("p[1] is %c\n",p[1]);
 printf("p[2] is %c\n\n",*(p+2));
        char *q="abcdef";
 printf("char q is %s\n",q);
 printf("sizeof(q) is %ld\n",sizeof(q));
        printf("strlen(q) is %ld\n\n",strlen(q));
 printf("q[0] is %c\n",*q );
 printf("q[1] is %c\n",q[1]);
 printf("q[2] is %c\n\n",*(q+2));
 printf("char_array5\n");
 return 0;
}

canonical_original_code:
int char_array5(){
 char c[] = "abcdef";
 printf("sizeof(c) is %ld\n",sizeof(c));
        printf("strlen(c) is %ld\n",strlen(c));
 printf("c[0] is %c\n",*c );
 printf("c[1] is %c\n",c[1]); printf("c[2] is %c\n\n",*(c+2));
 char *p;
 p=c;
        p[3]='k';
 printf("char c is %s\n",p);
 printf("sizeof(p) is %ld\n",sizeof(p));
        printf("strlen(p) is %ld\n",strlen(p));
 printf("p[0] is %c\n",*p );
 printf("p[1] is %c\n",p[1]);
 printf("p[2] is %c\n\n",*(p+2));
        char *q = "abcdef";
 printf("char q is %s\n",q);
 printf("sizeof(q) is %ld\n",sizeof(q));
        printf("strlen(q) is %ld\n\n",strlen(q));
 printf("q[0] is %c\n",*q );
 printf("q[1] is %c\n",q[1]);
 printf("q[2] is %c\n\n",*(q+2));
 printf("char_array5\n");
 return 0;
}

variable_types:
q
char *


getlen

decompiled_code:
__int64 getlen()
{
return 8LL;
}

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

original_code:
long int getlen(char* a){
 return sizeof(a);
}

canonical_original_code:
long getlen(char *a){
 return sizeof(a);
}

variable_types:
a
char *

return_type: long


decompiled_code:
__int64 char_array6()
{
__int64 v0; // rbp
char v2[23]; // [rsp+1h] [rbp-17h] BYREF

strcpy(v2, "abcdefghikjlmn");
printf("sizeof(c) is %ld\n", 15LL);
printf("sizeof(p) is %ld\n\n", 8LL);
printf("sizeof(q) is %ld\n", 8LL);
printf("sizeof(r) is %ld\n\n", 8LL);
printf("sizeof(int) is %ld\n\n", 4LL);
printf("sizeof(long) is %ld\n\n", 8LL);
printf("sizeof(char) is %ld\n\n", 1LL);
v0 = getlen(v2);
printf("getlen(c) is %ld\n", v0);
printf("getlen(p) is %ld\n\n", v0);
puts("char_array6");
return 0LL;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 v0; // rbp
char v2[23]; // [rsp+1h] [rbp-17h] BYREF

strcpy(v2, "abcdefghikjlmn");
printf("sizeof(c) is %ld\n", 15LL);
printf("sizeof(p) is %ld\n\n", 8LL);
printf("sizeof(q) is %ld\n", 8LL);
printf("sizeof(r) is %ld\n\n", 8LL);
printf("sizeof(int) is %ld\n\n", 4LL);
printf("sizeof(long) is %ld\n\n", 8LL);
printf("sizeof(char) is %ld\n\n", 1LL);
v0 = func5(v2);
printf("getlen(c) is %ld\n", v0);
printf("getlen(p) is %ld\n\n", v0);
puts("char_array6");
return 0LL;
}

original_code:
int char_array6(){
 char c[]="abcdefghikjlmn";
 char *p;
 p=c;
 printf("sizeof(c) is %ld\n",sizeof(c));
 printf("sizeof(p) is %ld\n\n",sizeof(p));
 char *q;
 int *r;
 printf("sizeof(q) is %ld\n",sizeof(q));
 printf("sizeof(r) is %ld\n\n",sizeof(r));
 printf("sizeof(int) is %ld\n\n",sizeof(int));
 printf("sizeof(long) is %ld\n\n",sizeof(long));
 printf("sizeof(char) is %ld\n\n",sizeof(char));
 printf("getlen(c) is %ld\n",getlen(c));
 printf("getlen(p) is %ld\n\n",getlen(p));
 printf("char_array6\n");
 return 0;
}

canonical_original_code:
int char_array6(){
 char c[] = "abcdefghikjlmn";
 char *p;
 p=c;
 printf("sizeof(c) is %ld\n",sizeof(c));
 printf("sizeof(p) is %ld\n\n",sizeof(p));
 char *q;
 int *r;
 printf("sizeof(q) is %ld\n",sizeof(q));
 printf("sizeof(r) is %ld\n\n",sizeof(r));
 printf("sizeof(int) is %ld\n\n",sizeof(int));
 printf("sizeof(long) is %ld\n\n",sizeof(long));
 printf("sizeof(char) is %ld\n\n",sizeof(char));
 printf("getlen(c) is %ld\n",getlen(c));
 printf("getlen(p) is %ld\n\n",getlen(p));
 printf("char_array6\n");
 return 0;
}

variable_types:
r
int *


f

decompiled_code:
void f()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void f(int i){
 i = 100;
}

canonical_original_code:
void f(int i){
 i = 100;
}

variable_types: i int


decompiled_code:
__int64 para1()
{
unsigned int v1[3]; // [rsp+Ch] [rbp-Ch] BYREF

v1[0] = 9;
printf("i=%d \n", 9LL);
printf("i=%d \n", 9LL);
f2(v1);
printf("i=%d \n", v1[0]);
puts("para done");
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int v1[3]; // [rsp+Ch] [rbp-Ch] BYREF

v1[0] = 9;
printf("i=%d \n", 9LL);
printf("i=%d \n", 9LL);
func1(v1);
printf("i=%d \n", v1[0]);
puts("para done");
return 0LL;
}

original_code:
int para1(void){
 int i = 9;
 printf("i=%d \n",i);
 f(i);
 printf("i=%d \n",i);
 f2(&i);
 printf("i=%d \n",i); printf("para done\n");
 return 0;
}

canonical_original_code:
int para1(){
 int i = 9;
 printf("i=%d \n",i);
 f(i);
 printf("i=%d \n",i);
 f2(&i);
 printf("i=%d \n",i); printf("para done\n");
 return 0;
}


decompiled_code:
int __fastcall show_array_1(unsigned int *a1, int a2)
{
unsigned int *v2; // rbx
__int64 v3; // rbp
__int64 v4; // rsi

v2 = a1;
*a1 = -1;
printf(" a is ");
if ( a2 > 0 )
{
v3 = (__int64)&a1[a2 - 1 + 1];
do
{
v4 = *v2++;
printf("%d ", v4);
}
while ( v2 != (unsigned int *)v3 );
}
return printf("\n ");
}

canonical_decompiled_code:
int __fastcall func3(unsigned int *a1, int a2)
{
unsigned int *v2; // rbx
__int64 v3; // rbp
__int64 v4; // rsi

v2 = a1;
*a1 = -1;
printf(" a is ");
if ( a2 > 0 )
{
v3 = (__int64)&a1[a2 - 1 + 1];
do
{
v4 = *v2++;
printf("%d ", v4);
}
while ( v2 != (unsigned int *)v3 );
}
return printf("\n ");
}

original_code:
void show_array_1(int *p, int len){
 p[0]=-1;
 int i;
 printf(" a is ");
 for (i=0;i<len;i++){
  printf("%d ",p[i]);
 }
 printf("\n ");
}

variable_types:
p
int *


original_code:
int array_point_1(){
 int a[5] = {1,2,3,4,5};
 show_array_1(a,5);
 printf("array_point done\n");
 return 0;
}

variable_types:
a
int [5]


decompiled_code:
__int64 pointer1()
{
printf("char p is %s\n", "ab");
printf("p is %p\n", "ab");
printf("p2 is %p\n", "b");
printf("p is %p\n", (const void *)0x75686C7);
printf("p2 is %p\n", (const void *)0x75686CB);
puts("pointer1 done");
putchar(10);
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
printf("char p is %s\n", "ab");
printf("p is %p\n", "ab");
printf("p2 is %p\n", "b");
printf("p is %p\n", (const void *)0x75686C7);
printf("p2 is %p\n", (const void *)0x75686CB);
puts("pointer1 done");
putchar(10);
return 0LL;
}

original_code:
int pointer1(){
 char * p= "ab";
 char * p2 = p+1;
 printf ("char p is %s\n",p);
 printf ("p is %p\n",p);
 printf ("p2 is %p\n",p2);
 int * p3= (int *)123111111;
 int * p4 = p3+1;
 printf ("p is %p\n",p3);
 printf ("p2 is %p\n",p4);
 printf("pointer1 done\n");
 printf("\n");
 return 0;
}

canonical_original_code:
int pointer1(){
 char *p = "ab";
 char *p2 = p+1;
 printf ("char p is %s\n",p);
 printf ("p is %p\n",p);
 printf ("p2 is %p\n",p2);
 int *p3 = (int *)123111111;
 int *p4 = p3+1;
 printf ("p is %p\n",p3);
 printf ("p2 is %p\n",p4);
 printf("pointer1 done\n");
 printf("\n");
 return 0;
}


decompiled_code:
__int64 __fastcall pointer2(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10, int a11, char a12)
{
char v13[8]; // [rsp+10h] [rbp-8h] BYREF

printf("last is %p\n", "sd");
printf("ap is %p\n", "is %p\n");
printf("ap2 is %p\n", v13);
printf("ap3 is %p\n", &a12);
printf("ap4 is %p\n", &a12);
printf("bp is %p\n", "is %p\n");
printf("cp is %p\n", "is %p\n");
putchar(10);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10, int a11, char a12)
{
char v13[8]; // [rsp+10h] [rbp-8h] BYREF

printf("last is %p\n", "sd");
printf("ap is %p\n", "is %p\n");
printf("ap2 is %p\n", v13);
printf("ap3 is %p\n", &a12);
printf("ap4 is %p\n", &a12);
printf("bp is %p\n", "is %p\n");
printf("cp is %p\n", "is %p\n");
putchar(10);
return 0LL;
}

original_code:
int pointer2(){
 char *last = "sd";
 char *ap = (char *)last + sizeof(last);
 char *ap2 = (char *)&last + sizeof(last);
 char **ap3 = (char **)&last + sizeof(last);
 char **ap4 = &last + sizeof(last);
 char *bp = last + sizeof(last);
 char *cp = (char *)(last + sizeof(last));
 printf ("last is %p\n",last);
 printf ("ap is %p\n",ap);
 printf ("ap2 is %p\n",ap2);
 printf ("ap3 is %p\n",ap3);
 printf ("ap4 is %p\n",ap3);
 printf ("bp is %p\n",bp);
 printf ("cp is %p\n",cp);
 printf("\n");
 return 0;
}

variable_types:
last
char *

variable_types:
ap
char *

variable_types:
bp
char *

variable_types:
cp
char *


decompiled_code:
__int64 pointer3()
{
int v1; // [rsp+Ch] [rbp-Ch] BYREF
char v2[4]; // [rsp+14h] [rbp-4h] BYREF

v1 = 123;
printf("last is %p\n", &v1);
printf("ap is %p\n", v2);
printf("bp is %p\n", v2);
printf("cp is %p\n", v2);
putchar(10);
return 0LL;
}

canonical_decompiled_code:
__int64 func7()
{
int v1; // [rsp+Ch] [rbp-Ch] BYREF
char v2[4]; // [rsp+14h] [rbp-4h] BYREF

v1 = 123;
printf("last is %p\n", &v1);
printf("ap is %p\n", v2);
printf("bp is %p\n", v2);
printf("cp is %p\n", v2);
putchar(10);
return 0LL;
}

original_code:
int pointer3(){
 int abc =123;
 int *last = &abc;
 int *ap = (int *)last + 2;
 int *bp = last + 2;
 int *cp = (int *)(last + 2);
 printf ("last is %p\n",last);
 printf ("ap is %p\n",ap);
 printf ("bp is %p\n",bp);
 printf ("cp is %p\n",cp);
 printf("\n");
 return 0;
}

canonical_original_code:
int pointer3(){
 int abc = 123;
 int *last = &abc;
 int *ap = (int *)last + 2;
 int *bp = last + 2;
 int *cp = (int *)(last + 2);
 printf ("last is %p\n",last);
 printf ("ap is %p\n",ap);
 printf ("bp is %p\n",bp);
 printf ("cp is %p\n",cp);
 printf("\n");
 return 0;
}

variable_types: abc int

variable_types:
last
int *

variable_types:
ap
int *

variable_types:
bp
int *

variable_types:
cp
int *


decompiled_code:
__int64 pointer4()
{
int v1[3]; // [rsp+Ch] [rbp-Ch] BYREF

v1[0] = 97;
printf("ap is %p\n", v1);
printf("*ap is %c\n", (unsigned int)SLOBYTE(v1[0]));
v1[0] = -143;
printf("*ap is %c\n", 113LL);
v1[0] = 831;
printf("*ap is %c\n", 63LL);
v1[0] = 0x7FFFFFFF;
printf("*ap is %c\n", 0xFFFFFFFFLL);
v1[0] = 0x80000000;
printf("*ap is %c\n", 0LL);
putchar(10);
return 0LL;
}

canonical_decompiled_code:
__int64 func8()
{
int v1[3]; // [rsp+Ch] [rbp-Ch] BYREF

v1[0] = 97;
printf("ap is %p\n", v1);
printf("*ap is %c\n", (unsigned int)SLOBYTE(v1[0]));
v1[0] = -143;
printf("*ap is %c\n", 113LL);
v1[0] = 831;
printf("*ap is %c\n", 63LL);
v1[0] = 0x7FFFFFFF;
printf("*ap is %c\n", 0xFFFFFFFFLL);
v1[0] = 0x80000000;
printf("*ap is %c\n", 0LL);
putchar(10);
return 0LL;
}

original_code:
int pointer4(){
 int abc =97;
 char *ap = (char *) &abc;
 printf ("ap is %p\n",ap);
 printf ("*ap is %c\n",*ap);
 abc=-143;
 printf ("*ap is %c\n",*ap);
 abc=831;
 printf ("*ap is %c\n",*ap);
 abc=2147483647;
 printf ("*ap is %c\n",*ap);
 abc=2147483648;
 printf ("*ap is %c\n",*ap);
 printf("\n");
 return 0;
}

canonical_original_code:
int pointer4(){
 int abc = 97;
 char *ap = (char *) &abc;
 printf ("ap is %p\n",ap);
 printf ("*ap is %c\n",*ap);
 abc=-143;
 printf ("*ap is %c\n",*ap);
 abc=831;
 printf ("*ap is %c\n",*ap);
 abc=2147483647;
 printf ("*ap is %c\n",*ap);
 abc=2147483648;
 printf ("*ap is %c\n",*ap);
 printf("\n");
 return 0;
}


decompiled_code:
__int64 pointer5()
{
printf("*p is %d\n", 97LL);
printf("*q is %d\n", 97LL);
printf("*q is %c\n", 97LL);
putchar(10);
return 0LL;
}

canonical_decompiled_code:
__int64 func9()
{
printf("*p is %d\n", 97LL);
printf("*q is %d\n", 97LL);
printf("*q is %c\n", 97LL);
putchar(10);
return 0LL;
}

original_code:
int pointer5(){
 int i =97;
 int * p = &i;
 char * q = (char *)&i;
 printf ("*p is %d\n",*p);
 printf ("*q is %d\n",*q);
 printf ("*q is %c\n",*q);
 printf("\n");
 return 0;
}

canonical_original_code:
int pointer5(){
 int i = 97;
 int *p = &i;
 char *q = (char *)&i;
 printf ("*p is %d\n",*p);
 printf ("*q is %d\n",*q);
 printf ("*q is %c\n",*q);
 printf("\n");
 return 0;
}


decompiled_code:
__int64 pointer6()
{
printf("*p is %d\n", 24930LL);
printf("*q is %c\n", 98LL);
printf("*(q+1) is %c\n", 97LL);
putchar(10);
return 0LL;
}

canonical_decompiled_code:
__int64 func10()
{
printf("*p is %d\n", 24930LL);
printf("*q is %c\n", 98LL);
printf("*(q+1) is %c\n", 97LL);
putchar(10);
return 0LL;
}

original_code:
int pointer6(){
 int i = 24930;
 int * p = &i;
 char * q = (char *)&i;
 printf ("*p is %d\n",*p);
 printf ("*q is %c\n",*q);
 printf ("*(q+1) is %c\n",*(q+1));
 printf("\n");
 return 0;
}

canonical_original_code:
int pointer6(){
 int i = 24930;
 int *p = &i;
 char *q = (char *)&i;
 printf ("*p is %d\n",*p);
 printf ("*q is %c\n",*q);
 printf ("*(q+1) is %c\n",*(q+1));
 printf("\n");
 return 0;
}


original_code:
int pointer7(){
 int i = -24930;
 int * p = &i;
 char * q = (char *)&i;
 printf ("*p is %d\n",*p);
 printf ("*q is %c\n",*q);
 printf ("*(q+1) is %c\n",*(q+1));
 printf("\n");
 return 0;
}

canonical_original_code:
int pointer7(){
 int i = -24930;
 int *p = &i;
 char *q = (char *)&i;
 printf ("*p is %d\n",*p);
 printf ("*q is %c\n",*q);
 printf ("*(q+1) is %c\n",*(q+1));
 printf("\n");
 return 0;
}


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

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

original_code:
int mem1(){
 int i = 2;
 int ii = -3;
 int aii = -2147483648;
        int iii = i + ii;
        return 0;
}

variable_types: ii int

variable_types: aii int

variable_types: iii int


decompiled_code:
__int64 pointer_main()
{
return mem1();
}

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

original_code:
int pointer_main(){
 int i;
        i = mem1();
 return 0;
}


decompiled_code:
__int64 array_main()
{
malloc_main();
puts("array_mian done!");
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
malloc_main();
puts("array_mian done!");
return 0LL;
}

original_code:
int array_main(){
 int i;
 i=malloc_main();
 printf("array_mian done!\n");
 return 0;
}


decompiled_code:
__int64 array2()
{
printf("B[0][0] is %d\n", 0LL);
printf("B[0][0] is %d\n", 99LL);
printf("B[0][1] is %d\n", 1LL);
printf("B[2][2] is %d\n", 12LL);
puts("array2 done");
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
printf("B[0][0] is %d\n", 0LL);
printf("B[0][0] is %d\n", 99LL);
printf("B[0][1] is %d\n", 1LL);
printf("B[2][2] is %d\n", 12LL);
puts("array2 done");
return 0LL;
}


decompiled_code:
__int64 array3()
{
printf("B[1][2] is %d\n", 12LL);
printf("B[2][1] is %d\n", 21LL);
puts("array3 done");
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
printf("B[1][2] is %d\n", 12LL);
printf("B[2][1] is %d\n", 21LL);
puts("array3 done");
return 0LL;
}


decompiled_code:
__int64 array4()
{
printf("B[1][2] is %d\n", 12LL);
printf("B[2][1] is %d\n", 21LL);
puts("array4 done");
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
printf("B[1][2] is %d\n", 12LL);
printf("B[2][1] is %d\n", 21LL);
puts("array4 done");
return 0LL;
}


decompiled_code:
__int64 array5()
{
printf("B[1][2] is %d\n", 12LL);
printf("B[2][1] is %d\n", 21LL);
puts("array5 done");
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
printf("B[1][2] is %d\n", 12LL);
printf("B[2][1] is %d\n", 21LL);
puts("array5 done");
return 0LL;
}


decompiled_code:
__int64 array6()
{
printf("A[3] is %d\n", 4LL);
return 0LL;
}

canonical_decompiled_code:
__int64 func6()
{
printf("A[3] is %d\n", 4LL);
return 0LL;
}

variable_types:
A
int []


decompiled_code:
__int64 struct1()
{
__int64 v1; // [rsp+4h] [rbp-24h] BYREF
__int16 v2; // [rsp+Ch] [rbp-1Ch]
int v3; // [rsp+10h] [rbp-18h]

v1 = 0x6E6F73614ALL;
v2 = 0;
v3 = 20;
printf("%d %s %d\n", 1000LL, (const char *)&v1, 20LL);
strcpy((char *)&v1, "Cindy");
v3 = 38;
printf("%d %s %d\n", 99LL, (const char *)&v1, 38LL);
puts("struct done");
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v1; // [rsp+4h] [rbp-24h] BYREF
__int16 v2; // [rsp+Ch] [rbp-1Ch]
int v3; // [rsp+10h] [rbp-18h]

v1 = 0x6E6F73614ALL;
v2 = 0;
v3 = 20;
printf("%d %s %d\n", 1000LL, (const char *)&v1, 20LL);
strcpy((char *)&v1, "Cindy");
v3 = 38;
printf("%d %s %d\n", 99LL, (const char *)&v1, 38LL);
puts("struct done");
return 0LL;
}

original_code:
int struct1(void) {
 struct Student st = {1000, "Jason", 20};
 printf("%d %s %d\n",st.sid, st.name, st.age);
 st.sid = 99;
 strcpy(st.name, "Cindy");
        st.age = 38;
 printf("%d %s %d\n",st.sid, st.name, st.age);
 printf("struct done\n");
 return 0;
}

canonical_original_code:
int struct1() {
 struct Student st = {1000, "Jason", 20};
 printf("%d %s %d\n",st.sid, st.name, st.age);
 st.sid = 99;
 strcpy(st.name, "Cindy");
        st.age = 38;
 printf("%d %s %d\n",st.sid, st.name, st.age);
 printf("struct done\n");
 return 0;
}

variable_types: struct Student { int sid; char name[10]; int age; }


decompiled_code:
__int64 struct2()
{
char v1[12]; // [rsp+4h] [rbp-24h] BYREF
int v2; // [rsp+10h] [rbp-18h]

strcpy(v1, "Moon");
v2 = 28;
printf("%d %s %d\n", 101LL, v1, 28LL);
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
char v1[12]; // [rsp+4h] [rbp-24h] BYREF
int v2; // [rsp+10h] [rbp-18h]

strcpy(v1, "Moon");
v2 = 28;
printf("%d %s %d\n", 101LL, v1, 28LL);
return 0LL;
}

original_code:
int struct2(void) {
 struct Student st;
 struct Student *pst;
 pst=&st;
        pst->sid = 101;
 strcpy(pst->name,"Moon");
        pst->age =28;
 printf("%d %s %d\n",pst->sid, pst->name, pst->age);
 return 0;
}

canonical_original_code:
int struct2() {
 struct Student st;
 struct Student *pst;
 pst=&st;
        pst->sid = 101;
 strcpy(pst->name,"Moon");
        pst->age =28;
 printf("%d %s %d\n",pst->sid, pst->name, pst->age);
 return 0;
}

variable_types: struct Student { int sid; char name[10]; int age; } *


sv

original_code:
void sv(struct Student * pst){
 pst->sid = 102;
 strcpy(pst->name, "Crystal");
 pst->age=24;
}

canonical_original_code:
void sv(struct Student *pst){
 pst->sid = 102;
 strcpy(pst->name, "Crystal");
 pst->age=24;
}

user_defined_types: struct Student { int sid; char name[10]; int age; }


pv

decompiled_code:
int __fastcall pv(const char *a1)
{
return printf("%d %s %d\n", *(unsigned int *)a1, a1 + 4, *((unsigned int *)a1 + 4));
}

canonical_decompiled_code:
int __fastcall func3(const char *a1)
{
return printf("%d %s %d\n", *(unsigned int *)a1, a1 + 4, *((unsigned int *)a1 + 4));
}

original_code:
void pv(struct Student * pst){
 printf("%d %s %d\n",pst->sid, pst->name, pst->age);
}

canonical_original_code:
void pv(struct Student *pst){
 printf("%d %s %d\n",pst->sid, pst->name, pst->age);
}


decompiled_code:
__int64 struct3()
{
char v1[40]; // [rsp+0h] [rbp-28h] BYREF

sv((__int64)v1);
pv(v1);
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
char v1[40]; // [rsp+0h] [rbp-28h] BYREF

func2((__int64)v1);
func3(v1);
return 0LL;
}

original_code:
int struct3(void) {
 struct Student st;
 sv(&st);
 pv(&st);
 return 0;
}

canonical_original_code:
int struct3() {
 struct Student st;
 sv(&st);
 pv(&st);
 return 0;
}


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

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

original_code:
int malloc_2(){
 return 0;
}

canonical_original_code:
int malloc_2(){
 return 0;
}


decompiled_code:
__int64 __fastcall malloc_4(void **a1, int a2)
{
*a1 = realloc(*a1, 4LL * a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(void **a1, int a2)
{
*a1 = realloc(*a1, 4LL * a2);
return 0LL;
}

original_code:
int malloc_4(int ** pa, int len){
 *pa = (int *)realloc(*pa, sizeof(int)* (len));
 return 0;
}

canonical_original_code:
int malloc_4(int **pa, int len){
 *pa = (int *)realloc(*pa, sizeof(int)* (len));
 return 0;
}

variable_types:
pa
int **

variable_types: len int


decompiled_code:
__int64 malloc_3()
{
_DWORD *v0; // rdi
__int64 i; // rax
void *v2; // rdi
void *ptr; // [rsp+8h] [rbp-10h] BYREF

ptr = malloc(0x1CuLL);
v0 = ptr;
for ( i = 1LL; i != 8; ++i )
v0[i - 1] = 2 * i;
p_array_int_1(v0, 7LL);
printf("address is %p\n", ptr);
malloc_4(&ptr, 8);
v2 = ptr;
*((_DWORD *)ptr + 7) = 40;
p_array_int_1(v2, 8LL);
printf("address is %p\n", ptr);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
_DWORD *v0; // rdi
__int64 i; // rax
void *v2; // rdi
void *ptr; // [rsp+8h] [rbp-10h] BYREF

ptr = malloc(0x1CuLL);
v0 = ptr;
for ( i = 1LL; i != 8; ++i )
v0[i - 1] = 2 * i;
p_array_int_1(v0, 7LL);
printf("address is %p\n", ptr);
func2(&ptr, 8);
v2 = ptr;
*((_DWORD *)ptr + 7) = 40;
p_array_int_1(v2, 8LL);
printf("address is %p\n", ptr);
free(ptr);
return 0LL;
}

original_code:
int malloc_3(){
 int len = 7;
 int * a = (int *)malloc(sizeof(int) * len);
 int i;
 for (i=0; i <len ; i++){
  a[i] = (i+1)*2;
 }
 i = p_array_int_1(a,len);
 printf("address is %p\n", a);
 len++;
 i = malloc_4(&a, len);
 a[len-1]= 40;
 i = p_array_int_1(a,len);
 printf("address is %p\n", a);
 free(a);
 return 0;
}

canonical_original_code:
int malloc_3(){
 int len = 7;
 int *a = (int *)malloc(sizeof(int) * len);
 int i;
 for (i=0; i <len ; i++){
  a[i] = (i+1)*2;
 }
 i = p_array_int_1(a,len);
 printf("address is %p\n", a);
 len++;
 i = malloc_4(&a, len);
 a[len-1]= 40;
 i = p_array_int_1(a,len);
 printf("address is %p\n", a);
 free(a);
 return 0;
}

variable_types:
a
int *

variable_types: i int


decompiled_code:
__int64 malloc_main()
{
malloc_3();
puts("malloc main done");
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
func3();
puts("malloc main done");
return 0LL;
}

original_code:
int malloc_main(){
 int i;
 i = malloc_3();
 printf("malloc main done\n");
 return 0;
}


bsget

decompiled_code:
__int64 __fastcall bsget(int a1, __int64 a2, int a3)
{
int v3; // er12
__int64 v5; // rsi
int v6; // eax
int v7; // ebx
__int64 result; // rax

v3 = a3 - 1;
v5 = 0LL;
if ( a3 - 1 <= 0 )
{
LABEL_7:
if ( *(_DWORD *)(a2 + 4LL * v3) == a1 )
{
printf("done the while %d times\n", v5);
}
else
{
printf("done the while %d times\n", v5);
v3 = -1;
}
result = (unsigned int)v3;
}
else
{
v6 = 0;
while ( 1 )
{
while ( 1 )
{
v5 = (unsigned int)(v5 + 1);
v7 = (v3 + v6) >> 1;
if ( a1 <= *(_DWORD *)(a2 + 4LL * v7) )
break;
v6 = v7 + 1;
if ( v7 + 1 >= v3 )
goto LABEL_7;
}
if ( a1 == *(_DWORD *)(a2 + 4LL * v7) )
break;
v3 = v7 - 1;
if ( v6 >= v7 - 1 )
goto LABEL_7;
}
printf("done the while %d times\n", v5);
result = (unsigned int)v7;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 a2, int a3)
{
int v3; // er12
__int64 v5; // rsi
int v6; // eax
int v7; // ebx
__int64 result; // rax

v3 = a3 - 1;
v5 = 0LL;
if ( a3 - 1 <= 0 )
{
LABEL_7:
if ( *(_DWORD *)(a2 + 4LL * v3) == a1 )
{
printf("done the while %d times\n", v5);
}
else
{
printf("done the while %d times\n", v5);
v3 = -1;
}
result = (unsigned int)v3;
}
else
{
v6 = 0;
while ( 1 )
{
while ( 1 )
{
v5 = (unsigned int)(v5 + 1);
v7 = (v3 + v6) >> 1;
if ( a1 <= *(_DWORD *)(a2 + 4LL * v7) )
break;
v6 = v7 + 1;
if ( v7 + 1 >= v3 )
goto LABEL_7;
}
if ( a1 == *(_DWORD *)(a2 + 4LL * v7) )
break;
v3 = v7 - 1;
if ( v6 >= v7 - 1 )
goto LABEL_7;
}
printf("done the while %d times\n", v5);
result = (unsigned int)v7;
}
return result;
}

original_code:
int bsget(int value, int* array , int count){
 int curid;
 int endid = count - 1;
 int startid = 0;
 int curval;
 int i=0;
 while(endid > startid){
  i++;
  curid= (startid + endid)/2;
  curval = array[curid];
  if (curval >= value){
   if (curval == value){
    printf("done the while %d times\n",i);
    return curid;
   }
   endid = --curid;
  }
  else{
   startid = ++curid;
  }
 }
 if (array[endid] == value){
  printf("done the while %d times\n",i);
  return endid;
 }
 printf("done the while %d times\n",i);
 return -1;
}

canonical_original_code:
int bsget(int value, int *array, int count){
 int curid;
 int endid = count - 1;
 int startid = 0;
 int curval;
 int i = 0;
 while(endid > startid){
  i++;
  curid= (startid + endid)/2;
  curval = array[curid];
  if (curval >= value){
   if (curval == value){
    printf("done the while %d times\n",i);
    return curid;
   }
   endid = --curid;
  }
  else{
   startid = ++curid;
  }
 }
 if (array[endid] == value){
  printf("done the while %d times\n",i);
  return endid;
 }
 printf("done the while %d times\n",i);
 return -1;
}

variable_types: value int

variable_types:
array
int *

variable_types: count int

variable_types: curid int

variable_types: endid int

variable_types: startid int

variable_types: curval int


decompiled_code:
__int64 bisearch1()
{
int v0; // eax
int *v1; // rdx
unsigned int v2; // eax
unsigned int v3; // ebp
int v5[1002]; // [rsp+0h] [rbp-FA8h] BYREF

v0 = 4;
v1 = v5;
do
{
*v1 = v0;
v0 += 2;
++v1;
}
while ( v0 != 2006 );
v2 = bsget(1604, (__int64)v5, 1000);
v3 = v2;
if ( v2 == -1 )
{
printf("%d is not in the array\n", 1604LL);
}
else
{
printf("sortid of %d is %d\n", 1604LL, v2);
printf("array[%d] is %d\n\n", v3, (unsigned int)v5[v3]);
}
puts("bisearch1 done");
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // eax
int *v1; // rdx
unsigned int v2; // eax
unsigned int v3; // ebp
int v5[1002]; // [rsp+0h] [rbp-FA8h] BYREF

v0 = 4;
v1 = v5;
do
{
*v1 = v0;
v0 += 2;
++v1;
}
while ( v0 != 2006 );
v2 = func0(1604, (__int64)v5, 1000);
v3 = v2;
if ( v2 == -1 )
{
printf("%d is not in the array\n", 1604LL);
}
else
{
printf("sortid of %d is %d\n", 1604LL, v2);
printf("array[%d] is %d\n\n", v3, (unsigned int)v5[v3]);
}
puts("bisearch1 done");
return 0LL;
}

original_code:
int bisearch1(){
 int a[1000];
 int sortid;
 int v;
 int i;
 int count = sizeof(a)/sizeof(*a);
 for (i=0;i<=count;i++){
  *(a+i)=2*i+4;
 }
 v=1604;
 sortid=bsget(v,a,count);
 if (sortid !=-1){
  printf("sortid of %d is %d\n",v,sortid);
  printf("array[%d] is %d\n\n",sortid, a[sortid]);
 }
 else{
  printf("%d is not in the array\n",v);
 }
 printf("bisearch1 done\n");
 return 0;
}

variable_types: sortid int

variable_types: v int


decompiled_code:
__int64 bit32_64()
{
char v1[14]; // [rsp+Ah] [rbp-Eh] BYREF

strcpy(v1, "abcde");
printf("addr of a is %p\n", v1);
printf("addr of b is %p\n", &v1[1]);
printf("addr of c is %p\n", &v1[2]);
printf("addr of d is %p\n", &v1[3]);
puts(" \nbit done");
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
char v1[14]; // [rsp+Ah] [rbp-Eh] BYREF

strcpy(v1, "abcde");
printf("addr of a is %p\n", v1);
printf("addr of b is %p\n", &v1[1]);
printf("addr of c is %p\n", &v1[2]);
printf("addr of d is %p\n", &v1[3]);
puts(" \nbit done");
return 0LL;
}

original_code:
int bit32_64(){
char a[]="abcde";
char *p;
p=a;
printf("addr of a is %p\n",p);
printf("addr of b is %p\n",p+1);
printf("addr of c is %p\n",p+2);
printf("addr of d is %p\n",p+3);
printf(" \nbit done\n");
return 0;
}

canonical_original_code:
int bit32_64(){
char a[] = "abcde";
char *p;
p=a;
printf("addr of a is %p\n",p);
printf("addr of b is %p\n",p+1);
printf("addr of c is %p\n",p+2);
printf("addr of d is %p\n",p+3);
printf(" \nbit done\n");
return 0;
}

variable_types:
a
char []

variable_types:
p
char *


showsize

decompiled_code:
__int64 showsize()
{
printf("sizeof(int) is %ld\n", 4LL);
printf("sizeof(long int) is %ld\n", 8LL);
printf("sizeof(char) is %ld\n", 1LL);
printf("sizeof(unsigned int) is %ld\n", 4LL);
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
printf("sizeof(int) is %ld\n", 4LL);
printf("sizeof(long int) is %ld\n", 8LL);
printf("sizeof(char) is %ld\n", 1LL);
printf("sizeof(unsigned int) is %ld\n", 4LL);
return 0LL;
}

original_code:
int showsize(){
int i;
i=68888;
printf("sizeof(int) is %ld\n",sizeof(int));
printf("sizeof(long int) is %ld\n",sizeof(long int));
printf("sizeof(char) is %ld\n",sizeof(char));
printf("sizeof(unsigned int) is %ld\n",sizeof(unsigned int));
return 0;
}

canonical_original_code:
int showsize(){
int i;
i=68888;
printf("sizeof(int) is %ld\n",sizeof(int));
printf("sizeof(long int) is %ld\n",sizeof(long));
printf("sizeof(char) is %ld\n",sizeof(char));
printf("sizeof(unsigned int) is %ld\n",sizeof(unsigned int));
return 0;
}


decompiled_code:
__int64 input_array_int()
{
printf("abc");
return 0LL;
}

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

original_code:
int input_array_int(){
 printf("abc");
 return 0;
}


decompiled_code:
__int64 __fastcall p_array_int_1(__int64 a1, int a2)
{
int v2; // er13
__int64 v3; // r12
__int64 i; // rbx
__int64 v5; // rsi

if ( a2 <= 0 )
return 0LL;
v2 = a2 - 1;
v3 = a2;
for ( i = 0LL; i != v3; ++i )
{
while ( 1 )
{
v5 = *(unsigned int *)(a1 + 4 * i);
if ( v2 <= (int)i )
break;
++i;
printf("%d, ", v5);
if ( i == v3 )
return 0LL;
}
printf("%d\n", v5);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2)
{
int v2; // er13
__int64 v3; // r12
__int64 i; // rbx
__int64 v5; // rsi

if ( a2 <= 0 )
return 0LL;
v2 = a2 - 1;
v3 = a2;
for ( i = 0LL; i != v3; ++i )
{
while ( 1 )
{
v5 = *(unsigned int *)(a1 + 4 * i);
if ( v2 <= (int)i )
break;
++i;
printf("%d, ", v5);
if ( i == v3 )
return 0LL;
}
printf("%d\n", v5);
}
return 0LL;
}

original_code:
int p_array_int_1(int * p, int len){
 int i;
 for (i=0; i<len; i++){
  if (i < (len -1)) {
   printf("%d, ",*p);
  }
  else{
   printf("%d\n",*p);
  }
  p++;
 }
 return 0;
}

canonical_original_code:
int p_array_int_1(int *p, int len){
 int i;
 for (i=0; i<len; i++){
  if (i < (len -1)) {
   printf("%d, ",*p);
  }
  else{
   printf("%d\n",*p);
  }
  p++;
 }
 return 0;
}

variable_types:
p
int *


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

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

original_code:
int p_array_int(int * p, int len){
 return 0;
}

canonical_original_code:
int p_array_int(int *p, int len){
 return 0;
}


decompiled_code:
int File2Print()
{
return puts("Print file2**********");
}

canonical_decompiled_code:
int func0()
{
return puts("Print file2**********");
}

original_code:
void File2Print(){
 printf("Print file2**********\n");
}


decompiled_code:
void *Create_list()
{
return malloc(0x6CuLL);
}

canonical_decompiled_code:
void *func0()
{
return malloc(0x6CuLL);
}

original_code:
struct Student * Create_list(){
 struct Student * pst;
 pst = (struct Student *)malloc(sizeof(struct Student)*1);
 return pst;
}

canonical_original_code:
struct Student *Create_list(){
 struct Student *pst;
 pst = (struct Student *)malloc(sizeof(struct Student)*1);
 return pst;
}

variable_types: struct Student { int sid; int age; char name[100]; } *


decompiled_code:
int __fastcall Show_list(const char *a1)
{
return printf("sid is %d, name is %s, age is %d\n", *(unsigned int *)a1, a1 + 8, *((unsigned int *)a1 + 1));
}

canonical_decompiled_code:
int __fastcall func1(const char *a1)
{
return printf("sid is %d, name is %s, age is %d\n", *(unsigned int *)a1, a1 + 8, *((unsigned int *)a1 + 1));
}

original_code:
void Show_list(struct Student * pst){
 printf("sid is %d, name is %s, age is %d\n",pst->sid, pst->name, pst->age);
}

canonical_original_code:
void Show_list(struct Student *pst){
 printf("sid is %d, name is %s, age is %d\n",pst->sid, pst->name, pst->age);
}

user_defined_types: struct Student { int sid; int age; char name[100]; }


decompiled_code:
int memory_1()
{
char *v0; // rax

v0 = (char *)Create_list();
*(_QWORD *)v0 = 0x180000000BLL;
strcpy(v0 + 8, "JasonPoon");
return Show_list(v0);
}

canonical_decompiled_code:
int func2()
{
char *v0; // rax

v0 = (char *)func0();
*(_QWORD *)v0 = 0x180000000BLL;
strcpy(v0 + 8, "JasonPoon");
return func1(v0);
}

original_code:
void memory_1(){
 struct Student * p = Create_list();
 p->sid = 11;
 p->age = 24;
 strcpy(p->name,"JasonPoon");
 Show_list(p);
}

canonical_original_code:
void memory_1(){
 struct Student *p = Create_list();
 p->sid = 11;
 p->age = 24;
 strcpy(p->name,"JasonPoon");
 Show_list(p);
}


decompiled_code:
__int64 memory_main()
{
memory_1();
puts("memory main done");
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
func2();
puts("memory main done");
return 0LL;
}

original_code:
int memory_main(){
 memory_1();
 printf("memory main done\n");
 return 0;
}


sort

decompiled_code:
__int64 sort()
{
puts("it's sort");
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
puts("it's sort");
return 0LL;
}

original_code:
int sort(){
 printf("it's sort\n");
 return 0;
}


audiocb

repo: nwf/hyperbola-chiptunes

decompiled_code:
void __fastcall audiocb(__int64 a1, _BYTE *a2, int a3)
{
__int64 v3; // rbp
_BYTE *v4; // rbx

if ( a3 > 0 )
{
v3 = (__int64)&a2[a3 - 1 + 1];
v4 = a2;
do
*v4++ = interrupthandler();
while ( v4 != (_BYTE *)v3 );
}
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1, _BYTE *a2, int a3)
{
__int64 v3; // rbp
_BYTE *v4; // rbx

if ( a3 > 0 )
{
v3 = (__int64)&a2[a3 - 1 + 1];
v4 = a2;
do
*v4++ = interrupthandler();
while ( v4 != (_BYTE *)v3 );
}
}

original_code:
void audiocb(void *userdata, Uint8 *buf, int len) {
    (void) userdata;
 int i;
 for(i = 0; i < len; i++) {
  buf[i] = interrupthandler();
 }
}

canonical_original_code:
void audiocb(void *userdata, unsigned char *buf, int len) {
    (void) userdata;
 int i;
 for(i = 0; i < len; i++) {
  buf[i] = interrupthandler();
 }
}

variable_types:
userdata
void *

variable_types:
buf
unsigned char *


silence

original_code:
void silence() {
 u8 i;
 for(i = 0; i < 4; i++) {
  osc[i].volume = 0;
 }
 playsong = 0;
 playtrack = 0;
}

canonical_original_code:
void silence() {
 unsigned char i;
 for(i = 0; i < 4; i++) {
  osc[i].volume = 0;
 }
 playsong = 0;
 playtrack = 0;
}

variable_types:
i
unsigned char


runcmd

decompiled_code:
void __fastcall runcmd(unsigned __int8 a1, char a2, __int16 a3)
{
__int16 *v3; // rax
__int16 *v4; // rax

if ( a2 )
{
switch ( a2 )
{
case '+':
HIBYTE(channel[12 * a1 + 3]) = LOBYTE(channel[12 * a1 + 1]) + a3 - 48;
break;
case '=':
HIBYTE(channel[12 * a1 + 3]) = a3;
break;
case 'S':
osc[4 * a1 + 1] += (unsigned __int8)a3;
break;
case 'd':
osc[4 * a1 + 2] = a3 << 8;
break;
case 'f':
LOBYTE(channel[12 * a1 + 6]) = a3;
break;
case 'i':
channel[12 * a1 + 10] = 2 * (unsigned __int8)a3;
break;
case 'j':
HIBYTE(channel[12 * a1 + 2]) = a3;
break;
case 'l':
LOBYTE(channel[12 * a1 + 4]) = a3;
break;
case 'm':
channel[12 * a1 + 7] = (unsigned __int8)a3 << 6;
break;
case 't':
LOBYTE(channel[12 * a1 + 3]) = a3;
break;
case 'v':
HIBYTE(osc[4 * a1 + 3]) = a3;
break;
case 'w':
LOBYTE(osc[4 * a1 + 3]) = a3;
break;
case '~':
v3 = &channel[12 * a1];
if ( *((_BYTE *)v3 + 16) != (unsigned __int8)a3 >> 4 )
*((_BYTE *)v3 + 18) = 0;
v4 = &channel[12 * a1];
*((_BYTE *)v4 + 16) = (unsigned __int8)a3 >> 4;
*((_BYTE *)v4 + 17) = a3 & 0xF;
break;
default:
return;
}
}
else
{
LOBYTE(channel[12 * a1 + 2]) = 0;
}
}

canonical_decompiled_code:
void __fastcall func1(unsigned __int8 a1, char a2, __int16 a3)
{
__int16 *v3; // rax
__int16 *v4; // rax

if ( a2 )
{
switch ( a2 )
{
case '+':
HIBYTE(channel[12 * a1 + 3]) = LOBYTE(channel[12 * a1 + 1]) + a3 - 48;
break;
case '=':
HIBYTE(channel[12 * a1 + 3]) = a3;
break;
case 'S':
osc[4 * a1 + 1] += (unsigned __int8)a3;
break;
case 'd':
osc[4 * a1 + 2] = a3 << 8;
break;
case 'f':
LOBYTE(channel[12 * a1 + 6]) = a3;
break;
case 'i':
channel[12 * a1 + 10] = 2 * (unsigned __int8)a3;
break;
case 'j':
HIBYTE(channel[12 * a1 + 2]) = a3;
break;
case 'l':
LOBYTE(channel[12 * a1 + 4]) = a3;
break;
case 'm':
channel[12 * a1 + 7] = (unsigned __int8)a3 << 6;
break;
case 't':
LOBYTE(channel[12 * a1 + 3]) = a3;
break;
case 'v':
HIBYTE(osc[4 * a1 + 3]) = a3;
break;
case 'w':
LOBYTE(osc[4 * a1 + 3]) = a3;
break;
case '~':
v3 = &channel[12 * a1];
if ( *((_BYTE *)v3 + 16) != (unsigned __int8)a3 >> 4 )
*((_BYTE *)v3 + 18) = 0;
v4 = &channel[12 * a1];
*((_BYTE *)v4 + 16) = (unsigned __int8)a3 >> 4;
*((_BYTE *)v4 + 17) = a3 & 0xF;
break;
default:
return;
}
}
else
{
LOBYTE(channel[12 * a1 + 2]) = 0;
}
}

original_code:
void runcmd(u8 ch, u8 cmd, u8 param) {
 switch(cmd) {
  case 0:
   channel[ch].inum = 0;
   break;
  case 'd':
   osc[ch].duty = param << 8;
   break;
  case 'f':
   channel[ch].volumed = param;
   break;
  case 'i':
   channel[ch].inertia = param << 1;
   break;
  case 'j':
   channel[ch].iptr = param;
   break;
  case 'l':
   channel[ch].bendd = param;
   break;
  case 'm':
   channel[ch].dutyd = param << 6;
   break;
  case 't':
   channel[ch].iwait = param;
   break;
  case 'v':
   osc[ch].volume = param;
   break;
  case 'w':
   osc[ch].waveform = param;
   break;
  case '+':
   channel[ch].inote = param + channel[ch].tnote - 12 * 4;
   break;
  case '=':
   channel[ch].inote = param;
   break;
  case '~':
   if(channel[ch].vdepth != (param >> 4)) {
    channel[ch].vpos = 0;
   }
   channel[ch].vdepth = param >> 4;
   channel[ch].vrate = param & 15;
   break;
  case 'S':
   osc[ch].phase += param;
   break;
 }
}

canonical_original_code:
void runcmd(unsigned char ch, unsigned char cmd, unsigned char param) {
 switch(cmd) {
  case 0:
   channel[ch].inum = 0;
   break;
  case 'd':
   osc[ch].duty = param << 8;
   break;
  case 'f':
   channel[ch].volumed = param;
   break;
  case 'i':
   channel[ch].inertia = param << 1;
   break;
  case 'j':
   channel[ch].iptr = param;
   break;
  case 'l':
   channel[ch].bendd = param;
   break;
  case 'm':
   channel[ch].dutyd = param << 6;
   break;
  case 't':
   channel[ch].iwait = param;
   break;
  case 'v':
   osc[ch].volume = param;
   break;
  case 'w':
   osc[ch].waveform = param;
   break;
  case '+':
   channel[ch].inote = param + channel[ch].tnote - 12 * 4;
   break;
  case '=':
   channel[ch].inote = param;
   break;
  case '~':
   if(channel[ch].vdepth != (param >> 4)) {
    channel[ch].vpos = 0;
   }
   channel[ch].vdepth = param >> 4;
   channel[ch].vrate = param & 15;
   break;
  case 'S':
   osc[ch].phase += param;
   break;
 }
}

variable_types:
ch
unsigned char

variable_types:
cmd
unsigned char

variable_types:
param
unsigned char


iedplonk

decompiled_code:
__int64 __fastcall iedplonk(char a1, char a2)
{
__int64 result; // rax

result = 0LL;
LOBYTE(channel[1]) = a1;
LOBYTE(channel[2]) = a2;
*(__int16 *)((char *)&channel[2] + 1) = 0;
channel[5] = 0;
LOBYTE(channel[4]) = 0;
LOBYTE(channel[6]) = 0;
channel[7] = 0;
LOBYTE(channel[8]) = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char a1, char a2)
{
__int64 result; // rax

result = 0LL;
LOBYTE(channel[1]) = a1;
LOBYTE(channel[2]) = a2;
*(__int16 *)((char *)&channel[2] + 1) = 0;
channel[5] = 0;
LOBYTE(channel[4]) = 0;
LOBYTE(channel[6]) = 0;
channel[7] = 0;
LOBYTE(channel[8]) = 0;
return result;
}

original_code:
void iedplonk(int note, int instr) {
 channel[0].tnote = note;
 channel[0].inum = instr;
 channel[0].iptr = 0;
 channel[0].iwait = 0;
 channel[0].bend = 0;
 channel[0].bendd = 0;
 channel[0].volumed = 0;
 channel[0].dutyd = 0;
 channel[0].vdepth = 0;
}

variable_types: note int

variable_types: instr int


startplaytrack

decompiled_code:
void __fastcall startplaytrack(char a1)
{
LOBYTE(channel[0]) = a1;
LOBYTE(channel[12]) = 0;
LOBYTE(channel[24]) = 0;
LOBYTE(channel[36]) = 0;
trackpos = 0;
trackwait = 0;
playtrack = 1;
playsong = 0;
}

canonical_decompiled_code:
void __fastcall func3(char a1)
{
LOBYTE(channel[0]) = a1;
LOBYTE(channel[12]) = 0;
LOBYTE(channel[24]) = 0;
LOBYTE(channel[36]) = 0;
trackpos = 0;
trackwait = 0;
playtrack = 1;
playsong = 0;
}

original_code:
void startplaytrack(int t) {
 channel[0].tnum = t;
 channel[1].tnum = 0;
 channel[2].tnum = 0;
 channel[3].tnum = 0;
 trackpos = 0;
 trackwait = 0;
 playtrack = 1;
 playsong = 0;
}

variable_types: t int


startplaysong

decompiled_code:
void __fastcall startplaysong(char a1)
{
songpos = a1;
trackpos = 0;
trackwait = 0;
playtrack = 0;
playsong = 1;
}

canonical_decompiled_code:
void __fastcall func4(char a1)
{
songpos = a1;
trackpos = 0;
trackwait = 0;
playtrack = 0;
playsong = 1;
}

original_code:
void startplaysong(int p) {
 songpos = p;
 trackpos = 0;
 trackwait = 0;
 playtrack = 0;
 playsong = 1;
}

variable_types: p int


playroutine

decompiled_code:
__int16 playroutine()
{
unsigned __int8 v0; // al
__int16 *v1; // rbx
__int64 v2; // r12
__int64 v3; // rdi
__int64 v4; // rbp
char v5; // al
__int16 v6; // ax
__int16 v7; // cx
__int16 v8; // si
__int16 v9; // dx
char v10; // dl
__int16 v11; // cx
__int16 v12; // ax
__int16 result; // ax
char v14; // dl
__int16 v15; // si
char v16; // dl
__int16 *v17; // rbx
__int64 v18; // rbp
__int64 v19; // rdi
__int16 *v20; // rbp
unsigned int v21; // ebx
__int64 v22; // rsi
unsigned __int8 v23; // al
char v24; // [rsp+Ah] [rbp-1Eh] BYREF
unsigned __int8 v25; // [rsp+Bh] [rbp-1Dh]
char v26; // [rsp+Ch] [rbp-1Ch]
unsigned __int8 v27; // [rsp+Eh] [rbp-1Ah]

v0 = playsong;
if ( __PAIR16__(playsong, playtrack) )
{
if ( trackwait )
{
--trackwait;
goto LABEL_4;
}
v16 = trackpos;
trackwait = 4;
if ( trackpos )
goto LABEL_34;
if ( !playsong )
goto LABEL_35;
v19 = (unsigned __int8)songpos;
if ( (unsigned __int8)songpos >= songlen )
{
playsong = 0;
if ( playtrack )
{
v0 = 0;
goto LABEL_35;
}
}
else
{
v20 = channel;
v21 = 0;
while ( 1 )
{
v22 = v21++;
v20 += 12;
readsong(v19, v22, &v24);
*((_BYTE *)v20 - 24) = v24;
*((_BYTE *)v20 - 23) = v25;
if ( v21 == 4 )
break;
v19 = (unsigned __int8)songpos;
}
++songpos;
if ( __PAIR16__(playsong, playtrack) )
{
v16 = trackpos;
LABEL_34:
v0 = v16;
LABEL_35:
v17 = channel;
v18 = 0LL;
while ( !*(_BYTE *)v17 )
{
LABEL_37:
++v18;
v17 += 12;
if ( v18 == 4 )
{
trackpos = (v0 + 1) & 0x1F;
goto LABEL_4;
}
}
readtrack(*(unsigned __int8 *)v17, v0, &v24);
if ( v24 )
{
*((_BYTE *)v17 + 2) = *((_BYTE *)v17 + 1) + v24;
v23 = v25;
if ( !v25 )
{
v23 = *((_BYTE *)v17 + 3);
if ( !v23 )
goto LABEL_49;
}
}
else
{
v23 = v25;
if ( !v25 )
{
LABEL_49:
if ( v26 )
runcmd(v18, v26, v27);
v0 = trackpos;
goto LABEL_37;
}
}
*((_BYTE *)v17 + 3) = v23;
*((_BYTE *)v17 + 4) = v23;
*((_BYTE *)v17 + 5) = 0;
*((_BYTE *)v17 + 6) = 0;
v17[5] = 0;
*((_BYTE *)v17 + 8) = 0;
*((_BYTE *)v17 + 12) = 0;
v17[7] = 0;
*((_BYTE *)v17 + 16) = 0;
goto LABEL_49;
}
}
}
LABEL_4:
v1 = channel;
v2 = 0LL;
do
{
v3 = *((unsigned __int8 *)v1 + 4);
v4 = (int)v2;
if ( (_BYTE)v3 )
{
while ( 1 )
{
v5 = *((_BYTE *)v1 + 6);
if ( v5 )
break;
readinstr(v3, *((unsigned __int8 *)v1 + 5), &v24);
++*((_BYTE *)v1 + 5);
runcmd(v2, v24, v25);
v3 = *((unsigned __int8 *)v1 + 4);
if ( !(_BYTE)v3 )
goto LABEL_25;
}
LABEL_9:
*((_BYTE *)v1 + 6) = v5 - 1;
goto LABEL_10;
}
LABEL_25:
v5 = *((_BYTE *)v1 + 6);
if ( v5 )
goto LABEL_9;
LABEL_10:
v6 = v1[10];
v7 = *((_WORD *)&freqtable + *((unsigned __int8 *)v1 + 7));
if ( v6 )
{
v8 = v1[11];
v9 = v7 - v8;
if ( (__int16)(v7 - v8) <= 0 )
{
if ( v7 == v8 )
{
v7 = v1[11];
}
else
{
v15 = v8 - v6;
if ( v9 < -v6 )
v7 = v15;
}
}
else
{
if ( v6 > v9 )
v6 = v7 - v8;
v7 = v6 + v8;
}
v1[11] = v7;
}
v10 = *((_BYTE *)v1 + 18);
osc[4 * (int)v2] = v7 + v1[5] + ((*((unsigned __int8 *)v1 + 16) * *((char *)&sinetable + (v10 & 0x3F))) >> 2);
v11 = HIBYTE(osc[4 * (int)v2 + 3]);
v1[5] += *((char *)v1 + 8);
v12 = v11 + *((char *)v1 + 12);
if ( v12 > 255 )
v12 = 255;
if ( v12 < 0 )
LOBYTE(v12) = 0;
HIBYTE(osc[4 * (int)v2 + 3]) = v12;
result = v1[7] + osc[4 * (int)v2 + 2];
if ( (unsigned __int16)result > 0xE000u )
{
result = 0x2000;
}
else if ( (unsigned __int16)result <= 0x1FFFu )
{
result = -8192;
}
v14 = *((_BYTE *)v1 + 17) + v10;
++v2;
osc[4 * v4 + 2] = result;
v1 += 12;
*((_BYTE *)v1 - 6) = v14;
}
while ( v2 != 4 );
return result;
}

canonical_decompiled_code:
__int16 func5()
{
unsigned __int8 v0; // al
__int16 *v1; // rbx
__int64 v2; // r12
__int64 v3; // rdi
__int64 v4; // rbp
char v5; // al
__int16 v6; // ax
__int16 v7; // cx
__int16 v8; // si
__int16 v9; // dx
char v10; // dl
__int16 v11; // cx
__int16 v12; // ax
__int16 result; // ax
char v14; // dl
__int16 v15; // si
char v16; // dl
__int16 *v17; // rbx
__int64 v18; // rbp
__int64 v19; // rdi
__int16 *v20; // rbp
unsigned int v21; // ebx
__int64 v22; // rsi
unsigned __int8 v23; // al
char v24; // [rsp+Ah] [rbp-1Eh] BYREF
unsigned __int8 v25; // [rsp+Bh] [rbp-1Dh]
char v26; // [rsp+Ch] [rbp-1Ch]
unsigned __int8 v27; // [rsp+Eh] [rbp-1Ah]

v0 = playsong;
if ( __PAIR16__(playsong, playtrack) )
{
if ( trackwait )
{
--trackwait;
goto LABEL_4;
}
v16 = trackpos;
trackwait = 4;
if ( trackpos )
goto LABEL_34;
if ( !playsong )
goto LABEL_35;
v19 = (unsigned __int8)songpos;
if ( (unsigned __int8)songpos >= songlen )
{
playsong = 0;
if ( playtrack )
{
v0 = 0;
goto LABEL_35;
}
}
else
{
v20 = channel;
v21 = 0;
while ( 1 )
{
v22 = v21++;
v20 += 12;
readsong(v19, v22, &v24);
*((_BYTE *)v20 - 24) = v24;
*((_BYTE *)v20 - 23) = v25;
if ( v21 == 4 )
break;
v19 = (unsigned __int8)songpos;
}
++songpos;
if ( __PAIR16__(playsong, playtrack) )
{
v16 = trackpos;
LABEL_34:
v0 = v16;
LABEL_35:
v17 = channel;
v18 = 0LL;
while ( !*(_BYTE *)v17 )
{
LABEL_37:
++v18;
v17 += 12;
if ( v18 == 4 )
{
trackpos = (v0 + 1) & 0x1F;
goto LABEL_4;
}
}
readtrack(*(unsigned __int8 *)v17, v0, &v24);
if ( v24 )
{
*((_BYTE *)v17 + 2) = *((_BYTE *)v17 + 1) + v24;
v23 = v25;
if ( !v25 )
{
v23 = *((_BYTE *)v17 + 3);
if ( !v23 )
goto LABEL_49;
}
}
else
{
v23 = v25;
if ( !v25 )
{
LABEL_49:
if ( v26 )
func1(v18, v26, v27);
v0 = trackpos;
goto LABEL_37;
}
}
*((_BYTE *)v17 + 3) = v23;
*((_BYTE *)v17 + 4) = v23;
*((_BYTE *)v17 + 5) = 0;
*((_BYTE *)v17 + 6) = 0;
v17[5] = 0;
*((_BYTE *)v17 + 8) = 0;
*((_BYTE *)v17 + 12) = 0;
v17[7] = 0;
*((_BYTE *)v17 + 16) = 0;
goto LABEL_49;
}
}
}
LABEL_4:
v1 = channel;
v2 = 0LL;
do
{
v3 = *((unsigned __int8 *)v1 + 4);
v4 = (int)v2;
if ( (_BYTE)v3 )
{
while ( 1 )
{
v5 = *((_BYTE *)v1 + 6);
if ( v5 )
break;
readinstr(v3, *((unsigned __int8 *)v1 + 5), &v24);
++*((_BYTE *)v1 + 5);
func1(v2, v24, v25);
v3 = *((unsigned __int8 *)v1 + 4);
if ( !(_BYTE)v3 )
goto LABEL_25;
}
LABEL_9:
*((_BYTE *)v1 + 6) = v5 - 1;
goto LABEL_10;
}
LABEL_25:
v5 = *((_BYTE *)v1 + 6);
if ( v5 )
goto LABEL_9;
LABEL_10:
v6 = v1[10];
v7 = *((_WORD *)&freqtable + *((unsigned __int8 *)v1 + 7));
if ( v6 )
{
v8 = v1[11];
v9 = v7 - v8;
if ( (__int16)(v7 - v8) <= 0 )
{
if ( v7 == v8 )
{
v7 = v1[11];
}
else
{
v15 = v8 - v6;
if ( v9 < -v6 )
v7 = v15;
}
}
else
{
if ( v6 > v9 )
v6 = v7 - v8;
v7 = v6 + v8;
}
v1[11] = v7;
}
v10 = *((_BYTE *)v1 + 18);
osc[4 * (int)v2] = v7 + v1[5] + ((*((unsigned __int8 *)v1 + 16) * *((char *)&sinetable + (v10 & 0x3F))) >> 2);
v11 = HIBYTE(osc[4 * (int)v2 + 3]);
v1[5] += *((char *)v1 + 8);
v12 = v11 + *((char *)v1 + 12);
if ( v12 > 255 )
v12 = 255;
if ( v12 < 0 )
LOBYTE(v12) = 0;
HIBYTE(osc[4 * (int)v2 + 3]) = v12;
result = v1[7] + osc[4 * (int)v2 + 2];
if ( (unsigned __int16)result > 0xE000u )
{
result = 0x2000;
}
else if ( (unsigned __int16)result <= 0x1FFFu )
{
result = -8192;
}
v14 = *((_BYTE *)v1 + 17) + v10;
++v2;
osc[4 * v4 + 2] = result;
v1 += 12;
*((_BYTE *)v1 - 6) = v14;
}
while ( v2 != 4 );
return result;
}

original_code:
void playroutine() {
 u8 ch;
 if(playtrack || playsong) {
  if(trackwait) {
   trackwait--;
  } else {
   trackwait = 4;
   if(!trackpos) {
    if(playsong) {
     if(songpos >= songlen) {
      playsong = 0;
     } else {
      for(ch = 0; ch < 4; ch++) {
       u8 tmp[2];
       readsong(songpos, ch, tmp);
       channel[ch].tnum = tmp[0];
       channel[ch].transp = tmp[1];
      }
      songpos++;
     }
    }
   }
   if(playtrack || playsong) {
    for(ch = 0; ch < 4; ch++) {
     if(channel[ch].tnum) {
      struct trackline tl;
      u8 instr = 0;
      readtrack(channel[ch].tnum, trackpos, &tl);
      if(tl.note) {
       channel[ch].tnote = tl.note + channel[ch].transp;
       instr = channel[ch].lastinstr;
      }
      if(tl.instr) {
       instr = tl.instr;
      }
      if(instr) {
       channel[ch].lastinstr = instr;
       channel[ch].inum = instr;
       channel[ch].iptr = 0;
       channel[ch].iwait = 0;
       channel[ch].bend = 0;
       channel[ch].bendd = 0;
       channel[ch].volumed = 0;
       channel[ch].dutyd = 0;
       channel[ch].vdepth = 0;
      }
      if(tl.cmd[0])
       runcmd(ch, tl.cmd[0], tl.param[0]);
     }
    }
    trackpos++;
    trackpos &= 31;
   }
  }
 }
 for(ch = 0; ch < 4; ch++) {
  s16 vol;
  u16 duty;
  u16 slur;
  while(channel[ch].inum && !channel[ch].iwait) {
   u8 il[2];
   readinstr(channel[ch].inum, channel[ch].iptr, il);
   channel[ch].iptr++;
   runcmd(ch, il[0], il[1]);
  }
  if(channel[ch].iwait) channel[ch].iwait--;
  if(channel[ch].inertia) {
   s16 diff;
   slur = channel[ch].slur;
   diff = freqtable[channel[ch].inote] - slur;
   if(diff > 0) {
    if(diff > channel[ch].inertia) diff = channel[ch].inertia;
   } else if(diff < 0) {
    if(diff < -channel[ch].inertia) diff = -channel[ch].inertia;
   }
   slur += diff;
   channel[ch].slur = slur;
  } else {
   slur = freqtable[channel[ch].inote];
  }
  osc[ch].freq =
   slur +
   channel[ch].bend +
   ((channel[ch].vdepth * sinetable[channel[ch].vpos & 63]) >> 2);
  channel[ch].bend += channel[ch].bendd;
  vol = osc[ch].volume + channel[ch].volumed;
  if(vol < 0) vol = 0;
  if(vol > 255) vol = 255;
  osc[ch].volume = vol;
  duty = osc[ch].duty + channel[ch].dutyd;
  if(duty > 0xe000) duty = 0x2000;
  if(duty < 0x2000) duty = 0xe000;
  osc[ch].duty = duty;
  channel[ch].vpos += channel[ch].vrate;
 }
}

canonical_original_code:
void playroutine() {
 unsigned char ch;
 if(playtrack || playsong) {
  if(trackwait) {
   trackwait--;
  } else {
   trackwait = 4;
   if(!trackpos) {
    if(playsong) {
     if(songpos >= songlen) {
      playsong = 0;
     } else {
      for(ch = 0; ch < 4; ch++) {
       unsigned char tmp[2];
       readsong(songpos, ch, tmp);
       channel[ch].tnum = tmp[0];
       channel[ch].transp = tmp[1];
      }
      songpos++;
     }
    }
   }
   if(playtrack || playsong) {
    for(ch = 0; ch < 4; ch++) {
     if(channel[ch].tnum) {
      struct trackline tl;
      unsigned char instr = 0;
      readtrack(channel[ch].tnum, trackpos, &tl);
      if(tl.note) {
       channel[ch].tnote = tl.note + channel[ch].transp;
       instr = channel[ch].lastinstr;
      }
      if(tl.instr) {
       instr = tl.instr;
      }
      if(instr) {
       channel[ch].lastinstr = instr;
       channel[ch].inum = instr;
       channel[ch].iptr = 0;
       channel[ch].iwait = 0;
       channel[ch].bend = 0;
       channel[ch].bendd = 0;
       channel[ch].volumed = 0;
       channel[ch].dutyd = 0;
       channel[ch].vdepth = 0;
      }
      if(tl.cmd[0])
       runcmd(ch, tl.cmd[0], tl.param[0]);
     }
    }
    trackpos++;
    trackpos &= 31;
   }
  }
 }
 for(ch = 0; ch < 4; ch++) {
  short vol;
  unsigned short duty;
  unsigned short slur;
  while(channel[ch].inum && !channel[ch].iwait) {
   unsigned char il[2];
   readinstr(channel[ch].inum, channel[ch].iptr, il);
   channel[ch].iptr++;
   runcmd(ch, il[0], il[1]);
  }
  if(channel[ch].iwait) channel[ch].iwait--;
  if(channel[ch].inertia) {
   short diff;
   slur = channel[ch].slur;
   diff = freqtable[channel[ch].inote] - slur;
   if(diff > 0) {
    if(diff > channel[ch].inertia) diff = channel[ch].inertia;
   } else if(diff < 0) {
    if(diff < -channel[ch].inertia) diff = -channel[ch].inertia;
   }
   slur += diff;
   channel[ch].slur = slur;
  } else {
   slur = freqtable[channel[ch].inote];
  }
  osc[ch].freq =
   slur +
   channel[ch].bend +
   ((channel[ch].vdepth * sinetable[channel[ch].vpos & 63]) >> 2);
  channel[ch].bend += channel[ch].bendd;
  vol = osc[ch].volume + channel[ch].volumed;
  if(vol < 0) vol = 0;
  if(vol > 255) vol = 255;
  osc[ch].volume = vol;
  duty = osc[ch].duty + channel[ch].dutyd;
  if(duty > 0xe000) duty = 0x2000;
  if(duty < 0x2000) duty = 0xe000;
  osc[ch].duty = duty;
  channel[ch].vpos += channel[ch].vrate;
 }
}

variable_types:
tmp
unsigned char [2]

variable_types: struct trackline { unsigned char note; unsigned char instr; unsigned char cmd[2]; unsigned char param[2]; }

variable_types:
instr
unsigned char

variable_types: vol short

variable_types:
duty
unsigned short

variable_types:
slur
unsigned short

variable_types:
il
unsigned char [2]

variable_types: diff short


initchip

decompiled_code:
void initchip()
{
HIBYTE(osc[3]) = 0;
trackwait = 0;
HIBYTE(osc[7]) = 0;
trackpos = 0;
HIBYTE(osc[11]) = 0;
playsong = 0;
playtrack = 0;
LOBYTE(channel[2]) = 0;
LOBYTE(channel[14]) = 0;
LOBYTE(channel[26]) = 0;
HIBYTE(osc[15]) = 0;
LOBYTE(channel[38]) = 0;
}

canonical_decompiled_code:
void func6()
{
HIBYTE(osc[3]) = 0;
trackwait = 0;
HIBYTE(osc[7]) = 0;
trackpos = 0;
HIBYTE(osc[11]) = 0;
playsong = 0;
playtrack = 0;
LOBYTE(channel[2]) = 0;
LOBYTE(channel[14]) = 0;
LOBYTE(channel[26]) = 0;
HIBYTE(osc[15]) = 0;
LOBYTE(channel[38]) = 0;
}

original_code:
void initchip() {
 trackwait = 0;
 trackpos = 0;
 playsong = 0;
 playtrack = 0;
 osc[0].volume = 0;
 channel[0].inum = 0;
 osc[1].volume = 0;
 channel[1].inum = 0;
 osc[2].volume = 0;
 channel[2].inum = 0;
 osc[3].volume = 0;
 channel[3].inum = 0;
}


interrupthandler

decompiled_code:
__int64 interrupthandler()
{
unsigned int v0; // edx
char v1; // al
int v2; // esi
int v3; // edi
int v4; // ecx
__int64 v5; // rax
unsigned __int8 v6; // dl
int v7; // edx
__int16 v8; // r11
bool v10; // zf

v0 = (unsigned int)noiseseed_0 >> 31;
if ( (noiseseed_0 & 0x1000000) != 0 )
LOBYTE(v0) = noiseseed_0 >= 0;
if ( (noiseseed_0 & 0x40) != 0 )
LOBYTE(v0) = v0 ^ 1;
if ( (noiseseed_0 & 0x200) != 0 )
LOBYTE(v0) = v0 ^ 1;
v1 = v0 | (2 * noiseseed_0);
noiseseed_0 = (unsigned __int8)v0 | (2 * noiseseed_0);
if ( callbackwait )
{
--callbackwait;
}
else
{
playroutine();
callbackwait = -77;
v1 = noiseseed_0;
}
v2 = 0;
v3 = 0;
v4 = (char)((v1 & 0x3F) - 32);
do
{
v5 = v2;
v6 = osc[4 * v2 + 3];
if ( v6 == 2 )
{
v7 = (unsigned __int16)osc[4 * v2 + 2] < (unsigned __int16)osc[4 * v2 + 1] ? -32 : 31;
}
else if ( v6 > 2u )
{
v10 = v6 == 3;
v7 = 0;
if ( v10 )
v7 = v4;
}
else if ( v6 )
{
v7 = (char)(((unsigned __int16)osc[4 * v2 + 1] >> 10) - 32);
}
else if ( osc[4 * v2 + 1] < 0 )
{
v7 = (char)(31 - (((unsigned __int16)osc[4 * v2 + 1] - 0x8000) >> 9));
}
else
{
v7 = (char)(((unsigned __int16)osc[4 * v2 + 1] >> 9) - 32);
}
v8 = osc[4 * v2++];
osc[4 * v5 + 1] += v8;
v3 += v7 * HIBYTE(osc[4 * v5 + 3]);
}
while ( v2 != 4 );
LOWORD(v3) = (__int16)v3 >> 8;
return (unsigned int)(v3 - 128);
}

original_code:
u8 interrupthandler()
{
 u8 i;
 s16 acc;
 static u32 noiseseed = 1;
 u8 newbit;
 newbit = 0;
 if(noiseseed & 0x80000000L) newbit ^= 1;
 if(noiseseed & 0x01000000L) newbit ^= 1;
 if(noiseseed & 0x00000040L) newbit ^= 1;
 if(noiseseed & 0x00000200L) newbit ^= 1;
 noiseseed = (noiseseed << 1) | newbit;
 if(callbackwait) {
  callbackwait--;
 } else {
  playroutine();
  callbackwait = 180 - 1;
 }
 acc = 0;
 for(i = 0; i < 4; i++) {
  s8 value;
  switch(osc[i].waveform) {
   case 0x00:
    if(osc[i].phase < 0x8000) {
     value = -32 + (osc[i].phase >> 9);
    } else {
     value = 31 - ((osc[i].phase - 0x8000) >> 9);
    }
    break;
   case 0x01:
    value = -32 + (osc[i].phase >> 10);
    break;
   case 0x02:
    value = (osc[i].phase > osc[i].duty)? -32 : 31;
    break;
   case 0x03:
    value = (noiseseed & 63) - 32;
    break;
   default:
    value = 0;
    break;
  }
  osc[i].phase += osc[i].freq;
  acc += value * osc[i].volume;
 }
 return 128 + (acc >> 8);
}

canonical_original_code:
unsigned char interrupthandler()
{
 unsigned char i;
 short acc;
 static unsigned int noiseseed = 1;
 unsigned char newbit;
 newbit = 0;
 if(noiseseed & 0x80000000L) newbit ^= 1;
 if(noiseseed & 0x01000000L) newbit ^= 1;
 if(noiseseed & 0x00000040L) newbit ^= 1;
 if(noiseseed & 0x00000200L) newbit ^= 1;
 noiseseed = (noiseseed << 1) | newbit;
 if(callbackwait) {
  callbackwait--;
 } else {
  playroutine();
  callbackwait = 180 - 1;
 }
 acc = 0;
 for(i = 0; i < 4; i++) {
  char value;
  switch(osc[i].waveform) {
   case 0x00:
    if(osc[i].phase < 0x8000) {
     value = -32 + (osc[i].phase >> 9);
    } else {
     value = 31 - ((osc[i].phase - 0x8000) >> 9);
    }
    break;
   case 0x01:
    value = -32 + (osc[i].phase >> 10);
    break;
   case 0x02:
    value = (osc[i].phase > osc[i].duty)? -32 : 31;
    break;
   case 0x03:
    value = (noiseseed & 63) - 32;
    break;
   default:
    value = 0;
    break;
  }
  osc[i].phase += osc[i].freq;
  acc += value * osc[i].volume;
 }
 return 128 + (acc >> 8);
}

variable_types: acc short

variable_types:
noiseseed
unsigned int

variable_types:
newbit
unsigned char

variable_types: value char

return_type: unsigned char


repo: nwf/lofdc

decompiled_code:
int __fastcall serial_mbis(int a1, int a2)
{
int result; // eax
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
result = ioctl(a1, 0x5416uLL, v3);
if ( result )
_assert_fail("res == 0", "controller/common-utils.c", 0x12u, "serial_mbis");
return result;
}

canonical_decompiled_code:
int __fastcall func0(int a1, int a2)
{
int result; // eax
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
result = ioctl(a1, 0x5416uLL, v3);
if ( result )
_assert_fail("res == 0", "controller/common-utils.c", 0x12u, "serial_mbis");
return result;
}

original_code:
void serial_mbis(int fd, int flags) {
  int res = ioctl(fd, 0x5416, &flags);
  ((void) sizeof ((res == 0) ? 1 : 0), __extension__ ({ if (res == 0) ; else __assert_fail ("res == 0", "controller/common-utils.c", 18, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types: fd int

variable_types: flags int

variable_types: res int


decompiled_code:
int __fastcall serial_mbic(int a1, int a2)
{
int result; // eax
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
result = ioctl(a1, 0x5417uLL, v3);
if ( result )
_assert_fail("res == 0", "controller/common-utils.c", 0x17u, "serial_mbic");
return result;
}

canonical_decompiled_code:
int __fastcall func1(int a1, int a2)
{
int result; // eax
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
result = ioctl(a1, 0x5417uLL, v3);
if ( result )
_assert_fail("res == 0", "controller/common-utils.c", 0x17u, "serial_mbic");
return result;
}

original_code:
void serial_mbic(int fd, int flags) {
  int res = ioctl(fd, 0x5417, &flags);
  ((void) sizeof ((res == 0) ? 1 : 0), __extension__ ({ if (res == 0) ; else __assert_fail ("res == 0", "controller/common-utils.c", 23, __extension__ __PRETTY_FUNCTION__); }));
}


decompiled_code:
int __fastcall serial_init(int fd, int a2)
{
int result; // eax
struct termios v3; // [rsp+0h] [rbp-58h] BYREF

v3.c_ospeed = 0;
*(_QWORD *)&v3.c_cc[31] = 0LL;
*(_OWORD *)&v3.c_iflag = 0LL;
*(_OWORD *)&v3.c_line = 0LL;
*(_OWORD *)&v3.c_cc[15] = 0LL;
if ( tcgetattr(fd, &v3) )
_assert_fail("res == 0", "controller/common-utils.c", 0x20u, "serial_init");
v3.c_cflag = a2 | v3.c_cflag & 0x7FFFEFF0 | 0xC00;
result = tcsetattr(fd, 1, &v3);
if ( result )
_assert_fail("res == 0", "controller/common-utils.c", 0x24u, "serial_init");
return result;
}

canonical_decompiled_code:
int __fastcall func2(int fd, int a2)
{
int result; // eax
struct termios v3; // [rsp+0h] [rbp-58h] BYREF

v3.c_ospeed = 0;
*(_QWORD *)&v3.c_cc[31] = 0LL;
*(_OWORD *)&v3.c_iflag = 0LL;
*(_OWORD *)&v3.c_line = 0LL;
*(_OWORD *)&v3.c_cc[15] = 0LL;
if ( tcgetattr(fd, &v3) )
_assert_fail("res == 0", "controller/common-utils.c", 0x20u, "serial_init");
v3.c_cflag = a2 | v3.c_cflag & 0x7FFFEFF0 | 0xC00;
result = tcsetattr(fd, 1, &v3);
if ( result )
_assert_fail("res == 0", "controller/common-utils.c", 0x24u, "serial_init");
return result;
}

original_code:
void serial_init(int fd, int baudtermio) {
  int res;
  struct termios tios;
  memset(&tios, 0, sizeof(tios));
  res = tcgetattr(fd, &tios);
  ((void) sizeof ((res == 0) ? 1 : 0), __extension__ ({ if (res == 0) ; else __assert_fail ("res == 0", "controller/common-utils.c", 32, __extension__ __PRETTY_FUNCTION__); }));
  tios.c_cflag &= ~(020000000000|0010017|0010000);
  tios.c_cflag |= 0002000 | 0004000 | baudtermio;
  res = tcsetattr(fd, 1, &tios);
  ((void) sizeof ((res == 0) ? 1 : 0), __extension__ ({ if (res == 0) ; else __assert_fail ("res == 0", "controller/common-utils.c", 36, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types: baudtermio int

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }


decompiled_code:
int __fastcall serial_deinit(int fd)
{
tcflag_t v1; // eax
struct termios v3; // [rsp+0h] [rbp-48h] BYREF

tcflush(fd, 2);
*(_OWORD *)&v3.c_iflag = 0LL;
*(_OWORD *)&v3.c_line = 0LL;
*(_OWORD *)&v3.c_cc[15] = 0LL;
*(_QWORD *)&v3.c_cc[31] = 0LL;
v3.c_ospeed = 0;
tcgetattr(fd, &v3);
v1 = v3.c_cflag & 0x7FFFEFF0;
BYTE1(v1) = ((unsigned __int16)(v3.c_cflag & 0xEFF0) >> 8) | 0xC;
v3.c_cflag = v1;
tcsetattr(fd, 2, &v3);
return close(fd);
}

canonical_decompiled_code:
int __fastcall func3(int fd)
{
tcflag_t v1; // eax
struct termios v3; // [rsp+0h] [rbp-48h] BYREF

tcflush(fd, 2);
*(_OWORD *)&v3.c_iflag = 0LL;
*(_OWORD *)&v3.c_line = 0LL;
*(_OWORD *)&v3.c_cc[15] = 0LL;
*(_QWORD *)&v3.c_cc[31] = 0LL;
v3.c_ospeed = 0;
tcgetattr(fd, &v3);
v1 = v3.c_cflag & 0x7FFFEFF0;
BYTE1(v1) = ((unsigned __int16)(v3.c_cflag & 0xEFF0) >> 8) | 0xC;
v3.c_cflag = v1;
tcsetattr(fd, 2, &v3);
return close(fd);
}

original_code:
void serial_deinit(int fd) {
  tcflush(fd, 2);
  struct termios tios;
  memset(&tios, 0, sizeof(tios));
  tcgetattr(fd, &tios);
  tios.c_cflag &= ~(0010017|0010000|020000000000);
  tios.c_cflag |= 0002000 | 0004000 | 0000000;
  tcsetattr(fd, 2, &tios);
  close(fd);
}

user_defined_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }


decompiled_code:
void *__fastcall load_obj(char *file, _QWORD *a2, char **a3)
{
void *v4; // rax
void *v5; // rbp
void *v6; // r12
char *v7; // rax

dlerror();
v4 = dlopen(file, 2);
if ( !v4 )
{
v6 = 0LL;
if ( a3 )
*a3 = dlerror();
return v6;
}
v5 = v4;
if ( a2 )
*a2 = v4;
dlerror();
v6 = dlsym(v5, "_plugin_vtable");
v7 = dlerror();
if ( !v7 )
return v6;
if ( a3 )
*a3 = v7;
dlclose(v5);
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func5(char *file, _QWORD *a2, char **a3)
{
void *v4; // rax
void *v5; // rbp
void *v6; // r12
char *v7; // rax

dlerror();
v4 = dlopen(file, 2);
if ( !v4 )
{
v6 = 0LL;
if ( a3 )
*a3 = dlerror();
return v6;
}
v5 = v4;
if ( a2 )
*a2 = v4;
dlerror();
v6 = dlsym(v5, "_plugin_vtable");
v7 = dlerror();
if ( !v7 )
return v6;
if ( a3 )
*a3 = v7;
dlclose(v5);
return 0LL;
}

original_code:
void * load_obj(char *fn, void **odl, char **oerr) {
  void *dl;
  char *err;
  dlerror();
  dl = dlopen(fn, 0 | 0x00002);
  if (!dl) {
    if(oerr) { *oerr = dlerror(); }
    goto out_dl;
  }
  if(odl) { *odl = dl; }
  dlerror();
  void *vt = dlsym(dl, "_plugin_vtable");
  err = dlerror();
  if(err) {
    if(oerr) { *oerr = err; }
    goto out_sym;
  }
  return vt;
out_sym:
  dlclose(dl);
out_dl:
  return ((void *)0);
}

canonical_original_code:
void *load_obj(char *fn, void **odl, char **oerr) {
  void *dl;
  char *err;
  dlerror();
  dl = dlopen(fn, 0 | 0x00002);
  if (!dl) {
    if(oerr) { *oerr = dlerror(); }
    goto out_dl;
  }
  if(odl) { *odl = dl; }
  dlerror();
  void *vt = dlsym(dl, "_plugin_vtable");
  err = dlerror();
  if(err) {
    if(oerr) { *oerr = err; }
    goto out_sym;
  }
  return vt;
out_sym:
  dlclose(dl);
out_dl:
  return ((void *)0);
}

variable_types:
fn
char *

variable_types:
odl
void **

variable_types:
oerr
char **

variable_types:
dl
void *

variable_types:
err
char *

variable_types:
vt
void *

return_type: void *


setnonblock

decompiled_code:
int __fastcall setnonblock(int fd)
{
int v1; // eax
int result; // eax

v1 = fcntl(fd, 3);
if ( v1 < 0 )
_assert_fail("fl >= 0", "controller/common-utils.c", 0x72u, "setnonblock");
BYTE1(v1) |= 8u;
result = fcntl(fd, 4, (unsigned int)v1);
if ( result < 0 )
_assert_fail("fl >= 0", "controller/common-utils.c", 0x75u, "setnonblock");
return result;
}

canonical_decompiled_code:
int __fastcall func6(int fd)
{
int v1; // eax
int result; // eax

v1 = fcntl(fd, 3);
if ( v1 < 0 )
_assert_fail("fl >= 0", "controller/common-utils.c", 0x72u, "setnonblock");
BYTE1(v1) |= 8u;
result = fcntl(fd, 4, (unsigned int)v1);
if ( result < 0 )
_assert_fail("fl >= 0", "controller/common-utils.c", 0x75u, "setnonblock");
return result;
}

original_code:
void setnonblock(int fd)
{
  int fl;
  fl = fcntl(fd, 3);
  ((void) sizeof ((fl >= 0) ? 1 : 0), __extension__ ({ if (fl >= 0) ; else __assert_fail ("fl >= 0", "controller/common-utils.c", 114, __extension__ __PRETTY_FUNCTION__); }));
  fl |= 04000;
  fl = fcntl(fd, 4, fl);
  ((void) sizeof ((fl >= 0) ? 1 : 0), __extension__ ({ if (fl >= 0) ; else __assert_fail ("fl >= 0", "controller/common-utils.c", 117, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types: fl int


decompiled_code:
void __fastcall tdestroy_finalize(void **a1, void (*a2)(void *nodep))
{
void *v2; // r8

v2 = *a1;
*a1 = 0LL;
tdestroy(v2, a2);
}

canonical_decompiled_code:
void __fastcall func7(void **a1, void (*a2)(void *nodep))
{
void *v2; // r8

v2 = *a1;
*a1 = 0LL;
tdestroy(v2, a2);
}

original_code:
void tdestroy_finalize(void **tree, void (*cb)(void *)) {
  void *root = *tree;
  *tree = ((void *)0);
  tdestroy(root, cb);
}

variable_types:
tree
void **

variable_types:
cb
void (*)(void *)

variable_types:
root
void *


decompiled_code:
__int64 __fastcall init_GPIO(unsigned int a1, int a2)
{
int v2; // eax
int v3; // ebp
int v5; // er13
char v6[48]; // [rsp+0h] [rbp-98h] BYREF
char dest[104]; // [rsp+30h] [rbp-68h] BYREF

snprintf(v6, 0x24uLL, "/sys/class/gpio/gpio%d/", a1);
if ( access(v6, 0) == -1 )
{
v5 = open("/sys/class/gpio/export", 513);
if ( v5 == -1 )
{
LABEL_14:
puts("Error opening gpio/export");
exit(-1);
}
sprintf(dest, "%d", a1);
if ( write(v5, dest, 2uLL) < 0 )
{
printf("Error exporting pin %d\n", a1);
exit(-1);
}
close(v5);
}
else
{
printf("Warning: GPIO pin %d has already been exported\n", a1);
}
strcpy(stpcpy(dest, v6), "direction");
v2 = open(dest, 513);
v3 = v2;
if ( v2 == -1 )
goto LABEL_14;
if ( a2 )
{
if ( a2 == 1 && write(v2, "in", 2uLL) < 0 )
{
printf("Error setting pin %d to IN\n", a1);
exit(-1);
}
}
else if ( write(v2, "out", 3uLL) < 0 )
{
printf("Error setting pin %d to OUT\n", a1);
exit(-1);
}
close(v3);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, int a2)
{
int v2; // eax
int v3; // ebp
int v5; // er13
char v6[48]; // [rsp+0h] [rbp-98h] BYREF
char dest[104]; // [rsp+30h] [rbp-68h] BYREF

snprintf(v6, 0x24uLL, "/sys/class/gpio/gpio%d/", a1);
if ( access(v6, 0) == -1 )
{
v5 = open("/sys/class/gpio/export", 513);
if ( v5 == -1 )
{
LABEL_14:
puts("Error opening gpio/export");
exit(-1);
}
sprintf(dest, "%d", a1);
if ( write(v5, dest, 2uLL) < 0 )
{
printf("Error exporting pin %d\n", a1);
exit(-1);
}
close(v5);
}
else
{
printf("Warning: GPIO pin %d has already been exported\n", a1);
}
strcpy(stpcpy(dest, v6), "direction");
v2 = open(dest, 513);
v3 = v2;
if ( v2 == -1 )
goto LABEL_14;
if ( a2 )
{
if ( a2 == 1 && write(v2, "in", 2uLL) < 0 )
{
printf("Error setting pin %d to IN\n", a1);
exit(-1);
}
}
else if ( write(v2, "out", 3uLL) < 0 )
{
printf("Error setting pin %d to OUT\n", a1);
exit(-1);
}
close(v3);
return 0LL;
}

original_code:
int init_GPIO(int pin, int direction){
 char pinDir[36];
 int fd;
 snprintf(pinDir, sizeof pinDir, "/sys/class/gpio/gpio%d/", pin);
 if( access( pinDir, 0 ) != -1 ) {
     printf("Warning: GPIO pin %d has already been exported\n",pin);
 } else {
  if((fd = open("/sys/class/gpio/export", 01|01000))==-1) {
   printf("Error opening gpio/export\n");
   exit(-1);
  }
  char pinb[2];
  sprintf(pinb, "%d", pin);
  if( write(fd, (char*)pinb, 2) < 0){
   printf("Error exporting pin %d\n", pin);
   exit(-1);
  }
  close(fd);
 }
 char opt[64];
 strcpy(opt,pinDir);
 strcat(opt,"direction");
 if((fd = open(opt, 01|01000)) == -1) {
  printf("Error opening gpio/export\n");
  exit(-1);
 }
 if( direction == 0){
  if(write(fd, (char*)"out", 3) < 0){
   printf("Error setting pin %d to OUT\n", pin);
   exit(-1);
  }
 } else if ( direction == 1){
  if(write(fd, (char*)"in", 2) < 0){
   printf("Error setting pin %d to IN\n", pin);
   exit(-1);
  }
 }
 close(fd);
 return 0;
}

canonical_original_code:
int init_GPIO(int pin, int direction){
 char pinDir[36];
 int fd;
 snprintf(pinDir, sizeof pinDir, "/sys/class/gpio/gpio%d/", pin);
 if( access( pinDir, 0 ) != -1 ) {
     printf("Warning: GPIO pin %d has already been exported\n",pin);
 } else {
  if((fd = open("/sys/class/gpio/export", 01|01000))==-1) {
   printf("Error opening gpio/export\n");
   exit(-1);
  }
  char pinb[2];
  sprintf(pinb, "%d", pin);
  if( write(fd, (char *)pinb, 2) < 0){
   printf("Error exporting pin %d\n", pin);
   exit(-1);
  }
  close(fd);
 }
 char opt[64];
 strcpy(opt,pinDir);
 strcat(opt,"direction");
 if((fd = open(opt, 01|01000)) == -1) {
  printf("Error opening gpio/export\n");
  exit(-1);
 }
 if( direction == 0){
  if(write(fd, (char *)"out", 3) < 0){
   printf("Error setting pin %d to OUT\n", pin);
   exit(-1);
  }
 } else if ( direction == 1){
  if(write(fd, (char *)"in", 2) < 0){
   printf("Error setting pin %d to IN\n", pin);
   exit(-1);
  }
 }
 close(fd);
 return 0;
}

variable_types: pin int

variable_types: direction int

variable_types:
pinDir
char [36]

variable_types:
pinb
char [2]

variable_types:
opt
char [64]


decompiled_code:
__int64 __fastcall set_GPIO(unsigned int a1, unsigned int a2)
{
int v3; // edi
char v5[48]; // [rsp+0h] [rbp-88h] BYREF
char dest[88]; // [rsp+30h] [rbp-58h] BYREF

snprintf(v5, 0x24uLL, "/sys/class/gpio/gpio%d/", a1);
if ( access(v5, 0) == -1 )
{
printf("Error GPIO pin %d has not been initialized\n", a1);
return 0LL;
}
strcpy(stpcpy(dest, v5), "value");
v3 = open(dest, 513);
if ( v3 == -1 )
{
printf("Error opening gpio/gpio%d/value\n", a1);
exit(-1);
}
if ( a2 == 1 )
{
if ( write(v3, "1", 3uLL) >= 0 )
return 0LL;
goto LABEL_9;
}
if ( !a2 )
{
if ( write(v3, "0", 3uLL) >= 0 )
return 0LL;
LABEL_9:
printf("Error setting pin %d to OUT\n", a1);
exit(-1);
}
printf("Error: value %d out of range\n", a2);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1, unsigned int a2)
{
int v3; // edi
char v5[48]; // [rsp+0h] [rbp-88h] BYREF
char dest[88]; // [rsp+30h] [rbp-58h] BYREF

snprintf(v5, 0x24uLL, "/sys/class/gpio/gpio%d/", a1);
if ( access(v5, 0) == -1 )
{
printf("Error GPIO pin %d has not been initialized\n", a1);
return 0LL;
}
strcpy(stpcpy(dest, v5), "value");
v3 = open(dest, 513);
if ( v3 == -1 )
{
printf("Error opening gpio/gpio%d/value\n", a1);
exit(-1);
}
if ( a2 == 1 )
{
if ( write(v3, "1", 3uLL) >= 0 )
return 0LL;
goto LABEL_9;
}
if ( !a2 )
{
if ( write(v3, "0", 3uLL) >= 0 )
return 0LL;
LABEL_9:
printf("Error setting pin %d to OUT\n", a1);
exit(-1);
}
printf("Error: value %d out of range\n", a2);
return 0xFFFFFFFFLL;
}

original_code:
int set_GPIO(int pin, int val){
 char pinDir[36];
 int fd;
 snprintf(pinDir, sizeof pinDir, "/sys/class/gpio/gpio%d/", pin);
 if( access( pinDir, 0 ) != -1 ) {
  char opt[64];
  strcpy(opt,pinDir);
  strcat(opt,"value");
  if((fd = open(opt, 01|01000)) == -1) {
   printf("Error opening gpio/gpio%d/value\n", pin);
   exit(-1);
  }
  if(val == 1){
   if(write(fd, (char*)"1", 3) < 0){
    printf("Error setting pin %d to OUT\n", pin);
    exit(-1);
   }
  }else if(val == 0){
   if(write(fd, (char*)"0", 3) < 0){
    printf("Error setting pin %d to OUT\n", pin);
    exit(-1);
   }
  } else {
   printf("Error: value %d out of range\n",val);
   return(-1);
  }
 } else {
  printf("Error GPIO pin %d has not been initialized\n",pin);
 }
 return 0;
}

canonical_original_code:
int set_GPIO(int pin, int val){
 char pinDir[36];
 int fd;
 snprintf(pinDir, sizeof pinDir, "/sys/class/gpio/gpio%d/", pin);
 if( access( pinDir, 0 ) != -1 ) {
  char opt[64];
  strcpy(opt,pinDir);
  strcat(opt,"value");
  if((fd = open(opt, 01|01000)) == -1) {
   printf("Error opening gpio/gpio%d/value\n", pin);
   exit(-1);
  }
  if(val == 1){
   if(write(fd, (char *)"1", 3) < 0){
    printf("Error setting pin %d to OUT\n", pin);
    exit(-1);
   }
  }else if(val == 0){
   if(write(fd, (char *)"0", 3) < 0){
    printf("Error setting pin %d to OUT\n", pin);
    exit(-1);
   }
  } else {
   printf("Error: value %d out of range\n",val);
   return(-1);
  }
 } else {
  printf("Error GPIO pin %d has not been initialized\n",pin);
 }
 return 0;
}

variable_types: val int

variable_types: fd int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
init_GPIO(21LL, 0LL, envp);
set_GPIO(21LL, 1LL);
sleep(5u);
set_GPIO(21LL, 0LL);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func7(21LL, 0LL, envp);
func8(21LL, 1LL);
sleep(5u);
func8(21LL, 0LL);
return 0;
}

original_code:
int main(int argc, char **argv){
 init_GPIO(21, 0);
 set_GPIO(21, 1);
 sleep(5);
 set_GPIO(21, 0);
  return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
int log_printf(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
evbuffer_add_vprintf(log_eb, format, arg);
va_end(arg);
va_start(arg, format);
return vfprintf(stderr, format, arg);
}

canonical_decompiled_code:
int func1(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
evbuffer_add_vprintf(log_eb, format, arg);
va_end(arg);
va_start(arg, format);
return vfprintf(stderr, format, arg);
}

original_code:
void log_printf(const char *fmt, ...) {
  va_list ap;
  __builtin_va_start(ap,fmt);
  evbuffer_add_vprintf(log_eb, fmt, ap);
  __builtin_va_end(ap);
  __builtin_va_start(ap,fmt);
  vfprintf(stderr, fmt, ap);
  __builtin_va_end(ap);
}

canonical_original_code:
void log_printf(char *fmt, ...) {
  __builtin_va_list ap;
  __builtin_va_start(ap,fmt);
  evbuffer_add_vprintf(log_eb, fmt, ap);
  __builtin_va_end(ap);
  __builtin_va_start(ap,fmt);
  vfprintf(stderr, fmt, ap);
  __builtin_va_end(ap);
}

variable_types:
fmt
char *


decompiled_code:
void rfid_common_ctor()
{
all_rfid = 0LL;
}

canonical_decompiled_code:
void func3()
{
all_rfid = 0LL;
}

original_code:
static void __attribute__((constructor)) rfid_common_ctor(void) {
  do { (&all_rfid)->lh_first = ((void *)0); } while ( 0);
}

canonical_original_code:
static void rfid_common_ctor() {
  do { (&all_rfid)->lh_first = ((void *)0); } while ( 0);
}


decompiled_code:
void lock_common_ctor()
{
all_lock = 0LL;
}

canonical_decompiled_code:
void func4()
{
all_lock = 0LL;
}

original_code:
static void __attribute__((constructor)) lock_common_ctor(void) {
  do { (&all_lock)->lh_first = ((void *)0); } while ( 0);
}

canonical_original_code:
static void lock_common_ctor() {
  do { (&all_lock)->lh_first = ((void *)0); } while ( 0);
}