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

v3 = a2;
v4 = __readfsqword(0x28u);
logfmt(0x4000LL, "[%s]\n", a1);
jtableS_iterate(&v3, print_key_value, a1);
return v4 - __readfsqword(0x28u);
}

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

v3 = a2;
v4 = __readfsqword(0x28u);
logfmt(0x4000LL, "[%s]\n", a1);
jtableS_iterate(&v3, print_key_value, a1);
return v4 - __readfsqword(0x28u);
}

original_code:
static void print_section(char *section, jtableS sectiondata) {
 logfmt(0x4000, "[%s]" "\n", section);
 jtableS_iterate(&sectiondata, (jtableS_cb)print_key_value, section);
}

canonical_original_code:
static void print_section(char *section, struct jtableS sectiondata) {
 logfmt(0x4000, "[%s]" "\n", section);
 jtableS_iterate(&sectiondata, (void (*)(char *key, void *data, void *param))print_key_value, section);
}

variable_types:
sectiondata
struct jtableS { void *t; }


repo: thommey/plservices

decompiled_code:
__int64 __fastcall config_get(_BYTE *a1, _BYTE *a2)
{
__int64 v2; // rdi

if ( a1 && a2 && *a1 && *a2 )
{
v2 = jtableS_getptr(&configdata, a1);
if ( v2 )
return jtableS_get(v2, a2);
}
else
{
logtxt(256LL, "Invalid config file get with empty data\n");
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(_BYTE *a1, _BYTE *a2)
{
__int64 v2; // rdi

if ( a1 && a2 && *a1 && *a2 )
{
v2 = jtableS_getptr(&configdata, a1);
if ( v2 )
return jtableS_get(v2, a2);
}
else
{
logtxt(256LL, "Invalid config file get with empty data\n");
}
return 0LL;
}

original_code:
char *config_get(const char *section, const char *key) {
 jtableS *sectiondata;
 if (!section || !key || !section[0] || !key[0]) {
  logtxt(0x0100, "Invalid config file get with empty data" "\n");
  return ((void *)0);
 }
 sectiondata = jtableS_getptr(&configdata, section);
 if (!sectiondata)
  return ((void *)0);
 return jtableS_get(sectiondata, key);
}

canonical_original_code:
char *config_get(char *section, char *key) {
 struct jtableS *sectiondata;
 if (!section || !key || !section[0] || !key[0]) {
  logtxt(0x0100, "Invalid config file get with empty data" "\n");
  return ((void *)0);
 }
 sectiondata = jtableS_getptr(&configdata, section);
 if (!sectiondata)
  return ((void *)0);
 return jtableS_get(sectiondata, key);
}

variable_types:
section
char *

variable_types:
key
char *

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

return_type: char *


decompiled_code:
__int64 __fastcall config_set(_BYTE *a1, _BYTE *a2, _BYTE *a3)
{
__int64 v5; // r14
__int64 v6; // rax
__int64 v7; // rdx

if ( a3 == 0LL || a2 == 0LL || !a1 || !*a1 || !*a2 || !*a3 )
return logtxt(256LL, "Invalid config file insert with empty data\n");
v5 = jtableS_getptr(&configdata, a1);
if ( !v5 )
{
jtableS_insert(&configdata, a1, 0LL);
v5 = jtableS_getptr(&configdata, a1);
}
v6 = jtableS_get(v5, a2);
sfree(v6);
v7 = sstrdup(a3);
return jtableS_insert(v5, a2, v7);
}

canonical_decompiled_code:
__int64 __fastcall func5(_BYTE *a1, _BYTE *a2, _BYTE *a3)
{
__int64 v5; // r14
__int64 v6; // rax
__int64 v7; // rdx

if ( a3 == 0LL || a2 == 0LL || !a1 || !*a1 || !*a2 || !*a3 )
return logtxt(256LL, "Invalid config file insert with empty data\n");
v5 = jtableS_getptr(&configdata, a1);
if ( !v5 )
{
jtableS_insert(&configdata, a1, 0LL);
v5 = jtableS_getptr(&configdata, a1);
}
v6 = jtableS_get(v5, a2);
sfree(v6);
v7 = sstrdup(a3);
return jtableS_insert(v5, a2, v7);
}

original_code:
void config_set(const char *section, const char *key, const char *value) {
 jtableS *sectiondata;
 char *tmp;
 if (!section || !key || !value || !section[0] || !key[0] || !value[0]) {
  logtxt(0x0100, "Invalid config file insert with empty data" "\n");
  return;
 }
 sectiondata = jtableS_getptr(&configdata, section);
 if (!sectiondata) {
  jtableS_insert(&configdata, section, ((void *)0));
  sectiondata = jtableS_getptr(&configdata, section);
 }
 tmp = jtableS_get(sectiondata, key);
 sfree(tmp);
 jtableS_insert(sectiondata, key, sstrdup(value));
}

canonical_original_code:
void config_set(char *section, char *key, char *value) {
 struct jtableS *sectiondata;
 char *tmp;
 if (!section || !key || !value || !section[0] || !key[0] || !value[0]) {
  logtxt(0x0100, "Invalid config file insert with empty data" "\n");
  return;
 }
 sectiondata = jtableS_getptr(&configdata, section);
 if (!sectiondata) {
  jtableS_insert(&configdata, section, ((void *)0));
  sectiondata = jtableS_getptr(&configdata, section);
 }
 tmp = jtableS_get(sectiondata, key);
 sfree(tmp);
 jtableS_insert(sectiondata, key, sstrdup(value));
}

variable_types:
value
char *

variable_types:
tmp
char *

return_type: void


decompiled_code:
__int64 print_config()
{
return jtableS_iterate(&configdata, print_section, 0LL);
}

canonical_decompiled_code:
__int64 func8()
{
return jtableS_iterate(&configdata, print_section, 0LL);
}

original_code:
void print_config(void) {
 jtableS_iterate(&configdata, (jtableS_cb)print_section, ((void *)0));
}

canonical_original_code:
void print_config() {
 jtableS_iterate(&configdata, (void (*)(char *key, void *data, void *param))print_section, ((void *)0));
}


decompiled_code:
__int64 __fastcall get_user_by_numeric(__int64 a1)
{
return jtableL_get(&userlist_num, a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return jtableL_get(&userlist_num, a1);
}

original_code:
struct user *get_user_by_numeric(unsigned long numeric) {
 return jtableL_get(&userlist_num, numeric);
}

variable_types:
numeric
unsigned long

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:
__int64 get_user_by_numericstr()
{
__int64 v0; // rdi

v0 = str2unum();
return get_user_by_numeric(v0);
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rdi

v0 = str2unum();
return func0(v0);
}

original_code:
struct user *get_user_by_numericstr(const char *numeric) {
 return get_user_by_numeric(str2unum(numeric));
}

canonical_original_code:
struct user *get_user_by_numericstr(char *numeric) {
 return get_user_by_numeric(str2unum(numeric));
}

variable_types:
numeric
char *

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


decompiled_code:
__int64 __fastcall get_user_by_nick(__int64 a1)
{
__int64 v1; // rax
_QWORD v3[5]; // [rsp+0h] [rbp-28h] BYREF

v3[3] = __readfsqword(0x28u);
v1 = strconv(&rfc_tolower, v3, 16LL, a1);
return jtableS_get(&userlist_nick, v1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // rax
_QWORD v3[5]; // [rsp+0h] [rbp-28h] BYREF

v3[3] = __readfsqword(0x28u);
v1 = strconv(&rfc_tolower, v3, 16LL, a1);
return jtableS_get(&userlist_nick, v1);
}

original_code:
struct user *get_user_by_nick(const char *nick) {
 char buf[15 +1];
 return jtableS_get(&userlist_nick, strconv(rfc_tolower, buf, sizeof(buf), nick));
}

canonical_original_code:
struct user *get_user_by_nick(char *nick) {
 char buf[-1];
 return jtableS_get(&userlist_nick, strconv(rfc_tolower, buf, sizeof(buf), nick));
}

variable_types:
nick
char *

variable_types:
buf
char [-1]


decompiled_code:
__int64 __fastcall add_user(__int64 a1, int a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
_DWORD *v10; // rax
_DWORD *v11; // r12
__int64 v12; // rax
__int64 v13; // rbp
__int64 v14; // rax
char v16[24]; // [rsp+10h] [rbp-58h] BYREF
unsigned __int64 v17; // [rsp+28h] [rbp-40h]

v17 = __readfsqword(0x28u);
v10 = (_DWORD *)zmalloc(504LL);
*v10 = 18929;
v11 = v10;
strncpyz(v10 + 4, a1, 6LL);
*((_QWORD *)v11 + 1) = str2unum(a1);
v11[75] = a2;
strncpyz((char *)v11 + 22, a3, 16LL);
strncpyz((char *)v11 + 38, a4, 11LL);
strncpyz((char *)v11 + 49, a5, 64LL);
strncpyz(v11 + 62, a6, 51LL);
v12 = get_server_by_numericstr(a1);
if ( !v12 )
_assert_fail("s", "src/users.c", 0x43u, "add_user");
v13 = v12;
server_add_user(v12, v11);
*((_QWORD *)v11 + 62) = v13;
v14 = strconv(&rfc_tolower, v16, 16LL, a3);
jtableS_insert(&userlist_nick, v14, v11);
return jtableL_insert(&userlist_num, *((_QWORD *)v11 + 1), v11);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
_DWORD *v10; // rax
_DWORD *v11; // r12
__int64 v12; // rax
__int64 v13; // rbp
__int64 v14; // rax
char v16[24]; // [rsp+10h] [rbp-58h] BYREF
unsigned __int64 v17; // [rsp+28h] [rbp-40h]

v17 = __readfsqword(0x28u);
v10 = (_DWORD *)zmalloc(504LL);
*v10 = 18929;
v11 = v10;
strncpyz(v10 + 4, a1, 6LL);
*((_QWORD *)v11 + 1) = str2unum(a1);
v11[75] = a2;
strncpyz((char *)v11 + 22, a3, 16LL);
strncpyz((char *)v11 + 38, a4, 11LL);
strncpyz((char *)v11 + 49, a5, 64LL);
strncpyz(v11 + 62, a6, 51LL);
v12 = get_server_by_numericstr(a1);
if ( !v12 )
_assert_fail("s", "src/users.c", 0x43u, "add_user");
v13 = v12;
server_add_user(v12, v11);
*((_QWORD *)v11 + 62) = v13;
v14 = strconv(&rfc_tolower, v16, 16LL, a3);
jtableS_insert(&userlist_nick, v14, v11);
return jtableL_insert(&userlist_num, *((_QWORD *)v11 + 1), v11);
}

original_code:
struct user *add_user(char *numeric, int hops, char *nick, const char *user, const char *host, const char *realname) {
 char buf[15 +1];
 struct user *u;
 struct server *s;
 u = zmalloc(sizeof(*u));
 u->magic = 0x49F1;
 strncpyz((u->numericstr), (numeric), sizeof(u->numericstr));
 u->numeric = str2unum(numeric);
 u->hops = hops;
 strncpyz((u->nick), (nick), sizeof(u->nick));
 strncpyz((u->user), (user), sizeof(u->user));
 strncpyz((u->host), (host), sizeof(u->host));
 strncpyz((u->realname), (realname), sizeof(u->realname));
 s = get_server_by_numericstr(numeric);
 ((s) ? (void) (0) : __assert_fail ("s", "src/users.c", 67, __extension__ __PRETTY_FUNCTION__));
 server_add_user(s, u);
 u->server = s;
 jtableS_insert(&userlist_nick, strconv(rfc_tolower, buf, sizeof(buf), nick), u);
 return jtableL_insert(&userlist_num, u->numeric, u);
}

canonical_original_code:
struct user *add_user(char *numeric, int hops, char *nick, char *user, char *host, char *realname) {
 char buf[-1];
 struct user *u;
 struct server *s;
 u = zmalloc(sizeof(*u));
 u->magic = 0x49F1;
 strncpyz((u->numericstr), (numeric), sizeof(u->numericstr));
 u->numeric = str2unum(numeric);
 u->hops = hops;
 strncpyz((u->nick), (nick), sizeof(u->nick));
 strncpyz((u->user), (user), sizeof(u->user));
 strncpyz((u->host), (host), sizeof(u->host));
 strncpyz((u->realname), (realname), sizeof(u->realname));
 s = get_server_by_numericstr(numeric);
 ((s) ? (void) (0) : __assert_fail ("s", "src/users.c", 67, __extension__ __PRETTY_FUNCTION__));
 server_add_user(s, u);
 u->server = s;
 jtableS_insert(&userlist_nick, strconv(rfc_tolower, buf, sizeof(buf), nick), u);
 return jtableL_insert(&userlist_num, u->numeric, u);
}

variable_types: hops int

variable_types:
user
char *

variable_types:
host
char *

variable_types:
realname
char *

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: 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 { void *t; } users; unsigned long mode; } *


decompiled_code:
void __fastcall del_user(void *ptr)
{
__int64 v1; // rax
__int64 v2; // rdx
__int64 v3; // rax
_BYTE v4[328]; // [rsp-150h] [rbp-2D8h] BYREF
_BYTE v5[336]; // [rsp+0h] [rbp-188h] BYREF
char v6[24]; // [rsp+150h] [rbp-38h] BYREF
unsigned __int64 v7; // [rsp+168h] [rbp-20h]

v7 = __readfsqword(0x28u);
v1 = arg_ptr();
pack_args(v5, v1, v2, 0LL, 0LL);
qmemcpy(v4, v5, sizeof(v4));
hook_call("onuserdel");
server_del_user(*((_QWORD *)ptr + 62), ptr);
v3 = strconv(&rfc_tolower, v6, 16LL, (char *)ptr + 22);
jtableS_remove(&userlist_nick, v3);
jtableL_remove(&userlist_num, *((_QWORD *)ptr + 1));
jtableP_unset(&opers, ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
__int64 v1; // rax
__int64 v2; // rdx
__int64 v3; // rax
_BYTE v4[328]; // [rsp-150h] [rbp-2D8h] BYREF
_BYTE v5[336]; // [rsp+0h] [rbp-188h] BYREF
char v6[24]; // [rsp+150h] [rbp-38h] BYREF
unsigned __int64 v7; // [rsp+168h] [rbp-20h]

v7 = __readfsqword(0x28u);
v1 = arg_ptr();
pack_args(v5, v1, v2, 0LL, 0LL);
qmemcpy(v4, v5, sizeof(v4));
hook_call("onuserdel");
server_del_user(*((_QWORD *)ptr + 62), ptr);
v3 = strconv(&rfc_tolower, v6, 16LL, (char *)ptr + 22);
jtableS_remove(&userlist_nick, v3);
jtableL_remove(&userlist_num, *((_QWORD *)ptr + 1));
jtableP_unset(&opers, ptr);
free(ptr);
}

original_code:
void del_user(struct user *user) {
 char buf[15 +1];
 hook_call("onuserdel", pack_args(arg_ptr(user), (struct funcarg) {.type = ARGTYPE_NONE}));
 server_del_user(user->server, user);
 jtableS_remove(&userlist_nick, strconv(rfc_tolower, buf, sizeof(buf), user->nick));
 jtableL_remove(&userlist_num, user->numeric);
 jtableP_unset(&opers, user);
 free(user);
}

canonical_original_code:
void del_user(struct user *user) {
 char buf[-1];
 hook_call("onuserdel", pack_args(arg_ptr(user), (struct funcarg) {.type = ARGTYPE_NONE}));
 server_del_user(user->server, user);
 jtableS_remove(&userlist_nick, strconv(rfc_tolower, buf, sizeof(buf), user->nick));
 jtableL_remove(&userlist_num, user->numeric);
 jtableP_unset(&opers, user);
 free(user);
}

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:
void __fastcall del_user_iter(_DWORD *a1)
{
if ( a1 )
{
if ( *a1 == 18929 )
del_user(a1);
}
}

canonical_decompiled_code:
void __fastcall func5(_DWORD *a1)
{
if ( a1 )
{
if ( *a1 == 18929 )
func4(a1);
}
}

original_code:
void del_user_iter(void *uptr, void *unused) {
 if (!uptr || !(((struct entity *)(uptr))->magic == 0x49F1))
  return;
 del_user(uptr);
}

variable_types:
uptr
void *

variable_types:
unused
void *


decompiled_code:
unsigned __int64 __fastcall user_nickchange(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rax
_BYTE v5[24]; // [rsp+0h] [rbp-48h] BYREF
unsigned __int64 v6; // [rsp+18h] [rbp-30h]

v6 = __readfsqword(0x28u);
v2 = strconv(&rfc_tolower, v5, 16LL, a1 + 22);
jtableS_remove(&userlist_nick, v2);
v3 = strconv(&rfc_tolower, v5, 16LL, a2);
jtableS_insert(&userlist_nick, v3, a1);
strncpyz(a1 + 22, a2, 16LL);
return v6 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rax
_BYTE v5[24]; // [rsp+0h] [rbp-48h] BYREF
unsigned __int64 v6; // [rsp+18h] [rbp-30h]

v6 = __readfsqword(0x28u);
v2 = strconv(&rfc_tolower, v5, 16LL, a1 + 22);
jtableS_remove(&userlist_nick, v2);
v3 = strconv(&rfc_tolower, v5, 16LL, a2);
jtableS_insert(&userlist_nick, v3, a1);
strncpyz(a1 + 22, a2, 16LL);
return v6 - __readfsqword(0x28u);
}

original_code:
void user_nickchange(struct user *u, char *newnick) {
 char buf[15 +1];
 jtableS_remove(&userlist_nick, strconv(rfc_tolower, buf, sizeof(buf), u->nick));
 jtableS_insert(&userlist_nick, strconv(rfc_tolower, buf, sizeof(buf), newnick), u);
 strncpyz((u->nick), (newnick), sizeof(u->nick));
}

canonical_original_code:
void user_nickchange(struct user *u, char *newnick) {
 char buf[-1];
 jtableS_remove(&userlist_nick, strconv(rfc_tolower, buf, sizeof(buf), u->nick));
 jtableS_insert(&userlist_nick, strconv(rfc_tolower, buf, sizeof(buf), newnick), u);
 strncpyz((u->nick), (newnick), sizeof(u->nick));
}

variable_types:
newnick
char *


decompiled_code:
__int64 __fastcall user_setopername(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
if ( a2 )
result = strncpyz(a1 + 188, a2, 16LL);
else
result = v3 - __readfsqword(0x28u);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
if ( a2 )
result = strncpyz(a1 + 188, a2, 16LL);
else
result = v3 - __readfsqword(0x28u);
return result;
}

original_code: void user_setopername (struct user *u, char *str) { if (str) strncpyz((u->opername), (str), sizeof(u->opername)); }

canonical_original_code: void user_setopername(struct user *u, char *str) { if (str) strncpyz((u->opername), (str), sizeof(u->opername)); }

variable_types:
str
char *


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

v2 = __readfsqword(0x28u);
*(_BYTE *)(a1 + 188) = 0;
return v2 - __readfsqword(0x28u);
}

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

v2 = __readfsqword(0x28u);
*(_BYTE *)(a1 + 188) = 0;
return v2 - __readfsqword(0x28u);
}

original_code: void user_unsetopername (struct user *u) { *u->opername = '\0'; }

canonical_original_code: void user_unsetopername(struct user *u) { *u->opername = '\0'; }


decompiled_code:
__int64 __fastcall user_setfakehost(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
if ( a2 )
result = strncpyz(a1 + 113, a2, 75LL);
else
result = v3 - __readfsqword(0x28u);
return result;
}

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

v3 = __readfsqword(0x28u);
if ( a2 )
result = strncpyz(a1 + 113, a2, 75LL);
else
result = v3 - __readfsqword(0x28u);
return result;
}

original_code: void user_setfakehost (struct user *u, char *str) { if (str) strncpyz((u->fakehost), (str), sizeof(u->fakehost)); }

canonical_original_code: void user_setfakehost(struct user *u, char *str) { if (str) strncpyz((u->fakehost), (str), sizeof(u->fakehost)); }


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

v2 = __readfsqword(0x28u);
*(_BYTE *)(a1 + 113) = 0;
return v2 - __readfsqword(0x28u);
}

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

v2 = __readfsqword(0x28u);
*(_BYTE *)(a1 + 113) = 0;
return v2 - __readfsqword(0x28u);
}

original_code: void user_unsetfakehost (struct user *u) { *u->fakehost = '\0'; }

canonical_original_code: void user_unsetfakehost(struct user *u) { *u->fakehost = '\0'; }


decompiled_code:
__int64 __fastcall user_setawaymsg(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned __int64 v3; // [rsp+8h] [rbp-10h]

v3 = __readfsqword(0x28u);
if ( a2 )
result = strncpyz(a1 + 308, a2, 161LL);
else
result = v3 - __readfsqword(0x28u);
return result;
}

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

v3 = __readfsqword(0x28u);
if ( a2 )
result = strncpyz(a1 + 308, a2, 161LL);
else
result = v3 - __readfsqword(0x28u);
return result;
}

original_code: void user_setawaymsg (struct user *u, char *str) { if (str) strncpyz((u->awaymsg), (str), sizeof(u->awaymsg)); }

canonical_original_code: void user_setawaymsg(struct user *u, char *str) { if (str) strncpyz((u->awaymsg), (str), sizeof(u->awaymsg)); }


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

v2 = __readfsqword(0x28u);
*(_BYTE *)(a1 + 308) = 0;
return v2 - __readfsqword(0x28u);
}

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

v2 = __readfsqword(0x28u);
*(_BYTE *)(a1 + 308) = 0;
return v2 - __readfsqword(0x28u);
}

original_code: void user_unsetawaymsg (struct user *u) { *u->awaymsg = '\0'; }

canonical_original_code: void user_unsetawaymsg(struct user *u) { *u->awaymsg = '\0'; }


decompiled_code:
unsigned __int64 __fastcall user_setaccount(_QWORD *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
unsigned __int64 v9; // [rsp+8h] [rbp-30h]

v9 = __readfsqword(0x28u);
strncpyz((char *)a1 + 204, a2, 16LL);
a1[28] = a3;
a1[29] = a4;
a1[30] = a5;
return v9 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func13(_QWORD *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
unsigned __int64 v9; // [rsp+8h] [rbp-30h]

v9 = __readfsqword(0x28u);
strncpyz((char *)a1 + 204, a2, 16LL);
a1[28] = a3;
a1[29] = a4;
a1[30] = a5;
return v9 - __readfsqword(0x28u);
}

original_code:
void user_setaccount(struct user *u, char *accname, time_t ts, long id, long flags) {
 strncpyz((u->account), (accname), sizeof(u->account));
 u->acctime = ts;
 u->accid = id;
 u->accflags = flags;
}

canonical_original_code:
void user_setaccount(struct user *u, char *accname, long ts, long id, long flags) {
 strncpyz((u->account), (accname), sizeof(u->account));
 u->acctime = ts;
 u->accid = id;
 u->accflags = flags;
}

variable_types:
accname
char *

variable_types: ts long

variable_types: id long

variable_types: flags long


decompiled_code:
unsigned __int64 __fastcall user_setaccountcolon(_QWORD *a1, __int64 a2)
{
__int64 v2; // r14
__int64 v3; // r12
__int64 v4; // r13
__int64 v5; // r8
char v7[8]; // [rsp+0h] [rbp-838h] BYREF
__int64 v8; // [rsp+8h] [rbp-830h]
char *nptr; // [rsp+10h] [rbp-828h]
char *v10; // [rsp+18h] [rbp-820h]
char *v11; // [rsp+20h] [rbp-818h]
unsigned __int64 v12; // [rsp+808h] [rbp-30h]

v12 = __readfsqword(0x28u);
split(v7, a2, 58LL);
if ( v7[0] )
{
v2 = v8;
if ( v7[0] == 1 )
{
v3 = 0LL;
v4 = 0LL;
v5 = 0LL;
}
else
{
v3 = strtol(nptr, 0LL, 10);
if ( v7[0] <= 2u )
{
v4 = 0LL;
v5 = 0LL;
}
else
{
v4 = strtol(v10, 0LL, 10);
if ( v7[0] <= 3u )
v5 = 0LL;
else
v5 = strtol(v11, 0LL, 10);
}
}
user_setaccount(a1, v2, v3, v4, v5);
}
else
{
logtxt(256LL, "Invalid +r parameter\n");
}
return v12 - __readfsqword(0x28u);
}

original_code:
static void user_setaccountcolon(struct user *u, char *param) {
 struct manyargs arg;
 char *accname;
 time_t ts;
 long id, flags;
 split(&arg, param, ':');
 if (arg.c == 0) {
  logtxt(0x0100, "Invalid +r parameter" "\n");
  return;
 }
 accname = arg.v[0];
 ts = arg.c > 1 ? (time_t)strtol(arg.v[1], ((void *)0), 10) : 0;
 id = arg.c > 2 ? strtol(arg.v[2], ((void *)0), 10) : 0;
 flags = arg.c > 3 ? strtol(arg.v[3], ((void *)0), 10) : 0;
 user_setaccount(u, accname, ts, id, flags);
}

canonical_original_code:
static void user_setaccountcolon(struct user *u, char *param) {
 struct manyargs arg;
 char *accname;
 long ts;
 long id; long flags;
 split(&arg, param, ':');
 if (arg.c == 0) {
  logtxt(0x0100, "Invalid +r parameter" "\n");
  return;
 }
 accname = arg.v[0];
 ts = arg.c > 1 ? (long)strtol(arg.v[1], ((void *)0), 10) : 0;
 id = arg.c > 2 ? strtol(arg.v[2], ((void *)0), 10) : 0;
 flags = arg.c > 3 ? strtol(arg.v[3], ((void *)0), 10) : 0;
 user_setaccount(u, accname, ts, id, flags);
}

variable_types:
param
char *

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


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

v2 = __readfsqword(0x28u);
*(_QWORD *)(a1 + 224) = 0LL;
*(_WORD *)(a1 + 204) = 48;
*(_QWORD *)(a1 + 240) = 0LL;
*(_QWORD *)(a1 + 232) = 0LL;
return v2 - __readfsqword(0x28u);
}

original_code:
void user_unsetaccount(struct user *u) {
 u->account[0] = '0';
 u->account[1] = '\0';
 u->acctime = 0;
 u->accflags = 0;
 u->accid = 0;
}


decompiled_code:
__int64 __fastcall user_modehook(__int64 a1, _QWORD *a2, int a3, char a4, __int64 a5)
{
if ( *(_DWORD *)a2 != 18929 )
{
logtxt(16LL, "Mode change for not-a-user!\n");
return 4294967293LL;
}
if ( a4 == 111 )
{
if ( !a3 )
goto LABEL_16;
if ( a5 )
{
user_setopername((__int64)a2, a5);
goto LABEL_15;
}
LABEL_14:
if ( a3 )
{
LABEL_15:
jtableP_set(&opers, a2);
return 0LL;
}
LABEL_16:
jtableP_unset(&opers, a2);
return 0LL;
}
if ( a4 > 111 )
{
if ( a4 == 114 )
{
if ( a3 )
{
user_setaccountcolon(a2, a5);
return 0LL;
}
user_unsetaccount((__int64)a2);
}
return 0LL;
}
if ( a4 == 79 )
goto LABEL_14;
if ( a4 != 104 )
return 0LL;
if ( a3 )
user_setfakehost((__int64)a2, a5);
else
user_unsetfakehost((__int64)a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, _QWORD *a2, int a3, char a4, __int64 a5)
{
if ( *(_DWORD *)a2 != 18929 )
{
logtxt(16LL, "Mode change for not-a-user!\n");
return 4294967293LL;
}
if ( a4 == 111 )
{
if ( !a3 )
goto LABEL_16;
if ( a5 )
{
func7((__int64)a2, a5);
goto LABEL_15;
}
LABEL_14:
if ( a3 )
{
LABEL_15:
jtableP_set(&opers, a2);
return 0LL;
}
LABEL_16:
jtableP_unset(&opers, a2);
return 0LL;
}
if ( a4 > 111 )
{
if ( a4 == 114 )
{
if ( a3 )
{
func14(a2, a5);
return 0LL;
}
func15((__int64)a2);
}
return 0LL;
}
if ( a4 == 79 )
goto LABEL_14;
if ( a4 != 104 )
return 0LL;
if ( a3 )
func9((__int64)a2, a5);
else
func10((__int64)a2);
return 0LL;
}

original_code:
int user_modehook(struct entity *from, struct entity *target, int pls, char modechange, char *param) {
 struct user *u;
 u = (struct user *)target;
 if (!(((struct entity *)(u))->magic == 0x49F1)) {
  logtxt(0x0010, "Mode change for not-a-user!" "\n");
  return -3;
 }
 switch (modechange) {
 case 'o':
  if (pls && param)
   user_setopername(u, param);
 case 'O':
  pls ? jtableP_set(&opers, u) : jtableP_unset(&opers, u);
  break;
 case 'h':
  pls ? user_setfakehost(u, param) : user_unsetfakehost(u);
  break;
 case 'r':
  pls ? user_setaccountcolon(u, param) : user_unsetaccount(u);
  break;
 }
 return 0;
}

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

variable_types:
target
struct entity *

variable_types: pls int

variable_types: modechange char

return_type: int


decompiled_code:
__int64 __fastcall user_apply_mode(__int64 a1, _DWORD *a2, __int64 a3, __int64 a4, unsigned int a5)
{
unsigned __int64 v6; // [rsp+8h] [rbp-10h]

v6 = __readfsqword(0x28u);
if ( *a2 != 18929 )
return logtxt(256LL, "Usermode change on non-user\n");
mode_apply(a1, a2, a2 + 118, a3, a4, a5, user_modehook);
return v6 - __readfsqword(0x28u);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, _DWORD *a2, __int64 a3, __int64 a4, unsigned int a5)
{
unsigned __int64 v6; // [rsp+8h] [rbp-10h]

v6 = __readfsqword(0x28u);
if ( *a2 != 18929 )
return logtxt(256LL, "Usermode change on non-user\n");
mode_apply(a1, a2, a2 + 118, a3, a4, a5, user_modehook);
return v6 - __readfsqword(0x28u);
}

original_code:
void user_apply_mode(struct entity *from, struct user *target, char *modechanges, struct manyargs *arg, int skip) {
 if (!(((struct entity *)(target))->magic == 0x49F1)) {
  logtxt(0x0100, "Usermode change on non-user" "\n");
  return;
 }
 mode_apply(from, (struct entity *)target, &target->mode, modechanges, arg, skip, user_modehook);
}

variable_types:
modechanges
char *

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

variable_types: skip int


decompiled_code:
__int64 __fastcall user_isoper(__int64 a1)
{
return jtableP_check(&opers, a1);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1)
{
return jtableP_check(&opers, a1);
}

original_code:
int user_isoper(struct user *u) {
 return jtableP_check(&opers, u);
}

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


decompiled_code:
unsigned __int64 init_base64()
{
unsigned __int8 v0; // cl
__int64 v1; // rdx
char v2; // al
__int64 v3; // rsi
unsigned __int64 v5; // [rsp+8h] [rbp-10h]

v0 = 66;
v1 = 65LL;
v5 = __readfsqword(0x28u);
v2 = 0;
base64table = -1LL;
xmmword_410 = -1LL;
xmmword_420 = -1LL;
xmmword_430 = -1LL;
xmmword_440 = -1LL;
xmmword_450 = -1LL;
xmmword_460 = -1LL;
xmmword_470 = -1LL;
xmmword_480 = -1LL;
xmmword_490 = -1LL;
xmmword_4A0 = -1LL;
xmmword_4B0 = -1LL;
xmmword_4C0 = -1LL;
xmmword_4D0 = -1LL;
xmmword_4E0 = -1LL;
xmmword_4F0 = -1LL;
while ( 1 )
{
*((_BYTE *)&base64table + v1) = v2;
if ( !v0 )
break;
v3 = (unsigned __int8)(v2 + 2);
++v2;
v1 = v0;
v0 = base64chars[v3];
}
return v5 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 func0()
{
unsigned __int8 v0; // cl
__int64 v1; // rdx
char v2; // al
__int64 v3; // rsi
unsigned __int64 v5; // [rsp+8h] [rbp-10h]

v0 = 66;
v1 = 65LL;
v5 = __readfsqword(0x28u);
v2 = 0;
base64table = -1LL;
xmmword_410 = -1LL;
xmmword_420 = -1LL;
xmmword_430 = -1LL;
xmmword_440 = -1LL;
xmmword_450 = -1LL;
xmmword_460 = -1LL;
xmmword_470 = -1LL;
xmmword_480 = -1LL;
xmmword_490 = -1LL;
xmmword_4A0 = -1LL;
xmmword_4B0 = -1LL;
xmmword_4C0 = -1LL;
xmmword_4D0 = -1LL;
xmmword_4E0 = -1LL;
xmmword_4F0 = -1LL;
while ( 1 )
{
*((_BYTE *)&base64table + v1) = v2;
if ( !v0 )
break;
v3 = (unsigned __int8)(v2 + 2);
++v2;
v1 = v0;
v0 = base64chars[v3];
}
return v5 - __readfsqword(0x28u);
}

original_code:
void init_base64(void) {
 int i;
 for (i = 0; i < sizeof(base64table); i++)
  base64table[(unsigned char)(i)] = -1;
 for (i = 0; base64chars[(unsigned char)(i)]; i++)
  base64table[(unsigned char)(base64chars[(unsigned char)(i)])] = i;
}

canonical_original_code:
void init_base64() {
 int i;
 for (i = 0; i < sizeof(base64table); i++)
  base64table[(unsigned char)(i)] = -1;
 for (i = 0; base64chars[(unsigned char)(i)]; i++)
  base64table[(unsigned char)(base64chars[(unsigned char)(i)])] = i;
}

variable_types: i int


decompiled_code:
__int64 __fastcall base64_decode_long(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rdx
__int64 v3; // r8
__int64 v4; // rax

v2 = 0LL;
v3 = 0LL;
while ( a2 )
{
if ( v2 >= a2 )
return v3;
v4 = *(unsigned __int8 *)(a1 + v2);
LABEL_4:
++v2;
v3 = *((char *)&base64table + v4) + (v3 << 6);
}
v4 = *(unsigned __int8 *)(a1 + v2);
if ( (_BYTE)v4 )
goto LABEL_4;
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rdx
__int64 v3; // r8
__int64 v4; // rax

v2 = 0LL;
v3 = 0LL;
while ( a2 )
{
if ( v2 >= a2 )
return v3;
v4 = *(unsigned __int8 *)(a1 + v2);
LABEL_4:
++v2;
v3 = *((char *)&base64table + v4) + (v3 << 6);
}
v4 = *(unsigned __int8 *)(a1 + v2);
if ( (_BYTE)v4 )
goto LABEL_4;
return v3;
}

original_code:
long base64_decode_long(const char *str, size_t len) {
 int i = 0;
 long result = 0;
 for (i = 0; len ? i < len : str[i]; i++) {
  result *= 64;
  result += base64table[(unsigned char)(str[i])];
 }
 return result;
}

canonical_original_code:
long base64_decode_long(char *str, unsigned long len) {
 int i = 0;
 long result = 0;
 for (i = 0; len ? i < len : str[i]; i++) {
  result *= 64;
  result += base64table[(unsigned char)(str[i])];
 }
 return result;
}

variable_types:
len
unsigned long

variable_types: result long

return_type: long


decompiled_code:
unsigned __int64 __fastcall base64_encode_padded(unsigned __int64 a1, unsigned __int64 a2, unsigned __int64 a3)
{
_BYTE *v3; // rax
unsigned __int64 v4; // r8
char v5; // cl

if ( a2 <= 1 )
{
logtxt(16LL, "Base64 encode with too small bufsize\n");
v4 = 0LL;
}
else
{
v3 = (_BYTE *)(a1 + a2 - 1);
v4 = a1;
*v3 = 0;
do
{
v5 = a3;
--v3;
a3 >>= 6;
*v3 = base64chars[v5 & 0x3F];
}
while ( a1 < (unsigned __int64)v3 );
}
return v4;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func2(unsigned __int64 a1, unsigned __int64 a2, unsigned __int64 a3)
{
_BYTE *v3; // rax
unsigned __int64 v4; // r8
char v5; // cl

if ( a2 <= 1 )
{
logtxt(16LL, "Base64 encode with too small bufsize\n");
v4 = 0LL;
}
else
{
v3 = (_BYTE *)(a1 + a2 - 1);
v4 = a1;
*v3 = 0;
do
{
v5 = a3;
--v3;
a3 >>= 6;
*v3 = base64chars[v5 & 0x3F];
}
while ( a1 < (unsigned __int64)v3 );
}
return v4;
}

original_code:
char *base64_encode_padded(char *buf, size_t bufsize, unsigned long num) {
 char *e;
 if (bufsize < 2) {
  logtxt(0x0010, "Base64 encode with too small bufsize" "\n");
  return ((void *)0);
 }
 e = buf + bufsize - 1;
 *e = '\0';
 do {
  *(--e) = base64chars[(unsigned char)(num % 64)];
  num /= 64;
 } while (e > buf);
 return buf;
}

canonical_original_code:
char *base64_encode_padded(char *buf, unsigned long bufsize, unsigned long num) {
 char *e;
 if (bufsize < 2) {
  logtxt(0x0010, "Base64 encode with too small bufsize" "\n");
  return ((void *)0);
 }
 e = buf + bufsize - 1;
 *e = '\0';
 do {
  *(--e) = base64chars[(unsigned char)(num % 64)];
  num /= 64;
 } while (e > buf);
 return buf;
}

variable_types:
buf
char *

variable_types:
bufsize
unsigned long

variable_types:
num
unsigned long

variable_types:
e
char *


decompiled_code:
__int64 __fastcall base64_incr(unsigned __int64 a1, unsigned __int64 a2)
{
_BYTE *v2; // rax
char v3; // dl
__int64 result; // rax

if ( a2 <= 1 )
{
logtxt(16LL, "Base64 incr with too small bufsize\n");
result = 1LL;
}
else
{
v2 = (_BYTE *)(a1 + a2 - 2);
if ( a1 <= (unsigned __int64)v2 )
{
while ( 1 )
{
v3 = *((_BYTE *)&base64table + (unsigned __int8)*v2);
if ( v3 != 63 )
break;
*v2-- = 65;
if ( a1 > (unsigned __int64)v2 )
goto LABEL_7;
}
*v2 = base64chars[(unsigned __int8)(v3 + 1)];
result = 0LL;
}
else
{
LABEL_7:
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int64 a1, unsigned __int64 a2)
{
_BYTE *v2; // rax
char v3; // dl
__int64 result; // rax

if ( a2 <= 1 )
{
logtxt(16LL, "Base64 incr with too small bufsize\n");
result = 1LL;
}
else
{
v2 = (_BYTE *)(a1 + a2 - 2);
if ( a1 <= (unsigned __int64)v2 )
{
while ( 1 )
{
v3 = *((_BYTE *)&base64table + (unsigned __int8)*v2);
if ( v3 != 63 )
break;
*v2-- = 65;
if ( a1 > (unsigned __int64)v2 )
goto LABEL_7;
}
*v2 = base64chars[(unsigned __int8)(v3 + 1)];
result = 0LL;
}
else
{
LABEL_7:
result = 1LL;
}
}
return result;
}

original_code:
int base64_incr(char *buf, size_t bufsize) {
 char *e, t;
 if (bufsize < 2) {
  logtxt(0x0010, "Base64 incr with too small bufsize" "\n");
  return 1;
 }
 e = buf + bufsize - 1;
 while (--e >= buf) {
  t = base64table[(unsigned char)(*e)];
  if (t == 63)
   *e = base64chars[0];
  else {
   *e = base64chars[(unsigned char)(t + 1)];
   return 0;
  }
 }
 return 1;
}

canonical_original_code:
int base64_incr(char *buf, unsigned long bufsize) {
 char *e; char t;
 if (bufsize < 2) {
  logtxt(0x0010, "Base64 incr with too small bufsize" "\n");
  return 1;
 }
 e = buf + bufsize - 1;
 while (--e >= buf) {
  t = base64table[(unsigned char)(*e)];
  if (t == 63)
   *e = base64chars[0];
  else {
   *e = base64chars[(unsigned char)(t + 1)];
   return 0;
  }
 }
 return 1;
}

variable_types: t char


decompiled_code:
__int64 __fastcall str2unum(__int64 a1)
{
return base64_decode_long(a1, 5uLL);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return func1(a1, 5uLL);
}

original_code:
unsigned long str2unum(const char *str) {
 return base64_decode_long(str, 5);
}

canonical_original_code:
unsigned long str2unum(char *str) {
 return base64_decode_long(str, 5);
}

variable_types:
str
char *

return_type: unsigned long


decompiled_code:
__int64 __fastcall str2snum(__int64 a1)
{
return base64_decode_long(a1, 2uLL);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return func1(a1, 2uLL);
}

original_code:
unsigned long str2snum(const char *str) {
 return base64_decode_long(str, 2);
}

canonical_original_code:
unsigned long str2snum(char *str) {
 return base64_decode_long(str, 2);
}


decompiled_code:
void *__fastcall unum2str(unsigned __int64 a1)
{
base64_encode_padded((unsigned __int64)&buf_2, 6uLL, a1);
return &buf_2;
}

canonical_decompiled_code:
void *__fastcall func6(unsigned __int64 a1)
{
func2((unsigned __int64)&buf_2, 6uLL, a1);
return &buf_2;
}

original_code:
const char *unum2str(unsigned long unum) {
 static char buf[5 +1];
 base64_encode_padded(buf, sizeof(buf), unum);
 return buf;
}

canonical_original_code:
char *unum2str(unsigned long unum) {
 static char buf[-1];
 base64_encode_padded(buf, sizeof(buf), unum);
 return buf;
}

variable_types:
unum
unsigned long

variable_types:
buf
char [-1]


decompiled_code:
void *__fastcall snum2str(unsigned __int64 a1)
{
base64_encode_padded((unsigned __int64)&buf_1, 3uLL, a1);
return &buf_1;
}

canonical_decompiled_code:
void *__fastcall func7(unsigned __int64 a1)
{
func2((unsigned __int64)&buf_1, 3uLL, a1);
return &buf_1;
}

original_code:
const char *snum2str(unsigned long snum) {
 static char buf[2 +1];
 base64_encode_padded(buf, sizeof(buf), snum);
 return buf;
}

canonical_original_code:
char *snum2str(unsigned long snum) {
 static char buf[-1];
 base64_encode_padded(buf, sizeof(buf), snum);
 return buf;
}

variable_types:
snum
unsigned long


decompiled_code:
void *__fastcall cnum2str(__int64 a1, __int64 a2)
{
base64_encode_padded((unsigned __int64)&buf_0, 6uLL, (a1 << 18) + a2);
return &buf_0;
}

canonical_decompiled_code:
void *__fastcall func8(__int64 a1, __int64 a2)
{
func2((unsigned __int64)&buf_0, 6uLL, (a1 << 18) + a2);
return &buf_0;
}

original_code:
const char *cnum2str(unsigned long snum, unsigned long cnum) {
 static char buf[5 +1];
 base64_encode_padded(buf, sizeof(buf), snum*64*64*64+cnum);
 return buf;
}

canonical_original_code:
char *cnum2str(unsigned long snum, unsigned long cnum) {
 static char buf[-1];
 base64_encode_padded(buf, sizeof(buf), snum*64*64*64+cnum);
 return buf;
}

variable_types:
cnum
unsigned long


decompiled_code:
__int64 __fastcall module_register(__int64 a1, const char *a2, const char *a3)
{
char *v4; // rax
__int64 v5; // rdx
_QWORD *v6; // rax

if ( modules[0] )
{
v4 = (char *)&modules[3];
LODWORD(v5) = 0;
do
{
v4 += 24;
v5 = (unsigned int)(v5 + 1);
}
while ( *((_QWORD *)v4 - 3) );
}
else
{
v5 = 0LL;
}
v6 = &modules[3 * (int)v5];
*v6 = a1;
v6[1] = a2;
v6[2] = a3;
logfmt(0x4000LL, "Module added - index: %d - name: %s - description: %s\n", v5, a2, a3);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2, const char *a3)
{
char *v4; // rax
__int64 v5; // rdx
_QWORD *v6; // rax

if ( modules[0] )
{
v4 = (char *)&modules[3];
LODWORD(v5) = 0;
do
{
v4 += 24;
v5 = (unsigned int)(v5 + 1);
}
while ( *((_QWORD *)v4 - 3) );
}
else
{
v5 = 0LL;
}
v6 = &modules[3 * (int)v5];
*v6 = a1;
v6[1] = a2;
v6[2] = a3;
logfmt(0x4000LL, "Module added - index: %d - name: %s - description: %s\n", v5, a2, a3);
return 0LL;
}

original_code:
int module_register(void *module, const char *name, const char *description) {
 int index = 0;
 for (; modules[index].module != ((void *)0); index++);
 if (index > 100) {
  logfmt(0x0100, "Cannot load module '%s' - max modules limit exceeded." "\n", name);
  return 1;
 }
 modules[index].module = module;
 modules[index].name = name;
 modules[index].description = description;
 logfmt(0x4000, "Module added - index: %d - name: %s - description: %s" "\n", index, name, description);
 return 0;
}

canonical_original_code:
int module_register(void *module, char *name, char *description) {
 int index = 0;
 for (; modules[index].module != ((void *)0); index++);
 if (index > 100) {
  logfmt(0x0100, "Cannot load module '%s' - max modules limit exceeded." "\n", name);
  return 1;
 }
 modules[index].module = module;
 modules[index].name = name;
 modules[index].description = description;
 logfmt(0x4000, "Module added - index: %d - name: %s - description: %s" "\n", index, name, description);
 return 0;
}

variable_types:
module
void *

variable_types:
name
char *

variable_types:
description
char *

variable_types: index int


decompiled_code:
__int64 __fastcall module_unregister(__int64 a1)
{
int v1; // eax
_QWORD *v2; // rdx
size_t v3; // rdx

v1 = 0;
v2 = modules;
while ( *v2 != a1 )
{
++v1;
v2 += 3;
if ( v1 == 100 )
{
v1 = -1;
goto LABEL_5;
}
}
if ( v1 == 99 )
return 1LL;
LABEL_5:
v3 = 24LL * (unsigned int)(99 - v1);
if ( v1 > 98 )
v3 = 24LL;
memmove(&modules[3 * v1], &modules[3 * v1 + 3], v3);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
int v1; // eax
_QWORD *v2; // rdx
size_t v3; // rdx

v1 = 0;
v2 = modules;
while ( *v2 != a1 )
{
++v1;
v2 += 3;
if ( v1 == 100 )
{
v1 = -1;
goto LABEL_5;
}
}
if ( v1 == 99 )
return 1LL;
LABEL_5:
v3 = 24LL * (unsigned int)(99 - v1);
if ( v1 > 98 )
v3 = 24LL;
memmove(&modules[3 * v1], &modules[3 * v1 + 3], v3);
return 1LL;
}

original_code:
int module_unregister(void *module) {
 int position = -1;
 for (int x = 0; x < 100; x++) {
  if (modules[x].module == module) {
   position = x;
   break;
  }
 }
 for (int c = position; c < 100 - 1 ; c++) modules[c] = modules[c+1];
 return 1;
}

variable_types: position int

variable_types: x int

variable_types: c int


decompiled_code:
__int64 __fastcall module_load(char *file, const char *a2, const char *a3)
{
void *v4; // rax
__int64 v5; // rbp
int (*v6)(void); // rbx
__int64 result; // rax
char *v8; // rax
char *v9; // rax

logfmt(0x4000LL, "(%s): Loading...\n", a2);
v4 = dlopen(file, 266);
if ( v4 )
{
v5 = (__int64)v4;
v6 = (int (*)(void))dlsym(v4, "load");
if ( dlerror() )
{
v8 = dlerror();
logfmt(16LL, "Cannot call 'load' for %s - error: %s\n", file, v8);
result = 1LL;
}
else if ( v6() > 0 )
{
logfmt(16LL, "(%s): load() was called, and exited with error.\n", a2);
result = 1LL;
}
else
{
module_register(v5, a2, a3);
result = 0LL;
}
}
else
{
v9 = dlerror();
logfmt(16LL, "Cannot load %s - error: %s\n", a2, v9);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *file, const char *a2, const char *a3)
{
void *v4; // rax
__int64 v5; // rbp
int (*v6)(void); // rbx
__int64 result; // rax
char *v8; // rax
char *v9; // rax

logfmt(0x4000LL, "(%s): Loading...\n", a2);
v4 = dlopen(file, 266);
if ( v4 )
{
v5 = (__int64)v4;
v6 = (int (*)(void))dlsym(v4, "load");
if ( dlerror() )
{
v8 = dlerror();
logfmt(16LL, "Cannot call 'load' for %s - error: %s\n", file, v8);
result = 1LL;
}
else if ( v6() > 0 )
{
logfmt(16LL, "(%s): load() was called, and exited with error.\n", a2);
result = 1LL;
}
else
{
func0(v5, a2, a3);
result = 0LL;
}
}
else
{
v9 = dlerror();
logfmt(16LL, "Cannot load %s - error: %s\n", a2, v9);
result = 1LL;
}
return result;
}

original_code:
int module_load(const char *path, const char *name, const char *description) {
 logfmt(0x4000, "(%s): Loading..." "\n", name);
 void *module;
 module = dlopen(path, 0x00002 | 0x00100 | 0x00008);
 if (!module) {
  logfmt(0x0010, "Cannot load %s - error: %s" "\n", name, dlerror());
  return 1;
 }
 module_func init;
 init = dlsym(module, "load");
 if (dlerror()) {
  logfmt(0x0010, "Cannot call 'load' for %s - error: %s" "\n", path, dlerror());
  return 1;
 }
 int res = init();
 if (res > 0) {
  logfmt(0x0010, "(%s): load() was called, and exited with error." "\n", name);
  return 1;
 }
 module_register(module, name, description);
 return 0;
}

canonical_original_code:
int module_load(char *path, char *name, char *description) {
 logfmt(0x4000, "(%s): Loading..." "\n", name);
 void *module;
 module = dlopen(path, 0x00002 | 0x00100 | 0x00008);
 if (!module) {
  logfmt(0x0010, "Cannot load %s - error: %s" "\n", name, dlerror());
  return 1;
 }
 int (*init)();
 init = dlsym(module, "load");
 if (dlerror()) {
  logfmt(0x0010, "Cannot call 'load' for %s - error: %s" "\n", path, dlerror());
  return 1;
 }
 int res = init();
 if (res > 0) {
  logfmt(0x0010, "(%s): load() was called, and exited with error." "\n", name);
  return 1;
 }
 module_register(module, name, description);
 return 0;
}

variable_types:
path
char *

variable_types:
init
int (*)()

variable_types: res int


decompiled_code:
__int64 __fastcall module_find_by_name(char *s2)
{
int v1; // ebx
size_t v2; // r14
const char **v3; // rbp

v1 = 0;
v2 = strlen(s2);
v3 = (const char **)&modules[1];
do
{
if ( !strncmp(*v3, s2, v2) )
return modules[3 * v1];
++v1;
v3 += 3;
}
while ( v1 != 100 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s2)
{
int v1; // ebx
size_t v2; // r14
const char **v3; // rbp

v1 = 0;
v2 = strlen(s2);
v3 = (const char **)&modules[1];
do
{
if ( !strncmp(*v3, s2, v2) )
return modules[3 * v1];
++v1;
v3 += 3;
}
while ( v1 != 100 );
return 0LL;
}

original_code:
void * module_find_by_name(const char *name) {
 for (int x = 0; x < 100; x++) {
  if (!strncmp(modules[x].name, name, strlen(name))) {
   return modules[x].module;
  }
 }
 return ((void *)0);
}

canonical_original_code:
void *module_find_by_name(char *name) {
 for (int x = 0; x < 100; x++) {
  if (!strncmp(modules[x].name, name, strlen(name))) {
   return modules[x].module;
  }
 }
 return ((void *)0);
}

return_type: void *


decompiled_code:
__int64 __fastcall module_unload(char *a1)
{
void *v1; // rax
__int64 v2; // rbp
__int64 (*v3)(void); // rbx
char *v4; // rax

v1 = (void *)module_find_by_name(a1);
if ( !v1 )
return 1LL;
v2 = (__int64)v1;
v3 = (__int64 (*)(void))dlsym(v1, "unload");
if ( dlerror() )
{
v4 = dlerror();
logfmt(16LL, "Cannot call 'unload' for %s - error: %s\n", a1, v4);
return 1LL;
}
module_unregister(v2);
return v3();
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
void *v1; // rax
__int64 v2; // rbp
__int64 (*v3)(void); // rbx
char *v4; // rax

v1 = (void *)func3(a1);
if ( !v1 )
return 1LL;
v2 = (__int64)v1;
v3 = (__int64 (*)(void))dlsym(v1, "unload");
if ( dlerror() )
{
v4 = dlerror();
logfmt(16LL, "Cannot call 'unload' for %s - error: %s\n", a1, v4);
return 1LL;
}
func1(v2);
return v3();
}

original_code:
int module_unload(const char *name) {
 void *mod = module_find_by_name(name);
 if (mod == ((void *)0)) return 1;
 module_func unload;
 unload = dlsym(mod, "unload");
 if (dlerror()) {
  logfmt(0x0010, "Cannot call 'unload' for %s - error: %s" "\n", name, dlerror());
  return 1;
 }
 module_unregister(mod);
 int result = unload();
 return result;
}

canonical_original_code:
int module_unload(char *name) {
 void *mod = module_find_by_name(name);
 if (mod == ((void *)0)) return 1;
 int (*unload)();
 unload = dlsym(mod, "unload");
 if (dlerror()) {
  logfmt(0x0010, "Cannot call 'unload' for %s - error: %s" "\n", name, dlerror());
  return 1;
 }
 module_unregister(mod);
 int result = unload();
 return result;
}

variable_types:
mod
void *

variable_types:
unload
int (*)()

variable_types: result int


decompiled_code:
__int64 __fastcall module_get_description(char *s2)
{
int v1; // ebx
size_t v2; // r14
const char **v3; // rbp

v1 = 0;
v2 = strlen(s2);
v3 = (const char **)&modules[1];
do
{
if ( !strncmp(*v3, s2, v2) )
return modules[3 * v1 + 2];
++v1;
v3 += 3;
}
while ( v1 != 100 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *s2)
{
int v1; // ebx
size_t v2; // r14
const char **v3; // rbp

v1 = 0;
v2 = strlen(s2);
v3 = (const char **)&modules[1];
do
{
if ( !strncmp(*v3, s2, v2) )
return modules[3 * v1 + 2];
++v1;
v3 += 3;
}
while ( v1 != 100 );
return 0LL;
}

original_code:
const char *module_get_description(const char *name) {
 for (int x = 0; x < 100; x++) {
  if (!strncmp(modules[x].name, name, strlen(name))) {
   return modules[x].description;
  }
 }
 return ((void *)0);
}

canonical_original_code:
char *module_get_description(char *name) {
 for (int x = 0; x < 100; x++) {
  if (!strncmp(modules[x].name, name, strlen(name))) {
   return modules[x].description;
  }
 }
 return ((void *)0);
}


decompiled_code:
__int64 module_loadAll()
{
module_load("modules/lua.so", "lua", "PLServices Lua Module.");
return module_load("modules/tcl.so", "tcl", "PLServices TCL Module.");
}

canonical_decompiled_code:
__int64 func6()
{
func2("modules/lua.so", "lua", "PLServices Lua Module.");
return func2("modules/tcl.so", "tcl", "PLServices TCL Module.");
}

original_code:
void module_loadAll() {
 module_load("modules/lua.so", "lua", "PLServices Lua Module.");
 module_load("modules/tcl.so", "tcl", "PLServices TCL Module.");
}


decompiled_code:
__int64 __fastcall module_join_channel(__int64 a1, const char *a2, int a3)
{
const char *v4; // rbp
__int64 v5; // rax
const char *v6; // r12
__int64 result; // rax
unsigned __int64 v8; // [rsp+0h] [rbp-20h]

v4 = (const char *)(a1 + 16);
v8 = __readfsqword(0x28u);
v5 = get_channel_by_name(a2);
if ( !v5 )
return send_format("%s C %s %ld\r\n", v4, a2, now);
v6 = (const char *)(v5 + 4);
send_format("%s J %s %ld\r\n", v4, (const char *)(v5 + 4), *(_QWORD *)(v5 + 488));
if ( a3 )
result = send_format("%s M %s +o %s\r\n", (const char *)(me + 24LL), v6, v4);
else
result = v8 - __readfsqword(0x28u);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, const char *a2, int a3)
{
const char *v4; // rbp
__int64 v5; // rax
const char *v6; // r12
__int64 result; // rax
unsigned __int64 v8; // [rsp+0h] [rbp-20h]

v4 = (const char *)(a1 + 16);
v8 = __readfsqword(0x28u);
v5 = get_channel_by_name(a2);
if ( !v5 )
return send_format("%s C %s %ld\r\n", v4, a2, now);
v6 = (const char *)(v5 + 4);
send_format("%s J %s %ld\r\n", v4, (const char *)(v5 + 4), *(_QWORD *)(v5 + 488));
if ( a3 )
result = send_format("%s M %s +o %s\r\n", (const char *)(me + 24LL), v6, v4);
else
result = v8 - __readfsqword(0x28u);
return result;
}

original_code:
void module_join_channel(struct user *from, const char *channel, int auto_op) {
 struct channel *chan = get_channel_by_name(channel);
 if (chan == ((void *)0)) {
  send_format("%s C %s %ld" "\r\n", from->numericstr, channel, now);
 } else {
  send_format("%s J %s %ld" "\r\n", from->numericstr, chan->name, chan->ts);
  if (auto_op) {
   send_format("%s M %s +o %s" "\r\n", me->numericstr, chan->name, from->numericstr);
  }
 }
}

canonical_original_code:
void module_join_channel(struct user *from, char *channel, int auto_op) {
 struct channel *chan = get_channel_by_name(channel);
 if (chan == ((void *)0)) {
  send_format("%s C %s %ld" "\r\n", from->numericstr, channel, now);
 } else {
  send_format("%s J %s %ld" "\r\n", from->numericstr, chan->name, chan->ts);
  if (auto_op) {
   send_format("%s M %s +o %s" "\r\n", me->numericstr, chan->name, from->numericstr);
  }
 }
}

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

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:
__int64 __fastcall module_part_channel(__int64 a1, const char *a2)
{
__int64 result; // rax
unsigned __int64 v3; // [rsp+8h] [rbp-20h]

v3 = __readfsqword(0x28u);
if ( get_channel_by_name(a2) )
result = send_format("%s L %s\r\n", (const char *)(a1 + 16), a2);
else
result = v3 - __readfsqword(0x28u);
return result;
}

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

v3 = __readfsqword(0x28u);
if ( get_channel_by_name(a2) )
result = send_format("%s L %s\r\n", (const char *)(a1 + 16), a2);
else
result = v3 - __readfsqword(0x28u);
return result;
}

original_code:
void module_part_channel(struct user *from, const char *channel) {
 if (get_channel_by_name(channel) == ((void *)0)) return;
 send_format("%s L %s" "\r\n", from->numericstr, channel);
}

canonical_original_code:
void module_part_channel(struct user *from, char *channel) {
 if (get_channel_by_name(channel) == ((void *)0)) return;
 send_format("%s L %s" "\r\n", from->numericstr, channel);
}


decompiled_code:
unsigned __int64 module_describe(__int64 a1, __int64 a2, const char *a3, ...)
{
gcc_va_list va; // [rsp+0h] [rbp-E8h] BYREF
unsigned __int64 v5; // [rsp+18h] [rbp-D0h]

va_start(va, a3);
v5 = __readfsqword(0x28u);
vsprintf(buf_2, a3, va);
if ( get_channel_by_name(a2) || get_user_by_numericstr(a2) )
send_format(LC18, a1 + 16, a2, buf_2);
return v5 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 func9(__int64 a1, __int64 a2, const char *a3, ...)
{
gcc_va_list va; // [rsp+0h] [rbp-E8h] BYREF
unsigned __int64 v5; // [rsp+18h] [rbp-D0h]

va_start(va, a3);
v5 = __readfsqword(0x28u);
vsprintf(buf_2, a3, va);
if ( get_channel_by_name(a2) || get_user_by_numericstr(a2) )
send_format(LC18, a1 + 16, a2, buf_2);
return v5 - __readfsqword(0x28u);
}

original_code:
void module_describe(struct user *from, const char *target, const char *message, ...) {
 static char buf[512];
 va_list ap;
 __builtin_va_start(ap,message);
 vsprintf(buf, message, ap);
 __builtin_va_end(ap);
 if (get_channel_by_name(target) == ((void *)0) && get_user_by_numericstr(target) == ((void *)0)) return;
 send_format("%s P %s :\001ACTION %s\001" "\r\n", from->numericstr, target, buf);
}

canonical_original_code:
void module_describe(struct user *from, char *target, char *message, ...) {
 static char buf[512];
 __builtin_va_list ap;
 __builtin_va_start(ap,message);
 vsprintf(buf, message, ap);
 __builtin_va_end(ap);
 if (get_channel_by_name(target) == ((void *)0) && get_user_by_numericstr(target) == ((void *)0)) return;
 send_format("%s P %s :\001ACTION %s\001" "\r\n", from->numericstr, target, buf);
}

variable_types:
target
char *

variable_types:
message
char *

variable_types:
buf
char [512]


decompiled_code:
unsigned __int64 module_privmsg(__int64 a1, const char *a2, const char *a3, ...)
{
gcc_va_list va; // [rsp+0h] [rbp-E8h] BYREF
unsigned __int64 v5; // [rsp+18h] [rbp-D0h]

va_start(va, a3);
v5 = __readfsqword(0x28u);
vsprintf(buf_1, a3, va);
if ( get_channel_by_name(a2) || get_user_by_numericstr(a2) )
send_format("%s P %s :%s\r\n", (const char *)(a1 + 16), a2, buf_1);
return v5 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 func10(__int64 a1, const char *a2, const char *a3, ...)
{
gcc_va_list va; // [rsp+0h] [rbp-E8h] BYREF
unsigned __int64 v5; // [rsp+18h] [rbp-D0h]

va_start(va, a3);
v5 = __readfsqword(0x28u);
vsprintf(buf_1, a3, va);
if ( get_channel_by_name(a2) || get_user_by_numericstr(a2) )
send_format("%s P %s :%s\r\n", (const char *)(a1 + 16), a2, buf_1);
return v5 - __readfsqword(0x28u);
}

original_code:
void module_privmsg(struct user *from, const char *target, const char *message, ...) {
 static char buf[512];
 va_list ap;
 __builtin_va_start(ap,message);
 vsprintf(buf, message, ap);
 __builtin_va_end(ap);
 if (get_channel_by_name(target) == ((void *)0) && get_user_by_numericstr(target) == ((void *)0)) return;
 send_format("%s P %s :%s" "\r\n", from->numericstr, target, buf);
}

canonical_original_code:
void module_privmsg(struct user *from, char *target, char *message, ...) {
 static char buf[512];
 __builtin_va_list ap;
 __builtin_va_start(ap,message);
 vsprintf(buf, message, ap);
 __builtin_va_end(ap);
 if (get_channel_by_name(target) == ((void *)0) && get_user_by_numericstr(target) == ((void *)0)) return;
 send_format("%s P %s :%s" "\r\n", from->numericstr, target, buf);
}


decompiled_code:
unsigned __int64 module_notice(__int64 a1, const char *a2, const char *a3, ...)
{
gcc_va_list va; // [rsp+0h] [rbp-E8h] BYREF
unsigned __int64 v5; // [rsp+18h] [rbp-D0h]

va_start(va, a3);
v5 = __readfsqword(0x28u);
vsprintf(buf_0, a3, va);
if ( get_user_by_numericstr(a2) )
send_format("%s O %s :%s\r\n", (const char *)(a1 + 16), a2, buf_0);
return v5 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 func11(__int64 a1, const char *a2, const char *a3, ...)
{
gcc_va_list va; // [rsp+0h] [rbp-E8h] BYREF
unsigned __int64 v5; // [rsp+18h] [rbp-D0h]

va_start(va, a3);
v5 = __readfsqword(0x28u);
vsprintf(buf_0, a3, va);
if ( get_user_by_numericstr(a2) )
send_format("%s O %s :%s\r\n", (const char *)(a1 + 16), a2, buf_0);
return v5 - __readfsqword(0x28u);
}

original_code:
void module_notice(struct user *from, const char *target, const char *message, ...) {
        static char buf[512];
        va_list ap;
        __builtin_va_start(ap,message);
        vsprintf(buf, message, ap);
        __builtin_va_end(ap);
        if (get_user_by_numericstr(target) == ((void *)0)) return;
        send_format("%s O %s :%s" "\r\n", from->numericstr, target, buf);
}

canonical_original_code:
void module_notice(struct user *from, char *target, char *message, ...) {
        static char buf[512];
        __builtin_va_list ap;
        __builtin_va_start(ap,message);
        vsprintf(buf, message, ap);
        __builtin_va_end(ap);
        if (get_user_by_numericstr(target) == ((void *)0)) return;
        send_format("%s O %s :%s" "\r\n", from->numericstr, target, buf);
}


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; // r15
__int64 v11; // r14
char *v12; // rax
const char *v13; // rdx
const char *v14; // rax
const char *v16; // [rsp+8h] [rbp-70h]
const char *v19; // [rsp+28h] [rbp-50h]

v10 = a7;
v11 = server_freenum();
if ( !*a6 && strchr(a5, 114) )
a6 = a2;
if ( !*a7 && strchr(a5, 111) )
v10 = a2;
v16 = (const char *)unum2str(v11);
v12 = strchr(a5, 111);
v13 = " ";
if ( !v12 )
{
v10 = (const char *)&LC22;
v13 = (const char *)&LC22;
}
v19 = v13;
if ( strchr(a5, 114) )
{
v14 = " ";
}
else
{
a6 = (const char *)&LC22;
v14 = (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,
v14,
a6,
v19,
v10,
"B]AAAB",
v16,
a8);
return get_user_by_numeric(v11);
}

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; // r15
__int64 v11; // r14
char *v12; // rax
const char *v13; // rdx
const char *v14; // rax
const char *v16; // [rsp+8h] [rbp-70h]
const char *v19; // [rsp+28h] [rbp-50h]

v10 = a7;
v11 = server_freenum();
if ( !*a6 && strchr(a5, 114) )
a6 = a2;
if ( !*a7 && strchr(a5, 111) )
v10 = a2;
v16 = (const char *)unum2str(v11);
v12 = strchr(a5, 111);
v13 = " ";
if ( !v12 )
{
v10 = (const char *)&LC22;
v13 = (const char *)&LC22;
}
v19 = v13;
if ( strchr(a5, 114) )
{
v14 = " ";
}
else
{
a6 = (const char *)&LC22;
v14 = (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,
v14,
a6,
v19,
v10,
"B]AAAB",
v16,
a8);
return get_user_by_numeric(v11);
}

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


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


decompiled_code:
__int64 __fastcall module_destroy_client(__int64 a1, const char *a2)
{
return send_format("%s Q :%s\r\n", (const char *)(a1 + 16), a2);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, const char *a2)
{
return send_format("%s Q :%s\r\n", (const char *)(a1 + 16), a2);
}

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


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:
__int64 mode_ontick()
{
return jtableL_iterate(&modebufs, &mode_flushmode_check, 0LL);
}

canonical_decompiled_code:
__int64 func2()
{
return jtableL_iterate(&modebufs, &mode_flushmode_check, 0LL);
}

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:
__int64 init_modes()
{
unsigned __int8 v0; // si
unsigned __int8 *v1; // r14
unsigned __int8 *v2; // r13
void **i; // r12
char v4; // bl
char *v5; // r14
char *v6; // rbx
unsigned __int8 v7; // si
const char *v8; // rbx
unsigned __int8 v9; // si
char *v10; // rbx
unsigned __int8 v11; // si

v0 = 98;
v1 = (unsigned __int8 *)&LC1;
v2 = (unsigned __int8 *)&LC0;
for ( i = &chanmodetable; ; v2 = (unsigned __int8 *)i[2] )
{
if ( v0 )
{
v4 = *((_BYTE *)i + 8);
v5 = (char *)(v1 + 1);
do
{
++v5;
registermode((__int64)&chanmodelist, v0, v4);
v0 = *(v5 - 1);
}
while ( v0 );
}
i += 2;
if ( !v2 )
break;
v0 = *v2;
v1 = v2;
}
v6 = (char *)&unk_1725;
v7 = 111;
do
{
++v6;
registermode((__int64)&usermodelist, v7, -127);
v7 = *(v6 - 1);
}
while ( v7 );
v8 = "OidkXnIgxRPqQ";
v9 = 119;
do
{
++v8;
registermode((__int64)&usermodelist, v9, -128);
v9 = *(v8 - 1);
}
while ( v9 );
v10 = "sn6";
v11 = 104;
do
{
++v10;
registermode((__int64)&servermodelist, v11, -128);
v11 = *(v10 - 1);
}
while ( v11 );
hook_hook("ontick", mode_ontick);
hook_hook("onuserdel", mode_flushmode_deletion);
return hook_hook("onserverdel", mode_flushmode_deletion);
}

canonical_decompiled_code:
__int64 func3()
{
unsigned __int8 v0; // si
unsigned __int8 *v1; // r14
unsigned __int8 *v2; // r13
void **i; // r12
char v4; // bl
char *v5; // r14
char *v6; // rbx
unsigned __int8 v7; // si
const char *v8; // rbx
unsigned __int8 v9; // si
char *v10; // rbx
unsigned __int8 v11; // si

v0 = 98;
v1 = (unsigned __int8 *)&LC1;
v2 = (unsigned __int8 *)&LC0;
for ( i = &chanmodetable; ; v2 = (unsigned __int8 *)i[2] )
{
if ( v0 )
{
v4 = *((_BYTE *)i + 8);
v5 = (char *)(v1 + 1);
do
{
++v5;
func1((__int64)&chanmodelist, v0, v4);
v0 = *(v5 - 1);
}
while ( v0 );
}
i += 2;
if ( !v2 )
break;
v0 = *v2;
v1 = v2;
}
v6 = (char *)&unk_1725;
v7 = 111;
do
{
++v6;
func1((__int64)&usermodelist, v7, -127);
v7 = *(v6 - 1);
}
while ( v7 );
v8 = "OidkXnIgxRPqQ";
v9 = 119;
do
{
++v8;
func1((__int64)&usermodelist, v9, -128);
v9 = *(v8 - 1);
}
while ( v9 );
v10 = "sn6";
v11 = 104;
do
{
++v10;
func1((__int64)&servermodelist, v11, -128);
v11 = *(v10 - 1);
}
while ( v11 );
hook_hook("ontick", mode_ontick);
hook_hook("onuserdel", mode_flushmode_deletion);
return hook_hook("onserverdel", mode_flushmode_deletion);
}

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()
{
return registermode((__int64)&servermodelist, 0x6Fu, -127);
}

canonical_decompiled_code:
unsigned __int64 func4()
{
return func1((__int64)&servermodelist, 0x6Fu, -127);
}

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()
{
return registermode((__int64)&servermodelist, 0x6Fu, -128);
}

canonical_decompiled_code:
unsigned __int64 func5()
{
return func1((__int64)&servermodelist, 0x6Fu, -128);
}

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


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


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:
void __fastcall mode_flushmode(void *ptr)
{
_BYTE *v1; // rcx
char *v2; // r8
_DWORD *v4; // rax
__int64 v5; // rcx
char *v6; // rdi
_DWORD *v7; // rsi

if ( ptr )
{
v1 = (_BYTE *)*((_QWORD *)ptr + 4);
v2 = (char *)ptr + 40;
if ( v1 != (char *)ptr + 40 )
{
v4 = *(_DWORD **)ptr;
v5 = v1 - v2;
v6 = (char *)ptr + 112;
v7 = v4 + 6;
if ( *v4 == 18929 )
v7 = v4 + 4;
send_format(
"%s M %s %.*s%.*s\r\n",
v7,
*((_QWORD *)ptr + 1) + 4LL,
v5,
v2,
*((_QWORD *)ptr + 13) - (_QWORD)v6,
v6);
}
jtableL_remove(&modebufs, *(_QWORD *)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func10(void *ptr)
{
_BYTE *v1; // rcx
char *v2; // r8
_DWORD *v4; // rax
__int64 v5; // rcx
char *v6; // rdi
_DWORD *v7; // rsi

if ( ptr )
{
v1 = (_BYTE *)*((_QWORD *)ptr + 4);
v2 = (char *)ptr + 40;
if ( v1 != (char *)ptr + 40 )
{
v4 = *(_DWORD **)ptr;
v5 = v1 - v2;
v6 = (char *)ptr + 112;
v7 = v4 + 6;
if ( *v4 == 18929 )
v7 = v4 + 4;
send_format(
"%s M %s %.*s%.*s\r\n",
v7,
*((_QWORD *)ptr + 1) + 4LL,
v5,
v2,
*((_QWORD *)ptr + 13) - (_QWORD)v6,
v6);
}
jtableL_remove(&modebufs, *(_QWORD *)ptr);
free(ptr);
}
}

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


decompiled_code:
void __fastcall mode_flushmode_check(__int64 a1, _QWORD *a2)
{
__int64 v2; // rax

v2 = a2[3];
if ( v2 )
{
if ( v2 <= now )
mode_flushmode(a2);
}
}

canonical_decompiled_code:
void __fastcall func11(__int64 a1, _QWORD *a2)
{
__int64 v2; // rax

v2 = a2[3];
if ( v2 )
{
if ( v2 <= now )
func10(a2);
}
}

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:
void __fastcall mode_flushmode_deletion(__int64 a1)
{
void *v1; // rax

v1 = (void *)jtableL_get(&modebufs, a1);
if ( v1 )
mode_flushmode(v1);
}

canonical_decompiled_code:
void __fastcall func12(__int64 a1)
{
void *v1; // rax

v1 = (void *)jtableL_get(&modebufs, a1);
if ( v1 )
func10(v1);
}

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)
{
__int64 v4; // rbp
int v5; // eax
const char *v6; // rdx
const char *v7; // r13
char *v8; // rax
char v10[264]; // [rsp-108h] [rbp-138h] BYREF
unsigned __int64 v11; // [rsp+0h] [rbp-30h]

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

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbp
int v5; // eax
const char *v6; // rdx
const char *v7; // r13
char *v8; // rax
char v10[264]; // [rsp-108h] [rbp-138h] BYREF
unsigned __int64 v11; // [rsp+0h] [rbp-30h]

v4 = a1 + 16;
v11 = __readfsqword(0x28u);
v5 = user_isoper();
v6 = "Access denied.";
if ( !v5 )
goto LABEL_4;
if ( *(_BYTE *)a3 == 1 )
{
module_notice(bot, a1 + 16, "You didn't specify enough parameters for LOAD.");
module_notice(bot, v4, "Usage: LOAD <script>");
module_notice(bot, v4, "Loads a lua script file into the engine.");
return 0LL;
}
v7 = *(const char **)(a3 + 16);
v8 = strpbrk(v7, "./");
v6 = "Invalid script name. Cannot contain '.' or '/'.";
if ( !v8 )
{
snprintf(v10, 0x100uLL, "scripts/lua/%s.lua", v7);
if ( (unsigned int)luabase_loadscript(v10) )
{
module_notice(bot, v4, "There was a problem loading '%s'.", *(const char **)(a3 + 16));
module_notice(bot, v4, "Please note that you do not need to include the '.lua' extension when loading a script.");
}
else
{
module_notice(bot, v4, "Done.");
}
}
else
{
LABEL_4:
module_notice(bot, v4, v6);
}
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)
{
__int64 v4; // rbp
int v5; // eax
const char *v6; // rdx
const char *v7; // r13
int v9; // eax
char v10[264]; // [rsp-108h] [rbp-138h] BYREF
unsigned __int64 v11; // [rsp+0h] [rbp-30h]

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

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbp
int v5; // eax
const char *v6; // rdx
const char *v7; // r13
int v9; // eax
char v10[264]; // [rsp-108h] [rbp-138h] BYREF
unsigned __int64 v11; // [rsp+0h] [rbp-30h]

v4 = a1 + 16;
v11 = __readfsqword(0x28u);
v5 = user_isoper();
v6 = "Access denied.";
if ( v5 )
{
if ( *(_BYTE *)a3 == 1 )
{
module_notice(bot, a1 + 16, "You didn't specify enough parameters for UNLOAD.");
module_notice(bot, v4, "Usage: UNLOAD <script>");
module_notice(bot, v4, "Unloads a load script file.");
return 0LL;
}
v7 = *(const char **)(a3 + 16);
if ( strpbrk(v7, "./") )
{
v6 = "Invalid script name. Cannot contain '.' or '/'.";
}
else
{
snprintf(v10, 0x100uLL, "scripts/lua/%s.lua", v7);
if ( !(unsigned int)luabase_valid_script(v10) )
{
module_notice(bot, v4, "Unknown script %s.", *(const char **)(a3 + 16));
return 0LL;
}
v9 = luabase_unloadscript(v10);
v6 = "Done.";
if ( v9 )
{
module_notice(bot, v4, "There was a problem unloading '%s'.", *(const char **)(a3 + 16));
module_notice(
bot,
v4,
"Please note that you do not need to include the '.lua' extension when unloading a script.");
return 0LL;
}
}
}
module_notice(bot, v4, v6);
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)
{
__int64 result; // rax
int v3[10]; // [rsp+10h] [rbp-38h] BYREF
unsigned __int64 v4; // [rsp+38h] [rbp-10h]

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

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

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

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 *