decompiled_code:
__int64 __fastcall s_rsue(_QWORD *a1)
{
__int64 result; // rax
size_t v2; // r8
int *v3; // rax
int *v4; // rbp
int *v5; // rax

if ( !f__init )
f_init();
f__reading = 1LL;
LODWORD(result) = c_sue(a1);
if ( (_DWORD)result )
return (int)result;
f__recpos = 0;
if ( *(_QWORD *)(f__curunit + 72LL) && (unsigned int)f__nowreading() )
{
v5 = _errno_location();
v4 = v5;
if ( !*a1 )
f__fatal((unsigned int)*v5, "read start");
return *v4;
}
v2 = fread(&f__reclen, 8uLL, 1uLL, (FILE *)f);
result = 0LL;
if ( v2 == 1 )
return result;
if ( !feof((FILE *)f) )
{
clearerr((FILE *)f);
v3 = _errno_location();
v4 = v3;
if ( !*a1 )
f__fatal((unsigned int)*v3, "start");
return *v4;
}
*(_QWORD *)(f__curunit + 64LL) = 1LL;
if ( a1[2] )
*_errno_location() = -1;
else
f__fatal(0xFFFFFFFFLL, "start");
return -1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
__int64 result; // rax
size_t v2; // r8
int *v3; // rax
int *v4; // rbp
int *v5; // rax

if ( !f__init )
f_init();
f__reading = 1LL;
LODWORD(result) = func0(a1);
if ( (_DWORD)result )
return (int)result;
f__recpos = 0;
if ( *(_QWORD *)(f__curunit + 72LL) && (unsigned int)f__nowreading() )
{
v5 = _errno_location();
v4 = v5;
if ( !*a1 )
f__fatal((unsigned int)*v5, "read start");
return *v4;
}
v2 = fread(&f__reclen, 8uLL, 1uLL, (FILE *)f);
result = 0LL;
if ( v2 == 1 )
return result;
if ( !feof((FILE *)f) )
{
clearerr((FILE *)f);
v3 = _errno_location();
v4 = v3;
if ( !*a1 )
f__fatal((unsigned int)*v3, "start");
return *v4;
}
*(_QWORD *)(f__curunit + 64LL) = 1LL;
if ( a1[2] )
*_errno_location() = -1;
else
f__fatal(0xFFFFFFFFLL, "start");
return -1LL;
}

original_code:
integer s_rsue(cilist *a)
{
 int n;
 if(!f__init) f_init();
 f__reading=1;
 if(n=c_sue(a)) return(n);
 f__recpos=0;
 if(f__curunit->uwrt && f__nowreading(f__curunit))
  {if(a->cierr) (*__errno_location ())= (*__errno_location ()); else f__fatal((*__errno_location ()),"read start"); return((*__errno_location ()));};
 if(fread((char *)&f__reclen,sizeof(uiolen),1,f__cf)
  != 1)
 { if(feof(f__cf))
  { f__curunit->uend = 1;
   {if(a->ciend) (*__errno_location ())= (-1); else f__fatal((-1),"start"); return((-1));};
  }
  clearerr(f__cf);
  {if(a->cierr) (*__errno_location ())= (*__errno_location ()); else f__fatal((*__errno_location ()),"start"); return((*__errno_location ()));};
 }
 return(0);
}

canonical_original_code:
long s_rsue(struct cilist *a)
{
 int n;
 if(!f__init) f_init();
 f__reading=1;
 if(n=c_sue(a)) return(n);
 f__recpos=0;
 if(f__curunit->uwrt && f__nowreading(f__curunit))
  {if(a->cierr) (*__errno_location ())= (*__errno_location ()); else f__fatal((*__errno_location ()),"read start"); return((*__errno_location ()));};
 if(fread((char *)&f__reclen,sizeof(uiolen),1,f__cf)
  != 1)
 { if(feof(f__cf))
  { f__curunit->uend = 1;
   {if(a->ciend) (*__errno_location ())= (-1); else f__fatal((-1),"start"); return((-1));};
  }
  clearerr(f__cf);
  {if(a->cierr) (*__errno_location ())= (*__errno_location ()); else f__fatal((*__errno_location ()),"start"); return((*__errno_location ()));};
 }
 return(0);
}


repo: kimtang/qml

decompiled_code:
__int64 __fastcall s_wsue(_QWORD *a1)
{
__int64 result; // rax
int *v2; // rax
int *v3; // rbp

if ( !f__init )
f_init();
LODWORD(result) = c_sue(a1);
if ( (_DWORD)result )
return (int)result;
f__reading = 0LL;
f__reclen = 0LL;
if ( *(_QWORD *)(f__curunit + 72LL) != 1LL && (unsigned int)f__nowwriting() )
{
v2 = _errno_location();
v3 = v2;
if ( !*a1 )
f__fatal((unsigned int)*v2, "write start");
result = *v3;
}
else
{
f__recloc = ftello64((FILE *)f);
fseeko64((FILE *)f, 8LL, 1);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
__int64 result; // rax
int *v2; // rax
int *v3; // rbp

if ( !f__init )
f_init();
LODWORD(result) = func0(a1);
if ( (_DWORD)result )
return (int)result;
f__reading = 0LL;
f__reclen = 0LL;
if ( *(_QWORD *)(f__curunit + 72LL) != 1LL && (unsigned int)f__nowwriting() )
{
v2 = _errno_location();
v3 = v2;
if ( !*a1 )
f__fatal((unsigned int)*v2, "write start");
result = *v3;
}
else
{
f__recloc = ftello64((FILE *)f);
fseeko64((FILE *)f, 8LL, 1);
result = 0LL;
}
return result;
}

original_code:
integer s_wsue(cilist *a)
{
 int n;
 if(!f__init) f_init();
 if(n=c_sue(a)) return(n);
 f__reading=0;
 f__reclen=0;
 if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
  {if(a->cierr) (*__errno_location ())= (*__errno_location ()); else f__fatal((*__errno_location ()),"write start"); return((*__errno_location ()));};
 f__recloc=ftello64(f__cf);
 fseeko64(f__cf,(__off64_t)sizeof(uiolen),1);
 return(0);
}

canonical_original_code:
long s_wsue(struct cilist *a)
{
 int n;
 if(!f__init) f_init();
 if(n=c_sue(a)) return(n);
 f__reading=0;
 f__reclen=0;
 if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
  {if(a->cierr) (*__errno_location ())= (*__errno_location ()); else f__fatal((*__errno_location ()),"write start"); return((*__errno_location ()));};
 f__recloc=ftello64(f__cf);
 fseeko64(f__cf,(long)sizeof(uiolen),1);
 return(0);
}

variable_types: struct cilist { long cierr; long ciunit; long ciend; char *cifmt; long cirec; } *

variable_types: n int

return_type: long


decompiled_code:
__int64 e_wsue()
{
__off64_t v0; // rbp

fwrite(&f__reclen, 8uLL, 1uLL, (FILE *)f);
v0 = ftello64((FILE *)f);
fseeko64((FILE *)f, f__recloc, 0);
fwrite(&f__reclen, 8uLL, 1uLL, (FILE *)f);
fseeko64((FILE *)f, v0, 0);
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
__off64_t v0; // rbp

fwrite(&f__reclen, 8uLL, 1uLL, (FILE *)f);
v0 = ftello64((FILE *)f);
fseeko64((FILE *)f, f__recloc, 0);
fwrite(&f__reclen, 8uLL, 1uLL, (FILE *)f);
fseeko64((FILE *)f, v0, 0);
return 0LL;
}

original_code:
integer e_wsue(void)
{ __off64_t loc;
 fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
 loc=ftello64(f__cf);
 fseeko64(f__cf,f__recloc,0);
 fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
 fseeko64(f__cf,loc,0);
 return(0);
}

canonical_original_code:
long e_wsue()
{ long loc;
 fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
 loc=ftello64(f__cf);
 fseeko64(f__cf,f__recloc,0);
 fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
 fseeko64(f__cf,loc,0);
 return(0);
}

variable_types: loc long


decompiled_code:
__int64 e_rsue()
{
fseeko64((FILE *)f, f__reclen - f__recpos + 8LL, 1);
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
fseeko64((FILE *)f, f__reclen - f__recpos + 8LL, 1);
return 0LL;
}

original_code:
integer e_rsue(void)
{
 fseeko64(f__cf,(__off64_t)(f__reclen-f__recpos+sizeof(uiolen)),1);
 return(0);
}

canonical_original_code:
long e_rsue()
{
 fseeko64(f__cf,(__off64_t)(f__reclen-f__recpos+sizeof(uiolen)),1);
 return(0);
}


decompiled_code:
double __fastcall r_dim(float *a1, float *a2)
{
double result; // xmm0_8

if ( *a1 <= *a2 )
result = 0.0;
else
result = (float)(*a1 - *a2);
return result;
}

canonical_decompiled_code:
double __fastcall func0(float *a1, float *a2)
{
double result; // xmm0_8

if ( *a1 <= *a2 )
result = 0.0;
else
result = (float)(*a1 - *a2);
return result;
}

original_code:
double r_dim(real *a, real *b)
{
return( *a > *b ? *a - *b : 0);
}

canonical_original_code:
double r_dim(float *a, float *b)
{
return( *a > *b ? *a - *b : 0);
}

variable_types:
a
float *

variable_types:
b
float *

return_type: double


decompiled_code:
_BOOL8 hl_le()
{
return s_cmp() <= 0;
}

canonical_decompiled_code:
_BOOL8 func0()
{
return s_cmp() <= 0;
}

original_code:
shortlogical hl_le(char *a, char *b, ftnlen la, ftnlen lb)
{
return(s_cmp(a,b,la,lb) <= 0);
}

canonical_original_code:
short hl_le(char *a, char *b, long la, long lb)
{
return(s_cmp(a,b,la,lb) <= 0);
}

variable_types:
a
char *

variable_types:
b
char *

variable_types: la long

variable_types: lb long

return_type: short


decompiled_code:
void __fastcall __noreturn s_stop(char *a1, __int64 a2)
{
char *v2; // rbx
char *v3; // rbp
int v4; // edi

if ( a2 > 0 )
{
v2 = a1;
v3 = &a1[a2];
fwrite("STOP ", 1uLL, 5uLL, stderr);
do
{
v4 = *v2++;
putc(v4, stderr);
}
while ( v3 != v2 );
fwrite(" statement executed\n", 1uLL, 0x14uLL, stderr);
}
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(char *a1, __int64 a2)
{
char *v2; // rbx
char *v3; // rbp
int v4; // edi

if ( a2 > 0 )
{
v2 = a1;
v3 = &a1[a2];
fwrite("STOP ", 1uLL, 5uLL, stderr);
do
{
v4 = *v2++;
putc(v4, stderr);
}
while ( v3 != v2 );
fwrite(" statement executed\n", 1uLL, 0x14uLL, stderr);
}
exit(0);
}

original_code:
int s_stop(char *s, ftnlen n)
{
int i;
if(n > 0)
 {
 fprintf(stderr, "STOP ");
 for(i = 0; i<n ; ++i)
  putc(*s++, stderr);
 fprintf(stderr, " statement executed\n");
 }
exit(0);
return 0;
}

canonical_original_code:
int s_stop(char *s, long n)
{
int i;
if(n > 0)
 {
 fprintf(stderr, "STOP ");
 for(i = 0; i<n ; ++i)
  putc(*s++, stderr);
 fprintf(stderr, " statement executed\n");
 }
exit(0);
return 0;
}

variable_types:
s
char *

variable_types: n long

variable_types: i int

return_type: int


decompiled_code:
void __fastcall r_cos(float *a1)
{
cos(*a1);
}

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

original_code:
double r_cos(real *x)
{
return( cos(*x) );
}

canonical_original_code:
double r_cos(float *x)
{
return( cos(*x) );
}

variable_types:
x
float *


decompiled_code:
__int64 __fastcall l_write(__int64 a1, const char *a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v5; // r15
char *v6; // r14
_QWORD *v7; // r13
int v9; // ebx
__int64 result; // rax
double v11; // [rsp+Ch] [rbp-50h]
double v12; // [rsp+14h] [rbp-48h]
double v13; // [rsp+1Ch] [rbp-40h]

if ( *(__int64 *)a1 <= 0 )
return 0LL;
v5 = 0LL;
v6 = (char *)a2;
v7 = (_QWORD *)a1;
v9 = a4;
while ( 2 )
{
switch ( v9 )
{
case 2:
a1 = *(__int16 *)v6;
goto LABEL_9;
case 3:
a1 = *(_QWORD *)v6;
goto LABEL_9;
case 4:
v11 = *(float *)v6;
goto LABEL_16;
case 5:
v11 = *(double *)v6;
LABEL_16:
sub_400(v11, a1, (__int64)a2);
goto LABEL_5;
case 6:
v12 = *(float *)v6;
v13 = *((float *)v6 + 1);
goto LABEL_11;
case 7:
v12 = *(double *)v6;
v13 = *((double *)v6 + 1);
LABEL_11:
sub_460(v12, v13, a1, (__int64)a2);
goto LABEL_5;
case 8:
case 12:
case 13:
a1 = *(_QWORD *)v6;
a2 = (const char *)a3;
sub_560(*(_QWORD *)v6, a3, a3, a4, a5);
goto LABEL_5;
case 9:
a2 = (const char *)a3;
a1 = (__int64)v6;
sub_30(v6, a3, a3, a4);
goto LABEL_5;
case 11:
goto LABEL_8;
default:
a2 = "unknown type in lio";
f__fatal(117LL, "unknown type in lio");
LABEL_8:
a1 = *v6;
LABEL_9:
sub_200(a1);
LABEL_5:
v6 += a3;
if ( *v7 > ++v5 )
continue;
result = 0LL;
break;
}
return result;
}
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, const char *a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v5; // r15
char *v6; // r14
_QWORD *v7; // r13
int v9; // ebx
__int64 result; // rax
double v11; // [rsp+Ch] [rbp-50h]
double v12; // [rsp+14h] [rbp-48h]
double v13; // [rsp+1Ch] [rbp-40h]

if ( *(__int64 *)a1 <= 0 )
return 0LL;
v5 = 0LL;
v6 = (char *)a2;
v7 = (_QWORD *)a1;
v9 = a4;
while ( 2 )
{
switch ( v9 )
{
case 2:
a1 = *(__int16 *)v6;
goto LABEL_9;
case 3:
a1 = *(_QWORD *)v6;
goto LABEL_9;
case 4:
v11 = *(float *)v6;
goto LABEL_16;
case 5:
v11 = *(double *)v6;
LABEL_16:
sub_400(v11, a1, (__int64)a2);
goto LABEL_5;
case 6:
v12 = *(float *)v6;
v13 = *((float *)v6 + 1);
goto LABEL_11;
case 7:
v12 = *(double *)v6;
v13 = *((double *)v6 + 1);
LABEL_11:
func4(v12, v13, a1, (__int64)a2);
goto LABEL_5;
case 8:
case 12:
case 13:
a1 = *(_QWORD *)v6;
a2 = (const char *)a3;
func5(*(_QWORD *)v6, a3, a3, a4, a5);
goto LABEL_5;
case 9:
a2 = (const char *)a3;
a1 = (__int64)v6;
func1(v6, a3, a3, a4);
goto LABEL_5;
case 11:
goto LABEL_8;
default:
a2 = "unknown type in lio";
f__fatal(117LL, "unknown type in lio");
LABEL_8:
a1 = *v6;
LABEL_9:
func2(a1);
LABEL_5:
v6 += a3;
if ( *v7 > ++v5 )
continue;
result = 0LL;
break;
}
return result;
}
}

original_code:
int
l_write(ftnint *number, char *ptr, ftnlen len, ftnint type)
{
 int i;
 long x;
 double y,z;
 real *xx;
 doublereal *yy;
 for(i=0;i< *number; i++)
 {
  switch((int)type)
  {
  default: f__fatal(117,"unknown type in lio");
  case 11:
   x = ((flex *)ptr)->flchar;
   goto xint;
  case 2:
   x=((flex *)ptr)->flshort;
   goto xint;
  case 3:
   x=((flex *)ptr)->flint;
  xint: lwrt_I(x);
   break;
  case 4:
   y=((flex *)ptr)->flreal;
   goto xfloat;
  case 5:
   y=((flex *)ptr)->fldouble;
  xfloat: lwrt_F(y);
   break;
  case 6:
   xx= &((flex *)ptr)->flreal;
   y = *xx++;
   z = *xx;
   goto xcomplex;
  case 7:
   yy = &((flex *)ptr)->fldouble;
   y= *yy++;
   z = *yy;
  xcomplex:
   lwrt_C(y,z);
   break;
  case 12:
   x = ((flex *)ptr)->flchar;
   goto xlog;
  case 13:
   x = ((flex *)ptr)->flshort;
   goto xlog;
  case 8:
   x = ((flex *)ptr)->flint;
  xlog: lwrt_L(((flex *)ptr)->flint, len);
   break;
  case 9:
   lwrt_A(ptr,len);
   break;
  }
  ptr += len;
 }
 return(0);
}

canonical_original_code:
int l_write(long *number, char *ptr, long len, long type)
{
 int i;
 long x;
 double y; double z;
 float *xx;
 double *yy;
 for(i=0;i< *number; i++)
 {
  switch((int)type)
  {
  default: f__fatal(117,"unknown type in lio");
  case 11:
   x = ((union flex *)ptr)->flchar;
   goto xint;
  case 2:
   x=((union flex *)ptr)->flshort;
   goto xint;
  case 3:
   x=((union flex *)ptr)->flint;
  xint: lwrt_I(x);
   break;
  case 4:
   y=((union flex *)ptr)->flreal;
   goto xfloat;
  case 5:
   y=((union flex *)ptr)->fldouble;
  xfloat: lwrt_F(y);
   break;
  case 6:
   xx= &((union flex *)ptr)->flreal;
   y = *xx++;
   z = *xx;
   goto xcomplex;
  case 7:
   yy = &((union flex *)ptr)->fldouble;
   y= *yy++;
   z = *yy;
  xcomplex:
   lwrt_C(y,z);
   break;
  case 12:
   x = ((union flex *)ptr)->flchar;
   goto xlog;
  case 13:
   x = ((union flex *)ptr)->flshort;
   goto xlog;
  case 8:
   x = ((union flex *)ptr)->flint;
  xlog: lwrt_L(((union flex *)ptr)->flint, len);
   break;
  case 9:
   lwrt_A(ptr,len);
   break;
  }
  ptr += len;
 }
 return(0);
}

variable_types:
number
long *

variable_types:
ptr
char *

variable_types: len long

variable_types: type long

variable_types: x long

variable_types: y double

variable_types: z double

variable_types:
xx
float *

variable_types:
yy
double *

user_defined_types: union flex { char flchar; short flshort; long flint; float flreal; double fldouble; }


decompiled_code:
__int64 __fastcall i_sceiling(float *a1)
{
__int64 result; // rax

LODWORD(result) = (int)*a1;
if ( *a1 <= 0.0 || *a1 == (float)(int)result )
result = (int)result;
else
result = (int)result + 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(float *a1)
{
__int64 result; // rax

LODWORD(result) = (int)*a1;
if ( *a1 <= 0.0 || *a1 == (float)(int)result )
result = (int)result;
else
result = (int)result + 1;
return result;
}

original_code:
integer i_sceiling(real *x)
{
    return (integer) ((int)(*x) + ((*x) > 0 && (*x) != (int)(*x)));
}

canonical_original_code:
long i_sceiling(float *x)
{
    return (integer) ((int)(*x) + ((*x) > 0 && (*x) != (int)(*x)));
}


decompiled_code:
__int64 __fastcall i_dceiling(double *a1)
{
__int64 result; // rax

LODWORD(result) = (int)*a1;
if ( *a1 <= 0.0 || *a1 == (double)(int)result )
result = (int)result;
else
result = (int)result + 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(double *a1)
{
__int64 result; // rax

LODWORD(result) = (int)*a1;
if ( *a1 <= 0.0 || *a1 == (double)(int)result )
result = (int)result;
else
result = (int)result + 1;
return result;
}

original_code:
integer i_dceiling(doublereal *x)
{
    return (integer) ((int)(*x) + ((*x) > 0 && (*x) != (int)(*x)));
}

canonical_original_code:
long i_dceiling(double *x)
{
    return (integer) ((int)(*x) + ((*x) > 0 && (*x) != (int)(*x)));
}

variable_types:
x
double *


decompiled_code:
double __fastcall pow_ri(float *a1, __int64 *a2)
{
__int64 v2; // rax
double v4; // [rsp+4h] [rbp-10h]
double v5; // [rsp+Ch] [rbp-8h]

v2 = *a2;
if ( !*a2 )
return *(double *)&LC0;
v5 = *a1;
if ( v2 < 0 )
{
v2 = -v2;
v5 = 1.0 / v5;
}
v4 = *(double *)&LC0;
while ( 1 )
{
if ( (v2 & 1) != 0 )
v4 = v4 * v5;
v2 = (unsigned __int64)v2 >> 1;
if ( !v2 )
break;
v5 = v5 * v5;
}
return v4;
}

original_code:
double pow_ri(real *ap, integer *bp)
{
double pow, x;
integer n;
unsigned long u;
pow = 1;
x = *ap;
n = *bp;
if(n != 0)
 {
 if(n < 0)
  {
  n = -n;
  x = 1/x;
  }
 for(u = n; ; )
  {
  if(u & 01)
   pow *= x;
  if(u >>= 1)
   x *= x;
  else
   break;
  }
 }
return(pow);
}

canonical_original_code:
double pow_ri(float *ap, long *bp)
{
double pow; double x;
long n;
unsigned long u;
pow = 1;
x = *ap;
n = *bp;
if(n != 0)
 {
 if(n < 0)
  {
  n = -n;
  x = 1/x;
  }
 for(u = n; ; )
  {
  if(u & 01)
   pow *= x;
  if(u >>= 1)
   x *= x;
  else
   break;
  }
 }
return(pow);
}

variable_types:
ap
float *

variable_types:
bp
long *

variable_types: pow double

variable_types: x double

variable_types:
u
unsigned long


decompiled_code:
void __fastcall d_cosh(double *a1)
{
cosh(*a1);
}

canonical_decompiled_code:
void __fastcall func0(double *a1)
{
cosh(*a1);
}

original_code:
double d_cosh(doublereal *x)
{
return( cosh(*x) );
}

canonical_original_code:
double d_cosh(double *x)
{
return( cosh(*x) );
}


original_code:
int
wrt_E(ufloat *p, int w, int d, int e, ftnlen len)
{
 char buf[40 +8 +4], *s, *se;
 int d1, delta, e1, i, sign, signspace;
 double dd;
 int e0 = e;
 if(e <= 0)
  e = 2;
 if(f__scale) {
  if(f__scale >= d + 2 || f__scale <= -d)
   goto nogood;
  }
 if(f__scale <= 0)
  --d;
 if (len == sizeof(real))
  dd = p->pf;
 else
  dd = p->pd;
 if (dd < 0.) {
  signspace = sign = 1;
  dd = -dd;
  }
 else {
  sign = 0;
  signspace = (int)f__cplus;
  if (!dd) {
   dd = 0.;
   }
  }
 delta = w - (2
   + 2 + signspace + d + e);
 if (delta < 0) {
nogood:
  while(--w >= 0)
   (*f__putn)('*');
  return(0);
  }
 if (f__scale < 0)
  d += f__scale;
 if (d > 40) {
  d1 = d - 40;
  d = 40;
  }
 else
  d1 = 0;
 sprintf(buf,"%#.*E", d, dd);
 if (!(My_ctype[(buf[0])+8] & 1)) {
  switch(buf[0]) {
   case 'n':
   case 'N':
    signspace = 0;
   }
  delta = w - strlen(buf) - signspace;
  if (delta < 0)
   goto nogood;
  while(--delta >= 0)
   (*f__putn)(' ');
  if (signspace)
   (*f__putn)(sign ? '-' : '+');
  for(s = buf; *s; s++)
   (*f__putn)(*s);
  return 0;
  }
 se = buf + d + 3;
 if (dd)
  sprintf(se, "%+.2d", atoi(se) + 1 - f__scale);
 else
  strcpy(se, "+00");
 s = ++se;
 if (e < 2) {
  if (*s != '0')
   goto nogood;
  }
 if (s[2]) {
  if (!e0) {
   for(s -= 2, e1 = 2; s[0] = s[1]; s++)
    ;
   }
  else if (e0 >= 0)
   goto shift;
  else
   e1 = e;
  }
 else
 shift:
  for(s += 2, e1 = 2; *s; ++e1, ++s)
   if (e1 >= e)
    goto nogood;
 while(--delta >= 0)
  (*f__putn)(' ');
 if (signspace)
  (*f__putn)(sign ? '-' : '+');
 s = buf;
 i = f__scale;
 if (f__scale <= 0) {
  (*f__putn)('.');
  for(; i < 0; ++i)
   (*f__putn)('0');
  (*f__putn)(*s);
  s += 2;
  }
 else if (f__scale > 1) {
  (*f__putn)(*s);
  s += 2;
  while(--i > 0)
   (*f__putn)(*s++);
  (*f__putn)('.');
  }
 if (d1) {
  se -= 2;
  while(s < se) (*f__putn)(*s++);
  se += 2;
  do (*f__putn)('0'); while(--d1 > 0);
  }
 while(s < se)
  (*f__putn)(*s++);
 if (e < 2)
  (*f__putn)(s[1]);
 else {
  while(++e1 <= e)
   (*f__putn)('0');
  while(*s)
   (*f__putn)(*s++);
  }
 return 0;
 }

canonical_original_code:
int wrt_E(union ufloat *p, int w, int d, int e, long len)
{
 char buf[-1]; char *s; char *se;
 int d1; int delta; int e1; int i; int sign; int signspace;
 double dd;
 int e0 = e;
 if(e <= 0)
  e = 2;
 if(f__scale) {
  if(f__scale >= d + 2 || f__scale <= -d)
   goto nogood;
  }
 if(f__scale <= 0)
  --d;
 if (len == sizeof(real))
  dd = p->pf;
 else
  dd = p->pd;
 if (dd < 0.) {
  signspace = sign = 1;
  dd = -dd;
  }
 else {
  sign = 0;
  signspace = (int)f__cplus;
  if (!dd) {
   dd = 0.;
   }
  }
 delta = w - (2
   + 2 + signspace + d + e);
 if (delta < 0) {
nogood:
  while(--w >= 0)
   (*f__putn)('*');
  return(0);
  }
 if (f__scale < 0)
  d += f__scale;
 if (d > 40) {
  d1 = d - 40;
  d = 40;
  }
 else
  d1 = 0;
 sprintf(buf,"%#.*E", d, dd);
 if (!(My_ctype[(buf[0])+8] & 1)) {
  switch(buf[0]) {
   case 'n':
   case 'N':
    signspace = 0;
   }
  delta = w - strlen(buf) - signspace;
  if (delta < 0)
   goto nogood;
  while(--delta >= 0)
   (*f__putn)(' ');
  if (signspace)
   (*f__putn)(sign ? '-' : '+');
  for(s = buf; *s; s++)
   (*f__putn)(*s);
  return 0;
  }
 se = buf + d + 3;
 if (dd)
  sprintf(se, "%+.2d", atoi(se) + 1 - f__scale);
 else
  strcpy(se, "+00");
 s = ++se;
 if (e < 2) {
  if (*s != '0')
   goto nogood;
  }
 if (s[2]) {
  if (!e0) {
   for(s -= 2, e1 = 2; s[0] = s[1]; s++)
    ;
   }
  else if (e0 >= 0)
   goto shift;
  else
   e1 = e;
  }
 else
 shift:
  for(s += 2, e1 = 2; *s; ++e1, ++s)
   if (e1 >= e)
    goto nogood;
 while(--delta >= 0)
  (*f__putn)(' ');
 if (signspace)
  (*f__putn)(sign ? '-' : '+');
 s = buf;
 i = f__scale;
 if (f__scale <= 0) {
  (*f__putn)('.');
  for(; i < 0; ++i)
   (*f__putn)('0');
  (*f__putn)(*s);
  s += 2;
  }
 else if (f__scale > 1) {
  (*f__putn)(*s);
  s += 2;
  while(--i > 0)
   (*f__putn)(*s++);
  (*f__putn)('.');
  }
 if (d1) {
  se -= 2;
  while(s < se) (*f__putn)(*s++);
  se += 2;
  do (*f__putn)('0'); while(--d1 > 0);
  }
 while(s < se)
  (*f__putn)(*s++);
 if (e < 2)
  (*f__putn)(s[1]);
 else {
  while(++e1 <= e)
   (*f__putn)('0');
  while(*s)
   (*f__putn)(*s++);
  }
 return 0;
 }

variable_types:
p
union ufloat { float pf; double pd; } *

variable_types: w int

variable_types: d int

variable_types: e int

variable_types:
buf
char [-1]

variable_types:
s
char *

variable_types:
se
char *

variable_types: delta int

variable_types: i int

variable_types: sign int

variable_types: signspace int

variable_types: dd double


canonical_original_code:
int wrt_F(union ufloat *p, int w, int d, long len)
{
 int d1; int sign; int n;
 double x;
 char *b; char buf[-1]; char *s;
 x= (len==sizeof(real)?p->pf:p->pd);
 if (d < 344)
  d1 = 0;
 else {
  d1 = d - 344;
  d = 344;
  }
 if (x < 0.)
  { x = -x; sign = 1; }
 else {
  sign = 0;
  if (!x) {
   x = 0.;
   }
  }
 if (n = f__scale)
  if (n > 0)
   do x *= 10.; while(--n > 0);
  else
   do x *= 0.1; while(++n < 0);
 n = sprintf(b = buf, "%#.*f", d, x) + d1;
 if (buf[0] == '0' && d)
  { ++b; --n; }
 if (sign == 1) {
  for(s = b;;) {
   while(*s == '0') s++;
   switch(*s) {
    case '.':
     s++; continue;
    case 0:
     sign = 0;
    }
   break;
   }
  }
 if (sign || f__cplus)
  ++n;
 if (n > w) {
  {
   while(--w >= 0)
    (*f__putn)('*');
   return 0;
   }
  }
 for(w -= n; --w >= 0; )
  (*f__putn)(' ');
 if (sign)
  (*f__putn)('-');
 else if (f__cplus)
  (*f__putn)('+');
 while(n = *b++)
  (*f__putn)(n);
 while(--d1 >= 0)
  (*f__putn)('0');
 return 0;
 }

variable_types: len long

variable_types: n int

variable_types:
b
char *


decompiled_code:
__int64 __fastcall h_dim(__int16 *a1, unsigned __int16 *a2)
{
int v2; // edx
__int64 result; // rax

v2 = *a2;
result = (unsigned int)(unsigned __int16)*a1 - v2;
if ( *a1 <= (__int16)v2 )
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int16 *a1, unsigned __int16 *a2)
{
int v2; // edx
__int64 result; // rax

v2 = *a2;
result = (unsigned int)(unsigned __int16)*a1 - v2;
if ( *a1 <= (__int16)v2 )
result = 0LL;
return result;
}

original_code:
shortint h_dim(shortint *a, shortint *b)
{
return( *a > *b ? *a - *b : 0);
}

canonical_original_code:
short h_dim(short *a, short *b)
{
return( *a > *b ? *a - *b : 0);
}

variable_types:
a
short *

variable_types:
b
short *


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

result = abs64(*a1);
if ( *a2 < 0 )
result = -(__int64)result;
return result;
}

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

result = abs64(*a1);
if ( *a2 < 0 )
result = -(__int64)result;
return result;
}

original_code:
integer i_sign(integer *a, integer *b)
{
integer x;
x = (*a >= 0 ? *a : - *a);
return( *b >= 0 ? x : -x);
}

canonical_original_code:
long i_sign(long *a, long *b)
{
long x;
x = (*a >= 0 ? *a : - *a);
return( *b >= 0 ? x : -x);
}

variable_types:
a
long *

variable_types:
b
long *

variable_types: x long


decompiled_code:
__int64 __fastcall s_rnge(_BYTE *a1, __int64 a2, char *a3, __int64 a4)
{
int i; // edi
int j; // edi

fprintf(stderr, "Subscript out of range on file line %ld, procedure ", a4);
for ( i = *a3; i; i = *++a3 )
{
if ( i == 95 )
break;
if ( i == 32 )
break;
putc(i, stderr);
}
fprintf(stderr, ".\nAttempt to access the %ld-th element of variable ", a2 + 1);
for ( j = (char)*a1; (*a1 & 0xDF) != 0; j = (char)*a1 )
{
++a1;
putc(j, stderr);
}
sig_die(".", 1LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, __int64 a2, char *a3, __int64 a4)
{
int i; // edi
int j; // edi

fprintf(stderr, "Subscript out of range on file line %ld, procedure ", a4);
for ( i = *a3; i; i = *++a3 )
{
if ( i == 95 )
break;
if ( i == 32 )
break;
putc(i, stderr);
}
fprintf(stderr, ".\nAttempt to access the %ld-th element of variable ", a2 + 1);
for ( j = (char)*a1; (*a1 & 0xDF) != 0; j = (char)*a1 )
{
++a1;
putc(j, stderr);
}
sig_die(".", 1LL);
return 0LL;
}

original_code:
integer s_rnge(char *varn, ftnint offset, char *procn, ftnint line)
{
register int i;
fprintf(stderr, "Subscript out of range on file line %ld, procedure ",
 (long)line);
while((i = *procn) && i != '_' && i != ' ')
 putc(*procn++, stderr);
fprintf(stderr, ".\nAttempt to access the %ld-th element of variable ",
 (long)offset+1);
while((i = *varn) && i != ' ')
 putc(*varn++, stderr);
sig_die(".", 1);
return 0;
}

canonical_original_code:
long s_rnge(char *varn, long offset, char *procn, long line)
{
register int i;
fprintf(stderr, "Subscript out of range on file line %ld, procedure ",
 (long)line);
while((i = *procn) && i != '_' && i != ' ')
 putc(*procn++, stderr);
fprintf(stderr, ".\nAttempt to access the %ld-th element of variable ",
 (long)offset+1);
while((i = *varn) && i != ' ')
 putc(*varn++, stderr);
sig_die(".", 1);
return 0;
}

variable_types:
varn
char *

variable_types: offset long

variable_types:
procn
char *

variable_types: line long


decompiled_code:
void __fastcall pow_dd(double *a1, double *a2)
{
pow(*a1, *a2);
}

canonical_decompiled_code:
void __fastcall func0(double *a1, double *a2)
{
pow(*a1, *a2);
}

original_code:
double pow_dd(doublereal *ap, doublereal *bp)
{
return(pow(*ap, *bp) );
}

canonical_original_code:
double pow_dd(double *ap, double *bp)
{
return(pow(*ap, *bp) );
}

variable_types:
ap
double *

variable_types:
bp
double *


decompiled_code:
void __fastcall z_log(double *a1, double *a2)
{
bool v2; // cc
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm0_8
double v6; // xmm1_8
double (__fastcall *v7)(double *, double *); // rbx
__int64 v8; // xmm1_8
double v9; // xmm4_8
double v10; // xmm0_8
double v11; // xmm2_8
double v12; // [rsp+8h] [rbp-130h] BYREF
double v13; // [rsp+10h] [rbp-128h] BYREF
double v14; // [rsp+18h] [rbp-120h]
double v15; // [rsp+20h] [rbp-118h]
double v16; // [rsp+28h] [rbp-110h]
double v17; // [rsp+30h] [rbp-108h]
double v18; // [rsp+38h] [rbp-100h]
double v19; // [rsp+48h] [rbp-F0h]
double v20; // [rsp+50h] [rbp-E8h]
double v21; // [rsp+58h] [rbp-E0h]
double v22; // [rsp+60h] [rbp-D8h]
double v23; // [rsp+68h] [rbp-D0h]
double v24; // [rsp+70h] [rbp-C8h]
double v25; // [rsp+78h] [rbp-C0h]
double v26; // [rsp+80h] [rbp-B8h]
double v27; // [rsp+88h] [rbp-B0h]
double v28; // [rsp+90h] [rbp-A8h]
double v29; // [rsp+98h] [rbp-A0h]
double v30; // [rsp+A0h] [rbp-98h]
double v31; // [rsp+A8h] [rbp-90h]
double v32; // [rsp+B0h] [rbp-88h]
double v33; // [rsp+B8h] [rbp-80h]
double v34; // [rsp+C0h] [rbp-78h]
double v35; // [rsp+C8h] [rbp-70h]
double v36; // [rsp+D0h] [rbp-68h]
__int64 v37; // [rsp+D8h] [rbp-60h]
double v38; // [rsp+E0h] [rbp-58h]
double y; // [rsp+E8h] [rbp-50h]
double x; // [rsp+F0h] [rbp-48h]
double v41; // [rsp+F8h] [rbp-40h]
double v42; // [rsp+100h] [rbp-38h]
double v43; // [rsp+108h] [rbp-30h]

y = a2[1];
x = *a2;
v2 = y >= 0.0;
v14 = atan2(y, x);
a1[1] = v14;
if ( !v2 )
*(_QWORD *)&y ^= LC2;
if ( x < 0.0 )
*(_QWORD *)&x ^= LC2;
v3 = y;
if ( y > x )
{
v4 = x;
x = y;
y = v4;
v3 = v4;
}
v41 = v3 / x;
v15 = v3 / x * (v3 / x);
v16 = v15 + 1.0;
v17 = sqrt(v15 + 1.0);
v18 = v17 * x;
v5 = v17 * x;
v12 = v17 * x;
v36 = v17 * x - 1.0;
if ( v36 < 0.0 )
*(_QWORD *)&v36 ^= LC2;
if ( v36 <= 0.01 )
{
v6 = x * x;
v7 = (double (__fastcall *)(double *, double *))gcc_bug_bypass_diff_F2C;
v23 = v5 + 1.0;
if ( !gcc_bug_bypass_diff_F2C )
v7 = sub_0;
v19 = x * x;
v38 = *(double *)&LC0;
v20 = v6 - 1.0;
v37 = LC0;
v21 = y * y;
v22 = v6 - 1.0 + y * y;
v8 = LC0;
v42 = v22 / v23;
v9 = v22 / v23;
v43 = v9 * v9;
v24 = 0.5 * (v22 / v23);
v25 = 1.0 - v24;
v10 = *(double *)&LC0;
while ( 1 )
{
v38 = v10 + 2.0;
v13 = v25;
*(double *)&v8 = *(double *)&v8 * v43;
v37 = v8;
v26 = *(double *)&v8 / (v10 + 2.0);
v27 = *(double *)&v8 * v9;
v10 = v10 + 2.0;
v28 = v10 + 1.0;
v29 = *(double *)&v8 * v9 / (v10 + 1.0);
v30 = v26 - v29;
v31 = v26 - v29 + v25;
v11 = v31;
v12 = v31;
v32 = v31 - v25;
if ( v31 - v25 <= 1.0e-18 )
{
v33 = v7(&v12, &v13);
if ( v33 <= 0.0 )
{
v34 = v12;
v35 = v12 * v42;
*a1 = v12 * v42;
return;
}
v31 = v12;
v9 = v42;
v11 = v12;
v8 = v37;
v10 = v38;
}
v25 = v11;
}
}
*a1 = log(v5);
}

canonical_decompiled_code:
void __fastcall func1(double *a1, double *a2)
{
bool v2; // cc
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm0_8
double v6; // xmm1_8
double (__fastcall *v7)(double *, double *); // rbx
__int64 v8; // xmm1_8
double v9; // xmm4_8
double v10; // xmm0_8
double v11; // xmm2_8
double v12; // [rsp+8h] [rbp-130h] BYREF
double v13; // [rsp+10h] [rbp-128h] BYREF
double v14; // [rsp+18h] [rbp-120h]
double v15; // [rsp+20h] [rbp-118h]
double v16; // [rsp+28h] [rbp-110h]
double v17; // [rsp+30h] [rbp-108h]
double v18; // [rsp+38h] [rbp-100h]
double v19; // [rsp+48h] [rbp-F0h]
double v20; // [rsp+50h] [rbp-E8h]
double v21; // [rsp+58h] [rbp-E0h]
double v22; // [rsp+60h] [rbp-D8h]
double v23; // [rsp+68h] [rbp-D0h]
double v24; // [rsp+70h] [rbp-C8h]
double v25; // [rsp+78h] [rbp-C0h]
double v26; // [rsp+80h] [rbp-B8h]
double v27; // [rsp+88h] [rbp-B0h]
double v28; // [rsp+90h] [rbp-A8h]
double v29; // [rsp+98h] [rbp-A0h]
double v30; // [rsp+A0h] [rbp-98h]
double v31; // [rsp+A8h] [rbp-90h]
double v32; // [rsp+B0h] [rbp-88h]
double v33; // [rsp+B8h] [rbp-80h]
double v34; // [rsp+C0h] [rbp-78h]
double v35; // [rsp+C8h] [rbp-70h]
double v36; // [rsp+D0h] [rbp-68h]
__int64 v37; // [rsp+D8h] [rbp-60h]
double v38; // [rsp+E0h] [rbp-58h]
double y; // [rsp+E8h] [rbp-50h]
double x; // [rsp+F0h] [rbp-48h]
double v41; // [rsp+F8h] [rbp-40h]
double v42; // [rsp+100h] [rbp-38h]
double v43; // [rsp+108h] [rbp-30h]

y = a2[1];
x = *a2;
v2 = y >= 0.0;
v14 = atan2(y, x);
a1[1] = v14;
if ( !v2 )
*(_QWORD *)&y ^= LC2;
if ( x < 0.0 )
*(_QWORD *)&x ^= LC2;
v3 = y;
if ( y > x )
{
v4 = x;
x = y;
y = v4;
v3 = v4;
}
v41 = v3 / x;
v15 = v3 / x * (v3 / x);
v16 = v15 + 1.0;
v17 = sqrt(v15 + 1.0);
v18 = v17 * x;
v5 = v17 * x;
v12 = v17 * x;
v36 = v17 * x - 1.0;
if ( v36 < 0.0 )
*(_QWORD *)&v36 ^= LC2;
if ( v36 <= 0.01 )
{
v6 = x * x;
v7 = (double (__fastcall *)(double *, double *))gcc_bug_bypass_diff_F2C;
v23 = v5 + 1.0;
if ( !gcc_bug_bypass_diff_F2C )
v7 = sub_0;
v19 = x * x;
v38 = *(double *)&LC0;
v20 = v6 - 1.0;
v37 = LC0;
v21 = y * y;
v22 = v6 - 1.0 + y * y;
v8 = LC0;
v42 = v22 / v23;
v9 = v22 / v23;
v43 = v9 * v9;
v24 = 0.5 * (v22 / v23);
v25 = 1.0 - v24;
v10 = *(double *)&LC0;
while ( 1 )
{
v38 = v10 + 2.0;
v13 = v25;
*(double *)&v8 = *(double *)&v8 * v43;
v37 = v8;
v26 = *(double *)&v8 / (v10 + 2.0);
v27 = *(double *)&v8 * v9;
v10 = v10 + 2.0;
v28 = v10 + 1.0;
v29 = *(double *)&v8 * v9 / (v10 + 1.0);
v30 = v26 - v29;
v31 = v26 - v29 + v25;
v11 = v31;
v12 = v31;
v32 = v31 - v25;
if ( v31 - v25 <= 1.0e-18 )
{
v33 = v7(&v12, &v13);
if ( v33 <= 0.0 )
{
v34 = v12;
v35 = v12 * v42;
*a1 = v12 * v42;
return;
}
v31 = v12;
v9 = v42;
v11 = v12;
v8 = v37;
v10 = v38;
}
v25 = v11;
}
}
*a1 = log(v5);
}

original_code:
void z_log(doublecomplex *r, doublecomplex *z)
{
 double s, s0, t, t2, u, v;
 double zi = z->i, zr = z->r;
 double (*diff) (double*,double*);
 r->i = atan2(zi, zr);
 if (zi < 0)
  zi = -zi;
 if (zr < 0)
  zr = -zr;
 if (zr < zi) {
  t = zi;
  zi = zr;
  zr = t;
  }
 t = zi/zr;
 s = zr * sqrt(1 + t*t);
 if ((t = s - 1) < 0)
  t = -t;
 if (t > .01)
  r->r = log(s);
 else {
  if (!(diff = gcc_bug_bypass_diff_F2C))
   diff = diff1;
  t = ((zr*zr - 1.) + zi*zi) / (s + 1);
  t2 = t*t;
  s = 1. - 0.5*t;
  u = v = 1;
  do {
   s0 = s;
   u *= t2;
   v += 2;
   s += u/v - t*u/(v+1);
   }
   while(s - s0 > 1e-18 || (*diff)(&s,&s0) > 0.);
  r->r = s*t;
  }
 }

canonical_original_code:
void z_log(struct doublecomplex *r, struct doublecomplex *z)
{
 double s; double s0; double t; double t2; double u; double v;
 double zi = z->i; double zr = z->r;
 double (*diff)(double *, double *);
 r->i = atan2(zi, zr);
 if (zi < 0)
  zi = -zi;
 if (zr < 0)
  zr = -zr;
 if (zr < zi) {
  t = zi;
  zi = zr;
  zr = t;
  }
 t = zi/zr;
 s = zr * sqrt(1 + t*t);
 if ((t = s - 1) < 0)
  t = -t;
 if (t > .01)
  r->r = log(s);
 else {
  if (!(diff = gcc_bug_bypass_diff_F2C))
   diff = diff1;
  t = ((zr*zr - 1.) + zi*zi) / (s + 1);
  t2 = t*t;
  s = 1. - 0.5*t;
  u = v = 1;
  do {
   s0 = s;
   u *= t2;
   v += 2;
   s += u/v - t*u/(v+1);
   }
   while(s - s0 > 1e-18 || (*diff)(&s,&s0) > 0.);
  r->r = s*t;
  }
 }

variable_types:
r
struct doublecomplex { double r; } *

variable_types:
z
struct doublecomplex *

variable_types: s double

variable_types: t double

variable_types: u double

variable_types: v double

variable_types: zi double

variable_types: zr double

variable_types:
diff
double (*)(double *, double *)

return_type: void


original_code:
void c_sqrt(complex *r, complex *z)
{
 double mag, t;
 double zi = z->i, zr = z->r;
 if( (mag = f__cabs(zr, zi)) == 0.)
  r->r = r->i = 0.;
 else if(zr > 0)
  {
  r->r = t = sqrt(0.5 * (mag + zr) );
  t = zi / t;
  r->i = 0.5 * t;
  }
 else
  {
  t = sqrt(0.5 * (mag - zr) );
  if(zi < 0)
   t = -t;
  r->i = t;
  t = zi / t;
  r->r = 0.5 * t;
  }
 }

canonical_original_code:
void c_sqrt(struct complex *r, struct complex *z)
{
 double mag; double t;
 double zi = z->i; double zr = z->r;
 if( (mag = f__cabs(zr, zi)) == 0.)
  r->r = r->i = 0.;
 else if(zr > 0)
  {
  r->r = t = sqrt(0.5 * (mag + zr) );
  t = zi / t;
  r->i = 0.5 * t;
  }
 else
  {
  t = sqrt(0.5 * (mag - zr) );
  if(zi < 0)
   t = -t;
  r->i = t;
  t = zi / t;
  r->r = 0.5 * t;
  }
 }

variable_types:
r
struct complex { float r; } *

variable_types:
z
struct complex *

variable_types: mag double


decompiled_code:
__int64 __fastcall w_ned(unsigned int *a1, __int64 a2)
{
char *v2; // rbx
unsigned int v3; // er13
__int64 v4; // rdi
_BYTE *v5; // rbp
char v6; // r12
_BYTE *v7; // rbx
_BYTE *v8; // rbx
char *v9; // rbx
__int64 result; // rax
char *v11; // rdi
char *v12; // rsi
unsigned int v13; // edi
__int64 v14; // rax

switch ( *a1 )
{
case 4u:
case 0xEu:
f__cursor += (int)a1[1];
result = 1LL;
break;
case 5u:
result = f__donewrec();
break;
case 0xBu:
v11 = (char *)*((_QWORD *)a1 + 1);
v2 = v11;
if ( !f__cursor || (result = sub_3F0(), !(_DWORD)result) )
{
v3 = *v11;
v4 = (unsigned int)v11[1];
v5 = v2 + 1;
v6 = *v2;
if ( v2[1] )
{
do
{
while ( v6 != (_BYTE)v4 )
{
v7 = v5++;
f__putn(v4, a2);
v4 = (unsigned int)(char)v7[1];
if ( !v7[1] )
goto LABEL_18;
}
if ( v5[1] != v6 )
break;
v8 = v5 + 1;
v5 += 2;
f__putn(v3, a2);
v4 = (unsigned int)(char)v8[1];
}
while ( v8[1] );
}
LABEL_18:
result = 1LL;
}
break;
case 0xCu:
v12 = (char *)*((_QWORD *)a1 + 1);
v13 = a1[1];
v9 = v12;
if ( !f__cursor || (result = sub_3F0(), !(_DWORD)result) )
{
if ( v13 )
{
do
f__putn((unsigned int)*v9++, v12);
while ( &v12[v13] != v9 );
}
result = 1LL;
}
break;
case 0xDu:
v14 = f__cursor - (int)a1[1];
if ( v14 < -f__recpos )
v14 = -f__recpos;
f__cursor = v14;
result = 1LL;
break;
case 0xFu:
f__cursor = (int)(a1[1] - f__recpos - 1);
result = 1LL;
break;
default:
fprintf(stderr, "w_ned, unexpected code: %d\n", *a1);
sig_die(f__fmtbuf, 1LL);
result = f__donewrec();
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int *a1, __int64 a2)
{
char *v2; // rbx
unsigned int v3; // er13
__int64 v4; // rdi
_BYTE *v5; // rbp
char v6; // r12
_BYTE *v7; // rbx
_BYTE *v8; // rbx
char *v9; // rbx
__int64 result; // rax
char *v11; // rdi
char *v12; // rsi
unsigned int v13; // edi
__int64 v14; // rax

switch ( *a1 )
{
case 4u:
case 0xEu:
f__cursor += (int)a1[1];
result = 1LL;
break;
case 5u:
result = f__donewrec();
break;
case 0xBu:
v11 = (char *)*((_QWORD *)a1 + 1);
v2 = v11;
if ( !f__cursor || (result = func4(), !(_DWORD)result) )
{
v3 = *v11;
v4 = (unsigned int)v11[1];
v5 = v2 + 1;
v6 = *v2;
if ( v2[1] )
{
do
{
while ( v6 != (_BYTE)v4 )
{
v7 = v5++;
f__putn(v4, a2);
v4 = (unsigned int)(char)v7[1];
if ( !v7[1] )
goto LABEL_18;
}
if ( v5[1] != v6 )
break;
v8 = v5 + 1;
v5 += 2;
f__putn(v3, a2);
v4 = (unsigned int)(char)v8[1];
}
while ( v8[1] );
}
LABEL_18:
result = 1LL;
}
break;
case 0xCu:
v12 = (char *)*((_QWORD *)a1 + 1);
v13 = a1[1];
v9 = v12;
if ( !f__cursor || (result = func4(), !(_DWORD)result) )
{
if ( v13 )
{
do
f__putn((unsigned int)*v9++, v12);
while ( &v12[v13] != v9 );
}
result = 1LL;
}
break;
case 0xDu:
v14 = f__cursor - (int)a1[1];
if ( v14 < -f__recpos )
v14 = -f__recpos;
f__cursor = v14;
result = 1LL;
break;
case 0xFu:
f__cursor = (int)(a1[1] - f__recpos - 1);
result = 1LL;
break;
default:
fprintf(stderr, "w_ned, unexpected code: %d\n", *a1);
sig_die(f__fmtbuf, 1LL);
result = f__donewrec();
break;
}
return result;
}

original_code:
int
w_ned(struct syl *p)
{
 switch(p->op)
 {
 default: fprintf(stderr,"w_ned, unexpected code: %d\n", p->op);
  sig_die(f__fmtbuf, 1);
 case 5:
  return((*f__donewrec)());
 case 15: f__cursor = p->p1-f__recpos - 1;
  return(1);
 case 13: f__cursor -= p->p1;
  if(f__cursor < -f__recpos)
   f__cursor = -f__recpos;
  return(1);
 case 14:
 case 4:
  f__cursor += p->p1;
  return(1);
 case 11:
  return(wrt_AP(p->p2.s));
 case 12:
  return(wrt_H(p->p1,p->p2.s));
 }
}

variable_types: struct syl { int op; int p1; union { int i[2]; char *s; } p2; } *


decompiled_code:
__int64 __fastcall ef1asc_(__int64 a1, _QWORD *a2, __int64 a3, _QWORD *a4)
{
s_copy(a1, a3, (*a2 + 7LL) & 0xFFFFFFFFFFFFFFF8LL, *a4);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _QWORD *a2, __int64 a3, _QWORD *a4)
{
s_copy(a1, a3, (*a2 + 7LL) & 0xFFFFFFFFFFFFFFF8LL, *a4);
return 0LL;
}

original_code:
int ef1asc_(ftnint *a, ftnlen *la, ftnint *b, ftnlen *lb)
{
s_copy( (char *)a, (char *)b, ( ( (*la)+ ( (long) (sizeof(long) - 1) )) & (~( (long) (sizeof(long) - 1) )) ), *lb );
return 0;
}

canonical_original_code:
int ef1asc_(long *a, long *la, long *b, long *lb)
{
s_copy( (char *)a, (char *)b, ( ( (*la)+ ( (long) (sizeof(long) - 1) )) & (~( (long) (sizeof(long) - 1) )) ), *lb );
return 0;
}

variable_types:
a
long *

variable_types:
la
long *

variable_types:
b
long *

variable_types:
lb
long *


decompiled_code:
void __fastcall r_tanh(float *a1)
{
tanh(*a1);
}

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

original_code:
double r_tanh(real *x)
{
return( tanh(*x) );
}

canonical_original_code:
double r_tanh(float *x)
{
return( tanh(*x) );
}

variable_types:
x
float *


original_code:
integer
system_(register char *s, ftnlen n)
{
 char buff0[256], *buff;
 register char *bp, *blast;
 integer rv;
 buff = bp = n < sizeof(buff0)
   ? buff0 : F77_aloc(n+1, "system_");
 blast = bp + n;
 while(bp < blast && *s)
  *bp++ = *s++;
 *bp = 0;
 rv = system(buff);
 if (buff != buff0)
  free(buff);
 return rv;
 }

canonical_original_code:
long system_(char *s, long n)
{
 char buff0[256]; char *buff;
 register char *bp; register char *blast;
 long rv;
 buff = bp = n < sizeof(buff0)
   ? buff0 : F77_aloc(n+1, "system_");
 blast = bp + n;
 while(bp < blast && *s)
  *bp++ = *s++;
 *bp = 0;
 rv = system(buff);
 if (buff != buff0)
  free(buff);
 return rv;
 }

variable_types:
s
char *

variable_types: n long

variable_types:
buff
char *

variable_types:
bp
char *

variable_types:
blast
char *

variable_types: rv long


decompiled_code:
__int64 __fastcall s_cmp(unsigned __int8 *a1, _BYTE *a2, __int64 a3, __int64 a4)
{
unsigned __int8 *v4; // r8
_BYTE *v5; // r9
__int64 result; // rax
int v7; // eax
int v8; // edx
unsigned __int8 *v9; // rcx
int v10; // eax
int v11; // eax
int v12; // edx

v4 = &a1[a3];
v5 = &a2[a4];
if ( a3 > a4 )
{
v9 = &a1[a4];
if ( a2 < v5 )
{
while ( 1 )
{
v11 = *a1;
v12 = (unsigned __int8)*a2;
if ( (_BYTE)v11 != (_BYTE)v12 )
break;
++a1;
++a2;
if ( a1 == v9 )
goto LABEL_13;
}
result = v11 - v12;
}
else
{
v9 = a1;
LABEL_13:
if ( v4 <= v9 )
return 0LL;
while ( 1 )
{
v10 = *v9;
if ( (_BYTE)v10 != 32 )
break;
if ( v4 == ++v9 )
return 0LL;
}
result = v10 - 32;
}
}
else if ( a1 < v4 )
{
while ( 1 )
{
v7 = *a1;
v8 = (unsigned __int8)*a2;
if ( (_BYTE)v7 != (_BYTE)v8 )
break;
++a1;
++a2;
if ( v4 == a1 )
goto LABEL_3;
}
result = v7 - v8;
}
else
{
LABEL_3:
if ( v5 <= a2 )
return 0LL;
while ( *a2 == 32 )
{
if ( v5 == ++a2 )
return 0LL;
}
result = 32 - (unsigned __int8)*a2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, _BYTE *a2, __int64 a3, __int64 a4)
{
unsigned __int8 *v4; // r8
_BYTE *v5; // r9
__int64 result; // rax
int v7; // eax
int v8; // edx
unsigned __int8 *v9; // rcx
int v10; // eax
int v11; // eax
int v12; // edx

v4 = &a1[a3];
v5 = &a2[a4];
if ( a3 > a4 )
{
v9 = &a1[a4];
if ( a2 < v5 )
{
while ( 1 )
{
v11 = *a1;
v12 = (unsigned __int8)*a2;
if ( (_BYTE)v11 != (_BYTE)v12 )
break;
++a1;
++a2;
if ( a1 == v9 )
goto LABEL_13;
}
result = v11 - v12;
}
else
{
v9 = a1;
LABEL_13:
if ( v4 <= v9 )
return 0LL;
while ( 1 )
{
v10 = *v9;
if ( (_BYTE)v10 != 32 )
break;
if ( v4 == ++v9 )
return 0LL;
}
result = v10 - 32;
}
}
else if ( a1 < v4 )
{
while ( 1 )
{
v7 = *a1;
v8 = (unsigned __int8)*a2;
if ( (_BYTE)v7 != (_BYTE)v8 )
break;
++a1;
++a2;
if ( v4 == a1 )
goto LABEL_3;
}
result = v7 - v8;
}
else
{
LABEL_3:
if ( v5 <= a2 )
return 0LL;
while ( *a2 == 32 )
{
if ( v5 == ++a2 )
return 0LL;
}
result = 32 - (unsigned __int8)*a2;
}
return result;
}

original_code:
integer s_cmp(char *a0, char *b0, ftnlen la, ftnlen lb)
{
register unsigned char *a, *aend, *b, *bend;
a = (unsigned char *)a0;
b = (unsigned char *)b0;
aend = a + la;
bend = b + lb;
if(la <= lb)
 {
 while(a < aend)
  if(*a != *b)
   return( *a - *b );
  else
   { ++a; ++b; }
 while(b < bend)
  if(*b != ' ')
   return( ' ' - *b );
  else ++b;
 }
else
 {
 while(b < bend)
  if(*a == *b)
   { ++a; ++b; }
  else
   return( *a - *b );
 while(a < aend)
  if(*a != ' ')
   return(*a - ' ');
  else ++a;
 }
return(0);
}

canonical_original_code:
long s_cmp(char *a0, char *b0, long la, long lb)
{
register unsigned char *a; register unsigned char *aend; register unsigned char *b; register unsigned char *bend;
a = (unsigned char *)a0;
b = (unsigned char *)b0;
aend = a + la;
bend = b + lb;
if(la <= lb)
 {
 while(a < aend)
  if(*a != *b)
   return( *a - *b );
  else
   { ++a; ++b; }
 while(b < bend)
  if(*b != ' ')
   return( ' ' - *b );
  else ++b;
 }
else
 {
 while(b < bend)
  if(*a == *b)
   { ++a; ++b; }
  else
   return( *a - *b );
 while(a < aend)
  if(*a != ' ')
   return(*a - ' ');
  else ++a;
 }
return(0);
}

variable_types: la long

variable_types: lb long

variable_types:
a
unsigned char *

variable_types:
aend
unsigned char *

variable_types:
b
unsigned char *

variable_types:
bend
unsigned char *


decompiled_code:
double __fastcall r_sign(float *a1, float *a2)
{
float v3; // [rsp+0h] [rbp-10h]
double v4; // [rsp+8h] [rbp-8h]

v3 = *a1;
if ( *a1 < 0.0 )
LODWORD(v3) = *(_DWORD *)a1 ^ LC1;
v4 = v3;
if ( *a2 < 0.0 )
*(_QWORD *)&v4 ^= LC2;
return v4;
}

canonical_decompiled_code:
double __fastcall func0(float *a1, float *a2)
{
float v3; // [rsp+0h] [rbp-10h]
double v4; // [rsp+8h] [rbp-8h]

v3 = *a1;
if ( *a1 < 0.0 )
LODWORD(v3) = *(_DWORD *)a1 ^ LC1;
v4 = v3;
if ( *a2 < 0.0 )
*(_QWORD *)&v4 ^= LC2;
return v4;
}

original_code:
double r_sign(real *a, real *b)
{
double x;
x = (*a >= 0 ? *a : - *a);
return( *b >= 0 ? x : -x);
}

canonical_original_code:
double r_sign(float *a, float *b)
{
double x;
x = (*a >= 0 ? *a : - *a);
return( *b >= 0 ? x : -x);
}

variable_types:
a
float *

variable_types:
b
float *

variable_types: x double


decompiled_code:
__int64 __fastcall s_rsli(_QWORD *a1)
{
f__lioproc = &l_read;
f__lquit = 0LL;
f__lcount = 0;
sub_0(a1);
f__doend = 0LL;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
f__lioproc = &l_read;
f__lquit = 0LL;
f__lcount = 0;
sub_0(a1);
f__doend = 0LL;
return 0LL;
}

original_code:
integer s_rsli(icilist *a)
{
 f__lioproc = l_read;
 f__lquit = 0;
 f__lcount = 0;
 c_lir(a);
 f__doend = 0;
 return(0);
 }

canonical_original_code:
long s_rsli(struct icilist *a)
{
 f__lioproc = l_read;
 f__lquit = 0;
 f__lcount = 0;
 c_lir(a);
 f__doend = 0;
 return(0);
 }

variable_types: struct icilist { long icierr; char *iciunit; long iciend; char *icifmt; long icirlen; long icirnum; } *


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

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

original_code:
integer e_rsli(void)
{ return 0; }

canonical_original_code:
long e_rsli()
{ return 0; }


decompiled_code:
__int64 __fastcall s_rsni(__int64 *a1)
{
__int64 result; // rax
__int64 v2[7]; // [rsp+0h] [rbp-38h] BYREF

v2[2] = a1[2];
v2[0] = *a1;
v2[3] = a1[3];
sub_0(a1);
result = (int)x_rsne(v2);
nml_read = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 *a1)
{
__int64 result; // rax
__int64 v2[7]; // [rsp+0h] [rbp-38h] BYREF

v2[2] = a1[2];
v2[0] = *a1;
v2[3] = a1[3];
sub_0(a1);
result = (int)x_rsne(v2);
nml_read = 0;
return result;
}

original_code:
integer s_rsni(icilist *a)
{
 extern int nml_read;
 integer rv;
 cilist ca;
 ca.ciend = a->iciend;
 ca.cierr = a->icierr;
 ca.cifmt = a->icifmt;
 c_lir(a);
 rv = x_rsne(&ca);
 nml_read = 0;
 return rv;
 }

canonical_original_code:
long s_rsni(struct icilist *a)
{
 extern int nml_read;
 long rv;
 struct cilist ca;
 ca.ciend = a->iciend;
 ca.cierr = a->icierr;
 ca.cifmt = a->icifmt;
 c_lir(a);
 rv = x_rsne(&ca);
 nml_read = 0;
 return rv;
 }

variable_types: struct cilist { long cierr; long ciunit; long ciend; char *cifmt; long cirec; }

user_defined_types: struct icilist { long icierr; char *iciunit; long iciend; char *icifmt; long icirlen; long icirnum; }


original_code:
double r_mod(real *x, real *y)
{
 double quotient;
 if( (quotient = (double)*x / *y) >= 0)
  quotient = floor(quotient);
 else
  quotient = -floor(-quotient);
 return(*x - (*y) * quotient );
}

canonical_original_code:
double r_mod(float *x, float *y)
{
 double quotient;
 if( (quotient = (double)*x / *y) >= 0)
  quotient = floor(quotient);
 else
  quotient = -floor(-quotient);
 return(*x - (*y) * quotient );
}

variable_types:
x
float *

variable_types:
y
float *

variable_types: quotient double


original_code:
void
getenv_(char *fname, char *value, ftnlen flen, ftnlen vlen)
{
 char buf[256], *ep, *fp;
 integer i;
 if (flen <= 0)
  goto add_blanks;
 for(i = 0; i < sizeof(buf); i++) {
  if (i == flen || (buf[i] = fname[i]) == ' ') {
   buf[i] = 0;
   ep = getenv(buf);
   goto have_ep;
   }
  }
 while(i < flen && fname[i] != ' ')
  i++;
 strncpy(fp = F77_aloc(i+1, "getenv_"), fname, (int)i);
 fp[i] = 0;
 ep = getenv(fp);
 free(fp);
 have_ep:
 if (ep)
  while(*ep && vlen-- > 0)
   *value++ = *ep++;
 add_blanks:
 while(vlen-- > 0)
  *value++ = ' ';
 }

canonical_original_code:
void getenv_(char *fname, char *value, long flen, long vlen)
{
 char buf[256]; char *ep; char *fp;
 long i;
 if (flen <= 0)
  goto add_blanks;
 for(i = 0; i < sizeof(buf); i++) {
  if (i == flen || (buf[i] = fname[i]) == ' ') {
   buf[i] = 0;
   ep = getenv(buf);
   goto have_ep;
   }
  }
 while(i < flen && fname[i] != ' ')
  i++;
 strncpy(fp = F77_aloc(i+1, "getenv_"), fname, (int)i);
 fp[i] = 0;
 ep = getenv(fp);
 free(fp);
 have_ep:
 if (ep)
  while(*ep && vlen-- > 0)
   *value++ = *ep++;
 add_blanks:
 while(vlen-- > 0)
  *value++ = ' ';
 }

variable_types:
fname
char *

variable_types:
value
char *

variable_types: flen long

variable_types: vlen long

variable_types:
buf
char [256]

variable_types:
ep
char *

variable_types:
fp
char *

variable_types: i long


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

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

variable_types:
x
double *


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

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


decompiled_code:
__int64 __fastcall s_paus(const char *a1, __int64 a2)
{
int v2; // eax
unsigned int v4; // eax

fwrite("PAUSE ", 1uLL, 6uLL, stderr);
if ( a2 > 0 )
fprintf(stderr, " %.*s", a2, a1);
fwrite(" statement executed\n", 1uLL, 0x14uLL, stderr);
v2 = fileno(stdin);
if ( isatty(v2) )
{
sub_10(stdin);
}
else
{
v4 = getpid();
fprintf(stderr, "To resume execution, execute a kill -%d %d command\n", 15LL, v4);
signal(15, (__sighandler_t)handler);
fflush(stderr);
pause();
}
fwrite("Execution resumes after PAUSE.\n", 1uLL, 0x1FuLL, stderr);
fflush(stderr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, __int64 a2)
{
int v2; // eax
unsigned int v4; // eax

fwrite("PAUSE ", 1uLL, 6uLL, stderr);
if ( a2 > 0 )
fprintf(stderr, " %.*s", a2, a1);
fwrite(" statement executed\n", 1uLL, 0x14uLL, stderr);
v2 = fileno(stdin);
if ( isatty(v2) )
{
func1(stdin);
}
else
{
v4 = getpid();
fprintf(stderr, "To resume execution, execute a kill -%d %d command\n", 15LL, v4);
signal(15, (__sighandler_t)handler);
fflush(stderr);
pause();
}
fwrite("Execution resumes after PAUSE.\n", 1uLL, 0x1FuLL, stderr);
fflush(stderr);
return 0LL;
}

original_code:
int
s_paus(char *s, ftnlen n)
{
 fprintf(stderr, "PAUSE ");
 if(n > 0)
  fprintf(stderr, " %.*s", (int)n, s);
 fprintf(stderr, " statement executed\n");
 if( isatty(fileno(stdin)) )
  s_1paus(stdin);
 else {
  fprintf(stderr,
  "To resume execution, execute a   kill -%d %d   command\n",
   15, getpid() );
  signal(15,(sig_pf)waitpause);
  fflush(stderr);
  pause();
  }
 fprintf(stderr, "Execution resumes after PAUSE.\n");
 fflush(stderr);
 return 0;
}

canonical_original_code:
int s_paus(char *s, long n)
{
 fprintf(stderr, "PAUSE ");
 if(n > 0)
  fprintf(stderr, " %.*s", (int)n, s);
 fprintf(stderr, " statement executed\n");
 if( isatty(fileno(stdin)) )
  s_1paus(stdin);
 else {
  fprintf(stderr,
  "To resume execution, execute a   kill -%d %d   command\n",
   15, getpid() );
  signal(15,(void (*)(int))waitpause);
  fflush(stderr);
  pause();
  }
 fprintf(stderr, "Execution resumes after PAUSE.\n");
 fflush(stderr);
 return 0;
}

variable_types:
s
char *

variable_types: n long


decompiled_code:
void __fastcall derfc_(double *a1)
{
erfc(*a1);
}

canonical_decompiled_code:
void __fastcall func0(double *a1)
{
erfc(*a1);
}

original_code:
double derfc_(doublereal *x)
{
return( erfc(*x) );
}

canonical_original_code:
double derfc_(double *x)
{
return( erfc(*x) );
}


decompiled_code:
void __fastcall r_acos(float *a1)
{
acos(*a1);
}

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

original_code:
double r_acos(real *x)
{
return( acos(*x) );
}

canonical_original_code:
double r_acos(float *x)
{
return( acos(*x) );
}


decompiled_code:
__int64 __fastcall h_abs(__int16 *a1)
{
return ((unsigned __int16)(*a1 >> 15) ^ (unsigned __int16)*a1) - (unsigned int)(unsigned __int16)(*a1 >> 15);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int16 *a1)
{
return ((unsigned __int16)(*a1 >> 15) ^ (unsigned __int16)*a1) - (unsigned int)(unsigned __int16)(*a1 >> 15);
}

original_code:
shortint h_abs(shortint *x)
{
if(*x >= 0)
 return(*x);
return(- *x);
}

canonical_original_code:
short h_abs(short *x)
{
if(*x >= 0)
 return(*x);
return(- *x);
}

variable_types:
x
short *


decompiled_code:
void __fastcall d_atn2(double *a1, double *a2)
{
atan2(*a1, *a2);
}

canonical_decompiled_code:
void __fastcall func0(double *a1, double *a2)
{
atan2(*a1, *a2);
}

original_code:
double d_atn2(doublereal *x, doublereal *y)
{
return( atan2(*x,*y) );
}

canonical_original_code:
double d_atn2(double *x, double *y)
{
return( atan2(*x,*y) );
}

variable_types:
y
double *


decompiled_code:
__int64 __fastcall i_mod(__int64 *a1, _QWORD *a2)
{
return *a1 % *a2;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1, _QWORD *a2)
{
return *a1 % *a2;
}

original_code:
integer i_mod(integer *a, integer *b)
{
return( *a % *b);
}

canonical_original_code:
long i_mod(long *a, long *b)
{
return( *a % *b);
}

variable_types:
a
long *

variable_types:
b
long *


decompiled_code:
_BOOL8 hl_ge()
{
return s_cmp() >= 0;
}

canonical_decompiled_code:
_BOOL8 func0()
{
return s_cmp() >= 0;
}

original_code:
shortlogical hl_ge(char *a, char *b, ftnlen la, ftnlen lb)
{
return(s_cmp(a,b,la,lb) >= 0);
}

canonical_original_code:
short hl_ge(char *a, char *b, long la, long lb)
{
return(s_cmp(a,b,la,lb) >= 0);
}

variable_types:
a
char *

variable_types:
b
char *

variable_types: la long

variable_types: lb long


original_code:
void
x_wsne(cilist *a)
{
 Namelist *nl;
 char *s;
 Vardesc *v, **vd, **vde;
 ftnint number, type;
 ftnlen *dims;
 ftnlen size;
 extern ftnlen f__typesize[];
 nl = (Namelist *)a->cifmt;
 (*f__putn)('&');
 for(s = nl->name; *s; s++)
  (*f__putn)(*s);
 (*f__putn)(' ');
 f__Aquote = 1;
 vd = nl->vars;
 vde = vd + nl->nvars;
 while(vd < vde) {
  v = *vd++;
  s = v->name;
   nl_donewrec();
  while(*s)
   (*f__putn)(*s++);
  (*f__putn)(' ');
  (*f__putn)('=');
  number = (dims = v->dims) ? dims[1] : 1;
  type = v->type;
  if (type < 0) {
   size = -type;
   type = 9;
   }
  else
   size = f__typesize[type];
  l_write(&number, v->addr, size, type);
  if (vd < vde) {
   if (f__recpos+2 >= L_len)
    nl_donewrec();
   (*f__putn)(',');
   (*f__putn)(' ');
   }
  else if (f__recpos+1 >= L_len)
   nl_donewrec();
  }
 f__Aquote = 0;
 (*f__putn)('/');
 }

canonical_original_code:
void x_wsne(struct cilist *a)
{
 struct Namelist *nl;
 char *s;
 struct Vardesc *v; struct Vardesc **vd; struct Vardesc **vde;
 long number; long type;
 long *dims;
 long size;
 extern long f__typesize[];
 nl = (struct Namelist *)a->cifmt;
 (*f__putn)('&');
 for(s = nl->name; *s; s++)
  (*f__putn)(*s);
 (*f__putn)(' ');
 f__Aquote = 1;
 vd = nl->vars;
 vde = vd + nl->nvars;
 while(vd < vde) {
  v = *vd++;
  s = v->name;
   nl_donewrec();
  while(*s)
   (*f__putn)(*s++);
  (*f__putn)(' ');
  (*f__putn)('=');
  number = (dims = v->dims) ? dims[1] : 1;
  type = v->type;
  if (type < 0) {
   size = -type;
   type = 9;
   }
  else
   size = f__typesize[type];
  l_write(&number, v->addr, size, type);
  if (vd < vde) {
   if (f__recpos+2 >= L_len)
    nl_donewrec();
   (*f__putn)(',');
   (*f__putn)(' ');
   }
  else if (f__recpos+1 >= L_len)
   nl_donewrec();
  }
 f__Aquote = 0;
 (*f__putn)('/');
 }

variable_types: struct cilist { long cierr; long ciunit; long ciend; char *cifmt; long cirec; } *

variable_types: struct Namelist { char *name; struct Vardesc { char *name; char *addr; long *dims; int type; } **vars; int nvars; } *

variable_types: number long

variable_types: type long

variable_types:
dims
long *

variable_types: size long

user_defined_types: struct Namelist { char *name; struct Vardesc **vars; int nvars; }


decompiled_code:
void __fastcall erfc_(float *a1)
{
erfc(*a1);
}

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

original_code:
double erfc_(real *x)
{
return( erfc((double)*x) );
}

canonical_original_code:
double erfc_(float *x)
{
return( erfc((double)*x) );
}

variable_types:
x
float *


decompiled_code:
char *__fastcall getarg_(__int64 *a1, __int64 a2, __int64 a3)
{
__int64 v3; // rax
void *v5; // r8
char *result; // rax
char v7; // dl

v3 = *a1;
v5 = &LC0;
if ( *a1 >= 0 && v3 < xargc )
v5 = *(void **)(xargv + 8 * v3);
result = 0LL;
if ( a3 > 0 )
{
while ( 1 )
{
v7 = result[(_QWORD)v5];
if ( !v7 )
break;
(result++)[a2] = v7;
if ( (char *)a3 == result )
return result;
}
if ( a3 > (int)result )
result = (char *)memset(&result[a2], 32, a3 - (int)result);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func0(__int64 *a1, __int64 a2, __int64 a3)
{
__int64 v3; // rax
void *v5; // r8
char *result; // rax
char v7; // dl

v3 = *a1;
v5 = &LC0;
if ( *a1 >= 0 && v3 < xargc )
v5 = *(void **)(xargv + 8 * v3);
result = 0LL;
if ( a3 > 0 )
{
while ( 1 )
{
v7 = result[(_QWORD)v5];
if ( !v7 )
break;
(result++)[a2] = v7;
if ( (char *)a3 == result )
return result;
}
if ( a3 > (int)result )
result = (char *)memset(&result[a2], 32, a3 - (int)result);
}
return result;
}

original_code:
void getarg_(ftnint *n, char *s, ftnlen ls)
{
 extern int xargc;
 extern char **xargv;
 const char *t;
 int i;
 if(*n>=0 && *n<xargc)
  t = xargv[*n];
 else
  t = "";
 for(i = 0; i<ls && *t!='\0' ; ++i)
  *s++ = *t++;
 for( ; i<ls ; ++i)
  *s++ = ' ';
 }

canonical_original_code:
void getarg_(long *n, char *s, long ls)
{
 extern int xargc;
 extern char **xargv;
 char *t;
 int i;
 if(*n>=0 && *n<xargc)
  t = xargv[*n];
 else
  t = "";
 for(i = 0; i<ls && *t!='\0' ; ++i)
  *s++ = *t++;
 for( ; i<ls ; ++i)
  *s++ = ' ';
 }

variable_types:
n
long *

variable_types:
s
char *

variable_types: ls long

variable_types: xargc int

variable_types:
xargv
char **

variable_types:
t
char *

variable_types: i int


decompiled_code:
unsigned __int64 __fastcall i_abs(__int64 *a1)
{
return abs64(*a1);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(__int64 *a1)
{
return abs64(*a1);
}

original_code:
integer i_abs(integer *x)
{
if(*x >= 0)
 return(*x);
return(- *x);
}

canonical_original_code:
long i_abs(long *x)
{
if(*x >= 0)
 return(*x);
return(- *x);
}

variable_types:
x
long *


decompiled_code:
__int64 iargc_()
{
return xargc - 1;
}

canonical_decompiled_code:
__int64 func0()
{
return xargc - 1;
}

original_code:
ftnint iargc_(void)
{
extern int xargc;
return ( xargc - 1 );
}

canonical_original_code:
long iargc_()
{
extern int xargc;
return ( xargc - 1 );
}


decompiled_code:
void __fastcall z_cos(double *a1, double *a2)
{
double v2; // xmm0_8
double v3; // [rsp+8h] [rbp-50h]
double v4; // [rsp+40h] [rbp-18h]
double x; // [rsp+48h] [rbp-10h]

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

canonical_decompiled_code:
void __fastcall func0(double *a1, double *a2)
{
double v2; // xmm0_8
double v3; // [rsp+8h] [rbp-50h]
double v4; // [rsp+40h] [rbp-18h]
double x; // [rsp+48h] [rbp-10h]

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

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

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

variable_types:
r
struct doublecomplex { double r; } *

variable_types:
z
struct doublecomplex *

variable_types: zi double

variable_types: zr double


original_code:
integer i_nint(real *x)
{
return (integer)(*x >= 0 ? floor(*x + .5) : -floor(.5 - *x));
}

canonical_original_code:
long i_nint(float *x)
{
return (integer)(*x >= 0 ? floor(*x + .5) : -floor(.5 - *x));
}


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

result = *a1 - *a2;
if ( *a1 <= *a2 )
result = 0LL;
return result;
}

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

result = *a1 - *a2;
if ( *a1 <= *a2 )
result = 0LL;
return result;
}

original_code:
integer i_dim(integer *a, integer *b)
{
return( *a > *b ? *a - *b : 0);
}

canonical_original_code:
long i_dim(long *a, long *b)
{
return( *a > *b ? *a - *b : 0);
}

variable_types:
a
long *

variable_types:
b
long *


decompiled_code:
double __fastcall d_sign(double *a1, double *a2)
{
double result; // xmm0_8

result = *a1;
if ( *a1 < 0.0 )
*(_QWORD *)&result ^= LC1;
if ( *a2 < 0.0 )
*(_QWORD *)&result ^= LC1;
return result;
}

canonical_decompiled_code:
double __fastcall func0(double *a1, double *a2)
{
double result; // xmm0_8

result = *a1;
if ( *a1 < 0.0 )
*(_QWORD *)&result ^= LC1;
if ( *a2 < 0.0 )
*(_QWORD *)&result ^= LC1;
return result;
}

original_code:
double d_sign(doublereal *a, doublereal *b)
{
double x;
x = (*a >= 0 ? *a : - *a);
return( *b >= 0 ? x : -x);
}

canonical_original_code:
double d_sign(double *a, double *b)
{
double x;
x = (*a >= 0 ? *a : - *a);
return( *b >= 0 ? x : -x);
}

variable_types:
a
double *

variable_types:
b
double *

variable_types: x double


decompiled_code:
unsigned __int64 l_lt()
{
return (unsigned __int64)s_cmp() >> 63;
}

canonical_decompiled_code:
unsigned __int64 func0()
{
return (unsigned __int64)s_cmp() >> 63;
}

original_code:
logical l_lt(char *a, char *b, ftnlen la, ftnlen lb)
{
return(s_cmp(a,b,la,lb) < 0);
}

canonical_original_code:
long l_lt(char *a, char *b, long la, long lb)
{
return(s_cmp(a,b,la,lb) < 0);
}

variable_types:
a
char *

variable_types:
b
char *

variable_types: la long

variable_types: lb long


decompiled_code:
void __fastcall d_sin(double *a1)
{
sin(*a1);
}

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

original_code:
double d_sin(doublereal *x)
{
return( sin(*x) );
}

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

variable_types:
x
double *


decompiled_code:
_BOOL8 l_ge()
{
return s_cmp() >= 0;
}

original_code:
logical l_ge(char *a, char *b, ftnlen la, ftnlen lb)
{
return(s_cmp(a,b,la,lb) >= 0);
}

canonical_original_code:
long l_ge(char *a, char *b, long la, long lb)
{
return(s_cmp(a,b,la,lb) >= 0);
}


decompiled_code:
__int64 __fastcall pow_hh(unsigned __int16 *a1, unsigned __int16 *a2)
{
unsigned int v2; // eax
int v3; // edx
unsigned int v4; // er8

v2 = *a2;
v3 = *a1;
if ( (__int16)v2 > 0 )
goto LABEL_2;
if ( (_WORD)v2 && (_WORD)v3 != 1 )
{
v4 = 0;
if ( (_WORD)v3 != 0xFFFF )
return v4;
v2 = -v2;
LABEL_2:
v2 = (__int16)v2;
v4 = 1;
while ( 1 )
{
if ( (v2 & 1) != 0 )
v4 *= v3;
v2 >>= 1;
if ( !v2 )
break;
v3 *= v3;
}
return v4;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int16 *a1, unsigned __int16 *a2)
{
unsigned int v2; // eax
int v3; // edx
unsigned int v4; // er8

v2 = *a2;
v3 = *a1;
if ( (__int16)v2 > 0 )
goto LABEL_2;
if ( (_WORD)v2 && (_WORD)v3 != 1 )
{
v4 = 0;
if ( (_WORD)v3 != 0xFFFF )
return v4;
v2 = -v2;
LABEL_2:
v2 = (__int16)v2;
v4 = 1;
while ( 1 )
{
if ( (v2 & 1) != 0 )
v4 *= v3;
v2 >>= 1;
if ( !v2 )
break;
v3 *= v3;
}
return v4;
}
return 1LL;
}

original_code:
shortint pow_hh(shortint *ap, shortint *bp)
{
 shortint pow, x, n;
 unsigned u;
 x = *ap;
 n = *bp;
 if (n <= 0) {
  if (n == 0 || x == 1)
   return 1;
  if (x != -1)
   return x == 0 ? 1/x : 0;
  n = -n;
  }
 u = n;
 for(pow = 1; ; )
  {
  if(u & 01)
   pow *= x;
  if(u >>= 1)
   x *= x;
  else
   break;
  }
 return(pow);
 }

canonical_original_code:
short pow_hh(short *ap, short *bp)
{
 short pow; short x; short n;
 unsigned int u;
 x = *ap;
 n = *bp;
 if (n <= 0) {
  if (n == 0 || x == 1)
   return 1;
  if (x != -1)
   return x == 0 ? 1/x : 0;
  n = -n;
  }
 u = n;
 for(pow = 1; ; )
  {
  if(u & 01)
   pow *= x;
  if(u >>= 1)
   x *= x;
  else
   break;
  }
 return(pow);
 }

variable_types:
ap
short *

variable_types:
bp
short *

variable_types: pow short

variable_types: x short

variable_types: n short

variable_types:
u
unsigned int


decompiled_code:
void __fastcall z_sin(double *a1, double *a2)
{
double v2; // [rsp+0h] [rbp-48h]
double v3; // [rsp+18h] [rbp-30h]
double v4; // [rsp+30h] [rbp-18h]
double x; // [rsp+38h] [rbp-10h]

v4 = a2[1];
x = *a2;
v2 = sin(*a2);
*a1 = v2 * cosh(v4);
v3 = cos(x);
a1[1] = v3 * sinh(v4);
}

canonical_decompiled_code:
void __fastcall func0(double *a1, double *a2)
{
double v2; // [rsp+0h] [rbp-48h]
double v3; // [rsp+18h] [rbp-30h]
double v4; // [rsp+30h] [rbp-18h]
double x; // [rsp+38h] [rbp-10h]

v4 = a2[1];
x = *a2;
v2 = sin(*a2);
*a1 = v2 * cosh(v4);
v3 = cos(x);
a1[1] = v3 * sinh(v4);
}

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

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

variable_types:
r
struct doublecomplex { double r; } *

variable_types:
z
struct doublecomplex *

variable_types: zi double

variable_types: zr double


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

result = (int)en_fio();
f__fmtbuf = 0LL;
return result;
}

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

result = (int)en_fio();
f__fmtbuf = 0LL;
return result;
}

original_code:
integer e_rsfe(void)
{ int n;
 n=en_fio();
 f__fmtbuf=((void *)0);
 return(n);
}

canonical_original_code:
long e_rsfe()
{ int n;
 n=en_fio();
 f__fmtbuf=((void *)0);
 return(n);
}

variable_types: n int


decompiled_code:
// attributes: thunk
__int64 e_wsfe()
{
return e_rsfe();
}

canonical_decompiled_code:
__int64 func2()
{
return func0();
}

original_code:
integer e_wsfe(void)
{
 int n = en_fio();
 f__fmtbuf = ((void *)0);
 return n;
}

canonical_original_code:
long e_wsfe()
{
 int n = en_fio();
 f__fmtbuf = ((void *)0);
 return n;
}


original_code:
void pow_zi(doublecomplex *p, doublecomplex *a, integer *b)
{
 integer n;
 unsigned long u;
 double t;
 doublecomplex q, x;
 static doublecomplex one = {1.0, 0.0};
 n = *b;
 q.r = 1;
 q.i = 0;
 if(n == 0)
  goto done;
 if(n < 0)
  {
  n = -n;
  z_div(&x, &one, a);
  }
 else
  {
  x.r = a->r;
  x.i = a->i;
  }
 for(u = n; ; )
  {
  if(u & 01)
   {
   t = q.r * x.r - q.i * x.i;
   q.i = q.r * x.i + q.i * x.r;
   q.r = t;
   }
  if(u >>= 1)
   {
   t = x.r * x.r - x.i * x.i;
   x.i = 2 * x.r * x.i;
   x.r = t;
   }
  else
   break;
  }
 done:
 p->i = q.i;
 p->r = q.r;
 }

canonical_original_code:
void pow_zi(struct doublecomplex *p, struct doublecomplex *a, long *b)
{
 long n;
 unsigned long u;
 double t;
 struct doublecomplex q; struct doublecomplex x;
 static struct doublecomplex one = {1.0, 0.0};
 n = *b;
 q.r = 1;
 q.i = 0;
 if(n == 0)
  goto done;
 if(n < 0)
  {
  n = -n;
  z_div(&x, &one, a);
  }
 else
  {
  x.r = a->r;
  x.i = a->i;
  }
 for(u = n; ; )
  {
  if(u & 01)
   {
   t = q.r * x.r - q.i * x.i;
   q.i = q.r * x.i + q.i * x.r;
   q.r = t;
   }
  if(u >>= 1)
   {
   t = x.r * x.r - x.i * x.i;
   x.i = 2 * x.r * x.i;
   x.r = t;
   }
  else
   break;
  }
 done:
 p->i = q.i;
 p->r = q.r;
 }

variable_types:
p
struct doublecomplex { double r; } *

variable_types:
a
struct doublecomplex *

variable_types:
b
long *

variable_types: n long

variable_types:
u
unsigned long

variable_types: t double

variable_types:
q
struct doublecomplex { double r; }

variable_types:
x
struct doublecomplex { double r; }

variable_types:
one
struct doublecomplex { double r; }


decompiled_code:
void __fastcall __noreturn exit_(_QWORD *a1)
{
exit(*a1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(_QWORD *a1)
{
exit(*a1);
}

original_code:
void
exit_(integer *rc)
{
 exit(*rc);
 }

canonical_original_code:
void exit_(long *rc)
{
 exit(*rc);
 }

variable_types:
rc
long *


decompiled_code:
void __fastcall z_exp(double *a1, double *a2)
{
double v2; // [rsp+30h] [rbp-18h]
double v3; // [rsp+38h] [rbp-10h]

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

canonical_decompiled_code:
void __fastcall func0(double *a1, double *a2)
{
double v2; // [rsp+30h] [rbp-18h]
double v3; // [rsp+38h] [rbp-10h]

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

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

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

variable_types: expx double


decompiled_code:
void __fastcall r_sqrt(float *a1)
{
sqrt(*a1);
}

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

original_code:
double r_sqrt(real *x)
{
return( sqrt(*x) );
}

canonical_original_code:
double r_sqrt(float *x)
{
return( sqrt(*x) );
}

variable_types:
x
float *


decompiled_code:
void __fastcall z_abs(double *a1)
{
f__cabs(*a1, a1[1]);
}

canonical_decompiled_code:
void __fastcall func0(double *a1)
{
f__cabs(*a1, a1[1]);
}

original_code:
double z_abs(doublecomplex *z)
{
return( f__cabs( z->r, z->i ) );
}

canonical_original_code:
double z_abs(struct doublecomplex *z)
{
return( f__cabs( z->r, z->i ) );
}

variable_types:
z
struct doublecomplex { double r; } *


original_code:
double pow_di(doublereal *ap, integer *bp)
{
double pow, x;
integer n;
unsigned long u;
pow = 1;
x = *ap;
n = *bp;
if(n != 0)
 {
 if(n < 0)
  {
  n = -n;
  x = 1/x;
  }
 for(u = n; ; )
  {
  if(u & 01)
   pow *= x;
  if(u >>= 1)
   x *= x;
  else
   break;
  }
 }
return(pow);
}

canonical_original_code:
double pow_di(double *ap, long *bp)
{
double pow; double x;
long n;
unsigned long u;
pow = 1;
x = *ap;
n = *bp;
if(n != 0)
 {
 if(n < 0)
  {
  n = -n;
  x = 1/x;
  }
 for(u = n; ; )
  {
  if(u & 01)
   pow *= x;
  if(u >>= 1)
   x *= x;
  else
   break;
  }
 }
return(pow);
}

variable_types:
ap
double *

variable_types:
bp
long *

variable_types: pow double

variable_types: x double


decompiled_code:
void __fastcall d_tan(double *a1)
{
tan(*a1);
}

canonical_decompiled_code:
void __fastcall func0(double *a1)
{
tan(*a1);
}

original_code:
double d_tan(doublereal *x)
{
return( tan(*x) );
}

canonical_original_code:
double d_tan(double *x)
{
return( tan(*x) );
}

variable_types:
x
double *


decompiled_code:
double __fastcall d_prod(float *a1, float *a2)
{
return (float)(*a1 * *a2);
}

canonical_decompiled_code:
double __fastcall func0(float *a1, float *a2)
{
return (float)(*a1 * *a2);
}

original_code:
double d_prod(real *x, real *y)
{
return( (*x) * (*y) );
}

canonical_original_code:
double d_prod(float *x, float *y)
{
return( (*x) * (*y) );
}

variable_types:
y
float *


original_code:
integer pow_ii(integer *ap, integer *bp)
{
 integer pow, x, n;
 unsigned long u;
 x = *ap;
 n = *bp;
 if (n <= 0) {
  if (n == 0 || x == 1)
   return 1;
  if (x != -1)
   return x == 0 ? 1/x : 0;
  n = -n;
  }
 u = n;
 for(pow = 1; ; )
  {
  if(u & 01)
   pow *= x;
  if(u >>= 1)
   x *= x;
  else
   break;
  }
 return(pow);
 }

canonical_original_code:
long pow_ii(long *ap, long *bp)
{
 long pow; long x; long n;
 unsigned long u;
 x = *ap;
 n = *bp;
 if (n <= 0) {
  if (n == 0 || x == 1)
   return 1;
  if (x != -1)
   return x == 0 ? 1/x : 0;
  n = -n;
  }
 u = n;
 for(pow = 1; ; )
  {
  if(u & 01)
   pow *= x;
  if(u >>= 1)
   x *= x;
  else
   break;
  }
 return(pow);
 }

variable_types:
ap
long *

variable_types: pow long

variable_types: x long


decompiled_code:
void *__fastcall F77_aloc(size_t size, const char *a2)
{
void *result; // rax

result = malloc((unsigned int)size);
if ( !result )
{
fprintf(stderr, "malloc(%u) failure in %s\n", (unsigned int)size, a2);
exit_((int)&status);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func0(size_t size, const char *a2)
{
void *result; // rax

result = malloc((unsigned int)size);
if ( !result )
{
fprintf(stderr, "malloc(%u) failure in %s\n", (unsigned int)size, a2);
exit_((int)&status);
}
return result;
}

original_code:
char *
F77_aloc(integer Len, const char *whence)
{
 char *rv;
 unsigned int uLen = (unsigned int) Len;
 if (!(rv = (char*)malloc(uLen))) {
  fprintf(stderr, "malloc(%u) failure in %s\n",
   uLen, whence);
  exit_(&memfailure);
  }
 return rv;
 }

canonical_original_code:
char *F77_aloc(long Len, char *whence)
{
 char *rv;
 unsigned int uLen = (unsigned int) Len;
 if (!(rv = (char *)malloc(uLen))) {
  fprintf(stderr, "malloc(%u) failure in %s\n",
   uLen, whence);
  exit_(&memfailure);
  }
 return rv;
 }

variable_types: Len long

variable_types:
whence
char *

variable_types:
rv
char *

variable_types:
uLen
unsigned int

return_type: char *


decompiled_code:
_BOOL8 l_le()
{
return s_cmp() <= 0;
}

canonical_decompiled_code:
_BOOL8 func0()
{
return s_cmp() <= 0;
}

original_code:
logical l_le(char *a, char *b, ftnlen la, ftnlen lb)
{
return(s_cmp(a,b,la,lb) <= 0);
}

canonical_original_code:
long l_le(char *a, char *b, long la, long lb)
{
return(s_cmp(a,b,la,lb) <= 0);
}

variable_types:
a
char *

variable_types:
b
char *

variable_types: la long

variable_types: lb long


canonical_decompiled_code:
double __fastcall func0(double *a1)
{
return 0.4342944819032518 * log(*a1);
}


decompiled_code:
void __fastcall r_sinh(float *a1)
{
sinh(*a1);
}

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

original_code:
double r_sinh(real *x)
{
return( sinh(*x) );
}

canonical_original_code:
double r_sinh(float *x)
{
return( sinh(*x) );
}

variable_types:
x
float *


decompiled_code:
double __fastcall d_imag(__int64 a1)
{
return *(double *)(a1 + 8);
}

canonical_decompiled_code:
double __fastcall func0(__int64 a1)
{
return *(double *)(a1 + 8);
}

original_code:
double d_imag(doublecomplex *z)
{
return(z->i);
}

canonical_original_code:
double d_imag(struct doublecomplex *z)
{
return(z->i);
}

variable_types:
z
struct doublecomplex { double r; } *


decompiled_code:
__int64 __fastcall pow_ci(float *a1, float *a2)
{
__int64 result; // rax
float v3; // xmm0_4
float v4; // xmm0_4
__int64 v5[2]; // [rsp+30h] [rbp-28h] BYREF
__int64 v6[3]; // [rsp+40h] [rbp-18h] BYREF

*(double *)v6 = *a2;
*(double *)&v6[1] = a2[1];
result = pow_zi(v5, v6);
v3 = *(double *)v5;
*a1 = v3;
v4 = *(double *)&v5[1];
a1[1] = v4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(float *a1, float *a2)
{
__int64 result; // rax
float v3; // xmm0_4
float v4; // xmm0_4
__int64 v5[2]; // [rsp+30h] [rbp-28h] BYREF
__int64 v6[3]; // [rsp+40h] [rbp-18h] BYREF

*(double *)v6 = *a2;
*(double *)&v6[1] = a2[1];
result = pow_zi(v5, v6);
v3 = *(double *)v5;
*a1 = v3;
v4 = *(double *)&v5[1];
a1[1] = v4;
return result;
}

original_code:
void pow_ci(complex *p, complex *a, integer *b)
{
doublecomplex p1, a1;
a1.r = a->r;
a1.i = a->i;
pow_zi(&p1, &a1, b);
p->r = p1.r;
p->i = p1.i;
}

canonical_original_code:
void pow_ci(struct complex *p, struct complex *a, long *b)
{
struct doublecomplex p1; struct doublecomplex a1;
a1.r = a->r;
a1.i = a->i;
pow_zi(&p1, &a1, b);
p->r = p1.r;
p->i = p1.i;
}

variable_types:
p
struct complex { float r; } *

variable_types:
a
struct complex *

variable_types:
b
long *

user_defined_types:
struct doublecomplex { double r; }
struct complex { float r; }


decompiled_code:
void __fastcall c_abs(float *a1)
{
f__cabs(*a1, a1[1]);
}

canonical_decompiled_code:
void __fastcall func0(float *a1)
{
f__cabs(*a1, a1[1]);
}

original_code:
double c_abs(complex *z)
{
return( f__cabs( z->r, z->i ) );
}

canonical_original_code:
double c_abs(struct complex *z)
{
return( f__cabs( z->r, z->i ) );
}

variable_types:
z
struct complex { float r; } *


decompiled_code:
_BOOL8 hl_gt()
{
return s_cmp() > 0;
}

canonical_decompiled_code:
_BOOL8 func0()
{
return s_cmp() > 0;
}

original_code:
shortlogical hl_gt(char *a, char *b, ftnlen la, ftnlen lb)
{
return(s_cmp(a,b,la,lb) > 0);
}

canonical_original_code:
short hl_gt(char *a, char *b, long la, long lb)
{
return(s_cmp(a,b,la,lb) > 0);
}


decompiled_code:
double __fastcall f__cabs(double a1, double a2)
{
double v2; // xmm1_8
double result; // xmm0_8
double v4; // [rsp+0h] [rbp-48h]
double v5; // [rsp+8h] [rbp-40h]

v5 = a1;
v4 = a2;
if ( a1 < 0.0 )
*(_QWORD *)&v5 = *(_QWORD *)&a1 ^ LC1;
if ( a2 < 0.0 )
*(_QWORD *)&v4 = *(_QWORD *)&a2 ^ LC1;
if ( v4 > v5 )
{
v2 = v5;
v5 = v4;
v4 = v2;
}
result = v5;
if ( v4 + v5 != v5 )
result = v5 * sqrt(v4 / v5 * (v4 / v5) + 1.0);
return result;
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2)
{
double v2; // xmm1_8
double result; // xmm0_8
double v4; // [rsp+0h] [rbp-48h]
double v5; // [rsp+8h] [rbp-40h]

v5 = a1;
v4 = a2;
if ( a1 < 0.0 )
*(_QWORD *)&v5 = *(_QWORD *)&a1 ^ LC1;
if ( a2 < 0.0 )
*(_QWORD *)&v4 = *(_QWORD *)&a2 ^ LC1;
if ( v4 > v5 )
{
v2 = v5;
v5 = v4;
v4 = v2;
}
result = v5;
if ( v4 + v5 != v5 )
result = v5 * sqrt(v4 / v5 * (v4 / v5) + 1.0);
return result;
}

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


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


decompiled_code:
double __fastcall r_int(float *a1)
{
float v1; // xmm0_4
double result; // xmm0_8
__m128 v3; // xmm3
__m128 v4; // xmm0
__m128 v5; // xmm3
float v6; // [rsp+0h] [rbp-20h]
int v7; // [rsp+4h] [rbp-1Ch]

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

canonical_decompiled_code:
double __fastcall func0(float *a1)
{
float v1; // xmm0_4
double result; // xmm0_8
__m128 v3; // xmm3
__m128 v4; // xmm0
__m128 v5; // xmm3
float v6; // [rsp+0h] [rbp-20h]
int v7; // [rsp+4h] [rbp-1Ch]

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

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


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

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

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

v1 = f__recpos;
if ( f__recpos < f__hiwater )
{
f__recpos = f__hiwater;
v1 = (int)f__hiwater;
}
if ( (int)f__buflen <= (int)v1 + 1 )
{
func0(v1 + 1, v1);
v1 = f__recpos;
}
v2 = ptr;
v3 = &ptr[v1];
if ( a1 )
*v3++ = a1;
*v3 = 0;
while ( 1 )
{
fputs(v2, (FILE *)f);
v4 = &v2[strlen(v2)];
if ( v3 <= v4 )
break;
v2 = v4 + 1;
putc(0, (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


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+40h] [rbp-18h]
double v5; // [rsp+48h] [rbp-10h]

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

canonical_decompiled_code:
void __fastcall func0(float *a1, float *a2)
{
float v2; // xmm0_4
float v3; // xmm0_4
double v4; // [rsp+40h] [rbp-18h]
double v5; // [rsp+48h] [rbp-10h]

v4 = a2[1];
v5 = exp(*a2);
v2 = cos(v4) * v5;
*a1 = v2;
v3 = sin(v4) * v5;
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


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 v5; // [rsp+18h] [rbp-50h]
double v6; // [rsp+50h] [rbp-18h]
double x; // [rsp+58h] [rbp-10h]

v6 = a2[1];
x = *a2;
v5 = cos(x);
v2 = v5 * 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 v5; // [rsp+18h] [rbp-50h]
double v6; // [rsp+50h] [rbp-18h]
double x; // [rsp+58h] [rbp-10h]

v6 = a2[1];
x = *a2;
v5 = cos(x);
v2 = v5 * 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
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rsi
__int64 v5; // rax
__int64 (__fastcall *v6)(__int64, char *); // rax
__int64 result; // rax
__int64 v8; // [rsp+8h] [rbp-4530h] BYREF
char v9[256]; // [rsp+10h] [rbp-4528h] BYREF
char dest[1024]; // [rsp+110h] [rbp-4428h] BYREF
int v11; // [rsp+510h] [rbp-4028h] BYREF
char src[16420]; // [rsp+514h] [rbp-4024h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
unsigned int v1; // ebx
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rsi
__int64 v5; // rax
__int64 (__fastcall *v6)(__int64, char *); // rax
__int64 result; // rax
__int64 v8; // [rsp+8h] [rbp-4530h] BYREF
char v9[256]; // [rsp+10h] [rbp-4528h] BYREF
char dest[1024]; // [rsp+110h] [rbp-4428h] BYREF
int v11; // [rsp+510h] [rbp-4028h] BYREF
char src[16420]; // [rsp+514h] [rbp-4024h] BYREF

debug_puts("fs_makedir()\n");
v8 = 0LL;
fs_split_path(a1, &v11);
strcpy(dest, "/");
if ( v11 == 1 )
{
v4 = 4LL;
}
else
{
v1 = 0;
do
{
v2 = v1++;
strcat(dest, &src[512 * v2]);
strcat(dest, "/");
v3 = (unsigned int)(v11 - 1);
}
while ( (unsigned int)v3 > v1 );
v4 = (v3 << 9) + 4;
}
strcpy(v9, (const char *)&v11 + v4);
fs_get_node(dest, &v8);
if ( v8
&& (v5 = func0((__int64)dest)) != 0
&& (v6 = *(__int64 (__fastcall **)(__int64, char *))(v5 + 312)) != 0LL )
{
result = v6(v8, v9);
}
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