decompiled_code:
__int64 get_agi_seqno()
{
return (dword_DA8 << 8) & 0xFF0000 | HIBYTE(dword_DA8) | (dword_DA8 << 24) | ((unsigned int)dword_DA8 >> 8) & 0xFF00;
}

canonical_decompiled_code:
__int64 func17()
{
return (dword_DA8 << 8) & 0xFF0000 | HIBYTE(dword_DA8) | (dword_DA8 << 24) | ((unsigned int)dword_DA8 >> 8) & 0xFF00;
}

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 *

return_type: int


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:
void *__fastcall mem_set(void *a1, int a2, size_t a3)
{
return memset(a1, a2, a3);
}

canonical_decompiled_code:
void *__fastcall func8(void *a1, int a2, size_t a3)
{
return memset(a1, a2, a3);
}

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:
int __fastcall str_ncmp(const char *a1, const char *a2, size_t a3)
{
return strncmp(a1, a2, a3);
}

canonical_decompiled_code:
int __fastcall func10(const char *a1, const char *a2, size_t a3)
{
return strncmp(a1, a2, a3);
}

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 *

variable_types: ret int


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

return_type: void


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

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

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

v3 = a1;
for ( result = a2(a1, a3); ; result = a2((_QWORD *)v6, a3) )
{
v6 = *v3 & 0xFFFFFFFFFFFFFFFCLL;
if ( !v6 )
break;
v7 = *(_QWORD **)(v6 + 16);
if ( v7 == v3 )
{
if ( *(_QWORD *)(v6 + 8) )
{
a2(*(_QWORD **)(v6 + 8), a3);
goto LABEL_5;
}
LABEL_4:
a2(v7, a3);
goto LABEL_5;
}
if ( v7 )
goto LABEL_4;
LABEL_5:
v3 = (_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(_QWORD *a1, __int64 (__fastcall *a2)(_QWORD *, __int64), __int64 a3)
{
_QWORD *v3; // rax

v3 = (_QWORD *)a1[2];
if ( !v3 )
{
v3 = (_QWORD *)a1[1];
if ( !v3 )
v3 = a1;
}
return rb_augment_path(v3, 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 func8(_QWORD *a1, __int64 (__fastcall *a2)(_QWORD *, __int64), __int64 a3)
{
__int64 result; // rax

if ( a1 )
result = func5(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);
}


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

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

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


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

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

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(_QWORD *a1)
{
unsigned __int64 v1; // rdx
unsigned __int64 result; // rax
_QWORD *v3; // rcx

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

canonical_decompiled_code:
unsigned __int64 __fastcall func11(_QWORD *a1)
{
unsigned __int64 v1; // rdx
unsigned __int64 result; // rax
_QWORD *v3; // rcx

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

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(_QWORD *a1)
{
unsigned __int64 result; // rax
_QWORD *v2; // rdx

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

canonical_decompiled_code:
unsigned __int64 __fastcall func12(_QWORD *a1)
{
unsigned __int64 result; // rax
_QWORD *v2; // rdx

result = a1[1];
if ( result )
{
if ( a1[2] )
{
v2 = (_QWORD *)func11(a1);
result = v2[1];
if ( !result )
{
result = *v2 & 0xFFFFFFFFFFFFFFFCLL;
if ( (_QWORD *)result == a1 )
result = (unsigned __int64)v2;
}
}
}
else
{
result = a1[2];
if ( !result )
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(_QWORD *a1)
{
unsigned __int64 v1; // rdx
unsigned __int64 result; // rax
_QWORD *v3; // rcx

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

canonical_decompiled_code:
unsigned __int64 __fastcall func13(_QWORD *a1)
{
unsigned __int64 v1; // rdx
unsigned __int64 result; // rax
_QWORD *v3; // rcx

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

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 *


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 *

return_type: unsigned int


variable_types:
ret
unsigned long long

return_type: 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 func12(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:
__int64 __fastcall xfs_dir2_sf_get_parent_ino(__int64 a1)
{
return xfs_dir2_sf_get_ino(a1, (unsigned __int64 *)(a1 + 2));
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
return func9(a1, (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:
__int64 __fastcall xfs_dir2_sfe_get_ino(__int64 a1, unsigned __int8 *a2)
{
unsigned __int64 *v2; // rax

v2 = (unsigned __int64 *)xfs_dir2_sfe_inop(a2);
return xfs_dir2_sf_get_ino(a1, v2);
}

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

v2 = (unsigned __int64 *)func12(a2);
return func9(a1, 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)
{
return a1 + (int)xfs_dir2_sf_hdr_size(*(unsigned __int8 *)(a1 + 1));
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return a1 + (int)func0(*(unsigned __int8 *)(a1 + 1));
}

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)
{
unsigned int v6; // eax
unsigned __int64 result; // rax

if ( a4 && (v6 = HIDWORD(sb[0]), v6 * a3 > a4) )
{
read_file_length(a1, v6 * a2, (unsigned int)a4, 1LL);
result = a4;
}
else
{
read_file_length(a1, HIDWORD(sb[0]) * a2, HIDWORD(sb[0]), 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)
{
unsigned int v6; // eax
unsigned __int64 result; // rax

if ( a4 && (v6 = HIDWORD(sb[0]), v6 * a3 > a4) )
{
read_file_length(a1, v6 * a2, (unsigned int)a4, 1LL);
result = a4;
}
else
{
read_file_length(a1, HIDWORD(sb[0]) * a2, HIDWORD(sb[0]), 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)
{
read_blocks((__int64)&block_buf, a1, 1u, 0LL);
block_bufp = (__int64)&block_buf;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
func6((__int64)&block_buf, a1, 1u, 0LL);
block_bufp = (__int64)&block_buf;
return 0LL;
}

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)
{
const char *v3; // r12
unsigned __int8 *v4; // rbx
int v5; // ebp
const char *v6; // r15
__int64 v7; // rbx
__int64 v8; // r13
unsigned __int8 v9; // bp
unsigned __int8 v10; // bl
int v11; // ebp
char v12; // al
int v13; // er14
int v14; // eax
__int64 v16; // rax
_QWORD *v17; // rbx
int v18; // ecx
unsigned __int64 v19; // rbp
__int64 v20; // r14
int v21; // eax
__int64 v22; // [rsp+8h] [rbp-E0h]
__int64 v24; // [rsp+20h] [rbp-C8h] BYREF
__int64 v25; // [rsp+28h] [rbp-C0h]
__int64 v26; // [rsp+30h] [rbp-B8h]
__int64 v27[2]; // [rsp+40h] [rbp-A8h] BYREF
unsigned __int16 v28; // [rsp+50h] [rbp-98h] BYREF
unsigned __int16 v29; // [rsp+52h] [rbp-96h]
char v30; // [rsp+54h] [rbp-94h]
char v31; // [rsp+55h] [rbp-93h]

v3 = a1;
eprint("read_file_from_disk: %s\n", a1);
v22 = rootino;
while ( *v3 )
{
if ( *v3 != 47 )
return 4294967293LL;
v6 = v3 + 1;
v7 = read_inode_relative(v22, (__int64)&v28);
if ( !v7 )
goto LABEL_21;
eprint("%x %x %x\n", v28, v29, (unsigned int)v30);
if ( (v29 & 0xF000) != 0x4000 )
return 4294967293LL;
if ( v31 != 1 )
return 4294967293LL;
v8 = v7 + 100;
v9 = *(_BYTE *)(v7 + 100);
v10 = *(_BYTE *)(v7 + 101);
eprint("Get count is %d %d\n", v9, v10);
if ( (v9 == 0) == (v10 == 0) )
return 4294967294LL;
v11 = v9 + v10;
v4 = (unsigned __int8 *)xfs_dir2_sf_firstentry(v8);
eprint("get entry len %d, offset %d\n", *v4, v4[2]);
v12 = v3[1];
if ( !v12 || v12 == 47 )
{
v21 = v11;
v5 = v11 - 1;
++v3;
v13 = 0;
if ( v21 )
goto LABEL_4;
}
else
{
++v3;
do
++v3;
while ( *v3 && *v3 != 47 );
v13 = (_DWORD)v3 - (_DWORD)v6;
v14 = v11;
v5 = v11 - 1;
if ( v14 )
{
LABEL_4:
while ( *v4 != v13 || (unsigned int)str_ncmp(v4 + 3, v6, v13) )
{
v4 = xfs_dir2_sf_nextentry(v8, v4);
if ( !v5 )
goto LABEL_7;
--v5;
}
v22 = xfs_dir2_sfe_get_ino(v8, v4);
}
else
{
LABEL_7:
if ( v6 != v3 )
return 4294967292LL;
}
}
}
eprint("Get first file block %lld\n", v22);
v16 = read_inode_relative(v22, (__int64)&v28);
if ( !v16 )
{
LABEL_21:
eprint("read ino error %lld\n", v22);
return 0xFFFFFFFFLL;
}
if ( (v29 & 1) != 0 )
return 4294967293LL;
if ( v31 != 2 )
return 4294967293LL;
v17 = (_QWORD *)(v16 + 100);
v18 = (*(_DWORD *)(v16 + 76) >> 8) & 0xFF00 | (*(_DWORD *)(v16 + 76) << 8) & 0xFF0000 | HIBYTE(*(_DWORD *)(v16 + 76)) | (*(_DWORD *)(v16 + 76) << 24);
v19 = (*(_QWORD *)(v16 + 56) >> 40) & 0xFF00LL | (*(_QWORD *)(v16 + 56) >> 24) & 0xFF0000LL | (*(_QWORD *)(v16 + 56) >> 8) & 0xFF000000LL | (*(_QWORD *)(v16 + 56) << 8) & 0xFF00000000LL | (*(_QWORD *)(v16 + 56) << 24) & 0xFF0000000000LL | (*(_QWORD *)(v16 + 56) << 40) & 0xFF000000000000LL | HIBYTE(*(_QWORD *)(v16 + 56)) | (*(_QWORD *)(v16 + 56) << 56);
if ( v19 > a3 )
return 4294967291LL;
if ( !v18 )
return 0LL;
v20 = v16 + 16LL * (unsigned int)(v18 - 1) + 116;
do
{
v27[0] = (*v17 >> 40) & 0xFF00LL | (*v17 >> 24) & 0xFF0000LL | (*v17 >> 8) & 0xFF000000LL | (*v17 << 8) & 0xFF00000000LL | (*v17 << 24) & 0xFF0000000000LL | (*v17 << 40) & 0xFF000000000000LL | HIBYTE(*v17) | (*v17 << 56);
v27[1] = (v17[1] >> 40) & 0xFF00LL | (v17[1] >> 24) & 0xFF0000LL | (v17[1] >> 8) & 0xFF000000LL | (v17[1] << 8) & 0xFF00000000LL | (v17[1] << 24) & 0xFF0000000000LL | (v17[1] << 40) & 0xFF000000000000LL | HIBYTE(v17[1]) | (v17[1] << 56);
xfs_bmbt_get_all(v27, &v24);
eprint("%u %u %u\n", v24, v25, v26);
v19 -= read_blocks(v24 + a2, v25, v26, v19);
v17 += 2;
}
while ( (_QWORD *)v20 != v17 );
return 0LL;
}

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 = gui_main((unsigned int)argc, argv);
else
result = compiler_main((unsigned int)argc, argv);
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 = *(_DWORD *)(a2 + 4);
LODWORD(result) = *a1 + 1;
*a1 = result;
result = (int)result;
a1[(int)result + 1] = a1[v2 + 1];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_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] = a1[v2 + 1];
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)
{
int v1; // eax
__int64 result; // rax

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

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

v1 = *a1;
a1[*a1] += a1[*a1 + 1];
result = (unsigned int)(v1 - 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)
{
int v1; // eax
__int64 result; // rax

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

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

v1 = *a1;
a1[*a1] -= a1[*a1 + 1];
result = (unsigned int)(v1 - 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)
{
int v1; // eax
__int64 result; // rax

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

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

v1 = *a1;
a1[*a1] *= a1[*a1 + 1];
result = (unsigned int)(v1 - 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; // ecx

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

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

result = (unsigned int)(*a1 - 1);
v2 = 0;
if ( a1[(int)result + 1] == 1 )
v2 = a1[*a1 + 1] == 1;
a1[(int)result + 1] = v2;
*a1 = result;
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

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

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

result = (unsigned int)(*a1 - 1);
v2 = a1[(int)result + 1];
if ( v2 != 1 )
v2 = a1[*a1 + 1] == 1;
a1[(int)result + 1] = v2;
*a1 = result;
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)
{
int v1; // eax
__int64 result; // rax

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

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

v1 = *a1;
a1[*a1] = a1[*a1] < a1[*a1 + 1];
result = (unsigned int)(v1 - 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)
{
int v1; // eax
__int64 result; // rax

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

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

v1 = *a1;
a1[*a1] = a1[*a1] > a1[*a1 + 1];
result = (unsigned int)(v1 - 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)
{
int v1; // eax
__int64 result; // rax

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

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

v1 = *a1;
a1[*a1] = a1[*a1] == a1[*a1 + 1];
result = (unsigned int)(v1 - 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)
{
int v1; // eax
__int64 result; // rax

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

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

v1 = *a1;
a1[*a1] = a1[*a1] != a1[*a1 + 1];
result = (unsigned int)(v1 - 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)
{
int v1; // eax
__int64 result; // rax

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

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

v1 = *a1;
a1[*a1] = a1[*a1] <= a1[*a1 + 1];
result = (unsigned int)(v1 - 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)
{
int v1; // eax
__int64 result; // rax

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

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

v1 = *a1;
a1[*a1] = a1[*a1] >= a1[*a1 + 1];
result = (unsigned int)(v1 - 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)
{
unsigned int v2; // edx
int v3; // eax
__int64 result; // rax

v2 = 0;
do
{
v3 = *a1 + 1;
*a1 = v3;
a1[v3 + 1] = a1[*(_DWORD *)(a2 + 4) + 1 + v2++];
result = (unsigned int)(*(_DWORD *)(a2 + 8) - 1);
}
while ( (unsigned int)result >= v2 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(int *a1, __int64 a2)
{
unsigned int v2; // edx
int v3; // eax
__int64 result; // rax

v2 = 0;
do
{
v3 = *a1 + 1;
*a1 = v3;
a1[v3 + 1] = a1[*(_DWORD *)(a2 + 4) + 1 + v2++];
result = (unsigned int)(*(_DWORD *)(a2 + 8) - 1);
}
while ( (unsigned int)result >= v2 );
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


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

for ( i = *(_DWORD *)(a2 + 8) - 1; i >= 0; --i )
{
v3 = *a1;
a1[*(_DWORD *)(a2 + 4) + i + 1] = a1[*a1 + 1];
result = (unsigned int)(v3 - 1);
*a1 = result;
}
return result;
}

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

for ( i = *(_DWORD *)(a2 + 8) - 1; i >= 0; --i )
{
v3 = *a1;
a1[*(_DWORD *)(a2 + 4) + i + 1] = a1[*a1 + 1];
result = (unsigned int)(v3 - 1);
*a1 = result;
}
return result;
}

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)
{
int v2; // eax
__int64 result; // rax

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

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

v2 = *a1;
a1[*(unsigned int *)(a2 + 4) + 1] = a1[*a1 + 1];
result = (unsigned int)(v2 - 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--;
}


original_code:
static void vm_prn(VM *vm, VMInstruction *i)
{
  gchar *tmp;
  tmp = g_strdup_printf("%d", vm->memory[vm->stack_top]);
  vm->write_function(vm->write_function_data, tmp);
  vm->stack_top--;
  g_free(tmp);
}

canonical_original_code:
static void vm_prn(struct _VM *vm, struct _VMInstruction *i)
{
  char *tmp;
  tmp = g_strdup_printf("%d", vm->memory[vm->stack_top]);
  vm->write_function(vm->write_function_data, tmp);
  vm->stack_top--;
  g_free(tmp);
}

variable_types:
tmp
char *


decompiled_code:
__int64 __fastcall vm_rd(int *a1)
{
const char *v1; // rax
int v2; // edx
__int64 result; // rax

++*a1;
v1 = (const char *)(*((__int64 (__fastcall **)(_QWORD))a1 + 32772))(*((_QWORD *)a1 + 32775));
v2 = atoi(v1);
result = *a1;
a1[result + 1] = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func23(int *a1)
{
const char *v1; // rax
int v2; // edx
__int64 result; // rax

++*a1;
v1 = (const char *)(*((__int64 (__fastcall **)(_QWORD))a1 + 32772))(*((_QWORD *)a1 + 32775));
v2 = atoi(v1);
result = *a1;
a1[result + 1] = v2;
return result;
}

original_code:
static void vm_rd(VM *vm, VMInstruction *i)
{
  vm->stack_top++;
  vm->memory[vm->stack_top] = atoi(vm->read_function(vm->read_function_data));
}

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


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

result = g_list_nth(*((_QWORD *)a1 + 32769), (unsigned int)(a1[*a1 + 1] - 1));
*((_QWORD *)a1 + 32770) = result;
--*a1;
return result;
}

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

result = g_list_nth(*((_QWORD *)a1 + 32769), (unsigned int)(a1[*a1 + 1] - 1));
*((_QWORD *)a1 + 32770) = result;
--*a1;
return result;
}

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

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


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

v2 = a1[*(unsigned int *)(a2 + 4) + 1];
*(_DWORD *)(a2 + 8) = 1;
vm_dalloc(a1, a2);
vm_return(a1);
LODWORD(result) = *a1 + 1;
*a1 = result;
result = (int)result;
a1[(int)result + 1] = v2;
return result;
}

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

v2 = a1[*(unsigned int *)(a2 + 4) + 1];
*(_DWORD *)(a2 + 8) = 1;
func18(a1, a2);
func24(a1);
LODWORD(result) = *a1 + 1;
*a1 = result;
result = (int)result;
a1[(int)result + 1] = v2;
return result;
}

original_code:
static void vm_returnf(VM *vm, VMInstruction *i)
{
  gint return_value;
  return_value = vm->memory[i->param1];
  i->param2 = 1;
  vm_dalloc(vm, i);
  vm_return(vm, i);
  vm->memory[++vm->stack_top] = return_value;
}

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


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

result = g_list_nth(*(_QWORD *)(a1 + 262152), (unsigned int)(*(_DWORD *)(a2 + 4) - 1));
*(_QWORD *)(a1 + 262160) = result;
return result;
}

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

result = g_list_nth(*(_QWORD *)(a1 + 262152), (unsigned int)(*(_DWORD *)(a2 + 4) - 1));
*(_QWORD *)(a1 + 262160) = result;
return result;
}

original_code:
static void vm_jmp(VM *vm, VMInstruction *i)
{
  vm->instruction_pointer = g_list_nth(vm->program, i->param1 - 1);
}

canonical_original_code:
static void vm_jmp(struct _VM *vm, struct _VMInstruction *i)
{
  vm->instruction_pointer = g_list_nth(vm->program, i->param1 - 1);
}


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

result = *a1;
if ( !a1[result + 1] )
result = vm_jmp((__int64)a1, a2);
--*a1;
return result;
}

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

result = *a1;
if ( !a1[result + 1] )
result = func26((__int64)a1, a2);
--*a1;
return result;
}

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

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


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

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


decompiled_code:
int __fastcall vm_default_write_function(__int64 a1, const char *a2)
{
return printf(">>> %s\n", a2);
}

canonical_decompiled_code:
int __fastcall func29(__int64 a1, const char *a2)
{
return printf(">>> %s\n", a2);
}

original_code:
static void
vm_default_write_function(gpointer data, char *string)
{
  printf(">>> %s\n", string);
}

canonical_original_code:
static void vm_default_write_function(void *data, char *string)
{
  printf(">>> %s\n", string);
}

variable_types:
data
void *

variable_types:
string
char *


decompiled_code:
char *vm_default_read_function()
{
printf("<<< ");
fgets(buffer_0, 128, stdin);
return buffer_0;
}

canonical_decompiled_code:
char *func30()
{
printf("<<< ");
fgets(buffer_0, 128, stdin);
return buffer_0;
}

original_code:
static gchar *
vm_default_read_function(gpointer data)
{
  static char buffer[128];
  printf("<<< ");
  fgets(buffer, 128, stdin);
  return buffer;
}

canonical_original_code:
static char *vm_default_read_function(void *data)
{
  static char buffer[128];
  printf("<<< ");
  fgets(buffer, 128, stdin);
  return buffer;
}

variable_types:
buffer
char [128]

return_type: char *


decompiled_code:
__int64 __fastcall vm_destroy(__int64 a1)
{
return g_free(a1);
}

canonical_decompiled_code:
__int64 __fastcall func31(__int64 a1)
{
return g_free(a1);
}

original_code:
void
vm_destroy(VM *vm)
{
  g_free(vm);
}

canonical_original_code:
void vm_destroy(struct _VM *vm)
{
  g_free(vm);
}


original_code:
void
vm_reset(VM *vm)
{
  vm->running = (0);
  vm->stack_top = -1;
  vm->instruction_pointer = vm->program;
  memset(vm->memory, 0, sizeof(vm->memory));
}

canonical_original_code:
void vm_reset(struct _VM *vm)
{
  vm->running = (0);
  vm->stack_top = -1;
  vm->instruction_pointer = vm->program;
  memset(vm->memory, 0, sizeof(vm->memory));
}


original_code:
void
vm_object_unload(VM *vm)
{
  VMInstruction *instruction;
  GList *list;
  for (list = vm->program; list; list = list->next) {
    instruction = (VMInstruction *)list->data;
    g_free(instruction->sparam1);
    g_free(instruction->sparam2);
    g_free(instruction->label_name);
    g_free(instruction);
  }
  g_list_free(vm->program);
  vm->program = ((void *)0);
}

canonical_original_code:
void vm_object_unload(struct _VM *vm)
{
  struct _VMInstruction *instruction;
  struct _GList *list;
  for (list = vm->program; list; list = list->next) {
    instruction = (struct _VMInstruction *)list->data;
    g_free(instruction->sparam1);
    g_free(instruction->sparam2);
    g_free(instruction->label_name);
    g_free(instruction);
  }
  g_list_free(vm->program);
  vm->program = ((void *)0);
}

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


original_code:
void
vm_step(VM *vm)
{
  VMInstruction *instruction;
  if (!vm->program || !vm->instruction_pointer)
    return;
  if ((instruction = (VMInstruction *)vm->instruction_pointer->data)) {
    vm->instruction_pointer = vm->instruction_pointer->next;
    instructions[instruction->opcode].callback(vm, instruction);
  }
}

canonical_original_code:
void vm_step(struct _VM *vm)
{
  struct _VMInstruction *instruction;
  if (!vm->program || !vm->instruction_pointer)
    return;
  if ((instruction = (struct _VMInstruction *)vm->instruction_pointer->data)) {
    vm->instruction_pointer = vm->instruction_pointer->next;
    instructions[instruction->opcode].callback(vm, instruction);
  }
}


decompiled_code:
_QWORD *symbol_table_new()
{
_QWORD *result; // rax

result = (_QWORD *)g_malloc0(16LL);
*result = 0LL;
result[1] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func3()
{
_QWORD *result; // rax

result = (_QWORD *)g_malloc0(16LL);
*result = 0LL;
result[1] = 0LL;
return result;
}

original_code:
SymbolTable *
symbol_table_new(void)
{
  SymbolTable *st;
  st = ((SymbolTable *) g_malloc0_n ((1), sizeof (SymbolTable)));
  st->root = ((void *)0);
  st->current_level = ((void *)0);
  return st;
}

canonical_original_code:
struct _SymbolTable *symbol_table_new()
{
  struct _SymbolTable *st;
  st = ((struct _SymbolTable *) g_malloc0_n ((1), sizeof (SymbolTable)));
  st->root = ((void *)0);
  st->current_level = ((void *)0);
  return st;
}

variable_types: struct _SymbolTable { struct _GNode { void *data; struct _GNode *next; struct _GNode *prev; struct _GNode *parent; struct _GNode *children; } *root; struct _GNode *current_level; } *

user_defined_types: struct _SymbolTable { struct _GNode *root; struct _GNode *current_level; }


decompiled_code:
__int64 __fastcall symbol_table_is_defined(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rbx
int v4; // ebp
__int64 result; // rax

v3 = *(_QWORD *)(a1 + 8);
if ( !v3 )
return 0LL;
v4 = a3;
if ( !a3 )
return 0LL;
while ( 1 )
{
result = symbol_table_get_node_at_context(a1, v3, a2);
if ( result )
return 1LL;
v3 = *(_QWORD *)(v3 + 24);
if ( !v3 )
break;
if ( !--v4 )
return result;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rbx
int v4; // ebp
__int64 result; // rax

v3 = *(_QWORD *)(a1 + 8);
if ( !v3 )
return 0LL;
v4 = a3;
if ( !a3 )
return 0LL;
while ( 1 )
{
result = func0(a1, v3, a2);
if ( result )
return 1LL;
v3 = *(_QWORD *)(v3 + 24);
if ( !v3 )
break;
if ( !--v4 )
return result;
}
return 0LL;
}

original_code:
gboolean
symbol_table_is_defined(SymbolTable *st, gchar *name, gint level)
{
  GNode *l;
  for (l = st->current_level; l && level--; l = l->parent) {
    if (symbol_table_get_node_at_context(st, l, name)) {
        return (!(0));
    }
  }
  return (0);
}

canonical_original_code:
int symbol_table_is_defined(struct _SymbolTable *st, char *name, int level)
{
  struct _GNode *l;
  for (l = st->current_level; l && level--; l = l->parent) {
    if (symbol_table_get_node_at_context(st, l, name)) {
        return (!(0));
    }
  }
  return (0);
}

variable_types:
name
char *

variable_types: level int

variable_types: struct _GNode { void *data; struct _GNode *next; struct _GNode *prev; struct _GNode *parent; struct _GNode *children; } *


decompiled_code:
__int64 __fastcall symbol_table_lookup_symbol(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 *v3; // rax

v2 = *(_QWORD *)(a1 + 8);
if ( v2 )
{
while ( 1 )
{
v3 = (__int64 *)symbol_table_get_node_at_context(a1, v2, a2);
if ( v3 )
break;
v2 = *(_QWORD *)(v2 + 24);
if ( !v2 )
return v2;
}
v2 = *v3;
}
return v2;
}

original_code:
Symbol *
symbol_table_lookup_symbol(SymbolTable *st, gchar *name)
{
  GNode *level, *node;
  for (level = st->current_level; level; level = level->parent) {
    if ((node = symbol_table_get_node_at_context(st, level, name))) {
       return (Symbol *)node->data;
    }
  }
  return ((void *)0);
}

canonical_original_code:
struct _Symbol *symbol_table_lookup_symbol(struct _SymbolTable *st, char *name)
{
  struct _GNode *level; struct _GNode *node;
  for (level = st->current_level; level; level = level->parent) {
    if ((node = symbol_table_get_node_at_context(st, level, name))) {
       return (struct _Symbol *)node->data;
    }
  }
  return ((void *)0);
}

return_type: struct _Symbol { char *name; enum SymbolType { ST_NONE=0, ST_VARIABLE=1, ST_FUNCTION=2, ST_PROCEDURE=3, ST_PROGRAM=4 } type; enum SymbolSubType { SST_NONE=0, SST_INTEGER=1, SST_BOOLEAN=2 } subtype; int memory_address; } *

user_defined_types: struct _GNode { void *data; struct _GNode *next; struct _GNode *prev; struct _GNode *parent; struct _GNode *children; }

user_defined_types: struct _Symbol { char *name; enum SymbolType type; enum SymbolSubType subtype; int memory_address; }


decompiled_code:
_BOOL8 __fastcall symbol_table_is_installed(__int64 a1, __int64 a2)
{
return symbol_table_lookup_symbol(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(__int64 a1, __int64 a2)
{
return func6(a1, a2) != 0;
}

original_code:
gboolean
symbol_table_is_installed(SymbolTable *st, gchar *name)
{
  return symbol_table_lookup_symbol(st, name) != ((void *)0);
}

canonical_original_code:
int symbol_table_is_installed(struct _SymbolTable *st, char *name)
{
  return symbol_table_lookup_symbol(st, name) != ((void *)0);
}


decompiled_code:
__int64 __fastcall symbol_table_get_attribute_int(__int64 a1, __int64 a2, int a3)
{
_DWORD *v4; // rax
unsigned int v5; // edx

v4 = (_DWORD *)symbol_table_lookup_symbol(a1, a2);
v5 = 0;
if ( v4 )
{
switch ( a3 )
{
case 1:
v5 = v4[3];
break;
case 2:
v5 = v4[4];
break;
case 0:
v5 = v4[2];
break;
}
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, int a3)
{
_DWORD *v4; // rax
unsigned int v5; // edx

v4 = (_DWORD *)func6(a1, a2);
v5 = 0;
if ( v4 )
{
switch ( a3 )
{
case 1:
v5 = v4[3];
break;
case 2:
v5 = v4[4];
break;
case 0:
v5 = v4[2];
break;
}
}
return v5;
}

original_code:
gint
symbol_table_get_attribute_int(SymbolTable *st, gchar *name, SymbolTableField field)
{
  Symbol *symbol;
  if ((symbol = symbol_table_lookup_symbol(st, name))) {
    switch (field) {
    case STF_TYPE:
      return symbol->type;
    case STF_SUBTYPE:
      return symbol->subtype;
    case STF_MEMORY_ADDRESS:
      return symbol->memory_address;
    default: return 0;
    }
  }
  return 0;
}

canonical_original_code:
int symbol_table_get_attribute_int(struct _SymbolTable *st, char *name, enum SymbolTableField field)
{
  struct _Symbol *symbol;
  if ((symbol = symbol_table_lookup_symbol(st, name))) {
    switch (field) {
    case STF_TYPE:
      return symbol->type;
    case STF_SUBTYPE:
      return symbol->subtype;
    case STF_MEMORY_ADDRESS:
      return symbol->memory_address;
    default: return 0;
    }
  }
  return 0;
}

variable_types: enum SymbolTableField { STF_TYPE=0, STF_SUBTYPE=1, STF_MEMORY_ADDRESS=2 }

variable_types: struct _Symbol { char *name; enum SymbolType { ST_NONE=0, ST_VARIABLE=1, ST_FUNCTION=2, ST_PROCEDURE=3, ST_PROGRAM=4 } type; enum SymbolSubType { SST_NONE=0, SST_INTEGER=1, SST_BOOLEAN=2 } subtype; int memory_address; } *


decompiled_code:
void __fastcall symbol_table_context_enter(__int64 a1, __int64 a2)
{
__int64 v2; // rax

if ( *(_QWORD *)(a1 + 8) )
{
v2 = symbol_table_get_node_at_current_context(a1, a2);
if ( v2 )
*(_QWORD *)(a1 + 8) = v2;
}
}

original_code:
void
symbol_table_context_enter(SymbolTable *st, gchar *context)
{
  GNode *node;
  if (!st->current_level) {
    return;
  }
  if ((node = symbol_table_get_node_at_current_context(st, context))) {
    st->current_level = node;
  }
}

canonical_original_code:
void symbol_table_context_enter(struct _SymbolTable *st, char *context)
{
  struct _GNode *node;
  if (!st->current_level) {
    return;
  }
  if ((node = symbol_table_get_node_at_current_context(st, context))) {
    st->current_level = node;
  }
}

variable_types:
context
char *


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

result = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 24LL);
*(_QWORD *)(a1 + 8) = result;
return result;
}

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

result = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 24LL);
*(_QWORD *)(a1 + 8) = result;
return result;
}

original_code:
void
symbol_table_context_leave(SymbolTable *st)
{
  st->current_level = st->current_level->parent;
}

canonical_original_code:
void symbol_table_context_leave(struct _SymbolTable *st)
{
  st->current_level = st->current_level->parent;
}


decompiled_code:
__int64 __fastcall symbol_table_get_context_level(__int64 a1)
{
return g_node_depth(*(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
return g_node_depth(*(_QWORD *)(a1 + 8));
}

original_code:
gint
symbol_table_get_context_level(SymbolTable *st)
{
  return g_node_depth(st->current_level);
}

canonical_original_code:
int symbol_table_get_context_level(struct _SymbolTable *st)
{
  return g_node_depth(st->current_level);
}


decompiled_code:
int __fastcall symbol_table_print(__int64 **a1)
{
return symbol_table_print_func((__int64)a1, *a1);
}

canonical_decompiled_code:
int __fastcall func13(__int64 **a1)
{
return func2((__int64)a1, *a1);
}

original_code:
void
symbol_table_print(SymbolTable *st)
{
  symbol_table_print_func(st, st->root);
}

canonical_original_code:
void symbol_table_print(struct _SymbolTable *st)
{
  symbol_table_print_func(st, st->root);
}


decompiled_code:
int __fastcall symbol_table_free(__int64 **a1)
{
return symbol_table_print(a1);
}

canonical_decompiled_code:
int __fastcall func14(__int64 **a1)
{
return func13(a1);
}

original_code:
void
symbol_table_free(SymbolTable *st)
{
  symbol_table_print(st);
}

canonical_original_code:
void symbol_table_free(struct _SymbolTable *st)
{
  symbol_table_print(st);
}


decompiled_code:
__int64 symbol_table_test_main()
{
__int64 v0; // rbx

v0 = lex();
ast(v0);
tl_unref(v0);
symbol_table_print(symbol_table);
return 0LL;
}

canonical_decompiled_code:
__int64 func15()
{
__int64 v0; // rbx

v0 = lex();
ast(v0);
tl_unref(v0);
func13(symbol_table);
return 0LL;
}

original_code:
int
symbol_table_test_main(int argc, char **argv)
{
    GNode *root;
    TokenList *token_list;
    token_list = lex();
    root = ast(token_list);
    tl_unref(token_list);
    symbol_table_print(symbol_table);
    return 0;
}

canonical_original_code:
int symbol_table_test_main(int argc, char **argv)
{
    struct _GNode *root;
    struct _TokenList *token_list;
    token_list = lex();
    root = ast(token_list);
    tl_unref(token_list);
    symbol_table_print(symbol_table);
    return 0;
}

variable_types: argc int

variable_types: struct _TokenList { struct _GList { void *data; struct _GList *next; struct _GList *prev; } *tokens; int ref_count; } *

user_defined_types: struct _TokenList { struct _GList *tokens; int ref_count; }


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

result = g_slist_prepend(char_buf, a1);
char_buf = result;
return result;
}

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

result = g_slist_prepend(char_buf, a1);
char_buf = result;
return result;
}

original_code:
void
char_buf_put_char(char ch)
{
 char_buf = g_slist_prepend(char_buf, ((gpointer) (glong) ((gint)ch)));
}

canonical_original_code:
void char_buf_put_char(char ch)
{
 char_buf = g_slist_prepend(char_buf, ((gpointer) (glong) ((int)ch)));
}

variable_types: ch char


decompiled_code:
__int64 __fastcall char_buf_put_string(char *a1)
{
char v1; // si
char *v2; // rbx
__int64 v3; // rdi
__int64 result; // rax

v1 = *a1;
if ( *a1 )
{
v2 = a1;
v3 = 0LL;
do
{
++v2;
v3 = g_slist_append(v3, v1);
v1 = *v2;
}
while ( *v2 );
}
else
{
v3 = 0LL;
}
result = g_slist_concat(v3, char_buf);
char_buf = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *a1)
{
char v1; // si
char *v2; // rbx
__int64 v3; // rdi
__int64 result; // rax

v1 = *a1;
if ( *a1 )
{
v2 = a1;
v3 = 0LL;
do
{
++v2;
v3 = g_slist_append(v3, v1);
v1 = *v2;
}
while ( *v2 );
}
else
{
v3 = 0LL;
}
result = g_slist_concat(v3, char_buf);
char_buf = result;
return result;
}

original_code:
void
char_buf_put_string(gchar *string)
{
 GSList *temp = ((void *)0);
 while (*string) {
  temp = g_slist_append(temp, ((gpointer) (glong) ((gint)*string++)));
 }
 char_buf = g_slist_concat(temp, char_buf);
}

canonical_original_code:
void char_buf_put_string(char *string)
{
 struct _GSList *temp = ((void *)0);
 while (*string) {
  temp = g_slist_append(temp, ((gpointer) (glong) ((gint)*string++)));
 }
 char_buf = g_slist_concat(temp, char_buf);
}

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


decompiled_code:
__int64 char_buf_get()
{
FILE *v0; // rdi
int v1; // eax
unsigned int v2; // ebx
__int64 v4; // rbp

if ( char_buf )
{
v2 = *(_DWORD *)char_buf;
v4 = *(_QWORD *)(char_buf + 8);
g_slist_free_1();
char_buf = v4;
}
else
{
v0 = (FILE *)char_buf_input;
if ( !char_buf_input )
v0 = stdin;
v1 = fgetc(v0);
v2 = tolower(v1);
}
return v2;
}

canonical_decompiled_code:
__int64 func3()
{
FILE *v0; // rdi
int v1; // eax
unsigned int v2; // ebx
__int64 v4; // rbp

if ( char_buf )
{
v2 = *(_DWORD *)char_buf;
v4 = *(_QWORD *)(char_buf + 8);
g_slist_free_1();
char_buf = v4;
}
else
{
v0 = (FILE *)char_buf_input;
if ( !char_buf_input )
v0 = stdin;
v1 = fgetc(v0);
v2 = tolower(v1);
}
return v2;
}

original_code:
int
char_buf_get(void)
{
 int ch;
 if ((char_buf == ((void *)0))) {
  ch = tolower(fgetc(char_buf_input ? char_buf_input : stdin));
 } else {
  GSList *next;
  ch = ((gint) (glong) (char_buf->data));
  next = char_buf->next;
  g_slist_free_1(char_buf);
  char_buf = next;
 }
 return ch;
}

canonical_original_code:
int char_buf_get()
{
 int ch;
 if ((char_buf == ((void *)0))) {
  ch = tolower(fgetc(char_buf_input ? char_buf_input : stdin));
 } else {
  struct _GSList *next;
  ch = ((gint) (glong) (char_buf->data));
  next = char_buf->next;
  g_slist_free_1(char_buf);
  char_buf = next;
 }
 return ch;
}

variable_types: ch int

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


decompiled_code:
_QWORD *tl_new()
{
_QWORD *result; // rax

result = (_QWORD *)g_malloc0(16LL);
*result = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *result; // rax

result = (_QWORD *)g_malloc0(16LL);
*result = 0LL;
return result;
}

original_code:
TokenList *
tl_new(void)
{
 TokenList *tl;
 tl = ((TokenList *) g_malloc0_n ((1), sizeof (TokenList)));
 tl->tokens = ((void *)0);
 return tl;
}

canonical_original_code:
struct _TokenList *tl_new()
{
 struct _TokenList *tl;
 tl = ((struct _TokenList *) g_malloc0_n ((1), sizeof (TokenList)));
 tl->tokens = ((void *)0);
 return tl;
}

return_type: struct _TokenList { struct _GList { void *data; struct _GList *next; struct _GList *prev; } *tokens; int ref_count; } *


decompiled_code:
void __fastcall tl_ref(__int64 a1)
{
++*(_DWORD *)(a1 + 8);
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
++*(_DWORD *)(a1 + 8);
}

original_code:
void
tl_ref(TokenList * t)
{
 t->ref_count++;
}

canonical_original_code:
void tl_ref(struct _TokenList *t)
{
 t->ref_count++;
}


decompiled_code:
__int64 __fastcall tl_destroy(_QWORD *a1)
{
g_list_free(*a1);
return g_free(a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
g_list_free(*a1);
return g_free(a1);
}

original_code:
void
tl_destroy(TokenList * tl)
{
 g_list_free(tl->tokens);
 g_free(tl);
}

canonical_original_code:
void tl_destroy(struct _TokenList *tl)
{
 g_list_free(tl->tokens);
 g_free(tl);
}


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

if ( a1 )
{
result = (unsigned int)(*(_DWORD *)(a1 + 8) - 1);
*(_DWORD *)(a1 + 8) = result;
if ( (int)result < 0 )
result = tl_destroy((_QWORD *)a1);
}
return result;
}

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

if ( a1 )
{
result = (unsigned int)(*(_DWORD *)(a1 + 8) - 1);
*(_DWORD *)(a1 + 8) = result;
if ( (int)result < 0 )
result = func2((_QWORD *)a1);
}
return result;
}

original_code:
void
tl_unref(TokenList * t)
{
 if (t && --t->ref_count < 0) {
  tl_destroy(t);
 }
}

canonical_original_code:
void tl_unref(struct _TokenList *t)
{
 if (t && --t->ref_count < 0) {
  tl_destroy(t);
 }
}