delfattach

decompiled_code:
int __fastcall delfattach(__int64 a1, unsigned __int16 *a2)
{
const char *v2; // r13
unsigned __int16 v4; // bp
const char *v5; // rsi
const char *v6; // r14
char *v7; // rax
char *v8; // rbx
char *v9; // rax
const char *v11; // rax
char v12[4112]; // [rsp+0h] [rbp-2048h] BYREF
char s[4152]; // [rsp+1010h] [rbp-1038h] BYREF

v2 = (const char *)(a1 + 6036);
v4 = *a2;
v5 = (const char *)*((_QWORD *)a2 + 39);
if ( v4 )
{
v6 = v12;
strcpy(v12, v5);
while ( 1 )
{
v7 = strchr(v6, 32);
v8 = v7;
if ( v7 )
*v7 = 0;
v9 = strrchr(v6, 47);
if ( v9 || (v9 = strrchr(v6, 92)) != 0LL )
v6 = v9 + 1;
sprintf(s, "%sfile/%04u.in/%s", v2, v4, v6);
remove(s);
if ( !v8 )
break;
v4 = *a2;
v6 = v8 + 1;
}
sprintf(v12, "%sfile/%04u.in", v2, *a2);
}
else
{
v11 = (const char *)getfname(v5);
sprintf(v12, "%sfile/%04u.out/%s", v2, a2[1], v11);
remove(v12);
sprintf(v12, "%sfile/%04u.out", v2, a2[1]);
}
return rmdir(v12);
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, unsigned __int16 *a2)
{
const char *v2; // r13
unsigned __int16 v4; // bp
const char *v5; // rsi
const char *v6; // r14
char *v7; // rax
char *v8; // rbx
char *v9; // rax
const char *v11; // rax
char v12[4112]; // [rsp+0h] [rbp-2048h] BYREF
char s[4152]; // [rsp+1010h] [rbp-1038h] BYREF

v2 = (const char *)(a1 + 6036);
v4 = *a2;
v5 = (const char *)*((_QWORD *)a2 + 39);
if ( v4 )
{
v6 = v12;
strcpy(v12, v5);
while ( 1 )
{
v7 = strchr(v6, 32);
v8 = v7;
if ( v7 )
*v7 = 0;
v9 = strrchr(v6, 47);
if ( v9 || (v9 = strrchr(v6, 92)) != 0LL )
v6 = v9 + 1;
sprintf(s, "%sfile/%04u.in/%s", v2, v4, v6);
remove(s);
if ( !v8 )
break;
v4 = *a2;
v6 = v8 + 1;
}
sprintf(v12, "%sfile/%04u.in", v2, *a2);
}
else
{
v11 = (const char *)getfname(v5);
sprintf(v12, "%sfile/%04u.out/%s", v2, a2[1], v11);
remove(v12);
sprintf(v12, "%sfile/%04u.out", v2, a2[1]);
}
return rmdir(v12);
}

original_code:
void delfattach(scfg_t* cfg, smbmsg_t* msg)
{
    char str[4096 +1];
 char str2[4096 +1];
 char *tp,*sp,*p;
 if(msg->idx.to==0) {
  sprintf(str,"%sfile/%04u.out/%s"
   ,cfg->data_dir,msg->idx.from,getfname(msg->subj));
  remove(str);
  sprintf(str,"%sfile/%04u.out"
   ,cfg->data_dir,msg->idx.from);
  rmdir(str);
  return;
 }
 strcpy(str,msg->subj);
 tp=str;
 while(1) {
  p=strchr(tp,' ');
  if(p) *p=0;
  sp=strrchr(tp,'/');
  if(!sp) sp=strrchr(tp,'\\');
  if(sp) tp=sp+1;
  sprintf(str2,"%sfile/%04u.in/%s"
   ,cfg->data_dir,msg->idx.to,tp);
  remove(str2);
  if(!p)
   break;
  tp=p+1; }
 sprintf(str,"%sfile/%04u.in",cfg->data_dir,msg->idx.to);
 rmdir(str);
}

canonical_original_code:
void delfattach(struct scfg_t *cfg, struct smbmsg_t *msg)
{
    char str[-1];
 char str2[-1];
 char *tp; char *sp; char *p;
 if(msg->idx.to==0) {
  sprintf(str,"%sfile/%04u.out/%s"
   ,cfg->data_dir,msg->idx.from,getfname(msg->subj));
  remove(str);
  sprintf(str,"%sfile/%04u.out"
   ,cfg->data_dir,msg->idx.from);
  rmdir(str);
  return;
 }
 strcpy(str,msg->subj);
 tp=str;
 while(1) {
  p=strchr(tp,' ');
  if(p) *p=0;
  sp=strrchr(tp,'/');
  if(!sp) sp=strrchr(tp,'\\');
  if(sp) tp=sp+1;
  sprintf(str2,"%sfile/%04u.in/%s"
   ,cfg->data_dir,msg->idx.to,tp);
  remove(str2);
  if(!p)
   break;
  tp=p+1; }
 sprintf(str,"%sfile/%04u.in",cfg->data_dir,msg->idx.to);
 rmdir(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 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; } *

variable_types:
str
char [-1]

variable_types:
tp
char *

variable_types:
sp
char *

variable_types:
p
char *

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

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


freemail

repo: ftnapps/pkg-sbbs

decompiled_code:
void __fastcall freemail(void *a1)
{
if ( a1 )
free(a1);
}

canonical_decompiled_code:
void __fastcall func2(void *a1)
{
if ( a1 )
free(a1);
}

original_code:
void freemail(mail_t* mail)
{
 if(mail!=((void *)0))
  free(mail);
}

canonical_original_code:
void freemail(struct idxrec_t *mail)
{
 if(mail!=((void *)0))
  free(mail);
}

variable_types: struct idxrec_t { unsigned short to; unsigned short from; unsigned short subj; unsigned short attr; unsigned long offset; unsigned long number; unsigned long time; } *

return_type: void


decompiled_code:
unsigned __int64 __fastcall crc32i(unsigned __int64 a1, const char *a2, size_t a3)
{
const char *v4; // rdx
char v5; // al

if ( a3 )
goto LABEL_5;
if ( a2 )
a3 = strlen(a2);
if ( a3 )
{
LABEL_5:
v4 = &a2[a3];
do
{
v5 = *a2++;
a1 = crc32tbl[(unsigned __int8)(a1 ^ v5)] ^ (a1 >> 8);
}
while ( v4 != a2 );
}
return ~a1;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(unsigned __int64 a1, const char *a2, size_t a3)
{
const char *v4; // rdx
char v5; // al

if ( a3 )
goto LABEL_5;
if ( a2 )
a3 = strlen(a2);
if ( a3 )
{
LABEL_5:
v4 = &a2[a3];
do
{
v5 = *a2++;
a1 = crc32tbl[(unsigned __int8)(a1 ^ v5)] ^ (a1 >> 8);
}
while ( v4 != a2 );
}
return ~a1;
}

original_code:
unsigned long crc32i(unsigned long crc, char *buf, unsigned long len)
{
 unsigned long l;
 if(len==0 && buf!=((void *)0))
  len=strlen(buf);
 for(l=0;l<len;l++)
  crc=(crc32tbl[(crc^(buf[l]))&0xff]^(crc>>8));
 return(~crc);
}

variable_types:
crc
unsigned long

variable_types:
buf
char *

variable_types:
len
unsigned long

variable_types:
l
unsigned long

return_type: unsigned long


original_code:
static int ar_exp(scfg_t* cfg, unsigned char **ptrptr, user_t* user)
{
 int result,not,or,equal;
 uint i,n,artype=AR_LEVEL,age;
 ulong l;
 time_t now;
 struct tm tm;
 result = 1;
 for(;(**ptrptr);(*ptrptr)++) {
  if((**ptrptr)==AR_ENDNEST)
   break;
  not=or=equal = 0;
  if((**ptrptr)==AR_OR) {
   or=1;
   (*ptrptr)++;
  }
  if((**ptrptr)==AR_NOT) {
   not=1;
   (*ptrptr)++;
  }
  if((**ptrptr)==AR_EQUAL) {
   equal=1;
   (*ptrptr)++;
  }
  if((result && or) || (!result && !or))
   break;
  if((**ptrptr)==AR_BEGNEST) {
   (*ptrptr)++;
   if(ar_exp(cfg,ptrptr,user))
    result=!not;
   else
    result=not;
   while((**ptrptr)!=AR_ENDNEST && (**ptrptr))
    (*ptrptr)++;
   if(!(**ptrptr))
    break;
   continue;
  }
  artype=(**ptrptr);
  switch(artype) {
   case AR_ANSI:
   case AR_RIP:
   case AR_WIP:
   case AR_LOCAL:
   case AR_EXPERT:
   case AR_SYSOP:
   case AR_GUEST:
   case AR_QNODE:
   case AR_QUIET:
   case AR_OS2:
   case AR_DOS:
    break;
   default:
    (*ptrptr)++;
    break;
  }
  n=(**ptrptr);
  i=(*(short *)*ptrptr);
  switch(artype) {
   case AR_LEVEL:
    if(user==((void *)0)
     || (equal && user->level!=n)
     || (!equal && user->level<n))
     result=not;
    else
     result=!not;
    break;
   case AR_AGE:
    if(user==((void *)0))
     result=not;
    else {
     age=getage(cfg,user->birth);
     if((equal && age!=n) || (!equal && age<n))
      result=not;
     else
      result=!not;
    }
    break;
   case AR_BPS:
    result=!not;
    (*ptrptr)++;
    break;
   case AR_ANSI:
    if(user==((void *)0) || !(user->misc&(1L<<1)))
     result=not;
    else result=!not;
    break;
   case AR_RIP:
    if(user==((void *)0) || !(user->misc&(1L<<3)))
     result=not;
    else result=!not;
    break;
   case AR_WIP:
    if(user==((void *)0) || !(user->misc&(1L<<21)))
     result=not;
    else result=!not;
    break;
   case AR_OS2:
     result=not;
    break;
   case AR_DOS:
    result=not;
    break;
   case AR_WIN32:
     result=not;
    break;
   case AR_UNIX:
     result=!not;
    break;
   case AR_LINUX:
     result=!not;
    break;
   case AR_ACTIVE:
    if(user==((void *)0) || user->misc&((1L<<0)|(1L<<6)))
     result=not;
    else result=!not;
    break;
   case AR_INACTIVE:
    if(user==((void *)0) || !(user->misc&(1L<<6)))
     result=not;
    else result=!not;
    break;
   case AR_DELETED:
    if(user==((void *)0) || !(user->misc&(1L<<0)))
     result=not;
    else result=!not;
    break;
   case AR_EXPERT:
    if(user==((void *)0) || !(user->misc&(1L<<7)))
     result=not;
    else result=!not;
    break;
   case AR_SYSOP:
    if(user==((void *)0) || user->level<90)
     result=not;
    else result=!not;
    break;
   case AR_GUEST:
    if(user==((void *)0) || !(user->rest&(ulong)(1UL<<('G'-'A'))))
     result=not;
    else result=!not;
    break;
   case AR_QNODE:
    if(user==((void *)0) || !(user->rest&(ulong)(1UL<<('Q'-'A'))))
     result=not;
    else result=!not;
    break;
   case AR_QUIET:
    result=not;
    break;
   case AR_LOCAL:
    result=not;
    break;
   case AR_DAY:
    now=time(((void *)0));
    localtime_r(&now,&tm);
    if((equal && tm.tm_wday!=(int)n)
     || (!equal && tm.tm_wday<(int)n))
     result=not;
    else
     result=!not;
    break;
   case AR_CREDIT:
    l=(ulong)i*1024UL;
    if(user==((void *)0)
     || (equal && user->cdt+user->freecdt!=l)
     || (!equal && user->cdt+user->freecdt<l))
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_NODE:
    if((equal && cfg->node_num!=n) || (!equal && cfg->node_num<n))
     result=not;
    else
     result=!not;
    break;
   case AR_USER:
    if(user==((void *)0)
     || (equal && user->number!=i)
     || (!equal && user->number<i))
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_GROUP:
    if(user==((void *)0))
     result=not;
    else {
     l=getgrpnum(cfg,user->cursub);
     if((equal && l!=i) || (!equal && l<i))
      result=not;
     else
      result=!not;
    }
    (*ptrptr)++;
    break;
   case AR_SUB:
    if(user==((void *)0))
     result=not;
    else {
     l=getsubnum(cfg,user->cursub);
     if((equal && l!=i) || (!equal && l<i))
      result=not;
     else
      result=!not;
    }
    (*ptrptr)++;
    break;
   case AR_SUBCODE:
    if(user!=((void *)0) && strcasecmp(user->cursub,(char *)*ptrptr)==0)
     result=!not;
    else
     result=not;
    result=not;
    while(*(*ptrptr))
     (*ptrptr)++;
    break;
   case AR_LIB:
    if(user==((void *)0))
     result=not;
    else {
     l=getlibnum(cfg,user->curdir);
     if((equal && l!=i) || (!equal && l<i))
      result=not;
     else
      result=!not;
    }
    (*ptrptr)++;
    break;
   case AR_DIR:
    if(user==((void *)0))
     result=not;
    else {
     l=getdirnum(cfg,user->curdir);
     if((equal && l!=i) || (!equal && l<i))
      result=not;
     else
      result=!not;
    }
    (*ptrptr)++;
    break;
   case AR_DIRCODE:
    if(user!=((void *)0) && strcasecmp(user->curdir,(char *)*ptrptr)==0)
     result=!not;
    else
     result=not;
    while(*(*ptrptr))
     (*ptrptr)++;
    break;
   case AR_EXPIRE:
    now=time(((void *)0));
    if(user==((void *)0)
     || user->expire==0
     || now+((long)i*24L*60L*60L)>user->expire)
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_RANDOM:
    n=xp_random(i+1);
    if((equal && n!=i) || (!equal && n<i))
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_LASTON:
    now=time(((void *)0));
    if(user==((void *)0) || (now-user->laston)/(24L*60L*60L)<(long)i)
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_LOGONS:
    if(user==((void *)0)
     || (equal && user->logons!=i)
     || (!equal && user->logons<i))
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_MAIN_CMDS:
    result=not;
    (*ptrptr)++;
    break;
   case AR_FILE_CMDS:
    result=not;
    (*ptrptr)++;
    break;
   case AR_TLEFT:
    result=not;
    break;
   case AR_TUSED:
    result=not;
    break;
   case AR_TIME:
    now=time(((void *)0));
    localtime_r(&now,&tm);
    if((tm.tm_hour*60)+tm.tm_min<(int)i)
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_PCR:
    if(user==((void *)0))
     result=not;
    else if(user->logons>user->posts
     && (!user->posts || 100/((float)user->logons/user->posts)<(long)n))
     result=not;
    else
     result=!not;
    break;
   case AR_UDR:
    if(user==((void *)0))
     result=not;
    else {
     l=user->dlb;
     if(!l) l=1;
     if(user->dlb>user->ulb
      && (!user->ulb || 100/((float)l/user->ulb)<n))
      result=not;
     else
      result=!not;
    }
    break;
   case AR_UDFR:
    if(user==((void *)0))
     result=not;
    else {
     i=user->dls;
     if(!i) i=1;
     if(user->dls>user->uls
      && (!user->uls || 100/((float)i/user->uls)<n))
      result=not;
     else
      result=!not;
    }
    break;
   case AR_FLAG1:
    if(user==((void *)0)
     || (!equal && !(user->flags1&(ulong)(1UL<<(n-'A'))))
     || (equal && user->flags1!=(ulong)(1UL<<(n-'A'))))
     result=not;
    else
     result=!not;
    break;
   case AR_FLAG2:
    if(user==((void *)0)
     || (!equal && !(user->flags2&(ulong)(1UL<<(n-'A'))))
     || (equal && user->flags2!=(ulong)(1UL<<(n-'A'))))
     result=not;
    else
     result=!not;
    break;
   case AR_FLAG3:
    if(user==((void *)0)
     || (!equal && !(user->flags3&(ulong)(1UL<<(n-'A'))))
     || (equal && user->flags3!=(ulong)(1UL<<(n-'A'))))
     result=not;
    else
     result=!not;
    break;
   case AR_FLAG4:
    if(user==((void *)0)
     || (!equal && !(user->flags4&(ulong)(1UL<<(n-'A'))))
     || (equal && user->flags4!=(ulong)(1UL<<(n-'A'))))
     result=not;
    else
     result=!not;
    break;
   case AR_REST:
    if(user==((void *)0)
     || (!equal && !(user->rest&(ulong)(1UL<<(n-'A'))))
     || (equal && user->rest!=(ulong)(1UL<<(n-'A'))))
     result=not;
    else
     result=!not;
    break;
   case AR_EXEMPT:
    if(user==((void *)0)
     || (!equal && !(user->exempt&(ulong)(1UL<<(n-'A'))))
     || (equal && user->exempt!=(ulong)(1UL<<(n-'A'))))
     result=not;
    else
     result=!not;
    break;
   case AR_SEX:
    if(user==((void *)0) || user->sex!=n)
     result=not;
    else
     result=!not;
    break;
   case AR_SHELL:
    if(user==((void *)0)
     || user->shell>=cfg->total_shells
     || strcasecmp(cfg->shell[user->shell]->code,(char*)*ptrptr))
     result=not;
    else
     result=!not;
    while(*(*ptrptr))
     (*ptrptr)++;
    break;
   case AR_PROT:
    if(user==((void *)0)
     || strcasecmp(user->modem,(char*)*ptrptr))
     result=not;
    else
     result=!not;
    while(*(*ptrptr))
     (*ptrptr)++;
    break;
  }
 }
 return(result);
}

canonical_original_code:
static int ar_exp(struct scfg_t *cfg, unsigned char **ptrptr, struct user_t *user)
{
 int result; int not; int or; int equal;
 unsigned int i; unsigned int n; unsigned int artype = AR_LEVEL; unsigned int age;
 unsigned long l;
 long now;
 struct tm tm;
 result = 1;
 for(;(**ptrptr);(*ptrptr)++) {
  if((**ptrptr)==AR_ENDNEST)
   break;
  not=or=equal = 0;
  if((**ptrptr)==AR_OR) {
   or=1;
   (*ptrptr)++;
  }
  if((**ptrptr)==AR_NOT) {
   not=1;
   (*ptrptr)++;
  }
  if((**ptrptr)==AR_EQUAL) {
   equal=1;
   (*ptrptr)++;
  }
  if((result && or) || (!result && !or))
   break;
  if((**ptrptr)==AR_BEGNEST) {
   (*ptrptr)++;
   if(ar_exp(cfg,ptrptr,user))
    result=!not;
   else
    result=not;
   while((**ptrptr)!=AR_ENDNEST && (**ptrptr))
    (*ptrptr)++;
   if(!(**ptrptr))
    break;
   continue;
  }
  artype=(**ptrptr);
  switch(artype) {
   case AR_ANSI:
   case AR_RIP:
   case AR_WIP:
   case AR_LOCAL:
   case AR_EXPERT:
   case AR_SYSOP:
   case AR_GUEST:
   case AR_QNODE:
   case AR_QUIET:
   case AR_OS2:
   case AR_DOS:
    break;
   default:
    (*ptrptr)++;
    break;
  }
  n=(**ptrptr);
  i=(*(short *)*ptrptr);
  switch(artype) {
   case AR_LEVEL:
    if(user==((void *)0)
     || (equal && user->level!=n)
     || (!equal && user->level<n))
     result=not;
    else
     result=!not;
    break;
   case AR_AGE:
    if(user==((void *)0))
     result=not;
    else {
     age=getage(cfg,user->birth);
     if((equal && age!=n) || (!equal && age<n))
      result=not;
     else
      result=!not;
    }
    break;
   case AR_BPS:
    result=!not;
    (*ptrptr)++;
    break;
   case AR_ANSI:
    if(user==((void *)0) || !(user->misc&(1L<<1)))
     result=not;
    else result=!not;
    break;
   case AR_RIP:
    if(user==((void *)0) || !(user->misc&(1L<<3)))
     result=not;
    else result=!not;
    break;
   case AR_WIP:
    if(user==((void *)0) || !(user->misc&(1L<<21)))
     result=not;
    else result=!not;
    break;
   case AR_OS2:
     result=not;
    break;
   case AR_DOS:
    result=not;
    break;
   case AR_WIN32:
     result=not;
    break;
   case AR_UNIX:
     result=!not;
    break;
   case AR_LINUX:
     result=!not;
    break;
   case AR_ACTIVE:
    if(user==((void *)0) || user->misc&((1L<<0)|(1L<<6)))
     result=not;
    else result=!not;
    break;
   case AR_INACTIVE:
    if(user==((void *)0) || !(user->misc&(1L<<6)))
     result=not;
    else result=!not;
    break;
   case AR_DELETED:
    if(user==((void *)0) || !(user->misc&(1L<<0)))
     result=not;
    else result=!not;
    break;
   case AR_EXPERT:
    if(user==((void *)0) || !(user->misc&(1L<<7)))
     result=not;
    else result=!not;
    break;
   case AR_SYSOP:
    if(user==((void *)0) || user->level<90)
     result=not;
    else result=!not;
    break;
   case AR_GUEST:
    if(user==((void *)0) || !(user->rest&(ulong)(1UL<<('G'-'A'))))
     result=not;
    else result=!not;
    break;
   case AR_QNODE:
    if(user==((void *)0) || !(user->rest&(ulong)(1UL<<('Q'-'A'))))
     result=not;
    else result=!not;
    break;
   case AR_QUIET:
    result=not;
    break;
   case AR_LOCAL:
    result=not;
    break;
   case AR_DAY:
    now=time(((void *)0));
    localtime_r(&now,&tm);
    if((equal && tm.tm_wday!=(int)n)
     || (!equal && tm.tm_wday<(int)n))
     result=not;
    else
     result=!not;
    break;
   case AR_CREDIT:
    l=(unsigned long)i*1024UL;
    if(user==((void *)0)
     || (equal && user->cdt+user->freecdt!=l)
     || (!equal && user->cdt+user->freecdt<l))
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_NODE:
    if((equal && cfg->node_num!=n) || (!equal && cfg->node_num<n))
     result=not;
    else
     result=!not;
    break;
   case AR_USER:
    if(user==((void *)0)
     || (equal && user->number!=i)
     || (!equal && user->number<i))
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_GROUP:
    if(user==((void *)0))
     result=not;
    else {
     l=getgrpnum(cfg,user->cursub);
     if((equal && l!=i) || (!equal && l<i))
      result=not;
     else
      result=!not;
    }
    (*ptrptr)++;
    break;
   case AR_SUB:
    if(user==((void *)0))
     result=not;
    else {
     l=getsubnum(cfg,user->cursub);
     if((equal && l!=i) || (!equal && l<i))
      result=not;
     else
      result=!not;
    }
    (*ptrptr)++;
    break;
   case AR_SUBCODE:
    if(user!=((void *)0) && strcasecmp(user->cursub,(char *)*ptrptr)==0)
     result=!not;
    else
     result=not;
    result=not;
    while(*(*ptrptr))
     (*ptrptr)++;
    break;
   case AR_LIB:
    if(user==((void *)0))
     result=not;
    else {
     l=getlibnum(cfg,user->curdir);
     if((equal && l!=i) || (!equal && l<i))
      result=not;
     else
      result=!not;
    }
    (*ptrptr)++;
    break;
   case AR_DIR:
    if(user==((void *)0))
     result=not;
    else {
     l=getdirnum(cfg,user->curdir);
     if((equal && l!=i) || (!equal && l<i))
      result=not;
     else
      result=!not;
    }
    (*ptrptr)++;
    break;
   case AR_DIRCODE:
    if(user!=((void *)0) && strcasecmp(user->curdir,(char *)*ptrptr)==0)
     result=!not;
    else
     result=not;
    while(*(*ptrptr))
     (*ptrptr)++;
    break;
   case AR_EXPIRE:
    now=time(((void *)0));
    if(user==((void *)0)
     || user->expire==0
     || now+((long)i*24L*60L*60L)>user->expire)
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_RANDOM:
    n=xp_random(i+1);
    if((equal && n!=i) || (!equal && n<i))
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_LASTON:
    now=time(((void *)0));
    if(user==((void *)0) || (now-user->laston)/(24L*60L*60L)<(long)i)
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_LOGONS:
    if(user==((void *)0)
     || (equal && user->logons!=i)
     || (!equal && user->logons<i))
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_MAIN_CMDS:
    result=not;
    (*ptrptr)++;
    break;
   case AR_FILE_CMDS:
    result=not;
    (*ptrptr)++;
    break;
   case AR_TLEFT:
    result=not;
    break;
   case AR_TUSED:
    result=not;
    break;
   case AR_TIME:
    now=time(((void *)0));
    localtime_r(&now,&tm);
    if((tm.tm_hour*60)+tm.tm_min<(int)i)
     result=not;
    else
     result=!not;
    (*ptrptr)++;
    break;
   case AR_PCR:
    if(user==((void *)0))
     result=not;
    else if(user->logons>user->posts
     && (!user->posts || 100/((float)user->logons/user->posts)<(long)n))
     result=not;
    else
     result=!not;
    break;
   case AR_UDR:
    if(user==((void *)0))
     result=not;
    else {
     l=user->dlb;
     if(!l) l=1;
     if(user->dlb>user->ulb
      && (!user->ulb || 100/((float)l/user->ulb)<n))
      result=not;
     else
      result=!not;
    }
    break;
   case AR_UDFR:
    if(user==((void *)0))
     result=not;
    else {
     i=user->dls;
     if(!i) i=1;
     if(user->dls>user->uls
      && (!user->uls || 100/((float)i/user->uls)<n))
      result=not;
     else
      result=!not;
    }
    break;
   case AR_FLAG1:
    if(user==((void *)0)
     || (!equal && !(user->flags1&(ulong)(1UL<<(n-'A'))))
     || (equal && user->flags1!=(ulong)(1UL<<(n-'A'))))
     result=not;
    else
     result=!not;
    break;
   case AR_FLAG2:
    if(user==((void *)0)
     || (!equal && !(user->flags2&(ulong)(1UL<<(n-'A'))))
     || (equal && user->flags2!=(ulong)(1UL<<(n-'A'))))
     result=not;
    else
     result=!not;
    break;
   case AR_FLAG3:
    if(user==((void *)0)
     || (!equal && !(user->flags3&(ulong)(1UL<<(n-'A'))))
     || (equal && user->flags3!=(ulong)(1UL<<(n-'A'))))
     result=not;
    else
     result=!not;
    break;
   case AR_FLAG4:
    if(user==((void *)0)
     || (!equal && !(user->flags4&(ulong)(1UL<<(n-'A'))))
     || (equal && user->flags4!=(ulong)(1UL<<(n-'A'))))
     result=not;
    else
     result=!not;
    break;
   case AR_REST:
    if(user==((void *)0)
     || (!equal && !(user->rest&(ulong)(1UL<<(n-'A'))))
     || (equal && user->rest!=(ulong)(1UL<<(n-'A'))))
     result=not;
    else
     result=!not;
    break;
   case AR_EXEMPT:
    if(user==((void *)0)
     || (!equal && !(user->exempt&(ulong)(1UL<<(n-'A'))))
     || (equal && user->exempt!=(ulong)(1UL<<(n-'A'))))
     result=not;
    else
     result=!not;
    break;
   case AR_SEX:
    if(user==((void *)0) || user->sex!=n)
     result=not;
    else
     result=!not;
    break;
   case AR_SHELL:
    if(user==((void *)0)
     || user->shell>=cfg->total_shells
     || strcasecmp(cfg->shell[user->shell]->code,(char *)*ptrptr))
     result=not;
    else
     result=!not;
    while(*(*ptrptr))
     (*ptrptr)++;
    break;
   case AR_PROT:
    if(user==((void *)0)
     || strcasecmp(user->modem,(char *)*ptrptr))
     result=not;
    else
     result=!not;
    while(*(*ptrptr))
     (*ptrptr)++;
    break;
  }
 }
 return(result);
}

variable_types:
ptrptr
unsigned char **

variable_types: struct user_t { unsigned short number; char alias[-1]; unsigned char level; unsigned long misc; long firston; } *

variable_types: result int

variable_types: not int

variable_types: or int

variable_types: equal int

variable_types:
i
unsigned int

variable_types:
n
unsigned int

variable_types:
artype
unsigned int

variable_types:
age
unsigned int

variable_types: now long

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

return_type: int

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


decompiled_code:
__int64 __fastcall sbbs_t::chk_ar(__int64 a1, const char *a2, unsigned __int16 *a3)
{
const char *v4; // [rsp+28h] [rbp-8h] BYREF

if ( !a2 )
return 1LL;
v4 = a2;
return sbbs_t::ar_exp(a1, &v4, a3);
}

canonical_decompiled_code:
__int64 __fastcall sbbs_t::func1(__int64 a1, const char *a2, unsigned __int16 *a3)
{
const char *v4; // [rsp+28h] [rbp-8h] BYREF

if ( !a2 )
return 1LL;
v4 = a2;
return sbbs_t::func0(a1, &v4, a3);
}

original_code:
int chk_ar(scfg_t* cfg, unsigned char *ar, user_t* user)
{
 unsigned char *p;
 if(ar==((void *)0))
  return(1);
 if(!(cfg!=((void *)0) && cfg->size==sizeof(scfg_t)))
  return(0);
 p=ar;
 return(ar_exp(cfg,&p,user));
}

canonical_original_code:
int chk_ar(struct scfg_t *cfg, unsigned char *ar, struct user_t *user)
{
 unsigned char *p;
 if(ar==((void *)0))
  return(1);
 if(!(cfg!=((void *)0) && cfg->size==sizeof(scfg_t)))
  return(0);
 p=ar;
 return(ar_exp(cfg,&p,user));
}

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:
ar
unsigned char *

variable_types:
p
unsigned char *

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 user_t { unsigned short number; char alias[-1]; unsigned char level; unsigned long misc; long firston; }

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


decompiled_code:
__int64 __fastcall sbbs_t::dir_op(sbbs_t *this, unsigned int a2)
{
__int64 result; // rax

LOBYTE(result) = *((_BYTE *)this + 26885) > 0x59u
|| (*((_QWORD *)this + 6414) & 4LL) != 0
|| **(_BYTE **)(*(_QWORD *)(*((_QWORD *)this + 66) + 8LL * a2) + 568LL)
&& (unsigned __int8)sbbs_t::chk_ar(
(__int64)this,
*(const char **)(*(_QWORD *)(*((_QWORD *)this + 66) + 8LL * a2) + 568LL),
(unsigned __int16 *)this + 13224);
return (unsigned __int8)result;
}

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

LOBYTE(result) = *((_BYTE *)this + 26885) > 0x59u
|| (*((_QWORD *)this + 6414) & 4LL) != 0
|| **(_BYTE **)(*(_QWORD *)(*((_QWORD *)this + 66) + 8LL * a2) + 568LL)
&& (unsigned __int8)sbbs_t::func1(
(__int64)this,
*(const char **)(*(_QWORD *)(*((_QWORD *)this + 66) + 8LL * a2) + 568LL),
(unsigned __int16 *)this + 13224);
return (unsigned __int8)result;
}

original_code:
int dir_op(scfg_t* cfg, user_t* user, uint dirnum)
{
 return(user->level>=90 || user->exempt&(ulong)(1UL<<('R'-'A'))
  || (cfg->dir[dirnum]->op_ar[0] && chk_ar(cfg,cfg->dir[dirnum]->op_ar,user)));
}

canonical_original_code:
int dir_op(struct scfg_t *cfg, struct user_t *user, unsigned int dirnum)
{
 return(user->level>=90 || user->exempt&(ulong)(1UL<<('R'-'A'))
  || (cfg->dir[dirnum]->op_ar[0] && chk_ar(cfg,cfg->dir[dirnum]->op_ar,user)));
}

variable_types:
dirnum
unsigned int

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


decompiled_code:
__int64 __fastcall msgid_serialno(__int64 a1)
{
int v1; // eax
int v2; // edx

msg_time(a1);
v1 = msg_number(a1);
return v2 + v1 - 1000000000;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v1; // eax
int v2; // edx

func1(a1);
v1 = func0(a1);
return v2 + v1 - 1000000000;
}

original_code:
static ulong msgid_serialno(smbmsg_t* msg)
{
 return (msg_time(msg)-1000000000) + msg_number(msg);
}

canonical_original_code:
static unsigned long msgid_serialno(struct smbmsg_t *msg)
{
 return (msg_time(msg)-1000000000) + msg_number(msg);
}

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


decompiled_code:
__int64 __fastcall add_char(_BYTE *a1, char a2, int a3, unsigned __int64 a4)
{
__int64 result; // rax

result = 1LL;
if ( (unsigned __int64)a1 < a4 )
{
if ( a3 )
*a1 = 61;
else
*a1 = *(&s + a2);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, char a2, int a3, unsigned __int64 a4)
{
__int64 result; // rax

result = 1LL;
if ( (unsigned __int64)a1 < a4 )
{
if ( a3 )
*a1 = 61;
else
*a1 = *(&s + a2);
result = 0LL;
}
return result;
}

original_code:
static int add_char(char *pos, char ch, int done, char *end)
{
 if(pos>=end) {
  return(1);
 }
 if(done)
  *pos=base64alphabet[64];
 else
  *pos=base64alphabet[(int)ch];
 return(0);
}

variable_types:
pos
char *

variable_types: ch char

variable_types: done int

variable_types:
end
char *


decompiled_code:
__int64 __fastcall b64_decode(_BYTE *a1, __int64 a2, const char *a3, size_t a4)
{
const char *v4; // r15
char *v5; // rbx
_BYTE *v6; // rbp
_BYTE *v7; // r12
int v8; // er13
int v9; // eax
int v10; // er14
char *v11; // rax
__int64 result; // rax

v4 = a3;
if ( !a4 )
a4 = strlen(a3);
v5 = (char *)&v4[a4];
v6 = &a1[a2];
if ( v4 >= &v4[a4] || a1 >= v6 )
{
v7 = a1;
LABEL_12:
if ( v6 == v7 )
{
*(v6 - 1) = 0;
result = 0xFFFFFFFFLL;
}
else
{
*v7 = 0;
result = (unsigned int)((_DWORD)v7 - (_DWORD)a1);
}
}
else
{
v7 = a1;
v8 = 0;
v9 = 0;
while ( 1 )
{
v10 = v9 << 6;
v11 = strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", *v4);
if ( !v11 )
break;
if ( *v11 == 61 )
{
if ( (v10 & 0xC0) == 0 )
goto LABEL_12;
break;
}
v9 = v10 | (v11 - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");
if ( v8 + 6 > 7 )
{
v8 -= 2;
++v7;
++v4;
*(v7 - 1) = (v9 & (255 << v8)) >> v8;
if ( v7 >= v6 )
goto LABEL_12;
}
else
{
v8 += 6;
++v4;
if ( v7 >= v6 )
goto LABEL_12;
}
if ( v5 <= v4 )
goto LABEL_12;
}
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1, __int64 a2, const char *a3, size_t a4)
{
const char *v4; // r15
char *v5; // rbx
_BYTE *v6; // rbp
_BYTE *v7; // r12
int v8; // er13
int v9; // eax
int v10; // er14
char *v11; // rax
__int64 result; // rax

v4 = a3;
if ( !a4 )
a4 = strlen(a3);
v5 = (char *)&v4[a4];
v6 = &a1[a2];
if ( v4 >= &v4[a4] || a1 >= v6 )
{
v7 = a1;
LABEL_12:
if ( v6 == v7 )
{
*(v6 - 1) = 0;
result = 0xFFFFFFFFLL;
}
else
{
*v7 = 0;
result = (unsigned int)((_DWORD)v7 - (_DWORD)a1);
}
}
else
{
v7 = a1;
v8 = 0;
v9 = 0;
while ( 1 )
{
v10 = v9 << 6;
v11 = strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", *v4);
if ( !v11 )
break;
if ( *v11 == 61 )
{
if ( (v10 & 0xC0) == 0 )
goto LABEL_12;
break;
}
v9 = v10 | (v11 - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");
if ( v8 + 6 > 7 )
{
v8 -= 2;
++v7;
++v4;
*(v7 - 1) = (v9 & (255 << v8)) >> v8;
if ( v7 >= v6 )
goto LABEL_12;
}
else
{
v8 += 6;
++v4;
if ( v7 >= v6 )
goto LABEL_12;
}
if ( v5 <= v4 )
goto LABEL_12;
}
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int b64_decode(char *target, size_t tlen, const char *source, size_t slen)
{
 const char *inp;
 char *outp;
 char *outend;
 const char *inend;
 int bits=0;
 int working=0;
 char * i;
 if(slen==0)
  slen=strlen(source);
 outp=target;
 inp=source;
 outend=target+tlen;
 inend=source+slen;
 for(;outp<outend && inp<inend;inp++) {
  working<<=6;
  i=strchr(base64alphabet,(char)*inp);
  if(i==((void *)0)) {
   return(-1);
  }
  if(*i=='=') {
   if((working&0xFF) != 0)
    return(-1);
   break;
  }
  bits+=6;
  working |= (i-base64alphabet);
  if(bits>=8) {
   *(outp++)=(char)((working&(0xFF<<(bits-8)))>>(bits-8));
   bits-=8;
  }
 }
 if(outp == outend) {
  *(--outp)=0;
  return(-1);
 }
 *outp=0;
 return(outp-target);
}

canonical_original_code:
int b64_decode(char *target, unsigned long tlen, char *source, unsigned long slen)
{
 char *inp;
 char *outp;
 char *outend;
 char *inend;
 int bits = 0;
 int working = 0;
 char *i;
 if(slen==0)
  slen=strlen(source);
 outp=target;
 inp=source;
 outend=target+tlen;
 inend=source+slen;
 for(;outp<outend && inp<inend;inp++) {
  working<<=6;
  i=strchr(base64alphabet,(char)*inp);
  if(i==((void *)0)) {
   return(-1);
  }
  if(*i=='=') {
   if((working&0xFF) != 0)
    return(-1);
   break;
  }
  bits+=6;
  working |= (i-base64alphabet);
  if(bits>=8) {
   *(outp++)=(char)((working&(0xFF<<(bits-8)))>>(bits-8));
   bits-=8;
  }
 }
 if(outp == outend) {
  *(--outp)=0;
  return(-1);
 }
 *outp=0;
 return(outp-target);
}

variable_types:
target
char *

variable_types:
tlen
unsigned long

variable_types:
source
char *

variable_types:
slen
unsigned long

variable_types:
inp
char *

variable_types:
outp
char *

variable_types:
outend
char *

variable_types:
inend
char *

variable_types: bits int

variable_types: working int

variable_types:
i
char *


decompiled_code:
__int64 __fastcall b64_encode(void *dest, size_t a2, const char *a3, size_t a4)
{
size_t v4; // r14
_BYTE *v6; // rbx
void *v7; // r13
unsigned __int64 v8; // rcx
const char *v9; // r8
unsigned __int64 v10; // rcx
__int64 v11; // r8
char v12; // r9
_BYTE *v13; // r11
unsigned __int64 v14; // rcx
__int64 v15; // r8
__int64 v16; // r10
int v17; // edx
unsigned __int64 v18; // rcx
__int64 v19; // r8
_BYTE *v20; // r9
__int64 v21; // r10
char v22; // dl
const char *v23; // r10
_BYTE *v25; // rax

v4 = a4;
if ( !a4 )
v4 = strlen(a3);
v6 = dest;
v7 = 0LL;
if ( a3 == dest )
{
v25 = malloc(a2);
v6 = v25;
if ( !v25 )
return 0xFFFFFFFFLL;
v7 = v25;
}
v8 = (unsigned __int64)&v6[a2];
if ( a3 < &a3[v4] )
{
v9 = a3;
while ( !(unsigned int)add_char(v6, (unsigned __int8)*v9 >> 2, 0, v8)
&& !(unsigned int)add_char(v13, (unsigned __int8)(*(_BYTE *)(v11 + 1) >> 4) | v12, 0, v10)
&& !(unsigned int)add_char(
v6 + 2,
(4 * *(_BYTE *)(v15 + 1)) & 0x3Cu | (*(_BYTE *)(v15 + 2) >> 6),
v16 == v15 + 1,
v14) )
{
if ( v21 == v19 + 2 )
v17 = 1;
v6 += 4;
if ( (unsigned int)add_char(v20, *(_BYTE *)(v19 + 2) & 0x3F, v17, v18) )
break;
if ( v23 == v9 || v23 <= v9 || (v22 & 1) != 0 )
goto LABEL_15;
}
if ( v7 )
free(v7);
return 0xFFFFFFFFLL;
}
LABEL_15:
if ( v8 > (unsigned __int64)v6 )
*v6 = 0;
if ( a3 == dest )
{
memcpy(dest, v7, a2);
free(v7);
}
return (unsigned int)((_DWORD)v6 - (_DWORD)dest);
}

canonical_decompiled_code:
__int64 __fastcall func2(void *dest, size_t a2, const char *a3, size_t a4)
{
size_t v4; // r14
_BYTE *v6; // rbx
void *v7; // r13
unsigned __int64 v8; // rcx
const char *v9; // r8
unsigned __int64 v10; // rcx
__int64 v11; // r8
char v12; // r9
_BYTE *v13; // r11
unsigned __int64 v14; // rcx
__int64 v15; // r8
__int64 v16; // r10
int v17; // edx
unsigned __int64 v18; // rcx
__int64 v19; // r8
_BYTE *v20; // r9
__int64 v21; // r10
char v22; // dl
const char *v23; // r10
_BYTE *v25; // rax

v4 = a4;
if ( !a4 )
v4 = strlen(a3);
v6 = dest;
v7 = 0LL;
if ( a3 == dest )
{
v25 = malloc(a2);
v6 = v25;
if ( !v25 )
return 0xFFFFFFFFLL;
v7 = v25;
}
v8 = (unsigned __int64)&v6[a2];
if ( a3 < &a3[v4] )
{
v9 = a3;
while ( !(unsigned int)func0(v6, (unsigned __int8)*v9 >> 2, 0, v8)
&& !(unsigned int)func0(v13, (unsigned __int8)(*(_BYTE *)(v11 + 1) >> 4) | v12, 0, v10)
&& !(unsigned int)func0(
v6 + 2,
(4 * *(_BYTE *)(v15 + 1)) & 0x3Cu | (*(_BYTE *)(v15 + 2) >> 6),
v16 == v15 + 1,
v14) )
{
if ( v21 == v19 + 2 )
v17 = 1;
v6 += 4;
if ( (unsigned int)func0(v20, *(_BYTE *)(v19 + 2) & 0x3F, v17, v18) )
break;
if ( v23 == v9 || v23 <= v9 || (v22 & 1) != 0 )
goto LABEL_15;
}
if ( v7 )
free(v7);
return 0xFFFFFFFFLL;
}
LABEL_15:
if ( v8 > (unsigned __int64)v6 )
*v6 = 0;
if ( a3 == dest )
{
memcpy(dest, v7, a2);
free(v7);
}
return (unsigned int)((_DWORD)v6 - (_DWORD)dest);
}

original_code:
int b64_encode(char *target, size_t tlen, const char *source, size_t slen) {
 const char *inp;
 char *outp;
 char *outend;
 const char *inend;
 char *tmpbuf=((void *)0);
 int done=0;
 char enc;
 int buf;
 if(slen==0)
  slen=strlen(source);
 inp=source;
 if(source==target) {
  tmpbuf=(char *)malloc(tlen);
  if(tmpbuf==((void *)0))
   return(-1);
  outp=tmpbuf;
 }
 else
  outp=target;
 outend=outp+tlen;
 inend=inp+slen;
 for(;(inp < inend) && !done;) {
  enc=*(inp++);
  buf=(enc & 0x03)<<4;
  enc=(enc&0xFC)>>2;
  if(add_char(outp++, enc, done, outend)) {
   if(tmpbuf!=((void *)0)) { free(tmpbuf); tmpbuf=((void *)0); };
   return(-1);
  }
  enc=buf|((*inp & 0xF0) >> 4);
  if(add_char(outp++, enc, done, outend)) {
   if(tmpbuf!=((void *)0)) { free(tmpbuf); tmpbuf=((void *)0); };
   return(-1);
  }
  if(inp==inend)
   done=1;
  buf=(*(inp++)<<2)&0x3C;
  enc=buf|((*inp & 0xC0)>>6);
  if(add_char(outp++, enc, done, outend)) {
   if(tmpbuf!=((void *)0)) { free(tmpbuf); tmpbuf=((void *)0); };
   return(-1);
  }
  if(inp==inend)
   done=1;
  enc=((int)*(inp++))&0x3F;
  if(add_char(outp++, enc, done, outend)) {
   if(tmpbuf!=((void *)0)) { free(tmpbuf); tmpbuf=((void *)0); };
   return(-1);
  }
  if(inp==inend)
   done=1;
 }
 if(outp<outend)
  *outp=0;
 if(target==source) {
  memcpy(target,tmpbuf,tlen);
  free(tmpbuf);
 }
 return(outp-target);
}

canonical_original_code:
int b64_encode(char *target, unsigned long tlen, char *source, unsigned long slen) {
 char *inp;
 char *outp;
 char *outend;
 char *inend;
 char *tmpbuf = ((void *)0);
 int done = 0;
 char enc;
 int buf;
 if(slen==0)
  slen=strlen(source);
 inp=source;
 if(source==target) {
  tmpbuf=(char *)malloc(tlen);
  if(tmpbuf==((void *)0))
   return(-1);
  outp=tmpbuf;
 }
 else
  outp=target;
 outend=outp+tlen;
 inend=inp+slen;
 for(;(inp < inend) && !done;) {
  enc=*(inp++);
  buf=(enc & 0x03)<<4;
  enc=(enc&0xFC)>>2;
  if(add_char(outp++, enc, done, outend)) {
   if(tmpbuf!=((void *)0)) { free(tmpbuf); tmpbuf=((void *)0); };
   return(-1);
  }
  enc=buf|((*inp & 0xF0) >> 4);
  if(add_char(outp++, enc, done, outend)) {
   if(tmpbuf!=((void *)0)) { free(tmpbuf); tmpbuf=((void *)0); };
   return(-1);
  }
  if(inp==inend)
   done=1;
  buf=(*(inp++)<<2)&0x3C;
  enc=buf|((*inp & 0xC0)>>6);
  if(add_char(outp++, enc, done, outend)) {
   if(tmpbuf!=((void *)0)) { free(tmpbuf); tmpbuf=((void *)0); };
   return(-1);
  }
  if(inp==inend)
   done=1;
  enc=((int)*(inp++))&0x3F;
  if(add_char(outp++, enc, done, outend)) {
   if(tmpbuf!=((void *)0)) { free(tmpbuf); tmpbuf=((void *)0); };
   return(-1);
  }
  if(inp==inend)
   done=1;
 }
 if(outp<outend)
  *outp=0;
 if(target==source) {
  memcpy(target,tmpbuf,tlen);
  free(tmpbuf);
 }
 return(outp-target);
}

variable_types:
tmpbuf
char *

variable_types: enc char

variable_types: buf int


decompiled_code:
__int64 __fastcall smb_subject_crc(char *s1)
{
char *v1; // rbp
char *i; // rax
char *v3; // rax
char *v4; // rbp
unsigned int v5; // er12

v1 = s1;
if ( !s1 )
return 0xFFFFFFFFLL;
while ( !strncasecmp(v1, "RE:", 3uLL) )
{
for ( i = v1 + 3; *i == 32; ++i )
;
v1 = i;
}
v3 = strdup(v1);
v4 = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
strlwr(v3);
v5 = crc16(v4, 0LL);
free(v4);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func8(char *s1)
{
char *v1; // rbp
char *i; // rax
char *v3; // rax
char *v4; // rbp
unsigned int v5; // er12

v1 = s1;
if ( !s1 )
return 0xFFFFFFFFLL;
while ( !strncasecmp(v1, "RE:", 3uLL) )
{
for ( i = v1 + 3; *i == 32; ++i )
;
v1 = i;
}
v3 = strdup(v1);
v4 = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
strlwr(v3);
v5 = crc16(v4, 0LL);
free(v4);
return v5;
}

original_code:
ushort smb_subject_crc(const char* subj)
{
 char* str;
 ushort crc;
 if(subj==((void *)0))
  return(0xffff);
 while(!strncasecmp(subj,"RE:",3)) {
  subj+=3;
  while(*subj==' ')
   subj++;
 }
 if((str=strdup(subj))==((void *)0))
  return(0xffff);
 strlwr(str);
 crc=crc16(str,0 );
 free(str);
 return(crc);
}

canonical_original_code:
unsigned short smb_subject_crc(char *subj)
{
 char *str;
 unsigned short crc;
 if(subj==((void *)0))
  return(0xffff);
 while(!strncasecmp(subj,"RE:",3)) {
  subj+=3;
  while(*subj==' ')
   subj++;
 }
 if((str=strdup(subj))==((void *)0))
  return(0xffff);
 strlwr(str);
 crc=crc16(str,0 );
 free(str);
 return(crc);
}

variable_types:
subj
char *

variable_types:
str
char *

variable_types:
crc
unsigned short

return_type: unsigned short


decompiled_code:
__int64 __fastcall smb_name_crc(const char *a1)
{
char *v1; // rax
char *v2; // rbp
unsigned int v3; // er12

if ( !a1 )
return 0xFFFFFFFFLL;
v1 = strdup(a1);
v2 = v1;
if ( !v1 )
return 0xFFFFFFFFLL;
strlwr(v1);
v3 = crc16(v2, 0LL);
free(v2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1)
{
char *v1; // rax
char *v2; // rbp
unsigned int v3; // er12

if ( !a1 )
return 0xFFFFFFFFLL;
v1 = strdup(a1);
v2 = v1;
if ( !v1 )
return 0xFFFFFFFFLL;
strlwr(v1);
v3 = crc16(v2, 0LL);
free(v2);
return v3;
}

original_code:
ushort smb_name_crc(const char* name)
{
 char* str;
 ushort crc;
 if(name==((void *)0))
  return(0xffff);
 if((str=strdup(name))==((void *)0))
  return(0xffff);
 strlwr(str);
 crc=crc16(str,0 );
 free(str);
 return(crc);
}

canonical_original_code:
unsigned short smb_name_crc(char *name)
{
 char *str;
 unsigned short crc;
 if(name==((void *)0))
  return(0xffff);
 if((str=strdup(name))==((void *)0))
  return(0xffff);
 strlwr(str);
 crc=crc16(str,0 );
 free(str);
 return(crc);
}

variable_types:
name
char *


decompiled_code:
const char *__fastcall display_filename(__int64 a1, unsigned __int16 a2, unsigned __int16 a3)
{
int v4; // ebp
const char *result; // rax
char buf[37]; // [rsp+3h] [rbp-25h] BYREF

sprintf(
str_0,
"%s%s.IXB",
(const char *)(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 8LL * a2) + 467LL),
*(const char **)(*(_QWORD *)(a1 + 64) + 8LL * a2));
v4 = nopen(str_0, 0LL);
result = "UNKNOWN";
if ( v4 != -1 )
{
lseek(v4, 22 * (a3 - 1), 0);
read(v4, buf, 0xBuLL);
close(v4);
sprintf(str_0, "%-8.8s.%c%c%c", buf, (unsigned int)buf[8], (unsigned int)buf[9], (unsigned int)buf[10]);
result = str_0;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func3(__int64 a1, unsigned __int16 a2, unsigned __int16 a3)
{
int v4; // ebp
const char *result; // rax
char buf[37]; // [rsp+3h] [rbp-25h] BYREF

sprintf(
str_0,
"%s%s.IXB",
(const char *)(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 8LL * a2) + 467LL),
*(const char **)(*(_QWORD *)(a1 + 64) + 8LL * a2));
v4 = nopen(str_0, 0LL);
result = "UNKNOWN";
if ( v4 != -1 )
{
lseek(v4, 22 * (a3 - 1), 0);
read(v4, buf, 0xBuLL);
close(v4);
sprintf(str_0, "%-8.8s.%c%c%c", buf, (unsigned int)buf[8], (unsigned int)buf[9], (unsigned int)buf[10]);
result = str_0;
}
return result;
}

original_code:
char *display_filename(scfg_t *cfg, ushort dir_num,ushort fil_off)
{
 static char str[256];
 char fname[13];
 int file;
 sprintf(str,"%s%s.IXB",cfg->dir[dir_num]->data_dir,cfg->dir[dir_num]->code);
 if((file=nopen(str,00))==-1)
  return("UNKNOWN");
 lseek(file,(long)(22*(fil_off-1)),0);
 read(file,fname,11);
 close(file);
 sprintf(str,"%-8.8s.%c%c%c",fname,fname[8],fname[9],fname[10]);
 return(str);
}

canonical_original_code:
char *display_filename(struct scfg_t *cfg, unsigned short dir_num, unsigned short fil_off)
{
 static char str[256];
 char fname[13];
 int file;
 sprintf(str,"%s%s.IXB",cfg->dir[dir_num]->data_dir,cfg->dir[dir_num]->code);
 if((file=nopen(str,00))==-1)
  return("UNKNOWN");
 lseek(file,(long)(22*(fil_off-1)),0);
 read(file,fname,11);
 close(file);
 sprintf(str,"%-8.8s.%c%c%c",fname,fname[8],fname[9],fname[10]);
 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:
str
char [256]

variable_types:
fname
char [13]

variable_types: file int

return_type: char *

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


bail

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

canonical_decompiled_code:
void __fastcall __noreturn func0(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


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:
tmp
char [256]

variable_types: i int

variable_types: j int

variable_types: k int

return_type: long


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