mimetextpartheader

decompiled_code:
__int64 __fastcall mimetextpartheader(__int64 a1, const char *a2)
{
sockprintf(a1, "--%s", a2);
sockprintf((unsigned int)a1, "Content-Type: text/plain;");
sockprintf((unsigned int)a1, " charset=\"iso-8859-1\"");
return sockprintf((unsigned int)a1, "Content-Transfer-Encoding: 7bit");
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, const char *a2)
{
sockprintf(a1, "--%s", a2);
sockprintf((unsigned int)a1, "Content-Type: text/plain;");
sockprintf((unsigned int)a1, " charset=\"iso-8859-1\"");
return sockprintf((unsigned int)a1, "Content-Transfer-Encoding: 7bit");
}

original_code:
void mimetextpartheader(int socket, char* boundary)
{
    sockprintf(socket,"--%s",boundary);
    sockprintf(socket,"Content-Type: text/plain;");
    sockprintf(socket," charset=\"iso-8859-1\"");
    sockprintf(socket,"Content-Transfer-Encoding: 7bit");
}

canonical_original_code:
void mimetextpartheader(int socket, char *boundary)
{
    sockprintf(socket,"--%s",boundary);
    sockprintf(socket,"Content-Type: text/plain;");
    sockprintf(socket," charset=\"iso-8859-1\"");
    sockprintf(socket,"Content-Transfer-Encoding: 7bit");
}


mimeattach

repo: ftnapps/pkg-sbbs

decompiled_code:
__int64 __fastcall mimeattach(unsigned int a1, const char *a2, const char *a3)
{
const char *v4; // r13
__int64 result; // rax

v4 = (const char *)getfname(a3);
sockprintf(a1, "--%s", a2);
sockprintf(a1, "Content-Type: application/octet-stream;");
sockprintf(a1, " name=\"%s\"", v4);
sockprintf(a1, "Content-Transfer-Encoding: base64");
sockprintf(a1, "Content-Disposition: attachment;");
sockprintf(a1, " filename=\"%s\"", v4);
sockprintf(a1, (const char *)&unk_324);
result = base64out(a1, a3);
if ( (_DWORD)result )
{
sockprintf(a1, (const char *)&unk_324);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, const char *a2, const char *a3)
{
const char *v4; // r13
__int64 result; // rax

v4 = (const char *)getfname(a3);
sockprintf(a1, "--%s", a2);
sockprintf(a1, "Content-Type: application/octet-stream;");
sockprintf(a1, " name=\"%s\"", v4);
sockprintf(a1, "Content-Transfer-Encoding: base64");
sockprintf(a1, "Content-Disposition: attachment;");
sockprintf(a1, " filename=\"%s\"", v4);
sockprintf(a1, (const char *)&unk_324);
result = func4(a1, a3);
if ( (_DWORD)result )
{
sockprintf(a1, (const char *)&unk_324);
result = 1LL;
}
return result;
}

original_code:
int mimeattach(int socket, char* boundary, char* pathfile)
{
    char* fname = getfname(pathfile);
    sockprintf(socket,"--%s",boundary);
    sockprintf(socket,"Content-Type: application/octet-stream;");
    sockprintf(socket," name=\"%s\"",fname);
    sockprintf(socket,"Content-Transfer-Encoding: base64");
    sockprintf(socket,"Content-Disposition: attachment;");
    sockprintf(socket," filename=\"%s\"",fname);
    sockprintf(socket,"");
    if(!base64out(socket,pathfile))
  return(0);
    sockprintf(socket,"");
 return(1);
}

canonical_original_code:
int mimeattach(int socket, char *boundary, char *pathfile)
{
    char *fname = getfname(pathfile);
    sockprintf(socket,"--%s",boundary);
    sockprintf(socket,"Content-Type: application/octet-stream;");
    sockprintf(socket," name=\"%s\"",fname);
    sockprintf(socket,"Content-Transfer-Encoding: base64");
    sockprintf(socket,"Content-Disposition: attachment;");
    sockprintf(socket," filename=\"%s\"",fname);
    sockprintf(socket,"");
    if(!base64out(socket,pathfile))
  return(0);
    sockprintf(socket,"");
 return(1);
}

variable_types: socket int

variable_types:
boundary
char *

variable_types:
pathfile
char *

variable_types:
fname
char *

return_type: int


endmime

decompiled_code:
__int64 __fastcall endmime(__int64 a1, const char *a2)
{
sockprintf(a1, "--%s--", a2);
return sockprintf((unsigned int)a1, (const char *)&unk_324);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, const char *a2)
{
sockprintf(a1, "--%s--", a2);
return sockprintf((unsigned int)a1, (const char *)&unk_324);
}

original_code:
void endmime(int socket, char* boundary)
{
    sockprintf(socket,"--%s--",boundary);
    sockprintf(socket,"");
}

canonical_original_code:
void endmime(int socket, char *boundary)
{
    sockprintf(socket,"--%s--",boundary);
    sockprintf(socket,"");
}

return_type: void


msgdate

decompiled_code:
char *__fastcall msgdate(time_t a1, __int16 a2, char *a3)
{
__int64 v4; // rbp
int v5; // ebx
__int64 v6; // r8
__int64 v7; // rdi
__int64 v8; // rsi
__int64 v9; // r9
__int64 v10; // rdx
__int64 v11; // rcx
__int64 v12; // rax
const char *v13; // r10
__int64 v14; // rax
time_t v16; // [rsp+0h] [rbp-68h] BYREF
__int16 v17; // [rsp+8h] [rbp-60h]
struct tm tp; // [rsp+10h] [rbp-58h] BYREF

v4 = 43LL;
v16 = a1;
v17 = a2;
v5 = smb_tzutc((unsigned int)a2);
if ( (v5 & 0x8000u) != 0 )
{
v5 = -v5;
v4 = 45LL;
}
if ( localtime_r(&v16, &tp) )
{
v6 = (unsigned int)tp.tm_sec;
v7 = (unsigned int)tp.tm_min;
v8 = (unsigned int)tp.tm_hour;
v9 = (unsigned int)(tp.tm_year + 1900);
v10 = tp.tm_mon;
v11 = (unsigned int)tp.tm_mday;
v12 = tp.tm_wday;
}
else
{
v12 = 0LL;
v11 = 0LL;
v10 = 0LL;
tp.tm_zone = 0LL;
v8 = 0LL;
v7 = 0LL;
v6 = 0LL;
*(_OWORD *)&tp.tm_sec = 0LL;
v9 = 1900LL;
*(_OWORD *)&tp.tm_mon = 0LL;
*(_OWORD *)&tp.tm_isdst = 0LL;
}
v13 = (const char *)*((_QWORD *)&wday + v12);
v14 = (unsigned int)((__int16)v5 / 60);
LODWORD(v14) = (__int16)v5 / 60;
sprintf(
a3,
"%s, %d %s %d %02d:%02d:%02d %c%02u%02u",
v13,
v11,
*((const char **)&mon + v10),
v9,
v8,
v7,
v6,
v4,
v14,
(unsigned int)((__int16)v5 % 60));
return a3;
}

canonical_decompiled_code:
char *__fastcall func0(time_t a1, __int16 a2, char *a3)
{
__int64 v4; // rbp
int v5; // ebx
__int64 v6; // r8
__int64 v7; // rdi
__int64 v8; // rsi
__int64 v9; // r9
__int64 v10; // rdx
__int64 v11; // rcx
__int64 v12; // rax
const char *v13; // r10
__int64 v14; // rax
time_t v16; // [rsp+0h] [rbp-68h] BYREF
__int16 v17; // [rsp+8h] [rbp-60h]
struct tm tp; // [rsp+10h] [rbp-58h] BYREF

v4 = 43LL;
v16 = a1;
v17 = a2;
v5 = smb_tzutc((unsigned int)a2);
if ( (v5 & 0x8000u) != 0 )
{
v5 = -v5;
v4 = 45LL;
}
if ( localtime_r(&v16, &tp) )
{
v6 = (unsigned int)tp.tm_sec;
v7 = (unsigned int)tp.tm_min;
v8 = (unsigned int)tp.tm_hour;
v9 = (unsigned int)(tp.tm_year + 1900);
v10 = tp.tm_mon;
v11 = (unsigned int)tp.tm_mday;
v12 = tp.tm_wday;
}
else
{
v12 = 0LL;
v11 = 0LL;
v10 = 0LL;
tp.tm_zone = 0LL;
v8 = 0LL;
v7 = 0LL;
v6 = 0LL;
*(_OWORD *)&tp.tm_sec = 0LL;
v9 = 1900LL;
*(_OWORD *)&tp.tm_mon = 0LL;
*(_OWORD *)&tp.tm_isdst = 0LL;
}
v13 = (const char *)*((_QWORD *)&wday + v12);
v14 = (unsigned int)((__int16)v5 / 60);
LODWORD(v14) = (__int16)v5 / 60;
sprintf(
a3,
"%s, %d %s %d %02d:%02d:%02d %c%02u%02u",
v13,
v11,
*((const char **)&mon + v10),
v9,
v8,
v7,
v6,
v4,
v14,
(unsigned int)((__int16)v5 % 60));
return a3;
}

original_code:
char* msgdate(when_t when, char* buf)
{
 struct tm tm;
 char plus='+';
 short tz;
 tz=smb_tzutc(when.zone);
 if(tz<0) {
  plus='-';
  tz=-tz;
 }
 if(localtime_r((const time_t*)&when.time,&tm)==((void *)0))
  memset(&tm,0,sizeof(tm));
 sprintf(buf,"%s, %d %s %d %02d:%02d:%02d %c%02u%02u"
  ,wday[tm.tm_wday]
  ,tm.tm_mday
  ,mon[tm.tm_mon]
  ,1900+tm.tm_year
  ,tm.tm_hour
  ,tm.tm_min
  ,tm.tm_sec
  ,plus, tz/60, tz%60
  );
 return(buf);
}

canonical_original_code:
char *msgdate(struct when_t when, char *buf)
{
 struct tm tm;
 char plus = '+';
 short tz;
 tz=smb_tzutc(when.zone);
 if(tz<0) {
  plus='-';
  tz=-tz;
 }
 if(localtime_r((long *)&when.time,&tm)==((void *)0))
  memset(&tm,0,sizeof(tm));
 sprintf(buf,"%s, %d %s %d %02d:%02d:%02d %c%02u%02u"
  ,wday[tm.tm_wday]
  ,tm.tm_mday
  ,mon[tm.tm_mon]
  ,1900+tm.tm_year
  ,tm.tm_hour
  ,tm.tm_min
  ,tm.tm_sec
  ,plus, tz/60, tz%60
  );
 return(buf);
}

variable_types: struct when_t { unsigned long time; short zone; }

variable_types:
buf
char *

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }

variable_types: plus char

variable_types: tz short

return_type: char *


decompiled_code:
time_t __fastcall rfc822date(char *nptr)
{
char *v1; // rbx
__int64 v2; // rbp
const unsigned __int16 *v3; // r12
__int64 v4; // rax
char v5; // al
const char *v6; // rbp
int v7; // eax
__int64 v8; // rbx
const unsigned __int16 *v9; // rax
__int64 v10; // rbx
const unsigned __int16 *v11; // r12
__int64 v12; // rax
__int64 v13; // rax
char v14; // bl
const char *v15; // rbp
char nptra[32]; // [rsp+14h] [rbp-98h] BYREF
char s[32]; // [rsp+34h] [rbp-78h] BYREF
struct tm tp; // [rsp+54h] [rbp-58h] BYREF

v1 = nptr;
v2 = *nptr;
tp.tm_zone = 0LL;
*(_OWORD *)&tp.tm_sec = 0LL;
*(_OWORD *)&tp.tm_mon = 0LL;
*(_OWORD *)&tp.tm_isdst = 0LL;
if ( !(_BYTE)v2 )
goto LABEL_59;
while ( (char)v2 <= 32 )
{
v2 = *++v1;
if ( !(_BYTE)v2 )
goto LABEL_59;
}
if ( (_BYTE)v2 )
{
v3 = *_ctype_b_loc();
while ( (v3[v2] & 0x800) == 0 )
{
v2 = *++v1;
if ( !(_BYTE)v2 )
goto LABEL_59;
}
tp.tm_mday = atoi(v1);
v4 = *v1;
if ( (_BYTE)v4 )
{
while ( (v3[v4] & 0x800) != 0 )
{
v4 = *++v1;
if ( !(_BYTE)v4 )
goto LABEL_17;
}
if ( *v1 <= 32 && *v1 )
{
do
v5 = *++v1;
while ( v5 && v5 <= 32 );
}
}
}
else
{
LABEL_59:
tp.tm_mday = atoi(v1);
}
LABEL_17:
sprintf(s, "%3.3s", v1);
if ( !strcasecmp(s, "jan") )
{
tp.tm_mon = 0;
}
else if ( !strcasecmp(s, "feb") )
{
tp.tm_mon = 1;
}
else if ( !strcasecmp(s, "mar") )
{
tp.tm_mon = 2;
}
else if ( !strcasecmp(s, "apr") )
{
tp.tm_mon = 3;
}
else if ( !strcasecmp(s, "may") )
{
tp.tm_mon = 4;
}
else if ( !strcasecmp(s, "jun") )
{
tp.tm_mon = 5;
}
else if ( !strcasecmp(s, "jul") )
{
tp.tm_mon = 6;
}
else if ( !strcasecmp(s, "aug") )
{
tp.tm_mon = 7;
}
else if ( !strcasecmp(s, "sep") )
{
tp.tm_mon = 8;
}
else if ( !strcasecmp(s, "oct") )
{
tp.tm_mon = 9;
}
else
{
tp.tm_mon = 11 - (strcasecmp(s, "nov") == 0);
}
v6 = v1 + 4;
v7 = atoi(v1 + 4);
if ( v7 > 69 )
{
if ( v7 >= 1901 )
v7 -= 1900;
tp.tm_year = v7;
}
else
{
tp.tm_year = v7 + 100;
}
v8 = v1[4];
if ( !(_BYTE)v8 )
{
LABEL_60:
tp.tm_hour = atoi(v6);
LABEL_61:
tp.tm_min = atoi(v6);
goto LABEL_62;
}
v9 = *_ctype_b_loc();
while ( (v9[v8] & 0x800) != 0 )
{
v8 = *++v6;
if ( !(_BYTE)v8 )
goto LABEL_60;
}
while ( 1 )
{
LOBYTE(v10) = *v6;
if ( !*v6 || (char)v10 > 32 )
break;
++v6;
}
tp.tm_hour = atoi(v6);
if ( !(_BYTE)v10 )
goto LABEL_61;
v11 = *_ctype_b_loc();
while ( 1 )
{
v12 = (char)v10;
LOBYTE(v10) = *++v6;
if ( (v11[v12] & 0x800) == 0 )
break;
if ( !(_BYTE)v10 )
goto LABEL_61;
}
tp.tm_min = atoi(v6);
while ( (_BYTE)v10 )
{
v13 = (char)v10;
v10 = *++v6;
if ( (v11[v13] & 0x800) == 0 )
{
tp.tm_sec = atoi(v6);
if ( (_BYTE)v10 )
{
while ( (v11[v10] & 0x800) != 0 )
{
v10 = *++v6;
if ( !(_BYTE)v10 )
goto LABEL_47;
}
while ( 1 )
{
v14 = *v6;
if ( !*v6 )
break;
if ( v14 > 32 )
{
if ( ((*_ctype_b_loc())[v14] & 0x800) == 0 && ((v14 - 43) & 0xFD) != 0 )
{
if ( strncasecmp(v6, "PDT", 3uLL)
&& strncasecmp(v6, "MDT", 3uLL)
&& strncasecmp(v6, "CDT", 3uLL)
&& strncasecmp(v6, "EDT", 3uLL)
&& strncasecmp(v6, "PST", 3uLL)
&& strncasecmp(v6, "MST", 3uLL)
&& strncasecmp(v6, "CST", 3uLL) )
{
strncasecmp(v6, "EST", 3uLL);
}
}
else
{
v15 = &v6[v14 == 43];
sprintf(nptra, "%.*s", (*v15 == 45) + 2, v15);
atoi(nptra);
atoi(&v15[(*v15 == 45) + 2]);
}
goto LABEL_47;
}
++v6;
}
}
goto LABEL_47;
}
}
LABEL_62:
tp.tm_sec = atoi(v6);
LABEL_47:
tp.tm_isdst = -1;
return mktime(&tp);
}

canonical_decompiled_code:
time_t __fastcall func1(char *nptr)
{
char *v1; // rbx
__int64 v2; // rbp
const unsigned __int16 *v3; // r12
__int64 v4; // rax
char v5; // al
const char *v6; // rbp
int v7; // eax
__int64 v8; // rbx
const unsigned __int16 *v9; // rax
__int64 v10; // rbx
const unsigned __int16 *v11; // r12
__int64 v12; // rax
__int64 v13; // rax
char v14; // bl
const char *v15; // rbp
char nptra[32]; // [rsp+14h] [rbp-98h] BYREF
char s[32]; // [rsp+34h] [rbp-78h] BYREF
struct tm tp; // [rsp+54h] [rbp-58h] BYREF

v1 = nptr;
v2 = *nptr;
tp.tm_zone = 0LL;
*(_OWORD *)&tp.tm_sec = 0LL;
*(_OWORD *)&tp.tm_mon = 0LL;
*(_OWORD *)&tp.tm_isdst = 0LL;
if ( !(_BYTE)v2 )
goto LABEL_59;
while ( (char)v2 <= 32 )
{
v2 = *++v1;
if ( !(_BYTE)v2 )
goto LABEL_59;
}
if ( (_BYTE)v2 )
{
v3 = *_ctype_b_loc();
while ( (v3[v2] & 0x800) == 0 )
{
v2 = *++v1;
if ( !(_BYTE)v2 )
goto LABEL_59;
}
tp.tm_mday = atoi(v1);
v4 = *v1;
if ( (_BYTE)v4 )
{
while ( (v3[v4] & 0x800) != 0 )
{
v4 = *++v1;
if ( !(_BYTE)v4 )
goto LABEL_17;
}
if ( *v1 <= 32 && *v1 )
{
do
v5 = *++v1;
while ( v5 && v5 <= 32 );
}
}
}
else
{
LABEL_59:
tp.tm_mday = atoi(v1);
}
LABEL_17:
sprintf(s, "%3.3s", v1);
if ( !strcasecmp(s, "jan") )
{
tp.tm_mon = 0;
}
else if ( !strcasecmp(s, "feb") )
{
tp.tm_mon = 1;
}
else if ( !strcasecmp(s, "mar") )
{
tp.tm_mon = 2;
}
else if ( !strcasecmp(s, "apr") )
{
tp.tm_mon = 3;
}
else if ( !strcasecmp(s, "may") )
{
tp.tm_mon = 4;
}
else if ( !strcasecmp(s, "jun") )
{
tp.tm_mon = 5;
}
else if ( !strcasecmp(s, "jul") )
{
tp.tm_mon = 6;
}
else if ( !strcasecmp(s, "aug") )
{
tp.tm_mon = 7;
}
else if ( !strcasecmp(s, "sep") )
{
tp.tm_mon = 8;
}
else if ( !strcasecmp(s, "oct") )
{
tp.tm_mon = 9;
}
else
{
tp.tm_mon = 11 - (strcasecmp(s, "nov") == 0);
}
v6 = v1 + 4;
v7 = atoi(v1 + 4);
if ( v7 > 69 )
{
if ( v7 >= 1901 )
v7 -= 1900;
tp.tm_year = v7;
}
else
{
tp.tm_year = v7 + 100;
}
v8 = v1[4];
if ( !(_BYTE)v8 )
{
LABEL_60:
tp.tm_hour = atoi(v6);
LABEL_61:
tp.tm_min = atoi(v6);
goto LABEL_62;
}
v9 = *_ctype_b_loc();
while ( (v9[v8] & 0x800) != 0 )
{
v8 = *++v6;
if ( !(_BYTE)v8 )
goto LABEL_60;
}
while ( 1 )
{
LOBYTE(v10) = *v6;
if ( !*v6 || (char)v10 > 32 )
break;
++v6;
}
tp.tm_hour = atoi(v6);
if ( !(_BYTE)v10 )
goto LABEL_61;
v11 = *_ctype_b_loc();
while ( 1 )
{
v12 = (char)v10;
LOBYTE(v10) = *++v6;
if ( (v11[v12] & 0x800) == 0 )
break;
if ( !(_BYTE)v10 )
goto LABEL_61;
}
tp.tm_min = atoi(v6);
while ( (_BYTE)v10 )
{
v13 = (char)v10;
v10 = *++v6;
if ( (v11[v13] & 0x800) == 0 )
{
tp.tm_sec = atoi(v6);
if ( (_BYTE)v10 )
{
while ( (v11[v10] & 0x800) != 0 )
{
v10 = *++v6;
if ( !(_BYTE)v10 )
goto LABEL_47;
}
while ( 1 )
{
v14 = *v6;
if ( !*v6 )
break;
if ( v14 > 32 )
{
if ( ((*_ctype_b_loc())[v14] & 0x800) == 0 && ((v14 - 43) & 0xFD) != 0 )
{
if ( strncasecmp(v6, "PDT", 3uLL)
&& strncasecmp(v6, "MDT", 3uLL)
&& strncasecmp(v6, "CDT", 3uLL)
&& strncasecmp(v6, "EDT", 3uLL)
&& strncasecmp(v6, "PST", 3uLL)
&& strncasecmp(v6, "MST", 3uLL)
&& strncasecmp(v6, "CST", 3uLL) )
{
strncasecmp(v6, "EST", 3uLL);
}
}
else
{
v15 = &v6[v14 == 43];
sprintf(nptra, "%.*s", (*v15 == 45) + 2, v15);
atoi(nptra);
atoi(&v15[(*v15 == 45) + 2]);
}
goto LABEL_47;
}
++v6;
}
}
goto LABEL_47;
}
}
LABEL_62:
tp.tm_sec = atoi(v6);
LABEL_47:
tp.tm_isdst = -1;
return mktime(&tp);
}

original_code:
when_t rfc822date(char* date)
{
 char* p=date;
 char str[32];
 char month[32];
 when_t when;
 struct tm tm;
 memset(&tm,0,sizeof(tm));
 memset(&when,0,sizeof(when));
 while(*p && *p<=' ') p++;
 while(*p && !((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short int) _ISdigit)) p++;
 tm.tm_mday=atoi(p);
 while(*p && ((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short int) _ISdigit)) p++;
 while(*p && *p<=' ') p++;
 sprintf(month,"%3.3s",p);
 if(!strcasecmp(month,"jan"))
  tm.tm_mon=0;
 else if(!strcasecmp(month,"feb"))
  tm.tm_mon=1;
 else if(!strcasecmp(month,"mar"))
  tm.tm_mon=2;
 else if(!strcasecmp(month,"apr"))
  tm.tm_mon=3;
 else if(!strcasecmp(month,"may"))
  tm.tm_mon=4;
 else if(!strcasecmp(month,"jun"))
  tm.tm_mon=5;
 else if(!strcasecmp(month,"jul"))
  tm.tm_mon=6;
 else if(!strcasecmp(month,"aug"))
  tm.tm_mon=7;
 else if(!strcasecmp(month,"sep"))
  tm.tm_mon=8;
 else if(!strcasecmp(month,"oct"))
  tm.tm_mon=9;
 else if(!strcasecmp(month,"nov"))
  tm.tm_mon=10;
 else
  tm.tm_mon=11;
 p+=4;
 tm.tm_year=atoi(p);
 if(tm.tm_year<70)
  tm.tm_year+=100;
 else if(tm.tm_year>1900)
  tm.tm_year-=1900;
 while(*p && ((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short int) _ISdigit)) p++;
 while(*p && *p<=' ') p++;
 tm.tm_hour=atoi(p);
 while(*p && ((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short int) _ISdigit)) p++;
 if(*p) p++;
 tm.tm_min=atoi(p);
 while(*p && ((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short int) _ISdigit)) p++;
 if(*p) p++;
 tm.tm_sec=atoi(p);
 while(*p && ((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short int) _ISdigit)) p++;
 while(*p && *p<=' ') p++;
 if(*p) {
  if(((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short int) _ISdigit) || *p=='-' || *p=='+') {
   if(*p=='+') p++;
   sprintf(str,"%.*s",*p=='-'? 3:2,p);
   when.zone=atoi(str)*60;
   p+=(*p=='-') ? 3:2;
   if(when.zone<0)
    when.zone-=atoi(p);
   else
    when.zone+=atoi(p);
  }
  else if(!strncasecmp(p,"PDT",3))
   when.zone=(short)0xC1E0;
  else if(!strncasecmp(p,"MDT",3))
   when.zone=(short)0xC1A4;
  else if(!strncasecmp(p,"CDT",3))
   when.zone=(short)0xC168;
  else if(!strncasecmp(p,"EDT",3))
   when.zone=(short)0xC12C;
  else if(!strncasecmp(p,"PST",3))
   when.zone=(short)0x41E0;
  else if(!strncasecmp(p,"MST",3))
   when.zone=(short)0x41A4;
  else if(!strncasecmp(p,"CST",3))
   when.zone=(short)0x4168;
  else if(!strncasecmp(p,"EST",3))
   when.zone=(short)0x412C;
 }
 tm.tm_isdst=-1;
 when.time=mktime(&tm);
 return(when);
}

canonical_original_code:
struct when_t rfc822date(char *date)
{
 char *p = date;
 char str[32];
 char month[32];
 struct when_t when;
 struct tm tm;
 memset(&tm,0,sizeof(tm));
 memset(&when,0,sizeof(when));
 while(*p && *p<=' ') p++;
 while(*p && !((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short) _ISdigit)) p++;
 tm.tm_mday=atoi(p);
 while(*p && ((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short) _ISdigit)) p++;
 while(*p && *p<=' ') p++;
 sprintf(month,"%3.3s",p);
 if(!strcasecmp(month,"jan"))
  tm.tm_mon=0;
 else if(!strcasecmp(month,"feb"))
  tm.tm_mon=1;
 else if(!strcasecmp(month,"mar"))
  tm.tm_mon=2;
 else if(!strcasecmp(month,"apr"))
  tm.tm_mon=3;
 else if(!strcasecmp(month,"may"))
  tm.tm_mon=4;
 else if(!strcasecmp(month,"jun"))
  tm.tm_mon=5;
 else if(!strcasecmp(month,"jul"))
  tm.tm_mon=6;
 else if(!strcasecmp(month,"aug"))
  tm.tm_mon=7;
 else if(!strcasecmp(month,"sep"))
  tm.tm_mon=8;
 else if(!strcasecmp(month,"oct"))
  tm.tm_mon=9;
 else if(!strcasecmp(month,"nov"))
  tm.tm_mon=10;
 else
  tm.tm_mon=11;
 p+=4;
 tm.tm_year=atoi(p);
 if(tm.tm_year<70)
  tm.tm_year+=100;
 else if(tm.tm_year>1900)
  tm.tm_year-=1900;
 while(*p && ((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short) _ISdigit)) p++;
 while(*p && *p<=' ') p++;
 tm.tm_hour=atoi(p);
 while(*p && ((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short) _ISdigit)) p++;
 if(*p) p++;
 tm.tm_min=atoi(p);
 while(*p && ((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short) _ISdigit)) p++;
 if(*p) p++;
 tm.tm_sec=atoi(p);
 while(*p && ((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short) _ISdigit)) p++;
 while(*p && *p<=' ') p++;
 if(*p) {
  if(((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short) _ISdigit) || *p=='-' || *p=='+') {
   if(*p=='+') p++;
   sprintf(str,"%.*s",*p=='-'? 3:2,p);
   when.zone=atoi(str)*60;
   p+=(*p=='-') ? 3:2;
   if(when.zone<0)
    when.zone-=atoi(p);
   else
    when.zone+=atoi(p);
  }
  else if(!strncasecmp(p,"PDT",3))
   when.zone=(short)0xC1E0;
  else if(!strncasecmp(p,"MDT",3))
   when.zone=(short)0xC1A4;
  else if(!strncasecmp(p,"CDT",3))
   when.zone=(short)0xC168;
  else if(!strncasecmp(p,"EDT",3))
   when.zone=(short)0xC12C;
  else if(!strncasecmp(p,"PST",3))
   when.zone=(short)0x41E0;
  else if(!strncasecmp(p,"MST",3))
   when.zone=(short)0x41A4;
  else if(!strncasecmp(p,"CST",3))
   when.zone=(short)0x4168;
  else if(!strncasecmp(p,"EST",3))
   when.zone=(short)0x412C;
 }
 tm.tm_isdst=-1;
 when.time=mktime(&tm);
 return(when);
}

variable_types:
date
char *

variable_types:
p
char *

variable_types:
str
char [32]

variable_types:
month
char [32]

return_type: struct when_t { unsigned long time; short zone; }

user_defined_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }


decompiled_code:
void __fastcall edit_table(int a1)
{
__int64 v1; // rbx
char *v2; // rdx
char *v3; // rax
char *v4; // rdx
char *v5; // rax
__int64 v6; // rdx
char *v7; // rax
__int64 v8; // rdx
char *v9; // rax
__int64 v10; // rdx
int v11; // eax
__int64 *v12; // rbp
__int16 v13; // ax
__int16 v14; // dx
__int64 *v15; // rbp
__int64 v16; // rax
__int64 *v17; // rbp
__int16 v18; // ax
__int16 v19; // dx
_BYTE *v20[6]; // [rsp+0h] [rbp-448h] BYREF
char s[1048]; // [rsp+30h] [rbp-418h] BYREF

v1 = 2LL * a1;
while ( 1 )
{
v2 = enabled;
if ( (tables[2 * a1] & 1) == 0 )
v2 = disabled[0];
sprintf(s, "Computer Player: %s", v2);
v3 = strdup(s);
v4 = enabled;
if ( (tables[2 * a1] & 2) == 0 )
v4 = disabled[0];
v20[0] = v3;
sprintf(s, "Password Protection: %s", v4);
v5 = strdup(s);
v6 = (unsigned int)SWORD1(tables[2 * a1]);
v20[1] = v5;
sprintf(s, "Ante: %d", v6);
v7 = strdup(s);
v8 = (unsigned int)SWORD2(tables[2 * a1]);
v20[2] = v7;
sprintf(s, "Bet Limit: %d", v8);
v9 = strdup(s);
v10 = tables[2 * a1 + 1];
v20[3] = v9;
sprintf(s, "Table Limit: %d", v10);
v20[4] = strdup(s);
v20[5] = strdup(&::s);
sprintf(s, "Table %d Options", (unsigned int)(a1 + 1));
v11 = ((__int64 (__fastcall *)(__int64, _QWORD, _QWORD, _QWORD, void *, void *, char *, _BYTE **))uifc[1039])(
3078LL,
0LL,
0LL,
0LL,
&opt_1,
&bar_0,
s,
v20);
if ( v11 == -1 )
break;
switch ( v11 )
{
case 0:
LOWORD(tables[2 * a1]) ^= 1u;
break;
case 1:
LOWORD(tables[2 * a1]) ^= 2u;
break;
case 2:
v17 = &tables[v1];
sprintf(s, "%d", (unsigned int)SWORD1(tables[2 * a1]));
if ( ((unsigned int (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Ante",
s,
4LL,
132LL) == -1 )
{
v19 = *((_WORD *)v17 + 1);
}
else
{
v18 = atoi(s);
*((_WORD *)v17 + 1) = v18;
v19 = v18;
}
if ( v19 < 0 )
WORD1(tables[2 * a1]) = 0;
break;
case 3:
v12 = &tables[v1];
sprintf(s, "%d", (unsigned int)SWORD2(tables[2 * a1]));
if ( ((unsigned int (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Bet Limit",
s,
4LL,
132LL) == -1 )
{
v14 = *((_WORD *)v12 + 2);
}
else
{
v13 = atoi(s);
*((_WORD *)v12 + 2) = v13;
v14 = v13;
}
if ( v14 <= 0 )
WORD2(tables[2 * a1]) = 1;
break;
case 4:
v15 = &tables[v1];
sprintf(s, "%d", tables[v1 + 1]);
if ( ((unsigned int (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Table Limit",
s,
10LL,
132LL) == -1 )
{
v16 = v15[1];
}
else
{
v16 = atoi(s);
v15[1] = (int)v16;
}
if ( !v16 )
tables[2 * a1 + 1] = 1LL;
break;
default:
break;
}
free_opts(v20);
}
free_opts(v20);
}

canonical_decompiled_code:
void __fastcall func3(int a1)
{
__int64 v1; // rbx
char *v2; // rdx
char *v3; // rax
char *v4; // rdx
char *v5; // rax
__int64 v6; // rdx
char *v7; // rax
__int64 v8; // rdx
char *v9; // rax
__int64 v10; // rdx
int v11; // eax
__int64 *v12; // rbp
__int16 v13; // ax
__int16 v14; // dx
__int64 *v15; // rbp
__int64 v16; // rax
__int64 *v17; // rbp
__int16 v18; // ax
__int16 v19; // dx
_BYTE *v20[6]; // [rsp+0h] [rbp-448h] BYREF
char s[1048]; // [rsp+30h] [rbp-418h] BYREF

v1 = 2LL * a1;
while ( 1 )
{
v2 = enabled;
if ( (tables[2 * a1] & 1) == 0 )
v2 = disabled[0];
sprintf(s, "Computer Player: %s", v2);
v3 = strdup(s);
v4 = enabled;
if ( (tables[2 * a1] & 2) == 0 )
v4 = disabled[0];
v20[0] = v3;
sprintf(s, "Password Protection: %s", v4);
v5 = strdup(s);
v6 = (unsigned int)SWORD1(tables[2 * a1]);
v20[1] = v5;
sprintf(s, "Ante: %d", v6);
v7 = strdup(s);
v8 = (unsigned int)SWORD2(tables[2 * a1]);
v20[2] = v7;
sprintf(s, "Bet Limit: %d", v8);
v9 = strdup(s);
v10 = tables[2 * a1 + 1];
v20[3] = v9;
sprintf(s, "Table Limit: %d", v10);
v20[4] = strdup(s);
v20[5] = strdup(&::s);
sprintf(s, "Table %d Options", (unsigned int)(a1 + 1));
v11 = ((__int64 (__fastcall *)(__int64, _QWORD, _QWORD, _QWORD, void *, void *, char *, _BYTE **))uifc[1039])(
3078LL,
0LL,
0LL,
0LL,
&opt_1,
&bar_0,
s,
v20);
if ( v11 == -1 )
break;
switch ( v11 )
{
case 0:
LOWORD(tables[2 * a1]) ^= 1u;
break;
case 1:
LOWORD(tables[2 * a1]) ^= 2u;
break;
case 2:
v17 = &tables[v1];
sprintf(s, "%d", (unsigned int)SWORD1(tables[2 * a1]));
if ( ((unsigned int (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Ante",
s,
4LL,
132LL) == -1 )
{
v19 = *((_WORD *)v17 + 1);
}
else
{
v18 = atoi(s);
*((_WORD *)v17 + 1) = v18;
v19 = v18;
}
if ( v19 < 0 )
WORD1(tables[2 * a1]) = 0;
break;
case 3:
v12 = &tables[v1];
sprintf(s, "%d", (unsigned int)SWORD2(tables[2 * a1]));
if ( ((unsigned int (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Bet Limit",
s,
4LL,
132LL) == -1 )
{
v14 = *((_WORD *)v12 + 2);
}
else
{
v13 = atoi(s);
*((_WORD *)v12 + 2) = v13;
v14 = v13;
}
if ( v14 <= 0 )
WORD2(tables[2 * a1]) = 1;
break;
case 4:
v15 = &tables[v1];
sprintf(s, "%d", tables[v1 + 1]);
if ( ((unsigned int (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Table Limit",
s,
10LL,
132LL) == -1 )
{
v16 = v15[1];
}
else
{
v16 = atoi(s);
v15[1] = (int)v16;
}
if ( !v16 )
tables[2 * a1 + 1] = 1LL;
break;
default:
break;
}
func2(v20);
}
func2(v20);
}

original_code:
void edit_table(int table)
{
 char *opts[6];
 char str[1024];
 int i;
 static int opt=0;
 static int bar=0;
 while(1) {
  sprintf(str,"Computer Player:     %s",tables[table].options&(1<<0)?enabled:disabled);
  opts[0]=strdup(str);
  sprintf(str,"Password Protection: %s",tables[table].options&(1<<1)?enabled:disabled);
  opts[1]=strdup(str);
  sprintf(str,"Ante:                %d",tables[table].ante);
  opts[2]=strdup(str);
  sprintf(str,"Bet Limit:           %d",tables[table].bet_limit);
  opts[3]=strdup(str);
  sprintf(str,"Table Limit:         %d",tables[table].max_total);
  opts[4]=strdup(str);
  opts[5]=strdup("");
  sprintf(str,"Table %d Options",table+1);
  i=uifc.list((1<<1)|(1<<11)|(1<<10)|(1<<2),0,0,0,&opt,&bar,str,opts);
  if(i==-1) {
   free_opts(opts);
   break;
  }
  switch(i) {
   case 0:
    tables[table].options ^= (1<<0);
    break;
   case 1:
    tables[table].options ^= (1<<1);
    break;
   case 2:
    sprintf(str,"%d",tables[table].ante);
    if(uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Ante",str,4,(1L<<7)|(1L<<2))!=-1)
     tables[table].ante=atoi(str);
    if(tables[table].ante<0)
     tables[table].ante=0;
    break;
   case 3:
    sprintf(str,"%d",tables[table].bet_limit);
    if(uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Bet Limit",str,4,(1L<<7)|(1L<<2))!=-1)
     tables[table].bet_limit=atoi(str);
    if(tables[table].bet_limit<1)
     tables[table].bet_limit=1;
    break;
   case 4:
    sprintf(str,"%d",tables[table].max_total);
    if(uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Table Limit",str,10,(1L<<7)|(1L<<2))!=-1)
     tables[table].max_total=atoi(str);
    if(tables[table].max_total<1)
     tables[table].max_total=1;
    break;
  }
  free_opts(opts);
 }
}

canonical_original_code:
void edit_table(int table)
{
 char *opts[6];
 char str[1024];
 int i;
 static int opt = 0;
 static int bar = 0;
 while(1) {
  sprintf(str,"Computer Player:     %s",tables[table].options&(1<<0)?enabled:disabled);
  opts[0]=strdup(str);
  sprintf(str,"Password Protection: %s",tables[table].options&(1<<1)?enabled:disabled);
  opts[1]=strdup(str);
  sprintf(str,"Ante:                %d",tables[table].ante);
  opts[2]=strdup(str);
  sprintf(str,"Bet Limit:           %d",tables[table].bet_limit);
  opts[3]=strdup(str);
  sprintf(str,"Table Limit:         %d",tables[table].max_total);
  opts[4]=strdup(str);
  opts[5]=strdup("");
  sprintf(str,"Table %d Options",table+1);
  i=uifc.list((1<<1)|(1<<11)|(1<<10)|(1<<2),0,0,0,&opt,&bar,str,opts);
  if(i==-1) {
   free_opts(opts);
   break;
  }
  switch(i) {
   case 0:
    tables[table].options ^= (1<<0);
    break;
   case 1:
    tables[table].options ^= (1<<1);
    break;
   case 2:
    sprintf(str,"%d",tables[table].ante);
    if(uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Ante",str,4,(1L<<7)|(1L<<2))!=-1)
     tables[table].ante=atoi(str);
    if(tables[table].ante<0)
     tables[table].ante=0;
    break;
   case 3:
    sprintf(str,"%d",tables[table].bet_limit);
    if(uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Bet Limit",str,4,(1L<<7)|(1L<<2))!=-1)
     tables[table].bet_limit=atoi(str);
    if(tables[table].bet_limit<1)
     tables[table].bet_limit=1;
    break;
   case 4:
    sprintf(str,"%d",tables[table].max_total);
    if(uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Table Limit",str,10,(1L<<7)|(1L<<2))!=-1)
     tables[table].max_total=atoi(str);
    if(tables[table].max_total<1)
     tables[table].max_total=1;
    break;
  }
  free_opts(opts);
 }
}

variable_types: table int

variable_types:
opts
char *[6]

variable_types:
str
char [1024]

variable_types: i int

variable_types: opt int

variable_types: bar int


decompiled_code:
void __fastcall free_opts(_BYTE **a1)
{
_BYTE *v2; // rdi
_BYTE **v3; // rbx

v2 = *a1;
if ( v2 )
{
v3 = a1 + 1;
while ( *v2 )
{
free(v2);
v2 = *v3++;
if ( !v2 )
return;
}
free(v2);
}
}

canonical_decompiled_code:
void __fastcall func2(_BYTE **a1)
{
_BYTE *v2; // rdi
_BYTE **v3; // rbx

v2 = *a1;
if ( v2 )
{
v3 = a1 + 1;
while ( *v2 )
{
free(v2);
v2 = *v3++;
if ( !v2 )
return;
}
free(v2);
}
}

original_code:
void free_opts(char **opts)
{
 int i;
 for(i=0; opts[i]!=((void *)0) && opts[i][0]; i++) {
  free(opts[i]);
 }
 if(opts[i]!=((void *)0))
  free(opts[i]);
}

variable_types:
opts
char **


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // er13
char **v5; // rbp
char **v6; // rbx
int v7; // eax
int v8; // edx
int v9; // ebx
char *v10; // r8
int v11; // eax
__int16 v12; // dx
unsigned __int64 v13; // rax
int v14; // eax
__int16 v15; // dx
int v16; // eax
__int64 v18; // rsi
__int64 v19; // [rsp+0h] [rbp-488h] BYREF
unsigned int v20; // [rsp+8h] [rbp-480h] BYREF
int v21; // [rsp+Ch] [rbp-47Ch] BYREF
__int64 v22[4]; // [rsp+10h] [rbp-478h] BYREF
_BYTE *v23[6]; // [rsp+30h] [rbp-458h] BYREF
char s[1064]; // [rsp+60h] [rbp-428h] BYREF

v19 = 0LL;
v20 = 0;
v22[0] = (__int64)"Yes";
v22[1] = (__int64)"No";
v22[2] = (__int64)&::s;
read_ini();
memset(uifc, 0, sizeof(uifc));
uifc[0] = 8384LL;
HIDWORD(uifc[4]) = 25;
v3 = uifcini32(uifc);
v21 = v3;
v4 = v3;
if ( v3 )
{
v4 = -1;
fprintf(stderr, "uifc library init returned error %d\n", v3);
}
else
{
if ( ((unsigned int (__fastcall *)(const char *))uifc[1036])("Domain Poker Config") )
{
v18 = (unsigned int)(HIDWORD(uifc[3]) + 1);
printf(" USCRN (len=%d) failed!\n", v18);
((void (*)(const char *, ...))uifc[1035])(" USCRN (len=%d) failed!\n", v18);
}
v5 = (char **)malloc(0xD0uLL);
if ( v5 )
{
LABEL_5:
sprintf(s, "Computer Player's Name: %s", comp_name);
v23[0] = strdup(s);
sprintf(s, "Number of Tables: %d", (unsigned int)num_tables);
v23[1] = strdup(s);
sprintf(s, "Time allow playing computer: %d", time_allowed);
v23[2] = strdup(s);
sprintf(s, "Percentage house takes from pot: %d%%", (unsigned int)skim);
v23[3] = strdup(s);
v23[4] = strdup("Table configuration...");
v23[5] = strdup(&::s);
switch ( ((unsigned int (__fastcall *)(__int64, _QWORD, _QWORD, _QWORD, __int64 *, _QWORD, const char *, _BYTE **))uifc[1039])(
25LL,
0LL,
0LL,
0LL,
&v19,
0LL,
"Main Options",
v23) )
{
case 0xFFFFFFFF:
v21 = 0;
v16 = ((__int64 (__fastcall *)(__int64, _QWORD, _QWORD, _QWORD, int *, _QWORD, const char *, __int64 *, __int64, _QWORD))uifc[1039])(
24LL,
0LL,
0LL,
0LL,
&v21,
0LL,
"Save Changes?",
v22,
v19,
v20);
if ( v16 )
{
if ( v16 != 1 )
goto LABEL_22;
}
else
{
write_ini();
v4 = 0;
}
return v4;
case 0u:
((void (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Computer's Name",
comp_name,
40LL,
128LL);
goto LABEL_22;
case 1u:
sprintf(s, "%d", (unsigned int)num_tables);
v14 = ((__int64 (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Number of Tables",
s,
2LL,
132LL);
v15 = num_tables;
if ( v14 != -1 )
{
num_tables = atoi(s);
v15 = num_tables;
}
if ( v15 <= 25 )
{
if ( v15 <= 0 )
num_tables = 1;
}
else
{
num_tables = 25;
}
goto LABEL_22;
case 2u:
sprintf(s, "%d", time_allowed);
if ( ((unsigned int (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Time allowed computer",
s,
5LL,
132LL) == -1 )
{
v13 = time_allowed;
}
else
{
v13 = atoi(s);
time_allowed = (int)v13;
}
if ( v13 > 0x15180 )
time_allowed = 86400LL;
goto LABEL_22;
case 3u:
sprintf(s, "%d", (unsigned int)skim);
v11 = ((__int64 (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Percentage to house",
s,
2LL,
132LL);
v12 = skim;
if ( v11 != -1 )
{
skim = atoi(s);
v12 = skim;
}
if ( v12 < 0 )
{
skim = 0;
}
else if ( v12 > 50 )
{
skim = 50;
}
goto LABEL_22;
case 4u:
goto LABEL_13;
default:
goto LABEL_22;
}
while ( 1 )
{
LABEL_13:
v21 = 0;
if ( num_tables <= 0 )
{
v6 = v5;
}
else
{
v8 = 0;
do
{
sprintf(s, "Table %d", (unsigned int)(v8 + 1));
v9 = v21;
v10 = strdup(s);
v8 = v9 + 1;
v5[v9] = v10;
v21 = v9 + 1;
}
while ( v9 + 1 < num_tables );
v6 = &v5[v8];
}
*v6 = strdup(&::s);
v7 = ((__int64 (__fastcall *)(__int64, _QWORD, _QWORD, _QWORD, char *, unsigned int *, const char *, char **))uifc[1039])(
485LL,
0LL,
0LL,
0LL,
(char *)&v19 + 4,
&v20,
"Table Options",
v5);
v21 = v7;
if ( v7 == -1 )
{
free_opts(v5);
LABEL_22:
free_opts(v23);
goto LABEL_5;
}
if ( num_tables == HIDWORD(v19) )
{
v21 = HIDWORD(v19) | 0x10000000;
}
else if ( (v7 & 0x10000000) == 0 )
{
if ( (v7 & 0x20000000) != 0 )
{
if ( num_tables > 1 )
{
--num_tables;
memcpy(&tables[2 * HIDWORD(v19)], &tables[2 * HIDWORD(v19) + 2], 16LL * (24 - HIDWORD(v19)));
LODWORD(tables[48]) = 16384001;
WORD2(tables[48]) = 250;
tables[49] = 1000LL;
}
}
else
{
edit_table(SHIDWORD(v19));
}
goto LABEL_12;
}
if ( num_tables <= 24 )
{
++num_tables;
memcpy(&tables[2 * SHIDWORD(v19) + 2], &tables[2 * SHIDWORD(v19)], 16LL * (24 - HIDWORD(v19)));
}
LABEL_12:
free_opts(v5);
}
}
v4 = 1;
fwrite("MALLOC() error!\r\n", 1uLL, 0x11uLL, stderr);
}
return v4;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // er13
char **v5; // rbp
char **v6; // rbx
int v7; // eax
int v8; // edx
int v9; // ebx
char *v10; // r8
int v11; // eax
__int16 v12; // dx
unsigned __int64 v13; // rax
int v14; // eax
__int16 v15; // dx
int v16; // eax
__int64 v18; // rsi
__int64 v19; // [rsp+0h] [rbp-488h] BYREF
unsigned int v20; // [rsp+8h] [rbp-480h] BYREF
int v21; // [rsp+Ch] [rbp-47Ch] BYREF
__int64 v22[4]; // [rsp+10h] [rbp-478h] BYREF
_BYTE *v23[6]; // [rsp+30h] [rbp-458h] BYREF
char s[1064]; // [rsp+60h] [rbp-428h] BYREF

v19 = 0LL;
v20 = 0;
v22[0] = (__int64)"Yes";
v22[1] = (__int64)"No";
v22[2] = (__int64)&::s;
func0();
memset(uifc, 0, sizeof(uifc));
uifc[0] = 8384LL;
HIDWORD(uifc[4]) = 25;
v3 = uifcini32(uifc);
v21 = v3;
v4 = v3;
if ( v3 )
{
v4 = -1;
fprintf(stderr, "uifc library init returned error %d\n", v3);
}
else
{
if ( ((unsigned int (__fastcall *)(const char *))uifc[1036])("Domain Poker Config") )
{
v18 = (unsigned int)(HIDWORD(uifc[3]) + 1);
printf(" USCRN (len=%d) failed!\n", v18);
((void (*)(const char *, ...))uifc[1035])(" USCRN (len=%d) failed!\n", v18);
}
v5 = (char **)malloc(0xD0uLL);
if ( v5 )
{
LABEL_5:
sprintf(s, "Computer Player's Name: %s", comp_name);
v23[0] = strdup(s);
sprintf(s, "Number of Tables: %d", (unsigned int)num_tables);
v23[1] = strdup(s);
sprintf(s, "Time allow playing computer: %d", time_allowed);
v23[2] = strdup(s);
sprintf(s, "Percentage house takes from pot: %d%%", (unsigned int)skim);
v23[3] = strdup(s);
v23[4] = strdup("Table configuration...");
v23[5] = strdup(&::s);
switch ( ((unsigned int (__fastcall *)(__int64, _QWORD, _QWORD, _QWORD, __int64 *, _QWORD, const char *, _BYTE **))uifc[1039])(
25LL,
0LL,
0LL,
0LL,
&v19,
0LL,
"Main Options",
v23) )
{
case 0xFFFFFFFF:
v21 = 0;
v16 = ((__int64 (__fastcall *)(__int64, _QWORD, _QWORD, _QWORD, int *, _QWORD, const char *, __int64 *, __int64, _QWORD))uifc[1039])(
24LL,
0LL,
0LL,
0LL,
&v21,
0LL,
"Save Changes?",
v22,
v19,
v20);
if ( v16 )
{
if ( v16 != 1 )
goto LABEL_22;
}
else
{
func1();
v4 = 0;
}
return v4;
case 0u:
((void (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Computer's Name",
comp_name,
40LL,
128LL);
goto LABEL_22;
case 1u:
sprintf(s, "%d", (unsigned int)num_tables);
v14 = ((__int64 (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Number of Tables",
s,
2LL,
132LL);
v15 = num_tables;
if ( v14 != -1 )
{
num_tables = atoi(s);
v15 = num_tables;
}
if ( v15 <= 25 )
{
if ( v15 <= 0 )
num_tables = 1;
}
else
{
num_tables = 25;
}
goto LABEL_22;
case 2u:
sprintf(s, "%d", time_allowed);
if ( ((unsigned int (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Time allowed computer",
s,
5LL,
132LL) == -1 )
{
v13 = time_allowed;
}
else
{
v13 = atoi(s);
time_allowed = (int)v13;
}
if ( v13 > 0x15180 )
time_allowed = 86400LL;
goto LABEL_22;
case 3u:
sprintf(s, "%d", (unsigned int)skim);
v11 = ((__int64 (__fastcall *)(__int64, _QWORD, _QWORD, const char *, char *, __int64, __int64))uifc[1040])(
26LL,
0LL,
0LL,
"Percentage to house",
s,
2LL,
132LL);
v12 = skim;
if ( v11 != -1 )
{
skim = atoi(s);
v12 = skim;
}
if ( v12 < 0 )
{
skim = 0;
}
else if ( v12 > 50 )
{
skim = 50;
}
goto LABEL_22;
case 4u:
goto LABEL_13;
default:
goto LABEL_22;
}
while ( 1 )
{
LABEL_13:
v21 = 0;
if ( num_tables <= 0 )
{
v6 = v5;
}
else
{
v8 = 0;
do
{
sprintf(s, "Table %d", (unsigned int)(v8 + 1));
v9 = v21;
v10 = strdup(s);
v8 = v9 + 1;
v5[v9] = v10;
v21 = v9 + 1;
}
while ( v9 + 1 < num_tables );
v6 = &v5[v8];
}
*v6 = strdup(&::s);
v7 = ((__int64 (__fastcall *)(__int64, _QWORD, _QWORD, _QWORD, char *, unsigned int *, const char *, char **))uifc[1039])(
485LL,
0LL,
0LL,
0LL,
(char *)&v19 + 4,
&v20,
"Table Options",
v5);
v21 = v7;
if ( v7 == -1 )
{
func2(v5);
LABEL_22:
func2(v23);
goto LABEL_5;
}
if ( num_tables == HIDWORD(v19) )
{
v21 = HIDWORD(v19) | 0x10000000;
}
else if ( (v7 & 0x10000000) == 0 )
{
if ( (v7 & 0x20000000) != 0 )
{
if ( num_tables > 1 )
{
--num_tables;
memcpy(&tables[2 * HIDWORD(v19)], &tables[2 * HIDWORD(v19) + 2], 16LL * (24 - HIDWORD(v19)));
LODWORD(tables[48]) = 16384001;
WORD2(tables[48]) = 250;
tables[49] = 1000LL;
}
}
else
{
func3(SHIDWORD(v19));
}
goto LABEL_12;
}
if ( num_tables <= 24 )
{
++num_tables;
memcpy(&tables[2 * SHIDWORD(v19) + 2], &tables[2 * SHIDWORD(v19)], 16LL * (24 - HIDWORD(v19)));
}
LABEL_12:
func2(v5);
}
}
v4 = 1;
fwrite("MALLOC() error!\r\n", 1uLL, 0x11uLL, stderr);
}
return v4;
}

original_code:
int main(int argc, char **argv)
{
 char *opts[6];
 char **topts;
 char str[1024];
 int opt=0;
 int topt=0;
 int tbar=0;
 char *YesNo[3]={"Yes","No",""};
 int i;
 read_ini();
    memset(&uifc,0,sizeof(uifc));
 uifc.size=sizeof(uifc);
 uifc.esc_delay=25;
 if((i=uifcini32(&uifc))!=0) {
  fprintf(stderr,"uifc library init returned error %d\n",i);
  return(-1);
 }
 if(uifc.scrn("Domain Poker Config")) {
  printf(" USCRN (len=%d) failed!\n",uifc.scrn_len+1);
  uifc.bail();
 }
 topts=(char **)malloc(sizeof(char *)*(25 +1));
 if(topts==((void *)0)) {
  fprintf(stderr,"MALLOC() error!\r\n");
  return(1);
 }
 while(1) {
  sprintf(str,"Computer Player's Name:          %s",comp_name);
  opts[0]=strdup(str);
  sprintf(str,"Number of Tables:                %d",num_tables);
  opts[1]=strdup(str);
  sprintf(str,"Time allow playing computer:     %d",time_allowed);
  opts[2]=strdup(str);
  sprintf(str,"Percentage house takes from pot: %d%%",skim);
  opts[3]=strdup(str);
  opts[4]=strdup("Table configuration...");
  opts[5]=strdup("");
  switch(uifc.list((1<<0)|(1<<3)|(1<<4),0,0,0,&opt,((void *)0),"Main Options",opts)) {
   case -1:
    i=0;
    switch(uifc.list((1<<3)|(1<<4),0,0,0,&i,((void *)0),"Save Changes?",YesNo)) {
     case 0:
      write_ini();
     case 1:
      return(0);
    }
    break;
   case 0:
    uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Computer's Name",comp_name,sizeof(comp_name)-1,(1L<<7));
    break;
   case 1:
    sprintf(str,"%d",num_tables);
    if(uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Number of Tables",str,2,(1L<<7)|(1L<<2))!=-1)
     num_tables=atoi(str);
    if(num_tables>25)
     num_tables=25;
    if(num_tables<1)
     num_tables=1;
    break;
   case 2:
    sprintf(str,"%d",time_allowed);
    if(uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Time allowed computer",str,5,(1L<<7)|(1L<<2))!=-1)
     time_allowed=atoi(str);
    if(time_allowed>86400 || time_allowed<0)
     time_allowed=86400;
    break;
   case 3:
    sprintf(str,"%d",skim);
    if(uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Percentage to house",str,2,(1L<<7)|(1L<<2))!=-1)
     skim=atoi(str);
    if(skim<0)
     skim=0;
    if(skim>50)
     skim=50;
    break;
   case 4:
    while(1) {
     for(i=0;i<num_tables;i++) {
      sprintf(str,"Table %d",i+1);
      topts[i]=strdup(str);
     }
     topts[i]=strdup("");
     i=uifc.list((1<<0)|(1<<7)|(1<<5)|(1<<2)|(1<<8)|(1<<6),0,0,0,&topt,&tbar,"Table Options",topts);
     if(i==-1) {
      free_opts(topts);
      break;
     }
     if(topt==num_tables)
      i=topt|0x10000000;
     if(i&0x10000000) {
      if(num_tables<25) {
       num_tables++;
       memcpy(&tables[topt+1],&tables[topt],sizeof(tables[topt])*(25 -topt-1));
      }
     }
     else if(i&0x20000000) {
      if(num_tables>1) {
       num_tables--;
       memcpy(&tables[topt],&tables[topt+1],sizeof(tables[topt])*(25 -topt-1));
       tables[25 -1].options=(1<<0);
       tables[25 -1].ante=250;
       tables[25 -1].bet_limit=250;
       tables[25 -1].max_total=1000;
      }
     }
     else {
      edit_table(topt);
     }
     free_opts(topts);
    }
    break;
  }
  free_opts(opts);
 }
 return(1);
}

canonical_original_code:
int main(int argc, char **argv)
{
 char *opts[6];
 char **topts;
 char str[1024];
 int opt = 0;
 int topt = 0;
 int tbar = 0;
 char *YesNo[3] = {"Yes","No",""};
 int i;
 read_ini();
    memset(&uifc,0,sizeof(uifc));
 uifc.size=sizeof(uifc);
 uifc.esc_delay=25;
 if((i=uifcini32(&uifc))!=0) {
  fprintf(stderr,"uifc library init returned error %d\n",i);
  return(-1);
 }
 if(uifc.scrn("Domain Poker Config")) {
  printf(" USCRN (len=%d) failed!\n",uifc.scrn_len+1);
  uifc.bail();
 }
 topts=(char **)malloc(sizeof(char *)*(25 +1));
 if(topts==((void *)0)) {
  fprintf(stderr,"MALLOC() error!\r\n");
  return(1);
 }
 while(1) {
  sprintf(str,"Computer Player's Name:          %s",comp_name);
  opts[0]=strdup(str);
  sprintf(str,"Number of Tables:                %d",num_tables);
  opts[1]=strdup(str);
  sprintf(str,"Time allow playing computer:     %d",time_allowed);
  opts[2]=strdup(str);
  sprintf(str,"Percentage house takes from pot: %d%%",skim);
  opts[3]=strdup(str);
  opts[4]=strdup("Table configuration...");
  opts[5]=strdup("");
  switch(uifc.list((1<<0)|(1<<3)|(1<<4),0,0,0,&opt,((void *)0),"Main Options",opts)) {
   case -1:
    i=0;
    switch(uifc.list((1<<3)|(1<<4),0,0,0,&i,((void *)0),"Save Changes?",YesNo)) {
     case 0:
      write_ini();
     case 1:
      return(0);
    }
    break;
   case 0:
    uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Computer's Name",comp_name,sizeof(comp_name)-1,(1L<<7));
    break;
   case 1:
    sprintf(str,"%d",num_tables);
    if(uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Number of Tables",str,2,(1L<<7)|(1L<<2))!=-1)
     num_tables=atoi(str);
    if(num_tables>25)
     num_tables=25;
    if(num_tables<1)
     num_tables=1;
    break;
   case 2:
    sprintf(str,"%d",time_allowed);
    if(uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Time allowed computer",str,5,(1L<<7)|(1L<<2))!=-1)
     time_allowed=atoi(str);
    if(time_allowed>86400 || time_allowed<0)
     time_allowed=86400;
    break;
   case 3:
    sprintf(str,"%d",skim);
    if(uifc.input((1<<3)|(1<<4)|(1<<1),0,0,"Percentage to house",str,2,(1L<<7)|(1L<<2))!=-1)
     skim=atoi(str);
    if(skim<0)
     skim=0;
    if(skim>50)
     skim=50;
    break;
   case 4:
    while(1) {
     for(i=0;i<num_tables;i++) {
      sprintf(str,"Table %d",i+1);
      topts[i]=strdup(str);
     }
     topts[i]=strdup("");
     i=uifc.list((1<<0)|(1<<7)|(1<<5)|(1<<2)|(1<<8)|(1<<6),0,0,0,&topt,&tbar,"Table Options",topts);
     if(i==-1) {
      free_opts(topts);
      break;
     }
     if(topt==num_tables)
      i=topt|0x10000000;
     if(i&0x10000000) {
      if(num_tables<25) {
       num_tables++;
       memcpy(&tables[topt+1],&tables[topt],sizeof(tables[topt])*(25 -topt-1));
      }
     }
     else if(i&0x20000000) {
      if(num_tables>1) {
       num_tables--;
       memcpy(&tables[topt],&tables[topt+1],sizeof(tables[topt])*(25 -topt-1));
       tables[25 -1].options=(1<<0);
       tables[25 -1].ante=250;
       tables[25 -1].bet_limit=250;
       tables[25 -1].max_total=1000;
      }
     }
     else {
      edit_table(topt);
     }
     free_opts(topts);
    }
    break;
  }
  free_opts(opts);
 }
 return(1);
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
topts
char **

variable_types: topt int

variable_types: tbar int

variable_types:
YesNo
char *[3]


viewscroll

decompiled_code:
void viewscroll()
{
unsigned int v0; // er13
unsigned int v1; // er12
char *v2; // rbp
int v3; // er13
__int64 v4; // rcx
int i; // eax
int v6; // eax
signed int v7; // ebx
char v8[7]; // [rsp+5h] [rbp-33h] BYREF
unsigned __int8 v9; // [rsp+Ch] [rbp-2Ch]
unsigned __int8 v10; // [rsp+Dh] [rbp-2Bh]

ciolib_gettextinfo(v8);
v0 = v9;
v1 = v10;
v2 = (char *)malloc(2 * v10 * (v9 + 1000));
memcpy(v2, *((const void **)&cterm + 265), (int)(2000 * v1));
ciolib_gettext(1LL, 1LL, v1, v0, &v2[2 * *((_DWORD *)&cterm + 1) * *((_DWORD *)&cterm + 532)]);
v3 = *((_DWORD *)&cterm + 532);
v4 = v9;
for ( i = v3; ; i = *((_DWORD *)&cterm + 532) )
{
if ( v3 <= 0 )
v3 = 1;
if ( v3 > i )
v3 = i;
ciolib_puttext(1LL, 1LL, v10, v4, &v2[2 * v3 * v10]);
v6 = ciolib_getch();
if ( v6 <= 108 )
break;
if ( v6 != 255 )
goto LABEL_10;
LABEL_16:
v7 = ((unsigned int)ciolib_getch() << 8) | v6;
if ( v7 == 20480 )
{
LABEL_13:
v4 = v9;
++v3;
}
else if ( v7 > 20480 )
{
if ( v7 != 20736 )
goto LABEL_10;
LABEL_12:
v4 = v9;
v3 += v9;
}
else if ( v7 == 18432 )
{
LABEL_14:
v4 = v9;
--v3;
}
else
{
if ( v7 != 18688 )
goto LABEL_10;
LABEL_20:
v4 = v9;
v3 -= v9;
}
LABEL_11:
;
}
if ( v6 > 71 )
{
switch ( v6 )
{
case 'H':
case 'h':
goto LABEL_20;
case 'J':
case 'j':
goto LABEL_14;
case 'K':
case 'k':
goto LABEL_13;
case 'L':
case 'l':
goto LABEL_12;
default:
goto LABEL_10;
}
}
if ( !v6 )
goto LABEL_16;
if ( v6 != 27 )
{
LABEL_10:
v4 = v9;
goto LABEL_11;
}
free(v2);
}

canonical_decompiled_code:
void func0()
{
unsigned int v0; // er13
unsigned int v1; // er12
char *v2; // rbp
int v3; // er13
__int64 v4; // rcx
int i; // eax
int v6; // eax
signed int v7; // ebx
char v8[7]; // [rsp+5h] [rbp-33h] BYREF
unsigned __int8 v9; // [rsp+Ch] [rbp-2Ch]
unsigned __int8 v10; // [rsp+Dh] [rbp-2Bh]

ciolib_gettextinfo(v8);
v0 = v9;
v1 = v10;
v2 = (char *)malloc(2 * v10 * (v9 + 1000));
memcpy(v2, *((const void **)&cterm + 265), (int)(2000 * v1));
ciolib_gettext(1LL, 1LL, v1, v0, &v2[2 * *((_DWORD *)&cterm + 1) * *((_DWORD *)&cterm + 532)]);
v3 = *((_DWORD *)&cterm + 532);
v4 = v9;
for ( i = v3; ; i = *((_DWORD *)&cterm + 532) )
{
if ( v3 <= 0 )
v3 = 1;
if ( v3 > i )
v3 = i;
ciolib_puttext(1LL, 1LL, v10, v4, &v2[2 * v3 * v10]);
v6 = ciolib_getch();
if ( v6 <= 108 )
break;
if ( v6 != 255 )
goto LABEL_10;
LABEL_16:
v7 = ((unsigned int)ciolib_getch() << 8) | v6;
if ( v7 == 20480 )
{
LABEL_13:
v4 = v9;
++v3;
}
else if ( v7 > 20480 )
{
if ( v7 != 20736 )
goto LABEL_10;
LABEL_12:
v4 = v9;
v3 += v9;
}
else if ( v7 == 18432 )
{
LABEL_14:
v4 = v9;
--v3;
}
else
{
if ( v7 != 18688 )
goto LABEL_10;
LABEL_20:
v4 = v9;
v3 -= v9;
}
LABEL_11:
;
}
if ( v6 > 71 )
{
switch ( v6 )
{
case 'H':
case 'h':
goto LABEL_20;
case 'J':
case 'j':
goto LABEL_14;
case 'K':
case 'k':
goto LABEL_13;
case 'L':
case 'l':
goto LABEL_12;
default:
goto LABEL_10;
}
}
if ( !v6 )
goto LABEL_16;
if ( v6 != 27 )
{
LABEL_10:
v4 = v9;
goto LABEL_11;
}
free(v2);
}

original_code:
void viewscroll(void)
{
 int top;
 int key;
 int i;
 char *scrollback;
 struct text_info txtinfo;
    ciolib_gettextinfo(&txtinfo);
 scrollback=(char *)malloc((txtinfo.screenwidth*2*1000)+(txtinfo.screenheight*txtinfo.screenwidth*2));
 memcpy(scrollback,cterm.scrollback,txtinfo.screenwidth*2*1000);
 ciolib_gettext(1,1,txtinfo.screenwidth,txtinfo.screenheight,scrollback+(cterm.backpos)*cterm.width*2);
 top=cterm.backpos;
 for(i=0;!i;) {
  if(top<1)
   top=1;
  if(top>cterm.backpos)
   top=cterm.backpos;
  ciolib_puttext(1,1,txtinfo.screenwidth,txtinfo.screenheight,scrollback+(txtinfo.screenwidth*2*top));
  key=ciolib_getch();
  switch(key) {
   case 0xff:
   case 0:
    switch(key|ciolib_getch()<<8) {
     case (72 << 8):
      top--;
      break;
     case (80 << 8):
      top++;
      break;
     case (0x49 << 8):
      top-=txtinfo.screenheight;
      break;
     case (0x51 << 8):
      top+=txtinfo.screenheight;
      break;
    }
    break;
   case 'j':
   case 'J':
    top--;
    break;
   case 'k':
   case 'K':
    top++;
    break;
   case 'h':
   case 'H':
    top-=txtinfo.screenheight;
    break;
   case 'l':
   case 'L':
    top+=txtinfo.screenheight;
    break;
   case '\033':
    i=1;
    break;
  }
 }
 free(scrollback);
 return;
}

canonical_original_code:
void viewscroll()
{
 int top;
 int key;
 int i;
 char *scrollback;
 struct text_info txtinfo;
    ciolib_gettextinfo(&txtinfo);
 scrollback=(char *)malloc((txtinfo.screenwidth*2*1000)+(txtinfo.screenheight*txtinfo.screenwidth*2));
 memcpy(scrollback,cterm.scrollback,txtinfo.screenwidth*2*1000);
 ciolib_gettext(1,1,txtinfo.screenwidth,txtinfo.screenheight,scrollback+(cterm.backpos)*cterm.width*2);
 top=cterm.backpos;
 for(i=0;!i;) {
  if(top<1)
   top=1;
  if(top>cterm.backpos)
   top=cterm.backpos;
  ciolib_puttext(1,1,txtinfo.screenwidth,txtinfo.screenheight,scrollback+(txtinfo.screenwidth*2*top));
  key=ciolib_getch();
  switch(key) {
   case 0xff:
   case 0:
    switch(key|ciolib_getch()<<8) {
     case (72 << 8):
      top--;
      break;
     case (80 << 8):
      top++;
      break;
     case (0x49 << 8):
      top-=txtinfo.screenheight;
      break;
     case (0x51 << 8):
      top+=txtinfo.screenheight;
      break;
    }
    break;
   case 'j':
   case 'J':
    top--;
    break;
   case 'k':
   case 'K':
    top++;
    break;
   case 'h':
   case 'H':
    top-=txtinfo.screenheight;
    break;
   case 'l':
   case 'L':
    top+=txtinfo.screenheight;
    break;
   case '\033':
    i=1;
    break;
  }
 }
 free(scrollback);
 return;
}

variable_types: top int

variable_types: key int

variable_types:
scrollback
char *

variable_types: struct text_info { unsigned char winleft; unsigned char wintop; unsigned char winright; unsigned char winbottom; unsigned char attribute; unsigned char normattr; unsigned char currmode; unsigned char screenheight; unsigned char screenwidth; unsigned char curx; unsigned char cury; }


lfexpand

decompiled_code:
void *__fastcall lfexpand(void *dest, int *a2)
{
void *v2; // r8
char *v4; // rdx
int v5; // ecx
char *v6; // rdi
char v7; // si
int v8; // eax
size_t v9; // rdx
char v11[2056]; // [rsp+0h] [rbp-808h] BYREF

v2 = dest;
if ( *a2 <= 0 )
{
v9 = 0LL;
v5 = 0;
}
else
{
v4 = (char *)dest;
v5 = 0;
v6 = (char *)dest + (unsigned int)(*a2 - 1) + 1;
do
{
v7 = *v4;
v8 = v5;
if ( *v4 == 10 )
{
v8 = v5 + 1;
v11[v5] = 13;
}
v5 = v8 + 1;
++v4;
v11[v8] = v7;
}
while ( v4 != v6 );
v9 = v5;
}
*a2 = v5;
return memcpy(v2, v11, v9);
}

original_code:
void lfexpand(char *buf, int *len)
{
 char newbuf[1024*2];
 int newlen=0;
 int i;
 for(i=0; i<*len; i++) {
  if(buf[i]=='\n') {
   newbuf[newlen++]='\r';
  }
  newbuf[newlen++]=buf[i];
 }
 *len=newlen;
 memcpy(buf, newbuf, newlen);
 return;
}

canonical_original_code:
void lfexpand(char *buf, int *len)
{
 char newbuf[-1];
 int newlen = 0;
 int i;
 for(i=0; i<*len; i++) {
  if(buf[i]=='\n') {
   newbuf[newlen++]='\r';
  }
  newbuf[newlen++]=buf[i];
 }
 *len=newlen;
 memcpy(buf, newbuf, newlen);
 return;
}

variable_types:
buf
char *

variable_types:
len
int *

variable_types:
newbuf
char [-1]

variable_types: newlen int


getstats

decompiled_code:
__int64 __fastcall getstats(__int64 a1, char a2, void *a3)
{
const char *v4; // rdx
int v5; // er12
__int64 result; // rax
char v7[4136]; // [rsp+0h] [rbp-1028h] BYREF

v4 = (const char *)(a1 + 5972);
if ( a2 )
v4 = (const char *)(a1 + ((__int64)(a2 - 1) << 6) + 6420);
sprintf(v7, "%sdsts.dab", v4);
v5 = nopen(v7, 0LL);
result = 0LL;
if ( v5 != -1 )
{
lseek(v5, 4LL, 0);
read(v5, a3, 0x60uLL);
close(v5);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, char a2, void *a3)
{
const char *v4; // rdx
int v5; // er12
__int64 result; // rax
char v7[4136]; // [rsp+0h] [rbp-1028h] BYREF

v4 = (const char *)(a1 + 5972);
if ( a2 )
v4 = (const char *)(a1 + ((__int64)(a2 - 1) << 6) + 6420);
sprintf(v7, "%sdsts.dab", v4);
v5 = nopen(v7, 0LL);
result = 0LL;
if ( v5 != -1 )
{
lseek(v5, 4LL, 0);
read(v5, a3, 0x60uLL);
close(v5);
result = 1LL;
}
return result;
}

original_code:
int getstats(scfg_t* cfg, char node, stats_t* stats)
{
    char str[4096 +1];
    int file;
    sprintf(str,"%sdsts.dab",node ? cfg->node_path[node-1] : cfg->ctrl_dir);
    if((file=nopen(str,00))==-1) {
        return(0);
 }
    lseek(file,4L,0);
    read(file,stats,sizeof(stats_t));
    close(file);
 return(1);
}

canonical_original_code:
int getstats(struct scfg_t *cfg, char node, struct stats_t *stats)
{
    char str[-1];
    int file;
    sprintf(str,"%sdsts.dab",node ? cfg->node_path[node-1] : cfg->ctrl_dir);
    if((file=nopen(str,00))==-1) {
        return(0);
 }
    lseek(file,4L,0);
    read(file,stats,sizeof(stats_t));
    close(file);
 return(1);
}

variable_types: struct scfg_t { unsigned long size; int prepped; struct grp_t { char lname[-1]; unsigned char *ar; } **grp; unsigned short total_grps; struct sub_t { char code[-1]; char code_suffix[-1]; char lname[-1]; unsigned char *ar; unsigned short grp; unsigned long misc; struct fidoaddr_t { unsigned short zone; unsigned short net; unsigned short node; unsigned short point; } faddr; } **sub; unsigned short total_subs; struct lib_t { char lname[-1]; unsigned char *ar; unsigned short offline_dir; } **lib; unsigned short total_libs; struct dir_t { char code[-1]; char code_suffix[-1]; char lname[-1]; unsigned char *ar; unsigned short maxfiles; unsigned long misc; } **dir; unsigned short total_dirs; struct txtsec_t { char code[-1]; char name[41]; unsigned char *ar; } **txtsec; unsigned short total_txtsecs; struct xtrnsec_t { char code[-1]; char name[41]; unsigned char *ar; } **xtrnsec; unsigned short total_xtrnsecs; struct xtrn_t { char code[-1]; char name[41]; unsigned char *ar; unsigned char type; unsigned short sec; unsigned long cost; } **xtrn; unsigned short total_xtrns; struct mdm_result_t { unsigned short code; char str[-1]; } *mdm_result; unsigned short mdm_results; struct prot_t { char mnemonic; char name[26]; unsigned char *ar; unsigned long misc; } **prot; unsigned short total_prots; struct fextr_t { char ext[4]; char arstr[-1]; unsigned char *ar; } **fextr; unsigned short total_fextrs; struct fcomp_t { char ext[4]; char arstr[-1]; unsigned char *ar; } **fcomp; unsigned short total_fcomps; struct fview_t { char ext[4]; char arstr[-1]; unsigned char *ar; } **fview; unsigned short total_fviews; struct ftest_t { char ext[4]; char arstr[-1]; unsigned char *ar; } **ftest; unsigned short total_ftests; struct xedit_t { char code[-1]; unsigned char *ar; unsigned long misc; unsigned char type; } **xedit; unsigned short total_xedits; struct qhub_t { char id[-1]; unsigned short time; long last; } **qhub; unsigned short total_qhubs; struct phub_t { char days; unsigned short time; long last; } **phub; unsigned short total_phubs; struct chan_t { char code[-1]; char name[26]; char arstr[-1]; unsigned char *ar; unsigned short actset; unsigned long cost; } **chan; unsigned short total_chans; struct chatact_t { char cmd[-1]; unsigned short actset; } **chatact; unsigned short total_chatacts; struct actset_t { char name[26]; } **actset; unsigned short total_actsets; struct page_t { char cmd[-1]; unsigned char *ar; unsigned long misc; } **page; unsigned short total_pages; struct event_t { char code[-1]; unsigned short node; unsigned long misc; long last; } **event; unsigned short total_events; struct dlevent_t { char ext[4]; char arstr[-1]; unsigned char *ar; } **dlevent; unsigned short total_dlevents; struct fidoaddr_t *faddr; unsigned short total_faddrs; struct swap_t { char cmd[-1]; } **swap; unsigned short total_swaps; struct natvpgm_t { char name[13]; unsigned long misc; } **natvpgm; unsigned short total_natvpgms; struct guru_t { char code[-1]; char name[26]; unsigned char *ar; } **guru; unsigned short total_gurus; struct shell_t { char code[-1]; char name[41]; unsigned char *ar; unsigned long misc; } **shell; unsigned short total_shells; struct hotkey_t { unsigned char key; char cmd[-1]; } **hotkey; unsigned short total_hotkeys; unsigned short com_base; unsigned long com_rate; char com_port; char mdm_init[64]; unsigned long mdm_misc; unsigned short mdm_reinit; unsigned short mdm_ansdelay; unsigned char mdm_rings; long sys_misc; char sys_pass[41]; char sys_name[41]; char sys_id[-1]; char sys_psname[13]; unsigned long sys_psnum; char sys_inetaddr[128]; char sys_location[41]; short sys_timezone; char sys_daily[-1]; char sys_logon[-1]; char sys_logout[-1]; unsigned short sys_pwdays; unsigned short sys_deldays; unsigned short sys_autodel; unsigned short sys_nodes; char sys_op[41]; char sys_guru[41]; unsigned char sys_exp_warn; char sys_def_stat; char sys_phonefmt[-1]; unsigned short sys_lastnode; unsigned short sys_autonode; char sys_chat_arstr[-1]; unsigned char *sys_chat_ar; long msg_misc; long file_misc; long xtrn_misc; char node_comspec[-1]; char node_editor[-1]; char node_viewer[-1]; char node_daily[-1]; unsigned char node_scrnlen; unsigned char node_scrnblank; unsigned long node_misc; unsigned short node_valuser; unsigned short node_ivt; unsigned char node_swap; char node_swapdir[-1]; unsigned short node_minbps; unsigned short node_num; char node_phone[13]; char node_arstr[-1]; unsigned char *node_ar; unsigned long node_cost; unsigned char node_dollars_per_call; unsigned short node_sem_check; unsigned short node_stat_check; char new_install; char new_pass[41]; char new_magic[21]; char new_sif[-1]; char new_sof[-1]; char new_level; unsigned long new_flags1; unsigned long new_flags2; unsigned long new_flags3; unsigned long new_flags4; unsigned long new_exempt; unsigned long new_rest; unsigned long new_cdt; unsigned long new_min; char new_xedit[-1]; unsigned short new_shell; unsigned long new_misc; unsigned short new_expire; unsigned char new_prot; char val_level[10]; unsigned long val_flags1[10]; unsigned long val_flags2[10]; unsigned long val_flags3[10]; unsigned long val_flags4[10]; unsigned long val_exempt[10]; unsigned long val_rest[10]; unsigned long val_cdt[10]; unsigned short val_expire[10]; unsigned char level_expireto[100]; unsigned short level_timepercall[100]; long level_freecdtperday[100]; long level_misc[100]; char expired_level; unsigned long expired_flags1; unsigned long expired_flags2; unsigned long expired_flags3; unsigned long expired_flags4; unsigned long expired_exempt; unsigned long expired_rest; unsigned short min_dspace; unsigned short max_batup; unsigned short max_batdn; unsigned short max_userxfer; unsigned long max_minutes; unsigned long max_qwkmsgs; char preqwk_arstr[-1]; unsigned char *preqwk_ar; unsigned short cdt_min_value; unsigned long cdt_per_dollar; unsigned short cdt_up_pct; unsigned short cdt_dn_pct; char node_dir[-1]; char ctrl_dir[-1]; char data_dir[-1]; char text_dir[-1]; char exec_dir[-1]; char temp_dir[-1]; char mods_dir[-1]; char logs_dir[-1]; char node_path[250][-1]; unsigned short sysop_dir; unsigned short user_dir; unsigned short upload_dir; char **altpath; unsigned short altpaths; unsigned short leech_pct; unsigned short leech_sec; unsigned long netmail_cost; char netmail_dir[-1]; unsigned short netmail_misc; unsigned long inetmail_misc; unsigned long inetmail_cost; char smtpmail_sem[-1]; char inetmail_sem[-1]; char echomail_dir[-1]; char fidofile_dir[-1]; char netmail_sem[-1]; char echomail_sem[-1]; char origline[51]; char qnet_tagline[128]; long uq; unsigned long mail_maxcrcs; unsigned short mail_maxage; struct fidoaddr_t dflt_faddr; char logon_mod[-1]; char logoff_mod[-1]; char newuser_mod[-1]; char login_mod[-1]; char logout_mod[-1]; char sync_mod[-1]; char expire_mod[-1]; char scfg_cmd[-1]; unsigned char smb_retry_time; unsigned short sec_warn; unsigned short sec_hangup; char *color; unsigned long total_colors; unsigned long ctrlkey_passthru; char wfc_cmd[10][-1]; char wfc_scmd[12][-1]; unsigned short user_backup_level; unsigned short mail_backup_level; } *

variable_types: node char

variable_types: struct stats_t { unsigned long logons; unsigned short nusers; } *

variable_types:
str
char [-1]

variable_types: file int

user_defined_types: struct scfg_t { unsigned long size; int prepped; struct grp_t **grp; unsigned short total_grps; struct sub_t **sub; unsigned short total_subs; struct lib_t **lib; unsigned short total_libs; struct dir_t **dir; unsigned short total_dirs; struct txtsec_t **txtsec; unsigned short total_txtsecs; struct xtrnsec_t **xtrnsec; unsigned short total_xtrnsecs; struct xtrn_t **xtrn; unsigned short total_xtrns; struct mdm_result_t *mdm_result; unsigned short mdm_results; struct prot_t **prot; unsigned short total_prots; struct fextr_t **fextr; unsigned short total_fextrs; struct fcomp_t **fcomp; unsigned short total_fcomps; struct fview_t **fview; unsigned short total_fviews; struct ftest_t **ftest; unsigned short total_ftests; struct xedit_t **xedit; unsigned short total_xedits; struct qhub_t **qhub; unsigned short total_qhubs; struct phub_t **phub; unsigned short total_phubs; struct chan_t **chan; unsigned short total_chans; struct chatact_t **chatact; unsigned short total_chatacts; struct actset_t **actset; unsigned short total_actsets; struct page_t **page; unsigned short total_pages; struct event_t **event; unsigned short total_events; struct dlevent_t **dlevent; unsigned short total_dlevents; struct fidoaddr_t *faddr; unsigned short total_faddrs; struct swap_t **swap; unsigned short total_swaps; struct natvpgm_t **natvpgm; unsigned short total_natvpgms; struct guru_t **guru; unsigned short total_gurus; struct shell_t **shell; unsigned short total_shells; struct hotkey_t **hotkey; unsigned short total_hotkeys; unsigned short com_base; unsigned long com_rate; char com_port; char mdm_init[64]; unsigned long mdm_misc; unsigned short mdm_reinit; unsigned short mdm_ansdelay; unsigned char mdm_rings; long sys_misc; char sys_pass[41]; char sys_name[41]; char sys_id[-1]; char sys_psname[13]; unsigned long sys_psnum; char sys_inetaddr[128]; char sys_location[41]; short sys_timezone; char sys_daily[-1]; char sys_logon[-1]; char sys_logout[-1]; unsigned short sys_pwdays; unsigned short sys_deldays; unsigned short sys_autodel; unsigned short sys_nodes; char sys_op[41]; char sys_guru[41]; unsigned char sys_exp_warn; char sys_def_stat; char sys_phonefmt[-1]; unsigned short sys_lastnode; unsigned short sys_autonode; char sys_chat_arstr[-1]; unsigned char *sys_chat_ar; long msg_misc; long file_misc; long xtrn_misc; char node_comspec[-1]; char node_editor[-1]; char node_viewer[-1]; char node_daily[-1]; unsigned char node_scrnlen; unsigned char node_scrnblank; unsigned long node_misc; unsigned short node_valuser; unsigned short node_ivt; unsigned char node_swap; char node_swapdir[-1]; unsigned short node_minbps; unsigned short node_num; char node_phone[13]; char node_arstr[-1]; unsigned char *node_ar; unsigned long node_cost; unsigned char node_dollars_per_call; unsigned short node_sem_check; unsigned short node_stat_check; char new_install; char new_pass[41]; char new_magic[21]; char new_sif[-1]; char new_sof[-1]; char new_level; unsigned long new_flags1; unsigned long new_flags2; unsigned long new_flags3; unsigned long new_flags4; unsigned long new_exempt; unsigned long new_rest; unsigned long new_cdt; unsigned long new_min; char new_xedit[-1]; unsigned short new_shell; unsigned long new_misc; unsigned short new_expire; unsigned char new_prot; char val_level[10]; unsigned long val_flags1[10]; unsigned long val_flags2[10]; unsigned long val_flags3[10]; unsigned long val_flags4[10]; unsigned long val_exempt[10]; unsigned long val_rest[10]; unsigned long val_cdt[10]; unsigned short val_expire[10]; unsigned char level_expireto[100]; unsigned short level_timepercall[100]; long level_freecdtperday[100]; long level_misc[100]; char expired_level; unsigned long expired_flags1; unsigned long expired_flags2; unsigned long expired_flags3; unsigned long expired_flags4; unsigned long expired_exempt; unsigned long expired_rest; unsigned short min_dspace; unsigned short max_batup; unsigned short max_batdn; unsigned short max_userxfer; unsigned long max_minutes; unsigned long max_qwkmsgs; char preqwk_arstr[-1]; unsigned char *preqwk_ar; unsigned short cdt_min_value; unsigned long cdt_per_dollar; unsigned short cdt_up_pct; unsigned short cdt_dn_pct; char node_dir[-1]; char ctrl_dir[-1]; char data_dir[-1]; char text_dir[-1]; char exec_dir[-1]; char temp_dir[-1]; char mods_dir[-1]; char logs_dir[-1]; char node_path[250][-1]; unsigned short sysop_dir; unsigned short user_dir; unsigned short upload_dir; char **altpath; unsigned short altpaths; unsigned short leech_pct; unsigned short leech_sec; unsigned long netmail_cost; char netmail_dir[-1]; unsigned short netmail_misc; unsigned long inetmail_misc; unsigned long inetmail_cost; char smtpmail_sem[-1]; char inetmail_sem[-1]; char echomail_dir[-1]; char fidofile_dir[-1]; char netmail_sem[-1]; char echomail_sem[-1]; char origline[51]; char qnet_tagline[128]; long uq; unsigned long mail_maxcrcs; unsigned short mail_maxage; struct fidoaddr_t dflt_faddr; char logon_mod[-1]; char logoff_mod[-1]; char newuser_mod[-1]; char login_mod[-1]; char logout_mod[-1]; char sync_mod[-1]; char expire_mod[-1]; char scfg_cmd[-1]; unsigned char smb_retry_time; unsigned short sec_warn; unsigned short sec_hangup; char *color; unsigned long total_colors; unsigned long ctrlkey_passthru; char wfc_cmd[10][-1]; char wfc_scmd[12][-1]; unsigned short user_backup_level; unsigned short mail_backup_level; }

user_defined_types: struct sub_t { char code[-1]; char code_suffix[-1]; char lname[-1]; unsigned char *ar; unsigned short grp; unsigned long misc; struct fidoaddr_t faddr; }


getfiles

decompiled_code:
__int64 __fastcall getfiles(__int64 a1, unsigned int a2)
{
__int64 result; // rax
__int64 v3; // rcx
char v4[264]; // [rsp-108h] [rbp-108h] BYREF

if ( *(unsigned __int16 *)(a1 + 72) <= a2 )
return 0LL;
sprintf(
v4,
"%s%s.ixb",
(const char *)(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 8LL * a2) + 467LL),
*(const char **)(*(_QWORD *)(a1 + 64) + 8LL * a2));
v3 = flength(v4);
result = 0LL;
if ( v3 > 0 )
result = v3 / 22;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int a2)
{
__int64 result; // rax
__int64 v3; // rcx
char v4[264]; // [rsp-108h] [rbp-108h] BYREF

if ( *(unsigned __int16 *)(a1 + 72) <= a2 )
return 0LL;
sprintf(
v4,
"%s%s.ixb",
(const char *)(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 8LL * a2) + 467LL),
*(const char **)(*(_QWORD *)(a1 + 64) + 8LL * a2));
v3 = flength(v4);
result = 0LL;
if ( v3 > 0 )
result = v3 / 22;
return result;
}

original_code:
long getfiles(scfg_t* cfg, uint dirnum)
{
 char str[256];
 long l;
 if(dirnum>=cfg->total_dirs)
  return(0);
 sprintf(str,"%s%s.ixb",cfg->dir[dirnum]->data_dir, cfg->dir[dirnum]->code);
 l=flength(str);
 if(l>0L)
  return(l/22);
 return(0);
}

canonical_original_code:
long getfiles(struct scfg_t *cfg, unsigned int dirnum)
{
 char str[256];
 long l;
 if(dirnum>=cfg->total_dirs)
  return(0);
 sprintf(str,"%s%s.ixb",cfg->dir[dirnum]->data_dir, cfg->dir[dirnum]->code);
 l=flength(str);
 if(l>0L)
  return(l/22);
 return(0);
}

variable_types:
dirnum
unsigned int

variable_types:
str
char [256]

variable_types: l long

return_type: long

user_defined_types: struct mdm_result_t { unsigned short code; char str[-1]; }

user_defined_types: struct grp_t { char lname[-1]; unsigned char *ar; }

user_defined_types: struct lib_t { char lname[-1]; unsigned char *ar; unsigned short offline_dir; }

user_defined_types: struct dir_t { char code[-1]; char code_suffix[-1]; char lname[-1]; unsigned char *ar; unsigned short maxfiles; unsigned long misc; }

user_defined_types: struct txtsec_t { char code[-1]; char name[41]; unsigned char *ar; }

user_defined_types: struct xtrnsec_t { char code[-1]; char name[41]; unsigned char *ar; }

user_defined_types: struct xtrn_t { char code[-1]; char name[41]; unsigned char *ar; unsigned char type; unsigned short sec; unsigned long cost; }

user_defined_types: struct prot_t { char mnemonic; char name[26]; unsigned char *ar; unsigned long misc; }

user_defined_types: struct fextr_t { char ext[4]; char arstr[-1]; unsigned char *ar; }

user_defined_types: struct fcomp_t { char ext[4]; char arstr[-1]; unsigned char *ar; }

user_defined_types: struct fview_t { char ext[4]; char arstr[-1]; unsigned char *ar; }

user_defined_types: struct ftest_t { char ext[4]; char arstr[-1]; unsigned char *ar; }

user_defined_types: struct xedit_t { char code[-1]; unsigned char *ar; unsigned long misc; unsigned char type; }

user_defined_types: struct qhub_t { char id[-1]; unsigned short time; long last; }

user_defined_types: struct phub_t { char days; unsigned short time; long last; }

user_defined_types: struct chan_t { char code[-1]; char name[26]; char arstr[-1]; unsigned char *ar; unsigned short actset; unsigned long cost; }

user_defined_types: struct chatact_t { char cmd[-1]; unsigned short actset; }

user_defined_types: struct page_t { char cmd[-1]; unsigned char *ar; unsigned long misc; }

user_defined_types: struct event_t { char code[-1]; unsigned short node; unsigned long misc; long last; }

user_defined_types: struct dlevent_t { char ext[4]; char arstr[-1]; unsigned char *ar; }

user_defined_types: struct natvpgm_t { char name[13]; unsigned long misc; }

user_defined_types: struct guru_t { char code[-1]; char name[26]; unsigned char *ar; }

user_defined_types: struct shell_t { char code[-1]; char name[41]; unsigned char *ar; unsigned long misc; }

user_defined_types: struct hotkey_t { unsigned char key; char cmd[-1]; }

user_defined_types: struct fidoaddr_t { unsigned short zone; unsigned short net; unsigned short node; unsigned short point; }


getposts

decompiled_code:
unsigned __int64 __fastcall getposts(__int64 a1, unsigned int a2)
{
unsigned __int64 v2; // rax
unsigned __int64 v3; // rdx
bool v4; // zf
unsigned __int64 result; // rax
char v6[136]; // [rsp+0h] [rbp-88h] BYREF

sprintf(
v6,
"%s%s.sid",
(const char *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL * a2) + 309LL),
*(const char **)(*(_QWORD *)(a1 + 32) + 8LL * a2));
v2 = flength(v6);
v3 = v2 >> 5;
v4 = v2 == -1LL;
result = 0LL;
if ( !v4 )
result = v3;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func2(__int64 a1, unsigned int a2)
{
unsigned __int64 v2; // rax
unsigned __int64 v3; // rdx
bool v4; // zf
unsigned __int64 result; // rax
char v6[136]; // [rsp+0h] [rbp-88h] BYREF

sprintf(
v6,
"%s%s.sid",
(const char *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL * a2) + 309LL),
*(const char **)(*(_QWORD *)(a1 + 32) + 8LL * a2));
v2 = flength(v6);
v3 = v2 >> 5;
v4 = v2 == -1LL;
result = 0LL;
if ( !v4 )
result = v3;
return result;
}

original_code:
ulong getposts(scfg_t* cfg, uint subnum)
{
 char str[128];
 ulong l;
 sprintf(str,"%s%s.sid",cfg->sub[subnum]->data_dir,cfg->sub[subnum]->code);
 l=flength(str);
 if((long)l==-1)
  return(0);
 return(l/sizeof(idxrec_t));
}

canonical_original_code:
unsigned long getposts(struct scfg_t *cfg, unsigned int subnum)
{
 char str[128];
 unsigned long l;
 sprintf(str,"%s%s.sid",cfg->sub[subnum]->data_dir,cfg->sub[subnum]->code);
 l=flength(str);
 if((long)l==-1)
  return(0);
 return(l/sizeof(idxrec_t));
}

variable_types:
subnum
unsigned int

variable_types:
str
char [128]

variable_types:
l
unsigned long

return_type: unsigned long

user_defined_types: struct scfg_t { unsigned long size; int prepped; struct grp_t **grp; unsigned short total_grps; struct sub_t **sub; unsigned short total_subs; struct lib_t **lib; unsigned short total_libs; struct dir_t **dir; unsigned short total_dirs; struct txtsec_t **txtsec; unsigned short total_txtsecs; struct xtrnsec_t **xtrnsec; unsigned short total_xtrnsecs; struct xtrn_t **xtrn; unsigned short total_xtrns; struct mdm_result_t *mdm_result; unsigned short mdm_results; struct prot_t **prot; unsigned short total_prots; struct fextr_t **fextr; unsigned short total_fextrs; struct fcomp_t **fcomp; unsigned short total_fcomps; struct fview_t **fview; unsigned short total_fviews; struct ftest_t **ftest; unsigned short total_ftests; struct xedit_t **xedit; unsigned short total_xedits; struct qhub_t **qhub; unsigned short total_qhubs; struct phub_t **phub; unsigned short total_phubs; struct chan_t **chan; unsigned short total_chans; struct chatact_t **chatact; unsigned short total_chatacts; struct actset_t **actset; unsigned short total_actsets; struct page_t **page; unsigned short total_pages; struct event_t **event; unsigned short total_events; struct dlevent_t **dlevent; unsigned short total_dlevents; struct fidoaddr_t *faddr; unsigned short total_faddrs; struct swap_t **swap; unsigned short total_swaps; struct natvpgm_t **natvpgm; unsigned short total_natvpgms; struct guru_t **guru; unsigned short total_gurus; struct shell_t **shell; unsigned short total_shells; struct hotkey_t **hotkey; unsigned short total_hotkeys; unsigned short com_base; unsigned long com_rate; char com_port; char mdm_init[64]; unsigned long mdm_misc; unsigned short mdm_reinit; unsigned short mdm_ansdelay; unsigned char mdm_rings; long sys_misc; char sys_pass[41]; char sys_name[41]; char sys_id[-1]; char sys_psname[13]; unsigned long sys_psnum; char sys_inetaddr[128]; char sys_location[41]; short sys_timezone; char sys_daily[-1]; char sys_logon[-1]; char sys_logout[-1]; unsigned short sys_pwdays; unsigned short sys_deldays; unsigned short sys_autodel; unsigned short sys_nodes; char sys_op[41]; char sys_guru[41]; unsigned char sys_exp_warn; char sys_def_stat; char sys_phonefmt[-1]; unsigned short sys_lastnode; unsigned short sys_autonode; char sys_chat_arstr[-1]; unsigned char *sys_chat_ar; long msg_misc; long file_misc; long xtrn_misc; char node_comspec[-1]; char node_editor[-1]; char node_viewer[-1]; char node_daily[-1]; unsigned char node_scrnlen; unsigned char node_scrnblank; unsigned long node_misc; unsigned short node_valuser; unsigned short node_ivt; unsigned char node_swap; char node_swapdir[-1]; unsigned short node_minbps; unsigned short node_num; char node_phone[13]; char node_arstr[-1]; unsigned char *node_ar; unsigned long node_cost; unsigned char node_dollars_per_call; unsigned short node_sem_check; unsigned short node_stat_check; char new_install; char new_pass[41]; char new_magic[21]; char new_sif[-1]; char new_sof[-1]; char new_level; unsigned long new_flags1; unsigned long new_flags2; unsigned long new_flags3; unsigned long new_flags4; unsigned long new_exempt; unsigned long new_rest; unsigned long new_cdt; unsigned long new_min; char new_xedit[-1]; unsigned short new_shell; unsigned long new_misc; unsigned short new_expire; unsigned char new_prot; char val_level[10]; unsigned long val_flags1[10]; unsigned long val_flags2[10]; unsigned long val_flags3[10]; unsigned long val_flags4[10]; unsigned long val_exempt[10]; unsigned long val_rest[10]; unsigned long val_cdt[10]; unsigned short val_expire[10]; unsigned char level_expireto[100]; unsigned short level_timepercall[100]; long level_freecdtperday[100]; long level_misc[100]; char expired_level; unsigned long expired_flags1; unsigned long expired_flags2; unsigned long expired_flags3; unsigned long expired_flags4; unsigned long expired_exempt; unsigned long expired_rest; unsigned short min_dspace; unsigned short max_batup; unsigned short max_batdn; unsigned short max_userxfer; unsigned long max_minutes; unsigned long max_qwkmsgs; char preqwk_arstr[-1]; unsigned char *preqwk_ar; unsigned short cdt_min_value; unsigned long cdt_per_dollar; unsigned short cdt_up_pct; unsigned short cdt_dn_pct; char node_dir[-1]; char ctrl_dir[-1]; char data_dir[-1]; char text_dir[-1]; char exec_dir[-1]; char temp_dir[-1]; char mods_dir[-1]; char logs_dir[-1]; char node_path[250][-1]; unsigned short sysop_dir; unsigned short user_dir; unsigned short upload_dir; char **altpath; unsigned short altpaths; unsigned short leech_pct; unsigned short leech_sec; unsigned long netmail_cost; char netmail_dir[-1]; unsigned short netmail_misc; unsigned long inetmail_misc; unsigned long inetmail_cost; char smtpmail_sem[-1]; char inetmail_sem[-1]; char echomail_dir[-1]; char fidofile_dir[-1]; char netmail_sem[-1]; char echomail_sem[-1]; char origline[51]; char qnet_tagline[128]; long uq; unsigned long mail_maxcrcs; unsigned short mail_maxage; struct fidoaddr_t dflt_faddr; char logon_mod[-1]; char logoff_mod[-1]; char newuser_mod[-1]; char login_mod[-1]; char logout_mod[-1]; char sync_mod[-1]; char expire_mod[-1]; char scfg_cmd[-1]; unsigned char smb_retry_time; unsigned short sec_warn; unsigned short sec_hangup; char *color; unsigned long total_colors; unsigned long ctrlkey_passthru; char wfc_cmd[10][-1]; char wfc_scmd[12][-1]; unsigned short user_backup_level; unsigned short mail_backup_level; }

user_defined_types: struct mdm_result_t { unsigned short code; char str[-1]; }

user_defined_types: struct grp_t { char lname[-1]; unsigned char *ar; }

user_defined_types: struct sub_t { char code[-1]; char code_suffix[-1]; char lname[-1]; unsigned char *ar; unsigned short grp; unsigned long misc; struct fidoaddr_t faddr; }

user_defined_types: struct lib_t { char lname[-1]; unsigned char *ar; unsigned short offline_dir; }

user_defined_types: struct dir_t { char code[-1]; char code_suffix[-1]; char lname[-1]; unsigned char *ar; unsigned short maxfiles; unsigned long misc; }

user_defined_types: struct txtsec_t { char code[-1]; char name[41]; unsigned char *ar; }

user_defined_types: struct xtrnsec_t { char code[-1]; char name[41]; unsigned char *ar; }

user_defined_types: struct xtrn_t { char code[-1]; char name[41]; unsigned char *ar; unsigned char type; unsigned short sec; unsigned long cost; }

user_defined_types: struct prot_t { char mnemonic; char name[26]; unsigned char *ar; unsigned long misc; }

user_defined_types: struct fextr_t { char ext[4]; char arstr[-1]; unsigned char *ar; }


decompiled_code:
__int64 first_msg()
{
bool v0; // zf
__int64 result; // rax
_QWORD v2[59]; // [rsp+0h] [rbp-1D8h] BYREF

v2[51] = 0LL;
v2[10] = 0LL;
v0 = (unsigned int)smb_getmsgidx(smb, v2) == 0;
result = 0LL;
if ( v0 )
result = v2[2];
return result;
}

canonical_decompiled_code:
__int64 func0()
{
bool v0; // zf
__int64 result; // rax
_QWORD v2[59]; // [rsp+0h] [rbp-1D8h] BYREF

v2[51] = 0LL;
v2[10] = 0LL;
v0 = (unsigned int)smb_getmsgidx(smb, v2) == 0;
result = 0LL;
if ( v0 )
result = v2[2];
return result;
}

original_code:
ulong first_msg()
{
 smbmsg_t msg;
msg.offset=0;
msg.hdr.number=0;
if(smb_getmsgidx(&smb,&msg))
 return(0);
return(msg.idx.number);
}

canonical_original_code:
unsigned long first_msg()
{
 struct smbmsg_t msg;
msg.offset=0;
msg.hdr.number=0;
if(smb_getmsgidx(&smb,&msg))
 return(0);
return(msg.idx.number);
}

variable_types: struct smbmsg_t { struct idxrec_t { unsigned short to; unsigned short from; unsigned short subj; unsigned short attr; unsigned long offset; unsigned long number; unsigned long time; } idx; struct msghdr_t { unsigned char id[4]; unsigned short type; unsigned short version; unsigned short length; unsigned short attr; unsigned long auxattr; unsigned long netattr; struct when_t { unsigned long time; short zone; } when_written; struct when_t when_imported; unsigned long number; unsigned long thread_back; unsigned long thread_next; unsigned long thread_first; unsigned short delivery_attempts; unsigned long times_downloaded; unsigned long last_downloaded; unsigned char reserved[6]; unsigned long offset; unsigned short total_dfields; } hdr; char *to; char *summary; char *subj; unsigned short to_agent; struct net_t { unsigned short type; void *addr; } to_net; unsigned short total_hfields; struct hfield_t { unsigned short type; unsigned short length; } *hfield; void **hfield_dat; struct dfield_t { unsigned short type; unsigned long offset; unsigned long length; } *dfield; long offset; int forwarded; unsigned long expiration; unsigned long priority; unsigned long cost; unsigned long flags; }

user_defined_types: struct smbmsg_t { struct idxrec_t idx; struct msghdr_t hdr; char *to; char *summary; char *subj; unsigned short to_agent; struct net_t to_net; unsigned short total_hfields; struct hfield_t *hfield; void **hfield_dat; struct dfield_t *dfield; long offset; int forwarded; unsigned long expiration; unsigned long priority; unsigned long cost; unsigned long flags; }

user_defined_types: struct msghdr_t { unsigned char id[4]; unsigned short type; unsigned short version; unsigned short length; unsigned short attr; unsigned long auxattr; unsigned long netattr; struct when_t when_written; struct when_t when_imported; unsigned long number; unsigned long thread_back; unsigned long thread_next; unsigned long thread_first; unsigned short delivery_attempts; unsigned long times_downloaded; unsigned long last_downloaded; unsigned char reserved[6]; unsigned long offset; unsigned short total_dfields; }


lputs

original_code:
long lputs(char *str)
{
    char tmp[256];
    int i,j,k;
j=strlen(str);
for(i=k=0;i<j;i++)
    if(str[i]=='\r' && str[i+1]=='\n')
        continue;
    else
        tmp[k++]=str[i];
tmp[k]=0;
return(fputs(tmp,stderr));
}

canonical_original_code:
long lputs(char *str)
{
    char tmp[256];
    int i; int j; int k;
j=strlen(str);
for(i=k=0;i<j;i++)
    if(str[i]=='\r' && str[i+1]=='\n')
        continue;
    else
        tmp[k++]=str[i];
tmp[k]=0;
return(fputs(tmp,stderr));
}

variable_types:
str
char *

variable_types:
tmp
char [256]

variable_types: i int

variable_types: j int

variable_types: k int


lprintf

decompiled_code:
__int64 lprintf(char *format, ...)
{
unsigned int v1; // er12
gcc_va_list arg; // [rsp+8h] [rbp-1D0h] BYREF
char s[256]; // [rsp+20h] [rbp-1B8h] BYREF

va_start(arg, format);
v1 = vsprintf(s, format, arg);
lputs((__int64)s);
return v1;
}

canonical_decompiled_code:
__int64 func2(char *format, ...)
{
unsigned int v1; // er12
gcc_va_list arg; // [rsp+8h] [rbp-1D0h] BYREF
char s[256]; // [rsp+20h] [rbp-1B8h] BYREF

va_start(arg, format);
v1 = vsprintf(s, format, arg);
func1((__int64)s);
return v1;
}

original_code:
int lprintf(char *fmat, ...)
{
 va_list argptr;
 char sbuf[256];
 int chcount;
__builtin_va_start(argptr,fmat);
chcount=vsprintf(sbuf,fmat,argptr);
__builtin_va_end(argptr);
lputs(sbuf);
return(chcount);
}

canonical_original_code:
int lprintf(char *fmat, ...)
{
 __builtin_va_list argptr;
 char sbuf[256];
 int chcount;
__builtin_va_start(argptr,fmat);
chcount=vsprintf(sbuf,fmat,argptr);
__builtin_va_end(argptr);
lputs(sbuf);
return(chcount);
}

variable_types:
fmat
char *

variable_types:
sbuf
char [256]

variable_types: chcount int


bail

decompiled_code:
void __fastcall __noreturn bail(int a1)
{
exit(a1);
}

canonical_decompiled_code:
void __fastcall __noreturn func3(int a1)
{
exit(a1);
}

original_code:
void bail(int code)
{
exit(code);
}

canonical_original_code:
void bail(int code)
{
exit(code);
}

variable_types: code int


sectostr

decompiled_code:
char *__fastcall sectostr(unsigned int a1, char *a2)
{
sprintf(
a2,
"%2.2d:%2.2d:%2.2d",
(unsigned __int8)(a1 / 0xE10),
(unsigned __int8)(a1 / 0x3C - 60 * (a1 / 0xE10)),
a1 % 0x3C);
return a2;
}

canonical_decompiled_code:
char *__fastcall func2(unsigned int a1, char *a2)
{
sprintf(
a2,
"%2.2d:%2.2d:%2.2d",
(unsigned __int8)(a1 / 0xE10),
(unsigned __int8)(a1 / 0x3C - 60 * (a1 / 0xE10)),
a1 % 0x3C);
return a2;
}

original_code:
char* sectostr(uint sec,char *str)
{
    unsigned char hour,min,sec2;
 hour=(sec/60)/60;
 min=(sec/60)-(hour*60);
 sec2=sec-((min+(hour*60))*60);
 sprintf(str,"%2.2d:%2.2d:%2.2d",hour,min,sec2);
 return(str);
}

canonical_original_code:
char *sectostr(unsigned int sec, char *str)
{
    unsigned char hour; unsigned char min; unsigned char sec2;
 hour=(sec/60)/60;
 min=(sec/60)-(hour*60);
 sec2=sec-((min+(hour*60))*60);
 sprintf(str,"%2.2d:%2.2d:%2.2d",hour,min,sec2);
 return(str);
}

variable_types:
sec
unsigned int

variable_types:
hour
unsigned char

variable_types:
min
unsigned char


hhmmtostr

decompiled_code:
char *__fastcall hhmmtostr(__int64 a1, __int64 a2, char *a3)
{
__int64 v4; // rcx
__int64 v5; // rdx
__int64 v6; // r8
char *result; // rax

v4 = *(unsigned int *)(a2 + 4);
v5 = *(unsigned int *)(a2 + 8);
if ( (*(_BYTE *)(a1 + 946) & 4) != 0 )
{
sprintf(a3, "%02d:%02d ", v5, v4);
result = a3;
}
else
{
if ( (int)v5 <= 11 )
{
v6 = 97LL;
if ( !(_DWORD)v5 )
v5 = 12LL;
}
else
{
if ( (_DWORD)v5 != 12 )
v5 = (unsigned int)(v5 - 12);
v6 = 112LL;
}
sprintf(a3, "%02d:%02d%c", v5, v4, v6);
result = a3;
}
return result;
}

original_code:
char* hhmmtostr(scfg_t* cfg, struct tm* tm, char* str)
{
 if(cfg->sys_misc&(1L<<18))
  sprintf(str,"%02d:%02d "
         ,tm->tm_hour,tm->tm_min);
 else
  sprintf(str,"%02d:%02d%c"
         ,tm->tm_hour>12 ? tm->tm_hour-12 : tm->tm_hour==0 ? 12 : tm->tm_hour
   ,tm->tm_min,tm->tm_hour>=12 ? 'p' : 'a');
 return(str);
}

canonical_original_code:
char *hhmmtostr(struct scfg_t *cfg, struct tm *tm, char *str)
{
 if(cfg->sys_misc&(1L<<18))
  sprintf(str,"%02d:%02d "
         ,tm->tm_hour,tm->tm_min);
 else
  sprintf(str,"%02d:%02d%c"
         ,tm->tm_hour>12 ? tm->tm_hour-12 : tm->tm_hour==0 ? 12 : tm->tm_hour
   ,tm->tm_min,tm->tm_hour>=12 ? 'p' : 'a');
 return(str);
}

variable_types: struct scfg_t { unsigned long size; int prepped; struct grp_t { char lname[-1]; unsigned char *ar; } **grp; unsigned short total_grps; struct sub_t { char code[-1]; char code_suffix[-1]; char lname[-1]; unsigned char *ar; unsigned short grp; unsigned long misc; struct fidoaddr_t { unsigned short zone; unsigned short net; unsigned short node; unsigned short point; } faddr; } **sub; unsigned short total_subs; struct lib_t { char lname[-1]; unsigned char *ar; unsigned short offline_dir; } **lib; unsigned short total_libs; struct dir_t { char code[-1]; char code_suffix[-1]; char lname[-1]; unsigned char *ar; unsigned short maxfiles; unsigned long misc; } **dir; unsigned short total_dirs; struct txtsec_t { char code[-1]; char name[41]; unsigned char *ar; } **txtsec; unsigned short total_txtsecs; struct xtrnsec_t { char code[-1]; char name[41]; unsigned char *ar; } **xtrnsec; unsigned short total_xtrnsecs; struct xtrn_t { char code[-1]; char name[41]; unsigned char *ar; unsigned char type; unsigned short sec; unsigned long cost; } **xtrn; unsigned short total_xtrns; struct mdm_result_t { unsigned short code; char str[-1]; } *mdm_result; unsigned short mdm_results; struct prot_t { char mnemonic; char name[26]; unsigned char *ar; unsigned long misc; } **prot; unsigned short total_prots; struct fextr_t { char ext[4]; char arstr[-1]; unsigned char *ar; } **fextr; unsigned short total_fextrs; struct fcomp_t { char ext[4]; char arstr[-1]; unsigned char *ar; } **fcomp; unsigned short total_fcomps; struct fview_t { char ext[4]; char arstr[-1]; unsigned char *ar; } **fview; unsigned short total_fviews; struct ftest_t { char ext[4]; char arstr[-1]; unsigned char *ar; } **ftest; unsigned short total_ftests; struct xedit_t { char code[-1]; unsigned char *ar; unsigned long misc; unsigned char type; } **xedit; unsigned short total_xedits; struct qhub_t { char id[-1]; unsigned short time; long last; } **qhub; unsigned short total_qhubs; struct phub_t { char days; unsigned short time; long last; } **phub; unsigned short total_phubs; struct chan_t { char code[-1]; char name[26]; char arstr[-1]; unsigned char *ar; unsigned short actset; unsigned long cost; } **chan; unsigned short total_chans; struct chatact_t { char cmd[-1]; unsigned short actset; } **chatact; unsigned short total_chatacts; struct actset_t { char name[26]; } **actset; unsigned short total_actsets; struct page_t { char cmd[-1]; unsigned char *ar; unsigned long misc; } **page; unsigned short total_pages; struct event_t { char code[-1]; unsigned short node; unsigned long misc; long last; } **event; unsigned short total_events; struct dlevent_t { char ext[4]; char arstr[-1]; unsigned char *ar; } **dlevent; unsigned short total_dlevents; struct fidoaddr_t *faddr; unsigned short total_faddrs; struct swap_t { char cmd[-1]; } **swap; unsigned short total_swaps; struct natvpgm_t { char name[13]; unsigned long misc; } **natvpgm; unsigned short total_natvpgms; struct guru_t { char code[-1]; char name[26]; unsigned char *ar; } **guru; unsigned short total_gurus; struct shell_t { char code[-1]; char name[41]; unsigned char *ar; unsigned long misc; } **shell; unsigned short total_shells; struct hotkey_t { unsigned char key; char cmd[-1]; } **hotkey; unsigned short total_hotkeys; unsigned short com_base; unsigned long com_rate; char com_port; char mdm_init[64]; unsigned long mdm_misc; unsigned short mdm_reinit; unsigned short mdm_ansdelay; unsigned char mdm_rings; long sys_misc; char sys_pass[41]; char sys_name[41]; char sys_id[-1]; char sys_psname[13]; unsigned long sys_psnum; char sys_inetaddr[128]; char sys_location[41]; short sys_timezone; char sys_daily[-1]; char sys_logon[-1]; char sys_logout[-1]; unsigned short sys_pwdays; unsigned short sys_deldays; unsigned short sys_autodel; unsigned short sys_nodes; char sys_op[41]; char sys_guru[41]; unsigned char sys_exp_warn; char sys_def_stat; char sys_phonefmt[-1]; unsigned short sys_lastnode; unsigned short sys_autonode; char sys_chat_arstr[-1]; unsigned char *sys_chat_ar; long msg_misc; long file_misc; long xtrn_misc; char node_comspec[-1]; char node_editor[-1]; char node_viewer[-1]; char node_daily[-1]; unsigned char node_scrnlen; unsigned char node_scrnblank; unsigned long node_misc; unsigned short node_valuser; unsigned short node_ivt; unsigned char node_swap; char node_swapdir[-1]; unsigned short node_minbps; unsigned short node_num; char node_phone[13]; char node_arstr[-1]; unsigned char *node_ar; unsigned long node_cost; unsigned char node_dollars_per_call; unsigned short node_sem_check; unsigned short node_stat_check; char new_install; char new_pass[41]; char new_magic[21]; char new_sif[-1]; char new_sof[-1]; char new_level; unsigned long new_flags1; unsigned long new_flags2; unsigned long new_flags3; unsigned long new_flags4; unsigned long new_exempt; unsigned long new_rest; unsigned long new_cdt; unsigned long new_min; char new_xedit[-1]; unsigned short new_shell; unsigned long new_misc; unsigned short new_expire; unsigned char new_prot; char val_level[10]; unsigned long val_flags1[10]; unsigned long val_flags2[10]; unsigned long val_flags3[10]; unsigned long val_flags4[10]; unsigned long val_exempt[10]; unsigned long val_rest[10]; unsigned long val_cdt[10]; unsigned short val_expire[10]; unsigned char level_expireto[100]; unsigned short level_timepercall[100]; long level_freecdtperday[100]; long level_misc[100]; char expired_level; unsigned long expired_flags1; unsigned long expired_flags2; unsigned long expired_flags3; unsigned long expired_flags4; unsigned long expired_exempt; unsigned long expired_rest; unsigned short min_dspace; unsigned short max_batup; unsigned short max_batdn; unsigned short max_userxfer; unsigned long max_minutes; unsigned long max_qwkmsgs; char preqwk_arstr[-1]; unsigned char *preqwk_ar; unsigned short cdt_min_value; unsigned long cdt_per_dollar; unsigned short cdt_up_pct; unsigned short cdt_dn_pct; char node_dir[-1]; char ctrl_dir[-1]; char data_dir[-1]; char text_dir[-1]; char exec_dir[-1]; char temp_dir[-1]; char mods_dir[-1]; char logs_dir[-1]; char node_path[250][-1]; unsigned short sysop_dir; unsigned short user_dir; unsigned short upload_dir; char **altpath; unsigned short altpaths; unsigned short leech_pct; unsigned short leech_sec; unsigned long netmail_cost; char netmail_dir[-1]; unsigned short netmail_misc; unsigned long inetmail_misc; unsigned long inetmail_cost; char smtpmail_sem[-1]; char inetmail_sem[-1]; char echomail_dir[-1]; char fidofile_dir[-1]; char netmail_sem[-1]; char echomail_sem[-1]; char origline[51]; char qnet_tagline[128]; long uq; unsigned long mail_maxcrcs; unsigned short mail_maxage; struct fidoaddr_t dflt_faddr; char logon_mod[-1]; char logoff_mod[-1]; char newuser_mod[-1]; char login_mod[-1]; char logout_mod[-1]; char sync_mod[-1]; char expire_mod[-1]; char scfg_cmd[-1]; unsigned char smb_retry_time; unsigned short sec_warn; unsigned short sec_hangup; char *color; unsigned long total_colors; unsigned long ctrlkey_passthru; char wfc_cmd[10][-1]; char wfc_scmd[12][-1]; unsigned short user_backup_level; unsigned short mail_backup_level; } *

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *


csvLineCreator

decompiled_code:
char *__fastcall csvLineCreator(const char **a1)
{
char *v1; // rbp
__int64 v2; // rbx
char *v3; // r14
size_t v4; // rsi
char *v5; // rax
char *v6; // rbp
size_t v7; // r14
const char *v8; // rax
char *v9; // r12

if ( !a1 )
return 0LL;
v1 = (char *)*a1;
if ( !*a1 )
return 0LL;
v2 = 0LL;
v3 = 0LL;
v4 = 2 * strlen(*a1);
while ( 1 )
{
v8 = (const char *)realloc(v3, v4);
v9 = (char *)v8;
if ( !v8 )
break;
if ( v2 )
{
*(_WORD *)&v8[strlen(v8)] = 44;
v5 = csvEncode(v1);
v6 = v5;
if ( !v5 )
return v9;
}
else
{
*v8 = 0;
v5 = csvEncode(v1);
v6 = v5;
if ( !v5 )
return v9;
}
++v2;
strcat(v9, v5);
free(v6);
v1 = (char *)a1[v2];
if ( !v1 )
return v9;
v7 = 2 * strlen(a1[v2]);
v4 = strlen(v9) + v7;
v3 = v9;
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func1(const char **a1)
{
char *v1; // rbp
__int64 v2; // rbx
char *v3; // r14
size_t v4; // rsi
char *v5; // rax
char *v6; // rbp
size_t v7; // r14
const char *v8; // rax
char *v9; // r12

if ( !a1 )
return 0LL;
v1 = (char *)*a1;
if ( !*a1 )
return 0LL;
v2 = 0LL;
v3 = 0LL;
v4 = 2 * strlen(*a1);
while ( 1 )
{
v8 = (const char *)realloc(v3, v4);
v9 = (char *)v8;
if ( !v8 )
break;
if ( v2 )
{
*(_WORD *)&v8[strlen(v8)] = 44;
v5 = func0(v1);
v6 = v5;
if ( !v5 )
return v9;
}
else
{
*v8 = 0;
v5 = func0(v1);
v6 = v5;
if ( !v5 )
return v9;
}
++v2;
strcat(v9, v5);
free(v6);
v1 = (char *)a1[v2];
if ( !v1 )
return v9;
v7 = 2 * strlen(a1[v2]);
v4 = strlen(v9) + v7;
v3 = v9;
}
return v3;
}

original_code:
char* csvLineCreator(const str_list_t columns)
{
 char* str=((void *)0);
 char* p;
 char* val;
 size_t i,len;
 if(columns==((void *)0))
  return(((void *)0));
 for(i=0;columns[i]!=((void *)0);i++) {
  len=strlen(columns[i])*2;
  if(str)
   len+=strlen(str);
  if((p=realloc(str,len))==((void *)0))
   break;
  str=p;
  if(i) strcat(str,",");
  else *str=0;
  if((val=csvEncode(columns[i]))==((void *)0))
   break;
  strcat(str,val);
  free(val);
 }
 return(str);
}

canonical_original_code:
char *csvLineCreator(char **columns)
{
 char *str = ((void *)0);
 char *p;
 char *val;
 unsigned long i; unsigned long len;
 if(columns==((void *)0))
  return(((void *)0));
 for(i=0;columns[i]!=((void *)0);i++) {
  len=strlen(columns[i])*2;
  if(str)
   len+=strlen(str);
  if((p=realloc(str,len))==((void *)0))
   break;
  str=p;
  if(i) strcat(str,",");
  else *str=0;
  if((val=csvEncode(columns[i]))==((void *)0))
   break;
  strcat(str,val);
  free(val);
 }
 return(str);
}

variable_types:
columns
char **

variable_types:
p
char *

variable_types:
val
char *

variable_types:
i
unsigned long

variable_types:
len
unsigned long


csvLineParser

decompiled_code:
char *__fastcall csvLineParser(char *s)
{
char *v1; // r12
char *v2; // rax
char *v3; // rsi
__int64 v4; // rbx
__int64 v5; // rdx
char *v7; // [rsp+0h] [rbp-28h] BYREF
__int64 v8[4]; // [rsp+8h] [rbp-20h] BYREF

v8[0] = strListInit();
v1 = (char *)v8[0];
if ( v8[0] )
{
v2 = strdup(s);
v1 = v2;
if ( v2 )
{
truncsp(v2);
v3 = strtok_r(v1, ",", &v7);
if ( v3 )
{
v4 = 0LL;
do
{
v5 = v4++;
strListAppend(v8, v3, v5);
v3 = strtok_r(0LL, ",", &v7);
}
while ( v3 );
}
free(v1);
v1 = (char *)v8[0];
}
else
{
strListFree(v8);
}
}
return v1;
}

canonical_decompiled_code:
char *__fastcall func2(char *s)
{
char *v1; // r12
char *v2; // rax
char *v3; // rsi
__int64 v4; // rbx
__int64 v5; // rdx
char *v7; // [rsp+0h] [rbp-28h] BYREF
__int64 v8[4]; // [rsp+8h] [rbp-20h] BYREF

v8[0] = strListInit();
v1 = (char *)v8[0];
if ( v8[0] )
{
v2 = strdup(s);
v1 = v2;
if ( v2 )
{
truncsp(v2);
v3 = strtok_r(v1, ",", &v7);
if ( v3 )
{
v4 = 0LL;
do
{
v5 = v4++;
strListAppend(v8, v3, v5);
v3 = strtok_r(0LL, ",", &v7);
}
while ( v3 );
}
free(v1);
v1 = (char *)v8[0];
}
else
{
strListFree(v8);
}
}
return v1;
}

original_code:
str_list_t csvLineParser(const char* line)
{
 char* p;
 char* buf;
 char* tmp;
 size_t count=0;
 str_list_t list;
 if((list=strListInit())==((void *)0))
  return(((void *)0));
 if((buf=strdup(line))==((void *)0)) {
  strListFree(&list);
  return(((void *)0));
 }
 truncsp(buf);
 for(p=strtok_r(buf,",",&tmp);p;p=strtok_r(((void *)0),",",&tmp))
  strListAppend(&list,p,count++);
 free(buf);
 return(list);
}

canonical_original_code:
char **csvLineParser(char *line)
{
 char *p;
 char *buf;
 char *tmp;
 unsigned long count = 0;
 char **list;
 if((list=strListInit())==((void *)0))
  return(((void *)0));
 if((buf=strdup(line))==((void *)0)) {
  strListFree(&list);
  return(((void *)0));
 }
 truncsp(buf);
 for(p=strtok_r(buf,",",&tmp);p;p=strtok_r(((void *)0),",",&tmp))
  strListAppend(&list,p,count++);
 free(buf);
 return(list);
}

variable_types:
line
char *

variable_types:
buf
char *

variable_types:
tmp
char *

variable_types:
count
unsigned long

variable_types:
list
char **

return_type: char **