decompiled_code:
void __fastcall set_data_alignment(int a1)
{
if ( auto_alignment )
align_data(a1);
}

canonical_decompiled_code:
void __fastcall func5(int a1)
{
if ( auto_alignment )
func4(a1);
}

original_code:
void
set_data_alignment (int alignment)
{
  if (auto_alignment)
    align_data (alignment);
}

canonical_original_code:
void set_data_alignment(int alignment)
{
  if (auto_alignment)
    align_data (alignment);
}


decompiled_code:
void enable_data_alignment()
{
auto_alignment = 1;
}

canonical_decompiled_code:
void func6()
{
auto_alignment = 1;
}

original_code:
void
enable_data_alignment (void)
{
  auto_alignment = 1;
}

return_type: void


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

result = (unsigned int)in_kernel;
if ( in_kernel )
next_k_data_pc = a1;
else
next_data_pc = a1;
return result;
}

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

result = (unsigned int)in_kernel;
if ( in_kernel )
next_k_data_pc = a1;
else
next_data_pc = a1;
return result;
}

original_code:
void
set_data_pc (mem_addr addr)
{
  if (in_kernel)
    next_k_data_pc = addr;
  else
    next_data_pc = addr;
}

canonical_original_code:
void set_data_pc(unsigned int addr)
{
  if (in_kernel)
    next_k_data_pc = addr;
  else
    next_data_pc = addr;
}

variable_types:
addr
unsigned int


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

result = (unsigned int)next_k_data_pc;
if ( !in_kernel )
result = (unsigned int)next_data_pc;
return result;
}

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

result = (unsigned int)next_k_data_pc;
if ( !in_kernel )
result = (unsigned int)next_data_pc;
return result;
}

original_code:
mem_addr
current_data_pc (void)
{
  return ((in_kernel ? next_k_data_pc : next_data_pc));
}

canonical_original_code:
unsigned int current_data_pc()
{
  return ((in_kernel ? next_k_data_pc : next_data_pc));
}

return_type: unsigned int


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

result = (unsigned int)in_kernel;
if ( in_kernel )
next_k_data_pc += a1;
else
next_data_pc += a1;
return result;
}

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

result = (unsigned int)in_kernel;
if ( in_kernel )
next_k_data_pc += a1;
else
next_data_pc += a1;
return result;
}

original_code:
void
increment_data_pc (int value)
{
  {if (in_kernel) next_k_data_pc += value; else {next_data_pc += value;}};
}

canonical_original_code:
void increment_data_pc(int value)
{
  {if (in_kernel) next_k_data_pc += value; else {next_data_pc += value;}};
}

variable_types: value int


decompiled_code:
__int64 __fastcall extern_directive(__int64 a1, int a2)
{
__int64 result; // rax
__int64 v4; // rcx
int v5; // esi

result = make_label_global();
if ( !bare_machine && (unsigned int)(a2 - 1) <= 7 )
{
v4 = (unsigned int)next_gp_item_addr;
v5 = a2 + next_gp_item_addr;
if ( a2 + next_gp_item_addr < (unsigned int)(gp_midpoint + 0x8000) )
{
*(_BYTE *)(result + 16) |= 2u;
*(_QWORD *)(result + 8) = v4;
next_gp_item_addr = v5;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, int a2)
{
__int64 result; // rax
__int64 v4; // rcx
int v5; // esi

result = make_label_global();
if ( !bare_machine && (unsigned int)(a2 - 1) <= 7 )
{
v4 = (unsigned int)next_gp_item_addr;
v5 = a2 + next_gp_item_addr;
if ( a2 + next_gp_item_addr < (unsigned int)(gp_midpoint + 0x8000) )
{
*(_BYTE *)(result + 16) |= 2u;
*(_QWORD *)(result + 8) = v4;
next_gp_item_addr = v5;
}
}
return result;
}

original_code:
void
extern_directive (char *name, int size)
{
  label *sym = make_label_global (name);
  if (!bare_machine
      && size > 0 && size <= 8
      && next_gp_item_addr + size < gp_midpoint + 32*1024)
    {
      sym->gp_flag = 1;
      sym->addr = next_gp_item_addr;
      next_gp_item_addr += size;
    }
}

canonical_original_code:
void extern_directive(char *name, int size)
{
  struct lab *sym = make_label_global (name);
  if (!bare_machine
      && size > 0 && size <= 8
      && next_gp_item_addr + size < gp_midpoint + 32*1024)
    {
      sym->gp_flag = 1;
      sym->addr = next_gp_item_addr;
      next_gp_item_addr += size;
    }
}

variable_types:
name
char *

variable_types: size int

variable_types: struct lab { char *name; long addr; unsigned int global_flag; unsigned int gp_flag; unsigned int const_flag; struct lab *next; struct lab *next_local; struct lab_use { struct inst_s { short opcode; union { struct { unsigned char rs; unsigned char rt; union { short imm; struct { unsigned char rd; unsigned char shamt; } r; } r_i; } r_i; unsigned int target; } r_t; unsigned int encoding; struct immexpr { int offset; struct lab *symbol; short bits; short pc_relative; } *expr; char *source_line; } *inst; unsigned int addr; struct lab_use *next; } *uses; } *

user_defined_types: struct lab { char *name; long addr; unsigned int global_flag; unsigned int gp_flag; unsigned int const_flag; struct lab *next; struct lab *next_local; struct lab_use *uses; }

user_defined_types: struct lab_use { struct inst_s *inst; unsigned int addr; struct lab_use *next; }

user_defined_types: struct inst_s { short opcode; union { struct { unsigned char rs; unsigned char rt; union { short imm; struct { unsigned char rd; unsigned char shamt; } r; } r_i; } r_i; unsigned int target; } r_t; unsigned int encoding; struct immexpr *expr; char *source_line; }


decompiled_code:
__int64 __fastcall lcomm_directive(__int64 a1, int a2)
{
__int64 result; // rax
__int64 v4; // rcx
int v5; // esi

result = lookup_label();
if ( !bare_machine && (unsigned int)(a2 - 1) <= 7 )
{
v4 = (unsigned int)next_gp_item_addr;
v5 = a2 + next_gp_item_addr;
if ( a2 + next_gp_item_addr < (unsigned int)(gp_midpoint + 0x8000) )
{
*(_BYTE *)(result + 16) |= 2u;
*(_QWORD *)(result + 8) = v4;
next_gp_item_addr = v5;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, int a2)
{
__int64 result; // rax
__int64 v4; // rcx
int v5; // esi

result = lookup_label();
if ( !bare_machine && (unsigned int)(a2 - 1) <= 7 )
{
v4 = (unsigned int)next_gp_item_addr;
v5 = a2 + next_gp_item_addr;
if ( a2 + next_gp_item_addr < (unsigned int)(gp_midpoint + 0x8000) )
{
*(_BYTE *)(result + 16) |= 2u;
*(_QWORD *)(result + 8) = v4;
next_gp_item_addr = v5;
}
}
return result;
}

original_code:
void
lcomm_directive (char *name, int size)
{
  label *sym = lookup_label (name);
  if (!bare_machine
      && size > 0 && size <= 8
      && next_gp_item_addr + size < gp_midpoint + 32*1024)
    {
      sym->gp_flag = 1;
      sym->addr = next_gp_item_addr;
      next_gp_item_addr += size;
    }
}

canonical_original_code:
void lcomm_directive(char *name, int size)
{
  struct lab *sym = lookup_label (name);
  if (!bare_machine
      && size > 0 && size <= 8
      && next_gp_item_addr + size < gp_midpoint + 32*1024)
    {
      sym->gp_flag = 1;
      sym->addr = next_gp_item_addr;
      next_gp_item_addr += size;
    }
}

user_defined_types: struct immexpr { int offset; struct lab *symbol; short bits; short pc_relative; }


decompiled_code:
__int64 __fastcall store_string(_BYTE *a1, int a2, int a3)
{
__int64 result; // rax
_BYTE *v4; // r12
_BYTE *v6; // rbx
__int64 v7; // rdi
__int64 v8; // rdi

result = (unsigned int)in_kernel;
v4 = &a1[a2];
v6 = a1;
if ( a2 > 0 )
{
do
{
while ( 1 )
{
v7 = (unsigned int)next_k_data_pc;
if ( !(_DWORD)result )
v7 = (unsigned int)next_data_pc;
data_modified = 1;
if ( (unsigned int)v7 <= 0xFFFFFFF || data_top <= (unsigned int)v7 )
{
if ( stack_bot > (unsigned int)v7 || (int)v7 < 0 )
{
if ( (unsigned int)v7 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v7 )
{
bad_mem_write(v7, (unsigned int)(char)*v6, 0LL);
result = (unsigned int)in_kernel;
}
else
{
*(_BYTE *)(k_data_seg_b + (unsigned int)(v7 + 1879048192)) = *v6;
}
}
else
{
*(_BYTE *)(stack_seg_b + (unsigned int)(v7 - stack_bot)) = *v6;
}
}
else
{
*(_BYTE *)(data_seg_b + (unsigned int)(v7 - 0x10000000)) = *v6;
}
if ( !(_DWORD)result )
break;
++v6;
++next_k_data_pc;
if ( v4 == v6 )
goto LABEL_11;
}
++v6;
++next_data_pc;
}
while ( v4 != v6 );
}
LABEL_11:
if ( a3 )
{
result = (unsigned int)in_kernel;
v8 = (unsigned int)next_k_data_pc;
data_modified = 1;
if ( !in_kernel )
v8 = (unsigned int)next_data_pc;
if ( (unsigned int)v8 <= 0xFFFFFFF || data_top <= (unsigned int)v8 )
{
if ( stack_bot > (unsigned int)v8 || (int)v8 < 0 )
{
if ( (unsigned int)v8 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v8 )
{
bad_mem_write(v8, 0LL, 0LL);
result = (unsigned int)in_kernel;
}
else
{
*(_BYTE *)(k_data_seg_b + (unsigned int)(v8 + 1879048192)) = 0;
}
}
else
{
*(_BYTE *)(stack_seg_b + (unsigned int)(v8 - stack_bot)) = 0;
}
if ( !(_DWORD)result )
goto LABEL_17;
}
else
{
*(_BYTE *)(data_seg_b + (unsigned int)(v8 - 0x10000000)) = 0;
if ( !(_DWORD)result )
{
LABEL_17:
++next_data_pc;
return result;
}
}
++next_k_data_pc;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(_BYTE *a1, int a2, int a3)
{
__int64 result; // rax
_BYTE *v4; // r12
_BYTE *v6; // rbx
__int64 v7; // rdi
__int64 v8; // rdi

result = (unsigned int)in_kernel;
v4 = &a1[a2];
v6 = a1;
if ( a2 > 0 )
{
do
{
while ( 1 )
{
v7 = (unsigned int)next_k_data_pc;
if ( !(_DWORD)result )
v7 = (unsigned int)next_data_pc;
data_modified = 1;
if ( (unsigned int)v7 <= 0xFFFFFFF || data_top <= (unsigned int)v7 )
{
if ( stack_bot > (unsigned int)v7 || (int)v7 < 0 )
{
if ( (unsigned int)v7 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v7 )
{
bad_mem_write(v7, (unsigned int)(char)*v6, 0LL);
result = (unsigned int)in_kernel;
}
else
{
*(_BYTE *)(k_data_seg_b + (unsigned int)(v7 + 1879048192)) = *v6;
}
}
else
{
*(_BYTE *)(stack_seg_b + (unsigned int)(v7 - stack_bot)) = *v6;
}
}
else
{
*(_BYTE *)(data_seg_b + (unsigned int)(v7 - 0x10000000)) = *v6;
}
if ( !(_DWORD)result )
break;
++v6;
++next_k_data_pc;
if ( v4 == v6 )
goto LABEL_11;
}
++v6;
++next_data_pc;
}
while ( v4 != v6 );
}
LABEL_11:
if ( a3 )
{
result = (unsigned int)in_kernel;
v8 = (unsigned int)next_k_data_pc;
data_modified = 1;
if ( !in_kernel )
v8 = (unsigned int)next_data_pc;
if ( (unsigned int)v8 <= 0xFFFFFFF || data_top <= (unsigned int)v8 )
{
if ( stack_bot > (unsigned int)v8 || (int)v8 < 0 )
{
if ( (unsigned int)v8 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v8 )
{
bad_mem_write(v8, 0LL, 0LL);
result = (unsigned int)in_kernel;
}
else
{
*(_BYTE *)(k_data_seg_b + (unsigned int)(v8 + 1879048192)) = 0;
}
}
else
{
*(_BYTE *)(stack_seg_b + (unsigned int)(v8 - stack_bot)) = 0;
}
if ( !(_DWORD)result )
goto LABEL_17;
}
else
{
*(_BYTE *)(data_seg_b + (unsigned int)(v8 - 0x10000000)) = 0;
if ( !(_DWORD)result )
{
LABEL_17:
++next_data_pc;
return result;
}
}
++next_k_data_pc;
}
return result;
}

original_code:
void
store_string (char *string, int length, int null_terminate)
{
  for ( ; length > 0; string ++, length --) {
    {register mem_addr _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((mem_addr) 0x10000000) && _addr_ < data_top) data_seg_b [_addr_ - ((mem_addr) 0x10000000)] = (unsigned char) (*string); else if (_addr_ >= stack_bot && _addr_ < ((mem_addr) 0x80000000)) stack_seg_b [_addr_ - stack_bot] = (unsigned char) (*string); else if (_addr_ >= ((mem_addr) 0x90000000) && _addr_ < k_data_top) k_data_seg_b [_addr_ - ((mem_addr) 0x90000000)] = (unsigned char) (*string); else bad_mem_write (_addr_, *string, 0);};
    {if (in_kernel) next_k_data_pc += 1; else {next_data_pc += 1;}};
  }
  if (null_terminate)
    {
      {register mem_addr _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((mem_addr) 0x10000000) && _addr_ < data_top) data_seg_b [_addr_ - ((mem_addr) 0x10000000)] = (unsigned char) (0); else if (_addr_ >= stack_bot && _addr_ < ((mem_addr) 0x80000000)) stack_seg_b [_addr_ - stack_bot] = (unsigned char) (0); else if (_addr_ >= ((mem_addr) 0x90000000) && _addr_ < k_data_top) k_data_seg_b [_addr_ - ((mem_addr) 0x90000000)] = (unsigned char) (0); else bad_mem_write (_addr_, 0, 0);};
      {if (in_kernel) next_k_data_pc += 1; else {next_data_pc += 1;}};
    }
}

canonical_original_code:
void store_string(char *string, int length, int null_terminate)
{
  for ( ; length > 0; string ++, length --) {
    {register unsigned int _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((unsigned int) 0x10000000) && _addr_ < data_top) data_seg_b [_addr_ - ((unsigned int) 0x10000000)] = (unsigned char) (*string); else if (_addr_ >= stack_bot && _addr_ < ((unsigned int) 0x80000000)) stack_seg_b [_addr_ - stack_bot] = (unsigned char) (*string); else if (_addr_ >= ((unsigned int) 0x90000000) && _addr_ < k_data_top) k_data_seg_b [_addr_ - ((unsigned int) 0x90000000)] = (unsigned char) (*string); else bad_mem_write (_addr_, *string, 0);};
    {if (in_kernel) next_k_data_pc += 1; else {next_data_pc += 1;}};
  }
  if (null_terminate)
    {
      {register unsigned int _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((unsigned int) 0x10000000) && _addr_ < data_top) data_seg_b [_addr_ - ((unsigned int) 0x10000000)] = (unsigned char) (0); else if (_addr_ >= stack_bot && _addr_ < ((unsigned int) 0x80000000)) stack_seg_b [_addr_ - stack_bot] = (unsigned char) (0); else if (_addr_ >= ((unsigned int) 0x90000000) && _addr_ < k_data_top) k_data_seg_b [_addr_ - ((unsigned int) 0x90000000)] = (unsigned char) (0); else bad_mem_write (_addr_, 0, 0);};
      {if (in_kernel) next_k_data_pc += 1; else {next_data_pc += 1;}};
    }
}

variable_types:
string
char *

variable_types: length int


decompiled_code:
__int64 __fastcall store_byte(unsigned int a1)
{
__int64 result; // rax
__int64 v2; // rsi
__int64 v3; // rdi

result = (unsigned int)in_kernel;
v2 = a1;
v3 = (unsigned int)next_k_data_pc;
data_modified = 1;
if ( !in_kernel )
v3 = (unsigned int)next_data_pc;
if ( (unsigned int)v3 > 0xFFFFFFF && data_top > (unsigned int)v3 )
{
*(_BYTE *)(data_seg_b + (unsigned int)(v3 - 0x10000000)) = v2;
if ( !(_DWORD)result )
{
LABEL_6:
++next_data_pc;
return result;
}
goto LABEL_11;
}
if ( stack_bot <= (unsigned int)v3 && (int)v3 >= 0 )
{
*(_BYTE *)(stack_seg_b + (unsigned int)(v3 - stack_bot)) = v2;
goto LABEL_10;
}
if ( (unsigned int)v3 > 0x8FFFFFFF && k_data_top > (unsigned int)v3 )
{
*(_BYTE *)(k_data_seg_b + (unsigned int)(v3 + 1879048192)) = v2;
LABEL_10:
if ( !(_DWORD)result )
goto LABEL_6;
LABEL_11:
++next_k_data_pc;
return result;
}
bad_mem_write(v3, v2, 0LL);
result = (unsigned int)in_kernel;
if ( in_kernel )
++next_k_data_pc;
else
++next_data_pc;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(unsigned int a1)
{
__int64 result; // rax
__int64 v2; // rsi
__int64 v3; // rdi

result = (unsigned int)in_kernel;
v2 = a1;
v3 = (unsigned int)next_k_data_pc;
data_modified = 1;
if ( !in_kernel )
v3 = (unsigned int)next_data_pc;
if ( (unsigned int)v3 > 0xFFFFFFF && data_top > (unsigned int)v3 )
{
*(_BYTE *)(data_seg_b + (unsigned int)(v3 - 0x10000000)) = v2;
if ( !(_DWORD)result )
{
LABEL_6:
++next_data_pc;
return result;
}
goto LABEL_11;
}
if ( stack_bot <= (unsigned int)v3 && (int)v3 >= 0 )
{
*(_BYTE *)(stack_seg_b + (unsigned int)(v3 - stack_bot)) = v2;
goto LABEL_10;
}
if ( (unsigned int)v3 > 0x8FFFFFFF && k_data_top > (unsigned int)v3 )
{
*(_BYTE *)(k_data_seg_b + (unsigned int)(v3 + 1879048192)) = v2;
LABEL_10:
if ( !(_DWORD)result )
goto LABEL_6;
LABEL_11:
++next_k_data_pc;
return result;
}
bad_mem_write(v3, v2, 0LL);
result = (unsigned int)in_kernel;
if ( in_kernel )
++next_k_data_pc;
else
++next_data_pc;
return result;
}

original_code:
void
store_byte (int value)
{
  {register mem_addr _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((mem_addr) 0x10000000) && _addr_ < data_top) data_seg_b [_addr_ - ((mem_addr) 0x10000000)] = (unsigned char) (value); else if (_addr_ >= stack_bot && _addr_ < ((mem_addr) 0x80000000)) stack_seg_b [_addr_ - stack_bot] = (unsigned char) (value); else if (_addr_ >= ((mem_addr) 0x90000000) && _addr_ < k_data_top) k_data_seg_b [_addr_ - ((mem_addr) 0x90000000)] = (unsigned char) (value); else bad_mem_write (_addr_, value, 0);};
  {if (in_kernel) next_k_data_pc += 1; else {next_data_pc += 1;}};
}

canonical_original_code:
void store_byte(int value)
{
  {register unsigned int _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((unsigned int) 0x10000000) && _addr_ < data_top) data_seg_b [_addr_ - ((unsigned int) 0x10000000)] = (unsigned char) (value); else if (_addr_ >= stack_bot && _addr_ < ((unsigned int) 0x80000000)) stack_seg_b [_addr_ - stack_bot] = (unsigned char) (value); else if (_addr_ >= ((unsigned int) 0x90000000) && _addr_ < k_data_top) k_data_seg_b [_addr_ - ((unsigned int) 0x90000000)] = (unsigned char) (value); else bad_mem_write (_addr_, value, 0);};
  {if (in_kernel) next_k_data_pc += 1; else {next_data_pc += 1;}};
}


decompiled_code:
__int64 __fastcall store_half(unsigned int a1)
{
__int64 result; // rax
__int64 v3; // rdi

result = (unsigned int)in_kernel;
if ( in_kernel )
{
v3 = (unsigned int)next_k_data_pc;
if ( (next_k_data_pc & 1) == 0 )
goto LABEL_3;
LABEL_17:
store_byte((unsigned __int8)a1);
return store_byte(BYTE1(a1));
}
v3 = (unsigned int)next_data_pc;
if ( (next_data_pc & 1) != 0 )
goto LABEL_17;
LABEL_3:
data_modified = 1;
if ( (unsigned int)v3 <= 0xFFFFFFF || data_top <= (unsigned int)v3 || (v3 & 1) != 0 )
{
if ( stack_bot > (unsigned int)v3 || (int)v3 < 0 || (v3 & 1) != 0 )
{
if ( (unsigned int)v3 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v3 || (v3 & 1) != 0 )
{
bad_mem_write(v3, a1, 1LL);
result = (unsigned int)in_kernel;
}
else
{
*(_WORD *)(k_data_seg_h + 2LL * ((unsigned int)(v3 + 1879048192) >> 1)) = a1;
}
}
else
{
*(_WORD *)(stack_seg_h + 2LL * ((unsigned int)(v3 - stack_bot) >> 1)) = a1;
}
}
else
{
*(_WORD *)(data_seg_h + 2LL * ((unsigned int)(v3 - 0x10000000) >> 1)) = a1;
}
if ( (_DWORD)result )
next_k_data_pc += 2;
else
next_data_pc += 2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(unsigned int a1)
{
__int64 result; // rax
__int64 v3; // rdi

result = (unsigned int)in_kernel;
if ( in_kernel )
{
v3 = (unsigned int)next_k_data_pc;
if ( (next_k_data_pc & 1) == 0 )
goto LABEL_3;
LABEL_17:
func13((unsigned __int8)a1);
return func13(BYTE1(a1));
}
v3 = (unsigned int)next_data_pc;
if ( (next_data_pc & 1) != 0 )
goto LABEL_17;
LABEL_3:
data_modified = 1;
if ( (unsigned int)v3 <= 0xFFFFFFF || data_top <= (unsigned int)v3 || (v3 & 1) != 0 )
{
if ( stack_bot > (unsigned int)v3 || (int)v3 < 0 || (v3 & 1) != 0 )
{
if ( (unsigned int)v3 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v3 || (v3 & 1) != 0 )
{
bad_mem_write(v3, a1, 1LL);
result = (unsigned int)in_kernel;
}
else
{
*(_WORD *)(k_data_seg_h + 2LL * ((unsigned int)(v3 + 1879048192) >> 1)) = a1;
}
}
else
{
*(_WORD *)(stack_seg_h + 2LL * ((unsigned int)(v3 - stack_bot) >> 1)) = a1;
}
}
else
{
*(_WORD *)(data_seg_h + 2LL * ((unsigned int)(v3 - 0x10000000) >> 1)) = a1;
}
if ( (_DWORD)result )
next_k_data_pc += 2;
else
next_data_pc += 2;
return result;
}

original_code:
void
store_half (int value)
{
  if ((in_kernel ? next_k_data_pc : next_data_pc) & 0x1)
    {
      store_byte (value & 0xff);
      store_byte ((value >> 8) & 0xff);
    }
  else
    {
      {register mem_addr _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((mem_addr) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x1)) data_seg_h [(_addr_ - ((mem_addr) 0x10000000)) >> 1] = (unsigned short) (value); else if (_addr_ >= stack_bot && _addr_ < ((mem_addr) 0x80000000) && !(_addr_ & 0x1)) stack_seg_h [(_addr_ - stack_bot) >> 1] = (unsigned short) (value); else if (_addr_ >= ((mem_addr) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x1)) k_data_seg_h [(_addr_ - ((mem_addr) 0x90000000)) >> 1] = (unsigned short) (value); else bad_mem_write (_addr_, value, 0x1);};
      {if (in_kernel) next_k_data_pc += 4 / 2; else {next_data_pc += 4 / 2;}};
    }
}

canonical_original_code:
void store_half(int value)
{
  if ((in_kernel ? next_k_data_pc : next_data_pc) & 0x1)
    {
      store_byte (value & 0xff);
      store_byte ((value >> 8) & 0xff);
    }
  else
    {
      {register unsigned int _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((unsigned int) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x1)) data_seg_h [(_addr_ - ((unsigned int) 0x10000000)) >> 1] = (unsigned short) (value); else if (_addr_ >= stack_bot && _addr_ < ((unsigned int) 0x80000000) && !(_addr_ & 0x1)) stack_seg_h [(_addr_ - stack_bot) >> 1] = (unsigned short) (value); else if (_addr_ >= ((unsigned int) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x1)) k_data_seg_h [(_addr_ - ((unsigned int) 0x90000000)) >> 1] = (unsigned short) (value); else bad_mem_write (_addr_, value, 0x1);};
      {if (in_kernel) next_k_data_pc += 4 / 2; else {next_data_pc += 4 / 2;}};
    }
}


decompiled_code:
__int64 __fastcall store_word(unsigned int a1)
{
__int64 result; // rax
__int64 v3; // rdi

result = (unsigned int)in_kernel;
if ( in_kernel )
{
v3 = (unsigned int)next_k_data_pc;
if ( (next_k_data_pc & 3) == 0 )
goto LABEL_3;
LABEL_17:
store_half((unsigned __int16)a1);
return store_half(HIWORD(a1));
}
v3 = (unsigned int)next_data_pc;
if ( (next_data_pc & 3) != 0 )
goto LABEL_17;
LABEL_3:
data_modified = 1;
if ( (unsigned int)v3 <= 0xFFFFFFF || data_top <= (unsigned int)v3 || (v3 & 3) != 0 )
{
if ( stack_bot > (unsigned int)v3 || (int)v3 < 0 || (v3 & 3) != 0 )
{
if ( (unsigned int)v3 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v3 || (v3 & 3) != 0 )
{
bad_mem_write(v3, a1, 3LL);
result = (unsigned int)in_kernel;
}
else
{
*(_DWORD *)(k_data_seg + 4LL * ((unsigned int)(v3 + 1879048192) >> 2)) = a1;
}
}
else
{
*(_DWORD *)(stack_seg + 4LL * ((unsigned int)(v3 - stack_bot) >> 2)) = a1;
}
}
else
{
*(_DWORD *)(data_seg + 4LL * ((unsigned int)(v3 - 0x10000000) >> 2)) = a1;
}
if ( (_DWORD)result )
next_k_data_pc += 4;
else
next_data_pc += 4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned int a1)
{
__int64 result; // rax
__int64 v3; // rdi

result = (unsigned int)in_kernel;
if ( in_kernel )
{
v3 = (unsigned int)next_k_data_pc;
if ( (next_k_data_pc & 3) == 0 )
goto LABEL_3;
LABEL_17:
func14((unsigned __int16)a1);
return func14(HIWORD(a1));
}
v3 = (unsigned int)next_data_pc;
if ( (next_data_pc & 3) != 0 )
goto LABEL_17;
LABEL_3:
data_modified = 1;
if ( (unsigned int)v3 <= 0xFFFFFFF || data_top <= (unsigned int)v3 || (v3 & 3) != 0 )
{
if ( stack_bot > (unsigned int)v3 || (int)v3 < 0 || (v3 & 3) != 0 )
{
if ( (unsigned int)v3 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v3 || (v3 & 3) != 0 )
{
bad_mem_write(v3, a1, 3LL);
result = (unsigned int)in_kernel;
}
else
{
*(_DWORD *)(k_data_seg + 4LL * ((unsigned int)(v3 + 1879048192) >> 2)) = a1;
}
}
else
{
*(_DWORD *)(stack_seg + 4LL * ((unsigned int)(v3 - stack_bot) >> 2)) = a1;
}
}
else
{
*(_DWORD *)(data_seg + 4LL * ((unsigned int)(v3 - 0x10000000) >> 2)) = a1;
}
if ( (_DWORD)result )
next_k_data_pc += 4;
else
next_data_pc += 4;
return result;
}

original_code:
void
store_word (int value)
{
  if ((in_kernel ? next_k_data_pc : next_data_pc) & 0x3)
    {
      store_half (value & 0xffff);
      store_half ((value >> 16) & 0xffff);
    }
  else
    {
      {register mem_addr _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((mem_addr) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x3)) data_seg [(_addr_ - ((mem_addr) 0x10000000)) >> 2] = (mem_word) (value); else if (_addr_ >= stack_bot && _addr_ < ((mem_addr) 0x80000000) && !(_addr_ & 0x3)) stack_seg [(_addr_ - stack_bot) >> 2] = (mem_word) (value); else if (_addr_ >= ((mem_addr) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x3)) k_data_seg [(_addr_ - ((mem_addr) 0x90000000)) >> 2] = (mem_word) (value); else bad_mem_write (_addr_, value, 0x3);};
      {if (in_kernel) next_k_data_pc += 4; else {next_data_pc += 4;}};
    }
}

canonical_original_code:
void store_word(int value)
{
  if ((in_kernel ? next_k_data_pc : next_data_pc) & 0x3)
    {
      store_half (value & 0xffff);
      store_half ((value >> 16) & 0xffff);
    }
  else
    {
      {register unsigned int _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((unsigned int) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x3)) data_seg [(_addr_ - ((unsigned int) 0x10000000)) >> 2] = (mem_word) (value); else if (_addr_ >= stack_bot && _addr_ < ((unsigned int) 0x80000000) && !(_addr_ & 0x3)) stack_seg [(_addr_ - stack_bot) >> 2] = (mem_word) (value); else if (_addr_ >= ((unsigned int) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x3)) k_data_seg [(_addr_ - ((unsigned int) 0x90000000)) >> 2] = (mem_word) (value); else bad_mem_write (_addr_, value, 0x3);};
      {if (in_kernel) next_k_data_pc += 4; else {next_data_pc += 4;}};
    }
}


decompiled_code:
__int64 __fastcall store_double(unsigned int *a1)
{
__int64 result; // rax
__int64 v3; // rdi
__int64 v4; // rsi
__int64 v5; // rdi
__int64 v6; // rsi

result = (unsigned int)in_kernel;
if ( in_kernel )
{
v3 = (unsigned int)next_k_data_pc;
if ( (next_k_data_pc & 7) == 0 )
goto LABEL_3;
LABEL_25:
store_word(*a1);
return store_word(a1[1]);
}
v3 = (unsigned int)next_data_pc;
if ( (next_data_pc & 7) != 0 )
goto LABEL_25;
LABEL_3:
data_modified = 1;
if ( (unsigned int)v3 <= 0xFFFFFFF || data_top <= (unsigned int)v3 || (v3 & 3) != 0 )
{
v4 = *a1;
if ( stack_bot > (unsigned int)v3 || (int)v3 < 0 || (v3 & 3) != 0 )
{
if ( (unsigned int)v3 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v3 || (v3 & 3) != 0 )
{
bad_mem_write(v3, v4, 3LL);
result = (unsigned int)in_kernel;
}
else
{
*(_DWORD *)(k_data_seg + 4LL * ((unsigned int)(v3 + 1879048192) >> 2)) = v4;
}
}
else
{
*(_DWORD *)(stack_seg + 4LL * ((unsigned int)(v3 - stack_bot) >> 2)) = v4;
}
}
else
{
*(_DWORD *)(data_seg + 4LL * ((unsigned int)(v3 - 0x10000000) >> 2)) = *a1;
}
if ( (_DWORD)result )
{
v5 = (unsigned int)(next_k_data_pc + 4);
next_k_data_pc += 4;
}
else
{
v5 = (unsigned int)(next_data_pc + 4);
next_data_pc += 4;
}
data_modified = 1;
v6 = a1[1];
if ( (unsigned int)v5 <= 0xFFFFFFF || data_top <= (unsigned int)v5 || (v5 & 3) != 0 )
{
if ( stack_bot > (unsigned int)v5 || (int)v5 < 0 || (v5 & 3) != 0 )
{
if ( (unsigned int)v5 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v5 || (v5 & 3) != 0 )
{
bad_mem_write(v5, v6, 3LL);
result = (unsigned int)in_kernel;
}
else
{
*(_DWORD *)(k_data_seg + 4LL * ((unsigned int)(v5 + 1879048192) >> 2)) = v6;
}
}
else
{
*(_DWORD *)(stack_seg + 4LL * ((unsigned int)(v5 - stack_bot) >> 2)) = v6;
}
}
else
{
*(_DWORD *)(data_seg + 4LL * ((unsigned int)(v5 - 0x10000000) >> 2)) = v6;
}
if ( (_DWORD)result )
next_k_data_pc += 4;
else
next_data_pc += 4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned int *a1)
{
__int64 result; // rax
__int64 v3; // rdi
__int64 v4; // rsi
__int64 v5; // rdi
__int64 v6; // rsi

result = (unsigned int)in_kernel;
if ( in_kernel )
{
v3 = (unsigned int)next_k_data_pc;
if ( (next_k_data_pc & 7) == 0 )
goto LABEL_3;
LABEL_25:
func15(*a1);
return func15(a1[1]);
}
v3 = (unsigned int)next_data_pc;
if ( (next_data_pc & 7) != 0 )
goto LABEL_25;
LABEL_3:
data_modified = 1;
if ( (unsigned int)v3 <= 0xFFFFFFF || data_top <= (unsigned int)v3 || (v3 & 3) != 0 )
{
v4 = *a1;
if ( stack_bot > (unsigned int)v3 || (int)v3 < 0 || (v3 & 3) != 0 )
{
if ( (unsigned int)v3 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v3 || (v3 & 3) != 0 )
{
bad_mem_write(v3, v4, 3LL);
result = (unsigned int)in_kernel;
}
else
{
*(_DWORD *)(k_data_seg + 4LL * ((unsigned int)(v3 + 1879048192) >> 2)) = v4;
}
}
else
{
*(_DWORD *)(stack_seg + 4LL * ((unsigned int)(v3 - stack_bot) >> 2)) = v4;
}
}
else
{
*(_DWORD *)(data_seg + 4LL * ((unsigned int)(v3 - 0x10000000) >> 2)) = *a1;
}
if ( (_DWORD)result )
{
v5 = (unsigned int)(next_k_data_pc + 4);
next_k_data_pc += 4;
}
else
{
v5 = (unsigned int)(next_data_pc + 4);
next_data_pc += 4;
}
data_modified = 1;
v6 = a1[1];
if ( (unsigned int)v5 <= 0xFFFFFFF || data_top <= (unsigned int)v5 || (v5 & 3) != 0 )
{
if ( stack_bot > (unsigned int)v5 || (int)v5 < 0 || (v5 & 3) != 0 )
{
if ( (unsigned int)v5 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v5 || (v5 & 3) != 0 )
{
bad_mem_write(v5, v6, 3LL);
result = (unsigned int)in_kernel;
}
else
{
*(_DWORD *)(k_data_seg + 4LL * ((unsigned int)(v5 + 1879048192) >> 2)) = v6;
}
}
else
{
*(_DWORD *)(stack_seg + 4LL * ((unsigned int)(v5 - stack_bot) >> 2)) = v6;
}
}
else
{
*(_DWORD *)(data_seg + 4LL * ((unsigned int)(v5 - 0x10000000) >> 2)) = v6;
}
if ( (_DWORD)result )
next_k_data_pc += 4;
else
next_data_pc += 4;
return result;
}

original_code:
void
store_double (double *value)
{
  if ((in_kernel ? next_k_data_pc : next_data_pc) & 0x7)
    {
      store_word (* ((mem_word *) value));
      store_word (* (((mem_word *) value) + 1));
    }
  else
    {
      {register mem_addr _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((mem_addr) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x3)) data_seg [(_addr_ - ((mem_addr) 0x10000000)) >> 2] = (mem_word) (* ((mem_word *) value)); else if (_addr_ >= stack_bot && _addr_ < ((mem_addr) 0x80000000) && !(_addr_ & 0x3)) stack_seg [(_addr_ - stack_bot) >> 2] = (mem_word) (* ((mem_word *) value)); else if (_addr_ >= ((mem_addr) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x3)) k_data_seg [(_addr_ - ((mem_addr) 0x90000000)) >> 2] = (mem_word) (* ((mem_word *) value)); else bad_mem_write (_addr_, * ((mem_word *) value), 0x3);};
      {if (in_kernel) next_k_data_pc += 4; else {next_data_pc += 4;}};
      {register mem_addr _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((mem_addr) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x3)) data_seg [(_addr_ - ((mem_addr) 0x10000000)) >> 2] = (mem_word) (* (((mem_word *) value) + 1)); else if (_addr_ >= stack_bot && _addr_ < ((mem_addr) 0x80000000) && !(_addr_ & 0x3)) stack_seg [(_addr_ - stack_bot) >> 2] = (mem_word) (* (((mem_word *) value) + 1)); else if (_addr_ >= ((mem_addr) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x3)) k_data_seg [(_addr_ - ((mem_addr) 0x90000000)) >> 2] = (mem_word) (* (((mem_word *) value) + 1)); else bad_mem_write (_addr_, * (((mem_word *) value) + 1), 0x3);};
      {if (in_kernel) next_k_data_pc += 4; else {next_data_pc += 4;}};
    }
}

canonical_original_code:
void store_double(double *value)
{
  if ((in_kernel ? next_k_data_pc : next_data_pc) & 0x7)
    {
      store_word (* ((int *) value));
      store_word (* (((int *) value) + 1));
    }
  else
    {
      {register unsigned int _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((unsigned int) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x3)) data_seg [(_addr_ - ((unsigned int) 0x10000000)) >> 2] = (mem_word) (* ((int *) value)); else if (_addr_ >= stack_bot && _addr_ < ((unsigned int) 0x80000000) && !(_addr_ & 0x3)) stack_seg [(_addr_ - stack_bot) >> 2] = (mem_word) (* ((int *) value)); else if (_addr_ >= ((unsigned int) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x3)) k_data_seg [(_addr_ - ((unsigned int) 0x90000000)) >> 2] = (mem_word) (* ((int *) value)); else bad_mem_write (_addr_, * ((int *) value), 0x3);};
      {if (in_kernel) next_k_data_pc += 4; else {next_data_pc += 4;}};
      {register unsigned int _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((unsigned int) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x3)) data_seg [(_addr_ - ((unsigned int) 0x10000000)) >> 2] = (mem_word) (* (((int *) value) + 1)); else if (_addr_ >= stack_bot && _addr_ < ((unsigned int) 0x80000000) && !(_addr_ & 0x3)) stack_seg [(_addr_ - stack_bot) >> 2] = (mem_word) (* (((int *) value) + 1)); else if (_addr_ >= ((unsigned int) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x3)) k_data_seg [(_addr_ - ((unsigned int) 0x90000000)) >> 2] = (mem_word) (* (((int *) value) + 1)); else bad_mem_write (_addr_, * (((int *) value) + 1), 0x3);};
      {if (in_kernel) next_k_data_pc += 4; else {next_data_pc += 4;}};
    }
}

variable_types:
value
double *


decompiled_code:
__int64 __fastcall store_float(double *a1)
{
__int64 result; // rax
__m128i v2; // xmm0
__int64 v3; // rsi
__int64 v4; // rdi

result = (unsigned int)in_kernel;
v2 = 0LL;
*(float *)v2.m128i_i32 = *a1;
v3 = (unsigned int)_mm_cvtsi128_si32(v2);
if ( in_kernel )
{
v4 = (unsigned int)next_k_data_pc;
if ( (next_k_data_pc & 3) == 0 )
goto LABEL_3;
LABEL_17:
store_half((unsigned __int16)v3);
return store_half(WORD1(v3));
}
v4 = (unsigned int)next_data_pc;
if ( (next_data_pc & 3) != 0 )
goto LABEL_17;
LABEL_3:
data_modified = 1;
if ( (unsigned int)v4 <= 0xFFFFFFF || data_top <= (unsigned int)v4 || (v4 & 3) != 0 )
{
if ( stack_bot > (unsigned int)v4 || (int)v4 < 0 || (v4 & 3) != 0 )
{
if ( (unsigned int)v4 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v4 || (v4 & 3) != 0 )
{
bad_mem_write(v4, v3, 3LL);
result = (unsigned int)in_kernel;
}
else
{
*(_DWORD *)(k_data_seg + 4LL * ((unsigned int)(v4 + 1879048192) >> 2)) = v3;
}
}
else
{
*(_DWORD *)(stack_seg + 4LL * ((unsigned int)(v4 - stack_bot) >> 2)) = v3;
}
}
else
{
*(_DWORD *)(data_seg + 4LL * ((unsigned int)(v4 - 0x10000000) >> 2)) = v3;
}
if ( (_DWORD)result )
next_k_data_pc += 4;
else
next_data_pc += 4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(double *a1)
{
__int64 result; // rax
__m128i v2; // xmm0
__int64 v3; // rsi
__int64 v4; // rdi

result = (unsigned int)in_kernel;
v2 = 0LL;
*(float *)v2.m128i_i32 = *a1;
v3 = (unsigned int)_mm_cvtsi128_si32(v2);
if ( in_kernel )
{
v4 = (unsigned int)next_k_data_pc;
if ( (next_k_data_pc & 3) == 0 )
goto LABEL_3;
LABEL_17:
func14((unsigned __int16)v3);
return func14(WORD1(v3));
}
v4 = (unsigned int)next_data_pc;
if ( (next_data_pc & 3) != 0 )
goto LABEL_17;
LABEL_3:
data_modified = 1;
if ( (unsigned int)v4 <= 0xFFFFFFF || data_top <= (unsigned int)v4 || (v4 & 3) != 0 )
{
if ( stack_bot > (unsigned int)v4 || (int)v4 < 0 || (v4 & 3) != 0 )
{
if ( (unsigned int)v4 <= 0x8FFFFFFF || k_data_top <= (unsigned int)v4 || (v4 & 3) != 0 )
{
bad_mem_write(v4, v3, 3LL);
result = (unsigned int)in_kernel;
}
else
{
*(_DWORD *)(k_data_seg + 4LL * ((unsigned int)(v4 + 1879048192) >> 2)) = v3;
}
}
else
{
*(_DWORD *)(stack_seg + 4LL * ((unsigned int)(v4 - stack_bot) >> 2)) = v3;
}
}
else
{
*(_DWORD *)(data_seg + 4LL * ((unsigned int)(v4 - 0x10000000) >> 2)) = v3;
}
if ( (_DWORD)result )
next_k_data_pc += 4;
else
next_data_pc += 4;
return result;
}

original_code:
void
store_float (double *value)
{
  float val = (float)*value;
  float *vp = &val;
  if ((in_kernel ? next_k_data_pc : next_data_pc) & 0x3)
    {
      store_half (*(mem_word *) vp & 0xffff);
      store_half ((*(mem_word *) vp >> 16) & 0xffff);
    }
  else
    {
      {register mem_addr _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((mem_addr) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x3)) data_seg [(_addr_ - ((mem_addr) 0x10000000)) >> 2] = (mem_word) (*((mem_word *) vp)); else if (_addr_ >= stack_bot && _addr_ < ((mem_addr) 0x80000000) && !(_addr_ & 0x3)) stack_seg [(_addr_ - stack_bot) >> 2] = (mem_word) (*((mem_word *) vp)); else if (_addr_ >= ((mem_addr) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x3)) k_data_seg [(_addr_ - ((mem_addr) 0x90000000)) >> 2] = (mem_word) (*((mem_word *) vp)); else bad_mem_write (_addr_, *((mem_word *) vp), 0x3);};
      {if (in_kernel) next_k_data_pc += 4; else {next_data_pc += 4;}};
    }
}

canonical_original_code:
void store_float(double *value)
{
  float val = (float)*value;
  float *vp = &val;
  if ((in_kernel ? next_k_data_pc : next_data_pc) & 0x3)
    {
      store_half (*(int *) vp & 0xffff);
      store_half ((*(int *) vp >> 16) & 0xffff);
    }
  else
    {
      {register unsigned int _addr_ = (mem_addr) ((in_kernel ? next_k_data_pc : next_data_pc)); data_modified = 1; if (_addr_ >= ((unsigned int) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x3)) data_seg [(_addr_ - ((unsigned int) 0x10000000)) >> 2] = (mem_word) (*((int *) vp)); else if (_addr_ >= stack_bot && _addr_ < ((unsigned int) 0x80000000) && !(_addr_ & 0x3)) stack_seg [(_addr_ - stack_bot) >> 2] = (mem_word) (*((int *) vp)); else if (_addr_ >= ((unsigned int) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x3)) k_data_seg [(_addr_ - ((unsigned int) 0x90000000)) >> 2] = (mem_word) (*((int *) vp)); else bad_mem_write (_addr_, *((int *) vp), 0x3);};
      {if (in_kernel) next_k_data_pc += 4; else {next_data_pc += 4;}};
    }
}

variable_types: val float

variable_types:
vp
float *


decompiled_code:
void __fastcall resolve_a_label_sub(__int64 a1, __int16 *a2, const char *a3)
{
unsigned int v3; // er12
__int64 v4; // rax
__int16 *v5; // rbx
_QWORD *v6; // rax
__int64 v7; // rax
__int64 v8; // rdi
int v9; // eax
__int64 v10; // rdx
int v11; // ebp
int v12; // eax
const char *v13; // rdx
int v14; // ebp
__int64 v15; // rsi
int v16; // eax
__int64 v17; // rdi
int v18; // edi
__int64 v19; // rax
__int64 v20; // rcx

v3 = (unsigned int)a3;
if ( a2 )
{
v4 = *((_QWORD *)a2 + 2);
v5 = a2;
if ( *(_WORD *)(v4 + 18) )
{
a3 = (const char *)(unsigned int)-(int)a3;
*(_DWORD *)v4 = (_DWORD)a3;
}
v6 = *(_QWORD **)(v4 + 8);
if ( !v6 || v6[1] )
{
if ( (unsigned int)opcode_is_branch((unsigned int)*a2) )
{
v7 = eval_imm_expr(*((_QWORD *)a2 + 2));
v8 = *((_QWORD *)a2 + 2);
if ( (v7 & 0x8000) != 0 )
v9 = eval_imm_expr(v8) | 0xFFFF0000;
else
v9 = eval_imm_expr(v8);
v11 = (unsigned __int16)(v9 >> 2);
if ( !delayed_branches )
{
LABEL_13:
if ( (unsigned int)opcode_is_jump((unsigned int)*v5) )
{
LABEL_14:
*((_DWORD *)v5 + 1) = v11;
LABEL_15:
*((_DWORD *)v5 + 2) = inst_encode(v5);
return;
}
LABEL_20:
v5[3] = v11;
goto LABEL_15;
}
--v11;
}
else
{
if ( (unsigned int)opcode_is_jump((unsigned int)*a2) )
{
v14 = eval_imm_expr(*((_QWORD *)a2 + 2));
if ( ((v3 ^ v14) & 0xF0000000) != 0 )
error((int)"Target of jump differs in high-order 4 bits from instruction pc 0x%x\n", v3, v13);
v11 = (v14 >> 2) & 0x3FFFFFF;
if ( (unsigned int)opcode_is_jump((unsigned int)*a2) )
goto LABEL_14;
goto LABEL_20;
}
v16 = opcode_is_load_store((unsigned int)*a2);
v17 = *((_QWORD *)a2 + 2);
if ( v16 )
{
v11 = eval_imm_expr(v17);
if ( (v11 & 0x8000) != 0 )
{
v18 = v3 - 4;
if ( v3 - 4 <= 0x3FFFFF || text_top <= (unsigned int)v18 || (v18 & 3) != 0 )
{
if ( v18 >= 0 || k_text_top <= (unsigned int)v18 || (v18 & 3) != 0 )
{
v19 = bad_text_read();
}
else
{
v10 = k_text_seg;
v19 = *(_QWORD *)(k_text_seg + 8LL * ((v3 + 2147483644) >> 2));
}
}
else
{
v10 = text_seg;
v19 = *(_QWORD *)(text_seg + 8LL * ((v3 - 4194308) >> 2));
}
if ( v19 )
{
if ( *(_WORD *)v19 == 354 )
{
v10 = *(_QWORD *)(v19 + 16);
v20 = *((_QWORD *)a2 + 2);
a2 = *(__int16 **)(v10 + 8);
if ( *(__int16 **)(v20 + 8) == a2 && !*(_WORD *)(v19 + 6) )
*(_DWORD *)v10 += 0x10000;
}
}
}
}
else
{
v11 = eval_imm_expr(v17);
}
}
HIWORD(v12) = HIWORD(v11);
LOWORD(v12) = 0;
if ( ((v12 + 0x10000) & 0xFFFE0000) != 0 )
{
error((int)"Immediate value is too large for field: ", (int)a2, (const char *)v10);
print_inst(v3);
}
goto LABEL_13;
}
error((int)"Resolving undefined symbol: %s\n", *v6, a3);
}
else
{
data_modified = 1;
v15 = *(_QWORD *)(a1 + 8);
if ( (unsigned int)a3 <= 0xFFFFFFF || data_top <= (unsigned int)a3 || ((unsigned __int8)a3 & 3) != 0 )
{
if ( stack_bot > (unsigned int)a3 || (int)a3 < 0 || ((unsigned __int8)a3 & 3) != 0 )
{
if ( (unsigned int)a3 <= 0x8FFFFFFF || k_data_top <= (unsigned int)a3 || ((unsigned __int8)a3 & 3) != 0 )
bad_mem_write((unsigned int)a3, v15, 3LL);
else
*(_DWORD *)&k_data_seg[4 * ((unsigned int)((_DWORD)a3 + 1879048192) >> 2)] = v15;
}
else
{
*(_DWORD *)(stack_seg + 4LL * ((unsigned int)((_DWORD)a3 - stack_bot) >> 2)) = v15;
}
}
else
{
*(_DWORD *)(data_seg + 4LL * ((unsigned int)((_DWORD)a3 - 0x10000000) >> 2)) = v15;
}
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, __int16 *a2, const char *a3)
{
unsigned int v3; // er12
__int64 v4; // rax
__int16 *v5; // rbx
_QWORD *v6; // rax
__int64 v7; // rax
__int64 v8; // rdi
int v9; // eax
__int64 v10; // rdx
int v11; // ebp
int v12; // eax
const char *v13; // rdx
int v14; // ebp
__int64 v15; // rsi
int v16; // eax
__int64 v17; // rdi
int v18; // edi
__int64 v19; // rax
__int64 v20; // rcx

v3 = (unsigned int)a3;
if ( a2 )
{
v4 = *((_QWORD *)a2 + 2);
v5 = a2;
if ( *(_WORD *)(v4 + 18) )
{
a3 = (const char *)(unsigned int)-(int)a3;
*(_DWORD *)v4 = (_DWORD)a3;
}
v6 = *(_QWORD **)(v4 + 8);
if ( !v6 || v6[1] )
{
if ( (unsigned int)opcode_is_branch((unsigned int)*a2) )
{
v7 = eval_imm_expr(*((_QWORD *)a2 + 2));
v8 = *((_QWORD *)a2 + 2);
if ( (v7 & 0x8000) != 0 )
v9 = eval_imm_expr(v8) | 0xFFFF0000;
else
v9 = eval_imm_expr(v8);
v11 = (unsigned __int16)(v9 >> 2);
if ( !delayed_branches )
{
LABEL_13:
if ( (unsigned int)opcode_is_jump((unsigned int)*v5) )
{
LABEL_14:
*((_DWORD *)v5 + 1) = v11;
LABEL_15:
*((_DWORD *)v5 + 2) = inst_encode(v5);
return;
}
LABEL_20:
v5[3] = v11;
goto LABEL_15;
}
--v11;
}
else
{
if ( (unsigned int)opcode_is_jump((unsigned int)*a2) )
{
v14 = eval_imm_expr(*((_QWORD *)a2 + 2));
if ( ((v3 ^ v14) & 0xF0000000) != 0 )
error((int)"Target of jump differs in high-order 4 bits from instruction pc 0x%x\n", v3, v13);
v11 = (v14 >> 2) & 0x3FFFFFF;
if ( (unsigned int)opcode_is_jump((unsigned int)*a2) )
goto LABEL_14;
goto LABEL_20;
}
v16 = opcode_is_load_store((unsigned int)*a2);
v17 = *((_QWORD *)a2 + 2);
if ( v16 )
{
v11 = eval_imm_expr(v17);
if ( (v11 & 0x8000) != 0 )
{
v18 = v3 - 4;
if ( v3 - 4 <= 0x3FFFFF || text_top <= (unsigned int)v18 || (v18 & 3) != 0 )
{
if ( v18 >= 0 || k_text_top <= (unsigned int)v18 || (v18 & 3) != 0 )
{
v19 = bad_text_read();
}
else
{
v10 = k_text_seg;
v19 = *(_QWORD *)(k_text_seg + 8LL * ((v3 + 2147483644) >> 2));
}
}
else
{
v10 = text_seg;
v19 = *(_QWORD *)(text_seg + 8LL * ((v3 - 4194308) >> 2));
}
if ( v19 )
{
if ( *(_WORD *)v19 == 354 )
{
v10 = *(_QWORD *)(v19 + 16);
v20 = *((_QWORD *)a2 + 2);
a2 = *(__int16 **)(v10 + 8);
if ( *(__int16 **)(v20 + 8) == a2 && !*(_WORD *)(v19 + 6) )
*(_DWORD *)v10 += 0x10000;
}
}
}
}
else
{
v11 = eval_imm_expr(v17);
}
}
HIWORD(v12) = HIWORD(v11);
LOWORD(v12) = 0;
if ( ((v12 + 0x10000) & 0xFFFE0000) != 0 )
{
error((int)"Immediate value is too large for field: ", (int)a2, (const char *)v10);
print_inst(v3);
}
goto LABEL_13;
}
error((int)"Resolving undefined symbol: %s\n", *v6, a3);
}
else
{
data_modified = 1;
v15 = *(_QWORD *)(a1 + 8);
if ( (unsigned int)a3 <= 0xFFFFFFF || data_top <= (unsigned int)a3 || ((unsigned __int8)a3 & 3) != 0 )
{
if ( stack_bot > (unsigned int)a3 || (int)a3 < 0 || ((unsigned __int8)a3 & 3) != 0 )
{
if ( (unsigned int)a3 <= 0x8FFFFFFF || k_data_top <= (unsigned int)a3 || ((unsigned __int8)a3 & 3) != 0 )
bad_mem_write((unsigned int)a3, v15, 3LL);
else
*(_DWORD *)&k_data_seg[4 * ((unsigned int)((_DWORD)a3 + 1879048192) >> 2)] = v15;
}
else
{
*(_DWORD *)(stack_seg + 4LL * ((unsigned int)((_DWORD)a3 - stack_bot) >> 2)) = v15;
}
}
else
{
*(_DWORD *)(data_seg + 4LL * ((unsigned int)((_DWORD)a3 - 0x10000000) >> 2)) = v15;
}
}
}

original_code:
static void
resolve_a_label_sub (label *sym, instruction *inst, mem_addr pc)
{
  if (inst == ((void *)0))
    {
      {register mem_addr _addr_ = (mem_addr) (pc); data_modified = 1; if (_addr_ >= ((mem_addr) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x3)) data_seg [(_addr_ - ((mem_addr) 0x10000000)) >> 2] = (mem_word) (sym->addr); else if (_addr_ >= stack_bot && _addr_ < ((mem_addr) 0x80000000) && !(_addr_ & 0x3)) stack_seg [(_addr_ - stack_bot) >> 2] = (mem_word) (sym->addr); else if (_addr_ >= ((mem_addr) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x3)) k_data_seg [(_addr_ - ((mem_addr) 0x90000000)) >> 2] = (mem_word) (sym->addr); else bad_mem_write (_addr_, sym->addr, 0x3);};
    }
  else
    {
      if ((inst)->expr->pc_relative)
 (inst)->expr->offset = 0 - pc;
      if ((inst)->expr->symbol == ((void *)0)
   || (((inst)->expr->symbol)->addr != 0))
 {
   int32 value;
   int32 field_mask;
   if (opcode_is_branch ((inst)->opcode))
     {
       int val;
       val = (((eval_imm_expr ((inst)->expr)) & 0x8000) ? ((eval_imm_expr ((inst)->expr)) | 0xffff0000) : (eval_imm_expr ((inst)->expr)));
       val = (val >> 2) & 0xffff;
       if (delayed_branches)
  val -= 1;
       value = val;
       field_mask = 0xffff;
     }
   else if (opcode_is_jump ((inst)->opcode))
     {
       value = eval_imm_expr ((inst)->expr);
    if ((value & 0xf0000000) != (pc & 0xf0000000))
    {
     error ("Target of jump differs in high-order 4 bits from instruction pc 0x%x\n", pc);
    }
       value = (value & 0x0fffffff) >> 2;
       field_mask = 0xffffffff;
     }
   else if (opcode_is_load_store ((inst)->opcode))
     {
       value = eval_imm_expr ((inst)->expr);
       field_mask = 0xffff;
       if (value & 0x8000)
  {
    instruction* prev_inst;
    {register mem_addr _addr_ = (mem_addr) (pc - 4); if (_addr_ >= ((mem_addr) 0x400000) && _addr_ < text_top && !(_addr_ & 0x3)) prev_inst = text_seg [(_addr_ - ((mem_addr) 0x400000)) >> 2]; else if (_addr_ >= ((mem_addr) 0x80000000) && _addr_ < k_text_top && !(_addr_ & 0x3)) prev_inst = k_text_seg [(_addr_ - ((mem_addr) 0x80000000)) >> 2]; else prev_inst = bad_text_read (_addr_);};
    if (prev_inst != ((void *)0)
        && (prev_inst)->opcode == 354
        && (inst)->expr->symbol == (prev_inst)->expr->symbol
        && (prev_inst)->r_t.r_i.r_i.imm == 0)
      {
        (prev_inst)->expr->offset += 0x10000;
      }
  }
     }
   else
     {
       value = eval_imm_expr ((inst)->expr);
       field_mask = 0xffff;
     }
   if ((value & ~field_mask) != 0 && (value & ~field_mask) != 0xffff0000)
     {
       error ("Immediate value is too large for field: ");
       print_inst (pc);
     }
   if (opcode_is_jump ((inst)->opcode))
     (inst)->r_t.target = (mem_addr)(value);
   else
     (inst)->r_t.r_i.r_i.imm = (short)(value);
   (inst)->encoding = inst_encode (inst);
 }
      else
 error ("Resolving undefined symbol: %s\n",
        ((inst)->expr->symbol == ((void *)0)) ? "" : (inst)->expr->symbol->name);
    }
}

canonical_original_code:
static void resolve_a_label_sub(struct lab *sym, struct inst_s *inst, unsigned int pc)
{
  if (inst == ((void *)0))
    {
      {register unsigned int _addr_ = (mem_addr) (pc); data_modified = 1; if (_addr_ >= ((unsigned int) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x3)) data_seg [(_addr_ - ((unsigned int) 0x10000000)) >> 2] = (mem_word) (sym->addr); else if (_addr_ >= stack_bot && _addr_ < ((unsigned int) 0x80000000) && !(_addr_ & 0x3)) stack_seg [(_addr_ - stack_bot) >> 2] = (mem_word) (sym->addr); else if (_addr_ >= ((unsigned int) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x3)) k_data_seg [(_addr_ - ((unsigned int) 0x90000000)) >> 2] = (mem_word) (sym->addr); else bad_mem_write (_addr_, sym->addr, 0x3);};
    }
  else
    {
      if ((inst)->expr->pc_relative)
 (inst)->expr->offset = 0 - pc;
      if ((inst)->expr->symbol == ((void *)0)
   || (((inst)->expr->symbol)->addr != 0))
 {
   int value;
   int field_mask;
   if (opcode_is_branch ((inst)->opcode))
     {
       int val;
       val = (((eval_imm_expr ((inst)->expr)) & 0x8000) ? ((eval_imm_expr ((inst)->expr)) | 0xffff0000) : (eval_imm_expr ((inst)->expr)));
       val = (val >> 2) & 0xffff;
       if (delayed_branches)
  val -= 1;
       value = val;
       field_mask = 0xffff;
     }
   else if (opcode_is_jump ((inst)->opcode))
     {
       value = eval_imm_expr ((inst)->expr);
    if ((value & 0xf0000000) != (pc & 0xf0000000))
    {
     error ("Target of jump differs in high-order 4 bits from instruction pc 0x%x\n", pc);
    }
       value = (value & 0x0fffffff) >> 2;
       field_mask = 0xffffffff;
     }
   else if (opcode_is_load_store ((inst)->opcode))
     {
       value = eval_imm_expr ((inst)->expr);
       field_mask = 0xffff;
       if (value & 0x8000)
  {
    struct inst_s *prev_inst;
    {register unsigned int _addr_ = (mem_addr) (pc - 4); if (_addr_ >= ((unsigned int) 0x400000) && _addr_ < text_top && !(_addr_ & 0x3)) prev_inst = text_seg [(_addr_ - ((unsigned int) 0x400000)) >> 2]; else if (_addr_ >= ((unsigned int) 0x80000000) && _addr_ < k_text_top && !(_addr_ & 0x3)) prev_inst = k_text_seg [(_addr_ - ((unsigned int) 0x80000000)) >> 2]; else prev_inst = bad_text_read (_addr_);};
    if (prev_inst != ((void *)0)
        && (prev_inst)->opcode == 354
        && (inst)->expr->symbol == (prev_inst)->expr->symbol
        && (prev_inst)->r_t.r_i.r_i.imm == 0)
      {
        (prev_inst)->expr->offset += 0x10000;
      }
  }
     }
   else
     {
       value = eval_imm_expr ((inst)->expr);
       field_mask = 0xffff;
     }
   if ((value & ~field_mask) != 0 && (value & ~field_mask) != 0xffff0000)
     {
       error ("Immediate value is too large for field: ");
       print_inst (pc);
     }
   if (opcode_is_jump ((inst)->opcode))
     (inst)->r_t.target = (mem_addr)(value);
   else
     (inst)->r_t.r_i.r_i.imm = (short)(value);
   (inst)->encoding = inst_encode (inst);
 }
      else
 error ("Resolving undefined symbol: %s\n",
        ((inst)->expr->symbol == ((void *)0)) ? "" : (inst)->expr->symbol->name);
    }
}

variable_types:
inst
struct inst_s *

variable_types:
pc
unsigned int

variable_types: val int

variable_types: struct inst_s { short opcode; union { struct { unsigned char rs; unsigned char rt; union { short imm; struct { unsigned char rd; unsigned char shamt; } r; } r_i; } r_i; unsigned int target; } r_t; unsigned int encoding; struct immexpr { int offset; struct lab { char *name; long addr; unsigned int global_flag; unsigned int gp_flag; unsigned int const_flag; struct lab *next; struct lab *next_local; struct lab_use { struct inst_s *inst; unsigned int addr; struct lab_use *next; } *uses; } *symbol; short bits; short pc_relative; } *expr; char *source_line; } *


decompiled_code:
void initialize_symbol_table()
{
__int64 *v0; // rbp
__int64 v1; // rbx
void *v2; // rdi

v0 = label_hash_table;
do
{
v1 = *v0;
while ( v1 )
{
free(*(void **)v1);
v2 = (void *)v1;
v1 = *(_QWORD *)(v1 + 24);
free(v2);
}
*v0++ = 0LL;
}
while ( v0 != &local_labels );
local_labels = 0LL;
}

canonical_decompiled_code:
void func2()
{
__int64 *v0; // rbp
__int64 v1; // rbx
void *v2; // rdi

v0 = label_hash_table;
do
{
v1 = *v0;
while ( v1 )
{
free(*(void **)v1);
v2 = (void *)v1;
v1 = *(_QWORD *)(v1 + 24);
free(v2);
}
*v0++ = 0LL;
}
while ( v0 != &local_labels );
local_labels = 0LL;
}

original_code:
void
initialize_symbol_table (void)
{
  int i;
  for (i = 0; i < 8191; i ++)
  {
    label *x, *n;
    for (x = label_hash_table [i]; x != ((void *)0); x = n)
    {
      free (x->name);
      n = x->next;
      free (x);
    }
    label_hash_table [i] = ((void *)0);
  }
  local_labels = ((void *)0);
}

canonical_original_code:
void initialize_symbol_table()
{
  int i;
  for (i = 0; i < 8191; i ++)
  {
    struct lab *x; struct lab *n;
    for (x = label_hash_table [i]; x != ((void *)0); x = n)
    {
      free (x->name);
      n = x->next;
      free (x);
    }
    label_hash_table [i] = ((void *)0);
  }
  local_labels = ((void *)0);
}

variable_types: i int


decompiled_code:
__int64 __fastcall label_is_defined(char *a1)
{
int v2; // [rsp+4h] [rbp-14h] BYREF
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

get_hash(a1, &v2, &v3);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1)
{
int v2; // [rsp+4h] [rbp-14h] BYREF
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

func0(a1, &v2, &v3);
return v3;
}

original_code:
label *
label_is_defined (char *name)
{
  int hi;
  label *entry;
  get_hash (name, &hi, &entry);
  return (entry);
}

canonical_original_code:
struct lab *label_is_defined(char *name)
{
  int hi;
  struct lab *entry;
  get_hash (name, &hi, &entry);
  return (entry);
}

variable_types: hi int

return_type: struct lab { char *name; long addr; unsigned int global_flag; unsigned int gp_flag; unsigned int const_flag; struct lab *next; struct lab *next_local; struct lab_use { struct inst_s { short opcode; union { struct { unsigned char rs; unsigned char rt; union { short imm; struct { unsigned char rd; unsigned char shamt; } r; } r_i; } r_i; unsigned int target; } r_t; unsigned int encoding; struct immexpr { int offset; struct lab *symbol; short bits; short pc_relative; } *expr; char *source_line; } *inst; unsigned int addr; struct lab_use *next; } *uses; } *


decompiled_code:
__int64 __fastcall lookup_label(char *a1)
{
__int64 v2; // r12
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rdx
int v6; // [rsp+4h] [rbp-24h] BYREF
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

get_hash(a1, &v6, v7);
if ( v7[0] )
return v7[0];
v2 = xmalloc(48LL);
v3 = str_copy(a1);
*(_BYTE *)(v2 + 16) &= 0xF8u;
*(_QWORD *)v2 = v3;
v4 = v6;
*(_QWORD *)(v2 + 8) = 0LL;
v5 = label_hash_table[v4];
*(_QWORD *)(v2 + 40) = 0LL;
*(_QWORD *)(v2 + 24) = v5;
label_hash_table[v4] = v2;
return v2;
}

original_code:
label *
lookup_label (char *name)
{
  int hi;
  label *entry, *lab;
  get_hash (name, &hi, &entry);
  if (entry != ((void *)0))
    return (entry);
  lab = (label *) xmalloc (sizeof (label));
  lab->name = str_copy (name);
  lab->addr = 0;
  lab->global_flag = 0;
  lab->const_flag = 0;
  lab->gp_flag = 0;
  lab->uses = ((void *)0);
  lab->next = label_hash_table [hi];
  label_hash_table [hi] = lab;
  return lab;
}

canonical_original_code:
struct lab *lookup_label(char *name)
{
  int hi;
  struct lab *entry; struct lab *lab;
  get_hash (name, &hi, &entry);
  if (entry != ((void *)0))
    return (entry);
  lab = (struct lab *) xmalloc (sizeof (label));
  lab->name = str_copy (name);
  lab->addr = 0;
  lab->global_flag = 0;
  lab->const_flag = 0;
  lab->gp_flag = 0;
  lab->uses = ((void *)0);
  lab->next = label_hash_table [hi];
  label_hash_table [hi] = lab;
  return lab;
}


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

result = lookup_label(a1);
*(_BYTE *)(result + 16) |= 1u;
return result;
}

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

result = func4(a1);
*(_BYTE *)(result + 16) |= 1u;
return result;
}

original_code:
label *
make_label_global (char *name)
{
  label *l = lookup_label (name);
  l->global_flag = 1;
  return (l);
}

canonical_original_code:
struct lab *make_label_global(char *name)
{
  struct lab *l = lookup_label (name);
  l->global_flag = 1;
  return (l);
}


decompiled_code:
__int64 __fastcall record_inst_uses_symbol(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

v2 = xmalloc(24LL);
if ( data_dir )
{
*(_QWORD *)v2 = copy_inst(a1);
*(_DWORD *)(v2 + 8) = current_data_pc();
}
else
{
*(_QWORD *)v2 = a1;
*(_DWORD *)(v2 + 8) = current_text_pc();
}
result = *(_QWORD *)(a2 + 40);
*(_QWORD *)(v2 + 16) = result;
*(_QWORD *)(a2 + 40) = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

v2 = xmalloc(24LL);
if ( data_dir )
{
*(_QWORD *)v2 = copy_inst(a1);
*(_DWORD *)(v2 + 8) = current_data_pc();
}
else
{
*(_QWORD *)v2 = a1;
*(_DWORD *)(v2 + 8) = current_text_pc();
}
result = *(_QWORD *)(a2 + 40);
*(_QWORD *)(v2 + 16) = result;
*(_QWORD *)(a2 + 40) = v2;
return result;
}

original_code:
void
record_inst_uses_symbol (instruction *inst, label *sym)
{
  label_use *u = (label_use *) xmalloc (sizeof (label_use));
  if (data_dir)
    {
      u->inst = copy_inst (inst);
      u->addr = current_data_pc ();
    }
  else
    {
      u->inst = inst;
      u->addr = current_text_pc ();
    }
  u->next = sym->uses;
  sym->uses = u;
}

canonical_original_code:
void record_inst_uses_symbol(struct inst_s *inst, struct lab *sym)
{
  struct lab_use *u = (label_use *) xmalloc (sizeof (label_use));
  if (data_dir)
    {
      u->inst = copy_inst (inst);
      u->addr = current_data_pc ();
    }
  else
    {
      u->inst = inst;
      u->addr = current_text_pc ();
    }
  u->next = sym->uses;
  sym->uses = u;
}

variable_types:
sym
struct lab *

variable_types: struct lab_use { struct inst_s { short opcode; union { struct { unsigned char rs; unsigned char rt; union { short imm; struct { unsigned char rd; unsigned char shamt; } r; } r_i; } r_i; unsigned int target; } r_t; unsigned int encoding; struct immexpr { int offset; struct lab { char *name; long addr; unsigned int global_flag; unsigned int gp_flag; unsigned int const_flag; struct lab *next; struct lab *next_local; struct lab_use *uses; } *symbol; short bits; short pc_relative; } *expr; char *source_line; } *inst; unsigned int addr; struct lab_use *next; } *


decompiled_code:
__int64 __fastcall record_data_uses_symbol(int a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdx

result = xmalloc(24LL);
v3 = *(_QWORD *)(a2 + 40);
*(_QWORD *)result = 0LL;
*(_DWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = v3;
*(_QWORD *)(a2 + 40) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdx

result = xmalloc(24LL);
v3 = *(_QWORD *)(a2 + 40);
*(_QWORD *)result = 0LL;
*(_DWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = v3;
*(_QWORD *)(a2 + 40) = result;
return result;
}

original_code:
void
record_data_uses_symbol (mem_addr location, label *sym)
{
  label_use *u = (label_use *) xmalloc (sizeof (label_use));
  u->inst = ((void *)0);
  u->addr = location;
  u->next = sym->uses;
  sym->uses = u;
}

canonical_original_code:
void record_data_uses_symbol(unsigned int location, struct lab *sym)
{
  struct lab_use *u = (label_use *) xmalloc (sizeof (label_use));
  u->inst = ((void *)0);
  u->addr = location;
  u->next = sym->uses;
  sym->uses = u;
}

variable_types:
location
unsigned int


decompiled_code:
void __fastcall resolve_label_uses(__int64 a1)
{
_QWORD *v2; // rbp
__int16 *v3; // rdi
unsigned int v4; // er12
__int64 v5; // rsi
_QWORD *v6; // rbx
char *v7; // rbx
_DWORD *v8; // rbx

v2 = *(_QWORD **)(a1 + 40);
if ( v2 )
{
while ( 1 )
{
resolve_a_label_sub(a1, (__int16 *)*v2, (const char *)*((unsigned int *)v2 + 2));
v3 = (__int16 *)*v2;
if ( *v2 )
{
v4 = *((_DWORD *)v2 + 2);
if ( v4 > 0xFFFFFFF && v4 < stack_bot )
{
data_modified = 1;
if ( v4 >= data_top || (v4 & 3) != 0 )
{
if ( v4 <= 0x8FFFFFFF || v4 >= k_data_top || (v4 & 3) != 0 )
{
v5 = (unsigned int)inst_encode(v3);
bad_mem_write(v4, v5, 3LL);
}
else
{
v7 = &k_data_seg[(v4 + 1879048192) & 0xFFFFFFFC];
*(_DWORD *)v7 = inst_encode(v3);
}
}
else
{
v8 = (_DWORD *)(data_seg + 4LL * ((v4 - 0x10000000) >> 2));
*v8 = inst_encode(v3);
}
free_inst(*v2);
}
}
v6 = (_QWORD *)v2[2];
free(v2);
if ( !v6 )
break;
v2 = v6;
}
}
*(_QWORD *)(a1 + 40) = 0LL;
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1)
{
_QWORD *v2; // rbp
__int16 *v3; // rdi
unsigned int v4; // er12
__int64 v5; // rsi
_QWORD *v6; // rbx
char *v7; // rbx
_DWORD *v8; // rbx

v2 = *(_QWORD **)(a1 + 40);
if ( v2 )
{
while ( 1 )
{
func1(a1, (__int16 *)*v2, (const char *)*((unsigned int *)v2 + 2));
v3 = (__int16 *)*v2;
if ( *v2 )
{
v4 = *((_DWORD *)v2 + 2);
if ( v4 > 0xFFFFFFF && v4 < stack_bot )
{
data_modified = 1;
if ( v4 >= data_top || (v4 & 3) != 0 )
{
if ( v4 <= 0x8FFFFFFF || v4 >= k_data_top || (v4 & 3) != 0 )
{
v5 = (unsigned int)inst_encode(v3);
bad_mem_write(v4, v5, 3LL);
}
else
{
v7 = &k_data_seg[(v4 + 1879048192) & 0xFFFFFFFC];
*(_DWORD *)v7 = inst_encode(v3);
}
}
else
{
v8 = (_DWORD *)(data_seg + 4LL * ((v4 - 0x10000000) >> 2));
*v8 = inst_encode(v3);
}
free_inst(*v2);
}
}
v6 = (_QWORD *)v2[2];
free(v2);
if ( !v6 )
break;
v2 = v6;
}
}
*(_QWORD *)(a1 + 40) = 0LL;
}

original_code:
void
resolve_label_uses (label *sym)
{
  label_use *use;
  label_use *next_use;
  for (use = sym->uses; use != ((void *)0); use = next_use)
    {
      resolve_a_label_sub (sym, use->inst, use->addr);
      if (use->inst != ((void *)0) && use->addr >= ((mem_addr) 0x10000000) && use->addr < stack_bot)
 {
   {register mem_addr _addr_ = (mem_addr) (use->addr); data_modified = 1; if (_addr_ >= ((mem_addr) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x3)) data_seg [(_addr_ - ((mem_addr) 0x10000000)) >> 2] = (mem_word) (inst_encode (use->inst)); else if (_addr_ >= stack_bot && _addr_ < ((mem_addr) 0x80000000) && !(_addr_ & 0x3)) stack_seg [(_addr_ - stack_bot) >> 2] = (mem_word) (inst_encode (use->inst)); else if (_addr_ >= ((mem_addr) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x3)) k_data_seg [(_addr_ - ((mem_addr) 0x90000000)) >> 2] = (mem_word) (inst_encode (use->inst)); else bad_mem_write (_addr_, inst_encode (use->inst), 0x3);};
   free_inst (use->inst);
 }
      next_use = use->next;
      free (use);
    }
  sym->uses = ((void *)0);
}

canonical_original_code:
void resolve_label_uses(struct lab *sym)
{
  struct lab_use *use;
  struct lab_use *next_use;
  for (use = sym->uses; use != ((void *)0); use = next_use)
    {
      resolve_a_label_sub (sym, use->inst, use->addr);
      if (use->inst != ((void *)0) && use->addr >= ((unsigned int) 0x10000000) && use->addr < stack_bot)
 {
   {register unsigned int _addr_ = (mem_addr) (use->addr); data_modified = 1; if (_addr_ >= ((unsigned int) 0x10000000) && _addr_ < data_top && !(_addr_ & 0x3)) data_seg [(_addr_ - ((unsigned int) 0x10000000)) >> 2] = (mem_word) (inst_encode (use->inst)); else if (_addr_ >= stack_bot && _addr_ < ((unsigned int) 0x80000000) && !(_addr_ & 0x3)) stack_seg [(_addr_ - stack_bot) >> 2] = (mem_word) (inst_encode (use->inst)); else if (_addr_ >= ((unsigned int) 0x90000000) && _addr_ < k_data_top && !(_addr_ & 0x3)) k_data_seg [(_addr_ - ((unsigned int) 0x90000000)) >> 2] = (mem_word) (inst_encode (use->inst)); else bad_mem_write (_addr_, inst_encode (use->inst), 0x3);};
   free_inst (use->inst);
 }
      next_use = use->next;
      free (use);
    }
  sym->uses = ((void *)0);
}


decompiled_code:
__int64 __fastcall record_label(char *a1, unsigned int a2, int a3)
{
__int64 v4; // r12
char v5; // al
__int64 v6; // rax

v4 = lookup_label(a1);
v5 = *(_BYTE *)(v4 + 16);
if ( (v5 & 2) == 0 )
{
if ( *(_QWORD *)(v4 + 8) )
{
yyerror("Label is defined for the second time");
return v4;
}
*(_QWORD *)(v4 + 8) = a2;
}
if ( a3 )
{
resolve_label_uses(v4);
v5 = *(_BYTE *)(v4 + 16);
}
if ( (v5 & 1) == 0 )
{
v6 = local_labels;
local_labels = v4;
*(_QWORD *)(v4 + 32) = v6;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func9(char *a1, unsigned int a2, int a3)
{
__int64 v4; // r12
char v5; // al
__int64 v6; // rax

v4 = func4(a1);
v5 = *(_BYTE *)(v4 + 16);
if ( (v5 & 2) == 0 )
{
if ( *(_QWORD *)(v4 + 8) )
{
yyerror("Label is defined for the second time");
return v4;
}
*(_QWORD *)(v4 + 8) = a2;
}
if ( a3 )
{
func8(v4);
v5 = *(_BYTE *)(v4 + 16);
}
if ( (v5 & 1) == 0 )
{
v6 = local_labels;
local_labels = v4;
*(_QWORD *)(v4 + 32) = v6;
}
return v4;
}

original_code:
label *
record_label (char *name, mem_addr address, int resolve_uses)
{
  label *l = lookup_label (name);
  if (!l->gp_flag)
    {
      if (l->addr != 0)
 {
   yyerror ("Label is defined for the second time");
   return (l);
 }
      l->addr = address;
    }
  if (resolve_uses)
    {
      resolve_label_uses (l);
    }
  if (!l->global_flag)
    {
      l->next_local = local_labels;
      local_labels = l;
    }
  return (l);
}

canonical_original_code:
struct lab *record_label(char *name, unsigned int address, int resolve_uses)
{
  struct lab *l = lookup_label (name);
  if (!l->gp_flag)
    {
      if (l->addr != 0)
 {
   yyerror ("Label is defined for the second time");
   return (l);
 }
      l->addr = address;
    }
  if (resolve_uses)
    {
      resolve_label_uses (l);
    }
  if (!l->global_flag)
    {
      l->next_local = local_labels;
      local_labels = l;
    }
  return (l);
}

variable_types:
name
char *

variable_types:
address
unsigned int


decompiled_code:
void __fastcall resolve_a_label(__int64 a1, __int16 *a2)
{
unsigned __int64 v2; // rdx

if ( data_dir )
v2 = (unsigned int)current_data_pc();
else
v2 = (unsigned int)current_text_pc();
resolve_a_label_sub(a1, a2, (const char *)v2);
}

canonical_decompiled_code:
void __fastcall func10(__int64 a1, __int16 *a2)
{
unsigned __int64 v2; // rdx

if ( data_dir )
v2 = (unsigned int)current_data_pc();
else
v2 = (unsigned int)current_text_pc();
func1(a1, a2, (const char *)v2);
}

original_code:
void
resolve_a_label (label *sym, instruction *inst)
{
  resolve_a_label_sub (sym,
         inst,
         (data_dir ? current_data_pc () : current_text_pc ()));
}

canonical_original_code:
void resolve_a_label(struct lab *sym, struct inst_s *inst)
{
  resolve_a_label_sub (sym,
         inst,
         (data_dir ? current_data_pc () : current_text_pc ()));
}

variable_types: struct lab { char *name; long addr; unsigned int global_flag; unsigned int gp_flag; unsigned int const_flag; struct lab *next; struct lab *next_local; struct lab_use { struct inst_s { short opcode; union { struct { unsigned char rs; unsigned char rt; union { short imm; struct { unsigned char rd; unsigned char shamt; } r; } r_i; } r_i; unsigned int target; } r_t; unsigned int encoding; struct immexpr { int offset; struct lab *symbol; short bits; short pc_relative; } *expr; char *source_line; } *inst; unsigned int addr; struct lab_use *next; } *uses; } *


decompiled_code:
void __fastcall flush_local_labels(int a1)
{
__int64 i; // rbx
__int64 v2; // rcx
__int64 v3; // rax
const char *v4; // rdx
int v5; // [rsp+4h] [rbp-24h] BYREF
__int64 v6[4]; // [rsp+8h] [rbp-20h] BYREF

for ( i = local_labels; i; i = *(_QWORD *)(i + 32) )
{
get_hash(*(char **)i, &v5, v6);
v2 = 0LL;
v3 = label_hash_table[v5];
if ( v3 )
{
while ( 1 )
{
v4 = *(const char **)(v3 + 24);
if ( v6[0] == v3 )
break;
v2 = v3;
if ( !v4 )
goto LABEL_13;
v3 = *(_QWORD *)(v3 + 24);
}
if ( v2 )
*(_QWORD *)(v2 + 24) = v4;
else
label_hash_table[v5] = (__int64)v4;
if ( a1 && !*(_QWORD *)(v3 + 8) && (*(_BYTE *)(v3 + 16) & 4) == 0 )
error((int)"Warning: local symbol %s was not defined\n", *(_QWORD *)v3, v4);
}
LABEL_13:
;
}
local_labels = 0LL;
}

canonical_decompiled_code:
void __fastcall func11(int a1)
{
__int64 i; // rbx
__int64 v2; // rcx
__int64 v3; // rax
const char *v4; // rdx
int v5; // [rsp+4h] [rbp-24h] BYREF
__int64 v6[4]; // [rsp+8h] [rbp-20h] BYREF

for ( i = local_labels; i; i = *(_QWORD *)(i + 32) )
{
func0(*(char **)i, &v5, v6);
v2 = 0LL;
v3 = label_hash_table[v5];
if ( v3 )
{
while ( 1 )
{
v4 = *(const char **)(v3 + 24);
if ( v6[0] == v3 )
break;
v2 = v3;
if ( !v4 )
goto LABEL_13;
v3 = *(_QWORD *)(v3 + 24);
}
if ( v2 )
*(_QWORD *)(v2 + 24) = v4;
else
label_hash_table[v5] = (__int64)v4;
if ( a1 && !*(_QWORD *)(v3 + 8) && (*(_BYTE *)(v3 + 16) & 4) == 0 )
error((int)"Warning: local symbol %s was not defined\n", *(_QWORD *)v3, v4);
}
LABEL_13:
;
}
local_labels = 0LL;
}

original_code:
void
flush_local_labels (int issue_undef_warnings)
{
  label *l;
  for (l = local_labels; l != ((void *)0); l = l->next_local)
    {
      int hi;
      label *entry, *lab, *p;
      get_hash (l->name, &hi, &entry);
      for (lab = label_hash_table [hi], p = ((void *)0);
    lab;
    p = lab, lab = lab->next)
 if (lab == entry)
   {
     if (p == ((void *)0))
       label_hash_table [hi] = lab->next;
     else
       p->next = lab->next;
     if (issue_undef_warnings && entry->addr == 0 && !entry->const_flag)
       error ("Warning: local symbol %s was not defined\n",
       entry->name);
     break;
   }
    }
  local_labels = ((void *)0);
}

canonical_original_code:
void flush_local_labels(int issue_undef_warnings)
{
  struct lab *l;
  for (l = local_labels; l != ((void *)0); l = l->next_local)
    {
      int hi;
      struct lab *entry; struct lab *lab; struct lab *p;
      get_hash (l->name, &hi, &entry);
      for (lab = label_hash_table [hi], p = ((void *)0);
    lab;
    p = lab, lab = lab->next)
 if (lab == entry)
   {
     if (p == ((void *)0))
       label_hash_table [hi] = lab->next;
     else
       p->next = lab->next;
     if (issue_undef_warnings && entry->addr == 0 && !entry->const_flag)
       error ("Warning: local symbol %s was not defined\n",
       entry->name);
     break;
   }
    }
  local_labels = ((void *)0);
}


decompiled_code:
__int64 __fastcall find_symbol_address(char *a1)
{
__int64 v1; // rax
__int64 result; // rax

v1 = lookup_label(a1);
if ( !v1 )
return 0LL;
result = *(_QWORD *)(v1 + 8);
if ( !result )
result = 0LL;
return result;
}

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

v1 = func4(a1);
if ( !v1 )
return 0LL;
result = *(_QWORD *)(v1 + 8);
if ( !result )
result = 0LL;
return result;
}

original_code:
mem_addr
find_symbol_address (char *symbol)
{
  label *l = lookup_label (symbol);
  if (l == ((void *)0) || l->addr == 0)
    return 0;
  else
    return (l->addr);
}

canonical_original_code:
unsigned int find_symbol_address(char *symbol)
{
  struct lab *l = lookup_label (symbol);
  if (l == ((void *)0) || l->addr == 0)
    return 0;
  else
    return (l->addr);
}

variable_types:
symbol
char *


decompiled_code:
__int64 print_symbols()
{
__int64 *v0; // r12
__int64 i; // rbx
const char *v2; // rdx
__int64 result; // rax

v0 = label_hash_table;
do
{
for ( i = *v0; i; i = *(_QWORD *)(i + 24) )
{
v2 = "\t";
if ( (*(_BYTE *)(i + 16) & 1) != 0 )
v2 = "g\t";
result = write_output(message_out, "%s%s at 0x%08x\n", v2, *(_QWORD *)i, *(_QWORD *)(i + 8));
}
++v0;
}
while ( v0 != &local_labels );
return result;
}

canonical_decompiled_code:
__int64 func13()
{
__int64 *v0; // r12
__int64 i; // rbx
const char *v2; // rdx
__int64 result; // rax

v0 = label_hash_table;
do
{
for ( i = *v0; i; i = *(_QWORD *)(i + 24) )
{
v2 = "\t";
if ( (*(_BYTE *)(i + 16) & 1) != 0 )
v2 = "g\t";
result = write_output(message_out, "%s%s at 0x%08x\n", v2, *(_QWORD *)i, *(_QWORD *)(i + 8));
}
++v0;
}
while ( v0 != &local_labels );
return result;
}

original_code:
void
print_symbols (void)
{
  int i;
  label *l;
  for (i = 0; i < 8191; i ++)
    for (l = label_hash_table [i]; l != ((void *)0); l = l->next)
      write_output (message_out, "%s%s at 0x%08x\n",
      l->global_flag ? "g\t" : "\t", l->name, l->addr);
}

canonical_original_code:
void print_symbols()
{
  int i;
  struct lab *l;
  for (i = 0; i < 8191; i ++)
    for (l = label_hash_table [i]; l != ((void *)0); l = l->next)
      write_output (message_out, "%s%s at 0x%08x\n",
      l->global_flag ? "g\t" : "\t", l->name, l->addr);
}


decompiled_code:
__int64 print_undefined_symbols()
{
__int64 *v0; // rbp
__int64 i; // rbx
__int64 result; // rax

v0 = label_hash_table;
do
{
for ( i = *v0; i; i = *(_QWORD *)(i + 24) )
{
while ( *(_QWORD *)(i + 8) )
{
i = *(_QWORD *)(i + 24);
if ( !i )
goto LABEL_7;
}
result = write_output(message_out, "%s\n", *(const char **)i);
}
LABEL_7:
++v0;
}
while ( v0 != &local_labels );
return result;
}

canonical_decompiled_code:
__int64 func14()
{
__int64 *v0; // rbp
__int64 i; // rbx
__int64 result; // rax

v0 = label_hash_table;
do
{
for ( i = *v0; i; i = *(_QWORD *)(i + 24) )
{
while ( *(_QWORD *)(i + 8) )
{
i = *(_QWORD *)(i + 24);
if ( !i )
goto LABEL_7;
}
result = write_output(message_out, "%s\n", *(const char **)i);
}
LABEL_7:
++v0;
}
while ( v0 != &local_labels );
return result;
}

original_code:
void
print_undefined_symbols (void)
{
  int i;
  label *l;
  for (i = 0; i < 8191; i ++)
    for (l = label_hash_table [i]; l != ((void *)0); l = l->next)
      if (l->addr == 0)
 write_output (message_out, "%s\n", l->name);
}

canonical_original_code:
void print_undefined_symbols()
{
  int i;
  struct lab *l;
  for (i = 0; i < 8191; i ++)
    for (l = label_hash_table [i]; l != ((void *)0); l = l->next)
      if (l->addr == 0)
 write_output (message_out, "%s\n", l->name);
}


original_code:
char *
undefined_symbol_string (void)
{
  int buffer_length = 128;
  int string_length = 0;
  char *buffer = malloc(buffer_length);
  int i;
  label *l;
  for (i = 0; i < 8191; i ++)
    for (l = label_hash_table[i]; l != ((void *)0); l = l->next)
      if (l->addr == 0)
      {
 int name_length = strlen(l->name);
 int after_length = string_length + name_length + 2;
 if (buffer_length < after_length)
 {
   buffer_length = ((2 * buffer_length) > (2 * after_length) ? (2 * buffer_length) : (2 * after_length));
   buffer = realloc (buffer, buffer_length);
 }
 memcpy (buffer + string_length, l->name, name_length);
 string_length += name_length;
 buffer[string_length] = '\n';
 string_length += 1;
 buffer[string_length + 1] = '\0';
      }
  if (string_length != 0)
    return (buffer);
  else
  {
    free (buffer);
    return (((void *)0));
  };
}

canonical_original_code:
char *undefined_symbol_string()
{
  int buffer_length = 128;
  int string_length = 0;
  char *buffer = malloc(buffer_length);
  int i;
  struct lab *l;
  for (i = 0; i < 8191; i ++)
    for (l = label_hash_table[i]; l != ((void *)0); l = l->next)
      if (l->addr == 0)
      {
 int name_length = strlen(l->name);
 int after_length = string_length + name_length + 2;
 if (buffer_length < after_length)
 {
   buffer_length = ((2 * buffer_length) > (2 * after_length) ? (2 * buffer_length) : (2 * after_length));
   buffer = realloc (buffer, buffer_length);
 }
 memcpy (buffer + string_length, l->name, name_length);
 string_length += name_length;
 buffer[string_length] = '\n';
 string_length += 1;
 buffer[string_length + 1] = '\0';
      }
  if (string_length != 0)
    return (buffer);
  else
  {
    free (buffer);
    return (((void *)0));
  };
}

variable_types:
buffer
char *

return_type: char *


decompiled_code:
int print_syscall_usage()
{
puts("System call counts...\n");
puts("Call#\t\tFrequency");
if ( syscall_usage > 0 )
printf("%d(%s)\t\t%d\n", 0LL, 0LL, (unsigned int)syscall_usage);
return putchar(10);
}

canonical_decompiled_code:
int func1()
{
puts("System call counts...\n");
puts("Call#\t\tFrequency");
if ( syscall_usage > 0 )
printf("%d(%s)\t\t%d\n", 0LL, 0LL, (unsigned int)syscall_usage);
return putchar(10);
}

original_code:
void
print_syscall_usage (void)
{
  int x;
  printf ("System call counts...\n\n");
  printf ("Call#\t\tFrequency\n");
  for (x = 0; x < (sizeof(syscall_table)/ sizeof(syscall_table[0])); x ++)
    if (syscall_usage[x] > 0)
      printf("%d(%s)\t\t%d\n",
      x, syscall_table[x].syscall_name, syscall_usage[x]);
  printf ("\n");
}

canonical_original_code:
void print_syscall_usage()
{
  int x;
  printf ("System call counts...\n\n");
  printf ("Call#\t\tFrequency\n");
  for (x = 0; x < (sizeof(syscall_table)/ sizeof(syscall_table[0])); x ++)
    if (syscall_usage[x] > 0)
      printf("%d(%s)\t\t%d\n",
      x, syscall_table[x].syscall_name, syscall_usage[x]);
  printf ("\n");
}

variable_types: x int


decompiled_code:
void __fastcall initialize_prog_fds(__int64 a1, int a2)
{
const char *v2; // rdx

prog_fds = -1LL;
xmmword_F50 = -1LL;
xmmword_F60 = -1LL;
xmmword_F70 = -1LL;
xmmword_F80 = -1LL;
xmmword_F90 = -1LL;
xmmword_FA0 = -1LL;
xmmword_FB0 = -1LL;
LODWORD(prog_fds) = dup(0);
if ( (int)prog_fds < 0
|| (DWORD1(prog_fds) = dup(1), (SDWORD1(prog_fds) & 0x80000000) != 0)
|| (DWORD2(prog_fds) = dup(2), (SDWORD2(prog_fds) & 0x80000000) != 0) )
{
error((int)"init_prog_fds", a2, v2);
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, int a2)
{
const char *v2; // rdx

prog_fds = -1LL;
xmmword_F50 = -1LL;
xmmword_F60 = -1LL;
xmmword_F70 = -1LL;
xmmword_F80 = -1LL;
xmmword_F90 = -1LL;
xmmword_FA0 = -1LL;
xmmword_FB0 = -1LL;
LODWORD(prog_fds) = dup(0);
if ( (int)prog_fds < 0
|| (DWORD1(prog_fds) = dup(1), (SDWORD1(prog_fds) & 0x80000000) != 0)
|| (DWORD2(prog_fds) = dup(2), (SDWORD2(prog_fds) & 0x80000000) != 0) )
{
error((int)"init_prog_fds", a2, v2);
}
}

original_code:
void
initialize_prog_fds (void)
{
  int x;
  for (x = 0; x < 32; prog_fds[x++] = -1);
  if (((prog_fds[0] = dup(0)) < 0) ||
      ((prog_fds[1] = dup(1)) < 0) ||
      ((prog_fds[2] = dup(2)) < 0))
    error("init_prog_fds");
}

canonical_original_code:
void initialize_prog_fds()
{
  int x;
  for (x = 0; x < 32; prog_fds[x++] = -1);
  if (((prog_fds[0] = dup(0)) < 0) ||
      ((prog_fds[1] = dup(1)) < 0) ||
      ((prog_fds[2] = dup(2)) < 0))
    error("init_prog_fds");
}


decompiled_code:
int kill_prog_fds()
{
int *v0; // rbx
int result; // eax

v0 = (int *)&prog_fds;
do
{
if ( *v0 != -1 )
result = close(*v0);
++v0;
}
while ( v0 != (int *)"%d" );
return result;
}

canonical_decompiled_code:
int func3()
{
int *v0; // rbx
int result; // eax

v0 = (int *)&prog_fds;
do
{
if ( *v0 != -1 )
result = close(*v0);
++v0;
}
while ( v0 != (int *)"%d" );
return result;
}

original_code:
void
kill_prog_fds (void)
{
  int x;
  for (x = 0; x < 32; x++)
    if (prog_fds[x] != -1) close(prog_fds[x]);
}

canonical_original_code:
void kill_prog_fds()
{
  int x;
  for (x = 0; x < 32; x++)
    if (prog_fds[x] != -1) close(prog_fds[x]);
}


decompiled_code:
void handle_exception()
{
const char *v0; // rdx
int v1; // esi
int v2; // eax

v0 = (const char *)(unsigned int)quiet;
v1 = CPR[13] >> 2;
v2 = v1 & 0xF;
if ( !(_DWORD)quiet )
{
if ( (v1 & 0xF) == 0 )
{
exception_occurred = 0;
*(_DWORD *)&PC = -2147483520;
LABEL_4:
if ( !source_file )
R[4] = 2;
return;
}
error((int)"Exception occurred at PC=0x%08x\n", CPR[14], (const char *)(unsigned int)quiet);
v1 = CPR[13] >> 2;
v2 = v1 & 0xF;
}
exception_occurred = 0;
*(_DWORD *)&PC = -2147483520;
switch ( v2 )
{
case 0:
goto LABEL_4;
case 4:
if ( !source_file )
R[4] = 11;
if ( !(_DWORD)quiet )
error((int)" Unaligned address in inst/data fetch: 0x%08x\n", CPR[8], v0);
break;
case 5:
if ( !source_file )
R[4] = 11;
if ( !(_DWORD)quiet )
error((int)" Unaligned address in store: 0x%08x\n", CPR[8], v0);
break;
case 6:
if ( !source_file )
R[4] = 7;
if ( !(_DWORD)quiet )
error((int)" Bad address in text read: 0x%08x\n", CPR[8], v0);
break;
case 7:
if ( !source_file )
R[4] = 7;
if ( !(_DWORD)quiet )
error((int)" Bad address in data/stack read: 0x%08x\n", CPR[8], v0);
break;
case 8:
if ( !(_DWORD)quiet )
error((int)" Error in syscall\n", v1, v0);
break;
case 9:
return;
case 10:
if ( !(_DWORD)quiet )
error((int)" Reserved instruction execution\n", (int)quiet, v0);
break;
case 12:
if ( !source_file )
R[4] = 8;
if ( !(_DWORD)quiet )
error((int)" Arithmetic overflow\n", v1, (const char *)(unsigned int)quiet);
break;
default:
if ( !(_DWORD)quiet )
error((int)"Unknown exception: %d\n", v1, v0);
break;
}
}

canonical_decompiled_code:
void func4()
{
const char *v0; // rdx
int v1; // esi
int v2; // eax

v0 = (const char *)(unsigned int)quiet;
v1 = CPR[13] >> 2;
v2 = v1 & 0xF;
if ( !(_DWORD)quiet )
{
if ( (v1 & 0xF) == 0 )
{
exception_occurred = 0;
*(_DWORD *)&PC = -2147483520;
LABEL_4:
if ( !source_file )
R[4] = 2;
return;
}
error((int)"Exception occurred at PC=0x%08x\n", CPR[14], (const char *)(unsigned int)quiet);
v1 = CPR[13] >> 2;
v2 = v1 & 0xF;
}
exception_occurred = 0;
*(_DWORD *)&PC = -2147483520;
switch ( v2 )
{
case 0:
goto LABEL_4;
case 4:
if ( !source_file )
R[4] = 11;
if ( !(_DWORD)quiet )
error((int)" Unaligned address in inst/data fetch: 0x%08x\n", CPR[8], v0);
break;
case 5:
if ( !source_file )
R[4] = 11;
if ( !(_DWORD)quiet )
error((int)" Unaligned address in store: 0x%08x\n", CPR[8], v0);
break;
case 6:
if ( !source_file )
R[4] = 7;
if ( !(_DWORD)quiet )
error((int)" Bad address in text read: 0x%08x\n", CPR[8], v0);
break;
case 7:
if ( !source_file )
R[4] = 7;
if ( !(_DWORD)quiet )
error((int)" Bad address in data/stack read: 0x%08x\n", CPR[8], v0);
break;
case 8:
if ( !(_DWORD)quiet )
error((int)" Error in syscall\n", v1, v0);
break;
case 9:
return;
case 10:
if ( !(_DWORD)quiet )
error((int)" Reserved instruction execution\n", (int)quiet, v0);
break;
case 12:
if ( !source_file )
R[4] = 8;
if ( !(_DWORD)quiet )
error((int)" Arithmetic overflow\n", v1, (const char *)(unsigned int)quiet);
break;
default:
if ( !(_DWORD)quiet )
error((int)"Unknown exception: %d\n", v1, v0);
break;
}
}

original_code:
void
handle_exception (void)
{
  if (!quiet && (((CPR[0][13]) >> 2) & 0xf) != 0)
    error ("Exception occurred at PC=0x%08x\n", (CPR[0][14]));
  exception_occurred = 0;
  PC = 0x80000080;
  switch (((CPR[0][13]) >> 2) & 0xf)
    {
    case 0:
      if (!source_file)
 R[4] = 2;
      break;
    case 4:
      if (!source_file)
 R[4] = 11;
      if (!quiet)
 error ("  Unaligned address in inst/data fetch: 0x%08x\n",(CPR[0][8]));
      break;
    case 5:
      if (!source_file)
 R[4] = 11;
      if (!quiet)
 error ("  Unaligned address in store: 0x%08x\n", (CPR[0][8]));
      break;
    case 6:
      if (!source_file)
 R[4] = 7;
      if (!quiet)
 error ("  Bad address in text read: 0x%08x\n", (CPR[0][8]));
      break;
    case 7:
      if (!source_file)
 R[4] = 7;
      if (!quiet)
 error ("  Bad address in data/stack read: 0x%08x\n", (CPR[0][8]));
      break;
    case 9:
      exception_occurred = 0;
      return;
    case 8:
      if (!quiet)
 error ("  Error in syscall\n");
      break;
    case 10:
      if (!quiet)
 error ("  Reserved instruction execution\n");
      break;
    case 12:
      if (!source_file)
 R[4] = 8;
      if (!quiet)
 error ("  Arithmetic overflow\n");
      break;
    default:
      if (!quiet)
 error ("Unknown exception: %d\n", (CPR[0][13]) >> 2);
      break;
    }
  if (!source_file)
    {
    }
}

canonical_original_code:
void handle_exception()
{
  if (!quiet && (((CPR[0][13]) >> 2) & 0xf) != 0)
    error ("Exception occurred at PC=0x%08x\n", (CPR[0][14]));
  exception_occurred = 0;
  PC = 0x80000080;
  switch (((CPR[0][13]) >> 2) & 0xf)
    {
    case 0:
      if (!source_file)
 R[4] = 2;
      break;
    case 4:
      if (!source_file)
 R[4] = 11;
      if (!quiet)
 error ("  Unaligned address in inst/data fetch: 0x%08x\n",(CPR[0][8]));
      break;
    case 5:
      if (!source_file)
 R[4] = 11;
      if (!quiet)
 error ("  Unaligned address in store: 0x%08x\n", (CPR[0][8]));
      break;
    case 6:
      if (!source_file)
 R[4] = 7;
      if (!quiet)
 error ("  Bad address in text read: 0x%08x\n", (CPR[0][8]));
      break;
    case 7:
      if (!source_file)
 R[4] = 7;
      if (!quiet)
 error ("  Bad address in data/stack read: 0x%08x\n", (CPR[0][8]));
      break;
    case 9:
      exception_occurred = 0;
      return;
    case 8:
      if (!quiet)
 error ("  Error in syscall\n");
      break;
    case 10:
      if (!quiet)
 error ("  Reserved instruction execution\n");
      break;
    case 12:
      if (!source_file)
 R[4] = 8;
      if (!quiet)
 error ("  Arithmetic overflow\n");
      break;
    default:
      if (!quiet)
 error ("Unknown exception: %d\n", (CPR[0][13]) >> 2);
      break;
    }
  if (!source_file)
    {
    }
}


decompiled_code:
__int64 bresenham_next()
{
int v0; // er8
int v1; // eax
int v2; // edi
char v3; // r10
char v4; // r9
int v5; // esi

v0 = i;
if ( i <= 0 )
return 255LL;
v1 = err;
if ( err >= 0 )
{
v2 = HIDWORD(p_act);
v3 = 0;
v4 = 0;
v5 = p_act;
do
{
while ( swapdir )
{
v5 += s1;
v4 = 1;
v1 -= dword_1D0;
if ( v1 < 0 )
goto LABEL_7;
}
v2 += s2;
v3 = 1;
v1 -= dword_1D0;
}
while ( v1 >= 0 );
LABEL_7:
if ( v4 )
LODWORD(p_act) = v5;
if ( v3 )
HIDWORD(p_act) = v2;
}
if ( swapdir )
HIDWORD(p_act) += s2;
else
LODWORD(p_act) = s1 + p_act;
err = dy + v1;
--i;
return 4 * (unsigned int)(v0 == 1);
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // er8
int v1; // eax
int v2; // edi
char v3; // r10
char v4; // r9
int v5; // esi

v0 = i;
if ( i <= 0 )
return 255LL;
v1 = err;
if ( err >= 0 )
{
v2 = HIDWORD(p_act);
v3 = 0;
v4 = 0;
v5 = p_act;
do
{
while ( swapdir )
{
v5 += s1;
v4 = 1;
v1 -= dword_1D0;
if ( v1 < 0 )
goto LABEL_7;
}
v2 += s2;
v3 = 1;
v1 -= dword_1D0;
}
while ( v1 >= 0 );
LABEL_7:
if ( v4 )
LODWORD(p_act) = v5;
if ( v3 )
HIDWORD(p_act) = v2;
}
if ( swapdir )
HIDWORD(p_act) += s2;
else
LODWORD(p_act) = s1 + p_act;
err = dy + v1;
--i;
return 4 * (unsigned int)(v0 == 1);
}

original_code:
int bresenham_next (void)
{
  if (i<=0)
 return (0xff);
  while (err >= 0)
  {
 if (swapdir)
  p_act.x += s1;
 else
  p_act.y += s2;
 err -= dx;
  }
  if (swapdir)
 p_act.y += s2;
  else
 p_act.x += s1;
  err += dy;
  i--;
  return ((i) ? 0 : 0x04);
}

canonical_original_code:
int bresenham_next()
{
  if (i<=0)
 return (0xff);
  while (err >= 0)
  {
 if (swapdir)
  p_act.x += s1;
 else
  p_act.y += s2;
 err -= dx;
  }
  if (swapdir)
 p_act.y += s2;
  else
 p_act.x += s1;
  err += dy;
  i--;
  return ((i) ? 0 : 0x04);
}

return_type: int


decompiled_code:
float *__fastcall code_to_ucoord(char a1, _DWORD *a2)
{
double v2; // xmm2_8
float *result; // rax
double v4; // xmm0_8
double v5; // xmm1_8
double v6; // xmm3_8
double v7; // xmm0_8
double v8; // xmm2_8

v2 = (double)(a1 & 0xF) - 4.0;
result = (float *)tp;
v4 = (double)(a1 >> 4) - 1.0;
v5 = *((double *)tp + 5) * v4;
v6 = *((double *)tp + 6) * v2;
v7 = v4 * *((double *)tp + 7);
v8 = v2 * *((double *)tp + 8);
*(float *)&v5 = v5 + v6 + *((float *)tp + 22) + *((float *)tp + 26);
*a2 = LODWORD(v5);
*(float *)&v7 = v8 + v7 + result[23] + result[27];
a2[1] = LODWORD(v7);
return result;
}

canonical_decompiled_code:
float *__fastcall func0(char a1, _DWORD *a2)
{
double v2; // xmm2_8
float *result; // rax
double v4; // xmm0_8
double v5; // xmm1_8
double v6; // xmm3_8
double v7; // xmm0_8
double v8; // xmm2_8

v2 = (double)(a1 & 0xF) - 4.0;
result = (float *)tp;
v4 = (double)(a1 >> 4) - 1.0;
v5 = *((double *)tp + 5) * v4;
v6 = *((double *)tp + 6) * v2;
v7 = v4 * *((double *)tp + 7);
v8 = v2 * *((double *)tp + 8);
*(float *)&v5 = v5 + v6 + *((float *)tp + 22) + *((float *)tp + 26);
*a2 = LODWORD(v5);
*(float *)&v7 = v8 + v7 + result[23] + result[27];
a2[1] = LODWORD(v7);
return result;
}

original_code:
void code_to_ucoord (char c, HPGL_Pt *pp)
{
double x,y;
  x = (double) (c >> 4) - 1.0;
  y = (double) (c & 0x0f) - 4.0;
  pp->x = tp->Txx * x + tp->Txy * y + tp->refpoint.x + tp->offset.x;
  pp->y = tp->Tyx * x + tp->Tyy * y + tp->refpoint.y + tp->offset.y;
}

canonical_original_code:
void code_to_ucoord(char c, struct HPGL_Pt *pp)
{
double x; double y;
  x = (double) (c >> 4) - 1.0;
  y = (double) (c & 0x0f) - 4.0;
  pp->x = tp->Txx * x + tp->Txy * y + tp->refpoint.x + tp->offset.x;
  pp->y = tp->Tyx * x + tp->Tyy * y + tp->refpoint.y + tp->offset.y;
}

variable_types: c char

variable_types:
pp
struct HPGL_Pt { float x; } *

variable_types: x double

variable_types: y double


decompiled_code:
__int64 __fastcall ASCII_to_char(int a1)
{
unsigned int v1; // er8
char *v2; // rbx
float *v3; // rax
__int64 result; // rax
_DWORD v5[4]; // [rsp+8h] [rbp-10h] BYREF

CurrentLineType = 7;
v1 = *((_DWORD *)tp + 8);
if ( v1 )
{
fprintf(stderr, "Charset %d not supported -- replaced by blank!\n", v1);
v2 = (char *)*(&charset0 + 32);
}
else
{
if ( (a1 & 0x80u) != 0 )
{
fprintf(stderr, "Illegal char in string: %c replaced by blank!\n", (unsigned int)a1);
a1 = 32;
}
v2 = (char *)*(&charset0 + a1);
}
while ( *v2 )
{
code_to_ucoord(*v2 & 0x7F, v5);
if ( *v2 >= 0 )
Pen_action_to_tmpfile(1LL, v5);
else
Pen_action_to_tmpfile(2LL, v5);
++v2;
}
v3 = (float *)tp;
*((float *)tp + 22) = *((float *)tp + 22) + *((float *)tp + 18);
v3[23] = v3[23] + v3[19];
result = GlobalLineType;
CurrentLineType = GlobalLineType;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
unsigned int v1; // er8
char *v2; // rbx
float *v3; // rax
__int64 result; // rax
_DWORD v5[4]; // [rsp+8h] [rbp-10h] BYREF

CurrentLineType = 7;
v1 = *((_DWORD *)tp + 8);
if ( v1 )
{
fprintf(stderr, "Charset %d not supported -- replaced by blank!\n", v1);
v2 = (char *)*(&charset0 + 32);
}
else
{
if ( (a1 & 0x80u) != 0 )
{
fprintf(stderr, "Illegal char in string: %c replaced by blank!\n", (unsigned int)a1);
a1 = 32;
}
v2 = (char *)*(&charset0 + a1);
}
while ( *v2 )
{
func0(*v2 & 0x7F, v5);
if ( *v2 >= 0 )
Pen_action_to_tmpfile(1LL, v5);
else
Pen_action_to_tmpfile(2LL, v5);
++v2;
}
v3 = (float *)tp;
*((float *)tp + 22) = *((float *)tp + 22) + *((float *)tp + 18);
v3[23] = v3[23] + v3[19];
result = GlobalLineType;
CurrentLineType = GlobalLineType;
return result;
}

original_code:
void ASCII_to_char (int c)
{
HPGL_Pt p;
char *ptr;
  CurrentLineType = LT_solid;
  switch (tp->font)
  {
    case 0:
 if (c & 0x80)
 {
  fprintf (stderr,
   "Illegal char in string: %c replaced by blank!\n", c);
  c = ' ';
 }
 ptr = &charset0[c][0];
 break;
    default:
 fprintf (stderr,
  "Charset %d not supported -- replaced by blank!\n", tp->font);
  c = ' ';
 ptr = &charset0[c][0];
 break;
  }
  for (; *ptr; ptr++)
  {
 code_to_ucoord (*ptr & 0x7f, &p);
 if (*ptr & 0x80)
  Pen_action_to_tmpfile (DRAW_TO, &p, 0);
 else
  Pen_action_to_tmpfile (MOVE_TO, &p, 0);
  }
  tp->refpoint.x += tp->chardiff.x;
  tp->refpoint.y += tp->chardiff.y;
  CurrentLineType = GlobalLineType;
}

canonical_original_code:
void ASCII_to_char(int c)
{
struct HPGL_Pt p;
char *ptr;
  CurrentLineType = LT_solid;
  switch (tp->font)
  {
    case 0:
 if (c & 0x80)
 {
  fprintf (stderr,
   "Illegal char in string: %c replaced by blank!\n", c);
  c = ' ';
 }
 ptr = &charset0[c][0];
 break;
    default:
 fprintf (stderr,
  "Charset %d not supported -- replaced by blank!\n", tp->font);
  c = ' ';
 ptr = &charset0[c][0];
 break;
  }
  for (; *ptr; ptr++)
  {
 code_to_ucoord (*ptr & 0x7f, &p);
 if (*ptr & 0x80)
  Pen_action_to_tmpfile (DRAW_TO, &p, 0);
 else
  Pen_action_to_tmpfile (MOVE_TO, &p, 0);
  }
  tp->refpoint.x += tp->chardiff.x;
  tp->refpoint.y += tp->chardiff.y;
  CurrentLineType = GlobalLineType;
}

variable_types: c int

variable_types:
p
struct HPGL_Pt { float x; }

variable_types:
ptr
char *


original_code:
void adjust_text_par (void)
{
double cdir,sdir;
  tp->space = tp->width * 1.5;
  tp->line = tp->height * 2.0;
  cdir = cos (tp->dir);
  sdir = sin (tp->dir);
  tp->Txx = tp->width * cdir / 4.0;
  tp->Tyx = tp->width * sdir / 4.0;
  tp->Txy = tp->height* (tp->slant * cdir - sdir) / 6.0;
  tp->Tyy = tp->height* (tp->slant * sdir + cdir) / 6.0;
  tp->chardiff.x= tp->space * (1.0 + tp->espace) * cdir;
  tp->chardiff.y= tp->space * (1.0 + tp->espace) * sdir;
  tp->linediff.x= tp->line * (1.0 + tp->eline ) * sdir;
  tp->linediff.y= -tp->line * (1.0 + tp->eline ) * cdir;
}

canonical_original_code:
void adjust_text_par()
{
double cdir; double sdir;
  tp->space = tp->width * 1.5;
  tp->line = tp->height * 2.0;
  cdir = cos (tp->dir);
  sdir = sin (tp->dir);
  tp->Txx = tp->width * cdir / 4.0;
  tp->Tyx = tp->width * sdir / 4.0;
  tp->Txy = tp->height* (tp->slant * cdir - sdir) / 6.0;
  tp->Tyy = tp->height* (tp->slant * sdir + cdir) / 6.0;
  tp->chardiff.x= tp->space * (1.0 + tp->espace) * cdir;
  tp->chardiff.y= tp->space * (1.0 + tp->espace) * sdir;
  tp->linediff.x= tp->line * (1.0 + tp->eline ) * sdir;
  tp->linediff.y= -tp->line * (1.0 + tp->eline ) * cdir;
}

variable_types: cdir double

variable_types: sdir double


original_code:
void init_text_par (void)
{
  tp->width = 0.005 * (P2.x - P1.x);
  tp->height = 0.0075 * (P2.y - P1.y);
  tp->espace = 0.0;
  tp->eline = 0.0;
  tp->dir = 0.0;
  tp->slant = 0.0;
  tp->font = 0;
  tp->orig = 1;
  tp->refpoint = tp->CR_point = HP_pos;
  tp->offset.x = tp->offset.y = 0.0;
  adjust_text_par();
}

canonical_original_code:
void init_text_par()
{
  tp->width = 0.005 * (P2.x - P1.x);
  tp->height = 0.0075 * (P2.y - P1.y);
  tp->espace = 0.0;
  tp->eline = 0.0;
  tp->dir = 0.0;
  tp->slant = 0.0;
  tp->font = 0;
  tp->orig = 1;
  tp->refpoint = tp->CR_point = HP_pos;
  tp->offset.x = tp->offset.y = 0.0;
  adjust_text_par();
}


original_code:
void get_label_offset (char *txt, LB_Mode mode)
{
float dx=0.0, dy=0.0;
static float nc, nl, nc_max;
  switch (mode)
  {
    case LB_direct:
 nc = nl = nc_max = 0.0;
 for (; *txt && *txt != '\015'; txt++)
  if (*txt >=' ' && ((*txt&'\x80') == 0))
   nc++;
  else if (*txt == '\010')
   nc--;
  else if (*txt == '\011')
   nc -= 0.5;
 break;
    case LB_buffered:
 nc = nl = nc_max = 0.0;
 for (; *txt; txt++)
  if (*txt >=' ' && ((*txt&'\x80') == 0))
   nc++;
  else if (*txt == '\010')
   nc--;
  else if (*txt == '\011')
   nc -= 0.5;
  else if (*txt == '\012')
   nl++;
  else if (*txt == '\013')
   nl--;
  else if (*txt == '\015')
  {
   if (nc > nc_max)
    nc_max = nc;
   nc = 0.0;
  }
 if (nc > nc_max)
  nc_max = nc;
 nc = nc_max;
 break;
    case LB_buffered_in_use:
 break;
  }
  switch (tp->orig)
  {
 case 1:
 case 2:
 case 3:
  dx = 0.0;
  break;
 case 11:
 case 12:
 case 13:
  dx = 0.5 * 0.666666666;
  break;
 case 4:
 case 5:
 case 6:
 case 14:
 case 15:
 case 16:
  dx = 0.5 * (1.0 - 0.666666666);
  tp->refpoint.x -= tp->chardiff.x * nc/2.0;
  tp->refpoint.y -= tp->chardiff.y * nc/2.0;
  break;
 case 7:
 case 8:
 case 9:
  dx = 1.0 - 0.666666666;
  tp->refpoint.x -= tp->chardiff.x * nc;
  tp->refpoint.y -= tp->chardiff.y * nc;
  break;
 case 17:
 case 18:
 case 19:
  dx = 1.0 - 1.5 * 0.666666666;
  tp->refpoint.x -= tp->chardiff.x * nc;
  tp->refpoint.y -= tp->chardiff.y * nc;
  break;
  }
  switch (tp->orig)
  {
 case 1:
 case 4:
 case 7:
  dy = 0.0;
  if (mode == LB_buffered || mode == LB_buffered_in_use)
  {
   tp->refpoint.x -= tp->linediff.x * nl;
   tp->refpoint.y -= tp->linediff.y * nl;
  }
  break;
 case 11:
 case 14:
 case 17:
  dy = 0.5 * 0.5;
  if (mode == LB_buffered || mode == LB_buffered_in_use)
  {
   tp->refpoint.x -= tp->linediff.x * nl;
   tp->refpoint.y -= tp->linediff.y * nl;
  }
  break;
 case 2:
 case 5:
 case 8:
 case 12:
 case 15:
 case 18:
  dy = -0.5 * 0.5;
  if (mode == LB_buffered || mode == LB_buffered_in_use)
  {
   tp->refpoint.x -= tp->linediff.x * nl/2.0;
   tp->refpoint.y -= tp->linediff.y * nl/2.0;
  }
  break;
 case 3:
 case 6:
 case 9:
  dy = -0.5;
  if (mode == LB_buffered || mode == LB_buffered_in_use)
  {
   tp->refpoint.x += tp->linediff.x * (nl-1.0);
   tp->refpoint.y += tp->linediff.y * (nl-1.0);
  }
  break;
 case 13:
 case 16:
 case 19:
  dy = -1.5 * 0.5;
  if (mode == LB_buffered || mode == LB_buffered_in_use)
  {
   tp->refpoint.x += tp->linediff.x * (nl-1.0);
   tp->refpoint.y += tp->linediff.y * (nl-1.0);
  }
  break;
  }
  tp->offset.x = tp->chardiff.x * dx - tp->linediff.x * dy;
  tp->offset.y = tp->chardiff.y * dx - tp->linediff.y * dy;
}

canonical_original_code:
void get_label_offset(char *txt, enum LB_Mode mode)
{
float dx = 0.0; float dy = 0.0;
static float nc; static float nl; static float nc_max;
  switch (mode)
  {
    case LB_direct:
 nc = nl = nc_max = 0.0;
 for (; *txt && *txt != '\015'; txt++)
  if (*txt >=' ' && ((*txt&'\x80') == 0))
   nc++;
  else if (*txt == '\010')
   nc--;
  else if (*txt == '\011')
   nc -= 0.5;
 break;
    case LB_buffered:
 nc = nl = nc_max = 0.0;
 for (; *txt; txt++)
  if (*txt >=' ' && ((*txt&'\x80') == 0))
   nc++;
  else if (*txt == '\010')
   nc--;
  else if (*txt == '\011')
   nc -= 0.5;
  else if (*txt == '\012')
   nl++;
  else if (*txt == '\013')
   nl--;
  else if (*txt == '\015')
  {
   if (nc > nc_max)
    nc_max = nc;
   nc = 0.0;
  }
 if (nc > nc_max)
  nc_max = nc;
 nc = nc_max;
 break;
    case LB_buffered_in_use:
 break;
  }
  switch (tp->orig)
  {
 case 1:
 case 2:
 case 3:
  dx = 0.0;
  break;
 case 11:
 case 12:
 case 13:
  dx = 0.5 * 0.666666666;
  break;
 case 4:
 case 5:
 case 6:
 case 14:
 case 15:
 case 16:
  dx = 0.5 * (1.0 - 0.666666666);
  tp->refpoint.x -= tp->chardiff.x * nc/2.0;
  tp->refpoint.y -= tp->chardiff.y * nc/2.0;
  break;
 case 7:
 case 8:
 case 9:
  dx = 1.0 - 0.666666666;
  tp->refpoint.x -= tp->chardiff.x * nc;
  tp->refpoint.y -= tp->chardiff.y * nc;
  break;
 case 17:
 case 18:
 case 19:
  dx = 1.0 - 1.5 * 0.666666666;
  tp->refpoint.x -= tp->chardiff.x * nc;
  tp->refpoint.y -= tp->chardiff.y * nc;
  break;
  }
  switch (tp->orig)
  {
 case 1:
 case 4:
 case 7:
  dy = 0.0;
  if (mode == LB_buffered || mode == LB_buffered_in_use)
  {
   tp->refpoint.x -= tp->linediff.x * nl;
   tp->refpoint.y -= tp->linediff.y * nl;
  }
  break;
 case 11:
 case 14:
 case 17:
  dy = 0.5 * 0.5;
  if (mode == LB_buffered || mode == LB_buffered_in_use)
  {
   tp->refpoint.x -= tp->linediff.x * nl;
   tp->refpoint.y -= tp->linediff.y * nl;
  }
  break;
 case 2:
 case 5:
 case 8:
 case 12:
 case 15:
 case 18:
  dy = -0.5 * 0.5;
  if (mode == LB_buffered || mode == LB_buffered_in_use)
  {
   tp->refpoint.x -= tp->linediff.x * nl/2.0;
   tp->refpoint.y -= tp->linediff.y * nl/2.0;
  }
  break;
 case 3:
 case 6:
 case 9:
  dy = -0.5;
  if (mode == LB_buffered || mode == LB_buffered_in_use)
  {
   tp->refpoint.x += tp->linediff.x * (nl-1.0);
   tp->refpoint.y += tp->linediff.y * (nl-1.0);
  }
  break;
 case 13:
 case 16:
 case 19:
  dy = -1.5 * 0.5;
  if (mode == LB_buffered || mode == LB_buffered_in_use)
  {
   tp->refpoint.x += tp->linediff.x * (nl-1.0);
   tp->refpoint.y += tp->linediff.y * (nl-1.0);
  }
  break;
  }
  tp->offset.x = tp->chardiff.x * dx - tp->linediff.x * dy;
  tp->offset.y = tp->chardiff.y * dx - tp->linediff.y * dy;
}

variable_types:
txt
char *

variable_types: enum LB_Mode { LB_direct=0, LB_buffered=1, LB_buffered_in_use=2 }

variable_types: dx float

variable_types: dy float

variable_types: nc float

variable_types: nl float


original_code:
void plot_string (char *txt, LB_Mode mode)
{
char *txt0;
  txt0 = txt;
  tp->refpoint = HP_pos;
  get_label_offset (txt, mode);
  while (*txt)
  {
 switch (*txt)
 {
   case ' ':
  tp->refpoint.x += tp->chardiff.x;
  tp->refpoint.y += tp->chardiff.y;
  break;
   case '\015':
  tp->refpoint = tp->CR_point;
  switch (mode)
  {
    case LB_direct:
   get_label_offset (txt+1, mode);
   break;
    case LB_buffered:
   get_label_offset (txt0, LB_buffered_in_use);
   break;
    default:
   break;
  }
  break;
   case '\012':
  tp->CR_point.x += tp->linediff.x;
  tp->CR_point.y += tp->linediff.y;
  tp->refpoint.x += tp->linediff.x;
  tp->refpoint.y += tp->linediff.y;
  break;
   case '\010':
  tp->refpoint.x -= tp->chardiff.x;
  tp->refpoint.y -= tp->chardiff.y;
  break;
   case '\011':
  tp->refpoint.x -= 0.5 * tp->chardiff.x;
  tp->refpoint.y -= 0.5 * tp->chardiff.y;
  break;
   case '\013':
  tp->CR_point.x -= tp->linediff.x;
  tp->CR_point.y -= tp->linediff.y;
  tp->refpoint.x -= tp->linediff.x;
  tp->refpoint.y -= tp->linediff.y;
  break;
   case '\016':
   case '\017':
  break;
   default:
   ASCII_to_char ((int) *txt);
        break;
 }
 Pen_action_to_tmpfile (MOVE_TO, &tp->refpoint, 0);
 txt++;
  }
}

canonical_original_code:
void plot_string(char *txt, enum LB_Mode mode)
{
char *txt0;
  txt0 = txt;
  tp->refpoint = HP_pos;
  get_label_offset (txt, mode);
  while (*txt)
  {
 switch (*txt)
 {
   case ' ':
  tp->refpoint.x += tp->chardiff.x;
  tp->refpoint.y += tp->chardiff.y;
  break;
   case '\015':
  tp->refpoint = tp->CR_point;
  switch (mode)
  {
    case LB_direct:
   get_label_offset (txt+1, mode);
   break;
    case LB_buffered:
   get_label_offset (txt0, LB_buffered_in_use);
   break;
    default:
   break;
  }
  break;
   case '\012':
  tp->CR_point.x += tp->linediff.x;
  tp->CR_point.y += tp->linediff.y;
  tp->refpoint.x += tp->linediff.x;
  tp->refpoint.y += tp->linediff.y;
  break;
   case '\010':
  tp->refpoint.x -= tp->chardiff.x;
  tp->refpoint.y -= tp->chardiff.y;
  break;
   case '\011':
  tp->refpoint.x -= 0.5 * tp->chardiff.x;
  tp->refpoint.y -= 0.5 * tp->chardiff.y;
  break;
   case '\013':
  tp->CR_point.x -= tp->linediff.x;
  tp->CR_point.y -= tp->linediff.y;
  tp->refpoint.x -= tp->linediff.x;
  tp->refpoint.y -= tp->linediff.y;
  break;
   case '\016':
   case '\017':
  break;
   default:
   ASCII_to_char ((int) *txt);
        break;
 }
 Pen_action_to_tmpfile (MOVE_TO, &tp->refpoint, 0);
 txt++;
  }
}

user_defined_types: enum LB_Mode { LB_direct=0, LB_buffered=1, LB_buffered_in_use=2 }