decompiled_code:
__int64 __fastcall bad_config(int a1)
{
__m128i *v1; // rax
__int64 result; // rax
size_t v3; // rax
FILE *v4; // rdi
char v5[1032]; // [rsp+0h] [rbp-408h] BYREF

sprintf(v5, "Bad config, missing required field: '%s'", (&setmap)[4 * a1]);
if ( !gotworkingcfg )
{
v3 = strlen(v5);
v4 = out;
*(_WORD *)&v5[v3] = 10;
fprintf(v4, v5);
exit(0);
}
v1 = (__m128i *)&v5[strlen(v5)];
strcpy(v1[1].m128i_i8, "vious config.");
*v1 = _mm_load_si128((const __m128i *)&LC2);
sRelay(v5);
config = lastcfg;
result = *(_QWORD *)((char *)&lastcfg + 3308);
*(_QWORD *)((char *)&config + 3308) = result;
qmemcpy(
(void *)(((_DWORD)&config + 8) & 0xFFFFFFF8),
(const void *)(&lastcfg - (_UNKNOWN *)((char *)&config - (((_DWORD)&config + 8) & 0xFFFFFFF8))),
8LL * (((unsigned int)&config - (((_DWORD)&config + 8) & 0xFFFFFFF8) + 3316) >> 3));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__m128i *v1; // rax
__int64 result; // rax
size_t v3; // rax
FILE *v4; // rdi
char v5[1032]; // [rsp+0h] [rbp-408h] BYREF

sprintf(v5, "Bad config, missing required field: '%s'", (&setmap)[4 * a1]);
if ( !gotworkingcfg )
{
v3 = strlen(v5);
v4 = out;
*(_WORD *)&v5[v3] = 10;
fprintf(v4, v5);
exit(0);
}
v1 = (__m128i *)&v5[strlen(v5)];
strcpy(v1[1].m128i_i8, "vious config.");
*v1 = _mm_load_si128((const __m128i *)&LC2);
sRelay(v5);
config = lastcfg;
result = *(_QWORD *)((char *)&lastcfg + 3308);
*(_QWORD *)((char *)&config + 3308) = result;
qmemcpy(
(void *)(((_DWORD)&config + 8) & 0xFFFFFFF8),
(const void *)(&lastcfg - (_UNKNOWN *)((char *)&config - (((_DWORD)&config + 8) & 0xFFFFFFF8))),
8LL * (((unsigned int)&config - (((_DWORD)&config + 8) & 0xFFFFFFF8) + 3316) >> 3));
return result;
}

original_code:
static void bad_config(int i)
{
 char eb[1024];
 sprintf(eb, "Bad config, missing required field: '%s'", setmap[i].var);
 if(gotworkingcfg) {
  strcat(eb, "Reverting to previous config.");
  sRelay(eb);
  config = lastcfg;
 } else {
  strcat(eb, "\n");
  fprintf(out, eb);
  exit(0);
 }
 return;
}


repo: ipacker/fireclaw

decompiled_code:
int __fastcall dealwith_line(unsigned int a1, __int64 a2, __int64 a3, const char *a4)
{
__int64 v7; // rbx
const char *v8; // rdi
char **v9; // r12
int *v10; // rax
int v11; // er8
const char *v12; // rsi
size_t v13; // rax
size_t v14; // rdx

if ( (unsigned int)strmi(a2, "die") )
exit(0);
if ( (unsigned int)strmi(a2, "set") )
{
v7 = 0LL;
v8 = "nick";
while ( !(unsigned int)strmi(v8, a3) )
{
++v7;
v8 = (&setmap)[4 * v7];
if ( !v8 )
{
v12 = "Variable name not recognised";
LABEL_14:
LODWORD(v10) = syntax_err(a1, v12);
return (int)v10;
}
}
v9 = &(&setmap)[4 * (int)v7];
LODWORD(v10) = *((unsigned __int8 *)v9 + 16);
if ( (_BYTE)v10 == 115 )
{
v13 = strlen(a4);
v14 = *((int *)v9 + 5);
if ( v13 > v14 )
{
v12 = "Value too long";
goto LABEL_14;
}
LODWORD(v10) = mystrncpy(v9[1], a4, (int)v14 + 1);
}
else if ( (_BYTE)v10 == 105 )
{
v11 = atoi(a4);
v10 = (int *)v9[1];
*v10 = v11;
}
}
else if ( (unsigned int)strmi(a3, "server") )
{
LODWORD(v10) = add_server(a4);
if ( !(_DWORD)v10 )
LODWORD(v10) = fwrite("Warning, MAX_SERVERS exceeded.\n", 1uLL, 0x1FuLL, out);
}
else if ( (unsigned int)strmi(a3, "badurl") )
{
LODWORD(v10) = add_badurl(a4);
}
else if ( (unsigned int)strmi(a3, "word") )
{
LODWORD(v10) = add_word(a4);
}
else if ( (unsigned int)strmi(a3, "vhost") )
{
LODWORD(v10) = add_vhost(a4);
}
else
{
LODWORD(v10) = strmi(a3, "link");
if ( (_DWORD)v10 )
LODWORD(v10) = add_link(a4, 102LL);
}
return (int)v10;
}

canonical_decompiled_code:
int __fastcall func2(unsigned int a1, __int64 a2, __int64 a3, const char *a4)
{
__int64 v7; // rbx
const char *v8; // rdi
char **v9; // r12
int *v10; // rax
int v11; // er8
const char *v12; // rsi
size_t v13; // rax
size_t v14; // rdx

if ( (unsigned int)strmi(a2, "die") )
exit(0);
if ( (unsigned int)strmi(a2, "set") )
{
v7 = 0LL;
v8 = "nick";
while ( !(unsigned int)strmi(v8, a3) )
{
++v7;
v8 = (&setmap)[4 * v7];
if ( !v8 )
{
v12 = "Variable name not recognised";
LABEL_14:
LODWORD(v10) = func0(a1, v12);
return (int)v10;
}
}
v9 = &(&setmap)[4 * (int)v7];
LODWORD(v10) = *((unsigned __int8 *)v9 + 16);
if ( (_BYTE)v10 == 115 )
{
v13 = strlen(a4);
v14 = *((int *)v9 + 5);
if ( v13 > v14 )
{
v12 = "Value too long";
goto LABEL_14;
}
LODWORD(v10) = mystrncpy(v9[1], a4, (int)v14 + 1);
}
else if ( (_BYTE)v10 == 105 )
{
v11 = atoi(a4);
v10 = (int *)v9[1];
*v10 = v11;
}
}
else if ( (unsigned int)strmi(a3, "server") )
{
LODWORD(v10) = add_server(a4);
if ( !(_DWORD)v10 )
LODWORD(v10) = fwrite("Warning, MAX_SERVERS exceeded.\n", 1uLL, 0x1FuLL, out);
}
else if ( (unsigned int)strmi(a3, "badurl") )
{
LODWORD(v10) = add_badurl(a4);
}
else if ( (unsigned int)strmi(a3, "word") )
{
LODWORD(v10) = add_word(a4);
}
else if ( (unsigned int)strmi(a3, "vhost") )
{
LODWORD(v10) = add_vhost(a4);
}
else
{
LODWORD(v10) = strmi(a3, "link");
if ( (_DWORD)v10 )
LODWORD(v10) = add_link(a4, 102LL);
}
return (int)v10;
}

original_code:
static void dealwith_line(int line, char *cmd, char *var, char *value)
{
 int i;
 if(strmi(cmd, "die"))
  exit(0);
 if(strmi(cmd, "set"))
 {
  for(i = 0; setmap[i].var; i++)
  {
   if(strmi(setmap[i].var, var))
   {
    if(setmap[i].type == 's') {
     if(strlen(value) <= setmap[i].length)
      mystrncpy((char*)setmap[i].memory, value, setmap[i].length+1);
     else
      syntax_err(line, "Value too long");
    } else if(setmap[i].type == 'i') {
     (*(int*)setmap[i].memory) = atoi(value);
    }
    return;
   }
  }
  syntax_err(line, "Variable name not recognised");
  return;
 }
 if(strmi(var, "server")) {
  if(!add_server(value))
   fprintf(out, "Warning, MAX_SERVERS exceeded.\n");
 } else if(strmi(var, "badurl")) {
  add_badurl(value);
 } else if(strmi(var, "word")) {
  add_word(value);
 } else if(strmi(var, "vhost")) {
  add_vhost(value);
 } else if(strmi(var, "link")) {
  add_link(value, 'f');
 }
 return;
}

canonical_original_code:
static void dealwith_line(int line, char *cmd, char *var, char *value)
{
 int i;
 if(strmi(cmd, "die"))
  exit(0);
 if(strmi(cmd, "set"))
 {
  for(i = 0; setmap[i].var; i++)
  {
   if(strmi(setmap[i].var, var))
   {
    if(setmap[i].type == 's') {
     if(strlen(value) <= setmap[i].length)
      mystrncpy((char *)setmap[i].memory, value, setmap[i].length+1);
     else
      syntax_err(line, "Value too long");
    } else if(setmap[i].type == 'i') {
     (*(int *)setmap[i].memory) = atoi(value);
    }
    return;
   }
  }
  syntax_err(line, "Variable name not recognised");
  return;
 }
 if(strmi(var, "server")) {
  if(!add_server(value))
   fprintf(out, "Warning, MAX_SERVERS exceeded.\n");
 } else if(strmi(var, "badurl")) {
  add_badurl(value);
 } else if(strmi(var, "word")) {
  add_word(value);
 } else if(strmi(var, "vhost")) {
  add_vhost(value);
 } else if(strmi(var, "link")) {
  add_link(value, 'f');
 }
 return;
}

variable_types: line int

variable_types:
cmd
char *

variable_types:
var
char *

variable_types:
value
char *

variable_types: i int

return_type: void


decompiled_code:
int __fastcall override_config(const char *a1, unsigned int *a2, unsigned int a3)
{
int result; // eax
char v5[328]; // [rsp-148h] [rbp-148h] BYREF

result = config[298];
if ( !result && *a2 != a3 )
{
sprintf(v5, "Overriding config setting for '%s', as server has told us a new value (%d).", a1, a3);
sRelay(v5);
result = fprintf(out, "%s\n", v5);
*a2 = a3;
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(const char *a1, unsigned int *a2, unsigned int a3)
{
int result; // eax
char v5[328]; // [rsp-148h] [rbp-148h] BYREF

result = config[298];
if ( !result && *a2 != a3 )
{
sprintf(v5, "Overriding config setting for '%s', as server has told us a new value (%d).", a1, a3);
sRelay(v5);
result = fprintf(out, "%s\n", v5);
*a2 = a3;
}
return result;
}

original_code:
void override_config(char *type, int *location, int newint)
{
 char eb[300];
 if(config.nooverride == 0 && *location != newint) {
  sprintf(eb, "Overriding config setting for '%s', as server has told us a new value (%d).", type, newint);
  sRelay(eb);
  fprintf(out, "%s\n", eb);
  *location = newint;
 }
 return;
}

variable_types:
type
char *

variable_types:
location
int *

variable_types: newint int

variable_types:
eb
char [300]


decompiled_code:
__int64 check_config()
{
char v0; // al
int v1; // ebp
void **i; // rbx
char *v3; // rax
int v4; // edx
int v5; // eax
bool v6; // cc
__int64 v7; // rdx
__int64 v8; // rdx
char *v9; // rdi
__int64 result; // rax
const char *v11; // rsi

v0 = 115;
v1 = 0;
for ( i = &off_1068; ; v0 = *((_BYTE *)i + 8) )
{
if ( v0 != 105 )
{
if ( v0 == 115 && !*(_BYTE *)*i )
{
v11 = (const char *)i[2];
if ( !v11 )
return bad_config(v1);
strcpy((char *)*i, v11);
}
LABEL_3:
i += 4;
++v1;
if ( !*(i - 1) )
break;
continue;
}
v3 = (char *)*i;
if ( *(_DWORD *)*i )
goto LABEL_3;
v4 = *((_DWORD *)i + 3);
if ( v4 == -1 )
return bad_config(v1);
i += 4;
++v1;
*(_DWORD *)v3 = v4;
if ( !*(i - 1) )
break;
}
v5 = config[258] / 2;
v6 = config[299] <= 299;
config[259] = v5;
config[260] = 3 * v5;
if ( v6 )
config[299] = 300;
HIBYTE(config[292]) = 0;
mystrncpy((unsigned int)((_DWORD)config + 1156), (unsigned int)((_DWORD)config + 113), 16LL);
kill_dcc_listen();
disconnect_all_links("ERROR Config rehash");
v7 = (unsigned int)config[288];
if ( (int)v7 > 0 && add_listen(68LL, 3LL, v7, (unsigned int)((_DWORD)config + 1156)) )
fprintf(
out,
"Listening for connections on %s:%d\n",
(const char *)(unsigned int)((_DWORD)config + 1156),
(unsigned int)config[288]);
v8 = (unsigned int)config[274];
if ( (int)v8 > 0 )
{
if ( add_listen(70LL, 4LL, v8, (unsigned int)((_DWORD)config + 113)) )
fprintf(
out,
"Listening for connections on %s:%d\n",
(const char *)(unsigned int)((_DWORD)config + 113),
(unsigned int)config[274]);
}
gotworkingcfg = 1;
v9 = (char *)(((_DWORD)&lastcfg + 8) & 0xFFFFFFF8);
lastcfg = *(_QWORD *)config;
*(_QWORD *)((char *)&lastcfg + 3308) = *(_QWORD *)&config[827];
result = ((unsigned int)(&lastcfg - (_UNKNOWN *)v9) + 3316) >> 3;
qmemcpy(v9, (char *)config - (&lastcfg - (_UNKNOWN *)v9), 8LL * (unsigned int)result);
return result;
}

canonical_decompiled_code:
__int64 func4()
{
char v0; // al
int v1; // ebp
void **i; // rbx
char *v3; // rax
int v4; // edx
int v5; // eax
bool v6; // cc
__int64 v7; // rdx
__int64 v8; // rdx
char *v9; // rdi
__int64 result; // rax
const char *v11; // rsi

v0 = 115;
v1 = 0;
for ( i = &off_1068; ; v0 = *((_BYTE *)i + 8) )
{
if ( v0 != 105 )
{
if ( v0 == 115 && !*(_BYTE *)*i )
{
v11 = (const char *)i[2];
if ( !v11 )
return func1(v1);
strcpy((char *)*i, v11);
}
LABEL_3:
i += 4;
++v1;
if ( !*(i - 1) )
break;
continue;
}
v3 = (char *)*i;
if ( *(_DWORD *)*i )
goto LABEL_3;
v4 = *((_DWORD *)i + 3);
if ( v4 == -1 )
return func1(v1);
i += 4;
++v1;
*(_DWORD *)v3 = v4;
if ( !*(i - 1) )
break;
}
v5 = config[258] / 2;
v6 = config[299] <= 299;
config[259] = v5;
config[260] = 3 * v5;
if ( v6 )
config[299] = 300;
HIBYTE(config[292]) = 0;
mystrncpy((unsigned int)((_DWORD)config + 1156), (unsigned int)((_DWORD)config + 113), 16LL);
kill_dcc_listen();
disconnect_all_links("ERROR Config rehash");
v7 = (unsigned int)config[288];
if ( (int)v7 > 0 && add_listen(68LL, 3LL, v7, (unsigned int)((_DWORD)config + 1156)) )
fprintf(
out,
"Listening for connections on %s:%d\n",
(const char *)(unsigned int)((_DWORD)config + 1156),
(unsigned int)config[288]);
v8 = (unsigned int)config[274];
if ( (int)v8 > 0 )
{
if ( add_listen(70LL, 4LL, v8, (unsigned int)((_DWORD)config + 113)) )
fprintf(
out,
"Listening for connections on %s:%d\n",
(const char *)(unsigned int)((_DWORD)config + 113),
(unsigned int)config[274]);
}
gotworkingcfg = 1;
v9 = (char *)(((_DWORD)&lastcfg + 8) & 0xFFFFFFF8);
lastcfg = *(_QWORD *)config;
*(_QWORD *)((char *)&lastcfg + 3308) = *(_QWORD *)&config[827];
result = ((unsigned int)(&lastcfg - (_UNKNOWN *)v9) + 3316) >> 3;
qmemcpy(v9, (char *)config - (&lastcfg - (_UNKNOWN *)v9), 8LL * (unsigned int)result);
return result;
}

original_code:
void check_config()
{
 int i;
  for(i = 0; setmap[i].var; i++)
  {
   if(setmap[i].type == 'i') {
    if(*(int*)setmap[i].memory == 0) {
     if(setmap[i].length == -1)
      { bad_config(i); return; }
     else
      *(int*)setmap[i].memory = setmap[i].length;
    }
    continue;
   }
   if(setmap[i].type == 's') {
    if(!(*(char*)setmap[i].memory)) {
     if(setmap[i].DEFAULT != ((void *)0))
      strcpy(setmap[i].memory, setmap[i].DEFAULT);
     else
      { bad_config(i); return; }
    }
    continue;
   }
  }
 config.float_step = (int)(config.float_thresh/2);
 config.float_step4 = 3 * config.float_step;
 if(config.oj_period < 300)
  config.oj_period = 300;
 config.dcc_listenip[15] = 0;
 mystrncpy(config.dcc_listenip, config.vhost, 16);
 kill_dcc_listen();
 disconnect_all_links("ERROR Config rehash");
 if(config.dcc_listenport > 0) {
  if(add_listen('D', 3, config.dcc_listenport, config.dcc_listenip)) {
   fprintf(out, "Listening for connections on %s:%d\n", config.dcc_listenip, config.dcc_listenport);
  }
 }
 if(config.linkport > 0) {
  if(add_listen('F', 4, config.linkport, config.vhost)) {
   fprintf(out, "Listening for connections on %s:%d\n", config.vhost, config.linkport);
  }
 }
 gotworkingcfg = 1;
 lastcfg = config;
 return;
}

canonical_original_code:
void check_config()
{
 int i;
  for(i = 0; setmap[i].var; i++)
  {
   if(setmap[i].type == 'i') {
    if(*(int *)setmap[i].memory == 0) {
     if(setmap[i].length == -1)
      { bad_config(i); return; }
     else
      *(int *)setmap[i].memory = setmap[i].length;
    }
    continue;
   }
   if(setmap[i].type == 's') {
    if(!(*(char *)setmap[i].memory)) {
     if(setmap[i].DEFAULT != ((void *)0))
      strcpy(setmap[i].memory, setmap[i].DEFAULT);
     else
      { bad_config(i); return; }
    }
    continue;
   }
  }
 config.float_step = (int)(config.float_thresh/2);
 config.float_step4 = 3 * config.float_step;
 if(config.oj_period < 300)
  config.oj_period = 300;
 config.dcc_listenip[15] = 0;
 mystrncpy(config.dcc_listenip, config.vhost, 16);
 kill_dcc_listen();
 disconnect_all_links("ERROR Config rehash");
 if(config.dcc_listenport > 0) {
  if(add_listen('D', 3, config.dcc_listenport, config.dcc_listenip)) {
   fprintf(out, "Listening for connections on %s:%d\n", config.dcc_listenip, config.dcc_listenport);
  }
 }
 if(config.linkport > 0) {
  if(add_listen('F', 4, config.linkport, config.vhost)) {
   fprintf(out, "Listening for connections on %s:%d\n", config.vhost, config.linkport);
  }
 }
 gotworkingcfg = 1;
 lastcfg = config;
 return;
}


decompiled_code:
__int64 __fastcall check_cmdstr(unsigned int a1, __int64 a2)
{
if ( (unsigned int)strmi(a2, "set") || (unsigned int)strmi(a2, "add") || (unsigned int)strmi(a2, "die") )
return 1LL;
syntax_err(a1, "Invalid command");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, __int64 a2)
{
if ( (unsigned int)strmi(a2, "set") || (unsigned int)strmi(a2, "add") || (unsigned int)strmi(a2, "die") )
return 1LL;
func0(a1, "Invalid command");
return 0LL;
}

original_code:
int check_cmdstr(int line, char *cmd)
{
 if(strmi(cmd, "set"))
  return 1;
 if(strmi(cmd, "add"))
  return 1;
 if(strmi(cmd, "die"))
  return 1;
 syntax_err(line, "Invalid command");
 return 0;
}

return_type: int


decompiled_code:
__int64 __fastcall attempt_reload_conf(char *filename)
{
reset_linklines();
wipe_ojdata();
kill_servers();
reset_badurls();
load_config(filename);
return check_config();
}

canonical_decompiled_code:
__int64 __fastcall func7(char *filename)
{
reset_linklines();
wipe_ojdata();
kill_servers();
reset_badurls();
func6(filename);
return func4();
}

original_code:
void attempt_reload_conf(char *filename)
{
 reset_linklines();
 wipe_ojdata();
 kill_servers();
 reset_badurls();
 load_config(filename);
 check_config();
 return;
}

variable_types:
filename
char *


decompiled_code:
__int64 __fastcall send_hreply(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( a2 )
result = sockwrite(a2, a1);
else
result = highMsg(a1);
return result;
}

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

if ( a2 )
result = sockwrite(a2, a1);
else
result = highMsg(a1);
return result;
}

original_code:
void send_hreply(char *reply, struct socket *dcc)
{
 if(dcc == ((void *)0)) {
  highMsg(reply);
 } else {
  sockwrite(dcc, reply);
 }
}

variable_types:
reply
char *

variable_types: struct socket { char type; char status; int id; int fd; int last_ts; int con_ts; char checkLink; char buffer[4096]; struct socket *next; } *


showFlags

decompiled_code:
__int64 __fastcall showFlags(const char *a1, __int64 a2)
{
char v3[536]; // [rsp+0h] [rbp-218h] BYREF

if ( a2 )
prefix = 0;
else
snprintf(&prefix, 0x7FuLL, "NOTICE %s :", a1);
sprintf(v3, "%s-- Channel flags --", &prefix);
send_hreply((__int64)v3, a2);
sprintf(
v3,
"%sj = join, e = enforcebans, a = scan channel for automatic logins, o = kick ops, k = kickclones, I = idledeop",
&prefix);
send_hreply((__int64)v3, a2);
sprintf(
v3,
"%sA = op admins, B = bitchmode, l = dynamic limiting, b = no bad urls, c = no colours, m = no offensive masks",
&prefix);
send_hreply((__int64)v3, a2);
sprintf(
v3,
"%sf = flood protection, i = no chanctcp's, h = no lamehosts, n = no chan notices, p = no CAPS, y = joinflood",
&prefix);
send_hreply((__int64)v3, a2);
sprintf(
v3,
"%sr = no repeating, s = no swearing, t = no excessive ctrl chars, x = no repeatchars, z = nickflood, d = onjoin",
&prefix);
return send_hreply((__int64)v3, a2);
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1, __int64 a2)
{
char v3[536]; // [rsp+0h] [rbp-218h] BYREF

if ( a2 )
prefix = 0;
else
snprintf(&prefix, 0x7FuLL, "NOTICE %s :", a1);
sprintf(v3, "%s-- Channel flags --", &prefix);
func0((__int64)v3, a2);
sprintf(
v3,
"%sj = join, e = enforcebans, a = scan channel for automatic logins, o = kick ops, k = kickclones, I = idledeop",
&prefix);
func0((__int64)v3, a2);
sprintf(
v3,
"%sA = op admins, B = bitchmode, l = dynamic limiting, b = no bad urls, c = no colours, m = no offensive masks",
&prefix);
func0((__int64)v3, a2);
sprintf(
v3,
"%sf = flood protection, i = no chanctcp's, h = no lamehosts, n = no chan notices, p = no CAPS, y = joinflood",
&prefix);
func0((__int64)v3, a2);
sprintf(
v3,
"%sr = no repeating, s = no swearing, t = no excessive ctrl chars, x = no repeatchars, z = nickflood, d = onjoin",
&prefix);
return func0((__int64)v3, a2);
}

original_code:
void showFlags(sUser *theUser, struct socket *dcc)
{
 char bh[513];
 if(!dcc)
  snprintf(prefix, 127, "NOTICE %s :", theUser->nick);
 else
  prefix[0] = 0;
 sprintf(bh, "%s-- Channel flags --", prefix);
 send_hreply(bh, dcc);
 sprintf(bh, "%sj = join, e = enforcebans, a = scan channel for automatic logins, o = kick ops, k = kickclones, I = idledeop", prefix);
 send_hreply(bh, dcc);
 sprintf(bh, "%sA = op admins, B = bitchmode, l = dynamic limiting, b = no bad urls, c = no colours, m = no offensive masks", prefix);
 send_hreply(bh, dcc);
 sprintf(bh, "%sf = flood protection, i = no chanctcp's, h = no lamehosts, n = no chan notices, p = no CAPS, y = joinflood", prefix);
 send_hreply(bh, dcc);
 sprintf(bh, "%sr = no repeating, s = no swearing, t = no excessive ctrl chars, x = no repeatchars, z = nickflood, d = onjoin", prefix);
 send_hreply(bh, dcc);
}

canonical_original_code:
void showFlags(struct ircUser *theUser, struct socket *dcc)
{
 char bh[513];
 if(!dcc)
  snprintf(prefix, 127, "NOTICE %s :", theUser->nick);
 else
  prefix[0] = 0;
 sprintf(bh, "%s-- Channel flags --", prefix);
 send_hreply(bh, dcc);
 sprintf(bh, "%sj = join, e = enforcebans, a = scan channel for automatic logins, o = kick ops, k = kickclones, I = idledeop", prefix);
 send_hreply(bh, dcc);
 sprintf(bh, "%sA = op admins, B = bitchmode, l = dynamic limiting, b = no bad urls, c = no colours, m = no offensive masks", prefix);
 send_hreply(bh, dcc);
 sprintf(bh, "%sf = flood protection, i = no chanctcp's, h = no lamehosts, n = no chan notices, p = no CAPS, y = joinflood", prefix);
 send_hreply(bh, dcc);
 sprintf(bh, "%sr = no repeating, s = no swearing, t = no excessive ctrl chars, x = no repeatchars, z = nickflood, d = onjoin", prefix);
 send_hreply(bh, dcc);
}

variable_types: struct ircUser { char nick[33]; char ident[33]; char host[256]; char mask[512]; char gnuUser[32]; } *

variable_types:
bh
char [513]

user_defined_types: struct socket { char type; char status; int id; int fd; int last_ts; int con_ts; char checkLink; char buffer[4096]; struct socket *next; }


cmdList

decompiled_code:
__int64 __fastcall cmdList(const char *a1, __int64 a2)
{
char v3[536]; // [rsp+0h] [rbp-218h] BYREF

if ( a2 )
prefix = 0;
else
snprintf(&prefix, 0x7FuLL, "NOTICE %s :", a1);
sprintf(v3, "%s500: deladmin newadmin raw rehash shutdown", &prefix);
send_hreply((__int64)v3, a2);
sprintf(v3, "%s400: delchan hop me newchan say setflags", &prefix);
send_hreply((__int64)v3, a2);
sprintf(v3, "%s100: kick ban connect realnameban unban mode setkey setgoodmodes setbadmodes invite op deop", &prefix);
send_hreply((__int64)v3, a2);
sprintf(
v3,
"%s*: boot chaninfo commands criminalstats devoice namescan newpass linktree listbans listchans listlinks socketsstat"
"us transfer who whoami voice",
&prefix);
return send_hreply((__int64)v3, a2);
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, __int64 a2)
{
char v3[536]; // [rsp+0h] [rbp-218h] BYREF

if ( a2 )
prefix = 0;
else
snprintf(&prefix, 0x7FuLL, "NOTICE %s :", a1);
sprintf(v3, "%s500: deladmin newadmin raw rehash shutdown", &prefix);
func0((__int64)v3, a2);
sprintf(v3, "%s400: delchan hop me newchan say setflags", &prefix);
func0((__int64)v3, a2);
sprintf(v3, "%s100: kick ban connect realnameban unban mode setkey setgoodmodes setbadmodes invite op deop", &prefix);
func0((__int64)v3, a2);
sprintf(
v3,
"%s*: boot chaninfo commands criminalstats devoice namescan newpass linktree listbans listchans listlinks socketsstat"
"us transfer who whoami voice",
&prefix);
return func0((__int64)v3, a2);
}

original_code:
void cmdList(sUser *theUser, struct socket *dcc)
{
 char bh[513];
 if(!dcc)
  snprintf(prefix, 127, "NOTICE %s :", theUser->nick);
 else
  prefix[0] = 0;
 sprintf(bh, "%s500: deladmin newadmin raw rehash shutdown", prefix); send_hreply(bh, dcc);
 sprintf(bh, "%s400: delchan hop me newchan say setflags", prefix); send_hreply(bh, dcc);
 sprintf(bh, "%s100: kick ban connect realnameban unban mode setkey setgoodmodes setbadmodes invite op deop", prefix); send_hreply(bh, dcc);
 sprintf(bh, "%s*: boot chaninfo commands criminalstats devoice namescan newpass linktree listbans listchans listlinks sockets" "status transfer who whoami voice", prefix); send_hreply(bh, dcc);
 return;
}

canonical_original_code:
void cmdList(struct ircUser *theUser, struct socket *dcc)
{
 char bh[513];
 if(!dcc)
  snprintf(prefix, 127, "NOTICE %s :", theUser->nick);
 else
  prefix[0] = 0;
 sprintf(bh, "%s500: deladmin newadmin raw rehash shutdown", prefix); send_hreply(bh, dcc);
 sprintf(bh, "%s400: delchan hop me newchan say setflags", prefix); send_hreply(bh, dcc);
 sprintf(bh, "%s100: kick ban connect realnameban unban mode setkey setgoodmodes setbadmodes invite op deop", prefix); send_hreply(bh, dcc);
 sprintf(bh, "%s*: boot chaninfo commands criminalstats devoice namescan newpass linktree listbans listchans listlinks sockets" "status transfer who whoami voice", prefix); send_hreply(bh, dcc);
 return;
}

user_defined_types: struct ircUser { char nick[33]; char ident[33]; char host[256]; char mask[512]; char gnuUser[32]; }


syntaxHelp

decompiled_code:
int __fastcall syntaxHelp(const char *a1, __int64 a2, __int64 a3)
{
int result; // eax
char v5[552]; // [rsp+0h] [rbp-228h] BYREF

if ( a3 )
prefix = 0;
else
snprintf(&prefix, 0x7FuLL, "NOTICE %s :", a1);
if ( !strcmp((const char *)a2, "newpass") )
{
result = sprintf(v5, "%sSyntax: newpass <password>", &prefix);
if ( v5[0] )
return send_hreply((__int64)v5, a3);
return result;
}
if ( !strcmp((const char *)a2, "deladmin") )
{
result = sprintf(v5, "%sSyntax: deladmin <username>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "newadmin") )
{
result = sprintf(v5, "%sSyntax: newadmin <username> <password> <level(1-500)>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "say") )
{
result = sprintf(v5, "%sSyntax: say <#channel> <message>", &prefix);
goto LABEL_32;
}
if ( *(_BYTE *)a2 == 109 && *(_BYTE *)(a2 + 1) == 101 && !*(_BYTE *)(a2 + 2) )
{
result = sprintf(v5, "%sSyntax: me <#channel> <message>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "action") )
{
result = sprintf(v5, "%sSyntax: action <#channel> <message>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "mode") )
{
result = sprintf(v5, "%sSyntax: mode <#channel> <modes> [arguments...]", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "unban") )
{
result = sprintf(v5, "%sSyntax: unban <#channel> <mask>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "ban") )
{
result = sprintf(v5, "%sSyntax: ban <#channel> <mask|nickname> <time>[w|d|h|m] [reason]", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "realnameban") )
{
result = sprintf(v5, "%sSyntax: realnameban <#channel> <mask> <time>[w|d|h|m] [reason]", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "setkey") )
{
result = sprintf(v5, "%sSyntax: setkey <#channel> <key>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "setbadmodes") )
{
result = sprintf(v5, "%sSyntax: setbadmodes <#channel> -[modes]", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "setgoodmodes") )
{
result = sprintf(v5, "%sSyntax: setgoodmodes <#channel> +[modes]", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "newchan") )
{
result = sprintf(v5, "%sSyntax: newchan <#channel>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "delchan") )
{
result = sprintf(v5, "%sSyntax: delchan <#channel>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "listbans") )
{
result = sprintf(v5, "%sSyntax: listbans <#channel> <mask>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "setflags") )
{
sprintf(v5, "%sSyntax: setflags <#channel> <+/-flags>", &prefix);
send_hreply((__int64)v5, a3);
result = sprintf(v5, "%sExample: setflags #foo +fo-rlmn", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "kick") )
{
result = sprintf(v5, "%sSyntax: kick <#channel> <nickname> [reason]", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "namescan") )
{
result = sprintf(v5, "%sSyntax: namescan <#channel> <mask>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "invite") )
{
result = sprintf(v5, "%sSyntax: invite <#channel>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "chaninfo") )
{
result = sprintf(v5, "%sSyntax: chaninfo <#channel>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "boot") )
{
sprintf(v5, "%sSyntax: boot <id>", &prefix);
send_hreply((__int64)v5, a3);
result = sprintf(v5, "%sUse 'who' to find the 'id' of the user you want to boot.", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "connect") )
{
result = sprintf(v5, "%sSyntax: connect <mask>", &prefix);
LABEL_32:
if ( !v5[0] )
return result;
return send_hreply((__int64)v5, a3);
}
if ( !strcmp((const char *)a2, "op")
|| !strcmp((const char *)a2, "deop")
|| !strcmp((const char *)a2, "voice")
|| (result = strcmp((const char *)a2, "devoice")) == 0 )
{
result = sprintf(v5, "%sSyntax: %s <#channel> [users]", &prefix, (const char *)a2);
goto LABEL_32;
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(const char *a1, __int64 a2, __int64 a3)
{
int result; // eax
char v5[552]; // [rsp+0h] [rbp-228h] BYREF

if ( a3 )
prefix = 0;
else
snprintf(&prefix, 0x7FuLL, "NOTICE %s :", a1);
if ( !strcmp((const char *)a2, "newpass") )
{
result = sprintf(v5, "%sSyntax: newpass <password>", &prefix);
if ( v5[0] )
return func0((__int64)v5, a3);
return result;
}
if ( !strcmp((const char *)a2, "deladmin") )
{
result = sprintf(v5, "%sSyntax: deladmin <username>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "newadmin") )
{
result = sprintf(v5, "%sSyntax: newadmin <username> <password> <level(1-500)>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "say") )
{
result = sprintf(v5, "%sSyntax: say <#channel> <message>", &prefix);
goto LABEL_32;
}
if ( *(_BYTE *)a2 == 109 && *(_BYTE *)(a2 + 1) == 101 && !*(_BYTE *)(a2 + 2) )
{
result = sprintf(v5, "%sSyntax: me <#channel> <message>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "action") )
{
result = sprintf(v5, "%sSyntax: action <#channel> <message>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "mode") )
{
result = sprintf(v5, "%sSyntax: mode <#channel> <modes> [arguments...]", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "unban") )
{
result = sprintf(v5, "%sSyntax: unban <#channel> <mask>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "ban") )
{
result = sprintf(v5, "%sSyntax: ban <#channel> <mask|nickname> <time>[w|d|h|m] [reason]", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "realnameban") )
{
result = sprintf(v5, "%sSyntax: realnameban <#channel> <mask> <time>[w|d|h|m] [reason]", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "setkey") )
{
result = sprintf(v5, "%sSyntax: setkey <#channel> <key>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "setbadmodes") )
{
result = sprintf(v5, "%sSyntax: setbadmodes <#channel> -[modes]", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "setgoodmodes") )
{
result = sprintf(v5, "%sSyntax: setgoodmodes <#channel> +[modes]", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "newchan") )
{
result = sprintf(v5, "%sSyntax: newchan <#channel>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "delchan") )
{
result = sprintf(v5, "%sSyntax: delchan <#channel>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "listbans") )
{
result = sprintf(v5, "%sSyntax: listbans <#channel> <mask>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "setflags") )
{
sprintf(v5, "%sSyntax: setflags <#channel> <+/-flags>", &prefix);
func0((__int64)v5, a3);
result = sprintf(v5, "%sExample: setflags #foo +fo-rlmn", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "kick") )
{
result = sprintf(v5, "%sSyntax: kick <#channel> <nickname> [reason]", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "namescan") )
{
result = sprintf(v5, "%sSyntax: namescan <#channel> <mask>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "invite") )
{
result = sprintf(v5, "%sSyntax: invite <#channel>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "chaninfo") )
{
result = sprintf(v5, "%sSyntax: chaninfo <#channel>", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "boot") )
{
sprintf(v5, "%sSyntax: boot <id>", &prefix);
func0((__int64)v5, a3);
result = sprintf(v5, "%sUse 'who' to find the 'id' of the user you want to boot.", &prefix);
goto LABEL_32;
}
if ( !strcmp((const char *)a2, "connect") )
{
result = sprintf(v5, "%sSyntax: connect <mask>", &prefix);
LABEL_32:
if ( !v5[0] )
return result;
return func0((__int64)v5, a3);
}
if ( !strcmp((const char *)a2, "op")
|| !strcmp((const char *)a2, "deop")
|| !strcmp((const char *)a2, "voice")
|| (result = strcmp((const char *)a2, "devoice")) == 0 )
{
result = sprintf(v5, "%sSyntax: %s <#channel> [users]", &prefix, (const char *)a2);
goto LABEL_32;
}
return result;
}

original_code:
void syntaxHelp(sUser *theUser, char *cmd, struct socket *dcc)
{
 char bh[513];
 if(!dcc)
  snprintf(prefix, 127, "NOTICE %s :", theUser->nick);
 else
  prefix[0] = 0;
 if(!strcmp(cmd, "newpass"))
  sprintf(bh, "%sSyntax: newpass <password>", prefix);
 else
 if(!strcmp(cmd, "deladmin"))
  sprintf(bh, "%sSyntax: deladmin <username>", prefix);
 else
 if(!strcmp(cmd, "newadmin"))
  sprintf(bh, "%sSyntax: newadmin <username> <password> <level(1-500)>", prefix);
 else
 if(!strcmp(cmd, "say"))
  sprintf(bh, "%sSyntax: say <#channel> <message>", prefix);
 else
 if(!strcmp(cmd, "me"))
  sprintf(bh, "%sSyntax: me <#channel> <message>", prefix);
 else
 if(!strcmp(cmd, "action"))
  sprintf(bh, "%sSyntax: action <#channel> <message>", prefix);
 else
 if(!strcmp(cmd, "mode"))
  sprintf(bh, "%sSyntax: mode <#channel> <modes> [arguments...]", prefix);
 else
 if(!strcmp(cmd, "unban"))
  sprintf(bh, "%sSyntax: unban <#channel> <mask>", prefix);
 else
 if(!strcmp(cmd, "ban"))
  sprintf(bh, "%sSyntax: ban <#channel> <mask|nickname> <time>[w|d|h|m] [reason]", prefix);
 else
 if(!strcmp(cmd, "realnameban"))
  sprintf(bh, "%sSyntax: realnameban <#channel> <mask> <time>[w|d|h|m] [reason]", prefix);
 else
 if(!strcmp(cmd, "setkey"))
  sprintf(bh, "%sSyntax: setkey <#channel> <key>", prefix);
 else
 if(!strcmp(cmd, "setbadmodes"))
  sprintf(bh, "%sSyntax: setbadmodes <#channel> -[modes]", prefix);
 else
 if(!strcmp(cmd, "setgoodmodes"))
  sprintf(bh, "%sSyntax: setgoodmodes <#channel> +[modes]", prefix);
 else
 if(!strcmp(cmd, "newchan"))
  sprintf(bh, "%sSyntax: newchan <#channel>", prefix);
 else
 if(!strcmp(cmd, "delchan"))
  sprintf(bh, "%sSyntax: delchan <#channel>", prefix);
 else
 if(!strcmp(cmd, "listbans"))
  sprintf(bh, "%sSyntax: listbans <#channel> <mask>", prefix);
 else
 if(!strcmp(cmd, "setflags")) {
  sprintf(bh, "%sSyntax: setflags <#channel> <+/-flags>", prefix); send_hreply(bh, dcc);
  sprintf(bh, "%sExample: setflags #foo +fo-rlmn", prefix);
 }
 else
 if(!strcmp(cmd, "kick"))
  sprintf(bh, "%sSyntax: kick <#channel> <nickname> [reason]", prefix);
 else
 if(!strcmp(cmd, "namescan"))
  sprintf(bh, "%sSyntax: namescan <#channel> <mask>", prefix);
 else
 if(!strcmp(cmd, "invite"))
  sprintf(bh, "%sSyntax: invite <#channel>", prefix);
 else
 if(!strcmp(cmd, "chaninfo"))
  sprintf(bh, "%sSyntax: chaninfo <#channel>", prefix);
 else
 if(!strcmp(cmd, "boot")) {
  sprintf(bh, "%sSyntax: boot <id>", prefix); send_hreply(bh, dcc);
  sprintf(bh, "%sUse 'who' to find the 'id' of the user you want to boot.", prefix);
 }
 else
 if(!strcmp(cmd, "connect")) {
  sprintf(bh, "%sSyntax: connect <mask>", prefix);
 }
 else
 if(!strcmp(cmd, "op") || !strcmp(cmd, "deop") || !strcmp(cmd, "voice") || !strcmp(cmd, "devoice")) {
  sprintf(bh, "%sSyntax: %s <#channel> [users]", prefix, cmd);
 } else {
  bh[0] = 0;
 }
 if(bh[0] != 0)
  send_hreply(bh, dcc);
 return;
}

canonical_original_code:
void syntaxHelp(struct ircUser *theUser, char *cmd, struct socket *dcc)
{
 char bh[513];
 if(!dcc)
  snprintf(prefix, 127, "NOTICE %s :", theUser->nick);
 else
  prefix[0] = 0;
 if(!strcmp(cmd, "newpass"))
  sprintf(bh, "%sSyntax: newpass <password>", prefix);
 else
 if(!strcmp(cmd, "deladmin"))
  sprintf(bh, "%sSyntax: deladmin <username>", prefix);
 else
 if(!strcmp(cmd, "newadmin"))
  sprintf(bh, "%sSyntax: newadmin <username> <password> <level(1-500)>", prefix);
 else
 if(!strcmp(cmd, "say"))
  sprintf(bh, "%sSyntax: say <#channel> <message>", prefix);
 else
 if(!strcmp(cmd, "me"))
  sprintf(bh, "%sSyntax: me <#channel> <message>", prefix);
 else
 if(!strcmp(cmd, "action"))
  sprintf(bh, "%sSyntax: action <#channel> <message>", prefix);
 else
 if(!strcmp(cmd, "mode"))
  sprintf(bh, "%sSyntax: mode <#channel> <modes> [arguments...]", prefix);
 else
 if(!strcmp(cmd, "unban"))
  sprintf(bh, "%sSyntax: unban <#channel> <mask>", prefix);
 else
 if(!strcmp(cmd, "ban"))
  sprintf(bh, "%sSyntax: ban <#channel> <mask|nickname> <time>[w|d|h|m] [reason]", prefix);
 else
 if(!strcmp(cmd, "realnameban"))
  sprintf(bh, "%sSyntax: realnameban <#channel> <mask> <time>[w|d|h|m] [reason]", prefix);
 else
 if(!strcmp(cmd, "setkey"))
  sprintf(bh, "%sSyntax: setkey <#channel> <key>", prefix);
 else
 if(!strcmp(cmd, "setbadmodes"))
  sprintf(bh, "%sSyntax: setbadmodes <#channel> -[modes]", prefix);
 else
 if(!strcmp(cmd, "setgoodmodes"))
  sprintf(bh, "%sSyntax: setgoodmodes <#channel> +[modes]", prefix);
 else
 if(!strcmp(cmd, "newchan"))
  sprintf(bh, "%sSyntax: newchan <#channel>", prefix);
 else
 if(!strcmp(cmd, "delchan"))
  sprintf(bh, "%sSyntax: delchan <#channel>", prefix);
 else
 if(!strcmp(cmd, "listbans"))
  sprintf(bh, "%sSyntax: listbans <#channel> <mask>", prefix);
 else
 if(!strcmp(cmd, "setflags")) {
  sprintf(bh, "%sSyntax: setflags <#channel> <+/-flags>", prefix); send_hreply(bh, dcc);
  sprintf(bh, "%sExample: setflags #foo +fo-rlmn", prefix);
 }
 else
 if(!strcmp(cmd, "kick"))
  sprintf(bh, "%sSyntax: kick <#channel> <nickname> [reason]", prefix);
 else
 if(!strcmp(cmd, "namescan"))
  sprintf(bh, "%sSyntax: namescan <#channel> <mask>", prefix);
 else
 if(!strcmp(cmd, "invite"))
  sprintf(bh, "%sSyntax: invite <#channel>", prefix);
 else
 if(!strcmp(cmd, "chaninfo"))
  sprintf(bh, "%sSyntax: chaninfo <#channel>", prefix);
 else
 if(!strcmp(cmd, "boot")) {
  sprintf(bh, "%sSyntax: boot <id>", prefix); send_hreply(bh, dcc);
  sprintf(bh, "%sUse 'who' to find the 'id' of the user you want to boot.", prefix);
 }
 else
 if(!strcmp(cmd, "connect")) {
  sprintf(bh, "%sSyntax: connect <mask>", prefix);
 }
 else
 if(!strcmp(cmd, "op") || !strcmp(cmd, "deop") || !strcmp(cmd, "voice") || !strcmp(cmd, "devoice")) {
  sprintf(bh, "%sSyntax: %s <#channel> [users]", prefix, cmd);
 } else {
  bh[0] = 0;
 }
 if(bh[0] != 0)
  send_hreply(bh, dcc);
 return;
}


mainHelp

decompiled_code:
int __fastcall mainHelp(const char *a1, const char *a2, __int64 a3)
{
size_t v4; // rbx
int result; // eax
char v6[568]; // [rsp+0h] [rbp-238h] BYREF

v4 = 0LL;
if ( a2 )
{
while ( strlen(a2) > v4 )
{
a2[v4] = (*_ctype_tolower_loc())[a2[v4]];
++v4;
}
result = syntaxHelp(a1, (__int64)a2, a3);
}
else
{
if ( a3 )
prefix = 0;
else
snprintf(&prefix, 0x7FuLL, "NOTICE %s :", a1);
sprintf(v6, "%sFor a list of commands type 'commands'.", &prefix);
send_hreply((__int64)v6, a3);
sprintf(v6, "%sFor a list of the different channel flags, type 'showflags'.", &prefix);
send_hreply((__int64)v6, a3);
sprintf(v6, "%sSee the docs for more detail.", &prefix);
result = send_hreply((__int64)v6, a3);
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(const char *a1, const char *a2, __int64 a3)
{
size_t v4; // rbx
int result; // eax
char v6[568]; // [rsp+0h] [rbp-238h] BYREF

v4 = 0LL;
if ( a2 )
{
while ( strlen(a2) > v4 )
{
a2[v4] = (*_ctype_tolower_loc())[a2[v4]];
++v4;
}
result = func3(a1, (__int64)a2, a3);
}
else
{
if ( a3 )
prefix = 0;
else
snprintf(&prefix, 0x7FuLL, "NOTICE %s :", a1);
sprintf(v6, "%sFor a list of commands type 'commands'.", &prefix);
func0((__int64)v6, a3);
sprintf(v6, "%sFor a list of the different channel flags, type 'showflags'.", &prefix);
func0((__int64)v6, a3);
sprintf(v6, "%sSee the docs for more detail.", &prefix);
result = func0((__int64)v6, a3);
}
return result;
}

original_code:
void mainHelp(sUser *theUser, char *tok2, struct socket *dcc)
{
 char bh[513];
 int i;
 if(tok2) {
  for(i = 0; i < strlen(tok2); i++)
   tok2[i] = tolower(tok2[i]);
  syntaxHelp(theUser, tok2, dcc);
  return;
 }
 if(!dcc)
  snprintf(prefix, 127, "NOTICE %s :", theUser->nick);
 else
  prefix[0] = 0;
 sprintf(bh, "%sFor a list of commands type 'commands'.", prefix); send_hreply(bh, dcc);
 sprintf(bh, "%sFor a list of the different channel flags, type 'showflags'.", prefix); send_hreply(bh, dcc);
 sprintf(bh, "%sSee the docs for more detail.", prefix); send_hreply(bh, dcc);
 return;
}

canonical_original_code:
void mainHelp(struct ircUser *theUser, char *tok2, struct socket *dcc)
{
 char bh[513];
 int i;
 if(tok2) {
  for(i = 0; i < strlen(tok2); i++)
   tok2[i] = tolower(tok2[i]);
  syntaxHelp(theUser, tok2, dcc);
  return;
 }
 if(!dcc)
  snprintf(prefix, 127, "NOTICE %s :", theUser->nick);
 else
  prefix[0] = 0;
 sprintf(bh, "%sFor a list of commands type 'commands'.", prefix); send_hreply(bh, dcc);
 sprintf(bh, "%sFor a list of the different channel flags, type 'showflags'.", prefix); send_hreply(bh, dcc);
 sprintf(bh, "%sSee the docs for more detail.", prefix); send_hreply(bh, dcc);
 return;
}


decompiled_code:
__int64 __fastcall chan_has_rn_bans(__int64 a1)
{
__int64 result; // rax

result = *(_QWORD *)(a1 + 184);
if ( !result )
return 0LL;
while ( *(_BYTE *)(result + 16) != 114 )
{
result = *(_QWORD *)(result + 40);
if ( !result )
return result;
}
return 1LL;
}

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

result = *(_QWORD *)(a1 + 184);
if ( !result )
return 0LL;
while ( *(_BYTE *)(result + 16) != 114 )
{
result = *(_QWORD *)(result + 40);
if ( !result )
return result;
}
return 1LL;
}

original_code:
int chan_has_rn_bans(struct chanRec *theChan)
{
 struct softBan *i;
 i = theChan->softbans;
 while(i)
 {
  if(i->type == 'r')
   return 1;
  i = i->next;
 }
 return 0;
}

variable_types: struct chanRec { char *name; char flags[-1]; char key[-1]; char goodModes[-1]; char badModes[-1]; struct schan { char *name; char topic[-1]; char modes[-1]; char key[-1]; int limit; int tsLim; struct criminalRecord { char nick[33]; char *identhost; char longTerm; char shortTerm; int laststamp; int lastJoin; int njoins; struct repeat { int id; int ts; char count; } trackrepeat[30]; struct criminalRecord *prev; struct criminalRecord *next; } *nortyusers; struct sban { char *mask; char *setby; int ts; struct sban *next; struct sban *prev; } *bans; struct suser { char nick[33]; char *ident; char *host; char *mask; char *realname; char isVoice; char isOp; int lastMsg; int flines; int joinTime; int nickchanges; int lastNick; int idleMsg; struct suser *next; struct suser *prev; } *user; int userSize; int banSize; int flood_last; int flood_lines; struct schan *next; struct schan *prev; struct chanRec *record; } *physical; struct softBan { char *banmask; char *reason; char type; char *setby; int expires; struct softBan *next; struct softBan *prev; } *softbans; struct chanRec *next; struct chanRec *prev; } *

user_defined_types: struct chanRec { char *name; char flags[-1]; char key[-1]; char goodModes[-1]; char badModes[-1]; struct schan *physical; struct softBan *softbans; struct chanRec *next; struct chanRec *prev; }

user_defined_types: struct schan { char *name; char topic[-1]; char modes[-1]; char key[-1]; int limit; int tsLim; struct criminalRecord *nortyusers; struct sban *bans; struct suser *user; int userSize; int banSize; int flood_last; int flood_lines; struct schan *next; struct schan *prev; struct chanRec *record; }

user_defined_types: struct criminalRecord { char nick[33]; char *identhost; char longTerm; char shortTerm; int laststamp; int lastJoin; int njoins; struct repeat trackrepeat[30]; struct criminalRecord *prev; struct criminalRecord *next; }


makeBanSpace

decompiled_code:
void __fastcall makeBanSpace(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx
unsigned int i; // ebp
size_t v4; // rax
char v5[568]; // [rsp+0h] [rbp-238h] BYREF

v5[0] = 0;
if ( a1 && (signed int)(a2 + *(_DWORD *)(a1 + 644)) > config[252] )
{
v2 = *(_QWORD *)(a1 + 624);
if ( v2 )
{
for ( i = a2; i; --i )
{
v4 = strlen(v5);
*(_WORD *)&v5[v4] = 32;
strcpy(&v5[v4 + 1], *(const char **)v2);
v2 = *(_QWORD *)(v2 + 24);
if ( !v2 )
break;
}
}
unsetBans(a1, a2, v5);
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx
unsigned int i; // ebp
size_t v4; // rax
char v5[568]; // [rsp+0h] [rbp-238h] BYREF

v5[0] = 0;
if ( a1 && (signed int)(a2 + *(_DWORD *)(a1 + 644)) > config[252] )
{
v2 = *(_QWORD *)(a1 + 624);
if ( v2 )
{
for ( i = a2; i; --i )
{
v4 = strlen(v5);
*(_WORD *)&v5[v4] = 32;
strcpy(&v5[v4 + 1], *(const char **)v2);
v2 = *(_QWORD *)(v2 + 24);
if ( !v2 )
break;
}
}
unsetBans(a1, a2, v5);
}
}

original_code:
void makeBanSpace(struct schan *theChan, int space)
{
 int i;
 struct sban *b;
 char targs[513];
 targs[0] = 0;
 if(!theChan)
  return;
 if(theChan->banSize + space <= config.banlim)
  return;
 b = theChan->bans;
 i = space;
 while(b && i--)
 {
  strcat(targs, " ");
  strcat(targs, b->mask);
  b = b->next;
 }
 unsetBans(theChan, space, targs);
 return;
}

variable_types: struct schan { char *name; char topic[-1]; char modes[-1]; char key[-1]; int limit; int tsLim; struct criminalRecord { char nick[33]; char *identhost; char longTerm; char shortTerm; int laststamp; int lastJoin; int njoins; struct repeat { int id; int ts; char count; } trackrepeat[30]; struct criminalRecord *prev; struct criminalRecord *next; } *nortyusers; struct sban { char *mask; char *setby; int ts; struct sban *next; struct sban *prev; } *bans; struct suser { char nick[33]; char *ident; char *host; char *mask; char *realname; char isVoice; char isOp; int lastMsg; int flines; int joinTime; int nickchanges; int lastNick; int idleMsg; struct suser *next; struct suser *prev; } *user; int userSize; int banSize; int flood_last; int flood_lines; struct schan *next; struct schan *prev; struct chanRec { char *name; char flags[-1]; char key[-1]; char goodModes[-1]; char badModes[-1]; struct schan *physical; struct softBan { char *banmask; char *reason; char type; char *setby; int expires; struct softBan *next; struct softBan *prev; } *softbans; struct chanRec *next; struct chanRec *prev; } *record; } *

variable_types: space int

variable_types:
targs
char [513]


decompiled_code:
__int64 __fastcall normal_ban(_QWORD *a1, const char *a2, __int64 a3, int a4, __int64 a5)
{
unsigned int v7; // ebp

v7 = time(0LL) + a4;
if ( !a1[22] || !(unsigned int)br_add(*a1, a2, a5, 110LL, a3, v7) )
return 0xFFFFFFFFLL;
makeBanSpace(a1[22], 1u);
sprintf(banbuf, "MODE %s +b %s", (const char *)*a1, a2);
quickMsg(banbuf);
save_chans("chans.txt");
return enforce_ban(a1[22], a2, a5, a3, v7);
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, const char *a2, __int64 a3, int a4, __int64 a5)
{
unsigned int v7; // ebp

v7 = time(0LL) + a4;
if ( !a1[22] || !(unsigned int)br_add(*a1, a2, a5, 110LL, a3, v7) )
return 0xFFFFFFFFLL;
func1(a1[22], 1u);
sprintf(banbuf, "MODE %s +b %s", (const char *)*a1, a2);
quickMsg(banbuf);
save_chans("chans.txt");
return enforce_ban(a1[22], a2, a5, a3, v7);
}

original_code:
int normal_ban(struct chanRec *theChan, char *mask, char *setby, int secs, char *reason)
{
 secs += time(((void *)0));
 if(!theChan->physical)
  return -1;
 if(!br_add(theChan->name, mask, reason, 'n', setby, secs))
  return -1;
 makeBanSpace(theChan->physical, 1);
 sprintf(banbuf, "MODE %s +b %s", theChan->name, mask);
 quickMsg(banbuf);
 save_chans("chans.txt");
 return enforce_ban(theChan->physical, mask, reason, setby, secs);
}

variable_types:
mask
char *

variable_types:
setby
char *

variable_types: secs int

variable_types:
reason
char *

user_defined_types: struct softBan { char *banmask; char *reason; char type; char *setby; int expires; struct softBan *next; struct softBan *prev; }

user_defined_types: struct sban { char *mask; char *setby; int ts; struct sban *next; struct sban *prev; }

user_defined_types: struct suser { char nick[33]; char *ident; char *host; char *mask; char *realname; char isVoice; char isOp; int lastMsg; int flines; int joinTime; int nickchanges; int lastNick; int idleMsg; struct suser *next; struct suser *prev; }

user_defined_types: struct repeat { int id; int ts; char count; }


decompiled_code:
__int64 __fastcall rn_ban(const char *a1, __int64 a2, __int64 a3, int a4, __int64 a5)
{
int v6; // er12
__int64 v7; // rbp
__int64 v8; // r14
int v9; // eax
unsigned int v11; // [rsp+Ch] [rbp-4Ch]

v11 = a4 + time(0LL);
if ( *((_QWORD *)a1 + 22) && (unsigned int)br_add(*(_QWORD *)a1, a2, a5, 114LL, a3, v11) )
{
v6 = 0;
v7 = *(_QWORD *)(*((_QWORD *)a1 + 22) + 632LL);
while ( v7 )
{
v8 = *(_QWORD *)(v7 + 64);
if ( v8 && (!*(_BYTE *)(v7 + 73) || strchr(a1 + 8, 111)) && (unsigned int)wildicmp(a2, v8) )
{
makeBanSpace(*((_QWORD *)a1 + 22), v6 + 1);
sprintf(newmask, "*!*@%s", *(const char **)(v7 + 48));
br_add(*(_QWORD *)a1, newmask, a5, 100LL, a3, v11);
sprintf(banbuf, "MODE %s +b %s", *(const char **)a1, newmask);
quickMsg(banbuf);
v9 = enforce_ban(*((_QWORD *)a1 + 22), newmask, a5, a3, v11);
v7 = *(_QWORD *)(v7 + 104);
v6 += v9;
if ( config[256] <= v6 )
break;
}
else
{
v7 = *(_QWORD *)(v7 + 104);
if ( config[256] <= v6 )
break;
}
}
save_chans("chans.txt");
}
else
{
v6 = -1;
}
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1, __int64 a2, __int64 a3, int a4, __int64 a5)
{
int v6; // er12
__int64 v7; // rbp
__int64 v8; // r14
int v9; // eax
unsigned int v11; // [rsp+Ch] [rbp-4Ch]

v11 = a4 + time(0LL);
if ( *((_QWORD *)a1 + 22) && (unsigned int)br_add(*(_QWORD *)a1, a2, a5, 114LL, a3, v11) )
{
v6 = 0;
v7 = *(_QWORD *)(*((_QWORD *)a1 + 22) + 632LL);
while ( v7 )
{
v8 = *(_QWORD *)(v7 + 64);
if ( v8 && (!*(_BYTE *)(v7 + 73) || strchr(a1 + 8, 111)) && (unsigned int)wildicmp(a2, v8) )
{
func1(*((_QWORD *)a1 + 22), v6 + 1);
sprintf(newmask, "*!*@%s", *(const char **)(v7 + 48));
br_add(*(_QWORD *)a1, newmask, a5, 100LL, a3, v11);
sprintf(banbuf, "MODE %s +b %s", *(const char **)a1, newmask);
quickMsg(banbuf);
v9 = enforce_ban(*((_QWORD *)a1 + 22), newmask, a5, a3, v11);
v7 = *(_QWORD *)(v7 + 104);
v6 += v9;
if ( config[256] <= v6 )
break;
}
else
{
v7 = *(_QWORD *)(v7 + 104);
if ( config[256] <= v6 )
break;
}
}
save_chans("chans.txt");
}
else
{
v6 = -1;
}
return (unsigned int)v6;
}

original_code:
int rn_ban(struct chanRec *theChan, char *mask, char *setby, int secs, char *reason)
{
 int count;
 struct suser *i;
 secs += time(((void *)0));
 if(!theChan->physical)
  return -1;
 if(!br_add(theChan->name, mask, reason, 'r', setby, secs))
  return -1;
 i = theChan->physical->user;
 count = 0;
 while(i)
 {
  if(i->realname && (!i->isOp || strchr(theChan->flags, 'o')) )
   if(wildicmp(mask, i->realname))
   {
    makeBanSpace(theChan->physical, count + 1);
    sprintf(newmask, "*!*@%s", i->host);
    br_add(theChan->name, newmask, reason, 'd', setby, secs);
    sprintf(banbuf, "MODE %s +b %s", theChan->name, newmask);
    quickMsg(banbuf);
    count += enforce_ban(theChan->physical, newmask, reason, setby, secs);
   }
  i = i->next;
  if(count >= config.maxkicks)
   break;
 }
 save_chans("chans.txt");
 return count;
}

variable_types: count int

variable_types: struct suser { char nick[33]; char *ident; char *host; char *mask; char *realname; char isVoice; char isOp; int lastMsg; int flines; int joinTime; int nickchanges; int lastNick; int idleMsg; struct suser *next; struct suser *prev; } *


decompiled_code:
char *__fastcall chkfor_rn_ban(const char **a1, __int64 a2)
{
char *result; // rax
__int64 v3; // rbx
int v4; // er13

result = (char *)a1[84];
v3 = *((_QWORD *)result + 23);
if ( v3 )
{
v4 = 0;
do
{
while ( 1 )
{
if ( *(_BYTE *)(v3 + 16) == 114 )
{
result = (char *)wildicmp(*(_QWORD *)v3, *(_QWORD *)(a2 + 64));
if ( (_DWORD)result )
{
if ( !*(_BYTE *)(a2 + 73) )
break;
result = strchr(a1[84] + 8, 111);
if ( result )
break;
}
}
v3 = *(_QWORD *)(v3 + 40);
if ( !v3 )
goto LABEL_9;
}
makeBanSpace((__int64)a1, ++v4);
sprintf(newmask, "*!*@%s", *(const char **)(a2 + 48));
br_add(*a1, newmask, *(_QWORD *)(v3 + 8), 100LL, *(_QWORD *)(v3 + 24), *(unsigned int *)(v3 + 32));
sprintf(banbuf, "MODE %s +b %s", *a1, newmask);
quickMsg(banbuf);
result = (char *)enforce_ban(a1, newmask, *(_QWORD *)(v3 + 8), *(_QWORD *)(v3 + 24), *(unsigned int *)(v3 + 32));
v3 = *(_QWORD *)(v3 + 40);
}
while ( v3 );
LABEL_9:
if ( v4 )
result = (char *)save_chans("chans.txt");
}
return result;
}

canonical_decompiled_code:
char *__fastcall func4(const char **a1, __int64 a2)
{
char *result; // rax
__int64 v3; // rbx
int v4; // er13

result = (char *)a1[84];
v3 = *((_QWORD *)result + 23);
if ( v3 )
{
v4 = 0;
do
{
while ( 1 )
{
if ( *(_BYTE *)(v3 + 16) == 114 )
{
result = (char *)wildicmp(*(_QWORD *)v3, *(_QWORD *)(a2 + 64));
if ( (_DWORD)result )
{
if ( !*(_BYTE *)(a2 + 73) )
break;
result = strchr(a1[84] + 8, 111);
if ( result )
break;
}
}
v3 = *(_QWORD *)(v3 + 40);
if ( !v3 )
goto LABEL_9;
}
func1((__int64)a1, ++v4);
sprintf(newmask, "*!*@%s", *(const char **)(a2 + 48));
br_add(*a1, newmask, *(_QWORD *)(v3 + 8), 100LL, *(_QWORD *)(v3 + 24), *(unsigned int *)(v3 + 32));
sprintf(banbuf, "MODE %s +b %s", *a1, newmask);
quickMsg(banbuf);
result = (char *)enforce_ban(a1, newmask, *(_QWORD *)(v3 + 8), *(_QWORD *)(v3 + 24), *(unsigned int *)(v3 + 32));
v3 = *(_QWORD *)(v3 + 40);
}
while ( v3 );
LABEL_9:
if ( v4 )
result = (char *)save_chans("chans.txt");
}
return result;
}

original_code:
void chkfor_rn_ban(struct schan *theChan, struct suser *theUser)
{
 struct softBan *i;
 int count = 0;
 i = theChan->record->softbans;
 while(i)
 {
  if(i->type == 'r' && wildicmp(i->banmask, theUser->realname) && (!theUser->isOp || strchr(theChan->record->flags, 'o')))
  {
   makeBanSpace(theChan, count + 1);
   sprintf(newmask, "*!*@%s", theUser->host);
   br_add(theChan->name, newmask, i->reason, 'd', i->setby, i->expires);
   sprintf(banbuf, "MODE %s +b %s", theChan->name, newmask);
   quickMsg(banbuf);
   enforce_ban(theChan, newmask, i->reason, i->setby, i->expires);
   count++;
  }
  i = i->next;
 }
 if(count > 0)
  save_chans("chans.txt");
 return;
}

variable_types:
theUser
struct suser *

variable_types: struct softBan { char *banmask; char *reason; char type; char *setby; int expires; struct softBan *next; struct softBan *prev; } *


searchForMissedBans

decompiled_code:
__int64 __fastcall searchForMissedBans(__int64 a1)
{
__int64 i; // rbx
__int64 result; // rax

for ( i = *(_QWORD *)(a1 + 632); i; i = *(_QWORD *)(i + 104) )
{
result = chkfor_ban(a1, i);
if ( *(_QWORD *)(i + 64) )
result = (__int64)chkfor_rn_ban((const char **)a1, i);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 i; // rbx
__int64 result; // rax

for ( i = *(_QWORD *)(a1 + 632); i; i = *(_QWORD *)(i + 104) )
{
result = func5(a1, i);
if ( *(_QWORD *)(i + 64) )
result = (__int64)func4((const char **)a1, i);
}
return result;
}

original_code:
void searchForMissedBans(struct schan *theChan)
{
 struct suser *i;
 i = theChan->user;
 while(i)
 {
  chkfor_ban(theChan, i);
  if(i->realname)
   chkfor_rn_ban(theChan, i);
  i = i->next;
 }
 return;
}


isSoftBan

decompiled_code:
__int64 __fastcall isSoftBan(__int64 a1, const char *a2)
{
__int64 v2; // rbx

if ( !a1 )
return 0LL;
v2 = *(_QWORD *)(a1 + 184);
if ( !v2 )
return 0LL;
while ( strcmp(*(const char **)v2, a2) )
{
v2 = *(_QWORD *)(v2 + 40);
if ( !v2 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, const char *a2)
{
__int64 v2; // rbx

if ( !a1 )
return 0LL;
v2 = *(_QWORD *)(a1 + 184);
if ( !v2 )
return 0LL;
while ( strcmp(*(const char **)v2, a2) )
{
v2 = *(_QWORD *)(v2 + 40);
if ( !v2 )
return 0LL;
}
return 1LL;
}

original_code:
int isSoftBan(struct chanRec *c, char *mask)
{
 struct softBan *i;
 if(!c)
  return 0;
 i = c->softbans;
 while(i)
 {
  if(!strcmp(i->banmask, mask))
   return 1;
  i = i->next;
 }
 return 0;
}


isHardBan

decompiled_code:
__int64 __fastcall isHardBan(__int64 a1, const char *a2)
{
__int64 v2; // rbx

if ( !a1 )
return 0LL;
v2 = *(_QWORD *)(a1 + 624);
if ( !v2 )
return 0LL;
while ( strcmp(*(const char **)v2, a2) )
{
v2 = *(_QWORD *)(v2 + 24);
if ( !v2 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, const char *a2)
{
__int64 v2; // rbx

if ( !a1 )
return 0LL;
v2 = *(_QWORD *)(a1 + 624);
if ( !v2 )
return 0LL;
while ( strcmp(*(const char **)v2, a2) )
{
v2 = *(_QWORD *)(v2 + 24);
if ( !v2 )
return 0LL;
}
return 1LL;
}

original_code:
int isHardBan(struct schan *c, char *mask)
{
 struct sban *i;
 if(!c)
  return 0;
 i = c->bans;
 while(i)
 {
  if(!strcmp(i->mask, mask))
   return 1;
  i = i->next;
 }
 return 0;
}

variable_types: struct sban { char *mask; char *setby; int ts; struct sban *next; struct sban *prev; } *


expireBans

decompiled_code:
void expireBans()
{
__int64 v0; // r13
int v1; // er14
__int64 v2; // rdi
int v3; // er15
__int64 v4; // rdi
__int64 v5; // rbx
__int64 v6; // rbp
time_t v7; // r12
const char *v8; // r12
size_t v9; // rax
__int64 v10; // rsi
__int64 i; // rbx
size_t v12; // rax
__int64 v13; // rsi
time_t v14; // rbp
char dest[2]; // [rsp+0h] [rbp-248h] BYREF

v0 = chans[24];
if ( v0 )
{
v1 = 0;
while ( 1 )
{
v2 = *(_QWORD *)(v0 + 176);
if ( v2 )
{
v3 = isOp(v2, &cNick);
if ( v3 )
{
v4 = *(_QWORD *)(v0 + 176);
dest[0] = 0;
v3 = check_dependants(v4);
if ( !v3 )
{
for ( i = *(_QWORD *)(*(_QWORD *)(v0 + 176) + 624LL); i; dest[0] = 0 )
{
while ( 1 )
{
if ( !(unsigned int)isSoftBan(v0, *(const char **)i) )
{
if ( !strcmp(*(const char **)(i + 8), &cNick)
|| (int)config[297] > 0
&& (v14 = *(int *)(i + 16), v14 < time(0LL) - 3600 * config[297])
&& *(int *)(i + 16) > 0 )
{
++v3;
v12 = strlen(dest);
*(_WORD *)&dest[v12] = 32;
strcpy(&dest[v12 + 1], *(const char **)i);
if ( config[251] <= v3 )
break;
}
}
i = *(_QWORD *)(i + 24);
if ( !i )
goto LABEL_34;
}
v13 = (unsigned int)v3;
v3 = 0;
unsetBans(*(_QWORD *)(v0 + 176), v13, dest);
i = *(_QWORD *)(i + 24);
}
LABEL_34:
if ( strchr((const char *)(v0 + 8), 73) )
check_idle_ops(v0);
v5 = *(_QWORD *)(v0 + 184);
goto LABEL_12;
}
v5 = *(_QWORD *)(v0 + 184);
v3 = 0;
if ( v5 )
{
while ( 1 )
{
LABEL_7:
v6 = v5;
v5 = *(_QWORD *)(v5 + 40);
v7 = *(int *)(v6 + 32);
if ( v7 < time(0LL) )
{
++v1;
v8 = *(const char **)v6;
if ( *(_BYTE *)(v6 + 16) != 114
&& main_irc
&& (unsigned int)isHardBan(*(_QWORD *)(v0 + 176), *(const char **)v6) )
{
++v3;
v9 = strlen(dest);
*(_WORD *)&dest[v9] = 32;
strcpy(&dest[v9 + 1], *(const char **)v6);
if ( config[251] <= v3 )
{
v10 = (unsigned int)v3;
v3 = 0;
unsetBans(*(_QWORD *)(v0 + 176), v10, dest);
dest[0] = 0;
}
v8 = *(const char **)v6;
}
br_del(v0, v8);
}
LABEL_12:
if ( !v5 )
{
if ( v3 > 0 )
unsetBans(*(_QWORD *)(v0 + 176), (unsigned int)v3, dest);
break;
}
}
}
}
else
{
sprintf(dest, "OP %s %s %s", (const char *)(unsigned int)((_DWORD)config + 1100), &cNick, *(const char **)v0);
send_to_all_links(dest);
v5 = *(_QWORD *)(v0 + 184);
dest[0] = 0;
if ( v5 )
goto LABEL_7;
}
}
else
{
v5 = *(_QWORD *)(v0 + 184);
dest[0] = 0;
v3 = 0;
if ( v5 )
goto LABEL_7;
}
v0 = *(_QWORD *)(v0 + 192);
if ( !v0 )
{
if ( v1 )
save_chans("chans.txt");
return;
}
}
}
}

original_code:
void expireBans()
{
 char targs[513];
 struct chanRec *i;
 struct softBan *b, *d;
 struct sban *h;
 int mc, count, meOp;
 mc = count = 0;
 i = chans.next;
 while(i)
 {
  if(i->physical) {
   meOp = isOp(i->physical, cNick);
   if(!meOp) {
    sprintf(targs, "OP %s %s %s", config.linkname, cNick, i->name);
    send_to_all_links(targs);
   }
  } else {
   meOp = 0;
  }
  mc = 0;
  targs[0] = '\0';
  if(meOp && !check_dependants(i->physical))
  {
   h = i->physical->bans;
   while(h)
   {
    if(!isSoftBan(i, h->mask)) {
     if( !strcmp(h->setby, cNick) || (
      (config.cleanbanlist > 0) &&
      (h->ts < time(0) - (config.cleanbanlist*3600)) &&
      (h->ts > 0) )
       )
     {
      strcat(targs, " "); strcat(targs, h->mask);
      if(++mc >= config.maxmodes)
      {
       unsetBans(i->physical, mc, targs);
       mc = 0;
       targs[0] = '\0';
      }
     }
    }
    h = h->next;
   }
   if(strchr(i->flags, 'I'))
    check_idle_ops(i);
  }
  b = i->softbans;
  while(b)
  {
   d = b->next;
   if( (b->expires < time(((void *)0))) )
   {
    count++;
    if( (b->type != 'r') && main_irc && isHardBan(i->physical, b->banmask) )
    {
     strcat(targs, " "); strcat(targs, b->banmask);
     if(++mc >= config.maxmodes)
     {
      unsetBans(i->physical, mc, targs);
      mc = 0;
      targs[0] = '\0';
     }
    }
    br_del(i, b->banmask);
   }
   b = d;
  }
  if(mc > 0)
  {
   unsetBans(i->physical, mc, targs);
  }
  i = i->next;
 }
 if(count > 0)
  save_chans("chans.txt");
 return;
}

canonical_original_code:
void expireBans()
{
 char targs[513];
 struct chanRec *i;
 struct softBan *b; struct softBan *d;
 struct sban *h;
 int mc; int count; int meOp;
 mc = count = 0;
 i = chans.next;
 while(i)
 {
  if(i->physical) {
   meOp = isOp(i->physical, cNick);
   if(!meOp) {
    sprintf(targs, "OP %s %s %s", config.linkname, cNick, i->name);
    send_to_all_links(targs);
   }
  } else {
   meOp = 0;
  }
  mc = 0;
  targs[0] = '\0';
  if(meOp && !check_dependants(i->physical))
  {
   h = i->physical->bans;
   while(h)
   {
    if(!isSoftBan(i, h->mask)) {
     if( !strcmp(h->setby, cNick) || (
      (config.cleanbanlist > 0) &&
      (h->ts < time(0) - (config.cleanbanlist*3600)) &&
      (h->ts > 0) )
       )
     {
      strcat(targs, " "); strcat(targs, h->mask);
      if(++mc >= config.maxmodes)
      {
       unsetBans(i->physical, mc, targs);
       mc = 0;
       targs[0] = '\0';
      }
     }
    }
    h = h->next;
   }
   if(strchr(i->flags, 'I'))
    check_idle_ops(i);
  }
  b = i->softbans;
  while(b)
  {
   d = b->next;
   if( (b->expires < time(((void *)0))) )
   {
    count++;
    if( (b->type != 'r') && main_irc && isHardBan(i->physical, b->banmask) )
    {
     strcat(targs, " "); strcat(targs, b->banmask);
     if(++mc >= config.maxmodes)
     {
      unsetBans(i->physical, mc, targs);
      mc = 0;
      targs[0] = '\0';
     }
    }
    br_del(i, b->banmask);
   }
   b = d;
  }
  if(mc > 0)
  {
   unsetBans(i->physical, mc, targs);
  }
  i = i->next;
 }
 if(count > 0)
  save_chans("chans.txt");
 return;
}

variable_types: mc int

variable_types: meOp int


massMode

decompiled_code:
void __fastcall massMode(const char **a1, char a2, char a3, int a4, const char *a5)
{
size_t v8; // r13
char *v9; // rdi
char *v10; // rax

if ( a1 && a4 > 0 )
{
v8 = a4;
sprintf(taskbuf, "MODE %s %c", *a1, (unsigned int)a2);
v9 = &taskbuf[strlen(taskbuf)];
if ( a4 <= 0 )
v8 = 1LL;
v10 = (char *)memset(v9, a3, v8);
strcpy(&v10[v8], a5);
quickMsg(taskbuf);
}
}

canonical_decompiled_code:
void __fastcall func0(const char **a1, char a2, char a3, int a4, const char *a5)
{
size_t v8; // r13
char *v9; // rdi
char *v10; // rax

if ( a1 && a4 > 0 )
{
v8 = a4;
sprintf(taskbuf, "MODE %s %c", *a1, (unsigned int)a2);
v9 = &taskbuf[strlen(taskbuf)];
if ( a4 <= 0 )
v8 = 1LL;
v10 = (char *)memset(v9, a3, v8);
strcpy(&v10[v8], a5);
quickMsg(taskbuf);
}
}

original_code:
void massMode(struct schan *chan, char sign, char mode, int count, char *arguments)
{
 char *pch;
 int i;
 if(!chan || (count < 1))
  return;
 sprintf(taskbuf, "MODE %s %c", chan->name, sign);
 pch = taskbuf + strlen(taskbuf);
 for(i = 0; i < count; i++)
  *pch++ = mode;
 strcpy(pch, arguments);
 quickMsg(taskbuf);
 return;
}

variable_types: sign char

variable_types: mode char

variable_types:
arguments
char *

variable_types:
pch
char *

variable_types: i int


decompiled_code:
int __fastcall check_idle_ops(__int64 a1)
{
time_t v1; // rax
__int64 v2; // r12

v1 = *(_QWORD *)(a1 + 176);
if ( v1 )
{
v2 = *(_QWORD *)(v1 + 632);
if ( v2 )
{
while ( 1 )
{
if ( *(_BYTE *)(v2 + 73) || *(_BYTE *)(v2 + 72) && config[294] == 1 )
{
v1 = time(0LL) - *(int *)(v2 + 96);
if ( v1 > config[293] )
{
LODWORD(v1) = strcmp(&cNick, (const char *)v2);
if ( (_DWORD)v1 )
break;
}
}
v2 = *(_QWORD *)(v2 + 104);
if ( !v2 )
return v1;
}
sprintf(taskbuf, "WHOIS %s %s", (const char *)v2, (const char *)v2);
LODWORD(v1) = lowMsg(taskbuf);
}
}
return v1;
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1)
{
time_t v1; // rax
__int64 v2; // r12

v1 = *(_QWORD *)(a1 + 176);
if ( v1 )
{
v2 = *(_QWORD *)(v1 + 632);
if ( v2 )
{
while ( 1 )
{
if ( *(_BYTE *)(v2 + 73) || *(_BYTE *)(v2 + 72) && config[294] == 1 )
{
v1 = time(0LL) - *(int *)(v2 + 96);
if ( v1 > config[293] )
{
LODWORD(v1) = strcmp(&cNick, (const char *)v2);
if ( (_DWORD)v1 )
break;
}
}
v2 = *(_QWORD *)(v2 + 104);
if ( !v2 )
return v1;
}
sprintf(taskbuf, "WHOIS %s %s", (const char *)v2, (const char *)v2);
LODWORD(v1) = lowMsg(taskbuf);
}
}
return v1;
}

original_code:
void check_idle_ops(struct chanRec *theChan)
{
 struct suser *i;
 if(!theChan->physical)
  return;
 i = theChan->physical->user;
 while(i)
 {
  if( (i->isOp || (i->isVoice && config.idlevoice == 1)) &&
   (time(0) - i->idleMsg > config.idle_limit) &&
   strcmp(cNick, i->nick) )
  {
   sprintf(taskbuf, "WHOIS %s %s", i->nick, i->nick);
   lowMsg(taskbuf);
   return;
  }
  i = i->next;
 }
}

variable_types: struct chanRec { char *name; char flags[-1]; char key[-1]; char goodModes[-1]; char badModes[-1]; struct schan { char *name; char topic[-1]; char modes[-1]; char key[-1]; int limit; int tsLim; struct criminalRecord { char nick[33]; char *identhost; char longTerm; char shortTerm; int laststamp; int lastJoin; int njoins; struct repeat { int id; int ts; char count; } trackrepeat[30]; struct criminalRecord *prev; struct criminalRecord *next; } *nortyusers; struct sban { char *mask; char *setby; int ts; struct sban *next; struct sban *prev; } *bans; struct suser { char nick[33]; char *ident; char *host; char *mask; char *realname; char isVoice; char isOp; int lastMsg; int flines; int joinTime; int nickchanges; int lastNick; int idleMsg; struct suser *next; struct suser *prev; } *user; int userSize; int banSize; int flood_last; int flood_lines; struct schan *next; struct schan *prev; struct chanRec *record; } *physical; struct softBan { char *banmask; char *reason; char type; char *setby; int expires; struct softBan *next; struct softBan *prev; } *softbans; struct chanRec *next; struct chanRec *prev; } *


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

v2 = *(_QWORD *)(a1 + 632);
if ( !v2 )
return 0LL;
v3 = 0;
do
{
v4 = strcmp(a2, *(const char **)(v2 + 48));
v2 = *(_QWORD *)(v2 + 104);
v3 += v4 == 0;
}
while ( v2 );
return v3;
}

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

v2 = *(_QWORD *)(a1 + 632);
if ( !v2 )
return 0LL;
v3 = 0;
do
{
v4 = strcmp(a2, *(const char **)(v2 + 48));
v2 = *(_QWORD *)(v2 + 104);
v3 += v4 == 0;
}
while ( v2 );
return v3;
}

original_code:
int count_clones(struct schan *theChan, char *host)
{
 struct suser *i;
 int count = 0;
 i = theChan->user;
 while(i)
 {
  if(!strcmp(host, i->host))
   count++;
  i = i->next;
 }
 return count;
}

variable_types: struct schan { char *name; char topic[-1]; char modes[-1]; char key[-1]; int limit; int tsLim; struct criminalRecord { char nick[33]; char *identhost; char longTerm; char shortTerm; int laststamp; int lastJoin; int njoins; struct repeat { int id; int ts; char count; } trackrepeat[30]; struct criminalRecord *prev; struct criminalRecord *next; } *nortyusers; struct sban { char *mask; char *setby; int ts; struct sban *next; struct sban *prev; } *bans; struct suser { char nick[33]; char *ident; char *host; char *mask; char *realname; char isVoice; char isOp; int lastMsg; int flines; int joinTime; int nickchanges; int lastNick; int idleMsg; struct suser *next; struct suser *prev; } *user; int userSize; int banSize; int flood_last; int flood_lines; struct schan *next; struct schan *prev; struct chanRec { char *name; char flags[-1]; char key[-1]; char goodModes[-1]; char badModes[-1]; struct schan *physical; struct softBan { char *banmask; char *reason; char type; char *setby; int expires; struct softBan *next; struct softBan *prev; } *softbans; struct chanRec *next; struct chanRec *prev; } *record; } *

variable_types:
host
char *


original_code:
int enforce_ban(struct schan *theChan, char *mask, char *reason, char *setby, int expire)
{
 struct suser *i;
 struct suser **kicklist;
 char *wild, lmask[513], *pch;
 int iter, count = 0;
 if(check_dependants(theChan))
  return 0;
 kicklist = (struct suser **)myalloc(config.maxkicks * sizeof(struct suser*));
 wild = (char*)myalloc(strlen(mask)+1);
 for(iter = 0; iter <= strlen(mask); iter++)
  wild[iter] = tolower(mask[iter]);
 i = theChan->user;
 while(i)
 {
  if(!strcmp(i->nick, cNick))
  {
   if(!i->isOp)
   {
    free(wild);
    free(kicklist);
    return -1;
   }
  }
  pch = lmask;
  for(iter = 0; iter < strlen(i->nick); iter++)
   *pch++ = tolower((i->nick)[iter]);
  *pch++ = '!';
  for(iter = 0; iter < strlen(i->ident); iter++)
   *pch++ = tolower((i->ident)[iter]);
  *pch++ = '@';
  for(iter = 0; iter < strlen(i->host); iter++)
   *pch++ = tolower((i->host)[iter]);
  *pch++ = '\0';
  if(wildcmp(wild, lmask))
  {
   if(!strcmp(i->nick, cNick))
   {
    free(wild);
    sprintf(lmask, "MODE %s -b %s", theChan->name, mask);
    quickMsg(lmask);
    free(kicklist);
    return -2;
   }
   kicklist[count] = i;
   if(++count >= config.maxkicks)
    break;
  }
  i = i->next;
 }
 free(wild);
 for(iter = 0; iter < count; iter++)
 {
  sprintf(lmask, "KICK %s %s :[%d%s %s (%s)",
   theChan->name, (kicklist[iter])->nick, count, (count == config.maxkicks) ? "+]" : "]", reason, setby);
  if(expire > time(((void *)0))) {
   strcat(lmask, " Duration: ");
   strcat(lmask, small_duration(expire - time(((void *)0))) );
  }
  if(expire == -1)
   highMsg(lmask);
  else
   quickMsg(lmask);
 }
 free(kicklist);
 return count;
}

canonical_original_code:
int enforce_ban(struct schan *theChan, char *mask, char *reason, char *setby, int expire)
{
 struct suser *i;
 struct suser **kicklist;
 char *wild; char lmask[513]; char *pch;
 int iter; int count = 0;
 if(check_dependants(theChan))
  return 0;
 kicklist = (struct suser **)myalloc(config.maxkicks * sizeof(struct suser *));
 wild = (char *)myalloc(strlen(mask)+1);
 for(iter = 0; iter <= strlen(mask); iter++)
  wild[iter] = tolower(mask[iter]);
 i = theChan->user;
 while(i)
 {
  if(!strcmp(i->nick, cNick))
  {
   if(!i->isOp)
   {
    free(wild);
    free(kicklist);
    return -1;
   }
  }
  pch = lmask;
  for(iter = 0; iter < strlen(i->nick); iter++)
   *pch++ = tolower((i->nick)[iter]);
  *pch++ = '!';
  for(iter = 0; iter < strlen(i->ident); iter++)
   *pch++ = tolower((i->ident)[iter]);
  *pch++ = '@';
  for(iter = 0; iter < strlen(i->host); iter++)
   *pch++ = tolower((i->host)[iter]);
  *pch++ = '\0';
  if(wildcmp(wild, lmask))
  {
   if(!strcmp(i->nick, cNick))
   {
    free(wild);
    sprintf(lmask, "MODE %s -b %s", theChan->name, mask);
    quickMsg(lmask);
    free(kicklist);
    return -2;
   }
   kicklist[count] = i;
   if(++count >= config.maxkicks)
    break;
  }
  i = i->next;
 }
 free(wild);
 for(iter = 0; iter < count; iter++)
 {
  sprintf(lmask, "KICK %s %s :[%d%s %s (%s)",
   theChan->name, (kicklist[iter])->nick, count, (count == config.maxkicks) ? "+]" : "]", reason, setby);
  if(expire > time(((void *)0))) {
   strcat(lmask, " Duration: ");
   strcat(lmask, small_duration(expire - time(((void *)0))) );
  }
  if(expire == -1)
   highMsg(lmask);
  else
   quickMsg(lmask);
 }
 free(kicklist);
 return count;
}

variable_types:
mask
char *

variable_types:
setby
char *

variable_types: expire int

variable_types: struct suser { char nick[33]; char *ident; char *host; char *mask; char *realname; char isVoice; char isOp; int lastMsg; int flines; int joinTime; int nickchanges; int lastNick; int idleMsg; struct suser *next; struct suser *prev; } **

variable_types:
wild
char *

variable_types:
lmask
char [513]

variable_types: iter int


isOp

decompiled_code:
_BOOL8 __fastcall isOp(__int64 a1, const char *a2)
{
__int64 v2; // rbx

v2 = *(_QWORD *)(a1 + 632);
if ( !v2 )
return 0LL;
while ( strcmp((const char *)v2, a2) )
{
v2 = *(_QWORD *)(v2 + 104);
if ( !v2 )
return 0LL;
}
return *(_BYTE *)(v2 + 73) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(__int64 a1, const char *a2)
{
__int64 v2; // rbx

v2 = *(_QWORD *)(a1 + 632);
if ( !v2 )
return 0LL;
while ( strcmp((const char *)v2, a2) )
{
v2 = *(_QWORD *)(v2 + 104);
if ( !v2 )
return 0LL;
}
return *(_BYTE *)(v2 + 73) != 0;
}

original_code:
int isOp(struct schan *chan, char *nick)
{
 struct suser *i = chan->user;
 while(i)
 {
  if(!strcmp(i->nick, nick))
  {
   if(i->isOp)
    return 1;
   else
    return 0;
  }
  i = i->next;
 }
 return 0;
}

variable_types:
nick
char *

variable_types: struct suser { char nick[33]; char *ident; char *host; char *mask; char *realname; char isVoice; char isOp; int lastMsg; int flines; int joinTime; int nickchanges; int lastNick; int idleMsg; struct suser *next; struct suser *prev; } *


massDeop

decompiled_code:
void __fastcall massDeop(const char **a1, int a2, const char *a3)
{
int v4; // ebx
size_t v5; // rax

if ( a1 && a2 > 0 )
{
v4 = 0;
sprintf(taskbuf, "MODE %s -", *a1);
do
{
++v4;
v5 = strlen(taskbuf);
*(_WORD *)&taskbuf[v5] = 111;
}
while ( a2 > v4 );
strcpy(&taskbuf[v5 + 1], a3);
quickMsg(taskbuf);
}
}

canonical_decompiled_code:
void __fastcall func5(const char **a1, int a2, const char *a3)
{
int v4; // ebx
size_t v5; // rax

if ( a1 && a2 > 0 )
{
v4 = 0;
sprintf(taskbuf, "MODE %s -", *a1);
do
{
++v4;
v5 = strlen(taskbuf);
*(_WORD *)&taskbuf[v5] = 111;
}
while ( a2 > v4 );
strcpy(&taskbuf[v5 + 1], a3);
quickMsg(taskbuf);
}
}

original_code:
void massDeop(struct schan *chan, int count, char *args)
{
 int i;
 if(!chan || (count < 1))
  return;
 sprintf(taskbuf, "MODE %s -", chan->name);
 for(i = 0; i < count; i++)
  strcat(taskbuf, "o");
 strcat(taskbuf, args);
 quickMsg(taskbuf);
 return;
}

variable_types: count int

variable_types:
args
char *


unsetBans

decompiled_code:
void __fastcall unsetBans(const char **a1, int a2, const char *a3)
{
int v4; // ebx
size_t v5; // rax

if ( a1 && a2 > 0 && isOp((__int64)a1, &cNick) )
{
v4 = 0;
sprintf(taskbuf, "MODE %s -", *a1);
do
{
++v4;
v5 = strlen(taskbuf);
*(_WORD *)&taskbuf[v5] = 98;
}
while ( a2 > v4 );
strcpy(&taskbuf[v5 + 1], a3);
quickMsg(taskbuf);
}
}

canonical_decompiled_code:
void __fastcall func6(const char **a1, int a2, const char *a3)
{
int v4; // ebx
size_t v5; // rax

if ( a1 && a2 > 0 && func4((__int64)a1, &cNick) )
{
v4 = 0;
sprintf(taskbuf, "MODE %s -", *a1);
do
{
++v4;
v5 = strlen(taskbuf);
*(_WORD *)&taskbuf[v5] = 98;
}
while ( a2 > v4 );
strcpy(&taskbuf[v5 + 1], a3);
quickMsg(taskbuf);
}
}

original_code:
void unsetBans(struct schan *chan, int count, char *args)
{
 int i;
 if(!chan || (count < 1))
  return;
 if(!isOp(chan, cNick))
  return;
 sprintf(taskbuf, "MODE %s -", chan->name);
 for(i = 0; i < count; i++)
  strcat(taskbuf, "b");
 strcat(taskbuf, args);
 quickMsg(taskbuf);
 return;
}


sendQUIT

decompiled_code:
__int64 __fastcall sendQUIT(__int64 a1)
{
int v1; // eax
__int64 v2; // rax

v1 = time(0LL);
v2 = fixed_duration((unsigned int)(v1 - tStart));
sprintf(taskbuf, aQuit, "0.93", v2, a1);
return irc_write(taskbuf);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
int v1; // eax
__int64 v2; // rax

v1 = time(0LL);
v2 = fixed_duration((unsigned int)(v1 - tStart));
sprintf(taskbuf, aQuit, "0.93", v2, a1);
return irc_write(taskbuf);
}

original_code:
void sendQUIT(char *extra)
{
 sprintf(taskbuf, "QUIT :\037/\002Fireclaw\002.%s/\037Running %s ~ %s", "0.93", fixed_duration(time(0) - tStart), extra);
 irc_write(taskbuf);
 return;
}

variable_types:
extra
char *


checkBadHost

decompiled_code:
__int64 __fastcall checkBadHost(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 result; // rax
__int64 v4; // rax

v2 = a2 + 322;
set_lower_message(v2, v2);
if ( (unsigned int)regmatch(&swear_norm, a2 + 322) || (result = regmatch(&swear_mild, v2), (_DWORD)result) )
{
v4 = findUser(a1, a2);
result = punish_user(*(_QWORD *)(a1 + 672), v4, 109LL, 0LL, 0LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 result; // rax
__int64 v4; // rax

v2 = a2 + 322;
set_lower_message(v2, v2);
if ( (unsigned int)regmatch(&swear_norm, a2 + 322) || (result = regmatch(&swear_mild, v2), (_DWORD)result) )
{
v4 = findUser(a1, a2);
result = punish_user(*(_QWORD *)(a1 + 672), v4, 109LL, 0LL, 0LL);
}
return result;
}

original_code:
void checkBadHost(struct schan *theChan, sUser *theUser)
{
 set_lower_message(theUser->mask, theUser->mask);
 if(regmatch(&swear_norm, theUser->mask) || regmatch(&swear_mild, theUser->mask))
  punish_user(theChan->record, findUser(theChan, theUser->nick), 'm', 0, 0);
 return;
}

canonical_original_code:
void checkBadHost(struct schan *theChan, struct ircUser *theUser)
{
 set_lower_message(theUser->mask, theUser->mask);
 if(regmatch(&swear_norm, theUser->mask) || regmatch(&swear_mild, theUser->mask))
  punish_user(theChan->record, findUser(theChan, theUser->nick), 'm', 0, 0);
 return;
}

variable_types: struct ircUser { char nick[33]; char ident[33]; char host[256]; char mask[512]; char gnuUser[32]; } *


checkLamehost

decompiled_code:
int __fastcall checkLamehost(__int64 a1, __int64 a2)
{
const char *v2; // r15
int result; // eax
int v4; // er12
int v5; // ebp
int v6; // ebx
char *v7; // r14
const char *v8; // r13
unsigned __int64 v9; // rax
int v10; // ebx
__int64 v11; // rax
unsigned __int64 v12; // rdx
__int64 v13; // [rsp+8h] [rbp-60h]
char s[8]; // [rsp+10h] [rbp-58h] BYREF

v2 = (const char *)(a2 + 66);
v13 = a2;
result = *(unsigned __int8 *)(a2 + 66 + (int)strlen((const char *)(a2 + 66)) - 1) - 48;
if ( (unsigned __int8)result <= 9u )
return result;
result = regmatch(&safehosts, a2 + 66);
v4 = result;
if ( result )
return result;
v5 = 0;
v6 = regmatch(&swear_norm, a2 + 322);
if ( v6 )
{
v5 = 1;
v6 = 30;
}
v7 = strchr(v2, 46);
if ( !v7 )
return sprintf(s, "%d spampoints", (unsigned int)(v5 * v6));
while ( 1 )
{
++v4;
v8 = v7 + 1;
v9 = v7 - v2;
if ( v7 - v2 <= 30 )
break;
s[0] = 0;
v6 += v9;
++v5;
v7 = strchr(v7 + 1, 46);
if ( !v7 )
goto LABEL_21;
LABEL_9:
v2 = v8;
}
if ( v9 >= 8 )
{
*(__int64 *)((char *)&v13 + v9) = *((_QWORD *)v7 - 1);
if ( v9 - 1 >= 8 )
{
v12 = 0LL;
do
{
*(_QWORD *)&s[v12] = *(_QWORD *)&v2[v12];
v12 += 8LL;
}
while ( v12 < ((v9 - 1) & 0xFFFFFFFFFFFFFFF8LL) );
}
}
else if ( (v9 & 4) != 0 )
{
*(_DWORD *)s = *(_DWORD *)v2;
*(_DWORD *)((char *)&v13 + v9 + 4) = *((_DWORD *)v7 - 1);
}
else if ( v9 )
{
s[0] = *v2;
if ( (v9 & 2) != 0 )
*(_WORD *)((char *)&v13 + v9 + 6) = *((_WORD *)v7 - 1);
}
s[v9] = 0;
v7 = strchr(v7 + 1, 46);
if ( v7 )
{
if ( s[0] )
{
if ( (unsigned int)regmatch(&lamehost_5, s) )
{
v6 += 5;
++v5;
}
if ( (unsigned int)regmatch(&lamehost_10, s) )
{
v6 += 10;
++v5;
}
if ( (unsigned int)regmatch(&lamehost_15, s) )
{
v6 += 15;
++v5;
}
}
goto LABEL_9;
}
LABEL_21:
if ( v4 > 4 )
v6 += 10;
v10 = v5 * v6;
result = sprintf(s, "%d spampoints", (unsigned int)v10);
if ( v10 > 50 )
{
v11 = findUser(a1, v13);
result = punish_user(*(_QWORD *)(a1 + 672), v11, 104LL, 0LL, s);
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1, __int64 a2)
{
const char *v2; // r15
int result; // eax
int v4; // er12
int v5; // ebp
int v6; // ebx
char *v7; // r14
const char *v8; // r13
unsigned __int64 v9; // rax
int v10; // ebx
__int64 v11; // rax
unsigned __int64 v12; // rdx
__int64 v13; // [rsp+8h] [rbp-60h]
char s[8]; // [rsp+10h] [rbp-58h] BYREF

v2 = (const char *)(a2 + 66);
v13 = a2;
result = *(unsigned __int8 *)(a2 + 66 + (int)strlen((const char *)(a2 + 66)) - 1) - 48;
if ( (unsigned __int8)result <= 9u )
return result;
result = regmatch(&safehosts, a2 + 66);
v4 = result;
if ( result )
return result;
v5 = 0;
v6 = regmatch(&swear_norm, a2 + 322);
if ( v6 )
{
v5 = 1;
v6 = 30;
}
v7 = strchr(v2, 46);
if ( !v7 )
return sprintf(s, "%d spampoints", (unsigned int)(v5 * v6));
while ( 1 )
{
++v4;
v8 = v7 + 1;
v9 = v7 - v2;
if ( v7 - v2 <= 30 )
break;
s[0] = 0;
v6 += v9;
++v5;
v7 = strchr(v7 + 1, 46);
if ( !v7 )
goto LABEL_21;
LABEL_9:
v2 = v8;
}
if ( v9 >= 8 )
{
*(__int64 *)((char *)&v13 + v9) = *((_QWORD *)v7 - 1);
if ( v9 - 1 >= 8 )
{
v12 = 0LL;
do
{
*(_QWORD *)&s[v12] = *(_QWORD *)&v2[v12];
v12 += 8LL;
}
while ( v12 < ((v9 - 1) & 0xFFFFFFFFFFFFFFF8LL) );
}
}
else if ( (v9 & 4) != 0 )
{
*(_DWORD *)s = *(_DWORD *)v2;
*(_DWORD *)((char *)&v13 + v9 + 4) = *((_DWORD *)v7 - 1);
}
else if ( v9 )
{
s[0] = *v2;
if ( (v9 & 2) != 0 )
*(_WORD *)((char *)&v13 + v9 + 6) = *((_WORD *)v7 - 1);
}
s[v9] = 0;
v7 = strchr(v7 + 1, 46);
if ( v7 )
{
if ( s[0] )
{
if ( (unsigned int)regmatch(&lamehost_5, s) )
{
v6 += 5;
++v5;
}
if ( (unsigned int)regmatch(&lamehost_10, s) )
{
v6 += 10;
++v5;
}
if ( (unsigned int)regmatch(&lamehost_15, s) )
{
v6 += 15;
++v5;
}
}
goto LABEL_9;
}
LABEL_21:
if ( v4 > 4 )
v6 += 10;
v10 = v5 * v6;
result = sprintf(s, "%d spampoints", (unsigned int)v10);
if ( v10 > 50 )
{
v11 = findUser(a1, v13);
result = punish_user(*(_QWORD *)(a1 + 672), v11, 104LL, 0LL, s);
}
return result;
}

original_code:
void checkLamehost(struct schan *theChan, sUser *theUser)
{
 char field[32];
 int points, len, fields, badfields;
 char *pch, *anchor;
 len = strlen(theUser->host);
 points = fields = badfields = 0;
 anchor = theUser->host;
 if(anchor[len-1] >= '0' && anchor[len-1] <= '9')
  return;
 if(regmatch(&safehosts, anchor))
  return;
 if(regmatch(&swear_norm, theUser->mask)) {
  points += 30;
  badfields++;
 }
 pch = strchr(anchor, '.');
 while(pch)
 {
  fields++;
  if(pch-anchor >= 31) {
   points += (int)(pch-anchor);
   badfields++;
   field[0] = '\0';
  } else {
   memcpy(field, anchor, pch-anchor);
   field[pch-anchor] = '\0';
  }
  anchor = ++pch;
  pch = strchr(anchor, '.');
  if(pch && field[0]) {
   if(regmatch(&lamehost_5, field)) {
    points += 5;
    badfields++;
   }
   if(regmatch(&lamehost_10, field)) {
    points += 10;
    badfields++;
   }
   if(regmatch(&lamehost_15, field)) {
    points += 15;
    badfields++;
   }
  }
 }
 if(fields > 4)
  points += 10;
 points *= badfields;
 sprintf(field, "%d spampoints", points);
 if(points > 50)
  punish_user(theChan->record, findUser(theChan, theUser->nick), 'h', 0, field);
 return;
}

canonical_original_code:
void checkLamehost(struct schan *theChan, struct ircUser *theUser)
{
 char field[32];
 int points; int len; int fields; int badfields;
 char *pch; char *anchor;
 len = strlen(theUser->host);
 points = fields = badfields = 0;
 anchor = theUser->host;
 if(anchor[len-1] >= '0' && anchor[len-1] <= '9')
  return;
 if(regmatch(&safehosts, anchor))
  return;
 if(regmatch(&swear_norm, theUser->mask)) {
  points += 30;
  badfields++;
 }
 pch = strchr(anchor, '.');
 while(pch)
 {
  fields++;
  if(pch-anchor >= 31) {
   points += (int)(pch-anchor);
   badfields++;
   field[0] = '\0';
  } else {
   memcpy(field, anchor, pch-anchor);
   field[pch-anchor] = '\0';
  }
  anchor = ++pch;
  pch = strchr(anchor, '.');
  if(pch && field[0]) {
   if(regmatch(&lamehost_5, field)) {
    points += 5;
    badfields++;
   }
   if(regmatch(&lamehost_10, field)) {
    points += 10;
    badfields++;
   }
   if(regmatch(&lamehost_15, field)) {
    points += 15;
    badfields++;
   }
  }
 }
 if(fields > 4)
  points += 10;
 points *= badfields;
 sprintf(field, "%d spampoints", points);
 if(points > 50)
  punish_user(theChan->record, findUser(theChan, theUser->nick), 'h', 0, field);
 return;
}

variable_types:
field
char [32]

variable_types: points int

variable_types: len int

variable_types: fields int

variable_types: badfields int

variable_types:
pch
char *

variable_types:
anchor
char *


decompiled_code:
__int64 service_auth()
{
snprintf(
sendbuf,
0x1FEuLL,
"PRIVMSG %s :%s",
(const char *)(unsigned int)((_DWORD)config + 197),
(const char *)(unsigned int)((_DWORD)config + 325));
return highMsg(sendbuf);
}

canonical_decompiled_code:
__int64 func1()
{
snprintf(
sendbuf,
0x1FEuLL,
"PRIVMSG %s :%s",
(const char *)(unsigned int)((_DWORD)config + 197),
(const char *)(unsigned int)((_DWORD)config + 325));
return highMsg(sendbuf);
}

original_code:
void service_auth()
{
 snprintf(sendbuf, 510, "PRIVMSG %s :%s", config.servicePrefix, config.serviceAuth);
 highMsg(sendbuf);
 return;
}


decompiled_code:
__int64 __fastcall sRelay_butone(const char *a1, __int64 a2)
{
if ( main_irc && config[133] == 35 )
{
snprintf(sendbuf, 0x1FEuLL, "PRIVMSG %s :%s", (const char *)(unsigned int)((_DWORD)config + 133), a1);
lowMsg(sendbuf);
}
snprintf(sendbuf, 0x1FEuLL, "# %s", a1);
return send_to_dcc_butonesock(sendbuf, a2, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, __int64 a2)
{
if ( main_irc && config[133] == 35 )
{
snprintf(sendbuf, 0x1FEuLL, "PRIVMSG %s :%s", (const char *)(unsigned int)((_DWORD)config + 133), a1);
lowMsg(sendbuf);
}
snprintf(sendbuf, 0x1FEuLL, "# %s", a1);
return send_to_dcc_butonesock(sendbuf, a2, 0LL);
}

original_code:
void sRelay_butone(char *message, struct socket *tso)
{
 if(main_irc && config.relaychan[0] == '#')
 {
  snprintf(sendbuf, 510, "PRIVMSG %s :%s", config.relaychan, message);
  lowMsg(sendbuf);
 }
 snprintf(sendbuf, 510, "# %s", message);
 send_to_dcc_butonesock(sendbuf, tso, 0);
 return;
}

variable_types:
message
char *

variable_types: struct socket { char type; char status; int id; int fd; int last_ts; int con_ts; char checkLink; char buffer[4096]; struct socket *next; } *


sRelay

decompiled_code:
__int64 __fastcall sRelay(const char *a1)
{
if ( main_irc && config[133] == 35 )
{
snprintf(sendbuf, 0x1FEuLL, "PRIVMSG %s :%s", (const char *)(unsigned int)((_DWORD)config + 133), a1);
lowMsg(sendbuf);
}
snprintf(sendbuf, 0x1FEuLL, "# %s", a1);
return send_to_all_dcc(sendbuf, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
if ( main_irc && config[133] == 35 )
{
snprintf(sendbuf, 0x1FEuLL, "PRIVMSG %s :%s", (const char *)(unsigned int)((_DWORD)config + 133), a1);
lowMsg(sendbuf);
}
snprintf(sendbuf, 0x1FEuLL, "# %s", a1);
return send_to_all_dcc(sendbuf, 0LL);
}

original_code:
void sRelay(char *message)
{
 if(main_irc && config.relaychan[0] == '#')
 {
  snprintf(sendbuf, 510, "PRIVMSG %s :%s", config.relaychan, message);
  lowMsg(sendbuf);
 }
 snprintf(sendbuf, 510, "# %s", message);
 send_to_all_dcc(sendbuf, 0);
 return;
}


myalloc

decompiled_code:
void *__fastcall myalloc(size_t a1)
{
void *result; // rax
struct mallinfo v2; // [rsp+0h] [rbp-38h] BYREF

result = malloc(a1);
if ( !result )
{
mallinfo(&v2);
fprintf(
out,
"Heap: %d, Used: %d, Spare: %d\n",
(unsigned int)v2.arena,
(unsigned int)v2.uordblks,
(unsigned int)v2.fordblks);
fprintf(out, "*ERROR* Out of memory trying to allocate %d bytes!\n", (unsigned int)a1);
exit(0);
}
return result;
}

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

result = malloc(a1);
if ( !result )
{
mallinfo(&v2);
fprintf(
out,
"Heap: %d, Used: %d, Spare: %d\n",
(unsigned int)v2.arena,
(unsigned int)v2.uordblks,
(unsigned int)v2.fordblks);
fprintf(out, "*ERROR* Out of memory trying to allocate %d bytes!\n", (unsigned int)a1);
exit(0);
}
return result;
}

original_code:
void *myalloc(size_t size)
{
 void *ret = malloc(size);
 if(!ret)
 {
  struct mallinfo mem = mallinfo();
  fprintf(out, "Heap: %d, Used: %d, Spare: %d\n", (int)mem.arena, (int)mem.uordblks, (int)mem.fordblks);
  fprintf(out, "*ERROR* Out of memory trying to allocate %d bytes!\n", (int)size);
  exit(0);
 }
 return ret;
}

canonical_original_code:
void *myalloc(unsigned long size)
{
 void *ret = malloc(size);
 if(!ret)
 {
  struct mallinfo mem = mallinfo();
  fprintf(out, "Heap: %d, Used: %d, Spare: %d\n", (int)mem.arena, (int)mem.uordblks, (int)mem.fordblks);
  fprintf(out, "*ERROR* Out of memory trying to allocate %d bytes!\n", (int)size);
  exit(0);
 }
 return ret;
}

variable_types:
size
unsigned long

variable_types:
ret
void *

variable_types: struct mallinfo { int arena; int ordblks; int smblks; int hblks; int hblkhd; int usmblks; int fsmblks; int uordblks; int fordblks; int keepcost; }

return_type: void *


printmem

decompiled_code:
int printmem()
{
struct mallinfo v1; // [rsp+0h] [rbp-38h] BYREF

mallinfo(&v1);
return fprintf(out, "**********: Heap size: %d bytes.\n", (unsigned int)v1.uordblks);
}

canonical_decompiled_code:
int func5()
{
struct mallinfo v1; // [rsp+0h] [rbp-38h] BYREF

mallinfo(&v1);
return fprintf(out, "**********: Heap size: %d bytes.\n", (unsigned int)v1.uordblks);
}

original_code:
void printmem()
{
 struct mallinfo mem = mallinfo();
 fprintf(out, "**********: Heap size: %d bytes.\n", (int)mem.uordblks);
 return;
}

user_defined_types: struct mallinfo { int arena; int ordblks; int smblks; int hblks; int hblkhd; int usmblks; int fsmblks; int uordblks; int fordblks; int keepcost; }


decompiled_code:
__int64 __fastcall sort_list(__int64 a1)
{
int v1; // er9
__int64 result; // rax
__int64 v3; // rsi
int v4; // ecx
__int64 v5; // rdx
__m128i v6; // xmm1
__m128i v7; // xmm0
__m128i v8; // xmm2
__m128i v9; // xmm3

v1 = listPos;
result = 5LL * (unsigned int)(listPos - 2);
v3 = a1 + 40LL * (unsigned int)(listPos - 2) + 40;
do
{
if ( v1 <= 1 )
break;
result = a1;
v4 = 0;
do
{
if ( *(_DWORD *)(result + 36) < *(_DWORD *)(result + 76) )
{
++v4;
v6 = _mm_loadu_si128((const __m128i *)result);
v7 = _mm_loadu_si128((const __m128i *)(result + 16));
v8 = _mm_loadu_si128((const __m128i *)(result + 40));
v9 = _mm_loadu_si128((const __m128i *)(result + 56));
v5 = *(_QWORD *)(result + 32);
*(_QWORD *)(result + 32) = *(_QWORD *)(result + 72);
*(_QWORD *)(result + 72) = v5;
*(__m128i *)result = v8;
*(__m128i *)(result + 16) = v9;
*(__m128i *)(result + 40) = v6;
*(__m128i *)(result + 56) = v7;
}
result += 40LL;
}
while ( result != v3 );
}
while ( v4 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
int v1; // er9
__int64 result; // rax
__int64 v3; // rsi
int v4; // ecx
__int64 v5; // rdx
__m128i v6; // xmm1
__m128i v7; // xmm0
__m128i v8; // xmm2
__m128i v9; // xmm3

v1 = listPos;
result = 5LL * (unsigned int)(listPos - 2);
v3 = a1 + 40LL * (unsigned int)(listPos - 2) + 40;
do
{
if ( v1 <= 1 )
break;
result = a1;
v4 = 0;
do
{
if ( *(_DWORD *)(result + 36) < *(_DWORD *)(result + 76) )
{
++v4;
v6 = _mm_loadu_si128((const __m128i *)result);
v7 = _mm_loadu_si128((const __m128i *)(result + 16));
v8 = _mm_loadu_si128((const __m128i *)(result + 40));
v9 = _mm_loadu_si128((const __m128i *)(result + 56));
v5 = *(_QWORD *)(result + 32);
*(_QWORD *)(result + 32) = *(_QWORD *)(result + 72);
*(_QWORD *)(result + 72) = v5;
*(__m128i *)result = v8;
*(__m128i *)(result + 16) = v9;
*(__m128i *)(result + 40) = v6;
*(__m128i *)(result + 56) = v7;
}
result += 40LL;
}
while ( result != v3 );
}
while ( v4 );
return result;
}

original_code:
void sort_list(struct tagList *list)
{
 struct tagList buf;
 int changes, iter;
 for(;;)
 {
  changes = 0;
  for(iter = 0; iter < listPos - 1; iter++)
  {
   if(list[iter].count < list[iter+1].count) {
    buf = list[iter];
    list[iter] = list[iter+1];
    list[iter+1] = buf;
    changes++;
   }
  }
  if(changes == 0)
   break;
 }
 return;
}

canonical_original_code:
void sort_list(struct tagList *list)
{
 struct tagList buf;
 int changes; int iter;
 for(;;)
 {
  changes = 0;
  for(iter = 0; iter < listPos - 1; iter++)
  {
   if(list[iter].count < list[iter+1].count) {
    buf = list[iter];
    list[iter] = list[iter+1];
    list[iter+1] = buf;
    changes++;
   }
  }
  if(changes == 0)
   break;
 }
 return;
}

variable_types: struct tagList { char tag[33]; int count; } *

variable_types: changes int

variable_types: iter int


decompiled_code:
__int64 __fastcall match_badurl(char *haystack)
{
_QWORD *v1; // rbx

v1 = badlist;
if ( !badlist )
return 0LL;
while ( !strstr(haystack, (const char *)*v1) )
{
v1 = (_QWORD *)v1[2];
if ( !v1 )
return 0LL;
}
++*((_DWORD *)v1 + 2);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *haystack)
{
_QWORD *v1; // rbx

v1 = badlist;
if ( !badlist )
return 0LL;
while ( !strstr(haystack, (const char *)*v1) )
{
v1 = (_QWORD *)v1[2];
if ( !v1 )
return 0LL;
}
++*((_DWORD *)v1 + 2);
return 1LL;
}

original_code:
int match_badurl(char *text)
{
 struct badUrl *i;
 i = badlist;
 while(i)
 {
  if(strstr(text, i->match)) {
   i->count++;
   return 1;
  }
  i = i->next;
 }
 return 0;
}

variable_types:
text
char *

variable_types: struct badUrl { char *match; int count; struct badUrl *next; } *


decompiled_code:
void init_badurls()
{
badlist = 0LL;
}

canonical_decompiled_code:
void func1()
{
badlist = 0LL;
}

original_code:
void init_badurls()
{
 badlist = ((void *)0);
}


decompiled_code:
void reset_badurls()
{
void **v0; // rbx
void **v1; // rbp

v0 = (void **)badlist;
if ( badlist )
{
do
{
v1 = v0;
v0 = (void **)v0[2];
free(*v1);
free(v1);
}
while ( v0 );
badlist = 0LL;
}
}

canonical_decompiled_code:
void func2()
{
void **v0; // rbx
void **v1; // rbp

v0 = (void **)badlist;
if ( badlist )
{
do
{
v1 = v0;
v0 = (void **)v0[2];
free(*v1);
free(v1);
}
while ( v0 );
badlist = 0LL;
}
}

original_code:
void reset_badurls()
{
 struct badUrl *i, *last;
 if(badlist) {
  i = badlist;
  while(i)
  {
   last = i;
   i = i->next;
   free(last->match);
   free(last);
  }
  badlist = ((void *)0);
 }
 return;
}

canonical_original_code:
void reset_badurls()
{
 struct badUrl *i; struct badUrl *last;
 if(badlist) {
  i = badlist;
  while(i)
  {
   last = i;
   i = i->next;
   free(last->match);
   free(last);
  }
  badlist = ((void *)0);
 }
 return;
}

user_defined_types: struct badUrl { char *match; int count; struct badUrl *next; }


decompiled_code:
int setup_signals()
{
struct sigaction v1; // [rsp+0h] [rbp-A8h] BYREF

sigemptyset(&v1.sa_mask);
v1.sa_flags = 0;
v1.sa_handler = (__sighandler_t)sigint;
sigaction(2, &v1, 0LL);
v1.sa_handler = (__sighandler_t)sighup;
sigaction(1, &v1, 0LL);
v1.sa_handler = (__sighandler_t)(sigint + 1);
sigaction(10, &v1, 0LL);
return sigaction(13, &v1, 0LL);
}

canonical_decompiled_code:
int func2()
{
struct sigaction v1; // [rsp+0h] [rbp-A8h] BYREF

sigemptyset(&v1.sa_mask);
v1.sa_flags = 0;
v1.sa_handler = (__sighandler_t)sigint;
sigaction(2, &v1, 0LL);
v1.sa_handler = (__sighandler_t)sighup;
sigaction(1, &v1, 0LL);
v1.sa_handler = (__sighandler_t)(sigint + 1);
sigaction(10, &v1, 0LL);
return sigaction(13, &v1, 0LL);
}

original_code:
void setup_signals()
{
    struct sigaction sv;
    sigemptyset( &sv.sa_mask );
    sv.sa_flags = 0;
 sv.__sigaction_handler.sa_handler = _sigint;
    sigaction( 2, &sv, ((void *)0) );
    sv.__sigaction_handler.sa_handler = _sighup;
    sigaction( 1, &sv, ((void *)0) );
    sv.__sigaction_handler.sa_handler = ((__sighandler_t) 1);
    sigaction( 10, &sv, ((void *)0) );
    sigaction( 13, &sv, ((void *)0) );
 return;
}

canonical_original_code:
void setup_signals()
{
    struct sigaction sv;
    sigemptyset( &sv.sa_mask );
    sv.sa_flags = 0;
 sv.__sigaction_handler.sa_handler = _sigint;
    sigaction( 2, &sv, ((void *)0) );
    sv.__sigaction_handler.sa_handler = _sighup;
    sigaction( 1, &sv, ((void *)0) );
    sv.__sigaction_handler.sa_handler = ((void (*)(int)) 1);
    sigaction( 10, &sv, ((void *)0) );
    sigaction( 13, &sv, ((void *)0) );
 return;
}

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }