decompiled_code:
__int64 __fastcall module_create_client_on(__int64 a1, const char *a2, const char *a3, const char *a4, const char *a5, const char *a6, const char *a7, const char *a8)
{
const char *v10; // r14
char *v11; // rdx
const char *v12; // rax
__int64 v14; // [rsp+8h] [rbp-70h]
const char *v15; // [rsp+10h] [rbp-68h]
const char *v16; // [rsp+18h] [rbp-60h]

v10 = a7;
v14 = server_freenum();
if ( !*a6 && strchr(a5, 114) )
a6 = a2;
if ( !*a7 && strchr(a5, 111) )
v10 = a2;
v15 = (const char *)unum2str(v14);
if ( strchr(a5, 111) )
{
v16 = " ";
}
else
{
v10 = (const char *)&LC22;
v16 = (const char *)&LC22;
}
v11 = strchr(a5, 114);
v12 = " ";
if ( !v11 )
{
a6 = (const char *)&LC22;
v12 = (const char *)&LC22;
}
send_format(
"%s N %s 1 %ld %s %s %s%s%s%s%s %s %s :%s\r\n",
(const char *)(a1 + 24),
a2,
now,
a3,
a4,
a5,
v12,
a6,
v16,
v10,
"B]AAAB",
v15,
a8);
return get_user_by_numeric(v14);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, const char *a2, const char *a3, const char *a4, const char *a5, const char *a6, const char *a7, const char *a8)
{
const char *v10; // r14
char *v11; // rdx
const char *v12; // rax
__int64 v14; // [rsp+8h] [rbp-70h]
const char *v15; // [rsp+10h] [rbp-68h]
const char *v16; // [rsp+18h] [rbp-60h]

v10 = a7;
v14 = server_freenum();
if ( !*a6 && strchr(a5, 114) )
a6 = a2;
if ( !*a7 && strchr(a5, 111) )
v10 = a2;
v15 = (const char *)unum2str(v14);
if ( strchr(a5, 111) )
{
v16 = " ";
}
else
{
v10 = (const char *)&LC22;
v16 = (const char *)&LC22;
}
v11 = strchr(a5, 114);
v12 = " ";
if ( !v11 )
{
a6 = (const char *)&LC22;
v12 = (const char *)&LC22;
}
send_format(
"%s N %s 1 %ld %s %s %s%s%s%s%s %s %s :%s\r\n",
(const char *)(a1 + 24),
a2,
now,
a3,
a4,
a5,
v12,
a6,
v16,
v10,
"B]AAAB",
v15,
a8);
return get_user_by_numeric(v14);
}

original_code:
struct user *module_create_client_on(struct server *server, const char *nick, const char *ident, const char *hostname, const char *modes, const char *account, const char *opername, const char *realname) {
 unsigned long numeric = server_freenum(server);
 if (!strlen(account) && strchr(modes, 'r') != ((void *)0)) account = nick;
 if (!strlen(opername) && strchr(modes, 'o') != ((void *)0)) opername = nick;
 send_format("%s N %s 1 %ld %s %s %s%s%s%s%s %s %s :%s" "\r\n", server->numericstr, nick, now, ident, hostname, modes, (strchr(modes, 'r') == ((void *)0) ? "" : " "), (strchr(modes, 'r') == ((void *)0) ? "" : account), (strchr(modes, 'o') == ((void *)0) ? "" : " "), (strchr(modes, 'o') == ((void *)0) ? "" : opername), "B]AAAB", unum2str(numeric), realname);
 return get_user_by_numeric(numeric);
}

canonical_original_code:
struct user *module_create_client_on(struct server *server, char *nick, char *ident, char *hostname, char *modes, char *account, char *opername, char *realname) {
 unsigned long numeric = server_freenum(server);
 if (!strlen(account) && strchr(modes, 'r') != ((void *)0)) account = nick;
 if (!strlen(opername) && strchr(modes, 'o') != ((void *)0)) opername = nick;
 send_format("%s N %s 1 %ld %s %s %s%s%s%s%s %s %s :%s" "\r\n", server->numericstr, nick, now, ident, hostname, modes, (strchr(modes, 'r') == ((void *)0) ? "" : " "), (strchr(modes, 'r') == ((void *)0) ? "" : account), (strchr(modes, 'o') == ((void *)0) ? "" : " "), (strchr(modes, 'o') == ((void *)0) ? "" : opername), "B]AAAB", unum2str(numeric), realname);
 return get_user_by_numeric(numeric);
}

variable_types:
server
struct server *

variable_types:
nick
char *

variable_types:
ident
char *

variable_types:
hostname
char *

variable_types:
modes
char *

variable_types:
account
char *

variable_types:
opername
char *

variable_types:
realname
char *

variable_types:
numeric
unsigned long


repo: thommey/plservices

decompiled_code:
__int64 __fastcall module_create_client(const char *a1, const char *a2, const char *a3, const char *a4, const char *a5, const char *a6, const char *a7)
{
return module_create_client_on(me, a1, a2, a3, a4, a5, a6, a7);
}

canonical_decompiled_code:
__int64 __fastcall func13(const char *a1, const char *a2, const char *a3, const char *a4, const char *a5, const char *a6, const char *a7)
{
return func12(me, a1, a2, a3, a4, a5, a6, a7);
}

original_code:
struct user *module_create_client(const char *nick, const char *ident, const char *hostname, const char *modes, const char *account, const char *opername, const char *realname) {
 return module_create_client_on(me, nick, ident, hostname, modes, account, opername, realname);
}

canonical_original_code:
struct user *module_create_client(char *nick, char *ident, char *hostname, char *modes, char *account, char *opername, char *realname) {
 return module_create_client_on(me, nick, ident, hostname, modes, account, opername, realname);
}

return_type: struct user { unsigned int magic; unsigned long numeric; char numericstr[-1]; char nick[-1]; char user[-1]; char host[-1]; char fakehost[-1]; char opername[-1]; char account[-1]; long acctime; long accid; char realname[-1]; int hops; unsigned int accountid; char awaymsg[-1]; unsigned long mode; int channelcount; struct jtableP { void *t; } channels; struct server { unsigned int magic; unsigned long numeric; unsigned long lastnumeric; char numericstr[-1]; char name[-1]; unsigned long maxusers; int hops; long boot; long link; char protocol[4]; char description[-1]; struct jtableP users; unsigned long mode; } *server; } *

user_defined_types: struct user { unsigned int magic; unsigned long numeric; char numericstr[-1]; char nick[-1]; char user[-1]; char host[-1]; char fakehost[-1]; char opername[-1]; char account[-1]; long acctime; long accid; char realname[-1]; int hops; unsigned int accountid; char awaymsg[-1]; unsigned long mode; int channelcount; struct jtableP channels; struct server *server; }


decompiled_code:
unsigned __int64 __fastcall module_destroy_client(__int64 a1, const char *a2)
{
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
send_format("%s Q :%s\r\n", (const char *)(a1 + 16), a2);
return v3 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func14(__int64 a1, const char *a2)
{
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
send_format("%s Q :%s\r\n", (const char *)(a1 + 16), a2);
return v3 - __readfsqword(0x28u);
}

original_code:
void module_destroy_client(struct user *from, const char *message) {
 send_format("%s Q :%s" "\r\n", from->numericstr, message);
}

canonical_original_code:
void module_destroy_client(struct user *from, char *message) {
 send_format("%s Q :%s" "\r\n", from->numericstr, message);
}

variable_types: struct user { unsigned int magic; unsigned long numeric; char numericstr[-1]; char nick[-1]; char user[-1]; char host[-1]; char fakehost[-1]; char opername[-1]; char account[-1]; long acctime; long accid; char realname[-1]; int hops; unsigned int accountid; char awaymsg[-1]; unsigned long mode; int channelcount; struct jtableP { void *t; } channels; struct server { unsigned int magic; unsigned long numeric; unsigned long lastnumeric; char numericstr[-1]; char name[-1]; unsigned long maxusers; int hops; long boot; long link; char protocol[4]; char description[-1]; struct jtableP users; unsigned long mode; } *server; } *

variable_types:
message
char *

return_type: void


getmodeflags

decompiled_code:
__int64 __fastcall getmodeflags(__int64 a1, unsigned __int8 a2)
{
return *(unsigned __int8 *)(a1 + a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned __int8 a2)
{
return *(unsigned __int8 *)(a1 + a2);
}

original_code:
static unsigned char getmodeflags(char *modelist, char modechar) {
 return modelist[(unsigned char)modechar];
}

variable_types:
modelist
char *

variable_types: modechar char

return_type: unsigned char


decompiled_code:
unsigned __int64 mode_ontick()
{
unsigned __int64 v1; // [rsp+8h] [rbp-10h]

v1 = __readfsqword(0x28u);
jtableL_iterate(&modebufs, &mode_flushmode_check, 0LL);
return v1 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 func2()
{
unsigned __int64 v1; // [rsp+8h] [rbp-10h]

v1 = __readfsqword(0x28u);
jtableL_iterate(&modebufs, &mode_flushmode_check, 0LL);
return v1 - __readfsqword(0x28u);
}

original_code:
void mode_ontick(void) {
 jtableL_iterate(&modebufs, (jtableL_cb)mode_flushmode_check, ((void *)0));
}

canonical_original_code:
void mode_ontick() {
 jtableL_iterate(&modebufs, (void (*)(unsigned long key, void *data, void *param))mode_flushmode_check, ((void *)0));
}


decompiled_code:
unsigned __int64 init_modes()
{
void **v0; // rbp
unsigned __int8 *v1; // rbx
unsigned __int8 v2; // si
unsigned __int8 *i; // rbx
void **v4; // rbp
unsigned __int8 *v5; // rbx
unsigned __int8 v6; // si
unsigned __int8 *j; // rbx
unsigned __int8 *v8; // rbx
unsigned __int8 v9; // si
unsigned __int64 v11; // [rsp+8h] [rbp-20h]

v11 = __readfsqword(0x28u);
v0 = &chanmodetable;
v1 = (unsigned __int8 *)&LC0;
do
{
v2 = *v1;
for ( i = v1 + 1; v2; v2 = *(i - 1) )
{
registermode((__int64)&chanmodelist, v2, *((_BYTE *)v0 + 8));
++i;
}
v0 += 2;
v1 = (unsigned __int8 *)*v0;
}
while ( *v0 );
v4 = &usermodetable;
v5 = (unsigned __int8 *)&LC1;
do
{
v6 = *v5;
for ( j = v5 + 1; v6; v6 = *(j - 1) )
{
registermode((__int64)&usermodelist, v6, *((_BYTE *)v4 + 8));
++j;
}
v4 += 2;
v5 = (unsigned __int8 *)*v4;
}
while ( *v4 );
v8 = (unsigned __int8 *)"sn6";
v9 = 104;
do
{
registermode((__int64)&servermodelist, v9, -128);
v9 = *v8++;
}
while ( v9 );
hook_hook("ontick", mode_ontick);
hook_hook("onuserdel", mode_flushmode_deletion);
hook_hook("onserverdel", mode_flushmode_deletion);
return v11 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 func3()
{
void **v0; // rbp
unsigned __int8 *v1; // rbx
unsigned __int8 v2; // si
unsigned __int8 *i; // rbx
void **v4; // rbp
unsigned __int8 *v5; // rbx
unsigned __int8 v6; // si
unsigned __int8 *j; // rbx
unsigned __int8 *v8; // rbx
unsigned __int8 v9; // si
unsigned __int64 v11; // [rsp+8h] [rbp-20h]

v11 = __readfsqword(0x28u);
v0 = &chanmodetable;
v1 = (unsigned __int8 *)&LC0;
do
{
v2 = *v1;
for ( i = v1 + 1; v2; v2 = *(i - 1) )
{
func1((__int64)&chanmodelist, v2, *((_BYTE *)v0 + 8));
++i;
}
v0 += 2;
v1 = (unsigned __int8 *)*v0;
}
while ( *v0 );
v4 = &usermodetable;
v5 = (unsigned __int8 *)&LC1;
do
{
v6 = *v5;
for ( j = v5 + 1; v6; v6 = *(j - 1) )
{
func1((__int64)&usermodelist, v6, *((_BYTE *)v4 + 8));
++j;
}
v4 += 2;
v5 = (unsigned __int8 *)*v4;
}
while ( *v4 );
v8 = (unsigned __int8 *)"sn6";
v9 = 104;
do
{
func1((__int64)&servermodelist, v9, -128);
v9 = *v8++;
}
while ( v9 );
hook_hook("ontick", mode_ontick);
hook_hook("onuserdel", mode_flushmode_deletion);
hook_hook("onserverdel", mode_flushmode_deletion);
return v11 - __readfsqword(0x28u);
}

original_code:
void init_modes() {
 int i, j;
 for (i = 0; chanmodetable[i].modes; i++)
  for (j = 0; chanmodetable[i].modes[j]; j++)
   registermode(chanmodelist, chanmodetable[i].modes[j], chanmodetable[i].type);
 for (i = 0; usermodetable[i].modes; i++)
  for (j = 0; usermodetable[i].modes[j]; j++)
   registermode(usermodelist, usermodetable[i].modes[j], usermodetable[i].type);
 for (i = 0; servermodetable[i].modes; i++)
  for (j = 0; servermodetable[i].modes[j]; j++)
   registermode(servermodelist, servermodetable[i].modes[j], servermodetable[i].type);
 hook_hook("ontick", mode_ontick);
 hook_hook("onuserdel", mode_flushmode_deletion);
 hook_hook("onserverdel", mode_flushmode_deletion);
}

canonical_original_code:
void init_modes() {
 int i; int j;
 for (i = 0; chanmodetable[i].modes; i++)
  for (j = 0; chanmodetable[i].modes[j]; j++)
   registermode(chanmodelist, chanmodetable[i].modes[j], chanmodetable[i].type);
 for (i = 0; usermodetable[i].modes; i++)
  for (j = 0; usermodetable[i].modes[j]; j++)
   registermode(usermodelist, usermodetable[i].modes[j], usermodetable[i].type);
 for (i = 0; servermodetable[i].modes; i++)
  for (j = 0; servermodetable[i].modes[j]; j++)
   registermode(servermodelist, servermodetable[i].modes[j], servermodetable[i].type);
 hook_hook("ontick", mode_ontick);
 hook_hook("onuserdel", mode_flushmode_deletion);
 hook_hook("onserverdel", mode_flushmode_deletion);
}

variable_types: i int

variable_types: j int


decompiled_code:
unsigned __int64 uplink_with_opername()
{
unsigned __int64 v1; // [rsp+8h] [rbp-10h]

v1 = __readfsqword(0x28u);
registermode((__int64)&servermodelist, 0x6Fu, -127);
return v1 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 func4()
{
unsigned __int64 v1; // [rsp+8h] [rbp-10h]

v1 = __readfsqword(0x28u);
func1((__int64)&servermodelist, 0x6Fu, -127);
return v1 - __readfsqword(0x28u);
}

original_code:
void uplink_with_opername(void) {
 registermode(servermodelist, 'o', (0x80|0x01));
}

canonical_original_code:
void uplink_with_opername() {
 registermode(servermodelist, 'o', (0x80|0x01));
}


decompiled_code:
unsigned __int64 uplink_without_opername()
{
unsigned __int64 v1; // [rsp+8h] [rbp-10h]

v1 = __readfsqword(0x28u);
registermode((__int64)&servermodelist, 0x6Fu, -128);
return v1 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 func5()
{
unsigned __int64 v1; // [rsp+8h] [rbp-10h]

v1 = __readfsqword(0x28u);
func1((__int64)&servermodelist, 0x6Fu, -128);
return v1 - __readfsqword(0x28u);
}

original_code:
void uplink_without_opername(void) {
 registermode(servermodelist, 'o', (0x80));
}

canonical_original_code:
void uplink_without_opername() {
 registermode(servermodelist, 'o', (0x80));
}


decompiled_code:
unsigned __int64 __fastcall mode_set1(_QWORD *a1, unsigned __int8 a2)
{
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
*a1 |= 1LL << mode2offset_table[a2];
return v3 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(_QWORD *a1, unsigned __int8 a2)
{
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
*a1 |= 1LL << mode2offset_table[a2];
return v3 - __readfsqword(0x28u);
}

original_code:
void mode_set1(uint64_t *modes, char modechar) {
 *modes |= ((uint64_t)1 << (mode2offset_table[(unsigned char)(modechar)]));
}

canonical_original_code:
void mode_set1(unsigned long *modes, char modechar) {
 *modes |= ((unsigned long)1 << (mode2offset_table[(unsigned char)(modechar)]));
}

variable_types:
modes
unsigned long *


decompiled_code:
__int64 __fastcall mode_check1(_QWORD *a1, unsigned __int8 a2)
{
return (*a1 >> mode2offset_table[a2]) & 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD *a1, unsigned __int8 a2)
{
return (*a1 >> mode2offset_table[a2]) & 1LL;
}

original_code:
int mode_check1(uint64_t *modes, char modechar) {
 return (*modes & ((uint64_t)1 << (mode2offset_table[(unsigned char)(modechar)]))) ? 1 : 0;
}

canonical_original_code:
int mode_check1(unsigned long *modes, char modechar) {
 return (*modes & ((unsigned long)1 << (mode2offset_table[(unsigned char)(modechar)]))) ? 1 : 0;
}

return_type: int


decompiled_code:
unsigned __int64 __fastcall mode_unset1(_QWORD *a1, unsigned __int8 a2)
{
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
*a1 &= __ROL8__(-2LL, mode2offset_table[a2]);
return v3 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func8(_QWORD *a1, unsigned __int8 a2)
{
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
*a1 &= __ROL8__(-2LL, mode2offset_table[a2]);
return v3 - __readfsqword(0x28u);
}

original_code:
void mode_unset1(uint64_t *modes, char modechar) {
 *modes &= ~((uint64_t)1 << (mode2offset_table[(unsigned char)(modechar)]));
}

canonical_original_code:
void mode_unset1(unsigned long *modes, char modechar) {
 *modes &= ~((unsigned long)1 << (mode2offset_table[(unsigned char)(modechar)]));
}


decompiled_code:
__int64 __fastcall mode_apply(__int64 a1, int *a2, _QWORD *a3, const char *a4, unsigned __int8 *a5, int a6, __int64 (__fastcall *a7)(__int64, int *, _QWORD, _QWORD, __int64))
{
int v8; // eax
void *v9; // r14
__int64 v11; // rbx
unsigned int v12; // er12
unsigned __int8 *v13; // rbp
signed __int8 v14; // bl
char v15; // al
unsigned int v16; // eax
unsigned int v17; // [rsp+18h] [rbp-60h]

v8 = *a2;
if ( *a2 == 11988 )
{
v9 = &chanmodelist;
goto LABEL_35;
}
if ( v8 == 18929 )
{
v9 = &usermodelist;
LABEL_35:
v14 = *a4;
v13 = (unsigned __int8 *)a4;
v12 = 1;
v17 = 0;
if ( !*a4 )
return v17;
while ( 1 )
{
if ( v14 == 43 )
{
v12 = 1;
goto LABEL_16;
}
if ( v14 == 45 )
{
v12 = 0;
goto LABEL_16;
}
v15 = getmodeflags((__int64)v9, v14);
if ( v15 >= 0 )
{
logfmt(256LL, "Invalid mode char: %c in sequence %s!\n", (unsigned int)v14, a4);
goto LABEL_16;
}
if ( v12 )
{
if ( (v15 & 0xF) == 0 )
mode_set1(a3, v14);
if ( (getmodeflags((__int64)v9, *v13) & 1) == 0 )
goto LABEL_38;
v11 = 0LL;
if ( *a5 > a6 )
v11 = *(_QWORD *)&a5[8 * a6++ + 8];
++v17;
}
else
{
if ( (v15 & 0xF) == 0 )
mode_unset1(a3, v14);
if ( (getmodeflags((__int64)v9, *v13) & 2) == 0 )
{
LABEL_38:
v16 = a7(a1, a2, v12, (unsigned int)(char)*v13, 0LL);
if ( v16 )
goto LABEL_31;
goto LABEL_16;
}
v11 = 0LL;
if ( *a5 > a6 )
v11 = *(_QWORD *)&a5[8 * a6++ + 8];
++v17;
}
v16 = a7(a1, a2, v12, (unsigned int)(char)*v13, v11);
if ( v16 )
{
if ( v11 && v16 >= 0xFFFFFFFE )
{
--a6;
--v17;
}
LABEL_31:
if ( v16 == -2 )
{
if ( v12 )
mode_unset1(a3, *v13);
else
mode_set1(a3, *v13);
}
}
LABEL_16:
v14 = *++v13;
if ( !*v13 )
return v17;
}
}
v9 = &servermodelist;
if ( v8 == 43065 )
goto LABEL_35;
logtxt(16LL, "Mode change for unknown entity.\n");
return 0;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int *a2, _QWORD *a3, const char *a4, unsigned __int8 *a5, int a6, __int64 (__fastcall *a7)(__int64, int *, _QWORD, _QWORD, __int64))
{
int v8; // eax
void *v9; // r14
__int64 v11; // rbx
unsigned int v12; // er12
unsigned __int8 *v13; // rbp
signed __int8 v14; // bl
char v15; // al
unsigned int v16; // eax
unsigned int v17; // [rsp+18h] [rbp-60h]

v8 = *a2;
if ( *a2 == 11988 )
{
v9 = &chanmodelist;
goto LABEL_35;
}
if ( v8 == 18929 )
{
v9 = &usermodelist;
LABEL_35:
v14 = *a4;
v13 = (unsigned __int8 *)a4;
v12 = 1;
v17 = 0;
if ( !*a4 )
return v17;
while ( 1 )
{
if ( v14 == 43 )
{
v12 = 1;
goto LABEL_16;
}
if ( v14 == 45 )
{
v12 = 0;
goto LABEL_16;
}
v15 = func0((__int64)v9, v14);
if ( v15 >= 0 )
{
logfmt(256LL, "Invalid mode char: %c in sequence %s!\n", (unsigned int)v14, a4);
goto LABEL_16;
}
if ( v12 )
{
if ( (v15 & 0xF) == 0 )
func6(a3, v14);
if ( (func0((__int64)v9, *v13) & 1) == 0 )
goto LABEL_38;
v11 = 0LL;
if ( *a5 > a6 )
v11 = *(_QWORD *)&a5[8 * a6++ + 8];
++v17;
}
else
{
if ( (v15 & 0xF) == 0 )
func8(a3, v14);
if ( (func0((__int64)v9, *v13) & 2) == 0 )
{
LABEL_38:
v16 = a7(a1, a2, v12, (unsigned int)(char)*v13, 0LL);
if ( v16 )
goto LABEL_31;
goto LABEL_16;
}
v11 = 0LL;
if ( *a5 > a6 )
v11 = *(_QWORD *)&a5[8 * a6++ + 8];
++v17;
}
v16 = a7(a1, a2, v12, (unsigned int)(char)*v13, v11);
if ( v16 )
{
if ( v11 && v16 >= 0xFFFFFFFE )
{
--a6;
--v17;
}
LABEL_31:
if ( v16 == -2 )
{
if ( v12 )
func8(a3, *v13);
else
func6(a3, *v13);
}
}
LABEL_16:
v14 = *++v13;
if ( !*v13 )
return v17;
}
}
v9 = &servermodelist;
if ( v8 == 43065 )
goto LABEL_35;
logtxt(16LL, "Mode change for unknown entity.\n");
return 0;
}

original_code:
int mode_apply(struct entity *from, struct entity *target, uint64_t *modes, char *modechanges, struct manyargs *arg, int skip, modehook func) {
 char *modelist;
 char *mc = modechanges;
 char *param;
 int ret, argsused = 0, pls = 1;
 if ((((struct entity *)(target))->magic == 0x2ED4))
  modelist = chanmodelist;
 else if ((((struct entity *)(target))->magic == 0x49F1))
  modelist = usermodelist;
 else if ((((struct entity *)(target))->magic == 0xA839))
  modelist = servermodelist;
 else {
  logtxt(0x0010, "Mode change for unknown entity." "\n");
  return 0;
 }
 while (*mc) {
  param = ((void *)0);
  switch (*mc) {
   case '+':
    pls = 1;
    break;
   case '-':
    pls = 0;
    break;
   default:
    if (!(getmodeflags((modelist), (*mc)) & 0x80)) {
     logfmt(0x0100, "Invalid mode char: %c in sequence %s!" "\n", *mc, modechanges);
     break;
    }
    if (pls) {
     if (!(getmodeflags((modelist), (*mc)) & (0x04|0x01)) && !(getmodeflags((modelist), (*mc)) & (0x08|0x01|0x02)))
      mode_set1(modes, *mc);
     if ((getmodeflags((modelist), (*mc)) & 0x01)) {
      param = skip < arg->c ? arg->v[skip++] : ((void *)0);
      argsused++;
     }
    } else {
     if (!(getmodeflags((modelist), (*mc)) & (0x04|0x01)) && !(getmodeflags((modelist), (*mc)) & (0x08|0x01|0x02)))
      mode_unset1(modes, *mc);
     if ((getmodeflags((modelist), (*mc)) & 0x02)) {
      param = skip < arg->c ? arg->v[skip++] : ((void *)0);
      argsused++;
     }
    }
    ret = func(from, target, pls, *mc, param);
    if (ret == 0)
     break;
    if (param && (ret == -1 || ret == -2))
     skip--, argsused--;
    if (ret == -2)
     pls ? mode_unset1(modes, *mc) : mode_set1(modes, *mc);
    break;
  }
  mc++;
 }
 return argsused;
}

canonical_original_code:
int mode_apply(struct entity *from, struct entity *target, unsigned long *modes, char *modechanges, struct manyargs *arg, int skip, int (*func)(struct entity *from, struct entity *target, int pls, char modechange, char *param)) {
 char *modelist;
 char *mc = modechanges;
 char *param;
 int ret; int argsused = 0; int pls = 1;
 if ((((struct entity *)(target))->magic == 0x2ED4))
  modelist = chanmodelist;
 else if ((((struct entity *)(target))->magic == 0x49F1))
  modelist = usermodelist;
 else if ((((struct entity *)(target))->magic == 0xA839))
  modelist = servermodelist;
 else {
  logtxt(0x0010, "Mode change for unknown entity." "\n");
  return 0;
 }
 while (*mc) {
  param = ((void *)0);
  switch (*mc) {
   case '+':
    pls = 1;
    break;
   case '-':
    pls = 0;
    break;
   default:
    if (!(getmodeflags((modelist), (*mc)) & 0x80)) {
     logfmt(0x0100, "Invalid mode char: %c in sequence %s!" "\n", *mc, modechanges);
     break;
    }
    if (pls) {
     if (!(getmodeflags((modelist), (*mc)) & (0x04|0x01)) && !(getmodeflags((modelist), (*mc)) & (0x08|0x01|0x02)))
      mode_set1(modes, *mc);
     if ((getmodeflags((modelist), (*mc)) & 0x01)) {
      param = skip < arg->c ? arg->v[skip++] : ((void *)0);
      argsused++;
     }
    } else {
     if (!(getmodeflags((modelist), (*mc)) & (0x04|0x01)) && !(getmodeflags((modelist), (*mc)) & (0x08|0x01|0x02)))
      mode_unset1(modes, *mc);
     if ((getmodeflags((modelist), (*mc)) & 0x02)) {
      param = skip < arg->c ? arg->v[skip++] : ((void *)0);
      argsused++;
     }
    }
    ret = func(from, target, pls, *mc, param);
    if (ret == 0)
     break;
    if (param && (ret == -1 || ret == -2))
     skip--, argsused--;
    if (ret == -2)
     pls ? mode_unset1(modes, *mc) : mode_set1(modes, *mc);
    break;
  }
  mc++;
 }
 return argsused;
}

variable_types:
from
struct entity { unsigned int magic; } *

variable_types:
target
struct entity *

variable_types:
modechanges
char *

variable_types: struct manyargs { unsigned char c; char *v[256]; } *

variable_types: skip int

variable_types: int (*)(struct entity *from, struct entity *target, int pls, char modechange, char *param)

variable_types:
mc
char *

variable_types:
param
char *

variable_types: ret int

variable_types: argsused int

variable_types: pls int


decompiled_code:
unsigned __int64 __fastcall mode_flushmode(void *ptr)
{
_BYTE *v2; // rcx
char *v3; // r8
char *v4; // rdi
__int64 v5; // rcx
__int64 v6; // rsi
unsigned __int64 v8; // [rsp+8h] [rbp-10h]

v8 = __readfsqword(0x28u);
if ( ptr )
{
v2 = (_BYTE *)*((_QWORD *)ptr + 4);
v3 = (char *)ptr + 40;
if ( v2 != (char *)ptr + 40 )
{
v4 = (char *)ptr + 112;
v5 = v2 - v3;
v6 = *(_QWORD *)ptr + 24LL;
if ( **(_DWORD **)ptr == 18929 )
v6 = *(_QWORD *)ptr + 16LL;
send_format(
"%s M %s %.*s%.*s\r\n",
v6,
*((_QWORD *)ptr + 1) + 4LL,
v5,
v3,
*((_QWORD *)ptr + 13) - (_QWORD)v4,
v4);
}
jtableL_remove(&modebufs, *(_QWORD *)ptr);
free(ptr);
}
return v8 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func10(void *ptr)
{
_BYTE *v2; // rcx
char *v3; // r8
char *v4; // rdi
__int64 v5; // rcx
__int64 v6; // rsi
unsigned __int64 v8; // [rsp+8h] [rbp-10h]

v8 = __readfsqword(0x28u);
if ( ptr )
{
v2 = (_BYTE *)*((_QWORD *)ptr + 4);
v3 = (char *)ptr + 40;
if ( v2 != (char *)ptr + 40 )
{
v4 = (char *)ptr + 112;
v5 = v2 - v3;
v6 = *(_QWORD *)ptr + 24LL;
if ( **(_DWORD **)ptr == 18929 )
v6 = *(_QWORD *)ptr + 16LL;
send_format(
"%s M %s %.*s%.*s\r\n",
v6,
*((_QWORD *)ptr + 1) + 4LL,
v5,
v3,
*((_QWORD *)ptr + 13) - (_QWORD)v4,
v4);
}
jtableL_remove(&modebufs, *(_QWORD *)ptr);
free(ptr);
}
return v8 - __readfsqword(0x28u);
}

original_code:
void mode_flushmode(struct modebuf *m) {
 if (!m)
  return;
 if (m->modestrpos != m->modestr)
  send_format("%s M %s %.*s%.*s" "\r\n", (((struct entity *)(m->from))->magic == 0x49F1) ? ((struct user *)m->from)->numericstr : ((struct server *)m->from)->numericstr, m->chan->name, m->modestrpos - m->modestr, m->modestr, m->targetstrpos - m->targetstr, m->targetstr);
 jtableL_remove(&modebufs, (unsigned long)m->from);
 free(m);
}

variable_types: struct modebuf { struct entity { unsigned int magic; } *from; struct channel { unsigned int magic; char name[-1]; char key[-1]; char topic[-1]; long limit; long ts; int usercount; unsigned long mode; struct jtableP { void *t; } ops; struct jtableS { void *t; } bans; } *chan; int modecount; long timeout; char *modestrpos; char *targetstrpos; } *

user_defined_types: struct modebuf { struct entity *from; struct channel *chan; int modecount; long timeout; char *modestrpos; char *targetstrpos; }

user_defined_types: struct server { unsigned int magic; unsigned long numeric; unsigned long lastnumeric; char numericstr[-1]; char name[-1]; unsigned long maxusers; int hops; long boot; long link; char protocol[4]; char description[-1]; struct jtableP users; unsigned long mode; }

user_defined_types: struct channel { unsigned int magic; char name[-1]; char key[-1]; char topic[-1]; long limit; long ts; int usercount; unsigned long mode; struct jtableP ops; struct jtableS bans; }


decompiled_code:
unsigned __int64 __fastcall mode_flushmode_check(__int64 a1, _QWORD *a2)
{
__int64 v2; // rax
unsigned __int64 v4; // [rsp+8h] [rbp-10h]

v4 = __readfsqword(0x28u);
v2 = a2[3];
if ( v2 && v2 <= now )
mode_flushmode(a2);
return v4 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func11(__int64 a1, _QWORD *a2)
{
__int64 v2; // rax
unsigned __int64 v4; // [rsp+8h] [rbp-10h]

v4 = __readfsqword(0x28u);
v2 = a2[3];
if ( v2 && v2 <= now )
func10(a2);
return v4 - __readfsqword(0x28u);
}

original_code:
static void mode_flushmode_check(struct entity *from, struct modebuf *m, void *nothing) {
 if (!m->timeout)
  return;
 if (now >= m->timeout)
  mode_flushmode(m);
}

variable_types: struct modebuf { struct entity *from; struct channel { unsigned int magic; char name[-1]; char key[-1]; char topic[-1]; long limit; long ts; int usercount; unsigned long mode; struct jtableP { void *t; } ops; struct jtableS { void *t; } bans; } *chan; int modecount; long timeout; char *modestrpos; char *targetstrpos; } *

variable_types:
nothing
void *


decompiled_code:
unsigned __int64 __fastcall mode_flushmode_deletion(__int64 a1)
{
void *v1; // rax
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
v1 = (void *)jtableL_get(&modebufs, a1);
if ( v1 )
mode_flushmode(v1);
return v3 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func12(__int64 a1)
{
void *v1; // rax
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
v1 = (void *)jtableL_get(&modebufs, a1);
if ( v1 )
func10(v1);
return v3 - __readfsqword(0x28u);
}

original_code:
static void mode_flushmode_deletion(struct entity *from) {
 struct modebuf *m = jtableL_get(&modebufs, (unsigned long)from);
 if (m)
  mode_flushmode(m);
}


decompiled_code:
__int64 __fastcall command_load(__int64 a1, __int64 a2, __int64 a3)
{
const char *v4; // r12
char v6[264]; // [rsp+0h] [rbp-138h] BYREF
unsigned __int64 v7; // [rsp+108h] [rbp-30h]

v7 = __readfsqword(0x28u);
if ( (unsigned int)user_isoper() )
{
if ( *(_BYTE *)a3 == 1 )
{
module_notice(bot, a1 + 16, "You didn't specify enough parameters for LOAD.");
module_notice(bot, a1 + 16, "Usage: LOAD <script>");
module_notice(bot, a1 + 16, "Loads a lua script file into the engine.");
}
else
{
v4 = *(const char **)(a3 + 16);
if ( strpbrk(v4, "./") )
{
module_notice(bot, a1 + 16, "Invalid script name. Cannot contain '.' or '/'.");
}
else
{
snprintf(v6, 0x100uLL, "scripts/lua/%s.lua", v4);
if ( (unsigned int)luabase_loadscript(v6) )
{
module_notice(bot, a1 + 16, "There was a problem loading '%s'.", *(const char **)(a3 + 16));
module_notice(
bot,
a1 + 16,
"Please note that you do not need to include the '.lua' extension when loading a script.");
}
else
{
module_notice(bot, a1 + 16, "Done.");
}
}
}
}
else
{
module_notice(bot, a1 + 16, "Access denied.");
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
const char *v4; // r12
char v6[264]; // [rsp+0h] [rbp-138h] BYREF
unsigned __int64 v7; // [rsp+108h] [rbp-30h]

v7 = __readfsqword(0x28u);
if ( (unsigned int)user_isoper() )
{
if ( *(_BYTE *)a3 == 1 )
{
module_notice(bot, a1 + 16, "You didn't specify enough parameters for LOAD.");
module_notice(bot, a1 + 16, "Usage: LOAD <script>");
module_notice(bot, a1 + 16, "Loads a lua script file into the engine.");
}
else
{
v4 = *(const char **)(a3 + 16);
if ( strpbrk(v4, "./") )
{
module_notice(bot, a1 + 16, "Invalid script name. Cannot contain '.' or '/'.");
}
else
{
snprintf(v6, 0x100uLL, "scripts/lua/%s.lua", v4);
if ( (unsigned int)luabase_loadscript(v6) )
{
module_notice(bot, a1 + 16, "There was a problem loading '%s'.", *(const char **)(a3 + 16));
module_notice(
bot,
a1 + 16,
"Please note that you do not need to include the '.lua' extension when loading a script.");
}
else
{
module_notice(bot, a1 + 16, "Done.");
}
}
}
}
else
{
module_notice(bot, a1 + 16, "Access denied.");
}
return 0LL;
}

original_code:
int command_load (struct user *from, struct user *to, struct manyargs *args) {
 char script[255 +1];
 if (!user_isoper(from)) {
  module_notice(bot, from->numericstr, "Access denied.");
  return 0;
 }
 if (args->c == 1) {
  module_notice(bot, from->numericstr, "You didn't specify enough parameters for LOAD.");
  module_notice(bot, from->numericstr, "Usage: LOAD <script>");
  module_notice(bot, from->numericstr, "Loads a lua script file into the engine.");
  return 0;
 }
 if (strpbrk(args->v[1], "./")) {
  module_notice(bot, from->numericstr, "Invalid script name. Cannot contain '.' or '/'.");
  return 0;
 }
 snprintf(script, sizeof(script), "scripts/lua/%s.lua", args->v[1]);
 if (!luabase_loadscript(script)) {
  module_notice(bot, from->numericstr, "Done.");
 } else {
  module_notice(bot, from->numericstr, "There was a problem loading '%s'.", args->v[1]);
  module_notice(bot, from->numericstr, "Please note that you do not need to include the '.lua' extension when loading a script.");
 }
 return 0;
}

canonical_original_code:
int command_load(struct user *from, struct user *to, struct manyargs *args) {
 char script[-1];
 if (!user_isoper(from)) {
  module_notice(bot, from->numericstr, "Access denied.");
  return 0;
 }
 if (args->c == 1) {
  module_notice(bot, from->numericstr, "You didn't specify enough parameters for LOAD.");
  module_notice(bot, from->numericstr, "Usage: LOAD <script>");
  module_notice(bot, from->numericstr, "Loads a lua script file into the engine.");
  return 0;
 }
 if (strpbrk(args->v[1], "./")) {
  module_notice(bot, from->numericstr, "Invalid script name. Cannot contain '.' or '/'.");
  return 0;
 }
 snprintf(script, sizeof(script), "scripts/lua/%s.lua", args->v[1]);
 if (!luabase_loadscript(script)) {
  module_notice(bot, from->numericstr, "Done.");
 } else {
  module_notice(bot, from->numericstr, "There was a problem loading '%s'.", args->v[1]);
  module_notice(bot, from->numericstr, "Please note that you do not need to include the '.lua' extension when loading a script.");
 }
 return 0;
}

variable_types: struct user { unsigned int magic; unsigned long numeric; char numericstr[-1]; char nick[-1]; char user[-1]; char host[-1]; char fakehost[-1]; char opername[-1]; char account[-1]; long acctime; long accid; char realname[-1]; int hops; unsigned int accountid; char awaymsg[-1]; unsigned long mode; int channelcount; struct jtableP { void *t; } channels; struct server { unsigned int magic; unsigned long numeric; unsigned long lastnumeric; char numericstr[-1]; char name[-1]; unsigned long maxusers; int hops; long boot; long link; char protocol[4]; char description[-1]; struct jtableP users; unsigned long mode; } *server; } *

variable_types:
to
struct user *

variable_types:
script
char [-1]

user_defined_types: struct manyargs { unsigned char c; char *v[256]; }


decompiled_code:
__int64 __fastcall command_unload(__int64 a1, __int64 a2, __int64 a3)
{
const char *v4; // r12
char v6[264]; // [rsp+0h] [rbp-138h] BYREF
unsigned __int64 v7; // [rsp+108h] [rbp-30h]

v7 = __readfsqword(0x28u);
if ( (unsigned int)user_isoper() )
{
if ( *(_BYTE *)a3 == 1 )
{
module_notice(bot, a1 + 16, "You didn't specify enough parameters for UNLOAD.");
module_notice(bot, a1 + 16, "Usage: UNLOAD <script>");
module_notice(bot, a1 + 16, "Unloads a load script file.");
}
else
{
v4 = *(const char **)(a3 + 16);
if ( strpbrk(v4, "./") )
{
module_notice(bot, a1 + 16, "Invalid script name. Cannot contain '.' or '/'.");
}
else
{
snprintf(v6, 0x100uLL, "scripts/lua/%s.lua", v4);
if ( (unsigned int)luabase_valid_script(v6) )
{
if ( (unsigned int)luabase_unloadscript(v6) )
{
module_notice(bot, a1 + 16, "There was a problem unloading '%s'.", *(const char **)(a3 + 16));
module_notice(
bot,
a1 + 16,
"Please note that you do not need to include the '.lua' extension when unloading a script.");
}
else
{
module_notice(bot, a1 + 16, "Done.");
}
}
else
{
module_notice(bot, a1 + 16, "Unknown script %s.", *(const char **)(a3 + 16));
}
}
}
}
else
{
module_notice(bot, a1 + 16, "Access denied.");
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
const char *v4; // r12
char v6[264]; // [rsp+0h] [rbp-138h] BYREF
unsigned __int64 v7; // [rsp+108h] [rbp-30h]

v7 = __readfsqword(0x28u);
if ( (unsigned int)user_isoper() )
{
if ( *(_BYTE *)a3 == 1 )
{
module_notice(bot, a1 + 16, "You didn't specify enough parameters for UNLOAD.");
module_notice(bot, a1 + 16, "Usage: UNLOAD <script>");
module_notice(bot, a1 + 16, "Unloads a load script file.");
}
else
{
v4 = *(const char **)(a3 + 16);
if ( strpbrk(v4, "./") )
{
module_notice(bot, a1 + 16, "Invalid script name. Cannot contain '.' or '/'.");
}
else
{
snprintf(v6, 0x100uLL, "scripts/lua/%s.lua", v4);
if ( (unsigned int)luabase_valid_script(v6) )
{
if ( (unsigned int)luabase_unloadscript(v6) )
{
module_notice(bot, a1 + 16, "There was a problem unloading '%s'.", *(const char **)(a3 + 16));
module_notice(
bot,
a1 + 16,
"Please note that you do not need to include the '.lua' extension when unloading a script.");
}
else
{
module_notice(bot, a1 + 16, "Done.");
}
}
else
{
module_notice(bot, a1 + 16, "Unknown script %s.", *(const char **)(a3 + 16));
}
}
}
}
else
{
module_notice(bot, a1 + 16, "Access denied.");
}
return 0LL;
}

original_code:
int command_unload (struct user *from, struct user *to, struct manyargs *args) {
 char script[255 +1];
 if (!user_isoper(from)) {
  module_notice(bot, from->numericstr, "Access denied.");
  return 0;
 }
 if (args->c == 1) {
  module_notice(bot, from->numericstr, "You didn't specify enough parameters for UNLOAD.");
  module_notice(bot, from->numericstr, "Usage: UNLOAD <script>");
  module_notice(bot, from->numericstr, "Unloads a load script file.");
  return 0;
 }
 if (strpbrk(args->v[1], "./")) {
  module_notice(bot, from->numericstr, "Invalid script name. Cannot contain '.' or '/'.");
  return 0;
 }
 snprintf(script, sizeof(script), "scripts/lua/%s.lua", args->v[1]);
 if (!luabase_valid_script(script)) {
  module_notice(bot, from->numericstr, "Unknown script %s.", args->v[1]);
  return 0;
 } else {
  if (!luabase_unloadscript(script)) {
   module_notice(bot, from->numericstr, "Done.");
  } else {
   module_notice(bot, from->numericstr, "There was a problem unloading '%s'.", args->v[1]);
   module_notice(bot, from->numericstr, "Please note that you do not need to include the '.lua' extension when unloading a script.");
  }
 }
 return 0;
}

canonical_original_code:
int command_unload(struct user *from, struct user *to, struct manyargs *args) {
 char script[-1];
 if (!user_isoper(from)) {
  module_notice(bot, from->numericstr, "Access denied.");
  return 0;
 }
 if (args->c == 1) {
  module_notice(bot, from->numericstr, "You didn't specify enough parameters for UNLOAD.");
  module_notice(bot, from->numericstr, "Usage: UNLOAD <script>");
  module_notice(bot, from->numericstr, "Unloads a load script file.");
  return 0;
 }
 if (strpbrk(args->v[1], "./")) {
  module_notice(bot, from->numericstr, "Invalid script name. Cannot contain '.' or '/'.");
  return 0;
 }
 snprintf(script, sizeof(script), "scripts/lua/%s.lua", args->v[1]);
 if (!luabase_valid_script(script)) {
  module_notice(bot, from->numericstr, "Unknown script %s.", args->v[1]);
  return 0;
 } else {
  if (!luabase_unloadscript(script)) {
   module_notice(bot, from->numericstr, "Done.");
  } else {
   module_notice(bot, from->numericstr, "There was a problem unloading '%s'.", args->v[1]);
   module_notice(bot, from->numericstr, "Please note that you do not need to include the '.lua' extension when unloading a script.");
  }
 }
 return 0;
}


decompiled_code:
__int64 __fastcall jtableS_remove(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v4; // [rsp+28h] [rbp-10h]

v4 = __readfsqword(0x28u);
result = JudySLDel(a1, a2, v3);
if ( (_DWORD)result == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
67LL,
"JudySLDel",
(unsigned int)v3[0],
(unsigned int)v3[1]);
exit(1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v4; // [rsp+28h] [rbp-10h]

v4 = __readfsqword(0x28u);
result = JudySLDel(a1, a2, v3);
if ( (_DWORD)result == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
67LL,
"JudySLDel",
(unsigned int)v3[0],
(unsigned int)v3[1]);
exit(1);
}
return result;
}

original_code:
int jtableS_remove(jtableS *table, const char *key) {
 int ret;
 { JError_t J_Error; if (((ret) = JudySLDel((&(table->t)), (const uint8_t*)key, &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 67, "JudySLDel", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 return ret;
}

canonical_original_code:
int jtableS_remove(struct jtableS *table, char *key) {
 int ret;
 { struct J_UDY_ERROR_STRUCT J_Error; if (((ret) = JudySLDel((&(table->t)), (unsigned char *)key, &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 67, "JudySLDel", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 return ret;
}

variable_types:
table
struct jtableS { void *t; } *

variable_types:
key
char *

variable_types: struct J_UDY_ERROR_STRUCT { enum JU_Errno_t { JU_ERRNO_NONE=0, JU_ERRNO_FULL=1, JU_ERRNO_NFMAX=expr, JU_ERRNO_NOMEM=2, JU_ERRNO_NULLPPARRAY=3, JU_ERRNO_NONNULLPARRAY=10, JU_ERRNO_NULLPINDEX=4, JU_ERRNO_NULLPVALUE=11, JU_ERRNO_NOTJUDY1=5, JU_ERRNO_NOTJUDYL=6, JU_ERRNO_NOTJUDYSL=7, JU_ERRNO_UNSORTED=12, JU_ERRNO_OVERRUN=8, JU_ERRNO_CORRUPT=9 } je_Errno; int je_ErrID; unsigned long je_reserved[4]; }

user_defined_types: struct J_UDY_ERROR_STRUCT { enum JU_Errno_t je_Errno; int je_ErrID; unsigned long je_reserved[4]; }


decompiled_code:
__int64 __fastcall jtableS_free(__int64 a1)
{
__int64 result; // rax
int v2[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v3; // [rsp+28h] [rbp-10h]

v3 = __readfsqword(0x28u);
result = JudySLFreeArray(a1, v2);
if ( (_DWORD)result == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
74LL,
"JudySLFreeArray",
(unsigned int)v2[0],
(unsigned int)v2[1]);
exit(1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 result; // rax
int v2[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v3; // [rsp+28h] [rbp-10h]

v3 = __readfsqword(0x28u);
result = JudySLFreeArray(a1, v2);
if ( (_DWORD)result == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
74LL,
"JudySLFreeArray",
(unsigned int)v2[0],
(unsigned int)v2[1]);
exit(1);
}
return result;
}

original_code:
int jtableS_free(jtableS *table) {
 int ret;
 { JError_t J_Error; if (((ret) = JudySLFreeArray((&(table->t)), &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 74, "JudySLFreeArray", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 return ret;
}

canonical_original_code:
int jtableS_free(struct jtableS *table) {
 int ret;
 { struct J_UDY_ERROR_STRUCT J_Error; if (((ret) = JudySLFreeArray((&(table->t)), &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 74, "JudySLFreeArray", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 return ret;
}

user_defined_types: enum JU_Errno_t { JU_ERRNO_NONE=0, JU_ERRNO_FULL=1, JU_ERRNO_NFMAX=expr, JU_ERRNO_NOMEM=2, JU_ERRNO_NULLPPARRAY=3, JU_ERRNO_NONNULLPARRAY=10, JU_ERRNO_NULLPINDEX=4, JU_ERRNO_NULLPVALUE=11, JU_ERRNO_NOTJUDY1=5, JU_ERRNO_NOTJUDYL=6, JU_ERRNO_NOTJUDYSL=7, JU_ERRNO_UNSORTED=12, JU_ERRNO_OVERRUN=8, JU_ERRNO_CORRUPT=9 }


decompiled_code:
__int64 __fastcall jtableL_remove(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v4; // [rsp+28h] [rbp-10h]

v4 = __readfsqword(0x28u);
result = JudyLDel(a1, a2, v3);
if ( (_DWORD)result == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
108LL,
"JudyLDel",
(unsigned int)v3[0],
(unsigned int)v3[1]);
exit(1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v4; // [rsp+28h] [rbp-10h]

v4 = __readfsqword(0x28u);
result = JudyLDel(a1, a2, v3);
if ( (_DWORD)result == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
108LL,
"JudyLDel",
(unsigned int)v3[0],
(unsigned int)v3[1]);
exit(1);
}
return result;
}

original_code:
int jtableL_remove(jtableL *table, unsigned long key) {
 int ret;
 { JError_t J_Error; if (((ret) = JudyLDel((&(table->t)), key, &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 108, "JudyLDel", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 return ret;
}

canonical_original_code:
int jtableL_remove(struct jtableL *table, unsigned long key) {
 int ret;
 { struct J_UDY_ERROR_STRUCT J_Error; if (((ret) = JudyLDel((&(table->t)), key, &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 108, "JudyLDel", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 return ret;
}

variable_types:
table
struct jtableL { void *t; } *

variable_types:
key
unsigned long


decompiled_code:
__int64 __fastcall jtableL_free(__int64 a1)
{
__int64 result; // rax
int v2[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v3; // [rsp+28h] [rbp-10h]

v3 = __readfsqword(0x28u);
result = JudyLFreeArray(a1, v2);
if ( (_DWORD)result == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
115LL,
"JudyLFreeArray",
(unsigned int)v2[0],
(unsigned int)v2[1]);
exit(1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 result; // rax
int v2[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v3; // [rsp+28h] [rbp-10h]

v3 = __readfsqword(0x28u);
result = JudyLFreeArray(a1, v2);
if ( (_DWORD)result == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
115LL,
"JudyLFreeArray",
(unsigned int)v2[0],
(unsigned int)v2[1]);
exit(1);
}
return result;
}

original_code:
int jtableL_free(jtableL *table) {
 int ret;
 { JError_t J_Error; if (((ret) = JudyLFreeArray((&(table->t)), &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 115, "JudyLFreeArray", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 return ret;
}

canonical_original_code:
int jtableL_free(struct jtableL *table) {
 int ret;
 { struct J_UDY_ERROR_STRUCT J_Error; if (((ret) = JudyLFreeArray((&(table->t)), &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 115, "JudyLFreeArray", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 return ret;
}


decompiled_code:
__int64 __fastcall jtableP_set(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
int v5[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v6; // [rsp+28h] [rbp-10h]

v6 = __readfsqword(0x28u);
v2 = Judy1Set(a1, a2, v5);
if ( v2 == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
134LL,
"Judy1Set",
(unsigned int)v5[0],
(unsigned int)v5[1]);
exit(1);
}
v3 = v2;
if ( !v2 )
logtxt(0x4000LL, "Duplicate insert into jtableP\n");
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
int v5[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v6; // [rsp+28h] [rbp-10h]

v6 = __readfsqword(0x28u);
v2 = Judy1Set(a1, a2, v5);
if ( v2 == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
134LL,
"Judy1Set",
(unsigned int)v5[0],
(unsigned int)v5[1]);
exit(1);
}
v3 = v2;
if ( !v2 )
logtxt(0x4000LL, "Duplicate insert into jtableP\n");
return v3;
}

original_code:
int jtableP_set(jtableP *table, void *key) {
 int ret;
 { JError_t J_Error; if (((ret) = Judy1Set((&(table->t)), (Word_t)key, &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 134, "Judy1Set", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 if (!ret)
  logtxt(0x4000, "Duplicate insert into jtableP" "\n");
 return ret;
}

canonical_original_code:
int jtableP_set(struct jtableP *table, void *key) {
 int ret;
 { struct J_UDY_ERROR_STRUCT J_Error; if (((ret) = Judy1Set((&(table->t)), (unsigned long)key, &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 134, "Judy1Set", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 if (!ret)
  logtxt(0x4000, "Duplicate insert into jtableP" "\n");
 return ret;
}

variable_types:
table
struct jtableP { void *t; } *

variable_types:
key
void *


decompiled_code:
__int64 __fastcall jtableP_check(_QWORD *a1, __int64 a2)
{
return Judy1Test(*a1, a2, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD *a1, __int64 a2)
{
return Judy1Test(*a1, a2, 0LL);
}

original_code:
int jtableP_check(jtableP *table, void *key) {
 int ret;
 (ret) = Judy1Test((Pvoid_t)(table->t), (Word_t)key, ((PJError_t) ((void *)0)));
 return ret;
}

canonical_original_code:
int jtableP_check(struct jtableP *table, void *key) {
 int ret;
 (ret) = Judy1Test((Pvoid_t)(table->t), (unsigned long)key, ((PJError_t) ((void *)0)));
 return ret;
}


decompiled_code:
__int64 __fastcall jtableP_unset(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
int v5[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v6; // [rsp+28h] [rbp-10h]

v6 = __readfsqword(0x28u);
v2 = Judy1Unset(a1, a2, v5);
if ( v2 == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
150LL,
"Judy1Unset",
(unsigned int)v5[0],
(unsigned int)v5[1]);
exit(1);
}
v3 = v2;
if ( !v2 )
logtxt(0x4000LL, "Deletion of non-existant element in jtableP\n");
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
int v5[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v6; // [rsp+28h] [rbp-10h]

v6 = __readfsqword(0x28u);
v2 = Judy1Unset(a1, a2, v5);
if ( v2 == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
150LL,
"Judy1Unset",
(unsigned int)v5[0],
(unsigned int)v5[1]);
exit(1);
}
v3 = v2;
if ( !v2 )
logtxt(0x4000LL, "Deletion of non-existant element in jtableP\n");
return v3;
}

original_code:
int jtableP_unset(jtableP *table, void *key) {
 int ret;
 { JError_t J_Error; if (((ret) = Judy1Unset((&(table->t)), (Word_t)key, &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 150, "Judy1Unset", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 if (!ret)
  logtxt(0x4000, "Deletion of non-existant element in jtableP" "\n");
 return ret;
}

canonical_original_code:
int jtableP_unset(struct jtableP *table, void *key) {
 int ret;
 { struct J_UDY_ERROR_STRUCT J_Error; if (((ret) = Judy1Unset((&(table->t)), (unsigned long)key, &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 150, "Judy1Unset", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 if (!ret)
  logtxt(0x4000, "Deletion of non-existant element in jtableP" "\n");
 return ret;
}


decompiled_code:
__int64 __fastcall jtableP_free(__int64 a1)
{
__int64 result; // rax
int v2[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v3; // [rsp+28h] [rbp-10h]

v3 = __readfsqword(0x28u);
result = Judy1FreeArray(a1, v2);
if ( (_DWORD)result == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
159LL,
"Judy1FreeArray",
(unsigned int)v2[0],
(unsigned int)v2[1]);
exit(1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
__int64 result; // rax
int v2[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v3; // [rsp+28h] [rbp-10h]

v3 = __readfsqword(0x28u);
result = Judy1FreeArray(a1, v2);
if ( (_DWORD)result == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
159LL,
"Judy1FreeArray",
(unsigned int)v2[0],
(unsigned int)v2[1]);
exit(1);
}
return result;
}

original_code:
int jtableP_free(jtableP *table) {
 int ret;
 { JError_t J_Error; if (((ret) = Judy1FreeArray((&(table->t)), &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 159, "Judy1FreeArray", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 return ret;
}

canonical_original_code:
int jtableP_free(struct jtableP *table) {
 int ret;
 { struct J_UDY_ERROR_STRUCT J_Error; if (((ret) = Judy1FreeArray((&(table->t)), &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 159, "Judy1FreeArray", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 return ret;
}


decompiled_code:
__int64 __fastcall jtableP_count(_QWORD *a1)
{
__int64 result; // rax
int v2[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v3; // [rsp+28h] [rbp-10h]

v3 = __readfsqword(0x28u);
result = Judy1Count(*a1, 0LL, -1LL, v2);
if ( !(_DWORD)result && v2[0] > 1u )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
166LL,
"Judy1Count",
(unsigned int)v2[0],
(unsigned int)v2[1]);
exit(1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(_QWORD *a1)
{
__int64 result; // rax
int v2[10]; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v3; // [rsp+28h] [rbp-10h]

v3 = __readfsqword(0x28u);
result = Judy1Count(*a1, 0LL, -1LL, v2);
if ( !(_DWORD)result && v2[0] > 1u )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
166LL,
"Judy1Count",
(unsigned int)v2[0],
(unsigned int)v2[1]);
exit(1);
}
return result;
}

original_code:
int jtableP_count(jtableP *table) {
 int ret;
 { JError_t J_Error; if ((((ret) = Judy1Count(table->t, 0, -1, &J_Error)) == 0) && (((&J_Error)->je_Errno) > JU_ERRNO_NFMAX)) { { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 166, "Judy1Count", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; } };
 return ret;
}

canonical_original_code:
int jtableP_count(struct jtableP *table) {
 int ret;
 { struct J_UDY_ERROR_STRUCT J_Error; if ((((ret) = Judy1Count(table->t, 0, -1, &J_Error)) == 0) && (((&J_Error)->je_Errno) > JU_ERRNO_NFMAX)) { { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 166, "Judy1Count", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; } };
 return ret;
}


decompiled_code:
unsigned __int64 __fastcall jtableP_iterate(_QWORD *a1, void (__fastcall *a2)(__int64, __int64), __int64 a3)
{
int v4; // eax
int v5; // eax
__int64 v7; // [rsp+8h] [rbp-60h] BYREF
unsigned int v8; // [rsp+10h] [rbp-58h] BYREF
unsigned int v9; // [rsp+14h] [rbp-54h]
unsigned __int64 v10; // [rsp+38h] [rbp-30h]

v10 = __readfsqword(0x28u);
v7 = 0LL;
v4 = Judy1First(*a1, &v7, &v8);
if ( v4 == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
174LL,
"Judy1First",
v8,
v9);
exit(1);
}
if ( v4 )
{
do
{
a2(v7, a3);
v5 = Judy1Next(*a1, &v7, &v8);
if ( v5 == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
177LL,
"Judy1Next",
v8,
v9);
exit(1);
}
}
while ( v5 );
}
return v10 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func14(_QWORD *a1, void (__fastcall *a2)(__int64, __int64), __int64 a3)
{
int v4; // eax
int v5; // eax
__int64 v7; // [rsp+8h] [rbp-60h] BYREF
unsigned int v8; // [rsp+10h] [rbp-58h] BYREF
unsigned int v9; // [rsp+14h] [rbp-54h]
unsigned __int64 v10; // [rsp+38h] [rbp-30h]

v10 = __readfsqword(0x28u);
v7 = 0LL;
v4 = Judy1First(*a1, &v7, &v8);
if ( v4 == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
174LL,
"Judy1First",
v8,
v9);
exit(1);
}
if ( v4 )
{
do
{
a2(v7, a3);
v5 = Judy1Next(*a1, &v7, &v8);
if ( v5 == -1 )
{
fprintf(
stderr,
"File '%s', line %d: %s(), JU_ERRNO_* == %d, ID == %d\n",
"src/jtable.c",
177LL,
"Judy1Next",
v8,
v9);
exit(1);
}
}
while ( v5 );
}
return v10 - __readfsqword(0x28u);
}

original_code:
void jtableP_iterate(jtableP *table, jtableP_cb f, void *param) {
 int ret;
 Word_t key = 0;
 { JError_t J_Error; if (((ret) = Judy1First(table->t, &(key), &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 174, "Judy1First", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 while (ret) {
  f((void *)key, param);
  { JError_t J_Error; if (((ret) = Judy1Next(table->t, &(key), &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 177, "Judy1Next", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 }
}

canonical_original_code:
void jtableP_iterate(struct jtableP *table, void (*f)(void *key, void *param), void *param) {
 int ret;
 unsigned long key = 0;
 { struct J_UDY_ERROR_STRUCT J_Error; if (((ret) = Judy1First(table->t, &(key), &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 174, "Judy1First", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 while (ret) {
  f((void *)key, param);
  { struct J_UDY_ERROR_STRUCT J_Error; if (((ret) = Judy1Next(table->t, &(key), &J_Error)) == (-1)) { (void) fprintf(stderr, "File '%s', line %d: %s(), " "JU_ERRNO_* == %d, ID == %d\n", "src/jtable.c", 177, "Judy1Next", ((&J_Error)->je_Errno), ((&J_Error)->je_ErrID)); exit(1); }; };
 }
}

variable_types:
f
void (*)(void *key, void *param)

variable_types:
param
void *


sfree

decompiled_code:
unsigned __int64 __fastcall sfree(void *a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
free(a1);
return v2 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(void *a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
free(a1);
return v2 - __readfsqword(0x28u);
}

original_code:
void sfree(void *p) {
 free(p);
}

canonical_original_code:
void sfree(void *p) {
 free(p);
}

variable_types:
p
void *


smalloc

decompiled_code:
void *__fastcall smalloc(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
logfmt(1LL, "Out of memory. Could not allocate %zd bytes.\n", a1);
exit(1);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
logfmt(1LL, "Out of memory. Could not allocate %zd bytes.\n", a1);
exit(1);
}
return result;
}

original_code:
void *smalloc(size_t s) {
 void *p = malloc(s);
 if (!p) {
  logfmt(0x0001, "Out of memory. Could not allocate %zd bytes." "\n", s);
  exit(1);
 }
 return p;
}

canonical_original_code:
void *smalloc(unsigned long s) {
 void *p = malloc(s);
 if (!p) {
  logfmt(0x0001, "Out of memory. Could not allocate %zd bytes." "\n", s);
  exit(1);
 }
 return p;
}

variable_types:
s
unsigned long

return_type: void *


sstrdup

decompiled_code:
char *__fastcall sstrdup(char *src)
{
size_t v1; // rax
char *v2; // rbp

v1 = strlen(src);
v2 = (char *)smalloc(v1 + 1);
strcpy(v2, src);
return v2;
}

canonical_decompiled_code:
char *__fastcall func2(char *src)
{
size_t v1; // rax
char *v2; // rbp

v1 = strlen(src);
v2 = (char *)func1(v1 + 1);
strcpy(v2, src);
return v2;
}

original_code:
char *sstrdup(const char *str) {
 char *new;
 size_t s = strlen(str);
 new = smalloc(s+1);
 strcpy(new, str);
 return new;
}

canonical_original_code:
char *sstrdup(char *str) {
 char *new;
 unsigned long s = strlen(str);
 new = smalloc(s+1);
 strcpy(new, str);
 return new;
}

variable_types:
str
char *

variable_types:
new
char *

return_type: char *


zmalloc

decompiled_code:
void *__fastcall zmalloc(size_t n)
{
void *v1; // rax
void *v2; // rbx

v1 = smalloc(n);
v2 = v1;
if ( v1 )
memset(v1, 0, n);
return v2;
}

canonical_decompiled_code:
void *__fastcall func3(size_t n)
{
void *v1; // rax
void *v2; // rbx

v1 = func1(n);
v2 = v1;
if ( v1 )
memset(v1, 0, n);
return v2;
}

original_code:
void *zmalloc(size_t s) {
 void *p = smalloc(s);
 if (p)
  memset(p, 0, s);
 return p;
}

canonical_original_code:
void *zmalloc(unsigned long s) {
 void *p = smalloc(s);
 if (p)
  memset(p, 0, s);
 return p;
}


decompiled_code:
unsigned __int64 __fastcall debug_print_chanuser(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
logfmt(
0x4000LL,
" '%s!%s@%s' (%s)\n",
(const char *)(a1 + 22),
(const char *)(a1 + 38),
(const char *)(a1 + 49),
*(const char **)(a1 + 8));
return v2 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
logfmt(
0x4000LL,
" '%s!%s@%s' (%s)\n",
(const char *)(a1 + 22),
(const char *)(a1 + 38),
(const char *)(a1 + 49),
*(const char **)(a1 + 8));
return v2 - __readfsqword(0x28u);
}

original_code:
static void debug_print_chanuser(struct user *u, void *null) {
 logfmt(0x4000, "    '%s!%s@%s' (%s)" "\n", u->nick, u->user, u->host, u->numeric);
}


decompiled_code:
unsigned __int64 __fastcall debug_print_ban(const char *a1, __int64 a2)
{
const char *v2; // r8
unsigned __int64 v4; // [rsp+8h] [rbp-10h]

v4 = __readfsqword(0x28u);
v2 = "/unknown/";
if ( *(_BYTE *)(a2 + 91) )
v2 = (const char *)(a2 + 91);
logfmt(0x4000LL, " '%s' == '%s' (from %s @ %ld)\n", a1, (const char *)a2, v2, *(_QWORD *)(a2 + 200));
return v4 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(const char *a1, __int64 a2)
{
const char *v2; // r8
unsigned __int64 v4; // [rsp+8h] [rbp-10h]

v4 = __readfsqword(0x28u);
v2 = "/unknown/";
if ( *(_BYTE *)(a2 + 91) )
v2 = (const char *)(a2 + 91);
logfmt(0x4000LL, " '%s' == '%s' (from %s @ %ld)\n", a1, (const char *)a2, v2, *(_QWORD *)(a2 + 200));
return v4 - __readfsqword(0x28u);
}

original_code:
static void debug_print_ban(const char *mask, struct mask *b, void *null) {
 logfmt(0x4000, "    '%s' == '%s' (from %s @ %ld)" "\n", mask, b->mask, b->from.nick[0] ? b->from.nick : "/unknown/", b->ts);
}

canonical_original_code:
static void debug_print_ban(char *mask, struct mask *b, void *null) {
 logfmt(0x4000, "    '%s' == '%s' (from %s @ %ld)" "\n", mask, b->mask, b->from.nick[0] ? b->from.nick : "/unknown/", b->ts);
}

variable_types:
mask
char *

variable_types: struct mask { char mask[-1]; struct maskfrom { char nick[-1]; char user[-1]; char host[-1]; char account[-1]; } from; long ts; } *

user_defined_types: struct mask { char mask[-1]; struct maskfrom from; long ts; }


decompiled_code:
unsigned __int64 __fastcall debug_print_channel(const char *a1, __int64 a2)
{
unsigned int i; // ebx
_BYTE *v4; // rax
unsigned int j; // ebx
_BYTE *v6; // rax
_BYTE *v7; // rax
unsigned __int64 v8; // [rsp+8h] [rbp-20h]

v8 = __readfsqword(0x28u);
if ( *(_DWORD *)a2 == 11988 )
{
logfmt(0x4000LL, "Channel info for '%s' == '%s'\n", a1, (const char *)(a2 + 4));
logfmt(
0x4000LL,
" Key: '%s'. Limit: %ld. Creation: %ld\n",
(const char *)(a2 + 205),
*(_QWORD *)(a2 + 480),
*(_QWORD *)(a2 + 488));
t_1 = (__int64)modebuf_0;
for ( i = 97; i != 123; ++i )
{
if ( (unsigned int)mode_check1(a2 + 504, i) )
{
v4 = (_BYTE *)t_1++;
*v4 = i;
}
}
for ( j = 65; j != 91; ++j )
{
if ( (unsigned int)mode_check1(a2 + 504, j) )
{
v6 = (_BYTE *)t_1++;
*v6 = j;
}
}
v7 = (_BYTE *)t_1++;
*v7 = 0;
logfmt(0x4000LL, " Mode: +%s\n", modebuf_0);
logtxt(0x4000LL, " Bans:\n");
jtableS_iterate(a2 + 536, debug_print_ban, 0LL);
logtxt(0x4000LL, " Users:\n");
jtableP_iterate(a2 + 528, debug_print_chanuser, 0LL);
logtxt(0x4000LL, " Ops:\n");
jtableP_iterate(a2 + 512, debug_print_chanuser, 0LL);
logtxt(0x4000LL, " Voices:\n");
jtableP_iterate(a2 + 520, debug_print_chanuser, 0LL);
}
else
{
logtxt(0x4000LL, "INVALID CHANNEL\n");
}
return v8 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func2(const char *a1, __int64 a2)
{
unsigned int i; // ebx
_BYTE *v4; // rax
unsigned int j; // ebx
_BYTE *v6; // rax
_BYTE *v7; // rax
unsigned __int64 v8; // [rsp+8h] [rbp-20h]

v8 = __readfsqword(0x28u);
if ( *(_DWORD *)a2 == 11988 )
{
logfmt(0x4000LL, "Channel info for '%s' == '%s'\n", a1, (const char *)(a2 + 4));
logfmt(
0x4000LL,
" Key: '%s'. Limit: %ld. Creation: %ld\n",
(const char *)(a2 + 205),
*(_QWORD *)(a2 + 480),
*(_QWORD *)(a2 + 488));
t_1 = (__int64)modebuf_0;
for ( i = 97; i != 123; ++i )
{
if ( (unsigned int)mode_check1(a2 + 504, i) )
{
v4 = (_BYTE *)t_1++;
*v4 = i;
}
}
for ( j = 65; j != 91; ++j )
{
if ( (unsigned int)mode_check1(a2 + 504, j) )
{
v6 = (_BYTE *)t_1++;
*v6 = j;
}
}
v7 = (_BYTE *)t_1++;
*v7 = 0;
logfmt(0x4000LL, " Mode: +%s\n", modebuf_0);
logtxt(0x4000LL, " Bans:\n");
jtableS_iterate(a2 + 536, debug_print_ban, 0LL);
logtxt(0x4000LL, " Users:\n");
jtableP_iterate(a2 + 528, debug_print_chanuser, 0LL);
logtxt(0x4000LL, " Ops:\n");
jtableP_iterate(a2 + 512, debug_print_chanuser, 0LL);
logtxt(0x4000LL, " Voices:\n");
jtableP_iterate(a2 + 520, debug_print_chanuser, 0LL);
}
else
{
logtxt(0x4000LL, "INVALID CHANNEL\n");
}
return v8 - __readfsqword(0x28u);
}

original_code:
static void debug_print_channel(const char *name, struct channel *c) {
 static char modebuf[64], *t;
 char i;
 if (!(((struct entity *)(c))->magic == 0x2ED4)) {
  logtxt(0x4000, "INVALID CHANNEL" "\n");
  return;
 }
 logfmt(0x4000, "Channel info for '%s' == '%s'" "\n", name, c->name);
 logfmt(0x4000, "  Key: '%s'. Limit: %ld. Creation: %ld" "\n", c->key, c->limit, c->ts);
 t = modebuf;
 for (i = 'a'; i <= 'z'; i++)
  if (mode_check1(&c->mode, i))
   *t++ = i;
 for (i = 'A'; i <= 'Z'; i++)
  if (mode_check1(&c->mode, i))
   *t++ = i;
 *t++ = '\0';
 logfmt(0x4000, "  Mode: +%s" "\n", modebuf);
 logtxt(0x4000, "  Bans:" "\n");
 jtableS_iterate(&c->bans, (jtableS_cb)debug_print_ban, ((void *)0));
 logtxt(0x4000, "  Users:" "\n");
 jtableP_iterate(&c->users, (jtableP_cb)debug_print_chanuser, ((void *)0));
 logtxt(0x4000, "  Ops:" "\n");
 jtableP_iterate(&c->ops, (jtableP_cb)debug_print_chanuser, ((void *)0));
 logtxt(0x4000, "  Voices:" "\n");
 jtableP_iterate(&c->voices, (jtableP_cb)debug_print_chanuser, ((void *)0));
}

canonical_original_code:
static void debug_print_channel(char *name, struct channel *c) {
 static char modebuf[64]; static char *t;
 char i;
 if (!(((struct entity *)(c))->magic == 0x2ED4)) {
  logtxt(0x4000, "INVALID CHANNEL" "\n");
  return;
 }
 logfmt(0x4000, "Channel info for '%s' == '%s'" "\n", name, c->name);
 logfmt(0x4000, "  Key: '%s'. Limit: %ld. Creation: %ld" "\n", c->key, c->limit, c->ts);
 t = modebuf;
 for (i = 'a'; i <= 'z'; i++)
  if (mode_check1(&c->mode, i))
   *t++ = i;
 for (i = 'A'; i <= 'Z'; i++)
  if (mode_check1(&c->mode, i))
   *t++ = i;
 *t++ = '\0';
 logfmt(0x4000, "  Mode: +%s" "\n", modebuf);
 logtxt(0x4000, "  Bans:" "\n");
 jtableS_iterate(&c->bans, (void (*)(char *key, void *data, void *param))debug_print_ban, ((void *)0));
 logtxt(0x4000, "  Users:" "\n");
 jtableP_iterate(&c->users, (void (*)(void *key, void *param))debug_print_chanuser, ((void *)0));
 logtxt(0x4000, "  Ops:" "\n");
 jtableP_iterate(&c->ops, (void (*)(void *key, void *param))debug_print_chanuser, ((void *)0));
 logtxt(0x4000, "  Voices:" "\n");
 jtableP_iterate(&c->voices, (void (*)(void *key, void *param))debug_print_chanuser, ((void *)0));
}

variable_types:
name
char *

variable_types: struct channel { unsigned int magic; char name[-1]; char key[-1]; char topic[-1]; long limit; long ts; int usercount; unsigned long mode; struct jtableP { void *t; } ops; struct jtableS { void *t; } bans; } *

variable_types:
modebuf
char [64]

variable_types:
t
char *

variable_types: i char


decompiled_code:
__int64 __fastcall add_channel(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rax

v2 = zmalloc(544LL);
*(_DWORD *)v2 = 11988;
strncpyz(v2 + 4, a1, 201LL);
*(_QWORD *)(v2 + 488) = a2;
v3 = strconv(&rfc_tolower, 0LL, 0LL, a1);
return jtableS_insert(&channels, v3, v2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rax

v2 = zmalloc(544LL);
*(_DWORD *)v2 = 11988;
strncpyz(v2 + 4, a1, 201LL);
*(_QWORD *)(v2 + 488) = a2;
v3 = strconv(&rfc_tolower, 0LL, 0LL, a1);
return jtableS_insert(&channels, v3, v2);
}

original_code:
struct channel *add_channel(char *name, time_t ts) {
 struct channel *c;
 c = zmalloc(sizeof(*c));
 c->magic = 0x2ED4;
 strncpyz((c->name), (name), sizeof(c->name));
 c->ts = ts;
 return jtableS_insert(&channels, strconv(rfc_tolower, ((void *)0), 0, name), c);
}

canonical_original_code:
struct channel *add_channel(char *name, long ts) {
 struct channel *c;
 c = zmalloc(sizeof(*c));
 c->magic = 0x2ED4;
 strncpyz((c->name), (name), sizeof(c->name));
 c->ts = ts;
 return jtableS_insert(&channels, strconv(rfc_tolower, ((void *)0), 0, name), c);
}

variable_types: ts long

return_type: struct channel { unsigned int magic; char name[-1]; char key[-1]; char topic[-1]; long limit; long ts; int usercount; unsigned long mode; struct jtableP { void *t; } ops; struct jtableS { void *t; } bans; } *


decompiled_code:
unsigned __int64 __fastcall del_channel(void *ptr)
{
__int64 v1; // rax
__int64 v2; // rdx
_BYTE v4[328]; // [rsp-150h] [rbp-2B8h] BYREF
_BYTE v5[328]; // [rsp+0h] [rbp-168h] BYREF
unsigned __int64 v6; // [rsp+148h] [rbp-20h]

v6 = __readfsqword(0x28u);
v1 = arg_ptr();
pack_args(v5, v1, v2, 0LL, 0LL);
qmemcpy(v4, v5, sizeof(v4));
hook_call("onchanneldel");
chanusers_del_channel(ptr);
jtableP_free((char *)ptr + 528);
jtableP_free((char *)ptr + 512);
jtableP_free((char *)ptr + 520);
jtableS_remove(&channels, (char *)ptr + 4);
free(ptr);
return v6 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(void *ptr)
{
__int64 v1; // rax
__int64 v2; // rdx
_BYTE v4[328]; // [rsp-150h] [rbp-2B8h] BYREF
_BYTE v5[328]; // [rsp+0h] [rbp-168h] BYREF
unsigned __int64 v6; // [rsp+148h] [rbp-20h]

v6 = __readfsqword(0x28u);
v1 = arg_ptr();
pack_args(v5, v1, v2, 0LL, 0LL);
qmemcpy(v4, v5, sizeof(v4));
hook_call("onchanneldel");
chanusers_del_channel(ptr);
jtableP_free((char *)ptr + 528);
jtableP_free((char *)ptr + 512);
jtableP_free((char *)ptr + 520);
jtableS_remove(&channels, (char *)ptr + 4);
free(ptr);
return v6 - __readfsqword(0x28u);
}

original_code:
void del_channel(struct channel *c) {
 hook_call("onchanneldel", pack_args(arg_ptr(c), (struct funcarg) {.type = ARGTYPE_NONE}));
 chanusers_del_channel(c);
 jtableP_free(&c->users);
 jtableP_free(&c->ops);
 jtableP_free(&c->voices);
 jtableS_remove(&channels, c->name);
 free(c);
}

user_defined_types: struct funcarg { enum argtype type; union argdata data; }

user_defined_types: enum argtype { ARGTYPE_NONE=0, ARGTYPE_INT=1, ARGTYPE_UINT=2, ARGTYPE_LONG=3, ARGTYPE_ULONG=4, ARGTYPE_TIME=5, ARGTYPE_USER=6, ARGTYPE_CHAN=7, ARGTYPE_SERVER=8, ARGTYPE_STR=9, ARGTYPE_PTR=10 }

user_defined_types: union argdata { int i; unsigned int u; long l; unsigned long ul; long t; void *p; }


decompiled_code:
__int64 __fastcall get_channel_by_name(__int64 a1)
{
__int64 v1; // rax

v1 = strconv(&rfc_tolower, 0LL, 0LL, a1);
return jtableS_get(&channels, v1);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 v1; // rax

v1 = strconv(&rfc_tolower, 0LL, 0LL, a1);
return jtableS_get(&channels, v1);
}

original_code:
struct channel *get_channel_by_name(const char *name) {
 return jtableS_get(&channels, strconv(rfc_tolower, ((void *)0), 0, name));
}

canonical_original_code:
struct channel *get_channel_by_name(char *name) {
 return jtableS_get(&channels, strconv(rfc_tolower, ((void *)0), 0, name));
}


decompiled_code:
unsigned __int64 __fastcall channel_plsprefix(__int64 a1, __int64 a2, char a3)
{
unsigned __int64 v5; // [rsp+8h] [rbp-20h]

v5 = __readfsqword(0x28u);
if ( !(unsigned int)chanusers_ison(a2, a1) )
_assert_fail("chanusers_ison(u, c)", "src/channels.c", 0x45u, "channel_plsprefix");
if ( a3 == 111 )
{
jtableP_set(a1 + 512, a2);
}
else if ( a3 == 118 )
{
jtableP_set(a1 + 520, a2);
}
else
{
logfmt(256LL, "Invalid prefix mode change: %c\n", (unsigned int)a3);
}
return v5 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(__int64 a1, __int64 a2, char a3)
{
unsigned __int64 v5; // [rsp+8h] [rbp-20h]

v5 = __readfsqword(0x28u);
if ( !(unsigned int)chanusers_ison(a2, a1) )
_assert_fail("chanusers_ison(u, c)", "src/channels.c", 0x45u, "channel_plsprefix");
if ( a3 == 111 )
{
jtableP_set(a1 + 512, a2);
}
else if ( a3 == 118 )
{
jtableP_set(a1 + 520, a2);
}
else
{
logfmt(256LL, "Invalid prefix mode change: %c\n", (unsigned int)a3);
}
return v5 - __readfsqword(0x28u);
}

original_code:
void channel_plsprefix(struct channel *c, struct user *u, char mc) {
 ((chanusers_ison(u, c)) ? (void) (0) : __assert_fail ("chanusers_ison(u, c)", "src/channels.c", 69, __extension__ __PRETTY_FUNCTION__));
 if (mc == 'o')
  jtableP_set(&c->ops, u);
 else if (mc == 'v')
  jtableP_set(&c->voices, u);
 else
  logfmt(0x0100, "Invalid prefix mode change: %c" "\n", mc);
}

variable_types: struct user { unsigned int magic; unsigned long numeric; char numericstr[-1]; char nick[-1]; char user[-1]; char host[-1]; char fakehost[-1]; char opername[-1]; char account[-1]; long acctime; long accid; char realname[-1]; int hops; unsigned int accountid; char awaymsg[-1]; unsigned long mode; int channelcount; struct jtableP channels; struct server { unsigned int magic; unsigned long numeric; unsigned long lastnumeric; char numericstr[-1]; char name[-1]; unsigned long maxusers; int hops; long boot; long link; char protocol[4]; char description[-1]; struct jtableP users; unsigned long mode; } *server; } *

variable_types: mc char


decompiled_code:
unsigned __int64 __fastcall channel_mnsprefix(__int64 a1, __int64 a2, char a3)
{
unsigned __int64 v5; // [rsp+8h] [rbp-20h]

v5 = __readfsqword(0x28u);
if ( !(unsigned int)chanusers_ison(a2, a1) )
_assert_fail("chanusers_ison(u, c)", "src/channels.c", 0x4Fu, "channel_mnsprefix");
if ( a3 == 111 )
{
jtableP_unset(a1 + 512, a2);
}
else if ( a3 == 118 )
{
jtableP_unset(a1 + 520, a2);
}
else
{
logfmt(256LL, "Invalid prefix mode change: %c\n", (unsigned int)a3);
}
return v5 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func7(__int64 a1, __int64 a2, char a3)
{
unsigned __int64 v5; // [rsp+8h] [rbp-20h]

v5 = __readfsqword(0x28u);
if ( !(unsigned int)chanusers_ison(a2, a1) )
_assert_fail("chanusers_ison(u, c)", "src/channels.c", 0x4Fu, "channel_mnsprefix");
if ( a3 == 111 )
{
jtableP_unset(a1 + 512, a2);
}
else if ( a3 == 118 )
{
jtableP_unset(a1 + 520, a2);
}
else
{
logfmt(256LL, "Invalid prefix mode change: %c\n", (unsigned int)a3);
}
return v5 - __readfsqword(0x28u);
}

original_code:
void channel_mnsprefix(struct channel *c, struct user *u, char mc) {
 ((chanusers_ison(u, c)) ? (void) (0) : __assert_fail ("chanusers_ison(u, c)", "src/channels.c", 79, __extension__ __PRETTY_FUNCTION__));
 if (mc == 'o')
  jtableP_unset(&c->ops, u);
 else if (mc == 'v')
  jtableP_unset(&c->voices, u);
 else
  logfmt(0x0100, "Invalid prefix mode change: %c" "\n", mc);
}


decompiled_code:
unsigned __int64 __fastcall channel_plsban(__int64 a1, char *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbx
unsigned __int64 v7; // [rsp+8h] [rbp-30h]

v7 = __readfsqword(0x28u);
v4 = zmalloc(208LL);
v5 = v4;
if ( a2 && *(_DWORD *)a2 == 18929 )
{
strncpyz(v4 + 91, a2 + 22, 16LL);
strncpyz(v5 + 107, a2 + 38, 11LL);
strncpyz(v5 + 118, a2 + 49, 64LL);
strncpyz(v5 + 182, a2 + 204, 16LL);
}
strncpyz(v5, a3, 91LL);
*(_QWORD *)(v5 + 200) = now;
jtableS_insert(a1 + 536, a3, v5);
return v7 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func8(__int64 a1, char *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbx
unsigned __int64 v7; // [rsp+8h] [rbp-30h]

v7 = __readfsqword(0x28u);
v4 = zmalloc(208LL);
v5 = v4;
if ( a2 && *(_DWORD *)a2 == 18929 )
{
strncpyz(v4 + 91, a2 + 22, 16LL);
strncpyz(v5 + 107, a2 + 38, 11LL);
strncpyz(v5 + 118, a2 + 49, 64LL);
strncpyz(v5 + 182, a2 + 204, 16LL);
}
strncpyz(v5, a3, 91LL);
*(_QWORD *)(v5 + 200) = now;
jtableS_insert(a1 + 536, a3, v5);
return v7 - __readfsqword(0x28u);
}

original_code:
void channel_plsban(struct channel *c, struct entity *e, char *str) {
 struct mask *m;
 struct user *u;
 m = zmalloc(sizeof(*m));
 if (e && (((struct entity *)(e))->magic == 0x49F1)) {
  u = (struct user *)e;
  strncpyz((m->from.nick), (u->nick), sizeof(m->from.nick));
  strncpyz((m->from.user), (u->user), sizeof(m->from.user));
  strncpyz((m->from.host), (u->host), sizeof(m->from.host));
  strncpyz((m->from.account), (u->account), sizeof(m->from.account));
 }
 strncpyz((m->mask), (str), sizeof(m->mask));
 m->ts = now;
 jtableS_insert(&c->bans, str, m);
}

variable_types:
e
struct entity { unsigned int magic; } *

variable_types: struct user { unsigned int magic; unsigned long numeric; char numericstr[-1]; char nick[-1]; char user[-1]; char host[-1]; char fakehost[-1]; char opername[-1]; char account[-1]; long acctime; long accid; char realname[-1]; int hops; unsigned int accountid; char awaymsg[-1]; unsigned long mode; int channelcount; struct jtableP { void *t; } channels; struct server { unsigned int magic; unsigned long numeric; unsigned long lastnumeric; char numericstr[-1]; char name[-1]; unsigned long maxusers; int hops; long boot; long link; char protocol[4]; char description[-1]; struct jtableP users; unsigned long mode; } *server; } *

user_defined_types: struct maskfrom { char nick[-1]; char user[-1]; char host[-1]; char account[-1]; }


decompiled_code:
unsigned __int64 __fastcall channel_mnsban(__int64 a1, _DWORD *a2, __int64 a3)
{
__int64 v4; // rbp
unsigned __int64 v6; // [rsp+8h] [rbp-20h]

v6 = __readfsqword(0x28u);
if ( *a2 != 18929 )
logtxt(256LL, "Ban unset by non-user.\n");
v4 = jtableS_get(a1 + 536, a3);
if ( v4 )
{
jtableS_remove(a1 + 536, a3);
sfree(v4);
}
else
{
logtxt(256LL, "Non-existant ban removed.\n");
}
return v6 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func9(__int64 a1, _DWORD *a2, __int64 a3)
{
__int64 v4; // rbp
unsigned __int64 v6; // [rsp+8h] [rbp-20h]

v6 = __readfsqword(0x28u);
if ( *a2 != 18929 )
logtxt(256LL, "Ban unset by non-user.\n");
v4 = jtableS_get(a1 + 536, a3);
if ( v4 )
{
jtableS_remove(a1 + 536, a3);
sfree(v4);
}
else
{
logtxt(256LL, "Non-existant ban removed.\n");
}
return v6 - __readfsqword(0x28u);
}

original_code:
void channel_mnsban(struct channel *c, struct entity *e, char *str) {
 struct mask *m;
 if (!(((struct entity *)(e))->magic == 0x49F1))
  logtxt(0x0100, "Ban unset by non-user." "\n");
 m = jtableS_get(&c->bans, str);
 if (!m) {
  logtxt(0x0100, "Non-existant ban removed." "\n");
  return;
 }
 jtableS_remove(&c->bans, str);
 sfree(m);
}


decompiled_code:
__int64 __fastcall channel_modehook(char *a1, __int64 a2, int a3, char a4, const char *a5)
{
__int64 result; // rax
__int64 v9; // rax
__int64 v10; // r12
_DWORD *v11; // rax

if ( *(_DWORD *)a2 == 11988 )
{
switch ( a4 )
{
case 'b':
if ( a5 && *a5 )
{
if ( a3 )
channel_plsban(a2, a1, (__int64)a5);
else
channel_mnsban(a2, a1, (__int64)a5);
goto LABEL_17;
}
logtxt(256LL, "Invalid ban mode change or non-existant ban.\n");
result = 0LL;
break;
case 'k':
if ( a3 )
{
strncpyz(a2 + 205, a5, 24LL);
result = 0LL;
}
else
{
if ( strcmp((const char *)(a2 + 205), a5) )
logfmt(256LL, "Unset key that wasn't set. Mine: '%s', theirs: '%s'.\n", (const char *)(a2 + 205), a5);
*(_BYTE *)(a2 + 205) = 0;
result = 0LL;
}
break;
case 'l':
v9 = strtol(a5, 0LL, 10);
v10 = v9;
if ( a3 && v9 <= 0 )
logfmt(256LL, "Invalid limit setting: '%s' (=> %ld)\n", a5, v9);
*(_QWORD *)(a2 + 480) = v10;
result = 0LL;
break;
case 'o':
case 'v':
LABEL_17:
v11 = (_DWORD *)get_user_by_numericstr(a5);
if ( v11 && *v11 == 18929 )
{
if ( a3 )
channel_plsprefix(a2, (__int64)v11, a4);
else
channel_mnsprefix(a2, (__int64)v11, a4);
result = 0LL;
}
else
{
logtxt(256LL, "Op/voice for non-existant/invalid user!\n");
result = 0LL;
}
break;
default:
result = 0LL;
break;
}
}
else
{
logtxt(16LL, "Mode change for not-a-channel!\n");
result = 4294967293LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(char *a1, __int64 a2, int a3, char a4, const char *a5)
{
__int64 result; // rax
__int64 v9; // rax
__int64 v10; // r12
_DWORD *v11; // rax

if ( *(_DWORD *)a2 == 11988 )
{
switch ( a4 )
{
case 'b':
if ( a5 && *a5 )
{
if ( a3 )
func8(a2, a1, (__int64)a5);
else
func9(a2, a1, (__int64)a5);
goto LABEL_17;
}
logtxt(256LL, "Invalid ban mode change or non-existant ban.\n");
result = 0LL;
break;
case 'k':
if ( a3 )
{
strncpyz(a2 + 205, a5, 24LL);
result = 0LL;
}
else
{
if ( strcmp((const char *)(a2 + 205), a5) )
logfmt(256LL, "Unset key that wasn't set. Mine: '%s', theirs: '%s'.\n", (const char *)(a2 + 205), a5);
*(_BYTE *)(a2 + 205) = 0;
result = 0LL;
}
break;
case 'l':
v9 = strtol(a5, 0LL, 10);
v10 = v9;
if ( a3 && v9 <= 0 )
logfmt(256LL, "Invalid limit setting: '%s' (=> %ld)\n", a5, v9);
*(_QWORD *)(a2 + 480) = v10;
result = 0LL;
break;
case 'o':
case 'v':
LABEL_17:
v11 = (_DWORD *)get_user_by_numericstr(a5);
if ( v11 && *v11 == 18929 )
{
if ( a3 )
func6(a2, (__int64)v11, a4);
else
func7(a2, (__int64)v11, a4);
result = 0LL;
}
else
{
logtxt(256LL, "Op/voice for non-existant/invalid user!\n");
result = 0LL;
}
break;
default:
result = 0LL;
break;
}
}
else
{
logtxt(16LL, "Mode change for not-a-channel!\n");
result = 4294967293LL;
}
return result;
}

original_code:
static int channel_modehook(struct entity *from, struct entity *target, int pls, char modechange, char *param) {
 struct channel *c;
 struct user *u;
 long tmp;
 c = (struct channel *)target;
 if (!(((struct entity *)(c))->magic == 0x2ED4)) {
  logtxt(0x0010, "Mode change for not-a-channel!" "\n");
  return -3;
 }
 switch (modechange) {
  case 'k':
   if (!pls) {
    if (strcmp(c->key, param))
     logfmt(0x0100, "Unset key that wasn't set. Mine: '%s', theirs: '%s'." "\n", c->key, param);
    c->key[0] = '\0';
   } else
    strncpyz((c->key), (param), sizeof(c->key));
   break;
  case 'l':
   tmp = strtol(param, ((void *)0), 10);
   if (pls && tmp <= 0) {
    logfmt(0x0100, "Invalid limit setting: '%s' (=> %ld)" "\n", param, tmp);
   }
   c->limit = tmp;
   break;
  case 'b':
   if (!param || !param[0]) {
    logtxt(0x0100, "Invalid ban mode change or non-existant ban." "\n");
    return 0;
   }
   pls ? channel_plsban(c, from, param) : channel_mnsban(c, from, param);
  case 'o':
  case 'v':
   u = get_user_by_numericstr(param);
   if (!u || !(((struct entity *)(u))->magic == 0x49F1)) {
    logtxt(0x0100, "Op/voice for non-existant/invalid user!" "\n");
    return 0;
   }
   pls ? channel_plsprefix(c, u, modechange) : channel_mnsprefix(c, u, modechange);
   break;
 }
 return 0;
}

variable_types:
from
struct entity { unsigned int magic; } *

variable_types:
target
struct entity *

variable_types: pls int

variable_types: modechange char

variable_types:
param
char *

variable_types: tmp long


decompiled_code:
__int64 __fastcall channel_isop(__int64 a1)
{
return jtableP_check(a1 + 512);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
return jtableP_check(a1 + 512);
}

original_code:
int channel_isop(struct channel *c, struct user *u) {
 return jtableP_check(&c->ops, u);
}


decompiled_code:
__int64 __fastcall channel_isvoice(__int64 a1)
{
return jtableP_check(a1 + 520);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
return jtableP_check(a1 + 520);
}

original_code:
int channel_isvoice(struct channel *c, struct user *u) {
 return jtableP_check(&c->voices, u);
}


decompiled_code:
_BOOL8 __fastcall channel_isoporvoice(__int64 a1)
{
int v1; // edx
_BOOL8 result; // rax

v1 = channel_isop(a1);
result = 1LL;
if ( !v1 )
result = (unsigned int)channel_isvoice(a1) != 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func13(__int64 a1)
{
int v1; // edx
_BOOL8 result; // rax

v1 = func11(a1);
result = 1LL;
if ( !v1 )
result = (unsigned int)func12(a1) != 0;
return result;
}

original_code:
int channel_isoporvoice(struct channel *c, struct user *u) {
 return channel_isop(c, u) || channel_isvoice(c, u);
}


decompiled_code:
_BOOL8 __fastcall channel_isregular(__int64 a1)
{
return !channel_isoporvoice(a1);
}

canonical_decompiled_code:
_BOOL8 __fastcall func14(__int64 a1)
{
return !func13(a1);
}

original_code:
int channel_isregular(struct channel *c, struct user *u) {
 return !channel_isoporvoice(c, u);
}


decompiled_code:
unsigned __int64 __fastcall channel_burstmode(__int64 a1, __int64 a2, char *a3)
{
char *v3; // rbx
char v4; // dl
unsigned __int64 v6; // [rsp+8h] [rbp-20h]

v3 = a3;
v6 = __readfsqword(0x28u);
v4 = *a3;
if ( (v4 & 0xDF) != 0 )
{
do
{
++v3;
channel_plsprefix(a1, a2, v4);
v4 = *v3;
}
while ( (*v3 & 0xDF) != 0 );
}
return v6 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func15(__int64 a1, __int64 a2, char *a3)
{
char *v3; // rbx
char v4; // dl
unsigned __int64 v6; // [rsp+8h] [rbp-20h]

v3 = a3;
v6 = __readfsqword(0x28u);
v4 = *a3;
if ( (v4 & 0xDF) != 0 )
{
do
{
++v3;
func6(a1, a2, v4);
v4 = *v3;
}
while ( (*v3 & 0xDF) != 0 );
}
return v6 - __readfsqword(0x28u);
}

original_code:
void channel_burstmode(struct channel *chan, struct user *user, char *modes) {
 while (*modes && *modes != ' ')
  channel_plsprefix(chan, user, *modes++);
}

variable_types:
modes
char *


decompiled_code:
__int64 __fastcall channel_apply_mode(__int64 a1, _DWORD *a2, __int64 a3, __int64 a4, unsigned int a5)
{
if ( *a2 == 11988 )
return mode_apply(a1, a2, a2 + 126, a3, a4, a5, channel_modehook);
logtxt(256LL, "Mode change on non-channel\n");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, _DWORD *a2, __int64 a3, __int64 a4, unsigned int a5)
{
if ( *a2 == 11988 )
return mode_apply(a1, a2, a2 + 126, a3, a4, a5, channel_modehook);
logtxt(256LL, "Mode change on non-channel\n");
return 0LL;
}

original_code:
int channel_apply_mode(struct entity *from, struct channel *target, char *modechanges, struct manyargs *arg, int skip) {
 if (!(((struct entity *)(target))->magic == 0x2ED4)) {
  logtxt(0x0100, "Mode change on non-channel" "\n");
  return 0;
 }
 return mode_apply(from, (struct entity *)target, &target->mode, modechanges, arg, skip, channel_modehook);
}

variable_types:
modechanges
char *

variable_types: struct manyargs { unsigned char c; char *v[256]; } *

variable_types: skip int


decompiled_code:
__int64 __fastcall channel_apply_clearmode(__int64 a1, __int64 a2, char *a3)
{
char *v4; // rbx
char i; // si

if ( *(_DWORD *)a2 == 11988 )
{
v4 = a3;
for ( i = *a3; *v4; i = *v4 )
{
switch ( i )
{
case 'b':
jtableS_free(a2 + 536);
break;
case 'k':
*(_BYTE *)(a2 + 205) = 0;
mode_unset1(a2 + 504, (unsigned int)*v4);
break;
case 'l':
*(_QWORD *)(a2 + 480) = 0LL;
mode_unset1(a2 + 504, (unsigned int)*v4);
break;
case 'o':
jtableP_free(a2 + 512);
break;
case 'v':
jtableP_free(a2 + 520);
break;
default:
mode_unset1(a2 + 504, (unsigned int)i);
break;
}
++v4;
}
}
else
{
logtxt(256LL, "Clearmode on non-channel\n");
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2, char *a3)
{
char *v4; // rbx
char i; // si

if ( *(_DWORD *)a2 == 11988 )
{
v4 = a3;
for ( i = *a3; *v4; i = *v4 )
{
switch ( i )
{
case 'b':
jtableS_free(a2 + 536);
break;
case 'k':
*(_BYTE *)(a2 + 205) = 0;
mode_unset1(a2 + 504, (unsigned int)*v4);
break;
case 'l':
*(_QWORD *)(a2 + 480) = 0LL;
mode_unset1(a2 + 504, (unsigned int)*v4);
break;
case 'o':
jtableP_free(a2 + 512);
break;
case 'v':
jtableP_free(a2 + 520);
break;
default:
mode_unset1(a2 + 504, (unsigned int)i);
break;
}
++v4;
}
}
else
{
logtxt(256LL, "Clearmode on non-channel\n");
}
return 0LL;
}

original_code:
int channel_apply_clearmode(struct entity *from, struct entity *target, char *modes) {
 struct channel *channel = (struct channel *)target;
 if (!(((struct entity *)(channel))->magic == 0x2ED4)) {
  logtxt(0x0100, "Clearmode on non-channel" "\n");
  return 0;
 }
 while (*modes) {
  switch (*modes) {
   case 'o':
    jtableP_free(&channel->ops);
    break;
   case 'v':
    jtableP_free(&channel->voices);
    break;
   case 'b':
    jtableS_free(&channel->bans);
    break;
   case 'l':
    channel->limit = 0;
    mode_unset1(&channel->mode, *modes);
    break;
   case 'k':
    channel->key[0] = 0;
    mode_unset1(&channel->mode, *modes);
    break;
   default:
    mode_unset1(&channel->mode, *modes);
  }
  modes++;
 }
 return 0;
}

variable_types: struct channel { unsigned int magic; char name[-1]; char key[-1]; char topic[-1]; long limit; long ts; int usercount; unsigned long mode; struct jtableP { void *t; } ops; struct jtableS { void *t; } bans; } *


decompiled_code:
unsigned __int64 debug_print_users()
{
unsigned __int64 v1; // [rsp+8h] [rbp-10h]

v1 = __readfsqword(0x28u);
logtxt(0x4000LL, "------------- Channel -------------\n");
jtableS_iterate(&channels, debug_print_channel, 0LL);
return v1 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 func18()
{
unsigned __int64 v1; // [rsp+8h] [rbp-10h]

v1 = __readfsqword(0x28u);
logtxt(0x4000LL, "------------- Channel -------------\n");
jtableS_iterate(&channels, debug_print_channel, 0LL);
return v1 - __readfsqword(0x28u);
}

original_code:
void debug_print_users(void) {
 logtxt(0x4000, "------------- Channel -------------" "\n");
 jtableS_iterate(&channels, (jtableS_cb)debug_print_channel, ((void *)0));
}

canonical_original_code:
void debug_print_users() {
 logtxt(0x4000, "------------- Channel -------------" "\n");
 jtableS_iterate(&channels, (void (*)(char *key, void *data, void *param))debug_print_channel, ((void *)0));
}


decompiled_code:
unsigned __int64 __fastcall user_del_channel(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
*(_DWORD *)(a1 + 480) -= jtableP_unset(a1 + 488);
return v2 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
*(_DWORD *)(a1 + 480) -= jtableP_unset(a1 + 488);
return v2 - __readfsqword(0x28u);
}

original_code:
static void user_del_channel(struct user *u, struct channel *c) {
 u->channelcount -= jtableP_unset(&u->channels, c);
}

variable_types: struct channel { unsigned int magic; char name[-1]; char key[-1]; char topic[-1]; long limit; long ts; int usercount; unsigned long mode; struct jtableP ops; struct jtableS { void *t; } bans; } *


decompiled_code:
unsigned __int64 __fastcall channel_del_user(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-20h]

v2 = __readfsqword(0x28u);
jtableP_unset(a1 + 512);
jtableP_unset(a1 + 520);
*(_DWORD *)(a1 + 496) -= jtableP_unset(a1 + 528);
return v2 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-20h]

v2 = __readfsqword(0x28u);
jtableP_unset(a1 + 512);
jtableP_unset(a1 + 520);
*(_DWORD *)(a1 + 496) -= jtableP_unset(a1 + 528);
return v2 - __readfsqword(0x28u);
}

original_code:
static void channel_del_user(struct channel *c, struct user *u) {
 jtableP_unset(&c->ops, u);
 jtableP_unset(&c->voices, u);
 c->usercount -= jtableP_unset(&c->users, u);
}


decompiled_code:
unsigned __int64 __fastcall channel_add_user(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
*(_DWORD *)(a1 + 496) += jtableP_set(a1 + 528);
return v2 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func2(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
*(_DWORD *)(a1 + 496) += jtableP_set(a1 + 528);
return v2 - __readfsqword(0x28u);
}

original_code:
static void channel_add_user(struct channel *c, struct user *u) {
 c->usercount += jtableP_set(&c->users, u);
}


decompiled_code:
unsigned __int64 __fastcall user_add_channel(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
*(_DWORD *)(a1 + 480) += jtableP_set(a1 + 488);
return v2 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func3(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
*(_DWORD *)(a1 + 480) += jtableP_set(a1 + 488);
return v2 - __readfsqword(0x28u);
}

original_code:
static void user_add_channel(struct user *u, struct channel *c) {
 u->channelcount += jtableP_set(&u->channels, c);
}


decompiled_code:
__int64 __fastcall user_ison(__int64 a1)
{
return jtableP_check(a1 + 488);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return jtableP_check(a1 + 488);
}

original_code:
static int user_ison(struct user *u, struct channel *c) {
 return jtableP_check(&u->channels, c);
}


decompiled_code:
__int64 __fastcall channel_ison(__int64 a1)
{
return jtableP_check(a1 + 528);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return jtableP_check(a1 + 528);
}

original_code:
static int channel_ison(struct channel *c, struct user *u) {
 return jtableP_check(&c->users, u);
}


decompiled_code:
unsigned __int64 __fastcall chanusers_del_channel(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
jtableP_iterate(a1 + 528, user_del_channel, a1);
return v2 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
jtableP_iterate(a1 + 528, user_del_channel, a1);
return v2 - __readfsqword(0x28u);
}

original_code:
void chanusers_del_channel(struct channel *c) {
 jtableP_iterate(&c->users, (jtableP_cb)user_del_channel, c);
}

canonical_original_code:
void chanusers_del_channel(struct channel *c) {
 jtableP_iterate(&c->users, (void (*)(void *key, void *param))user_del_channel, c);
}


decompiled_code:
unsigned __int64 __fastcall chanusers_del_user(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
jtableP_iterate(a1 + 488, channel_del_user, a1);
return v2 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func7(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
jtableP_iterate(a1 + 488, channel_del_user, a1);
return v2 - __readfsqword(0x28u);
}

original_code:
void chanusers_del_user(struct user *u) {
 jtableP_iterate(&u->channels, (jtableP_cb)channel_del_user, u);
}

canonical_original_code:
void chanusers_del_user(struct user *u) {
 jtableP_iterate(&u->channels, (void (*)(void *key, void *param))channel_del_user, u);
}


decompiled_code:
unsigned __int64 __fastcall chanusers_join(__int64 a1, __int64 a2)
{
unsigned __int64 v3; // [rsp+8h] [rbp-20h]

v3 = __readfsqword(0x28u);
channel_add_user(a2);
user_add_channel(a1);
return v3 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func8(__int64 a1, __int64 a2)
{
unsigned __int64 v3; // [rsp+8h] [rbp-20h]

v3 = __readfsqword(0x28u);
func2(a2);
func3(a1);
return v3 - __readfsqword(0x28u);
}

original_code:
void chanusers_join(struct user *u, struct channel *c) {
 channel_add_user(c, u);
 user_add_channel(u, c);
}


decompiled_code:
unsigned __int64 __fastcall chanusers_leave(__int64 a1, __int64 a2)
{
unsigned __int64 v3; // [rsp+8h] [rbp-20h]

v3 = __readfsqword(0x28u);
channel_del_user(a2);
user_del_channel(a1);
return v3 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func9(__int64 a1, __int64 a2)
{
unsigned __int64 v3; // [rsp+8h] [rbp-20h]

v3 = __readfsqword(0x28u);
func1(a2);
func0(a1);
return v3 - __readfsqword(0x28u);
}

original_code:
void chanusers_leave(struct user *u, struct channel *c) {
 channel_del_user(c, u);
 user_del_channel(u, c);
}


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

if ( *(_DWORD *)(a1 + 480) >= *(_DWORD *)(a2 + 496) )
result = channel_ison(a2);
else
result = user_ison(a1);
return result;
}

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

if ( *(_DWORD *)(a1 + 480) >= *(_DWORD *)(a2 + 496) )
result = func5(a2);
else
result = func4(a1);
return result;
}

original_code:
int chanusers_ison(struct user *u, struct channel *c) {
 if (u->channelcount < c->usercount)
  return user_ison(u, c);
 else
  return channel_ison(c, u);
}


decompiled_code:
unsigned __int64 __fastcall chanusers_join0(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
chanusers_del_user(a1);
jtableP_free(a1 + 488);
if ( *(_DWORD *)(a1 + 480) )
_assert_fail("u->channelcount == 0", "src/chanusers.c", 0x5Au, "chanusers_join0");
return v2 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func11(__int64 a1)
{
unsigned __int64 v2; // [rsp+8h] [rbp-10h]

v2 = __readfsqword(0x28u);
func7(a1);
jtableP_free(a1 + 488);
if ( *(_DWORD *)(a1 + 480) )
_assert_fail("u->channelcount == 0", "src/chanusers.c", 0x5Au, "chanusers_join0");
return v2 - __readfsqword(0x28u);
}

original_code:
void chanusers_join0(struct user *u) {
 chanusers_del_user(u);
 jtableP_free(&u->channels);
 ((u->channelcount == 0) ? (void) (0) : __assert_fail ("u->channelcount == 0", "src/chanusers.c", 90, __extension__ __PRETTY_FUNCTION__));
}


decompiled_code:
unsigned __int64 __fastcall hook_register(__int64 a1)
{
__int64 v1; // rax
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
v1 = zmalloc(8LL);
jtableS_insert(&hooks, a1, v1);
return v3 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(__int64 a1)
{
__int64 v1; // rax
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
v1 = zmalloc(8LL);
jtableS_insert(&hooks, a1, v1);
return v3 - __readfsqword(0x28u);
}

original_code:
static void hook_register(char *name) {
 jtableP *t = zmalloc(sizeof(*t));
 jtableS_insert(&hooks, name, t);
}

canonical_original_code:
static void hook_register(char *name) {
 struct jtableP *t = zmalloc(sizeof(*t));
 jtableS_insert(&hooks, name, t);
}

variable_types:
name
char *

variable_types:
t
struct jtableP { void *t; } *


decompiled_code:
__int64 __fastcall get_funcs(const char *a1)
{
__int64 v1; // rbx

v1 = jtableS_get(&hooks, a1);
if ( !v1 )
logfmt(256LL, "Invalid hook '%s'\n", a1);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
__int64 v1; // rbx

v1 = jtableS_get(&hooks, a1);
if ( !v1 )
logfmt(256LL, "Invalid hook '%s'\n", a1);
return v1;
}

original_code:
static jtableP *get_funcs(const char *name) {
 jtableP *funcs = jtableS_get(&hooks, name);
 if (!funcs) {
  logfmt(0x0100, "Invalid hook '%s'" "\n", name);
  return ((void *)0);
 }
 return funcs;
}

canonical_original_code:
static struct jtableP *get_funcs(char *name) {
 struct jtableP *funcs = jtableS_get(&hooks, name);
 if (!funcs) {
  logfmt(0x0100, "Invalid hook '%s'" "\n", name);
  return ((void *)0);
 }
 return funcs;
}

variable_types:
funcs
struct jtableP { void *t; } *

return_type: struct jtableP { void *t; } *


decompiled_code:
unsigned __int64 hook_call1()
{
unsigned __int64 v1; // [rsp+8h] [rbp-10h]

v1 = __readfsqword(0x28u);
call_varargs();
return v1 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 func2()
{
unsigned __int64 v1; // [rsp+8h] [rbp-10h]

v1 = __readfsqword(0x28u);
call_varargs();
return v1 - __readfsqword(0x28u);
}

original_code:
static void hook_call1(void (*func)(), struct args *arg) {
 call_varargs(func, arg);
}

variable_types:
func
void (*)()

variable_types: struct args { unsigned char c; struct funcarg { enum argtype { ARGTYPE_NONE=0, ARGTYPE_INT=1, ARGTYPE_UINT=2, ARGTYPE_LONG=3, ARGTYPE_ULONG=4, ARGTYPE_TIME=5, ARGTYPE_USER=6, ARGTYPE_CHAN=7, ARGTYPE_SERVER=8, ARGTYPE_STR=9, ARGTYPE_PTR=10 } type; union argdata { int i; unsigned int u; long l; unsigned long ul; long t; void *p; } data; } v[20]; } *

user_defined_types: struct args { unsigned char c; struct funcarg v[20]; }