decompiled_code:
char __fastcall mkdir_p(const char *a1)
{
size_t v2; // rcx
void *v3; // rsp
char *v4; // rdx
int *i; // rax
char *v6; // rbx
char v7; // si
char v8; // di
char v9; // r13
char v11[32]; // [rsp+0h] [rbp-20h] BYREF

v2 = strlen(a1);
v3 = alloca(v2 + 1);
v4 = v11;
for ( i = 0LL; i != (int *)v2; i = (int *)((char *)i + 1) )
{
v7 = *((_BYTE *)i + (_QWORD)a1);
if ( v7 == 47 || v7 == 92 )
{
v8 = *((_BYTE *)i + (_QWORD)a1 + 1);
if ( v8 == 47 || v8 == 92 )
continue;
}
*v4++ = v7;
}
*v4 = 0;
v6 = v11;
while ( *v6++ )
{
if ( v11 != v6 )
{
v9 = *v6;
LOBYTE(i) = *v6 == 92;
if ( (unsigned __int8)i | (*v6 == 47) || !v9 )
{
*v6 = 0;
LODWORD(i) = mkdir(v11, 0x1EDu);
if ( (_DWORD)i )
{
i = _errno_location();
if ( *i != 17 )
fatal_error_with_errno("Cannot create directory \"%s\"", v11);
}
*v6 = v9;
}
}
}
return (char)i;
}

canonical_decompiled_code:
char __fastcall func11(const char *a1)
{
size_t v2; // rcx
void *v3; // rsp
char *v4; // rdx
int *i; // rax
char *v6; // rbx
char v7; // si
char v8; // di
char v9; // r13
char v11[32]; // [rsp+0h] [rbp-20h] BYREF

v2 = strlen(a1);
v3 = alloca(v2 + 1);
v4 = v11;
for ( i = 0LL; i != (int *)v2; i = (int *)((char *)i + 1) )
{
v7 = *((_BYTE *)i + (_QWORD)a1);
if ( v7 == 47 || v7 == 92 )
{
v8 = *((_BYTE *)i + (_QWORD)a1 + 1);
if ( v8 == 47 || v8 == 92 )
continue;
}
*v4++ = v7;
}
*v4 = 0;
v6 = v11;
while ( *v6++ )
{
if ( v11 != v6 )
{
v9 = *v6;
LOBYTE(i) = *v6 == 92;
if ( (unsigned __int8)i | (*v6 == 47) || !v9 )
{
*v6 = 0;
LODWORD(i) = mkdir(v11, 0x1EDu);
if ( (_DWORD)i )
{
i = _errno_location();
if ( *i != 17 )
func1("Cannot create directory \"%s\"", v11);
}
*v6 = v9;
}
}
}
return (char)i;
}

original_code:
void mkdir_p(const char *dir)
{
 size_t len = strlen(dir);
 char dir_copy[len + 1];
 char *p = dir_copy;
 for (size_t i = 0; i < len; i++) {
  if ((dir[i] != '/' && dir[i] != '\\')
   || (dir[i + 1] != '/' &&
       dir[i + 1] != '\\'))
  {
   *p++ = dir[i];
  }
 }
 *p = '\0';
 p = dir_copy;
 do {
  if (p != dir_copy && (*p == '/' || *p == '\\' || *p == '\0')) {
   char orig_char = *p;
   *p = '\0';
   if (mkdir(dir_copy, 0755) != 0 && (*__errno_location ()) != 17) {
    fatal_error_with_errno("Cannot create "
             "directory \"%s\"",
             dir_copy);
   }
   *p = orig_char;
  }
 } while (*p++ != '\0');
}

canonical_original_code:
void mkdir_p(char *dir)
{
 unsigned long len = strlen(dir);
 char dir_copy[-1];
 char *p = dir_copy;
 for (unsigned long i = 0; i < len; i++) {
  if ((dir[i] != '/' && dir[i] != '\\')
   || (dir[i + 1] != '/' &&
       dir[i + 1] != '\\'))
  {
   *p++ = dir[i];
  }
 }
 *p = '\0';
 p = dir_copy;
 do {
  if (p != dir_copy && (*p == '/' || *p == '\\' || *p == '\0')) {
   char orig_char = *p;
   *p = '\0';
   if (mkdir(dir_copy, 0755) != 0 && (*__errno_location ()) != 17) {
    fatal_error_with_errno("Cannot create "
             "directory \"%s\"",
             dir_copy);
   }
   *p = orig_char;
  }
 } while (*p++ != '\0');
}

variable_types:
dir
char *

variable_types:
len
unsigned long

variable_types:
p
char *

variable_types:
i
unsigned long


repo: libor-m/ngsClean

original_code:
static int pair_align(const struct read *read_1, const struct read *read_2,
        int min_overlap, int max_overlap,
        float max_mismatch_density)
{
 float best_mismatch_density = max_mismatch_density + 1.0f;
 float best_qual_score = 0.0f;
 int best_position = -1;
 int start = (((0) > (read_1->seq_len - read_2->seq_len)) ? (0) : (read_1->seq_len - read_2->seq_len));
 int end = read_1->seq_len - min_overlap + 1;
 for (int i = start; i < end; i++) {
  float mismatch_density;
  float qual_score;
  align_position(read_1->seq + i,
          read_2->seq,
          read_1->qual + i,
          read_2->qual,
          read_1->seq_len - i,
          min_overlap, max_overlap,
          &mismatch_density, &qual_score);
  if (mismatch_density < best_mismatch_density) {
   best_qual_score = qual_score;
   best_mismatch_density = mismatch_density;
   best_position = i;
  } else if (mismatch_density == best_mismatch_density) {
   if (qual_score < best_qual_score) {
    best_qual_score = qual_score;
    best_position = i;
   }
  }
 }
 if (best_mismatch_density > max_mismatch_density)
  return -1;
 else
  return best_position;
}

canonical_original_code:
static int pair_align(struct read *read_1, struct read *read_2, int min_overlap, int max_overlap, float max_mismatch_density)
{
 float best_mismatch_density = max_mismatch_density + 1.0f;
 float best_qual_score = 0.0f;
 int best_position = -1;
 int start = (((0) > (read_1->seq_len - read_2->seq_len)) ? (0) : (read_1->seq_len - read_2->seq_len));
 int end = read_1->seq_len - min_overlap + 1;
 for (int i = start; i < end; i++) {
  float mismatch_density;
  float qual_score;
  align_position(read_1->seq + i,
          read_2->seq,
          read_1->qual + i,
          read_2->qual,
          read_1->seq_len - i,
          min_overlap, max_overlap,
          &mismatch_density, &qual_score);
  if (mismatch_density < best_mismatch_density) {
   best_qual_score = qual_score;
   best_mismatch_density = mismatch_density;
   best_position = i;
  } else if (mismatch_density == best_mismatch_density) {
   if (qual_score < best_qual_score) {
    best_qual_score = qual_score;
    best_position = i;
   }
  }
 }
 if (best_mismatch_density > max_mismatch_density)
  return -1;
 else
  return best_position;
}

variable_types: struct read { char *tag; char *seq; char *qual; unsigned long seq_bufsz; unsigned long tag_bufsz; unsigned long qual_bufsz; int seq_len; int tag_len; } *

variable_types: start int

variable_types: end int

variable_types: i int

return_type: int


original_code:
_Bool combine_reads(const struct read *read_1, const struct read *read_2,
     struct read *combined_read, int min_overlap,
     int max_overlap, float max_mismatch_density)
{
 int overlap_begin;
 int overlap_len;
 int remaining_len;
 int combined_seq_len;
 const char * restrict seq_1 = read_1->seq;
 const char * restrict seq_2 = read_2->seq;
 const char * restrict qual_1 = read_1->qual;
 const char * restrict qual_2 = read_2->qual;
 char * restrict combined_seq;
 char * restrict combined_qual;
 overlap_begin = pair_align(read_1, read_2, min_overlap, max_overlap,
       max_mismatch_density);
 if (overlap_begin < 0)
  return 0;
 overlap_len = read_1->seq_len - overlap_begin;
 remaining_len = read_2->seq_len - overlap_len;
 combined_seq_len = read_1->seq_len + remaining_len;
 if (combined_read->seq_bufsz < combined_seq_len) {
  combined_read->seq = xrealloc(combined_read->seq,
           combined_seq_len);
  combined_read->qual = xrealloc(combined_read->qual,
            combined_seq_len);
  combined_read->seq_bufsz = combined_seq_len;
 }
 combined_seq = combined_read->seq;
 combined_qual = combined_read->qual;
 combined_read->seq_len = combined_seq_len;
 while (overlap_begin--) {
  *combined_seq++ = *seq_1++;
  *combined_qual++ = *qual_1++;
 }
 while (overlap_len--) {
  if (*seq_1 == *seq_2) {
   *combined_seq = *seq_1;
   *combined_qual = (((*qual_1) > (*qual_2)) ? (*qual_1) : (*qual_2));
  } else {
   *combined_qual = (((*qual_1) < (*qual_2)) ? (*qual_1) : (*qual_2));
   *combined_qual = (((*combined_qual) < (2)) ? (*combined_qual) : (2));
   if (*qual_1 > *qual_2) {
    *combined_seq = *seq_1;
   } else if (*qual_1 < *qual_2) {
    *combined_seq = *seq_2;
   } else {
    if (*seq_2 == 'N')
     *combined_seq = *seq_1;
    else
     *combined_seq = *seq_2;
   }
  }
  combined_seq++;
  combined_qual++;
  seq_1++;
  seq_2++;
  qual_1++;
  qual_2++;
 }
 while (remaining_len--) {
  *combined_seq++ = *seq_2++;
  *combined_qual++ = *qual_2++;
 }
 return 1;
}

canonical_original_code:
_Bool combine_reads(struct read *read_1, struct read *read_2, struct read *combined_read, int min_overlap, int max_overlap, float max_mismatch_density)
{
 int overlap_begin;
 int overlap_len;
 int remaining_len;
 int combined_seq_len;
 char *seq_1 = read_1->seq;
 char *seq_2 = read_2->seq;
 char *qual_1 = read_1->qual;
 char *qual_2 = read_2->qual;
 char *combined_seq;
 char *combined_qual;
 overlap_begin = pair_align(read_1, read_2, min_overlap, max_overlap,
       max_mismatch_density);
 if (overlap_begin < 0)
  return 0;
 overlap_len = read_1->seq_len - overlap_begin;
 remaining_len = read_2->seq_len - overlap_len;
 combined_seq_len = read_1->seq_len + remaining_len;
 if (combined_read->seq_bufsz < combined_seq_len) {
  combined_read->seq = xrealloc(combined_read->seq,
           combined_seq_len);
  combined_read->qual = xrealloc(combined_read->qual,
            combined_seq_len);
  combined_read->seq_bufsz = combined_seq_len;
 }
 combined_seq = combined_read->seq;
 combined_qual = combined_read->qual;
 combined_read->seq_len = combined_seq_len;
 while (overlap_begin--) {
  *combined_seq++ = *seq_1++;
  *combined_qual++ = *qual_1++;
 }
 while (overlap_len--) {
  if (*seq_1 == *seq_2) {
   *combined_seq = *seq_1;
   *combined_qual = (((*qual_1) > (*qual_2)) ? (*qual_1) : (*qual_2));
  } else {
   *combined_qual = (((*qual_1) < (*qual_2)) ? (*qual_1) : (*qual_2));
   *combined_qual = (((*combined_qual) < (2)) ? (*combined_qual) : (2));
   if (*qual_1 > *qual_2) {
    *combined_seq = *seq_1;
   } else if (*qual_1 < *qual_2) {
    *combined_seq = *seq_2;
   } else {
    if (*seq_2 == 'N')
     *combined_seq = *seq_1;
    else
     *combined_seq = *seq_2;
   }
  }
  combined_seq++;
  combined_qual++;
  seq_1++;
  seq_2++;
  qual_1++;
  qual_2++;
 }
 while (remaining_len--) {
  *combined_seq++ = *seq_2++;
  *combined_qual++ = *qual_2++;
 }
 return 1;
}

user_defined_types: struct read { char *tag; char *seq; char *qual; unsigned long seq_bufsz; unsigned long tag_bufsz; unsigned long qual_bufsz; int seq_len; int tag_len; }


repo: liboshi/clang

decompiled_code:
int __fastcall OSHILIB_SayHello(const char *a1)
{
return printf("Hello %s\n", a1);
}

canonical_decompiled_code:
int __fastcall func6(const char *a1)
{
return printf("Hello %s\n", a1);
}

original_code:
void
OSHILIB_SayHello(char *name)
{
        printf("Hello %s\n", name);
}

variable_types:
name
char *

return_type: void


decompiled_code:
int __fastcall OSHILIB_SayGoodbye(const char *a1)
{
return printf("Goodbye %s\n", a1);
}

canonical_decompiled_code:
int __fastcall func7(const char *a1)
{
return printf("Goodbye %s\n", a1);
}

original_code:
void
OSHILIB_SayGoodbye(char *name)
{
        printf("Goodbye %s\n", name);
}


decompiled_code:
__int64 OSHI_Start()
{
return OSHILIB_GetIntf();
}

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

original_code:
__attribute__ ((visibility ("default"))) void
OSHI_Start(OshiIntf intf)
{
        OSHILIB_GetIntf(intf);
}

canonical_original_code:
void OSHI_Start(void *intf)
{
        OSHILIB_GetIntf(intf);
}

variable_types:
intf
void *


repo: libreswan/libreswan

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

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

original_code:
static int jambuf_debugf_nop(const char *format __attribute__ ((unused)), ...)
{
 return 0;
}

canonical_original_code:
static int jambuf_debugf_nop(char *format, ...)
{
 return 0;
}

variable_types:
format
char *


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

v4 = __readfsqword(0x28u);
if ( !a1[3] )
abort();
v1 = a1[1];
v2 = a1[2];
if ( v1 < v2 && *(_BYTE *)(*a1 + v1) )
abort();
if ( *(_BYTE *)(*a1 + v2 - 1) )
abort();
if ( *(_BYTE *)(*a1 + v2) != 0xFE )
abort();
return v4 - __readfsqword(0x28u);
}

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

v4 = __readfsqword(0x28u);
if ( !a1[3] )
abort();
v1 = a1[1];
v2 = a1[2];
if ( v1 < v2 && *(_BYTE *)(*a1 + v1) )
abort();
if ( *(_BYTE *)(*a1 + v2 - 1) )
abort();
if ( *(_BYTE *)(*a1 + v2) != 0xFE )
abort();
return v4 - __readfsqword(0x28u);
}

original_code:
static void assert_jambuf(struct jambuf *buf)
{
 if (!(buf->dots != ((void *)0))) abort();
 if (!(buf->total >= buf->roof || buf->array[buf->total] == '\0')) abort();
 if (!(buf->array[buf->roof-1] == '\0')) abort();
 if (!(buf->array[buf->roof-0] == ((char) -2))) abort();
}

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


decompiled_code:
size_t __fastcall jam_raw_bytes(__int64 *a1, const void *a2, size_t a3)
{
_BYTE *v4; // rax
size_t v5; // rdx
_BYTE *v6; // r13
size_t v7; // r12

assert_jambuf(a1);
v4 = dest(a1);
v6 = v4;
a1[1] += a3;
if ( a3 < v5 )
{
memcpy(v4, a2, a3);
v6[a3] = 0;
}
else
{
v7 = v5;
if ( v5 )
{
memcpy(v4, a2, v5 - 1);
v6[v7 - 1] = 0;
truncate_buf(a1);
}
}
assert_jambuf(a1);
return a3;
}

canonical_decompiled_code:
size_t __fastcall func3(__int64 *a1, const void *a2, size_t a3)
{
_BYTE *v4; // rax
size_t v5; // rdx
_BYTE *v6; // r13
size_t v7; // r12

func1(a1);
v4 = dest(a1);
v6 = v4;
a1[1] += a3;
if ( a3 < v5 )
{
memcpy(v4, a2, a3);
v6[a3] = 0;
}
else
{
v7 = v5;
if ( v5 )
{
memcpy(v4, a2, v5 - 1);
v6[v7 - 1] = 0;
func2(a1);
}
}
func1(a1);
return a3;
}

original_code:
size_t jam_raw_bytes(struct jambuf *buf, const void *string, size_t n)
{
 assert_jambuf(buf);
 struct dest d = dest(buf);
 buf->total += n;
 if (d.size > n) {
  memcpy(d.cursor, string, n);
  d.cursor[n] = '\0';
 } else if (d.size > 0) {
  memcpy(d.cursor, string, d.size - 1);
  d.cursor[d.size - 1] = '\0';
  truncate_buf(buf);
 }
 assert_jambuf(buf);
 return n;
}

canonical_original_code:
unsigned long jam_raw_bytes(struct jambuf *buf, void *string, unsigned long n)
{
 assert_jambuf(buf);
 struct dest d = dest(buf);
 buf->total += n;
 if (d.size > n) {
  memcpy(d.cursor, string, n);
  d.cursor[n] = '\0';
 } else if (d.size > 0) {
  memcpy(d.cursor, string, d.size - 1);
  d.cursor[d.size - 1] = '\0';
  truncate_buf(buf);
 }
 assert_jambuf(buf);
 return n;
}

variable_types:
string
void *

variable_types:
n
unsigned long

variable_types: struct dest { char *cursor; unsigned long size; }

return_type: unsigned long

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


decompiled_code:
__int64 __fastcall jam_va_list(__int64 *a1, __int64 a2, __int64 a3)
{
_BYTE *v4; // rax
unsigned __int64 v5; // rdx
unsigned __int64 v6; // r12
int v7; // eax
__int64 v8; // rbx

assert_jambuf(a1);
v4 = dest(a1);
v6 = v5;
v7 = _vsnprintf_chk(v4, v5, 1LL, -1LL, a2, a3);
if ( v7 < 0 )
abort();
v8 = v7;
a1[1] += v7;
if ( v7 >= v6 && v6 )
truncate_buf(a1);
assert_jambuf(a1);
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 *a1, __int64 a2, __int64 a3)
{
_BYTE *v4; // rax
unsigned __int64 v5; // rdx
unsigned __int64 v6; // r12
int v7; // eax
__int64 v8; // rbx

func1(a1);
v4 = dest(a1);
v6 = v5;
v7 = _vsnprintf_chk(v4, v5, 1LL, -1LL, a2, a3);
if ( v7 < 0 )
abort();
v8 = v7;
a1[1] += v7;
if ( v7 >= v6 && v6 )
func2(a1);
func1(a1);
return v8;
}

original_code:
size_t jam_va_list(struct jambuf *buf, const char *format, va_list ap)
{
 assert_jambuf(buf);
 struct dest d = dest(buf);
 int sn = vsnprintf(d.cursor, d.size, format, ap);
 if (sn < 0) {
  abort();
 }
 size_t n = sn;
 buf->total += n;
 if (d.size > 0 && n >= d.size) {
  truncate_buf(buf);
 }
 assert_jambuf(buf);
 return n;
}

canonical_original_code:
unsigned long jam_va_list(struct jambuf *buf, char *format, __builtin_va_list ap)
{
 assert_jambuf(buf);
 struct dest d = dest(buf);
 int sn = vsnprintf(d.cursor, d.size, format, ap);
 if (sn < 0) {
  abort();
 }
 unsigned long n = sn;
 buf->total += n;
 if (d.size > 0 && n >= d.size) {
  truncate_buf(buf);
 }
 assert_jambuf(buf);
 return n;
}

variable_types: sn int

user_defined_types: struct dest { char *cursor; unsigned long size; }


jam

decompiled_code:
__int64 jam(__int64 *a1, __int64 a2, ...)
{
gcc_va_list va; // [rsp+0h] [rbp-D8h] BYREF
unsigned __int64 v4; // [rsp+18h] [rbp-C0h]

va_start(va, a2);
v4 = __readfsqword(0x28u);
return jam_va_list(a1, a2, (__int64)va);
}

canonical_decompiled_code:
__int64 func5(__int64 *a1, __int64 a2, ...)
{
gcc_va_list va; // [rsp+0h] [rbp-D8h] BYREF
unsigned __int64 v4; // [rsp+18h] [rbp-C0h]

va_start(va, a2);
v4 = __readfsqword(0x28u);
return func4(a1, a2, (__int64)va);
}

original_code:
size_t jam(struct jambuf *buf, const char *format, ...)
{
 va_list ap;
 __builtin_va_start(ap,format);
 size_t n = jam_va_list(buf, format, ap);
 __builtin_va_end(ap);
 return n;
}

canonical_original_code:
unsigned long jam(struct jambuf *buf, char *format, ...)
{
 __builtin_va_list ap;
 __builtin_va_start(ap,format);
 unsigned long n = jam_va_list(buf, format, ap);
 __builtin_va_end(ap);
 return n;
}


decompiled_code:
size_t __fastcall jam_char(__int64 *a1, char a2)
{
char v3[12]; // [rsp+Ch] [rbp-1Ch] BYREF
unsigned __int64 v4; // [rsp+18h] [rbp-10h]

v3[0] = a2;
v4 = __readfsqword(0x28u);
return jam_raw_bytes(a1, v3, 1uLL);
}

canonical_decompiled_code:
size_t __fastcall func6(__int64 *a1, char a2)
{
char v3[12]; // [rsp+Ch] [rbp-1Ch] BYREF
unsigned __int64 v4; // [rsp+18h] [rbp-10h]

v3[0] = a2;
v4 = __readfsqword(0x28u);
return func3(a1, v3, 1uLL);
}

original_code:
size_t jam_char(struct jambuf *buf, char c)
{
 return jam_raw_bytes(buf, &c, 1);
}

canonical_original_code:
unsigned long jam_char(struct jambuf *buf, char c)
{
 return jam_raw_bytes(buf, &c, 1);
}

variable_types: c char


decompiled_code:
size_t __fastcall jam_string(__int64 *a1, const char *a2)
{
const char *v2; // rbx
size_t v3; // rax

v2 = a2;
if ( !a2 )
v2 = "(null)";
v3 = strlen(v2);
return jam_raw_bytes(a1, v2, v3);
}

canonical_decompiled_code:
size_t __fastcall func7(__int64 *a1, const char *a2)
{
const char *v2; // rbx
size_t v3; // rax

v2 = a2;
if ( !a2 )
v2 = "(null)";
v3 = strlen(v2);
return func3(a1, v2, v3);
}

original_code:
size_t jam_string(struct jambuf *buf, const char *string)
{
 if (string == ((void *)0)) {
  string = "(null)";
 }
 return jam_raw_bytes(buf, string, strlen(string));
}

canonical_original_code:
unsigned long jam_string(struct jambuf *buf, char *string)
{
 if (string == ((void *)0)) {
  string = "(null)";
 }
 return jam_raw_bytes(buf, string, strlen(string));
}

variable_types:
string
char *


decompiled_code:
__int64 __fastcall jam_errno(__int64 *a1, unsigned int a2)
{
const char *v2; // rbp
__int64 result; // rax
__int64 v4; // rdx
int v5; // er14
int v6; // er13
int v7; // ebp

assert_jambuf(a1);
v2 = dest(a1);
result = 1LL;
if ( v4 )
{
v5 = _xpg_strerror_r(a2, v2);
v6 = strlen(v2);
v7 = v6;
a1[1] += v6;
if ( v5 == 34 )
{
a1[1] = a1[2];
truncate_buf(a1);
}
else if ( v5 != 22 )
{
v7 = jam(a1, (__int64)" (errno %d)", a2) + v6;
}
assert_jambuf(a1);
result = v7;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 *a1, unsigned int a2)
{
const char *v2; // rbp
__int64 result; // rax
__int64 v4; // rdx
int v5; // er14
int v6; // er13
int v7; // ebp

func1(a1);
v2 = dest(a1);
result = 1LL;
if ( v4 )
{
v5 = _xpg_strerror_r(a2, v2);
v6 = strlen(v2);
v7 = v6;
a1[1] += v6;
if ( v5 == 34 )
{
a1[1] = a1[2];
func2(a1);
}
else if ( v5 != 22 )
{
v7 = func5(a1, (__int64)" (errno %d)", a2) + v6;
}
func1(a1);
result = v7;
}
return result;
}

original_code:
size_t jam_errno(struct jambuf *buf, int error)
{
 assert_jambuf(buf);
 struct dest d = dest(buf);
 if (d.size == 0) {
  return 1;
 }
 int e = strerror_r(error, d.cursor, d.size);
 int n = strlen(d.cursor);
 buf->total += n;
 if (e == 34) {
  buf->total = buf->roof;
  truncate_buf(buf);
 } else if (e != 22) {
  n += jam(buf, " (errno %d)", error);
 }
 assert_jambuf(buf);
 return n;
}

canonical_original_code:
unsigned long jam_errno(struct jambuf *buf, int error)
{
 assert_jambuf(buf);
 struct dest d = dest(buf);
 if (d.size == 0) {
  return 1;
 }
 int e = strerror_r(error, d.cursor, d.size);
 int n = strlen(d.cursor);
 buf->total += n;
 if (e == 34) {
  buf->total = buf->roof;
  truncate_buf(buf);
 } else if (e != 22) {
  n += jam(buf, " (errno %d)", error);
 }
 assert_jambuf(buf);
 return n;
}

variable_types: error int

variable_types: e int

variable_types: n int


decompiled_code:
bool __fastcall jambuf_ok(_QWORD *a1)
{
assert_jambuf(a1);
return a1[1] < a1[2];
}

canonical_decompiled_code:
bool __fastcall func9(_QWORD *a1)
{
func1(a1);
return a1[1] < a1[2];
}

original_code:
_Bool jambuf_ok(struct jambuf *buf)
{
 assert_jambuf(buf);
 return buf->total < buf->roof;
}


decompiled_code:
__int64 __fastcall jambuf_as_shunk(_QWORD *a1)
{
_BYTE *v1; // rax

assert_jambuf(a1);
v1 = dest(a1);
return shunk2(*a1, &v1[-*a1]);
}

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD *a1)
{
_BYTE *v1; // rax

func1(a1);
v1 = dest(a1);
return shunk2(*a1, &v1[-*a1]);
}

original_code:
shunk_t jambuf_as_shunk(struct jambuf *buf)
{
 assert_jambuf(buf);
 struct dest d = dest(buf);
 return shunk2(buf->array, d.cursor - buf->array);
}

canonical_original_code:
struct shunk jambuf_as_shunk(struct jambuf *buf)
{
 assert_jambuf(buf);
 struct dest d = dest(buf);
 return shunk2(buf->array, d.cursor - buf->array);
}

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


decompiled_code:
size_t __fastcall jam_jambuf(__int64 *a1, _QWORD *a2)
{
const void *v2; // rax
size_t v3; // rdx

v2 = (const void *)jambuf_as_shunk(a2);
return jam_raw_bytes(a1, v2, v3);
}

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

v2 = (const void *)func10(a2);
return func3(a1, v2, v3);
}

original_code:
size_t jam_jambuf(struct jambuf *buf, struct jambuf *jambuf)
{
 shunk_t s = jambuf_as_shunk(jambuf);
 return jam_raw_bytes(buf, s.ptr, s.len);
}

canonical_original_code:
unsigned long jam_jambuf(struct jambuf *buf, struct jambuf *jambuf)
{
 struct shunk s = jambuf_as_shunk(jambuf);
 return jam_raw_bytes(buf, s.ptr, s.len);
}

variable_types:
jambuf
struct jambuf *

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


decompiled_code:
__int64 __fastcall jambuf_get_pos(_QWORD *a1)
{
assert_jambuf(a1);
return a1[1];
}

canonical_decompiled_code:
__int64 __fastcall func12(_QWORD *a1)
{
func1(a1);
return a1[1];
}

original_code:
jampos_t jambuf_get_pos(struct jambuf *buf)
{
 assert_jambuf(buf);
 jampos_t pos = {
  .total = buf->total,
 };
 return pos;
}

canonical_original_code:
struct jampos_t jambuf_get_pos(struct jambuf *buf)
{
 assert_jambuf(buf);
 struct jampos_t pos = {
  .total = buf->total,
 };
 return pos;
}

variable_types: struct jampos_t { unsigned long total; }


original_code:
void jambuf_set_pos(struct jambuf *buf, const jampos_t *pos)
{
 assert_jambuf(buf);
 if (pos->total >= buf->roof) {
  buf->total = pos->total;
 } else if (
  buf->total < buf->roof ||
  pos->total + strlen(buf->dots) < buf->roof) {
  buf->array[pos->total] = '\0';
  buf->total = pos->total;
 } else {
  buf->total = buf->roof;
 }
 assert_jambuf(buf);
}

canonical_original_code:
void jambuf_set_pos(struct jambuf *buf, struct jampos_t *pos)
{
 assert_jambuf(buf);
 if (pos->total >= buf->roof) {
  buf->total = pos->total;
 } else if (
  buf->total < buf->roof ||
  pos->total + strlen(buf->dots) < buf->roof) {
  buf->array[pos->total] = '\0';
  buf->total = pos->total;
 } else {
  buf->total = buf->roof;
 }
 assert_jambuf(buf);
}

variable_types: struct jampos_t { unsigned long total; } *


decompiled_code:
__int64 diag_va_list()
{
return alloc_vprintf();
}

canonical_decompiled_code:
__int64 func0()
{
return alloc_vprintf();
}

original_code:
diag_t diag_va_list(const char *fmt, va_list ap)
{
 return (diag_t)alloc_vprintf(fmt, ap);
}

canonical_original_code:
struct diag *diag_va_list(char *fmt, __builtin_va_list ap)
{
 return (struct diag *)alloc_vprintf(fmt, ap);
}

variable_types:
fmt
char *

return_type: struct diag { char message[1]; } *


diag

decompiled_code:
__int64 diag(__int64 a1, ...)
{
gcc_va_list va; // [rsp+0h] [rbp-D8h] BYREF
unsigned __int64 v3; // [rsp+18h] [rbp-C0h]

va_start(va, a1);
v3 = __readfsqword(0x28u);
return diag_va_list(a1, va);
}

canonical_decompiled_code:
__int64 func1(__int64 a1, ...)
{
gcc_va_list va; // [rsp+0h] [rbp-D8h] BYREF
unsigned __int64 v3; // [rsp+18h] [rbp-C0h]

va_start(va, a1);
v3 = __readfsqword(0x28u);
return func0(a1, va);
}

original_code:
diag_t diag(const char *fmt, ...)
{
 va_list ap;
 __builtin_va_start(ap,fmt);
 diag_t d = diag_va_list(fmt, ap);
 __builtin_va_end(ap);
 return d;
}

canonical_original_code:
struct diag *diag(char *fmt, ...)
{
 __builtin_va_list ap;
 __builtin_va_start(ap,fmt);
 struct diag *d = diag_va_list(fmt, ap);
 __builtin_va_end(ap);
 return d;
}

variable_types:
d
struct diag { char message[1]; } *


decompiled_code:
__int64 diag_errno(unsigned int a1, __int64 a2, ...)
{
size_t v2; // rax
_BYTE v4[40]; // [rsp+0h] [rbp-528h] BYREF
gcc_va_list va; // [rsp+28h] [rbp-500h] BYREF
char s[1032]; // [rsp+40h] [rbp-4E8h] BYREF
unsigned __int64 v7; // [rsp+448h] [rbp-E0h]

va_start(va, a2);
v7 = __readfsqword(0x28u);
array_as_jambuf(v4, s, 1024LL);
jam_va_list(v4, a2, va);
jam_errno(v4, a1);
v2 = strlen(s);
return clone_bytes(s, v2 + 1, "diag-errno");
}

canonical_decompiled_code:
__int64 func2(unsigned int a1, __int64 a2, ...)
{
size_t v2; // rax
_BYTE v4[40]; // [rsp+0h] [rbp-528h] BYREF
gcc_va_list va; // [rsp+28h] [rbp-500h] BYREF
char s[1032]; // [rsp+40h] [rbp-4E8h] BYREF
unsigned __int64 v7; // [rsp+448h] [rbp-E0h]

va_start(va, a2);
v7 = __readfsqword(0x28u);
array_as_jambuf(v4, s, 1024LL);
jam_va_list(v4, a2, va);
jam_errno(v4, a1);
v2 = strlen(s);
return clone_bytes(s, v2 + 1, "diag-errno");
}

original_code:
diag_t diag_errno(int error, const char *fmt, ...)
{
 char output[((size_t)1024)];
 struct jambuf buf = array_as_jambuf((output), sizeof(output));
 va_list ap;
 __builtin_va_start(ap,fmt);
 jam_va_list(&buf, fmt, ap);
 __builtin_va_end(ap);
 jam_errno(&buf, error);
 return (diag_t)((output) == ((void *)0) ? ((void *)0) : clone_bytes((output), strlen((output)) + 1, ("diag-errno")));
}

canonical_original_code:
struct diag *diag_errno(int error, char *fmt, ...)
{
 char output[-1];
 struct jambuf buf = array_as_jambuf((output), sizeof(output));
 __builtin_va_list ap;
 __builtin_va_start(ap,fmt);
 jam_va_list(&buf, fmt, ap);
 __builtin_va_end(ap);
 jam_errno(&buf, error);
 return (diag_t)((output) == ((void *)0) ? ((void *)0) : clone_bytes((output), strlen((output)) + 1, ("diag-errno")));
}

variable_types:
output
char [-1]

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


decompiled_code:
__int64 __fastcall clone_diag(const char *a1)
{
__int64 result; // rax
size_t v2; // rax

result = (__int64)a1;
if ( a1 )
{
v2 = strlen(a1);
result = clone_bytes(a1, v2 + 1, "diag clone");
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1)
{
__int64 result; // rax
size_t v2; // rax

result = (__int64)a1;
if ( a1 )
{
v2 = strlen(a1);
result = clone_bytes(a1, v2 + 1, "diag clone");
}
return result;
}

original_code:
diag_t clone_diag(diag_t diag)
{
 return (diag_t) (((char*)diag) == ((void *)0) ? ((void *)0) : clone_bytes(((char*)diag), strlen(((char*)diag)) + 1, ("diag clone")));
}

canonical_original_code:
struct diag *clone_diag(struct diag *diag)
{
 return (diag_t) (((char *)diag) == ((void *)0) ? ((void *)0) : clone_bytes(((char *)diag), strlen(((char *)diag)) + 1, ("diag clone")));
}

variable_types:
diag
struct diag *


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

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

original_code:
const char *str_diag(diag_t diag)
{
 return (char*)diag;
}

canonical_original_code:
char *str_diag(struct diag *diag)
{
 return (char *)diag;
}

variable_types:
diag
struct diag { char message[1]; } *

return_type: char *


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

v2 = __readfsqword(0x28u);
if ( *a1 )
{
pfree();
*a1 = 0LL;
}
return v2 - __readfsqword(0x28u);
}

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

v2 = __readfsqword(0x28u);
if ( *a1 )
{
pfree();
*a1 = 0LL;
}
return v2 - __readfsqword(0x28u);
}

original_code:
void pfree_diag(diag_t *diag)
{
 if (*diag != ((void *)0)) {
  pfree(*diag);
  *diag = ((void *)0);
 }
}

canonical_original_code:
void pfree_diag(struct diag **diag)
{
 if (*diag != ((void *)0)) {
  pfree(*diag);
  *diag = ((void *)0);
 }
}

variable_types:
diag
struct diag { char message[1]; } **


decompiled_code:
__int64 __fastcall jam_diag(__int64 a1, __int64 a2)
{
__int64 v2; // rax

v2 = str_diag(a2);
return jam_string(a1, v2);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
__int64 v2; // rax

v2 = func5(a2);
return jam_string(a1, v2);
}

original_code:
size_t jam_diag(struct jambuf *buf, diag_t diag)
{
 return jam_string(buf, str_diag(diag));
}

canonical_original_code:
unsigned long jam_diag(struct jambuf *buf, struct diag *diag)
{
 return jam_string(buf, str_diag(diag));
}

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


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

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

original_code:
ip_port ip_hport(unsigned hport)
{
 ip_port port = { .hport = hport, };
 return port;
}

canonical_original_code:
struct ip_port ip_hport(unsigned int hport)
{
 struct ip_port port = { .hport = hport, };
 return port;
}

variable_types:
hport
unsigned int

variable_types:
port
struct ip_port { unsigned int hport; }

return_type: struct ip_port { unsigned int hport; }


decompiled_code:
__int64 __fastcall ip_nport(__int16 a1)
{
unsigned __int16 v1; // ax

v1 = _bswap_16(a1);
return ip_hport(v1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int16 a1)
{
unsigned __int16 v1; // ax

v1 = func0(a1);
return func1(v1);
}

original_code:
ip_port ip_nport(unsigned nport)
{
 return ip_hport(ntohs(nport));
}

canonical_original_code:
struct ip_port ip_nport(unsigned int nport)
{
 return ip_hport(ntohs(nport));
}

variable_types:
nport
unsigned int


hport

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

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

original_code:
unsigned hport(const ip_port port)
{
 return port.hport;
}

canonical_original_code:
unsigned int hport(struct ip_port port)
{
 return port.hport;
}

return_type: unsigned int


nport

decompiled_code:
__int64 __fastcall nport(__int16 a1)
{
return (unsigned __int16)_bswap_16(a1);
}

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

original_code:
unsigned nport(const ip_port port)
{
 return htons(port.hport);
}

canonical_original_code:
unsigned int nport(struct ip_port port)
{
 return htons(port.hport);
}


decompiled_code:
__int64 __fastcall jam_hport(__int64 a1, unsigned int a2)
{
unsigned int v2; // eax

v2 = hport(a2);
return jam(a1, &LC0, v2);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned int a2)
{
unsigned int v2; // eax

v2 = func3(a2);
return jam(a1, &LC0, v2);
}

original_code:
size_t jam_hport(struct jambuf *buf, ip_port port)
{
 return jam(buf, "%u", hport(port));
}

canonical_original_code:
unsigned long jam_hport(struct jambuf *buf, struct ip_port port)
{
 return jam(buf, "%u", hport(port));
}


decompiled_code:
__int64 __fastcall jam_nport(__int64 a1, unsigned int a2)
{
unsigned int v2; // eax

v2 = hport(a2);
return jam(a1, "%04x", v2);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2)
{
unsigned int v2; // eax

v2 = func3(a2);
return jam(a1, "%04x", v2);
}

original_code:
size_t jam_nport(struct jambuf *buf, ip_port port)
{
 return jam(buf, "%04x", hport(port));
}

canonical_original_code:
unsigned long jam_nport(struct jambuf *buf, struct ip_port port)
{
 return jam(buf, "%04x", hport(port));
}


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

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

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

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

original_code:
const char *str_hport(ip_port port, port_buf *buf)
{
 struct jambuf jambuf = array_as_jambuf((buf->buf), sizeof(buf->buf));
 jam_hport(&jambuf, port);
 return buf->buf;
}

canonical_original_code:
char *str_hport(struct ip_port port, struct port_buf *buf)
{
 struct jambuf jambuf = array_as_jambuf((buf->buf), sizeof(buf->buf));
 jam_hport(&jambuf, port);
 return buf->buf;
}

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


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

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

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

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

original_code:
const char *str_nport(ip_port port, port_buf *buf)
{
 struct jambuf jambuf = array_as_jambuf((buf->buf), sizeof(buf->buf));
 jam_nport(&jambuf, port);
 return buf->buf;
}

canonical_original_code:
char *str_nport(struct ip_port port, struct port_buf *buf)
{
 struct jambuf jambuf = array_as_jambuf((buf->buf), sizeof(buf->buf));
 jam_nport(&jambuf, port);
 return buf->buf;
}


ttoport

decompiled_code:
const char *__fastcall ttoport(const char *a1, _DWORD *a2)
{
struct servent *v2; // rax
__int64 v3; // rax
__int64 v4; // rdx
const char *v5; // rbx
__int64 v7[5]; // [rsp+0h] [rbp-28h] BYREF

v7[1] = __readfsqword(0x28u);
v2 = getservbyname(a1, 0LL);
if ( v2 )
{
*a2 = ip_nport(v2->s_port);
v5 = 0LL;
}
else
{
v3 = shunk1(a1);
v5 = (const char *)shunk_to_uintmax(v3, v4, 0LL, 0LL, v7);
if ( v5 )
{
*a2 = unset_port;
}
else if ( v7[0] <= 0xFFFFuLL )
{
*a2 = ip_hport(v7[0]);
}
else
{
*a2 = unset_port;
v5 = "must be between 0 and 65535";
}
}
return v5;
}

canonical_decompiled_code:
const char *__fastcall func10(const char *a1, _DWORD *a2)
{
struct servent *v2; // rax
__int64 v3; // rax
__int64 v4; // rdx
const char *v5; // rbx
__int64 v7[5]; // [rsp+0h] [rbp-28h] BYREF

v7[1] = __readfsqword(0x28u);
v2 = getservbyname(a1, 0LL);
if ( v2 )
{
*a2 = func2(v2->s_port);
v5 = 0LL;
}
else
{
v3 = shunk1(a1);
v5 = (const char *)shunk_to_uintmax(v3, v4, 0LL, 0LL, v7);
if ( v5 )
{
*a2 = unset_port;
}
else if ( v7[0] <= 0xFFFFuLL )
{
*a2 = func1(v7[0]);
}
else
{
*a2 = unset_port;
v5 = "must be between 0 and 65535";
}
}
return v5;
}

original_code:
err_t ttoport(const char *service_name, ip_port *port)
{
 const struct servent *service = getservbyname(service_name, ((void *)0));
 if (service != ((void *)0)) {
  *port = ip_nport(service->s_port );
  return ((void *)0);
 }
 uintmax_t l;
 err_t e = shunk_to_uintmax(shunk1(service_name), ((void *)0) ,
       0 , &l);
 if (e != ((void *)0)) {
  *port = unset_port;
  return e;
 }
 if (l > 0xffff) {
  *port = unset_port;
  return "must be between 0 and 65535";
 }
 *port = ip_hport(l);
 return ((void *)0);
}

canonical_original_code:
char *ttoport(char *service_name, struct ip_port *port)
{
 struct servent *service = getservbyname(service_name, ((void *)0));
 if (service != ((void *)0)) {
  *port = ip_nport(service->s_port );
  return ((void *)0);
 }
 unsigned long l;
 char *e = shunk_to_uintmax(shunk1(service_name), ((void *)0) ,
       0 , &l);
 if (e != ((void *)0)) {
  *port = unset_port;
  return e;
 }
 if (l > 0xffff) {
  *port = unset_port;
  return "must be between 0 and 65535";
 }
 *port = ip_hport(l);
 return ((void *)0);
}

variable_types: struct ip_port { unsigned int hport; } *

variable_types: struct servent { char *s_name; char **s_aliases; int s_port; char *s_proto; } *

variable_types:
l
unsigned long

variable_types:
e
char *


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

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

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

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

original_code:
const struct ip_info *address_info(const ip_address address)
{
 if (!address.is_set) {
  return ((void *)0);
 }
 return ip_version_info(address.version);
}

canonical_original_code:
struct ip_info *address_info(struct ip_address address)
{
 if (!address.is_set) {
  return ((void *)0);
 }
 return ip_version_info(address.version);
}

variable_types:
address
struct ip_address

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

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

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

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

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

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

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


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

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

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

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

original_code:
const struct ip_info *address_type(const ip_address *address)
{
 if (address == ((void *)0)) {
  return ((void *)0);
 }
 return address_info(*address);
}

canonical_original_code:
struct ip_info *address_type(struct ip_address *address)
{
 if (address == ((void *)0)) {
  return ((void *)0);
 }
 return address_info(*address);
}

variable_types:
address
struct ip_address *

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

v6 = address_type(a1, a2, a3, a4, a5, a6);
if ( v6 )
result = shunk2(&a1->m128i_u64[1], *(_QWORD *)(v6 + 16));
else
result = null_shunk;
return result;
}

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

v6 = func1(a1, a2, a3, a4, a5, a6);
if ( v6 )
result = shunk2(&a1->m128i_u64[1], *(_QWORD *)(v6 + 16));
else
result = null_shunk;
return result;
}

original_code:
shunk_t address_as_shunk(const ip_address *address)
{
 const struct ip_info *afi = address_type(address);
 if (afi == ((void *)0)) {
  return null_shunk;
 }
 return shunk2(&address->bytes, afi->ip_size);
}

canonical_original_code:
struct shunk address_as_shunk(struct ip_address *address)
{
 struct ip_info *afi = address_type(address);
 if (afi == ((void *)0)) {
  return null_shunk;
 }
 return shunk2(&address->bytes, afi->ip_size);
}

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 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 shunk { void *ptr; unsigned long len; }


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

v6 = address_type(a1, a2, a3, a4, a5, a6);
if ( v6 )
result = chunk2(&a1->m128i_u64[1], *(_QWORD *)(v6 + 16));
else
result = empty_chunk;
return result;
}

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

v6 = func1(a1, a2, a3, a4, a5, a6);
if ( v6 )
result = chunk2(&a1->m128i_u64[1], *(_QWORD *)(v6 + 16));
else
result = empty_chunk;
return result;
}

original_code:
chunk_t address_as_chunk(ip_address *address)
{
 const struct ip_info *afi = address_type(address);
 if (afi == ((void *)0)) {
  return empty_chunk;
 }
 return chunk2(&address->bytes, afi->ip_size);
}

canonical_original_code:
struct chunk_t address_as_chunk(struct ip_address *address)
{
 struct ip_info *afi = address_type(address);
 if (afi == ((void *)0)) {
  return empty_chunk;
 }
 return chunk2(&address->bytes, afi->ip_size);
}

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

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


original_code:
size_t jam_address_reversed(struct jambuf *buf, const ip_address *address)
{
 const struct ip_info *afi = address_type(address);
 if (afi == ((void *)0)) {
  return jam(buf, "<invalid>");
 }
 shunk_t bytes = address_as_shunk(address);
 size_t s = 0;
 switch (afi->af) {
 case 2:
  for (int i = bytes.len - 1; i >= 0; i--) {
   const uint8_t *byte = bytes.ptr;
   s += jam(buf, "%d.", byte[i]);
  }
  s += jam(buf, "IN-ADDR.ARPA.");
  break;
 case 10:
  for (int i = bytes.len - 1; i >= 0; i--) {
   const uint8_t *byte = bytes.ptr;
   s += jam(buf, "%x.%x.", byte[i] & 0xf, byte[i] >> 4);
  }
  s += jam(buf, "IP6.ARPA.");
  break;
 case 0:
  s += jam(buf, "<unspecified>");
  break;
 default:
  libreswan_bad_case("afi->af", (afi->af), ({ static const struct where here = { .func = __func__, .file = "lib/libswan/ip_address.c", .line = 173, }; &here; }));
  break;
 }
 return s;
}

canonical_original_code:
unsigned long jam_address_reversed(struct jambuf *buf, struct ip_address *address)
{
 struct ip_info *afi = address_type(address);
 if (afi == ((void *)0)) {
  return jam(buf, "<invalid>");
 }
 struct shunk bytes = address_as_shunk(address);
 unsigned long s = 0;
 switch (afi->af) {
 case 2:
  for (int i = bytes.len - 1; i >= 0; i--) {
   unsigned char *byte = bytes.ptr;
   s += jam(buf, "%d.", byte[i]);
  }
  s += jam(buf, "IN-ADDR.ARPA.");
  break;
 case 10:
  for (int i = bytes.len - 1; i >= 0; i--) {
   unsigned char *byte = bytes.ptr;
   s += jam(buf, "%x.%x.", byte[i] & 0xf, byte[i] >> 4);
  }
  s += jam(buf, "IP6.ARPA.");
  break;
 case 0:
  s += jam(buf, "<unspecified>");
  break;
 default:
  libreswan_bad_case("afi->af", (afi->af), ({ static struct where here = { .func = __func__, .file = "lib/libswan/ip_address.c", .line = 173, }; &here; }));
  break;
 }
 return s;
}

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

variable_types:
s
unsigned long

variable_types: i int

variable_types:
byte
unsigned char *

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

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


decompiled_code:
__int64 __fastcall str_address_reversed(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, 75LL);
jam_address_reversed((__int64)v7, a1, v2, v3, v4, v5);
return a2;
}

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

canonical_original_code:
char *str_address_reversed(struct ip_address *src, struct address_reversed_buf *dst)
{
 struct jambuf buf = array_as_jambuf((dst->buf), sizeof(dst->buf));
 jam_address_reversed(&buf, src);
 return dst->buf;
}

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

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

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


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

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

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

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

original_code:
_Bool address_is_unset(const ip_address *address)
{
 if (address == ((void *)0)) {
  return 1;
 }
 return !address->is_set;
}

canonical_original_code:
_Bool address_is_unset(struct ip_address *address)
{
 if (address == ((void *)0)) {
  return 1;
 }
 return !address->is_set;
}


decompiled_code:
__int64 __fastcall jam_address(__int64 a1, __m128i *a2)
{
__int64 v2; // rdx
__int64 v3; // rcx
__int64 v4; // r8
__int64 v5; // r9
__int64 v6; // rax
__int64 result; // rax

if ( (unsigned __int8)address_is_unset((unsigned __int8 *)a2) )
return jam_string(a1, "<unset-address>");
v6 = address_type(a2, (__int64)a2, v2, v3, v4, v5);
if ( v6 )
result = (*(__int64 (__fastcall **)(__int64, __int64, __int64 *))(v6 + 80))(a1, v6, &a2->m128i_i64[1]);
else
result = jam_string(a1, "<unknown-address>");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __m128i *a2)
{
__int64 v2; // rdx
__int64 v3; // rcx
__int64 v4; // r8
__int64 v5; // r9
__int64 v6; // rax
__int64 result; // rax

if ( (unsigned __int8)func6((unsigned __int8 *)a2) )
return jam_string(a1, "<unset-address>");
v6 = func1(a2, (__int64)a2, v2, v3, v4, v5);
if ( v6 )
result = (*(__int64 (__fastcall **)(__int64, __int64, __int64 *))(v6 + 80))(a1, v6, &a2->m128i_i64[1]);
else
result = jam_string(a1, "<unknown-address>");
return result;
}

original_code:
size_t jam_address(struct jambuf *buf, const ip_address *address)
{
 if (address_is_unset(address)) {
  return jam_string(buf, "<unset-address>");
 }
 const struct ip_info *afi = address_type(address);
 if (afi == ((void *)0)) {
  return jam_string(buf, "<unknown-address>");
 }
 return afi->address.jam(buf, afi, &address->bytes);
}

canonical_original_code:
unsigned long jam_address(struct jambuf *buf, struct ip_address *address)
{
 if (address_is_unset(address)) {
  return jam_string(buf, "<unset-address>");
 }
 struct ip_info *afi = address_type(address);
 if (afi == ((void *)0)) {
  return jam_string(buf, "<unknown-address>");
 }
 return afi->address.jam(buf, afi, &address->bytes);
}

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

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


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

if ( log_ip )
result = jam_address(a1, a2);
else
result = jam_string(a1, "<address>");
return result;
}

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

if ( log_ip )
result = func7(a1, a2);
else
result = jam_string(a1, "<address>");
return result;
}

original_code:
size_t jam_address_sensitive(struct jambuf *buf, const ip_address *address)
{
 if (!log_ip) {
  return jam_string(buf, "<address>");
 }
 return jam_address(buf, address);
}

canonical_original_code:
unsigned long jam_address_sensitive(struct jambuf *buf, struct ip_address *address)
{
 if (!log_ip) {
  return jam_string(buf, "<address>");
 }
 return jam_address(buf, address);
}


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

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

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

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

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

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

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


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

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

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

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

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

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


ipstr

decompiled_code:
__int64 __fastcall ipstr(__m128i *a1, __int64 a2)
{
return str_address(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func11(__m128i *a1, __int64 a2)
{
return func10(a1, a2);
}

original_code:
const char *ipstr(const ip_address *src, ipstr_buf *b)
{
 return str_address(src, b);
}

canonical_original_code:
char *ipstr(struct ip_address *src, struct address_buf *b)
{
 return str_address(src, b);
}

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


decompiled_code:
__int64 __fastcall jam_address_wrapped(__int64 a1, __m128i *a2)
{
__int64 v2; // rdx
__int64 v3; // rcx
__int64 v4; // r8
__int64 v5; // r9
__int64 v6; // rax
__int64 result; // rax

if ( (unsigned __int8)address_is_unset((unsigned __int8 *)a2) )
return jam_string(a1, "<unset-address>");
v6 = address_type(a2, (__int64)a2, v2, v3, v4, v5);
if ( v6 )
result = (*(__int64 (__fastcall **)(__int64, __int64, __int64 *))(v6 + 88))(a1, v6, &a2->m128i_i64[1]);
else
result = jam_string(a1, "<unknown-address>");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __m128i *a2)
{
__int64 v2; // rdx
__int64 v3; // rcx
__int64 v4; // r8
__int64 v5; // r9
__int64 v6; // rax
__int64 result; // rax

if ( (unsigned __int8)func6((unsigned __int8 *)a2) )
return jam_string(a1, "<unset-address>");
v6 = func1(a2, (__int64)a2, v2, v3, v4, v5);
if ( v6 )
result = (*(__int64 (__fastcall **)(__int64, __int64, __int64 *))(v6 + 88))(a1, v6, &a2->m128i_i64[1]);
else
result = jam_string(a1, "<unknown-address>");
return result;
}

original_code:
size_t jam_address_wrapped(struct jambuf *buf, const ip_address *address)
{
 if (address_is_unset(address)) {
  return jam_string(buf, "<unset-address>");
 }
 const struct ip_info *afi = address_type(address);
 if (afi == ((void *)0)) {
  return jam_string(buf, "<unknown-address>");
 }
 return afi->address.jam_wrapped(buf, afi, &address->bytes);
}

canonical_original_code:
unsigned long jam_address_wrapped(struct jambuf *buf, struct ip_address *address)
{
 if (address_is_unset(address)) {
  return jam_string(buf, "<unset-address>");
 }
 struct ip_info *afi = address_type(address);
 if (afi == ((void *)0)) {
  return jam_string(buf, "<unknown-address>");
 }
 return afi->address.jam_wrapped(buf, afi, &address->bytes);
}

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


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


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_address { _Bool is_set; enum ip_version { IPv4=4, IPv6=6 } version; struct ip_bytes { unsigned char byte[16]; } bytes; }

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


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

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


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 where { char *func; char *file; long line; } *


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:
bool __fastcall is_monotime_epoch(__int64 a1, __int64 a2)
{
__int64 v3[5]; // [rsp+0h] [rbp-28h] BYREF

v3[0] = a1;
v3[1] = a2;
v3[3] = __readfsqword(0x28u);
return memcmp(v3, &monotime_epoch, 0x10uLL) == 0;
}

canonical_decompiled_code:
bool __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v3[5]; // [rsp+0h] [rbp-28h] BYREF

v3[0] = a1;
v3[1] = a2;
v3[3] = __readfsqword(0x28u);
return memcmp(v3, &monotime_epoch, 0x10uLL) == 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;
}


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, __int64 a7, __int64 a8)
{
__int64 result; // rax

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

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

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

original_code:
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, __int64 a7, __int64 a8)
{
__int64 result; // rax

result = a1 - a7;
if ( a2 - a8 < 0 )
--result;
return result;
}

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

result = a1 - a7;
if ( a2 - a8 < 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));
}


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


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

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

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

result = 0LL;
if ( a2 )
result = jam(a1, "%s: ", a2);
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: struct jambuf { char *array; unsigned long total; unsigned long roof; char *dots; } *

variable_types:
progname
char *


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

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

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

if ( a1 && (v6 = a4, a3) )
{
v7 = a4;
if ( a2 <= a4 )
v7 = a2;
result = memcmp(a1, a3, v7);
v9 = a2 - v6;
if ( !result )
result = v9;
}
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, __int64 a2, const void *a3, size_t a4)
{
bool result; // al

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

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

result = a3 == 0LL || a1 == 0LL;
if ( result )
return a1 == a3;
if ( a2 == a4 )
result = memcmp(a1, a3, a4) == 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, __int64 a2, const char *a3, size_t a4)
{
bool result; // al

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

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

result = a3 == 0LL || a1 == 0LL;
if ( result )
return a1 == a3;
if ( a2 == a4 )
result = strncasecmp(a1, a3, a4) == 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 int i; // eax
unsigned __int64 v5; // [rsp+8h] [rbp-10h]

v5 = __readfsqword(0x28u);
for ( i = 0; i < a3; ++i )
{
*(_BYTE *)(a2 + (_DWORD)a3 - 1 - i) = a1;
a1 >>= 8;
}
return v5 - __readfsqword(0x28u);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(unsigned __int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned int i; // eax
unsigned __int64 v5; // [rsp+8h] [rbp-10h]

v5 = __readfsqword(0x28u);
for ( i = 0; i < a3; ++i )
{
*(_BYTE *)(a2 + (_DWORD)a3 - 1 - i) = a1;
a1 >>= 8;
}
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(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // rax
unsigned int v3; // ecx
unsigned __int64 v4; // rdx
unsigned __int64 v5; // rax

v2 = 0LL;
if ( !a2 )
return 0LL;
v3 = 0;
v4 = 0LL;
do
{
v5 = (v4 << 8) + *(unsigned __int8 *)(a1 + v2);
if ( v5 < v4 )
v5 = -1LL;
v4 = v5;
v2 = ++v3;
}
while ( v3 < a2 );
return v4;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // rax
unsigned int v3; // ecx
unsigned __int64 v4; // rdx
unsigned __int64 v5; // rax

v2 = 0LL;
if ( !a2 )
return 0LL;
v3 = 0;
v4 = 0LL;
do
{
v5 = (v4 << 8) + *(unsigned __int8 *)(a1 + v2);
if ( v5 < v4 )
v5 = -1LL;
v4 = v5;
v2 = ++v3;
}
while ( v3 < a2 );
return v4;
}

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 func6(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 func7(char a1)
{
return (unsigned __int8)(a1 - 97) <= 0x19u;
}

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


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

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

canonical_decompiled_code:
_BOOL8 __fastcall func8(char a1)
{
bool v1; // al

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


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 func9(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 func10(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 func11(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 func12(char a1)
{
return (unsigned __int8)(a1 - 48) <= 7u;
}

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


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

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

canonical_decompiled_code:
_BOOL8 __fastcall func13(char a1)
{
bool v1; // al

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


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

canonical_decompiled_code:
_BOOL8 __fastcall func14(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; // dl
__int64 result; // rax

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

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

v1 = func6(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; // dl
__int64 result; // rax

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

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

v1 = func7(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 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 = 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 func18(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; }