decompiled_code:
__int64 __fastcall vid_get_standards(int fd)
{
__int64 result; // rax
__int128 v2; // [rsp+0h] [rbp-A8h] BYREF
char s[16]; // [rsp+10h] [rbp-98h] BYREF
__int128 v4; // [rsp+20h] [rbp-88h]
__int128 v5; // [rsp+30h] [rbp-78h]
__int64 v6; // [rsp+40h] [rbp-68h]
__int128 v7[3]; // [rsp+50h] [rbp-58h] BYREF
__int128 v8; // [rsp+80h] [rbp-28h]
__int128 v9; // [rsp+90h] [rbp-18h]

v7[0] = 0LL;
v7[1] = 0LL;
v7[2] = 0LL;
v8 = 0LL;
v9 = 0LL;
if ( (unsigned int)xioctl(fd, -2147199450, (__int64)v7) == -1 )
{
perror("VIDIOC_G_INPUT");
exit(1);
}
if ( (unsigned int)xioctl(fd, -1068476902, (__int64)v7) == -1 )
{
perror("VIDIOC_ENUM_INPUT");
exit(1);
}
printf("Current input %s supports:\n", (const char *)v7 + 4);
v6 = 0LL;
v2 = 0LL;
*(_OWORD *)s = 0LL;
v4 = 0LL;
v5 = 0LL;
while ( !(unsigned int)xioctl(fd, -1069001191, (__int64)&v2) )
{
if ( ((unsigned __int64)v8 & *((_QWORD *)&v2 + 1)) != 0 )
puts(s);
LODWORD(v2) = v2 + 1;
}
if ( *_errno_location() != 22 || (result = (unsigned int)v2, !(_DWORD)v2) )
{
perror("VIDIOC_ENUMSTD");
exit(1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int fd)
{
__int64 result; // rax
__int128 v2; // [rsp+0h] [rbp-A8h] BYREF
char s[16]; // [rsp+10h] [rbp-98h] BYREF
__int128 v4; // [rsp+20h] [rbp-88h]
__int128 v5; // [rsp+30h] [rbp-78h]
__int64 v6; // [rsp+40h] [rbp-68h]
__int128 v7[3]; // [rsp+50h] [rbp-58h] BYREF
__int128 v8; // [rsp+80h] [rbp-28h]
__int128 v9; // [rsp+90h] [rbp-18h]

v7[0] = 0LL;
v7[1] = 0LL;
v7[2] = 0LL;
v8 = 0LL;
v9 = 0LL;
if ( (unsigned int)func0(fd, -2147199450, (__int64)v7) == -1 )
{
perror("VIDIOC_G_INPUT");
exit(1);
}
if ( (unsigned int)func0(fd, -1068476902, (__int64)v7) == -1 )
{
perror("VIDIOC_ENUM_INPUT");
exit(1);
}
printf("Current input %s supports:\n", (const char *)v7 + 4);
v6 = 0LL;
v2 = 0LL;
*(_OWORD *)s = 0LL;
v4 = 0LL;
v5 = 0LL;
while ( !(unsigned int)func0(fd, -1069001191, (__int64)&v2) )
{
if ( ((unsigned __int64)v8 & *((_QWORD *)&v2 + 1)) != 0 )
puts(s);
LODWORD(v2) = v2 + 1;
}
if ( *_errno_location() != 22 || (result = (unsigned int)v2, !(_DWORD)v2) )
{
perror("VIDIOC_ENUMSTD");
exit(1);
}
return result;
}

original_code:
void vid_get_standards(int handle)
{
 struct v4l2_input input;
 struct v4l2_standard standard;
 memset (&input, 0, sizeof (input));
 if (-1 == xioctl (handle, (((2U) << (((0 +8)+8)+14)) | ((('V')) << (0 +8)) | (((38)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &input.index))
 {
  perror ("VIDIOC_G_INPUT");
  exit (1);
 }
 if (-1 == xioctl (handle, (((2U|1U) << (((0 +8)+8)+14)) | ((('V')) << (0 +8)) | (((26)) << 0) | ((((sizeof(struct v4l2_input)))) << ((0 +8)+8))), &input))
 {
  perror ("VIDIOC_ENUM_INPUT");
  exit (1);
 }
 printf ("Current input %s supports:\n", input.name);
 memset (&standard, 0, sizeof (standard));
 standard.index = 0;
 while (0 == xioctl (handle, (((2U|1U) << (((0 +8)+8)+14)) | ((('V')) << (0 +8)) | (((25)) << 0) | ((((sizeof(struct v4l2_standard)))) << ((0 +8)+8))), &standard))
 {
  if (standard.id & input.std)
   printf ("%s\n", standard.name);
  standard.index++;
 }
 if ((*__errno_location ()) != 22 || standard.index == 0)
 {
  perror ("VIDIOC_ENUMSTD");
  exit (1);
 }
}

variable_types: struct v4l2_input { unsigned int index; unsigned char name[32]; unsigned int type; unsigned int audioset; unsigned int tuner; unsigned long long std; unsigned int status; unsigned int capabilities; unsigned int reserved[3]; }

variable_types: struct v4l2_standard { unsigned int index; unsigned long long id; unsigned char name[24]; struct v4l2_fract { unsigned int numerator; unsigned int denominator; } frameperiod; unsigned int framelines; unsigned int reserved[4]; }

user_defined_types: struct v4l2_standard { unsigned int index; unsigned long long id; unsigned char name[24]; struct v4l2_fract frameperiod; unsigned int framelines; unsigned int reserved[4]; }


xioctl

repo: ElFeesho/OldCProjects

decompiled_code:
__int64 __fastcall xioctl(int fd, int a2, __int64 a3)
{
int i; // eax
unsigned int v5; // er12

for ( i = ioctl(fd, a2, a3); ; i = ioctl(fd, a2, a3) )
{
v5 = i;
if ( i != -1 || *_errno_location() != 4 )
break;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(int fd, int a2, __int64 a3)
{
int i; // eax
unsigned int v5; // er12

for ( i = ioctl(fd, a2, a3); ; i = ioctl(fd, a2, a3) )
{
v5 = i;
if ( i != -1 || *_errno_location() != 4 )
break;
}
return v5;
}

original_code:
static int xioctl(int fd, int32_t request, void *arg)
{
 int r;
 do
 {
  r = ioctl (fd, request, arg);
 } while (-1 == r && 4 == (*__errno_location ()));
 return r;
}

canonical_original_code:
static int xioctl(int fd, int request, void *arg)
{
 int r;
 do
 {
  r = ioctl (fd, request, arg);
 } while (-1 == r && 4 == (*__errno_location ()));
 return r;
}

variable_types: fd int

variable_types: request int

variable_types:
arg
void *

variable_types: r int

return_type: int


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

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

original_code:
extern int groups_get_id()
{
 return groups_selected;
}


decompiled_code:
void *__fastcall thread_entry(void *a1)
{
__int64 v1; // rbx

v1 = 1000000000LL;
while ( ++v1 != 15000000000LL )
{
if ( (double)(int)v1 < 0.0 )
sqrt((double)(int)v1);
}
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func7(void *a1)
{
__int64 v1; // rbx

v1 = 1000000000LL;
while ( ++v1 != 15000000000LL )
{
if ( (double)(int)v1 < 0.0 )
sqrt((double)(int)v1);
}
return 0LL;
}

original_code:
void *thread_entry(void *data)
{
 unsigned long int i;
 for(i=1000000000;i<15000000000;i++)
 {
  double res = sqrt(i);
 }
 return ((void *)0);
}

canonical_original_code:
void *thread_entry(void *data)
{
 unsigned long i;
 for(i=1000000000;i<15000000000;i++)
 {
  double res = sqrt(i);
 }
 return ((void *)0);
}

variable_types:
data
void *

variable_types:
i
unsigned long

variable_types: res double

return_type: void *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
pthread_t *v3; // rbx
__int64 i; // rbx
pthread_t th[256]; // [rsp+0h] [rbp-818h] BYREF
char v7; // [rsp+800h] [rbp-18h] BYREF

v3 = th;
do
pthread_create(v3++, 0LL, thread_entry, 0LL);
while ( v3 != (pthread_t *)&v7 );
for ( i = 0LL; i != 256; ++i )
{
pthread_join(th[i], 0LL);
printf("Thread: %d done!\n", (unsigned int)i);
}
return 0;
}

original_code:
int main(int argc, char **argv)
{
 pthread_t threads[256];
 int i;
 for(i = 0;i<256;i++)
  pthread_create(&threads[i],((void *)0),thread_entry,((void *)0));
 for (i=0; i<256; i++)
 {
  pthread_join(threads[i], ((void *)0));
  printf("Thread: %d done!\n",i);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 unsigned long threads[256];
 int i;
 for(i = 0;i<256;i++)
  pthread_create(&threads[i],((void *)0),thread_entry,((void *)0));
 for (i=0; i<256; i++)
 {
  pthread_join(threads[i], ((void *)0));
  printf("Thread: %d done!\n",i);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
threads
unsigned long [256]

variable_types: i int


decompiled_code:
void get_folder_contents()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
char *get_folder_contents(char *dir_name)
{
 char *ret_string = malloc(32);
}

return_type: char *


decompiled_code:
int __fastcall print_details(__int64 a1, const char *a2)
{
struct stat *v2; // rbx
char *v3; // r12
char *v4; // rax
const char *v5; // r15
const char *v6; // r14
const char *v7; // r13
const char *v8; // r12
const char *v9; // rax

v2 = (struct stat *)malloc(0x90uLL);
v3 = (char *)calloc(0x100uLL, 1uLL);
v4 = stpcpy(v3, a2);
strcpy(v4, (const char *)(a1 + 19));
lstat(v3, v2);
free(v3);
v5 = (const char *)time_format(&v2->st_mtim);
v6 = (const char *)size_format(v2->st_size);
v7 = (const char *)group_format(v2->st_gid);
v8 = (const char *)user_format(v2->st_uid);
v9 = (const char *)mode_format(v2->st_mode);
return printf("%10s %s %s %4s %16s \x1B[32;1m%-16s\x1B[34;0m\n", v9, v8, v7, v6, v5, (const char *)(a1 + 19));
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, const char *a2)
{
struct stat *v2; // rbx
char *v3; // r12
char *v4; // rax
const char *v5; // r15
const char *v6; // r14
const char *v7; // r13
const char *v8; // r12
const char *v9; // rax

v2 = (struct stat *)malloc(0x90uLL);
v3 = (char *)calloc(0x100uLL, 1uLL);
v4 = stpcpy(v3, a2);
strcpy(v4, (const char *)(a1 + 19));
lstat(v3, v2);
free(v3);
v5 = (const char *)time_format(&v2->st_mtim);
v6 = (const char *)size_format(v2->st_size);
v7 = (const char *)group_format(v2->st_gid);
v8 = (const char *)user_format(v2->st_uid);
v9 = (const char *)mode_format(v2->st_mode);
return printf("%10s %s %s %4s %16s \x1B[32;1m%-16s\x1B[34;0m\n", v9, v8, v7, v6, v5, (const char *)(a1 + 19));
}

original_code:
void print_details(struct dirent *dir, char *root_dir)
{
 struct stat *file_mode = malloc(sizeof(struct stat));
 char *cfile_name = malloc(256);
 memset(cfile_name,'\0',256);
 strcpy(cfile_name,root_dir);
 strcat(cfile_name,dir->d_name);
 lstat(cfile_name, file_mode);
 free(cfile_name);
 char *user = malloc(32);
 char *group = malloc(32);
 printf("%10s %s %s %4s %16s \x1b[32;1m%-16s\x1b[34;0m\n",mode_format(file_mode->st_mode),user_format(file_mode->st_uid),group_format(file_mode->st_gid), size_format(file_mode->st_size), time_format(&file_mode->st_mtim.tv_sec), dir->d_name);
}

variable_types: struct dirent { unsigned long d_ino; long d_off; unsigned short d_reclen; unsigned char d_type; char d_name[256]; } *

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:
user
char *

variable_types:
group
char *

return_type: void

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:
__int64 res_load_resources()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax

if ( !res_mutex )
res_mutex = SDL_CreateMutex();
SDL_mutexP();
v0 = SDL_RWFromFile("sound/bass.wav", &unk_318);
samples = Mix_LoadWAV_RW(v0, 1LL);
v1 = SDL_RWFromFile("sound/cym.wav", &unk_318);
qword_2C8 = Mix_LoadWAV_RW(v1, 1LL);
v2 = SDL_RWFromFile("sound/hihat.wav", &unk_318);
qword_2D0 = Mix_LoadWAV_RW(v2, 1LL);
v3 = SDL_RWFromFile("sound/hihat2.wav", &unk_318);
qword_2D8 = Mix_LoadWAV_RW(v3, 1LL);
v4 = SDL_RWFromFile("sound/snare.wav", &unk_318);
qword_2E0 = Mix_LoadWAV_RW(v4, 1LL);
v5 = SDL_RWFromFile("sound/cra.wav", &unk_318);
qword_2E8 = Mix_LoadWAV_RW(v5, 1LL);
v6 = SDL_RWFromFile("sound/hi.wav", &unk_318);
qword_2F0 = Mix_LoadWAV_RW(v6, 1LL);
v7 = SDL_RWFromFile("sound/mid.wav", &unk_318);
qword_2F8 = Mix_LoadWAV_RW(v7, 1LL);
v8 = SDL_RWFromFile("sound/low.wav", &unk_318);
qword_300 = Mix_LoadWAV_RW(v8, 1LL);
v9 = SDL_RWFromFile("sound/stick.wav", &unk_318);
qword_308 = Mix_LoadWAV_RW(v9, 1LL);
kit = IMG_Load("kit.png");
SDL_mutexV(res_mutex);
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax

if ( !res_mutex )
res_mutex = SDL_CreateMutex();
SDL_mutexP();
v0 = SDL_RWFromFile("sound/bass.wav", &unk_318);
samples = Mix_LoadWAV_RW(v0, 1LL);
v1 = SDL_RWFromFile("sound/cym.wav", &unk_318);
qword_2C8 = Mix_LoadWAV_RW(v1, 1LL);
v2 = SDL_RWFromFile("sound/hihat.wav", &unk_318);
qword_2D0 = Mix_LoadWAV_RW(v2, 1LL);
v3 = SDL_RWFromFile("sound/hihat2.wav", &unk_318);
qword_2D8 = Mix_LoadWAV_RW(v3, 1LL);
v4 = SDL_RWFromFile("sound/snare.wav", &unk_318);
qword_2E0 = Mix_LoadWAV_RW(v4, 1LL);
v5 = SDL_RWFromFile("sound/cra.wav", &unk_318);
qword_2E8 = Mix_LoadWAV_RW(v5, 1LL);
v6 = SDL_RWFromFile("sound/hi.wav", &unk_318);
qword_2F0 = Mix_LoadWAV_RW(v6, 1LL);
v7 = SDL_RWFromFile("sound/mid.wav", &unk_318);
qword_2F8 = Mix_LoadWAV_RW(v7, 1LL);
v8 = SDL_RWFromFile("sound/low.wav", &unk_318);
qword_300 = Mix_LoadWAV_RW(v8, 1LL);
v9 = SDL_RWFromFile("sound/stick.wav", &unk_318);
qword_308 = Mix_LoadWAV_RW(v9, 1LL);
kit = IMG_Load("kit.png");
SDL_mutexV(res_mutex);
return 0LL;
}

original_code:
int res_load_resources(void *data)
{
 if(!res_mutex)
  res_mutex = SDL_CreateMutex();
 SDL_mutexP(res_mutex);
 int i = 0;
 samples[i++] = Mix_LoadWAV_RW(SDL_RWFromFile("sound/bass.wav", "rb"), 1);
 samples[i++] = Mix_LoadWAV_RW(SDL_RWFromFile("sound/cym.wav", "rb"), 1);
 samples[i++] = Mix_LoadWAV_RW(SDL_RWFromFile("sound/hihat.wav", "rb"), 1);
 samples[i++] = Mix_LoadWAV_RW(SDL_RWFromFile("sound/hihat2.wav", "rb"), 1);
 samples[i++] = Mix_LoadWAV_RW(SDL_RWFromFile("sound/snare.wav", "rb"), 1);
 samples[i++] = Mix_LoadWAV_RW(SDL_RWFromFile("sound/cra.wav", "rb"), 1);
 samples[i++] = Mix_LoadWAV_RW(SDL_RWFromFile("sound/hi.wav", "rb"), 1);
 samples[i++] = Mix_LoadWAV_RW(SDL_RWFromFile("sound/mid.wav", "rb"), 1);
 samples[i++] = Mix_LoadWAV_RW(SDL_RWFromFile("sound/low.wav", "rb"), 1);
 samples[i++] = Mix_LoadWAV_RW(SDL_RWFromFile("sound/stick.wav", "rb"), 1);
 kit = IMG_Load("kit.png");
 SDL_mutexV(res_mutex);
 return 0;
}


decompiled_code:
__int64 res_loaded()
{
SDL_mutexP(res_mutex);
SDL_mutexV(res_mutex);
return SDL_DestroyMutex(res_mutex);
}

canonical_decompiled_code:
__int64 func1()
{
SDL_mutexP(res_mutex);
SDL_mutexV(res_mutex);
return SDL_DestroyMutex(res_mutex);
}

original_code:
void res_loaded()
{
 SDL_mutexP(res_mutex);
 SDL_mutexV(res_mutex);
 SDL_DestroyMutex(res_mutex);
}


decompiled_code:
__int64 __fastcall res_play(int a1, unsigned int a2)
{
return Mix_PlayChannelTimed(a2, samples[a1], 0LL, 0xFFFFFFFFLL);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, unsigned int a2)
{
return Mix_PlayChannelTimed(a2, samples[a1], 0LL, 0xFFFFFFFFLL);
}

original_code:
void res_play(drum_sounds sound, int channel)
{
 Mix_PlayChannelTimed(channel,samples[sound],0,-1);
}

canonical_original_code:
void res_play(enum drum_sounds sound, int channel)
{
 Mix_PlayChannelTimed(channel,samples[sound],0,-1);
}

variable_types: enum drum_sounds { BASS=0, CYM=1, HIHAT=2, HIHAT2=3, SNARE=4, CRASH=5, HITOM=6, MIDTOM=7, FLOORTOM=8, STICK=9 }

variable_types: channel int


decompiled_code:
__int64 __fastcall _(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return a1;
}

original_code:
char *_(char *str)
{
 return str;
}

canonical_original_code:
char *_(char *str)
{
 return str;
}

variable_types:
str
char *


split

decompiled_code:
char *__fastcall split(const char *a1, char a2, int a3)
{
size_t v5; // rdx
int v6; // eax
__int64 v7; // rsi
size_t v8; // rax
const char *v9; // rbp
int v10; // ecx
int v11; // ecx
size_t v12; // rbx
size_t v13; // rdi
char *v14; // rax
char *result; // rax

v5 = strlen(a1);
if ( a3 )
{
v6 = 0;
v7 = 0LL;
while ( 1 )
{
if ( a1[v7] == a2 && a3 == ++v6 )
{
a3 = v7 + 1;
v8 = (int)v7 + 1;
v9 = &a1[v8];
goto LABEL_9;
}
if ( v7 == v5 )
break;
if ( ++v7 > v5 )
{
v9 = &a1[v7];
v13 = 1LL;
v12 = 0LL;
goto LABEL_12;
}
}
result = 0LL;
}
else
{
v9 = a1;
v8 = 0LL;
do
{
LABEL_9:
v10 = v8;
if ( v8 > v5 )
break;
++v8;
}
while ( a1[v8 - 1] != a2 );
v11 = v10 - a3;
v12 = v11;
v13 = v11 + 1;
LABEL_12:
v14 = (char *)malloc(v13);
result = strncpy(v14, v9, v12);
result[v12] = 0;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func2(const char *a1, char a2, int a3)
{
size_t v5; // rdx
int v6; // eax
__int64 v7; // rsi
size_t v8; // rax
const char *v9; // rbp
int v10; // ecx
int v11; // ecx
size_t v12; // rbx
size_t v13; // rdi
char *v14; // rax
char *result; // rax

v5 = strlen(a1);
if ( a3 )
{
v6 = 0;
v7 = 0LL;
while ( 1 )
{
if ( a1[v7] == a2 && a3 == ++v6 )
{
a3 = v7 + 1;
v8 = (int)v7 + 1;
v9 = &a1[v8];
goto LABEL_9;
}
if ( v7 == v5 )
break;
if ( ++v7 > v5 )
{
v9 = &a1[v7];
v13 = 1LL;
v12 = 0LL;
goto LABEL_12;
}
}
result = 0LL;
}
else
{
v9 = a1;
v8 = 0LL;
do
{
LABEL_9:
v10 = v8;
if ( v8 > v5 )
break;
++v8;
}
while ( a1[v8 - 1] != a2 );
v11 = v10 - a3;
v12 = v11;
v13 = v11 + 1;
LABEL_12:
v14 = (char *)malloc(v13);
result = strncpy(v14, v9, v12);
result[v12] = 0;
}
return result;
}

original_code:
char *split(char *str, char splits, int ret)
{
  char *ptr;
  int a, b, c=0;
  if(ret!=0)
  {
    for(a=0;a<=strlen(str);a++)
    {
      if(str[a]==splits && ++c==ret)
      {
        a++;
        break;
      }
      if(a==strlen(str))
        return ((void *)0);
    }
  } else
  {
    a = 0;
  }
  for(b=a;b<=strlen(str);b++)
    if(str[b]==splits) break;
  ptr = (char *)malloc(sizeof(char)*(b-a+1));
  strncpy(ptr, &str[a], b-a);
  ptr[b-a]=0x0;
  return (char *)ptr;
}

canonical_original_code:
char *split(char *str, char splits, int ret)
{
  char *ptr;
  int a; int b; int c = 0;
  if(ret!=0)
  {
    for(a=0;a<=strlen(str);a++)
    {
      if(str[a]==splits && ++c==ret)
      {
        a++;
        break;
      }
      if(a==strlen(str))
        return ((void *)0);
    }
  } else
  {
    a = 0;
  }
  for(b=a;b<=strlen(str);b++)
    if(str[b]==splits) break;
  ptr = (char *)malloc(sizeof(char)*(b-a+1));
  strncpy(ptr, &str[a], b-a);
  ptr[b-a]=0x0;
  return (char *)ptr;
}

variable_types: splits char

variable_types: ret int

variable_types:
ptr
char *

variable_types: a int

variable_types: b int

variable_types: c int


decompiled_code:
__int64 __fastcall MSN_url_encode(char *s, __int64 a2, int a3)
{
size_t v3; // rbp
int i; // ebx
size_t v5; // rax
char *v6; // r13
unsigned int v7; // er14

v3 = 0LL;
for ( i = 0; ; ++i )
{
v5 = strlen(s);
v6 = (char *)(a2 + i);
if ( i >= a3 || v5 <= v3 )
break;
v7 = s[v3];
if ( isalnum(v7) )
{
*v6 = v7;
}
else
{
i += 2;
snprintf(v6, a3 - (int)v3, "%%%x", v7);
}
++v3;
}
*v6 = 0;
return a2;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s, __int64 a2, int a3)
{
size_t v3; // rbp
int i; // ebx
size_t v5; // rax
char *v6; // r13
unsigned int v7; // er14

v3 = 0LL;
for ( i = 0; ; ++i )
{
v5 = strlen(s);
v6 = (char *)(a2 + i);
if ( i >= a3 || v5 <= v3 )
break;
v7 = s[v3];
if ( isalnum(v7) )
{
*v6 = v7;
}
else
{
i += 2;
snprintf(v6, a3 - (int)v3, "%%%x", v7);
}
++v3;
}
*v6 = 0;
return a2;
}

original_code:
char *MSN_url_encode(char *str, char *ret, int ret_len)
{
  int i, a;
  for(i=0, a=0;i<strlen(str) && a<ret_len;i++, a++)
  {
    if(!isalnum(str[i]))
    {
      snprintf(&ret[a], ret_len-i, "%%%x", str[i]);
      a+=2;
    }
    else
    {
      ret[a] = str[i];
    }
  }
  ret[a]=0x0;
  return ret;
}

canonical_original_code:
char *MSN_url_encode(char *str, char *ret, int ret_len)
{
  int i; int a;
  for(i=0, a=0;i<strlen(str) && a<ret_len;i++, a++)
  {
    if(!isalnum(str[i]))
    {
      snprintf(&ret[a], ret_len-i, "%%%x", str[i]);
      a+=2;
    }
    else
    {
      ret[a] = str[i];
    }
  }
  ret[a]=0x0;
  return ret;
}

variable_types:
ret
char *


decompiled_code:
__int64 __fastcall tcp_connect(char *name, __int16 a2)
{
unsigned int v2; // er12
__int64 v3; // rdx
struct sockaddr v5; // [rsp+0h] [rbp-28h] BYREF

v2 = socket(2, 1, 0);
gethostbyname(name);
v5.sa_family = 2;
*(_WORD *)v5.sa_data = _bswap_16(a2);
*(_DWORD *)&v5.sa_data[2] = ***(_DWORD ***)(v3 + 24);
connect(v2, &v5, 0x10u);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *name, __int16 a2)
{
unsigned int v2; // er12
__int64 v3; // rdx
struct sockaddr v5; // [rsp+0h] [rbp-28h] BYREF

v2 = socket(2, 1, 0);
gethostbyname(name);
v5.sa_family = 2;
*(_WORD *)v5.sa_data = func0(a2);
*(_DWORD *)&v5.sa_data[2] = ***(_DWORD ***)(v3 + 24);
connect(v2, &v5, 0x10u);
return v2;
}

original_code:
int tcp_connect(char *host, short port)
{
 int rsock = socket(2, SOCK_STREAM, 0);
 struct hostent *hent = gethostbyname(host);
 struct sockaddr_in sock_dst;
 sock_dst.sin_family = 2;
 sock_dst.sin_port = htons(port);
 sock_dst.sin_addr = *((struct in_addr*)hent->h_addr_list[0]);
 connect(rsock, (struct sockaddr*)&sock_dst, sizeof(sock_dst));
 return rsock;
}

canonical_original_code:
int tcp_connect(char *host, short port)
{
 int rsock = socket(2, SOCK_STREAM, 0);
 struct hostent *hent = gethostbyname(host);
 struct sockaddr_in sock_dst;
 sock_dst.sin_family = 2;
 sock_dst.sin_port = htons(port);
 sock_dst.sin_addr = *((struct in_addr *)hent->h_addr_list[0]);
 connect(rsock, (struct sockaddr *)&sock_dst, sizeof(sock_dst));
 return rsock;
}

variable_types:
host
char *

variable_types: port short

variable_types: rsock int

variable_types: struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *

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

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


decompiled_code:
void __fastcall __noreturn berr_exit(const char *a1)
{
BIO_printf(bio_err, "%s\n", a1);
ERR_print_errors(bio_err);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func5(const char *a1)
{
BIO_printf(bio_err, "%s\n", a1);
ERR_print_errors(bio_err);
exit(0);
}

original_code:
int berr_exit(char *string)
{
  BIO_printf(bio_err,"%s\n",string);
  ERR_print_errors(bio_err);
  exit(0);
}

variable_types:
string
char *


original_code:
int https_auth(char *origHost,int port,char *origFile,char *msnLogin,char *msnPasswd,char *idString,char *ticket,int ticketLen, void (*callback)(int,void *))
{
  int r;
  pid_t pid;
  struct timeval tv;
  char buf[2048], request[2048], *host, *encodedPasswd, *file, *ptr;
  char requestTemplate[] = "GET /%s HTTP/1.1\r\nAuthorization: "
                           "Passport1.4 OrgVerb=GET,"
                           "OrgURL=http%%3A%%2F%%2Fmessenger%%2Emsn%%2Ecom,"
                           "sign-in=%s,pwd=%s,%sHost: "
         "%s\r\n\r\n";
  pid = getpid();
  RAND_add(&pid, sizeof(pid),0.01);
  pid = getpgrp();
  RAND_add(&pid, sizeof(pid),0.01);
  pid = getppid();
  RAND_add(&pid, sizeof(pid),0.01);
  pid = 0;
  gettimeofday(&tv,((void *)0));
  RAND_add(&tv, sizeof(tv),0.1);
  memset(&tv, '\0', sizeof(tv));
  MSN_url_encode(msnPasswd, buf, sizeof(buf)-1);
  encodedPasswd = strdup(buf);
  host = strdup(origHost);
  file = strdup(origFile);
  if(encodedPasswd==((void *)0) || host==((void *)0) || file==((void *)0))
  {
    if(callback!=((void *)0)) callback(-1,_("Cannot allocate memory"));
    return -1;
  }
 printf("MSN LOGIN: %s\n",msnLogin);
 char *escaped_msnLogin = malloc(strlen(msnLogin)*3+1);
 printf("Done!\n");
 memset(escaped_msnLogin,strlen(msnLogin)*3+1,'\0');
 printf("OT OH\n");
 MSN_url_encode(msnLogin, escaped_msnLogin, strlen(msnLogin)*3);
 printf("SPAGHETTIOHS!\n");
  snprintf(request, 2048 -1, requestTemplate, file, escaped_msnLogin, encodedPasswd, idString, host);
 printf("Request: %s\n", request);
  while((r=get_https(host, port, request, buf, sizeof(buf)-1))==-2)
  {
    free(host);
    free(file);
    if((ptr = strstr(buf, "Location:"))==((void *)0))
    {
      printf("No 'Location:' in HTTP header\n");
      return -1;
    }
    ptr[strlen(ptr)-4]=0x0;
    host = split(ptr, '/', 2);
    file = split(ptr, '/', 3);
    if(host==((void *)0) || file==((void *)0))
    {
      printf("Couldn't parse URL\n");
      return -1;
    }
    if((ptr = strstr(file, "\r\n")) != ((void *)0))
      *ptr = 0x0;
    snprintf(request, sizeof(request)-1, requestTemplate,file, escaped_msnLogin, encodedPasswd, idString, host );
  }
  free(host);
  free(file);
  free(encodedPasswd);
  if(r==-1)
  {
    printf("Bad username or password!\n");
    return -1;
  }
  if((ptr=split(buf, '\'',1))==((void *)0))
  {
    printf("Couldn't extract ticket\n");
    return -1;
  }
  strncpy(ticket, ptr, ticketLen);
  free(ptr);
  return 0;
}

canonical_original_code:
int https_auth(char *origHost, int port, char *origFile, char *msnLogin, char *msnPasswd, char *idString, char *ticket, int ticketLen, void (*callback)(int, void *))
{
  int r;
  int pid;
  struct timeval tv;
  char buf[2048]; char request[2048]; char *host; char *encodedPasswd; char *file; char *ptr;
  char requestTemplate[] = "GET /%s HTTP/1.1\r\nAuthorization: "
                           "Passport1.4 OrgVerb=GET,"
                           "OrgURL=http%%3A%%2F%%2Fmessenger%%2Emsn%%2Ecom,"
                           "sign-in=%s,pwd=%s,%sHost: "
         "%s\r\n\r\n";
  pid = getpid();
  RAND_add(&pid, sizeof(pid),0.01);
  pid = getpgrp();
  RAND_add(&pid, sizeof(pid),0.01);
  pid = getppid();
  RAND_add(&pid, sizeof(pid),0.01);
  pid = 0;
  gettimeofday(&tv,((void *)0));
  RAND_add(&tv, sizeof(tv),0.1);
  memset(&tv, '\0', sizeof(tv));
  MSN_url_encode(msnPasswd, buf, sizeof(buf)-1);
  encodedPasswd = strdup(buf);
  host = strdup(origHost);
  file = strdup(origFile);
  if(encodedPasswd==((void *)0) || host==((void *)0) || file==((void *)0))
  {
    if(callback!=((void *)0)) callback(-1,_("Cannot allocate memory"));
    return -1;
  }
 printf("MSN LOGIN: %s\n",msnLogin);
 char *escaped_msnLogin = malloc(strlen(msnLogin)*3+1);
 printf("Done!\n");
 memset(escaped_msnLogin,strlen(msnLogin)*3+1,'\0');
 printf("OT OH\n");
 MSN_url_encode(msnLogin, escaped_msnLogin, strlen(msnLogin)*3);
 printf("SPAGHETTIOHS!\n");
  snprintf(request, 2048 -1, requestTemplate, file, escaped_msnLogin, encodedPasswd, idString, host);
 printf("Request: %s\n", request);
  while((r=get_https(host, port, request, buf, sizeof(buf)-1))==-2)
  {
    free(host);
    free(file);
    if((ptr = strstr(buf, "Location:"))==((void *)0))
    {
      printf("No 'Location:' in HTTP header\n");
      return -1;
    }
    ptr[strlen(ptr)-4]=0x0;
    host = split(ptr, '/', 2);
    file = split(ptr, '/', 3);
    if(host==((void *)0) || file==((void *)0))
    {
      printf("Couldn't parse URL\n");
      return -1;
    }
    if((ptr = strstr(file, "\r\n")) != ((void *)0))
      *ptr = 0x0;
    snprintf(request, sizeof(request)-1, requestTemplate,file, escaped_msnLogin, encodedPasswd, idString, host );
  }
  free(host);
  free(file);
  free(encodedPasswd);
  if(r==-1)
  {
    printf("Bad username or password!\n");
    return -1;
  }
  if((ptr=split(buf, '\'',1))==((void *)0))
  {
    printf("Couldn't extract ticket\n");
    return -1;
  }
  strncpy(ticket, ptr, ticketLen);
  free(ptr);
  return 0;
}

variable_types:
origHost
char *

variable_types: port int

variable_types:
origFile
char *

variable_types:
msnLogin
char *

variable_types:
msnPasswd
char *

variable_types:
idString
char *

variable_types:
ticket
char *

variable_types: ticketLen int

variable_types:
callback
void (*)(int, void *)

variable_types: r int

variable_types: pid int

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

variable_types:
buf
char [2048]

variable_types:
request
char [2048]

variable_types:
encodedPasswd
char *

variable_types:
file
char *

variable_types:
requestTemplate
char []


decompiled_code:
char *__fastcall time_format(time_t *timer)
{
char *v1; // r12
struct tm *v2; // rax

v1 = (char *)calloc(0x10uLL, 1uLL);
v2 = localtime(timer);
sprintf(
v1,
"%d-%02d-%02d %02d:%02d",
(unsigned int)(v2->tm_year + 1900),
(unsigned int)(v2->tm_mon + 1),
(unsigned int)v2->tm_mday,
(unsigned int)v2->tm_hour,
(unsigned int)v2->tm_min);
return v1;
}

canonical_decompiled_code:
char *__fastcall func1(time_t *timer)
{
char *v1; // r12
struct tm *v2; // rax

v1 = (char *)calloc(0x10uLL, 1uLL);
v2 = localtime(timer);
sprintf(
v1,
"%d-%02d-%02d %02d:%02d",
(unsigned int)(v2->tm_year + 1900),
(unsigned int)(v2->tm_mon + 1),
(unsigned int)v2->tm_mday,
(unsigned int)v2->tm_hour,
(unsigned int)v2->tm_min);
return v1;
}

original_code:
extern char *time_format(time_t *mod_time)
{
 char *rtn = malloc(16);
 memset(rtn,'\0',16);
 struct tm *timeinf = localtime(mod_time);
 sprintf(rtn,"%d-%02d-%02d %02d:%02d",1900+timeinf->tm_year,timeinf->tm_mon+1,timeinf->tm_mday,timeinf->tm_hour,timeinf->tm_min);
 return rtn;
}

canonical_original_code:
extern char *time_format(long *mod_time)
{
 char *rtn = malloc(16);
 memset(rtn,'\0',16);
 struct tm *timeinf = localtime(mod_time);
 sprintf(rtn,"%d-%02d-%02d %02d:%02d",1900+timeinf->tm_year,timeinf->tm_mon+1,timeinf->tm_mday,timeinf->tm_hour,timeinf->tm_min);
 return rtn;
}

variable_types:
rtn
char *

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *


decompiled_code:
char *__fastcall user_format(__uid_t a1)
{
struct passwd *v1; // rax
char *v3; // r13

v1 = getpwuid(a1);
if ( v1 )
return strdup(v1->pw_name);
v3 = (char *)calloc(0xAuLL, 1uLL);
sprintf(v3, "%d", a1);
return v3;
}

canonical_decompiled_code:
char *__fastcall func3(__uid_t a1)
{
struct passwd *v1; // rax
char *v3; // r13

v1 = getpwuid(a1);
if ( v1 )
return strdup(v1->pw_name);
v3 = (char *)calloc(0xAuLL, 1uLL);
sprintf(v3, "%d", a1);
return v3;
}

original_code:
extern char *user_format(int uid)
{
 struct passwd *c_filepass = getpwuid(uid);
 if(c_filepass!=((void *)0))
 {
  return strdup(c_filepass->pw_name);
 }
 else
 {
  char *ret_str = malloc(10);
  memset(ret_str,'\0',10);
  sprintf(ret_str,"%d",uid);
  return ret_str;
 }
}

variable_types: uid int

variable_types: struct passwd { char *pw_name; char *pw_passwd; unsigned int pw_uid; unsigned int pw_gid; char *pw_gecos; char *pw_dir; char *pw_shell; } *


decompiled_code:
char *__fastcall group_format(__gid_t a1)
{
struct group *v1; // rax
char *v3; // r13

v1 = getgrgid(a1);
if ( v1 )
return strdup(v1->gr_name);
v3 = (char *)calloc(0xAuLL, 1uLL);
sprintf(v3, "%d", a1);
return v3;
}

canonical_decompiled_code:
char *__fastcall func4(__gid_t a1)
{
struct group *v1; // rax
char *v3; // r13

v1 = getgrgid(a1);
if ( v1 )
return strdup(v1->gr_name);
v3 = (char *)calloc(0xAuLL, 1uLL);
sprintf(v3, "%d", a1);
return v3;
}

original_code:
extern char *group_format(int gid)
{
 struct group *c_filegroup = getgrgid(gid);
 if(c_filegroup!=((void *)0))
 {
  return strdup(c_filegroup->gr_name);
 }
 else
 {
  char *ret_str = malloc(10);
  memset(ret_str,'\0',10);
  sprintf(ret_str,"%d",gid);
  return ret_str;
 }
}

variable_types: gid int

variable_types: struct group { char *gr_name; char *gr_passwd; unsigned int gr_gid; char **gr_mem; } *


terminate

decompiled_code:
void __noreturn terminate()
{
endwin();
exit(0);
}

canonical_decompiled_code:
void __noreturn func7()
{
endwin();
exit(0);
}

original_code:
static void terminate(int signumber)
{
 endwin();
 exit(0);
}

variable_types: signumber int


decompiled_code:
__int64 net_init()
{
unsigned int v0; // er12
int optval[3]; // [rsp+Ch] [rbp-Ch] BYREF

optval[0] = 1;
v0 = socket(2, 2, 0);
if ( setsockopt(v0, 1, 6, optval, 4u) == -1 )
{
v0 = -1;
mvprintw(
LINES__NCURSES6_TINFO_5_0_19991023 / 2 - 1,
COLS__NCURSES6_TINFO_5_0_19991023 / 2 - 28,
"Failed to initialise network");
}
else
{
udp_sock_dst = 2;
word_4040F2 = _bswap_16_constprop_0("255.255.255.255", &inp);
inet_aton("255.255.255.255", &inp);
}
return v0;
}

canonical_decompiled_code:
__int64 func9()
{
unsigned int v0; // er12
int optval[3]; // [rsp+Ch] [rbp-Ch] BYREF

optval[0] = 1;
v0 = socket(2, 2, 0);
if ( setsockopt(v0, 1, 6, optval, 4u) == -1 )
{
v0 = -1;
mvprintw(
LINES__NCURSES6_TINFO_5_0_19991023 / 2 - 1,
COLS__NCURSES6_TINFO_5_0_19991023 / 2 - 28,
"Failed to initialise network");
}
else
{
udp_sock_dst = 2;
word_4040F2 = func8("255.255.255.255", &inp);
inet_aton("255.255.255.255", &inp);
}
return v0;
}

original_code:
static int net_init()
{
 int udp_sock = socket(2, SOCK_DGRAM, 0);
 int bc = 1;
 if (setsockopt(udp_sock, 1, 6, &bc, sizeof bc) == -1)
 {
  mvprintw(LINES/2-1,COLS/2-strlen("Failed to initialise Network"),"Failed to initialise network");
  return -1;
 }
 udp_sock_dst.sin_family = 2;
 udp_sock_dst.sin_port = htons(9348);
 inet_aton("255.255.255.255",&(udp_sock_dst.sin_addr));
 return udp_sock;
}

variable_types: bc int


decompiled_code:
int __fastcall print_header(char a1)
{
char *v1; // r12

v1 = (char *)malloc(6uLL);
sprintf(v1, "%%%ds", (unsigned int)COLS__NCURSES6_TINFO_5_0_19991023);
wattr_on(_bss_start, 0x40000uLL, 0LL);
mvprintw(0, 0, v1, " ");
mvprintw(0, 2, "GMU mamo 2.0.6");
mvprintw(0, (COLS__NCURSES6_TINFO_5_0_19991023 - 16) / 2, "File: UDsPlat");
if ( a1 )
mvprintw(0, COLS__NCURSES6_TINFO_5_0_19991023 - 10, "Modified");
wattr_off(_bss_start, 0x40000uLL, 0LL);
return wmove(_bss_start, 1, 0);
}

canonical_decompiled_code:
int __fastcall func10(char a1)
{
char *v1; // r12

v1 = (char *)malloc(6uLL);
sprintf(v1, "%%%ds", (unsigned int)COLS__NCURSES6_TINFO_5_0_19991023);
wattr_on(_bss_start, 0x40000uLL, 0LL);
mvprintw(0, 0, v1, " ");
mvprintw(0, 2, "GMU mamo 2.0.6");
mvprintw(0, (COLS__NCURSES6_TINFO_5_0_19991023 - 16) / 2, "File: UDsPlat");
if ( a1 )
mvprintw(0, COLS__NCURSES6_TINFO_5_0_19991023 - 10, "Modified");
wattr_off(_bss_start, 0x40000uLL, 0LL);
return wmove(_bss_start, 1, 0);
}

original_code:
void print_header(_Bool modified)
{
 char *print_blank = malloc(6);
 sprintf(print_blank,"%%%ds",COLS);
 wattr_on(stdscr, (attr_t)((((chtype)((1U)) << ((10) + 8)))), ((void *)0));
 mvprintw(0,0,print_blank," ");
 mvprintw(0,2,"GMU mamo 2.0.6");
 mvprintw(0,(COLS-16)/2,"File: UDsPlat");
 if(modified==1)
 {
  mvprintw(0,COLS-10, "Modified");
 }
 wattr_off(stdscr, (attr_t)((((chtype)((1U)) << ((10) + 8)))), ((void *)0));
 wmove(stdscr,(1),(0));
}


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebx

signal(2, terminate);
initscr();
keypad(_bss_start, 1);
nonl();
cbreak();
noecho();
print_header(1LL);
if ( (unsigned int)net_init() != -1 )
{
do
{
v3 = wgetch(_bss_start);
print_header(1LL);
wrefresh(_bss_start);
}
while ( v3 != 65 );
terminate(0);
}
wgetch(_bss_start);
terminate(0);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebx

signal(2, terminate);
initscr();
keypad(_bss_start, 1);
nonl();
cbreak();
noecho();
func10(1LL);
if ( (unsigned int)func9() != -1 )
{
do
{
v3 = wgetch(_bss_start);
func10(1LL);
wrefresh(_bss_start);
}
while ( v3 != 65 );
func7(0);
}
wgetch(_bss_start);
func7(0);
}

original_code:
int main(int argc, char **argv)
{
 signal(2, terminate);
 initscr();
 keypad(stdscr, 1);
 nonl();
 cbreak();
 noecho();
 print_header(1);
 int sock = net_init();
 if(sock==-1)
 {
  wgetch(stdscr);
  terminate(0);
 }
 for(;;)
 {
  int c = wgetch(stdscr);
  print_header(1);
  wrefresh(stdscr);
  if(c == 65)
   break;
 }
 terminate(0);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: sock int

variable_types: c int


decompiled_code:
void __noreturn jump_func()
{
struct __jmp_buf_tag v0; // [rsp+0h] [rbp-D8h] BYREF

_setjmp(&v0);
puts("Here");
longjmp(&v0, 0);
}

canonical_decompiled_code:
void __noreturn func7()
{
struct __jmp_buf_tag v0; // [rsp+0h] [rbp-D8h] BYREF

_setjmp(&v0);
puts("Here");
longjmp(&v0, 0);
}

original_code:
void jump_func()
{
 jmp_buf env;
 int i = 0;
 _setjmp (env);
 printf("Here\n");
 if(i == 0)
 {
  i=1;
  longjmp(env,0);
 }
}

canonical_original_code:
void jump_func()
{
 struct __jmp_buf_tag env[1];
 int i = 0;
 _setjmp (env);
 printf("Here\n");
 if(i == 0)
 {
  i=1;
  longjmp(env,0);
 }
}

variable_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } [1]

variable_types: i int

user_defined_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t __saved_mask; }


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
jump_func(argc, argv, envp);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
func7(argc, argv, envp);
}

original_code:
int main(int argc, char **argv)
{
 jump_func();
 return 0;
}


original_code:
void manip_decompress_init()
{
 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;
 }
}

canonical_original_code:
void manip_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;
 }
}

variable_types: val int

variable_types: len int

variable_types: unk int


original_code:
int manip_decompress(int width, int height, unsigned char *inp, unsigned char *outp)
{
 int row, col;
 int val;
 int bitpos;
 unsigned char code;
 unsigned char *addr;
 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;
   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 manip_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;
 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;
   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 *


decompiled_code:
__int64 gtk_vimage_get_type_once()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("GtkVImage");
v1 = gtk_widget_get_type();
return g_type_register_static_simple(v1, v0, 720LL, gtk_vimage_class_intern_init, 112LL, gtk_vimage_init, 0LL);
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("GtkVImage");
v1 = gtk_widget_get_type();
return g_type_register_static_simple(v1, v0, 720LL, gtk_vimage_class_intern_init, 112LL, gtk_vimage_init, 0LL);
}

original_code: __attribute__((noinline)) static GType gtk_vimage_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((gtk_widget_get_type ()), g_intern_static_string ("GtkVImage"), sizeof (GtkVImageClass), (GClassInitFunc)(void (*)(void)) gtk_vimage_class_intern_init, sizeof (GtkVImage), (GInstanceInitFunc)(void (*)(void)) gtk_vimage_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

canonical_original_code: static unsigned long gtk_vimage_get_type_once() { unsigned long g_define_type_id = g_type_register_static_simple ((gtk_widget_get_type ()), g_intern_static_string ("GtkVImage"), sizeof (GtkVImageClass), (GClassInitFunc)(void (*)(void)) gtk_vimage_class_intern_init, sizeof (GtkVImage), (GInstanceInitFunc)(void (*)(void)) gtk_vimage_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

return_type: unsigned long


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


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


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


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

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

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

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

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 *


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; // r12
char *v3; // rax
struct stat *v4; // rbx
struct timespec *v5; // r15
void *v6; // rbp
__int64 v7; // rax
__int64 v8; // rdi
__int64 v9; // rax
__int64 v10; // rdi
__int64 v11; // rax
__off_t v12; // rdi
__int64 v13; // rax
__int64 v14; // rdi
__int64 v15; // rax
int v16; // ebx
size_t v17; // rax
const char *v18; // rdi
int v19; // ebx
size_t v20; // rax
__int64 *v21; // rax
__int64 v22; // rdx
__int64 *v23; // rbp
__int64 v24; // rax
__int64 v25; // rdi
__int64 v26; // rbp
__int64 v27; // rax
__int64 v28; // rdi
__int64 v29; // rbp
__int64 v30; // rax
__off_t v31; // rdi
__int64 v32; // rbp
__int64 v33; // rax
__int64 v34; // rdi
__int64 v35; // rbp
__int64 v36; // rax
__int64 v37; // rbx
__int64 v38; // rbx
__int64 v39; // rax

v2 = (char *)calloc(0x100uLL, 1uLL);
v3 = stpcpy(v2, a2);
*v3 = 47;
strcpy(v3 + 1, src);
v4 = (struct stat *)malloc(0x90uLL);
if ( lstat(v2, v4) == -1 )
{
fprintf(stderr, "Couldn't stat %s\n", v2);
exit(1);
}
v5 = &v4->st_mtim;
if ( file_list )
{
v6 = malloc(0x40uLL);
v7 = fname_format(src, a2, v4->st_mode, 0LL);
v8 = v4->st_uid;
*(_QWORD *)v6 = v7;
v9 = user_format(v8);
v10 = v4->st_gid;
*((_QWORD *)v6 + 1) = v9;
v11 = group_format(v10);
v12 = v4->st_size;
*((_QWORD *)v6 + 2) = v11;
v13 = size_format(v12);
v14 = v4->st_mode;
*((_QWORD *)v6 + 3) = v13;
*((_QWORD *)v6 + 4) = mode_format(v14);
*((_QWORD *)v6 + 5) = time_format(&v4->st_mtim);
*((_QWORD *)v6 + 6) = nested_format(v2);
v15 = file_list;
file_list = (__int64)v6;
*((_QWORD *)v6 + 7) = v15;
}
else
{
v21 = (__int64 *)malloc(0x40uLL);
v22 = v4->st_mode;
v23 = v21;
file_list = (__int64)v21;
v24 = fname_format(src, a2, v22, 0LL);
v25 = v4->st_uid;
*v23 = v24;
v26 = file_list;
v27 = user_format(v25);
v28 = v4->st_gid;
*(_QWORD *)(v26 + 8) = v27;
v29 = file_list;
v30 = group_format(v28);
v31 = v4->st_size;
*(_QWORD *)(v29 + 16) = v30;
v32 = file_list;
v33 = size_format(v31);
v34 = v4->st_mode;
*(_QWORD *)(v32 + 24) = v33;
v35 = file_list;
v36 = mode_format(v34);
v37 = file_list;
*(_QWORD *)(v35 + 32) = v36;
*(_QWORD *)(v37 + 40) = time_format(v5);
v38 = file_list;
v39 = nested_format(v2);
v6 = (void *)file_list;
*(_QWORD *)(v38 + 48) = v39;
*((_QWORD *)v6 + 7) = 0LL;
}
v16 = filelist_user_len;
v17 = strlen(*((const char **)v6 + 1));
v18 = (const char *)*((_QWORD *)v6 + 2);
if ( v16 <= v17 )
v16 = v17;
filelist_user_len = v16;
v19 = filelist_group_len;
v20 = strlen(v18);
if ( v19 <= v20 )
v19 = v20;
filelist_group_len = v19;
free(v2);
}

canonical_decompiled_code:
void __fastcall func0(char *src, char *a2)
{
char *v2; // r12
char *v3; // rax
struct stat *v4; // rbx
struct timespec *v5; // r15
void *v6; // rbp
__int64 v7; // rax
__int64 v8; // rdi
__int64 v9; // rax
__int64 v10; // rdi
__int64 v11; // rax
__off_t v12; // rdi
__int64 v13; // rax
__int64 v14; // rdi
__int64 v15; // rax
int v16; // ebx
size_t v17; // rax
const char *v18; // rdi
int v19; // ebx
size_t v20; // rax
__int64 *v21; // rax
__int64 v22; // rdx
__int64 *v23; // rbp
__int64 v24; // rax
__int64 v25; // rdi
__int64 v26; // rbp
__int64 v27; // rax
__int64 v28; // rdi
__int64 v29; // rbp
__int64 v30; // rax
__off_t v31; // rdi
__int64 v32; // rbp
__int64 v33; // rax
__int64 v34; // rdi
__int64 v35; // rbp
__int64 v36; // rax
__int64 v37; // rbx
__int64 v38; // rbx
__int64 v39; // rax

v2 = (char *)calloc(0x100uLL, 1uLL);
v3 = stpcpy(v2, a2);
*v3 = 47;
strcpy(v3 + 1, src);
v4 = (struct stat *)malloc(0x90uLL);
if ( lstat(v2, v4) == -1 )
{
fprintf(stderr, "Couldn't stat %s\n", v2);
exit(1);
}
v5 = &v4->st_mtim;
if ( file_list )
{
v6 = malloc(0x40uLL);
v7 = fname_format(src, a2, v4->st_mode, 0LL);
v8 = v4->st_uid;
*(_QWORD *)v6 = v7;
v9 = user_format(v8);
v10 = v4->st_gid;
*((_QWORD *)v6 + 1) = v9;
v11 = group_format(v10);
v12 = v4->st_size;
*((_QWORD *)v6 + 2) = v11;
v13 = size_format(v12);
v14 = v4->st_mode;
*((_QWORD *)v6 + 3) = v13;
*((_QWORD *)v6 + 4) = mode_format(v14);
*((_QWORD *)v6 + 5) = time_format(&v4->st_mtim);
*((_QWORD *)v6 + 6) = nested_format(v2);
v15 = file_list;
file_list = (__int64)v6;
*((_QWORD *)v6 + 7) = v15;
}
else
{
v21 = (__int64 *)malloc(0x40uLL);
v22 = v4->st_mode;
v23 = v21;
file_list = (__int64)v21;
v24 = fname_format(src, a2, v22, 0LL);
v25 = v4->st_uid;
*v23 = v24;
v26 = file_list;
v27 = user_format(v25);
v28 = v4->st_gid;
*(_QWORD *)(v26 + 8) = v27;
v29 = file_list;
v30 = group_format(v28);
v31 = v4->st_size;
*(_QWORD *)(v29 + 16) = v30;
v32 = file_list;
v33 = size_format(v31);
v34 = v4->st_mode;
*(_QWORD *)(v32 + 24) = v33;
v35 = file_list;
v36 = mode_format(v34);
v37 = file_list;
*(_QWORD *)(v35 + 32) = v36;
*(_QWORD *)(v37 + 40) = time_format(v5);
v38 = file_list;
v39 = nested_format(v2);
v6 = (void *)file_list;
*(_QWORD *)(v38 + 48) = v39;
*((_QWORD *)v6 + 7) = 0LL;
}
v16 = filelist_user_len;
v17 = strlen(*((const char **)v6 + 1));
v18 = (const char *)*((_QWORD *)v6 + 2);
if ( v16 <= v17 )
v16 = v17;
filelist_user_len = v16;
v19 = filelist_group_len;
v20 = strlen(v18);
if ( v19 <= v20 )
v19 = v20;
filelist_group_len = v19;
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; } *


decompiled_code:
int filelist_print()
{
char *v0; // rbp
int result; // eax
_QWORD *v2; // rbx
int v3; // [rsp-10h] [rbp-28h]

v0 = (char *)calloc(0x20uLL, 1uLL);
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
{
printf(v0, v2[4], v2[1], v2[2], v2[3], v2[5], *v2, v2[6]);
v2 = (_QWORD *)v2[7];
result = v3;
}
while ( v2 );
}
return result;
}

canonical_decompiled_code:
int func1()
{
char *v0; // rbp
int result; // eax
_QWORD *v2; // rbx
int v3; // [rsp-10h] [rbp-28h]

v0 = (char *)calloc(0x20uLL, 1uLL);
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
{
printf(v0, v2[4], v2[1], v2[2], v2[3], v2[5], *v2, v2[6]);
v2 = (_QWORD *)v2[7];
result = v3;
}
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:
__int64 __fastcall wiiuse_startup(const char *a1)
{
__int64 v1; // r12
__int64 result; // rax
void (__fastcall *v3)(__int64 *); // rax
__int64 v4; // r12

v1 = wiiuse_api;
if ( wiiuse_api )
return *(_QWORD *)wiiuse_api;
if ( !a1 )
return v1;
wiiuse_mod = dlopen(a1, 2);
if ( !wiiuse_mod )
return v1;
v3 = (void (__fastcall *)(__int64 *))dlsym(wiiuse_mod, "wiiuse_main");
if ( !v3 || (v3(&wiiuse_api), *(_DWORD *)(wiiuse_api + 8) != 8) )
{
wiiuse_shutdown();
return v1;
}
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);
v4 = *(_QWORD *)wiiuse_api;
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);
result = v4;
wiiuse_poll = *(_QWORD *)(wiiuse_api + 184);
return result;
}

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

v1 = wiiuse_api;
if ( wiiuse_api )
return *(_QWORD *)wiiuse_api;
if ( !a1 )
return v1;
wiiuse_mod = dlopen(a1, 2);
if ( !wiiuse_mod )
return v1;
v3 = (void (__fastcall *)(__int64 *))dlsym(wiiuse_mod, "wiiuse_main");
if ( !v3 || (v3(&wiiuse_api), *(_DWORD *)(wiiuse_api + 8) != 8) )
{
func0();
return v1;
}
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);
v4 = *(_QWORD *)wiiuse_api;
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);
result = v4;
wiiuse_poll = *(_QWORD *)(wiiuse_api + 184);
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 i; // er8

v0 = qlist;
for ( i = 0; v0; ++i )
v0 = *(_QWORD *)(v0 + 8);
return i;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rax
unsigned int i; // er8

v0 = qlist;
for ( i = 0; v0; ++i )
v0 = *(_QWORD *)(v0 + 8);
return i;
}

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 result; // al

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

canonical_decompiled_code:
char __fastcall func4(char *s)
{
bool v1; // zf
char result; // al

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

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

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

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; // r12
char *v4; // rbp
int v5; // ebx
_BYTE *v6; // rbp

if ( argc != 1 )
func5(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;
}

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 **