decompiled_code:
void __fastcall __noreturn handle_error(unsigned int a1)
{
if ( a1 != -11 )
{
if ( a1 != -3 )
{
if ( a1 != -1 )
{
if ( a1 != -49 )
{
if ( a1 != -51 )
{
if ( a1 != -50 )
{
if ( a1 != -42 )
{
if ( a1 != -43 )
{
if ( a1 != -36 )
{
if ( a1 != -34 )
{
if ( a1 != -33 )
{
if ( a1 != -31 )
{
if ( a1 != -57 )
{
if ( a1 != -56 )
{
if ( a1 != -40 )
{
if ( a1 != -48 )
{
if ( a1 != -52 )
{
if ( a1 != -46 )
{
if ( a1 != -38 )
{
if ( a1 != -59 )
{
if ( a1 != -32 )
{
if ( a1 != -44 )
{
if ( a1 != -45 )
{
if ( a1 != -35 )
{
if ( a1 != -41 )
{
if ( a1 != -30 )
{
if ( a1 != -53 )
{
if ( a1 != -54 )
{
if ( a1 != -55 )
{
if ( a1 != -4 )
{
if ( a1 != -5 )
{
if ( a1 != -6 )
{
fprintf(stderr, "Unknown OpenCL Error: %d\n", a1);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_OUT_OF_HOST_MEMORY (%d)\n",
4294967290LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_OUT_OF_RESOURCES (%d)\n",
4294967291LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_MEM_OBJECT_ALLOCATION_FAILURE (%d)\n",
4294967292LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_WORK_ITEM_SIZE (%d)\n",
4294967241LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_WORK_GROUP_SIZE (%d)\n",
4294967242LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_WORK_DIMENSION (%d)\n",
4294967243LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_VALUE (%d)\n",
4294967266LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_SAMPLER (%d)\n",
4294967255LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_QUEUE_PROPERTIES (%d)\n",
4294967261LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_PROGRAM_EXECUTABLE (%d)\n",
4294967251LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_PROGRAM (%d)\n", 4294967252LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_PLATFORM (%d)\n", 4294967264LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_OPERATION (%d)\n", 4294967237LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_MEM_OBJECT (%d)\n", 4294967258LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_KERNEL_NAME (%d)\n", 4294967250LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_KERNEL_ARGS (%d)\n", 4294967244LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_KERNEL (%d)\n", 4294967248LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_IMAGE_SIZE (%d)\n", 4294967256LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_GLOBAL_OFFSET (%d)\n", 4294967240LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_EVENT_WAIT_LIST (%d)\n", 4294967239LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_DEVICE_TYPE (%d)\n", 4294967265LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_DEVICE (%d)\n", 4294967263LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_CONTEXT (%d)\n", 4294967262LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_COMMAND_QUEUE (%d)\n", 4294967260LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_BUILD_OPTIONS (%d)\n", 4294967253LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_BINARY (%d)\n", 4294967254LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_ARG_VALUE (%d)\n", 4294967246LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_ARG_SIZE (%d)\n", 4294967245LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_ARG_INDEX (%d)\n", 4294967247LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_DEVICE_NOT_FOUND (%d)\n", 0xFFFFFFFFLL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_COMPILER_NOT_AVAILABLE (%d)\n", 4294967293LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_BUILD_PROGRAM_FAILURE (%d)\n", 4294967285LL);
abort();
}

canonical_decompiled_code:
void __fastcall __noreturn func3(unsigned int a1)
{
if ( a1 != -11 )
{
if ( a1 != -3 )
{
if ( a1 != -1 )
{
if ( a1 != -49 )
{
if ( a1 != -51 )
{
if ( a1 != -50 )
{
if ( a1 != -42 )
{
if ( a1 != -43 )
{
if ( a1 != -36 )
{
if ( a1 != -34 )
{
if ( a1 != -33 )
{
if ( a1 != -31 )
{
if ( a1 != -57 )
{
if ( a1 != -56 )
{
if ( a1 != -40 )
{
if ( a1 != -48 )
{
if ( a1 != -52 )
{
if ( a1 != -46 )
{
if ( a1 != -38 )
{
if ( a1 != -59 )
{
if ( a1 != -32 )
{
if ( a1 != -44 )
{
if ( a1 != -45 )
{
if ( a1 != -35 )
{
if ( a1 != -41 )
{
if ( a1 != -30 )
{
if ( a1 != -53 )
{
if ( a1 != -54 )
{
if ( a1 != -55 )
{
if ( a1 != -4 )
{
if ( a1 != -5 )
{
if ( a1 != -6 )
{
fprintf(stderr, "Unknown OpenCL Error: %d\n", a1);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_OUT_OF_HOST_MEMORY (%d)\n",
4294967290LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_OUT_OF_RESOURCES (%d)\n",
4294967291LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_MEM_OBJECT_ALLOCATION_FAILURE (%d)\n",
4294967292LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_WORK_ITEM_SIZE (%d)\n",
4294967241LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_WORK_GROUP_SIZE (%d)\n",
4294967242LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_WORK_DIMENSION (%d)\n",
4294967243LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_VALUE (%d)\n",
4294967266LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_SAMPLER (%d)\n",
4294967255LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_QUEUE_PROPERTIES (%d)\n",
4294967261LL);
abort();
}
fprintf(
stderr,
"OpenCL Error: CL_INVALID_PROGRAM_EXECUTABLE (%d)\n",
4294967251LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_PROGRAM (%d)\n", 4294967252LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_PLATFORM (%d)\n", 4294967264LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_OPERATION (%d)\n", 4294967237LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_MEM_OBJECT (%d)\n", 4294967258LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_KERNEL_NAME (%d)\n", 4294967250LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_KERNEL_ARGS (%d)\n", 4294967244LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_KERNEL (%d)\n", 4294967248LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_IMAGE_SIZE (%d)\n", 4294967256LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_GLOBAL_OFFSET (%d)\n", 4294967240LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_EVENT_WAIT_LIST (%d)\n", 4294967239LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_DEVICE_TYPE (%d)\n", 4294967265LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_DEVICE (%d)\n", 4294967263LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_CONTEXT (%d)\n", 4294967262LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_COMMAND_QUEUE (%d)\n", 4294967260LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_BUILD_OPTIONS (%d)\n", 4294967253LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_BINARY (%d)\n", 4294967254LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_ARG_VALUE (%d)\n", 4294967246LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_ARG_SIZE (%d)\n", 4294967245LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_INVALID_ARG_INDEX (%d)\n", 4294967247LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_DEVICE_NOT_FOUND (%d)\n", 0xFFFFFFFFLL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_COMPILER_NOT_AVAILABLE (%d)\n", 4294967293LL);
abort();
}
fprintf(stderr, "OpenCL Error: CL_BUILD_PROGRAM_FAILURE (%d)\n", 4294967285LL);
abort();
}

original_code:
void handle_error(cl_int e) {
    if(e == -11) { fprintf(stderr, "OpenCL Error: " "CL_BUILD_PROGRAM_FAILURE" " (%d)\n", e); abort(); };
    if(e == -3) { fprintf(stderr, "OpenCL Error: " "CL_COMPILER_NOT_AVAILABLE" " (%d)\n", e); abort(); };
    if(e == -1) { fprintf(stderr, "OpenCL Error: " "CL_DEVICE_NOT_FOUND" " (%d)\n", e); abort(); };
 if(e == -49) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_ARG_INDEX" " (%d)\n", e); abort(); };
 if(e == -51) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_ARG_SIZE" " (%d)\n", e); abort(); };
 if(e == -50) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_ARG_VALUE" " (%d)\n", e); abort(); };
    if(e == -42) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_BINARY" " (%d)\n", e); abort(); };
    if(e == -43) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_BUILD_OPTIONS" " (%d)\n", e); abort(); };
    if(e == -36) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_COMMAND_QUEUE" " (%d)\n", e); abort(); };
    if(e == -34) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_CONTEXT" " (%d)\n", e); abort(); };
    if(e == -33) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_DEVICE" " (%d)\n", e); abort(); };
    if(e == -31) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_DEVICE_TYPE" " (%d)\n", e); abort(); };
    if(e == -57) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_EVENT_WAIT_LIST" " (%d)\n", e); abort(); };
    if(e == -56) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_GLOBAL_OFFSET" " (%d)\n", e); abort(); };
    if(e == -40) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_IMAGE_SIZE" " (%d)\n", e); abort(); };
    if(e == -48) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_KERNEL" " (%d)\n", e); abort(); };
    if(e == -52) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_KERNEL_ARGS" " (%d)\n", e); abort(); };
    if(e == -46) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_KERNEL_NAME" " (%d)\n", e); abort(); };
 if(e == -38) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_MEM_OBJECT" " (%d)\n", e); abort(); };
    if(e == -59) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_OPERATION" " (%d)\n", e); abort(); };
    if(e == -32) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_PLATFORM" " (%d)\n", e); abort(); };
    if(e == -44) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_PROGRAM" " (%d)\n", e); abort(); };
    if(e == -45) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_PROGRAM_EXECUTABLE" " (%d)\n", e); abort(); };
    if(e == -35) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_QUEUE_PROPERTIES" " (%d)\n", e); abort(); };
 if(e == -41) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_SAMPLER" " (%d)\n", e); abort(); };
    if(e == -30) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_VALUE" " (%d)\n", e); abort(); };
    if(e == -53) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_WORK_DIMENSION" " (%d)\n", e); abort(); };
    if(e == -54) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_WORK_GROUP_SIZE" " (%d)\n", e); abort(); };
    if(e == -55) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_WORK_ITEM_SIZE" " (%d)\n", e); abort(); };
    if(e == -4) { fprintf(stderr, "OpenCL Error: " "CL_MEM_OBJECT_ALLOCATION_FAILURE" " (%d)\n", e); abort(); };
    if(e == -5) { fprintf(stderr, "OpenCL Error: " "CL_OUT_OF_RESOURCES" " (%d)\n", e); abort(); };
    if(e == -6) { fprintf(stderr, "OpenCL Error: " "CL_OUT_OF_HOST_MEMORY" " (%d)\n", e); abort(); };
    fprintf(stderr, "Unknown OpenCL Error: %d\n", e);
    abort();
}

canonical_original_code:
void handle_error(int e) {
    if(e == -11) { fprintf(stderr, "OpenCL Error: " "CL_BUILD_PROGRAM_FAILURE" " (%d)\n", e); abort(); };
    if(e == -3) { fprintf(stderr, "OpenCL Error: " "CL_COMPILER_NOT_AVAILABLE" " (%d)\n", e); abort(); };
    if(e == -1) { fprintf(stderr, "OpenCL Error: " "CL_DEVICE_NOT_FOUND" " (%d)\n", e); abort(); };
 if(e == -49) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_ARG_INDEX" " (%d)\n", e); abort(); };
 if(e == -51) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_ARG_SIZE" " (%d)\n", e); abort(); };
 if(e == -50) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_ARG_VALUE" " (%d)\n", e); abort(); };
    if(e == -42) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_BINARY" " (%d)\n", e); abort(); };
    if(e == -43) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_BUILD_OPTIONS" " (%d)\n", e); abort(); };
    if(e == -36) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_COMMAND_QUEUE" " (%d)\n", e); abort(); };
    if(e == -34) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_CONTEXT" " (%d)\n", e); abort(); };
    if(e == -33) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_DEVICE" " (%d)\n", e); abort(); };
    if(e == -31) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_DEVICE_TYPE" " (%d)\n", e); abort(); };
    if(e == -57) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_EVENT_WAIT_LIST" " (%d)\n", e); abort(); };
    if(e == -56) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_GLOBAL_OFFSET" " (%d)\n", e); abort(); };
    if(e == -40) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_IMAGE_SIZE" " (%d)\n", e); abort(); };
    if(e == -48) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_KERNEL" " (%d)\n", e); abort(); };
    if(e == -52) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_KERNEL_ARGS" " (%d)\n", e); abort(); };
    if(e == -46) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_KERNEL_NAME" " (%d)\n", e); abort(); };
 if(e == -38) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_MEM_OBJECT" " (%d)\n", e); abort(); };
    if(e == -59) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_OPERATION" " (%d)\n", e); abort(); };
    if(e == -32) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_PLATFORM" " (%d)\n", e); abort(); };
    if(e == -44) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_PROGRAM" " (%d)\n", e); abort(); };
    if(e == -45) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_PROGRAM_EXECUTABLE" " (%d)\n", e); abort(); };
    if(e == -35) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_QUEUE_PROPERTIES" " (%d)\n", e); abort(); };
 if(e == -41) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_SAMPLER" " (%d)\n", e); abort(); };
    if(e == -30) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_VALUE" " (%d)\n", e); abort(); };
    if(e == -53) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_WORK_DIMENSION" " (%d)\n", e); abort(); };
    if(e == -54) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_WORK_GROUP_SIZE" " (%d)\n", e); abort(); };
    if(e == -55) { fprintf(stderr, "OpenCL Error: " "CL_INVALID_WORK_ITEM_SIZE" " (%d)\n", e); abort(); };
    if(e == -4) { fprintf(stderr, "OpenCL Error: " "CL_MEM_OBJECT_ALLOCATION_FAILURE" " (%d)\n", e); abort(); };
    if(e == -5) { fprintf(stderr, "OpenCL Error: " "CL_OUT_OF_RESOURCES" " (%d)\n", e); abort(); };
    if(e == -6) { fprintf(stderr, "OpenCL Error: " "CL_OUT_OF_HOST_MEMORY" " (%d)\n", e); abort(); };
    fprintf(stderr, "Unknown OpenCL Error: %d\n", e);
    abort();
}

variable_types: e int


repo: eholk/RustGPU

decompiled_code:
void __fastcall check_status(unsigned int a1)
{
if ( a1 )
handle_error(a1);
}

canonical_decompiled_code:
void __fastcall func4(unsigned int a1)
{
if ( a1 )
func3(a1);
}

original_code:
void check_status(cl_int e) {
    if(0 != e) {
        handle_error(e);
    }
}

canonical_original_code:
void check_status(int e) {
    if(0 != e) {
        handle_error(e);
    }
}

return_type: void


nanotime

decompiled_code:
__syscall_slong_t nanotime()
{
struct timespec v1; // [rsp+0h] [rbp-18h] BYREF

clock_gettime(1, &v1);
return v1.tv_nsec + 1000000000 * v1.tv_sec;
}

canonical_decompiled_code:
__syscall_slong_t func0()
{
struct timespec v1; // [rsp+0h] [rbp-18h] BYREF

clock_gettime(1, &v1);
return v1.tv_nsec + 1000000000 * v1.tv_sec;
}

original_code:
uint64_t nanotime() {
    uint64_t ns_per_s = 1000000000LL;
    struct timespec ts;
    clock_gettime(1, &ts);
    return (ts.tv_sec * ns_per_s + ts.tv_nsec);
}

canonical_original_code:
unsigned long nanotime() {
    unsigned long ns_per_s = 1000000000LL;
    struct timespec ts;
    clock_gettime(1, &ts);
    return (ts.tv_sec * ns_per_s + ts.tv_nsec);
}

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

return_type: unsigned long


decompiled_code:
double time_s()
{
__syscall_slong_t v0; // rax
double v1; // xmm0_8

v0 = nanotime();
if ( v0 < 0 )
v1 = (double)(int)(v0 & 1 | ((unsigned __int64)v0 >> 1)) + (double)(int)(v0 & 1 | ((unsigned __int64)v0 >> 1));
else
v1 = (double)(int)v0;
return v1 / 1000000000.0;
}

canonical_decompiled_code:
double func1()
{
__syscall_slong_t v0; // rax
double v1; // xmm0_8

v0 = func0();
if ( v0 < 0 )
v1 = (double)(int)(v0 & 1 | ((unsigned __int64)v0 >> 1)) + (double)(int)(v0 & 1 | ((unsigned __int64)v0 >> 1));
else
v1 = (double)(int)v0;
return v1 / 1000000000.0;
}

original_code:
double time_s() {
    return nanotime() / 1e9;
}

return_type: double


decompiled_code:
int __fastcall print_vector(double *a1, int a2)
{
double *v2; // rbx

putchar(91);
if ( a2 > 0 )
{
v2 = a1;
do
printf(" %f", *v2++);
while ( v2 != &a1[(unsigned int)(a2 - 1) + 1] );
}
return puts(" ]");
}

canonical_decompiled_code:
int __fastcall func2(double *a1, int a2)
{
double *v2; // rbx

putchar(91);
if ( a2 > 0 )
{
v2 = a1;
do
printf(" %f", *v2++);
while ( v2 != &a1[(unsigned int)(a2 - 1) + 1] );
}
return puts(" ]");
}

original_code:
void print_vector(double *x, int len) {
  printf("[");
  for(int i = 0; i < len; ++i) {
 printf(" %f", x[i]);
  }
  printf(" ]\n");
}

variable_types:
x
double *

variable_types: len int

variable_types: i int


repo: ehorton/horst

decompiled_code:
__int64 __fastcall device_index(int fd, const char *a2)
{
__int64 result; // rax
char v3[16]; // [rsp+0h] [rbp-48h] BYREF
unsigned int v4; // [rsp+10h] [rbp-38h]

strncpy(v3, a2, 0x10uLL);
LOWORD(v4) = 2;
if ( ioctl(fd, 0x8933uLL, v3) < 0 )
err(1, "Interface %s not found", a2);
result = v4;
if ( (v4 & 0x80000000) != 0 )
err(1, "Interface %s not found", a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int fd, const char *a2)
{
__int64 result; // rax
char v3[16]; // [rsp+0h] [rbp-48h] BYREF
unsigned int v4; // [rsp+10h] [rbp-38h]

strncpy(v3, a2, 0x10uLL);
LOWORD(v4) = 2;
if ( ioctl(fd, 0x8933uLL, v3) < 0 )
err(1, "Interface %s not found", a2);
result = v4;
if ( (v4 & 0x80000000) != 0 )
err(1, "Interface %s not found", a2);
return result;
}

original_code:
static int
device_index(int fd, const char *devname)
{
 struct ifreq req;
 strncpy(req.ifr_ifrn.ifrn_name, devname, 16);
 req.ifr_ifru.ifru_addr.sa_family = 2;
 if (ioctl(fd, 0x8933, &req) < 0)
  err(1, "Interface %s not found", devname);
 if (req.ifr_ifru.ifru_ivalue < 0)
  err(1, "Interface %s not found", devname);
 ;
 return req.ifr_ifru.ifru_ivalue;
}

canonical_original_code:
static int device_index(int fd, char *devname)
{
 struct ifreq req;
 strncpy(req.ifr_ifrn.ifrn_name, devname, 16);
 req.ifr_ifru.ifru_addr.sa_family = 2;
 if (ioctl(fd, 0x8933, &req) < 0)
  err(1, "Interface %s not found", devname);
 if (req.ifr_ifru.ifru_ivalue < 0)
  err(1, "Interface %s not found", devname);
 ;
 return req.ifr_ifru.ifru_ivalue;
}

variable_types: fd int

variable_types:
devname
char *

variable_types: struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap { unsigned long mem_start; unsigned long mem_end; unsigned short base_addr; unsigned char irq; unsigned char dma; unsigned char port; } ifru_map; char ifru_slave[16]; char ifru_newname[16]; char *ifru_data; } ifr_ifru; }

return_type: int

user_defined_types: struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap ifru_map; char ifru_slave[16]; char ifru_newname[16]; char *ifru_data; } ifr_ifru; }


decompiled_code:
int __fastcall device_promisc(int fd, const char *a2, int a3)
{
__int16 v4; // ax
__int16 v5; // ax
int result; // eax
char v7[16]; // [rsp+0h] [rbp-48h] BYREF
__int16 v8; // [rsp+10h] [rbp-38h]

strncpy(v7, a2, 0x10uLL);
v8 = 2;
if ( ioctl(fd, 0x8913uLL, v7) < 0 )
err(1, "Could not get device flags for %s", a2);
LOBYTE(v4) = v8;
HIBYTE(v4) = HIBYTE(v8) & 0xFE;
v5 = v4 | 1;
if ( a3 )
v5 = v8 | 0x101;
v8 = v5;
result = ioctl(fd, 0x8914uLL, v7);
if ( result < 0 )
err(1, "Could not set promisc mode for %s", a2);
return result;
}

canonical_decompiled_code:
int __fastcall func1(int fd, const char *a2, int a3)
{
__int16 v4; // ax
__int16 v5; // ax
int result; // eax
char v7[16]; // [rsp+0h] [rbp-48h] BYREF
__int16 v8; // [rsp+10h] [rbp-38h]

strncpy(v7, a2, 0x10uLL);
v8 = 2;
if ( ioctl(fd, 0x8913uLL, v7) < 0 )
err(1, "Could not get device flags for %s", a2);
LOBYTE(v4) = v8;
HIBYTE(v4) = HIBYTE(v8) & 0xFE;
v5 = v4 | 1;
if ( a3 )
v5 = v8 | 0x101;
v8 = v5;
result = ioctl(fd, 0x8914uLL, v7);
if ( result < 0 )
err(1, "Could not set promisc mode for %s", a2);
return result;
}

original_code:
static void
device_promisc(int fd, const char *devname, int on)
{
 struct ifreq req;
 strncpy(req.ifr_ifrn.ifrn_name, devname, 16);
 req.ifr_ifru.ifru_addr.sa_family = 2;
 if (ioctl(fd, 0x8913, &req) < 0)
  err(1, "Could not get device flags for %s", devname);
 req.ifr_ifru.ifru_flags |= IFF_UP;
 if (on)
  req.ifr_ifru.ifru_flags |= IFF_PROMISC;
 else
  req.ifr_ifru.ifru_flags &= ~IFF_PROMISC;
 if (ioctl(fd, 0x8914, &req) < 0)
  err(1, "Could not set promisc mode for %s", devname);
}

canonical_original_code:
static void device_promisc(int fd, char *devname, int on)
{
 struct ifreq req;
 strncpy(req.ifr_ifrn.ifrn_name, devname, 16);
 req.ifr_ifru.ifru_addr.sa_family = 2;
 if (ioctl(fd, 0x8913, &req) < 0)
  err(1, "Could not get device flags for %s", devname);
 req.ifr_ifru.ifru_flags |= IFF_UP;
 if (on)
  req.ifr_ifru.ifru_flags |= IFF_PROMISC;
 else
  req.ifr_ifru.ifru_flags &= ~IFF_PROMISC;
 if (ioctl(fd, 0x8914, &req) < 0)
  err(1, "Could not set promisc mode for %s", devname);
}

variable_types: on int

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }

user_defined_types: struct ifmap { unsigned long mem_start; unsigned long mem_end; unsigned short base_addr; unsigned char irq; unsigned char dma; unsigned char port; }


decompiled_code:
__int64 __fastcall device_get_arptype(int fd, const char *a2)
{
char v3[16]; // [rsp+0h] [rbp-38h] BYREF
__int64 v4; // [rsp+10h] [rbp-28h]
__int64 v5; // [rsp+18h] [rbp-20h]
__int64 v6; // [rsp+20h] [rbp-18h]

v4 = 0LL;
v5 = 0LL;
v6 = 0LL;
strncpy(v3, a2, 0x10uLL);
if ( ioctl(fd, 0x8927uLL, v3) < 0 )
err(1, "Could not get arptype");
return (unsigned __int16)v4;
}

canonical_decompiled_code:
__int64 __fastcall func4(int fd, const char *a2)
{
char v3[16]; // [rsp+0h] [rbp-38h] BYREF
__int64 v4; // [rsp+10h] [rbp-28h]
__int64 v5; // [rsp+18h] [rbp-20h]
__int64 v6; // [rsp+20h] [rbp-18h]

v4 = 0LL;
v5 = 0LL;
v6 = 0LL;
strncpy(v3, a2, 0x10uLL);
if ( ioctl(fd, 0x8927uLL, v3) < 0 )
err(1, "Could not get arptype");
return (unsigned __int16)v4;
}

original_code:
int
device_get_arptype(int fd, char* ifname)
{
 struct ifreq ifr;
 memset(&ifr, 0, sizeof(ifr));
 strncpy(ifr.ifr_ifrn.ifrn_name, ifname, sizeof(ifr.ifr_ifrn.ifrn_name));
 if (ioctl(fd, 0x8927, &ifr) < 0)
  err(1, "Could not get arptype");
 ;
 return ifr.ifr_ifru.ifru_hwaddr.sa_family;
}

canonical_original_code:
int device_get_arptype(int fd, char *ifname)
{
 struct ifreq ifr;
 memset(&ifr, 0, sizeof(ifr));
 strncpy(ifr.ifr_ifrn.ifrn_name, ifname, sizeof(ifr.ifr_ifrn.ifrn_name));
 if (ioctl(fd, 0x8927, &ifr) < 0)
  err(1, "Could not get arptype");
 ;
 return ifr.ifr_ifru.ifru_hwaddr.sa_family;
}

variable_types:
ifname
char *


decompiled_code:
__int64 __fastcall open_packet_socket(const char *a1, __int64 a2, unsigned int a3)
{
unsigned __int16 v4; // bp
int v5; // eax
unsigned int v6; // ebx
struct sockaddr v8; // [rsp+0h] [rbp-48h] BYREF
int v9; // [rsp+10h] [rbp-38h]

v4 = _bswap_16(3);
v5 = socket(17, 3, v4);
if ( v5 < 0 )
err(1, "Could not create packet socket");
v6 = v5;
*(_DWORD *)&v8.sa_data[10] = 0;
v9 = 0;
*(_QWORD *)&v8.sa_data[2] = (unsigned int)device_index(v5, a1);
v8.sa_family = 17;
*(_WORD *)v8.sa_data = v4;
if ( bind(v6, &v8, 0x14u) )
err(1, "bind failed");
device_promisc(v6, a1, 1);
if ( a3 )
set_receive_buffer(v6, a3);
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1, __int64 a2, unsigned int a3)
{
unsigned __int16 v4; // bp
int v5; // eax
unsigned int v6; // ebx
struct sockaddr v8; // [rsp+0h] [rbp-48h] BYREF
int v9; // [rsp+10h] [rbp-38h]

v4 = func2(3);
v5 = socket(17, 3, v4);
if ( v5 < 0 )
err(1, "Could not create packet socket");
v6 = v5;
*(_DWORD *)&v8.sa_data[10] = 0;
v9 = 0;
*(_QWORD *)&v8.sa_data[2] = (unsigned int)func0(v5, a1);
v8.sa_family = 17;
*(_WORD *)v8.sa_data = v4;
if ( bind(v6, &v8, 0x14u) )
err(1, "bind failed");
func1(v6, a1, 1);
if ( a3 )
func3(v6, a3);
return v6;
}

original_code:
int
open_packet_socket(char* devname, size_t bufsize, int recv_buffer_size)
{
 int ret;
 int mon_fd;
 int ifindex;
 struct sockaddr_ll sall;
 mon_fd = socket(17, SOCK_RAW, htons(0x0003));
 if (mon_fd < 0)
  err(1, "Could not create packet socket");
 ifindex = device_index(mon_fd, devname);
 memset(&sall, 0, sizeof(struct sockaddr_ll));
 sall.sll_ifindex = ifindex;
 sall.sll_family = 17;
 sall.sll_protocol = htons(0x0003);
 ret = bind(mon_fd, (struct sockaddr*)&sall, sizeof(sall));
 if (ret != 0)
  err(1, "bind failed");
 device_promisc(mon_fd, devname, 1);
 if (recv_buffer_size)
  set_receive_buffer(mon_fd, recv_buffer_size);
 return mon_fd;
}

canonical_original_code:
int open_packet_socket(char *devname, unsigned long bufsize, int recv_buffer_size)
{
 int ret;
 int mon_fd;
 int ifindex;
 struct sockaddr_ll sall;
 mon_fd = socket(17, SOCK_RAW, htons(0x0003));
 if (mon_fd < 0)
  err(1, "Could not create packet socket");
 ifindex = device_index(mon_fd, devname);
 memset(&sall, 0, sizeof(struct sockaddr_ll));
 sall.sll_ifindex = ifindex;
 sall.sll_family = 17;
 sall.sll_protocol = htons(0x0003);
 ret = bind(mon_fd, (struct sockaddr *)&sall, sizeof(sall));
 if (ret != 0)
  err(1, "bind failed");
 device_promisc(mon_fd, devname, 1);
 if (recv_buffer_size)
  set_receive_buffer(mon_fd, recv_buffer_size);
 return mon_fd;
}

variable_types:
bufsize
unsigned long

variable_types: ret int

variable_types: ifindex int

variable_types: struct sockaddr_ll { unsigned short sll_family; unsigned short sll_protocol; int sll_ifindex; unsigned short sll_hatype; unsigned char sll_pkttype; unsigned char sll_halen; unsigned char sll_addr[8]; }


decompiled_code:
ssize_t __fastcall recv_packet(int a1, void *a2, size_t a3)
{
return recv(a1, a2, a3, 64);
}

canonical_decompiled_code:
ssize_t __fastcall func6(int a1, void *a2, size_t a3)
{
return recv(a1, a2, a3, 64);
}

original_code:
inline int
recv_packet(int fd, unsigned char* buffer, size_t bufsize)
{
 return recv(fd, buffer, bufsize, MSG_DONTWAIT);
}

canonical_original_code:
inline int recv_packet(int fd, unsigned char *buffer, unsigned long bufsize)
{
 return recv(fd, buffer, bufsize, MSG_DONTWAIT);
}

variable_types:
buffer
unsigned char *


decompiled_code:
int __fastcall close_packet_socket(int fd, const char *a2)
{
int result; // eax

if ( fd > 0 )
{
device_promisc(fd, a2, 0);
result = close(fd);
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(int fd, const char *a2)
{
int result; // eax

if ( fd > 0 )
{
func1(fd, a2, 0);
result = close(fd);
}
return result;
}

original_code:
void
close_packet_socket(int fd, char* ifname)
{
 if (fd > 0) {
  device_promisc(fd, ifname, 0);
  close(fd);
 }
}

canonical_original_code:
void close_packet_socket(int fd, char *ifname)
{
 if (fd > 0) {
  device_promisc(fd, ifname, 0);
  close(fd);
 }
}


main

canonical_name: main

repo: ehsan/gl-samples

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er8
int result; // eax

v3 = SDL_Init();
result = 1;
if ( v3 >= 0 )
{
if ( SDL_SetVideoMode() )
{
glClearColor();
glClear();
glEnable();
glScissor();
glClearColor();
glClear();
SDL_GL_SwapBuffers();
SDL_Delay();
SDL_Quit();
result = 0;
}
else
{
result = 2;
}
}
return result;
}

original_code:
int
main(int argc, char *argv[])
{
   glutInit(&argc, argv);
   glutInitWindowSize(300, 300);
   glutInitDisplayMode(0x0002 | 0x0000 | 0x0010);
   glutCreateWindow("es2gears");
   glutIdleFunc (gears_idle);
   glutReshapeFunc(gears_reshape);
   glutDisplayFunc(gears_draw);
   glutSpecialFunc(gears_special);
   gears_init();
   glutMainLoop();
   return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


delProc

repo: eichlan/usersv

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

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

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

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

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

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

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


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 )
{
result = beginRunsv(i);
++v3;
}
}
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 )
{
result = func9(i);
++v3;
}
}
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 **


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
scanUsers();
while ( 1 )
{
sleep(0x1Eu);
scanProcs();
scanUsers();
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
func10();
while ( 1 )
{
sleep(0x1Eu);
func8();
func10();
}
}

original_code:
int main( int argc, char *argv[] )
{
 scanUsers();
 for(;;)
 {
  sleep( 30 );
  scanProcs();
  scanUsers();
 }
}

canonical_original_code:
int main(int argc, char *argv[])
{
 scanUsers();
 for(;;)
 {
  sleep( 30 );
  scanProcs();
  scanUsers();
 }
}


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; // ebx
int v1; // ebp
struct in_addr v2; // er12
struct in_addr v3; // er13
__int64 v4; // rdx
__int64 i; // rax
struct tm *v6; // r14
unsigned int v7; // er15
char *v8; // rax
char *v9; // rax
const char *v10; // rax
__int64 v11; // r14
unsigned __int16 v12; // r15
unsigned __int16 v13; // r14
char *v14; // rax
const char *v15; // rsi
char *v16; // rax
unsigned int v17; // ebp
const char *v18; // rsi
__int64 v19; // r13
__int64 v20; // r12
__int64 v21; // rbx
__int64 v22; // r14
char v23; // al
__int64 v24; // rbx
unsigned __int16 v25; // ax
__int64 v26; // rbx
unsigned __int16 v27; // ax
struct timeval v29; // [rsp+0h] [rbp-68h] BYREF
struct ether_addr v30; // [rsp+1Ch] [rbp-4Ch] BYREF
struct ether_addr addr; // [rsp+22h] [rbp-46h] BYREF
time_t timer; // [rsp+28h] [rbp-40h] BYREF

v0 = get_port();
v1 = get_host();
v2.s_addr = *(_DWORD *)(qword_500 + 16LL);
v3.s_addr = *(_DWORD *)(qword_500 + 12LL);
v4 = eptr;
for ( i = 0LL; i != 7; ++i )
{
addr.ether_addr_octet[i] = *(_BYTE *)(v4 + i + 6);
v30.ether_addr_octet[i] = *(_BYTE *)(v4 + i);
}
time(0LL);
v6 = gmtime(&timer);
gettimeofday(&v29, 0LL);
v7 = (unsigned __int16)_bswap_16(*(_WORD *)(eptr + 12LL));
nk_printf(
"%d:%d:%d-%ld ",
(unsigned int)v6->tm_hour,
(unsigned int)v6->tm_min,
(unsigned int)v6->tm_sec,
v29.tv_usec);
v8 = ether_ntoa(&addr);
print_mac(v8);
nk_printf("-> ");
v9 = ether_ntoa(&v30);
print_mac(v9);
LOWORD(v6) = _bswap_16(*(_WORD *)(qword_500 + 2LL));
v10 = (const char *)convert_type(v7);
nk_printf(" Type:0x%X [%s] Len:%d ", v7, v10, (unsigned __int16)v6);
v11 = tcp;
v12 = _bswap_16(*tcp);
v13 = _bswap_16(*(_WORD *)(v11 + 2));
v14 = inet_ntoa(v3);
if ( v1 )
v14 = (char *)nk_resolve(v14);
nk_printf("%s:", v14);
v15 = (const char *)convert_port(v12, v0, "tcp");
if ( v15 )
nk_printf("%s", v15);
else
nk_printf("%d", v12);
nk_printf(" -> ");
v16 = inet_ntoa(v2);
if ( v1 )
v16 = (char *)nk_resolve(v16);
nk_printf("%s:", v16);
v17 = v13;
v18 = (const char *)convert_port(v13, v0, "tcp");
if ( v18 )
nk_printf("%s ", v18);
else
nk_printf("%d ", v13);
v19 = tcp;
v20 = (unsigned __int16)_bswap_16(*(_WORD *)(tcp + 14LL));
v21 = (unsigned int)_bswap_32(*(_DWORD *)(v19 + 8));
v22 = (unsigned int)_bswap_32(*(_DWORD *)(v19 + 4));
v23 = *(_BYTE *)(v19 + 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,
((v23 >> 31) & 0x2Cu) + 45,
v22,
v21,
v20);
v24 = qword_500;
v25 = _bswap_16(*(_WORD *)(qword_500 + 4LL));
nk_printf("TOS:0x%X ID:%d TTL:%d\n\n", *(unsigned __int8 *)(v24 + 1), v25, *(unsigned __int8 *)(v24 + 8));
v26 = qword_500;
v27 = _bswap_16(*(_WORD *)(qword_500 + 2LL));
return print_payload(payload, (unsigned int)v27 - 40, v26, v17);
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int v0; // ebx
int v1; // ebp
struct in_addr v2; // er12
struct in_addr v3; // er13
__int64 v4; // rdx
__int64 i; // rax
struct tm *v6; // r14
unsigned int v7; // er15
char *v8; // rax
char *v9; // rax
const char *v10; // rax
__int64 v11; // r14
unsigned __int16 v12; // r15
unsigned __int16 v13; // r14
char *v14; // rax
const char *v15; // rsi
char *v16; // rax
unsigned int v17; // ebp
const char *v18; // rsi
__int64 v19; // r13
__int64 v20; // r12
__int64 v21; // rbx
__int64 v22; // r14
char v23; // al
__int64 v24; // rbx
unsigned __int16 v25; // ax
__int64 v26; // rbx
unsigned __int16 v27; // ax
struct timeval v29; // [rsp+0h] [rbp-68h] BYREF
struct ether_addr v30; // [rsp+1Ch] [rbp-4Ch] BYREF
struct ether_addr addr; // [rsp+22h] [rbp-46h] BYREF
time_t timer; // [rsp+28h] [rbp-40h] BYREF

v0 = get_port();
v1 = get_host();
v2.s_addr = *(_DWORD *)(qword_500 + 16LL);
v3.s_addr = *(_DWORD *)(qword_500 + 12LL);
v4 = eptr;
for ( i = 0LL; i != 7; ++i )
{
addr.ether_addr_octet[i] = *(_BYTE *)(v4 + i + 6);
v30.ether_addr_octet[i] = *(_BYTE *)(v4 + i);
}
time(0LL);
v6 = gmtime(&timer);
gettimeofday(&v29, 0LL);
v7 = (unsigned __int16)func1(*(_WORD *)(eptr + 12LL));
nk_printf(
"%d:%d:%d-%ld ",
(unsigned int)v6->tm_hour,
(unsigned int)v6->tm_min,
(unsigned int)v6->tm_sec,
v29.tv_usec);
v8 = ether_ntoa(&addr);
print_mac(v8);
nk_printf("-> ");
v9 = ether_ntoa(&v30);
print_mac(v9);
LOWORD(v6) = func1(*(_WORD *)(qword_500 + 2LL));
v10 = (const char *)convert_type(v7);
nk_printf(" Type:0x%X [%s] Len:%d ", v7, v10, (unsigned __int16)v6);
v11 = tcp;
v12 = func1(*tcp);
v13 = func1(*(_WORD *)(v11 + 2));
v14 = inet_ntoa(v3);
if ( v1 )
v14 = (char *)nk_resolve(v14);
nk_printf("%s:", v14);
v15 = (const char *)convert_port(v12, v0, "tcp");
if ( v15 )
nk_printf("%s", v15);
else
nk_printf("%d", v12);
nk_printf(" -> ");
v16 = inet_ntoa(v2);
if ( v1 )
v16 = (char *)nk_resolve(v16);
nk_printf("%s:", v16);
v17 = v13;
v18 = (const char *)convert_port(v13, v0, "tcp");
if ( v18 )
nk_printf("%s ", v18);
else
nk_printf("%d ", v13);
v19 = tcp;
v20 = (unsigned __int16)func1(*(_WORD *)(tcp + 14LL));
v21 = (unsigned int)func0(*(_DWORD *)(v19 + 8));
v22 = (unsigned int)func0(*(_DWORD *)(v19 + 4));
v23 = *(_BYTE *)(v19 + 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,
((v23 >> 31) & 0x2Cu) + 45,
v22,
v21,
v20);
v24 = qword_500;
v25 = func1(*(_WORD *)(qword_500 + 4LL));
nk_printf("TOS:0x%X ID:%d TTL:%d\n\n", *(unsigned __int8 *)(v24 + 1), v25, *(unsigned __int8 *)(v24 + 8));
v26 = qword_500;
v27 = func1(*(_WORD *)(qword_500 + 2LL));
return print_payload(payload, (unsigned int)v27 - 40, v26, v17);
}

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; // er12
struct tm *v1; // rbx
int v2; // ebp
char *v3; // rax
const char *v5; // rbx
const char *v6; // rbx
unsigned __int16 v7; // ax
const char *v8; // rax
char *v9; // rax
char *v10; // rax
unsigned __int16 v11; // ax
const char *v12; // rax
__int64 v13; // rcx
__int64 i; // rax
char *v15; // rbx
unsigned __int16 v16; // ax
const char *v17; // rax
char *v18; // rax
struct ether_addr addr; // [rsp+Ah] [rbp-3Eh] BYREF
struct timeval tv; // [rsp+10h] [rbp-38h] BYREF
time_t timer; // [rsp+28h] [rbp-20h] BYREF

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

canonical_decompiled_code:
__int64 func1()
{
int v0; // er12
struct tm *v1; // rbx
int v2; // ebp
char *v3; // rax
const char *v5; // rbx
const char *v6; // rbx
unsigned __int16 v7; // ax
const char *v8; // rax
char *v9; // rax
char *v10; // rax
unsigned __int16 v11; // ax
const char *v12; // rax
__int64 v13; // rcx
__int64 i; // rax
char *v15; // rbx
unsigned __int16 v16; // ax
const char *v17; // rax
char *v18; // rax
struct ether_addr addr; // [rsp+Ah] [rbp-3Eh] BYREF
struct timeval tv; // [rsp+10h] [rbp-38h] BYREF
time_t timer; // [rsp+28h] [rbp-20h] BYREF

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


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
const unsigned __int16 **v4; // r13
__int64 v5; // rbx
char v6; // si

result = get_payload();
if ( (_DWORD)result && a2 > 0 )
{
v4 = _ctype_b_loc();
v5 = 0LL;
do
{
v6 = *(_BYTE *)(a1 + v5);
if ( ((*v4)[v6] & 0x4000) != 0 )
nk_printf("%c", (unsigned int)v6);
else
nk_printf("0x%x ", (unsigned int)v6);
++v5;
}
while ( a2 >= (int)v5 );
result = nk_printf("\n\n");
}
return result;
}

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

result = get_payload();
if ( (_DWORD)result && a2 > 0 )
{
v4 = _ctype_b_loc();
v5 = 0LL;
do
{
v6 = *(_BYTE *)(a1 + v5);
if ( ((*v4)[v6] & 0x4000) != 0 )
nk_printf("%c", (unsigned int)v6);
else
nk_printf("0x%x ", (unsigned int)v6);
++v5;
}
while ( a2 >= (int)v5 );
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, ...)
{
char v2[8200]; // [rsp+0h] [rbp-20D8h] BYREF
gcc_va_list arg; // [rsp+2008h] [rbp-D0h] BYREF

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

canonical_decompiled_code:
int func0(char *format, ...)
{
char v2[8200]; // [rsp+0h] [rbp-20D8h] BYREF
gcc_va_list arg; // [rsp+2008h] [rbp-D0h] BYREF

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

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:
struct servent *__fastcall convert_port(__int16 a1, int a2, const char *a3)
{
struct servent *result; // rax
unsigned __int16 v5; // ax

result = 0LL;
if ( a2 )
{
v5 = _bswap_16(a1);
result = getservbyport(v5, a3);
name = (__int64)result;
if ( result )
result = (struct servent *)result->s_name;
}
return result;
}

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

result = 0LL;
if ( a2 )
{
v5 = func0(a1);
result = getservbyport(v5, a3);
name = (__int64)result;
if ( result )
result = (struct servent *)result->s_name;
}
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; // ebx
int v3; // ebp
__int64 v4; // rdx
__int64 i; // rax
struct tm *v6; // r14
unsigned int v7; // er15
char *v8; // rax
char *v9; // rax
const char *v10; // rax
__int64 v11; // r14
unsigned __int16 v12; // r15
unsigned __int16 v13; // r14
char *v14; // rax
const char *v15; // rsi
char *v16; // rax
const char *v17; // rsi
__int64 v18; // rbp
unsigned __int16 v19; // bx
unsigned __int16 v20; // ax
struct timeval v22; // [rsp+0h] [rbp-68h] BYREF
struct ether_addr v23; // [rsp+1Ch] [rbp-4Ch] BYREF
struct ether_addr addr; // [rsp+22h] [rbp-46h] BYREF
time_t timer; // [rsp+28h] [rbp-40h] BYREF

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

canonical_decompiled_code:
__int64 func1()
{
struct in_addr v0; // er12
struct in_addr v1; // er13
unsigned int v2; // ebx
int v3; // ebp
__int64 v4; // rdx
__int64 i; // rax
struct tm *v6; // r14
unsigned int v7; // er15
char *v8; // rax
char *v9; // rax
const char *v10; // rax
__int64 v11; // r14
unsigned __int16 v12; // r15
unsigned __int16 v13; // r14
char *v14; // rax
const char *v15; // rsi
char *v16; // rax
const char *v17; // rsi
__int64 v18; // rbp
unsigned __int16 v19; // bx
unsigned __int16 v20; // ax
struct timeval v22; // [rsp+0h] [rbp-68h] BYREF
struct ether_addr v23; // [rsp+1Ch] [rbp-4Ch] BYREF
struct ether_addr addr; // [rsp+22h] [rbp-46h] BYREF
time_t timer; // [rsp+28h] [rbp-40h] BYREF

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

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; // ebx
struct in_addr v1; // er12
struct in_addr v2; // ebp
__int64 v3; // rdx
__int64 i; // rax
struct tm *v5; // r13
unsigned int v6; // er14
char *v7; // rax
char *v8; // rax
const char *v9; // rax
char *v10; // rax
const char *v11; // rax
char *v12; // rax
const char *v13; // rax
unsigned int v14; // ebp
unsigned int v15; // ebx
const char *v16; // rax
__int64 v17; // rbx
__int64 v18; // rbx
unsigned __int16 v19; // ax
__int64 v20; // rbx
unsigned __int16 v21; // ax
char *v23; // rax
unsigned __int16 v24; // bp
unsigned __int16 v25; // ax
__int64 v26; // rbx
unsigned __int16 v27; // ax
struct timeval v28; // [rsp+0h] [rbp-58h] BYREF
struct ether_addr addr; // [rsp+1Ch] [rbp-3Ch] BYREF
struct ether_addr v30; // [rsp+22h] [rbp-36h] BYREF
time_t timer; // [rsp+28h] [rbp-30h] BYREF

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

canonical_decompiled_code:
__int64 func1()
{
int v0; // ebx
struct in_addr v1; // er12
struct in_addr v2; // ebp
__int64 v3; // rdx
__int64 i; // rax
struct tm *v5; // r13
unsigned int v6; // er14
char *v7; // rax
char *v8; // rax
const char *v9; // rax
char *v10; // rax
const char *v11; // rax
char *v12; // rax
const char *v13; // rax
unsigned int v14; // ebp
unsigned int v15; // ebx
const char *v16; // rax
__int64 v17; // rbx
__int64 v18; // rbx
unsigned __int16 v19; // ax
__int64 v20; // rbx
unsigned __int16 v21; // ax
char *v23; // rax
unsigned __int16 v24; // bp
unsigned __int16 v25; // ax
__int64 v26; // rbx
unsigned __int16 v27; // ax
struct timeval v28; // [rsp+0h] [rbp-58h] BYREF
struct ether_addr addr; // [rsp+1Ch] [rbp-3Ch] BYREF
struct ether_addr v30; // [rsp+22h] [rbp-36h] BYREF
time_t timer; // [rsp+28h] [rbp-30h] BYREF

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

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)
{
int v1; // er12
char v2; // bp
int v3; // ebx
char v4; // si
char v5; // dl
char v7[72]; // [rsp+0h] [rbp-48h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func0(char *src)
{
int v1; // er12
char v2; // bp
int v3; // ebx
char v4; // si
char v5; // dl
char v7[72]; // [rsp+0h] [rbp-48h] BYREF

strncpy(v7, src, 0x14uLL);
v1 = strlen(v7);
v2 = 58;
v3 = 0;
do
{
if ( v1 - 2 <= v3 )
v2 = 32;
v4 = v7[v3];
if ( v4 != 58 )
{
v5 = v7[v3 + 1];
if ( v5 == 58 )
{
nk_printf("0%c%c", (unsigned int)v4, (unsigned int)v2);
}
else
{
nk_printf("%c%c%c", (unsigned int)v4, (unsigned int)v5, (unsigned int)v2);
++v3;
}
}
v3 += 2;
}
while ( v1 >= v3 );
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_51;
if ( a1 > 2054 )
{
result = (const char *)&unk_49;
if ( a1 == 32821 )
result = "RARP";
}
else
{
result = (const char *)&unk_4A;
if ( a1 != 512 )
{
result = (const char *)&unk_49;
if ( a1 == 2048 )
result = (const char *)&unk_4E;
}
}
return result;
}

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

if ( a1 == 2054 )
return (const char *)&unk_51;
if ( a1 > 2054 )
{
result = (const char *)&unk_49;
if ( a1 == 32821 )
result = "RARP";
}
else
{
result = (const char *)&unk_4A;
if ( a1 != 512 )
{
result = (const char *)&unk_49;
if ( a1 == 2048 )
result = (const char *)&unk_4E;
}
}
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:
__int64 jpg1byte()
{
unsigned int v0; // ebx

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

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

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

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:
__int64 topmkr()
{
int v0; // edx
__int64 result; // rax

v0 = jpg1byte();
result = 256LL;
if ( v0 == 255 )
result = jpg1byte();
return result;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // edx
__int64 result; // rax

v0 = func0();
result = 256LL;
if ( v0 == 255 )
result = func0();
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:
__int64 nxtmkr()
{
int v0; // ebp
unsigned int v1; // ebx

v0 = 0;
while ( (unsigned int)jpg1byte() != 255 )
++v0;
do
v1 = jpg1byte();
while ( v1 == 255 );
if ( v0 )
exifwarn("skipped spurious bytes in JPEG");
return v1;
}

canonical_decompiled_code:
__int64 func2()
{
int v0; // ebp
unsigned int v1; // ebx

v0 = 0;
while ( (unsigned int)func0() != 255 )
++v0;
do
v1 = func0();
while ( v1 == 255 );
if ( v0 )
exifwarn("skipped spurious bytes in JPEG");
return v1;
}

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 )
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 )
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:
__int64 skipmkr()
{
__int64 result; // rax
int i; // ebx

result = mkrlen();
for ( i = result; i; --i )
result = jpg1byte();
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax
int i; // ebx

result = func4();
for ( i = result; i; --i )
result = func0();
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--;
 }
}