decompiled_code:
__int64 __fastcall render_write_letter(unsigned __int8 a1, char a2, int a3, int a4, int a5)
{
char *v5; // rbp
unsigned int v8; // er13
int i; // ebx
__int64 result; // rax
int v11; // [rsp+8h] [rbp-40h]
int v12; // [rsp+Ch] [rbp-3Ch]

if ( a1 == 16 )
{
v5 = (char *)&default_font_8x16 + 16 * a2;
}
else
{
if ( a1 != 8 )
{
v11 = a1;
if ( !a1 )
return result;
goto LABEL_7;
}
v5 = (char *)&default_font_8x8 + 8 * a2;
}
v11 = a1;
LABEL_7:
v8 = a5 - 4;
v12 = 4 - a5;
do
{
for ( i = 0; i != 8; ++i )
{
if ( ((1 << i) & *v5) > 0 )
render_draw_pixel(i + a4, v8, a3);
}
++v8;
++v5;
result = v8 + v12;
}
while ( v11 > (int)result );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int8 a1, char a2, int a3, int a4, int a5)
{
char *v5; // rbp
unsigned int v8; // er13
int i; // ebx
__int64 result; // rax
int v11; // [rsp+8h] [rbp-40h]
int v12; // [rsp+Ch] [rbp-3Ch]

if ( a1 == 16 )
{
v5 = (char *)&default_font_8x16 + 16 * a2;
}
else
{
if ( a1 != 8 )
{
v11 = a1;
if ( !a1 )
return result;
goto LABEL_7;
}
v5 = (char *)&default_font_8x8 + 8 * a2;
}
v11 = a1;
LABEL_7:
v8 = a5 - 4;
v12 = 4 - a5;
do
{
for ( i = 0; i != 8; ++i )
{
if ( ((1 << i) & *v5) > 0 )
func2(i + a4, v8, a3);
}
++v8;
++v5;
result = v8 + v12;
}
while ( v11 > (int)result );
return result;
}

original_code:
void render_write_letter(uint8_t size, char letter, uint32_t col, uint32_t x, uint32_t y)
{
 char *let_data;
 if(size == 16) let_data = default_font_8x16[letter];
 else if (size == 8) let_data = default_font_8x8[letter];
 int i;
 int j;
 for(i = 0; i < size; i++)
 {
  for(j = 0; j < 8; j++)
  {
   if((let_data[i] & (1 << j)) > 0)
    render_draw_pixel(x+j, y+i-4, (uint32_t) col);
  }
 }
}

canonical_original_code:
void render_write_letter(unsigned char size, char letter, unsigned int col, unsigned int x, unsigned int y)
{
 char *let_data;
 if(size == 16) let_data = default_font_8x16[letter];
 else if (size == 8) let_data = default_font_8x8[letter];
 int i;
 int j;
 for(i = 0; i < size; i++)
 {
  for(j = 0; j < 8; j++)
  {
   if((let_data[i] & (1 << j)) > 0)
    render_draw_pixel(x+j, y+i-4, (unsigned int) col);
  }
 }
}

variable_types:
size
unsigned char

variable_types: letter char

variable_types:
col
unsigned int

variable_types:
x
unsigned int

variable_types: i int

variable_types: j int


repo: dakk/spiderpig-os

decompiled_code:
__int64 __fastcall render_write_text(unsigned __int8 a1, char *a2, int a3, int a4, int a5)
{
char *v5; // rbx
char v6; // si
__int64 result; // rax

v5 = a2;
v6 = *a2;
if ( v6 )
{
do
{
result = render_write_letter(a1, v6, a3, a4, a5);
a4 += 8;
v6 = *++v5;
}
while ( *v5 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int8 a1, char *a2, int a3, int a4, int a5)
{
char *v5; // rbx
char v6; // si
__int64 result; // rax

v5 = a2;
v6 = *a2;
if ( v6 )
{
do
{
result = func3(a1, v6, a3, a4, a5);
a4 += 8;
v6 = *++v5;
}
while ( *v5 );
}
return result;
}

original_code:
void render_write_text(uint8_t size, char *text, uint32_t col, uint32_t x, uint32_t y)
{
 char *str = text;
 uint32_t cx = x;
 while(*str != '\0')
 {
  render_write_letter(size, *str, col, cx, y);
  cx = cx + 8;
  str++;
 }
}

canonical_original_code:
void render_write_text(unsigned char size, char *text, unsigned int col, unsigned int x, unsigned int y)
{
 char *str = text;
 unsigned int cx = x;
 while(*str != '\0')
 {
  render_write_letter(size, *str, col, cx, y);
  cx = cx + 8;
  str++;
 }
}

variable_types:
text
char *

variable_types:
y
unsigned int

variable_types:
str
char *

variable_types:
cx
unsigned int

return_type: void


decompiled_code:
__int64 __fastcall render_draw_line(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5)
{
unsigned int v7; // ebp
unsigned int v8; // ebx
__int64 result; // rax

if ( a1 < a3 || a2 < a4 )
{
v7 = a2;
v8 = a1;
while ( 1 )
{
vesa_get_pixel(a1, a2);
result = render_draw_pixel(v8, v7, a5);
if ( a3 <= v8 )
break;
++v8;
if ( a4 > v7 )
goto LABEL_5;
LABEL_6:
if ( a3 <= v8 && v7 >= a4 )
return result;
}
if ( a4 <= v7 )
return result;
LABEL_5:
++v7;
goto LABEL_6;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5)
{
unsigned int v7; // ebp
unsigned int v8; // ebx
__int64 result; // rax

if ( a1 < a3 || a2 < a4 )
{
v7 = a2;
v8 = a1;
while ( 1 )
{
vesa_get_pixel(a1, a2);
result = func2(v8, v7, a5);
if ( a3 <= v8 )
break;
++v8;
if ( a4 > v7 )
goto LABEL_5;
LABEL_6:
if ( a3 <= v8 && v7 >= a4 )
return result;
}
if ( a4 <= v7 )
return result;
LABEL_5:
++v7;
goto LABEL_6;
}
return result;
}

original_code:
void render_draw_line(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t col)
{
 uint32_t x = x0;
 uint32_t y = y0;
 while(x < x1 || y < y1)
 {
  uint32_t c = (vesa_get_pixel(x0, y0) + col) / 2;
  render_draw_pixel(x, y, col);
  if(x < x1) x++;
  if(y < y1) y++;
 }
}

canonical_original_code:
void render_draw_line(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int col)
{
 unsigned int x = x0;
 unsigned int y = y0;
 while(x < x1 || y < y1)
 {
  unsigned int c = (vesa_get_pixel(x0, y0) + col) / 2;
  render_draw_pixel(x, y, col);
  if(x < x1) x++;
  if(y < y1) y++;
 }
}

variable_types:
c
unsigned int


decompiled_code:
__int64 __fastcall render_draw_rect(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5)
{
render_draw_line(a1, a2, a1, a4, a5);
render_draw_line(a1, a2, a3, a2, a5);
render_draw_line(a3, a2, a3, a4, a5);
return render_draw_line(a1, a4, a3, a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5)
{
func5(a1, a2, a1, a4, a5);
func5(a1, a2, a3, a2, a5);
func5(a3, a2, a3, a4, a5);
return func5(a1, a4, a3, a4, a5);
}

original_code:
void render_draw_rect(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t col)
{
 render_draw_line(x0, y0, x0, y1, col);
 render_draw_line(x0, y0, x1, y0, col);
 render_draw_line(x1, y0, x1, y1, col);
 render_draw_line(x0, y1, x1, y1, col);
}

canonical_original_code:
void render_draw_rect(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int col)
{
 render_draw_line(x0, y0, x0, y1, col);
 render_draw_line(x0, y0, x1, y0, col);
 render_draw_line(x1, y0, x1, y1, col);
 render_draw_line(x0, y1, x1, y1, col);
}


decompiled_code:
__int64 __fastcall render_draw_rect_fill(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5)
{
unsigned int i; // ebx
__int64 result; // rax

for ( i = a2; a4 >= i; ++i )
result = render_draw_line(a1, i, a3, i, a5);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5)
{
unsigned int i; // ebx
__int64 result; // rax

for ( i = a2; a4 >= i; ++i )
result = func5(a1, i, a3, i, a5);
return result;
}

original_code:
void render_draw_rect_fill(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t fill)
{
 while(y0 <= y1)
 {
  render_draw_line(x0, y0, x1, y0, fill);
  y0++;
 }
}

canonical_original_code:
void render_draw_rect_fill(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int fill)
{
 while(y0 <= y1)
 {
  render_draw_line(x0, y0, x1, y0, fill);
  y0++;
 }
}

variable_types:
fill
unsigned int


decompiled_code:
__int64 __fastcall render_draw_rect_bordered(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, __int64 a5, int a6, int a7)
{
render_draw_rect_fill(a1, a2, a3, a4, a7);
return render_draw_rect(a1, a2, a3, a4, a6);
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, __int64 a5, int a6, int a7)
{
func7(a1, a2, a3, a4, a7);
return func6(a1, a2, a3, a4, a6);
}

original_code:
void render_draw_rect_bordered(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
        uint8_t border_pix, uint32_t border, uint32_t fill)
{
 render_draw_rect_fill(x0, y0, x1, y1, fill);
 render_draw_rect(x0, y0, x1, y1, border);
}

canonical_original_code:
void render_draw_rect_bordered(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned char border_pix, unsigned int border, unsigned int fill)
{
 render_draw_rect_fill(x0, y0, x1, y1, fill);
 render_draw_rect(x0, y0, x1, y1, border);
}

variable_types:
border
unsigned int


decompiled_code:
__int64 __fastcall render_draw_rect_fill_gradient(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5, int a6)
{
unsigned int v6; // ebx
int v9; // ebp
unsigned int v10; // ecx
__int64 result; // rax
unsigned int i; // er12

v6 = a2;
v9 = a5;
v10 = a4 - a2;
result = (a6 - a5) / v10;
for ( i = (a6 - a5) / v10; a4 >= v6; ++v6 )
{
result = render_draw_line(a1, v6, a3, v6, v9);
v9 += i;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5, int a6)
{
unsigned int v6; // ebx
int v9; // ebp
unsigned int v10; // ecx
__int64 result; // rax
unsigned int i; // er12

v6 = a2;
v9 = a5;
v10 = a4 - a2;
result = (a6 - a5) / v10;
for ( i = (a6 - a5) / v10; a4 >= v6; ++v6 )
{
result = func5(a1, v6, a3, v6, v9);
v9 += i;
}
return result;
}

original_code:
void render_draw_rect_fill_gradient(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t c1, uint32_t c2)
{
 uint32_t gr = (c2 - c1) / (y1 - y0);
 uint32_t cur = c1;
 while(y0 <= y1)
 {
  render_draw_line(x0, y0, x1, y0, (uint32_t) cur);
  cur = cur + gr;
  y0++;
 }
}

canonical_original_code:
void render_draw_rect_fill_gradient(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int c1, unsigned int c2)
{
 unsigned int gr = (c2 - c1) / (y1 - y0);
 unsigned int cur = c1;
 while(y0 <= y1)
 {
  render_draw_line(x0, y0, x1, y0, (unsigned int) cur);
  cur = cur + gr;
  y0++;
 }
}

variable_types:
gr
unsigned int

variable_types:
cur
unsigned int


decompiled_code:
__int64 __fastcall render_draw_rect_bordered_gradient(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, __int64 a5, int a6, int a7, int a8)
{
render_draw_rect_fill_gradient(a1, a2, a3, a4, a7, a8);
return render_draw_rect(a1, a2, a3, a4, a6);
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, __int64 a5, int a6, int a7, int a8)
{
func9(a1, a2, a3, a4, a7, a8);
return func6(a1, a2, a3, a4, a6);
}

original_code:
void render_draw_rect_bordered_gradient(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
        uint8_t border_pix, uint32_t border, uint32_t col1, uint32_t col2)
{
 render_draw_rect_fill_gradient(x0, y0, x1, y1, col1, col2);
 render_draw_rect(x0, y0, x1, y1, border);
}

canonical_original_code:
void render_draw_rect_bordered_gradient(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned char border_pix, unsigned int border, unsigned int col1, unsigned int col2)
{
 render_draw_rect_fill_gradient(x0, y0, x1, y1, col1, col2);
 render_draw_rect(x0, y0, x1, y1, border);
}


decompiled_code:
void __fastcall render_gimp_image(unsigned int *a1, int a2, unsigned int a3)
{
unsigned int i; // er12
unsigned int j; // ebx
unsigned int v7; // eax
__int64 v8; // rdi
unsigned int v9; // eax
unsigned int v10; // edx

for ( i = 0; a1[1] > i; ++a3 )
{
v7 = *a1;
for ( j = 0; *a1 > j; v7 = *a1 )
{
v8 = *((_QWORD *)a1 + 2);
v9 = 4 * (j + i * v7);
v10 = (*(unsigned __int8 *)(v8 + v9 + 3) << 24)
+ (*(unsigned __int8 *)(v8 + v9 + 1) << 8)
+ *(unsigned __int8 *)(v8 + v9 + 2)
+ (*(unsigned __int8 *)(v8 + v9) << 16);
if ( v10 > 0x22222222 )
render_draw_pixel(a2 + j, a3, v10);
++j;
}
++i;
}
}

canonical_decompiled_code:
void __fastcall func11(unsigned int *a1, int a2, unsigned int a3)
{
unsigned int i; // er12
unsigned int j; // ebx
unsigned int v7; // eax
__int64 v8; // rdi
unsigned int v9; // eax
unsigned int v10; // edx

for ( i = 0; a1[1] > i; ++a3 )
{
v7 = *a1;
for ( j = 0; *a1 > j; v7 = *a1 )
{
v8 = *((_QWORD *)a1 + 2);
v9 = 4 * (j + i * v7);
v10 = (*(unsigned __int8 *)(v8 + v9 + 3) << 24)
+ (*(unsigned __int8 *)(v8 + v9 + 1) << 8)
+ *(unsigned __int8 *)(v8 + v9 + 2)
+ (*(unsigned __int8 *)(v8 + v9) << 16);
if ( v10 > 0x22222222 )
func2(a2 + j, a3, v10);
++j;
}
++i;
}
}

original_code:
void render_gimp_image(gimp_image *gi, uint32_t x, uint32_t y)
{
 uint32_t i,j;
 for(i = 0; i < gi->height; i++)
  for(j = 0; j < gi->width; j++)
  {
   uint32_t col =
    (gi->pixel_data[((i*4*gi->width)+j*4)+3] << 24) +
    (gi->pixel_data[((i*4*gi->width)+j*4)+1] << 8) +
    (gi->pixel_data[((i*4*gi->width)+j*4)+2] << 0) +
    (gi->pixel_data[(i*4*gi->width)+j*4] << 16);
   if(col > 0x22222222)
    render_draw_pixel(x + j, y + i, col);
  }
}

canonical_original_code:
void render_gimp_image(struct gimp_image *gi, unsigned int x, unsigned int y)
{
 unsigned int i; unsigned int j;
 for(i = 0; i < gi->height; i++)
  for(j = 0; j < gi->width; j++)
  {
   unsigned int col = (gi->pixel_data[((i*4*gi->width)+j*4)+3] << 24) +
    (gi->pixel_data[((i*4*gi->width)+j*4)+1] << 8) +
    (gi->pixel_data[((i*4*gi->width)+j*4)+2] << 0) +
    (gi->pixel_data[(i*4*gi->width)+j*4] << 16);
   if(col > 0x22222222)
    render_draw_pixel(x + j, y + i, col);
  }
}

variable_types: struct gimp_image { unsigned int width; unsigned int height; unsigned int bytes_per_pixel; unsigned char *pixel_data; } *

variable_types:
i
unsigned int

variable_types:
j
unsigned int


decompiled_code:
void __fastcall render_bit_map(__int64 a1, int a2, unsigned int a3, unsigned int a4, unsigned int a5)
{
unsigned int v5[4]; // [rsp+0h] [rbp-28h] BYREF
__int64 v6; // [rsp+10h] [rbp-18h]

v5[0] = a4;
v5[1] = a5;
v6 = a1;
v5[2] = 4;
render_gimp_image(v5, a2, a3);
}

canonical_decompiled_code:
void __fastcall func12(__int64 a1, int a2, unsigned int a3, unsigned int a4, unsigned int a5)
{
unsigned int v5[4]; // [rsp+0h] [rbp-28h] BYREF
__int64 v6; // [rsp+10h] [rbp-18h]

v5[0] = a4;
v5[1] = a5;
v6 = a1;
v5[2] = 4;
func11(v5, a2, a3);
}

original_code:
void render_bit_map(uint32_t *data, uint32_t x, uint32_t y, uint32_t sx, uint32_t sy)
{
 gimp_image g;
 g.width = sx;
 g.height = sy;
 g.pixel_data = (char *) data;
 g.bytes_per_pixel = 4;
 render_gimp_image(&g, x, y);
}

canonical_original_code:
void render_bit_map(unsigned int *data, unsigned int x, unsigned int y, unsigned int sx, unsigned int sy)
{
 struct gimp_image g;
 g.width = sx;
 g.height = sy;
 g.pixel_data = (char *) data;
 g.bytes_per_pixel = 4;
 render_gimp_image(&g, x, y);
}

variable_types:
data
unsigned int *

variable_types:
sx
unsigned int

variable_types:
sy
unsigned int

variable_types: struct gimp_image { unsigned int width; unsigned int height; unsigned int bytes_per_pixel; unsigned char *pixel_data; }


decompiled_code:
void __fastcall render_draw_cursor(int a1, unsigned int a2)
{
render_bit_map((__int64)&cursor, a1, a2, 0xDu, 0xFu);
}

canonical_decompiled_code:
void __fastcall func13(int a1, unsigned int a2)
{
func12((__int64)&cursor, a1, a2, 0xDu, 0xFu);
}

original_code:
void render_draw_cursor(uint32_t x, uint32_t y)
{
  render_bit_map((uint32_t *) cursor, x, y, 13, 15);
 if(1==0)
 {
  render_draw_line(x - 5, y - 1, x + 5, y - 1, 0x0);
  render_draw_line(x - 5, y, x + 5, y, 0xFFFFFF);
  render_draw_line(x - 5, y + 1, x + 5, y + 1, 0x0);
  render_draw_line(x - 1, y - 5, x - 1, y + 5, 0x0);
  render_draw_line(x + 1, y - 5, x + 1, y + 5, 0x0);
  render_draw_line(x - 5, y, x + 5, y, 0xFFFFFF);
  render_draw_line(x, y - 5, x, y + 5, 0xFFFFFF);
 }
}

canonical_original_code:
void render_draw_cursor(unsigned int x, unsigned int y)
{
  render_bit_map((unsigned int *) cursor, x, y, 13, 15);
 if(1==0)
 {
  render_draw_line(x - 5, y - 1, x + 5, y - 1, 0x0);
  render_draw_line(x - 5, y, x + 5, y, 0xFFFFFF);
  render_draw_line(x - 5, y + 1, x + 5, y + 1, 0x0);
  render_draw_line(x - 1, y - 5, x - 1, y + 5, 0x0);
  render_draw_line(x + 1, y - 5, x + 1, y + 5, 0x0);
  render_draw_line(x - 5, y, x + 5, y, 0xFFFFFF);
  render_draw_line(x, y - 5, x, y + 5, 0xFFFFFF);
 }
}

variable_types:
x
unsigned int


decompiled_code:
void *__fastcall render_swap_buffer(void *a1, const void *a2, size_t a3)
{
void *result; // rax

result = memcpy(a1, a2, a3);
render_y1 = 0;
render_y0 = 0;
render_x1 = 0;
render_x0 = 0;
return result;
}

canonical_decompiled_code:
void *__fastcall func14(void *a1, const void *a2, size_t a3)
{
void *result; // rax

result = memcpy(a1, a2, a3);
render_y1 = 0;
render_y0 = 0;
render_x1 = 0;
render_x0 = 0;
return result;
}

original_code:
void render_swap_buffer(char *phys, char *ram, uint32_t size)
{
 memcpy(phys, ram, size);
 render_x0 = render_x1 = render_y0 = render_y1 = 0;
}

canonical_original_code:
void render_swap_buffer(char *phys, char *ram, unsigned int size)
{
 memcpy(phys, ram, size);
 render_x0 = render_x1 = render_y0 = render_y1 = 0;
}

variable_types:
phys
char *

variable_types:
ram
char *

variable_types:
size
unsigned int


decompiled_code:
void __fastcall idt_set_gate(unsigned __int8 a1, int a2, __int16 a3, char a4)
{
idt[4 * a1] = a2;
idt[4 * a1 + 3] = HIWORD(a2);
idt[4 * a1 + 1] = a3;
LOBYTE(idt[4 * a1 + 2]) = 0;
HIBYTE(idt[4 * a1 + 2]) = a4;
}

canonical_decompiled_code:
void __fastcall func0(unsigned __int8 a1, int a2, __int16 a3, char a4)
{
idt[4 * a1] = a2;
idt[4 * a1 + 3] = HIWORD(a2);
idt[4 * a1 + 1] = a3;
LOBYTE(idt[4 * a1 + 2]) = 0;
HIBYTE(idt[4 * a1 + 2]) = a4;
}

original_code:
void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags)
{
    idt[num].base_lo = (base & 0xFFFF);
    idt[num].base_hi = (base >> 16) & 0xFFFF;
    idt[num].sel = sel;
    idt[num].always0 = 0;
    idt[num].flags = flags;
}

variable_types:
num
unsigned char

variable_types:
base
unsigned long

variable_types:
sel
unsigned short

variable_types:
flags
unsigned char


decompiled_code:
__int64 idt_install()
{
idtp = 2047;
*(_DWORD *)(&idtp + 1) = (unsigned int)idt;
memset(idt, 0, 0x800uLL);
return idt_load();
}

canonical_decompiled_code:
__int64 func1()
{
idtp = 2047;
*(_DWORD *)(&idtp + 1) = (unsigned int)idt;
memset(idt, 0, 0x800uLL);
return idt_load();
}

original_code:
void idt_install()
{
    idtp.limit = (sizeof (struct idt_entry) * 256) - 1;
    idtp.base = (unsigned int) &idt;
    memset(&idt, 0, sizeof(struct idt_entry) * 256);
    idt_load();
}

user_defined_types: struct idt_entry { unsigned short base_lo; unsigned short sel; unsigned char always0; unsigned char flags; unsigned short base_hi; }


original_code:
void isrs_install()
{
    idt_set_gate(0, (unsigned)isr0, 0x08, 0x8E);
    idt_set_gate(1, (unsigned)isr1, 0x08, 0x8E);
    idt_set_gate(2, (unsigned)isr2, 0x08, 0x8E);
    idt_set_gate(3, (unsigned)isr3, 0x08, 0x8E);
    idt_set_gate(4, (unsigned)isr4, 0x08, 0x8E);
    idt_set_gate(5, (unsigned)isr5, 0x08, 0x8E);
    idt_set_gate(6, (unsigned)isr6, 0x08, 0x8E);
    idt_set_gate(7, (unsigned)isr7, 0x08, 0x8E);
    idt_set_gate(8, (unsigned)isr8, 0x08, 0x8E);
    idt_set_gate(9, (unsigned)isr9, 0x08, 0x8E);
    idt_set_gate(10, (unsigned)isr10, 0x08, 0x8E);
    idt_set_gate(11, (unsigned)isr11, 0x08, 0x8E);
    idt_set_gate(12, (unsigned)isr12, 0x08, 0x8E);
    idt_set_gate(13, (unsigned)isr13, 0x08, 0x8E);
    idt_set_gate(14, (unsigned)isr14, 0x08, 0x8E);
    idt_set_gate(15, (unsigned)isr15, 0x08, 0x8E);
    idt_set_gate(16, (unsigned)isr16, 0x08, 0x8E);
    idt_set_gate(17, (unsigned)isr17, 0x08, 0x8E);
    idt_set_gate(18, (unsigned)isr18, 0x08, 0x8E);
    idt_set_gate(19, (unsigned)isr19, 0x08, 0x8E);
    idt_set_gate(20, (unsigned)isr20, 0x08, 0x8E);
    idt_set_gate(21, (unsigned)isr21, 0x08, 0x8E);
    idt_set_gate(22, (unsigned)isr22, 0x08, 0x8E);
    idt_set_gate(23, (unsigned)isr23, 0x08, 0x8E);
    idt_set_gate(24, (unsigned)isr24, 0x08, 0x8E);
    idt_set_gate(25, (unsigned)isr25, 0x08, 0x8E);
    idt_set_gate(26, (unsigned)isr26, 0x08, 0x8E);
    idt_set_gate(27, (unsigned)isr27, 0x08, 0x8E);
    idt_set_gate(28, (unsigned)isr28, 0x08, 0x8E);
    idt_set_gate(29, (unsigned)isr29, 0x08, 0x8E);
    idt_set_gate(30, (unsigned)isr30, 0x08, 0x8E);
    idt_set_gate(31, (unsigned)isr31, 0x08, 0x8E);
}

canonical_original_code:
void isrs_install()
{
    idt_set_gate(0, (unsigned int)isr0, 0x08, 0x8E);
    idt_set_gate(1, (unsigned int)isr1, 0x08, 0x8E);
    idt_set_gate(2, (unsigned int)isr2, 0x08, 0x8E);
    idt_set_gate(3, (unsigned int)isr3, 0x08, 0x8E);
    idt_set_gate(4, (unsigned int)isr4, 0x08, 0x8E);
    idt_set_gate(5, (unsigned int)isr5, 0x08, 0x8E);
    idt_set_gate(6, (unsigned int)isr6, 0x08, 0x8E);
    idt_set_gate(7, (unsigned int)isr7, 0x08, 0x8E);
    idt_set_gate(8, (unsigned int)isr8, 0x08, 0x8E);
    idt_set_gate(9, (unsigned int)isr9, 0x08, 0x8E);
    idt_set_gate(10, (unsigned int)isr10, 0x08, 0x8E);
    idt_set_gate(11, (unsigned int)isr11, 0x08, 0x8E);
    idt_set_gate(12, (unsigned int)isr12, 0x08, 0x8E);
    idt_set_gate(13, (unsigned int)isr13, 0x08, 0x8E);
    idt_set_gate(14, (unsigned int)isr14, 0x08, 0x8E);
    idt_set_gate(15, (unsigned int)isr15, 0x08, 0x8E);
    idt_set_gate(16, (unsigned int)isr16, 0x08, 0x8E);
    idt_set_gate(17, (unsigned int)isr17, 0x08, 0x8E);
    idt_set_gate(18, (unsigned int)isr18, 0x08, 0x8E);
    idt_set_gate(19, (unsigned int)isr19, 0x08, 0x8E);
    idt_set_gate(20, (unsigned int)isr20, 0x08, 0x8E);
    idt_set_gate(21, (unsigned int)isr21, 0x08, 0x8E);
    idt_set_gate(22, (unsigned int)isr22, 0x08, 0x8E);
    idt_set_gate(23, (unsigned int)isr23, 0x08, 0x8E);
    idt_set_gate(24, (unsigned int)isr24, 0x08, 0x8E);
    idt_set_gate(25, (unsigned int)isr25, 0x08, 0x8E);
    idt_set_gate(26, (unsigned int)isr26, 0x08, 0x8E);
    idt_set_gate(27, (unsigned int)isr27, 0x08, 0x8E);
    idt_set_gate(28, (unsigned int)isr28, 0x08, 0x8E);
    idt_set_gate(29, (unsigned int)isr29, 0x08, 0x8E);
    idt_set_gate(30, (unsigned int)isr30, 0x08, 0x8E);
    idt_set_gate(31, (unsigned int)isr31, 0x08, 0x8E);
}


decompiled_code:
void __fastcall fault_handler(__int64 a1)
{
if ( *(_DWORD *)(a1 + 48) <= 0x1Fu )
{
video_puts("Error! '");
video_puts((&exception_messages)[*(unsigned int *)(a1 + 48)]);
video_puts("' System Halted!\n");
while ( 1 )
;
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1)
{
if ( *(_DWORD *)(a1 + 48) <= 0x1Fu )
{
video_puts("Error! '");
video_puts((&exception_messages)[*(unsigned int *)(a1 + 48)]);
video_puts("' System Halted!\n");
while ( 1 )
;
}
}

original_code:
void fault_handler(regs_t *r)
{
    if (r->which_int < 32)
    {
        video_puts("Error! '");
        video_puts(exception_messages[r->which_int]);
        video_puts("' System Halted!\n");
        for (;;);
    }
}

canonical_original_code:
void fault_handler(struct regs_t *r)
{
    if (r->which_int < 32)
    {
        video_puts("Error! '");
        video_puts(exception_messages[r->which_int]);
        video_puts("' System Halted!\n");
        for (;;);
    }
}

variable_types: struct regs_t { unsigned int edi; unsigned int ds; unsigned int which_int; unsigned int eip; } *


decompiled_code:
unsigned __int64 __fastcall gdt_set_gate(int a1, unsigned __int64 a2, int a3, char a4, char a5)
{
unsigned __int64 result; // rax

gdt[4 * a1 + 1] = a2;
result = a2 >> 16;
LOBYTE(gdt[4 * a1 + 2]) = BYTE2(a2);
HIBYTE(gdt[4 * a1 + 3]) = BYTE3(a2);
gdt[4 * a1] = a3;
LOBYTE(gdt[4 * a1 + 3]) = a5 & 0xF0 | BYTE2(a3) & 0xF;
HIBYTE(gdt[4 * a1 + 2]) = a4;
return result;
}

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

gdt[4 * a1 + 1] = a2;
result = a2 >> 16;
LOBYTE(gdt[4 * a1 + 2]) = BYTE2(a2);
HIBYTE(gdt[4 * a1 + 3]) = BYTE3(a2);
gdt[4 * a1] = a3;
LOBYTE(gdt[4 * a1 + 3]) = a5 & 0xF0 | BYTE2(a3) & 0xF;
HIBYTE(gdt[4 * a1 + 2]) = a4;
return result;
}

original_code:
void gdt_set_gate(int num, unsigned long base, unsigned long limit, unsigned char access, unsigned char gran)
{
 gdt[num].base_low = (base & 0xFFFF);
 gdt[num].base_middle = (base >> 16) & 0xFF;
 gdt[num].base_high = (base >> 24) & 0xFF;
 gdt[num].limit_low = (limit & 0xFFFF);
 gdt[num].granularity = ((limit >> 16) & 0x0F);
 gdt[num].granularity |= (gran & 0xF0);
 gdt[num].access = access;
}

variable_types: num int

variable_types:
limit
unsigned long

variable_types:
access
unsigned char

variable_types:
gran
unsigned char


original_code:
void gdt_install()
{
    gp.limit = (sizeof(struct gdt_entry) * 3) - 1;
    gp.base = (unsigned int) &gdt;
    gdt_set_gate(0, 0, 0, 0, 0);
    gdt_set_gate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF);
    gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
 gdt_set_gate(3, 0, 0xFFFFFFFF, 0xFA, 0xCF);
 gdt_set_gate(4, 0, 0xFFFFFFFF, 0xF2, 0xCF);
 gdt_flush((uint32_t)&gp);
}

canonical_original_code:
void gdt_install()
{
    gp.limit = (sizeof(struct gdt_entry) * 3) - 1;
    gp.base = (unsigned int) &gdt;
    gdt_set_gate(0, 0, 0, 0, 0);
    gdt_set_gate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF);
    gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
 gdt_set_gate(3, 0, 0xFFFFFFFF, 0xFA, 0xCF);
 gdt_set_gate(4, 0, 0xFFFFFFFF, 0xF2, 0xCF);
 gdt_flush((unsigned int)&gp);
}

user_defined_types: struct gdt_entry { unsigned short limit_low; unsigned short base_low; unsigned char base_middle; unsigned char access; unsigned char granularity; unsigned char base_high; }


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

result = (unsigned int)(a1 - 1);
if ( (unsigned __int8)(a1 - 1) <= 0xEu )
irq_routines[(unsigned __int8)a1] = a2;
return result;
}

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

result = (unsigned int)(a1 - 1);
if ( (unsigned __int8)(a1 - 1) <= 0xEu )
irq_routines[(unsigned __int8)a1] = a2;
return result;
}

original_code:
void handler_reg(uint8_t irq, void (*handler)(regs_t *r))
{
    if(irq > 0 && irq < 16) irq_routines[irq] = handler;
}

canonical_original_code:
void handler_reg(unsigned char irq, void (*handler)(struct regs_t *r))
{
    if(irq > 0 && irq < 16) irq_routines[irq] = handler;
}

variable_types:
irq
unsigned char

variable_types: void (*)(struct regs_t { unsigned int edi; unsigned int ds; unsigned int which_int; unsigned int eip; } *r)


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

result = (unsigned int)(a1 - 1);
if ( (unsigned __int8)(a1 - 1) <= 0xEu )
irq_routines[(unsigned __int8)a1] = 0LL;
return result;
}

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

result = (unsigned int)(a1 - 1);
if ( (unsigned __int8)(a1 - 1) <= 0xEu )
irq_routines[(unsigned __int8)a1] = 0LL;
return result;
}

original_code:
void handler_unreg(uint8_t irq)
{
    if(irq > 0 && irq < 16) irq_routines[irq] = 0;
}

canonical_original_code:
void handler_unreg(unsigned char irq)
{
    if(irq > 0 && irq < 16) irq_routines[irq] = 0;
}


decompiled_code:
__int64 irq_remap()
{
io_outb(32LL, 17LL);
io_outb(160LL, 17LL);
io_outb(33LL, 32LL);
io_outb(161LL, 40LL);
io_outb(33LL, 4LL);
io_outb(161LL, 2LL);
io_outb(33LL, 1LL);
io_outb(161LL, 1LL);
io_outb(33LL, 0LL);
return io_outb(161LL, 0LL);
}

canonical_decompiled_code:
__int64 func8()
{
io_outb(32LL, 17LL);
io_outb(160LL, 17LL);
io_outb(33LL, 32LL);
io_outb(161LL, 40LL);
io_outb(33LL, 4LL);
io_outb(161LL, 2LL);
io_outb(33LL, 1LL);
io_outb(161LL, 1LL);
io_outb(33LL, 0LL);
return io_outb(161LL, 0LL);
}


decompiled_code:
void irq_install()
{
irq_remap();
idt_set_gate(0x20u, (int)&irq0, 8, 142);
idt_set_gate(0x21u, (int)&irq1, 8, 142);
idt_set_gate(0x22u, (int)&irq2, 8, 142);
idt_set_gate(0x23u, (int)&irq3, 8, 142);
idt_set_gate(0x24u, (int)&irq4, 8, 142);
idt_set_gate(0x25u, (int)&irq5, 8, 142);
idt_set_gate(0x26u, (int)&irq6, 8, 142);
idt_set_gate(0x27u, (int)&irq7, 8, 142);
idt_set_gate(0x28u, (int)&irq8, 8, 142);
idt_set_gate(0x29u, (int)&irq9, 8, 142);
idt_set_gate(0x2Au, (int)&irq10, 8, 142);
idt_set_gate(0x2Bu, (int)&irq11, 8, 142);
idt_set_gate(0x2Cu, (int)&irq12, 8, 142);
idt_set_gate(0x2Du, (int)&irq13, 8, 142);
idt_set_gate(0x2Eu, (int)&irq14, 8, 142);
idt_set_gate(0x2Fu, (int)&irq15, 8, 142);
}

original_code:
void irq_install()
{
    irq_remap();
    idt_set_gate(32, (unsigned)irq0, 0x08, 0x8E);
    idt_set_gate(33, (unsigned)irq1, 0x08, 0x8E);
    idt_set_gate(34, (unsigned)irq2, 0x08, 0x8E);
    idt_set_gate(35, (unsigned)irq3, 0x08, 0x8E);
    idt_set_gate(36, (unsigned)irq4, 0x08, 0x8E);
    idt_set_gate(37, (unsigned)irq5, 0x08, 0x8E);
    idt_set_gate(38, (unsigned)irq6, 0x08, 0x8E);
    idt_set_gate(39, (unsigned)irq7, 0x08, 0x8E);
    idt_set_gate(40, (unsigned)irq8, 0x08, 0x8E);
    idt_set_gate(41, (unsigned)irq9, 0x08, 0x8E);
    idt_set_gate(42, (unsigned)irq10, 0x08, 0x8E);
    idt_set_gate(43, (unsigned)irq11, 0x08, 0x8E);
    idt_set_gate(44, (unsigned)irq12, 0x08, 0x8E);
    idt_set_gate(45, (unsigned)irq13, 0x08, 0x8E);
    idt_set_gate(46, (unsigned)irq14, 0x08, 0x8E);
    idt_set_gate(47, (unsigned)irq15, 0x08, 0x8E);
}

canonical_original_code:
void irq_install()
{
    irq_remap();
    idt_set_gate(32, (unsigned int)irq0, 0x08, 0x8E);
    idt_set_gate(33, (unsigned int)irq1, 0x08, 0x8E);
    idt_set_gate(34, (unsigned int)irq2, 0x08, 0x8E);
    idt_set_gate(35, (unsigned int)irq3, 0x08, 0x8E);
    idt_set_gate(36, (unsigned int)irq4, 0x08, 0x8E);
    idt_set_gate(37, (unsigned int)irq5, 0x08, 0x8E);
    idt_set_gate(38, (unsigned int)irq6, 0x08, 0x8E);
    idt_set_gate(39, (unsigned int)irq7, 0x08, 0x8E);
    idt_set_gate(40, (unsigned int)irq8, 0x08, 0x8E);
    idt_set_gate(41, (unsigned int)irq9, 0x08, 0x8E);
    idt_set_gate(42, (unsigned int)irq10, 0x08, 0x8E);
    idt_set_gate(43, (unsigned int)irq11, 0x08, 0x8E);
    idt_set_gate(44, (unsigned int)irq12, 0x08, 0x8E);
    idt_set_gate(45, (unsigned int)irq13, 0x08, 0x8E);
    idt_set_gate(46, (unsigned int)irq14, 0x08, 0x8E);
    idt_set_gate(47, (unsigned int)irq15, 0x08, 0x8E);
}


decompiled_code:
__int64 __fastcall irq_handler(__int64 a1)
{
void (*v1)(void); // rax

v1 = (void (*)(void))irq_routines[*(_DWORD *)(a1 + 48) - 32];
if ( v1 )
v1();
if ( *(_DWORD *)(a1 + 48) > 0x27u )
io_outb(160LL, 32LL);
return io_outb(32LL, 32LL);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
void (*v1)(void); // rax

v1 = (void (*)(void))irq_routines[*(_DWORD *)(a1 + 48) - 32];
if ( v1 )
v1();
if ( *(_DWORD *)(a1 + 48) > 0x27u )
io_outb(160LL, 32LL);
return io_outb(32LL, 32LL);
}

original_code:
void irq_handler(regs_t *r)
{
    void (*handler)(regs_t *r);
    handler = irq_routines[r->which_int - 32];
    if (handler)
    {
        handler(r);
    }
    if (r->which_int >= 40)
        io_outb(0xA0, 0x20);
    io_outb(0x20, 0x20);
}

canonical_original_code:
void irq_handler(struct regs_t *r)
{
    void (*handler)(struct regs_t *r);
    handler = irq_routines[r->which_int - 32];
    if (handler)
    {
        handler(r);
    }
    if (r->which_int >= 40)
        io_outb(0xA0, 0x20);
    io_outb(0x20, 0x20);
}

user_defined_types: struct regs_t { unsigned int edi; unsigned int ds; unsigned int which_int; unsigned int eip; }


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

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

original_code:
uint32_t sys_void()
{
 return 0;
}

canonical_original_code:
unsigned int sys_void()
{
 return 0;
}

return_type: unsigned int


decompiled_code:
int sys_getch()
{
return getchar();
}

canonical_decompiled_code:
int func1()
{
return getchar();
}

original_code:
int sys_getch()
{
 return getchar();
}

canonical_original_code:
int sys_getch()
{
 return getchar();
}

return_type: int


decompiled_code:
int __fastcall sys_putch(char a1)
{
return putchar(a1);
}

canonical_decompiled_code:
int __fastcall func2(char a1)
{
return putchar(a1);
}

original_code:
int sys_putch(uint32_t c)
{
 putchar((char) c);
}

canonical_original_code:
int sys_putch(unsigned int c)
{
 putchar((char) c);
}

variable_types:
c
unsigned int


decompiled_code:
__int64 __fastcall sys_mount(unsigned int a1, unsigned int a2, unsigned int a3)
{
return fs_mount(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, unsigned int a2, unsigned int a3)
{
return fs_mount(a1, a2, a3);
}

original_code:
int sys_mount(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
{
 return fs_mount((char *) a, (char *) b, (char *) c, (uint32_t) d);
}

canonical_original_code:
int sys_mount(unsigned int a, unsigned int b, unsigned int c, unsigned int d)
{
 return fs_mount((char *) a, (char *) b, (char *) c, (unsigned int) d);
}

variable_types:
a
unsigned int

variable_types:
b
unsigned int

variable_types:
d
unsigned int


decompiled_code:
__int64 __fastcall sys_umount(unsigned int a1)
{
return fs_umount(a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1)
{
return fs_umount(a1);
}

original_code:
int sys_umount(uint32_t a)
{
 return fs_umount((char *) a);
}

canonical_original_code:
int sys_umount(unsigned int a)
{
 return fs_umount((char *) a);
}


decompiled_code:
__int64 __fastcall sys_iget_mount_point(__int64 a1, unsigned int a2)
{
return fs_iget_mount_point(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned int a2)
{
return fs_iget_mount_point(a1, a2);
}

original_code:
int sys_iget_mount_point(uint32_t a, uint32_t b)
{
 return fs_iget_mount_point((uint32_t) a, (mount_point_t **) b);
}

canonical_original_code:
int sys_iget_mount_point(unsigned int a, unsigned int b)
{
 return fs_iget_mount_point((unsigned int) a, (struct mount_point_p **) b);
}

user_defined_types: struct mount_point_p { char path[512]; char dev[512]; char fs[512]; void *fs_struct; struct inode_p *root; struct inode_p *childs; unsigned char used; }

user_defined_types: struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; }


decompiled_code:
__int64 __fastcall sys_readdir(unsigned int a1, unsigned int a2)
{
return fs_readdir(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1, unsigned int a2)
{
return fs_readdir(a1, a2);
}

original_code:
int sys_readdir(uint32_t a, uint32_t b)
{
 return fs_readdir((dir_t *) a, (struct dirent *) b);
}

canonical_original_code:
int sys_readdir(unsigned int a, unsigned int b)
{
 return fs_readdir((struct dir_p *) a, (struct dirent *) b);
}

user_defined_types: struct dir_p { struct file_p *f; char *d_name; unsigned int cur_i; char path[512]; }

user_defined_types: struct dirent { char name[255]; unsigned int inode; }

user_defined_types: struct file_p { unsigned int id; unsigned long long seek_p; unsigned long long size; struct inode_p *node; void *drv; struct file_p *next; }


decompiled_code:
__int64 __fastcall sys_opendir(unsigned int a1)
{
return fs_opendir(a1);
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1)
{
return fs_opendir(a1);
}

original_code:
int sys_opendir(uint32_t a)
{
 return (int) fs_opendir((char *) a);
}

canonical_original_code:
int sys_opendir(unsigned int a)
{
 return (int) fs_opendir((char *) a);
}


decompiled_code:
__int64 __fastcall sys_closedir(unsigned int a1)
{
return fs_closedir(a1);
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1)
{
return fs_closedir(a1);
}

original_code:
int sys_closedir(uint32_t a)
{
 return fs_closedir((dir_t *) a);
}

canonical_original_code:
int sys_closedir(unsigned int a)
{
 return fs_closedir((struct dir_p *) a);
}


decompiled_code:
__int64 __fastcall sys_rewinddir(unsigned int a1)
{
return fs_rewinddir(a1);
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1)
{
return fs_rewinddir(a1);
}

original_code:
int sys_rewinddir(uint32_t a)
{
 return fs_rewinddir((dir_t *) a);
}

canonical_original_code:
int sys_rewinddir(unsigned int a)
{
 return fs_rewinddir((struct dir_p *) a);
}


decompiled_code:
__int64 __fastcall sys_makedir(unsigned int a1)
{
return fs_makedir(a1);
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1)
{
return fs_makedir(a1);
}

original_code:
int sys_makedir(uint32_t a)
{
 return fs_makedir((char *) a);
}

canonical_original_code:
int sys_makedir(unsigned int a)
{
 return fs_makedir((char *) a);
}


decompiled_code:
__int64 __fastcall sys_rm(unsigned int a1)
{
return fs_rm(a1);
}

canonical_decompiled_code:
__int64 __fastcall func11(unsigned int a1)
{
return fs_rm(a1);
}

original_code:
int sys_rm(uint32_t a)
{
 return fs_rm((char *) a);
}

canonical_original_code:
int sys_rm(unsigned int a)
{
 return fs_rm((char *) a);
}


decompiled_code:
__int64 __fastcall sys_read(unsigned int a1, unsigned int a2)
{
return fs_read(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned int a1, unsigned int a2)
{
return fs_read(a1, a2);
}

original_code:
int sys_read(uint32_t a, uint32_t b, uint32_t c)
{
 return fs_read((file_t *) a, (char *) b, (uint32_t) c);
}

canonical_original_code:
int sys_read(unsigned int a, unsigned int b, unsigned int c)
{
 return fs_read((struct file_p *) a, (char *) b, (unsigned int) c);
}


decompiled_code:
__int64 __fastcall sys_open(unsigned int a1, unsigned int a2)
{
return fs_open(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func13(unsigned int a1, unsigned int a2)
{
return fs_open(a1, a2);
}

original_code:
int sys_open(uint32_t a, uint32_t b)
{
 return (int) fs_open((char *) a, (char *) b);
}

canonical_original_code:
int sys_open(unsigned int a, unsigned int b)
{
 return (int) fs_open((char *) a, (char *) b);
}


decompiled_code:
__int64 __fastcall sys_close(unsigned int a1)
{
return fs_close(a1);
}

canonical_decompiled_code:
__int64 __fastcall func14(unsigned int a1)
{
return fs_close(a1);
}

original_code:
int sys_close(uint32_t a)
{
 return fs_close((file_t *) a);
}

canonical_original_code:
int sys_close(unsigned int a)
{
 return fs_close((struct file_p *) a);
}


decompiled_code:
__int64 __fastcall sys_write(unsigned int a1, unsigned int a2)
{
return fs_write(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned int a1, unsigned int a2)
{
return fs_write(a1, a2);
}

original_code:
int sys_write(uint32_t a, uint32_t b, uint32_t c)
{
 return fs_write((file_t *) a, (char *) b, (uint32_t) c);
}

canonical_original_code:
int sys_write(unsigned int a, unsigned int b, unsigned int c)
{
 return fs_write((struct file_p *) a, (char *) b, (unsigned int) c);
}


decompiled_code:
__int64 __fastcall sys_seek(unsigned int a1, unsigned __int8 a2, unsigned int a3)
{
return fs_seek(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned int a1, unsigned __int8 a2, unsigned int a3)
{
return fs_seek(a1, a2, a3);
}

original_code:
int sys_seek(uint32_t a, uint32_t b, uint32_t c)
{
 return fs_seek((file_t *) a, (uint32_t) b, (uint64_t) c);
}

canonical_original_code:
int sys_seek(unsigned int a, unsigned int b, unsigned int c)
{
 return fs_seek((struct file_p *) a, (unsigned int) b, (unsigned long long) c);
}


decompiled_code:
__int64 __fastcall sys_link(unsigned int a1, unsigned int a2)
{
return fs_link(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func17(unsigned int a1, unsigned int a2)
{
return fs_link(a1, a2);
}

original_code:
uint32_t sys_link(uint32_t a, uint32_t b)
{
 return fs_link((char *) a, (char *) b);
}

canonical_original_code:
unsigned int sys_link(unsigned int a, unsigned int b)
{
 return fs_link((char *) a, (char *) b);
}


decompiled_code:
__int64 __fastcall sys_unlink(unsigned int a1)
{
return fs_unlink(a1);
}

canonical_decompiled_code:
__int64 __fastcall func18(unsigned int a1)
{
return fs_unlink(a1);
}

original_code:
uint32_t sys_unlink(uint32_t a)
{
 return fs_unlink((char *) a);
}

canonical_original_code:
unsigned int sys_unlink(unsigned int a)
{
 return fs_unlink((char *) a);
}


decompiled_code:
__int64 __fastcall sys_device_iget(__int64 a1, unsigned int a2)
{
return device_iget(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, unsigned int a2)
{
return device_iget(a1, a2);
}

original_code:
uint32_t sys_device_iget(uint32_t a, uint32_t b)
{
 return device_iget((uint32_t) a, (device_t **) b);
}

canonical_original_code:
unsigned int sys_device_iget(unsigned int a, unsigned int b)
{
 return device_iget((unsigned int) a, (struct device_p **) b);
}

user_defined_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; }


decompiled_code:
__int64 sys_device_update()
{
device_update();
return 0LL;
}

canonical_decompiled_code:
__int64 func20()
{
device_update();
return 0LL;
}

original_code:
uint32_t sys_device_update()
{
 device_update();
 return 0;
}

canonical_original_code:
unsigned int sys_device_update()
{
 device_update();
 return 0;
}


decompiled_code:
__int64 sys_message_clear()
{
message_clear();
return 0LL;
}

canonical_decompiled_code:
__int64 func21()
{
message_clear();
return 0LL;
}

original_code:
uint32_t sys_message_clear()
{
 message_clear();
 return 0;
}

canonical_original_code:
unsigned int sys_message_clear()
{
 message_clear();
 return 0;
}


decompiled_code:
__int64 __fastcall sys_message_send(__int64 a1, unsigned int a2)
{
return message_send(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1, unsigned int a2)
{
return message_send(a1, a2);
}

original_code:
uint32_t sys_message_send(uint32_t a, uint32_t b, uint32_t c)
{
 return message_send((pid_t) a, (char *) b, (uint32_t) c);
}

canonical_original_code:
unsigned int sys_message_send(unsigned int a, unsigned int b, unsigned int c)
{
 return message_send((int) a, (char *) b, (unsigned int) c);
}


decompiled_code:
__int64 __fastcall sys_driver_add(unsigned int a1)
{
return driver_add(a1);
}

canonical_decompiled_code:
__int64 __fastcall func23(unsigned int a1)
{
return driver_add(a1);
}

original_code:
uint32_t sys_driver_add(uint32_t a)
{
 return driver_add((driver_t *) a);
}

canonical_original_code:
unsigned int sys_driver_add(unsigned int a)
{
 return driver_add((struct driver_p *) a);
}

user_defined_types: struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t fs; struct driver_video_t video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; }

user_defined_types: struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; }

user_defined_types: struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); }

user_defined_types: struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; }


decompiled_code:
__int64 __fastcall sys_driver_del(unsigned int a1)
{
return driver_del(a1);
}

canonical_decompiled_code:
__int64 __fastcall func24(unsigned int a1)
{
return driver_del(a1);
}

original_code:
uint32_t sys_driver_del(uint32_t a)
{
 return driver_del((char *) a);
}

canonical_original_code:
unsigned int sys_driver_del(unsigned int a)
{
 return driver_del((char *) a);
}


decompiled_code:
__int64 __fastcall sys_driver_iget(__int64 a1, unsigned int a2)
{
return driver_iget(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func25(__int64 a1, unsigned int a2)
{
return driver_iget(a1, a2);
}

original_code:
uint32_t sys_driver_iget(uint32_t a, uint32_t b)
{
 return driver_iget((uint32_t) a, (driver_t **) b);
}

canonical_original_code:
unsigned int sys_driver_iget(unsigned int a, unsigned int b)
{
 return driver_iget((unsigned int) a, (struct driver_p **) b);
}


decompiled_code:
__int64 __fastcall sys_driver_initd(unsigned int a1)
{
return (unsigned __int8)driver_initd(a1);
}

canonical_decompiled_code:
__int64 __fastcall func26(unsigned int a1)
{
return (unsigned __int8)driver_initd(a1);
}

original_code:
uint32_t sys_driver_initd(uint32_t a)
{
 return driver_initd((char *) a);
}

canonical_original_code:
unsigned int sys_driver_initd(unsigned int a)
{
 return driver_initd((char *) a);
}


decompiled_code:
__int64 __fastcall sys_driver_freed(unsigned int a1)
{
return (unsigned __int8)driver_freed(a1);
}

canonical_decompiled_code:
__int64 __fastcall func27(unsigned int a1)
{
return (unsigned __int8)driver_freed(a1);
}

original_code:
uint32_t sys_driver_freed(uint32_t a)
{
 return driver_freed((char *) a);
}

canonical_original_code:
unsigned int sys_driver_freed(unsigned int a)
{
 return driver_freed((char *) a);
}


decompiled_code:
__int64 __fastcall sys_message_recv(unsigned int a1, unsigned int a2)
{
return message_recv(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func28(unsigned int a1, unsigned int a2)
{
return message_recv(a1, a2);
}

original_code:
uint32_t sys_message_recv(uint32_t a, uint32_t b)
{
 return message_recv((char *) a, (pid_t *) b);
}

canonical_original_code:
unsigned int sys_message_recv(unsigned int a, unsigned int b)
{
 return message_recv((char *) a, (int *) b);
}


decompiled_code:
__int64 sys_test()
{
_enable();
bish();
return 0LL;
}

canonical_decompiled_code:
__int64 func29()
{
_enable();
bish();
return 0LL;
}

original_code:
uint32_t sys_test()
{
 asm("sti");
 bish();
 return 0;
}

canonical_original_code:
unsigned int sys_test()
{
 asm("sti");
 bish();
 return 0;
}


decompiled_code:
__int64 sys_millisleep()
{
return arch_sleep();
}

canonical_decompiled_code:
__int64 func30()
{
return arch_sleep();
}

original_code:
uint32_t sys_millisleep(uint32_t a)
{
 arch_sleep(a);
}

canonical_original_code:
unsigned int sys_millisleep(unsigned int a)
{
 arch_sleep(a);
}


decompiled_code:
__int64 sys_task_sleepms()
{
return task_sleep_ms();
}

canonical_decompiled_code:
__int64 func31()
{
return task_sleep_ms();
}

original_code:
uint32_t sys_task_sleepms(uint32_t a)
{
 task_sleep_ms(a);
}

canonical_original_code:
unsigned int sys_task_sleepms(unsigned int a)
{
 task_sleep_ms(a);
}


decompiled_code:
__int64 __fastcall sys_driver_puts(unsigned int a1, __int64 a2, unsigned int a3)
{
return driver_puts(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func32(unsigned int a1, __int64 a2, unsigned int a3)
{
return driver_puts(a1, a2, a3);
}

original_code:
uint32_t sys_driver_puts(uint32_t a, uint32_t b, uint32_t c)
{
 driver_puts((driver_t *) a, b, (char *) c);
}

canonical_original_code:
unsigned int sys_driver_puts(unsigned int a, unsigned int b, unsigned int c)
{
 driver_puts((struct driver_p *) a, b, (char *) c);
}


decompiled_code:
__int64 __fastcall syscall_call5()
{
__int64 result; // rax

__asm { int 84h }
return (unsigned int)result;
}

canonical_decompiled_code:
__int64 __fastcall func33()
{
__int64 result; // rax

__asm { int 84h }
return (unsigned int)result;
}

original_code:
int syscall_call5(uint32_t call, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4, uint32_t p5)
{
 int ret;
 asm ("int %0\n" : : "g" (0x84));
 asm ("movl %%eax, %0\n\t" : "=r" (ret));
 return ret;
}

canonical_original_code:
int syscall_call5(unsigned int call, unsigned int p1, unsigned int p2, unsigned int p3, unsigned int p4, unsigned int p5)
{
 int ret;
 asm ("int %0\n" : : "g" (0x84));
 asm ("movl %%eax, %0\n\t" : "=r" (ret));
 return ret;
}

variable_types:
call
unsigned int

variable_types: ret int


decompiled_code:
__int64 __fastcall syscall_callback(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 result; // rax
unsigned int v5; // ebx

result = (unsigned int)result;
if ( syscalls_number >= (unsigned int)result )
{
switch ( syscalls[4 * (unsigned int)result] )
{
case 0:
case 1:
case 2:
LODWORD(result) = ((__int64 (__fastcall *)(_QWORD, _QWORD, __int64))off_66C8[2 * (unsigned int)result])(
v5,
a4,
16LL * (unsigned int)result);
break;
default:
LODWORD(result) = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_66C8[2 * (unsigned int)result])(
v5,
a4,
0LL);
break;
}
result = (unsigned int)result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func34(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 result; // rax
unsigned int v5; // ebx

result = (unsigned int)result;
if ( syscalls_number >= (unsigned int)result )
{
switch ( syscalls[4 * (unsigned int)result] )
{
case 0:
case 1:
case 2:
LODWORD(result) = ((__int64 (__fastcall *)(_QWORD, _QWORD, __int64))off_66C8[2 * (unsigned int)result])(
v5,
a4,
16LL * (unsigned int)result);
break;
default:
LODWORD(result) = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_66C8[2 * (unsigned int)result])(
v5,
a4,
0LL);
break;
}
result = (unsigned int)result;
}
return result;
}

original_code:
void syscall_callback(regs_t *r)
{
 int ret;
 uint32_t p1, p2, p3, p4, p5, call;
 asm("mov %%eax, %0\n" : "=r" (call));
 asm("mov %%ebx, %0\n" : "=r" (p1));
 asm("mov %%ecx, %0\n" : "=r" (p2));
 if(call > syscalls_number)
  return;
 switch(syscalls[call].arg)
 {
  case 0:
   ret = syscalls[call].call();
   break;
  case 1:
   ret = syscalls[call].call(p1);
   break;
  case 2:
   ret = syscalls[call].call(p1, p2);
   break;
  case 3:
   ret = syscalls[call].call(p1, p2, p3);
   break;
  case 4:
   ret = syscalls[call].call(p1, p2, p3, p4);
   break;
  case 5:
   ret = syscalls[call].call(p1, p2, p3, p4, p5);
   break;
  default:
   ret = syscalls[call].call(p1, p2, p3);
 }
 asm("movl %0, %%eax\n\t": : "g" (ret));
}

canonical_original_code:
void syscall_callback(struct regs_t *r)
{
 int ret;
 unsigned int p1; unsigned int p2; unsigned int p3; unsigned int p4; unsigned int p5; unsigned int call;
 asm("mov %%eax, %0\n" : "=r" (call));
 asm("mov %%ebx, %0\n" : "=r" (p1));
 asm("mov %%ecx, %0\n" : "=r" (p2));
 if(call > syscalls_number)
  return;
 switch(syscalls[call].arg)
 {
  case 0:
   ret = syscalls[call].call();
   break;
  case 1:
   ret = syscalls[call].call(p1);
   break;
  case 2:
   ret = syscalls[call].call(p1, p2);
   break;
  case 3:
   ret = syscalls[call].call(p1, p2, p3);
   break;
  case 4:
   ret = syscalls[call].call(p1, p2, p3, p4);
   break;
  case 5:
   ret = syscalls[call].call(p1, p2, p3, p4, p5);
   break;
  default:
   ret = syscalls[call].call(p1, p2, p3);
 }
 asm("movl %0, %%eax\n\t": : "g" (ret));
}


decompiled_code:
__int64 syscall_init()
{
return debug_puts("syscall_init()\n");
}

canonical_decompiled_code:
__int64 func35()
{
return debug_puts("syscall_init()\n");
}

original_code:
void syscall_init()
{
 debug_puts("syscall_init()\n");
}


decompiled_code:
char *__fastcall sys_info_get(unsigned int a1)
{
return syscall_info_get((char *)a1);
}

canonical_decompiled_code:
char *__fastcall func37(unsigned int a1)
{
return func36((char *)a1);
}

original_code:
uint32_t sys_info_get(uint32_t a)
{
 return syscall_info_get((sysinfo_t *) a);
}

canonical_original_code:
unsigned int sys_info_get(unsigned int a)
{
 return syscall_info_get((struct sysinfo_t *) a);
}

user_defined_types: struct sysinfo_t { char name[32]; char ver[16]; char rev[16]; char date[16]; char time[16]; char arch[16]; char vend[16]; }


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

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

original_code:
uint32_t cpu_get_freq()
{
 return 0;
}

canonical_original_code:
unsigned int cpu_get_freq()
{
 return 0;
}


canonical_original_code:
unsigned int cpu_vendor_name(char *name)
{
  struct regs_t r = cpu_cpuid(0x00);
  char line1[5];
  line1[0] = ((char *) &r.ebx)[0];
  line1[1] = ((char *) &r.ebx)[1];
  line1[2] = ((char *) &r.ebx)[2];
  line1[3] = ((char *) &r.ebx)[3];
  line1[4] = '\0';
  char line2[5];
  line2[0] = ((char *) &r.ecx)[0];
  line2[1] = ((char *) &r.ecx)[1];
  line2[2] = ((char *) &r.ecx)[2];
  line2[3] = ((char *) &r.ecx)[3];
  line2[4] = '\0';
  char line3[5];
  line3[0] = ((char *) &r.edx)[0];
  line3[1] = ((char *) &r.edx)[1];
  line3[2] = ((char *) &r.edx)[2];
  line3[3] = ((char *) &r.edx)[3];
  line3[4] = '\0';
  strcpy(name, line1);
  strcat(name, line3);
  strcat(name, line2);
  return 15;
}

variable_types:
name
char *

variable_types: struct regs_t { unsigned int edi; unsigned int ds; unsigned int which_int; unsigned int eip; }


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

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

original_code:
uint32_t cpu_get_free()
{
 return 0;
}

canonical_original_code:
unsigned int cpu_get_free()
{
 return 0;
}


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

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

original_code:
uint32_t cpu_stop(uint32_t cpu)
{
 return 0;
}

canonical_original_code:
unsigned int cpu_stop(unsigned int cpu)
{
 return 0;
}

variable_types:
cpu
unsigned int


decompiled_code:
__int64 cpu_num()
{
return 1LL;
}

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

original_code:
uint32_t cpu_num()
{
 return 1;
}

canonical_original_code:
unsigned int cpu_num()
{
 return 1;
}


decompiled_code:
_BOOL8 __fastcall cpu_get_state(unsigned int a1)
{
return (unsigned int)cpu_num() > a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(unsigned int a1)
{
return (unsigned int)func4() > a1;
}

original_code:
uint32_t cpu_get_state(uint32_t cpu)
{
 if(cpu < cpu_num())
  return 1;
 else
  return 0;
}

canonical_original_code:
unsigned int cpu_get_state(unsigned int cpu)
{
 if(cpu < cpu_num())
  return 1;
 else
  return 0;
}


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

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

original_code:
uint32_t cpu_exec(uint32_t cpu, void *code)
{
 return 0;
}

canonical_original_code:
unsigned int cpu_exec(unsigned int cpu, void *code)
{
 return 0;
}

variable_types:
code
void *


decompiled_code:
void cpu_whake()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
uint32_t cpu_whake(uint32_t cpu)
{
}

canonical_original_code:
unsigned int cpu_whake(unsigned int cpu)
{
}


decompiled_code:
void cpu_sleep()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
uint32_t cpu_sleep(uint32_t cpu)
{
}

canonical_original_code:
unsigned int cpu_sleep(unsigned int cpu)
{
}


decompiled_code:
void cpu_reset()
{
;
}

canonical_decompiled_code:
void func9()
{
;
}

original_code:
uint32_t cpu_reset(uint32_t cpu)
{
}

canonical_original_code:
unsigned int cpu_reset(unsigned int cpu)
{
}


decompiled_code:
void cpu_get_id()
{
;
}

canonical_decompiled_code:
void func10()
{
;
}

original_code:
uint32_t cpu_get_id()
{
}

canonical_original_code:
unsigned int cpu_get_id()
{
}


decompiled_code:
void rtl8139_probe()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
uint32_t rtl8139_probe(device_t *dev)
{
}

canonical_original_code:
unsigned int rtl8139_probe(struct device_p *dev)
{
}

variable_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *


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

_disable();
debug_puts("arch_init()\n");
ARCH = 120;
*(&ARCH + 1) = 56;
*(&ARCH + 2) = 54;
*(&ARCH + 3) = 0;
cpu_vendor_name(&CPU_VENDOR);
gdt_install();
idt_install();
isrs_install();
irq_install();
timer_init();
clock_init();
idt_set_gate(132LL, &syscallisr, 8LL, 142LL);
result = idt_set_gate(14LL, &page_fault_handler, 8LL, 142LL);
_enable();
return result;
}

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

_disable();
debug_puts("arch_init()\n");
ARCH = 120;
*(&ARCH + 1) = 56;
*(&ARCH + 2) = 54;
*(&ARCH + 3) = 0;
cpu_vendor_name(&CPU_VENDOR);
gdt_install();
idt_install();
isrs_install();
irq_install();
timer_init();
clock_init();
idt_set_gate(132LL, &syscallisr, 8LL, 142LL);
result = idt_set_gate(14LL, &page_fault_handler, 8LL, 142LL);
_enable();
return result;
}

original_code:
void arch_init()
{
 asm("cli");
 debug_puts("arch_init()\n");
 ARCH[0] = 'x';
 ARCH[1] = '8';
 ARCH[2] = '6';
 ARCH[3] = '\0';
 cpu_vendor_name(CPU_VENDOR);
 gdt_install();
 idt_install();
 isrs_install();
 irq_install();
 timer_init();
 clock_init();
    idt_set_gate(0x84, (uint32_t) syscallisr, 0x08, 0x8E);
  idt_set_gate(14, (uint32_t) page_fault_handler, 0x08, 0x8E);
 asm("sti");
}

canonical_original_code:
void arch_init()
{
 asm("cli");
 debug_puts("arch_init()\n");
 ARCH[0] = 'x';
 ARCH[1] = '8';
 ARCH[2] = '6';
 ARCH[3] = '\0';
 cpu_vendor_name(CPU_VENDOR);
 gdt_install();
 idt_install();
 isrs_install();
 irq_install();
 timer_init();
 clock_init();
    idt_set_gate(0x84, (unsigned int) syscallisr, 0x08, 0x8E);
  idt_set_gate(14, (unsigned int) page_fault_handler, 0x08, 0x8E);
 asm("sti");
}


decompiled_code:
void __noreturn arch_shutdown()
{
_disable();
__halt();
}

canonical_decompiled_code:
void __noreturn func1()
{
_disable();
__halt();
}

original_code:
void arch_shutdown()
{
 asm("cli");
 asm("hlt");
}


decompiled_code:
void arch_reboot()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void arch_reboot()
{
}

canonical_original_code:
void arch_reboot()
{
}


decompiled_code:
void arch_standby()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void arch_standby()
{
}

canonical_original_code:
void arch_standby()
{
}


decompiled_code:
__int64 initramfs_umount()
{
return 1LL;
}

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

original_code:
uint32_t initramfs_umount(inode_t *root)
{
 return 1;
}

canonical_original_code:
unsigned int initramfs_umount(struct inode_p *root)
{
 return 1;
}

variable_types: struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *


decompiled_code:
__int64 initramfs_mount()
{
return 1LL;
}

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

original_code:
uint32_t initramfs_mount(char *dev, uint32_t flags, inode_t *root)
{
 return 1;
}

canonical_original_code:
unsigned int initramfs_mount(char *dev, unsigned int flags, struct inode_p *root)
{
 return 1;
}

variable_types:
dev
char *

variable_types:
flags
unsigned int


decompiled_code:
__int64 __fastcall initramfs_read(__int64 a1, _BYTE *a2, unsigned int a3, __int64 a4)
{
unsigned __int64 v6; // rsi
__int64 v7; // rbx
__int64 v8; // rax
unsigned int v9; // er10
int v10; // edx
__int64 result; // rax

v6 = mod_addr + (unsigned int)a4 + (unsigned __int64)*(unsigned int *)(*(_QWORD *)(a1 + 264) + 44LL);
if ( a3 )
{
v7 = a3;
v8 = 0LL;
while ( 1 )
{
v9 = v8;
if ( *(unsigned int *)(*(_QWORD *)(a1 + 264) + 40LL) <= (unsigned __int64)(a4 + v8) )
break;
a2[v8] = *(_BYTE *)(v6 + v8);
v10 = ++v8;
if ( v8 == v7 )
{
a2[v10] = 0;
v9 = a3;
goto LABEL_7;
}
}
a2[v8] = 0;
LABEL_7:
result = v9;
}
else
{
*a2 = 0;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _BYTE *a2, unsigned int a3, __int64 a4)
{
unsigned __int64 v6; // rsi
__int64 v7; // rbx
__int64 v8; // rax
unsigned int v9; // er10
int v10; // edx
__int64 result; // rax

v6 = mod_addr + (unsigned int)a4 + (unsigned __int64)*(unsigned int *)(*(_QWORD *)(a1 + 264) + 44LL);
if ( a3 )
{
v7 = a3;
v8 = 0LL;
while ( 1 )
{
v9 = v8;
if ( *(unsigned int *)(*(_QWORD *)(a1 + 264) + 40LL) <= (unsigned __int64)(a4 + v8) )
break;
a2[v8] = *(_BYTE *)(v6 + v8);
v10 = ++v8;
if ( v8 == v7 )
{
a2[v10] = 0;
v9 = a3;
goto LABEL_7;
}
}
a2[v8] = 0;
LABEL_7:
result = v9;
}
else
{
*a2 = 0;
result = 0LL;
}
return result;
}

original_code:
uint32_t initramfs_read(inode_t *node, char *buf, uint32_t size, uint64_t offset)
{
 int i;
 char *data = (char *) (mod_addr + (((initramfs_node_t *) (node->fs_node))->data));
 data = data + (uint32_t) offset;
 for(i = 0; i < size; i++)
 {
  if((offset + i) >= (((initramfs_node_t *) (node->fs_node))->size))
  {
   buf[i] = '\0';
   return i;
  }
  buf[i] = *data;
  data++;
 }
 buf[i] = '\0';
 return size;
}

canonical_original_code:
unsigned int initramfs_read(struct inode_p *node, char *buf, unsigned int size, unsigned long long offset)
{
 int i;
 char *data = (char *) (mod_addr + (((initramfs_node_t *) (node->fs_node))->data));
 data = data + (unsigned int) offset;
 for(i = 0; i < size; i++)
 {
  if((offset + i) >= (((struct initramfs_node_t *) (node->fs_node))->size))
  {
   buf[i] = '\0';
   return i;
  }
  buf[i] = *data;
  data++;
 }
 buf[i] = '\0';
 return size;
}

variable_types:
buf
char *

variable_types:
size
unsigned int

variable_types:
offset
unsigned long long

variable_types: i int

variable_types:
data
char *

user_defined_types: struct initramfs_node_t { unsigned int identify; char name[32]; unsigned int n; unsigned int size; unsigned int data; }


decompiled_code:
__int64 __fastcall initramfs_readdir(__int64 a1, unsigned int a2, __int64 a3)
{
__int64 v4; // rbx
__int64 result; // rax

v4 = mod_addr + 48LL * a2;
strcpy((char *)a3, src);
result = 0LL;
if ( *(_DWORD *)v4 == 11259375 )
{
strcpy((char *)a3, (const char *)(v4 + 4));
*(_DWORD *)(a3 + 256) = *(_DWORD *)(v4 + 36);
result = 1LL;
}
return result;
}

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

v4 = mod_addr + 48LL * a2;
strcpy((char *)a3, src);
result = 0LL;
if ( *(_DWORD *)v4 == 11259375 )
{
strcpy((char *)a3, (const char *)(v4 + 4));
*(_DWORD *)(a3 + 256) = *(_DWORD *)(v4 + 36);
result = 1LL;
}
return result;
}

original_code:
uint32_t initramfs_readdir(inode_t *root, uint32_t n, struct dirent *d)
{
 uint32_t i;
 initramfs_node_t *node = (initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * n));
 strcpy(d->name, "\0");
 if(node->identify == 0xABCDEF)
 {
  strcpy(d->name, node->name);
  d->inode = node->n;
  return 1;
 }
 else
  return 0;
}

canonical_original_code:
unsigned int initramfs_readdir(struct inode_p *root, unsigned int n, struct dirent *d)
{
 unsigned int i;
 struct initramfs_node_t *node = (initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * n));
 strcpy(d->name, "\0");
 if(node->identify == 0xABCDEF)
 {
  strcpy(d->name, node->name);
  d->inode = node->n;
  return 1;
 }
 else
  return 0;
}

variable_types:
n
unsigned int

variable_types: struct dirent { char name[255]; unsigned int inode; } *

variable_types:
i
unsigned int

variable_types: struct initramfs_node_t { unsigned int identify; char name[32]; unsigned int n; unsigned int size; unsigned int data; } *


decompiled_code:
__int64 __fastcall initramfs_open(__int64 a1)
{
signed int i; // ebx
__int64 result; // rax
_DWORD v3[74]; // [rsp+0h] [rbp-128h] BYREF

for ( i = 0; ; ++i )
{
result = initramfs_readdir(0LL, i, (__int64)v3);
if ( !(_DWORD)result )
break;
if ( v3[64] == *(_DWORD *)(a1 + 256) )
{
*(_QWORD *)(a1 + 264) = mod_addr + 48LL * i;
return 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
signed int i; // ebx
__int64 result; // rax
_DWORD v3[74]; // [rsp+0h] [rbp-128h] BYREF

for ( i = 0; ; ++i )
{
result = func3(0LL, i, (__int64)v3);
if ( !(_DWORD)result )
break;
if ( v3[64] == *(_DWORD *)(a1 + 256) )
{
*(_QWORD *)(a1 + 264) = mod_addr + 48LL * i;
return 1LL;
}
}
return result;
}

original_code:
uint32_t initramfs_open(inode_t *node, char *flags)
{
 int i = 0;
 struct dirent dir;
 while(initramfs_readdir(0, i, &dir) != 0)
 {
  if(dir.inode == node->inode_n)
  {
   node->fs_node = (void *) (initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * i));
   return 1;
  }
  i++;
 }
 return 0;
}

canonical_original_code:
unsigned int initramfs_open(struct inode_p *node, char *flags)
{
 int i = 0;
 struct dirent dir;
 while(initramfs_readdir(0, i, &dir) != 0)
 {
  if(dir.inode == node->inode_n)
  {
   node->fs_node = (void *) (struct initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * i));
   return 1;
  }
  i++;
 }
 return 0;
}

variable_types:
flags
char *

variable_types: struct dirent { char name[255]; unsigned int inode; }


original_code:
uint32_t initramfs_get_node(inode_t *root, uint32_t node_n, inode_t **node)
{
 int i = 0;
 initramfs_node_t *nod;
 while(1)
 {
  nod = (initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * i));
  if(nod->identify == 0xABCDEF)
  {
   if(nod->n == node_n)
   {
    *node = fs_create_node(nod->name, root, 1, 1);
    (*node)->inode_n = nod->n;
    (*node)->fs_node = nod;
    return 1;
   }
  }
  i++;
 }
 return 0;
}

canonical_original_code:
unsigned int initramfs_get_node(struct inode_p *root, unsigned int node_n, struct inode_p **node)
{
 int i = 0;
 struct initramfs_node_t *nod;
 while(1)
 {
  nod = (struct initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * i));
  if(nod->identify == 0xABCDEF)
  {
   if(nod->n == node_n)
   {
    *node = fs_create_node(nod->name, root, 1, 1);
    (*node)->inode_n = nod->n;
    (*node)->fs_node = nod;
    return 1;
   }
  }
  i++;
 }
 return 0;
}

variable_types:
node
struct inode_p **


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

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

original_code:
uint32_t crc32_make(uint8_t *blocks, uint32_t size)
{
 uint32_t crc_code = 0x00000000;
 return crc_code;
}

canonical_original_code:
unsigned int crc32_make(unsigned char *blocks, unsigned int size)
{
 unsigned int crc_code = 0x00000000;
 return crc_code;
}

variable_types:
blocks
unsigned char *


original_code:
uint32_t crc32_check(uint32_t crc32, uint8_t *blocks, uint32_t size)
{
 uint32_t crc_gen = crc32_make(blocks, size);
 uint32_t sindrome = crc32 ^ crc_gen;
 if(sindrome == 0) return sindrome;
 uint32_t block = sindrome / 8;
 uint32_t bit = sindrome % 8;
 blocks[block] = blocks[block] + ~(blocks[block] & (1 << bit)) << bit;
 return sindrome;
}

canonical_original_code:
unsigned int crc32_check(unsigned int crc32, unsigned char *blocks, unsigned int size)
{
 unsigned int crc_gen = crc32_make(blocks, size);
 unsigned int sindrome = crc32 ^ crc_gen;
 if(sindrome == 0) return sindrome;
 unsigned int block = sindrome / 8;
 unsigned int bit = sindrome % 8;
 blocks[block] = blocks[block] + ~(blocks[block] & (1 << bit)) << bit;
 return sindrome;
}

variable_types:
sindrome
unsigned int

variable_types:
block
unsigned int

variable_types:
bit
unsigned int


decompiled_code:
void rs232_probe()
{
;
}

original_code:
uint32_t rs232_probe(device_t *dev)
{
}

canonical_original_code:
unsigned int rs232_probe(struct device_p *dev)
{
}

variable_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *


decompiled_code:
__int64 rs232_free()
{
handler_unreg(4LL);
handler_unreg(3LL);
devfs_unreg_device("ser0");
devfs_unreg_device("ser1");
devfs_unreg_device("ser2");
devfs_unreg_device("ser3");
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
handler_unreg(4LL);
handler_unreg(3LL);
devfs_unreg_device("ser0");
devfs_unreg_device("ser1");
devfs_unreg_device("ser2");
devfs_unreg_device("ser3");
return 0LL;
}

original_code:
uint32_t rs232_free()
{
 handler_unreg(4);
 handler_unreg(3);
 devfs_unreg_device("ser0");
 devfs_unreg_device("ser1");
 devfs_unreg_device("ser2");
 devfs_unreg_device("ser3");
 return 0;
}

canonical_original_code:
unsigned int rs232_free()
{
 handler_unreg(4);
 handler_unreg(3);
 devfs_unreg_device("ser0");
 devfs_unreg_device("ser1");
 devfs_unreg_device("ser2");
 devfs_unreg_device("ser3");
 return 0;
}


original_code:
static void rs232_callback(regs_t *reg)
{
 if((io_inb(0x3f8 + 5) & 1) != 0)
 {
  combuf[0].buf[combuf[0].point] = io_inb(0x3f8);
  combuf[0].size++;
  combuf[0].point++;
 }
 if((io_inb(0x2f8 + 5) & 1) != 0)
 {
  combuf[1].buf[combuf[1].point] = io_inb(0x2f8);
  combuf[1].size++;
  combuf[1].point++;
 }
 if((io_inb(0x3e8 + 5) & 1) != 0)
 {
  combuf[2].buf[combuf[2].point] = io_inb(0x3e8);
  combuf[2].size++;
  combuf[2].point++;
 }
 if((io_inb(0x2e8 + 5) & 1) != 0)
 {
  combuf[3].buf[combuf[3].point] = io_inb(0x2e8);
  combuf[3].size++;
  combuf[3].point++;
 }
  modem_callback(reg);
}

canonical_original_code:
static void rs232_callback(struct regs_t *reg)
{
 if((io_inb(0x3f8 + 5) & 1) != 0)
 {
  combuf[0].buf[combuf[0].point] = io_inb(0x3f8);
  combuf[0].size++;
  combuf[0].point++;
 }
 if((io_inb(0x2f8 + 5) & 1) != 0)
 {
  combuf[1].buf[combuf[1].point] = io_inb(0x2f8);
  combuf[1].size++;
  combuf[1].point++;
 }
 if((io_inb(0x3e8 + 5) & 1) != 0)
 {
  combuf[2].buf[combuf[2].point] = io_inb(0x3e8);
  combuf[2].size++;
  combuf[2].point++;
 }
 if((io_inb(0x2e8 + 5) & 1) != 0)
 {
  combuf[3].buf[combuf[3].point] = io_inb(0x2e8);
  combuf[3].size++;
  combuf[3].point++;
 }
  modem_callback(reg);
}

variable_types: struct regs_t { unsigned int edi; unsigned int ds; unsigned int which_int; unsigned int eip; } *


decompiled_code:
__int64 __fastcall rs232_init_port(unsigned __int16 a1)
{
io_outb((unsigned __int16)(a1 + 1), 1LL);
io_outb((unsigned __int16)(a1 + 3), 128LL);
io_outb(a1, 3LL);
io_outb((unsigned __int16)(a1 + 1), 0LL);
io_outb((unsigned __int16)(a1 + 3), 3LL);
io_outb((unsigned __int16)(a1 + 2), 199LL);
return io_outb((unsigned __int16)(a1 + 4), 11LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int16 a1)
{
io_outb((unsigned __int16)(a1 + 1), 1LL);
io_outb((unsigned __int16)(a1 + 3), 128LL);
io_outb(a1, 3LL);
io_outb((unsigned __int16)(a1 + 1), 0LL);
io_outb((unsigned __int16)(a1 + 3), 3LL);
io_outb((unsigned __int16)(a1 + 2), 199LL);
return io_outb((unsigned __int16)(a1 + 4), 11LL);
}

original_code:
void rs232_init_port(uint32_t port)
{
 io_outb(port + 1, 0x01);
 io_outb(port + 3, 0x80);
 io_outb(port + 0, 0x03);
 io_outb(port + 1, 0x00);
 io_outb(port + 3, 0x03);
 io_outb(port + 2, 0xC7);
 io_outb(port + 4, 0x0B);
}

canonical_original_code:
void rs232_init_port(unsigned int port)
{
 io_outb(port + 1, 0x01);
 io_outb(port + 3, 0x80);
 io_outb(port + 0, 0x03);
 io_outb(port + 1, 0x00);
 io_outb(port + 3, 0x03);
 io_outb(port + 2, 0xC7);
 io_outb(port + 4, 0x0B);
}

variable_types:
port
unsigned int


decompiled_code:
__int64 rs232_init()
{
char *v0; // rax

rs232_init_port(0x3F8u);
rs232_init_port(0x2F8u);
rs232_init_port(0x3E8u);
rs232_init_port(0x2E8u);
v0 = combuf;
do
{
v0[258] = 0;
v0[256] = 0;
v0[257] = 0;
v0 += 259;
}
while ( v0 != (char *)(unsigned int)((_DWORD)combuf + 1036) );
handler_reg(4LL, rs232_callback);
handler_reg(3LL, rs232_callback);
devfs_reg_device(0LL, 0LL, "ser0");
devfs_reg_device(0LL, 0LL, "ser1");
devfs_reg_device(0LL, 0LL, "ser2");
devfs_reg_device(0LL, 0LL, "ser3");
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
char *v0; // rax

func3(0x3F8u);
func3(0x2F8u);
func3(0x3E8u);
func3(0x2E8u);
v0 = combuf;
do
{
v0[258] = 0;
v0[256] = 0;
v0[257] = 0;
v0 += 259;
}
while ( v0 != (char *)(unsigned int)((_DWORD)combuf + 1036) );
handler_reg(4LL, rs232_callback);
handler_reg(3LL, rs232_callback);
devfs_reg_device(0LL, 0LL, "ser0");
devfs_reg_device(0LL, 0LL, "ser1");
devfs_reg_device(0LL, 0LL, "ser2");
devfs_reg_device(0LL, 0LL, "ser3");
return 0LL;
}

original_code:
uint32_t rs232_init()
{
 int x;
 rs232_init_port(0x3f8);
 rs232_init_port(0x2f8);
 rs232_init_port(0x3e8);
 rs232_init_port(0x2e8);
 for(x = 0; x < 4; x++)
  combuf[x].where = combuf[x].size = combuf[x].point = 0;
 handler_reg(4, &rs232_callback);
 handler_reg(3, &rs232_callback);
 devfs_reg_device(0, 0, "ser0");
 devfs_reg_device(0, 0, "ser1");
 devfs_reg_device(0, 0, "ser2");
 devfs_reg_device(0, 0, "ser3");
 return 0;
}

canonical_original_code:
unsigned int rs232_init()
{
 int x;
 rs232_init_port(0x3f8);
 rs232_init_port(0x2f8);
 rs232_init_port(0x3e8);
 rs232_init_port(0x2e8);
 for(x = 0; x < 4; x++)
  combuf[x].where = combuf[x].size = combuf[x].point = 0;
 handler_reg(4, &rs232_callback);
 handler_reg(3, &rs232_callback);
 devfs_reg_device(0, 0, "ser0");
 devfs_reg_device(0, 0, "ser1");
 devfs_reg_device(0, 0, "ser2");
 devfs_reg_device(0, 0, "ser3");
 return 0;
}

variable_types: x int


decompiled_code:
__int64 __fastcall rs232_send(unsigned __int16 a1, unsigned __int8 a2)
{
while ( (io_inb((unsigned __int16)(a1 + 5)) & 0x20) == 0 )
;
return io_outb(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int16 a1, unsigned __int8 a2)
{
while ( (io_inb((unsigned __int16)(a1 + 5)) & 0x20) == 0 )
;
return io_outb(a1, a2);
}

original_code:
void rs232_send(uint32_t port, uint8_t data)
{
 while ((io_inb(port + 5) & 0x20) == 0);
 io_outb(port, data);
}

canonical_original_code:
void rs232_send(unsigned int port, unsigned char data)
{
 while ((io_inb(port + 5) & 0x20) == 0);
 io_outb(port, data);
}

variable_types:
data
unsigned char


decompiled_code:
__int64 __fastcall rs232_receive(unsigned int a1)
{
char v1; // dl
__int64 result; // rax
unsigned __int8 v3; // cl
char v4; // dl
unsigned __int8 v5; // cl
char v6; // dl
unsigned __int8 v7; // cl
char v8; // dl
unsigned __int8 v9; // cl

if ( a1 == 1000 )
{
v6 = combuf[774];
result = 0LL;
if ( v6 )
{
v7 = combuf[775];
result = (unsigned __int8)combuf[v7 + 518];
combuf[775] = v7 + 1;
combuf[774] = v6 - 1;
}
}
else if ( a1 > 0x3E8 )
{
if ( a1 == 1016 )
{
v4 = combuf[256];
result = 0LL;
if ( v4 )
{
v5 = combuf[257];
result = (unsigned __int8)combuf[v5];
combuf[257] = v5 + 1;
combuf[256] = v4 - 1;
}
}
}
else if ( a1 == 744 )
{
v8 = combuf[1033];
result = 0LL;
if ( v8 )
{
v9 = combuf[1034];
result = (unsigned __int8)combuf[v9 + 777];
combuf[1034] = v9 + 1;
combuf[1033] = v8 - 1;
}
}
else if ( a1 == 760 )
{
v1 = combuf[515];
result = 0LL;
if ( v1 )
{
v3 = combuf[516];
result = (unsigned __int8)combuf[v3 + 259];
combuf[516] = v3 + 1;
combuf[515] = v1 - 1;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1)
{
char v1; // dl
__int64 result; // rax
unsigned __int8 v3; // cl
char v4; // dl
unsigned __int8 v5; // cl
char v6; // dl
unsigned __int8 v7; // cl
char v8; // dl
unsigned __int8 v9; // cl

if ( a1 == 1000 )
{
v6 = combuf[774];
result = 0LL;
if ( v6 )
{
v7 = combuf[775];
result = (unsigned __int8)combuf[v7 + 518];
combuf[775] = v7 + 1;
combuf[774] = v6 - 1;
}
}
else if ( a1 > 0x3E8 )
{
if ( a1 == 1016 )
{
v4 = combuf[256];
result = 0LL;
if ( v4 )
{
v5 = combuf[257];
result = (unsigned __int8)combuf[v5];
combuf[257] = v5 + 1;
combuf[256] = v4 - 1;
}
}
}
else if ( a1 == 744 )
{
v8 = combuf[1033];
result = 0LL;
if ( v8 )
{
v9 = combuf[1034];
result = (unsigned __int8)combuf[v9 + 777];
combuf[1034] = v9 + 1;
combuf[1033] = v8 - 1;
}
}
else if ( a1 == 760 )
{
v1 = combuf[515];
result = 0LL;
if ( v1 )
{
v3 = combuf[516];
result = (unsigned __int8)combuf[v3 + 259];
combuf[516] = v3 + 1;
combuf[515] = v1 - 1;
}
}
return result;
}

original_code:
uint8_t rs232_receive(uint32_t port)
{
 char ch = 0;
 switch(port)
 {
  case 0x3f8:
   if(combuf[0].size > 0)
   {
    ch = combuf[0].buf[combuf[0].where];
    combuf[0].where++;
    combuf[0].size--;
   }
   return ch;
  case 0x2f8:
   if(combuf[1].size > 0)
   {
    ch = combuf[1].buf[combuf[1].where];
    combuf[1].where++;
    combuf[1].size--;
   }
   return ch;
  case 0x3e8:
   if(combuf[2].size > 0)
   {
    ch = combuf[2].buf[combuf[2].where];
    combuf[2].where++;
    combuf[2].size--;
   }
   return ch;
  case 0x2e8:
   if(combuf[3].size > 0)
   {
    ch = combuf[3].buf[combuf[3].where];
    combuf[3].where++;
    combuf[3].size--;
   }
   return ch;
 }
}

canonical_original_code:
unsigned char rs232_receive(unsigned int port)
{
 char ch = 0;
 switch(port)
 {
  case 0x3f8:
   if(combuf[0].size > 0)
   {
    ch = combuf[0].buf[combuf[0].where];
    combuf[0].where++;
    combuf[0].size--;
   }
   return ch;
  case 0x2f8:
   if(combuf[1].size > 0)
   {
    ch = combuf[1].buf[combuf[1].where];
    combuf[1].where++;
    combuf[1].size--;
   }
   return ch;
  case 0x3e8:
   if(combuf[2].size > 0)
   {
    ch = combuf[2].buf[combuf[2].where];
    combuf[2].where++;
    combuf[2].size--;
   }
   return ch;
  case 0x2e8:
   if(combuf[3].size > 0)
   {
    ch = combuf[3].buf[combuf[3].where];
    combuf[3].where++;
    combuf[3].size--;
   }
   return ch;
 }
}

variable_types: ch char

return_type: unsigned char


decompiled_code:
__int64 devfs_umount()
{
return 1LL;
}

original_code:
uint32_t devfs_umount(inode_t *root)
{
 return 1;
}

canonical_original_code:
unsigned int devfs_umount(struct inode_p *root)
{
 return 1;
}

variable_types: struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *


decompiled_code:
__int64 __fastcall devfs_mount(__int64 a1, __int64 a2, __int64 a3)
{
*(_QWORD *)(a3 + 312) = devfs_childs;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
*(_QWORD *)(a3 + 312) = devfs_childs;
return 1LL;
}

original_code:
uint32_t devfs_mount(char *dev, uint32_t flags, inode_t *root)
{
 root->childs = devfs_childs;
 return 1;
}

canonical_original_code:
unsigned int devfs_mount(char *dev, unsigned int flags, struct inode_p *root)
{
 root->childs = devfs_childs;
 return 1;
}

variable_types:
dev
char *

variable_types:
flags
unsigned int


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

result = *(_QWORD *)(devfs_root + 312);
if ( !result )
return 0LL;
while ( *(_DWORD *)(result + 256) != a2 )
{
result = *(_QWORD *)(result + 288);
if ( !result )
return result;
}
*a3 = result;
return 1LL;
}

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

result = *(_QWORD *)(devfs_root + 312);
if ( !result )
return 0LL;
while ( *(_DWORD *)(result + 256) != a2 )
{
result = *(_QWORD *)(result + 288);
if ( !result )
return result;
}
*a3 = result;
return 1LL;
}

original_code:
uint32_t devfs_get_node(inode_t *root, uint32_t i, inode_t **child)
{
 inode_t *tmp = devfs_root->childs;
 while(tmp != 0)
 {
  if(tmp->inode_n == i)
  {
   *child = tmp;
   return 1;
  }
  tmp = tmp->next;
 }
 return 0;
}

canonical_original_code:
unsigned int devfs_get_node(struct inode_p *root, unsigned int i, struct inode_p **child)
{
 struct inode_p *tmp = devfs_root->childs;
 while(tmp != 0)
 {
  if(tmp->inode_n == i)
  {
   *child = tmp;
   return 1;
  }
  tmp = tmp->next;
 }
 return 0;
}

variable_types:
i
unsigned int

variable_types:
child
struct inode_p **


decompiled_code:
_BOOL8 __fastcall devfs_open(__int64 a1)
{
return *(_QWORD *)(a1 + 264) != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1)
{
return *(_QWORD *)(a1 + 264) != 0LL;
}

original_code:
uint32_t devfs_open(inode_t *node, char *flags)
{
 int i = 0;
 struct dirent dir;
 if(node->fs_node == 0)
  return 0;
 return 1;
}

canonical_original_code:
unsigned int devfs_open(struct inode_p *node, char *flags)
{
 int i = 0;
 struct dirent dir;
 if(node->fs_node == 0)
  return 0;
 return 1;
}

variable_types:
flags
char *

variable_types: i int

variable_types: struct dirent { char name[255]; unsigned int inode; }


decompiled_code:
__int64 __fastcall devfs_read(__int64 a1, __int64 a2, unsigned int a3)
{
_QWORD *v4; // rdx
__int64 result; // rax
__int64 v6; // r9
__int64 (__fastcall *v7)(__int64, __int64, _QWORD); // r8

v4 = *(_QWORD **)(a1 + 264);
result = 0LL;
if ( v4 )
{
if ( *v4 )
{
v6 = v4[1];
if ( v6 )
{
v7 = *(__int64 (__fastcall **)(__int64, __int64, _QWORD))(*v4 + 488LL);
if ( v7 )
result = v7(v6, a2, a3);
}
}
}
return result;
}

original_code:
uint32_t devfs_read(inode_t *node, char *buf, uint32_t size, uint64_t offset)
{
 if( (node->fs_node != 0) &&
  (((devfs_node_t *) (node->fs_node))->driver != 0) &&
  (((devfs_node_t *) (node->fs_node))->device != 0) &&
  ((((devfs_node_t *) (node->fs_node))->driver)->read != 0))
 {
  return (((devfs_node_t *) (node->fs_node))->driver)->read(((devfs_node_t *) (node->fs_node))->device, buf, size, offset);
 }
 return 0;
}

canonical_original_code:
unsigned int devfs_read(struct inode_p *node, char *buf, unsigned int size, unsigned long long offset)
{
 if( (node->fs_node != 0) &&
  (((struct devfs_node_t *) (node->fs_node))->driver != 0) &&
  (((struct devfs_node_t *) (node->fs_node))->device != 0) &&
  ((((struct devfs_node_t *) (node->fs_node))->driver)->read != 0))
 {
  return (((struct devfs_node_t *) (node->fs_node))->driver)->read(((struct devfs_node_t *) (node->fs_node))->device, buf, size, offset);
 }
 return 0;
}

variable_types:
buf
char *

variable_types:
size
unsigned int

variable_types:
offset
unsigned long long

user_defined_types: struct devfs_node_t { struct driver_p *driver; struct device_p *device; }


decompiled_code:
__int64 __fastcall devfs_write(__int64 a1, __int64 a2, unsigned int a3)
{
_QWORD *v4; // rdx
__int64 result; // rax
__int64 v6; // r9
__int64 (__fastcall *v7)(__int64, __int64, _QWORD); // r8

v4 = *(_QWORD **)(a1 + 264);
result = 0LL;
if ( v4 )
{
if ( *v4 )
{
v6 = v4[1];
if ( v6 )
{
v7 = *(__int64 (__fastcall **)(__int64, __int64, _QWORD))(*v4 + 496LL);
if ( v7 )
result = v7(v6, a2, a3);
}
}
}
return result;
}

original_code:
uint32_t devfs_write(inode_t *node, char *buf, uint32_t size, uint64_t offset)
{
 if( (node->fs_node != 0) &&
  (((devfs_node_t *) (node->fs_node))->driver != 0) &&
  (((devfs_node_t *) (node->fs_node))->device != 0) &&
  ((((devfs_node_t *) (node->fs_node))->driver)->write != 0))
 {
  return (((devfs_node_t *) (node->fs_node))->driver)->write(((devfs_node_t *) (node->fs_node))->device, buf, size, offset);
 }
 return 0;
}

canonical_original_code:
unsigned int devfs_write(struct inode_p *node, char *buf, unsigned int size, unsigned long long offset)
{
 if( (node->fs_node != 0) &&
  (((struct devfs_node_t *) (node->fs_node))->driver != 0) &&
  (((struct devfs_node_t *) (node->fs_node))->device != 0) &&
  ((((struct devfs_node_t *) (node->fs_node))->driver)->write != 0))
 {
  return (((struct devfs_node_t *) (node->fs_node))->driver)->write(((struct devfs_node_t *) (node->fs_node))->device, buf, size, offset);
 }
 return 0;
}


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

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

original_code:
uint32_t devfs_close(inode_t *node)
{
 return 0;
}

canonical_original_code:
unsigned int devfs_close(struct inode_p *node)
{
 return 0;
}


decompiled_code:
__int64 __fastcall devfs_readdir(__int64 a1, unsigned int a2, __int64 a3)
{
__int64 v3; // rbx
unsigned int v5; // eax
__int64 result; // rax

v3 = *(_QWORD *)(devfs_root + 312);
if ( !v3 )
return 0LL;
if ( a2 )
{
v5 = 0;
while ( 1 )
{
++v5;
v3 = *(_QWORD *)(v3 + 288);
if ( !v3 || a2 < v5 )
break;
if ( a2 == v5 )
goto LABEL_7;
}
result = 0LL;
}
else
{
LABEL_7:
strcpy((char *)a3, (const char *)v3);
*(_DWORD *)(a3 + 256) = *(_DWORD *)(v3 + 256);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2, __int64 a3)
{
__int64 v3; // rbx
unsigned int v5; // eax
__int64 result; // rax

v3 = *(_QWORD *)(devfs_root + 312);
if ( !v3 )
return 0LL;
if ( a2 )
{
v5 = 0;
while ( 1 )
{
++v5;
v3 = *(_QWORD *)(v3 + 288);
if ( !v3 || a2 < v5 )
break;
if ( a2 == v5 )
goto LABEL_7;
}
result = 0LL;
}
else
{
LABEL_7:
strcpy((char *)a3, (const char *)v3);
*(_DWORD *)(a3 + 256) = *(_DWORD *)(v3 + 256);
result = 1LL;
}
return result;
}

original_code:
uint32_t devfs_readdir(inode_t *root, uint32_t n, struct dirent *d)
{
 inode_t *childs = devfs_root->childs;
 unsigned i = 0;
 while(childs != 0 && i <= n)
 {
  if(i == n)
  {
   strcpy(d->name, childs->name);
   d->inode = childs->inode_n;
   return 1;
  }
  i++;
  childs = childs->next;
 }
 return 0;
}

canonical_original_code:
unsigned int devfs_readdir(struct inode_p *root, unsigned int n, struct dirent *d)
{
 struct inode_p *childs = devfs_root->childs;
 unsigned int i = 0;
 while(childs != 0 && i <= n)
 {
  if(i == n)
  {
   strcpy(d->name, childs->name);
   d->inode = childs->inode_n;
   return 1;
  }
  i++;
  childs = childs->next;
 }
 return 0;
}

variable_types:
n
unsigned int

variable_types: struct dirent { char name[255]; unsigned int inode; } *


decompiled_code:
__int64 __fastcall devfs_reg_device(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
signed int v5; // eax

debug_puts("devfs_reg_device()\n");
if ( a3 )
{
v4 = fs_create_node(a3, devfs_root, 1LL, 0LL);
v5 = (unsigned int)malloc(0x10uLL);
*(_QWORD *)(v4 + 264) = v5;
*(_QWORD *)v5 = a2;
*(_QWORD *)(*(_QWORD *)(v4 + 264) + 8LL) = a1;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
signed int v5; // eax

debug_puts("devfs_reg_device()\n");
if ( a3 )
{
v4 = fs_create_node(a3, devfs_root, 1LL, 0LL);
v5 = (unsigned int)malloc(0x10uLL);
*(_QWORD *)(v4 + 264) = v5;
*(_QWORD *)v5 = a2;
*(_QWORD *)(*(_QWORD *)(v4 + 264) + 8LL) = a1;
}
return 0LL;
}

original_code:
uint32_t devfs_reg_device(device_t *dev, driver_t *drv, char *name)
{
 debug_puts("devfs_reg_device()\n");
 if(name == 0)
  return 0;
 inode_t *devv = fs_create_node(name, devfs_root, 1, 0);
 (devv->fs_node) = (void *) malloc(sizeof(devfs_node_t));
 ((devfs_node_t *) (devv->fs_node))->driver = drv;
 ((devfs_node_t *) (devv->fs_node))->device = dev;
 return 0;
}

canonical_original_code:
unsigned int devfs_reg_device(struct device_p *dev, struct driver_p *drv, char *name)
{
 debug_puts("devfs_reg_device()\n");
 if(name == 0)
  return 0;
 struct inode_p *devv = fs_create_node(name, devfs_root, 1, 0);
 (devv->fs_node) = (void *) malloc(sizeof(devfs_node_t));
 ((struct devfs_node_t *) (devv->fs_node))->driver = drv;
 ((struct devfs_node_t *) (devv->fs_node))->device = dev;
 return 0;
}

variable_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *

variable_types: struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *

variable_types:
name
char *


decompiled_code:
__int64 devfs_unreg_device()
{
return debug_puts("devfs_unreg_device()\n");
}

canonical_decompiled_code:
__int64 func9()
{
return debug_puts("devfs_unreg_device()\n");
}

original_code:
uint32_t devfs_unreg_device(char *name)
{
 debug_puts("devfs_unreg_device()\n");
 inode_t *node = devfs_root->childs;
 inode_t *prev = 0;
 while(prev != 0)
 {
  if(strcmp(node->name, name) == 0)
  {
   if(prev == 0)
    devfs_root->childs = node->next;
   else
    prev->next = node->next;
   free(node);
   return 0;
  }
  prev = node;
  node = node->next;
 }
}

canonical_original_code:
unsigned int devfs_unreg_device(char *name)
{
 debug_puts("devfs_unreg_device()\n");
 struct inode_p *node = devfs_root->childs;
 struct inode_p *prev = 0;
 while(prev != 0)
 {
  if(strcmp(node->name, name) == 0)
  {
   if(prev == 0)
    devfs_root->childs = node->next;
   else
    prev->next = node->next;
   free(node);
   return 0;
  }
  prev = node;
  node = node->next;
 }
}


decompiled_code:
size_t __fastcall devfs_find_freen(char *src, char *s)
{
int v2; // edx
size_t result; // rax
unsigned int i; // er13
__int64 v5; // rbx
unsigned int v6; // eax
char srca[8]; // [rsp+8h] [rbp-50h] BYREF
char dest[72]; // [rsp+10h] [rbp-48h] BYREF

v2 = strcmp(src, ::src);
result = 0LL;
if ( v2 )
{
strcpy(s, ::src);
for ( i = 0; ; ++i )
{
v5 = *(_QWORD *)(devfs_root + 312);
strcpy(dest, src);
v6 = itoa(i);
strcpy(srca, (const char *)v6);
strcat(srca, ::src);
strcat(dest, srca);
if ( !v5 )
break;
while ( strcmp(dest, (const char *)v5) )
{
v5 = *(_QWORD *)(v5 + 288);
if ( !v5 )
goto LABEL_7;
}
}
LABEL_7:
strcpy(s, dest);
strcat(s, ::src);
result = 0LL;
if ( *s )
result = strlen(s);
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func10(char *src, char *s)
{
int v2; // edx
size_t result; // rax
unsigned int i; // er13
__int64 v5; // rbx
unsigned int v6; // eax
char srca[8]; // [rsp+8h] [rbp-50h] BYREF
char dest[72]; // [rsp+10h] [rbp-48h] BYREF

v2 = strcmp(src, ::src);
result = 0LL;
if ( v2 )
{
strcpy(s, ::src);
for ( i = 0; ; ++i )
{
v5 = *(_QWORD *)(devfs_root + 312);
strcpy(dest, src);
v6 = itoa(i);
strcpy(srca, (const char *)v6);
strcat(srca, ::src);
strcat(dest, srca);
if ( !v5 )
break;
while ( strcmp(dest, (const char *)v5) )
{
v5 = *(_QWORD *)(v5 + 288);
if ( !v5 )
goto LABEL_7;
}
}
LABEL_7:
strcpy(s, dest);
strcat(s, ::src);
result = 0LL;
if ( *s )
result = strlen(s);
}
return result;
}

original_code:
uint32_t devfs_find_freen(char *name, char *res)
{
 inode_t *next;
 if(strcmp(name, "\0") != 0)
 {
  char a[32];
  char b[8];
  int i = 0;
  int over = 1;
  strcpy(res, "\0");
  while(over)
  {
   tent:
   next = devfs_root->childs;
   strcpy(a, name);
   strcpy(b, itoa(i));
   strcat(b, "\0");
   strcat(a, b);
   while(next != 0)
   {
    if(strcmp(a, next->name) == 0)
    {
     i++;
     goto tent;
    }
    next = next->next;
   }
   over = 0;
   strcpy(res, a);
   strcat(res, "\0");
  }
  if(res[0] != '\0')
   return strlen(res);
 }
 return 0;
}

canonical_original_code:
unsigned int devfs_find_freen(char *name, char *res)
{
 struct inode_p *next;
 if(strcmp(name, "\0") != 0)
 {
  char a[32];
  char b[8];
  int i = 0;
  int over = 1;
  strcpy(res, "\0");
  while(over)
  {
   tent:
   next = devfs_root->childs;
   strcpy(a, name);
   strcpy(b, itoa(i));
   strcat(b, "\0");
   strcat(a, b);
   while(next != 0)
   {
    if(strcmp(a, next->name) == 0)
    {
     i++;
     goto tent;
    }
    next = next->next;
   }
   over = 0;
   strcpy(res, a);
   strcat(res, "\0");
  }
  if(res[0] != '\0')
   return strlen(res);
 }
 return 0;
}

variable_types:
res
char *

variable_types:
a
char [32]

variable_types:
b
char [8]

variable_types: over int


decompiled_code:
__int64 __fastcall route_add(__int64 a1, const void *a2, const void *a3, const void *a4, char a5, int a6)
{
__int64 v9; // rbx

v9 = (int)malloc(0x28uLL);
*(_QWORD *)((char *)&loc_17 + v9 + 1) = a1;
*(_DWORD *)((char *)&loc_E + v9 + 2) = a6;
memcpy((void *)v9, a3, 4uLL);
memcpy((void *)(v9 + 4), a2, 4uLL);
memcpy((void *)(v9 + 8), a4, 4uLL);
*(_BYTE *)(v9 + 13) = a5;
*(_QWORD *)(v9 + 32) = route_table;
route_table = v9;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const void *a2, const void *a3, const void *a4, char a5, int a6)
{
__int64 v9; // rbx

v9 = (int)malloc(0x28uLL);
*(_QWORD *)((char *)&loc_17 + v9 + 1) = a1;
*(_DWORD *)((char *)&loc_E + v9 + 2) = a6;
memcpy((void *)v9, a3, 4uLL);
memcpy((void *)(v9 + 4), a2, 4uLL);
memcpy((void *)(v9 + 8), a4, 4uLL);
*(_BYTE *)(v9 + 13) = a5;
*(_QWORD *)(v9 + 32) = route_table;
route_table = v9;
return 0LL;
}

original_code:
uint32_t route_add( network_iface_t *iface, ip_t dest, ip_t gw,
     ip_t genmask, uint8_t if_net, uint32_t flags)
{
 route_entry_t *re = (route_entry_t *) malloc(sizeof(route_entry_t));
 re->iface = iface;
 re->flags = flags;
 memcpy(re->gw, gw, 4);
 memcpy(re->dest, dest, 4);
 memcpy(re->genmask, genmask, 4);
 re->if_net = if_net;
 re->next = route_table;
 route_table = re;
 return 0;
}

canonical_original_code:
unsigned int route_add(struct network_iface_p *iface, char dest[4], char gw[4], char genmask[4], unsigned char if_net, unsigned int flags)
{
 struct route_entry_p *re = (route_entry_t *) malloc(sizeof(route_entry_t));
 re->iface = iface;
 re->flags = flags;
 memcpy(re->gw, gw, 4);
 memcpy(re->dest, dest, 4);
 memcpy(re->genmask, genmask, 4);
 re->if_net = if_net;
 re->next = route_table;
 route_table = re;
 return 0;
}

variable_types:
dest
char [4]

variable_types:
gw
char [4]

variable_types:
genmask
char [4]

variable_types:
flags
unsigned int

variable_types: struct route_entry_p { char gw[4]; char dest[4]; char genmask[4]; unsigned char addr_len; unsigned char if_net; unsigned int flags; struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; } *iface; struct route_entry_p *next; } *

user_defined_types: struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; }

user_defined_types: struct route_entry_p { char gw[4]; char dest[4]; char genmask[4]; unsigned char addr_len; unsigned char if_net; unsigned int flags; struct network_iface_p *iface; struct route_entry_p *next; }


decompiled_code:
void route_del()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
uint32_t route_del(ip_t dest)
{
}

canonical_original_code:
unsigned int route_del(char dest[4])
{
}