decompiled_code:
__int64 __fastcall write_to_disk(int fd, void *buf, __off64_t offset, size_t n)
{
__int64 result; // rax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax

if ( lseek64(fd, offset, 0) < 0 )
{
v6 = _errno_location();
v7 = strerror(*v6);
log_error("%s(%d) lseek error %s\n", "write_to_disk", 54LL, v7);
result = 0xFFFFFFFFLL;
}
else if ( write(fd, buf, n) < 0 )
{
v8 = _errno_location();
v9 = strerror(*v8);
log_error("%s(%d) write error %s\n", "write_to_disk", 58LL, v9);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int fd, void *buf, __off64_t offset, size_t n)
{
__int64 result; // rax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax

if ( lseek64(fd, offset, 0) < 0 )
{
v6 = _errno_location();
v7 = strerror(*v6);
log_error("%s(%d) lseek error %s\n", "write_to_disk", 54LL, v7);
result = 0xFFFFFFFFLL;
}
else if ( write(fd, buf, n) < 0 )
{
v8 = _errno_location();
v9 = strerror(*v8);
log_error("%s(%d) write error %s\n", "write_to_disk", 58LL, v9);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

original_code:
int write_to_disk(int fd, void *buf, uint64_t offset, size_t len)
{
 if (lseek64(fd, offset, 0) < 0) {
  do { log_error("%s(%d) " "lseek error %s\n", __FUNCTION__, 54, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 if (write(fd, buf, len) < 0) {
  do { log_error("%s(%d) " "write error %s\n", __FUNCTION__, 58, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 return 0;
}

canonical_original_code:
int write_to_disk(int fd, void *buf, unsigned long offset, unsigned long len)
{
 if (lseek64(fd, offset, 0) < 0) {
  do { log_error("%s(%d) " "lseek error %s\n", __FUNCTION__, 54, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 if (write(fd, buf, len) < 0) {
  do { log_error("%s(%d) " "write error %s\n", __FUNCTION__, 58, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 return 0;
}

variable_types:
offset
unsigned long


decompiled_code:
__int64 __fastcall read_from_disk(int fd, void *buf, __off64_t offset, size_t nbytes)
{
__int64 result; // rax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax

if ( lseek64(fd, offset, 0) < 0 )
{
v6 = _errno_location();
v7 = strerror(*v6);
log_error("%s(%d) lseek error %s\n", "read_from_disk", 68LL, v7);
result = 0xFFFFFFFFLL;
}
else if ( read(fd, buf, nbytes) < 0 )
{
v8 = _errno_location();
v9 = strerror(*v8);
log_error("%s(%d) read error %s\n", "read_from_disk", 72LL, v9);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int fd, void *buf, __off64_t offset, size_t nbytes)
{
__int64 result; // rax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax

if ( lseek64(fd, offset, 0) < 0 )
{
v6 = _errno_location();
v7 = strerror(*v6);
log_error("%s(%d) lseek error %s\n", "read_from_disk", 68LL, v7);
result = 0xFFFFFFFFLL;
}
else if ( read(fd, buf, nbytes) < 0 )
{
v8 = _errno_location();
v9 = strerror(*v8);
log_error("%s(%d) read error %s\n", "read_from_disk", 72LL, v9);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

original_code:
int read_from_disk(int fd, void *buf, uint64_t offset, size_t len)
{
 if (lseek64(fd, offset, 0) < 0) {
  do { log_error("%s(%d) " "lseek error %s\n", __FUNCTION__, 68, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 if (read(fd, buf, len) < 0) {
  do { log_error("%s(%d) " "read error %s\n", __FUNCTION__, 72, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 return 0;
}

canonical_original_code:
int read_from_disk(int fd, void *buf, unsigned long offset, unsigned long len)
{
 if (lseek64(fd, offset, 0) < 0) {
  do { log_error("%s(%d) " "lseek error %s\n", __FUNCTION__, 68, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 if (read(fd, buf, len) < 0) {
  do { log_error("%s(%d) " "read error %s\n", __FUNCTION__, 72, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 return 0;
}

variable_types: fd int

variable_types:
buf
void *

variable_types:
len
unsigned long

return_type: int


decompiled_code:
__int64 __fastcall write_extend(unsigned int a1, void *a2)
{
size_t v2; // rbp
int v3; // eax

v2 = get_extend_size();
v3 = get_disk_fd();
return (unsigned int)-((unsigned int)write_to_disk(v3, a2, v2 * a1, v2) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1, void *a2)
{
size_t v2; // rbp
int v3; // eax

v2 = get_extend_size();
v3 = get_disk_fd();
return (unsigned int)-((unsigned int)func8(v3, a2, v2 * a1, v2) != 0);
}

original_code:
int write_extend(uint32_t extend_no, void *buf)
{
 size_t len = get_extend_size();
 int fd = get_disk_fd();
 off64_t offset = (uint64_t)extend_no * len;
 if (write_to_disk(fd, buf, offset, len))
  return -1;
 return 0;
}

canonical_original_code:
int write_extend(unsigned int extend_no, void *buf)
{
 unsigned long len = get_extend_size();
 int fd = get_disk_fd();
 long offset = (uint64_t)extend_no * len;
 if (write_to_disk(fd, buf, offset, len))
  return -1;
 return 0;
}

variable_types: offset long


decompiled_code:
__int64 __fastcall read_extend(unsigned int a1, void *a2)
{
size_t v2; // rbp
int v3; // eax

v2 = get_extend_size();
v3 = get_disk_fd();
return (unsigned int)-((unsigned int)read_from_disk(v3, a2, v2 * a1, v2) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func11(unsigned int a1, void *a2)
{
size_t v2; // rbp
int v3; // eax

v2 = get_extend_size();
v3 = get_disk_fd();
return (unsigned int)-((unsigned int)func9(v3, a2, v2 * a1, v2) != 0);
}

original_code:
int read_extend(uint32_t extend_no, void *buf)
{
 size_t len = get_extend_size();
 int fd = get_disk_fd();
 off64_t offset = (uint32_t)extend_no * len;
 if (read_from_disk(fd, buf, offset, len))
  return -1;
 return 0;
}

canonical_original_code:
int read_extend(unsigned int extend_no, void *buf)
{
 unsigned long len = get_extend_size();
 int fd = get_disk_fd();
 long offset = (uint32_t)extend_no * len;
 if (read_from_disk(fd, buf, offset, len))
  return -1;
 return 0;
}


decompiled_code:
void __fastcall register_ioengine(__int64 a1)
{
ioengine = a1;
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
ioengine = a1;
}

original_code:
void register_ioengine(struct ioengine_ops *ops)
{
 ioengine = ops;
}

variable_types: struct ioengine_ops { char *name; int (*io_init)(); int (*io_exit)(); int (*io_submit)(struct extend_buf { struct hlist_node { struct hlist_node *next; } hash_list; struct list_head { struct list_head *next; } lru_list; unsigned int eno; unsigned int real_eno; char *data; int rw; int error; unsigned int list_mode; unsigned int hold_cnt; unsigned int state; unsigned long last_accessed; 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; } lock; 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; } cond; void (*end_io_fn)(void *args); void *args; struct list_head data_list; struct queue { struct list_head lru[2]; unsigned long n_buffers[2]; struct hlist_head { struct hlist_node *first; } *cache_hash; int hash_bits; struct list_head reserved_buffers; unsigned int need_reserved_buffers; unsigned long clean_tid; int clean_stop; union pthread_mutex_t clean_lock; union pthread_cond_t free_buffer_cond; union pthread_mutex_t free_buffer_lock; union pthread_mutex_t lock; unsigned int eno_prefix; } *q; struct list_head inode_list; } *b); } *

return_type: void

user_defined_types: struct ioengine_ops { char *name; int (*io_init)(); int (*io_exit)(); int (*io_submit)(struct extend_buf *b); }

user_defined_types: struct extend_buf { struct hlist_node hash_list; struct list_head lru_list; unsigned int eno; unsigned int real_eno; char *data; int rw; int error; unsigned int list_mode; unsigned int hold_cnt; unsigned int state; unsigned long last_accessed; union pthread_mutex_t lock; union pthread_cond_t cond; void (*end_io_fn)(void *args); void *args; struct list_head data_list; struct queue *q; struct list_head inode_list; }

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

user_defined_types: struct queue { struct list_head lru[2]; unsigned long n_buffers[2]; struct hlist_head *cache_hash; int hash_bits; struct list_head reserved_buffers; unsigned int need_reserved_buffers; unsigned long clean_tid; int clean_stop; union pthread_mutex_t clean_lock; union pthread_cond_t free_buffer_cond; union pthread_mutex_t free_buffer_lock; union pthread_mutex_t lock; unsigned int eno_prefix; }


repo: salmon/workdemo

decompiled_code:
unsigned __int64 __fastcall tf_to_lba(_BYTE *a1)
{
unsigned int v1; // eax

if ( a1[4] )
v1 = (unsigned __int8)a1[12] | ((unsigned __int8)a1[13] << 8) | ((unsigned __int8)a1[14] << 16);
else
v1 = *a1 & 0xF;
return (unsigned __int8)a1[7] | ((unsigned __int8)a1[8] << 8) | ((unsigned __int8)a1[9] << 16) | ((unsigned __int64)v1 << 24);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(_BYTE *a1)
{
unsigned int v1; // eax

if ( a1[4] )
v1 = (unsigned __int8)a1[12] | ((unsigned __int8)a1[13] << 8) | ((unsigned __int8)a1[14] << 16);
else
v1 = *a1 & 0xF;
return (unsigned __int8)a1[7] | ((unsigned __int8)a1[8] << 8) | ((unsigned __int8)a1[9] << 16) | ((unsigned __int64)v1 << 24);
}

original_code:
static __u64 tf_to_lba(struct ata_tf *tf)
{
 __u32 lba24, lbah;
 __u64 lba64;
 lba24 = (tf->lob.lbah << 16) | (tf->lob.lbam << 8) | (tf->lob.lbal);
 if (tf->is_lba48)
  lbah = (tf->hob.lbah << 16) | (tf->hob.lbam << 8) | (tf->hob.lbal);
 else
  lbah = (tf->dev & 0x0f);
 lba64 = (((__u64)lbah) << 24) | (__u64)lba24;
 return lba64;
}

canonical_original_code:
static unsigned long long tf_to_lba(struct ata_tf *tf)
{
 unsigned int lba24; unsigned int lbah;
 unsigned long long lba64;
 lba24 = (tf->lob.lbah << 16) | (tf->lob.lbam << 8) | (tf->lob.lbal);
 if (tf->is_lba48)
  lbah = (tf->hob.lbah << 16) | (tf->hob.lbam << 8) | (tf->hob.lbal);
 else
  lbah = (tf->dev & 0x0f);
 lba64 = (((unsigned long long)lbah) << 24) | (unsigned long long)lba24;
 return lba64;
}

variable_types: struct ata_tf { unsigned char dev; unsigned char command; unsigned char error; unsigned char status; unsigned char is_lba48; struct ata_lba_regs { unsigned char feat; unsigned char nsect; unsigned char lbal; unsigned char lbam; unsigned char lbah; } lob; struct ata_lba_regs hob; } *

variable_types:
lbah
unsigned int

return_type: unsigned long long

user_defined_types: struct ata_tf { unsigned char dev; unsigned char command; unsigned char error; unsigned char status; unsigned char is_lba48; struct ata_lba_regs lob; struct ata_lba_regs hob; }


decompiled_code:
__int64 __fastcall get_identify_data(int fd, _QWORD *a2)
{
unsigned int v2; // edx
int v3; // eax

memset(&args_0, 0, 0x200uLL);
*((_DWORD *)&args_0 + 128) = 0;
args_0 = -20;
byte_343 = 1;
if ( (unsigned int)do_drive_cmd(fd, &args_0, 0) )
return (unsigned int)-1;
v2 = 0;
*a2 = qword_344;
a2[63] = qword_53C;
qmemcpy(
(void *)((unsigned __int64)(a2 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)&qword_344 - ((char *)a2 - ((unsigned __int64)(a2 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)a2 - (((_DWORD)a2 + 8) & 0xFFFFFFF8) + 512) >> 3));
v3 = 256;
do
--v3;
while ( v3 );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(int fd, _QWORD *a2)
{
unsigned int v2; // edx
int v3; // eax

memset(&args_0, 0, 0x200uLL);
*((_DWORD *)&args_0 + 128) = 0;
args_0 = -20;
byte_343 = 1;
if ( (unsigned int)func2(fd, &args_0, 0) )
return (unsigned int)-1;
v2 = 0;
*a2 = qword_344;
a2[63] = qword_53C;
qmemcpy(
(void *)((unsigned __int64)(a2 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)&qword_344 - ((char *)a2 - ((unsigned __int64)(a2 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)a2 - (((_DWORD)a2 + 8) & 0xFFFFFFF8) + 512) >> 3));
v3 = 256;
do
--v3;
while ( v3 );
return v2;
}

original_code:
int get_identify_data(int fd, __u16 *id)
{
 static __u8 args[4+512];
 int i;
 memset(args, 0, sizeof(args));
 args[0] = (0xec);
 args[3] = 1;
 if (do_drive_cmd(fd, args, 0))
  return -1;
 memcpy(id, (void *)(args + 4), 512);
 for (i = 0; i < 0x100; ++i)
  do { (void)(id[i]); } while (0);
 return 0;
}

canonical_original_code:
int get_identify_data(int fd, unsigned short *id)
{
 static unsigned char args[-1];
 int i;
 memset(args, 0, sizeof(args));
 args[0] = (0xec);
 args[3] = 1;
 if (do_drive_cmd(fd, args, 0))
  return -1;
 memcpy(id, (void *)(args + 4), 512);
 for (i = 0; i < 0x100; ++i)
  do { (void)(id[i]); } while (0);
 return 0;
}

variable_types:
id
unsigned short *

variable_types:
args
unsigned char [-1]

variable_types: i int


repo: salviati/ips

decompiled_code:
int display_version()
{
return fprintf(stdout, "%s %s (%s)\n", "ips", "0.0.1", "May 23 2025");
}

original_code:
static void display_version()
{
 fprintf(stdout, "%s %s (%s)\n", "ips", "0.0.1", "Apr 24 2024");
}


decompiled_code:
size_t display_usage()
{
fprintf(stdout, "%s\n", "ips");
fwrite("A utility for appyling & creating IPS patches.\n\n", 1uLL, 0x30uLL, stdout);
fprintf(stdout, "usage: %s [-hLV] -a|c -r <romfile> -m <modified_romfile> -i <ipsfile>\n\n", "ips");
fwrite("-a apply IPS patch\n", 1uLL, 0x1FuLL, stderr);
fwrite("-c create IPS patch\n", 1uLL, 0x20uLL, stderr);
fwrite("-h create IPS patch\n", 1uLL, 0x20uLL, stderr);
fwrite("-i <ipsfile> set IPS patch filename\n", 1uLL, 0x26uLL, stderr);
fwrite("-L display software license and quit\n", 1uLL, 0x31uLL, stderr);
fwrite("-m <mromfile> set modified rom filename (only with -c)\n", 1uLL, 0x38uLL, stderr);
fwrite("-r <romfile> set original rom filename\n", 1uLL, 0x29uLL, stderr);
fwrite("-v verify integrity of IPS file\n", 1uLL, 0x2CuLL, stderr);
return fwrite("-V display version info and quit\n", 1uLL, 0x2DuLL, stderr);
}

canonical_decompiled_code:
size_t func8()
{
fprintf(stdout, "%s\n", "ips");
fwrite("A utility for appyling & creating IPS patches.\n\n", 1uLL, 0x30uLL, stdout);
fprintf(stdout, "usage: %s [-hLV] -a|c -r <romfile> -m <modified_romfile> -i <ipsfile>\n\n", "ips");
fwrite("-a apply IPS patch\n", 1uLL, 0x1FuLL, stderr);
fwrite("-c create IPS patch\n", 1uLL, 0x20uLL, stderr);
fwrite("-h create IPS patch\n", 1uLL, 0x20uLL, stderr);
fwrite("-i <ipsfile> set IPS patch filename\n", 1uLL, 0x26uLL, stderr);
fwrite("-L display software license and quit\n", 1uLL, 0x31uLL, stderr);
fwrite("-m <mromfile> set modified rom filename (only with -c)\n", 1uLL, 0x38uLL, stderr);
fwrite("-r <romfile> set original rom filename\n", 1uLL, 0x29uLL, stderr);
fwrite("-v verify integrity of IPS file\n", 1uLL, 0x2CuLL, stderr);
return fwrite("-V display version info and quit\n", 1uLL, 0x2DuLL, stderr);
}

original_code:
static void display_usage()
{
 fprintf(stdout, "%s\n", "ips");
 fprintf(stdout, "A utility for appyling & creating IPS patches.\n\n");
 fprintf(stdout, "usage: %s [-hLV] -a|c -r <romfile> -m <modified_romfile> -i <ipsfile>\n\n", "ips");
 fprintf(stderr, "-a             apply IPS patch\n");
 fprintf(stderr, "-c             create IPS patch\n");
 fprintf(stderr, "-h             create IPS patch\n");
 fprintf(stderr, "-i <ipsfile>   set IPS patch filename\n");
 fprintf(stderr, "-L             display software license and quit\n");
 fprintf(stderr, "-m <mromfile>  set modified rom filename (only with -c)\n");
 fprintf(stderr, "-r <romfile>   set original rom filename\n");
 fprintf(stderr, "-v             verify integrity of IPS file\n");
 fprintf(stderr, "-V             display version info and quit\n");
}


decompiled_code:
size_t display_license()
{
fwrite("You may redistribute copies of this program\n", 1uLL, 0x2CuLL, stdout);
fwrite("under the terms of the GNU General Public License.\n", 1uLL, 0x33uLL, stdout);
fwrite("For more information about these matters, see the file named COPYING.\n", 1uLL, 0x46uLL, stdout);
return fwrite("Report bugs to <bug@freeconsole.org>.\n", 1uLL, 0x26uLL, stdout);
}

canonical_decompiled_code:
size_t func9()
{
fwrite("You may redistribute copies of this program\n", 1uLL, 0x2CuLL, stdout);
fwrite("under the terms of the GNU General Public License.\n", 1uLL, 0x33uLL, stdout);
fwrite("For more information about these matters, see the file named COPYING.\n", 1uLL, 0x46uLL, stdout);
return fwrite("Report bugs to <bug@freeconsole.org>.\n", 1uLL, 0x26uLL, stdout);
}

original_code:
static void display_license()
{
 fprintf(stdout, "You may redistribute copies of this program\n");
 fprintf(stdout, "under the terms of the GNU General Public License.\n");
 fprintf(stdout, "For more information about these matters, see the file named COPYING.\n");
 fprintf(stdout, "Report bugs to <bug@freeconsole.org>.\n");
}


error

decompiled_code:
void __fastcall __noreturn error(const char *a1)
{
fputs(a1, stderr);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func10(const char *a1)
{
fputs(a1, stderr);
exit(1);
}

original_code:
static void error(const char *s)
{
 fprintf(stderr, "%s", s);
 exit(1);
}

canonical_original_code:
static void error(char *s)
{
 fprintf(stderr, "%s", s);
 exit(1);
}

variable_types:
s
char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r14
char *v4; // r12
__int64 v5; // r13
int v6; // er15
int v7; // eax
int v9; // ebx
int *v10; // rax
char *v11; // rax
int v12; // eax
int v13; // ebx
int *v14; // rax
char *v15; // rax

v3 = 0LL;
v4 = 0LL;
v5 = 0LL;
v6 = 0;
while ( 1 )
{
v7 = getopt(argc, (char *const *)argv, "acvr:m:i:hLV");
if ( v7 == -1 )
break;
switch ( v7 )
{
case 'L':
display_license();
exit(0);
case 'V':
display_version();
exit(0);
case 'a':
v6 = 1;
break;
case 'c':
v6 = 2;
break;
case 'h':
display_usage();
exit(0);
case 'i':
v5 = optarg;
break;
case 'm':
v3 = optarg;
break;
case 'r':
case 'v':
v4 = (char *)optarg;
break;
default:
continue;
}
}
if ( v6 == 1 )
{
if ( !v4 )
error("no rom file specified\n");
if ( !v5 )
error("no IPS file specified\n");
v9 = ips_apply(v4);
if ( v9 )
{
v10 = __errno_location();
v11 = strerror(*v10);
fprintf(stderr, "error: %s\n", v11);
exit(v9);
}
}
else if ( v6 == 2 )
{
if ( !v4 )
error("no rom file specified\n");
if ( !v3 )
error("no modified rom file specified\n");
if ( !v5 )
error("no IPS file specified\n");
v12 = ips_create(v4, v3, v5);
v13 = v12;
if ( v12 )
{
if ( v12 == -1 )
{
fwrite("rom lengths do not match.\n", 1uLL, 0x1AuLL, stderr);
}
else
{
v14 = __errno_location();
v15 = strerror(*v14);
fprintf(stderr, "error: %s\n", v15);
}
exit(v13);
}
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r14
char *v4; // r12
__int64 v5; // r13
int v6; // er15
int v7; // eax
int v9; // ebx
int *v10; // rax
char *v11; // rax
int v12; // eax
int v13; // ebx
int *v14; // rax
char *v15; // rax

v3 = 0LL;
v4 = 0LL;
v5 = 0LL;
v6 = 0;
while ( 1 )
{
v7 = getopt(argc, (char *const *)argv, "acvr:m:i:hLV");
if ( v7 == -1 )
break;
switch ( v7 )
{
case 'L':
func9();
exit(0);
case 'V':
func7();
exit(0);
case 'a':
v6 = 1;
break;
case 'c':
v6 = 2;
break;
case 'h':
func8();
exit(0);
case 'i':
v5 = optarg;
break;
case 'm':
v3 = optarg;
break;
case 'r':
case 'v':
v4 = (char *)optarg;
break;
default:
continue;
}
}
if ( v6 == 1 )
{
if ( !v4 )
func10("no rom file specified\n");
if ( !v5 )
func10("no IPS file specified\n");
v9 = func17(v4);
if ( v9 )
{
v10 = __errno_location();
v11 = strerror(*v10);
fprintf(stderr, "error: %s\n", v11);
exit(v9);
}
}
else if ( v6 == 2 )
{
if ( !v4 )
func10("no rom file specified\n");
if ( !v3 )
func10("no modified rom file specified\n");
if ( !v5 )
func10("no IPS file specified\n");
v12 = func18(v4, v3, v5);
v13 = v12;
if ( v12 )
{
if ( v12 == -1 )
{
fwrite("rom lengths do not match.\n", 1uLL, 0x1AuLL, stderr);
}
else
{
v14 = __errno_location();
v15 = strerror(*v14);
fprintf(stderr, "error: %s\n", v15);
}
exit(v13);
}
}
return 0;
}

original_code:
int main(int argc, char* argv[])
{
 enum {
  ACT_NONE,
  ACT_APPLY,
  ACT_CREATE
 } action = ACT_NONE;
 int c, err;
 char *ipsfile=0, *romfile=0, *modified_romfile=0;
 int verify=0;
 while((c=getopt(argc, argv, "acvr:m:i:hLV")) != (-1))
 {
  switch(c)
  {
   case 'a':
    action = ACT_APPLY;
   break;
   case 'c':
    action = ACT_CREATE;
   break;
   case 'v':
    verify = 1;
   case 'r':
    romfile = optarg;
   break;
   case 'm':
    modified_romfile = optarg;
   break;
   case 'i':
    ipsfile = optarg;
   break;
   case 'h':
    display_usage();
    exit(0);
   case 'L':
    display_license();
    exit(0);
   break;
   case 'V':
    display_version();
    exit(0);
  }
 }
 if(action == ACT_APPLY)
 {
  if(!romfile) error("no rom file specified\n");
  if(!ipsfile) error("no IPS file specified\n");
  if((err = ips_apply(romfile, ipsfile)))
  {
   fprintf(stderr, "error: %s\n", strerror((*__errno_location ())));
   exit(err);
  }
 }
 else if(action == ACT_CREATE)
 {
  if(!romfile) error("no rom file specified\n");
  if(!modified_romfile) error("no modified rom file specified\n");
  if(!ipsfile) error("no IPS file specified\n");
  if((err = ips_create(romfile, modified_romfile, ipsfile)))
  {
   if(err==-1) fprintf(stderr, "rom lengths do not match.\n");
   else fprintf(stderr, "error: %s\n", strerror((*__errno_location ())));
   exit(err);
  }
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 enum { ACT_NONE=0, ACT_APPLY=1, ACT_CREATE=2 } action = ACT_NONE;
 int c; int err;
 char *ipsfile = 0; char *romfile = 0; char *modified_romfile = 0;
 int verify = 0;
 while((c=getopt(argc, argv, "acvr:m:i:hLV")) != (-1))
 {
  switch(c)
  {
   case 'a':
    action = ACT_APPLY;
   break;
   case 'c':
    action = ACT_CREATE;
   break;
   case 'v':
    verify = 1;
   case 'r':
    romfile = optarg;
   break;
   case 'm':
    modified_romfile = optarg;
   break;
   case 'i':
    ipsfile = optarg;
   break;
   case 'h':
    display_usage();
    exit(0);
   case 'L':
    display_license();
    exit(0);
   break;
   case 'V':
    display_version();
    exit(0);
  }
 }
 if(action == ACT_APPLY)
 {
  if(!romfile) error("no rom file specified\n");
  if(!ipsfile) error("no IPS file specified\n");
  if((err = ips_apply(romfile, ipsfile)))
  {
   fprintf(stderr, "error: %s\n", strerror((*__errno_location ())));
   exit(err);
  }
 }
 else if(action == ACT_CREATE)
 {
  if(!romfile) error("no rom file specified\n");
  if(!modified_romfile) error("no modified rom file specified\n");
  if(!ipsfile) error("no IPS file specified\n");
  if((err = ips_create(romfile, modified_romfile, ipsfile)))
  {
   if(err==-1) fprintf(stderr, "rom lengths do not match.\n");
   else fprintf(stderr, "error: %s\n", strerror((*__errno_location ())));
   exit(err);
  }
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: c int

variable_types: err int

variable_types:
ipsfile
char *

variable_types:
romfile
char *

variable_types: verify int


ra

original_code:
static unsigned int ra(const void *p)
{
 unsigned char *s = (unsigned char *)p;
 return s[2] | (s[1]<<8) | (s[0]<<16);
}

canonical_original_code:
static unsigned int ra(void *p)
{
 unsigned char *s = (unsigned char *)p;
 return s[2] | (s[1]<<8) | (s[0]<<16);
}

variable_types:
p
void *

variable_types:
s
unsigned char *

return_type: unsigned int


rs

decompiled_code:
__int64 __fastcall rs(unsigned __int8 *a1)
{
return a1[1] | (*a1 << 8);
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned __int8 *a1)
{
return a1[1] | (*a1 << 8);
}

original_code:
static unsigned int rs(const void *p)
{
 unsigned char *s = (unsigned char *)p;
 return s[1] | (s[0]<<8);
}

canonical_original_code:
static unsigned int rs(void *p)
{
 unsigned char *s = (unsigned char *)p;
 return s[1] | (s[0]<<8);
}


decompiled_code:
__int64 __fastcall ips_apply_mem(__int64 a1, __int64 a2, __int64 a3, int a4)
{
unsigned __int64 v4; // r12
unsigned __int8 *v5; // rbx
unsigned int v6; // ebp
unsigned int v7; // eax

v4 = a3 + a4 - 2;
v5 = (unsigned __int8 *)(a3 + 5);
if ( v4 > a3 + 5 )
{
do
{
v6 = ra(v5);
v7 = rs(v5 + 2);
v5 += 5;
memcpy((void *)v6, v5, v7);
}
while ( v4 > (unsigned __int64)v5 );
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2, __int64 a3, int a4)
{
unsigned __int64 v4; // r12
unsigned __int8 *v5; // rbx
unsigned int v6; // ebp
unsigned int v7; // eax

v4 = a3 + a4 - 2;
v5 = (unsigned __int8 *)(a3 + 5);
if ( v4 > a3 + 5 )
{
do
{
v6 = func11(v5);
v7 = func12(v5 + 2);
v5 += 5;
memcpy((void *)v6, v5, v7);
}
while ( v4 > (unsigned __int64)v5 );
}
return 0LL;
}

original_code:
int ips_apply_mem(void *rom, int rom_size, const void *ips, int ips_size)
{
 char *p=(char*)ips, *end, *dst=(char*)dst;
 unsigned int adr,size;
 end = p + (ips_size - strlen("PATCH") + strlen("EOF")) ;
 p += strlen("PATCH");
 while(p<end)
 {
  adr = ra(p);
  p+=2;
  size = rs(p);
  p+=3;
  memcpy(dst+adr,p,size);
 }
 return 0;
}

canonical_original_code:
int ips_apply_mem(void *rom, int rom_size, void *ips, int ips_size)
{
 char *p = (char*)ips; char *end; char *dst = (char*)dst;
 unsigned int adr; unsigned int size;
 end = p + (ips_size - strlen("PATCH") + strlen("EOF")) ;
 p += strlen("PATCH");
 while(p<end)
 {
  adr = ra(p);
  p+=2;
  size = rs(p);
  p+=3;
  memcpy(dst+adr,p,size);
 }
 return 0;
}

variable_types:
rom
void *

variable_types:
ips
void *

variable_types:
p
char *

variable_types:
end
char *

variable_types:
dst
char *

variable_types:
adr
unsigned int

variable_types:
size
unsigned int


decompiled_code:
__int64 __fastcall ips_create_mem(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
strcpy((char *)a4, "PATCH");
*(_DWORD *)(a4 + 5) = 4607813;
return 0LL;
}

original_code:
int ips_create_mem(const void *rom, int rom_size, const void *modified_rom, void *_ips)
{
 char *ips = (char*)_ips;
 strcpy(ips, "PATCH");
 ips += strlen("PATCH");
 strcpy(ips,"EOF");
 return 0;
}

canonical_original_code:
int ips_create_mem(void *rom, int rom_size, void *modified_rom, void *_ips)
{
 char *ips = (char*)_ips;
 strcpy(ips, "PATCH");
 ips += strlen("PATCH");
 strcpy(ips,"EOF");
 return 0;
}

variable_types:
ips
char *


decompiled_code:
__int64 __fastcall ips_estimate(__int64 a1, __int64 a2, __int64 a3)
{
return ips_create_mem(a1, a2, a3, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, __int64 a2, __int64 a3)
{
return func15(a1, a2, a3, 0LL);
}

original_code:
int ips_estimate(const void *rom, int romsize, const void *modified_rom)
{
 return ips_create_mem(rom,romsize,modified_rom,0);
}

canonical_original_code:
int ips_estimate(void *rom, int romsize, void *modified_rom)
{
 return ips_create_mem(rom,romsize,modified_rom,0);
}

variable_types: romsize int


decompiled_code:
const char *ips_version()
{
return "0.0.1";
}

canonical_decompiled_code:
const char *func19()
{
return "0.0.1";
}

canonical_original_code:
char *ips_version()
{
 return "0.0.1";
}

return_type: char *


usage

repo: sam-github/netfilter-lua

decompiled_code:
void __noreturn usage()
{
fwrite(
"usage: expect-create-userspace [-v ] -s srcip -d dstip -f srcport -t dstport -e expectport -T timeout [-P]\n",
1uLL,
0x6BuLL,
stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func10()
{
fwrite(
"usage: expect-create-userspace [-v ] -s srcip -d dstip -f srcport -t dstport -e expectport -T timeout [-P]\n",
1uLL,
0x6BuLL,
stderr);
exit(1);
}

original_code:
void usage(void)
{
    fprintf(stderr,
            "usage: expect-create-userspace [-v ] -s srcip -d dstip -f srcport -t dstport -e expectport -T timeout [-P]\n"
           );
    exit(1);
}

canonical_original_code:
void usage()
{
    fprintf(stderr,
            "usage: expect-create-userspace [-v ] -s srcip -d dstip -f srcport -t dstport -e expectport -T timeout [-P]\n"
           );
    exit(1);
}


error

repo: samaitra/unix-netwk-prog

decompiled_code:
void __fastcall __noreturn error(const char *a1)
{
perror(a1);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func8(const char *a1)
{
perror(a1);
exit(0);
}

original_code:
void error(char *msg)
{
perror(msg);
exit(0);
}

variable_types:
msg
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
__int16 v4; // ax
size_t v5; // rax
char v7[256]; // [rsp+0h] [rbp-128h] BYREF
struct sockaddr addr; // [rsp+100h] [rbp-28h] BYREF

if ( argc <= 2 )
{
fprintf(stderr, "usage %s <IP ADDRESS> <PORT>\n", *argv);
exit(0);
}
v3 = socket(2, 1, 0);
if ( v3 < 0 )
error("ERROR opening socket");
*(_QWORD *)&addr.sa_family = 2LL;
*(_QWORD *)&addr.sa_data[6] = 0LL;
*(_DWORD *)&addr.sa_data[2] = inet_addr(argv[1]);
v4 = atoi(argv[2]);
*(_WORD *)addr.sa_data = _bswap_16(v4);
if ( connect(v3, &addr, 0x10u) < 0 )
error("ERROR connecting");
puts("Connection Established");
printf("Query: ");
memset(v7, 0, sizeof(v7));
fgets(v7, 255, stdin);
v5 = strlen(v7);
if ( (int)write(v3, v7, v5) < 0 )
error("ERROR writing to socket");
memset(v7, 0, sizeof(v7));
if ( (int)read(v3, v7, 0xFFuLL) < 0 )
error("ERROR reading from socket");
printf("Client:%s\n", v7);
close(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
__int16 v4; // ax
size_t v5; // rax
char v7[256]; // [rsp+0h] [rbp-128h] BYREF
struct sockaddr addr; // [rsp+100h] [rbp-28h] BYREF

if ( argc <= 2 )
{
fprintf(stderr, "usage %s <IP ADDRESS> <PORT>\n", *argv);
exit(0);
}
v3 = socket(2, 1, 0);
if ( v3 < 0 )
func8("ERROR opening socket");
*(_QWORD *)&addr.sa_family = 2LL;
*(_QWORD *)&addr.sa_data[6] = 0LL;
*(_DWORD *)&addr.sa_data[2] = inet_addr(argv[1]);
v4 = atoi(argv[2]);
*(_WORD *)addr.sa_data = func7(v4);
if ( connect(v3, &addr, 0x10u) < 0 )
func8("ERROR connecting");
puts("Connection Established");
printf("Query: ");
memset(v7, 0, sizeof(v7));
fgets(v7, 255, stdin);
v5 = strlen(v7);
if ( (int)write(v3, v7, v5) < 0 )
func8("ERROR writing to socket");
memset(v7, 0, sizeof(v7));
if ( (int)read(v3, v7, 0xFFuLL) < 0 )
func8("ERROR reading from socket");
printf("Client:%s\n", v7);
close(v3);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
    int sockfd, portno, n;
    struct sockaddr_in serv_addr;
    struct hostent *shost;
    char buff[256];
    if (argc < 3) { fprintf(stderr,"usage %s <IP ADDRESS> <PORT>\n", argv[0]);
     exit(0);
  }
    sockfd = socket(2, SOCK_STREAM, 0);
 if (sockfd < 0) error("ERROR opening socket");
    bzero((char *) &serv_addr, sizeof(serv_addr));
 portno = atoi(argv[2]);
    serv_addr.sin_family = 2;
    serv_addr.sin_addr.s_addr= inet_addr(argv[1]);
   serv_addr.sin_port = htons(atoi(argv[2]));
   if (connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0)
       error("ERROR connecting");
       printf("Connection Established\n");
       printf("Query: ");
     bzero(buff,256);
    fgets(buff,255,stdin);
  n = write(sockfd,buff,strlen(buff));
     if (n < 0) error("ERROR writing to socket");
      bzero(buff,256);
  n = read(sockfd,buff,255);
    if (n < 0) error("ERROR reading from socket");
   printf("Client:%s\n",buff);
close(sockfd);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    int sockfd; int portno; int n;
    struct sockaddr_in serv_addr;
    struct hostent *shost;
    char buff[256];
    if (argc < 3) { fprintf(stderr,"usage %s <IP ADDRESS> <PORT>\n", argv[0]);
     exit(0);
  }
    sockfd = socket(2, SOCK_STREAM, 0);
 if (sockfd < 0) error("ERROR opening socket");
    bzero((char *) &serv_addr, sizeof(serv_addr));
 portno = atoi(argv[2]);
    serv_addr.sin_family = 2;
    serv_addr.sin_addr.s_addr= inet_addr(argv[1]);
   serv_addr.sin_port = htons(atoi(argv[2]));
   if (connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0)
       error("ERROR connecting");
       printf("Connection Established\n");
       printf("Query: ");
     bzero(buff,256);
    fgets(buff,255,stdin);
  n = write(sockfd,buff,strlen(buff));
     if (n < 0) error("ERROR writing to socket");
      bzero(buff,256);
  n = read(sockfd,buff,255);
    if (n < 0) error("ERROR reading from socket");
   printf("Client:%s\n",buff);
close(sockfd);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: sockfd int

variable_types: portno int

variable_types: n int

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

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

variable_types:
buff
char [256]

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

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


decompiled_code:
void __fastcall sig_stp(unsigned int a1)
{
printf("Pressed ctrl-z");
printf("\nReceived SIGSTOP signal %d\n", a1);
}

canonical_decompiled_code:
void __fastcall func8(unsigned int a1)
{
printf("Pressed ctrl-z");
printf("\nReceived SIGSTOP signal %d\n", a1);
}

original_code:
void sig_stp(int signo) {
    printf("Pressed ctrl-z");
     printf("\nReceived SIGSTOP signal %d\n", signo);
}

variable_types: signo int


decompiled_code:
void __fastcall sig_int(unsigned int a1)
{
printf("Pressed ctrl-c");
printf("\nReceived SIGINT signal %d\n", a1);
}

canonical_decompiled_code:
void __fastcall func7(unsigned int a1)
{
printf("Pressed ctrl-c");
printf("\nReceived SIGINT signal %d\n", a1);
}

original_code:
void sig_int(int signo) {
      printf("Pressed ctrl-c");
      printf("\nReceived SIGINT signal %d\n", signo);
     }


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
char *v3; // rbp
unsigned int v4; // eax
char *v5; // rbx
__pid_t v6; // eax
char s[56]; // [rsp+20h] [rbp-38h] BYREF

signal(2, (__sighandler_t)sig_int);
signal(19, (__sighandler_t)sig_stp);
while ( 1 )
{
do
{
puts("Enter command:");
__isoc99_scanf();
puts("Enter execution style, valid types are sequential(s) or parallel(p):");
__isoc99_scanf();
v5 = strtok(s, ";");
}
while ( !v5 );
do
{
while ( 1 )
{
v6 = fork();
if ( v6 )
break;
if ( v5[(int)strlen(v5) - 1] == 38 )
{
v3 = strtok(v5, "&");
if ( v3 )
{
printf("Executing command in background %s\n", v5);
execlp(v3, "&", 0LL);
}
}
else
{
printf("Executing command %s\n", v5);
execlp(v5, v5, 0LL);
}
}
v4 = waitpid(v6, 0LL, 0);
printf("PID of terminated Child:%d\n", v4);
v5 = strtok(0LL, ";");
}
while ( v5 );
}
}

original_code:
int main(int argc, char *argv[]) {
 char commands[32];
 char style[32] = "sequential";
 pid_t pid;
 int rid;
 char *token;
 char *bgjob;
 signal(2, sig_int);
 signal(19, sig_stp);
 for(;;){
 printf("Enter command:\n");
 scanf("%s", commands);
 printf("Enter execution style, valid types are sequential(s) or parallel(p):\n");
 scanf("%s", style);
 if (style[0] == 's' || style[0] == 'S') {
  token = strtok(commands, ";");
  while (token != ((void *)0) ) {
   pid = fork();
   if (pid == 0) {
    int len = strlen(token);
    char last = token[len - 1];
    if (last == '&') {
     bgjob = strtok(token, "&");
     if (bgjob != ((void *)0) ) {
      printf("Executing command in background %s\n", token);
      execlp(bgjob, "&", ((void *)0) );
     }
    } else {
     printf("Executing command %s\n", token);
     execlp(token, token, ((void *)0) );
     }
    }
    else {
    rid = waitpid(pid, 0, 0);
    printf("PID of terminated Child:%d\n", rid);
    token = strtok(((void *)0), ";");
   }
  }
 }
 if (style[0] == 'p' || style[0] == 'P') {
  token = strtok(commands, ";");
  while (token != ((void *)0) ) {
   pid = fork();
   if (pid == 0) {
    int len = strlen(token);
    char last = token[len - 1];
    if (last == '&') {
     bgjob = strtok(token, "&");
     if (bgjob != ((void *)0) ) {
      printf("Executing command in background %s\n", token);
      execlp(bgjob, "&", ((void *)0) );
     }
    } else {
     printf("Executing command %s\n", token);
     execlp(token, token, ((void *)0) );
    }
   } else {
    token = strtok(((void *)0), ";");
   }
  }
     while ((rid = wait(((void *)0))) > 0)
     {
      printf("PID of terminated Child:%d\n", rid);
     }
 }
 }
}

canonical_original_code:
int main(int argc, char *argv[]) {
 char commands[32];
 char style[32] = "sequential";
 int pid;
 int rid;
 char *token;
 char *bgjob;
 signal(2, sig_int);
 signal(19, sig_stp);
 for(;;){
 printf("Enter command:\n");
 scanf("%s", commands);
 printf("Enter execution style, valid types are sequential(s) or parallel(p):\n");
 scanf("%s", style);
 if (style[0] == 's' || style[0] == 'S') {
  token = strtok(commands, ";");
  while (token != ((void *)0) ) {
   pid = fork();
   if (pid == 0) {
    int len = strlen(token);
    char last = token[len - 1];
    if (last == '&') {
     bgjob = strtok(token, "&");
     if (bgjob != ((void *)0) ) {
      printf("Executing command in background %s\n", token);
      execlp(bgjob, "&", ((void *)0) );
     }
    } else {
     printf("Executing command %s\n", token);
     execlp(token, token, ((void *)0) );
     }
    }
    else {
    rid = waitpid(pid, 0, 0);
    printf("PID of terminated Child:%d\n", rid);
    token = strtok(((void *)0), ";");
   }
  }
 }
 if (style[0] == 'p' || style[0] == 'P') {
  token = strtok(commands, ";");
  while (token != ((void *)0) ) {
   pid = fork();
   if (pid == 0) {
    int len = strlen(token);
    char last = token[len - 1];
    if (last == '&') {
     bgjob = strtok(token, "&");
     if (bgjob != ((void *)0) ) {
      printf("Executing command in background %s\n", token);
      execlp(bgjob, "&", ((void *)0) );
     }
    } else {
     printf("Executing command %s\n", token);
     execlp(token, token, ((void *)0) );
    }
   } else {
    token = strtok(((void *)0), ";");
   }
  }
     while ((rid = wait(((void *)0))) > 0)
     {
      printf("PID of terminated Child:%d\n", rid);
     }
 }
 }
}

variable_types:
commands
char [32]

variable_types:
style
char [32]

variable_types: pid int

variable_types: rid int

variable_types:
token
char *

variable_types:
bgjob
char *

variable_types: len int

variable_types: last char


decompiled_code:
int __fastcall str_echo(int fd)
{
char *v1; // rax
char *v2; // rax
size_t v3; // rax
char *v5; // rax
size_t v6; // rax
__pid_t v7; // ebp
unsigned int v8; // eax
__pid_t v9; // ebp
unsigned int v10; // er12
unsigned int v11; // eax
__pid_t v12; // er12
unsigned int v13; // eax
int fda; // [rsp+0h] [rbp-C68h] BYREF
int v15; // [rsp+4h] [rbp-C64h]
int pipedes[2]; // [rsp+8h] [rbp-C60h] BYREF
char *argv; // [rsp+10h] [rbp-C58h] BYREF
char *v18; // [rsp+18h] [rbp-C50h]
char *v19; // [rsp+20h] [rbp-C48h]
__int64 v20; // [rsp+28h] [rbp-C40h]
char src[8]; // [rsp+30h] [rbp-C38h] BYREF
char dest[256]; // [rsp+830h] [rbp-438h] BYREF
char v23[256]; // [rsp+930h] [rbp-338h] BYREF
char s[256]; // [rsp+A30h] [rbp-238h] BYREF
char v25[32]; // [rsp+B30h] [rbp-138h] BYREF
char buf[280]; // [rsp+B50h] [rbp-118h] BYREF

if ( (int)read(fd, buf, 0xFFuLL) < 0 )
printf("ERROR reading from socket");
printf("Received message from Client: %s\n", buf);
v1 = strtok(buf, " \t");
strcpy(dest, v1);
v2 = strtok(0LL, " \t");
strcpy(v25, v2);
if ( v25[0] == 78 )
{
v5 = strtok(0LL, " \t");
strcpy(s, v5);
v6 = strlen(s);
strncpy(v23, s, v6 - 1);
}
printf("query %s\n", dest);
printf("type %s\n", v25);
printf("filename %s\n", s);
if ( v25[0] == 78 )
{
pipe(pipedes);
v7 = fork();
if ( v7 )
{
close(pipedes[1]);
*(_QWORD *)&src[8 * (int)read(pipedes[0], src, 0x100uLL)] = 0LL;
v8 = waitpid(v7, 0LL, 0);
printf("Pid of terminated Child:%d\n", v8);
}
else
{
dup2(pipedes[1], 1);
close(pipedes[0]);
argv = "grep";
v18 = dest;
v19 = v23;
v20 = 0LL;
if ( execvp("grep", &argv) < 0 )
perror("execvp");
}
}
else if ( v25[0] == 89 )
{
pipe(&fda);
pipe(pipedes);
v9 = fork();
if ( v9 )
{
dup2(fda, 0);
close(v15);
v12 = fork();
if ( v12 )
{
close(pipedes[1]);
*(_QWORD *)&src[8 * (int)read(pipedes[0], src, 0x100uLL)] = 0LL;
v13 = waitpid(v12, 0LL, 0);
printf("Pid of terminated Child:%d\n", v13);
}
else
{
dup2(pipedes[1], 1);
close(pipedes[0]);
argv = "grep";
v18 = dest;
v19 = 0LL;
execvp("grep", &argv);
}
}
else
{
close(fda);
v10 = strlen(tempbuf);
printf("tempbuf len %d\n", v10);
write(v15, tempbuf, (int)v10);
}
v11 = waitpid(v9, 0LL, 0);
printf("Pid of terminated Child:%d\n", v11);
}
strcpy(tempbuf, src);
v3 = strlen(src);
if ( (int)write(fd, src, v3) < 0 )
perror("ERROR Received writing to socket");
return close(fd);
}

canonical_decompiled_code:
int __fastcall func9(int fd)
{
char *v1; // rax
char *v2; // rax
size_t v3; // rax
char *v5; // rax
size_t v6; // rax
__pid_t v7; // ebp
unsigned int v8; // eax
__pid_t v9; // ebp
unsigned int v10; // er12
unsigned int v11; // eax
__pid_t v12; // er12
unsigned int v13; // eax
int fda; // [rsp+0h] [rbp-C68h] BYREF
int v15; // [rsp+4h] [rbp-C64h]
int pipedes[2]; // [rsp+8h] [rbp-C60h] BYREF
char *argv; // [rsp+10h] [rbp-C58h] BYREF
char *v18; // [rsp+18h] [rbp-C50h]
char *v19; // [rsp+20h] [rbp-C48h]
__int64 v20; // [rsp+28h] [rbp-C40h]
char src[8]; // [rsp+30h] [rbp-C38h] BYREF
char dest[256]; // [rsp+830h] [rbp-438h] BYREF
char v23[256]; // [rsp+930h] [rbp-338h] BYREF
char s[256]; // [rsp+A30h] [rbp-238h] BYREF
char v25[32]; // [rsp+B30h] [rbp-138h] BYREF
char buf[280]; // [rsp+B50h] [rbp-118h] BYREF

if ( (int)read(fd, buf, 0xFFuLL) < 0 )
printf("ERROR reading from socket");
printf("Received message from Client: %s\n", buf);
v1 = strtok(buf, " \t");
strcpy(dest, v1);
v2 = strtok(0LL, " \t");
strcpy(v25, v2);
if ( v25[0] == 78 )
{
v5 = strtok(0LL, " \t");
strcpy(s, v5);
v6 = strlen(s);
strncpy(v23, s, v6 - 1);
}
printf("query %s\n", dest);
printf("type %s\n", v25);
printf("filename %s\n", s);
if ( v25[0] == 78 )
{
pipe(pipedes);
v7 = fork();
if ( v7 )
{
close(pipedes[1]);
*(_QWORD *)&src[8 * (int)read(pipedes[0], src, 0x100uLL)] = 0LL;
v8 = waitpid(v7, 0LL, 0);
printf("Pid of terminated Child:%d\n", v8);
}
else
{
dup2(pipedes[1], 1);
close(pipedes[0]);
argv = "grep";
v18 = dest;
v19 = v23;
v20 = 0LL;
if ( execvp("grep", &argv) < 0 )
perror("execvp");
}
}
else if ( v25[0] == 89 )
{
pipe(&fda);
pipe(pipedes);
v9 = fork();
if ( v9 )
{
dup2(fda, 0);
close(v15);
v12 = fork();
if ( v12 )
{
close(pipedes[1]);
*(_QWORD *)&src[8 * (int)read(pipedes[0], src, 0x100uLL)] = 0LL;
v13 = waitpid(v12, 0LL, 0);
printf("Pid of terminated Child:%d\n", v13);
}
else
{
dup2(pipedes[1], 1);
close(pipedes[0]);
argv = "grep";
v18 = dest;
v19 = 0LL;
execvp("grep", &argv);
}
}
else
{
close(fda);
v10 = strlen(tempbuf);
printf("tempbuf len %d\n", v10);
write(v15, tempbuf, (int)v10);
}
v11 = waitpid(v9, 0LL, 0);
printf("Pid of terminated Child:%d\n", v11);
}
strcpy(tempbuf, src);
v3 = strlen(src);
if ( (int)write(fd, src, v3) < 0 )
perror("ERROR Received writing to socket");
return close(fd);
}

original_code:
void str_echo(void *arg) {
 char buff[256], *ptr;
 int n;
 n = read(arg, buff, 255);
 if (n < 0)
  printf("ERROR reading from socket");
  printf("Received  message from Client: %s\n", buff);
  char type[32];
  char *filename[32];
  char *fi[32];
  char *query[32];
  strcpy(query, strtok(buff , " \t"));
  strcpy(type, strtok(((void *)0), " \t"));
  if(type[0]=='N'){
   strcpy(filename , strtok(((void *)0), " \t"));
   strncpy(fi, filename, (strlen(filename)-1));
   }
  printf("query %s\n",query);
  printf("type %s\n",type);
  printf("filename %s\n",filename);
  char* buf[256];
  if(type[0]=='N'){
   int fd[2], pid,retval,rid;
   int n;
       pipe(fd);
    pid=fork();
           if (pid==0) {
               dup2(fd[1],1);
               close(fd[0]);
               char *argv[] = { "grep", query, fi, ((void *)0)};
               if(execvp("grep", argv)<0){
               perror("execvp");
               }
           }
    else
      { close(fd[1]);
            n = read(fd[0], buf, 256);
            buf[n] = '\0';
            rid=waitpid(pid, 0, 0);
            printf("Pid of terminated Child:%d\n",rid);
      }
  }
  else if(type[0]=='Y'){
   int pfd[2], cpid,rid;
   int fd[2],cppid,rrid;
       pipe(pfd);
    pipe(fd);
       cpid=fork();
           if (cpid==0) {
               close(pfd[0]);
               int len = strlen(tempbuf);
               printf("tempbuf len %d\n",len);
               write(pfd[1],tempbuf,len);
               }
           else
           {
              dup2(pfd[0],0);
             close(pfd[1]);
             cppid = fork();
             if(cppid==0){
                  dup2(fd[1],1);
               close(fd[0]);
               char *argv[] = { "grep", query, ((void *)0)};
               execvp("grep", argv);
             }else{
              close(fd[1]);
              n = read(fd[0], buf, 256);
                    buf[n] = '\0';
                    rrid=waitpid(cppid, 0, 0);
                    printf("Pid of terminated Child:%d\n",rrid);
             }
            }
    rid=waitpid(cpid, 0, 0);
    printf("Pid of terminated Child:%d\n",rid);
  }
 strcpy(tempbuf, buf);
 n = write(arg, buf, strlen(buf));
 if (n < 0)
  perror("ERROR Received writing to socket");
 close(arg);
}

canonical_original_code:
void str_echo(void *arg) {
 char buff[256]; char *ptr;
 int n;
 n = read(arg, buff, 255);
 if (n < 0)
  printf("ERROR reading from socket");
  printf("Received  message from Client: %s\n", buff);
  char type[32];
  char *filename[32];
  char *fi[32];
  char *query[32];
  strcpy(query, strtok(buff , " \t"));
  strcpy(type, strtok(((void *)0), " \t"));
  if(type[0]=='N'){
   strcpy(filename , strtok(((void *)0), " \t"));
   strncpy(fi, filename, (strlen(filename)-1));
   }
  printf("query %s\n",query);
  printf("type %s\n",type);
  printf("filename %s\n",filename);
  char *buf[256];
  if(type[0]=='N'){
   int fd[2]; int pid; int retval; int rid;
   int n;
       pipe(fd);
    pid=fork();
           if (pid==0) {
               dup2(fd[1],1);
               close(fd[0]);
               char *argv[] = { "grep", query, fi, ((void *)0)};
               if(execvp("grep", argv)<0){
               perror("execvp");
               }
           }
    else
      { close(fd[1]);
            n = read(fd[0], buf, 256);
            buf[n] = '\0';
            rid=waitpid(pid, 0, 0);
            printf("Pid of terminated Child:%d\n",rid);
      }
  }
  else if(type[0]=='Y'){
   int pfd[2]; int cpid; int rid;
   int fd[2]; int cppid; int rrid;
       pipe(pfd);
    pipe(fd);
       cpid=fork();
           if (cpid==0) {
               close(pfd[0]);
               int len = strlen(tempbuf);
               printf("tempbuf len %d\n",len);
               write(pfd[1],tempbuf,len);
               }
           else
           {
              dup2(pfd[0],0);
             close(pfd[1]);
             cppid = fork();
             if(cppid==0){
                  dup2(fd[1],1);
               close(fd[0]);
               char *argv[] = { "grep", query, ((void *)0)};
               execvp("grep", argv);
             }else{
              close(fd[1]);
              n = read(fd[0], buf, 256);
                    buf[n] = '\0';
                    rrid=waitpid(cppid, 0, 0);
                    printf("Pid of terminated Child:%d\n",rrid);
             }
            }
    rid=waitpid(cpid, 0, 0);
    printf("Pid of terminated Child:%d\n",rid);
  }
 strcpy(tempbuf, buf);
 n = write(arg, buf, strlen(buf));
 if (n < 0)
  perror("ERROR Received writing to socket");
 close(arg);
}

variable_types:
arg
void *

variable_types:
ptr
char *

variable_types:
type
char [32]

variable_types:
filename
char *[32]

variable_types:
fi
char *[32]

variable_types:
query
char *[32]

variable_types:
buf
char *[256]

variable_types:
fd
int [2]

variable_types: retval int

variable_types:
pfd
int [2]

variable_types: cpid int

variable_types: cppid int

variable_types: rrid int


doit

decompiled_code:
void *__fastcall doit(void *a1)
{
pthread_t v1; // rax

v1 = pthread_self();
pthread_detach(v1);
str_echo((int)a1);
close((int)a1);
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func10(void *a1)
{
pthread_t v1; // rax

v1 = pthread_self();
pthread_detach(v1);
func9((int)a1);
close((int)a1);
return 0LL;
}

original_code:
static void *
  doit(void *arg) {
   pthread_detach(pthread_self());
   str_echo((int) arg);
   close((int) arg);
   return (((void *)0) );
}

canonical_original_code:
static void *doit(void *arg) {
   pthread_detach(pthread_self());
   str_echo((int) arg);
   close((int) arg);
   return (((void *)0) );
}

return_type: void *


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
__int16 v4; // bx
int v5; // ebx
pthread_t newthread; // [rsp+8h] [rbp-50h] BYREF
struct sockaddr v7; // [rsp+10h] [rbp-48h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-38h] BYREF
socklen_t addr_len[7]; // [rsp+3Ch] [rbp-1Ch] BYREF

if ( argc <= 1 )
fwrite("ERROR, no port provided\n", 1uLL, 0x18uLL, stderr);
v3 = socket(2, 1, 0);
if ( v3 < 0 )
perror("ERROR opening socket");
*(_QWORD *)&addr.sa_family = 0LL;
*(_QWORD *)&addr.sa_data[6] = 0LL;
v4 = atoi(argv[1]);
addr.sa_family = 2;
*(_QWORD *)&addr.sa_data[2] = (unsigned int)_bswap_32(0);
*(_WORD *)addr.sa_data = _bswap_16(v4);
if ( bind(v3, &addr, 0x10u) >= 0 )
{
listen(v3, 5);
while ( 1 )
{
addr_len[0] = 16;
v5 = accept(v3, &v7, addr_len);
if ( v5 < 0 )
perror("ERROR on accept");
pthread_create(&newthread, 0LL, doit, (void *)v5);
}
}
perror("ERROR on binding");
exit(0);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
__int16 v4; // bx
int v5; // ebx
pthread_t newthread; // [rsp+8h] [rbp-50h] BYREF
struct sockaddr v7; // [rsp+10h] [rbp-48h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-38h] BYREF
socklen_t addr_len[7]; // [rsp+3Ch] [rbp-1Ch] BYREF

if ( argc <= 1 )
fwrite("ERROR, no port provided\n", 1uLL, 0x18uLL, stderr);
v3 = socket(2, 1, 0);
if ( v3 < 0 )
perror("ERROR opening socket");
*(_QWORD *)&addr.sa_family = 0LL;
*(_QWORD *)&addr.sa_data[6] = 0LL;
v4 = atoi(argv[1]);
addr.sa_family = 2;
*(_QWORD *)&addr.sa_data[2] = (unsigned int)func7(0);
*(_WORD *)addr.sa_data = func8(v4);
if ( bind(v3, &addr, 0x10u) >= 0 )
{
listen(v3, 5);
while ( 1 )
{
addr_len[0] = 16;
v5 = accept(v3, &v7, addr_len);
if ( v5 < 0 )
perror("ERROR on accept");
pthread_create(&newthread, 0LL, doit, (void *)v5);
}
}
perror("ERROR on binding");
exit(0);
}

original_code:
int main(int argc, char *argv[]) {
 int sockfd, newsockfd, portno, clilen;
 char buff[256], *ptr;
 struct sockaddr_in serv_addr, cli_addr;
 pthread_t tid;
 int n;
 const int on = 1;
 if (argc < 2) {
  fprintf(stderr, "ERROR, no port provided\n");
 }
 sockfd = socket(2, SOCK_STREAM, 0);
 if (sockfd < 0)
  perror("ERROR opening socket");
 bzero((char *) &serv_addr, sizeof(serv_addr));
 portno = atoi(argv[1]);
 serv_addr.sin_family = 2;
 serv_addr.sin_addr.s_addr = htonl(((in_addr_t) 0x00000000));
 serv_addr.sin_port = htons(portno);
 if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
  perror("ERROR on binding");
  exit(0);
 }
 listen(sockfd, 5);
 for (;;) {
  clilen = sizeof(cli_addr);
  newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  if (newsockfd < 0)
   perror("ERROR on accept");
  pthread_create(&tid, ((void *)0), doit, (void *) newsockfd);
  }
 }

canonical_original_code:
int main(int argc, char *argv[]) {
 int sockfd; int newsockfd; int portno; int clilen;
 char buff[256]; char *ptr;
 struct sockaddr_in serv_addr; struct sockaddr_in cli_addr;
 unsigned long tid;
 int n;
 int on = 1;
 if (argc < 2) {
  fprintf(stderr, "ERROR, no port provided\n");
 }
 sockfd = socket(2, SOCK_STREAM, 0);
 if (sockfd < 0)
  perror("ERROR opening socket");
 bzero((char *) &serv_addr, sizeof(serv_addr));
 portno = atoi(argv[1]);
 serv_addr.sin_family = 2;
 serv_addr.sin_addr.s_addr = htonl(((unsigned int) 0x00000000));
 serv_addr.sin_port = htons(portno);
 if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
  perror("ERROR on binding");
  exit(0);
 }
 listen(sockfd, 5);
 for (;;) {
  clilen = sizeof(cli_addr);
  newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  if (newsockfd < 0)
   perror("ERROR on accept");
  pthread_create(&tid, ((void *)0), doit, (void *) newsockfd);
  }
 }

variable_types: argc int

variable_types:
argv
char *[]

variable_types: sockfd int

variable_types: newsockfd int

variable_types: portno int

variable_types: clilen int

variable_types:
buff
char [256]

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

variable_types:
tid
unsigned long

variable_types: n int

variable_types: on int


repo: sambeau/burp

decompiled_code:
__int64 bz_real_length()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 1LL;
}

original_code:
size_t bz_real_length(bz_Real* r)
{
  return 1;
}

canonical_original_code:
unsigned long bz_real_length(struct bz_Real *r)
{
  return 1;
}

variable_types: struct bz_Real { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; double value; } *

return_type: unsigned long

user_defined_types: struct bz_Real { struct bz_Type *type; double value; }


decompiled_code:
double *__fastcall bz_real_new(double a1)
{
double *v1; // rbx

bz_barf_push_function("bz_real_new");
v1 = (double *)malloc(0x10uLL);
if ( !v1 )
bz_barf("Out of Memory");
*(_QWORD *)v1 = &bz_real_type;
v1[1] = a1;
bz_barf_pop_function();
return v1;
}

canonical_decompiled_code:
double *__fastcall func1(double a1)
{
double *v1; // rbx

bz_barf_push_function("bz_real_new");
v1 = (double *)malloc(0x10uLL);
if ( !v1 )
bz_barf("Out of Memory");
*(_QWORD *)v1 = &bz_real_type;
v1[1] = a1;
bz_barf_pop_function();
return v1;
}

original_code:
bz_Real* bz_real_new(double r)
{
   bz_Real* R;
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   R = malloc(sizeof(bz_Real));
   if(R == ((void *)0))
      bz_barf("Out of Memory");
   R->type = &bz_real_type;
   R->value = r;
   {;bz_barf_pop_function();return (R);};
}

canonical_original_code:
struct bz_Real *bz_real_new(double r)
{
   struct bz_Real *R;
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   R = malloc(sizeof(bz_Real));
   if(R == ((void *)0))
      bz_barf("Out of Memory");
   R->type = &bz_real_type;
   R->value = r;
   {;bz_barf_pop_function();return (R);};
}

variable_types: r double

return_type: struct bz_Real { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; double value; } *


decompiled_code:
__int64 __fastcall bz_real_compare(__int64 a1, __int64 a2)
{
double v2; // xmm0_8
__int64 result; // rax

bz_barf_push_function("bz_real_compare");
v2 = *(double *)(a1 + 8) - *(double *)(a2 + 8);
if ( v2 > 0.0 )
{
bz_barf_pop_function();
result = 1LL;
}
else
{
bz_barf_pop_function();
if ( v2 < 0.0 )
result = 0xFFFFFFFFLL;
else
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
double v2; // xmm0_8
__int64 result; // rax

bz_barf_push_function("bz_real_compare");
v2 = *(double *)(a1 + 8) - *(double *)(a2 + 8);
if ( v2 > 0.0 )
{
bz_barf_pop_function();
result = 1LL;
}
else
{
bz_barf_pop_function();
if ( v2 < 0.0 )
result = 0xFFFFFFFFLL;
else
result = 0LL;
}
return result;
}

original_code:
int bz_real_compare(bz_Real* x, bz_Real* y)
{
  double r;
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  r = x->value - y->value;
  if (r > 0) {;bz_barf_pop_function();return (1);};
  if (r < 0) {;bz_barf_pop_function();return (-1);};
                  {;bz_barf_pop_function();return (0);};
}

canonical_original_code:
int bz_real_compare(struct bz_Real *x, struct bz_Real *y)
{
  double r;
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  r = x->value - y->value;
  if (r > 0) {;bz_barf_pop_function();return (1);};
  if (r < 0) {;bz_barf_pop_function();return (-1);};
                  {;bz_barf_pop_function();return (0);};
}

variable_types:
y
struct bz_Real *

user_defined_types: struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); }


original_code:
size_t bz_real_charsize(bz_Real* r)
{
  double rv = r->value;
  if (rv == 0.0)
    return 6 + 2;
  int x = (int)trunc(abs(rv));
  if (x == 0)
    return 6 + 2 + (rv < 0.0 ? 1 : 0);
  else
    return ((int)floor( log10( x ) ) + 6 + 2 + (rv < 0.0 ? 1 : 0));
}

canonical_original_code:
unsigned long bz_real_charsize(struct bz_Real *r)
{
  double rv = r->value;
  if (rv == 0.0)
    return 6 + 2;
  int x = (int)trunc(abs(rv));
  if (x == 0)
    return 6 + 2 + (rv < 0.0 ? 1 : 0);
  else
    return ((int)floor( log10( x ) ) + 6 + 2 + (rv < 0.0 ? 1 : 0));
}

variable_types: rv double

variable_types: x int


decompiled_code:
int bz_real_show()
{
struct _IO_FILE *v0; // rbx
const wchar_t *v1; // rax

v0 = stdout;
v1 = (const wchar_t *)bz_real_to_wstr();
return fputws(v1, v0);
}

canonical_decompiled_code:
int func4()
{
struct _IO_FILE *v0; // rbx
const wchar_t *v1; // rax

v0 = stdout;
v1 = (const wchar_t *)bz_real_to_wstr();
return fputws(v1, v0);
}

original_code:
void bz_real_show(bz_Real* r)
{
  fputws(bz_real_to_wstr(r),stdout);
}

canonical_original_code:
void bz_real_show(struct bz_Real *r)
{
  fputws(bz_real_to_wstr(r),stdout);
}


decompiled_code:
__int64 __fastcall bz_integer_to_integer(__int64 a1)
{
bz_barf_push_function("bz_integer_to_integer");
bz_barf_pop_function();
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
bz_barf_push_function("bz_integer_to_integer");
bz_barf_pop_function();
return a1;
}

original_code:
bz_Integer* bz_integer_to_integer(bz_Integer* I)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (I);};
}

canonical_original_code:
struct bz_Integer *bz_integer_to_integer(struct bz_Integer *I)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (I);};
}

variable_types:
I
struct bz_Integer *

return_type: struct bz_Integer { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; long long value; } *

user_defined_types: struct bz_Integer { struct bz_Type *type; long long value; }


decompiled_code:
__int64 __fastcall bz_integer_to_real(__int64 a1)
{
bz_barf_push_function("bz_integer_to_real");
bz_barf_pop_function();
return bz_real_new((double)(int)*(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
bz_barf_push_function("bz_integer_to_real");
bz_barf_pop_function();
return bz_real_new((double)(int)*(_QWORD *)(a1 + 8));
}

original_code:
bz_Real* bz_integer_to_real(bz_Integer* I)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (bz_real_new((double) I->value));};
}

canonical_original_code:
struct bz_Real *bz_integer_to_real(struct bz_Integer *I)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (bz_real_new((double) I->value));};
}

variable_types: struct bz_Integer { struct bz_Type *type; long long value; } *


decompiled_code:
__int64 __fastcall bz_integer_to_list(__int64 a1)
{
bz_barf_push_function("bz_integer_to_list");
bz_barf_pop_function();
return bz_list_cons(&bz_Empty_value, a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
bz_barf_push_function("bz_integer_to_list");
bz_barf_pop_function();
return bz_list_cons(&bz_Empty_value, a1);
}

original_code:
bz_List* bz_integer_to_list(bz_Integer* I)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (bz_list_cons(((void *)&bz_Empty_value),I));};
}

canonical_original_code:
struct bz_list_node *bz_integer_to_list(struct bz_Integer *I)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (bz_list_cons(((void *)&bz_Empty_value),I));};
}

return_type: struct bz_list_node { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; void *node; struct bz_list_node *next; } *

user_defined_types: struct bz_list_node { struct bz_Type *type; void *node; struct bz_list_node *next; }


decompiled_code:
__int64 __fastcall bz_integer_to_string(__int64 a1)
{
wchar_t *v1; // rax

bz_barf_push_function("bz_integer_to_string");
bz_barf_pop_function();
v1 = bz_integer_to_wstr(a1);
return bz_string_new(v1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
wchar_t *v1; // rax

bz_barf_push_function("bz_integer_to_string");
bz_barf_pop_function();
v1 = bz_integer_to_wstr(a1);
return bz_string_new(v1);
}

original_code:
bz_String* bz_integer_to_string(bz_Integer* I)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (bz_string_new(bz_integer_to_wstr(I)));};
}

canonical_original_code:
struct bz_String *bz_integer_to_string(struct bz_Integer *I)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (bz_string_new(bz_integer_to_wstr(I)));};
}

return_type: struct bz_String { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; unsigned long buffer_size; unsigned long length; int *string; } *

user_defined_types: struct bz_String { struct bz_Type *type; unsigned long buffer_size; unsigned long length; int *string; }


decompiled_code:
__int64 __fastcall bz_real_to_integer(__int64 a1)
{
bz_barf_push_function("bz_real_to_integer");
bz_barf_pop_function();
return bz_integer_new((unsigned int)(int)*(double *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
bz_barf_push_function("bz_real_to_integer");
bz_barf_pop_function();
return bz_integer_new((unsigned int)(int)*(double *)(a1 + 8));
}

original_code:
bz_Integer* bz_real_to_integer(bz_Real* r)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (bz_integer_new((long long)r->value));};
}

canonical_original_code:
struct bz_Integer *bz_real_to_integer(struct bz_Real *r)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (bz_integer_new((long long)r->value));};
}

variable_types: struct bz_Real { struct bz_Type *type; double value; } *


decompiled_code:
__int64 __fastcall bz_real_to_real(__int64 a1)
{
bz_barf_push_function("bz_real_to_real");
bz_barf_pop_function();
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
bz_barf_push_function("bz_real_to_real");
bz_barf_pop_function();
return a1;
}

original_code:
bz_Real* bz_real_to_real(bz_Real* r)
{
    {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (r);};
}

canonical_original_code:
struct bz_Real *bz_real_to_real(struct bz_Real *r)
{
    {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (r);};
}

variable_types:
r
struct bz_Real *


decompiled_code:
__int64 __fastcall bz_real_to_list(__int64 a1)
{
bz_barf_push_function("bz_real_to_list");
bz_barf_pop_function();
return bz_list_cons(&bz_Empty_value, a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
bz_barf_push_function("bz_real_to_list");
bz_barf_pop_function();
return bz_list_cons(&bz_Empty_value, a1);
}

original_code:
bz_List* bz_real_to_list(bz_Real* r)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (bz_list_cons(((void *)&bz_Empty_value),r));};
}

canonical_original_code:
struct bz_list_node *bz_real_to_list(struct bz_Real *r)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (bz_list_cons(((void *)&bz_Empty_value),r));};
}


decompiled_code:
__int64 __fastcall bz_real_to_string(__int64 a1)
{
wchar_t *v1; // rax

bz_barf_push_function("bz_real_to_string");
bz_barf_pop_function();
v1 = bz_real_to_wstr(a1);
return bz_string_new(v1);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
wchar_t *v1; // rax

bz_barf_push_function("bz_real_to_string");
bz_barf_pop_function();
v1 = bz_real_to_wstr(a1);
return bz_string_new(v1);
}

original_code:
bz_String* bz_real_to_string(bz_Real* r)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (bz_string_new(bz_real_to_wstr(r)));};
}

canonical_original_code:
struct bz_String *bz_real_to_string(struct bz_Real *r)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (bz_string_new(bz_real_to_wstr(r)));};
}


decompiled_code:
__int64 __fastcall bz_string_to_integer(__int64 a1)
{
int *v1; // rbx
__int64 v2; // rdi
__int64 v3; // rbp
wchar_t *endptr; // [rsp+8h] [rbp-20h] BYREF

bz_barf_push_function("bz_string_to_integer");
v1 = _errno_location();
*v1 = 0;
v2 = wcstol(*(const wchar_t **)(a1 + 24), &endptr, 0);
v3 = bz_integer_new(v2);
if ( *v1 )
bz_barf("bz_Integer too long");
bz_barf_pop_function();
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
int *v1; // rbx
__int64 v2; // rdi
__int64 v3; // rbp
wchar_t *endptr; // [rsp+8h] [rbp-20h] BYREF

bz_barf_push_function("bz_string_to_integer");
v1 = _errno_location();
*v1 = 0;
v2 = wcstol(*(const wchar_t **)(a1 + 24), &endptr, 0);
v3 = bz_integer_new(v2);
if ( *v1 )
bz_barf("bz_Integer too long");
bz_barf_pop_function();
return v3;
}

original_code:
bz_Integer* bz_string_to_integer(bz_String* s)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  wchar_t *error;
  (*__errno_location ()) = 0;
  bz_Integer* I = bz_integer_new(wcstol(s->string, &error , 0));
  if((*__errno_location ())){
    bz_barf("bz_Integer too long");
  }
  {;bz_barf_pop_function();return (I);};
}

canonical_original_code:
struct bz_Integer *bz_string_to_integer(struct bz_String *s)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  int *error;
  (*__errno_location ()) = 0;
  struct bz_Integer *I = bz_integer_new(wcstol(s->string, &error , 0));
  if((*__errno_location ())){
    bz_barf("bz_Integer too long");
  }
  {;bz_barf_pop_function();return (I);};
}

variable_types: struct bz_String { struct bz_Type *type; unsigned long buffer_size; unsigned long length; int *string; } *

variable_types:
error
int *

variable_types: struct bz_Integer { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; long long value; } *


decompiled_code:
__int64 __fastcall bz_string_to_real(__int64 a1)
{
int *v1; // rbx
double v2; // xmm0_8
__int64 v3; // rbp
wchar_t *endptr; // [rsp+8h] [rbp-20h] BYREF

bz_barf_push_function("bz_string_to_real");
v1 = _errno_location();
*v1 = 0;
v2 = wcstod(*(const wchar_t **)(a1 + 24), &endptr);
v3 = bz_real_new(v2);
if ( *v1 )
bz_barf("bz_Real too long");
bz_barf_pop_function();
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
int *v1; // rbx
double v2; // xmm0_8
__int64 v3; // rbp
wchar_t *endptr; // [rsp+8h] [rbp-20h] BYREF

bz_barf_push_function("bz_string_to_real");
v1 = _errno_location();
*v1 = 0;
v2 = wcstod(*(const wchar_t **)(a1 + 24), &endptr);
v3 = bz_real_new(v2);
if ( *v1 )
bz_barf("bz_Real too long");
bz_barf_pop_function();
return v3;
}

original_code:
bz_Real* bz_string_to_real(bz_String* s)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  wchar_t *error;
  (*__errno_location ()) = 0;
  bz_Real* R = bz_real_new(wcstod(s->string,&error));
  if((*__errno_location ())) {
    bz_barf("bz_Real too long");
  }
  {;bz_barf_pop_function();return (R);};
}

canonical_original_code:
struct bz_Real *bz_string_to_real(struct bz_String *s)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  int *error;
  (*__errno_location ()) = 0;
  struct bz_Real *R = bz_real_new(wcstod(s->string,&error));
  if((*__errno_location ())) {
    bz_barf("bz_Real too long");
  }
  {;bz_barf_pop_function();return (R);};
}


decompiled_code:
__int64 __fastcall bz_string_to_string(__int64 a1)
{
bz_barf_push_function("bz_string_to_string");
bz_barf_pop_function();
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
bz_barf_push_function("bz_string_to_string");
bz_barf_pop_function();
return a1;
}

original_code:
bz_String* bz_string_to_string(bz_String* s)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (s);};
}

canonical_original_code:
struct bz_String *bz_string_to_string(struct bz_String *s)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (s);};
}

variable_types:
s
struct bz_String *


decompiled_code:
__int64 __fastcall bz_string_to_list(__int64 a1)
{
bz_barf_push_function("bz_string_to_list");
bz_barf_pop_function();
return bz_list_cons(&bz_Empty_value, a1);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
bz_barf_push_function("bz_string_to_list");
bz_barf_pop_function();
return bz_list_cons(&bz_Empty_value, a1);
}

original_code:
bz_List* bz_string_to_list(bz_String* s)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (bz_list_cons(((void *)&bz_Empty_value),s));};
}

canonical_original_code:
struct bz_list_node *bz_string_to_list(struct bz_String *s)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (bz_list_cons(((void *)&bz_Empty_value),s));};
}


decompiled_code:
__int64 __fastcall bz_string_to_wstr(__int64 a1)
{
bz_barf_push_function("bz_string_to_wstr");
bz_barf_pop_function();
return *(_QWORD *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
bz_barf_push_function("bz_string_to_wstr");
bz_barf_pop_function();
return *(_QWORD *)(a1 + 24);
}

original_code:
wchar_t* bz_string_to_wstr(bz_String* e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (e->string);};
}

canonical_original_code:
int *bz_string_to_wstr(struct bz_String *e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (e->string);};
}

variable_types: struct bz_String { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; unsigned long buffer_size; unsigned long length; int *string; } *

return_type: int *


decompiled_code:
__int64 bz_empty_to_integer()
{
bz_barf_push_function("bz_empty_to_integer");
bz_barf_pop_function();
return bz_integer_new(0LL);
}

canonical_decompiled_code:
__int64 func13()
{
bz_barf_push_function("bz_empty_to_integer");
bz_barf_pop_function();
return bz_integer_new(0LL);
}

original_code:
bz_Integer* bz_empty_to_integer(bz_Empty* e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (bz_integer_new(0));};
}

canonical_original_code:
struct bz_Integer *bz_empty_to_integer(struct bz_Empty *e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (bz_integer_new(0));};
}

variable_types: struct bz_Empty { struct bz_Type *type; } *


decompiled_code:
__int64 bz_empty_to_real()
{
bz_barf_push_function("bz_empty_to_real");
bz_barf_pop_function();
return bz_real_new(0.0);
}

canonical_decompiled_code:
__int64 func14()
{
bz_barf_push_function("bz_empty_to_real");
bz_barf_pop_function();
return bz_real_new(0.0);
}

original_code:
bz_Real* bz_empty_to_real(bz_Empty* e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (bz_real_new((double)0.0));};
}

canonical_original_code:
struct bz_Real *bz_empty_to_real(struct bz_Empty *e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (bz_real_new((double)0.0));};
}

user_defined_types: struct bz_Empty { struct bz_Type *type; }


decompiled_code:
__int64 bz_empty_to_string()
{
return bz_string_new(&unk_698);
}

canonical_decompiled_code:
__int64 func15()
{
return bz_string_new(&unk_698);
}

original_code:
bz_String* bz_empty_to_string(bz_Empty* e)
{
  return bz_string_new(L"");
}

canonical_original_code:
struct bz_String *bz_empty_to_string(struct bz_Empty *e)
{
  return bz_string_new(L"");
}


decompiled_code:
void *bz_empty_to_wstr()
{
return &unk_698;
}

canonical_decompiled_code:
void *func16()
{
return &unk_698;
}

original_code:
wchar_t* bz_empty_to_wstr(bz_Empty* e)
{
  return L"";
}

canonical_original_code:
int *bz_empty_to_wstr(struct bz_Empty *e)
{
  return L"";
}

variable_types: struct bz_Empty { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; } *


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

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

original_code:
bz_List* bz_empty_to_list(bz_Empty* e)
{
  return (bz_List*)e;
}

canonical_original_code:
struct bz_list_node *bz_empty_to_list(struct bz_Empty *e)
{
  return (struct bz_list_node *)e;
}


decompiled_code:
char *__fastcall wstr_to_cstr(wchar_t *pwcs)
{
size_t v1; // r12
char *v3; // rdi

bz_barf_push_function("wstr_to_cstr");
v1 = wcstombs(0LL, pwcs, 0LL);
v3 = (char *)malloc(v1 + 1);
v3[wcstombs(v3, pwcs, v1)] = 0;
bz_barf_pop_function();
return v3;
}

canonical_decompiled_code:
char *__fastcall func18(wchar_t *pwcs)
{
size_t v1; // r12
char *v3; // rdi

bz_barf_push_function("wstr_to_cstr");
v1 = wcstombs(0LL, pwcs, 0LL);
v3 = (char *)malloc(v1 + 1);
v3[wcstombs(v3, pwcs, v1)] = 0;
bz_barf_pop_function();
return v3;
}

original_code:
char* wstr_to_cstr(wchar_t* bz_string_to_wstr)
{
  char *cstr;
  size_t cstrlength;
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  cstrlength = wcstombs(((void *)0),bz_string_to_wstr,0);
 cstr = malloc(sizeof(char)*(cstrlength + 1));
 cstrlength = wcstombs(cstr, bz_string_to_wstr, cstrlength);
 if (cstrlength < 0){
  bz_barf("Unreadable string");
 }
 cstr[cstrlength]='\0';
   {;bz_barf_pop_function();return (cstr);};
}

canonical_original_code:
char *wstr_to_cstr(int *bz_string_to_wstr)
{
  char *cstr;
  unsigned long cstrlength;
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  cstrlength = wcstombs(((void *)0),bz_string_to_wstr,0);
 cstr = malloc(sizeof(char)*(cstrlength + 1));
 cstrlength = wcstombs(cstr, bz_string_to_wstr, cstrlength);
 if (cstrlength < 0){
  bz_barf("Unreadable string");
 }
 cstr[cstrlength]='\0';
   {;bz_barf_pop_function();return (cstr);};
}

variable_types:
cstr
char *

variable_types:
cstrlength
unsigned long


decompiled_code:
__int64 __fastcall bz_list_to_integer(__int64 a1)
{
bz_barf_push_function("bz_list_to_integer");
bz_barf_pop_function();
return (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 8) + 56LL))(*(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1)
{
bz_barf_push_function("bz_list_to_integer");
bz_barf_pop_function();
return (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 8) + 56LL))(*(_QWORD *)(a1 + 8));
}

original_code:
bz_Integer* bz_list_to_integer(bz_List* e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return ((bz_Integer *) (void *)((bz_Type *)((bz_node *)e->node)->type)->to_integer(e->node));};
}

canonical_original_code:
struct bz_Integer *bz_list_to_integer(struct bz_list_node *e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return ((struct bz_Integer *) (void *)((struct bz_Type *)((struct bz_node *)e->node)->type)->to_integer(e->node));};
}

variable_types: struct bz_list_node { struct bz_Type *type; void *node; struct bz_list_node *next; } *

user_defined_types: struct bz_node { struct bz_Type *type; }


decompiled_code:
__int64 __fastcall bz_list_to_real(__int64 a1)
{
__int64 v1; // rax

bz_barf_push_function("bz_list_to_real");
bz_barf_pop_function();
v1 = bz_list_to_integer(a1);
return bz_integer_to_real(v1);
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1)
{
__int64 v1; // rax

bz_barf_push_function("bz_list_to_real");
bz_barf_pop_function();
v1 = func19(a1);
return func1(v1);
}

original_code:
bz_Real* bz_list_to_real(bz_List* e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (bz_integer_to_real(bz_list_to_integer(e)));};
}

canonical_original_code:
struct bz_Real *bz_list_to_real(struct bz_list_node *e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;}; {;bz_barf_pop_function();return (bz_integer_to_real(bz_list_to_integer(e)));};
}


decompiled_code:
__int64 __fastcall bz_list_to_string(__int64 a1)
{
__int64 v1; // rbx
__int64 i; // rbp
__int64 v3; // rax

bz_barf_push_function("bz_list_to_string");
v1 = bz_list_flatten(a1);
for ( i = bz_string_new(0LL); (_UNKNOWN *)v1 != &bz_Empty_value && v1; v1 = *(_QWORD *)(v1 + 16) )
{
v3 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(v1 + 8) + 72LL))(*(_QWORD *)(v1 + 8));
i = bz_string_cat(i, v3, 0LL);
}
bz_barf_pop_function();
return i;
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1)
{
__int64 v1; // rbx
__int64 i; // rbp
__int64 v3; // rax

bz_barf_push_function("bz_list_to_string");
v1 = bz_list_flatten(a1);
for ( i = bz_string_new(0LL); (_UNKNOWN *)v1 != &bz_Empty_value && v1; v1 = *(_QWORD *)(v1 + 16) )
{
v3 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(v1 + 8) + 72LL))(*(_QWORD *)(v1 + 8));
i = bz_string_cat(i, v3, 0LL);
}
bz_barf_pop_function();
return i;
}

original_code:
bz_String* bz_list_to_string(bz_List* e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  bz_List* e1 = bz_list_flatten(e);
  bz_String* s = bz_string_new(((void *)0));
  while (e1 && e1 != ((void *)&bz_Empty_value)) {
    s = _bz_string_cat(s, (void *)((bz_Type *)((bz_node *)e1->node)->type)->to_string(e1->node), ((void *)0));
    e1 = e1->next;
  }
  {;bz_barf_pop_function();return (s);};
}

canonical_original_code:
struct bz_String *bz_list_to_string(struct bz_list_node *e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  struct bz_list_node *e1 = bz_list_flatten(e);
  struct bz_String *s = bz_string_new(((void *)0));
  while (e1 && e1 != ((void *)&bz_Empty_value)) {
    s = _bz_string_cat(s, (void *)((struct bz_Type *)((struct bz_node *)e1->node)->type)->to_string(e1->node), ((void *)0));
    e1 = e1->next;
  }
  {;bz_barf_pop_function();return (s);};
}

variable_types: struct bz_list_node { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; void *node; struct bz_list_node *next; } *


decompiled_code:
__int64 __fastcall bz_list_to_wstr(__int64 a1)
{
__int64 v1; // rbx

bz_barf_push_function("bz_list_to_wstr");
v1 = bz_list_to_string(a1);
bz_barf_pop_function();
return *(_QWORD *)(v1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1)
{
__int64 v1; // rbx

bz_barf_push_function("bz_list_to_wstr");
v1 = func21(a1);
bz_barf_pop_function();
return *(_QWORD *)(v1 + 24);
}

original_code:
wchar_t* bz_list_to_wstr(bz_List* e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  bz_String*s = bz_list_to_string(e);
  {;bz_barf_pop_function();return (s->string);};
}

canonical_original_code:
int *bz_list_to_wstr(struct bz_list_node *e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  struct bz_String *s = bz_list_to_string(e);
  {;bz_barf_pop_function();return (s->string);};
}


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

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

original_code:
bz_List* bz_list_to_list(bz_List* e)
{
  return e;
}

canonical_original_code:
struct bz_list_node *bz_list_to_list(struct bz_list_node *e)
{
  return e;
}

variable_types:
e
struct bz_list_node *


decompiled_code:
__int64 __fastcall bz_string_length(__int64 a1)
{
bz_barf_push_function("bz_string_length");
bz_barf_pop_function();
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
bz_barf_push_function("bz_string_length");
bz_barf_pop_function();
return *(_QWORD *)(a1 + 16);
}

original_code:
size_t bz_string_length(bz_String* e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (e->length);};
}

canonical_original_code:
unsigned long bz_string_length(struct bz_String *e)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (e->length);};
}


decompiled_code:
__int64 __fastcall bz_string_stretch(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 v3; // rsi
__int64 v4; // rax

bz_barf_push_function("bz_string_stretch");
v3 = *(_QWORD *)(a1 + 8);
if ( a2 >= v3 )
{
do
v3 *= 2LL;
while ( v3 <= a2 );
*(_QWORD *)(a1 + 8) = v3;
}
v4 = GC_realloc(*(_QWORD *)(a1 + 24), 4 * v3);
*(_QWORD *)(a1 + 24) = v4;
if ( !v4 )
bz_barf("Out of Memory");
return bz_barf_pop_function();
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 v3; // rsi
__int64 v4; // rax

bz_barf_push_function("bz_string_stretch");
v3 = *(_QWORD *)(a1 + 8);
if ( a2 >= v3 )
{
do
v3 *= 2LL;
while ( v3 <= a2 );
*(_QWORD *)(a1 + 8) = v3;
}
v4 = GC_realloc(*(_QWORD *)(a1 + 24), 4 * v3);
*(_QWORD *)(a1 + 24) = v4;
if ( !v4 )
bz_barf("Out of Memory");
return bz_barf_pop_function();
}

original_code:
static void bz_string_stretch(bz_String* e, size_t new_size)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  while(e->buffer_size <= new_size)
    e->buffer_size = e->buffer_size << 1;
  e->string = (wchar_t *) GC_realloc(e->string,sizeof(wchar_t) * e->buffer_size);
  if(e->string == ((void *)0))
    bz_barf("Out of Memory");
  {;bz_barf_pop_function();};
}

canonical_original_code:
static void bz_string_stretch(struct bz_String *e, unsigned long new_size)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  while(e->buffer_size <= new_size)
    e->buffer_size = e->buffer_size << 1;
  e->string = (int *) GC_realloc(e->string,sizeof(wchar_t) * e->buffer_size);
  if(e->string == ((void *)0))
    bz_barf("Out of Memory");
  {;bz_barf_pop_function();};
}


decompiled_code:
int __fastcall bz_string_compare(__int64 a1, __int64 a2)
{
bz_barf_push_function("bz_string_compare");
bz_barf_pop_function();
return wcscmp(*(const wchar_t **)(a1 + 24), *(const wchar_t **)(a2 + 24));
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1, __int64 a2)
{
bz_barf_push_function("bz_string_compare");
bz_barf_pop_function();
return wcscmp(*(const wchar_t **)(a1 + 24), *(const wchar_t **)(a2 + 24));
}

original_code:
int bz_string_compare(bz_String* e1, bz_String* e2)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (wcscmp(e1->string,e2->string));};
}

canonical_original_code:
int bz_string_compare(struct bz_String *e1, struct bz_String *e2)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (wcscmp(e1->string,e2->string));};
}


decompiled_code:
int __fastcall bz_string_show(__int64 a1)
{
const wchar_t *v1; // rax

if ( !a1 )
_assert_fail("s", "src/string.c", 0x1B2u, "bz_string_show");
if ( *(void ***)a1 != &bz_String_type )
_assert_fail("s->type == bz_STRING", "src/string.c", 0x1B3u, "bz_string_show");
v1 = *(const wchar_t **)(a1 + 24);
if ( v1[*(_QWORD *)(a1 + 16)] )
_assert_fail("s->string[s->length] == L'\\0'", "src/string.c", 0x1B4u, "bz_string_show");
return fputws(v1, stdout);
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
const wchar_t *v1; // rax

if ( !a1 )
_assert_fail("s", "src/string.c", 0x1B2u, "bz_string_show");
if ( *(void ***)a1 != &bz_String_type )
_assert_fail("s->type == bz_STRING", "src/string.c", 0x1B3u, "bz_string_show");
v1 = *(const wchar_t **)(a1 + 24);
if ( v1[*(_QWORD *)(a1 + 16)] )
_assert_fail("s->string[s->length] == L'\\0'", "src/string.c", 0x1B4u, "bz_string_show");
return fputws(v1, stdout);
}

original_code:
void bz_string_show(bz_String* s)
{
  ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "src/string.c", 434, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((s->type == &bz_String_type) ? 1 : 0), __extension__ ({ if (s->type == &bz_String_type) ; else __assert_fail ("s->type == bz_STRING", "src/string.c", 435, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((s->string[s->length] == L'\0') ? 1 : 0), __extension__ ({ if (s->string[s->length] == L'\0') ; else __assert_fail ("s->string[s->length] == L'\\0'", "src/string.c", 436, __extension__ __PRETTY_FUNCTION__); }));
  fputws(s->string,stdout);
}

canonical_original_code:
void bz_string_show(struct bz_String *s)
{
  ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "src/string.c", 434, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((s->type == &bz_String_type) ? 1 : 0), __extension__ ({ if (s->type == &bz_String_type) ; else __assert_fail ("s->type == bz_STRING", "src/string.c", 435, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((s->string[s->length] == L'\0') ? 1 : 0), __extension__ ({ if (s->string[s->length] == L'\0') ; else __assert_fail ("s->string[s->length] == L'\\0'", "src/string.c", 436, __extension__ __PRETTY_FUNCTION__); }));
  fputws(s->string,stdout);
}


decompiled_code:
__int64 __fastcall bz_string_cat_wstr(_QWORD *a1, const wchar_t *a2)
{
size_t v3; // rbp
unsigned __int64 v4; // rsi
size_t v5; // rbp

bz_barf_push_function("bz_string_cat_wstr");
v3 = wcslen(a2);
v4 = v3 + a1[2] + 1;
if ( v4 > a1[1] )
bz_string_stretch((__int64)a1, v4);
wmemcpy((wchar_t *)(a1[3] + 4LL * a1[2]), a2, v3 + 1);
v5 = a1[2] + v3;
a1[2] = v5;
if ( v5 >= a1[1] )
_assert_fail("e->length < e->buffer_size", "src/string.c", 0xB9u, "bz_string_cat_wstr");
return bz_barf_pop_function();
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, const wchar_t *a2)
{
size_t v3; // rbp
unsigned __int64 v4; // rsi
size_t v5; // rbp

bz_barf_push_function("bz_string_cat_wstr");
v3 = wcslen(a2);
v4 = v3 + a1[2] + 1;
if ( v4 > a1[1] )
func2((__int64)a1, v4);
wmemcpy((wchar_t *)(a1[3] + 4LL * a1[2]), a2, v3 + 1);
v5 = a1[2] + v3;
a1[2] = v5;
if ( v5 >= a1[1] )
_assert_fail("e->length < e->buffer_size", "src/string.c", 0xB9u, "bz_string_cat_wstr");
return bz_barf_pop_function();
}

original_code:
void bz_string_cat_wstr(bz_String* e, wchar_t* s)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  size_t n = wcslen(s);
  if ((n + e->length + 1) > e->buffer_size)
    {
      (void) bz_string_stretch(e, e->length + n + 1);
    }
(void) wmemcpy(
  &e->string[e->length],
  s,
  (n+1));
  e->length += n;
  ((void) sizeof ((e->length < e->buffer_size) ? 1 : 0), __extension__ ({ if (e->length < e->buffer_size) ; else __assert_fail ("e->length < e->buffer_size", "src/string.c", 185, __extension__ __PRETTY_FUNCTION__); }));
  {;bz_barf_pop_function();};
}

canonical_original_code:
void bz_string_cat_wstr(struct bz_String *e, int *s)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  unsigned long n = wcslen(s);
  if ((n + e->length + 1) > e->buffer_size)
    {
      (void) bz_string_stretch(e, e->length + n + 1);
    }
(void) wmemcpy(
  &e->string[e->length],
  s,
  (n+1));
  e->length += n;
  ((void) sizeof ((e->length < e->buffer_size) ? 1 : 0), __extension__ ({ if (e->length < e->buffer_size) ; else __assert_fail ("e->length < e->buffer_size", "src/string.c", 185, __extension__ __PRETTY_FUNCTION__); }));
  {;bz_barf_pop_function();};
}

variable_types:
s
int *

variable_types:
n
unsigned long


decompiled_code:
__int64 __fastcall bz_string_cat_wchar(_QWORD *a1, int a2)
{
unsigned __int64 v3; // rsi
unsigned __int64 v4; // rax

bz_barf_push_function("bz_string_cat_wchar");
v3 = a1[2] + 2LL;
if ( v3 > a1[1] )
bz_string_stretch((__int64)a1, v3);
*(_DWORD *)(a1[3] + 4LL * a1[2]) = a2;
v4 = a1[2] + 1LL;
a1[2] = v4;
if ( v4 >= a1[1] )
_assert_fail("e->length < e->buffer_size", "src/string.c", 0xCFu, "bz_string_cat_wchar");
*(_DWORD *)(a1[3] + 4 * v4) = 0;
return bz_barf_pop_function();
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, int a2)
{
unsigned __int64 v3; // rsi
unsigned __int64 v4; // rax

bz_barf_push_function("bz_string_cat_wchar");
v3 = a1[2] + 2LL;
if ( v3 > a1[1] )
func2((__int64)a1, v3);
*(_DWORD *)(a1[3] + 4LL * a1[2]) = a2;
v4 = a1[2] + 1LL;
a1[2] = v4;
if ( v4 >= a1[1] )
_assert_fail("e->length < e->buffer_size", "src/string.c", 0xCFu, "bz_string_cat_wchar");
*(_DWORD *)(a1[3] + 4 * v4) = 0;
return bz_barf_pop_function();
}

original_code:
void bz_string_cat_wchar(bz_String* e, wchar_t c)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  if ((e->length + 2) > e->buffer_size)
  {
    (void) bz_string_stretch(e, e->length + 2);
  }
  e->string[e->length]=c;
  e->length++;
  ((void) sizeof ((e->length < e->buffer_size) ? 1 : 0), __extension__ ({ if (e->length < e->buffer_size) ; else __assert_fail ("e->length < e->buffer_size", "src/string.c", 207, __extension__ __PRETTY_FUNCTION__); }));
  e->string[e->length]=L'\0';
  {;bz_barf_pop_function();};
}

canonical_original_code:
void bz_string_cat_wchar(struct bz_String *e, int c)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  if ((e->length + 2) > e->buffer_size)
  {
    (void) bz_string_stretch(e, e->length + 2);
  }
  e->string[e->length]=c;
  e->length++;
  ((void) sizeof ((e->length < e->buffer_size) ? 1 : 0), __extension__ ({ if (e->length < e->buffer_size) ; else __assert_fail ("e->length < e->buffer_size", "src/string.c", 207, __extension__ __PRETTY_FUNCTION__); }));
  e->string[e->length]=L'\0';
  {;bz_barf_pop_function();};
}

variable_types: c int


decompiled_code:
__int64 __fastcall bz_string_compare_ignorecase(__int64 a1, __int64 a2)
{
bz_barf_push_function("bz_string_compare_ignorecase");
bz_barf_pop_function();
return wcscasecmp(*(_QWORD *)(a1 + 24), *(_QWORD *)(a2 + 24));
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2)
{
bz_barf_push_function("bz_string_compare_ignorecase");
bz_barf_pop_function();
return func9(*(_QWORD *)(a1 + 24), *(_QWORD *)(a2 + 24));
}

original_code:
int bz_string_compare_ignorecase(bz_String* e1, bz_String* e2)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (wcscasecmp(e1->string,e2->string));};
}

canonical_original_code:
int bz_string_compare_ignorecase(struct bz_String *e1, struct bz_String *e2)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (wcscasecmp(e1->string,e2->string));};
}


decompiled_code:
__int64 __fastcall bz_string_eq(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
__int64 v3; // rax

bz_barf_push_function("bz_string_eq");
v2 = *(_QWORD *)(a1 + 16);
if ( v2 == *(_QWORD *)(a2 + 16) )
{
if ( !v2 )
{
LABEL_6:
bz_barf_pop_function();
return 1LL;
}
v3 = 0LL;
while ( *(_DWORD *)(*(_QWORD *)(a1 + 24) + 4 * v3) == *(_DWORD *)(*(_QWORD *)(a2 + 24) + 4 * v3) )
{
if ( v2 == ++v3 )
goto LABEL_6;
}
}
bz_barf_pop_function();
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
__int64 v3; // rax

bz_barf_push_function("bz_string_eq");
v2 = *(_QWORD *)(a1 + 16);
if ( v2 == *(_QWORD *)(a2 + 16) )
{
if ( !v2 )
{
LABEL_6:
bz_barf_pop_function();
return 1LL;
}
v3 = 0LL;
while ( *(_DWORD *)(*(_QWORD *)(a1 + 24) + 4 * v3) == *(_DWORD *)(*(_QWORD *)(a2 + 24) + 4 * v3) )
{
if ( v2 == ++v3 )
goto LABEL_6;
}
}
bz_barf_pop_function();
return 0LL;
}

original_code:
int bz_string_eq(bz_String* e1, bz_String* e2)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  size_t n1,n2,i;
  n1 = e1->length;
  n2 = e2->length;
  if(n1 != n2)
    {;bz_barf_pop_function();return (0);};
  for(i=0;i<n1;i++)
    if(e1->string[i] != e2->string[i])
      {;bz_barf_pop_function();return (0);};
  {;bz_barf_pop_function();return (1);};
}

canonical_original_code:
int bz_string_eq(struct bz_String *e1, struct bz_String *e2)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  unsigned long n1; unsigned long n2; unsigned long i;
  n1 = e1->length;
  n2 = e2->length;
  if(n1 != n2)
    {;bz_barf_pop_function();return (0);};
  for(i=0;i<n1;i++)
    if(e1->string[i] != e2->string[i])
      {;bz_barf_pop_function();return (0);};
  {;bz_barf_pop_function();return (1);};
}

variable_types:
i
unsigned long


decompiled_code:
__int64 __fastcall bz_minihash_length(__int64 a1)
{
_QWORD *v1; // rax
__int64 v2; // rdx

v1 = (_QWORD *)(a1 + 8);
v2 = 0LL;
do
v2 -= (*v1++ == 0LL) - 1LL;
while ( v1 != (_QWORD *)(a1 + 264) );
return v2;
}

original_code:
size_t bz_minihash_length(bz_Minihash* m)
{
  size_t n = 0;
  int i;
    for (i=0; i<32; i++)
      if(m->name[i])
     n ++;
    return n;
}

canonical_original_code:
unsigned long bz_minihash_length(struct bz_Minihash *m)
{
  unsigned long n = 0;
  int i;
    for (i=0; i<32; i++)
      if(m->name[i])
     n ++;
    return n;
}

variable_types: struct bz_Minihash { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; struct bz_String { struct bz_Type *type; unsigned long buffer_size; unsigned long length; int *string; } *name[32]; void *value[32]; struct bz_String *filename[32]; unsigned long line[32]; } *

variable_types: i int

user_defined_types: struct bz_Minihash { struct bz_Type *type; struct bz_String *name[32]; void *value[32]; struct bz_String *filename[32]; unsigned long line[32]; }


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

v0 = malloc(0x408uLL);
if ( !v0 )
bz_barf("Out of memory");
*v0 = &bz_Minihash_type;
return v0;
}

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

v0 = malloc(0x408uLL);
if ( !v0 )
bz_barf("Out of memory");
*v0 = &bz_Minihash_type;
return v0;
}

original_code:
bz_Minihash* bz_minihash_new(void)
{
  bz_Minihash* m;
  m = malloc(sizeof(bz_Minihash)); if(!m) bz_barf("Out of memory"); m->type = &bz_Minihash_type;
  return m;
}

canonical_original_code:
struct bz_Minihash *bz_minihash_new()
{
  struct bz_Minihash *m;
  m = malloc(sizeof(bz_Minihash)); if(!m) bz_barf("Out of memory"); m->type = &bz_Minihash_type;
  return m;
}

return_type: struct bz_Minihash { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; struct bz_String { struct bz_Type *type; unsigned long buffer_size; unsigned long length; int *string; } *name[32]; void *value[32]; struct bz_String *filename[32]; unsigned long line[32]; } *


decompiled_code:
__int64 __fastcall bz_minihash_copy(__int64 a1)
{
if ( !malloc(0x408uLL) )
bz_barf("Out of memory");
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
if ( !malloc(0x408uLL) )
bz_barf("Out of memory");
return a1;
}

original_code:
bz_Minihash* bz_minihash_copy(bz_Minihash* m)
{
  bz_Minihash* mm;
  mm = malloc(sizeof(bz_Minihash)); if(!mm) bz_barf("Out of memory"); mm->type = &bz_Minihash_type;
  memcpy(mm,m,sizeof(bz_Minihash));
  return m;
}

canonical_original_code:
struct bz_Minihash *bz_minihash_copy(struct bz_Minihash *m)
{
  struct bz_Minihash *mm;
  mm = malloc(sizeof(bz_Minihash)); if(!mm) bz_barf("Out of memory"); mm->type = &bz_Minihash_type;
  memcpy(mm,m,sizeof(bz_Minihash));
  return m;
}

variable_types:
m
struct bz_Minihash *


decompiled_code:
__int64 __fastcall bz_minihash_charsize(__int64 a1)
{
_QWORD *v1; // rbx
__int64 v2; // r12

v1 = (_QWORD *)(a1 + 8);
v2 = 0LL;
do
{
if ( *v1 )
v2 += bz_string_length();
++v1;
}
while ( v1 != (_QWORD *)(a1 + 264) );
return v2;
}

original_code:
size_t bz_minihash_charsize(bz_Minihash* m)
{
  size_t n = 0;
  int i;
    for (i=0; i<32; i++)
      if(m->name[i])
     n += bz_string_length(m->name[i]);
    return n;
}

canonical_original_code:
unsigned long bz_minihash_charsize(struct bz_Minihash *m)
{
  unsigned long n = 0;
  int i;
    for (i=0; i<32; i++)
      if(m->name[i])
     n += bz_string_length(m->name[i]);
    return n;
}


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

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

original_code:
int bz_minihash_compare(bz_Minihash* x, bz_Minihash* y)
{
  return(0);
}

canonical_original_code:
int bz_minihash_compare(struct bz_Minihash *x, struct bz_Minihash *y)
{
  return(0);
}

variable_types:
y
struct bz_Minihash *


decompiled_code:
void bz_minihash_show()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void bz_minihash_show(bz_Minihash* m)
{
   ;
}

canonical_original_code:
void bz_minihash_show(struct bz_Minihash *m)
{
   ;
}