decompiled_code:
__int64 __fastcall irq_handler(__int64 a1)
{
unsigned int v1; // eax
void (*v2)(void); // rdx

v1 = *(_DWORD *)(a1 + 48);
v2 = (void (*)(void))irq_routines[v1 - 32];
if ( v2 )
{
v2();
v1 = *(_DWORD *)(a1 + 48);
}
if ( v1 > 0x27 )
io_outb(160LL, 32LL);
return io_outb(32LL, 32LL);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
unsigned int v1; // eax
void (*v2)(void); // rdx

v1 = *(_DWORD *)(a1 + 48);
v2 = (void (*)(void))irq_routines[v1 - 32];
if ( v2 )
{
v2();
v1 = *(_DWORD *)(a1 + 48);
}
if ( v1 > 0x27 )
io_outb(160LL, 32LL);
return io_outb(32LL, 32LL);
}

original_code:
void irq_handler(regs_t *r)
{
    void (*handler)(regs_t *r);
    handler = irq_routines[r->which_int - 32];
    if (handler)
    {
        handler(r);
    }
    if (r->which_int >= 40)
        io_outb(0xA0, 0x20);
    io_outb(0x20, 0x20);
}

canonical_original_code:
void irq_handler(struct regs_t *r)
{
    void (*handler)(struct regs_t *r);
    handler = irq_routines[r->which_int - 32];
    if (handler)
    {
        handler(r);
    }
    if (r->which_int >= 40)
        io_outb(0xA0, 0x20);
    io_outb(0x20, 0x20);
}

user_defined_types: struct regs_t { unsigned int edi; unsigned int ds; unsigned int which_int; unsigned int eip; }


repo: dakk/spiderpig-os

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

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

original_code:
uint32_t sys_void()
{
 return 0;
}

canonical_original_code:
unsigned int sys_void()
{
 return 0;
}

return_type: unsigned int


decompiled_code:
int sys_getch()
{
return getchar();
}

canonical_decompiled_code:
int func1()
{
return getchar();
}

original_code:
int sys_getch()
{
 return getchar();
}

canonical_original_code:
int sys_getch()
{
 return getchar();
}

return_type: int


decompiled_code:
int __fastcall sys_putch(char a1)
{
return putchar(a1);
}

canonical_decompiled_code:
int __fastcall func2(char a1)
{
return putchar(a1);
}

original_code:
int sys_putch(uint32_t c)
{
 putchar((char) c);
}

canonical_original_code:
int sys_putch(unsigned int c)
{
 putchar((char) c);
}

variable_types:
c
unsigned int


decompiled_code:
__int64 __fastcall sys_mount(unsigned int a1, unsigned int a2, unsigned int a3)
{
return fs_mount(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, unsigned int a2, unsigned int a3)
{
return fs_mount(a1, a2, a3);
}

original_code:
int sys_mount(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
{
 return fs_mount((char *) a, (char *) b, (char *) c, (uint32_t) d);
}

canonical_original_code:
int sys_mount(unsigned int a, unsigned int b, unsigned int c, unsigned int d)
{
 return fs_mount((char *) a, (char *) b, (char *) c, (unsigned int) d);
}

variable_types:
a
unsigned int

variable_types:
b
unsigned int

variable_types:
d
unsigned int


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

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

original_code:
int sys_umount(uint32_t a)
{
 return fs_umount((char *) a);
}

canonical_original_code:
int sys_umount(unsigned int a)
{
 return fs_umount((char *) a);
}


decompiled_code:
__int64 __fastcall sys_iget_mount_point(__int64 a1, unsigned int a2)
{
return fs_iget_mount_point(a1, a2);
}

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

original_code:
int sys_iget_mount_point(uint32_t a, uint32_t b)
{
 return fs_iget_mount_point((uint32_t) a, (mount_point_t **) b);
}

canonical_original_code:
int sys_iget_mount_point(unsigned int a, unsigned int b)
{
 return fs_iget_mount_point((unsigned int) a, (struct mount_point_p **) b);
}

user_defined_types: struct mount_point_p { char path[512]; char dev[512]; char fs[512]; void *fs_struct; struct inode_p *root; struct inode_p *childs; unsigned char used; }

user_defined_types: struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; }


decompiled_code:
__int64 __fastcall sys_readdir(unsigned int a1, unsigned int a2)
{
return fs_readdir(a1, a2);
}

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

original_code:
int sys_readdir(uint32_t a, uint32_t b)
{
 return fs_readdir((dir_t *) a, (struct dirent *) b);
}

canonical_original_code:
int sys_readdir(unsigned int a, unsigned int b)
{
 return fs_readdir((struct dir_p *) a, (struct dirent *) b);
}

user_defined_types: struct dir_p { struct file_p *f; char *d_name; unsigned int cur_i; char path[512]; }

user_defined_types: struct dirent { char name[255]; unsigned int inode; }

user_defined_types: struct file_p { unsigned int id; unsigned long long seek_p; unsigned long long size; struct inode_p *node; void *drv; struct file_p *next; }


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

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

original_code:
int sys_opendir(uint32_t a)
{
 return (int) fs_opendir((char *) a);
}

canonical_original_code:
int sys_opendir(unsigned int a)
{
 return (int) fs_opendir((char *) a);
}


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

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

original_code:
int sys_closedir(uint32_t a)
{
 return fs_closedir((dir_t *) a);
}

canonical_original_code:
int sys_closedir(unsigned int a)
{
 return fs_closedir((struct dir_p *) a);
}


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

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

original_code:
int sys_rewinddir(uint32_t a)
{
 return fs_rewinddir((dir_t *) a);
}

canonical_original_code:
int sys_rewinddir(unsigned int a)
{
 return fs_rewinddir((struct dir_p *) a);
}


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

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

original_code:
int sys_makedir(uint32_t a)
{
 return fs_makedir((char *) a);
}

canonical_original_code:
int sys_makedir(unsigned int a)
{
 return fs_makedir((char *) a);
}


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

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

original_code:
int sys_rm(uint32_t a)
{
 return fs_rm((char *) a);
}

canonical_original_code:
int sys_rm(unsigned int a)
{
 return fs_rm((char *) a);
}


decompiled_code:
__int64 __fastcall sys_read(unsigned int a1, unsigned int a2)
{
return fs_read(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned int a1, unsigned int a2)
{
return fs_read(a1, a2);
}

original_code:
int sys_read(uint32_t a, uint32_t b, uint32_t c)
{
 return fs_read((file_t *) a, (char *) b, (uint32_t) c);
}

canonical_original_code:
int sys_read(unsigned int a, unsigned int b, unsigned int c)
{
 return fs_read((struct file_p *) a, (char *) b, (unsigned int) c);
}


decompiled_code:
__int64 __fastcall sys_open(unsigned int a1, unsigned int a2)
{
return fs_open(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func13(unsigned int a1, unsigned int a2)
{
return fs_open(a1, a2);
}

original_code:
int sys_open(uint32_t a, uint32_t b)
{
 return (int) fs_open((char *) a, (char *) b);
}

canonical_original_code:
int sys_open(unsigned int a, unsigned int b)
{
 return (int) fs_open((char *) a, (char *) b);
}


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

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

original_code:
int sys_close(uint32_t a)
{
 return fs_close((file_t *) a);
}

canonical_original_code:
int sys_close(unsigned int a)
{
 return fs_close((struct file_p *) a);
}


decompiled_code:
__int64 __fastcall sys_write(unsigned int a1, unsigned int a2)
{
return fs_write(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned int a1, unsigned int a2)
{
return fs_write(a1, a2);
}

original_code:
int sys_write(uint32_t a, uint32_t b, uint32_t c)
{
 return fs_write((file_t *) a, (char *) b, (uint32_t) c);
}

canonical_original_code:
int sys_write(unsigned int a, unsigned int b, unsigned int c)
{
 return fs_write((struct file_p *) a, (char *) b, (unsigned int) c);
}


decompiled_code:
__int64 __fastcall sys_seek(unsigned int a1, unsigned __int8 a2, unsigned int a3)
{
return fs_seek(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned int a1, unsigned __int8 a2, unsigned int a3)
{
return fs_seek(a1, a2, a3);
}

original_code:
int sys_seek(uint32_t a, uint32_t b, uint32_t c)
{
 return fs_seek((file_t *) a, (uint32_t) b, (uint64_t) c);
}

canonical_original_code:
int sys_seek(unsigned int a, unsigned int b, unsigned int c)
{
 return fs_seek((struct file_p *) a, (unsigned int) b, (unsigned long long) c);
}


decompiled_code:
__int64 __fastcall sys_link(unsigned int a1, unsigned int a2)
{
return fs_link(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func17(unsigned int a1, unsigned int a2)
{
return fs_link(a1, a2);
}

original_code:
uint32_t sys_link(uint32_t a, uint32_t b)
{
 return fs_link((char *) a, (char *) b);
}

canonical_original_code:
unsigned int sys_link(unsigned int a, unsigned int b)
{
 return fs_link((char *) a, (char *) b);
}


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

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

original_code:
uint32_t sys_unlink(uint32_t a)
{
 return fs_unlink((char *) a);
}

canonical_original_code:
unsigned int sys_unlink(unsigned int a)
{
 return fs_unlink((char *) a);
}


decompiled_code:
__int64 __fastcall sys_device_iget(__int64 a1, unsigned int a2)
{
return device_iget(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, unsigned int a2)
{
return device_iget(a1, a2);
}

original_code:
uint32_t sys_device_iget(uint32_t a, uint32_t b)
{
 return device_iget((uint32_t) a, (device_t **) b);
}

canonical_original_code:
unsigned int sys_device_iget(unsigned int a, unsigned int b)
{
 return device_iget((unsigned int) a, (struct device_p **) b);
}

user_defined_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; }


decompiled_code:
__int64 sys_device_update()
{
device_update();
return 0LL;
}

canonical_decompiled_code:
__int64 func20()
{
device_update();
return 0LL;
}

original_code:
uint32_t sys_device_update()
{
 device_update();
 return 0;
}

canonical_original_code:
unsigned int sys_device_update()
{
 device_update();
 return 0;
}


decompiled_code:
__int64 sys_message_clear()
{
message_clear();
return 0LL;
}

canonical_decompiled_code:
__int64 func21()
{
message_clear();
return 0LL;
}

original_code:
uint32_t sys_message_clear()
{
 message_clear();
 return 0;
}

canonical_original_code:
unsigned int sys_message_clear()
{
 message_clear();
 return 0;
}


decompiled_code:
__int64 __fastcall sys_message_send(__int64 a1, unsigned int a2)
{
return message_send(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1, unsigned int a2)
{
return message_send(a1, a2);
}

original_code:
uint32_t sys_message_send(uint32_t a, uint32_t b, uint32_t c)
{
 return message_send((pid_t) a, (char *) b, (uint32_t) c);
}

canonical_original_code:
unsigned int sys_message_send(unsigned int a, unsigned int b, unsigned int c)
{
 return message_send((int) a, (char *) b, (unsigned int) c);
}


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

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

original_code:
uint32_t sys_driver_add(uint32_t a)
{
 return driver_add((driver_t *) a);
}

canonical_original_code:
unsigned int sys_driver_add(unsigned int a)
{
 return driver_add((struct driver_p *) a);
}

user_defined_types: struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t fs; struct driver_video_t video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; }

user_defined_types: struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; }

user_defined_types: struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); }

user_defined_types: struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; }


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

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

original_code:
uint32_t sys_driver_del(uint32_t a)
{
 return driver_del((char *) a);
}

canonical_original_code:
unsigned int sys_driver_del(unsigned int a)
{
 return driver_del((char *) a);
}


decompiled_code:
__int64 __fastcall sys_driver_iget(__int64 a1, unsigned int a2)
{
return driver_iget(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func25(__int64 a1, unsigned int a2)
{
return driver_iget(a1, a2);
}

original_code:
uint32_t sys_driver_iget(uint32_t a, uint32_t b)
{
 return driver_iget((uint32_t) a, (driver_t **) b);
}

canonical_original_code:
unsigned int sys_driver_iget(unsigned int a, unsigned int b)
{
 return driver_iget((unsigned int) a, (struct driver_p **) b);
}


decompiled_code:
__int64 __fastcall sys_driver_initd(unsigned int a1)
{
return (unsigned __int8)driver_initd(a1);
}

canonical_decompiled_code:
__int64 __fastcall func26(unsigned int a1)
{
return (unsigned __int8)driver_initd(a1);
}

original_code:
uint32_t sys_driver_initd(uint32_t a)
{
 return driver_initd((char *) a);
}

canonical_original_code:
unsigned int sys_driver_initd(unsigned int a)
{
 return driver_initd((char *) a);
}


decompiled_code:
__int64 __fastcall sys_driver_freed(unsigned int a1)
{
return (unsigned __int8)driver_freed(a1);
}

canonical_decompiled_code:
__int64 __fastcall func27(unsigned int a1)
{
return (unsigned __int8)driver_freed(a1);
}

original_code:
uint32_t sys_driver_freed(uint32_t a)
{
 return driver_freed((char *) a);
}

canonical_original_code:
unsigned int sys_driver_freed(unsigned int a)
{
 return driver_freed((char *) a);
}


decompiled_code:
__int64 __fastcall sys_message_recv(unsigned int a1, unsigned int a2)
{
return message_recv(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func28(unsigned int a1, unsigned int a2)
{
return message_recv(a1, a2);
}

original_code:
uint32_t sys_message_recv(uint32_t a, uint32_t b)
{
 return message_recv((char *) a, (pid_t *) b);
}

canonical_original_code:
unsigned int sys_message_recv(unsigned int a, unsigned int b)
{
 return message_recv((char *) a, (int *) b);
}


decompiled_code:
__int64 sys_test()
{
_enable();
bish();
return 0LL;
}

canonical_decompiled_code:
__int64 func29()
{
_enable();
bish();
return 0LL;
}

original_code:
uint32_t sys_test()
{
 asm("sti");
 bish();
 return 0;
}

canonical_original_code:
unsigned int sys_test()
{
 asm("sti");
 bish();
 return 0;
}


decompiled_code:
__int64 sys_millisleep()
{
return arch_sleep();
}

canonical_decompiled_code:
__int64 func30()
{
return arch_sleep();
}

original_code:
uint32_t sys_millisleep(uint32_t a)
{
 arch_sleep(a);
}

canonical_original_code:
unsigned int sys_millisleep(unsigned int a)
{
 arch_sleep(a);
}


decompiled_code:
__int64 sys_task_sleepms()
{
return task_sleep_ms();
}

canonical_decompiled_code:
__int64 func31()
{
return task_sleep_ms();
}

original_code:
uint32_t sys_task_sleepms(uint32_t a)
{
 task_sleep_ms(a);
}

canonical_original_code:
unsigned int sys_task_sleepms(unsigned int a)
{
 task_sleep_ms(a);
}


decompiled_code:
__int64 __fastcall sys_driver_puts(unsigned int a1, __int64 a2, unsigned int a3)
{
return driver_puts(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func32(unsigned int a1, __int64 a2, unsigned int a3)
{
return driver_puts(a1, a2, a3);
}

original_code:
uint32_t sys_driver_puts(uint32_t a, uint32_t b, uint32_t c)
{
 driver_puts((driver_t *) a, b, (char *) c);
}

canonical_original_code:
unsigned int sys_driver_puts(unsigned int a, unsigned int b, unsigned int c)
{
 driver_puts((struct driver_p *) a, b, (char *) c);
}


decompiled_code:
__int64 __fastcall syscall_call5()
{
__int64 result; // rax

__asm { int 84h }
return (unsigned int)result;
}

canonical_decompiled_code:
__int64 __fastcall func33()
{
__int64 result; // rax

__asm { int 84h }
return (unsigned int)result;
}

original_code:
int syscall_call5(uint32_t call, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4, uint32_t p5)
{
 int ret;
 asm ("int %0\n" : : "g" (0x84));
 asm ("movl %%eax, %0\n\t" : "=r" (ret));
 return ret;
}

canonical_original_code:
int syscall_call5(unsigned int call, unsigned int p1, unsigned int p2, unsigned int p3, unsigned int p4, unsigned int p5)
{
 int ret;
 asm ("int %0\n" : : "g" (0x84));
 asm ("movl %%eax, %0\n\t" : "=r" (ret));
 return ret;
}

variable_types:
call
unsigned int

variable_types: ret int


decompiled_code:
__int64 __fastcall syscall_callback(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 result; // rax
unsigned int v5; // ebx
unsigned __int64 v6; // rax
__int64 (__fastcall *v7)(); // r9

result = (unsigned int)result;
if ( syscalls_number >= (unsigned int)result )
{
v6 = 4LL * (unsigned int)result;
v7 = off_66C8[v6 / 2];
switch ( syscalls[v6] )
{
case 0:
case 1:
case 2:
LODWORD(result) = ((__int64 (__fastcall *)(_QWORD, _QWORD))v7)(v5, a4);
break;
case 4:
LODWORD(result) = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD, _QWORD))v7)(v5, a4, 0LL, 0LL);
break;
case 5:
LODWORD(result) = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD, _QWORD, _QWORD))v7)(v5, a4, 0LL, 0LL, 0LL);
break;
default:
LODWORD(result) = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))v7)(v5, a4, 0LL);
break;
}
result = (unsigned int)result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func34(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 result; // rax
unsigned int v5; // ebx
unsigned __int64 v6; // rax
__int64 (__fastcall *v7)(); // r9

result = (unsigned int)result;
if ( syscalls_number >= (unsigned int)result )
{
v6 = 4LL * (unsigned int)result;
v7 = off_66C8[v6 / 2];
switch ( syscalls[v6] )
{
case 0:
case 1:
case 2:
LODWORD(result) = ((__int64 (__fastcall *)(_QWORD, _QWORD))v7)(v5, a4);
break;
case 4:
LODWORD(result) = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD, _QWORD))v7)(v5, a4, 0LL, 0LL);
break;
case 5:
LODWORD(result) = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD, _QWORD, _QWORD))v7)(v5, a4, 0LL, 0LL, 0LL);
break;
default:
LODWORD(result) = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))v7)(v5, a4, 0LL);
break;
}
result = (unsigned int)result;
}
return result;
}

original_code:
void syscall_callback(regs_t *r)
{
 int ret;
 uint32_t p1, p2, p3, p4, p5, call;
 asm("mov %%eax, %0\n" : "=r" (call));
 asm("mov %%ebx, %0\n" : "=r" (p1));
 asm("mov %%ecx, %0\n" : "=r" (p2));
 if(call > syscalls_number)
  return;
 switch(syscalls[call].arg)
 {
  case 0:
   ret = syscalls[call].call();
   break;
  case 1:
   ret = syscalls[call].call(p1);
   break;
  case 2:
   ret = syscalls[call].call(p1, p2);
   break;
  case 3:
   ret = syscalls[call].call(p1, p2, p3);
   break;
  case 4:
   ret = syscalls[call].call(p1, p2, p3, p4);
   break;
  case 5:
   ret = syscalls[call].call(p1, p2, p3, p4, p5);
   break;
  default:
   ret = syscalls[call].call(p1, p2, p3);
 }
 asm("movl %0, %%eax\n\t": : "g" (ret));
}

canonical_original_code:
void syscall_callback(struct regs_t *r)
{
 int ret;
 unsigned int p1; unsigned int p2; unsigned int p3; unsigned int p4; unsigned int p5; unsigned int call;
 asm("mov %%eax, %0\n" : "=r" (call));
 asm("mov %%ebx, %0\n" : "=r" (p1));
 asm("mov %%ecx, %0\n" : "=r" (p2));
 if(call > syscalls_number)
  return;
 switch(syscalls[call].arg)
 {
  case 0:
   ret = syscalls[call].call();
   break;
  case 1:
   ret = syscalls[call].call(p1);
   break;
  case 2:
   ret = syscalls[call].call(p1, p2);
   break;
  case 3:
   ret = syscalls[call].call(p1, p2, p3);
   break;
  case 4:
   ret = syscalls[call].call(p1, p2, p3, p4);
   break;
  case 5:
   ret = syscalls[call].call(p1, p2, p3, p4, p5);
   break;
  default:
   ret = syscalls[call].call(p1, p2, p3);
 }
 asm("movl %0, %%eax\n\t": : "g" (ret));
}

variable_types: struct regs_t { unsigned int edi; unsigned int ds; unsigned int which_int; unsigned int eip; } *

return_type: void


decompiled_code:
__int64 syscall_init()
{
return debug_puts("syscall_init()\n");
}

canonical_decompiled_code:
__int64 func35()
{
return debug_puts("syscall_init()\n");
}

original_code:
void syscall_init()
{
 debug_puts("syscall_init()\n");
}


decompiled_code:
char *__fastcall sys_info_get(unsigned int a1)
{
return syscall_info_get((char *)a1);
}

canonical_decompiled_code:
char *__fastcall func37(unsigned int a1)
{
return func36((char *)a1);
}

original_code:
uint32_t sys_info_get(uint32_t a)
{
 return syscall_info_get((sysinfo_t *) a);
}

canonical_original_code:
unsigned int sys_info_get(unsigned int a)
{
 return syscall_info_get((struct sysinfo_t *) a);
}

user_defined_types: struct sysinfo_t { char name[32]; char ver[16]; char rev[16]; char date[16]; char time[16]; char arch[16]; char vend[16]; }


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

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

original_code:
uint32_t cpu_get_freq()
{
 return 0;
}

canonical_original_code:
unsigned int cpu_get_freq()
{
 return 0;
}


decompiled_code:
__int64 __fastcall cpu_vendor_name(char *dest)
{
char src[4]; // [rsp+1h] [rbp-67h] BYREF
char v3; // [rsp+5h] [rbp-63h]
char v4[4]; // [rsp+6h] [rbp-62h] BYREF
char v5; // [rsp+Ah] [rbp-5Eh]
char v6[4]; // [rsp+Bh] [rbp-5Dh] BYREF
char v7; // [rsp+Fh] [rbp-59h]
_DWORD v8[22]; // [rsp+10h] [rbp-58h] BYREF

cpu_cpuid(v8, 0);
v3 = 0;
*(_DWORD *)src = v8[4];
v5 = 0;
*(_DWORD *)v4 = v8[6];
v7 = 0;
*(_DWORD *)v6 = v8[5];
strcpy(dest, src);
strcat(dest, v6);
strcat(dest, v4);
return 15LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *dest)
{
char src[4]; // [rsp+1h] [rbp-67h] BYREF
char v3; // [rsp+5h] [rbp-63h]
char v4[4]; // [rsp+6h] [rbp-62h] BYREF
char v5; // [rsp+Ah] [rbp-5Eh]
char v6[4]; // [rsp+Bh] [rbp-5Dh] BYREF
char v7; // [rsp+Fh] [rbp-59h]
_DWORD v8[22]; // [rsp+10h] [rbp-58h] BYREF

cpu_cpuid(v8, 0);
v3 = 0;
*(_DWORD *)src = v8[4];
v5 = 0;
*(_DWORD *)v4 = v8[6];
v7 = 0;
*(_DWORD *)v6 = v8[5];
strcpy(dest, src);
strcat(dest, v6);
strcat(dest, v4);
return 15LL;
}

canonical_original_code:
unsigned int cpu_vendor_name(char *name)
{
  struct regs_t r = cpu_cpuid(0x00);
  char line1[5];
  line1[0] = ((char *) &r.ebx)[0];
  line1[1] = ((char *) &r.ebx)[1];
  line1[2] = ((char *) &r.ebx)[2];
  line1[3] = ((char *) &r.ebx)[3];
  line1[4] = '\0';
  char line2[5];
  line2[0] = ((char *) &r.ecx)[0];
  line2[1] = ((char *) &r.ecx)[1];
  line2[2] = ((char *) &r.ecx)[2];
  line2[3] = ((char *) &r.ecx)[3];
  line2[4] = '\0';
  char line3[5];
  line3[0] = ((char *) &r.edx)[0];
  line3[1] = ((char *) &r.edx)[1];
  line3[2] = ((char *) &r.edx)[2];
  line3[3] = ((char *) &r.edx)[3];
  line3[4] = '\0';
  strcpy(name, line1);
  strcat(name, line3);
  strcat(name, line2);
  return 15;
}

variable_types:
name
char *

variable_types: struct regs_t { unsigned int edi; unsigned int ds; unsigned int which_int; unsigned int eip; }


decompiled_code:
__int64 cpu_get_free()
{
return cpu_get_freq();
}

canonical_decompiled_code:
__int64 func2()
{
return func0();
}

original_code:
uint32_t cpu_get_free()
{
 return 0;
}

canonical_original_code:
unsigned int cpu_get_free()
{
 return 0;
}


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

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

original_code:
uint32_t cpu_stop(uint32_t cpu)
{
 return 0;
}

canonical_original_code:
unsigned int cpu_stop(unsigned int cpu)
{
 return 0;
}

variable_types:
cpu
unsigned int


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

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

original_code:
uint32_t cpu_num()
{
 return 1;
}

canonical_original_code:
unsigned int cpu_num()
{
 return 1;
}


decompiled_code:
_BOOL8 __fastcall cpu_get_state(unsigned int a1)
{
return (unsigned int)cpu_num() > a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(unsigned int a1)
{
return (unsigned int)func4() > a1;
}

original_code:
uint32_t cpu_get_state(uint32_t cpu)
{
 if(cpu < cpu_num())
  return 1;
 else
  return 0;
}

canonical_original_code:
unsigned int cpu_get_state(unsigned int cpu)
{
 if(cpu < cpu_num())
  return 1;
 else
  return 0;
}


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

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

original_code:
uint32_t cpu_exec(uint32_t cpu, void *code)
{
 return 0;
}

canonical_original_code:
unsigned int cpu_exec(unsigned int cpu, void *code)
{
 return 0;
}

variable_types:
code
void *


decompiled_code:
void cpu_whake()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
uint32_t cpu_whake(uint32_t cpu)
{
}

canonical_original_code:
unsigned int cpu_whake(unsigned int cpu)
{
}


decompiled_code:
// attributes: thunk
void cpu_sleep()
{
cpu_whake();
}

canonical_decompiled_code:
void func8()
{
func7();
}

original_code:
uint32_t cpu_sleep(uint32_t cpu)
{
}

canonical_original_code:
unsigned int cpu_sleep(unsigned int cpu)
{
}


decompiled_code:
// attributes: thunk
void cpu_reset()
{
cpu_whake();
}

canonical_decompiled_code:
void func9()
{
func7();
}

original_code:
uint32_t cpu_reset(uint32_t cpu)
{
}

canonical_original_code:
unsigned int cpu_reset(unsigned int cpu)
{
}


decompiled_code:
void cpu_get_id()
{
;
}

canonical_decompiled_code:
void func10()
{
;
}

original_code:
uint32_t cpu_get_id()
{
}

canonical_original_code:
unsigned int cpu_get_id()
{
}


decompiled_code:
void rtl8139_probe()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
uint32_t rtl8139_probe(device_t *dev)
{
}

canonical_original_code:
unsigned int rtl8139_probe(struct device_p *dev)
{
}

variable_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *


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

_disable();
debug_puts("arch_init()\n");
ARCH = 3553400;
cpu_vendor_name(&CPU_VENDOR);
gdt_install();
idt_install();
isrs_install();
irq_install();
timer_init();
clock_init();
idt_set_gate(132LL, &syscallisr, 8LL, 142LL);
result = idt_set_gate(14LL, &page_fault_handler, 8LL, 142LL);
_enable();
return result;
}

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

_disable();
debug_puts("arch_init()\n");
ARCH = 3553400;
cpu_vendor_name(&CPU_VENDOR);
gdt_install();
idt_install();
isrs_install();
irq_install();
timer_init();
clock_init();
idt_set_gate(132LL, &syscallisr, 8LL, 142LL);
result = idt_set_gate(14LL, &page_fault_handler, 8LL, 142LL);
_enable();
return result;
}

original_code:
void arch_init()
{
 asm("cli");
 debug_puts("arch_init()\n");
 ARCH[0] = 'x';
 ARCH[1] = '8';
 ARCH[2] = '6';
 ARCH[3] = '\0';
 cpu_vendor_name(CPU_VENDOR);
 gdt_install();
 idt_install();
 isrs_install();
 irq_install();
 timer_init();
 clock_init();
    idt_set_gate(0x84, (uint32_t) syscallisr, 0x08, 0x8E);
  idt_set_gate(14, (uint32_t) page_fault_handler, 0x08, 0x8E);
 asm("sti");
}

canonical_original_code:
void arch_init()
{
 asm("cli");
 debug_puts("arch_init()\n");
 ARCH[0] = 'x';
 ARCH[1] = '8';
 ARCH[2] = '6';
 ARCH[3] = '\0';
 cpu_vendor_name(CPU_VENDOR);
 gdt_install();
 idt_install();
 isrs_install();
 irq_install();
 timer_init();
 clock_init();
    idt_set_gate(0x84, (unsigned int) syscallisr, 0x08, 0x8E);
  idt_set_gate(14, (unsigned int) page_fault_handler, 0x08, 0x8E);
 asm("sti");
}


decompiled_code:
void __noreturn arch_shutdown()
{
_disable();
__halt();
}

canonical_decompiled_code:
void __noreturn func1()
{
_disable();
__halt();
}

original_code:
void arch_shutdown()
{
 asm("cli");
 asm("hlt");
}


decompiled_code:
void arch_reboot()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void arch_reboot()
{
}

canonical_original_code:
void arch_reboot()
{
}


decompiled_code:
void arch_standby()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void arch_standby()
{
}

canonical_original_code:
void arch_standby()
{
}


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

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

original_code:
uint32_t initramfs_umount(inode_t *root)
{
 return 1;
}

canonical_original_code:
unsigned int initramfs_umount(struct inode_p *root)
{
 return 1;
}

variable_types: struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *


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

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

original_code:
uint32_t initramfs_mount(char *dev, uint32_t flags, inode_t *root)
{
 return 1;
}

canonical_original_code:
unsigned int initramfs_mount(char *dev, unsigned int flags, struct inode_p *root)
{
 return 1;
}

variable_types:
dev
char *

variable_types:
flags
unsigned int


decompiled_code:
__int64 __fastcall initramfs_read(__int64 a1, _BYTE *a2, unsigned int a3, unsigned __int64 a4)
{
__int64 v6; // rsi
_BYTE *v8; // rdx
__int64 result; // rax
unsigned __int64 v10; // r9
char v11; // si

v6 = *(_QWORD *)(a1 + 264);
if ( a3 )
{
v8 = a2;
LODWORD(result) = 0;
v10 = mod_addr + (unsigned int)a4 + (unsigned __int64)*(unsigned int *)(v6 + 44) - a4;
while ( 1 )
{
if ( *(unsigned int *)(v6 + 40) <= a4 )
{
*v8 = 0;
return (unsigned int)result;
}
v11 = *(_BYTE *)(v10 + a4);
LODWORD(result) = result + 1;
++v8;
++a4;
*(v8 - 1) = v11;
if ( (_DWORD)result == a3 )
break;
v6 = *(_QWORD *)(a1 + 264);
}
a2 += (int)a3;
}
*a2 = 0;
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _BYTE *a2, unsigned int a3, unsigned __int64 a4)
{
__int64 v6; // rsi
_BYTE *v8; // rdx
__int64 result; // rax
unsigned __int64 v10; // r9
char v11; // si

v6 = *(_QWORD *)(a1 + 264);
if ( a3 )
{
v8 = a2;
LODWORD(result) = 0;
v10 = mod_addr + (unsigned int)a4 + (unsigned __int64)*(unsigned int *)(v6 + 44) - a4;
while ( 1 )
{
if ( *(unsigned int *)(v6 + 40) <= a4 )
{
*v8 = 0;
return (unsigned int)result;
}
v11 = *(_BYTE *)(v10 + a4);
LODWORD(result) = result + 1;
++v8;
++a4;
*(v8 - 1) = v11;
if ( (_DWORD)result == a3 )
break;
v6 = *(_QWORD *)(a1 + 264);
}
a2 += (int)a3;
}
*a2 = 0;
return a3;
}

original_code:
uint32_t initramfs_read(inode_t *node, char *buf, uint32_t size, uint64_t offset)
{
 int i;
 char *data = (char *) (mod_addr + (((initramfs_node_t *) (node->fs_node))->data));
 data = data + (uint32_t) offset;
 for(i = 0; i < size; i++)
 {
  if((offset + i) >= (((initramfs_node_t *) (node->fs_node))->size))
  {
   buf[i] = '\0';
   return i;
  }
  buf[i] = *data;
  data++;
 }
 buf[i] = '\0';
 return size;
}

canonical_original_code:
unsigned int initramfs_read(struct inode_p *node, char *buf, unsigned int size, unsigned long long offset)
{
 int i;
 char *data = (char *) (mod_addr + (((initramfs_node_t *) (node->fs_node))->data));
 data = data + (unsigned int) offset;
 for(i = 0; i < size; i++)
 {
  if((offset + i) >= (((struct initramfs_node_t *) (node->fs_node))->size))
  {
   buf[i] = '\0';
   return i;
  }
  buf[i] = *data;
  data++;
 }
 buf[i] = '\0';
 return size;
}

variable_types:
buf
char *

variable_types:
size
unsigned int

variable_types:
offset
unsigned long long

variable_types: i int

variable_types:
data
char *

user_defined_types: struct initramfs_node_t { unsigned int identify; char name[32]; unsigned int n; unsigned int size; unsigned int data; }


decompiled_code:
__int64 __fastcall initramfs_readdir(__int64 a1, unsigned int a2, __int64 a3)
{
__int64 v4; // rbx
__int64 result; // rax

v4 = mod_addr + 48LL * a2;
strcpy((char *)a3, src);
result = 0LL;
if ( *(_DWORD *)v4 == 11259375 )
{
strcpy((char *)a3, (const char *)(v4 + 4));
*(_DWORD *)(a3 + 256) = *(_DWORD *)(v4 + 36);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2, __int64 a3)
{
__int64 v4; // rbx
__int64 result; // rax

v4 = mod_addr + 48LL * a2;
strcpy((char *)a3, src);
result = 0LL;
if ( *(_DWORD *)v4 == 11259375 )
{
strcpy((char *)a3, (const char *)(v4 + 4));
*(_DWORD *)(a3 + 256) = *(_DWORD *)(v4 + 36);
result = 1LL;
}
return result;
}

original_code:
uint32_t initramfs_readdir(inode_t *root, uint32_t n, struct dirent *d)
{
 uint32_t i;
 initramfs_node_t *node = (initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * n));
 strcpy(d->name, "\0");
 if(node->identify == 0xABCDEF)
 {
  strcpy(d->name, node->name);
  d->inode = node->n;
  return 1;
 }
 else
  return 0;
}

canonical_original_code:
unsigned int initramfs_readdir(struct inode_p *root, unsigned int n, struct dirent *d)
{
 unsigned int i;
 struct initramfs_node_t *node = (initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * n));
 strcpy(d->name, "\0");
 if(node->identify == 0xABCDEF)
 {
  strcpy(d->name, node->name);
  d->inode = node->n;
  return 1;
 }
 else
  return 0;
}

variable_types:
n
unsigned int

variable_types: struct dirent { char name[255]; unsigned int inode; } *

variable_types:
i
unsigned int

variable_types: struct initramfs_node_t { unsigned int identify; char name[32]; unsigned int n; unsigned int size; unsigned int data; } *


decompiled_code:
__int64 __fastcall initramfs_open(__int64 a1)
{
signed int i; // ebx
__int64 result; // rax
_DWORD v3[74]; // [rsp+0h] [rbp-128h] BYREF

for ( i = 0; ; ++i )
{
result = initramfs_readdir(0LL, i, (__int64)v3);
if ( !(_DWORD)result )
break;
if ( v3[64] == *(_DWORD *)(a1 + 256) )
{
*(_QWORD *)(a1 + 264) = mod_addr + 48LL * i;
return 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
signed int i; // ebx
__int64 result; // rax
_DWORD v3[74]; // [rsp+0h] [rbp-128h] BYREF

for ( i = 0; ; ++i )
{
result = func3(0LL, i, (__int64)v3);
if ( !(_DWORD)result )
break;
if ( v3[64] == *(_DWORD *)(a1 + 256) )
{
*(_QWORD *)(a1 + 264) = mod_addr + 48LL * i;
return 1LL;
}
}
return result;
}

original_code:
uint32_t initramfs_open(inode_t *node, char *flags)
{
 int i = 0;
 struct dirent dir;
 while(initramfs_readdir(0, i, &dir) != 0)
 {
  if(dir.inode == node->inode_n)
  {
   node->fs_node = (void *) (initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * i));
   return 1;
  }
  i++;
 }
 return 0;
}

canonical_original_code:
unsigned int initramfs_open(struct inode_p *node, char *flags)
{
 int i = 0;
 struct dirent dir;
 while(initramfs_readdir(0, i, &dir) != 0)
 {
  if(dir.inode == node->inode_n)
  {
   node->fs_node = (void *) (struct initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * i));
   return 1;
  }
  i++;
 }
 return 0;
}

variable_types:
flags
char *

variable_types: struct dirent { char name[255]; unsigned int inode; }


original_code:
uint32_t initramfs_get_node(inode_t *root, uint32_t node_n, inode_t **node)
{
 int i = 0;
 initramfs_node_t *nod;
 while(1)
 {
  nod = (initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * i));
  if(nod->identify == 0xABCDEF)
  {
   if(nod->n == node_n)
   {
    *node = fs_create_node(nod->name, root, 1, 1);
    (*node)->inode_n = nod->n;
    (*node)->fs_node = nod;
    return 1;
   }
  }
  i++;
 }
 return 0;
}

canonical_original_code:
unsigned int initramfs_get_node(struct inode_p *root, unsigned int node_n, struct inode_p **node)
{
 int i = 0;
 struct initramfs_node_t *nod;
 while(1)
 {
  nod = (struct initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * i));
  if(nod->identify == 0xABCDEF)
  {
   if(nod->n == node_n)
   {
    *node = fs_create_node(nod->name, root, 1, 1);
    (*node)->inode_n = nod->n;
    (*node)->fs_node = nod;
    return 1;
   }
  }
  i++;
 }
 return 0;
}

variable_types:
node
struct inode_p **


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

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

original_code:
uint32_t crc32_make(uint8_t *blocks, uint32_t size)
{
 uint32_t crc_code = 0x00000000;
 return crc_code;
}

canonical_original_code:
unsigned int crc32_make(unsigned char *blocks, unsigned int size)
{
 unsigned int crc_code = 0x00000000;
 return crc_code;
}

variable_types:
blocks
unsigned char *


original_code:
uint32_t crc32_check(uint32_t crc32, uint8_t *blocks, uint32_t size)
{
 uint32_t crc_gen = crc32_make(blocks, size);
 uint32_t sindrome = crc32 ^ crc_gen;
 if(sindrome == 0) return sindrome;
 uint32_t block = sindrome / 8;
 uint32_t bit = sindrome % 8;
 blocks[block] = blocks[block] + ~(blocks[block] & (1 << bit)) << bit;
 return sindrome;
}

canonical_original_code:
unsigned int crc32_check(unsigned int crc32, unsigned char *blocks, unsigned int size)
{
 unsigned int crc_gen = crc32_make(blocks, size);
 unsigned int sindrome = crc32 ^ crc_gen;
 if(sindrome == 0) return sindrome;
 unsigned int block = sindrome / 8;
 unsigned int bit = sindrome % 8;
 blocks[block] = blocks[block] + ~(blocks[block] & (1 << bit)) << bit;
 return sindrome;
}

variable_types:
sindrome
unsigned int

variable_types:
block
unsigned int

variable_types:
bit
unsigned int


decompiled_code:
void rs232_probe()
{
;
}

original_code:
uint32_t rs232_probe(device_t *dev)
{
}

canonical_original_code:
unsigned int rs232_probe(struct device_p *dev)
{
}

variable_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *


decompiled_code:
__int64 rs232_free()
{
handler_unreg(4LL);
handler_unreg(3LL);
devfs_unreg_device("ser0");
devfs_unreg_device("ser1");
devfs_unreg_device("ser2");
devfs_unreg_device("ser3");
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
handler_unreg(4LL);
handler_unreg(3LL);
devfs_unreg_device("ser0");
devfs_unreg_device("ser1");
devfs_unreg_device("ser2");
devfs_unreg_device("ser3");
return 0LL;
}

original_code:
uint32_t rs232_free()
{
 handler_unreg(4);
 handler_unreg(3);
 devfs_unreg_device("ser0");
 devfs_unreg_device("ser1");
 devfs_unreg_device("ser2");
 devfs_unreg_device("ser3");
 return 0;
}

canonical_original_code:
unsigned int rs232_free()
{
 handler_unreg(4);
 handler_unreg(3);
 devfs_unreg_device("ser0");
 devfs_unreg_device("ser1");
 devfs_unreg_device("ser2");
 devfs_unreg_device("ser3");
 return 0;
}


decompiled_code:
__int64 __fastcall rs232_callback(__int64 a1)
{
char v2; // al
__int64 v3; // rdx
char v4; // al
__int64 v5; // rdx
char v6; // al
__int64 v7; // rdx
char v8; // al
__int64 v9; // rdx

if ( (io_inb(1021LL) & 1) != 0 )
{
v2 = io_inb(1016LL);
v3 = (unsigned __int8)combuf[258];
++combuf[256];
combuf[v3] = v2;
combuf[258] = v3 + 1;
if ( (io_inb(765LL) & 1) == 0 )
{
LABEL_3:
if ( (io_inb(1005LL) & 1) == 0 )
goto LABEL_4;
LABEL_8:
v6 = io_inb(1000LL);
v7 = (unsigned __int8)combuf[776];
++combuf[774];
combuf[v7 + 518] = v6;
combuf[776] = v7 + 1;
if ( (io_inb(749LL) & 1) == 0 )
return modem_callback(a1);
goto LABEL_9;
}
}
else if ( (io_inb(765LL) & 1) == 0 )
{
goto LABEL_3;
}
v4 = io_inb(760LL);
v5 = (unsigned __int8)combuf[517];
++combuf[515];
combuf[v5 + 259] = v4;
combuf[517] = v5 + 1;
if ( (io_inb(1005LL) & 1) != 0 )
goto LABEL_8;
LABEL_4:
if ( (io_inb(749LL) & 1) == 0 )
return modem_callback(a1);
LABEL_9:
v8 = io_inb(744LL);
v9 = (unsigned __int8)combuf[1035];
++combuf[1033];
combuf[v9 + 777] = v8;
combuf[1035] = v9 + 1;
return modem_callback(a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
char v2; // al
__int64 v3; // rdx
char v4; // al
__int64 v5; // rdx
char v6; // al
__int64 v7; // rdx
char v8; // al
__int64 v9; // rdx

if ( (io_inb(1021LL) & 1) != 0 )
{
v2 = io_inb(1016LL);
v3 = (unsigned __int8)combuf[258];
++combuf[256];
combuf[v3] = v2;
combuf[258] = v3 + 1;
if ( (io_inb(765LL) & 1) == 0 )
{
LABEL_3:
if ( (io_inb(1005LL) & 1) == 0 )
goto LABEL_4;
LABEL_8:
v6 = io_inb(1000LL);
v7 = (unsigned __int8)combuf[776];
++combuf[774];
combuf[v7 + 518] = v6;
combuf[776] = v7 + 1;
if ( (io_inb(749LL) & 1) == 0 )
return modem_callback(a1);
goto LABEL_9;
}
}
else if ( (io_inb(765LL) & 1) == 0 )
{
goto LABEL_3;
}
v4 = io_inb(760LL);
v5 = (unsigned __int8)combuf[517];
++combuf[515];
combuf[v5 + 259] = v4;
combuf[517] = v5 + 1;
if ( (io_inb(1005LL) & 1) != 0 )
goto LABEL_8;
LABEL_4:
if ( (io_inb(749LL) & 1) == 0 )
return modem_callback(a1);
LABEL_9:
v8 = io_inb(744LL);
v9 = (unsigned __int8)combuf[1035];
++combuf[1033];
combuf[v9 + 777] = v8;
combuf[1035] = v9 + 1;
return modem_callback(a1);
}

original_code:
static void rs232_callback(regs_t *reg)
{
 if((io_inb(0x3f8 + 5) & 1) != 0)
 {
  combuf[0].buf[combuf[0].point] = io_inb(0x3f8);
  combuf[0].size++;
  combuf[0].point++;
 }
 if((io_inb(0x2f8 + 5) & 1) != 0)
 {
  combuf[1].buf[combuf[1].point] = io_inb(0x2f8);
  combuf[1].size++;
  combuf[1].point++;
 }
 if((io_inb(0x3e8 + 5) & 1) != 0)
 {
  combuf[2].buf[combuf[2].point] = io_inb(0x3e8);
  combuf[2].size++;
  combuf[2].point++;
 }
 if((io_inb(0x2e8 + 5) & 1) != 0)
 {
  combuf[3].buf[combuf[3].point] = io_inb(0x2e8);
  combuf[3].size++;
  combuf[3].point++;
 }
  modem_callback(reg);
}

canonical_original_code:
static void rs232_callback(struct regs_t *reg)
{
 if((io_inb(0x3f8 + 5) & 1) != 0)
 {
  combuf[0].buf[combuf[0].point] = io_inb(0x3f8);
  combuf[0].size++;
  combuf[0].point++;
 }
 if((io_inb(0x2f8 + 5) & 1) != 0)
 {
  combuf[1].buf[combuf[1].point] = io_inb(0x2f8);
  combuf[1].size++;
  combuf[1].point++;
 }
 if((io_inb(0x3e8 + 5) & 1) != 0)
 {
  combuf[2].buf[combuf[2].point] = io_inb(0x3e8);
  combuf[2].size++;
  combuf[2].point++;
 }
 if((io_inb(0x2e8 + 5) & 1) != 0)
 {
  combuf[3].buf[combuf[3].point] = io_inb(0x2e8);
  combuf[3].size++;
  combuf[3].point++;
 }
  modem_callback(reg);
}

variable_types: struct regs_t { unsigned int edi; unsigned int ds; unsigned int which_int; unsigned int eip; } *


decompiled_code:
__int64 __fastcall rs232_init_port(unsigned __int16 a1)
{
io_outb((unsigned __int16)(a1 + 1), 1LL);
io_outb((unsigned __int16)(a1 + 3), 128LL);
io_outb(a1, 3LL);
io_outb((unsigned __int16)(a1 + 1), 0LL);
io_outb((unsigned __int16)(a1 + 3), 3LL);
io_outb((unsigned __int16)(a1 + 2), 199LL);
return io_outb((unsigned __int16)(a1 + 4), 11LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int16 a1)
{
io_outb((unsigned __int16)(a1 + 1), 1LL);
io_outb((unsigned __int16)(a1 + 3), 128LL);
io_outb(a1, 3LL);
io_outb((unsigned __int16)(a1 + 1), 0LL);
io_outb((unsigned __int16)(a1 + 3), 3LL);
io_outb((unsigned __int16)(a1 + 2), 199LL);
return io_outb((unsigned __int16)(a1 + 4), 11LL);
}

original_code:
void rs232_init_port(uint32_t port)
{
 io_outb(port + 1, 0x01);
 io_outb(port + 3, 0x80);
 io_outb(port + 0, 0x03);
 io_outb(port + 1, 0x00);
 io_outb(port + 3, 0x03);
 io_outb(port + 2, 0xC7);
 io_outb(port + 4, 0x0B);
}

canonical_original_code:
void rs232_init_port(unsigned int port)
{
 io_outb(port + 1, 0x01);
 io_outb(port + 3, 0x80);
 io_outb(port + 0, 0x03);
 io_outb(port + 1, 0x00);
 io_outb(port + 3, 0x03);
 io_outb(port + 2, 0xC7);
 io_outb(port + 4, 0x0B);
}

variable_types:
port
unsigned int


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

rs232_init_port(0x3F8u);
rs232_init_port(0x2F8u);
rs232_init_port(0x3E8u);
rs232_init_port(0x2E8u);
v0 = combuf;
do
{
v0[258] = 0;
v0 += 259;
*(v0 - 3) = 0;
*(v0 - 2) = 0;
}
while ( v0 != &combuf[1036] );
handler_reg(4LL, rs232_callback);
handler_reg(3LL, rs232_callback);
devfs_reg_device(0LL, 0LL, "ser0");
devfs_reg_device(0LL, 0LL, "ser1");
devfs_reg_device(0LL, 0LL, "ser2");
devfs_reg_device(0LL, 0LL, "ser3");
return 0LL;
}

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

func3(0x3F8u);
func3(0x2F8u);
func3(0x3E8u);
func3(0x2E8u);
v0 = combuf;
do
{
v0[258] = 0;
v0 += 259;
*(v0 - 3) = 0;
*(v0 - 2) = 0;
}
while ( v0 != &combuf[1036] );
handler_reg(4LL, rs232_callback);
handler_reg(3LL, rs232_callback);
devfs_reg_device(0LL, 0LL, "ser0");
devfs_reg_device(0LL, 0LL, "ser1");
devfs_reg_device(0LL, 0LL, "ser2");
devfs_reg_device(0LL, 0LL, "ser3");
return 0LL;
}

original_code:
uint32_t rs232_init()
{
 int x;
 rs232_init_port(0x3f8);
 rs232_init_port(0x2f8);
 rs232_init_port(0x3e8);
 rs232_init_port(0x2e8);
 for(x = 0; x < 4; x++)
  combuf[x].where = combuf[x].size = combuf[x].point = 0;
 handler_reg(4, &rs232_callback);
 handler_reg(3, &rs232_callback);
 devfs_reg_device(0, 0, "ser0");
 devfs_reg_device(0, 0, "ser1");
 devfs_reg_device(0, 0, "ser2");
 devfs_reg_device(0, 0, "ser3");
 return 0;
}

canonical_original_code:
unsigned int rs232_init()
{
 int x;
 rs232_init_port(0x3f8);
 rs232_init_port(0x2f8);
 rs232_init_port(0x3e8);
 rs232_init_port(0x2e8);
 for(x = 0; x < 4; x++)
  combuf[x].where = combuf[x].size = combuf[x].point = 0;
 handler_reg(4, &rs232_callback);
 handler_reg(3, &rs232_callback);
 devfs_reg_device(0, 0, "ser0");
 devfs_reg_device(0, 0, "ser1");
 devfs_reg_device(0, 0, "ser2");
 devfs_reg_device(0, 0, "ser3");
 return 0;
}

variable_types: x int


decompiled_code:
__int64 __fastcall rs232_send(unsigned __int16 a1, unsigned __int8 a2)
{
while ( (io_inb((unsigned __int16)(a1 + 5)) & 0x20) == 0 )
;
return io_outb(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int16 a1, unsigned __int8 a2)
{
while ( (io_inb((unsigned __int16)(a1 + 5)) & 0x20) == 0 )
;
return io_outb(a1, a2);
}

original_code:
void rs232_send(uint32_t port, uint8_t data)
{
 while ((io_inb(port + 5) & 0x20) == 0);
 io_outb(port, data);
}

canonical_original_code:
void rs232_send(unsigned int port, unsigned char data)
{
 while ((io_inb(port + 5) & 0x20) == 0);
 io_outb(port, data);
}

variable_types:
data
unsigned char


original_code:
uint8_t rs232_receive(uint32_t port)
{
 char ch = 0;
 switch(port)
 {
  case 0x3f8:
   if(combuf[0].size > 0)
   {
    ch = combuf[0].buf[combuf[0].where];
    combuf[0].where++;
    combuf[0].size--;
   }
   return ch;
  case 0x2f8:
   if(combuf[1].size > 0)
   {
    ch = combuf[1].buf[combuf[1].where];
    combuf[1].where++;
    combuf[1].size--;
   }
   return ch;
  case 0x3e8:
   if(combuf[2].size > 0)
   {
    ch = combuf[2].buf[combuf[2].where];
    combuf[2].where++;
    combuf[2].size--;
   }
   return ch;
  case 0x2e8:
   if(combuf[3].size > 0)
   {
    ch = combuf[3].buf[combuf[3].where];
    combuf[3].where++;
    combuf[3].size--;
   }
   return ch;
 }
}

canonical_original_code:
unsigned char rs232_receive(unsigned int port)
{
 char ch = 0;
 switch(port)
 {
  case 0x3f8:
   if(combuf[0].size > 0)
   {
    ch = combuf[0].buf[combuf[0].where];
    combuf[0].where++;
    combuf[0].size--;
   }
   return ch;
  case 0x2f8:
   if(combuf[1].size > 0)
   {
    ch = combuf[1].buf[combuf[1].where];
    combuf[1].where++;
    combuf[1].size--;
   }
   return ch;
  case 0x3e8:
   if(combuf[2].size > 0)
   {
    ch = combuf[2].buf[combuf[2].where];
    combuf[2].where++;
    combuf[2].size--;
   }
   return ch;
  case 0x2e8:
   if(combuf[3].size > 0)
   {
    ch = combuf[3].buf[combuf[3].where];
    combuf[3].where++;
    combuf[3].size--;
   }
   return ch;
 }
}

variable_types: ch char

return_type: unsigned char


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

original_code:
uint32_t devfs_umount(inode_t *root)
{
 return 1;
}

canonical_original_code:
unsigned int devfs_umount(struct inode_p *root)
{
 return 1;
}

variable_types: struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *


decompiled_code:
__int64 __fastcall devfs_mount(__int64 a1, __int64 a2, __int64 a3)
{
*(_QWORD *)(a3 + 312) = devfs_childs;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
*(_QWORD *)(a3 + 312) = devfs_childs;
return 1LL;
}

original_code:
uint32_t devfs_mount(char *dev, uint32_t flags, inode_t *root)
{
 root->childs = devfs_childs;
 return 1;
}

canonical_original_code:
unsigned int devfs_mount(char *dev, unsigned int flags, struct inode_p *root)
{
 root->childs = devfs_childs;
 return 1;
}

variable_types:
dev
char *

variable_types:
flags
unsigned int


decompiled_code:
__int64 __fastcall devfs_get_node(__int64 a1, int a2, __int64 *a3)
{
__int64 result; // rax

result = *(_QWORD *)(devfs_root + 312);
if ( !result )
return 0LL;
while ( *(_DWORD *)(result + 256) != a2 )
{
result = *(_QWORD *)(result + 288);
if ( !result )
return result;
}
*a3 = result;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2, __int64 *a3)
{
__int64 result; // rax

result = *(_QWORD *)(devfs_root + 312);
if ( !result )
return 0LL;
while ( *(_DWORD *)(result + 256) != a2 )
{
result = *(_QWORD *)(result + 288);
if ( !result )
return result;
}
*a3 = result;
return 1LL;
}

original_code:
uint32_t devfs_get_node(inode_t *root, uint32_t i, inode_t **child)
{
 inode_t *tmp = devfs_root->childs;
 while(tmp != 0)
 {
  if(tmp->inode_n == i)
  {
   *child = tmp;
   return 1;
  }
  tmp = tmp->next;
 }
 return 0;
}

canonical_original_code:
unsigned int devfs_get_node(struct inode_p *root, unsigned int i, struct inode_p **child)
{
 struct inode_p *tmp = devfs_root->childs;
 while(tmp != 0)
 {
  if(tmp->inode_n == i)
  {
   *child = tmp;
   return 1;
  }
  tmp = tmp->next;
 }
 return 0;
}

variable_types:
i
unsigned int

variable_types:
child
struct inode_p **


decompiled_code:
_BOOL8 __fastcall devfs_open(__int64 a1)
{
return *(_QWORD *)(a1 + 264) != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1)
{
return *(_QWORD *)(a1 + 264) != 0LL;
}

original_code:
uint32_t devfs_open(inode_t *node, char *flags)
{
 int i = 0;
 struct dirent dir;
 if(node->fs_node == 0)
  return 0;
 return 1;
}

canonical_original_code:
unsigned int devfs_open(struct inode_p *node, char *flags)
{
 int i = 0;
 struct dirent dir;
 if(node->fs_node == 0)
  return 0;
 return 1;
}

variable_types:
flags
char *

variable_types: i int

variable_types: struct dirent { char name[255]; unsigned int inode; }


original_code:
uint32_t devfs_read(inode_t *node, char *buf, uint32_t size, uint64_t offset)
{
 if( (node->fs_node != 0) &&
  (((devfs_node_t *) (node->fs_node))->driver != 0) &&
  (((devfs_node_t *) (node->fs_node))->device != 0) &&
  ((((devfs_node_t *) (node->fs_node))->driver)->read != 0))
 {
  return (((devfs_node_t *) (node->fs_node))->driver)->read(((devfs_node_t *) (node->fs_node))->device, buf, size, offset);
 }
 return 0;
}

canonical_original_code:
unsigned int devfs_read(struct inode_p *node, char *buf, unsigned int size, unsigned long long offset)
{
 if( (node->fs_node != 0) &&
  (((struct devfs_node_t *) (node->fs_node))->driver != 0) &&
  (((struct devfs_node_t *) (node->fs_node))->device != 0) &&
  ((((struct devfs_node_t *) (node->fs_node))->driver)->read != 0))
 {
  return (((struct devfs_node_t *) (node->fs_node))->driver)->read(((struct devfs_node_t *) (node->fs_node))->device, buf, size, offset);
 }
 return 0;
}

variable_types:
buf
char *

variable_types:
size
unsigned int

variable_types:
offset
unsigned long long

user_defined_types: struct devfs_node_t { struct driver_p *driver; struct device_p *device; }


original_code:
uint32_t devfs_write(inode_t *node, char *buf, uint32_t size, uint64_t offset)
{
 if( (node->fs_node != 0) &&
  (((devfs_node_t *) (node->fs_node))->driver != 0) &&
  (((devfs_node_t *) (node->fs_node))->device != 0) &&
  ((((devfs_node_t *) (node->fs_node))->driver)->write != 0))
 {
  return (((devfs_node_t *) (node->fs_node))->driver)->write(((devfs_node_t *) (node->fs_node))->device, buf, size, offset);
 }
 return 0;
}

canonical_original_code:
unsigned int devfs_write(struct inode_p *node, char *buf, unsigned int size, unsigned long long offset)
{
 if( (node->fs_node != 0) &&
  (((struct devfs_node_t *) (node->fs_node))->driver != 0) &&
  (((struct devfs_node_t *) (node->fs_node))->device != 0) &&
  ((((struct devfs_node_t *) (node->fs_node))->driver)->write != 0))
 {
  return (((struct devfs_node_t *) (node->fs_node))->driver)->write(((struct devfs_node_t *) (node->fs_node))->device, buf, size, offset);
 }
 return 0;
}


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

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

original_code:
uint32_t devfs_close(inode_t *node)
{
 return 0;
}

canonical_original_code:
unsigned int devfs_close(struct inode_p *node)
{
 return 0;
}


decompiled_code:
__int64 __fastcall devfs_readdir(__int64 a1, unsigned int a2, __int64 a3)
{
__int64 v3; // rbx
unsigned int v5; // eax

v3 = *(_QWORD *)(devfs_root + 312);
if ( v3 )
{
if ( !a2 )
{
LABEL_7:
strcpy((char *)a3, (const char *)v3);
*(_DWORD *)(a3 + 256) = *(_DWORD *)(v3 + 256);
return 1LL;
}
v5 = 0;
while ( 1 )
{
v3 = *(_QWORD *)(v3 + 288);
++v5;
if ( !v3 || a2 < v5 )
break;
if ( a2 == v5 )
goto LABEL_7;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2, __int64 a3)
{
__int64 v3; // rbx
unsigned int v5; // eax

v3 = *(_QWORD *)(devfs_root + 312);
if ( v3 )
{
if ( !a2 )
{
LABEL_7:
strcpy((char *)a3, (const char *)v3);
*(_DWORD *)(a3 + 256) = *(_DWORD *)(v3 + 256);
return 1LL;
}
v5 = 0;
while ( 1 )
{
v3 = *(_QWORD *)(v3 + 288);
++v5;
if ( !v3 || a2 < v5 )
break;
if ( a2 == v5 )
goto LABEL_7;
}
}
return 0LL;
}

original_code:
uint32_t devfs_readdir(inode_t *root, uint32_t n, struct dirent *d)
{
 inode_t *childs = devfs_root->childs;
 unsigned i = 0;
 while(childs != 0 && i <= n)
 {
  if(i == n)
  {
   strcpy(d->name, childs->name);
   d->inode = childs->inode_n;
   return 1;
  }
  i++;
  childs = childs->next;
 }
 return 0;
}

canonical_original_code:
unsigned int devfs_readdir(struct inode_p *root, unsigned int n, struct dirent *d)
{
 struct inode_p *childs = devfs_root->childs;
 unsigned int i = 0;
 while(childs != 0 && i <= n)
 {
  if(i == n)
  {
   strcpy(d->name, childs->name);
   d->inode = childs->inode_n;
   return 1;
  }
  i++;
  childs = childs->next;
 }
 return 0;
}

variable_types:
n
unsigned int

variable_types: struct dirent { char name[255]; unsigned int inode; } *


decompiled_code:
__int64 __fastcall devfs_reg_device(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbp
signed int v5; // eax

debug_puts("devfs_reg_device()\n");
if ( a3 )
{
v4 = fs_create_node(a3, devfs_root, 1LL, 0LL);
v5 = (unsigned int)malloc(0x10uLL);
*(_QWORD *)(v4 + 264) = v5;
*(_QWORD *)v5 = a2;
*(_QWORD *)&algn_6[v5 + 2] = a1;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbp
signed int v5; // eax

debug_puts("devfs_reg_device()\n");
if ( a3 )
{
v4 = fs_create_node(a3, devfs_root, 1LL, 0LL);
v5 = (unsigned int)malloc(0x10uLL);
*(_QWORD *)(v4 + 264) = v5;
*(_QWORD *)v5 = a2;
*(_QWORD *)&algn_6[v5 + 2] = a1;
}
return 0LL;
}

original_code:
uint32_t devfs_reg_device(device_t *dev, driver_t *drv, char *name)
{
 debug_puts("devfs_reg_device()\n");
 if(name == 0)
  return 0;
 inode_t *devv = fs_create_node(name, devfs_root, 1, 0);
 (devv->fs_node) = (void *) malloc(sizeof(devfs_node_t));
 ((devfs_node_t *) (devv->fs_node))->driver = drv;
 ((devfs_node_t *) (devv->fs_node))->device = dev;
 return 0;
}

canonical_original_code:
unsigned int devfs_reg_device(struct device_p *dev, struct driver_p *drv, char *name)
{
 debug_puts("devfs_reg_device()\n");
 if(name == 0)
  return 0;
 struct inode_p *devv = fs_create_node(name, devfs_root, 1, 0);
 (devv->fs_node) = (void *) malloc(sizeof(devfs_node_t));
 ((struct devfs_node_t *) (devv->fs_node))->driver = drv;
 ((struct devfs_node_t *) (devv->fs_node))->device = dev;
 return 0;
}

variable_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *

variable_types: struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *

variable_types:
name
char *


decompiled_code:
__int64 devfs_unreg_device()
{
return debug_puts("devfs_unreg_device()\n");
}

canonical_decompiled_code:
__int64 func9()
{
return debug_puts("devfs_unreg_device()\n");
}

original_code:
uint32_t devfs_unreg_device(char *name)
{
 debug_puts("devfs_unreg_device()\n");
 inode_t *node = devfs_root->childs;
 inode_t *prev = 0;
 while(prev != 0)
 {
  if(strcmp(node->name, name) == 0)
  {
   if(prev == 0)
    devfs_root->childs = node->next;
   else
    prev->next = node->next;
   free(node);
   return 0;
  }
  prev = node;
  node = node->next;
 }
}

canonical_original_code:
unsigned int devfs_unreg_device(char *name)
{
 debug_puts("devfs_unreg_device()\n");
 struct inode_p *node = devfs_root->childs;
 struct inode_p *prev = 0;
 while(prev != 0)
 {
  if(strcmp(node->name, name) == 0)
  {
   if(prev == 0)
    devfs_root->childs = node->next;
   else
    prev->next = node->next;
   free(node);
   return 0;
  }
  prev = node;
  node = node->next;
 }
}


decompiled_code:
size_t __fastcall devfs_find_freen(char *src, char *s)
{
int v2; // er8
size_t result; // rax
unsigned int v4; // er13
__int64 v5; // rbx
unsigned int v6; // eax
char srca[8]; // [rsp+8h] [rbp-50h] BYREF
char dest[72]; // [rsp+10h] [rbp-48h] BYREF

v2 = strcmp(src, ::src);
result = 0LL;
if ( v2 )
{
v4 = 0;
strcpy(s, ::src);
while ( 1 )
{
v5 = *(_QWORD *)(devfs_root + 312);
strcpy(dest, src);
v6 = itoa(v4);
strcpy(srca, (const char *)v6);
strcat(srca, ::src);
strcat(dest, srca);
if ( !v5 )
break;
while ( strcmp(dest, (const char *)v5) )
{
v5 = *(_QWORD *)(v5 + 288);
if ( !v5 )
goto LABEL_9;
}
++v4;
}
LABEL_9:
strcpy(s, dest);
strcat(s, ::src);
result = 0LL;
if ( *s )
result = strlen(s);
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func10(char *src, char *s)
{
int v2; // er8
size_t result; // rax
unsigned int v4; // er13
__int64 v5; // rbx
unsigned int v6; // eax
char srca[8]; // [rsp+8h] [rbp-50h] BYREF
char dest[72]; // [rsp+10h] [rbp-48h] BYREF

v2 = strcmp(src, ::src);
result = 0LL;
if ( v2 )
{
v4 = 0;
strcpy(s, ::src);
while ( 1 )
{
v5 = *(_QWORD *)(devfs_root + 312);
strcpy(dest, src);
v6 = itoa(v4);
strcpy(srca, (const char *)v6);
strcat(srca, ::src);
strcat(dest, srca);
if ( !v5 )
break;
while ( strcmp(dest, (const char *)v5) )
{
v5 = *(_QWORD *)(v5 + 288);
if ( !v5 )
goto LABEL_9;
}
++v4;
}
LABEL_9:
strcpy(s, dest);
strcat(s, ::src);
result = 0LL;
if ( *s )
result = strlen(s);
}
return result;
}

original_code:
uint32_t devfs_find_freen(char *name, char *res)
{
 inode_t *next;
 if(strcmp(name, "\0") != 0)
 {
  char a[32];
  char b[8];
  int i = 0;
  int over = 1;
  strcpy(res, "\0");
  while(over)
  {
   tent:
   next = devfs_root->childs;
   strcpy(a, name);
   strcpy(b, itoa(i));
   strcat(b, "\0");
   strcat(a, b);
   while(next != 0)
   {
    if(strcmp(a, next->name) == 0)
    {
     i++;
     goto tent;
    }
    next = next->next;
   }
   over = 0;
   strcpy(res, a);
   strcat(res, "\0");
  }
  if(res[0] != '\0')
   return strlen(res);
 }
 return 0;
}

canonical_original_code:
unsigned int devfs_find_freen(char *name, char *res)
{
 struct inode_p *next;
 if(strcmp(name, "\0") != 0)
 {
  char a[32];
  char b[8];
  int i = 0;
  int over = 1;
  strcpy(res, "\0");
  while(over)
  {
   tent:
   next = devfs_root->childs;
   strcpy(a, name);
   strcpy(b, itoa(i));
   strcat(b, "\0");
   strcat(a, b);
   while(next != 0)
   {
    if(strcmp(a, next->name) == 0)
    {
     i++;
     goto tent;
    }
    next = next->next;
   }
   over = 0;
   strcpy(res, a);
   strcat(res, "\0");
  }
  if(res[0] != '\0')
   return strlen(res);
 }
 return 0;
}

variable_types:
res
char *

variable_types:
a
char [32]

variable_types:
b
char [8]

variable_types: over int


decompiled_code:
__int64 __fastcall route_add(__int64 a1, const void *a2, const void *a3, const void *a4, char a5, int a6)
{
__int64 v10; // rbx
__int64 v11; // rax

v10 = (int)malloc(0x28uLL);
*(_QWORD *)((char *)&loc_17 + v10 + 1) = a1;
*(_DWORD *)((char *)&loc_E + v10 + 2) = a6;
memcpy((void *)v10, a3, 4uLL);
memcpy((void *)(v10 + 4), a2, 4uLL);
memcpy((void *)(v10 + 8), a4, 4uLL);
v11 = route_table;
*(_BYTE *)(v10 + 13) = a5;
route_table = v10;
*(_QWORD *)(v10 + 32) = v11;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const void *a2, const void *a3, const void *a4, char a5, int a6)
{
__int64 v10; // rbx
__int64 v11; // rax

v10 = (int)malloc(0x28uLL);
*(_QWORD *)((char *)&loc_17 + v10 + 1) = a1;
*(_DWORD *)((char *)&loc_E + v10 + 2) = a6;
memcpy((void *)v10, a3, 4uLL);
memcpy((void *)(v10 + 4), a2, 4uLL);
memcpy((void *)(v10 + 8), a4, 4uLL);
v11 = route_table;
*(_BYTE *)(v10 + 13) = a5;
route_table = v10;
*(_QWORD *)(v10 + 32) = v11;
return 0LL;
}

original_code:
uint32_t route_add( network_iface_t *iface, ip_t dest, ip_t gw,
     ip_t genmask, uint8_t if_net, uint32_t flags)
{
 route_entry_t *re = (route_entry_t *) malloc(sizeof(route_entry_t));
 re->iface = iface;
 re->flags = flags;
 memcpy(re->gw, gw, 4);
 memcpy(re->dest, dest, 4);
 memcpy(re->genmask, genmask, 4);
 re->if_net = if_net;
 re->next = route_table;
 route_table = re;
 return 0;
}

canonical_original_code:
unsigned int route_add(struct network_iface_p *iface, char dest[4], char gw[4], char genmask[4], unsigned char if_net, unsigned int flags)
{
 struct route_entry_p *re = (route_entry_t *) malloc(sizeof(route_entry_t));
 re->iface = iface;
 re->flags = flags;
 memcpy(re->gw, gw, 4);
 memcpy(re->dest, dest, 4);
 memcpy(re->genmask, genmask, 4);
 re->if_net = if_net;
 re->next = route_table;
 route_table = re;
 return 0;
}

variable_types:
dest
char [4]

variable_types:
gw
char [4]

variable_types:
genmask
char [4]

variable_types:
flags
unsigned int

variable_types: struct route_entry_p { char gw[4]; char dest[4]; char genmask[4]; unsigned char addr_len; unsigned char if_net; unsigned int flags; struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; } *iface; struct route_entry_p *next; } *

user_defined_types: struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; }

user_defined_types: struct route_entry_p { char gw[4]; char dest[4]; char genmask[4]; unsigned char addr_len; unsigned char if_net; unsigned int flags; struct network_iface_p *iface; struct route_entry_p *next; }


decompiled_code:
void route_del()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
uint32_t route_del(ip_t dest)
{
}

canonical_original_code:
unsigned int route_del(char dest[4])
{
}


decompiled_code:
__int64 __fastcall route_iget(int a1, __int64 *a2)
{
__int64 result; // rax
int v3; // edx

result = route_table;
*a2 = 0LL;
if ( !result )
return 0LL;
if ( a1 )
{
v3 = 0;
while ( 1 )
{
result = *(_QWORD *)(result + 32);
++v3;
if ( !result )
break;
if ( a1 == v3 )
goto LABEL_7;
}
}
else
{
LABEL_7:
*a2 = result;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, __int64 *a2)
{
__int64 result; // rax
int v3; // edx

result = route_table;
*a2 = 0LL;
if ( !result )
return 0LL;
if ( a1 )
{
v3 = 0;
while ( 1 )
{
result = *(_QWORD *)(result + 32);
++v3;
if ( !result )
break;
if ( a1 == v3 )
goto LABEL_7;
}
}
else
{
LABEL_7:
*a2 = result;
result = 1LL;
}
return result;
}

original_code:
uint32_t route_iget(uint32_t x, route_entry_t **route)
{
 route_entry_t *cf = route_table;
 uint32_t i = 0;
 *route = 0;
 while(cf != 0)
 {
  if(i == x)
  {
   *route = cf;
   return 1;
  }
  i++;
  cf = cf->next;
 }
 return 0;
}

canonical_original_code:
unsigned int route_iget(unsigned int x, struct route_entry_p **route)
{
 struct route_entry_p *cf = route_table;
 unsigned int i = 0;
 *route = 0;
 while(cf != 0)
 {
  if(i == x)
  {
   *route = cf;
   return 1;
  }
  i++;
  cf = cf->next;
 }
 return 0;
}

variable_types:
x
unsigned int

variable_types: struct route_entry_p { char gw[4]; char dest[4]; char genmask[4]; unsigned char addr_len; unsigned char if_net; unsigned int flags; struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; } *iface; struct route_entry_p *next; } **

variable_types:
i
unsigned int


decompiled_code:
void fs_get_abs_path()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
uint32_t fs_get_abs_path(char *path, char *cur, char *dest)
{
}

canonical_original_code:
unsigned int fs_get_abs_path(char *path, char *cur, char *dest)
{
}

variable_types:
path
char *

variable_types:
cur
char *

variable_types:
dest
char *


decompiled_code:
__int64 __fastcall fs_check_name(unsigned __int8 *a1)
{
int v1; // eax
__int64 v2; // rcx
unsigned __int64 v3; // rax

v1 = *a1;
if ( !(_BYTE)v1 )
return 1LL;
v2 = 0x4000000001FFBLL;
while ( 1 )
{
if ( (unsigned __int8)((v1 & 0xDF) - 65) > 0x19u )
{
v3 = (unsigned int)(v1 - 45);
if ( (unsigned __int8)v3 > 0x32u || !_bittest64(&v2, v3) )
break;
}
v1 = *++a1;
if ( !(_BYTE)v1 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 *a1)
{
int v1; // eax
__int64 v2; // rcx
unsigned __int64 v3; // rax

v1 = *a1;
if ( !(_BYTE)v1 )
return 1LL;
v2 = 0x4000000001FFBLL;
while ( 1 )
{
if ( (unsigned __int8)((v1 & 0xDF) - 65) > 0x19u )
{
v3 = (unsigned int)(v1 - 45);
if ( (unsigned __int8)v3 > 0x32u || !_bittest64(&v2, v3) )
break;
}
v1 = *++a1;
if ( !(_BYTE)v1 )
return 1LL;
}
return 0LL;
}

variable_types:
c
char *


original_code:
inode_t *fs_create_node(char *name, inode_t *parent, uint8_t type, uint8_t ow)
{
 if(!fs_check_name(name))
  return (inode_t *) 0;
 inode_t *i = (inode_t *) malloc(sizeof(inode_t));
 strcpy(i->name, name);
 cur_inode_n++;
 i->inode_n = cur_inode_n;
 i->type = type;
 i->childs = 0;
 i->fs_node = 0;
 i->parent = parent;
 i->next = 0;
 i->prev = 0;
 if(parent != 0)
 {
  i->next = parent->childs;
  i->next->prev = i;
  parent->childs = i;
 }
 if(ow == 1) node_n++;
 i->ow = ow;
 return i;
}

canonical_original_code:
struct inode_p *fs_create_node(char *name, struct inode_p *parent, unsigned char type, unsigned char ow)
{
 if(!fs_check_name(name))
  return (struct inode_p *) 0;
 struct inode_p *i = (inode_t *) malloc(sizeof(inode_t));
 strcpy(i->name, name);
 cur_inode_n++;
 i->inode_n = cur_inode_n;
 i->type = type;
 i->childs = 0;
 i->fs_node = 0;
 i->parent = parent;
 i->next = 0;
 i->prev = 0;
 if(parent != 0)
 {
  i->next = parent->childs;
  i->next->prev = i;
  parent->childs = i;
 }
 if(ow == 1) node_n++;
 i->ow = ow;
 return i;
}

variable_types:
name
char *

variable_types:
parent
struct inode_p *

variable_types:
type
unsigned char

variable_types:
ow
unsigned char

variable_types: struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *


decompiled_code:
int __fastcall fs_show_tree(__int64 a1, int a2)
{
int v2; // ebx
__int64 v3; // r12
int result; // eax

v2 = 0;
v3 = *(_QWORD *)(a1 + 312);
if ( a2 )
{
do
{
++v2;
printf(" ");
}
while ( a2 != v2 );
}
result = printf("/%s\n", (const char *)a1);
if ( *(_BYTE *)(a1 + 260) == 2 && v3 )
{
do
{
result = fs_show_tree(v3, (unsigned int)(a2 + 1));
v3 = *(_QWORD *)(v3 + 288);
}
while ( v3 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1, int a2)
{
int v2; // ebx
__int64 v3; // r12
int result; // eax

v2 = 0;
v3 = *(_QWORD *)(a1 + 312);
if ( a2 )
{
do
{
++v2;
printf(" ");
}
while ( a2 != v2 );
}
result = printf("/%s\n", (const char *)a1);
if ( *(_BYTE *)(a1 + 260) == 2 && v3 )
{
do
{
result = func3(v3, (unsigned int)(a2 + 1));
v3 = *(_QWORD *)(v3 + 288);
}
while ( v3 );
}
return result;
}

original_code:
void fs_show_tree(inode_t *start, uint32_t level)
{
 inode_t *childs = start->childs;
 int x;
 for(x = 0; x < level; x++) printf(" ");
 printf("/%s\n",start->name);
 if(start->type == 2)
 {
  while(childs != 0)
  {
   fs_show_tree(childs, level+1);
   childs = childs->next;
  }
 }
}

canonical_original_code:
void fs_show_tree(struct inode_p *start, unsigned int level)
{
 struct inode_p *childs = start->childs;
 int x;
 for(x = 0; x < level; x++) printf(" ");
 printf("/%s\n",start->name);
 if(start->type == 2)
 {
  while(childs != 0)
  {
   fs_show_tree(childs, level+1);
   childs = childs->next;
  }
 }
}

variable_types:
level
unsigned int

variable_types: x int


original_code:
uint32_t fs_tree_cleanup(inode_t *start, int attr)
{
 uint32_t removed = 0;
 if(start->next != 0)
  removed = removed + fs_tree_cleanup(start->next, attr);
 if(start->childs != 0)
  removed = removed + fs_tree_cleanup(start->childs, attr);
 if(start->ow == 1 || !(attr))
  if(start->next == 0)
  {
   start->parent->childs = start->next;
   free(start);
   removed++;
  }
 return removed;
}

canonical_original_code:
unsigned int fs_tree_cleanup(struct inode_p *start, int attr)
{
 unsigned int removed = 0;
 if(start->next != 0)
  removed = removed + fs_tree_cleanup(start->next, attr);
 if(start->childs != 0)
  removed = removed + fs_tree_cleanup(start->childs, attr);
 if(start->ow == 1 || !(attr))
  if(start->next == 0)
  {
   start->parent->childs = start->next;
   free(start);
   removed++;
  }
 return removed;
}

variable_types: attr int

variable_types:
removed
unsigned int


canonical_original_code:
unsigned int fs_split_path(char *path, struct fs_splitted_path *split)
{
 int i = 0;
 int j = 0;
 int x = 0;
 for(i = 0; i < 31; i++) split->list[i][0] = '\0';
 i = 0;
 if(path[0] == '/' && path[1] == '\0')
 {
  split->i = 1;
  strcpy(split->list[0], "/\0");
  return 1;
 }
 while(1)
 {
  if(path[i] == '/' || path[i] == '\0')
  {
   split->list[j][x] = '\0';
   if(i != 0 && x != 0)
   {
    j++;
   }
   x = 0;
   if(path[i] == '\0' || (path[i] == '/' && path[i+1] == '\0')) break;
  }
  else
  {
   split->list[j][x] = path[i];
   x++;
  }
  i++;
 }
 split->i = j;
 return j;
}

variable_types: struct fs_splitted_path { unsigned int i; char list[32][512]; } *

variable_types: i int

variable_types: j int


decompiled_code:
__int64 __fastcall fs_get_node(char *s1, _QWORD *a2)
{
__int64 v2; // rbx
unsigned int v3; // er13
__int64 v4; // rbp
int v6; // eax
_BYTE v7[16440]; // [rsp+0h] [rbp-4038h] BYREF

*a2 = 0LL;
if ( (unsigned int)node_n > 0x400 )
fs_tree_cleanup(fs_root, 1u);
fs_split_path(s1, (__int64)v7);
if ( strcmp(s1, "/") )
{
v2 = *(_QWORD *)(fs_root + 312);
if ( !v2 )
return 0LL;
v3 = 0;
v4 = 0LL;
while ( 1 )
{
if ( !strcmp(&v7[512 * v4 + 4], (const char *)v2) )
{
v4 = ++v3;
v6 = strcmp(&v7[512 * (unsigned __int64)v3 + 4], byte_6820);
*a2 = v2;
if ( !v6 )
return 1LL;
v2 = *(_QWORD *)(v2 + 312);
}
else
{
v2 = *(_QWORD *)(v2 + 288);
}
if ( !v2 )
return 0LL;
}
}
*a2 = fs_root;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *s1, _QWORD *a2)
{
__int64 v2; // rbx
unsigned int v3; // er13
__int64 v4; // rbp
int v6; // eax
_BYTE v7[16440]; // [rsp+0h] [rbp-4038h] BYREF

*a2 = 0LL;
if ( (unsigned int)node_n > 0x400 )
func4(fs_root, 1u);
func5(s1, (__int64)v7);
if ( strcmp(s1, "/") )
{
v2 = *(_QWORD *)(fs_root + 312);
if ( !v2 )
return 0LL;
v3 = 0;
v4 = 0LL;
while ( 1 )
{
if ( !strcmp(&v7[512 * v4 + 4], (const char *)v2) )
{
v4 = ++v3;
v6 = strcmp(&v7[512 * (unsigned __int64)v3 + 4], byte_6820);
*a2 = v2;
if ( !v6 )
return 1LL;
v2 = *(_QWORD *)(v2 + 312);
}
else
{
v2 = *(_QWORD *)(v2 + 288);
}
if ( !v2 )
return 0LL;
}
}
*a2 = fs_root;
return 1LL;
}

original_code:
uint32_t fs_get_node(char *path, inode_t **node)
{
 inode_t *nod;
 *node = 0;
 uint32_t j;
 if(node_n > 1024)
  fs_tree_cleanup(fs_root, 1);
 fs_splitted_path sp;
 fs_split_path(path, &sp);
 if((strcmp(path, "/\0") == 0))
 {
  *node = fs_root;
  return 1;
 }
 nod = fs_root->childs;
 j = 0;
 while(nod != 0)
 {
  if(strcmp(sp.list[j], nod->name) == 0)
  {
   if(strcmp(sp.list[j+1], "\0") == 0)
   {
    *node = nod;
    return 1;
   }
   *node = nod;
   nod = nod->childs;
   j++;
   continue;
  }
  nod = nod->next;
 }
 return 0;
}

canonical_original_code:
unsigned int fs_get_node(char *path, struct inode_p **node)
{
 struct inode_p *nod;
 *node = 0;
 unsigned int j;
 if(node_n > 1024)
  fs_tree_cleanup(fs_root, 1);
 struct fs_splitted_path sp;
 fs_split_path(path, &sp);
 if((strcmp(path, "/\0") == 0))
 {
  *node = fs_root;
  return 1;
 }
 nod = fs_root->childs;
 j = 0;
 while(nod != 0)
 {
  if(strcmp(sp.list[j], nod->name) == 0)
  {
   if(strcmp(sp.list[j+1], "\0") == 0)
   {
    *node = nod;
    return 1;
   }
   *node = nod;
   nod = nod->childs;
   j++;
   continue;
  }
  nod = nod->next;
 }
 return 0;
}

variable_types: struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } **

variable_types:
j
unsigned int

variable_types: struct fs_splitted_path { unsigned int i; char list[32][512]; }


decompiled_code:
__int64 fs_init()
{
unsigned __int64 v0; // rax

v0 = (unsigned int)((_DWORD)&fs_mountpoints + 1560);
do
{
*(_BYTE *)v0 = 0;
v0 += 1568LL;
}
while ( (_UNKNOWN *)v0 != (_UNKNOWN *)((char *)&fs_mountpoints + 26648) );
files_open_n = 1;
file_list = 0LL;
cur_inode_n = 0;
driver_add(&driver_devfs);
node_n = 0;
fs_root = (__int64)fs_create_node((char *)&byte_680F, 0LL, 2, 0);
fs_mount(byte_6820, "/", "tmpfs", 0LL);
devfs_childs = 0LL;
devfs_root = fs_root;
fs_makedir("/dev");
fs_get_node("/dev", &devfs_root);
return fs_mount(byte_6820, "/dev", "devfs", 0LL);
}

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

v0 = (unsigned int)((_DWORD)&fs_mountpoints + 1560);
do
{
*(_BYTE *)v0 = 0;
v0 += 1568LL;
}
while ( (_UNKNOWN *)v0 != (_UNKNOWN *)((char *)&fs_mountpoints + 26648) );
files_open_n = 1;
file_list = 0LL;
cur_inode_n = 0;
driver_add(&driver_devfs);
node_n = 0;
fs_root = (__int64)func2((char *)&byte_680F, 0LL, 2, 0);
fs_mount(byte_6820, "/", "tmpfs", 0LL);
devfs_childs = 0LL;
devfs_root = fs_root;
fs_makedir("/dev");
func6("/dev", &devfs_root);
return fs_mount(byte_6820, "/dev", "devfs", 0LL);
}

original_code:
void fs_init()
{
 int i;
 for(i = 0; i < 16; i++)
  fs_mountpoints[i].used = 0;
 files_open_n = 1;
 file_list = 0;
 cur_inode_n = 0;
 driver_add(&driver_devfs);
 node_n = 0;
 fs_root = fs_create_node("", 0, 2, 0);
 fs_mount("\0", "/", "tmpfs\0", 0);
 devfs_childs = 0;
 devfs_root = fs_root;
 fs_makedir("/dev");
 fs_get_node("/dev", &devfs_root);
 fs_mount("\0", "/dev", "devfs", 0);
}


decompiled_code:
char *__fastcall fs_get_full_path(char *src, char *a2, char *dest)
{
if ( *a2 == 47 )
return strcpy(dest, a2);
strcpy(dest, src);
if ( dest[(unsigned int)strlen(dest) - 1] != 47 )
strcat(dest, "/");
return strcat(dest, a2);
}

canonical_decompiled_code:
char *__fastcall func8(char *src, char *a2, char *dest)
{
if ( *a2 == 47 )
return strcpy(dest, a2);
strcpy(dest, src);
if ( dest[(unsigned int)strlen(dest) - 1] != 47 )
strcat(dest, "/");
return strcat(dest, a2);
}

original_code:
uint32_t fs_get_full_path(char *cur, char *cur2, char *dest)
{
 if(cur2[0] != '/')
 {
  strcpy(dest, cur);
  if(dest[strlen(dest)-1] != '/')
   strcat(dest, "/");
  strcat(dest, cur2);
 }
 else strcpy(dest, cur2);
}

canonical_original_code:
unsigned int fs_get_full_path(char *cur, char *cur2, char *dest)
{
 if(cur2[0] != '/')
 {
  strcpy(dest, cur);
  if(dest[strlen(dest)-1] != '/')
   strcat(dest, "/");
  strcat(dest, cur2);
 }
 else strcpy(dest, cur2);
}

variable_types:
cur
char *

variable_types:
dest
char *


repo: mangrish/university-projects

decompiled_code:
char *__fastcall next_token(char *a1)
{
const unsigned __int16 *v2; // rax
__int64 v3; // rdx
__int64 v4; // rdx

v2 = *_ctype_b_loc();
do
v3 = *a1++;
while ( (v2[v3] & 0x2000) != 0 );
do
v4 = *a1++;
while ( (v2[v4] & 0x2000) == 0 );
return a1;
}

canonical_decompiled_code:
char *__fastcall func1(char *a1)
{
const unsigned __int16 *v2; // rax
__int64 v3; // rdx
__int64 v4; // rdx

v2 = *_ctype_b_loc();
do
v3 = *a1++;
while ( (v2[v3] & 0x2000) != 0 );
do
v4 = *a1++;
while ( (v2[v4] & 0x2000) == 0 );
return a1;
}

original_code:
char* next_token(char* string)
{
    while (((*__ctype_b_loc ())[(int) ((*(string++)))] & (unsigned short int) _ISspace));
    while (!((*__ctype_b_loc ())[(int) ((*(string++)))] & (unsigned short int) _ISspace));
    return string;
}

canonical_original_code:
char *next_token(char *string)
{
    while (((*__ctype_b_loc ())[(int) ((*(string++)))] & (unsigned short) _ISspace));
    while (!((*__ctype_b_loc ())[(int) ((*(string++)))] & (unsigned short) _ISspace));
    return string;
}

variable_types:
string
char *

return_type: char *


original_code:
long long mod_exp(long long a, long long b, long long n) {
 long long f = 1;
 long long e = 4294967296;
 int i;
 for(i=32; i>=0; i--) {
  f = (f*f)%n;
  if(b & e) {
   f = (f*a)%n;
  } else {
  }
  e = e/2;
 }
 return f;
}

variable_types:
a
long long

variable_types:
b
long long

variable_types:
n
long long

variable_types:
f
long long

variable_types:
e
long long

return_type: long long


gcd

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

v2 = a1;
v3 = a2;
if ( !a2 )
return a1;
while ( 1 )
{
v4 = v2 % v3;
v2 = v3;
if ( !v4 )
break;
v3 = v4;
}
return (unsigned int)v3;
}

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

v2 = a1;
v3 = a2;
if ( !a2 )
return a1;
while ( 1 )
{
v4 = v2 % v3;
v2 = v3;
if ( !v4 )
break;
v3 = v4;
}
return (unsigned int)v3;
}

original_code:
int gcd(int a, int b) {
 if(b == 0)
  return a;
 else
  return gcd(b, a%b);
}

variable_types: a int

variable_types: b int


decompiled_code:
__int64 __fastcall rand_int(int a1, int a2, int a3)
{
int v4; // eax
int v5; // eax

do
{
v4 = time(0LL);
srand(a3 + v4);
v5 = rand() / (0x7FFFFFFF / (a2 - a1 + 1));
}
while ( a2 - a1 < v5 );
return (unsigned int)(a1 + v5);
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, int a2, int a3)
{
int v4; // eax
int v5; // eax

do
{
v4 = time(0LL);
srand(a3 + v4);
v5 = rand() / (0x7FFFFFFF / (a2 - a1 + 1));
}
while ( a2 - a1 < v5 );
return (unsigned int)(a1 + v5);
}

original_code:
int rand_int(int l_bound, int u_bound, int seed) {
 u_bound = u_bound - l_bound;
 int div = 2147483647/(u_bound + 1);
 int value;
 do {
  srand(time(((void *)0))+seed);
  value = rand() / div;
 } while (value > u_bound);
 return value + l_bound;
}

variable_types: seed int

variable_types: div int

variable_types: value int


original_code:
long generate_primes(int seed) {
 int is_not_prime = 1;
 long p;
 do {
  p = (double)rand_int(1000,10000,seed);
  if(p%2 == 1) {
   int exp = (p-1)/2;
   for(int i=0; i<8; i++) {
    int a = rand_int(0,p,seed);
    int r = mod_exp(a, exp, p);
    if( (r == 1) | (r == -1) ) {
     if(i == 7)
      is_not_prime = 0;
    }
   }
  }
 } while (is_not_prime);
 return p;
}

canonical_original_code:
long generate_primes(int seed) {
 int is_not_prime = 1;
 long p;
 do {
  p = (double)rand_int(1000,10000,seed);
  if(p%2 == 1) {
   int exp = (p-1)/2;
   for(int i = 0; i<8; i++) {
    int a = rand_int(0,p,seed);
    int r = mod_exp(a, exp, p);
    if( (r == 1) | (r == -1) ) {
     if(i == 7)
      is_not_prime = 0;
    }
   }
  }
 } while (is_not_prime);
 return p;
}

variable_types: p long

variable_types: exp int

variable_types: i int

variable_types: r int

return_type: long


decompiled_code:
__int64 __fastcall inverse_modulus(__int64 a1, __int64 a2)
{
int v3; // er9
__int64 v4; // rcx
int v5; // er8
int i; // edi
__int64 v7; // rt2
int v8; // esi
int v9; // edx
int v10; // edx
__int64 result; // rax

v3 = a2;
if ( !a2 )
return 1LL;
v4 = a2;
v5 = 1;
for ( i = 0; ; i = v10 )
{
v7 = a1 % v4;
v8 = a1 / v4;
a1 = v4;
v4 = (int)v7;
v9 = v5;
v5 = i;
v10 = v9 - i * v8;
if ( !(_DWORD)v7 )
break;
}
result = i + v3;
if ( i >= 0 )
result = i;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2)
{
int v3; // er9
__int64 v4; // rcx
int v5; // er8
int i; // edi
__int64 v7; // rt2
int v8; // esi
int v9; // edx
int v10; // edx
__int64 result; // rax

v3 = a2;
if ( !a2 )
return 1LL;
v4 = a2;
v5 = 1;
for ( i = 0; ; i = v10 )
{
v7 = a1 % v4;
v8 = a1 / v4;
a1 = v4;
v4 = (int)v7;
v9 = v5;
v5 = i;
v10 = v9 - i * v8;
if ( !(_DWORD)v7 )
break;
}
result = i + v3;
if ( i >= 0 )
result = i;
return result;
}

original_code:
long long inverse_modulus(long long e, long long modulus) {
 long long a = e;
 long long b = modulus;
 int x = 0;
 int y = 1;
 int x0 = 1;
 int y0 = 0;
 int q, temp;
 while(b != 0) {
  q = a/b;
  temp = a %b;
  a = b;
  b = temp;
  temp = x;
  x = x0 - q * x;
  x0 = temp;
  temp = y;
  y = y0 - q * y;
  y0 = temp;
 }
 if(x0 < 0)
  x0 += modulus;
 return x0;
}

canonical_original_code:
long long inverse_modulus(long long e, long long modulus) {
 long long a = e;
 long long b = modulus;
 int x = 0;
 int y = 1;
 int x0 = 1;
 int y0 = 0;
 int q; int temp;
 while(b != 0) {
  q = a/b;
  temp = a %b;
  a = b;
  b = temp;
  temp = x;
  x = x0 - q * x;
  x0 = temp;
  temp = y;
  y = y0 - q * y;
  y0 = temp;
 }
 if(x0 < 0)
  x0 += modulus;
 return x0;
}

variable_types:
modulus
long long

variable_types: x int

variable_types: y int

variable_types: q int

variable_types: temp int


decompiled_code:
__int64 __fastcall generate_exponent(int a1)
{
unsigned int i; // er9
unsigned int v2; // er9

for ( i = rand_int(10, a1, 1111); (unsigned int)gcd(i, a1) != 1; i = (int)(v2 + 1) % a1 )
;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1)
{
unsigned int i; // er9
unsigned int v2; // er9

for ( i = func9(10, a1, 1111); (unsigned int)func8(i, a1) != 1; i = (int)(v2 + 1) % a1 )
;
return v2;
}

original_code:
int generate_exponent(int totient, int modulus) {
 int e = rand_int(10, totient, 1111);
 while(1) {
  if(gcd(e,totient) == 1)
   return e;
  e = (e+1)%totient;
 }
 return e;
}

variable_types: totient int

variable_types: modulus int

variable_types: e int


main

canonical_name: main

repo: manuscola/stack

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

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

original_code:
int main()
{
    test_stack();
    return 0;
}

canonical_original_code:
int main()
{
    test_stack();
    return 0;
}


decompiled_code:
__int64 __fastcall stack_init(_QWORD *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
*a1 = 0LL;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
*a1 = 0LL;
return 0LL;
}

original_code:
int stack_init(struct Stack* self)
{
 if(self == ((void *)0))
 {
  return -1;
 }
 self->head = ((void *)0);
 return 0;
}

canonical_original_code:
int stack_init(struct Stack *self)
{
 if(self == ((void *)0))
 {
  return -1;
 }
 self->head = ((void *)0);
 return 0;
}

variable_types: struct Stack { struct Stack_node { void *data; struct Stack_node *next; } *head; } *

user_defined_types: struct Stack { struct Stack_node *head; }


decompiled_code:
_BOOL8 __fastcall stack_empty(_QWORD *a1)
{
return *a1 == 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(_QWORD *a1)
{
return *a1 == 0LL;
}

original_code:
int stack_empty(struct Stack* self)
{
 return self->head == ((void *)0);
}

canonical_original_code:
int stack_empty(struct Stack *self)
{
 return self->head == ((void *)0);
}

user_defined_types: struct Stack_node { void *data; struct Stack_node *next; }


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

v2 = malloc(0x10uLL);
if ( !v2 )
return 0xFFFFFFFFLL;
v3 = *a1;
*v2 = a2;
*a1 = (__int64)v2;
v2[1] = v3;
return 0LL;
}

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

v2 = malloc(0x10uLL);
if ( !v2 )
return 0xFFFFFFFFLL;
v3 = *a1;
*v2 = a2;
*a1 = (__int64)v2;
v2[1] = v3;
return 0LL;
}

original_code:
int stack_push(struct Stack* self,void *data)
{
 struct Stack_node* newnode = malloc(sizeof(struct Stack_node));
 if(newnode == ((void *)0))
  return -1;
 else
 {
  newnode->data = data;
  newnode->next = self->head;
  self->head = newnode;
  return 0;
 }
}

canonical_original_code:
int stack_push(struct Stack *self, void *data)
{
 struct Stack_node *newnode = malloc(sizeof(struct Stack_node));
 if(newnode == ((void *)0))
  return -1;
 else
 {
  newnode->data = data;
  newnode->next = self->head;
  self->head = newnode;
  return 0;
 }
}

variable_types:
data
void *

variable_types: struct Stack_node { void *data; struct Stack_node *next; } *


original_code:
void* stack_pop(struct Stack* self)
{
 if(self->head == ((void *)0))
  return ((void *)0);
 void* data = self->head->data;
 struct Stack_node* next = self->head->next;
 free(self->head);
 self->head = next;
 return data;
}

canonical_original_code:
void *stack_pop(struct Stack *self)
{
 if(self->head == ((void *)0))
  return ((void *)0);
 void *data = self->head->data;
 struct Stack_node *next = self->head->next;
 free(self->head);
 self->head = next;
 return data;
}

return_type: void *


decompiled_code:
__int64 test_stack()
{
char *v0; // rbx
unsigned int v1; // eax
unsigned int v2; // eax
__int64 v3; // rsi
unsigned int *v4; // rax
__int64 *v6; // [rsp+0h] [rbp-50h] BYREF
__int128 v7[2]; // [rsp+8h] [rbp-48h] BYREF
__int64 v8; // [rsp+28h] [rbp-28h]
char v9; // [rsp+30h] [rbp-20h] BYREF

v7[0] = 0LL;
v8 = 0LL;
v7[1] = 0LL;
if ( (int)stack_init(&v6) < 0 )
fwrite("stack init failed\n", 1uLL, 0x12uLL, stderr);
v0 = (char *)v7;
v1 = time(0LL);
srand(v1);
do
{
v2 = rand() % 100;
*(_DWORD *)v0 = v2;
printf("%d\t", v2);
v3 = (__int64)v0;
v0 += 4;
stack_push((__int64 *)&v6, v3);
}
while ( v0 != &v9 );
fputc(10, stdout);
while ( !stack_empty(&v6) )
{
v4 = (unsigned int *)stack_pop(&v6);
fprintf(stdout, "%d\t", *v4);
}
fputc(10, stdout);
return 0LL;
}

canonical_decompiled_code:
__int64 func11()
{
char *v0; // rbx
unsigned int v1; // eax
unsigned int v2; // eax
__int64 v3; // rsi
unsigned int *v4; // rax
__int64 *v6; // [rsp+0h] [rbp-50h] BYREF
__int128 v7[2]; // [rsp+8h] [rbp-48h] BYREF
__int64 v8; // [rsp+28h] [rbp-28h]
char v9; // [rsp+30h] [rbp-20h] BYREF

v7[0] = 0LL;
v8 = 0LL;
v7[1] = 0LL;
if ( (int)func7(&v6) < 0 )
fwrite("stack init failed\n", 1uLL, 0x12uLL, stderr);
v0 = (char *)v7;
v1 = time(0LL);
srand(v1);
do
{
v2 = rand() % 100;
*(_DWORD *)v0 = v2;
printf("%d\t", v2);
v3 = (__int64)v0;
v0 += 4;
func9((__int64 *)&v6, v3);
}
while ( v0 != &v9 );
fputc(10, stdout);
while ( !func8(&v6) )
{
v4 = (unsigned int *)func10(&v6);
fprintf(stdout, "%d\t", *v4);
}
fputc(10, stdout);
return 0LL;
}

original_code:
int test_stack()
{
    int data_array[10] = {0};
    struct Stack stack;
    int i = 0;
    int ret = stack_init(&stack);
    if(ret < 0)
    {
        fprintf(stderr,"stack init failed\n");
    }
    srand(time(((void *)0)));
    for(i = 0;i<10;i++)
    {
        data_array[i] = rand()%100;
        printf("%d\t",data_array[i]);
        stack_push(&stack,&data_array[i]);
    }
    fprintf(stdout,"\n");
    while(stack_empty(&stack) == 0)
    {
        int *p = (int *)stack_pop(&stack);
        fprintf(stdout,"%d\t",*p);
    }
    fprintf(stdout,"\n");
    return 0;
}

variable_types: struct Stack { struct Stack_node { void *data; struct Stack_node *next; } *head; }

variable_types: ret int

variable_types:
p
int *


decompiled_code:
__int64 __fastcall get_card_index_in_order(char a1)
{
__int64 result; // rax
char v2; // dl
__m128i v3; // [rsp+0h] [rbp-28h]
int v4; // [rsp+10h] [rbp-18h]
char v5; // [rsp+14h] [rbp-14h]

v5 = 0;
result = 0LL;
v2 = 71;
v4 = 0;
v3 = _mm_load_si128((const __m128i *)&xmmword_402010);
do
{
if ( a1 == v2 )
return (unsigned int)result;
v2 = v3.m128i_i8[++result];
}
while ( v2 );
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func7(char a1)
{
__int64 result; // rax
char v2; // dl
__m128i v3; // [rsp+0h] [rbp-28h]
int v4; // [rsp+10h] [rbp-18h]
char v5; // [rsp+14h] [rbp-14h]

v5 = 0;
result = 0LL;
v2 = 71;
v4 = 0;
v3 = _mm_load_si128((const __m128i *)&xmmword_402010);
do
{
if ( a1 == v2 )
return (unsigned int)result;
v2 = v3.m128i_i8[++result];
}
while ( v2 );
return 0xFFFFFFFFLL;
}

original_code:
int get_card_index_in_order(const T_A_CARD card)
{
  const T_CARDS cards_sort="Gg2AKQJ09876543";
  T_A_CARD a_card;
  int index=0;
  while((a_card=*(cards_sort+index))){
 if(a_card==card)
   return index;
 else
   ++index;
  }
  return -1;
}

canonical_original_code:
int get_card_index_in_order(char card)
{
  char cards_sort[21] = "Gg2AKQJ09876543";
  char a_card;
  int index = 0;
  while((a_card=*(cards_sort+index))){
 if(a_card==card)
   return index;
 else
   ++index;
  }
  return -1;
}

variable_types: card char

variable_types: index int