getstats

decompiled_code:
__int64 __fastcall getstats(__int64 a1, char a2, void *a3)
{
const char *v4; // rdx
int v5; // ebp
__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; // ebp
__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

repo: ftnapps/pkg-sbbs

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

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

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

result = 0LL;
if ( *(unsigned __int16 *)(a1 + 72) > a2 )
{
v3 = *(const char **)(*(_QWORD *)(a1 + 64) + 8LL * a2);
sprintf(v5, "%s%s.ixb", v3 + 467, v3);
v4 = flength(v5);
result = 0LL;
if ( v4 > 0 )
result = v4 / 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)
{
const char *v2; // rcx
unsigned __int64 v3; // rax
unsigned __int64 v4; // rdx
bool v5; // zf
unsigned __int64 result; // rax
char v7[136]; // [rsp+0h] [rbp-88h] BYREF

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

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

v2 = *(const char **)(*(_QWORD *)(a1 + 32) + 8LL * a2);
sprintf(v7, "%s%s.sid", v2 + 309, v2);
v3 = flength(v7);
v4 = v3 >> 5;
v5 = v3 == -1LL;
result = 0LL;
if ( !v5 )
result = v4;
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; // ebx
char v3[264]; // [rsp+0h] [rbp-1D8h] BYREF
gcc_va_list arg; // [rsp+108h] [rbp-D0h] BYREF

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

canonical_decompiled_code:
__int64 func2(char *format, ...)
{
unsigned int v1; // ebx
char v3[264]; // [rsp+0h] [rbp-1D8h] BYREF
gcc_va_list arg; // [rsp+108h] [rbp-D0h] BYREF

va_start(arg, format);
v1 = vsprintf(v3, format, arg);
func1(v3);
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

return_type: 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

return_type: void


sectostr

decompiled_code:
char *__fastcall sectostr(unsigned int a1, char *a2)
{
__int64 v2; // rcx

v2 = (unsigned __int8)(a1 / 0x3C - 60 * (a1 / 0xE10));
sprintf(
a2,
"%2.2d:%2.2d:%2.2d",
(unsigned __int8)(a1 / 0xE10),
v2,
(unsigned __int8)(a1 - 60 * (v2 + 60 * (a1 / 0xE10))));
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

return_type: char *


hhmmtostr

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
char *v2; // rbx
size_t v3; // rsi
__int64 v4; // r12
char *i; // r14
char *v6; // rax
char *v7; // rbp
size_t v8; // r14
const char *v9; // rax

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

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

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

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; // rbp
char *v2; // rax
char *v3; // rsi
__int64 v4; // rbx
__int64 v5; // rdx
char *v7; // [rsp+0h] [rbp-28h] BYREF
char *save_ptr[4]; // [rsp+8h] [rbp-20h] BYREF

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

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

v1 = (char *)strListInit();
v7 = v1;
if ( v1 )
{
v2 = strdup(s);
v1 = v2;
if ( v2 )
{
truncsp(v2);
v3 = strtok_r(v1, ",", save_ptr);
if ( v3 )
{
v4 = 0LL;
do
{
v5 = v4++;
strListAppend(&v7, v3, v5);
v3 = strtok_r(0LL, ",", save_ptr);
}
while ( v3 );
}
free(v1);
v1 = v7;
}
else
{
strListFree(&v7);
}
}
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 **


tabLineCreator

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

if ( !a1 )
return 0LL;
v1 = *a1;
v2 = (char *)*a1;
if ( *a1 )
{
v3 = 2 * strlen(*a1);
v4 = 0LL;
for ( i = 0LL; ; i = v2 )
{
v7 = (const char *)realloc(i, v3);
v2 = (char *)v7;
if ( !v7 )
break;
if ( v4 )
*(_WORD *)&v7[strlen(v7)] = 9;
else
*v7 = 0;
strcat(v2, v1);
v1 = a1[++v4];
if ( !v1 )
return v2;
v6 = 2 * strlen(a1[v4]);
v3 = strlen(v2) + v6;
}
v2 = i;
}
return v2;
}

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

if ( !a1 )
return 0LL;
v1 = *a1;
v2 = (char *)*a1;
if ( *a1 )
{
v3 = 2 * strlen(*a1);
v4 = 0LL;
for ( i = 0LL; ; i = v2 )
{
v7 = (const char *)realloc(i, v3);
v2 = (char *)v7;
if ( !v7 )
break;
if ( v4 )
*(_WORD *)&v7[strlen(v7)] = 9;
else
*v7 = 0;
strcat(v2, v1);
v1 = a1[++v4];
if ( !v1 )
return v2;
v6 = 2 * strlen(a1[v4]);
v3 = strlen(v2) + v6;
}
v2 = i;
}
return v2;
}

original_code:
char* tabLineCreator(const str_list_t columns)
{
 char* str=((void *)0);
 char* p;
 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,"\t");
  else *str=0;
  strcat(str,columns[i]);
 }
 return(str);
}

canonical_original_code:
char *tabLineCreator(char **columns)
{
 char *str = ((void *)0);
 char *p;
 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,"\t");
  else *str=0;
  strcat(str,columns[i]);
 }
 return(str);
}

variable_types:
str
char *


tabLineParser

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

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

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

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

original_code:
str_list_t tabLineParser(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));
 }
 for(p=strtok_r(buf,"\t",&tmp);p;p=strtok_r(((void *)0),"\t",&tmp))
  strListAppend(&list,p,count++);
 free(buf);
 return(list);
}

canonical_original_code:
char **tabLineParser(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));
 }
 for(p=strtok_r(buf,"\t",&tmp);p;p=strtok_r(((void *)0),"\t",&tmp))
  strListAppend(&list,p,count++);
 free(buf);
 return(list);
}


dataCreateList

decompiled_code:
__int64 __fastcall dataCreateList(_QWORD *a1, __int64 a2, __int64 (*a3)(void))
{
__int64 result; // rax
__int64 v5; // rbp
void *v6; // rsi
_QWORD *v7; // r13
void *v8; // rbx
__int64 v9; // rdx
__int64 v10[6]; // [rsp+8h] [rbp-30h] BYREF

result = strListInit();
v10[0] = result;
if ( result )
{
v5 = 0LL;
if ( a2 )
{
v6 = (void *)((__int64 (__fastcall *)(__int64))a3)(a2);
strListAppend(v10, v6, 0LL);
free(v6);
v5 = 1LL;
}
if ( a1 && *a1 )
{
v7 = &a1[-v5];
do
{
v8 = (void *)a3();
v9 = v5++;
strListAppend(v10, v8, v9);
free(v8);
}
while ( v7[v5] );
}
result = v10[0];
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, __int64 a2, __int64 (*a3)(void))
{
__int64 result; // rax
__int64 v5; // rbp
void *v6; // rsi
_QWORD *v7; // r13
void *v8; // rbx
__int64 v9; // rdx
__int64 v10[6]; // [rsp+8h] [rbp-30h] BYREF

result = strListInit();
v10[0] = result;
if ( result )
{
v5 = 0LL;
if ( a2 )
{
v6 = (void *)((__int64 (__fastcall *)(__int64))a3)(a2);
strListAppend(v10, v6, 0LL);
free(v6);
v5 = 1LL;
}
if ( a1 && *a1 )
{
v7 = &a1[-v5];
do
{
v8 = (void *)a3();
v9 = v5++;
strListAppend(v10, v8, v9);
free(v8);
}
while ( v7[v5] );
}
result = v10[0];
}
return result;
}

original_code:
str_list_t dataCreateList(const str_list_t records[], const str_list_t columns, dataLineCreator_t lineCreator)
{
 char* p;
 str_list_t list;
 size_t i;
 size_t li=0;
 if((list=strListInit())==((void *)0))
  return(((void *)0));
 if(columns!=((void *)0)) {
  p=lineCreator(columns);
  strListAppend(&list,p,li++);
  free(p);
 }
 if(records!=((void *)0))
  for(i=0;records[i]!=((void *)0);i++) {
   p=lineCreator(records[i]);
   strListAppend(&list,p,li++);
   free(p);
  }
 return(list);
}

canonical_original_code:
char **dataCreateList(char **records[], char **columns, char *(*lineCreator)(char **))
{
 char *p;
 char **list;
 unsigned long i;
 unsigned long li = 0;
 if((list=strListInit())==((void *)0))
  return(((void *)0));
 if(columns!=((void *)0)) {
  p=lineCreator(columns);
  strListAppend(&list,p,li++);
  free(p);
 }
 if(records!=((void *)0))
  for(i=0;records[i]!=((void *)0);i++) {
   p=lineCreator(records[i]);
   strListAppend(&list,p,li++);
   free(p);
  }
 return(list);
}

variable_types:
records
char **[]

variable_types:
lineCreator
char *(*)(char **)

variable_types:
li
unsigned long


original_code:
size_t dns_name(unsigned char* name, size_t* namelen, size_t maxlen, unsigned char* srcbuf, unsigned char* p)
{
 size_t len=0;
 size_t plen;
 ushort offset;
 while(p && *p && (*namelen)<maxlen) {
  if(len)
   name[(*namelen)++]='.';
  if(((*p)&0xC0)==0xC0) {
   (*p)&=~0xC0;
   offset=ntohs(*(ushort*)p);
   (*p)|=0xC0;
   dns_name(name, namelen, maxlen, srcbuf, srcbuf+offset);
   return(len+2);
  }
  plen=(*p);
  if((*namelen)+plen>maxlen)
   break;
  memcpy(name+(*namelen),p+1,plen);
  (*namelen)+=plen;
  plen++;
  p+=plen;
  len+=plen;
 }
 name[(*namelen)++]=0;
 return(len+1);
}

canonical_original_code:
unsigned long dns_name(unsigned char *name, unsigned long *namelen, unsigned long maxlen, unsigned char *srcbuf, unsigned char *p)
{
 unsigned long len = 0;
 unsigned long plen;
 unsigned short offset;
 while(p && *p && (*namelen)<maxlen) {
  if(len)
   name[(*namelen)++]='.';
  if(((*p)&0xC0)==0xC0) {
   (*p)&=~0xC0;
   offset=ntohs(*(unsigned short *)p);
   (*p)|=0xC0;
   dns_name(name, namelen, maxlen, srcbuf, srcbuf+offset);
   return(len+2);
  }
  plen=(*p);
  if((*namelen)+plen>maxlen)
   break;
  memcpy(name+(*namelen),p+1,plen);
  (*namelen)+=plen;
  plen++;
  p+=plen;
  len+=plen;
 }
 name[(*namelen)++]=0;
 return(len+1);
}

variable_types:
name
unsigned char *

variable_types:
namelen
unsigned long *

variable_types:
maxlen
unsigned long

variable_types:
srcbuf
unsigned char *

variable_types:
p
unsigned char *

variable_types:
plen
unsigned long

variable_types:
offset
unsigned short


decompiled_code:
__int64 __fastcall dns_getmx(const char *a1, char *a2, char *a3, unsigned int a4, int a5, int a6, int a7)
{
int v9; // er13
unsigned int v10; // er14
__int16 v11; // ax
int v12; // eax
int v13; // er15
char v14; // al
char *v15; // rbp
int v16; // er12
unsigned __int64 v18; // rbx
int v19; // er12
const char *v20; // rbp
char *v21; // rax
int v22; // er12
__int64 v23; // rbp
int v24; // eax
int v25; // eax
int v26; // eax
_QWORD *v27; // rdx
__int64 v28; // rcx
unsigned __int64 v29; // rsi
char *v30; // rdx
char *v31; // rdi
unsigned int v32; // eax
unsigned int v33; // edx
int v34; // eax
int v35; // ebp
int v36; // er15
char *v37; // rbx
unsigned int v38; // er12
char *v39; // r13
__int16 *v40; // rbp
unsigned __int16 v41; // r14
char *s; // [rsp+0h] [rbp-3A8h]
unsigned __int16 v44; // [rsp+Ch] [rbp-39Ch]
int v47; // [rsp+20h] [rbp-388h]
int v48; // [rsp+20h] [rbp-388h]
int nfds; // [rsp+24h] [rbp-384h]
fd_set writefds; // [rsp+30h] [rbp-378h] BYREF
struct timeval timeout; // [rsp+B0h] [rbp-2F8h] BYREF
__int64 v52; // [rsp+C2h] [rbp-2E6h] BYREF
int v53; // [rsp+CAh] [rbp-2DEh]
__int16 v54; // [rsp+CEh] [rbp-2DAh]
__int64 buf; // [rsp+D0h] [rbp-2D8h] BYREF
int v56; // [rsp+D8h] [rbp-2D0h]
__int16 v57; // [rsp+DCh] [rbp-2CCh]
struct sockaddr addr; // [rsp+2D0h] [rbp-D8h] BYREF
unsigned __int64 v59; // [rsp+2E8h] [rbp-C0h] BYREF
char src[184]; // [rsp+2F0h] [rbp-B8h] BYREF

s = (char *)a1;
*(_QWORD *)&addr.sa_family = 0LL;
*(_QWORD *)&addr.sa_data[6] = 0LL;
*a2 = 0;
*a3 = 0;
if ( a6 )
v9 = mail_open_socket(1LL, &unk_7A7);
else
v9 = mail_open_socket(2LL, &unk_7A7);
if ( v9 == -1 )
return (unsigned int)*_errno_location();
*(_DWORD *)&addr.sa_data[2] = _bswap_32(a4);
addr.sa_family = 2;
*(_WORD *)addr.sa_data = 0;
if ( bind(v9, &addr, 0x10u)
|| (*(_QWORD *)&addr.sa_data[6] = 0LL,
*(_DWORD *)&addr.sa_data[2] = a5,
addr.sa_family = 2,
*(_WORD *)addr.sa_data = _bswap_16(53),
(v10 = connect(v9, &addr, 0x10u)) != 0) )
{
mail_close_socket((unsigned int)v9);
v10 = *_errno_location();
}
else
{
v53 = 0;
v54 = 0;
v11 = strlen(a1);
LODWORD(v52) = (unsigned __int16)_bswap_16(v11 + 18);
WORD2(v52) = _bswap_16(256);
LOWORD(v12) = _bswap_16(1);
HIWORD(v52) = v12;
v13 = (unsigned __int16)_bswap_16(15) | (v12 << 16);
buf = v52;
v56 = 0;
v57 = 0;
v14 = *a1;
if ( *a1 )
{
v15 = (char *)a1;
v16 = 14;
do
{
v20 = &v15[v14 == 46];
v21 = strchr(v20, 46);
if ( v21 )
v18 = v21 - v20;
else
v18 = strlen(v20);
v59 = v18;
*((_BYTE *)&buf + v16) = v18;
v19 = v16 + 1;
memcpy((char *)&buf + v19, v20, v18);
v16 = v18 + v19;
v15 = (char *)&v20[v18];
v14 = *v15;
}
while ( *v15 );
}
else
{
v16 = 14;
}
*((_BYTE *)&buf + v16) = 0;
*(_DWORD *)((char *)&buf + v16 + 1) = v13;
if ( a6 )
{
v47 = v16 + 5;
v22 = v10;
}
else
{
v47 = v16 + 3;
v22 = 2;
}
timeout.tv_sec = a7;
timeout.tv_usec = 0LL;
memset(&writefds, 0, sizeof(writefds));
v23 = 1LL << (v9 % 64);
writefds.fds_bits[v9 / 64] |= v23;
v24 = select(v9 + 1, 0LL, &writefds, 0LL, &timeout);
if ( v24 <= 0 )
{
v10 = -1;
if ( v24 == -1 )
v10 = *_errno_location();
}
else
{
v25 = send(v9, (char *)&buf + v22, v47, 0);
if ( v47 == v25 )
{
timeout.tv_sec = a7;
timeout.tv_usec = 0LL;
memset(&writefds, 0, sizeof(writefds));
writefds.fds_bits[v9 / 64] |= v23;
v26 = select(v9 + 1, &writefds, 0LL, 0LL, &timeout);
if ( v26 <= 0 )
{
v10 = -1;
if ( v26 == -1 )
v10 = *_errno_location();
}
else
{
if ( (int)recv(v9, &buf, 0x200uLL, 0) > 0 )
{
v27 = (__int64 *)((char *)&v52 + v22);
*v27 = buf;
v28 = (unsigned int)(14 - v22);
*(_QWORD *)((char *)v27 + v28 - 8) = *(__int64 *)((char *)&v52 + v28 + 6);
v29 = (unsigned __int64)(v27 + 1) & 0xFFFFFFFFFFFFFFF8LL;
v30 = (char *)v27 - v29;
v31 = (char *)((char *)&buf - v30);
if ( (((_DWORD)v30 + (_DWORD)v28) & 0xFFFFFFF8) >= 8 )
{
v32 = ((_DWORD)v30 + v28) & 0xFFFFFFF8;
v33 = 0;
do
{
*(_QWORD *)(v29 + v33) = *(_QWORD *)&v31[v33];
v33 += 8;
}
while ( v33 < v32 );
}
v34 = 2;
if ( !a6 )
v34 = 0;
v35 = v34;
v36 = (unsigned __int16)_bswap_16(v53);
v37 = (char *)&buf + v47;
if ( v36 > 0 )
{
v38 = v10;
v44 = -1;
v48 = v9;
v39 = (char *)&buf + v35;
nfds = v10;
do
{
v59 = 0LL;
v40 = (__int16 *)&v37[dns_name((__int64)src, &v59, 0x7FuLL, (__int64)v39, (__int64)v37)];
v37 = (char *)v40 + (unsigned __int16)_bswap_16(v40[6]) + 14;
if ( _bswap_16(*v40) == 15 )
{
v41 = _bswap_16(v40[7]);
v59 = 0LL;
v37 = (char *)v40 + dns_name((__int64)src, &v59, 0x7FuLL, (__int64)v39, (__int64)(v40 + 8)) + 16;
if ( v41 > v44 )
{
if ( !*a3 )
strcpy(a3, src);
}
else
{
if ( *a2 )
strcpy(a3, a2);
strcpy(a2, src);
v44 = v41;
}
}
++v38;
}
while ( v36 != v38 );
v9 = v48;
v10 = nfds;
}
}
if ( !*a2 )
strcpy(a2, s);
}
}
else
{
v10 = -2;
if ( v25 == -1 )
v10 = *_errno_location();
}
}
mail_close_socket((unsigned int)v9);
}
return v10;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1, char *a2, char *a3, unsigned int a4, int a5, int a6, int a7)
{
int v9; // er13
unsigned int v10; // er14
__int16 v11; // ax
int v12; // eax
int v13; // er15
char v14; // al
char *v15; // rbp
int v16; // er12
unsigned __int64 v18; // rbx
int v19; // er12
const char *v20; // rbp
char *v21; // rax
int v22; // er12
__int64 v23; // rbp
int v24; // eax
int v25; // eax
int v26; // eax
_QWORD *v27; // rdx
__int64 v28; // rcx
unsigned __int64 v29; // rsi
char *v30; // rdx
char *v31; // rdi
unsigned int v32; // eax
unsigned int v33; // edx
int v34; // eax
int v35; // ebp
int v36; // er15
char *v37; // rbx
unsigned int v38; // er12
char *v39; // r13
__int16 *v40; // rbp
unsigned __int16 v41; // r14
char *s; // [rsp+0h] [rbp-3A8h]
unsigned __int16 v44; // [rsp+Ch] [rbp-39Ch]
int v47; // [rsp+20h] [rbp-388h]
int v48; // [rsp+20h] [rbp-388h]
int nfds; // [rsp+24h] [rbp-384h]
fd_set writefds; // [rsp+30h] [rbp-378h] BYREF
struct timeval timeout; // [rsp+B0h] [rbp-2F8h] BYREF
__int64 v52; // [rsp+C2h] [rbp-2E6h] BYREF
int v53; // [rsp+CAh] [rbp-2DEh]
__int16 v54; // [rsp+CEh] [rbp-2DAh]
__int64 buf; // [rsp+D0h] [rbp-2D8h] BYREF
int v56; // [rsp+D8h] [rbp-2D0h]
__int16 v57; // [rsp+DCh] [rbp-2CCh]
struct sockaddr addr; // [rsp+2D0h] [rbp-D8h] BYREF
unsigned __int64 v59; // [rsp+2E8h] [rbp-C0h] BYREF
char src[184]; // [rsp+2F0h] [rbp-B8h] BYREF

s = (char *)a1;
*(_QWORD *)&addr.sa_family = 0LL;
*(_QWORD *)&addr.sa_data[6] = 0LL;
*a2 = 0;
*a3 = 0;
if ( a6 )
v9 = mail_open_socket(1LL, &unk_7A7);
else
v9 = mail_open_socket(2LL, &unk_7A7);
if ( v9 == -1 )
return (unsigned int)*_errno_location();
*(_DWORD *)&addr.sa_data[2] = func1(a4);
addr.sa_family = 2;
*(_WORD *)addr.sa_data = 0;
if ( bind(v9, &addr, 0x10u)
|| (*(_QWORD *)&addr.sa_data[6] = 0LL,
*(_DWORD *)&addr.sa_data[2] = a5,
addr.sa_family = 2,
*(_WORD *)addr.sa_data = func0(53),
(v10 = connect(v9, &addr, 0x10u)) != 0) )
{
mail_close_socket((unsigned int)v9);
v10 = *_errno_location();
}
else
{
v53 = 0;
v54 = 0;
v11 = strlen(a1);
LODWORD(v52) = (unsigned __int16)func0(v11 + 18);
WORD2(v52) = func0(256);
LOWORD(v12) = func0(1);
HIWORD(v52) = v12;
v13 = (unsigned __int16)func0(15) | (v12 << 16);
buf = v52;
v56 = 0;
v57 = 0;
v14 = *a1;
if ( *a1 )
{
v15 = (char *)a1;
v16 = 14;
do
{
v20 = &v15[v14 == 46];
v21 = strchr(v20, 46);
if ( v21 )
v18 = v21 - v20;
else
v18 = strlen(v20);
v59 = v18;
*((_BYTE *)&buf + v16) = v18;
v19 = v16 + 1;
memcpy((char *)&buf + v19, v20, v18);
v16 = v18 + v19;
v15 = (char *)&v20[v18];
v14 = *v15;
}
while ( *v15 );
}
else
{
v16 = 14;
}
*((_BYTE *)&buf + v16) = 0;
*(_DWORD *)((char *)&buf + v16 + 1) = v13;
if ( a6 )
{
v47 = v16 + 5;
v22 = v10;
}
else
{
v47 = v16 + 3;
v22 = 2;
}
timeout.tv_sec = a7;
timeout.tv_usec = 0LL;
memset(&writefds, 0, sizeof(writefds));
v23 = 1LL << (v9 % 64);
writefds.fds_bits[v9 / 64] |= v23;
v24 = select(v9 + 1, 0LL, &writefds, 0LL, &timeout);
if ( v24 <= 0 )
{
v10 = -1;
if ( v24 == -1 )
v10 = *_errno_location();
}
else
{
v25 = send(v9, (char *)&buf + v22, v47, 0);
if ( v47 == v25 )
{
timeout.tv_sec = a7;
timeout.tv_usec = 0LL;
memset(&writefds, 0, sizeof(writefds));
writefds.fds_bits[v9 / 64] |= v23;
v26 = select(v9 + 1, &writefds, 0LL, 0LL, &timeout);
if ( v26 <= 0 )
{
v10 = -1;
if ( v26 == -1 )
v10 = *_errno_location();
}
else
{
if ( (int)recv(v9, &buf, 0x200uLL, 0) > 0 )
{
v27 = (__int64 *)((char *)&v52 + v22);
*v27 = buf;
v28 = (unsigned int)(14 - v22);
*(_QWORD *)((char *)v27 + v28 - 8) = *(__int64 *)((char *)&v52 + v28 + 6);
v29 = (unsigned __int64)(v27 + 1) & 0xFFFFFFFFFFFFFFF8LL;
v30 = (char *)v27 - v29;
v31 = (char *)((char *)&buf - v30);
if ( (((_DWORD)v30 + (_DWORD)v28) & 0xFFFFFFF8) >= 8 )
{
v32 = ((_DWORD)v30 + v28) & 0xFFFFFFF8;
v33 = 0;
do
{
*(_QWORD *)(v29 + v33) = *(_QWORD *)&v31[v33];
v33 += 8;
}
while ( v33 < v32 );
}
v34 = 2;
if ( !a6 )
v34 = 0;
v35 = v34;
v36 = (unsigned __int16)func0(v53);
v37 = (char *)&buf + v47;
if ( v36 > 0 )
{
v38 = v10;
v44 = -1;
v48 = v9;
v39 = (char *)&buf + v35;
nfds = v10;
do
{
v59 = 0LL;
v40 = (__int16 *)&v37[func2((__int64)src, &v59, 0x7FuLL, (__int64)v39, (__int64)v37)];
v37 = (char *)v40 + (unsigned __int16)func0(v40[6]) + 14;
if ( func0(*v40) == 15 )
{
v41 = func0(v40[7]);
v59 = 0LL;
v37 = (char *)v40 + func2((__int64)src, &v59, 0x7FuLL, (__int64)v39, (__int64)(v40 + 8)) + 16;
if ( v41 > v44 )
{
if ( !*a3 )
strcpy(a3, src);
}
else
{
if ( *a2 )
strcpy(a3, a2);
strcpy(a2, src);
v44 = v41;
}
}
++v38;
}
while ( v36 != v38 );
v9 = v48;
v10 = nfds;
}
}
if ( !*a2 )
strcpy(a2, s);
}
}
else
{
v10 = -2;
if ( v25 == -1 )
v10 = *_errno_location();
}
}
mail_close_socket((unsigned int)v9);
}
return v10;
}

original_code:
int dns_getmx(char* name, char* mx, char* mx2
     ,ulong intf, ulong ip_addr, int use_tcp, int timeout)
{
 unsigned char* p;
 unsigned char* tp;
 char hostname[128];
 size_t namelen;
 ushort pref;
 ushort highpref=0xffff;
 int i;
 int rd;
 int len;
 int offset;
 int result;
 int answers;
 int sock;
 struct sockaddr_in addr={0};
 unsigned char msg[512];
 dns_msghdr_t msghdr;
 dns_query_t query;
 dns_rr_t* rr;
 struct timeval tv;
 fd_set socket_set;
 mx[0]=0;
 mx2[0]=0;
 if(use_tcp)
  sock = mail_open_socket(SOCK_STREAM,"dns");
 else
  sock = mail_open_socket(SOCK_DGRAM,"dns");
 if(sock == (int)(~0))
  return((*__errno_location ()));
 addr.sin_addr.s_addr = htonl(intf);
    addr.sin_family = 2;
    addr.sin_port = 0;
    result = bind(sock,(struct sockaddr *)&addr, sizeof(addr));
 if(result != 0) {
  mail_close_socket(sock);
  return((*__errno_location ()));
 }
 memset(&addr,0,sizeof(addr));
 addr.sin_addr.s_addr = ip_addr;
 addr.sin_family = 2;
 addr.sin_port = htons(53);
 if((result=connect(sock, (struct sockaddr *)&addr, sizeof(addr)))!=0) {
  mail_close_socket(sock);
  return((*__errno_location ()));
 }
 memset(&msghdr,0,sizeof(msghdr));
 len=sizeof(msghdr)+strlen(name)+sizeof(query);
 msghdr.length=htons((ushort)len);
 msghdr.bitfields=htons((1<<8));
 msghdr.qdcount=htons(1);
 query.type=htons(DNS_MX);
 query.class=htons(1);
 memcpy(msg,&msghdr,sizeof(msghdr));
 len=sizeof(msghdr);
 for(p=name;*p;p+=namelen) {
  if(*p=='.')
   p++;
  tp=strchr(p,'.');
  if(tp)
   namelen=tp-p;
  else
   namelen=strlen(p);
  *(msg+len)=(unsigned char)namelen;
  len++;
  memcpy(msg+len,p,namelen);
  len+=namelen;
 }
 *(msg+len)=0;
 len++;
 memcpy(msg+len,&query,sizeof(query));
 len+=sizeof(query);
 if(use_tcp)
  offset=0;
 else {
  offset=sizeof(msghdr.length);
  len-=sizeof(msghdr.length);
 }
 tv.tv_sec=timeout;
 tv.tv_usec=0;
 do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&socket_set)->__fds_bits)[0]) : "memory"); } while (0);
 ((void) (((&socket_set)->__fds_bits)[((sock) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((sock) % (8 * (int) sizeof (__fd_mask)))))));
 i=select(sock+1,((void *)0),&socket_set,((void *)0),&tv);
 if(i<1) {
  if(i==-1)
   result=(*__errno_location ());
  else
   result=-1;
  mail_close_socket(sock);
  return(result);
 }
 i=send(sock,msg+offset,len,0);
 if(i!=len) {
  if(i==-1)
   result=(*__errno_location ());
  else
   result=-2;
  mail_close_socket(sock);
  return(result);
 }
 tv.tv_sec=timeout;
 tv.tv_usec=0;
 do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&socket_set)->__fds_bits)[0]) : "memory"); } while (0);
 ((void) (((&socket_set)->__fds_bits)[((sock) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((sock) % (8 * (int) sizeof (__fd_mask)))))));
 i=select(sock+1,&socket_set,((void *)0),((void *)0),&tv);
 if(i<1) {
  if(i==-1)
   result=(*__errno_location ());
  else
   result=-1;
  mail_close_socket(sock);
  return(result);
 }
 rd=recv(sock,msg,sizeof(msg),0);
 if(rd>0) {
  memcpy(((unsigned char*)(&msghdr))+offset,msg,sizeof(msghdr)-offset);
  if(!use_tcp)
   offset=0;
  else
   offset=sizeof(msghdr.length);
  answers=ntohs(msghdr.ancount);
  p=msg+len;
  for(i=0;i<answers;i++) {
   namelen=0;
   p+=dns_name(hostname, &namelen, sizeof(hostname)-1, msg+offset, p);
   rr=(dns_rr_t*)p;
   p+=sizeof(dns_rr_t);
   len=ntohs(rr->length);
   if(ntohs(rr->type)==DNS_MX) {
    pref=ntohs(*(ushort*)p);
    p+=2;
    namelen=0;
    p+=dns_name(hostname, &namelen, sizeof(hostname)-1, msg+offset, p);
    if(pref<=highpref) {
     highpref=pref;
     if(mx[0])
      strcpy(mx2,mx);
     strcpy(mx,hostname);
    } else if(!mx2[0])
     strcpy(mx2,hostname);
   }
   else
    p+=len;
  }
 }
 if(!mx[0]) {
  strcpy(mx,name);
 }
 mail_close_socket(sock);
 return(0);
}

canonical_original_code:
int dns_getmx(char *name, char *mx, char *mx2, unsigned long intf, unsigned long ip_addr, int use_tcp, int timeout)
{
 unsigned char *p;
 unsigned char *tp;
 char hostname[128];
 unsigned long namelen;
 unsigned short pref;
 unsigned short highpref = 0xffff;
 int i;
 int rd;
 int len;
 int offset;
 int result;
 int answers;
 int sock;
 struct sockaddr_in addr = {0};
 unsigned char msg[512];
 struct dns_msghdr_t msghdr;
 struct dns_query_t query;
 struct dns_rr_t *rr;
 struct timeval tv;
 struct fd_set socket_set;
 mx[0]=0;
 mx2[0]=0;
 if(use_tcp)
  sock = mail_open_socket(SOCK_STREAM,"dns");
 else
  sock = mail_open_socket(SOCK_DGRAM,"dns");
 if(sock == (int)(~0))
  return((*__errno_location ()));
 addr.sin_addr.s_addr = htonl(intf);
    addr.sin_family = 2;
    addr.sin_port = 0;
    result = bind(sock,(struct sockaddr *)&addr, sizeof(addr));
 if(result != 0) {
  mail_close_socket(sock);
  return((*__errno_location ()));
 }
 memset(&addr,0,sizeof(addr));
 addr.sin_addr.s_addr = ip_addr;
 addr.sin_family = 2;
 addr.sin_port = htons(53);
 if((result=connect(sock, (struct sockaddr *)&addr, sizeof(addr)))!=0) {
  mail_close_socket(sock);
  return((*__errno_location ()));
 }
 memset(&msghdr,0,sizeof(msghdr));
 len=sizeof(msghdr)+strlen(name)+sizeof(query);
 msghdr.length=htons((unsigned short)len);
 msghdr.bitfields=htons((1<<8));
 msghdr.qdcount=htons(1);
 query.type=htons(DNS_MX);
 query.class=htons(1);
 memcpy(msg,&msghdr,sizeof(msghdr));
 len=sizeof(msghdr);
 for(p=name;*p;p+=namelen) {
  if(*p=='.')
   p++;
  tp=strchr(p,'.');
  if(tp)
   namelen=tp-p;
  else
   namelen=strlen(p);
  *(msg+len)=(unsigned char)namelen;
  len++;
  memcpy(msg+len,p,namelen);
  len+=namelen;
 }
 *(msg+len)=0;
 len++;
 memcpy(msg+len,&query,sizeof(query));
 len+=sizeof(query);
 if(use_tcp)
  offset=0;
 else {
  offset=sizeof(msghdr.length);
  len-=sizeof(msghdr.length);
 }
 tv.tv_sec=timeout;
 tv.tv_usec=0;
 do { int __d0; int __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&socket_set)->__fds_bits)[0]) : "memory"); } while (0);
 ((void) (((&socket_set)->__fds_bits)[((sock) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((sock) % (8 * (int) sizeof (__fd_mask)))))));
 i=select(sock+1,((void *)0),&socket_set,((void *)0),&tv);
 if(i<1) {
  if(i==-1)
   result=(*__errno_location ());
  else
   result=-1;
  mail_close_socket(sock);
  return(result);
 }
 i=send(sock,msg+offset,len,0);
 if(i!=len) {
  if(i==-1)
   result=(*__errno_location ());
  else
   result=-2;
  mail_close_socket(sock);
  return(result);
 }
 tv.tv_sec=timeout;
 tv.tv_usec=0;
 do { int __d0; int __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&socket_set)->__fds_bits)[0]) : "memory"); } while (0);
 ((void) (((&socket_set)->__fds_bits)[((sock) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((sock) % (8 * (int) sizeof (__fd_mask)))))));
 i=select(sock+1,&socket_set,((void *)0),((void *)0),&tv);
 if(i<1) {
  if(i==-1)
   result=(*__errno_location ());
  else
   result=-1;
  mail_close_socket(sock);
  return(result);
 }
 rd=recv(sock,msg,sizeof(msg),0);
 if(rd>0) {
  memcpy(((unsigned char *)(&msghdr))+offset,msg,sizeof(msghdr)-offset);
  if(!use_tcp)
   offset=0;
  else
   offset=sizeof(msghdr.length);
  answers=ntohs(msghdr.ancount);
  p=msg+len;
  for(i=0;i<answers;i++) {
   namelen=0;
   p+=dns_name(hostname, &namelen, sizeof(hostname)-1, msg+offset, p);
   rr=(struct dns_rr_t *)p;
   p+=sizeof(dns_rr_t);
   len=ntohs(rr->length);
   if(ntohs(rr->type)==DNS_MX) {
    pref=ntohs(*(unsigned short *)p);
    p+=2;
    namelen=0;
    p+=dns_name(hostname, &namelen, sizeof(hostname)-1, msg+offset, p);
    if(pref<=highpref) {
     highpref=pref;
     if(mx[0])
      strcpy(mx2,mx);
     strcpy(mx,hostname);
    } else if(!mx2[0])
     strcpy(mx2,hostname);
   }
   else
    p+=len;
  }
 }
 if(!mx[0]) {
  strcpy(mx,name);
 }
 mail_close_socket(sock);
 return(0);
}

variable_types:
name
char *

variable_types:
mx
char *

variable_types:
intf
unsigned long

variable_types: timeout int

variable_types:
tp
unsigned char *

variable_types:
hostname
char [128]

variable_types:
namelen
unsigned long

variable_types:
pref
unsigned short

variable_types:
highpref
unsigned short

variable_types: i int

variable_types: rd int

variable_types: len int

variable_types: offset int

variable_types: result int

variable_types: answers int

variable_types: sock int

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

variable_types:
msg
unsigned char [512]

variable_types: struct dns_msghdr_t { unsigned short length; unsigned short id; unsigned short bitfields; unsigned short qdcount; unsigned short ancount; unsigned short nscount; unsigned short arcount; }

variable_types: struct dns_query_t { unsigned short type; unsigned short class; }

variable_types: struct dns_rr_t { unsigned short type; unsigned short class; unsigned long ttl; unsigned short length; } *

variable_types: struct timeval { long tv_sec; long tv_usec; }

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

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


getkey

decompiled_code:
int __fastcall sbbs_t::getkey(sbbs_t *this, __int64 a2)
{
int result; // eax
__int64 v3; // rax
char v4; // al
char v5; // al
char v6; // al
char v7; // al
char v8; // al
char v9; // al
unsigned __int64 v10; // rdx
char v11; // al
const char *v13; // rax
__int64 v15; // [rsp+0h] [rbp-40h]
struct timeval timeout; // [rsp+10h] [rbp-30h] BYREF
int v17; // [rsp+28h] [rbp-18h]
char v18; // [rsp+2Dh] [rbp-13h]
unsigned __int8 v19; // [rsp+2Eh] [rbp-12h]
char v20; // [rsp+2Fh] [rbp-11h]
__int64 v21; // [rsp+30h] [rbp-10h]
char v22; // [rsp+3Fh] [rbp-1h]

v15 = a2;
v22 = 0;
v20 = sbbs_random(5LL);
v21 = 0LL;
if ( *((_QWORD *)this + 6413) && *((_BYTE *)this + 26098) == 1 )
{
v3 = *((_QWORD *)this + 6414);
BYTE1(v3) &= 0xF7u;
*((_QWORD *)this + 6414) = v3;
if ( ((*((_QWORD *)this + 6414) & 8LL) != 0 || *((_BYTE *)this + 51296) == 9) && (a2 & 0x200800) == 0 )
v15 = *((_QWORD *)this + 3362) & 0x20LL | a2;
*((_QWORD *)this + 6065) = 0LL;
*((_QWORD *)this + 6054) = time(0LL);
if ( (v15 & 0x20) != 0 )
sbbs_t::outchar(this, 32);
while ( (*((_QWORD *)this + 6414) & 0x800LL) == 0 )
{
if ( (v15 & 0x20) != 0 )
{
if ( (*((_QWORD *)this + 3362) & 0x8000LL) != 0 )
{
v4 = v22++;
if ( v4 == 3 )
{
LABEL_26:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, 92);
v22 = 0;
}
else if ( v4 <= 3 )
{
if ( v4 == 2 )
{
LABEL_25:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, 45);
}
else if ( v4 <= 2 )
{
if ( v4 )
{
if ( v4 == 1 )
{
LABEL_24:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, 47);
}
}
else
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, 124);
}
}
}
}
else
{
switch ( v20 )
{
case 0:
v5 = v22++;
if ( v5 == 3 )
goto LABEL_26;
if ( v5 <= 3 )
{
if ( v5 == 2 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -60);
}
else if ( v5 <= 2 )
{
if ( v5 )
{
if ( v5 == 1 )
goto LABEL_24;
}
else
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -77);
}
}
}
break;
case 1:
v6 = v22++;
switch ( v6 )
{
case 0:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -80);
break;
case 1:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -79);
break;
case 2:
case 4:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -78);
break;
case 3:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -37);
break;
case 5:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -79);
v22 = 0;
break;
default:
goto LABEL_78;
}
break;
case 2:
v7 = v22++;
if ( v7 == 3 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, 61);
v22 = 0;
}
else if ( v7 <= 3 )
{
if ( v7 == 2 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -16);
}
else if ( v7 <= 2 )
{
if ( !v7 )
goto LABEL_25;
if ( v7 == 1 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, 61);
}
}
}
break;
case 3:
v8 = v22++;
if ( v8 == 3 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -65);
v22 = 0;
}
else if ( v8 <= 3 )
{
if ( v8 == 2 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -39);
}
else if ( v8 <= 2 )
{
if ( v8 )
{
if ( v8 == 1 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -64);
}
}
else
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -38);
}
}
}
break;
case 4:
v9 = v22++;
if ( v9 == 3 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -35);
v22 = 0;
}
else if ( v9 <= 3 )
{
if ( v9 == 2 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -33);
}
else if ( v9 <= 2 )
{
if ( v9 )
{
if ( v9 == 1 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -34);
}
}
else
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -36);
}
}
}
break;
default:
break;
}
}
}
LABEL_78:
if ( (v15 & 0x20) != 0 )
v10 = 250LL;
else
v10 = 1000LL;
v19 = sbbs_t::inkey(this, v15, v10);
if ( (*((_QWORD *)this + 6414) & 0x800LL) != 0 )
return 0;
*((_QWORD *)this + 6406) = time(0LL);
if ( v19 )
{
if ( ((v15 & 4) == 0 || !isprint((char)v19) || (unsigned int)((char)v19 - 48) <= 9)
&& ((v15 & 0x400) == 0 || !isprint((char)v19) || isalpha((char)v19))
&& ((v15 & 0x2000) == 0 || (v19 & 0x80u) == 0) )
{
if ( (v15 & 0x20) != 0 )
sbbs_t::backspace(this);
if ( (v15 & 0x10000) == 0 || (char)v19 <= 32 || (*((_QWORD *)this + 3362) & 0x40000LL) == 0 )
goto LABEL_110;
if ( (v15 & 1) != 0 )
{
v11 = toupper((char)v19);
sbbs_t::outchar(this, v11);
}
else
{
sbbs_t::outchar(this, v19);
}
do
v18 = sbbs_t::inkey(this, v15, 0x3E8uLL);
while ( !v18 && *((_QWORD *)this + 6413) && (*((_QWORD *)this + 6414) & 0x800LL) == 0 );
sbbs_t::backspace(this);
if ( v18 != 8 && v18 != 127 )
{
if ( v18 > 32 )
sbbs_t::ungetkey(this, v18);
LABEL_110:
if ( (v15 & 1) != 0 )
result = toupper((char)v19);
else
result = v19;
return result;
}
}
}
else
{
if ( (*((_QWORD *)this + 6414) & 8LL) == 0 || (*((_QWORD *)this + 6414) & 0x10LL) != 0 )
{
if ( *((_QWORD *)this + 6413)
&& (__int64)(*((_QWORD *)this + 6406) - *((_QWORD *)this + 6407)) > 1800
&& (*((_QWORD *)this + 6414) & 0x10LL) == 0 )
{
*((_QWORD *)this + 6394) &= 0xFFFFFFFFFFFFFFEDLL;
*((_QWORD *)this + 6394) |= 9uLL;
sbbs_t::bputs(this, *((char **)this + 5021));
sbbs_t::hangup(this);
}
}
else
{
sbbs_t::gettimeleft(this);
}
if ( (*((_QWORD *)this + 6414) & 8LL) != 0
&& *((_QWORD *)this + 6413)
&& *((_QWORD *)this + 6451) / 0x3CuLL < 5LL - *((_QWORD *)this + 6055)
&& *((_BYTE *)this + 26885) <= 0x59u
&& (*((_QWORD *)this + 6414) & 4LL) == 0
&& (*((_QWORD *)this + 6414) & 0x10LL) == 0 )
{
*((_QWORD *)this + 6055) = 5 - *((_QWORD *)this + 6451) / 0x3CuLL;
*((_BYTE *)this + *((int *)this + 12655) + 50612) = *((_BYTE *)this + 51144);
*((_BYTE *)this + *((int *)this + 12655) + 50616) = *((_BYTE *)this + 48448);
sprintf(
(char *)this + 513 * *((int *)this + 12655) + 48560,
"%.*s",
*((_DWORD *)this + 12785),
(const char *)this + 50624);
if ( *((int *)this + 12655) <= 3 )
++*((_DWORD *)this + 12655);
*((_DWORD *)this + 12785) = 0;
sbbs_t::attr(this, 7);
if ( *((_QWORD *)this + 6451) > 0x3BuLL )
v13 = "s";
else
v13 = nulstr;
sbbs_t::bprintf(this, *((char **)this + 5131), (unsigned __int16)*((_QWORD *)this + 6451) / 0x3Cu + 1, v13);
*((_DWORD *)this + 12785) = 0;
if ( *((_DWORD *)this + 12655) )
--*((_DWORD *)this + 12655);
sbbs_t::attr(this, *((char *)this + *((int *)this + 12655) + 50612));
sbbs_t::rputs(this, (char *)this + 513 * *((int *)this + 12655) + 48560);
*((_BYTE *)this + 48448) = *((_BYTE *)this + *((int *)this + 12655) + 50616);
}
if ( (*(_QWORD *)(*(_QWORD *)this + 32LL) & 0x100LL) == 0
&& v21 != *((_QWORD *)this + 6406)
&& (__int64)(*((_QWORD *)this + 6406) - *((_QWORD *)this + 6054)) > 59
&& !((*((_QWORD *)this + 6406) - *((_QWORD *)this + 6054)) % 60LL) )
{
sbbs_t::send_telnet_cmd(this, 0xF9u, 0);
v21 = *((_QWORD *)this + 6406);
}
if ( *((_QWORD *)this + 6413) == 2LL
&& (*((_QWORD *)this + 6394) & 0x2000LL) == 0
&& *((_QWORD *)this + 6406) - *((_QWORD *)this + 6054) >= (__int64)*((unsigned __int16 *)this + 11865) )
{
if ( (*((_QWORD *)this + 6414) & 8LL) == 0 || *((_WORD *)this + 11865) == *((_WORD *)this + 11866) )
{
sbbs_t::bputs(this, "\a\a");
}
else
{
*((_BYTE *)this + *((int *)this + 12655) + 50612) = *((_BYTE *)this + 51144);
*((_BYTE *)this + *((int *)this + 12655) + 50616) = *((_BYTE *)this + 48448);
sprintf(
(char *)this + 513 * *((int *)this + 12655) + 48560,
"%.*s",
*((_DWORD *)this + 12785),
(const char *)this + 50624);
if ( *((int *)this + 12655) <= 3 )
++*((_DWORD *)this + 12655);
*((_DWORD *)this + 12785) = 0;
sbbs_t::bputs(this, *((char **)this + 5132));
}
while ( !(unsigned __int8)sbbs_t::inkey(this, 0LL, 0x64uLL)
&& *((_QWORD *)this + 6413)
&& *((_QWORD *)this + 6406) - *((_QWORD *)this + 6054) >= (__int64)*((unsigned __int16 *)this + 11865) )
{
*((_QWORD *)this + 6406) = time(0LL);
if ( *((_QWORD *)this + 6406) - *((_QWORD *)this + 6054) >= (__int64)*((unsigned __int16 *)this + 11866) )
{
if ( *((_QWORD *)this + 6413) == 2LL )
{
*((_QWORD *)this + 6394) |= 1uLL;
*((_QWORD *)this + 6394) &= 0xFFFFFFFFFFFFFFFDLL;
}
sbbs_t::bputs(this, *((char **)this + 5022));
sbbs_t::logline(this, nulstr, "Inactive");
sbbs_t::hangup(this);
return 0;
}
}
if ( (*((_QWORD *)this + 6414) & 8LL) != 0 && *((_WORD *)this + 11865) != *((_WORD *)this + 11866) )
{
sbbs_t::bputs(this, asc_1F13);
*((_DWORD *)this + 12785) = 0;
if ( *((_DWORD *)this + 12655) )
--*((_DWORD *)this + 12655);
sbbs_t::attr(this, *((char *)this + *((int *)this + 12655) + 50612));
sbbs_t::rputs(this, (char *)this + 513 * *((int *)this + 12655) + 48560);
*((_BYTE *)this + 48448) = *((_BYTE *)this + *((int *)this + 12655) + 50616);
}
*((_QWORD *)this + 6054) = *((_QWORD *)this + 6406);
}
}
if ( !*((_QWORD *)this + 6413) )
return 0;
}
if ( (v15 & 0x20) != 0 )
sbbs_t::backspace(this);
result = 0;
}
else
{
v17 = 1;
timeout.tv_sec = 0LL;
timeout.tv_usec = 1000LL;
select(0, 0LL, 0LL, 0LL, &timeout);
result = 0;
}
return result;
}

canonical_decompiled_code:
int __fastcall sbbs_t::func0(sbbs_t *this, __int64 a2)
{
int result; // eax
__int64 v3; // rax
char v4; // al
char v5; // al
char v6; // al
char v7; // al
char v8; // al
char v9; // al
unsigned __int64 v10; // rdx
char v11; // al
const char *v13; // rax
__int64 v15; // [rsp+0h] [rbp-40h]
struct timeval timeout; // [rsp+10h] [rbp-30h] BYREF
int v17; // [rsp+28h] [rbp-18h]
char v18; // [rsp+2Dh] [rbp-13h]
unsigned __int8 v19; // [rsp+2Eh] [rbp-12h]
char v20; // [rsp+2Fh] [rbp-11h]
__int64 v21; // [rsp+30h] [rbp-10h]
char v22; // [rsp+3Fh] [rbp-1h]

v15 = a2;
v22 = 0;
v20 = sbbs_random(5LL);
v21 = 0LL;
if ( *((_QWORD *)this + 6413) && *((_BYTE *)this + 26098) == 1 )
{
v3 = *((_QWORD *)this + 6414);
BYTE1(v3) &= 0xF7u;
*((_QWORD *)this + 6414) = v3;
if ( ((*((_QWORD *)this + 6414) & 8LL) != 0 || *((_BYTE *)this + 51296) == 9) && (a2 & 0x200800) == 0 )
v15 = *((_QWORD *)this + 3362) & 0x20LL | a2;
*((_QWORD *)this + 6065) = 0LL;
*((_QWORD *)this + 6054) = time(0LL);
if ( (v15 & 0x20) != 0 )
sbbs_t::outchar(this, 32);
while ( (*((_QWORD *)this + 6414) & 0x800LL) == 0 )
{
if ( (v15 & 0x20) != 0 )
{
if ( (*((_QWORD *)this + 3362) & 0x8000LL) != 0 )
{
v4 = v22++;
if ( v4 == 3 )
{
LABEL_26:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, 92);
v22 = 0;
}
else if ( v4 <= 3 )
{
if ( v4 == 2 )
{
LABEL_25:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, 45);
}
else if ( v4 <= 2 )
{
if ( v4 )
{
if ( v4 == 1 )
{
LABEL_24:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, 47);
}
}
else
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, 124);
}
}
}
}
else
{
switch ( v20 )
{
case 0:
v5 = v22++;
if ( v5 == 3 )
goto LABEL_26;
if ( v5 <= 3 )
{
if ( v5 == 2 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -60);
}
else if ( v5 <= 2 )
{
if ( v5 )
{
if ( v5 == 1 )
goto LABEL_24;
}
else
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -77);
}
}
}
break;
case 1:
v6 = v22++;
switch ( v6 )
{
case 0:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -80);
break;
case 1:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -79);
break;
case 2:
case 4:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -78);
break;
case 3:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -37);
break;
case 5:
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -79);
v22 = 0;
break;
default:
goto LABEL_78;
}
break;
case 2:
v7 = v22++;
if ( v7 == 3 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, 61);
v22 = 0;
}
else if ( v7 <= 3 )
{
if ( v7 == 2 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -16);
}
else if ( v7 <= 2 )
{
if ( !v7 )
goto LABEL_25;
if ( v7 == 1 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, 61);
}
}
}
break;
case 3:
v8 = v22++;
if ( v8 == 3 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -65);
v22 = 0;
}
else if ( v8 <= 3 )
{
if ( v8 == 2 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -39);
}
else if ( v8 <= 2 )
{
if ( v8 )
{
if ( v8 == 1 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -64);
}
}
else
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -38);
}
}
}
break;
case 4:
v9 = v22++;
if ( v9 == 3 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -35);
v22 = 0;
}
else if ( v9 <= 3 )
{
if ( v9 == 2 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -33);
}
else if ( v9 <= 2 )
{
if ( v9 )
{
if ( v9 == 1 )
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -34);
}
}
else
{
sbbs_t::outchar(this, 8);
sbbs_t::outchar(this, -36);
}
}
}
break;
default:
break;
}
}
}
LABEL_78:
if ( (v15 & 0x20) != 0 )
v10 = 250LL;
else
v10 = 1000LL;
v19 = sbbs_t::inkey(this, v15, v10);
if ( (*((_QWORD *)this + 6414) & 0x800LL) != 0 )
return 0;
*((_QWORD *)this + 6406) = time(0LL);
if ( v19 )
{
if ( ((v15 & 4) == 0 || !isprint((char)v19) || (unsigned int)((char)v19 - 48) <= 9)
&& ((v15 & 0x400) == 0 || !isprint((char)v19) || isalpha((char)v19))
&& ((v15 & 0x2000) == 0 || (v19 & 0x80u) == 0) )
{
if ( (v15 & 0x20) != 0 )
sbbs_t::backspace(this);
if ( (v15 & 0x10000) == 0 || (char)v19 <= 32 || (*((_QWORD *)this + 3362) & 0x40000LL) == 0 )
goto LABEL_110;
if ( (v15 & 1) != 0 )
{
v11 = toupper((char)v19);
sbbs_t::outchar(this, v11);
}
else
{
sbbs_t::outchar(this, v19);
}
do
v18 = sbbs_t::inkey(this, v15, 0x3E8uLL);
while ( !v18 && *((_QWORD *)this + 6413) && (*((_QWORD *)this + 6414) & 0x800LL) == 0 );
sbbs_t::backspace(this);
if ( v18 != 8 && v18 != 127 )
{
if ( v18 > 32 )
sbbs_t::ungetkey(this, v18);
LABEL_110:
if ( (v15 & 1) != 0 )
result = toupper((char)v19);
else
result = v19;
return result;
}
}
}
else
{
if ( (*((_QWORD *)this + 6414) & 8LL) == 0 || (*((_QWORD *)this + 6414) & 0x10LL) != 0 )
{
if ( *((_QWORD *)this + 6413)
&& (__int64)(*((_QWORD *)this + 6406) - *((_QWORD *)this + 6407)) > 1800
&& (*((_QWORD *)this + 6414) & 0x10LL) == 0 )
{
*((_QWORD *)this + 6394) &= 0xFFFFFFFFFFFFFFEDLL;
*((_QWORD *)this + 6394) |= 9uLL;
sbbs_t::bputs(this, *((char **)this + 5021));
sbbs_t::hangup(this);
}
}
else
{
sbbs_t::gettimeleft(this);
}
if ( (*((_QWORD *)this + 6414) & 8LL) != 0
&& *((_QWORD *)this + 6413)
&& *((_QWORD *)this + 6451) / 0x3CuLL < 5LL - *((_QWORD *)this + 6055)
&& *((_BYTE *)this + 26885) <= 0x59u
&& (*((_QWORD *)this + 6414) & 4LL) == 0
&& (*((_QWORD *)this + 6414) & 0x10LL) == 0 )
{
*((_QWORD *)this + 6055) = 5 - *((_QWORD *)this + 6451) / 0x3CuLL;
*((_BYTE *)this + *((int *)this + 12655) + 50612) = *((_BYTE *)this + 51144);
*((_BYTE *)this + *((int *)this + 12655) + 50616) = *((_BYTE *)this + 48448);
sprintf(
(char *)this + 513 * *((int *)this + 12655) + 48560,
"%.*s",
*((_DWORD *)this + 12785),
(const char *)this + 50624);
if ( *((int *)this + 12655) <= 3 )
++*((_DWORD *)this + 12655);
*((_DWORD *)this + 12785) = 0;
sbbs_t::attr(this, 7);
if ( *((_QWORD *)this + 6451) > 0x3BuLL )
v13 = "s";
else
v13 = nulstr;
sbbs_t::bprintf(this, *((char **)this + 5131), (unsigned __int16)*((_QWORD *)this + 6451) / 0x3Cu + 1, v13);
*((_DWORD *)this + 12785) = 0;
if ( *((_DWORD *)this + 12655) )
--*((_DWORD *)this + 12655);
sbbs_t::attr(this, *((char *)this + *((int *)this + 12655) + 50612));
sbbs_t::rputs(this, (char *)this + 513 * *((int *)this + 12655) + 48560);
*((_BYTE *)this + 48448) = *((_BYTE *)this + *((int *)this + 12655) + 50616);
}
if ( (*(_QWORD *)(*(_QWORD *)this + 32LL) & 0x100LL) == 0
&& v21 != *((_QWORD *)this + 6406)
&& (__int64)(*((_QWORD *)this + 6406) - *((_QWORD *)this + 6054)) > 59
&& !((*((_QWORD *)this + 6406) - *((_QWORD *)this + 6054)) % 60LL) )
{
sbbs_t::send_telnet_cmd(this, 0xF9u, 0);
v21 = *((_QWORD *)this + 6406);
}
if ( *((_QWORD *)this + 6413) == 2LL
&& (*((_QWORD *)this + 6394) & 0x2000LL) == 0
&& *((_QWORD *)this + 6406) - *((_QWORD *)this + 6054) >= (__int64)*((unsigned __int16 *)this + 11865) )
{
if ( (*((_QWORD *)this + 6414) & 8LL) == 0 || *((_WORD *)this + 11865) == *((_WORD *)this + 11866) )
{
sbbs_t::bputs(this, "\a\a");
}
else
{
*((_BYTE *)this + *((int *)this + 12655) + 50612) = *((_BYTE *)this + 51144);
*((_BYTE *)this + *((int *)this + 12655) + 50616) = *((_BYTE *)this + 48448);
sprintf(
(char *)this + 513 * *((int *)this + 12655) + 48560,
"%.*s",
*((_DWORD *)this + 12785),
(const char *)this + 50624);
if ( *((int *)this + 12655) <= 3 )
++*((_DWORD *)this + 12655);
*((_DWORD *)this + 12785) = 0;
sbbs_t::bputs(this, *((char **)this + 5132));
}
while ( !(unsigned __int8)sbbs_t::inkey(this, 0LL, 0x64uLL)
&& *((_QWORD *)this + 6413)
&& *((_QWORD *)this + 6406) - *((_QWORD *)this + 6054) >= (__int64)*((unsigned __int16 *)this + 11865) )
{
*((_QWORD *)this + 6406) = time(0LL);
if ( *((_QWORD *)this + 6406) - *((_QWORD *)this + 6054) >= (__int64)*((unsigned __int16 *)this + 11866) )
{
if ( *((_QWORD *)this + 6413) == 2LL )
{
*((_QWORD *)this + 6394) |= 1uLL;
*((_QWORD *)this + 6394) &= 0xFFFFFFFFFFFFFFFDLL;
}
sbbs_t::bputs(this, *((char **)this + 5022));
sbbs_t::logline(this, nulstr, "Inactive");
sbbs_t::hangup(this);
return 0;
}
}
if ( (*((_QWORD *)this + 6414) & 8LL) != 0 && *((_WORD *)this + 11865) != *((_WORD *)this + 11866) )
{
sbbs_t::bputs(this, asc_1F13);
*((_DWORD *)this + 12785) = 0;
if ( *((_DWORD *)this + 12655) )
--*((_DWORD *)this + 12655);
sbbs_t::attr(this, *((char *)this + *((int *)this + 12655) + 50612));
sbbs_t::rputs(this, (char *)this + 513 * *((int *)this + 12655) + 48560);
*((_BYTE *)this + 48448) = *((_BYTE *)this + *((int *)this + 12655) + 50616);
}
*((_QWORD *)this + 6054) = *((_QWORD *)this + 6406);
}
}
if ( !*((_QWORD *)this + 6413) )
return 0;
}
if ( (v15 & 0x20) != 0 )
sbbs_t::backspace(this);
result = 0;
}
else
{
v17 = 1;
timeout.tv_sec = 0LL;
timeout.tv_usec = 1000LL;
select(0, 0LL, 0LL, 0LL, &timeout);
result = 0;
}
return result;
}

original_code:
char getkey(long mode)
{
 char ch,warn=0;
 long tleft;
 time_t timeout,now;
 aborted=lncntr=0;
 timeout=time(((void *)0));
 do {
  checkline();
  ch=inkey(mode);
  now=time(((void *)0));
  if(ch) {
   if(mode&(1<<2) && ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISprint) && !((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISdigit))
    continue;
   if(mode&(1<<10) && ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISprint) && !((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISalpha))
    continue;
   if(ch=='\n') continue;
   if(mode&(1<<0))
    return(toupper(ch));
   return(ch);
  }
  checktimeleft();
  tleft=timeleft-(now-starttime);
  if((tleft/60)<(5-timeleft_warn)) {
   timeleft_warn=5-(tleft/60);
   { slatr[slcnt]=latr; sprintf(slbuf[slcnt<4 ? slcnt++ : slcnt] ,"%.*s",lbuflen,lbuf); lbuflen=0; };
   bprintf("\1n\1h\r\n\7\r\nYou only have \1r\1i%u\1n\1h minute%s "
    "left.\r\n\r\n"
    ,((unsigned short)tleft/60)+1,(tleft/60) ? "s" : "");
   { lbuflen=0; attr(slatr[--slcnt]); bputs(slbuf[slcnt]); };
  }
  if(now-timeout>=(time_t)sec_warn && !warn)
   for(warn=0;warn<5;warn++)
    outchar(7);
 } while(now-timeout<(time_t)sec_timeout);
 bputs("\r\nInactive too long.\r\n");
 exit(0);
 return(0);
}

canonical_original_code:
char getkey(long mode)
{
 char ch; char warn = 0;
 long tleft;
 long timeout; long now;
 aborted=lncntr=0;
 timeout=time(((void *)0));
 do {
  checkline();
  ch=inkey(mode);
  now=time(((void *)0));
  if(ch) {
   if(mode&(1<<2) && ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISprint) && !((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISdigit))
    continue;
   if(mode&(1<<10) && ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISprint) && !((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISalpha))
    continue;
   if(ch=='\n') continue;
   if(mode&(1<<0))
    return(toupper(ch));
   return(ch);
  }
  checktimeleft();
  tleft=timeleft-(now-starttime);
  if((tleft/60)<(5-timeleft_warn)) {
   timeleft_warn=5-(tleft/60);
   { slatr[slcnt]=latr; sprintf(slbuf[slcnt<4 ? slcnt++ : slcnt] ,"%.*s",lbuflen,lbuf); lbuflen=0; };
   bprintf("\1n\1h\r\n\7\r\nYou only have \1r\1i%u\1n\1h minute%s "
    "left.\r\n\r\n"
    ,((unsigned short)tleft/60)+1,(tleft/60) ? "s" : "");
   { lbuflen=0; attr(slatr[--slcnt]); bputs(slbuf[slcnt]); };
  }
  if(now-timeout>=(long)sec_warn && !warn)
   for(warn=0;warn<5;warn++)
    outchar(7);
 } while(now-timeout<(long)sec_timeout);
 bputs("\r\nInactive too long.\r\n");
 exit(0);
 return(0);
}

variable_types: mode long

variable_types: ch char

variable_types: warn char

variable_types: tleft long

variable_types: timeout long

variable_types: now long

return_type: char


mnemonics

decompiled_code:
__int64 __fastcall sbbs_t::mnemonics(sbbs_t *this, char *a2)
{
__int64 result; // rax
__int64 v3; // rax
char *v4; // [rsp+10h] [rbp-10h]
__int64 v5; // [rsp+18h] [rbp-8h]
__int64 v6; // [rsp+18h] [rbp-8h]
__int64 v7; // [rsp+18h] [rbp-8h]

if ( !strchr(a2, 126) )
goto LABEL_2;
v4 = strchr(a2, 1);
if ( !v4 )
{
if ( *a2 == 64 && a2[strlen(a2) - 1] == 64 && !strchr(a2, 32) )
{
LABEL_2:
*((_QWORD *)this + 6774) = a2;
return sbbs_t::bputs(this, a2);
}
sbbs_t::attr(this, *(char *)(*((_QWORD *)this + 2967) + 1LL));
}
v5 = 0LL;
while ( 1 )
{
result = (unsigned __int8)a2[v5];
if ( !(_BYTE)result )
break;
if ( a2[v5] == 126 && a2[v5 + 1] )
{
if ( !sbbs_t::term_supports(this, 2LL) )
sbbs_t::outchar(this, 40);
v6 = v5 + 1;
if ( !v4 )
sbbs_t::attr(this, **((char **)this + 2967));
sbbs_t::outchar(this, a2[v6]);
v5 = v6 + 1;
if ( !sbbs_t::term_supports(this, 2LL) )
sbbs_t::outchar(this, 41);
if ( !v4 )
sbbs_t::attr(this, *(char *)(*((_QWORD *)this + 2967) + 1LL));
}
else if ( a2[v5] == 1 && a2[v5 + 1] )
{
v7 = v5 + 1;
sbbs_t::ctrl_a(this, a2[v7]);
v5 = v7 + 1;
}
else
{
v3 = v5++;
sbbs_t::outchar(this, a2[v3]);
}
}
if ( !v4 )
result = sbbs_t::attr(this, *(char *)(*((_QWORD *)this + 2967) + 2LL));
return result;
}

canonical_decompiled_code:
__int64 __fastcall sbbs_t::func1(sbbs_t *this, char *a2)
{
__int64 result; // rax
__int64 v3; // rax
char *v4; // [rsp+10h] [rbp-10h]
__int64 v5; // [rsp+18h] [rbp-8h]
__int64 v6; // [rsp+18h] [rbp-8h]
__int64 v7; // [rsp+18h] [rbp-8h]

if ( !strchr(a2, 126) )
goto LABEL_2;
v4 = strchr(a2, 1);
if ( !v4 )
{
if ( *a2 == 64 && a2[strlen(a2) - 1] == 64 && !strchr(a2, 32) )
{
LABEL_2:
*((_QWORD *)this + 6774) = a2;
return sbbs_t::bputs(this, a2);
}
sbbs_t::attr(this, *(char *)(*((_QWORD *)this + 2967) + 1LL));
}
v5 = 0LL;
while ( 1 )
{
result = (unsigned __int8)a2[v5];
if ( !(_BYTE)result )
break;
if ( a2[v5] == 126 && a2[v5 + 1] )
{
if ( !sbbs_t::term_supports(this, 2LL) )
sbbs_t::outchar(this, 40);
v6 = v5 + 1;
if ( !v4 )
sbbs_t::attr(this, **((char **)this + 2967));
sbbs_t::outchar(this, a2[v6]);
v5 = v6 + 1;
if ( !sbbs_t::term_supports(this, 2LL) )
sbbs_t::outchar(this, 41);
if ( !v4 )
sbbs_t::attr(this, *(char *)(*((_QWORD *)this + 2967) + 1LL));
}
else if ( a2[v5] == 1 && a2[v5 + 1] )
{
v7 = v5 + 1;
sbbs_t::ctrl_a(this, a2[v7]);
v5 = v7 + 1;
}
else
{
v3 = v5++;
sbbs_t::outchar(this, a2[v3]);
}
}
if ( !v4 )
result = sbbs_t::attr(this, *(char *)(*((_QWORD *)this + 2967) + 2LL));
return result;
}

original_code:
void mnemonics(char *str)
{
 long l;
 attr(mnelow);
 l=0L;
 while(str[l]) {
  if(str[l]=='~' && str[l+1]) {
   if(!(user_misc&(1<<0)))
    outchar('(');
   l++;
   attr(mnehigh);
   outchar(str[l]);
   l++;
   if(!(user_misc&(1<<0)))
    outchar(')');
   attr(mnelow);
  }
  else
   outchar(str[l++]);
 }
 attr(LIGHTGRAY);
}

variable_types:
str
char *

variable_types: l long


yesno

decompiled_code:
__int64 __fastcall sbbs_t::yesno(sbbs_t *this, char *a2)
{
char v3; // [rsp+1Fh] [rbp-1h]

strcpy((char *)this + 54064, a2);
sbbs_t::getnodedat(this, *((unsigned __int16 *)this + 1212), (char *)this + 27056, 0LL);
sbbs_t::nodesync(this);
if ( (*((_QWORD *)this + 3362) & 0x200000LL) != 0 )
{
strip_ctrl((char *)this + 54064);
sbbs_t::menu(this, "yesno");
}
else
{
sbbs_t::bprintf(this, *((char **)this + 5023), a2);
}
do
{
if ( !*((_QWORD *)this + 6413) )
return 1LL;
if ( (*((_QWORD *)this + 6414) & 0x800LL) != 0 )
v3 = *(_BYTE *)(*((_QWORD *)this + 5184) + 1LL);
else
v3 = sbbs_t::getkey(this, 65537LL);
if ( v3 == **((_BYTE **)this + 5184) || v3 == 13 )
{
if ( (unsigned int)sbbs_t::bputs(this, *((char **)this + 5024)) )
{
sbbs_t::outchar(this, 13);
sbbs_t::outchar(this, 10);
}
*((_QWORD *)this + 6065) = 0LL;
return 1LL;
}
}
while ( v3 != *(_BYTE *)(*((_QWORD *)this + 5184) + 1LL) );
if ( (unsigned int)sbbs_t::bputs(this, *((char **)this + 5025)) )
{
sbbs_t::outchar(this, 13);
sbbs_t::outchar(this, 10);
}
*((_QWORD *)this + 6065) = 0LL;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall sbbs_t::func2(sbbs_t *this, char *a2)
{
char v3; // [rsp+1Fh] [rbp-1h]

strcpy((char *)this + 54064, a2);
sbbs_t::getnodedat(this, *((unsigned __int16 *)this + 1212), (char *)this + 27056, 0LL);
sbbs_t::nodesync(this);
if ( (*((_QWORD *)this + 3362) & 0x200000LL) != 0 )
{
strip_ctrl((char *)this + 54064);
sbbs_t::menu(this, "yesno");
}
else
{
sbbs_t::bprintf(this, *((char **)this + 5023), a2);
}
do
{
if ( !*((_QWORD *)this + 6413) )
return 1LL;
if ( (*((_QWORD *)this + 6414) & 0x800LL) != 0 )
v3 = *(_BYTE *)(*((_QWORD *)this + 5184) + 1LL);
else
v3 = sbbs_t::func0(this, 65537LL);
if ( v3 == **((_BYTE **)this + 5184) || v3 == 13 )
{
if ( (unsigned int)sbbs_t::bputs(this, *((char **)this + 5024)) )
{
sbbs_t::outchar(this, 13);
sbbs_t::outchar(this, 10);
}
*((_QWORD *)this + 6065) = 0LL;
return 1LL;
}
}
while ( v3 != *(_BYTE *)(*((_QWORD *)this + 5184) + 1LL) );
if ( (unsigned int)sbbs_t::bputs(this, *((char **)this + 5025)) )
{
sbbs_t::outchar(this, 13);
sbbs_t::outchar(this, 10);
}
*((_QWORD *)this + 6065) = 0LL;
return 0LL;
}

original_code:
char yesno(char *str)
{
 char ch;
 bprintf("\1_\1b\1h%s (Y/n) ? \1w",str);
 while(1) {
  ch=getkey((1<<0));
  if(ch=='Y' || ch=='\r') {
   bputs("Yes\r\n");
   return(1); }
  if(ch=='N' || aborted) {
   bputs("No\r\n");
   return(0);
  }
 }
}


noyes

decompiled_code:
__int64 __fastcall sbbs_t::noyes(sbbs_t *this, char *a2)
{
char v3; // [rsp+1Fh] [rbp-1h]

strcpy((char *)this + 54064, a2);
sbbs_t::getnodedat(this, *((unsigned __int16 *)this + 1212), (char *)this + 27056, 0LL);
sbbs_t::nodesync(this);
if ( (*((_QWORD *)this + 3362) & 0x200000LL) != 0 )
{
strip_ctrl((char *)this + 54064);
sbbs_t::menu(this, "noyes");
}
else
{
sbbs_t::bprintf(this, *((char **)this + 5026), a2);
}
do
{
if ( !*((_QWORD *)this + 6413) )
return 1LL;
if ( (*((_QWORD *)this + 6414) & 0x800LL) != 0 )
v3 = *(_BYTE *)(*((_QWORD *)this + 5184) + 1LL);
else
v3 = sbbs_t::getkey(this, 65537LL);
if ( v3 == *(_BYTE *)(*((_QWORD *)this + 5184) + 1LL) || v3 == 13 )
{
if ( (unsigned int)sbbs_t::bputs(this, *((char **)this + 5025)) )
{
sbbs_t::outchar(this, 13);
sbbs_t::outchar(this, 10);
}
*((_QWORD *)this + 6065) = 0LL;
return 1LL;
}
}
while ( v3 != **((_BYTE **)this + 5184) );
if ( (unsigned int)sbbs_t::bputs(this, *((char **)this + 5024)) )
{
sbbs_t::outchar(this, 13);
sbbs_t::outchar(this, 10);
}
*((_QWORD *)this + 6065) = 0LL;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall sbbs_t::func3(sbbs_t *this, char *a2)
{
char v3; // [rsp+1Fh] [rbp-1h]

strcpy((char *)this + 54064, a2);
sbbs_t::getnodedat(this, *((unsigned __int16 *)this + 1212), (char *)this + 27056, 0LL);
sbbs_t::nodesync(this);
if ( (*((_QWORD *)this + 3362) & 0x200000LL) != 0 )
{
strip_ctrl((char *)this + 54064);
sbbs_t::menu(this, "noyes");
}
else
{
sbbs_t::bprintf(this, *((char **)this + 5026), a2);
}
do
{
if ( !*((_QWORD *)this + 6413) )
return 1LL;
if ( (*((_QWORD *)this + 6414) & 0x800LL) != 0 )
v3 = *(_BYTE *)(*((_QWORD *)this + 5184) + 1LL);
else
v3 = sbbs_t::func0(this, 65537LL);
if ( v3 == *(_BYTE *)(*((_QWORD *)this + 5184) + 1LL) || v3 == 13 )
{
if ( (unsigned int)sbbs_t::bputs(this, *((char **)this + 5025)) )
{
sbbs_t::outchar(this, 13);
sbbs_t::outchar(this, 10);
}
*((_QWORD *)this + 6065) = 0LL;
return 1LL;
}
}
while ( v3 != **((_BYTE **)this + 5184) );
if ( (unsigned int)sbbs_t::bputs(this, *((char **)this + 5024)) )
{
sbbs_t::outchar(this, 13);
sbbs_t::outchar(this, 10);
}
*((_QWORD *)this + 6065) = 0LL;
return 0LL;
}

original_code:
char noyes(char *str)
{
 char ch;
 bprintf("\1_\1b\1h%s (y/N) ? \1w",str);
 while(1) {
  ch=getkey((1<<0));
  if(ch=='N' || ch=='\r' || aborted) {
   bputs("No\r\n");
   return(1); }
  if(ch=='Y') {
   bputs("Yes\r\n");
   return(0);
  }
 }
}