count

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

result = MitnStack_Count(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetCellAsLong(&v2, v1);
if ( !(_DWORD)result )
result = MitnStack_Push(1LL, v2);
}
return result;
}

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

result = MitnStack_Count(1LL, &v1);
if ( !(_DWORD)result )
{
result = MitnCell_GetCellAsLong(&v2, v1);
if ( !(_DWORD)result )
result = MitnStack_Push(1LL, v2);
}
return result;
}

original_code:
ER count (void)
{
  Cell *c;
  ER result;
  W count;
  result = MitnStack_Count(1, &count);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetCellAsLong(&c, count);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Push(1, c);
  if ((result) != (0)) { return (result); };
  return (0);
}

canonical_original_code:
int count()
{
  struct _cell *c;
  int result;
  long count;
  result = MitnStack_Count(1, &count);
  if ((result) != (0)) { return (result); };
  result = MitnCell_GetCellAsLong(&c, count);
  if ((result) != (0)) { return (result); };
  result = MitnStack_Push(1, c);
  if ((result) != (0)) { return (result); };
  return (0);
}


PopAndPrint

repo: monaka/B-Free

decompiled_code:
__int64 PopAndPrint()
{
unsigned int v0; // ebx
char v2[264]; // [rsp+0h] [rbp-118h] BYREF
__int64 v3; // [rsp+108h] [rbp-10h] BYREF

v0 = MitnStack_Pop(1LL, &v3);
if ( !v0 )
{
v0 = MitnCell_ToString(v2, v3, 255LL);
if ( !v0 )
printf("%s", v2);
}
return v0;
}

canonical_decompiled_code:
__int64 func12()
{
unsigned int v0; // ebx
char v2[264]; // [rsp+0h] [rbp-118h] BYREF
__int64 v3; // [rsp+108h] [rbp-10h] BYREF

v0 = MitnStack_Pop(1LL, &v3);
if ( !v0 )
{
v0 = MitnCell_ToString(v2, v3, 255LL);
if ( !v0 )
printf("%s", v2);
}
return v0;
}

original_code:
ER PopAndPrint (void)
{
  Cell *c;
  char str[255];
  ER result;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_ToString(str, c, 255);
  if ((result) != (0)) { return (result); };
  printf("%s", str);
  return (0);
}

canonical_original_code:
int PopAndPrint()
{
  struct _cell *c;
  char str[255];
  int result;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  result = MitnCell_ToString(str, c, 255);
  if ((result) != (0)) { return (result); };
  printf("%s", str);
  return (0);
}

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:
str
char [255]

variable_types: result int

return_type: int


dup

decompiled_code:
__int64 dup()
{
return MitnStack_Duplicate(1LL, 1LL);
}

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

original_code:
ER dup (void)
{
  Cell *c;
  ER result;
  result = MitnStack_Duplicate (1, 1);
  if ((result) != (0)) { return (result); };
  return (0);
}

canonical_original_code:
int dup()
{
  struct _cell *c;
  int result;
  result = MitnStack_Duplicate (1, 1);
  if ((result) != (0)) { return (result); };
  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; }


pop

decompiled_code:
__int64 pop()
{
char v1[16]; // [rsp+8h] [rbp-10h] BYREF

return MitnStack_Pop(1LL, v1);
}

canonical_decompiled_code:
__int64 func10()
{
char v1[16]; // [rsp+8h] [rbp-10h] BYREF

return MitnStack_Pop(1LL, v1);
}

original_code:
ER pop (void)
{
  Cell *c;
  ER result;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  return (0);
}

canonical_original_code:
int pop()
{
  struct _cell *c;
  int result;
  result = MitnStack_Pop(1, &c);
  if ((result) != (0)) { return (result); };
  return (0);
}


decompiled_code:
__int64 MitnCell_GetCell()
{
return MitnStack_GetLinkCellFromPool();
}

canonical_decompiled_code:
__int64 func1()
{
return MitnStack_GetLinkCellFromPool();
}

original_code:
static ER
MitnCell_GetCell(Cell **c)
{
  ER result;
  result = MitnStack_GetLinkCellFromPool(c);
  if ((result) != (0)) { return (result); };
  return (0);
}

canonical_original_code:
static int MitnCell_GetCell(struct _cell **c)
{
  int result;
  result = MitnStack_GetLinkCellFromPool(c);
  if ((result) != (0)) { return (result); };
  return (0);
}

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


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

result = MitnCell_GetCell();
if ( !(_DWORD)result )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 268828672LL;
*(_QWORD *)(*(_QWORD *)a1 + 32LL) = a2;
}
return result;
}

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

result = func1();
if ( !(_DWORD)result )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 268828672LL;
*(_QWORD *)(*(_QWORD *)a1 + 32LL) = a2;
}
return result;
}

original_code:
ER MitnCell_GetCellAsLong(Cell **c, long n)
{
  ER result;
  result = MitnCell_GetCell(c);
  if ((result) != (0)) { return (result); };
  (*c)->type = (0x00040000 | (0x10000000) | (0x00020000 | (0x10000000)));
  (*c)->value.inum = n;
  return (0);
}

canonical_original_code:
int MitnCell_GetCellAsLong(struct _cell **c, long n)
{
  int result;
  result = MitnCell_GetCell(c);
  if ((result) != (0)) { return (result); };
  (*c)->type = (0x00040000 | (0x10000000) | (0x00020000 | (0x10000000)));
  (*c)->value.inum = n;
  return (0);
}

variable_types: n long


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

result = MitnCell_GetCell();
if ( !(_DWORD)result )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 269090816LL;
*(double *)(*(_QWORD *)a1 + 32LL) = a2;
}
return result;
}

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

result = func1();
if ( !(_DWORD)result )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 269090816LL;
*(double *)(*(_QWORD *)a1 + 32LL) = a2;
}
return result;
}

original_code:
ER MitnCell_GetCellAsDouble(Cell **c, double n)
{
  ER result;
  result = MitnCell_GetCell(c);
  if ((result) != (0)) { return (result); };
  (*c)->type = (0x00080000 | (0x10000000) | (0x00020000 | (0x10000000)));
  (*c)->value.dnum = n;
  return (0);
}

canonical_original_code:
int MitnCell_GetCellAsDouble(struct _cell **c, double n)
{
  int result;
  result = MitnCell_GetCell(c);
  if ((result) != (0)) { return (result); };
  (*c)->type = (0x00080000 | (0x10000000) | (0x00020000 | (0x10000000)));
  (*c)->value.dnum = n;
  return (0);
}

variable_types: n double


decompiled_code:
__int64 __fastcall MitnCell_GetCellAsStr(__int64 a1, const char *a2)
{
unsigned int v2; // ebp

v2 = MitnCell_GetCell();
if ( !v2 )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 536936448LL;
strncpy((char *)(*(_QWORD *)a1 + 32LL), a2, 0x30uLL);
*(_QWORD *)(*(_QWORD *)a1 + 80LL) = strlen(a2);
if ( *(__int64 *)(*(_QWORD *)a1 + 80LL) > 48 )
*(_QWORD *)(*(_QWORD *)a1 + 80LL) = 48LL;
}
return v2;
}

original_code:
ER MitnCell_GetCellAsStr(Cell **c, B* pStr)
{
  ER result;
  result = MitnCell_GetCell(c);
  if ((result) != (0)) { return (result); };
  (*c)->type = (0x00010000 | (0x20000000));
  strncpy((*c)->value.string.str, pStr, 48);
  (*c)->value.string.length = strlen(pStr);
  if ((*c)->value.string.length > 48) {
    (*c)->value.string.length = 48;
  }
  return (0);
}

canonical_original_code:
int MitnCell_GetCellAsStr(struct _cell **c, char *pStr)
{
  int result;
  result = MitnCell_GetCell(c);
  if ((result) != (0)) { return (result); };
  (*c)->type = (0x00010000 | (0x20000000));
  strncpy((*c)->value.string.str, pStr, 48);
  (*c)->value.string.length = strlen(pStr);
  if ((*c)->value.string.length > 48) {
    (*c)->value.string.length = 48;
  }
  return (0);
}

variable_types:
pStr
char *


decompiled_code:
__int64 __fastcall MitnCell_GetCellAsName(__int64 a1, const char *a2)
{
unsigned int v2; // ebp

v2 = MitnCell_GetCell();
if ( !v2 )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 269221888LL;
*(_QWORD *)(*(_QWORD *)a1 + 32LL) = 0LL;
strncpy((char *)(*(_QWORD *)a1 + 40LL), a2, 0x30uLL);
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, const char *a2)
{
unsigned int v2; // ebp

v2 = func1();
if ( !v2 )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 269221888LL;
*(_QWORD *)(*(_QWORD *)a1 + 32LL) = 0LL;
strncpy((char *)(*(_QWORD *)a1 + 40LL), a2, 0x30uLL);
}
return v2;
}

original_code:
ER MitnCell_GetCellAsName(Cell **c, B* pStr)
{
  ER result;
  result = MitnCell_GetCell(c);
  if ((result) != (0)) { return (result); };
  (*c)->type = (0x000C0000 | (0x10000000));
  (*c)->value.name.link = (0);
  strncpy((*c)->value.name.str, pStr, 48);
  return (0);
}

canonical_original_code:
int MitnCell_GetCellAsName(struct _cell **c, char *pStr)
{
  int result;
  result = MitnCell_GetCell(c);
  if ((result) != (0)) { return (result); };
  (*c)->type = (0x000C0000 | (0x10000000));
  (*c)->value.name.link = (0);
  strncpy((*c)->value.name.str, pStr, 48);
  return (0);
}


decompiled_code:
__int64 __fastcall MitnCell_GetCellAsTradFunc(__int64 a1, __int64 a2, __int16 a3)
{
__int64 result; // rax

result = MitnCell_GetCell();
if ( !(_DWORD)result )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 570490880LL;
*(_QWORD *)(*(_QWORD *)a1 + 40LL) = a2;
*(_QWORD *)(*(_QWORD *)a1 + 32LL) = (a3 & 0xFFF) + 1LL;
}
return result;
}

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

result = func1();
if ( !(_DWORD)result )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 570490880LL;
*(_QWORD *)(*(_QWORD *)a1 + 40LL) = a2;
*(_QWORD *)(*(_QWORD *)a1 + 32LL) = (a3 & 0xFFF) + 1LL;
}
return result;
}

original_code:
ER MitnCell_GetCellAsTradFunc(Cell **c, ER (*f)(int argc, char* argv[]), W arg_num)
{
  ER result;
  result = MitnCell_GetCell(c);
  if ((result) != (0)) { return (result); };
  (*c)->type = (0x00010000 | (0x20000000) | (0x02000000));
  (*c)->value.trad.func = f;
  (*c)->value.trad.arg_num = ((arg_num) & 0xFFF) + 1;
  return (0);
}

canonical_original_code:
int MitnCell_GetCellAsTradFunc(struct _cell **c, int (*f)(int argc, char *argv[]), long arg_num)
{
  int result;
  result = MitnCell_GetCell(c);
  if ((result) != (0)) { return (result); };
  (*c)->type = (0x00010000 | (0x20000000) | (0x02000000));
  (*c)->value.trad.func = f;
  (*c)->value.trad.arg_num = ((arg_num) & 0xFFF) + 1;
  return (0);
}

variable_types:
f
int (*)(int argc, char *argv[])


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

result = MitnCell_GetCell();
if ( !(_DWORD)result )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 570556416LL;
*(_QWORD *)(*(_QWORD *)a1 + 32LL) = a2;
}
return result;
}

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

result = func1();
if ( !(_DWORD)result )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 570556416LL;
*(_QWORD *)(*(_QWORD *)a1 + 32LL) = a2;
}
return result;
}

original_code:
ER MitnCell_GetCellAsMitnFunc(Cell **c, ER (*f)(void))
{
  ER result;
  result = MitnCell_GetCell(c);
  if ((result) != (0)) { return (result); };
  (*c)->type = (0x00020000 | (0x20000000) | (0x02000000));
  (*c)->value.mitn_func = f;
  return (0);
}

canonical_original_code:
int MitnCell_GetCellAsMitnFunc(struct _cell **c, int (*f)())
{
  int result;
  result = MitnCell_GetCell(c);
  if ((result) != (0)) { return (result); };
  (*c)->type = (0x00020000 | (0x20000000) | (0x02000000));
  (*c)->value.mitn_func = f;
  return (0);
}


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

result = MitnStack_GetLinkCellFromPool();
if ( !(_DWORD)result )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 268500992LL;
*(_QWORD *)(*(_QWORD *)a1 + 32LL) = 0LL;
*(_QWORD *)(*(_QWORD *)a1 + 24LL) = 0LL;
*(_QWORD *)(*(_QWORD *)a1 + 16LL) = 0LL;
}
return result;
}

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

result = MitnStack_GetLinkCellFromPool();
if ( !(_DWORD)result )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 268500992LL;
*(_QWORD *)(*(_QWORD *)a1 + 32LL) = 0LL;
*(_QWORD *)(*(_QWORD *)a1 + 24LL) = 0LL;
*(_QWORD *)(*(_QWORD *)a1 + 16LL) = 0LL;
}
return result;
}

original_code:
ER MitnCell_GetCellAsMark(Cell **dest)
{
  ER result;
  result = MitnStack_GetLinkCellFromPool(dest);
  if ((result) != (0)) { return (result); };
  (*dest)->type = (0x00010000 | (0x10000000));
  (*dest)->value.link = (0);
  (*dest)->next = (0);
  (*dest)->prev = (0);
  return (0);
}

canonical_original_code:
int MitnCell_GetCellAsMark(struct _cell **dest)
{
  int result;
  result = MitnStack_GetLinkCellFromPool(dest);
  if ((result) != (0)) { return (result); };
  (*dest)->type = (0x00010000 | (0x10000000));
  (*dest)->value.link = (0);
  (*dest)->next = (0);
  (*dest)->prev = (0);
  return (0);
}


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

result = MitnStack_GetLinkCellFromPool();
if ( !(_DWORD)result )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 0x40000000LL;
*(_QWORD *)(*(_QWORD *)a1 + 32LL) = a2;
*(_QWORD *)(*(_QWORD *)a1 + 24LL) = 0LL;
*(_QWORD *)(*(_QWORD *)a1 + 16LL) = 0LL;
}
return result;
}

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

result = MitnStack_GetLinkCellFromPool();
if ( !(_DWORD)result )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 0x40000000LL;
*(_QWORD *)(*(_QWORD *)a1 + 32LL) = a2;
*(_QWORD *)(*(_QWORD *)a1 + 24LL) = 0LL;
*(_QWORD *)(*(_QWORD *)a1 + 16LL) = 0LL;
}
return result;
}

original_code:
ER MitnCell_GetCellAsLink(Cell **dest, Cell *src)
{
  ER result;
  result = MitnStack_GetLinkCellFromPool(dest);
  if ((result) != (0)) { return (result); };
  (*dest)->type = (0x40000000);
  (*dest)->value.link = src;
  (*dest)->next = (0);
  (*dest)->prev = (0);
  return (0);
}

canonical_original_code:
int MitnCell_GetCellAsLink(struct _cell **dest, struct _cell *src)
{
  int result;
  result = MitnStack_GetLinkCellFromPool(dest);
  if ((result) != (0)) { return (result); };
  (*dest)->type = (0x40000000);
  (*dest)->value.link = src;
  (*dest)->next = (0);
  (*dest)->prev = (0);
  return (0);
}

variable_types:
src
struct _cell *


original_code:
ER MitnCell_ToString(B *str, Cell *c, W len)
{
  ER result;
  result = (0);
  switch(c->type)
    {
    case (0x000C0000 | (0x10000000)):
    case (0x00010000 | (0x20000000)):
      strncpy(str, c->value.string.str, len - 1);
      c->value.string.length = len - 1;
      str[len] = '\0';
      break;
    case (0x00040000 | (0x10000000) | (0x00020000 | (0x10000000))):
      l2a(str, c->value.inum, len);
      break;
    default:
      result = (-17);
    }
  return result;
}

canonical_original_code:
int MitnCell_ToString(char *str, struct _cell *c, long len)
{
  int result;
  result = (0);
  switch(c->type)
    {
    case (0x000C0000 | (0x10000000)):
    case (0x00010000 | (0x20000000)):
      strncpy(str, c->value.string.str, len - 1);
      c->value.string.length = len - 1;
      str[len] = '\0';
      break;
    case (0x00040000 | (0x10000000) | (0x00020000 | (0x10000000))):
      l2a(str, c->value.inum, len);
      break;
    default:
      result = (-17);
    }
  return result;
}

variable_types:
str
char *

variable_types: len long


variable_types:
n
long *


original_code:
ER MitnCell_CopyCell(Cell **dest, Cell *src)
{
  ER result;
  switch (src->type) {
  case (0x00010000 | (0x10000000)):
    result = MitnCell_GetCellAsMark(dest);
    break;
  case (0x00040000 | (0x10000000) | (0x00020000 | (0x10000000))):
    result = MitnCell_GetCellAsLong(dest, src->value.inum);
    break;
  case (0x00080000 | (0x10000000) | (0x00020000 | (0x10000000))):
    result = (-17);
    break;
  case (0x000C0000 | (0x10000000)):
    result = MitnCell_GetCellAsName(dest, src->value.name.str);
    break;
  case (0x00100000 | (0x10000000)):
    result = (-17);
    break;
  case (0x00010000 | (0x20000000)):
    result = MitnCell_GetCellAsStr(dest, src->value.string.str);
    break;
  case (0x00020000 | (0x20000000)):
    result = (-17);
    break;
  case (0x00040000 | (0x20000000)):
    result = (-17);
    break;
  case (0x00010000 | (0x20000000) | (0x02000000)):
    result = MitnCell_GetCellAsTradFunc(dest,
        src->value.trad.func,
        src->value.trad.arg_num);
    break;
  case (0x00020000 | (0x20000000) | (0x02000000)):
    result = MitnCell_GetCellAsMitnFunc(dest,
        src->value.mitn_func);
    break;
  }
  if ((result) != (0)) { return (result); };
  return (0);
}

canonical_original_code:
int MitnCell_CopyCell(struct _cell **dest, struct _cell *src)
{
  int result;
  switch (src->type) {
  case (0x00010000 | (0x10000000)):
    result = MitnCell_GetCellAsMark(dest);
    break;
  case (0x00040000 | (0x10000000) | (0x00020000 | (0x10000000))):
    result = MitnCell_GetCellAsLong(dest, src->value.inum);
    break;
  case (0x00080000 | (0x10000000) | (0x00020000 | (0x10000000))):
    result = (-17);
    break;
  case (0x000C0000 | (0x10000000)):
    result = MitnCell_GetCellAsName(dest, src->value.name.str);
    break;
  case (0x00100000 | (0x10000000)):
    result = (-17);
    break;
  case (0x00010000 | (0x20000000)):
    result = MitnCell_GetCellAsStr(dest, src->value.string.str);
    break;
  case (0x00020000 | (0x20000000)):
    result = (-17);
    break;
  case (0x00040000 | (0x20000000)):
    result = (-17);
    break;
  case (0x00010000 | (0x20000000) | (0x02000000)):
    result = MitnCell_GetCellAsTradFunc(dest,
        src->value.trad.func,
        src->value.trad.arg_num);
    break;
  case (0x00020000 | (0x20000000) | (0x02000000)):
    result = MitnCell_GetCellAsMitnFunc(dest,
        src->value.mitn_func);
    break;
  }
  if ((result) != (0)) { return (result); };
  return (0);
}


decompiled_code:
void f_quit()
{
error_no = -1;
}

canonical_decompiled_code:
void func0()
{
error_no = -1;
}

original_code:
void f_quit()
{
  error_no = (-1);
}

canonical_original_code:
void f_quit()
{
  error_no = (-1);
}

return_type: void


decompiled_code:
unsigned int f_dot()
{
unsigned int result; // eax

result = pop();
if ( !error_no )
result = printf("%d", result);
return result;
}

canonical_decompiled_code:
unsigned int func1()
{
unsigned int result; // eax

result = pop();
if ( !error_no )
result = printf("%d", result);
return result;
}

original_code:
void f_dot()
{
  int val;
  val = pop();
  if (error_no != 0) return;;
  printf("%d", val);
}

variable_types: val int


decompiled_code:
unsigned int f_doth()
{
unsigned int result; // eax

result = pop();
if ( !error_no )
result = printf("%x", result);
return result;
}

canonical_decompiled_code:
unsigned int func2()
{
unsigned int result; // eax

result = pop();
if ( !error_no )
result = printf("%x", result);
return result;
}

original_code:
void f_doth()
{
  int val;
  val = pop();
  if (error_no != 0) return;;
  printf("%x", val);
}


decompiled_code:
unsigned int f_doto()
{
unsigned int result; // eax

result = pop();
if ( !error_no )
result = printf("%o", result);
return result;
}

canonical_decompiled_code:
unsigned int func3()
{
unsigned int result; // eax

result = pop();
if ( !error_no )
result = printf("%o", result);
return result;
}

original_code:
void f_doto()
{
  int val;
  val = pop();
  if (error_no != 0) return;;
  printf("%o", val);
}


decompiled_code:
int f_cr()
{
return putchar(10);
}

canonical_decompiled_code:
int func4()
{
return putchar(10);
}

original_code:
void f_cr()
{
  printf("\n");
}

canonical_original_code:
void f_cr()
{
  printf("\n");
}


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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push((unsigned int)(v1 + result));
}
return result;
}

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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push((unsigned int)(v1 + result));
}
return result;
}

original_code:
void f_sum()
{
  int val1, val2;
  val1 = pop(); if (error_no != 0) return;;
  val2 = pop(); if (error_no != 0) return;;
  push(val1 + val2); if (error_no != 0) return;;
}

canonical_original_code:
void f_sum()
{
  int val1; int val2;
  val1 = pop(); if (error_no != 0) return;;
  val2 = pop(); if (error_no != 0) return;;
  push(val1 + val2); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push((unsigned int)(result - v1));
}
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 )
result = push((unsigned int)(result - v1));
}
return result;
}

original_code:
void f_sub()
{
  int val1, val2;
  val1 = pop(); if (error_no != 0) return;;
  val2 = pop(); if (error_no != 0) return;;
  push(val2 - val1); if (error_no != 0) return;;
}

canonical_original_code:
void f_sub()
{
  int val1; int val2;
  val1 = pop(); if (error_no != 0) return;;
  val2 = pop(); if (error_no != 0) return;;
  push(val2 - val1); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push((unsigned int)(result * v1));
}
return result;
}

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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push((unsigned int)(result * v1));
}
return result;
}

original_code:
void f_mul()
{
  int val1, val2;
  val1 = pop(); if (error_no != 0) return;;
  val2 = pop(); if (error_no != 0) return;;
  push(val1 * val2); if (error_no != 0) return;;
}

canonical_original_code:
void f_mul()
{
  int val1; int val2;
  val1 = pop(); if (error_no != 0) return;;
  val2 = pop(); if (error_no != 0) return;;
  push(val1 * val2); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
{
if ( v1 )
result = push((unsigned int)((int)result / v1));
else
error_no = 4;
}
}
return result;
}

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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
{
if ( v1 )
result = push((unsigned int)((int)result / v1));
else
error_no = 4;
}
}
return result;
}

original_code:
void f_div()
{
  int val1, val2;
  val1 = pop(); if (error_no != 0) return;;
  val2 = pop(); if (error_no != 0) return;;
  if (val1 == 0) {
    error_no = 4;
    return;
  }
  push(val2 / val1); if (error_no != 0) return;;
}

canonical_original_code:
void f_div()
{
  int val1; int val2;
  val1 = pop(); if (error_no != 0) return;;
  val2 = pop(); if (error_no != 0) return;;
  if (val1 == 0) {
    error_no = 4;
    return;
  }
  push(val2 / val1); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
{
if ( v1 )
result = push((unsigned int)((int)result % v1));
else
error_no = 4;
}
}
return result;
}

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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
{
if ( v1 )
result = push((unsigned int)((int)result % v1));
else
error_no = 4;
}
}
return result;
}

original_code:
void f_mod()
{
  int val1, val2;
  val1 = pop(); if (error_no != 0) return;;
  val2 = pop(); if (error_no != 0) return;;
  if (val1 == 0) {
    error_no = 4;
    return;
  }
  push(val2 % val1); if (error_no != 0) return;;
}

canonical_original_code:
void f_mod()
{
  int val1; int val2;
  val1 = pop(); if (error_no != 0) return;;
  val2 = pop(); if (error_no != 0) return;;
  if (val1 == 0) {
    error_no = 4;
    return;
  }
  push(val2 % val1); if (error_no != 0) return;;
}


decompiled_code:
int f_echo()
{
int result; // eax
int v1; // ecx
int v2; // eax

while ( 1 )
{
result = pop();
if ( error_no )
break;
str_0 = result;
if ( !(_BYTE)result )
return printf("%s", &str_0);
byte_7CD = BYTE1(result);
v1 = result >> 16;
if ( !BYTE1(result) )
return printf("%s", &str_0);
byte_7CE = BYTE2(result);
v2 = result >> 24;
if ( !(_BYTE)v1 )
return printf("%s", &str_0);
byte_7CF = v2;
if ( !(_BYTE)v2 )
return printf("%s", &str_0);
printf("%s", &str_0);
}
return result;
}

canonical_decompiled_code:
int func10()
{
int result; // eax
int v1; // ecx
int v2; // eax

while ( 1 )
{
result = pop();
if ( error_no )
break;
str_0 = result;
if ( !(_BYTE)result )
return printf("%s", &str_0);
byte_7CD = BYTE1(result);
v1 = result >> 16;
if ( !BYTE1(result) )
return printf("%s", &str_0);
byte_7CE = BYTE2(result);
v2 = result >> 24;
if ( !(_BYTE)v1 )
return printf("%s", &str_0);
byte_7CF = v2;
if ( !(_BYTE)v2 )
return printf("%s", &str_0);
printf("%s", &str_0);
}
return result;
}

original_code:
void f_echo()
{
  int val1, i, cl, il;
  static char str[5] = {0, 0, 0, 0, 0};
  cl = sizeof(char)*8;
  il = sizeof(int) / sizeof(char);
  while(1) {
    val1 = pop(); if (error_no != 0) return;;
    for(i = 0; i < il; ++i) {
      str[i] = val1 & 0x00FF;
      val1 >>= cl;
      if (str[i] == 0) break;
    }
    if (i != il) break;
    printf("%s", str);
  }
  printf("%s", str);
}

canonical_original_code:
void f_echo()
{
  int val1; int i; int cl; int il;
  static char str[5] = {0, 0, 0, 0, 0};
  cl = sizeof(char)*8;
  il = sizeof(int) / sizeof(char);
  while(1) {
    val1 = pop(); if (error_no != 0) return;;
    for(i = 0; i < il; ++i) {
      str[i] = val1 & 0x00FF;
      val1 >>= cl;
      if (str[i] == 0) break;
    }
    if (i != il) break;
    printf("%s", str);
  }
  printf("%s", str);
}

variable_types: i int

variable_types: cl int

variable_types: il int

variable_types:
str
char [5]


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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push(v1 == (_DWORD)result);
}
return result;
}

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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push(v1 == (_DWORD)result);
}
return result;
}

original_code:
void f_eq()
{
  int v1, v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v1 == v2); if (error_no != 0) return;;
}

canonical_original_code:
void f_eq()
{
  int v1; int v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v1 == v2); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push(v1 > (int)result);
}
return result;
}

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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push(v1 > (int)result);
}
return result;
}

original_code:
void f_lt()
{
  int v1, v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v2 < v1); if (error_no != 0) return;;
}

canonical_original_code:
void f_lt()
{
  int v1; int v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v2 < v1); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push(v1 < (int)result);
}
return result;
}

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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push(v1 < (int)result);
}
return result;
}

original_code:
void f_gt()
{
  int v1, v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v2 > v1); if (error_no != 0) return;;
}

canonical_original_code:
void f_gt()
{
  int v1; int v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v2 > v1); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push(v1 >= (int)result);
}
return result;
}

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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push(v1 >= (int)result);
}
return result;
}

original_code:
void f_le()
{
  int v1, v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v2 <= v1); if (error_no != 0) return;;
}

canonical_original_code:
void f_le()
{
  int v1; int v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v2 <= v1); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push(v1 <= (int)result);
}
return result;
}

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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
result = push(v1 <= (int)result);
}
return result;
}

original_code:
void f_ge()
{
  int v1, v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v2 >= v1); if (error_no != 0) return;;
}

canonical_original_code:
void f_ge()
{
  int v1; int v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v2 >= v1); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
result = push((_DWORD)result == 0);
return result;
}

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

result = pop();
if ( !error_no )
result = push((_DWORD)result == 0);
return result;
}

original_code:
void f_not()
{
  int val;
  val = pop(); if (error_no != 0) return;;
  push(! val); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
{
v1 = result;
result = push((unsigned int)result);
if ( !error_no )
result = push(v1);
}
return result;
}

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

result = pop();
if ( !error_no )
{
v1 = result;
result = push((unsigned int)result);
if ( !error_no )
result = push(v1);
}
return result;
}

original_code:
void f_dup()
{
  int val;
  val = pop(); if (error_no != 0) return;;
  push(val); if (error_no != 0) return;;
  push(val); if (error_no != 0) return;;
}


decompiled_code:
__int64 f_swap()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // ebp

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = push(v1);
if ( !error_no )
result = push(v2);
}
}
return result;
}

canonical_decompiled_code:
__int64 func18()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // ebp

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = push(v1);
if ( !error_no )
result = push(v2);
}
}
return result;
}

original_code:
void f_swap()
{
  int v1, v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v1); if (error_no != 0) return;;
  push(v2); if (error_no != 0) return;;
}

canonical_original_code:
void f_swap()
{
  int v1; int v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v1); if (error_no != 0) return;;
  push(v2); if (error_no != 0) return;;
}


decompiled_code:
__int64 f_drop()
{
return pop();
}

canonical_decompiled_code:
__int64 func19()
{
return pop();
}

original_code:
void f_drop()
{
  pop(); if (error_no != 0) return;;
}


decompiled_code:
int f_sp()
{
return putchar(32);
}

canonical_decompiled_code:
int func20()
{
return putchar(32);
}

original_code:
void f_sp()
{
  printf(" ");
}

canonical_original_code:
void f_sp()
{
  printf(" ");
}


decompiled_code:
int f_spaces()
{
int result; // eax
int v1; // ebx
int v2; // ebp

result = pop();
v1 = error_no;
if ( !error_no )
{
v2 = result;
if ( result > 0 )
{
do
{
result = putchar(32);
++v1;
}
while ( v2 != v1 );
}
}
return result;
}

canonical_decompiled_code:
int func21()
{
int result; // eax
int v1; // ebx
int v2; // ebp

result = pop();
v1 = error_no;
if ( !error_no )
{
v2 = result;
if ( result > 0 )
{
do
{
result = putchar(32);
++v1;
}
while ( v2 != v1 );
}
}
return result;
}

original_code:
void f_spaces()
{
  int val, i;
  val = pop(); if (error_no != 0) return;;
  for(i = 0; i < val; ++i) {
    printf(" ");
  }
}

canonical_original_code:
void f_spaces()
{
  int val; int i;
  val = pop(); if (error_no != 0) return;;
  for(i = 0; i < val; ++i) {
    printf(" ");
  }
}


decompiled_code:
int f_esc()
{
return putchar(27);
}

canonical_decompiled_code:
int func22()
{
return putchar(27);
}

original_code:
void f_esc()
{
  printf("\033");
}

canonical_original_code:
void f_esc()
{
  printf("\033");
}


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

result = pop();
if ( !error_no )
result = push((unsigned int)-(int)result);
return result;
}

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

result = pop();
if ( !error_no )
result = push((unsigned int)-(int)result);
return result;
}

original_code:
void f_minus()
{
  int val;
  val = pop(); if (error_no != 0) return;;
  val *= -1;
  push(val); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
{
if ( (int)result < 0 )
result = push((unsigned int)-(int)result);
else
result = push((unsigned int)result);
}
return result;
}

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

result = pop();
if ( !error_no )
{
if ( (int)result < 0 )
result = push((unsigned int)-(int)result);
else
result = push((unsigned int)result);
}
return result;
}

original_code:
void f_abs()
{
  int val;
  val = pop(); if (error_no != 0) return;;
  if (val < 0) {
    push(-val); if (error_no != 0) return;;
  }
  else {
    push(val);
  }
}


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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
{
if ( v1 >= (int)result )
LODWORD(result) = v1;
result = push((unsigned int)result);
}
}
return result;
}

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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
{
if ( v1 >= (int)result )
LODWORD(result) = v1;
result = push((unsigned int)result);
}
}
return result;
}

original_code:
void f_max()
{
  int v1, v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push((v1 > v2)? v1: v2); if (error_no != 0) return;;
}

canonical_original_code:
void f_max()
{
  int v1; int v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push((v1 > v2)? v1: v2); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
{
if ( v1 <= (int)result )
LODWORD(result) = v1;
result = push((unsigned int)result);
}
}
return result;
}

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

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
if ( !error_no )
{
if ( v1 <= (int)result )
LODWORD(result) = v1;
result = push((unsigned int)result);
}
}
return result;
}

original_code:
void f_min()
{
  int v1, v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push((v1 < v2)? v1: v2); if (error_no != 0) return;;
}

canonical_original_code:
void f_min()
{
  int v1; int v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push((v1 < v2)? v1: v2); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
result = push((unsigned int)(result + 1));
return result;
}

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

result = pop();
if ( !error_no )
result = push((unsigned int)(result + 1));
return result;
}

original_code:
void f_inc()
{
  int val;
  val = pop(); if (error_no != 0) return;;
  push(val + 1); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
result = push((unsigned int)(result - 1));
return result;
}

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

result = pop();
if ( !error_no )
result = push((unsigned int)(result - 1));
return result;
}

original_code:
void f_dec()
{
  int val;
  val = pop(); if (error_no != 0) return;;
  push(val - 1); if (error_no != 0) return;;
}


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

result = pop();
if ( !error_no )
result = push((_DWORD)result == 0);
return result;
}

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

result = pop();
if ( !error_no )
result = push((_DWORD)result == 0);
return result;
}

original_code:
void f_eq0()
{
  int val;
  val = pop(); if (error_no != 0) return;;
  push(val == 0); if (error_no != 0) return;;
}


decompiled_code:
__int64 f_over()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // ebp

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = push((unsigned int)result);
if ( !error_no )
{
result = push(v1);
if ( !error_no )
result = push(v2);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func30()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // ebp

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = push((unsigned int)result);
if ( !error_no )
{
result = push(v1);
if ( !error_no )
result = push(v2);
}
}
}
return result;
}

original_code:
void f_over()
{
  int v1, v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v2); if (error_no != 0) return;;
  push(v1); if (error_no != 0) return;;
  push(v2); if (error_no != 0) return;;
}

canonical_original_code:
void f_over()
{
  int v1; int v2;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  push(v2); if (error_no != 0) return;;
  push(v1); if (error_no != 0) return;;
  push(v2); if (error_no != 0) return;;
}


decompiled_code:
__int64 f_rot()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // ebp
unsigned int v3; // er12

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
result = push(v2);
if ( !error_no )
{
result = push(v1);
if ( !error_no )
result = push(v3);
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func31()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // ebp
unsigned int v3; // er12

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
result = push(v2);
if ( !error_no )
{
result = push(v1);
if ( !error_no )
result = push(v3);
}
}
}
}
return result;
}

original_code:
void f_rot()
{
  int v1, v2, v3;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  v3 = pop(); if (error_no != 0) return;;
  push(v2); if (error_no != 0) return;;
  push(v1); if (error_no != 0) return;;
  push(v3); if (error_no != 0) return;;
}

canonical_original_code:
void f_rot()
{
  int v1; int v2; int v3;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  v3 = pop(); if (error_no != 0) return;;
  push(v2); if (error_no != 0) return;;
  push(v1); if (error_no != 0) return;;
  push(v3); if (error_no != 0) return;;
}


decompiled_code:
__int64 f_rotr()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // ebp
unsigned int v3; // er12

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
result = push(v1);
if ( !error_no )
{
result = push(v3);
if ( !error_no )
result = push(v2);
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func32()
{
__int64 result; // rax
unsigned int v1; // ebx
unsigned int v2; // ebp
unsigned int v3; // er12

result = pop();
if ( !error_no )
{
v1 = result;
result = pop();
v2 = result;
if ( !error_no )
{
result = pop();
v3 = result;
if ( !error_no )
{
result = push(v1);
if ( !error_no )
{
result = push(v3);
if ( !error_no )
result = push(v2);
}
}
}
}
return result;
}

original_code:
void f_rotr()
{
  int v1, v2, v3;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  v3 = pop(); if (error_no != 0) return;;
  push(v1); if (error_no != 0) return;;
  push(v3); if (error_no != 0) return;;
  push(v2); if (error_no != 0) return;;
}

canonical_original_code:
void f_rotr()
{
  int v1; int v2; int v3;
  v1 = pop(); if (error_no != 0) return;;
  v2 = pop(); if (error_no != 0) return;;
  v3 = pop(); if (error_no != 0) return;;
  push(v1); if (error_no != 0) return;;
  push(v3); if (error_no != 0) return;;
  push(v2); if (error_no != 0) return;;
}


times

decompiled_code:
__int64 __fastcall times(__int64 a1)
{
return (int)call_lowlib(34LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return (int)call_lowlib(34LL, a1);
}

original_code:
clock_t
times (struct tms *buf)
{
  return (call_lowlib (34, buf));
}

canonical_original_code:
unsigned long times(struct tms *buf)
{
  return (call_lowlib (34, buf));
}

variable_types:
buf
struct tms {  } *

return_type: unsigned long


decompiled_code:
__int64 init_fd_driver()
{
recvport = get_port(1096LL, 1096LL);
if ( recvport <= 0 )
{
dbg_printf("FD: cannot make receive porrt.\n");
slp_tsk();
}
regist_port("driver.fd", (unsigned int)recvport);
waitflag = get_flag(0LL, 0LL);
fd_data = get_fdspec("2HD");
*(&fd_data + 1) = get_fdspec("2HD");
return init_fd();
}

canonical_decompiled_code:
__int64 func1()
{
recvport = get_port(1096LL, 1096LL);
if ( recvport <= 0 )
{
dbg_printf("FD: cannot make receive porrt.\n");
slp_tsk();
}
regist_port("driver.fd", (unsigned int)recvport);
waitflag = get_flag(0LL, 0LL);
fd_data = get_fdspec("2HD");
*(&fd_data + 1) = get_fdspec("2HD");
return func0();
}

original_code:
static void
init_fd_driver (void)
{
  int i;
  ID root_dev;
  ER error;
  recvport = get_port (sizeof (DDEV_RES), sizeof (DDEV_RES));
  if (recvport <= 0)
    {
      dbg_printf ("FD: cannot make receive porrt.\n");
      slp_tsk ();
    }
  error = regist_port ("driver.fd", recvport);
  if (error != (0))
    {
    }
  waitflag = get_flag ((0x00000000), 0);
  fd_data[0] = get_fdspec ("2HD");
  fd_data[1] = get_fdspec ("2HD");
  init_fd ();
}

canonical_original_code:
static void init_fd_driver()
{
  int i;
  int root_dev;
  int error;
  recvport = get_port (sizeof (DDEV_RES), sizeof (DDEV_RES));
  if (recvport <= 0)
    {
      dbg_printf ("FD: cannot make receive porrt.\n");
      slp_tsk ();
    }
  error = regist_port ("driver.fd", recvport);
  if (error != (0))
    {
    }
  waitflag = get_flag ((0x00000000), 0);
  fd_data[0] = get_fdspec ("2HD");
  fd_data[1] = get_fdspec ("2HD");
  init_fd ();
}

variable_types: error int


original_code:
W
close_fd (ID caller, DDEV_CLS_REQ *packet)
{
  DDEV_RES res;
  res.body.cls_res.dd = packet->dd;
  res.body.cls_res.errcd = (0);
  res.body.cls_res.errinfo = (0);
  snd_mbf (caller, sizeof (res), &res);
  return ((0));
}

canonical_original_code:
long close_fd(int caller, struct DDEV_CLS_REQ *packet)
{
  struct DDEV_RES res;
  res.body.cls_res.dd = packet->dd;
  res.body.cls_res.errcd = (0);
  res.body.cls_res.errinfo = (0);
  snd_mbf (caller, sizeof (res), &res);
  return ((0));
}

variable_types: caller int

variable_types: struct DDEV_CLS_REQ { long dd; long eject; } *

variable_types: struct DDEV_RES { struct SVC_REQ { int mbfid; long msgtyp; int tskid; long len; unsigned long arg[]; } header; union { struct DDEV_OPN_RES { long dd; long errcd; long errinfo; } opn_res; struct DDEV_CLS_RES { long dd; long errcd; long errinfo; } cls_res; struct DDEV_REA_RES { long dd; long errcd; long errinfo; long split; long a_size; unsigned char dt[1024]; } rea_res; struct DDEV_WRI_RES { long dd; long errcd; long errinfo; long a_size; } wri_res; struct DDEV_CTL_RES { long dd; long errcd; long errinfo; long res[]; } ctl_res; } body; }

return_type: long

user_defined_types: struct DDEV_RES { struct SVC_REQ header; union { struct DDEV_OPN_RES opn_res; struct DDEV_CLS_RES cls_res; struct DDEV_REA_RES rea_res; struct DDEV_WRI_RES wri_res; struct DDEV_CTL_RES ctl_res; } body; }


decompiled_code:
__int64 __fastcall control_fd(unsigned int a1, __int64 a2)
{
__int64 v3; // rax
__int64 v4; // rbx
unsigned __int8 v5; // si
int v6; // ebx
int v7; // ebx
_QWORD v9[141]; // [rsp+0h] [rbp-468h] BYREF

v3 = *(_QWORD *)(a2 + 8);
if ( v3 )
{
LODWORD(v4) = -17;
if ( v3 == 1 )
{
v5 = *(_BYTE *)(a2 + 24);
if ( v5 == 1 )
{
v7 = *(unsigned __int8 *)(a2 + 25);
fd_data[v7] = get_fdspec("2HC");
LODWORD(v4) = reset_fdc(*(unsigned __int8 *)(a2 + 25)) == 0 ? 0xFFFFFF9B : 0;
}
else if ( v5 == 2 )
{
dbg_printf("control_fd: Unknown FD type.\n");
LODWORD(v4) = 0;
}
else if ( v5 )
{
dbg_printf("control_fd: unknown FD type (%d)\n", v5);
LODWORD(v4) = -33;
}
else
{
v6 = *(unsigned __int8 *)(a2 + 25);
fd_data[v6] = get_fdspec("2HD");
LODWORD(v4) = reset_fdc(*(unsigned __int8 *)(a2 + 25)) == 0 ? 0xFFFFFF9B : 0;
}
}
}
else
{
dbg_printf("control_fd: nowork\n");
LODWORD(v4) = 0;
}
v9[4] = *(_QWORD *)a2;
v4 = (int)v4;
v9[5] = v4;
v9[6] = (int)v4;
snd_mbf(a1, 1096LL, v9);
return (int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1, __int64 a2)
{
__int64 v3; // rax
__int64 v4; // rbx
unsigned __int8 v5; // si
int v6; // ebx
int v7; // ebx
_QWORD v9[141]; // [rsp+0h] [rbp-468h] BYREF

v3 = *(_QWORD *)(a2 + 8);
if ( v3 )
{
LODWORD(v4) = -17;
if ( v3 == 1 )
{
v5 = *(_BYTE *)(a2 + 24);
if ( v5 == 1 )
{
v7 = *(unsigned __int8 *)(a2 + 25);
fd_data[v7] = get_fdspec("2HC");
LODWORD(v4) = reset_fdc(*(unsigned __int8 *)(a2 + 25)) == 0 ? 0xFFFFFF9B : 0;
}
else if ( v5 == 2 )
{
dbg_printf("control_fd: Unknown FD type.\n");
LODWORD(v4) = 0;
}
else if ( v5 )
{
dbg_printf("control_fd: unknown FD type (%d)\n", v5);
LODWORD(v4) = -33;
}
else
{
v6 = *(unsigned __int8 *)(a2 + 25);
fd_data[v6] = get_fdspec("2HD");
LODWORD(v4) = reset_fdc(*(unsigned __int8 *)(a2 + 25)) == 0 ? 0xFFFFFF9B : 0;
}
}
}
else
{
dbg_printf("control_fd: nowork\n");
LODWORD(v4) = 0;
}
v9[4] = *(_QWORD *)a2;
v4 = (int)v4;
v9[5] = v4;
v9[6] = (int)v4;
snd_mbf(a1, 1096LL, v9);
return (int)v4;
}

original_code:
W
control_fd (ID caller, DDEV_CTL_REQ *packet)
{
  DDEV_RES res;
  ER error = (0);
  W drive;
  switch (packet->cmd)
    {
    case 1:
      switch (packet->param[0])
 {
 case 0:
   fd_data[packet->param[1]] = get_fdspec ("2HD");
   if (reset_fdc (packet->param[1]) == (0))
     error = (-101);
   break;
 case 1:
   fd_data[packet->param[1]] = get_fdspec ("2HC");
   if (reset_fdc (packet->param[1]) == (0))
     error = (-101);
   break;
 case 2:
   dbg_printf ("control_fd: Unknown FD type.\n");
   break;
 default:
   dbg_printf ("control_fd: unknown FD type (%d)\n", packet->param[0]);
   error = (-33);
   break;
 }
      break;
    case 0:
      dbg_printf ("control_fd: nowork\n");
      break;
    default:
      error = (-17);
      break;
    }
  res.body.ctl_res.dd = packet->dd;
  res.body.ctl_res.errcd = error;
  res.body.ctl_res.errinfo = error;
  snd_mbf (caller, sizeof (res), &res);
  return (error);
}

canonical_original_code:
long control_fd(int caller, struct DDEV_CTL_REQ *packet)
{
  struct DDEV_RES res;
  int error = (0);
  long drive;
  switch (packet->cmd)
    {
    case 1:
      switch (packet->param[0])
 {
 case 0:
   fd_data[packet->param[1]] = get_fdspec ("2HD");
   if (reset_fdc (packet->param[1]) == (0))
     error = (-101);
   break;
 case 1:
   fd_data[packet->param[1]] = get_fdspec ("2HC");
   if (reset_fdc (packet->param[1]) == (0))
     error = (-101);
   break;
 case 2:
   dbg_printf ("control_fd: Unknown FD type.\n");
   break;
 default:
   dbg_printf ("control_fd: unknown FD type (%d)\n", packet->param[0]);
   error = (-33);
   break;
 }
      break;
    case 0:
      dbg_printf ("control_fd: nowork\n");
      break;
    default:
      error = (-17);
      break;
    }
  res.body.ctl_res.dd = packet->dd;
  res.body.ctl_res.errcd = error;
  res.body.ctl_res.errinfo = error;
  snd_mbf (caller, sizeof (res), &res);
  return (error);
}

variable_types: struct DDEV_CTL_REQ { long dd; unsigned long cmd; long len; unsigned char param[]; } *

variable_types: drive long

user_defined_types: struct SVC_REQ { int mbfid; long msgtyp; int tskid; long len; unsigned long arg[]; }

user_defined_types: struct DDEV_OPN_RES { long dd; long errcd; long errinfo; }

user_defined_types: struct DDEV_CLS_RES { long dd; long errcd; long errinfo; }

user_defined_types: struct DDEV_REA_RES { long dd; long errcd; long errinfo; long split; long a_size; unsigned char dt[1024]; }

user_defined_types: struct DDEV_WRI_RES { long dd; long errcd; long errinfo; long a_size; }

user_defined_types: struct DDEV_CTL_RES { long dd; long errcd; long errinfo; long res[]; }


decompiled_code:
__int64 init_fd()
{
unsigned int v0; // eax
__int64 result; // rax
unsigned int v2; // ebx
int v3; // [rsp+0h] [rbp-18h] BYREF
void *v4; // [rsp+8h] [rbp-10h]

v3 = 3;
v4 = &intr_fd;
v0 = def_int(38LL, &v3);
if ( v0 )
{
v2 = v0;
dbg_printf("fd: error on def_int (errno = %d)\n", v0);
result = (int)v2;
}
else
{
reset_intr_mask(6LL);
intr_flag = 0LL;
result = reset_fdc(0LL);
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // eax
__int64 result; // rax
unsigned int v2; // ebx
int v3; // [rsp+0h] [rbp-18h] BYREF
void *v4; // [rsp+8h] [rbp-10h]

v3 = 3;
v4 = &intr_fd;
v0 = def_int(38LL, &v3);
if ( v0 )
{
v2 = v0;
dbg_printf("fd: error on def_int (errno = %d)\n", v0);
result = (int)v2;
}
else
{
reset_intr_mask(6LL);
intr_flag = 0LL;
result = reset_fdc(0LL);
}
return result;
}

original_code:
W
init_fd (void)
{
  W status;
  T_DINT pkt;
  ER err;
  pkt.intatr = (3);
  pkt.inthdr = (FP)intr_fd;
  err = def_int (38, &pkt);
  if (err != (0))
    {
      dbg_printf ("fd: error on def_int (errno = %d)\n", err);
      return (err);
    }
  reset_intr_mask (6);
  intr_flag = (0);
  reset_fdc (0);
}

canonical_original_code:
long init_fd()
{
  long status;
  struct t_dint pkt;
  int err;
  pkt.intatr = (3);
  pkt.inthdr = (void (*)())intr_fd;
  err = def_int (38, &pkt);
  if (err != (0))
    {
      dbg_printf ("fd: error on def_int (errno = %d)\n", err);
      return (err);
    }
  reset_intr_mask (6);
  intr_flag = (0);
  reset_fdc (0);
}

variable_types: status long

variable_types: struct t_dint { unsigned int intatr; void (*inthdr)(); }

variable_types: err int


original_code:
W
open_fd (ID caller, DDEV_OPN_REQ *packet)
{
  DDEV_RES res;
  res.body.opn_res.dd = packet->dd;
  res.body.opn_res.errcd = (0);
  res.body.opn_res.errinfo = (0);
  snd_mbf (caller, sizeof (res), &res);
  return ((0));
}

canonical_original_code:
long open_fd(int caller, struct DDEV_OPN_REQ *packet)
{
  struct DDEV_RES res;
  res.body.opn_res.dd = packet->dd;
  res.body.opn_res.errcd = (0);
  res.body.opn_res.errinfo = (0);
  snd_mbf (caller, sizeof (res), &res);
  return ((0));
}

variable_types:
packet
struct DDEV_OPN_REQ { long dd; } *


original_code:
W
read_fd (ID caller, DDEV_REA_REQ *packet)
{
  DDEV_RES res;
  W blockno;
  W bcount;
  W cylinder;
  W head;
  W sector;
  W drive;
  W i, try;
  W done_length;
  static B buff[512 * 2];
  UW bp;
  ER ret;
  ER error;
  UW bufstart;
  UW buflength;
  drive = packet->dd & 0xff;
  if (reset_fdc (drive) == (0))
    {
      goto bad;
    }
  bufstart = ((packet->start / 512) * 512);
  buflength = ((packet->start + packet->size + (512 -1)) / 512 * 512);
  for (bp = 0; bp < (buflength - bufstart); bp += 512)
    {
      blockno = ((UW)(bp + bufstart) / 512) * (512 / fd_data[packet->dd & 0xff]->length);
      if (512 >= (fd_data[packet->dd & 0xff]->length))
 {
   bcount = 512 / (fd_data[packet->dd & 0xff]->length);
 }
      done_length = 0;
      error = (0);
      ret = (0);
      for (i = 0; i < bcount; i++)
 {
   head = (blockno % ((fd_data[packet->dd & 0xff]->head) * (fd_data[packet->dd & 0xff]->sector))) / (fd_data[packet->dd & 0xff]->sector);
   cylinder = (blockno / ((fd_data[packet->dd & 0xff]->head) * (fd_data[packet->dd & 0xff]->sector)));
   sector = (blockno % (fd_data[packet->dd & 0xff]->sector)) + 1;
   for (try = 0; try < (fd_data[packet->dd & 0xff]->retry); try++)
     {
       ret = get_data (drive, head, cylinder, sector, (void *)&(buff[bp + (i * (fd_data[packet->dd & 0xff]->length))]));
       if (ret == (0))
  break;
     }
   if (ret == (0))
     {
       done_length += (fd_data[packet->dd & 0xff]->length);
       blockno += 1;
     }
   else
     {
       error = ret;
       goto bad;
     }
 }
    }
  bcopy (&buff[packet->start - bufstart],
  res.body.rea_res.dt,
  (done_length < packet->size) ? done_length : packet->size);
  res.body.rea_res.dd = packet->dd;
  res.body.rea_res.a_size = (done_length < packet->size) ? done_length : packet->size;
  res.body.rea_res.errcd = error;
  res.body.rea_res.errinfo = (0);
  snd_mbf (caller, sizeof (res), &res);
  return ((0));
bad:
  stop_motor (drive);
  dbg_printf("fd: read fail. head = %d cylinder = %d sector = %d\n",
      head, cylinder, sector);
  res.body.rea_res.dd = packet->dd;
  res.body.rea_res.a_size = done_length;
  res.body.rea_res.errcd = error;
  res.body.rea_res.errinfo = error;
  snd_mbf (caller, sizeof (res), &res);
  return (error);
}

canonical_original_code:
long read_fd(int caller, struct DDEV_REA_REQ *packet)
{
  struct DDEV_RES res;
  long blockno;
  long bcount;
  long cylinder;
  long head;
  long sector;
  long drive;
  long i; long try;
  long done_length;
  static char buff[-1];
  unsigned long bp;
  int ret;
  int error;
  unsigned long bufstart;
  unsigned long buflength;
  drive = packet->dd & 0xff;
  if (reset_fdc (drive) == (0))
    {
      goto bad;
    }
  bufstart = ((packet->start / 512) * 512);
  buflength = ((packet->start + packet->size + (512 -1)) / 512 * 512);
  for (bp = 0; bp < (buflength - bufstart); bp += 512)
    {
      blockno = ((UW)(bp + bufstart) / 512) * (512 / fd_data[packet->dd & 0xff]->length);
      if (512 >= (fd_data[packet->dd & 0xff]->length))
 {
   bcount = 512 / (fd_data[packet->dd & 0xff]->length);
 }
      done_length = 0;
      error = (0);
      ret = (0);
      for (i = 0; i < bcount; i++)
 {
   head = (blockno % ((fd_data[packet->dd & 0xff]->head) * (fd_data[packet->dd & 0xff]->sector))) / (fd_data[packet->dd & 0xff]->sector);
   cylinder = (blockno / ((fd_data[packet->dd & 0xff]->head) * (fd_data[packet->dd & 0xff]->sector)));
   sector = (blockno % (fd_data[packet->dd & 0xff]->sector)) + 1;
   for (try = 0; try < (fd_data[packet->dd & 0xff]->retry); try++)
     {
       ret = get_data (drive, head, cylinder, sector, (void *)&(buff[bp + (i * (fd_data[packet->dd & 0xff]->length))]));
       if (ret == (0))
  break;
     }
   if (ret == (0))
     {
       done_length += (fd_data[packet->dd & 0xff]->length);
       blockno += 1;
     }
   else
     {
       error = ret;
       goto bad;
     }
 }
    }
  bcopy (&buff[packet->start - bufstart],
  res.body.rea_res.dt,
  (done_length < packet->size) ? done_length : packet->size);
  res.body.rea_res.dd = packet->dd;
  res.body.rea_res.a_size = (done_length < packet->size) ? done_length : packet->size;
  res.body.rea_res.errcd = error;
  res.body.rea_res.errinfo = (0);
  snd_mbf (caller, sizeof (res), &res);
  return ((0));
bad:
  stop_motor (drive);
  dbg_printf("fd: read fail. head = %d cylinder = %d sector = %d\n",
      head, cylinder, sector);
  res.body.rea_res.dd = packet->dd;
  res.body.rea_res.a_size = done_length;
  res.body.rea_res.errcd = error;
  res.body.rea_res.errinfo = error;
  snd_mbf (caller, sizeof (res), &res);
  return (error);
}

variable_types: struct DDEV_REA_REQ { long dd; long start; long size; } *

variable_types: blockno long

variable_types: bcount long

variable_types: cylinder long

variable_types: head long

variable_types: sector long

variable_types: i long

variable_types: try long

variable_types:
buff
char [-1]

variable_types:
bp
unsigned long

variable_types: ret int

variable_types:
bufstart
unsigned long

variable_types:
buflength
unsigned long


original_code:
W
write_fd(ID caller, DDEV_WRI_REQ *packet)
{
  DDEV_RES res;
  W blockno;
  W bcount;
  W cylinder;
  W head;
  W sector;
  W drive;
  W i, try;
  W done_length;
  static B buff[512 * 2];
  ER ret;
  ER error;
  UW bp;
  UW bufstart;
  UW buflength;
  drive = packet->dd & 0xff;
  if (reset_fdc (drive) == (0))
    {
      goto bad;
    }
  bufstart = ((packet->start / 512) * 512);
  buflength = ((packet->start + packet->size + (512 -1)) / 512 * 512);
  for (bp = 0; bp < (buflength - bufstart); bp += 512)
    {
      blockno = ((UW)(bp + bufstart) / 512) * (512 / fd_data[packet->dd & 0xff]->length);
      if (512 >= (fd_data[packet->dd & 0xff]->length))
 {
   bcount = 512 / (fd_data[packet->dd & 0xff]->length);
 }
      done_length = 0;
      error = (0);
      ret = (0);
      for (i = 0; i < bcount; i++)
 {
   head = (blockno % ((fd_data[packet->dd & 0xff]->head) * (fd_data[packet->dd & 0xff]->sector))) / (fd_data[packet->dd & 0xff]->sector);
   cylinder = (blockno / ((fd_data[packet->dd & 0xff]->head) * (fd_data[packet->dd & 0xff]->sector)));
   sector = (blockno % (fd_data[packet->dd & 0xff]->sector)) + 1;
   for (try = 0; try < (fd_data[packet->dd & 0xff]->retry); try++)
     {
       ret = get_data (drive, head, cylinder, sector, (void *)&(buff[bp + (i * (fd_data[packet->dd & 0xff]->length))]));
       if (ret == (0))
  break;
     }
   if (ret == (0))
     {
       done_length += (fd_data[packet->dd & 0xff]->length);
       blockno += 1;
     }
   else
     {
       error = ret;
       goto bad;
     }
 }
    }
  done_length = 0;
  error = (0);
  ret = (0);
  bcopy (packet->dt, &buff[packet->start - bufstart], packet->size);
  for (bp = 0; bp < (buflength - bufstart); bp += 512)
    {
      blockno = ((bp + bufstart) / 512) * (512 / fd_data[packet->dd & 0xff]->length);
      if (512 >= (fd_data[packet->dd & 0xff]->length))
 {
   bcount = 512 / (fd_data[packet->dd & 0xff]->length);
 }
      for (i = 0; i < bcount; i++)
 {
   head = (blockno % ((fd_data[packet->dd & 0xff]->head) * (fd_data[packet->dd & 0xff]->sector))) / (fd_data[packet->dd & 0xff]->sector);
   cylinder = (blockno / ((fd_data[packet->dd & 0xff]->head) * (fd_data[packet->dd & 0xff]->sector)));
   sector = (blockno % (fd_data[packet->dd & 0xff]->sector)) + 1;
   for (try = 0; try < (fd_data[packet->dd & 0xff]->retry); try++)
     {
       ret = put_data (drive,
         head,
         cylinder,
         sector,
         (void *)(W)(buff + (bp + i * (fd_data[packet->dd & 0xff]->length))));
       if (ret == (0))
  break;
     }
   if (ret == (0))
     {
       done_length += (fd_data[packet->dd & 0xff]->length);
       blockno += 1;
     }
   else
     {
       error = ret;
       goto bad;
     }
 }
    }
  res.body.wri_res.dd = packet->dd;
  res.body.wri_res.a_size = (done_length < packet->size) ? done_length : packet->size;
  res.body.wri_res.errcd = error;
  res.body.wri_res.errinfo = (0);
  snd_mbf (caller, sizeof (res), &res);
  return ((0));
bad:
  stop_motor (drive);
  dbg_printf("fd: write fail. head = %d cylinder = %d sector = %d\n",
      head, cylinder, sector);
  res.body.wri_res.dd = packet->dd;
  res.body.wri_res.a_size = done_length;
  res.body.wri_res.errcd = error;
  res.body.wri_res.errinfo = error;
  snd_mbf (caller, sizeof (res), &res);
  return (error);
}

canonical_original_code:
long write_fd(int caller, struct DDEV_WRI_REQ *packet)
{
  struct DDEV_RES res;
  long blockno;
  long bcount;
  long cylinder;
  long head;
  long sector;
  long drive;
  long i; long try;
  long done_length;
  static char buff[-1];
  int ret;
  int error;
  unsigned long bp;
  unsigned long bufstart;
  unsigned long buflength;
  drive = packet->dd & 0xff;
  if (reset_fdc (drive) == (0))
    {
      goto bad;
    }
  bufstart = ((packet->start / 512) * 512);
  buflength = ((packet->start + packet->size + (512 -1)) / 512 * 512);
  for (bp = 0; bp < (buflength - bufstart); bp += 512)
    {
      blockno = ((UW)(bp + bufstart) / 512) * (512 / fd_data[packet->dd & 0xff]->length);
      if (512 >= (fd_data[packet->dd & 0xff]->length))
 {
   bcount = 512 / (fd_data[packet->dd & 0xff]->length);
 }
      done_length = 0;
      error = (0);
      ret = (0);
      for (i = 0; i < bcount; i++)
 {
   head = (blockno % ((fd_data[packet->dd & 0xff]->head) * (fd_data[packet->dd & 0xff]->sector))) / (fd_data[packet->dd & 0xff]->sector);
   cylinder = (blockno / ((fd_data[packet->dd & 0xff]->head) * (fd_data[packet->dd & 0xff]->sector)));
   sector = (blockno % (fd_data[packet->dd & 0xff]->sector)) + 1;
   for (try = 0; try < (fd_data[packet->dd & 0xff]->retry); try++)
     {
       ret = get_data (drive, head, cylinder, sector, (void *)&(buff[bp + (i * (fd_data[packet->dd & 0xff]->length))]));
       if (ret == (0))
  break;
     }
   if (ret == (0))
     {
       done_length += (fd_data[packet->dd & 0xff]->length);
       blockno += 1;
     }
   else
     {
       error = ret;
       goto bad;
     }
 }
    }
  done_length = 0;
  error = (0);
  ret = (0);
  bcopy (packet->dt, &buff[packet->start - bufstart], packet->size);
  for (bp = 0; bp < (buflength - bufstart); bp += 512)
    {
      blockno = ((bp + bufstart) / 512) * (512 / fd_data[packet->dd & 0xff]->length);
      if (512 >= (fd_data[packet->dd & 0xff]->length))
 {
   bcount = 512 / (fd_data[packet->dd & 0xff]->length);
 }
      for (i = 0; i < bcount; i++)
 {
   head = (blockno % ((fd_data[packet->dd & 0xff]->head) * (fd_data[packet->dd & 0xff]->sector))) / (fd_data[packet->dd & 0xff]->sector);
   cylinder = (blockno / ((fd_data[packet->dd & 0xff]->head) * (fd_data[packet->dd & 0xff]->sector)));
   sector = (blockno % (fd_data[packet->dd & 0xff]->sector)) + 1;
   for (try = 0; try < (fd_data[packet->dd & 0xff]->retry); try++)
     {
       ret = put_data (drive,
         head,
         cylinder,
         sector,
         (void *)(W)(buff + (bp + i * (fd_data[packet->dd & 0xff]->length))));
       if (ret == (0))
  break;
     }
   if (ret == (0))
     {
       done_length += (fd_data[packet->dd & 0xff]->length);
       blockno += 1;
     }
   else
     {
       error = ret;
       goto bad;
     }
 }
    }
  res.body.wri_res.dd = packet->dd;
  res.body.wri_res.a_size = (done_length < packet->size) ? done_length : packet->size;
  res.body.wri_res.errcd = error;
  res.body.wri_res.errinfo = (0);
  snd_mbf (caller, sizeof (res), &res);
  return ((0));
bad:
  stop_motor (drive);
  dbg_printf("fd: write fail. head = %d cylinder = %d sector = %d\n",
      head, cylinder, sector);
  res.body.wri_res.dd = packet->dd;
  res.body.wri_res.a_size = done_length;
  res.body.wri_res.errcd = error;
  res.body.wri_res.errinfo = error;
  snd_mbf (caller, sizeof (res), &res);
  return (error);
}

variable_types: caller int

variable_types: struct DDEV_WRI_REQ { long dd; long start; long size; unsigned char dt[1024]; } *

variable_types: struct DDEV_RES { struct SVC_REQ { int mbfid; long msgtyp; int tskid; long len; unsigned long arg[]; } header; union { struct DDEV_OPN_RES { long dd; long errcd; long errinfo; } opn_res; struct DDEV_CLS_RES { long dd; long errcd; long errinfo; } cls_res; struct DDEV_REA_RES { long dd; long errcd; long errinfo; long split; long a_size; unsigned char dt[1024]; } rea_res; struct DDEV_WRI_RES { long dd; long errcd; long errinfo; long a_size; } wri_res; struct DDEV_CTL_RES { long dd; long errcd; long errinfo; long res[]; } ctl_res; } body; }

variable_types: drive long

variable_types: error int


doit

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

result = *((_QWORD *)a1 + 1);
switch ( result )
{
case 0LL:
result = open_fd(*a1, (_QWORD *)a1 + 4);
break;
case 1LL:
result = close_fd(*a1, (_QWORD *)a1 + 4);
break;
case 2LL:
result = read_fd(*a1, (__int64 *)a1 + 4);
break;
case 3LL:
result = write_fd(*a1, (__int64 *)a1 + 4);
break;
case 4LL:
result = control_fd(*a1, (__int64)(a1 + 8));
break;
default:
return result;
}
return result;
}

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

result = *((_QWORD *)a1 + 1);
switch ( result )
{
case 0LL:
result = func2(*a1, (_QWORD *)a1 + 4);
break;
case 1LL:
result = func3(*a1, (_QWORD *)a1 + 4);
break;
case 2LL:
result = func4(*a1, (__int64 *)a1 + 4);
break;
case 3LL:
result = func5(*a1, (__int64 *)a1 + 4);
break;
case 4LL:
result = func6(*a1, (__int64)(a1 + 8));
break;
default:
return result;
}
return result;
}

original_code:
static void
doit (DDEV_REQ *packet)
{
  switch (packet->header.msgtyp)
    {
    case DEV_OPN:
      open_fd (packet->header.mbfid, &(packet->body.opn_req));
      break;
    case DEV_CLS:
      close_fd (packet->header.mbfid, &(packet->body.cls_req));
      break;
    case DEV_REA:
      read_fd (packet->header.mbfid, &(packet->body.rea_req));
      break;
    case DEV_WRI:
      write_fd (packet->header.mbfid, &(packet->body.wri_req));
      break;
    case DEV_CTL:
      control_fd (packet->header.mbfid, &(packet->body.ctl_req));
      break;
    }
}

canonical_original_code:
static void doit(struct DDEV_REQ *packet)
{
  switch (packet->header.msgtyp)
    {
    case DEV_OPN:
      open_fd (packet->header.mbfid, &(packet->body.opn_req));
      break;
    case DEV_CLS:
      close_fd (packet->header.mbfid, &(packet->body.cls_req));
      break;
    case DEV_REA:
      read_fd (packet->header.mbfid, &(packet->body.rea_req));
      break;
    case DEV_WRI:
      write_fd (packet->header.mbfid, &(packet->body.wri_req));
      break;
    case DEV_CTL:
      control_fd (packet->header.mbfid, &(packet->body.ctl_req));
      break;
    }
}

variable_types: struct DDEV_REQ { struct SVC_REQ { int mbfid; long msgtyp; int tskid; long len; unsigned long arg[]; } header; union { struct DDEV_OPN_REQ { long dd; } opn_req; struct DDEV_CLS_REQ { long dd; long eject; } cls_req; struct DDEV_REA_REQ { long dd; long start; long size; } rea_req; struct DDEV_WRI_REQ { long dd; long start; long size; unsigned char dt[1024]; } wri_req; struct DDEV_CTL_REQ { long dd; unsigned long cmd; long len; unsigned char param[]; } ctl_req; struct DDEV_PRD_REQ { long dd; char *buf; long start; long length; } prd_req; struct DDEV_RLY_REQ { long dd; long start; long size; unsigned char dt[1024]; } rly_req; } body; } *

user_defined_types: struct DDEV_REQ { struct SVC_REQ header; union { struct DDEV_OPN_REQ opn_req; struct DDEV_CLS_REQ cls_req; struct DDEV_REA_REQ rea_req; struct DDEV_WRI_REQ wri_req; struct DDEV_CTL_REQ ctl_req; struct DDEV_PRD_REQ prd_req; struct DDEV_RLY_REQ rly_req; } body; }


decompiled_code:
void __noreturn main_loop()
{
char v0[8]; // [rsp+8h] [rbp-450h] BYREF
unsigned int v1[274]; // [rsp+10h] [rbp-448h] BYREF

while ( 1 )
{
get_req((unsigned int)recvport, v1, v0);
if ( sys_errno )
{
dbg_printf("fd: get_req() Unknown error(error = %d)\n", sys_errno);
dbg_printf("FD driver is halt.\n");
slp_tsk();
}
else
{
doit(v1);
}
}
}

canonical_decompiled_code:
void __noreturn func8()
{
char v0[8]; // [rsp+8h] [rbp-450h] BYREF
unsigned int v1[274]; // [rsp+10h] [rbp-448h] BYREF

while ( 1 )
{
get_req((unsigned int)recvport, v1, v0);
if ( sys_errno )
{
dbg_printf("fd: get_req() Unknown error(error = %d)\n", sys_errno);
dbg_printf("FD driver is halt.\n");
slp_tsk();
}
else
{
func7(v1);
}
}
}

original_code:
static void
main_loop ()
{
  DDEV_REQ req;
  extern ER sys_errno;
  UW rsize;
  for (;;)
    {
      get_req (recvport, &req, &rsize);
      switch (sys_errno)
 {
 case (0):
   doit (&req);
   break;
 default:
   dbg_printf ("fd: get_req() Unknown error(error = %d)\n", sys_errno);
   dbg_printf ("FD driver is halt.\n");
   slp_tsk ();
   break;
 }
    }
}

canonical_original_code:
static void main_loop()
{
  struct DDEV_REQ req;
  extern int sys_errno;
  unsigned long rsize;
  for (;;)
    {
      get_req (recvport, &req, &rsize);
      switch (sys_errno)
 {
 case (0):
   doit (&req);
   break;
 default:
   dbg_printf ("fd: get_req() Unknown error(error = %d)\n", sys_errno);
   dbg_printf ("FD driver is halt.\n");
   slp_tsk ();
   break;
 }
    }
}

variable_types: struct DDEV_REQ { struct SVC_REQ { int mbfid; long msgtyp; int tskid; long len; unsigned long arg[]; } header; union { struct DDEV_OPN_REQ { long dd; } opn_req; struct DDEV_CLS_REQ { long dd; long eject; } cls_req; struct DDEV_REA_REQ { long dd; long start; long size; } rea_req; struct DDEV_WRI_REQ { long dd; long start; long size; unsigned char dt[1024]; } wri_req; struct DDEV_CTL_REQ { long dd; unsigned long cmd; long len; unsigned char param[]; } ctl_req; struct DDEV_PRD_REQ { long dd; char *buf; long start; long length; } prd_req; struct DDEV_RLY_REQ { long dd; long start; long size; unsigned char dt[1024]; } rly_req; } body; }

variable_types:
rsize
unsigned long


decompiled_code:
__int64 fork_entry()
{
ena_int();
return 0LL;
}

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

original_code:
int fork_entry()
{
  ena_int();
  return(0);
}


decompiled_code:
__int64 __fastcall psys_fork(int *a1)
{
__int64 result; // rax
int v2; // ebp
__int64 v3[3]; // [rsp+0h] [rbp-118h] BYREF
int v4; // [rsp+18h] [rbp-100h]
int v5; // [rsp+1Ch] [rbp-FCh]
__int64 v6; // [rsp+20h] [rbp-F8h]
__int64 v7; // [rsp+28h] [rbp-F0h]
unsigned int v8; // [rsp+38h] [rbp-E0h] BYREF
unsigned int v9; // [rsp+3Ch] [rbp-DCh] BYREF
char v10[24]; // [rsp+40h] [rbp-D8h] BYREF
__int64 v11; // [rsp+58h] [rbp-C0h]
unsigned int v12; // [rsp+60h] [rbp-B8h]
char v13[32]; // [rsp+80h] [rbp-98h] BYREF
unsigned int v14; // [rsp+A0h] [rbp-78h]
int v15; // [rsp+A4h] [rbp-74h]

v3[0] = 0LL;
v3[1] = 1LL;
v6 = 0LL;
v7 = 0LL;
v3[2] = (__int64)fork_entry;
v4 = 10;
v5 = 12288;
result = vcre_tsk(v3, &v9);
if ( !(_DWORD)result )
{
v14 = v9;
v15 = 0;
v2 = make_connection(11LL, v13, v10);
if ( v2 )
{
del_tsk(v9);
MEMORY[0x7FFF0028] = v2;
result = 0xFFFFFFFFLL;
}
else if ( v11 )
{
del_tsk(v9);
MEMORY[0x7FFF0028] = v11;
result = 0xFFFFFFFFLL;
}
else
{
get_tid(&v8);
vcpy_stk(v8, *a1, a1[1], v9);
sta_tsk(v9, 0LL);
result = v12;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int *a1)
{
__int64 result; // rax
int v2; // ebp
__int64 v3[3]; // [rsp+0h] [rbp-118h] BYREF
int v4; // [rsp+18h] [rbp-100h]
int v5; // [rsp+1Ch] [rbp-FCh]
__int64 v6; // [rsp+20h] [rbp-F8h]
__int64 v7; // [rsp+28h] [rbp-F0h]
unsigned int v8; // [rsp+38h] [rbp-E0h] BYREF
unsigned int v9; // [rsp+3Ch] [rbp-DCh] BYREF
char v10[24]; // [rsp+40h] [rbp-D8h] BYREF
__int64 v11; // [rsp+58h] [rbp-C0h]
unsigned int v12; // [rsp+60h] [rbp-B8h]
char v13[32]; // [rsp+80h] [rbp-98h] BYREF
unsigned int v14; // [rsp+A0h] [rbp-78h]
int v15; // [rsp+A4h] [rbp-74h]

v3[0] = 0LL;
v3[1] = 1LL;
v6 = 0LL;
v7 = 0LL;
v3[2] = (__int64)fork_entry;
v4 = 10;
v5 = 12288;
result = vcre_tsk(v3, &v9);
if ( !(_DWORD)result )
{
v14 = v9;
v15 = 0;
v2 = make_connection(11LL, v13, v10);
if ( v2 )
{
del_tsk(v9);
MEMORY[0x7FFF0028] = v2;
result = 0xFFFFFFFFLL;
}
else if ( v11 )
{
del_tsk(v9);
MEMORY[0x7FFF0028] = v11;
result = 0xFFFFFFFFLL;
}
else
{
get_tid(&v8);
vcpy_stk(v8, *a1, a1[1], v9);
sta_tsk(v9, 0LL);
result = v12;
}
}
return result;
}

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

canonical_original_code:
unsigned short psys_fork(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

variable_types:
argp
void *

variable_types:
args
struct a {  } *

return_type: unsigned short


decompiled_code:
int f_cat()
{
int result; // eax
int v1; // eax
int v2; // er14
int i; // er13
int v4; // eax
int v5; // er12
__int64 v6; // rbp
__int64 j; // rbx
char v8[152]; // [rsp+0h] [rbp-98h] BYREF

result = pop_string(v8);
if ( !error_no )
{
v1 = open(v8, 0, 0LL);
v2 = v1;
if ( v1 < 0 )
{
result = printf("cannot open file. [%d](%s)\n", MEMORY[0x7FFF0028], v8);
}
else if ( stat((const char *)(unsigned int)v1, &st_2) )
{
printf("cannot stat for file. [%d]\n", MEMORY[0x7FFF0028]);
result = close(v2);
}
else
{
printf("file size is = %d\n", qword_E38);
for ( i = qword_E38; i > 0; i -= v5 )
{
v4 = read(v2, buf_1, 0x200uLL);
v5 = v4;
if ( v4 <= 0 )
break;
v6 = (unsigned int)v4;
for ( j = 0LL; j != v6; ++j )
putc(buf_1[j], (FILE *)(unsigned int)((_DWORD)&_file_table__ + 1056));
}
printf("\nread done\n");
result = close(v2);
}
}
return result;
}

canonical_decompiled_code:
int func0()
{
int result; // eax
int v1; // eax
int v2; // er14
int i; // er13
int v4; // eax
int v5; // er12
__int64 v6; // rbp
__int64 j; // rbx
char v8[152]; // [rsp+0h] [rbp-98h] BYREF

result = pop_string(v8);
if ( !error_no )
{
v1 = open(v8, 0, 0LL);
v2 = v1;
if ( v1 < 0 )
{
result = printf("cannot open file. [%d](%s)\n", MEMORY[0x7FFF0028], v8);
}
else if ( stat((const char *)(unsigned int)v1, &st_2) )
{
printf("cannot stat for file. [%d]\n", MEMORY[0x7FFF0028]);
result = close(v2);
}
else
{
printf("file size is = %d\n", qword_E38);
for ( i = qword_E38; i > 0; i -= v5 )
{
v4 = read(v2, buf_1, 0x200uLL);
v5 = v4;
if ( v4 <= 0 )
break;
v6 = (unsigned int)v4;
for ( j = 0LL; j != v6; ++j )
putc(buf_1[j], (FILE *)(unsigned int)((_DWORD)&_file_table__ + 1056));
}
printf("\nread done\n");
result = close(v2);
}
}
return result;
}

original_code:
void f_cat ()
{
  int fd;
  static struct stat st;
  static char buf[512];
  int length, rlength;
  int i;
  int offset = 0;
  char file[100];
  pop_string(file); if (error_no != 0) return;;
  fd = open(file, 0, 0);
  if (fd < 0)
    {
      printf ("cannot open file. [%d](%s)\n", ((((struct lowlib_data *)(0x7fff0000)))->errno), file);
      return;
    }
  if (stat(fd, &st))
    {
      printf ("cannot stat for file. [%d]\n", ((((struct lowlib_data *)(0x7fff0000)))->errno));
      close(fd);
      return;
    }
  if (st.st_size < 0)
    {
      printf ("file size is 0.\n");
      close(fd);
      return;
    }
  printf ("file size is = %d\n", st.st_size);
  for (rlength = st.st_size; rlength > 0; rlength -= length)
    {
      if ((length = read (fd, buf, sizeof (buf))) <= 0)
 {
   break;
 }
      for (i = 0; i < length; i++)
 {
   putc (buf[i], (&__file_table__[1]));
 }
    }
  printf ("\nread done\n");
  close (fd);
}

canonical_original_code:
void f_cat()
{
  int fd;
  static struct stat st;
  static char buf[512];
  int length; int rlength;
  int i;
  int offset = 0;
  char file[100];
  pop_string(file); if (error_no != 0) return;;
  fd = open(file, 0, 0);
  if (fd < 0)
    {
      printf ("cannot open file. [%d](%s)\n", ((((struct lowlib_data *)(0x7fff0000)))->errno), file);
      return;
    }
  if (stat(fd, &st))
    {
      printf ("cannot stat for file. [%d]\n", ((((struct lowlib_data *)(0x7fff0000)))->errno));
      close(fd);
      return;
    }
  if (st.st_size < 0)
    {
      printf ("file size is 0.\n");
      close(fd);
      return;
    }
  printf ("file size is = %d\n", st.st_size);
  for (rlength = st.st_size; rlength > 0; rlength -= length)
    {
      if ((length = read (fd, buf, sizeof (buf))) <= 0)
 {
   break;
 }
      for (i = 0; i < length; i++)
 {
   putc (buf[i], (&__file_table__[1]));
 }
    }
  printf ("\nread done\n");
  close (fd);
}

variable_types: fd int

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_mode; unsigned long st_nlink; unsigned long st_uid; unsigned long st_gid; unsigned long st_rdev; unsigned long st_size; unsigned long st_blksize; unsigned long st_blocks; unsigned long st_atime; unsigned long st_mtime; unsigned long st_ctime; }

variable_types:
buf
char [512]

variable_types: length int

variable_types: rlength int

variable_types: i int

variable_types: offset int

variable_types:
file
char [100]

user_defined_types: struct lowlib_data { int recv_port; int my_pid; int main_task; int signal_task; int fifo_task; int alarm_task; void (*start_func)(); int efile; long errno; }


decompiled_code:
__int64 f_open()
{
__int64 result; // rax
int v1; // ebx
int v2; // ebx
char v3[264]; // [rsp+0h] [rbp-108h] BYREF

result = pop();
if ( !error_no )
{
v1 = result;
result = pop_string(v3);
if ( !error_no )
{
v2 = open(v3, v1, 438LL);
if ( v2 < 0 )
printf("open failed. [%d](%s)\n", MEMORY[0x7FFF0028], v3);
result = push((unsigned int)v2);
}
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
int v1; // ebx
int v2; // ebx
char v3[264]; // [rsp+0h] [rbp-108h] BYREF

result = pop();
if ( !error_no )
{
v1 = result;
result = pop_string(v3);
if ( !error_no )
{
v2 = open(v3, v1, 438LL);
if ( v2 < 0 )
printf("open failed. [%d](%s)\n", MEMORY[0x7FFF0028], v3);
result = push((unsigned int)v2);
}
}
return result;
}

original_code:
void f_open(void)
{
  int fd;
  char fname[256];
  int oflag;
  oflag = pop(); if (error_no != 0) return;;
  pop_string(fname); if (error_no != 0) return;;
  fd = open (fname, oflag, 0666);
  if (fd < 0) {
    printf("open failed. [%d](%s)\n", ((((struct lowlib_data *)(0x7fff0000)))->errno), fname);
  }
  push(fd); if (error_no != 0) return;;
}

canonical_original_code:
void f_open()
{
  int fd;
  char fname[256];
  int oflag;
  oflag = pop(); if (error_no != 0) return;;
  pop_string(fname); if (error_no != 0) return;;
  fd = open (fname, oflag, 0666);
  if (fd < 0) {
    printf("open failed. [%d](%s)\n", ((((struct lowlib_data *)(0x7fff0000)))->errno), fname);
  }
  push(fd); if (error_no != 0) return;;
}

variable_types:
fname
char [256]

variable_types: oflag int


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

result = pop();
if ( !error_no )
{
if ( result > 2 )
result = close(result);
else
result = printf("Illegal file descriptor %d\n", (unsigned int)result);
}
return result;
}

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

result = pop();
if ( !error_no )
{
if ( result > 2 )
result = close(result);
else
result = printf("Illegal file descriptor %d\n", (unsigned int)result);
}
return result;
}

original_code:
void f_close(void)
{
  int fd;
  fd = pop(); if (error_no != 0) return;;
  if (fd < 3) {
    printf("Illegal file descriptor %d\n", fd);
  }
  else {
    close(fd);
  }
}

canonical_original_code:
void f_close()
{
  int fd;
  fd = pop(); if (error_no != 0) return;;
  if (fd < 3) {
    printf("Illegal file descriptor %d\n", fd);
  }
  else {
    close(fd);
  }
}


decompiled_code:
int f_write()
{
int result; // eax
int v1; // ebx
size_t v2; // rax
char v3[264]; // [rsp+0h] [rbp-108h] BYREF

result = pop();
if ( !error_no )
{
v1 = result;
result = pop_string(v3);
if ( !error_no )
{
v2 = strlen(v3);
result = write(v1, v3, v2);
if ( result < 0 )
result = printf("write failed. [%d]\n", MEMORY[0x7FFF0028]);
}
}
return result;
}

canonical_decompiled_code:
int func4()
{
int result; // eax
int v1; // ebx
size_t v2; // rax
char v3[264]; // [rsp+0h] [rbp-108h] BYREF

result = pop();
if ( !error_no )
{
v1 = result;
result = pop_string(v3);
if ( !error_no )
{
v2 = strlen(v3);
result = write(v1, v3, v2);
if ( result < 0 )
result = printf("write failed. [%d]\n", MEMORY[0x7FFF0028]);
}
}
return result;
}

original_code:
void f_write(void)
{
  char str[256];
  int fd, res;
  fd = pop(); if (error_no != 0) return;;
  pop_string(str); if (error_no != 0) return;;
  res = write (fd, str, strlen(str));
  if (res < 0) {
    printf("write failed. [%d]\n", ((((struct lowlib_data *)(0x7fff0000)))->errno));
  }
}

canonical_original_code:
void f_write()
{
  char str[256];
  int fd; int res;
  fd = pop(); if (error_no != 0) return;;
  pop_string(str); if (error_no != 0) return;;
  res = write (fd, str, strlen(str));
  if (res < 0) {
    printf("write failed. [%d]\n", ((((struct lowlib_data *)(0x7fff0000)))->errno));
  }
}

variable_types:
str
char [256]

variable_types: res int


decompiled_code:
int f_unlink()
{
int result; // eax
char v1[264]; // [rsp+0h] [rbp-108h] BYREF

result = pop_string(v1);
if ( !error_no )
{
result = unlink(v1);
if ( result < 0 )
result = printf("unlink failed. [%d](%s)\n", MEMORY[0x7FFF0028], v1);
}
return result;
}

canonical_decompiled_code:
int func5()
{
int result; // eax
char v1[264]; // [rsp+0h] [rbp-108h] BYREF

result = pop_string(v1);
if ( !error_no )
{
result = unlink(v1);
if ( result < 0 )
result = printf("unlink failed. [%d](%s)\n", MEMORY[0x7FFF0028], v1);
}
return result;
}

original_code:
void f_unlink(void)
{
  int result;
  char str[256];
  pop_string(str); if (error_no != 0) return;;
  result = unlink(str);
  if (result < 0) {
    printf("unlink failed. [%d](%s)\n", ((((struct lowlib_data *)(0x7fff0000)))->errno), str);
  }
}

canonical_original_code:
void f_unlink()
{
  int result;
  char str[256];
  pop_string(str); if (error_no != 0) return;;
  result = unlink(str);
  if (result < 0) {
    printf("unlink failed. [%d](%s)\n", ((((struct lowlib_data *)(0x7fff0000)))->errno), str);
  }
}

variable_types: result int


decompiled_code:
int f_chdir()
{
int result; // eax
char v1[264]; // [rsp+0h] [rbp-108h] BYREF

result = pop_string(v1);
if ( !error_no )
{
result = chdir(v1);
if ( result < 0 )
result = printf("chdir failed. [%d](%s)\n", MEMORY[0x7FFF0028], v1);
}
return result;
}

canonical_decompiled_code:
int func8()
{
int result; // eax
char v1[264]; // [rsp+0h] [rbp-108h] BYREF

result = pop_string(v1);
if ( !error_no )
{
result = chdir(v1);
if ( result < 0 )
result = printf("chdir failed. [%d](%s)\n", MEMORY[0x7FFF0028], v1);
}
return result;
}

original_code:
void f_chdir(void)
{
  int result;
  char str[256];
  pop_string(str); if (error_no != 0) return;;
  result = chdir(str);
  if (result < 0) {
    printf("chdir failed. [%d](%s)\n", ((((struct lowlib_data *)(0x7fff0000)))->errno), str);
  }
}

canonical_original_code:
void f_chdir()
{
  int result;
  char str[256];
  pop_string(str); if (error_no != 0) return;;
  result = chdir(str);
  if (result < 0) {
    printf("chdir failed. [%d](%s)\n", ((((struct lowlib_data *)(0x7fff0000)))->errno), str);
  }
}


decompiled_code:
int f_exec()
{
int result; // eax
unsigned int v1; // eax
unsigned int v2; // eax
int stat_loc; // [rsp+Ch] [rbp-10Ch] BYREF
char path[264]; // [rsp+10h] [rbp-108h] BYREF

result = pop_string(path);
if ( !error_no )
{
v1 = fork();
stat_loc = v1;
if ( !v1 )
{
execve(path, 0LL, 0LL);
exit(1);
}
if ( v1 == -1 )
{
result = printf("fork error\n");
}
else
{
printf("waiting pid=%d ...\n", v1);
v2 = waitpid(-1, &stat_loc, 0);
result = printf("child process exited pid=%d stat=%d\n", v2, (unsigned int)stat_loc);
}
}
return result;
}

canonical_decompiled_code:
int func9()
{
int result; // eax
unsigned int v1; // eax
unsigned int v2; // eax
int stat_loc; // [rsp+Ch] [rbp-10Ch] BYREF
char path[264]; // [rsp+10h] [rbp-108h] BYREF

result = pop_string(path);
if ( !error_no )
{
v1 = fork();
stat_loc = v1;
if ( !v1 )
{
execve(path, 0LL, 0LL);
exit(1);
}
if ( v1 == -1 )
{
result = printf("fork error\n");
}
else
{
printf("waiting pid=%d ...\n", v1);
v2 = waitpid(-1, &stat_loc, 0);
result = printf("child process exited pid=%d stat=%d\n", v2, (unsigned int)stat_loc);
}
}
return result;
}

original_code:
void f_exec(void)
{
  char str[256];
  int pid, res;
  pop_string(str); if (error_no != 0) return;;
  if ((res = fork()) == 0) {
    execve(str, (0), (0));
    _exit(1);
  }
  else if (res == -1) {
    printf("fork error\n");
  }
  else {
    printf("waiting pid=%d ...\n", res);
    pid = waitpid(-1, &res, 0);
    printf("child process exited pid=%d stat=%d\n", pid, res);
  }
}

canonical_original_code:
void f_exec()
{
  char str[256];
  int pid; int res;
  pop_string(str); if (error_no != 0) return;;
  if ((res = fork()) == 0) {
    execve(str, (0), (0));
    _exit(1);
  }
  else if (res == -1) {
    printf("fork error\n");
  }
  else {
    printf("waiting pid=%d ...\n", res);
    pid = waitpid(-1, &res, 0);
    printf("child process exited pid=%d stat=%d\n", pid, res);
  }
}

variable_types: pid int


decompiled_code:
__int64 f_multi()
{
__pid_t v0; // eax
int v1; // ebx
__pid_t v2; // eax
int v4; // eax
int v5; // ebx
char *const *__attribute__((__org_arrdim(0,0))) v6; // rdx
int v7; // eax
int v8; // ebx
char *const *__attribute__((__org_arrdim(0,0))) v9; // rdx
int stat_loc[3]; // [rsp+Ch] [rbp-Ch] BYREF

f_gm();
winmod(1LL, 1LL);
v0 = fork();
stat_loc[0] = v0;
if ( !v0 )
{
close(0);
close(1);
close(2);
v4 = open("/dev/win1", 2, 438LL);
v5 = v4;
if ( v4 >= 0 )
{
dup(v4);
dup(v5);
execve("/frtm", 0LL, v6);
exit(1);
}
exit(-1);
}
v1 = 1;
if ( v0 == -1 )
{
printf("fork error\n");
v1 = 0;
}
v2 = fork();
stat_loc[0] = v2;
if ( !v2 )
{
close(0);
close(1);
close(2);
v7 = open("/dev/win2", 2, 438LL);
v8 = v7;
if ( v7 >= 0 )
{
dup(v7);
dup(v8);
execve("/frtm", 0LL, v9);
exit(1);
}
exit(-1);
}
if ( v2 == -1 )
{
printf("fork error\n");
if ( v1 <= 0 )
return f_tm();
goto LABEL_7;
}
waitpid(-1, stat_loc, 0);
if ( v1 > 0 )
LABEL_7:
waitpid(-1, stat_loc, 0);
return f_tm();
}

canonical_decompiled_code:
__int64 func10()
{
__pid_t v0; // eax
int v1; // ebx
__pid_t v2; // eax
int v4; // eax
int v5; // ebx
char *const *__attribute__((__org_arrdim(0,0))) v6; // rdx
int v7; // eax
int v8; // ebx
char *const *__attribute__((__org_arrdim(0,0))) v9; // rdx
int stat_loc[3]; // [rsp+Ch] [rbp-Ch] BYREF

f_gm();
winmod(1LL, 1LL);
v0 = fork();
stat_loc[0] = v0;
if ( !v0 )
{
close(0);
close(1);
close(2);
v4 = open("/dev/win1", 2, 438LL);
v5 = v4;
if ( v4 >= 0 )
{
dup(v4);
dup(v5);
execve("/frtm", 0LL, v6);
exit(1);
}
exit(-1);
}
v1 = 1;
if ( v0 == -1 )
{
printf("fork error\n");
v1 = 0;
}
v2 = fork();
stat_loc[0] = v2;
if ( !v2 )
{
close(0);
close(1);
close(2);
v7 = open("/dev/win2", 2, 438LL);
v8 = v7;
if ( v7 >= 0 )
{
dup(v7);
dup(v8);
execve("/frtm", 0LL, v9);
exit(1);
}
exit(-1);
}
if ( v2 == -1 )
{
printf("fork error\n");
if ( v1 <= 0 )
return f_tm();
goto LABEL_7;
}
waitpid(-1, stat_loc, 0);
if ( v1 > 0 )
LABEL_7:
waitpid(-1, stat_loc, 0);
return f_tm();
}

original_code:
void f_multi(void)
{
  int fd, i, cnt = 0, res;
  f_gm();
  winmod(1, 1);
  if ((res = fork()) == 0) {
    close(0);
    close(1);
    close(2);
    fd = open("/dev/win1", 2, 0666);
    if (fd < 0) _exit(-1);
    dup(fd);
    dup(fd);
    execve("/frtm", (0));
    _exit(1);
  }
  else if (res == -1) {
    printf("fork error\n");
  }
  else {
    ++cnt;
  }
  if ((res = fork()) == 0) {
    close(0);
    close(1);
    close(2);
    fd = open("/dev/win2", 2, 0666);
    if (fd < 0) _exit(-1);
    dup(fd);
    dup(fd);
    execve("/frtm", (0));
    _exit(1);
  }
  else if (res == -1) {
    printf("fork error\n");
  }
  else {
    ++cnt;
  }
  for(i = 0; i < cnt; ++i) {
    waitpid(-1, &res, 0);
  }
  f_tm();
}

canonical_original_code:
void f_multi()
{
  int fd; int i; int cnt = 0; int res;
  f_gm();
  winmod(1, 1);
  if ((res = fork()) == 0) {
    close(0);
    close(1);
    close(2);
    fd = open("/dev/win1", 2, 0666);
    if (fd < 0) _exit(-1);
    dup(fd);
    dup(fd);
    execve("/frtm", (0));
    _exit(1);
  }
  else if (res == -1) {
    printf("fork error\n");
  }
  else {
    ++cnt;
  }
  if ((res = fork()) == 0) {
    close(0);
    close(1);
    close(2);
    fd = open("/dev/win2", 2, 0666);
    if (fd < 0) _exit(-1);
    dup(fd);
    dup(fd);
    execve("/frtm", (0));
    _exit(1);
  }
  else if (res == -1) {
    printf("fork error\n");
  }
  else {
    ++cnt;
  }
  for(i = 0; i < cnt; ++i) {
    waitpid(-1, &res, 0);
  }
  f_tm();
}

variable_types: cnt int


decompiled_code:
int f_single()
{
int v0; // eax
int result; // eax
int v2; // eax
int v3; // ebx
char *const *__attribute__((__org_arrdim(0,0))) v4; // rdx
int stat_loc[3]; // [rsp+Ch] [rbp-Ch] BYREF

v0 = fork();
stat_loc[0] = v0;
if ( !v0 )
{
close(0);
close(1);
close(2);
v2 = open("/dev/console", 2, 438LL);
v3 = v2;
if ( v2 >= 0 )
{
dup(v2);
dup(v3);
execve("/frtm", 0LL, v4);
exit(1);
}
exit(-1);
}
if ( v0 == -1 )
result = printf("fork error\n");
else
result = waitpid(-1, stat_loc, 0);
return result;
}

canonical_decompiled_code:
int func11()
{
int v0; // eax
int result; // eax
int v2; // eax
int v3; // ebx
char *const *__attribute__((__org_arrdim(0,0))) v4; // rdx
int stat_loc[3]; // [rsp+Ch] [rbp-Ch] BYREF

v0 = fork();
stat_loc[0] = v0;
if ( !v0 )
{
close(0);
close(1);
close(2);
v2 = open("/dev/console", 2, 438LL);
v3 = v2;
if ( v2 >= 0 )
{
dup(v2);
dup(v3);
execve("/frtm", 0LL, v4);
exit(1);
}
exit(-1);
}
if ( v0 == -1 )
result = printf("fork error\n");
else
result = waitpid(-1, stat_loc, 0);
return result;
}

original_code:
void f_single(void)
{
  int fd, i, cnt = 0, res;
  if ((res = fork()) == 0) {
    close(0);
    close(1);
    close(2);
    fd = open("/dev/console", 2, 0666);
    if (fd < 0) _exit(-1);
    dup(fd);
    dup(fd);
    execve("/frtm", (0));
    _exit(1);
  }
  else if (res == -1) {
    printf("fork error\n");
  }
  else {
    ++cnt;
  }
  for(i = 0; i < cnt; ++i) {
    waitpid(-1, &res, 0);
  }
}

canonical_original_code:
void f_single()
{
  int fd; int i; int cnt = 0; int res;
  if ((res = fork()) == 0) {
    close(0);
    close(1);
    close(2);
    fd = open("/dev/console", 2, 0666);
    if (fd < 0) _exit(-1);
    dup(fd);
    dup(fd);
    execve("/frtm", (0));
    _exit(1);
  }
  else if (res == -1) {
    printf("fork error\n");
  }
  else {
    ++cnt;
  }
  for(i = 0; i < cnt; ++i) {
    waitpid(-1, &res, 0);
  }
}


bclose

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

result = close(bfd);
bfd = -1;
return result;
}

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

result = close(bfd);
bfd = -1;
return result;
}

original_code:
void bclose(void)
{
  close(bfd);
  bfd = -1;
}

canonical_original_code:
void bclose()
{
  close(bfd);
  bfd = -1;
}


bopen

decompiled_code:
int __fastcall bopen(char *file)
{
int result; // eax

if ( bfd > 0 )
bclose();
result = open(file, 2, 438LL);
bfd = result;
bsize = 0;
boffset = 0;
return result;
}

canonical_decompiled_code:
int __fastcall func13(char *file)
{
int result; // eax

if ( bfd > 0 )
func12();
result = open(file, 2, 438LL);
bfd = result;
bsize = 0;
boffset = 0;
return result;
}

original_code:
int bopen(char *name)
{
  if (bfd > 0) bclose();
  bfd = open (name, 0x02, 0666);
  bsize = 0;
  boffset = 0;
  return(bfd);
}

variable_types:
name
char *


bget

decompiled_code:
__int64 bget()
{
int v0; // eax

if ( bsize )
{
if ( boffset != 512 )
{
if ( bsize != boffset )
goto LABEL_5;
return 0xFFFFFFFFLL;
}
}
else if ( boffset && boffset != 512 )
{
goto LABEL_5;
}
bsize = read(bfd, buf_0, 0x200uLL);
boffset = 0;
if ( bsize )
{
LABEL_5:
v0 = boffset++;
return (unsigned int)buf_0[v0];
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func14()
{
int v0; // eax

if ( bsize )
{
if ( boffset != 512 )
{
if ( bsize != boffset )
goto LABEL_5;
return 0xFFFFFFFFLL;
}
}
else if ( boffset && boffset != 512 )
{
goto LABEL_5;
}
bsize = read(bfd, buf_0, 0x200uLL);
boffset = 0;
if ( bsize )
{
LABEL_5:
v0 = boffset++;
return (unsigned int)buf_0[v0];
}
return 0xFFFFFFFFLL;
}

original_code:
int bget()
{
  static char buf[512];
  if ((bsize == 0 && boffset == 0) ||
      (boffset == 512)) {
    bsize = read(bfd, buf, 512);
    boffset = 0;
    if (bsize == 0) return(-1);
  }
  else if (boffset == bsize) return(-1);
  return(buf[boffset++]);
}


decompiled_code:
int f_load()
{
int result; // eax
int v1; // ebp
int v2; // ebx
int v3; // eax
char v4[280]; // [rsp+0h] [rbp-118h] BYREF

result = pop_string(v4);
v1 = error_no;
if ( error_no )
return result;
v2 = error_no;
if ( bopen(v4) < 0 )
return printf("open failed. %s\n", v4);
while ( 1 )
{
v3 = bget();
if ( v3 == -1 )
break;
if ( v3 == 13 || v3 == 10 )
goto LABEL_10;
v4[v2] = v3;
if ( v2 == 254 )
{
++v2;
LABEL_10:
v4[v2] = 0;
if ( v4[0] != 35 && v2 )
{
result = eval(v4);
v2 = error_no;
if ( error_no )
return result;
}
else
{
v2 = v1;
}
}
else
{
++v2;
}
}
v4[v2] = 0;
if ( v4[0] == 35 || !v2 || (result = eval(v4), !error_no) )
result = bclose();
return result;
}

canonical_decompiled_code:
int func15()
{
int result; // eax
int v1; // ebp
int v2; // ebx
int v3; // eax
char v4[280]; // [rsp+0h] [rbp-118h] BYREF

result = pop_string(v4);
v1 = error_no;
if ( error_no )
return result;
v2 = error_no;
if ( func13(v4) < 0 )
return printf("open failed. %s\n", v4);
while ( 1 )
{
v3 = func14();
if ( v3 == -1 )
break;
if ( v3 == 13 || v3 == 10 )
goto LABEL_10;
v4[v2] = v3;
if ( v2 == 254 )
{
++v2;
LABEL_10:
v4[v2] = 0;
if ( v4[0] != 35 && v2 )
{
result = eval(v4);
v2 = error_no;
if ( error_no )
return result;
}
else
{
v2 = v1;
}
}
else
{
++v2;
}
}
v4[v2] = 0;
if ( v4[0] == 35 || !v2 || (result = eval(v4), !error_no) )
result = func12();
return result;
}

original_code:
void f_load(void)
{
  char str[256];
  int c, i = 0, flag = 0;
  pop_string(str); if (error_no != 0) return;;
  if (bopen(str) < 0) {
    printf("open failed. %s\n", str);
    return;
  }
  while (1) {
    c = bget();
    if (c == -1) {
      flag = 2;
    }
    else if (c == ('m' & 0x1f) || c == ('j' & 0x1f)) {
      flag = 1;
    }
    else {
      str[i++] = c;
      if (i == 255) flag = 1;
    }
    if (flag > 0) {
      str[i] = 0;
      if ((str[0] != '#') && (i != 0)) {
 eval(str); if (error_no != 0) return;;
      }
      if (flag == 2) break;
      flag = 0;
      i = 0;
    }
  }
  bclose();
}

canonical_original_code:
void f_load()
{
  char str[256];
  int c; int i = 0; int flag = 0;
  pop_string(str); if (error_no != 0) return;;
  if (bopen(str) < 0) {
    printf("open failed. %s\n", str);
    return;
  }
  while (1) {
    c = bget();
    if (c == -1) {
      flag = 2;
    }
    else if (c == ('m' & 0x1f) || c == ('j' & 0x1f)) {
      flag = 1;
    }
    else {
      str[i++] = c;
      if (i == 255) flag = 1;
    }
    if (flag > 0) {
      str[i] = 0;
      if ((str[0] != '#') && (i != 0)) {
 eval(str); if (error_no != 0) return;;
      }
      if (flag == 2) break;
      flag = 0;
      i = 0;
    }
  }
  bclose();
}

variable_types: c int

variable_types: flag int


decompiled_code:
int f_dir()
{
int result; // eax
int v1; // er14
int v2; // er13
int v3; // er12
int v4; // ebp
_BYTE v5[512]; // [rsp+0h] [rbp-328h] BYREF
char file[296]; // [rsp+200h] [rbp-128h] BYREF

result = pop_string(file);
v1 = error_no;
if ( !error_no )
{
if ( file[0] )
{
v2 = open(file, 0, 0LL);
if ( v2 < 0 )
{
printf("cannot open file. [%d](%s)\n", MEMORY[0x7FFF0028], file);
result = close(v2);
}
else
{
while ( 1 )
{
v3 = getdents((unsigned int)v2, v5, 512LL);
if ( v3 <= 0 )
break;
v4 = v1;
do
{
printf("%s\n", &v5[v4 + 18]);
v4 += *(unsigned __int16 *)&v5[v4 + 16];
}
while ( v3 > v4 );
}
result = close(v2);
}
}
else
{
result = printf("Directory name is empty\n");
}
}
return result;
}

canonical_decompiled_code:
int func1()
{
int result; // eax
int v1; // er14
int v2; // er13
int v3; // er12
int v4; // ebp
_BYTE v5[512]; // [rsp+0h] [rbp-328h] BYREF
char file[296]; // [rsp+200h] [rbp-128h] BYREF

result = pop_string(file);
v1 = error_no;
if ( !error_no )
{
if ( file[0] )
{
v2 = open(file, 0, 0LL);
if ( v2 < 0 )
{
printf("cannot open file. [%d](%s)\n", MEMORY[0x7FFF0028], file);
result = close(v2);
}
else
{
while ( 1 )
{
v3 = getdents((unsigned int)v2, v5, 512LL);
if ( v3 <= 0 )
break;
v4 = v1;
do
{
printf("%s\n", &v5[v4 + 18]);
v4 += *(unsigned __int16 *)&v5[v4 + 16];
}
while ( v3 > v4 );
}
result = close(v2);
}
}
else
{
result = printf("Directory name is empty\n");
}
}
return result;
}

original_code:
void f_dir (void)
{
  int fd;
  static struct stat st;
  int length;
  int i;
  char dirname[256];
  char buf[512];
  struct dirent *dp;
  pop_string(dirname); if (error_no != 0) return;;
  if (dirname[0] == 0) {
    printf("Directory name is empty\n");
    return;
  }
  fd = open (dirname, 0, 0);
  if (fd < 0)
    {
      printf ("cannot open file. [%d](%s)\n", ((((struct lowlib_data *)(0x7fff0000)))->errno), dirname);
      close(fd);
      return;
    }
  while((length = getdents(fd, buf, 512)) > 0) {
    for(i = 0; i < length; i += dp->d_reclen) {
      dp = (struct dirent *) (buf+i);
      printf("%s\n", dp->d_name);
    }
  }
  close (fd);
}

canonical_original_code:
void f_dir()
{
  int fd;
  static struct stat st;
  int length;
  int i;
  char dirname[256];
  char buf[512];
  struct dirent *dp;
  pop_string(dirname); if (error_no != 0) return;;
  if (dirname[0] == 0) {
    printf("Directory name is empty\n");
    return;
  }
  fd = open (dirname, 0, 0);
  if (fd < 0)
    {
      printf ("cannot open file. [%d](%s)\n", ((((struct lowlib_data *)(0x7fff0000)))->errno), dirname);
      close(fd);
      return;
    }
  while((length = getdents(fd, buf, 512)) > 0) {
    for(i = 0; i < length; i += dp->d_reclen) {
      dp = (struct dirent *) (buf+i);
      printf("%s\n", dp->d_name);
    }
  }
  close (fd);
}

variable_types: fd int

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_mode; unsigned long st_nlink; unsigned long st_uid; unsigned long st_gid; unsigned long st_rdev; unsigned long st_size; unsigned long st_blksize; unsigned long st_blocks; unsigned long st_atime; unsigned long st_mtime; unsigned long st_ctime; }

variable_types:
dirname
char [256]

variable_types: struct dirent { long d_ino; unsigned long d_off; unsigned short d_reclen; char d_name[1]; } *