decompiled_code:
__int64 __fastcall cr_add(char *src, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax
char **v9; // rax
char **v10; // rbx
size_t v11; // rax
char *v12; // rax
char *v13; // rax
char *v14; // rdx

if ( fetchChanRec((__int64)src) )
return 0LL;
if ( strlen(src) > 0x40 )
return 0LL;
v9 = (char **)myalloc(208LL);
v10 = v9;
if ( !v9 )
return 0LL;
v9[24] = 0LL;
v9[22] = 0LL;
v9[23] = 0LL;
v11 = strlen(src);
v12 = (char *)myalloc(v11 + 1);
*v10 = v12;
strcpy(v12, src);
mystrncpy(v10 + 1, a2, 33LL);
mystrncpy((char *)v10 + 41, a3, 65LL);
mystrncpy((char *)v10 + 106, a4, 33LL);
mystrncpy((char *)v10 + 139, a5, 33LL);
v13 = (char *)chans;
do
{
v14 = v13;
v13 = (char *)*((_QWORD *)v13 + 24);
}
while ( v13 );
*((_QWORD *)v14 + 24) = v10;
result = 1LL;
v10[25] = v14;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *src, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax
char **v9; // rax
char **v10; // rbx
size_t v11; // rax
char *v12; // rax
char *v13; // rax
char *v14; // rdx

if ( fetchChanRec((__int64)src) )
return 0LL;
if ( strlen(src) > 0x40 )
return 0LL;
v9 = (char **)myalloc(208LL);
v10 = v9;
if ( !v9 )
return 0LL;
v9[24] = 0LL;
v9[22] = 0LL;
v9[23] = 0LL;
v11 = strlen(src);
v12 = (char *)myalloc(v11 + 1);
*v10 = v12;
strcpy(v12, src);
mystrncpy(v10 + 1, a2, 33LL);
mystrncpy((char *)v10 + 41, a3, 65LL);
mystrncpy((char *)v10 + 106, a4, 33LL);
mystrncpy((char *)v10 + 139, a5, 33LL);
v13 = (char *)chans;
do
{
v14 = v13;
v13 = (char *)*((_QWORD *)v13 + 24);
}
while ( v13 );
*((_QWORD *)v14 + 24) = v10;
result = 1LL;
v10[25] = v14;
return result;
}

original_code:
int cr_add(char *name, char *flags, char *key, char *gModes, char *bModes)
{
 struct chanRec *temp, *i;
 if(fetchChanRec(name))
  return 0;
 if(strlen(name) > 64)
  return 0;
 temp = (struct chanRec *)myalloc(sizeof(struct chanRec));
 if(!temp)
  return 0;
 temp->next = ((void *)0);
 temp->physical = ((void *)0);
 temp->softbans = ((void *)0);
 temp->name = (char *)myalloc(strlen(name)+1);
 strcpy(temp->name, name);
 mystrncpy(temp->flags, flags, 32 +1);
 mystrncpy(temp->key, key, 64 +1);
 mystrncpy(temp->goodModes, gModes, 32 +1);
 mystrncpy(temp->badModes, bModes, 32 +1);
 i = &chans;
 while(i->next != ((void *)0))
  i = i->next;
 i->next = temp;
 temp->prev = i;
 return 1;
}

canonical_original_code:
int cr_add(char *name, char *flags, char *key, char *gModes, char *bModes)
{
 struct chanRec *temp; struct chanRec *i;
 if(fetchChanRec(name))
  return 0;
 if(strlen(name) > 64)
  return 0;
 temp = (struct chanRec *)myalloc(sizeof(struct chanRec));
 if(!temp)
  return 0;
 temp->next = ((void *)0);
 temp->physical = ((void *)0);
 temp->softbans = ((void *)0);
 temp->name = (char *)myalloc(strlen(name)+1);
 strcpy(temp->name, name);
 mystrncpy(temp->flags, flags, 32 +1);
 mystrncpy(temp->key, key, 64 +1);
 mystrncpy(temp->goodModes, gModes, 32 +1);
 mystrncpy(temp->badModes, bModes, 32 +1);
 i = &chans;
 while(i->next != ((void *)0))
  i = i->next;
 i->next = temp;
 temp->prev = i;
 return 1;
}

variable_types:
name
char *

variable_types:
flags
char *

variable_types:
key
char *

variable_types:
gModes
char *

variable_types:
bModes
char *


repo: ipacker/fireclaw

original_code:
int br_add(char *channel, char *banmask, char *reason, char type, char *setby, int expires)
{
 struct chanRec *theChan;
 struct softBan *temp, *i;
 if(!(theChan = fetchChanRec(channel)))
  return 0;
 if(fetchSoftBan(theChan, banmask))
  return 0;
 if(strlen(banmask) > 256)
  return 0;
 temp = (struct softBan *)myalloc(sizeof(struct softBan));
 if(!temp)
  return 0;
 temp->next = ((void *)0);
 temp->type = type;
 temp->expires = expires;
 temp->banmask = (char*)myalloc(strlen(banmask)+1);
 temp->reason = (char*)myalloc(strlen(reason)+1);
 temp->setby = (char*)myalloc(strlen(setby)+1);
 strcpy(temp->banmask, banmask);
 strcpy(temp->reason, reason);
 strcpy(temp->setby, setby);
 i = theChan->softbans;
 if(!i) {
  theChan->softbans = temp;
  temp->prev = ((void *)0);
 } else {
  while(i->next != ((void *)0))
   i = i->next;
  i->next = temp;
  temp->prev = i;
 }
 return 1;
}

canonical_original_code:
int br_add(char *channel, char *banmask, char *reason, char type, char *setby, int expires)
{
 struct chanRec *theChan;
 struct softBan *temp; struct softBan *i;
 if(!(theChan = fetchChanRec(channel)))
  return 0;
 if(fetchSoftBan(theChan, banmask))
  return 0;
 if(strlen(banmask) > 256)
  return 0;
 temp = (struct softBan *)myalloc(sizeof(struct softBan));
 if(!temp)
  return 0;
 temp->next = ((void *)0);
 temp->type = type;
 temp->expires = expires;
 temp->banmask = (char *)myalloc(strlen(banmask)+1);
 temp->reason = (char *)myalloc(strlen(reason)+1);
 temp->setby = (char *)myalloc(strlen(setby)+1);
 strcpy(temp->banmask, banmask);
 strcpy(temp->reason, reason);
 strcpy(temp->setby, setby);
 i = theChan->softbans;
 if(!i) {
  theChan->softbans = temp;
  temp->prev = ((void *)0);
 } else {
  while(i->next != ((void *)0))
   i = i->next;
  i->next = temp;
  temp->prev = i;
 }
 return 1;
}

variable_types:
channel
char *

variable_types:
banmask
char *

variable_types:
reason
char *

variable_types: type char

variable_types:
setby
char *

variable_types: expires int

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

return_type: int

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

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

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


decompiled_code:
__int64 __fastcall br_del(__int64 a1, __int64 a2)
{
void **v2; // rbp
__int64 result; // rax
_QWORD *v4; // rdx
_QWORD *v5; // rax

v2 = (void **)fetchSoftBan(a1, a2);
result = 0LL;
if ( v2 )
{
free(*v2);
free(v2[1]);
free(v2[3]);
v4 = v2[6];
v5 = v2[5];
if ( v4 )
v4[5] = v5;
else
*(_QWORD *)(a1 + 184) = v5;
if ( v5 )
v5[6] = v4;
free(v2);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
void **v2; // rbp
__int64 result; // rax
_QWORD *v4; // rdx
_QWORD *v5; // rax

v2 = (void **)fetchSoftBan(a1, a2);
result = 0LL;
if ( v2 )
{
free(*v2);
free(v2[1]);
free(v2[3]);
v4 = v2[6];
v5 = v2[5];
if ( v4 )
v4[5] = v5;
else
*(_QWORD *)(a1 + 184) = v5;
if ( v5 )
v5[6] = v4;
free(v2);
result = 1LL;
}
return result;
}

original_code:
int br_del(struct chanRec *theChan, char *banmask)
{
 struct softBan *i = fetchSoftBan(theChan, banmask);
 if(!i)
  return 0;
 free(i->banmask); free(i->reason); free(i->setby);
 if(i->prev)
  i->prev->next = i->next;
 else
  theChan->softbans = i->next;
 if(i->next)
  i->next->prev = i->prev;
 free(i);
 return 1;
}

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

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

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

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


original_code:
void clear_softbans(struct chanRec *cr)
{
 struct softBan *i, *fr;
 i = cr->softbans;
 while(i)
 {
  fr = i;
  free(i->banmask);
  free(i->reason);
  free(i->setby);
  i = i->next;
  free(fr);
 }
 cr->softbans = ((void *)0);
 return;
}

canonical_original_code:
void clear_softbans(struct chanRec *cr)
{
 struct softBan *i; struct softBan *fr;
 i = cr->softbans;
 while(i)
 {
  fr = i;
  free(i->banmask);
  free(i->reason);
  free(i->setby);
  i = i->next;
  free(fr);
 }
 cr->softbans = ((void *)0);
 return;
}

return_type: void

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


decompiled_code:
__int64 __fastcall cr_del(__int64 a1)
{
void **v1; // rbp
__int64 result; // rax
_QWORD *v3; // rax
_QWORD *v4; // rdx

v1 = (void **)fetchChanRec(a1);
result = 0LL;
if ( v1 )
{
clear_softbans((__int64)v1);
v3 = v1[24];
if ( v3 )
v3[25] = v1[25];
v4 = v1[25];
if ( v4 )
v4[24] = v3;
free(*v1);
free(v1);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
void **v1; // rbp
__int64 result; // rax
_QWORD *v3; // rax
_QWORD *v4; // rdx

v1 = (void **)fetchChanRec(a1);
result = 0LL;
if ( v1 )
{
func7((__int64)v1);
v3 = v1[24];
if ( v3 )
v3[25] = v1[25];
v4 = v1[25];
if ( v4 )
v4[24] = v3;
free(*v1);
free(v1);
result = 1LL;
}
return result;
}

original_code:
int cr_del(char *name)
{
 struct chanRec *d = fetchChanRec(name);
 if(!d)
  return 0;
 clear_softbans(d);
 if(d->next)
  d->next->prev = d->prev;
 if(d->prev)
  d->prev->next = d->next;
 free(d->name);
 free(d);
 return 1;
}


decompiled_code:
__int64 clear_chans()
{
__int64 *i; // rbx
__int64 *v1; // rax
__int64 result; // rax

for ( i = (__int64 *)chans[24]; i; result = cr_del(*v1) )
{
v1 = i;
i = (__int64 *)i[24];
}
return result;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 *i; // rbx
__int64 *v1; // rax
__int64 result; // rax

for ( i = (__int64 *)chans[24]; i; result = func8(*v1) )
{
v1 = i;
i = (__int64 *)i[24];
}
return result;
}

original_code:
void clear_chans()
{
 struct chanRec *i, *fr;
 i = chans.next;
 while(i)
 {
  fr = i->next;
  cr_del(i->name);
  i = fr;
 }
 return;
}

canonical_original_code:
void clear_chans()
{
 struct chanRec *i; struct chanRec *fr;
 i = chans.next;
 while(i)
 {
  fr = i->next;
  cr_del(i->name);
  i = fr;
 }
 return;
}


decompiled_code:
__int64 count_chans()
{
__int64 v0; // rax
unsigned int i; // er8

v0 = chans[24];
for ( i = 0; v0; ++i )
v0 = *(_QWORD *)(v0 + 192);
return i;
}

canonical_decompiled_code:
__int64 func10()
{
__int64 v0; // rax
unsigned int i; // er8

v0 = chans[24];
for ( i = 0; v0; ++i )
v0 = *(_QWORD *)(v0 + 192);
return i;
}

original_code:
int count_chans()
{
 struct chanRec *i;
 int count = 0;
 i = chans.next;
 while(i)
 {
  count++;
  i = i->next;
 }
 return count;
}

variable_types: count int


decompiled_code:
__int64 __fastcall count_softBansOn(__int64 a1)
{
__int64 v1; // rax
unsigned int i; // er8

v1 = *(_QWORD *)(a1 + 184);
for ( i = 0; v1; ++i )
v1 = *(_QWORD *)(v1 + 40);
return i;
}

original_code:
int count_softBansOn(struct chanRec *c)
{
 struct softBan *i;
 int count = 0;
 i = c->softbans;
 while(i)
 {
  count++;
  i = i->next;
 }
 return count;
}


findChan

decompiled_code:
__int64 __fastcall findChan(char *s1)
{
__int64 i; // r12

for ( i = ial; i; i = *(_QWORD *)(i + 656) )
{
if ( !strcmp(s1, *(const char **)i) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1)
{
__int64 i; // r12

for ( i = ial; i; i = *(_QWORD *)(i + 656) )
{
if ( !strcmp(s1, *(const char **)i) )
break;
}
return i;
}

original_code:
struct schan *findChan(char *name)
{
 struct schan *i;
 i = ial.channel;
 while(i != ((void *)0))
 {
  if(strcmp(name, i->name) == 0)
   return i;
  i = i->next;
 }
 return ((void *)0);
}

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


decompiled_code:
__int64 __fastcall count_criminals(__int64 a1)
{
__int64 v1; // rax
unsigned int i; // er8

v1 = *(_QWORD *)(a1 + 616);
for ( i = 0; v1; ++i )
v1 = *(_QWORD *)(v1 + 432);
return i;
}

original_code:
int count_criminals(struct schan *c)
{
 struct criminalRecord *i;
 int count = 0;
 i = c->nortyusers;
 while(i != ((void *)0))
 {
  count++;
  i = i->next;
 }
 return count;
}

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


original_code:
void cl_add(char *name)
{
 struct schan *temp, *i;
 int size;
 if(findChan(name))
 {
  sRelay("Debug: SYNC Error trying to add channel twice");
  return;
 }
 temp = (struct schan *)myalloc(sizeof(struct schan));
 size = strlen(name) + 1;
 temp->userSize = 0;
 temp->flood_last = 0;
 temp->flood_lines = 0;
 temp->banSize = 0;
 temp->limit = 0;
 temp->tsLim = 0;
 temp->next = ((void *)0);
 temp->user = ((void *)0);
 temp->nortyusers = ((void *)0);
 temp->bans = ((void *)0);
 temp->record = fetchChanRec(name);
 temp->name = (char *)myalloc(size);
 memcpy(temp->name, name, size);
 memset(temp->topic, 0, 500);
 memset(temp->modes, 0, 32);
 memset(temp->key, 0, 64);
 i = ial.channel;
 if(i == ((void *)0))
 {
  ial.channel = temp;
  temp->prev = ((void *)0);
 }
 else
 {
  while(i->next != ((void *)0))
   i = i->next;
  i->next = temp;
  temp->prev = i;
 }
 if(temp->record)
  temp->record->physical = temp;
 return;
}

canonical_original_code:
void cl_add(char *name)
{
 struct schan *temp; struct schan *i;
 int size;
 if(findChan(name))
 {
  sRelay("Debug: SYNC Error trying to add channel twice");
  return;
 }
 temp = (struct schan *)myalloc(sizeof(struct schan));
 size = strlen(name) + 1;
 temp->userSize = 0;
 temp->flood_last = 0;
 temp->flood_lines = 0;
 temp->banSize = 0;
 temp->limit = 0;
 temp->tsLim = 0;
 temp->next = ((void *)0);
 temp->user = ((void *)0);
 temp->nortyusers = ((void *)0);
 temp->bans = ((void *)0);
 temp->record = fetchChanRec(name);
 temp->name = (char *)myalloc(size);
 memcpy(temp->name, name, size);
 memset(temp->topic, 0, 500);
 memset(temp->modes, 0, 32);
 memset(temp->key, 0, 64);
 i = ial.channel;
 if(i == ((void *)0))
 {
  ial.channel = temp;
  temp->prev = ((void *)0);
 }
 else
 {
  while(i->next != ((void *)0))
   i = i->next;
  i->next = temp;
  temp->prev = i;
 }
 if(temp->record)
  temp->record->physical = temp;
 return;
}

variable_types: size int


findiUser

decompiled_code:
__int64 __fastcall findiUser(__int64 a1, __int64 a2)
{
__int64 v2; // r12

v2 = *(_QWORD *)(a1 + 632);
if ( !v2 )
return 0LL;
while ( !(unsigned int)strmi(a2, v2) )
{
v2 = *(_QWORD *)(v2 + 104);
if ( !v2 )
return 0LL;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
__int64 v2; // r12

v2 = *(_QWORD *)(a1 + 632);
if ( !v2 )
return 0LL;
while ( !(unsigned int)strmi(a2, v2) )
{
v2 = *(_QWORD *)(v2 + 104);
if ( !v2 )
return 0LL;
}
return v2;
}

original_code:
struct suser *findiUser(struct schan *channel, char *nick)
{
 struct suser *i;
 i = channel->user;
 while(i != ((void *)0))
 {
  if(strmi(nick, i->nick))
   return i;
  i = i->next;
 }
 return ((void *)0);
}

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

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


findUser

decompiled_code:
__int64 __fastcall findUser(__int64 a1, const char *a2)
{
__int64 i; // r12

for ( i = *(_QWORD *)(a1 + 632); i; i = *(_QWORD *)(i + 104) )
{
if ( !strcmp(a2, (const char *)i) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, const char *a2)
{
__int64 i; // r12

for ( i = *(_QWORD *)(a1 + 632); i; i = *(_QWORD *)(i + 104) )
{
if ( !strcmp(a2, (const char *)i) )
break;
}
return i;
}

original_code:
struct suser *findUser(struct schan *channel, char *nick)
{
 struct suser *i;
 i = channel->user;
 while(i != ((void *)0))
 {
  if(!strcmp(nick, i->nick))
   return i;
  i = i->next;
 }
 return ((void *)0);
}

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


userExists

decompiled_code:
__int64 __fastcall userExists(const char *a1)
{
__int64 v1; // rbx
__int64 result; // rax

v1 = ial;
if ( !ial )
return 0LL;
while ( 1 )
{
result = findUser(v1, a1);
if ( result )
break;
v1 = *(_QWORD *)(v1 + 656);
if ( !v1 )
return result;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1)
{
__int64 v1; // rbx
__int64 result; // rax

v1 = ial;
if ( !ial )
return 0LL;
while ( 1 )
{
result = func4(v1, a1);
if ( result )
break;
v1 = *(_QWORD *)(v1 + 656);
if ( !v1 )
return result;
}
return 1LL;
}

original_code:
int userExists(char *nick)
{
 struct schan *c;
 c = ial.channel;
 while(c != ((void *)0))
 {
  if(findUser(c, nick))
   return 1;
  c = c->next;
 }
 return 0;
}


findCriminal

decompiled_code:
__int64 __fastcall findCriminal(__int64 a1, const char *a2)
{
__int64 i; // r12

for ( i = *(_QWORD *)(a1 + 616); i; i = *(_QWORD *)(i + 432) )
{
if ( !strcmp(a2, (const char *)i) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, const char *a2)
{
__int64 i; // r12

for ( i = *(_QWORD *)(a1 + 616); i; i = *(_QWORD *)(i + 432) )
{
if ( !strcmp(a2, (const char *)i) )
break;
}
return i;
}

original_code:
struct criminalRecord *findCriminal(struct schan *channel, char *nick)
{
 struct criminalRecord *i;
 i = channel->nortyusers;
 while(i != ((void *)0))
 {
  if(!strcmp(nick, i->nick))
   return i;
  i = i->next;
 }
 return ((void *)0);
}

variable_types: struct schan { char *name; char topic[-1]; char modes[-1]; char key[-1]; int limit; int tsLim; struct criminalRecord *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; } *

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


original_code:
struct suser *u_add(struct schan *channel, char *nick, char *ident, char *host)
{
 struct suser *temp, *i;
 int si, sh, sm;
 if(findUser(channel, nick))
  return ((void *)0);
 si = strlen(ident) + 1;
 sh = strlen(host) + 1;
 sm = strlen(nick) + strlen(ident) + strlen(host) + 3;
 temp = (struct suser *)myalloc(sizeof(struct suser));
 temp->isVoice = 0;
 temp->isOp = 0;
 temp->flines = 0;
 temp->nickchanges = 0;
 temp->joinTime = (int)time(0);
 temp->idleMsg = 0;
 temp->lastMsg = 0;
 temp->lastNick = 0;
 temp->next = ((void *)0);
 temp->realname = ((void *)0);
 temp->ident = (char *)myalloc(si);
 temp->host = (char *)myalloc(sh);
 temp->mask = (char*)myalloc(sm);
 memcpy(temp->ident, ident, si);
 memcpy(temp->host, host, sh);
 mystrncpy(temp->nick, nick, 33);
 sprintf(temp->mask, "%s!%s@%s", nick, ident, host);
 i = channel->user;
 if(i == ((void *)0))
 {
  channel->user = temp;
  temp->prev = ((void *)0);
 } else
 {
  while(i->next != ((void *)0))
   i = i->next;
  i->next = temp;
  temp->prev = i;
 }
 channel->userSize++;
 return temp;
}

canonical_original_code:
struct suser *u_add(struct schan *channel, char *nick, char *ident, char *host)
{
 struct suser *temp; struct suser *i;
 int si; int sh; int sm;
 if(findUser(channel, nick))
  return ((void *)0);
 si = strlen(ident) + 1;
 sh = strlen(host) + 1;
 sm = strlen(nick) + strlen(ident) + strlen(host) + 3;
 temp = (struct suser *)myalloc(sizeof(struct suser));
 temp->isVoice = 0;
 temp->isOp = 0;
 temp->flines = 0;
 temp->nickchanges = 0;
 temp->joinTime = (int)time(0);
 temp->idleMsg = 0;
 temp->lastMsg = 0;
 temp->lastNick = 0;
 temp->next = ((void *)0);
 temp->realname = ((void *)0);
 temp->ident = (char *)myalloc(si);
 temp->host = (char *)myalloc(sh);
 temp->mask = (char *)myalloc(sm);
 memcpy(temp->ident, ident, si);
 memcpy(temp->host, host, sh);
 mystrncpy(temp->nick, nick, 33);
 sprintf(temp->mask, "%s!%s@%s", nick, ident, host);
 i = channel->user;
 if(i == ((void *)0))
 {
  channel->user = temp;
  temp->prev = ((void *)0);
 } else
 {
  while(i->next != ((void *)0))
   i = i->next;
  i->next = temp;
  temp->prev = i;
 }
 channel->userSize++;
 return temp;
}

variable_types:
ident
char *

variable_types:
host
char *

variable_types: si int

variable_types: sh int

variable_types: sm int


original_code:
void u_del(struct schan *theChan, struct suser *theUser)
{
 if(theUser->realname)
  free(theUser->realname);
 free(theUser->ident);
 free(theUser->host);
 free(theUser->mask);
 if(!theUser->prev)
  theChan->user = theUser->next;
 else
  theUser->prev->next = theUser->next;
 if(theUser->next)
  theUser->next->prev = theUser->prev;
 free(theUser);
 theChan->userSize--;
 return;
}

variable_types:
theUser
struct suser *


original_code:
void clear_users(struct schan *c)
{
 struct suser *fr, *i;
 i = c->user;
 while(i != ((void *)0))
 {
  fr = i;
  i = i->next;
  u_del(c, fr);
 }
}

canonical_original_code:
void clear_users(struct schan *c)
{
 struct suser *fr; struct suser *i;
 i = c->user;
 while(i != ((void *)0))
 {
  fr = i;
  i = i->next;
  u_del(c, fr);
 }
}


addMode

decompiled_code:
char *__fastcall addMode(__int64 a1, char a2)
{
_BYTE *v2; // rbx
char *result; // rax

v2 = (_BYTE *)(a1 + 509);
result = strchr((const char *)(a1 + 509), a2);
if ( !result )
{
if ( *(_BYTE *)(a1 + 509) )
{
do
++v2;
while ( *v2 );
}
*v2 = a2;
v2[1] = 0;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func10(__int64 a1, char a2)
{
_BYTE *v2; // rbx
char *result; // rax

v2 = (_BYTE *)(a1 + 509);
result = strchr((const char *)(a1 + 509), a2);
if ( !result )
{
if ( *(_BYTE *)(a1 + 509) )
{
do
++v2;
while ( *v2 );
}
*v2 = a2;
v2[1] = 0;
}
return result;
}

original_code:
void addMode(struct schan *theChan, char mode)
{
 char *pch = theChan->modes;
 if(!strchr(pch, mode))
 {
  for(; (*pch); pch++);
  *(pch++) = mode;
  *pch = '\0';
 }
 return;
}

variable_types: mode char

variable_types:
pch
char *


removeMode

decompiled_code:
char *__fastcall removeMode(__int64 a1, char a2)
{
char *result; // rax
char v3; // dl

result = strchr((const char *)(a1 + 509), a2);
if ( result && *result )
{
do
{
v3 = *++result;
*(result - 1) = v3;
}
while ( v3 );
}
return result;
}

canonical_decompiled_code:
char *__fastcall func11(__int64 a1, char a2)
{
char *result; // rax
char v3; // dl

result = strchr((const char *)(a1 + 509), a2);
if ( result && *result )
{
do
{
v3 = *++result;
*(result - 1) = v3;
}
while ( v3 );
}
return result;
}

original_code:
void removeMode(struct schan *theChan, char mode)
{
 char *pch = strchr(theChan->modes, mode);
 if(pch)
  for(; (*pch); pch++)
   *pch = *(pch + 1);
 return;
}


findBan

decompiled_code:
__int64 __fastcall findBan(__int64 a1, const char *a2)
{
__int64 i; // r12

for ( i = *(_QWORD *)(a1 + 624); i; i = *(_QWORD *)(i + 24) )
{
if ( !strcmp(a2, *(const char **)i) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, const char *a2)
{
__int64 i; // r12

for ( i = *(_QWORD *)(a1 + 624); i; i = *(_QWORD *)(i + 24) )
{
if ( !strcmp(a2, *(const char **)i) )
break;
}
return i;
}

original_code:
struct sban *findBan(struct schan *channel, char *mask)
{
 struct sban *i;
 i = channel->bans;
 while(i != ((void *)0))
 {
  if(!strcmp(mask, i->mask))
   return i;
  i = i->next;
 }
 return ((void *)0);
}

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

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


original_code:
struct criminalRecord *nu_add(struct schan *channel, char *nick, char *ident, char *host)
{
 struct criminalRecord *temp, *i;
 int sih;
 if(findCriminal(channel, nick))
  return ((void *)0);
 sih = strlen(ident) + strlen(host) + 2;
 temp = (struct criminalRecord *)myalloc(sizeof(struct criminalRecord));
 temp->shortTerm = temp->longTerm = 0;
 temp->lastJoin = 0;
 temp->njoins = 0;
 temp->laststamp = time(((void *)0));
 temp->identhost = (char *)myalloc(sih);
 sprintf(temp->identhost, "%s@%s", ident, host);
 mystrncpy(temp->nick, nick, 33);
 temp->next = ((void *)0);
 for(sih = 0; sih < 30; sih++)
  temp->trackrepeat[sih].id = 0;
 i = channel->nortyusers;
 if(i == ((void *)0))
 {
  channel->nortyusers = temp;
  temp->prev = ((void *)0);
 } else
 {
  while(i->next != ((void *)0))
   i = i->next;
  i->next = temp;
  temp->prev = i;
 }
 return temp;
}

canonical_original_code:
struct criminalRecord *nu_add(struct schan *channel, char *nick, char *ident, char *host)
{
 struct criminalRecord *temp; struct criminalRecord *i;
 int sih;
 if(findCriminal(channel, nick))
  return ((void *)0);
 sih = strlen(ident) + strlen(host) + 2;
 temp = (struct criminalRecord *)myalloc(sizeof(struct criminalRecord));
 temp->shortTerm = temp->longTerm = 0;
 temp->lastJoin = 0;
 temp->njoins = 0;
 temp->laststamp = time(((void *)0));
 temp->identhost = (char *)myalloc(sih);
 sprintf(temp->identhost, "%s@%s", ident, host);
 mystrncpy(temp->nick, nick, 33);
 temp->next = ((void *)0);
 for(sih = 0; sih < 30; sih++)
  temp->trackrepeat[sih].id = 0;
 i = channel->nortyusers;
 if(i == ((void *)0))
 {
  channel->nortyusers = temp;
  temp->prev = ((void *)0);
 } else
 {
  while(i->next != ((void *)0))
   i = i->next;
  i->next = temp;
  temp->prev = i;
 }
 return temp;
}

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: sih int


original_code:
void nu_del(struct schan *theChan, struct criminalRecord *criminal)
{
 free(criminal->identhost);
 if(!criminal->prev)
  theChan->nortyusers = criminal->next;
 else
  criminal->prev->next = criminal->next;
 if(criminal->next)
  criminal->next->prev = criminal->prev;
 free(criminal);
 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:
criminal
struct criminalRecord *


decompiled_code:
void __fastcall clear_nortyusers(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rsi

v1 = *(_QWORD *)(a1 + 616);
while ( v1 )
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 432);
nu_del(a1, v2);
}
}

original_code:
void clear_nortyusers(struct schan *c)
{
 struct criminalRecord *fr, *i;
 i = c->nortyusers;
 while(i != ((void *)0))
 {
  fr = i;
  i = i->next;
  nu_del(c, fr);
 }
}

canonical_original_code:
void clear_nortyusers(struct schan *c)
{
 struct criminalRecord *fr; struct criminalRecord *i;
 i = c->nortyusers;
 while(i != ((void *)0))
 {
  fr = i;
  i = i->next;
  nu_del(c, fr);
 }
}


original_code:
struct sban *bl_add(struct schan *channel, char *mask, char *setby, int ts)
{
 struct sban *temp, *i;
 int sm, ss;
 if(findBan(channel, mask))
  return ((void *)0);
 sm = strlen(mask) + 1;
 ss = strlen(setby) + 1;
 temp = (struct sban *)myalloc(sizeof(struct sban));
 temp->ts = ts;
 temp->mask = (char *)myalloc(sm);
 temp->setby = (char *)myalloc(ss);
 temp->next = ((void *)0);
 memcpy(temp->mask, mask, sm);
 memcpy(temp->setby, setby, ss);
 i = channel->bans;
 if(i == ((void *)0))
 {
  channel->bans = temp;
  temp->prev = ((void *)0);
 } else
 {
  while(i->next != ((void *)0))
   i = i->next;
  i->next = temp;
  temp->prev = i;
 }
 channel->banSize++;
 return temp;
}

canonical_original_code:
struct sban *bl_add(struct schan *channel, char *mask, char *setby, int ts)
{
 struct sban *temp; struct sban *i;
 int sm; int ss;
 if(findBan(channel, mask))
  return ((void *)0);
 sm = strlen(mask) + 1;
 ss = strlen(setby) + 1;
 temp = (struct sban *)myalloc(sizeof(struct sban));
 temp->ts = ts;
 temp->mask = (char *)myalloc(sm);
 temp->setby = (char *)myalloc(ss);
 temp->next = ((void *)0);
 memcpy(temp->mask, mask, sm);
 memcpy(temp->setby, setby, ss);
 i = channel->bans;
 if(i == ((void *)0))
 {
  channel->bans = temp;
  temp->prev = ((void *)0);
 } else
 {
  while(i->next != ((void *)0))
   i = i->next;
  i->next = temp;
  temp->prev = i;
 }
 channel->banSize++;
 return temp;
}

variable_types:
setby
char *

variable_types: ts int

variable_types: ss int

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


original_code:
void bl_del(struct schan *theChan, struct sban *theBan)
{
 free(theBan->mask);
 free(theBan->setby);
 if(!theBan->prev)
  theChan->bans = theBan->next;
 else
  theBan->prev->next = theBan->next;
 if(theBan->next)
  theBan->next->prev = theBan->prev;
 free(theBan);
 theChan->banSize--;
 return;
}

variable_types:
theBan
struct sban *


original_code:
void clear_bans(struct schan *c)
{
 struct sban *fr, *i;
 i = c->bans;
 while(i != ((void *)0))
 {
  fr = i;
  i = i->next;
  bl_del(c, fr);
 }
}

canonical_original_code:
void clear_bans(struct schan *c)
{
 struct sban *fr; struct sban *i;
 i = c->bans;
 while(i != ((void *)0))
 {
  fr = i;
  i = i->next;
  bl_del(c, fr);
 }
}


decompiled_code:
void __fastcall cl_del(char *a1)
{
__int64 v1; // rax
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // rdx
__int64 v5; // rax

v1 = findChan(a1);
if ( v1 )
{
v2 = v1;
v3 = *(_QWORD *)(v1 + 672);
if ( v3 )
*(_QWORD *)(v3 + 176) = 0LL;
checkLastPointer(v2);
free(*(void **)v2);
clear_users(v2);
clear_bans(v2);
clear_nortyusers(v2);
v4 = *(_QWORD *)(v2 + 664);
v5 = *(_QWORD *)(v2 + 656);
if ( v4 )
*(_QWORD *)(v4 + 656) = v5;
else
ial = *(_QWORD *)(v2 + 656);
if ( v5 )
*(_QWORD *)(v5 + 664) = v4;
free((void *)v2);
}
else
{
sRelay("Debug: SYNC Error trying to delete channel that doesn't exist.");
}
}

canonical_decompiled_code:
void __fastcall func19(char *a1)
{
__int64 v1; // rax
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // rdx
__int64 v5; // rax

v1 = func0(a1);
if ( v1 )
{
v2 = v1;
v3 = *(_QWORD *)(v1 + 672);
if ( v3 )
*(_QWORD *)(v3 + 176) = 0LL;
checkLastPointer(v2);
free(*(void **)v2);
func9(v2);
func18(v2);
func15(v2);
v4 = *(_QWORD *)(v2 + 664);
v5 = *(_QWORD *)(v2 + 656);
if ( v4 )
*(_QWORD *)(v4 + 656) = v5;
else
ial = *(_QWORD *)(v2 + 656);
if ( v5 )
*(_QWORD *)(v5 + 664) = v4;
free((void *)v2);
}
else
{
sRelay("Debug: SYNC Error trying to delete channel that doesn't exist.");
}
}

original_code:
void cl_del(char *name)
{
 struct schan *theChan = findChan(name);
 if(!theChan)
 {
  sRelay("Debug: SYNC Error trying to delete channel that doesn't exist.");
  return;
 }
 if(theChan->record)
  theChan->record->physical = ((void *)0);
 checkLastPointer(theChan);
 free(theChan->name);
 clear_users(theChan);
 clear_bans(theChan);
 clear_nortyusers(theChan);
 if(theChan->prev == ((void *)0))
  ial.channel = theChan->next;
 else
  theChan->prev->next = theChan->next;
 if(theChan->next != ((void *)0))
  theChan->next->prev = theChan->prev;
 free(theChan);
 return;
}

variable_types:
name
char *


decompiled_code:
void clear_ial()
{
__int64 v0; // rbx
char **v1; // rax

v0 = ial;
while ( v0 )
{
v1 = (char **)v0;
v0 = *(_QWORD *)(v0 + 656);
cl_del(*v1);
}
ial = 0LL;
}

original_code:
void clear_ial()
{
 struct schan *c, *n;
 c = ial.channel;
 while(c != ((void *)0))
 {
  n = c;
  c = c->next;
  cl_del(n->name);
 }
 ial.channel = ((void *)0);
}

canonical_original_code:
void clear_ial()
{
 struct schan *c; struct schan *n;
 c = ial.channel;
 while(c != ((void *)0))
 {
  n = c;
  c = c->next;
  cl_del(n->name);
 }
 ial.channel = ((void *)0);
}


modifyFlags

decompiled_code:
void __fastcall modifyFlags(char *dest, char *a2)
{
char v2; // bl
char *v3; // rbp
char v4; // r13
char *v5; // rax
char v6; // dl
char src[42]; // [rsp+Eh] [rbp-2Ah] BYREF

v2 = *a2;
src[1] = 0;
if ( v2 )
{
v3 = a2;
v4 = 43;
while ( 1 )
{
while ( 1 )
{
while ( ((v2 - 43) & 0xFD) == 0 )
{
++v3;
v4 = v2;
v2 = *v3;
if ( !*v3 )
return;
}
if ( strchr("ABIOVabcdefhijklmnoprstxyz", v2) )
break;
LABEL_8:
v2 = *++v3;
if ( !v2 )
return;
}
if ( v4 == 43 )
{
if ( strchr(dest, v2) )
goto LABEL_8;
++v3;
src[0] = v2;
strcat(dest, src);
v2 = *v3;
if ( !*v3 )
return;
}
else
{
if ( v4 != 45 )
goto LABEL_8;
v5 = strchr(dest, v2);
if ( !v5 || !*v5 )
goto LABEL_8;
do
{
v6 = *++v5;
*(v5 - 1) = v6;
}
while ( v6 );
v2 = *++v3;
if ( !v2 )
return;
}
}
}
}

canonical_decompiled_code:
void __fastcall func0(char *dest, char *a2)
{
char v2; // bl
char *v3; // rbp
char v4; // r13
char *v5; // rax
char v6; // dl
char src[42]; // [rsp+Eh] [rbp-2Ah] BYREF

v2 = *a2;
src[1] = 0;
if ( v2 )
{
v3 = a2;
v4 = 43;
while ( 1 )
{
while ( 1 )
{
while ( ((v2 - 43) & 0xFD) == 0 )
{
++v3;
v4 = v2;
v2 = *v3;
if ( !*v3 )
return;
}
if ( strchr("ABIOVabcdefhijklmnoprstxyz", v2) )
break;
LABEL_8:
v2 = *++v3;
if ( !v2 )
return;
}
if ( v4 == 43 )
{
if ( strchr(dest, v2) )
goto LABEL_8;
++v3;
src[0] = v2;
strcat(dest, src);
v2 = *v3;
if ( !*v3 )
return;
}
else
{
if ( v4 != 45 )
goto LABEL_8;
v5 = strchr(dest, v2);
if ( !v5 || !*v5 )
goto LABEL_8;
do
{
v6 = *++v5;
*(v5 - 1) = v6;
}
while ( v6 );
v2 = *++v3;
if ( !v2 )
return;
}
}
}
}

original_code:
void modifyFlags(char *flags, char *changes)
{
 char ptt[2];
 char *pch, *set;
 char sign = '+';
 for(ptt[1] = 0; *changes; changes++)
 {
  if(*changes == '+' || *changes == '-') {
   sign = *changes;
  } else if(strchr("ABIOVabcdefhijklmnoprstxyz", *changes)) {
   if(sign == '+' && !strchr(flags, *changes)) {
    ptt[0] = *changes;
    strcat(flags, ptt);
   } else if(sign == '-') {
    pch = strchr(flags, *changes);
    if(pch) {
     set = pch + 1;
     while(*pch)
      *pch++ = *set++;
    }
   }
  }
 }
 return;
}

canonical_original_code:
void modifyFlags(char *flags, char *changes)
{
 char ptt[2];
 char *pch; char *set;
 char sign = '+';
 for(ptt[1] = 0; *changes; changes++)
 {
  if(*changes == '+' || *changes == '-') {
   sign = *changes;
  } else if(strchr("ABIOVabcdefhijklmnoprstxyz", *changes)) {
   if(sign == '+' && !strchr(flags, *changes)) {
    ptt[0] = *changes;
    strcat(flags, ptt);
   } else if(sign == '-') {
    pch = strchr(flags, *changes);
    if(pch) {
     set = pch + 1;
     while(*pch)
      *pch++ = *set++;
    }
   }
  }
 }
 return;
}

variable_types:
flags
char *

variable_types:
changes
char *

variable_types:
ptt
char [2]

variable_types:
set
char *

variable_types: sign char


decompiled_code:
char *__fastcall str_remove(char *haystack, char *needle)
{
int v2; // ebx
char *result; // rax
char *v4; // rdi
const char *v5; // rax

v2 = strlen(needle);
result = strstr(haystack, needle);
if ( result )
{
v4 = result;
do
{
v5 = (const char *)memcpy(v4, &v4[v2], v2 + 1);
result = strstr(v5, needle);
v4 = result;
}
while ( result );
}
return result;
}

canonical_decompiled_code:
char *__fastcall func1(char *haystack, char *needle)
{
int v2; // ebx
char *result; // rax
char *v4; // rdi
const char *v5; // rax

v2 = strlen(needle);
result = strstr(haystack, needle);
if ( result )
{
v4 = result;
do
{
v5 = (const char *)memcpy(v4, &v4[v2], v2 + 1);
result = strstr(v5, needle);
v4 = result;
}
while ( result );
}
return result;
}

original_code:
void str_remove(char *str, char *remove)
{
 int len, rlen;
 char *pch;
 len = strlen(str);
 rlen = strlen(remove);
 pch = strstr(str, remove);
 while(pch)
 {
  memcpy(pch, pch + rlen, rlen + 1);
  pch = strstr(pch, remove);
 }
 return;
}

canonical_original_code:
void str_remove(char *str, char *remove)
{
 int len; int rlen;
 char *pch;
 len = strlen(str);
 rlen = strlen(remove);
 pch = strstr(str, remove);
 while(pch)
 {
  memcpy(pch, pch + rlen, rlen + 1);
  pch = strstr(pch, remove);
 }
 return;
}

variable_types:
str
char *

variable_types:
remove
char *

variable_types: len int

variable_types: rlen int

variable_types:
pch
char *


strmi

decompiled_code:
__int64 __fastcall strmi(__int64 a1, __int64 a2)
{
const __int32_t *v3; // rcx
__int64 v4; // rax
__int64 v5; // rdi

v3 = *_ctype_tolower_loc();
v4 = 0LL;
do
{
v5 = *(char *)(a1 + v4);
if ( v3[v5] != v3[*(char *)(a2 + v4)] )
return 0LL;
++v4;
}
while ( (_BYTE)v5 );
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
const __int32_t *v3; // rcx
__int64 v4; // rax
__int64 v5; // rdi

v3 = *_ctype_tolower_loc();
v4 = 0LL;
do
{
v5 = *(char *)(a1 + v4);
if ( v3[v5] != v3[*(char *)(a2 + v4)] )
return 0LL;
++v4;
}
while ( (_BYTE)v5 );
return 1LL;
}

original_code:
int strmi(char *str1, char *str2)
{
 int i = 0;
 for(;;i++) {
  if(tolower(str1[i]) != tolower(str2[i]))
   return 0;
  if(str1[i] == '\0')
   return 1;
 }
 return 1;
}

variable_types: i int


tokenize

decompiled_code:
__int64 __fastcall tokenize(char *a1, const char *a2, char **a3, int a4)
{
unsigned int v5; // er12
char *i; // rax

v5 = 0;
for ( i = strtok(a1, a2); i; i = strtok(0LL, a2) )
{
if ( a4 > (int)v5 )
*a3 = i;
++v5;
++a3;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1, const char *a2, char **a3, int a4)
{
unsigned int v5; // er12
char *i; // rax

v5 = 0;
for ( i = strtok(a1, a2); i; i = strtok(0LL, a2) )
{
if ( a4 > (int)v5 )
*a3 = i;
++v5;
++a3;
}
return v5;
}

original_code:
int tokenize( char *line, char *separators, char *tokens[], int max )
{
   int i = 0;
   char *pch;
   pch = (char*)strtok( line, separators );
   while(pch != ((void *)0))
   {
      if ( i < max )
         tokens[i] =pch;
      pch = (char*)strtok( ((void *)0), separators );
      i++;
   }
   return( i );
}

canonical_original_code:
int tokenize(char *line, char *separators, char *tokens[], int max)
{
   int i = 0;
   char *pch;
   pch = (char *)strtok( line, separators );
   while(pch != ((void *)0))
   {
      if ( i < max )
         tokens[i] =pch;
      pch = (char *)strtok( ((void *)0), separators );
      i++;
   }
   return( i );
}

variable_types:
line
char *

variable_types:
separators
char *

variable_types:
tokens
char *[]

variable_types: max int


decompiled_code:
_BOOL8 __fastcall write_memory(const char *a1, const void *a2, unsigned int a3)
{
int v4; // ebp
_BOOL8 result; // rax
int v6; // er12

v4 = open(a1, 65, 0LL);
result = 0LL;
if ( v4 != -1 )
{
v6 = write(v4, a2, a3);
close(v4);
result = a3 == v6;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(const char *a1, const void *a2, unsigned int a3)
{
int v4; // ebp
_BOOL8 result; // rax
int v6; // er12

v4 = open(a1, 65, 0LL);
result = 0LL;
if ( v4 != -1 )
{
v6 = write(v4, a2, a3);
close(v4);
result = a3 == v6;
}
return result;
}

original_code:
int write_memory(char *file, char *begin, unsigned size)
{
 int handle, bytes;
 handle = open(file, 0100 | 01, 0);
 if(handle == -1)
  return 0;
 bytes = write(handle, begin, size);
 close(handle);
 if(bytes != size)
  return 0;
 return 1;
}

canonical_original_code:
int write_memory(char *file, char *begin, unsigned int size)
{
 int handle; int bytes;
 handle = open(file, 0100 | 01, 0);
 if(handle == -1)
  return 0;
 bytes = write(handle, begin, size);
 close(handle);
 if(bytes != size)
  return 0;
 return 1;
}

variable_types:
file
char *

variable_types:
begin
char *

variable_types:
size
unsigned int

variable_types: handle int

variable_types: bytes int


decompiled_code:
_BOOL8 __fastcall read_memory(const char *a1, void *a2, unsigned int a3)
{
int v4; // ebp
_BOOL8 result; // rax
int v6; // er12

v4 = open(a1, 0, 0LL);
result = 0LL;
if ( v4 != -1 )
{
v6 = read(v4, a2, a3);
close(v4);
result = a3 == v6;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(const char *a1, void *a2, unsigned int a3)
{
int v4; // ebp
_BOOL8 result; // rax
int v6; // er12

v4 = open(a1, 0, 0LL);
result = 0LL;
if ( v4 != -1 )
{
v6 = read(v4, a2, a3);
close(v4);
result = a3 == v6;
}
return result;
}

original_code:
int read_memory(char *file, char *begin, unsigned size)
{
 int handle, bytes;
 handle = open(file, 00, 0);
 if(handle == -1)
  return 0;
 bytes = read(handle, begin, size);
 close(handle);
 if(bytes != size)
  return 0;
 return 1;
}

canonical_original_code:
int read_memory(char *file, char *begin, unsigned int size)
{
 int handle; int bytes;
 handle = open(file, 00, 0);
 if(handle == -1)
  return 0;
 bytes = read(handle, begin, size);
 close(handle);
 if(bytes != size)
  return 0;
 return 1;
}


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 *


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

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);
result = &dbuffer_0;
}
else
{
if ( (_DWORD)v3 )
sprintf(&dbuffer_0, "%dh %dm", v3, (unsigned int)v4);
else
sprintf(&dbuffer_0, "%dm", (unsigned int)v4);
result = &dbuffer_0;
}
return result;
}

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

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);
result = &dbuffer_0;
}
else
{
if ( (_DWORD)v3 )
sprintf(&dbuffer_0, "%dh %dm", v3, (unsigned int)v4);
else
sprintf(&dbuffer_0, "%dm", (unsigned int)v4);
result = &dbuffer_0;
}
return result;
}

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 *


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 int v2; // er12
unsigned __int8 *v3; // rbx

v2 = *a1;
if ( (_BYTE)v2 )
{
v3 = a1;
do
{
if ( strchr(a2, (char)v2) )
break;
v2 = *++v3;
}
while ( (_BYTE)v2 );
}
return v2;
}

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

v2 = *a1;
if ( (_BYTE)v2 )
{
v3 = a1;
do
{
if ( strchr(a2, (char)v2) )
break;
v2 = *++v3;
}
while ( (_BYTE)v2 );
}
return v2;
}

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]


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
char *result; // rax

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

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

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

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
FILE *v1; // rdi
int v2; // esi
__int64 v3; // r8
const char *v4; // rcx
__int64 v5; // rdx

init_oj();
lastConnect = time(0LL);
v0 = get_next_server();
v1 = out;
v2 = *((_DWORD *)v0 + 6);
v3 = *((unsigned int *)v0 + 2);
serv = v0;
v4 = *(const char **)v0;
v5 = (unsigned int)(v2 + 1);
*((_DWORD *)v0 + 6) = v5;
fprintf(v1, "Connection attempt %d [%s:%d]\n", v5, v4, v3);
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
FILE *v1; // rdi
int v2; // esi
__int64 v3; // r8
const char *v4; // rcx
__int64 v5; // rdx

init_oj();
lastConnect = time(0LL);
v0 = func2();
v1 = out;
v2 = *((_DWORD *)v0 + 6);
v3 = *((unsigned int *)v0 + 2);
serv = v0;
v4 = *(const char **)v0;
v5 = (unsigned int)(v2 + 1);
*((_DWORD *)v0 + 6) = v5;
fprintf(v1, "Connection attempt %d [%s:%d]\n", v5, v4, v3);
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; // r13
int v5; // er12
size_t v6; // rax
int v7; // ebx
size_t v8; // rax
char *v9; // rax
__int64 v10; // rax
char *v11; // rdx
int v12; // eax
int v14; // er12
size_t v15; // rax
int v16; // ebx
char *v17; // rdx

v1 = strchr(s, 58);
if ( !v1 )
{
v14 = 6667;
goto LABEL_6;
}
*v1 = 0;
v2 = v1 + 1;
v3 = strchr(v1 + 1, 32);
if ( !v3 )
{
v14 = atoi(v2);
LABEL_6:
v15 = strlen(s);
v16 = numserves;
*((_QWORD *)&servers + 5 * v16) = myalloc(v15 + 1);
v10 = numserves;
v17 = (char *)&servers + 40 * numserves;
*((_DWORD *)v17 + 2) = v14;
*((_QWORD *)v17 + 2) = 0LL;
goto LABEL_4;
}
*v3 = 0;
v4 = v3 + 1;
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);
v10 = numserves;
LABEL_4:
strcpy(*((char **)&servers + 5 * v10), s);
v11 = (char *)&servers + 40 * numserves;
v12 = numserves + 1;
*((_QWORD *)v11 + 3) = 0LL;
*((_DWORD *)v11 + 8) = 0;
numserves = v12;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s)
{
char *v1; // rax
const char *v2; // r12
char *v3; // rax
const char *v4; // r13
int v5; // er12
size_t v6; // rax
int v7; // ebx
size_t v8; // rax
char *v9; // rax
__int64 v10; // rax
char *v11; // rdx
int v12; // eax
int v14; // er12
size_t v15; // rax
int v16; // ebx
char *v17; // rdx

v1 = strchr(s, 58);
if ( !v1 )
{
v14 = 6667;
goto LABEL_6;
}
*v1 = 0;
v2 = v1 + 1;
v3 = strchr(v1 + 1, 32);
if ( !v3 )
{
v14 = atoi(v2);
LABEL_6:
v15 = strlen(s);
v16 = numserves;
*((_QWORD *)&servers + 5 * v16) = myalloc(v15 + 1);
v10 = numserves;
v17 = (char *)&servers + 40 * numserves;
*((_DWORD *)v17 + 2) = v14;
*((_QWORD *)v17 + 2) = 0LL;
goto LABEL_4;
}
*v3 = 0;
v4 = v3 + 1;
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);
v10 = numserves;
LABEL_4:
strcpy(*((char **)&servers + 5 * v10), s);
v11 = (char *)&servers + 40 * numserves;
v12 = numserves + 1;
*((_QWORD *)v11 + 3) = 0LL;
*((_DWORD *)v11 + 8) = 0;
numserves = v12;
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()
{
int v0; // ebp
void **v1; // rbx
void *v2; // rdi

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

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

if ( numserves > 0 )
{
v0 = 0;
v1 = (void **)&servers;
do
{
free(*v1);
v2 = v1[2];
if ( v2 )
free(v2);
++v0;
v1 += 5;
}
while ( numserves > v0 );
}
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; // er8

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

canonical_decompiled_code:
__int64 __fastcall func0(char *a1)
{
char v1; // al
char v2; // dl
unsigned int v3; // er8

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

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;
while ( 1 )
{
while ( (unsigned __int8)(v1 - 65) <= 0x19u )
{
v3 = v3 + 1.0;
LABEL_4:
v1 = *++a1;
if ( !v1 )
return (unsigned int)(int)(float)((float)(v3 / (float)(v2 + v3)) * 100.0);
}
if ( (unsigned __int8)(v1 - 97) > 0x19u )
goto LABEL_4;
v1 = *++a1;
v2 = v2 + 1.0;
if ( !v1 )
return (unsigned int)(int)(float)((float)(v3 / (float)(v2 + v3)) * 100.0);
}
}
return 50LL;
}

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

v1 = *a1;
if ( *a1 )
{
v2 = *(float *)&LC0;
v3 = *(float *)&LC0;
while ( 1 )
{
while ( (unsigned __int8)(v1 - 65) <= 0x19u )
{
v3 = v3 + 1.0;
LABEL_4:
v1 = *++a1;
if ( !v1 )
return (unsigned int)(int)(float)((float)(v3 / (float)(v2 + v3)) * 100.0);
}
if ( (unsigned __int8)(v1 - 97) > 0x19u )
goto LABEL_4;
v1 = *++a1;
v2 = v2 + 1.0;
if ( !v1 )
return (unsigned int)(int)(float)((float)(v3 / (float)(v2 + v3)) * 100.0);
}
}
return 50LL;
}

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


decompiled_code:
__int64 __fastcall ctrlchar_percent(char *a1)
{
char v1; // al
float v2; // xmm1_4
unsigned __int8 v3; // si
char v4; // dl
char v5; // cl
float v6; // xmm0_4

v1 = *a1;
if ( *a1 )
{
v2 = *(float *)&LC3;
v3 = 0;
v4 = 0;
v5 = 0;
v6 = *(float *)&LC3;
while ( 1 )
{
while ( 1 )
{
if ( v1 == 22 )
{
v3 = v4 ^ 1;
goto LABEL_5;
}
if ( v1 <= 22 )
break;
if ( v1 != 31 )
{
LABEL_14:
if ( v3 | (unsigned __int8)(v5 | v4) )
{
v6 = v6 + 1.0;
}
else
{
v2 = v2 + 1.0;
v3 = 0;
v4 = 0;
v5 = 0;
}
goto LABEL_5;
}
v4 ^= 1u;
LABEL_5:
v1 = *++a1;
if ( !v1 )
return (unsigned int)(int)(float)((float)(v6 / (float)(v2 + v6)) * 100.0);
}
if ( v1 != 2 )
{
if ( v1 != 15 )
goto LABEL_14;
v3 = 0;
v4 = 0;
v5 = 0;
goto LABEL_5;
}
v1 = *++a1;
v5 ^= 1u;
if ( !v1 )
return (unsigned int)(int)(float)((float)(v6 / (float)(v2 + v6)) * 100.0);
}
}
return 50LL;
}

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 int v2; // er8
int v3; // ecx
int v4; // edx

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

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int8 *a1)
{
unsigned __int8 v1; // al
unsigned int v2; // er8
int v3; // ecx
int v4; // edx

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

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(__int64 a1)
{
size_t v1; // rdx
int v2; // eax

v1 = a1 + strlen((const char *)a1) - 1;
v2 = 0;
while ( a1 != v1 )
{
if ( *(_BYTE *)a1 == *(_BYTE *)(a1 + 1) )
{
if ( config[255] <= ++v2 )
return 1LL;
}
else
{
v2 = 0;
}
++a1;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
size_t v1; // rdx
int v2; // eax

v1 = a1 + strlen((const char *)a1) - 1;
v2 = 0;
while ( a1 != v1 )
{
if ( *(_BYTE *)a1 == *(_BYTE *)(a1 + 1) )
{
if ( config[255] <= ++v2 )
return 1LL;
}
else
{
v2 = 0;
}
++a1;
}
return 0LL;
}

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:
__int64 __fastcall chan_msg(__int64 a1, __int64 a2, char *a3, _QWORD *a4, __int64 a5, char a6)
{
__int64 result; // rax
__int64 v10; // rdi
const char **v11; // rbp
int *v12; // rbx
int v13; // eax
const void *v14; // rsi
time_t v15; // r14
const char *v16; // rdx
int v17; // eax
bool v18; // cc
time_t v19; // r14
int v20; // eax
int v21; // eax
int v22; // eax
int v23; // er14
__int64 v24; // r15
signed __int64 v25; // rbx
char v26; // al
char *v27; // rax
__int64 v28; // rax
__int64 v29; // rax
unsigned int v30; // eax
__int64 v31; // rax
unsigned int v32; // eax
__int64 v33; // rax
__int64 v34; // rax
__int64 v35; // rax
int v36; // er8
const char *v37; // rax
__int64 v38; // rbx
int v39; // eax
__int64 v40; // rax
__int64 v41; // rax
__int64 v42; // rax
__int64 v43; // rax
__int64 v44; // rax
int v45; // [rsp+4h] [rbp-454h]
char *s; // [rsp+8h] [rbp-450h]
int v48; // [rsp+14h] [rbp-444h]
__int64 v49; // [rsp+18h] [rbp-440h]
char v50[512]; // [rsp+20h] [rbp-438h] BYREF
char v51[568]; // [rsp+220h] [rbp-238h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2, char *a3, _QWORD *a4, __int64 a5, char a6)
{
__int64 result; // rax
__int64 v10; // rdi
const char **v11; // rbp
int *v12; // rbx
int v13; // eax
const void *v14; // rsi
time_t v15; // r14
const char *v16; // rdx
int v17; // eax
bool v18; // cc
time_t v19; // r14
int v20; // eax
int v21; // eax
int v22; // eax
int v23; // er14
__int64 v24; // r15
signed __int64 v25; // rbx
char v26; // al
char *v27; // rax
__int64 v28; // rax
__int64 v29; // rax
unsigned int v30; // eax
__int64 v31; // rax
unsigned int v32; // eax
__int64 v33; // rax
__int64 v34; // rax
__int64 v35; // rax
int v36; // er8
const char *v37; // rax
__int64 v38; // rbx
int v39; // eax
__int64 v40; // rax
__int64 v41; // rax
__int64 v42; // rax
__int64 v43; // rax
__int64 v44; // rax
int v45; // [rsp+4h] [rbp-454h]
char *s; // [rsp+8h] [rbp-450h]
int v48; // [rsp+14h] [rbp-444h]
__int64 v49; // [rsp+18h] [rbp-440h]
char v50[512]; // [rsp+20h] [rbp-438h] BYREF
char v51[568]; // [rsp+220h] [rbp-238h] BYREF

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

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]


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 != &pmap + 130 );
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 != &pmap + 130 );
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; // r12
char v11; // al
__int64 *v12; // rbx
char v13[32]; // [rsp+0h] [rbp-158h] BYREF
char s[312]; // [rsp+20h] [rbp-138h] 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_C00, *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;
}
v10 = LOBYTE(pmap[5 * (int)v8]) + a4;
*(_BYTE *)(v9 + 48) += v10;
*(_BYTE *)(v9 + 49) += v10;
if ( time(0LL) - *(int *)(a2 + 84) <= 59 )
{
++*(_BYTE *)(v9 + 49);
*(_BYTE *)(v9 + 48) += 2;
}
if ( a5 )
snprintf(s, 0xFAuLL, "%s (%s)", (const char *)pmap[5 * (int)v8 + 2], a5);
else
mystrncpy(s, pmap[5 * (int)v8 + 2], 250LL);
v11 = *(_BYTE *)(v9 + 49);
if ( v11 <= 1 )
{
snprintf(punbuf, 0x1FEuLL, (const char *)(unsigned int)((_DWORD)&config + 709), a2, *a1, s);
quickMsg(punbuf);
strcpy(v13, "warn");
}
else if ( v11 == 2 )
{
snprintf(punbuf, 0x1FEuLL, "KICK %s %s :[Warning] %s", *a1, (const char *)a2, s);
quickMsg(punbuf);
strcpy(v13, "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)), s);
strcpy(v13, "ban");
}
v12 = &pmap[5 * (int)v8];
sprintf(punbuf, asc_C38, *a1, a2, (unsigned int)*(char *)(v9 + 48), v12[1], v13);
sRelay(punbuf);
++*((_DWORD *)v12 + 8);
}
}
}
}
}
}

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; // r12
char v11; // al
__int64 *v12; // rbx
char v13[32]; // [rsp+0h] [rbp-158h] BYREF
char s[312]; // [rsp+20h] [rbp-138h] 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_C00, *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;
}
v10 = LOBYTE(pmap[5 * (int)v8]) + a4;
*(_BYTE *)(v9 + 48) += v10;
*(_BYTE *)(v9 + 49) += v10;
if ( time(0LL) - *(int *)(a2 + 84) <= 59 )
{
++*(_BYTE *)(v9 + 49);
*(_BYTE *)(v9 + 48) += 2;
}
if ( a5 )
snprintf(s, 0xFAuLL, "%s (%s)", (const char *)pmap[5 * (int)v8 + 2], a5);
else
mystrncpy(s, pmap[5 * (int)v8 + 2], 250LL);
v11 = *(_BYTE *)(v9 + 49);
if ( v11 <= 1 )
{
snprintf(punbuf, 0x1FEuLL, (const char *)(unsigned int)((_DWORD)&config + 709), a2, *a1, s);
quickMsg(punbuf);
strcpy(v13, "warn");
}
else if ( v11 == 2 )
{
snprintf(punbuf, 0x1FEuLL, "KICK %s %s :[Warning] %s", *a1, (const char *)a2, s);
quickMsg(punbuf);
strcpy(v13, "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)), s);
strcpy(v13, "ban");
}
v12 = &pmap[5 * (int)v8];
sprintf(punbuf, asc_C38, *a1, a2, (unsigned int)*(char *)(v9 + 48), v12[1], v13);
sRelay(punbuf);
++*((_DWORD *)v12 + 8);
}
}
}
}
}
}

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


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

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

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

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

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]