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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)(result + 1);
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)(result + 1);
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

original_code:
unsigned int list_size(List *l)
{
  int i;
  for (i = 0; (l); ++i, l = l->next);
  return i;
}

canonical_original_code:
unsigned int list_size(struct _List *l)
{
  int i;
  for (i = 0; (l); ++i, l = l->next);
  return i;
}


delHuffmanEncoder

repo: xorver/mikro

decompiled_code:
void __fastcall delHuffmanEncoder(void *ptr)
{
delDiscreteCosineTransform(*((_QWORD *)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
delDiscreteCosineTransform(*((_QWORD *)ptr + 1));
free(ptr);
}

original_code:
void delHuffmanEncoder(HuffmanEncoder* encoder)
{
 delDiscreteCosineTransform(encoder->_dct);
 free(encoder);
}

canonical_original_code:
void delHuffmanEncoder(struct HuffmanEncoder *encoder)
{
 delDiscreteCosineTransform(encoder->_dct);
 free(encoder);
}

variable_types: struct HuffmanEncoder { struct BitBuffer { unsigned char *_buffer; unsigned char *_insert; unsigned int _length; unsigned char _preBuffer; unsigned char _preLength; void (*put)(struct BitBuffer *self, int data, unsigned char bitsNum); void (*flush)(struct BitBuffer *self); void (*rawPut)(struct BitBuffer *self, unsigned char bit); void (*rawWrite)(struct BitBuffer *self, void *data, unsigned int size, unsigned int count); void (*calcBits)(struct BitBuffer *self, int value, unsigned short bits[2]); } *_buffer; struct DiscreteCosineTransform { void (*transformMCU)(struct DiscreteCosineTransform *self, float *MCU); } *_dct; int MCU[64]; int (*encodeBlock)(struct HuffmanEncoder *self, float *MCU, float *fdtbl, int lastDC, unsigned short HTDC[256][2], unsigned short HTAC[256][2]); void (*quantizeZigzag)(struct HuffmanEncoder *self, float *MCU, float *fdtbl); } *

return_type: void

user_defined_types: struct HuffmanEncoder { struct BitBuffer *_buffer; struct DiscreteCosineTransform *_dct; int MCU[64]; int (*encodeBlock)(struct HuffmanEncoder *self, float *MCU, float *fdtbl, int lastDC, unsigned short HTDC[256][2], unsigned short HTAC[256][2]); void (*quantizeZigzag)(struct HuffmanEncoder *self, float *MCU, float *fdtbl); }


delEncoderInput

decompiled_code:
void __fastcall delEncoderInput(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

original_code:
void delEncoderInput(EncoderInput* input)
{
 free(input->data);
 free(input);
}

canonical_original_code:
void delEncoderInput(struct EncoderInput *input)
{
 free(input->data);
 free(input);
}

variable_types: struct EncoderInput { unsigned char *data; unsigned int rows; unsigned int cols; unsigned char components; } *


newDiscreteCosineTransform

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

result = malloc(8uLL);
*result = _transformMCU;
return result;
}

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

result = malloc(8uLL);
*result = _transformMCU;
return result;
}

original_code:
DiscreteCosineTransform* newDiscreteCosineTransform()
{
 DiscreteCosineTransform* dct = (DiscreteCosineTransform*) malloc(sizeof(DiscreteCosineTransform));
 dct->transformMCU = __transformMCU;
 return dct;
}

canonical_original_code:
struct DiscreteCosineTransform *newDiscreteCosineTransform()
{
 struct DiscreteCosineTransform *dct = (DiscreteCosineTransform*) malloc(sizeof(DiscreteCosineTransform));
 dct->transformMCU = __transformMCU;
 return dct;
}

variable_types: struct DiscreteCosineTransform { void (*transformMCU)(struct DiscreteCosineTransform *self, float *MCU); } *


delDiscreteCosineTransform

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

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

original_code:
void delDiscreteCosineTransform(DiscreteCosineTransform* dct)
{
 free(dct);
}

canonical_original_code:
void delDiscreteCosineTransform(struct DiscreteCosineTransform *dct)
{
 free(dct);
}

user_defined_types: struct DiscreteCosineTransform { void (*transformMCU)(struct DiscreteCosineTransform *self, float *MCU); }


emailInit

decompiled_code:
int emailInit()
{
system("mkdir -p ~/.mutt/cache/headers");
system("mkdir -p ~/.mutt/cache/bodies");
system("touch -p ~/.mutt/certificates");
return system("sudo cp ../.muttrc ~/");
}

canonical_decompiled_code:
int func0()
{
system("mkdir -p ~/.mutt/cache/headers");
system("mkdir -p ~/.mutt/cache/bodies");
system("touch -p ~/.mutt/certificates");
return system("sudo cp ../.muttrc ~/");
}

original_code:
void emailInit(){
 system("mkdir -p ~/.mutt/cache/headers");
 system("mkdir -p ~/.mutt/cache/bodies");
 system("touch -p ~/.mutt/certificates");
 system("sudo cp ../.muttrc ~/");
}


sendVideo

decompiled_code:
int __fastcall sendVideo(char *src)
{
char v2[1032]; // [rsp+0h] [rbp-408h] BYREF

v2[0] = 0;
strcat(v2, "echo \"Zaobserwowano ruch, nagranie w zalaczniku.\" | mutt -s \"nagranie z monitoringu\" -a ");
strcat(v2, src);
strcat(v2, " -- ");
strcat(v2, "projektmonitoringu@gmail.com");
return system(v2);
}

canonical_decompiled_code:
int __fastcall func1(char *src)
{
char v2[1032]; // [rsp+0h] [rbp-408h] BYREF

v2[0] = 0;
strcat(v2, "echo \"Zaobserwowano ruch, nagranie w zalaczniku.\" | mutt -s \"nagranie z monitoringu\" -a ");
strcat(v2, src);
strcat(v2, " -- ");
strcat(v2, "projektmonitoringu@gmail.com");
return system(v2);
}

original_code:
void sendVideo(char* path){
 char command[1024];
 command[0]=0;
 strcat(command,"echo \"Zaobserwowano ruch, nagranie w zalaczniku.\" | mutt -s \"nagranie z monitoringu\" -a ");
 strcat(command,path);
 strcat(command," -- ");
 strcat(command,"projektmonitoringu@gmail.com");
 system(command);
}

canonical_original_code:
void sendVideo(char *path){
 char command[1024];
 command[0]=0;
 strcat(command,"echo \"Zaobserwowano ruch, nagranie w zalaczniku.\" | mutt -s \"nagranie z monitoringu\" -a ");
 strcat(command,path);
 strcat(command," -- ");
 strcat(command,"projektmonitoringu@gmail.com");
 system(command);
}

variable_types:
path
char *

variable_types:
command
char [1024]


decompiled_code:
__off_t __fastcall file_sz(const char *a1)
{
__off_t result; // rax
struct stat v2; // [rsp+0h] [rbp-98h] BYREF

if ( stat(a1, &v2) == -1 )
result = -1LL;
else
result = v2.st_size;
return result;
}

canonical_decompiled_code:
__off_t __fastcall func0(const char *a1)
{
__off_t result; // rax
struct stat v2; // [rsp+0h] [rbp-98h] BYREF

if ( stat(a1, &v2) == -1 )
result = -1LL;
else
result = v2.st_size;
return result;
}

original_code:
off_t file_sz(char *fn)
{
  struct stat s;
  if (stat(fn, &s) == -1)
    return -1;
  return s.st_size;
}

canonical_original_code:
long file_sz(char *fn)
{
  struct stat s;
  if (stat(fn, &s) == -1)
    return -1;
  return s.st_size;
}

variable_types:
fn
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

return_type: long

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


decompiled_code:
__off_t __fastcall get_file_sz(_QWORD *a1)
{
_QWORD *v1; // rbx
__int64 v2; // rbp
__off_t v3; // rax
__off_t v4; // rdx

if ( !a1 )
return 0LL;
v1 = a1;
v2 = 0LL;
while ( 1 )
{
v3 = file_sz((const char *)(*v1 + 8LL));
v4 = v3;
if ( v3 == -1 )
break;
*(_DWORD *)*v1 = v3;
v2 += v3 + (4 - v3 % 4) % 4;
v1 = (_QWORD *)v1[1];
if ( !v1 )
return v2;
}
return v4;
}

canonical_decompiled_code:
__off_t __fastcall func1(_QWORD *a1)
{
_QWORD *v1; // rbx
__int64 v2; // rbp
__off_t v3; // rax
__off_t v4; // rdx

if ( !a1 )
return 0LL;
v1 = a1;
v2 = 0LL;
while ( 1 )
{
v3 = func0((const char *)(*v1 + 8LL));
v4 = v3;
if ( v3 == -1 )
break;
*(_DWORD *)*v1 = v3;
v2 += v3 + (4 - v3 % 4) % 4;
v1 = (_QWORD *)v1[1];
if ( !v1 )
return v2;
}
return v4;
}

original_code:
off_t get_file_sz(List *l)
{
  off_t tmp, ret = 0;
  for(; (l); l = l->next) {
    if((tmp = file_sz(((Jpeg_Data *)l->data)->name)) == -1)
      return -1;
    ((Jpeg_Data *)l->data)->size = (DWORD) tmp;
    tmp += ((4-(tmp%4)) % 4);
    ret += tmp;
  }
  return ret;
}

canonical_original_code:
long get_file_sz(struct _List *l)
{
  long tmp; long ret = 0;
  for(; (l); l = l->next) {
    if((tmp = file_sz(((struct _Jpeg_Data *)l->data)->name)) == -1)
      return -1;
    ((struct _Jpeg_Data *)l->data)->size = (unsigned int) tmp;
    tmp += ((4-(tmp%4)) % 4);
    ret += tmp;
  }
  return ret;
}

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

variable_types: tmp long

variable_types: ret long

user_defined_types: struct _Jpeg_Data { unsigned int size; unsigned int offset; char name[]; }


decompiled_code:
_QWORD *get_file_list_stdin()
{
_QWORD *v0; // r12
_QWORD *v1; // rbp
size_t v2; // rax
void *v3; // rbx
char v5[4120]; // [rsp+0h] [rbp-1018h] BYREF

v0 = malloc(0x18uLL);
*v0 = 0LL;
v0[2] = 0LL;
v0[1] = 0LL;
v1 = v0;
while ( (unsigned int)_isoc99_scanf(&unk_AEE, v5) == 1 )
{
v2 = strlen(v5);
v3 = malloc(v2 + 9);
*((_DWORD *)v3 + 1) = 0;
*(_DWORD *)v3 = 0;
strcpy((char *)v3 + 8, v5);
if ( *v1 )
v1 = (_QWORD *)list_push_back(v1, v3);
else
*v1 = v3;
}
return v0;
}

canonical_decompiled_code:
_QWORD *func2()
{
_QWORD *v0; // r12
_QWORD *v1; // rbp
size_t v2; // rax
void *v3; // rbx
char v5[4120]; // [rsp+0h] [rbp-1018h] BYREF

v0 = malloc(0x18uLL);
*v0 = 0LL;
v0[2] = 0LL;
v0[1] = 0LL;
v1 = v0;
while ( (unsigned int)_isoc99_scanf(&unk_AEE, v5) == 1 )
{
v2 = strlen(v5);
v3 = malloc(v2 + 9);
*((_DWORD *)v3 + 1) = 0;
*(_DWORD *)v3 = 0;
strcpy((char *)v3 + 8, v5);
if ( *v1 )
v1 = (_QWORD *)list_push_back(v1, v3);
else
*v1 = v3;
}
return v0;
}

original_code:
List *get_file_list_stdin(void)
{
  char fn[4096];
  Jpeg_Data *tmp;
  List *ret = (List *) malloc(sizeof(List)),
       *l = ret;
  ret->data = 0;
  ret->prev = 0;
  ret->next = 0;
  while (scanf("%s", fn) == 1) {
    tmp = (Jpeg_Data *) malloc(strlen(fn) + 1 + (sizeof(DWORD) * 2));
    tmp->offset = 0;
    tmp->size = 0;
    strcpy(tmp->name, fn);
    if (l->data == 0)
      l->data = tmp;
    else
      l = list_push_back(l, tmp);
  }
  return ret;
}

canonical_original_code:
struct _List *get_file_list_stdin()
{
  char fn[4096];
  struct _Jpeg_Data *tmp;
  struct _List *ret = (List *) malloc(sizeof(List)); struct _List *l = ret;
  ret->data = 0;
  ret->prev = 0;
  ret->next = 0;
  while (scanf("%s", fn) == 1) {
    tmp = (struct _Jpeg_Data *) malloc(strlen(fn) + 1 + (sizeof(DWORD) * 2));
    tmp->offset = 0;
    tmp->size = 0;
    strcpy(tmp->name, fn);
    if (l->data == 0)
      l->data = tmp;
    else
      l = list_push_back(l, tmp);
  }
  return ret;
}

variable_types:
fn
char [4096]

variable_types: struct _Jpeg_Data { unsigned int size; unsigned int offset; char name[]; } *

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


makeMovie

decompiled_code:
void __fastcall makeMovie(int a1, const char *a2, const char *a3, unsigned int a4)
{
int v4; // er14
char **v5; // rax
char **v6; // rbx
void **v7; // rbp
void **v8; // rbp
char s[120]; // [rsp+10h] [rbp-78h] BYREF

v4 = 2 * a1 + 4;
v5 = (char **)malloc(8LL * v4);
v6 = v5;
if ( v4 > 0 )
{
v7 = (void **)v5;
do
*v7++ = malloc(0x32uLL);
while ( v7 != (void **)&v6[v4] );
}
strcpy(*v6, "moviemaker");
sprintf(v6[1], "%d", a4);
sprintf(v6[2], "%d", 640LL);
sprintf(v6[3], "%d", 480LL);
if ( a1 > 0 )
{
while ( 1 )
{
sprintf(s, "%d", 0LL);
strcpy(v6[4], a2);
strcat(v6[4], s);
sprintf(s, "%d", 0LL);
strcpy(v6[5], a2);
strcat(v6[5], s);
}
}
makeMovieInside(v4, (__int64)v6, a3);
if ( v4 > 0 )
{
v8 = (void **)v6;
do
free(*v8++);
while ( v8 != (void **)&v6[v4] );
}
free(v6);
}

canonical_decompiled_code:
void __fastcall func6(int a1, const char *a2, const char *a3, unsigned int a4)
{
int v4; // er14
char **v5; // rax
char **v6; // rbx
void **v7; // rbp
void **v8; // rbp
char s[120]; // [rsp+10h] [rbp-78h] BYREF

v4 = 2 * a1 + 4;
v5 = (char **)malloc(8LL * v4);
v6 = v5;
if ( v4 > 0 )
{
v7 = (void **)v5;
do
*v7++ = malloc(0x32uLL);
while ( v7 != (void **)&v6[v4] );
}
strcpy(*v6, "moviemaker");
sprintf(v6[1], "%d", a4);
sprintf(v6[2], "%d", 640LL);
sprintf(v6[3], "%d", 480LL);
if ( a1 > 0 )
{
while ( 1 )
{
sprintf(s, "%d", 0LL);
strcpy(v6[4], a2);
strcat(v6[4], s);
sprintf(s, "%d", 0LL);
strcpy(v6[5], a2);
strcat(v6[5], s);
}
}
func5(v4, (__int64)v6, a3);
if ( v4 > 0 )
{
v8 = (void **)v6;
do
free(*v8++);
while ( v8 != (void **)&v6[v4] );
}
free(v6);
}

original_code:
void makeMovie(int amount, char* picturesPath, char* videoPath, int fps){
    char** photos = malloc(sizeof(char*)*((2*amount)+4));
    int i;
    for(i=0; i<(2*amount)+4; i++){
        photos[i] = malloc(50);
    }
    sprintf(photos[0], "moviemaker");
    sprintf(photos[1], "%d",fps);
    sprintf(photos[2], "%d", 640);
    sprintf(photos[3], "%d", 480);
    char tmp[50];
    for(i=4; i<amount+4;i=i++){
        sprintf(tmp, "%d", (i-4));
 int ind= (i-4)*2+4;
        strcpy(photos[ind], picturesPath);
        strcat(photos[ind], tmp);
 sprintf(tmp, "%d", (i-4));
        strcpy(photos[ind+1], picturesPath);
        strcat(photos[ind+1], tmp);
    }
    makeMovieInside(2*amount+4, photos, videoPath);
    for(i=0; i<2*amount+4; i++){
        free(photos[i]);
    }
    free(photos);
}

canonical_original_code:
void makeMovie(int amount, char *picturesPath, char *videoPath, int fps){
    char **photos = malloc(sizeof(char*)*((2*amount)+4));
    int i;
    for(i=0; i<(2*amount)+4; i++){
        photos[i] = malloc(50);
    }
    sprintf(photos[0], "moviemaker");
    sprintf(photos[1], "%d",fps);
    sprintf(photos[2], "%d", 640);
    sprintf(photos[3], "%d", 480);
    char tmp[50];
    for(i=4; i<amount+4;i=i++){
        sprintf(tmp, "%d", (i-4));
 int ind = (i-4)*2+4;
        strcpy(photos[ind], picturesPath);
        strcat(photos[ind], tmp);
 sprintf(tmp, "%d", (i-4));
        strcpy(photos[ind+1], picturesPath);
        strcat(photos[ind+1], tmp);
    }
    makeMovieInside(2*amount+4, photos, videoPath);
    for(i=0; i<2*amount+4; i++){
        free(photos[i]);
    }
    free(photos);
}

variable_types: amount int

variable_types:
picturesPath
char *

variable_types:
videoPath
char *

variable_types: fps int

variable_types:
photos
char **

variable_types: i int

variable_types:
tmp
char [50]

variable_types: ind int


delBitBuffer

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

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

original_code:
void delBitBuffer(BitBuffer* self)
{
 free(self);
}

canonical_original_code:
void delBitBuffer(struct BitBuffer *self)
{
 free(self);
}

variable_types: struct BitBuffer { unsigned char *_buffer; unsigned char *_insert; unsigned int _length; unsigned char _preBuffer; unsigned char _preLength; void (*put)(struct BitBuffer *self, int data, unsigned char bitsNum); void (*flush)(struct BitBuffer *self); void (*rawPut)(struct BitBuffer *self, unsigned char bit); void (*rawWrite)(struct BitBuffer *self, void *data, unsigned int size, unsigned int count); void (*calcBits)(struct BitBuffer *self, int value, unsigned short bits[2]); } *


delDibHeader

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

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

original_code:
void delDibHeader(DibHeader* header)
{
 free(header);
}

canonical_original_code:
void delDibHeader(struct structure_DibHeader *header)
{
 free(header);
}

variable_types: struct structure_DibHeader { unsigned int rawDataOffset; unsigned int rawDataSize; unsigned int rawRowSize; unsigned int rowSize; unsigned int rowPadding; unsigned int imageWidth; unsigned int imageHeight; unsigned short bitsPerPixel; } *


delBitmap

decompiled_code:
void __fastcall delBitmap(void *ptr)
{
unsigned int v1; // ebx

if ( *(_DWORD *)(*(_QWORD *)ptr + 24LL) )
{
v1 = 0;
do
free(*(void **)(*((_QWORD *)ptr + 1) + 8LL * v1++));
while ( *(_DWORD *)(*(_QWORD *)ptr + 24LL) > v1 );
}
free(*((void **)ptr + 1));
delDibHeader(*(_QWORD *)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
unsigned int v1; // ebx

if ( *(_DWORD *)(*(_QWORD *)ptr + 24LL) )
{
v1 = 0;
do
free(*(void **)(*((_QWORD *)ptr + 1) + 8LL * v1++));
while ( *(_DWORD *)(*(_QWORD *)ptr + 24LL) > v1 );
}
free(*((void **)ptr + 1));
delDibHeader(*(_QWORD *)ptr);
free(ptr);
}

original_code:
void delBitmap(Bitmap* bmp)
{
 uint32_t row, col;
 for(row = 0; row < bmp->header->imageHeight; ++row)
  free(bmp->data[row]);
 free(bmp->data);
 delDibHeader(bmp->header);
 free(bmp);
}

canonical_original_code:
void delBitmap(struct struct_Bitmap *bmp)
{
 unsigned int row; unsigned int col;
 for(row = 0; row < bmp->header->imageHeight; ++row)
  free(bmp->data[row]);
 free(bmp->data);
 delDibHeader(bmp->header);
 free(bmp);
}

variable_types: struct struct_Bitmap { struct structure_DibHeader { unsigned int rawDataOffset; unsigned int rawDataSize; unsigned int rawRowSize; unsigned int rowSize; unsigned int rowPadding; unsigned int imageWidth; unsigned int imageHeight; unsigned short bitsPerPixel; } *header; struct struct_Pixel { unsigned char r; unsigned char g; unsigned char b; } **data; } *

variable_types:
row
unsigned int

variable_types:
col
unsigned int

user_defined_types: struct struct_Bitmap { struct structure_DibHeader *header; struct struct_Pixel **data; }


delPixel

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

original_code:
void delPixel(Pixel* pixel)
{
 free(pixel);
}

canonical_original_code:
void delPixel(struct struct_Pixel *pixel)
{
 free(pixel);
}

variable_types: struct struct_Pixel { unsigned char r; unsigned char g; unsigned char b; } *


repo: xrash/color

decompiled_code:
__int64 __fastcall color2code(__int64 a1, int a2, const char *a3)
{
__int64 v4; // rbx

if ( !a3 )
return 0LL;
if ( !a1 )
return 0LL;
if ( a2 <= 0 )
return 0LL;
v4 = 0LL;
while ( strcmp(*(const char **)(a1 + 8 * v4), a3) )
{
v4 += 2LL;
if ( v4 == 2LL * (((unsigned int)(a2 - 1) >> 1) + 1) )
return 0LL;
}
return *(_QWORD *)(a1 + 8 * v4 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2, const char *a3)
{
__int64 v4; // rbx

if ( !a3 )
return 0LL;
if ( !a1 )
return 0LL;
if ( a2 <= 0 )
return 0LL;
v4 = 0LL;
while ( strcmp(*(const char **)(a1 + 8 * v4), a3) )
{
v4 += 2LL;
if ( v4 == 2LL * (((unsigned int)(a2 - 1) >> 1) + 1) )
return 0LL;
}
return *(_QWORD *)(a1 + 8 * v4 + 8);
}

original_code:
char* color2code(char *array[], int len, char* color) {
 int i;
 if (color == ((void *)0) || array == ((void *)0)) {
  return ((void *)0);
 }
 for (i = 0; i < len; i = i + 2) {
  if (strcmp(array[i], color) == 0) {
   return array[i+1];
  }
 }
 return ((void *)0);
}

canonical_original_code:
char *color2code(char *array[], int len, char *color) {
 int i;
 if (color == ((void *)0) || array == ((void *)0)) {
  return ((void *)0);
 }
 for (i = 0; i < len; i = i + 2) {
  if (strcmp(array[i], color) == 0) {
   return array[i+1];
  }
 }
 return ((void *)0);
}

variable_types:
array
char *[]

variable_types: len int

variable_types:
color
char *

return_type: char *


decompiled_code:
__int64 __fastcall fg2code(const char *a1)
{
return color2code((__int64)&FG_COLORS, FG_COLORS_LEN, a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
return func0((__int64)&FG_COLORS, FG_COLORS_LEN, a1);
}

original_code:
char* fg2code(char* color) {
 return color2code(FG_COLORS, FG_COLORS_LEN, color);
}

canonical_original_code:
char *fg2code(char *color) {
 return color2code(FG_COLORS, FG_COLORS_LEN, color);
}


decompiled_code:
__int64 __fastcall bg2code(const char *a1)
{
return color2code((__int64)BG_COLORS, BG_COLORS_LEN, a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1)
{
return func0((__int64)BG_COLORS, BG_COLORS_LEN, a1);
}

original_code:
char* bg2code(char* color) {
 return color2code(BG_COLORS, BG_COLORS_LEN, color);
}

canonical_original_code:
char *bg2code(char *color) {
 return color2code(BG_COLORS, BG_COLORS_LEN, color);
}


decompiled_code:
size_t __fastcall print_buffer(char *a1, int a2, const char **a3)
{
const char *v5; // rdi
char *v6; // rbp

fputs(*a3, stdout);
v5 = a3[1];
if ( v5 )
fputs(v5, stdout);
if ( a2 > 0 )
{
v6 = &a1[a2];
do
fputc(*a1++, stdout);
while ( a1 != v6 );
}
return fwrite("\x1B[0m", 1uLL, 4uLL, stdout);
}

canonical_decompiled_code:
size_t __fastcall func0(char *a1, int a2, const char **a3)
{
const char *v5; // rdi
char *v6; // rbp

fputs(*a3, stdout);
v5 = a3[1];
if ( v5 )
fputs(v5, stdout);
if ( a2 > 0 )
{
v6 = &a1[a2];
do
fputc(*a1++, stdout);
while ( a1 != v6 );
}
return fwrite("\x1B[0m", 1uLL, 4uLL, stdout);
}

original_code:
void print_buffer(char* buffer, int size, color* color) {
 fputs(color->foreground, stdout);
 if (color->background != ((void *)0)) {
  fputs(color->background, stdout);
 }
 while (size-- > 0) {
  fputc(*buffer++, stdout);
 }
 fputs("\x1b[0m", stdout);
}

canonical_original_code:
void print_buffer(char *buffer, int size, struct _color *color) {
 fputs(color->foreground, stdout);
 if (color->background != ((void *)0)) {
  fputs(color->background, stdout);
 }
 while (size-- > 0) {
  fputc(*buffer++, stdout);
 }
 fputs("\x1b[0m", stdout);
}

variable_types:
buffer
char *

variable_types: size int

variable_types: struct _color { char *foreground; char *background; } *


original_code:
void print_colored_buffer(char* buffer, list* matches) {
 int bufferlen = strlen(buffer);
 char** start;
 char** end;
 o_match* m = ((void *)0);
 list_node* n = ((void *)0);
 int len = 0;
 int c = 0;
 int i = 0;
 int j = 0;
 start = malloc(sizeof(char*) * (bufferlen + 1));
 end = malloc(sizeof(char*) * (bufferlen + 1));
 memset(start, 0, sizeof(char*) * (bufferlen + 1));
 memset(end, 0, sizeof(char*) * (bufferlen + 1));
 n = matches->head;
 while ((n = n->next) != ((void *)0)) {
  m = n->element;
  if (start[m->start] != ((void *)0) || end[m->end] != ((void *)0)) {
   continue;
  }
  for (j = m->start + 1; j < m->end; j++) {
   if (start[j] != ((void *)0) || end[j] != ((void *)0)) {
    break;
   }
  }
  if (j != m->end) {
   continue;
  }
  len = strlen(m->color->foreground);
  if (m->color->background != ((void *)0)) {
   len += strlen(m->color->background);
  }
  start[m->start] = malloc(len + 1);
  memset(start[m->start], 0, len + 1);
  strcat(start[m->start], m->color->foreground);
  if (m->color->background != ((void *)0)) {
   strcat(start[m->start], m->color->background);
  }
  end[m->end] = malloc(strlen("\x1b[0m") + 1);
  strcpy(end[m->end], "\x1b[0m");
 }
 while ((c = *buffer++) != '\0') {
  if (end[i] != ((void *)0)) {
   fputs(end[i], stdout);
  }
  if (start[i] != ((void *)0)) {
   fputs(start[i], stdout);
  }
  i++;
  fputc(c, stdout);
 }
 if (end[i] != ((void *)0)) {
  fputs(end[i], stdout);
 }
 if (start[i] != ((void *)0)) {
  fputs(start[i], stdout);
 }
}

canonical_original_code:
void print_colored_buffer(char *buffer, struct list *matches) {
 int bufferlen = strlen(buffer);
 char **start;
 char **end;
 struct o_match *m = ((void *)0);
 struct list_node_ *n = ((void *)0);
 int len = 0;
 int c = 0;
 int i = 0;
 int j = 0;
 start = malloc(sizeof(char *) * (bufferlen + 1));
 end = malloc(sizeof(char *) * (bufferlen + 1));
 memset(start, 0, sizeof(char *) * (bufferlen + 1));
 memset(end, 0, sizeof(char *) * (bufferlen + 1));
 n = matches->head;
 while ((n = n->next) != ((void *)0)) {
  m = n->element;
  if (start[m->start] != ((void *)0) || end[m->end] != ((void *)0)) {
   continue;
  }
  for (j = m->start + 1; j < m->end; j++) {
   if (start[j] != ((void *)0) || end[j] != ((void *)0)) {
    break;
   }
  }
  if (j != m->end) {
   continue;
  }
  len = strlen(m->color->foreground);
  if (m->color->background != ((void *)0)) {
   len += strlen(m->color->background);
  }
  start[m->start] = malloc(len + 1);
  memset(start[m->start], 0, len + 1);
  strcat(start[m->start], m->color->foreground);
  if (m->color->background != ((void *)0)) {
   strcat(start[m->start], m->color->background);
  }
  end[m->end] = malloc(strlen("\x1b[0m") + 1);
  strcpy(end[m->end], "\x1b[0m");
 }
 while ((c = *buffer++) != '\0') {
  if (end[i] != ((void *)0)) {
   fputs(end[i], stdout);
  }
  if (start[i] != ((void *)0)) {
   fputs(start[i], stdout);
  }
  i++;
  fputc(c, stdout);
 }
 if (end[i] != ((void *)0)) {
  fputs(end[i], stdout);
 }
 if (start[i] != ((void *)0)) {
  fputs(start[i], stdout);
 }
}

variable_types: struct list { struct list_node_ { void *element; struct list_node_ *next; } *head; struct list_node_ *tail; int length; } *

variable_types: bufferlen int

variable_types:
start
char **

variable_types:
end
char **

variable_types: struct o_match { int start; int end; struct _color { char *foreground; char *background; } *color; char *string; } *

variable_types: c int

variable_types: j int

user_defined_types: struct list { struct list_node_ *head; struct list_node_ *tail; int length; }

user_defined_types: struct o_match { int start; int end; struct _color *color; char *string; }


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

v0 = malloc(0x18uLL);
*v0 = list_node_new(0LL);
v0[1] = list_node_new(0LL);
*((_DWORD *)v0 + 4) = 0;
return v0;
}

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

v0 = malloc(0x18uLL);
*v0 = list_node_new(0LL);
v0[1] = list_node_new(0LL);
*((_DWORD *)v0 + 4) = 0;
return v0;
}

original_code:
list* list_new() {
 list* l = malloc(sizeof(list));
 l->head = list_node_new(((void *)0));
 l->tail = list_node_new(((void *)0));
 l->length = 0;
 return l;
}

canonical_original_code:
struct list *list_new() {
 struct list *l = malloc(sizeof(list));
 l->head = list_node_new(((void *)0));
 l->tail = list_node_new(((void *)0));
 l->length = 0;
 return l;
}

return_type: struct list { struct list_node_ { void *element; struct list_node_ *next; } *head; struct list_node_ *tail; int length; } *


original_code:
int list_add(list* l, void* e) {
 list_node* n = list_node_new(e);
 if (l == ((void *)0) || e == ((void *)0)) {
  return 0;
 }
 if (n != ((void *)0)) {
  if (l->head->next == ((void *)0)) {
   l->head->next = n;
  }
  if (l->tail != ((void *)0)) {
   l->tail->next = n;
  }
  l->tail = n;
  l->length++;
  return 1;
 }
 return 0;
}

canonical_original_code:
int list_add(struct list *l, void *e) {
 struct list_node_ *n = list_node_new(e);
 if (l == ((void *)0) || e == ((void *)0)) {
  return 0;
 }
 if (n != ((void *)0)) {
  if (l->head->next == ((void *)0)) {
   l->head->next = n;
  }
  if (l->tail != ((void *)0)) {
   l->tail->next = n;
  }
  l->tail = n;
  l->length++;
  return 1;
 }
 return 0;
}

variable_types:
e
void *

variable_types: struct list_node_ { void *element; struct list_node_ *next; } *

return_type: int


decompiled_code:
int __fastcall list_print(__int64 *a1)
{
__int64 v1; // rax
__int64 i; // rbx

v1 = *a1;
for ( i = *(_QWORD *)(*a1 + 8); i; i = *(_QWORD *)(i + 8) )
LODWORD(v1) = printf("list_print: %p\n", *(const void **)i);
return v1;
}

canonical_decompiled_code:
int __fastcall func2(__int64 *a1)
{
__int64 v1; // rax
__int64 i; // rbx

v1 = *a1;
for ( i = *(_QWORD *)(*a1 + 8); i; i = *(_QWORD *)(i + 8) )
LODWORD(v1) = printf("list_print: %p\n", *(const void **)i);
return v1;
}

original_code:
void list_print(list* l) {
 list_node* n = l->head;
 while ((n = n->next) != ((void *)0)) {
  printf("list_print: %p\n", n->element);
 }
}

canonical_original_code:
void list_print(struct list *l) {
 struct list_node_ *n = l->head;
 while ((n = n->next) != ((void *)0)) {
  printf("list_print: %p\n", n->element);
 }
}

user_defined_types: struct list_node_ { void *element; struct list_node_ *next; }


help

decompiled_code:
void __noreturn help()
{
puts("Usage:\n color [-h] [-f <filename>] [-c <foreground[/<background>]>...] <pattern...>\n");
puts(
"Description:\n"
" color reads stdin and output a colorized version applying specified colors to every regular expression <pattern."
"..> matched.\n"
" Patterns and colors are matched by order of declaration: if you declare two colors and then two patterns, the fi"
"rst color matches the first pattern and so on. If you declare less colors than patterns, the last color will repeat."
" See Examples for more information.\n");
puts(
"Options:\n"
" -h\n"
" Print this message and exit.\n"
" -f <filename>\n"
" Read <filename> instead of stdin.\n"
" -c <foreground>[/<background>]\n"
" Specify the foreground and background colors. Background is optional. See Supported colors and Examples for "
"more information.");
puts(
" -m <mode>\n"
" Supported modes are \"char\" and \"line\". Default is line.\n"
" Line mode executes every pattern line by line.\n"
" Char mode advances the text from left to right executing every pattern each character.\n"
" Nested matches are NOT supported by any of the two modes. They will be ignored. First matches have priority.\n");
puts(
"Supported colors:\n"
" Foreground:\n"
" black red green brown\n"
" blue purple cyan light-gray\n"
" dark-gray light-red light-green yellow\n"
" light-blue light-purple light-cyan white\n"
" Background:\n"
" black red green brown\n"
" blue purple cyan light-gray\n");
puts(
"Examples:\n"
" echo \"Hello, world\" | color world\n"
" echo \"Hello, world\" | color -c green world\n"
" echo \"Hello, world\" | color -c blue/green world\n"
" echo \"Hello, world\" | color -c green Hello world\n"
" echo \"Hello, world\" | color -c red/light-gray -c green Hello world\n"
" color -f /path/to/file -c red WARNING");
puts(
" color -m char \\\n"
" 'if(?= ?\\()' -c cyan \\\n"
" 'true|false' -c cyan \\\n"
" '\\(|\\)' -c yellow \\\n"
" 'then|else' -c green \\\n"
" '\".*\"' -c red \\\n"
" <<EOF\n"
" if (true) then \"if (\" else false\n"
" EOF\n");
exit(0);
}

canonical_decompiled_code:
void __noreturn func0()
{
puts("Usage:\n color [-h] [-f <filename>] [-c <foreground[/<background>]>...] <pattern...>\n");
puts(
"Description:\n"
" color reads stdin and output a colorized version applying specified colors to every regular expression <pattern."
"..> matched.\n"
" Patterns and colors are matched by order of declaration: if you declare two colors and then two patterns, the fi"
"rst color matches the first pattern and so on. If you declare less colors than patterns, the last color will repeat."
" See Examples for more information.\n");
puts(
"Options:\n"
" -h\n"
" Print this message and exit.\n"
" -f <filename>\n"
" Read <filename> instead of stdin.\n"
" -c <foreground>[/<background>]\n"
" Specify the foreground and background colors. Background is optional. See Supported colors and Examples for "
"more information.");
puts(
" -m <mode>\n"
" Supported modes are \"char\" and \"line\". Default is line.\n"
" Line mode executes every pattern line by line.\n"
" Char mode advances the text from left to right executing every pattern each character.\n"
" Nested matches are NOT supported by any of the two modes. They will be ignored. First matches have priority.\n");
puts(
"Supported colors:\n"
" Foreground:\n"
" black red green brown\n"
" blue purple cyan light-gray\n"
" dark-gray light-red light-green yellow\n"
" light-blue light-purple light-cyan white\n"
" Background:\n"
" black red green brown\n"
" blue purple cyan light-gray\n");
puts(
"Examples:\n"
" echo \"Hello, world\" | color world\n"
" echo \"Hello, world\" | color -c green world\n"
" echo \"Hello, world\" | color -c blue/green world\n"
" echo \"Hello, world\" | color -c green Hello world\n"
" echo \"Hello, world\" | color -c red/light-gray -c green Hello world\n"
" color -f /path/to/file -c red WARNING");
puts(
" color -m char \\\n"
" 'if(?= ?\\()' -c cyan \\\n"
" 'true|false' -c cyan \\\n"
" '\\(|\\)' -c yellow \\\n"
" 'then|else' -c green \\\n"
" '\".*\"' -c red \\\n"
" <<EOF\n"
" if (true) then \"if (\" else false\n"
" EOF\n");
exit(0);
}

original_code:
void help() {
 printf(
"Usage:\n"
"    color [-h] [-f <filename>] [-c <foreground[/<background>]>...] <pattern...>\n"
"\n");
 printf(
"Description:\n"
"    color reads stdin and output a colorized version applying specified colors to every regular expression <pattern...> matched.\n"
"    Patterns and colors are matched by order of declaration: if you declare two colors and then two patterns, the first color matches the first pattern and so on. If you declare less colors than patterns, the last color will repeat. See Examples for more information.\n"
"\n");
 printf(
"Options:\n"
"    -h\n"
"        Print this message and exit.\n"
"    -f <filename>\n"
"        Read <filename> instead of stdin.\n"
"    -c <foreground>[/<background>]\n"
"        Specify the foreground and background colors. Background is optional. See Supported colors and Examples for more information.\n"
  );
 printf(
"    -m <mode>\n"
"        Supported modes are \"char\" and \"line\". Default is line.\n"
"        Line mode executes every pattern line by line.\n"
"        Char mode advances the text from left to right executing every pattern each character.\n"
"        Nested matches are NOT supported by any of the two modes. They will be ignored. First matches have priority.\n"
"\n");
 printf(
"Supported colors:\n"
"    Foreground:\n"
"        black         red          green         brown\n"
"        blue          purple       cyan          light-gray\n"
"        dark-gray     light-red    light-green   yellow\n"
"        light-blue    light-purple light-cyan    white\n"
"    Background:\n"
"        black         red          green         brown\n"
"        blue          purple       cyan          light-gray\n"
"\n"
);
 printf(
"Examples:\n"
"    echo \"Hello, world\" | color world\n"
"    echo \"Hello, world\" | color -c green world\n"
"    echo \"Hello, world\" | color -c blue/green world\n"
"    echo \"Hello, world\" | color -c green Hello world\n"
"    echo \"Hello, world\" | color -c red/light-gray -c green Hello world\n"
"    color -f /path/to/file -c red WARNING\n"
  );
 printf(
"    color -m char \\\n"
"        'if(?= ?\\()' -c cyan \\\n"
"        'true|false' -c cyan \\\n"
"        '\\(|\\)' -c yellow \\\n"
"        'then|else' -c green \\\n"
"        '\".*\"' -c red \\\n"
"    <<EOF\n"
"    if (true) then \"if (\" else false\n"
"    EOF\n"
"\n"
);
 exit(0);
}


yyerror

repo: xtaci/ssh-kvr

decompiled_code:
int __fastcall yyerror(const char *a1)
{
return fprintf(stderr, "error: %s\n", a1);
}

canonical_decompiled_code:
int __fastcall func4(const char *a1)
{
return fprintf(stderr, "error: %s\n", a1);
}

original_code:
void yyerror(const char *str)
{
        fprintf(stderr,"error: %s\n",str);
}

canonical_original_code:
void yyerror(char *str)
{
        fprintf(stderr,"error: %s\n",str);
}

variable_types:
str
char *


yyparse

decompiled_code:
__int64 yyparse()
{
int v0; // ebp
unsigned __int64 v1; // r14
char *v2; // r12
__int16 *v3; // rbx
__int16 *v4; // r13
int v5; // edx
unsigned int v6; // er15
__int16 *v7; // rcx
int v8; // er15
int v9; // edx
unsigned __int8 v10; // bp
int v11; // eax
unsigned int v12; // edx
unsigned __int64 v13; // rax
signed __int64 v14; // r12
__int16 *v15; // rax
__int16 *v16; // r15
int v17; // er15
unsigned __int8 v18; // al
__int16 *v19; // rax
unsigned int v20; // ebp
int v21; // eax
unsigned int v22; // eax
int v24; // [rsp+Ch] [rbp-50Ch]
char *v25; // [rsp+10h] [rbp-508h]
__int64 v26; // [rsp+18h] [rbp-500h]
unsigned int v27; // [rsp+18h] [rbp-500h]
unsigned int v28; // [rsp+20h] [rbp-4F8h]
char *v29; // [rsp+28h] [rbp-4F0h]
char v30[800]; // [rsp+30h] [rbp-4E8h] BYREF
__int16 src[228]; // [rsp+350h] [rbp-1C8h] BYREF

yynerrs = 0;
yychar = -2;
src[0] = 0;
v24 = 0;
v0 = 0;
v1 = 200LL;
v2 = v30;
v25 = v30;
v3 = src;
v4 = src;
while ( 1 )
{
v17 = yypact[v0];
if ( v17 == -2 )
break;
if ( yychar == -2 )
yychar = yylex();
if ( yychar <= 0 )
{
yychar = 0;
v5 = 0;
}
else
{
v5 = 2;
if ( (unsigned int)yychar <= 0x109 )
v5 = (unsigned __int8)yytranslate[yychar];
}
v6 = v5 + v17;
if ( v6 > 0xF || yycheck[v6] != v5 )
break;
v0 = (unsigned __int8)yytable[v6];
if ( yytable[v6] )
{
v24 = (v24 == 0) + v24 - 1;
yychar = -2;
*((_DWORD *)v2 + 1) = yylval;
v2 += 4;
v7 = v3;
goto LABEL_11;
}
v8 = *((_DWORD *)v2 + 1);
v9 = 0;
v10 = 0;
LABEL_8:
v7 = &v3[-v10];
v2 = &v2[-4 * v10 + 4];
*(_DWORD *)v2 = v8;
v11 = (unsigned __int8)yyr1[v9] - 11;
v12 = *v7 + yypgoto[v11];
if ( v12 <= 0xF && *v7 == yycheck[v12] )
v0 = (unsigned __int8)yytable[v12];
else
v0 = yydefgoto[v11];
LABEL_11:
v3 = v7 + 1;
v7[1] = v0;
v13 = 2 * v1;
if ( v7 + 1 >= &v4[v1 - 1] )
{
v14 = (char *)v3 - (char *)v4;
v26 = v3 - v4 + 1;
if ( v1 > 0x270F )
goto LABEL_51;
v1 = 10000LL;
if ( v13 <= 0x2710 )
v1 = v13;
v15 = (__int16 *)malloc(6 * v1 + 3);
v16 = v15;
if ( !v15 )
{
LABEL_51:
yyerror("memory exhausted");
v19 = v3;
v3 = v4;
v20 = 2;
goto LABEL_53;
}
memcpy(v15, v4, v14 + 2);
v29 = (char *)&v16[v1];
memcpy(v29, v25, 4 * v26);
if ( v4 != src )
free(v4);
v3 = (__int16 *)((char *)v16 + v14);
v2 = &v29[4 * v26 - 4];
if ( v3 >= &v16[v1 - 1] )
{
if ( v16 == v3 )
{
v3 = v16;
v20 = 1;
goto LABEL_56;
}
v19 = v3;
v3 = v16;
v20 = 1;
goto LABEL_54;
}
v25 = v29;
v4 = v16;
}
if ( v0 == 2 )
{
v19 = v3;
v3 = v4;
v20 = 0;
goto LABEL_53;
}
}
v18 = yydefact[v0];
v9 = v18;
if ( v18 )
{
v10 = yyr2[v18];
v8 = *(_DWORD *)&v2[4 * (1 - v10)];
switch ( v18 )
{
case 9u:
prompt();
v9 = 9;
break;
case 0xAu:
v24 = 0;
break;
case 0xBu:
puts("Commands:");
puts("define node:\t node01=192.168.0.xx");
puts("switch to node:\t node01");
puts("list nodes:\t nodes");
prompt();
v9 = 11;
break;
case 0xCu:
puts("list nodes");
prompt();
v9 = 12;
break;
case 0xDu:
printf("send commands only to %s\n", (const char *)*(unsigned int *)v2);
prompt();
v9 = 13;
break;
case 0xEu:
puts("send commands to all nodes");
prompt();
v9 = 14;
break;
case 0xFu:
v27 = *(_DWORD *)v2;
v28 = *((_DWORD *)v2 - 2);
node_add((__int64)&mylist, (int)v28, *(int *)v2);
printf("%s --> %s \tOK!\n", (const char *)v28, (const char *)v27);
prompt();
v9 = 15;
break;
default:
goto LABEL_8;
}
goto LABEL_8;
}
if ( !v24 )
{
++yynerrs;
yyerror("syntax error");
goto LABEL_46;
}
if ( v24 == 3 )
{
if ( yychar > 0 )
{
yychar = -2;
goto LABEL_46;
}
if ( !yychar )
{
v19 = v3;
v3 = v4;
v20 = 1;
LABEL_53:
if ( v19 == v3 )
goto LABEL_55;
do
LABEL_54:
--v19;
while ( v19 != v3 );
goto LABEL_55;
}
}
while ( 1 )
{
LABEL_46:
v21 = yypact[v0];
if ( v21 != -2 )
{
v22 = v21 + 1;
if ( v22 <= 0xF && yycheck[v22] == 1 )
{
v0 = (unsigned __int8)yytable[v22];
if ( yytable[v22] )
{
*((_DWORD *)v2 + 1) = yylval;
v2 += 4;
v7 = v3;
v24 = 3;
goto LABEL_11;
}
}
}
if ( v3 == v4 )
break;
v2 -= 4;
v0 = *--v3;
}
v20 = 1;
LABEL_55:
if ( v3 == src )
return v20;
LABEL_56:
free(v3);
return v20;
}

original_code:
int
yyparse (void)
{
    int yystate;
    int yyerrstatus;
    yytype_int16 yyssa[200];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;
    YYSTYPE yyvsa[200];
    YYSTYPE *yyvs;
    YYSTYPE *yyvsp;
    long unsigned int yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (yytype_int16) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      long unsigned int yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 2)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-2))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned) (yychar) <= 265 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 15 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 9:
    { prompt(); }
    break;
  case 10:
    { (yyerrstatus = 0);}
    break;
  case 11:
    {
 printf("Commands:\n");
 printf("define node:\t node01=192.168.0.xx\n");
 printf("switch to node:\t node01\n");
 printf("list nodes:\t nodes\n");
 prompt();
}
    break;
  case 12:
    {
 printf("list nodes\n");
 prompt();
}
    break;
  case 13:
    {
 printf("send commands only to %s\n", yyvsp[0]);
 prompt();
}
    break;
  case 14:
    {
 printf("send commands to all nodes\n");
 prompt();
}
    break;
  case 15:
    {
 node_add(&mylist, yyvsp[-2], yyvsp[0]);
 printf("%s --> %s \tOK!\n",yyvsp[-2],yyvsp[0]);
 prompt();
}
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    const int yylhs = yyr1[yyn] - 11;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 15 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned) (yychar) <= 265 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-2))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 15 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned) (yychar) <= 265 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

canonical_original_code:
int yyparse()
{
    int yystate;
    int yyerrstatus;
    short yyssa[200];
    short *yyss;
    short *yyssp;
    int yyvsa[200];
    int *yyvs;
    int *yyvsp;
    unsigned long yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  int yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (short) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      unsigned long yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        short *yyss1 = yyss;
        union yyalloc *yyptr = (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 2)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-2))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned int) (yychar) <= 265 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 15 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 9:
    { prompt(); }
    break;
  case 10:
    { (yyerrstatus = 0);}
    break;
  case 11:
    {
 printf("Commands:\n");
 printf("define node:\t node01=192.168.0.xx\n");
 printf("switch to node:\t node01\n");
 printf("list nodes:\t nodes\n");
 prompt();
}
    break;
  case 12:
    {
 printf("list nodes\n");
 prompt();
}
    break;
  case 13:
    {
 printf("send commands only to %s\n", yyvsp[0]);
 prompt();
}
    break;
  case 14:
    {
 printf("send commands to all nodes\n");
 prompt();
}
    break;
  case 15:
    {
 node_add(&mylist, yyvsp[-2], yyvsp[0]);
 printf("%s --> %s \tOK!\n",yyvsp[-2],yyvsp[0]);
 prompt();
}
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    int yylhs = yyr1[yyn] - 11;
    int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 15 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned int) (yychar) <= 265 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-2))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 15 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned int) (yychar) <= 265 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

variable_types: yystate int

variable_types: yyerrstatus int

variable_types:
yyssa
short [200]

variable_types:
yyss
short *

variable_types:
yyssp
short *

variable_types:
yyvsa
int [200]

variable_types:
yyvs
int *

variable_types:
yyvsp
int *

variable_types:
yystacksize
unsigned long

variable_types: yyn int

variable_types: yyresult int

variable_types: yytoken int

variable_types: yyval int

variable_types: yylen int

variable_types:
yysize
unsigned long

variable_types: union yyalloc { short yyss_alloc; int yyvs_alloc; } *

variable_types:
yynewbytes
unsigned long

variable_types: yylhs int

variable_types: yyi int


decompiled_code:
void __fastcall app_timer_unregister(int a1)
{
void **v1; // rbx
void **v2; // rax

v2 = (void **)timer_list;
if ( timer_list != &timer_list )
{
do
{
v1 = v2 - 9;
if ( *((_DWORD *)v2 - 13) == a1 )
break;
v2 = (void **)*v2;
}
while ( v2 != &timer_list );
}
printf(&format, *((unsigned int *)v1 + 5));
list_del((__int64)(v1 + 9));
*v1 = 0LL;
v1[1] = 0LL;
v1[3] = 0LL;
v1[4] = 0LL;
v1[5] = 0LL;
v1[6] = 0LL;
*((_DWORD *)v1 + 4) = 0;
v1[7] = 0LL;
v1[8] = 0LL;
*((_DWORD *)v1 + 5) = 0;
}

original_code:
void app_timer_unregister(unsigned int clientreg)
{
    struct app_timer *sa_ptr;
 struct list_head *pos;
 for (pos = (&timer_list)->next; pos != (&timer_list); pos = pos->next){
  sa_ptr = ((struct app_timer *)((char *)(pos)-(unsigned long)(&((struct app_timer *)0)->list)));
  if(sa_ptr->clientreg == clientreg)
   break;
 }
    if(sa_ptr != ((void *)0)) {
        printf("注销定时器 %d 号\n", sa_ptr->clientreg);
  list_del(&sa_ptr->list);
  (sa_ptr)->t.tv_sec = 0;
  (sa_ptr)->t.tv_usec = 0;
  (sa_ptr)->t_last.tv_sec = 0;
  (sa_ptr)->t_last.tv_usec = 0;
  (sa_ptr)->t_next.tv_sec = 0;
  (sa_ptr)->t_next.tv_usec = 0;
  (sa_ptr)->flags = 0;
  (sa_ptr)->clientarg = ((void *)0);
  (sa_ptr)->thecallback = ((void *)0);
  (sa_ptr)->clientreg = 0;
    }
    else {
    }
}

variable_types:
clientreg
unsigned int

variable_types: struct app_timer { struct timeval { long tv_sec; long tv_usec; } t; unsigned int flags; unsigned int clientreg; struct timeval t_last; struct timeval t_next; void *clientarg; void (*thecallback)(unsigned int clientreg, void *clientarg); struct list_head { struct list_head *next; } list; } *

variable_types: struct list_head { struct list_head *next; } *

user_defined_types: struct app_timer { struct timeval t; unsigned int flags; unsigned int clientreg; struct timeval t_last; struct timeval t_next; void *clientarg; void (*thecallback)(unsigned int clientreg, void *clientarg); struct list_head list; }


original_code:
void update_timer(struct app_timer *a)
{
    if(a->t_last.tv_sec == 0 && a->t_last.tv_usec == 0) {
        struct timeval t_now;
        gettimeofday(&t_now, ((void *)0));
        a->t_last.tv_sec = t_now.tv_sec;
        a->t_last.tv_usec = t_now.tv_usec;
        a->t_next.tv_sec = t_now.tv_sec + a->t.tv_sec;
        a->t_next.tv_usec = t_now.tv_usec + a->t.tv_usec;
        while(a->t_next.tv_usec >= 1000000) {
            a->t_next.tv_usec -= 1000000;
            a->t_next.tv_sec += 1;
        }
    }
    else if(a->t_next.tv_sec == 0 && a->t_next.tv_usec == 0) {
        if(a->flags & 0x01) {
            if(a->t.tv_sec == 0 && a->t.tv_usec == 0) {
                app_timer_unregister(a->clientreg);
                return;
            }
            a->t_next.tv_sec = a->t_last.tv_sec + a->t.tv_sec;
            a->t_next.tv_usec = a->t_last.tv_usec + a->t.tv_usec;
            while(a->t_next.tv_usec >= 1000000) {
                a->t_next.tv_usec -= 1000000;
                a->t_next.tv_sec += 1;
            }
        }
        else {
            app_timer_unregister(a->clientreg);
        }
    }
}

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

user_defined_types: struct list_head { struct list_head *next; }


decompiled_code:
void **find_next_timer()
{
void **v0; // rax
void **v1; // rdx
void *v3; // rsi
void *v4; // rcx

v0 = (void **)timer_list;
v1 = (void **)((char *)timer_list - 72);
if ( timer_list == &timer_list )
return 0LL;
while ( 1 )
{
v0 = (void **)*v0;
if ( v0 == &timer_list )
break;
if ( v1 )
{
v3 = *(v0 - 4);
v4 = v1[5];
if ( v3 == v4 )
{
if ( (__int64)*(v0 - 3) < (__int64)v1[6] )
v1 = v0 - 9;
}
else if ( (__int64)v3 < (__int64)v4 )
{
v1 = v0 - 9;
}
}
else
{
v1 = v0 - 9;
}
}
return v1;
}

canonical_decompiled_code:
void **func6()
{
void **v0; // rax
void **v1; // rdx
void *v3; // rsi
void *v4; // rcx

v0 = (void **)timer_list;
v1 = (void **)((char *)timer_list - 72);
if ( timer_list == &timer_list )
return 0LL;
while ( 1 )
{
v0 = (void **)*v0;
if ( v0 == &timer_list )
break;
if ( v1 )
{
v3 = *(v0 - 4);
v4 = v1[5];
if ( v3 == v4 )
{
if ( (__int64)*(v0 - 3) < (__int64)v1[6] )
v1 = v0 - 9;
}
else if ( (__int64)v3 < (__int64)v4 )
{
v1 = v0 - 9;
}
}
else
{
v1 = v0 - 9;
}
}
return v1;
}

original_code:
struct app_timer *find_next_timer(void)
{
    struct app_timer *a, *lowest = ((void *)0);
 struct list_head *pos;
 for (pos = (&timer_list)->next; pos != (&timer_list); pos = pos->next){
  a = ((struct app_timer *)((char *)(pos)-(unsigned long)(&((struct app_timer *)0)->list)));
  if(lowest == ((void *)0))
   lowest = a;
  else if(a->t_next.tv_sec == lowest->t_next.tv_sec) {
   if(a->t_next.tv_usec < lowest->t_next.tv_usec) {
    lowest = a;
   }
  }else if(a->t_next.tv_sec < lowest->t_next.tv_sec) {
   lowest = a;
  }
 }
 return lowest;
}

canonical_original_code:
struct app_timer *find_next_timer()
{
    struct app_timer *a; struct app_timer *lowest = ((void *)0);
 struct list_head *pos;
 for (pos = (&timer_list)->next; pos != (&timer_list); pos = pos->next){
  a = ((struct app_timer *)((char *)(pos)-(unsigned long)(&((struct app_timer *)0)->list)));
  if(lowest == ((void *)0))
   lowest = a;
  else if(a->t_next.tv_sec == lowest->t_next.tv_sec) {
   if(a->t_next.tv_usec < lowest->t_next.tv_usec) {
    lowest = a;
   }
  }else if(a->t_next.tv_sec < lowest->t_next.tv_sec) {
   lowest = a;
  }
 }
 return lowest;
}

return_type: struct app_timer { struct timeval { long tv_sec; long tv_usec; } t; unsigned int flags; unsigned int clientreg; struct timeval t_last; struct timeval t_next; void *clientarg; void (*thecallback)(unsigned int clientreg, void *clientarg); struct list_head { struct list_head *next; } list; } *


decompiled_code:
void **__fastcall sa_find_specific(int a1)
{
void **v1; // rax

v1 = (void **)timer_list;
if ( timer_list == &timer_list )
return 0LL;
while ( *((_DWORD *)v1 - 13) != a1 )
{
v1 = (void **)*v1;
if ( v1 == &timer_list )
return 0LL;
}
return v1 - 9;
}

canonical_decompiled_code:
void **__fastcall func7(int a1)
{
void **v1; // rax

v1 = (void **)timer_list;
if ( timer_list == &timer_list )
return 0LL;
while ( *((_DWORD *)v1 - 13) != a1 )
{
v1 = (void **)*v1;
if ( v1 == &timer_list )
return 0LL;
}
return v1 - 9;
}

original_code:
struct app_timer *sa_find_specific(unsigned int clientreg)
{
    struct app_timer *sa_ptr;
 struct list_head *pos;
 for (pos = (&timer_list)->next; pos != (&timer_list); pos = pos->next){
  sa_ptr = ((struct app_timer *)((char *)(pos)-(unsigned long)(&((struct app_timer *)0)->list)));
        if(sa_ptr->clientreg == clientreg) {
            return sa_ptr;
        }
    }
    return ((void *)0);
}

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


decompiled_code:
__time_t run_timers()
{
unsigned int v0; // ebp
void **v1; // rax
__time_t result; // rax
__time_t v3; // rbx
__time_t v4; // rdx
struct timeval v5; // [rsp+0h] [rbp-28h] BYREF

while ( 1 )
{
result = (__time_t)find_next_timer();
v3 = result;
if ( !result )
break;
gettimeofday(&v5, 0LL);
v4 = *(_QWORD *)(v3 + 40);
result = v5.tv_sec;
if ( v4 >= v5.tv_sec )
{
if ( v4 != v5.tv_sec )
break;
result = v5.tv_usec;
if ( *(_QWORD *)(v3 + 48) >= v5.tv_usec )
break;
}
v0 = *(_DWORD *)(v3 + 20);
(*(void (__fastcall **)(_QWORD, _QWORD))(v3 + 64))(v0, *(_QWORD *)(v3 + 56));
v1 = sa_find_specific(v0);
if ( v1 )
{
*(struct timeval *)(v1 + 3) = v5;
v1[5] = 0LL;
v1[6] = 0LL;
update_timer((__int64)v1);
}
}
return result;
}

canonical_decompiled_code:
__time_t func8()
{
unsigned int v0; // ebp
void **v1; // rax
__time_t result; // rax
__time_t v3; // rbx
__time_t v4; // rdx
struct timeval v5; // [rsp+0h] [rbp-28h] BYREF

while ( 1 )
{
result = (__time_t)func6();
v3 = result;
if ( !result )
break;
gettimeofday(&v5, 0LL);
v4 = *(_QWORD *)(v3 + 40);
result = v5.tv_sec;
if ( v4 >= v5.tv_sec )
{
if ( v4 != v5.tv_sec )
break;
result = v5.tv_usec;
if ( *(_QWORD *)(v3 + 48) >= v5.tv_usec )
break;
}
v0 = *(_DWORD *)(v3 + 20);
(*(void (__fastcall **)(_QWORD, _QWORD))(v3 + 64))(v0, *(_QWORD *)(v3 + 56));
v1 = func7(v0);
if ( v1 )
{
*(struct timeval *)(v1 + 3) = v5;
v1[5] = 0LL;
v1[6] = 0LL;
func5((__int64)v1);
}
}
return result;
}

original_code:
void run_timers(void)
{
    int done = 0;
    struct app_timer *a = ((void *)0);
    unsigned int clientreg;
    struct timeval t_now;
    while(!done) {
        if((a = find_next_timer()) == ((void *)0)) {
            return;
        }
        gettimeofday(&t_now, ((void *)0));
        if((a->t_next.tv_sec < t_now.tv_sec) ||
           ((a->t_next.tv_sec == t_now.tv_sec) &&
            (a->t_next.tv_usec < t_now.tv_usec))) {
            clientreg = a->clientreg;
            (*(a->thecallback)) (clientreg, a->clientarg);
            if((a = sa_find_specific(clientreg)) != ((void *)0)) {
                a->t_last.tv_sec = t_now.tv_sec;
                a->t_last.tv_usec = t_now.tv_usec;
                a->t_next.tv_sec = 0;
                a->t_next.tv_usec = 0;
                update_timer(a);
            }
            else {
            }
        }
        else {
            done = 1;
        }
    }
}

canonical_original_code:
void run_timers()
{
    int done = 0;
    struct app_timer *a = ((void *)0);
    unsigned int clientreg;
    struct timeval t_now;
    while(!done) {
        if((a = find_next_timer()) == ((void *)0)) {
            return;
        }
        gettimeofday(&t_now, ((void *)0));
        if((a->t_next.tv_sec < t_now.tv_sec) ||
           ((a->t_next.tv_sec == t_now.tv_sec) &&
            (a->t_next.tv_usec < t_now.tv_usec))) {
            clientreg = a->clientreg;
            (*(a->thecallback)) (clientreg, a->clientarg);
            if((a = sa_find_specific(clientreg)) != ((void *)0)) {
                a->t_last.tv_sec = t_now.tv_sec;
                a->t_last.tv_usec = t_now.tv_usec;
                a->t_next.tv_sec = 0;
                a->t_next.tv_usec = 0;
                update_timer(a);
            }
            else {
            }
        }
        else {
            done = 1;
        }
    }
}

variable_types: done int


decompiled_code:
__int64 __fastcall get_next_timer_delay_time(__time_t *a1)
{
void **v1; // rbx
__int64 result; // rax
__time_t v3; // rcx
__time_t v4; // rcx
__suseconds_t v5; // rax
__time_t v6; // rdx
struct timeval v7; // [rsp+0h] [rbp-28h] BYREF

v1 = find_next_timer();
result = 0LL;
if ( v1 )
{
gettimeofday(&v7, 0LL);
v3 = (__time_t)v1[5];
if ( v7.tv_sec > v3 || v7.tv_sec == v3 && v7.tv_usec > (__int64)v1[6] )
{
*a1 = 0LL;
a1[1] = 1LL;
result = *((unsigned int *)v1 + 5);
}
else
{
v4 = v3 - v7.tv_sec;
v5 = (__suseconds_t)v1[6] - v7.tv_usec;
if ( v5 < 0 )
{
v6 = v4 - 1;
do
{
v4 = v6--;
v5 += 1000000LL;
}
while ( v5 < 0 );
}
*a1 = v4;
a1[1] = v5;
result = *((unsigned int *)v1 + 5);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__time_t *a1)
{
void **v1; // rbx
__int64 result; // rax
__time_t v3; // rcx
__time_t v4; // rcx
__suseconds_t v5; // rax
__time_t v6; // rdx
struct timeval v7; // [rsp+0h] [rbp-28h] BYREF

v1 = func6();
result = 0LL;
if ( v1 )
{
gettimeofday(&v7, 0LL);
v3 = (__time_t)v1[5];
if ( v7.tv_sec > v3 || v7.tv_sec == v3 && v7.tv_usec > (__int64)v1[6] )
{
*a1 = 0LL;
a1[1] = 1LL;
result = *((unsigned int *)v1 + 5);
}
else
{
v4 = v3 - v7.tv_sec;
v5 = (__suseconds_t)v1[6] - v7.tv_usec;
if ( v5 < 0 )
{
v6 = v4 - 1;
do
{
v4 = v6--;
v5 += 1000000LL;
}
while ( v5 < 0 );
}
*a1 = v4;
a1[1] = v5;
result = *((unsigned int *)v1 + 5);
}
}
return result;
}

original_code:
int get_next_timer_delay_time(struct timeval *delta)
{
    struct app_timer *sa_ptr;
    struct timeval t_diff, t_now;
    sa_ptr = find_next_timer();
    if(sa_ptr) {
        gettimeofday(&t_now, 0);
        if((t_now.tv_sec > sa_ptr->t_next.tv_sec) ||
           ((t_now.tv_sec == sa_ptr->t_next.tv_sec) &&
            (t_now.tv_usec > sa_ptr->t_next.tv_usec))) {
            delta->tv_sec = 0;
            delta->tv_usec = 1;
            return sa_ptr->clientreg;
        }
        else {
            t_diff.tv_sec = sa_ptr->t_next.tv_sec - t_now.tv_sec;
            t_diff.tv_usec = sa_ptr->t_next.tv_usec - t_now.tv_usec;
            while(t_diff.tv_usec < 0) {
                t_diff.tv_sec -= 1;
                t_diff.tv_usec += 1000000;
            }
            delta->tv_sec = t_diff.tv_sec;
            delta->tv_usec = t_diff.tv_usec;
            return sa_ptr->clientreg;
        }
    }
    return 0;
}

canonical_original_code:
int get_next_timer_delay_time(struct timeval *delta)
{
    struct app_timer *sa_ptr;
    struct timeval t_diff; struct timeval t_now;
    sa_ptr = find_next_timer();
    if(sa_ptr) {
        gettimeofday(&t_now, 0);
        if((t_now.tv_sec > sa_ptr->t_next.tv_sec) ||
           ((t_now.tv_sec == sa_ptr->t_next.tv_sec) &&
            (t_now.tv_usec > sa_ptr->t_next.tv_usec))) {
            delta->tv_sec = 0;
            delta->tv_usec = 1;
            return sa_ptr->clientreg;
        }
        else {
            t_diff.tv_sec = sa_ptr->t_next.tv_sec - t_now.tv_sec;
            t_diff.tv_usec = sa_ptr->t_next.tv_usec - t_now.tv_usec;
            while(t_diff.tv_usec < 0) {
                t_diff.tv_sec -= 1;
                t_diff.tv_usec += 1000000;
            }
            delta->tv_sec = t_diff.tv_sec;
            delta->tv_usec = t_diff.tv_usec;
            return sa_ptr->clientreg;
        }
    }
    return 0;
}

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


decompiled_code:
int set_an_timer()
{
int result; // eax
struct itimerval v1; // [rsp+0h] [rbp-38h] BYREF
struct timeval v2; // [rsp+20h] [rbp-18h] BYREF

result = get_next_timer_delay_time(&v2.tv_sec);
if ( result )
{
v1.it_value = v2;
v1.it_interval.tv_sec = 0LL;
v1.it_interval.tv_usec = 0LL;
signal(14, timer_handler);
result = setitimer(ITIMER_REAL, &v1, 0LL);
}
return result;
}

canonical_decompiled_code:
int func10()
{
int result; // eax
struct itimerval v1; // [rsp+0h] [rbp-38h] BYREF
struct timeval v2; // [rsp+20h] [rbp-18h] BYREF

result = func9(&v2.tv_sec);
if ( result )
{
v1.it_value = v2;
v1.it_interval.tv_sec = 0LL;
v1.it_interval.tv_usec = 0LL;
signal(14, timer_handler);
result = setitimer(ITIMER_REAL, &v1, 0LL);
}
return result;
}

original_code:
void set_an_timer(void)
{
    struct timeval delta;
    int next_timer = get_next_timer_delay_time(&delta);
    if(next_timer) {
        struct itimerval it;
        it.it_value.tv_sec = delta.tv_sec;
        it.it_value.tv_usec = delta.tv_usec;
        it.it_interval.tv_sec = 0;
        it.it_interval.tv_usec = 0;
        signal(14, timer_handler);
        setitimer(ITIMER_REAL, &it, ((void *)0));
    }
    else {
    }
}

canonical_original_code:
void set_an_timer()
{
    struct timeval delta;
    int next_timer = get_next_timer_delay_time(&delta);
    if(next_timer) {
        struct itimerval it;
        it.it_value.tv_sec = delta.tv_sec;
        it.it_value.tv_usec = delta.tv_usec;
        it.it_interval.tv_sec = 0;
        it.it_interval.tv_usec = 0;
        signal(14, timer_handler);
        setitimer(ITIMER_REAL, &it, ((void *)0));
    }
    else {
    }
}

variable_types: struct itimerval { struct timeval { long tv_sec; long tv_usec; } it_interval; struct timeval it_value; }

user_defined_types: struct itimerval { struct timeval it_interval; struct timeval it_value; }


decompiled_code:
void timer_handler()
{
run_timers();
set_an_timer();
}

canonical_decompiled_code:
void func11()
{
func8();
func10();
}

original_code:
void timer_handler(int a)
{
    run_timers();
    set_an_timer();
}

variable_types: a int


original_code:
unsigned int
app_timer_register(struct app_timer *sa_ptr,unsigned int when, unsigned int flags,
                    APPTimerCallback * thecallback, void *clientarg)
{
 struct list_head *pos;
 list_add_tail(&sa_ptr->list, &timer_list);
    if(sa_ptr == ((void *)0))
        return 0;
    if(0 == when) {
        (sa_ptr)->t.tv_sec = 0;
        (sa_ptr)->t.tv_usec = 1;
    }
    else {
        (sa_ptr)->t.tv_sec = when;
        (sa_ptr)->t.tv_usec = 0;
    }
 (sa_ptr)->t_last.tv_sec = 0;
 (sa_ptr)->t_last.tv_usec = 0;
 (sa_ptr)->t_next.tv_sec = 0;
 (sa_ptr)->t_next.tv_usec = 0;
    (sa_ptr)->flags = flags;
    (sa_ptr)->clientarg = clientarg;
    (sa_ptr)->thecallback = thecallback;
    (sa_ptr)->clientreg = regnum++;
    update_timer(sa_ptr);
    set_an_timer();
    return (sa_ptr)->clientreg;
}

canonical_original_code:
unsigned int app_timer_register(struct app_timer *sa_ptr, unsigned int when, unsigned int flags, void (*thecallback)(unsigned int clientreg, void *clientarg), void *clientarg)
{
 struct list_head *pos;
 list_add_tail(&sa_ptr->list, &timer_list);
    if(sa_ptr == ((void *)0))
        return 0;
    if(0 == when) {
        (sa_ptr)->t.tv_sec = 0;
        (sa_ptr)->t.tv_usec = 1;
    }
    else {
        (sa_ptr)->t.tv_sec = when;
        (sa_ptr)->t.tv_usec = 0;
    }
 (sa_ptr)->t_last.tv_sec = 0;
 (sa_ptr)->t_last.tv_usec = 0;
 (sa_ptr)->t_next.tv_sec = 0;
 (sa_ptr)->t_next.tv_usec = 0;
    (sa_ptr)->flags = flags;
    (sa_ptr)->clientarg = clientarg;
    (sa_ptr)->thecallback = thecallback;
    (sa_ptr)->clientreg = regnum++;
    update_timer(sa_ptr);
    set_an_timer();
    return (sa_ptr)->clientreg;
}

variable_types:
when
unsigned int

variable_types:
flags
unsigned int

variable_types: void (*)(unsigned int clientreg, void *clientarg)

variable_types:
clientarg
void *

return_type: unsigned int


repo: xudifsd/libsi

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

result = (char *)&unk_510;
if ( !a1 )
result = (char *)&unk_510 - 16;
return result;
}

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

result = (char *)&unk_510;
if ( !a1 )
result = (char *)&unk_510 - 16;
return result;
}

original_code:
struct bool *alloc_bool(int value) {
 if (value)
  return bpool + 1;
 else
  return bpool + 0;
}

variable_types: value int

return_type: struct bool { unsigned long tag; unsigned int value; } *


decompiled_code:
__int64 __fastcall alloc_tree_node(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

result = GC_malloc(56LL);
if ( !result )
_assert_fail("rtn != NULL", "malloc.c", 0x21u, "alloc_tree_node");
*(_DWORD *)result = 1;
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
*(_QWORD *)(result + 24) = 0LL;
*(_QWORD *)(result + 32) = 0LL;
*(_QWORD *)(result + 40) = a3;
*(_QWORD *)(result + 48) = a4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

result = GC_malloc(56LL);
if ( !result )
_assert_fail("rtn != NULL", "malloc.c", 0x21u, "alloc_tree_node");
*(_DWORD *)result = 1;
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
*(_QWORD *)(result + 24) = 0LL;
*(_QWORD *)(result + 32) = 0LL;
*(_QWORD *)(result + 40) = a3;
*(_QWORD *)(result + 48) = a4;
return result;
}

original_code:
struct tree_node *alloc_tree_node(struct tree_node *parent, struct tree_node **pparent,
  struct symbol *sym, struct exp *e) {
 struct tree_node *rtn = (struct tree_node *)GC_malloc(sizeof(struct tree_node));
 ((void) sizeof ((rtn != ((void *)0)) ? 1 : 0), __extension__ ({ if (rtn != ((void *)0)) ; else __assert_fail ("rtn != NULL", "malloc.c", 33, __extension__ __PRETTY_FUNCTION__); }));
 rtn->color = RED;
 rtn->parent = parent;
 rtn->pparent = pparent;
 rtn->left = ((void *)0);
 rtn->right = ((void *)0);
 rtn->sym = sym;
 rtn->value = e;
 return rtn;
}

variable_types:
parent
struct tree_node *

variable_types:
pparent
struct tree_node **

variable_types:
sym
struct symbol *

variable_types:
e
struct exp *

variable_types: struct tree_node { enum tree_color { BLACK=0, RED=1 } color; struct tree_node *parent; struct tree_node **pparent; struct tree_node *left; struct tree_node *right; struct symbol { unsigned long tag; char sym[70]; } *sym; struct exp { unsigned long tag; } *value; } *

user_defined_types: struct tree_node { enum tree_color color; struct tree_node *parent; struct tree_node **pparent; struct tree_node *left; struct tree_node *right; struct symbol *sym; struct exp *value; }


decompiled_code:
__int64 __fastcall alloc_symbol(char *src)
{
__int64 v1; // rax
__int64 v2; // rbx

v1 = GC_malloc_atomic(80LL);
if ( !v1 )
_assert_fail("rtn", "malloc.c", 0x2Eu, "alloc_symbol");
v2 = v1;
*(_QWORD *)v1 = 2LL;
strcpy((char *)(v1 + 8), src);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *src)
{
__int64 v1; // rax
__int64 v2; // rbx

v1 = GC_malloc_atomic(80LL);
if ( !v1 )
_assert_fail("rtn", "malloc.c", 0x2Eu, "alloc_symbol");
v2 = v1;
*(_QWORD *)v1 = 2LL;
strcpy((char *)(v1 + 8), src);
return v2;
}

original_code:
struct symbol *alloc_symbol(const char *str) {
 struct symbol *rtn = (struct symbol *)GC_malloc_atomic(sizeof(struct symbol));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 46, __extension__ __PRETTY_FUNCTION__); }));
 rtn->tag = (1<<1);
 strcpy((char *)rtn->sym, str);
 return rtn;
}

canonical_original_code:
struct symbol *alloc_symbol(char *str) {
 struct symbol *rtn = (struct symbol *)GC_malloc_atomic(sizeof(struct symbol));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 46, __extension__ __PRETTY_FUNCTION__); }));
 rtn->tag = (1<<1);
 strcpy((char *)rtn->sym, str);
 return rtn;
}

variable_types:
str
char *

variable_types: struct symbol { unsigned long tag; char sym[70]; } *


decompiled_code:
__int64 alloc_err_msg(char *format, ...)
{
__int64 v1; // rbx
gcc_va_list arg; // [rsp+8h] [rbp-E0h] BYREF

va_start(arg, format);
v1 = alloc_symbol((char *)&LC3);
vsnprintf((char *)(v1 + 8), 0x46uLL, format, arg);
return v1;
}

canonical_decompiled_code:
__int64 func3(char *format, ...)
{
__int64 v1; // rbx
gcc_va_list arg; // [rsp+8h] [rbp-E0h] BYREF

va_start(arg, format);
v1 = func2((char *)&LC3);
vsnprintf((char *)(v1 + 8), 0x46uLL, format, arg);
return v1;
}

original_code:
struct symbol *alloc_err_msg(const char *fmt, ...) {
 struct symbol *rtn = alloc_symbol("");
 va_list args;
 __builtin_va_start(args,fmt);
 vsnprintf((char *)rtn->sym, 70, fmt, args);
 __builtin_va_end(args);
 return rtn;
}

canonical_original_code:
struct symbol *alloc_err_msg(char *fmt, ...) {
 struct symbol *rtn = alloc_symbol("");
 __builtin_va_list args;
 __builtin_va_start(args,fmt);
 vsnprintf((char *)rtn->sym, 70, fmt, args);
 __builtin_va_end(args);
 return rtn;
}

variable_types:
fmt
char *

return_type: struct symbol { unsigned long tag; char sym[70]; } *


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

result = GC_malloc_atomic(24LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x36u, "alloc_long");
*(_QWORD *)result = 1LL;
*(_DWORD *)(result + 16) = 0;
*(_QWORD *)(result + 8) = a1;
return result;
}

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

result = GC_malloc_atomic(24LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x36u, "alloc_long");
*(_QWORD *)result = 1LL;
*(_DWORD *)(result + 16) = 0;
*(_QWORD *)(result + 8) = a1;
return result;
}

original_code:
struct number *alloc_long(long value) {
 struct number *rtn = (struct number *)GC_malloc_atomic(sizeof(struct number));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 54, __extension__ __PRETTY_FUNCTION__); }));
 rtn->tag = (1<<0);
 rtn->type = LONG;
 rtn->l_value = value;
 return rtn;
}

variable_types: value long

variable_types: struct number { unsigned long tag; union { long l_value; double d_value; }; enum num_type { LONG=0, DOUBLE=1 } type; } *

user_defined_types: struct number { unsigned long tag; union { long l_value; double d_value; }; enum num_type type; }


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

result = GC_malloc_atomic(24LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x3Fu, "alloc_double");
*(_QWORD *)result = 1LL;
*(_DWORD *)(result + 16) = 1;
*(double *)(result + 8) = a1;
return result;
}

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

result = GC_malloc_atomic(24LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x3Fu, "alloc_double");
*(_QWORD *)result = 1LL;
*(_DWORD *)(result + 16) = 1;
*(double *)(result + 8) = a1;
return result;
}

original_code:
struct number *alloc_double(double value) {
 struct number *rtn = (struct number *)GC_malloc_atomic(sizeof(struct number));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 63, __extension__ __PRETTY_FUNCTION__); }));
 rtn->tag = (1<<0);
 rtn->type = DOUBLE;
 rtn->d_value = value;
 return rtn;
}

variable_types: value double

return_type: struct number { unsigned long tag; union { long l_value; double d_value; }; enum num_type { LONG=0, DOUBLE=1 } type; } *


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

result = GC_malloc(32LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x51u, "alloc_stack_frame");
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = 0LL;
*(_QWORD *)(result + 24) = result + 16;
*(_DWORD *)result = 0;
return result;
}

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

result = GC_malloc(32LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x51u, "alloc_stack_frame");
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = 0LL;
*(_QWORD *)(result + 24) = result + 16;
*(_DWORD *)result = 0;
return result;
}

original_code:
struct stack_frame *alloc_stack_frame(struct stack_frame *prev) {
 struct stack_frame *rtn = (struct stack_frame *)GC_malloc(sizeof(struct stack_frame));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 81, __extension__ __PRETTY_FUNCTION__); }));
 rtn->prev = prev;
 rtn->head = ((void *)0);
 rtn->tail = &rtn->head;
 rtn->dot_list = 0;
 return rtn;
}

variable_types:
prev
struct stack_frame *

variable_types: struct stack_frame { int dot_list; struct stack_frame *prev; struct pair { unsigned long tag; struct exp { unsigned long tag; } *car; struct exp *cdr; } *head; struct pair **tail; } *

user_defined_types: struct stack_frame { int dot_list; struct stack_frame *prev; struct pair *head; struct pair **tail; }

user_defined_types: struct pair { unsigned long tag; struct exp *car; struct exp *cdr; }


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

result = GC_malloc(16LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x63u, "alloc_quote_stack");
*(_QWORD *)(result + 8) = a1;
*(_DWORD *)result = 0;
return result;
}

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

result = GC_malloc(16LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x63u, "alloc_quote_stack");
*(_QWORD *)(result + 8) = a1;
*(_DWORD *)result = 0;
return result;
}

original_code:
struct quote_stack *alloc_quote_stack(struct quote_stack *prev) {
 struct quote_stack *rtn = (struct quote_stack *)GC_malloc(sizeof(struct quote_stack));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 99, __extension__ __PRETTY_FUNCTION__); }));
 rtn->prev = prev;
 rtn->nest = 0;
 return rtn;
}

variable_types:
prev
struct quote_stack *

variable_types: struct quote_stack { unsigned int nest; struct quote_stack *prev; } *


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

result = GC_malloc(16LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x6Bu, "alloc_dot_stack");
*(_QWORD *)(result + 8) = a1;
*(_DWORD *)result = 0;
return result;
}

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

result = GC_malloc(16LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x6Bu, "alloc_dot_stack");
*(_QWORD *)(result + 8) = a1;
*(_DWORD *)result = 0;
return result;
}

original_code:
struct dot_stack *alloc_dot_stack(struct dot_stack *prev) {
 struct dot_stack *rtn = (struct dot_stack *)GC_malloc(sizeof(struct dot_stack));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 107, __extension__ __PRETTY_FUNCTION__); }));
 rtn->prev = prev;
 rtn->dot_nest = 0;
 return rtn;
}

variable_types:
prev
struct dot_stack *

variable_types: struct dot_stack { int dot_nest; struct dot_stack *prev; } *


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

result = GC_malloc_atomic(40LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x73u, "alloc_builtin_pro");
*(_QWORD *)result = 8LL;
*(_DWORD *)(result + 32) = 1;
*(_QWORD *)(result + 8) = a1;
return result;
}

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

result = GC_malloc_atomic(40LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x73u, "alloc_builtin_pro");
*(_QWORD *)result = 8LL;
*(_DWORD *)(result + 32) = 1;
*(_QWORD *)(result + 8) = a1;
return result;
}

original_code:
struct callable *alloc_builtin_pro(builtin_pro_f fun) {
 struct callable *rtn = GC_malloc_atomic(sizeof(struct callable));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 115, __extension__ __PRETTY_FUNCTION__); }));
 rtn->tag = (1<<3);
 rtn->type = BUILTIN_PRO;
 rtn->bp_value = fun;
 return rtn;
}

canonical_original_code:
struct callable *alloc_builtin_pro(enum rtn_type (*fun)(struct pair *args, struct exp **rtn)) {
 struct callable *rtn = GC_malloc_atomic(sizeof(struct callable));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 115, __extension__ __PRETTY_FUNCTION__); }));
 rtn->tag = (1<<3);
 rtn->type = BUILTIN_PRO;
 rtn->bp_value = fun;
 return rtn;
}

variable_types: enum rtn_type { SUCC=0, ERR_ARGC=1, ERR_TYPE=2, ERR_UNBOUND=3, ERR_MATH=4, ERR_ENV=5, ERR_MEM=6, ERR_USER_PRO=7, ERR_PARSE_RB=8, ERR_PARSE_DOT=9 } (*)(struct pair *args, struct exp **rtn)

variable_types: struct callable { unsigned long tag; union { enum rtn_type { SUCC=0, ERR_ARGC=1, ERR_TYPE=2, ERR_UNBOUND=3, ERR_MATH=4, ERR_ENV=5, ERR_MEM=6, ERR_USER_PRO=7, ERR_PARSE_RB=8, ERR_PARSE_DOT=9 } (*bp_value)(struct pair { unsigned long tag; struct exp { unsigned long tag; } *car; struct exp *cdr; } *args, struct exp **rtn); enum rtn_type { SUCC=0, ERR_ARGC=1, ERR_TYPE=2, ERR_UNBOUND=3, ERR_MATH=4, ERR_ENV=5, ERR_MEM=6, ERR_USER_PRO=7, ERR_PARSE_RB=8, ERR_PARSE_DOT=9 } (*bs_value)(struct pair *args, struct exp **rtn, struct environ { struct environ *parent; struct tree_node { enum tree_color { BLACK=0, RED=1 } color; struct tree_node *parent; struct tree_node **pparent; struct tree_node *left; struct tree_node *right; struct symbol { unsigned long tag; char sym[70]; } *sym; struct exp *value; } *repo; } *env); struct user_defined_s { struct pair *pars; struct pair *body; struct environ *bind; } u_value; }; enum callable_type { BUILTIN_SYNTAX=0, BUILTIN_PRO=1, LAMBDA=2, MACRO=3 } type; } *

user_defined_types: struct callable { unsigned long tag; union { enum rtn_type (*bp_value)(struct pair *args, struct exp **rtn); enum rtn_type (*bs_value)(struct pair *args, struct exp **rtn, struct environ *env); struct user_defined_s u_value; }; enum callable_type type; }

user_defined_types: struct environ { struct environ *parent; struct tree_node *repo; }


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

result = GC_malloc_atomic(40LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x7Cu, "alloc_builtin_syntax");
*(_QWORD *)result = 8LL;
*(_DWORD *)(result + 32) = 0;
*(_QWORD *)(result + 8) = a1;
return result;
}

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

result = GC_malloc_atomic(40LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x7Cu, "alloc_builtin_syntax");
*(_QWORD *)result = 8LL;
*(_DWORD *)(result + 32) = 0;
*(_QWORD *)(result + 8) = a1;
return result;
}

original_code:
struct callable *alloc_builtin_syntax(builtin_syntax_f fun) {
 struct callable *rtn = GC_malloc_atomic(sizeof(struct callable));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 124, __extension__ __PRETTY_FUNCTION__); }));
 rtn->tag = (1<<3);
 rtn->type = BUILTIN_SYNTAX;
 rtn->bs_value = fun;
 return rtn;
}

canonical_original_code:
struct callable *alloc_builtin_syntax(enum rtn_type (*fun)(struct pair *args, struct exp **rtn, struct environ *env)) {
 struct callable *rtn = GC_malloc_atomic(sizeof(struct callable));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 124, __extension__ __PRETTY_FUNCTION__); }));
 rtn->tag = (1<<3);
 rtn->type = BUILTIN_SYNTAX;
 rtn->bs_value = fun;
 return rtn;
}

variable_types: enum rtn_type { SUCC=0, ERR_ARGC=1, ERR_TYPE=2, ERR_UNBOUND=3, ERR_MATH=4, ERR_ENV=5, ERR_MEM=6, ERR_USER_PRO=7, ERR_PARSE_RB=8, ERR_PARSE_DOT=9 } (*)(struct pair *args, struct exp **rtn, struct environ *env)

return_type: struct callable { unsigned long tag; union { enum rtn_type { SUCC=0, ERR_ARGC=1, ERR_TYPE=2, ERR_UNBOUND=3, ERR_MATH=4, ERR_ENV=5, ERR_MEM=6, ERR_USER_PRO=7, ERR_PARSE_RB=8, ERR_PARSE_DOT=9 } (*bp_value)(struct pair { unsigned long tag; struct exp { unsigned long tag; } *car; struct exp *cdr; } *args, struct exp **rtn); enum rtn_type { SUCC=0, ERR_ARGC=1, ERR_TYPE=2, ERR_UNBOUND=3, ERR_MATH=4, ERR_ENV=5, ERR_MEM=6, ERR_USER_PRO=7, ERR_PARSE_RB=8, ERR_PARSE_DOT=9 } (*bs_value)(struct pair *args, struct exp **rtn, struct environ { struct environ *parent; struct tree_node { enum tree_color { BLACK=0, RED=1 } color; struct tree_node *parent; struct tree_node **pparent; struct tree_node *left; struct tree_node *right; struct symbol { unsigned long tag; char sym[70]; } *sym; struct exp *value; } *repo; } *env); struct user_defined_s { struct pair *pars; struct pair *body; struct environ *bind; } u_value; }; enum callable_type { BUILTIN_SYNTAX=0, BUILTIN_PRO=1, LAMBDA=2, MACRO=3 } type; } *


decompiled_code:
__int64 __fastcall alloc_lambda(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = GC_malloc(40LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x85u, "alloc_lambda");
*(_QWORD *)result = 8LL;
*(_DWORD *)(result + 32) = 2;
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
*(_QWORD *)(result + 24) = a3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = GC_malloc(40LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x85u, "alloc_lambda");
*(_QWORD *)result = 8LL;
*(_DWORD *)(result + 32) = 2;
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
*(_QWORD *)(result + 24) = a3;
return result;
}

original_code:
struct callable *alloc_lambda(struct pair *pars, struct pair *body, struct environ *bind) {
 struct callable *rtn = GC_malloc(sizeof(struct callable));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 133, __extension__ __PRETTY_FUNCTION__); }));
 rtn->tag = (1<<3);
 rtn->type = LAMBDA;
 rtn->u_value.pars = pars;
 rtn->u_value.body = body;
 rtn->u_value.bind = bind;
 return rtn;
}

variable_types:
pars
struct pair *

variable_types:
body
struct pair *

variable_types:
bind
struct environ *

user_defined_types: enum callable_type { BUILTIN_SYNTAX=0, BUILTIN_PRO=1, LAMBDA=2, MACRO=3 }

user_defined_types: struct user_defined_s { struct pair *pars; struct pair *body; struct environ *bind; }

user_defined_types: enum rtn_type { SUCC=0, ERR_ARGC=1, ERR_TYPE=2, ERR_UNBOUND=3, ERR_MATH=4, ERR_ENV=5, ERR_MEM=6, ERR_USER_PRO=7, ERR_PARSE_RB=8, ERR_PARSE_DOT=9 }

user_defined_types: struct symbol { unsigned long tag; char sym[70]; }


decompiled_code:
__int64 __fastcall alloc_macro(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = GC_malloc(40LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x90u, "alloc_macro");
*(_QWORD *)result = 8LL;
*(_DWORD *)(result + 32) = 3;
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
*(_QWORD *)(result + 24) = a3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = GC_malloc(40LL);
if ( !result )
_assert_fail("rtn", "malloc.c", 0x90u, "alloc_macro");
*(_QWORD *)result = 8LL;
*(_DWORD *)(result + 32) = 3;
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
*(_QWORD *)(result + 24) = a3;
return result;
}

original_code:
struct callable *alloc_macro(struct pair *pars, struct pair *body, struct environ *bind) {
 struct callable *rtn = GC_malloc(sizeof(struct callable));
 ((void) sizeof ((rtn) ? 1 : 0), __extension__ ({ if (rtn) ; else __assert_fail ("rtn", "malloc.c", 144, __extension__ __PRETTY_FUNCTION__); }));
 rtn->tag = (1<<3);
 rtn->type = MACRO;
 rtn->u_value.pars = pars;
 rtn->u_value.body = body;
 rtn->u_value.bind = bind;
 return rtn;
}


decompiled_code:
int __fastcall to_dot(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax
const char *v3; // rcx
__int64 v4; // rax

v1 = *(_QWORD *)(a1 + 24);
if ( v1 )
fprintf(
stderr,
"\t\"%s\" -> \"%s\"[headport=n, tailport=sw]\n",
(const char *)(*(_QWORD *)(a1 + 40) + 8LL),
(const char *)(*(_QWORD *)(v1 + 40) + 8LL));
v2 = *(_QWORD *)(a1 + 8);
if ( v2 )
fprintf(
stderr,
"\t\"%s\" -> \"%s\"[headport=s, tailport=n]\n",
(const char *)(*(_QWORD *)(a1 + 40) + 8LL),
(const char *)(*(_QWORD *)(v2 + 40) + 8LL));
v3 = (const char *)&LC0;
if ( *(_DWORD *)a1 != 1 )
v3 = "black";
fprintf(stderr, "\t\"%s\"[color=%s]\n", (const char *)(*(_QWORD *)(a1 + 40) + 8LL), v3);
v4 = *(_QWORD *)(a1 + 32);
if ( v4 )
LODWORD(v4) = fprintf(
stderr,
"\t\"%s\" -> \"%s\"[headport=n, tailport=se]\n",
(const char *)(*(_QWORD *)(a1 + 40) + 8LL),
(const char *)(*(_QWORD *)(v4 + 40) + 8LL));
return v4;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax
const char *v3; // rcx
__int64 v4; // rax

v1 = *(_QWORD *)(a1 + 24);
if ( v1 )
fprintf(
stderr,
"\t\"%s\" -> \"%s\"[headport=n, tailport=sw]\n",
(const char *)(*(_QWORD *)(a1 + 40) + 8LL),
(const char *)(*(_QWORD *)(v1 + 40) + 8LL));
v2 = *(_QWORD *)(a1 + 8);
if ( v2 )
fprintf(
stderr,
"\t\"%s\" -> \"%s\"[headport=s, tailport=n]\n",
(const char *)(*(_QWORD *)(a1 + 40) + 8LL),
(const char *)(*(_QWORD *)(v2 + 40) + 8LL));
v3 = (const char *)&LC0;
if ( *(_DWORD *)a1 != 1 )
v3 = "black";
fprintf(stderr, "\t\"%s\"[color=%s]\n", (const char *)(*(_QWORD *)(a1 + 40) + 8LL), v3);
v4 = *(_QWORD *)(a1 + 32);
if ( v4 )
LODWORD(v4) = fprintf(
stderr,
"\t\"%s\" -> \"%s\"[headport=n, tailport=se]\n",
(const char *)(*(_QWORD *)(a1 + 40) + 8LL),
(const char *)(*(_QWORD *)(v4 + 40) + 8LL));
return v4;
}

original_code:
static void to_dot(struct tree_node *cur) {
 if (cur->left != ((void *)0))
  fprintf(stderr, "\t\"%s\" -> \"%s\"[headport=n, tailport=sw]\n", cur->sym->sym, cur->left->sym->sym);
 if (cur->parent != ((void *)0))
  fprintf(stderr, "\t\"%s\" -> \"%s\"[headport=s, tailport=n]\n", cur->sym->sym, cur->parent->sym->sym);
 fprintf(stderr, "\t\"%s\"[color=%s]\n", cur->sym->sym, (cur->color == RED)?"red":"black");
 if (cur->right != ((void *)0))
  fprintf(stderr, "\t\"%s\" -> \"%s\"[headport=n, tailport=se]\n", cur->sym->sym, cur->right->sym->sym);
}

variable_types: struct tree_node { enum tree_color { BLACK=0, RED=1 } color; struct tree_node *parent; struct tree_node **pparent; struct tree_node *left; struct tree_node *right; struct symbol { unsigned long tag; char sym[70]; } *sym; struct exp { unsigned long tag; } *value; } *


decompiled_code:
__int64 __fastcall tree_find(_QWORD *a1, const char *a2, _QWORD *a3)
{
_QWORD *v3; // rbx
int v6; // eax

v3 = a1;
if ( !a1 )
return 0LL;
do
{
v6 = strcmp(a2, (const char *)(v3[5] + 8LL));
if ( v6 > 0 )
{
v3 = (_QWORD *)v3[4];
}
else
{
if ( v6 >= 0 )
{
*a3 = v3[6];
return 1LL;
}
v3 = (_QWORD *)v3[3];
}
}
while ( v3 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, const char *a2, _QWORD *a3)
{
_QWORD *v3; // rbx
int v6; // eax

v3 = a1;
if ( !a1 )
return 0LL;
do
{
v6 = strcmp(a2, (const char *)(v3[5] + 8LL));
if ( v6 > 0 )
{
v3 = (_QWORD *)v3[4];
}
else
{
if ( v6 >= 0 )
{
*a3 = v3[6];
return 1LL;
}
v3 = (_QWORD *)v3[3];
}
}
while ( v3 );
return 0LL;
}

original_code:
int tree_find(struct tree_node *root, const char *str, struct exp **rtn) {
 struct tree_node *p = root;
 int cmp;
 while (p) {
  cmp = strcmp(str, p->sym->sym);
  if (cmp > 0)
   p = p->right;
  else if (cmp < 0)
   p = p->left;
  else {
   *rtn = p->value;
   return 1;
  }
 }
 return 0;
}

canonical_original_code:
int tree_find(struct tree_node *root, char *str, struct exp **rtn) {
 struct tree_node *p = root;
 int cmp;
 while (p) {
  cmp = strcmp(str, p->sym->sym);
  if (cmp > 0)
   p = p->right;
  else if (cmp < 0)
   p = p->left;
  else {
   *rtn = p->value;
   return 1;
  }
 }
 return 0;
}

variable_types:
str
char *

variable_types:
rtn
struct exp **

variable_types: cmp int


decompiled_code:
__int64 __fastcall tree_insert(__int64 *a1, __int64 a2, __int64 a3, int a4)
{
__int64 *v4; // r15
_QWORD *v7; // rbx
__int64 result; // rax
int v9; // eax
__int64 v10; // rax

v4 = a1;
v7 = (_QWORD *)*a1;
if ( !*a1 )
{
LABEL_10:
result = 1LL;
if ( !a4 )
{
v10 = alloc_tree_node(v7, v4, a2, a3);
*v4 = v10;
insert_case1(v10);
result = 0LL;
}
return result;
}
while ( 1 )
{
v9 = strcmp((const char *)(a2 + 8), (const char *)(v7[5] + 8LL));
v4 = v7 + 4;
if ( v9 > 0 )
goto LABEL_5;
if ( v9 >= 0 )
break;
v4 = v7 + 3;
LABEL_5:
if ( !*v4 )
goto LABEL_10;
v7 = (_QWORD *)*v4;
}
result = 1LL;
if ( a4 )
{
v7[6] = a3;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 *a1, __int64 a2, __int64 a3, int a4)
{
__int64 *v4; // r15
_QWORD *v7; // rbx
__int64 result; // rax
int v9; // eax
__int64 v10; // rax

v4 = a1;
v7 = (_QWORD *)*a1;
if ( !*a1 )
{
LABEL_10:
result = 1LL;
if ( !a4 )
{
v10 = alloc_tree_node(v7, v4, a2, a3);
*v4 = v10;
func2(v10);
result = 0LL;
}
return result;
}
while ( 1 )
{
v9 = strcmp((const char *)(a2 + 8), (const char *)(v7[5] + 8LL));
v4 = v7 + 4;
if ( v9 > 0 )
goto LABEL_5;
if ( v9 >= 0 )
break;
v4 = v7 + 3;
LABEL_5:
if ( !*v4 )
goto LABEL_10;
v7 = (_QWORD *)*v4;
}
result = 1LL;
if ( a4 )
{
v7[6] = a3;
result = 0LL;
}
return result;
}

original_code:
int tree_insert(struct tree_node **root, struct symbol *sym, struct exp *e, int replace) {
 struct tree_node **cur;
 struct tree_node *p;
 struct tree_node *parent;
 int cmp;
 for (cur = root, parent = ((void *)0); *cur;) {
  p = *cur;
  cmp = strcmp(sym->sym, p->sym->sym);
  if (cmp > 0) {
   parent = p;
   cur = &p->right;
  } else if (cmp < 0) {
   parent = p;
   cur = &p->left;
  } else {
   if (replace) {
    p->value = e;
    return 0;
   }
   return 1;
  }
 }
 if (replace)
  return 1;
 *cur = alloc_tree_node(parent, cur, sym, e);
 insert_case1(*cur);
 return 0;
}

variable_types: struct tree_node { enum tree_color { BLACK=0, RED=1 } color; struct tree_node *parent; struct tree_node **pparent; struct tree_node *left; struct tree_node *right; struct symbol { unsigned long tag; char sym[70]; } *sym; struct exp { unsigned long tag; } *value; } **

variable_types:
sym
struct symbol *

variable_types:
e
struct exp *

variable_types: replace int


dump

decompiled_code:
size_t __fastcall dump(__int64 a1)
{
fwrite("digraph heaptree{\n", 1uLL, 0x12uLL, stderr);
traverse(a1, (__int64 (*)(void))to_dot);
return fwrite("}\n", 1uLL, 2uLL, stderr);
}

canonical_decompiled_code:
size_t __fastcall func7(__int64 a1)
{
fwrite("digraph heaptree{\n", 1uLL, 0x12uLL, stderr);
func3(a1, (__int64 (*)(void))to_dot);
return fwrite("}\n", 1uLL, 2uLL, stderr);
}

original_code:
void dump(struct tree_node *root) {
 fprintf(stderr, "digraph heaptree{\n");
 traverse(root, to_dot);
 fprintf(stderr, "}\n");
}


decompiled_code:
__int64 __fastcall is_bool(_QWORD *a1)
{
__int64 result; // rax

result = 0LL;
if ( a1 )
result = (*a1 >> 4) & 1LL;
return result;
}

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

result = 0LL;
if ( a1 )
result = (*a1 >> 4) & 1LL;
return result;
}

original_code:
static inline int is_bool(struct exp *var) {
 return (var && (var->tag & (1<<4)));
}

variable_types:
var
struct exp { unsigned long tag; } *


decompiled_code:
__int64 __fastcall is_number(_QWORD *a1)
{
__int64 result; // rax

result = 0LL;
if ( a1 )
result = *a1 & 1LL;
return result;
}

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

result = 0LL;
if ( a1 )
result = *a1 & 1LL;
return result;
}

original_code:
static inline int is_number(struct exp *var) {
 return (var && (var->tag & (1<<0)));
}


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

result = 0LL;
if ( a1 )
result = *(_DWORD *)(a1 + 16) == 0;
return result;
}

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

result = 0LL;
if ( a1 )
result = *(_DWORD *)(a1 + 16) == 0;
return result;
}

original_code:
static inline int is_long(struct number *num) {
 return (num && num->type == LONG);
}

variable_types: struct number { unsigned long tag; union { long l_value; double d_value; }; enum num_type { LONG=0, DOUBLE=1 } type; } *


decompiled_code:
__int64 __fastcall is_symbol(_QWORD *a1)
{
__int64 result; // rax

result = 0LL;
if ( a1 )
result = (*a1 >> 1) & 1LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1)
{
__int64 result; // rax

result = 0LL;
if ( a1 )
result = (*a1 >> 1) & 1LL;
return result;
}

original_code:
static inline int is_symbol(struct exp *var) {
 return (var && (var->tag & (1<<1)));
}


decompiled_code:
__int64 __fastcall is_callable(_QWORD *a1)
{
__int64 result; // rax

result = 0LL;
if ( a1 )
result = (*a1 >> 3) & 1LL;
return result;
}

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

result = 0LL;
if ( a1 )
result = (*a1 >> 3) & 1LL;
return result;
}

original_code:
static inline int is_callable(struct exp *var) {
 return (var && (var->tag & (1<<3)));
}


decompiled_code:
__int64 __fastcall is_pair(_QWORD *a1)
{
__int64 result; // rax

result = 0LL;
if ( a1 )
result = (*a1 >> 2) & 1LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1)
{
__int64 result; // rax

result = 0LL;
if ( a1 )
result = (*a1 >> 2) & 1LL;
return result;
}

original_code:
static inline int is_pair(struct exp *var) {
 return (var && (var->tag & (1<<2)));
}


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

result = 0LL;
if ( a1 )
result = *(_DWORD *)(a1 + 32) == 0;
return result;
}

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

result = 0LL;
if ( a1 )
result = *(_DWORD *)(a1 + 32) == 0;
return result;
}

original_code:
static inline int is_builtin_syntax(struct callable *var) {
 return (var && (var->type == BUILTIN_SYNTAX));
}


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

result = 0LL;
if ( a1 )
result = *(_DWORD *)(a1 + 32) == 1;
return result;
}

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

result = 0LL;
if ( a1 )
result = *(_DWORD *)(a1 + 32) == 1;
return result;
}

original_code:
static inline int is_builtin_pro(struct callable *var) {
 return (var && (var->type == BUILTIN_PRO));
}


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

result = 0LL;
if ( a1 )
result = *(_DWORD *)(a1 + 32) == 2;
return result;
}

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

result = 0LL;
if ( a1 )
result = *(_DWORD *)(a1 + 32) == 2;
return result;
}

original_code:
static inline int is_lambda(struct callable *var) {
 return (var && (var->type == LAMBDA));
}