delProc

decompiled_code:
void __fastcall delProc(_QWORD *a1)
{
__int64 v1; // rbx
_QWORD *v2; // rbp

v1 = a1[2];
v2 = (_QWORD *)a1[1];
if ( v1 )
{
if ( v2 )
{
*(_QWORD *)(v1 + 8) = v2;
v2[2] = v1;
LABEL_4:
free(a1);
return;
}
free(*(void **)(v1 + 8));
*(_QWORD *)(v1 + 8) = 0LL;
}
else
{
a1 = pProcHead;
if ( !v2 )
goto LABEL_4;
free(pProcHead);
v2[2] = 0LL;
pProcHead = v2;
}
}

canonical_decompiled_code:
void __fastcall func7(_QWORD *a1)
{
__int64 v1; // rbx
_QWORD *v2; // rbp

v1 = a1[2];
v2 = (_QWORD *)a1[1];
if ( v1 )
{
if ( v2 )
{
*(_QWORD *)(v1 + 8) = v2;
v2[2] = v1;
LABEL_4:
free(a1);
return;
}
free(*(void **)(v1 + 8));
*(_QWORD *)(v1 + 8) = 0LL;
}
else
{
a1 = pProcHead;
if ( !v2 )
goto LABEL_4;
free(pProcHead);
v2[2] = 0LL;
pProcHead = v2;
}
}

original_code:
void delProc( UserSv *pUsr )
{
 if( pUsr->pPrev == ((void *)0) && pUsr->pNext == ((void *)0) )
 {
  free( pProcHead );
  pProcHead == ((void *)0);
 }
 else if( pUsr->pPrev == ((void *)0) )
 {
  UserSv *pTmp = pUsr->pNext;
  free( pProcHead );
  pProcHead = pTmp;
  pProcHead->pPrev = ((void *)0);
 }
 else if( pUsr->pNext == ((void *)0) )
 {
  UserSv *pTmp = pUsr->pPrev;
  free( pTmp->pNext );
  pTmp->pNext = ((void *)0);
 }
 else
 {
  pUsr->pPrev->pNext = pUsr->pNext;
  pUsr->pNext->pPrev = pUsr->pPrev;
  free( pUsr );
 }
}

canonical_original_code:
void delProc(struct UserSv *pUsr)
{
 if( pUsr->pPrev == ((void *)0) && pUsr->pNext == ((void *)0) )
 {
  free( pProcHead );
  pProcHead == ((void *)0);
 }
 else if( pUsr->pPrev == ((void *)0) )
 {
  struct UserSv *pTmp = pUsr->pNext;
  free( pProcHead );
  pProcHead = pTmp;
  pProcHead->pPrev = ((void *)0);
 }
 else if( pUsr->pNext == ((void *)0) )
 {
  struct UserSv *pTmp = pUsr->pPrev;
  free( pTmp->pNext );
  pTmp->pNext = ((void *)0);
 }
 else
 {
  pUsr->pPrev->pNext = pUsr->pNext;
  pUsr->pNext->pPrev = pUsr->pPrev;
  free( pUsr );
 }
}

variable_types: struct UserSv { int pidSv; unsigned int uidOwner; struct UserSv *pNext; struct UserSv *pPrev; } *


scanProcs

repo: eichlan/usersv

decompiled_code:
void scanProcs()
{
_QWORD *v0; // rbp
_QWORD *v1; // rbx
int stat_loc[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v0 = pProcHead;
while ( v0 )
{
if ( waitpid(*(_DWORD *)v0, stat_loc, 1) && (stat_loc[0] & 0x7F) == 0 )
{
printf("Process %d for user %d ended.\n", *(unsigned int *)v0, *((unsigned int *)v0 + 1));
v1 = (_QWORD *)v0[1];
delProc(v0);
v0 = v1;
}
else
{
v0 = (_QWORD *)v0[1];
}
}
}

canonical_decompiled_code:
void func8()
{
_QWORD *v0; // rbp
_QWORD *v1; // rbx
int stat_loc[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v0 = pProcHead;
while ( v0 )
{
if ( waitpid(*(_DWORD *)v0, stat_loc, 1) && (stat_loc[0] & 0x7F) == 0 )
{
printf("Process %d for user %d ended.\n", *(unsigned int *)v0, *((unsigned int *)v0 + 1));
v1 = (_QWORD *)v0[1];
func7(v0);
v0 = v1;
}
else
{
v0 = (_QWORD *)v0[1];
}
}
}

original_code:
void scanProcs()
{
 int iStatus;
 UserSv *pCur = pProcHead;
 while( pCur != ((void *)0) )
 {
  if( waitpid( pCur->pidSv, &iStatus, 1 ) )
  {
   if( (((iStatus) & 0x7f) == 0) )
   {
    printf("Process %d for user %d ended.\n", pCur->pidSv, pCur->uidOwner );
    UserSv *pTmp = pCur->pNext;
    delProc( pCur );
    pCur = pTmp;
    continue;
   }
  }
  pCur = pCur->pNext;
 }
}

canonical_original_code:
void scanProcs()
{
 int iStatus;
 struct UserSv *pCur = pProcHead;
 while( pCur != ((void *)0) )
 {
  if( waitpid( pCur->pidSv, &iStatus, 1 ) )
  {
   if( (((iStatus) & 0x7f) == 0) )
   {
    printf("Process %d for user %d ended.\n", pCur->pidSv, pCur->uidOwner );
    struct UserSv *pTmp = pCur->pNext;
    delProc( pCur );
    pCur = pTmp;
    continue;
   }
  }
  pCur = pCur->pNext;
 }
}

variable_types: iStatus int

return_type: void

user_defined_types: struct UserSv { int pidSv; unsigned int uidOwner; struct UserSv *pNext; struct UserSv *pPrev; }


beginRunsv

variable_types:
sUsername
char *

variable_types:
idGroup
unsigned int

variable_types:
buf
char *

variable_types: struct passwd { char *pw_name; char *pw_passwd; unsigned int pw_uid; unsigned int pw_gid; char *pw_gecos; char *pw_dir; char *pw_shell; } *

variable_types: p int

return_type: int


scanUsers

decompiled_code:
int scanUsers()
{
struct group *v0; // rax
struct group *v1; // rbp
int result; // eax
char **v3; // rbx
char *i; // rdi

v0 = getgrnam("svusers");
if ( v0 )
{
v1 = v0;
result = puts("Scanning svusers group...");
v3 = v1->gr_mem;
for ( i = *v3; *v3; i = *v3 )
{
++v3;
result = beginRunsv(i);
}
}
else
{
puts("No group name svusers exists.");
result = 1;
}
return result;
}

canonical_decompiled_code:
int func10()
{
struct group *v0; // rax
struct group *v1; // rbp
int result; // eax
char **v3; // rbx
char *i; // rdi

v0 = getgrnam("svusers");
if ( v0 )
{
v1 = v0;
result = puts("Scanning svusers group...");
v3 = v1->gr_mem;
for ( i = *v3; *v3; i = *v3 )
{
++v3;
result = func9(i);
}
}
else
{
puts("No group name svusers exists.");
result = 1;
}
return result;
}

original_code:
int scanUsers()
{
 struct group *grp;
 char **sName;
 grp = getgrnam( "svusers" );
 if( grp == ((void *)0) )
 {
  printf("No group name " "svusers" " exists.\n");
  return 1;
 }
 printf("Scanning " "svusers" " group...\n");
 for( sName = grp->gr_mem; *sName; sName++ )
 {
  beginRunsv( *sName, grp->gr_gid );
 }
}

variable_types: struct group { char *gr_name; char *gr_passwd; unsigned int gr_gid; char **gr_mem; } *

variable_types:
sName
char **


repo: ejlb/code

decompiled_code:
void __fastcall set_port(int a1)
{
port_arg = a1;
}

canonical_decompiled_code:
void __fastcall func0(int a1)
{
port_arg = a1;
}

original_code:
void
set_port (int arg)
{
    port_arg = arg;
}

canonical_original_code:
void set_port(int arg)
{
    port_arg = arg;
}

variable_types: arg int


decompiled_code:
__int64 get_port()
{
return (unsigned int)port_arg;
}

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

original_code:
int
get_port (void)
{
    return port_arg;
}

canonical_original_code:
int get_port()
{
    return port_arg;
}


decompiled_code:
void __fastcall set_host(int a1)
{
host_arg = a1;
}

canonical_decompiled_code:
void __fastcall func2(int a1)
{
host_arg = a1;
}

original_code:
void
set_host (int arg)
{
    host_arg = arg;
}

canonical_original_code:
void set_host(int arg)
{
    host_arg = arg;
}


decompiled_code:
__int64 get_host()
{
return (unsigned int)host_arg;
}

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

original_code:
int
get_host (void)
{
    return host_arg;
}

canonical_original_code:
int get_host()
{
    return host_arg;
}


decompiled_code:
void __fastcall set_plog(int a1)
{
plog_arg = a1;
}

canonical_decompiled_code:
void __fastcall func4(int a1)
{
plog_arg = a1;
}

original_code:
void
set_plog (int arg)
{
    plog_arg = arg;
}

canonical_original_code:
void set_plog(int arg)
{
    plog_arg = arg;
}


decompiled_code:
__int64 get_plog()
{
return (unsigned int)plog_arg;
}

canonical_decompiled_code:
__int64 func5()
{
return (unsigned int)plog_arg;
}

original_code:
int
get_plog (void)
{
    return plog_arg;
}

canonical_original_code:
int get_plog()
{
    return plog_arg;
}


decompiled_code:
void __fastcall set_payload(int a1)
{
payload_arg = a1;
}

canonical_decompiled_code:
void __fastcall func6(int a1)
{
payload_arg = a1;
}

original_code:
void
set_payload (int arg)
{
    payload_arg = arg;
}

canonical_original_code:
void set_payload(int arg)
{
    payload_arg = arg;
}


decompiled_code:
__int64 get_payload()
{
return (unsigned int)payload_arg;
}

canonical_decompiled_code:
__int64 func7()
{
return (unsigned int)payload_arg;
}

original_code:
int
get_payload (void)
{
    return payload_arg;
}

canonical_original_code:
int get_payload()
{
    return payload_arg;
}


decompiled_code:
void __fastcall set_verbose(int a1)
{
verbose_arg = a1;
set_payload(a1);
}

canonical_decompiled_code:
void __fastcall func8(int a1)
{
verbose_arg = a1;
func6(a1);
}

original_code:
void
set_verbose (int arg)
{
    verbose_arg = arg;
    set_payload (arg);
}

canonical_original_code:
void set_verbose(int arg)
{
    verbose_arg = arg;
    set_payload (arg);
}


decompiled_code:
__int64 get_verbose()
{
return (unsigned int)verbose_arg;
}

canonical_decompiled_code:
__int64 func9()
{
return (unsigned int)verbose_arg;
}

original_code:
int
get_verbose (void)
{
    return verbose_arg;
}

canonical_original_code:
int get_verbose()
{
    return verbose_arg;
}


decompiled_code:
void __fastcall set_pass_plugin(int a1)
{
pass_plugin_arg = a1;
set_payload(a1);
}

canonical_decompiled_code:
void __fastcall func10(int a1)
{
pass_plugin_arg = a1;
func6(a1);
}

original_code:
void
set_pass_plugin (int arg)
{
    pass_plugin_arg = arg;
    set_payload (arg);
}

canonical_original_code:
void set_pass_plugin(int arg)
{
    pass_plugin_arg = arg;
    set_payload (arg);
}


decompiled_code:
__int64 get_pass_plugin()
{
return (unsigned int)pass_plugin_arg;
}

canonical_decompiled_code:
__int64 func11()
{
return (unsigned int)pass_plugin_arg;
}

original_code:
int
get_pass_plugin (void)
{
    return pass_plugin_arg;
}

canonical_original_code:
int get_pass_plugin()
{
    return pass_plugin_arg;
}


decompiled_code:
void __fastcall set_http_pass_plugin(int a1)
{
http_pass_plugin_arg = a1;
set_payload(a1);
}

canonical_decompiled_code:
void __fastcall func12(int a1)
{
http_pass_plugin_arg = a1;
func6(a1);
}

original_code:
void
set_http_pass_plugin (int arg)
{
    http_pass_plugin_arg = arg;
    set_payload (arg);
}

canonical_original_code:
void set_http_pass_plugin(int arg)
{
    http_pass_plugin_arg = arg;
    set_payload (arg);
}


decompiled_code:
__int64 get_http_pass_plugin()
{
return (unsigned int)http_pass_plugin_arg;
}

canonical_decompiled_code:
__int64 func13()
{
return (unsigned int)http_pass_plugin_arg;
}

original_code:
int
get_http_pass_plugin (void)
{
    return http_pass_plugin_arg;
}

canonical_original_code:
int get_http_pass_plugin()
{
    return http_pass_plugin_arg;
}


decompiled_code:
void getset_init()
{
set_port(1);
set_verbose(0);
set_host(0);
set_plog(0);
set_pass_plugin(0);
set_http_pass_plugin(0);
}

original_code:
void
getset_init (void)
{
    set_port (1);
    set_verbose (0);
    set_host (0);
    set_plog (0);
    set_pass_plugin (0);
    set_http_pass_plugin (0);
}

canonical_original_code:
void getset_init()
{
    set_port (1);
    set_verbose (0);
    set_host (0);
    set_plog (0);
    set_pass_plugin (0);
    set_http_pass_plugin (0);
}


decompiled_code:
__int64 print_tcp()
{
unsigned int v0; // ebp
int v1; // eax
__int64 v2; // rdx
int v3; // ebx
struct in_addr v4; // er12
struct in_addr v5; // er14
__int64 i; // rax
struct tm *v7; // r13
unsigned int v8; // er15
char *v9; // rax
char *v10; // rax
const char *v11; // rax
__int64 v12; // rdx
unsigned int v13; // er15
unsigned __int16 v14; // r13
char *v15; // rax
const char *v16; // rsi
char *v17; // rax
const char *v18; // rsi
__int64 v19; // rdx
__int64 v20; // rbx
__int64 v21; // rdx
unsigned int v22; // eax
__int64 v23; // rdx
__int64 v24; // r9
unsigned __int16 v25; // ax
__int64 v26; // rcx
unsigned __int16 v27; // ax
struct ether_addr addr; // [rsp+Ch] [rbp-5Ch] BYREF
struct ether_addr v30; // [rsp+12h] [rbp-56h] BYREF
time_t timer; // [rsp+18h] [rbp-50h] BYREF
struct timeval tv; // [rsp+20h] [rbp-48h] BYREF

v0 = get_port();
v1 = get_host();
v2 = eptr;
v3 = v1;
v4.s_addr = *(_DWORD *)(qword_4F8 + 16LL);
v5.s_addr = *(_DWORD *)(qword_4F8 + 12LL);
for ( i = 0LL; i != 7; ++i )
{
addr.ether_addr_octet[i] = *(_BYTE *)(v2 + i + 6);
v30.ether_addr_octet[i] = *(_BYTE *)(v2 + i);
}
time(0LL);
v7 = gmtime(&timer);
gettimeofday(&tv, 0LL);
v8 = (unsigned __int16)_bswap_16(*(_WORD *)(eptr + 12LL));
nk_printf("%d:%d:%d-%ld ", (unsigned int)v7->tm_hour, (unsigned int)v7->tm_min, (unsigned int)v7->tm_sec, tv.tv_usec);
v9 = ether_ntoa(&addr);
print_mac(v9);
nk_printf("-> ");
v10 = ether_ntoa(&v30);
print_mac(v10);
LOWORD(v7) = _bswap_16(*(_WORD *)(qword_4F8 + 2LL));
v11 = (const char *)convert_type(v8);
nk_printf(" Type:0x%X [%s] Len:%d ", v8, v11, (unsigned __int16)v7);
v13 = (unsigned __int16)_bswap_16(*tcp);
v14 = _bswap_16(*(_WORD *)(v12 + 2));
v15 = inet_ntoa(v5);
if ( v3 )
v15 = (char *)nk_resolve(v15, v15);
nk_printf("%s:", v15);
v16 = (const char *)convert_port(v13, v0, "tcp");
if ( v16 )
nk_printf("%s", v16);
else
nk_printf("%d", v13);
nk_printf(" -> ");
v17 = inet_ntoa(v4);
if ( v3 )
v17 = (char *)nk_resolve(v17, v17);
nk_printf("%s:", v17);
v18 = (const char *)convert_port(v14, v0, "tcp");
if ( v18 )
nk_printf("%s ", v18);
else
nk_printf("%d ", v14);
v20 = (unsigned __int16)_bswap_16(*(_WORD *)(tcp + 14LL));
_bswap_32(*(_DWORD *)(v19 + 8));
v22 = _bswap_32(*(_DWORD *)(v21 + 4));
LODWORD(v23) = *(char *)(v23 + 13);
nk_printf(
" TCP Flags:[%c%c%c%c%c%c%c%c] Seq:0x%X AckSeq:0x%X Window:0x%X ",
(v23 & 0x20) == 0 ? 45 : 85,
(v23 & 0x10) == 0 ? 45 : 65,
(v23 & 8) == 0 ? 45 : 80,
(v23 & 4) == 0 ? 45 : 82,
(v23 & 2) == 0 ? 45 : 83,
(v23 & 1) == 0 ? 45 : 70,
(v23 & 0x40) == 0 ? 45 : 88,
(((int)v23 >> 31) & 0x2Cu) + 45,
v22,
v24,
v20);
v25 = _bswap_16(*(_WORD *)(qword_4F8 + 4LL));
nk_printf("TOS:0x%X ID:%d TTL:%d\n\n", *(unsigned __int8 *)(v26 + 1), v25, *(unsigned __int8 *)(v26 + 8));
v27 = _bswap_16(*(_WORD *)(qword_4F8 + 2LL));
return print_payload(payload, (unsigned int)v27 - 40);
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int v0; // ebp
int v1; // eax
__int64 v2; // rdx
int v3; // ebx
struct in_addr v4; // er12
struct in_addr v5; // er14
__int64 i; // rax
struct tm *v7; // r13
unsigned int v8; // er15
char *v9; // rax
char *v10; // rax
const char *v11; // rax
__int64 v12; // rdx
unsigned int v13; // er15
unsigned __int16 v14; // r13
char *v15; // rax
const char *v16; // rsi
char *v17; // rax
const char *v18; // rsi
__int64 v19; // rdx
__int64 v20; // rbx
__int64 v21; // rdx
unsigned int v22; // eax
__int64 v23; // rdx
__int64 v24; // r9
unsigned __int16 v25; // ax
__int64 v26; // rcx
unsigned __int16 v27; // ax
struct ether_addr addr; // [rsp+Ch] [rbp-5Ch] BYREF
struct ether_addr v30; // [rsp+12h] [rbp-56h] BYREF
time_t timer; // [rsp+18h] [rbp-50h] BYREF
struct timeval tv; // [rsp+20h] [rbp-48h] BYREF

v0 = get_port();
v1 = get_host();
v2 = eptr;
v3 = v1;
v4.s_addr = *(_DWORD *)(qword_4F8 + 16LL);
v5.s_addr = *(_DWORD *)(qword_4F8 + 12LL);
for ( i = 0LL; i != 7; ++i )
{
addr.ether_addr_octet[i] = *(_BYTE *)(v2 + i + 6);
v30.ether_addr_octet[i] = *(_BYTE *)(v2 + i);
}
time(0LL);
v7 = gmtime(&timer);
gettimeofday(&tv, 0LL);
v8 = (unsigned __int16)func1(*(_WORD *)(eptr + 12LL));
nk_printf("%d:%d:%d-%ld ", (unsigned int)v7->tm_hour, (unsigned int)v7->tm_min, (unsigned int)v7->tm_sec, tv.tv_usec);
v9 = ether_ntoa(&addr);
print_mac(v9);
nk_printf("-> ");
v10 = ether_ntoa(&v30);
print_mac(v10);
LOWORD(v7) = func1(*(_WORD *)(qword_4F8 + 2LL));
v11 = (const char *)convert_type(v8);
nk_printf(" Type:0x%X [%s] Len:%d ", v8, v11, (unsigned __int16)v7);
v13 = (unsigned __int16)func1(*tcp);
v14 = func1(*(_WORD *)(v12 + 2));
v15 = inet_ntoa(v5);
if ( v3 )
v15 = (char *)nk_resolve(v15, v15);
nk_printf("%s:", v15);
v16 = (const char *)convert_port(v13, v0, "tcp");
if ( v16 )
nk_printf("%s", v16);
else
nk_printf("%d", v13);
nk_printf(" -> ");
v17 = inet_ntoa(v4);
if ( v3 )
v17 = (char *)nk_resolve(v17, v17);
nk_printf("%s:", v17);
v18 = (const char *)convert_port(v14, v0, "tcp");
if ( v18 )
nk_printf("%s ", v18);
else
nk_printf("%d ", v14);
v20 = (unsigned __int16)func1(*(_WORD *)(tcp + 14LL));
func0(*(_DWORD *)(v19 + 8));
v22 = func0(*(_DWORD *)(v21 + 4));
LODWORD(v23) = *(char *)(v23 + 13);
nk_printf(
" TCP Flags:[%c%c%c%c%c%c%c%c] Seq:0x%X AckSeq:0x%X Window:0x%X ",
(v23 & 0x20) == 0 ? 45 : 85,
(v23 & 0x10) == 0 ? 45 : 65,
(v23 & 8) == 0 ? 45 : 80,
(v23 & 4) == 0 ? 45 : 82,
(v23 & 2) == 0 ? 45 : 83,
(v23 & 1) == 0 ? 45 : 70,
(v23 & 0x40) == 0 ? 45 : 88,
(((int)v23 >> 31) & 0x2Cu) + 45,
v22,
v24,
v20);
v25 = func1(*(_WORD *)(qword_4F8 + 4LL));
nk_printf("TOS:0x%X ID:%d TTL:%d\n\n", *(unsigned __int8 *)(v26 + 1), v25, *(unsigned __int8 *)(v26 + 8));
v27 = func1(*(_WORD *)(qword_4F8 + 2LL));
return print_payload(payload, (unsigned int)v27 - 40);
}

original_code:
void
print_tcp ()
{
    struct in_addr d_addr, s_addr;
    extern struct iphdr *ip;
    extern struct tcphdr *tcp;
    extern char *payload;
    extern struct ether_header *eptr;
    char *daddr = "";
    char *saddr = "";
    char *port_name;
    time_t current;
    u_short s_port = 0;
    u_short d_port = 0;
    int i;
    int payload_len;
    int type;
    struct ether_addr smac_addr;
    struct ether_addr dmac_addr;
    struct timeval tv;
    struct tm *t;
    int op_port;
    int op_host;
    op_port = get_port ();
    op_host = get_host ();
    d_addr.s_addr = ip->daddr;
    s_addr.s_addr = ip->saddr;
    for (i = 0; i <= 6; i++) {
        smac_addr.ether_addr_octet[i] = eptr->ether_shost[i];
        dmac_addr.ether_addr_octet[i] = eptr->ether_dhost[i];
    }
    current - time (((void *)0));
    t = gmtime (&current);
    gettimeofday (&tv, ((void *)0));
    type = ntohs (eptr->ether_type);
    nk_printf ("%d:%d:%d-%ld  ", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec);
    saddr = ether_ntoa (&smac_addr);
    print_mac (saddr);
    nk_printf ("-> ");
    daddr = ether_ntoa (&dmac_addr);
    print_mac (daddr);
    nk_printf (" Type:0x%X [%s]  Len:%d  ", type, convert_type (type), ntohs (ip->tot_len));
    s_port = ntohs (tcp->source);
    d_port = ntohs (tcp->dest);
    saddr = inet_ntoa (s_addr);
    if (op_host)
        nk_printf ("%s:", nk_resolve (saddr));
    else
        nk_printf ("%s:", saddr);
    port_name = convert_port (s_port, op_port, "tcp");
    if (port_name != ((void *)0))
        nk_printf ("%s", port_name);
    else
        nk_printf ("%d", s_port);
    nk_printf (" -> ");
    daddr = inet_ntoa (d_addr);
    if (op_host)
        nk_printf ("%s:", nk_resolve (daddr));
    else
        nk_printf ("%s:", daddr);
    port_name = convert_port (d_port, op_port, "tcp");
    if (port_name != ((void *)0))
        nk_printf ("%s ", port_name);
    else
        nk_printf ("%d ", d_port);
    nk_printf
        (" TCP  Flags:[%c%c%c%c%c%c%c%c] Seq:0x%X  AckSeq:0x%X  Window:0x%X  ",
         (tcp->urg == 1) ? 'U' : '-', (tcp->ack == 1) ? 'A' : '-',
         (tcp->psh == 1) ? 'P' : '-', (tcp->rst == 1) ? 'R' : '-',
         (tcp->syn == 1) ? 'S' : '-', (tcp->fin == 1) ? 'F' : '-',
         (tcp->ece == 1) ? 'X' : '-', (tcp->cwr == 1) ? 'Y' : '-',
         ntohl (tcp->seq), ntohl (tcp->ack_seq), ntohs (tcp->window));
    nk_printf ("TOS:0x%X  ID:%d  TTL:%d\n\n", ip->tos, ntohs (ip->id), ip->ttl);
    payload_len = (ntohs (ip->tot_len) - sizeof(struct tcphdr) - sizeof(struct iphdr));
    print_payload (payload, payload_len, ip, d_port);
    return;
}

canonical_original_code:
void print_tcp()
{
    struct in_addr d_addr; struct in_addr s_addr;
    extern struct iphdr *ip;
    extern struct tcphdr *tcp;
    extern char *payload;
    extern struct ether_header *eptr;
    char *daddr = "";
    char *saddr = "";
    char *port_name;
    long current;
    unsigned short s_port = 0;
    unsigned short d_port = 0;
    int i;
    int payload_len;
    int type;
    struct ether_addr smac_addr;
    struct ether_addr dmac_addr;
    struct timeval tv;
    struct tm *t;
    int op_port;
    int op_host;
    op_port = get_port ();
    op_host = get_host ();
    d_addr.s_addr = ip->daddr;
    s_addr.s_addr = ip->saddr;
    for (i = 0; i <= 6; i++) {
        smac_addr.ether_addr_octet[i] = eptr->ether_shost[i];
        dmac_addr.ether_addr_octet[i] = eptr->ether_dhost[i];
    }
    current - time (((void *)0));
    t = gmtime (&current);
    gettimeofday (&tv, ((void *)0));
    type = ntohs (eptr->ether_type);
    nk_printf ("%d:%d:%d-%ld  ", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec);
    saddr = ether_ntoa (&smac_addr);
    print_mac (saddr);
    nk_printf ("-> ");
    daddr = ether_ntoa (&dmac_addr);
    print_mac (daddr);
    nk_printf (" Type:0x%X [%s]  Len:%d  ", type, convert_type (type), ntohs (ip->tot_len));
    s_port = ntohs (tcp->source);
    d_port = ntohs (tcp->dest);
    saddr = inet_ntoa (s_addr);
    if (op_host)
        nk_printf ("%s:", nk_resolve (saddr));
    else
        nk_printf ("%s:", saddr);
    port_name = convert_port (s_port, op_port, "tcp");
    if (port_name != ((void *)0))
        nk_printf ("%s", port_name);
    else
        nk_printf ("%d", s_port);
    nk_printf (" -> ");
    daddr = inet_ntoa (d_addr);
    if (op_host)
        nk_printf ("%s:", nk_resolve (daddr));
    else
        nk_printf ("%s:", daddr);
    port_name = convert_port (d_port, op_port, "tcp");
    if (port_name != ((void *)0))
        nk_printf ("%s ", port_name);
    else
        nk_printf ("%d ", d_port);
    nk_printf
        (" TCP  Flags:[%c%c%c%c%c%c%c%c] Seq:0x%X  AckSeq:0x%X  Window:0x%X  ",
         (tcp->urg == 1) ? 'U' : '-', (tcp->ack == 1) ? 'A' : '-',
         (tcp->psh == 1) ? 'P' : '-', (tcp->rst == 1) ? 'R' : '-',
         (tcp->syn == 1) ? 'S' : '-', (tcp->fin == 1) ? 'F' : '-',
         (tcp->ece == 1) ? 'X' : '-', (tcp->cwr == 1) ? 'Y' : '-',
         ntohl (tcp->seq), ntohl (tcp->ack_seq), ntohs (tcp->window));
    nk_printf ("TOS:0x%X  ID:%d  TTL:%d\n\n", ip->tos, ntohs (ip->id), ip->ttl);
    payload_len = (ntohs (ip->tot_len) - sizeof(struct tcphdr) - sizeof(struct iphdr));
    print_payload (payload, payload_len, ip, d_port);
    return;
}

variable_types: struct iphdr { unsigned char ihl; unsigned char tos; unsigned short tot_len; unsigned short id; unsigned short frag_off; unsigned char ttl; unsigned char protocol; unsigned short check; unsigned int saddr; unsigned int daddr; } *

variable_types: struct tcphdr { unsigned short source; unsigned short dest; unsigned int seq; unsigned int ack_seq; unsigned short res1; unsigned short window; unsigned short check; unsigned short urg_ptr; } *

variable_types:
payload
char *

variable_types: struct ether_header { unsigned char ether_dhost[6]; unsigned char ether_shost[6]; unsigned short ether_type; } *

variable_types:
daddr
char *

variable_types:
saddr
char *

variable_types: current long

variable_types: i int

variable_types: type int

variable_types: struct ether_addr { unsigned char ether_addr_octet[6]; }

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

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


decompiled_code:
__int64 print_arp()
{
int v0; // ebp
unsigned int *v1; // rdx
int v2; // ebx
char *v3; // rax
__int64 v5; // rcx
__int64 i; // rax
char *v7; // r12
unsigned __int16 v8; // ax
const char *v9; // rax
char *v10; // rax
const char *v11; // r12
const char *v12; // r12
unsigned __int16 v13; // ax
const char *v14; // rax
char *v15; // rax
char *v16; // rax
unsigned __int16 v17; // ax
const char *v18; // rax
struct ether_addr addr; // [rsp+2h] [rbp-36h] BYREF
time_t timer; // [rsp+8h] [rbp-30h] BYREF
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF

v0 = get_host();
timer = time(0LL);
gettimeofday(&tv, 0LL);
gmtime(&timer);
v2 = (unsigned __int16)_bswap_16(*(_WORD *)(arp + 6LL));
nk_printf("%d:%d:%d-%ld ", v1[2], v1[1], *v1, tv.tv_usec);
v3 = inet_ntoa(*(struct in_addr *)(arp + 24LL));
if ( v2 == 1 )
{
v11 = v3;
if ( v0 )
{
v12 = (const char *)nk_resolve(v3);
v13 = _bswap_16(*(_WORD *)(arp + 6LL));
v14 = (const char *)convert_arp(v13);
nk_printf("%s who-has %s ", v14, v12);
v15 = inet_ntoa(*(struct in_addr *)(arp + 14LL));
v16 = (char *)nk_resolve(v15);
}
else
{
v17 = _bswap_16(*(_WORD *)(arp + 6LL));
v18 = (const char *)convert_arp(v17);
nk_printf("%s who-has %s ", v18, v11);
v16 = inet_ntoa(*(struct in_addr *)(arp + 14LL));
}
nk_printf("tell %s", v16);
}
else if ( v2 == 2 )
{
v5 = eptr;
for ( i = 0LL; i != 7; ++i )
addr.ether_addr_octet[i] = *(_BYTE *)(v5 + i + 6);
v7 = inet_ntoa(*(struct in_addr *)(arp + 14LL));
v8 = _bswap_16(*(_WORD *)(arp + 6LL));
v9 = (const char *)convert_arp(v8);
nk_printf("%s %s is-at ", v9, v7);
v10 = ether_ntoa(&addr);
print_mac(v10);
}
return nk_printf("\n\n");
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // ebp
unsigned int *v1; // rdx
int v2; // ebx
char *v3; // rax
__int64 v5; // rcx
__int64 i; // rax
char *v7; // r12
unsigned __int16 v8; // ax
const char *v9; // rax
char *v10; // rax
const char *v11; // r12
const char *v12; // r12
unsigned __int16 v13; // ax
const char *v14; // rax
char *v15; // rax
char *v16; // rax
unsigned __int16 v17; // ax
const char *v18; // rax
struct ether_addr addr; // [rsp+2h] [rbp-36h] BYREF
time_t timer; // [rsp+8h] [rbp-30h] BYREF
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF

v0 = get_host();
timer = time(0LL);
gettimeofday(&tv, 0LL);
gmtime(&timer);
v2 = (unsigned __int16)func0(*(_WORD *)(arp + 6LL));
nk_printf("%d:%d:%d-%ld ", v1[2], v1[1], *v1, tv.tv_usec);
v3 = inet_ntoa(*(struct in_addr *)(arp + 24LL));
if ( v2 == 1 )
{
v11 = v3;
if ( v0 )
{
v12 = (const char *)nk_resolve(v3);
v13 = func0(*(_WORD *)(arp + 6LL));
v14 = (const char *)convert_arp(v13);
nk_printf("%s who-has %s ", v14, v12);
v15 = inet_ntoa(*(struct in_addr *)(arp + 14LL));
v16 = (char *)nk_resolve(v15);
}
else
{
v17 = func0(*(_WORD *)(arp + 6LL));
v18 = (const char *)convert_arp(v17);
nk_printf("%s who-has %s ", v18, v11);
v16 = inet_ntoa(*(struct in_addr *)(arp + 14LL));
}
nk_printf("tell %s", v16);
}
else if ( v2 == 2 )
{
v5 = eptr;
for ( i = 0LL; i != 7; ++i )
addr.ether_addr_octet[i] = *(_BYTE *)(v5 + i + 6);
v7 = inet_ntoa(*(struct in_addr *)(arp + 14LL));
v8 = func0(*(_WORD *)(arp + 6LL));
v9 = (const char *)convert_arp(v8);
nk_printf("%s %s is-at ", v9, v7);
v10 = ether_ntoa(&addr);
print_mac(v10);
}
return nk_printf("\n\n");
}

original_code:
void
print_arp ()
{
    struct in_addr d_addr, s_addr;
    extern struct arphd *arp;
    extern struct ether_header *eptr;
    char *daddr, *saddr;
    time_t current;
    int type, i;
    struct timeval tv;
    struct tm *t;
    struct ether_addr smac_addr;
    int op_host = get_host ();
    current = time (((void *)0));
    gettimeofday (&tv, ((void *)0));
    t = gmtime (&current);
    type = ntohs (arp->ar_op);
    nk_printf ("%d:%d:%d-%ld  ", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec);
    memcpy (&d_addr.s_addr, arp->__ar_tip, sizeof (arp->__ar_tip));
    daddr = inet_ntoa (d_addr);
    if (type == 1) {
        if (op_host) {
            nk_printf ("%s who-has %s ", convert_arp (ntohs (arp->ar_op)), nk_resolve (daddr));
            memcpy (&s_addr.s_addr, arp->__ar_sip, sizeof (arp->__ar_sip));
            saddr = inet_ntoa (s_addr);
            nk_printf ("tell %s", nk_resolve (saddr));
        } else {
            nk_printf ("%s who-has %s ", convert_arp (ntohs (arp->ar_op)), daddr);
            memcpy (&s_addr.s_addr, arp->__ar_sip, sizeof (arp->__ar_sip));
            saddr = inet_ntoa (s_addr);
            nk_printf ("tell %s", saddr);
        }
    }
    else if (type == 2) {
        for (i = 0; i <= 6; i++)
            smac_addr.ether_addr_octet[i] = eptr->ether_shost[i];
        memcpy (&s_addr.s_addr, arp->__ar_sip, sizeof (arp->__ar_sip));
        saddr = inet_ntoa (s_addr);
        nk_printf ("%s %s is-at ", convert_arp (ntohs (arp->ar_op)), saddr);
        saddr = ether_ntoa (&smac_addr);
        print_mac (saddr);
    }
    nk_printf ("\n\n");
    return;
}

canonical_original_code:
void print_arp()
{
    struct in_addr d_addr; struct in_addr s_addr;
    extern struct arphd *arp;
    extern struct ether_header *eptr;
    char *daddr; char *saddr;
    long current;
    int type; int i;
    struct timeval tv;
    struct tm *t;
    struct ether_addr smac_addr;
    int op_host = get_host ();
    current = time (((void *)0));
    gettimeofday (&tv, ((void *)0));
    t = gmtime (&current);
    type = ntohs (arp->ar_op);
    nk_printf ("%d:%d:%d-%ld  ", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec);
    memcpy (&d_addr.s_addr, arp->__ar_tip, sizeof (arp->__ar_tip));
    daddr = inet_ntoa (d_addr);
    if (type == 1) {
        if (op_host) {
            nk_printf ("%s who-has %s ", convert_arp (ntohs (arp->ar_op)), nk_resolve (daddr));
            memcpy (&s_addr.s_addr, arp->__ar_sip, sizeof (arp->__ar_sip));
            saddr = inet_ntoa (s_addr);
            nk_printf ("tell %s", nk_resolve (saddr));
        } else {
            nk_printf ("%s who-has %s ", convert_arp (ntohs (arp->ar_op)), daddr);
            memcpy (&s_addr.s_addr, arp->__ar_sip, sizeof (arp->__ar_sip));
            saddr = inet_ntoa (s_addr);
            nk_printf ("tell %s", saddr);
        }
    }
    else if (type == 2) {
        for (i = 0; i <= 6; i++)
            smac_addr.ether_addr_octet[i] = eptr->ether_shost[i];
        memcpy (&s_addr.s_addr, arp->__ar_sip, sizeof (arp->__ar_sip));
        saddr = inet_ntoa (s_addr);
        nk_printf ("%s %s is-at ", convert_arp (ntohs (arp->ar_op)), saddr);
        saddr = ether_ntoa (&smac_addr);
        print_mac (saddr);
    }
    nk_printf ("\n\n");
    return;
}

variable_types: struct arphd { unsigned short ar_hrd; unsigned short ar_pro; unsigned char ar_hln; unsigned char ar_pln; unsigned short ar_op; unsigned char __ar_sha[6]; unsigned char __ar_sip[4]; unsigned char __ar_tha[6]; unsigned char __ar_tip[4]; } *

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

user_defined_types: struct ether_addr { unsigned char ether_addr_octet[6]; }

user_defined_types: struct ether_header { unsigned char ether_dhost[6]; unsigned char ether_shost[6]; unsigned short ether_type; }

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


decompiled_code:
__int64 __fastcall nk_process_packet(__int64 a1, __int64 a2, __int64 a3)
{
__int16 v3; // di
__int16 v4; // ax
__int64 v5; // rdx
__int64 v6; // rcx
char v7; // al
__int64 result; // rax

v3 = *(_WORD *)(a3 + 12);
eptr = a3;
payload = 0LL;
v4 = _bswap_16(v3);
if ( v4 == -32715 || v4 == 2054 )
{
payload = v5 + 42;
arp = v6;
print_arp();
result = 0LL;
}
else
{
unk_110 = v6;
v7 = *(_BYTE *)(v5 + 23);
if ( v7 == 6 )
{
payload = v5 + 54;
tcp = v5 + 34;
print_tcp();
result = 0LL;
}
else if ( v7 == 17 )
{
payload = v5 + 42;
udp = v5 + 34;
print_udp();
result = 0LL;
}
else
{
if ( v7 == 1 )
{
payload = v5 + 42;
icmp = v5 + 34;
print_icmp();
}
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
__int16 v3; // di
__int16 v4; // ax
__int64 v5; // rdx
__int64 v6; // rcx
char v7; // al
__int64 result; // rax

v3 = *(_WORD *)(a3 + 12);
eptr = a3;
payload = 0LL;
v4 = func0(v3);
if ( v4 == -32715 || v4 == 2054 )
{
payload = v5 + 42;
arp = v6;
print_arp();
result = 0LL;
}
else
{
unk_110 = v6;
v7 = *(_BYTE *)(v5 + 23);
if ( v7 == 6 )
{
payload = v5 + 54;
tcp = v5 + 34;
print_tcp();
result = 0LL;
}
else if ( v7 == 17 )
{
payload = v5 + 42;
udp = v5 + 34;
print_udp();
result = 0LL;
}
else
{
if ( v7 == 1 )
{
payload = v5 + 42;
icmp = v5 + 34;
print_icmp();
}
result = 0LL;
}
}
return result;
}

original_code:
void *
nk_process_packet (u_char * arg, const struct pcap_pkthdr *pkthdr, u_char * packet)
{
    int protocol;
    char *buf;
    eptr = (struct ether_header *) packet;
    payload = ((void *)0);
    if (ntohs (eptr->ether_type) == 0x0806 || ntohs (eptr->ether_type) == 0x8035) {
        buf = (packet + sizeof(struct ether_header));
        protocol = -1;
    } else {
        ip = (struct iphdr *) (packet + sizeof(struct ether_header));
        buf = (packet + sizeof(struct ether_header) + sizeof(struct iphdr));
        protocol = ip->protocol;
    }
    switch (protocol) {
    case IPPROTO_TCP:
        {
            tcp = (struct tcphdr *) buf;
            payload = (buf + sizeof(struct tcphdr));
            print_tcp ();
            break;
        }
    case IPPROTO_UDP:
        {
            udp = (struct udphdr *) buf;
            payload = (buf + sizeof(struct udphdr));
            print_udp ();
            break;
        }
    case IPPROTO_ICMP:
        {
            icmp = (struct icmphdr *) buf;
            payload = (buf + sizeof(struct icmphdr));
            print_icmp ();
            break;
        }
    case -1:
        {
            arp = (struct arphd *) buf;
            payload = (buf + sizeof(struct arphd));
            print_arp ();
            break;
        }
    }
    return 0;
}

canonical_original_code:
void *nk_process_packet(unsigned char *arg, struct pcap_pkthdr *pkthdr, unsigned char *packet)
{
    int protocol;
    char *buf;
    eptr = (struct ether_header *) packet;
    payload = ((void *)0);
    if (ntohs (eptr->ether_type) == 0x0806 || ntohs (eptr->ether_type) == 0x8035) {
        buf = (packet + sizeof(struct ether_header));
        protocol = -1;
    } else {
        ip = (struct iphdr *) (packet + sizeof(struct ether_header));
        buf = (packet + sizeof(struct ether_header) + sizeof(struct iphdr));
        protocol = ip->protocol;
    }
    switch (protocol) {
    case IPPROTO_TCP:
        {
            tcp = (struct tcphdr *) buf;
            payload = (buf + sizeof(struct tcphdr));
            print_tcp ();
            break;
        }
    case IPPROTO_UDP:
        {
            udp = (struct udphdr *) buf;
            payload = (buf + sizeof(struct udphdr));
            print_udp ();
            break;
        }
    case IPPROTO_ICMP:
        {
            icmp = (struct icmphdr *) buf;
            payload = (buf + sizeof(struct icmphdr));
            print_icmp ();
            break;
        }
    case -1:
        {
            arp = (struct arphd *) buf;
            payload = (buf + sizeof(struct arphd));
            print_arp ();
            break;
        }
    }
    return 0;
}

variable_types:
arg
unsigned char *

variable_types: struct pcap_pkthdr { struct timeval { long tv_sec; long tv_usec; } ts; unsigned int caplen; unsigned int len; } *

variable_types:
packet
unsigned char *

variable_types: protocol int

variable_types:
buf
char *

return_type: void *

user_defined_types: struct iphdr { unsigned char ihl; unsigned char tos; unsigned short tot_len; unsigned short id; unsigned short frag_off; unsigned char ttl; unsigned char protocol; unsigned short check; unsigned int saddr; unsigned int daddr; }

user_defined_types: struct tcphdr { unsigned short source; unsigned short dest; unsigned int seq; unsigned int ack_seq; unsigned short res1; unsigned short window; unsigned short check; unsigned short urg_ptr; }

user_defined_types: struct udphdr { unsigned short source; unsigned short dest; unsigned short len; unsigned short check; }

user_defined_types: struct icmphdr { unsigned char type; unsigned char code; unsigned short checksum; union { struct { unsigned short id; unsigned short sequence; } echo; unsigned int gateway; struct { unsigned short __unused; unsigned short mtu; } frag; unsigned char reserved[4]; } un; }

user_defined_types: struct arphd { unsigned short ar_hrd; unsigned short ar_pro; unsigned char ar_hln; unsigned char ar_pln; unsigned short ar_op; unsigned char __ar_sha[6]; unsigned char __ar_sip[4]; unsigned char __ar_tha[6]; unsigned char __ar_tip[4]; }

user_defined_types: struct pcap_pkthdr { struct timeval ts; unsigned int caplen; unsigned int len; }


decompiled_code:
__int64 __fastcall print_payload(__int64 a1, int a2)
{
__int64 result; // rax
__int64 v4; // rbx
const unsigned __int16 **v5; // r13
__int64 v6; // rsi

result = get_payload();
if ( (_DWORD)result && a2 > 0 )
{
v4 = 0LL;
v5 = _ctype_b_loc();
do
{
while ( 1 )
{
v6 = *(char *)(a1 + v4);
if ( ((*v5)[v6] & 0x4000) == 0 )
break;
++v4;
nk_printf("%c");
if ( a2 < (int)v4 )
goto LABEL_8;
}
++v4;
nk_printf("0x%x ", v6);
}
while ( a2 >= (int)v4 );
LABEL_8:
result = nk_printf("\n\n");
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
__int64 result; // rax
__int64 v4; // rbx
const unsigned __int16 **v5; // r13
__int64 v6; // rsi

result = get_payload();
if ( (_DWORD)result && a2 > 0 )
{
v4 = 0LL;
v5 = _ctype_b_loc();
do
{
while ( 1 )
{
v6 = *(char *)(a1 + v4);
if ( ((*v5)[v6] & 0x4000) == 0 )
break;
++v4;
nk_printf("%c");
if ( a2 < (int)v4 )
goto LABEL_8;
}
++v4;
nk_printf("0x%x ", v6);
}
while ( a2 >= (int)v4 );
LABEL_8:
result = nk_printf("\n\n");
}
return result;
}

original_code:
void
print_payload (char *payload, int payload_len, struct iphdr *ip, unsigned int port)
{
    int i;
    int op_payload = get_payload ();
    if (payload_len > 0) {
        if (op_payload) {
            for (i = 0; i <= payload_len; i++) {
                if (((*__ctype_b_loc ())[(int) ((payload[i]))] & (unsigned short int) _ISprint))
                    nk_printf ("%c", payload[i]);
                else
                    nk_printf ("0x%x ", (char)payload[i]);
            }
            nk_printf("\n\n");
        }
    }
    return;
}

canonical_original_code:
void print_payload(char *payload, int payload_len, struct iphdr *ip, unsigned int port)
{
    int i;
    int op_payload = get_payload ();
    if (payload_len > 0) {
        if (op_payload) {
            for (i = 0; i <= payload_len; i++) {
                if (((*__ctype_b_loc ())[(int) ((payload[i]))] & (unsigned short) _ISprint))
                    nk_printf ("%c", payload[i]);
                else
                    nk_printf ("0x%x ", (char)payload[i]);
            }
            nk_printf("\n\n");
        }
    }
    return;
}

variable_types: struct iphdr { unsigned char ihl; unsigned char tos; unsigned short tot_len; unsigned short id; unsigned short frag_off; unsigned char ttl; unsigned char protocol; unsigned short check; unsigned int saddr; unsigned int daddr; } *

variable_types:
port
unsigned int


decompiled_code:
void *__fastcall nk_resolve(const char *a1)
{
struct hostent *v1; // rdx
void *result; // rax
struct in_addr inp; // [rsp+Ch] [rbp-1Ch] BYREF

inet_aton(a1, &inp);
v1 = gethostbyaddr(&inp, 4u, 2);
result = (void *)a1;
if ( v1 )
result = v1->h_name;
return result;
}

canonical_decompiled_code:
void *__fastcall func0(const char *a1)
{
struct hostent *v1; // rdx
void *result; // rax
struct in_addr inp; // [rsp+Ch] [rbp-1Ch] BYREF

inet_aton(a1, &inp);
v1 = gethostbyaddr(&inp, 4u, 2);
result = (void *)a1;
if ( v1 )
result = v1->h_name;
return result;
}

original_code:
char *
nk_resolve (char *ip)
{
    struct hostent *h_info;
    struct in_addr addr;
    inet_aton (ip, &addr);
    if ((h_info = gethostbyaddr (&addr, sizeof (addr), 2)) == ((void *)0))
        return ip;
    else
        return h_info->h_name;
}

canonical_original_code:
char *nk_resolve(char *ip)
{
    struct hostent *h_info;
    struct in_addr addr;
    inet_aton (ip, &addr);
    if ((h_info = gethostbyaddr (&addr, sizeof (addr), 2)) == ((void *)0))
        return ip;
    else
        return h_info->h_name;
}

variable_types:
ip
char *

variable_types: struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *

variable_types:
addr
struct in_addr { unsigned int s_addr; }

return_type: char *


decompiled_code:
int nk_printf(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-20D0h] BYREF
char s[8192]; // [rsp+20h] [rbp-20B8h] BYREF

va_start(arg, format);
vsnprintf(s, 0x2000uLL, format, arg);
return printf("%s", s);
}

canonical_decompiled_code:
int func0(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-20D0h] BYREF
char s[8192]; // [rsp+20h] [rbp-20B8h] BYREF

va_start(arg, format);
vsnprintf(s, 0x2000uLL, format, arg);
return printf("%s", s);
}

original_code:
int
nk_printf (char *format, ...)
{
    va_list ap;
    int len;
    char buf[8192];
    __builtin_va_start(ap,format);
    vsnprintf (buf, 8192, format, ap);
    len = printf ("%s", buf);
    __builtin_va_end(ap);
    return len;
}

canonical_original_code:
int nk_printf(char *format, ...)
{
    __builtin_va_list ap;
    int len;
    char buf[8192];
    __builtin_va_start(ap,format);
    vsnprintf (buf, 8192, format, ap);
    len = printf ("%s", buf);
    __builtin_va_end(ap);
    return len;
}

variable_types:
format
char *

variable_types: len int

variable_types:
buf
char [8192]


decompiled_code:
char *__fastcall convert_port(__int16 a1, int a2, const char *a3)
{
unsigned __int16 v4; // ax
struct servent *v5; // rax
char *result; // rax

if ( !a2 )
return 0LL;
v4 = _bswap_16(a1);
v5 = getservbyport(v4, a3);
name = (__int64)v5;
if ( v5 )
result = v5->s_name;
else
result = 0LL;
return result;
}

canonical_decompiled_code:
char *__fastcall func1(__int16 a1, int a2, const char *a3)
{
unsigned __int16 v4; // ax
struct servent *v5; // rax
char *result; // rax

if ( !a2 )
return 0LL;
v4 = func0(a1);
v5 = getservbyport(v4, a3);
name = (__int64)v5;
if ( v5 )
result = v5->s_name;
else
result = 0LL;
return result;
}

original_code:
char *
convert_port (unsigned int port, int flag, char *proto)
{
    if (flag) {
        if ((name = getservbyport (htons (port), proto)) != ((void *)0)) {
            return name->s_name;
        }
    }
    return ((void *)0);
}

canonical_original_code:
char *convert_port(unsigned int port, int flag, char *proto)
{
    if (flag) {
        if ((name = getservbyport (htons (port), proto)) != ((void *)0)) {
            return name->s_name;
        }
    }
    return ((void *)0);
}

variable_types: flag int

variable_types:
proto
char *


usage

decompiled_code:
void __fastcall __noreturn usage(const char *a1)
{
printf("%s-%s - %s\n", a1, "1.00", "ejlbell@gmail.com");
printf("%s [options]\n\n", a1);
puts(" -i --interface \t - specify an interface to sniff on");
puts(" -f --filter \t - filter packets that match a pcap regex");
puts(" -L --xml-log \t - save a log of data in xml format");
puts(" -v --verbose \t - verbose output");
puts(" -h --help \t - this help message");
putchar(10);
puts(" -r --enable-resolve \t - enable host name resolving");
puts(" -n --disable-portname \t - disable port name conversions");
puts(" -p --disable-promisc \t - disable promiscious mode");
putchar(10);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(const char *a1)
{
printf("%s-%s - %s\n", a1, "1.00", "ejlbell@gmail.com");
printf("%s [options]\n\n", a1);
puts(" -i --interface \t - specify an interface to sniff on");
puts(" -f --filter \t - filter packets that match a pcap regex");
puts(" -L --xml-log \t - save a log of data in xml format");
puts(" -v --verbose \t - verbose output");
puts(" -h --help \t - this help message");
putchar(10);
puts(" -r --enable-resolve \t - enable host name resolving");
puts(" -n --disable-portname \t - disable port name conversions");
puts(" -p --disable-promisc \t - disable promiscious mode");
putchar(10);
exit(0);
}

original_code:
void
usage (char *program)
{
    printf ("%s-%s - %s\n", program, "1.00", "ejlbell@gmail.com");
    printf ("%s [options]\n\n", program);
    printf ("  -i  --interface  \t - specify an interface to sniff on\n");
    printf ("  -f  --filter     \t - filter packets that match a pcap regex\n");
    printf ("  -L  --xml-log    \t - save a log of data in xml format\n");
    printf ("  -v  --verbose    \t - verbose output\n");
    printf ("  -h  --help       \t - this help message\n");
    printf ("\n");
    printf ("  -r  --enable-resolve      \t - enable host name resolving\n");
    printf ("  -n  --disable-portname  \t - disable port name conversions\n");
    printf ("  -p  --disable-promisc   \t - disable promiscious mode\n");
    printf ("\n");
    exit (0);
}

canonical_original_code:
void usage(char *program)
{
    printf ("%s-%s - %s\n", program, "1.00", "ejlbell@gmail.com");
    printf ("%s [options]\n\n", program);
    printf ("  -i  --interface  \t - specify an interface to sniff on\n");
    printf ("  -f  --filter     \t - filter packets that match a pcap regex\n");
    printf ("  -L  --xml-log    \t - save a log of data in xml format\n");
    printf ("  -v  --verbose    \t - verbose output\n");
    printf ("  -h  --help       \t - this help message\n");
    printf ("\n");
    printf ("  -r  --enable-resolve      \t - enable host name resolving\n");
    printf ("  -n  --disable-portname  \t - disable port name conversions\n");
    printf ("  -p  --disable-promisc   \t - disable promiscious mode\n");
    printf ("\n");
    exit (0);
}

variable_types:
program
char *


decompiled_code:
__int64 print_udp()
{
struct in_addr v0; // er12
struct in_addr v1; // er13
unsigned int v2; // ebp
int v3; // eax
__int64 v4; // rdx
int v5; // ebx
__int64 i; // rax
struct tm *v7; // r14
unsigned int v8; // er15
char *v9; // rax
char *v10; // rax
const char *v11; // rax
__int64 v12; // rdx
unsigned int v13; // er15
unsigned int v14; // er14
char *v15; // rax
const char *v16; // rsi
char *v17; // rax
const char *v18; // rsi
__int64 v19; // rdx
unsigned __int16 v20; // bx
unsigned __int16 v21; // ax
__int64 v22; // rdx
struct ether_addr addr; // [rsp+Ch] [rbp-5Ch] BYREF
struct ether_addr v25; // [rsp+12h] [rbp-56h] BYREF
time_t timer; // [rsp+18h] [rbp-50h] BYREF
struct timeval tv; // [rsp+20h] [rbp-48h] BYREF

v0.s_addr = *(_DWORD *)(qword_3A0 + 16LL);
v1.s_addr = *(_DWORD *)(qword_3A0 + 12LL);
get_payload();
v2 = get_port();
v3 = get_host();
v4 = eptr;
v5 = v3;
for ( i = 0LL; i != 7; ++i )
{
addr.ether_addr_octet[i] = *(_BYTE *)(v4 + i + 6);
v25.ether_addr_octet[i] = *(_BYTE *)(v4 + i);
}
timer = time(0LL);
v7 = gmtime(&timer);
gettimeofday(&tv, 0LL);
v8 = (unsigned __int16)_bswap_16(*(_WORD *)(eptr + 12LL));
nk_printf("%d:%d:%d-%ld ", (unsigned int)v7->tm_hour, (unsigned int)v7->tm_min, (unsigned int)v7->tm_sec, tv.tv_usec);
v9 = ether_ntoa(&addr);
print_mac(v9);
nk_printf("-> ");
v10 = ether_ntoa(&v25);
print_mac(v10);
LOWORD(v7) = _bswap_16(*(_WORD *)(qword_3A0 + 2LL));
v11 = (const char *)convert_type(v8);
nk_printf(" Type:0x%X [%s] Len:%d ", v8, v11, (unsigned __int16)v7);
v13 = (unsigned __int16)_bswap_16(*udp);
v14 = (unsigned __int16)_bswap_16(*(_WORD *)(v12 + 2));
v15 = inet_ntoa(v1);
if ( v5 )
v15 = (char *)nk_resolve(v15, v15);
nk_printf("%s:", v15);
v16 = (const char *)convert_port(v13, v2, "udp");
if ( v16 )
nk_printf("%s", v16);
else
nk_printf("%d", v13);
nk_printf(" -> ");
v17 = inet_ntoa(v0);
if ( v5 )
v17 = (char *)nk_resolve(v17, v17);
nk_printf("%s:", v17);
v18 = (const char *)convert_port(v14, v2, "udp");
if ( v18 )
nk_printf("%s ", v18);
else
nk_printf("%d ", v14);
nk_printf(" UDP ");
v20 = _bswap_16(*(_WORD *)(qword_3A0 + 2LL));
v21 = _bswap_16(*(_WORD *)(v19 + 4));
nk_printf("TOS:0x%x ID:%d TTL:%d\n\n", *(unsigned __int8 *)(v22 + 1), v21, *(unsigned __int8 *)(v22 + 8));
return print_payload(payload, (unsigned int)v20 - 28, qword_3A0, v14);
}

canonical_decompiled_code:
__int64 func1()
{
struct in_addr v0; // er12
struct in_addr v1; // er13
unsigned int v2; // ebp
int v3; // eax
__int64 v4; // rdx
int v5; // ebx
__int64 i; // rax
struct tm *v7; // r14
unsigned int v8; // er15
char *v9; // rax
char *v10; // rax
const char *v11; // rax
__int64 v12; // rdx
unsigned int v13; // er15
unsigned int v14; // er14
char *v15; // rax
const char *v16; // rsi
char *v17; // rax
const char *v18; // rsi
__int64 v19; // rdx
unsigned __int16 v20; // bx
unsigned __int16 v21; // ax
__int64 v22; // rdx
struct ether_addr addr; // [rsp+Ch] [rbp-5Ch] BYREF
struct ether_addr v25; // [rsp+12h] [rbp-56h] BYREF
time_t timer; // [rsp+18h] [rbp-50h] BYREF
struct timeval tv; // [rsp+20h] [rbp-48h] BYREF

v0.s_addr = *(_DWORD *)(qword_3A0 + 16LL);
v1.s_addr = *(_DWORD *)(qword_3A0 + 12LL);
get_payload();
v2 = get_port();
v3 = get_host();
v4 = eptr;
v5 = v3;
for ( i = 0LL; i != 7; ++i )
{
addr.ether_addr_octet[i] = *(_BYTE *)(v4 + i + 6);
v25.ether_addr_octet[i] = *(_BYTE *)(v4 + i);
}
timer = time(0LL);
v7 = gmtime(&timer);
gettimeofday(&tv, 0LL);
v8 = (unsigned __int16)func0(*(_WORD *)(eptr + 12LL));
nk_printf("%d:%d:%d-%ld ", (unsigned int)v7->tm_hour, (unsigned int)v7->tm_min, (unsigned int)v7->tm_sec, tv.tv_usec);
v9 = ether_ntoa(&addr);
print_mac(v9);
nk_printf("-> ");
v10 = ether_ntoa(&v25);
print_mac(v10);
LOWORD(v7) = func0(*(_WORD *)(qword_3A0 + 2LL));
v11 = (const char *)convert_type(v8);
nk_printf(" Type:0x%X [%s] Len:%d ", v8, v11, (unsigned __int16)v7);
v13 = (unsigned __int16)func0(*udp);
v14 = (unsigned __int16)func0(*(_WORD *)(v12 + 2));
v15 = inet_ntoa(v1);
if ( v5 )
v15 = (char *)nk_resolve(v15, v15);
nk_printf("%s:", v15);
v16 = (const char *)convert_port(v13, v2, "udp");
if ( v16 )
nk_printf("%s", v16);
else
nk_printf("%d", v13);
nk_printf(" -> ");
v17 = inet_ntoa(v0);
if ( v5 )
v17 = (char *)nk_resolve(v17, v17);
nk_printf("%s:", v17);
v18 = (const char *)convert_port(v14, v2, "udp");
if ( v18 )
nk_printf("%s ", v18);
else
nk_printf("%d ", v14);
nk_printf(" UDP ");
v20 = func0(*(_WORD *)(qword_3A0 + 2LL));
v21 = func0(*(_WORD *)(v19 + 4));
nk_printf("TOS:0x%x ID:%d TTL:%d\n\n", *(unsigned __int8 *)(v22 + 1), v21, *(unsigned __int8 *)(v22 + 8));
return print_payload(payload, (unsigned int)v20 - 28, qword_3A0, v14);
}

original_code:
void
print_udp ()
{
    struct in_addr d_addr, s_addr;
    extern struct iphdr *ip;
    extern struct udphdr *udp;
    extern char *payload;
    extern struct ether_header *eptr;
    char *daddr = "";
    char *saddr = "";
    char *port_name;
    time_t current;
    u_short s_port = 0;
    u_short d_port = 0;
    int payload_len = -1;
    int i, type;
    int op_payload;
    int op_port;
    int op_host;
    struct ether_addr smac_addr;
    struct ether_addr dmac_addr;
    struct timeval tv;
    struct tm *t;
    d_addr.s_addr = ip->daddr;
    s_addr.s_addr = ip->saddr;
    op_payload = get_payload ();
    op_port = get_port ();
    op_host = get_host ();
    for (i = 0; i <= 6; i++) {
        smac_addr.ether_addr_octet[i] = eptr->ether_shost[i];
        dmac_addr.ether_addr_octet[i] = eptr->ether_dhost[i];
    }
    current = time (((void *)0));
    t = gmtime (&current);
    gettimeofday (&tv, ((void *)0));
    type = ntohs (eptr->ether_type);
    nk_printf ("%d:%d:%d-%ld  ", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec);
    saddr = ether_ntoa (&smac_addr);
    print_mac (saddr);
    nk_printf ("-> ");
    daddr = ether_ntoa (&dmac_addr);
    print_mac (daddr);
    nk_printf (" Type:0x%X [%s]  Len:%d  ", type, convert_type (type), ntohs (ip->tot_len));
    s_port = ntohs (udp->source);
    d_port = ntohs (udp->dest);
    saddr = inet_ntoa (s_addr);
    if (op_host)
        nk_printf ("%s:", nk_resolve (saddr));
    else
        nk_printf ("%s:", saddr);
    port_name = convert_port (s_port, op_port, "udp");
    if (port_name != ((void *)0))
        nk_printf ("%s", port_name);
    else
        nk_printf ("%d", s_port);
    nk_printf (" -> ");
    daddr = inet_ntoa (d_addr);
    if (op_host)
        nk_printf ("%s:", nk_resolve (daddr));
    else
        nk_printf ("%s:", daddr);
    port_name = convert_port (d_port, op_port, "udp");
    if (port_name != ((void *)0))
        nk_printf ("%s ", port_name);
    else
        nk_printf ("%d ", d_port);
    nk_printf (" UDP  ");
    payload_len = (ntohs (ip->tot_len) - sizeof(struct udphdr) - sizeof(struct iphdr));
    nk_printf ("TOS:0x%x  ID:%d  TTL:%d\n\n", ip->tos, ntohs (ip->id), ip->ttl);
    print_payload (payload, payload_len, ip, d_port);
    return;
}

canonical_original_code:
void print_udp()
{
    struct in_addr d_addr; struct in_addr s_addr;
    extern struct iphdr *ip;
    extern struct udphdr *udp;
    extern char *payload;
    extern struct ether_header *eptr;
    char *daddr = "";
    char *saddr = "";
    char *port_name;
    long current;
    unsigned short s_port = 0;
    unsigned short d_port = 0;
    int payload_len = -1;
    int i; int type;
    int op_payload;
    int op_port;
    int op_host;
    struct ether_addr smac_addr;
    struct ether_addr dmac_addr;
    struct timeval tv;
    struct tm *t;
    d_addr.s_addr = ip->daddr;
    s_addr.s_addr = ip->saddr;
    op_payload = get_payload ();
    op_port = get_port ();
    op_host = get_host ();
    for (i = 0; i <= 6; i++) {
        smac_addr.ether_addr_octet[i] = eptr->ether_shost[i];
        dmac_addr.ether_addr_octet[i] = eptr->ether_dhost[i];
    }
    current = time (((void *)0));
    t = gmtime (&current);
    gettimeofday (&tv, ((void *)0));
    type = ntohs (eptr->ether_type);
    nk_printf ("%d:%d:%d-%ld  ", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec);
    saddr = ether_ntoa (&smac_addr);
    print_mac (saddr);
    nk_printf ("-> ");
    daddr = ether_ntoa (&dmac_addr);
    print_mac (daddr);
    nk_printf (" Type:0x%X [%s]  Len:%d  ", type, convert_type (type), ntohs (ip->tot_len));
    s_port = ntohs (udp->source);
    d_port = ntohs (udp->dest);
    saddr = inet_ntoa (s_addr);
    if (op_host)
        nk_printf ("%s:", nk_resolve (saddr));
    else
        nk_printf ("%s:", saddr);
    port_name = convert_port (s_port, op_port, "udp");
    if (port_name != ((void *)0))
        nk_printf ("%s", port_name);
    else
        nk_printf ("%d", s_port);
    nk_printf (" -> ");
    daddr = inet_ntoa (d_addr);
    if (op_host)
        nk_printf ("%s:", nk_resolve (daddr));
    else
        nk_printf ("%s:", daddr);
    port_name = convert_port (d_port, op_port, "udp");
    if (port_name != ((void *)0))
        nk_printf ("%s ", port_name);
    else
        nk_printf ("%d ", d_port);
    nk_printf (" UDP  ");
    payload_len = (ntohs (ip->tot_len) - sizeof(struct udphdr) - sizeof(struct iphdr));
    nk_printf ("TOS:0x%x  ID:%d  TTL:%d\n\n", ip->tos, ntohs (ip->id), ip->ttl);
    print_payload (payload, payload_len, ip, d_port);
    return;
}

variable_types: struct udphdr { unsigned short source; unsigned short dest; unsigned short len; unsigned short check; } *

variable_types:
payload
char *

variable_types: struct ether_header { unsigned char ether_dhost[6]; unsigned char ether_shost[6]; unsigned short ether_type; } *

variable_types:
daddr
char *

variable_types:
saddr
char *

variable_types: current long

variable_types: i int

variable_types: type int

variable_types: struct ether_addr { unsigned char ether_addr_octet[6]; }

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

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


decompiled_code:
__int64 print_icmp()
{
int v0; // eax
__int64 v1; // rdx
int v2; // er12
struct in_addr v3; // ebp
struct in_addr v4; // er13
__int64 i; // rax
unsigned int *v6; // rdx
unsigned int v7; // er14
char *v8; // rax
char *v9; // rax
unsigned __int16 v10; // bx
const char *v11; // rax
char *v12; // rax
const char *v13; // rsi
char *v14; // rax
const char *v15; // rax
unsigned int v16; // er13
unsigned int v17; // er12
const char *v18; // rax
unsigned __int16 v19; // ax
__int64 v20; // rcx
unsigned __int16 v21; // ax
char *v23; // rax
__int64 v24; // rdx
unsigned __int16 v25; // ax
unsigned __int16 v26; // cx
unsigned __int16 v27; // ax
__int64 v28; // rcx
struct ether_addr v29; // [rsp+Ch] [rbp-4Ch] BYREF
struct ether_addr addr; // [rsp+12h] [rbp-46h] BYREF
time_t timer; // [rsp+18h] [rbp-40h] BYREF
struct timeval tv; // [rsp+20h] [rbp-38h] BYREF

v0 = get_host();
v1 = eptr;
v2 = v0;
v3.s_addr = *(_DWORD *)(qword_3B0 + 16LL);
v4.s_addr = *(_DWORD *)(qword_3B0 + 12LL);
for ( i = 0LL; i != 7; ++i )
{
v29.ether_addr_octet[i] = *(_BYTE *)(v1 + i + 6);
addr.ether_addr_octet[i] = *(_BYTE *)(v1 + i);
}
timer = time(0LL);
gettimeofday(&tv, 0LL);
gmtime(&timer);
v7 = (unsigned __int16)_bswap_16(*(_WORD *)(eptr + 12LL));
nk_printf("%d:%d:%d-%ld ", v6[2], v6[1], *v6, tv.tv_usec);
v8 = ether_ntoa(&addr);
print_mac(v8);
nk_printf("-> ");
v9 = ether_ntoa(&v29);
print_mac(v9);
v10 = _bswap_16(*(_WORD *)(qword_3B0 + 2LL));
v11 = (const char *)convert_type(v7);
nk_printf(" Type:0x%X [%s] Len:%d ", v7, v11, v10);
v12 = inet_ntoa(v4);
if ( v2 )
{
v13 = (const char *)nk_resolve(v12, v12);
nk_printf("%s -> ", v13);
v14 = inet_ntoa(v3);
v15 = (const char *)nk_resolve(v14, v13);
nk_printf("%s", v15);
}
else
{
nk_printf("%s -> ", v12);
v23 = inet_ntoa(v3);
nk_printf("%s ", v23);
}
v16 = *(unsigned __int8 *)(icmp + 1LL);
v17 = (unsigned __int8)*icmp;
v18 = (const char *)convert_icmp(*(unsigned __int8 *)(icmp + 1LL), (unsigned __int8)*icmp);
nk_printf(" ICMP %s Type:%d Code:%d ", v18, v17, v16);
if ( (*icmp & 0xF7) == 0 )
{
_bswap_16(*(_WORD *)(icmp + 6LL));
v25 = _bswap_16(*(_WORD *)(v24 + 4));
nk_printf("[ EchoID:%d Seq:%d ", v25, v26);
v27 = _bswap_16(*(_WORD *)(qword_3B0 + 4LL));
nk_printf("TOS:0x%x ID:%d TTL:%d ] ", *(unsigned __int8 *)(v28 + 1), v27, *(unsigned __int8 *)(v28 + 8));
}
v19 = _bswap_16(*(_WORD *)(qword_3B0 + 4LL));
nk_printf("TOS:0x%x ID:%d TTL:%d", *(unsigned __int8 *)(v20 + 1), v19, *(unsigned __int8 *)(v20 + 8));
nk_printf("\n\n");
v21 = _bswap_16(*(_WORD *)(qword_3B0 + 2LL));
return print_payload(payload, (unsigned int)v21 - 28);
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // eax
__int64 v1; // rdx
int v2; // er12
struct in_addr v3; // ebp
struct in_addr v4; // er13
__int64 i; // rax
unsigned int *v6; // rdx
unsigned int v7; // er14
char *v8; // rax
char *v9; // rax
unsigned __int16 v10; // bx
const char *v11; // rax
char *v12; // rax
const char *v13; // rsi
char *v14; // rax
const char *v15; // rax
unsigned int v16; // er13
unsigned int v17; // er12
const char *v18; // rax
unsigned __int16 v19; // ax
__int64 v20; // rcx
unsigned __int16 v21; // ax
char *v23; // rax
__int64 v24; // rdx
unsigned __int16 v25; // ax
unsigned __int16 v26; // cx
unsigned __int16 v27; // ax
__int64 v28; // rcx
struct ether_addr v29; // [rsp+Ch] [rbp-4Ch] BYREF
struct ether_addr addr; // [rsp+12h] [rbp-46h] BYREF
time_t timer; // [rsp+18h] [rbp-40h] BYREF
struct timeval tv; // [rsp+20h] [rbp-38h] BYREF

v0 = get_host();
v1 = eptr;
v2 = v0;
v3.s_addr = *(_DWORD *)(qword_3B0 + 16LL);
v4.s_addr = *(_DWORD *)(qword_3B0 + 12LL);
for ( i = 0LL; i != 7; ++i )
{
v29.ether_addr_octet[i] = *(_BYTE *)(v1 + i + 6);
addr.ether_addr_octet[i] = *(_BYTE *)(v1 + i);
}
timer = time(0LL);
gettimeofday(&tv, 0LL);
gmtime(&timer);
v7 = (unsigned __int16)func0(*(_WORD *)(eptr + 12LL));
nk_printf("%d:%d:%d-%ld ", v6[2], v6[1], *v6, tv.tv_usec);
v8 = ether_ntoa(&addr);
print_mac(v8);
nk_printf("-> ");
v9 = ether_ntoa(&v29);
print_mac(v9);
v10 = func0(*(_WORD *)(qword_3B0 + 2LL));
v11 = (const char *)convert_type(v7);
nk_printf(" Type:0x%X [%s] Len:%d ", v7, v11, v10);
v12 = inet_ntoa(v4);
if ( v2 )
{
v13 = (const char *)nk_resolve(v12, v12);
nk_printf("%s -> ", v13);
v14 = inet_ntoa(v3);
v15 = (const char *)nk_resolve(v14, v13);
nk_printf("%s", v15);
}
else
{
nk_printf("%s -> ", v12);
v23 = inet_ntoa(v3);
nk_printf("%s ", v23);
}
v16 = *(unsigned __int8 *)(icmp + 1LL);
v17 = (unsigned __int8)*icmp;
v18 = (const char *)convert_icmp(*(unsigned __int8 *)(icmp + 1LL), (unsigned __int8)*icmp);
nk_printf(" ICMP %s Type:%d Code:%d ", v18, v17, v16);
if ( (*icmp & 0xF7) == 0 )
{
func0(*(_WORD *)(icmp + 6LL));
v25 = func0(*(_WORD *)(v24 + 4));
nk_printf("[ EchoID:%d Seq:%d ", v25, v26);
v27 = func0(*(_WORD *)(qword_3B0 + 4LL));
nk_printf("TOS:0x%x ID:%d TTL:%d ] ", *(unsigned __int8 *)(v28 + 1), v27, *(unsigned __int8 *)(v28 + 8));
}
v19 = func0(*(_WORD *)(qword_3B0 + 4LL));
nk_printf("TOS:0x%x ID:%d TTL:%d", *(unsigned __int8 *)(v20 + 1), v19, *(unsigned __int8 *)(v20 + 8));
nk_printf("\n\n");
v21 = func0(*(_WORD *)(qword_3B0 + 2LL));
return print_payload(payload, (unsigned int)v21 - 28);
}

original_code:
void
print_icmp ()
{
    struct in_addr d_addr, s_addr;
    extern struct iphdr *ip;
    extern struct icmphdr *icmp;
    extern char *payload;
    extern struct ether_header *eptr;
    char *daddr, *saddr;
    time_t current;
    int i, type;
    int payload_len;
    struct ether_addr smac_addr;
    struct ether_addr dmac_addr;
    struct timeval tv;
    struct tm *t;
    int op_host = get_host ();
    d_addr.s_addr = ip->daddr;
    s_addr.s_addr = ip->saddr;
    for (i = 0; i <= 6; i++) {
        smac_addr.ether_addr_octet[i] = eptr->ether_shost[i];
        dmac_addr.ether_addr_octet[i] = eptr->ether_dhost[i];
    }
    current = time (((void *)0));
    gettimeofday (&tv, ((void *)0));
    t = gmtime (&current);
    type = ntohs (eptr->ether_type);
    nk_printf ("%d:%d:%d-%ld  ", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec);
    daddr = ether_ntoa (&dmac_addr);
    print_mac (daddr);
    nk_printf ("-> ");
    saddr = ether_ntoa (&smac_addr);
    print_mac (saddr);
    nk_printf (" Type:0x%X [%s]  Len:%d  ", type, convert_type (type), ntohs (ip->tot_len));
    saddr = inet_ntoa (s_addr);
    if (op_host) {
        nk_printf ("%s -> ", nk_resolve (saddr));
        daddr = inet_ntoa (d_addr);
        nk_printf ("%s", nk_resolve (daddr));
    } else {
        nk_printf ("%s -> ", saddr);
        daddr = inet_ntoa (d_addr);
        nk_printf ("%s ", daddr);
    }
    nk_printf (" ICMP  %s  Type:%d  Code:%d  ",
               convert_icmp (icmp->code, icmp->type), icmp->type, icmp->code);
    if (icmp->type == 0 || icmp->type == 8) {
        nk_printf ("[ EchoID:%d  Seq:%d  ", ntohs ((icmp->un).echo.id),
                   ntohs ((icmp->un).echo.sequence));
        nk_printf ("TOS:0x%x  ID:%d  TTL:%d ]  ", ip->tos, ntohs (ip->id), ip->ttl);
    }
    nk_printf ("TOS:0x%x  ID:%d  TTL:%d", ip->tos, ntohs (ip->id), ip->ttl);
    nk_printf ("\n\n");
    payload_len = (ntohs (ip->tot_len) - sizeof(struct icmphdr) - sizeof(struct iphdr));
    print_payload (payload, payload_len, ip, 0);
    return;
}

canonical_original_code:
void print_icmp()
{
    struct in_addr d_addr; struct in_addr s_addr;
    extern struct iphdr *ip;
    extern struct icmphdr *icmp;
    extern char *payload;
    extern struct ether_header *eptr;
    char *daddr; char *saddr;
    long current;
    int i; int type;
    int payload_len;
    struct ether_addr smac_addr;
    struct ether_addr dmac_addr;
    struct timeval tv;
    struct tm *t;
    int op_host = get_host ();
    d_addr.s_addr = ip->daddr;
    s_addr.s_addr = ip->saddr;
    for (i = 0; i <= 6; i++) {
        smac_addr.ether_addr_octet[i] = eptr->ether_shost[i];
        dmac_addr.ether_addr_octet[i] = eptr->ether_dhost[i];
    }
    current = time (((void *)0));
    gettimeofday (&tv, ((void *)0));
    t = gmtime (&current);
    type = ntohs (eptr->ether_type);
    nk_printf ("%d:%d:%d-%ld  ", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec);
    daddr = ether_ntoa (&dmac_addr);
    print_mac (daddr);
    nk_printf ("-> ");
    saddr = ether_ntoa (&smac_addr);
    print_mac (saddr);
    nk_printf (" Type:0x%X [%s]  Len:%d  ", type, convert_type (type), ntohs (ip->tot_len));
    saddr = inet_ntoa (s_addr);
    if (op_host) {
        nk_printf ("%s -> ", nk_resolve (saddr));
        daddr = inet_ntoa (d_addr);
        nk_printf ("%s", nk_resolve (daddr));
    } else {
        nk_printf ("%s -> ", saddr);
        daddr = inet_ntoa (d_addr);
        nk_printf ("%s ", daddr);
    }
    nk_printf (" ICMP  %s  Type:%d  Code:%d  ",
               convert_icmp (icmp->code, icmp->type), icmp->type, icmp->code);
    if (icmp->type == 0 || icmp->type == 8) {
        nk_printf ("[ EchoID:%d  Seq:%d  ", ntohs ((icmp->un).echo.id),
                   ntohs ((icmp->un).echo.sequence));
        nk_printf ("TOS:0x%x  ID:%d  TTL:%d ]  ", ip->tos, ntohs (ip->id), ip->ttl);
    }
    nk_printf ("TOS:0x%x  ID:%d  TTL:%d", ip->tos, ntohs (ip->id), ip->ttl);
    nk_printf ("\n\n");
    payload_len = (ntohs (ip->tot_len) - sizeof(struct icmphdr) - sizeof(struct iphdr));
    print_payload (payload, payload_len, ip, 0);
    return;
}

variable_types: struct iphdr { unsigned char ihl; unsigned char tos; unsigned short tot_len; unsigned short id; unsigned short frag_off; unsigned char ttl; unsigned char protocol; unsigned short check; unsigned int saddr; unsigned int daddr; } *

variable_types: struct icmphdr { unsigned char type; unsigned char code; unsigned short checksum; union { struct { unsigned short id; unsigned short sequence; } echo; unsigned int gateway; struct { unsigned short __unused; unsigned short mtu; } frag; unsigned char reserved[4]; } un; } *


decompiled_code:
__int64 __fastcall print_mac(char *src)
{
char v1; // r14
int v2; // ebx
int v3; // er13
__int64 v4; // rsi
int v5; // er15
__int64 v6; // rcx
char v8[88]; // [rsp+0h] [rbp-58h] BYREF

v1 = 58;
v2 = 0;
strncpy(v8, src, 0x14uLL);
v3 = strlen(v8);
do
{
while ( 1 )
{
v4 = (unsigned int)v8[v2];
if ( v3 - 2 <= v2 )
v1 = 32;
if ( v8[v2] == 58 )
goto LABEL_3;
v5 = v2 + 1;
v6 = (unsigned int)v1;
if ( v8[v2 + 1] == 58 )
break;
++v2;
nk_printf("%c%c%c", v4, (unsigned int)v8[v5], v6);
LABEL_3:
v2 += 2;
if ( v3 < v2 )
return 0LL;
}
v2 += 2;
nk_printf("0%c%c", v4, (unsigned int)v6);
}
while ( v3 >= v2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *src)
{
char v1; // r14
int v2; // ebx
int v3; // er13
__int64 v4; // rsi
int v5; // er15
__int64 v6; // rcx
char v8[88]; // [rsp+0h] [rbp-58h] BYREF

v1 = 58;
v2 = 0;
strncpy(v8, src, 0x14uLL);
v3 = strlen(v8);
do
{
while ( 1 )
{
v4 = (unsigned int)v8[v2];
if ( v3 - 2 <= v2 )
v1 = 32;
if ( v8[v2] == 58 )
goto LABEL_3;
v5 = v2 + 1;
v6 = (unsigned int)v1;
if ( v8[v2 + 1] == 58 )
break;
++v2;
nk_printf("%c%c%c", v4, (unsigned int)v8[v5], v6);
LABEL_3:
v2 += 2;
if ( v3 < v2 )
return 0LL;
}
v2 += 2;
nk_printf("0%c%c", v4, (unsigned int)v6);
}
while ( v3 >= v2 );
return 0LL;
}

original_code:
int
print_mac (char *mac_addr)
{
    int count, len;
    char print_delim = ':';
    char addr_buf[20];
    strncpy (addr_buf, mac_addr, 20);
    len = strlen (addr_buf);
    for (count = 0; count <= len; count += 2) {
        if (count >= len - 2)
            print_delim = ' ';
        if (addr_buf[count] != ':' && addr_buf[count + 1] != ':') {
            nk_printf ("%c%c%c", addr_buf[count], addr_buf[count + 1], print_delim);
            count++;
        }
        else if (addr_buf[count] != ':' && addr_buf[count + 1] == ':')
            nk_printf ("0%c%c", addr_buf[count], print_delim);
    }
    mac_addr = "";
    return 0;
}

canonical_original_code:
int print_mac(char *mac_addr)
{
    int count; int len;
    char print_delim = ':';
    char addr_buf[20];
    strncpy (addr_buf, mac_addr, 20);
    len = strlen (addr_buf);
    for (count = 0; count <= len; count += 2) {
        if (count >= len - 2)
            print_delim = ' ';
        if (addr_buf[count] != ':' && addr_buf[count + 1] != ':') {
            nk_printf ("%c%c%c", addr_buf[count], addr_buf[count + 1], print_delim);
            count++;
        }
        else if (addr_buf[count] != ':' && addr_buf[count + 1] == ':')
            nk_printf ("0%c%c", addr_buf[count], print_delim);
    }
    mac_addr = "";
    return 0;
}

variable_types: count int

variable_types: len int


decompiled_code:
const char *__fastcall convert_type(int a1)
{
const char *result; // rax

if ( a1 == 2054 )
return (const char *)&unk_58;
if ( a1 > 2054 )
{
result = (const char *)&unk_50;
if ( a1 == 32821 )
result = "RARP";
}
else
{
result = (const char *)&unk_51;
if ( a1 != 512 )
{
result = (const char *)&unk_50;
if ( a1 == 2048 )
result = (const char *)&unk_55;
}
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(int a1)
{
const char *result; // rax

if ( a1 == 2054 )
return (const char *)&unk_58;
if ( a1 > 2054 )
{
result = (const char *)&unk_50;
if ( a1 == 32821 )
result = "RARP";
}
else
{
result = (const char *)&unk_51;
if ( a1 != 512 )
{
result = (const char *)&unk_50;
if ( a1 == 2048 )
result = (const char *)&unk_55;
}
}
return result;
}

original_code:
char *
convert_type (int type)
{
    switch (type) {
    case 0x0200:
        return "PUP";
    case 0x0800:
        return "IP";
    case 0x0806:
        return "ARP";
    case 0x8035:
        return "RARP";
    }
    return "";
}

canonical_original_code:
char *convert_type(int type)
{
    switch (type) {
    case 0x0200:
        return "PUP";
    case 0x0800:
        return "IP";
    case 0x0806:
        return "ARP";
    case 0x8035:
        return "RARP";
    }
    return "";
}


repo: ejohnst/exiftags

decompiled_code:
int jpg1byte()
{
int result; // eax

result = fgetc(infile);
if ( result == -1 )
{
exifdie("invalid JPEG format");
result = -1;
}
return result;
}

canonical_decompiled_code:
int func0()
{
int result; // eax

result = fgetc(infile);
if ( result == -1 )
{
exifdie("invalid JPEG format");
result = -1;
}
return result;
}

original_code:
static int
jpg1byte(void)
{
 int b;
 b = fgetc(infile);
 if (b == (-1))
  exifdie("invalid JPEG format");
 return (b);
}

canonical_original_code:
static int jpg1byte()
{
 int b;
 b = fgetc(infile);
 if (b == (-1))
  exifdie("invalid JPEG format");
 return (b);
}

variable_types: b int


topmkr

decompiled_code:
int topmkr()
{
int result; // eax

if ( jpg1byte() == 255 )
result = jpg1byte();
else
result = 256;
return result;
}

canonical_decompiled_code:
int func1()
{
int result; // eax

if ( func0() == 255 )
result = func0();
else
result = 256;
return result;
}

original_code:
static int
topmkr(void)
{
 if (jpg1byte() != 0xff)
  return (0x100);
 return (jpg1byte());
}

canonical_original_code:
static int topmkr()
{
 if (jpg1byte() != 0xff)
  return (0x100);
 return (jpg1byte());
}


nxtmkr

decompiled_code:
int nxtmkr()
{
int v0; // ebx
int result; // eax
int v2; // [rsp+Ch] [rbp-Ch]

v0 = 0;
while ( jpg1byte() != 255 )
++v0;
do
result = jpg1byte();
while ( result == 255 );
if ( v0 )
{
v2 = result;
exifwarn("skipped spurious bytes in JPEG");
result = v2;
}
return result;
}

canonical_decompiled_code:
int func2()
{
int v0; // ebx
int result; // eax
int v2; // [rsp+Ch] [rbp-Ch]

v0 = 0;
while ( func0() != 255 )
++v0;
do
result = func0();
while ( result == 255 );
if ( v0 )
{
v2 = result;
exifwarn("skipped spurious bytes in JPEG");
result = v2;
}
return result;
}

original_code:
static int
nxtmkr(void)
{
 int b;
 int bad = 0;
 while ((b = jpg1byte()) != 0xff)
  bad++;
 while ((b = jpg1byte()) == 0xff);
 if (bad)
  exifwarn("skipped spurious bytes in JPEG");
 return (b);
}

canonical_original_code:
static int nxtmkr()
{
 int b;
 int bad = 0;
 while ((b = jpg1byte()) != 0xff)
  bad++;
 while ((b = jpg1byte()) == 0xff);
 if (bad)
  exifwarn("skipped spurious bytes in JPEG");
 return (b);
}

variable_types: bad int


decompiled_code:
__int64 jpg2byte()
{
int v0; // ebx
int v1; // eax
int v2; // ebp

v0 = fgetc(infile);
v1 = fgetc(infile);
v2 = v1;
if ( v0 != -1 && v1 != -1 )
return v1 | (unsigned int)(v0 << 8);
exifdie("invalid JPEG format");
return v2 | (unsigned int)(v0 << 8);
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // ebx
int v1; // eax
int v2; // ebp

v0 = fgetc(infile);
v1 = fgetc(infile);
v2 = v1;
if ( v0 != -1 && v1 != -1 )
return v1 | (unsigned int)(v0 << 8);
exifdie("invalid JPEG format");
return v2 | (unsigned int)(v0 << 8);
}

original_code:
static unsigned int
jpg2byte(void)
{
 unsigned int b1, b2;
 b1 = fgetc(infile);
 b2 = fgetc(infile);
 if (b1 == (-1) || b2 == (-1))
  exifdie("invalid JPEG format");
 return ((b1 << 8) | b2);
}

canonical_original_code:
static unsigned int jpg2byte()
{
 unsigned int b1; unsigned int b2;
 b1 = fgetc(infile);
 b2 = fgetc(infile);
 if (b1 == (-1) || b2 == (-1))
  exifdie("invalid JPEG format");
 return ((b1 << 8) | b2);
}

return_type: unsigned int


mkrlen

decompiled_code:
__int64 mkrlen()
{
unsigned int v0; // ebx

v0 = jpg2byte();
if ( v0 <= 1 )
exifdie("invalid JPEG marker (length mismatch)");
return v0 - 2;
}

canonical_decompiled_code:
__int64 func4()
{
unsigned int v0; // ebx

v0 = func3();
if ( v0 <= 1 )
exifdie("invalid JPEG marker (length mismatch)");
return v0 - 2;
}

original_code:
static unsigned int
mkrlen(void)
{
 unsigned int l;
 if ((l = jpg2byte()) < 2)
  exifdie("invalid JPEG marker (length mismatch)");
 return (l - 2);
}

canonical_original_code:
static unsigned int mkrlen()
{
 unsigned int l;
 if ((l = jpg2byte()) < 2)
  exifdie("invalid JPEG marker (length mismatch)");
 return (l - 2);
}

variable_types:
l
unsigned int


skipmkr

decompiled_code:
int skipmkr()
{
int result; // eax
int v1; // ebx

result = mkrlen();
if ( result )
{
v1 = result;
do
{
result = jpg1byte();
--v1;
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
int func5()
{
int result; // eax
int v1; // ebx

result = func4();
if ( result )
{
v1 = result;
do
{
result = func0();
--v1;
}
while ( v1 );
}
return result;
}

original_code:
static void
skipmkr(void)
{
 unsigned int l;
 l = mkrlen();
 while (l) {
  jpg1byte();
  l--;
 }
}

canonical_original_code:
static void skipmkr()
{
 unsigned int l;
 l = mkrlen();
 while (l) {
  jpg1byte();
  l--;
 }
}


sofmrk

decompiled_code:
int sofmrk()
{
int v0; // ebx
int result; // eax
int v2; // ebx

v0 = mkrlen();
jpg_prcsn = jpg1byte();
jpg_height = jpg2byte();
jpg_width = jpg2byte();
result = jpg1byte();
jpg_cmpnts = result;
if ( 3 * result + 6 != v0 )
{
exifdie("invalid JPEG SOF marker (length mismatch)");
result = jpg_cmpnts;
}
v2 = 0;
if ( result > 0 )
{
do
{
jpg1byte();
++v2;
jpg1byte();
result = jpg1byte();
}
while ( jpg_cmpnts > v2 );
}
seensof = 1;
return result;
}

canonical_decompiled_code:
int func6()
{
int v0; // ebx
int result; // eax
int v2; // ebx

v0 = func4();
jpg_prcsn = func0();
jpg_height = func3();
jpg_width = func3();
result = func0();
jpg_cmpnts = result;
if ( 3 * result + 6 != v0 )
{
exifdie("invalid JPEG SOF marker (length mismatch)");
result = jpg_cmpnts;
}
v2 = 0;
if ( result > 0 )
{
do
{
func0();
++v2;
func0();
result = func0();
}
while ( jpg_cmpnts > v2 );
}
seensof = 1;
return result;
}

original_code:
static void
sofmrk(int mark)
{
 int i;
 unsigned int l;
 l = mkrlen();
 jpg_prcsn = jpg1byte();
 jpg_height = jpg2byte();
 jpg_width = jpg2byte();
 jpg_cmpnts = jpg1byte();
 for (i = 0; process[i].sof < 0x100; i++)
  if (process[i].sof == mark)
   break;
 jpg_prcss = process[i].str;
 if (l != (unsigned int)(6 + jpg_cmpnts * 3))
  exifdie("invalid JPEG SOF marker (length mismatch)");
 for (i = 0; i < jpg_cmpnts; i++) {
  jpg1byte(); jpg1byte(); jpg1byte();
 }
 seensof = 1;
}

variable_types: mark int


jpeginfo

decompiled_code:
__int64 __fastcall jpeginfo(_DWORD *a1, _DWORD *a2, _DWORD *a3, _DWORD *a4)
{
*a1 = jpg_prcsn;
*a2 = jpg_cmpnts;
*a3 = jpg_height;
*a4 = jpg_width;
return (unsigned int)seensof;
}

canonical_decompiled_code:
__int64 __fastcall func8(_DWORD *a1, _DWORD *a2, _DWORD *a3, _DWORD *a4)
{
*a1 = jpg_prcsn;
*a2 = jpg_cmpnts;
*a3 = jpg_height;
*a4 = jpg_width;
return (unsigned int)seensof;
}

original_code:
int
jpeginfo(int *prcsn, int *cmpnts, unsigned int *height, unsigned int *width,
    const char *prcss)
{
 *prcsn = jpg_prcsn;
 *cmpnts = jpg_cmpnts;
 *height = jpg_height;
 *width = jpg_width;
 prcss = jpg_prcss;
 return (seensof);
}

canonical_original_code:
int jpeginfo(int *prcsn, int *cmpnts, unsigned int *height, unsigned int *width, char *prcss)
{
 *prcsn = jpg_prcsn;
 *cmpnts = jpg_cmpnts;
 *height = jpg_height;
 *width = jpg_width;
 prcss = jpg_prcss;
 return (seensof);
}

variable_types:
prcsn
int *

variable_types:
cmpnts
int *

variable_types:
height
unsigned int *

variable_types:
width
unsigned int *

variable_types:
prcss
char *


original_code:
static void
nikon_prop0(struct exifprop *prop, struct exiftags *t)
{
 u_int32_t a, b;
 switch (prop->tag) {
 case 0x000a:
  a = exif4byte(t->mkrmd.btiff + prop->value, t->mkrmd.order);
  b = exif4byte(t->mkrmd.btiff + prop->value + 4, t->mkrmd.order);
  if (!a) {
   snprintf(prop->str, 31, "None");
   prop->lvl = 0x08;
  } else
   snprintf(prop->str, 31, "x%.1f", (float)a / (float)b);
  break;
 }
}

canonical_original_code:
static void nikon_prop0(struct exifprop *prop, struct exiftags *t)
{
 unsigned int a; unsigned int b;
 switch (prop->tag) {
 case 0x000a:
  a = exif4byte(t->mkrmd.btiff + prop->value, t->mkrmd.order);
  b = exif4byte(t->mkrmd.btiff + prop->value + 4, t->mkrmd.order);
  if (!a) {
   snprintf(prop->str, 31, "None");
   prop->lvl = 0x08;
  } else
   snprintf(prop->str, 31, "x%.1f", (float)a / (float)b);
  break;
 }
}

variable_types: struct exifprop { unsigned int tag; unsigned int type; unsigned int count; unsigned int value; char *name; char *descr; char *str; unsigned short lvl; int ifdseq; unsigned int override; struct exiftag { unsigned int tag; unsigned int type; unsigned int count; unsigned short lvl; char *name; char *descr; struct descrip { int val; char *descr; } *table; } *tagset; struct exifprop *par; struct exifprop *next; } *

variable_types: struct exiftags { struct exifprop *props; struct tiffmeta { enum byteorder { LITTLE=0, BIG=1 } order; unsigned char *btiff; unsigned char *etiff; void *ifdoffs; } md; char *model; short mkrval; struct tiffmeta mkrmd; short exifmaj; short exifmin; } *

variable_types:
a
unsigned int

variable_types:
b
unsigned int

user_defined_types: struct exifprop { unsigned int tag; unsigned int type; unsigned int count; unsigned int value; char *name; char *descr; char *str; unsigned short lvl; int ifdseq; unsigned int override; struct exiftag *tagset; struct exifprop *par; struct exifprop *next; }

user_defined_types: struct exiftags { struct exifprop *props; struct tiffmeta md; char *model; short mkrval; struct tiffmeta mkrmd; short exifmaj; short exifmin; }

user_defined_types: struct tiffmeta { enum byteorder order; unsigned char *btiff; unsigned char *etiff; void *ifdoffs; }

user_defined_types: struct exiftag { unsigned int tag; unsigned int type; unsigned int count; unsigned short lvl; char *name; char *descr; struct descrip *table; }