canonical_original_code:
void xfs_sb_from_disk(struct xfs_sb *to, struct xfs_dsb *from)
{
 to->sb_magicnum = ((__u32)( (((__u32)(from->sb_magicnum) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_magicnum) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_magicnum) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_magicnum) & ( unsigned int)0xff000000UL) >> 24)));
 to->sb_blocksize = ((__u32)( (((__u32)(from->sb_blocksize) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_blocksize) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_blocksize) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_blocksize) & ( unsigned int)0xff000000UL) >> 24)));
 to->sb_dblocks = ((__u64)( (((__u64)(from->sb_dblocks) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_dblocks) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_dblocks) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_dblocks) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_dblocks) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_dblocks) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_dblocks) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_dblocks) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->sb_rblocks = ((__u64)( (((__u64)(from->sb_rblocks) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_rblocks) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_rblocks) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_rblocks) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_rblocks) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_rblocks) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_rblocks) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_rblocks) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->sb_rextents = ((__u64)( (((__u64)(from->sb_rextents) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_rextents) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_rextents) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_rextents) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_rextents) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_rextents) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_rextents) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_rextents) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 mem_cpy(&to->sb_uuid, &from->sb_uuid, sizeof(to->sb_uuid));
 to->sb_logstart = ((__u64)( (((__u64)(from->sb_logstart) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_logstart) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_logstart) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_logstart) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_logstart) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_logstart) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_logstart) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_logstart) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->sb_rootino = ((__u64)( (((__u64)(from->sb_rootino) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_rootino) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_rootino) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_rootino) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_rootino) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_rootino) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_rootino) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_rootino) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->sb_rbmino = ((__u64)( (((__u64)(from->sb_rbmino) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_rbmino) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_rbmino) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_rbmino) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_rbmino) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_rbmino) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_rbmino) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_rbmino) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->sb_rsumino = ((__u64)( (((__u64)(from->sb_rsumino) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_rsumino) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_rsumino) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_rsumino) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_rsumino) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_rsumino) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_rsumino) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_rsumino) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->sb_rextsize = ((__u32)( (((__u32)(from->sb_rextsize) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_rextsize) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_rextsize) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_rextsize) & ( unsigned int)0xff000000UL) >> 24)));
 to->sb_agblocks = ((__u32)( (((__u32)(from->sb_agblocks) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_agblocks) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_agblocks) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_agblocks) & ( unsigned int)0xff000000UL) >> 24)));
 to->sb_agcount = ((__u32)( (((__u32)(from->sb_agcount) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_agcount) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_agcount) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_agcount) & ( unsigned int)0xff000000UL) >> 24)));
 to->sb_rbmblocks = ((__u32)( (((__u32)(from->sb_rbmblocks) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_rbmblocks) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_rbmblocks) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_rbmblocks) & ( unsigned int)0xff000000UL) >> 24)));
 to->sb_logblocks = ((__u32)( (((__u32)(from->sb_logblocks) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_logblocks) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_logblocks) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_logblocks) & ( unsigned int)0xff000000UL) >> 24)));
 to->sb_versionnum = ((__u16)( (((__u16)(from->sb_versionnum) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->sb_versionnum) & ( unsigned short)0xff00U) >> 8)));
 to->sb_sectsize = ((__u16)( (((__u16)(from->sb_sectsize) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->sb_sectsize) & ( unsigned short)0xff00U) >> 8)));
 to->sb_inodesize = ((__u16)( (((__u16)(from->sb_inodesize) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->sb_inodesize) & ( unsigned short)0xff00U) >> 8)));
 to->sb_inopblock = ((__u16)( (((__u16)(from->sb_inopblock) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->sb_inopblock) & ( unsigned short)0xff00U) >> 8)));
 mem_cpy(&to->sb_fname, &from->sb_fname, sizeof(to->sb_fname));
 to->sb_blocklog = from->sb_blocklog;
 to->sb_sectlog = from->sb_sectlog;
 to->sb_inodelog = from->sb_inodelog;
 to->sb_inopblog = from->sb_inopblog;
 to->sb_agblklog = from->sb_agblklog;
 to->sb_rextslog = from->sb_rextslog;
 to->sb_inprogress = from->sb_inprogress;
 to->sb_imax_pct = from->sb_imax_pct;
 to->sb_icount = ((__u64)( (((__u64)(from->sb_icount) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_icount) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_icount) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_icount) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_icount) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_icount) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_icount) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_icount) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->sb_ifree = ((__u64)( (((__u64)(from->sb_ifree) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_ifree) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_ifree) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_ifree) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_ifree) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_ifree) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_ifree) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_ifree) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->sb_fdblocks = ((__u64)( (((__u64)(from->sb_fdblocks) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_fdblocks) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_fdblocks) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_fdblocks) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_fdblocks) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_fdblocks) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_fdblocks) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_fdblocks) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->sb_frextents = ((__u64)( (((__u64)(from->sb_frextents) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_frextents) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_frextents) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_frextents) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_frextents) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_frextents) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_frextents) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_frextents) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->sb_uquotino = ((__u64)( (((__u64)(from->sb_uquotino) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_uquotino) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_uquotino) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_uquotino) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_uquotino) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_uquotino) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_uquotino) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_uquotino) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->sb_gquotino = ((__u64)( (((__u64)(from->sb_gquotino) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->sb_gquotino) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->sb_gquotino) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->sb_gquotino) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->sb_gquotino) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->sb_gquotino) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->sb_gquotino) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->sb_gquotino) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->sb_qflags = ((__u16)( (((__u16)(from->sb_qflags) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->sb_qflags) & ( unsigned short)0xff00U) >> 8)));
 to->sb_flags = from->sb_flags;
 to->sb_shared_vn = from->sb_shared_vn;
 to->sb_inoalignmt = ((__u32)( (((__u32)(from->sb_inoalignmt) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_inoalignmt) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_inoalignmt) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_inoalignmt) & ( unsigned int)0xff000000UL) >> 24)));
 to->sb_unit = ((__u32)( (((__u32)(from->sb_unit) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_unit) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_unit) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_unit) & ( unsigned int)0xff000000UL) >> 24)));
 to->sb_width = ((__u32)( (((__u32)(from->sb_width) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_width) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_width) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_width) & ( unsigned int)0xff000000UL) >> 24)));
 to->sb_dirblklog = from->sb_dirblklog;
 to->sb_logsectlog = from->sb_logsectlog;
 to->sb_logsectsize = ((__u16)( (((__u16)(from->sb_logsectsize) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->sb_logsectsize) & ( unsigned short)0xff00U) >> 8)));
 to->sb_logsunit = ((__u32)( (((__u32)(from->sb_logsunit) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_logsunit) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_logsunit) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_logsunit) & ( unsigned int)0xff000000UL) >> 24)));
 to->sb_features2 = ((__u32)( (((__u32)(from->sb_features2) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_features2) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_features2) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_features2) & ( unsigned int)0xff000000UL) >> 24)));
 to->sb_bad_features2 = ((__u32)( (((__u32)(from->sb_bad_features2) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->sb_bad_features2) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->sb_bad_features2) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->sb_bad_features2) & ( unsigned int)0xff000000UL) >> 24)));
}

variable_types: struct xfs_sb { unsigned int sb_magicnum; unsigned int sb_blocksize; unsigned long long sb_dblocks; unsigned long long sb_rblocks; unsigned long long sb_rextents; struct uuid_t { unsigned char __u_bits[16]; } sb_uuid; unsigned long long sb_logstart; unsigned long long sb_rootino; unsigned long long sb_rbmino; unsigned long long sb_rsumino; unsigned int sb_rextsize; unsigned int sb_agblocks; unsigned int sb_agcount; unsigned int sb_rbmblocks; unsigned int sb_logblocks; unsigned short sb_versionnum; unsigned short sb_sectsize; unsigned short sb_inodesize; unsigned short sb_inopblock; char sb_fname[12]; unsigned char sb_blocklog; unsigned char sb_sectlog; unsigned char sb_inodelog; unsigned char sb_inopblog; unsigned char sb_agblklog; unsigned char sb_rextslog; unsigned char sb_inprogress; unsigned char sb_imax_pct; unsigned long long sb_icount; unsigned long long sb_ifree; unsigned long long sb_fdblocks; unsigned long long sb_frextents; unsigned long long sb_uquotino; unsigned long long sb_gquotino; unsigned short sb_qflags; unsigned char sb_flags; unsigned char sb_shared_vn; unsigned int sb_inoalignmt; unsigned int sb_unit; unsigned int sb_width; unsigned char sb_dirblklog; unsigned char sb_logsectlog; unsigned short sb_logsectsize; unsigned int sb_logsunit; unsigned int sb_features2; unsigned int sb_bad_features2; } *

variable_types: struct xfs_dsb { unsigned int sb_magicnum; unsigned int sb_blocksize; unsigned long long sb_dblocks; unsigned long long sb_rblocks; unsigned long long sb_rextents; struct uuid_t sb_uuid; unsigned long long sb_logstart; unsigned long long sb_rootino; unsigned long long sb_rbmino; unsigned long long sb_rsumino; unsigned int sb_rextsize; unsigned int sb_agblocks; unsigned int sb_agcount; unsigned int sb_rbmblocks; unsigned int sb_logblocks; unsigned short sb_versionnum; unsigned short sb_sectsize; unsigned short sb_inodesize; unsigned short sb_inopblock; char sb_fname[12]; unsigned char sb_blocklog; unsigned char sb_sectlog; unsigned char sb_inodelog; unsigned char sb_inopblog; unsigned char sb_agblklog; unsigned char sb_rextslog; unsigned char sb_inprogress; unsigned char sb_imax_pct; unsigned long long sb_icount; unsigned long long sb_ifree; unsigned long long sb_fdblocks; unsigned long long sb_frextents; unsigned long long sb_uquotino; unsigned long long sb_gquotino; unsigned short sb_qflags; unsigned char sb_flags; unsigned char sb_shared_vn; unsigned int sb_inoalignmt; unsigned int sb_unit; unsigned int sb_width; unsigned char sb_dirblklog; unsigned char sb_logsectlog; unsigned short sb_logsectsize; unsigned int sb_logsunit; unsigned int sb_features2; unsigned int sb_bad_features2; } *

user_defined_types: struct xfs_sb { unsigned int sb_magicnum; unsigned int sb_blocksize; unsigned long long sb_dblocks; unsigned long long sb_rblocks; unsigned long long sb_rextents; struct uuid_t sb_uuid; unsigned long long sb_logstart; unsigned long long sb_rootino; unsigned long long sb_rbmino; unsigned long long sb_rsumino; unsigned int sb_rextsize; unsigned int sb_agblocks; unsigned int sb_agcount; unsigned int sb_rbmblocks; unsigned int sb_logblocks; unsigned short sb_versionnum; unsigned short sb_sectsize; unsigned short sb_inodesize; unsigned short sb_inopblock; char sb_fname[12]; unsigned char sb_blocklog; unsigned char sb_sectlog; unsigned char sb_inodelog; unsigned char sb_inopblog; unsigned char sb_agblklog; unsigned char sb_rextslog; unsigned char sb_inprogress; unsigned char sb_imax_pct; unsigned long long sb_icount; unsigned long long sb_ifree; unsigned long long sb_fdblocks; unsigned long long sb_frextents; unsigned long long sb_uquotino; unsigned long long sb_gquotino; unsigned short sb_qflags; unsigned char sb_flags; unsigned char sb_shared_vn; unsigned int sb_inoalignmt; unsigned int sb_unit; unsigned int sb_width; unsigned char sb_dirblklog; unsigned char sb_logsectlog; unsigned short sb_logsectsize; unsigned int sb_logsunit; unsigned int sb_features2; unsigned int sb_bad_features2; }


init

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

if ( (unsigned int)open_file("tslib/xfs.lib", &unk_8B0) )
return (unsigned int)-1;
v0 = 0;
seek_file_set(0LL);
read_file(&dsb, 208LL, 1LL);
xfs_sb_from_disk((__int64)&sb, (__int64)&dsb);
seek_file_set(*((unsigned __int16 *)&sb + 51));
read_file(&agf, 64LL, 1LL);
seek_file_set(2 * *((unsigned __int16 *)&sb + 51));
read_file(&agi, 296LL, 1LL);
seek_file_set(3 * *((unsigned __int16 *)&sb + 51));
read_file(&agfl, 4LL, _byteswap_ulong(dword_7D0));
return v0;
}

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

if ( (unsigned int)open_file("tslib/xfs.lib", &unk_8B0) )
return (unsigned int)-1;
v0 = 0;
seek_file_set(0LL);
read_file(&dsb, 208LL, 1LL);
func0((__int64)&sb, (__int64)&dsb);
seek_file_set(*((unsigned __int16 *)&sb + 51));
read_file(&agf, 64LL, 1LL);
seek_file_set(2 * *((unsigned __int16 *)&sb + 51));
read_file(&agi, 296LL, 1LL);
seek_file_set(3 * *((unsigned __int16 *)&sb + 51));
read_file(&agfl, 4LL, _byteswap_ulong(dword_7D0));
return v0;
}

original_code:
int init()
{
 if ( open_file( "tslib/xfs.lib", "r"))
 {
  return -1;
 }
 else
 {
  seek_file_set( 0);
  read_file( ( void *) &dsb, sizeof( sb), 1);
  xfs_sb_from_disk( &sb, &dsb);
  seek_file_set( sb.sb_sectsize);
  read_file( ( void *)&agf, sizeof( agf), 1);
  seek_file_set( sb.sb_sectsize * 2);
  read_file( ( void *)&agi, sizeof( agi), 1);
  seek_file_set( sb.sb_sectsize * 3);
  read_file( ( void *)agfl, sizeof( xfs_agfl_t), ((__u32)( (((__u32)(agf.agf_flcount) & ( __u32)0x000000ffUL) << 24) | (((__u32)(agf.agf_flcount) & ( __u32)0x0000ff00UL) << 8) | (((__u32)(agf.agf_flcount) & ( __u32)0x00ff0000UL) >> 8) | (((__u32)(agf.agf_flcount) & ( __u32)0xff000000UL) >> 24))));
 }
 return 0;
}

canonical_original_code:
int init()
{
 if ( open_file( "tslib/xfs.lib", "r"))
 {
  return -1;
 }
 else
 {
  seek_file_set( 0);
  read_file( ( void *) &dsb, sizeof( sb), 1);
  xfs_sb_from_disk( &sb, &dsb);
  seek_file_set( sb.sb_sectsize);
  read_file( ( void *)&agf, sizeof( agf), 1);
  seek_file_set( sb.sb_sectsize * 2);
  read_file( ( void *)&agi, sizeof( agi), 1);
  seek_file_set( sb.sb_sectsize * 3);
  read_file( ( void *)agfl, sizeof( xfs_agfl_t), ((__u32)( (((__u32)(agf.agf_flcount) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(agf.agf_flcount) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(agf.agf_flcount) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(agf.agf_flcount) & ( unsigned int)0xff000000UL) >> 24))));
 }
 return 0;
}

return_type: int


decompiled_code:
__int64 __fastcall get_sb_magic(__int64 a1)
{
return mem_cpy(a1, &sb, 4LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return mem_cpy(a1, &sb, 4LL);
}

original_code:
void get_sb_magic( char * magic)
{
 char *cur = ( char *)&(sb.sb_magicnum);
 mem_cpy( magic, cur, 4);
}

canonical_original_code:
void get_sb_magic(char *magic)
{
 char *cur = ( char *)&(sb.sb_magicnum);
 mem_cpy( magic, cur, 4);
}

variable_types:
magic
char *

variable_types:
cur
char *

return_type: void


decompiled_code:
__int64 get_dsb_magic_int()
{
return (unsigned int)dsb;
}

canonical_decompiled_code:
__int64 func4()
{
return (unsigned int)dsb;
}

original_code:
unsigned int get_dsb_magic_int()
{
 return dsb.sb_magicnum;
}

return_type: unsigned int


decompiled_code:
__int64 get_sbs_count()
{
return 46LL;
}

canonical_decompiled_code:
__int64 func5()
{
return 46LL;
}

original_code:
int get_sbs_count()
{
 return ((int)XFS_SBS_FIELDCOUNT);
}


decompiled_code:
__int64 get_dsb_size()
{
return 208LL;
}

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

original_code:
int get_dsb_size()
{
 return sizeof( xfs_dsb_t);
}


decompiled_code:
__int64 get_sb_size()
{
return get_dsb_size();
}

canonical_decompiled_code:
__int64 func7()
{
return func6();
}

original_code:
int get_sb_size()
{
 return sizeof( xfs_sb_t);
}


decompiled_code:
__int64 get_sb_features2()
{
return sb[12].m128i_u32[2];
}

original_code:
int get_sb_features2()
{
 return sb.sb_features2;
}


decompiled_code:
__int64 get_sb_sectsize()
{
return sb[6].m128i_u16[3];
}

original_code:
int get_sb_sectsize()
{
 return sb.sb_sectsize;
}


decompiled_code:
__int64 __fastcall get_agf_magic(__int64 a1)
{
return mem_cpy(a1, &agf, 4LL);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return mem_cpy(a1, &agf, 4LL);
}

original_code:
int get_agf_magic( char * magic)
{
 char *cur = ( char *)&(agf.agf_magicnum);
 mem_cpy( magic, cur, 4);
}

canonical_original_code:
int get_agf_magic(char *magic)
{
 char *cur = ( char *)&(agf.agf_magicnum);
 mem_cpy( magic, cur, 4);
}


decompiled_code:
__int64 __fastcall get_agf_free_block(signed __int32 a1)
{
unsigned __int32 v1; // er8

v1 = 0;
if ( (int)_byteswap_ulong(dword_7D0) >= a1 )
v1 = _byteswap_ulong(agfl[_byteswap_ulong(dword_7C8) + a1]);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func11(signed __int32 a1)
{
unsigned __int32 v1; // er8

v1 = 0;
if ( (int)_byteswap_ulong(dword_7D0) >= a1 )
v1 = _byteswap_ulong(agfl[_byteswap_ulong(dword_7C8) + a1]);
return v1;
}

variable_types: count int

variable_types: flcount int

variable_types: ret int


decompiled_code:
__int64 get_agf_flcount()
{
return _byteswap_ulong(dword_7D0);
}

canonical_decompiled_code:
__int64 func12()
{
return _byteswap_ulong(dword_7D0);
}

canonical_original_code:
int get_agf_flcount()
{
 return ((__u32)( (((__u32)(agf.agf_flcount) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(agf.agf_flcount) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(agf.agf_flcount) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(agf.agf_flcount) & ( unsigned int)0xff000000UL) >> 24)));
}


decompiled_code:
__int64 get_agf_versionnum()
{
return _byteswap_ulong(dword_7A4);
}

canonical_decompiled_code:
__int64 func13()
{
return _byteswap_ulong(dword_7A4);
}

canonical_original_code:
int get_agf_versionnum()
{
 return ((__u32)( (((__u32)(agf.agf_versionnum) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(agf.agf_versionnum) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(agf.agf_versionnum) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(agf.agf_versionnum) & ( unsigned int)0xff000000UL) >> 24)));
}


decompiled_code:
__int64 get_sb_ifree()
{
return sb[8].m128i_u32[2];
}

original_code:
int get_sb_ifree()
{
 return sb.sb_ifree;
}


decompiled_code:
__int64 get_sb_rootino()
{
return sb[3].m128i_i64[1];
}

original_code:
xfs_ino_t get_sb_rootino()
{
 return sb.sb_rootino;
}

canonical_original_code:
unsigned long long get_sb_rootino()
{
 return sb.sb_rootino;
}

return_type: unsigned long long


decompiled_code:
__int64 get_agi_root()
{
return _byteswap_ulong(dword_674);
}

canonical_decompiled_code:
__int64 func16()
{
return _byteswap_ulong(dword_674);
}

canonical_original_code:
long long get_agi_root()
{
 return ( xfs_daddr_t)((__u32)( (((__u32)(agi.agi_root) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(agi.agi_root) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(agi.agi_root) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(agi.agi_root) & ( unsigned int)0xff000000UL) >> 24)));
}

return_type: long long


decompiled_code:
__int64 get_agi_seqno()
{
return _byteswap_ulong(dword_668);
}

canonical_decompiled_code:
__int64 func17()
{
return _byteswap_ulong(dword_668);
}

canonical_original_code:
unsigned int get_agi_seqno()
{
 return ((__u32)( (((__u32)(agi.agi_seqno) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(agi.agi_seqno) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(agi.agi_seqno) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(agi.agi_seqno) & ( unsigned int)0xff000000UL) >> 24)));
}


decompiled_code:
__int64 __fastcall open_file(const char *a1, const char *a2)
{
file = fopen(a1, a2);
return (unsigned int)-(file == 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, const char *a2)
{
file = fopen(a1, a2);
return (unsigned int)-(file == 0LL);
}

original_code:
int open_file( const char *name, const char *mode)
{
 file = fopen( name, mode);
 return file == ((void *)0) ? -1 : 0;
}

canonical_original_code:
int open_file(char *name, char *mode)
{
 file = fopen( name, mode);
 return file == ((void *)0) ? -1 : 0;
}

variable_types:
name
char *

variable_types:
mode
char *


decompiled_code:
size_t __fastcall read_file(void *a1, int a2, int a3)
{
return fread(a1, a2, a3, file);
}

canonical_decompiled_code:
size_t __fastcall func1(void *a1, int a2, int a3)
{
return fread(a1, a2, a3, file);
}

original_code:
int read_file( void *ptr, int size, int nmemb)
{
 return fread( ptr, size, nmemb, file);
}

canonical_original_code:
int read_file(void *ptr, int size, int nmemb)
{
 return fread( ptr, size, nmemb, file);
}

variable_types:
ptr
void *

variable_types: size int

variable_types: nmemb int


decompiled_code:
size_t __fastcall write_file(const void *a1, int a2, int a3)
{
return fwrite(a1, a2, a3, file);
}

canonical_decompiled_code:
size_t __fastcall func2(const void *a1, int a2, int a3)
{
return fwrite(a1, a2, a3, file);
}

original_code:
int write_file( void * ptr, int size, int nmemb)
{
 return fwrite( ptr, size, nmemb, file);
}

canonical_original_code:
int write_file(void *ptr, int size, int nmemb)
{
 return fwrite( ptr, size, nmemb, file);
}


decompiled_code:
int __fastcall seek_file(__int64 off, int whence)
{
return fseek(file, off, whence);
}

canonical_decompiled_code:
int __fastcall func3(__int64 off, int whence)
{
return fseek(file, off, whence);
}

original_code:
int seek_file( long offset, int whence)
{
 return fseek( file, offset, whence);
}

canonical_original_code:
int seek_file(long offset, int whence)
{
 return fseek( file, offset, whence);
}

variable_types: offset long

variable_types: whence int


decompiled_code:
int __fastcall seek_file_set(__int64 off)
{
return fseek(file, off, 0);
}

canonical_decompiled_code:
int __fastcall func4(__int64 off)
{
return fseek(file, off, 0);
}

original_code:
int seek_file_set( long offset)
{
 return fseek( file, offset, 0);
}

canonical_original_code:
int seek_file_set(long offset)
{
 return fseek( file, offset, 0);
}


decompiled_code:
int __fastcall seek_file_cur(__int64 off)
{
return fseek(file, off, 1);
}

canonical_decompiled_code:
int __fastcall func5(__int64 off)
{
return fseek(file, off, 1);
}

original_code:
int seek_file_cur( long offset)
{
 return fseek( file, offset, 1);
}

canonical_original_code:
int seek_file_cur(long offset)
{
 return fseek( file, offset, 1);
}


decompiled_code:
int __fastcall seek_file_end(__int64 off)
{
return fseek(file, off, 2);
}

canonical_decompiled_code:
int __fastcall func6(__int64 off)
{
return fseek(file, off, 2);
}

original_code:
int seek_file_end( long offset)
{
 return fseek( file, offset, 2);
}

canonical_original_code:
int seek_file_end(long offset)
{
 return fseek( file, offset, 2);
}


decompiled_code:
void *__fastcall mem_cpy(void *a1, const void *a2, int a3)
{
return memcpy(a1, a2, a3);
}

canonical_decompiled_code:
void *__fastcall func7(void *a1, const void *a2, int a3)
{
return memcpy(a1, a2, a3);
}

original_code:
void *mem_cpy( void *dst, void *src, int n)
{
 return memcpy( dst, src, n);
}

canonical_original_code:
void *mem_cpy(void *dst, void *src, int n)
{
 return memcpy( dst, src, n);
}

variable_types:
dst
void *

variable_types:
src
void *

variable_types: n int

return_type: void *


decompiled_code:
// attributes: thunk
void *mem_set(void *s, int c, size_t n)
{
return memset(s, c, n);
}

canonical_decompiled_code:
void *func8(void *s, int c, size_t n)
{
return memset(s, c, n);
}

original_code:
void *mem_set( void *s, int c, long n)
{
 return memset( s, c, n);
}

canonical_original_code:
void *mem_set(void *s, int c, long n)
{
 return memset( s, c, n);
}

variable_types:
s
void *

variable_types: c int

variable_types: n long


decompiled_code:
// attributes: thunk
int str_ncmp(const char *s1, const char *s2, size_t n)
{
return strncmp(s1, s2, n);
}

canonical_decompiled_code:
int func10(const char *s1, const char *s2, size_t n)
{
return strncmp(s1, s2, n);
}

original_code:
int str_ncmp( const char *s1, const char *s2, long n)
{
 return strncmp( s1, s2, n);
}

canonical_original_code:
int str_ncmp(char *s1, char *s2, long n)
{
 return strncmp( s1, s2, n);
}


print

decompiled_code:
int print(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
return vprintf(a1, arg);
}

canonical_decompiled_code:
int func12(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
return vprintf(a1, arg);
}

original_code:
int print( const char *format, ...)
{
 va_list arg;
 int ret;
 __builtin_va_start(arg,format);
 ret = vprintf( format, arg);
 __builtin_va_end(arg);
 return ret;
}

canonical_original_code:
int print(char *format, ...)
{
 __builtin_va_list arg;
 int ret;
 __builtin_va_start(arg,format);
 ret = vprintf( format, arg);
 __builtin_va_end(arg);
 return ret;
}

variable_types:
format
char *


eprint

decompiled_code:
int eprint(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
return vfprintf(stderr, format, arg);
}

canonical_decompiled_code:
int func13(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
return vfprintf(stderr, format, arg);
}

original_code:
int eprint( const char *format, ...)
{
 va_list arg;
 int ret;
 __builtin_va_start(arg,format);
 ret = vfprintf( stderr, format, arg);
 __builtin_va_end(arg);
 return ret;
}

canonical_original_code:
int eprint(char *format, ...)
{
 __builtin_va_list arg;
 int ret;
 __builtin_va_start(arg,format);
 ret = vfprintf( stderr, format, arg);
 __builtin_va_end(arg);
 return ret;
}


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

result = a2 | *a1 & 0xFFFFFFFFFFFFFFFELL;
*a1 = result;
return result;
}

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

result = a2 | *a1 & 0xFFFFFFFFFFFFFFFELL;
*a1 = result;
return result;
}

original_code:
static inline void rb_set_color(struct rb_node *rb, int color)
{
 rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
}

variable_types: struct rb_node { unsigned long rb_parent_color; struct rb_node *rb_right; struct rb_node *rb_left; } *

variable_types: color int


decompiled_code:
__int64 __fastcall rb_augment_path(_QWORD *a1, __int64 (__fastcall *a2)(_QWORD *, __int64), __int64 a3)
{
_QWORD *v4; // rbp
__int64 result; // rax
unsigned __int64 v6; // rbx
_QWORD *v7; // rdi

v4 = a1;
for ( result = a2(a1, a3); ; result = a2((_QWORD *)v6, a3) )
{
v6 = *v4 & 0xFFFFFFFFFFFFFFFCLL;
if ( !v6 )
break;
v7 = *(_QWORD **)(v6 + 16);
if ( v7 != v4 )
{
if ( !v7 )
goto LABEL_4;
LABEL_3:
a2(v7, a3);
goto LABEL_4;
}
if ( !*(_QWORD *)(v6 + 8) )
goto LABEL_3;
a2(*(_QWORD **)(v6 + 8), a3);
LABEL_4:
v4 = (_QWORD *)v6;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1, __int64 (__fastcall *a2)(_QWORD *, __int64), __int64 a3)
{
_QWORD *v4; // rbp
__int64 result; // rax
unsigned __int64 v6; // rbx
_QWORD *v7; // rdi

v4 = a1;
for ( result = a2(a1, a3); ; result = a2((_QWORD *)v6, a3) )
{
v6 = *v4 & 0xFFFFFFFFFFFFFFFCLL;
if ( !v6 )
break;
v7 = *(_QWORD **)(v6 + 16);
if ( v7 != v4 )
{
if ( !v7 )
goto LABEL_4;
LABEL_3:
a2(v7, a3);
goto LABEL_4;
}
if ( !*(_QWORD *)(v6 + 8) )
goto LABEL_3;
a2(*(_QWORD **)(v6 + 8), a3);
LABEL_4:
v4 = (_QWORD *)v6;
}
return result;
}

original_code:
static void rb_augment_path(struct rb_node *node, rb_augment_f func, void *data)
{
 struct rb_node *parent;
up:
 func(node, data);
 parent = ((struct rb_node *)((node)->rb_parent_color & ~3));
 if (!parent)
  return;
 if (node == parent->rb_left && parent->rb_right)
  func(parent->rb_right, data);
 else if (parent->rb_left)
  func(parent->rb_left, data);
 node = parent;
 goto up;
}

canonical_original_code:
static void rb_augment_path(struct rb_node *node, void (*func)(struct rb_node *node, void *data), void *data)
{
 struct rb_node *parent;
up:
 func(node, data);
 parent = ((struct rb_node *)((node)->rb_parent_color & ~3));
 if (!parent)
  return;
 if (node == parent->rb_left && parent->rb_right)
  func(parent->rb_right, data);
 else if (parent->rb_left)
  func(parent->rb_left, data);
 node = parent;
 goto up;
}

variable_types: void (*)(struct rb_node *node, void *data)

variable_types:
data
void *

user_defined_types: struct rb_node { unsigned long rb_parent_color; struct rb_node *rb_right; struct rb_node *rb_left; }


decompiled_code:
__int64 __fastcall rb_augment_insert(__int64 a1, __int64 (__fastcall *a2)(_QWORD *, __int64), __int64 a3)
{
_QWORD *v4; // r8

if ( *(_QWORD *)(a1 + 16) )
return rb_augment_path(*(_QWORD **)(a1 + 16), a2, a3);
v4 = *(_QWORD **)(a1 + 8);
if ( !v4 )
v4 = (_QWORD *)a1;
return rb_augment_path(v4, a2, a3);
}

original_code:
void rb_augment_insert(struct rb_node *node, rb_augment_f func, void *data)
{
 if (node->rb_left)
  node = node->rb_left;
 else if (node->rb_right)
  node = node->rb_right;
 rb_augment_path(node, func, data);
}

canonical_original_code:
void rb_augment_insert(struct rb_node *node, void (*func)(struct rb_node *node, void *data), void *data)
{
 if (node->rb_left)
  node = node->rb_left;
 else if (node->rb_right)
  node = node->rb_right;
 rb_augment_path(node, func, data);
}


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

if ( a1 )
result = rb_augment_path(a1, a2, a3);
return result;
}

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

if ( a1 )
result = func4(a1, a2, a3);
return result;
}

original_code:
void rb_augment_erase_end(struct rb_node *node, rb_augment_f func, void *data)
{
 if (node)
  rb_augment_path(node, func, data);
}

canonical_original_code:
void rb_augment_erase_end(struct rb_node *node, void (*func)(struct rb_node *node, void *data), void *data)
{
 if (node)
  rb_augment_path(node, func, data);
}


original_code:
struct rb_node *rb_first(const struct rb_root *root)
{
 struct rb_node *n;
 n = root->rb_node;
 if (!n)
  return (( void *)0);
 while (n->rb_left)
  n = n->rb_left;
 return n;
}

canonical_original_code:
struct rb_node *rb_first(struct rb_root *root)
{
 struct rb_node *n;
 n = root->rb_node;
 if (!n)
  return (( void *)0);
 while (n->rb_left)
  n = n->rb_left;
 return n;
}

variable_types: struct rb_root { struct rb_node *rb_node; } *

return_type: struct rb_node { unsigned long rb_parent_color; struct rb_node *rb_right; struct rb_node *rb_left; } *


original_code:
struct rb_node *rb_last(const struct rb_root *root)
{
 struct rb_node *n;
 n = root->rb_node;
 if (!n)
  return (( void *)0);
 while (n->rb_right)
  n = n->rb_right;
 return n;
}

canonical_original_code:
struct rb_node *rb_last(struct rb_root *root)
{
 struct rb_node *n;
 n = root->rb_node;
 if (!n)
  return (( void *)0);
 while (n->rb_right)
  n = n->rb_right;
 return n;
}

user_defined_types: struct rb_root { struct rb_node *rb_node; }


decompiled_code:
unsigned __int64 __fastcall rb_next(__int64 *a1)
{
__int64 v1; // rdx
unsigned __int64 v2; // rax
unsigned __int64 v3; // r8
__int64 *v5; // rax

v1 = *a1;
if ( a1 == (__int64 *)(*a1 & 0xFFFFFFFFFFFFFFFCLL) )
return 0LL;
v2 = a1[1];
if ( v2 )
{
do
{
v3 = v2;
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return v3;
}
while ( 1 )
{
v5 = (__int64 *)(v1 & 0xFFFFFFFFFFFFFFFCLL);
v3 = v1 & 0xFFFFFFFFFFFFFFFCLL;
if ( (v1 & 0xFFFFFFFFFFFFFFFCLL) == 0 )
break;
if ( (__int64 *)v5[1] != a1 )
return v3;
v1 = *v5;
a1 = v5;
}
return 0LL;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func9(__int64 *a1)
{
__int64 v1; // rdx
unsigned __int64 v2; // rax
unsigned __int64 v3; // r8
__int64 *v5; // rax

v1 = *a1;
if ( a1 == (__int64 *)(*a1 & 0xFFFFFFFFFFFFFFFCLL) )
return 0LL;
v2 = a1[1];
if ( v2 )
{
do
{
v3 = v2;
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return v3;
}
while ( 1 )
{
v5 = (__int64 *)(v1 & 0xFFFFFFFFFFFFFFFCLL);
v3 = v1 & 0xFFFFFFFFFFFFFFFCLL;
if ( (v1 & 0xFFFFFFFFFFFFFFFCLL) == 0 )
break;
if ( (__int64 *)v5[1] != a1 )
return v3;
v1 = *v5;
a1 = v5;
}
return 0LL;
}

original_code:
struct rb_node *rb_next(const struct rb_node *node)
{
 struct rb_node *parent;
 if (((struct rb_node *)((node)->rb_parent_color & ~3)) == node)
  return (( void *)0);
 if (node->rb_right) {
  node = node->rb_right;
  while (node->rb_left)
   node=node->rb_left;
  return (struct rb_node *)node;
 }
 while ((parent = ((struct rb_node *)((node)->rb_parent_color & ~3))) && node == parent->rb_right)
  node = parent;
 return parent;
}

canonical_original_code:
struct rb_node *rb_next(struct rb_node *node)
{
 struct rb_node *parent;
 if (((struct rb_node *)((node)->rb_parent_color & ~3)) == node)
  return (( void *)0);
 if (node->rb_right) {
  node = node->rb_right;
  while (node->rb_left)
   node=node->rb_left;
  return (struct rb_node *)node;
 }
 while ((parent = ((struct rb_node *)((node)->rb_parent_color & ~3))) && node == parent->rb_right)
  node = parent;
 return parent;
}

variable_types:
node
struct rb_node *


decompiled_code:
unsigned __int64 __fastcall rb_augment_erase_begin(__int64 *a1)
{
unsigned __int64 result; // rax
__int64 v2; // rdx
_QWORD *v3; // rdx
__int64 v4; // rcx

result = a1[1];
v2 = a1[2];
if ( result )
{
if ( v2 )
{
v3 = (_QWORD *)rb_next(a1);
result = v3[1];
if ( !result )
{
result = *v3 & 0xFFFFFFFFFFFFFFFCLL;
if ( result == v4 )
result = (unsigned __int64)v3;
}
}
}
else
{
result = a1[2];
if ( !v2 )
result = *a1 & 0xFFFFFFFFFFFFFFFCLL;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func10(__int64 *a1)
{
unsigned __int64 result; // rax
__int64 v2; // rdx
_QWORD *v3; // rdx
__int64 v4; // rcx

result = a1[1];
v2 = a1[2];
if ( result )
{
if ( v2 )
{
v3 = (_QWORD *)func9(a1);
result = v3[1];
if ( !result )
{
result = *v3 & 0xFFFFFFFFFFFFFFFCLL;
if ( result == v4 )
result = (unsigned __int64)v3;
}
}
}
else
{
result = a1[2];
if ( !v2 )
result = *a1 & 0xFFFFFFFFFFFFFFFCLL;
}
return result;
}

original_code:
struct rb_node *rb_augment_erase_begin(struct rb_node *node)
{
 struct rb_node *deepest;
 if (!node->rb_right && !node->rb_left)
  deepest = ((struct rb_node *)((node)->rb_parent_color & ~3));
 else if (!node->rb_right)
  deepest = node->rb_left;
 else if (!node->rb_left)
  deepest = node->rb_right;
 else {
  deepest = rb_next(node);
  if (deepest->rb_right)
   deepest = deepest->rb_right;
  else if (((struct rb_node *)((deepest)->rb_parent_color & ~3)) != node)
   deepest = ((struct rb_node *)((deepest)->rb_parent_color & ~3));
 }
 return deepest;
}


decompiled_code:
unsigned __int64 __fastcall rb_prev(__int64 *a1)
{
__int64 v1; // rdx
unsigned __int64 v2; // rax
unsigned __int64 v3; // r8
__int64 *v5; // rax

v1 = *a1;
if ( a1 == (__int64 *)(*a1 & 0xFFFFFFFFFFFFFFFCLL) )
return 0LL;
v2 = a1[2];
if ( v2 )
{
do
{
v3 = v2;
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
return v3;
}
while ( 1 )
{
v5 = (__int64 *)(v1 & 0xFFFFFFFFFFFFFFFCLL);
v3 = v1 & 0xFFFFFFFFFFFFFFFCLL;
if ( (v1 & 0xFFFFFFFFFFFFFFFCLL) == 0 )
break;
if ( (__int64 *)v5[2] != a1 )
return v3;
v1 = *v5;
a1 = v5;
}
return 0LL;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func11(__int64 *a1)
{
__int64 v1; // rdx
unsigned __int64 v2; // rax
unsigned __int64 v3; // r8
__int64 *v5; // rax

v1 = *a1;
if ( a1 == (__int64 *)(*a1 & 0xFFFFFFFFFFFFFFFCLL) )
return 0LL;
v2 = a1[2];
if ( v2 )
{
do
{
v3 = v2;
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
return v3;
}
while ( 1 )
{
v5 = (__int64 *)(v1 & 0xFFFFFFFFFFFFFFFCLL);
v3 = v1 & 0xFFFFFFFFFFFFFFFCLL;
if ( (v1 & 0xFFFFFFFFFFFFFFFCLL) == 0 )
break;
if ( (__int64 *)v5[2] != a1 )
return v3;
v1 = *v5;
a1 = v5;
}
return 0LL;
}

original_code:
struct rb_node *rb_prev(const struct rb_node *node)
{
 struct rb_node *parent;
 if (((struct rb_node *)((node)->rb_parent_color & ~3)) == node)
  return (( void *)0);
 if (node->rb_left) {
  node = node->rb_left;
  while (node->rb_right)
   node=node->rb_right;
  return (struct rb_node *)node;
 }
 while ((parent = ((struct rb_node *)((node)->rb_parent_color & ~3))) && node == parent->rb_left)
  node = parent;
 return parent;
}

canonical_original_code:
struct rb_node *rb_prev(struct rb_node *node)
{
 struct rb_node *parent;
 if (((struct rb_node *)((node)->rb_parent_color & ~3)) == node)
  return (( void *)0);
 if (node->rb_left) {
  node = node->rb_left;
  while (node->rb_right)
   node=node->rb_right;
  return (struct rb_node *)node;
 }
 while ((parent = ((struct rb_node *)((node)->rb_parent_color & ~3))) && node == parent->rb_left)
  node = parent;
 return parent;
}


original_code:
void rb_replace_node(struct rb_node *victim, struct rb_node *new,
       struct rb_root *root)
{
 struct rb_node *parent = ((struct rb_node *)((victim)->rb_parent_color & ~3));
 if (parent) {
  if (victim == parent->rb_left)
   parent->rb_left = new;
  else
   parent->rb_right = new;
 } else {
  root->rb_node = new;
 }
 if (victim->rb_left)
  rb_set_parent(victim->rb_left, new);
 if (victim->rb_right)
  rb_set_parent(victim->rb_right, new);
 *new = *victim;
}

variable_types:
new
struct rb_node *


decompiled_code:
__int64 __fastcall get_unaligned_be32(unsigned int *a1)
{
return _byteswap_ulong(*a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int *a1)
{
return _byteswap_ulong(*a1);
}

canonical_original_code:
static inline unsigned int get_unaligned_be32(void *p)
{
 unsigned int ret;
 unsigned char *left = ( __u8 *) &ret;
 unsigned char *right = ( __u8 *)p;
 *(left++) = *(right++);
 *(left++) = *(right++);
 *(left++) = *(right++);
 *(left++) = *(right++);
 return ((__u32)( (((__u32)(ret) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(ret) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(ret) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(ret) & ( unsigned int)0xff000000UL) >> 24)));
}

variable_types:
p
void *

variable_types:
ret
unsigned int

variable_types:
left
unsigned char *

variable_types:
right
unsigned char *


decompiled_code:
unsigned __int64 __fastcall get_unaligned_be64(unsigned __int64 *a1)
{
return _byteswap_uint64(*a1);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(unsigned __int64 *a1)
{
return _byteswap_uint64(*a1);
}

variable_types:
ret
unsigned long long


decompiled_code:
__int64 __fastcall xfs_dir2_sf_hdr_size(int a1)
{
return a1 == 0 ? 6 : 10;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
return a1 == 0 ? 6 : 10;
}

original_code:
static inline int xfs_dir2_sf_hdr_size(int i8count)
{
 return sizeof(struct xfs_dir2_sf_hdr) -
  (i8count == 0) *
  (sizeof(xfs_dir2_ino8_t) - sizeof(xfs_dir2_ino4_t));
}

user_defined_types: struct xfs_dir2_sf_hdr { unsigned char count; unsigned char i8count; union xfs_dir2_inou_t parent; }

user_defined_types: union xfs_dir2_inou_t { struct xfs_dir2_ino8_t i8; struct xfs_dir2_ino4_t i4; }

user_defined_types: struct xfs_dir2_ino8_t { unsigned char i[8]; }

user_defined_types: struct xfs_dir2_ino4_t { unsigned char i[4]; }


decompiled_code:
__int64 __fastcall xfs_dir2_sfe_inop(unsigned __int8 *a1)
{
return (__int64)&a1[*a1 + 3];
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned __int8 *a1)
{
return (__int64)&a1[*a1 + 3];
}

original_code:
static xfs_dir2_inou_t *
xfs_dir2_sfe_inop(
 struct xfs_dir2_sf_entry *sfep)
{
 return (xfs_dir2_inou_t *)&sfep->name[sfep->namelen];
}

canonical_original_code:
static union xfs_dir2_inou_t *xfs_dir2_sfe_inop(struct xfs_dir2_sf_entry *sfep)
{
 return (union xfs_dir2_inou_t *)&sfep->name[sfep->namelen];
}

variable_types: struct xfs_dir2_sf_entry { unsigned char namelen; struct xfs_dir2_sf_off_t { unsigned char i[2]; } offset; unsigned char name[]; } *

return_type: union xfs_dir2_inou_t { struct xfs_dir2_ino8_t { unsigned char i[8]; } i8; struct xfs_dir2_ino4_t { unsigned char i[4]; } i4; } *

user_defined_types: struct xfs_dir2_sf_entry { unsigned char namelen; struct xfs_dir2_sf_off_t offset; unsigned char name[]; }


decompiled_code:
unsigned __int64 __fastcall xfs_dir2_sf_get_parent_ino(__int64 a1)
{
return xfs_dir2_sf_get_ino_isra_0(*(_BYTE *)(a1 + 1), (unsigned __int64 *)(a1 + 2));
}

canonical_decompiled_code:
unsigned __int64 __fastcall func14(__int64 a1)
{
return func10(*(_BYTE *)(a1 + 1), (unsigned __int64 *)(a1 + 2));
}

original_code:
xfs_ino_t
xfs_dir2_sf_get_parent_ino(
 struct xfs_dir2_sf_hdr *hdr)
{
 return xfs_dir2_sf_get_ino(hdr, &hdr->parent);
}

canonical_original_code:
unsigned long long xfs_dir2_sf_get_parent_ino(struct xfs_dir2_sf_hdr *hdr)
{
 return xfs_dir2_sf_get_ino(hdr, &hdr->parent);
}

variable_types: struct xfs_dir2_sf_hdr { unsigned char count; unsigned char i8count; union xfs_dir2_inou_t { struct xfs_dir2_ino8_t { unsigned char i[8]; } i8; struct xfs_dir2_ino4_t { unsigned char i[4]; } i4; } parent; } *


decompiled_code:
unsigned __int64 __fastcall xfs_dir2_sfe_get_ino(__int64 a1, unsigned __int8 *a2)
{
unsigned __int64 *v2; // rax
__int64 v3; // rdx

v2 = (unsigned __int64 *)xfs_dir2_sfe_inop(a2);
return xfs_dir2_sf_get_ino_isra_0(*(_BYTE *)(v3 + 1), v2);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func15(__int64 a1, unsigned __int8 *a2)
{
unsigned __int64 *v2; // rax
__int64 v3; // rdx

v2 = (unsigned __int64 *)func6(a2);
return func10(*(_BYTE *)(v3 + 1), v2);
}

original_code:
xfs_ino_t
xfs_dir2_sfe_get_ino(
 struct xfs_dir2_sf_hdr *hdr,
 struct xfs_dir2_sf_entry *sfep)
{
 return xfs_dir2_sf_get_ino(hdr, xfs_dir2_sfe_inop(sfep));
}

canonical_original_code:
unsigned long long xfs_dir2_sfe_get_ino(struct xfs_dir2_sf_hdr *hdr, struct xfs_dir2_sf_entry *sfep)
{
 return xfs_dir2_sf_get_ino(hdr, xfs_dir2_sfe_inop(sfep));
}

user_defined_types: struct xfs_dir2_sf_off_t { unsigned char i[2]; }


canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return a1 == 0 ? 6 : 10;
}

canonical_original_code:
static inline int xfs_dir2_sf_hdr_size(int i8count)
{
 return sizeof(struct xfs_dir2_sf_hdr) -
  (i8count == 0) *
  (sizeof(xfs_dir2_ino8_t) - sizeof(xfs_dir2_ino4_t));
}


decompiled_code:
__int64 __fastcall xfs_dir2_sf_firstentry(__int64 a1)
{
int v1; // eax
__int64 v2; // rdx

v1 = xfs_dir2_sf_hdr_size(*(unsigned __int8 *)(a1 + 1));
return v2 + v1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
int v1; // eax
__int64 v2; // rdx

v1 = func0(*(unsigned __int8 *)(a1 + 1));
return v2 + v1;
}

original_code:
static inline struct xfs_dir2_sf_entry *
xfs_dir2_sf_firstentry(struct xfs_dir2_sf_hdr *hdr)
{
 return (struct xfs_dir2_sf_entry *)
  ((char *)hdr + xfs_dir2_sf_hdr_size(hdr->i8count));
}

canonical_original_code:
static inline struct xfs_dir2_sf_entry *xfs_dir2_sf_firstentry(struct xfs_dir2_sf_hdr *hdr)
{
 return (struct xfs_dir2_sf_entry *)
  ((char *)hdr + xfs_dir2_sf_hdr_size(hdr->i8count));
}

return_type: struct xfs_dir2_sf_entry { unsigned char namelen; struct xfs_dir2_sf_off_t { unsigned char i[2]; } offset; unsigned char name[]; } *


canonical_original_code:
void xfs_dinode_from_disk(struct xfs_icdinode *to, struct xfs_dinode *from)
{
 to->di_magic = ((__u16)( (((__u16)(from->di_magic) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->di_magic) & ( unsigned short)0xff00U) >> 8)));
 to->di_mode = ((__u16)( (((__u16)(from->di_mode) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->di_mode) & ( unsigned short)0xff00U) >> 8)));
 to->di_version = from ->di_version;
 to->di_format = from->di_format;
 to->di_onlink = ((__u16)( (((__u16)(from->di_onlink) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->di_onlink) & ( unsigned short)0xff00U) >> 8)));
 to->di_uid = ((__u32)( (((__u32)(from->di_uid) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_uid) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_uid) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_uid) & ( unsigned int)0xff000000UL) >> 24)));
 to->di_gid = ((__u32)( (((__u32)(from->di_gid) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_gid) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_gid) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_gid) & ( unsigned int)0xff000000UL) >> 24)));
 to->di_nlink = ((__u32)( (((__u32)(from->di_nlink) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_nlink) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_nlink) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_nlink) & ( unsigned int)0xff000000UL) >> 24)));
 to->di_projid_lo = ((__u16)( (((__u16)(from->di_projid_lo) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->di_projid_lo) & ( unsigned short)0xff00U) >> 8)));
 to->di_projid_hi = ((__u16)( (((__u16)(from->di_projid_hi) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->di_projid_hi) & ( unsigned short)0xff00U) >> 8)));
 mem_cpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
 to->di_flushiter = ((__u16)( (((__u16)(from->di_flushiter) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->di_flushiter) & ( unsigned short)0xff00U) >> 8)));
 to->di_atime.t_sec = ((__u32)( (((__u32)(from->di_atime.t_sec) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_atime.t_sec) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_atime.t_sec) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_atime.t_sec) & ( unsigned int)0xff000000UL) >> 24)));
 to->di_atime.t_nsec = ((__u32)( (((__u32)(from->di_atime.t_nsec) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_atime.t_nsec) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_atime.t_nsec) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_atime.t_nsec) & ( unsigned int)0xff000000UL) >> 24)));
 to->di_mtime.t_sec = ((__u32)( (((__u32)(from->di_mtime.t_sec) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_mtime.t_sec) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_mtime.t_sec) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_mtime.t_sec) & ( unsigned int)0xff000000UL) >> 24)));
 to->di_mtime.t_nsec = ((__u32)( (((__u32)(from->di_mtime.t_nsec) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_mtime.t_nsec) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_mtime.t_nsec) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_mtime.t_nsec) & ( unsigned int)0xff000000UL) >> 24)));
 to->di_ctime.t_sec = ((__u32)( (((__u32)(from->di_ctime.t_sec) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_ctime.t_sec) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_ctime.t_sec) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_ctime.t_sec) & ( unsigned int)0xff000000UL) >> 24)));
 to->di_ctime.t_nsec = ((__u32)( (((__u32)(from->di_ctime.t_nsec) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_ctime.t_nsec) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_ctime.t_nsec) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_ctime.t_nsec) & ( unsigned int)0xff000000UL) >> 24)));
 to->di_size = ((__u64)( (((__u64)(from->di_size) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->di_size) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->di_size) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->di_size) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->di_size) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->di_size) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->di_size) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->di_size) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->di_nblocks = ((__u64)( (((__u64)(from->di_nblocks) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(from->di_nblocks) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(from->di_nblocks) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(from->di_nblocks) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(from->di_nblocks) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(from->di_nblocks) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(from->di_nblocks) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(from->di_nblocks) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 to->di_extsize = ((__u32)( (((__u32)(from->di_extsize) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_extsize) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_extsize) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_extsize) & ( unsigned int)0xff000000UL) >> 24)));
 to->di_nextents = ((__u32)( (((__u32)(from->di_nextents) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_nextents) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_nextents) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_nextents) & ( unsigned int)0xff000000UL) >> 24)));
 to->di_anextents = ((__u16)( (((__u16)(from->di_anextents) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->di_anextents) & ( unsigned short)0xff00U) >> 8)));
 to->di_forkoff = from->di_forkoff;
 to->di_aformat = from->di_aformat;
 to->di_dmevmask = ((__u32)( (((__u32)(from->di_dmevmask) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_dmevmask) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_dmevmask) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_dmevmask) & ( unsigned int)0xff000000UL) >> 24)));
 to->di_dmstate = ((__u16)( (((__u16)(from->di_dmstate) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->di_dmstate) & ( unsigned short)0xff00U) >> 8)));
 to->di_flags = ((__u16)( (((__u16)(from->di_flags) & ( unsigned short)0x00ffU) << 8) | (((__u16)(from->di_flags) & ( unsigned short)0xff00U) >> 8)));
 to->di_gen = ((__u32)( (((__u32)(from->di_gen) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)(from->di_gen) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)(from->di_gen) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)(from->di_gen) & ( unsigned int)0xff000000UL) >> 24)));
}

variable_types: struct xfs_icdinode { unsigned short di_magic; unsigned short di_mode; char di_version; char di_format; unsigned short di_onlink; unsigned int di_uid; unsigned int di_gid; unsigned int di_nlink; unsigned short di_projid_lo; unsigned short di_projid_hi; unsigned char di_pad[6]; unsigned short di_flushiter; struct xfs_ictimestamp { int t_sec; int t_nsec; } di_atime; struct xfs_ictimestamp di_mtime; struct xfs_ictimestamp di_ctime; long long di_size; unsigned long long di_nblocks; unsigned int di_extsize; int di_nextents; short di_anextents; unsigned char di_forkoff; char di_aformat; unsigned int di_dmevmask; unsigned short di_dmstate; unsigned short di_flags; unsigned int di_gen; } *

variable_types: struct xfs_dinode { unsigned short di_magic; unsigned short di_mode; unsigned char di_version; unsigned char di_format; unsigned short di_onlink; unsigned int di_uid; unsigned int di_gid; unsigned int di_nlink; unsigned short di_projid_lo; unsigned short di_projid_hi; unsigned char di_pad[6]; unsigned short di_flushiter; struct xfs_timestamp { unsigned int t_sec; unsigned int t_nsec; } di_atime; struct xfs_timestamp di_mtime; struct xfs_timestamp di_ctime; unsigned long long di_size; unsigned long long di_nblocks; unsigned int di_extsize; unsigned int di_nextents; unsigned short di_anextents; unsigned char di_forkoff; char di_aformat; unsigned int di_dmevmask; unsigned short di_dmstate; unsigned short di_flags; unsigned int di_gen; unsigned int di_next_unlinked; } *

user_defined_types: struct xfs_icdinode { unsigned short di_magic; unsigned short di_mode; char di_version; char di_format; unsigned short di_onlink; unsigned int di_uid; unsigned int di_gid; unsigned int di_nlink; unsigned short di_projid_lo; unsigned short di_projid_hi; unsigned char di_pad[6]; unsigned short di_flushiter; struct xfs_ictimestamp di_atime; struct xfs_ictimestamp di_mtime; struct xfs_ictimestamp di_ctime; long long di_size; unsigned long long di_nblocks; unsigned int di_extsize; int di_nextents; short di_anextents; unsigned char di_forkoff; char di_aformat; unsigned int di_dmevmask; unsigned short di_dmstate; unsigned short di_flags; unsigned int di_gen; }

user_defined_types: struct xfs_dinode { unsigned short di_magic; unsigned short di_mode; unsigned char di_version; unsigned char di_format; unsigned short di_onlink; unsigned int di_uid; unsigned int di_gid; unsigned int di_nlink; unsigned short di_projid_lo; unsigned short di_projid_hi; unsigned char di_pad[6]; unsigned short di_flushiter; struct xfs_timestamp di_atime; struct xfs_timestamp di_mtime; struct xfs_timestamp di_ctime; unsigned long long di_size; unsigned long long di_nblocks; unsigned int di_extsize; unsigned int di_nextents; unsigned short di_anextents; unsigned char di_forkoff; char di_aformat; unsigned int di_dmevmask; unsigned short di_dmstate; unsigned short di_flags; unsigned int di_gen; unsigned int di_next_unlinked; }


decompiled_code:
__int64 init_read_file_from_disk()
{
rootino = sb[7];
return get_agi_root();
}

canonical_decompiled_code:
__int64 func5()
{
rootino = sb[7];
return get_agi_root();
}

original_code:
int init_read_file_from_disk()
{
 rootino = sb.sb_rootino;
 agi_root = get_agi_root();
}


decompiled_code:
unsigned __int64 __fastcall read_blocks(__int64 a1, __int64 a2, unsigned int a3, unsigned __int64 a4)
{
__int64 v5; // rdx
__int64 v6; // rsi
unsigned __int64 result; // rax

v5 = HIDWORD(sb[0]);
v6 = a2 * v5;
if ( a4 && a3 * (unsigned int)v5 > a4 )
{
read_file_length(a1, v6, (unsigned int)a4, 1LL);
result = a4;
}
else
{
read_file_length(a1, v6, v5, a3);
result = HIDWORD(sb[0]) * a3;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(__int64 a1, __int64 a2, unsigned int a3, unsigned __int64 a4)
{
__int64 v5; // rdx
__int64 v6; // rsi
unsigned __int64 result; // rax

v5 = HIDWORD(sb[0]);
v6 = a2 * v5;
if ( a4 && a3 * (unsigned int)v5 > a4 )
{
read_file_length(a1, v6, (unsigned int)a4, 1LL);
result = a4;
}
else
{
read_file_length(a1, v6, v5, a3);
result = HIDWORD(sb[0]) * a3;
}
return result;
}

original_code:
__TSLIB___uint64_t read_blocks( void *mem, xfs_daddr_t block, int nmeb, __TSLIB___uint64_t size)
{
 if ( size && size < sb.sb_blocksize * nmeb)
 {
  read_file_length( mem, block * sb.sb_blocksize, size, 1);
  return size;
 }
 else
 {
  read_file_length( mem, block * sb.sb_blocksize, sb.sb_blocksize, nmeb);
  return sb.sb_blocksize * nmeb;
 }
 return 0;
}

canonical_original_code:
unsigned long long read_blocks(void *mem, long long block, int nmeb, unsigned long long size)
{
 if ( size && size < sb.sb_blocksize * nmeb)
 {
  read_file_length( mem, block * sb.sb_blocksize, size, 1);
  return size;
 }
 else
 {
  read_file_length( mem, block * sb.sb_blocksize, sb.sb_blocksize, nmeb);
  return sb.sb_blocksize * nmeb;
 }
 return 0;
}

variable_types:
mem
void *

variable_types:
block
long long

variable_types: nmeb int

variable_types:
size
unsigned long long


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

read_blocks((__int64)&block_buf, a1, 1u, 0LL);
result = 0LL;
block_bufp = (__int64)&block_buf;
return result;
}

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

func6((__int64)&block_buf, a1, 1u, 0LL);
result = 0LL;
block_bufp = (__int64)&block_buf;
return result;
}

original_code:
int cache_block_from_disk( xfs_daddr_t block)
{
 read_blocks( ( void *)block_buf, block, 1, 0);
 block_bufp = block_buf;
 return 0;
}

canonical_original_code:
int cache_block_from_disk(long long block)
{
 read_blocks( ( void *)block_buf, block, 1, 0);
 block_bufp = block_buf;
 return 0;
}


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

v2 = block_bufp;
*a1 = block_bufp;
block_bufp = a2 + v2;
return 0LL;
}

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

v2 = block_bufp;
*a1 = block_bufp;
block_bufp = a2 + v2;
return 0LL;
}

original_code:
int init_mem( void **mem, int size)
{
 *mem = block_bufp;
 block_bufp += size;
 return 0;
}

canonical_original_code:
int init_mem(void **mem, int size)
{
 *mem = block_bufp;
 block_bufp += size;
 return 0;
}

variable_types:
mem
void **

variable_types: size int


decompiled_code:
__int64 __fastcall read_inode_relative(unsigned int a1, __int64 a2)
{
int v2; // er12
int v3; // eax
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = HIDWORD(sb[10]);
v3 = get_agi_seqno();
cache_block_from_disk((unsigned int)(v2 * v3) + (unsigned __int64)(a1 >> BYTE3(sb[15])));
init_mem(v5, LOWORD(sb[13]) * (a1 & ((1LL << BYTE3(sb[15])) - 1)));
init_mem(v5, LOWORD(sb[13]));
xfs_dinode_from_disk(a2, v5[0]);
return v5[0];
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1, __int64 a2)
{
int v2; // er12
int v3; // eax
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = HIDWORD(sb[10]);
v3 = get_agi_seqno();
func7((unsigned int)(v2 * v3) + (unsigned __int64)(a1 >> BYTE3(sb[15])));
func8(v5, LOWORD(sb[13]) * (a1 & ((1LL << BYTE3(sb[15])) - 1)));
func8(v5, LOWORD(sb[13]));
func4(a2, v5[0]);
return v5[0];
}

original_code:
xfs_dinode_t *read_inode_relative( xfs_agino_t inode, xfs_icdinode_t *mem)
{
 xfs_agblock_t blocks;
 xfs_daddr_t inoblock;
 xfs_dinode_t *temp;
 xfs_daddr_t offset;
 blocks = sb.sb_agblocks;
 blocks *= get_agi_seqno();
 inoblock = inode >> sb.sb_inopblog;
 inoblock += blocks;
 cache_block_from_disk( inoblock);
 offset = inode & (__uint32_t)((1ULL << (sb.sb_inopblog)) - 1);
 init_mem( ( void **) &temp, sb.sb_inodesize * offset);
 init_mem( ( void **) &temp, sb.sb_inodesize);
 xfs_dinode_from_disk( mem, temp);
 return temp;
}

canonical_original_code:
struct xfs_dinode *read_inode_relative(unsigned int inode, struct xfs_icdinode *mem)
{
 unsigned int blocks;
 long long inoblock;
 struct xfs_dinode *temp;
 long long offset;
 blocks = sb.sb_agblocks;
 blocks *= get_agi_seqno();
 inoblock = inode >> sb.sb_inopblog;
 inoblock += blocks;
 cache_block_from_disk( inoblock);
 offset = inode & (__uint32_t)((1ULL << (sb.sb_inopblog)) - 1);
 init_mem( ( void **) &temp, sb.sb_inodesize * offset);
 init_mem( ( void **) &temp, sb.sb_inodesize);
 xfs_dinode_from_disk( mem, temp);
 return temp;
}

variable_types:
inode
unsigned int

variable_types:
blocks
unsigned int

variable_types:
inoblock
long long

variable_types:
offset
long long

return_type: struct xfs_dinode { unsigned short di_magic; unsigned short di_mode; unsigned char di_version; unsigned char di_format; unsigned short di_onlink; unsigned int di_uid; unsigned int di_gid; unsigned int di_nlink; unsigned short di_projid_lo; unsigned short di_projid_hi; unsigned char di_pad[6]; unsigned short di_flushiter; struct xfs_timestamp { unsigned int t_sec; unsigned int t_nsec; } di_atime; struct xfs_timestamp di_mtime; struct xfs_timestamp di_ctime; unsigned long long di_size; unsigned long long di_nblocks; unsigned int di_extsize; unsigned int di_nextents; unsigned short di_anextents; unsigned char di_forkoff; char di_aformat; unsigned int di_dmevmask; unsigned short di_dmstate; unsigned short di_flags; unsigned int di_gen; unsigned int di_next_unlinked; } *

user_defined_types: struct xfs_ictimestamp { int t_sec; int t_nsec; }


decompiled_code:
__int64 __fastcall read_file_from_disk(const char *a1, __int64 a2, unsigned __int64 a3)
{
char v3; // al
const char *v4; // r14
__int64 v5; // r12
int v6; // ebx
int v7; // er15
int v8; // ebx
char *v9; // rbp
unsigned __int8 *v10; // r15
char v11; // al
int v12; // er13
unsigned __int8 *v13; // rbp
__int64 v14; // rax
unsigned __int64 *v15; // rbx
unsigned __int32 v16; // edx
unsigned __int64 v17; // rbp
__int64 v18; // r12
unsigned __int64 v19; // rax
__int64 result; // rax
const char *v21; // rax
const char *v22; // [rsp+8h] [rbp-100h]
__int64 v23; // [rsp+10h] [rbp-F8h]
char *v24; // [rsp+18h] [rbp-F0h]
__int64 v25; // [rsp+20h] [rbp-E8h]
__int64 v27[2]; // [rsp+40h] [rbp-C8h] BYREF
__int64 v28; // [rsp+50h] [rbp-B8h] BYREF
__int64 v29; // [rsp+58h] [rbp-B0h]
__int64 v30; // [rsp+60h] [rbp-A8h]
unsigned __int16 v31; // [rsp+70h] [rbp-98h] BYREF
unsigned __int16 v32; // [rsp+72h] [rbp-96h]
char v33; // [rsp+74h] [rbp-94h]
char v34; // [rsp+75h] [rbp-93h]

v22 = a1;
eprint("read_file_from_disk: %s\n", a1);
v25 = rootino;
v3 = *a1;
if ( *a1 )
{
while ( 1 )
{
if ( v3 != 47 )
goto LABEL_31;
v4 = v22 + 1;
v5 = read_inode_relative(v25, (__int64)&v31);
if ( !v5 )
goto LABEL_32;
eprint("%x %x %x\n", v31, v32, (unsigned int)v33);
if ( (v32 & 0xF000) != 0x4000 || v34 != 1 )
goto LABEL_31;
v6 = *(unsigned __int8 *)(v5 + 100);
v7 = *(unsigned __int8 *)(v5 + 101);
v23 = v5 + 100;
eprint("Get count is %d %d\n", *(unsigned __int8 *)(v5 + 100), *(unsigned __int8 *)(v5 + 101));
if ( ((_BYTE)v6 == 0) == ((_BYTE)v7 == 0) )
return 4294967294LL;
v8 = v7 + v6;
v9 = (char *)(v22 + 1);
v10 = (unsigned __int8 *)xfs_dir2_sf_firstentry(v23);
eprint("get entry len %d, offset %d\n", *v10, v10[2]);
v3 = v22[1];
if ( !v3 || v3 == 47 )
break;
do
v11 = *++v9;
while ( v11 && v11 != 47 );
v12 = (_DWORD)v9 - (_DWORD)v4;
if ( v8 )
goto LABEL_12;
LABEL_27:
if ( v9 != v4 )
return 4294967292LL;
v21 = v22;
v22 = v9;
v3 = v21[1];
LABEL_17:
if ( !v3 )
goto LABEL_18;
}
v12 = 0;
if ( !v8 )
{
++v22;
goto LABEL_17;
}
LABEL_12:
v24 = v9;
v13 = v10;
do
{
if ( *v13 == v12 && !(unsigned int)str_ncmp(v13 + 3, v4, v12) )
{
v22 = v24;
v25 = xfs_dir2_sfe_get_ino(v23, v13);
v3 = *v24;
goto LABEL_17;
}
v13 = (unsigned __int8 *)xfs_dir2_sf_nextentry_isra_0(*(_BYTE *)(v5 + 101), v13);
--v8;
}
while ( v8 );
v9 = v24;
goto LABEL_27;
}
LABEL_18:
eprint("Get first file block %lld\n", v25);
v14 = read_inode_relative(v25, (__int64)&v31);
if ( v14 )
{
if ( (v32 & 1) != 0 || v34 != 2 )
{
LABEL_31:
result = 4294967293LL;
}
else
{
v15 = (unsigned __int64 *)(v14 + 100);
v16 = _byteswap_ulong(*(_DWORD *)(v14 + 76));
v17 = _byteswap_uint64(*(_QWORD *)(v14 + 56));
if ( v17 > a3 )
{
result = 4294967291LL;
}
else
{
if ( v16 )
{
v18 = v14 + 16LL * (v16 - 1) + 116;
do
{
v19 = *v15;
v15 += 2;
v27[0] = _byteswap_uint64(v19);
v27[1] = _byteswap_uint64(*(v15 - 1));
xfs_bmbt_get_all(v27, &v28);
eprint("%u %u %u\n", v28, v29, v30);
v17 -= read_blocks(a2 + v28, v29, v30, v17);
}
while ( (unsigned __int64 *)v18 != v15 );
}
result = 0LL;
}
}
}
else
{
LABEL_32:
eprint("read ino error %lld\n", v25);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int read_file_from_disk( const char *file_name, void *mem, __TSLIB___uint64_t size)
{
 eprint("read_file_from_disk: %s\n", file_name);
 xfs_icdinode_t cur;
 xfs_dinode_t *raw;
 xfs_ino_t next_ino = rootino;
 xfs_dir2_sf_hdr_t *hdrptr;
 __TSLIB___uint8_t count;
 __TSLIB___uint8_t i8count;
 int tot;
 const char *tail;
 int name_len;
 xfs_bmbt_rec_t *rec;
 xfs_bmbt_rec_host_t host;
 xfs_bmbt_irec_t irec;
 while ( *file_name)
 {
  if ( *file_name != '/')
  {
   return -3;
  }
  ++file_name;
  if ( ( raw = read_inode_relative( next_ino, &cur)) != (( void *)0))
  {
   eprint("%x %x %x\n", (int)cur.di_magic, (int)cur.di_mode, (int)cur.di_version);
   if ( ( cur.di_mode & 00170000) == 0040000)
   {
    if ( cur.di_format != XFS_DINODE_FMT_LOCAL)
    {
     return -3;
    }
    else
    {
     hdrptr = ( xfs_dir2_sf_hdr_t *)((char *)(raw) + sizeof(struct xfs_dinode));
     count = hdrptr->count;
     i8count = hdrptr->i8count;
     eprint("Get count is %d %d\n", (int)count, (int)i8count);
     if ( ( !count) ^ ( !i8count))
     {
      tot = count + i8count;
      xfs_dir2_sf_entry_t *entptr = xfs_dir2_sf_firstentry( hdrptr);
      eprint("get entry len %d, offset %d\n", (int)( entptr->namelen), (int)( entptr->offset.i[1]));
      tail = file_name;
      while ( *tail && *tail != '/')
      {
       ++tail;
      }
      name_len = tail - file_name;
      while( tot--)
      {
       if ( name_len == entptr->namelen && str_ncmp( entptr->name, file_name, name_len) == 0)
       {
        file_name = tail;
        next_ino = xfs_dir2_sfe_get_ino( hdrptr, entptr);
        break;
       }
       entptr = xfs_dir2_sf_nextentry( hdrptr, entptr);
      }
      if ( file_name != tail)
      {
       return -4;
      }
     }
     else
     {
      return -2;
     }
    }
   }
   else
   {
    return -3;
   }
  }
  else
  {
   eprint("read ino error %lld\n", (long long)next_ino);
   return -1;
  }
 }
 eprint("Get first file block %lld\n", (long long)next_ino);
 if ( ( raw = read_inode_relative( next_ino, &cur)) != (( void *)0))
 {
  if ( cur.di_mode & 00170000 != 0100000)
  {
   return -3;
  }
  else
  {
   if ( cur.di_format != XFS_DINODE_FMT_EXTENTS)
   {
    return -3;
   }
   else
   {
    rec = ( xfs_bmbt_rec_t *)((char *)(raw) + sizeof(struct xfs_dinode));
    tot = ((0) == 0 ? ((__u32)( (((__u32)((raw)->di_nextents) & ( __u32)0x000000ffUL) << 24) | (((__u32)((raw)->di_nextents) & ( __u32)0x0000ff00UL) << 8) | (((__u32)((raw)->di_nextents) & ( __u32)0x00ff0000UL) >> 8) | (((__u32)((raw)->di_nextents) & ( __u32)0xff000000UL) >> 24))) : ((__u16)( (((__u16)((raw)->di_anextents) & ( __u16)0x00ffU) << 8) | (((__u16)((raw)->di_anextents) & ( __u16)0xff00U) >> 8))));
    if ( size < ((__u64)( (((__u64)(raw->di_size) & ( __u64)0x00000000000000ffUL) << 56) | (((__u64)(raw->di_size) & ( __u64)0x000000000000ff00UL) << 40) | (((__u64)(raw->di_size) & ( __u64)0x0000000000ff0000UL) << 24) | (((__u64)(raw->di_size) & ( __u64)0x00000000ff000000UL) << 8) | (((__u64)(raw->di_size) & ( __u64)0x000000ff00000000UL) >> 8) | (((__u64)(raw->di_size) & ( __u64)0x0000ff0000000000UL) >> 24) | (((__u64)(raw->di_size) & ( __u64)0x00ff000000000000UL) >> 40) | (((__u64)(raw->di_size) & ( __u64)0xff00000000000000UL) >> 56))))
    {
     return -5;
    }
    else
    {
     size = ((__u64)( (((__u64)(raw->di_size) & ( __u64)0x00000000000000ffUL) << 56) | (((__u64)(raw->di_size) & ( __u64)0x000000000000ff00UL) << 40) | (((__u64)(raw->di_size) & ( __u64)0x0000000000ff0000UL) << 24) | (((__u64)(raw->di_size) & ( __u64)0x00000000ff000000UL) << 8) | (((__u64)(raw->di_size) & ( __u64)0x000000ff00000000UL) >> 8) | (((__u64)(raw->di_size) & ( __u64)0x0000ff0000000000UL) >> 24) | (((__u64)(raw->di_size) & ( __u64)0x00ff000000000000UL) >> 40) | (((__u64)(raw->di_size) & ( __u64)0xff00000000000000UL) >> 56)));
    }
    while ( tot--)
    {
     host.l0 = ((__u64)( (((__u64)(rec->l0) & ( __u64)0x00000000000000ffUL) << 56) | (((__u64)(rec->l0) & ( __u64)0x000000000000ff00UL) << 40) | (((__u64)(rec->l0) & ( __u64)0x0000000000ff0000UL) << 24) | (((__u64)(rec->l0) & ( __u64)0x00000000ff000000UL) << 8) | (((__u64)(rec->l0) & ( __u64)0x000000ff00000000UL) >> 8) | (((__u64)(rec->l0) & ( __u64)0x0000ff0000000000UL) >> 24) | (((__u64)(rec->l0) & ( __u64)0x00ff000000000000UL) >> 40) | (((__u64)(rec->l0) & ( __u64)0xff00000000000000UL) >> 56)));
     host.l1 = ((__u64)( (((__u64)(rec->l1) & ( __u64)0x00000000000000ffUL) << 56) | (((__u64)(rec->l1) & ( __u64)0x000000000000ff00UL) << 40) | (((__u64)(rec->l1) & ( __u64)0x0000000000ff0000UL) << 24) | (((__u64)(rec->l1) & ( __u64)0x00000000ff000000UL) << 8) | (((__u64)(rec->l1) & ( __u64)0x000000ff00000000UL) >> 8) | (((__u64)(rec->l1) & ( __u64)0x0000ff0000000000UL) >> 24) | (((__u64)(rec->l1) & ( __u64)0x00ff000000000000UL) >> 40) | (((__u64)(rec->l1) & ( __u64)0xff00000000000000UL) >> 56)));
     xfs_bmbt_get_all( &host, &irec);
     eprint("%u %u %u\n", irec.br_startoff, irec.br_startblock, irec.br_blockcount);
     size -= read_blocks( mem + irec.br_startoff, irec.br_startblock, irec.br_blockcount, size);
     rec++;
    }
   }
  }
 }
 else
 {
  eprint("read ino error %lld\n", (long long)next_ino);
  return -1;
 }
 return 0;
}

canonical_original_code:
int read_file_from_disk(char *file_name, void *mem, unsigned long long size)
{
 eprint("read_file_from_disk: %s\n", file_name);
 struct xfs_icdinode cur;
 struct xfs_dinode *raw;
 unsigned long long next_ino = rootino;
 struct xfs_dir2_sf_hdr *hdrptr;
 unsigned char count;
 unsigned char i8count;
 int tot;
 char *tail;
 int name_len;
 struct xfs_bmbt_rec *rec;
 struct xfs_bmbt_rec_host host;
 struct xfs_bmbt_irec irec;
 while ( *file_name)
 {
  if ( *file_name != '/')
  {
   return -3;
  }
  ++file_name;
  if ( ( raw = read_inode_relative( next_ino, &cur)) != (( void *)0))
  {
   eprint("%x %x %x\n", (int)cur.di_magic, (int)cur.di_mode, (int)cur.di_version);
   if ( ( cur.di_mode & 00170000) == 0040000)
   {
    if ( cur.di_format != XFS_DINODE_FMT_LOCAL)
    {
     return -3;
    }
    else
    {
     hdrptr = ( struct xfs_dir2_sf_hdr *)((char *)(raw) + sizeof(struct xfs_dinode));
     count = hdrptr->count;
     i8count = hdrptr->i8count;
     eprint("Get count is %d %d\n", (int)count, (int)i8count);
     if ( ( !count) ^ ( !i8count))
     {
      tot = count + i8count;
      struct xfs_dir2_sf_entry *entptr = xfs_dir2_sf_firstentry( hdrptr);
      eprint("get entry len %d, offset %d\n", (int)( entptr->namelen), (int)( entptr->offset.i[1]));
      tail = file_name;
      while ( *tail && *tail != '/')
      {
       ++tail;
      }
      name_len = tail - file_name;
      while( tot--)
      {
       if ( name_len == entptr->namelen && str_ncmp( entptr->name, file_name, name_len) == 0)
       {
        file_name = tail;
        next_ino = xfs_dir2_sfe_get_ino( hdrptr, entptr);
        break;
       }
       entptr = xfs_dir2_sf_nextentry( hdrptr, entptr);
      }
      if ( file_name != tail)
      {
       return -4;
      }
     }
     else
     {
      return -2;
     }
    }
   }
   else
   {
    return -3;
   }
  }
  else
  {
   eprint("read ino error %lld\n", (long long)next_ino);
   return -1;
  }
 }
 eprint("Get first file block %lld\n", (long long)next_ino);
 if ( ( raw = read_inode_relative( next_ino, &cur)) != (( void *)0))
 {
  if ( cur.di_mode & 00170000 != 0100000)
  {
   return -3;
  }
  else
  {
   if ( cur.di_format != XFS_DINODE_FMT_EXTENTS)
   {
    return -3;
   }
   else
   {
    rec = ( struct xfs_bmbt_rec *)((char *)(raw) + sizeof(struct xfs_dinode));
    tot = ((0) == 0 ? ((__u32)( (((__u32)((raw)->di_nextents) & ( unsigned int)0x000000ffUL) << 24) | (((__u32)((raw)->di_nextents) & ( unsigned int)0x0000ff00UL) << 8) | (((__u32)((raw)->di_nextents) & ( unsigned int)0x00ff0000UL) >> 8) | (((__u32)((raw)->di_nextents) & ( unsigned int)0xff000000UL) >> 24))) : ((__u16)( (((__u16)((raw)->di_anextents) & ( unsigned short)0x00ffU) << 8) | (((__u16)((raw)->di_anextents) & ( unsigned short)0xff00U) >> 8))));
    if ( size < ((__u64)( (((__u64)(raw->di_size) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(raw->di_size) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(raw->di_size) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(raw->di_size) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(raw->di_size) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(raw->di_size) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(raw->di_size) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(raw->di_size) & ( unsigned long long)0xff00000000000000UL) >> 56))))
    {
     return -5;
    }
    else
    {
     size = ((__u64)( (((__u64)(raw->di_size) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(raw->di_size) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(raw->di_size) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(raw->di_size) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(raw->di_size) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(raw->di_size) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(raw->di_size) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(raw->di_size) & ( unsigned long long)0xff00000000000000UL) >> 56)));
    }
    while ( tot--)
    {
     host.l0 = ((__u64)( (((__u64)(rec->l0) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(rec->l0) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(rec->l0) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(rec->l0) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(rec->l0) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(rec->l0) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(rec->l0) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(rec->l0) & ( unsigned long long)0xff00000000000000UL) >> 56)));
     host.l1 = ((__u64)( (((__u64)(rec->l1) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(rec->l1) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(rec->l1) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(rec->l1) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(rec->l1) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(rec->l1) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(rec->l1) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(rec->l1) & ( unsigned long long)0xff00000000000000UL) >> 56)));
     xfs_bmbt_get_all( &host, &irec);
     eprint("%u %u %u\n", irec.br_startoff, irec.br_startblock, irec.br_blockcount);
     size -= read_blocks( mem + irec.br_startoff, irec.br_startblock, irec.br_blockcount, size);
     rec++;
    }
   }
  }
 }
 else
 {
  eprint("read ino error %lld\n", (long long)next_ino);
  return -1;
 }
 return 0;
}

variable_types: struct xfs_icdinode { unsigned short di_magic; unsigned short di_mode; char di_version; char di_format; unsigned short di_onlink; unsigned int di_uid; unsigned int di_gid; unsigned int di_nlink; unsigned short di_projid_lo; unsigned short di_projid_hi; unsigned char di_pad[6]; unsigned short di_flushiter; struct xfs_ictimestamp { int t_sec; int t_nsec; } di_atime; struct xfs_ictimestamp di_mtime; struct xfs_ictimestamp di_ctime; long long di_size; unsigned long long di_nblocks; unsigned int di_extsize; int di_nextents; short di_anextents; unsigned char di_forkoff; char di_aformat; unsigned int di_dmevmask; unsigned short di_dmstate; unsigned short di_flags; unsigned int di_gen; }

variable_types:
count
unsigned char

variable_types: tot int

variable_types:
tail
char *

variable_types: struct xfs_bmbt_rec { unsigned long long l0; } *

variable_types: struct xfs_bmbt_rec_host { unsigned long long l0; }

variable_types: struct xfs_bmbt_irec { unsigned long long br_startoff; unsigned long long br_startblock; unsigned long long br_blockcount; enum xfs_exntst_t { XFS_EXT_NORM=0, XFS_EXT_UNWRITTEN=1, XFS_EXT_DMAPI_OFFLINE=2, XFS_EXT_INVALID=3 } br_state; }

user_defined_types: struct xfs_bmbt_irec { unsigned long long br_startoff; unsigned long long br_startblock; unsigned long long br_blockcount; enum xfs_exntst_t br_state; }

user_defined_types: struct xfs_timestamp { unsigned int t_sec; unsigned int t_nsec; }


main

canonical_name: main

repo: lpereira/compilador-tosco

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax

argv0 = (__int64)strdup(*argv);
if ( argc <= 1 )
result = ((__int64 (__fastcall *)(_QWORD, const char **))gui_main)((unsigned int)argc, argv);
else
result = compiler_main((unsigned int)argc);
return result;
}

original_code:
int main(int argc, char **argv)
{
  argv0 = strdup(argv[0]);
  if (argc < 2) {
    return gui_main(argc, argv);
  } else {
    return compiler_main(argc, argv);
  }
  return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
void vm_null()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
static void vm_null(VM *vm, VMInstruction *i)
{
  ;
}

canonical_original_code:
static void vm_null(struct _VM *vm, struct _VMInstruction *i)
{
  ;
}

variable_types: struct _VM { int stack_top; int memory[65536]; struct _GList { void *data; struct _GList *next; struct _GList *prev; } *program; int running; char *(*read_function)(void *data); void (*write_function)(void *data, char *string); void *write_function_data; } *

variable_types: struct _VMInstruction { enum VMOpcode { OP_LABEL=0, OP_LDC=1, OP_LDV=2, OP_ADD=3, OP_SUB=4, OP_MULT=5, OP_DIVI=6, OP_INV=7, OP_AND=8, OP_OR=9, OP_NEG=10, OP_CME=11, OP_CMA=12, OP_CEQ=13, OP_CDIF=14, OP_CMEQ=15, OP_CMAQ=16, OP_JMP=17, OP_JMPF=18, OP_ALLOC=19, OP_DALLOC=20, OP_START=21, OP_HLT=22, OP_CALL=23, OP_RETURN=24, OP_RETURNF=25, OP_RD=26, OP_PRN=27, OP_STR=28, N_OP=29 } opcode; unsigned int param1; char *sparam1; char *label_name; void *data; } *

user_defined_types: struct _VM { int stack_top; int memory[65536]; struct _GList *program; int running; char *(*read_function)(void *data); void (*write_function)(void *data, char *string); void *write_function_data; }

user_defined_types: struct _VMInstruction { enum VMOpcode opcode; unsigned int param1; char *sparam1; char *label_name; void *data; }


decompiled_code:
__int64 __fastcall vm_ldc(_DWORD *a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax

v2 = *(_DWORD *)(a2 + 4);
LODWORD(result) = *a1 + 1;
*a1 = result;
result = (int)result;
a1[(int)result + 1] = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax

v2 = *(_DWORD *)(a2 + 4);
LODWORD(result) = *a1 + 1;
*a1 = result;
result = (int)result;
a1[(int)result + 1] = v2;
return result;
}

original_code:
static void vm_ldc(VM *vm, VMInstruction *i)
{
  vm->memory[++vm->stack_top] = i->param1;
}

canonical_original_code:
static void vm_ldc(struct _VM *vm, struct _VMInstruction *i)
{
  vm->memory[++vm->stack_top] = i->param1;
}

user_defined_types: enum VMOpcode { OP_LABEL=0, OP_LDC=1, OP_LDV=2, OP_ADD=3, OP_SUB=4, OP_MULT=5, OP_DIVI=6, OP_INV=7, OP_AND=8, OP_OR=9, OP_NEG=10, OP_CME=11, OP_CMA=12, OP_CEQ=13, OP_CDIF=14, OP_CMEQ=15, OP_CMAQ=16, OP_JMP=17, OP_JMPF=18, OP_ALLOC=19, OP_DALLOC=20, OP_START=21, OP_HLT=22, OP_CALL=23, OP_RETURN=24, OP_RETURNF=25, OP_RD=26, OP_PRN=27, OP_STR=28, N_OP=29 }

user_defined_types: struct _GList { void *data; struct _GList *next; struct _GList *prev; }


decompiled_code:
__int64 __fastcall vm_ldv(_DWORD *a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax

v2 = a1[*(unsigned int *)(a2 + 4) + 1];
LODWORD(result) = *a1 + 1;
*a1 = result;
result = (int)result;
a1[(int)result + 1] = v2;
return result;
}

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

v2 = a1[*(unsigned int *)(a2 + 4) + 1];
LODWORD(result) = *a1 + 1;
*a1 = result;
result = (int)result;
a1[(int)result + 1] = v2;
return result;
}

original_code:
static void vm_ldv(VM *vm, VMInstruction *i)
{
  vm->memory[++vm->stack_top] = vm->memory[i->param1];
}

canonical_original_code:
static void vm_ldv(struct _VM *vm, struct _VMInstruction *i)
{
  vm->memory[++vm->stack_top] = vm->memory[i->param1];
}


decompiled_code:
__int64 __fastcall vm_add(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] += a1[*a1 + 1];
*a1 = result;
return result;
}

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

result = (unsigned int)(*a1 - 1);
a1[*a1] += a1[*a1 + 1];
*a1 = result;
return result;
}

original_code:
static void vm_add(VM *vm, VMInstruction *i)
{
  vm->memory[vm->stack_top - 1] = vm->memory[vm->stack_top - 1] +
                                  vm->memory[vm->stack_top];
  vm->stack_top--;
}

canonical_original_code:
static void vm_add(struct _VM *vm, struct _VMInstruction *i)
{
  vm->memory[vm->stack_top - 1] = vm->memory[vm->stack_top - 1] +
                                  vm->memory[vm->stack_top];
  vm->stack_top--;
}


decompiled_code:
__int64 __fastcall vm_sub(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] -= a1[*a1 + 1];
*a1 = result;
return result;
}

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

result = (unsigned int)(*a1 - 1);
a1[*a1] -= a1[*a1 + 1];
*a1 = result;
return result;
}

original_code:
static void vm_sub(VM *vm, VMInstruction *i)
{
  vm->memory[vm->stack_top - 1] = vm->memory[vm->stack_top - 1] -
                                  vm->memory[vm->stack_top];
  vm->stack_top--;
}

canonical_original_code:
static void vm_sub(struct _VM *vm, struct _VMInstruction *i)
{
  vm->memory[vm->stack_top - 1] = vm->memory[vm->stack_top - 1] -
                                  vm->memory[vm->stack_top];
  vm->stack_top--;
}


decompiled_code:
__int64 __fastcall vm_mult(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] *= a1[*a1 + 1];
*a1 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] *= a1[*a1 + 1];
*a1 = result;
return result;
}

original_code:
static void vm_mult(VM *vm, VMInstruction *i)
{
  vm->memory[vm->stack_top - 1] = vm->memory[vm->stack_top - 1] *
                                  vm->memory[vm->stack_top];
  vm->stack_top--;
}

canonical_original_code:
static void vm_mult(struct _VM *vm, struct _VMInstruction *i)
{
  vm->memory[vm->stack_top - 1] = vm->memory[vm->stack_top - 1] *
                                  vm->memory[vm->stack_top];
  vm->stack_top--;
}


original_code:
static void vm_divi(VM *vm, VMInstruction *i)
{
  if (vm->memory[vm->stack_top] != 0) {
    vm->memory[vm->stack_top - 1] = vm->memory[vm->stack_top - 1] /
                                    vm->memory[vm->stack_top];
    vm->stack_top--;
  } else {
    vm->write_function(vm->write_function_data, "Divisão por zero\n");
    vm->running = (0);
    vm->instruction_pointer = ((void *)0);
  }
}

canonical_original_code:
static void vm_divi(struct _VM *vm, struct _VMInstruction *i)
{
  if (vm->memory[vm->stack_top] != 0) {
    vm->memory[vm->stack_top - 1] = vm->memory[vm->stack_top - 1] /
                                    vm->memory[vm->stack_top];
    vm->stack_top--;
  } else {
    vm->write_function(vm->write_function_data, "Divisão por zero\n");
    vm->running = (0);
    vm->instruction_pointer = ((void *)0);
  }
}


decompiled_code:
__int64 __fastcall vm_inv(int *a1)
{
__int64 result; // rax

result = *a1;
a1[result + 1] = -a1[result + 1];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int *a1)
{
__int64 result; // rax

result = *a1;
a1[result + 1] = -a1[result + 1];
return result;
}

original_code:
static void vm_inv(VM *vm, VMInstruction *i)
{
  vm->memory[vm->stack_top] = - vm->memory[vm->stack_top];
}

canonical_original_code:
static void vm_inv(struct _VM *vm, struct _VMInstruction *i)
{
  vm->memory[vm->stack_top] = - vm->memory[vm->stack_top];
}


decompiled_code:
__int64 __fastcall vm_and(int *a1)
{
__int64 result; // rax
_BOOL4 v2; // esi
int v3; // edx

result = *a1;
v2 = 0;
v3 = result - 1;
if ( a1[(int)result] == 1 )
v2 = a1[result + 1] == 1;
a1[v3 + 1] = v2;
*a1 = v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int *a1)
{
__int64 result; // rax
_BOOL4 v2; // esi
int v3; // edx

result = *a1;
v2 = 0;
v3 = result - 1;
if ( a1[(int)result] == 1 )
v2 = a1[result + 1] == 1;
a1[v3 + 1] = v2;
*a1 = v3;
return result;
}

original_code:
static void vm_and(VM *vm, VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] == 1 &&
      vm->memory[vm->stack_top] == 1) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}

canonical_original_code:
static void vm_and(struct _VM *vm, struct _VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] == 1 &&
      vm->memory[vm->stack_top] == 1) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}


decompiled_code:
__int64 __fastcall vm_or(int *a1)
{
__int64 result; // rax
int v2; // ecx
int v3; // edx

result = *a1;
v2 = result - 1;
v3 = a1[(int)result];
if ( v3 != 1 )
v3 = a1[result + 1] == 1;
a1[v2 + 1] = v3;
*a1 = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int *a1)
{
__int64 result; // rax
int v2; // ecx
int v3; // edx

result = *a1;
v2 = result - 1;
v3 = a1[(int)result];
if ( v3 != 1 )
v3 = a1[result + 1] == 1;
a1[v2 + 1] = v3;
*a1 = v2;
return result;
}

original_code:
static void vm_or(VM *vm, VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] == 1 ||
      vm->memory[vm->stack_top] == 1) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}

canonical_original_code:
static void vm_or(struct _VM *vm, struct _VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] == 1 ||
      vm->memory[vm->stack_top] == 1) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}


decompiled_code:
__int64 __fastcall vm_neg(int *a1)
{
__int64 v1; // rdx
__int64 result; // rax

v1 = *a1;
result = (unsigned int)(1 - a1[v1 + 1]);
a1[v1 + 1] = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int *a1)
{
__int64 v1; // rdx
__int64 result; // rax

v1 = *a1;
result = (unsigned int)(1 - a1[v1 + 1]);
a1[v1 + 1] = result;
return result;
}

original_code:
static void vm_neg(VM *vm, VMInstruction *i)
{
  vm->memory[vm->stack_top] = 1 - vm->memory[vm->stack_top];
}

canonical_original_code:
static void vm_neg(struct _VM *vm, struct _VMInstruction *i)
{
  vm->memory[vm->stack_top] = 1 - vm->memory[vm->stack_top];
}


decompiled_code:
__int64 __fastcall vm_cme(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] = a1[*a1] < a1[*a1 + 1];
*a1 = result;
return result;
}

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

result = (unsigned int)(*a1 - 1);
a1[*a1] = a1[*a1] < a1[*a1 + 1];
*a1 = result;
return result;
}

original_code:
static void vm_cme(VM *vm, VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] < vm->memory[vm->stack_top]) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}

canonical_original_code:
static void vm_cme(struct _VM *vm, struct _VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] < vm->memory[vm->stack_top]) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}


decompiled_code:
__int64 __fastcall vm_cma(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] = a1[*a1] > a1[*a1 + 1];
*a1 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] = a1[*a1] > a1[*a1 + 1];
*a1 = result;
return result;
}

original_code:
static void vm_cma(VM *vm, VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] > vm->memory[vm->stack_top]) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}

canonical_original_code:
static void vm_cma(struct _VM *vm, struct _VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] > vm->memory[vm->stack_top]) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}


decompiled_code:
__int64 __fastcall vm_ceq(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] = a1[*a1] == a1[*a1 + 1];
*a1 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] = a1[*a1] == a1[*a1 + 1];
*a1 = result;
return result;
}

original_code:
static void vm_ceq(VM *vm, VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] == vm->memory[vm->stack_top]) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}

canonical_original_code:
static void vm_ceq(struct _VM *vm, struct _VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] == vm->memory[vm->stack_top]) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}


decompiled_code:
__int64 __fastcall vm_cdif(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] = a1[*a1] != a1[*a1 + 1];
*a1 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] = a1[*a1] != a1[*a1 + 1];
*a1 = result;
return result;
}

original_code:
static void vm_cdif(VM *vm, VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] != vm->memory[vm->stack_top]) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}

canonical_original_code:
static void vm_cdif(struct _VM *vm, struct _VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] != vm->memory[vm->stack_top]) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}


decompiled_code:
__int64 __fastcall vm_cmeq(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] = a1[*a1] <= a1[*a1 + 1];
*a1 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] = a1[*a1] <= a1[*a1 + 1];
*a1 = result;
return result;
}

original_code:
static void vm_cmeq(VM *vm, VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] <= vm->memory[vm->stack_top]) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}

canonical_original_code:
static void vm_cmeq(struct _VM *vm, struct _VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] <= vm->memory[vm->stack_top]) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}


decompiled_code:
__int64 __fastcall vm_cmaq(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] = a1[*a1] >= a1[*a1 + 1];
*a1 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(int *a1)
{
__int64 result; // rax

result = (unsigned int)(*a1 - 1);
a1[*a1] = a1[*a1] >= a1[*a1 + 1];
*a1 = result;
return result;
}

original_code:
static void vm_cmaq(VM *vm, VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] >= vm->memory[vm->stack_top]) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}

canonical_original_code:
static void vm_cmaq(struct _VM *vm, struct _VMInstruction *i)
{
  if (vm->memory[vm->stack_top - 1] >= vm->memory[vm->stack_top]) {
    vm->memory[vm->stack_top - 1] = 1;
  } else {
    vm->memory[vm->stack_top - 1] = 0;
  }
  vm->stack_top--;
}


decompiled_code:
__int64 __fastcall vm_alloc(int *a1, __int64 a2)
{
int v2; // er9
__int64 result; // rax
__int64 v4; // r8
int *v5; // rdx
int v6; // esi
__int64 v7; // rcx

v2 = *(_DWORD *)(a2 + 8);
LODWORD(result) = *(_DWORD *)(a2 + 4);
v4 = *a1;
v5 = &a1[v4];
v6 = result + v2;
do
{
v7 = (unsigned int)result;
result = (unsigned int)(result + 1);
++v5;
v5[1] = a1[v7 + 1];
}
while ( (_DWORD)result != v6 );
*a1 = v2 + v4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(int *a1, __int64 a2)
{
int v2; // er9
__int64 result; // rax
__int64 v4; // r8
int *v5; // rdx
int v6; // esi
__int64 v7; // rcx

v2 = *(_DWORD *)(a2 + 8);
LODWORD(result) = *(_DWORD *)(a2 + 4);
v4 = *a1;
v5 = &a1[v4];
v6 = result + v2;
do
{
v7 = (unsigned int)result;
result = (unsigned int)(result + 1);
++v5;
v5[1] = a1[v7 + 1];
}
while ( (_DWORD)result != v6 );
*a1 = v2 + v4;
return result;
}

original_code:
static void vm_alloc(VM *vm, VMInstruction *i)
{
  int k;
  for (k = 0; k <= i->param2 - 1; k++) {
    vm->stack_top++;
    vm->memory[vm->stack_top] = vm->memory[i->param1 + k];
  }
}

canonical_original_code:
static void vm_alloc(struct _VM *vm, struct _VMInstruction *i)
{
  int k;
  for (k = 0; k <= i->param2 - 1; k++) {
    vm->stack_top++;
    vm->memory[vm->stack_top] = vm->memory[i->param1 + k];
  }
}

variable_types: k int


original_code:
static void vm_dalloc(VM *vm, VMInstruction *i)
{
  int k;
  for (k = i->param2 - 1; k >= 0; k--) {
    vm->memory[i->param1 + k] = vm->memory[vm->stack_top];
    vm->stack_top--;
  }
}

canonical_original_code:
static void vm_dalloc(struct _VM *vm, struct _VMInstruction *i)
{
  int k;
  for (k = i->param2 - 1; k >= 0; k--) {
    vm->memory[i->param1 + k] = vm->memory[vm->stack_top];
    vm->stack_top--;
  }
}


original_code:
static void vm_hlt(VM *vm, VMInstruction *i)
{
  vm->running = (0);
}

canonical_original_code:
static void vm_hlt(struct _VM *vm, struct _VMInstruction *i)
{
  vm->running = (0);
}


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

result = (unsigned int)(*a1 - 1);
a1[*(unsigned int *)(a2 + 4) + 1] = a1[*a1 + 1];
*a1 = result;
return result;
}

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

result = (unsigned int)(*a1 - 1);
a1[*(unsigned int *)(a2 + 4) + 1] = a1[*a1 + 1];
*a1 = result;
return result;
}

original_code:
static void vm_str(VM *vm, VMInstruction *i)
{
  vm->memory[i->param1] = vm->memory[vm->stack_top];
  vm->stack_top--;
}

canonical_original_code:
static void vm_str(struct _VM *vm, struct _VMInstruction *i)
{
  vm->memory[i->param1] = vm->memory[vm->stack_top];
  vm->stack_top--;
}