decompiled_code:
__int64 resolve_syms()
{
char *v0; // rax

IPC_init = (__int64 (__fastcall *)(_QWORD, _QWORD))dlsym(test_handle, "IPC_init");
v0 = dlerror();
dl_error = (__int64)v0;
if ( v0 )
goto LABEL_14;
if ( !IPC_init )
return 0xFFFFFFFFLL;
printf("loaded %s,addr %p\n", "IPC_init", IPC_init);
IPC_close = (__int64)dlsym(test_handle, "IPC_close");
v0 = dlerror();
dl_error = (__int64)v0;
if ( v0 )
goto LABEL_14;
if ( !IPC_close )
return 0xFFFFFFFFLL;
printf("loaded %s,addr %p\n", "IPC_close", (const void *)IPC_close);
IPC_peek = (__int64 (__fastcall *)(_QWORD, _QWORD))dlsym(test_handle, "IPC_peek");
v0 = dlerror();
dl_error = (__int64)v0;
if ( v0 )
goto LABEL_14;
if ( !IPC_peek )
return 0xFFFFFFFFLL;
printf("loaded %s,addr %p\n", "IPC_peek", IPC_peek);
IPC_recv = (__int64 (__fastcall *)(_QWORD, _QWORD))dlsym(test_handle, "IPC_recv");
v0 = dlerror();
dl_error = (__int64)v0;
if ( v0 )
goto LABEL_14;
if ( !IPC_recv )
return 0xFFFFFFFFLL;
printf("loaded %s,addr %p\n", "IPC_recv", IPC_recv);
IPC_send = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD, _QWORD))dlsym(test_handle, "IPC_send");
v0 = dlerror();
dl_error = (__int64)v0;
if ( v0 )
goto LABEL_14;
if ( !IPC_send )
return 0xFFFFFFFFLL;
printf("loaded %s,addr %p\n", "IPC_send", IPC_send);
get_version = (__int64 (*)(void))dlsym(test_handle, "get_version");
v0 = dlerror();
dl_error = (__int64)v0;
if ( v0 )
{
LABEL_14:
printf("DL_ERROR: %s\n", v0);
return 0xFFFFFFFFLL;
}
if ( get_version )
{
printf("loaded %s,addr %p\n", "get_version", get_version);
return 0LL;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func8()
{
char *v0; // rax

IPC_init = (__int64 (__fastcall *)(_QWORD, _QWORD))dlsym(test_handle, "IPC_init");
v0 = dlerror();
dl_error = (__int64)v0;
if ( v0 )
goto LABEL_14;
if ( !IPC_init )
return 0xFFFFFFFFLL;
printf("loaded %s,addr %p\n", "IPC_init", IPC_init);
IPC_close = (__int64)dlsym(test_handle, "IPC_close");
v0 = dlerror();
dl_error = (__int64)v0;
if ( v0 )
goto LABEL_14;
if ( !IPC_close )
return 0xFFFFFFFFLL;
printf("loaded %s,addr %p\n", "IPC_close", (const void *)IPC_close);
IPC_peek = (__int64 (__fastcall *)(_QWORD, _QWORD))dlsym(test_handle, "IPC_peek");
v0 = dlerror();
dl_error = (__int64)v0;
if ( v0 )
goto LABEL_14;
if ( !IPC_peek )
return 0xFFFFFFFFLL;
printf("loaded %s,addr %p\n", "IPC_peek", IPC_peek);
IPC_recv = (__int64 (__fastcall *)(_QWORD, _QWORD))dlsym(test_handle, "IPC_recv");
v0 = dlerror();
dl_error = (__int64)v0;
if ( v0 )
goto LABEL_14;
if ( !IPC_recv )
return 0xFFFFFFFFLL;
printf("loaded %s,addr %p\n", "IPC_recv", IPC_recv);
IPC_send = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD, _QWORD))dlsym(test_handle, "IPC_send");
v0 = dlerror();
dl_error = (__int64)v0;
if ( v0 )
goto LABEL_14;
if ( !IPC_send )
return 0xFFFFFFFFLL;
printf("loaded %s,addr %p\n", "IPC_send", IPC_send);
get_version = (__int64 (*)(void))dlsym(test_handle, "get_version");
v0 = dlerror();
dl_error = (__int64)v0;
if ( v0 )
{
LABEL_14:
printf("DL_ERROR: %s\n", v0);
return 0xFFFFFFFFLL;
}
if ( get_version )
{
printf("loaded %s,addr %p\n", "get_version", get_version);
return 0LL;
}
return 0xFFFFFFFFLL;
}

original_code:
int resolve_syms()
{
    do {(*(int**)(&IPC_init)=dlsym(test_handle,"IPC_init")); dl_error = dlerror(); if(dl_error!=((void *)0)) { printf("DL_ERROR: %s\n",dl_error); return -1; } if(IPC_init==((void *)0)) return -1; printf("loaded %s,addr %p\n","IPC_init",(int*)IPC_init); }while(0);;
    do {(*(int**)(&IPC_close)=dlsym(test_handle,"IPC_close")); dl_error = dlerror(); if(dl_error!=((void *)0)) { printf("DL_ERROR: %s\n",dl_error); return -1; } if(IPC_close==((void *)0)) return -1; printf("loaded %s,addr %p\n","IPC_close",(int*)IPC_close); }while(0);;
    do {(*(int**)(&IPC_peek)=dlsym(test_handle,"IPC_peek")); dl_error = dlerror(); if(dl_error!=((void *)0)) { printf("DL_ERROR: %s\n",dl_error); return -1; } if(IPC_peek==((void *)0)) return -1; printf("loaded %s,addr %p\n","IPC_peek",(int*)IPC_peek); }while(0);;
    do {(*(int**)(&IPC_recv)=dlsym(test_handle,"IPC_recv")); dl_error = dlerror(); if(dl_error!=((void *)0)) { printf("DL_ERROR: %s\n",dl_error); return -1; } if(IPC_recv==((void *)0)) return -1; printf("loaded %s,addr %p\n","IPC_recv",(int*)IPC_recv); }while(0);;
    do {(*(int**)(&IPC_send)=dlsym(test_handle,"IPC_send")); dl_error = dlerror(); if(dl_error!=((void *)0)) { printf("DL_ERROR: %s\n",dl_error); return -1; } if(IPC_send==((void *)0)) return -1; printf("loaded %s,addr %p\n","IPC_send",(int*)IPC_send); }while(0);;
    do {(*(char***)(&get_version)=dlsym(test_handle,"get_version")); dl_error = dlerror(); if(dl_error!=((void *)0)) { printf("DL_ERROR: %s\n",dl_error); return -1; } if(get_version==((void *)0)) return -1; printf("loaded %s,addr %p\n","get_version",(int*)get_version); }while(0);;
    return 0;
}

canonical_original_code:
int resolve_syms()
{
    do {(*(int **)(&IPC_init)=dlsym(test_handle,"IPC_init")); dl_error = dlerror(); if(dl_error!=((void *)0)) { printf("DL_ERROR: %s\n",dl_error); return -1; } if(IPC_init==((void *)0)) return -1; printf("loaded %s,addr %p\n","IPC_init",(int *)IPC_init); }while(0);;
    do {(*(int **)(&IPC_close)=dlsym(test_handle,"IPC_close")); dl_error = dlerror(); if(dl_error!=((void *)0)) { printf("DL_ERROR: %s\n",dl_error); return -1; } if(IPC_close==((void *)0)) return -1; printf("loaded %s,addr %p\n","IPC_close",(int *)IPC_close); }while(0);;
    do {(*(int **)(&IPC_peek)=dlsym(test_handle,"IPC_peek")); dl_error = dlerror(); if(dl_error!=((void *)0)) { printf("DL_ERROR: %s\n",dl_error); return -1; } if(IPC_peek==((void *)0)) return -1; printf("loaded %s,addr %p\n","IPC_peek",(int *)IPC_peek); }while(0);;
    do {(*(int **)(&IPC_recv)=dlsym(test_handle,"IPC_recv")); dl_error = dlerror(); if(dl_error!=((void *)0)) { printf("DL_ERROR: %s\n",dl_error); return -1; } if(IPC_recv==((void *)0)) return -1; printf("loaded %s,addr %p\n","IPC_recv",(int *)IPC_recv); }while(0);;
    do {(*(int **)(&IPC_send)=dlsym(test_handle,"IPC_send")); dl_error = dlerror(); if(dl_error!=((void *)0)) { printf("DL_ERROR: %s\n",dl_error); return -1; } if(IPC_send==((void *)0)) return -1; printf("loaded %s,addr %p\n","IPC_send",(int *)IPC_send); }while(0);;
    do {(*(char ***)(&get_version)=dlsym(test_handle,"get_version")); dl_error = dlerror(); if(dl_error!=((void *)0)) { printf("DL_ERROR: %s\n",dl_error); return -1; } if(get_version==((void *)0)) return -1; printf("loaded %s,addr %p\n","get_version",(int *)get_version); }while(0);;
    return 0;
}


repo: shadowpho/Lisa

decompiled_code:
__int64 close_lib()
{
unsigned int v0; // er12

v0 = IPC_close();
dlclose(test_handle);
if ( v0 )
{
v0 = -1;
perror("closing");
}
return v0;
}

canonical_decompiled_code:
__int64 func9()
{
unsigned int v0; // er12

v0 = IPC_close();
dlclose(test_handle);
if ( v0 )
{
v0 = -1;
perror("closing");
}
return v0;
}

original_code:
int close_lib()
{
    int status = IPC_close();
    dlclose(test_handle);
    if(status!=0) {
        perror("closing");
        return -1;
    }
    return 0;
}

variable_types: status int

return_type: int


repo: shailikapoor/fusegit

decompiled_code:
__int64 __fastcall hello_proc(__int64 a1, const char *a2, unsigned int a3)
{
printf("key: %d, arg: %s\n", a3, a2);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, const char *a2, unsigned int a3)
{
printf("key: %d, arg: %s\n", a3, a2);
return 1LL;
}

original_code:
int hello_proc(void *data, const char *arg, int key, struct fuse_args *outargs)
{
 printf("key: %d, arg: %s\n", key, arg);
 return 1;
}

canonical_original_code:
int hello_proc(void *data, char *arg, int key, struct fuse_args *outargs)
{
 printf("key: %d, arg: %s\n", key, arg);
 return 1;
}

variable_types:
data
void *

variable_types:
arg
char *

variable_types: key int

variable_types: struct fuse_args { int argc; char **argv; int allocated; } *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
fuse_opt_parse();
return 0;
}

original_code:
int main(int argc, char *argv[])
{
 struct fuse_args args = { argc, argv, 0 };
 struct fuse_opt opts[] = {
  { "-b ", -1U, 1 },
  { "-r ", -1U, 2 },
  { "-o ", -1U, 3 },
  { ((void *)0), 0, 0 }
 };
 fuse_opt_parse(&args, ((void *)0), opts, hello_proc);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct fuse_args { int argc; char **argv; int allocated; }

variable_types: struct fuse_opt { char *templ; unsigned long offset; int value; } []


decompiled_code:
__int64 fg_access()
{
debug_print("FG_ACCESS");
return 4294967258LL;
}

canonical_decompiled_code:
__int64 func0()
{
debug_print("FG_ACCESS");
return 4294967258LL;
}

original_code:
static int fg_access(const char *path, int mask)
{
 debug_print("FG_ACCESS");
        return -38;
}

canonical_original_code:
static int fg_access(char *path, int mask)
{
 debug_print("FG_ACCESS");
        return -38;
}

variable_types:
path
char *

variable_types: mask int


decompiled_code:
__int64 fg_statfs()
{
debug_print("FG_STATFS");
return 4294967258LL;
}

canonical_decompiled_code:
__int64 func1()
{
debug_print("FG_STATFS");
return 4294967258LL;
}

original_code:
static int fg_statfs(const char *path, struct statvfs *stbuf)
{
 debug_print("FG_STATFS");
        return -38;
}

canonical_original_code:
static int fg_statfs(char *path, struct statvfs *stbuf)
{
 debug_print("FG_STATFS");
        return -38;
}

variable_types: struct statvfs { unsigned long f_bsize; unsigned long f_frsize; unsigned long f_blocks; unsigned long f_bfree; unsigned long f_bavail; unsigned long f_files; unsigned long f_ffree; unsigned long f_favail; unsigned long f_fsid; unsigned long f_flag; unsigned long f_namemax; int __f_spare[6]; } *


decompiled_code:
__int64 fg_symlink()
{
debug_print("FG_SYMLINK");
return 4294967258LL;
}

canonical_decompiled_code:
__int64 func2()
{
debug_print("FG_SYMLINK");
return 4294967258LL;
}

original_code:
static int fg_symlink(const char *from, const char *to)
{
 debug_print("FG_SYMLINK");
        return -38;
}

canonical_original_code:
static int fg_symlink(char *from, char *to)
{
 debug_print("FG_SYMLINK");
        return -38;
}

variable_types:
from
char *

variable_types:
to
char *


decompiled_code:
__int64 fg_mknod()
{
debug_print("FG_MKNOD");
return 4294967258LL;
}

canonical_decompiled_code:
__int64 func3()
{
debug_print("FG_MKNOD");
return 4294967258LL;
}

original_code:
static int fg_mknod(const char *path, mode_t mode, dev_t rdev)
{
 debug_print("FG_MKNOD");
        return -38;
}

canonical_original_code:
static int fg_mknod(char *path, unsigned int mode, unsigned long rdev)
{
 debug_print("FG_MKNOD");
        return -38;
}

variable_types:
mode
unsigned int

variable_types:
rdev
unsigned long


decompiled_code:
__int64 fg_readlink()
{
debug_print("FG_READLINK");
return 4294967258LL;
}

canonical_decompiled_code:
__int64 func4()
{
debug_print("FG_READLINK");
return 4294967258LL;
}

original_code:
static int fg_readlink(const char *path, char *buf, size_t size)
{
 debug_print("FG_READLINK");
        return -38;
}

canonical_original_code:
static int fg_readlink(char *path, char *buf, unsigned long size)
{
 debug_print("FG_READLINK");
        return -38;
}

variable_types:
buf
char *

variable_types:
size
unsigned long


decompiled_code:
__int64 __fastcall fg_utimens(__int64 a1, __int64 a2)
{
debug_print("FG_UTIMENS");
return (unsigned int)((int)repo_update_time_ns(a1, a2) >> 31);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
debug_print("FG_UTIMENS");
return (unsigned int)((int)repo_update_time_ns(a1, a2) >> 31);
}

original_code:
static int fg_utimens(const char *path, const struct timespec ts[2])
{
 debug_print("FG_UTIMENS");
 int r;
 if ((r = repo_update_time_ns(path, ts)) < 0)
  return -1;
        return 0;
}

canonical_original_code:
static int fg_utimens(char *path, struct timespec ts[2])
{
 debug_print("FG_UTIMENS");
 int r;
 if ((r = repo_update_time_ns(path, ts)) < 0)
  return -1;
        return 0;
}

variable_types: struct timespec { long tv_sec; long tv_nsec; } [2]

variable_types: r int


decompiled_code:
__int64 __fastcall fg_create(__int64 a1, unsigned int a2, __int64 a3)
{
debug_print("FG_CREATE");
return (unsigned int)((int)repo_create_file(a1, a2, a3 + 24) >> 31);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned int a2, __int64 a3)
{
debug_print("FG_CREATE");
return (unsigned int)((int)repo_create_file(a1, a2, a3 + 24) >> 31);
}

original_code:
static int fg_create(const char *path, mode_t mode, struct fuse_file_info *fi)
{
 debug_print("FG_CREATE");
 int r;
 if ((r = repo_create_file(path, mode, &fi->fh)) < 0)
  return -1;
 return 0;
}

canonical_original_code:
static int fg_create(char *path, unsigned int mode, struct fuse_file_info *fi)
{
 debug_print("FG_CREATE");
 int r;
 if ((r = repo_create_file(path, mode, &fi->fh)) < 0)
  return -1;
 return 0;
}

variable_types: struct fuse_file_info { int flags; unsigned long fh_old; int writepage; unsigned int direct_io; unsigned int keep_cache; unsigned int flush; unsigned int nonseekable; unsigned int flock_release; unsigned int padding; unsigned long fh; unsigned long lock_owner; } *


decompiled_code:
__int64 __fastcall fg_readdir(__int64 a1, __int64 a2, void (__fastcall *a3)(__int64, const char *, _QWORD, _QWORD))
{
unsigned int v5; // ebx
__int64 v6; // rsi
unsigned int v7; // er13
__int64 v8; // rbx
__int64 v9; // rax
int v11; // [rsp+4h] [rbp-434h] BYREF
void *ptr; // [rsp+8h] [rbp-430h] BYREF
__int128 v13; // [rsp+10h] [rbp-428h] BYREF
char v14[1008]; // [rsp+20h] [rbp-418h] BYREF

v5 = 0;
debug_print("FG_READDIR");
v13 = 0LL;
memset(v14, 0, sizeof(v14));
while ( 1 )
{
v6 = v5++;
if ( !(unsigned int)get_next_component(a1, v6, &v13) )
break;
if ( !(unsigned int)repo_path_exists(&v13) )
return (unsigned int)-2;
}
v7 = repo_is_file(&v13);
if ( v7 || (int)repo_get_children(&ptr, &v11, a1) < 0 )
return (unsigned int)-2;
a3(a2, ".", 0LL, 0LL);
a3(a2, "..", 0LL, 0LL);
if ( v11 > 0 )
{
v8 = 0LL;
do
{
v9 = 3 * v8++;
a3(a2, *((const char **)ptr + v9), 0LL, 0LL);
}
while ( v11 > (int)v8 );
}
free(ptr);
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, void (__fastcall *a3)(__int64, const char *, _QWORD, _QWORD))
{
unsigned int v5; // ebx
__int64 v6; // rsi
unsigned int v7; // er13
__int64 v8; // rbx
__int64 v9; // rax
int v11; // [rsp+4h] [rbp-434h] BYREF
void *ptr; // [rsp+8h] [rbp-430h] BYREF
__int128 v13; // [rsp+10h] [rbp-428h] BYREF
char v14[1008]; // [rsp+20h] [rbp-418h] BYREF

v5 = 0;
debug_print("FG_READDIR");
v13 = 0LL;
memset(v14, 0, sizeof(v14));
while ( 1 )
{
v6 = v5++;
if ( !(unsigned int)get_next_component(a1, v6, &v13) )
break;
if ( !(unsigned int)repo_path_exists(&v13) )
return (unsigned int)-2;
}
v7 = repo_is_file(&v13);
if ( v7 || (int)repo_get_children(&ptr, &v11, a1) < 0 )
return (unsigned int)-2;
a3(a2, ".", 0LL, 0LL);
a3(a2, "..", 0LL, 0LL);
if ( v11 > 0 )
{
v8 = 0LL;
do
{
v9 = 3 * v8++;
a3(a2, *((const char **)ptr + v9), 0LL, 0LL);
}
while ( v11 > (int)v8 );
}
free(ptr);
return v7;
}

original_code:
static int fg_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
                         off_t offset, struct fuse_file_info *fi)
{
 debug_print("FG_READDIR");
 char name[1024] = "";
 int hier = 0;
 struct repo_file_node *children;
 int children_count;
 int i, r;
 while (get_next_component(path, hier++, name)) {
  if (!repo_path_exists(name))
   return -2;
 }
 if (repo_is_file(name))
  return -2;
 if ((r = repo_get_children(&children, &children_count, path)) < 0)
  return -2;
 filler(buf, ".", ((void *)0), 0);
 filler(buf, "..", ((void *)0), 0);
 for (i=0; i<children_count; i++) {
  filler(buf, children[i].name, ((void *)0), 0);
 }
 free(children);
        return 0;
}

canonical_original_code:
static int fg_readdir(char *path, void *buf, int (*filler)(void *buf, char *name, struct stat *stbuf, long off), long offset, struct fuse_file_info *fi)
{
 debug_print("FG_READDIR");
 char name[1024] = "";
 int hier = 0;
 struct repo_file_node *children;
 int children_count;
 int i; int r;
 while (get_next_component(path, hier++, name)) {
  if (!repo_path_exists(name))
   return -2;
 }
 if (repo_is_file(name))
  return -2;
 if ((r = repo_get_children(&children, &children_count, path)) < 0)
  return -2;
 filler(buf, ".", ((void *)0), 0);
 filler(buf, "..", ((void *)0), 0);
 for (i=0; i<children_count; i++) {
  filler(buf, children[i].name, ((void *)0), 0);
 }
 free(children);
        return 0;
}

variable_types:
buf
void *

variable_types: int (*)(void *buf, char *name, 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]; } *stbuf, long off)

variable_types: offset long

variable_types:
name
char [1024]

variable_types: hier int

variable_types: struct repo_file_node { char *name; char *path; 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]; } *stbuf; } *

variable_types: i int

user_defined_types: struct fuse_file_info { int flags; unsigned long fh_old; int writepage; unsigned int direct_io; unsigned int keep_cache; unsigned int flush; unsigned int nonseekable; unsigned int flock_release; unsigned int padding; unsigned long fh; unsigned long lock_owner; }

user_defined_types: struct repo_file_node { char *name; char *path; struct stat *stbuf; }

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 __fastcall fg_fsync(__int64 a1, unsigned int a2, __int64 a3)
{
debug_print("FG_FSYNC : metadata?%d", a2 == 0);
return ((int)repo_fsync(a1, *(_QWORD *)(a3 + 24), a2) >> 31) & 0xFFFFFFBD;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, unsigned int a2, __int64 a3)
{
debug_print("FG_FSYNC : metadata?%d", a2 == 0);
return ((int)repo_fsync(a1, *(_QWORD *)(a3 + 24), a2) >> 31) & 0xFFFFFFBD;
}

original_code:
static int fg_fsync(const char *path, int isdatasync,
                       struct fuse_file_info *fi)
{
 debug_print("FG_FSYNC : metadata?%d", isdatasync?0:1);
 int r;
 if ((r = repo_fsync(path, fi->fh, isdatasync)) < 0)
  return -67;
        return 0;
}

canonical_original_code:
static int fg_fsync(char *path, int isdatasync, struct fuse_file_info *fi)
{
 debug_print("FG_FSYNC : metadata?%d", isdatasync?0:1);
 int r;
 if ((r = repo_fsync(path, fi->fh, isdatasync)) < 0)
  return -67;
        return 0;
}

variable_types:
path
char *

variable_types: isdatasync int


decompiled_code:
__int64 __fastcall fg_release(__int64 a1, __int64 a2)
{
debug_print("FG_RELEASE");
return ((int)repo_release(a1, *(_QWORD *)(a2 + 24)) >> 31) & 0xFFFFFFBD;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2)
{
debug_print("FG_RELEASE");
return ((int)repo_release(a1, *(_QWORD *)(a2 + 24)) >> 31) & 0xFFFFFFBD;
}

original_code:
static int fg_release(const char *path, struct fuse_file_info *fi)
{
 debug_print("FG_RELEASE");
 int r;
 if ((r = repo_release(path, fi->fh)) < 0)
  return -67;
        return 0;
}

canonical_original_code:
static int fg_release(char *path, struct fuse_file_info *fi)
{
 debug_print("FG_RELEASE");
 int r;
 if ((r = repo_release(path, fi->fh)) < 0)
  return -67;
        return 0;
}


decompiled_code:
__int64 __fastcall fg_flush(__int64 a1, __int64 a2)
{
debug_print("FG_FLUSH");
return ((int)repo_flush(a1, *(_QWORD *)(a2 + 24)) >> 31) & 0xFFFFFFBD;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2)
{
debug_print("FG_FLUSH");
return ((int)repo_flush(a1, *(_QWORD *)(a2 + 24)) >> 31) & 0xFFFFFFBD;
}

original_code:
static int fg_flush(const char *path, struct fuse_file_info *fi)
{
 debug_print("FG_FLUSH");
 int r;
 if ((r = repo_flush(path, fi->fh)) < 0)
  return -67;
 return 0;
}

canonical_original_code:
static int fg_flush(char *path, struct fuse_file_info *fi)
{
 debug_print("FG_FLUSH");
 int r;
 if ((r = repo_flush(path, fi->fh)) < 0)
  return -67;
 return 0;
}


decompiled_code:
__int64 __fastcall fg_write(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
debug_print("FG_WRITE");
return repo_write(a1, a2, a3, a4, *(_QWORD *)(a5 + 24));
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
debug_print("FG_WRITE");
return repo_write(a1, a2, a3, a4, *(_QWORD *)(a5 + 24));
}

original_code:
static int fg_write(const char *path, const char *buf, size_t size,
                       off_t offset, struct fuse_file_info *fi)
{
 debug_print("FG_WRITE");
        return repo_write(path, buf, size, offset, fi->fh);
}

canonical_original_code:
static int fg_write(char *path, char *buf, unsigned long size, long offset, struct fuse_file_info *fi)
{
 debug_print("FG_WRITE");
        return repo_write(path, buf, size, offset, fi->fh);
}


decompiled_code:
__int64 __fastcall fg_read(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
debug_print("FG_READ");
return repo_read(a1, a2, a3, a4, *(_QWORD *)(a5 + 24));
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
debug_print("FG_READ");
return repo_read(a1, a2, a3, a4, *(_QWORD *)(a5 + 24));
}

original_code:
static int fg_read(const char *path, char *buf, size_t size, off_t offset,
                      struct fuse_file_info *fi)
{
 debug_print("FG_READ");
 return repo_read(path, buf, size, offset, fi->fh);
}

canonical_original_code:
static int fg_read(char *path, char *buf, unsigned long size, long offset, struct fuse_file_info *fi)
{
 debug_print("FG_READ");
 return repo_read(path, buf, size, offset, fi->fh);
}


decompiled_code:
__int64 __fastcall fg_open(__int64 a1, __int64 a2)
{
debug_print("FG_OPEN");
return ((int)repo_open(a1, a2 + 24) >> 31) & 0xFFFFFFBD;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
debug_print("FG_OPEN");
return ((int)repo_open(a1, a2 + 24) >> 31) & 0xFFFFFFBD;
}

original_code:
static int fg_open(const char *path, struct fuse_file_info *fi)
{
 debug_print("FG_OPEN");
 int r;
 if ((r = repo_open(path, &fi->fh)) < 0)
  return -67;
 return 0;
}

canonical_original_code:
static int fg_open(char *path, struct fuse_file_info *fi)
{
 debug_print("FG_OPEN");
 int r;
 if ((r = repo_open(path, &fi->fh)) < 0)
  return -67;
 return 0;
}


decompiled_code:
__int64 __fastcall fg_truncate(__int64 a1, __int64 a2)
{
debug_print("FG_TRUNCATE");
return ((int)repo_truncate(a1, a2) >> 31) & 0xFFFFFFFE;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2)
{
debug_print("FG_TRUNCATE");
return ((int)repo_truncate(a1, a2) >> 31) & 0xFFFFFFFE;
}

original_code:
static int fg_truncate(const char *path, off_t size)
{
 debug_print("FG_TRUNCATE");
 int r;
 if ((r = repo_truncate(path, size)) < 0)
  return -2;
        return 0;
}

canonical_original_code:
static int fg_truncate(char *path, long size)
{
 debug_print("FG_TRUNCATE");
 int r;
 if ((r = repo_truncate(path, size)) < 0)
  return -2;
        return 0;
}

variable_types: size long


decompiled_code:
__int64 __fastcall fg_chown(__int64 a1, unsigned int a2, unsigned int a3)
{
debug_print("FG_CHOWN");
return ((int)repo_chown(a1, a2, a3) >> 31) & 0xFFFFFFBD;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, unsigned int a2, unsigned int a3)
{
debug_print("FG_CHOWN");
return ((int)repo_chown(a1, a2, a3) >> 31) & 0xFFFFFFBD;
}

original_code:
static int fg_chown(const char *path, uid_t uid, gid_t gid)
{
 debug_print("FG_CHOWN");
 int r;
 if ((r = repo_chown(path, uid, gid)) < 0)
  return -67;
        return 0;
}

canonical_original_code:
static int fg_chown(char *path, unsigned int uid, unsigned int gid)
{
 debug_print("FG_CHOWN");
 int r;
 if ((r = repo_chown(path, uid, gid)) < 0)
  return -67;
        return 0;
}

variable_types:
uid
unsigned int

variable_types:
gid
unsigned int


decompiled_code:
__int64 __fastcall fg_chmod(__int64 a1, unsigned int a2)
{
debug_print("FG_CHMOD");
return ((int)repo_chmod(a1, a2) >> 31) & 0xFFFFFFBD;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, unsigned int a2)
{
debug_print("FG_CHMOD");
return ((int)repo_chmod(a1, a2) >> 31) & 0xFFFFFFBD;
}

original_code:
static int fg_chmod(const char *path, mode_t mode)
{
 debug_print("FG_CHMOD");
 int r;
 if ((r = repo_chmod(path, mode)) < 0)
  return -67;
        return 0;
}

canonical_original_code:
static int fg_chmod(char *path, unsigned int mode)
{
 debug_print("FG_CHMOD");
 int r;
 if ((r = repo_chmod(path, mode)) < 0)
  return -67;
        return 0;
}

variable_types:
mode
unsigned int


decompiled_code:
__int64 __fastcall fg_link(__int64 a1, __int64 a2)
{
int v2; // eax
unsigned int v3; // er8

debug_print("FG_LINK");
v2 = repo_link(a1, a2);
v3 = 0;
if ( v2 < 0 )
{
v3 = -67;
if ( v2 == -1 )
v3 = -2;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2)
{
int v2; // eax
unsigned int v3; // er8

debug_print("FG_LINK");
v2 = repo_link(a1, a2);
v3 = 0;
if ( v2 < 0 )
{
v3 = -67;
if ( v2 == -1 )
v3 = -2;
}
return v3;
}

original_code:
static int fg_link(const char *from, const char *to)
{
 debug_print("FG_LINK");
 int r;
 if ((r = repo_link(from, to)) < 0) {
  switch(r) {
  case -1:
   return -2;
  case -3:
   return -67;
  }
  return -67;
 }
 return 0;
}

canonical_original_code:
static int fg_link(char *from, char *to)
{
 debug_print("FG_LINK");
 int r;
 if ((r = repo_link(from, to)) < 0) {
  switch(r) {
  case -1:
   return -2;
  case -3:
   return -67;
  }
  return -67;
 }
 return 0;
}

variable_types:
from
char *

variable_types:
to
char *


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

debug_print("FG_RENAME");
if ( (unsigned int)repo_is_dir(a1) )
result = (unsigned int)((int)repo_rename_dir(a1) >> 31);
else
result = (unsigned int)((int)repo_rename_file(a1) >> 31);
return result;
}

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

debug_print("FG_RENAME");
if ( (unsigned int)repo_is_dir(a1) )
result = (unsigned int)((int)repo_rename_dir(a1) >> 31);
else
result = (unsigned int)((int)repo_rename_file(a1) >> 31);
return result;
}

original_code:
static int fg_rename(const char *from, const char *to)
{
 debug_print("FG_RENAME");
 int r;
 if (repo_is_dir(from)) {
  if ((r = repo_rename_dir(from, to)) < 0)
   return -1;
 } else {
  if ((r = repo_rename_file(from, to)) < 0)
   return -1;
 }
        return 0;
}

canonical_original_code:
static int fg_rename(char *from, char *to)
{
 debug_print("FG_RENAME");
 int r;
 if (repo_is_dir(from)) {
  if ((r = repo_rename_dir(from, to)) < 0)
   return -1;
 } else {
  if ((r = repo_rename_file(from, to)) < 0)
   return -1;
 }
        return 0;
}

variable_types: r int


decompiled_code:
__int64 __fastcall fg_rmdir(__int64 a1)
{
int v1; // eax
unsigned int v2; // er8

debug_print("FG_RMDIR");
v1 = repo_rmdir(a1);
v2 = 0;
if ( v1 < 0 )
{
v2 = -2;
if ( v1 == -2 )
v2 = -39;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1)
{
int v1; // eax
unsigned int v2; // er8

debug_print("FG_RMDIR");
v1 = repo_rmdir(a1);
v2 = 0;
if ( v1 < 0 )
{
v2 = -2;
if ( v1 == -2 )
v2 = -39;
}
return v2;
}

original_code:
static int fg_rmdir(const char *path)
{
 debug_print("FG_RMDIR");
 int r;
 if ((r = repo_rmdir(path)) < 0) {
  switch(r) {
  case -1:
   return -2;
  case -2:
   return -39;
  }
  return -2;
 }
        return 0;
}

canonical_original_code:
static int fg_rmdir(char *path)
{
 debug_print("FG_RMDIR");
 int r;
 if ((r = repo_rmdir(path)) < 0) {
  switch(r) {
  case -1:
   return -2;
  case -2:
   return -39;
  }
  return -2;
 }
        return 0;
}


decompiled_code:
__int64 __fastcall fg_unlink(__int64 a1)
{
debug_print("FG_UNLINK");
return ((int)repo_unlink(a1) >> 31) & 0xFFFFFFBD;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1)
{
debug_print("FG_UNLINK");
return ((int)repo_unlink(a1) >> 31) & 0xFFFFFFBD;
}

original_code:
static int fg_unlink(const char *path)
{
 debug_print("FG_UNLINK");
 int r;
 if ((r = repo_unlink(path)) < 0)
  return -67;
        return 0;
}

canonical_original_code:
static int fg_unlink(char *path)
{
 debug_print("FG_UNLINK");
 int r;
 if ((r = repo_unlink(path)) < 0)
  return -67;
        return 0;
}


decompiled_code:
__int64 __fastcall fg_mkdir(__int64 a1, unsigned int a2)
{
unsigned int v2; // ebx

v2 = a2;
BYTE1(v2) = BYTE1(a2) | 0x40;
debug_print("FG_MKDIR");
return ((int)repo_mkdir(a1, v2) >> 31) & 0xFFFFFFFE;
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1, unsigned int a2)
{
unsigned int v2; // ebx

v2 = a2;
BYTE1(v2) = BYTE1(a2) | 0x40;
debug_print("FG_MKDIR");
return ((int)repo_mkdir(a1, v2) >> 31) & 0xFFFFFFFE;
}

original_code:
static int fg_mkdir(const char *path, mode_t mode)
{
 debug_print("FG_MKDIR");
 int r;
 if ((r = repo_mkdir(path, mode|0040000)) < 0)
  return -2;
        return 0;
}

canonical_original_code:
static int fg_mkdir(char *path, unsigned int mode)
{
 debug_print("FG_MKDIR");
 int r;
 if ((r = repo_mkdir(path, mode|0040000)) < 0)
  return -2;
        return 0;
}


decompiled_code:
__int64 __fastcall fg_getattr(const char *a1, __int64 a2)
{
const char *v2; // rbp
unsigned int v3; // er12

v2 = a1;
debug_print("FG_GETATTR");
debug_print("checking if path exists: %s", a1);
if ( !(unsigned int)repo_path_exists(a1) )
return (unsigned int)-2;
debug_print("getting attribute of %s", a1);
v3 = repo_is_dir(a1);
if ( !v3 )
{
if ( *a1 == 47 && !a1[1] )
a1 = "/";
if ( (int)repo_stat(a1, a2) >= 0 )
{
print_file_stats(v2, a2);
return v3;
}
return (unsigned int)-2;
}
if ( (int)repo_dir_stat(a1, a2) < 0 )
return (unsigned int)-2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func22(const char *a1, __int64 a2)
{
const char *v2; // rbp
unsigned int v3; // er12

v2 = a1;
debug_print("FG_GETATTR");
debug_print("checking if path exists: %s", a1);
if ( !(unsigned int)repo_path_exists(a1) )
return (unsigned int)-2;
debug_print("getting attribute of %s", a1);
v3 = repo_is_dir(a1);
if ( !v3 )
{
if ( *a1 == 47 && !a1[1] )
a1 = "/";
if ( (int)repo_stat(a1, a2) >= 0 )
{
print_file_stats(v2, a2);
return v3;
}
return (unsigned int)-2;
}
if ( (int)repo_dir_stat(a1, a2) < 0 )
return (unsigned int)-2;
return 0LL;
}

original_code:
static int fg_getattr(const char *path, struct stat *stbuf)
{
 debug_print("FG_GETATTR");
 int r;
 debug_print("checking if path exists: %s", path);
 if (!repo_path_exists(path))
  return -2;
 debug_print("getting attribute of %s", path);
 if ((r = repo_is_dir(path))) {
  if ((r = repo_dir_stat(path, stbuf)) < 0)
   return -2;
  return 0;
 }
 if ((r = repo_stat(strcmp("/", path) ? path : "/", stbuf)) < 0)
  return -2;
 print_file_stats(path, stbuf);
        return 0;
}

canonical_original_code:
static int fg_getattr(char *path, struct stat *stbuf)
{
 debug_print("FG_GETATTR");
 int r;
 debug_print("checking if path exists: %s", path);
 if (!repo_path_exists(path))
  return -2;
 debug_print("getting attribute of %s", path);
 if ((r = repo_is_dir(path))) {
  if ((r = repo_dir_stat(path, stbuf)) < 0)
   return -2;
  return 0;
 }
 if ((r = repo_stat(strcmp("/", path) ? path : "/", stbuf)) < 0)
  return -2;
 print_file_stats(path, stbuf);
        return 0;
}

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


decompiled_code:
__int64 __fastcall fg_fuse_main(int a1, __int64 a2)
{
__int64 v3; // rbx
const char *v4; // rdx
__int64 v5; // rsi

if ( a1 > 0 )
{
v3 = 0LL;
do
{
v4 = *(const char **)(a2 + 8 * v3);
v5 = (unsigned int)v3++;
debug_print("arg %d: %s", v5, v4);
}
while ( v3 != a1 );
}
return fuse_main_real((unsigned int)a1, a2, &fg_oper, 360LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func23(int a1, __int64 a2)
{
__int64 v3; // rbx
const char *v4; // rdx
__int64 v5; // rsi

if ( a1 > 0 )
{
v3 = 0LL;
do
{
v4 = *(const char **)(a2 + 8 * v3);
v5 = (unsigned int)v3++;
debug_print("arg %d: %s", v5, v4);
}
while ( v3 != a1 );
}
return fuse_main_real((unsigned int)a1, a2, &fg_oper, 360LL, 0LL);
}

original_code:
int
fg_fuse_main(int argc, char *argv[])
{
 int i;
 for (i=0; i<argc; i++) {
  debug_print("arg %d: %s", i, argv[i]);
 }
        return fuse_main_real(argc, argv, &fg_oper, sizeof(*(&fg_oper)), ((void *)0));
}

variable_types: argc int

variable_types:
argv
char *[]


decompiled_code:
int debug_print(char *format, ...)
{
size_t v1; // rax
FILE *v2; // rsi
gcc_va_list arg; // [rsp+8h] [rbp-10E0h] BYREF
char s[4112]; // [rsp+20h] [rbp-10C8h] BYREF

va_start(arg, format);
vsnprintf(s, 0x1000uLL, format, arg);
s[strlen(s) + 1] = 0;
v1 = strlen(s);
v2 = stdout;
s[v1] = 10;
return fputs(s, v2);
}

canonical_decompiled_code:
int func0(char *format, ...)
{
size_t v1; // rax
FILE *v2; // rsi
gcc_va_list arg; // [rsp+8h] [rbp-10E0h] BYREF
char s[4112]; // [rsp+20h] [rbp-10C8h] BYREF

va_start(arg, format);
vsnprintf(s, 0x1000uLL, format, arg);
s[strlen(s) + 1] = 0;
v1 = strlen(s);
v2 = stdout;
s[v1] = 10;
return fputs(s, v2);
}

original_code:
void debug_print(char *msg, ...)
{
 char buf[4096 +2];
 va_list argp;
        __builtin_va_start(argp,msg);
 vsnprintf(buf, 4096, msg, argp);
 __builtin_va_end(argp);
 buf[strlen(buf)+1] = '\0';
 buf[strlen(buf)] = '\n';
 fprintf(stdout, "%s", buf);
}

canonical_original_code:
void debug_print(char *msg, ...)
{
 char buf[-1];
 __builtin_va_list argp;
        __builtin_va_start(argp,msg);
 vsnprintf(buf, 4096, msg, argp);
 __builtin_va_end(argp);
 buf[strlen(buf)+1] = '\0';
 buf[strlen(buf)] = '\n';
 fprintf(stdout, "%s", buf);
}

variable_types:
msg
char *

variable_types:
buf
char [-1]

return_type: void


decompiled_code:
_BOOL8 __fastcall is_substr(const char *a1, const char *a2)
{
return strstr(a1, a2) != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(const char *a1, const char *a2)
{
return strstr(a1, a2) != 0LL;
}

original_code:
int is_substr(const char *str, const char *sub)
{
 return strstr(str, sub) ? 1 : 0;
}

canonical_original_code:
int is_substr(char *str, char *sub)
{
 return strstr(str, sub) ? 1 : 0;
}

variable_types:
str
char *

variable_types:
sub
char *


decompiled_code:
__int64 __fastcall get_parent_path(char *src, char *s)
{
char *v2; // rbx
int v3; // eax
int v4; // er12
int v5; // er8
__int64 result; // rax

if ( src )
strcpy(s, src);
v2 = rindex(s, 47);
v3 = strlen(s);
v2[1] = 0;
v4 = v3;
v5 = strlen(s);
result = 0LL;
if ( v4 == v5 )
{
if ( *s != 47 || s[1] )
{
*v2 = 0;
rindex(s, 47)[1] = 0;
result = 0LL;
}
else
{
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *src, char *s)
{
char *v2; // rbx
int v3; // eax
int v4; // er12
int v5; // er8
__int64 result; // rax

if ( src )
strcpy(s, src);
v2 = rindex(s, 47);
v3 = strlen(s);
v2[1] = 0;
v4 = v3;
v5 = strlen(s);
result = 0LL;
if ( v4 == v5 )
{
if ( *s != 47 || s[1] )
{
*v2 = 0;
rindex(s, 47)[1] = 0;
result = 0LL;
}
else
{
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int get_parent_path(const char *path, char *parent)
{
 char *tmp;
 int old_len;
 int new_len;
 if (path)
  strcpy(parent, path);
 tmp = rindex(parent, '/');
 old_len = strlen(parent);
 *(tmp+1) = '\0';
 new_len = strlen(parent);
 if ((old_len == new_len) && (strcmp(parent, "/") == 0))
  return -1;
 if (old_len == new_len) {
  *tmp = '\0';
  tmp = rindex(parent, '/');
  *(tmp+1) = '\0';
 }
 return 0;
}

canonical_original_code:
int get_parent_path(char *path, char *parent)
{
 char *tmp;
 int old_len;
 int new_len;
 if (path)
  strcpy(parent, path);
 tmp = rindex(parent, '/');
 old_len = strlen(parent);
 *(tmp+1) = '\0';
 new_len = strlen(parent);
 if ((old_len == new_len) && (strcmp(parent, "/") == 0))
  return -1;
 if (old_len == new_len) {
  *tmp = '\0';
  tmp = rindex(parent, '/');
  *(tmp+1) = '\0';
 }
 return 0;
}

variable_types:
parent
char *

variable_types:
tmp
char *


decompiled_code:
__int64 __fastcall get_last_component(char *src, char *s)
{
char *v2; // rax
char *v3; // rbx

if ( *src != 47 )
return 0xFFFFFFFFLL;
strcpy(s, src);
while ( 1 )
{
v2 = rindex(s, 47);
v3 = v2;
if ( !v2 )
break;
if ( strlen(v2) != 1 )
{
strcpy(s, v3 + 1);
return 0LL;
}
*v3 = 0;
}
*s = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *src, char *s)
{
char *v2; // rax
char *v3; // rbx

if ( *src != 47 )
return 0xFFFFFFFFLL;
strcpy(s, src);
while ( 1 )
{
v2 = rindex(s, 47);
v3 = v2;
if ( !v2 )
break;
if ( strlen(v2) != 1 )
{
strcpy(s, v3 + 1);
return 0LL;
}
*v3 = 0;
}
*s = 0;
return 0LL;
}

original_code:
int get_last_component(const char *path, char *name)
{
 if (*path != '/')
  return -1;
 char *dummy = ((void *)0);
 strcpy(name, path);
 do {
  if (dummy)
   dummy[0] = '\0';
  dummy = rindex(name, '/');
 } while (dummy && strlen(dummy) == 1);
 if (dummy)
  strcpy(name, dummy+1);
 else
  *name = '\0';
 return 0;
}

canonical_original_code:
int get_last_component(char *path, char *name)
{
 if (*path != '/')
  return -1;
 char *dummy = ((void *)0);
 strcpy(name, path);
 do {
  if (dummy)
   dummy[0] = '\0';
  dummy = rindex(name, '/');
 } while (dummy && strlen(dummy) == 1);
 if (dummy)
  strcpy(name, dummy+1);
 else
  *name = '\0';
 return 0;
}

variable_types:
path
char *

variable_types:
name
char *

variable_types:
dummy
char *


decompiled_code:
_BOOL8 __fastcall get_next_component(char *src, int a2, char *a3)
{
int v3; // er14
int v5; // er12
char *v6; // r13
char *v7; // rax

v3 = 0;
v5 = strlen(a3);
v6 = stpcpy(a3, src);
v7 = index(a3, 47);
while ( v3 < a2 )
{
++v3;
v7 = index(v7 + 1, 47);
if ( !v7 )
return v6 - a3 != v5;
}
if ( *v7 == 47 )
v7[1] = 0;
return 1LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(char *src, int a2, char *a3)
{
int v3; // er14
int v5; // er12
char *v6; // r13
char *v7; // rax

v3 = 0;
v5 = strlen(a3);
v6 = stpcpy(a3, src);
v7 = index(a3, 47);
while ( v3 < a2 )
{
++v3;
v7 = index(v7 + 1, 47);
if ( !v7 )
return v6 - a3 != v5;
}
if ( *v7 == 47 )
v7[1] = 0;
return 1LL;
}

original_code:
int get_next_component(const char *path, int hier, char *name)
{
 char *ind;
 int len = strlen(name);
 int count = 0;
 strcpy(name, path);
 ind = index(name, '/');
 while (count < hier) {
  count++;
  ind++;
  ind = index(ind, '/');
  if (ind == ((void *)0)) {
   if (len == strlen(name))
    return 0;
   else
    return 1;
  }
 }
 if (*ind == '/')
  *(ind+1) = '\0';
 return 1;
}

canonical_original_code:
int get_next_component(char *path, int hier, char *name)
{
 char *ind;
 int len = strlen(name);
 int count = 0;
 strcpy(name, path);
 ind = index(name, '/');
 while (count < hier) {
  count++;
  ind++;
  ind = index(ind, '/');
  if (ind == ((void *)0)) {
   if (len == strlen(name))
    return 0;
   else
    return 1;
  }
 }
 if (*ind == '/')
  *(ind+1) = '\0';
 return 1;
}

variable_types: hier int

variable_types:
ind
char *

variable_types: len int

variable_types: count int


decompiled_code:
int __fastcall print_file_stats(const char *a1, unsigned int *a2)
{
debug_print("***PRINT STAT : %s", a1);
debug_print("\tdev=%x", *a2);
debug_print("\tino=%x", a2[2]);
debug_print("\tmode=%x", a2[6]);
debug_print("\tnlink=%x", a2[4]);
debug_print("\tuid=%x", a2[7]);
debug_print("\tgid=%x", a2[8]);
debug_print("\tsize=%x", a2[12]);
debug_print("\tmtime=%x", a2[22]);
debug_print("\tctime=%x", *((_QWORD *)a2 + 13));
return debug_print("***PRINT STAT OVER\n");
}

canonical_decompiled_code:
int __fastcall func5(const char *a1, unsigned int *a2)
{
func0("***PRINT STAT : %s", a1);
func0("\tdev=%x", *a2);
func0("\tino=%x", a2[2]);
func0("\tmode=%x", a2[6]);
func0("\tnlink=%x", a2[4]);
func0("\tuid=%x", a2[7]);
func0("\tgid=%x", a2[8]);
func0("\tsize=%x", a2[12]);
func0("\tmtime=%x", a2[22]);
func0("\tctime=%x", *((_QWORD *)a2 + 13));
return func0("***PRINT STAT OVER\n");
}

original_code:
void print_file_stats(const char *path, struct stat *stbuf)
{
 debug_print("***PRINT STAT : %s", path);
 debug_print("\tdev=%x", (unsigned int)stbuf->st_dev);
 debug_print("\tino=%x", (unsigned int)stbuf->st_ino);
 debug_print("\tmode=%x", (unsigned int)stbuf->st_mode);
 debug_print("\tnlink=%x", (unsigned int)stbuf->st_nlink);
 debug_print("\tuid=%x", (unsigned int)stbuf->st_uid);
 debug_print("\tgid=%x", (unsigned int)stbuf->st_gid);
 debug_print("\tsize=%x", (unsigned int)stbuf->st_size);
 debug_print("\tmtime=%x", (unsigned int)stbuf->st_mtim.tv_sec);
 debug_print("\tctime=%x", (unsigned int)stbuf->st_ctim.tv_sec);
 debug_print("***PRINT STAT OVER\n");
}

canonical_original_code:
void print_file_stats(char *path, struct stat *stbuf)
{
 debug_print("***PRINT STAT : %s", path);
 debug_print("\tdev=%x", (unsigned int)stbuf->st_dev);
 debug_print("\tino=%x", (unsigned int)stbuf->st_ino);
 debug_print("\tmode=%x", (unsigned int)stbuf->st_mode);
 debug_print("\tnlink=%x", (unsigned int)stbuf->st_nlink);
 debug_print("\tuid=%x", (unsigned int)stbuf->st_uid);
 debug_print("\tgid=%x", (unsigned int)stbuf->st_gid);
 debug_print("\tsize=%x", (unsigned int)stbuf->st_size);
 debug_print("\tmtime=%x", (unsigned int)stbuf->st_mtim.tv_sec);
 debug_print("\tctime=%x", (unsigned int)stbuf->st_ctim.tv_sec);
 debug_print("***PRINT STAT OVER\n");
}

user_defined_types: struct timespec { long tv_sec; long tv_nsec; }


repo: shanepelletier/ZolkVM

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // [rsp+10h] [rbp-8h]

printf((const char *)v4, argv, envp);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
  int testprogram[1] = {0x20210005};
  printf(testprogram[1]);
 return 0;
}

variable_types:
testprogram
int [1]


repo: shanet/Irrational

decompiled_code:
void __fastcall calc_term(void *a1)
{
char v1[24]; // [rsp+0h] [rbp-68h] BYREF

switch ( *(_DWORD *)a1 )
{
case 1:
strcpy(v1, "239");
goto LABEL_3;
case 2:
strcpy(v1, "1023");
goto LABEL_3;
case 3:
strcpy(v1, "5832");
goto LABEL_9;
case 4:
strcpy(v1, "113021");
goto LABEL_3;
case 5:
strcpy(v1, "6826318");
goto LABEL_9;
case 6:
strcpy(v1, "33366019650");
LABEL_9:
mpfr_set_default_prec();
mpfr_init_set_str();
mpfr_atan2();
mpfr_mul_ui();
pthread_mutex_lock(&sum_mutex);
mpfr_sub();
goto LABEL_4;
case 7:
strcpy(v1, "43599522992503626068");
LABEL_3:
mpfr_set_default_prec();
mpfr_init_set_str();
mpfr_atan2();
mpfr_mul_ui();
pthread_mutex_lock(&sum_mutex);
mpfr_add();
LABEL_4:
pthread_mutex_unlock(&sum_mutex);
mpfr_clears();
mpfr_free_cache();
break;
default:
break;
}
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall func7(void *a1)
{
char v1[24]; // [rsp+0h] [rbp-68h] BYREF

switch ( *(_DWORD *)a1 )
{
case 1:
strcpy(v1, "239");
goto LABEL_3;
case 2:
strcpy(v1, "1023");
goto LABEL_3;
case 3:
strcpy(v1, "5832");
goto LABEL_9;
case 4:
strcpy(v1, "113021");
goto LABEL_3;
case 5:
strcpy(v1, "6826318");
goto LABEL_9;
case 6:
strcpy(v1, "33366019650");
LABEL_9:
mpfr_set_default_prec();
mpfr_init_set_str();
mpfr_atan2();
mpfr_mul_ui();
pthread_mutex_lock(&sum_mutex);
mpfr_sub();
goto LABEL_4;
case 7:
strcpy(v1, "43599522992503626068");
LABEL_3:
mpfr_set_default_prec();
mpfr_init_set_str();
mpfr_atan2();
mpfr_mul_ui();
pthread_mutex_lock(&sum_mutex);
mpfr_add();
LABEL_4:
pthread_mutex_unlock(&sum_mutex);
mpfr_clears();
mpfr_free_cache();
break;
default:
break;
}
pthread_exit(0LL);
}

original_code:
void* calc_term(void* term_num) {
    char x_str[22];
    int op;
    int coeff;
    mpfr_t *term;
    switch(*(int *)term_num) {
        case 1:
            term = &t1;
            coeff = 183;
            op = 0;
            sprintf(x_str, "239");
            break;
        case 2:
            term = &t2;
            coeff = 32;
            op = 0;
            sprintf(x_str, "1023");
            break;
        case 3:
            term = &t3;
            coeff = 68;
            op = 1;
            sprintf(x_str, "5832");
            break;
        case 4:
            term = &t4;
            coeff = 12;
            op = 0;
            sprintf(x_str, "113021");
            break;
        case 5:
            term = &t5;
            coeff = 100;
            op = 1;
            sprintf(x_str, "6826318");
            break;
        case 6:
            term = &t6;
            coeff = 12;
            op = 1;
            sprintf(x_str, "33366019650");
            break;
        case 7:
            term = &t7;
            coeff = 12;
            op = 0;
            sprintf(x_str, "43599522992503626068");
            break;
        default:
            pthread_exit(((void *)0));
    }
    mpfr_t x;
    mpfr_set_default_prec(precision);
    mpfr_init_set_str(x, x_str, 10, MPFR_RNDN);
    mpfr_atan2(*term, one, x, MPFR_RNDN);
    (__builtin_constant_p (coeff) && (mpfr_ulong) (coeff) >= 1 && ((mpfr_ulong) (coeff) & ((mpfr_ulong) (coeff) - 1)) == 0 ? mpfr_mul_2si((*term), (*term), __builtin_ctzl (coeff), (MPFR_RNDN)) : mpfr_mul_ui ((*term), (*term), (coeff), (MPFR_RNDN)));
    pthread_mutex_lock(&sum_mutex);
    if(op == 0) {
        mpfr_add(pi, pi, *term, MPFR_RNDN);
    } else {
        mpfr_sub(pi, pi, *term, MPFR_RNDN);
    }
    pthread_mutex_unlock(&sum_mutex);
    mpfr_clears(*term, x, ((void *)0));
    mpfr_free_cache();
    pthread_exit(((void *)0));
}

canonical_original_code:
void *calc_term(void *term_num) {
    char x_str[22];
    int op;
    int coeff;
    struct __mpfr_struct (*term)[1];
    switch(*(int *)term_num) {
        case 1:
            term = &t1;
            coeff = 183;
            op = 0;
            sprintf(x_str, "239");
            break;
        case 2:
            term = &t2;
            coeff = 32;
            op = 0;
            sprintf(x_str, "1023");
            break;
        case 3:
            term = &t3;
            coeff = 68;
            op = 1;
            sprintf(x_str, "5832");
            break;
        case 4:
            term = &t4;
            coeff = 12;
            op = 0;
            sprintf(x_str, "113021");
            break;
        case 5:
            term = &t5;
            coeff = 100;
            op = 1;
            sprintf(x_str, "6826318");
            break;
        case 6:
            term = &t6;
            coeff = 12;
            op = 1;
            sprintf(x_str, "33366019650");
            break;
        case 7:
            term = &t7;
            coeff = 12;
            op = 0;
            sprintf(x_str, "43599522992503626068");
            break;
        default:
            pthread_exit(((void *)0));
    }
    struct __mpfr_struct x[1];
    mpfr_set_default_prec(precision);
    mpfr_init_set_str(x, x_str, 10, MPFR_RNDN);
    mpfr_atan2(*term, one, x, MPFR_RNDN);
    (__builtin_constant_p (coeff) && (mpfr_ulong) (coeff) >= 1 && ((mpfr_ulong) (coeff) & ((mpfr_ulong) (coeff) - 1)) == 0 ? mpfr_mul_2si((*term), (*term), __builtin_ctzl (coeff), (MPFR_RNDN)) : mpfr_mul_ui ((*term), (*term), (coeff), (MPFR_RNDN)));
    pthread_mutex_lock(&sum_mutex);
    if(op == 0) {
        mpfr_add(pi, pi, *term, MPFR_RNDN);
    } else {
        mpfr_sub(pi, pi, *term, MPFR_RNDN);
    }
    pthread_mutex_unlock(&sum_mutex);
    mpfr_clears(*term, x, ((void *)0));
    mpfr_free_cache();
    pthread_exit(((void *)0));
}

variable_types: op int

variable_types: coeff int

variable_types: struct __mpfr_struct { long _mpfr_prec; int _mpfr_sign; long _mpfr_exp; unsigned long *_mpfr_d; } (*)[1]

variable_types: struct __mpfr_struct { long _mpfr_prec; int _mpfr_sign; long _mpfr_exp; unsigned long *_mpfr_d; } [1]

return_type: void *


biscSendLedCommand

repo: shanet/libbiscuit

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

if ( (unsigned int)biscSendByte(139LL) == -1
|| (unsigned int)biscSendByte(ledState[0]) == -1
|| (unsigned int)biscSendByte(ledState[1]) == -1 )
{
result = 0xFFFFFFFFLL;
}
else
{
result = (unsigned int)-((unsigned int)biscSendByte(ledState[2]) == -1);
}
return result;
}

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

if ( (unsigned int)biscSendByte(139LL) == -1
|| (unsigned int)biscSendByte(ledState[0]) == -1
|| (unsigned int)biscSendByte(ledState[1]) == -1 )
{
result = 0xFFFFFFFFLL;
}
else
{
result = (unsigned int)-((unsigned int)biscSendByte(ledState[2]) == -1);
}
return result;
}

original_code:
int biscSendLedCommand(void) {
    if(biscSendByte(139) == -1) return -1;
    if(biscSendByte(ledState.playAdvanceState) == -1) return -1;
    if(biscSendByte(ledState.powerLedColor) == -1) return -1;
    if(biscSendByte(ledState.powerLedIntensity) == -1) return -1;
    return 0;
}

canonical_original_code:
int biscSendLedCommand() {
    if(biscSendByte(139) == -1) return -1;
    if(biscSendByte(ledState.playAdvanceState) == -1) return -1;
    if(biscSendByte(ledState.powerLedColor) == -1) return -1;
    if(biscSendByte(ledState.powerLedIntensity) == -1) return -1;
    return 0;
}


biscTurnOnAdvanceLed

decompiled_code:
__int64 biscTurnOnAdvanceLed()
{
ledState[0] |= 8u;
return biscSendLedCommand();
}

canonical_decompiled_code:
__int64 func1()
{
ledState[0] |= 8u;
return func0();
}

original_code:
int biscTurnOnAdvanceLed(void) {
    ledState.playAdvanceState |= 8;
    return biscSendLedCommand();
}

canonical_original_code:
int biscTurnOnAdvanceLed() {
    ledState.playAdvanceState |= 8;
    return biscSendLedCommand();
}


biscTurnOffAdvanceLed

decompiled_code:
__int64 biscTurnOffAdvanceLed()
{
ledState[0] ^= 8u;
return biscSendLedCommand();
}

canonical_decompiled_code:
__int64 func2()
{
ledState[0] ^= 8u;
return func0();
}

original_code:
int biscTurnOffAdvanceLed(void) {
    ledState.playAdvanceState ^= 1 << 3;
    return biscSendLedCommand();
}

canonical_original_code:
int biscTurnOffAdvanceLed() {
    ledState.playAdvanceState ^= 1 << 3;
    return biscSendLedCommand();
}


biscTurnOnPlayLed

decompiled_code:
__int64 biscTurnOnPlayLed()
{
ledState[0] |= 2u;
return biscSendLedCommand();
}

canonical_decompiled_code:
__int64 func3()
{
ledState[0] |= 2u;
return func0();
}

original_code:
int biscTurnOnPlayLed(void) {
    ledState.playAdvanceState |= 2;
    return biscSendLedCommand();
}

canonical_original_code:
int biscTurnOnPlayLed() {
    ledState.playAdvanceState |= 2;
    return biscSendLedCommand();
}


biscTurnOffPlayLed

decompiled_code:
__int64 biscTurnOffPlayLed()
{
ledState[0] ^= 2u;
return biscSendLedCommand();
}

canonical_decompiled_code:
__int64 func4()
{
ledState[0] ^= 2u;
return func0();
}

original_code:
int biscTurnOffPlayLed(void) {
    ledState.playAdvanceState ^= 1 << 1;
    return biscSendLedCommand();
}

canonical_original_code:
int biscTurnOffPlayLed() {
    ledState.playAdvanceState ^= 1 << 1;
    return biscSendLedCommand();
}


biscSetPowerLed

decompiled_code:
__int64 __fastcall biscSetPowerLed(unsigned __int8 a1, unsigned __int8 a2)
{
ledState[1] = a1;
ledState[2] = a2;
return biscSendLedCommand();
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int8 a1, unsigned __int8 a2)
{
ledState[1] = a1;
ledState[2] = a2;
return func0();
}

original_code:
int biscSetPowerLed(unsigned char color, unsigned char intensity) {
    ledState.powerLedColor = color;
    ledState.powerLedIntensity = intensity;
    return biscSendLedCommand();
}

variable_types:
color
unsigned char

variable_types:
intensity
unsigned char


biscTurnOffPowerLed

decompiled_code:
__int64 biscTurnOffPowerLed()
{
ledState[2] = 0;
return biscSendLedCommand();
}

canonical_decompiled_code:
__int64 func6()
{
ledState[2] = 0;
return func0();
}

original_code:
int biscTurnOffPowerLed(void) {
    ledState.powerLedIntensity = 0;
    return biscSendLedCommand();
}

canonical_original_code:
int biscTurnOffPowerLed() {
    ledState.powerLedIntensity = 0;
    return biscSendLedCommand();
}


biscFlashLed

decompiled_code:
__int64 __fastcall biscFlashLed(unsigned __int8 a1, int a2, unsigned int a3)
{
int v4; // ebx
__int16 v5; // r15
unsigned __int8 v7; // [rsp+Fh] [rbp-39h]

if ( (int)a3 <= 0 || a2 <= 0 || a1 > 2u )
return 0xFFFFFFFFLL;
v4 = 0;
v5 = *(_WORD *)ledState;
v7 = ledState[2];
do
{
if ( a1 == 1 )
{
if ( (unsigned int)biscTurnOnPlayLed() == -1
|| (unsigned int)biscWaitTime(a3) == -1
|| (unsigned int)biscTurnOffPlayLed() == -1 )
{
return 0xFFFFFFFFLL;
}
}
else if ( a1 == 2 )
{
if ( (unsigned int)biscTurnOnAdvanceLed() == -1
|| (unsigned int)biscWaitTime(a3) == -1
|| (unsigned int)biscTurnOffAdvanceLed() == -1 )
{
return 0xFFFFFFFFLL;
}
}
else if ( (unsigned int)biscSetPowerLed(ledState[1], 0xFFu) == -1
|| (unsigned int)biscWaitTime(a3) == -1
|| (unsigned int)biscSetPowerLed(ledState[1], 0) == -1 )
{
return 0xFFFFFFFFLL;
}
if ( (unsigned int)biscWaitTime(a3) == -1 )
return 0xFFFFFFFFLL;
++v4;
}
while ( a2 > v4 );
*(_WORD *)ledState = v5;
ledState[2] = v7;
return (unsigned int)-((unsigned int)biscSendLedCommand() == -1);
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int8 a1, int a2, unsigned int a3)
{
int v4; // ebx
__int16 v5; // r15
unsigned __int8 v7; // [rsp+Fh] [rbp-39h]

if ( (int)a3 <= 0 || a2 <= 0 || a1 > 2u )
return 0xFFFFFFFFLL;
v4 = 0;
v5 = *(_WORD *)ledState;
v7 = ledState[2];
do
{
if ( a1 == 1 )
{
if ( (unsigned int)func3() == -1
|| (unsigned int)biscWaitTime(a3) == -1
|| (unsigned int)func4() == -1 )
{
return 0xFFFFFFFFLL;
}
}
else if ( a1 == 2 )
{
if ( (unsigned int)func1() == -1
|| (unsigned int)biscWaitTime(a3) == -1
|| (unsigned int)func2() == -1 )
{
return 0xFFFFFFFFLL;
}
}
else if ( (unsigned int)func5(ledState[1], 0xFFu) == -1
|| (unsigned int)biscWaitTime(a3) == -1
|| (unsigned int)func5(ledState[1], 0) == -1 )
{
return 0xFFFFFFFFLL;
}
if ( (unsigned int)biscWaitTime(a3) == -1 )
return 0xFFFFFFFFLL;
++v4;
}
while ( a2 > v4 );
*(_WORD *)ledState = v5;
ledState[2] = v7;
return (unsigned int)-((unsigned int)func0() == -1);
}

original_code:
int biscFlashLed(char led, int numFlashes, int flashDurationMS) {
    if(led < 0 || led > 2) return -1;
    if(numFlashes <= 0) return -1;
    if(flashDurationMS <= 0) return -1;
    LedState stateBackup = ledState;
    for(int i=0; i<numFlashes; i++) {
        switch(led) {
            case 1:
                if(biscTurnOnPlayLed() == -1) return -1;
                break;
            case 2:
                if(biscTurnOnAdvanceLed() == -1) return -1;
                break;
            case 0:
                if(biscSetPowerLed(ledState.powerLedColor, 255) == -1) return -1;
                break;
            default:
                return -1;
        }
        if(biscWaitTime(flashDurationMS) == -1) return -1;
        switch(led) {
            case 1:
                if(biscTurnOffPlayLed() == -1) return -1;
                break;
            case 2:
                if(biscTurnOffAdvanceLed() == -1) return -1;
                break;
            case 0:
                if(biscSetPowerLed(ledState.powerLedColor, 0) == -1) return -1;
                break;
            default:
                return -1;
        }
        if(biscWaitTime(flashDurationMS) == -1) return -1;
    }
    ledState = stateBackup;
    if(biscSendLedCommand() == -1) return -1;
    return 0;
}

canonical_original_code:
int biscFlashLed(char led, int numFlashes, int flashDurationMS) {
    if(led < 0 || led > 2) return -1;
    if(numFlashes <= 0) return -1;
    if(flashDurationMS <= 0) return -1;
    struct LedState stateBackup = ledState;
    for(int i = 0; i<numFlashes; i++) {
        switch(led) {
            case 1:
                if(biscTurnOnPlayLed() == -1) return -1;
                break;
            case 2:
                if(biscTurnOnAdvanceLed() == -1) return -1;
                break;
            case 0:
                if(biscSetPowerLed(ledState.powerLedColor, 255) == -1) return -1;
                break;
            default:
                return -1;
        }
        if(biscWaitTime(flashDurationMS) == -1) return -1;
        switch(led) {
            case 1:
                if(biscTurnOffPlayLed() == -1) return -1;
                break;
            case 2:
                if(biscTurnOffAdvanceLed() == -1) return -1;
                break;
            case 0:
                if(biscSetPowerLed(ledState.powerLedColor, 0) == -1) return -1;
                break;
            default:
                return -1;
        }
        if(biscWaitTime(flashDurationMS) == -1) return -1;
    }
    ledState = stateBackup;
    if(biscSendLedCommand() == -1) return -1;
    return 0;
}

variable_types: led char

variable_types: numFlashes int

variable_types: flashDurationMS int

variable_types: struct LedState { char playAdvanceState; char powerLedColor; char powerLedIntensity; }

variable_types: i int


biscConnect

decompiled_code:
__int64 __fastcall biscConnect(const char *a1)
{
int v1; // edi
struct termios v3; // [rsp+0h] [rbp-58h] BYREF

if ( !a1 )
return 0xFFFFFFFFLL;
v1 = open(a1, 2306);
deviceDescriptor = v1;
if ( v1 == -1 )
return 0xFFFFFFFFLL;
tcgetattr(v1, &v3);
*(_QWORD *)&v3.c_iflag = 5LL;
*(_QWORD *)&v3.c_cflag = 2224LL;
cfsetispeed(&v3, 0x1001u);
cfsetospeed(&v3, 0x1001u);
tcsetattr(deviceDescriptor, 0, &v3);
return deviceDescriptor;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
int v1; // edi
struct termios v3; // [rsp+0h] [rbp-58h] BYREF

if ( !a1 )
return 0xFFFFFFFFLL;
v1 = open(a1, 2306);
deviceDescriptor = v1;
if ( v1 == -1 )
return 0xFFFFFFFFLL;
tcgetattr(v1, &v3);
*(_QWORD *)&v3.c_iflag = 5LL;
*(_QWORD *)&v3.c_cflag = 2224LL;
cfsetispeed(&v3, 0x1001u);
cfsetospeed(&v3, 0x1001u);
tcsetattr(deviceDescriptor, 0, &v3);
return deviceDescriptor;
}

original_code:
int biscConnect(char *device) {
    if(device == ((void *)0)) return -1;
    struct termios tty;
    if((deviceDescriptor = open(device, 02 | 0400 | 04000)) == -1) {
        return -1;
    }
    tcgetattr(deviceDescriptor, &tty);
    tty.c_iflag = 0000001 | 0000004;
    tty.c_lflag = 0;
    tty.c_oflag = 0;
    tty.c_cflag = 0000200 | 0000060 | 0004000;
    cfsetispeed(&tty, 0010001);
    cfsetospeed(&tty, 0010001);
    tcsetattr(deviceDescriptor, 0, &tty);
    return deviceDescriptor;
}

variable_types:
device
char *

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


biscDisconnect

decompiled_code:
__int64 biscDisconnect()
{
if ( !deviceDescriptor || close(deviceDescriptor) == -1 )
return 0xFFFFFFFFLL;
deviceDescriptor = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
if ( !deviceDescriptor || close(deviceDescriptor) == -1 )
return 0xFFFFFFFFLL;
deviceDescriptor = 0;
return 0LL;
}

original_code:
int biscDisconnect(void) {
    if(deviceDescriptor == 0) {
        return -1;
    }
    if(close(deviceDescriptor) == -1) {
        return -1;
    }
    deviceDescriptor = 0;
    return 0;
}

canonical_original_code:
int biscDisconnect() {
    if(deviceDescriptor == 0) {
        return -1;
    }
    if(close(deviceDescriptor) == -1) {
        return -1;
    }
    deviceDescriptor = 0;
    return 0;
}


biscSendByte

decompiled_code:
__int64 __fastcall biscSendByte(char a1)
{
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
usleep(0x2710u);
return (unsigned int)-(write(deviceDescriptor, buf, 1uLL) != 1);
}

canonical_decompiled_code:
__int64 __fastcall func2(char a1)
{
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
usleep(0x2710u);
return (unsigned int)-(write(deviceDescriptor, buf, 1uLL) != 1);
}

original_code:
int biscSendByte(unsigned char byte) {
    usleep(10000);
    return (write(deviceDescriptor, &byte, 1) == 1 ? 0 : -1);
}

variable_types:
byte
unsigned char


biscInit

decompiled_code:
__int64 __fastcall biscInit(const char *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
if ( (unsigned int)biscConnect(a1) == -1
|| (unsigned int)biscSendByte(128) == -1
|| (unsigned int)biscSendByte(131) == -1 )
{
return 0xFFFFFFFFLL;
}
ledState = 0;
*((_BYTE *)&ledState + 2) = -1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
if ( (unsigned int)func0(a1) == -1
|| (unsigned int)func2(128) == -1
|| (unsigned int)func2(131) == -1 )
{
return 0xFFFFFFFFLL;
}
ledState = 0;
*((_BYTE *)&ledState + 2) = -1;
return 0LL;
}

original_code:
int biscInit(char *device) {
    if(device == ((void *)0)) return -1;
    if(biscConnect(device) == -1) return -1;
    if(biscSendByte(128) == -1) return -1;
    if(biscSendByte(131) == -1) return -1;
    ledState.playAdvanceState = 0;
    ledState.powerLedColor = 0;
    ledState.powerLedIntensity = 255;
    return 0;
}


biscChangeMode

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

if ( (unsigned __int8)(a1 + 125) > 1u && a1 != (char)0x80 || (unsigned int)biscSendByte(128) == -1 )
result = 0xFFFFFFFFLL;
else
result = biscSendByte(a1);
return result;
}

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

if ( (unsigned __int8)(a1 + 125) > 1u && a1 != (char)0x80 || (unsigned int)func2(128) == -1 )
result = 0xFFFFFFFFLL;
else
result = func2(a1);
return result;
}

original_code:
int biscChangeMode(unsigned char mode) {
    if(mode != 132 && mode != 131 && mode != 128) return -1;
    if(biscSendByte(128) == -1) return -1;
    return biscSendByte(mode);
}

variable_types:
mode
unsigned char


biscHighByte

decompiled_code:
__int64 __fastcall biscHighByte(int a1)
{
return (unsigned int)(a1 >> 8);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
return (unsigned int)(a1 >> 8);
}

original_code:
char biscHighByte(int num) {
    return (num >> 8) & 0xff;
}

variable_types: num int

return_type: char


biscLowByte

decompiled_code:
__int64 __fastcall biscLowByte(unsigned int a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1)
{
return a1;
}

original_code:
char biscLowByte(int num) {
    return num & 0xff;
}


biscSendInt

decompiled_code:
__int64 __fastcall biscSendInt(unsigned int a1)
{
char v1; // al
__int64 result; // rax
char v3; // al

v1 = biscHighByte(a1);
result = biscSendByte(v1);
if ( (_DWORD)result != -1 )
{
v3 = biscLowByte(a1);
result = (unsigned int)-((unsigned int)biscSendByte(v3) == -1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1)
{
char v1; // al
__int64 result; // rax
char v3; // al

v1 = func5(a1);
result = func2(v1);
if ( (_DWORD)result != -1 )
{
v3 = func6(a1);
result = (unsigned int)-((unsigned int)func2(v3) == -1);
}
return result;
}

original_code:
int biscSendInt(int num) {
    if(biscSendByte(biscHighByte(num)) == -1) return -1;
    if(biscSendByte(biscLowByte(num)) == -1) return -1;
    return 0;
}


biscGetVersion

decompiled_code:
const char *biscGetVersion()
{
return "1.0.0";
}

canonical_decompiled_code:
const char *func8()
{
return "1.0.0";
}

original_code:
char* biscGetVersion(void) {
    return "1.0.0";
}

return_type: char *


biscWaitTime

decompiled_code:
__int64 __fastcall biscWaitTime(int a1)
{
if ( a1 <= 0 )
return 0xFFFFFFFFLL;
if ( (unsigned int)biscSendByte(155) == -1 )
return 0xFFFFFFFFLL;
return (unsigned int)-((unsigned int)biscSendByte((unsigned __int8)((1374389535LL * a1) >> 37) - (unsigned __int8)(a1 >> 31)) == -1);
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1)
{
if ( a1 <= 0 )
return 0xFFFFFFFFLL;
if ( (unsigned int)func2(155) == -1 )
return 0xFFFFFFFFLL;
return (unsigned int)-((unsigned int)func2((unsigned __int8)((1374389535LL * a1) >> 37) - (unsigned __int8)(a1 >> 31)) == -1);
}

original_code:
int biscWaitTime(int mseconds) {
    if(mseconds <= 0) return -1;
    if(biscSendByte(155) == -1) return -1;
    if(biscSendByte(mseconds / 100) == -1) return -1;
    return 0;
}

variable_types: mseconds int


biscWaitDistance

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

result = biscSendByte(156);
if ( (_DWORD)result != -1 )
result = (unsigned int)-((unsigned int)biscSendInt(a1) == -1);
return result;
}

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

result = func2(156);
if ( (_DWORD)result != -1 )
result = (unsigned int)-((unsigned int)func7(a1) == -1);
return result;
}

original_code:
int biscWaitDistance(int distanceMM) {
    if(biscSendByte(156) == -1) return -1;
    if(biscSendInt(distanceMM) == -1) return -1;
    return 0;
}

variable_types: distanceMM int


biscWaitAngle

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

result = biscSendByte(157);
if ( (_DWORD)result != -1 )
result = (unsigned int)-((unsigned int)biscSendInt(a1) == -1);
return result;
}

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

result = func2(157);
if ( (_DWORD)result != -1 )
result = (unsigned int)-((unsigned int)func7(a1) == -1);
return result;
}

original_code:
int biscWaitAngle(int degrees) {
    if(biscSendByte(157) == -1) return -1;
    if(biscSendInt(degrees) == -1) return -1;
    return 0;
}

variable_types: degrees int


biscWaitEvent

decompiled_code:
__int64 __fastcall biscWaitEvent(unsigned int a1)
{
if ( a1 > 0x16 )
return 0xFFFFFFFFLL;
if ( (unsigned int)biscSendByte(158) == -1 )
return 0xFFFFFFFFLL;
return (unsigned int)-((unsigned int)biscSendByte(a1) == -1);
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned int a1)
{
if ( a1 > 0x16 )
return 0xFFFFFFFFLL;
if ( (unsigned int)func2(158) == -1 )
return 0xFFFFFFFFLL;
return (unsigned int)-((unsigned int)func2(a1) == -1);
}

original_code:
int biscWaitEvent(int eventCode) {
    if(eventCode < 0 || eventCode > 22) return -1;
    if(biscSendByte(158) == -1) return -1;
    if(biscSendByte(eventCode) == -1) return -1;
    return 0;
}

variable_types: eventCode int


biscDrive

decompiled_code:
__int64 __fastcall biscDrive(unsigned int a1, unsigned int a2)
{
if ( a1 + 500 > 0x3E8 )
return 0xFFFFFFFFLL;
if ( (unsigned int)biscSendByte(137LL) == -1
|| (unsigned int)biscSendInt(a1) == -1
|| (unsigned int)biscSendInt(a2) == -1 )
{
return 0xFFFFFFFFLL;
}
return (unsigned int)-((unsigned int)biscSendLedCommand() == -1);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, unsigned int a2)
{
if ( a1 + 500 > 0x3E8 )
return 0xFFFFFFFFLL;
if ( (unsigned int)biscSendByte(137LL) == -1
|| (unsigned int)biscSendInt(a1) == -1
|| (unsigned int)biscSendInt(a2) == -1 )
{
return 0xFFFFFFFFLL;
}
return (unsigned int)-((unsigned int)biscSendLedCommand() == -1);
}

original_code:
int biscDrive(int velocity, int radius) {
    if(velocity < -500 || velocity > 500) return -1;
    if(biscSendByte(137) == -1) return -1;
    if(biscSendInt(velocity) == -1) return -1;
    if(biscSendInt(radius) == -1) return -1;
    if(biscSendLedCommand() == -1) return -1;
    return 0;
}

variable_types: velocity int

variable_types: radius int


biscDirectDrive

decompiled_code:
__int64 __fastcall biscDirectDrive(unsigned int a1, unsigned int a2)
{
if ( a1 + 500 > 0x3E8 )
return 0xFFFFFFFFLL;
if ( a2 + 500 > 0x3E8 || (unsigned int)biscSendByte(145LL) == -1 || (unsigned int)biscSendInt(a1) == -1 )
return 0xFFFFFFFFLL;
return (unsigned int)-((unsigned int)biscSendInt(a2) == -1);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, unsigned int a2)
{
if ( a1 + 500 > 0x3E8 )
return 0xFFFFFFFFLL;
if ( a2 + 500 > 0x3E8 || (unsigned int)biscSendByte(145LL) == -1 || (unsigned int)biscSendInt(a1) == -1 )
return 0xFFFFFFFFLL;
return (unsigned int)-((unsigned int)biscSendInt(a2) == -1);
}

original_code:
int biscDirectDrive(int rightVelocity, int leftVelocity) {
    if(rightVelocity < -500 || rightVelocity > 500) return -1;
    if(leftVelocity < -500 || leftVelocity > 500) return -1;
    if(biscSendByte(145) == -1) return -1;
    if(biscSendInt(rightVelocity) == -1) return -1;
    if(biscSendInt(leftVelocity) == -1) return -1;
    return 0;
}

variable_types: rightVelocity int

variable_types: leftVelocity int


biscDriveStraight

decompiled_code:
__int64 __fastcall biscDriveStraight(unsigned int a1)
{
return biscDrive(a1, 0x7FFFu);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
return func0(a1, 0x7FFFu);
}

original_code:
int biscDriveStraight(int velocity) {
    return biscDrive(velocity, 0x7FFF);
}


biscSpin

decompiled_code:
__int64 __fastcall biscSpin(unsigned int a1)
{
return biscDrive(a1, 0xFFFFu);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
return func0(a1, 0xFFFFu);
}

original_code:
int biscSpin(int velocity) {
    return biscDrive(velocity, 0xFFFF);
}


biscDriveStop

decompiled_code:
__int64 biscDriveStop()
{
return biscDrive(0, 0);
}

canonical_decompiled_code:
__int64 func4()
{
return func0(0, 0);
}

original_code:
int biscDriveStop(void) {
    return biscDrive(0, 0);
}

canonical_original_code:
int biscDriveStop() {
    return biscDrive(0, 0);
}


biscTimedDrive

decompiled_code:
__int64 __fastcall biscTimedDrive(unsigned int a1, unsigned int a2, int a3)
{
if ( a3 <= 0 )
return 0xFFFFFFFFLL;
if ( (unsigned int)biscDrive(a1, a2) == -1 || (unsigned int)biscWaitTime((unsigned int)a3) == -1 )
return 0xFFFFFFFFLL;
return (unsigned int)-((unsigned int)biscDriveStop() == -1);
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, unsigned int a2, int a3)
{
if ( a3 <= 0 )
return 0xFFFFFFFFLL;
if ( (unsigned int)func0(a1, a2) == -1 || (unsigned int)biscWaitTime((unsigned int)a3) == -1 )
return 0xFFFFFFFFLL;
return (unsigned int)-((unsigned int)func4() == -1);
}

original_code:
int biscTimedDrive(int velocity, int radius, int mseconds) {
    if(mseconds <= 0) return -1;
    if(biscDrive(velocity, radius) == -1) return -1;
    if(biscWaitTime(mseconds) == -1) return -1;
    if(biscDriveStop() == -1) return -1;
    return 0;
}


biscTimedDriveStraight

decompiled_code:
__int64 __fastcall biscTimedDriveStraight(unsigned int a1, int a2)
{
return biscTimedDrive(a1, 0x7FFFu, a2);
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1, int a2)
{
return func5(a1, 0x7FFFu, a2);
}

original_code:
int biscTimedDriveStraight(int velocity, int mseconds) {
    return biscTimedDrive(velocity, 0x7FFF, mseconds);
}


biscDriveDistance

decompiled_code:
__int64 __fastcall biscDriveDistance(signed int a1, unsigned int a2, int a3)
{
__int64 result; // rax

if ( a1 > 0 && a3 < 0
|| a1 < 0 && a3 > 0
|| (unsigned int)biscDrive(a1, a2) == -1
|| (unsigned int)biscWaitDistance((unsigned int)a3) == -1 )
{
result = 0xFFFFFFFFLL;
}
else
{
result = (unsigned int)-((unsigned int)biscDriveStop() == -1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(signed int a1, unsigned int a2, int a3)
{
__int64 result; // rax

if ( a1 > 0 && a3 < 0
|| a1 < 0 && a3 > 0
|| (unsigned int)func0(a1, a2) == -1
|| (unsigned int)biscWaitDistance((unsigned int)a3) == -1 )
{
result = 0xFFFFFFFFLL;
}
else
{
result = (unsigned int)-((unsigned int)func4() == -1);
}
return result;
}

original_code:
int biscDriveDistance(int velocity, int radius, int distanceMM) {
    if((velocity > 0 && distanceMM < 0) || (velocity < 0 && distanceMM > 0)) return -1;
    if(biscDrive(velocity, radius) == -1) return -1;
    if(biscWaitDistance(distanceMM) == -1) return -1;
    if(biscDriveStop() == -1) return -1;
    return 0;
}


biscDriveDistanceStraight

decompiled_code:
__int64 __fastcall biscDriveDistanceStraight(signed int a1, int a2)
{
return biscDriveDistance(a1, 0x7FFFu, a2);
}

canonical_decompiled_code:
__int64 __fastcall func8(signed int a1, int a2)
{
return func7(a1, 0x7FFFu, a2);
}

original_code:
int biscDriveDistanceStraight(int velocity, int distanceMM) {
    return biscDriveDistance(velocity, 0x7FFF, distanceMM);
}


biscTimedSpin

decompiled_code:
__int64 __fastcall biscTimedSpin(unsigned int a1, int a2)
{
if ( a2 <= 0 )
return 0xFFFFFFFFLL;
if ( (unsigned int)biscSpin(a1) == -1 || (unsigned int)biscWaitTime((unsigned int)a2) == -1 )
return 0xFFFFFFFFLL;
return (unsigned int)-((unsigned int)biscDriveStop() == -1);
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1, int a2)
{
if ( a2 <= 0 )
return 0xFFFFFFFFLL;
if ( (unsigned int)func3(a1) == -1 || (unsigned int)biscWaitTime((unsigned int)a2) == -1 )
return 0xFFFFFFFFLL;
return (unsigned int)-((unsigned int)func4() == -1);
}

original_code:
int biscTimedSpin(int velocity, int mseconds) {
    if(mseconds <= 0) return -1;
    if(biscSpin(velocity) == -1) return -1;
    if(biscWaitTime(mseconds) == -1) return -1;
    if(biscDriveStop() == -1) return -1;
    return 0;
}


biscSpinAngle

decompiled_code:
__int64 __fastcall biscSpinAngle(unsigned int a1, unsigned int a2)
{
__int64 result; // rax

if ( (unsigned int)biscSpin(a1) == -1 || (unsigned int)biscWaitAngle(a2) == -1 )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)-((unsigned int)biscDriveStop() == -1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1, unsigned int a2)
{
__int64 result; // rax

if ( (unsigned int)func3(a1) == -1 || (unsigned int)biscWaitAngle(a2) == -1 )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)-((unsigned int)func4() == -1);
return result;
}

original_code:
int biscSpinAngle(int velocity, int degrees) {
    if(biscSpin(velocity) == -1) return -1;
    if(biscWaitAngle(degrees) == -1) return -1;
    if(biscDriveStop() == -1) return -1;
    return 0;
}


biscDefineSong

decompiled_code:
__int64 __fastcall biscDefineSong(unsigned __int8 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 v4; // rbp
__int64 v6; // rbx
__int64 v7; // rdi

if ( a1 > 0xFu )
return 0xFFFFFFFFLL;
v4 = a4;
if ( a4 - 1 <= 0xF
&& (unsigned int)biscSendByte(140LL) != -1
&& (unsigned int)biscSendByte(a1) != -1
&& (unsigned int)biscSendByte((unsigned int)v4) != -1 )
{
v6 = 0LL;
while ( 1 )
{
v7 = *(unsigned __int8 *)(a2 + v6);
if ( (unsigned __int8)(v7 - 31) > 0x60u
|| (unsigned int)biscSendByte(v7) == -1
|| (unsigned int)biscSendByte(*(unsigned __int8 *)(a3 + v6)) == -1 )
{
break;
}
if ( v4 == ++v6 )
return 0LL;
}
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 v4; // rbp
__int64 v6; // rbx
__int64 v7; // rdi

if ( a1 > 0xFu )
return 0xFFFFFFFFLL;
v4 = a4;
if ( a4 - 1 <= 0xF
&& (unsigned int)biscSendByte(140LL) != -1
&& (unsigned int)biscSendByte(a1) != -1
&& (unsigned int)biscSendByte((unsigned int)v4) != -1 )
{
v6 = 0LL;
while ( 1 )
{
v7 = *(unsigned __int8 *)(a2 + v6);
if ( (unsigned __int8)(v7 - 31) > 0x60u
|| (unsigned int)biscSendByte(v7) == -1
|| (unsigned int)biscSendByte(*(unsigned __int8 *)(a3 + v6)) == -1 )
{
break;
}
if ( v4 == ++v6 )
return 0LL;
}
}
return 0xFFFFFFFFLL;
}

original_code:
int biscDefineSong(unsigned char songNum, unsigned char *notes, unsigned char *notesDurations, unsigned int notesLen) {
    if(songNum > 15) return -1;
    if(sizeof(notes) != sizeof(notesDurations)) return -1;
    if(notesLen <= 0 || notesLen > 16) return -1;
    if(biscSendByte(140) == -1) return -1;
    if(biscSendByte(songNum) == -1) return -1;
    if(biscSendByte(notesLen) == -1) return -1;
    for(unsigned int i=0; i<notesLen; i++) {
        if(notes[i] < 31 || notes[i] > 127) return -1;
        if(biscSendByte(notes[i]) == -1) return -1;
        if(biscSendByte(notesDurations[i]) == -1) return -1;
    }
    return 0;
}

canonical_original_code:
int biscDefineSong(unsigned char songNum, unsigned char *notes, unsigned char *notesDurations, unsigned int notesLen) {
    if(songNum > 15) return -1;
    if(sizeof(notes) != sizeof(notesDurations)) return -1;
    if(notesLen <= 0 || notesLen > 16) return -1;
    if(biscSendByte(140) == -1) return -1;
    if(biscSendByte(songNum) == -1) return -1;
    if(biscSendByte(notesLen) == -1) return -1;
    for(unsigned int i = 0; i<notesLen; i++) {
        if(notes[i] < 31 || notes[i] > 127) return -1;
        if(biscSendByte(notes[i]) == -1) return -1;
        if(biscSendByte(notesDurations[i]) == -1) return -1;
    }
    return 0;
}

variable_types:
songNum
unsigned char

variable_types:
notes
unsigned char *

variable_types:
notesDurations
unsigned char *

variable_types:
notesLen
unsigned int

variable_types:
i
unsigned int


biscPlaySong

decompiled_code:
__int64 __fastcall biscPlaySong(unsigned __int8 a1)
{
if ( a1 > 0xFu )
return 0xFFFFFFFFLL;
if ( (unsigned int)biscSendByte(141LL) == -1 )
return 0xFFFFFFFFLL;
return (unsigned int)-((unsigned int)biscSendByte(a1) == -1);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 a1)
{
if ( a1 > 0xFu )
return 0xFFFFFFFFLL;
if ( (unsigned int)biscSendByte(141LL) == -1 )
return 0xFFFFFFFFLL;
return (unsigned int)-((unsigned int)biscSendByte(a1) == -1);
}

original_code:
int biscPlaySong(unsigned char songNum) {
    if(songNum > 15) return -1;
    if(biscSendByte(141) == -1) return -1;
    if(biscSendByte(songNum) == -1) return -1;
    return 0;
}


biscBeep

decompiled_code:
__int64 biscBeep()
{
__int64 result; // rax
char v1; // [rsp+Eh] [rbp-Ah] BYREF
char v2[9]; // [rsp+Fh] [rbp-9h] BYREF

v1 = 70;
v2[0] = 10;
result = biscDefineSong(0, (__int64)&v1, (__int64)v2, 1u);
if ( (_DWORD)result != -1 )
result = biscPlaySong(0);
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
char v1; // [rsp+Eh] [rbp-Ah] BYREF
char v2[9]; // [rsp+Fh] [rbp-9h] BYREF

v1 = 70;
v2[0] = 10;
result = func0(0, (__int64)&v1, (__int64)v2, 1u);
if ( (_DWORD)result != -1 )
result = func1(0);
return result;
}

original_code:
int biscBeep(void) {
    unsigned char beep[] = {70};
    unsigned char beepd[] = {10};
    if(biscDefineSong(0, beep, beepd, sizeof(beepd)) == -1) return -1;
    return biscPlaySong(0);
}

canonical_original_code:
int biscBeep() {
    unsigned char beep[] = {70};
    unsigned char beepd[] = {10};
    if(biscDefineSong(0, beep, beepd, sizeof(beepd)) == -1) return -1;
    return biscPlaySong(0);
}

variable_types:
beep
unsigned char []

variable_types:
beepd
unsigned char []


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
__int64 v4; // r12
__int64 v5; // rax
__int64 v6; // r13
unsigned int v7; // ebx
int v8; // ebp
int v9; // eax
struct timespec v11; // [rsp+0h] [rbp-38h] BYREF

v3 = init_requests_queue(&request_mutex, &got_request, envp);
if ( !v3 )
_assert_fail("requests", "main.c", 0x2Bu, "main");
v4 = v3;
v5 = init_handler_threads_pool(&request_mutex, &got_request, v3);
v6 = v5;
if ( !v5 )
_assert_fail("handler_threads", "main.c", 0x30u, "main");
v7 = 0;
add_handler_thread(v5);
add_handler_thread(v6);
add_handler_thread(v6);
do
{
while ( 1 )
{
add_request(v4, v7);
v8 = get_requests_number(v4);
v9 = get_handler_threads_number(v6);
if ( v8 > 15 && v9 <= 13 )
{
printf("main: adding thread: '%d' requests, '%d' threads\n", (unsigned int)v8, (unsigned int)v9);
add_handler_thread(v6);
goto LABEL_6;
}
if ( v8 <= 2 && v9 > 3 )
break;
LABEL_6:
if ( rand() > 1610612733 )
goto LABEL_12;
LABEL_7:
if ( ++v7 == 600 )
goto LABEL_13;
}
printf("main: deleting thread: '%d' requests, '%d' threads\n", (unsigned int)v8, (unsigned int)v9);
delete_handler_thread(v6);
if ( rand() <= 1610612733 )
goto LABEL_7;
LABEL_12:
++v7;
v11.tv_sec = 0LL;
v11.tv_nsec = 1LL;
nanosleep(&v11, 0LL);
}
while ( v7 != 600 );
LABEL_13:
pthread_mutex_lock(&request_mutex);
done_creating_requests = 1;
pthread_cond_broadcast(&got_request);
pthread_mutex_unlock(&request_mutex);
delete_handler_threads_pool(v6);
delete_requests_queue(v4);
puts("Glory, we are done.");
return 0;
}

original_code:
int
main(int argc, char* argv[])
{
    int i;
    struct timespec delay;
    struct requests_queue* requests = ((void *)0);
    struct handler_threads_pool* handler_threads = ((void *)0);
    requests = init_requests_queue(&request_mutex, &got_request);
    ((void) sizeof ((requests) ? 1 : 0), __extension__ ({ if (requests) ; else __assert_fail ("requests", "main.c", 43, __extension__ __PRETTY_FUNCTION__); }));
    handler_threads =
 init_handler_threads_pool(&request_mutex, &got_request, requests);
    ((void) sizeof ((handler_threads) ? 1 : 0), __extension__ ({ if (handler_threads) ; else __assert_fail ("handler_threads", "main.c", 48, __extension__ __PRETTY_FUNCTION__); }));
    for (i=0; i<3; i++) {
 add_handler_thread(handler_threads);
    }
    for (i=0; i<600; i++) {
 int num_requests;
 int num_threads;
 add_request(requests, i);
 num_requests = get_requests_number(requests);
 num_threads = get_handler_threads_number(handler_threads);
 if (num_requests > 15 &&
     num_threads < 14) {
  printf("main: adding thread: '%d' requests, '%d' threads\n",
         num_requests, num_threads);
  add_handler_thread(handler_threads);
 }
 if (num_requests < 3 &&
   num_threads > 3) {
     printf("main: deleting thread: '%d' requests, '%d' threads\n",
     num_requests, num_threads);
     delete_handler_thread(handler_threads);
 }
 if (rand() > 3*(2147483647/4)) {
     delay.tv_sec = 0;
     delay.tv_nsec = 1;
     nanosleep(&delay, ((void *)0));
 }
    }
    {
        int rc;
        rc = pthread_mutex_lock(&request_mutex);
        done_creating_requests = 1;
        rc = pthread_cond_broadcast(&got_request);
        rc = pthread_mutex_unlock(&request_mutex);
    }
    delete_handler_threads_pool(handler_threads);
    delete_requests_queue(requests);
    printf("Glory,  we are done.\n");
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    int i;
    struct timespec delay;
    struct requests_queue *requests = ((void *)0);
    struct handler_threads_pool *handler_threads = ((void *)0);
    requests = init_requests_queue(&request_mutex, &got_request);
    ((void) sizeof ((requests) ? 1 : 0), __extension__ ({ if (requests) ; else __assert_fail ("requests", "main.c", 43, __extension__ __PRETTY_FUNCTION__); }));
    handler_threads =
 init_handler_threads_pool(&request_mutex, &got_request, requests);
    ((void) sizeof ((handler_threads) ? 1 : 0), __extension__ ({ if (handler_threads) ; else __assert_fail ("handler_threads", "main.c", 48, __extension__ __PRETTY_FUNCTION__); }));
    for (i=0; i<3; i++) {
 add_handler_thread(handler_threads);
    }
    for (i=0; i<600; i++) {
 int num_requests;
 int num_threads;
 add_request(requests, i);
 num_requests = get_requests_number(requests);
 num_threads = get_handler_threads_number(handler_threads);
 if (num_requests > 15 &&
     num_threads < 14) {
  printf("main: adding thread: '%d' requests, '%d' threads\n",
         num_requests, num_threads);
  add_handler_thread(handler_threads);
 }
 if (num_requests < 3 &&
   num_threads > 3) {
     printf("main: deleting thread: '%d' requests, '%d' threads\n",
     num_requests, num_threads);
     delete_handler_thread(handler_threads);
 }
 if (rand() > 3*(2147483647/4)) {
     delay.tv_sec = 0;
     delay.tv_nsec = 1;
     nanosleep(&delay, ((void *)0));
 }
    }
    {
        int rc;
        rc = pthread_mutex_lock(&request_mutex);
        done_creating_requests = 1;
        rc = pthread_cond_broadcast(&got_request);
        rc = pthread_mutex_unlock(&request_mutex);
    }
    delete_handler_threads_pool(handler_threads);
    delete_requests_queue(requests);
    printf("Glory,  we are done.\n");
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: i int

variable_types: struct timespec { long tv_sec; long tv_nsec; }

variable_types: struct requests_queue { struct request { int number; struct request *next; } *requests; struct request *last_request; int num_requests; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *p_mutex; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } *p_cond_var; } *

variable_types: struct handler_threads_pool { struct handler_thread { unsigned long thread; int thr_id; struct handler_thread *next; } *threads; struct handler_thread *last_thread; int num_threads; int max_thr_id; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *p_mutex; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } *p_cond_var; struct requests_queue { struct request { int number; struct request *next; } *requests; struct request *last_request; int num_requests; union pthread_mutex_t *p_mutex; union pthread_cond_t *p_cond_var; } *requests; } *

variable_types: rc int

user_defined_types: struct requests_queue { struct request *requests; struct request *last_request; int num_requests; union pthread_mutex_t *p_mutex; union pthread_cond_t *p_cond_var; }

user_defined_types: struct handler_threads_pool { struct handler_thread *threads; struct handler_thread *last_thread; int num_threads; int max_thr_id; union pthread_mutex_t *p_mutex; union pthread_cond_t *p_cond_var; struct requests_queue *requests; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
__int64 __fastcall remove_first_handler_thread(__int64 *a1)
{
int v1; // edx
__int64 result; // rax

if ( !a1 )
_assert_fail("pool", "handler_threads_pool.c", 0x5Eu, "remove_first_handler_thread");
v1 = *((_DWORD *)a1 + 4);
result = 0LL;
if ( v1 > 0 )
{
result = *a1;
if ( *a1 )
{
*a1 = *(_QWORD *)(result + 16);
*(_QWORD *)(result + 16) = 0LL;
*((_DWORD *)a1 + 4) = v1 - 1;
}
}
return result;
}

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

if ( !a1 )
_assert_fail("pool", "handler_threads_pool.c", 0x5Eu, "remove_first_handler_thread");
v1 = *((_DWORD *)a1 + 4);
result = 0LL;
if ( v1 > 0 )
{
result = *a1;
if ( *a1 )
{
*a1 = *(_QWORD *)(result + 16);
*(_QWORD *)(result + 16) = 0LL;
*((_DWORD *)a1 + 4) = v1 - 1;
}
}
return result;
}

original_code:
static struct handler_thread*
remove_first_handler_thread(struct handler_threads_pool* pool)
{
    struct handler_thread* a_thread = ((void *)0);
    ((void) sizeof ((pool) ? 1 : 0), __extension__ ({ if (pool) ; else __assert_fail ("pool", "handler_threads_pool.c", 94, __extension__ __PRETTY_FUNCTION__); }));
    if (pool->num_threads > 0 && pool->threads) {
 a_thread = pool->threads;
 pool->threads = a_thread->next;
 a_thread->next = ((void *)0);
        pool->num_threads--;
    }
    return a_thread;
}

canonical_original_code:
static struct handler_thread *remove_first_handler_thread(struct handler_threads_pool *pool)
{
    struct handler_thread *a_thread = ((void *)0);
    ((void) sizeof ((pool) ? 1 : 0), __extension__ ({ if (pool) ; else __assert_fail ("pool", "handler_threads_pool.c", 94, __extension__ __PRETTY_FUNCTION__); }));
    if (pool->num_threads > 0 && pool->threads) {
 a_thread = pool->threads;
 pool->threads = a_thread->next;
 a_thread->next = ((void *)0);
        pool->num_threads--;
    }
    return a_thread;
}

variable_types: struct handler_threads_pool { struct handler_thread *threads; struct handler_thread *last_thread; int num_threads; int max_thr_id; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *p_mutex; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } *p_cond_var; struct requests_queue { struct request { int number; struct request *next; } *requests; struct request *last_request; int num_requests; union pthread_mutex_t *p_mutex; union pthread_cond_t *p_cond_var; } *requests; } *

variable_types: struct handler_thread { unsigned long thread; int thr_id; struct handler_thread *next; } *


decompiled_code:
__int64 __fastcall add_handler_thread(__int64 a1)
{
pthread_t *v1; // rax
pthread_t *v2; // rbp
int v3; // er12
_QWORD *v4; // rax
int v5; // eax
__int64 result; // rax

if ( !a1 )
_assert_fail("pool", "handler_threads_pool.c", 0x2Cu, "add_handler_thread");
v1 = (pthread_t *)malloc(0x18uLL);
v2 = v1;
if ( !v1
|| (v3 = *(_DWORD *)(a1 + 20),
v1[2] = 0LL,
*((_DWORD *)v1 + 2) = v3,
*(_DWORD *)(a1 + 20) = v3 + 1,
(v4 = malloc(0x20uLL)) == 0LL) )
{
fwrite("add_handler_thread: out of memory. exiting\n", 1uLL, 0x2BuLL, stderr);
exit(1);
}
*(_DWORD *)v4 = v3;
v4[1] = *(_QWORD *)(a1 + 24);
v4[2] = *(_QWORD *)(a1 + 32);
v4[3] = *(_QWORD *)(a1 + 40);
pthread_create(v2, 0LL, (void *(*)(void *))&handle_requests_loop, v4);
v5 = *(_DWORD *)(a1 + 16);
if ( v5 )
{
result = (unsigned int)(v5 + 1);
*(_QWORD *)(*(_QWORD *)(a1 + 8) + 16LL) = v2;
*(_QWORD *)(a1 + 8) = v2;
*(_DWORD *)(a1 + 16) = result;
}
else
{
result = 1LL;
*(_QWORD *)a1 = v2;
*(_QWORD *)(a1 + 8) = v2;
*(_DWORD *)(a1 + 16) = 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
pthread_t *v1; // rax
pthread_t *v2; // rbp
int v3; // er12
_QWORD *v4; // rax
int v5; // eax
__int64 result; // rax

if ( !a1 )
_assert_fail("pool", "handler_threads_pool.c", 0x2Cu, "add_handler_thread");
v1 = (pthread_t *)malloc(0x18uLL);
v2 = v1;
if ( !v1
|| (v3 = *(_DWORD *)(a1 + 20),
v1[2] = 0LL,
*((_DWORD *)v1 + 2) = v3,
*(_DWORD *)(a1 + 20) = v3 + 1,
(v4 = malloc(0x20uLL)) == 0LL) )
{
fwrite("add_handler_thread: out of memory. exiting\n", 1uLL, 0x2BuLL, stderr);
exit(1);
}
*(_DWORD *)v4 = v3;
v4[1] = *(_QWORD *)(a1 + 24);
v4[2] = *(_QWORD *)(a1 + 32);
v4[3] = *(_QWORD *)(a1 + 40);
pthread_create(v2, 0LL, (void *(*)(void *))&handle_requests_loop, v4);
v5 = *(_DWORD *)(a1 + 16);
if ( v5 )
{
result = (unsigned int)(v5 + 1);
*(_QWORD *)(*(_QWORD *)(a1 + 8) + 16LL) = v2;
*(_QWORD *)(a1 + 8) = v2;
*(_DWORD *)(a1 + 16) = result;
}
else
{
result = 1LL;
*(_QWORD *)a1 = v2;
*(_QWORD *)(a1 + 8) = v2;
*(_DWORD *)(a1 + 16) = 1;
}
return result;
}

original_code:
void
add_handler_thread(struct handler_threads_pool* pool)
{
    struct handler_thread* a_thread;
    struct handler_thread_params* params;
    ((void) sizeof ((pool) ? 1 : 0), __extension__ ({ if (pool) ; else __assert_fail ("pool", "handler_threads_pool.c", 44, __extension__ __PRETTY_FUNCTION__); }));
    a_thread = (struct handler_thread*)malloc(sizeof(struct handler_thread));
    if (!a_thread) {
 fprintf(stderr, "add_handler_thread: out of memory. exiting\n");
 exit(1);
    }
    a_thread->thr_id = pool->max_thr_id++;
    a_thread->next = ((void *)0);
    params = (struct handler_thread_params*)
                            malloc(sizeof(struct handler_thread_params));
    if (!params) {
 fprintf(stderr, "add_handler_thread: out of memory. exiting\n");
 exit(1);
    }
    params->thread_id = a_thread->thr_id;
    params->request_mutex = pool->p_mutex;
    params->got_request = pool->p_cond_var;
    params->requests = pool->requests;
    pthread_create(&a_thread->thread,
     ((void *)0),
     handle_requests_loop,
     (void*)params);
    if (pool->num_threads == 0) {
        pool->threads = a_thread;
        pool->last_thread = a_thread;
    }
    else {
        pool->last_thread->next = a_thread;
        pool->last_thread = a_thread;
    }
    pool->num_threads++;
}

canonical_original_code:
void add_handler_thread(struct handler_threads_pool *pool)
{
    struct handler_thread *a_thread;
    struct handler_thread_params *params;
    ((void) sizeof ((pool) ? 1 : 0), __extension__ ({ if (pool) ; else __assert_fail ("pool", "handler_threads_pool.c", 44, __extension__ __PRETTY_FUNCTION__); }));
    a_thread = (struct handler_thread *)malloc(sizeof(struct handler_thread));
    if (!a_thread) {
 fprintf(stderr, "add_handler_thread: out of memory. exiting\n");
 exit(1);
    }
    a_thread->thr_id = pool->max_thr_id++;
    a_thread->next = ((void *)0);
    params = (struct handler_thread_params *)
                            malloc(sizeof(struct handler_thread_params));
    if (!params) {
 fprintf(stderr, "add_handler_thread: out of memory. exiting\n");
 exit(1);
    }
    params->thread_id = a_thread->thr_id;
    params->request_mutex = pool->p_mutex;
    params->got_request = pool->p_cond_var;
    params->requests = pool->requests;
    pthread_create(&a_thread->thread,
     ((void *)0),
     handle_requests_loop,
     (void *)params);
    if (pool->num_threads == 0) {
        pool->threads = a_thread;
        pool->last_thread = a_thread;
    }
    else {
        pool->last_thread->next = a_thread;
        pool->last_thread = a_thread;
    }
    pool->num_threads++;
}

variable_types: struct handler_thread_params { int thread_id; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *request_mutex; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } *got_request; struct requests_queue { struct request { int number; struct request *next; } *requests; struct request *last_request; int num_requests; union pthread_mutex_t *p_mutex; union pthread_cond_t *p_cond_var; } *requests; } *

user_defined_types: struct handler_thread { unsigned long thread; int thr_id; struct handler_thread *next; }

user_defined_types: struct handler_thread_params { int thread_id; union pthread_mutex_t *request_mutex; union pthread_cond_t *got_request; struct requests_queue *requests; }


decompiled_code:
void __fastcall delete_handler_thread(__int64 *a1)
{
pthread_t *v1; // rax
pthread_t *v2; // rbp

if ( !a1 )
_assert_fail("pool", "handler_threads_pool.c", 0x71u, "delete_handler_thread");
v1 = (pthread_t *)remove_first_handler_thread(a1);
v2 = v1;
if ( v1 )
{
pthread_cancel(*v1);
free(v2);
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 *a1)
{
pthread_t *v1; // rax
pthread_t *v2; // rbp

if ( !a1 )
_assert_fail("pool", "handler_threads_pool.c", 0x71u, "delete_handler_thread");
v1 = (pthread_t *)func0(a1);
v2 = v1;
if ( v1 )
{
pthread_cancel(*v1);
free(v2);
}
}

original_code:
void
delete_handler_thread(struct handler_threads_pool* pool)
{
    struct handler_thread* a_thread;
    ((void) sizeof ((pool) ? 1 : 0), __extension__ ({ if (pool) ; else __assert_fail ("pool", "handler_threads_pool.c", 113, __extension__ __PRETTY_FUNCTION__); }));
    a_thread = remove_first_handler_thread(pool);
    if (a_thread) {
 pthread_cancel(a_thread->thread);
        free(a_thread);
    }
}

canonical_original_code:
void delete_handler_thread(struct handler_threads_pool *pool)
{
    struct handler_thread *a_thread;
    ((void) sizeof ((pool) ? 1 : 0), __extension__ ({ if (pool) ; else __assert_fail ("pool", "handler_threads_pool.c", 113, __extension__ __PRETTY_FUNCTION__); }));
    a_thread = remove_first_handler_thread(pool);
    if (a_thread) {
 pthread_cancel(a_thread->thread);
        free(a_thread);
    }
}

user_defined_types: struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }

user_defined_types: struct request { int number; struct request *next; }


decompiled_code:
__int64 __fastcall get_handler_threads_number(__int64 a1)
{
if ( !a1 )
_assert_fail("pool", "handler_threads_pool.c", 0x7Fu, "get_handler_threads_number");
return *(unsigned int *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
if ( !a1 )
_assert_fail("pool", "handler_threads_pool.c", 0x7Fu, "get_handler_threads_number");
return *(unsigned int *)(a1 + 16);
}

original_code:
int
get_handler_threads_number(struct handler_threads_pool* pool)
{
    ((void) sizeof ((pool) ? 1 : 0), __extension__ ({ if (pool) ; else __assert_fail ("pool", "handler_threads_pool.c", 127, __extension__ __PRETTY_FUNCTION__); }));
    return pool->num_threads;
}

canonical_original_code:
int get_handler_threads_number(struct handler_threads_pool *pool)
{
    ((void) sizeof ((pool) ? 1 : 0), __extension__ ({ if (pool) ; else __assert_fail ("pool", "handler_threads_pool.c", 127, __extension__ __PRETTY_FUNCTION__); }));
    return pool->num_threads;
}