decompiled_code:
__int64 __fastcall m3l_ACKN(char *s)
{
_QWORD *v1; // rbp
__int64 v2; // rbx
__int64 v4[4]; // [rsp+8h] [rbp-20h] BYREF

v4[0] = m3l_Mklist("ackn", &LC0, 0LL, 0LL, 0LL, 0LL, 0LL);
if ( !v4[0] )
Perror("m3l_Mklist", 0LL);
v1 = malloc(8uLL);
*v1 = strlen(s);
v2 = m3l_Mklist("ANSWER", "C", 1LL, v1, v4, "/ackn", "./");
if ( !v2 )
Error("m3l_Mklist", "C", 0LL);
*(_QWORD *)(v2 + 32) = s;
free(v1);
return v4[0];
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s)
{
_QWORD *v1; // rbp
__int64 v2; // rbx
__int64 v4[4]; // [rsp+8h] [rbp-20h] BYREF

v4[0] = m3l_Mklist("ackn", &LC0, 0LL, 0LL, 0LL, 0LL, 0LL);
if ( !v4[0] )
Perror("m3l_Mklist", 0LL);
v1 = malloc(8uLL);
*v1 = strlen(s);
v2 = m3l_Mklist("ANSWER", "C", 1LL, v1, v4, "/ackn", "./");
if ( !v2 )
Error("m3l_Mklist", "C", 0LL);
*(_QWORD *)(v2 + 32) = s;
free(v1);
return v4[0];
}

original_code:
node_t *m3l_ACKN(char *answer)
{
 node_t *Gnode, *TmpNode;
 size_t *dim;
 if( (Gnode = m3l_Mklist("ackn", "DIR", 0, 0, (node_t **)((void *)0), (const char *)((void *)0), (const char *)((void *)0), (char *)((void *)0))) == 0)
  Perror("m3l_Mklist");
 dim = (size_t *) malloc( 1* sizeof(size_t));
 dim[0] = strlen(answer);
 if( (TmpNode = m3l_Mklist("ANSWER", "C", 1, dim, &Gnode, "/ackn", "./", (char *)((void *)0))) == 0)
  Error("m3l_Mklist");
 TmpNode->data.c = answer;
 free(dim);
  return Gnode;
}

canonical_original_code:
struct node *m3l_ACKN(char *answer)
{
 struct node *Gnode; struct node *TmpNode;
 unsigned long *dim;
 if( (Gnode = m3l_Mklist("ackn", "DIR", 0, 0, (struct node **)((void *)0), (char *)((void *)0), (char *)((void *)0), (char *)((void *)0))) == 0)
  Perror("m3l_Mklist");
 dim = (unsigned long *) malloc( 1* sizeof(unsigned long));
 dim[0] = strlen(answer);
 if( (TmpNode = m3l_Mklist("ANSWER", "C", 1, dim, &Gnode, "/ackn", "./", (char *)((void *)0))) == 0)
  Error("m3l_Mklist");
 TmpNode->data.c = answer;
 free(dim);
  return Gnode;
}

variable_types:
answer
char *

variable_types: struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; } data; long create_time; struct node *next; struct find_str { struct node *List; } **linknode; unsigned long lcounter; char no_malloc; int ap; } *

variable_types:
dim
unsigned long *


MkTCPIPHeader

decompiled_code:
__int64 __fastcall MkTCPIPHeader(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
_QWORD *v3; // rax
__int64 v4; // rdx
__int64 v5; // r12
int v6; // eax
__int64 v8; // [rsp+8h] [rbp-B0h] BYREF
__int64 v9; // [rsp+10h] [rbp-A8h] BYREF
char *v10; // [rsp+18h] [rbp-A0h] BYREF
char v11; // [rsp+20h] [rbp-98h] BYREF
char v12[21]; // [rsp+50h] [rbp-68h] BYREF
char v13[6]; // [rsp+65h] [rbp-53h] BYREF
__int64 v14; // [rsp+88h] [rbp-30h]
void *ptr; // [rsp+90h] [rbp-28h]

v10 = &v11;
m3l_set_MkTCPIPHeader(&v10);
strcpy(v13, "ader-");
*(__m128i *)&v12[5] = _mm_load_si128((const __m128i *)&LC10);
strcpy(v12, "DIR");
v14 = 0LL;
ptr = 0LL;
v8 = m3l_AllocateNode(a1);
if ( v8 )
{
strcpy(&v12[5], "TCPIP_encoding");
strcpy(v12, "C");
v14 = 1LL;
v3 = malloc(8uLL);
ptr = v3;
if ( !v3 )
{
Perror("malloc", a2);
v3 = ptr;
}
*v3 = 2LL;
v9 = m3l_AllocateNode(v10);
v5 = v9;
if ( v9 )
{
free(ptr);
**(_BYTE **)(v9 + 32) = *(_BYTE *)(a1 + 33);
*(_BYTE *)(*(_QWORD *)(v9 + 32) + 1LL) = 0;
v6 = m3l_add_list(&v9, &v8, v10);
v5 = v8;
if ( v6 < 0 )
{
v5 = 0LL;
Warning("problem in add_list");
m3l_rm_list(1LL, &v8, v10);
m3l_rm_list(1LL, &v9, v10);
}
}
else
{
Error("Allocate", a2, v4);
free(ptr);
m3l_rm_list(1LL, &v8, a1);
}
}
else
{
v5 = 0LL;
Error("Allocate", a2, v2);
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
_QWORD *v3; // rax
__int64 v4; // rdx
__int64 v5; // r12
int v6; // eax
__int64 v8; // [rsp+8h] [rbp-B0h] BYREF
__int64 v9; // [rsp+10h] [rbp-A8h] BYREF
char *v10; // [rsp+18h] [rbp-A0h] BYREF
char v11; // [rsp+20h] [rbp-98h] BYREF
char v12[21]; // [rsp+50h] [rbp-68h] BYREF
char v13[6]; // [rsp+65h] [rbp-53h] BYREF
__int64 v14; // [rsp+88h] [rbp-30h]
void *ptr; // [rsp+90h] [rbp-28h]

v10 = &v11;
m3l_set_MkTCPIPHeader(&v10);
strcpy(v13, "ader-");
*(__m128i *)&v12[5] = _mm_load_si128((const __m128i *)&LC10);
strcpy(v12, "DIR");
v14 = 0LL;
ptr = 0LL;
v8 = m3l_AllocateNode(a1);
if ( v8 )
{
strcpy(&v12[5], "TCPIP_encoding");
strcpy(v12, "C");
v14 = 1LL;
v3 = malloc(8uLL);
ptr = v3;
if ( !v3 )
{
Perror("malloc", a2);
v3 = ptr;
}
*v3 = 2LL;
v9 = m3l_AllocateNode(v10);
v5 = v9;
if ( v9 )
{
free(ptr);
**(_BYTE **)(v9 + 32) = *(_BYTE *)(a1 + 33);
*(_BYTE *)(*(_QWORD *)(v9 + 32) + 1LL) = 0;
v6 = m3l_add_list(&v9, &v8, v10);
v5 = v8;
if ( v6 < 0 )
{
v5 = 0LL;
Warning("problem in add_list");
m3l_rm_list(1LL, &v8, v10);
m3l_rm_list(1LL, &v9, v10);
}
}
else
{
Error("Allocate", a2, v4);
free(ptr);
m3l_rm_list(1LL, &v8, a1);
}
}
else
{
v5 = 0LL;
Error("Allocate", a2, v2);
}
return v5;
}

original_code:
node_t *MkTCPIPHeader(opts_t *Popts)
{
 node_t *Tmpnode, *AddNode;
 tmpstruct_t TMPSTR;
 opts_t *Poptadd, opts;
 Poptadd = &opts;
 m3l_set_MkTCPIPHeader(&Poptadd);
 if( snprintf(TMPSTR.Name_Of_List, sizeof(TMPSTR.Name_Of_List), "%s", "-libm3l_TCPIP_Header-") < 0)
     Perror("snprintf");
 if( snprintf(TMPSTR.Type, sizeof(TMPSTR.Type),"%s", "DIR") < 0)
     Perror("snprintf");
 TMPSTR.ndim = 0;
 TMPSTR.dim=((void *)0);
 if( (Tmpnode = m3l_AllocateNode(TMPSTR, Popts)) == ((void *)0)){
  Error("Allocate");
  return (node_t *) ((void *)0);
 }
 if( snprintf(TMPSTR.Name_Of_List, sizeof(TMPSTR.Name_Of_List),"%s", "TCPIP_encoding") < 0)
     Perror("snprintf");
 if( snprintf(TMPSTR.Type, sizeof(TMPSTR.Type),"%s", "C") < 0)
     Perror("snprintf");
 TMPSTR.ndim = 1;
 if( (TMPSTR.dim=(size_t *)malloc(TMPSTR.ndim * sizeof(size_t))) == ((void *)0))
  Perror("malloc");
 TMPSTR.dim[0]=2;
 if( (AddNode = m3l_AllocateNode(TMPSTR, Poptadd)) == ((void *)0)){
  Error("Allocate");
  free(TMPSTR.dim);
  if( m3l_rm_list(1, &Tmpnode, Popts) < 0)
   Warning("problem in rm_list");
  return (node_t *) ((void *)0);
 }
 free(TMPSTR.dim);
 AddNode->data.c[0] = Popts->opt_tcpencoding;
 AddNode->data.c[1] = '\0';
 if( m3l_add_list(&AddNode, &Tmpnode, Poptadd) < 0){
  Warning("problem in add_list");
  if( m3l_rm_list(1, &Tmpnode, Poptadd) < 0)
   Warning("problem in rm_list");
  if( m3l_rm_list(1, &AddNode, Poptadd) < 0)
   Warning("problem in rm_list");
  return (node_t *)((void *)0);
 }
 return Tmpnode;
}

canonical_original_code:
struct node *MkTCPIPHeader(struct opts *Popts)
{
 struct node *Tmpnode; struct node *AddNode;
 struct tmpstruct TMPSTR;
 struct opts *Poptadd; struct opts opts;
 Poptadd = &opts;
 m3l_set_MkTCPIPHeader(&Poptadd);
 if( snprintf(TMPSTR.Name_Of_List, sizeof(TMPSTR.Name_Of_List), "%s", "-libm3l_TCPIP_Header-") < 0)
     Perror("snprintf");
 if( snprintf(TMPSTR.Type, sizeof(TMPSTR.Type),"%s", "DIR") < 0)
     Perror("snprintf");
 TMPSTR.ndim = 0;
 TMPSTR.dim=((void *)0);
 if( (Tmpnode = m3l_AllocateNode(TMPSTR, Popts)) == ((void *)0)){
  Error("Allocate");
  return (struct node *) ((void *)0);
 }
 if( snprintf(TMPSTR.Name_Of_List, sizeof(TMPSTR.Name_Of_List),"%s", "TCPIP_encoding") < 0)
     Perror("snprintf");
 if( snprintf(TMPSTR.Type, sizeof(TMPSTR.Type),"%s", "C") < 0)
     Perror("snprintf");
 TMPSTR.ndim = 1;
 if( (TMPSTR.dim=(unsigned long *)malloc(TMPSTR.ndim * sizeof(unsigned long))) == ((void *)0))
  Perror("malloc");
 TMPSTR.dim[0]=2;
 if( (AddNode = m3l_AllocateNode(TMPSTR, Poptadd)) == ((void *)0)){
  Error("Allocate");
  free(TMPSTR.dim);
  if( m3l_rm_list(1, &Tmpnode, Popts) < 0)
   Warning("problem in rm_list");
  return (struct node *) ((void *)0);
 }
 free(TMPSTR.dim);
 AddNode->data.c[0] = Popts->opt_tcpencoding;
 AddNode->data.c[1] = '\0';
 if( m3l_add_list(&AddNode, &Tmpnode, Poptadd) < 0){
  Warning("problem in add_list");
  if( m3l_rm_list(1, &Tmpnode, Poptadd) < 0)
   Warning("problem in rm_list");
  if( m3l_rm_list(1, &AddNode, Poptadd) < 0)
   Warning("problem in rm_list");
  return (struct node *)((void *)0);
 }
 return Tmpnode;
}

variable_types: struct opts { char opt_a; char opt_b; char opt_c; char opt_d; char opt_e; char opt_f; char opt_i; char opt_k; char opt_l; char opt_m; char opt_n; char opt_p; char opt_r; char opt_s; char opt_u; char opt_linkscleanemptrefs; char opt_nomalloc; char opt_tcpencoding; char opt_tcpheader; char opt_shutdown; char opt_add; char opt_MEMCP; char opt_EOBseq; char opt_REOBseq; char opt_format; char opt_xformat; } *

variable_types: struct tmpstruct { char Type[5]; unsigned long ndim; }

return_type: struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; } data; long create_time; struct node *next; struct find_str { struct node *List; } **linknode; unsigned long lcounter; char no_malloc; int ap; } *

user_defined_types: struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t data; long create_time; struct node *next; struct find_str **linknode; unsigned long lcounter; char no_malloc; int ap; }


decompiled_code:
__int64 __fastcall m3l_Umount(_QWORD *a1)
{
__int64 result; // rax

if ( *a1 )
{
m3l_rm_list(2LL, a1, 0LL);
*a1 = 0LL;
result = 1LL;
}
else
{
Warning("Umount: : NULL list");
result = 0xFFFFFFFFLL;
}
return result;
}

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

if ( *a1 )
{
m3l_rm_list(2LL, a1, 0LL);
*a1 = 0LL;
result = 1LL;
}
else
{
Warning("Umount: : NULL list");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int m3l_Umount(node_t **List)
{
 if( (*List) == ((void *)0)){
  Warning("Umount: : NULL list");
  return -1;
 }
 if( m3l_rm_list(2, List, (opts_t *)((void *)0)) < 0){
  Error("Unable to unmount node \n");
  return -1;
 }
 *List = ((void *)0);
 return 1;
}

canonical_original_code:
int m3l_Umount(struct node **List)
{
 if( (*List) == ((void *)0)){
  Warning("Umount: : NULL list");
  return -1;
 }
 if( m3l_rm_list(2, List, (struct opts *)((void *)0)) < 0){
  Error("Unable to unmount node \n");
  return -1;
 }
 *List = ((void *)0);
 return 1;
}

variable_types: struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; } data; long create_time; struct node *next; struct find_str { struct node *List; } **linknode; unsigned long lcounter; char no_malloc; int ap; } **

return_type: int

user_defined_types: struct opts { char opt_a; char opt_b; char opt_c; char opt_d; char opt_e; char opt_f; char opt_i; char opt_k; char opt_l; char opt_m; char opt_n; char opt_p; char opt_r; char opt_s; char opt_u; char opt_linkscleanemptrefs; char opt_nomalloc; char opt_tcpencoding; char opt_tcpheader; char opt_shutdown; char opt_add; char opt_MEMCP; char opt_EOBseq; char opt_REOBseq; char opt_format; char opt_xformat; }


original_code:
size_t m3l_detach_list(int call, node_t **List, opts_t *Popts)
{
 node_t *PAR, *CLD, *NEXT, *PREV, *CURR;
 if((*List) == ((void *)0)){
  Warning("detach_list: : NULL list");
  return -1;
 }
 if((*List)->parent == ((void *)0)){
  return 0;
 }
 PAR = (*List)->parent;
 CLD = (*List)->child;
 NEXT = (*List)->next;
 PREV = (*List)->prev;
 CURR = (*List);
 if(PREV == ((void *)0) && NEXT == ((void *)0)){
  ((*List)->parent)->child = ((void *)0);
 }
 else if (PREV == ((void *)0))
 {
  NEXT->prev = ((void *)0);
  ((*List)->parent)->child = NEXT;
 }
  else if(NEXT == ((void *)0)){
  PREV->next = ((void *)0);
 }
 else
 {
  PREV->next = NEXT;
  NEXT->prev = PREV;
 }
 (*List)->parent->ndim--;
 (*List)->parent = ((void *)0);
 (*List)->prev = ((void *)0);
 (*List)->next = ((void *)0);
 return 1;
}

canonical_original_code:
unsigned long m3l_detach_list(int call, struct node **List, struct opts *Popts)
{
 struct node *PAR; struct node *CLD; struct node *NEXT; struct node *PREV; struct node *CURR;
 if((*List) == ((void *)0)){
  Warning("detach_list: : NULL list");
  return -1;
 }
 if((*List)->parent == ((void *)0)){
  return 0;
 }
 PAR = (*List)->parent;
 CLD = (*List)->child;
 NEXT = (*List)->next;
 PREV = (*List)->prev;
 CURR = (*List);
 if(PREV == ((void *)0) && NEXT == ((void *)0)){
  ((*List)->parent)->child = ((void *)0);
 }
 else if (PREV == ((void *)0))
 {
  NEXT->prev = ((void *)0);
  ((*List)->parent)->child = NEXT;
 }
  else if(NEXT == ((void *)0)){
  PREV->next = ((void *)0);
 }
 else
 {
  PREV->next = NEXT;
  NEXT->prev = PREV;
 }
 (*List)->parent->ndim--;
 (*List)->parent = ((void *)0);
 (*List)->prev = ((void *)0);
 (*List)->next = ((void *)0);
 return 1;
}

variable_types: call int

return_type: unsigned long

user_defined_types: union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; }


original_code:
uint64_t pack754(long double f, unsigned bits, unsigned expbits)
{
 long double fnorm;
 int shift;
 long long int sign, exp, significand;
 unsigned significandbits = bits - expbits - 1;
 if (f == 0.0) return 0;
 if (f < 0) {
  sign = 1; fnorm = -f;
 }
 else {
  sign = 0; fnorm = f;
 }
 shift = 0;
 while(fnorm >= 2.0) { fnorm /= 2.0; shift++; }
 while(fnorm < 1.0) { fnorm *= 2.0; shift--; }
 fnorm = fnorm - 1.0;
 significand = fnorm * ((1LL<<significandbits) + 0.5f);
 exp = shift + ((1<<(expbits-1)) - 1);
 return (sign<<(bits-1)) | (exp<<(bits-expbits-1)) | significand;
}

canonical_original_code:
unsigned long pack754(long double f, unsigned int bits, unsigned int expbits)
{
 long double fnorm;
 int shift;
 long long sign; long long exp; long long significand;
 unsigned int significandbits = bits - expbits - 1;
 if (f == 0.0) return 0;
 if (f < 0) {
  sign = 1; fnorm = -f;
 }
 else {
  sign = 0; fnorm = f;
 }
 shift = 0;
 while(fnorm >= 2.0) { fnorm /= 2.0; shift++; }
 while(fnorm < 1.0) { fnorm *= 2.0; shift--; }
 fnorm = fnorm - 1.0;
 significand = fnorm * ((1LL<<significandbits) + 0.5f);
 exp = shift + ((1<<(expbits-1)) - 1);
 return (sign<<(bits-1)) | (exp<<(bits-expbits-1)) | significand;
}

variable_types:
f
long double

variable_types:
bits
unsigned int

variable_types:
expbits
unsigned int

variable_types:
fnorm
long double

variable_types: shift int

variable_types:
sign
long long

variable_types:
exp
long long

variable_types:
significand
long long

variable_types:
significandbits
unsigned int


decompiled_code:
long double __fastcall unpack754(unsigned __int64 a1, int a2, char a3)
{
char v3; // r8
__int64 v4; // rax
long double result; // fst7

if ( !a1 )
return 0.0;
v3 = a2 - a3 - 1;
v4 = ((a1 >> v3) & ((1LL << a3) - 1)) - (unsigned int)((1 << (a3 - 1)) - 1);
result = (long double)(a1 & ((1LL << v3) - 1)) / (long double)(1LL << v3) + 1.0;
if ( v4 <= 0 )
{
if ( ((a1 >> v3) & ((1LL << a3) - 1)) != (1 << (a3 - 1)) - 1 )
{
do
{
result = result * 0.5;
++v4;
}
while ( v4 );
if ( _bittest64((const __int64 *)&a1, (unsigned int)(a2 - 1)) )
return -result;
return result;
}
}
else
{
do
{
result = result + result;
--v4;
}
while ( v4 );
}
if ( _bittest64((const __int64 *)&a1, (unsigned int)(a2 - 1)) )
return -result;
return result;
}

canonical_decompiled_code:
long double __fastcall func1(unsigned __int64 a1, int a2, char a3)
{
char v3; // r8
__int64 v4; // rax
long double result; // fst7

if ( !a1 )
return 0.0;
v3 = a2 - a3 - 1;
v4 = ((a1 >> v3) & ((1LL << a3) - 1)) - (unsigned int)((1 << (a3 - 1)) - 1);
result = (long double)(a1 & ((1LL << v3) - 1)) / (long double)(1LL << v3) + 1.0;
if ( v4 <= 0 )
{
if ( ((a1 >> v3) & ((1LL << a3) - 1)) != (1 << (a3 - 1)) - 1 )
{
do
{
result = result * 0.5;
++v4;
}
while ( v4 );
if ( _bittest64((const __int64 *)&a1, (unsigned int)(a2 - 1)) )
return -result;
return result;
}
}
else
{
do
{
result = result + result;
--v4;
}
while ( v4 );
}
if ( _bittest64((const __int64 *)&a1, (unsigned int)(a2 - 1)) )
return -result;
return result;
}

original_code:
long double unpack754(uint64_t i, unsigned bits, unsigned expbits)
{
 long double result;
 long long int shift;
 unsigned bias;
 unsigned significandbits = bits - expbits - 1;
 if (i == 0) return 0.0;
 result = (i&((1LL<<significandbits)-1));
 result /= (1LL<<significandbits);
 result += 1.0f;
 bias = (1<<(expbits-1)) - 1;
 shift = ((i>>significandbits)&((1LL<<expbits)-1)) - bias;
 while(shift > 0) { result *= 2.0; shift--; }
 while(shift < 0) { result /= 2.0; shift++; }
 result *= (i>>(bits-1))&1? -1.0: 1.0;
 return result;
}

canonical_original_code:
long double unpack754(unsigned long i, unsigned int bits, unsigned int expbits)
{
 long double result;
 long long shift;
 unsigned int bias;
 unsigned int significandbits = bits - expbits - 1;
 if (i == 0) return 0.0;
 result = (i&((1LL<<significandbits)-1));
 result /= (1LL<<significandbits);
 result += 1.0f;
 bias = (1<<(expbits-1)) - 1;
 shift = ((i>>significandbits)&((1LL<<expbits)-1)) - bias;
 while(shift > 0) { result *= 2.0; shift--; }
 while(shift < 0) { result /= 2.0; shift++; }
 result *= (i>>(bits-1))&1? -1.0: 1.0;
 return result;
}

variable_types:
i
unsigned long

variable_types:
result
long double

variable_types:
shift
long long

variable_types:
bias
unsigned int

return_type: long double


decompiled_code:
char *__fastcall double_2_Hex(double a1)
{
char *v1; // rbx
char *v2; // rbp
__int64 v3; // rdx
char *v4; // rdi
double v6; // [rsp+8h] [rbp-50h] BYREF
char s[16]; // [rsp+10h] [rbp-48h] BYREF
char v8; // [rsp+20h] [rbp-38h] BYREF

v6 = a1;
v1 = (char *)&v6;
v2 = s;
do
{
v3 = (unsigned int)*v1;
v4 = v2;
++v1;
v2 += 2;
sprintf(v4, "%02X", v3);
}
while ( v1 != s );
return &v8;
}

canonical_decompiled_code:
char *__fastcall func2(double a1)
{
char *v1; // rbx
char *v2; // rbp
__int64 v3; // rdx
char *v4; // rdi
double v6; // [rsp+8h] [rbp-50h] BYREF
char s[16]; // [rsp+10h] [rbp-48h] BYREF
char v8; // [rsp+20h] [rbp-38h] BYREF

v6 = a1;
v1 = (char *)&v6;
v2 = s;
do
{
v3 = (unsigned int)*v1;
v4 = v2;
++v1;
v2 += 2;
sprintf(v4, "%02X", v3);
}
while ( v1 != s );
return &v8;
}

original_code:
char * double_2_Hex(double a)
{
 char buf[17];
 char *d2c;
 char *n = buf;
 int i;
 d2c = (char *) &a;
 for(i = 0; i < 8; i++){
  sprintf(n, "%02X", *d2c++);
  n += 2;
 }
 *(n) = '\0';
 return n;
}

canonical_original_code:
char *double_2_Hex(double a)
{
 char buf[17];
 char *d2c;
 char *n = buf;
 int i;
 d2c = (char *) &a;
 for(i = 0; i < 8; i++){
  sprintf(n, "%02X", *d2c++);
  n += 2;
 }
 *(n) = '\0';
 return n;
}

variable_types: a double

variable_types:
buf
char [17]

variable_types:
n
char *

variable_types: i int

return_type: char *


decompiled_code:
__int64 __fastcall hex2dec(const char *a1)
{
int v1; // er12
__int64 v2; // r14
int v3; // ebp
const char *v4; // r13
int v5; // ebx
double v6; // xmm1_8
char v7; // bl

v1 = strlen(a1);
if ( v1 - 1 < 0 )
return 0LL;
LODWORD(v2) = 0;
v3 = 0;
v4 = &a1[v1 - 1];
while ( 1 )
{
v7 = *v4;
if ( (unsigned __int8)(*v4 - 48) > 9u )
break;
v5 = (char)(v7 - 48);
LABEL_4:
--v4;
v6 = (double)v3++;
v2 = (unsigned int)(int)((double)v5 * pow(16.0, v6) + (double)(int)v2);
if ( v1 == v3 )
return v2;
}
if ( (unsigned __int8)(v7 - 65) <= 5u )
{
v5 = (char)(v7 - 55);
goto LABEL_4;
}
v2 = -1LL;
printf("The Entered number is not hexadecimal number");
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
int v1; // er12
__int64 v2; // r14
int v3; // ebp
const char *v4; // r13
int v5; // ebx
double v6; // xmm1_8
char v7; // bl

v1 = strlen(a1);
if ( v1 - 1 < 0 )
return 0LL;
LODWORD(v2) = 0;
v3 = 0;
v4 = &a1[v1 - 1];
while ( 1 )
{
v7 = *v4;
if ( (unsigned __int8)(*v4 - 48) > 9u )
break;
v5 = (char)(v7 - 48);
LABEL_4:
--v4;
v6 = (double)v3++;
v2 = (unsigned int)(int)((double)v5 * pow(16.0, v6) + (double)(int)v2);
if ( v1 == v3 )
return v2;
}
if ( (unsigned __int8)(v7 - 65) <= 5u )
{
v5 = (char)(v7 - 55);
goto LABEL_4;
}
v2 = -1LL;
printf("The Entered number is not hexadecimal number");
return v2;
}

original_code:
long int hex2dec(char *hex)
{
 int i,num,len,counter;
 long int sum=0;
 len=strlen(hex);
 counter = 0;
 for(i=len-1;i>=0;i--){
  if(hex[i]>='0'&&hex[i]<='9')
   num=hex[i]-'0';
  else{
   if(hex[i]>='A'&&hex[i]<='F')
    num=hex[i]-55;
   else{
    printf("The Entered number is not hexadecimal number");
    return -1;
   }
  }
  sum=sum+pow(16,counter)*num;
  counter++;
 }
 return sum;
}

canonical_original_code:
long hex2dec(char *hex)
{
 int i; int num; int len; int counter;
 long sum = 0;
 len=strlen(hex);
 counter = 0;
 for(i=len-1;i>=0;i--){
  if(hex[i]>='0'&&hex[i]<='9')
   num=hex[i]-'0';
  else{
   if(hex[i]>='A'&&hex[i]<='F')
    num=hex[i]-55;
   else{
    printf("The Entered number is not hexadecimal number");
    return -1;
   }
  }
  sum=sum+pow(16,counter)*num;
  counter++;
 }
 return sum;
}

variable_types:
hex
char *

variable_types: num int

variable_types: len int

variable_types: counter int

variable_types: sum long

return_type: long


original_code:
size_t m3l_rm(node_t **List, const char *path, const char *path_loc, opts_t *Popts)
{
 size_t i, rm_tot_nodes, rm_nodes;
 find_t *Founds;
 int init_call;
 if( (*List) == ((void *)0)){
  Warning("rm_list: NULL list");
  return 0;
 }
 if ( (Founds = m3l_locate( *List, path, path_loc, Popts)) == ((void *)0)){
  return 0;
 }
 else
 {
  if(Popts->opt_k == 'k'){
   init_call = 1;
  }
  else{
   init_call = 2;
  }
  rm_tot_nodes = 0;
  for(i=0; i< Founds->founds; i++){
   if( (rm_nodes = m3l_rm_list(init_call, &Founds->Found_Nodes[i]->List, Popts)) < 0){
    Warning("problem in rm_list");
   }
   else{
    rm_tot_nodes += rm_nodes;
   }
  }
  if(Founds->founds == 1 && Founds->Found_Nodes[0]->List == (*List) && Popts->opt_k != 'k') (*List) = ((void *)0);
  m3l_DestroyFound(&Founds);
  return rm_tot_nodes;
 }
}

canonical_original_code:
unsigned long m3l_rm(struct node **List, char *path, char *path_loc, struct opts *Popts)
{
 unsigned long i; unsigned long rm_tot_nodes; unsigned long rm_nodes;
 struct find *Founds;
 int init_call;
 if( (*List) == ((void *)0)){
  Warning("rm_list: NULL list");
  return 0;
 }
 if ( (Founds = m3l_locate( *List, path, path_loc, Popts)) == ((void *)0)){
  return 0;
 }
 else
 {
  if(Popts->opt_k == 'k'){
   init_call = 1;
  }
  else{
   init_call = 2;
  }
  rm_tot_nodes = 0;
  for(i=0; i< Founds->founds; i++){
   if( (rm_nodes = m3l_rm_list(init_call, &Founds->Found_Nodes[i]->List, Popts)) < 0){
    Warning("problem in rm_list");
   }
   else{
    rm_tot_nodes += rm_nodes;
   }
  }
  if(Founds->founds == 1 && Founds->Found_Nodes[0]->List == (*List) && Popts->opt_k != 'k') (*List) = ((void *)0);
  m3l_DestroyFound(&Founds);
  return rm_tot_nodes;
 }
}

variable_types: struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; } data; long create_time; struct node *next; struct find_str { struct node *List; } **linknode; unsigned long lcounter; char no_malloc; int ap; } **

variable_types:
path
char *

variable_types: struct opts { char opt_a; char opt_b; char opt_c; char opt_d; char opt_e; char opt_f; char opt_i; char opt_k; char opt_l; char opt_m; char opt_n; char opt_p; char opt_r; char opt_s; char opt_u; char opt_linkscleanemptrefs; char opt_nomalloc; char opt_tcpencoding; char opt_tcpheader; char opt_shutdown; char opt_add; char opt_MEMCP; char opt_EOBseq; char opt_REOBseq; char opt_format; char opt_xformat; } *

variable_types: struct find { struct find_str { struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; } data; long create_time; struct node *next; struct find_str **linknode; unsigned long lcounter; char no_malloc; int ap; } *List; } **Found_Nodes; unsigned long founds; struct node *Home_Node; } *

user_defined_types: struct find { struct find_str **Found_Nodes; unsigned long founds; struct node *Home_Node; }


repo: libor-m/ngsClean

decompiled_code:
void __noreturn fatal_error(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
fflush(stdout);
fwrite("[FLASH] ERROR: ", 1uLL, 0xFuLL, stderr);
vfprintf(stderr, a1, arg);
putc(10, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func0(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
fflush(stdout);
fwrite("[FLASH] ERROR: ", 1uLL, 0xFuLL, stderr);
vfprintf(stderr, a1, arg);
putc(10, stderr);
exit(1);
}

original_code:
void fatal_error(const char *msg, ...)
{
 va_list va;
 __builtin_va_start(va,msg);
 fflush(stdout);
 fputs("[FLASH] " "ERROR: ", stderr);
 vfprintf(stderr, msg, va);
 putc('\n', stderr);
 __builtin_va_end(va);
 exit(1);
}

canonical_original_code:
void fatal_error(char *msg, ...)
{
 __builtin_va_list va;
 __builtin_va_start(va,msg);
 fflush(stdout);
 fputs("[FLASH] " "ERROR: ", stderr);
 vfprintf(stderr, msg, va);
 putc('\n', stderr);
 __builtin_va_end(va);
 exit(1);
}

variable_types:
msg
char *

return_type: void


decompiled_code:
void __noreturn fatal_error_with_errno(const char *a1, ...)
{
int *v1; // rax
char *v2; // rax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
fflush(stdout);
fwrite("[FLASH] ERROR: ", 1uLL, 0xFuLL, stderr);
vfprintf(stderr, a1, arg);
v1 = _errno_location();
v2 = strerror(*v1);
fprintf(stderr, ": %s\n", v2);
exit(1);
}

canonical_decompiled_code:
void __noreturn func1(const char *a1, ...)
{
int *v1; // rax
char *v2; // rax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
fflush(stdout);
fwrite("[FLASH] ERROR: ", 1uLL, 0xFuLL, stderr);
vfprintf(stderr, a1, arg);
v1 = _errno_location();
v2 = strerror(*v1);
fprintf(stderr, ": %s\n", v2);
exit(1);
}

original_code:
void fatal_error_with_errno(const char *msg, ...)
{
 va_list va;
 __builtin_va_start(va,msg);
 fflush(stdout);
 fputs("[FLASH] " "ERROR: ", stderr);
 vfprintf(stderr, msg, va);
 fprintf(stderr, ": %s\n", strerror((*__errno_location ())));
 __builtin_va_end(va);
 exit(1);
}

canonical_original_code:
void fatal_error_with_errno(char *msg, ...)
{
 __builtin_va_list va;
 __builtin_va_start(va,msg);
 fflush(stdout);
 fputs("[FLASH] " "ERROR: ", stderr);
 vfprintf(stderr, msg, va);
 fprintf(stderr, ": %s\n", strerror((*__errno_location ())));
 __builtin_va_end(va);
 exit(1);
}


warning

decompiled_code:
int warning(char *format, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, format);
fwrite("[FLASH] WARNING: ", 1uLL, 0x11uLL, stderr);
fprintf(stderr, format, va);
return putc(10, stderr);
}

canonical_decompiled_code:
int func2(char *format, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, format);
fwrite("[FLASH] WARNING: ", 1uLL, 0x11uLL, stderr);
fprintf(stderr, format, va);
return putc(10, stderr);
}

original_code:
void warning(const char *msg, ...)
{
 va_list va;
 __builtin_va_start(va,msg);
 fputs("[FLASH] " "WARNING: ", stderr);
 fprintf(stderr, msg, va);
 putc('\n', stderr);
 __builtin_va_end(va);
}

canonical_original_code:
void warning(char *msg, ...)
{
 __builtin_va_list va;
 __builtin_va_start(va,msg);
 fputs("[FLASH] " "WARNING: ", stderr);
 fprintf(stderr, msg, va);
 putc('\n', stderr);
 __builtin_va_end(va);
}


info

decompiled_code:
void info(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
flockfile(stdout);
fwrite("[FLASH] ", 1uLL, 8uLL, stdout);
vprintf(format, arg);
putchar(10);
fflush(stdout);
funlockfile(stdout);
}

canonical_decompiled_code:
void func3(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
flockfile(stdout);
fwrite("[FLASH] ", 1uLL, 8uLL, stdout);
vprintf(format, arg);
putchar(10);
fflush(stdout);
funlockfile(stdout);
}

original_code:
void info(const char *msg, ...)
{
 va_list va;
 __builtin_va_start(va,msg);
 flockfile(stdout);
 fputs("[FLASH] ", stdout);
 vprintf(msg, va);
 putchar('\n');
 fflush(stdout);
 __builtin_va_end(va);
 funlockfile(stdout);
}

canonical_original_code:
void info(char *msg, ...)
{
 __builtin_va_list va;
 __builtin_va_start(va,msg);
 flockfile(stdout);
 fputs("[FLASH] ", stdout);
 vprintf(msg, va);
 putchar('\n');
 fflush(stdout);
 __builtin_va_end(va);
 funlockfile(stdout);
}


decompiled_code:
__int64 __fastcall get_default_num_threads(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rdx
__int64 v4; // rcx
unsigned int v5; // er8

v2 = sysconf(84);
v5 = v2;
if ( v2 == -1 )
{
warning("Could not deteremine number of processors! Assuming 1", a2, v3, v4, 0xFFFFFFFFLL);
v5 = 1;
}
return v5;
}

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

v2 = sysconf(84);
v5 = v2;
if ( v2 == -1 )
{
func2("Could not deteremine number of processors! Assuming 1", a2, v3, v4, 0xFFFFFFFFLL);
v5 = 1;
}
return v5;
}

original_code:
unsigned get_default_num_threads()
{
 long nthreads = sysconf(_SC_NPROCESSORS_ONLN);
 if (nthreads == -1) {
  warning("Could not deteremine number of processors! Assuming 1");
  return 1;
 } else {
  return (unsigned)nthreads;
 }
}

canonical_original_code:
unsigned int get_default_num_threads()
{
 long nthreads = sysconf(_SC_NPROCESSORS_ONLN);
 if (nthreads == -1) {
  warning("Could not deteremine number of processors! Assuming 1");
  return 1;
 } else {
  return (unsigned int)nthreads;
 }
}

variable_types: nthreads long

return_type: unsigned int


xmalloc

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

result = malloc(a1);
if ( !result )
fatal_error("Out of memory: tried to allocate %zu bytes", a1);
return result;
}

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

result = malloc(a1);
if ( !result )
func0("Out of memory: tried to allocate %zu bytes", a1);
return result;
}

original_code:
void *xmalloc(size_t size)
{
 void *p = malloc(size);
 if (!p)
  fatal_error("Out of memory: tried to allocate %zu bytes", size);
 return p;
}

canonical_original_code:
void *xmalloc(unsigned long size)
{
 void *p = malloc(size);
 if (!p)
  fatal_error("Out of memory: tried to allocate %zu bytes", size);
 return p;
}

variable_types:
size
unsigned long

variable_types:
p
void *

return_type: void *


xrealloc

decompiled_code:
void *__fastcall xrealloc(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
fatal_error("Out of memory: tried to reallocate %zu bytes", a2);
return result;
}

canonical_decompiled_code:
void *__fastcall func6(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
func0("Out of memory: tried to reallocate %zu bytes", a2);
return result;
}

original_code:
void *xrealloc(void *ptr, size_t size)
{
 void *p = realloc(ptr, size);
 if (!p)
  fatal_error("Out of memory: tried to reallocate %zu bytes", size);
 return p;
}

canonical_original_code:
void *xrealloc(void *ptr, unsigned long size)
{
 void *p = realloc(ptr, size);
 if (!p)
  fatal_error("Out of memory: tried to reallocate %zu bytes", size);
 return p;
}

variable_types:
ptr
void *


xgzopen

decompiled_code:
__int64 __fastcall xgzopen(const char *a1, const char *a2)
{
char *v2; // rax
__int64 result; // rax
const char *v4; // rdx
int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( !strcmp(a1, "-") )
{
v2 = strchr(a2, 119);
result = gzdopen(v2 != 0LL, a2);
}
else
{
result = gzopen64(a1, a2);
}
if ( !result )
{
v4 = (const char *)gzerror(0LL, v5);
if ( v5[0] == -1 )
fatal_error_with_errno("Failed to open the file \"%s\"", a1);
fatal_error("zlib error opening \"%s\": %s", a1, v4);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1, const char *a2)
{
char *v2; // rax
__int64 result; // rax
const char *v4; // rdx
int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( !strcmp(a1, "-") )
{
v2 = strchr(a2, 119);
result = gzdopen(v2 != 0LL, a2);
}
else
{
result = gzopen64(a1, a2);
}
if ( !result )
{
v4 = (const char *)gzerror(0LL, v5);
if ( v5[0] == -1 )
func1("Failed to open the file \"%s\"", a1);
func0("zlib error opening \"%s\": %s", a1, v4);
}
return result;
}

original_code:
void *xgzopen(const char *filename, const char *mode)
{
 gzFile f;
 if (strcmp(filename, "-") == 0) {
  int fd;
  if (strchr(mode, 'w'))
   fd = 1;
  else
   fd = 0;
  f = gzdopen(fd, mode);
 } else {
  f = gzopen64(filename, mode);
 }
 if (!f) {
  const char *err_str;
  int errnum;
  err_str = gzerror(f, &errnum);
  if (errnum == (-1))
   fatal_error_with_errno("Failed to open the file \"%s\"",
            filename);
  else
   fatal_error("zlib error opening \"%s\": %s",
        filename, err_str);
 }
 return f;
}

canonical_original_code:
void *xgzopen(char *filename, char *mode)
{
 struct gzFile_s *f;
 if (strcmp(filename, "-") == 0) {
  int fd;
  if (strchr(mode, 'w'))
   fd = 1;
  else
   fd = 0;
  f = gzdopen(fd, mode);
 } else {
  f = gzopen64(filename, mode);
 }
 if (!f) {
  char *err_str;
  int errnum;
  err_str = gzerror(f, &errnum);
  if (errnum == (-1))
   fatal_error_with_errno("Failed to open the file \"%s\"",
            filename);
  else
   fatal_error("zlib error opening \"%s\": %s",
        filename, err_str);
 }
 return f;
}

variable_types:
filename
char *

variable_types:
mode
char *

variable_types: struct gzFile_s { unsigned int have; unsigned char *next; long pos; } *

variable_types: fd int

variable_types: errnum int


xgzclose

decompiled_code:
void __fastcall xgzclose(__int64 a1)
{
if ( a1 )
{
if ( (unsigned int)gzclose(a1) )
fatal_error_with_errno("Failed to close output file");
}
}

canonical_decompiled_code:
void __fastcall func10(__int64 a1)
{
if ( a1 )
{
if ( (unsigned int)gzclose(a1) )
func1("Failed to close output file");
}
}

original_code:
void xgzclose(void *fp)
{
 if (fp && gzclose((gzFile)fp) != 0)
  fatal_error_with_errno("Failed to close output file");
}

canonical_original_code:
void xgzclose(void *fp)
{
 if (fp && gzclose((struct gzFile_s *)fp) != 0)
  fatal_error_with_errno("Failed to close output file");
}

variable_types:
fp
void *

user_defined_types: struct gzFile_s { unsigned int have; unsigned char *next; long pos; }


decompiled_code:
char __fastcall mkdir_p(const char *a1)
{
__int64 v1; // rax
size_t v3; // rcx
void *v4; // rsp
int *v5; // rax
_BYTE *v6; // rdx
char v7; // si
char v8; // di
_QWORD *v9; // rbx
char v10; // r13
_QWORD v12[4]; // [rsp-8h] [rbp-20h] BYREF

v12[0] = v1;
v3 = strlen(a1);
v4 = alloca(v3 + 1);
v5 = 0LL;
v6 = v12;
while ( v5 != (int *)v3 )
{
v7 = *((_BYTE *)v5 + (_QWORD)a1);
v5 = (int *)((char *)v5 + 1);
if ( v7 == 47 || v7 == 92 )
{
v8 = *((_BYTE *)v5 + (_QWORD)a1);
if ( v8 == 47 || v8 == 92 )
continue;
}
*v6++ = v7;
}
*v6 = 0;
v9 = v12;
while ( 1 )
{
v9 = (_QWORD *)((char *)v9 + 1);
if ( !*((_BYTE *)v9 - 1) )
break;
if ( v12 != v9 )
{
v10 = *(_BYTE *)v9;
LOBYTE(v5) = *(_BYTE *)v9 == 92;
if ( (unsigned __int8)v5 | (*(_BYTE *)v9 == 47) || !v10 )
{
*(_BYTE *)v9 = 0;
LODWORD(v5) = mkdir((const char *)v12, 0x1EDu);
if ( (_DWORD)v5 )
{
v5 = _errno_location();
if ( *v5 != 17 )
fatal_error_with_errno("Cannot create directory \"%s\"", (const char *)v12);
}
*(_BYTE *)v9 = v10;
}
}
}
return (char)v5;
}

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


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


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 *


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:
// attributes: thunk
__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(__int64 *a1)
{
unsigned __int64 v1; // rcx
unsigned __int64 v2; // rax
__int64 v3; // rdx
unsigned __int64 v5; // [rsp+8h] [rbp-10h]

v5 = __readfsqword(0x28u);
if ( !a1[3]
|| (v1 = a1[1], v2 = a1[2], v3 = *a1, v1 < v2) && *(_BYTE *)(v3 + v1)
|| *(_BYTE *)(v3 + v2 - 1)
|| *(_BYTE *)(v3 + v2) != 0xFE )
{
assert_jambuf_cold();
}
return v5 - __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

assert_jambuf(a1);
v4 = dest(a1);
a1[1] += a3;
if ( a3 < v5 )
{
*((_BYTE *)memcpy(v4, a2, a3) + a3) = 0;
}
else if ( v5 )
{
*((char *)memcpy(v4, a2, v5 - 1) + v5 - 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

func1(a1);
v4 = dest(a1);
a1[1] += a3;
if ( a3 < v5 )
{
*((_BYTE *)memcpy(v4, a2, a3) + a3) = 0;
}
else if ( v5 )
{
*((char *)memcpy(v4, a2, v5 - 1) + v5 - 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; }

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; // rbx
int v7; // eax
__int64 v8; // r12

assert_jambuf(a1);
v4 = dest(a1);
v6 = v5;
v7 = _vsnprintf_chk(v4, v5, 1LL, -1LL, a2, a3);
if ( v7 < 0 )
jam_va_list_cold();
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; // rbx
int v7; // eax
__int64 v8; // r12

func1(a1);
v4 = dest(a1);
v6 = v5;
v7 = _vsnprintf_chk(v4, v5, 1LL, -1LL, a2, a3);
if ( v7 < 0 )
func15();
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)
{
size_t v2; // rdx
const char *v3; // rbp

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

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

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

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)
{
__int64 v2; // r14
const char *v3; // rax
__int64 v4; // rdx
const char *v6; // r12
int v7; // ebx
int v8; // eax

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

canonical_decompiled_code:
__int64 __fastcall func8(__int64 *a1, unsigned int a2)
{
__int64 v2; // r14
const char *v3; // rax
__int64 v4; // rdx
const char *v6; // r12
int v7; // ebx
int v8; // eax

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

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(__int64 *a1)
{
assert_jambuf(a1);
return a1[1] < (unsigned __int64)a1[2];
}

canonical_decompiled_code:
bool __fastcall func9(__int64 *a1)
{
func1(a1);
return a1[1] < (unsigned __int64)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(__int64 *a1)
{
unsigned int v1; // eax

assert_jambuf(a1);
v1 = (unsigned int)dest(a1);
return shunk2(*a1, v1 - (unsigned int)*a1);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 *a1)
{
unsigned int v1; // eax

func1(a1);
v1 = (unsigned int)dest(a1);
return shunk2(*a1, v1 - (unsigned int)*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, __int64 *a2)
{
const void *v2; // rsi
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, __int64 *a2)
{
const void *v2; // rsi
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(__int64 *a1)
{
assert_jambuf(a1);
return a1[1];
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 *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)
{
size_t v1; // rax

if ( !a1 )
return 0LL;
v1 = strlen(a1);
return clone_bytes(a1, v1 + 1, "diag clone");
}

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

if ( !a1 )
return 0LL;
v1 = strlen(a1);
return clone_bytes(a1, v1 + 1, "diag clone");
}

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


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; // rsi

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

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

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


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)
{
__int64 v2; // rdx

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

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

v2 = (unsigned int)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)
{
__int64 v2; // rdx

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

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

v2 = (unsigned int)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; // r12
__int64 v7[5]; // [rsp+0h] [rbp-28h] BYREF

v7[1] = __readfsqword(0x28u);
v2 = getservbyname(a1, 0LL);
if ( v2 )
{
v5 = 0LL;
*a2 = ip_nport(v2->s_port);
}
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
{
v5 = "must be between 0 and 65535";
*a2 = unset_port;
}
}
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; // r12
__int64 v7[5]; // [rsp+0h] [rbp-28h] BYREF

v7[1] = __readfsqword(0x28u);
v2 = getservbyname(a1, 0LL);
if ( v2 )
{
v5 = 0LL;
*a2 = func2(v2->s_port);
}
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
{
v5 = "must be between 0 and 65535";
*a2 = unset_port;
}
}
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, __int128 a7)
{
__int64 result; // rax
__m128i v8; // [rsp+8h] [rbp-30h]

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

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

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

original_code:
const struct ip_info *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, *(_OWORD *)&_mm_loadu_si128(a1));
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, *(_OWORD *)&_mm_loadu_si128(a1));
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 v3; // rdx
__int64 v4; // rcx
__int64 v5; // r8
__int64 v6; // r9
__int64 v7; // rsi
const char *v9; // rsi

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

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 v3; // rdx
__int64 v4; // rcx
__int64 v5; // r8
__int64 v6; // r9
__int64 v7; // rsi
const char *v9; // rsi

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

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