decompiled_code:
__int64 __fastcall str_address_wrapped(__m128i *a1, __int64 a2)
{
_QWORD v3[9]; // [rsp+0h] [rbp-48h] BYREF

v3[5] = __readfsqword(0x28u);
array_as_jambuf(v3, a2, 43LL);
jam_address_wrapped((__int64)v3, a1);
return a2;
}

canonical_decompiled_code:
__int64 __fastcall func13(__m128i *a1, __int64 a2)
{
_QWORD v3[9]; // [rsp+0h] [rbp-48h] BYREF

v3[5] = __readfsqword(0x28u);
array_as_jambuf(v3, a2, 43LL);
func12((__int64)v3, a1);
return a2;
}

original_code:
const char *str_address_wrapped(const ip_address *src,
    address_buf *dst)
{
 struct jambuf buf = array_as_jambuf((dst->buf), sizeof(dst->buf));
 jam_address_wrapped(&buf, src);
 return dst->buf;
}

canonical_original_code:
char *str_address_wrapped(struct ip_address *src, struct address_buf *dst)
{
 struct jambuf buf = array_as_jambuf((dst->buf), sizeof(dst->buf));
 jam_address_wrapped(&buf, src);
 return dst->buf;
}


repo: libreswan/libreswan

original_code:
_Bool address_is_specified(const ip_address address)
{
 const struct ip_info *afi = address_type(&address);
 if (afi == ((void *)0)) {
  return 0;
 }
 if (address_eq_address(address, afi->address.unspec)) {
  return 0;
 }
 return 1;
}

canonical_original_code:
_Bool address_is_specified(struct ip_address address)
{
 struct ip_info *afi = address_type(&address);
 if (afi == ((void *)0)) {
  return 0;
 }
 if (address_eq_address(address, afi->address.unspec)) {
  return 0;
 }
 return 1;
}

variable_types: 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_address { _Bool is_set; enum ip_version version; struct ip_bytes bytes; }

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


original_code:
_Bool address_is_loopback(const ip_address address)
{
 const struct ip_info *afi = address_type(&address);
 if (afi == ((void *)0)) {
  return 0;
 }
 return address_eq_address(address, afi->address.loopback);
}

canonical_original_code:
_Bool address_is_loopback(struct ip_address address)
{
 struct ip_info *afi = address_type(&address);
 if (afi == ((void *)0)) {
  return 0;
 }
 return address_eq_address(address, afi->address.loopback);
}

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

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


original_code:
void pexpect_address(const ip_address *a, where_t where)
{
 if (a == ((void *)0)) {
  return;
 }
 if (address_eq_address(*a, unset_address)) {
  return;
 }
 if (a->is_set == 0 ||
     a->version == 0) {
  llog_pexpect(&global_logger, where, "invalid address: ""<address-%s:IPv%d[""%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x""]>", ((a)->is_set ? "set" : "unset"), (a)->version, ((a)->bytes).byte[0], ((a)->bytes).byte[1], ((a)->bytes).byte[2], ((a)->bytes).byte[3], ((a)->bytes).byte[4], ((a)->bytes).byte[5], ((a)->bytes).byte[6], ((a)->bytes).byte[7], ((a)->bytes).byte[8], ((a)->bytes).byte[9], ((a)->bytes).byte[10], ((a)->bytes).byte[11], ((a)->bytes).byte[12], ((a)->bytes).byte[13], ((a)->bytes).byte[14], ((a)->bytes).byte[15]);
 }
}

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

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

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

return_type: void


monotime

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

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

original_code:
monotime_t monotime(intmax_t seconds)
{
 return (monotime_t) { .mt = { .tv_sec = seconds, }, };
}

canonical_original_code:
struct monotime_t monotime(long seconds)
{
 return (struct monotime_t) { .mt = { .tv_sec = seconds, }, };
}

variable_types: seconds long

return_type: struct monotime_t { struct timeval { long tv_sec; long tv_usec; } mt; }

user_defined_types: struct monotime_t { struct timeval mt; }


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

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

original_code:
monotime_t monotime_ms(intmax_t milliseconds)
{
 return (monotime_t) { .mt = timeval_ms(milliseconds), };
}

canonical_original_code:
struct monotime_t monotime_ms(long milliseconds)
{
 return (struct monotime_t) { .mt = timeval_ms(milliseconds), };
}

variable_types: milliseconds long

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


decompiled_code:
_BOOL8 __fastcall is_monotime_epoch(__int64 a1, __int64 a2)
{
return (monotime_epoch ^ a1 | *(&monotime_epoch + 1) ^ a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1, __int64 a2)
{
return (monotime_epoch ^ a1 | *(&monotime_epoch + 1) ^ a2) == 0;
}

original_code:
_Bool is_monotime_epoch(monotime_t t)
{
 return (memcmp((&t), (&monotime_epoch), (sizeof(monotime_t))) == 0);
}

canonical_original_code:
_Bool is_monotime_epoch(struct monotime_t t)
{
 return (memcmp((&t), (&monotime_epoch), (sizeof(monotime_t))) == 0);
}

variable_types: struct monotime_t { struct timeval { long tv_sec; long tv_usec; } mt; }


decompiled_code:
__int64 monotime_clockid()
{
return 7LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 7LL;
}

original_code:
clockid_t monotime_clockid(void)
{
 return 7;
}

canonical_original_code:
int monotime_clockid()
{
 return 7;
}

return_type: int


mononow

decompiled_code:
__time_t mononow()
{
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 = monotime_clockid();
if ( clock_gettime(v0, &v3) < 0 )
{
v2 = _errno_location();
fatal_errno(5LL, &global_logger, (unsigned int)*v2, "clock_gettime(%d,...) in mononow() failed", v0);
}
return v3.tv_sec;
}

canonical_decompiled_code:
__time_t func4()
{
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 = func3();
if ( clock_gettime(v0, &v3) < 0 )
{
v2 = _errno_location();
fatal_errno(5LL, &global_logger, (unsigned int)*v2, "clock_gettime(%d,...) in mononow() failed", v0);
}
return v3.tv_sec;
}

original_code:
monotime_t mononow(void)
{
 struct timespec t;
 int e = clock_gettime(monotime_clockid(), &t);
 if (e < 0) {
  fatal_errno(PLUTO_EXIT_KERNEL_FAIL, &global_logger, (*__errno_location ()),
       "clock_gettime(%d,...) in mononow() failed",
       monotime_clockid());
 }
 return (monotime_t) {
  .mt = {
   .tv_sec = t.tv_sec,
   .tv_usec = t.tv_nsec / 1000,
  },
 };
}

canonical_original_code:
struct monotime_t mononow()
{
 struct timespec t;
 int e = clock_gettime(monotime_clockid(), &t);
 if (e < 0) {
  fatal_errno(PLUTO_EXIT_KERNEL_FAIL, &global_logger, (*__errno_location ()),
       "clock_gettime(%d,...) in mononow() failed",
       monotime_clockid());
 }
 return (struct monotime_t) {
  .mt = {
   .tv_sec = t.tv_sec,
   .tv_usec = t.tv_nsec / 1000,
  },
 };
}

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

variable_types: e int


monosecs

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

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

original_code:
intmax_t monosecs(monotime_t m)
{
 return m.mt.tv_sec;
}

canonical_original_code:
long monosecs(struct monotime_t m)
{
 return m.mt.tv_sec;
}

return_type: long


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

result = a1 + a7;
if ( (__int64)((*(unsigned __int128 *)&_mm_loadu_si128((const __m128i *)&a7) >> 64) + a2) > 999999 )
++result;
return result;
}

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

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

variable_types:
t
struct monotime_t

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


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

result = a1 - a7;
if ( (__int64)(a2 - (*(unsigned __int128 *)&_mm_loadu_si128((const __m128i *)&a7) >> 64)) < 0 )
--result;
return result;
}

original_code:
monotime_t monotime_sub(monotime_t t, deltatime_t d)
{
 monotime_t s = { { 0, 0 } };
 do { (&s.mt)->tv_sec = (&t.mt)->tv_sec - (&d.dt)->tv_sec; (&s.mt)->tv_usec = (&t.mt)->tv_usec - (&d.dt)->tv_usec; if ((&s.mt)->tv_usec < 0) { --(&s.mt)->tv_sec; (&s.mt)->tv_usec += 1000000; } } while (0);
 return s;
}

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

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


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

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

original_code:
int monotime_sub_sign(monotime_t l, monotime_t r)
{
 return timeval_sub_sign(l.mt, r.mt);
}

canonical_original_code:
int monotime_sub_sign(struct monotime_t l, struct monotime_t r)
{
 return timeval_sub_sign(l.mt, r.mt);
}

variable_types:
r
struct monotime_t


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

if ( (int)monotime_sub_sign() <= 0 )
result = a3;
else
result = a1;
return result;
}

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

if ( (int)func8() <= 0 )
result = a3;
else
result = a1;
return result;
}

original_code:
monotime_t monotime_max(monotime_t l, monotime_t r)
{
 if ((monotime_sub_sign(l, r) > 0)) {
  return l;
 } else {
  return r;
 }
}

canonical_original_code:
struct monotime_t monotime_max(struct monotime_t l, struct monotime_t r)
{
 if ((monotime_sub_sign(l, r) > 0)) {
  return l;
 } else {
  return r;
 }
}

variable_types:
l
struct monotime_t


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

if ( (int)monotime_sub_sign() < 0 )
result = a1;
else
result = a3;
return result;
}

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

if ( (int)func8() < 0 )
result = a1;
else
result = a3;
return result;
}

original_code:
monotime_t monotime_min(monotime_t l, monotime_t r)
{
 if ((monotime_sub_sign(l, r) < 0)) {
  return l;
 } else {
  return r;
 }
}

canonical_original_code:
struct monotime_t monotime_min(struct monotime_t l, struct monotime_t r)
{
 if ((monotime_sub_sign(l, r) < 0)) {
  return l;
 } else {
  return r;
 }
}


monotimediff

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

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

original_code:
deltatime_t monotimediff(monotime_t a, monotime_t b)
{
 return deltatime_timevals_diff(a.mt, b.mt);
}

canonical_original_code:
struct deltatime_t monotimediff(struct monotime_t a, struct monotime_t b)
{
 return deltatime_timevals_diff(a.mt, b.mt);
}

variable_types: struct monotime_t { struct timeval mt; }

variable_types:
b
struct monotime_t

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


decompiled_code:
__int64 __fastcall jam_monotime(__int64 a1)
{
__int64 v2[5]; // [rsp+0h] [rbp-28h] BYREF

v2[3] = __readfsqword(0x28u);
monotimediff((__int64)v2);
return jam_deltatime(a1);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
__int64 v2[5]; // [rsp+0h] [rbp-28h] BYREF

v2[3] = __readfsqword(0x28u);
func11((__int64)v2);
return jam_deltatime(a1);
}

original_code:
size_t jam_monotime(struct jambuf *buf, monotime_t m)
{
 return jam_deltatime(buf, monotimediff(m, monotime_epoch));
}

canonical_original_code:
unsigned long jam_monotime(struct jambuf *buf, struct monotime_t m)
{
 return jam_deltatime(buf, monotimediff(m, monotime_epoch));
}

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

return_type: unsigned long


decompiled_code:
__int64 __fastcall str_monotime(__int64 a1, __int64 a2, __int64 a3)
{
_QWORD v5[11]; // [rsp+0h] [rbp-58h] BYREF

v5[5] = __readfsqword(0x28u);
array_as_jambuf(v5, a3, 31LL);
jam_monotime((__int64)v5);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2, __int64 a3)
{
_QWORD v5[11]; // [rsp+0h] [rbp-58h] BYREF

v5[5] = __readfsqword(0x28u);
array_as_jambuf(v5, a3, 31LL);
func12((__int64)v5);
return a3;
}

original_code:
const char *str_monotime(monotime_t m, monotime_buf *buf)
{
 struct jambuf jambuf = array_as_jambuf((buf->buf), sizeof(buf->buf));
 jam_monotime(&jambuf, m);
 return buf->buf;
}

canonical_original_code:
char *str_monotime(struct monotime_t m, struct monotime_buf *buf)
{
 struct jambuf jambuf = array_as_jambuf((buf->buf), sizeof(buf->buf));
 jam_monotime(&jambuf, m);
 return buf->buf;
}

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

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

return_type: char *


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

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

original_code:
static _Bool suppress_progname_log(const void *object __attribute__ ((unused)))
{
 return 0;
}

canonical_original_code:
static _Bool suppress_progname_log(void *object)
{
 return 0;
}

variable_types:
object
void *


decompiled_code:
__int64 __fastcall jam_progname_prefix(__int64 a1, const char *a2)
{
__int64 result; // rax

if ( a2 )
result = jam(a1, "%s: ", a2);
else
result = 0LL;
return result;
}

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

if ( a2 )
result = jam(a1, "%s: ", a2);
else
result = 0LL;
return result;
}

original_code:
static size_t jam_progname_prefix(struct jambuf *buf, const void *object __attribute__ ((unused)))
{
 const char *progname = object;
 if (progname != ((void *)0)) {
  return jam(buf, "%s: ", progname);
 }
 return 0;
}

canonical_original_code:
static unsigned long jam_progname_prefix(struct jambuf *buf, void *object)
{
 char *progname = object;
 if (progname != ((void *)0)) {
  return jam(buf, "%s: ", progname);
 }
 return 0;
}

variable_types:
progname
char *


decompiled_code:
int __fastcall raw_cmp(const void *a1, size_t a2, const void *a3, size_t a4)
{
size_t v6; // rdx
int v7; // ebx
int result; // eax

if ( a1 && a3 )
{
v6 = a4;
if ( a2 <= a4 )
v6 = a2;
v7 = a2 - a4;
result = memcmp(a1, a3, v6);
if ( !result )
result = v7;
}
else
{
result = 1;
if ( !a1 )
result = a3 != 0LL ? 0xFFFFFFF5 : 0;
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(const void *a1, size_t a2, const void *a3, size_t a4)
{
size_t v6; // rdx
int v7; // ebx
int result; // eax

if ( a1 && a3 )
{
v6 = a4;
if ( a2 <= a4 )
v6 = a2;
v7 = a2 - a4;
result = memcmp(a1, a3, v6);
if ( !result )
result = v7;
}
else
{
result = 1;
if ( !a1 )
result = a3 != 0LL ? 0xFFFFFFF5 : 0;
}
return result;
}

original_code:
int raw_cmp(const void *l_ptr, size_t l_len,
      const void *r_ptr, size_t r_len)
{
 if (l_ptr == ((void *)0) || r_ptr == ((void *)0)) {
  if (l_ptr != ((void *)0)) {
   return 1;
  }
  if (r_ptr != ((void *)0)) {
   return -11;
  }
  return 0;
 }
 size_t len = ({ typeof(l_len) _min1 = (l_len); typeof(r_len) _min2 = (r_len); (void) (&_min1 == &_min2); _min1 < _min2 ? _min1 : _min2; });
 int d = memcmp(l_ptr, r_ptr, len);
 if (d != 0) {
  return d;
 }
 return ((int)l_len - (int)r_len);
}

canonical_original_code:
int raw_cmp(void *l_ptr, unsigned long l_len, void *r_ptr, unsigned long r_len)
{
 if (l_ptr == ((void *)0) || r_ptr == ((void *)0)) {
  if (l_ptr != ((void *)0)) {
   return 1;
  }
  if (r_ptr != ((void *)0)) {
   return -11;
  }
  return 0;
 }
 unsigned long len = ({ typeof(l_len) _min1 = (l_len); typeof(r_len) _min2 = (r_len); (void) (&_min1 == &_min2); _min1 < _min2 ? _min1 : _min2; });
 int d = memcmp(l_ptr, r_ptr, len);
 if (d != 0) {
  return d;
 }
 return ((int)l_len - (int)r_len);
}

variable_types:
len
unsigned long

variable_types: d int


decompiled_code:
bool __fastcall raw_eq(const void *a1, size_t a2, const void *a3, __int64 a4)
{
bool result; // al

result = a3 == 0LL || a1 == 0LL;
if ( result )
return a1 == a3;
if ( a2 == a4 )
result = memcmp(a1, a3, a2) == 0;
return result;
}

canonical_decompiled_code:
bool __fastcall func1(const void *a1, size_t a2, const void *a3, __int64 a4)
{
bool result; // al

result = a3 == 0LL || a1 == 0LL;
if ( result )
return a1 == a3;
if ( a2 == a4 )
result = memcmp(a1, a3, a2) == 0;
return result;
}

original_code:
_Bool raw_eq(const void *l_ptr, size_t l_len,
     const void *r_ptr, size_t r_len)
{
 if (l_ptr == ((void *)0) || r_ptr == ((void *)0)) {
  return l_ptr == r_ptr;
 }
 if (l_len != r_len) {
  return 0;
 }
 return memcmp(l_ptr, r_ptr, r_len) == 0;
}

canonical_original_code:
_Bool raw_eq(void *l_ptr, unsigned long l_len, void *r_ptr, unsigned long r_len)
{
 if (l_ptr == ((void *)0) || r_ptr == ((void *)0)) {
  return l_ptr == r_ptr;
 }
 if (l_len != r_len) {
  return 0;
 }
 return memcmp(l_ptr, r_ptr, r_len) == 0;
}


decompiled_code:
bool __fastcall raw_caseeq(const char *a1, size_t a2, const char *a3, __int64 a4)
{
bool result; // al

result = a3 == 0LL || a1 == 0LL;
if ( result )
return a1 == a3;
if ( a2 == a4 )
result = strncasecmp(a1, a3, a2) == 0;
return result;
}

canonical_decompiled_code:
bool __fastcall func2(const char *a1, size_t a2, const char *a3, __int64 a4)
{
bool result; // al

result = a3 == 0LL || a1 == 0LL;
if ( result )
return a1 == a3;
if ( a2 == a4 )
result = strncasecmp(a1, a3, a2) == 0;
return result;
}

original_code:
_Bool raw_caseeq(const void *l_ptr, size_t l_len,
  const void *r_ptr, size_t r_len)
{
 if (l_ptr == ((void *)0) || r_ptr == ((void *)0)) {
  return l_ptr == r_ptr;
 }
 if (l_len != r_len) {
  return 0;
 }
 return strncasecmp(l_ptr, r_ptr, r_len) == 0;
}

canonical_original_code:
_Bool raw_caseeq(void *l_ptr, unsigned long l_len, void *r_ptr, unsigned long r_len)
{
 if (l_ptr == ((void *)0) || r_ptr == ((void *)0)) {
  return l_ptr == r_ptr;
 }
 if (l_len != r_len) {
  return 0;
 }
 return strncasecmp(l_ptr, r_ptr, r_len) == 0;
}


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

v5 = __readfsqword(0x28u);
LODWORD(v3) = 0;
if ( a3 )
{
do
{
*(_BYTE *)(a2 + (unsigned int)(a3 - 1 - v3)) = a1;
a1 >>= 8;
v3 = (unsigned int)(v3 + 1);
}
while ( v3 < a3 );
}
return v5 - __readfsqword(0x28u);
}

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

v5 = __readfsqword(0x28u);
LODWORD(v3) = 0;
if ( a3 )
{
do
{
*(_BYTE *)(a2 + (unsigned int)(a3 - 1 - v3)) = a1;
a1 >>= 8;
v3 = (unsigned int)(v3 + 1);
}
while ( v3 < a3 );
}
return v5 - __readfsqword(0x28u);
}

original_code:
void hton_bytes(uintmax_t h, void *bytes, size_t size)
{
 uint8_t *byte = bytes;
 for (unsigned i = 0; i < size; i++) {
  unsigned j = size - i - 1;
  byte[j] = h & 0xff;
  h = h >> 8;
 }
}

canonical_original_code:
void hton_bytes(unsigned long h, void *bytes, unsigned long size)
{
 unsigned char *byte = bytes;
 for (unsigned int i = 0; i < size; i++) {
  unsigned int j = size - i - 1;
  byte[j] = h & 0xff;
  h = h >> 8;
 }
}

variable_types:
h
unsigned long

variable_types:
bytes
void *

variable_types:
size
unsigned long

variable_types:
byte
unsigned char *

variable_types:
i
unsigned int

variable_types:
j
unsigned int


decompiled_code:
unsigned __int64 __fastcall ntoh_bytes(unsigned __int8 *a1, unsigned __int64 a2)
{
unsigned __int64 v2; // r8
int v3; // edx
unsigned __int64 v4; // rax

v2 = 0LL;
if ( a2 )
{
v2 = *a1;
v3 = 0;
while ( (unsigned int)++v3 < a2 )
{
v4 = (v2 << 8) + a1[v3];
if ( v2 > v4 )
v4 = -1LL;
v2 = v4;
}
}
return v2;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(unsigned __int8 *a1, unsigned __int64 a2)
{
unsigned __int64 v2; // r8
int v3; // edx
unsigned __int64 v4; // rax

v2 = 0LL;
if ( a2 )
{
v2 = *a1;
v3 = 0;
while ( (unsigned int)++v3 < a2 )
{
v4 = (v2 << 8) + a1[v3];
if ( v2 > v4 )
v4 = -1LL;
v2 = v4;
}
}
return v2;
}

original_code:
uintmax_t ntoh_bytes(const void *bytes, size_t size)
{
 uintmax_t h = 0;
 const uint8_t *byte = bytes;
 for (unsigned i = 0; i < size; i++) {
  uintmax_t n = (h<<8) + byte[i];
  if (n < h) {
   h = (18446744073709551615UL);
  } else {
   h = n;
  }
 }
 return h;
}

canonical_original_code:
unsigned long ntoh_bytes(void *bytes, unsigned long size)
{
 unsigned long h = 0;
 unsigned char *byte = bytes;
 for (unsigned int i = 0; i < size; i++) {
  unsigned long n = (h<<8) + byte[i];
  if (n < h) {
   h = (18446744073709551615UL);
  } else {
   h = n;
  }
 }
 return h;
}

variable_types:
n
unsigned long


decompiled_code:
_BOOL8 __fastcall char_isupper(char a1)
{
return (unsigned __int8)(a1 - 65) <= 0x19u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(char a1)
{
return (unsigned __int8)(a1 - 65) <= 0x19u;
}

original_code:
_Bool char_isupper(char c)
{
 return (c >= 'A' && c <= 'Z');
}

variable_types: c char


decompiled_code:
_BOOL8 __fastcall char_islower(char a1)
{
return (unsigned __int8)(a1 - 97) <= 0x19u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(char a1)
{
return (unsigned __int8)(a1 - 97) <= 0x19u;
}

original_code:
_Bool char_islower(char c)
{
 return (c >= 'a' && c <= 'z');
}


decompiled_code:
bool __fastcall char_isspace(char a1)
{
bool result; // al

result = 1;
if ( a1 != 32 )
result = (unsigned __int8)(a1 - 9) <= 4u;
return result;
}

canonical_decompiled_code:
bool __fastcall func7(char a1)
{
bool result; // al

result = 1;
if ( a1 != 32 )
result = (unsigned __int8)(a1 - 9) <= 4u;
return result;
}


decompiled_code:
__int64 __fastcall char_isblank(char a1, __int64 a2, int a3)
{
LOBYTE(a3) = a1 == 9;
return a3 | (unsigned int)(a1 == 32);
}

canonical_decompiled_code:
__int64 __fastcall func8(char a1, __int64 a2, int a3)
{
LOBYTE(a3) = a1 == 9;
return a3 | (unsigned int)(a1 == 32);
}

original_code:
_Bool char_isblank(char c)
{
 return (c == ' ' ||
  c == '\t');
}


decompiled_code:
_BOOL8 __fastcall char_isdigit(char a1)
{
return (unsigned __int8)(a1 - 48) <= 9u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(char a1)
{
return (unsigned __int8)(a1 - 48) <= 9u;
}

original_code:
_Bool char_isdigit(char c)
{
 return (c >= '0' && c <= '9');
}


decompiled_code:
_BOOL8 __fastcall char_isbdigit(char a1)
{
return (unsigned __int8)(a1 - 48) <= 1u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func10(char a1)
{
return (unsigned __int8)(a1 - 48) <= 1u;
}

original_code:
_Bool char_isbdigit(char c)
{
 return (c >= '0' && c <= '1');
}


decompiled_code:
_BOOL8 __fastcall char_isodigit(char a1)
{
return (unsigned __int8)(a1 - 48) <= 7u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(char a1)
{
return (unsigned __int8)(a1 - 48) <= 7u;
}

original_code:
_Bool char_isodigit(char c)
{
 return (c >= '0' && c <= '7');
}


decompiled_code:
bool __fastcall char_isxdigit(char a1)
{
bool result; // al

result = 1;
if ( (unsigned __int8)(a1 - 48) > 9u )
result = (unsigned __int8)((a1 & 0xDF) - 65) <= 5u;
return result;
}

canonical_decompiled_code:
bool __fastcall func12(char a1)
{
bool result; // al

result = 1;
if ( (unsigned __int8)(a1 - 48) > 9u )
result = (unsigned __int8)((a1 & 0xDF) - 65) <= 5u;
return result;
}


decompiled_code:
_BOOL8 __fastcall char_isprint(char a1)
{
return (unsigned __int8)(a1 - 32) <= 0x5Eu;
}

canonical_decompiled_code:
_BOOL8 __fastcall func13(char a1)
{
return (unsigned __int8)(a1 - 32) <= 0x5Eu;
}

original_code:
_Bool char_isprint(char c)
{
 return (c >= 0x20 && c <= 0x7e);
}


decompiled_code:
__int64 __fastcall char_tolower(unsigned int a1)
{
bool v1; // r8
__int64 result; // rax

v1 = char_isupper(a1);
result = a1 + 32;
if ( !v1 )
result = a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(unsigned int a1)
{
bool v1; // r8
__int64 result; // rax

v1 = func5(a1);
result = a1 + 32;
if ( !v1 )
result = a1;
return result;
}

original_code:
char char_tolower(char c)
{
 return char_isupper(c) ? c - 'A' + 'a' : c;
}

return_type: char


decompiled_code:
__int64 __fastcall char_toupper(unsigned int a1)
{
bool v1; // r8
__int64 result; // rax

v1 = char_islower(a1);
result = a1 - 32;
if ( !v1 )
result = a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned int a1)
{
bool v1; // r8
__int64 result; // rax

v1 = func6(a1);
result = a1 - 32;
if ( !v1 )
result = a1;
return result;
}

original_code:
char char_toupper(char c)
{
 return char_islower(c) ? c - 'a' + 'A' : c;
}


decompiled_code:
bool __fastcall raw_starteq(const char *a1, size_t a2, const char *a3, size_t a4)
{
bool result; // al

if ( a2 < a4 || a3 == 0LL || !a1 )
result = 0;
else
result = strncmp(a1, a3, a4) == 0;
return result;
}

canonical_decompiled_code:
bool __fastcall func16(const char *a1, size_t a2, const char *a3, size_t a4)
{
bool result; // al

if ( a2 < a4 || a3 == 0LL || !a1 )
result = 0;
else
result = strncmp(a1, a3, a4) == 0;
return result;
}

original_code:
_Bool raw_starteq(const void *ptr, size_t len, const void *eat_ptr, size_t eat_len)
{
 if (ptr == ((void *)0) || eat_ptr == ((void *)0)) {
  return 0;
 }
 if (len < eat_len) {
  return 0;
 }
 if (strncmp(ptr, eat_ptr, eat_len) != 0) {
  return 0;
 }
 return 1;
}

canonical_original_code:
_Bool raw_starteq(void *ptr, unsigned long len, void *eat_ptr, unsigned long eat_len)
{
 if (ptr == ((void *)0) || eat_ptr == ((void *)0)) {
  return 0;
 }
 if (len < eat_len) {
  return 0;
 }
 if (strncmp(ptr, eat_ptr, eat_len) != 0) {
  return 0;
 }
 return 1;
}

variable_types:
ptr
void *


decompiled_code:
bool __fastcall raw_casestarteq(const char *a1, size_t a2, const char *a3, size_t a4)
{
bool result; // al

if ( a2 < a4 || a3 == 0LL || !a1 )
result = 0;
else
result = strncasecmp(a1, a3, a4) == 0;
return result;
}

canonical_decompiled_code:
bool __fastcall func17(const char *a1, size_t a2, const char *a3, size_t a4)
{
bool result; // al

if ( a2 < a4 || a3 == 0LL || !a1 )
result = 0;
else
result = strncasecmp(a1, a3, a4) == 0;
return result;
}

original_code:
_Bool raw_casestarteq(const void *ptr, size_t len, const void *eat_ptr, size_t eat_len)
{
 if (ptr == ((void *)0) || eat_ptr == ((void *)0)) {
  return 0;
 }
 if (len < eat_len) {
  return 0;
 }
 if (strncasecmp(ptr, eat_ptr, eat_len) != 0) {
  return 0;
 }
 return 1;
}

canonical_original_code:
_Bool raw_casestarteq(void *ptr, unsigned long len, void *eat_ptr, unsigned long eat_len)
{
 if (ptr == ((void *)0) || eat_ptr == ((void *)0)) {
  return 0;
 }
 if (len < eat_len) {
  return 0;
 }
 if (strncasecmp(ptr, eat_ptr, eat_len) != 0) {
  return 0;
 }
 return 1;
}


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

result = alloc_bytes();
++*(_DWORD *)a3;
++*(_DWORD *)(a3 + 4);
if ( *(_QWORD *)(a3 + 8) < a1 )
*(_QWORD *)(a3 + 8) = a1;
return result;
}

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

result = alloc_bytes();
++*(_DWORD *)a3;
++*(_DWORD *)(a3 + 4);
if ( *(_QWORD *)(a3 + 8) < a1 )
*(_QWORD *)(a3 + 8) = a1;
return result;
}

original_code:
static void * alloc_bytes_st(size_t size, const char *str,
        struct db_ops_stats *st)
{
 void *ptr = alloc_bytes(size, str);
 st->st_curr_cnt++;
 st->st_total_cnt++;
 if (size > st->st_maxsz)
  st->st_maxsz = size;
 return ptr;
}

canonical_original_code:
static void *alloc_bytes_st(unsigned long size, char *str, struct db_ops_stats *st)
{
 void *ptr = alloc_bytes(size, str);
 st->st_curr_cnt++;
 st->st_total_cnt++;
 if (size > st->st_maxsz)
  st->st_maxsz = size;
 return ptr;
}

variable_types:
str
char *

variable_types: struct db_ops_stats { int st_curr_cnt; int st_total_cnt; unsigned long st_maxsz; } *

return_type: void *


original_code:
static void db_prop_init(struct db_context *ctx, uint8_t protoid, int max_trans,
   int max_attrs)
{
 ctx->trans0 = ((void *)0);
 ctx->attrs0 = ((void *)0);
 if (max_trans > 0) {
  ctx->trans0 = alloc_bytes_st(sizeof(struct db_trans) * max_trans, "db_context->trans", &(db_trans_st));;
 }
 if (max_attrs > 0) {
  ctx->attrs0 = alloc_bytes_st(sizeof(struct db_attr) * max_attrs, "db_context->attrs", &(db_attrs_st));;
 }
 ctx->max_trans = max_trans;
 ctx->max_attrs = max_attrs;
 ctx->trans_cur = ctx->trans0;
 ctx->attrs_cur = ctx->attrs0;
 ctx->prop.protoid = protoid;
 ctx->prop.trans = ctx->trans0;
 ctx->prop.trans_cnt = 0;
}

canonical_original_code:
static void db_prop_init(struct db_context *ctx, unsigned char protoid, int max_trans, int max_attrs)
{
 ctx->trans0 = ((void *)0);
 ctx->attrs0 = ((void *)0);
 if (max_trans > 0) {
  ctx->trans0 = alloc_bytes_st(sizeof(struct db_trans) * max_trans, "db_context->trans", &(db_trans_st));;
 }
 if (max_attrs > 0) {
  ctx->attrs0 = alloc_bytes_st(sizeof(struct db_attr) * max_attrs, "db_context->attrs", &(db_attrs_st));;
 }
 ctx->max_trans = max_trans;
 ctx->max_attrs = max_attrs;
 ctx->trans_cur = ctx->trans0;
 ctx->attrs_cur = ctx->attrs0;
 ctx->prop.protoid = protoid;
 ctx->prop.trans = ctx->trans0;
 ctx->prop.trans_cnt = 0;
}

variable_types: struct db_context { struct db_prop { unsigned char protoid; struct db_trans { unsigned short transid; struct db_attr { union { enum ikev1_oakley_attr { OAKLEY_ATTR_undefined=0, OAKLEY_ENCRYPTION_ALGORITHM=1, OAKLEY_HASH_ALGORITHM=2, OAKLEY_AUTHENTICATION_METHOD=3, OAKLEY_GROUP_DESCRIPTION=4, OAKLEY_GROUP_TYPE=5, OAKLEY_GROUP_PRIME=6, OAKLEY_GROUP_GENERATOR_ONE=7, OAKLEY_GROUP_GENERATOR_TWO=8, OAKLEY_GROUP_CURVE_A=9, OAKLEY_GROUP_CURVE_B=10, OAKLEY_LIFE_TYPE=11, OAKLEY_LIFE_DURATION=12, OAKLEY_PRF=13, OAKLEY_KEY_LENGTH=14, OAKLEY_FIELD_SIZE=15, OAKLEY_GROUP_ORDER=16 } oakley; enum ikev1_ipsec_attr { SA_LIFE_TYPE=1, SA_LIFE_DURATION=2, GROUP_DESCRIPTION=3, ENCAPSULATION_MODE=4, AUTH_ALGORITHM=5, KEY_LENGTH=6, KEY_ROUNDS=7, COMPRESS_DICT_SIZE=8, COMPRESS_PRIVATE_ALG=9, ECN_TUNNEL=10, ECN_TUNNEL_or_old_SECCTX=expr, ESN_64BIT_SEQNUM=11, IKEv1_IPSEC_ATTR_UNSPEC_12=12, SIG_ENC_ALGO_VAL=13, ADDRESS_PRESERVATION=14, SA_DIRECTION=15, IPSEC_ATTR_VAL_DESCS_ROOF=16, SECCTX=32001 } ipsec; } type; unsigned short val; } *attrs; unsigned int attr_cnt; } *trans; unsigned int trans_cnt; } prop; struct db_trans *trans0; struct db_trans *trans_cur; struct db_attr *attrs0; struct db_attr *attrs_cur; int max_trans; int max_attrs; } *

variable_types:
protoid
unsigned char

user_defined_types: struct db_trans { unsigned short transid; struct db_attr *attrs; unsigned int attr_cnt; }

user_defined_types: struct db_attr { union { enum ikev1_oakley_attr oakley; enum ikev1_ipsec_attr ipsec; } type; unsigned short val; }

user_defined_types: struct db_context { struct db_prop prop; struct db_trans *trans0; struct db_trans *trans_cur; struct db_attr *attrs0; struct db_attr *attrs_cur; int max_trans; int max_attrs; }

user_defined_types: struct db_prop { unsigned char protoid; struct db_trans *trans; unsigned int trans_cnt; }


original_code:
static void db_trans_expand(struct db_context *ctx, int delta_trans)
{
 int max_trans = ctx->max_trans + delta_trans;
 struct db_trans *const old_trans = ctx->trans0;
 struct db_trans *const new_trans = alloc_bytes_st(sizeof(struct db_trans) * max_trans, "db_context->trans (expand)", &(db_trans_st));;
 memcpy(new_trans, old_trans, ctx->max_trans * sizeof(struct db_trans));
 ctx->trans0 = ctx->prop.trans = new_trans;
 ctx->trans_cur = ctx->trans_cur - old_trans + new_trans;
 ctx->max_trans = max_trans;
 if (old_trans != ((void *)0))
  { db_trans_st.st_curr_cnt--; pfree(old_trans); };
}

canonical_original_code:
static void db_trans_expand(struct db_context *ctx, int delta_trans)
{
 int max_trans = ctx->max_trans + delta_trans;
 struct db_trans *old_trans = ctx->trans0;
 struct db_trans *new_trans = alloc_bytes_st(sizeof(struct db_trans) * max_trans, "db_context->trans (expand)", &(db_trans_st));;
 memcpy(new_trans, old_trans, ctx->max_trans * sizeof(struct db_trans));
 ctx->trans0 = ctx->prop.trans = new_trans;
 ctx->trans_cur = ctx->trans_cur - old_trans + new_trans;
 ctx->max_trans = max_trans;
 if (old_trans != ((void *)0))
  { db_trans_st.st_curr_cnt--; pfree(old_trans); };
}

variable_types: struct db_trans { unsigned short transid; struct db_attr { union { enum ikev1_oakley_attr { OAKLEY_ATTR_undefined=0, OAKLEY_ENCRYPTION_ALGORITHM=1, OAKLEY_HASH_ALGORITHM=2, OAKLEY_AUTHENTICATION_METHOD=3, OAKLEY_GROUP_DESCRIPTION=4, OAKLEY_GROUP_TYPE=5, OAKLEY_GROUP_PRIME=6, OAKLEY_GROUP_GENERATOR_ONE=7, OAKLEY_GROUP_GENERATOR_TWO=8, OAKLEY_GROUP_CURVE_A=9, OAKLEY_GROUP_CURVE_B=10, OAKLEY_LIFE_TYPE=11, OAKLEY_LIFE_DURATION=12, OAKLEY_PRF=13, OAKLEY_KEY_LENGTH=14, OAKLEY_FIELD_SIZE=15, OAKLEY_GROUP_ORDER=16 } oakley; enum ikev1_ipsec_attr { SA_LIFE_TYPE=1, SA_LIFE_DURATION=2, GROUP_DESCRIPTION=3, ENCAPSULATION_MODE=4, AUTH_ALGORITHM=5, KEY_LENGTH=6, KEY_ROUNDS=7, COMPRESS_DICT_SIZE=8, COMPRESS_PRIVATE_ALG=9, ECN_TUNNEL=10, ECN_TUNNEL_or_old_SECCTX=expr, ESN_64BIT_SEQNUM=11, IKEv1_IPSEC_ATTR_UNSPEC_12=12, SIG_ENC_ALGO_VAL=13, ADDRESS_PRESERVATION=14, SA_DIRECTION=15, IPSEC_ATTR_VAL_DESCS_ROOF=16, SECCTX=32001 } ipsec; } type; unsigned short val; } *attrs; unsigned int attr_cnt; } *


original_code:
static void db_attrs_expand(struct db_context *ctx, int delta_attrs)
{
 unsigned int ti;
 int max_attrs = ctx->max_attrs + delta_attrs;
 struct db_attr *const old_attrs = ctx->attrs0;
 struct db_attr *const new_attrs = alloc_bytes_st(sizeof(struct db_attr) * max_attrs, "db_context->attrs (expand)", &(db_attrs_st));;
 memcpy(new_attrs, old_attrs, ctx->max_attrs * sizeof(struct db_attr));
 ctx->attrs0 = ctx->attrs0 - old_attrs + new_attrs;
 ctx->attrs_cur = ctx->attrs_cur - old_attrs + new_attrs;
 for (ti = 0; ti < ctx->prop.trans_cnt; ti++)
  ctx->prop.trans[ti].attrs = ctx->prop.trans[ti].attrs - old_attrs + new_attrs;
 ctx->max_attrs = max_attrs;
 if (old_attrs != ((void *)0))
  { db_attrs_st.st_curr_cnt--; pfree(old_attrs); };
}

canonical_original_code:
static void db_attrs_expand(struct db_context *ctx, int delta_attrs)
{
 unsigned int ti;
 int max_attrs = ctx->max_attrs + delta_attrs;
 struct db_attr *old_attrs = ctx->attrs0;
 struct db_attr *new_attrs = alloc_bytes_st(sizeof(struct db_attr) * max_attrs, "db_context->attrs (expand)", &(db_attrs_st));;
 memcpy(new_attrs, old_attrs, ctx->max_attrs * sizeof(struct db_attr));
 ctx->attrs0 = ctx->attrs0 - old_attrs + new_attrs;
 ctx->attrs_cur = ctx->attrs_cur - old_attrs + new_attrs;
 for (ti = 0; ti < ctx->prop.trans_cnt; ti++)
  ctx->prop.trans[ti].attrs = ctx->prop.trans[ti].attrs - old_attrs + new_attrs;
 ctx->max_attrs = max_attrs;
 if (old_attrs != ((void *)0))
  { db_attrs_st.st_curr_cnt--; pfree(old_attrs); };
}

variable_types:
ti
unsigned int

variable_types: struct db_attr { union { enum ikev1_oakley_attr { OAKLEY_ATTR_undefined=0, OAKLEY_ENCRYPTION_ALGORITHM=1, OAKLEY_HASH_ALGORITHM=2, OAKLEY_AUTHENTICATION_METHOD=3, OAKLEY_GROUP_DESCRIPTION=4, OAKLEY_GROUP_TYPE=5, OAKLEY_GROUP_PRIME=6, OAKLEY_GROUP_GENERATOR_ONE=7, OAKLEY_GROUP_GENERATOR_TWO=8, OAKLEY_GROUP_CURVE_A=9, OAKLEY_GROUP_CURVE_B=10, OAKLEY_LIFE_TYPE=11, OAKLEY_LIFE_DURATION=12, OAKLEY_PRF=13, OAKLEY_KEY_LENGTH=14, OAKLEY_FIELD_SIZE=15, OAKLEY_GROUP_ORDER=16 } oakley; enum ikev1_ipsec_attr { SA_LIFE_TYPE=1, SA_LIFE_DURATION=2, GROUP_DESCRIPTION=3, ENCAPSULATION_MODE=4, AUTH_ALGORITHM=5, KEY_LENGTH=6, KEY_ROUNDS=7, COMPRESS_DICT_SIZE=8, COMPRESS_PRIVATE_ALG=9, ECN_TUNNEL=10, ECN_TUNNEL_or_old_SECCTX=expr, ESN_64BIT_SEQNUM=11, IKEv1_IPSEC_ATTR_UNSPEC_12=12, SIG_ENC_ALGO_VAL=13, ADDRESS_PRESERVATION=14, SA_DIRECTION=15, IPSEC_ATTR_VAL_DESCS_ROOF=16, SECCTX=32001 } ipsec; } type; unsigned short val; } *


original_code:
static void db_attr_add(struct db_context *ctx, const struct db_attr *a)
{
 if ((ctx->attrs_cur - ctx->attrs0) >= ctx->max_attrs) {
  db_attrs_expand(ctx, ctx->max_attrs / 2 + 1);
 }
 *ctx->attrs_cur++ = *a;
 ctx->trans_cur->attr_cnt++;
}

canonical_original_code:
static void db_attr_add(struct db_context *ctx, struct db_attr *a)
{
 if ((ctx->attrs_cur - ctx->attrs0) >= ctx->max_attrs) {
  db_attrs_expand(ctx, ctx->max_attrs / 2 + 1);
 }
 *ctx->attrs_cur++ = *a;
 ctx->trans_cur->attr_cnt++;
}

variable_types:
a
struct db_attr *

user_defined_types: enum ikev1_oakley_attr { OAKLEY_ATTR_undefined=0, OAKLEY_ENCRYPTION_ALGORITHM=1, OAKLEY_HASH_ALGORITHM=2, OAKLEY_AUTHENTICATION_METHOD=3, OAKLEY_GROUP_DESCRIPTION=4, OAKLEY_GROUP_TYPE=5, OAKLEY_GROUP_PRIME=6, OAKLEY_GROUP_GENERATOR_ONE=7, OAKLEY_GROUP_GENERATOR_TWO=8, OAKLEY_GROUP_CURVE_A=9, OAKLEY_GROUP_CURVE_B=10, OAKLEY_LIFE_TYPE=11, OAKLEY_LIFE_DURATION=12, OAKLEY_PRF=13, OAKLEY_KEY_LENGTH=14, OAKLEY_FIELD_SIZE=15, OAKLEY_GROUP_ORDER=16 }

user_defined_types: enum ikev1_ipsec_attr { SA_LIFE_TYPE=1, SA_LIFE_DURATION=2, GROUP_DESCRIPTION=3, ENCAPSULATION_MODE=4, AUTH_ALGORITHM=5, KEY_LENGTH=6, KEY_ROUNDS=7, COMPRESS_DICT_SIZE=8, COMPRESS_PRIVATE_ALG=9, ECN_TUNNEL=10, ECN_TUNNEL_or_old_SECCTX=expr, ESN_64BIT_SEQNUM=11, IKEv1_IPSEC_ATTR_UNSPEC_12=12, SIG_ENC_ALGO_VAL=13, ADDRESS_PRESERVATION=14, SA_DIRECTION=15, IPSEC_ATTR_VAL_DESCS_ROOF=16, SECCTX=32001 }


decompiled_code:
__int64 __fastcall db_prop_new(char a1, int a2, int a3)
{
__int64 v4; // r12

v4 = alloc_bytes_st(0x40uLL, (__int64)"db_context", (__int64)&db_context_st);
db_prop_init(v4, a1, a2, a3);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func5(char a1, int a2, int a3)
{
__int64 v4; // r12

v4 = func0(0x40uLL, (__int64)"db_context", (__int64)&db_context_st);
func1(v4, a1, a2, a3);
return v4;
}

original_code:
struct db_context *db_prop_new(uint8_t protoid, int max_trans, int max_attrs)
{
 struct db_context *ctx = alloc_bytes_st(sizeof(struct db_context), "db_context", &(db_context_st));;
 db_prop_init(ctx, protoid, max_trans, max_attrs);
 return ctx;
}

canonical_original_code:
struct db_context *db_prop_new(unsigned char protoid, int max_trans, int max_attrs)
{
 struct db_context *ctx = alloc_bytes_st(sizeof(struct db_context), "db_context", &(db_context_st));;
 db_prop_init(ctx, protoid, max_trans, max_attrs);
 return ctx;
}

return_type: struct db_context { struct db_prop { unsigned char protoid; struct db_trans { unsigned short transid; struct db_attr { union { enum ikev1_oakley_attr { OAKLEY_ATTR_undefined=0, OAKLEY_ENCRYPTION_ALGORITHM=1, OAKLEY_HASH_ALGORITHM=2, OAKLEY_AUTHENTICATION_METHOD=3, OAKLEY_GROUP_DESCRIPTION=4, OAKLEY_GROUP_TYPE=5, OAKLEY_GROUP_PRIME=6, OAKLEY_GROUP_GENERATOR_ONE=7, OAKLEY_GROUP_GENERATOR_TWO=8, OAKLEY_GROUP_CURVE_A=9, OAKLEY_GROUP_CURVE_B=10, OAKLEY_LIFE_TYPE=11, OAKLEY_LIFE_DURATION=12, OAKLEY_PRF=13, OAKLEY_KEY_LENGTH=14, OAKLEY_FIELD_SIZE=15, OAKLEY_GROUP_ORDER=16 } oakley; enum ikev1_ipsec_attr { SA_LIFE_TYPE=1, SA_LIFE_DURATION=2, GROUP_DESCRIPTION=3, ENCAPSULATION_MODE=4, AUTH_ALGORITHM=5, KEY_LENGTH=6, KEY_ROUNDS=7, COMPRESS_DICT_SIZE=8, COMPRESS_PRIVATE_ALG=9, ECN_TUNNEL=10, ECN_TUNNEL_or_old_SECCTX=expr, ESN_64BIT_SEQNUM=11, IKEv1_IPSEC_ATTR_UNSPEC_12=12, SIG_ENC_ALGO_VAL=13, ADDRESS_PRESERVATION=14, SA_DIRECTION=15, IPSEC_ATTR_VAL_DESCS_ROOF=16, SECCTX=32001 } ipsec; } type; unsigned short val; } *attrs; unsigned int attr_cnt; } *trans; unsigned int trans_cnt; } prop; struct db_trans *trans0; struct db_trans *trans_cur; struct db_attr *attrs0; struct db_attr *attrs_cur; int max_trans; int max_attrs; } *


decompiled_code:
__int64 __fastcall db_destroy(__int64 a1)
{
__int64 v2; // rdi
__int64 v3; // rdi

v2 = *(_QWORD *)(a1 + 24);
if ( v2 )
{
--db_trans_st;
pfree(v2);
}
v3 = *(_QWORD *)(a1 + 40);
if ( v3 )
{
--db_attrs_st;
pfree(v3);
}
--db_context_st;
return pfree(a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 v2; // rdi
__int64 v3; // rdi

v2 = *(_QWORD *)(a1 + 24);
if ( v2 )
{
--db_trans_st;
pfree(v2);
}
v3 = *(_QWORD *)(a1 + 40);
if ( v3 )
{
--db_attrs_st;
pfree(v3);
}
--db_context_st;
return pfree(a1);
}

original_code:
void db_destroy(struct db_context *ctx)
{
 if (ctx->trans0 != ((void *)0))
  { db_trans_st.st_curr_cnt--; pfree(ctx->trans0); };
 if (ctx->attrs0 != ((void *)0))
  { db_attrs_st.st_curr_cnt--; pfree(ctx->attrs0); };
 { db_context_st.st_curr_cnt--; pfree(ctx); };
}


decompiled_code:
unsigned __int64 __fastcall db_attr_add_values(__int64 a1, int a2, __int16 a3)
{
__int64 v4; // [rsp+0h] [rbp-18h] BYREF
unsigned __int64 v5; // [rsp+8h] [rbp-10h]

v5 = __readfsqword(0x28u);
LODWORD(v4) = a2;
WORD2(v4) = a3;
db_attr_add(a1, &v4);
return v5 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func8(__int64 a1, int a2, __int16 a3)
{
__int64 v4; // [rsp+0h] [rbp-18h] BYREF
unsigned __int64 v5; // [rsp+8h] [rbp-10h]

v5 = __readfsqword(0x28u);
LODWORD(v4) = a2;
WORD2(v4) = a3;
func4(a1, &v4);
return v5 - __readfsqword(0x28u);
}

original_code:
void db_attr_add_values(struct db_context *ctx, enum ikev1_ipsec_attr type, uint16_t val)
{
 struct db_attr attr;
 attr.type.ipsec = type;
 attr.val = val;
 db_attr_add(ctx, &attr);
}

canonical_original_code:
void db_attr_add_values(struct db_context *ctx, enum ikev1_ipsec_attr type, unsigned short val)
{
 struct db_attr attr;
 attr.type.ipsec = type;
 attr.val = val;
 db_attr_add(ctx, &attr);
}

variable_types:
val
unsigned short

variable_types: struct db_attr { union { enum ikev1_oakley_attr { OAKLEY_ATTR_undefined=0, OAKLEY_ENCRYPTION_ALGORITHM=1, OAKLEY_HASH_ALGORITHM=2, OAKLEY_AUTHENTICATION_METHOD=3, OAKLEY_GROUP_DESCRIPTION=4, OAKLEY_GROUP_TYPE=5, OAKLEY_GROUP_PRIME=6, OAKLEY_GROUP_GENERATOR_ONE=7, OAKLEY_GROUP_GENERATOR_TWO=8, OAKLEY_GROUP_CURVE_A=9, OAKLEY_GROUP_CURVE_B=10, OAKLEY_LIFE_TYPE=11, OAKLEY_LIFE_DURATION=12, OAKLEY_PRF=13, OAKLEY_KEY_LENGTH=14, OAKLEY_FIELD_SIZE=15, OAKLEY_GROUP_ORDER=16 } oakley; enum ikev1_ipsec_attr { SA_LIFE_TYPE=1, SA_LIFE_DURATION=2, GROUP_DESCRIPTION=3, ENCAPSULATION_MODE=4, AUTH_ALGORITHM=5, KEY_LENGTH=6, KEY_ROUNDS=7, COMPRESS_DICT_SIZE=8, COMPRESS_PRIVATE_ALG=9, ECN_TUNNEL=10, ECN_TUNNEL_or_old_SECCTX=expr, ESN_64BIT_SEQNUM=11, IKEv1_IPSEC_ATTR_UNSPEC_12=12, SIG_ENC_ALGO_VAL=13, ADDRESS_PRESERVATION=14, SA_DIRECTION=15, IPSEC_ATTR_VAL_DESCS_ROOF=16, SECCTX=32001 } ipsec; } type; unsigned short val; }


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

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

original_code:
struct db_prop *db_prop_get(struct db_context *ctx)
{
 return &ctx->prop;
}

variable_types: struct db_context { struct db_prop prop; struct db_trans *trans0; struct db_trans *trans_cur; struct db_attr *attrs0; struct db_attr *attrs_cur; int max_trans; int max_attrs; } *

return_type: struct db_prop { unsigned char protoid; struct db_trans { unsigned short transid; struct db_attr { union { enum ikev1_oakley_attr { OAKLEY_ATTR_undefined=0, OAKLEY_ENCRYPTION_ALGORITHM=1, OAKLEY_HASH_ALGORITHM=2, OAKLEY_AUTHENTICATION_METHOD=3, OAKLEY_GROUP_DESCRIPTION=4, OAKLEY_GROUP_TYPE=5, OAKLEY_GROUP_PRIME=6, OAKLEY_GROUP_GENERATOR_ONE=7, OAKLEY_GROUP_GENERATOR_TWO=8, OAKLEY_GROUP_CURVE_A=9, OAKLEY_GROUP_CURVE_B=10, OAKLEY_LIFE_TYPE=11, OAKLEY_LIFE_DURATION=12, OAKLEY_PRF=13, OAKLEY_KEY_LENGTH=14, OAKLEY_FIELD_SIZE=15, OAKLEY_GROUP_ORDER=16 } oakley; enum ikev1_ipsec_attr { SA_LIFE_TYPE=1, SA_LIFE_DURATION=2, GROUP_DESCRIPTION=3, ENCAPSULATION_MODE=4, AUTH_ALGORITHM=5, KEY_LENGTH=6, KEY_ROUNDS=7, COMPRESS_DICT_SIZE=8, COMPRESS_PRIVATE_ALG=9, ECN_TUNNEL=10, ECN_TUNNEL_or_old_SECCTX=expr, ESN_64BIT_SEQNUM=11, IKEv1_IPSEC_ATTR_UNSPEC_12=12, SIG_ENC_ALGO_VAL=13, ADDRESS_PRESERVATION=14, SA_DIRECTION=15, IPSEC_ATTR_VAL_DESCS_ROOF=16, SECCTX=32001 } ipsec; } type; unsigned short val; } *attrs; unsigned int attr_cnt; } *trans; unsigned int trans_cnt; } *


decompiled_code:
__int64 __fastcall jam_sanitized_char(__int64 a1, unsigned __int8 a2, unsigned int a3)
{
const char *v4; // rsi
__int64 result; // rax

switch ( a2 )
{
case 0u:
result = jam_string(a1, &LC0);
break;
case 7u:
result = jam_string(a1, &LC1);
break;
case 8u:
result = jam_string(a1, &LC2);
break;
case 9u:
result = jam_string(a1, &LC3);
break;
case 0xAu:
result = jam_string(a1, &LC4);
break;
case 0xBu:
result = jam_string(a1, &LC5);
break;
case 0xCu:
result = jam_string(a1, &LC6);
break;
case 0xDu:
result = jam_string(a1, &LC7);
break;
default:
if ( (unsigned __int8)char_isprint((unsigned int)(char)a2) )
{
result = jam_char(a1, (unsigned int)(char)a2, a3);
}
else
{
if ( (unsigned __int8)char_isdigit((unsigned int)(char)a3) )
v4 = "\\%03o";
else
v4 = "\\%o";
result = jam(a1, v4, a2);
}
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned __int8 a2, unsigned int a3)
{
const char *v4; // rsi
__int64 result; // rax

switch ( a2 )
{
case 0u:
result = jam_string(a1, &LC0);
break;
case 7u:
result = jam_string(a1, &LC1);
break;
case 8u:
result = jam_string(a1, &LC2);
break;
case 9u:
result = jam_string(a1, &LC3);
break;
case 0xAu:
result = jam_string(a1, &LC4);
break;
case 0xBu:
result = jam_string(a1, &LC5);
break;
case 0xCu:
result = jam_string(a1, &LC6);
break;
case 0xDu:
result = jam_string(a1, &LC7);
break;
default:
if ( (unsigned __int8)char_isprint((unsigned int)(char)a2) )
{
result = jam_char(a1, (unsigned int)(char)a2, a3);
}
else
{
if ( (unsigned __int8)char_isdigit((unsigned int)(char)a3) )
v4 = "\\%03o";
else
v4 = "\\%o";
result = jam(a1, v4, a2);
}
break;
}
return result;
}

original_code:
static size_t jam_sanitized_char(struct jambuf *buf, char c, char c1)
{
 switch (c) {
 case '\0': return jam_string(buf, "\\0");
 case '\a': return jam_string(buf, "\\a");
 case '\b': return jam_string(buf, "\\b");
 case '\t': return jam_string(buf, "\\t");
 case '\n': return jam_string(buf, "\\n");
 case '\v': return jam_string(buf, "\\v");
 case '\f': return jam_string(buf, "\\f");
 case '\r': return jam_string(buf, "\\r");
 }
 if (char_isprint(c)) {
  return jam_char(buf, c);
 }
 if (char_isdigit(c1)) {
  return jam(buf, "\\%03o", c & 0xFF);
 }
 return jam(buf, "\\%o", c & 0xFF);
}

canonical_original_code:
static unsigned long jam_sanitized_char(struct jambuf *buf, char c, char c1)
{
 switch (c) {
 case '\0': return jam_string(buf, "\\0");
 case '\a': return jam_string(buf, "\\a");
 case '\b': return jam_string(buf, "\\b");
 case '\t': return jam_string(buf, "\\t");
 case '\n': return jam_string(buf, "\\n");
 case '\v': return jam_string(buf, "\\v");
 case '\f': return jam_string(buf, "\\f");
 case '\r': return jam_string(buf, "\\r");
 }
 if (char_isprint(c)) {
  return jam_char(buf, c);
 }
 if (char_isdigit(c1)) {
  return jam(buf, "\\%03o", c & 0xFF);
 }
 return jam(buf, "\\%o", c & 0xFF);
}

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


decompiled_code:
__int64 __fastcall jam_hex_bytes(__int64 a1, __int64 a2, unsigned __int64 a3)
{
__int64 v3; // rax
unsigned int v5; // er15
__int64 v6; // r12

v3 = 0LL;
if ( !a3 )
return 0LL;
v5 = 0;
v6 = 0LL;
do
{
v6 += jam(a1, "%02x", *(unsigned __int8 *)(a2 + v3));
v3 = ++v5;
}
while ( v5 < a3 );
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, unsigned __int64 a3)
{
__int64 v3; // rax
unsigned int v5; // er15
__int64 v6; // r12

v3 = 0LL;
if ( !a3 )
return 0LL;
v5 = 0;
v6 = 0LL;
do
{
v6 += jam(a1, "%02x", *(unsigned __int8 *)(a2 + v3));
v3 = ++v5;
}
while ( v5 < a3 );
return v6;
}

original_code:
size_t jam_hex_bytes(struct jambuf *buf, const void *ptr, size_t size)
{
 size_t n = 0;
 const uint8_t *bytes = ptr;
 for (unsigned i = 0; i < size; i++) {
  n += jam(buf, "%02x", bytes[i]);
 }
 return n;
}

canonical_original_code:
unsigned long jam_hex_bytes(struct jambuf *buf, void *ptr, unsigned long size)
{
 unsigned long n = 0;
 unsigned char *bytes = ptr;
 for (unsigned int i = 0; i < size; i++) {
  n += jam(buf, "%02x", bytes[i]);
 }
 return n;
}

variable_types:
size
unsigned long

variable_types:
bytes
unsigned char *

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall jam_HEX_bytes(__int64 a1, __int64 a2, unsigned __int64 a3)
{
__int64 v3; // rax
unsigned int v5; // er15
__int64 v6; // r12

v3 = 0LL;
if ( !a3 )
return 0LL;
v5 = 0;
v6 = 0LL;
do
{
v6 += jam(a1, "%02X", *(unsigned __int8 *)(a2 + v3));
v3 = ++v5;
}
while ( v5 < a3 );
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, unsigned __int64 a3)
{
__int64 v3; // rax
unsigned int v5; // er15
__int64 v6; // r12

v3 = 0LL;
if ( !a3 )
return 0LL;
v5 = 0;
v6 = 0LL;
do
{
v6 += jam(a1, "%02X", *(unsigned __int8 *)(a2 + v3));
v3 = ++v5;
}
while ( v5 < a3 );
return v6;
}

original_code:
size_t jam_HEX_bytes(struct jambuf *buf, const void *ptr, size_t size)
{
 size_t n = 0;
 const uint8_t *bytes = ptr;
 for (unsigned i = 0; i < size; i++) {
  n += jam(buf, "%02X", bytes[i]);
 }
 return n;
}

canonical_original_code:
unsigned long jam_HEX_bytes(struct jambuf *buf, void *ptr, unsigned long size)
{
 unsigned long n = 0;
 unsigned char *bytes = ptr;
 for (unsigned int i = 0; i < size; i++) {
  n += jam(buf, "%02X", bytes[i]);
 }
 return n;
}

variable_types:
n
unsigned long


decompiled_code:
__int64 __fastcall jam_dump_bytes(__int64 a1, unsigned __int8 *a2, __int64 a3)
{
unsigned __int8 *v3; // rbx
unsigned __int64 v4; // r13
const char *v5; // rdx
__int64 v6; // r12
unsigned int v7; // ebp
__int64 v8; // rcx
__int64 v9; // rax

if ( !a3 )
return 0LL;
v3 = a2;
if ( a2 )
{
v4 = (unsigned __int64)&a2[a3];
if ( a2 < &a2[a3] )
{
v5 = (const char *)&LC12;
v6 = 0LL;
while ( 1 )
{
v7 = 0;
while ( 1 )
{
v8 = *v3;
++v7;
++v3;
v9 = jam(a1, "%s%02x", v5, v8);
v5 = " ";
v6 += v9;
if ( v7 > 3 )
break;
if ( v4 <= (unsigned __int64)v3 )
return v6;
}
if ( v4 <= (unsigned __int64)v3 )
break;
v5 = " ";
}
return v6;
}
return 0LL;
}
return jam_string(a1, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned __int8 *a2, __int64 a3)
{
unsigned __int8 *v3; // rbx
unsigned __int64 v4; // r13
const char *v5; // rdx
__int64 v6; // r12
unsigned int v7; // ebp
__int64 v8; // rcx
__int64 v9; // rax

if ( !a3 )
return 0LL;
v3 = a2;
if ( a2 )
{
v4 = (unsigned __int64)&a2[a3];
if ( a2 < &a2[a3] )
{
v5 = (const char *)&LC12;
v6 = 0LL;
while ( 1 )
{
v7 = 0;
while ( 1 )
{
v8 = *v3;
++v7;
++v3;
v9 = jam(a1, "%s%02x", v5, v8);
v5 = " ";
v6 += v9;
if ( v7 > 3 )
break;
if ( v4 <= (unsigned __int64)v3 )
return v6;
}
if ( v4 <= (unsigned __int64)v3 )
break;
v5 = " ";
}
return v6;
}
return 0LL;
}
return jam_string(a1, 0LL);
}

original_code:
size_t jam_dump_bytes(struct jambuf *buf, const void *bytes, size_t size)
{
 if (size == 0) {
  return 0;
 } else if (bytes == ((void *)0)) {
  return jam_string(buf, ((void *)0));
 }
 size_t n = 0;
 const uint8_t *byte = bytes;
 const uint8_t *end = byte + size;
 const char *sep = "";
 while (byte < end) {
  for (unsigned b = 0; b < 4 && byte < end; b++) {
   n += jam(buf, "%s%02x", sep, *byte++);
   sep = " ";
  }
  sep = "  ";
 }
 return n;
}

canonical_original_code:
unsigned long jam_dump_bytes(struct jambuf *buf, void *bytes, unsigned long size)
{
 if (size == 0) {
  return 0;
 } else if (bytes == ((void *)0)) {
  return jam_string(buf, ((void *)0));
 }
 unsigned long n = 0;
 unsigned char *byte = bytes;
 unsigned char *end = byte + size;
 char *sep = "";
 while (byte < end) {
  for (unsigned int b = 0; b < 4 && byte < end; b++) {
   n += jam(buf, "%s%02x", sep, *byte++);
   sep = " ";
  }
  sep = "  ";
 }
 return n;
}

variable_types:
bytes
void *

variable_types:
byte
unsigned char *

variable_types:
end
unsigned char *

variable_types:
sep
char *

variable_types:
b
unsigned int


decompiled_code:
__int64 __fastcall jam_sanitized_bytes(__int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned int v5; // ebp
__int64 v6; // r12
__int64 v7; // rbx
unsigned __int8 v8; // si

if ( !a3 )
return 0LL;
v5 = 0;
v6 = 0LL;
v7 = 0LL;
while ( 1 )
{
v8 = *(_BYTE *)(a2 + v7);
v7 = ++v5;
if ( v5 == a3 )
break;
v6 += jam_sanitized_char(a1, v8, *(char *)(a2 + v5));
if ( v5 >= a3 )
return v6;
}
v6 += jam_sanitized_char(a1, v8, 0);
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned int v5; // ebp
__int64 v6; // r12
__int64 v7; // rbx
unsigned __int8 v8; // si

if ( !a3 )
return 0LL;
v5 = 0;
v6 = 0LL;
v7 = 0LL;
while ( 1 )
{
v8 = *(_BYTE *)(a2 + v7);
v7 = ++v5;
if ( v5 == a3 )
break;
v6 += func0(a1, v8, *(char *)(a2 + v5));
if ( v5 >= a3 )
return v6;
}
v6 += func0(a1, v8, 0);
return v6;
}

original_code:
size_t jam_sanitized_bytes(struct jambuf *buf, const void *ptr, size_t size)
{
 size_t n = 0;
 const char *chars = ptr;
 for (unsigned i = 0; i < size; i++) {
  char c = chars[i];
  char c1 = (i + 1 == size ? '\0' : chars[i+1]);
  n += jam_sanitized_char(buf, c, c1);
 }
 return n;
}

canonical_original_code:
unsigned long jam_sanitized_bytes(struct jambuf *buf, void *ptr, unsigned long size)
{
 unsigned long n = 0;
 char *chars = ptr;
 for (unsigned int i = 0; i < size; i++) {
  char c = chars[i];
  char c1 = (i + 1 == size ? '\0' : chars[i+1]);
  n += jam_sanitized_char(buf, c, c1);
 }
 return n;
}

variable_types:
ptr
void *

variable_types:
chars
char *

variable_types: c char


decompiled_code:
__int64 __fastcall jam_shell_quoted_bytes(__int64 a1, __int64 a2, unsigned __int64 a3)
{
__int64 v3; // rax
unsigned int v6; // ebx
__int64 v7; // r12
unsigned int v8; // esi
__int64 v9; // rcx
__int64 v10; // rdx

v3 = 0LL;
if ( !a3 )
return 0LL;
v6 = 0;
v7 = 0LL;
do
{
while ( 1 )
{
v8 = *(char *)(a2 + v3);
if ( (unsigned __int8)(v8 - 34) <= 0x3Eu )
{
v9 = 0x4400000000000025LL;
if ( _bittest64(&v9, v8 - 34) )
break;
}
if ( !(unsigned __int8)char_isprint(v8) )
break;
v7 += jam_char(a1, v8, v10);
v3 = ++v6;
if ( v6 >= a3 )
return v7;
}
v7 += jam(a1, "\\%03o", (unsigned __int8)v8);
v3 = ++v6;
}
while ( v6 < a3 );
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, unsigned __int64 a3)
{
__int64 v3; // rax
unsigned int v6; // ebx
__int64 v7; // r12
unsigned int v8; // esi
__int64 v9; // rcx
__int64 v10; // rdx

v3 = 0LL;
if ( !a3 )
return 0LL;
v6 = 0;
v7 = 0LL;
do
{
while ( 1 )
{
v8 = *(char *)(a2 + v3);
if ( (unsigned __int8)(v8 - 34) <= 0x3Eu )
{
v9 = 0x4400000000000025LL;
if ( _bittest64(&v9, v8 - 34) )
break;
}
if ( !(unsigned __int8)char_isprint(v8) )
break;
v7 += jam_char(a1, v8, v10);
v3 = ++v6;
if ( v6 >= a3 )
return v7;
}
v7 += jam(a1, "\\%03o", (unsigned __int8)v8);
v3 = ++v6;
}
while ( v6 < a3 );
return v7;
}

original_code:
size_t jam_shell_quoted_bytes(struct jambuf *buf, const void *ptr, size_t size)
{
 size_t n = 0;
 const char *chars = ptr;
 for (unsigned i = 0; i < size; i++) {
  char c = chars[i];
  switch (c) {
  case '\'':
  case '\\':
  case '"':
  case '`':
  case '$':
   n += jam(buf, "\\%03o", c & 0xFF);
   break;
  default:
   if (char_isprint(c)) {
    n += jam_char(buf, c);
   } else {
    n += jam(buf, "\\%03o", c & 0xFF);
   }
   break;
  }
 }
 return n;
}

canonical_original_code:
unsigned long jam_shell_quoted_bytes(struct jambuf *buf, void *ptr, unsigned long size)
{
 unsigned long n = 0;
 char *chars = ptr;
 for (unsigned int i = 0; i < size; i++) {
  char c = chars[i];
  switch (c) {
  case '\'':
  case '\\':
  case '"':
  case '`':
  case '$':
   n += jam(buf, "\\%03o", c & 0xFF);
   break;
  default:
   if (char_isprint(c)) {
    n += jam_char(buf, c);
   } else {
    n += jam(buf, "\\%03o", c & 0xFF);
   }
   break;
  }
 }
 return n;
}


decompiled_code:
__int64 __fastcall jam_ucase_bytes(__int64 a1, __int64 a2, unsigned __int64 a3)
{
int v4; // ebp
__int64 v5; // r12
unsigned __int64 v6; // rbx
unsigned int v7; // edx
unsigned int v8; // er14
char v9; // al
__int64 v10; // rdx

if ( !a3 )
return 0LL;
v4 = 0;
v5 = 0LL;
v6 = 0LL;
do
{
while ( 1 )
{
v8 = *(char *)(a2 + v6);
v6 = (unsigned int)++v4;
if ( !(unsigned __int8)char_islower(v8) )
break;
v9 = char_toupper(v8);
v5 += jam_char(a1, (unsigned int)v9, v10);
if ( a3 <= v6 )
return v5;
}
v7 = 0;
if ( a3 != v6 )
v7 = *(char *)(a2 + v6);
v5 += jam_sanitized_char(a1, v8, v7);
}
while ( a3 > v6 );
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, unsigned __int64 a3)
{
int v4; // ebp
__int64 v5; // r12
unsigned __int64 v6; // rbx
unsigned int v7; // edx
unsigned int v8; // er14
char v9; // al
__int64 v10; // rdx

if ( !a3 )
return 0LL;
v4 = 0;
v5 = 0LL;
v6 = 0LL;
do
{
while ( 1 )
{
v8 = *(char *)(a2 + v6);
v6 = (unsigned int)++v4;
if ( !(unsigned __int8)char_islower(v8) )
break;
v9 = char_toupper(v8);
v5 += jam_char(a1, (unsigned int)v9, v10);
if ( a3 <= v6 )
return v5;
}
v7 = 0;
if ( a3 != v6 )
v7 = *(char *)(a2 + v6);
v5 += func0(a1, v8, v7);
}
while ( a3 > v6 );
return v5;
}

original_code:
size_t jam_ucase_bytes(struct jambuf *buf, const void *ptr, size_t size)
{
 size_t n = 0;
 const char *chars = ptr;
 for (unsigned i = 0; i < size; i++) {
  char c = chars[i];
  if (char_islower(c)) {
   n += jam_char(buf, char_toupper(c));
  } else {
   char c1 = (i + 1 == size ? '\0' : chars[i+1]);
   n += jam_sanitized_char(buf, c, c1);
  }
 }
 return n;
}

canonical_original_code:
unsigned long jam_ucase_bytes(struct jambuf *buf, void *ptr, unsigned long size)
{
 unsigned long n = 0;
 char *chars = ptr;
 for (unsigned int i = 0; i < size; i++) {
  char c = chars[i];
  if (char_islower(c)) {
   n += jam_char(buf, char_toupper(c));
  } else {
   char c1 = (i + 1 == size ? '\0' : chars[i+1]);
   n += jam_sanitized_char(buf, c, c1);
  }
 }
 return n;
}


decompiled_code:
__int64 __fastcall jam_ucase_string(__int64 a1, const char *a2)
{
unsigned __int64 v2; // rdx

v2 = strlen(a2);
return jam_ucase_bytes(a1, (__int64)a2, v2);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, const char *a2)
{
unsigned __int64 v2; // rdx

v2 = strlen(a2);
return func6(a1, (__int64)a2, v2);
}

original_code:
size_t jam_ucase_string(struct jambuf *buf, const char *string)
{
 return jam_ucase_bytes(buf, string, strlen(string));
}

canonical_original_code:
unsigned long jam_ucase_string(struct jambuf *buf, char *string)
{
 return jam_ucase_bytes(buf, string, strlen(string));
}

variable_types:
string
char *


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

if ( a2 )
result = jam_lset_short(a1, &sa_policy_bit_names, &LC0, a2);
else
result = 0LL;
return result;
}

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

if ( a2 )
result = jam_lset_short(a1, &sa_policy_bit_names, &LC0, a2);
else
result = 0LL;
return result;
}

original_code:
size_t jam_policy(struct jambuf *buf, lset_t policy)
{
 size_t s = 0;
 if (policy != ((lset_t)0)) {
  s += jam_lset_short(buf, &sa_policy_bit_names, "+", policy);
 }
 return s;
}

canonical_original_code:
unsigned long jam_policy(struct jambuf *buf, unsigned long policy)
{
 unsigned long s = 0;
 if (policy != ((unsigned long)0)) {
  s += jam_lset_short(buf, &sa_policy_bit_names, "+", policy);
 }
 return s;
}

variable_types:
policy
unsigned long

variable_types:
s
unsigned long


decompiled_code:
__int64 __fastcall str_policy(__int64 a1, __int64 a2)
{
_QWORD v3[9]; // [rsp+0h] [rbp-48h] BYREF

v3[5] = __readfsqword(0x28u);
array_as_jambuf(v3, a2, 512LL);
jam_policy((__int64)v3, a1);
return a2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
_QWORD v3[9]; // [rsp+0h] [rbp-48h] BYREF

v3[5] = __readfsqword(0x28u);
array_as_jambuf(v3, a2, 512LL);
func0((__int64)v3, a1);
return a2;
}

original_code:
const char *str_policy(lset_t policy, policy_buf *dst)
{
 struct jambuf buf = array_as_jambuf((dst->buf), sizeof(dst->buf));
 jam_policy(&buf, policy);
 return dst->buf;
}

canonical_original_code:
char *str_policy(unsigned long policy, struct policy_buf *dst)
{
 struct jambuf buf = array_as_jambuf((dst->buf), sizeof(dst->buf));
 jam_policy(&buf, policy);
 return dst->buf;
}

variable_types:
dst
struct policy_buf { char buf[512]; } *

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


decompiled_code:
__int64 init_pluto_constants()
{
return check_enum_names(&pluto_enum_names_checklist, 15LL);
}

canonical_decompiled_code:
__int64 func3()
{
return check_enum_names(&pluto_enum_names_checklist, 15LL);
}

original_code:
void init_pluto_constants(void) {
 check_enum_names((pluto_enum_names_checklist), (sizeof(pluto_enum_names_checklist) / sizeof(*(pluto_enum_names_checklist))));
}

canonical_original_code:
void init_pluto_constants() {
 check_enum_names((pluto_enum_names_checklist), (sizeof(pluto_enum_names_checklist) / sizeof(*(pluto_enum_names_checklist))));
}


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

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

original_code:
_Bool suppress_object_log_false(const void *object __attribute__ ((unused)))
{
 return 0;
}

canonical_original_code:
_Bool suppress_object_log_false(void *object)
{
 return 0;
}

variable_types:
object
void *


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

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

original_code:
size_t jam_object_prefix_none(struct jambuf *buf __attribute__ ((unused)), const void *object __attribute__ ((unused)))
{
 return 0;
}

canonical_original_code:
unsigned long jam_object_prefix_none(struct jambuf *buf, void *object)
{
 return 0;
}

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


decompiled_code:
__int64 suppress_object_log_true()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 1LL;
}

original_code:
_Bool suppress_object_log_true(const void *object __attribute__ ((unused)))
{
 return 1;
}

canonical_original_code:
_Bool suppress_object_log_true(void *object)
{
 return 1;
}


decompiled_code:
__int64 __fastcall cmp_iface(const void *a1, const void *a2)
{
__int64 v2; // r13
__int64 v3; // rbp
int v4; // er12
__int64 v5; // rdx
unsigned int v6; // er12
__int64 v8; // rdx
__int64 v9; // rdx
__int64 v10; // rdx
__int64 v11; // rdx

v2 = *(_QWORD *)a1;
v3 = *(_QWORD *)a2;
v4 = *(_DWORD *)(address_type(*(_QWORD *)a1) + 336);
v6 = v4 - *(_DWORD *)(address_type(v3) + 336);
if ( !v6 )
{
if ( (unsigned __int8)address_is_loopback(v3, a2, v5) )
{
if ( !(unsigned __int8)address_is_loopback(v3, a2, v8) )
return -2 - ((unsigned int)((unsigned __int8)address_is_specified(v3, a2, v9) == 0) - 1);
}
else
{
v6 = ((unsigned __int8)address_is_specified(v3, a2, v8) == 0) + 1;
if ( (unsigned __int8)address_is_loopback(v3, a2, v10) )
return v6;
v6 -= ((unsigned __int8)address_is_specified(v3, a2, v11) == 0) + 1;
if ( v6 )
return v6;
}
v6 = strcmp((const char *)(v2 + 32), (const char *)(v3 + 32));
if ( !v6 )
{
v6 = addrcmp(v2, v3);
if ( !v6 && (cur_debugging & 1) != 0 )
DBG_log("interface sort not stable or duplicate");
}
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func1(const void *a1, const void *a2)
{
__int64 v2; // r13
__int64 v3; // rbp
int v4; // er12
__int64 v5; // rdx
unsigned int v6; // er12
__int64 v8; // rdx
__int64 v9; // rdx
__int64 v10; // rdx
__int64 v11; // rdx

v2 = *(_QWORD *)a1;
v3 = *(_QWORD *)a2;
v4 = *(_DWORD *)(address_type(*(_QWORD *)a1) + 336);
v6 = v4 - *(_DWORD *)(address_type(v3) + 336);
if ( !v6 )
{
if ( (unsigned __int8)address_is_loopback(v3, a2, v5) )
{
if ( !(unsigned __int8)address_is_loopback(v3, a2, v8) )
return -2 - ((unsigned int)((unsigned __int8)address_is_specified(v3, a2, v9) == 0) - 1);
}
else
{
v6 = ((unsigned __int8)address_is_specified(v3, a2, v8) == 0) + 1;
if ( (unsigned __int8)address_is_loopback(v3, a2, v10) )
return v6;
v6 -= ((unsigned __int8)address_is_specified(v3, a2, v11) == 0) + 1;
if ( v6 )
return v6;
}
v6 = strcmp((const char *)(v2 + 32), (const char *)(v3 + 32));
if ( !v6 )
{
v6 = addrcmp(v2, v3);
if ( !v6 && (cur_debugging & 1) != 0 )
DBG_log("interface sort not stable or duplicate");
}
}
return v6;
}

original_code:
static int cmp_iface(const void *lv, const void *rv)
{
 const struct raw_iface *const *ll = lv;
 const struct raw_iface *const *rr = rv;
 const struct raw_iface *l = *ll;
 const struct raw_iface *r = *rr;
 int i;
 i = address_type(&l->addr)->af - address_type(&r->addr)->af;
 if (i != 0) {
  return i;
 }
 i = (address_is_loopback(l->addr) ? 0 : address_is_specified(l->addr) ? 1 : 2) - (address_is_loopback(r->addr) ? 0 : address_is_specified(r->addr) ? 1 : 2);
 if (i != 0) {
  return i;
 }
 i = strcmp(l->name, r->name);
 if (i != 0) {
  return i;
 }
 i = addrcmp(&l->addr, &r->addr);
 if (i != 0) {
  return i;
 }
 { if ((cur_debugging & (((lset_t)1 << (DBG_BASE_IX))))) { DBG_log("interface sort not stable or duplicate"); } };
 return 0;
}

canonical_original_code:
static int cmp_iface(void *lv, void *rv)
{
 struct raw_iface **ll = lv;
 struct raw_iface **rr = rv;
 struct raw_iface *l = *ll;
 struct raw_iface *r = *rr;
 int i;
 i = address_type(&l->addr)->af - address_type(&r->addr)->af;
 if (i != 0) {
  return i;
 }
 i = (address_is_loopback(l->addr) ? 0 : address_is_specified(l->addr) ? 1 : 2) - (address_is_loopback(r->addr) ? 0 : address_is_specified(r->addr) ? 1 : 2);
 if (i != 0) {
  return i;
 }
 i = strcmp(l->name, r->name);
 if (i != 0) {
  return i;
 }
 i = addrcmp(&l->addr, &r->addr);
 if (i != 0) {
  return i;
 }
 { if ((cur_debugging & (((unsigned long)1 << (DBG_BASE_IX))))) { DBG_log("interface sort not stable or duplicate"); } };
 return 0;
}

variable_types:
lv
void *

variable_types:
rv
void *

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

variable_types: i int

user_defined_types: struct raw_iface { struct ip_address addr; struct raw_iface *next; char name[]; }

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


decompiled_code:
__int64 __fastcall said_is_unset(unsigned __int8 *a1)
{
__int64 result; // rax

if ( a1 )
result = *a1 ^ 1u;
else
result = 1LL;
return result;
}

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

if ( a1 )
result = *a1 ^ 1u;
else
result = 1LL;
return result;
}

original_code:
_Bool said_is_unset(const ip_said *said)
{
 if (said == ((void *)0)) {
  return 1;
 }
 return !said->is_set;
}

canonical_original_code:
_Bool said_is_unset(struct ip_said *said)
{
 if (said == ((void *)0)) {
  return 1;
 }
 return !said->is_set;
}

variable_types: struct ip_said { _Bool is_set; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes { unsigned char byte[16]; } dst; unsigned int ipproto; unsigned int spi; } *

user_defined_types: struct ip_said { _Bool is_set; enum ip_version version; struct ip_bytes dst; unsigned int ipproto; unsigned int spi; }


decompiled_code:
__int64 __fastcall said_info(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int128 a7)
{
__int64 result; // rax
__m128i v8; // [rsp+0h] [rbp-38h]

v8 = _mm_loadu_si128((const __m128i *)&a7);
if ( (_BYTE)a7 )
result = ip_version_info(v8.m128i_u32[1], a2, 0LL);
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int128 a7)
{
__int64 result; // rax
__m128i v8; // [rsp+0h] [rbp-38h]

v8 = _mm_loadu_si128((const __m128i *)&a7);
if ( (_BYTE)a7 )
result = ip_version_info(v8.m128i_u32[1], a2, 0LL);
else
result = 0LL;
return result;
}

original_code:
const struct ip_info *said_info(const ip_said said)
{
 if (!said.is_set) {
  return ((void *)0);
 }
 return ip_version_info(said.version);
}

canonical_original_code:
struct ip_info *said_info(struct ip_said said)
{
 if (!said.is_set) {
  return ((void *)0);
 }
 return ip_version_info(said.version);
}

variable_types: struct ip_said { _Bool is_set; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes dst; unsigned int ipproto; unsigned int spi; }

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_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_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 said_type(const __m128i *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 result; // rax

if ( a1 )
result = said_info((__int64)a1, a2, a3, a4, a5, a6, *(_OWORD *)&_mm_loadu_si128(a1));
else
result = 0LL;
return result;
}

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

if ( a1 )
result = func4((__int64)a1, a2, a3, a4, a5, a6, *(_OWORD *)&_mm_loadu_si128(a1));
else
result = 0LL;
return result;
}

original_code:
const struct ip_info *said_type(const ip_said *said)
{
 if (said == ((void *)0)) {
  return ((void *)0);
 }
 return said_info(*said);
}

canonical_original_code:
struct ip_info *said_type(struct ip_said *said)
{
 if (said == ((void *)0)) {
  return ((void *)0);
 }
 return said_info(*said);
}

variable_types: struct ip_said { _Bool is_set; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes dst; unsigned int ipproto; unsigned int spi; } *

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 str_said(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, 72LL);
jam_said((__int64)v7, a1, v2, v3, v4, v5);
return a2;
}

original_code:
const char *str_said(const ip_said *said, said_buf *buf)
{
 struct jambuf b = array_as_jambuf((buf->buf), sizeof(buf->buf));
 jam_said(&b, said);
 return buf->buf;
}

canonical_original_code:
char *str_said(struct ip_said *said, struct said_buf *buf)
{
 struct jambuf b = array_as_jambuf((buf->buf), sizeof(buf->buf));
 jam_said(&b, said);
 return buf->buf;
}

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


decompiled_code:
unsigned __int64 __fastcall unpack_nonce(__m128i *a1, __m128i *a2)
{
__m128i v2; // xmm1
unsigned __int64 v4; // [rsp+8h] [rbp-20h]

v4 = __readfsqword(0x28u);
free_chunk_content();
v2 = _mm_loadu_si128(&empty_chunk);
*a1 = _mm_loadu_si128(a2);
*a2 = v2;
return v4 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(__m128i *a1, __m128i *a2)
{
__m128i v2; // xmm1
unsigned __int64 v4; // [rsp+8h] [rbp-20h]

v4 = __readfsqword(0x28u);
free_chunk_content();
v2 = _mm_loadu_si128(&empty_chunk);
*a1 = _mm_loadu_si128(a2);
*a2 = v2;
return v4 - __readfsqword(0x28u);
}

original_code:
void unpack_nonce(chunk_t *n, chunk_t *nonce)
{
 free_chunk_content(n);
 *n = *nonce;
 *nonce = empty_chunk;
}

canonical_original_code:
void unpack_nonce(struct chunk_t *n, struct chunk_t *nonce)
{
 free_chunk_content(n);
 *n = *nonce;
 *nonce = empty_chunk;
}

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

variable_types:
nonce
struct chunk_t *


trydotted

decompiled_code:
const char *__fastcall trydotted(__int64 a1, __int64 a2, __m128i *a3)
{
__int64 v4; // rbx
__int64 v5; // rdx
__int64 v6; // rdi
const char *v7; // r8
unsigned __int64 v8; // rax
unsigned int v10; // edx
__int64 v11; // rcx
__m128i v12; // xmm1
__m128i v13; // [rsp+0h] [rbp-88h] BYREF
__int64 v14; // [rsp+10h] [rbp-78h]
unsigned __int64 v15; // [rsp+28h] [rbp-60h] BYREF
__int64 v16; // [rsp+30h] [rbp-58h] BYREF
__int64 v17; // [rsp+38h] [rbp-50h]
__m128i v18; // [rsp+40h] [rbp-48h]
unsigned __int64 v19; // [rsp+58h] [rbp-30h]

v4 = 0LL;
v19 = __readfsqword(0x28u);
v16 = a1;
v17 = a2;
v18 = _mm_loadu_si128(&unset_ip_bytes);
while ( 1 )
{
if ( !v16 )
goto LABEL_17;
v6 = shunk_token(&v16, 0LL, ".");
if ( !v5 )
return "empty dotted-numeric address field";
v7 = (const char *)shunk_to_uintmax(v6, v5, 0LL, 0LL, &v15);
if ( v7 )
return v7;
v8 = v15;
if ( !v17 && (_DWORD)v4 )
{
v10 = 3;
while ( v8 )
{
v11 = v10--;
v18.m128i_i8[v11] = v8;
v8 >>= 8;
if ( v10 < (unsigned int)v4 )
{
v15 = v8;
v7 = "overflow in dotted-numeric address";
if ( v8 )
return v7;
break;
}
}
LABEL_9:
if ( v16 )
return "garbage at end of dotted-address";
LABEL_17:
address_from_raw(&v13, here_1, ip_families[0], v18.m128i_i64[0], v18.m128i_i64[1]);
v12 = _mm_loadu_si128(&v13);
v7 = 0LL;
a3[1].m128i_i64[0] = v14;
*a3 = v12;
return v7;
}
if ( v15 > 0xFF )
return "byte overflow in dotted-numeric address";
v18.m128i_i8[v4++] = v15;
if ( v4 == 4 )
goto LABEL_9;
}
}

canonical_decompiled_code:
const char *__fastcall func3(__int64 a1, __int64 a2, __m128i *a3)
{
__int64 v4; // rbx
__int64 v5; // rdx
__int64 v6; // rdi
const char *v7; // r8
unsigned __int64 v8; // rax
unsigned int v10; // edx
__int64 v11; // rcx
__m128i v12; // xmm1
__m128i v13; // [rsp+0h] [rbp-88h] BYREF
__int64 v14; // [rsp+10h] [rbp-78h]
unsigned __int64 v15; // [rsp+28h] [rbp-60h] BYREF
__int64 v16; // [rsp+30h] [rbp-58h] BYREF
__int64 v17; // [rsp+38h] [rbp-50h]
__m128i v18; // [rsp+40h] [rbp-48h]
unsigned __int64 v19; // [rsp+58h] [rbp-30h]

v4 = 0LL;
v19 = __readfsqword(0x28u);
v16 = a1;
v17 = a2;
v18 = _mm_loadu_si128(&unset_ip_bytes);
while ( 1 )
{
if ( !v16 )
goto LABEL_17;
v6 = shunk_token(&v16, 0LL, ".");
if ( !v5 )
return "empty dotted-numeric address field";
v7 = (const char *)shunk_to_uintmax(v6, v5, 0LL, 0LL, &v15);
if ( v7 )
return v7;
v8 = v15;
if ( !v17 && (_DWORD)v4 )
{
v10 = 3;
while ( v8 )
{
v11 = v10--;
v18.m128i_i8[v11] = v8;
v8 >>= 8;
if ( v10 < (unsigned int)v4 )
{
v15 = v8;
v7 = "overflow in dotted-numeric address";
if ( v8 )
return v7;
break;
}
}
LABEL_9:
if ( v16 )
return "garbage at end of dotted-address";
LABEL_17:
address_from_raw(&v13, here_1, ip_families[0], v18.m128i_i64[0], v18.m128i_i64[1]);
v12 = _mm_loadu_si128(&v13);
v7 = 0LL;
a3[1].m128i_i64[0] = v14;
*a3 = v12;
return v7;
}
if ( v15 > 0xFF )
return "byte overflow in dotted-numeric address";
v18.m128i_i8[v4++] = v15;
if ( v4 == 4 )
goto LABEL_9;
}
}

original_code:
static err_t trydotted(shunk_t src, ip_address *dst)
{
 struct ip_bytes bytes = unset_ip_bytes;
 shunk_t cursor = src;
 for (unsigned b = 0; b < 4 && cursor.ptr != ((void *)0) ; b++) {
  shunk_t token = shunk_token(&cursor, ((void *)0), ".");
  if (token.len == 0) {
   return "empty dotted-numeric address field";
  }
  uintmax_t byte;
  err_t err = shunk_to_uintmax(token, ((void *)0), 0, &byte);
  if (err != ((void *)0)) {
   return err;
  }
  if (cursor.len == 0 && b > 0) {
   for (unsigned e = 3; e >= b && byte != 0; e--) {
    bytes.byte[e] = byte;
    byte = byte >> 8;
   }
   if (byte != 0) {
    return "overflow in dotted-numeric address";
   }
   break;
  }
  if (byte > (255)) {
   return "byte overflow in dotted-numeric address";
  }
  bytes.byte[b] = byte;
 }
 if (cursor.ptr != ((void *)0)) {
  return "garbage at end of dotted-address";
 }
 *dst = address_from_raw(({ static const struct where here = { .func = __func__, .file = "lib/libswan/ttoaddress_num.c", .line = 224, }; &here; }), ip_families[IPv4_INDEX].ip_version, bytes);
 return ((void *)0);
}

canonical_original_code:
static char *trydotted(struct shunk src, struct ip_address *dst)
{
 struct ip_bytes bytes = unset_ip_bytes;
 struct shunk cursor = src;
 for (unsigned int b = 0; b < 4 && cursor.ptr != ((void *)0) ; b++) {
  struct shunk token = shunk_token(&cursor, ((void *)0), ".");
  if (token.len == 0) {
   return "empty dotted-numeric address field";
  }
  unsigned long byte;
  char *err = shunk_to_uintmax(token, ((void *)0), 0, &byte);
  if (err != ((void *)0)) {
   return err;
  }
  if (cursor.len == 0 && b > 0) {
   for (unsigned int e = 3; e >= b && byte != 0; e--) {
    bytes.byte[e] = byte;
    byte = byte >> 8;
   }
   if (byte != 0) {
    return "overflow in dotted-numeric address";
   }
   break;
  }
  if (byte > (255)) {
   return "byte overflow in dotted-numeric address";
  }
  bytes.byte[b] = byte;
 }
 if (cursor.ptr != ((void *)0)) {
  return "garbage at end of dotted-address";
 }
 *dst = address_from_raw(({ static struct where here = { .func = __func__, .file = "lib/libswan/ttoaddress_num.c", .line = 224, }; &here; }), ip_families[IPv4_INDEX].ip_version, bytes);
 return ((void *)0);
}

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

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

variable_types:
b
unsigned int

variable_types:
byte
unsigned long

variable_types:
err
char *

variable_types:
e
unsigned int

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

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


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

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

original_code:
_Bool lmod_empty(lmod_t mod)
{
 return mod.set == ((lset_t)0) && mod.clr == ((lset_t)0);
}

canonical_original_code:
_Bool lmod_empty(struct lmod_t mod)
{
 return mod.set == ((unsigned long)0) && mod.clr == ((unsigned long)0);
}

variable_types: struct lmod_t { unsigned long set; unsigned long clr; }


decompiled_code:
unsigned __int64 __fastcall lmod_merge(__int64 *a1, __int64 a2, __int64 a3)
{
__int64 v3; // rax
__int64 v4; // rsi
unsigned __int64 v6; // [rsp+8h] [rbp-10h]

v6 = __readfsqword(0x28u);
v3 = a2 | *a1 & ~a3;
v4 = a3 | a1[1] & ~a2;
*a1 = v3;
a1[1] = v4;
return v6 - __readfsqword(0x28u);
}

original_code:
void lmod_merge(lmod_t *lhs, lmod_t rhs)
{
 lhs->set = (lhs->set & ~rhs.clr) | rhs.set;
 lhs->clr = (lhs->clr & ~rhs.set) | rhs.clr;
}

canonical_original_code:
void lmod_merge(struct lmod_t *lhs, struct lmod_t rhs)
{
 lhs->set = (lhs->set & ~rhs.clr) | rhs.set;
 lhs->clr = (lhs->clr & ~rhs.set) | rhs.clr;
}

variable_types: struct lmod_t { unsigned long set; unsigned long clr; } *

variable_types:
rhs
struct lmod_t


lmod

decompiled_code:
__int64 __fastcall lmod(__int64 a1, __int64 a2, __int64 a3)
{
return a2 | a1 & ~a3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3)
{
return a2 | a1 & ~a3;
}

original_code:
lset_t lmod(lset_t set, lmod_t mod)
{
 return (set & ~mod.clr ) | mod.set;
}

canonical_original_code:
unsigned long lmod(unsigned long set, struct lmod_t mod)
{
 return (set & ~mod.clr ) | mod.set;
}

variable_types:
set
unsigned long

user_defined_types: struct lmod_t { unsigned long set; unsigned long clr; }


decompiled_code:
__int64 __fastcall lmod_set(__int64 a1, __int64 a2, __int64 a3)
{
return a1 | a3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
return a1 | a3;
}

original_code:
lmod_t lmod_set(lmod_t mod, lset_t set)
{
 mod.set |= set;
 mod.clr &= ~set;
 return mod;
}

canonical_original_code:
struct lmod_t lmod_set(struct lmod_t mod, unsigned long set)
{
 mod.set |= set;
 mod.clr &= ~set;
 return mod;
}

variable_types:
mod
struct lmod_t

return_type: struct lmod_t { unsigned long set; unsigned long clr; }


decompiled_code:
__int64 __fastcall lmod_clr(__int64 a1, __int64 a2, __int64 a3)
{
return a1 & ~a3;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
return a1 & ~a3;
}

original_code:
lmod_t lmod_clr(lmod_t mod, lset_t clr)
{
 mod.clr |= clr;
 mod.set &= ~clr;
 return mod;
}

canonical_original_code:
struct lmod_t lmod_clr(struct lmod_t mod, unsigned long clr)
{
 mod.clr |= clr;
 mod.set &= ~clr;
 return mod;
}

variable_types:
clr
unsigned long


decompiled_code:
_BOOL8 __fastcall lmod_is_set(__int64 a1, __int64 a2, __int64 a3)
{
return (a3 & a1) == a3;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 a1, __int64 a2, __int64 a3)
{
return (a3 & a1) == a3;
}

original_code:
_Bool lmod_is_set(lmod_t mod, lset_t set)
{
 return (((set) & (mod.set)) == (set));
}

canonical_original_code:
_Bool lmod_is_set(struct lmod_t mod, unsigned long set)
{
 return (((set) & (mod.set)) == (set));
}


decompiled_code:
_BOOL8 __fastcall lmod_is_clr(__int64 a1, __int64 a2, __int64 a3)
{
return (a3 & a2) == a3;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(__int64 a1, __int64 a2, __int64 a3)
{
return (a3 & a2) == a3;
}

original_code:
_Bool lmod_is_clr(lmod_t mod, lset_t clr)
{
 return (((clr) & (mod.clr)) == (clr));
}

canonical_original_code:
_Bool lmod_is_clr(struct lmod_t mod, unsigned long clr)
{
 return (((clr) & (mod.clr)) == (clr));
}