decompiled_code:
__int64 gtk_vimage_get_type()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_3 )
return g_define_type_id__volatile_3;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_3) )
{
v1 = gtk_vimage_get_type_once();
g_once_init_leave(&g_define_type_id__volatile_3, v1);
}
return g_define_type_id__volatile_3;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_3 )
return g_define_type_id__volatile_3;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_3) )
{
v1 = func1();
g_once_init_leave(&g_define_type_id__volatile_3, v1);
}
return g_define_type_id__volatile_3;
}

original_code: GType gtk_vimage_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); guint64 gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (gpointer) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { GType g_define_type_id = gtk_vimage_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }

canonical_original_code: unsigned long gtk_vimage_get_type() { static unsigned long g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); unsigned long gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (void *) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { unsigned long g_define_type_id = gtk_vimage_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }


repo: ElFeesho/OldCProjects

original_code:
void sonix_decompress_init(void)
{
 int i;
 int is_abs, val, len, unk;
 for (i = 0; i < 256; i++) {
  is_abs = 0;
  val = 0;
  len = 0;
  unk = 0;
  if ((i & 0x80) == 0) {
   val = 0;
   len = 1;
  }
  else if ((i & 0xE0) == 0x80) {
   val = +4;
   len = 3;
  }
  else if ((i & 0xE0) == 0xA0) {
   val = -4;
   len = 3;
  }
  else if ((i & 0xF0) == 0xD0) {
   val = +11;
   len = 4;
  }
  else if ((i & 0xF0) == 0xF0) {
   val = -11;
   len = 4;
  }
  else if ((i & 0xF8) == 0xC8) {
   val = +20;
   len = 5;
  }
  else if ((i & 0xFC) == 0xC0) {
   val = -20;
   len = 6;
  }
  else if ((i & 0xFC) == 0xC4) {
   val = 0;
   len = 8;
   unk = 1;
  }
  else if ((i & 0xF0) == 0xE0) {
   is_abs = 1;
   val = (i & 0x0F) << 4;
   len = 8;
  }
  table[i].is_abs = is_abs;
  table[i].val = val;
  table[i].len = len;
  table[i].unk = unk;
 }
 sonix_unknown = 0;
 init_done = 1;
}

canonical_original_code:
void sonix_decompress_init()
{
 int i;
 int is_abs; int val; int len; int unk;
 for (i = 0; i < 256; i++) {
  is_abs = 0;
  val = 0;
  len = 0;
  unk = 0;
  if ((i & 0x80) == 0) {
   val = 0;
   len = 1;
  }
  else if ((i & 0xE0) == 0x80) {
   val = +4;
   len = 3;
  }
  else if ((i & 0xE0) == 0xA0) {
   val = -4;
   len = 3;
  }
  else if ((i & 0xF0) == 0xD0) {
   val = +11;
   len = 4;
  }
  else if ((i & 0xF0) == 0xF0) {
   val = -11;
   len = 4;
  }
  else if ((i & 0xF8) == 0xC8) {
   val = +20;
   len = 5;
  }
  else if ((i & 0xFC) == 0xC0) {
   val = -20;
   len = 6;
  }
  else if ((i & 0xFC) == 0xC4) {
   val = 0;
   len = 8;
   unk = 1;
  }
  else if ((i & 0xF0) == 0xE0) {
   is_abs = 1;
   val = (i & 0x0F) << 4;
   len = 8;
  }
  table[i].is_abs = is_abs;
  table[i].val = val;
  table[i].len = len;
  table[i].unk = unk;
 }
 sonix_unknown = 0;
 init_done = 1;
}

variable_types: i int

variable_types: val int

variable_types: len int

variable_types: unk int

return_type: void


original_code:
int sonix_decompress(int width, int height, unsigned char *inp, unsigned char *outp)
{
 int row, col;
 int val;
 int bitpos;
 unsigned char code;
 unsigned char *addr;
 if (!init_done) {
  return -1;
 }
 bitpos = 0;
 for (row = 0; row < height; row++) {
  col = 0;
  if (row < 2) {
   addr = inp + (bitpos >> 3);
   code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7)));
   bitpos += 8;
   *outp++ = code;
   addr = inp + (bitpos >> 3);
   code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7)));
   bitpos += 8;
   *outp++ = code;
   col += 2;
  }
  while (col < width) {
   addr = inp + (bitpos >> 3);
   code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7)));
   bitpos += table[code].len;
   sonix_unknown += table[code].unk;
   val = table[code].val;
   if (!table[code].is_abs) {
    if (col < 2) {
     val += outp[-2*width];
    }
    else if (row < 2) {
     val += outp[-2];
    }
    else {
     val += (outp[-2] + outp[-2*width]) / 2;
    }
   }
   *outp++ = ((val)<0?0:((val)>255)?255:(val));
   col++;
  }
 }
 return 0;
}

canonical_original_code:
int sonix_decompress(int width, int height, unsigned char *inp, unsigned char *outp)
{
 int row; int col;
 int val;
 int bitpos;
 unsigned char code;
 unsigned char *addr;
 if (!init_done) {
  return -1;
 }
 bitpos = 0;
 for (row = 0; row < height; row++) {
  col = 0;
  if (row < 2) {
   addr = inp + (bitpos >> 3);
   code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7)));
   bitpos += 8;
   *outp++ = code;
   addr = inp + (bitpos >> 3);
   code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7)));
   bitpos += 8;
   *outp++ = code;
   col += 2;
  }
  while (col < width) {
   addr = inp + (bitpos >> 3);
   code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7)));
   bitpos += table[code].len;
   sonix_unknown += table[code].unk;
   val = table[code].val;
   if (!table[code].is_abs) {
    if (col < 2) {
     val += outp[-2*width];
    }
    else if (row < 2) {
     val += outp[-2];
    }
    else {
     val += (outp[-2] + outp[-2*width]) / 2;
    }
   }
   *outp++ = ((val)<0?0:((val)>255)?255:(val));
   col++;
  }
 }
 return 0;
}

variable_types: width int

variable_types: height int

variable_types:
inp
unsigned char *

variable_types:
outp
unsigned char *

variable_types: row int

variable_types: col int

variable_types: bitpos int

variable_types:
code
unsigned char

variable_types:
addr
unsigned char *

return_type: int


decompiled_code:
__int64 __fastcall strip_lines_tabs(char *s)
{
size_t v1; // rax
__int64 v2; // r12
size_t i; // rbx
char v4; // al

v1 = strlen(s);
v2 = g_malloc0(v1);
for ( i = 0LL; strlen(s) > i; ++i )
{
v4 = s[i];
if ( (unsigned __int8)(v4 - 9) < 2u )
v4 = 32;
*(_BYTE *)(v2 + i) = v4;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s)
{
size_t v1; // rax
__int64 v2; // r12
size_t i; // rbx
char v4; // al

v1 = strlen(s);
v2 = g_malloc0(v1);
for ( i = 0LL; strlen(s) > i; ++i )
{
v4 = s[i];
if ( (unsigned __int8)(v4 - 9) < 2u )
v4 = 32;
*(_BYTE *)(v2 + i) = v4;
}
return v2;
}

original_code:
gchar *strip_lines_tabs(gchar *string)
{
 gchar *return_string = g_malloc0(strlen(string));
 int i;
 for(i = 0; i<strlen(string);i++)
 {
  if(string[i]!='\n' && string[i]!='\t')
   return_string[i] = string[i];
  else
   return_string[i] = ' ';
 }
 return return_string;
}

canonical_original_code:
char *strip_lines_tabs(char *string)
{
 char *return_string = g_malloc0(strlen(string));
 int i;
 for(i = 0; i<strlen(string);i++)
 {
  if(string[i]!='\n' && string[i]!='\t')
   return_string[i] = string[i];
  else
   return_string[i] = ' ';
 }
 return return_string;
}

variable_types:
string
char *

return_type: char *


decompiled_code:
__int64 __fastcall input_keydown(int a1)
{
return *(unsigned __int8 *)(SDL_GetKeyState(0LL) + keymap[a1]);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
return *(unsigned __int8 *)(SDL_GetKeyState(0LL) + keymap[a1]);
}

original_code:
int input_keydown(int key)
{
 Uint8 *keys = SDL_GetKeyState(((void *)0));
 return keys[keymap[key]];
}

canonical_original_code:
int input_keydown(int key)
{
 unsigned char *keys = SDL_GetKeyState(((void *)0));
 return keys[keymap[key]];
}

variable_types: key int

variable_types:
keys
unsigned char *


decompiled_code:
__int64 song_eng_get_notes()
{
return note_list;
}

canonical_decompiled_code:
__int64 func2()
{
return note_list;
}

original_code:
song_note *song_eng_get_notes(void)
{
 return note_list;
}

canonical_original_code:
struct song_note *song_eng_get_notes()
{
 return note_list;
}

return_type: struct song_note { unsigned char colour; long t_off; unsigned char type; unsigned char played; void *next; } *


decompiled_code:
__int64 song_eng_get_speed()
{
return (unsigned int)(int)(float)(1000.0 * *(float *)&speed);
}

canonical_decompiled_code:
__int64 func3()
{
return (unsigned int)(int)(float)(1000.0 * *(float *)&speed);
}

original_code:
long int song_eng_get_speed(void)
{
 return speed*1000;
}

canonical_original_code:
long song_eng_get_speed()
{
 return speed*1000;
}

return_type: long


decompiled_code:
__int64 song_eng_get_song()
{
return song_file;
}

canonical_decompiled_code:
__int64 func4()
{
return song_file;
}

original_code:
char *song_eng_get_song(void)
{
 return song_file;
}

canonical_original_code:
char *song_eng_get_song()
{
 return song_file;
}


decompiled_code:
void __fastcall filelist_add(char *src, char *a2)
{
char *v2; // rbx
struct stat *v3; // rbp
void *v4; // r12
int v5; // ebp
size_t v6; // rax
int v7; // ebp
size_t v8; // rax
__int64 v9; // r12
__int64 v10; // r12
__int64 v11; // r12
__int64 v12; // r12
__int64 v13; // r12
__int64 v14; // rbp
__int64 v15; // r12
int v16; // ebp
size_t v17; // rax
int v18; // ebp
size_t v19; // rax

v2 = (char *)malloc(0x100uLL);
memset(v2, 0, 0x100uLL);
strcpy(v2, a2);
*(_WORD *)&v2[strlen(v2)] = 47;
strcat(v2, src);
v3 = (struct stat *)malloc(0x90uLL);
if ( lstat(v2, v3) == -1 )
{
fprintf(stderr, "Couldn't stat %s\n", v2);
exit(1);
}
if ( file_list )
{
v4 = malloc(0x40uLL);
*(_QWORD *)v4 = fname_format(src, a2, v3->st_mode, 0LL);
*((_QWORD *)v4 + 1) = user_format(v3->st_uid);
*((_QWORD *)v4 + 2) = group_format(v3->st_gid);
*((_QWORD *)v4 + 3) = size_format(v3->st_size);
*((_QWORD *)v4 + 4) = mode_format(v3->st_mode);
*((_QWORD *)v4 + 5) = time_format(&v3->st_mtim);
*((_QWORD *)v4 + 6) = nested_format(v2);
*((_QWORD *)v4 + 7) = file_list;
file_list = (__int64)v4;
v5 = filelist_user_len;
v6 = strlen(*((const char **)v4 + 1));
if ( v5 <= v6 )
v5 = v6;
filelist_user_len = v5;
v7 = filelist_group_len;
v8 = strlen(*((const char **)v4 + 2));
if ( v7 <= v8 )
v7 = v8;
filelist_group_len = v7;
}
else
{
file_list = (__int64)malloc(0x40uLL);
*(_QWORD *)file_list = fname_format(src, a2, v3->st_mode, 0LL);
v9 = file_list;
*(_QWORD *)(v9 + 8) = user_format(v3->st_uid);
v10 = file_list;
*(_QWORD *)(v10 + 16) = group_format(v3->st_gid);
v11 = file_list;
*(_QWORD *)(v11 + 24) = size_format(v3->st_size);
v12 = file_list;
*(_QWORD *)(v12 + 32) = mode_format(v3->st_mode);
v13 = file_list;
*(_QWORD *)(v13 + 40) = time_format(&v3->st_mtim);
v14 = file_list;
*(_QWORD *)(v14 + 48) = nested_format(v2);
v15 = file_list;
*(_QWORD *)(file_list + 56) = 0LL;
v16 = filelist_user_len;
v17 = strlen(*(const char **)(v15 + 8));
if ( v16 <= v17 )
v16 = v17;
filelist_user_len = v16;
v18 = filelist_group_len;
v19 = strlen(*(const char **)(v15 + 16));
if ( v18 <= v19 )
v18 = v19;
filelist_group_len = v18;
}
free(v2);
}

canonical_decompiled_code:
void __fastcall func0(char *src, char *a2)
{
char *v2; // rbx
struct stat *v3; // rbp
void *v4; // r12
int v5; // ebp
size_t v6; // rax
int v7; // ebp
size_t v8; // rax
__int64 v9; // r12
__int64 v10; // r12
__int64 v11; // r12
__int64 v12; // r12
__int64 v13; // r12
__int64 v14; // rbp
__int64 v15; // r12
int v16; // ebp
size_t v17; // rax
int v18; // ebp
size_t v19; // rax

v2 = (char *)malloc(0x100uLL);
memset(v2, 0, 0x100uLL);
strcpy(v2, a2);
*(_WORD *)&v2[strlen(v2)] = 47;
strcat(v2, src);
v3 = (struct stat *)malloc(0x90uLL);
if ( lstat(v2, v3) == -1 )
{
fprintf(stderr, "Couldn't stat %s\n", v2);
exit(1);
}
if ( file_list )
{
v4 = malloc(0x40uLL);
*(_QWORD *)v4 = fname_format(src, a2, v3->st_mode, 0LL);
*((_QWORD *)v4 + 1) = user_format(v3->st_uid);
*((_QWORD *)v4 + 2) = group_format(v3->st_gid);
*((_QWORD *)v4 + 3) = size_format(v3->st_size);
*((_QWORD *)v4 + 4) = mode_format(v3->st_mode);
*((_QWORD *)v4 + 5) = time_format(&v3->st_mtim);
*((_QWORD *)v4 + 6) = nested_format(v2);
*((_QWORD *)v4 + 7) = file_list;
file_list = (__int64)v4;
v5 = filelist_user_len;
v6 = strlen(*((const char **)v4 + 1));
if ( v5 <= v6 )
v5 = v6;
filelist_user_len = v5;
v7 = filelist_group_len;
v8 = strlen(*((const char **)v4 + 2));
if ( v7 <= v8 )
v7 = v8;
filelist_group_len = v7;
}
else
{
file_list = (__int64)malloc(0x40uLL);
*(_QWORD *)file_list = fname_format(src, a2, v3->st_mode, 0LL);
v9 = file_list;
*(_QWORD *)(v9 + 8) = user_format(v3->st_uid);
v10 = file_list;
*(_QWORD *)(v10 + 16) = group_format(v3->st_gid);
v11 = file_list;
*(_QWORD *)(v11 + 24) = size_format(v3->st_size);
v12 = file_list;
*(_QWORD *)(v12 + 32) = mode_format(v3->st_mode);
v13 = file_list;
*(_QWORD *)(v13 + 40) = time_format(&v3->st_mtim);
v14 = file_list;
*(_QWORD *)(v14 + 48) = nested_format(v2);
v15 = file_list;
*(_QWORD *)(file_list + 56) = 0LL;
v16 = filelist_user_len;
v17 = strlen(*(const char **)(v15 + 8));
if ( v16 <= v17 )
v16 = v17;
filelist_user_len = v16;
v18 = filelist_group_len;
v19 = strlen(*(const char **)(v15 + 16));
if ( v18 <= v19 )
v18 = v19;
filelist_group_len = v18;
}
free(v2);
}

original_code:
extern void filelist_add(char *name, char *root)
{
 char *actual_file = malloc(256);
 memset(actual_file,'\0',256);
 strcpy(actual_file,root);
 strcat(actual_file,"/");
 strcat(actual_file,name);
 struct stat *file_stat = malloc(sizeof(struct stat));
 if(lstat(actual_file,file_stat)==-1)
 {
  fprintf(stderr,"Couldn't stat %s\n",actual_file);
  exit(1);
 }
 if(!file_list)
 {
  file_list = malloc(sizeof(filelist_node_t));
  file_list->name = fname_format(name,root,file_stat->st_mode,0);
  file_list->user = user_format(file_stat->st_uid);
  file_list->group = group_format(file_stat->st_gid);
  file_list->size = size_format(file_stat->st_size);
  file_list->mode = mode_format(file_stat->st_mode);
  file_list->time = time_format(&file_stat->st_mtim.tv_sec);
  file_list->nested = nested_format(actual_file);
  file_list->next = ((void *)0);
  filelist_user_len = (filelist_user_len>strlen(file_list->user))?(filelist_user_len):(strlen(file_list->user));
  filelist_group_len = (filelist_group_len>strlen(file_list->group))?(filelist_group_len):(strlen(file_list->group));
 }
 else
 {
  filelist_node_t *temp = malloc(sizeof(filelist_node_t));
  temp->name = fname_format(name,root,file_stat->st_mode,0);
  temp->user = user_format(file_stat->st_uid);
  temp->group = group_format(file_stat->st_gid);
  temp->size = size_format(file_stat->st_size);
  temp->mode = mode_format(file_stat->st_mode);
  temp->time = time_format(&file_stat->st_mtim.tv_sec);
  temp->nested = nested_format(actual_file);
  temp->next = file_list;
  file_list = temp;
  filelist_user_len = (filelist_user_len>strlen(file_list->user))?(filelist_user_len):(strlen(file_list->user));
  filelist_group_len = (filelist_group_len>strlen(file_list->group))?(filelist_group_len):(strlen(file_list->group));
 }
 free(actual_file);
}

canonical_original_code:
extern void filelist_add(char *name, char *root)
{
 char *actual_file = malloc(256);
 memset(actual_file,'\0',256);
 strcpy(actual_file,root);
 strcat(actual_file,"/");
 strcat(actual_file,name);
 struct stat *file_stat = malloc(sizeof(struct stat));
 if(lstat(actual_file,file_stat)==-1)
 {
  fprintf(stderr,"Couldn't stat %s\n",actual_file);
  exit(1);
 }
 if(!file_list)
 {
  file_list = malloc(sizeof(filelist_node_t));
  file_list->name = fname_format(name,root,file_stat->st_mode,0);
  file_list->user = user_format(file_stat->st_uid);
  file_list->group = group_format(file_stat->st_gid);
  file_list->size = size_format(file_stat->st_size);
  file_list->mode = mode_format(file_stat->st_mode);
  file_list->time = time_format(&file_stat->st_mtim.tv_sec);
  file_list->nested = nested_format(actual_file);
  file_list->next = ((void *)0);
  filelist_user_len = (filelist_user_len>strlen(file_list->user))?(filelist_user_len):(strlen(file_list->user));
  filelist_group_len = (filelist_group_len>strlen(file_list->group))?(filelist_group_len):(strlen(file_list->group));
 }
 else
 {
  struct _filelist_t *temp = malloc(sizeof(filelist_node_t));
  temp->name = fname_format(name,root,file_stat->st_mode,0);
  temp->user = user_format(file_stat->st_uid);
  temp->group = group_format(file_stat->st_gid);
  temp->size = size_format(file_stat->st_size);
  temp->mode = mode_format(file_stat->st_mode);
  temp->time = time_format(&file_stat->st_mtim.tv_sec);
  temp->nested = nested_format(actual_file);
  temp->next = file_list;
  file_list = temp;
  filelist_user_len = (filelist_user_len>strlen(file_list->user))?(filelist_user_len):(strlen(file_list->user));
  filelist_group_len = (filelist_group_len>strlen(file_list->group))?(filelist_group_len):(strlen(file_list->group));
 }
 free(actual_file);
}

variable_types:
name
char *

variable_types:
root
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]; } *

variable_types: struct _filelist_t { char *name; char *user; char *group; char *size; char *mode; char *time; char *nested; struct _filelist_t *next; } *

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:
int filelist_print()
{
char *v0; // rbp
int result; // eax
_QWORD *v2; // rbx

v0 = (char *)malloc(0x20uLL);
*(_QWORD *)v0 = 0LL;
*((_QWORD *)v0 + 1) = 0LL;
*((_QWORD *)v0 + 2) = 0LL;
*((_QWORD *)v0 + 3) = 0LL;
result = sprintf(
v0,
"%%s %%%ds %%-%ds %%4s %%s %%s\x1B[33;0m %%s\n",
(unsigned int)filelist_user_len,
(unsigned int)filelist_group_len);
v2 = (_QWORD *)file_list;
if ( file_list )
{
do
{
result = printf(v0, v2[4], v2[1], v2[2], v2[3], v2[5], *v2, v2[6]);
v2 = (_QWORD *)v2[7];
}
while ( v2 );
}
return result;
}

canonical_decompiled_code:
int func1()
{
char *v0; // rbp
int result; // eax
_QWORD *v2; // rbx

v0 = (char *)malloc(0x20uLL);
*(_QWORD *)v0 = 0LL;
*((_QWORD *)v0 + 1) = 0LL;
*((_QWORD *)v0 + 2) = 0LL;
*((_QWORD *)v0 + 3) = 0LL;
result = sprintf(
v0,
"%%s %%%ds %%-%ds %%4s %%s %%s\x1B[33;0m %%s\n",
(unsigned int)filelist_user_len,
(unsigned int)filelist_group_len);
v2 = (_QWORD *)file_list;
if ( file_list )
{
do
{
result = printf(v0, v2[4], v2[1], v2[2], v2[3], v2[5], *v2, v2[6]);
v2 = (_QWORD *)v2[7];
}
while ( v2 );
}
return result;
}

original_code:
extern void filelist_print()
{
 char *format = malloc(32);
 memset(format,'\0',32);
 sprintf(format,"%%s %%%ds %%-%ds %%4s %%s %%s\x1b[33;0m %%s\n",filelist_user_len, filelist_group_len);
 filelist_node_t *temp = file_list;
 while(temp!=((void *)0))
 {
  printf(format,temp->mode, temp->user, temp->group, temp->size, temp->time, temp->name, temp->nested);
  temp = temp->next;
 }
}

canonical_original_code:
extern void filelist_print()
{
 char *format = malloc(32);
 memset(format,'\0',32);
 sprintf(format,"%%s %%%ds %%-%ds %%4s %%s %%s\x1b[33;0m %%s\n",filelist_user_len, filelist_group_len);
 struct _filelist_t *temp = file_list;
 while(temp!=((void *)0))
 {
  printf(format,temp->mode, temp->user, temp->group, temp->size, temp->time, temp->name, temp->nested);
  temp = temp->next;
 }
}

variable_types:
format
char *

user_defined_types: struct _filelist_t { char *name; char *user; char *group; char *size; char *mode; char *time; char *nested; struct _filelist_t *next; }


decode

original_code:
static gboolean decode(MimCtx *ctx, gboolean is_pframe)
{
    gint y, x, i, j, chrom_ch, *bptr, base_offset, offset;
    gint dct_block[64];
    guchar *src, *dst, *p;
    guint32 bit;
    p = ctx->cur_frame_buf + ctx->y_size;
    memset(p, 128, 2 * ctx->crcb_size);
    for (y = 0; y < ctx->num_vblocks_y; y++) {
        base_offset = ctx->y_stride * 8 * y;
        src = ctx->prev_frame_buf + base_offset;
        dst = ctx->cur_frame_buf + base_offset;
        for (x = 0; x < ctx->num_hblocks_y; x++) {
            if (is_pframe)
                bit = _read_bits(ctx, 1);
            else
                bit = 0;
            if (bit == 0) {
                if (is_pframe)
                    bit = _read_bits(ctx, 1);
                if (bit == 0) {
                    if (_vlc_decode_block(ctx, dct_block, ctx->num_coeffs) == (0)) {
                        return (0);
                    }
                    _idct_dequant_block(ctx, dct_block, 0);
                    bptr = dct_block;
                    for (i = 0; i < 8; i++) {
                        offset = ctx->y_stride * i;
                        for (j = 0; j < 8; j++) {
                            guint v;
                            if (bptr[j] <= 255)
                                v = (bptr[j] >= 0) ? bptr[j] : 0;
                            else
                                v = 255;
                            *(dst + offset + j) = v;
                        }
                        bptr += 8;
                    }
                } else {
                    guint32 backref;
                    backref = _read_bits(ctx, 4);
                    p = ctx->buf_ptrs[(ctx->ptr_index + backref) % 16];
                    p += base_offset + (x * 8);
                    for (i = 0; i < 8; i++) {
                        offset = ctx->y_stride * i;
                        memcpy(dst + offset, p + offset, 8);
                    }
                }
            } else {
                for (i = 0; i < 8; i++) {
                    offset = ctx->y_stride * i;
                    memcpy(dst + offset, src + offset, 8);
                }
            }
            src += 8;
            dst += 8;
        }
    }
    for (chrom_ch = 0; chrom_ch < 2; chrom_ch++) {
        base_offset = ctx->y_size + (ctx->crcb_size * chrom_ch);
        for (y = 0; y < ctx->num_vblocks_cbcr; y++) {
            guint num_rows = 8;
            if (y + 1 == ctx->num_vblocks_cbcr && ctx->frame_height % 16 != 0)
                num_rows = 4;
            offset = base_offset + (ctx->crcb_stride * 8 * y);
            src = ctx->prev_frame_buf + offset;
            dst = ctx->cur_frame_buf + offset;
            for (x = 0; x < ctx->num_hblocks_cbcr; x++) {
                if (is_pframe)
                    bit = _read_bits(ctx, 1);
                else
                    bit = 1;
                if (bit == 1) {
                    if (_vlc_decode_block(ctx, dct_block, ctx->num_coeffs) == (0)) {
                        p = ctx->cur_frame_buf + ctx->y_size;
                        memset(p, 128, ctx->crcb_size * 2);
                        return (0);
                    }
                    _idct_dequant_block(ctx, dct_block, 1);
                    for (i = 0; i < num_rows; i++) {
                        p = dst + (ctx->crcb_stride * i);
                        for (j = 0; j < 8; j++)
                            p[j] = dct_block[(i * 8) + j];
                    }
                } else {
                    for (i = 0; i < num_rows; i++) {
                        offset = ctx->crcb_stride * i;
                        memcpy(dst + offset, src + offset, 8);
                    }
                }
                src += 8;
                dst += 8;
            }
        }
    }
    ctx->prev_frame_buf = ctx->buf_ptrs[ctx->ptr_index];
    memcpy(ctx->prev_frame_buf, ctx->cur_frame_buf,
           ctx->y_size + (ctx->crcb_size * 2));
    if (--ctx->ptr_index < 0)
        ctx->ptr_index = 15;
    _deblock(ctx->cur_frame_buf,
             ctx->y_stride, ctx->y_row_count);
    _deblock(ctx->cur_frame_buf + ctx->y_size,
             ctx->crcb_stride, ctx->crcb_row_count);
    _deblock(ctx->cur_frame_buf + ctx->y_size + ctx->crcb_size,
             ctx->crcb_stride, ctx->crcb_row_count);
    return (!(0));
}

canonical_original_code:
static int decode(struct _MimCtx *ctx, int is_pframe)
{
    int y; int x; int i; int j; int chrom_ch; int *bptr; int base_offset; int offset;
    int dct_block[64];
    unsigned char *src; unsigned char *dst; unsigned char *p;
    unsigned int bit;
    p = ctx->cur_frame_buf + ctx->y_size;
    memset(p, 128, 2 * ctx->crcb_size);
    for (y = 0; y < ctx->num_vblocks_y; y++) {
        base_offset = ctx->y_stride * 8 * y;
        src = ctx->prev_frame_buf + base_offset;
        dst = ctx->cur_frame_buf + base_offset;
        for (x = 0; x < ctx->num_hblocks_y; x++) {
            if (is_pframe)
                bit = _read_bits(ctx, 1);
            else
                bit = 0;
            if (bit == 0) {
                if (is_pframe)
                    bit = _read_bits(ctx, 1);
                if (bit == 0) {
                    if (_vlc_decode_block(ctx, dct_block, ctx->num_coeffs) == (0)) {
                        return (0);
                    }
                    _idct_dequant_block(ctx, dct_block, 0);
                    bptr = dct_block;
                    for (i = 0; i < 8; i++) {
                        offset = ctx->y_stride * i;
                        for (j = 0; j < 8; j++) {
                            unsigned int v;
                            if (bptr[j] <= 255)
                                v = (bptr[j] >= 0) ? bptr[j] : 0;
                            else
                                v = 255;
                            *(dst + offset + j) = v;
                        }
                        bptr += 8;
                    }
                } else {
                    unsigned int backref;
                    backref = _read_bits(ctx, 4);
                    p = ctx->buf_ptrs[(ctx->ptr_index + backref) % 16];
                    p += base_offset + (x * 8);
                    for (i = 0; i < 8; i++) {
                        offset = ctx->y_stride * i;
                        memcpy(dst + offset, p + offset, 8);
                    }
                }
            } else {
                for (i = 0; i < 8; i++) {
                    offset = ctx->y_stride * i;
                    memcpy(dst + offset, src + offset, 8);
                }
            }
            src += 8;
            dst += 8;
        }
    }
    for (chrom_ch = 0; chrom_ch < 2; chrom_ch++) {
        base_offset = ctx->y_size + (ctx->crcb_size * chrom_ch);
        for (y = 0; y < ctx->num_vblocks_cbcr; y++) {
            unsigned int num_rows = 8;
            if (y + 1 == ctx->num_vblocks_cbcr && ctx->frame_height % 16 != 0)
                num_rows = 4;
            offset = base_offset + (ctx->crcb_stride * 8 * y);
            src = ctx->prev_frame_buf + offset;
            dst = ctx->cur_frame_buf + offset;
            for (x = 0; x < ctx->num_hblocks_cbcr; x++) {
                if (is_pframe)
                    bit = _read_bits(ctx, 1);
                else
                    bit = 1;
                if (bit == 1) {
                    if (_vlc_decode_block(ctx, dct_block, ctx->num_coeffs) == (0)) {
                        p = ctx->cur_frame_buf + ctx->y_size;
                        memset(p, 128, ctx->crcb_size * 2);
                        return (0);
                    }
                    _idct_dequant_block(ctx, dct_block, 1);
                    for (i = 0; i < num_rows; i++) {
                        p = dst + (ctx->crcb_stride * i);
                        for (j = 0; j < 8; j++)
                            p[j] = dct_block[(i * 8) + j];
                    }
                } else {
                    for (i = 0; i < num_rows; i++) {
                        offset = ctx->crcb_stride * i;
                        memcpy(dst + offset, src + offset, 8);
                    }
                }
                src += 8;
                dst += 8;
            }
        }
    }
    ctx->prev_frame_buf = ctx->buf_ptrs[ctx->ptr_index];
    memcpy(ctx->prev_frame_buf, ctx->cur_frame_buf,
           ctx->y_size + (ctx->crcb_size * 2));
    if (--ctx->ptr_index < 0)
        ctx->ptr_index = 15;
    _deblock(ctx->cur_frame_buf,
             ctx->y_stride, ctx->y_row_count);
    _deblock(ctx->cur_frame_buf + ctx->y_size,
             ctx->crcb_stride, ctx->crcb_row_count);
    _deblock(ctx->cur_frame_buf + ctx->y_size + ctx->crcb_size,
             ctx->crcb_stride, ctx->crcb_row_count);
    return (!(0));
}

variable_types: struct _MimCtx { int encoder_initialized; int decoder_initialized; int frame_width; int frame_height; int quality; int num_coeffs; int y_stride; int y_row_count; int y_size; int crcb_stride; int crcb_row_count; int crcb_size; int num_vblocks_y; int num_hblocks_y; int num_vblocks_cbcr; int num_hblocks_cbcr; unsigned char *cur_frame_buf; unsigned char *prev_frame_buf; char vlcdec_lookup[2296]; char *data_buffer; unsigned int data_index; unsigned int cur_chunk; int cur_chunk_len; unsigned int *chunk_ptr; int read_odd; int frame_num; int ptr_index; unsigned char *buf_ptrs[16]; } *

variable_types: y int

variable_types: x int

variable_types: i int

variable_types: j int

variable_types:
bptr
int *

variable_types: offset int

variable_types:
src
unsigned char *

variable_types:
dst
unsigned char *

variable_types:
p
unsigned char *

variable_types:
bit
unsigned int

variable_types:
v
unsigned int

variable_types:
backref
unsigned int


original_code:
gboolean mimic_decode_frame(MimCtx *ctx,
                            const guchar *input_buffer,
                            guchar *output_buffer)
{
    gboolean result, is_pframe;
    guchar *input_y, *input_cr, *input_cb;
    gint width, height;
    if (ctx == ((void *)0) || input_buffer == ((void *)0) || output_buffer == ((void *)0))
    {
        return (0);
    }
    if (!ctx->decoder_initialized)
        return (0);
    width = (((guint16) (*((guint16 *) (input_buffer + 4)))));
    height = (((guint16) (*((guint16 *) (input_buffer + 6)))));
    if (width != ctx->frame_width ||
        height != ctx->frame_height)
    {
        return (0);
    }
    ctx->frame_num++;
    ctx->quality = (((guint16) (*((guint16 *) (input_buffer + 2)))));
    is_pframe = (((guint32) (*((guint32 *) (input_buffer + 12)))));
    ctx->num_coeffs = input_buffer[16];
    ctx->data_buffer = (gchar *) (input_buffer + 20);
    ctx->data_index = 0;
    ctx->cur_chunk_len = 16;
    ctx->read_odd = (0);
    if (!(is_pframe && ctx->prev_frame_buf == ((void *)0)))
        result = decode(ctx, is_pframe);
    else
        result = (0);
    input_y = ctx->cur_frame_buf;
    input_cr = ctx->cur_frame_buf + ctx->y_size;
    input_cb = ctx->cur_frame_buf + ctx->y_size + ctx->crcb_size;
    _yuv_to_rgb(input_y,
                input_cb,
                input_cr,
                output_buffer,
                ctx->frame_width,
                ctx->frame_height);
    return result;
}

canonical_original_code:
int mimic_decode_frame(struct _MimCtx *ctx, unsigned char *input_buffer, unsigned char *output_buffer)
{
    int result; int is_pframe;
    unsigned char *input_y; unsigned char *input_cr; unsigned char *input_cb;
    int width; int height;
    if (ctx == ((void *)0) || input_buffer == ((void *)0) || output_buffer == ((void *)0))
    {
        return (0);
    }
    if (!ctx->decoder_initialized)
        return (0);
    width = (((guint16) (*((unsigned short *) (input_buffer + 4)))));
    height = (((guint16) (*((unsigned short *) (input_buffer + 6)))));
    if (width != ctx->frame_width ||
        height != ctx->frame_height)
    {
        return (0);
    }
    ctx->frame_num++;
    ctx->quality = (((guint16) (*((unsigned short *) (input_buffer + 2)))));
    is_pframe = (((guint32) (*((unsigned int *) (input_buffer + 12)))));
    ctx->num_coeffs = input_buffer[16];
    ctx->data_buffer = (char *) (input_buffer + 20);
    ctx->data_index = 0;
    ctx->cur_chunk_len = 16;
    ctx->read_odd = (0);
    if (!(is_pframe && ctx->prev_frame_buf == ((void *)0)))
        result = decode(ctx, is_pframe);
    else
        result = (0);
    input_y = ctx->cur_frame_buf;
    input_cr = ctx->cur_frame_buf + ctx->y_size;
    input_cb = ctx->cur_frame_buf + ctx->y_size + ctx->crcb_size;
    _yuv_to_rgb(input_y,
                input_cb,
                input_cr,
                output_buffer,
                ctx->frame_width,
                ctx->frame_height);
    return result;
}

variable_types: result int

variable_types: width int

variable_types: height int

user_defined_types: struct _MimCtx { int encoder_initialized; int decoder_initialized; int frame_width; int frame_height; int quality; int num_coeffs; int y_stride; int y_row_count; int y_size; int crcb_stride; int crcb_row_count; int crcb_size; int num_vblocks_y; int num_hblocks_y; int num_vblocks_cbcr; int num_hblocks_cbcr; unsigned char *cur_frame_buf; unsigned char *prev_frame_buf; char vlcdec_lookup[2296]; char *data_buffer; unsigned int data_index; unsigned int cur_chunk; int cur_chunk_len; unsigned int *chunk_ptr; int read_odd; int frame_num; int ptr_index; unsigned char *buf_ptrs[16]; }


decompiled_code:
int wiiuse_shutdown()
{
int result; // eax

if ( wiiuse_mod )
{
result = dlclose(wiiuse_mod);
wiiuse_api = 0LL;
wiiuse_init = 0LL;
wiiuse_disconnected = 0LL;
wiiuse_rumble = 0LL;
wiiuse_toggle_rumble = 0LL;
wiiuse_set_leds = 0LL;
wiiuse_motion_sensing = 0LL;
wiiuse_read_data = 0LL;
wiiuse_write_data = 0LL;
wiiuse_status = 0LL;
wiiuse_get_by_id = 0LL;
wiiuse_set_flags = 0LL;
wiiuse_set_smooth_alpha = 0LL;
wiiuse_set_ir = 0LL;
wiiuse_set_ir_vres = 0LL;
wiiuse_set_ir_position = 0LL;
wiiuse_set_aspect_ratio = 0LL;
wiiuse_set_bluetooth_stack = 0LL;
wiiuse_set_orient_threshold = 0LL;
wiiuse_find = 0LL;
wiiuse_connect = 0LL;
wiiuse_disconnect = 0LL;
wiiuse_poll = 0LL;
}
return result;
}

canonical_decompiled_code:
int func0()
{
int result; // eax

if ( wiiuse_mod )
{
result = dlclose(wiiuse_mod);
wiiuse_api = 0LL;
wiiuse_init = 0LL;
wiiuse_disconnected = 0LL;
wiiuse_rumble = 0LL;
wiiuse_toggle_rumble = 0LL;
wiiuse_set_leds = 0LL;
wiiuse_motion_sensing = 0LL;
wiiuse_read_data = 0LL;
wiiuse_write_data = 0LL;
wiiuse_status = 0LL;
wiiuse_get_by_id = 0LL;
wiiuse_set_flags = 0LL;
wiiuse_set_smooth_alpha = 0LL;
wiiuse_set_ir = 0LL;
wiiuse_set_ir_vres = 0LL;
wiiuse_set_ir_position = 0LL;
wiiuse_set_aspect_ratio = 0LL;
wiiuse_set_bluetooth_stack = 0LL;
wiiuse_set_orient_threshold = 0LL;
wiiuse_find = 0LL;
wiiuse_connect = 0LL;
wiiuse_disconnect = 0LL;
wiiuse_poll = 0LL;
}
return result;
}

original_code:
void wiiuse_shutdown() {
 if (!wiiuse_mod)
  return;
 dlclose(wiiuse_mod);
 wiiuse_api = ((void *)0);
 wiiuse_init = ((void *)0);
 wiiuse_disconnected = ((void *)0);
 wiiuse_rumble = ((void *)0);
 wiiuse_toggle_rumble = ((void *)0);
 wiiuse_set_leds = ((void *)0);
 wiiuse_motion_sensing = ((void *)0);
 wiiuse_read_data = ((void *)0);
 wiiuse_write_data = ((void *)0);
 wiiuse_status = ((void *)0);
 wiiuse_get_by_id = ((void *)0);
 wiiuse_set_flags = ((void *)0);
 wiiuse_set_smooth_alpha = ((void *)0);
 wiiuse_set_ir = ((void *)0);
 wiiuse_set_ir_vres = ((void *)0);
 wiiuse_set_ir_position = ((void *)0);
 wiiuse_set_aspect_ratio = ((void *)0);
 wiiuse_set_bluetooth_stack = ((void *)0);
 wiiuse_set_orient_threshold = ((void *)0);
 wiiuse_find = ((void *)0);
 wiiuse_connect = ((void *)0);
 wiiuse_disconnect = ((void *)0);
 wiiuse_poll = ((void *)0);
}


decompiled_code:
void *__fastcall wiiuse_startup(const char *a1)
{
__int64 v1; // rbx
void *result; // rax
void (__fastcall *v3)(__int64 *); // rax

v1 = wiiuse_api;
if ( wiiuse_api )
return *(void **)wiiuse_api;
if ( !a1 )
return 0LL;
result = dlopen(a1, 2);
wiiuse_mod = result;
if ( result )
{
v3 = (void (__fastcall *)(__int64 *))dlsym(result, "wiiuse_main");
if ( v3 && (v3(&wiiuse_api), *(_DWORD *)(wiiuse_api + 8) == 8) )
{
wiiuse_init = *(_QWORD *)(wiiuse_api + 16);
wiiuse_disconnected = *(_QWORD *)(wiiuse_api + 24);
wiiuse_rumble = *(_QWORD *)(wiiuse_api + 32);
wiiuse_toggle_rumble = *(_QWORD *)(wiiuse_api + 40);
wiiuse_set_leds = *(_QWORD *)(wiiuse_api + 48);
wiiuse_motion_sensing = *(_QWORD *)(wiiuse_api + 56);
wiiuse_read_data = *(_QWORD *)(wiiuse_api + 64);
wiiuse_write_data = *(_QWORD *)(wiiuse_api + 72);
wiiuse_status = *(_QWORD *)(wiiuse_api + 80);
wiiuse_get_by_id = *(_QWORD *)(wiiuse_api + 88);
wiiuse_set_flags = *(_QWORD *)(wiiuse_api + 96);
wiiuse_set_smooth_alpha = *(_QWORD *)(wiiuse_api + 104);
wiiuse_set_ir = *(_QWORD *)(wiiuse_api + 112);
wiiuse_set_ir_vres = *(_QWORD *)(wiiuse_api + 120);
wiiuse_set_ir_position = *(_QWORD *)(wiiuse_api + 128);
wiiuse_set_aspect_ratio = *(_QWORD *)(wiiuse_api + 136);
wiiuse_set_bluetooth_stack = *(_QWORD *)(wiiuse_api + 144);
wiiuse_set_orient_threshold = *(_QWORD *)(wiiuse_api + 152);
wiiuse_find = *(_QWORD *)(wiiuse_api + 160);
wiiuse_connect = *(_QWORD *)(wiiuse_api + 168);
wiiuse_disconnect = *(_QWORD *)(wiiuse_api + 176);
wiiuse_poll = *(_QWORD *)(wiiuse_api + 184);
result = *(void **)wiiuse_api;
}
else
{
wiiuse_shutdown();
result = (void *)v1;
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(const char *a1)
{
__int64 v1; // rbx
void *result; // rax
void (__fastcall *v3)(__int64 *); // rax

v1 = wiiuse_api;
if ( wiiuse_api )
return *(void **)wiiuse_api;
if ( !a1 )
return 0LL;
result = dlopen(a1, 2);
wiiuse_mod = result;
if ( result )
{
v3 = (void (__fastcall *)(__int64 *))dlsym(result, "wiiuse_main");
if ( v3 && (v3(&wiiuse_api), *(_DWORD *)(wiiuse_api + 8) == 8) )
{
wiiuse_init = *(_QWORD *)(wiiuse_api + 16);
wiiuse_disconnected = *(_QWORD *)(wiiuse_api + 24);
wiiuse_rumble = *(_QWORD *)(wiiuse_api + 32);
wiiuse_toggle_rumble = *(_QWORD *)(wiiuse_api + 40);
wiiuse_set_leds = *(_QWORD *)(wiiuse_api + 48);
wiiuse_motion_sensing = *(_QWORD *)(wiiuse_api + 56);
wiiuse_read_data = *(_QWORD *)(wiiuse_api + 64);
wiiuse_write_data = *(_QWORD *)(wiiuse_api + 72);
wiiuse_status = *(_QWORD *)(wiiuse_api + 80);
wiiuse_get_by_id = *(_QWORD *)(wiiuse_api + 88);
wiiuse_set_flags = *(_QWORD *)(wiiuse_api + 96);
wiiuse_set_smooth_alpha = *(_QWORD *)(wiiuse_api + 104);
wiiuse_set_ir = *(_QWORD *)(wiiuse_api + 112);
wiiuse_set_ir_vres = *(_QWORD *)(wiiuse_api + 120);
wiiuse_set_ir_position = *(_QWORD *)(wiiuse_api + 128);
wiiuse_set_aspect_ratio = *(_QWORD *)(wiiuse_api + 136);
wiiuse_set_bluetooth_stack = *(_QWORD *)(wiiuse_api + 144);
wiiuse_set_orient_threshold = *(_QWORD *)(wiiuse_api + 152);
wiiuse_find = *(_QWORD *)(wiiuse_api + 160);
wiiuse_connect = *(_QWORD *)(wiiuse_api + 168);
wiiuse_disconnect = *(_QWORD *)(wiiuse_api + 176);
wiiuse_poll = *(_QWORD *)(wiiuse_api + 184);
result = *(void **)wiiuse_api;
}
else
{
func0();
result = (void *)v1;
}
}
return result;
}

original_code:
const char* wiiuse_startup(char* wiiuse_file) {
 entry_func_t entry_func = ((void *)0);
 if (wiiuse_api)
  return wiiuse_api->version;
 if (!wiiuse_file)
  return ((void *)0);
 wiiuse_mod = dlopen(wiiuse_file, 0x00002);
 if (!wiiuse_mod)
  return ((void *)0);
 entry_func = (entry_func_t)dlsym(wiiuse_mod, "wiiuse_main");
 if (!entry_func) {
  wiiuse_shutdown();
  return ((void *)0);
 }
 entry_func(&wiiuse_api);
 if (wiiuse_api->api_version != 8) {
  wiiuse_shutdown();
  return ((void *)0);
 }
 wiiuse_init = wiiuse_api->_wiiuse_init;
 wiiuse_disconnected = wiiuse_api->_wiiuse_disconnected;
 wiiuse_rumble = wiiuse_api->_wiiuse_rumble;
 wiiuse_toggle_rumble = wiiuse_api->_wiiuse_toggle_rumble;
 wiiuse_set_leds = wiiuse_api->_wiiuse_set_leds;
 wiiuse_motion_sensing = wiiuse_api->_wiiuse_motion_sensing;
 wiiuse_read_data = wiiuse_api->_wiiuse_read_data;
 wiiuse_write_data = wiiuse_api->_wiiuse_write_data;
 wiiuse_status = wiiuse_api->_wiiuse_status;
 wiiuse_get_by_id = wiiuse_api->_wiiuse_get_by_id;
 wiiuse_set_flags = wiiuse_api->_wiiuse_set_flags;
 wiiuse_set_smooth_alpha = wiiuse_api->_wiiuse_set_smooth_alpha;
 wiiuse_set_ir = wiiuse_api->_wiiuse_set_ir;
 wiiuse_set_ir_vres = wiiuse_api->_wiiuse_set_ir_vres;
 wiiuse_set_ir_position = wiiuse_api->_wiiuse_set_ir_position;
 wiiuse_set_aspect_ratio = wiiuse_api->_wiiuse_set_aspect_ratio;
 wiiuse_set_bluetooth_stack = wiiuse_api->_wiiuse_set_bluetooth_stack;
 wiiuse_set_orient_threshold = wiiuse_api->_wiiuse_set_orient_threshold;
 wiiuse_find = wiiuse_api->_wiiuse_find;
 wiiuse_connect = wiiuse_api->_wiiuse_connect;
 wiiuse_disconnect = wiiuse_api->_wiiuse_disconnect;
 wiiuse_poll = wiiuse_api->_wiiuse_poll;
 return wiiuse_api->version;
}

canonical_original_code:
char *wiiuse_startup(char *wiiuse_file) {
 int (*entry_func)(struct wiiuse_api_t **) = ((void *)0);
 if (wiiuse_api)
  return wiiuse_api->version;
 if (!wiiuse_file)
  return ((void *)0);
 wiiuse_mod = dlopen(wiiuse_file, 0x00002);
 if (!wiiuse_mod)
  return ((void *)0);
 entry_func = (int (*)(struct wiiuse_api_t **))dlsym(wiiuse_mod, "wiiuse_main");
 if (!entry_func) {
  wiiuse_shutdown();
  return ((void *)0);
 }
 entry_func(&wiiuse_api);
 if (wiiuse_api->api_version != 8) {
  wiiuse_shutdown();
  return ((void *)0);
 }
 wiiuse_init = wiiuse_api->_wiiuse_init;
 wiiuse_disconnected = wiiuse_api->_wiiuse_disconnected;
 wiiuse_rumble = wiiuse_api->_wiiuse_rumble;
 wiiuse_toggle_rumble = wiiuse_api->_wiiuse_toggle_rumble;
 wiiuse_set_leds = wiiuse_api->_wiiuse_set_leds;
 wiiuse_motion_sensing = wiiuse_api->_wiiuse_motion_sensing;
 wiiuse_read_data = wiiuse_api->_wiiuse_read_data;
 wiiuse_write_data = wiiuse_api->_wiiuse_write_data;
 wiiuse_status = wiiuse_api->_wiiuse_status;
 wiiuse_get_by_id = wiiuse_api->_wiiuse_get_by_id;
 wiiuse_set_flags = wiiuse_api->_wiiuse_set_flags;
 wiiuse_set_smooth_alpha = wiiuse_api->_wiiuse_set_smooth_alpha;
 wiiuse_set_ir = wiiuse_api->_wiiuse_set_ir;
 wiiuse_set_ir_vres = wiiuse_api->_wiiuse_set_ir_vres;
 wiiuse_set_ir_position = wiiuse_api->_wiiuse_set_ir_position;
 wiiuse_set_aspect_ratio = wiiuse_api->_wiiuse_set_aspect_ratio;
 wiiuse_set_bluetooth_stack = wiiuse_api->_wiiuse_set_bluetooth_stack;
 wiiuse_set_orient_threshold = wiiuse_api->_wiiuse_set_orient_threshold;
 wiiuse_find = wiiuse_api->_wiiuse_find;
 wiiuse_connect = wiiuse_api->_wiiuse_connect;
 wiiuse_disconnect = wiiuse_api->_wiiuse_disconnect;
 wiiuse_poll = wiiuse_api->_wiiuse_poll;
 return wiiuse_api->version;
}

variable_types: int (*)(struct wiiuse_api_t { char *version; int api_version; struct wiimote_t { int unid; struct bdaddr_t { unsigned char b[6]; } bdaddr; char bdaddr_str[18]; int out_sock; int in_sock; int state; int leds; int flags; void (*event_cb)(struct wiimote_t *wm); void (*dis_cb)(struct wiimote_t *wm); void (*stat_cb)(struct wiimote_t *wm, int attachment, int speaker, int ir, int led[4], float battery_level); unsigned char handshake_state; struct read_req_t { void (*cb)(struct wiimote_t *wm, unsigned char *data, unsigned short len); unsigned char *buf; unsigned int addr; unsigned short size; unsigned short wait; struct read_req_t *next; } *read_req; struct accel_t { struct vec3b_t { unsigned char x; } cal_zero; struct vec3b_t cal_g; float st_roll; float st_pitch; float st_alpha; } accel_calib; struct expansion_t { enum { EXP_NONE=0, EXP_NUNCHUK=1, EXP_CLASSIC=2 } type; union { struct nunchuk_t { struct accel_t accel_calib; struct joystick_t { struct vec2b_t { unsigned char x; } max; struct vec2b_t min; struct vec2b_t center; float ang; float mag; } js; int *flags; unsigned char btns; unsigned char btns_held; unsigned char btns_released; struct vec3b_t accel; struct orient_t { float roll; float pitch; float yaw; } orient; struct gforce_t { float x; } gforce; } nunchuk; struct classic_ctrl_t { short btns; short btns_held; short btns_released; float r_shoulder; float l_shoulder; struct joystick_t ljs; struct joystick_t rjs; } classic; }; } exp; struct vec3b_t accel; struct orient_t orient; struct gforce_t gforce; struct ir_t { struct ir_dot_t { unsigned char visible; unsigned int x; unsigned int y; short rx; short ry; unsigned char order; unsigned char size; } dot[4]; unsigned char num_dots; enum aspect_t { WIIUSE_ASPECT_4_3=0, WIIUSE_ASPECT_16_9=1 } aspect; enum ir_position_t { WIIUSE_IR_ABOVE=0, WIIUSE_IR_BELOW=1 } pos; unsigned int vres[2]; int offset[2]; int state; int ax; int ay; int x; int y; float distance; float z; } ir; unsigned short btns; unsigned short btns_held; unsigned short btns_released; float orient_threshold; struct wiimote_state_t { float exp_ljs_ang; float exp_rjs_ang; float exp_ljs_mag; float exp_rjs_mag; unsigned char exp_btns; struct orient_t exp_orient; float exp_r_shoulder; float exp_l_shoulder; int ir_ax; int ir_ay; float ir_distance; struct orient_t orient; unsigned short btns; } lstate; unsigned char event[32]; } **(*_wiiuse_init)(int wiimotes, int *unids, void (*event_cb)(struct wiimote_t *wm), void (*stat_cb)(struct wiimote_t *wm, int attachment, int speaker, int ir, int led[4], float battery_level), void (*dis_cb)(struct wiimote_t *wm)); void (*_wiiuse_disconnected)(struct wiimote_t *wm); void (*_wiiuse_rumble)(struct wiimote_t *wm, int status); void (*_wiiuse_toggle_rumble)(struct wiimote_t *wm); void (*_wiiuse_set_leds)(struct wiimote_t *wm, int leds); void (*_wiiuse_motion_sensing)(struct wiimote_t *wm, int status); int (*_wiiuse_read_data)(struct wiimote_t *wm, void (*read_cb)(struct wiimote_t *wm, unsigned char *data, unsigned short len), unsigned char *buffer, unsigned int offset, unsigned short len); int (*_wiiuse_write_data)(struct wiimote_t *wm, unsigned int addr, unsigned char *data, unsigned char len); void (*_wiiuse_status)(struct wiimote_t *wm); struct wiimote_t *(*_wiiuse_get_by_id)(struct wiimote_t **wm, int wiimotes, int unid); int (*_wiiuse_set_flags)(struct wiimote_t *wm, int enable, int disable); float (*_wiiuse_set_smooth_alpha)(struct wiimote_t *wm, float alpha); void (*_wiiuse_set_ir)(struct wiimote_t *wm, int status); void (*_wiiuse_set_ir_vres)(struct wiimote_t *wm, unsigned int x, unsigned int y); void (*_wiiuse_set_ir_position)(struct wiimote_t *wm, enum ir_position_t { WIIUSE_IR_ABOVE=0, WIIUSE_IR_BELOW=1 } pos); void (*_wiiuse_set_aspect_ratio)(struct wiimote_t *wm, enum aspect_t { WIIUSE_ASPECT_4_3=0, WIIUSE_ASPECT_16_9=1 } aspect); void (*_wiiuse_set_bluetooth_stack)(struct wiimote_t **wm, int wiimotes, enum win_bt_stack_t { WIIUSE_STACK_UNKNOWN=0, WIIUSE_STACK_MS=1, WIIUSE_STACK_BLUESOLEIL=2 } type); void (*_wiiuse_set_orient_threshold)(struct wiimote_t *wm, float threshold); int (*_wiiuse_find)(struct wiimote_t **wm, int max_wiimotes, int timeout); int (*_wiiuse_connect)(struct wiimote_t **wm, int wiimotes); void (*_wiiuse_disconnect)(struct wiimote_t *wm); void (*_wiiuse_poll)(struct wiimote_t **wm, int wiimotes); } **)

user_defined_types: struct wiiuse_api_t { char *version; int api_version; struct wiimote_t **(*_wiiuse_init)(int wiimotes, int *unids, void (*event_cb)(struct wiimote_t *wm), void (*stat_cb)(struct wiimote_t *wm, int attachment, int speaker, int ir, int led[4], float battery_level), void (*dis_cb)(struct wiimote_t *wm)); void (*_wiiuse_disconnected)(struct wiimote_t *wm); void (*_wiiuse_rumble)(struct wiimote_t *wm, int status); void (*_wiiuse_toggle_rumble)(struct wiimote_t *wm); void (*_wiiuse_set_leds)(struct wiimote_t *wm, int leds); void (*_wiiuse_motion_sensing)(struct wiimote_t *wm, int status); int (*_wiiuse_read_data)(struct wiimote_t *wm, void (*read_cb)(struct wiimote_t *wm, unsigned char *data, unsigned short len), unsigned char *buffer, unsigned int offset, unsigned short len); int (*_wiiuse_write_data)(struct wiimote_t *wm, unsigned int addr, unsigned char *data, unsigned char len); void (*_wiiuse_status)(struct wiimote_t *wm); struct wiimote_t *(*_wiiuse_get_by_id)(struct wiimote_t **wm, int wiimotes, int unid); int (*_wiiuse_set_flags)(struct wiimote_t *wm, int enable, int disable); float (*_wiiuse_set_smooth_alpha)(struct wiimote_t *wm, float alpha); void (*_wiiuse_set_ir)(struct wiimote_t *wm, int status); void (*_wiiuse_set_ir_vres)(struct wiimote_t *wm, unsigned int x, unsigned int y); void (*_wiiuse_set_ir_position)(struct wiimote_t *wm, enum ir_position_t pos); void (*_wiiuse_set_aspect_ratio)(struct wiimote_t *wm, enum aspect_t aspect); void (*_wiiuse_set_bluetooth_stack)(struct wiimote_t **wm, int wiimotes, enum win_bt_stack_t type); void (*_wiiuse_set_orient_threshold)(struct wiimote_t *wm, float threshold); int (*_wiiuse_find)(struct wiimote_t **wm, int max_wiimotes, int timeout); int (*_wiiuse_connect)(struct wiimote_t **wm, int wiimotes); void (*_wiiuse_disconnect)(struct wiimote_t *wm); void (*_wiiuse_poll)(struct wiimote_t **wm, int wiimotes); }

user_defined_types: struct wiimote_t { int unid; struct bdaddr_t bdaddr; char bdaddr_str[18]; int out_sock; int in_sock; int state; int leds; int flags; void (*event_cb)(struct wiimote_t *wm); void (*dis_cb)(struct wiimote_t *wm); void (*stat_cb)(struct wiimote_t *wm, int attachment, int speaker, int ir, int led[4], float battery_level); unsigned char handshake_state; struct read_req_t *read_req; struct accel_t accel_calib; struct expansion_t exp; struct vec3b_t accel; struct orient_t orient; struct gforce_t gforce; struct ir_t ir; unsigned short btns; unsigned short btns_held; unsigned short btns_released; float orient_threshold; struct wiimote_state_t lstate; unsigned char event[32]; }

user_defined_types: struct accel_t { struct vec3b_t cal_zero; struct vec3b_t cal_g; float st_roll; float st_pitch; float st_alpha; }

user_defined_types: struct expansion_t { enum { EXP_NONE=0, EXP_NUNCHUK=1, EXP_CLASSIC=2 } type; union { struct nunchuk_t nunchuk; struct classic_ctrl_t classic; }; }

user_defined_types: struct ir_t { struct ir_dot_t dot[4]; unsigned char num_dots; enum aspect_t aspect; enum ir_position_t pos; unsigned int vres[2]; int offset[2]; int state; int ax; int ay; int x; int y; float distance; float z; }

user_defined_types: struct nunchuk_t { struct accel_t accel_calib; struct joystick_t js; int *flags; unsigned char btns; unsigned char btns_held; unsigned char btns_released; struct vec3b_t accel; struct orient_t orient; struct gforce_t gforce; }

user_defined_types: struct joystick_t { struct vec2b_t max; struct vec2b_t min; struct vec2b_t center; float ang; float mag; }


decompiled_code:
__int64 question_clear_all()
{
__int64 result; // rax
__int64 v1; // rdx

result = qlist;
if ( qlist )
{
do
{
v1 = result;
result = *(_QWORD *)(result + 8);
*(_QWORD *)(v1 + 8) = 0LL;
}
while ( result );
qlist = 0LL;
}
return result;
}

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

result = qlist;
if ( qlist )
{
do
{
v1 = result;
result = *(_QWORD *)(result + 8);
*(_QWORD *)(v1 + 8) = 0LL;
}
while ( result );
qlist = 0LL;
}
return result;
}

original_code:
static void question_clear_all()
{
 if(qlist!=((void *)0))
 {
  struct QuestionNode *temp2, *temp = qlist;
  while(temp)
  {
   temp2 = temp;
   temp = temp->next;
   temp2->next = ((void *)0);
  }
  qlist = ((void *)0);
 }
}

canonical_original_code:
static void question_clear_all()
{
 if(qlist!=((void *)0))
 {
  struct QuestionNode *temp2; struct QuestionNode *temp = qlist;
  while(temp)
  {
   temp2 = temp;
   temp = temp->next;
   temp2->next = ((void *)0);
  }
  qlist = ((void *)0);
 }
}

variable_types: struct QuestionNode { struct Question { int number; char *caption; char *filename; } *qstn; void *next; } *

user_defined_types: struct QuestionNode { struct Question *qstn; void *next; }


decompiled_code:
__int64 question_get_total()
{
__int64 v0; // rax
unsigned int v1; // edx

v0 = qlist;
if ( !qlist )
return 0;
v1 = 0;
do
{
++v1;
v0 = *(_QWORD *)(v0 + 8);
}
while ( v0 );
return v1;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rax
unsigned int v1; // edx

v0 = qlist;
if ( !qlist )
return 0;
v1 = 0;
do
{
++v1;
v0 = *(_QWORD *)(v0 + 8);
}
while ( v0 );
return v1;
}

original_code:
int question_get_total()
{
 struct QuestionNode *temp = qlist;
 int count = 0;
 while(temp)
 {
  count++;
  temp = temp->next;
 }
 return count;
}

variable_types: count int

user_defined_types: struct Question { int number; char *caption; char *filename; }


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

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

original_code:
struct Question *question_get_by_num(int num)
{
 return ((void *)0);
}

variable_types: num int

return_type: struct Question { int number; char *caption; char *filename; } *


usage

decompiled_code:
void __fastcall __noreturn usage(const char *a1)
{
printf(
"Nonlogic Intrusion Detection System - Copyright Nonlogic 2008\n"
"\n"
"\tExample: %s -a file1 file2 ... fileN -f output.dat\n"
"\n",
a1);
puts("Command Options:\n\n\t-a\tAdd a file. Can take a list of files including directories.");
puts("\t-s\tScan for changes. Scans files from the given file (specified with -f) for changes on the system");
puts("\t-f\tFile to save/load files to/from");
puts("\t-v\tAdd's verboseness");
puts("\t-u\tAllows existing file records to be updated.");
puts("\t-h|-?\tThis help message\n");
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(const char *a1)
{
printf(
"Nonlogic Intrusion Detection System - Copyright Nonlogic 2008\n"
"\n"
"\tExample: %s -a file1 file2 ... fileN -f output.dat\n"
"\n",
a1);
puts("Command Options:\n\n\t-a\tAdd a file. Can take a list of files including directories.");
puts("\t-s\tScan for changes. Scans files from the given file (specified with -f) for changes on the system");
puts("\t-f\tFile to save/load files to/from");
puts("\t-v\tAdd's verboseness");
puts("\t-u\tAllows existing file records to be updated.");
puts("\t-h|-?\tThis help message\n");
exit(0);
}

original_code:
static void usage(char *prog_name)
{
 printf("Nonlogic Intrusion Detection System - Copyright Nonlogic 2008\n\n\tExample: %s -a file1 file2 ... fileN -f output.dat\n\n",prog_name);
 printf("Command Options:\n\n\t-a\tAdd a file. Can take a list of files including directories.\n");
 printf("\t-s\tScan for changes. Scans files from the given file (specified with -f) for changes on the system\n");
 printf("\t-f\tFile to save/load files to/from\n");
 printf("\t-v\tAdd's verboseness\n");
 printf("\t-u\tAllows existing file records to be updated.\n");
 printf("\t-h|-?\tThis help message\n\n");
 exit(0);
}


decompiled_code:
char __fastcall set_output(char *s)
{
bool v1; // zf
char *v2; // rax

v1 = strcmp(encrypted_file, "files.dat") == 0;
LOBYTE(v2) = !v1;
if ( v1 )
{
v2 = strdup(s);
encrypted_file = v2;
if ( verbose )
LOBYTE(v2) = printf("Saving to %s\n", s);
}
return (char)v2;
}

canonical_decompiled_code:
char __fastcall func4(char *s)
{
bool v1; // zf
char *v2; // rax

v1 = strcmp(encrypted_file, "files.dat") == 0;
LOBYTE(v2) = !v1;
if ( v1 )
{
v2 = strdup(s);
encrypted_file = v2;
if ( verbose )
LOBYTE(v2) = printf("Saving to %s\n", s);
}
return (char)v2;
}

original_code:
static void set_output(char *filename)
{
 if(strcmp(encrypted_file,"files.dat")==0)
 {
  encrypted_file = strdup(filename);
  if(verbose)
   printf("Saving to %s\n",filename);
 }
}

variable_types:
filename
char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
FILE *v3; // rbp
char *v4; // r12
int v5; // ebx
char *v6; // r12

if ( argc != 1 )
parse_args(argc, argv);
v3 = tmp_file;
if ( tmp_file )
{
v4 = decrypted_buf;
if ( decrypted_buf )
{
v5 = strlen(decrypted_buf);
v6 = encrypt_nl(v4, v5);
fwrite(v6, 1uLL, v5, v3);
free(decrypted_buf);
free(v6);
}
fclose(tmp_file);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
FILE *v3; // rbp
char *v4; // r12
int v5; // ebx
char *v6; // r12

if ( argc != 1 )
func5(argc, argv);
v3 = tmp_file;
if ( tmp_file )
{
v4 = decrypted_buf;
if ( decrypted_buf )
{
v5 = strlen(decrypted_buf);
v6 = func1(v4, v5);
fwrite(v6, 1uLL, v5, v3);
free(decrypted_buf);
free(v6);
}
fclose(tmp_file);
}
return 0;
}

original_code:
int main(int argc, char **argv)
{
 if(argc!=1)
 {
  parse_args(argc, argv);
 }
 if(tmp_file!=((void *)0))
 {
  if(decrypted_buf)
  {
   int decrypted_len = strlen(decrypted_buf);
   char *encrypted_txt = encrypt_nl(decrypted_buf,decrypted_len);
   fwrite(encrypted_txt, 1, decrypted_len, tmp_file);
   free(decrypted_buf);
   free(encrypted_txt);
  }
  fclose(tmp_file);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 __fastcall database_open(__int64 a1)
{
return (unsigned int)((int)sqlite3_open(a1, &database_handle) >> 31);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return (unsigned int)((int)sqlite3_open(a1, &database_handle) >> 31);
}

original_code:
int database_open(char *filename)
{
 if(sqlite3_open(filename,&database_handle)<0)
  return -1;
 return 0;
}


decompiled_code:
void __fastcall signal_catcher(unsigned int a1)
{
log_writef(0LL, "Caught signal: %d, closing\n", a1);
log_file_close();
}

canonical_decompiled_code:
void __fastcall func0(unsigned int a1)
{
log_writef(0LL, "Caught signal: %d, closing\n", a1);
log_file_close();
}

original_code:
void signal_catcher(int signal)
{
 log_writef(LOG_INFO,"Caught signal: %d, closing\n",signal);
 log_file_close();
}

variable_types: signal int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
log_file_open(argc, argv, envp);
signal(2, (__sighandler_t)signal_catcher);
signal(3, (__sighandler_t)signal_catcher);
signal(11, (__sighandler_t)signal_catcher);
signal(15, (__sighandler_t)signal_catcher);
network_init(10101LL);
return 0;
}

original_code:
int main(int argc, char ** argv)
{
 log_file_open();
 signal(2,signal_catcher);
 signal(3,signal_catcher);
 signal(11,signal_catcher);
 signal(15,signal_catcher);
 network_init(10101);
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 log_file_open();
 signal(2,signal_catcher);
 signal(3,signal_catcher);
 signal(11,signal_catcher);
 signal(15,signal_catcher);
 network_init(10101);
 return 0;
}


decompiled_code:
void panels_update()
{
;
}

canonical_decompiled_code:
void func13()
{
;
}

original_code:
void panels_update()
{
}

canonical_original_code:
void panels_update()
{
}


decompiled_code:
__int64 __fastcall net_connect(void *buf, void *a2)
{
size_t v2; // rax
size_t v3; // rax
__int64 v5[2]; // [rsp+0h] [rbp-1028h] BYREF
char v6[4080]; // [rsp+10h] [rbp-1018h] BYREF
struct sockaddr addr; // [rsp+1000h] [rbp-28h] BYREF

sock = socket(2, 1, 0);
addr.sa_family = 2;
*(_WORD *)addr.sa_data = _bswap_16(23);
*(_DWORD *)&addr.sa_data[2] = inet_addr("192.168.1.254");
if ( connect(sock, &addr, 0x10u) )
return 0xFFFFFFFFLL;
v2 = strlen((const char *)buf);
send(sock, buf, v2, 0);
send(sock, "\r\n", 2uLL, 0);
v3 = strlen((const char *)a2);
send(sock, a2, v3, 0);
send(sock, "\r\n", 2uLL, 0);
sleep(1u);
v5[0] = 0LL;
v5[1] = 0LL;
memset(v6, 0, sizeof(v6));
recv(sock, v5, 0x1000uLL, 64);
return (unsigned int)sock;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *buf, void *a2)
{
size_t v2; // rax
size_t v3; // rax
__int64 v5[2]; // [rsp+0h] [rbp-1028h] BYREF
char v6[4080]; // [rsp+10h] [rbp-1018h] BYREF
struct sockaddr addr; // [rsp+1000h] [rbp-28h] BYREF

sock = socket(2, 1, 0);
addr.sa_family = 2;
*(_WORD *)addr.sa_data = func0(23);
*(_DWORD *)&addr.sa_data[2] = inet_addr("192.168.1.254");
if ( connect(sock, &addr, 0x10u) )
return 0xFFFFFFFFLL;
v2 = strlen((const char *)buf);
send(sock, buf, v2, 0);
send(sock, "\r\n", 2uLL, 0);
v3 = strlen((const char *)a2);
send(sock, a2, v3, 0);
send(sock, "\r\n", 2uLL, 0);
sleep(1u);
v5[0] = 0LL;
v5[1] = 0LL;
memset(v6, 0, sizeof(v6));
recv(sock, v5, 0x1000uLL, 64);
return (unsigned int)sock;
}

original_code:
int net_connect(const char *username, const char *password)
{
 sock = socket(2, SOCK_STREAM, 0);
 struct sockaddr_in sock_dst;
 sock_dst.sin_family = 2;
 sock_dst.sin_port = htons(23);
 sock_dst.sin_addr.s_addr = inet_addr("192.168.1.254");
 if(connect(sock, (struct sockaddr*)&sock_dst, sizeof(sock_dst))!=0)
  return -1;
 send(sock, username, strlen(username),0);
 send(sock, "\r\n", 2, 0);
 send(sock, password, strlen(password),0);
 send(sock, "\r\n", 2, 0);
 sleep(1);
 char buffer[4096] = { 0 };
 recv(sock, buffer, 4096, MSG_DONTWAIT);
 return sock;
}

canonical_original_code:
int net_connect(char *username, char *password)
{
 sock = socket(2, SOCK_STREAM, 0);
 struct sockaddr_in sock_dst;
 sock_dst.sin_family = 2;
 sock_dst.sin_port = htons(23);
 sock_dst.sin_addr.s_addr = inet_addr("192.168.1.254");
 if(connect(sock, (struct sockaddr *)&sock_dst, sizeof(sock_dst))!=0)
  return -1;
 send(sock, username, strlen(username),0);
 send(sock, "\r\n", 2, 0);
 send(sock, password, strlen(password),0);
 send(sock, "\r\n", 2, 0);
 sleep(1);
 char buffer[4096] = { 0 };
 recv(sock, buffer, 4096, MSG_DONTWAIT);
 return sock;
}

variable_types:
username
char *

variable_types:
password
char *

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

variable_types:
buffer
char [4096]

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


original_code:
const char *net_update()
{
 send(sock, ":xdsl info\r\n", 12, 0);
 char buffer[4096] = { 0 };
 int i = 0;
 do
 {
  recv(sock,buffer+i,1,0);
 }
 while(buffer[i++]!='>');
 int k;
 for(k = 0;k<i;k++)
 {
  if(buffer[k]=='{')
  {
   buffer[k-2] = '\0';
   break;
  }
 }
 return strdup(buffer+12);
}

variable_types: i int

variable_types: k int


decompiled_code:
int net_shutdown()
{
return shutdown(sock, 0);
}

canonical_decompiled_code:
int func3()
{
return shutdown(sock, 0);
}

original_code:
void net_shutdown()
{
 shutdown(sock, 0);
}


decompiled_code:
void handle_sig()
{
puts("THE GOGGLES DO NOTHING!");
}

canonical_decompiled_code:
void func0()
{
puts("THE GOGGLES DO NOTHING!");
}

original_code:
void handle_sig(int signum)
{
 printf("THE GOGGLES DO NOTHING!\n");
}

variable_types: signum int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
signal(13, (__sighandler_t)handle_sig);
if ( argc <= 1 )
{
network_init("localhost");
}
else
{
network_init(argv[1]);
if ( argc > 2 )
{
camera_open(argv[2], 320LL, 240LL);
goto LABEL_4;
}
}
camera_open("/dev/video0", 320LL, 240LL);
LABEL_4:
while ( (unsigned __int8)update_camera() )
;
return 0;
}

original_code:
int main(int argc, char **argv)
{
 signal(13,handle_sig);
 if(argc>1)
  network_init(argv[1]);
 else
  network_init("localhost");
 if(argc>2)
  camera_open(argv[2],320, 240);
 else
  camera_open("/dev/video0",320, 240);
 while(update_camera());
 return 0;
}


buttonDown

decompiled_code:
__int64 __fastcall buttonDown(char a1)
{
return (buttonsdown & (unsigned int)(1 << a1)) >> a1;
}

canonical_decompiled_code:
__int64 __fastcall func8(char a1)
{
return (buttonsdown & (unsigned int)(1 << a1)) >> a1;
}

original_code:
int buttonDown(int buttonnum)
{
 return (buttonsdown & (1<<buttonnum))>>buttonnum;
}

variable_types: buttonnum int


decompiled_code:
time_t __fastcall take_photo(__int64 a1)
{
int v1; // ebx
char *v2; // rax
__int64 v3; // rdx
time_t result; // rax

v1 = ltime_1;
if ( !ltime_1 )
{
ltime_1 = time(0LL);
LABEL_3:
v2 = (char *)malloc(0x80uLL);
v3 = (unsigned int)img_num_0++;
sprintf(v2, "caught%03d.bmp", v3);
return bitmap_write(a1, 320LL, 240LL);
}
result = time(0LL);
if ( v1 + 2 < (int)result )
goto LABEL_3;
return result;
}

canonical_decompiled_code:
time_t __fastcall func0(__int64 a1)
{
int v1; // ebx
char *v2; // rax
__int64 v3; // rdx
time_t result; // rax

v1 = ltime_1;
if ( !ltime_1 )
{
ltime_1 = time(0LL);
LABEL_3:
v2 = (char *)malloc(0x80uLL);
v3 = (unsigned int)img_num_0++;
sprintf(v2, "caught%03d.bmp", v3);
return bitmap_write(a1, 320LL, 240LL);
}
result = time(0LL);
if ( v1 + 2 < (int)result )
goto LABEL_3;
return result;
}

original_code:
void take_photo(void *data)
{
 static int ltime = 0;
 static int img_num = 0;
 if(ltime == 0)
 {
  ltime = time(((void *)0));
 }
 else if(time(((void *)0))<ltime+3)
 {
  return;
 }
 char *filename = malloc(128);
 sprintf(filename,"caught%03d.bmp",img_num++);
 bitmap_write(data, 320, 240);
}

variable_types:
data
void *

variable_types: ltime int


decompiled_code:
__int64 update_camera()
{
__int64 v0; // rbx
void *ptr; // [rsp+8h] [rbp-20h] BYREF
char v3[4]; // [rsp+10h] [rbp-18h] BYREF
char v4[4]; // [rsp+14h] [rbp-14h] BYREF
char v5[4]; // [rsp+18h] [rbp-10h] BYREF
int v6[3]; // [rsp+1Ch] [rbp-Ch] BYREF

v0 = camera_read_image();
manip_check_diffs(v0, v6, v5, v4, v3);
if ( v6[0] != -2 )
take_photo(v0);
if ( v0 )
{
ptr = 0LL;
network_encode_data(v0, &ptr);
free(ptr);
}
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rbx
void *ptr; // [rsp+8h] [rbp-20h] BYREF
char v3[4]; // [rsp+10h] [rbp-18h] BYREF
char v4[4]; // [rsp+14h] [rbp-14h] BYREF
char v5[4]; // [rsp+18h] [rbp-10h] BYREF
int v6[3]; // [rsp+1Ch] [rbp-Ch] BYREF

v0 = camera_read_image();
manip_check_diffs(v0, v6, v5, v4, v3);
if ( v6[0] != -2 )
func0(v0);
if ( v0 )
{
ptr = 0LL;
network_encode_data(v0, &ptr);
free(ptr);
}
return 1LL;
}

original_code:
char update_camera()
{
 char *data = camera_read_image();
   int x, y,x2,y2;
   manip_check_diffs(data, &x, &y, &x2, &y2);
 if(x!=-2)
 {
  take_photo(data);
 }
 if(data==((void *)0))
  return 1;
 unsigned char *send_data = ((void *)0);
 int bytes = network_encode_data(data, &send_data);
 free(send_data);
 return 1;
}

canonical_original_code:
char update_camera()
{
 char *data = camera_read_image();
   int x; int y; int x2; int y2;
   manip_check_diffs(data, &x, &y, &x2, &y2);
 if(x!=-2)
 {
  take_photo(data);
 }
 if(data==((void *)0))
  return 1;
 unsigned char *send_data = ((void *)0);
 int bytes = network_encode_data(data, &send_data);
 free(send_data);
 return 1;
}

variable_types:
data
char *

variable_types: x int

variable_types: y int

variable_types: bytes int

return_type: char


original_code:
char *generate_question()
{
 char *answer = ((void *)0);
 int matrix_a[2], matrix_b[2];
 matrix_a[0] = (rand()%4)+1;
 matrix_a[1] = (rand()%4)+1;
 matrix_b[0] = (rand()%4)+1;
 matrix_b[1] = (rand()%4)+1;
 int matrix_a_els[matrix_a[0]][matrix_a[1]];
 int matrix_b_els[matrix_b[0]][matrix_b[1]];
 int i = 0;
 int j = 0;
 int k = 0;
 for(i = 0;i<matrix_a[0];i++)
 {
  for(j = 0;j<matrix_a[1];j++)
  {
   matrix_a_els[i][j] = rand()%10;
  }
 }
 for(i = 0;i<matrix_b[0];i++)
 {
  for(j = 0;j<matrix_b[1];j++)
  {
   matrix_b_els[i][j] = rand()%10;
  }
 }
 int max = (matrix_a[0]<=matrix_b[0])?(matrix_b[0]):(matrix_a[0]);
 int chars_moved = 2;
 int cchars_moved = 2;
 for(i = 0;i<max;i++)
 {
  if(i<matrix_a[0])
  {
   printf("[ ");
   for(j=0;j<matrix_a[1];j++)
   {
    printf("%d ",matrix_a_els[i][j]);
    cchars_moved += 2;
   }
   printf("] ");
   cchars_moved += 2;
   if(cchars_moved>chars_moved)
   {
    chars_moved = cchars_moved;
   }
  }
  else
  {
   for(k=0;k<chars_moved;k++,printf(" "));
  }
  if(i<matrix_b[0])
  {
   printf("[ ");
   for(j=0;j<matrix_b[1];j++)
   {
    printf("%d ",matrix_b_els[i][j]);
   }
   printf("]");
  }
  printf("\n");
  cchars_moved = 0;
 }
 while(fgetc(stdin)<0);
 printf("\nAnswer:");
 if(matrix_a[0]!=matrix_b[1])
 {
  printf("\nImpossible to multiply matrices, matrix A doesn't have the same amount of columns as matrix B has rows\n");
 }
 else
 {
  printf("Answer matrix size %dx%d\n\n",matrix_a[1],matrix_b[0]);
  int answer_matrix[matrix_a[0]][matrix_b[1]];
  for(i = 0;i<matrix_a[0];i++)
  {
   for(j=0;j<matrix_b[0];j++)
   {
    int ans = 0;
    for(k = 0; k<matrix_a[1];k++)
    {
     ans += matrix_a_els[i][k]*matrix_b_els[k][j];
    }
    answer_matrix[i][j] = ans;
   }
  }
  answer = malloc(1024);
  memset(answer, '\0', 1024);
  for(i=0;i<matrix_a[0];i++)
  {
   printf("\n[ ");
   for(j=0;j<matrix_b[1];j++)
   {
    printf("%d ",answer_matrix[i][j]);
   }
   printf("]");
  }
  printf("\n");
 }
 return ((void *)0);
}

canonical_original_code:
char *generate_question()
{
 char *answer = ((void *)0);
 int matrix_a[2]; int matrix_b[2];
 matrix_a[0] = (rand()%4)+1;
 matrix_a[1] = (rand()%4)+1;
 matrix_b[0] = (rand()%4)+1;
 matrix_b[1] = (rand()%4)+1;
 int matrix_a_els[-1][-1];
 int matrix_b_els[-1][-1];
 int i = 0;
 int j = 0;
 int k = 0;
 for(i = 0;i<matrix_a[0];i++)
 {
  for(j = 0;j<matrix_a[1];j++)
  {
   matrix_a_els[i][j] = rand()%10;
  }
 }
 for(i = 0;i<matrix_b[0];i++)
 {
  for(j = 0;j<matrix_b[1];j++)
  {
   matrix_b_els[i][j] = rand()%10;
  }
 }
 int max = (matrix_a[0]<=matrix_b[0])?(matrix_b[0]):(matrix_a[0]);
 int chars_moved = 2;
 int cchars_moved = 2;
 for(i = 0;i<max;i++)
 {
  if(i<matrix_a[0])
  {
   printf("[ ");
   for(j=0;j<matrix_a[1];j++)
   {
    printf("%d ",matrix_a_els[i][j]);
    cchars_moved += 2;
   }
   printf("] ");
   cchars_moved += 2;
   if(cchars_moved>chars_moved)
   {
    chars_moved = cchars_moved;
   }
  }
  else
  {
   for(k=0;k<chars_moved;k++,printf(" "));
  }
  if(i<matrix_b[0])
  {
   printf("[ ");
   for(j=0;j<matrix_b[1];j++)
   {
    printf("%d ",matrix_b_els[i][j]);
   }
   printf("]");
  }
  printf("\n");
  cchars_moved = 0;
 }
 while(fgetc(stdin)<0);
 printf("\nAnswer:");
 if(matrix_a[0]!=matrix_b[1])
 {
  printf("\nImpossible to multiply matrices, matrix A doesn't have the same amount of columns as matrix B has rows\n");
 }
 else
 {
  printf("Answer matrix size %dx%d\n\n",matrix_a[1],matrix_b[0]);
  int answer_matrix[-1][-1];
  for(i = 0;i<matrix_a[0];i++)
  {
   for(j=0;j<matrix_b[0];j++)
   {
    int ans = 0;
    for(k = 0; k<matrix_a[1];k++)
    {
     ans += matrix_a_els[i][k]*matrix_b_els[k][j];
    }
    answer_matrix[i][j] = ans;
   }
  }
  answer = malloc(1024);
  memset(answer, '\0', 1024);
  for(i=0;i<matrix_a[0];i++)
  {
   printf("\n[ ");
   for(j=0;j<matrix_b[1];j++)
   {
    printf("%d ",answer_matrix[i][j]);
   }
   printf("]");
  }
  printf("\n");
 }
 return ((void *)0);
}

variable_types:
answer
char *

variable_types: j int

variable_types: max int

variable_types: ans int


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
FILE *v4; // rdi

puts("Matrix Multiplication Revision - by Feesh!\n");
puts("Let's start- Questions will appear, you will need");
puts("to answer them on a piece of paper, as you cannot");
puts("input your answer directly into the program.\n");
puts("You will receive a question, and then you will");
puts("have to hit the return key to see the answer!\n");
puts("Press CTRL+C to exit the program\n");
v3 = time(0LL);
v4 = (FILE *)v3;
srand(v3);
while ( 1 )
{
generate_question(v4, argv);
do
v4 = stdin;
while ( fgetc(stdin) < 0 );
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
FILE *v4; // rdi

puts("Matrix Multiplication Revision - by Feesh!\n");
puts("Let's start- Questions will appear, you will need");
puts("to answer them on a piece of paper, as you cannot");
puts("input your answer directly into the program.\n");
puts("You will receive a question, and then you will");
puts("have to hit the return key to see the answer!\n");
puts("Press CTRL+C to exit the program\n");
v3 = time(0LL);
v4 = (FILE *)v3;
srand(v3);
while ( 1 )
{
func7(v4, argv);
do
v4 = stdin;
while ( fgetc(stdin) < 0 );
}
}

original_code:
int main(int argc, char **argv)
{
 printf("Matrix Multiplication Revision - by Feesh!\n\n");
 printf("Let's start- Questions will appear, you will need\n");
 printf("to answer them on a piece of paper, as you cannot\n");
 printf("input your answer directly into the program.\n\n");
 printf("You will receive a question, and then you will\n");
 printf("have to hit the return key to see the answer!\n\n");
 printf("Press CTRL+C to exit the program\n\n");
 srand(time(((void *)0)));
 for(;;)
 {
  generate_question();
  while(fgetc(stdin)<0);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 __fastcall controls_get_max_gain(int a1)
{
__int64 v2[5]; // [rsp+0h] [rbp-58h] BYREF
__int64 v3; // [rsp+28h] [rbp-30h]
__int64 v4; // [rsp+30h] [rbp-28h]
__int64 v5; // [rsp+38h] [rbp-20h]
int v6; // [rsp+40h] [rbp-18h]

v2[0] = 9963795LL;
v2[1] = 0LL;
v2[2] = 0LL;
v2[3] = 0LL;
v2[4] = 0LL;
v3 = 0LL;
v4 = 0LL;
v5 = 0LL;
v6 = 0;
if ( ioctl(a1, 0xC0445624uLL, v2) )
{
perror("ioctl VIDIOC_QUERYCTRL failed for V4L2_CID_GAIN");
}
else if ( (v5 & 1) != 0 )
{
_assert_fail("!(queryctrl.flags & V4L2_CTRL_FLAG_DISABLED)", "controls.c", 0x15u, "controls_get_max_gain");
}
return HIDWORD(v3);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
__int64 v2[5]; // [rsp+0h] [rbp-58h] BYREF
__int64 v3; // [rsp+28h] [rbp-30h]
__int64 v4; // [rsp+30h] [rbp-28h]
__int64 v5; // [rsp+38h] [rbp-20h]
int v6; // [rsp+40h] [rbp-18h]

v2[0] = 9963795LL;
v2[1] = 0LL;
v2[2] = 0LL;
v2[3] = 0LL;
v2[4] = 0LL;
v3 = 0LL;
v4 = 0LL;
v5 = 0LL;
v6 = 0;
if ( ioctl(a1, 0xC0445624uLL, v2) )
{
perror("ioctl VIDIOC_QUERYCTRL failed for V4L2_CID_GAIN");
}
else if ( (v5 & 1) != 0 )
{
_assert_fail("!(queryctrl.flags & V4L2_CTRL_FLAG_DISABLED)", "controls.c", 0x15u, "controls_get_max_gain");
}
return HIDWORD(v3);
}

original_code:
int controls_get_max_gain(int fd)
{
 printf("Stub get max gain\n");
 return 0;
}

variable_types: fd int


decompiled_code:
__int64 __fastcall controls_get_gain(int a1)
{
int v2; // [rsp+8h] [rbp-10h] BYREF
unsigned int v3; // [rsp+Ch] [rbp-Ch]

v3 = 0;
v2 = 9963795;
if ( ioctl(a1, 0xC008561BuLL, &v2) )
perror("VIDIOC_G_CTRL");
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
int v2; // [rsp+8h] [rbp-10h] BYREF
unsigned int v3; // [rsp+Ch] [rbp-Ch]

v3 = 0;
v2 = 9963795;
if ( ioctl(a1, 0xC008561BuLL, &v2) )
perror("VIDIOC_G_CTRL");
return v3;
}

original_code:
int controls_get_gain(int fd)
{
 printf("Stub get gain\n");
 return 0;
}


decompiled_code:
int __fastcall controls_set_gain(int a1, unsigned int a2)
{
int result; // eax
unsigned int v3; // [rsp+8h] [rbp-10h] BYREF
unsigned int v4; // [rsp+Ch] [rbp-Ch]

v3 = 9963795;
v4 = a2;
result = ioctl(a1, 0xC008561CuLL, &v3);
if ( result == -1 )
{
perror("VIDEOC_S_CTRL");
fprintf(stderr, "control.id=%x\n", v3);
result = fprintf(stderr, "control.value=%d\n", v4);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1, unsigned int a2)
{
int result; // eax
unsigned int v3; // [rsp+8h] [rbp-10h] BYREF
unsigned int v4; // [rsp+Ch] [rbp-Ch]

v3 = 9963795;
v4 = a2;
result = ioctl(a1, 0xC008561CuLL, &v3);
if ( result == -1 )
{
perror("VIDEOC_S_CTRL");
fprintf(stderr, "control.id=%x\n", v3);
result = fprintf(stderr, "control.value=%d\n", v4);
}
return result;
}

original_code:
void controls_set_gain(int fd, int v)
{
 printf("Stub set gain\n");
}

variable_types: v int


decompiled_code:
__int64 __fastcall controls_get_jpegcompr(int a1)
{
unsigned int v1; // ebx
unsigned int v3[38]; // [rsp+0h] [rbp-98h] BYREF

if ( ioctl(a1, 0x808C563DuLL, v3) != -1 )
return v3[0];
v1 = -1;
perror("VIDIOC_G_JPEGCOMP");
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func17(int a1)
{
unsigned int v1; // ebx
unsigned int v3[38]; // [rsp+0h] [rbp-98h] BYREF

if ( ioctl(a1, 0x808C563DuLL, v3) != -1 )
return v3[0];
v1 = -1;
perror("VIDIOC_G_JPEGCOMP");
return v1;
}

original_code:
int controls_get_jpegcompr(int fd)
{
  struct v4l2_jpegcompression compr;
  int rv=ioctl(fd, (((2U) << (((0 +8)+8)+14)) | ((('V')) << (0 +8)) | (((61)) << 0) | ((((sizeof(struct v4l2_jpegcompression)))) << ((0 +8)+8))), &compr);
  if (rv==-1)
  {
    perror("VIDIOC_G_JPEGCOMP");
    return -1;
  }
  return compr.quality;
}

canonical_original_code:
int controls_get_jpegcompr(int fd)
{
  struct v4l2_jpegcompression compr;
  int rv = ioctl(fd, (((2U) << (((0 +8)+8)+14)) | ((('V')) << (0 +8)) | (((61)) << 0) | ((((sizeof(struct v4l2_jpegcompression)))) << ((0 +8)+8))), &compr);
  if (rv==-1)
  {
    perror("VIDIOC_G_JPEGCOMP");
    return -1;
  }
  return compr.quality;
}

variable_types: struct v4l2_jpegcompression { int quality; int APPn; int APP_len; char APP_data[60]; int COM_len; char COM_data[60]; unsigned int jpeg_markers; }

variable_types: rv int


decompiled_code:
__int64 __fastcall controls_get_max_gain(int a1)
{
__int64 v2[5]; // [rsp+0h] [rbp-58h] BYREF
__int64 v3; // [rsp+28h] [rbp-30h]
__int64 v4; // [rsp+30h] [rbp-28h]
__int64 v5; // [rsp+38h] [rbp-20h]
int v6; // [rsp+40h] [rbp-18h]

v2[0] = 9963795LL;
v2[1] = 0LL;
v2[2] = 0LL;
v2[3] = 0LL;
v2[4] = 0LL;
v3 = 0LL;
v4 = 0LL;
v5 = 0LL;
v6 = 0;
if ( ioctl(a1, 0xC0445624uLL, v2) )
{
perror("ioctl VIDIOC_QUERYCTRL failed for V4L2_CID_GAIN");
}
else if ( (v5 & 1) != 0 )
{
_assert_fail("!(queryctrl.flags & V4L2_CTRL_FLAG_DISABLED)", "controls.c", 0x5Fu, "controls_get_max_gain");
}
return HIDWORD(v3);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 v2[5]; // [rsp+0h] [rbp-58h] BYREF
__int64 v3; // [rsp+28h] [rbp-30h]
__int64 v4; // [rsp+30h] [rbp-28h]
__int64 v5; // [rsp+38h] [rbp-20h]
int v6; // [rsp+40h] [rbp-18h]

v2[0] = 9963795LL;
v2[1] = 0LL;
v2[2] = 0LL;
v2[3] = 0LL;
v2[4] = 0LL;
v3 = 0LL;
v4 = 0LL;
v5 = 0LL;
v6 = 0;
if ( ioctl(a1, 0xC0445624uLL, v2) )
{
perror("ioctl VIDIOC_QUERYCTRL failed for V4L2_CID_GAIN");
}
else if ( (v5 & 1) != 0 )
{
_assert_fail("!(queryctrl.flags & V4L2_CTRL_FLAG_DISABLED)", "controls.c", 0x5Fu, "controls_get_max_gain");
}
return HIDWORD(v3);
}

canonical_original_code:
int controls_get_max_gain(int fd)
{
 printf("Stub get max gain\n");
 return 0;
}


canonical_decompiled_code:
__int64 __fastcall func3(int a1)
{
int v2; // [rsp+8h] [rbp-10h] BYREF
unsigned int v3; // [rsp+Ch] [rbp-Ch]

v3 = 0;
v2 = 9963795;
if ( ioctl(a1, 0xC008561BuLL, &v2) )
perror("VIDIOC_G_CTRL");
return v3;
}

canonical_original_code:
int controls_get_gain(int fd)
{
 printf("Stub get gain\n");
 return 0;
}


canonical_decompiled_code:
int __fastcall func4(int a1, unsigned int a2)
{
int result; // eax
unsigned int v3; // [rsp+8h] [rbp-10h] BYREF
unsigned int v4; // [rsp+Ch] [rbp-Ch]

v3 = 9963795;
v4 = a2;
result = ioctl(a1, 0xC008561CuLL, &v3);
if ( result == -1 )
{
perror("VIDEOC_S_CTRL");
fprintf(stderr, "control.id=%x\n", v3);
result = fprintf(stderr, "control.value=%d\n", v4);
}
return result;
}

canonical_original_code:
void controls_set_gain(int fd, int v)
{
 printf("Stub set gain\n");
}


canonical_decompiled_code:
__int64 __fastcall func9(int a1)
{
unsigned int v1; // ebx
unsigned int v3[38]; // [rsp+0h] [rbp-98h] BYREF

if ( ioctl(a1, 0x808C563DuLL, v3) != -1 )
return v3[0];
v1 = -1;
perror("VIDIOC_G_JPEGCOMP");
return v1;
}

user_defined_types: struct v4l2_jpegcompression { int quality; int APPn; int APP_len; char APP_data[60]; int COM_len; char COM_data[60]; unsigned int jpeg_markers; }


original_code:
void colour_convert(double H, double S, double V, double *R, double *G, double *B)
{
 if( V == 0 )
 {
  *R = 0;
  *G = 0;
  *B = 0;
 }
 else if( S == 0 )
 {
  *R = V;
  *G = V;
  *B = V;
 }
 else
 {
  const double hf = H / 60.0;
  const int i = (int) floor( hf );
  const double f = hf - i;
  const double pv = V * ( 1 - S );
  const double qv = V * ( 1 - S * f );
  const double tv = V * ( 1 - S * ( 1 - f ) );
  switch( i )
  {
   case 0:
    *R = V;
    *G = tv;
    *B = pv;
    break;
   case 1:
    *R = qv;
    *G = V;
    *B = pv;
    break;
   case 2:
    *R = pv;
    *G = V;
    *B = tv;
    break;
   case 3:
    *R = pv;
    *G = qv;
    *B = V;
    break;
   case 4:
    *R = tv;
    *G = pv;
    *B = V;
    break;
   case 5:
    *R = V;
    *G = pv;
    *B = qv;
    break;
   case 6:
    *R = V;
    *G = tv;
    *B = pv;
    break;
   case -1:
    *R = V;
    *G = pv;
    *B = qv;
    break;
   default:
    fprintf(stderr,"i Value error in Pixel conversion, Value is %d\n",i);
    break;
  }
 }
 *R *= 255.0F;
 *G *= 255.0F;
 *B *= 255.0F;
}

canonical_original_code:
void colour_convert(double H, double S, double V, double *R, double *G, double *B)
{
 if( V == 0 )
 {
  *R = 0;
  *G = 0;
  *B = 0;
 }
 else if( S == 0 )
 {
  *R = V;
  *G = V;
  *B = V;
 }
 else
 {
  double hf = H / 60.0;
  int i = (int) floor( hf );
  double f = hf - i;
  double pv = V * ( 1 - S );
  double qv = V * ( 1 - S * f );
  double tv = V * ( 1 - S * ( 1 - f ) );
  switch( i )
  {
   case 0:
    *R = V;
    *G = tv;
    *B = pv;
    break;
   case 1:
    *R = qv;
    *G = V;
    *B = pv;
    break;
   case 2:
    *R = pv;
    *G = V;
    *B = tv;
    break;
   case 3:
    *R = pv;
    *G = qv;
    *B = V;
    break;
   case 4:
    *R = tv;
    *G = pv;
    *B = V;
    break;
   case 5:
    *R = V;
    *G = pv;
    *B = qv;
    break;
   case 6:
    *R = V;
    *G = tv;
    *B = pv;
    break;
   case -1:
    *R = V;
    *G = pv;
    *B = qv;
    break;
   default:
    fprintf(stderr,"i Value error in Pixel conversion, Value is %d\n",i);
    break;
  }
 }
 *R *= 255.0F;
 *G *= 255.0F;
 *B *= 255.0F;
}

variable_types: H double

variable_types: S double

variable_types: V double

variable_types:
R
double *

variable_types:
G
double *

variable_types:
B
double *

variable_types: hf double

variable_types: i int

variable_types: f double

variable_types: pv double

variable_types: qv double

variable_types: tv double


decompiled_code:
__int64 window_show()
{
__int64 v0; // rax

v0 = window_create();
return gtk_widget_show_all(v0);
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // rax

v0 = func6();
return gtk_widget_show_all(v0);
}

original_code:
void window_show()
{
 gtk_widget_show_all(window_create());
}


decompiled_code:
__int64 __fastcall update_camera(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rax
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

v1 = camera_read_image();
if ( v1 )
{
v2 = v1;
v5[0] = 0LL;
network_encode_data(v1, v5);
g_free(v5[0]);
v3 = gdk_gc_new(*(_QWORD *)(a1 + 80));
gdk_draw_rgb_image(*(_QWORD *)(a1 + 80), v3, 0LL, 0LL, 320LL, 240LL, 0LL, v2, 960LL);
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rax
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

v1 = camera_read_image();
if ( v1 )
{
v2 = v1;
v5[0] = 0LL;
network_encode_data(v1, v5);
g_free(v5[0]);
v3 = gdk_gc_new(*(_QWORD *)(a1 + 80));
gdk_draw_rgb_image(*(_QWORD *)(a1 + 80), v3, 0LL, 0LL, 320LL, 240LL, 0LL, v2, 960LL);
}
return 1LL;
}

variable_types:
data
char *

variable_types: x int

variable_types: y int

variable_types: bytes int


repo: ElFeesho/nonogram

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

v3 = time(0LL);
v4 = v3;
srand(v3);
gameboard_init(v4, argv);
while ( (unsigned int)gameboard_process_input() )
gameboard_render();
gameboard_deinit();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
__int64 v4; // rdi

v3 = time(0LL);
v4 = v3;
srand(v3);
func14(v4, argv);
while ( (unsigned int)func17() )
func16();
func15();
return 0;
}

original_code:
int main(int argc, char **argv)
{
 srand(time(((void *)0)));
 gameboard_init();
 while(gameboard_process_input())
 {
  gameboard_render();
 }
 gameboard_deinit();
 return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
char *reset_board()
{
char *v0; // rdx
char *result; // rax

image_generate(10LL, 10LL);
v0 = (char *)&unk_4040CA;
do
{
result = v0 - 10;
do
*result++ = 0;
while ( result != v0 );
v0 += 10;
}
while ( v0 != (_BYTE *)&screen + 6 );
return result;
}

canonical_decompiled_code:
char *func7()
{
char *v0; // rdx
char *result; // rax

func18(10LL, 10LL);
v0 = (char *)&unk_4040CA;
do
{
result = v0 - 10;
do
*result++ = 0;
while ( result != v0 );
v0 += 10;
}
while ( v0 != (_BYTE *)&screen + 6 );
return result;
}

original_code:
void reset_board(void)
{
 image_generate(10, 10);
 int x, y;
 for(y = 0;y<10;y++)
 {
  for(x = 0;x<10;x++)
  {
   gameboard[y][x] = 0;
  }
 }
}

canonical_original_code:
void reset_board()
{
 image_generate(10, 10);
 int x; int y;
 for(y = 0;y<10;y++)
 {
  for(x = 0;x<10;x++)
  {
   gameboard[y][x] = 0;
  }
 }
}


decompiled_code:
__int64 put_pixel()
{
return SDL_FillRect();
}

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

original_code:
void put_pixel(int x, int y, unsigned int col)
{
 SDL_Rect pos;
 pos.x = x;
 pos.y = y;
 pos.w = 1;
 pos.h = 1;
 SDL_FillRect(screen, &pos, col);
}

canonical_original_code:
void put_pixel(int x, int y, unsigned int col)
{
 struct SDL_Rect pos;
 pos.x = x;
 pos.y = y;
 pos.w = 1;
 pos.h = 1;
 SDL_FillRect(screen, &pos, col);
}

variable_types:
col
unsigned int

variable_types: struct SDL_Rect { short x; unsigned short w; }


decompiled_code:
__int64 draw_highlight()
{
SDL_MapRGB();
return SDL_FillRect();
}

canonical_decompiled_code:
__int64 func9()
{
SDL_MapRGB();
return SDL_FillRect();
}

original_code:
void draw_highlight(void)
{
 SDL_Rect t;
 t.x = stage_x+sel_x*24+1;
 t.y = stage_y+sel_y*24+1;
 t.w = 23;
 t.h = 23;
 SDL_FillRect(screen, &t, SDL_MapRGB(screen->format,0,128,255));
}

canonical_original_code:
void draw_highlight()
{
 struct SDL_Rect t;
 t.x = stage_x+sel_x*24+1;
 t.y = stage_y+sel_y*24+1;
 t.w = 23;
 t.h = 23;
 SDL_FillRect(screen, &t, SDL_MapRGB(screen->format,0,128,255));
}

user_defined_types: struct SDL_Rect { short x; unsigned short w; }


decompiled_code:
__int64 draw_gameboard()
{
char *v0; // r12
__int16 v1; // r13
char *v2; // rbp
__int16 i; // bx
__int64 result; // rax

v0 = &gameboard;
v1 = 63;
do
{
v2 = v0;
for ( i = 123; i != 363; i += 24 )
{
if ( *v2 == 1 )
{
SDL_MapRGB();
result = SDL_FillRect();
}
++v2;
}
v1 += 24;
v0 += 10;
}
while ( v0 != (char *)&unk_404124 );
return result;
}

original_code:
void draw_gameboard(void)
{
 int x, y;
 for(y = 0;y<10;y++)
 {
  for(x = 0;x<10;x++)
  {
   if(gameboard[y][x] == 1)
   {
    SDL_Rect t;
    t.x = stage_x+x*24+3;
    t.y = stage_y+y*24+3;
    t.w = 19;
    t.h = 19;
    SDL_FillRect(screen, &t, SDL_MapRGB(screen->format,0,0,0));
   }
  }
 }
}

canonical_original_code:
void draw_gameboard()
{
 int x; int y;
 for(y = 0;y<10;y++)
 {
  for(x = 0;x<10;x++)
  {
   if(gameboard[y][x] == 1)
   {
    struct SDL_Rect t;
    t.x = stage_x+x*24+3;
    t.y = stage_y+y*24+3;
    t.w = 19;
    t.h = 19;
    SDL_FillRect(screen, &t, SDL_MapRGB(screen->format,0,0,0));
   }
  }
 }
}


decompiled_code:
char __fastcall do_move(int a1, unsigned int a2)
{
__int64 v2; // rax

v2 = image_get_row(a2);
if ( *(_DWORD *)(v2 + 4LL * a1) == 1 )
{
LOBYTE(v2) = 1 - gameboard[10 * a2 + a1];
gameboard[10 * a2 + a1] = v2;
}
return v2;
}

canonical_decompiled_code:
char __fastcall func11(int a1, unsigned int a2)
{
__int64 v2; // rax

v2 = func19(a2);
if ( *(_DWORD *)(v2 + 4LL * a1) == 1 )
{
LOBYTE(v2) = 1 - gameboard[10 * a2 + a1];
gameboard[10 * a2 + a1] = v2;
}
return v2;
}

original_code:
void do_move(int x, int y)
{
 int *row = image_get_row(y);
 if(row[x] == 1)
  gameboard[y][x] = 1-gameboard[y][x];
}

variable_types:
row
int *


decompiled_code:
__int64 __fastcall draw_number(int a1, unsigned int a2, int a3)
{
int v3; // er15
__int64 result; // rax
int v5; // er14
__int64 i; // rbx
unsigned int v7; // eax
unsigned int v8; // er12
unsigned __int64 v9; // rbp
unsigned __int64 v10; // r13

v3 = a3;
result = (unsigned int)(int)(log10((double)a3) + 1.0);
if ( (int)result > 0 )
{
v5 = a1 + 5 * result;
do
{
v8 = a2;
v9 = 100LL * (v3 % 10);
v10 = v9 + 100;
do
{
for ( i = 0LL; i != 5; ++i )
{
if ( num_font[i + v9 / 4] == 1 )
{
v7 = SDL_MapRGB();
put_pixel((unsigned int)(v5 + i), v8, v7);
}
}
++v8;
v9 += 20LL;
}
while ( v9 != v10 );
result = (unsigned int)(v3 / 10);
v3 /= 10;
v5 -= 5;
}
while ( v5 != a1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, unsigned int a2, int a3)
{
int v3; // er15
__int64 result; // rax
int v5; // er14
__int64 i; // rbx
unsigned int v7; // eax
unsigned int v8; // er12
unsigned __int64 v9; // rbp
unsigned __int64 v10; // r13

v3 = a3;
result = (unsigned int)(int)(log10((double)a3) + 1.0);
if ( (int)result > 0 )
{
v5 = a1 + 5 * result;
do
{
v8 = a2;
v9 = 100LL * (v3 % 10);
v10 = v9 + 100;
do
{
for ( i = 0LL; i != 5; ++i )
{
if ( num_font[i + v9 / 4] == 1 )
{
v7 = SDL_MapRGB();
func8((unsigned int)(v5 + i), v8, v7);
}
}
++v8;
v9 += 20LL;
}
while ( v9 != v10 );
result = (unsigned int)(v3 / 10);
v3 /= 10;
v5 -= 5;
}
while ( v5 != a1 );
}
return result;
}

original_code:
void draw_number(int x, int y, int num)
{
 int ix, iy;
 int n = -1;
 int t = log10(num)+1;
 while(t>0)
 {
  n = num%10;
  for(iy = 0;iy<5;iy++)
  {
   for(ix = 0;ix<5;ix++)
   {
    if(num_font[n][iy][ix] == 1)
    {
     put_pixel(x+t*5+ix,y+iy,SDL_MapRGB(screen->format,0,0,0));
    }
   }
  }
  num /= 10;
  t--;
 }
}

canonical_original_code:
void draw_number(int x, int y, int num)
{
 int ix; int iy;
 int n = -1;
 int t = log10(num)+1;
 while(t>0)
 {
  n = num%10;
  for(iy = 0;iy<5;iy++)
  {
   for(ix = 0;ix<5;ix++)
   {
    if(num_font[n][iy][ix] == 1)
    {
     put_pixel(x+t*5+ix,y+iy,SDL_MapRGB(screen->format,0,0,0));
    }
   }
  }
  num /= 10;
  t--;
 }
}

variable_types: num int

variable_types: ix int

variable_types: iy int

variable_types: n int

variable_types: t int


canonical_original_code:
void draw_grid()
{
 int x; int y;
 for(y = 0;y<=10;y++)
 {
  struct SDL_Rect t;
  t.x = stage_x+1;
  t.y = stage_y+y*24;
  t.w = 10*24-1;
  t.h = 1;
  SDL_FillRect(screen, &t, 0);
 }
 for(x = 0;x<=10;x++)
 {
  struct SDL_Rect t;
  t.x = stage_x+x*24;
  t.y = stage_y+1;
  t.w = 1;
  t.h = 10*24-1;
  SDL_FillRect(screen, &t, 0);
 }
 for(y = 0;y<10;y++)
 {
  int *img_row = image_get_row(y);
  int cx = 0;
  int f = 0;
  for(x = 10 -1;x>=0;x--)
  {
   if(img_row[x] == 1)
   {
    cx++;
   }
   else
   {
    if(cx>0)
    {
     draw_number((stage_x-12)-(f*10),stage_y+y*24+10,cx);
     cx = 0;
     f++;
    }
   }
  }
  if(f == 0 || cx!=0)
  {
   draw_number((stage_x-12)-(f*10),stage_y+y*24+10,cx);
  }
 }
 for(x = 0;x<10;x++)
 {
  int cy = 0;
  int f = 0;
  for(y = 10 -1;y>=0;y--)
  {
   int *img_row = image_get_row(y);
   if(img_row[x] == 1)
   {
    cy++;
   }
   else
   {
    if(cy>0)
    {
     draw_number(stage_x+x*24+5, (stage_y-12)-(f*10),cy);
     cy = 0;
     f++;
    }
   }
  }
  if(f == 0 || cy!=0)
  {
   draw_number(stage_x+x*24+5, (stage_y-12)-(f*10),cy);
  }
 }
}

variable_types: cx int

variable_types: f int

variable_types: cy int


decompiled_code:
__int64 gameboard_init()
{
SDL_Init();
screen = SDL_SetVideoMode();
return image_generate(10LL, 10LL);
}

canonical_decompiled_code:
__int64 func14()
{
SDL_Init();
screen = SDL_SetVideoMode();
return func18(10LL, 10LL);
}

original_code:
void gameboard_init(void)
{
 SDL_Init(0x00000020);
 screen = SDL_SetVideoMode(480,360,0,0x00000000);
 image_generate(10, 10);
}

canonical_original_code:
void gameboard_init()
{
 SDL_Init(0x00000020);
 screen = SDL_SetVideoMode(480,360,0,0x00000000);
 image_generate(10, 10);
}


decompiled_code:
__int64 gameboard_deinit()
{
image_destroy();
SDL_FreeSurface();
return SDL_Quit();
}

canonical_decompiled_code:
__int64 func15()
{
func20();
SDL_FreeSurface();
return SDL_Quit();
}

original_code:
void gameboard_deinit(void)
{
 image_destroy();
 SDL_FreeSurface(screen);
 SDL_Quit();
}

canonical_original_code:
void gameboard_deinit()
{
 image_destroy();
 SDL_FreeSurface(screen);
 SDL_Quit();
}


decompiled_code:
__int64 gameboard_render()
{
__int64 v0; // rdi

SDL_MapRGB();
v0 = screen;
SDL_FillRect();
draw_grid(v0, 0LL);
draw_highlight();
draw_gameboard();
return SDL_Flip();
}

canonical_decompiled_code:
__int64 func16()
{
__int64 v0; // rdi

SDL_MapRGB();
v0 = screen;
SDL_FillRect();
func13(v0, 0LL);
func9();
func10();
return SDL_Flip();
}

original_code:
void gameboard_render(void)
{
 SDL_FillRect(screen, ((void *)0), SDL_MapRGB(screen->format,255,255,255));
 draw_grid();
 draw_highlight();
 draw_gameboard();
 SDL_Flip(screen);
}

canonical_original_code:
void gameboard_render()
{
 SDL_FillRect(screen, ((void *)0), SDL_MapRGB(screen->format,255,255,255));
 draw_grid();
 draw_highlight();
 draw_gameboard();
 SDL_Flip(screen);
}


decompiled_code:
unsigned __int64 __fastcall image_generate(int a1, int a2)
{
unsigned __int64 result; // rax
void **v3; // rbx
void **v4; // rbp
void **v5; // r13
__int64 v6; // r12
__int64 v7; // rbx

result = (unsigned __int64)malloc(8LL * a2);
image = (void *)result;
imh = a2;
if ( a2 > 0 )
{
v3 = (void **)result;
v4 = (void **)result;
v5 = (void **)(result + 8LL * (unsigned int)a2);
do
*v3++ = malloc(8LL * a1);
while ( v3 != v5 );
result = (unsigned int)(a1 - 1);
v6 = 4 * result + 4;
do
{
v7 = 0LL;
if ( a1 > 0 )
{
do
{
result = (unsigned int)(rand() % 2);
*(_DWORD *)((char *)*v4 + v7) = result;
v7 += 4LL;
}
while ( v6 != v7 );
}
++v4;
}
while ( v4 != v5 );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func18(int a1, int a2)
{
unsigned __int64 result; // rax
void **v3; // rbx
void **v4; // rbp
void **v5; // r13
__int64 v6; // r12
__int64 v7; // rbx

result = (unsigned __int64)malloc(8LL * a2);
image = (void *)result;
imh = a2;
if ( a2 > 0 )
{
v3 = (void **)result;
v4 = (void **)result;
v5 = (void **)(result + 8LL * (unsigned int)a2);
do
*v3++ = malloc(8LL * a1);
while ( v3 != v5 );
result = (unsigned int)(a1 - 1);
v6 = 4 * result + 4;
do
{
v7 = 0LL;
if ( a1 > 0 )
{
do
{
result = (unsigned int)(rand() % 2);
*(_DWORD *)((char *)*v4 + v7) = result;
v7 += 4LL;
}
while ( v6 != v7 );
}
++v4;
}
while ( v4 != v5 );
}
return result;
}

original_code:
void image_generate(int xs, int ys)
{
 image = malloc(sizeof(int*)*ys);
 imw = xs;
 imh = ys;
 int x;
 int y;
 for(y = 0;y<ys;y++)
 {
  image[y] = malloc(sizeof(int*)*xs);
 }
 for(y = 0;y<ys;y++)
 {
  for(x = 0;x<xs;x++)
  {
   image[y][x] = rand()%2;
  }
 }
}

canonical_original_code:
void image_generate(int xs, int ys)
{
 image = malloc(sizeof(int *)*ys);
 imw = xs;
 imh = ys;
 int x;
 int y;
 for(y = 0;y<ys;y++)
 {
  image[y] = malloc(sizeof(int *)*xs);
 }
 for(y = 0;y<ys;y++)
 {
  for(x = 0;x<xs;x++)
  {
   image[y][x] = rand()%2;
  }
 }
}

variable_types: xs int

variable_types: ys int


decompiled_code:
__int64 __fastcall image_get_row(int a1)
{
return *((_QWORD *)image + a1);
}

canonical_decompiled_code:
__int64 __fastcall func19(int a1)
{
return *((_QWORD *)image + a1);
}

original_code:
int *image_get_row(int r)
{
 return image[r];
}

variable_types: r int

return_type: int *


decompiled_code:
void image_destroy()
{
__int64 v0; // rbp
__int64 v1; // rbx

if ( imh > 0 )
{
v0 = 8LL * (unsigned int)imh;
v1 = 0LL;
do
{
free(*(void **)((char *)image + v1));
v1 += 8LL;
}
while ( v1 != v0 );
}
free(image);
}

canonical_decompiled_code:
void func20()
{
__int64 v0; // rbp
__int64 v1; // rbx

if ( imh > 0 )
{
v0 = 8LL * (unsigned int)imh;
v1 = 0LL;
do
{
free(*(void **)((char *)image + v1));
v1 += 8LL;
}
while ( v1 != v0 );
}
free(image);
}

original_code:
void image_destroy()
{
 int y;
 for(y = 0;y<imh;y++)
 {
  free(image[y]);
 }
 free(image);
}

variable_types: y int


initICreateCom

repo: Elektordi/robotcite

decompiled_code:
__int64 __fastcall initICreateCom(const char *a1)
{
__int64 result; // rax
int *v2; // rax
char *v3; // rax

result = initSerial(a1, 57600LL, 8LL, 1LL, 0LL);
iCreateCom = result;
if ( (_DWORD)result == -1 )
{
v2 = _errno_location();
v3 = strerror(*v2);
printf("*** Unable to open %s at 57600 bauds (8n1) [%s]\n", a1, v3);
abort();
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
__int64 result; // rax
int *v2; // rax
char *v3; // rax

result = initSerial(a1, 57600LL, 8LL, 1LL, 0LL);
iCreateCom = result;
if ( (_DWORD)result == -1 )
{
v2 = _errno_location();
v3 = strerror(*v2);
printf("*** Unable to open %s at 57600 bauds (8n1) [%s]\n", a1, v3);
abort();
}
return result;
}

original_code:
void initICreateCom(char* device)
{
  iCreateCom = initSerial(device, 57600, 8, 1, 0);
 if(iCreateCom==-1)
 {
  printf("*** Unable to open %s at 57600 bauds (8n1) [%s]\n",device,strerror((*__errno_location ())));
  abort();
 }
}

canonical_original_code:
void initICreateCom(char *device)
{
  iCreateCom = initSerial(device, 57600, 8, 1, 0);
 if(iCreateCom==-1)
 {
  printf("*** Unable to open %s at 57600 bauds (8n1) [%s]\n",device,strerror((*__errno_location ())));
  abort();
 }
}

variable_types:
device
char *


closeICreateCom

decompiled_code:
__int64 closeICreateCom()
{
return closeSerial((unsigned int)iCreateCom);
}

canonical_decompiled_code:
__int64 func1()
{
return closeSerial((unsigned int)iCreateCom);
}

original_code:
void closeICreateCom()
{
 closeSerial(iCreateCom);
}


decompiled_code:
__int64 iC_Start()
{
sendSerial((unsigned int)iCreateCom, 128LL);
return flushRecieveBuffer((unsigned int)iCreateCom);
}

canonical_decompiled_code:
__int64 func2()
{
sendSerial((unsigned int)iCreateCom, 128LL);
return flushRecieveBuffer((unsigned int)iCreateCom);
}

original_code:
void iC_Start(void)
{
  sendSerial(iCreateCom,128);
  flushRecieveBuffer(iCreateCom);
}

canonical_original_code:
void iC_Start()
{
  sendSerial(iCreateCom,128);
  flushRecieveBuffer(iCreateCom);
}


decompiled_code:
__int64 __fastcall iC_Baud(unsigned __int8 a1)
{
sendSerial((unsigned int)iCreateCom, 129LL);
return sendSerial((unsigned int)iCreateCom, a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int8 a1)
{
sendSerial((unsigned int)iCreateCom, 129LL);
return sendSerial((unsigned int)iCreateCom, a1);
}

original_code:
void iC_Baud(unsigned char baudCode)
{
  sendSerial(iCreateCom,129);
  sendSerial(iCreateCom,baudCode);
}

variable_types:
baudCode
unsigned char


decompiled_code:
__int64 iC_Safe()
{
return sendSerial((unsigned int)iCreateCom, 131LL);
}

canonical_decompiled_code:
__int64 func4()
{
return sendSerial((unsigned int)iCreateCom, 131LL);
}

original_code:
void iC_Safe(void)
{
  sendSerial(iCreateCom,131);
}

canonical_original_code:
void iC_Safe()
{
  sendSerial(iCreateCom,131);
}