decompiled_code:
char *__fastcall fixed_duration(int a1)
{
sprintf(
dbuffer_1,
"%01d days, %02d:%02d:%02d",
(unsigned int)(a1 / 86400),
(unsigned int)(a1 % 86400 / 3600),
(unsigned int)(a1 % 86400 % 3600 / 60),
(unsigned int)(a1 % 86400 % 3600 % 60));
return dbuffer_1;
}

original_code:
char *fixed_duration(int duration)
{
  static char dbuffer[20];
  int days = 0, hours = 0, mins = 0;
        days = (int)(duration/(24*60*60));
        duration %= (24*60*60);
        hours = (int)(duration/(60*60));
        duration %= (60*60);
        mins = (int)(duration/60);
        duration %= 60;
        sprintf(dbuffer, "%01d days, %02d:%02d:%02d", days, hours, mins, duration);
        return dbuffer;
}

canonical_original_code:
char *fixed_duration(int duration)
{
  static char dbuffer[20];
  int days = 0; int hours = 0; int mins = 0;
        days = (int)(duration/(24*60*60));
        duration %= (24*60*60);
        hours = (int)(duration/(60*60));
        duration %= (60*60);
        mins = (int)(duration/60);
        duration %= 60;
        sprintf(dbuffer, "%01d days, %02d:%02d:%02d", days, hours, mins, duration);
        return dbuffer;
}

variable_types: duration int

variable_types:
dbuffer
char [20]

variable_types: days int

variable_types: hours int

variable_types: mins int

return_type: char *


repo: ipacker/fireclaw

decompiled_code:
char *__fastcall small_duration(int a1)
{
unsigned int v1; // eax
int v2; // edi
__int64 v3; // rdx
__int64 v4; // r8

dbuffer_0 = 0;
v1 = a1 / 86400;
v2 = a1 % 86400;
v3 = (unsigned int)(v2 / 3600);
v4 = (unsigned int)(v2 % 3600 / 60);
if ( v1 )
{
sprintf(&dbuffer_0, "%dd %dh %dm", v1, (unsigned int)v3, v4);
}
else if ( (_DWORD)v3 )
{
sprintf(&dbuffer_0, "%dh %dm", v3, (unsigned int)v4);
}
else
{
sprintf(&dbuffer_0, "%dm", (unsigned int)v4);
}
return &dbuffer_0;
}

canonical_decompiled_code:
char *__fastcall func7(int a1)
{
unsigned int v1; // eax
int v2; // edi
__int64 v3; // rdx
__int64 v4; // r8

dbuffer_0 = 0;
v1 = a1 / 86400;
v2 = a1 % 86400;
v3 = (unsigned int)(v2 / 3600);
v4 = (unsigned int)(v2 % 3600 / 60);
if ( v1 )
{
sprintf(&dbuffer_0, "%dd %dh %dm", v1, (unsigned int)v3, v4);
}
else if ( (_DWORD)v3 )
{
sprintf(&dbuffer_0, "%dh %dm", v3, (unsigned int)v4);
}
else
{
sprintf(&dbuffer_0, "%dm", (unsigned int)v4);
}
return &dbuffer_0;
}

original_code:
char *small_duration(int duration)
{
 static char dbuffer[20];
 int days = 0, hours = 0, mins = 0;
 dbuffer[0] = 0;
 days = (int)(duration/(24*60*60));
 duration %= (24*60*60);
 hours = (int)(duration/(60*60));
 duration %= (60*60);
 mins = (int)(duration/60);
 if(days)
  sprintf(dbuffer, "%dd %dh %dm", days, hours, mins);
 else if(hours)
  sprintf(dbuffer, "%dh %dm", hours, mins);
 else
  sprintf(dbuffer, "%dm", mins);
 return dbuffer;
}

canonical_original_code:
char *small_duration(int duration)
{
 static char dbuffer[20];
 int days = 0; int hours = 0; int mins = 0;
 dbuffer[0] = 0;
 days = (int)(duration/(24*60*60));
 duration %= (24*60*60);
 hours = (int)(duration/(60*60));
 duration %= (60*60);
 mins = (int)(duration/60);
 if(days)
  sprintf(dbuffer, "%dd %dh %dm", days, hours, mins);
 else if(hours)
  sprintf(dbuffer, "%dh %dm", hours, mins);
 else
  sprintf(dbuffer, "%dm", mins);
 return dbuffer;
}


wildcmp

original_code:
int wildcmp(char *wild, char *string)
{
 char *cp, *mp;
 mp = cp = 0;
 while ((*string) && (*wild != '*')) {
  if ((*wild != *string) && (*wild != '?')) {
   return 0;
  }
  wild++;
  string++;
 }
 while (*string) {
  if (*wild == '*') {
   if (!*++wild) {
    return 1;
   }
   mp = wild;
   cp = string+1;
  } else if ((*wild == *string) || (*wild == '?')) {
   wild++;
   string++;
  } else {
   wild = mp;
   string = cp++;
  }
 }
 while (*wild == '*') {
  wild++;
 }
 return !*wild;
}

canonical_original_code:
int wildcmp(char *wild, char *string)
{
 char *cp; char *mp;
 mp = cp = 0;
 while ((*string) && (*wild != '*')) {
  if ((*wild != *string) && (*wild != '?')) {
   return 0;
  }
  wild++;
  string++;
 }
 while (*string) {
  if (*wild == '*') {
   if (!*++wild) {
    return 1;
   }
   mp = wild;
   cp = string+1;
  } else if ((*wild == *string) || (*wild == '?')) {
   wild++;
   string++;
  } else {
   wild = mp;
   string = cp++;
  }
 }
 while (*wild == '*') {
  wild++;
 }
 return !*wild;
}

variable_types:
wild
char *

variable_types:
string
char *

variable_types:
cp
char *

variable_types:
mp
char *

return_type: int


wildicmp

original_code:
int wildicmp(char *wild, char *string)
{
 char *cp, *mp;
 mp = cp = 0;
 while ((*string) && (*wild != '*')) {
  if ((tolower(*wild) != tolower(*string)) && (*wild != '?')) {
   return 0;
  }
  wild++;
  string++;
 }
 while (*string) {
  if (*wild == '*') {
   if (!*++wild) {
    return 1;
   }
   mp = wild;
   cp = string+1;
  } else if ((tolower(*wild) == tolower(*string)) || (*wild == '?')) {
   wild++;
   string++;
  } else {
   wild = mp;
   string = cp++;
  }
 }
 while (*wild == '*') {
  wild++;
 }
 return !*wild;
}

canonical_original_code:
int wildicmp(char *wild, char *string)
{
 char *cp; char *mp;
 mp = cp = 0;
 while ((*string) && (*wild != '*')) {
  if ((tolower(*wild) != tolower(*string)) && (*wild != '?')) {
   return 0;
  }
  wild++;
  string++;
 }
 while (*string) {
  if (*wild == '*') {
   if (!*++wild) {
    return 1;
   }
   mp = wild;
   cp = string+1;
  } else if ((tolower(*wild) == tolower(*string)) || (*wild == '?')) {
   wild++;
   string++;
  } else {
   wild = mp;
   string = cp++;
  }
 }
 while (*wild == '*') {
  wild++;
 }
 return !*wild;
}


checkSimChars

decompiled_code:
__int64 __fastcall checkSimChars(unsigned __int8 *a1, const char *a2)
{
unsigned __int8 *v2; // rbx
unsigned int i; // ebp

v2 = a1;
for ( i = *a1; (_BYTE)i; i = *++v2 )
{
if ( strchr(a2, (char)i) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned __int8 *a1, const char *a2)
{
unsigned __int8 *v2; // rbx
unsigned int i; // ebp

v2 = a1;
for ( i = *a1; (_BYTE)i; i = *++v2 )
{
if ( strchr(a2, (char)i) )
break;
}
return i;
}

original_code:
char checkSimChars(char *str1, char *str2)
{
 for(; *str1; str1++)
  if(strchr(str2, *str1))
   return *str1;
 return 0;
}

return_type: char


decompiled_code:
__int64 register_self()
{
const char *v0; // rdx
char v2[536]; // [rsp+0h] [rbp-218h] BYREF

v0 = *(const char **)(serv + 16LL);
if ( v0 )
{
sprintf(v2, "PASS %s", v0);
irc_write(v2);
}
strcpy(&cNick, &config);
snprintf(v2, 0x1FEuLL, "NICK %s", &config);
irc_write(v2);
snprintf(
v2,
0x1FEuLL,
"USER %s %d * :%s",
(const char *)(unsigned int)((_DWORD)&config + 33),
8LL,
(const char *)(unsigned int)((_DWORD)&config + 49));
return irc_write(v2);
}

canonical_decompiled_code:
__int64 func0()
{
const char *v0; // rdx
char v2[536]; // [rsp+0h] [rbp-218h] BYREF

v0 = *(const char **)(serv + 16LL);
if ( v0 )
{
sprintf(v2, "PASS %s", v0);
irc_write(v2);
}
strcpy(&cNick, &config);
snprintf(v2, 0x1FEuLL, "NICK %s", &config);
irc_write(v2);
snprintf(
v2,
0x1FEuLL,
"USER %s %d * :%s",
(const char *)(unsigned int)((_DWORD)&config + 33),
8LL,
(const char *)(unsigned int)((_DWORD)&config + 49));
return irc_write(v2);
}

original_code:
void register_self()
{
 char sendbuf[513];
 if(serv->password)
 {
  sprintf(sendbuf, "PASS %s", serv->password);
  irc_write(sendbuf);
 }
 strcpy(cNick, config.nick);
 snprintf(sendbuf, 510, "NICK %s", config.nick);
 irc_write(sendbuf);
 snprintf(sendbuf, 510, "USER %s %d * :%s", config.ident, 8, config.realname);
 irc_write(sendbuf);
}

variable_types:
sendbuf
char [513]

return_type: void


decompiled_code:
void init_servers()
{
numserves = 0;
i = -1;
}

canonical_decompiled_code:
void func1()
{
numserves = 0;
i = -1;
}


decompiled_code:
char *get_next_server()
{
int v0; // eax

if ( !numserves )
return 0LL;
v0 = i + 1;
if ( numserves <= i + 1 )
v0 = 0;
i = v0;
return (char *)&servers + 40 * v0;
}

canonical_decompiled_code:
char *func2()
{
int v0; // eax

if ( !numserves )
return 0LL;
v0 = i + 1;
if ( numserves <= i + 1 )
v0 = 0;
i = v0;
return (char *)&servers + 40 * v0;
}

original_code:
struct Server *get_next_server()
{
 if(numserves == 0)
  return ((void *)0);
 if(++i >= numserves)
  i = 0;
 return &servers[i];
}

return_type: struct Server { char *hostname; int port; char *password; int numtries; int lastconnect; int lastfail; } *


decompiled_code:
size_t initiate_main_connect()
{
char *v0; // rax
__int64 v1; // rdx

init_oj();
lastConnect = time(0LL);
v0 = get_next_server();
serv = v0;
v1 = (unsigned int)(*((_DWORD *)v0 + 6) + 1);
*((_DWORD *)v0 + 6) = v1;
fprintf(out, "Connection attempt %d [%s:%d]\n", v1, *(const char **)v0, *((unsigned int *)v0 + 2));
if ( !add_socket(109LL, 1LL, *serv, *(unsigned int *)(serv + 8LL), (unsigned int)((_DWORD)&config + 113), 0LL) )
return fwrite("Could not connect.\n", 1uLL, 0x13uLL, out);
clear_ial();
reset_queue();
reset_timers();
return logout_all_admins();
}

canonical_decompiled_code:
size_t func3()
{
char *v0; // rax
__int64 v1; // rdx

init_oj();
lastConnect = time(0LL);
v0 = func2();
serv = v0;
v1 = (unsigned int)(*((_DWORD *)v0 + 6) + 1);
*((_DWORD *)v0 + 6) = v1;
fprintf(out, "Connection attempt %d [%s:%d]\n", v1, *(const char **)v0, *((unsigned int *)v0 + 2));
if ( !add_socket(109LL, 1LL, *serv, *(unsigned int *)(serv + 8LL), (unsigned int)((_DWORD)&config + 113), 0LL) )
return fwrite("Could not connect.\n", 1uLL, 0x13uLL, out);
clear_ial();
reset_queue();
reset_timers();
return logout_all_admins();
}

original_code:
void initiate_main_connect()
{
 init_oj();
 lastConnect = time(0);
 serv = get_next_server();
 serv->numtries++;
 if(!serv) {
  fprintf(out, "Error, no servers in my list!\n");
  exit(0);
 }
 fprintf(out, "Connection attempt %d [%s:%d]\n", serv->numtries, serv->hostname, serv->port);
 if(add_socket('m', 1, serv->hostname, serv->port, config.vhost, 0))
 {
  clear_ial();
  reset_queue();
  reset_timers();
  logout_all_admins();
 } else
  fprintf(out, "Could not connect.\n");
}


decompiled_code:
__int64 __fastcall add_server(char *s)
{
char *v1; // rax
const char *v2; // r12
char *v3; // rax
const char *v4; // rbp
int v5; // er13
size_t v6; // rax
int v7; // er12
size_t v8; // rax
char *v9; // rax
int v10; // edx
__int64 v11; // rsi
int v13; // er12
size_t v14; // rax
int v15; // ebp
__int64 v16; // rcx

v1 = strchr(s, 58);
if ( !v1 )
{
v13 = 6667;
goto LABEL_7;
}
v2 = v1 + 1;
*v1 = 0;
v3 = strchr(v1 + 1, 32);
if ( !v3 )
{
v13 = atoi(v2);
LABEL_7:
v14 = strlen(s);
v15 = numserves;
*((_QWORD *)&servers + 5 * v15) = myalloc(v14 + 1);
v16 = 5LL * numserves;
*((_DWORD *)&servers + 2 * v16 + 2) = v13;
*((_QWORD *)&servers + v16 + 2) = 0LL;
goto LABEL_4;
}
v4 = v3 + 1;
*v3 = 0;
v5 = atoi(v2);
v6 = strlen(s);
v7 = numserves;
*((_QWORD *)&servers + 5 * v7) = myalloc(v6 + 1);
*((_DWORD *)&servers + 10 * numserves + 2) = v5;
v8 = strlen(v4);
v9 = (char *)myalloc(v8 + 1);
*((_QWORD *)&servers + 5 * numserves + 2) = v9;
strcpy(v9, v4);
LABEL_4:
strcpy(*((char **)&servers + 5 * numserves), s);
v10 = numserves;
v11 = 5LL * numserves;
*((_DWORD *)&servers + 2 * v11 + 6) = 0;
*((_DWORD *)&servers + 2 * v11 + 7) = 0;
*((_DWORD *)&servers + 2 * v11 + 8) = 0;
numserves = v10 + 1;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s)
{
char *v1; // rax
const char *v2; // r12
char *v3; // rax
const char *v4; // rbp
int v5; // er13
size_t v6; // rax
int v7; // er12
size_t v8; // rax
char *v9; // rax
int v10; // edx
__int64 v11; // rsi
int v13; // er12
size_t v14; // rax
int v15; // ebp
__int64 v16; // rcx

v1 = strchr(s, 58);
if ( !v1 )
{
v13 = 6667;
goto LABEL_7;
}
v2 = v1 + 1;
*v1 = 0;
v3 = strchr(v1 + 1, 32);
if ( !v3 )
{
v13 = atoi(v2);
LABEL_7:
v14 = strlen(s);
v15 = numserves;
*((_QWORD *)&servers + 5 * v15) = myalloc(v14 + 1);
v16 = 5LL * numserves;
*((_DWORD *)&servers + 2 * v16 + 2) = v13;
*((_QWORD *)&servers + v16 + 2) = 0LL;
goto LABEL_4;
}
v4 = v3 + 1;
*v3 = 0;
v5 = atoi(v2);
v6 = strlen(s);
v7 = numserves;
*((_QWORD *)&servers + 5 * v7) = myalloc(v6 + 1);
*((_DWORD *)&servers + 10 * numserves + 2) = v5;
v8 = strlen(v4);
v9 = (char *)myalloc(v8 + 1);
*((_QWORD *)&servers + 5 * numserves + 2) = v9;
strcpy(v9, v4);
LABEL_4:
strcpy(*((char **)&servers + 5 * numserves), s);
v10 = numserves;
v11 = 5LL * numserves;
*((_DWORD *)&servers + 2 * v11 + 6) = 0;
*((_DWORD *)&servers + 2 * v11 + 7) = 0;
*((_DWORD *)&servers + 2 * v11 + 8) = 0;
numserves = v10 + 1;
return 1LL;
}

original_code:
int add_server(char *confstring)
{
 int portn;
 char *host, *port, *pass;
 host = confstring;
 port = strchr(host, ':');
 if(!port)
 {
  portn = 6667;
  pass = ((void *)0);
 } else {
  *port++ = '\0';
  pass = strchr(port, ' ');
  if(!pass)
  {
   portn = atoi(port);
   pass = ((void *)0);
  } else {
   *pass++ = '\0';
   portn = atoi(port);
  }
 }
 servers[numserves].hostname = (char*)myalloc(strlen(host)+1);
 servers[numserves].port = portn;
 servers[numserves].password = pass ? (char*)myalloc(strlen(pass)+1) : ((void *)0);
 if(pass)
  strcpy(servers[numserves].password, pass);
 strcpy(servers[numserves].hostname, host);
 servers[numserves].numtries = 0;
 servers[numserves].lastconnect = 0;
 servers[numserves].lastfail = 0;
 numserves++;
 return 1;
}

canonical_original_code:
int add_server(char *confstring)
{
 int portn;
 char *host; char *port; char *pass;
 host = confstring;
 port = strchr(host, ':');
 if(!port)
 {
  portn = 6667;
  pass = ((void *)0);
 } else {
  *port++ = '\0';
  pass = strchr(port, ' ');
  if(!pass)
  {
   portn = atoi(port);
   pass = ((void *)0);
  } else {
   *pass++ = '\0';
   portn = atoi(port);
  }
 }
 servers[numserves].hostname = (char *)myalloc(strlen(host)+1);
 servers[numserves].port = portn;
 servers[numserves].password = pass ? (char *)myalloc(strlen(pass)+1) : ((void *)0);
 if(pass)
  strcpy(servers[numserves].password, pass);
 strcpy(servers[numserves].hostname, host);
 servers[numserves].numtries = 0;
 servers[numserves].lastconnect = 0;
 servers[numserves].lastfail = 0;
 numserves++;
 return 1;
}

variable_types:
confstring
char *

variable_types: portn int

variable_types:
host
char *

variable_types:
port
char *

variable_types:
pass
char *


decompiled_code:
void kill_servers()
{
void **v0; // rbx
int v1; // ebp
void *v2; // rdi

if ( numserves > 0 )
{
v0 = (void **)&servers;
v1 = 0;
do
{
free(*v0);
v2 = v0[2];
if ( v2 )
free(v2);
++v1;
v0 += 5;
}
while ( numserves > v1 );
}
init_servers();
}

canonical_decompiled_code:
void func5()
{
void **v0; // rbx
int v1; // ebp
void *v2; // rdi

if ( numserves > 0 )
{
v0 = (void **)&servers;
v1 = 0;
do
{
free(*v0);
v2 = v0[2];
if ( v2 )
free(v2);
++v1;
v0 += 5;
}
while ( numserves > v1 );
}
func1();
}

original_code:
void kill_servers()
{
 int i;
 for(i = 0; i < numserves; i++)
 {
  free(servers[i].hostname);
  if(servers[i].password)
   free(servers[i].password);
 }
 init_servers();
}

variable_types: i int


decompiled_code:
__int64 __fastcall count_coloured_chars(char *a1)
{
char v1; // al
char v2; // dl
unsigned int v3; // ecx

v1 = *a1;
if ( !*a1 )
return 0;
v2 = 0;
v3 = 0;
do
{
if ( v1 == 3 )
{
v2 ^= 1u;
}
else if ( v1 == 15 )
{
v2 = 0;
}
else
{
v3 -= (v2 == 0) - 1;
}
v1 = *++a1;
}
while ( *a1 );
return v3;
}

original_code:
static int count_coloured_chars(char *text)
{
 int ret;
 char c = 0;
 for(ret = 0; *text; text++)
 {
  switch(*text)
  {
   case '\003': { c = (c) ? 0 : 1; break; }
   case '\017': { c = 0; break; }
   default: { if(c) ret++; break; }
  }
 }
 return ret;
}

variable_types:
text
char *

variable_types: ret int

variable_types: c char


decompiled_code:
__int64 __fastcall caps_percent(char *a1)
{
char v1; // al
float v2; // xmm1_4
float v3; // xmm0_4

v1 = *a1;
if ( *a1 )
{
v2 = *(float *)&LC0;
v3 = *(float *)&LC0;
do
{
if ( (unsigned __int8)(v1 - 65) > 0x19u )
{
if ( (unsigned __int8)(v1 - 97) <= 0x19u )
v2 = v2 + 1.0;
}
else
{
v3 = v3 + 1.0;
}
v1 = *++a1;
}
while ( *a1 );
}
else
{
v2 = *(float *)&LC0;
v3 = *(float *)&LC0;
}
return (unsigned int)(int)(float)((float)(v3 / (float)(v2 + v3)) * 100.0);
}

original_code:
static int caps_percent(char *text)
{
 float upper, lower;
 upper = lower = 0.01;
 for(; *text; text++) {
  if(*text >= 'A' && *text <= 'Z')
   upper++;
  else if(*text >= 'a' && *text <= 'z')
   lower++;
 }
 return (int)(100*(upper/(upper+lower)));
}

canonical_original_code:
static int caps_percent(char *text)
{
 float upper; float lower;
 upper = lower = 0.01;
 for(; *text; text++) {
  if(*text >= 'A' && *text <= 'Z')
   upper++;
  else if(*text >= 'a' && *text <= 'z')
   lower++;
 }
 return (int)(100*(upper/(upper+lower)));
}

variable_types: upper float

variable_types: lower float


original_code:
static int ctrlchar_percent(char *text)
{
 char cb, cu, cr;
 float yes, no;
 yes = no = 0.001;
 cb = cu = cr = 0;
 for(; *text; text++) {
  switch(*text) {
   case '\002': { cb = (cb) ? 0 : 1; break; }
   case '\037': { cu = (cu) ? 0 : 1; break; }
   case '\026': { cr = (cu) ? 0 : 1; break; }
   case '\017': { cr = cu = cb = 0; break; }
   default: {
    if(cb || cu || cr)
     yes++;
    else
     no++;
    break;
   }
  }
 }
 return (int)(100*(yes/(yes+no)));
}

canonical_original_code:
static int ctrlchar_percent(char *text)
{
 char cb; char cu; char cr;
 float yes; float no;
 yes = no = 0.001;
 cb = cu = cr = 0;
 for(; *text; text++) {
  switch(*text) {
   case '\002': { cb = (cb) ? 0 : 1; break; }
   case '\037': { cu = (cu) ? 0 : 1; break; }
   case '\026': { cr = (cu) ? 0 : 1; break; }
   case '\017': { cr = cu = cb = 0; break; }
   default: {
    if(cb || cu || cr)
     yes++;
    else
     no++;
    break;
   }
  }
 }
 return (int)(100*(yes/(yes+no)));
}

variable_types: cb char

variable_types: cu char

variable_types: cr char

variable_types: yes float

variable_types: no float


decompiled_code:
__int64 __fastcall make_msg_id(unsigned __int8 *a1)
{
unsigned __int8 v1; // al
unsigned __int8 *v2; // rdx
unsigned int v3; // esi
int v4; // edi

v1 = *a1;
if ( !*a1 )
return 0;
v2 = a1;
v3 = 0;
v4 = 255 - (_DWORD)a1;
do
{
v3 += (v4 + (_DWORD)v2++) * v1;
v1 = *v2;
}
while ( *v2 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int8 *a1)
{
unsigned __int8 v1; // al
unsigned __int8 *v2; // rdx
unsigned int v3; // esi
int v4; // edi

v1 = *a1;
if ( !*a1 )
return 0;
v2 = a1;
v3 = 0;
v4 = 255 - (_DWORD)a1;
do
{
v3 += (v4 + (_DWORD)v2++) * v1;
v1 = *v2;
}
while ( *v2 );
return v3;
}

original_code:
static int make_msg_id(char *in)
{
 int i;
 int ID = 0;
 for(i = 0; *in; in++, i++) {
  ID += (int)( (i+255) * (unsigned char)*in );
 }
 return ID;
}

variable_types:
in
char *

variable_types: ID int


decompiled_code:
__int64 __fastcall check_repeat_char(const char *a1)
{
size_t v1; // rdx
const char *v2; // rax
__int64 v3; // rcx
int v4; // edx

v1 = strlen(a1);
v2 = a1;
v3 = (__int64)&a1[v1 - 1];
v4 = 0;
while ( 1 )
{
if ( v2 == (const char *)v3 )
return 0LL;
if ( *v2 == v2[1] )
break;
v4 = 0;
LABEL_3:
++v2;
}
if ( config[255] > ++v4 )
goto LABEL_3;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1)
{
size_t v1; // rdx
const char *v2; // rax
__int64 v3; // rcx
int v4; // edx

v1 = strlen(a1);
v2 = a1;
v3 = (__int64)&a1[v1 - 1];
v4 = 0;
while ( 1 )
{
if ( v2 == (const char *)v3 )
return 0LL;
if ( *v2 == v2[1] )
break;
v4 = 0;
LABEL_3:
++v2;
}
if ( config[255] > ++v4 )
goto LABEL_3;
return 1LL;
}

original_code:
static int check_repeat_char(char *text)
{
 int count = 0, i = 0;
 for(; i < strlen(text) - 1; i++)
 {
  if(text[i] == text[i+1]) {
   if(++count >= config.repeatchar_lim)
    return 1;
  }
  else
   count = 0;
 }
 return 0;
}

canonical_original_code:
static int check_repeat_char(char *text)
{
 int count = 0; int i = 0;
 for(; i < strlen(text) - 1; i++)
 {
  if(text[i] == text[i+1]) {
   if(++count >= config.repeatchar_lim)
    return 1;
  }
  else
   count = 0;
 }
 return 0;
}

variable_types: count int


decompiled_code:
int init_regex()
{
regcomp(&swear_norm, "f[uv\\*]+[c\\*]+k|sh+[i\\*]+t|c[uv]+n+t", 9);
regcomp(&swear_mild, "c[o\\*]+ck|as+ho+le|arseho+le|bollock|bastard|wank", 9);
regcomp(&lamehost_5, "^(by|all)$", 11);
regcomp(&lamehost_10, "^(at|in|you|if|just|like|ein|bei|my|it|get)$", 11);
regcomp(&lamehost_15, "^(is|the|for|your|a|that|and|are|suck|i|a|dont|ist)$", 11);
return regcomp(
&safehosts,
"\\.(edu|ac\\.uk|pol\\.co\\.uk|blueyonder\\.co\\.uk|netgamers\\.org|chello\\.nl|online\\.no|ntl\\.com|aol\\.co"
"m|t-dialin\\.net)$",
9);
}

canonical_decompiled_code:
int func7()
{
regcomp(&swear_norm, "f[uv\\*]+[c\\*]+k|sh+[i\\*]+t|c[uv]+n+t", 9);
regcomp(&swear_mild, "c[o\\*]+ck|as+ho+le|arseho+le|bollock|bastard|wank", 9);
regcomp(&lamehost_5, "^(by|all)$", 11);
regcomp(&lamehost_10, "^(at|in|you|if|just|like|ein|bei|my|it|get)$", 11);
regcomp(&lamehost_15, "^(is|the|for|your|a|that|and|are|suck|i|a|dont|ist)$", 11);
return regcomp(
&safehosts,
"\\.(edu|ac\\.uk|pol\\.co\\.uk|blueyonder\\.co\\.uk|netgamers\\.org|chello\\.nl|online\\.no|ntl\\.com|aol\\.co"
"m|t-dialin\\.net)$",
9);
}

original_code:
void init_regex()
{
 regcomp(&swear_norm, "f[uv\\*]+[c\\*]+k|sh+[i\\*]+t|c[uv]+n+t", 1|(1 << 3));
 regcomp(&swear_mild, "c[o\\*]+ck|as+ho+le|arseho+le|bollock|bastard|wank", 1|(1 << 3));
 regcomp(&lamehost_5, "^(by|all)$", 1|(1 << 3)|(1 << 1));
 regcomp(&lamehost_10, "^(at|in|you|if|just|like|ein|bei|my|it|get)$", 1|(1 << 3)|(1 << 1));
 regcomp(&lamehost_15, "^(is|the|for|your|a|that|and|are|suck|i|a|dont|ist)$", 1|(1 << 3)|(1 << 1));
 regcomp(&safehosts, "\\.(edu|ac\\.uk|pol\\.co\\.uk|blueyonder\\.co\\.uk|netgamers\\.org|chello\\.nl|online\\.no|ntl\\.com|aol\\.com|t-dialin\\.net)$", 1|(1 << 3));
 return;
}


decompiled_code:
void free_regex()
{
regfree(&swear_norm);
regfree(&swear_mild);
regfree(&lamehost_5);
regfree(&lamehost_10);
regfree(&lamehost_15);
regfree(&safehosts);
}

canonical_decompiled_code:
void func8()
{
regfree(&swear_norm);
regfree(&swear_mild);
regfree(&lamehost_5);
regfree(&lamehost_10);
regfree(&lamehost_15);
regfree(&safehosts);
}

original_code:
void free_regex()
{
 regfree(&swear_norm);
 regfree(&swear_mild);
 regfree(&lamehost_5);
 regfree(&lamehost_10);
 regfree(&lamehost_15);
 regfree(&safehosts);
 return;
}


decompiled_code:
char __fastcall chan_msg(__int64 a1, __int64 a2, char *a3, __int64 a4, __int64 a5, char a6)
{
__int64 v6; // rbx
char *v9; // rax
const char **v10; // r12
__int64 v11; // rdi
char *v12; // rbx
bool v13; // zf
time_t v14; // rbp
const char *v15; // rdx
int v16; // eax
time_t v17; // rbp
int v18; // eax
__int64 v19; // rbx
int v20; // ebp
time_t v21; // r14
__int64 v22; // rax
__int64 v23; // rax
int v24; // eax
int v25; // eax
int v26; // edx
__int64 v27; // rax
__int64 v28; // rax
char *v29; // rax
__int64 v30; // rax
int v31; // edx
__int64 v32; // rax
__int64 v33; // rax
__int64 v34; // rax
__int64 v35; // rax
__int64 v36; // rax
unsigned int v37; // eax
__int64 v38; // rax
unsigned int v39; // eax
__int64 v40; // rax
char v42; // [rsp+8h] [rbp-460h]
int v43; // [rsp+14h] [rbp-454h]
int v46; // [rsp+24h] [rbp-444h]
__int64 v47; // [rsp+28h] [rbp-440h]
char v48[512]; // [rsp+30h] [rbp-438h] BYREF
char s[568]; // [rsp+230h] [rbp-238h] BYREF

v6 = a1;
v9 = (char *)fetchChanRec(a2);
if ( !v9 )
return (char)v9;
v10 = (const char **)v9;
v11 = *((_QWORD *)v9 + 22);
if ( !v11 )
return (char)v9;
if ( !*(_QWORD *)a4 )
return (char)v9;
v9 = (char *)findUser(v11, v6);
v12 = v9;
if ( !v9 )
return (char)v9;
*((_DWORD *)v9 + 24) = time(0LL);
v13 = memcmp(*(const void **)(a4 + 24), &unk_F95, 9uLL) == 0;
LOBYTE(v9) = !v13;
if ( v13 )
{
a3 += 8;
}
else if ( *a3 == 1 )
{
if ( a3[strlen(a3) - 1] == 1 && strchr((const char *)v10 + 8, 105) )
{
v22 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v22, 105LL, 0LL, 0LL);
return (char)v9;
}
goto LABEL_11;
}
if ( !*a3 )
return (char)v9;
LABEL_11:
perform_basic_strip(s, a3);
if ( strchr((const char *)v10 + 8, 98) )
{
set_lower_message(v48, s);
if ( (unsigned int)match_badurl(v48) )
{
v23 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v23, 98LL, 0LL, 0LL);
return (char)v9;
}
}
if ( strchr((const char *)v10 + 8, 102) )
{
v14 = *((int *)v10[22] + 162);
if ( v14 < time(0LL) - (int)config[261] )
{
*((_DWORD *)v10[22] + 162) = time(0LL);
*((_DWORD *)v10[22] + 163) = 1;
}
else
{
v15 = v10[22];
v16 = *((_DWORD *)v15 + 163) + 1;
*((_DWORD *)v15 + 163) = v16;
if ( v16 >= config[262] )
{
*((_DWORD *)v10[22] + 162) = 0;
*((_DWORD *)v10[22] + 163) = 0;
sprintf(s, "MODE %s +m", *v10);
irc_write(s);
sprintf(s, "NOTICE %s :Suspected flood attempt, locking channel.", *v10);
LOBYTE(v9) = highMsg(s);
return (char)v9;
}
}
v17 = *((int *)v12 + 19);
if ( v17 < time(0LL) - (int)config[263] )
{
*((_DWORD *)v12 + 19) = time(0LL);
*((_DWORD *)v12 + 20) = 1;
}
else
{
v18 = *((_DWORD *)v12 + 20) + 1;
*((_DWORD *)v12 + 20) = v18;
if ( v18 >= config[264] )
{
v24 = time(0LL);
sprintf(s, "%d lines in %d secs", *((unsigned int *)v12 + 20), (unsigned int)(v24 - *((_DWORD *)v12 + 19)));
LOBYTE(v9) = punish_user(v10, v12, 102LL, 0LL, s);
*((_DWORD *)v12 + 20) = 0;
*((_DWORD *)v12 + 19) = 0;
return (char)v9;
}
}
}
if ( strchr((const char *)v10 + 8, 114) )
{
v46 = make_msg_id((unsigned __int8 *)s);
v47 = findCriminal(v10[22], a1);
if ( !v47 )
{
v9 = (char *)nu_add(v10[22], a1, a1 + 33, a1 + 66);
v47 = (__int64)v9;
if ( !v9 )
return (char)v9;
}
v19 = v47 + 64;
v20 = 0;
v43 = -1;
v21 = strlen(s) < 5 ? 6 : 30;
do
{
if ( time(0LL) - *(int *)(v19 + 4) <= v21 )
{
if ( *(_DWORD *)v19 )
{
if ( *(_DWORD *)v19 == v46 )
{
*(_DWORD *)(v19 + 4) = time(0LL);
v42 = *(_BYTE *)(v19 + 8);
*(_BYTE *)(v19 + 8) = v42 + 1;
v25 = (char)(v42 + 1);
v26 = config[271];
if ( v25 > v26 )
{
v27 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v27, 114LL, 1LL, 0LL);
return (char)v9;
}
if ( v25 == v26 )
{
v28 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v28, 114LL, 0LL, 0LL);
return (char)v9;
}
v43 = -1;
}
}
else
{
v43 = v20;
}
}
else
{
*(_DWORD *)v19 = 0;
v43 = v20;
}
++v20;
v19 += 12LL;
}
while ( v20 != 30 );
if ( v43 >= 0 )
{
*(_DWORD *)(v47 + 12LL * v43 + 64) = v46;
v31 = time(0LL);
v32 = 3LL * v43;
*(_DWORD *)(v47 + 4 * v32 + 68) = v31;
*(_BYTE *)(v47 + 4 * v32 + 72) = 1;
}
}
v29 = strchr((const char *)v10 + 8, 110);
if ( a6 && v29 )
{
v33 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v33, 110LL, 0LL, 0LL);
}
else
{
if ( strchr((const char *)v10 + 8, 115) )
{
strip_for_sweartest(v48, s);
if ( regmatch(&swear_norm, v48) )
{
v34 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v34, 115LL, 1LL, 0LL);
return (char)v9;
}
if ( regmatch(&swear_mild, v48) )
{
v35 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v35, 115LL, 0LL, 0LL);
return (char)v9;
}
}
if ( strchr((const char *)v10 + 8, 99) && (unsigned int)count_coloured_chars(a3) )
{
v36 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v36, 99LL, 0LL, 0LL);
}
else if ( strchr((const char *)v10 + 8, 116)
&& strlen(a3) > 7
&& (v37 = ctrlchar_percent(a3), config[254] < (signed int)v37) )
{
sprintf(v48, "%d%%", v37);
v38 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v38, 116LL, 0LL, v48);
}
else if ( strchr((const char *)v10 + 8, 112)
&& strlen(s) > 7
&& (v39 = caps_percent(s), config[253] < (signed int)v39) )
{
sprintf(v48, "%d%%", v39);
v40 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v40, 112LL, 0LL, v48);
}
else
{
v9 = strchr((const char *)v10 + 8, 120);
if ( v9 )
{
LODWORD(v9) = check_repeat_char(s);
if ( (_DWORD)v9 )
{
v30 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v30, 120LL, 0LL, 0LL);
}
}
}
}
return (char)v9;
}

canonical_decompiled_code:
char __fastcall func12(__int64 a1, __int64 a2, char *a3, __int64 a4, __int64 a5, char a6)
{
__int64 v6; // rbx
char *v9; // rax
const char **v10; // r12
__int64 v11; // rdi
char *v12; // rbx
bool v13; // zf
time_t v14; // rbp
const char *v15; // rdx
int v16; // eax
time_t v17; // rbp
int v18; // eax
__int64 v19; // rbx
int v20; // ebp
time_t v21; // r14
__int64 v22; // rax
__int64 v23; // rax
int v24; // eax
int v25; // eax
int v26; // edx
__int64 v27; // rax
__int64 v28; // rax
char *v29; // rax
__int64 v30; // rax
int v31; // edx
__int64 v32; // rax
__int64 v33; // rax
__int64 v34; // rax
__int64 v35; // rax
__int64 v36; // rax
unsigned int v37; // eax
__int64 v38; // rax
unsigned int v39; // eax
__int64 v40; // rax
char v42; // [rsp+8h] [rbp-460h]
int v43; // [rsp+14h] [rbp-454h]
int v46; // [rsp+24h] [rbp-444h]
__int64 v47; // [rsp+28h] [rbp-440h]
char v48[512]; // [rsp+30h] [rbp-438h] BYREF
char s[568]; // [rsp+230h] [rbp-238h] BYREF

v6 = a1;
v9 = (char *)fetchChanRec(a2);
if ( !v9 )
return (char)v9;
v10 = (const char **)v9;
v11 = *((_QWORD *)v9 + 22);
if ( !v11 )
return (char)v9;
if ( !*(_QWORD *)a4 )
return (char)v9;
v9 = (char *)findUser(v11, v6);
v12 = v9;
if ( !v9 )
return (char)v9;
*((_DWORD *)v9 + 24) = time(0LL);
v13 = memcmp(*(const void **)(a4 + 24), &unk_F95, 9uLL) == 0;
LOBYTE(v9) = !v13;
if ( v13 )
{
a3 += 8;
}
else if ( *a3 == 1 )
{
if ( a3[strlen(a3) - 1] == 1 && strchr((const char *)v10 + 8, 105) )
{
v22 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v22, 105LL, 0LL, 0LL);
return (char)v9;
}
goto LABEL_11;
}
if ( !*a3 )
return (char)v9;
LABEL_11:
func5(s, a3);
if ( strchr((const char *)v10 + 8, 98) )
{
func11(v48, s);
if ( (unsigned int)match_badurl(v48) )
{
v23 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v23, 98LL, 0LL, 0LL);
return (char)v9;
}
}
if ( strchr((const char *)v10 + 8, 102) )
{
v14 = *((int *)v10[22] + 162);
if ( v14 < time(0LL) - (int)config[261] )
{
*((_DWORD *)v10[22] + 162) = time(0LL);
*((_DWORD *)v10[22] + 163) = 1;
}
else
{
v15 = v10[22];
v16 = *((_DWORD *)v15 + 163) + 1;
*((_DWORD *)v15 + 163) = v16;
if ( v16 >= config[262] )
{
*((_DWORD *)v10[22] + 162) = 0;
*((_DWORD *)v10[22] + 163) = 0;
sprintf(s, "MODE %s +m", *v10);
irc_write(s);
sprintf(s, "NOTICE %s :Suspected flood attempt, locking channel.", *v10);
LOBYTE(v9) = highMsg(s);
return (char)v9;
}
}
v17 = *((int *)v12 + 19);
if ( v17 < time(0LL) - (int)config[263] )
{
*((_DWORD *)v12 + 19) = time(0LL);
*((_DWORD *)v12 + 20) = 1;
}
else
{
v18 = *((_DWORD *)v12 + 20) + 1;
*((_DWORD *)v12 + 20) = v18;
if ( v18 >= config[264] )
{
v24 = time(0LL);
sprintf(s, "%d lines in %d secs", *((unsigned int *)v12 + 20), (unsigned int)(v24 - *((_DWORD *)v12 + 19)));
LOBYTE(v9) = punish_user(v10, v12, 102LL, 0LL, s);
*((_DWORD *)v12 + 20) = 0;
*((_DWORD *)v12 + 19) = 0;
return (char)v9;
}
}
}
if ( strchr((const char *)v10 + 8, 114) )
{
v46 = func3((unsigned __int8 *)s);
v47 = findCriminal(v10[22], a1);
if ( !v47 )
{
v9 = (char *)nu_add(v10[22], a1, a1 + 33, a1 + 66);
v47 = (__int64)v9;
if ( !v9 )
return (char)v9;
}
v19 = v47 + 64;
v20 = 0;
v43 = -1;
v21 = strlen(s) < 5 ? 6 : 30;
do
{
if ( time(0LL) - *(int *)(v19 + 4) <= v21 )
{
if ( *(_DWORD *)v19 )
{
if ( *(_DWORD *)v19 == v46 )
{
*(_DWORD *)(v19 + 4) = time(0LL);
v42 = *(_BYTE *)(v19 + 8);
*(_BYTE *)(v19 + 8) = v42 + 1;
v25 = (char)(v42 + 1);
v26 = config[271];
if ( v25 > v26 )
{
v27 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v27, 114LL, 1LL, 0LL);
return (char)v9;
}
if ( v25 == v26 )
{
v28 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v28, 114LL, 0LL, 0LL);
return (char)v9;
}
v43 = -1;
}
}
else
{
v43 = v20;
}
}
else
{
*(_DWORD *)v19 = 0;
v43 = v20;
}
++v20;
v19 += 12LL;
}
while ( v20 != 30 );
if ( v43 >= 0 )
{
*(_DWORD *)(v47 + 12LL * v43 + 64) = v46;
v31 = time(0LL);
v32 = 3LL * v43;
*(_DWORD *)(v47 + 4 * v32 + 68) = v31;
*(_BYTE *)(v47 + 4 * v32 + 72) = 1;
}
}
v29 = strchr((const char *)v10 + 8, 110);
if ( a6 && v29 )
{
v33 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v33, 110LL, 0LL, 0LL);
}
else
{
if ( strchr((const char *)v10 + 8, 115) )
{
func6(v48, s);
if ( func9(&swear_norm, v48) )
{
v34 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v34, 115LL, 1LL, 0LL);
return (char)v9;
}
if ( func9(&swear_mild, v48) )
{
v35 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v35, 115LL, 0LL, 0LL);
return (char)v9;
}
}
if ( strchr((const char *)v10 + 8, 99) && (unsigned int)func0(a3) )
{
v36 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v36, 99LL, 0LL, 0LL);
}
else if ( strchr((const char *)v10 + 8, 116)
&& strlen(a3) > 7
&& (v37 = func2(a3), config[254] < (signed int)v37) )
{
sprintf(v48, "%d%%", v37);
v38 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v38, 116LL, 0LL, v48);
}
else if ( strchr((const char *)v10 + 8, 112)
&& strlen(s) > 7
&& (v39 = func1(s), config[253] < (signed int)v39) )
{
sprintf(v48, "%d%%", v39);
v40 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v40, 112LL, 0LL, v48);
}
else
{
v9 = strchr((const char *)v10 + 8, 120);
if ( v9 )
{
LODWORD(v9) = func4(s);
if ( (_DWORD)v9 )
{
v30 = findUser(v10[22], a1);
LOBYTE(v9) = punish_user(v10, v30, 120LL, 0LL, 0LL);
}
}
}
}
return (char)v9;
}

original_code:
void chan_msg(sUser *theUser, char *channel, char *message, char *tokens[], int *ctok, char isNotice)
{
 struct chanRec *theChan;
 struct criminalRecord *userRec;
 char stripped_message[512];
 struct suser *u;
 char isAction = 0;
 theChan = fetchChanRec(channel);
 userRec = ((void *)0);
 if(!theChan || !theChan->physical || !tokens[0])
  return;
 if(!(u = findUser(theChan->physical, theUser->nick)))
  return;
 u->idleMsg = time(0);
 if(!strcmp(tokens[3], ":\001ACTION")) {
  isAction = 1;
  message += 8;
 } else if((message[0] == '\001') && (message[strlen(message)-1] == '\001') && strchr(theChan->flags, 'i')) {
  punish_user(theChan, findUser(theChan->physical, theUser->nick), 'i', 0, 0);
  return;
 }
 if(!(*message))
  return;
 perform_basic_strip(stripped_message, message);
 if(strchr(theChan->flags, 'b')) {
  char lower_message[512];
  set_lower_message(lower_message, stripped_message);
  if(match_badurl(lower_message)) {
   punish_user(theChan, findUser(theChan->physical, theUser->nick), 'b', 0, 0);
   return;
  }
 }
 if(strchr(theChan->flags, 'f')) {
  if(theChan->physical->flood_last < (time(0) - config.flood_global_period)) {
   theChan->physical->flood_last = time(0);
   theChan->physical->flood_lines = 1;
  } else {
   if(++theChan->physical->flood_lines >= config.flood_global_limit) {
    theChan->physical->flood_lines = theChan->physical->flood_last = 0;
    sprintf(stripped_message, "MODE %s +m", theChan->name);
    irc_write(stripped_message);
    sprintf(stripped_message, "NOTICE %s :Suspected flood attempt, locking channel.", theChan->name);
    highMsg(stripped_message);
    return;
   }
  }
  if(!u)
   return;
  if(u->lastMsg < (time(0) - config.flood_period)) {
   u->lastMsg = time(0);
   u->flines = 1;
  } else {
   if(++u->flines >= config.flood_limit) {
    sprintf(stripped_message, "%d lines in %d secs", u->flines, (int)(time(0) - u->lastMsg));
    punish_user(theChan, u, 'f', 0, stripped_message);
    u->flines = 0;
    u->lastMsg = 0;
    return;
   }
  }
 }
 if(strchr(theChan->flags, 'r')) {
  struct criminalRecord *c;
  int repeat_period, addid, i;
  int msgid = make_msg_id(stripped_message);
  c = findCriminal(theChan->physical, theUser->nick);
  if(!c) {
   c = nu_add(theChan->physical, theUser->nick, theUser->ident, theUser->host);
   if(!c) return;
  }
  repeat_period = (strlen(stripped_message) < 5) ? 6 : 30;
  addid = -1;
  for(i = 0; i < 30; i++)
  {
   if(time(0) - c->trackrepeat[i].ts > repeat_period) {
    c->trackrepeat[i].id = 0;
    addid = i;
   }
   else if(c->trackrepeat[i].id == 0)
    addid = i;
   else if(c->trackrepeat[i].id == msgid) {
    c->trackrepeat[i].ts = time(0);
    if(++c->trackrepeat[i].count > config.repeat_limit) {
     punish_user(theChan, findUser(theChan->physical, theUser->nick), 'r', 1, 0);
     return;
    } else if(c->trackrepeat[i].count == config.repeat_limit) {
     punish_user(theChan, findUser(theChan->physical, theUser->nick), 'r', 0, 0);
     return;
    }
    addid = -1;
   }
  }
  if(addid >= 0) {
   c->trackrepeat[addid].id = msgid;
   c->trackrepeat[addid].ts = time(0);
   c->trackrepeat[addid].count = 1;
  }
 }
 if(strchr(theChan->flags, 'n') && isNotice) {
  punish_user(theChan, findUser(theChan->physical, theUser->nick), 'n', 0, 0);
  return;
 }
 if(strchr(theChan->flags, 's')) {
  char swear_match_message[512];
  strip_for_sweartest(swear_match_message, stripped_message);
  if(regmatch(&swear_norm, swear_match_message)) {
   punish_user(theChan, findUser(theChan->physical, theUser->nick), 's', 1, 0);
   return;
  } else if(regmatch(&swear_mild, swear_match_message)) {
   punish_user(theChan, findUser(theChan->physical, theUser->nick), 's', 0, 0);
   return;
  }
 }
 if(strchr(theChan->flags, 'c') && (count_coloured_chars(message))) {
  punish_user(theChan, findUser(theChan->physical, theUser->nick), 'c', 0, 0);
  return;
 }
 if(strchr(theChan->flags, 't') && (strlen(message) > 7)) {
  int percent = ctrlchar_percent(message);
  if(percent > config.ctrlchar_max) {
   char numbuf[8];
   sprintf(numbuf, "%d%%", percent);
   punish_user(theChan, findUser(theChan->physical, theUser->nick), 't', 0, numbuf);
   return;
  }
 }
 if(strchr(theChan->flags, 'p') && (strlen(stripped_message) > 7)) {
  int percent = caps_percent(stripped_message);
  if(percent > config.caps_max) {
   char numbuf[8];
   sprintf(numbuf, "%d%%", percent);
   punish_user(theChan, findUser(theChan->physical, theUser->nick), 'p', 0, numbuf);
   return;
  }
 }
 if(strchr(theChan->flags, 'x') && check_repeat_char(stripped_message)) {
  punish_user(theChan, findUser(theChan->physical, theUser->nick), 'x', 0, 0);
  return;
 }
 return;
}

canonical_original_code:
void chan_msg(struct ircUser *theUser, char *channel, char *message, char *tokens[], int *ctok, char isNotice)
{
 struct chanRec *theChan;
 struct criminalRecord *userRec;
 char stripped_message[512];
 struct suser *u;
 char isAction = 0;
 theChan = fetchChanRec(channel);
 userRec = ((void *)0);
 if(!theChan || !theChan->physical || !tokens[0])
  return;
 if(!(u = findUser(theChan->physical, theUser->nick)))
  return;
 u->idleMsg = time(0);
 if(!strcmp(tokens[3], ":\001ACTION")) {
  isAction = 1;
  message += 8;
 } else if((message[0] == '\001') && (message[strlen(message)-1] == '\001') && strchr(theChan->flags, 'i')) {
  punish_user(theChan, findUser(theChan->physical, theUser->nick), 'i', 0, 0);
  return;
 }
 if(!(*message))
  return;
 perform_basic_strip(stripped_message, message);
 if(strchr(theChan->flags, 'b')) {
  char lower_message[512];
  set_lower_message(lower_message, stripped_message);
  if(match_badurl(lower_message)) {
   punish_user(theChan, findUser(theChan->physical, theUser->nick), 'b', 0, 0);
   return;
  }
 }
 if(strchr(theChan->flags, 'f')) {
  if(theChan->physical->flood_last < (time(0) - config.flood_global_period)) {
   theChan->physical->flood_last = time(0);
   theChan->physical->flood_lines = 1;
  } else {
   if(++theChan->physical->flood_lines >= config.flood_global_limit) {
    theChan->physical->flood_lines = theChan->physical->flood_last = 0;
    sprintf(stripped_message, "MODE %s +m", theChan->name);
    irc_write(stripped_message);
    sprintf(stripped_message, "NOTICE %s :Suspected flood attempt, locking channel.", theChan->name);
    highMsg(stripped_message);
    return;
   }
  }
  if(!u)
   return;
  if(u->lastMsg < (time(0) - config.flood_period)) {
   u->lastMsg = time(0);
   u->flines = 1;
  } else {
   if(++u->flines >= config.flood_limit) {
    sprintf(stripped_message, "%d lines in %d secs", u->flines, (int)(time(0) - u->lastMsg));
    punish_user(theChan, u, 'f', 0, stripped_message);
    u->flines = 0;
    u->lastMsg = 0;
    return;
   }
  }
 }
 if(strchr(theChan->flags, 'r')) {
  struct criminalRecord *c;
  int repeat_period; int addid; int i;
  int msgid = make_msg_id(stripped_message);
  c = findCriminal(theChan->physical, theUser->nick);
  if(!c) {
   c = nu_add(theChan->physical, theUser->nick, theUser->ident, theUser->host);
   if(!c) return;
  }
  repeat_period = (strlen(stripped_message) < 5) ? 6 : 30;
  addid = -1;
  for(i = 0; i < 30; i++)
  {
   if(time(0) - c->trackrepeat[i].ts > repeat_period) {
    c->trackrepeat[i].id = 0;
    addid = i;
   }
   else if(c->trackrepeat[i].id == 0)
    addid = i;
   else if(c->trackrepeat[i].id == msgid) {
    c->trackrepeat[i].ts = time(0);
    if(++c->trackrepeat[i].count > config.repeat_limit) {
     punish_user(theChan, findUser(theChan->physical, theUser->nick), 'r', 1, 0);
     return;
    } else if(c->trackrepeat[i].count == config.repeat_limit) {
     punish_user(theChan, findUser(theChan->physical, theUser->nick), 'r', 0, 0);
     return;
    }
    addid = -1;
   }
  }
  if(addid >= 0) {
   c->trackrepeat[addid].id = msgid;
   c->trackrepeat[addid].ts = time(0);
   c->trackrepeat[addid].count = 1;
  }
 }
 if(strchr(theChan->flags, 'n') && isNotice) {
  punish_user(theChan, findUser(theChan->physical, theUser->nick), 'n', 0, 0);
  return;
 }
 if(strchr(theChan->flags, 's')) {
  char swear_match_message[512];
  strip_for_sweartest(swear_match_message, stripped_message);
  if(regmatch(&swear_norm, swear_match_message)) {
   punish_user(theChan, findUser(theChan->physical, theUser->nick), 's', 1, 0);
   return;
  } else if(regmatch(&swear_mild, swear_match_message)) {
   punish_user(theChan, findUser(theChan->physical, theUser->nick), 's', 0, 0);
   return;
  }
 }
 if(strchr(theChan->flags, 'c') && (count_coloured_chars(message))) {
  punish_user(theChan, findUser(theChan->physical, theUser->nick), 'c', 0, 0);
  return;
 }
 if(strchr(theChan->flags, 't') && (strlen(message) > 7)) {
  int percent = ctrlchar_percent(message);
  if(percent > config.ctrlchar_max) {
   char numbuf[8];
   sprintf(numbuf, "%d%%", percent);
   punish_user(theChan, findUser(theChan->physical, theUser->nick), 't', 0, numbuf);
   return;
  }
 }
 if(strchr(theChan->flags, 'p') && (strlen(stripped_message) > 7)) {
  int percent = caps_percent(stripped_message);
  if(percent > config.caps_max) {
   char numbuf[8];
   sprintf(numbuf, "%d%%", percent);
   punish_user(theChan, findUser(theChan->physical, theUser->nick), 'p', 0, numbuf);
   return;
  }
 }
 if(strchr(theChan->flags, 'x') && check_repeat_char(stripped_message)) {
  punish_user(theChan, findUser(theChan->physical, theUser->nick), 'x', 0, 0);
  return;
 }
 return;
}

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

variable_types:
channel
char *

variable_types:
message
char *

variable_types:
tokens
char *[]

variable_types:
ctok
int *

variable_types: isNotice char

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

variable_types: isAction char

variable_types: addid int

variable_types: msgid int

variable_types: percent int

variable_types:
numbuf
char [8]

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

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


decompiled_code:
char *__fastcall write_cstat_msg(char *dest)
{
__int64 *v1; // rbx
char *result; // rax
char v3[56]; // [rsp+0h] [rbp-38h] BYREF

v1 = &pmap;
do
{
if ( *(char *)v1 > 0 )
{
sprintf(v3, format, v1[1], *((unsigned int *)v1 + 8));
result = strcat(dest, v3);
}
v1 += 5;
}
while ( v1 != (__int64 *)(unsigned int)((_DWORD)&pmap + 1040) );
return result;
}

canonical_decompiled_code:
char *__fastcall func0(char *dest)
{
__int64 *v1; // rbx
char *result; // rax
char v3[56]; // [rsp+0h] [rbp-38h] BYREF

v1 = &pmap;
do
{
if ( *(char *)v1 > 0 )
{
sprintf(v3, format, v1[1], *((unsigned int *)v1 + 8));
result = strcat(dest, v3);
}
v1 += 5;
}
while ( v1 != (__int64 *)(unsigned int)((_DWORD)&pmap + 1040) );
return result;
}

original_code:
void write_cstat_msg(char *buffer)
{
 char smallbuf[32];
 int i;
 for(i = 0; i < 26; i++)
 {
  if(pmap[i].weight > 0)
  {
   sprintf(smallbuf, "%s(\002%d\002) ", pmap[i].shortName, pmap[i].counter);
   strcat(buffer, smallbuf);
  }
 }
 return;
}

variable_types:
buffer
char *

variable_types:
smallbuf
char [32]

variable_types: i int


decompiled_code:
void __fastcall punish_user(const char **a1, __int64 a2, unsigned __int8 a3, char a4, const char *a5)
{
unsigned int v8; // ebx
__int64 v9; // r15
char v10; // al
char v11[256]; // [rsp-100h] [rbp-158h] BYREF
char v12[88]; // [rsp+0h] [rbp-58h] BYREF

if ( a2 )
{
if ( a1 )
{
if ( a1[22] )
{
if ( !(unsigned int)check_dependants() )
{
v8 = a3 - 97;
if ( v8 <= 0x19 )
{
if ( *(_BYTE *)(a2 + 73) && !strchr((const char *)a1 + 8, 111) )
{
snprintf(punbuf, 0x1F4uLL, asc_C60, *a1, *(_QWORD *)(a2 + 56), pmap[5 * (int)v8 + 1]);
sRelay(punbuf);
return;
}
v9 = findCriminal(a1[22], a2);
if ( v9 )
{
*(_DWORD *)(v9 + 52) = time(0LL);
}
else
{
v9 = nu_add(a1[22], a2, *(_QWORD *)(a2 + 40), *(_QWORD *)(a2 + 48));
if ( !v9 )
return;
}
*(_BYTE *)(v9 + 48) += LOBYTE(pmap[5 * (int)v8]) + a4;
*(_BYTE *)(v9 + 49) += LOBYTE(pmap[5 * (int)v8]) + a4;
if ( time(0LL) - *(int *)(a2 + 84) <= 59 )
{
++*(_BYTE *)(v9 + 49);
*(_BYTE *)(v9 + 48) += 2;
}
if ( a5 )
snprintf(v11, 0xFAuLL, "%s (%s)", (const char *)pmap[5 * (int)v8 + 2], a5);
else
mystrncpy(v11, pmap[5 * (int)v8 + 2], 250LL);
v10 = *(_BYTE *)(v9 + 49);
if ( v10 <= 1 )
{
snprintf(punbuf, 0x1FEuLL, (const char *)(unsigned int)((_DWORD)&config + 709), a2, *a1, v11);
quickMsg(punbuf);
strcpy(v12, "warn");
}
else if ( v10 == 2 )
{
snprintf(punbuf, 0x1FEuLL, "KICK %s %s :[Warning] %s", *a1, (const char *)a2, v11);
quickMsg(punbuf);
strcpy(v12, "kick");
}
else
{
*(_BYTE *)(v9 + 49) = 0;
sprintf(punbuf, "*!*@%s", *(const char **)(a2 + 48));
normal_ban(a1, punbuf, "Auto", (unsigned int)(*(_DWORD *)pmap[5 * (int)v8 + 3] * *(char *)(v9 + 48)), v11);
strcpy(v12, "ban");
}
sprintf(punbuf, asc_C98, *a1, a2, (unsigned int)*(char *)(v9 + 48), pmap[5 * (int)v8 + 1], v12);
sRelay(punbuf);
++LODWORD(pmap[5 * (int)v8 + 4]);
}
}
}
}
}
}

canonical_decompiled_code:
void __fastcall func1(const char **a1, __int64 a2, unsigned __int8 a3, char a4, const char *a5)
{
unsigned int v8; // ebx
__int64 v9; // r15
char v10; // al
char v11[256]; // [rsp-100h] [rbp-158h] BYREF
char v12[88]; // [rsp+0h] [rbp-58h] BYREF

if ( a2 )
{
if ( a1 )
{
if ( a1[22] )
{
if ( !(unsigned int)check_dependants() )
{
v8 = a3 - 97;
if ( v8 <= 0x19 )
{
if ( *(_BYTE *)(a2 + 73) && !strchr((const char *)a1 + 8, 111) )
{
snprintf(punbuf, 0x1F4uLL, asc_C60, *a1, *(_QWORD *)(a2 + 56), pmap[5 * (int)v8 + 1]);
sRelay(punbuf);
return;
}
v9 = findCriminal(a1[22], a2);
if ( v9 )
{
*(_DWORD *)(v9 + 52) = time(0LL);
}
else
{
v9 = nu_add(a1[22], a2, *(_QWORD *)(a2 + 40), *(_QWORD *)(a2 + 48));
if ( !v9 )
return;
}
*(_BYTE *)(v9 + 48) += LOBYTE(pmap[5 * (int)v8]) + a4;
*(_BYTE *)(v9 + 49) += LOBYTE(pmap[5 * (int)v8]) + a4;
if ( time(0LL) - *(int *)(a2 + 84) <= 59 )
{
++*(_BYTE *)(v9 + 49);
*(_BYTE *)(v9 + 48) += 2;
}
if ( a5 )
snprintf(v11, 0xFAuLL, "%s (%s)", (const char *)pmap[5 * (int)v8 + 2], a5);
else
mystrncpy(v11, pmap[5 * (int)v8 + 2], 250LL);
v10 = *(_BYTE *)(v9 + 49);
if ( v10 <= 1 )
{
snprintf(punbuf, 0x1FEuLL, (const char *)(unsigned int)((_DWORD)&config + 709), a2, *a1, v11);
quickMsg(punbuf);
strcpy(v12, "warn");
}
else if ( v10 == 2 )
{
snprintf(punbuf, 0x1FEuLL, "KICK %s %s :[Warning] %s", *a1, (const char *)a2, v11);
quickMsg(punbuf);
strcpy(v12, "kick");
}
else
{
*(_BYTE *)(v9 + 49) = 0;
sprintf(punbuf, "*!*@%s", *(const char **)(a2 + 48));
normal_ban(a1, punbuf, "Auto", (unsigned int)(*(_DWORD *)pmap[5 * (int)v8 + 3] * *(char *)(v9 + 48)), v11);
strcpy(v12, "ban");
}
sprintf(punbuf, asc_C98, *a1, a2, (unsigned int)*(char *)(v9 + 48), pmap[5 * (int)v8 + 1], v12);
sRelay(punbuf);
++LODWORD(pmap[5 * (int)v8 + 4]);
}
}
}
}
}
}

original_code:
void punish_user(struct chanRec *theChan, struct suser *theUser, char type, char subtype, char *extra)
{
 struct punishment *p;
 struct criminalRecord *c;
 char action[32];
 char reason[250];
 int index = ((int)((unsigned char)type - 97));
 if(!theUser || !theChan || !theChan->physical)
  return;
 if(check_dependants(theChan->physical))
  return;
 if((index < 0) || (index > 25))
  return;
 p = &pmap[index];
 if(theUser->isOp && !strchr(theChan->flags, 'o')) {
  snprintf(punbuf, 500, "[\002%s\002] %s triggered '%s' punishment, but is an op.",
   theChan->name, theUser->mask, p->shortName);
  sRelay(punbuf);
  return;
 }
 c = findCriminal(theChan->physical, theUser->nick);
 if(!c) {
  c = nu_add(theChan->physical, theUser->nick, theUser->ident, theUser->host);
  if(!c)
   return;
 } else {
  c->laststamp = time(((void *)0));
 }
 c->longTerm += p->weight + subtype;
 c->shortTerm += p->weight + subtype;
 if(time(((void *)0)) - theUser->joinTime < 60) {
  c->shortTerm++;
  c->longTerm += 2;
 }
 if(extra)
  snprintf(reason, 250, "%s (%s)", p->reason, extra);
 else
  mystrncpy(reason, p->reason, 250);
 if(c->shortTerm <= 1) {
  snprintf(punbuf, 510, config.warntemplate, theUser->nick, theChan->name, reason);
  quickMsg(punbuf);
  strcpy(action, "warn");
 } else if(c->shortTerm == 2) {
  snprintf(punbuf, 510, "KICK %s %s :[Warning] %s", theChan->name, theUser->nick, reason);
  quickMsg(punbuf);
  strcpy(action, "kick");
 } else {
  c->shortTerm = 0;
  sprintf(punbuf, "*!*@%s", theUser->host);
  normal_ban(theChan, punbuf, "Auto", (c->longTerm * (*p->banlen)), reason);
  strcpy(action, "ban");
 }
 sprintf(punbuf, "[\002%s\002] Criminal: %s, Karma: %d, Offence: %s, Action Taken: %s", theChan->name, theUser->nick, c->longTerm, p->shortName, action);
 sRelay(punbuf);
 p->counter++;
 return;
}

variable_types:
theUser
struct suser *

variable_types: type char

variable_types: subtype char

variable_types:
extra
char *

variable_types: struct punishment { char weight; char *shortName; char *reason; int *banlen; int counter; } *

variable_types: 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; } *

variable_types:
action
char [32]

variable_types:
reason
char [250]

variable_types: index int

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


decompiled_code:
int __fastcall syntax_err(unsigned int a1, const char *a2)
{
char v3[1032]; // [rsp+0h] [rbp-408h] BYREF

sprintf(v3, "Syntax warning, line %d: %s", a1, a2);
sRelay(v3);
*(_WORD *)&v3[strlen(v3)] = 10;
return fprintf(out, v3);
}

canonical_decompiled_code:
int __fastcall func0(unsigned int a1, const char *a2)
{
char v3[1032]; // [rsp+0h] [rbp-408h] BYREF

sprintf(v3, "Syntax warning, line %d: %s", a1, a2);
sRelay(v3);
*(_WORD *)&v3[strlen(v3)] = 10;
return fprintf(out, v3);
}

original_code:
static void syntax_err(int line, char *reason)
{
 char eb[1024];
 sprintf(eb, "Syntax warning, line %d: %s", line, reason);
 sRelay(eb);
 strcat(eb, "\n");
 fprintf(out, eb);
 return;
}

variable_types: line int

variable_types:
reason
char *

variable_types:
eb
char [1024]


decompiled_code:
__int64 __fastcall bad_config(int a1)
{
__int64 result; // rax
char v2[1032]; // [rsp+0h] [rbp-408h] BYREF

sprintf(v2, "Bad config, missing required field: '%s'", (&setmap)[4 * a1]);
if ( !gotworkingcfg )
{
*(_WORD *)&v2[strlen(v2)] = 10;
fprintf(out, v2);
exit(0);
}
strcat(v2, "Reverting to previous config.");
sRelay(v2);
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)
{
__int64 result; // rax
char v2[1032]; // [rsp+0h] [rbp-408h] BYREF

sprintf(v2, "Bad config, missing required field: '%s'", (&setmap)[4 * a1]);
if ( !gotworkingcfg )
{
*(_WORD *)&v2[strlen(v2)] = 10;
fprintf(out, v2);
exit(0);
}
strcat(v2, "Reverting to previous config.");
sRelay(v2);
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;
}


decompiled_code:
int __fastcall dealwith_line(unsigned int a1, __int64 a2, __int64 a3, const char *a4)
{
__int64 v7; // rbx
const char *v8; // rdi
int *v9; // rax
int v10; // edx
size_t v11; // rcx
int v12; // eax

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 )
{
LODWORD(v9) = syntax_err(a1, "Variable name not recognised");
return (int)v9;
}
}
LODWORD(v9) = (unsigned __int8)byte_FF0[32 * (int)v7];
if ( (_BYTE)v9 == 115 )
{
v11 = strlen(a4);
v12 = dword_FF4[8 * (int)v7];
if ( v11 > v12 )
LODWORD(v9) = syntax_err(a1, "Value too long");
else
LODWORD(v9) = mystrncpy(*(&off_FE8 + 4 * (int)v7), a4, v12 + 1);
}
else if ( (_BYTE)v9 == 105 )
{
v10 = atoi(a4);
v9 = (int *)*(&off_FE8 + 4 * (int)v7);
*v9 = v10;
}
}
else if ( (unsigned int)strmi(a3, "server") )
{
LODWORD(v9) = add_server(a4);
if ( !(_DWORD)v9 )
LODWORD(v9) = fwrite("Warning, MAX_SERVERS exceeded.\n", 1uLL, 0x1FuLL, out);
}
else if ( (unsigned int)strmi(a3, "badurl") )
{
LODWORD(v9) = add_badurl(a4);
}
else if ( (unsigned int)strmi(a3, "word") )
{
LODWORD(v9) = add_word(a4);
}
else if ( (unsigned int)strmi(a3, "vhost") )
{
LODWORD(v9) = add_vhost(a4);
}
else
{
LODWORD(v9) = strmi(a3, "link");
if ( (_DWORD)v9 )
LODWORD(v9) = add_link(a4, 102LL);
}
return (int)v9;
}

canonical_decompiled_code:
int __fastcall func2(unsigned int a1, __int64 a2, __int64 a3, const char *a4)
{
__int64 v7; // rbx
const char *v8; // rdi
int *v9; // rax
int v10; // edx
size_t v11; // rcx
int v12; // eax

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 )
{
LODWORD(v9) = func0(a1, "Variable name not recognised");
return (int)v9;
}
}
LODWORD(v9) = (unsigned __int8)byte_FF0[32 * (int)v7];
if ( (_BYTE)v9 == 115 )
{
v11 = strlen(a4);
v12 = dword_FF4[8 * (int)v7];
if ( v11 > v12 )
LODWORD(v9) = func0(a1, "Value too long");
else
LODWORD(v9) = mystrncpy(*(&off_FE8 + 4 * (int)v7), a4, v12 + 1);
}
else if ( (_BYTE)v9 == 105 )
{
v10 = atoi(a4);
v9 = (int *)*(&off_FE8 + 4 * (int)v7);
*v9 = v10;
}
}
else if ( (unsigned int)strmi(a3, "server") )
{
LODWORD(v9) = add_server(a4);
if ( !(_DWORD)v9 )
LODWORD(v9) = fwrite("Warning, MAX_SERVERS exceeded.\n", 1uLL, 0x1FuLL, out);
}
else if ( (unsigned int)strmi(a3, "badurl") )
{
LODWORD(v9) = add_badurl(a4);
}
else if ( (unsigned int)strmi(a3, "word") )
{
LODWORD(v9) = add_word(a4);
}
else if ( (unsigned int)strmi(a3, "vhost") )
{
LODWORD(v9) = add_vhost(a4);
}
else
{
LODWORD(v9) = strmi(a3, "link");
if ( (_DWORD)v9 )
LODWORD(v9) = add_link(a4, 102LL);
}
return (int)v9;
}

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:
cmd
char *

variable_types:
var
char *

variable_types:
value
char *


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

if ( !config[298] && *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

if ( !config[298] && *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()
{
void **v0; // rbx
int v1; // ebp
int v2; // edx
char v3; // al
const char *v4; // rsi
__int64 result; // rax
int v6; // eax
__int64 v7; // rdx
__int64 v8; // rdx
char *v9; // rdi

v0 = &off_FE8;
v1 = 0;
do
{
v3 = *((_BYTE *)v0 + 8);
if ( v3 == 105 )
{
if ( !*(_DWORD *)*v0 )
{
v2 = *((_DWORD *)v0 + 3);
if ( v2 == -1 )
return bad_config(v1);
*(_DWORD *)*v0 = v2;
}
}
else if ( v3 == 115 && !*(_BYTE *)*v0 )
{
v4 = (const char *)v0[2];
if ( !v4 )
return bad_config(v1);
strcpy((char *)*v0, v4);
}
++v1;
v0 += 4;
}
while ( *(v0 - 1) );
v6 = config[258] / 2;
config[259] = v6;
config[260] = 3 * v6;
if ( (int)config[299] <= 299 )
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;
lastcfg = *(_QWORD *)config;
*(_QWORD *)((char *)&lastcfg + 3308) = *(_QWORD *)&config[827];
v9 = (char *)(((_DWORD)&lastcfg + 8) & 0xFFFFFFF8);
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()
{
void **v0; // rbx
int v1; // ebp
int v2; // edx
char v3; // al
const char *v4; // rsi
__int64 result; // rax
int v6; // eax
__int64 v7; // rdx
__int64 v8; // rdx
char *v9; // rdi

v0 = &off_FE8;
v1 = 0;
do
{
v3 = *((_BYTE *)v0 + 8);
if ( v3 == 105 )
{
if ( !*(_DWORD *)*v0 )
{
v2 = *((_DWORD *)v0 + 3);
if ( v2 == -1 )
return func1(v1);
*(_DWORD *)*v0 = v2;
}
}
else if ( v3 == 115 && !*(_BYTE *)*v0 )
{
v4 = (const char *)v0[2];
if ( !v4 )
return func1(v1);
strcpy((char *)*v0, v4);
}
++v1;
v0 += 4;
}
while ( *(v0 - 1) );
v6 = config[258] / 2;
config[259] = v6;
config[260] = 3 * v6;
if ( (int)config[299] <= 299 )
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;
lastcfg = *(_QWORD *)config;
*(_QWORD *)((char *)&lastcfg + 3308) = *(_QWORD *)&config[827];
v9 = (char *)(((_DWORD)&lastcfg + 8) & 0xFFFFFFF8);
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;
}

variable_types: i int


decompiled_code:
__int64 __fastcall check_cmdstr(unsigned int a1, __int64 a2)
{
unsigned int v2; // ebp

v2 = 1;
if ( !(unsigned int)strmi(a2, "set") && !(unsigned int)strmi(a2, "add") )
{
v2 = strmi(a2, "die");
if ( v2 )
v2 = 1;
else
syntax_err(a1, "Invalid command");
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, __int64 a2)
{
unsigned int v2; // ebp

v2 = 1;
if ( !(unsigned int)strmi(a2, "set") && !(unsigned int)strmi(a2, "add") )
{
v2 = strmi(a2, "die");
if ( v2 )
v2 = 1;
else
func0(a1, "Invalid command");
}
return v2;
}

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


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();
return result;
}

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

if ( a2 )
result = sockwrite(a2, a1);
else
result = highMsg();
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, const char *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(a2, "newpass") )
{
result = sprintf(v5, "%sSyntax: newpass <password>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "deladmin") )
{
result = sprintf(v5, "%sSyntax: deladmin <username>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "newadmin") )
{
result = sprintf(v5, "%sSyntax: newadmin <username> <password> <level(1-500)>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "say") )
{
result = sprintf(v5, "%sSyntax: say <#channel> <message>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "me") )
{
result = sprintf(v5, "%sSyntax: me <#channel> <message>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "action") )
{
result = sprintf(v5, "%sSyntax: action <#channel> <message>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "mode") )
{
result = sprintf(v5, "%sSyntax: mode <#channel> <modes> [arguments...]", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "unban") )
{
result = sprintf(v5, "%sSyntax: unban <#channel> <mask>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "ban") )
{
result = sprintf(v5, "%sSyntax: ban <#channel> <mask|nickname> <time>[w|d|h|m] [reason]", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "realnameban") )
{
result = sprintf(v5, "%sSyntax: realnameban <#channel> <mask> <time>[w|d|h|m] [reason]", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "setkey") )
{
result = sprintf(v5, "%sSyntax: setkey <#channel> <key>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "setbadmodes") )
{
result = sprintf(v5, "%sSyntax: setbadmodes <#channel> -[modes]", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "setgoodmodes") )
{
result = sprintf(v5, "%sSyntax: setgoodmodes <#channel> +[modes]", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "newchan") )
{
result = sprintf(v5, "%sSyntax: newchan <#channel>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "delchan") )
{
result = sprintf(v5, "%sSyntax: delchan <#channel>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "listbans") )
{
result = sprintf(v5, "%sSyntax: listbans <#channel> <mask>", &prefix);
goto LABEL_33;
}
if ( !strcmp(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_33;
}
if ( !strcmp(a2, "kick") )
{
result = sprintf(v5, "%sSyntax: kick <#channel> <nickname> [reason]", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "namescan") )
{
result = sprintf(v5, "%sSyntax: namescan <#channel> <mask>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "invite") )
{
result = sprintf(v5, "%sSyntax: invite <#channel>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "chaninfo") )
{
result = sprintf(v5, "%sSyntax: chaninfo <#channel>", &prefix);
goto LABEL_33;
}
if ( !strcmp(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_33;
}
if ( !strcmp(a2, "connect") )
{
result = sprintf(v5, "%sSyntax: connect <mask>", &prefix);
LABEL_33:
if ( v5[0] )
result = send_hreply((__int64)v5, a3);
return result;
}
if ( !strcmp(a2, "op") || !strcmp(a2, "deop") || !strcmp(a2, "voice") || (result = strcmp(a2, "devoice")) == 0 )
{
result = sprintf(v5, "%sSyntax: %s <#channel> [users]", &prefix, a2);
goto LABEL_33;
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(const char *a1, const char *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(a2, "newpass") )
{
result = sprintf(v5, "%sSyntax: newpass <password>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "deladmin") )
{
result = sprintf(v5, "%sSyntax: deladmin <username>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "newadmin") )
{
result = sprintf(v5, "%sSyntax: newadmin <username> <password> <level(1-500)>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "say") )
{
result = sprintf(v5, "%sSyntax: say <#channel> <message>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "me") )
{
result = sprintf(v5, "%sSyntax: me <#channel> <message>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "action") )
{
result = sprintf(v5, "%sSyntax: action <#channel> <message>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "mode") )
{
result = sprintf(v5, "%sSyntax: mode <#channel> <modes> [arguments...]", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "unban") )
{
result = sprintf(v5, "%sSyntax: unban <#channel> <mask>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "ban") )
{
result = sprintf(v5, "%sSyntax: ban <#channel> <mask|nickname> <time>[w|d|h|m] [reason]", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "realnameban") )
{
result = sprintf(v5, "%sSyntax: realnameban <#channel> <mask> <time>[w|d|h|m] [reason]", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "setkey") )
{
result = sprintf(v5, "%sSyntax: setkey <#channel> <key>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "setbadmodes") )
{
result = sprintf(v5, "%sSyntax: setbadmodes <#channel> -[modes]", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "setgoodmodes") )
{
result = sprintf(v5, "%sSyntax: setgoodmodes <#channel> +[modes]", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "newchan") )
{
result = sprintf(v5, "%sSyntax: newchan <#channel>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "delchan") )
{
result = sprintf(v5, "%sSyntax: delchan <#channel>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "listbans") )
{
result = sprintf(v5, "%sSyntax: listbans <#channel> <mask>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "setflags") )
{
sprintf(v5, "%sSyntax: setflags <#channel> <+/-flags>", &prefix);
func0((__int64)v5, a3);
result = sprintf(v5, "%sExample: setflags #foo +fo-rlmn", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "kick") )
{
result = sprintf(v5, "%sSyntax: kick <#channel> <nickname> [reason]", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "namescan") )
{
result = sprintf(v5, "%sSyntax: namescan <#channel> <mask>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "invite") )
{
result = sprintf(v5, "%sSyntax: invite <#channel>", &prefix);
goto LABEL_33;
}
if ( !strcmp(a2, "chaninfo") )
{
result = sprintf(v5, "%sSyntax: chaninfo <#channel>", &prefix);
goto LABEL_33;
}
if ( !strcmp(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_33;
}
if ( !strcmp(a2, "connect") )
{
result = sprintf(v5, "%sSyntax: connect <mask>", &prefix);
LABEL_33:
if ( v5[0] )
result = func0((__int64)v5, a3);
return result;
}
if ( !strcmp(a2, "op") || !strcmp(a2, "deop") || !strcmp(a2, "voice") || (result = strcmp(a2, "devoice")) == 0 )
{
result = sprintf(v5, "%sSyntax: %s <#channel> [users]", &prefix, a2);
goto LABEL_33;
}
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, 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, 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; } *


makeBanSpace

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

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

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

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

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; // er14

v7 = time(0LL) + a4;
if ( !a1[22] )
return 0xFFFFFFFFLL;
if ( !(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; // er14

v7 = time(0LL) + a4;
if ( !a1[22] )
return 0xFFFFFFFFLL;
if ( !(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 repeat { int id; int ts; char count; }