sigwaitinfo

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

if ( a1 )
{
result = syscall_signal_wait_isra_0(*a1, a2, 0LL);
if ( (int)result < 0 )
{
errno = -(int)result;
result = 0xFFFFFFFFLL;
}
}
else
{
errno = 29;
result = 0xFFFFFFFFLL;
}
return result;
}

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

if ( a1 )
{
result = func1(*a1, a2, 0LL);
if ( (int)result < 0 )
{
errno = -(int)result;
result = 0xFFFFFFFFLL;
}
}
else
{
errno = 29;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int sigwaitinfo(const sigset_t *__restrict set,
       siginfo_t *__restrict info)
{
 int ret;
 if(set == ((void *) 0))
 {
  errno = 0x1d;
  return -1;
 }
 ret = syscall_signal_wait(set, info, ((void *) 0));
 if(ret < 0)
 {
  errno = -ret;
  return -1;
 }
 return ret;
}

canonical_original_code:
int sigwaitinfo(int *set, struct siginfo *info)
{
 int ret;
 if(set == ((void *) 0))
 {
  errno = 0x1d;
  return -1;
 }
 ret = syscall_signal_wait(set, info, ((void *) 0));
 if(ret < 0)
 {
  errno = -ret;
  return -1;
 }
 return ret;
}

variable_types:
set
int *

variable_types: struct siginfo { int si_signo; int si_code; int si_errno; int si_pid; void *si_addr; int si_status; long si_band; union sigval { int sigval_int; void *sigval_ptr; } si_value; } *


sigtimedwait

repo: mregmi/manrix

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

if ( a1 )
{
result = syscall_signal_wait_isra_0(*a1, a2, a3);
if ( (int)result < 0 )
{
errno = -(int)result;
result = 0xFFFFFFFFLL;
}
}
else
{
errno = 29;
result = 0xFFFFFFFFLL;
}
return result;
}

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

if ( a1 )
{
result = func1(*a1, a2, a3);
if ( (int)result < 0 )
{
errno = -(int)result;
result = 0xFFFFFFFFLL;
}
}
else
{
errno = 29;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int sigtimedwait(const sigset_t *__restrict set,
       siginfo_t *__restrict info,
       const struct timespec *__restrict timeout)
{
 int ret;
 if(set == ((void *) 0))
 {
  errno = 0x1d;
  return -1;
 }
 ret = syscall_signal_wait(set, info, timeout);
 if(ret < 0)
 {
  errno = -ret;
  return -1;
 }
 return ret;
}

canonical_original_code:
int sigtimedwait(int *set, struct siginfo *info, struct timespec *timeout)
{
 int ret;
 if(set == ((void *) 0))
 {
  errno = 0x1d;
  return -1;
 }
 ret = syscall_signal_wait(set, info, timeout);
 if(ret < 0)
 {
  errno = -ret;
  return -1;
 }
 return ret;
}

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

variable_types: ret int

return_type: int

user_defined_types: struct siginfo { int si_signo; int si_code; int si_errno; int si_pid; void *si_addr; int si_status; long si_band; union sigval si_value; }

user_defined_types: union sigval { int sigval_int; void *sigval_ptr; }


decompiled_code:
void __fastcall __noreturn IRQ_common(void *a1, __int64 a2, __int64 a3, __int64 a4)
{
_QWORD *v4; // r8
void (*v5)(void); // rbx

syscall_change_iopl_constprop_0_isra_0(a1, a2, a3, a4, a1);
syscall_IRQ_request_isra_0(*(unsigned int *)a1);
v5 = (void (*)(void))v4[1];
free(v4);
while ( 1 )
{
syscall_IRQ_wait_isra_0();
v5();
}
}

canonical_decompiled_code:
void __fastcall __noreturn func3(void *a1, __int64 a2, __int64 a3, __int64 a4)
{
_QWORD *v4; // r8
void (*v5)(void); // rbx

func0(a1, a2, a3, a4, a1);
func1(*(unsigned int *)a1);
v5 = (void (*)(void))v4[1];
free(v4);
while ( 1 )
{
func2();
v5();
}
}

original_code:
int IRQ_common(struct irq_data *data)
{
 ihand_t handle;
 syscall_change_iopl(3);
 syscall_IRQ_request(data->irq);
 handle = data->hand;
 free(data);
 while(1)
 {
  syscall_IRQ_wait();
  handle();
 }
 pthread_exit(((void *) 0));
}

canonical_original_code:
int IRQ_common(struct irq_data *data)
{
 void (*handle)();
 syscall_change_iopl(3);
 syscall_IRQ_request(data->irq);
 handle = data->hand;
 free(data);
 while(1)
 {
  syscall_IRQ_wait();
  handle();
 }
 pthread_exit(((void *) 0));
}

variable_types: struct irq_data { int irq; void (*hand)(); } *

variable_types:
handle
void (*)()


decompiled_code:
int __fastcall IRQ_request(int a1, __int64 a2)
{
_QWORD *v2; // rax
struct sched_param param; // [rsp+Ch] [rbp-3Ch] BYREF
pthread_attr_t attr; // [rsp+10h] [rbp-38h] BYREF

pthread_attr_init(&attr);
param.__sched_priority = 127;
pthread_attr_setschedparam(&attr, &param);
v2 = malloc(0x10uLL);
*(_DWORD *)v2 = a1;
v2[1] = a2;
return pthread_create(0LL, &attr, (void *(*)(void *))IRQ_common, v2);
}

canonical_decompiled_code:
int __fastcall func4(int a1, __int64 a2)
{
_QWORD *v2; // rax
struct sched_param param; // [rsp+Ch] [rbp-3Ch] BYREF
pthread_attr_t attr; // [rsp+10h] [rbp-38h] BYREF

pthread_attr_init(&attr);
param.__sched_priority = 127;
pthread_attr_setschedparam(&attr, &param);
v2 = malloc(0x10uLL);
*(_DWORD *)v2 = a1;
v2[1] = a2;
return pthread_create(0LL, &attr, (void *(*)(void *))IRQ_common, v2);
}

original_code:
int IRQ_request(int irq, ihand_t hand)
{
 struct irq_data *idata;
 pthread_attr_t attr;
 struct sched_param parm;
 pthread_attr_init(&attr);
 parm.sched_priority = 127;
 pthread_attr_setschedparam(&attr, &parm);
 idata = malloc(sizeof(struct irq_data));
 idata->irq = irq;
 idata->hand = hand;
 pthread_create(((void *) 0), &attr, IRQ_common, idata);
}

canonical_original_code:
int IRQ_request(int irq, void (*hand)())
{
 struct irq_data *idata;
 struct pthread_attr attr;
 struct sched_param parm;
 pthread_attr_init(&attr);
 parm.sched_priority = 127;
 pthread_attr_setschedparam(&attr, &parm);
 idata = malloc(sizeof(struct irq_data));
 idata->irq = irq;
 idata->hand = hand;
 pthread_create(((void *) 0), &attr, IRQ_common, idata);
}

variable_types: irq int

variable_types:
hand
void (*)()

variable_types: struct pthread_attr { int flags; struct sched_param { int sched_priority; } prio; void *stackaddr; unsigned int stack_size; int policy; }

user_defined_types: struct pthread_attr { int flags; struct sched_param prio; void *stackaddr; unsigned int stack_size; int policy; }

user_defined_types: struct irq_data { int irq; void (*hand)(); }


nulldev

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

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

original_code:
static inline int nulldev()
{
 return 0;
}


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

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

original_code:
int ext2_write(struct file *file, struct vnode *vn, void *buf, size_t size)
{
 return 0;
}

canonical_original_code:
int ext2_write(struct file *file, struct vnode *vn, void *buf, unsigned int size)
{
 return 0;
}

variable_types: struct file { int f_access; unsigned long f_offset; int f_ref; struct indev { int inode; unsigned long dev; } vnode; } *

variable_types: struct vnode { unsigned short v_flag; int v_count; struct vfs { struct linked_list { void *next; } vfs_next; struct vnode *vfs_mpoint; unsigned long vfs_dev; unsigned int blk_size; union { struct ext2sb { struct ext2_super_block { unsigned long s_inodes_count; unsigned long s_blocks_count; unsigned long s_r_blocks_count; unsigned long s_free_blocks_count; unsigned long s_free_inodes_count; unsigned long s_first_data_block; unsigned long s_log_block_size; unsigned long s_log_frag_size; unsigned long s_blocks_per_group; unsigned long s_frags_per_group; unsigned long s_inodes_per_group; unsigned long s_mtime; unsigned long s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_pad; unsigned short s_minor_rev_level; unsigned long s_lastcheck; unsigned long s_checkinterval; unsigned long s_creator_os; unsigned long s_rev_level; unsigned short s_def_resuid; unsigned short s_def_regid; unsigned long s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned long s_feature_compat; unsigned long s_feature_incompat; unsigned long s_feature_ro_compat; unsigned char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; unsigned long s_algorithm_usage_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned short s_padding1; unsigned long s_reserved[204]; } ext2; struct ext2_group_desc { unsigned long bg_block_bitmap; unsigned long bg_inode_bitmap; unsigned long bg_inode_table; unsigned short bg_free_blocks_count; unsigned short bg_free_inodes_count; unsigned short bg_used_dirs_count; unsigned short bg_pad; unsigned long bg_reserved[3]; } *gdes; } ext2_sb; struct fat_super_block { int ino_val; int fat_type; char fatbs[512]; void *bsptr; } fat; } sb; struct vfsops { int (*vfs_mount)(); int (*vfs_unmount)(); int (*vfs_statvfs)(); int (*vfs_sync)(); } *ops; struct mrx_mutex { struct mrx_mutexattr { int type; int pshared; int protocol; } mattr; int counter; int sync_id; } lock; } *v_fsmounted; struct vfs *vfsp; int v_inum; unsigned long v_rdev; int v_type; struct linked_list v_freelist; struct vnode *v_next; struct vnodeops { int (*vop_open)(struct file *, struct vnode *, int); int (*vop_close)(struct file *, struct vnode *); int (*vop_read)(struct file *, struct vnode *, void *, unsigned int); int (*vop_write)(struct file *, struct vnode *, void *, unsigned int); int (*vop_strategy)(); int (*vop_ioctl)(); int (*vop_create)(); int (*vop_remove)(); int (*vop_link)(); int (*vop_unlink)(); int (*vop_rename)(); int (*vop_mkdir)(); int (*vop_rmdir)(); int (*vop_readdir)(); int (*vop_symlink)(); int (*vop_poll)(); int (*vop_read_inode)(struct vnode *, int); unsigned long (*vop_bmap)(struct vnode *, unsigned long); void (*vop_write_inode)(struct vnode *); int (*vop_namei)(struct vnode *, char *, struct nameidata { struct vnode *vn; struct userid { int uid; int gid; } id; struct vfs *vfs; char *path; int mode; int access; } *); void (*vop_get_attr)(struct vnode *, struct vattr { unsigned long st_dev; int st_ino; int st_mode; int st_nlink; int st_uid; int st_gid; unsigned long st_rdev; unsigned long st_size; long st_atime; long st_mtime; long st_ctime; int st_blksize; unsigned long st_blocks; } *); void (*vop_put_attr)(struct vnode *, struct vattr *); int (*vop_req_iospace)(int, int); } *ops; void *data; struct mrx_mutex smlock; union inode { struct ext2inode { unsigned short i_mode; unsigned short i_uid; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_dtime; unsigned short i_gid; unsigned short i_links_count; unsigned long i_blocks; unsigned long i_flags; union { struct { unsigned long l_i_reserved1; } linux1; struct { unsigned long h_i_translator; } hurd1; struct { unsigned long m_i_reserved1; } masix1; } osd1; unsigned long i_block[-1]; unsigned long i_generation; unsigned long i_file_acl; unsigned long i_dir_acl; unsigned long i_faddr; union { struct { unsigned char l_i_frag; unsigned char l_i_fsize; unsigned short i_pad1; unsigned short l_i_uid_high; unsigned short l_i_gid_high; unsigned long l_i_reserved2; } linux2; struct { unsigned char h_i_frag; unsigned char h_i_fsize; unsigned short h_i_mode_high; unsigned short h_i_uid_high; unsigned short h_i_gid_high; unsigned short h_i_author; } hurd2; struct { unsigned char m_i_frag; unsigned char m_i_fsize; unsigned short m_pad1; unsigned long m_i_reserved2[2]; } masix2; } osd2; } ext2inode; } v_ino; } *

variable_types:
buf
void *

variable_types:
size
unsigned int

user_defined_types: struct file { int f_access; unsigned long f_offset; int f_ref; struct indev vnode; }

user_defined_types: struct vnode { unsigned short v_flag; int v_count; struct vfs *v_fsmounted; struct vfs *vfsp; int v_inum; unsigned long v_rdev; int v_type; struct linked_list v_freelist; struct vnode *v_next; struct vnodeops *ops; void *data; struct mrx_mutex smlock; union inode v_ino; }

user_defined_types: union inode { struct ext2inode ext2inode; }

user_defined_types: struct vfs { struct linked_list vfs_next; struct vnode *vfs_mpoint; unsigned long vfs_dev; unsigned int blk_size; union { struct ext2sb ext2_sb; struct fat_super_block fat; } sb; struct vfsops *ops; struct mrx_mutex lock; }

user_defined_types: struct vnodeops { int (*vop_open)(struct file *, struct vnode *, int); int (*vop_close)(struct file *, struct vnode *); int (*vop_read)(struct file *, struct vnode *, void *, unsigned int); int (*vop_write)(struct file *, struct vnode *, void *, unsigned int); int (*vop_strategy)(); int (*vop_ioctl)(); int (*vop_create)(); int (*vop_remove)(); int (*vop_link)(); int (*vop_unlink)(); int (*vop_rename)(); int (*vop_mkdir)(); int (*vop_rmdir)(); int (*vop_readdir)(); int (*vop_symlink)(); int (*vop_poll)(); int (*vop_read_inode)(struct vnode *, int); unsigned long (*vop_bmap)(struct vnode *, unsigned long); void (*vop_write_inode)(struct vnode *); int (*vop_namei)(struct vnode *, char *, struct nameidata *); void (*vop_get_attr)(struct vnode *, struct vattr *); void (*vop_put_attr)(struct vnode *, struct vattr *); int (*vop_req_iospace)(int, int); }

user_defined_types: struct mrx_mutex { struct mrx_mutexattr mattr; int counter; int sync_id; }

user_defined_types: struct ext2sb { struct ext2_super_block ext2; struct ext2_group_desc *gdes; }

user_defined_types: struct nameidata { struct vnode *vn; struct userid id; struct vfs *vfs; char *path; int mode; int access; }


decompiled_code:
__int64 ext2_statvfs()
{
return nulldev();
}

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

original_code:
int ext2_statvfs()
{
 return 0;
}

canonical_original_code:
int ext2_statvfs()
{
 return 0;
}


decompiled_code:
__int64 ext2_sync()
{
return nulldev();
}

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

original_code:
int ext2_sync()
{
 return 0;
}

canonical_original_code:
int ext2_sync()
{
 return 0;
}


decompiled_code:
__int64 __fastcall ext2_namei(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = ext2_readdir();
if ( !(_DWORD)result && (*(_BYTE *)(a3 + 44) & 3) != 0 )
result = 4294967275LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = ext2_readdir();
if ( !(_DWORD)result && (*(_BYTE *)(a3 + 44) & 3) != 0 )
result = 4294967275LL;
return result;
}

original_code:
int ext2_namei(struct vnode *vn, char *path, struct nameidata *ndata)
{
 int ret;
 ret = ext2_readdir(vn, path, ndata);
 if(ret < 0)
  goto nofile;
 if(ret > 0)
  goto end;
 if((ndata->access & 0x01) || (ndata->access & 0x02))
  return -0x15;
 return ret;
nofile:
 if(ndata->vn == ((void *) 0))
  goto end;
 if((ndata->vn->v_type == 0x4)
  && (ndata->access & 0x01))
  ;
end:
 return ret;
}

variable_types: struct vnode { unsigned short v_flag; int v_count; struct vfs { struct linked_list { void *next; } vfs_next; struct vnode *vfs_mpoint; unsigned long vfs_dev; unsigned int blk_size; union { struct ext2sb { struct ext2_super_block { unsigned long s_inodes_count; unsigned long s_blocks_count; unsigned long s_r_blocks_count; unsigned long s_free_blocks_count; unsigned long s_free_inodes_count; unsigned long s_first_data_block; unsigned long s_log_block_size; unsigned long s_log_frag_size; unsigned long s_blocks_per_group; unsigned long s_frags_per_group; unsigned long s_inodes_per_group; unsigned long s_mtime; unsigned long s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_pad; unsigned short s_minor_rev_level; unsigned long s_lastcheck; unsigned long s_checkinterval; unsigned long s_creator_os; unsigned long s_rev_level; unsigned short s_def_resuid; unsigned short s_def_regid; unsigned long s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned long s_feature_compat; unsigned long s_feature_incompat; unsigned long s_feature_ro_compat; unsigned char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; unsigned long s_algorithm_usage_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned short s_padding1; unsigned long s_reserved[204]; } ext2; struct ext2_group_desc { unsigned long bg_block_bitmap; unsigned long bg_inode_bitmap; unsigned long bg_inode_table; unsigned short bg_free_blocks_count; unsigned short bg_free_inodes_count; unsigned short bg_used_dirs_count; unsigned short bg_pad; unsigned long bg_reserved[3]; } *gdes; } ext2_sb; struct fat_super_block { int ino_val; int fat_type; char fatbs[512]; void *bsptr; } fat; } sb; struct vfsops { int (*vfs_mount)(); int (*vfs_unmount)(); int (*vfs_statvfs)(); int (*vfs_sync)(); } *ops; struct mrx_mutex { struct mrx_mutexattr { int type; int pshared; int protocol; } mattr; int counter; int sync_id; } lock; } *v_fsmounted; struct vfs *vfsp; int v_inum; unsigned long v_rdev; int v_type; struct linked_list v_freelist; struct vnode *v_next; struct vnodeops { int (*vop_open)(struct file { int f_access; unsigned long f_offset; int f_ref; struct indev { int inode; unsigned long dev; } vnode; } *, struct vnode *, int); int (*vop_close)(struct file *, struct vnode *); int (*vop_read)(struct file *, struct vnode *, void *, unsigned int); int (*vop_write)(struct file *, struct vnode *, void *, unsigned int); int (*vop_strategy)(); int (*vop_ioctl)(); int (*vop_create)(); int (*vop_remove)(); int (*vop_link)(); int (*vop_unlink)(); int (*vop_rename)(); int (*vop_mkdir)(); int (*vop_rmdir)(); int (*vop_readdir)(); int (*vop_symlink)(); int (*vop_poll)(); int (*vop_read_inode)(struct vnode *, int); unsigned long (*vop_bmap)(struct vnode *, unsigned long); void (*vop_write_inode)(struct vnode *); int (*vop_namei)(struct vnode *, char *, struct nameidata { struct vnode *vn; struct userid { int uid; int gid; } id; struct vfs *vfs; char *path; int mode; int access; } *); void (*vop_get_attr)(struct vnode *, struct vattr { unsigned long st_dev; int st_ino; int st_mode; int st_nlink; int st_uid; int st_gid; unsigned long st_rdev; unsigned long st_size; long st_atime; long st_mtime; long st_ctime; int st_blksize; unsigned long st_blocks; } *); void (*vop_put_attr)(struct vnode *, struct vattr *); int (*vop_req_iospace)(int, int); } *ops; void *data; struct mrx_mutex smlock; union inode { struct ext2inode { unsigned short i_mode; unsigned short i_uid; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_dtime; unsigned short i_gid; unsigned short i_links_count; unsigned long i_blocks; unsigned long i_flags; union { struct { unsigned long l_i_reserved1; } linux1; struct { unsigned long h_i_translator; } hurd1; struct { unsigned long m_i_reserved1; } masix1; } osd1; unsigned long i_block[-1]; unsigned long i_generation; unsigned long i_file_acl; unsigned long i_dir_acl; unsigned long i_faddr; union { struct { unsigned char l_i_frag; unsigned char l_i_fsize; unsigned short i_pad1; unsigned short l_i_uid_high; unsigned short l_i_gid_high; unsigned long l_i_reserved2; } linux2; struct { unsigned char h_i_frag; unsigned char h_i_fsize; unsigned short h_i_mode_high; unsigned short h_i_uid_high; unsigned short h_i_gid_high; unsigned short h_i_author; } hurd2; struct { unsigned char m_i_frag; unsigned char m_i_fsize; unsigned short m_pad1; unsigned long m_i_reserved2[2]; } masix2; } osd2; } ext2inode; } v_ino; } *

variable_types:
path
char *

variable_types:
ndata
struct nameidata *


decompiled_code:
__int64 __fastcall ext2_mount(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdx
__int64 v3; // rax
_QWORD v4[47]; // [rsp+0h] [rbp-178h] BYREF

result = ext2_read_sb();
if ( (int)result >= 0 )
{
v2 = *(_QWORD *)(a1 + 24);
v4[9] = ext2_vnode_ops;
v4[2] = a1;
v3 = vget(v4, 2LL, v2);
*(_QWORD *)(v3 + 72) = ext2_vnode_ops;
*(_QWORD *)(a1 + 16) = v3;
*(_DWORD *)(v3 + 40) = 4;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdx
__int64 v3; // rax
_QWORD v4[47]; // [rsp+0h] [rbp-178h] BYREF

result = ext2_read_sb();
if ( (int)result >= 0 )
{
v2 = *(_QWORD *)(a1 + 24);
v4[9] = ext2_vnode_ops;
v4[2] = a1;
v3 = vget(v4, 2LL, v2);
*(_QWORD *)(v3 + 72) = ext2_vnode_ops;
*(_QWORD *)(a1 + 16) = v3;
*(_DWORD *)(v3 + 40) = 4;
result = 0LL;
}
return result;
}

original_code:
int ext2_mount(struct vfs *vfs, int option)
{
 struct vnode *rootvn, oper;
 int ret;
 ret = ext2_read_sb(vfs);
 if(ret < 0)
  return ret;
 oper.ops = &ext2_vnode_ops;
 oper.vfsp = vfs;
 rootvn = vget(&oper, 2, vfs->vfs_dev);
 rootvn->ops = &ext2_vnode_ops;
 vfs->vfs_mpoint = rootvn;
 rootvn->v_type = 0x4;
 return 0;
}

canonical_original_code:
int ext2_mount(struct vfs *vfs, int option)
{
 struct vnode *rootvn; struct vnode oper;
 int ret;
 ret = ext2_read_sb(vfs);
 if(ret < 0)
  return ret;
 oper.ops = &ext2_vnode_ops;
 oper.vfsp = vfs;
 rootvn = vget(&oper, 2, vfs->vfs_dev);
 rootvn->ops = &ext2_vnode_ops;
 vfs->vfs_mpoint = rootvn;
 rootvn->v_type = 0x4;
 return 0;
}

variable_types: struct vfs { struct linked_list { void *next; } vfs_next; struct vnode { unsigned short v_flag; int v_count; struct vfs *v_fsmounted; struct vfs *vfsp; int v_inum; unsigned long v_rdev; int v_type; struct linked_list v_freelist; struct vnode *v_next; struct vnodeops { int (*vop_open)(struct file { int f_access; unsigned long f_offset; int f_ref; struct indev { int inode; unsigned long dev; } vnode; } *, struct vnode *, int); int (*vop_close)(struct file *, struct vnode *); int (*vop_read)(struct file *, struct vnode *, void *, unsigned int); int (*vop_write)(struct file *, struct vnode *, void *, unsigned int); int (*vop_strategy)(); int (*vop_ioctl)(); int (*vop_create)(); int (*vop_remove)(); int (*vop_link)(); int (*vop_unlink)(); int (*vop_rename)(); int (*vop_mkdir)(); int (*vop_rmdir)(); int (*vop_readdir)(); int (*vop_symlink)(); int (*vop_poll)(); int (*vop_read_inode)(struct vnode *, int); unsigned long (*vop_bmap)(struct vnode *, unsigned long); void (*vop_write_inode)(struct vnode *); int (*vop_namei)(struct vnode *, char *, struct nameidata { struct vnode *vn; struct userid { int uid; int gid; } id; struct vfs *vfs; char *path; int mode; int access; } *); void (*vop_get_attr)(struct vnode *, struct vattr { unsigned long st_dev; int st_ino; int st_mode; int st_nlink; int st_uid; int st_gid; unsigned long st_rdev; unsigned long st_size; long st_atime; long st_mtime; long st_ctime; int st_blksize; unsigned long st_blocks; } *); void (*vop_put_attr)(struct vnode *, struct vattr *); int (*vop_req_iospace)(int, int); } *ops; void *data; struct mrx_mutex { struct mrx_mutexattr { int type; int pshared; int protocol; } mattr; int counter; int sync_id; } smlock; union inode { struct ext2inode { unsigned short i_mode; unsigned short i_uid; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_dtime; unsigned short i_gid; unsigned short i_links_count; unsigned long i_blocks; unsigned long i_flags; union { struct { unsigned long l_i_reserved1; } linux1; struct { unsigned long h_i_translator; } hurd1; struct { unsigned long m_i_reserved1; } masix1; } osd1; unsigned long i_block[-1]; unsigned long i_generation; unsigned long i_file_acl; unsigned long i_dir_acl; unsigned long i_faddr; union { struct { unsigned char l_i_frag; unsigned char l_i_fsize; unsigned short i_pad1; unsigned short l_i_uid_high; unsigned short l_i_gid_high; unsigned long l_i_reserved2; } linux2; struct { unsigned char h_i_frag; unsigned char h_i_fsize; unsigned short h_i_mode_high; unsigned short h_i_uid_high; unsigned short h_i_gid_high; unsigned short h_i_author; } hurd2; struct { unsigned char m_i_frag; unsigned char m_i_fsize; unsigned short m_pad1; unsigned long m_i_reserved2[2]; } masix2; } osd2; } ext2inode; } v_ino; } *vfs_mpoint; unsigned long vfs_dev; unsigned int blk_size; union { struct ext2sb { struct ext2_super_block { unsigned long s_inodes_count; unsigned long s_blocks_count; unsigned long s_r_blocks_count; unsigned long s_free_blocks_count; unsigned long s_free_inodes_count; unsigned long s_first_data_block; unsigned long s_log_block_size; unsigned long s_log_frag_size; unsigned long s_blocks_per_group; unsigned long s_frags_per_group; unsigned long s_inodes_per_group; unsigned long s_mtime; unsigned long s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_pad; unsigned short s_minor_rev_level; unsigned long s_lastcheck; unsigned long s_checkinterval; unsigned long s_creator_os; unsigned long s_rev_level; unsigned short s_def_resuid; unsigned short s_def_regid; unsigned long s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned long s_feature_compat; unsigned long s_feature_incompat; unsigned long s_feature_ro_compat; unsigned char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; unsigned long s_algorithm_usage_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned short s_padding1; unsigned long s_reserved[204]; } ext2; struct ext2_group_desc { unsigned long bg_block_bitmap; unsigned long bg_inode_bitmap; unsigned long bg_inode_table; unsigned short bg_free_blocks_count; unsigned short bg_free_inodes_count; unsigned short bg_used_dirs_count; unsigned short bg_pad; unsigned long bg_reserved[3]; } *gdes; } ext2_sb; struct fat_super_block { int ino_val; int fat_type; char fatbs[512]; void *bsptr; } fat; } sb; struct vfsops { int (*vfs_mount)(); int (*vfs_unmount)(); int (*vfs_statvfs)(); int (*vfs_sync)(); } *ops; struct mrx_mutex lock; } *

variable_types: option int

variable_types: struct vnode { unsigned short v_flag; int v_count; struct vfs { struct linked_list { void *next; } vfs_next; struct vnode *vfs_mpoint; unsigned long vfs_dev; unsigned int blk_size; union { struct ext2sb { struct ext2_super_block { unsigned long s_inodes_count; unsigned long s_blocks_count; unsigned long s_r_blocks_count; unsigned long s_free_blocks_count; unsigned long s_free_inodes_count; unsigned long s_first_data_block; unsigned long s_log_block_size; unsigned long s_log_frag_size; unsigned long s_blocks_per_group; unsigned long s_frags_per_group; unsigned long s_inodes_per_group; unsigned long s_mtime; unsigned long s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_pad; unsigned short s_minor_rev_level; unsigned long s_lastcheck; unsigned long s_checkinterval; unsigned long s_creator_os; unsigned long s_rev_level; unsigned short s_def_resuid; unsigned short s_def_regid; unsigned long s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned long s_feature_compat; unsigned long s_feature_incompat; unsigned long s_feature_ro_compat; unsigned char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; unsigned long s_algorithm_usage_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned short s_padding1; unsigned long s_reserved[204]; } ext2; struct ext2_group_desc { unsigned long bg_block_bitmap; unsigned long bg_inode_bitmap; unsigned long bg_inode_table; unsigned short bg_free_blocks_count; unsigned short bg_free_inodes_count; unsigned short bg_used_dirs_count; unsigned short bg_pad; unsigned long bg_reserved[3]; } *gdes; } ext2_sb; struct fat_super_block { int ino_val; int fat_type; char fatbs[512]; void *bsptr; } fat; } sb; struct vfsops { int (*vfs_mount)(); int (*vfs_unmount)(); int (*vfs_statvfs)(); int (*vfs_sync)(); } *ops; struct mrx_mutex { struct mrx_mutexattr { int type; int pshared; int protocol; } mattr; int counter; int sync_id; } lock; } *v_fsmounted; struct vfs *vfsp; int v_inum; unsigned long v_rdev; int v_type; struct linked_list v_freelist; struct vnode *v_next; struct vnodeops { int (*vop_open)(struct file { int f_access; unsigned long f_offset; int f_ref; struct indev { int inode; unsigned long dev; } vnode; } *, struct vnode *, int); int (*vop_close)(struct file *, struct vnode *); int (*vop_read)(struct file *, struct vnode *, void *, unsigned int); int (*vop_write)(struct file *, struct vnode *, void *, unsigned int); int (*vop_strategy)(); int (*vop_ioctl)(); int (*vop_create)(); int (*vop_remove)(); int (*vop_link)(); int (*vop_unlink)(); int (*vop_rename)(); int (*vop_mkdir)(); int (*vop_rmdir)(); int (*vop_readdir)(); int (*vop_symlink)(); int (*vop_poll)(); int (*vop_read_inode)(struct vnode *, int); unsigned long (*vop_bmap)(struct vnode *, unsigned long); void (*vop_write_inode)(struct vnode *); int (*vop_namei)(struct vnode *, char *, struct nameidata { struct vnode *vn; struct userid { int uid; int gid; } id; struct vfs *vfs; char *path; int mode; int access; } *); void (*vop_get_attr)(struct vnode *, struct vattr { unsigned long st_dev; int st_ino; int st_mode; int st_nlink; int st_uid; int st_gid; unsigned long st_rdev; unsigned long st_size; long st_atime; long st_mtime; long st_ctime; int st_blksize; unsigned long st_blocks; } *); void (*vop_put_attr)(struct vnode *, struct vattr *); int (*vop_req_iospace)(int, int); } *ops; void *data; struct mrx_mutex smlock; union inode { struct ext2inode { unsigned short i_mode; unsigned short i_uid; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_dtime; unsigned short i_gid; unsigned short i_links_count; unsigned long i_blocks; unsigned long i_flags; union { struct { unsigned long l_i_reserved1; } linux1; struct { unsigned long h_i_translator; } hurd1; struct { unsigned long m_i_reserved1; } masix1; } osd1; unsigned long i_block[-1]; unsigned long i_generation; unsigned long i_file_acl; unsigned long i_dir_acl; unsigned long i_faddr; union { struct { unsigned char l_i_frag; unsigned char l_i_fsize; unsigned short i_pad1; unsigned short l_i_uid_high; unsigned short l_i_gid_high; unsigned long l_i_reserved2; } linux2; struct { unsigned char h_i_frag; unsigned char h_i_fsize; unsigned short h_i_mode_high; unsigned short h_i_uid_high; unsigned short h_i_gid_high; unsigned short h_i_author; } hurd2; struct { unsigned char m_i_frag; unsigned char m_i_fsize; unsigned short m_pad1; unsigned long m_i_reserved2[2]; } masix2; } osd2; } ext2inode; } v_ino; }


decompiled_code:
__int64 __fastcall ext2_unmount(__int64 a1)
{
free(*(void **)(a1 + 1984));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
free(*(void **)(a1 + 1984));
return 0LL;
}

original_code:
int ext2_unmount(struct vfs *vfs)
{
 free(vfs->sb.ext2_sb.gdes);
 return 0;
}

user_defined_types: struct fat_super_block { int ino_val; int fat_type; char fatbs[512]; void *bsptr; }

user_defined_types: struct vfsops { int (*vfs_mount)(); int (*vfs_unmount)(); int (*vfs_statvfs)(); int (*vfs_sync)(); }

user_defined_types: struct ext2_super_block { unsigned long s_inodes_count; unsigned long s_blocks_count; unsigned long s_r_blocks_count; unsigned long s_free_blocks_count; unsigned long s_free_inodes_count; unsigned long s_first_data_block; unsigned long s_log_block_size; unsigned long s_log_frag_size; unsigned long s_blocks_per_group; unsigned long s_frags_per_group; unsigned long s_inodes_per_group; unsigned long s_mtime; unsigned long s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_pad; unsigned short s_minor_rev_level; unsigned long s_lastcheck; unsigned long s_checkinterval; unsigned long s_creator_os; unsigned long s_rev_level; unsigned short s_def_resuid; unsigned short s_def_regid; unsigned long s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned long s_feature_compat; unsigned long s_feature_incompat; unsigned long s_feature_ro_compat; unsigned char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; unsigned long s_algorithm_usage_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned short s_padding1; unsigned long s_reserved[204]; }

user_defined_types: struct mrx_mutexattr { int type; int pshared; int protocol; }

user_defined_types: struct ext2inode { unsigned short i_mode; unsigned short i_uid; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_dtime; unsigned short i_gid; unsigned short i_links_count; unsigned long i_blocks; unsigned long i_flags; union { struct { unsigned long l_i_reserved1; } linux1; struct { unsigned long h_i_translator; } hurd1; struct { unsigned long m_i_reserved1; } masix1; } osd1; unsigned long i_block[-1]; unsigned long i_generation; unsigned long i_file_acl; unsigned long i_dir_acl; unsigned long i_faddr; union { struct { unsigned char l_i_frag; unsigned char l_i_fsize; unsigned short i_pad1; unsigned short l_i_uid_high; unsigned short l_i_gid_high; unsigned long l_i_reserved2; } linux2; struct { unsigned char h_i_frag; unsigned char h_i_fsize; unsigned short h_i_mode_high; unsigned short h_i_uid_high; unsigned short h_i_gid_high; unsigned short h_i_author; } hurd2; struct { unsigned char m_i_frag; unsigned char m_i_fsize; unsigned short m_pad1; unsigned long m_i_reserved2[2]; } masix2; } osd2; }

user_defined_types: struct ext2_group_desc { unsigned long bg_block_bitmap; unsigned long bg_inode_bitmap; unsigned long bg_inode_table; unsigned short bg_free_blocks_count; unsigned short bg_free_inodes_count; unsigned short bg_used_dirs_count; unsigned short bg_pad; unsigned long bg_reserved[3]; }

user_defined_types: struct vattr { unsigned long st_dev; int st_ino; int st_mode; int st_nlink; int st_uid; int st_gid; unsigned long st_rdev; unsigned long st_size; long st_atime; long st_mtime; long st_ctime; int st_blksize; unsigned long st_blocks; }

user_defined_types: struct indev { int inode; unsigned long dev; }


decompiled_code:
__int64 ext2fs_construct()
{
char *v0; // rax
__int64 v1; // r8
__int64 result; // rax

v0 = (char *)malloc(0x7E8uLL);
memset_constprop_0_isra_0(v0);
result = v1;
*(_QWORD *)(v1 + 1992) = ext2_vfs_ops;
return result;
}

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

v0 = (char *)malloc(0x7E8uLL);
func7(v0);
result = v1;
*(_QWORD *)(v1 + 1992) = ext2_vfs_ops;
return result;
}

original_code:
struct vfs *ext2fs_construct()
{
 struct vfs *vfs;
 vfs = (struct vfs *)malloc(sizeof(struct vfs));
 memset(vfs, 0, sizeof(struct vfs));
 vfs->ops = &ext2_vfs_ops;
 return vfs;
}

return_type: struct vfs { struct linked_list { void *next; } vfs_next; struct vnode { unsigned short v_flag; int v_count; struct vfs *v_fsmounted; struct vfs *vfsp; int v_inum; unsigned long v_rdev; int v_type; struct linked_list v_freelist; struct vnode *v_next; struct vnodeops { int (*vop_open)(struct file { int f_access; unsigned long f_offset; int f_ref; struct indev { int inode; unsigned long dev; } vnode; } *, struct vnode *, int); int (*vop_close)(struct file *, struct vnode *); int (*vop_read)(struct file *, struct vnode *, void *, unsigned int); int (*vop_write)(struct file *, struct vnode *, void *, unsigned int); int (*vop_strategy)(); int (*vop_ioctl)(); int (*vop_create)(); int (*vop_remove)(); int (*vop_link)(); int (*vop_unlink)(); int (*vop_rename)(); int (*vop_mkdir)(); int (*vop_rmdir)(); int (*vop_readdir)(); int (*vop_symlink)(); int (*vop_poll)(); int (*vop_read_inode)(struct vnode *, int); unsigned long (*vop_bmap)(struct vnode *, unsigned long); void (*vop_write_inode)(struct vnode *); int (*vop_namei)(struct vnode *, char *, struct nameidata { struct vnode *vn; struct userid { int uid; int gid; } id; struct vfs *vfs; char *path; int mode; int access; } *); void (*vop_get_attr)(struct vnode *, struct vattr { unsigned long st_dev; int st_ino; int st_mode; int st_nlink; int st_uid; int st_gid; unsigned long st_rdev; unsigned long st_size; long st_atime; long st_mtime; long st_ctime; int st_blksize; unsigned long st_blocks; } *); void (*vop_put_attr)(struct vnode *, struct vattr *); int (*vop_req_iospace)(int, int); } *ops; void *data; struct mrx_mutex { struct mrx_mutexattr { int type; int pshared; int protocol; } mattr; int counter; int sync_id; } smlock; union inode { struct ext2inode { unsigned short i_mode; unsigned short i_uid; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_dtime; unsigned short i_gid; unsigned short i_links_count; unsigned long i_blocks; unsigned long i_flags; union { struct { unsigned long l_i_reserved1; } linux1; struct { unsigned long h_i_translator; } hurd1; struct { unsigned long m_i_reserved1; } masix1; } osd1; unsigned long i_block[-1]; unsigned long i_generation; unsigned long i_file_acl; unsigned long i_dir_acl; unsigned long i_faddr; union { struct { unsigned char l_i_frag; unsigned char l_i_fsize; unsigned short i_pad1; unsigned short l_i_uid_high; unsigned short l_i_gid_high; unsigned long l_i_reserved2; } linux2; struct { unsigned char h_i_frag; unsigned char h_i_fsize; unsigned short h_i_mode_high; unsigned short h_i_uid_high; unsigned short h_i_gid_high; unsigned short h_i_author; } hurd2; struct { unsigned char m_i_frag; unsigned char m_i_fsize; unsigned short m_pad1; unsigned long m_i_reserved2[2]; } masix2; } osd2; } ext2inode; } v_ino; } *vfs_mpoint; unsigned long vfs_dev; unsigned int blk_size; union { struct ext2sb { struct ext2_super_block { unsigned long s_inodes_count; unsigned long s_blocks_count; unsigned long s_r_blocks_count; unsigned long s_free_blocks_count; unsigned long s_free_inodes_count; unsigned long s_first_data_block; unsigned long s_log_block_size; unsigned long s_log_frag_size; unsigned long s_blocks_per_group; unsigned long s_frags_per_group; unsigned long s_inodes_per_group; unsigned long s_mtime; unsigned long s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_pad; unsigned short s_minor_rev_level; unsigned long s_lastcheck; unsigned long s_checkinterval; unsigned long s_creator_os; unsigned long s_rev_level; unsigned short s_def_resuid; unsigned short s_def_regid; unsigned long s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned long s_feature_compat; unsigned long s_feature_incompat; unsigned long s_feature_ro_compat; unsigned char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; unsigned long s_algorithm_usage_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned short s_padding1; unsigned long s_reserved[204]; } ext2; struct ext2_group_desc { unsigned long bg_block_bitmap; unsigned long bg_inode_bitmap; unsigned long bg_inode_table; unsigned short bg_free_blocks_count; unsigned short bg_free_inodes_count; unsigned short bg_used_dirs_count; unsigned short bg_pad; unsigned long bg_reserved[3]; } *gdes; } ext2_sb; struct fat_super_block { int ino_val; int fat_type; char fatbs[512]; void *bsptr; } fat; } sb; struct vfsops { int (*vfs_mount)(); int (*vfs_unmount)(); int (*vfs_statvfs)(); int (*vfs_sync)(); } *ops; struct mrx_mutex lock; } *


original_code:
int ext2_read(struct file *file, struct vnode *vn, void *buf, size_t size)
{
 struct ext2inode *inode = &vn->v_ino.ext2inode;
 struct bcache *bdata;
 int err = -0x1d;
 unsigned int blkno, blkindex, toread = size, read = 0, sz = 0, off;
 void *bufptr = buf;
 void *dataptr;
 if(file->f_offset >= inode->i_size)
  return 0;
 do{
  blkindex = file->f_offset/vn->vfsp->blk_size;
  blkno = ext2_bmap(vn, blkindex);
  bdata = bread(vn->v_rdev, blkno, vn->vfsp->blk_size);
  if(bdata == ((void *) 0))
   return err;
  off = file->f_offset % vn->vfsp->blk_size;
  dataptr = (void *)((unsigned int)bdata->b_data + off);
  if(toread < (vn->vfsp->blk_size - off))
   sz = toread;
  else
   sz = vn->vfsp->blk_size - off;
  if((file->f_offset + sz) > inode->i_size)
   sz = inode->i_size - file->f_offset;
  memcpy(bufptr, dataptr, sz);
  brelse(bdata);
  file->f_offset += sz;
  read += sz;
  if(file->f_offset >= inode->i_size)
   break;
  bufptr = (void *)((unsigned long)bufptr + sz);
  toread -= sz;
 } while(read < size);
 return read;
}

canonical_original_code:
int ext2_read(struct file *file, struct vnode *vn, void *buf, unsigned int size)
{
 struct ext2inode *inode = &vn->v_ino.ext2inode;
 struct bcache *bdata;
 int err = -0x1d;
 unsigned int blkno; unsigned int blkindex; unsigned int toread = size; unsigned int read = 0; unsigned int sz = 0; unsigned int off;
 void *bufptr = buf;
 void *dataptr;
 if(file->f_offset >= inode->i_size)
  return 0;
 do{
  blkindex = file->f_offset/vn->vfsp->blk_size;
  blkno = ext2_bmap(vn, blkindex);
  bdata = bread(vn->v_rdev, blkno, vn->vfsp->blk_size);
  if(bdata == ((void *) 0))
   return err;
  off = file->f_offset % vn->vfsp->blk_size;
  dataptr = (void *)((unsigned int)bdata->b_data + off);
  if(toread < (vn->vfsp->blk_size - off))
   sz = toread;
  else
   sz = vn->vfsp->blk_size - off;
  if((file->f_offset + sz) > inode->i_size)
   sz = inode->i_size - file->f_offset;
  memcpy(bufptr, dataptr, sz);
  brelse(bdata);
  file->f_offset += sz;
  read += sz;
  if(file->f_offset >= inode->i_size)
   break;
  bufptr = (void *)((unsigned long)bufptr + sz);
  toread -= sz;
 } while(read < size);
 return read;
}

variable_types: struct ext2inode { unsigned short i_mode; unsigned short i_uid; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_dtime; unsigned short i_gid; unsigned short i_links_count; unsigned long i_blocks; unsigned long i_flags; union { struct { unsigned long l_i_reserved1; } linux1; struct { unsigned long h_i_translator; } hurd1; struct { unsigned long m_i_reserved1; } masix1; } osd1; unsigned long i_block[-1]; unsigned long i_generation; unsigned long i_file_acl; unsigned long i_dir_acl; unsigned long i_faddr; union { struct { unsigned char l_i_frag; unsigned char l_i_fsize; unsigned short i_pad1; unsigned short l_i_uid_high; unsigned short l_i_gid_high; unsigned long l_i_reserved2; } linux2; struct { unsigned char h_i_frag; unsigned char h_i_fsize; unsigned short h_i_mode_high; unsigned short h_i_uid_high; unsigned short h_i_gid_high; unsigned short h_i_author; } hurd2; struct { unsigned char m_i_frag; unsigned char m_i_fsize; unsigned short m_pad1; unsigned long m_i_reserved2[2]; } masix2; } osd2; } *

variable_types: struct bcache { int b_status; struct bcache *next; struct linked_list { void *next; } b_freelist; unsigned long b_devno; unsigned long b_blockno; int b_ioerror; void *b_data; unsigned int b_datasz; struct mrx_mutex { struct mrx_mutexattr { int type; int pshared; int protocol; } mattr; int counter; int sync_id; } smlock; } *

variable_types: err int

variable_types:
blkno
unsigned int

variable_types:
blkindex
unsigned int

variable_types:
toread
unsigned int

variable_types:
read
unsigned int

variable_types:
sz
unsigned int

variable_types:
off
unsigned int

variable_types:
bufptr
void *

variable_types:
dataptr
void *

user_defined_types: struct bcache { int b_status; struct bcache *next; struct linked_list b_freelist; unsigned long b_devno; unsigned long b_blockno; int b_ioerror; void *b_data; unsigned int b_datasz; struct mrx_mutex smlock; }


decompiled_code:
__int64 ext2fs_init()
{
index = register_vfs("ext2", ext2fs_construct, ext2_vfs_ops);
return 0LL;
}

canonical_decompiled_code:
__int64 func11()
{
index = register_vfs("ext2", ext2fs_construct, ext2_vfs_ops);
return 0LL;
}

original_code:
int ext2fs_init()
{
 index = register_vfs("ext2", ext2fs_construct, &ext2_vfs_ops);
 return 0;
}


decompiled_code:
__int64 ext2fs_exit()
{
return unregister_vfs((unsigned int)index);
}

canonical_decompiled_code:
__int64 func12()
{
return unregister_vfs((unsigned int)index);
}

original_code:
int ext2fs_exit()
{
 return unregister_vfs(index);
}


decompiled_code:
__int64 vm_init()
{
list_init_constprop_0();
vm_page_init();
slab_init();
vm_map_init();
vm_object_init();
return pmap_init();
}

canonical_decompiled_code:
__int64 func1()
{
func0();
vm_page_init();
slab_init();
vm_map_init();
vm_object_init();
return pmap_init();
}

original_code:
void vm_init()
{
 list_init(&kernel_object.page);
 vm_page_init();
 slab_init();
 vm_map_init();
 vm_object_init();
 pmap_init();
}

return_type: void


decompiled_code:
__int64 __fastcall vm_allocate(__int64 a1, _DWORD *a2, int a3)
{
*a2 = *(_DWORD *)(a1 + 24);
vm_map_enter(a1, a2, (a3 + 4095) & 0xFFFFF000, 0LL, 1LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _DWORD *a2, int a3)
{
*a2 = *(_DWORD *)(a1 + 24);
vm_map_enter(a1, a2, (a3 + 4095) & 0xFFFFF000, 0LL, 1LL);
return 0LL;
}

original_code:
int vm_allocate(vm_map_t map, vm_offset_t *address, vm_size_t size)
{
 *address = map->start;
 ((size) = (((vm_offset_t) (size)) + (0x1000 -1)) & ~(0x1000 -1));
 vm_map_enter(map, address, size, ((void *)0), 1);
 return 0;
}

canonical_original_code:
int vm_allocate(struct vm_map *map, unsigned int *address, unsigned int size)
{
 *address = map->start;
 ((size) = (((vm_offset_t) (size)) + (0x1000 -1)) & ~(0x1000 -1));
 vm_map_enter(map, address, size, ((void *)0), 1);
 return 0;
}

variable_types: struct vm_map { struct vm_map_entry { struct linked_list { void *next; } entries; unsigned int start; unsigned int end; struct vm_object { struct linked_list page; struct atomic_t { int value; } ref_count; struct atomic_t npages; unsigned int size; struct vm_object *shadow; int attribute; struct vn_object { int fd; int blk_size; unsigned int page_size; unsigned int va; unsigned long offset; int map_type; int protection; unsigned int size; int pager_id; unsigned int noload_start; } vn; struct spinlock { int lock; } lock; } *object; unsigned short type; unsigned short attr; struct spinlock lock; } *vmentry; struct pmap { struct linked_list plist; unsigned int *pdbr; struct spinlock lock; } *pmap; unsigned int size; struct atomic_t ref_count; unsigned int start; unsigned int end; struct vm_map_entry *hint; unsigned int private; int attr; struct spinlock vmlock; } *

variable_types:
address
unsigned int *

variable_types:
size
unsigned int

user_defined_types: struct vm_map { struct vm_map_entry *vmentry; struct pmap *pmap; unsigned int size; struct atomic_t ref_count; unsigned int start; unsigned int end; struct vm_map_entry *hint; unsigned int private; int attr; struct spinlock vmlock; }

user_defined_types: struct vm_map_entry { struct linked_list entries; unsigned int start; unsigned int end; struct vm_object *object; unsigned short type; unsigned short attr; struct spinlock lock; }

user_defined_types: struct vm_object { struct linked_list page; struct atomic_t ref_count; struct atomic_t npages; unsigned int size; struct vm_object *shadow; int attribute; struct vn_object vn; struct spinlock lock; }


decompiled_code:
__int64 __fastcall vm_deallocate(__int64 a1, int a2, int a3)
{
return vm_map_remove(a1, a2 & 0xFFFFF000, (a3 + 4095) & 0xFFFFF000);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2, int a3)
{
return vm_map_remove(a1, a2 & 0xFFFFF000, (a3 + 4095) & 0xFFFFF000);
}

original_code:
int vm_deallocate(vm_map_t map, vm_offset_t offset, vm_size_t size)
{
 ((offset) = (((vm_offset_t)(offset)) & ~(0x1000 -1)));
 ((size) = (((vm_offset_t) (size)) + (0x1000 -1)) & ~(0x1000 -1));
 return vm_map_remove(map, offset, size);
}

canonical_original_code:
int vm_deallocate(struct vm_map *map, unsigned int offset, unsigned int size)
{
 ((offset) = (((vm_offset_t)(offset)) & ~(0x1000 -1)));
 ((size) = (((vm_offset_t) (size)) + (0x1000 -1)) & ~(0x1000 -1));
 return vm_map_remove(map, offset, size);
}

variable_types:
offset
unsigned int

user_defined_types: struct pmap { struct linked_list plist; unsigned int *pdbr; struct spinlock lock; }

user_defined_types: struct vn_object { int fd; int blk_size; unsigned int page_size; unsigned int va; unsigned long offset; int map_type; int protection; unsigned int size; int pager_id; unsigned int noload_start; }


original_code:
void *vm_map(vm_map_t map, struct vn_object *vno, int type)
{
 int ret, prot = 0x004;
 vm_object_t object;
 vm_offset_t pa = vno->va;
 object = vm_object_create(vno->size);
 if(!object)
  return (void *)(-0x31);
 if(vno->protection & 2)
  prot |= 0x002;
 if(!vno->va && !(type & 1))
 {
  type |= 1;
 }
 if(!(type & 4))
  vno->va = map->start;
 object->vn = *vno;
 ((vno->va) = (((vm_offset_t)(vno->va)) & ~(0x1000 -1)));
 ret = vm_map_enter(map, &vno->va, vno->size, object, type);
 if((type & 8) && !(type & 1))
 {
  if(vno->map_type & 2)
   prot = 0x002;
  pmap_enter_range(map->pmap, pa, vno->va, vno->size, prot|0x004);
 }
 return (void *)vno->va;
}

canonical_original_code:
void *vm_map(struct vm_map *map, struct vn_object *vno, int type)
{
 int ret; int prot = 0x004;
 struct vm_object *object;
 unsigned int pa = vno->va;
 object = vm_object_create(vno->size);
 if(!object)
  return (void *)(-0x31);
 if(vno->protection & 2)
  prot |= 0x002;
 if(!vno->va && !(type & 1))
 {
  type |= 1;
 }
 if(!(type & 4))
  vno->va = map->start;
 object->vn = *vno;
 ((vno->va) = (((vm_offset_t)(vno->va)) & ~(0x1000 -1)));
 ret = vm_map_enter(map, &vno->va, vno->size, object, type);
 if((type & 8) && !(type & 1))
 {
  if(vno->map_type & 2)
   prot = 0x002;
  pmap_enter_range(map->pmap, pa, vno->va, vno->size, prot|0x004);
 }
 return (void *)vno->va;
}

variable_types:
vno
struct vn_object *

variable_types: type int

variable_types: ret int

variable_types: prot int

variable_types: struct vm_object { struct linked_list { void *next; } page; struct atomic_t { int value; } ref_count; struct atomic_t npages; unsigned int size; struct vm_object *shadow; int attribute; struct vn_object { int fd; int blk_size; unsigned int page_size; unsigned int va; unsigned long offset; int map_type; int protection; unsigned int size; int pager_id; unsigned int noload_start; } vn; struct spinlock { int lock; } lock; } *

variable_types:
pa
unsigned int

return_type: void *


decompiled_code:
// attributes: thunk
__int64 fd_alloc()
{
return syscall_fd_alloc_constprop_0();
}

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

original_code:
int fd_alloc(tid_t tid)
{
 return syscall_fd_alloc(tid, -1, ((void *) 0));
}

canonical_original_code:
int fd_alloc(int tid)
{
 return syscall_fd_alloc(tid, -1, ((void *) 0));
}

variable_types: tid int


decompiled_code:
// attributes: thunk
__int64 __fastcall get_openfile(__int64 a1, __int64 a2, __int64 a3)
{
return syscall_fd_free(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
return func0(a1, a2, a3);
}

original_code:
int get_openfile(tid_t tid, int fdesc, struct file *file)
{
 return syscall_fd_free(tid, fdesc, file);
}

canonical_original_code:
int get_openfile(int tid, int fdesc, struct file *file)
{
 return syscall_fd_free(tid, fdesc, file);
}

variable_types: fdesc int

variable_types: struct file { int f_access; unsigned long f_offset; int f_ref; struct indev { int inode; unsigned long dev; } vnode; } *

user_defined_types: struct file { int f_access; unsigned long f_offset; int f_ref; struct indev vnode; }


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

result = 44LL;
__asm { int 30h; (NOT A VECTOR!) FAR JMP instruction for CP/M-style calls }
return result;
}

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

result = 44LL;
__asm { int 30h; (NOT A VECTOR!) FAR JMP instruction for CP/M-style calls }
return result;
}

original_code:
static inline int syscall_fd_free(tid_t tid, int desc, struct file *table)
{
 register int ret;
 asm (
  "int $0x30"
  :"=a"(ret)
  :"0"(44), "b"(tid), "c"(desc), "d"(table)
  );
 if(ret < 0)
 {
  errno = -ret;
  return -1;
 }
 return ret;
}

canonical_original_code:
static inline int syscall_fd_free(int tid, int desc, struct file *table)
{
 register int ret;
 asm (
  "int $0x30"
  :"=a"(ret)
  :"0"(44), "b"(tid), "c"(desc), "d"(table)
  );
 if(ret < 0)
 {
  errno = -ret;
  return -1;
 }
 return ret;
}

variable_types: desc int


decompiled_code:
__int64 __fastcall fd_free(__int64 a1, __int64 a2)
{
return syscall_fd_free(a1, a2, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
return func0(a1, a2, 0LL);
}

original_code:
int fd_free(tid_t tid, int fdesc)
{
 return syscall_fd_free(tid, fdesc, ((void *) 0));
}

canonical_original_code:
int fd_free(int tid, int fdesc)
{
 return syscall_fd_free(tid, fdesc, ((void *) 0));
}


memcmp

decompiled_code:
__int64 __fastcall memcmp(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v4; // rsi
__int64 i; // rax
unsigned int v6; // edx

if ( !a3 )
return 0;
v4 = a3;
for ( i = 0LL; i != v4; ++i )
{
v6 = *(unsigned __int8 *)(a1 + i) - *(unsigned __int8 *)(a2 + i);
if ( v6 )
break;
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v4; // rsi
__int64 i; // rax
unsigned int v6; // edx

if ( !a3 )
return 0;
v4 = a3;
for ( i = 0LL; i != v4; ++i )
{
v6 = *(unsigned __int8 *)(a1 + i) - *(unsigned __int8 *)(a2 + i);
if ( v6 )
break;
}
return v6;
}

original_code:
int memcmp(const void * cs,const void * ct,size_t count)
{
 const unsigned char *su1, *su2;
 int res = 0;
 for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
  if ((res = *su1 - *su2) != 0)
   break;
 return res;
}

canonical_original_code:
int memcmp(void *cs, void *ct, unsigned int count)
{
 unsigned char *su1; unsigned char *su2;
 int res = 0;
 for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
  if ((res = *su1 - *su2) != 0)
   break;
 return res;
}

variable_types:
cs
void *

variable_types:
ct
void *

variable_types:
count
unsigned int

variable_types: res int


strnicmp

decompiled_code:
__int64 __fastcall strnicmp(unsigned __int8 *a1, unsigned __int8 *a2, int a3)
{
unsigned __int8 *v3; // r8
__int64 result; // rax
unsigned __int8 *v6; // r10
unsigned __int8 v7; // al
unsigned __int8 v8; // cl
int v9; // edi
unsigned __int8 v10; // si

v3 = a1;
result = 0LL;
if ( a3 )
{
v6 = &a1[a3];
while ( 1 )
{
v9 = *v3;
v10 = *a2;
++v3;
++a2;
if ( !(_BYTE)v9 )
return (unsigned int)-v10;
if ( !v10 )
return (unsigned __int8)v9;
if ( (_BYTE)v9 != v10 )
{
tolower(v9);
v7 = tolower(v10);
if ( v8 != v7 )
break;
}
if ( v3 == v6 )
return 0LL;
}
result = v8 - (unsigned int)v7;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int8 *a1, unsigned __int8 *a2, int a3)
{
unsigned __int8 *v3; // r8
__int64 result; // rax
unsigned __int8 *v6; // r10
unsigned __int8 v7; // al
unsigned __int8 v8; // cl
int v9; // edi
unsigned __int8 v10; // si

v3 = a1;
result = 0LL;
if ( a3 )
{
v6 = &a1[a3];
while ( 1 )
{
v9 = *v3;
v10 = *a2;
++v3;
++a2;
if ( !(_BYTE)v9 )
return (unsigned int)-v10;
if ( !v10 )
return (unsigned __int8)v9;
if ( (_BYTE)v9 != v10 )
{
func0(v9);
v7 = func0(v10);
if ( v8 != v7 )
break;
}
if ( v3 == v6 )
return 0LL;
}
result = v8 - (unsigned int)v7;
}
return result;
}

original_code:
int strnicmp(const char *s1, const char *s2, size_t len)
{
 unsigned char c1, c2;
 c1 = 0; c2 = 0;
 if (len) {
  do {
   c1 = *s1; c2 = *s2;
   s1++; s2++;
   if (!c1)
    break;
   if (!c2)
    break;
   if (c1 == c2)
    continue;
   c1 = _tolower(c1);
   c2 = _tolower(c2);
   if (c1 != c2)
    break;
  } while (--len);
 }
 return (int)c1 - (int)c2;
}

canonical_original_code:
int strnicmp(char *s1, char *s2, unsigned int len)
{
 unsigned char c1; unsigned char c2;
 c1 = 0; c2 = 0;
 if (len) {
  do {
   c1 = *s1; c2 = *s2;
   s1++; s2++;
   if (!c1)
    break;
   if (!c2)
    break;
   if (c1 == c2)
    continue;
   c1 = _tolower(c1);
   c2 = _tolower(c2);
   if (c1 != c2)
    break;
  } while (--len);
 }
 return (int)c1 - (int)c2;
}

variable_types:
len
unsigned int


strspn

decompiled_code:
__int64 __fastcall strspn(char *a1, _BYTE *a2)
{
char v2; // cl
unsigned int v4; // er8
char v5; // si
_BYTE *v6; // rdx
char v7; // al

v2 = *a1;
v4 = 0;
if ( *a1 )
{
v5 = *a2;
v4 = 0;
do
{
if ( !v5 )
break;
v6 = a2;
v7 = v5;
while ( v7 != v2 )
{
v7 = *++v6;
if ( !v7 )
return v4;
}
v2 = *++a1;
++v4;
}
while ( v2 );
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1, _BYTE *a2)
{
char v2; // cl
unsigned int v4; // er8
char v5; // si
_BYTE *v6; // rdx
char v7; // al

v2 = *a1;
v4 = 0;
if ( *a1 )
{
v5 = *a2;
v4 = 0;
do
{
if ( !v5 )
break;
v6 = a2;
v7 = v5;
while ( v7 != v2 )
{
v7 = *++v6;
if ( !v7 )
return v4;
}
v2 = *++a1;
++v4;
}
while ( v2 );
}
return v4;
}

original_code:
size_t strspn(const char *s, const char *accept)
{
 const char *p;
 const char *a;
 size_t count = 0;
 for (p = s; *p != '\0'; ++p) {
  for (a = accept; *a != '\0'; ++a) {
   if (*p == *a)
    break;
  }
  if (*a == '\0')
   return count;
  ++count;
 }
 return count;
}

canonical_original_code:
unsigned int strspn(char *s, char *accept)
{
 char *p;
 char *a;
 unsigned int count = 0;
 for (p = s; *p != '\0'; ++p) {
  for (a = accept; *a != '\0'; ++a) {
   if (*p == *a)
    break;
  }
  if (*a == '\0')
   return count;
  ++count;
 }
 return count;
}

variable_types:
s
char *

variable_types:
accept
char *

variable_types:
p
char *

variable_types:
a
char *

return_type: unsigned int


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

result = 6LL;
__asm { int 30h; (NOT A VECTOR!) FAR JMP instruction for CP/M-style calls }
return result;
}

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

result = 6LL;
__asm { int 30h; (NOT A VECTOR!) FAR JMP instruction for CP/M-style calls }
return result;
}

original_code:
static inline int syscall_get_pid(tid_t tid)
{
 register int pid;
 asm volatile (
  "int $0x30\n\t"
  :"=a"(pid)
  :"0"(6), "D"(tid)
  );
 return pid;
}

canonical_original_code:
static inline int syscall_get_pid(int tid)
{
 register int pid;
 asm volatile (
  "int $0x30\n\t"
  :"=a"(pid)
  :"0"(6), "D"(tid)
  );
 return pid;
}

variable_types: pid int


decompiled_code:
__int64 __fastcall get_cwd(__int64 a1)
{
int v2[6]; // [rsp+0h] [rbp-18h] BYREF

syscall_get_cwd_constprop_0_isra_0(a1, v2);
return find_vnode(v2[0], (unsigned int)v2[2]);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v2[6]; // [rsp+0h] [rbp-18h] BYREF

func1(a1, v2);
return find_vnode(v2[0], (unsigned int)v2[2]);
}

original_code:
static inline struct vnode *get_cwd(tid_t tid)
{
 struct indev indev;
 syscall_get_cwd(tid, &indev, ((void *) 0));
 return find_vnode(indev.inode, indev.dev);
}

canonical_original_code:
static inline struct vnode *get_cwd(int tid)
{
 struct indev indev;
 syscall_get_cwd(tid, &indev, ((void *) 0));
 return find_vnode(indev.inode, indev.dev);
}

return_type: struct vnode { unsigned short v_flag; int v_count; struct vfs { struct linked_list { void *next; } vfs_next; struct vnode *vfs_mpoint; unsigned long vfs_dev; unsigned int blk_size; union { struct ext2sb { struct ext2_super_block { unsigned long s_inodes_count; unsigned long s_blocks_count; unsigned long s_r_blocks_count; unsigned long s_free_blocks_count; unsigned long s_free_inodes_count; unsigned long s_first_data_block; unsigned long s_log_block_size; unsigned long s_log_frag_size; unsigned long s_blocks_per_group; unsigned long s_frags_per_group; unsigned long s_inodes_per_group; unsigned long s_mtime; unsigned long s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_pad; unsigned short s_minor_rev_level; unsigned long s_lastcheck; unsigned long s_checkinterval; unsigned long s_creator_os; unsigned long s_rev_level; unsigned short s_def_resuid; unsigned short s_def_regid; unsigned long s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned long s_feature_compat; unsigned long s_feature_incompat; unsigned long s_feature_ro_compat; unsigned char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; unsigned long s_algorithm_usage_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned short s_padding1; unsigned long s_reserved[204]; } ext2; struct ext2_group_desc { unsigned long bg_block_bitmap; unsigned long bg_inode_bitmap; unsigned long bg_inode_table; unsigned short bg_free_blocks_count; unsigned short bg_free_inodes_count; unsigned short bg_used_dirs_count; unsigned short bg_pad; unsigned long bg_reserved[3]; } *gdes; } ext2_sb; struct fat_super_block { int ino_val; int fat_type; char fatbs[512]; void *bsptr; } fat; } sb; struct vfsops { int (*vfs_mount)(); int (*vfs_unmount)(); int (*vfs_statvfs)(); int (*vfs_sync)(); } *ops; struct mrx_mutex { struct mrx_mutexattr { int type; int pshared; int protocol; } mattr; int counter; int sync_id; } lock; } *v_fsmounted; struct vfs *vfsp; int v_inum; unsigned long v_rdev; int v_type; struct linked_list v_freelist; struct vnode *v_next; struct vnodeops { int (*vop_open)(struct file { int f_access; unsigned long f_offset; int f_ref; struct indev { int inode; unsigned long dev; } vnode; } *, struct vnode *, int); int (*vop_close)(struct file *, struct vnode *); int (*vop_read)(struct file *, struct vnode *, void *, unsigned int); int (*vop_write)(struct file *, struct vnode *, void *, unsigned int); int (*vop_strategy)(); int (*vop_ioctl)(); int (*vop_create)(); int (*vop_remove)(); int (*vop_link)(); int (*vop_unlink)(); int (*vop_rename)(); int (*vop_mkdir)(); int (*vop_rmdir)(); int (*vop_readdir)(); int (*vop_symlink)(); int (*vop_poll)(); int (*vop_read_inode)(struct vnode *, int); unsigned long (*vop_bmap)(struct vnode *, unsigned long); void (*vop_write_inode)(struct vnode *); int (*vop_namei)(struct vnode *, char *, struct nameidata { struct vnode *vn; struct userid { int uid; int gid; } id; struct vfs *vfs; char *path; int mode; int access; } *); void (*vop_get_attr)(struct vnode *, struct vattr { unsigned long st_dev; int st_ino; int st_mode; int st_nlink; int st_uid; int st_gid; unsigned long st_rdev; unsigned long st_size; long st_atime; long st_mtime; long st_ctime; int st_blksize; unsigned long st_blocks; } *); void (*vop_put_attr)(struct vnode *, struct vattr *); int (*vop_req_iospace)(int, int); } *ops; void *data; struct mrx_mutex smlock; union inode { struct ext2inode { unsigned short i_mode; unsigned short i_uid; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_dtime; unsigned short i_gid; unsigned short i_links_count; unsigned long i_blocks; unsigned long i_flags; union { struct { unsigned long l_i_reserved1; } linux1; struct { unsigned long h_i_translator; } hurd1; struct { unsigned long m_i_reserved1; } masix1; } osd1; unsigned long i_block[-1]; unsigned long i_generation; unsigned long i_file_acl; unsigned long i_dir_acl; unsigned long i_faddr; union { struct { unsigned char l_i_frag; unsigned char l_i_fsize; unsigned short i_pad1; unsigned short l_i_uid_high; unsigned short l_i_gid_high; unsigned long l_i_reserved2; } linux2; struct { unsigned char h_i_frag; unsigned char h_i_fsize; unsigned short h_i_mode_high; unsigned short h_i_uid_high; unsigned short h_i_gid_high; unsigned short h_i_author; } hurd2; struct { unsigned char m_i_frag; unsigned char m_i_fsize; unsigned short m_pad1; unsigned long m_i_reserved2[2]; } masix2; } osd2; } ext2inode; } v_ino; } *

user_defined_types: struct vnode { unsigned short v_flag; int v_count; struct vfs *v_fsmounted; struct vfs *vfsp; int v_inum; unsigned long v_rdev; int v_type; struct linked_list v_freelist; struct vnode *v_next; struct vnodeops *ops; void *data; struct mrx_mutex smlock; union inode v_ino; }

user_defined_types: union inode { struct ext2inode ext2inode; }

user_defined_types: struct vfs { struct linked_list vfs_next; struct vnode *vfs_mpoint; unsigned long vfs_dev; unsigned int blk_size; union { struct ext2sb ext2_sb; struct fat_super_block fat; } sb; struct vfsops *ops; struct mrx_mutex lock; }

user_defined_types: struct vnodeops { int (*vop_open)(struct file *, struct vnode *, int); int (*vop_close)(struct file *, struct vnode *); int (*vop_read)(struct file *, struct vnode *, void *, unsigned int); int (*vop_write)(struct file *, struct vnode *, void *, unsigned int); int (*vop_strategy)(); int (*vop_ioctl)(); int (*vop_create)(); int (*vop_remove)(); int (*vop_link)(); int (*vop_unlink)(); int (*vop_rename)(); int (*vop_mkdir)(); int (*vop_rmdir)(); int (*vop_readdir)(); int (*vop_symlink)(); int (*vop_poll)(); int (*vop_read_inode)(struct vnode *, int); unsigned long (*vop_bmap)(struct vnode *, unsigned long); void (*vop_write_inode)(struct vnode *); int (*vop_namei)(struct vnode *, char *, struct nameidata *); void (*vop_get_attr)(struct vnode *, struct vattr *); void (*vop_put_attr)(struct vnode *, struct vattr *); int (*vop_req_iospace)(int, int); }

user_defined_types: struct mrx_mutex { struct mrx_mutexattr mattr; int counter; int sync_id; }

user_defined_types: struct ext2sb { struct ext2_super_block ext2; struct ext2_group_desc *gdes; }


readdir

decompiled_code:
char *__fastcall readdir(__int64 a1)
{
int v1; // ebp
unsigned int v2; // edx
char *v3; // r8
__int64 v4; // rcx
int v5; // esi
char *result; // rax
int v7; // eax

v1 = errno;
v2 = *(_DWORD *)(a1 + 24);
v3 = *(char **)(a1 + 8);
while ( 1 )
{
result = &v3[v2];
if ( *(_DWORD *)(a1 + 20) <= v2 )
break;
LABEL_2:
v4 = *((unsigned __int16 *)result + 2);
result[(unsigned __int8)result[6] + 8] = 0;
v5 = (unsigned __int16)v4;
*(_QWORD *)(a1 + 32) += v4;
LODWORD(v4) = *(_DWORD *)result;
v2 += v5;
*(_DWORD *)(a1 + 24) = v2;
if ( (_DWORD)v4 )
return result;
}
v7 = _getdirentries(*(_DWORD *)a1, v3, *(unsigned int *)(a1 + 16));
if ( v7 > 0 )
{
v3 = *(char **)(a1 + 8);
*(_DWORD *)(a1 + 20) = v7;
v2 = 0;
result = v3;
goto LABEL_2;
}
if ( !v7 || (result = 0LL, errno == 45) )
{
errno = v1;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func1(__int64 a1)
{
int v1; // ebp
unsigned int v2; // edx
char *v3; // r8
__int64 v4; // rcx
int v5; // esi
char *result; // rax
int v7; // eax

v1 = errno;
v2 = *(_DWORD *)(a1 + 24);
v3 = *(char **)(a1 + 8);
while ( 1 )
{
result = &v3[v2];
if ( *(_DWORD *)(a1 + 20) <= v2 )
break;
LABEL_2:
v4 = *((unsigned __int16 *)result + 2);
result[(unsigned __int8)result[6] + 8] = 0;
v5 = (unsigned __int16)v4;
*(_QWORD *)(a1 + 32) += v4;
LODWORD(v4) = *(_DWORD *)result;
v2 += v5;
*(_DWORD *)(a1 + 24) = v2;
if ( (_DWORD)v4 )
return result;
}
v7 = func0(*(_DWORD *)a1, v3, *(unsigned int *)(a1 + 16));
if ( v7 > 0 )
{
v3 = *(char **)(a1 + 8);
*(_DWORD *)(a1 + 20) = v7;
v2 = 0;
result = v3;
goto LABEL_2;
}
if ( !v7 || (result = 0LL, errno == 45) )
{
errno = v1;
result = 0LL;
}
return result;
}

original_code:
struct dirent *
readdir (DIR *dirp)
{
  struct dirent *dp;
  int saved_errno = errno;
  do
    {
      size_t reclen;
      if (dirp->offset >= dirp->size)
 {
   size_t maxread;
   ssize_t bytes;
   maxread = dirp->allocation;
   bytes = __getdirentries(dirp->fd, dirp->data, maxread);
   if (bytes <= 0)
     {
       if (bytes < 0 && errno == 0x2d)
  bytes = 0;
       if (bytes == 0)
  ((errno) = (saved_errno));
       dp = ((void *) 0);
       break;
     }
   dirp->size = (size_t) bytes;
   dirp->offset = 0;
 }
      dp = (struct dirent *) &dirp->data[dirp->offset];
      reclen = dp->d_reclen;
      dp->d_name[dp->d_namelen] = '\0';
      dirp->offset += reclen;
      dirp->filepos += reclen;
    } while (dp->d_ino == 0);
  return dp;
}

canonical_original_code:
struct dirent *readdir(struct __dirstream *dirp)
{
  struct dirent *dp;
  int saved_errno = errno;
  do
    {
      unsigned int reclen;
      if (dirp->offset >= dirp->size)
 {
   unsigned int maxread;
   int bytes;
   maxread = dirp->allocation;
   bytes = __getdirentries(dirp->fd, dirp->data, maxread);
   if (bytes <= 0)
     {
       if (bytes < 0 && errno == 0x2d)
  bytes = 0;
       if (bytes == 0)
  ((errno) = (saved_errno));
       dp = ((void *) 0);
       break;
     }
   dirp->size = (unsigned int) bytes;
   dirp->offset = 0;
 }
      dp = (struct dirent *) &dirp->data[dirp->offset];
      reclen = dp->d_reclen;
      dp->d_name[dp->d_namelen] = '\0';
      dirp->offset += reclen;
      dirp->filepos += reclen;
    } while (dp->d_ino == 0);
  return dp;
}

variable_types: struct __dirstream { int fd; char *data; unsigned int allocation; unsigned int size; unsigned int offset; unsigned long filepos; } *

variable_types: struct dirent { int d_ino; unsigned short d_reclen; unsigned char d_namelen; unsigned char d_filetype; char d_name[256]; } *

variable_types:
reclen
unsigned int

variable_types:
maxread
unsigned int

variable_types: bytes int


closedir

decompiled_code:
int __fastcall closedir(int *a1)
{
int v1; // ebp
int result; // eax

if ( a1 )
{
v1 = *a1;
free(a1);
result = close(v1);
}
else
{
errno = 29;
result = -1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(int *a1)
{
int v1; // ebp
int result; // eax

if ( a1 )
{
v1 = *a1;
free(a1);
result = close(v1);
}
else
{
errno = 29;
result = -1;
}
return result;
}

original_code:
int
closedir (DIR *dirp)
{
  int fd;
  if (dirp == ((void *) 0))
    {
      ((errno) = (0x1d));
      return -1;
    }
  fd = dirp->fd;
  free ((void *) dirp);
  return close (fd);
}

canonical_original_code:
int closedir(struct __dirstream *dirp)
{
  int fd;
  if (dirp == ((void *) 0))
    {
      ((errno) = (0x1d));
      return -1;
    }
  fd = dirp->fd;
  free ((void *) dirp);
  return close (fd);
}

variable_types: fd int

user_defined_types: struct __dirstream { int fd; char *data; unsigned int allocation; unsigned int size; unsigned int offset; unsigned long filepos; }


telldir

decompiled_code:
__int64 __fastcall telldir(__int64 a1)
{
return *(_QWORD *)(a1 + 32);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return *(_QWORD *)(a1 + 32);
}

original_code:
long int
telldir (DIR *dirp)
{
  return dirp->filepos;
}

canonical_original_code:
long telldir(struct __dirstream *dirp)
{
  return dirp->filepos;
}

return_type: long


decompiled_code:
__int64 __fastcall multiboot_parse(int a1, unsigned int a2)
{
if ( a1 != 732803074 )
panic("ManRiX is NOT loaded properly.\n\tPlease use multiboot complaint Boot loaders like GRUB.\n");
minfo = a2;
return kprintf("ManRiX Microkernel Loaded as '%s'.\n", (const char *)*(unsigned int *)((char *)&loc_10 + a2));
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, unsigned int a2)
{
if ( a1 != 732803074 )
panic("ManRiX is NOT loaded properly.\n\tPlease use multiboot complaint Boot loaders like GRUB.\n");
minfo = a2;
return kprintf("ManRiX Microkernel Loaded as '%s'.\n", (const char *)*(unsigned int *)((char *)&loc_10 + a2));
}

original_code:
void multiboot_parse(u32 magic, u32 info_add)
{
 char *cmdline;
 if(magic != 0x2BADB002)
 {
  panic("ManRiX is NOT loaded properly.\n	Please use multiboot complaint Boot loaders like GRUB.\n");
 }
 minfo = (struct multiboot_info *)info_add;
 cmdline = (char *)minfo->cmdline;
 kprintf("ManRiX Microkernel Loaded as '%s'.\n", cmdline);
}

canonical_original_code:
void multiboot_parse(unsigned int magic, unsigned int info_add)
{
 char *cmdline;
 if(magic != 0x2BADB002)
 {
  panic("ManRiX is NOT loaded properly.\n	Please use multiboot complaint Boot loaders like GRUB.\n");
 }
 minfo = (struct multiboot_info *)info_add;
 cmdline = (char *)minfo->cmdline;
 kprintf("ManRiX Microkernel Loaded as '%s'.\n", cmdline);
}

variable_types:
magic
unsigned int

variable_types:
cmdline
char *

user_defined_types: struct multiboot_info { unsigned int flags; unsigned int mem_lower; unsigned int mem_upper; unsigned int boot_device; unsigned int cmdline; unsigned int mods_count; unsigned int mods_addr; struct elf_section_header_table elf_table; unsigned int mmap_length; unsigned int mmap_addr; }

user_defined_types: struct elf_section_header_table { unsigned int num; unsigned int strsize; unsigned int addr; unsigned int reserved; }


decompiled_code:
__int64 __fastcall open_elf(_QWORD *a1, __int64 a2)
{
__m128i *v2; // rax

v2 = read_header(a1, a2);
if ( !v2 )
return 0xFFFFFFFFLL;
a1[10] = v2;
*(_QWORD *)(a2 + 16) = v2[2].m128i_i64[0];
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, __int64 a2)
{
__m128i *v2; // rax

v2 = read_header(a1, a2);
if ( !v2 )
return 0xFFFFFFFFLL;
a1[10] = v2;
*(_QWORD *)(a2 + 16) = v2[2].m128i_i64[0];
return 0LL;
}

original_code:
int open_elf(struct vnode *vnode, struct vn_object *obj)
{
 struct exec_struct *exec;
 exec = read_header(vnode, obj);
 if(!exec)
  return -1;
 vnode->data = exec;
 obj->va = exec->header.e_entry;
 return 0;
}

variable_types: struct vnode { unsigned short v_flag; int v_count; struct vfs { struct linked_list { void *next; } vfs_next; struct vnode *vfs_mpoint; unsigned long vfs_dev; unsigned int blk_size; union { struct ext2sb { struct ext2_super_block { unsigned long s_inodes_count; unsigned long s_blocks_count; unsigned long s_r_blocks_count; unsigned long s_free_blocks_count; unsigned long s_free_inodes_count; unsigned long s_first_data_block; unsigned long s_log_block_size; unsigned long s_log_frag_size; unsigned long s_blocks_per_group; unsigned long s_frags_per_group; unsigned long s_inodes_per_group; unsigned long s_mtime; unsigned long s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_pad; unsigned short s_minor_rev_level; unsigned long s_lastcheck; unsigned long s_checkinterval; unsigned long s_creator_os; unsigned long s_rev_level; unsigned short s_def_resuid; unsigned short s_def_regid; unsigned long s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned long s_feature_compat; unsigned long s_feature_incompat; unsigned long s_feature_ro_compat; unsigned char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; unsigned long s_algorithm_usage_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned short s_padding1; unsigned long s_reserved[204]; } ext2; struct ext2_group_desc { unsigned long bg_block_bitmap; unsigned long bg_inode_bitmap; unsigned long bg_inode_table; unsigned short bg_free_blocks_count; unsigned short bg_free_inodes_count; unsigned short bg_used_dirs_count; unsigned short bg_pad; unsigned long bg_reserved[3]; } *gdes; } ext2_sb; struct fat_super_block { int ino_val; int fat_type; char fatbs[512]; void *bsptr; } fat; } sb; struct vfsops { int (*vfs_mount)(); int (*vfs_unmount)(); int (*vfs_statvfs)(); int (*vfs_sync)(); } *ops; struct mrx_mutex { struct mrx_mutexattr { int type; int pshared; int protocol; } mattr; int counter; int sync_id; } lock; } *v_fsmounted; struct vfs *vfsp; int v_inum; unsigned long v_rdev; int v_type; struct linked_list v_freelist; struct vnode *v_next; struct vnodeops { int (*vop_open)(struct file { int f_access; unsigned long f_offset; int f_ref; struct indev { int inode; unsigned long dev; } vnode; } *, struct vnode *, int); int (*vop_close)(struct file *, struct vnode *); int (*vop_read)(struct file *, struct vnode *, void *, unsigned int); int (*vop_write)(struct file *, struct vnode *, void *, unsigned int); int (*vop_strategy)(); int (*vop_ioctl)(); int (*vop_create)(); int (*vop_remove)(); int (*vop_link)(); int (*vop_unlink)(); int (*vop_rename)(); int (*vop_mkdir)(); int (*vop_rmdir)(); int (*vop_readdir)(); int (*vop_symlink)(); int (*vop_poll)(); int (*vop_read_inode)(struct vnode *, int); unsigned long (*vop_bmap)(struct vnode *, unsigned long); void (*vop_write_inode)(struct vnode *); int (*vop_namei)(struct vnode *, char *, struct nameidata { struct vnode *vn; struct userid { int uid; int gid; } id; struct vfs *vfs; char *path; int mode; int access; } *); void (*vop_get_attr)(struct vnode *, struct vattr { unsigned long st_dev; int st_ino; int st_mode; int st_nlink; int st_uid; int st_gid; unsigned long st_rdev; unsigned long st_size; long st_atime; long st_mtime; long st_ctime; int st_blksize; unsigned long st_blocks; } *); void (*vop_put_attr)(struct vnode *, struct vattr *); int (*vop_req_iospace)(int, int); } *ops; void *data; struct mrx_mutex smlock; union inode { struct ext2inode { unsigned short i_mode; unsigned short i_uid; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_dtime; unsigned short i_gid; unsigned short i_links_count; unsigned long i_blocks; unsigned long i_flags; union { struct { unsigned long l_i_reserved1; } linux1; struct { unsigned long h_i_translator; } hurd1; struct { unsigned long m_i_reserved1; } masix1; } osd1; unsigned long i_block[-1]; unsigned long i_generation; unsigned long i_file_acl; unsigned long i_dir_acl; unsigned long i_faddr; union { struct { unsigned char l_i_frag; unsigned char l_i_fsize; unsigned short i_pad1; unsigned short l_i_uid_high; unsigned short l_i_gid_high; unsigned long l_i_reserved2; } linux2; struct { unsigned char h_i_frag; unsigned char h_i_fsize; unsigned short h_i_mode_high; unsigned short h_i_uid_high; unsigned short h_i_gid_high; unsigned short h_i_author; } hurd2; struct { unsigned char m_i_frag; unsigned char m_i_fsize; unsigned short m_pad1; unsigned long m_i_reserved2[2]; } masix2; } osd2; } ext2inode; } v_ino; } *

variable_types: struct vn_object { int fd; int blk_size; unsigned int page_size; unsigned long va; unsigned long offset; int map_type; int protection; unsigned int size; int pager_id; unsigned long noload_start; } *

variable_types: struct exec_struct { struct Elf32_Ehdr { unsigned char e_ident[16]; unsigned short e_type; unsigned short e_machine; unsigned long e_version; unsigned long e_entry; unsigned long e_phoff; unsigned long e_shoff; unsigned long e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; } header; struct Elf32_Phdr { unsigned long p_type; unsigned long p_offset; unsigned long p_vaddr; unsigned long p_paddr; unsigned long p_filesz; unsigned long p_memsz; unsigned long p_flags; unsigned long p_align; } *phdr; } *

user_defined_types: struct exec_struct { struct Elf32_Ehdr header; struct Elf32_Phdr *phdr; }

user_defined_types: struct nameidata { struct vnode *vn; struct userid id; struct vfs *vfs; char *path; int mode; int access; }


original_code:
int elf_read_data(struct vnode *vnode, struct vn_object *obj, void *data)
{
 Elf32_Ehdr *hdr;
 Elf32_Phdr *phdr;
 size_t size;
 int index;
 struct exec_struct *exec;
 index = 0;
 exec = (struct exec_struct *)vnode->data;
 hdr = &exec->header;
 do{
  phdr = (Elf32_Phdr *)((unsigned long)exec->phdr + (hdr->e_phentsize * index));
  if((obj->va >= phdr->p_vaddr) && (obj->va <= (phdr->p_vaddr + phdr->p_filesz)))
   goto done;
  index++;
 }while(index < hdr->e_phnum);
 printf("Not Found %X ", obj->va);
 if(obj->blk_size >= obj->page_size)
  size = obj->blk_size;
 else
  size = obj->page_size;
 return 0;
done:
 return read_file(vnode, obj, data, phdr);
}

canonical_original_code:
int elf_read_data(struct vnode *vnode, struct vn_object *obj, void *data)
{
 struct Elf32_Ehdr *hdr;
 struct Elf32_Phdr *phdr;
 unsigned int size;
 int index;
 struct exec_struct *exec;
 index = 0;
 exec = (struct exec_struct *)vnode->data;
 hdr = &exec->header;
 do{
  phdr = (struct Elf32_Phdr *)((unsigned long)exec->phdr + (hdr->e_phentsize * index));
  if((obj->va >= phdr->p_vaddr) && (obj->va <= (phdr->p_vaddr + phdr->p_filesz)))
   goto done;
  index++;
 }while(index < hdr->e_phnum);
 printf("Not Found %X ", obj->va);
 if(obj->blk_size >= obj->page_size)
  size = obj->blk_size;
 else
  size = obj->page_size;
 return 0;
done:
 return read_file(vnode, obj, data, phdr);
}

variable_types:
data
void *

variable_types: struct Elf32_Ehdr { unsigned char e_ident[16]; unsigned short e_type; unsigned short e_machine; unsigned long e_version; unsigned long e_entry; unsigned long e_phoff; unsigned long e_shoff; unsigned long e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; } *

variable_types: struct Elf32_Phdr { unsigned long p_type; unsigned long p_offset; unsigned long p_vaddr; unsigned long p_paddr; unsigned long p_filesz; unsigned long p_memsz; unsigned long p_flags; unsigned long p_align; } *

variable_types:
size
unsigned int

variable_types: index int

user_defined_types: struct vn_object { int fd; int blk_size; unsigned int page_size; unsigned long va; unsigned long offset; int map_type; int protection; unsigned int size; int pager_id; unsigned long noload_start; }

user_defined_types: struct ext2inode { unsigned short i_mode; unsigned short i_uid; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_dtime; unsigned short i_gid; unsigned short i_links_count; unsigned long i_blocks; unsigned long i_flags; union { struct { unsigned long l_i_reserved1; } linux1; struct { unsigned long h_i_translator; } hurd1; struct { unsigned long m_i_reserved1; } masix1; } osd1; unsigned long i_block[-1]; unsigned long i_generation; unsigned long i_file_acl; unsigned long i_dir_acl; unsigned long i_faddr; union { struct { unsigned char l_i_frag; unsigned char l_i_fsize; unsigned short i_pad1; unsigned short l_i_uid_high; unsigned short l_i_gid_high; unsigned long l_i_reserved2; } linux2; struct { unsigned char h_i_frag; unsigned char h_i_fsize; unsigned short h_i_mode_high; unsigned short h_i_uid_high; unsigned short h_i_gid_high; unsigned short h_i_author; } hurd2; struct { unsigned char m_i_frag; unsigned char m_i_fsize; unsigned short m_pad1; unsigned long m_i_reserved2[2]; } masix2; } osd2; }

user_defined_types: struct fat_super_block { int ino_val; int fat_type; char fatbs[512]; void *bsptr; }

user_defined_types: struct vfsops { int (*vfs_mount)(); int (*vfs_unmount)(); int (*vfs_statvfs)(); int (*vfs_sync)(); }

user_defined_types: struct mrx_mutexattr { int type; int pshared; int protocol; }

user_defined_types: struct ext2_super_block { unsigned long s_inodes_count; unsigned long s_blocks_count; unsigned long s_r_blocks_count; unsigned long s_free_blocks_count; unsigned long s_free_inodes_count; unsigned long s_first_data_block; unsigned long s_log_block_size; unsigned long s_log_frag_size; unsigned long s_blocks_per_group; unsigned long s_frags_per_group; unsigned long s_inodes_per_group; unsigned long s_mtime; unsigned long s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_pad; unsigned short s_minor_rev_level; unsigned long s_lastcheck; unsigned long s_checkinterval; unsigned long s_creator_os; unsigned long s_rev_level; unsigned short s_def_resuid; unsigned short s_def_regid; unsigned long s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned long s_feature_compat; unsigned long s_feature_incompat; unsigned long s_feature_ro_compat; unsigned char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; unsigned long s_algorithm_usage_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned short s_padding1; unsigned long s_reserved[204]; }

user_defined_types: struct ext2_group_desc { unsigned long bg_block_bitmap; unsigned long bg_inode_bitmap; unsigned long bg_inode_table; unsigned short bg_free_blocks_count; unsigned short bg_free_inodes_count; unsigned short bg_used_dirs_count; unsigned short bg_pad; unsigned long bg_reserved[3]; }

user_defined_types: struct vattr { unsigned long st_dev; int st_ino; int st_mode; int st_nlink; int st_uid; int st_gid; unsigned long st_rdev; unsigned long st_size; long st_atime; long st_mtime; long st_ctime; int st_blksize; unsigned long st_blocks; }

user_defined_types: struct indev { int inode; unsigned long dev; }


inportb

decompiled_code:
unsigned __int8 __fastcall inportb(unsigned __int16 a1)
{
return __inbyte(a1);
}

canonical_decompiled_code:
unsigned __int8 __fastcall func0(unsigned __int16 a1)
{
return __inbyte(a1);
}

original_code:
static inline unsigned char inportb(unsigned short port)
{
 register unsigned char ret;
 __asm__ volatile
   (
   "inb %%dx,%%al"
   :"=a" (ret)
   :"d" (port)
   );
 return ret;
}

variable_types:
port
unsigned short

variable_types:
ret
unsigned char

return_type: unsigned char


decompiled_code:
__int64 __fastcall init_8259a(unsigned __int8 a1, unsigned __int8 a2)
{
__int64 result; // rax

__outbyte(0x20u, 0x11u);
__outbyte(0xA0u, 0x11u);
__outbyte(0x21u, a1);
__outbyte(0xA1u, a2);
__outbyte(0x21u, 4u);
__outbyte(0xA1u, 2u);
__outbyte(0x21u, 1u);
__outbyte(0xA1u, 1u);
result = 255LL;
__outbyte(0x21u, 0xFFu);
__outbyte(0xA1u, 0xFFu);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 a1, unsigned __int8 a2)
{
__int64 result; // rax

__outbyte(0x20u, 0x11u);
__outbyte(0xA0u, 0x11u);
__outbyte(0x21u, a1);
__outbyte(0xA1u, a2);
__outbyte(0x21u, 4u);
__outbyte(0xA1u, 2u);
__outbyte(0x21u, 1u);
__outbyte(0xA1u, 1u);
result = 255LL;
__outbyte(0x21u, 0xFFu);
__outbyte(0xA1u, 0xFFu);
return result;
}


decompiled_code:
int __fastcall enable_irq(int a1)
{
unsigned __int8 v1; // al
char v2; // cl
int result; // eax
unsigned __int8 v4; // al
char v5; // cl

if ( a1 > 7 )
{
v4 = inportb(0xA1u);
result = v4 & ~(1 << v5);
__outbyte(0xA1u, result);
}
else
{
v1 = inportb(0x21u);
result = v1 & ~(1 << v2);
__outbyte(0x21u, result);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1)
{
unsigned __int8 v1; // al
char v2; // cl
int result; // eax
unsigned __int8 v4; // al
char v5; // cl

if ( a1 > 7 )
{
v4 = func0(0xA1u);
result = v4 & ~(1 << v5);
__outbyte(0xA1u, result);
}
else
{
v1 = func0(0x21u);
result = v1 & ~(1 << v2);
__outbyte(0x21u, result);
}
return result;
}

original_code:
void enable_irq(int irq)
{
 if(irq < 8)
  __asm__ volatile("outb %%al,%%dx"::"a" (inportb(0x21) & ~(1 << irq)),"d" (0x21));
 else
  __asm__ volatile("outb %%al,%%dx"::"a" (inportb(0xA1) & ~(1 << (irq-8))),"d" (0xA1));
}

variable_types: irq int


decompiled_code:
int __fastcall disable_irq(int a1)
{
unsigned __int8 v1; // al
char v2; // cl
int result; // eax
unsigned __int8 v4; // al
char v5; // cl

if ( a1 > 7 )
{
v4 = inportb(0xA1u);
result = v4 | (1 << v5);
__outbyte(0xA1u, result);
}
else
{
v1 = inportb(0x21u);
result = v1 | (1 << v2);
__outbyte(0x21u, result);
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(int a1)
{
unsigned __int8 v1; // al
char v2; // cl
int result; // eax
unsigned __int8 v4; // al
char v5; // cl

if ( a1 > 7 )
{
v4 = func0(0xA1u);
result = v4 | (1 << v5);
__outbyte(0xA1u, result);
}
else
{
v1 = func0(0x21u);
result = v1 | (1 << v2);
__outbyte(0x21u, result);
}
return result;
}

original_code:
void disable_irq(int irq)
{
 if(irq < 8)
  __asm__ volatile("outb %%al,%%dx"::"a" (inportb(0x21) | (1 << irq)),"d" (0x21));
 else
  __asm__ volatile("outb %%al,%%dx"::"a" (inportb(0xA1) | (1 << (irq-8))),"d" (0xA1));
}


decompiled_code:
// attributes: thunk
__int64 __fastcall pic_init(unsigned __int8 a1, unsigned __int8 a2)
{
return init_8259a(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int8 a1, unsigned __int8 a2)
{
return func1(a1, a2);
}

original_code:
void pic_init(int pic1_start, int pic2_start)
{
 init_8259a(pic1_start, pic2_start);
}


decompiled_code:
__int64 __fastcall get_file_blk(__int64 a1)
{
return *(_QWORD *)(a1 + 168) << 9;
}

original_code:
static inline uint32_t get_file_blk(struct vnode *vn)
{
 struct ext2inode *in = &vn->v_ino.ext2inode;
 return (in->i_blocks * 512);
}

canonical_original_code:
static inline unsigned long get_file_blk(struct vnode *vn)
{
 struct ext2inode *in = &vn->v_ino.ext2inode;
 return (in->i_blocks * 512);
}

variable_types: struct ext2inode { unsigned short i_mode; unsigned short i_uid; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_dtime; unsigned short i_gid; unsigned short i_links_count; unsigned long i_blocks; unsigned long i_flags; union { struct { unsigned long l_i_reserved1; } linux1; struct { unsigned long h_i_translator; } hurd1; struct { unsigned long m_i_reserved1; } masix1; } osd1; unsigned long i_block[-1]; unsigned long i_generation; unsigned long i_file_acl; unsigned long i_dir_acl; unsigned long i_faddr; union { struct { unsigned char l_i_frag; unsigned char l_i_fsize; unsigned short i_pad1; unsigned short l_i_uid_high; unsigned short l_i_gid_high; unsigned long l_i_reserved2; } linux2; struct { unsigned char h_i_frag; unsigned char h_i_fsize; unsigned short h_i_mode_high; unsigned short h_i_uid_high; unsigned short h_i_gid_high; unsigned short h_i_author; } hurd2; struct { unsigned char m_i_frag; unsigned char m_i_fsize; unsigned short m_pad1; unsigned long m_i_reserved2[2]; } masix2; } osd2; } *

return_type: unsigned long

user_defined_types: struct vnode { unsigned short v_flag; int v_count; struct vfs *v_fsmounted; struct vfs *vfsp; int v_inum; unsigned long v_rdev; int v_type; struct linked_list v_freelist; struct vnode *v_next; struct vnodeops *ops; void *data; struct mrx_mutex smlock; union inode v_ino; }

user_defined_types: union inode { struct ext2inode ext2inode; }

user_defined_types: struct vfs { struct linked_list vfs_next; struct vnode *vfs_mpoint; unsigned long vfs_dev; unsigned int blk_size; union { struct ext2sb ext2_sb; struct fat_super_block fat; } sb; struct vfsops *ops; struct mrx_mutex lock; }

user_defined_types: struct vnodeops { int (*vop_open)(struct file *, struct vnode *, int); int (*vop_close)(struct file *, struct vnode *); int (*vop_read)(struct file *, struct vnode *, void *, unsigned int); int (*vop_write)(struct file *, struct vnode *, void *, unsigned int); int (*vop_strategy)(); int (*vop_ioctl)(); int (*vop_create)(); int (*vop_remove)(); int (*vop_link)(); int (*vop_unlink)(); int (*vop_rename)(); int (*vop_mkdir)(); int (*vop_rmdir)(); int (*vop_readdir)(); int (*vop_symlink)(); int (*vop_poll)(); int (*vop_read_inode)(struct vnode *, int); unsigned long (*vop_bmap)(struct vnode *, unsigned long); void (*vop_write_inode)(struct vnode *); int (*vop_namei)(struct vnode *, char *, struct nameidata *); void (*vop_get_attr)(struct vnode *, struct vattr *); void (*vop_put_attr)(struct vnode *, struct vattr *); int (*vop_req_iospace)(int, int); }

user_defined_types: struct file { int f_access; unsigned long f_offset; int f_ref; struct indev vnode; }


original_code:
int check_name(char *dest, uint8_t nlen, char *src)
{
 int i=0,j=0, srclen;
 srclen = strlen(src);
 for(i=0,j=0;i<srclen;i++,j++)
 {
  if(src[i] == '?')
   continue;
  if(src[i] == '*')
  {
   for(;src[i] != '.';i++)
    if(src[i] == '\0')
     return 0;
   for(;dest[j] != '.';j++)
    if(src[j] == '\0')
     return 0;
  }
  if(src[i] != dest[j])
   return 1;
 }
 if(i != nlen)
  return 1;
 return 0;
}

canonical_original_code:
int check_name(char *dest, unsigned char nlen, char *src)
{
 int i = 0; int j = 0; int srclen;
 srclen = strlen(src);
 for(i=0,j=0;i<srclen;i++,j++)
 {
  if(src[i] == '?')
   continue;
  if(src[i] == '*')
  {
   for(;src[i] != '.';i++)
    if(src[i] == '\0')
     return 0;
   for(;dest[j] != '.';j++)
    if(src[j] == '\0')
     return 0;
  }
  if(src[i] != dest[j])
   return 1;
 }
 if(i != nlen)
  return 1;
 return 0;
}

variable_types:
dest
char *

variable_types:
nlen
unsigned char

variable_types:
src
char *

variable_types: i int

variable_types: j int

variable_types: srclen int