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

canonical_decompiled_code:
__int64 func2()
{
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 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 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; }


repo: mregmi/manrix

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

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

original_code:
int ext2_statvfs()
{
 return 0;
}

canonical_original_code:
int ext2_statvfs()
{
 return 0;
}

return_type: int


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

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

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 func5(__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 *

variable_types: ret int

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

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


decompiled_code:
__int64 __fastcall ext2_read(__int64 a1, _QWORD *a2, _DWORD *a3, unsigned int a4)
{
__int64 result; // rax
unsigned int v5; // er14
unsigned int v6; // er15
unsigned int v7; // eax
__int64 v8; // r12
unsigned __int64 v9; // rcx
unsigned int v10; // ebx
unsigned __int64 v11; // rax
unsigned int v13; // [rsp+Ch] [rbp-3Ch]

v13 = a4;
result = 0LL;
if ( *(_QWORD *)(a1 + 8) < a2[15] )
{
v5 = a4;
v6 = 0;
while ( 1 )
{
v7 = ext2_bmap(
a2,
(unsigned int)(*(_QWORD *)(a1 + 8) / (unsigned __int64)*(unsigned int *)(a2[2] + 32LL)),
*(_QWORD *)(a1 + 8) % (unsigned __int64)*(unsigned int *)(a2[2] + 32LL));
v8 = bread(a2[4], v7, *(unsigned int *)(a2[2] + 32LL));
if ( !v8 )
break;
v9 = *(_QWORD *)(a1 + 8);
v10 = *(_DWORD *)(a2[2] + 32LL) - v9 % *(unsigned int *)(a2[2] + 32LL);
if ( v10 > v5 )
v10 = v5;
if ( v9 + v10 > a2[15] )
v10 = a2[15] - v9;
memcpy(
a3,
(_DWORD *)(*(_DWORD *)(v8 + 56)
+ (unsigned int)(*(_QWORD *)(a1 + 8) % (unsigned __int64)*(unsigned int *)(a2[2] + 32LL))),
v10);
brelse(v8);
v11 = *(_QWORD *)(a1 + 8) + v10;
*(_QWORD *)(a1 + 8) = v11;
v6 += v10;
if ( v11 < a2[15] )
{
a3 = (_DWORD *)((char *)a3 + v10);
v5 -= v10;
if ( v13 > v6 )
continue;
}
return v6;
}
result = 4294967267LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, _QWORD *a2, _DWORD *a3, unsigned int a4)
{
__int64 result; // rax
unsigned int v5; // er14
unsigned int v6; // er15
unsigned int v7; // eax
__int64 v8; // r12
unsigned __int64 v9; // rcx
unsigned int v10; // ebx
unsigned __int64 v11; // rax
unsigned int v13; // [rsp+Ch] [rbp-3Ch]

v13 = a4;
result = 0LL;
if ( *(_QWORD *)(a1 + 8) < a2[15] )
{
v5 = a4;
v6 = 0;
while ( 1 )
{
v7 = ext2_bmap(
a2,
(unsigned int)(*(_QWORD *)(a1 + 8) / (unsigned __int64)*(unsigned int *)(a2[2] + 32LL)),
*(_QWORD *)(a1 + 8) % (unsigned __int64)*(unsigned int *)(a2[2] + 32LL));
v8 = bread(a2[4], v7, *(unsigned int *)(a2[2] + 32LL));
if ( !v8 )
break;
v9 = *(_QWORD *)(a1 + 8);
v10 = *(_DWORD *)(a2[2] + 32LL) - v9 % *(unsigned int *)(a2[2] + 32LL);
if ( v10 > v5 )
v10 = v5;
if ( v9 + v10 > a2[15] )
v10 = a2[15] - v9;
memcpy(
a3,
(_DWORD *)(*(_DWORD *)(v8 + 56)
+ (unsigned int)(*(_QWORD *)(a1 + 8) % (unsigned __int64)*(unsigned int *)(a2[2] + 32LL))),
v10);
brelse(v8);
v11 = *(_QWORD *)(a1 + 8) + v10;
*(_QWORD *)(a1 + 8) = v11;
v6 += v10;
if ( v11 < a2[15] )
{
a3 = (_DWORD *)((char *)a3 + v10);
v5 -= v10;
if ( v13 > v6 )
continue;
}
return v6;
}
result = 4294967267LL;
}
return result;
}

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

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

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


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

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

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

result = ext2_read_sb();
if ( (int)result >= 0 )
{
v3[9] = ext2_vnode_ops;
v3[2] = a1;
v2 = vget(v3, 2LL, *(_QWORD *)(a1 + 24));
*(_QWORD *)(v2 + 72) = ext2_vnode_ops;
*(_QWORD *)(a1 + 16) = v2;
*(_DWORD *)(v2 + 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 func8(__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 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; }


decompiled_code:
int *ext2fs_construct()
{
int *v0; // rbx

v0 = (int *)malloc(0x7E8uLL);
memset(v0, 0, 0x7E8u);
*((_QWORD *)v0 + 249) = ext2_vfs_ops;
return v0;
}

canonical_decompiled_code:
int *func9()
{
int *v0; // rbx

v0 = (int *)malloc(0x7E8uLL);
func0(v0, 0, 0x7E8u);
*((_QWORD *)v0 + 249) = ext2_vfs_ops;
return v0;
}

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

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


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

canonical_decompiled_code:
__int64 func10()
{
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 func11()
{
return unregister_vfs((unsigned int)index);
}

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


decompiled_code:
__int64 vm_init()
{
list_init(&kernel_object);
vm_page_init();
slab_init();
vm_map_init();
vm_object_init();
return pmap_init();
}

canonical_decompiled_code:
__int64 func1()
{
func0(&kernel_object);
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:
__int64 __fastcall fd_alloc(__int64 a1)
{
return syscall_fd_alloc(a1, 0xFFFFFFFFLL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return func0(a1, 0xFFFFFFFFLL, 0LL);
}

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 func1(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; } *


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

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

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 func1(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; // r12
unsigned __int8 *v5; // r14
unsigned __int8 v6; // bl
unsigned __int8 v7; // bp

if ( a3 )
{
v3 = a1;
v5 = &a1[a3];
while ( 1 )
{
v6 = *v3;
v7 = *a2;
++v3;
++a2;
if ( !v7 )
break;
if ( !v6 )
break;
if ( v6 != v7 )
{
v6 = tolower(v6);
v7 = tolower(v7);
if ( v6 != v7 )
break;
}
if ( v3 == v5 )
{
v6 = v7;
return v6 - (unsigned int)v7;
}
}
}
else
{
v7 = 0;
v6 = 0;
}
return v6 - (unsigned int)v7;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int8 *a1, unsigned __int8 *a2, int a3)
{
unsigned __int8 *v3; // r12
unsigned __int8 *v5; // r14
unsigned __int8 v6; // bl
unsigned __int8 v7; // bp

if ( a3 )
{
v3 = a1;
v5 = &a1[a3];
while ( 1 )
{
v6 = *v3;
v7 = *a2;
++v3;
++a2;
if ( !v7 )
break;
if ( !v6 )
break;
if ( v6 != v7 )
{
v6 = func0(v6);
v7 = func0(v7);
if ( v6 != v7 )
break;
}
if ( v3 == v5 )
{
v6 = v7;
return v6 - (unsigned int)v7;
}
}
}
else
{
v7 = 0;
v6 = 0;
}
return v6 - (unsigned int)v7;
}

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 v3; // cl
char v4; // r9
unsigned int v5; // esi
char v6; // dl
_BYTE *v7; // rax

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

canonical_decompiled_code:
__int64 __fastcall func3(char *a1, _BYTE *a2)
{
char v3; // cl
char v4; // r9
unsigned int v5; // esi
char v6; // dl
_BYTE *v7; // rax

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

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(a1, v2, 0LL);
return find_vnode(v2[0], (unsigned int)v2[2]);
}

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

func2(a1, v2, 0LL);
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: 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; }


readdir

decompiled_code:
__int64 __fastcall readdir(__int64 a1)
{
int v1; // ebp
__int64 result; // rax
unsigned __int16 v3; // dx
int v4; // eax

v1 = errno;
while ( *(_DWORD *)(a1 + 24) < *(_DWORD *)(a1 + 20) )
{
LABEL_7:
result = *(_QWORD *)(a1 + 8) + *(unsigned int *)(a1 + 24);
v3 = *(_WORD *)(result + 4);
*(_BYTE *)(result + *(unsigned __int8 *)(result + 6) + 8) = 0;
*(_DWORD *)(a1 + 24) += v3;
*(_QWORD *)(a1 + 32) += v3;
if ( *(_DWORD *)result )
return result;
}
v4 = _getdirentries(*(_DWORD *)a1, *(void **)(a1 + 8), *(unsigned int *)(a1 + 16));
if ( v4 > 0 )
{
*(_DWORD *)(a1 + 20) = v4;
*(_DWORD *)(a1 + 24) = 0;
goto LABEL_7;
}
if ( v4 >= 0 || (result = 0LL, errno == 45) )
{
errno = v1;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
int v1; // ebp
__int64 result; // rax
unsigned __int16 v3; // dx
int v4; // eax

v1 = errno;
while ( *(_DWORD *)(a1 + 24) < *(_DWORD *)(a1 + 20) )
{
LABEL_7:
result = *(_QWORD *)(a1 + 8) + *(unsigned int *)(a1 + 24);
v3 = *(_WORD *)(result + 4);
*(_BYTE *)(result + *(unsigned __int8 *)(result + 6) + 8) = 0;
*(_DWORD *)(a1 + 24) += v3;
*(_QWORD *)(a1 + 32) += v3;
if ( *(_DWORD *)result )
return result;
}
v4 = func0(*(_DWORD *)a1, *(void **)(a1 + 8), *(unsigned int *)(a1 + 16));
if ( v4 > 0 )
{
*(_DWORD *)(a1 + 20) = v4;
*(_DWORD *)(a1 + 24) = 0;
goto LABEL_7;
}
if ( v4 >= 0 || (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; // ebx
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; // ebx
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_D + a2 + 3));
}

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_D + a2 + 3));
}

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 func1(_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 file { int f_access; unsigned long f_offset; int f_ref; struct indev vnode; }


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 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: 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)
{
int result; // eax

if ( a1 > 7 )
{
result = inportb(0xA1u) & ~(1 << (a1 - 8));
__outbyte(0xA1u, result);
}
else
{
result = inportb(0x21u) & ~(1 << a1);
__outbyte(0x21u, result);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1)
{
int result; // eax

if ( a1 > 7 )
{
result = func0(0xA1u) & ~(1 << (a1 - 8));
__outbyte(0xA1u, result);
}
else
{
result = func0(0x21u) & ~(1 << a1);
__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)
{
int result; // eax

if ( a1 > 7 )
{
result = inportb(0xA1u) | (1 << (a1 - 8));
__outbyte(0xA1u, result);
}
else
{
result = inportb(0x21u) | (1 << a1);
__outbyte(0x21u, result);
}
return result;
}

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

if ( a1 > 7 )
{
result = func0(0xA1u) | (1 << (a1 - 8));
__outbyte(0xA1u, result);
}
else
{
result = func0(0x21u) | (1 << a1);
__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: 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; }


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


original_code:
int ext2_readdir(struct vnode *parent, char *path, struct nameidata *nm)
{
 uint32_t block_no, blkindex = 0, blksz;
 struct ext2inode *eino = &parent->v_ino.ext2inode;
 struct bcache *entry;
 struct ext2dirent *dir;
 struct vnode *vnode = parent;
 uint32_t last_sym= 0, entrysz;
 char name[255];
 char *pth = path;
 int ret= -0x1d , comp = 0, index = 0;
again:
 do{
  while(*pth == '/')
   pth++;
  while (*pth != '/')
  {
   if(*pth == '\0')
    break;
   name[index] = *pth++;
   index++;
  }
  name[index] = 0;
  if((*pth == '\0') || (*(pth + 1) == '\0'))
   comp = 1;
  pthread_mutex_lock(&vnode->smlock);
  do{
   if(!(vnode->v_type & 0x4))
   {
    ret = -0x1d;
    goto err;
   }
   if(vnode->v_fsmounted)
   {
    nm->vfs = vnode->v_fsmounted;
    return 1;
   }
   can_execute(&nm->id, eino);
   block_no = ext2_bmap(vnode, blkindex);
   entry = (struct bcache *)bread(vnode->v_rdev, block_no, vnode->vfsp->blk_size);
   if(!entry)
    return -0x1c;
   dir = (struct ext2dirent *)entry->b_data;
   entrysz = ((uint32_t)entry->b_data + entry->b_datasz);
   while((dir->rec_len != 0))
   {
    if(dir->namelen > 255)
     return (-0x26);
    ret = check_name(dir->name, dir->namelen, name);
    if(ret == 0)
     goto fileok;
    dir = (struct ext2dirent *)(((uint32_t)dir)+dir->rec_len);
    if((uint32_t)dir >= entrysz)
     break;
   }
   brelse(entry);
   blksz = get_file_blk(vnode);
   blkindex++;
   if((blkindex * vnode->vfsp->blk_size) >= blksz)
    break;
  }while(1);
  if(comp == 1)
   nm->vn = vnode;
  pthread_mutex_unlock(&vnode->smlock);
  return -1;
 fileok:
  pthread_mutex_unlock(&vnode->smlock);
  vnode = vget(vnode, dir->inum, vnode->v_rdev);
  if(vnode == ((void *) 0))
   return -1;
  eino = &vnode->v_ino.ext2inode;
  can_execute(&nm->id, eino);
  blkindex = 0;
  index = 0;
 }while(comp == 0);
 nm->vn = vnode;
 pthread_mutex_lock(&vnode->smlock);
 return 0;
err:
 pthread_mutex_unlock(&vnode->smlock);
 return ret;
}

canonical_original_code:
int ext2_readdir(struct vnode *parent, char *path, struct nameidata *nm)
{
 unsigned long block_no; unsigned long blkindex = 0; unsigned long blksz;
 struct ext2inode *eino = &parent->v_ino.ext2inode;
 struct bcache *entry;
 struct ext2dirent *dir;
 struct vnode *vnode = parent;
 unsigned long last_sym = 0; unsigned long entrysz;
 char name[255];
 char *pth = path;
 int ret = -0x1d; int comp = 0; int index = 0;
again:
 do{
  while(*pth == '/')
   pth++;
  while (*pth != '/')
  {
   if(*pth == '\0')
    break;
   name[index] = *pth++;
   index++;
  }
  name[index] = 0;
  if((*pth == '\0') || (*(pth + 1) == '\0'))
   comp = 1;
  pthread_mutex_lock(&vnode->smlock);
  do{
   if(!(vnode->v_type & 0x4))
   {
    ret = -0x1d;
    goto err;
   }
   if(vnode->v_fsmounted)
   {
    nm->vfs = vnode->v_fsmounted;
    return 1;
   }
   can_execute(&nm->id, eino);
   block_no = ext2_bmap(vnode, blkindex);
   entry = (struct bcache *)bread(vnode->v_rdev, block_no, vnode->vfsp->blk_size);
   if(!entry)
    return -0x1c;
   dir = (struct ext2dirent *)entry->b_data;
   entrysz = ((unsigned long)entry->b_data + entry->b_datasz);
   while((dir->rec_len != 0))
   {
    if(dir->namelen > 255)
     return (-0x26);
    ret = check_name(dir->name, dir->namelen, name);
    if(ret == 0)
     goto fileok;
    dir = (struct ext2dirent *)(((unsigned long)dir)+dir->rec_len);
    if((unsigned long)dir >= entrysz)
     break;
   }
   brelse(entry);
   blksz = get_file_blk(vnode);
   blkindex++;
   if((blkindex * vnode->vfsp->blk_size) >= blksz)
    break;
  }while(1);
  if(comp == 1)
   nm->vn = vnode;
  pthread_mutex_unlock(&vnode->smlock);
  return -1;
 fileok:
  pthread_mutex_unlock(&vnode->smlock);
  vnode = vget(vnode, dir->inum, vnode->v_rdev);
  if(vnode == ((void *) 0))
   return -1;
  eino = &vnode->v_ino.ext2inode;
  can_execute(&nm->id, eino);
  blkindex = 0;
  index = 0;
 }while(comp == 0);
 nm->vn = vnode;
 pthread_mutex_lock(&vnode->smlock);
 return 0;
err:
 pthread_mutex_unlock(&vnode->smlock);
 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:
nm
struct nameidata *

variable_types:
blkindex
unsigned long

variable_types:
blksz
unsigned long

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: struct ext2dirent { unsigned long inum; unsigned short rec_len; unsigned char namelen; unsigned char file_type; char name[255]; } *

variable_types:
entrysz
unsigned long

variable_types:
name
char [255]

variable_types:
pth
char *

variable_types: ret int

variable_types: comp int

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

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


strlen

decompiled_code:
__int64 __fastcall strlen(_BYTE *a1)
{
__int64 v1; // rcx
bool v2; // zf

v1 = 0xFFFFFFFFLL;
do
{
if ( !v1 )
break;
v2 = *a1++ == 0;
--v1;
}
while ( !v2 );
return (unsigned int)(-(int)v1 - 2);
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1)
{
__int64 v1; // rcx
bool v2; // zf

v1 = 0xFFFFFFFFLL;
do
{
if ( !v1 )
break;
v2 = *a1++ == 0;
--v1;
}
while ( !v2 );
return (unsigned int)(-(int)v1 - 2);
}

original_code:
static inline size_t strlen(const char * s)
{
int d0;
register int __res;
__asm__ __volatile__(
 "repne\n\t"
 "scasb\n\t"
 "notl %0\n\t"
 "decl %0"
 :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffffu));
return __res;
}

canonical_original_code:
static inline unsigned int strlen(char *s)
{
int d0;
register int __res;
__asm__ __volatile__(
 "repne\n\t"
 "scasb\n\t"
 "notl %0\n\t"
 "decl %0"
 :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffffu));
return __res;
}

variable_types:
s
char *


original_code:
static inline int read_primary(MBR *mbr, struct partition_info *pinfo)
{
 PARTITION *part;
 int index, ebr = -1;
 for(index = 1; index <= 4; index++)
 {
  part = &mbr->part[index];
  pinfo->start = part->relativeSectors;
  pinfo->size = part->totalSectors;
  pinfo->ptype = part->systemId;
  pinfo->flag = part->bootIndicator;
 printf(" Part %x,  size %d MB lba %d\n", part->systemId, part->totalSectors/(2 * 1024), part->relativeSectors);
  if((pinfo->ptype == 0x05) ||
   (pinfo->ptype == 0x0F))
   ebr = index;
 }
 return ebr;
}

canonical_original_code:
static inline int read_primary(struct tagMBR *mbr, struct partition_info *pinfo)
{
 struct tagPARTITION *part;
 int index; int ebr = -1;
 for(index = 1; index <= 4; index++)
 {
  part = &mbr->part[index];
  pinfo->start = part->relativeSectors;
  pinfo->size = part->totalSectors;
  pinfo->ptype = part->systemId;
  pinfo->flag = part->bootIndicator;
 printf(" Part %x,  size %d MB lba %d\n", part->systemId, part->totalSectors/(2 * 1024), part->relativeSectors);
  if((pinfo->ptype == 0x05) ||
   (pinfo->ptype == 0x0F))
   ebr = index;
 }
 return ebr;
}

variable_types: struct tagMBR { char res[446]; struct tagPARTITION { unsigned char bootIndicator; unsigned char startingHead; unsigned short start; unsigned char systemId; unsigned char endingHead; unsigned short end; unsigned long relativeSectors; unsigned long totalSectors; } part[4]; unsigned short signature; } *

variable_types: struct partition_info { unsigned long start; unsigned long size; unsigned short ptype; unsigned short flag; } *

variable_types: struct tagPARTITION { unsigned char bootIndicator; unsigned char startingHead; unsigned short start; unsigned char systemId; unsigned char endingHead; unsigned short end; unsigned long relativeSectors; unsigned long totalSectors; } *

variable_types: index int

variable_types: ebr int

user_defined_types: struct tagMBR { char res[446]; struct tagPARTITION part[4]; unsigned short signature; }