original_code:
double f__cabs(double real, double imag)
{
double temp;
if(real < 0)
 real = -real;
if(imag < 0)
 imag = -imag;
if(imag > real){
 temp = real;
 real = imag;
 imag = temp;
}
if((real+imag) == real)
 return(real);
temp = imag/real;
temp = real*sqrt(1.0 + temp*temp);
return(temp);
}

variable_types: real double

variable_types: imag double

variable_types: temp double


repo: kimtang/qml

decompiled_code:
__int64 __fastcall i_len_trim(__int64 a1, int a2)
{
__int64 v2; // rsi

LODWORD(v2) = a2 - 1;
if ( (int)v2 < 0 )
return 0LL;
v2 = (int)v2;
while ( *(_BYTE *)(a1 + v2) == 32 )
{
if ( (int)--v2 < 0 )
return 0LL;
}
return (int)v2 + 1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
__int64 v2; // rsi

LODWORD(v2) = a2 - 1;
if ( (int)v2 < 0 )
return 0LL;
v2 = (int)v2;
while ( *(_BYTE *)(a1 + v2) == 32 )
{
if ( (int)--v2 < 0 )
return 0LL;
}
return (int)v2 + 1;
}

original_code:
integer i_len_trim(char *s, ftnlen n)
{
  int i;
  for(i=n-1;i>=0;i--)
    if(s[i] != ' ')
      return i + 1;
  return(0);
}

canonical_original_code:
long i_len_trim(char *s, long n)
{
  int i;
  for(i=n-1;i>=0;i--)
    if(s[i] != ' ')
      return i + 1;
  return(0);
}

variable_types:
s
char *

variable_types: n long

variable_types: i int

return_type: long


decompiled_code:
double __fastcall r_int(float *a1)
{
float v1; // xmm3_4
__m128 v2; // xmm3
__m128 v4; // xmm1
float v5; // xmm3_4
__m128 v6; // xmm3
double v7; // [rsp+8h] [rbp-18h]
float v8; // [rsp+1Ch] [rbp-4h]

v8 = *a1;
if ( *a1 <= 0.0 )
{
v4 = (__m128)(LODWORD(v8) ^ (unsigned int)LC4);
LODWORD(v5) = LODWORD(v8) ^ LC4;
if ( COERCE_FLOAT((LODWORD(v8) ^ LC4) & LC2) < 8388608.0 )
{
v6.m128_f32[0] = (float)(int)v4.m128_f32[0];
LODWORD(v5) = COERCE_UNSIGNED_INT(v6.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v6, v4).m128_u32[0] & LC3)) | _mm_andnot_ps((__m128)(unsigned int)LC2, v4).m128_u32[0];
}
*(_QWORD *)&v7 = COERCE_UNSIGNED_INT64(v5) ^ LC5;
}
else
{
v1 = *a1;
if ( COERCE_FLOAT(LODWORD(v8) & LC2) < 8388608.0 )
{
v2.m128_f32[0] = (float)(int)v8;
LODWORD(v1) = COERCE_UNSIGNED_INT(v2.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v2, (__m128)LODWORD(v8)).m128_u32[0] & LC3)) | _mm_andnot_ps((__m128)(unsigned int)LC2, (__m128)LODWORD(v8)).m128_u32[0];
}
v7 = v1;
}
return v7;
}

canonical_decompiled_code:
double __fastcall func0(float *a1)
{
float v1; // xmm3_4
__m128 v2; // xmm3
__m128 v4; // xmm1
float v5; // xmm3_4
__m128 v6; // xmm3
double v7; // [rsp+8h] [rbp-18h]
float v8; // [rsp+1Ch] [rbp-4h]

v8 = *a1;
if ( *a1 <= 0.0 )
{
v4 = (__m128)(LODWORD(v8) ^ (unsigned int)LC4);
LODWORD(v5) = LODWORD(v8) ^ LC4;
if ( COERCE_FLOAT((LODWORD(v8) ^ LC4) & LC2) < 8388608.0 )
{
v6.m128_f32[0] = (float)(int)v4.m128_f32[0];
LODWORD(v5) = COERCE_UNSIGNED_INT(v6.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v6, v4).m128_u32[0] & LC3)) | _mm_andnot_ps((__m128)(unsigned int)LC2, v4).m128_u32[0];
}
*(_QWORD *)&v7 = COERCE_UNSIGNED_INT64(v5) ^ LC5;
}
else
{
v1 = *a1;
if ( COERCE_FLOAT(LODWORD(v8) & LC2) < 8388608.0 )
{
v2.m128_f32[0] = (float)(int)v8;
LODWORD(v1) = COERCE_UNSIGNED_INT(v2.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v2, (__m128)LODWORD(v8)).m128_u32[0] & LC3)) | _mm_andnot_ps((__m128)(unsigned int)LC2, (__m128)LODWORD(v8)).m128_u32[0];
}
v7 = v1;
}
return v7;
}

original_code:
double r_int(real *x)
{
return( (*x>0) ? floor(*x) : -floor(- *x) );
}

canonical_original_code:
double r_int(float *x)
{
return( (*x>0) ? floor(*x) : -floor(- *x) );
}

variable_types:
x
float *

return_type: double


decompiled_code:
__int64 __fastcall f__putbuf(int a1)
{
const char *v1; // rbx
char *v2; // rbp
char *v3; // rax

if ( f__recpos < f__hiwater )
f__recpos = f__hiwater;
if ( f__buflen <= f__recpos + 1 )
sub_0(f__recpos + 1, f__recpos);
v1 = ptr;
v2 = &ptr[f__recpos];
if ( a1 )
*v2++ = a1;
*v2 = 0;
while ( 1 )
{
fputs(v1, (FILE *)f);
v3 = (char *)&v1[strlen(v1)];
if ( v2 <= v3 )
break;
v1 = v3 + 1;
putc(*v3, (FILE *)f);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
const char *v1; // rbx
char *v2; // rbp
char *v3; // rax

if ( f__recpos < f__hiwater )
f__recpos = f__hiwater;
if ( f__buflen <= f__recpos + 1 )
func0(f__recpos + 1, f__recpos);
v1 = ptr;
v2 = &ptr[f__recpos];
if ( a1 )
*v2++ = a1;
*v2 = 0;
while ( 1 )
{
fputs(v1, (FILE *)f);
v3 = (char *)&v1[strlen(v1)];
if ( v2 <= v3 )
break;
v1 = v3 + 1;
putc(*v3, (FILE *)f);
}
return 0LL;
}

original_code:
int
f__putbuf(int c)
{
 char *s, *se;
 int n;
 if (f__hiwater > f__recpos)
  f__recpos = f__hiwater;
 n = f__recpos + 1;
 if (n >= f__buflen)
  f__bufadj(n, f__recpos);
 s = f__buf;
 se = s + f__recpos;
 if (c)
  *se++ = c;
 *se = 0;
 for(;;) {
  fputs(s, f__cf);
  s += strlen(s);
  if (s >= se)
   break;
  putc(*s++, f__cf);
  }
 return 0;
 }

canonical_original_code:
int f__putbuf(int c)
{
 char *s; char *se;
 int n;
 if (f__hiwater > f__recpos)
  f__recpos = f__hiwater;
 n = f__recpos + 1;
 if (n >= f__buflen)
  f__bufadj(n, f__recpos);
 s = f__buf;
 se = s + f__recpos;
 if (c)
  *se++ = c;
 *se = 0;
 for(;;) {
  fputs(s, f__cf);
  s += strlen(s);
  if (s >= se)
   break;
  putc(*s++, f__cf);
  }
 return 0;
 }

variable_types: c int

variable_types:
se
char *

variable_types: n int

return_type: int


original_code:
int
fk_open(int seq, int fmt, ftnint n)
{ char nbuf[10];
 olist a;
 (void) sprintf(nbuf,"fort.%ld",(long)n);
 a.oerr=1;
 a.ounit=n;
 a.ofnm=nbuf;
 a.ofnmlen=strlen(nbuf);
 a.osta=((void *)0);
 a.oacc= (char*)(seq==3?"s":"d");
 a.ofm = (char*)(fmt==5?"f":"u");
 a.orl = seq==4?1:0;
 a.oblnk=((void *)0);
 return(f_open(&a));
}

canonical_original_code:
int fk_open(int seq, int fmt, long n)
{ char nbuf[10];
 struct olist a;
 (void) sprintf(nbuf,"fort.%ld",(long)n);
 a.oerr=1;
 a.ounit=n;
 a.ofnm=nbuf;
 a.ofnmlen=strlen(nbuf);
 a.osta=((void *)0);
 a.oacc= (char *)(seq==3?"s":"d");
 a.ofm = (char *)(fmt==5?"f":"u");
 a.orl = seq==4?1:0;
 a.oblnk=((void *)0);
 return(f_open(&a));
}

variable_types: seq int

variable_types: fmt int

variable_types:
nbuf
char [10]

variable_types: struct olist { long oerr; long ounit; char *ofnm; long ofnmlen; char *osta; char *oacc; char *ofm; long orl; char *oblnk; }


decompiled_code:
void __fastcall c_exp(float *a1, float *a2)
{
float v2; // xmm0_4
float v3; // xmm0_4
double v4; // [rsp+0h] [rbp-58h]
double v5; // [rsp+8h] [rbp-50h]

v5 = a2[1];
v4 = exp(*a2);
v2 = cos(v5) * v4;
*a1 = v2;
v3 = sin(v5) * v4;
a1[1] = v3;
}

canonical_decompiled_code:
void __fastcall func0(float *a1, float *a2)
{
float v2; // xmm0_4
float v3; // xmm0_4
double v4; // [rsp+0h] [rbp-58h]
double v5; // [rsp+8h] [rbp-50h]

v5 = a2[1];
v4 = exp(*a2);
v2 = cos(v5) * v4;
*a1 = v2;
v3 = sin(v5) * v4;
a1[1] = v3;
}

original_code:
void c_exp(complex *r, complex *z)
{
 double expx, zi = z->i;
 expx = exp(z->r);
 r->r = expx * cos(zi);
 r->i = expx * sin(zi);
 }

canonical_original_code:
void c_exp(struct complex *r, struct complex *z)
{
 double expx; double zi = z->i;
 expx = exp(z->r);
 r->r = expx * cos(zi);
 r->i = expx * sin(zi);
 }

variable_types:
r
struct complex { float r; } *

variable_types:
z
struct complex *

variable_types: expx double

variable_types: zi double

return_type: void


decompiled_code:
void __fastcall pow_zz(double *a1, double *a2, double *a3)
{
double v4; // [rsp+0h] [rbp-C8h]
double v5; // [rsp+8h] [rbp-C0h]
double v6; // [rsp+10h] [rbp-B8h]
double v7; // [rsp+18h] [rbp-B0h]
double x; // [rsp+98h] [rbp-30h]

x = f__cabs(*a2, a2[1]);
v7 = log(x);
v6 = atan2(a2[1], *a2);
v5 = exp(*a3 * v7 - a3[1] * v6);
v4 = a3[1] * v7 + *a3 * v6;
*a1 = cos(v4) * v5;
a1[1] = sin(v4) * v5;
}

canonical_decompiled_code:
void __fastcall func0(double *a1, double *a2, double *a3)
{
double v4; // [rsp+0h] [rbp-C8h]
double v5; // [rsp+8h] [rbp-C0h]
double v6; // [rsp+10h] [rbp-B8h]
double v7; // [rsp+18h] [rbp-B0h]
double x; // [rsp+98h] [rbp-30h]

x = f__cabs(*a2, a2[1]);
v7 = log(x);
v6 = atan2(a2[1], *a2);
v5 = exp(*a3 * v7 - a3[1] * v6);
v4 = a3[1] * v7 + *a3 * v6;
*a1 = cos(v4) * v5;
a1[1] = sin(v4) * v5;
}

original_code:
void pow_zz(doublecomplex *r, doublecomplex *a, doublecomplex *b)
{
double logr, logi, x, y;
logr = log( f__cabs(a->r, a->i) );
logi = atan2(a->i, a->r);
x = exp( logr * b->r - logi * b->i );
y = logr * b->i + logi * b->r;
r->r = x * cos(y);
r->i = x * sin(y);
}

canonical_original_code:
void pow_zz(struct doublecomplex *r, struct doublecomplex *a, struct doublecomplex *b)
{
double logr; double logi; double x; double y;
logr = log( f__cabs(a->r, a->i) );
logi = atan2(a->i, a->r);
x = exp( logr * b->r - logi * b->i );
y = logr * b->i + logi * b->r;
r->r = x * cos(y);
r->i = x * sin(y);
}

variable_types:
r
struct doublecomplex { double r; } *

variable_types:
a
struct doublecomplex *

variable_types:
b
struct doublecomplex *

variable_types: logr double

variable_types: logi double

variable_types: x double

variable_types: y double


decompiled_code:
void __fastcall r_sin(float *a1)
{
sin(*a1);
}

canonical_decompiled_code:
void __fastcall func0(float *a1)
{
sin(*a1);
}

original_code:
double r_sin(real *x)
{
return( sin(*x) );
}

canonical_original_code:
double r_sin(float *x)
{
return( sin(*x) );
}

variable_types:
x
float *


decompiled_code:
void __fastcall c_cos(float *a1, float *a2)
{
float v2; // xmm0_4
double v3; // xmm0_8
float v4; // xmm0_4
double x; // [rsp+0h] [rbp-68h]
double v6; // [rsp+8h] [rbp-60h]
double v7; // [rsp+50h] [rbp-18h]

v6 = a2[1];
x = *a2;
v7 = cos(x);
v2 = v7 * cosh(v6);
*a1 = v2;
v3 = sin(x);
v4 = COERCE_DOUBLE(*(_QWORD *)&v3 ^ LC0) * sinh(v6);
a1[1] = v4;
}

canonical_decompiled_code:
void __fastcall func0(float *a1, float *a2)
{
float v2; // xmm0_4
double v3; // xmm0_8
float v4; // xmm0_4
double x; // [rsp+0h] [rbp-68h]
double v6; // [rsp+8h] [rbp-60h]
double v7; // [rsp+50h] [rbp-18h]

v6 = a2[1];
x = *a2;
v7 = cos(x);
v2 = v7 * cosh(v6);
*a1 = v2;
v3 = sin(x);
v4 = COERCE_DOUBLE(*(_QWORD *)&v3 ^ LC0) * sinh(v6);
a1[1] = v4;
}

original_code:
void c_cos(complex *r, complex *z)
{
 double zi = z->i, zr = z->r;
 r->r = cos(zr) * cosh(zi);
 r->i = - sin(zr) * sinh(zi);
 }

canonical_original_code:
void c_cos(struct complex *r, struct complex *z)
{
 double zi = z->i; double zr = z->r;
 r->r = cos(zr) * cosh(zi);
 r->i = - sin(zr) * sinh(zi);
 }

variable_types: zr double


original_code:
double d_nint(doublereal *x)
{
return( (*x)>=0 ?
 floor(*x + .5) : -floor(.5 - *x) );
}

canonical_original_code:
double d_nint(double *x)
{
return( (*x)>=0 ?
 floor(*x + .5) : -floor(.5 - *x) );
}

variable_types:
x
double *


decompiled_code:
void __fastcall __noreturn sig_die(const char *a1, int a2)
{
fprintf(stderr, "%s\n", a1);
if ( !a2 )
exit(1);
fflush(stderr);
f_exit();
fflush(stderr);
signal(6, 0LL);
abort();
}

canonical_decompiled_code:
void __fastcall __noreturn func0(const char *a1, int a2)
{
fprintf(stderr, "%s\n", a1);
if ( !a2 )
exit(1);
fflush(stderr);
f_exit();
fflush(stderr);
signal(6, 0LL);
abort();
}

original_code:
void sig_die(const char *s, int kill)
{
 fprintf(stderr, "%s\n", s);
 if(kill)
  {
  fflush(stderr);
  f_exit();
  fflush(stderr);
  signal(6, ((__sighandler_t) 0));
  abort();
  }
 else {
  exit(1);
  }
 }

canonical_original_code:
void sig_die(char *s, int kill)
{
 fprintf(stderr, "%s\n", s);
 if(kill)
  {
  fflush(stderr);
  f_exit();
  fflush(stderr);
  signal(6, ((void (*)(int)) 0));
  abort();
  }
 else {
  exit(1);
  }
 }

variable_types:
s
char *

variable_types: kill int


repo: dakk/spiderpig-os

decompiled_code:
__int64 __fastcall fs_get_fs_driver(__int64 a1)
{
_BYTE v2[136]; // [rsp+0h] [rbp-88h] BYREF

fs_get_mount_point(a1, v2);
fs_get_mount_point_fs(v2, v2);
return driver_get(v2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
_BYTE v2[136]; // [rsp+0h] [rbp-88h] BYREF

fs_get_mount_point(a1, v2);
fs_get_mount_point_fs(v2, v2);
return driver_get(v2);
}

original_code:
driver_t *fs_get_fs_driver(char *path)
{
 char mp[128];
 fs_get_mount_point(path, mp);
 fs_get_mount_point_fs(mp, mp);
 return (driver_t *) driver_get(mp);
}

canonical_original_code:
struct driver_p *fs_get_fs_driver(char *path)
{
 char mp[128];
 fs_get_mount_point(path, mp);
 fs_get_mount_point_fs(mp, mp);
 return (struct driver_p *) driver_get(mp);
}

variable_types:
path
char *

variable_types:
mp
char [128]

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

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

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


decompiled_code:
__int64 __fastcall fs_makedir(__int64 a1)
{
unsigned int v1; // ebx
unsigned int v2; // eax
__int64 result; // rax
__int64 v4; // rax
__int64 (__fastcall *v5)(__int64, char *); // rdx
char v6[256]; // [rsp+0h] [rbp-4528h] BYREF
char dest[1032]; // [rsp+100h] [rbp-4428h] BYREF
__int64 v8; // [rsp+508h] [rbp-4020h] BYREF
int v9; // [rsp+510h] [rbp-4018h] BYREF
char src[16404]; // [rsp+514h] [rbp-4014h] BYREF

debug_puts("fs_makedir()\n");
v8 = 0LL;
fs_split_path(a1, &v9);
strcpy(dest, "/");
if ( v9 == 1 )
{
v2 = 0;
}
else
{
v1 = 0;
do
{
strcat(dest, &src[512 * (unsigned __int64)v1]);
strcat(dest, "/");
++v1;
v2 = v9 - 1;
}
while ( v9 - 1 > v1 );
}
strcpy(v6, &src[512 * (unsigned __int64)v2]);
fs_get_node(dest, &v8);
result = 0LL;
if ( v8 )
{
v4 = fs_get_fs_driver((__int64)dest);
if ( v4 )
{
v5 = *(__int64 (__fastcall **)(__int64, char *))(v4 + 312);
result = 0LL;
if ( v5 )
result = v5(v8, v6);
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
unsigned int v1; // ebx
unsigned int v2; // eax
__int64 result; // rax
__int64 v4; // rax
__int64 (__fastcall *v5)(__int64, char *); // rdx
char v6[256]; // [rsp+0h] [rbp-4528h] BYREF
char dest[1032]; // [rsp+100h] [rbp-4428h] BYREF
__int64 v8; // [rsp+508h] [rbp-4020h] BYREF
int v9; // [rsp+510h] [rbp-4018h] BYREF
char src[16404]; // [rsp+514h] [rbp-4014h] BYREF

debug_puts("fs_makedir()\n");
v8 = 0LL;
fs_split_path(a1, &v9);
strcpy(dest, "/");
if ( v9 == 1 )
{
v2 = 0;
}
else
{
v1 = 0;
do
{
strcat(dest, &src[512 * (unsigned __int64)v1]);
strcat(dest, "/");
++v1;
v2 = v9 - 1;
}
while ( v9 - 1 > v1 );
}
strcpy(v6, &src[512 * (unsigned __int64)v2]);
fs_get_node(dest, &v8);
result = 0LL;
if ( v8 )
{
v4 = func0((__int64)dest);
if ( v4 )
{
v5 = *(__int64 (__fastcall **)(__int64, char *))(v4 + 312);
result = 0LL;
if ( v5 )
result = v5(v8, v6);
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
uint32_t fs_makedir(char *path_)
{
 debug_puts("fs_makedir()\n");
 fs_splitted_path sp;
 inode_t *node = 0;
 char path[1024];
 char name[255];
 uint32_t i;
 fs_split_path(path_, &sp);
 strcpy(path, "/");
 for(i = 0; i < (sp.i - 1); i++)
 {
  strcat(path, sp.list[i]);
  strcat(path, "/");
 }
 strcpy(name, sp.list[sp.i - 1]);
 fs_get_node(path, &node);
 if(node == 0)
  return 0;
 driver_t *drv = fs_get_fs_driver(path);
 driver_fs_t *filesystem_struct;
 if(drv != 0)
  filesystem_struct = &drv->fs;
 else
  return 0;
 if(filesystem_struct->mkdir != 0)
  return filesystem_struct->mkdir(node, name);
 return 0;
}

canonical_original_code:
unsigned int fs_makedir(char *path_)
{
 debug_puts("fs_makedir()\n");
 struct fs_splitted_path sp;
 struct inode_p *node = 0;
 char path[1024];
 char name[255];
 unsigned int i;
 fs_split_path(path_, &sp);
 strcpy(path, "/");
 for(i = 0; i < (sp.i - 1); i++)
 {
  strcat(path, sp.list[i]);
  strcat(path, "/");
 }
 strcpy(name, sp.list[sp.i - 1]);
 fs_get_node(path, &node);
 if(node == 0)
  return 0;
 struct driver_p *drv = fs_get_fs_driver(path);
 struct driver_fs_t *filesystem_struct;
 if(drv != 0)
  filesystem_struct = &drv->fs;
 else
  return 0;
 if(filesystem_struct->mkdir != 0)
  return filesystem_struct->mkdir(node, name);
 return 0;
}

variable_types: struct fs_splitted_path { unsigned int i; char list[32][512]; }

variable_types:
path
char [1024]

variable_types:
name
char [255]

variable_types:
i
unsigned int

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

variable_types: struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } *

return_type: unsigned int


decompiled_code:
__int64 __fastcall fs_rm(__int64 a1)
{
unsigned int v1; // ebx
unsigned int v2; // eax
__int64 result; // rax
__int64 v4; // rax
__int64 (__fastcall *v5)(__int64, char *); // rdx
char v6[256]; // [rsp+0h] [rbp-4528h] BYREF
char dest[1032]; // [rsp+100h] [rbp-4428h] BYREF
__int64 v8; // [rsp+508h] [rbp-4020h] BYREF
int v9; // [rsp+510h] [rbp-4018h] BYREF
char src[16404]; // [rsp+514h] [rbp-4014h] BYREF

debug_puts("fs_rm()\n");
v8 = 0LL;
fs_split_path(a1, &v9);
strcpy(dest, "/");
if ( v9 == 1 )
{
v2 = 0;
}
else
{
v1 = 0;
do
{
strcat(dest, &src[512 * (unsigned __int64)v1]);
strcat(dest, "/");
++v1;
v2 = v9 - 1;
}
while ( v9 - 1 > v1 );
}
strcpy(v6, &src[512 * (unsigned __int64)v2]);
fs_get_node(dest, &v8);
result = 0LL;
if ( v8 )
{
v4 = fs_get_fs_driver((__int64)dest);
if ( v4 )
{
v5 = *(__int64 (__fastcall **)(__int64, char *))(v4 + 336);
result = 0LL;
if ( v5 )
result = v5(v8, v6);
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
unsigned int v1; // ebx
unsigned int v2; // eax
__int64 result; // rax
__int64 v4; // rax
__int64 (__fastcall *v5)(__int64, char *); // rdx
char v6[256]; // [rsp+0h] [rbp-4528h] BYREF
char dest[1032]; // [rsp+100h] [rbp-4428h] BYREF
__int64 v8; // [rsp+508h] [rbp-4020h] BYREF
int v9; // [rsp+510h] [rbp-4018h] BYREF
char src[16404]; // [rsp+514h] [rbp-4014h] BYREF

debug_puts("fs_rm()\n");
v8 = 0LL;
fs_split_path(a1, &v9);
strcpy(dest, "/");
if ( v9 == 1 )
{
v2 = 0;
}
else
{
v1 = 0;
do
{
strcat(dest, &src[512 * (unsigned __int64)v1]);
strcat(dest, "/");
++v1;
v2 = v9 - 1;
}
while ( v9 - 1 > v1 );
}
strcpy(v6, &src[512 * (unsigned __int64)v2]);
fs_get_node(dest, &v8);
result = 0LL;
if ( v8 )
{
v4 = func0((__int64)dest);
if ( v4 )
{
v5 = *(__int64 (__fastcall **)(__int64, char *))(v4 + 336);
result = 0LL;
if ( v5 )
result = v5(v8, v6);
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
uint32_t fs_rm(char *path_)
{
 debug_puts("fs_rm()\n");
 fs_splitted_path sp;
 inode_t *node = 0;
 char path[1024];
 char name[255];
 uint32_t i;
 fs_split_path(path_, &sp);
 strcpy(path, "/");
 for(i = 0; i < (sp.i - 1); i++)
 {
  strcat(path, sp.list[i]);
  strcat(path, "/");
 }
 strcpy(name, sp.list[sp.i - 1]);
 fs_get_node(path, &node);
 if(node == 0)
  return 0;
 driver_t *drv = fs_get_fs_driver(path);
 driver_fs_t *filesystem_struct;
 if(drv != 0)
  filesystem_struct = &drv->fs;
 else
  return 0;
 if(filesystem_struct->delete_node != 0)
  return filesystem_struct->delete_node(node, name);
 return 0;
}

canonical_original_code:
unsigned int fs_rm(char *path_)
{
 debug_puts("fs_rm()\n");
 struct fs_splitted_path sp;
 struct inode_p *node = 0;
 char path[1024];
 char name[255];
 unsigned int i;
 fs_split_path(path_, &sp);
 strcpy(path, "/");
 for(i = 0; i < (sp.i - 1); i++)
 {
  strcat(path, sp.list[i]);
  strcat(path, "/");
 }
 strcpy(name, sp.list[sp.i - 1]);
 fs_get_node(path, &node);
 if(node == 0)
  return 0;
 struct driver_p *drv = fs_get_fs_driver(path);
 struct driver_fs_t *filesystem_struct;
 if(drv != 0)
  filesystem_struct = &drv->fs;
 else
  return 0;
 if(filesystem_struct->delete_node != 0)
  return filesystem_struct->delete_node(node, name);
 return 0;
}

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

user_defined_types: struct fs_splitted_path { unsigned int i; char list[32][512]; }

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

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

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

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


decompiled_code:
__int64 __fastcall fs_close(void *ptr)
{
debug_puts("fs_close()\n");
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(void *ptr)
{
debug_puts("fs_close()\n");
free(ptr);
return 0LL;
}

original_code:
uint32_t fs_close(file_t *f)
{
 debug_puts("fs_close()\n");
 free(f);
 return 0;
}

canonical_original_code:
unsigned int fs_close(struct file_p *f)
{
 debug_puts("fs_close()\n");
 free(f);
 return 0;
}

variable_types: struct file_p { unsigned int id; unsigned long long seek_p; unsigned long long size; struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *node; void *drv; struct file_p *next; } *

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


decompiled_code:
__int64 __fastcall fs_read(_QWORD *a1, __int64 a2, unsigned int a3)
{
__int64 v4; // rax
__int64 (__fastcall *v5)(_QWORD, __int64, _QWORD, _QWORD); // r8
__int64 result; // rax

debug_puts("fs_read()\n");
v4 = a1[4];
if ( !v4 )
return 0LL;
v5 = *(__int64 (__fastcall **)(_QWORD, __int64, _QWORD, _QWORD))(v4 + 384);
result = 0LL;
if ( v5 )
result = v5(a1[3], a2, a3, a1[1]);
a1[1] += (unsigned int)result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1, __int64 a2, unsigned int a3)
{
__int64 v4; // rax
__int64 (__fastcall *v5)(_QWORD, __int64, _QWORD, _QWORD); // r8
__int64 result; // rax

debug_puts("fs_read()\n");
v4 = a1[4];
if ( !v4 )
return 0LL;
v5 = *(__int64 (__fastcall **)(_QWORD, __int64, _QWORD, _QWORD))(v4 + 384);
result = 0LL;
if ( v5 )
result = v5(a1[3], a2, a3, a1[1]);
a1[1] += (unsigned int)result;
return result;
}

original_code:
uint32_t fs_read(file_t *f, char *buf, uint32_t size)
{
 debug_puts("fs_read()\n");
 driver_fs_t *filesystem_struct = 0;
 unsigned av = 0;
 if(f->drv != 0)
  filesystem_struct = &((driver_t *) (f->drv))->fs;
 else
  return 0;
 if(filesystem_struct->read != 0)
  av = filesystem_struct->read(f->node, buf, size, f->seek_p);
 f->seek_p = f->seek_p + av;
 return av;
}

canonical_original_code:
unsigned int fs_read(struct file_p *f, char *buf, unsigned int size)
{
 debug_puts("fs_read()\n");
 struct driver_fs_t *filesystem_struct = 0;
 unsigned int av = 0;
 if(f->drv != 0)
  filesystem_struct = &((struct driver_p *) (f->drv))->fs;
 else
  return 0;
 if(filesystem_struct->read != 0)
  av = filesystem_struct->read(f->node, buf, size, f->seek_p);
 f->seek_p = f->seek_p + av;
 return av;
}

variable_types:
buf
char *

variable_types:
size
unsigned int

variable_types:
av
unsigned int

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


decompiled_code:
__int64 __fastcall fs_write(_QWORD *a1, __int64 a2, unsigned int a3)
{
__int64 v4; // rax
__int64 (__fastcall *v5)(_QWORD, __int64, _QWORD, _QWORD); // r8
__int64 result; // rax

debug_puts("fs_write()\n");
v4 = a1[4];
if ( !v4 )
return 0LL;
v5 = *(__int64 (__fastcall **)(_QWORD, __int64, _QWORD, _QWORD))(v4 + 392);
result = 0LL;
if ( v5 )
result = v5(a1[3], a2, a3, a1[1]);
a1[1] += (unsigned int)result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, __int64 a2, unsigned int a3)
{
__int64 v4; // rax
__int64 (__fastcall *v5)(_QWORD, __int64, _QWORD, _QWORD); // r8
__int64 result; // rax

debug_puts("fs_write()\n");
v4 = a1[4];
if ( !v4 )
return 0LL;
v5 = *(__int64 (__fastcall **)(_QWORD, __int64, _QWORD, _QWORD))(v4 + 392);
result = 0LL;
if ( v5 )
result = v5(a1[3], a2, a3, a1[1]);
a1[1] += (unsigned int)result;
return result;
}

original_code:
uint32_t fs_write(file_t *f, char *buf, uint32_t size)
{
 debug_puts("fs_write()\n");
 driver_fs_t *filesystem_struct = 0;
 unsigned av = 0;
 if(f->drv != 0)
  filesystem_struct = &((driver_t *) (f->drv))->fs;
 else
  return 0;
 if(filesystem_struct->write != 0)
  av = filesystem_struct->write(f->node, buf, size, f->seek_p);
 f->seek_p = f->seek_p + av;
 return av;
}

canonical_original_code:
unsigned int fs_write(struct file_p *f, char *buf, unsigned int size)
{
 debug_puts("fs_write()\n");
 struct driver_fs_t *filesystem_struct = 0;
 unsigned int av = 0;
 if(f->drv != 0)
  filesystem_struct = &((struct driver_p *) (f->drv))->fs;
 else
  return 0;
 if(filesystem_struct->write != 0)
  av = filesystem_struct->write(f->node, buf, size, f->seek_p);
 f->seek_p = f->seek_p + av;
 return av;
}


original_code:
uint32_t fs_seek(file_t *f, uint8_t mod, uint64_t offset)
{
 debug_puts("fs_seek()\n");
 if(mod == 1)
  f->seek_p = f->seek_p + offset;
 else if(mod == 0)
  f->seek_p = offset;
 else if(mod == 2)
  f->seek_p = f->size - offset;
 return 0;
}

canonical_original_code:
unsigned int fs_seek(struct file_p *f, unsigned char mod, unsigned long long offset)
{
 debug_puts("fs_seek()\n");
 if(mod == 1)
  f->seek_p = f->seek_p + offset;
 else if(mod == 0)
  f->seek_p = offset;
 else if(mod == 2)
  f->seek_p = f->size - offset;
 return 0;
}

variable_types:
mod
unsigned char

variable_types:
offset
unsigned long long


decompiled_code:
__int64 __fastcall fs_opendir(char *src)
{
__int64 v1; // rbx
char v3[256]; // [rsp+0h] [rbp-4128h] BYREF
int v4; // [rsp+100h] [rbp-4028h] BYREF
char srca[16420]; // [rsp+104h] [rbp-4024h] BYREF

debug_puts("fs_opendir()\n");
fs_split_path(src, &v4);
strcpy(v3, &srca[512 * (unsigned __int64)(unsigned int)(v4 - 1)]);
v1 = fs_get_fs_driver((__int64)src);
if ( v1 )
{
v1 = (int)malloc(0x218uLL);
*(_QWORD *)((char *)&loc_7 + v1 + 1) = v3;
if ( !v3[0] )
strcpy(v3, "/");
strcpy((char *)(v1 + 20), src);
*(_QWORD *)v1 = 0LL;
*(_DWORD *)(v1 + 16) = 0;
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *src)
{
__int64 v1; // rbx
char v3[256]; // [rsp+0h] [rbp-4128h] BYREF
int v4; // [rsp+100h] [rbp-4028h] BYREF
char srca[16420]; // [rsp+104h] [rbp-4024h] BYREF

debug_puts("fs_opendir()\n");
fs_split_path(src, &v4);
strcpy(v3, &srca[512 * (unsigned __int64)(unsigned int)(v4 - 1)]);
v1 = func0((__int64)src);
if ( v1 )
{
v1 = (int)malloc(0x218uLL);
*(_QWORD *)((char *)&loc_7 + v1 + 1) = v3;
if ( !v3[0] )
strcpy(v3, "/");
strcpy((char *)(v1 + 20), src);
*(_QWORD *)v1 = 0LL;
*(_DWORD *)(v1 + 16) = 0;
}
return v1;
}

original_code:
dir_t *fs_opendir(char *path)
{
 debug_puts("fs_opendir()\n");
 file_t *f = 0;
 fs_splitted_path sp;
 char name[255];
 uint32_t i;
 struct dirent dir;
 fs_split_path(path, &sp);
 strcpy(name, sp.list[sp.i - 1]);
 driver_t *drv = fs_get_fs_driver(path);
 if(drv == 0)
  return (dir_t *) 0;
 dir_t *d = (dir_t *) malloc(sizeof(dir_t));
 d->d_name = name;
 if(d->d_name[0] == '\0')
  strcpy(d->d_name, "/");
 strcpy(d->path, path);
 d->f = f;
 d->cur_i = 0;
 return d;
}

canonical_original_code:
struct dir_p *fs_opendir(char *path)
{
 debug_puts("fs_opendir()\n");
 struct file_p *f = 0;
 struct fs_splitted_path sp;
 char name[255];
 unsigned int i;
 struct dirent dir;
 fs_split_path(path, &sp);
 strcpy(name, sp.list[sp.i - 1]);
 struct driver_p *drv = fs_get_fs_driver(path);
 if(drv == 0)
  return (struct dir_p *) 0;
 struct dir_p *d = (dir_t *) malloc(sizeof(dir_t));
 d->d_name = name;
 if(d->d_name[0] == '\0')
  strcpy(d->d_name, "/");
 strcpy(d->path, path);
 d->f = f;
 d->cur_i = 0;
 return d;
}

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

variable_types: struct dir_p { struct file_p { unsigned int id; unsigned long long seek_p; unsigned long long size; struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *node; void *drv; struct file_p *next; } *f; char *d_name; unsigned int cur_i; char path[512]; } *

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


decompiled_code:
__int64 __fastcall fs_closedir(void *ptr)
{
debug_puts("fs_closedir()\n");
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(void *ptr)
{
debug_puts("fs_closedir()\n");
free(ptr);
return 0LL;
}

original_code:
uint32_t fs_closedir(dir_t *dr)
{
 debug_puts("fs_closedir()\n");
 free(dr);
 return 0;
}

canonical_original_code:
unsigned int fs_closedir(struct dir_p *dr)
{
 debug_puts("fs_closedir()\n");
 free(dr);
 return 0;
}


decompiled_code:
__int64 __fastcall fs_rewinddir(__int64 a1)
{
debug_puts("fs_rewinddir()\n");
*(_DWORD *)(a1 + 16) = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
debug_puts("fs_rewinddir()\n");
*(_DWORD *)(a1 + 16) = 0;
return 0LL;
}

original_code:
uint32_t fs_rewinddir(dir_t *dr)
{
 debug_puts("fs_rewinddir()\n");
 dr->cur_i = 0;
 return 0;
}

canonical_original_code:
unsigned int fs_rewinddir(struct dir_p *dr)
{
 debug_puts("fs_rewinddir()\n");
 dr->cur_i = 0;
 return 0;
}


original_code:
uint32_t fs_readdir2(char *path, uint32_t in, struct dirent *dir)
{
 inode_t *node = 0;
 fs_get_node(path, &node);
 if(node == 0)
  return 0;
 if(node->type == 3)
  node = node->link;
 if(node == 0)
  return 0;
 strcpy(dir->name, "\0");
 dir->inode = 0;
 driver_t *drv = fs_get_fs_driver(path);
 driver_fs_t *filesystem_struct;
 if(drv != 0)
  filesystem_struct = &drv->fs;
 else
  return 0;
 if(filesystem_struct->readdir != 0)
  return filesystem_struct->readdir(node, in, dir);
 return 0;
}

canonical_original_code:
unsigned int fs_readdir2(char *path, unsigned int in, struct dirent *dir)
{
 struct inode_p *node = 0;
 fs_get_node(path, &node);
 if(node == 0)
  return 0;
 if(node->type == 3)
  node = node->link;
 if(node == 0)
  return 0;
 strcpy(dir->name, "\0");
 dir->inode = 0;
 struct driver_p *drv = fs_get_fs_driver(path);
 struct driver_fs_t *filesystem_struct;
 if(drv != 0)
  filesystem_struct = &drv->fs;
 else
  return 0;
 if(filesystem_struct->readdir != 0)
  return filesystem_struct->readdir(node, in, dir);
 return 0;
}

variable_types:
path
char *

variable_types:
in
unsigned int

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


decompiled_code:
__int64 __fastcall fs_open(__int64 a1, _BYTE *a2)
{
unsigned int v2; // ebx
unsigned int v3; // eax
__int64 result; // rax
__int64 v5; // r12
unsigned int i; // ebx
void (__fastcall *v7)(__int64, _QWORD, __int64 *); // rax
unsigned int (__fastcall *v8)(__int64, _BYTE *); // rdx
int v9; // edx
__int64 v10; // [rsp+0h] [rbp-4648h] BYREF
__int64 v11; // [rsp+8h] [rbp-4640h] BYREF
char s1[256]; // [rsp+10h] [rbp-4638h] BYREF
unsigned int v13; // [rsp+110h] [rbp-4538h]
char s2[256]; // [rsp+120h] [rbp-4528h] BYREF
char dest[1024]; // [rsp+220h] [rbp-4428h] BYREF
int v16; // [rsp+620h] [rbp-4028h] BYREF
char src[16420]; // [rsp+624h] [rbp-4024h] BYREF

debug_puts("fs_open()\n");
fs_split_path(a1, &v16);
strcpy(dest, "/");
if ( v16 == 1 )
{
v3 = 0;
}
else
{
v2 = 0;
do
{
strcat(dest, &src[512 * (unsigned __int64)v2]);
strcat(dest, "/");
++v2;
v3 = v16 - 1;
}
while ( v16 - 1 > v2 );
}
strcpy(s2, &src[512 * (unsigned __int64)v3]);
v11 = 0LL;
fs_split_path(dest, &v16);
result = fs_get_fs_driver((__int64)dest);
v5 = result;
if ( result )
{
for ( i = 0; (unsigned int)fs_readdir2((__int64)dest, i, (__int64)s1) && strcmp(s1, s2); ++i )
v13 = 0;
if ( v13 )
{
fs_get_node(dest, &v10);
v7 = *(void (__fastcall **)(__int64, _QWORD, __int64 *))(v5 + 328);
if ( v7 && v10 )
v7(v10, v13, &v11);
result = v11;
if ( !v11 || *(_BYTE *)(v11 + 260) != 1 )
return 0LL;
}
else
{
result = 0LL;
if ( *a2 != 119 )
return result;
fs_get_node(dest, &v11);
result = v11;
if ( !v11 )
return result;
fs_create_node(s2, v11, 1LL, 0LL);
result = v11;
if ( !v11 )
return result;
}
*(_QWORD *)(*(_QWORD *)((char *)&loc_15 + 3) + 272LL) = v5 + 296;
v8 = *(unsigned int (__fastcall **)(__int64, _BYTE *))(v5 + 368);
if ( v8 && !v8(result, a2) )
{
result = 0LL;
}
else
{
result = (int)malloc(0x30uLL);
*(_QWORD *)((char *)&loc_22 + (int)result + 6) = file_list;
*(_QWORD *)((char *)&loc_1D + (int)result + 3) = v5;
*(_QWORD *)((char *)&loc_15 + (int)result + 3) = v11;
file_list = (int)result;
v9 = files_open_n++;
*(_DWORD *)(int)result = v9;
*(_QWORD *)((char *)&loc_7 + (int)result + 1) = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, _BYTE *a2)
{
unsigned int v2; // ebx
unsigned int v3; // eax
__int64 result; // rax
__int64 v5; // r12
unsigned int i; // ebx
void (__fastcall *v7)(__int64, _QWORD, __int64 *); // rax
unsigned int (__fastcall *v8)(__int64, _BYTE *); // rdx
int v9; // edx
__int64 v10; // [rsp+0h] [rbp-4648h] BYREF
__int64 v11; // [rsp+8h] [rbp-4640h] BYREF
char s1[256]; // [rsp+10h] [rbp-4638h] BYREF
unsigned int v13; // [rsp+110h] [rbp-4538h]
char s2[256]; // [rsp+120h] [rbp-4528h] BYREF
char dest[1024]; // [rsp+220h] [rbp-4428h] BYREF
int v16; // [rsp+620h] [rbp-4028h] BYREF
char src[16420]; // [rsp+624h] [rbp-4024h] BYREF

debug_puts("fs_open()\n");
fs_split_path(a1, &v16);
strcpy(dest, "/");
if ( v16 == 1 )
{
v3 = 0;
}
else
{
v2 = 0;
do
{
strcat(dest, &src[512 * (unsigned __int64)v2]);
strcat(dest, "/");
++v2;
v3 = v16 - 1;
}
while ( v16 - 1 > v2 );
}
strcpy(s2, &src[512 * (unsigned __int64)v3]);
v11 = 0LL;
fs_split_path(dest, &v16);
result = func0((__int64)dest);
v5 = result;
if ( result )
{
for ( i = 0; (unsigned int)func10((__int64)dest, i, (__int64)s1) && strcmp(s1, s2); ++i )
v13 = 0;
if ( v13 )
{
fs_get_node(dest, &v10);
v7 = *(void (__fastcall **)(__int64, _QWORD, __int64 *))(v5 + 328);
if ( v7 && v10 )
v7(v10, v13, &v11);
result = v11;
if ( !v11 || *(_BYTE *)(v11 + 260) != 1 )
return 0LL;
}
else
{
result = 0LL;
if ( *a2 != 119 )
return result;
fs_get_node(dest, &v11);
result = v11;
if ( !v11 )
return result;
fs_create_node(s2, v11, 1LL, 0LL);
result = v11;
if ( !v11 )
return result;
}
*(_QWORD *)(*(_QWORD *)((char *)&loc_15 + 3) + 272LL) = v5 + 296;
v8 = *(unsigned int (__fastcall **)(__int64, _BYTE *))(v5 + 368);
if ( v8 && !v8(result, a2) )
{
result = 0LL;
}
else
{
result = (int)malloc(0x30uLL);
*(_QWORD *)((char *)&loc_22 + (int)result + 6) = file_list;
*(_QWORD *)((char *)&loc_1D + (int)result + 3) = v5;
*(_QWORD *)((char *)&loc_15 + (int)result + 3) = v11;
file_list = (int)result;
v9 = files_open_n++;
*(_DWORD *)(int)result = v9;
*(_QWORD *)((char *)&loc_7 + (int)result + 1) = 0LL;
}
}
return result;
}

original_code:
file_t *fs_open(char *path_, char *flags)
{
 debug_puts("fs_open()\n");
 file_t *f = 0;
 fs_splitted_path sp;
 char path[1024];
 char name[255];
 uint32_t i;
 struct dirent dir;
 fs_split_path(path_, &sp);
 strcpy(path, "/");
 for(i = 0; i < (sp.i - 1); i++)
 {
  strcat(path, sp.list[i]);
  strcat(path, "/");
 }
 strcpy(name, sp.list[sp.i - 1]);
 inode_t *node = 0;
 fs_split_path(path, &sp);
 driver_t *drv = fs_get_fs_driver(path);
 driver_fs_t *filesystem_struct;
 if(drv == 0)
  return (file_t *) 0;
 filesystem_struct = &drv->fs;
 i = 0;
 while(fs_readdir2(path, i, &dir) != 0)
 {
  if(strcmp(dir.name, name) == 0)
   break;
  else
   dir.inode = 0;
  i++;
 }
 if((dir.inode == 0) && (flags[0] == 'w'))
 {
  fs_get_node(path, &node);
  if(node != 0)
   fs_create_node(name, node, 1, 0);
  else
   return 0;
 }
 else if(dir.inode == 0)
 {
  return 0;
 }
 else if(dir.inode != 0)
 {
  inode_t *node_tmp;
  fs_get_node(path, &node_tmp);
  if(filesystem_struct->get_node != 0 && node_tmp != 0)
   filesystem_struct->get_node(node_tmp, dir.inode, &node);
  if(node == 0 || node->type != 1)
   return 0;
 }
 if(node == 0)
   return 0;
 f->node->fs_driver = filesystem_struct;
 if(filesystem_struct->open != 0)
 {
  if(!filesystem_struct->open(node, flags))
   return (file_t *) 0;
 }
 f = (file_t *) malloc(sizeof(file_t));
 f->next = file_list;
 f->drv = (void *) drv;
 f->node = node;
 file_list = f;
 f->id = files_open_n++;
 f->seek_p = 0;
 return f;
}

canonical_original_code:
struct file_p *fs_open(char *path_, char *flags)
{
 debug_puts("fs_open()\n");
 struct file_p *f = 0;
 struct fs_splitted_path sp;
 char path[1024];
 char name[255];
 unsigned int i;
 struct dirent dir;
 fs_split_path(path_, &sp);
 strcpy(path, "/");
 for(i = 0; i < (sp.i - 1); i++)
 {
  strcat(path, sp.list[i]);
  strcat(path, "/");
 }
 strcpy(name, sp.list[sp.i - 1]);
 struct inode_p *node = 0;
 fs_split_path(path, &sp);
 struct driver_p *drv = fs_get_fs_driver(path);
 struct driver_fs_t *filesystem_struct;
 if(drv == 0)
  return (struct file_p *) 0;
 filesystem_struct = &drv->fs;
 i = 0;
 while(fs_readdir2(path, i, &dir) != 0)
 {
  if(strcmp(dir.name, name) == 0)
   break;
  else
   dir.inode = 0;
  i++;
 }
 if((dir.inode == 0) && (flags[0] == 'w'))
 {
  fs_get_node(path, &node);
  if(node != 0)
   fs_create_node(name, node, 1, 0);
  else
   return 0;
 }
 else if(dir.inode == 0)
 {
  return 0;
 }
 else if(dir.inode != 0)
 {
  struct inode_p *node_tmp;
  fs_get_node(path, &node_tmp);
  if(filesystem_struct->get_node != 0 && node_tmp != 0)
   filesystem_struct->get_node(node_tmp, dir.inode, &node);
  if(node == 0 || node->type != 1)
   return 0;
 }
 if(node == 0)
   return 0;
 f->node->fs_driver = filesystem_struct;
 if(filesystem_struct->open != 0)
 {
  if(!filesystem_struct->open(node, flags))
   return (struct file_p *) 0;
 }
 f = (struct file_p *) malloc(sizeof(file_t));
 f->next = file_list;
 f->drv = (void *) drv;
 f->node = node;
 file_list = f;
 f->id = files_open_n++;
 f->seek_p = 0;
 return f;
}

variable_types:
flags
char *

variable_types: struct fs_splitted_path { unsigned int i; char list[32][512]; }

variable_types:
path
char [1024]

return_type: struct file_p { unsigned int id; unsigned long long seek_p; unsigned long long size; struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *node; void *drv; struct file_p *next; } *


decompiled_code:
__int64 __fastcall fs_readdir(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v4; // esi

debug_puts("fs_readdir()\n");
result = 0LL;
if ( a1 )
{
v4 = *(_DWORD *)(a1 + 16);
*(_DWORD *)(a1 + 16) = v4 + 1;
result = fs_readdir2(a1 + 20, v4, a2);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v4; // esi

debug_puts("fs_readdir()\n");
result = 0LL;
if ( a1 )
{
v4 = *(_DWORD *)(a1 + 16);
*(_DWORD *)(a1 + 16) = v4 + 1;
result = func10(a1 + 20, v4, a2);
}
return result;
}

original_code:
uint32_t fs_readdir(dir_t *dr, struct dirent *dir)
{
 debug_puts("fs_readdir()\n");
 if(dr == 0)
  return 0;
 dr->cur_i++;
 return fs_readdir2(dr->path, (dr->cur_i - 1), dir);
}

canonical_original_code:
unsigned int fs_readdir(struct dir_p *dr, struct dirent *dir)
{
 debug_puts("fs_readdir()\n");
 if(dr == 0)
  return 0;
 dr->cur_i++;
 return fs_readdir2(dr->path, (dr->cur_i - 1), dir);
}


decompiled_code:
__int64 __fastcall fs_link(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
unsigned int v3; // eax
__int64 v4; // r12
unsigned int i; // ebx
__int64 result; // rax
void (__fastcall *v7)(__int64, _QWORD, __int64 *); // rax
unsigned int v8; // ebx
unsigned int v9; // eax
__int64 v10; // [rsp+8h] [rbp-8B60h] BYREF
char v11[256]; // [rsp+10h] [rbp-8B58h] BYREF
char v12[1024]; // [rsp+110h] [rbp-8A58h] BYREF
int v13; // [rsp+510h] [rbp-8658h] BYREF
char v14[16396]; // [rsp+514h] [rbp-8654h] BYREF
__int64 v15; // [rsp+4520h] [rbp-4648h] BYREF
__int64 v16; // [rsp+4528h] [rbp-4640h] BYREF
char s1[256]; // [rsp+4530h] [rbp-4638h] BYREF
unsigned int v18; // [rsp+4630h] [rbp-4538h]
char s2[256]; // [rsp+4640h] [rbp-4528h] BYREF
char dest[1024]; // [rsp+4740h] [rbp-4428h] BYREF
int v21; // [rsp+4B40h] [rbp-4028h] BYREF
char src[16420]; // [rsp+4B44h] [rbp-4024h] BYREF

debug_puts("fs_link()\n");
fs_split_path(a1, &v21);
strcpy(dest, "/");
if ( v21 == 1 )
{
v3 = 0;
}
else
{
v2 = 0;
do
{
strcat(dest, &src[512 * (unsigned __int64)v2]);
strcat(dest, "/");
++v2;
v3 = v21 - 1;
}
while ( v21 - 1 > v2 );
}
strcpy(s2, &src[512 * (unsigned __int64)v3]);
v16 = 0LL;
fs_split_path(dest, &v21);
v4 = fs_get_fs_driver((__int64)dest);
if ( !v4 )
return 1LL;
for ( i = 0; (unsigned int)fs_readdir2((__int64)dest, i, (__int64)s1) && strcmp(s1, s2); ++i )
v18 = 0;
result = 1LL;
if ( v18 )
{
fs_get_node(dest, &v15);
v7 = *(void (__fastcall **)(__int64, _QWORD, __int64 *))(v4 + 328);
if ( v7 && v15 )
v7(v15, v18, &v16);
if ( v16 )
{
result = 3LL;
if ( *(_QWORD *)(v4 + 400) )
{
fs_split_path(a2, &v13);
strcpy(v12, "/");
if ( v13 == 1 )
{
v9 = 0;
}
else
{
v8 = 0;
do
{
strcat(v12, &v14[512 * (unsigned __int64)v8]);
strcat(v12, "/");
++v8;
v9 = v13 - 1;
}
while ( v13 - 1 > v8 );
}
strcpy(v11, &v14[512 * (unsigned __int64)v9]);
fs_get_node(v12, &v10);
if ( v10 )
result = (*(__int64 (__fastcall **)(__int64, char *, __int64, char *))(v4 + 400))(v15, s2, v10, v11);
else
result = 1LL;
}
}
else
{
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
unsigned int v3; // eax
__int64 v4; // r12
unsigned int i; // ebx
__int64 result; // rax
void (__fastcall *v7)(__int64, _QWORD, __int64 *); // rax
unsigned int v8; // ebx
unsigned int v9; // eax
__int64 v10; // [rsp+8h] [rbp-8B60h] BYREF
char v11[256]; // [rsp+10h] [rbp-8B58h] BYREF
char v12[1024]; // [rsp+110h] [rbp-8A58h] BYREF
int v13; // [rsp+510h] [rbp-8658h] BYREF
char v14[16396]; // [rsp+514h] [rbp-8654h] BYREF
__int64 v15; // [rsp+4520h] [rbp-4648h] BYREF
__int64 v16; // [rsp+4528h] [rbp-4640h] BYREF
char s1[256]; // [rsp+4530h] [rbp-4638h] BYREF
unsigned int v18; // [rsp+4630h] [rbp-4538h]
char s2[256]; // [rsp+4640h] [rbp-4528h] BYREF
char dest[1024]; // [rsp+4740h] [rbp-4428h] BYREF
int v21; // [rsp+4B40h] [rbp-4028h] BYREF
char src[16420]; // [rsp+4B44h] [rbp-4024h] BYREF

debug_puts("fs_link()\n");
fs_split_path(a1, &v21);
strcpy(dest, "/");
if ( v21 == 1 )
{
v3 = 0;
}
else
{
v2 = 0;
do
{
strcat(dest, &src[512 * (unsigned __int64)v2]);
strcat(dest, "/");
++v2;
v3 = v21 - 1;
}
while ( v21 - 1 > v2 );
}
strcpy(s2, &src[512 * (unsigned __int64)v3]);
v16 = 0LL;
fs_split_path(dest, &v21);
v4 = func0((__int64)dest);
if ( !v4 )
return 1LL;
for ( i = 0; (unsigned int)func10((__int64)dest, i, (__int64)s1) && strcmp(s1, s2); ++i )
v18 = 0;
result = 1LL;
if ( v18 )
{
fs_get_node(dest, &v15);
v7 = *(void (__fastcall **)(__int64, _QWORD, __int64 *))(v4 + 328);
if ( v7 && v15 )
v7(v15, v18, &v16);
if ( v16 )
{
result = 3LL;
if ( *(_QWORD *)(v4 + 400) )
{
fs_split_path(a2, &v13);
strcpy(v12, "/");
if ( v13 == 1 )
{
v9 = 0;
}
else
{
v8 = 0;
do
{
strcat(v12, &v14[512 * (unsigned __int64)v8]);
strcat(v12, "/");
++v8;
v9 = v13 - 1;
}
while ( v13 - 1 > v8 );
}
strcpy(v11, &v14[512 * (unsigned __int64)v9]);
fs_get_node(v12, &v10);
if ( v10 )
result = (*(__int64 (__fastcall **)(__int64, char *, __int64, char *))(v4 + 400))(v15, s2, v10, v11);
else
result = 1LL;
}
}
else
{
result = 1LL;
}
}
return result;
}

original_code:
uint32_t fs_link(char *file_name, char *link_name)
{
 debug_puts("fs_link()\n");
 fs_splitted_path sp;
 char path[1024];
 char name[255];
 uint32_t i;
 struct dirent dir;
 fs_split_path(file_name, &sp);
 strcpy(path, "/");
 for(i = 0; i < (sp.i - 1); i++)
 {
  strcat(path, sp.list[i]);
  strcat(path, "/");
 }
 strcpy(name, sp.list[sp.i - 1]);
 inode_t *node = 0;
 fs_split_path(path, &sp);
 driver_t *drv = fs_get_fs_driver(path);
 driver_fs_t *filesystem_struct;
 if(drv == 0)
  return 1;
 filesystem_struct = &drv->fs;
 i = 0;
 while(fs_readdir2(path, i, &dir) != 0)
 {
  if(strcmp(dir.name, name) == 0)
   break;
  else
   dir.inode = 0;
  i++;
 }
 inode_t *node_tmp;
 if(dir.inode == 0)
 {
  return 1;
 }
 else if(dir.inode != 0)
 {
  fs_get_node(path, &node_tmp);
  if(filesystem_struct->get_node != 0 && node_tmp != 0)
   filesystem_struct->get_node(node_tmp, dir.inode, &node);
 }
 if(node == 0)
  return 1;
 if(filesystem_struct->link != 0)
 {
  fs_splitted_path sp2;
  char path2[1024];
  char name2[255];
  fs_split_path(link_name, &sp2);
  strcpy(path2, "/");
  for(i = 0; i < (sp2.i - 1); i++)
  {
   strcat(path2, sp2.list[i]);
   strcat(path2, "/");
  }
  strcpy(name2, sp2.list[sp2.i - 1]);
  inode_t *dest_root;
  fs_get_node(path2, &dest_root);
  if(dest_root == 0)
   return 1;
  if(!filesystem_struct->link(node_tmp, name, dest_root, name2))
   return 0;
 }
 else
  return 3;
}

canonical_original_code:
unsigned int fs_link(char *file_name, char *link_name)
{
 debug_puts("fs_link()\n");
 struct fs_splitted_path sp;
 char path[1024];
 char name[255];
 unsigned int i;
 struct dirent dir;
 fs_split_path(file_name, &sp);
 strcpy(path, "/");
 for(i = 0; i < (sp.i - 1); i++)
 {
  strcat(path, sp.list[i]);
  strcat(path, "/");
 }
 strcpy(name, sp.list[sp.i - 1]);
 struct inode_p *node = 0;
 fs_split_path(path, &sp);
 struct driver_p *drv = fs_get_fs_driver(path);
 struct driver_fs_t *filesystem_struct;
 if(drv == 0)
  return 1;
 filesystem_struct = &drv->fs;
 i = 0;
 while(fs_readdir2(path, i, &dir) != 0)
 {
  if(strcmp(dir.name, name) == 0)
   break;
  else
   dir.inode = 0;
  i++;
 }
 struct inode_p *node_tmp;
 if(dir.inode == 0)
 {
  return 1;
 }
 else if(dir.inode != 0)
 {
  fs_get_node(path, &node_tmp);
  if(filesystem_struct->get_node != 0 && node_tmp != 0)
   filesystem_struct->get_node(node_tmp, dir.inode, &node);
 }
 if(node == 0)
  return 1;
 if(filesystem_struct->link != 0)
 {
  struct fs_splitted_path sp2;
  char path2[1024];
  char name2[255];
  fs_split_path(link_name, &sp2);
  strcpy(path2, "/");
  for(i = 0; i < (sp2.i - 1); i++)
  {
   strcat(path2, sp2.list[i]);
   strcat(path2, "/");
  }
  strcpy(name2, sp2.list[sp2.i - 1]);
  struct inode_p *dest_root;
  fs_get_node(path2, &dest_root);
  if(dest_root == 0)
   return 1;
  if(!filesystem_struct->link(node_tmp, name, dest_root, name2))
   return 0;
 }
 else
  return 3;
}

variable_types:
name
char [255]

variable_types:
i
unsigned int

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


decompiled_code:
__int64 __fastcall fs_unlink(__int64 a1)
{
unsigned int v1; // ebx
unsigned int v2; // eax
__int64 result; // rax
__int64 v4; // rax
__int64 (__fastcall *v5)(__int64, char *); // rax
char v6[256]; // [rsp+0h] [rbp-4528h] BYREF
char dest[1032]; // [rsp+100h] [rbp-4428h] BYREF
__int64 v8; // [rsp+508h] [rbp-4020h] BYREF
int v9; // [rsp+510h] [rbp-4018h] BYREF
char src[16404]; // [rsp+514h] [rbp-4014h] BYREF

debug_puts("fs_unlink()\n");
v8 = 0LL;
fs_split_path(a1, &v9);
strcpy(dest, "/");
if ( v9 == 1 )
{
v2 = 0;
}
else
{
v1 = 0;
do
{
strcat(dest, &src[512 * (unsigned __int64)v1]);
strcat(dest, "/");
++v1;
v2 = v9 - 1;
}
while ( v9 - 1 > v1 );
}
strcpy(v6, &src[512 * (unsigned __int64)v2]);
fs_get_node(dest, &v8);
result = 0LL;
if ( v8 )
{
v4 = fs_get_fs_driver((__int64)dest);
if ( v4 )
{
v5 = *(__int64 (__fastcall **)(__int64, char *))(v4 + 408);
if ( v5 )
result = v5(v8, v6);
else
result = 3LL;
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
unsigned int v1; // ebx
unsigned int v2; // eax
__int64 result; // rax
__int64 v4; // rax
__int64 (__fastcall *v5)(__int64, char *); // rax
char v6[256]; // [rsp+0h] [rbp-4528h] BYREF
char dest[1032]; // [rsp+100h] [rbp-4428h] BYREF
__int64 v8; // [rsp+508h] [rbp-4020h] BYREF
int v9; // [rsp+510h] [rbp-4018h] BYREF
char src[16404]; // [rsp+514h] [rbp-4014h] BYREF

debug_puts("fs_unlink()\n");
v8 = 0LL;
fs_split_path(a1, &v9);
strcpy(dest, "/");
if ( v9 == 1 )
{
v2 = 0;
}
else
{
v1 = 0;
do
{
strcat(dest, &src[512 * (unsigned __int64)v1]);
strcat(dest, "/");
++v1;
v2 = v9 - 1;
}
while ( v9 - 1 > v1 );
}
strcpy(v6, &src[512 * (unsigned __int64)v2]);
fs_get_node(dest, &v8);
result = 0LL;
if ( v8 )
{
v4 = func0((__int64)dest);
if ( v4 )
{
v5 = *(__int64 (__fastcall **)(__int64, char *))(v4 + 408);
if ( v5 )
result = v5(v8, v6);
else
result = 3LL;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
uint32_t fs_unlink(char *path_)
{
 debug_puts("fs_unlink()\n");
 fs_splitted_path sp;
 inode_t *node = 0;
 char path[1024];
 char name[255];
 uint32_t i;
 fs_split_path(path_, &sp);
 strcpy(path, "/");
 for(i = 0; i < (sp.i - 1); i++)
 {
  strcat(path, sp.list[i]);
  strcat(path, "/");
 }
 strcpy(name, sp.list[sp.i - 1]);
 fs_get_node(path, &node);
 if(node == 0)
  return 0;
 driver_t *drv = fs_get_fs_driver(path);
 driver_fs_t *filesystem_struct;
 if(drv != 0)
  filesystem_struct = &drv->fs;
 else
  return 0;
 if(filesystem_struct->unlink != 0)
  return filesystem_struct->unlink(node, name);
 else
 {
  return 3;
 }
}

canonical_original_code:
unsigned int fs_unlink(char *path_)
{
 debug_puts("fs_unlink()\n");
 struct fs_splitted_path sp;
 struct inode_p *node = 0;
 char path[1024];
 char name[255];
 unsigned int i;
 fs_split_path(path_, &sp);
 strcpy(path, "/");
 for(i = 0; i < (sp.i - 1); i++)
 {
  strcat(path, sp.list[i]);
  strcat(path, "/");
 }
 strcpy(name, sp.list[sp.i - 1]);
 fs_get_node(path, &node);
 if(node == 0)
  return 0;
 struct driver_p *drv = fs_get_fs_driver(path);
 struct driver_fs_t *filesystem_struct;
 if(drv != 0)
  filesystem_struct = &drv->fs;
 else
  return 0;
 if(filesystem_struct->unlink != 0)
  return filesystem_struct->unlink(node, name);
 else
 {
  return 3;
 }
}

variable_types: struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } *


decompiled_code:
int __fastcall sock_shutdown(int a1)
{
LODWORD(sockets[2056 * a1 + 4]) = 0;
return printf("shutdown ok\n");
}

canonical_decompiled_code:
int __fastcall func1(int a1)
{
LODWORD(sockets[2056 * a1 + 4]) = 0;
return printf("shutdown ok\n");
}

original_code:
int sock_shutdown(int sockfd, int how)
{
 {
  sockets[sockfd].used = 0;
  printf("shutdown ok\n");
 }
}

variable_types: sockfd int

variable_types: how int


decompiled_code:
__int64 __fastcall sock_connect(int a1, __int64 a2, unsigned int a3)
{
unsigned int i; // ebx
__int64 result; // rax
__int64 v6[6]; // [rsp+8h] [rbp-30h] BYREF

for ( i = 0; ; ++i )
{
result = route_iget(i, v6);
if ( !(_DWORD)result )
break;
if ( !strncmp((const char *)(a2 + 4), (const char *)(v6[0] + 4), a3) )
{
sockets[2056 * a1] = *(_QWORD *)(v6[0] + 24);
printf("found a valid routing rule for this address\n");
return 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, __int64 a2, unsigned int a3)
{
unsigned int i; // ebx
__int64 result; // rax
__int64 v6[6]; // [rsp+8h] [rbp-30h] BYREF

for ( i = 0; ; ++i )
{
result = route_iget(i, v6);
if ( !(_DWORD)result )
break;
if ( !strncmp((const char *)(a2 + 4), (const char *)(v6[0] + 4), a3) )
{
sockets[2056 * a1] = *(_QWORD *)(v6[0] + 24);
printf("found a valid routing rule for this address\n");
return 0LL;
}
}
return result;
}

original_code:
int sock_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
{
 int i = 0;
 route_entry_t *re;
 while(route_iget(i, &re))
 {
  if(strncmp((char *) addr->sa_data, (char *) re->dest, addrlen) == 0)
  {
   sockets[sockfd].iface = re->iface;
   printf("found a valid routing rule for this address\n");
   return 0;
  }
  i++;
 }
}

canonical_original_code:
int sock_connect(int sockfd, struct sockaddr *addr, unsigned int addrlen)
{
 int i = 0;
 struct route_entry_p *re;
 while(route_iget(i, &re))
 {
  if(strncmp((char *) addr->sa_data, (char *) re->dest, addrlen) == 0)
  {
   sockets[sockfd].iface = re->iface;
   printf("found a valid routing rule for this address\n");
   return 0;
  }
  i++;
 }
}

variable_types: struct sockaddr { unsigned int sa_family; char sa_data[14]; } *

variable_types:
addrlen
unsigned int

variable_types: i int

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

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

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


decompiled_code:
void sock_sendto()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
uint32_t sock_sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen)
{
}

canonical_original_code:
unsigned int sock_sendto(int sockfd, void *buf, unsigned int len, int flags, struct sockaddr *dest_addr, unsigned int addrlen)
{
}

variable_types:
buf
void *

variable_types:
len
unsigned int

variable_types: flags int

user_defined_types: struct sockaddr { unsigned int sa_family; char sa_data[14]; }


decompiled_code:
void sock_recvfrom()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
uint32_t sock_recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen)
{
}

canonical_original_code:
unsigned int sock_recvfrom(int sockfd, void *buf, unsigned int len, int flags, struct sockaddr *src_addr, unsigned int *addrlen)
{
}

variable_types:
addrlen
unsigned int *


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

result = 0LL;
if ( a1 <= 0x400 )
{
*a2 = &sockets[2056 * a1];
result = 1LL;
}
return result;
}

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

result = 0LL;
if ( a1 <= 0x400 )
{
*a2 = &sockets[2056 * a1];
result = 1LL;
}
return result;
}

original_code:
uint32_t sock_iget(uint32_t x, socket_t **s)
{
 if(x > 1024)
  return 0;
 *s = &sockets[x];
 return 1;
}

canonical_original_code:
unsigned int sock_iget(unsigned int x, struct socket_t **s)
{
 if(x > 1024)
  return 0;
 *s = &sockets[x];
 return 1;
}

variable_types:
x
unsigned int

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

user_defined_types: struct socket_t { struct network_iface_p *iface; unsigned int protocol; unsigned int type; unsigned int domain; unsigned char is_server; unsigned short port; char addr[4]; int uid; unsigned int used; char rec_buf[8192]; int rec_p1; int rec_p2; int rec_data_len; char send_buf[8192]; int send_p1; int send_p2; int send_data_len; }


decompiled_code:
__int64 __fastcall sock_bind(unsigned int a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

sock_iget(a1, &v3);
result = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
*(_BYTE *)(v3 + 20) = 1;
*(_WORD *)(result + 22) = *(_DWORD *)(a2 + 4);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

func5(a1, &v3);
result = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
*(_BYTE *)(v3 + 20) = 1;
*(_WORD *)(result + 22) = *(_DWORD *)(a2 + 4);
return result;
}

original_code:
int sock_bind(int sockfd, const struct sockaddr_in *addr, socklen_t addrlen)
{
 socket_t *sock;
 sock_iget(sockfd, &sock);
 if(sock == 0)
  return -1;
 sock->is_server = 1;
 sock->port = addr->sin_port;
}

canonical_original_code:
int sock_bind(int sockfd, struct sockaddr_in *addr, unsigned int addrlen)
{
 struct socket_t *sock;
 sock_iget(sockfd, &sock);
 if(sock == 0)
  return -1;
 sock->is_server = 1;
 sock->port = addr->sin_port;
}

variable_types: struct sockaddr_in { unsigned int sin_family; unsigned int sin_port; struct in_addr { unsigned int s_addr; } sin_addr; } *

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

user_defined_types: struct sockaddr_in { unsigned int sin_family; unsigned int sin_port; struct in_addr sin_addr; }


decompiled_code:
__int64 __fastcall sock_send(unsigned int a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

sock_iget(a1, v5);
printf("sending sock pack\n");
result = 0xFFFFFFFFLL;
if ( v5[0] )
{
result = packet_create(a2, a3);
if ( *(_DWORD *)(v5[0] + 12) == 2 )
result = udp_send_packet(v5[0], result);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

func5(a1, v5);
printf("sending sock pack\n");
result = 0xFFFFFFFFLL;
if ( v5[0] )
{
result = packet_create(a2, a3);
if ( *(_DWORD *)(v5[0] + 12) == 2 )
result = udp_send_packet(v5[0], result);
}
return result;
}

original_code:
uint32_t sock_send(int sockfd, const void *buf, size_t len, int flags)
{
 socket_t *sock;
 sock_iget(sockfd, &sock);
 printf("sending sock pack\n");
 if(sock == 0)
  return -1;
 packet_t *p = packet_create((char *) buf, len);
 if(sock->type == 0x02)
  return udp_send_packet(sock, p);
}

canonical_original_code:
unsigned int sock_send(int sockfd, void *buf, unsigned int len, int flags)
{
 struct socket_t *sock;
 sock_iget(sockfd, &sock);
 printf("sending sock pack\n");
 if(sock == 0)
  return -1;
 struct packet_t *p = packet_create((char *) buf, len);
 if(sock->type == 0x02)
  return udp_send_packet(sock, p);
}

variable_types: struct packet_t { unsigned int size; char *data; } *


original_code:
uint32_t sock_recv(int sockfd, void *buf_, size_t len, int flags)
{
 socket_t *sock;
 sock_iget(sockfd, &sock);
 if(sock == 0)
  return -1;
 if(sock->rec_data_len > 0)
 {
  unsigned i;
  for(i = 0; i < len; i++)
  {
   char *buf = buf_;
   buf[i] = sock->rec_buf[sock->rec_p2];
   sock->rec_p2++;
   if(sock->rec_p2 >= sock->rec_p1)
    return i;
   sock->rec_data_len--;
  }
  return len;
 }
 return -1;
}

canonical_original_code:
unsigned int sock_recv(int sockfd, void *buf_, unsigned int len, int flags)
{
 struct socket_t *sock;
 sock_iget(sockfd, &sock);
 if(sock == 0)
  return -1;
 if(sock->rec_data_len > 0)
 {
  unsigned int i;
  for(i = 0; i < len; i++)
  {
   char *buf = buf_;
   buf[i] = sock->rec_buf[sock->rec_p2];
   sock->rec_p2++;
   if(sock->rec_p2 >= sock->rec_p1)
    return i;
   sock->rec_data_len--;
  }
  return len;
 }
 return -1;
}

variable_types:
i
unsigned int

variable_types:
buf
char *


decompiled_code:
int sock_test()
{
unsigned int v0; // ebx
unsigned int v1; // ebp
int result; // eax
char v3[16]; // [rsp+0h] [rbp-48h] BYREF
int v4; // [rsp+10h] [rbp-38h] BYREF
char v5[16]; // [rsp+14h] [rbp-34h] BYREF
int v6[9]; // [rsp+24h] [rbp-24h] BYREF

printf("\nsock_test()\n");
v0 = socket(1LL, 2);
v6[0] = 1;
v6[1] = 24;
sock_bind(v0, (__int64)v6);
v1 = socket(1LL, 2);
network_toaddr(v5, 127LL, 0LL, 0LL, 1LL);
v4 = 1;
sock_connect(v1, (__int64)&v4, 4u);
sock_send(v1, (__int64)"ciao", 5u);
result = sock_recv(v0, (__int64)v3, 0x10u);
if ( result != -1 )
result = printf("Received packet data: %s\n\n", v3);
return result;
}

canonical_decompiled_code:
int func9()
{
unsigned int v0; // ebx
unsigned int v1; // ebp
int result; // eax
char v3[16]; // [rsp+0h] [rbp-48h] BYREF
int v4; // [rsp+10h] [rbp-38h] BYREF
char v5[16]; // [rsp+14h] [rbp-34h] BYREF
int v6[9]; // [rsp+24h] [rbp-24h] BYREF

printf("\nsock_test()\n");
v0 = func0(1LL, 2);
v6[0] = 1;
v6[1] = 24;
func6(v0, (__int64)v6);
v1 = func0(1LL, 2);
network_toaddr(v5, 127LL, 0LL, 0LL, 1LL);
v4 = 1;
func2(v1, (__int64)&v4, 4u);
func7(v1, (__int64)"ciao", 5u);
result = func8(v0, (__int64)v3, 0x10u);
if ( result != -1 )
result = printf("Received packet data: %s\n\n", v3);
return result;
}

original_code:
void sock_test()
{
 printf("\nsock_test()\n");
 int sock_s = socket(0x01, 0x02, 0);
 struct sockaddr_in s;
 s.sin_family = 0x01;
    s.sin_port = 24;
 sock_bind(sock_s, &s, sizeof(s));
 int sock_c = socket(0x01, 0x02, 0);
 struct sockaddr c;
 network_toaddr(c.sa_data, 127, 0, 0, 1);
 c.sa_family = 0x01;
 sock_connect(sock_c, &c, 4);
 sock_send(sock_c, "ciao\0", 5, 0);
 char buf[16];
 if(sock_recv(sock_s, buf, 16, 0) != -1)
  printf("Received packet data: %s\n\n", buf);
}

variable_types: struct sockaddr_in { unsigned int sin_family; unsigned int sin_port; struct in_addr { unsigned int s_addr; } sin_addr; }

variable_types: struct sockaddr { unsigned int sa_family; char sa_data[14]; }

variable_types:
buf
char [16]


socket

decompiled_code:
__int64 __fastcall socket(__int64 a1, int a2)
{
unsigned int v2; // ebx
unsigned int v3; // eax
__int64 v4; // rcx
unsigned int v5; // edx
__int64 v6; // rax
int v7; // ecx

v2 = sock_first_free;
v3 = task_get_pid();
HIDWORD(sockets[2056 * (int)v2 + 3]) = task_get_uid(v3);
if ( a2 == 2 )
{
HIDWORD(sockets[2056 * (int)v2 + 1]) = 2;
}
else
{
if ( a2 != 1 )
return (unsigned int)-1;
HIDWORD(sockets[2056 * (int)v2 + 1]) = 1;
}
LODWORD(sockets[2056 * (int)v2 + 4]) = 1;
HIDWORD(sockets[2056 * (int)v2 + 2054]) = 0;
LODWORD(sockets[2056 * (int)v2 + 2054]) = 0;
LODWORD(sockets[2056 * (int)v2 + 1029]) = 0;
HIDWORD(sockets[2056 * (int)v2 + 1028]) = 0;
HIDWORD(sockets[2056 * (int)v2 + 1029]) = 0;
v4 = 2056LL * (int)v2;
LODWORD(sockets[v4 + 2055]) = 0;
sockets[v4] = 0LL;
if ( LODWORD(sockets[2056 * (unsigned int)sock_first_free + 4]) )
{
v5 = sock_first_free + 1;
do
{
v6 = 2056LL * v5;
v7 = v5++;
}
while ( LODWORD(sockets[v6 + 4]) );
sock_first_free = v7;
}
printf("created socket %d\n", v2);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
unsigned int v2; // ebx
unsigned int v3; // eax
__int64 v4; // rcx
unsigned int v5; // edx
__int64 v6; // rax
int v7; // ecx

v2 = sock_first_free;
v3 = task_get_pid();
HIDWORD(sockets[2056 * (int)v2 + 3]) = task_get_uid(v3);
if ( a2 == 2 )
{
HIDWORD(sockets[2056 * (int)v2 + 1]) = 2;
}
else
{
if ( a2 != 1 )
return (unsigned int)-1;
HIDWORD(sockets[2056 * (int)v2 + 1]) = 1;
}
LODWORD(sockets[2056 * (int)v2 + 4]) = 1;
HIDWORD(sockets[2056 * (int)v2 + 2054]) = 0;
LODWORD(sockets[2056 * (int)v2 + 2054]) = 0;
LODWORD(sockets[2056 * (int)v2 + 1029]) = 0;
HIDWORD(sockets[2056 * (int)v2 + 1028]) = 0;
HIDWORD(sockets[2056 * (int)v2 + 1029]) = 0;
v4 = 2056LL * (int)v2;
LODWORD(sockets[v4 + 2055]) = 0;
sockets[v4] = 0LL;
if ( LODWORD(sockets[2056 * (unsigned int)sock_first_free + 4]) )
{
v5 = sock_first_free + 1;
do
{
v6 = 2056LL * v5;
v7 = v5++;
}
while ( LODWORD(sockets[v6 + 4]) );
sock_first_free = v7;
}
printf("created socket %d\n", v2);
return v2;
}

original_code:
int socket(uint32_t domain, uint32_t type, uint32_t protocol)
{
 int sock;
 sock = sock_first_free;
 sockets[sock].uid = task_get_uid(task_get_pid());
  if(type == 0x02)
  {
   sockets[sock].type = 0x02;
  }
  else if(type == 0x01)
  {
   sockets[sock].type = 0x01;
  }
  else
  {
   return -1;
  }
 sockets[sock].used = 1;
 sockets[sock].send_p1 = sockets[sock].send_p2 = 0;
 sockets[sock].rec_p1 = sockets[sock].rec_p2 = 0;
 sockets[sock].send_data_len = sockets[sock].rec_data_len = 0;
 sockets[sock].iface = 0;
 while(sockets[sock_first_free].used)
  sock_first_free++;
 printf("created socket %d\n", sock);
 return sock;
}

canonical_original_code:
int socket(unsigned int domain, unsigned int type, unsigned int protocol)
{
 int sock;
 sock = sock_first_free;
 sockets[sock].uid = task_get_uid(task_get_pid());
  if(type == 0x02)
  {
   sockets[sock].type = 0x02;
  }
  else if(type == 0x01)
  {
   sockets[sock].type = 0x01;
  }
  else
  {
   return -1;
  }
 sockets[sock].used = 1;
 sockets[sock].send_p1 = sockets[sock].send_p2 = 0;
 sockets[sock].rec_p1 = sockets[sock].rec_p2 = 0;
 sockets[sock].send_data_len = sockets[sock].rec_data_len = 0;
 sockets[sock].iface = 0;
 while(sockets[sock_first_free].used)
  sock_first_free++;
 printf("created socket %d\n", sock);
 return sock;
}

variable_types:
domain
unsigned int

variable_types:
type
unsigned int

variable_types:
protocol
unsigned int

variable_types: sock int


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

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

original_code:
uint32_t ata_pio_probe(device_t *dev)
{
 return 1;
}

canonical_original_code:
unsigned int ata_pio_probe(struct device_p *dev)
{
 return 1;
}

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


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

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

original_code:
uint32_t ata_pio_free()
{
 return 0;
}

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


decompiled_code:
void ata_pio_read()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
uint32_t ata_pio_read(device_t *dev, char *data, uint32_t size, uint64_t off)
{
}

canonical_original_code:
unsigned int ata_pio_read(struct device_p *dev, char *data, unsigned int size, unsigned long long off)
{
}

variable_types:
data
char *

variable_types:
size
unsigned int

variable_types:
off
unsigned long long


decompiled_code:
void ata_pio_write()
{
;
}

original_code:
uint32_t ata_pio_write(device_t *dev, char *data, uint32_t size, uint64_t off)
{
}

canonical_original_code:
unsigned int ata_pio_write(struct device_p *dev, char *data, unsigned int size, unsigned long long off)
{
}


decompiled_code:
__int64 ata_pio_init()
{
devfs_reg_device(0LL, 0LL, "ata0");
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
devfs_reg_device(0LL, 0LL, "ata0");
return 0LL;
}

original_code:
uint32_t ata_pio_init()
{
 devfs_reg_device(0, 0, "ata0");
 return 0;
}

canonical_original_code:
unsigned int ata_pio_init()
{
 devfs_reg_device(0, 0, "ata0");
 return 0;
}


connect

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

original_code:
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
{
 return 0;
}

canonical_original_code:
int connect(int sockfd, struct sockaddr *addr, unsigned int addrlen)
{
 return 0;
}

variable_types: sockfd int

variable_types:
addr
struct sockaddr { char a; } *

variable_types:
addrlen
unsigned int


send

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

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

original_code:
ssize_t send(int sockfd, const void *buf, size_t len, int flags)
{
 return 0;
}

canonical_original_code:
unsigned int send(int sockfd, void *buf, unsigned int len, int flags)
{
 return 0;
}

variable_types:
buf
void *

variable_types:
len
unsigned int

variable_types: flags int


sendto

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

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

original_code:
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen)
{
 return 0;
}

canonical_original_code:
unsigned int sendto(int sockfd, void *buf, unsigned int len, int flags, struct sockaddr *dest_addr, unsigned int addrlen)
{
 return 0;
}


recv

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

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

original_code:
ssize_t recv(int sockfd, void *buf, size_t len, int flags)
{
 return 0;
}

canonical_original_code:
unsigned int recv(int sockfd, void *buf, unsigned int len, int flags)
{
 return 0;
}


recvfrom

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

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

original_code:
ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen)
{
 return 0;
}

canonical_original_code:
unsigned int recvfrom(int sockfd, void *buf, unsigned int len, int flags, struct sockaddr *src_addr, unsigned int *addrlen)
{
 return 0;
}

variable_types:
addrlen
unsigned int *


shutdown

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

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

original_code:
int shutdown(int sockfd, int how)
{
 return 0;
}

variable_types: how int


socket

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

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

original_code:
int socket(int domain, int type, int protocol)
{
 return 0;
}

variable_types: domain int

variable_types: type int

variable_types: protocol int


decompiled_code:
_BOOL8 log_stat()
{
return log_file != 0;
}

canonical_decompiled_code:
_BOOL8 func0()
{
return log_file != 0;
}

original_code:
uint32_t log_stat()
{
 if(log_file != 0)
  return 1;
 else
  return 0;
}

canonical_original_code:
unsigned int log_stat()
{
 if(log_file != 0)
  return 1;
 else
  return 0;
}


decompiled_code:
__int64 __fastcall log_write(const char *a1)
{
__int64 result; // rax
unsigned int v2; // eax

result = 0LL;
if ( log_file )
{
v2 = strlen(a1);
result = fs_write(log_file, a1, v2);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
__int64 result; // rax
unsigned int v2; // eax

result = 0LL;
if ( log_file )
{
v2 = strlen(a1);
result = fs_write(log_file, a1, v2);
}
return result;
}

original_code:
uint32_t log_write(char *buf)
{
 if(log_file != 0)
  return fs_write(log_file, buf, strlen(buf));
 return 0;
}

canonical_original_code:
unsigned int log_write(char *buf)
{
 if(log_file != 0)
  return fs_write(log_file, buf, strlen(buf));
 return 0;
}

variable_types:
buf
char *


decompiled_code:
__int64 log_init()
{
fs_makedir("/log");
log_file = fs_open("/log/syslog.txt", "w");
return log_write("log started\n");
}

canonical_decompiled_code:
__int64 func2()
{
fs_makedir("/log");
log_file = fs_open("/log/syslog.txt", "w");
return func1("log started\n");
}

original_code:
void log_init()
{
 fs_makedir("/log");
 log_file = fs_open("/log/syslog.txt", "w");
 log_write("log started\n");
}


strlen

decompiled_code:
__int64 __fastcall strlen(_BYTE *a1)
{
_BYTE *v1; // rax
unsigned int v2; // ecx

if ( !*a1 )
return 0;
v1 = a1 + 1;
do
v2 = (_DWORD)v1++ - (_DWORD)a1;
while ( *(v1 - 1) );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1)
{
_BYTE *v1; // rax
unsigned int v2; // ecx

if ( !*a1 )
return 0;
v1 = a1 + 1;
do
v2 = (_DWORD)v1++ - (_DWORD)a1;
while ( *(v1 - 1) );
return v2;
}

original_code:
size_t strlen(const char *str)
{
 size_t x = 0;
 while(*str++ != '\0') x++;
 return x;
}

canonical_original_code:
unsigned int strlen(char *str)
{
 unsigned int x = 0;
 while(*str++ != '\0') x++;
 return x;
}

variable_types:
str
char *

variable_types:
x
unsigned int


decompiled_code:
__int64 __fastcall strncpy2(_BYTE *a1, __int64 a2, unsigned int a3)
{
return strcpy(a1, (unsigned __int8 *)(a3 + a2));
}

canonical_decompiled_code:
__int64 __fastcall func2(_BYTE *a1, __int64 a2, unsigned int a3)
{
return func1(a1, (unsigned __int8 *)(a3 + a2));
}

original_code:
void strncpy2(char *str1, char *str2, size_t n)
{
 int i = 0;
 str2 = str2 + n;
 strcpy(str1, str2);
}

canonical_original_code:
void strncpy2(char *str1, char *str2, unsigned int n)
{
 int i = 0;
 str2 = str2 + n;
 strcpy(str1, str2);
}

variable_types:
n
unsigned int

variable_types: i int


strcmp

decompiled_code:
__int64 __fastcall strcmp(unsigned __int8 *a1, unsigned __int8 *a2)
{
unsigned __int8 v2; // dl
unsigned __int8 v3; // cl
__int64 v4; // rax

v2 = *a1;
v3 = *a2;
if ( *a1 != *a2 )
return 1LL;
v4 = 1LL;
while ( v3 | v2 )
{
v2 = a1[v4++];
v3 = a2[v4 - 1];
if ( v2 != v3 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int8 *a1, unsigned __int8 *a2)
{
unsigned __int8 v2; // dl
unsigned __int8 v3; // cl
__int64 v4; // rax

v2 = *a1;
v3 = *a2;
if ( *a1 != *a2 )
return 1LL;
v4 = 1LL;
while ( v3 | v2 )
{
v2 = a1[v4++];
v3 = a2[v4 - 1];
if ( v2 != v3 )
return 1LL;
}
return 0LL;
}

original_code:
int strcmp(const char *s1, const char *s2)
{
 while(1)
 {
  if(*s1 != *s2) return 1;
  else if(*s1 == '\0' && *s2 == '\0') return 0;
  s1++;
  s2++;
 }
}


strncmp

decompiled_code:
__int64 __fastcall strncmp(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v3; // rcx
__int64 v4; // rax
char v5; // dl

if ( !a3 )
return 0LL;
v3 = a3;
v4 = 0LL;
while ( 1 )
{
v5 = *(_BYTE *)(a1 + v4);
if ( v5 != *(_BYTE *)(a2 + v4) )
return 1LL;
if ( !v5 )
break;
if ( ++v4 == v3 )
return 0LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v3; // rcx
__int64 v4; // rax
char v5; // dl

if ( !a3 )
return 0LL;
v3 = a3;
v4 = 0LL;
while ( 1 )
{
v5 = *(_BYTE *)(a1 + v4);
if ( v5 != *(_BYTE *)(a2 + v4) )
return 1LL;
if ( !v5 )
break;
if ( ++v4 == v3 )
return 0LL;
}
return 0LL;
}

original_code:
int strncmp(const char *s1, const char *s2, size_t dim)
{
 int a = 0;
 while(a < dim)
 {
  if(*s1 != *s2) return 1;
  else if(*s1 == '\0' && *s2 == '\0') return 0;
  s1++;
  s2++;
  a++;
 }
 return 0;
}

canonical_original_code:
int strncmp(char *s1, char *s2, unsigned int dim)
{
 int a = 0;
 while(a < dim)
 {
  if(*s1 != *s2) return 1;
  else if(*s1 == '\0' && *s2 == '\0') return 0;
  s1++;
  s2++;
  a++;
 }
 return 0;
}

variable_types:
dim
unsigned int

variable_types: a int


memmove

decompiled_code:
void memmove()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void *memmove(void *a, void *b, size_t dim)
{
}

canonical_original_code:
void *memmove(void *a, void *b, unsigned int dim)
{
}

variable_types:
a
void *

variable_types:
b
void *

return_type: void *


memcmp

decompiled_code:
void memcmp()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
int memcmp(const void *a, const void *b, size_t dim)
{
}

canonical_original_code:
int memcmp(void *a, void *b, unsigned int dim)
{
}


decompiled_code:
void ne2k_ioctl()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
uint32_t ne2k_ioctl(device_t *d, uint32_t call, uint32_t a, uint32_t b)
{
 switch(call)
 {
  default:
   break;
 }
}

canonical_original_code:
unsigned int ne2k_ioctl(struct device_p *d, unsigned int call, unsigned int a, unsigned int b)
{
 switch(call)
 {
  default:
   break;
 }
}

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

variable_types:
call
unsigned int

variable_types:
a
unsigned int

variable_types:
b
unsigned int


decompiled_code:
__int64 __fastcall ne2k_probe()
{
unsigned int v0; // ebp
void **v1; // rbx
__int64 v2; // rax
__int64 result; // rax
__int64 v4[4]; // [rsp+8h] [rbp-20h] BYREF

while ( 1 )
{
result = device_iget(v0, v4);
if ( (_DWORD)result )
break;
if ( *(_BYTE *)(v4[0] + 228) == 1 )
{
v1 = &ne2k_dev_list;
do
{
v2 = *(_QWORD *)(v4[0] + 232);
if ( *(_DWORD *)(v2 + 32) == *((_DWORD *)v1 + 1) && *(_DWORD *)(v2 + 28) == *(_DWORD *)v1 )
printf("found ne2k\n");
++v1;
}
while ( v1 != (void **)(unsigned int)((_DWORD)&ne2k_dev_list + 64) );
}
++v0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1()
{
unsigned int v0; // ebp
void **v1; // rbx
__int64 v2; // rax
__int64 result; // rax
__int64 v4[4]; // [rsp+8h] [rbp-20h] BYREF

while ( 1 )
{
result = device_iget(v0, v4);
if ( (_DWORD)result )
break;
if ( *(_BYTE *)(v4[0] + 228) == 1 )
{
v1 = &ne2k_dev_list;
do
{
v2 = *(_QWORD *)(v4[0] + 232);
if ( *(_DWORD *)(v2 + 32) == *((_DWORD *)v1 + 1) && *(_DWORD *)(v2 + 28) == *(_DWORD *)v1 )
printf("found ne2k\n");
++v1;
}
while ( v1 != (void **)(unsigned int)((_DWORD)&ne2k_dev_list + 64) );
}
++v0;
}
return result;
}

original_code:
uint32_t ne2k_probe(device_t *d)
{
 uint32_t i, j;
 device_t *dev;
 while(device_iget(i, &dev) == 0)
 {
   if(dev->bus_type == 0x01)
   {
    for(j = 0; j < sizeof(sizeof(ne2k_dev_list) / sizeof(pci_id_entry_t)); j++)
    {
     if( (((pci_device_t *) (dev->pci_dev))->device_id == ne2k_dev_list[j].device_id) &&
      (((pci_device_t *) (dev->pci_dev))->vendor_id == ne2k_dev_list[j].vendor_id))
     {
      printf("found ne2k\n");
     }
    }
   }
  i++;
 }
}

canonical_original_code:
unsigned int ne2k_probe(struct device_p *d)
{
 unsigned int i; unsigned int j;
 struct device_p *dev;
 while(device_iget(i, &dev) == 0)
 {
   if(dev->bus_type == 0x01)
   {
    for(j = 0; j < sizeof(sizeof(ne2k_dev_list) / sizeof(pci_id_entry_t)); j++)
    {
     if( (((struct pci_device_t *) (dev->pci_dev))->device_id == ne2k_dev_list[j].device_id) &&
      (((struct pci_device_t *) (dev->pci_dev))->vendor_id == ne2k_dev_list[j].vendor_id))
     {
      printf("found ne2k\n");
     }
    }
   }
  i++;
 }
}

variable_types:
i
unsigned int

variable_types:
j
unsigned int

user_defined_types: struct pci_device_t { unsigned int bus; unsigned int function; unsigned int device; unsigned int command; unsigned int status; unsigned int rev_id; unsigned int iface; unsigned int vendor_id; unsigned int device_id; unsigned int class_id; unsigned int subclass_id; unsigned int bar[6]; unsigned int int_line; unsigned int int_pin; }