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

v2 = __readfsqword(0x28u);
lsw_conf_setdefault();
subst(&global_oco, a1, (__int64)"override /");
lsw_conf_calculate();
return v2 - __readfsqword(0x28u);
}

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

v2 = __readfsqword(0x28u);
func0();
func1(&global_oco, a1, (__int64)"override /");
func2();
return v2 - __readfsqword(0x28u);
}

original_code:
void lsw_conf_rootdir(const char *root_dir)
{
 lsw_conf_setdefault();
 subst(&global_oco.rootdir, root_dir, "override /");
 lsw_conf_calculate();
}

canonical_original_code:
void lsw_conf_rootdir(char *root_dir)
{
 lsw_conf_setdefault();
 subst(&global_oco.rootdir, root_dir, "override /");
 lsw_conf_calculate();
}


repo: libreswan/libreswan

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

v2 = __readfsqword(0x28u);
lsw_conf_setdefault();
subst(&qword_838, a1, (__int64)"secretsfile");
lsw_conf_calculate();
return v2 - __readfsqword(0x28u);
}

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

v2 = __readfsqword(0x28u);
func0();
func1(&qword_838, a1, (__int64)"secretsfile");
func2();
return v2 - __readfsqword(0x28u);
}

original_code:
void lsw_conf_secretsfile(const char *secretsfile)
{
 lsw_conf_setdefault();
 subst(&global_oco.secretsfile, secretsfile, "secretsfile");
 lsw_conf_calculate();
}

canonical_original_code:
void lsw_conf_secretsfile(char *secretsfile)
{
 lsw_conf_setdefault();
 subst(&global_oco.secretsfile, secretsfile, "secretsfile");
 lsw_conf_calculate();
}

variable_types:
secretsfile
char *

return_type: void


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

v2 = __readfsqword(0x28u);
lsw_conf_setdefault();
subst(&qword_878, a1, (__int64)"nsspassword");
lsw_conf_calculate();
return v2 - __readfsqword(0x28u);
}

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

v2 = __readfsqword(0x28u);
func0();
func1(&qword_878, a1, (__int64)"nsspassword");
func2();
return v2 - __readfsqword(0x28u);
}

original_code:
void lsw_conf_nsspassword(const char *nsspassword)
{
 lsw_conf_setdefault();
 subst(&global_oco.nsspassword, nsspassword, "nsspassword");
 lsw_conf_calculate();
}

canonical_original_code:
void lsw_conf_nsspassword(char *nsspassword)
{
 lsw_conf_setdefault();
 subst(&global_oco.nsspassword, nsspassword, "nsspassword");
 lsw_conf_calculate();
}

variable_types:
nsspassword
char *


decompiled_code:
__int64 __fastcall cidr_info(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7)
{
__int64 result; // rax

result = 0LL;
if ( (_BYTE)a7 )
result = ip_version_info(HIDWORD(a7));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7)
{
__int64 result; // rax

result = 0LL;
if ( (_BYTE)a7 )
result = ip_version_info(HIDWORD(a7));
return result;
}

original_code:
const struct ip_info *cidr_info(const ip_cidr cidr)
{
 if (!cidr.is_set) {
  return ((void *)0);
 }
 return ip_version_info(cidr.version);
}

canonical_original_code:
struct ip_info *cidr_info(struct ip_cidr cidr)
{
 if (!cidr.is_set) {
  return ((void *)0);
 }
 return ip_version_info(cidr.version);
}

variable_types: struct ip_cidr { _Bool is_set; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes bytes; unsigned int prefix_len; }

return_type: struct ip_info { enum ip_version { IPv4=4, IPv6=6 } ip_version; enum ip_index { IPv4_INDEX=0, IPv6_INDEX=1 } ip_index; char *ip_name; unsigned long ip_size; unsigned int mask_cnt; struct { struct ip_address { _Bool is_set; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes { unsigned char byte[16]; } bytes; } unspec; struct ip_address loopback; unsigned long (*jam)(struct jambuf { char *array; unsigned long total; unsigned long roof; char *dots; } *buf, struct ip_info *info, struct ip_bytes *bytes); unsigned long (*jam_wrapped)(struct jambuf *buf, struct ip_info *info, struct ip_bytes *bytes); } address; struct { unsigned long (*jam)(struct jambuf *buf, struct ip_info *info, struct ip_bytes *bytes, unsigned int hport); } endpoint; struct { struct ip_subnet { _Bool is_set; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes bytes; unsigned int maskbits; } zero; struct ip_subnet all; } subnet; struct { struct ip_range { _Bool is_set; _Bool is_subnet; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes start; struct ip_bytes end; } zero; struct ip_range all; } range; struct { struct ip_selector { _Bool is_set; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes bytes; unsigned int maskbits; unsigned int ipproto; int hport; } zero; struct ip_selector all; } selector; unsigned int ikev1_max_fragment_size; unsigned int ikev2_max_fragment_size; struct { int domain; char *domain_name; } socket; int af; char *af_name; unsigned long sockaddr_size; struct ip_address (*address_from_sockaddr)(struct ip_sockaddr { unsigned int len; union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } sa; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } sa; } sa); struct ip_port { unsigned int hport; } (*port_from_sockaddr)(struct ip_sockaddr sa); enum ikev2_ts_type { IKEv2_TS_IPV4_ADDR_RANGE=7, IKEv2_TS_IPV6_ADDR_RANGE=8, IKEv2_TS_FC_ADDR_RANGE=9, IKEv2_TS_SECLABEL=10 } ikev2_ts_addr_range_type; enum ikev2_cp_attribute_type { IKEv2_CP_ATTR_RESERVED=0, IKEv2_INTERNAL_IP4_ADDRESS=1, IKEv2_INTERNAL_IP4_NETMASK=2, IKEv2_INTERNAL_IP4_DNS=3, IKEv2_INTERNAL_IP4_NBNS=4, IKEv2_RESERVED_5=5, IKEv2_INTERNAL_IP4_DHCP=6, IKEv2_APPLICATION_VERSION=7, IKEv2_INTERNAL_IP6_ADDRESS=8, IKEv2_RESERVED_9=9, IKEv2_INTERNAL_IP6_DNS=10, IKEv2_RESERVED_11=11, IKEv2_INTERNAL_IP6_DHCP=12, IKEv2_INTERNAL_IP4_SUBNET=13, IKEv2_SUPPORTED_ATTRIBUTES=14, IKEv2_INTERNAL_IP6_SUBNET=15, IKEv2_MIP6_HOME_PREFIX=16, IKEv2_INTERNAL_IP6_LINK=17, IKEv2_INTERNAL_IP6_PREFIX=18, IKEv2_HOME_AGENT_ADDRESS=19, IKEv2_P_CSCF_IP4_ADDRESS=20, IKEv2_P_CSCF_IP6_ADDRESS=21, IKEv2_FTT_KAT=22, IKEv2_EXTERNAL_SOURCE_IP4_NAT_INFO=23, IKEv2_TIMEOUT_PERIOD_FOR_LIVENESS_CHECK=24, IKEv2_INTERNAL_DNS_DOMAIN=25, IKEv2_INTERNAL_DNSSEC_TA=26 } ikev2_internal_address; enum ikev2_cp_attribute_type { IKEv2_CP_ATTR_RESERVED=0, IKEv2_INTERNAL_IP4_ADDRESS=1, IKEv2_INTERNAL_IP4_NETMASK=2, IKEv2_INTERNAL_IP4_DNS=3, IKEv2_INTERNAL_IP4_NBNS=4, IKEv2_RESERVED_5=5, IKEv2_INTERNAL_IP4_DHCP=6, IKEv2_APPLICATION_VERSION=7, IKEv2_INTERNAL_IP6_ADDRESS=8, IKEv2_RESERVED_9=9, IKEv2_INTERNAL_IP6_DNS=10, IKEv2_RESERVED_11=11, IKEv2_INTERNAL_IP6_DHCP=12, IKEv2_INTERNAL_IP4_SUBNET=13, IKEv2_SUPPORTED_ATTRIBUTES=14, IKEv2_INTERNAL_IP6_SUBNET=15, IKEv2_MIP6_HOME_PREFIX=16, IKEv2_INTERNAL_IP6_LINK=17, IKEv2_INTERNAL_IP6_PREFIX=18, IKEv2_HOME_AGENT_ADDRESS=19, IKEv2_P_CSCF_IP4_ADDRESS=20, IKEv2_P_CSCF_IP6_ADDRESS=21, IKEv2_FTT_KAT=22, IKEv2_EXTERNAL_SOURCE_IP4_NAT_INFO=23, IKEv2_TIMEOUT_PERIOD_FOR_LIVENESS_CHECK=24, IKEv2_INTERNAL_DNS_DOMAIN=25, IKEv2_INTERNAL_DNSSEC_TA=26 } ikev2_internal_dns; enum ike_id_type { ID_FROMCERT=-1, ID_NONE=0, ID_IPV4_ADDR=1, ID_FQDN=2, ID_USER_FQDN=3, ID_RFC822_ADDR=expr, ID_IPV4_ADDR_SUBNET=4, ID_IPV6_ADDR=5, ID_IPV6_ADDR_SUBNET=6, ID_IPV4_ADDR_RANGE=7, ID_IPV6_ADDR_RANGE=8, ID_DER_ASN1_DN=9, ID_DER_ASN1_GN=10, ID_KEY_ID=11, ID_FC_NAME=12, ID_NULL=13 } id_ip_addr; enum ike_id_type { ID_FROMCERT=-1, ID_NONE=0, ID_IPV4_ADDR=1, ID_FQDN=2, ID_USER_FQDN=3, ID_RFC822_ADDR=expr, ID_IPV4_ADDR_SUBNET=4, ID_IPV6_ADDR=5, ID_IPV6_ADDR_SUBNET=6, ID_IPV4_ADDR_RANGE=7, ID_IPV6_ADDR_RANGE=8, ID_DER_ASN1_DN=9, ID_DER_ASN1_GN=10, ID_KEY_ID=11, ID_FC_NAME=12, ID_NULL=13 } id_ip_addr_subnet; enum ike_id_type { ID_FROMCERT=-1, ID_NONE=0, ID_IPV4_ADDR=1, ID_FQDN=2, ID_USER_FQDN=3, ID_RFC822_ADDR=expr, ID_IPV4_ADDR_SUBNET=4, ID_IPV6_ADDR=5, ID_IPV6_ADDR_SUBNET=6, ID_IPV4_ADDR_RANGE=7, ID_IPV6_ADDR_RANGE=8, ID_DER_ASN1_DN=9, ID_DER_ASN1_GN=10, ID_KEY_ID=11, ID_FC_NAME=12, ID_NULL=13 } id_ip_addr_range; } *

user_defined_types: struct ip_cidr { _Bool is_set; enum ip_version version; struct ip_bytes bytes; unsigned int prefix_len; }

user_defined_types: struct ip_info { enum ip_version ip_version; enum ip_index ip_index; char *ip_name; unsigned long ip_size; unsigned int mask_cnt; struct { struct ip_address unspec; struct ip_address loopback; unsigned long (*jam)(struct jambuf *buf, struct ip_info *info, struct ip_bytes *bytes); unsigned long (*jam_wrapped)(struct jambuf *buf, struct ip_info *info, struct ip_bytes *bytes); } address; struct { unsigned long (*jam)(struct jambuf *buf, struct ip_info *info, struct ip_bytes *bytes, unsigned int hport); } endpoint; struct { struct ip_subnet zero; struct ip_subnet all; } subnet; struct { struct ip_range zero; struct ip_range all; } range; struct { struct ip_selector zero; struct ip_selector all; } selector; unsigned int ikev1_max_fragment_size; unsigned int ikev2_max_fragment_size; struct { int domain; char *domain_name; } socket; int af; char *af_name; unsigned long sockaddr_size; struct ip_address (*address_from_sockaddr)(struct ip_sockaddr sa); struct ip_port (*port_from_sockaddr)(struct ip_sockaddr sa); enum ikev2_ts_type ikev2_ts_addr_range_type; enum ikev2_cp_attribute_type ikev2_internal_address; enum ikev2_cp_attribute_type ikev2_internal_dns; enum ike_id_type id_ip_addr; enum ike_id_type id_ip_addr_subnet; enum ike_id_type id_ip_addr_range; }

user_defined_types: struct ip_address { _Bool is_set; enum ip_version version; struct ip_bytes bytes; }

user_defined_types: struct ip_subnet { _Bool is_set; enum ip_version version; struct ip_bytes bytes; unsigned int maskbits; }

user_defined_types: struct ip_range { _Bool is_set; _Bool is_subnet; enum ip_version version; struct ip_bytes start; struct ip_bytes end; }

user_defined_types: struct ip_selector { _Bool is_set; enum ip_version version; struct ip_bytes bytes; unsigned int maskbits; unsigned int ipproto; int hport; }

user_defined_types: struct ip_sockaddr { unsigned int len; union { struct sockaddr sa; struct sockaddr_in sin; struct sockaddr_in6 sin6; } sa; }

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr sin6_addr; unsigned int sin6_scope_id; }


decompiled_code:
__int64 __fastcall cidr_type(const __m128i *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 result; // rax

if ( a1 )
result = cidr_info((__int64)a1, a2, a3, a4, a5, a6, _mm_loadu_si128(a1).m128i_i64[0]);
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(const __m128i *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 result; // rax

if ( a1 )
result = func0((__int64)a1, a2, a3, a4, a5, a6, _mm_loadu_si128(a1).m128i_i64[0]);
else
result = 0LL;
return result;
}

original_code:
const struct ip_info *cidr_type(const ip_cidr *cidr)
{
 if (cidr == ((void *)0)) {
  return ((void *)0);
 }
 return cidr_info(*cidr);
}

canonical_original_code:
struct ip_info *cidr_type(struct ip_cidr *cidr)
{
 if (cidr == ((void *)0)) {
  return ((void *)0);
 }
 return cidr_info(*cidr);
}

variable_types: struct ip_cidr { _Bool is_set; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes bytes; unsigned int prefix_len; } *

user_defined_types: enum ip_index { IPv4_INDEX=0, IPv6_INDEX=1 }

user_defined_types: enum ikev2_ts_type { IKEv2_TS_IPV4_ADDR_RANGE=7, IKEv2_TS_IPV6_ADDR_RANGE=8, IKEv2_TS_FC_ADDR_RANGE=9, IKEv2_TS_SECLABEL=10 }

user_defined_types: enum ikev2_cp_attribute_type { IKEv2_CP_ATTR_RESERVED=0, IKEv2_INTERNAL_IP4_ADDRESS=1, IKEv2_INTERNAL_IP4_NETMASK=2, IKEv2_INTERNAL_IP4_DNS=3, IKEv2_INTERNAL_IP4_NBNS=4, IKEv2_RESERVED_5=5, IKEv2_INTERNAL_IP4_DHCP=6, IKEv2_APPLICATION_VERSION=7, IKEv2_INTERNAL_IP6_ADDRESS=8, IKEv2_RESERVED_9=9, IKEv2_INTERNAL_IP6_DNS=10, IKEv2_RESERVED_11=11, IKEv2_INTERNAL_IP6_DHCP=12, IKEv2_INTERNAL_IP4_SUBNET=13, IKEv2_SUPPORTED_ATTRIBUTES=14, IKEv2_INTERNAL_IP6_SUBNET=15, IKEv2_MIP6_HOME_PREFIX=16, IKEv2_INTERNAL_IP6_LINK=17, IKEv2_INTERNAL_IP6_PREFIX=18, IKEv2_HOME_AGENT_ADDRESS=19, IKEv2_P_CSCF_IP4_ADDRESS=20, IKEv2_P_CSCF_IP6_ADDRESS=21, IKEv2_FTT_KAT=22, IKEv2_EXTERNAL_SOURCE_IP4_NAT_INFO=23, IKEv2_TIMEOUT_PERIOD_FOR_LIVENESS_CHECK=24, IKEv2_INTERNAL_DNS_DOMAIN=25, IKEv2_INTERNAL_DNSSEC_TA=26 }

user_defined_types: enum ike_id_type { ID_FROMCERT=-1, ID_NONE=0, ID_IPV4_ADDR=1, ID_FQDN=2, ID_USER_FQDN=3, ID_RFC822_ADDR=expr, ID_IPV4_ADDR_SUBNET=4, ID_IPV6_ADDR=5, ID_IPV6_ADDR_SUBNET=6, ID_IPV4_ADDR_RANGE=7, ID_IPV6_ADDR_RANGE=8, ID_DER_ASN1_DN=9, ID_DER_ASN1_GN=10, ID_KEY_ID=11, ID_FC_NAME=12, ID_NULL=13 }

user_defined_types: struct ip_bytes { unsigned char byte[16]; }

user_defined_types: struct jambuf { char *array; unsigned long total; unsigned long roof; char *dots; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }

user_defined_types: struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; }


decompiled_code:
__int64 __fastcall cidr_prefix_len(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, unsigned int a10)
{
return a10;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, unsigned int a10)
{
return a10;
}

original_code:
unsigned cidr_prefix_len(const ip_cidr cidr)
{
 return cidr.prefix_len;
}

canonical_original_code:
unsigned int cidr_prefix_len(struct ip_cidr cidr)
{
 return cidr.prefix_len;
}

variable_types: struct ip_cidr { _Bool is_set; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes { unsigned char byte[16]; } bytes; unsigned int prefix_len; }

return_type: unsigned int

user_defined_types: struct ip_cidr { _Bool is_set; enum ip_version version; struct ip_bytes bytes; unsigned int prefix_len; }


original_code:
_Bool cidr_is_specified(const ip_cidr cidr)
{
 return cidr_check(cidr) == ((void *)0);
}

canonical_original_code:
_Bool cidr_is_specified(struct ip_cidr cidr)
{
 return cidr_check(cidr) == ((void *)0);
}


original_code:
size_t jam_cidr(struct jambuf *buf, const ip_cidr *cidr)
{
 if (cidr == ((void *)0)) {
  return jam_string(buf, "<null-cidr>");
 }
 if (!cidr->is_set) {
  return jam_string(buf, "<unset-cidr>");
 }
 size_t s = 0;
 ip_address sa = cidr_address(*cidr);
 s += jam_address(buf, &sa);
 s += jam(buf, "/%u", cidr->prefix_len);
 return s;
}

canonical_original_code:
unsigned long jam_cidr(struct jambuf *buf, struct ip_cidr *cidr)
{
 if (cidr == ((void *)0)) {
  return jam_string(buf, "<null-cidr>");
 }
 if (!cidr->is_set) {
  return jam_string(buf, "<unset-cidr>");
 }
 unsigned long s = 0;
 struct ip_address sa = cidr_address(*cidr);
 s += jam_address(buf, &sa);
 s += jam(buf, "/%u", cidr->prefix_len);
 return s;
}

variable_types: struct jambuf { char *array; unsigned long total; unsigned long roof; char *dots; } *

variable_types: struct ip_cidr { _Bool is_set; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes { unsigned char byte[16]; } bytes; unsigned int prefix_len; } *

variable_types:
s
unsigned long

variable_types: struct ip_address { _Bool is_set; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes { unsigned char byte[16]; } bytes; }

return_type: unsigned long


decompiled_code:
__int64 __fastcall str_cidr(const __m128i *a1, __int64 a2)
{
__int64 v2; // rdx
__int64 v3; // rcx
__int64 v4; // r8
__int64 v5; // r9
_QWORD v7[9]; // [rsp+0h] [rbp-48h] BYREF

v7[5] = __readfsqword(0x28u);
array_as_jambuf(v7, a2, 47LL);
jam_cidr((__int64)v7, a1, v2, v3, v4, v5);
return a2;
}

original_code:
const char *str_cidr(const ip_cidr *cidr, cidr_buf *out)
{
 struct jambuf buf = array_as_jambuf((out->buf), sizeof(out->buf));
 jam_cidr(&buf, cidr);
 return out->buf;
}

canonical_original_code:
char *str_cidr(struct ip_cidr *cidr, struct cidr_buf *out)
{
 struct jambuf buf = array_as_jambuf((out->buf), sizeof(out->buf));
 jam_cidr(&buf, cidr);
 return out->buf;
}

variable_types:
out
struct cidr_buf { char buf[-1]; } *

variable_types: struct jambuf { char *array; unsigned long total; unsigned long roof; char *dots; }

return_type: char *


original_code:
void pexpect_cidr(const ip_cidr cidr, where_t where)
{
 if (cidr.is_set == 0 ||
     cidr.version == 0) {
  llog_pexpect(&global_logger, where, "invalid ""<cidr-%s:IPv%d[""%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x""]/%u>", ((cidr).is_set ? "set" : "unset"), (cidr).version, ((cidr).bytes).byte[0], ((cidr).bytes).byte[1], ((cidr).bytes).byte[2], ((cidr).bytes).byte[3], ((cidr).bytes).byte[4], ((cidr).bytes).byte[5], ((cidr).bytes).byte[6], ((cidr).bytes).byte[7], ((cidr).bytes).byte[8], ((cidr).bytes).byte[9], ((cidr).bytes).byte[10], ((cidr).bytes).byte[11], ((cidr).bytes).byte[12], ((cidr).bytes).byte[13], ((cidr).bytes).byte[14], ((cidr).bytes).byte[15], (cidr).prefix_len);
 }
}

canonical_original_code:
void pexpect_cidr(struct ip_cidr cidr, struct where *where)
{
 if (cidr.is_set == 0 ||
     cidr.version == 0) {
  llog_pexpect(&global_logger, where, "invalid ""<cidr-%s:IPv%d[""%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x""]/%u>", ((cidr).is_set ? "set" : "unset"), (cidr).version, ((cidr).bytes).byte[0], ((cidr).bytes).byte[1], ((cidr).bytes).byte[2], ((cidr).bytes).byte[3], ((cidr).bytes).byte[4], ((cidr).bytes).byte[5], ((cidr).bytes).byte[6], ((cidr).bytes).byte[7], ((cidr).bytes).byte[8], ((cidr).bytes).byte[9], ((cidr).bytes).byte[10], ((cidr).bytes).byte[11], ((cidr).bytes).byte[12], ((cidr).bytes).byte[13], ((cidr).bytes).byte[14], ((cidr).bytes).byte[15], (cidr).prefix_len);
 }
}

variable_types: struct where { char *func; char *file; long line; } *


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

v3 = __readfsqword(0x28u);
if ( (unsigned int)PK11_GenerateRandom() )
passert_nss_error(&global_logger, here_1, "generating %zu random bytes", a2);
return v3 - __readfsqword(0x28u);
}

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

v3 = __readfsqword(0x28u);
if ( (unsigned int)PK11_GenerateRandom() )
passert_nss_error(&global_logger, here_1, "generating %zu random bytes", a2);
return v3 - __readfsqword(0x28u);
}

original_code:
void get_rnd_bytes(void *buffer, size_t length)
{
 if (PK11_GenerateRandom(buffer, length) != SECSuccess) {
  passert_nss_error(&global_logger, ({ static const struct where here = { .func = __func__, .file = "lib/libswan/rnd.c", .line = 68, }; &here; }), "generating %zu random bytes", length);
 }
}

canonical_original_code:
void get_rnd_bytes(void *buffer, unsigned long length)
{
 if (PK11_GenerateRandom(buffer, length) != SECSuccess) {
  passert_nss_error(&global_logger, ({ static struct where here = { .func = __func__, .file = "lib/libswan/rnd.c", .line = 68, }; &here; }), "generating %zu random bytes", length);
 }
}

variable_types:
buffer
void *

variable_types:
length
unsigned long

variable_types: struct where { char *func; char *file; long line; }


decompiled_code:
__int64 __fastcall get_rnd_uintmax(unsigned __int64 a1)
{
__int64 v2[3]; // [rsp+0h] [rbp-18h] BYREF

v2[1] = __readfsqword(0x28u);
get_rnd_bytes((__int64)v2, 8LL);
return v2[0] % a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int64 a1)
{
__int64 v2[3]; // [rsp+0h] [rbp-18h] BYREF

v2[1] = __readfsqword(0x28u);
func0((__int64)v2, 8LL);
return v2[0] % a1;
}

original_code:
uintmax_t get_rnd_uintmax(uintmax_t roof)
{
 uintmax_t rnd;
 get_rnd_bytes(&rnd, sizeof(rnd));
 return rnd % roof;
}

canonical_original_code:
unsigned long get_rnd_uintmax(unsigned long roof)
{
 unsigned long rnd;
 get_rnd_bytes(&rnd, sizeof(rnd));
 return rnd % roof;
}

variable_types:
roof
unsigned long

variable_types:
rnd
unsigned long


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

v3 = __readfsqword(0x28u);
get_rnd_bytes(a1, a2);
return v3 - __readfsqword(0x28u);
}

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

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

original_code:
void fill_rnd_chunk(chunk_t chunk)
{
 get_rnd_bytes(chunk.ptr, chunk.len);
}

canonical_original_code:
void fill_rnd_chunk(struct chunk_t chunk)
{
 get_rnd_bytes(chunk.ptr, chunk.len);
}

variable_types: struct chunk_t { unsigned char *ptr; unsigned long len; }


decompiled_code:
__int64 alloc_rnd_chunk()
{
__int64 v0; // rbp
__int64 v1; // rdx

v0 = alloc_chunk();
fill_rnd_chunk(v0, v1);
return v0;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbp
__int64 v1; // rdx

v0 = alloc_chunk();
func2(v0, v1);
return v0;
}

original_code:
chunk_t alloc_rnd_chunk(size_t size, const char *name)
{
 chunk_t chunk = alloc_chunk(size, name);
 fill_rnd_chunk(chunk);
 return chunk;
}

canonical_original_code:
struct chunk_t alloc_rnd_chunk(unsigned long size, char *name)
{
 struct chunk_t chunk = alloc_chunk(size, name);
 fill_rnd_chunk(chunk);
 return chunk;
}

variable_types:
size
unsigned long

variable_types:
name
char *

return_type: struct chunk_t { unsigned char *ptr; unsigned long len; }


decompiled_code:
__int64 __fastcall str_nss_oid(unsigned int a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // r12

v2 = SECOID_FindOIDByTag();
if ( v2 )
return *(_QWORD *)(v2 + 32);
v3 = a2;
_snprintf_chk(a2, 23LL, 1LL, -1LL, "SEC_OID_%d", a1);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // r12

v2 = SECOID_FindOIDByTag();
if ( v2 )
return *(_QWORD *)(v2 + 32);
v3 = a2;
_snprintf_chk(a2, 23LL, 1LL, -1LL, "SEC_OID_%d", a1);
return v3;
}

original_code:
const char *str_nss_oid(SECOidTag oidtag, enum_buf *buf)
{
 SECOidData *data = SECOID_FindOIDByTag(oidtag);
 if (data != ((void *)0)) {
  return data->desc;
 } else {
  snprintf(buf->buf, sizeof(buf->buf),
    "SEC_OID_%d", oidtag);
  return buf->buf;
 }
}

canonical_original_code:
char *str_nss_oid(enum SECOidTag oidtag, struct enum_buf *buf)
{
 struct SECOidDataStr *data = SECOID_FindOIDByTag(oidtag);
 if (data != ((void *)0)) {
  return data->desc;
 } else {
  snprintf(buf->buf, sizeof(buf->buf),
    "SEC_OID_%d", oidtag);
  return buf->buf;
 }
}

variable_types:
buf
struct enum_buf { char buf[-1]; } *

variable_types: struct SECOidDataStr { struct SECItemStr { enum SECItemType { siBuffer=0, siClearDataBuffer=1, siCipherDataBuffer=2, siDERCertBuffer=3, siEncodedCertBuffer=4, siDERNameBuffer=5, siEncodedNameBuffer=6, siAsciiNameString=7, siAsciiString=8, siDEROID=9, siUnsignedInteger=10, siUTCTime=11, siGeneralizedTime=12, siVisibleString=13, siUTF8String=14, siBMPString=15 } type; unsigned char *data; unsigned int len; } oid; enum SECOidTag { SEC_OID_UNKNOWN=0, SEC_OID_MD2=1, SEC_OID_MD4=2, SEC_OID_MD5=3, SEC_OID_SHA1=4, SEC_OID_RC2_CBC=5, SEC_OID_RC4=6, SEC_OID_DES_EDE3_CBC=7, SEC_OID_RC5_CBC_PAD=8, SEC_OID_DES_ECB=9, SEC_OID_DES_CBC=10, SEC_OID_DES_OFB=11, SEC_OID_DES_CFB=12, SEC_OID_DES_MAC=13, SEC_OID_DES_EDE=14, SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE=15, SEC_OID_PKCS1_RSA_ENCRYPTION=16, SEC_OID_PKCS1_MD2_WITH_RSA_ENCRYPTION=17, SEC_OID_PKCS1_MD4_WITH_RSA_ENCRYPTION=18, SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION=19, SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION=20, SEC_OID_PKCS5_PBE_WITH_MD2_AND_DES_CBC=21, SEC_OID_PKCS5_PBE_WITH_MD5_AND_DES_CBC=22, SEC_OID_PKCS5_PBE_WITH_SHA1_AND_DES_CBC=23, SEC_OID_PKCS7=24, SEC_OID_PKCS7_DATA=25, SEC_OID_PKCS7_SIGNED_DATA=26, SEC_OID_PKCS7_ENVELOPED_DATA=27, SEC_OID_PKCS7_SIGNED_ENVELOPED_DATA=28, SEC_OID_PKCS7_DIGESTED_DATA=29, SEC_OID_PKCS7_ENCRYPTED_DATA=30, SEC_OID_PKCS9_EMAIL_ADDRESS=31, SEC_OID_PKCS9_UNSTRUCTURED_NAME=32, SEC_OID_PKCS9_CONTENT_TYPE=33, SEC_OID_PKCS9_MESSAGE_DIGEST=34, SEC_OID_PKCS9_SIGNING_TIME=35, SEC_OID_PKCS9_COUNTER_SIGNATURE=36, SEC_OID_PKCS9_CHALLENGE_PASSWORD=37, SEC_OID_PKCS9_UNSTRUCTURED_ADDRESS=38, SEC_OID_PKCS9_EXTENDED_CERTIFICATE_ATTRIBUTES=39, SEC_OID_PKCS9_SMIME_CAPABILITIES=40, SEC_OID_AVA_COMMON_NAME=41, SEC_OID_AVA_COUNTRY_NAME=42, SEC_OID_AVA_LOCALITY=43, SEC_OID_AVA_STATE_OR_PROVINCE=44, SEC_OID_AVA_ORGANIZATION_NAME=45, SEC_OID_AVA_ORGANIZATIONAL_UNIT_NAME=46, SEC_OID_AVA_DN_QUALIFIER=47, SEC_OID_AVA_DC=48, SEC_OID_NS_TYPE_GIF=49, SEC_OID_NS_TYPE_JPEG=50, SEC_OID_NS_TYPE_URL=51, SEC_OID_NS_TYPE_HTML=52, SEC_OID_NS_TYPE_CERT_SEQUENCE=53, SEC_OID_MISSI_KEA_DSS_OLD=54, SEC_OID_MISSI_DSS_OLD=55, SEC_OID_MISSI_KEA_DSS=56, SEC_OID_MISSI_DSS=57, SEC_OID_MISSI_KEA=58, SEC_OID_MISSI_ALT_KEA=59, SEC_OID_NS_CERT_EXT_NETSCAPE_OK=60, SEC_OID_NS_CERT_EXT_ISSUER_LOGO=61, SEC_OID_NS_CERT_EXT_SUBJECT_LOGO=62, SEC_OID_NS_CERT_EXT_CERT_TYPE=63, SEC_OID_NS_CERT_EXT_BASE_URL=64, SEC_OID_NS_CERT_EXT_REVOCATION_URL=65, SEC_OID_NS_CERT_EXT_CA_REVOCATION_URL=66, SEC_OID_NS_CERT_EXT_CA_CRL_URL=67, SEC_OID_NS_CERT_EXT_CA_CERT_URL=68, SEC_OID_NS_CERT_EXT_CERT_RENEWAL_URL=69, SEC_OID_NS_CERT_EXT_CA_POLICY_URL=70, SEC_OID_NS_CERT_EXT_HOMEPAGE_URL=71, SEC_OID_NS_CERT_EXT_ENTITY_LOGO=72, SEC_OID_NS_CERT_EXT_USER_PICTURE=73, SEC_OID_NS_CERT_EXT_SSL_SERVER_NAME=74, SEC_OID_NS_CERT_EXT_COMMENT=75, SEC_OID_NS_CERT_EXT_LOST_PASSWORD_URL=76, SEC_OID_NS_CERT_EXT_CERT_RENEWAL_TIME=77, SEC_OID_NS_KEY_USAGE_GOVT_APPROVED=78, SEC_OID_X509_SUBJECT_DIRECTORY_ATTR=79, SEC_OID_X509_SUBJECT_KEY_ID=80, SEC_OID_X509_KEY_USAGE=81, SEC_OID_X509_PRIVATE_KEY_USAGE_PERIOD=82, SEC_OID_X509_SUBJECT_ALT_NAME=83, SEC_OID_X509_ISSUER_ALT_NAME=84, SEC_OID_X509_BASIC_CONSTRAINTS=85, SEC_OID_X509_NAME_CONSTRAINTS=86, SEC_OID_X509_CRL_DIST_POINTS=87, SEC_OID_X509_CERTIFICATE_POLICIES=88, SEC_OID_X509_POLICY_MAPPINGS=89, SEC_OID_X509_POLICY_CONSTRAINTS=90, SEC_OID_X509_AUTH_KEY_ID=91, SEC_OID_X509_EXT_KEY_USAGE=92, SEC_OID_X509_AUTH_INFO_ACCESS=93, SEC_OID_X509_CRL_NUMBER=94, SEC_OID_X509_REASON_CODE=95, SEC_OID_X509_INVALID_DATE=96, SEC_OID_X500_RSA_ENCRYPTION=97, SEC_OID_RFC1274_UID=98, SEC_OID_RFC1274_MAIL=99, SEC_OID_PKCS12=100, SEC_OID_PKCS12_MODE_IDS=101, SEC_OID_PKCS12_ESPVK_IDS=102, SEC_OID_PKCS12_BAG_IDS=103, SEC_OID_PKCS12_CERT_BAG_IDS=104, SEC_OID_PKCS12_OIDS=105, SEC_OID_PKCS12_PBE_IDS=106, SEC_OID_PKCS12_SIGNATURE_IDS=107, SEC_OID_PKCS12_ENVELOPING_IDS=108, SEC_OID_PKCS12_PKCS8_KEY_SHROUDING=109, SEC_OID_PKCS12_KEY_BAG_ID=110, SEC_OID_PKCS12_CERT_AND_CRL_BAG_ID=111, SEC_OID_PKCS12_SECRET_BAG_ID=112, SEC_OID_PKCS12_X509_CERT_CRL_BAG=113, SEC_OID_PKCS12_SDSI_CERT_BAG=114, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC4=115, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC4=116, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_TRIPLE_DES_CBC=117, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC=118, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC=119, SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_128_BIT_RC4=120, SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_40_BIT_RC4=121, SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_TRIPLE_DES=122, SEC_OID_PKCS12_RSA_SIGNATURE_WITH_SHA1_DIGEST=123, SEC_OID_ANSIX9_DSA_SIGNATURE=124, SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST=125, SEC_OID_BOGUS_DSA_SIGNATURE_WITH_SHA1_DIGEST=126, SEC_OID_VERISIGN_USER_NOTICES=127, SEC_OID_PKIX_CPS_POINTER_QUALIFIER=128, SEC_OID_PKIX_USER_NOTICE_QUALIFIER=129, SEC_OID_PKIX_OCSP=130, SEC_OID_PKIX_OCSP_BASIC_RESPONSE=131, SEC_OID_PKIX_OCSP_NONCE=132, SEC_OID_PKIX_OCSP_CRL=133, SEC_OID_PKIX_OCSP_RESPONSE=134, SEC_OID_PKIX_OCSP_NO_CHECK=135, SEC_OID_PKIX_OCSP_ARCHIVE_CUTOFF=136, SEC_OID_PKIX_OCSP_SERVICE_LOCATOR=137, SEC_OID_PKIX_REGCTRL_REGTOKEN=138, SEC_OID_PKIX_REGCTRL_AUTHENTICATOR=139, SEC_OID_PKIX_REGCTRL_PKIPUBINFO=140, SEC_OID_PKIX_REGCTRL_PKI_ARCH_OPTIONS=141, SEC_OID_PKIX_REGCTRL_OLD_CERT_ID=142, SEC_OID_PKIX_REGCTRL_PROTOCOL_ENC_KEY=143, SEC_OID_PKIX_REGINFO_UTF8_PAIRS=144, SEC_OID_PKIX_REGINFO_CERT_REQUEST=145, SEC_OID_EXT_KEY_USAGE_SERVER_AUTH=146, SEC_OID_EXT_KEY_USAGE_CLIENT_AUTH=147, SEC_OID_EXT_KEY_USAGE_CODE_SIGN=148, SEC_OID_EXT_KEY_USAGE_EMAIL_PROTECT=149, SEC_OID_EXT_KEY_USAGE_TIME_STAMP=150, SEC_OID_OCSP_RESPONDER=151, SEC_OID_NETSCAPE_SMIME_KEA=152, SEC_OID_FORTEZZA_SKIPJACK=153, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC4=154, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC4=155, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_3KEY_TRIPLE_DES_CBC=156, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_2KEY_TRIPLE_DES_CBC=157, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC=158, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC=159, SEC_OID_PKCS12_SAFE_CONTENTS_ID=160, SEC_OID_PKCS12_PKCS8_SHROUDED_KEY_BAG_ID=161, SEC_OID_PKCS12_V1_KEY_BAG_ID=162, SEC_OID_PKCS12_V1_PKCS8_SHROUDED_KEY_BAG_ID=163, SEC_OID_PKCS12_V1_CERT_BAG_ID=164, SEC_OID_PKCS12_V1_CRL_BAG_ID=165, SEC_OID_PKCS12_V1_SECRET_BAG_ID=166, SEC_OID_PKCS12_V1_SAFE_CONTENTS_BAG_ID=167, SEC_OID_PKCS9_X509_CERT=168, SEC_OID_PKCS9_SDSI_CERT=169, SEC_OID_PKCS9_X509_CRL=170, SEC_OID_PKCS9_FRIENDLY_NAME=171, SEC_OID_PKCS9_LOCAL_KEY_ID=172, SEC_OID_BOGUS_KEY_USAGE=173, SEC_OID_X942_DIFFIE_HELMAN_KEY=174, SEC_OID_NETSCAPE_NICKNAME=175, SEC_OID_NETSCAPE_RECOVERY_REQUEST=176, SEC_OID_CERT_RENEWAL_LOCATOR=177, SEC_OID_NS_CERT_EXT_SCOPE_OF_USE=178, SEC_OID_CMS_EPHEMERAL_STATIC_DIFFIE_HELLMAN=179, SEC_OID_CMS_3DES_KEY_WRAP=180, SEC_OID_CMS_RC2_KEY_WRAP=181, SEC_OID_SMIME_ENCRYPTION_KEY_PREFERENCE=182, SEC_OID_AES_128_ECB=183, SEC_OID_AES_128_CBC=184, SEC_OID_AES_192_ECB=185, SEC_OID_AES_192_CBC=186, SEC_OID_AES_256_ECB=187, SEC_OID_AES_256_CBC=188, SEC_OID_SDN702_DSA_SIGNATURE=189, SEC_OID_MS_SMIME_ENCRYPTION_KEY_PREFERENCE=190, SEC_OID_SHA256=191, SEC_OID_SHA384=192, SEC_OID_SHA512=193, SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION=194, SEC_OID_PKCS1_SHA384_WITH_RSA_ENCRYPTION=195, SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION=196, SEC_OID_AES_128_KEY_WRAP=197, SEC_OID_AES_192_KEY_WRAP=198, SEC_OID_AES_256_KEY_WRAP=199, SEC_OID_ANSIX962_EC_PUBLIC_KEY=200, SEC_OID_ANSIX962_ECDSA_SHA1_SIGNATURE=201, SEC_OID_ANSIX962_EC_PRIME192V1=202, SEC_OID_ANSIX962_EC_PRIME192V2=203, SEC_OID_ANSIX962_EC_PRIME192V3=204, SEC_OID_ANSIX962_EC_PRIME239V1=205, SEC_OID_ANSIX962_EC_PRIME239V2=206, SEC_OID_ANSIX962_EC_PRIME239V3=207, SEC_OID_ANSIX962_EC_PRIME256V1=208, SEC_OID_SECG_EC_SECP112R1=209, SEC_OID_SECG_EC_SECP112R2=210, SEC_OID_SECG_EC_SECP128R1=211, SEC_OID_SECG_EC_SECP128R2=212, SEC_OID_SECG_EC_SECP160K1=213, SEC_OID_SECG_EC_SECP160R1=214, SEC_OID_SECG_EC_SECP160R2=215, SEC_OID_SECG_EC_SECP192K1=216, SEC_OID_SECG_EC_SECP224K1=217, SEC_OID_SECG_EC_SECP224R1=218, SEC_OID_SECG_EC_SECP256K1=219, SEC_OID_SECG_EC_SECP384R1=220, SEC_OID_SECG_EC_SECP521R1=221, SEC_OID_ANSIX962_EC_C2PNB163V1=222, SEC_OID_ANSIX962_EC_C2PNB163V2=223, SEC_OID_ANSIX962_EC_C2PNB163V3=224, SEC_OID_ANSIX962_EC_C2PNB176V1=225, SEC_OID_ANSIX962_EC_C2TNB191V1=226, SEC_OID_ANSIX962_EC_C2TNB191V2=227, SEC_OID_ANSIX962_EC_C2TNB191V3=228, SEC_OID_ANSIX962_EC_C2ONB191V4=229, SEC_OID_ANSIX962_EC_C2ONB191V5=230, SEC_OID_ANSIX962_EC_C2PNB208W1=231, SEC_OID_ANSIX962_EC_C2TNB239V1=232, SEC_OID_ANSIX962_EC_C2TNB239V2=233, SEC_OID_ANSIX962_EC_C2TNB239V3=234, SEC_OID_ANSIX962_EC_C2ONB239V4=235, SEC_OID_ANSIX962_EC_C2ONB239V5=236, SEC_OID_ANSIX962_EC_C2PNB272W1=237, SEC_OID_ANSIX962_EC_C2PNB304W1=238, SEC_OID_ANSIX962_EC_C2TNB359V1=239, SEC_OID_ANSIX962_EC_C2PNB368W1=240, SEC_OID_ANSIX962_EC_C2TNB431R1=241, SEC_OID_SECG_EC_SECT113R1=242, SEC_OID_SECG_EC_SECT113R2=243, SEC_OID_SECG_EC_SECT131R1=244, SEC_OID_SECG_EC_SECT131R2=245, SEC_OID_SECG_EC_SECT163K1=246, SEC_OID_SECG_EC_SECT163R1=247, SEC_OID_SECG_EC_SECT163R2=248, SEC_OID_SECG_EC_SECT193R1=249, SEC_OID_SECG_EC_SECT193R2=250, SEC_OID_SECG_EC_SECT233K1=251, SEC_OID_SECG_EC_SECT233R1=252, SEC_OID_SECG_EC_SECT239K1=253, SEC_OID_SECG_EC_SECT283K1=254, SEC_OID_SECG_EC_SECT283R1=255, SEC_OID_SECG_EC_SECT409K1=256, SEC_OID_SECG_EC_SECT409R1=257, SEC_OID_SECG_EC_SECT571K1=258, SEC_OID_SECG_EC_SECT571R1=259, SEC_OID_NETSCAPE_AOLSCREENNAME=260, SEC_OID_AVA_SURNAME=261, SEC_OID_AVA_SERIAL_NUMBER=262, SEC_OID_AVA_STREET_ADDRESS=263, SEC_OID_AVA_TITLE=264, SEC_OID_AVA_POSTAL_ADDRESS=265, SEC_OID_AVA_POSTAL_CODE=266, SEC_OID_AVA_POST_OFFICE_BOX=267, SEC_OID_AVA_GIVEN_NAME=268, SEC_OID_AVA_INITIALS=269, SEC_OID_AVA_GENERATION_QUALIFIER=270, SEC_OID_AVA_HOUSE_IDENTIFIER=271, SEC_OID_AVA_PSEUDONYM=272, SEC_OID_PKIX_CA_ISSUERS=273, SEC_OID_PKCS9_EXTENSION_REQUEST=274, SEC_OID_ANSIX962_ECDSA_SIGNATURE_RECOMMENDED_DIGEST=275, SEC_OID_ANSIX962_ECDSA_SIGNATURE_SPECIFIED_DIGEST=276, SEC_OID_ANSIX962_ECDSA_SHA224_SIGNATURE=277, SEC_OID_ANSIX962_ECDSA_SHA256_SIGNATURE=278, SEC_OID_ANSIX962_ECDSA_SHA384_SIGNATURE=279, SEC_OID_ANSIX962_ECDSA_SHA512_SIGNATURE=280, SEC_OID_X509_HOLD_INSTRUCTION_CODE=281, SEC_OID_X509_DELTA_CRL_INDICATOR=282, SEC_OID_X509_ISSUING_DISTRIBUTION_POINT=283, SEC_OID_X509_CERT_ISSUER=284, SEC_OID_X509_FRESHEST_CRL=285, SEC_OID_X509_INHIBIT_ANY_POLICY=286, SEC_OID_X509_SUBJECT_INFO_ACCESS=287, SEC_OID_CAMELLIA_128_CBC=288, SEC_OID_CAMELLIA_192_CBC=289, SEC_OID_CAMELLIA_256_CBC=290, SEC_OID_PKCS5_PBKDF2=291, SEC_OID_PKCS5_PBES2=292, SEC_OID_PKCS5_PBMAC1=293, SEC_OID_HMAC_SHA1=294, SEC_OID_HMAC_SHA224=295, SEC_OID_HMAC_SHA256=296, SEC_OID_HMAC_SHA384=297, SEC_OID_HMAC_SHA512=298, SEC_OID_PKIX_TIMESTAMPING=299, SEC_OID_PKIX_CA_REPOSITORY=300, SEC_OID_ISO_SHA1_WITH_RSA_SIGNATURE=301, SEC_OID_SEED_CBC=302, SEC_OID_X509_ANY_POLICY=303, SEC_OID_PKCS1_RSA_OAEP_ENCRYPTION=304, SEC_OID_PKCS1_MGF1=305, SEC_OID_PKCS1_PSPECIFIED=306, SEC_OID_PKCS1_RSA_PSS_SIGNATURE=307, SEC_OID_PKCS1_SHA224_WITH_RSA_ENCRYPTION=308, SEC_OID_SHA224=309, SEC_OID_EV_INCORPORATION_LOCALITY=310, SEC_OID_EV_INCORPORATION_STATE=311, SEC_OID_EV_INCORPORATION_COUNTRY=312, SEC_OID_BUSINESS_CATEGORY=313, SEC_OID_NIST_DSA_SIGNATURE_WITH_SHA224_DIGEST=314, SEC_OID_NIST_DSA_SIGNATURE_WITH_SHA256_DIGEST=315, SEC_OID_MS_EXT_KEY_USAGE_CTL_SIGNING=316, SEC_OID_AVA_NAME=317, SEC_OID_AES_128_GCM=318, SEC_OID_AES_192_GCM=319, SEC_OID_AES_256_GCM=320, SEC_OID_IDEA_CBC=321, SEC_OID_RC2_40_CBC=322, SEC_OID_DES_40_CBC=323, SEC_OID_RC4_40=324, SEC_OID_RC4_56=325, SEC_OID_NULL_CIPHER=326, SEC_OID_HMAC_MD5=327, SEC_OID_TLS_RSA=328, SEC_OID_TLS_DHE_RSA=329, SEC_OID_TLS_DHE_DSS=330, SEC_OID_TLS_DH_RSA=331, SEC_OID_TLS_DH_DSS=332, SEC_OID_TLS_DH_ANON=333, SEC_OID_TLS_ECDHE_ECDSA=334, SEC_OID_TLS_ECDHE_RSA=335, SEC_OID_TLS_ECDH_ECDSA=336, SEC_OID_TLS_ECDH_RSA=337, SEC_OID_TLS_ECDH_ANON=338, SEC_OID_TLS_RSA_EXPORT=339, SEC_OID_TLS_DHE_RSA_EXPORT=340, SEC_OID_TLS_DHE_DSS_EXPORT=341, SEC_OID_TLS_DH_RSA_EXPORT=342, SEC_OID_TLS_DH_DSS_EXPORT=343, SEC_OID_TLS_DH_ANON_EXPORT=344, SEC_OID_APPLY_SSL_POLICY=345, SEC_OID_CHACHA20_POLY1305=346, SEC_OID_TLS_ECDHE_PSK=347, SEC_OID_TLS_DHE_PSK=348, SEC_OID_TLS_FFDHE_2048=349, SEC_OID_TLS_FFDHE_3072=350, SEC_OID_TLS_FFDHE_4096=351, SEC_OID_TLS_FFDHE_6144=352, SEC_OID_TLS_FFDHE_8192=353, SEC_OID_TLS_DHE_CUSTOM=354, SEC_OID_CURVE25519=355, SEC_OID_TLS13_KEA_ANY=356, SEC_OID_X509_ANY_EXT_KEY_USAGE=357, SEC_OID_EXT_KEY_USAGE_IPSEC_IKE=358, SEC_OID_IPSEC_IKE_END=359, SEC_OID_IPSEC_IKE_INTERMEDIATE=360, SEC_OID_TOTAL=361 } offset; char *desc; unsigned long mechanism; enum SECSupportExtenTag { INVALID_CERT_EXTENSION=0, UNSUPPORTED_CERT_EXTENSION=1, SUPPORTED_CERT_EXTENSION=2 } supportedExtension; } *

user_defined_types: struct SECOidDataStr { struct SECItemStr oid; enum SECOidTag offset; char *desc; unsigned long mechanism; enum SECSupportExtenTag supportedExtension; }

user_defined_types: struct SECItemStr { enum SECItemType type; unsigned char *data; unsigned int len; }


decompiled_code:
__int64 __fastcall jam_nss_oid(__int64 a1, unsigned int a2)
{
__int64 v2; // rax
__int64 result; // rax

v2 = SECOID_FindOIDByTag(a2);
if ( v2 )
result = jam_string(a1, *(_QWORD *)(v2 + 32));
else
result = jam(a1, "SEC_OID_%d", a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int a2)
{
__int64 v2; // rax
__int64 result; // rax

v2 = SECOID_FindOIDByTag(a2);
if ( v2 )
result = jam_string(a1, *(_QWORD *)(v2 + 32));
else
result = jam(a1, "SEC_OID_%d", a2);
return result;
}

original_code:
size_t jam_nss_oid(struct jambuf *buf, SECOidTag oidtag)
{
 SECOidData *data = SECOID_FindOIDByTag(oidtag);
 if (data != ((void *)0)) {
  return jam_string(buf, data->desc);
 }
 return jam(buf, "SEC_OID_%d", oidtag);
}

canonical_original_code:
unsigned long jam_nss_oid(struct jambuf *buf, enum SECOidTag oidtag)
{
 struct SECOidDataStr *data = SECOID_FindOIDByTag(oidtag);
 if (data != ((void *)0)) {
  return jam_string(buf, data->desc);
 }
 return jam(buf, "SEC_OID_%d", oidtag);
}

variable_types: struct jambuf { char *array; unsigned long total; unsigned long roof; char *dots; } *

variable_types: enum SECOidTag { SEC_OID_UNKNOWN=0, SEC_OID_MD2=1, SEC_OID_MD4=2, SEC_OID_MD5=3, SEC_OID_SHA1=4, SEC_OID_RC2_CBC=5, SEC_OID_RC4=6, SEC_OID_DES_EDE3_CBC=7, SEC_OID_RC5_CBC_PAD=8, SEC_OID_DES_ECB=9, SEC_OID_DES_CBC=10, SEC_OID_DES_OFB=11, SEC_OID_DES_CFB=12, SEC_OID_DES_MAC=13, SEC_OID_DES_EDE=14, SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE=15, SEC_OID_PKCS1_RSA_ENCRYPTION=16, SEC_OID_PKCS1_MD2_WITH_RSA_ENCRYPTION=17, SEC_OID_PKCS1_MD4_WITH_RSA_ENCRYPTION=18, SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION=19, SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION=20, SEC_OID_PKCS5_PBE_WITH_MD2_AND_DES_CBC=21, SEC_OID_PKCS5_PBE_WITH_MD5_AND_DES_CBC=22, SEC_OID_PKCS5_PBE_WITH_SHA1_AND_DES_CBC=23, SEC_OID_PKCS7=24, SEC_OID_PKCS7_DATA=25, SEC_OID_PKCS7_SIGNED_DATA=26, SEC_OID_PKCS7_ENVELOPED_DATA=27, SEC_OID_PKCS7_SIGNED_ENVELOPED_DATA=28, SEC_OID_PKCS7_DIGESTED_DATA=29, SEC_OID_PKCS7_ENCRYPTED_DATA=30, SEC_OID_PKCS9_EMAIL_ADDRESS=31, SEC_OID_PKCS9_UNSTRUCTURED_NAME=32, SEC_OID_PKCS9_CONTENT_TYPE=33, SEC_OID_PKCS9_MESSAGE_DIGEST=34, SEC_OID_PKCS9_SIGNING_TIME=35, SEC_OID_PKCS9_COUNTER_SIGNATURE=36, SEC_OID_PKCS9_CHALLENGE_PASSWORD=37, SEC_OID_PKCS9_UNSTRUCTURED_ADDRESS=38, SEC_OID_PKCS9_EXTENDED_CERTIFICATE_ATTRIBUTES=39, SEC_OID_PKCS9_SMIME_CAPABILITIES=40, SEC_OID_AVA_COMMON_NAME=41, SEC_OID_AVA_COUNTRY_NAME=42, SEC_OID_AVA_LOCALITY=43, SEC_OID_AVA_STATE_OR_PROVINCE=44, SEC_OID_AVA_ORGANIZATION_NAME=45, SEC_OID_AVA_ORGANIZATIONAL_UNIT_NAME=46, SEC_OID_AVA_DN_QUALIFIER=47, SEC_OID_AVA_DC=48, SEC_OID_NS_TYPE_GIF=49, SEC_OID_NS_TYPE_JPEG=50, SEC_OID_NS_TYPE_URL=51, SEC_OID_NS_TYPE_HTML=52, SEC_OID_NS_TYPE_CERT_SEQUENCE=53, SEC_OID_MISSI_KEA_DSS_OLD=54, SEC_OID_MISSI_DSS_OLD=55, SEC_OID_MISSI_KEA_DSS=56, SEC_OID_MISSI_DSS=57, SEC_OID_MISSI_KEA=58, SEC_OID_MISSI_ALT_KEA=59, SEC_OID_NS_CERT_EXT_NETSCAPE_OK=60, SEC_OID_NS_CERT_EXT_ISSUER_LOGO=61, SEC_OID_NS_CERT_EXT_SUBJECT_LOGO=62, SEC_OID_NS_CERT_EXT_CERT_TYPE=63, SEC_OID_NS_CERT_EXT_BASE_URL=64, SEC_OID_NS_CERT_EXT_REVOCATION_URL=65, SEC_OID_NS_CERT_EXT_CA_REVOCATION_URL=66, SEC_OID_NS_CERT_EXT_CA_CRL_URL=67, SEC_OID_NS_CERT_EXT_CA_CERT_URL=68, SEC_OID_NS_CERT_EXT_CERT_RENEWAL_URL=69, SEC_OID_NS_CERT_EXT_CA_POLICY_URL=70, SEC_OID_NS_CERT_EXT_HOMEPAGE_URL=71, SEC_OID_NS_CERT_EXT_ENTITY_LOGO=72, SEC_OID_NS_CERT_EXT_USER_PICTURE=73, SEC_OID_NS_CERT_EXT_SSL_SERVER_NAME=74, SEC_OID_NS_CERT_EXT_COMMENT=75, SEC_OID_NS_CERT_EXT_LOST_PASSWORD_URL=76, SEC_OID_NS_CERT_EXT_CERT_RENEWAL_TIME=77, SEC_OID_NS_KEY_USAGE_GOVT_APPROVED=78, SEC_OID_X509_SUBJECT_DIRECTORY_ATTR=79, SEC_OID_X509_SUBJECT_KEY_ID=80, SEC_OID_X509_KEY_USAGE=81, SEC_OID_X509_PRIVATE_KEY_USAGE_PERIOD=82, SEC_OID_X509_SUBJECT_ALT_NAME=83, SEC_OID_X509_ISSUER_ALT_NAME=84, SEC_OID_X509_BASIC_CONSTRAINTS=85, SEC_OID_X509_NAME_CONSTRAINTS=86, SEC_OID_X509_CRL_DIST_POINTS=87, SEC_OID_X509_CERTIFICATE_POLICIES=88, SEC_OID_X509_POLICY_MAPPINGS=89, SEC_OID_X509_POLICY_CONSTRAINTS=90, SEC_OID_X509_AUTH_KEY_ID=91, SEC_OID_X509_EXT_KEY_USAGE=92, SEC_OID_X509_AUTH_INFO_ACCESS=93, SEC_OID_X509_CRL_NUMBER=94, SEC_OID_X509_REASON_CODE=95, SEC_OID_X509_INVALID_DATE=96, SEC_OID_X500_RSA_ENCRYPTION=97, SEC_OID_RFC1274_UID=98, SEC_OID_RFC1274_MAIL=99, SEC_OID_PKCS12=100, SEC_OID_PKCS12_MODE_IDS=101, SEC_OID_PKCS12_ESPVK_IDS=102, SEC_OID_PKCS12_BAG_IDS=103, SEC_OID_PKCS12_CERT_BAG_IDS=104, SEC_OID_PKCS12_OIDS=105, SEC_OID_PKCS12_PBE_IDS=106, SEC_OID_PKCS12_SIGNATURE_IDS=107, SEC_OID_PKCS12_ENVELOPING_IDS=108, SEC_OID_PKCS12_PKCS8_KEY_SHROUDING=109, SEC_OID_PKCS12_KEY_BAG_ID=110, SEC_OID_PKCS12_CERT_AND_CRL_BAG_ID=111, SEC_OID_PKCS12_SECRET_BAG_ID=112, SEC_OID_PKCS12_X509_CERT_CRL_BAG=113, SEC_OID_PKCS12_SDSI_CERT_BAG=114, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC4=115, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC4=116, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_TRIPLE_DES_CBC=117, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC=118, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC=119, SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_128_BIT_RC4=120, SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_40_BIT_RC4=121, SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_TRIPLE_DES=122, SEC_OID_PKCS12_RSA_SIGNATURE_WITH_SHA1_DIGEST=123, SEC_OID_ANSIX9_DSA_SIGNATURE=124, SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST=125, SEC_OID_BOGUS_DSA_SIGNATURE_WITH_SHA1_DIGEST=126, SEC_OID_VERISIGN_USER_NOTICES=127, SEC_OID_PKIX_CPS_POINTER_QUALIFIER=128, SEC_OID_PKIX_USER_NOTICE_QUALIFIER=129, SEC_OID_PKIX_OCSP=130, SEC_OID_PKIX_OCSP_BASIC_RESPONSE=131, SEC_OID_PKIX_OCSP_NONCE=132, SEC_OID_PKIX_OCSP_CRL=133, SEC_OID_PKIX_OCSP_RESPONSE=134, SEC_OID_PKIX_OCSP_NO_CHECK=135, SEC_OID_PKIX_OCSP_ARCHIVE_CUTOFF=136, SEC_OID_PKIX_OCSP_SERVICE_LOCATOR=137, SEC_OID_PKIX_REGCTRL_REGTOKEN=138, SEC_OID_PKIX_REGCTRL_AUTHENTICATOR=139, SEC_OID_PKIX_REGCTRL_PKIPUBINFO=140, SEC_OID_PKIX_REGCTRL_PKI_ARCH_OPTIONS=141, SEC_OID_PKIX_REGCTRL_OLD_CERT_ID=142, SEC_OID_PKIX_REGCTRL_PROTOCOL_ENC_KEY=143, SEC_OID_PKIX_REGINFO_UTF8_PAIRS=144, SEC_OID_PKIX_REGINFO_CERT_REQUEST=145, SEC_OID_EXT_KEY_USAGE_SERVER_AUTH=146, SEC_OID_EXT_KEY_USAGE_CLIENT_AUTH=147, SEC_OID_EXT_KEY_USAGE_CODE_SIGN=148, SEC_OID_EXT_KEY_USAGE_EMAIL_PROTECT=149, SEC_OID_EXT_KEY_USAGE_TIME_STAMP=150, SEC_OID_OCSP_RESPONDER=151, SEC_OID_NETSCAPE_SMIME_KEA=152, SEC_OID_FORTEZZA_SKIPJACK=153, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC4=154, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC4=155, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_3KEY_TRIPLE_DES_CBC=156, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_2KEY_TRIPLE_DES_CBC=157, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC=158, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC=159, SEC_OID_PKCS12_SAFE_CONTENTS_ID=160, SEC_OID_PKCS12_PKCS8_SHROUDED_KEY_BAG_ID=161, SEC_OID_PKCS12_V1_KEY_BAG_ID=162, SEC_OID_PKCS12_V1_PKCS8_SHROUDED_KEY_BAG_ID=163, SEC_OID_PKCS12_V1_CERT_BAG_ID=164, SEC_OID_PKCS12_V1_CRL_BAG_ID=165, SEC_OID_PKCS12_V1_SECRET_BAG_ID=166, SEC_OID_PKCS12_V1_SAFE_CONTENTS_BAG_ID=167, SEC_OID_PKCS9_X509_CERT=168, SEC_OID_PKCS9_SDSI_CERT=169, SEC_OID_PKCS9_X509_CRL=170, SEC_OID_PKCS9_FRIENDLY_NAME=171, SEC_OID_PKCS9_LOCAL_KEY_ID=172, SEC_OID_BOGUS_KEY_USAGE=173, SEC_OID_X942_DIFFIE_HELMAN_KEY=174, SEC_OID_NETSCAPE_NICKNAME=175, SEC_OID_NETSCAPE_RECOVERY_REQUEST=176, SEC_OID_CERT_RENEWAL_LOCATOR=177, SEC_OID_NS_CERT_EXT_SCOPE_OF_USE=178, SEC_OID_CMS_EPHEMERAL_STATIC_DIFFIE_HELLMAN=179, SEC_OID_CMS_3DES_KEY_WRAP=180, SEC_OID_CMS_RC2_KEY_WRAP=181, SEC_OID_SMIME_ENCRYPTION_KEY_PREFERENCE=182, SEC_OID_AES_128_ECB=183, SEC_OID_AES_128_CBC=184, SEC_OID_AES_192_ECB=185, SEC_OID_AES_192_CBC=186, SEC_OID_AES_256_ECB=187, SEC_OID_AES_256_CBC=188, SEC_OID_SDN702_DSA_SIGNATURE=189, SEC_OID_MS_SMIME_ENCRYPTION_KEY_PREFERENCE=190, SEC_OID_SHA256=191, SEC_OID_SHA384=192, SEC_OID_SHA512=193, SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION=194, SEC_OID_PKCS1_SHA384_WITH_RSA_ENCRYPTION=195, SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION=196, SEC_OID_AES_128_KEY_WRAP=197, SEC_OID_AES_192_KEY_WRAP=198, SEC_OID_AES_256_KEY_WRAP=199, SEC_OID_ANSIX962_EC_PUBLIC_KEY=200, SEC_OID_ANSIX962_ECDSA_SHA1_SIGNATURE=201, SEC_OID_ANSIX962_EC_PRIME192V1=202, SEC_OID_ANSIX962_EC_PRIME192V2=203, SEC_OID_ANSIX962_EC_PRIME192V3=204, SEC_OID_ANSIX962_EC_PRIME239V1=205, SEC_OID_ANSIX962_EC_PRIME239V2=206, SEC_OID_ANSIX962_EC_PRIME239V3=207, SEC_OID_ANSIX962_EC_PRIME256V1=208, SEC_OID_SECG_EC_SECP112R1=209, SEC_OID_SECG_EC_SECP112R2=210, SEC_OID_SECG_EC_SECP128R1=211, SEC_OID_SECG_EC_SECP128R2=212, SEC_OID_SECG_EC_SECP160K1=213, SEC_OID_SECG_EC_SECP160R1=214, SEC_OID_SECG_EC_SECP160R2=215, SEC_OID_SECG_EC_SECP192K1=216, SEC_OID_SECG_EC_SECP224K1=217, SEC_OID_SECG_EC_SECP224R1=218, SEC_OID_SECG_EC_SECP256K1=219, SEC_OID_SECG_EC_SECP384R1=220, SEC_OID_SECG_EC_SECP521R1=221, SEC_OID_ANSIX962_EC_C2PNB163V1=222, SEC_OID_ANSIX962_EC_C2PNB163V2=223, SEC_OID_ANSIX962_EC_C2PNB163V3=224, SEC_OID_ANSIX962_EC_C2PNB176V1=225, SEC_OID_ANSIX962_EC_C2TNB191V1=226, SEC_OID_ANSIX962_EC_C2TNB191V2=227, SEC_OID_ANSIX962_EC_C2TNB191V3=228, SEC_OID_ANSIX962_EC_C2ONB191V4=229, SEC_OID_ANSIX962_EC_C2ONB191V5=230, SEC_OID_ANSIX962_EC_C2PNB208W1=231, SEC_OID_ANSIX962_EC_C2TNB239V1=232, SEC_OID_ANSIX962_EC_C2TNB239V2=233, SEC_OID_ANSIX962_EC_C2TNB239V3=234, SEC_OID_ANSIX962_EC_C2ONB239V4=235, SEC_OID_ANSIX962_EC_C2ONB239V5=236, SEC_OID_ANSIX962_EC_C2PNB272W1=237, SEC_OID_ANSIX962_EC_C2PNB304W1=238, SEC_OID_ANSIX962_EC_C2TNB359V1=239, SEC_OID_ANSIX962_EC_C2PNB368W1=240, SEC_OID_ANSIX962_EC_C2TNB431R1=241, SEC_OID_SECG_EC_SECT113R1=242, SEC_OID_SECG_EC_SECT113R2=243, SEC_OID_SECG_EC_SECT131R1=244, SEC_OID_SECG_EC_SECT131R2=245, SEC_OID_SECG_EC_SECT163K1=246, SEC_OID_SECG_EC_SECT163R1=247, SEC_OID_SECG_EC_SECT163R2=248, SEC_OID_SECG_EC_SECT193R1=249, SEC_OID_SECG_EC_SECT193R2=250, SEC_OID_SECG_EC_SECT233K1=251, SEC_OID_SECG_EC_SECT233R1=252, SEC_OID_SECG_EC_SECT239K1=253, SEC_OID_SECG_EC_SECT283K1=254, SEC_OID_SECG_EC_SECT283R1=255, SEC_OID_SECG_EC_SECT409K1=256, SEC_OID_SECG_EC_SECT409R1=257, SEC_OID_SECG_EC_SECT571K1=258, SEC_OID_SECG_EC_SECT571R1=259, SEC_OID_NETSCAPE_AOLSCREENNAME=260, SEC_OID_AVA_SURNAME=261, SEC_OID_AVA_SERIAL_NUMBER=262, SEC_OID_AVA_STREET_ADDRESS=263, SEC_OID_AVA_TITLE=264, SEC_OID_AVA_POSTAL_ADDRESS=265, SEC_OID_AVA_POSTAL_CODE=266, SEC_OID_AVA_POST_OFFICE_BOX=267, SEC_OID_AVA_GIVEN_NAME=268, SEC_OID_AVA_INITIALS=269, SEC_OID_AVA_GENERATION_QUALIFIER=270, SEC_OID_AVA_HOUSE_IDENTIFIER=271, SEC_OID_AVA_PSEUDONYM=272, SEC_OID_PKIX_CA_ISSUERS=273, SEC_OID_PKCS9_EXTENSION_REQUEST=274, SEC_OID_ANSIX962_ECDSA_SIGNATURE_RECOMMENDED_DIGEST=275, SEC_OID_ANSIX962_ECDSA_SIGNATURE_SPECIFIED_DIGEST=276, SEC_OID_ANSIX962_ECDSA_SHA224_SIGNATURE=277, SEC_OID_ANSIX962_ECDSA_SHA256_SIGNATURE=278, SEC_OID_ANSIX962_ECDSA_SHA384_SIGNATURE=279, SEC_OID_ANSIX962_ECDSA_SHA512_SIGNATURE=280, SEC_OID_X509_HOLD_INSTRUCTION_CODE=281, SEC_OID_X509_DELTA_CRL_INDICATOR=282, SEC_OID_X509_ISSUING_DISTRIBUTION_POINT=283, SEC_OID_X509_CERT_ISSUER=284, SEC_OID_X509_FRESHEST_CRL=285, SEC_OID_X509_INHIBIT_ANY_POLICY=286, SEC_OID_X509_SUBJECT_INFO_ACCESS=287, SEC_OID_CAMELLIA_128_CBC=288, SEC_OID_CAMELLIA_192_CBC=289, SEC_OID_CAMELLIA_256_CBC=290, SEC_OID_PKCS5_PBKDF2=291, SEC_OID_PKCS5_PBES2=292, SEC_OID_PKCS5_PBMAC1=293, SEC_OID_HMAC_SHA1=294, SEC_OID_HMAC_SHA224=295, SEC_OID_HMAC_SHA256=296, SEC_OID_HMAC_SHA384=297, SEC_OID_HMAC_SHA512=298, SEC_OID_PKIX_TIMESTAMPING=299, SEC_OID_PKIX_CA_REPOSITORY=300, SEC_OID_ISO_SHA1_WITH_RSA_SIGNATURE=301, SEC_OID_SEED_CBC=302, SEC_OID_X509_ANY_POLICY=303, SEC_OID_PKCS1_RSA_OAEP_ENCRYPTION=304, SEC_OID_PKCS1_MGF1=305, SEC_OID_PKCS1_PSPECIFIED=306, SEC_OID_PKCS1_RSA_PSS_SIGNATURE=307, SEC_OID_PKCS1_SHA224_WITH_RSA_ENCRYPTION=308, SEC_OID_SHA224=309, SEC_OID_EV_INCORPORATION_LOCALITY=310, SEC_OID_EV_INCORPORATION_STATE=311, SEC_OID_EV_INCORPORATION_COUNTRY=312, SEC_OID_BUSINESS_CATEGORY=313, SEC_OID_NIST_DSA_SIGNATURE_WITH_SHA224_DIGEST=314, SEC_OID_NIST_DSA_SIGNATURE_WITH_SHA256_DIGEST=315, SEC_OID_MS_EXT_KEY_USAGE_CTL_SIGNING=316, SEC_OID_AVA_NAME=317, SEC_OID_AES_128_GCM=318, SEC_OID_AES_192_GCM=319, SEC_OID_AES_256_GCM=320, SEC_OID_IDEA_CBC=321, SEC_OID_RC2_40_CBC=322, SEC_OID_DES_40_CBC=323, SEC_OID_RC4_40=324, SEC_OID_RC4_56=325, SEC_OID_NULL_CIPHER=326, SEC_OID_HMAC_MD5=327, SEC_OID_TLS_RSA=328, SEC_OID_TLS_DHE_RSA=329, SEC_OID_TLS_DHE_DSS=330, SEC_OID_TLS_DH_RSA=331, SEC_OID_TLS_DH_DSS=332, SEC_OID_TLS_DH_ANON=333, SEC_OID_TLS_ECDHE_ECDSA=334, SEC_OID_TLS_ECDHE_RSA=335, SEC_OID_TLS_ECDH_ECDSA=336, SEC_OID_TLS_ECDH_RSA=337, SEC_OID_TLS_ECDH_ANON=338, SEC_OID_TLS_RSA_EXPORT=339, SEC_OID_TLS_DHE_RSA_EXPORT=340, SEC_OID_TLS_DHE_DSS_EXPORT=341, SEC_OID_TLS_DH_RSA_EXPORT=342, SEC_OID_TLS_DH_DSS_EXPORT=343, SEC_OID_TLS_DH_ANON_EXPORT=344, SEC_OID_APPLY_SSL_POLICY=345, SEC_OID_CHACHA20_POLY1305=346, SEC_OID_TLS_ECDHE_PSK=347, SEC_OID_TLS_DHE_PSK=348, SEC_OID_TLS_FFDHE_2048=349, SEC_OID_TLS_FFDHE_3072=350, SEC_OID_TLS_FFDHE_4096=351, SEC_OID_TLS_FFDHE_6144=352, SEC_OID_TLS_FFDHE_8192=353, SEC_OID_TLS_DHE_CUSTOM=354, SEC_OID_CURVE25519=355, SEC_OID_TLS13_KEA_ANY=356, SEC_OID_X509_ANY_EXT_KEY_USAGE=357, SEC_OID_EXT_KEY_USAGE_IPSEC_IKE=358, SEC_OID_IPSEC_IKE_END=359, SEC_OID_IPSEC_IKE_INTERMEDIATE=360, SEC_OID_TOTAL=361 }

user_defined_types: enum SECSupportExtenTag { INVALID_CERT_EXTENSION=0, UNSUPPORTED_CERT_EXTENSION=1, SUPPORTED_CERT_EXTENSION=2 }

user_defined_types: enum SECItemType { siBuffer=0, siClearDataBuffer=1, siCipherDataBuffer=2, siDERCertBuffer=3, siEncodedCertBuffer=4, siDERNameBuffer=5, siEncodedNameBuffer=6, siAsciiNameString=7, siAsciiString=8, siDEROID=9, siUnsignedInteger=10, siUTCTime=11, siGeneralizedTime=12, siVisibleString=13, siUTF8String=14, siBMPString=15 }


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

if ( a2 )
result = jam(a1, "CKA_%08lx", a2);
else
result = jam_string(a1, "FLAGS_ONLY");
return result;
}

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

if ( a2 )
result = jam(a1, "CKA_%08lx", a2);
else
result = jam_string(a1, "FLAGS_ONLY");
return result;
}

original_code:
size_t jam_nss_cka(struct jambuf *buf, CK_ATTRIBUTE_TYPE attribute)
{
 switch (attribute) {
  case 0x0000010C: return jam_string(buf, &"CKA_DERIVE"[strlen("CKA_")]);
  case 0: return jam_string(buf, &"CKA_FLAGS_ONLY"[strlen("CKA_")]);
  case 0x00000106: return jam_string(buf, &"CKA_WRAP"[strlen("CKA_")]);
  case 0x00000107: return jam_string(buf, &"CKA_UNWRAP"[strlen("CKA_")]);
  case 0x00000104: return jam_string(buf, &"CKA_ENCRYPT"[strlen("CKA_")]);
  case 0x00000105: return jam_string(buf, &"CKA_DECRYPT"[strlen("CKA_")]);
  case 0x00000108: return jam_string(buf, &"CKA_SIGN"[strlen("CKA_")]);
  case 0x00000109: return jam_string(buf, &"CKA_SIGN_RECOVER"[strlen("CKA_")]);
  case 0x0000010A: return jam_string(buf, &"CKA_VERIFY"[strlen("CKA_")]);
  case 0x0000010B: return jam_string(buf, &"CKA_VERIFY_RECOVER"[strlen("CKA_")]);
 default:
  return jam(buf, "CKA_%08lx", (long)attribute);
 }
}

canonical_original_code:
unsigned long jam_nss_cka(struct jambuf *buf, unsigned long attribute)
{
 switch (attribute) {
  case 0x0000010C: return jam_string(buf, &"CKA_DERIVE"[strlen("CKA_")]);
  case 0: return jam_string(buf, &"CKA_FLAGS_ONLY"[strlen("CKA_")]);
  case 0x00000106: return jam_string(buf, &"CKA_WRAP"[strlen("CKA_")]);
  case 0x00000107: return jam_string(buf, &"CKA_UNWRAP"[strlen("CKA_")]);
  case 0x00000104: return jam_string(buf, &"CKA_ENCRYPT"[strlen("CKA_")]);
  case 0x00000105: return jam_string(buf, &"CKA_DECRYPT"[strlen("CKA_")]);
  case 0x00000108: return jam_string(buf, &"CKA_SIGN"[strlen("CKA_")]);
  case 0x00000109: return jam_string(buf, &"CKA_SIGN_RECOVER"[strlen("CKA_")]);
  case 0x0000010A: return jam_string(buf, &"CKA_VERIFY"[strlen("CKA_")]);
  case 0x0000010B: return jam_string(buf, &"CKA_VERIFY_RECOVER"[strlen("CKA_")]);
 default:
  return jam(buf, "CKA_%08lx", (long)attribute);
 }
}

variable_types:
attribute
unsigned long


untext

decompiled_code:
__int64 __fastcall untext(_BYTE *a1, _BYTE *a2, __int64 a3)
{
if ( !a3 )
return 4294967294LL;
*a2 = *a1;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, _BYTE *a2, __int64 a3)
{
if ( !a3 )
return 4294967294LL;
*a2 = *a1;
return 1LL;
}

original_code:
static int untext(const char *src,
    char *dst,
    size_t dstlen)
{
 if (dstlen < 1)
  return (-2);
 *dst = *src;
 return 1;
}

canonical_original_code:
static int untext(char *src, char *dst, unsigned long dstlen)
{
 if (dstlen < 1)
  return (-2);
 *dst = *src;
 return 1;
}

variable_types:
src
char *

variable_types:
dst
char *

variable_types:
dstlen
unsigned long

return_type: int


badch

decompiled_code:
const char *badch()
{
return "unknown character in input";
}

canonical_decompiled_code:
const char *func1()
{
return "unknown character in input";
}

original_code:
static err_t badch(void)
{
 return "unknown character in input";
}

canonical_original_code:
static char *badch()
{
 return "unknown character in input";
}


ttodatav

decompiled_code:
const char *__fastcall ttodatav(char *a1, unsigned __int64 a2, int a3, char *a4, __int64 a5, char *a6)
{
char *v6; // rbx
char *v7; // r14
const char *result; // rax
__int64 (__fastcall *v9)(); // r15
char *v10; // rax
unsigned __int64 v11; // rbp
char *v12; // r13
unsigned __int64 v13; // r12
int v14; // eax
unsigned int v15; // edx
char *v16; // rdx
__int64 v17; // [rsp+8h] [rbp-70h]
int v19; // [rsp+20h] [rbp-58h]
int v20; // [rsp+24h] [rbp-54h]
char *v21; // [rsp+28h] [rbp-50h]
char v22[4]; // [rsp+30h] [rbp-48h] BYREF
char v23[4]; // [rsp+34h] [rbp-44h] BYREF
unsigned __int64 v24; // [rsp+38h] [rbp-40h]

v6 = a1;
v24 = __readfsqword(0x28u);
v7 = v22;
if ( a5 )
v7 = a4;
if ( a3 )
{
LABEL_10:
if ( a3 == 64 )
{
v19 = 0;
v9 = unb64;
v17 = 4LL;
}
else if ( a3 == 256 )
{
v19 = 0;
v9 = (__int64 (__fastcall *)())untext;
v17 = 1LL;
}
else
{
result = "unknown base";
if ( a3 != 16 )
return result;
v19 = 1;
v9 = (__int64 (__fastcall *)())unhex;
v17 = 2LL;
}
if ( !a2 )
return "no data bytes specified by input";
v21 = &v7[a5];
v20 = 0;
while ( 1 )
{
v10 = v23;
v11 = a2 - v17;
while ( 1 )
{
*v10 = *v6;
v12 = v6++;
v13 = a2--;
if ( v11 == a2 )
break;
++v10;
if ( !a2 )
return "input ends in mid-byte, perhaps truncated";
}
v14 = ((__int64 (__fastcall *)(char *, char *, __int64))v9)(v23, v22, 4LL);
if ( v14 == -3 )
return "bad (non-zero) padding at end of base64 input";
if ( v14 < -2 )
{
v15 = v14 + 7;
result = "unknown internal error";
if ( v15 <= 3 )
result = badch();
return result;
}
if ( v14 == -2 )
return "internal buffer too short (\"can't happen\")";
if ( v14 <= 0 )
return "unknown internal error";
v16 = v22;
do
{
if ( v21 > v7 )
*v7++ = *v16;
++v16;
}
while ( &v22[v14 - 1 + 1] != v16 );
v20 += v14;
if ( !v19 || v11 <= 1 )
break;
a2 = v11;
if ( *v6 == 95 )
{
v6 = v12 + 2;
a2 = v13 - 2;
LABEL_40:
if ( !a2 )
{
if ( !v20 )
return "no data bytes specified by input";
result = a6;
if ( a6 )
{
*(_QWORD *)a6 = v20;
result = 0LL;
}
return result;
}
}
}
a2 = v11;
goto LABEL_40;
}
result = "input too short to be valid";
if ( a2 > 1 )
{
result = "input does not begin with format prefix";
if ( *a1 == 48 )
{
switch ( a1[1] )
{
case 'S':
case 's':
a3 = 64;
goto LABEL_9;
case 'T':
case 't':
a3 = 256;
goto LABEL_9;
case 'X':
case 'x':
a3 = 16;
LABEL_9:
a2 -= 2LL;
v6 = a1 + 2;
goto LABEL_10;
default:
return "unknown format prefix";
}
}
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func2(char *a1, unsigned __int64 a2, int a3, char *a4, __int64 a5, char *a6)
{
char *v6; // rbx
char *v7; // r14
const char *result; // rax
__int64 (__fastcall *v9)(); // r15
char *v10; // rax
unsigned __int64 v11; // rbp
char *v12; // r13
unsigned __int64 v13; // r12
int v14; // eax
unsigned int v15; // edx
char *v16; // rdx
__int64 v17; // [rsp+8h] [rbp-70h]
int v19; // [rsp+20h] [rbp-58h]
int v20; // [rsp+24h] [rbp-54h]
char *v21; // [rsp+28h] [rbp-50h]
char v22[4]; // [rsp+30h] [rbp-48h] BYREF
char v23[4]; // [rsp+34h] [rbp-44h] BYREF
unsigned __int64 v24; // [rsp+38h] [rbp-40h]

v6 = a1;
v24 = __readfsqword(0x28u);
v7 = v22;
if ( a5 )
v7 = a4;
if ( a3 )
{
LABEL_10:
if ( a3 == 64 )
{
v19 = 0;
v9 = unb64;
v17 = 4LL;
}
else if ( a3 == 256 )
{
v19 = 0;
v9 = (__int64 (__fastcall *)())untext;
v17 = 1LL;
}
else
{
result = "unknown base";
if ( a3 != 16 )
return result;
v19 = 1;
v9 = (__int64 (__fastcall *)())unhex;
v17 = 2LL;
}
if ( !a2 )
return "no data bytes specified by input";
v21 = &v7[a5];
v20 = 0;
while ( 1 )
{
v10 = v23;
v11 = a2 - v17;
while ( 1 )
{
*v10 = *v6;
v12 = v6++;
v13 = a2--;
if ( v11 == a2 )
break;
++v10;
if ( !a2 )
return "input ends in mid-byte, perhaps truncated";
}
v14 = ((__int64 (__fastcall *)(char *, char *, __int64))v9)(v23, v22, 4LL);
if ( v14 == -3 )
return "bad (non-zero) padding at end of base64 input";
if ( v14 < -2 )
{
v15 = v14 + 7;
result = "unknown internal error";
if ( v15 <= 3 )
result = func1();
return result;
}
if ( v14 == -2 )
return "internal buffer too short (\"can't happen\")";
if ( v14 <= 0 )
return "unknown internal error";
v16 = v22;
do
{
if ( v21 > v7 )
*v7++ = *v16;
++v16;
}
while ( &v22[v14 - 1 + 1] != v16 );
v20 += v14;
if ( !v19 || v11 <= 1 )
break;
a2 = v11;
if ( *v6 == 95 )
{
v6 = v12 + 2;
a2 = v13 - 2;
LABEL_40:
if ( !a2 )
{
if ( !v20 )
return "no data bytes specified by input";
result = a6;
if ( a6 )
{
*(_QWORD *)a6 = v20;
result = 0LL;
}
return result;
}
}
}
a2 = v11;
goto LABEL_40;
}
result = "input too short to be valid";
if ( a2 > 1 )
{
result = "input does not begin with format prefix";
if ( *a1 == 48 )
{
switch ( a1[1] )
{
case 'S':
case 's':
a3 = 64;
goto LABEL_9;
case 'T':
case 't':
a3 = 256;
goto LABEL_9;
case 'X':
case 'x':
a3 = 16;
LABEL_9:
a2 -= 2LL;
v6 = a1 + 2;
goto LABEL_10;
default:
return "unknown format prefix";
}
}
}
return result;
}

original_code:
static const char *ttodatav(const char *src, size_t srclen,
       int base,
       char *dst,
       size_t dstlen,
       size_t *lenp)
{
 size_t ingroup;
 char buf[4];
 int nbytes;
 int (*decode)(const char *, char *, size_t);
 char *stop;
 int ndone;
 int i;
 int underscoreok;
 if (dstlen == 0)
  dst = buf;
 stop = dst + dstlen;
 if (base == 0) {
  if (srclen < 2)
   return "input too short to be valid";
  if (*src++ != '0')
   return "input does not begin with format prefix";
  switch (*src++) {
  case 'x':
  case 'X':
   base = 16;
   break;
  case 's':
  case 'S':
   base = 64;
   break;
  case 't':
  case 'T':
   base = 256;
   break;
  default:
   return "unknown format prefix";
  }
  srclen -= 2;
 }
 switch (base) {
 case 16:
  decode = unhex;
  underscoreok = 1;
  ingroup = 2;
  break;
 case 64:
  decode = unb64;
  underscoreok = 0;
  ingroup = 4;
  break;
 case 256:
  decode = untext;
  ingroup = 1;
  underscoreok = 0;
  break;
 default:
  return "unknown base";
 }
 ndone = 0;
 while (srclen > 0) {
  char stage[4];
  size_t sl = 0;
  for (sl = 0; sl < ingroup; src++, srclen--) {
   if (srclen == 0)
    return "input ends in mid-byte, perhaps truncated";
   else
    stage[sl++] = *src;
  }
  nbytes = (*decode)(stage, buf, sizeof(buf));
  switch (nbytes) {
  case (-4):
  case (-5):
  case (-6):
  case (-7):
   return badch();
  case (-2):
   return "internal buffer too short (\"can't happen\")";
  case (-3):
   return "bad (non-zero) padding at end of base64 input";
  }
  if (nbytes <= 0)
   return "unknown internal error";
  for (i = 0; i < nbytes; i++) {
   if (dst < stop)
    *dst++ = buf[i];
   ndone++;
  }
  if (underscoreok && srclen > 1 && *src == '_') {
   src++;
   srclen--;
  }
 }
 if (ndone == 0)
  return "no data bytes specified by input";
 if (lenp != ((void *)0))
  *lenp = ndone;
 return ((void *)0);
}

canonical_original_code:
static char *ttodatav(char *src, unsigned long srclen, int base, char *dst, unsigned long dstlen, unsigned long *lenp)
{
 unsigned long ingroup;
 char buf[4];
 int nbytes;
 int (*decode)(char *, char *, unsigned long);
 char *stop;
 int ndone;
 int i;
 int underscoreok;
 if (dstlen == 0)
  dst = buf;
 stop = dst + dstlen;
 if (base == 0) {
  if (srclen < 2)
   return "input too short to be valid";
  if (*src++ != '0')
   return "input does not begin with format prefix";
  switch (*src++) {
  case 'x':
  case 'X':
   base = 16;
   break;
  case 's':
  case 'S':
   base = 64;
   break;
  case 't':
  case 'T':
   base = 256;
   break;
  default:
   return "unknown format prefix";
  }
  srclen -= 2;
 }
 switch (base) {
 case 16:
  decode = unhex;
  underscoreok = 1;
  ingroup = 2;
  break;
 case 64:
  decode = unb64;
  underscoreok = 0;
  ingroup = 4;
  break;
 case 256:
  decode = untext;
  ingroup = 1;
  underscoreok = 0;
  break;
 default:
  return "unknown base";
 }
 ndone = 0;
 while (srclen > 0) {
  char stage[4];
  unsigned long sl = 0;
  for (sl = 0; sl < ingroup; src++, srclen--) {
   if (srclen == 0)
    return "input ends in mid-byte, perhaps truncated";
   else
    stage[sl++] = *src;
  }
  nbytes = (*decode)(stage, buf, sizeof(buf));
  switch (nbytes) {
  case (-4):
  case (-5):
  case (-6):
  case (-7):
   return badch();
  case (-2):
   return "internal buffer too short (\"can't happen\")";
  case (-3):
   return "bad (non-zero) padding at end of base64 input";
  }
  if (nbytes <= 0)
   return "unknown internal error";
  for (i = 0; i < nbytes; i++) {
   if (dst < stop)
    *dst++ = buf[i];
   ndone++;
  }
  if (underscoreok && srclen > 1 && *src == '_') {
   src++;
   srclen--;
  }
 }
 if (ndone == 0)
  return "no data bytes specified by input";
 if (lenp != ((void *)0))
  *lenp = ndone;
 return ((void *)0);
}

variable_types:
srclen
unsigned long

variable_types: base int

variable_types:
lenp
unsigned long *

variable_types:
ingroup
unsigned long

variable_types:
buf
char [4]

variable_types: nbytes int

variable_types:
decode
int (*)(char *, char *, unsigned long)

variable_types:
stop
char *

variable_types: ndone int

variable_types: i int

variable_types: underscoreok int

variable_types:
stage
char [4]

variable_types:
sl
unsigned long


decompiled_code:
__int64 __fastcall unb64(char *a1, _BYTE *a2, unsigned __int64 a3)
{
char *v3; // rax
char v4; // bl
char *v5; // rax
signed __int64 v6; // rax
char v7; // bl
char v8; // r13
char *v9; // rax
signed __int64 v10; // rax
char v11; // bl
char v12; // bp
char *v13; // rax
__int64 result; // rax

if ( a3 <= 2 )
return 4294967294LL;
v3 = strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", *a1);
if ( !v3 )
return 4294967292LL;
v4 = 4 * (v3 - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
v5 = strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", a1[1]);
if ( !v5 )
return 4294967291LL;
v6 = v5 - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
*a2 = ((unsigned int)v6 >> 4) | v4;
v7 = 16 * v6;
v8 = a1[2];
v9 = strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", v8);
if ( v9 )
{
v10 = v9 - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
a2[1] = ((unsigned int)v10 >> 2) | v7;
v11 = (_BYTE)v10 << 6;
v12 = a1[3];
v13 = strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", v12);
if ( v13 )
{
a2[2] = v11 | ((_BYTE)v13 - (unsigned __int8)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
result = 3LL;
}
else if ( v12 == 61 )
{
result = v11 == 0 ? 2 : -3;
}
else
{
result = 4294967289LL;
}
}
else if ( v8 == 61 )
{
if ( a1[3] == 61 )
result = v7 == 0 ? 1 : -3;
else
result = 4294967290LL;
}
else
{
result = 4294967290LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1, _BYTE *a2, unsigned __int64 a3)
{
char *v3; // rax
char v4; // bl
char *v5; // rax
signed __int64 v6; // rax
char v7; // bl
char v8; // r13
char *v9; // rax
signed __int64 v10; // rax
char v11; // bl
char v12; // bp
char *v13; // rax
__int64 result; // rax

if ( a3 <= 2 )
return 4294967294LL;
v3 = strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", *a1);
if ( !v3 )
return 4294967292LL;
v4 = 4 * (v3 - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
v5 = strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", a1[1]);
if ( !v5 )
return 4294967291LL;
v6 = v5 - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
*a2 = ((unsigned int)v6 >> 4) | v4;
v7 = 16 * v6;
v8 = a1[2];
v9 = strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", v8);
if ( v9 )
{
v10 = v9 - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
a2[1] = ((unsigned int)v10 >> 2) | v7;
v11 = (_BYTE)v10 << 6;
v12 = a1[3];
v13 = strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", v12);
if ( v13 )
{
a2[2] = v11 | ((_BYTE)v13 - (unsigned __int8)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
result = 3LL;
}
else if ( v12 == 61 )
{
result = v11 == 0 ? 2 : -3;
}
else
{
result = 4294967289LL;
}
}
else if ( v8 == 61 )
{
if ( a1[3] == 61 )
result = v7 == 0 ? 1 : -3;
else
result = 4294967290LL;
}
else
{
result = 4294967290LL;
}
return result;
}

original_code:
static int unb64(const char *src,
   char *dst,
   size_t dstlen)
{
 const char *p;
 unsigned byte1;
 unsigned byte2;
 static const char base64[] =
  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 if (dstlen < 3)
  return (-2);
 p = strchr(base64, *src++);
 if (p == ((void *)0))
  return (-4);
 byte1 = (p - base64) << 2;
 p = strchr(base64, *src++);
 if (p == ((void *)0))
  return (-5);
 byte2 = p - base64;
 *dst++ = byte1 | (byte2 >> 4);
 byte1 = (byte2 & 0xf) << 4;
 p = strchr(base64, *src++);
 if (p == ((void *)0)) {
  if (*(src - 1) == '=' && *src == '=') {
   if (byte1 != 0)
    return (-3);
   return 1;
  }
  return (-6);
 }
 byte2 = p - base64;
 *dst++ = byte1 | (byte2 >> 2);
 byte1 = (byte2 & 0x3) << 6;
 p = strchr(base64, *src++);
 if (p == ((void *)0)) {
  if (*(src - 1) == '=') {
   if (byte1 != 0)
    return (-3);
   return 2;
  }
  return (-7);
 }
 byte2 = p - base64;
 *dst++ = byte1 | byte2;
 return 3;
}

canonical_original_code:
static int unb64(char *src, char *dst, unsigned long dstlen)
{
 char *p;
 unsigned int byte1;
 unsigned int byte2;
 static char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 if (dstlen < 3)
  return (-2);
 p = strchr(base64, *src++);
 if (p == ((void *)0))
  return (-4);
 byte1 = (p - base64) << 2;
 p = strchr(base64, *src++);
 if (p == ((void *)0))
  return (-5);
 byte2 = p - base64;
 *dst++ = byte1 | (byte2 >> 4);
 byte1 = (byte2 & 0xf) << 4;
 p = strchr(base64, *src++);
 if (p == ((void *)0)) {
  if (*(src - 1) == '=' && *src == '=') {
   if (byte1 != 0)
    return (-3);
   return 1;
  }
  return (-6);
 }
 byte2 = p - base64;
 *dst++ = byte1 | (byte2 >> 2);
 byte1 = (byte2 & 0x3) << 6;
 p = strchr(base64, *src++);
 if (p == ((void *)0)) {
  if (*(src - 1) == '=') {
   if (byte1 != 0)
    return (-3);
   return 2;
  }
  return (-7);
 }
 byte2 = p - base64;
 *dst++ = byte1 | byte2;
 return 3;
}

variable_types:
p
char *


unhex

original_code:
static int unhex(const char *src,
   char *dst,
   size_t dstlen)
{
 const char *p;
 unsigned byte;
 static const char hex[] = "0123456789abcdef";
 if (dstlen < 1)
  return (-2);
 p = strchr(hex, *src);
 if (p == ((void *)0))
  p = strchr(hex, char_tolower(*src));
 if (p == ((void *)0))
  return (-4);
 byte = (p - hex) << 4;
 src++;
 p = strchr(hex, *src);
 if (p == ((void *)0))
  p = strchr(hex, char_tolower(*src));
 if (p == ((void *)0))
  return (-5);
 byte |= (p - hex);
 *dst = byte;
 return 1;
}

canonical_original_code:
static int unhex(char *src, char *dst, unsigned long dstlen)
{
 char *p;
 unsigned int byte;
 static char hex[] = "0123456789abcdef";
 if (dstlen < 1)
  return (-2);
 p = strchr(hex, *src);
 if (p == ((void *)0))
  p = strchr(hex, char_tolower(*src));
 if (p == ((void *)0))
  return (-4);
 byte = (p - hex) << 4;
 src++;
 p = strchr(hex, *src);
 if (p == ((void *)0))
  p = strchr(hex, char_tolower(*src));
 if (p == ((void *)0))
  return (-5);
 byte |= (p - hex);
 *dst = byte;
 return 1;
}

variable_types:
src
char *

variable_types:
byte
unsigned int

variable_types:
hex
char []


ttodata

decompiled_code:
const char *__fastcall ttodata(char *a1, unsigned __int64 a2, int a3, char *a4, __int64 a5, char *a6)
{
if ( !a2 )
a2 = strlen(a1);
return ttodatav(a1, a2, a3, a4, a5, a6);
}

canonical_decompiled_code:
const char *__fastcall func5(char *a1, unsigned __int64 a2, int a3, char *a4, __int64 a5, char *a6)
{
if ( !a2 )
a2 = strlen(a1);
return func2(a1, a2, a3, a4, a5, a6);
}

original_code:
const char *ttodata(const char *src,
      size_t srclen,
      int base,
      void *dst,
      size_t dstlen,
      size_t *lenp)
{
 if (srclen == 0)
  srclen = strlen(src);
 return ttodatav(src, srclen, base, dst, dstlen, lenp);
}

canonical_original_code:
char *ttodata(char *src, unsigned long srclen, int base, void *dst, unsigned long dstlen, unsigned long *lenp)
{
 if (srclen == 0)
  srclen = strlen(src);
 return ttodatav(src, srclen, base, dst, dstlen, lenp);
}

variable_types:
srclen
unsigned long

variable_types:
dst
void *

variable_types:
dstlen
unsigned long


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

for ( result = *a1; *a1; result = *a1 )
{
if ( a1[1] == a2 )
break;
a1 += 2;
}
return result;
}

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

for ( result = *a1; *a1; result = *a1 )
{
if ( a1[1] == a2 )
break;
a1 += 2;
}
return result;
}

original_code:
const char *sparse_name(sparse_names sd, unsigned long val)
{
 for (const struct sparse_name *p = sd; p->name != ((void *)0); p++) {
  if (p->value == val) {
   return p->name;
  }
 }
 return ((void *)0);
}

canonical_original_code:
char *sparse_name(struct sparse_name sd[], unsigned long val)
{
 for (struct sparse_name *p = sd; p->name != ((void *)0); p++) {
  if (p->value == val) {
   return p->name;
  }
 }
 return ((void *)0);
}

variable_types: struct sparse_name { char *name; unsigned long value; } []

variable_types:
val
unsigned long

variable_types: struct sparse_name { char *name; unsigned long value; } *


decompiled_code:
__int64 __fastcall jam_sparse(__int64 a1, __int64 *a2, __int64 a3)
{
__int64 v4; // rax
__int64 result; // rax

v4 = sparse_name(a2, a3);
if ( v4 )
result = jam_string(a1, v4);
else
result = jam(a1, "%lu??", a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 *a2, __int64 a3)
{
__int64 v4; // rax
__int64 result; // rax

v4 = func0(a2, a3);
if ( v4 )
result = jam_string(a1, v4);
else
result = jam(a1, "%lu??", a3);
return result;
}

original_code:
size_t jam_sparse(struct jambuf *buf, sparse_names sd, unsigned long val)
{
 const char *p = sparse_name(sd, val);
 if (p != ((void *)0)) {
  return jam_string(buf, p);
 }
 return jam(buf, "%lu??", val);
}

canonical_original_code:
unsigned long jam_sparse(struct jambuf *buf, struct sparse_name sd[], unsigned long val)
{
 char *p = sparse_name(sd, val);
 if (p != ((void *)0)) {
  return jam_string(buf, p);
 }
 return jam(buf, "%lu??", val);
}

variable_types: struct jambuf { char *array; unsigned long total; unsigned long roof; char *dots; } *

user_defined_types: struct sparse_name { char *name; unsigned long value; }


decompiled_code:
__int64 __fastcall str_sparse(__int64 *a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx

v4 = sparse_name(a1, a2);
if ( !v4 )
{
v4 = a3;
_snprintf_chk(a3, 16LL, 1LL, -1LL, "%lu??", a2);
}
return v4;
}

original_code:
const char *str_sparse(sparse_names sd, unsigned long val, sparse_buf *buf)
{
 const char *p = sparse_name(sd, val);
 if (p != ((void *)0)) {
  return p;
 }
 snprintf(buf->buf, sizeof(buf->buf), "%lu??", val);
 return buf->buf;
}

canonical_original_code:
char *str_sparse(struct sparse_name sd[], unsigned long val, struct sparse_buf *buf)
{
 char *p = sparse_name(sd, val);
 if (p != ((void *)0)) {
  return p;
 }
 snprintf(buf->buf, sizeof(buf->buf), "%lu??", val);
 return buf->buf;
}

variable_types:
buf
struct sparse_buf { char buf[16]; } *


decompiled_code:
__int64 __fastcall keyword_by_value_linear(__int64 *a1, int a2)
{
__int64 v2; // rax
unsigned __int64 v3; // rcx
__int64 v4; // rdi
unsigned int v5; // edx
__int64 result; // rax

v2 = 0LL;
v3 = a1[1];
if ( !v3 )
return 0LL;
v4 = *a1;
v5 = 0;
while ( 1 )
{
result = v4 + 32 * v2;
if ( *(_DWORD *)(result + 16) == a2 )
break;
v2 = ++v5;
if ( v5 >= v3 )
return 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 *a1, int a2)
{
__int64 v2; // rax
unsigned __int64 v3; // rcx
__int64 v4; // rdi
unsigned int v5; // edx
__int64 result; // rax

v2 = 0LL;
v3 = a1[1];
if ( !v3 )
return 0LL;
v4 = *a1;
v5 = 0;
while ( 1 )
{
result = v4 + 32 * v2;
if ( *(_DWORD *)(result + 16) == a2 )
break;
v2 = ++v5;
if ( v5 >= v3 )
return 0LL;
}
return result;
}

original_code:
const struct keyword *keyword_by_value_linear(const struct keywords *keywords,
           unsigned value)
{
 for (unsigned ki = 0; ki < keywords->nr_values; ki++) {
  const struct keyword *kv = &keywords->values[ki];
  if (kv->value == value) {
   return kv;
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct keyword *keyword_by_value_linear(struct keywords *keywords, unsigned int value)
{
 for (unsigned int ki = 0; ki < keywords->nr_values; ki++) {
  struct keyword *kv = &keywords->values[ki];
  if (kv->value == value) {
   return kv;
  }
 }
 return ((void *)0);
}

variable_types: struct keywords { struct keyword *values; unsigned long nr_values; struct keyword *(*by_value)(struct keywords *, unsigned int); char *name; } *

variable_types:
value
unsigned int

variable_types:
ki
unsigned int

variable_types: struct keyword { char *name; char *sname; unsigned int value; char *details; } *


decompiled_code:
__int64 __fastcall keyword_by_value(__int64 a1)
{
return (*(__int64 (**)(void))(a1 + 16))();
}

original_code:
const struct keyword *keyword_by_value(const struct keywords *keywords,
           unsigned value)
{
 return keywords->by_value(keywords, value);
}

canonical_original_code:
struct keyword *keyword_by_value(struct keywords *keywords, unsigned int value)
{
 return keywords->by_value(keywords, value);
}

return_type: struct keyword { char *name; char *sname; unsigned int value; char *details; } *

user_defined_types: struct keywords { struct keyword *values; unsigned long nr_values; struct keyword *(*by_value)(struct keywords *, unsigned int); char *name; }


decompiled_code:
__int64 __fastcall jam_keyword_name(__int64 a1, __int64 a2, unsigned int a3)
{
_QWORD *v4; // rax
__int64 result; // rax

v4 = (_QWORD *)keyword_by_value(a2);
if ( v4 )
result = jam_string(a1, *v4);
else
result = jam(a1, "'%s %u'", *(const char **)(a2 + 24), a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, unsigned int a3)
{
_QWORD *v4; // rax
__int64 result; // rax

v4 = (_QWORD *)func4(a2);
if ( v4 )
result = jam_string(a1, *v4);
else
result = jam(a1, "'%s %u'", *(const char **)(a2 + 24), a3);
return result;
}

original_code:
size_t jam_keyword_name(struct jambuf *buf, const struct keywords *keywords, unsigned value)
{
 const struct keyword *keyword = keyword_by_value(keywords, value);
 if (keyword == ((void *)0)) {
  return jam(buf, "'%s %u'", keywords->name, value);
 } else {
  return jam_string(buf, keyword->name);
 }
}

canonical_original_code:
unsigned long jam_keyword_name(struct jambuf *buf, struct keywords *keywords, unsigned int value)
{
 struct keyword *keyword = keyword_by_value(keywords, value);
 if (keyword == ((void *)0)) {
  return jam(buf, "'%s %u'", keywords->name, value);
 } else {
  return jam_string(buf, keyword->name);
 }
}

variable_types: struct keywords { struct keyword { char *name; char *sname; unsigned int value; char *details; } *values; unsigned long nr_values; struct keyword *(*by_value)(struct keywords *, unsigned int); char *name; } *


decompiled_code:
__int64 __fastcall jam_keyword_sname(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v4; // rax
__int64 result; // rax

v4 = keyword_by_value(a2);
if ( v4 )
result = jam_string(a1, *(_QWORD *)(v4 + 8));
else
result = jam(a1, "'%s %u'", *(const char **)(a2 + 24), a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v4; // rax
__int64 result; // rax

v4 = func4(a2);
if ( v4 )
result = jam_string(a1, *(_QWORD *)(v4 + 8));
else
result = jam(a1, "'%s %u'", *(const char **)(a2 + 24), a3);
return result;
}

original_code:
size_t jam_keyword_sname(struct jambuf *buf, const struct keywords *keywords, unsigned value)
{
 const struct keyword *keyword = keyword_by_value(keywords, value);
 if (keyword == ((void *)0)) {
  return jam(buf, "'%s %u'", keywords->name, value);
 } else {
  return jam_string(buf, keyword->sname);
 }
}

canonical_original_code:
unsigned long jam_keyword_sname(struct jambuf *buf, struct keywords *keywords, unsigned int value)
{
 struct keyword *keyword = keyword_by_value(keywords, value);
 if (keyword == ((void *)0)) {
  return jam(buf, "'%s %u'", keywords->name, value);
 } else {
  return jam_string(buf, keyword->sname);
 }
}

user_defined_types: struct keyword { char *name; char *sname; unsigned int value; char *details; }


decompiled_code:
unsigned __int64 __fastcall eat_whitespace(char **a1)
{
char *i; // rdx
char v2; // cl
unsigned __int64 v4; // [rsp+8h] [rbp-10h]

v4 = __readfsqword(0x28u);
for ( i = a1[1]; i; a1[1] = --i )
{
v2 = **a1;
if ( v2 != 32 && v2 != 9 )
break;
++*a1;
}
return v4 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(char **a1)
{
char *i; // rdx
char v2; // cl
unsigned __int64 v4; // [rsp+8h] [rbp-10h]

v4 = __readfsqword(0x28u);
for ( i = a1[1]; i; a1[1] = --i )
{
v2 = **a1;
if ( v2 != 32 && v2 != 9 )
break;
++*a1;
}
return v4 - __readfsqword(0x28u);
}

original_code:
static void eat_whitespace(chunk_t *src)
{
 while (src->len > 0 && (*src->ptr == ' ' || *src->ptr == '\t')) {
  src->ptr++;
  src->len--;
 }
}

canonical_original_code:
static void eat_whitespace(struct chunk_t *src)
{
 while (src->len > 0 && (*src->ptr == ' ' || *src->ptr == '\t')) {
  src->ptr++;
  src->len--;
 }
}

variable_types: struct chunk_t { unsigned char *ptr; unsigned long len; } *


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

v4 = (char *)memchr(*(const void **)a3, a2, *(_QWORD *)(a3 + 8));
*a1 = 0LL;
a1[1] = 0LL;
if ( !v4 )
return 0LL;
v5 = *(const void **)a3;
*a1 = *(_QWORD *)a3;
a1[1] = (unsigned int)((_DWORD)v4 - (_DWORD)v5);
*(_QWORD *)a3 = v4 + 1;
*(_QWORD *)(a3 + 8) += ~a1[1];
return 1LL;
}

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

v4 = (char *)memchr(*(const void **)a3, a2, *(_QWORD *)(a3 + 8));
*a1 = 0LL;
a1[1] = 0LL;
if ( !v4 )
return 0LL;
v5 = *(const void **)a3;
*a1 = *(_QWORD *)a3;
a1[1] = (unsigned int)((_DWORD)v4 - (_DWORD)v5);
*(_QWORD *)a3 = v4 + 1;
*(_QWORD *)(a3 + 8) += ~a1[1];
return 1LL;
}

original_code:
static _Bool extract_token(chunk_t *token, char termination, chunk_t *src)
{
 uint8_t *eot = memchr(src->ptr, termination, src->len);
 *token = ((const chunk_t) { .ptr = ((void *)0), .len = 0 });
 if (eot == ((void *)0))
  return 0;
 token->ptr = src->ptr;
 token->len = (unsigned)(eot - src->ptr);
 src->ptr = eot + 1;
 src->len -= (token->len + 1);
 return 1;
}

canonical_original_code:
static _Bool extract_token(struct chunk_t *token, char termination, struct chunk_t *src)
{
 unsigned char *eot = memchr(src->ptr, termination, src->len);
 *token = ((struct chunk_t) { .ptr = ((void *)0), .len = 0 });
 if (eot == ((void *)0))
  return 0;
 token->ptr = src->ptr;
 token->len = (unsigned int)(eot - src->ptr);
 src->ptr = eot + 1;
 src->len -= (token->len + 1);
 return 1;
}

variable_types: termination char

variable_types:
src
struct chunk_t *

variable_types:
eot
unsigned char *

user_defined_types: struct chunk_t { unsigned char *ptr; unsigned long len; }


fetchline

original_code:
static _Bool fetchline(chunk_t *src, chunk_t *line)
{
 if (src->len == 0)
  return 0;
 if (extract_token(line, '\n', src)) {
  if (line->len > 0 && *(line->ptr + line->len - 1) == '\r')
   line->len--;
 } else {
  *line = *src;
  src->ptr += src->len;
  src->len = 0;
 }
 return 1;
}

canonical_original_code:
static _Bool fetchline(struct chunk_t *src, struct chunk_t *line)
{
 if (src->len == 0)
  return 0;
 if (extract_token(line, '\n', src)) {
  if (line->len > 0 && *(line->ptr + line->len - 1) == '\r')
   line->len--;
 } else {
  *line = *src;
  src->ptr += src->len;
  src->len = 0;
 }
 return 1;
}

variable_types:
line
struct chunk_t *


present

decompiled_code:
__int64 __fastcall present(char *s2, __int64 a2)
{
unsigned int v2; // eax
unsigned __int64 v3; // r13
size_t v4; // rbp
__int64 result; // rax
const char *v6; // r14
int v7; // edx

v2 = strlen(s2);
v3 = *(_QWORD *)(a2 + 8);
v4 = v2;
result = 0LL;
if ( v3 >= v4 )
{
v6 = *(const char **)a2;
v7 = strncmp(*(const char **)a2, s2, v4);
result = 0LL;
if ( !v7 )
{
*(_QWORD *)a2 = &v6[v4];
*(_QWORD *)(a2 + 8) = v3 - v4;
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s2, __int64 a2)
{
unsigned int v2; // eax
unsigned __int64 v3; // r13
size_t v4; // rbp
__int64 result; // rax
const char *v6; // r14
int v7; // edx

v2 = strlen(s2);
v3 = *(_QWORD *)(a2 + 8);
v4 = v2;
result = 0LL;
if ( v3 >= v4 )
{
v6 = *(const char **)a2;
v7 = strncmp(*(const char **)a2, s2, v4);
result = 0LL;
if ( !v7 )
{
*(_QWORD *)a2 = &v6[v4];
*(_QWORD *)(a2 + 8) = v3 - v4;
result = 1LL;
}
}
return result;
}

original_code:
static _Bool present(const char* pattern, chunk_t* ch)
{
 unsigned pattern_len = strlen(pattern);
 if (ch->len >= pattern_len &&
  (strncmp(((char *)ch->ptr), (pattern), (pattern_len)) == 0)) {
  ch->ptr += pattern_len;
  ch->len -= pattern_len;
  return 1;
 }
 return 0;
}

canonical_original_code:
static _Bool present(char *pattern, struct chunk_t *ch)
{
 unsigned int pattern_len = strlen(pattern);
 if (ch->len >= pattern_len &&
  (strncmp(((char *)ch->ptr), (pattern), (pattern_len)) == 0)) {
  ch->ptr += pattern_len;
  ch->len -= pattern_len;
  return 1;
 }
 return 0;
}

variable_types:
pattern
char *


original_code:
static _Bool find_boundary(const char *tag, chunk_t *line)
{
 chunk_t name = ((const chunk_t) { .ptr = ((void *)0), .len = 0 });
 if (!present("-----", line))
  return 0;
 if (!present(tag, line))
  return 0;
 if (*line->ptr != ' ')
  return 0;
 line->ptr++;
 line->len--;
 name.ptr = line->ptr;
 while (line->len > 0) {
  if (present("-----", line)) {
   { if ((cur_debugging & (((lset_t)1 << (DBG_BASE_IX))))) { DBG_log("  -----%s %.*s-----", tag, (int)name.len, name.ptr); } };
   return 1;
  }
  line->ptr++;
  line->len--;
  name.len++;
 }
 return 0;
}

canonical_original_code:
static _Bool find_boundary(char *tag, struct chunk_t *line)
{
 struct chunk_t name = ((const chunk_t) { .ptr = ((void *)0), .len = 0 });
 if (!present("-----", line))
  return 0;
 if (!present(tag, line))
  return 0;
 if (*line->ptr != ' ')
  return 0;
 line->ptr++;
 line->len--;
 name.ptr = line->ptr;
 while (line->len > 0) {
  if (present("-----", line)) {
   { if ((cur_debugging & (((unsigned long)1 << (DBG_BASE_IX))))) { DBG_log("  -----%s %.*s-----", tag, (int)name.len, name.ptr); } };
   return 1;
  }
  line->ptr++;
  line->len--;
  name.len++;
 }
 return 0;
}

variable_types:
tag
char *

variable_types: struct chunk_t { unsigned char *ptr; unsigned long len; }


decompiled_code:
__int64 __fastcall reqid_ah(unsigned int a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
return a1;
}

original_code:
reqid_t reqid_ah(reqid_t r)
{
 return r;
}

canonical_original_code:
unsigned int reqid_ah(unsigned int r)
{
 return r;
}

variable_types:
r
unsigned int


decompiled_code:
__int64 __fastcall reqid_esp(unsigned int a1)
{
return a1 - ((a1 < 0x4000) - 1);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
return a1 - ((a1 < 0x4000) - 1);
}

original_code:
reqid_t reqid_esp(reqid_t r)
{
 return r <= 0x3fff ? r : (r + 1);
}

canonical_original_code:
unsigned int reqid_esp(unsigned int r)
{
 return r <= 0x3fff ? r : (r + 1);
}


decompiled_code:
__int64 __fastcall reqid_ipcomp(unsigned int a1)
{
__int64 result; // rax

result = a1;
if ( a1 > 0x3FFF )
result = a1 + 2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
__int64 result; // rax

result = a1;
if ( a1 > 0x3FFF )
result = a1 + 2;
return result;
}

original_code:
reqid_t reqid_ipcomp(reqid_t r)
{
 return r <= 0x3fff ? r : (r + 2);
}

canonical_original_code:
unsigned int reqid_ipcomp(unsigned int r)
{
 return r <= 0x3fff ? r : (r + 2);
}


realtime

decompiled_code:
__int64 __fastcall realtime(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return a1;
}

original_code:
realtime_t realtime(time_t time)
{
 return (realtime_t) { { time, 0, }, };
}

canonical_original_code:
struct realtime_t realtime(long time)
{
 return (struct realtime_t) { { time, 0, }, };
}

variable_types: time long

return_type: struct realtime_t { struct timeval { long tv_sec; long tv_usec; } rt; }

user_defined_types: struct realtime_t { struct timeval rt; }


decompiled_code:
__int64 realtime_ms()
{
return timeval_ms();
}

canonical_decompiled_code:
__int64 func1()
{
return timeval_ms();
}

original_code:
realtime_t realtime_ms(intmax_t milliseconds)
{
 return (realtime_t) { .rt = timeval_ms(milliseconds), };
}

canonical_original_code:
struct realtime_t realtime_ms(long milliseconds)
{
 return (struct realtime_t) { .rt = timeval_ms(milliseconds), };
}

variable_types: milliseconds long

user_defined_types: struct timeval { long tv_sec; long tv_usec; }


realmicroseconds

decompiled_code:
__int64 __fastcall realmicroseconds(__int64 a1, __int64 a2)
{
return 1000000 * a1 + a2;
}

original_code:
uint64_t realmicroseconds(realtime_t t)
{
 return t.rt.tv_sec * 1000000LL + t.rt.tv_usec;
}

canonical_original_code:
unsigned long realmicroseconds(struct realtime_t t)
{
 return t.rt.tv_sec * 1000000LL + t.rt.tv_usec;
}

variable_types: struct realtime_t { struct timeval { long tv_sec; long tv_usec; } rt; }


realtimesum

decompiled_code:
__int64 __fastcall realtimesum(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8)
{
__int64 result; // rax

result = a1 + a7;
if ( a8 + a2 > 999999 )
++result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8)
{
__int64 result; // rax

result = a1 + a7;
if ( a8 + a2 > 999999 )
++result;
return result;
}

original_code:
realtime_t realtimesum(realtime_t t, deltatime_t d)
{
 realtime_t s;
 do { (&s.rt)->tv_sec = (&t.rt)->tv_sec + (&d.dt)->tv_sec; (&s.rt)->tv_usec = (&t.rt)->tv_usec + (&d.dt)->tv_usec; if ((&s.rt)->tv_usec >= 1000000) { ++(&s.rt)->tv_sec; (&s.rt)->tv_usec -= 1000000; } } while (0);
 return s;
}

canonical_original_code:
struct realtime_t realtimesum(struct realtime_t t, struct deltatime_t d)
{
 struct realtime_t s;
 do { (&s.rt)->tv_sec = (&t.rt)->tv_sec + (&d.dt)->tv_sec; (&s.rt)->tv_usec = (&t.rt)->tv_usec + (&d.dt)->tv_usec; if ((&s.rt)->tv_usec >= 1000000) { ++(&s.rt)->tv_sec; (&s.rt)->tv_usec -= 1000000; } } while (0);
 return s;
}

variable_types:
t
struct realtime_t

variable_types: struct deltatime_t { struct timeval dt; _Bool is_set; }


decompiled_code:
_BOOL8 __fastcall is_realtime_epoch(__int128 a1)
{
return a1 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(__int128 a1)
{
return a1 == 0;
}

original_code:
_Bool is_realtime_epoch(realtime_t t)
{
 return !((&t.rt)->tv_sec || (&t.rt)->tv_usec);
}

canonical_original_code:
_Bool is_realtime_epoch(struct realtime_t t)
{
 return !((&t.rt)->tv_sec || (&t.rt)->tv_usec);
}


decompiled_code:
__int64 realtime_sub_sign()
{
return timeval_sub_sign();
}

canonical_decompiled_code:
__int64 func5()
{
return timeval_sub_sign();
}

original_code:
int realtime_sub_sign(realtime_t l, realtime_t r)
{
 return timeval_sub_sign(l.rt, r.rt);
}

canonical_original_code:
int realtime_sub_sign(struct realtime_t l, struct realtime_t r)
{
 return timeval_sub_sign(l.rt, r.rt);
}

variable_types:
r
struct realtime_t


realtimediff

decompiled_code:
__int64 __fastcall realtimediff(__int64 a1)
{
deltatime_timevals_diff();
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
deltatime_timevals_diff();
return a1;
}

original_code:
deltatime_t realtimediff(realtime_t a, realtime_t b)
{
 return deltatime_timevals_diff(a.rt, b.rt);
}

canonical_original_code:
struct deltatime_t realtimediff(struct realtime_t a, struct realtime_t b)
{
 return deltatime_timevals_diff(a.rt, b.rt);
}

variable_types: struct realtime_t { struct timeval rt; }

variable_types:
b
struct realtime_t

return_type: struct deltatime_t { struct timeval { long tv_sec; long tv_usec; } dt; _Bool is_set; }

user_defined_types: struct deltatime_t { struct timeval dt; _Bool is_set; }


decompiled_code:
__int64 realtime_clockid()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func7()
{
return 0LL;
}

original_code:
clockid_t realtime_clockid(void)
{
 return 0;
}

canonical_original_code:
int realtime_clockid()
{
 return 0;
}


realnow

decompiled_code:
__time_t realnow()
{
unsigned int v0; // ebx
int *v2; // rax
struct timespec v3; // [rsp+0h] [rbp-28h] BYREF
unsigned __int64 v4; // [rsp+18h] [rbp-10h]

v4 = __readfsqword(0x28u);
v0 = realtime_clockid();
if ( clock_gettime(v0, &v3) < 0 )
{
v2 = _errno_location();
fatal_errno(5LL, &global_logger, (unsigned int)*v2, "clock_gettime(%d,...) call in realnow() failed", v0);
}
return v3.tv_sec;
}

canonical_decompiled_code:
__time_t func8()
{
unsigned int v0; // ebx
int *v2; // rax
struct timespec v3; // [rsp+0h] [rbp-28h] BYREF
unsigned __int64 v4; // [rsp+18h] [rbp-10h]

v4 = __readfsqword(0x28u);
v0 = func7();
if ( clock_gettime(v0, &v3) < 0 )
{
v2 = _errno_location();
fatal_errno(5LL, &global_logger, (unsigned int)*v2, "clock_gettime(%d,...) call in realnow() failed", v0);
}
return v3.tv_sec;
}

original_code:
realtime_t realnow(void)
{
 struct timespec ts;
 int e = clock_gettime(realtime_clockid(), &ts);
 if (e < 0) {
  fatal_errno(PLUTO_EXIT_KERNEL_FAIL, &global_logger, (*__errno_location ()),
       "clock_gettime(%d,...) call in realnow() failed",
       realtime_clockid());
 }
 realtime_t t = {
  .rt = {
   .tv_sec = ts.tv_sec,
   .tv_usec = ts.tv_nsec / 1000,
  },
 };
 return t;
}

canonical_original_code:
struct realtime_t realnow()
{
 struct timespec ts;
 int e = clock_gettime(realtime_clockid(), &ts);
 if (e < 0) {
  fatal_errno(PLUTO_EXIT_KERNEL_FAIL, &global_logger, (*__errno_location ()),
       "clock_gettime(%d,...) call in realnow() failed",
       realtime_clockid());
 }
 struct realtime_t t = {
  .rt = {
   .tv_sec = ts.tv_sec,
   .tv_usec = ts.tv_nsec / 1000,
  },
 };
 return t;
}

variable_types: struct timespec { long tv_sec; long tv_nsec; }

variable_types: e int


original_code:
size_t jam_realtime(struct jambuf *buf, const realtime_t rtm, _Bool utc)
{
 static const char *months[] = {
  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
 };
 size_t s = 0;
 if (is_realtime_epoch(rtm)) {
  s += jam(buf, "--- -- --:--:--%s----", (utc) ? " UTC " : " ");
 } else {
  struct realtm t = (utc ? utc_realtime : local_realtime)(rtm);
  s += jam(buf, "%s %02d %02d:%02d:%02d%s%04d",
    months[t.tm.tm_mon], t.tm.tm_mday, t.tm.tm_hour,
    t.tm.tm_min, t.tm.tm_sec,
    (utc) ? " UTC " : " ", t.tm.tm_year + 1900);
 }
 return s;
}

canonical_original_code:
unsigned long jam_realtime(struct jambuf *buf, struct realtime_t rtm, _Bool utc)
{
 static char *months[] = {
  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
 };
 unsigned long s = 0;
 if (is_realtime_epoch(rtm)) {
  s += jam(buf, "--- -- --:--:--%s----", (utc) ? " UTC " : " ");
 } else {
  struct realtm t = (utc ? utc_realtime : local_realtime)(rtm);
  s += jam(buf, "%s %02d %02d:%02d:%02d%s%04d",
    months[t.tm.tm_mon], t.tm.tm_mday, t.tm.tm_hour,
    t.tm.tm_min, t.tm.tm_sec,
    (utc) ? " UTC " : " ", t.tm.tm_year + 1900);
 }
 return s;
}

variable_types: struct jambuf { char *array; unsigned long total; unsigned long roof; char *dots; } *

variable_types:
months
char *[]

variable_types:
s
unsigned long

variable_types: struct realtm { struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } tm; long microsec; }

user_defined_types: struct realtm { struct tm tm; long microsec; }


decompiled_code:
__int64 __fastcall str_realtime(time_t a1, __int64 a2, char a3, __int64 a4)
{
_QWORD v7[11]; // [rsp+0h] [rbp-58h] BYREF

v7[5] = __readfsqword(0x28u);
array_as_jambuf(v7, a4, 26LL);
jam_realtime((__int64)v7, a1, a2, a3);
return a4;
}

canonical_decompiled_code:
__int64 __fastcall func10(time_t a1, __int64 a2, char a3, __int64 a4)
{
_QWORD v7[11]; // [rsp+0h] [rbp-58h] BYREF

v7[5] = __readfsqword(0x28u);
array_as_jambuf(v7, a4, 26LL);
func9((__int64)v7, a1, a2, a3);
return a4;
}

original_code:
const char *str_realtime(realtime_t r, _Bool utc, realtime_buf *buf)
{
 struct jambuf jambuf = array_as_jambuf((buf->buf), sizeof(buf->buf));
 jam_realtime(&jambuf, r, utc);
 return buf->buf;
}

canonical_original_code:
char *str_realtime(struct realtime_t r, _Bool utc, struct realtime_buf *buf)
{
 struct jambuf jambuf = array_as_jambuf((buf->buf), sizeof(buf->buf));
 jam_realtime(&jambuf, r, utc);
 return buf->buf;
}

variable_types:
buf
struct realtime_buf { char buf[-1]; } *

variable_types: struct jambuf { char *array; unsigned long total; unsigned long roof; char *dots; }


decompiled_code:
__int64 __fastcall hash_connection_serialno(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdx

v1 = shunk2(a1, 4LL);
return hash_bytes(v1, v2, zero_hash);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdx

v1 = shunk2(a1, 4LL);
return hash_bytes(v1, v2, zero_hash);
}

original_code:
static hash_t hash_connection_serialno(const co_serial_t *serialno)
{
 return ({ shunk_t h_ = shunk2(&(*serialno), sizeof(*serialno)); hash_bytes(h_.ptr, h_.len, zero_hash); });
}

canonical_original_code:
static struct hash_t hash_connection_serialno(enum co_serial_t *serialno)
{
 return ({ struct shunk h_ = shunk2(&(*serialno), sizeof(*serialno)); hash_bytes(h_.ptr, h_.len, zero_hash); });
}

variable_types: enum co_serial_t { UNSET_CO_SERIAL=0, MAX_CO_SERIAL=expr } *

variable_types: struct shunk { void *ptr; unsigned long len; }

return_type: struct hash_t { unsigned int hash; }


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

v1 = __readfsqword(0x28u);
if ( (cur_debugging & 1) != 0 )
DBG_log("kernel_alg_init()");
memset(&integ_by_fqn, 0, 0x100uLL);
memset(&encrypt_by_fqn, 0, 0x100uLL);
memset(&ipcomp_by_fqn, 0, 0x100uLL);
ipcomp_num = 0LL;
integ_num = 0LL;
encrypt_num = 0LL;
return v1 - __readfsqword(0x28u);
}

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

v1 = __readfsqword(0x28u);
if ( (cur_debugging & 1) != 0 )
DBG_log("kernel_alg_init()");
memset(&integ_by_fqn, 0, 0x100uLL);
memset(&encrypt_by_fqn, 0, 0x100uLL);
memset(&ipcomp_by_fqn, 0, 0x100uLL);
ipcomp_num = 0LL;
integ_num = 0LL;
encrypt_num = 0LL;
return v1 - __readfsqword(0x28u);
}

original_code:
void kernel_alg_init(void)
{
 { if ((cur_debugging & (((lset_t)1 << (DBG_BASE_IX))))) { DBG_log("kernel_alg_init()"); } };
 memset((&integ_by_fqn), '\0', sizeof(*(&integ_by_fqn)));
 memset((&encrypt_by_fqn), '\0', sizeof(*(&encrypt_by_fqn)));
 memset((&ipcomp_by_fqn), '\0', sizeof(*(&ipcomp_by_fqn)));
 encrypt_num = integ_num = ipcomp_num = 0;
}

canonical_original_code:
void kernel_alg_init()
{
 { if ((cur_debugging & (((unsigned long)1 << (DBG_BASE_IX))))) { DBG_log("kernel_alg_init()"); } };
 memset((&integ_by_fqn), '\0', sizeof(*(&integ_by_fqn)));
 memset((&encrypt_by_fqn), '\0', sizeof(*(&encrypt_by_fqn)));
 memset((&ipcomp_by_fqn), '\0', sizeof(*(&ipcomp_by_fqn)));
 encrypt_num = integ_num = ipcomp_num = 0;
}


decompiled_code:
__int64 kernel_alg_encrypt_count()
{
return encrypt_num;
}

canonical_decompiled_code:
__int64 func11()
{
return encrypt_num;
}

original_code:
int kernel_alg_encrypt_count(void)
{
 return encrypt_num;
}

canonical_original_code:
int kernel_alg_encrypt_count()
{
 return encrypt_num;
}


decompiled_code:
__int64 kernel_alg_integ_count()
{
return integ_num;
}

canonical_decompiled_code:
__int64 func12()
{
return integ_num;
}

original_code:
int kernel_alg_integ_count(void)
{
 return integ_num;
}

canonical_original_code:
int kernel_alg_integ_count()
{
 return integ_num;
}


decompiled_code:
__int64 kernel_alg_ipcomp_count()
{
return ipcomp_num;
}

canonical_decompiled_code:
__int64 func13()
{
return ipcomp_num;
}

original_code:
int kernel_alg_ipcomp_count(void)
{
 return ipcomp_num;
}

canonical_original_code:
int kernel_alg_ipcomp_count()
{
 return ipcomp_num;
}


decompiled_code:
const char *__fastcall vet_seclabel(__int64 a1, __int64 a2)
{
if ( (cur_debugging & 1) != 0 )
DBG_log("%s() not implemented: %zu", "vet_seclabel", a2);
return "Labeled IPsec not supported";
}

canonical_decompiled_code:
const char *__fastcall func0(__int64 a1, __int64 a2)
{
if ( (cur_debugging & 1) != 0 )
DBG_log("%s() not implemented: %zu", "vet_seclabel", a2);
return "Labeled IPsec not supported";
}

original_code:
err_t vet_seclabel(shunk_t sl)
{
 { if ((cur_debugging & (((lset_t)1 << (DBG_BASE_IX))))) { DBG_log("%s() not implemented: %zu", __func__, sl.len); } };
 return "Labeled IPsec not supported";
}

canonical_original_code:
char *vet_seclabel(struct shunk sl)
{
 { if ((cur_debugging & (((unsigned long)1 << (DBG_BASE_IX))))) { DBG_log("%s() not implemented: %zu", __func__, sl.len); } };
 return "Labeled IPsec not supported";
}

user_defined_types: struct shunk { void *ptr; unsigned long len; }


decompiled_code:
__int64 __fastcall shunk2(__int64 a1)
{
return a1;
}

original_code:
shunk_t shunk2(const void *ptr, int len)
{
 return (shunk_t) { .ptr = ptr, .len = len, };
}

canonical_original_code:
struct shunk shunk2(void *ptr, int len)
{
 return (struct shunk) { .ptr = ptr, .len = len, };
}

variable_types:
ptr
void *

variable_types: len int

return_type: struct shunk { void *ptr; unsigned long len; }


decompiled_code:
__int64 __fastcall shunk1(const char *a1)
{
__int64 result; // rax

result = 0LL;
if ( a1 )
{
strlen(a1);
result = shunk2((__int64)a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
__int64 result; // rax

result = 0LL;
if ( a1 )
{
strlen(a1);
result = func0((__int64)a1);
}
return result;
}

original_code:
shunk_t shunk1(const char *ptr)
{
 if (ptr == ((void *)0)) {
  return null_shunk;
 } else {
  return shunk2(ptr, strlen(ptr));
 }
}

canonical_original_code:
struct shunk shunk1(char *ptr)
{
 if (ptr == ((void *)0)) {
  return null_shunk;
 } else {
  return shunk2(ptr, strlen(ptr));
 }
}

variable_types:
ptr
char *