parseatt

decompiled_code:
__int64 __fastcall parseatt(_QWORD *a1)
{
unsigned __int8 *v1; // rsi
unsigned __int8 *v2; // rdx
__int64 v3; // r13
__int64 v4; // r12
__int64 v5; // rbp
unsigned __int64 v7; // rax
unsigned __int8 *v8; // rcx
unsigned int i; // er9
unsigned __int64 v10; // rdi
unsigned __int8 *v11; // rax
unsigned __int8 *v13; // rcx
unsigned __int64 v14; // rax
unsigned __int8 *v15; // rdi
__int64 v16; // r8
void (__fastcall *v17)(_QWORD, unsigned __int8 *, _QWORD, unsigned __int8 *, __int64); // rax
unsigned __int8 *v18; // rdi

v1 = (unsigned __int8 *)a1[2];
v2 = (unsigned __int8 *)a1[1];
if ( v2 <= v1 )
return 0xFFFFFFFFLL;
v3 = 0x4000800100002600LL;
v4 = 0x2000000100002600LL;
v5 = 0x100002600LL;
while ( 1 )
{
v7 = *v1;
if ( (_BYTE)v7 == 47 || (_BYTE)v7 == 62 )
return 0LL;
if ( (unsigned __int8)v7 > 0x20u || !_bittest64(&v5, v7) )
break;
LABEL_23:
v1 = (unsigned __int8 *)(a1[2] + 1LL);
a1[2] = v1;
if ( v1 >= v2 )
return 0xFFFFFFFFLL;
}
v8 = (unsigned __int8 *)a1[2];
for ( i = 0; ; ++i )
{
while ( 1 )
{
v10 = *v8;
if ( (unsigned __int8)v10 <= 0x3Du )
break;
++v8;
++i;
a1[2] = v8;
if ( v2 <= v8 )
return 0xFFFFFFFFLL;
}
v11 = v8 + 1;
if ( _bittest64(&v4, v10) )
break;
++v8;
a1[2] = v11;
if ( v2 <= v11 )
return 0xFFFFFFFFLL;
}
while ( 1 )
{
a1[2] = v11;
v13 = v11;
if ( *(v11 - 1) == 61 )
break;
if ( v11 >= v2 )
return 0xFFFFFFFFLL;
++v11;
}
while ( 1 )
{
v14 = *v13;
if ( (unsigned __int8)v14 > 0x20u )
break;
if ( !_bittest64(&v5, v14) )
goto LABEL_18;
a1[2] = ++v13;
if ( v13 >= v2 )
return 0xFFFFFFFFLL;
}
if ( (_BYTE)v14 == 39 || (_BYTE)v14 == 34 )
{
a1[2] = ++v13;
if ( v13 >= v2 )
return 0xFFFFFFFFLL;
v18 = v13;
v16 = 0LL;
while ( (_BYTE)v14 != *v18 )
{
++v18;
v16 = (unsigned int)(v16 + 1);
a1[2] = v18;
if ( v18 == v2 )
return 0xFFFFFFFFLL;
}
goto LABEL_20;
}
LABEL_18:
v15 = v13 + 1;
v16 = 0LL;
if ( (unsigned __int8)v14 > 0x3Eu )
goto LABEL_28;
LABEL_19:
if ( _bittest64(&v3, v14) )
{
LABEL_20:
v17 = (void (__fastcall *)(_QWORD, unsigned __int8 *, _QWORD, unsigned __int8 *, __int64))a1[8];
if ( v17 )
{
v17(a1[4], v1, i, v13, v16);
v2 = (unsigned __int8 *)a1[1];
}
goto LABEL_23;
}
LABEL_28:
while ( 1 )
{
a1[2] = v15;
v16 = (unsigned int)(v16 + 1);
if ( v15 >= v2 )
return 0xFFFFFFFFLL;
v14 = *v15++;
if ( (unsigned __int8)v14 <= 0x3Eu )
goto LABEL_19;
}
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
unsigned __int8 *v1; // rsi
unsigned __int8 *v2; // rdx
__int64 v3; // r13
__int64 v4; // r12
__int64 v5; // rbp
unsigned __int64 v7; // rax
unsigned __int8 *v8; // rcx
unsigned int i; // er9
unsigned __int64 v10; // rdi
unsigned __int8 *v11; // rax
unsigned __int8 *v13; // rcx
unsigned __int64 v14; // rax
unsigned __int8 *v15; // rdi
__int64 v16; // r8
void (__fastcall *v17)(_QWORD, unsigned __int8 *, _QWORD, unsigned __int8 *, __int64); // rax
unsigned __int8 *v18; // rdi

v1 = (unsigned __int8 *)a1[2];
v2 = (unsigned __int8 *)a1[1];
if ( v2 <= v1 )
return 0xFFFFFFFFLL;
v3 = 0x4000800100002600LL;
v4 = 0x2000000100002600LL;
v5 = 0x100002600LL;
while ( 1 )
{
v7 = *v1;
if ( (_BYTE)v7 == 47 || (_BYTE)v7 == 62 )
return 0LL;
if ( (unsigned __int8)v7 > 0x20u || !_bittest64(&v5, v7) )
break;
LABEL_23:
v1 = (unsigned __int8 *)(a1[2] + 1LL);
a1[2] = v1;
if ( v1 >= v2 )
return 0xFFFFFFFFLL;
}
v8 = (unsigned __int8 *)a1[2];
for ( i = 0; ; ++i )
{
while ( 1 )
{
v10 = *v8;
if ( (unsigned __int8)v10 <= 0x3Du )
break;
++v8;
++i;
a1[2] = v8;
if ( v2 <= v8 )
return 0xFFFFFFFFLL;
}
v11 = v8 + 1;
if ( _bittest64(&v4, v10) )
break;
++v8;
a1[2] = v11;
if ( v2 <= v11 )
return 0xFFFFFFFFLL;
}
while ( 1 )
{
a1[2] = v11;
v13 = v11;
if ( *(v11 - 1) == 61 )
break;
if ( v11 >= v2 )
return 0xFFFFFFFFLL;
++v11;
}
while ( 1 )
{
v14 = *v13;
if ( (unsigned __int8)v14 > 0x20u )
break;
if ( !_bittest64(&v5, v14) )
goto LABEL_18;
a1[2] = ++v13;
if ( v13 >= v2 )
return 0xFFFFFFFFLL;
}
if ( (_BYTE)v14 == 39 || (_BYTE)v14 == 34 )
{
a1[2] = ++v13;
if ( v13 >= v2 )
return 0xFFFFFFFFLL;
v18 = v13;
v16 = 0LL;
while ( (_BYTE)v14 != *v18 )
{
++v18;
v16 = (unsigned int)(v16 + 1);
a1[2] = v18;
if ( v18 == v2 )
return 0xFFFFFFFFLL;
}
goto LABEL_20;
}
LABEL_18:
v15 = v13 + 1;
v16 = 0LL;
if ( (unsigned __int8)v14 > 0x3Eu )
goto LABEL_28;
LABEL_19:
if ( _bittest64(&v3, v14) )
{
LABEL_20:
v17 = (void (__fastcall *)(_QWORD, unsigned __int8 *, _QWORD, unsigned __int8 *, __int64))a1[8];
if ( v17 )
{
v17(a1[4], v1, i, v13, v16);
v2 = (unsigned __int8 *)a1[1];
}
goto LABEL_23;
}
LABEL_28:
while ( 1 )
{
a1[2] = v15;
v16 = (unsigned int)(v16 + 1);
if ( v15 >= v2 )
return 0xFFFFFFFFLL;
v14 = *v15++;
if ( (unsigned __int8)v14 <= 0x3Eu )
goto LABEL_19;
}
}

original_code:
int parseatt(struct xmlparser * p)
{
 const char * attname;
 int attnamelen;
 const char * attvalue;
 int attvaluelen;
 while(p->xml < p->xmlend)
 {
  if(*p->xml=='/' || *p->xml=='>')
   return 0;
  if( !((*p->xml==' ') || (*p->xml=='\t') || (*p->xml=='\r') || (*p->xml=='\n')) )
  {
   char sep;
   attname = p->xml;
   attnamelen = 0;
   while(*p->xml!='=' && !((*p->xml==' ') || (*p->xml=='\t') || (*p->xml=='\r') || (*p->xml=='\n')) )
   {
    attnamelen++; p->xml++;
    if(p->xml >= p->xmlend)
     return -1;
   }
   while(*(p->xml++) != '=')
   {
    if(p->xml >= p->xmlend)
     return -1;
   }
   while(((*p->xml==' ') || (*p->xml=='\t') || (*p->xml=='\r') || (*p->xml=='\n')))
   {
    p->xml++;
    if(p->xml >= p->xmlend)
     return -1;
   }
   sep = *p->xml;
   if(sep=='\'' || sep=='\"')
   {
    p->xml++;
    if(p->xml >= p->xmlend)
     return -1;
    attvalue = p->xml;
    attvaluelen = 0;
    while(*p->xml != sep)
    {
     attvaluelen++; p->xml++;
     if(p->xml >= p->xmlend)
      return -1;
    }
   }
   else
   {
    attvalue = p->xml;
    attvaluelen = 0;
    while( !((*p->xml==' ') || (*p->xml=='\t') || (*p->xml=='\r') || (*p->xml=='\n'))
       && *p->xml != '>' && *p->xml != '/')
    {
     attvaluelen++; p->xml++;
     if(p->xml >= p->xmlend)
      return -1;
    }
   }
   if(p->attfunc)
    p->attfunc(p->data, attname, attnamelen, attvalue, attvaluelen);
  }
  p->xml++;
 }
 return -1;
}

canonical_original_code:
int parseatt(struct xmlparser *p)
{
 char *attname;
 int attnamelen;
 char *attvalue;
 int attvaluelen;
 while(p->xml < p->xmlend)
 {
  if(*p->xml=='/' || *p->xml=='>')
   return 0;
  if( !((*p->xml==' ') || (*p->xml=='\t') || (*p->xml=='\r') || (*p->xml=='\n')) )
  {
   char sep;
   attname = p->xml;
   attnamelen = 0;
   while(*p->xml!='=' && !((*p->xml==' ') || (*p->xml=='\t') || (*p->xml=='\r') || (*p->xml=='\n')) )
   {
    attnamelen++; p->xml++;
    if(p->xml >= p->xmlend)
     return -1;
   }
   while(*(p->xml++) != '=')
   {
    if(p->xml >= p->xmlend)
     return -1;
   }
   while(((*p->xml==' ') || (*p->xml=='\t') || (*p->xml=='\r') || (*p->xml=='\n')))
   {
    p->xml++;
    if(p->xml >= p->xmlend)
     return -1;
   }
   sep = *p->xml;
   if(sep=='\'' || sep=='\"')
   {
    p->xml++;
    if(p->xml >= p->xmlend)
     return -1;
    attvalue = p->xml;
    attvaluelen = 0;
    while(*p->xml != sep)
    {
     attvaluelen++; p->xml++;
     if(p->xml >= p->xmlend)
      return -1;
    }
   }
   else
   {
    attvalue = p->xml;
    attvaluelen = 0;
    while( !((*p->xml==' ') || (*p->xml=='\t') || (*p->xml=='\r') || (*p->xml=='\n'))
       && *p->xml != '>' && *p->xml != '/')
    {
     attvaluelen++; p->xml++;
     if(p->xml >= p->xmlend)
      return -1;
    }
   }
   if(p->attfunc)
    p->attfunc(p->data, attname, attnamelen, attvalue, attvaluelen);
  }
  p->xml++;
 }
 return -1;
}

variable_types: struct xmlparser { char *xmlstart; char *xmlend; char *xml; int xmlsize; void *data; void (*starteltfunc)(void *, char *, int); void (*endeltfunc)(void *, char *, int); void (*datafunc)(void *, char *, int); void (*attfunc)(void *, char *, int, char *, int); } *

variable_types:
attname
char *

variable_types: attnamelen int

variable_types:
attvalue
char *

variable_types: attvaluelen int

variable_types: sep char


parseelt

repo: zyclonite/dlnaproxy

decompiled_code:
unsigned __int8 *__fastcall parseelt(_QWORD *a1)
{
unsigned __int8 *result; // rax
unsigned __int64 v3; // rdi
__int64 v4; // rbp
__int64 v5; // r12
unsigned __int8 *v6; // rsi
unsigned __int64 v7; // rdx
unsigned int v8; // er8
void (__fastcall *v9)(_QWORD, unsigned __int8 *, _QWORD); // rax
unsigned int v10; // er8
unsigned __int8 *v11; // rsi
unsigned __int64 v12; // rdx
void (__fastcall *v13)(_QWORD, unsigned __int8 *, _QWORD); // rcx
unsigned __int8 *v14; // rsi
__int64 v15; // rdx
void (__fastcall *v16)(_QWORD, unsigned __int8 *, __int64); // rcx

result = (unsigned __int8 *)a1[2];
v3 = a1[1];
if ( (unsigned __int64)result < v3 - 1 )
{
v4 = 0x4000000000002400LL;
v5 = 0x100002600LL;
while ( 1 )
{
v6 = result + 1;
if ( *result == 60 && result[1] != 63 )
break;
a1[2] = v6;
++result;
LABEL_4:
if ( (unsigned __int64)result >= v3 - 1 )
return result;
}
LABEL_7:
a1[2] = v6;
result = v6;
v7 = *v6;
v8 = 0;
while ( 1 )
{
if ( (_BYTE)v7 == 32 || (_BYTE)v7 == 9 )
{
if ( !v8 )
goto LABEL_4;
goto LABEL_17;
}
if ( (unsigned __int8)v7 <= 0x3Eu )
{
if ( _bittest64(&v4, v7) )
{
if ( !v8 )
goto LABEL_4;
goto LABEL_17;
}
if ( (_BYTE)v7 == 47 )
break;
}
++v8;
a1[2] = result + 1;
if ( v3 <= (unsigned __int64)(result + 1) )
return result;
v7 = result[1];
if ( (_BYTE)v7 == 58 )
{
v6 = result + 2;
goto LABEL_7;
}
++result;
}
if ( !v8 )
{
v14 = result + 1;
a1[2] = result + 1;
if ( v3 <= (unsigned __int64)(result + 1) )
return result;
++result;
v15 = 0LL;
while ( *result != 62 )
{
++result;
v15 = (unsigned int)(v15 + 1);
a1[2] = result;
if ( (unsigned __int8 *)v3 == result )
return result;
}
v16 = (void (__fastcall *)(_QWORD, unsigned __int8 *, __int64))a1[6];
if ( v16 )
{
v16(a1[4], v14, v15);
result = (unsigned __int8 *)a1[2];
v3 = a1[1];
}
a1[2] = ++result;
goto LABEL_4;
}
LABEL_17:
v9 = (void (__fastcall *)(_QWORD, unsigned __int8 *, _QWORD))a1[5];
if ( v9 )
v9(a1[4], v6, v8);
result = (unsigned __int8 *)parseatt(a1);
v10 = (unsigned int)result;
if ( !(_DWORD)result )
{
result = (unsigned __int8 *)a1[2];
v3 = a1[1];
if ( *result == 47 )
goto LABEL_4;
v11 = result + 1;
a1[2] = result + 1;
if ( (unsigned __int64)(result + 1) < v3 )
{
++result;
while ( 1 )
{
v12 = *result;
if ( (unsigned __int8)v12 > 0x20u || !_bittest64(&v5, v12) )
break;
a1[2] = ++result;
if ( result == (unsigned __int8 *)v3 )
return result;
}
while ( (_BYTE)v12 != 60 )
{
++result;
++v10;
a1[2] = result;
if ( (unsigned __int64)result >= v3 )
return result;
LOBYTE(v12) = *result;
}
if ( v10 )
{
v13 = (void (__fastcall *)(_QWORD, unsigned __int8 *, _QWORD))a1[7];
if ( v13 )
{
v13(a1[4], v11, v10);
result = (unsigned __int8 *)a1[2];
v3 = a1[1];
}
}
goto LABEL_4;
}
}
}
return result;
}

canonical_decompiled_code:
unsigned __int8 *__fastcall func1(_QWORD *a1)
{
unsigned __int8 *result; // rax
unsigned __int64 v3; // rdi
__int64 v4; // rbp
__int64 v5; // r12
unsigned __int8 *v6; // rsi
unsigned __int64 v7; // rdx
unsigned int v8; // er8
void (__fastcall *v9)(_QWORD, unsigned __int8 *, _QWORD); // rax
unsigned int v10; // er8
unsigned __int8 *v11; // rsi
unsigned __int64 v12; // rdx
void (__fastcall *v13)(_QWORD, unsigned __int8 *, _QWORD); // rcx
unsigned __int8 *v14; // rsi
__int64 v15; // rdx
void (__fastcall *v16)(_QWORD, unsigned __int8 *, __int64); // rcx

result = (unsigned __int8 *)a1[2];
v3 = a1[1];
if ( (unsigned __int64)result < v3 - 1 )
{
v4 = 0x4000000000002400LL;
v5 = 0x100002600LL;
while ( 1 )
{
v6 = result + 1;
if ( *result == 60 && result[1] != 63 )
break;
a1[2] = v6;
++result;
LABEL_4:
if ( (unsigned __int64)result >= v3 - 1 )
return result;
}
LABEL_7:
a1[2] = v6;
result = v6;
v7 = *v6;
v8 = 0;
while ( 1 )
{
if ( (_BYTE)v7 == 32 || (_BYTE)v7 == 9 )
{
if ( !v8 )
goto LABEL_4;
goto LABEL_17;
}
if ( (unsigned __int8)v7 <= 0x3Eu )
{
if ( _bittest64(&v4, v7) )
{
if ( !v8 )
goto LABEL_4;
goto LABEL_17;
}
if ( (_BYTE)v7 == 47 )
break;
}
++v8;
a1[2] = result + 1;
if ( v3 <= (unsigned __int64)(result + 1) )
return result;
v7 = result[1];
if ( (_BYTE)v7 == 58 )
{
v6 = result + 2;
goto LABEL_7;
}
++result;
}
if ( !v8 )
{
v14 = result + 1;
a1[2] = result + 1;
if ( v3 <= (unsigned __int64)(result + 1) )
return result;
++result;
v15 = 0LL;
while ( *result != 62 )
{
++result;
v15 = (unsigned int)(v15 + 1);
a1[2] = result;
if ( (unsigned __int8 *)v3 == result )
return result;
}
v16 = (void (__fastcall *)(_QWORD, unsigned __int8 *, __int64))a1[6];
if ( v16 )
{
v16(a1[4], v14, v15);
result = (unsigned __int8 *)a1[2];
v3 = a1[1];
}
a1[2] = ++result;
goto LABEL_4;
}
LABEL_17:
v9 = (void (__fastcall *)(_QWORD, unsigned __int8 *, _QWORD))a1[5];
if ( v9 )
v9(a1[4], v6, v8);
result = (unsigned __int8 *)func0(a1);
v10 = (unsigned int)result;
if ( !(_DWORD)result )
{
result = (unsigned __int8 *)a1[2];
v3 = a1[1];
if ( *result == 47 )
goto LABEL_4;
v11 = result + 1;
a1[2] = result + 1;
if ( (unsigned __int64)(result + 1) < v3 )
{
++result;
while ( 1 )
{
v12 = *result;
if ( (unsigned __int8)v12 > 0x20u || !_bittest64(&v5, v12) )
break;
a1[2] = ++result;
if ( result == (unsigned __int8 *)v3 )
return result;
}
while ( (_BYTE)v12 != 60 )
{
++result;
++v10;
a1[2] = result;
if ( (unsigned __int64)result >= v3 )
return result;
LOBYTE(v12) = *result;
}
if ( v10 )
{
v13 = (void (__fastcall *)(_QWORD, unsigned __int8 *, _QWORD))a1[7];
if ( v13 )
{
v13(a1[4], v11, v10);
result = (unsigned __int8 *)a1[2];
v3 = a1[1];
}
}
goto LABEL_4;
}
}
}
return result;
}

original_code:
void parseelt(struct xmlparser * p)
{
 int i;
 const char * elementname;
 while(p->xml < (p->xmlend - 1))
 {
  if((p->xml)[0]=='<' && (p->xml)[1]!='?')
  {
   i = 0; elementname = ++p->xml;
   while( !((*p->xml==' ') || (*p->xml=='\t') || (*p->xml=='\r') || (*p->xml=='\n'))
      && (*p->xml!='>') && (*p->xml!='/')
     )
   {
    i++; p->xml++;
    if (p->xml >= p->xmlend)
     return;
    if(*p->xml==':')
    {
     i = 0;
     elementname = ++p->xml;
    }
   }
   if(i>0)
   {
    if(p->starteltfunc)
     p->starteltfunc(p->data, elementname, i);
    if(parseatt(p))
     return;
    if(*p->xml!='/')
    {
     const char * data;
     i = 0; data = ++p->xml;
     if (p->xml >= p->xmlend)
      return;
     while( ((*p->xml==' ') || (*p->xml=='\t') || (*p->xml=='\r') || (*p->xml=='\n')) )
     {
      p->xml++;
      if (p->xml >= p->xmlend)
       return;
     }
     while(*p->xml!='<')
     {
      i++; p->xml++;
      if (p->xml >= p->xmlend)
       return;
     }
     if(i>0 && p->datafunc)
      p->datafunc(p->data, data, i);
    }
   }
   else if(*p->xml == '/')
   {
    i = 0; elementname = ++p->xml;
    if (p->xml >= p->xmlend)
     return;
    while((*p->xml != '>'))
    {
     i++; p->xml++;
     if (p->xml >= p->xmlend)
      return;
    }
    if(p->endeltfunc)
     p->endeltfunc(p->data, elementname, i);
    p->xml++;
   }
  }
  else
  {
   p->xml++;
  }
 }
}

canonical_original_code:
void parseelt(struct xmlparser *p)
{
 int i;
 char *elementname;
 while(p->xml < (p->xmlend - 1))
 {
  if((p->xml)[0]=='<' && (p->xml)[1]!='?')
  {
   i = 0; elementname = ++p->xml;
   while( !((*p->xml==' ') || (*p->xml=='\t') || (*p->xml=='\r') || (*p->xml=='\n'))
      && (*p->xml!='>') && (*p->xml!='/')
     )
   {
    i++; p->xml++;
    if (p->xml >= p->xmlend)
     return;
    if(*p->xml==':')
    {
     i = 0;
     elementname = ++p->xml;
    }
   }
   if(i>0)
   {
    if(p->starteltfunc)
     p->starteltfunc(p->data, elementname, i);
    if(parseatt(p))
     return;
    if(*p->xml!='/')
    {
     char *data;
     i = 0; data = ++p->xml;
     if (p->xml >= p->xmlend)
      return;
     while( ((*p->xml==' ') || (*p->xml=='\t') || (*p->xml=='\r') || (*p->xml=='\n')) )
     {
      p->xml++;
      if (p->xml >= p->xmlend)
       return;
     }
     while(*p->xml!='<')
     {
      i++; p->xml++;
      if (p->xml >= p->xmlend)
       return;
     }
     if(i>0 && p->datafunc)
      p->datafunc(p->data, data, i);
    }
   }
   else if(*p->xml == '/')
   {
    i = 0; elementname = ++p->xml;
    if (p->xml >= p->xmlend)
     return;
    while((*p->xml != '>'))
    {
     i++; p->xml++;
     if (p->xml >= p->xmlend)
      return;
    }
    if(p->endeltfunc)
     p->endeltfunc(p->data, elementname, i);
    p->xml++;
   }
  }
  else
  {
   p->xml++;
  }
 }
}

variable_types: i int

variable_types:
elementname
char *

variable_types:
data
char *

return_type: void

user_defined_types: struct xmlparser { char *xmlstart; char *xmlend; char *xml; int xmlsize; void *data; void (*starteltfunc)(void *, char *, int); void (*endeltfunc)(void *, char *, int); void (*datafunc)(void *, char *, int); void (*attfunc)(void *, char *, int, char *, int); }


parsexml

decompiled_code:
unsigned __int8 *__fastcall parsexml(_QWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rdx

v1 = *a1;
v2 = *((int *)a1 + 6);
a1[2] = *a1;
a1[1] = v2 + v1;
return parseelt(a1);
}

original_code:
void parsexml(struct xmlparser * parser)
{
 parser->xml = parser->xmlstart;
 parser->xmlend = parser->xmlstart + parser->xmlsize;
 parseelt(parser);
}

canonical_original_code:
void parsexml(struct xmlparser *parser)
{
 parser->xml = parser->xmlstart;
 parser->xmlend = parser->xmlstart + parser->xmlsize;
 parseelt(parser);
}


freeoptions

decompiled_code:
void freeoptions()
{
if ( ary_options )
{
free(ary_options);
ary_options = 0LL;
num_options = 0;
}
}

canonical_decompiled_code:
void func1()
{
if ( ary_options )
{
free(ary_options);
ary_options = 0LL;
num_options = 0;
}
}

original_code:
void
freeoptions(void)
{
 if(ary_options)
 {
  free(ary_options);
  ary_options = ((void *)0);
  num_options = 0;
 }
}

canonical_original_code:
void freeoptions()
{
 if(ary_options)
 {
  free(ary_options);
  ary_options = ((void *)0);
  num_options = 0;
 }
}


writepidfile

decompiled_code:
__int64 __fastcall writepidfile(const char *a1, unsigned int a2)
{
int v2; // ebp
int v3; // eax
__int64 result; // rax
int *v5; // rax
char *v6; // rax
int *v7; // rax
char *v8; // rax
char v9[40]; // [rsp-28h] [rbp-28h] BYREF

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !*a1 )
return 0xFFFFFFFFLL;
v2 = open64(a1, 65, 420LL);
if ( v2 < 0 )
{
v7 = _errno_location();
v8 = strerror(*v7);
log_err(2LL, 0LL, "daemonize.c", 98LL, "Unable to open pidfile for writing %s: %s\n", a1, v8);
result = 0xFFFFFFFFLL;
}
else
{
v3 = snprintf(v9, 0x10uLL, "%d\n", a2);
if ( write(v2, v9, v3) < 0 )
{
v5 = _errno_location();
v6 = strerror(*v5);
log_err(2LL, 0LL, "daemonize.c", 113LL, "Unable to write to pidfile %s: %s\n", a1, v6);
}
close(v2);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, unsigned int a2)
{
int v2; // ebp
int v3; // eax
__int64 result; // rax
int *v5; // rax
char *v6; // rax
int *v7; // rax
char *v8; // rax
char v9[40]; // [rsp-28h] [rbp-28h] BYREF

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !*a1 )
return 0xFFFFFFFFLL;
v2 = open64(a1, 65, 420LL);
if ( v2 < 0 )
{
v7 = _errno_location();
v8 = strerror(*v7);
log_err(2LL, 0LL, "daemonize.c", 98LL, "Unable to open pidfile for writing %s: %s\n", a1, v8);
result = 0xFFFFFFFFLL;
}
else
{
v3 = snprintf(v9, 0x10uLL, "%d\n", a2);
if ( write(v2, v9, v3) < 0 )
{
v5 = _errno_location();
v6 = strerror(*v5);
log_err(2LL, 0LL, "daemonize.c", 113LL, "Unable to write to pidfile %s: %s\n", a1, v6);
}
close(v2);
result = 0LL;
}
return result;
}

original_code:
int
writepidfile(const char * fname, int pid)
{
 char pidstring[16];
 int pidstringlen;
 int pidfile;
 if(!fname || (strlen(fname) == 0))
  return -1;
 if( (pidfile = open(fname, 01|0100, 0644)) < 0)
 {
  { log_err(2, L_GENERAL, "daemonize.c", 98, "Unable to open pidfile for writing %s: %s\n", fname, strerror((*__errno_location ()))); };
  return -1;
 }
 pidstringlen = snprintf(pidstring, sizeof(pidstring), "%d\n", pid);
 if(pidstringlen <= 0)
 {
  { log_err(2, L_GENERAL, "daemonize.c", 105, "Unable to write to pidfile %s: snprintf(): FAILED\n", fname); };
  close(pidfile);
  return -1;
 }
 else
 {
  if(write(pidfile, pidstring, pidstringlen) < 0)
   { log_err(2, L_GENERAL, "daemonize.c", 113, "Unable to write to pidfile %s: %s\n", fname, strerror((*__errno_location ()))); };
 }
 close(pidfile);
 return 0;
}

canonical_original_code:
int writepidfile(char *fname, int pid)
{
 char pidstring[16];
 int pidstringlen;
 int pidfile;
 if(!fname || (strlen(fname) == 0))
  return -1;
 if( (pidfile = open(fname, 01|0100, 0644)) < 0)
 {
  { log_err(2, L_GENERAL, "daemonize.c", 98, "Unable to open pidfile for writing %s: %s\n", fname, strerror((*__errno_location ()))); };
  return -1;
 }
 pidstringlen = snprintf(pidstring, sizeof(pidstring), "%d\n", pid);
 if(pidstringlen <= 0)
 {
  { log_err(2, L_GENERAL, "daemonize.c", 105, "Unable to write to pidfile %s: snprintf(): FAILED\n", fname); };
  close(pidfile);
  return -1;
 }
 else
 {
  if(write(pidfile, pidstring, pidstringlen) < 0)
   { log_err(2, L_GENERAL, "daemonize.c", 113, "Unable to write to pidfile %s: %s\n", fname, strerror((*__errno_location ()))); };
 }
 close(pidfile);
 return 0;
}

variable_types:
fname
char *

variable_types: pid int

variable_types:
pidstring
char [16]

variable_types: pidstringlen int

variable_types: pidfile int

return_type: int


checkforrunning

decompiled_code:
__int64 __fastcall checkforrunning(const char *a1)
{
int v1; // ebp
__int64 result; // rax
__pid_t v3; // eax
__int128 v4[4]; // [rsp+0h] [rbp-48h] BYREF

if ( !a1 || !*a1 )
return 0xFFFFFFFFLL;
v1 = open64(a1, 0);
result = 0LL;
if ( v1 >= 0 )
{
v4[0] = 0LL;
v4[1] = 0LL;
v4[2] = 0LL;
v4[3] = 0LL;
if ( !read(v1, v4, 0x3FuLL) || (v3 = atol((const char *)v4), v3 <= 0) || kill(v3, 0) )
{
close(v1);
result = 0LL;
}
else
{
close(v1);
result = 4294967294LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
int v1; // ebp
__int64 result; // rax
__pid_t v3; // eax
__int128 v4[4]; // [rsp+0h] [rbp-48h] BYREF

if ( !a1 || !*a1 )
return 0xFFFFFFFFLL;
v1 = open64(a1, 0);
result = 0LL;
if ( v1 >= 0 )
{
v4[0] = 0LL;
v4[1] = 0LL;
v4[2] = 0LL;
v4[3] = 0LL;
if ( !read(v1, v4, 0x3FuLL) || (v3 = atol((const char *)v4), v3 <= 0) || kill(v3, 0) )
{
close(v1);
result = 0LL;
}
else
{
close(v1);
result = 4294967294LL;
}
}
return result;
}

original_code:
int
checkforrunning(const char * fname)
{
 char buffer[64];
 int pidfile;
 pid_t pid;
 if(!fname || (strlen(fname) == 0))
  return -1;
 if( (pidfile = open(fname, 00)) < 0)
  return 0;
 memset(buffer, 0, 64);
 if(read(pidfile, buffer, 63))
 {
  if( (pid = atol(buffer)) > 0)
  {
   if(!kill(pid, 0))
   {
    close(pidfile);
    return -2;
   }
  }
 }
 close(pidfile);
 return 0;
}

canonical_original_code:
int checkforrunning(char *fname)
{
 char buffer[64];
 int pidfile;
 int pid;
 if(!fname || (strlen(fname) == 0))
  return -1;
 if( (pidfile = open(fname, 00)) < 0)
  return 0;
 memset(buffer, 0, 64);
 if(read(pidfile, buffer, 63))
 {
  if( (pid = atol(buffer)) > 0)
  {
   if(!kill(pid, 0))
   {
    close(pidfile);
    return -2;
   }
  }
 }
 close(pidfile);
 return 0;
}

variable_types:
buffer
char [64]


SearchClientCache

decompiled_code:
__int64 __fastcall SearchClientCache(unsigned int a1, int a2)
{
__int64 v2; // rax
__int64 v3; // r12
__int64 v4; // r14
char *v5; // r15
int v7; // [rsp+Ah] [rbp-3Eh] BYREF
__int16 v8; // [rsp+Eh] [rbp-3Ah]

v2 = 0LL;
while ( 1 )
{
v3 = (unsigned int)v2;
if ( *((_DWORD *)&clients + 8 * v2) == a1 )
break;
if ( ++v2 == 20 )
{
LODWORD(v3) = -1;
return (unsigned int)v3;
}
}
v4 = (int)v2;
v5 = (char *)&clients + 32 * (int)v2;
if ( time(0LL) - *((_QWORD *)&clients + 4 * (int)v2 + 3) > 3600 )
{
if ( (unsigned int)get_remote_mac(a1, &v7)
|| v7 != *((_DWORD *)&clients + 8 * v4 + 1)
|| v8 != *((_WORD *)&clients + 16 * v4 + 4) )
{
LODWORD(v3) = -1;
*((_OWORD *)&clients + 2 * v4) = 0LL;
*((_OWORD *)v5 + 1) = 0LL;
return (unsigned int)v3;
}
*((_QWORD *)v5 + 3) = time(0LL);
}
if ( !a2 )
log_err(
5LL,
2LL,
"utils.c",
61LL,
"Client found in cache. [type %d/entry %d]\n",
*((unsigned int *)&clients + 8 * (int)v3 + 3),
v3);
return (unsigned int)v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, int a2)
{
__int64 v2; // rax
__int64 v3; // r12
__int64 v4; // r14
char *v5; // r15
int v7; // [rsp+Ah] [rbp-3Eh] BYREF
__int16 v8; // [rsp+Eh] [rbp-3Ah]

v2 = 0LL;
while ( 1 )
{
v3 = (unsigned int)v2;
if ( *((_DWORD *)&clients + 8 * v2) == a1 )
break;
if ( ++v2 == 20 )
{
LODWORD(v3) = -1;
return (unsigned int)v3;
}
}
v4 = (int)v2;
v5 = (char *)&clients + 32 * (int)v2;
if ( time(0LL) - *((_QWORD *)&clients + 4 * (int)v2 + 3) > 3600 )
{
if ( (unsigned int)get_remote_mac(a1, &v7)
|| v7 != *((_DWORD *)&clients + 8 * v4 + 1)
|| v8 != *((_WORD *)&clients + 16 * v4 + 4) )
{
LODWORD(v3) = -1;
*((_OWORD *)&clients + 2 * v4) = 0LL;
*((_OWORD *)v5 + 1) = 0LL;
return (unsigned int)v3;
}
*((_QWORD *)v5 + 3) = time(0LL);
}
if ( !a2 )
log_err(
5LL,
2LL,
"utils.c",
61LL,
"Client found in cache. [type %d/entry %d]\n",
*((unsigned int *)&clients + 8 * (int)v3 + 3),
v3);
return (unsigned int)v3;
}

original_code:
int
SearchClientCache(struct in_addr addr, int quiet)
{
 int i;
 for( i=0; i<20; i++ )
 {
  if( clients[i].addr.s_addr == addr.s_addr )
  {
   if( (time(((void *)0)) - clients[i].age) > 3600 )
   {
    unsigned char mac[6];
    if( get_remote_mac(addr, mac) == 0 &&
        memcmp(mac, clients[i].mac, 6) == 0 )
    {
     clients[i].age = time(((void *)0));
    }
    else
    {
     memset(&clients[i], 0, sizeof(struct client_cache_s));
     return -1;
    }
   }
   if( !quiet )
    { log_err(5, L_HTTP, "utils.c", 61, "Client found in cache. [type %d/entry %d]\n", clients[i].type, i); };
   return i;
  }
 }
 return -1;
}

variable_types:
addr
struct in_addr { unsigned int s_addr; }

variable_types: quiet int

variable_types:
mac
unsigned char [6]

user_defined_types: struct client_cache_s { struct in_addr addr; unsigned char mac[6]; enum client_types type; unsigned int flags; long age; }

user_defined_types: enum client_types { EXbox=1, EPS3=2, ESamsungTV=3, EDenonReceiver=4, EFreeBox=5, EPopcornHour=6, EMediaRoom=7, ESonyBDP=8, ESonyBravia=9, ERokuSoundBridge=10, EToshibaTV=11, ELGDevice=12, ENetgearEVA2000=13, ESamsungSeriesA=14, ESamsungSeriesB=15, EMarantzDMP=16, EStandardDLNA150=100 }


strstrc

decompiled_code:
char *__fastcall strstrc(const char *a1, const char *a2, char a3)
{
const char *v3; // rbx
char *v4; // rax
char *v5; // r12
size_t v6; // r12
size_t v7; // rax
size_t v8; // r14
char v9; // r13
const char *v10; // r15
char v11; // al
size_t n; // [rsp+8h] [rbp-40h]

v3 = a1;
v4 = strchr(a1, a3);
v5 = v4;
if ( v4 )
{
v6 = v4 - a1;
v7 = strlen(a2);
v8 = v7;
if ( v7 > v6 )
{
LABEL_8:
v5 = 0LL;
}
else
{
v9 = *a2;
v10 = &a1[v6];
n = v7 - 1;
while ( 1 )
{
v11 = *v3;
v5 = (char *)v3++;
if ( v11 == v9 && !strncmp(v3, a2 + 1, n) )
break;
if ( v10 - v3 < v8 )
goto LABEL_8;
}
}
}
return v5;
}

canonical_decompiled_code:
char *__fastcall func1(const char *a1, const char *a2, char a3)
{
const char *v3; // rbx
char *v4; // rax
char *v5; // r12
size_t v6; // r12
size_t v7; // rax
size_t v8; // r14
char v9; // r13
const char *v10; // r15
char v11; // al
size_t n; // [rsp+8h] [rbp-40h]

v3 = a1;
v4 = strchr(a1, a3);
v5 = v4;
if ( v4 )
{
v6 = v4 - a1;
v7 = strlen(a2);
v8 = v7;
if ( v7 > v6 )
{
LABEL_8:
v5 = 0LL;
}
else
{
v9 = *a2;
v10 = &a1[v6];
n = v7 - 1;
while ( 1 )
{
v11 = *v3;
v5 = (char *)v3++;
if ( v11 == v9 && !strncmp(v3, a2 + 1, n) )
break;
if ( v10 - v3 < v8 )
goto LABEL_8;
}
}
}
return v5;
}

original_code:
char *
strstrc(const char *s, const char *p, const char t)
{
 char *endptr;
 size_t slen, plen;
 endptr = strchr(s, t);
 if (!endptr)
  return ((void *)0);
 plen = strlen(p);
 slen = endptr - s;
 while (slen >= plen)
 {
  if (*s == *p && strncmp(s+1, p+1, plen-1) == 0)
   return (char*)s;
  s++;
  slen--;
 }
 return ((void *)0);
}

canonical_original_code:
char *strstrc(char *s, char *p, char t)
{
 char *endptr;
 unsigned long slen; unsigned long plen;
 endptr = strchr(s, t);
 if (!endptr)
  return ((void *)0);
 plen = strlen(p);
 slen = endptr - s;
 while (slen >= plen)
 {
  if (*s == *p && strncmp(s+1, p+1, plen-1) == 0)
   return (char *)s;
  s++;
  slen--;
 }
 return ((void *)0);
}

variable_types:
s
char *

variable_types:
p
char *

variable_types: t char

variable_types:
endptr
char *

variable_types:
slen
unsigned long

variable_types:
plen
unsigned long

return_type: char *


decompiled_code:
__int64 __fastcall make_dir(char *file, __mode_t mode)
{
char *v2; // rbp
char v3; // bl
char v4; // al
char *v5; // r12
struct stat64 v7; // [rsp+0h] [rbp-B8h] BYREF

v2 = file;
v3 = *file;
while ( v3 )
{
v4 = v3;
v5 = v2;
v3 = *++v2;
if ( v4 == 47 )
{
do
v3 = *++v5;
while ( v3 == 47 );
*v5 = 0;
if ( mkdir(file, mode) < 0 )
{
v2 = v5;
goto LABEL_6;
}
LABEL_10:
if ( !v3 )
return 0LL;
*v5 = v3;
v2 = v5;
}
}
if ( mkdir(file, mode) >= 0 )
return 0LL;
v3 = 0;
LABEL_6:
if ( *_errno_location() == 17 && stat64(file, &v7) >= 0 && (v7.st_mode & 0xF000) == 0x4000 )
{
v5 = v2;
goto LABEL_10;
}
log_err(3LL, 0LL, "utils.c", 135LL, "make_dir: cannot create directory '%s'\n", file);
if ( v3 )
*v2 = v3;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *file, __mode_t mode)
{
char *v2; // rbp
char v3; // bl
char v4; // al
char *v5; // r12
struct stat64 v7; // [rsp+0h] [rbp-B8h] BYREF

v2 = file;
v3 = *file;
while ( v3 )
{
v4 = v3;
v5 = v2;
v3 = *++v2;
if ( v4 == 47 )
{
do
v3 = *++v5;
while ( v3 == 47 );
*v5 = 0;
if ( mkdir(file, mode) < 0 )
{
v2 = v5;
goto LABEL_6;
}
LABEL_10:
if ( !v3 )
return 0LL;
*v5 = v3;
v2 = v5;
}
}
if ( mkdir(file, mode) >= 0 )
return 0LL;
v3 = 0;
LABEL_6:
if ( *_errno_location() == 17 && stat64(file, &v7) >= 0 && (v7.st_mode & 0xF000) == 0x4000 )
{
v5 = v2;
goto LABEL_10;
}
log_err(3LL, 0LL, "utils.c", 135LL, "make_dir: cannot create directory '%s'\n", file);
if ( v3 )
*v2 = v3;
return 0xFFFFFFFFLL;
}

original_code:
int
make_dir(char * path, mode_t mode)
{
 char * s = path;
 char c;
 struct stat st;
 do {
  c = '\0';
  while (*s) {
   if (*s == '/') {
    do {
     ++s;
    } while (*s == '/');
    c = *s;
    *s = '\0';
    break;
   }
   ++s;
  }
  if (mkdir(path, mode) < 0) {
   if ((*__errno_location ()) != 17 || (stat(path, &st) < 0 || !((((st.st_mode)) & 0170000) == (0040000)))) {
    { log_err(3, L_GENERAL, "utils.c", 135, "make_dir: cannot create directory '%s'\n", path); };
    if (c)
     *s = c;
    return -1;
   }
  }
         if (!c)
   return 0;
  *s = c;
 } while (1);
}

canonical_original_code:
int make_dir(char *path, unsigned int mode)
{
 char *s = path;
 char c;
 struct stat st;
 do {
  c = '\0';
  while (*s) {
   if (*s == '/') {
    do {
     ++s;
    } while (*s == '/');
    c = *s;
    *s = '\0';
    break;
   }
   ++s;
  }
  if (mkdir(path, mode) < 0) {
   if ((*__errno_location ()) != 17 || (stat(path, &st) < 0 || !((((st.st_mode)) & 0170000) == (0040000)))) {
    { log_err(3, L_GENERAL, "utils.c", 135, "make_dir: cannot create directory '%s'\n", path); };
    if (c)
     *s = c;
    return -1;
   }
  }
         if (!c)
   return 0;
  *s = c;
 } while (1);
}

variable_types:
path
char *

variable_types:
mode
unsigned int

variable_types: c char

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


decompiled_code:
void log_err(int a1, unsigned int a2, const char *a3, unsigned int a4, const char *a5, ...)
{
int v7; // eax
struct tm *v8; // rax
char *ptr; // [rsp+8h] [rbp-F0h] BYREF
time_t timer; // [rsp+10h] [rbp-E8h] BYREF
gcc_va_list arg; // [rsp+18h] [rbp-E0h] BYREF

if ( !a1 )
goto LABEL_5;
v7 = 1;
if ( *((int *)&log_level + a2) > 0 )
v7 = *((_DWORD *)&log_level + a2);
if ( a1 <= v7 )
{
LABEL_5:
if ( !log_fp )
log_fp = stdout;
va_start(arg, a5);
if ( vasprintf(&ptr, a5, arg) != -1 )
{
timer = time(0LL);
v8 = localtime(&timer);
fprintf(
log_fp,
"[%04d/%02d/%02d %02d:%02d:%02d] ",
(unsigned int)(v8->tm_year + 1900),
(unsigned int)(v8->tm_mon + 1),
(unsigned int)v8->tm_mday,
(unsigned int)v8->tm_hour,
(unsigned int)v8->tm_min,
(unsigned int)v8->tm_sec);
if ( a1 )
{
fprintf(log_fp, "%s:%d: %s: %s", a3, a4, level_name[a1], ptr);
fflush(log_fp);
free(ptr);
if ( a1 == 1 )
exit(-1);
}
else
{
fprintf(log_fp, "%s:%d: %s", a3, a4, ptr);
fflush(log_fp);
free(ptr);
}
}
}
}

canonical_decompiled_code:
void func1(int a1, unsigned int a2, const char *a3, unsigned int a4, const char *a5, ...)
{
int v7; // eax
struct tm *v8; // rax
char *ptr; // [rsp+8h] [rbp-F0h] BYREF
time_t timer; // [rsp+10h] [rbp-E8h] BYREF
gcc_va_list arg; // [rsp+18h] [rbp-E0h] BYREF

if ( !a1 )
goto LABEL_5;
v7 = 1;
if ( *((int *)&log_level + a2) > 0 )
v7 = *((_DWORD *)&log_level + a2);
if ( a1 <= v7 )
{
LABEL_5:
if ( !log_fp )
log_fp = stdout;
va_start(arg, a5);
if ( vasprintf(&ptr, a5, arg) != -1 )
{
timer = time(0LL);
v8 = localtime(&timer);
fprintf(
log_fp,
"[%04d/%02d/%02d %02d:%02d:%02d] ",
(unsigned int)(v8->tm_year + 1900),
(unsigned int)(v8->tm_mon + 1),
(unsigned int)v8->tm_mday,
(unsigned int)v8->tm_hour,
(unsigned int)v8->tm_min,
(unsigned int)v8->tm_sec);
if ( a1 )
{
fprintf(log_fp, "%s:%d: %s: %s", a3, a4, level_name[a1], ptr);
fflush(log_fp);
free(ptr);
if ( a1 == 1 )
exit(-1);
}
else
{
fprintf(log_fp, "%s:%d: %s", a3, a4, ptr);
fflush(log_fp);
free(ptr);
}
}
}
}

original_code:
void
log_err(int level, enum _log_facility facility, char *fname, int lineno, char *fmt, ...)
{
 char * errbuf;
 va_list ap;
 time_t t;
 struct tm *tm;
 if (level && level>log_level[facility] && level>1)
  return;
 if (!log_fp)
  log_fp = stdout;
 __builtin_va_start(ap,fmt);
 if (vasprintf(&errbuf, fmt, ap) == -1)
 {
  __builtin_va_end(ap);
  return;
 }
 __builtin_va_end(ap);
 t = time(((void *)0));
 tm = localtime(&t);
 fprintf(log_fp, "[%04d/%02d/%02d %02d:%02d:%02d] ",
         tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
         tm->tm_hour, tm->tm_min, tm->tm_sec);
 if (level)
  fprintf(log_fp, "%s:%d: %s: %s", fname, lineno, level_name[level], errbuf);
 else
  fprintf(log_fp, "%s:%d: %s", fname, lineno, errbuf);
 fflush(log_fp);
 free(errbuf);
 if (level==1)
  exit(-1);
 return;
}

canonical_original_code:
void log_err(int level, enum _log_facility facility, char *fname, int lineno, char *fmt, ...)
{
 char *errbuf;
 __builtin_va_list ap;
 long t;
 struct tm *tm;
 if (level && level>log_level[facility] && level>1)
  return;
 if (!log_fp)
  log_fp = stdout;
 __builtin_va_start(ap,fmt);
 if (vasprintf(&errbuf, fmt, ap) == -1)
 {
  __builtin_va_end(ap);
  return;
 }
 __builtin_va_end(ap);
 t = time(((void *)0));
 tm = localtime(&t);
 fprintf(log_fp, "[%04d/%02d/%02d %02d:%02d:%02d] ",
         tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
         tm->tm_hour, tm->tm_min, tm->tm_sec);
 if (level)
  fprintf(log_fp, "%s:%d: %s: %s", fname, lineno, level_name[level], errbuf);
 else
  fprintf(log_fp, "%s:%d: %s", fname, lineno, errbuf);
 fflush(log_fp);
 free(errbuf);
 if (level==1)
  exit(-1);
 return;
}

variable_types: level int

variable_types: enum _log_facility { L_GENERAL=0, L_INOTIFY=1, L_HTTP=2, L_SSDP=3, L_MAX=4 }

variable_types:
fname
char *

variable_types: lineno int

variable_types:
fmt
char *

variable_types:
errbuf
char *

variable_types: t long

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


repo: zydcom/dnfs

decompiled_code:
bool_t __fastcall xdr_chunk_info(XDR *a1, void *a2)
{
bool_t result; // eax

result = xdr_uint32_t(a1, (uint32_t *)a2);
if ( result )
result = xdr_uint32_t(a1, (uint32_t *)a2 + 1) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func0(XDR *a1, void *a2)
{
bool_t result; // eax

result = xdr_uint32_t(a1, (uint32_t *)a2);
if ( result )
result = xdr_uint32_t(a1, (uint32_t *)a2 + 1) != 0;
return result;
}

original_code:
bool_t
xdr_chunk_info (XDR *xdrs, chunk_info *objp)
{
 register int32_t *buf;
  if (!xdr_uint32_t (xdrs, &objp->ip))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->bip))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_chunk_info(struct XDR *xdrs, struct chunk_info *objp)
{
 register int *buf;
  if (!xdr_uint32_t (xdrs, &objp->ip))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->bip))
   return (0);
 return (1);
}

variable_types: struct XDR { enum xdr_op { XDR_ENCODE=0, XDR_DECODE=1, XDR_FREE=2 } x_op; struct xdr_ops { int (*x_getlong)(struct XDR *__xdrs, long *__lp); int (*x_putlong)(struct XDR *__xdrs, long *__lp); int (*x_getbytes)(struct XDR *__xdrs, char *__addr, unsigned int __len); int (*x_putbytes)(struct XDR *__xdrs, char *__addr, unsigned int __len); unsigned int (*x_getpostn)(struct XDR *__xdrs); int (*x_setpostn)(struct XDR *__xdrs, unsigned int __pos); int *(*x_inline)(struct XDR *__xdrs, unsigned int __len); void (*x_destroy)(struct XDR *__xdrs); int (*x_getint32)(struct XDR *__xdrs, int *__ip); int (*x_putint32)(struct XDR *__xdrs, int *__ip); } *x_ops; char *x_public; char *x_private; char *x_base; unsigned int x_handy; } *

variable_types: struct chunk_info { unsigned int ip; unsigned int bip; } *

variable_types:
buf
int *

user_defined_types: struct XDR { enum xdr_op x_op; struct xdr_ops *x_ops; char *x_public; char *x_private; char *x_base; unsigned int x_handy; }


decompiled_code:
_BOOL8 __fastcall xdr_dnfs_dir(XDR *a1, void *a2)
{
_BOOL8 result; // rax

if ( xdr_uint64_t(a1, (uint64_t *)a2) && xdr_uint8_t(a1, (uint8_t *)a2 + 8) )
result = xdr_opaque(a1, (caddr_t)a2 + 9, 0x400u) != 0;
else
result = 0LL;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(XDR *a1, void *a2)
{
_BOOL8 result; // rax

if ( xdr_uint64_t(a1, (uint64_t *)a2) && xdr_uint8_t(a1, (uint8_t *)a2 + 8) )
result = xdr_opaque(a1, (caddr_t)a2 + 9, 0x400u) != 0;
else
result = 0LL;
return result;
}

original_code:
bool_t
xdr_dnfs_dir (XDR *xdrs, dnfs_dir *objp)
{
 register int32_t *buf;
 int i;
  if (!xdr_uint64_t (xdrs, &objp->d_ino))
   return (0);
  if (!xdr_uint8_t (xdrs, &objp->d_type))
   return (0);
  if (!xdr_opaque (xdrs, objp->d_name, 1024))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_dnfs_dir(struct XDR *xdrs, struct dnfs_dir *objp)
{
 register int *buf;
 int i;
  if (!xdr_uint64_t (xdrs, &objp->d_ino))
   return (0);
  if (!xdr_uint8_t (xdrs, &objp->d_type))
   return (0);
  if (!xdr_opaque (xdrs, objp->d_name, 1024))
   return (0);
 return (1);
}

variable_types: struct dnfs_dir { unsigned long d_ino; unsigned char d_type; char d_name[1024]; } *

variable_types: i int

user_defined_types: enum xdr_op { XDR_ENCODE=0, XDR_DECODE=1, XDR_FREE=2 }

user_defined_types: struct xdr_ops { int (*x_getlong)(struct XDR *__xdrs, long *__lp); int (*x_putlong)(struct XDR *__xdrs, long *__lp); int (*x_getbytes)(struct XDR *__xdrs, char *__addr, unsigned int __len); int (*x_putbytes)(struct XDR *__xdrs, char *__addr, unsigned int __len); unsigned int (*x_getpostn)(struct XDR *__xdrs); int (*x_setpostn)(struct XDR *__xdrs, unsigned int __pos); int *(*x_inline)(struct XDR *__xdrs, unsigned int __len); void (*x_destroy)(struct XDR *__xdrs); int (*x_getint32)(struct XDR *__xdrs, int *__ip); int (*x_putint32)(struct XDR *__xdrs, int *__ip); }


decompiled_code:
_BOOL8 __fastcall xdr_dnfs_stat(XDR *xdrs, __int64 a2)
{
_BOOL8 result; // rax

if ( xdr_uint64_t(xdrs, (uint64_t *)a2)
&& xdr_uint32_t(xdrs, (uint32_t *)(a2 + 8))
&& xdr_uint16_t(xdrs, (uint16_t *)(a2 + 12))
&& xdr_uint16_t(xdrs, (uint16_t *)(a2 + 14))
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 16))
&& xdr_uint32_t(xdrs, (uint32_t *)(a2 + 24))
&& xdr_uint32_t(xdrs, (uint32_t *)(a2 + 28))
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 32))
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 40))
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 48))
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 56))
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 64)) )
{
result = xdr_uint64_t(xdrs, (uint64_t *)(a2 + 72)) != 0;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(XDR *xdrs, __int64 a2)
{
_BOOL8 result; // rax

if ( xdr_uint64_t(xdrs, (uint64_t *)a2)
&& xdr_uint32_t(xdrs, (uint32_t *)(a2 + 8))
&& xdr_uint16_t(xdrs, (uint16_t *)(a2 + 12))
&& xdr_uint16_t(xdrs, (uint16_t *)(a2 + 14))
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 16))
&& xdr_uint32_t(xdrs, (uint32_t *)(a2 + 24))
&& xdr_uint32_t(xdrs, (uint32_t *)(a2 + 28))
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 32))
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 40))
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 48))
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 56))
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 64)) )
{
result = xdr_uint64_t(xdrs, (uint64_t *)(a2 + 72)) != 0;
}
else
{
result = 0LL;
}
return result;
}

original_code:
bool_t
xdr_dnfs_stat (XDR *xdrs, dnfs_stat *objp)
{
 register int32_t *buf;
  if (!xdr_uint64_t (xdrs, &objp->s_ino))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->s_mode))
   return (0);
  if (!xdr_uint16_t (xdrs, &objp->s_chunks))
   return (0);
  if (!xdr_uint16_t (xdrs, &objp->s_copies))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_nlink))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->s_uid))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->s_gid))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_rdev))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_size))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_blocks))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_atime))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_mtime))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_ctime))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_dnfs_stat(struct XDR *xdrs, struct dnfs_stat *objp)
{
 register int *buf;
  if (!xdr_uint64_t (xdrs, &objp->s_ino))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->s_mode))
   return (0);
  if (!xdr_uint16_t (xdrs, &objp->s_chunks))
   return (0);
  if (!xdr_uint16_t (xdrs, &objp->s_copies))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_nlink))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->s_uid))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->s_gid))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_rdev))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_size))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_blocks))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_atime))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_mtime))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->s_ctime))
   return (0);
 return (1);
}

variable_types: struct dnfs_stat { unsigned long s_ino; unsigned int s_mode; unsigned short s_chunks; unsigned short s_copies; unsigned long s_nlink; unsigned int s_uid; unsigned int s_gid; unsigned long s_rdev; unsigned long s_size; unsigned long s_blocks; unsigned long s_atime; unsigned long s_mtime; unsigned long s_ctime; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_getattr_in(XDR *a1, char **a2)
{
return xdr_string(a1, a2, 0x400u) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(XDR *a1, char **a2)
{
return xdr_string(a1, a2, 0x400u) != 0;
}

original_code:
bool_t
xdr_cs_getattr_in (XDR *xdrs, cs_getattr_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_getattr_in(struct XDR *xdrs, struct cs_getattr_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_getattr_in { char *path; } *


decompiled_code:
__int64 __fastcall xdr_cs_getattr_out(XDR *xdrs, __int64 a2)
{
__int64 result; // rax

result = xdr_dnfs_stat(xdrs, a2);
if ( (_DWORD)result )
result = xdr_int(xdrs, (int *)(a2 + 80)) != 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(XDR *xdrs, __int64 a2)
{
__int64 result; // rax

result = func2(xdrs, a2);
if ( (_DWORD)result )
result = xdr_int(xdrs, (int *)(a2 + 80)) != 0;
return result;
}

original_code:
bool_t
xdr_cs_getattr_out (XDR *xdrs, cs_getattr_out *objp)
{
 register int32_t *buf;
  if (!xdr_dnfs_stat (xdrs, &objp->st))
   return (0);
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_getattr_out(struct XDR *xdrs, struct cs_getattr_out *objp)
{
 register int *buf;
  if (!xdr_dnfs_stat (xdrs, &objp->st))
   return (0);
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types: struct cs_getattr_out { struct dnfs_stat { unsigned long s_ino; unsigned int s_mode; unsigned short s_chunks; unsigned short s_copies; unsigned long s_nlink; unsigned int s_uid; unsigned int s_gid; unsigned long s_rdev; unsigned long s_size; unsigned long s_blocks; unsigned long s_atime; unsigned long s_mtime; unsigned long s_ctime; } st; int err; } *

user_defined_types: struct cs_getattr_out { struct dnfs_stat st; int err; }


decompiled_code:
bool_t __fastcall xdr_cs_access_in(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_int(xdrs, (int *)(a2 + 8)) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func5(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_int(xdrs, (int *)(a2 + 8)) != 0;
return result;
}

original_code:
bool_t
xdr_cs_access_in (XDR *xdrs, cs_access_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_int (xdrs, &objp->mode))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_access_in(struct XDR *xdrs, struct cs_access_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_int (xdrs, &objp->mode))
   return (0);
 return (1);
}

variable_types: struct cs_access_in { char *path; int mode; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_access_out(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

original_code:
bool_t
xdr_cs_access_out (XDR *xdrs, cs_access_out *objp)
{
 register int32_t *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_access_out(struct XDR *xdrs, struct cs_access_out *objp)
{
 register int *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_access_out { int err; } *


decompiled_code:
bool_t __fastcall xdr_cs_mkdir_in(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_u_int(xdrs, (u_int *)(a2 + 8)) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func7(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_u_int(xdrs, (u_int *)(a2 + 8)) != 0;
return result;
}

original_code:
bool_t
xdr_cs_mkdir_in (XDR *xdrs, cs_mkdir_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_u_int (xdrs, &objp->mode))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_mkdir_in(struct XDR *xdrs, struct cs_mkdir_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_u_int (xdrs, &objp->mode))
   return (0);
 return (1);
}

variable_types: struct cs_mkdir_in { char *path; unsigned int mode; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_mkdir_out(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

original_code:
bool_t
xdr_cs_mkdir_out (XDR *xdrs, cs_mkdir_out *objp)
{
 register int32_t *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_mkdir_out(struct XDR *xdrs, struct cs_mkdir_out *objp)
{
 register int *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_mkdir_out { int err; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_rmdir_in(XDR *a1, char **a2)
{
return xdr_string(a1, a2, 0x400u) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(XDR *a1, char **a2)
{
return xdr_string(a1, a2, 0x400u) != 0;
}

original_code:
bool_t
xdr_cs_rmdir_in (XDR *xdrs, cs_rmdir_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_rmdir_in(struct XDR *xdrs, struct cs_rmdir_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_rmdir_in { char *path; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_rmdir_out(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func10(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

original_code:
bool_t
xdr_cs_rmdir_out (XDR *xdrs, cs_rmdir_out *objp)
{
 register int32_t *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_rmdir_out(struct XDR *xdrs, struct cs_rmdir_out *objp)
{
 register int *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_rmdir_out { int err; } *


decompiled_code:
bool_t __fastcall xdr_cs_readdir_in(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_u_long(xdrs, (u_long *)(a2 + 8)) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func11(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_u_long(xdrs, (u_long *)(a2 + 8)) != 0;
return result;
}

original_code:
bool_t
xdr_cs_readdir_in (XDR *xdrs, cs_readdir_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_u_long (xdrs, &objp->dp))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_readdir_in(struct XDR *xdrs, struct cs_readdir_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_u_long (xdrs, &objp->dp))
   return (0);
 return (1);
}

variable_types: struct cs_readdir_in { char *path; unsigned long dp; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_readdir_out(XDR *xdrs, u_int *sizep)
{
_BOOL8 result; // rax

if ( xdr_array(xdrs, (caddr_t *)sizep + 1, sizep, 0x1Eu, 0x410u, (xdrproc_t)xdr_dnfs_dir)
&& xdr_u_long(xdrs, (u_long *)sizep + 2) )
{
result = xdr_int(xdrs, (int *)sizep + 6) != 0;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func12(XDR *xdrs, u_int *sizep)
{
_BOOL8 result; // rax

if ( xdr_array(xdrs, (caddr_t *)sizep + 1, sizep, 0x1Eu, 0x410u, (xdrproc_t)xdr_dnfs_dir)
&& xdr_u_long(xdrs, (u_long *)sizep + 2) )
{
result = xdr_int(xdrs, (int *)sizep + 6) != 0;
}
else
{
result = 0LL;
}
return result;
}

original_code:
bool_t
xdr_cs_readdir_out (XDR *xdrs, cs_readdir_out *objp)
{
 register int32_t *buf;
  if (!xdr_array (xdrs, (char **)&objp->dirs.dirs_val, (u_int *) &objp->dirs.dirs_len, 30,
  sizeof (dnfs_dir), (xdrproc_t) xdr_dnfs_dir))
   return (0);
  if (!xdr_u_long (xdrs, &objp->dp))
   return (0);
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_readdir_out(struct XDR *xdrs, struct cs_readdir_out *objp)
{
 register int *buf;
  if (!xdr_array (xdrs, (char **)&objp->dirs.dirs_val, (unsigned int *) &objp->dirs.dirs_len, 30,
  sizeof (dnfs_dir), (int (*)(struct XDR *, void *, ...)) xdr_dnfs_dir))
   return (0);
  if (!xdr_u_long (xdrs, &objp->dp))
   return (0);
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types: struct cs_readdir_out { struct { unsigned int dirs_len; struct dnfs_dir { unsigned long d_ino; unsigned char d_type; char d_name[1024]; } *dirs_val; } dirs; unsigned long dp; int err; } *

user_defined_types: struct cs_readdir_out { struct { unsigned int dirs_len; struct dnfs_dir *dirs_val; } dirs; unsigned long dp; int err; }


decompiled_code:
bool_t __fastcall xdr_cs_mknod_in(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_u_int(xdrs, (u_int *)(a2 + 8)) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func13(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_u_int(xdrs, (u_int *)(a2 + 8)) != 0;
return result;
}

original_code:
bool_t
xdr_cs_mknod_in (XDR *xdrs, cs_mknod_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_u_int (xdrs, &objp->mode))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_mknod_in(struct XDR *xdrs, struct cs_mknod_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_u_int (xdrs, &objp->mode))
   return (0);
 return (1);
}

variable_types: struct cs_mknod_in { char *path; unsigned int mode; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_mknod_out(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func14(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

original_code:
bool_t
xdr_cs_mknod_out (XDR *xdrs, cs_mknod_out *objp)
{
 register int32_t *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_mknod_out(struct XDR *xdrs, struct cs_mknod_out *objp)
{
 register int *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types: struct XDR { enum xdr_op { XDR_ENCODE=0, XDR_DECODE=1, XDR_FREE=2 } x_op; struct xdr_ops { int (*x_getlong)(struct XDR *__xdrs, long *__lp); int (*x_putlong)(struct XDR *__xdrs, long *__lp); int (*x_getbytes)(struct XDR *__xdrs, char *__addr, unsigned int __len); int (*x_putbytes)(struct XDR *__xdrs, char *__addr, unsigned int __len); unsigned int (*x_getpostn)(struct XDR *__xdrs); int (*x_setpostn)(struct XDR *__xdrs, unsigned int __pos); int *(*x_inline)(struct XDR *__xdrs, unsigned int __len); void (*x_destroy)(struct XDR *__xdrs); int (*x_getint32)(struct XDR *__xdrs, int *__ip); int (*x_putint32)(struct XDR *__xdrs, int *__ip); } *x_ops; char *x_public; char *x_private; char *x_base; unsigned int x_handy; } *

variable_types:
objp
struct cs_mknod_out { int err; } *


decompiled_code:
bool_t __fastcall xdr_cs_setwflag_in(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_int(xdrs, (int *)(a2 + 8)) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func15(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_int(xdrs, (int *)(a2 + 8)) != 0;
return result;
}

original_code:
bool_t
xdr_cs_setwflag_in (XDR *xdrs, cs_setwflag_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_int (xdrs, &objp->promote))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_setwflag_in(struct XDR *xdrs, struct cs_setwflag_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_int (xdrs, &objp->promote))
   return (0);
 return (1);
}

variable_types: struct cs_setwflag_in { char *path; int promote; } *

variable_types:
buf
int *


decompiled_code:
_BOOL8 __fastcall xdr_cs_setwflag_out(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func16(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

original_code:
bool_t
xdr_cs_setwflag_out (XDR *xdrs, cs_setwflag_out *objp)
{
 register int32_t *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_setwflag_out(struct XDR *xdrs, struct cs_setwflag_out *objp)
{
 register int *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_setwflag_out { int err; } *


decompiled_code:
bool_t __fastcall xdr_cs_open_in(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_u_int(xdrs, (u_int *)(a2 + 8)) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func17(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_u_int(xdrs, (u_int *)(a2 + 8)) != 0;
return result;
}

original_code:
bool_t
xdr_cs_open_in (XDR *xdrs, cs_open_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_u_int (xdrs, &objp->mode))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_open_in(struct XDR *xdrs, struct cs_open_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_u_int (xdrs, &objp->mode))
   return (0);
 return (1);
}

variable_types: struct cs_open_in { char *path; unsigned int mode; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_open_out(XDR *xdrs, __int64 a2)
{
_BOOL8 result; // rax

if ( xdr_uint64_t(xdrs, (uint64_t *)a2)
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 8))
&& xdr_array(xdrs, (caddr_t *)(a2 + 24), (u_int *)(a2 + 16), 0x400u, 8u, (xdrproc_t)xdr_chunk_info) )
{
result = xdr_int(xdrs, (int *)(a2 + 32)) != 0;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func18(XDR *xdrs, __int64 a2)
{
_BOOL8 result; // rax

if ( xdr_uint64_t(xdrs, (uint64_t *)a2)
&& xdr_uint64_t(xdrs, (uint64_t *)(a2 + 8))
&& xdr_array(xdrs, (caddr_t *)(a2 + 24), (u_int *)(a2 + 16), 0x400u, 8u, (xdrproc_t)xdr_chunk_info) )
{
result = xdr_int(xdrs, (int *)(a2 + 32)) != 0;
}
else
{
result = 0LL;
}
return result;
}

original_code:
bool_t
xdr_cs_open_out (XDR *xdrs, cs_open_out *objp)
{
 register int32_t *buf;
  if (!xdr_uint64_t (xdrs, &objp->ino))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->size))
   return (0);
  if (!xdr_array (xdrs, (char **)&objp->chunks.chunks_val, (u_int *) &objp->chunks.chunks_len, 1024,
  sizeof (chunk_info), (xdrproc_t) xdr_chunk_info))
   return (0);
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_open_out(struct XDR *xdrs, struct cs_open_out *objp)
{
 register int *buf;
  if (!xdr_uint64_t (xdrs, &objp->ino))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->size))
   return (0);
  if (!xdr_array (xdrs, (char **)&objp->chunks.chunks_val, (unsigned int *) &objp->chunks.chunks_len, 1024,
  sizeof (chunk_info), (int (*)(struct XDR *, void *, ...)) xdr_chunk_info))
   return (0);
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types: struct cs_open_out { unsigned long ino; unsigned long size; struct { unsigned int chunks_len; struct chunk_info { unsigned int ip; unsigned int bip; } *chunks_val; } chunks; int err; } *

user_defined_types: struct cs_open_out { unsigned long ino; unsigned long size; struct { unsigned int chunks_len; struct chunk_info *chunks_val; } chunks; int err; }


decompiled_code:
_BOOL8 __fastcall xdr_cs_newchunk_in(XDR *a1, char **a2)
{
return xdr_string(a1, a2, 0x400u) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func19(XDR *a1, char **a2)
{
return xdr_string(a1, a2, 0x400u) != 0;
}

original_code:
bool_t
xdr_cs_newchunk_in (XDR *xdrs, cs_newchunk_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_newchunk_in(struct XDR *xdrs, struct cs_newchunk_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_newchunk_in { char *path; } *


decompiled_code:
bool_t __fastcall xdr_cs_newchunk_out(XDR *xdrs, int *a2)
{
bool_t result; // eax

result = xdr_chunk_info(xdrs, a2);
if ( result )
result = xdr_int(xdrs, a2 + 2) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func20(XDR *xdrs, int *a2)
{
bool_t result; // eax

result = func0(xdrs, a2);
if ( result )
result = xdr_int(xdrs, a2 + 2) != 0;
return result;
}

original_code:
bool_t
xdr_cs_newchunk_out (XDR *xdrs, cs_newchunk_out *objp)
{
 register int32_t *buf;
  if (!xdr_chunk_info (xdrs, &objp->chunk))
   return (0);
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_newchunk_out(struct XDR *xdrs, struct cs_newchunk_out *objp)
{
 register int *buf;
  if (!xdr_chunk_info (xdrs, &objp->chunk))
   return (0);
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types: struct cs_newchunk_out { struct chunk_info { unsigned int ip; unsigned int bip; } chunk; int err; } *

user_defined_types: struct cs_newchunk_out { struct chunk_info chunk; int err; }


decompiled_code:
bool_t __fastcall xdr_cs_release_in(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_uint64_t(xdrs, (uint64_t *)(a2 + 8)) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func21(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_uint64_t(xdrs, (uint64_t *)(a2 + 8)) != 0;
return result;
}

original_code:
bool_t
xdr_cs_release_in (XDR *xdrs, cs_release_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->size))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_release_in(struct XDR *xdrs, struct cs_release_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->size))
   return (0);
 return (1);
}

variable_types: struct cs_release_in { char *path; unsigned long size; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_release_out(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func22(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

original_code:
bool_t
xdr_cs_release_out (XDR *xdrs, cs_release_out *objp)
{
 register int32_t *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_release_out(struct XDR *xdrs, struct cs_release_out *objp)
{
 register int *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_release_out { int err; } *


decompiled_code:
bool_t __fastcall xdr_cs_truncate_in(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_uint64_t(xdrs, (uint64_t *)(a2 + 8)) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func23(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_uint64_t(xdrs, (uint64_t *)(a2 + 8)) != 0;
return result;
}

original_code:
bool_t
xdr_cs_truncate_in (XDR *xdrs, cs_truncate_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->size))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_truncate_in(struct XDR *xdrs, struct cs_truncate_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_uint64_t (xdrs, &objp->size))
   return (0);
 return (1);
}

variable_types: struct cs_truncate_in { char *path; unsigned long size; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_truncate_out(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func24(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

original_code:
bool_t
xdr_cs_truncate_out (XDR *xdrs, cs_truncate_out *objp)
{
 register int32_t *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_truncate_out(struct XDR *xdrs, struct cs_truncate_out *objp)
{
 register int *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_truncate_out { int err; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_getlist_in(XDR *a1, char **a2)
{
return xdr_string(a1, a2, 0x400u) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func25(XDR *a1, char **a2)
{
return xdr_string(a1, a2, 0x400u) != 0;
}

original_code:
bool_t
xdr_cs_getlist_in (XDR *xdrs, cs_getlist_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_getlist_in(struct XDR *xdrs, struct cs_getlist_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_getlist_in { char *path; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_getlist_out(XDR *xdrs, __int64 a2)
{
_BOOL8 result; // rax

if ( xdr_uint64_t(xdrs, (uint64_t *)a2)
&& xdr_array(xdrs, (caddr_t *)(a2 + 16), (u_int *)(a2 + 8), 0x400u, 8u, (xdrproc_t)xdr_chunk_info) )
{
result = xdr_int(xdrs, (int *)(a2 + 24)) != 0;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func26(XDR *xdrs, __int64 a2)
{
_BOOL8 result; // rax

if ( xdr_uint64_t(xdrs, (uint64_t *)a2)
&& xdr_array(xdrs, (caddr_t *)(a2 + 16), (u_int *)(a2 + 8), 0x400u, 8u, (xdrproc_t)xdr_chunk_info) )
{
result = xdr_int(xdrs, (int *)(a2 + 24)) != 0;
}
else
{
result = 0LL;
}
return result;
}

original_code:
bool_t
xdr_cs_getlist_out (XDR *xdrs, cs_getlist_out *objp)
{
 register int32_t *buf;
  if (!xdr_uint64_t (xdrs, &objp->ino))
   return (0);
  if (!xdr_array (xdrs, (char **)&objp->chunks.chunks_val, (u_int *) &objp->chunks.chunks_len, 1024,
  sizeof (chunk_info), (xdrproc_t) xdr_chunk_info))
   return (0);
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_getlist_out(struct XDR *xdrs, struct cs_getlist_out *objp)
{
 register int *buf;
  if (!xdr_uint64_t (xdrs, &objp->ino))
   return (0);
  if (!xdr_array (xdrs, (char **)&objp->chunks.chunks_val, (unsigned int *) &objp->chunks.chunks_len, 1024,
  sizeof (chunk_info), (int (*)(struct XDR *, void *, ...)) xdr_chunk_info))
   return (0);
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types: struct cs_getlist_out { unsigned long ino; struct { unsigned int chunks_len; struct chunk_info { unsigned int ip; unsigned int bip; } *chunks_val; } chunks; int err; } *

user_defined_types: struct cs_getlist_out { unsigned long ino; struct { unsigned int chunks_len; struct chunk_info *chunks_val; } chunks; int err; }


decompiled_code:
_BOOL8 __fastcall xdr_cs_unlink_in(XDR *a1, char **a2)
{
return xdr_string(a1, a2, 0x400u) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func27(XDR *a1, char **a2)
{
return xdr_string(a1, a2, 0x400u) != 0;
}

original_code:
bool_t
xdr_cs_unlink_in (XDR *xdrs, cs_unlink_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_unlink_in(struct XDR *xdrs, struct cs_unlink_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_unlink_in { char *path; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_unlink_out(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func28(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

original_code:
bool_t
xdr_cs_unlink_out (XDR *xdrs, cs_unlink_out *objp)
{
 register int32_t *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_unlink_out(struct XDR *xdrs, struct cs_unlink_out *objp)
{
 register int *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_unlink_out { int err; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_chown_in(XDR *xdrs, __int64 a2)
{
_BOOL8 result; // rax

if ( xdr_string(xdrs, (char **)a2, 0x400u) && xdr_u_int(xdrs, (u_int *)(a2 + 8)) )
result = xdr_u_int(xdrs, (u_int *)(a2 + 12)) != 0;
else
result = 0LL;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func29(XDR *xdrs, __int64 a2)
{
_BOOL8 result; // rax

if ( xdr_string(xdrs, (char **)a2, 0x400u) && xdr_u_int(xdrs, (u_int *)(a2 + 8)) )
result = xdr_u_int(xdrs, (u_int *)(a2 + 12)) != 0;
else
result = 0LL;
return result;
}

original_code:
bool_t
xdr_cs_chown_in (XDR *xdrs, cs_chown_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_u_int (xdrs, &objp->owner))
   return (0);
  if (!xdr_u_int (xdrs, &objp->group))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_chown_in(struct XDR *xdrs, struct cs_chown_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_u_int (xdrs, &objp->owner))
   return (0);
  if (!xdr_u_int (xdrs, &objp->group))
   return (0);
 return (1);
}

variable_types: struct XDR { enum xdr_op { XDR_ENCODE=0, XDR_DECODE=1, XDR_FREE=2 } x_op; struct xdr_ops { int (*x_getlong)(struct XDR *__xdrs, long *__lp); int (*x_putlong)(struct XDR *__xdrs, long *__lp); int (*x_getbytes)(struct XDR *__xdrs, char *__addr, unsigned int __len); int (*x_putbytes)(struct XDR *__xdrs, char *__addr, unsigned int __len); unsigned int (*x_getpostn)(struct XDR *__xdrs); int (*x_setpostn)(struct XDR *__xdrs, unsigned int __pos); int *(*x_inline)(struct XDR *__xdrs, unsigned int __len); void (*x_destroy)(struct XDR *__xdrs); int (*x_getint32)(struct XDR *__xdrs, int *__ip); int (*x_putint32)(struct XDR *__xdrs, int *__ip); } *x_ops; char *x_public; char *x_private; char *x_base; unsigned int x_handy; } *

variable_types: struct cs_chown_in { char *path; unsigned int owner; unsigned int group; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_chown_out(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func30(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

original_code:
bool_t
xdr_cs_chown_out (XDR *xdrs, cs_chown_out *objp)
{
 register int32_t *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_chown_out(struct XDR *xdrs, struct cs_chown_out *objp)
{
 register int *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_chown_out { int err; } *


decompiled_code:
bool_t __fastcall xdr_cs_chmod_in(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_u_int(xdrs, (u_int *)(a2 + 8)) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func31(XDR *xdrs, __int64 a2)
{
bool_t result; // eax

result = xdr_string(xdrs, (char **)a2, 0x400u);
if ( result )
result = xdr_u_int(xdrs, (u_int *)(a2 + 8)) != 0;
return result;
}

original_code:
bool_t
xdr_cs_chmod_in (XDR *xdrs, cs_chmod_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_u_int (xdrs, &objp->mode))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_chmod_in(struct XDR *xdrs, struct cs_chmod_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
  if (!xdr_u_int (xdrs, &objp->mode))
   return (0);
 return (1);
}

variable_types: struct cs_chmod_in { char *path; unsigned int mode; } *

variable_types:
buf
int *


decompiled_code:
_BOOL8 __fastcall xdr_cs_chmod_out(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func32(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

original_code:
bool_t
xdr_cs_chmod_out (XDR *xdrs, cs_chmod_out *objp)
{
 register int32_t *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_chmod_out(struct XDR *xdrs, struct cs_chmod_out *objp)
{
 register int *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_chmod_out { int err; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_statfs_in(XDR *a1, char **a2)
{
return xdr_string(a1, a2, 0x400u) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func33(XDR *a1, char **a2)
{
return xdr_string(a1, a2, 0x400u) != 0;
}

original_code:
bool_t
xdr_cs_statfs_in (XDR *xdrs, cs_statfs_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_statfs_in(struct XDR *xdrs, struct cs_statfs_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->path, 1024))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_statfs_in { char *path; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_statfs_out(XDR *xdrs, __int64 a2)
{
_BOOL8 result; // rax

if ( xdr_uint32_t(xdrs, (uint32_t *)a2)
&& xdr_uint32_t(xdrs, (uint32_t *)(a2 + 4))
&& xdr_uint32_t(xdrs, (uint32_t *)(a2 + 8)) )
{
result = xdr_int(xdrs, (int *)(a2 + 12)) != 0;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func34(XDR *xdrs, __int64 a2)
{
_BOOL8 result; // rax

if ( xdr_uint32_t(xdrs, (uint32_t *)a2)
&& xdr_uint32_t(xdrs, (uint32_t *)(a2 + 4))
&& xdr_uint32_t(xdrs, (uint32_t *)(a2 + 8)) )
{
result = xdr_int(xdrs, (int *)(a2 + 12)) != 0;
}
else
{
result = 0LL;
}
return result;
}

original_code:
bool_t
xdr_cs_statfs_out (XDR *xdrs, cs_statfs_out *objp)
{
 register int32_t *buf;
  if (!xdr_uint32_t (xdrs, &objp->f_blocks))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->f_bavail))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->f_bsize))
   return (0);
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_statfs_out(struct XDR *xdrs, struct cs_statfs_out *objp)
{
 register int *buf;
  if (!xdr_uint32_t (xdrs, &objp->f_blocks))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->f_bavail))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->f_bsize))
   return (0);
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types: struct cs_statfs_out { unsigned int f_blocks; unsigned int f_bavail; unsigned int f_bsize; int err; } *


decompiled_code:
bool_t __fastcall xdr_cs_auth_in(XDR *xdrs, char **a2)
{
bool_t result; // eax

result = xdr_string(xdrs, a2, 0x100u);
if ( result )
result = xdr_string(xdrs, a2 + 1, 0x100u) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func35(XDR *xdrs, char **a2)
{
bool_t result; // eax

result = xdr_string(xdrs, a2, 0x100u);
if ( result )
result = xdr_string(xdrs, a2 + 1, 0x100u) != 0;
return result;
}

original_code:
bool_t
xdr_cs_auth_in (XDR *xdrs, cs_auth_in *objp)
{
 register int32_t *buf;
  if (!xdr_string (xdrs, &objp->user, 256))
   return (0);
  if (!xdr_string (xdrs, &objp->passwd, 256))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_auth_in(struct XDR *xdrs, struct cs_auth_in *objp)
{
 register int *buf;
  if (!xdr_string (xdrs, &objp->user, 256))
   return (0);
  if (!xdr_string (xdrs, &objp->passwd, 256))
   return (0);
 return (1);
}

variable_types: struct cs_auth_in { char *user; char *passwd; } *


decompiled_code:
_BOOL8 __fastcall xdr_cs_auth_out(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func36(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

original_code:
bool_t
xdr_cs_auth_out (XDR *xdrs, cs_auth_out *objp)
{
 register int32_t *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_cs_auth_out(struct XDR *xdrs, struct cs_auth_out *objp)
{
 register int *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types:
objp
struct cs_auth_out { int err; } *


decompiled_code:
bool_t __fastcall xdr_os_heart_in(XDR *xdrs, uint32_t *a2)
{
bool_t result; // eax

result = xdr_uint32_t(xdrs, a2);
if ( result )
result = xdr_uint32_t(xdrs, a2 + 1) != 0;
return result;
}

canonical_decompiled_code:
bool_t __fastcall func37(XDR *xdrs, uint32_t *a2)
{
bool_t result; // eax

result = xdr_uint32_t(xdrs, a2);
if ( result )
result = xdr_uint32_t(xdrs, a2 + 1) != 0;
return result;
}

original_code:
bool_t
xdr_os_heart_in (XDR *xdrs, os_heart_in *objp)
{
 register int32_t *buf;
  if (!xdr_uint32_t (xdrs, &objp->total))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->avail))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_os_heart_in(struct XDR *xdrs, struct os_heart_in *objp)
{
 register int *buf;
  if (!xdr_uint32_t (xdrs, &objp->total))
   return (0);
  if (!xdr_uint32_t (xdrs, &objp->avail))
   return (0);
 return (1);
}

variable_types: struct os_heart_in { unsigned int total; unsigned int avail; } *


decompiled_code:
_BOOL8 __fastcall xdr_os_heart_out(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func38(XDR *a1, int *a2)
{
return xdr_int(a1, a2) != 0;
}

original_code:
bool_t
xdr_os_heart_out (XDR *xdrs, os_heart_out *objp)
{
 register int32_t *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

canonical_original_code:
int xdr_os_heart_out(struct XDR *xdrs, struct os_heart_out *objp)
{
 register int *buf;
  if (!xdr_int (xdrs, &objp->err))
   return (0);
 return (1);
}

variable_types:
objp
struct os_heart_out { int err; } *


decompiled_code:
void __fastcall __noreturn heart_check(void *a1)
{
int v1; // edx
unsigned __int16 v2; // r12
__int64 v3; // rax
int v4; // ebp
__int64 v5; // rsi
unsigned int *v6; // rdi
int v7; // ecx
__int64 v8; // rbx
__int16 v9; // r12
bool v10; // zf
char v11[40]; // [rsp+0h] [rbp-28h] BYREF

while ( 1 )
{
fwrite("[check node state]\n", 1uLL, 0x13uLL, stderr);
v1 = *((unsigned __int16 *)&nodehead + 4);
if ( *((_WORD *)&nodehead + 4) )
{
v2 = *((_WORD *)&nodehead + 4);
v3 = 0LL;
v4 = 0;
do
{
v5 = nodehead;
v6 = (unsigned int *)(nodehead + v3);
v7 = *(_DWORD *)(nodehead + v3 + 12);
if ( v7 > 3 )
{
*((_QWORD *)&nodehead + 2) -= v6[1];
*((_QWORD *)&nodehead + 3) -= v6[2];
v8 = v3 + 16;
if ( v1 - 1 > v4 )
v6 = (unsigned int *)memmove(v6, (const void *)(v3 + 16 + v5), 16 * ((unsigned int)(v1 - 2 - v4) + 1LL));
v9 = v2 - 1;
v10 = v9 == *((_WORD *)&nodehead + 5);
*((_WORD *)&nodehead + 4) = v9;
if ( v10 )
*((_WORD *)&nodehead + 5) = 0;
get_addr(v11, *v6);
fprintf(stderr, "[node %s is down]\n", v11);
v2 = *((_WORD *)&nodehead + 4);
}
else
{
v8 = v3 + 16;
if ( v7 >= 0 )
v6[3] = v7 + 1;
}
++v4;
v1 = v2;
v3 = v8;
}
while ( v2 > v4 );
}
sleep(5u);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func1(void *a1)
{
int v1; // edx
unsigned __int16 v2; // r12
__int64 v3; // rax
int v4; // ebp
__int64 v5; // rsi
unsigned int *v6; // rdi
int v7; // ecx
__int64 v8; // rbx
__int16 v9; // r12
bool v10; // zf
char v11[40]; // [rsp+0h] [rbp-28h] BYREF

while ( 1 )
{
fwrite("[check node state]\n", 1uLL, 0x13uLL, stderr);
v1 = *((unsigned __int16 *)&nodehead + 4);
if ( *((_WORD *)&nodehead + 4) )
{
v2 = *((_WORD *)&nodehead + 4);
v3 = 0LL;
v4 = 0;
do
{
v5 = nodehead;
v6 = (unsigned int *)(nodehead + v3);
v7 = *(_DWORD *)(nodehead + v3 + 12);
if ( v7 > 3 )
{
*((_QWORD *)&nodehead + 2) -= v6[1];
*((_QWORD *)&nodehead + 3) -= v6[2];
v8 = v3 + 16;
if ( v1 - 1 > v4 )
v6 = (unsigned int *)memmove(v6, (const void *)(v3 + 16 + v5), 16 * ((unsigned int)(v1 - 2 - v4) + 1LL));
v9 = v2 - 1;
v10 = v9 == *((_WORD *)&nodehead + 5);
*((_WORD *)&nodehead + 4) = v9;
if ( v10 )
*((_WORD *)&nodehead + 5) = 0;
get_addr(v11, *v6);
fprintf(stderr, "[node %s is down]\n", v11);
v2 = *((_WORD *)&nodehead + 4);
}
else
{
v8 = v3 + 16;
if ( v7 >= 0 )
v6[3] = v7 + 1;
}
++v4;
v1 = v2;
v3 = v8;
}
while ( v2 > v4 );
}
sleep(5u);
}
}

original_code:
void* heart_check()
{
 int i, j;
 while(1)
 {
  fprintf(stderr, "[check node state]\n");
        for(i = 0; i < nodehead.items; i++) {
         if(nodehead.list[i].hearts >= 4) {
          nodehead.total -= nodehead.list[i].total;
          nodehead.avail -= nodehead.list[i].avail;
          for(j = i; j < nodehead.items - 1; j++) {
           nodehead.list[j] = nodehead.list[j+1];
          }
          nodehead.items--;
          if(nodehead.offset == nodehead.items)
           nodehead.offset = 0;
          char ipp[16];
          get_addr(ipp, nodehead.list[i].ip);
          fprintf(stderr, "[node %s is down]\n", ipp);
         }
         else if(nodehead.list[i].hearts >= 0)
          nodehead.list[i].hearts++;
        }
        sleep(5);
    }
}

canonical_original_code:
void *heart_check()
{
 int i; int j;
 while(1)
 {
  fprintf(stderr, "[check node state]\n");
        for(i = 0; i < nodehead.items; i++) {
         if(nodehead.list[i].hearts >= 4) {
          nodehead.total -= nodehead.list[i].total;
          nodehead.avail -= nodehead.list[i].avail;
          for(j = i; j < nodehead.items - 1; j++) {
           nodehead.list[j] = nodehead.list[j+1];
          }
          nodehead.items--;
          if(nodehead.offset == nodehead.items)
           nodehead.offset = 0;
          char ipp[16];
          get_addr(ipp, nodehead.list[i].ip);
          fprintf(stderr, "[node %s is down]\n", ipp);
         }
         else if(nodehead.list[i].hearts >= 0)
          nodehead.list[i].hearts++;
        }
        sleep(5);
    }
}

variable_types: i int

variable_types: j int

variable_types:
ipp
char [16]

return_type: void *


decompiled_code:
__int64 nodehead_init()
{
*((_QWORD *)&nodehead + 2) = 0LL;
*((_QWORD *)&nodehead + 3) = 0LL;
*((_DWORD *)&nodehead + 2) = 0;
*((_WORD *)&nodehead + 6) = 32;
nodehead = malloc(0x200uLL);
return nodehead == 0LL ? 0xFFFFFFF4 : 0;
}

canonical_decompiled_code:
__int64 func4()
{
*((_QWORD *)&nodehead + 2) = 0LL;
*((_QWORD *)&nodehead + 3) = 0LL;
*((_DWORD *)&nodehead + 2) = 0;
*((_WORD *)&nodehead + 6) = 32;
nodehead = malloc(0x200uLL);
return nodehead == 0LL ? 0xFFFFFFF4 : 0;
}

original_code:
int nodehead_init()
{
 nodehead.items = 0;
 nodehead.offset = 0;
 nodehead.total = 0;
 nodehead.avail = 0;
 nodehead.cur_max = 32;
 nodehead.list = (node_info*)malloc(32 * sizeof(node_info));
 if(!nodehead.list)
  return -12;
 return 0;
}

canonical_original_code:
int nodehead_init()
{
 nodehead.items = 0;
 nodehead.offset = 0;
 nodehead.total = 0;
 nodehead.avail = 0;
 nodehead.cur_max = 32;
 nodehead.list = (struct node_info *)malloc(32 * sizeof(node_info));
 if(!nodehead.list)
  return -12;
 return 0;
}

user_defined_types: struct node_info { unsigned int ip; unsigned int total; unsigned int avail; int hearts; }


decompiled_code:
__int64 filehead_init()
{
char *v0; // rax
__int64 i; // rbx
__int64 v2; // rdx

v0 = (char *)malloc(0x3800uLL);
filehead = v0;
if ( !v0 )
return 4294967284LL;
for ( i = 0LL; i != 14336; i += 56LL )
{
pthread_mutex_init((pthread_mutex_t *)&v0[i + 16], 0LL);
v0 = (char *)filehead;
v2 = filehead + i;
*(_DWORD *)v2 = 0;
*(_QWORD *)(v2 + 8) = 0LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
char *v0; // rax
__int64 i; // rbx
__int64 v2; // rdx

v0 = (char *)malloc(0x3800uLL);
filehead = v0;
if ( !v0 )
return 4294967284LL;
for ( i = 0LL; i != 14336; i += 56LL )
{
pthread_mutex_init((pthread_mutex_t *)&v0[i + 16], 0LL);
v0 = (char *)filehead;
v2 = filehead + i;
*(_DWORD *)v2 = 0;
*(_QWORD *)(v2 + 8) = 0LL;
}
return 0LL;
}

original_code:
int filehead_init()
{
 filehead = (file_head*)malloc(256 * sizeof(file_head));
 if(!filehead)
  return -12;
 int i;
 for(i = 0; i < 256; i++) {
  pthread_mutex_init(&filehead[i].lock, ((void *)0));
  filehead[i].items = 0;
  ((&filehead[i].list)->first = ((void *)0));
 }
 return 0;
}

canonical_original_code:
int filehead_init()
{
 filehead = (struct file_head *)malloc(256 * sizeof(file_head));
 if(!filehead)
  return -12;
 int i;
 for(i = 0; i < 256; i++) {
  pthread_mutex_init(&filehead[i].lock, ((void *)0));
  filehead[i].items = 0;
  ((&filehead[i].list)->first = ((void *)0));
 }
 return 0;
}

user_defined_types: struct file_head { int items; struct hlist_head list; union pthread_mutex_t lock; }

user_defined_types: struct hlist_head { struct hlist_node *first; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }

user_defined_types: struct hlist_node { struct hlist_node *next; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }


decompiled_code:
_DWORD *file_get()
{
_DWORD *result; // rax

result = malloc(0x20uLL);
if ( result )
{
result[4] = 0;
*((_QWORD *)result + 3) = 0LL;
*(_QWORD *)result = 0LL;
*((_QWORD *)result + 1) = 0LL;
}
return result;
}

canonical_decompiled_code:
_DWORD *func6()
{
_DWORD *result; // rax

result = malloc(0x20uLL);
if ( result )
{
result[4] = 0;
*((_QWORD *)result + 3) = 0LL;
*(_QWORD *)result = 0LL;
*((_QWORD *)result + 1) = 0LL;
}
return result;
}

original_code:
file_info* file_get()
{
 file_info *item = (file_info*)malloc(sizeof(file_info));
 if(!item)
  return ((void *)0);
 item->wflag = 0;
 item->path = ((void *)0);
 ((&item->list)->next = ((void *)0), (&item->list)->pprev = ((void *)0));
 return item;
}

canonical_original_code:
struct file_info *file_get()
{
 struct file_info *item = (file_info*)malloc(sizeof(file_info));
 if(!item)
  return ((void *)0);
 item->wflag = 0;
 item->path = ((void *)0);
 ((&item->list)->next = ((void *)0), (&item->list)->pprev = ((void *)0));
 return item;
}

variable_types: struct file_info { struct hlist_node { struct hlist_node *next; } list; int wflag; char *path; } *

user_defined_types: struct file_info { struct hlist_node list; int wflag; char *path; }


decompiled_code:
void __fastcall file_put(void *ptr)
{
void *v2; // rdi

v2 = (void *)*((_QWORD *)ptr + 3);
if ( v2 )
free(v2);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func7(void *ptr)
{
void *v2; // rdi

v2 = (void *)*((_QWORD *)ptr + 3);
if ( v2 )
free(v2);
free(ptr);
}

original_code:
void file_put(file_info *item)
{
 if(item->path) {
  free(item->path);
  item->path = ((void *)0);
 }
 free(item);
}

canonical_original_code:
void file_put(struct file_info *item)
{
 if(item->path) {
  free(item->path);
  item->path = ((void *)0);
 }
 free(item);
}


hash

decompiled_code:
__int64 __fastcall hash(char *a1, int a2)
{
unsigned int v2; // edx
char *v3; // rsi

if ( !a2 )
return 167LL;
v2 = 1315423911;
v3 = &a1[a2];
do
v2 ^= *a1++ + (v2 >> 2) + 32 * v2;
while ( a1 != v3 );
return (unsigned __int8)v2;
}

canonical_decompiled_code:
__int64 __fastcall func8(char *a1, int a2)
{
unsigned int v2; // edx
char *v3; // rsi

if ( !a2 )
return 167LL;
v2 = 1315423911;
v3 = &a1[a2];
do
v2 ^= *a1++ + (v2 >> 2) + 32 * v2;
while ( a1 != v3 );
return (unsigned __int8)v2;
}

original_code:
unsigned int hash(char* str, unsigned int len)
{
   unsigned int hash = 1315423911;
   unsigned int i = 0;
   for(i = 0; i < len; str++, i++)
   {
      hash ^= ((hash << 5) + (*str) + (hash >> 2));
   }
   return hash % 256;
}

canonical_original_code:
unsigned int hash(char *str, unsigned int len)
{
   unsigned int hash = 1315423911;
   unsigned int i = 0;
   for(i = 0; i < len; str++, i++)
   {
      hash ^= ((hash << 5) + (*str) + (hash >> 2));
   }
   return hash % 256;
}

variable_types:
str
char *

variable_types:
len
unsigned int

variable_types:
hash
unsigned int

variable_types:
i
unsigned int

return_type: unsigned int


decompiled_code:
__int64 __fastcall file_add(__int64 *a1)
{
char *v1; // r12
int v2; // eax
__int64 v3; // rbx
__int64 v4; // rbx

v1 = (char *)a1[3];
v2 = strlen(v1);
v3 = 56LL * (unsigned int)hash(v1, v2);
pthread_mutex_lock((pthread_mutex_t *)(v3 + filehead + 16));
hlist_add_head(a1, (__int64 *)(v3 + filehead + 8));
v4 = filehead + v3;
++*(_DWORD *)v4;
pthread_mutex_unlock((pthread_mutex_t *)(v4 + 16));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 *a1)
{
char *v1; // r12
int v2; // eax
__int64 v3; // rbx
__int64 v4; // rbx

v1 = (char *)a1[3];
v2 = strlen(v1);
v3 = 56LL * (unsigned int)func8(v1, v2);
pthread_mutex_lock((pthread_mutex_t *)(v3 + filehead + 16));
func0(a1, (__int64 *)(v3 + filehead + 8));
v4 = filehead + v3;
++*(_DWORD *)v4;
pthread_mutex_unlock((pthread_mutex_t *)(v4 + 16));
return 0LL;
}

original_code:
int file_add(file_info *item)
{
 unsigned int hval = hash(item->path, strlen(item->path));
 pthread_mutex_lock(&filehead[hval].lock);
 hlist_add_head(&item->list, &filehead[hval].list);
 filehead[hval].items++;
 pthread_mutex_unlock(&filehead[hval].lock);
 return 0;
}

canonical_original_code:
int file_add(struct file_info *item)
{
 unsigned int hval = hash(item->path, strlen(item->path));
 pthread_mutex_lock(&filehead[hval].lock);
 hlist_add_head(&item->list, &filehead[hval].list);
 filehead[hval].items++;
 pthread_mutex_unlock(&filehead[hval].lock);
 return 0;
}

variable_types:
hval
unsigned int


decompiled_code:
__int64 __fastcall file_del(__int64 a1)
{
char *v1; // r12
int v2; // eax
__int64 v3; // rbx
__int64 v4; // rbx

v1 = *(char **)(a1 + 24);
v2 = strlen(v1);
v3 = 56LL * (unsigned int)hash(v1, v2);
pthread_mutex_lock((pthread_mutex_t *)(v3 + filehead + 16));
hlist_del(a1);
v4 = filehead + v3;
--*(_DWORD *)v4;
pthread_mutex_unlock((pthread_mutex_t *)(v4 + 16));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
char *v1; // r12
int v2; // eax
__int64 v3; // rbx
__int64 v4; // rbx

v1 = *(char **)(a1 + 24);
v2 = strlen(v1);
v3 = 56LL * (unsigned int)func8(v1, v2);
pthread_mutex_lock((pthread_mutex_t *)(v3 + filehead + 16));
func3(a1);
v4 = filehead + v3;
--*(_DWORD *)v4;
pthread_mutex_unlock((pthread_mutex_t *)(v4 + 16));
return 0LL;
}

original_code:
int file_del(file_info *item)
{
 unsigned int hval = hash(item->path, strlen(item->path));
 pthread_mutex_lock(&filehead[hval].lock);
 hlist_del(&item->list);
 filehead[hval].items--;
 pthread_mutex_unlock(&filehead[hval].lock);
 return 0;
}

canonical_original_code:
int file_del(struct file_info *item)
{
 unsigned int hval = hash(item->path, strlen(item->path));
 pthread_mutex_lock(&filehead[hval].lock);
 hlist_del(&item->list);
 filehead[hval].items--;
 pthread_mutex_unlock(&filehead[hval].lock);
 return 0;
}


decompiled_code:
__int64 __fastcall parse_server_cmd(int a1, __int64 a2)
{
const char **v2; // rbx
__int64 v3; // rbp
_BYTE *v4; // rax
const char *v6; // rsi
int v7; // eax

if ( a1 <= 1 )
return 0LL;
v2 = (const char **)(a2 + 16);
v3 = a2 + 16LL * ((unsigned int)(a1 - 2) >> 1) + 32;
do
{
while ( 1 )
{
v4 = *(v2 - 1);
if ( *v4 != 45 )
{
LABEL_4:
usage();
return 0xFFFFFFFFLL;
}
if ( v4[1] == 99 && !v4[2] )
break;
if ( v4[1] != 114 || v4[2] )
goto LABEL_4;
v6 = *v2;
v2 += 2;
strcpy(&meta_root, v6);
if ( (const char **)v3 == v2 )
return 0LL;
}
v7 = atoi(*v2);
if ( (unsigned int)(v7 - 1) > 1 )
goto LABEL_4;
v2 += 2;
file_copies = v7;
}
while ( (const char **)v3 != v2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, __int64 a2)
{
const char **v2; // rbx
__int64 v3; // rbp
_BYTE *v4; // rax
const char *v6; // rsi
int v7; // eax

if ( a1 <= 1 )
return 0LL;
v2 = (const char **)(a2 + 16);
v3 = a2 + 16LL * ((unsigned int)(a1 - 2) >> 1) + 32;
do
{
while ( 1 )
{
v4 = *(v2 - 1);
if ( *v4 != 45 )
{
LABEL_4:
func11();
return 0xFFFFFFFFLL;
}
if ( v4[1] == 99 && !v4[2] )
break;
if ( v4[1] != 114 || v4[2] )
goto LABEL_4;
v6 = *v2;
v2 += 2;
strcpy(&meta_root, v6);
if ( (const char **)v3 == v2 )
return 0LL;
}
v7 = atoi(*v2);
if ( (unsigned int)(v7 - 1) > 1 )
goto LABEL_4;
v2 += 2;
file_copies = v7;
}
while ( (const char **)v3 != v2 );
return 0LL;
}

original_code:
int parse_server_cmd(int argc, char *argv[])
{
 int i;
 int ret;
 int srvflag = 0;
 for(i = 1; i < argc; i += 2) {
  if(!strcmp(argv[i], "-c")) {
   int tmp = atoi(argv[i+1]);
   if(tmp != 1 && tmp != 2) {
    usage();
    return -1;
   }
   file_copies = tmp;
  }
  else if(!strcmp(argv[i], "-r")) {
   strcpy(meta_root, argv[i+1]);
  }
  else {
   usage();
   return -1;
  }
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: ret int

variable_types: srvflag int

variable_types: tmp int


lockfile

decompiled_code:
int __fastcall lockfile(int a1)
{
int v2; // [rsp+0h] [rbp-28h] BYREF
__int64 v3; // [rsp+8h] [rbp-20h]
__int64 v4; // [rsp+10h] [rbp-18h]

v2 = 1;
v3 = 0LL;
v4 = 0LL;
return fcntl(a1, 6, &v2);
}

canonical_decompiled_code:
int __fastcall func13(int a1)
{
int v2; // [rsp+0h] [rbp-28h] BYREF
__int64 v3; // [rsp+8h] [rbp-20h]
__int64 v4; // [rsp+10h] [rbp-18h]

v2 = 1;
v3 = 0LL;
v4 = 0LL;
return fcntl(a1, 6, &v2);
}

original_code:
int lockfile(int fd)
{
    struct flock fl;
    fl.l_type = 1;
    fl.l_start = 0;
    fl.l_whence = 0;
    fl.l_len = 0;
    return(fcntl(fd, 6, &fl));
}

variable_types: fd int

variable_types: struct flock { short l_type; short l_whence; long l_start; long l_len; int l_pid; }


decompiled_code:
__int64 __fastcall already_running(const char *a1)
{
int v1; // eax
int v2; // ebp
__pid_t v3; // eax
size_t v4; // rax
__int64 result; // rax
char v6[24]; // [rsp+0h] [rbp-18h] BYREF

v1 = open(a1, 66, 420LL);
if ( v1 < 0 || (v2 = v1, lockfile(v1) < 0) )
{
printf("dnfs-server is already running!");
result = 0xFFFFFFFFLL;
}
else
{
ftruncate(v2, 0LL);
v3 = getpid();
sprintf(v6, "%ld", v3);
v4 = strlen(v6);
write(v2, v6, v4 + 1);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(const char *a1)
{
int v1; // eax
int v2; // ebp
__pid_t v3; // eax
size_t v4; // rax
__int64 result; // rax
char v6[24]; // [rsp+0h] [rbp-18h] BYREF

v1 = open(a1, 66, 420LL);
if ( v1 < 0 || (v2 = v1, func13(v1) < 0) )
{
printf("dnfs-server is already running!");
result = 0xFFFFFFFFLL;
}
else
{
ftruncate(v2, 0LL);
v3 = getpid();
sprintf(v6, "%ld", v3);
v4 = strlen(v6);
write(v2, v6, v4 + 1);
result = 0LL;
}
return result;
}

original_code:
int already_running(const char *filename)
{
    int fd;
    char buf[16];
    fd = open(filename, 02 | 0100, 0644);
    if (fd < 0) {
        printf("dnfs-server is already running!");
        return -1;
    }
    if (lockfile(fd) < 0) {
        printf("dnfs-server is already running!");
        return -1;
    }
    ftruncate(fd, 0);
    sprintf(buf, "%ld", (long)getpid());
    write(fd, buf, strlen(buf) + 1);
    return 0;
}

canonical_original_code:
int already_running(char *filename)
{
    int fd;
    char buf[16];
    fd = open(filename, 02 | 0100, 0644);
    if (fd < 0) {
        printf("dnfs-server is already running!");
        return -1;
    }
    if (lockfile(fd) < 0) {
        printf("dnfs-server is already running!");
        return -1;
    }
    ftruncate(fd, 0);
    sprintf(buf, "%ld", (long)getpid());
    write(fd, buf, strlen(buf) + 1);
    return 0;
}

variable_types:
filename
char *

variable_types:
buf
char [16]


decompiled_code:
__int64 __fastcall server_init(int a1, __int64 a2)
{
int v2; // er12
pthread_t newthread[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = already_running("/var/run/dnfs-server.pid");
if ( v2 >= 0 )
{
v2 = parse_server_cmd(a1, a2);
if ( v2 >= 0 )
{
v2 = check_directory(&meta_root);
if ( v2 >= 0 )
{
v2 = nodehead_init();
if ( v2 >= 0 )
{
v2 = filehead_init();
if ( v2 >= 0 )
{
v2 = pthread_create(newthread, 0LL, (void *(*)(void *))heart_check, 0LL);
if ( v2 )
{
v2 = -1;
perror("pthread_create error in [osd_init]");
}
else
{
printf("metadata root dierctory: %s\n", &meta_root);
printf("file copy number: %d\n", file_copies);
puts("Metadata server initialized successfully!\n");
}
}
}
}
}
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func15(int a1, __int64 a2)
{
int v2; // er12
pthread_t newthread[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = func14("/var/run/dnfs-server.pid");
if ( v2 >= 0 )
{
v2 = func12(a1, a2);
if ( v2 >= 0 )
{
v2 = check_directory(&meta_root);
if ( v2 >= 0 )
{
v2 = func4();
if ( v2 >= 0 )
{
v2 = func5();
if ( v2 >= 0 )
{
v2 = pthread_create(newthread, 0LL, (void *(*)(void *))heart_check, 0LL);
if ( v2 )
{
v2 = -1;
perror("pthread_create error in [osd_init]");
}
else
{
printf("metadata root dierctory: %s\n", &meta_root);
printf("file copy number: %d\n", file_copies);
puts("Metadata server initialized successfully!\n");
}
}
}
}
}
}
return (unsigned int)v2;
}

original_code:
int server_init(int argc, char *argv[])
{
 int ret = 0;
 ret = already_running("/var/run/dnfs-server.pid");
 do {if((ret) < 0) return ret; } while(0);
 ret = parse_server_cmd(argc, argv);
 do {if((ret) < 0) return ret; } while(0);
 ret = check_directory(meta_root);
 do {if((ret) < 0) return ret; } while(0);
 ret = nodehead_init();
 do {if((ret) < 0) return ret; } while(0);
 ret = filehead_init();
 do {if((ret) < 0) return ret; } while(0);
 pthread_t tid;
 if((ret = pthread_create(&tid, ((void *)0), heart_check, ((void *)0))) != 0) {
  perror("pthread_create error in [osd_init]");
  return -1;
 }
 printf("metadata root dierctory: %s\n", meta_root);
 printf("file copy number: %d\n", file_copies);
 printf("Metadata server initialized successfully!\n\n");
 return 0;
}

canonical_original_code:
int server_init(int argc, char *argv[])
{
 int ret = 0;
 ret = already_running("/var/run/dnfs-server.pid");
 do {if((ret) < 0) return ret; } while(0);
 ret = parse_server_cmd(argc, argv);
 do {if((ret) < 0) return ret; } while(0);
 ret = check_directory(meta_root);
 do {if((ret) < 0) return ret; } while(0);
 ret = nodehead_init();
 do {if((ret) < 0) return ret; } while(0);
 ret = filehead_init();
 do {if((ret) < 0) return ret; } while(0);
 unsigned long tid;
 if((ret = pthread_create(&tid, ((void *)0), heart_check, ((void *)0))) != 0) {
  perror("pthread_create error in [osd_init]");
  return -1;
 }
 printf("metadata root dierctory: %s\n", meta_root);
 printf("file copy number: %d\n", file_copies);
 printf("Metadata server initialized successfully!\n\n");
 return 0;
}

variable_types:
tid
unsigned long


decompiled_code:
int __fastcall get_chunk_path(char *a1, const char *a2)
{
return sprintf(a1, "%s/%s", (const char *)&storage_root, a2);
}

canonical_decompiled_code:
int __fastcall func0(char *a1, const char *a2)
{
return sprintf(a1, "%s/%s", (const char *)&storage_root, a2);
}

original_code:
void get_chunk_path(char *dest, char *src)
{
 sprintf(dest, "%s/%s", storage_root, src);
}

variable_types:
dest
char *

variable_types:
src
char *