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

result = text_mode(1LL);
gflag = 0;
return result;
}

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

result = text_mode(1LL);
gflag = 0;
return result;
}

original_code:
void f_tm()
{
  text_mode(1);
  gflag = 0;
}


repo: monaka/B-Free

decompiled_code:
__int64 f_cls()
{
return fillbox_vga(1LL, 0LL, 0LL, 640LL, 480LL, 0LL);
}

canonical_decompiled_code:
__int64 func3()
{
return fillbox_vga(1LL, 0LL, 0LL, 640LL, 480LL, 0LL);
}

return_type: void


decompiled_code:
__int64 f_moveto()
{
__int64 result; // rax
int v1; // ebx

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
{
cy = v1;
dword_1604 = result;
}
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax
int v1; // ebx

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
{
cy = v1;
dword_1604 = result;
}
}
return result;
}

original_code:
void f_moveto()
{
  int x, y;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  cx = x; cy = y;
}

canonical_original_code:
void f_moveto()
{
  int x; int y;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  cx = x; cy = y;
}

variable_types: x int

variable_types: y int


decompiled_code:
__int64 f_lineto()
{
__int64 result; // rax
unsigned int v1; // ebx
int v2; // ebp
__int64 v3; // [rsp-10h] [rbp-28h]

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
line_vga(1LL, (unsigned int)dword_1604, (unsigned int)cy, (unsigned int)result, v1, (unsigned int)color, 0LL);
result = v3;
dword_1604 = v2;
cy = v1;
}
}
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax
unsigned int v1; // ebx
int v2; // ebp
__int64 v3; // [rsp-10h] [rbp-28h]

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
line_vga(1LL, (unsigned int)dword_1604, (unsigned int)cy, (unsigned int)result, v1, (unsigned int)color, 0LL);
result = v3;
dword_1604 = v2;
cy = v1;
}
}
return result;
}

original_code:
void f_lineto()
{
  int x, y;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  line_vga(1, cx, cy, x, y, color, 0);
  cx = x; cy = y;
}

canonical_original_code:
void f_lineto()
{
  int x; int y;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  line_vga(1, cx, cy, x, y, color, 0);
  cx = x; cy = y;
}


decompiled_code:
__int64 f_rmoveto()
{
__int64 result; // rax
int v1; // ebx

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
{
cy += v1;
dword_1604 += result;
}
}
return result;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 result; // rax
int v1; // ebx

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
{
cy += v1;
dword_1604 += result;
}
}
return result;
}

original_code:
void f_rmoveto()
{
  int x, y;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  cx += x; cy += y;
}

canonical_original_code:
void f_rmoveto()
{
  int x; int y;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  cx += x; cy += y;
}


decompiled_code:
__int64 f_rlineto()
{
__int64 result; // rax
int v1; // ebx
int v2; // ebp
__int64 v3; // [rsp-10h] [rbp-28h]

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
line_vga(
1LL,
(unsigned int)dword_1604,
(unsigned int)cy,
(unsigned int)(dword_1604 + result),
(unsigned int)(cy + v1),
(unsigned int)color,
0LL);
result = v3;
dword_1604 += v2;
cy += v1;
}
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax
int v1; // ebx
int v2; // ebp
__int64 v3; // [rsp-10h] [rbp-28h]

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
line_vga(
1LL,
(unsigned int)dword_1604,
(unsigned int)cy,
(unsigned int)(dword_1604 + result),
(unsigned int)(cy + v1),
(unsigned int)color,
0LL);
result = v3;
dword_1604 += v2;
cy += v1;
}
}
return result;
}

original_code:
void f_rlineto()
{
  int x, y;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  line_vga(1, cx, cy, cx+x, cy+y, color, 0);
  cx += x; cy += y;
}

canonical_original_code:
void f_rlineto()
{
  int x; int y;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  line_vga(1, cx, cy, cx+x, cy+y, color, 0);
  cx += x; cy += y;
}


decompiled_code:
__int64 f_rect()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // er12
unsigned int v3; // er13
__int64 v4; // rsi

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
v4 = (unsigned int)pop();
result = error_no;
if ( !error_no )
result = box_vga(1LL, v4, v3, v2, v1, (unsigned int)color);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // er12
unsigned int v3; // er13
__int64 v4; // rsi

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
v4 = (unsigned int)pop();
result = error_no;
if ( !error_no )
result = box_vga(1LL, v4, v3, v2, v1, (unsigned int)color);
}
}
}
return result;
}

original_code:
void f_rect()
{
  int x, y, w, h;
  h = pop(); if (error_no != 0) return;;
  w = pop(); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  box_vga(1, x, y, w, h, color);
}

canonical_original_code:
void f_rect()
{
  int x; int y; int w; int h;
  h = pop(); if (error_no != 0) return;;
  w = pop(); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  box_vga(1, x, y, w, h, color);
}

variable_types: w int

variable_types: h int


decompiled_code:
__int64 f_rectf()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // er12
unsigned int v3; // er13
__int64 v4; // rsi

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
v4 = (unsigned int)pop();
result = error_no;
if ( !error_no )
result = fillbox_vga(1LL, v4, v3, v2, v1, (unsigned int)color);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // er12
unsigned int v3; // er13
__int64 v4; // rsi

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
v4 = (unsigned int)pop();
result = error_no;
if ( !error_no )
result = fillbox_vga(1LL, v4, v3, v2, v1, (unsigned int)color);
}
}
}
return result;
}

original_code:
void f_rectf()
{
  int x, y, w, h;
  h = pop(); if (error_no != 0) return;;
  w = pop(); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  fillbox_vga(1, x, y, w, h, color);
}

canonical_original_code:
void f_rectf()
{
  int x; int y; int w; int h;
  h = pop(); if (error_no != 0) return;;
  w = pop(); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  fillbox_vga(1, x, y, w, h, color);
}


decompiled_code:
__int64 f_point()
{
__int64 result; // rax
unsigned int v1; // er12
__int64 v2; // rsi

result = pop();
if ( !error_no )
{
v1 = result;
v2 = (unsigned int)pop();
result = error_no;
if ( !error_no )
result = point_vga(1LL, v2, v1, (unsigned int)color, 0LL);
}
return result;
}

canonical_decompiled_code:
__int64 func10()
{
__int64 result; // rax
unsigned int v1; // er12
__int64 v2; // rsi

result = pop();
if ( !error_no )
{
v1 = result;
v2 = (unsigned int)pop();
result = error_no;
if ( !error_no )
result = point_vga(1LL, v2, v1, (unsigned int)color, 0LL);
}
return result;
}

original_code:
void f_point()
{
  int x, y;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  point_vga(1, x, y, color, 0);
}

canonical_original_code:
void f_point()
{
  int x; int y;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  point_vga(1, x, y, color, 0);
}


decompiled_code:
__int64 f_ellips()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // er12
unsigned int v3; // er13
__int64 v4; // rsi

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
v4 = (unsigned int)pop();
result = error_no;
if ( !error_no )
result = ellipse_vga(1LL, v4, v3, v2, v1, (unsigned int)color);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func11()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // er12
unsigned int v3; // er13
__int64 v4; // rsi

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
v4 = (unsigned int)pop();
result = error_no;
if ( !error_no )
result = ellipse_vga(1LL, v4, v3, v2, v1, (unsigned int)color);
}
}
}
return result;
}

original_code:
void f_ellips()
{
  int x, y, w, h;
  h = pop(); if (error_no != 0) return;;
  w = pop(); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  ellipse_vga(1, x, y, w, h, color);
}

canonical_original_code:
void f_ellips()
{
  int x; int y; int w; int h;
  h = pop(); if (error_no != 0) return;;
  w = pop(); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  ellipse_vga(1, x, y, w, h, color);
}


decompiled_code:
__int64 f_ellipsf()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // er12
unsigned int v3; // er13
__int64 v4; // rsi

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
v4 = (unsigned int)pop();
result = error_no;
if ( !error_no )
result = fillellipse_vga(1LL, v4, v3, v2, v1, (unsigned int)color);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func12()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // er12
unsigned int v3; // er13
__int64 v4; // rsi

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
v4 = (unsigned int)pop();
result = error_no;
if ( !error_no )
result = fillellipse_vga(1LL, v4, v3, v2, v1, (unsigned int)color);
}
}
}
return result;
}

original_code:
void f_ellipsf()
{
  int x, y, w, h;
  h = pop(); if (error_no != 0) return;;
  w = pop(); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  fillellipse_vga(1, x, y, w, h, color);
}

canonical_original_code:
void f_ellipsf()
{
  int x; int y; int w; int h;
  h = pop(); if (error_no != 0) return;;
  w = pop(); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  fillellipse_vga(1, x, y, w, h, color);
}


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

result = pop();
if ( !error_no && (int)result >= 0 )
{
result &= 0xFu;
color = result;
}
return result;
}

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

result = pop();
if ( !error_no && (int)result >= 0 )
{
result &= 0xFu;
color = result;
}
return result;
}

original_code:
void f_setcolor()
{
  int c;
  c = pop(); if (error_no != 0) return;;
  if (c >= 0) color = c % 16;
}

variable_types: c int


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

result = pop();
if ( !error_no && (int)result >= 0 )
{
result &= 0xFu;
bgcolor = result;
}
return result;
}

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

result = pop();
if ( !error_no && (int)result >= 0 )
{
result &= 0xFu;
bgcolor = result;
}
return result;
}

original_code:
void f_setbgc()
{
  int c;
  c = pop(); if (error_no != 0) return;;
  if (c >= 0) bgcolor = c % 16;
}


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

result = pop();
if ( !error_no && (int)result >= 0 )
{
result &= 1u;
font = result;
}
return result;
}

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

result = pop();
if ( !error_no && (int)result >= 0 )
{
result &= 1u;
font = result;
}
return result;
}

original_code:
void f_setfont()
{
  int c;
  c = pop(); if (error_no != 0) return;;
  if (c >= 0) font = c % 2;
}


decompiled_code:
size_t f_drawstring()
{
size_t result; // rax
unsigned int v1; // ebx
unsigned int v2; // er14
__int64 v3; // r12
__int64 v4; // r13
char *v5; // rax
char *v6; // [rsp-10h] [rbp-38h]

result = pop_string(str_2);
if ( !error_no )
{
result = pop();
v1 = result;
if ( !error_no )
{
result = pop();
v2 = result;
if ( !error_no )
{
result = strlen(str_2);
if ( result )
{
v3 = (unsigned int)(result + 1);
v4 = 1LL;
while ( 1 )
{
result = (unsigned int)byte_157F[v4];
if ( (unsigned int)(result - 32) >= 0x5F )
result = 32LL;
if ( !font )
break;
if ( font == 1 )
{
v5 = (char *)&a14Bxbm + 14 * (int)result - 448;
LABEL_9:
v6 = v5;
spl_bitmap(1LL, v2, v1, 7LL, 14LL, 14LL);
result = (size_t)v6;
}
++v4;
v2 += 7;
if ( v4 == v3 )
return result;
}
v5 = (char *)&a14xbm + 14 * (int)result - 448;
goto LABEL_9;
}
}
}
}
return result;
}

canonical_decompiled_code:
size_t func16()
{
size_t result; // rax
unsigned int v1; // ebx
unsigned int v2; // er14
__int64 v3; // r12
__int64 v4; // r13
char *v5; // rax
char *v6; // [rsp-10h] [rbp-38h]

result = pop_string(str_2);
if ( !error_no )
{
result = pop();
v1 = result;
if ( !error_no )
{
result = pop();
v2 = result;
if ( !error_no )
{
result = strlen(str_2);
if ( result )
{
v3 = (unsigned int)(result + 1);
v4 = 1LL;
while ( 1 )
{
result = (unsigned int)byte_157F[v4];
if ( (unsigned int)(result - 32) >= 0x5F )
result = 32LL;
if ( !font )
break;
if ( font == 1 )
{
v5 = (char *)&a14Bxbm + 14 * (int)result - 448;
LABEL_9:
v6 = v5;
spl_bitmap(1LL, v2, v1, 7LL, 14LL, 14LL);
result = (size_t)v6;
}
++v4;
v2 += 7;
if ( v4 == v3 )
return result;
}
v5 = (char *)&a14xbm + 14 * (int)result - 448;
goto LABEL_9;
}
}
}
}
return result;
}

original_code:
void f_drawstring()
{
  int x, y, i, len;
  static char str[100];
  pop_string(str); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  len = strlen(str);
  for(i = 0; i < len; ++i) {
    int j;
    j = str[i];
    if ((j < 0x20) || (j > 0x7e)) j = 0x20;
    switch(font) {
    case 0:
      spl_bitmap(1, x, y, 7, 14, 14, a14xbm[j-0x20], color);
      break;
    case 1:
      spl_bitmap(1, x, y, 7, 14, 14, a14Bxbm[j-0x20], color);
      break;
    }
    x += 7;
  }
}

canonical_original_code:
void f_drawstring()
{
  int x; int y; int i; int len;
  static char str[100];
  pop_string(str); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  len = strlen(str);
  for(i = 0; i < len; ++i) {
    int j;
    j = str[i];
    if ((j < 0x20) || (j > 0x7e)) j = 0x20;
    switch(font) {
    case 0:
      spl_bitmap(1, x, y, 7, 14, 14, a14xbm[j-0x20], color);
      break;
    case 1:
      spl_bitmap(1, x, y, 7, 14, 14, a14Bxbm[j-0x20], color);
      break;
    }
    x += 7;
  }
}

variable_types: i int

variable_types: len int

variable_types:
str
char [100]

variable_types: j int


decompiled_code:
size_t f_drawistring()
{
size_t result; // rax
unsigned int v1; // ebx
unsigned int v2; // er14
__int64 v3; // r12
__int64 v4; // r13

result = pop_string(str_1);
if ( !error_no )
{
result = pop();
v1 = result;
if ( !error_no )
{
v2 = pop();
result = error_no;
if ( !error_no )
{
result = strlen(str_1);
if ( result )
{
v3 = (unsigned int)(result + 1);
v4 = 1LL;
do
{
result = (unsigned int)byte_14FF[v4];
if ( (unsigned int)(result - 32) >= 0x5F )
result = 32LL;
if ( font )
{
if ( font == 1 )
result = set_bitmap(
1LL,
v2,
v1,
7LL,
14LL,
14LL,
(char *)&a14Bxbm + 14 * (int)result - 448,
(unsigned int)color,
(unsigned int)bgcolor);
}
else
{
result = set_bitmap(
1LL,
v2,
v1,
7LL,
14LL,
14LL,
(char *)&a14xbm + 14 * (int)result - 448,
(unsigned int)color,
(unsigned int)bgcolor);
}
++v4;
v2 += 7;
}
while ( v4 != v3 );
}
}
}
}
return result;
}

canonical_decompiled_code:
size_t func17()
{
size_t result; // rax
unsigned int v1; // ebx
unsigned int v2; // er14
__int64 v3; // r12
__int64 v4; // r13

result = pop_string(str_1);
if ( !error_no )
{
result = pop();
v1 = result;
if ( !error_no )
{
v2 = pop();
result = error_no;
if ( !error_no )
{
result = strlen(str_1);
if ( result )
{
v3 = (unsigned int)(result + 1);
v4 = 1LL;
do
{
result = (unsigned int)byte_14FF[v4];
if ( (unsigned int)(result - 32) >= 0x5F )
result = 32LL;
if ( font )
{
if ( font == 1 )
result = set_bitmap(
1LL,
v2,
v1,
7LL,
14LL,
14LL,
(char *)&a14Bxbm + 14 * (int)result - 448,
(unsigned int)color,
(unsigned int)bgcolor);
}
else
{
result = set_bitmap(
1LL,
v2,
v1,
7LL,
14LL,
14LL,
(char *)&a14xbm + 14 * (int)result - 448,
(unsigned int)color,
(unsigned int)bgcolor);
}
++v4;
v2 += 7;
}
while ( v4 != v3 );
}
}
}
}
return result;
}

original_code:
void f_drawistring()
{
  int x, y, i, len;
  static char str[100];
  pop_string(str); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  len = strlen(str);
  for(i = 0; i < len; ++i) {
    int j;
    j = str[i];
    if ((j < 0x20) || (j > 0x7e)) j = 0x20;
    switch(font) {
    case 0:
      set_bitmap(1, x, y, 7, 14, 14, a14xbm[j-0x20], color, bgcolor);
      break;
    case 1:
      set_bitmap(1, x, y, 7, 14, 14, a14Bxbm[j-0x20], color, bgcolor);
      break;
    }
    x += 7;
  }
}

canonical_original_code:
void f_drawistring()
{
  int x; int y; int i; int len;
  static char str[100];
  pop_string(str); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  len = strlen(str);
  for(i = 0; i < len; ++i) {
    int j;
    j = str[i];
    if ((j < 0x20) || (j > 0x7e)) j = 0x20;
    switch(font) {
    case 0:
      set_bitmap(1, x, y, 7, 14, 14, a14xbm[j-0x20], color, bgcolor);
      break;
    case 1:
      set_bitmap(1, x, y, 7, 14, 14, a14Bxbm[j-0x20], color, bgcolor);
      break;
    }
    x += 7;
  }
}


decompiled_code:
int f_kfopen()
{
int result; // eax

pop_string(name_0);
result = error_no;
if ( !error_no )
{
k_fd = open(name_0, 4, 0LL);
if ( k_fd < 0 )
{
result = printf("cant open file %s\n", name_0);
}
else
{
read(k_fd, fheader, 0xEuLL);
if ( !strcmp(fheader, "BFB") )
{
result = printf(
"size = %d top_code = %x end_code = %x\n",
(unsigned int)word_15EC,
(unsigned __int16)word_15F2,
(unsigned __int16)word_15F4);
has_kfont = 1;
}
else
{
printf("opened file is not %s font", "BFB");
result = close(k_fd);
}
}
}
return result;
}

canonical_decompiled_code:
int func18()
{
int result; // eax

pop_string(name_0);
result = error_no;
if ( !error_no )
{
k_fd = open(name_0, 4, 0LL);
if ( k_fd < 0 )
{
result = printf("cant open file %s\n", name_0);
}
else
{
read(k_fd, fheader, 0xEuLL);
if ( !strcmp(fheader, "BFB") )
{
result = printf(
"size = %d top_code = %x end_code = %x\n",
(unsigned int)word_15EC,
(unsigned __int16)word_15F2,
(unsigned __int16)word_15F4);
has_kfont = 1;
}
else
{
printf("opened file is not %s font", "BFB");
result = close(k_fd);
}
}
}
return result;
}

original_code:
void f_kfopen()
{
  static char name[100];
  pop_string(name); if (error_no != 0) return;;
  if ((k_fd = open(name, 4, 0)) < 0) {
    printf("cant open file %s\n", name);
    return;
  }
  read(k_fd, &fheader, sizeof(struct font_header));
  if (strcmp(fheader.magic, "BFB") != 0) {
    printf("opened file is not %s font", "BFB");
    close(k_fd);
    return;
  }
  printf("size = %d top_code = %x end_code = %x\n",
  fheader.fnt_size, fheader.top_code, fheader.end_code);
  has_kfont = 1;
}

variable_types:
name
char [100]

user_defined_types: struct font_header { char magic[4]; short fnt_size; short fnt_height; short fnt_width; unsigned short top_code; unsigned short end_code; }


decompiled_code:
int f_kfclose()
{
int result; // eax

result = has_kfont;
if ( has_kfont )
{
result = close(k_fd);
k_fd = -1;
has_kfont = 0;
}
return result;
}

canonical_decompiled_code:
int func19()
{
int result; // eax

result = has_kfont;
if ( has_kfont )
{
result = close(k_fd);
k_fd = -1;
has_kfont = 0;
}
return result;
}

original_code:
void f_kfclose()
{
  if (! has_kfont) return;
  close(k_fd);
  k_fd = -1;
  has_kfont = 0;
}


decompiled_code:
__int64 f_drawkch()
{
__int64 result; // rax
int v1; // ebp
unsigned int v2; // er12
unsigned int v3; // er13
int v4; // eax
_BYTE v5[280]; // [rsp+0h] [rbp-118h] BYREF

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
result = (unsigned int)has_kfont;
if ( has_kfont )
{
result = (unsigned __int16)word_15F2;
if ( (unsigned __int16)word_15F2 <= v1 )
{
result = (unsigned __int16)word_15F4;
if ( (unsigned __int16)word_15F4 >= v1 )
{
v4 = cal_offset(v1);
lseek(k_fd, (unsigned int)(v4 * word_15EC + 1024), 0);
read(k_fd, v5, (unsigned int)word_15EC);
result = set_bitmap(
1LL,
v3,
v2,
(unsigned int)word_15F0,
(unsigned int)word_15EE,
(unsigned int)word_15EC,
v5,
(unsigned int)color,
(unsigned int)bgcolor);
}
}
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func20()
{
__int64 result; // rax
int v1; // ebp
unsigned int v2; // er12
unsigned int v3; // er13
int v4; // eax
_BYTE v5[280]; // [rsp+0h] [rbp-118h] BYREF

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
result = (unsigned int)has_kfont;
if ( has_kfont )
{
result = (unsigned __int16)word_15F2;
if ( (unsigned __int16)word_15F2 <= v1 )
{
result = (unsigned __int16)word_15F4;
if ( (unsigned __int16)word_15F4 >= v1 )
{
v4 = func0(v1);
lseek(k_fd, (unsigned int)(v4 * word_15EC + 1024), 0);
read(k_fd, v5, (unsigned int)word_15EC);
result = set_bitmap(
1LL,
v3,
v2,
(unsigned int)word_15F0,
(unsigned int)word_15EE,
(unsigned int)word_15EC,
v5,
(unsigned int)color,
(unsigned int)bgcolor);
}
}
}
}
}
}
return result;
}

original_code:
void f_drawkch()
{
  int x, y, code, oft;
  char buf[255];
  code = pop(); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  if (! has_kfont) return;
  if (code < fheader.top_code || code > fheader.end_code) return;
  oft = cal_offset(code);
  lseek(k_fd, 1024 + oft*fheader.fnt_size, 0);
  read(k_fd, buf, fheader.fnt_size);
  set_bitmap(1, x, y, fheader.fnt_width, fheader.fnt_height, fheader.fnt_size,
      buf, color, bgcolor);
}

canonical_original_code:
void f_drawkch()
{
  int x; int y; int code; int oft;
  char buf[255];
  code = pop(); if (error_no != 0) return;;
  y = pop(); if (error_no != 0) return;;
  x = pop(); if (error_no != 0) return;;
  if (! has_kfont) return;
  if (code < fheader.top_code || code > fheader.end_code) return;
  oft = cal_offset(code);
  lseek(k_fd, 1024 + oft*fheader.fnt_size, 0);
  read(k_fd, buf, fheader.fnt_size);
  set_bitmap(1, x, y, fheader.fnt_width, fheader.fnt_height, fheader.fnt_size,
      buf, color, bgcolor);
}

variable_types: code int

variable_types: oft int

variable_types:
buf
char [255]


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

result = pop();
if ( !error_no )
result = winmod(1LL, (unsigned int)result);
return result;
}

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

result = pop();
if ( !error_no )
result = winmod(1LL, (unsigned int)result);
return result;
}

original_code:
void f_winmod()
{
  int mode;
  mode = pop(); if (error_no != 0) return;;
  winmod(1, mode);
}

variable_types: mode int


decompiled_code:
__int64 __fastcall reset_adaptor(_WORD *a1)
{
__int64 v1; // rbx
unsigned __int8 v2; // al

v1 = 30000LL;
printf("NE2000: reset\n");
v2 = inb(*a1 + 31);
outb(*(_BYTE *)a1 + 31, v2);
do
{
if ( (inb(*a1 + 7) & 0x80u) != 0 )
break;
--v1;
}
while ( v1 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_WORD *a1)
{
__int64 v1; // rbx
unsigned __int8 v2; // al

v1 = 30000LL;
printf("NE2000: reset\n");
v2 = inb(*a1 + 31);
outb(*(_BYTE *)a1 + 31, v2);
do
{
if ( (inb(*a1 + 7) & 0x80u) != 0 )
break;
--v1;
}
while ( v1 );
return 0LL;
}

original_code:
ER
reset_adaptor (struct ne2000_device *dev)
{
  W i;
  UB data;
  printf ("NE2000: reset\n");
  data = inb ((dev->io_base + 0x1f));
  outb ((dev->io_base + 0x1f), data);
  for (i = 0; i < 30000; i++)
    {
      data = inb ((dev->io_base) + 0x07);
      if (data & 0x80)
 {
   break;
 }
    }
  return ((0));
}

canonical_original_code:
int reset_adaptor(struct ne2000_device *dev)
{
  long i;
  unsigned char data;
  printf ("NE2000: reset\n");
  data = inb ((dev->io_base + 0x1f));
  outb ((dev->io_base + 0x1f), data);
  for (i = 0; i < 30000; i++)
    {
      data = inb ((dev->io_base) + 0x07);
      if (data & 0x80)
 {
   break;
 }
    }
  return ((0));
}

variable_types: struct ne2000_device { unsigned long io_base; unsigned char sa_prom[32]; char tx_busy; char tx_use; char tx_new; char tx_next; char tx_len[2]; char rx_next; char word_access; unsigned long tx_count; unsigned long tx_error; unsigned long collision; unsigned long rx_count; unsigned long rx_error; unsigned char intr_number; void (*intr_handler)(); } *

variable_types: i long

variable_types:
data
unsigned char

return_type: int


decompiled_code:
void read_frame()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
ER
read_frame (struct ne2000_device *dev, B *buf, W *buflen)
{
}

canonical_original_code:
int read_frame(struct ne2000_device *dev, char *buf, long *buflen)
{
}

variable_types:
buf
char *

variable_types:
buflen
long *

user_defined_types: struct ne2000_device { unsigned long io_base; unsigned char sa_prom[32]; char tx_busy; char tx_use; char tx_new; char tx_next; char tx_len[2]; char rx_next; char word_access; unsigned long tx_count; unsigned long tx_error; unsigned long collision; unsigned long rx_count; unsigned long rx_error; unsigned char intr_number; void (*intr_handler)(); }


original_code:
ER
copy_from_ne2000 (struct ne2000_device *dev, B *buf, UH tx_buf, W buflen)
{
  return ((-17));
}

canonical_original_code:
int copy_from_ne2000(struct ne2000_device *dev, char *buf, unsigned short tx_buf, long buflen)
{
  return ((-17));
}

variable_types: buflen long


decompiled_code:
void __fastcall select_page0(_QWORD *a1)
{
outb(*a1, 0x22u);
}

canonical_decompiled_code:
void __fastcall func3(_QWORD *a1)
{
outb(*a1, 0x22u);
}

original_code:
void
select_page0 (struct ne2000_device *dev)
{
  outb ((dev->io_base + 0x00), 0x00 + 0x02 + 0x20);
}

canonical_original_code:
void select_page0(struct ne2000_device *dev)
{
  outb ((dev->io_base + 0x00), 0x00 + 0x02 + 0x20);
}


decompiled_code:
__int64 __fastcall ne2000_transmit(__int64 a1)
{
__int16 v1; // bp
int v2; // edx
__int64 result; // rax

v1 = *(char *)(a1 + *(char *)(a1 + 43) + 44);
printf("ne2000_transmit: %d\n", 337LL);
select_page0((_QWORD *)a1);
outb(*(_BYTE *)a1 + 4, (*(char *)(a1 + 43) << 8) + 64);
outb(*(_BYTE *)a1 + 5, (unsigned __int8)v1);
outb(*(_BYTE *)a1 + 6, HIBYTE(v1));
outb(*(_QWORD *)a1, 0x26u);
*(_BYTE *)(a1 + 40) = 1;
printf("ne2000_transmit: %d\n", 353LL);
v2 = *(unsigned __int8 *)(a1 + 43);
result = (unsigned int)(v2 + 1);
if ( (_BYTE)v2 == 1 )
result = 0LL;
*(_BYTE *)(a1 + 43) = result;
return result;
}

original_code:
void
ne2000_transmit (struct ne2000_device *dev)
{
  UH length;
  length = dev->tx_len[ dev->tx_next ];
  printf ("ne2000_transmit: %d\n", 337);
  select_page0 (dev);
  outb ((dev->io_base + 0x00) + 0x04, 64 + dev->tx_next * 256);
  outb ((dev->io_base + 0x00) + 0x05, length & 0xff);
  outb ((dev->io_base + 0x00) + 0x06, length >> 8);
  outb ((dev->io_base + 0x00), 0x20 | 0x00 | 0x04 | 0x02);
  dev->tx_busy = 1;
  printf ("ne2000_transmit: %d\n", 353);
  dev->tx_next++;
  if (dev->tx_next == 2 ) dev->tx_next = 0;
}

canonical_original_code:
void ne2000_transmit(struct ne2000_device *dev)
{
  unsigned short length;
  length = dev->tx_len[ dev->tx_next ];
  printf ("ne2000_transmit: %d\n", 337);
  select_page0 (dev);
  outb ((dev->io_base + 0x00) + 0x04, 64 + dev->tx_next * 256);
  outb ((dev->io_base + 0x00) + 0x05, length & 0xff);
  outb ((dev->io_base + 0x00) + 0x06, length >> 8);
  outb ((dev->io_base + 0x00), 0x20 | 0x00 | 0x04 | 0x02);
  dev->tx_busy = 1;
  printf ("ne2000_transmit: %d\n", 353);
  dev->tx_next++;
  if (dev->tx_next == 2 ) dev->tx_next = 0;
}

variable_types:
length
unsigned short


decompiled_code:
__int64 __fastcall copy_to_ne2000(_QWORD *a1, unsigned __int16 *a2, __int16 a3, __int64 a4)
{
unsigned __int16 *v6; // rbx
unsigned __int16 *v7; // r13
unsigned __int16 v8; // si
__int64 v9; // rbx

v6 = a2;
select_page0(a1);
outb(*(_BYTE *)a1 + 7, 0x40u);
outb(*(_BYTE *)a1 + 10, (unsigned __int8)a4);
outb(*(_BYTE *)a1 + 11, (int)a4 >> 8);
outb(*(_BYTE *)a1 + 8, (unsigned __int8)a3);
outb(*(_BYTE *)a1 + 9, HIBYTE(a3));
outb(*a1, 0x12u);
if ( a4 > 1 )
{
v7 = (unsigned __int16 *)((char *)a2 + (a4 & 0xFFFFFFFFFFFFFFFELL));
do
{
v8 = *v6++;
outw(*(_WORD *)a1 + 16, v8);
}
while ( v7 != v6 );
a4 &= 1u;
}
if ( a4 == 1 )
outw(*(_WORD *)a1 + 16, *((unsigned __int8 *)v6 - 1));
v9 = 100LL;
do
{
if ( (inb(*(_WORD *)a1 + 7) & 0x40) == 0 )
return 0LL;
--v9;
}
while ( v9 );
select_page0(a1);
ne2000_transmit((__int64)a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, unsigned __int16 *a2, __int16 a3, __int64 a4)
{
unsigned __int16 *v6; // rbx
unsigned __int16 *v7; // r13
unsigned __int16 v8; // si
__int64 v9; // rbx

v6 = a2;
func3(a1);
outb(*(_BYTE *)a1 + 7, 0x40u);
outb(*(_BYTE *)a1 + 10, (unsigned __int8)a4);
outb(*(_BYTE *)a1 + 11, (int)a4 >> 8);
outb(*(_BYTE *)a1 + 8, (unsigned __int8)a3);
outb(*(_BYTE *)a1 + 9, HIBYTE(a3));
outb(*a1, 0x12u);
if ( a4 > 1 )
{
v7 = (unsigned __int16 *)((char *)a2 + (a4 & 0xFFFFFFFFFFFFFFFELL));
do
{
v8 = *v6++;
outw(*(_WORD *)a1 + 16, v8);
}
while ( v7 != v6 );
a4 &= 1u;
}
if ( a4 == 1 )
outw(*(_WORD *)a1 + 16, *((unsigned __int8 *)v6 - 1));
v9 = 100LL;
do
{
if ( (inb(*(_WORD *)a1 + 7) & 0x40) == 0 )
return 0LL;
--v9;
}
while ( v9 );
func3(a1);
func4((__int64)a1);
return 0LL;
}

original_code:
ER
copy_to_ne2000 (struct ne2000_device *dev, B *buf, UH tx_buf, W buflen)
{
  W maxwait = 100;
  UB savebyte[2];
  select_page0 (dev);
  outb ((dev->io_base) + 0x07, 0x40);
  outb ((dev->io_base) + 0x0a, buflen & 0xff);
  outb ((dev->io_base) + 0x0b, buflen >> 8);
  outb ((dev->io_base) + 0x08, tx_buf & 0xff);
  outb ((dev->io_base) + 0x09, tx_buf >> 8);
  outb ((dev->io_base + 0x00), (0x10 + 0x00 + 0x02));
  if (buflen > 1)
    {
      W i;
      for (i = 0; i < (buflen / 2); i++)
 {
   UH tmp;
   tmp = *(UH *)buf;
   outw ((dev->io_base + 0x10), tmp);
   buf += 2;
 }
      buflen &=1;
    }
  if (buflen==1){
    savebyte[0] = *(buf - 1);
    savebyte[1] = 0;
    outw ((dev->io_base + 0x10), *(UH *)savebyte);
  }
  while ((inb ((dev->io_base) + 0x07) & 0x40) && (--maxwait))
    {
      ;
    }
  if (!maxwait)
    {
      select_page0 (dev);
      ne2000_transmit (dev);
    }
  return ((0));
}

canonical_original_code:
int copy_to_ne2000(struct ne2000_device *dev, char *buf, unsigned short tx_buf, long buflen)
{
  long maxwait = 100;
  unsigned char savebyte[2];
  select_page0 (dev);
  outb ((dev->io_base) + 0x07, 0x40);
  outb ((dev->io_base) + 0x0a, buflen & 0xff);
  outb ((dev->io_base) + 0x0b, buflen >> 8);
  outb ((dev->io_base) + 0x08, tx_buf & 0xff);
  outb ((dev->io_base) + 0x09, tx_buf >> 8);
  outb ((dev->io_base + 0x00), (0x10 + 0x00 + 0x02));
  if (buflen > 1)
    {
      long i;
      for (i = 0; i < (buflen / 2); i++)
 {
   unsigned short tmp;
   tmp = *(unsigned short *)buf;
   outw ((dev->io_base + 0x10), tmp);
   buf += 2;
 }
      buflen &=1;
    }
  if (buflen==1){
    savebyte[0] = *(buf - 1);
    savebyte[1] = 0;
    outw ((dev->io_base + 0x10), *(unsigned short *)savebyte);
  }
  while ((inb ((dev->io_base) + 0x07) & 0x40) && (--maxwait))
    {
      ;
    }
  if (!maxwait)
    {
      select_page0 (dev);
      ne2000_transmit (dev);
    }
  return ((0));
}

variable_types: maxwait long

variable_types:
savebyte
unsigned char [2]

variable_types:
tmp
unsigned short


original_code:
ER
write_frame (struct ne2000_device *dev, B *buf, W buflen)
{
  UH tx_buf;
  if (buflen > 1514)
    {
      return ((-33));
    }
  if (dev->tx_use > 0)
    {
      ne2000_transmit (dev);
    }
  if (dev->tx_busy == 1)
    {
      return ((-101));
    }
  if (dev->tx_use >= 2)
    {
      return ((-101));
    }
  tx_buf = 0x4000 + (dev->tx_new * 6 * 256);
  copy_to_ne2000 (dev, buf, tx_buf, buflen);
  if ( buflen > 64)
    {
      dev->tx_len[dev->tx_new] = buflen;
    }
  else
    {
      dev->tx_len[dev->tx_new] = 64;
    }
  dev->tx_use++;
  dev->tx_new++;
  if (dev->tx_new == 2)
    {
      dev->tx_new = 0;
    }
  if (dev->tx_busy == 0)
    {
printf ("%s: %d\n", "ne2000low.c", 424);
      ne2000_transmit (dev);
printf ("%s: %d\n", "ne2000low.c", 426);
    }
  return ((0));
}

canonical_original_code:
int write_frame(struct ne2000_device *dev, char *buf, long buflen)
{
  unsigned short tx_buf;
  if (buflen > 1514)
    {
      return ((-33));
    }
  if (dev->tx_use > 0)
    {
      ne2000_transmit (dev);
    }
  if (dev->tx_busy == 1)
    {
      return ((-101));
    }
  if (dev->tx_use >= 2)
    {
      return ((-101));
    }
  tx_buf = 0x4000 + (dev->tx_new * 6 * 256);
  copy_to_ne2000 (dev, buf, tx_buf, buflen);
  if ( buflen > 64)
    {
      dev->tx_len[dev->tx_new] = buflen;
    }
  else
    {
      dev->tx_len[dev->tx_new] = 64;
    }
  dev->tx_use++;
  dev->tx_new++;
  if (dev->tx_new == 2)
    {
      dev->tx_new = 0;
    }
  if (dev->tx_busy == 0)
    {
printf ("%s: %d\n", "ne2000low.c", 424);
      ne2000_transmit (dev);
printf ("%s: %d\n", "ne2000low.c", 426);
    }
  return ((0));
}


decompiled_code:
void __fastcall select_page1(_QWORD *a1)
{
outb(*a1, 0x62u);
}

canonical_decompiled_code:
void __fastcall func7(_QWORD *a1)
{
outb(*a1, 0x62u);
}

original_code:
void
select_page1 (struct ne2000_device *dev)
{
  outb ((dev->io_base + 0x00), 0x40 + 0x02 + 0x20);
}

canonical_original_code:
void select_page1(struct ne2000_device *dev)
{
  outb ((dev->io_base + 0x00), 0x40 + 0x02 + 0x20);
}


decompiled_code:
char __fastcall probe_1(_WORD *a1)
{
unsigned __int16 v1; // ax
unsigned __int16 v2; // bp
int v3; // eax

reset_adaptor(a1);
inb(*(_QWORD *)a1);
select_page1(a1);
LOBYTE(v1) = inb(*a1 + 13);
v2 = v1;
outb(*(_BYTE *)a1 + 13, 0xFFu);
outb(*(_QWORD *)a1, 0x20u);
inb(*a1 + 13);
LOBYTE(v3) = inb(*a1 + 13);
if ( v3 )
{
outb(*(_QWORD *)a1, 0);
outb(*(_BYTE *)a1 + 13, v2);
dbg_printf("NE*000: ethernetcard probe at 0x%x\n", *(_QWORD *)a1);
LOBYTE(v3) = -101;
}
return v3;
}

canonical_decompiled_code:
char __fastcall func8(_WORD *a1)
{
unsigned __int16 v1; // ax
unsigned __int16 v2; // bp
int v3; // eax

func0(a1);
inb(*(_QWORD *)a1);
func7(a1);
LOBYTE(v1) = inb(*a1 + 13);
v2 = v1;
outb(*(_BYTE *)a1 + 13, 0xFFu);
outb(*(_QWORD *)a1, 0x20u);
inb(*a1 + 13);
LOBYTE(v3) = inb(*a1 + 13);
if ( v3 )
{
outb(*(_QWORD *)a1, 0);
outb(*(_BYTE *)a1 + 13, v2);
dbg_printf("NE*000: ethernetcard probe at 0x%x\n", *(_QWORD *)a1);
LOBYTE(v3) = -101;
}
return v3;
}

original_code:
ER
probe_1 (struct ne2000_device *dev)
{
  W regd;
  W reg0;
  W reg;
  reset_adaptor (dev);
  reg = inb ((dev->io_base));
  select_page1 (dev);
  regd = inb ((dev->io_base) + 0x0d);
  outb ((dev->io_base) + 0x0d, 0xff);
  outb ((dev->io_base + 0x00), 0x20 + 0x00);
  inb ((dev->io_base) + 0x0d);
  if (inb ((dev->io_base) + 0x0d) != 0) {
    outb ((dev->io_base), reg0);
    outb ((dev->io_base) + 0x0d, regd);
    dbg_printf ("NE*000: ethernetcard probe at 0x%x\n", (dev->io_base));
    return ((-101));
  }
  return ((0));
}

canonical_original_code:
int probe_1(struct ne2000_device *dev)
{
  long regd;
  long reg0;
  long reg;
  reset_adaptor (dev);
  reg = inb ((dev->io_base));
  select_page1 (dev);
  regd = inb ((dev->io_base) + 0x0d);
  outb ((dev->io_base) + 0x0d, 0xff);
  outb ((dev->io_base + 0x00), 0x20 + 0x00);
  inb ((dev->io_base) + 0x0d);
  if (inb ((dev->io_base) + 0x0d) != 0) {
    outb ((dev->io_base), reg0);
    outb ((dev->io_base) + 0x0d, regd);
    dbg_printf ("NE*000: ethernetcard probe at 0x%x\n", (dev->io_base));
    return ((-101));
  }
  return ((0));
}

variable_types: regd long

variable_types: reg long


original_code:
W
init_adaptor (struct ne2000_device *dev)
{
  W saprom_index;
  W macaddr_index;
  dev->word_access = 2;
  reset_adaptor (dev);
  outb ((dev->io_base + 0x00), 0x00 + 0x02 + 0x20);
  outb ((dev->io_base) + 0x0e, 0x48);
  outb ((dev->io_base) + 0x0a, 0x00);
  outb ((dev->io_base) + 0x0b, 0x00);
  outb ((dev->io_base) + 0x0f, 0x00);
  outb ((dev->io_base) + 0x07, 0xff);
  outb ((dev->io_base) + 0x0c, 0x20);
  outb ((dev->io_base) + 0x0d, 0x02);
  outb ((dev->io_base) + 0x0a, 32);
  outb ((dev->io_base) + 0x0b, 0);
  outb ((dev->io_base) + 0x08, 0);
  outb ((dev->io_base) + 0x09, 0);
  outb ((dev->io_base + 0x00), 0x08 + 0x02);
  for (saprom_index = 0; saprom_index < 32; saprom_index += 2)
    {
      dev->sa_prom[saprom_index] = (UW)inb ((dev->io_base + 0x10)) & 0xff;
      dev->sa_prom[saprom_index + 1] = (UW)inb ((dev->io_base + 0x10)) & 0xff;
      if (dev->sa_prom[saprom_index] != dev->sa_prom[saprom_index + 1])
 {
   dev->word_access = 1;
 }
    }
  if (dev->word_access == 2)
    {
      for (saprom_index = 0; saprom_index < 16; saprom_index++)
 {
   dev->sa_prom[saprom_index] = dev->sa_prom[saprom_index + saprom_index];
 }
    }
  else
    {
      return ((-17));
    }
  select_page1 (dev);
  for (macaddr_index = 0; macaddr_index < 6; macaddr_index++)
    {
      outb ((dev->io_base) + 0x01 + macaddr_index, dev->sa_prom[macaddr_index]);
    }
  return ((0));
}

canonical_original_code:
long init_adaptor(struct ne2000_device *dev)
{
  long saprom_index;
  long macaddr_index;
  dev->word_access = 2;
  reset_adaptor (dev);
  outb ((dev->io_base + 0x00), 0x00 + 0x02 + 0x20);
  outb ((dev->io_base) + 0x0e, 0x48);
  outb ((dev->io_base) + 0x0a, 0x00);
  outb ((dev->io_base) + 0x0b, 0x00);
  outb ((dev->io_base) + 0x0f, 0x00);
  outb ((dev->io_base) + 0x07, 0xff);
  outb ((dev->io_base) + 0x0c, 0x20);
  outb ((dev->io_base) + 0x0d, 0x02);
  outb ((dev->io_base) + 0x0a, 32);
  outb ((dev->io_base) + 0x0b, 0);
  outb ((dev->io_base) + 0x08, 0);
  outb ((dev->io_base) + 0x09, 0);
  outb ((dev->io_base + 0x00), 0x08 + 0x02);
  for (saprom_index = 0; saprom_index < 32; saprom_index += 2)
    {
      dev->sa_prom[saprom_index] = (unsigned long)inb ((dev->io_base + 0x10)) & 0xff;
      dev->sa_prom[saprom_index + 1] = (unsigned long)inb ((dev->io_base + 0x10)) & 0xff;
      if (dev->sa_prom[saprom_index] != dev->sa_prom[saprom_index + 1])
 {
   dev->word_access = 1;
 }
    }
  if (dev->word_access == 2)
    {
      for (saprom_index = 0; saprom_index < 16; saprom_index++)
 {
   dev->sa_prom[saprom_index] = dev->sa_prom[saprom_index + saprom_index];
 }
    }
  else
    {
      return ((-17));
    }
  select_page1 (dev);
  for (macaddr_index = 0; macaddr_index < 6; macaddr_index++)
    {
      outb ((dev->io_base) + 0x01 + macaddr_index, dev->sa_prom[macaddr_index]);
    }
  return ((0));
}

return_type: long


probe

decompiled_code:
char __fastcall probe(_WORD *a1)
{
__int64 v1; // rax
__int64 v2; // rbx
int v3; // eax

v1 = port_table[0];
if ( port_table[0] <= 0 )
goto LABEL_7;
v2 = 0LL;
while ( 1 )
{
*(_QWORD *)a1 = v1;
LOBYTE(v3) = probe_1(a1);
if ( !v3 )
break;
v1 = port_table[++v2];
if ( v1 <= 0 )
goto LABEL_7;
}
if ( port_table[v2] <= 0 )
{
LABEL_7:
dbg_printf("Can not probe: ne2000\n");
LOBYTE(v3) = -101;
}
else
{
port_table[v2] = 0LL;
}
return v3;
}

canonical_decompiled_code:
char __fastcall func9(_WORD *a1)
{
__int64 v1; // rax
__int64 v2; // rbx
int v3; // eax

v1 = port_table[0];
if ( port_table[0] <= 0 )
goto LABEL_7;
v2 = 0LL;
while ( 1 )
{
*(_QWORD *)a1 = v1;
LOBYTE(v3) = func8(a1);
if ( !v3 )
break;
v1 = port_table[++v2];
if ( v1 <= 0 )
goto LABEL_7;
}
if ( port_table[v2] <= 0 )
{
LABEL_7:
dbg_printf("Can not probe: ne2000\n");
LOBYTE(v3) = -101;
}
else
{
port_table[v2] = 0LL;
}
return v3;
}

original_code:
ER
probe (struct ne2000_device *dev)
{
  W counter;
  for (counter = 0; port_table[counter] > 0; counter++)
    {
      if (port_table[counter] != 0)
 {
   (dev->io_base) = port_table[counter];
   if (probe_1 (dev) == (0))
     break;
 }
    }
  if (port_table[counter] <= 0)
    {
      dbg_printf ("Can not probe: ne2000\n");
      return ((-101));
    }
  port_table[counter] = 0;
  return ((0));
}

canonical_original_code:
int probe(struct ne2000_device *dev)
{
  long counter;
  for (counter = 0; port_table[counter] > 0; counter++)
    {
      if (port_table[counter] != 0)
 {
   (dev->io_base) = port_table[counter];
   if (probe_1 (dev) == (0))
     break;
 }
    }
  if (port_table[counter] <= 0)
    {
      dbg_printf ("Can not probe: ne2000\n");
      return ((-101));
    }
  port_table[counter] = 0;
  return ((0));
}

variable_types: counter long


original_code:
ER
init_device (struct ne2000_device *dev)
{
  dev->tx_busy = 0;
  dev->tx_use = 0;
  dev->tx_new = 0;
  dev->tx_next = 0;
  dev->rx_next = 76;
  dev->intr_number = 35;
  dev->intr_handler = ne2000_interrupt_handler;
  set_interrupt_handler (dev, dev->intr_number,dev->intr_handler);
  select_page0 (dev);
  outb ((dev->io_base) + 0x0e, 0x49);
  outb ((dev->io_base) + 0x0a, 0x00);
  outb ((dev->io_base) + 0x0b, 0x00);
  outb ((dev->io_base) + 0x0c, 0x20);
  outb ((dev->io_base) + 0x0d, 0x02);
  outb ((dev->io_base) + 0x04, 64);
  outb ((dev->io_base) + 0x01, 76);
  outb ((dev->io_base) + 0x02, 128);
  outb ((dev->io_base) + 0x03, 76);
  outb ((dev->io_base) + 0x07, 0xff);
  outb ((dev->io_base) + 0x0f, 0x01 | 0x02 | 0x04 | 0x08 | 0x10 );
  select_page1 (dev);
  outb ((dev->io_base) + 0x07, dev->rx_next);
  select_page0 (dev);
  outb ((dev->io_base) + 0x0c, 0x04);
  outb ((dev->io_base) + 0x0d, 0x00);
  outb ((dev->io_base) + 0x00, 0x20 + 0x00 + 0x02);
  return ((0));
}

canonical_original_code:
int init_device(struct ne2000_device *dev)
{
  dev->tx_busy = 0;
  dev->tx_use = 0;
  dev->tx_new = 0;
  dev->tx_next = 0;
  dev->rx_next = 76;
  dev->intr_number = 35;
  dev->intr_handler = ne2000_interrupt_handler;
  set_interrupt_handler (dev, dev->intr_number,dev->intr_handler);
  select_page0 (dev);
  outb ((dev->io_base) + 0x0e, 0x49);
  outb ((dev->io_base) + 0x0a, 0x00);
  outb ((dev->io_base) + 0x0b, 0x00);
  outb ((dev->io_base) + 0x0c, 0x20);
  outb ((dev->io_base) + 0x0d, 0x02);
  outb ((dev->io_base) + 0x04, 64);
  outb ((dev->io_base) + 0x01, 76);
  outb ((dev->io_base) + 0x02, 128);
  outb ((dev->io_base) + 0x03, 76);
  outb ((dev->io_base) + 0x07, 0xff);
  outb ((dev->io_base) + 0x0f, 0x01 | 0x02 | 0x04 | 0x08 | 0x10 );
  select_page1 (dev);
  outb ((dev->io_base) + 0x07, dev->rx_next);
  select_page0 (dev);
  outb ((dev->io_base) + 0x0c, 0x04);
  outb ((dev->io_base) + 0x0d, 0x00);
  outb ((dev->io_base) + 0x00, 0x20 + 0x00 + 0x02);
  return ((0));
}


decompiled_code:
__int64 __fastcall psys_chdir(__int64 *a1)
{
__int64 v2; // [rsp+0h] [rbp-C8h] BYREF
__int64 v3; // [rsp+18h] [rbp-B0h]
unsigned int v4; // [rsp+20h] [rbp-A8h]
char v5[32]; // [rsp+40h] [rbp-88h] BYREF
__int64 v6; // [rsp+60h] [rbp-68h]
__int64 v7; // [rsp+68h] [rbp-60h]

v7 = a1[1];
v6 = *a1;
if ( (unsigned int)make_connection(2LL, v5, &v2) || !v3 )
return v4;
MEMORY[0x7FFF0028] = v3;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1)
{
__int64 v2; // [rsp+0h] [rbp-C8h] BYREF
__int64 v3; // [rsp+18h] [rbp-B0h]
unsigned int v4; // [rsp+20h] [rbp-A8h]
char v5[32]; // [rsp+40h] [rbp-88h] BYREF
__int64 v6; // [rsp+60h] [rbp-68h]
__int64 v7; // [rsp+68h] [rbp-60h]

v7 = a1[1];
v6 = *a1;
if ( (unsigned int)make_connection(2LL, v5, &v2) || !v3 )
return v4;
MEMORY[0x7FFF0028] = v3;
return 0xFFFFFFFFLL;
}

original_code:
int
psys_chdir (void *argp)
{
  int error;
  int retval;
  char path[255];
  struct a
    {
      const char *path;
    } *args = (struct a *)argp;
  if (args->path[0] != '/')
    {
      if (resolv_fullpath (args->path, path) == (0))
 {
   errno = 13;
   return (-1);
 }
      args->path = path;
    }
  retval = proc_chdir (args->path, &error);
  if (error)
    {
      errno = error;
    }
  return (retval);
}

canonical_original_code:
int psys_chdir(void *argp)
{
  int error;
  int retval;
  char path[255];
  struct a *args = (struct a *)argp;
  if (args->path[0] != '/')
    {
      if (resolv_fullpath (args->path, path) == (0))
 {
   errno = 13;
   return (-1);
 }
      args->path = path;
    }
  retval = proc_chdir (args->path, &error);
  if (error)
    {
      errno = error;
    }
  return (retval);
}

variable_types:
argp
void *

variable_types: error int

variable_types: retval int

variable_types:
path
char [255]

variable_types:
args
struct a { char *path; } *


decompiled_code:
__int64 psys_getcwd()
{
errno = 26;
return 0LL;
}

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

original_code:
char *
psys_getcwd (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
char *psys_getcwd(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

variable_types:
args
struct a {  } *

return_type: char *


decompiled_code:
__int64 fdc_sense()
{
__int64 v0; // rbx
int v1; // eax
unsigned __int8 v2; // dl

v0 = 0LL;
v1 = inb(0x3F4u);
while ( v1 != 208 )
{
LABEL_5:
v2 = inb(0x3F4u);
v1 = v2 & 0xD0;
if ( (v2 & 0xD0) == 0x80 )
return 1LL;
}
if ( (int)v0 <= 7 )
{
fd_status[v0 + 1] = inb(0x3F5u);
v0 = (int)v0 + 1;
goto LABEL_5;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbx
int v1; // eax
unsigned __int8 v2; // dl

v0 = 0LL;
v1 = inb(0x3F4u);
while ( v1 != 208 )
{
LABEL_5:
v2 = inb(0x3F4u);
v1 = v2 & 0xD0;
if ( (v2 & 0xD0) == 0x80 )
return 1LL;
}
if ( (int)v0 <= 7 )
{
fd_status[v0 + 1] = inb(0x3F5u);
v0 = (int)v0 + 1;
goto LABEL_5;
}
return 0LL;
}

original_code:
BOOL
fdc_sense ()
{
  int result_nr = 0;
  int status;
  status = inb (0x3f4);
  for (;;)
    {
      if (status == (0x80 | 0x40 | 0x10))
 {
   if (result_nr >= 8)
     {
       break;
     }
   fd_status.status_data[result_nr++] = inb (0x3f5);
 }
      status = inb (0x3f4) & (0x80 | 0x40 | 0x10);
      if (status == 0x80)
 {
   return (TRUE);
 }
    }
  return (FALSE);
}

canonical_original_code:
enum BOOL fdc_sense()
{
  int result_nr = 0;
  int status;
  status = inb (0x3f4);
  for (;;)
    {
      if (status == (0x80 | 0x40 | 0x10))
 {
   if (result_nr >= 8)
     {
       break;
     }
   fd_status.status_data[result_nr++] = inb (0x3f5);
 }
      status = inb (0x3f4) & (0x80 | 0x40 | 0x10);
      if (status == 0x80)
 {
   return (TRUE);
 }
    }
  return (FALSE);
}

variable_types: status int

return_type: enum BOOL { FALSE=0, TRUE=1 }


decompiled_code:
__int64 fd_ready_check()
{
int v0; // ebx
__int64 result; // rax

v0 = 10;
while ( 1 )
{
LODWORD(result) = inb(0x3F4u) & 0x10;
if ( !(_DWORD)result )
break;
if ( !--v0 )
return (unsigned __int8)result;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
int v0; // ebx
__int64 result; // rax

v0 = 10;
while ( 1 )
{
LODWORD(result) = inb(0x3F4u) & 0x10;
if ( !(_DWORD)result )
break;
if ( !--v0 )
return (unsigned __int8)result;
}
return 0LL;
}

original_code:
int
fd_ready_check (void)
{
  int i;
  int status;
  for (i = 0; i < 10; i++)
    {
      status = inb (0x3f4);
      status = status & 0x10;
      if (status == 0)
 return (0);
    }
  return (status);
}

canonical_original_code:
int fd_ready_check()
{
  int i;
  int status;
  for (i = 0; i < 10; i++)
    {
      status = inb (0x3f4);
      status = status & 0x10;
      if (status == 0)
 return (0);
    }
  return (status);
}

variable_types: i int


decompiled_code:
__int64 __fastcall fd_get_status(__int64 a1, int a2)
{
int v2; // er12
int i; // ebx
unsigned __int8 v4; // al
unsigned __int8 v5; // bp
unsigned __int8 v7; // r8
__int64 v8; // rax

v2 = 0;
for ( i = 0; ; i = 1 )
{
while ( 1 )
{
v4 = inb(0x3F4u);
v5 = v4 & 0xD0;
if ( (v4 & 0xC0) != 0 )
break;
if ( v5 == 0x80 )
return 128LL;
if ( ++i == 10 )
return 0xFFFFFFFFLL;
}
v7 = inb(0x3F5u);
v8 = v2++;
fd_status[v8 + 1] = v7;
if ( v2 >= a2 )
break;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
int v2; // er12
int i; // ebx
unsigned __int8 v4; // al
unsigned __int8 v5; // bp
unsigned __int8 v7; // r8
__int64 v8; // rax

v2 = 0;
for ( i = 0; ; i = 1 )
{
while ( 1 )
{
v4 = inb(0x3F4u);
v5 = v4 & 0xD0;
if ( (v4 & 0xC0) != 0 )
break;
if ( v5 == 0x80 )
return 128LL;
if ( ++i == 10 )
return 0xFFFFFFFFLL;
}
v7 = inb(0x3F5u);
v8 = v2++;
fd_status[v8 + 1] = v7;
if ( v2 >= a2 )
break;
}
return v5;
}

original_code:
int fd_get_status (BYTE drive, int datan)
{
  int status;
  int status_count = 0;
  int i;
  int tmp;
  for (i = 0; i < 10; i++)
    {
      status = inb (0x3f4);
      status &= (0x80 | 0x40 | 0x10);
      if ((status & (0x80 | 0x40)))
 {
   tmp = inb (0x3f5);
   fd_status.status_data[status_count] = tmp;
   status_count++;
   i = 0;
   if (status_count >= datan)
     return (status);
 }
      else if (status == 0x80)
 {
   return (status);
 }
    }
  return (-1);
}

canonical_original_code:
int fd_get_status(unsigned char drive, int datan)
{
  int status;
  int status_count = 0;
  int i;
  int tmp;
  for (i = 0; i < 10; i++)
    {
      status = inb (0x3f4);
      status &= (0x80 | 0x40 | 0x10);
      if ((status & (0x80 | 0x40)))
 {
   tmp = inb (0x3f5);
   fd_status.status_data[status_count] = tmp;
   status_count++;
   i = 0;
   if (status_count >= datan)
     return (status);
 }
      else if (status == 0x80)
 {
   return (status);
 }
    }
  return (-1);
}

variable_types:
drive
unsigned char

variable_types: datan int

variable_types: tmp int


decompiled_code:
__int64 __fastcall fd_recalibrate(unsigned __int8 a1)
{
fd_ready_check();
write_fdc(7u);
write_fdc(a1);
wait_int(&intr_flag);
fdc_isense();
return (unsigned __int8)fd_status[1];
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned __int8 a1)
{
func4();
func0(7u);
func0(a1);
wait_int(&intr_flag);
func2();
return (unsigned __int8)fd_status[1];
}

original_code:
int
fd_recalibrate (BYTE drive)
{
  fd_ready_check ();
  write_fdc (0x07);
  write_fdc (drive);
  wait_int (&intr_flag);
  fdc_isense ();
  return (fd_status.status_data[0]);
}

canonical_original_code:
int fd_recalibrate(unsigned char drive)
{
  fd_ready_check ();
  write_fdc (0x07);
  write_fdc (drive);
  wait_int (&intr_flag);
  fdc_isense ();
  return (fd_status.status_data[0]);
}


decompiled_code:
__int64 fd_specify()
{
fd_ready_check();
write_fdc(3u);
write_fdc(0xDFu);
write_fdc(2u);
outb(0xF7u, 0);
return 0LL;
}

canonical_decompiled_code:
__int64 func7()
{
func4();
func0(3u);
func0(0xDFu);
func0(2u);
outb(0xF7u, 0);
return 0LL;
}

original_code:
int
fd_specify (UWORD32 srt,
     UWORD32 hut,
     UWORD32 hlt,
     UWORD32 nd)
{
  fd_ready_check ();
  write_fdc (0x03);
  write_fdc (0xdf);
  write_fdc (0x02);
  outb(0x3f7, 0x00);
  return (0);
}

canonical_original_code:
int fd_specify(unsigned long srt, unsigned long hut, unsigned long hlt, unsigned long nd)
{
  fd_ready_check ();
  write_fdc (0x03);
  write_fdc (0xdf);
  write_fdc (0x02);
  outb(0x3f7, 0x00);
  return (0);
}

variable_types:
srt
unsigned long

variable_types:
hut
unsigned long

variable_types:
hlt
unsigned long

variable_types:
nd
unsigned long


decompiled_code:
__int64 stop_motor()
{
motor_goal = 0;
if ( motor_status )
{
outb(0xF2u, 0xCu);
motor_status = motor_goal;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func9()
{
motor_goal = 0;
if ( motor_status )
{
outb(0xF2u, 0xCu);
motor_status = motor_goal;
}
return 0LL;
}

original_code:
int
stop_motor (BYTE drive)
{
  motor_goal = 0;
  if (motor_goal != motor_status) {
 outb (0x3f2, (motor_goal << 4) | 0x0c);
 motor_status = motor_goal;
  }
  return (0);
}

canonical_original_code:
int stop_motor(unsigned char drive)
{
  motor_goal = 0;
  if (motor_goal != motor_status) {
 outb (0x3f2, (motor_goal << 4) | 0x0c);
 motor_status = motor_goal;
  }
  return (0);
}


decompiled_code:
_BOOL8 __fastcall fd_seek(char a1, char a2, int a3)
{
_BOOL8 result; // rax

on_motor(0);
fd_ready_check();
intr_flag = 0;
write_fdc(0xFu);
write_fdc((4 * a2) | a1 & 3);
write_fdc(a3);
wait_int(&intr_flag);
fdc_isense();
result = 0LL;
if ( (unsigned __int8)fd_status[2] == a3 )
result = (fd_status[1] & 0xF8) == 32;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func10(char a1, char a2, int a3)
{
_BOOL8 result; // rax

func8(0);
func4();
intr_flag = 0;
func0(0xFu);
func0((4 * a2) | a1 & 3);
func0(a3);
wait_int(&intr_flag);
func2();
result = 0LL;
if ( (unsigned __int8)fd_status[2] == a3 )
result = (fd_status[1] & 0xF8) == 32;
return result;
}

original_code:
int
fd_seek (BYTE drive, int head, int cylinder, int motor)
{
  int result;
  on_motor (0);
  fd_ready_check ();
  intr_flag = FALSE;
  write_fdc (0x0f);
  write_fdc ((head << 2) | (drive & 0x03));
  write_fdc (cylinder);
  wait_int (&intr_flag);
  fdc_isense ();
  result = TRUE;
  if ((fd_status.status_data[0] & 0xF8) != 0x20) result = FALSE;
  if (fd_status.status_data[1] != cylinder) result = FALSE;
  return (result);
}

canonical_original_code:
int fd_seek(unsigned char drive, int head, int cylinder, int motor)
{
  int result;
  on_motor (0);
  fd_ready_check ();
  intr_flag = FALSE;
  write_fdc (0x0f);
  write_fdc ((head << 2) | (drive & 0x03));
  write_fdc (cylinder);
  wait_int (&intr_flag);
  fdc_isense ();
  result = TRUE;
  if ((fd_status.status_data[0] & 0xF8) != 0x20) result = FALSE;
  if (fd_status.status_data[1] != cylinder) result = FALSE;
  return (result);
}

variable_types: head int

variable_types: cylinder int

variable_types: motor int

variable_types: result int


decompiled_code:
__int64 __fastcall fd_get_data(char a1, unsigned __int8 a2, unsigned __int8 a3, unsigned __int8 a4)
{
lock();
write_fdc(0xE6u);
write_fdc((4 * a2) | a1);
write_fdc(a3);
write_fdc(a2);
write_fdc(a4);
write_fdc(2u);
write_fdc(0x12u);
write_fdc(0x1Bu);
write_fdc(0xFFu);
unlock();
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(char a1, unsigned __int8 a2, unsigned __int8 a3, unsigned __int8 a4)
{
lock();
func0(0xE6u);
func0((4 * a2) | a1);
func0(a3);
func0(a2);
func0(a4);
func0(2u);
func0(0x12u);
func0(0x1Bu);
func0(0xFFu);
unlock();
return 1LL;
}

original_code:
int
fd_get_data (BYTE drive, int head, int cylinder, int sector, void *buff)
{
  lock();
  write_fdc (0xE6);
  write_fdc ((head << 2) | drive);
  write_fdc (cylinder);
  write_fdc (head);
  write_fdc (sector);
  write_fdc (2);
  write_fdc (18);
  write_fdc (0x1B);
  write_fdc (0xff);
  unlock ();
  return (TRUE);
}

canonical_original_code:
int fd_get_data(unsigned char drive, int head, int cylinder, int sector, void *buff)
{
  lock();
  write_fdc (0xE6);
  write_fdc ((head << 2) | drive);
  write_fdc (cylinder);
  write_fdc (head);
  write_fdc (sector);
  write_fdc (2);
  write_fdc (18);
  write_fdc (0x1B);
  write_fdc (0xff);
  unlock ();
  return (TRUE);
}

variable_types: sector int

variable_types:
buff
void *


decompiled_code:
__int64 __fastcall fd_read(char a1, int a2, __int64 a3)
{
int v4; // ebx
int v5; // er13
int v6; // ebp
int v7; // er12
_BOOL4 v8; // edx
__int64 result; // rax

on_motor(0);
intr_flag = 0;
v4 = 10;
v5 = 2 * a2 / 36;
v6 = 2 * a2 % 18 + 1;
v7 = 2 * a2 % 36 / 18;
while ( 1 )
{
if ( fd_seek(a1, v7, v5) )
{
setup_dma(a3, 68LL, 1024LL, 2LL);
fd_get_data(a1, v7, v5, v6);
wait_int(&intr_flag);
if ( (unsigned int)fdc_sense() == 1 && (fd_status[1] & 0xF8) == 0 )
{
v8 = fd_status[3] != 0;
result = v8 | (unsigned int)(unsigned __int8)fd_status[2];
if ( !(v8 | (unsigned __int8)fd_status[2])
&& (18 * ((unsigned __int8)fd_status[5] - v7)
+ 36 * ((unsigned __int8)fd_status[4] - v5)
+ (unsigned __int8)fd_status[6]
- v6) << 9 == 1024 )
{
break;
}
}
}
if ( !--v4 )
{
boot_printf("Read failed.\n");
stop_motor(0LL);
return 4294967254LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(char a1, int a2, __int64 a3)
{
int v4; // ebx
int v5; // er13
int v6; // ebp
int v7; // er12
_BOOL4 v8; // edx
__int64 result; // rax

func8(0);
intr_flag = 0;
v4 = 10;
v5 = 2 * a2 / 36;
v6 = 2 * a2 % 18 + 1;
v7 = 2 * a2 % 36 / 18;
while ( 1 )
{
if ( func10(a1, v7, v5) )
{
setup_dma(a3, 68LL, 1024LL, 2LL);
func11(a1, v7, v5, v6);
wait_int(&intr_flag);
if ( (unsigned int)func3() == 1 && (fd_status[1] & 0xF8) == 0 )
{
v8 = fd_status[3] != 0;
result = v8 | (unsigned int)(unsigned __int8)fd_status[2];
if ( !(v8 | (unsigned __int8)fd_status[2])
&& (18 * ((unsigned __int8)fd_status[5] - v7)
+ 36 * ((unsigned __int8)fd_status[4] - v5)
+ (unsigned __int8)fd_status[6]
- v6) << 9 == 1024 )
{
break;
}
}
}
if ( !--v4 )
{
boot_printf("Read failed.\n");
func9(0LL);
return 4294967254LL;
}
}
return result;
}

original_code:
int
fd_read (BYTE drive,
  int blockno,
  BYTE *buff)
{
  int cylinder;
  int head;
  int sector;
  int i;
  int ret;
  int readcount;
  int s;
  on_motor (0);
  blockno *= 2;
  for (readcount = 0; readcount < (1024 / 1024); readcount++, blockno++, buff += 1024)
    {
      head = (blockno % (2 * 18)) / 18;
      cylinder = (blockno / (2 * 18));
      sector = (blockno % 18) + 1;
      intr_flag = FALSE;
      for (i = 0; i < 10; i++)
 {
   ret = fd_seek (drive, head, cylinder, 0);
   if (ret != TRUE) continue;
   setup_dma ((void *)buff, 0x44, 1024, 0x02);
   fd_get_data (drive, head, cylinder, sector, buff);
   wait_int (&intr_flag);
   ret = fdc_sense ();
   if (ret != TRUE) continue;
   if ((fd_status.status_data[0] & 0xF8) != 0x00) continue;
   if (fd_status.status_data[1] | fd_status.status_data[2] != 0x00)
     continue;
   s = (fd_status.status_data[3] - cylinder) * 2 * 18;
   s += (fd_status.status_data[4] - head) * 18;
   s += (fd_status.status_data[5] - sector);
   if (s * 512 != 1024) continue;
   else
     {
       ret = (0);
       break;
     }
 }
      if (i >= 10)
 {
   boot_printf ("Read failed.\n");
   stop_motor (0);
   return ((-42));
 }
    }
  return ((0));
}

canonical_original_code:
int fd_read(unsigned char drive, int blockno, unsigned char *buff)
{
  int cylinder;
  int head;
  int sector;
  int i;
  int ret;
  int readcount;
  int s;
  on_motor (0);
  blockno *= 2;
  for (readcount = 0; readcount < (1024 / 1024); readcount++, blockno++, buff += 1024)
    {
      head = (blockno % (2 * 18)) / 18;
      cylinder = (blockno / (2 * 18));
      sector = (blockno % 18) + 1;
      intr_flag = FALSE;
      for (i = 0; i < 10; i++)
 {
   ret = fd_seek (drive, head, cylinder, 0);
   if (ret != TRUE) continue;
   setup_dma ((void *)buff, 0x44, 1024, 0x02);
   fd_get_data (drive, head, cylinder, sector, buff);
   wait_int (&intr_flag);
   ret = fdc_sense ();
   if (ret != TRUE) continue;
   if ((fd_status.status_data[0] & 0xF8) != 0x00) continue;
   if (fd_status.status_data[1] | fd_status.status_data[2] != 0x00)
     continue;
   s = (fd_status.status_data[3] - cylinder) * 2 * 18;
   s += (fd_status.status_data[4] - head) * 18;
   s += (fd_status.status_data[5] - sector);
   if (s * 512 != 1024) continue;
   else
     {
       ret = (0);
       break;
     }
 }
      if (i >= 10)
 {
   boot_printf ("Read failed.\n");
   stop_motor (0);
   return ((-42));
 }
    }
  return ((0));
}

variable_types: blockno int

variable_types:
buff
unsigned char *

variable_types: ret int

variable_types: readcount int

variable_types: s int


decompiled_code:
__int64 __fastcall fd_read_with_partition(char a1, __int64 a2, int a3, __int64 a4)
{
return fd_read(a1, a3, a4);
}

canonical_decompiled_code:
__int64 __fastcall func13(char a1, __int64 a2, int a3, __int64 a4)
{
return func12(a1, a3, a4);
}

original_code:
int
fd_read_with_partition (int drive, int part, int blockno, BYTE *buff, int length)
{
  int result;
  result = fd_read (drive, blockno, buff) ;
  return result;
}

canonical_original_code:
int fd_read_with_partition(int drive, int part, int blockno, unsigned char *buff, int length)
{
  int result;
  result = fd_read (drive, blockno, buff) ;
  return result;
}

variable_types: drive int

variable_types: part int

variable_types: length int


decompiled_code:
__int64 fd_reset()
{
on_motor(0);
fd_specify(12LL, 15LL, 8LL, 0LL);
stop_motor(0LL);
return 0LL;
}

canonical_decompiled_code:
__int64 func14()
{
func8(0);
func7(12LL, 15LL, 8LL, 0LL);
func9(0LL);
return 0LL;
}

original_code:
int
fd_reset (void)
{
  on_motor (0);
  fd_specify (fd_spec[0].srt,
       fd_spec[0].hut,
       fd_spec[0].hlt,
       fd_spec[0].nd);
  stop_motor (0);
  return (0);
}

canonical_original_code:
int fd_reset()
{
  on_motor (0);
  fd_specify (fd_spec[0].srt,
       fd_spec[0].hut,
       fd_spec[0].hlt,
       fd_spec[0].nd);
  stop_motor (0);
  return (0);
}


decompiled_code:
__int64 __fastcall write_fdc(unsigned __int8 a1)
{
int v1; // ebx
unsigned __int8 v2; // al

v1 = 1001;
if ( (inb(0x3F4u) & 0xC0) != 0x80 )
{
while ( 1 )
{
v2 = inb(0x3F4u);
if ( (v2 & 0xC0) == 0x80 )
break;
if ( !--v1 )
{
boot_printf("write_fdc: timeout!! status = 0x%x\n", v2);
break;
}
}
}
outb(0xF5u, a1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 a1)
{
int v1; // ebx
unsigned __int8 v2; // al

v1 = 1001;
if ( (inb(0x3F4u) & 0xC0) != 0x80 )
{
while ( 1 )
{
v2 = inb(0x3F4u);
if ( (v2 & 0xC0) == 0x80 )
break;
if ( !--v1 )
{
boot_printf("write_fdc: timeout!! status = 0x%x\n", v2);
break;
}
}
}
outb(0xF5u, a1);
return 1LL;
}

original_code:
int
write_fdc (BYTE value)
{
  int i;
  UWORD32 status;
  i = 1000;
  status = inb (0x3f4);
  while ((status & (0x80 | 0x40)) != (0x80 | 0))
    {
      if (i < 0)
 {
   boot_printf ("write_fdc: timeout!! status = 0x%x\n", status);
   break;
 }
      i--;
      status = inb (0x3f4);
    }
  outb(0x3f5, value);
  return (1);
}

canonical_original_code:
int write_fdc(unsigned char value)
{
  int i;
  unsigned long status;
  i = 1000;
  status = inb (0x3f4);
  while ((status & (0x80 | 0x40)) != (0x80 | 0))
    {
      if (i < 0)
 {
   boot_printf ("write_fdc: timeout!! status = 0x%x\n", status);
   break;
 }
      i--;
      status = inb (0x3f4);
    }
  outb(0x3f5, value);
  return (1);
}

variable_types:
value
unsigned char

variable_types: i int

variable_types:
status
unsigned long


decompiled_code:
__int64 intr_fd()
{
lock();
intr_flag = 1;
return unlock();
}

canonical_decompiled_code:
__int64 func1()
{
lock();
intr_flag = 1;
return unlock();
}

original_code:
void
intr_fd (void)
{
  lock ();
  intr_flag = 1;
  unlock ();
}

canonical_original_code:
void intr_fd()
{
  lock ();
  intr_flag = 1;
  unlock ();
}


decompiled_code:
__int64 fdc_isense()
{
__int64 v0; // rbx
int v1; // eax
unsigned __int8 v2; // dl

v0 = 0LL;
write_fdc(8u);
v1 = inb(0x3F4u);
while ( v1 != 208 )
{
LABEL_5:
v2 = inb(0x3F4u);
v1 = v2 & 0xD0;
if ( (v2 & 0xD0) == 0x80 )
return 1LL;
}
if ( (int)v0 <= 7 )
{
fd_status[v0 + 1] = inb(0x3F5u);
v0 = (int)v0 + 1;
goto LABEL_5;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rbx
int v1; // eax
unsigned __int8 v2; // dl

v0 = 0LL;
func0(8u);
v1 = inb(0x3F4u);
while ( v1 != 208 )
{
LABEL_5:
v2 = inb(0x3F4u);
v1 = v2 & 0xD0;
if ( (v2 & 0xD0) == 0x80 )
return 1LL;
}
if ( (int)v0 <= 7 )
{
fd_status[v0 + 1] = inb(0x3F5u);
v0 = (int)v0 + 1;
goto LABEL_5;
}
return 0LL;
}

original_code:
BOOL
fdc_isense ()
{
  int result_nr = 0;
  int status;
  write_fdc (0x08);
  status = inb (0x3f4);
  for (;;)
    {
      if (status == (0x80 | 0x40 | 0x10))
 {
   if (result_nr >= 8)
     {
       break;
     }
   fd_status.status_data[result_nr++] = inb (0x3f5);
 }
      status = inb (0x3f4) & (0x80 | 0x40 | 0x10);
      if (status == 0x80)
 {
   return (TRUE);
 }
    }
  return (FALSE);
}

canonical_original_code:
enum BOOL fdc_isense()
{
  int result_nr = 0;
  int status;
  write_fdc (0x08);
  status = inb (0x3f4);
  for (;;)
    {
      if (status == (0x80 | 0x40 | 0x10))
 {
   if (result_nr >= 8)
     {
       break;
     }
   fd_status.status_data[result_nr++] = inb (0x3f5);
 }
      status = inb (0x3f4) & (0x80 | 0x40 | 0x10);
      if (status == 0x80)
 {
   return (TRUE);
 }
    }
  return (FALSE);
}

variable_types: status int


decompiled_code:
__int64 __fastcall on_motor(char a1)
{
int v1; // ebx

v1 = (1 << a1) & motor_status;
motor_goal = motor_status | (1 << a1);
outb(0xF2u, (unsigned __int8)((16 * (motor_status | (1 << a1))) | a1) | 0xC);
motor_status = motor_goal;
if ( !v1 )
busywait(1000LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(char a1)
{
int v1; // ebx

v1 = (1 << a1) & motor_status;
motor_goal = motor_status | (1 << a1);
outb(0xF2u, (unsigned __int8)((16 * (motor_status | (1 << a1))) | a1) | 0xC);
motor_status = motor_goal;
if ( !v1 )
busywait(1000LL);
return 0LL;
}

original_code:
int
on_motor (BYTE drive)
{
  int motor_bit, running;
  motor_bit = 1 << drive;
  running = motor_status & motor_bit;
  motor_goal = motor_status | motor_bit;
  outb (0x3f2, (motor_goal << 4) | 0x0c | drive);
  motor_status = motor_goal;
  if (!running)
    {
      busywait (1000);
    }
  return (0);
}

canonical_original_code:
int on_motor(unsigned char drive)
{
  int motor_bit; int running;
  motor_bit = 1 << drive;
  running = motor_status & motor_bit;
  motor_goal = motor_status | motor_bit;
  outb (0x3f2, (motor_goal << 4) | 0x0c | drive);
  motor_status = motor_goal;
  if (!running)
    {
      busywait (1000);
    }
  return (0);
}

variable_types:
drive
unsigned char

variable_types: running int


decompiled_code:
__int64 init_fd()
{
set_idt(38LL, 8LL, (unsigned int)&int38_handler, 14LL, 0LL);
reset_intr_mask(6LL);
fd_reset();
return 0LL;
}

canonical_decompiled_code:
__int64 func15()
{
set_idt(38LL, 8LL, (unsigned int)&int38_handler, 14LL, 0LL);
reset_intr_mask(6LL);
func14();
return 0LL;
}

original_code:
int
init_fd (void)
{
  set_idt (38, 0x08, (int)int38_handler, 0xe, 0);
  reset_intr_mask (6);
  fd_reset ();
  return (0);
}

canonical_original_code:
int init_fd()
{
  set_idt (38, 0x08, (int)int38_handler, 0xe, 0);
  reset_intr_mask (6);
  fd_reset ();
  return (0);
}


decompiled_code:
unsigned __int8 __fastcall i8250_inb(__int64 a1, __int16 a2, unsigned __int8 *a3)
{
unsigned __int8 result; // al

result = inb(LOWORD(i8250_base_address[a1]) + a2);
*a3 = result;
return result;
}

canonical_decompiled_code:
unsigned __int8 __fastcall func0(__int64 a1, __int16 a2, unsigned __int8 *a3)
{
unsigned __int8 result; // al

result = inb(LOWORD(i8250_base_address[a1]) + a2);
*a3 = result;
return result;
}

original_code:
static void
i8250_inb (W port, W offset, UB *value)
{
  *value = inb (i8250_base_address[port] + offset);
}

canonical_original_code:
static void i8250_inb(long port, long offset, unsigned char *value)
{
  *value = inb (i8250_base_address[port] + offset);
}

variable_types: port long

variable_types: offset long

variable_types:
value
unsigned char *


decompiled_code:
void __fastcall i8250_outb(__int64 a1, char a2, unsigned __int8 a3)
{
outb(LOBYTE(i8250_base_address[a1]) + a2, a3);
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, char a2, unsigned __int8 a3)
{
outb(LOBYTE(i8250_base_address[a1]) + a2, a3);
}

original_code:
static void
i8250_outb (W port, W offset, UB value)
{
  outb (i8250_base_address[port] + offset, value);
}

canonical_original_code:
static void i8250_outb(long port, long offset, unsigned char value)
{
  outb (i8250_base_address[port] + offset, value);
}


original_code:
ER
i8250_set_dlab (W port, W flag)
{
  UB old_value;
  i8250_inb (port, 3, &old_value);
  if (flag == 1)
    {
      old_value |= 0x80;
    }
  else
    {
      old_value &= 0x7f;
    }
  i8250_outb (port, 3, old_value);
  return ((0));
}

canonical_original_code:
int i8250_set_dlab(long port, long flag)
{
  unsigned char old_value;
  i8250_inb (port, 3, &old_value);
  if (flag == 1)
    {
      old_value |= 0x80;
    }
  else
    {
      old_value &= 0x7f;
    }
  i8250_outb (port, 3, old_value);
  return ((0));
}

variable_types: flag long


decompiled_code:
__int64 __fastcall i8250_set_frequency_register(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

i8250_set_dlab(a1, 1LL);
v2 = baud_table_0[a2];
i8250_outb(a1, 0, v2);
i8250_outb(a1, 1, BYTE1(v2));
i8250_set_dlab(a1, 0LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

func2(a1, 1LL);
v2 = baud_table_0[a2];
func1(a1, 0, v2);
func1(a1, 1, BYTE1(v2));
func2(a1, 0LL);
return 0LL;
}

canonical_original_code:
int i8250_set_frequency_register(long port, long baud)
{
  unsigned char line_status;
  static long baud_table[] = {
    0x0900,
    0x0600,
    0x0300,
    0x0180,
    0x0150,
    0x00c0,
    0x0030,
    0x0018,
    0x000c,
    0x0006,
    0x0003,
    0x0002,
    0x0001,
  };
  i8250_set_dlab (port, 1);
  i8250_outb (port, 0, baud_table[baud] & 0xff);
  i8250_outb (port, 0 + 1, (baud_table[baud] >> 8) & 0xff);
  i8250_set_dlab (port, 0);
  return ((0));
}

variable_types: baud long


decompiled_code:
__int64 __fastcall i8250_set_interrupt_register(__int64 a1)
{
i8250_outb(a1, 1, 0xFu);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
func1(a1, 1, 0xFu);
return 0LL;
}

original_code:
ER
i8250_set_interrupt_register (W port, W flag)
{
  i8250_outb (port, 1, 0x0f);
  return ((0));
}

canonical_original_code:
int i8250_set_interrupt_register(long port, long flag)
{
  i8250_outb (port, 1, 0x0f);
  return ((0));
}


decompiled_code:
__int64 __fastcall i8250_get_interrupt_status(__int64 a1, unsigned __int8 *a2)
{
i8250_inb(a1, 2, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned __int8 *a2)
{
func0(a1, 2, a2);
return 0LL;
}

original_code:
ER
i8250_get_interrupt_status (W port, UB *status)
{
  i8250_inb (port, 2, status);
  return ((0));
}

canonical_original_code:
int i8250_get_interrupt_status(long port, unsigned char *status)
{
  i8250_inb (port, 2, status);
  return ((0));
}

variable_types:
status
unsigned char *


original_code:
ER
i8250_set_fifo (W port, W byte)
{
  return ((-17));
}

canonical_original_code:
int i8250_set_fifo(long port, long byte)
{
  return ((-17));
}

variable_types: byte long


decompiled_code:
__int64 __fastcall i8250_set_line_control(__int64 a1, unsigned __int8 a2)
{
i8250_outb(a1, 3, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned __int8 a2)
{
func1(a1, 3, a2);
return 0LL;
}

original_code:
ER
i8250_set_line_control (W port, W value)
{
  i8250_outb (port, 3, value);
  return ((0));
}

canonical_original_code:
int i8250_set_line_control(long port, long value)
{
  i8250_outb (port, 3, value);
  return ((0));
}

variable_types: value long


decompiled_code:
__int64 __fastcall i8250_set_modem_control(__int64 a1, unsigned __int8 a2)
{
i8250_outb(a1, 4, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, unsigned __int8 a2)
{
func1(a1, 4, a2);
return 0LL;
}

original_code:
ER
i8250_set_modem_control (W port, W value)
{
  i8250_outb (port, 4, value);
  return ((0));
}

canonical_original_code:
int i8250_set_modem_control(long port, long value)
{
  i8250_outb (port, 4, value);
  return ((0));
}


decompiled_code:
__int64 __fastcall i8250_get_line_status(__int64 a1, unsigned __int8 *a2)
{
i8250_inb(a1, 5, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, unsigned __int8 *a2)
{
func0(a1, 5, a2);
return 0LL;
}

original_code:
ER
i8250_get_line_status (W port, UB *value)
{
  i8250_inb (port, 5, value);
  return ((0));
}

canonical_original_code:
int i8250_get_line_status(long port, unsigned char *value)
{
  i8250_inb (port, 5, value);
  return ((0));
}


decompiled_code:
__int64 __fastcall i8250_get_modem_status(__int64 a1, unsigned __int8 *a2)
{
i8250_inb(a1, 6, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, unsigned __int8 *a2)
{
func0(a1, 6, a2);
return 0LL;
}

original_code:
ER
i8250_get_modem_status (W port, UB *value)
{
  i8250_inb (port, 6, value);
  return ((0));
}

canonical_original_code:
int i8250_get_modem_status(long port, unsigned char *value)
{
  i8250_inb (port, 6, value);
  return ((0));
}


gsave

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

qword_AA8 = 0LL;
result = 0LL;
path = 0LL;
qword_AB8 = 0LL;
qword_AB0 = 0LL;
qword_AC0 = 0LL;
qword_AC8 = 0LL;
return result;
}

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

qword_AA8 = 0LL;
result = 0LL;
path = 0LL;
qword_AB8 = 0LL;
qword_AB0 = 0LL;
qword_AC0 = 0LL;
qword_AC8 = 0LL;
return result;
}

original_code:
ER
gsave (void)
{
  path.orgX = path.orgY = 0;
  path.x = path.y = 0;
  path.color = 0;
  path.mode = 0;
  return (0);
}

canonical_original_code:
int gsave()
{
  path.orgX = path.orgY = 0;
  path.x = path.y = 0;
  path.color = 0;
  path.mode = 0;
  return (0);
}


translate

decompiled_code:
__int64 translate()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v3, v1);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v1);
if ( !(_DWORD)result )
{
path = v2;
qword_AA8 = v3;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v3, v1);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v1);
if ( !(_DWORD)result )
{
path = v2;
qword_AA8 = v3;
}
}
}
}
return result;
}

original_code:
ER
translate(void)
{
  ER result;
  Cell *c;
  long x;
  long y;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&y, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&x, c);
  if ((result) != (0)) { return (result); };
  path.orgX = x;
  path.orgY = y;
  return (0);
}

canonical_original_code:
int translate()
{
  int result;
  struct _cell *c;
  long x;
  long y;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&y, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&x, c);
  if ((result) != (0)) { return (result); };
  path.orgX = x;
  path.orgY = y;
  return (0);
}

variable_types: result int

variable_types: struct _cell { char mark; unsigned long type; struct _cell *prev; struct _cell *next; union { long inum; double dnum; struct { char str[48]; long length; } string; struct { struct _cell *link; char str[48]; } name; int (*mitn_func)(); struct { long arg_num; int (*func)(int argc, char *argv[]); } trad; struct _cell *link; } value; } *

variable_types: x long

variable_types: y long


moveto

decompiled_code:
__int64 moveto()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v3, v1);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v1);
if ( !(_DWORD)result )
{
qword_AB0 = v2;
qword_AB8 = v3;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v3, v1);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v1);
if ( !(_DWORD)result )
{
qword_AB0 = v2;
qword_AB8 = v3;
}
}
}
}
return result;
}

original_code:
ER
moveto(void)
{
  ER result;
  Cell *c;
  long x;
  long y;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&y, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&x, c);
  if ((result) != (0)) { return (result); };
  path.x = x;
  path.y = y;
  return (0);
}

canonical_original_code:
int moveto()
{
  int result;
  struct _cell *c;
  long x;
  long y;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&y, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&x, c);
  if ((result) != (0)) { return (result); };
  path.x = x;
  path.y = y;
  return (0);
}

user_defined_types: struct _cell { char mark; unsigned long type; struct _cell *prev; struct _cell *next; union { long inum; double dnum; struct { char str[48]; long length; } string; struct { struct _cell *link; char str[48]; } name; int (*mitn_func)(); struct { long arg_num; int (*func)(int argc, char *argv[]); } trad; struct _cell *link; } value; }


rmoveto

decompiled_code:
__int64 rmoveto()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v3, v1);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v1);
if ( !(_DWORD)result )
{
qword_AB0 += v2;
qword_AB8 += v3;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v3, v1);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v1);
if ( !(_DWORD)result )
{
qword_AB0 += v2;
qword_AB8 += v3;
}
}
}
}
return result;
}

original_code:
ER
rmoveto(void)
{
  ER result;
  Cell *c;
  long x;
  long y;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&y, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&x, c);
  if ((result) != (0)) { return (result); };
  path.x += x;
  path.y += y;
  return (0);
}

canonical_original_code:
int rmoveto()
{
  int result;
  struct _cell *c;
  long x;
  long y;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&y, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&x, c);
  if ((result) != (0)) { return (result); };
  path.x += x;
  path.y += y;
  return (0);
}


setcolor

decompiled_code:
__int64 setcolor()
{
__int64 result; // rax
__int64 v1; // [rsp+0h] [rbp-18h] BYREF
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v1);
if ( !(_DWORD)result )
qword_AC0 = v2;
}
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax
__int64 v1; // [rsp+0h] [rbp-18h] BYREF
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v1);
if ( !(_DWORD)result )
qword_AC0 = v2;
}
return result;
}

original_code:
ER
setcolor(void)
{
  ER result;
  Cell *c;
  long color;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&color, c);
  if ((result) != (0)) { return (result); };
  path.color = color;
  return (0);
}

canonical_original_code:
int setcolor()
{
  int result;
  struct _cell *c;
  long color;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&color, c);
  if ((result) != (0)) { return (result); };
  path.color = color;
  return (0);
}

variable_types: color long


setmode

decompiled_code:
__int64 setmode()
{
__int64 result; // rax
__int64 v1; // [rsp+0h] [rbp-18h] BYREF
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v1);
if ( !(_DWORD)result )
qword_AC8 = v2;
}
return result;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 result; // rax
__int64 v1; // [rsp+0h] [rbp-18h] BYREF
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v1);
if ( !(_DWORD)result )
qword_AC8 = v2;
}
return result;
}

original_code:
ER
setmode(void)
{
  ER result;
  Cell *c;
  long mode;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&mode, c);
  if ((result) != (0)) { return (result); };
  path.mode = mode;
  return (0);
}

canonical_original_code:
int setmode()
{
  int result;
  struct _cell *c;
  long mode;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&mode, c);
  if ((result) != (0)) { return (result); };
  path.mode = mode;
  return (0);
}

variable_types: mode long


box

decompiled_code:
__int64 box()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3[2]; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v3[0]);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v1, v3[0]);
if ( !(_DWORD)result )
result = box_vga(qword_AB0 + path, qword_AB8 + qword_AA8, v1, v2, qword_AC0);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3[2]; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v3[0]);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v1, v3[0]);
if ( !(_DWORD)result )
result = box_vga(qword_AB0 + path, qword_AB8 + qword_AA8, v1, v2, qword_AC0);
}
}
}
return result;
}

original_code:
ER
box(void)
{
  long width;
  long height;
  Cell *c;
  ER result;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&height, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&width, c);
  if ((result) != (0)) { return (result); };
  result = box_vga (path.x + path.orgX,
      path.y + path.orgY,
      width,
      height,
      path.color);
  if ((result) != (0)) { return (result); };
  return (0);
}

canonical_original_code:
int box()
{
  long width;
  long height;
  struct _cell *c;
  int result;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&height, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&width, c);
  if ((result) != (0)) { return (result); };
  result = box_vga (path.x + path.orgX,
      path.y + path.orgY,
      width,
      height,
      path.color);
  if ((result) != (0)) { return (result); };
  return (0);
}

variable_types: width long

variable_types: height long


fillbox

decompiled_code:
__int64 fillbox()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3[2]; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v3[0]);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v1, v3[0]);
if ( !(_DWORD)result )
result = fillbox_vga(qword_AB0 + path, qword_AB8 + qword_AA8, v1, v2, qword_AC0);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3[2]; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v3[0]);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v1, v3[0]);
if ( !(_DWORD)result )
result = fillbox_vga(qword_AB0 + path, qword_AB8 + qword_AA8, v1, v2, qword_AC0);
}
}
}
return result;
}

original_code:
ER
fillbox(void)
{
  long width;
  long height;
  Cell *c;
  ER result;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&height, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&width, c);
  if ((result) != (0)) { return (result); };
  result = fillbox_vga (path.x + path.orgX,
   path.y + path.orgY,
   width,
   height,
   path.color);
  if ((result) != (0)) { return (result); };
  return (0);
}

canonical_original_code:
int fillbox()
{
  long width;
  long height;
  struct _cell *c;
  int result;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&height, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&width, c);
  if ((result) != (0)) { return (result); };
  result = fillbox_vga (path.x + path.orgX,
   path.y + path.orgY,
   width,
   height,
   path.color);
  if ((result) != (0)) { return (result); };
  return (0);
}


lineto

decompiled_code:
__int64 lineto()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3[2]; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v3[0]);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v1, v3[0]);
if ( !(_DWORD)result )
{
result = line_vga(qword_AB0 + path, qword_AB8 + qword_AA8, path + v1, qword_AA8 + v2, qword_AC0, qword_AC8);
if ( !(_DWORD)result )
{
qword_AB0 = v1;
qword_AB8 = v2;
}
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3[2]; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v3[0]);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v1, v3[0]);
if ( !(_DWORD)result )
{
result = line_vga(qword_AB0 + path, qword_AB8 + qword_AA8, path + v1, qword_AA8 + v2, qword_AC0, qword_AC8);
if ( !(_DWORD)result )
{
qword_AB0 = v1;
qword_AB8 = v2;
}
}
}
}
}
return result;
}

original_code:
ER
lineto(void)
{
  long x;
  long y;
  Cell *c;
  ER result;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&y, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&x, c);
  if ((result) != (0)) { return (result); };
  result = line_vga (path.x + path.orgX,
       path.y + path.orgY,
       x + path.orgX,
       y + path.orgY,
       path.color,
       path.mode);
  if ((result) != (0)) { return (result); };
  path.x = x;
  path.y = y;
  return (0);
}

canonical_original_code:
int lineto()
{
  long x;
  long y;
  struct _cell *c;
  int result;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&y, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&x, c);
  if ((result) != (0)) { return (result); };
  result = line_vga (path.x + path.orgX,
       path.y + path.orgY,
       x + path.orgX,
       y + path.orgY,
       path.color,
       path.mode);
  if ((result) != (0)) { return (result); };
  path.x = x;
  path.y = y;
  return (0);
}


rlineto

decompiled_code:
__int64 rlineto()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3[2]; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v3[0]);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v1, v3[0]);
if ( !(_DWORD)result )
{
result = line_vga(
qword_AB0 + path,
qword_AB8 + qword_AA8,
qword_AB0 + path + v1,
qword_AB8 + qword_AA8 + v2,
qword_AC0,
qword_AC8);
qword_AB0 += v1;
qword_AB8 += v2;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func10()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-20h] BYREF
__int64 v2; // [rsp+10h] [rbp-18h] BYREF
__int64 v3[2]; // [rsp+18h] [rbp-10h] BYREF

result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v2, v3[0]);
if ( !(_DWORD)result )
{
result = MitnStack_Pop(1LL, v3);
if ( !(_DWORD)result )
{
result = MitnCell_GetLongFromCell(&v1, v3[0]);
if ( !(_DWORD)result )
{
result = line_vga(
qword_AB0 + path,
qword_AB8 + qword_AA8,
qword_AB0 + path + v1,
qword_AB8 + qword_AA8 + v2,
qword_AC0,
qword_AC8);
qword_AB0 += v1;
qword_AB8 += v2;
}
}
}
}
return result;
}

original_code:
ER
rlineto(void)
{
  long x;
  long y;
  Cell *c;
  ER result;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&y, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&x, c);
  if ((result) != (0)) { return (result); };
  result = line_vga (path.x + path.orgX,
       path.y + path.orgY,
       path.x + path.orgX + x,
       path.y + path.orgY + y,
       path.color,
       path.mode);
  path.x += x;
  path.y += y;
  if ((result) != (0)) { return (result); };
  return (0);
}

canonical_original_code:
int rlineto()
{
  long x;
  long y;
  struct _cell *c;
  int result;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&y, c);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetLongFromCell(&x, c);
  if ((result) != (0)) { return (result); };
  result = line_vga (path.x + path.orgX,
       path.y + path.orgY,
       path.x + path.orgX + x,
       path.y + path.orgY + y,
       path.color,
       path.mode);
  path.x += x;
  path.y += y;
  if ((result) != (0)) { return (result); };
  return (0);
}


canonical_original_code:
void disp_smask(long x)
{
long mask; long k; long i; long t;
  for(mask=0,k = 7 - (x % 8U); k >= 0; --k)
    {
      mask |= (1 << (k));
    }
  printf("smask = ");
  for(i=7;i>=0;i--){
    t = (1 << (i));
    if((mask&t)==t){
      printf("1");
    }else{
      printf("0");
    }
  }
  printf("B\n");
}

variable_types: mask long

variable_types: k long

variable_types: i long

variable_types: t long


canonical_original_code:
void disp_emask(long x)
{
long mask; long k; long i; long t;
  for(mask=0,k = (x % 8U); k > 0; --k)
    {
      mask |= (1 << (8-k));
    }
  printf("emask = ");
  for(i=7;i>=0;i--){
    t = (1 << (i));
    if((mask&t)==t){
      printf("1");
    }else{
      printf("0");
    }
  }
  printf("B\n");
}


scroll

decompiled_code:
__int64 scroll()
{
char v0; // al
__int64 v1; // rbp
int v2; // ebx
char v3; // al
char v4; // al
char v5; // al
char v6; // al

graphic_mode();
printf("scroll test v.0.01\n");
printf(" end -> push Q key\n");
printf(" push any key to continue\n");
v0 = getc(&_file_table__);
if ( (unsigned __int8)tolower(v0) != 113 )
{
v1 = 30LL;
line_vga(0LL, 0LL, 639LL, 479LL, 8LL, 0LL);
v2 = 0;
while ( 1 )
{
test_mesh_constprop_0();
if ( v2 <= 276 )
{
disp_smask(v1 - 17);
disp_emask(v1 + 273);
box_vga((unsigned int)(v2 + 12), (unsigned int)(v2 + 12), 291LL, 191LL, 5LL);
scroll_vga(0LL, (unsigned int)(v2 + 13), (unsigned int)(v2 + 13), 290LL, 190LL, 37LL, 3LL);
}
v3 = getc(&_file_table__);
if ( (unsigned __int8)tolower(v3) == 113 )
break;
fillbox_vga(0LL, 0LL, 640LL, 480LL, 0LL);
v4 = getc(&_file_table__);
if ( (unsigned __int8)tolower(v4) == 113 )
break;
test_mesh_constprop_0();
if ( v2 <= 372 )
{
disp_smask(v1);
disp_emask(v1 + 177);
box_vga((unsigned int)(v2 + 29), (unsigned int)(v2 + 62), 178LL, 118LL, 5LL);
scroll_vga(1LL, (unsigned int)v1, (unsigned int)(v2 + 63), 177LL, 117LL, 47LL, 4LL);
}
v5 = getc(&_file_table__);
if ( (unsigned __int8)tolower(v5) == 113 )
break;
fillbox_vga(0LL, 0LL, 640LL, 480LL, 0LL);
v6 = getc(&_file_table__);
if ( (unsigned __int8)tolower(v6) == 113 )
break;
v2 += 5;
v1 += 5LL;
if ( v2 == 640 )
return line_vga(639LL, 0LL, 0LL, 479LL, 8LL, 0LL);
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 func14()
{
char v0; // al
__int64 v1; // rbp
int v2; // ebx
char v3; // al
char v4; // al
char v5; // al
char v6; // al

graphic_mode();
printf("scroll test v.0.01\n");
printf(" end -> push Q key\n");
printf(" push any key to continue\n");
v0 = getc(&_file_table__);
if ( (unsigned __int8)tolower(v0) != 113 )
{
v1 = 30LL;
line_vga(0LL, 0LL, 639LL, 479LL, 8LL, 0LL);
v2 = 0;
while ( 1 )
{
func0();
if ( v2 <= 276 )
{
func12(v1 - 17);
func13(v1 + 273);
box_vga((unsigned int)(v2 + 12), (unsigned int)(v2 + 12), 291LL, 191LL, 5LL);
scroll_vga(0LL, (unsigned int)(v2 + 13), (unsigned int)(v2 + 13), 290LL, 190LL, 37LL, 3LL);
}
v3 = getc(&_file_table__);
if ( (unsigned __int8)tolower(v3) == 113 )
break;
fillbox_vga(0LL, 0LL, 640LL, 480LL, 0LL);
v4 = getc(&_file_table__);
if ( (unsigned __int8)tolower(v4) == 113 )
break;
func0();
if ( v2 <= 372 )
{
func12(v1);
func13(v1 + 177);
box_vga((unsigned int)(v2 + 29), (unsigned int)(v2 + 62), 178LL, 118LL, 5LL);
scroll_vga(1LL, (unsigned int)v1, (unsigned int)(v2 + 63), 177LL, 117LL, 47LL, 4LL);
}
v5 = getc(&_file_table__);
if ( (unsigned __int8)tolower(v5) == 113 )
break;
fillbox_vga(0LL, 0LL, 640LL, 480LL, 0LL);
v6 = getc(&_file_table__);
if ( (unsigned __int8)tolower(v6) == 113 )
break;
v2 += 5;
v1 += 5LL;
if ( v2 == 640 )
return line_vga(639LL, 0LL, 0LL, 479LL, 8LL, 0LL);
}
}
return 0LL;
}

variable_types: x int

variable_types: y int

variable_types: c char