decompiled_code:
void __fastcall pbr_dealwith_return(__int64 a1, unsigned int a2)
{
unsigned __int16 v2; // ax
_BYTE v3[16]; // [rsp-10h] [rbp-38h] BYREF
struct timeval tv; // [rsp+0h] [rbp-28h] BYREF

if ( a1 )
{
gettimeofday(&tv, 0LL);
v2 = check_return_pk(a1, a2, &tv, v3);
if ( v2 )
{
svr_send(v2, v3, 16LL);
print_ri(v3);
}
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, unsigned int a2)
{
unsigned __int16 v2; // ax
_BYTE v3[16]; // [rsp-10h] [rbp-38h] BYREF
struct timeval tv; // [rsp+0h] [rbp-28h] BYREF

if ( a1 )
{
gettimeofday(&tv, 0LL);
v2 = check_return_pk(a1, a2, &tv, v3);
if ( v2 )
{
svr_send(v2, v3, 16LL);
print_ri(v3);
}
}
}

original_code:
void pbr_dealwith_return(const char *packet, int len)
{
    unsigned short idx;
    struct timeval rtv;
    struct return_info ri;
    if (!packet)
        return;
    gettimeofday(&rtv, ((void *)0));
    idx = check_return_pk(packet, len, &rtv, &ri);
    if (idx == 0)
        return;
    do{ svr_send(idx, (char*)&ri, sizeof(struct return_info)); print_ri(&ri); }while(0);;
    return;
}

canonical_original_code:
void pbr_dealwith_return(char *packet, int len)
{
    unsigned short idx;
    struct timeval rtv;
    struct return_info ri;
    if (!packet)
        return;
    gettimeofday(&rtv, ((void *)0));
    idx = check_return_pk(packet, len, &rtv, &ri);
    if (idx == 0)
        return;
    do{ svr_send(idx, (char *)&ri, sizeof(struct return_info)); print_ri(&ri); }while(0);;
    return;
}

variable_types: len int

variable_types:
idx
unsigned short

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

user_defined_types: struct return_info { unsigned short seq; unsigned char type; unsigned char zero1; unsigned int from; unsigned short id; unsigned char ttl; unsigned char zero2; unsigned int rtt; }


repo: YuZhang/fastrace

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

v0 = add_packet();
send_ppk();
return v0;
}

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

v0 = add_packet();
func1();
return v0;
}

original_code:
unsigned short pbr_probe(struct probing_info *pi)
{
    unsigned short idx;
    idx = add_packet(pi);
    send_ppk();
    return idx;
}

variable_types: struct probing_info { unsigned short seq; unsigned char type; unsigned char option; unsigned char ttl; unsigned char wt; unsigned short zero; unsigned int src; unsigned int dst; unsigned short sport; unsigned short dport; } *

return_type: unsigned short


decompiled_code:
__int64 __fastcall pbr_server(__int16 *a1, unsigned int a2)
{
__int16 v3; // [rsp+0h] [rbp-28h] BYREF
char v4; // [rsp+2h] [rbp-26h]

if ( (unsigned __int16)pbr_probe() )
return print_pi(a1);
fwrite("-warnning- error pbr_probe return idx", 1uLL, 0x25uLL, stderr);
fprintf(stderr, " %s:%d %s() ", "prober.c", 129LL, "pbr_server");
fputc(10, stderr);
v3 = *a1;
v4 = 0;
svr_send(a2, &v3, 16LL);
return print_ri(&v3);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int16 *a1, unsigned int a2)
{
__int16 v3; // [rsp+0h] [rbp-28h] BYREF
char v4; // [rsp+2h] [rbp-26h]

if ( (unsigned __int16)func4() )
return print_pi(a1);
fwrite("-warnning- error pbr_probe return idx", 1uLL, 0x25uLL, stderr);
fprintf(stderr, " %s:%d %s() ", "prober.c", 129LL, "pbr_server");
fputc(10, stderr);
v3 = *a1;
v4 = 0;
svr_send(a2, &v3, 16LL);
return print_ri(&v3);
}

original_code:
void pbr_server(struct probing_info *pi, int idx)
{
    struct return_info ri;
    if (pbr_probe(pi) == 0) {
        do{fprintf(stderr, "-warnning- " "error pbr_probe return idx"); fprintf(stderr, " %s:%d %s() ", "prober.c", 129, __func__); fprintf(stderr, "\n");} while(0);
        ri.seq = pi->seq;
        ri.type = 0;
        do{ svr_send(idx, (char*)&ri, sizeof(struct return_info)); print_ri(&ri); }while(0);;
        return;
    }
    print_pi(pi);
}

canonical_original_code:
void pbr_server(struct probing_info *pi, int idx)
{
    struct return_info ri;
    if (pbr_probe(pi) == 0) {
        do{fprintf(stderr, "-warnning- " "error pbr_probe return idx"); fprintf(stderr, " %s:%d %s() ", "prober.c", 129, __func__); fprintf(stderr, "\n");} while(0);
        ri.seq = pi->seq;
        ri.type = 0;
        do{ svr_send(idx, (char *)&ri, sizeof(struct return_info)); print_ri(&ri); }while(0);;
        return;
    }
    print_pi(pi);
}

variable_types: idx int

variable_types: struct return_info { unsigned short seq; unsigned char type; unsigned char zero1; unsigned int from; unsigned short id; unsigned char ttl; unsigned char zero2; unsigned int rtt; }

return_type: void

user_defined_types: struct probing_info { unsigned short seq; unsigned char type; unsigned char option; unsigned char ttl; unsigned char wt; unsigned short zero; unsigned int src; unsigned int dst; unsigned short sport; unsigned short dport; }


decompiled_code:
unsigned int pbr_start()
{
unsigned __int16 v0; // ax

pps = opt_pps;
credit = opt_pps;
v0 = getpid();
engine_ini(v0);
init_socket();
signal(14, (__sighandler_t)pbr_timer);
return alarm(1u);
}

canonical_decompiled_code:
unsigned int func6()
{
unsigned __int16 v0; // ax

pps = opt_pps;
credit = opt_pps;
v0 = getpid();
engine_ini(v0);
init_socket();
signal(14, (__sighandler_t)pbr_timer);
return alarm(1u);
}

original_code:
void pbr_start(void)
{
    _pps = _opt_pps;
    _credit = _pps;
    engine_ini(getpid() & 0xffff);
    init_socket();
    signal(14, pbr_timer);
    alarm(1);
}

canonical_original_code:
void pbr_start()
{
    _pps = _opt_pps;
    _credit = _pps;
    engine_ini(getpid() & 0xffff);
    init_socket();
    signal(14, pbr_timer);
    alarm(1);
}


decompiled_code:
void __noreturn pbr_loop()
{
__int16 *v0; // rbx
unsigned int v1; // [rsp+8h] [rbp-10h] BYREF
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

while ( 1 )
{
while ( 1 )
{
v0 = (__int16 *)svr_recv(&v1, v2);
pbr_timer_act();
if ( v2[0] != -1 )
break;
pbr_dealwith_return((__int64)v0, v1);
}
if ( (int)v2[0] > 0 && v1 == 20 )
pbr_server(v0, v2[0]);
}
}

canonical_decompiled_code:
void __noreturn func7()
{
__int16 *v0; // rbx
unsigned int v1; // [rsp+8h] [rbp-10h] BYREF
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

while ( 1 )
{
while ( 1 )
{
v0 = (__int16 *)svr_recv(&v1, v2);
func2();
if ( v2[0] != -1 )
break;
func3((__int64)v0, v1);
}
if ( (int)v2[0] > 0 && v1 == 20 )
func5(v0, v2[0]);
}
}

original_code:
void pbr_loop(void)
{
    int idx;
    const char *packet;
    int len;
    while (1) {
        packet = svr_recv(&len, &idx);
        pbr_timer_act();
        if (idx == -1) {
            pbr_dealwith_return(packet, len);
            continue;
        }
        if (idx > 0) {
            if (len != sizeof(struct probing_info))
                continue;
            pbr_server((struct probing_info *) packet, idx);
            continue;
        }
    }
}

canonical_original_code:
void pbr_loop()
{
    int idx;
    char *packet;
    int len;
    while (1) {
        packet = svr_recv(&len, &idx);
        pbr_timer_act();
        if (idx == -1) {
            pbr_dealwith_return(packet, len);
            continue;
        }
        if (idx > 0) {
            if (len != sizeof(struct probing_info))
                continue;
            pbr_server((struct probing_info *) packet, idx);
            continue;
        }
    }
}

variable_types:
packet
char *


decompiled_code:
__int64 pbr_stop()
{
signal(14, (__sighandler_t)((char *)pbr_timer + 1));
fini_socket();
return engine_fin();
}

canonical_decompiled_code:
__int64 func8()
{
signal(14, (__sighandler_t)((char *)pbr_timer + 1));
fini_socket();
return engine_fin();
}

original_code:
void pbr_stop(void)
{
    signal(14, ((__sighandler_t) 1));
    fini_socket();
    engine_fin();
}

canonical_original_code:
void pbr_stop()
{
    signal(14, ((void (*)(int)) 1));
    fini_socket();
    engine_fin();
}


original_code:
static int lasthop_subtest(int pbr, IP_t* lasthops, IP_t dst, unsigned char ttl)
{
    IP_t destination = 0;
    IP_t from = 0;
    int try_c = 0;
    unsigned char test_ttl[6];
    int test_c = 0;
    unsigned char ret=0;
    test_ttl[0] = ttl;
    test_ttl[1] = ttl+1;
    test_ttl[2] = ttl+2;
    test_ttl[3] = ttl+3;
    test_ttl[4] = ttl+4;
    test_ttl[5] = ttl-1;
    test_ttl[6] = ttl-2;
    test_ttl[7] = ttl-3;
    test_ttl[8] = ttl-4;
    for (test_c=0; test_c<9; ++test_c) {
        destination = dst;
        if (try_c>3 && test_c==1) {
            continue;
        }
        for (try_c=0; try_c<3; ++try_c) {
            if (test_ttl[test_c] <= 0) {
                break;
            }
            ret=hopping(pbr, destination, test_ttl[test_c], &from);
            if (from != 0) {
                break;
            } else {
                destination = 0;
            }
        }
        if (ret!=11 && test_c<4) {
            test_c=4;
            continue;
        }
        if (from == lasthops[0]) {
            break;
        }
        if (test_c>4 && from == lasthops[test_c-4]) {
            test_c += 5;
            break;
        }
    }
    return test_c;
}

canonical_original_code:
static int lasthop_subtest(int pbr, unsigned int *lasthops, unsigned int dst, unsigned char ttl)
{
    unsigned int destination = 0;
    unsigned int from = 0;
    int try_c = 0;
    unsigned char test_ttl[6];
    int test_c = 0;
    unsigned char ret = 0;
    test_ttl[0] = ttl;
    test_ttl[1] = ttl+1;
    test_ttl[2] = ttl+2;
    test_ttl[3] = ttl+3;
    test_ttl[4] = ttl+4;
    test_ttl[5] = ttl-1;
    test_ttl[6] = ttl-2;
    test_ttl[7] = ttl-3;
    test_ttl[8] = ttl-4;
    for (test_c=0; test_c<9; ++test_c) {
        destination = dst;
        if (try_c>3 && test_c==1) {
            continue;
        }
        for (try_c=0; try_c<3; ++try_c) {
            if (test_ttl[test_c] <= 0) {
                break;
            }
            ret=hopping(pbr, destination, test_ttl[test_c], &from);
            if (from != 0) {
                break;
            } else {
                destination = 0;
            }
        }
        if (ret!=11 && test_c<4) {
            test_c=4;
            continue;
        }
        if (from == lasthops[0]) {
            break;
        }
        if (test_c>4 && from == lasthops[test_c-4]) {
            test_c += 5;
            break;
        }
    }
    return test_c;
}

variable_types: pbr int

variable_types:
lasthops
unsigned int *

variable_types:
dst
unsigned int

variable_types:
ttl
unsigned char

variable_types:
destination
unsigned int

variable_types:
from
unsigned int

variable_types:
ret
unsigned char

return_type: int


original_code:
static void lasthop_test(int pbr, int test_pfx, const TRACE_t * trace, int pfx)
{
    IP_t lasthops[5] = {0, 0, 0, 0, 0};
    IP_t destination = 0;
    int test_count = 0;
    int same[14];
    int max_count = 1<<(test_pfx<pfx?0:(test_pfx-pfx));
    int max_host = (1<<(32-(test_pfx<pfx?pfx:test_pfx)))-4;
    int ret = 0;
    int i = 0;
    memset(same, 0, 14*sizeof(int));
    printf("LHT START %s/%u", ip2str(((trace->dst) & (0xffffffff<<(32-(pfx))))), pfx);
    if (trace->end >= 2) {
        for (i=0; i<5; ++i) {
            if (trace->end>=2+i) {
                lasthops[i] = trace->hop[trace->end-2-i];
            } else {
                lasthops[i] = 0;
            }
            printf(" %s", ip2str(lasthops[i]));
        }
        printf("\n");
        fflush(stdout);
    } else {
        printf(" No Test\n");
        printf("LHC End No Result\n\n");
        fflush(stdout);
     return;
    }
    do {
        destination = ((trace->dst) & (0xffffffff<<(32-(pfx)))) + test_count * (1 << (32-test_pfx))
            + get_rand_int(max_host) + 2;
        if (destination == trace->dst) {
            destination ^= 1;
        }
        ret = lasthop_subtest(pbr, lasthops, destination, trace->end - 1);
        ++same[ret];
        ++test_count;
    } while (test_count < max_count);
    printf("LHT END");
    for(i=0; i< 14; ++i) {
        printf(" %d", same[i]);
    }
    printf(" %d", test_count);
    printf("\n\n");
    fflush(stdout);
    return;
}

canonical_original_code:
static void lasthop_test(int pbr, int test_pfx, struct TRACE_t *trace, int pfx)
{
    unsigned int lasthops[5] = {0, 0, 0, 0, 0};
    unsigned int destination = 0;
    int test_count = 0;
    int same[14];
    int max_count = 1<<(test_pfx<pfx?0:(test_pfx-pfx));
    int max_host = (1<<(32-(test_pfx<pfx?pfx:test_pfx)))-4;
    int ret = 0;
    int i = 0;
    memset(same, 0, 14*sizeof(int));
    printf("LHT START %s/%u", ip2str(((trace->dst) & (0xffffffff<<(32-(pfx))))), pfx);
    if (trace->end >= 2) {
        for (i=0; i<5; ++i) {
            if (trace->end>=2+i) {
                lasthops[i] = trace->hop[trace->end-2-i];
            } else {
                lasthops[i] = 0;
            }
            printf(" %s", ip2str(lasthops[i]));
        }
        printf("\n");
        fflush(stdout);
    } else {
        printf(" No Test\n");
        printf("LHC End No Result\n\n");
        fflush(stdout);
     return;
    }
    do {
        destination = ((trace->dst) & (0xffffffff<<(32-(pfx)))) + test_count * (1 << (32-test_pfx))
            + get_rand_int(max_host) + 2;
        if (destination == trace->dst) {
            destination ^= 1;
        }
        ret = lasthop_subtest(pbr, lasthops, destination, trace->end - 1);
        ++same[ret];
        ++test_count;
    } while (test_count < max_count);
    printf("LHT END");
    for(i=0; i< 14; ++i) {
        printf(" %d", same[i]);
    }
    printf(" %d", test_count);
    printf("\n\n");
    fflush(stdout);
    return;
}

variable_types: struct TRACE_t { unsigned int dst; unsigned char start; unsigned char end; unsigned char ept; unsigned char rst; unsigned int hop[30]; } *

variable_types: pfx int

variable_types:
lasthops
unsigned int [5]

variable_types:
same
int [14]

variable_types: ret int

variable_types: i int


decompiled_code:
_BOOL8 __fastcall is_empty(__int64 a1)
{
return *(_QWORD *)(a1 + 8) == 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1)
{
return *(_QWORD *)(a1 + 8) == 0LL;
}

original_code:
int is_empty(STACK S)
{
    return (S->next == ((void *)0));
}

canonical_original_code:
int is_empty(struct node *S)
{
    return (S->next == ((void *)0));
}

variable_types: struct node { void *element; struct node *next; } *


top

decompiled_code:
__int64 __fastcall top(__int64 a1)
{
if ( !is_empty(a1) )
return **(_QWORD **)(a1 + 8);
fwrite("[!]", 1uLL, 3uLL, stderr);
fprintf(stderr, "%s:%s:%d: ", "top", "treetrace.c", 35LL);
fwrite("Empty stack", 1uLL, 0xBuLL, stderr);
fputc(10, stderr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
if ( !func2(a1) )
return **(_QWORD **)(a1 + 8);
fwrite("[!]", 1uLL, 3uLL, stderr);
fprintf(stderr, "%s:%s:%d: ", "top", "treetrace.c", 35LL);
fwrite("Empty stack", 1uLL, 0xBuLL, stderr);
fputc(10, stderr);
return 0LL;
}

original_code:
void *top(STACK S)
{
    if (is_empty(S)) {
        do{fprintf(stderr, "[!]"); fprintf(stderr, "%s:%s:%d: ", __func__, "treetrace.c", 35); fprintf(stderr, "Empty stack"); fprintf(stderr, "\n");} while(0);
        return ((void *)0);
    } else
        return S->next->element;
}

canonical_original_code:
void *top(struct node *S)
{
    if (is_empty(S)) {
        do{fprintf(stderr, "[!]"); fprintf(stderr, "%s:%s:%d: ", __func__, "treetrace.c", 35); fprintf(stderr, "Empty stack"); fprintf(stderr, "\n");} while(0);
        return ((void *)0);
    } else
        return S->next->element;
}

return_type: void *

user_defined_types: struct node { void *element; struct node *next; }


pop

decompiled_code:
int __fastcall pop(__int64 a1)
{
int result; // eax

if ( is_empty(a1) )
{
fwrite("[!]", 1uLL, 3uLL, stderr);
fprintf(stderr, "%s:%s:%d: ", "pop", "treetrace.c", 46LL);
fwrite("Empty stack", 1uLL, 0xBuLL, stderr);
result = fputc(10, stderr);
}
else
{
*(_QWORD *)(a1 + 8) = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL);
result = safe_free();
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
int result; // eax

if ( func2(a1) )
{
fwrite("[!]", 1uLL, 3uLL, stderr);
fprintf(stderr, "%s:%s:%d: ", "pop", "treetrace.c", 46LL);
fwrite("Empty stack", 1uLL, 0xBuLL, stderr);
result = fputc(10, stderr);
}
else
{
*(_QWORD *)(a1 + 8) = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL);
result = safe_free();
}
return result;
}

original_code:
void pop(STACK S)
{
    node_ptr first_cell;
    if (is_empty(S))
        do{fprintf(stderr, "[!]"); fprintf(stderr, "%s:%s:%d: ", __func__, "treetrace.c", 46); fprintf(stderr, "Empty stack"); fprintf(stderr, "\n");} while(0);
    else {
        first_cell = S->next;
        S->next = S->next->next;
        safe_free(first_cell);
    }
}

canonical_original_code:
void pop(struct node *S)
{
    struct node *first_cell;
    if (is_empty(S))
        do{fprintf(stderr, "[!]"); fprintf(stderr, "%s:%s:%d: ", __func__, "treetrace.c", 46); fprintf(stderr, "Empty stack"); fprintf(stderr, "\n");} while(0);
    else {
        first_cell = S->next;
        S->next = S->next->next;
        safe_free(first_cell);
    }
}


decompiled_code:
__int64 create_stack()
{
return safe_malloc(16LL);
}

canonical_decompiled_code:
__int64 func5()
{
return safe_malloc(16LL);
}

original_code:
STACK create_stack(void)
{
    STACK S;
    S = (STACK) safe_malloc(sizeof(struct node));
    return S;
}

canonical_original_code:
struct node *create_stack()
{
    struct node *S;
    S = (struct node *) safe_malloc(sizeof(struct node));
    return S;
}

return_type: struct node { void *element; struct node *next; } *


decompiled_code:
__int64 __fastcall delete_stack(__int64 a1)
{
while ( !is_empty(a1) )
pop(a1);
return safe_free(a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
while ( !func2(a1) )
func4(a1);
return safe_free(a1);
}

original_code:
void delete_stack(STACK S)
{
    while (!is_empty(S)) {
        pop(S);
    }
    safe_free(S);
}

canonical_original_code:
void delete_stack(struct node *S)
{
    while (!is_empty(S)) {
        pop(S);
    }
    safe_free(S);
}


decompiled_code:
int __fastcall normal_traceroute(unsigned int a1, unsigned int a2)
{
int result; // eax
int v3; // eax
const char *v4; // rax
const char *v5; // rbp
const char *v6; // rax
int v7; // [rsp+Ch] [rbp-9Ch] BYREF
unsigned int v8; // [rsp+10h] [rbp-98h] BYREF
char v9; // [rsp+14h] [rbp-94h]

v8 = a2;
v9 = 1;
if ( opt_verbose )
{
v5 = (const char *)now_time_db();
v6 = (const char *)ip2str(v8);
fprintf(stdout, "Fastrace %s/32 at %s", v6, v5);
fflush(stdout);
}
result = forward_traceroute(a1, &v8, 0LL);
if ( result != -1 )
{
v3 = trace_to_tab(global_map, &v8, &v7);
total_ip += v7;
total_link += v3;
v4 = (const char *)ip2str(v8);
printf("Subnet %s/32 , Normal traceroute\n", v4);
print_tr(&v8);
result = putchar(10);
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(unsigned int a1, unsigned int a2)
{
int result; // eax
int v3; // eax
const char *v4; // rax
const char *v5; // rbp
const char *v6; // rax
int v7; // [rsp+Ch] [rbp-9Ch] BYREF
unsigned int v8; // [rsp+10h] [rbp-98h] BYREF
char v9; // [rsp+14h] [rbp-94h]

v8 = a2;
v9 = 1;
if ( opt_verbose )
{
v5 = (const char *)now_time_db();
v6 = (const char *)ip2str(v8);
fprintf(stdout, "Fastrace %s/32 at %s", v6, v5);
fflush(stdout);
}
result = forward_traceroute(a1, &v8, 0LL);
if ( result != -1 )
{
v3 = trace_to_tab(global_map, &v8, &v7);
total_ip += v7;
total_link += v3;
v4 = (const char *)ip2str(v8);
printf("Subnet %s/32 , Normal traceroute\n", v4);
print_tr(&v8);
result = putchar(10);
}
return result;
}

original_code:
void normal_traceroute(int pbr, IP_t ip)
{
    TRACE_t trace;
    int nr_new_ip, nr_new_link;
    trace.dst = ip;
    trace.start = 1;
    do{if (_opt_verbose) {fprintf(stdout, "Fastrace %s/32 at %s", ip2str(trace.dst), now_time_db()); fflush(stdout);} } while(0);
    if (forward_traceroute(pbr, &trace, ((void *)0)) == -1) {
        return;
    }
    nr_new_link = trace_to_tab(_global_map, &trace, &nr_new_ip);
    _total_ip += nr_new_ip;
    _total_link += nr_new_link;
    printf("Subnet %s/32 , Normal traceroute\n", ip2str(trace.dst));
    print_tr(&trace);
    printf("\n");
    return;
}

canonical_original_code:
void normal_traceroute(int pbr, unsigned int ip)
{
    struct TRACE_t trace;
    int nr_new_ip; int nr_new_link;
    trace.dst = ip;
    trace.start = 1;
    do{if (_opt_verbose) {fprintf(stdout, "Fastrace %s/32 at %s", ip2str(trace.dst), now_time_db()); fflush(stdout);} } while(0);
    if (forward_traceroute(pbr, &trace, ((void *)0)) == -1) {
        return;
    }
    nr_new_link = trace_to_tab(_global_map, &trace, &nr_new_ip);
    _total_ip += nr_new_ip;
    _total_link += nr_new_link;
    printf("Subnet %s/32 , Normal traceroute\n", ip2str(trace.dst));
    print_tr(&trace);
    printf("\n");
    return;
}

variable_types:
ip
unsigned int

variable_types: struct TRACE_t { unsigned int dst; unsigned char start; unsigned char end; unsigned char ept; unsigned char rst; unsigned int hop[30]; }


iphash

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

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

original_code:
static INDEX iphash(IP_t key)
{
    unsigned int hash_val = 0;
    hash_val = key & 0xffff;
    return hash_val;
}

canonical_original_code:
static unsigned int iphash(unsigned int key)
{
    unsigned int hash_val = 0;
    hash_val = key & 0xffff;
    return hash_val;
}

variable_types:
key
unsigned int

return_type: unsigned int


decompiled_code:
_BOOL8 __fastcall search_ip_in_list(__int64 a1, int a2)
{
for ( ; a1; a1 = *(_QWORD *)(a1 + 8) )
{
if ( *(_DWORD *)a1 == a2 )
break;
}
return a1 != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1, int a2)
{
for ( ; a1; a1 = *(_QWORD *)(a1 + 8) )
{
if ( *(_DWORD *)a1 == a2 )
break;
}
return a1 != 0;
}

original_code:
static int search_ip_in_list(const struct iplist *ipl, IP_t ip)
{
    const struct iplist *p;
    p = ipl;
    while (p != ((void *)0) && p->ip != ip) {
        p = p->next;
    }
    if (p)
        return 1;
    else
        return 0;
}

canonical_original_code:
static int search_ip_in_list(struct iplist *ipl, unsigned int ip)
{
    struct iplist *p;
    p = ipl;
    while (p != ((void *)0) && p->ip != ip) {
        p = p->next;
    }
    if (p)
        return 1;
    else
        return 0;
}

variable_types: struct iplist { unsigned int ip; struct iplist *next; } *


decompiled_code:
_QWORD *new_ihtable()
{
_QWORD *v0; // rbx
__int64 i; // rax

v0 = (_QWORD *)safe_malloc(8LL);
*v0 = safe_malloc(0x80000LL);
for ( i = 0LL; i != 0x80000; i += 8LL )
*(_QWORD *)(*v0 + i) = 0LL;
return v0;
}

canonical_decompiled_code:
_QWORD *func2()
{
_QWORD *v0; // rbx
__int64 i; // rax

v0 = (_QWORD *)safe_malloc(8LL);
*v0 = safe_malloc(0x80000LL);
for ( i = 0LL; i != 0x80000; i += 8LL )
*(_QWORD *)(*v0 + i) = 0LL;
return v0;
}

original_code:
static IP_HASH_TABLE new_ihtable(void)
{
    IP_HASH_TABLE H;
    int i;
    H = (IP_HASH_TABLE) safe_malloc(sizeof(struct ip_hash_tbl));
    H->the_lists = (ihpos *) safe_malloc(sizeof(IHLIST) * 0x10000);
    for (i = 0; i < 0x10000; i++) {
        H->the_lists[i] = ((void *)0);
    }
    return H;
}

canonical_original_code:
static struct ip_hash_tbl *new_ihtable()
{
    struct ip_hash_tbl *H;
    int i;
    H = (struct ip_hash_tbl *) safe_malloc(sizeof(struct ip_hash_tbl));
    H->the_lists = (struct ih_list_node **) safe_malloc(sizeof(IHLIST) * 0x10000);
    for (i = 0; i < 0x10000; i++) {
        H->the_lists[i] = ((void *)0);
    }
    return H;
}

variable_types: struct ip_hash_tbl { struct ih_list_node { struct ih_element { unsigned int ip; void *info; } element; struct ih_list_node *next; } **the_lists; } *

user_defined_types: struct ip_hash_tbl { struct ih_list_node **the_lists; }

user_defined_types: struct ih_list_node { struct ih_element element; struct ih_list_node *next; }


decompiled_code:
__int64 __fastcall ih_find(_QWORD *a1, int a2)
{
__int64 result; // rax

if ( !a1 )
_assert_fail("H", "iptab.c", 0x65u, "ih_find");
for ( result = *(_QWORD *)(*a1 + 8LL * (unsigned int)iphash(a2)); result; result = *(_QWORD *)(result + 16) )
{
if ( *(_DWORD *)result == a2 )
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1, int a2)
{
__int64 result; // rax

if ( !a1 )
_assert_fail("H", "iptab.c", 0x65u, "ih_find");
for ( result = *(_QWORD *)(*a1 + 8LL * (unsigned int)func0(a2)); result; result = *(_QWORD *)(result + 16) )
{
if ( *(_DWORD *)result == a2 )
break;
}
return result;
}

original_code:
static ihpos ih_find(IP_HASH_TABLE H, IP_t key)
{
    ihpos p;
    IHLIST L;
    ((void) sizeof ((H) ? 1 : 0), __extension__ ({ if (H) ; else __assert_fail ("H", "iptab.c", 101, __extension__ __PRETTY_FUNCTION__); }));
    L = H->the_lists[iphash(key)];
    p = L;
    while ((p != ((void *)0)) && ((p->element).ip != key))
        p = p->next;
    return p;
}

canonical_original_code:
static struct ih_list_node *ih_find(struct ip_hash_tbl *H, unsigned int key)
{
    struct ih_list_node *p;
    struct ih_list_node *L;
    ((void) sizeof ((H) ? 1 : 0), __extension__ ({ if (H) ; else __assert_fail ("H", "iptab.c", 101, __extension__ __PRETTY_FUNCTION__); }));
    L = H->the_lists[iphash(key)];
    p = L;
    while ((p != ((void *)0)) && ((p->element).ip != key))
        p = p->next;
    return p;
}

variable_types: struct ip_hash_tbl { struct ih_list_node **the_lists; } *

variable_types: struct ih_list_node { struct ih_element { unsigned int ip; void *info; } element; struct ih_list_node *next; } *


decompiled_code:
__int64 __fastcall ih_insert(_QWORD *a1, int a2)
{
__int64 v2; // rbp
unsigned int v3; // eax

if ( !a1 )
_assert_fail("H", "iptab.c", 0x73u, "ih_insert");
if ( ih_find(a1, a2) )
_assert_fail("pos == NULL", "iptab.c", 0x77u, "ih_insert");
v2 = safe_malloc(24LL);
v3 = iphash(a2);
*(_QWORD *)(v2 + 16) = *(_QWORD *)(*a1 + 8LL * v3);
*(_DWORD *)v2 = a2;
*(_QWORD *)(*a1 + 8LL * v3) = v2;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1, int a2)
{
__int64 v2; // rbp
unsigned int v3; // eax

if ( !a1 )
_assert_fail("H", "iptab.c", 0x73u, "ih_insert");
if ( func3(a1, a2) )
_assert_fail("pos == NULL", "iptab.c", 0x77u, "ih_insert");
v2 = safe_malloc(24LL);
v3 = func0(a2);
*(_QWORD *)(v2 + 16) = *(_QWORD *)(*a1 + 8LL * v3);
*(_DWORD *)v2 = a2;
*(_QWORD *)(*a1 + 8LL * v3) = v2;
return v2;
}

original_code:
static ihpos ih_insert(IP_HASH_TABLE H, IP_t key)
{
    ihpos pos, new_cell;
    ((void) sizeof ((H) ? 1 : 0), __extension__ ({ if (H) ; else __assert_fail ("H", "iptab.c", 115, __extension__ __PRETTY_FUNCTION__); }));
    pos = ih_find(H, key);
    ((void) sizeof ((pos == ((void *)0)) ? 1 : 0), __extension__ ({ if (pos == ((void *)0)) ; else __assert_fail ("pos == NULL", "iptab.c", 119, __extension__ __PRETTY_FUNCTION__); }));
    new_cell = (ihpos) safe_malloc(sizeof(struct ih_list_node));
    new_cell->next = H->the_lists[iphash(key)];
    (new_cell->element).ip = key;
    H->the_lists[iphash(key)] = new_cell;
    pos = new_cell;
    return pos;
}

canonical_original_code:
static struct ih_list_node *ih_insert(struct ip_hash_tbl *H, unsigned int key)
{
    struct ih_list_node *pos; struct ih_list_node *new_cell;
    ((void) sizeof ((H) ? 1 : 0), __extension__ ({ if (H) ; else __assert_fail ("H", "iptab.c", 115, __extension__ __PRETTY_FUNCTION__); }));
    pos = ih_find(H, key);
    ((void) sizeof ((pos == ((void *)0)) ? 1 : 0), __extension__ ({ if (pos == ((void *)0)) ; else __assert_fail ("pos == NULL", "iptab.c", 119, __extension__ __PRETTY_FUNCTION__); }));
    new_cell = (struct ih_list_node *) safe_malloc(sizeof(struct ih_list_node));
    new_cell->next = H->the_lists[iphash(key)];
    (new_cell->element).ip = key;
    H->the_lists[iphash(key)] = new_cell;
    pos = new_cell;
    return pos;
}

return_type: struct ih_list_node { struct ih_element { unsigned int ip; void *info; } element; struct ih_list_node *next; } *


decompiled_code:
__int64 __fastcall del_ihtable(_QWORD *a1)
{
__int64 i; // rbp
__int64 v3; // rbx
__int64 v4; // rdi

if ( !a1 )
_assert_fail("H", "iptab.c", 0x54u, "del_ihtable");
for ( i = 0LL; i != 0x80000; i += 8LL )
{
v3 = *(_QWORD *)(*a1 + i);
while ( v3 )
{
v4 = v3;
v3 = *(_QWORD *)(v3 + 16);
safe_free(v4);
}
}
safe_free(*a1);
return safe_free(a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1)
{
__int64 i; // rbp
__int64 v3; // rbx
__int64 v4; // rdi

if ( !a1 )
_assert_fail("H", "iptab.c", 0x54u, "del_ihtable");
for ( i = 0LL; i != 0x80000; i += 8LL )
{
v3 = *(_QWORD *)(*a1 + i);
while ( v3 )
{
v4 = v3;
v3 = *(_QWORD *)(v3 + 16);
safe_free(v4);
}
}
safe_free(*a1);
return safe_free(a1);
}

original_code:
static void del_ihtable(IP_HASH_TABLE H)
{
    int i;
    ihnode_p p, q;
    ((void) sizeof ((H) ? 1 : 0), __extension__ ({ if (H) ; else __assert_fail ("H", "iptab.c", 84, __extension__ __PRETTY_FUNCTION__); }));
    for (i = 0; i < 0x10000; i++) {
        for (p = H->the_lists[i]; p != ((void *)0); p = q) {
            q = p->next;
            safe_free(p);
        }
    }
    safe_free(H->the_lists);
    safe_free(H);
}

canonical_original_code:
static void del_ihtable(struct ip_hash_tbl *H)
{
    int i;
    struct ih_list_node *p; struct ih_list_node *q;
    ((void) sizeof ((H) ? 1 : 0), __extension__ ({ if (H) ; else __assert_fail ("H", "iptab.c", 84, __extension__ __PRETTY_FUNCTION__); }));
    for (i = 0; i < 0x10000; i++) {
        for (p = H->the_lists[i]; p != ((void *)0); p = q) {
            q = p->next;
            safe_free(p);
        }
    }
    safe_free(H->the_lists);
    safe_free(H);
}

user_defined_types: struct ih_element { unsigned int ip; void *info; }


decompiled_code:
__int64 new_iptab()
{
int v0; // ebx
__int64 result; // rax

v0 = new_id_9;
if ( new_id_9 > 126 )
{
fwrite("[!]", 1uLL, 3uLL, stderr);
fprintf(stderr, "%s:%s:%d: ", "new_iptab", "iptab.c", 144LL);
fwrite("Reach max number of ip hash table", 1uLL, 0x21uLL, stderr);
fputc(10, stderr);
result = 0xFFFFFFFFLL;
}
else
{
++new_id_9;
ip_hash_table[v0] = (__int64)new_ihtable();
result = (unsigned int)new_id_9;
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
int v0; // ebx
__int64 result; // rax

v0 = new_id_9;
if ( new_id_9 > 126 )
{
fwrite("[!]", 1uLL, 3uLL, stderr);
fprintf(stderr, "%s:%s:%d: ", "new_iptab", "iptab.c", 144LL);
fwrite("Reach max number of ip hash table", 1uLL, 0x21uLL, stderr);
fputc(10, stderr);
result = 0xFFFFFFFFLL;
}
else
{
++new_id_9;
ip_hash_table[v0] = (__int64)func2();
result = (unsigned int)new_id_9;
}
return result;
}

original_code:
int new_iptab(void)
{
    static int new_id = 0;
    if (new_id + 1 >= 128) {
        do{fprintf(stderr, "[!]"); fprintf(stderr, "%s:%s:%d: ", __func__, "iptab.c", 144); fprintf(stderr, "Reach max number of ip hash table"); fprintf(stderr, "\n");} while(0);
        return -1;
    }
    new_id++;
    _ip_hash_table[new_id - 1] = new_ihtable();
    return new_id;
}

canonical_original_code:
int new_iptab()
{
    static int new_id = 0;
    if (new_id + 1 >= 128) {
        do{fprintf(stderr, "[!]"); fprintf(stderr, "%s:%s:%d: ", __func__, "iptab.c", 144); fprintf(stderr, "Reach max number of ip hash table"); fprintf(stderr, "\n");} while(0);
        return -1;
    }
    new_id++;
    _ip_hash_table[new_id - 1] = new_ihtable();
    return new_id;
}


decompiled_code:
__int64 __fastcall del_iptab(int a1)
{
if ( (unsigned int)(a1 - 1) > 0x7F )
_assert_fail("tab > 0 && tab <= MAX_NR_IPHASH_TAB", "iptab.c", 0x9Au, "del_iptab");
return del_ihtable((_QWORD *)ip_hash_table[a1 - 1]);
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
if ( (unsigned int)(a1 - 1) > 0x7F )
_assert_fail("tab > 0 && tab <= MAX_NR_IPHASH_TAB", "iptab.c", 0x9Au, "del_iptab");
return func6((_QWORD *)ip_hash_table[a1 - 1]);
}

original_code:
void del_iptab(int tab)
{
    ((void) sizeof ((tab > 0 && tab <= 128) ? 1 : 0), __extension__ ({ if (tab > 0 && tab <= 128) ; else __assert_fail ("tab > 0 && tab <= MAX_NR_IPHASH_TAB", "iptab.c", 154, __extension__ __PRETTY_FUNCTION__); }));
    del_ihtable(_ip_hash_table[tab - 1]);
}

variable_types: tab int


decompiled_code:
__int64 __fastcall find_ip_in_tab(int a1, int a2)
{
__int64 result; // rax

if ( (unsigned int)(a1 - 1) > 0x7F )
_assert_fail("tab > 0 && tab <= MAX_NR_IPHASH_TAB", "iptab.c", 0xB2u, "find_ip_in_tab");
result = ih_find((_QWORD *)ip_hash_table[a1 - 1], a2);
if ( result )
result = *(_QWORD *)(result + 8);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, int a2)
{
__int64 result; // rax

if ( (unsigned int)(a1 - 1) > 0x7F )
_assert_fail("tab > 0 && tab <= MAX_NR_IPHASH_TAB", "iptab.c", 0xB2u, "find_ip_in_tab");
result = func3((_QWORD *)ip_hash_table[a1 - 1], a2);
if ( result )
result = *(_QWORD *)(result + 8);
return result;
}

original_code:
struct ipnode *find_ip_in_tab(int tab, IP_t ip)
{
    ihpos pos;
    ((void) sizeof ((tab > 0 && tab <= 128) ? 1 : 0), __extension__ ({ if (tab > 0 && tab <= 128) ; else __assert_fail ("tab > 0 && tab <= MAX_NR_IPHASH_TAB", "iptab.c", 178, __extension__ __PRETTY_FUNCTION__); }));
    pos = ih_find(_ip_hash_table[tab - 1], ip);
    if (!pos)
        return ((void *)0);
    else
        return (struct ipnode *) ((pos->element).info);
}

canonical_original_code:
struct ipnode *find_ip_in_tab(int tab, unsigned int ip)
{
    struct ih_list_node *pos;
    ((void) sizeof ((tab > 0 && tab <= 128) ? 1 : 0), __extension__ ({ if (tab > 0 && tab <= 128) ; else __assert_fail ("tab > 0 && tab <= MAX_NR_IPHASH_TAB", "iptab.c", 178, __extension__ __PRETTY_FUNCTION__); }));
    pos = ih_find(_ip_hash_table[tab - 1], ip);
    if (!pos)
        return ((void *)0);
    else
        return (struct ipnode *) ((pos->element).info);
}

return_type: struct ipnode { unsigned int ip; unsigned char min_hop; struct iplist { unsigned int ip; struct iplist *next; } *up; struct iplist *down; } *

user_defined_types: struct ipnode { unsigned int ip; unsigned char min_hop; struct iplist *up; struct iplist *down; }


decompiled_code:
__int64 __fastcall insert_ip_to_tab(int a1, int a2)
{
__int64 v2; // rbx
__int64 result; // rax

if ( (unsigned int)(a1 - 1) > 0x7F )
_assert_fail("tab > 0 && tab <= MAX_NR_IPHASH_TAB", "iptab.c", 0xBFu, "insert_ip_to_tab");
v2 = ih_insert((_QWORD *)ip_hash_table[a1 - 1], a2);
result = safe_malloc(24LL);
*(_QWORD *)(v2 + 8) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, int a2)
{
__int64 v2; // rbx
__int64 result; // rax

if ( (unsigned int)(a1 - 1) > 0x7F )
_assert_fail("tab > 0 && tab <= MAX_NR_IPHASH_TAB", "iptab.c", 0xBFu, "insert_ip_to_tab");
v2 = func4((_QWORD *)ip_hash_table[a1 - 1], a2);
result = safe_malloc(24LL);
*(_QWORD *)(v2 + 8) = result;
return result;
}

original_code:
struct ipnode *insert_ip_to_tab(int tab, IP_t ip)
{
    ihpos pos;
    ((void) sizeof ((tab > 0 && tab <= 128) ? 1 : 0), __extension__ ({ if (tab > 0 && tab <= 128) ; else __assert_fail ("tab > 0 && tab <= MAX_NR_IPHASH_TAB", "iptab.c", 191, __extension__ __PRETTY_FUNCTION__); }));
    pos = ih_insert(_ip_hash_table[tab - 1], ip);
    (pos->element).info = (void *) safe_malloc(sizeof(struct ipnode));
    return (struct ipnode *) ((pos->element).info);
}

canonical_original_code:
struct ipnode *insert_ip_to_tab(int tab, unsigned int ip)
{
    struct ih_list_node *pos;
    ((void) sizeof ((tab > 0 && tab <= 128) ? 1 : 0), __extension__ ({ if (tab > 0 && tab <= 128) ; else __assert_fail ("tab > 0 && tab <= MAX_NR_IPHASH_TAB", "iptab.c", 191, __extension__ __PRETTY_FUNCTION__); }));
    pos = ih_insert(_ip_hash_table[tab - 1], ip);
    (pos->element).info = (void *) safe_malloc(sizeof(struct ipnode));
    return (struct ipnode *) ((pos->element).info);
}

user_defined_types: struct iplist { unsigned int ip; struct iplist *next; }


decompiled_code:
_BOOL8 __fastcall search_link_in_tab(int a1, int a2, int a3)
{
__int64 v4; // rbp
_BOOL8 result; // rax
__int64 v6; // rbx

v4 = find_ip_in_tab(a1, a2);
result = 0LL;
if ( v4 )
{
v6 = find_ip_in_tab(a1, a3);
result = 0LL;
if ( v6 )
{
result = search_ip_in_list(*(_QWORD *)(v4 + 8), a3);
if ( result )
result = search_ip_in_list(*(_QWORD *)(v6 + 8), a2);
}
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(int a1, int a2, int a3)
{
__int64 v4; // rbp
_BOOL8 result; // rax
__int64 v6; // rbx

v4 = func9(a1, a2);
result = 0LL;
if ( v4 )
{
v6 = func9(a1, a3);
result = 0LL;
if ( v6 )
{
result = func1(*(_QWORD *)(v4 + 8), a3);
if ( result )
result = func1(*(_QWORD *)(v6 + 8), a2);
}
}
return result;
}

original_code:
int search_link_in_tab(int tab, IP_t start, IP_t end)
{
    struct ipnode *sn, *en;
    if ((sn = find_ip_in_tab(tab, start)) == ((void *)0))
        return 0;
    if ((en = find_ip_in_tab(tab, end)) == ((void *)0))
        return 0;
    if (search_ip_in_list(sn->up, end) && search_ip_in_list(en->up, start))
        return 1;
    else
        return 0;
}

canonical_original_code:
int search_link_in_tab(int tab, unsigned int start, unsigned int end)
{
    struct ipnode *sn; struct ipnode *en;
    if ((sn = find_ip_in_tab(tab, start)) == ((void *)0))
        return 0;
    if ((en = find_ip_in_tab(tab, end)) == ((void *)0))
        return 0;
    if (search_ip_in_list(sn->up, end) && search_ip_in_list(en->up, start))
        return 1;
    else
        return 0;
}

variable_types:
start
unsigned int

variable_types:
end
unsigned int

variable_types: struct ipnode { unsigned int ip; unsigned char min_hop; struct iplist { unsigned int ip; struct iplist *next; } *up; struct iplist *down; } *


decompiled_code:
__int64 __fastcall insert_link_to_tab(int a1, int a2, int a3)
{
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rbp

v4 = find_ip_in_tab(a1, a2);
v5 = find_ip_in_tab(a1, a3);
if ( !v4 || (v6 = v5) == 0 )
_assert_fail("sn && en", "iptab.c", 0xF9u, "insert_link_to_tab");
add_ip_to_list((__int64 *)(v4 + 8), a3);
add_ip_to_list((__int64 *)(v6 + 8), a2);
return 1LL;
}

original_code:
int insert_link_to_tab(int tab, IP_t start, IP_t end)
{
    struct ipnode *sn, *en;
    sn = find_ip_in_tab(tab, start);
    en = find_ip_in_tab(tab, end);
    ((void) sizeof ((sn && en) ? 1 : 0), __extension__ ({ if (sn && en) ; else __assert_fail ("sn && en", "iptab.c", 249, __extension__ __PRETTY_FUNCTION__); }));
    add_ip_to_list(&(sn->up), end);
    add_ip_to_list(&(en->up), start);
    return 1;
}

canonical_original_code:
int insert_link_to_tab(int tab, unsigned int start, unsigned int end)
{
    struct ipnode *sn; struct ipnode *en;
    sn = find_ip_in_tab(tab, start);
    en = find_ip_in_tab(tab, end);
    ((void) sizeof ((sn && en) ? 1 : 0), __extension__ ({ if (sn && en) ; else __assert_fail ("sn && en", "iptab.c", 249, __extension__ __PRETTY_FUNCTION__); }));
    add_ip_to_list(&(sn->up), end);
    add_ip_to_list(&(en->up), start);
    return 1;
}


decompiled_code:
__int64 __fastcall dump_ip_from_tab(int a1)
{
unsigned int **v1; // r12
unsigned int **v2; // r13
unsigned int v3; // ebp
unsigned int *i; // rbx
const char *v5; // rax

v1 = *(unsigned int ***)ip_hash_table[a1 - 1];
v2 = v1 + 0x10000;
v3 = 0;
do
{
for ( i = *v1; i; i = (unsigned int *)*((_QWORD *)i + 2) )
{
v5 = (const char *)ip2str(*i);
printf("<N> %s\n", v5);
++v3;
}
++v1;
}
while ( v1 != v2 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func14(int a1)
{
unsigned int **v1; // r12
unsigned int **v2; // r13
unsigned int v3; // ebp
unsigned int *i; // rbx
const char *v5; // rax

v1 = *(unsigned int ***)ip_hash_table[a1 - 1];
v2 = v1 + 0x10000;
v3 = 0;
do
{
for ( i = *v1; i; i = (unsigned int *)*((_QWORD *)i + 2) )
{
v5 = (const char *)ip2str(*i);
printf("<N> %s\n", v5);
++v3;
}
++v1;
}
while ( v1 != v2 );
return v3;
}

original_code:
int dump_ip_from_tab(int tab)
{
    IHLIST *L = _ip_hash_table[tab - 1]->the_lists;
    int i;
    ihpos p;
    int c = 0;
    for (i = 0; i < 0x10000; i++) {
        p = L[i];
        for (p = L[i]; (p != ((void *)0)); p = p->next) {
            printf("<N> %s\n", ip2str((p->element).ip));
            c++;
        }
    }
    return c;
}

canonical_original_code:
int dump_ip_from_tab(int tab)
{
    struct ih_list_node **L = _ip_hash_table[tab - 1]->the_lists;
    int i;
    struct ih_list_node *p;
    int c = 0;
    for (i = 0; i < 0x10000; i++) {
        p = L[i];
        for (p = L[i]; (p != ((void *)0)); p = p->next) {
            printf("<N> %s\n", ip2str((p->element).ip));
            c++;
        }
    }
    return c;
}

variable_types: struct ih_list_node { struct ih_element { unsigned int ip; void *info; } element; struct ih_list_node *next; } **

variable_types: c int


decompiled_code:
__int64 __fastcall dump_link_from_tab(int a1)
{
unsigned int **v1; // r13
unsigned int **v2; // r14
unsigned int v3; // er12
unsigned int *v4; // rbx
__int64 v5; // rdi
const char *v6; // rax
unsigned int *i; // rbp
const char *v8; // rax
char v10[72]; // [rsp+0h] [rbp-48h] BYREF

v1 = *(unsigned int ***)ip_hash_table[a1 - 1];
v2 = v1 + 0x10000;
v3 = 0;
do
{
for ( i = *v1; i; i = (unsigned int *)*((_QWORD *)i + 2) )
{
v4 = *(unsigned int **)(*((_QWORD *)i + 1) + 8LL);
v8 = (const char *)ip2str(*i);
strcpy(v10, v8);
for ( ; v4; v4 = (unsigned int *)*((_QWORD *)v4 + 1) )
{
v5 = *v4;
if ( *i < (unsigned int)v5 )
{
v6 = (const char *)ip2str(v5);
printf("<L> %s %s\n", v10, v6);
++v3;
}
}
}
++v1;
}
while ( v2 != v1 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func15(int a1)
{
unsigned int **v1; // r13
unsigned int **v2; // r14
unsigned int v3; // er12
unsigned int *v4; // rbx
__int64 v5; // rdi
const char *v6; // rax
unsigned int *i; // rbp
const char *v8; // rax
char v10[72]; // [rsp+0h] [rbp-48h] BYREF

v1 = *(unsigned int ***)ip_hash_table[a1 - 1];
v2 = v1 + 0x10000;
v3 = 0;
do
{
for ( i = *v1; i; i = (unsigned int *)*((_QWORD *)i + 2) )
{
v4 = *(unsigned int **)(*((_QWORD *)i + 1) + 8LL);
v8 = (const char *)ip2str(*i);
strcpy(v10, v8);
for ( ; v4; v4 = (unsigned int *)*((_QWORD *)v4 + 1) )
{
v5 = *v4;
if ( *i < (unsigned int)v5 )
{
v6 = (const char *)ip2str(v5);
printf("<L> %s %s\n", v10, v6);
++v3;
}
}
}
++v1;
}
while ( v2 != v1 );
return v3;
}

original_code:
int dump_link_from_tab(int tab)
{
    IHLIST *L = _ip_hash_table[tab - 1]->the_lists;
    int i;
    char ipstr[20];
    ihpos p;
    int c = 0;
    for (i = 0; i < 0x10000; i++) {
        p = L[i];
        for (p = L[i]; (p != ((void *)0)); p = p->next) {
            struct ipnode *inp = (struct ipnode *) ((p->element).info);
            struct iplist *ilp = inp->up;
            sprintf(ipstr, "%s", ip2str((p->element).ip));
            for (; ilp != ((void *)0); ilp = ilp->next) {
                if ((p->element).ip < ilp->ip) {
                    printf("<L> %s %s\n", ipstr, ip2str(ilp->ip));
                    c++;
                }
            }
        }
    }
    return c;
}

canonical_original_code:
int dump_link_from_tab(int tab)
{
    struct ih_list_node **L = _ip_hash_table[tab - 1]->the_lists;
    int i;
    char ipstr[20];
    struct ih_list_node *p;
    int c = 0;
    for (i = 0; i < 0x10000; i++) {
        p = L[i];
        for (p = L[i]; (p != ((void *)0)); p = p->next) {
            struct ipnode *inp = (struct ipnode *) ((p->element).info);
            struct iplist *ilp = inp->up;
            sprintf(ipstr, "%s", ip2str((p->element).ip));
            for (; ilp != ((void *)0); ilp = ilp->next) {
                if ((p->element).ip < ilp->ip) {
                    printf("<L> %s %s\n", ipstr, ip2str(ilp->ip));
                    c++;
                }
            }
        }
    }
    return c;
}

variable_types:
ipstr
char [20]


iffinder

decompiled_code:
__int64 __fastcall iffinder(unsigned int a1, unsigned int a2, _DWORD *a3)
{
__int64 v4; // rax
int v5; // eax
const char *v6; // rax
__int64 result; // rax
const char *v8; // rax
const char *v9; // rax
__int16 v10; // [rsp+8h] [rbp-20h] BYREF
char v11; // [rsp+Bh] [rbp-1Dh] BYREF
int v12[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v12[0] = 3;
v11 = 5;
v10 = get_rand_int(4080LL) + 28672;
if ( a1 - 1 > 0x7E || !a3 )
_assert_fail("pbr <= MAX_PBR_ID && pbr > 0 && from", "ally.c", 0x19u, "iffinder");
v4 = ping(a1, a2, v12, &v11, &v10);
if ( v4 && (v5 = *(_DWORD *)(v4 + 4), *a3 = v5, v5 != a2) && v5 )
{
v8 = (const char *)ip2str(a2);
printf("An interface on %s", v8);
v9 = (const char *)ip2str((unsigned int)*a3);
printf(" is %s\n", v9);
result = 1LL;
}
else
{
v6 = (const char *)ip2str(a2);
printf("No new interface found on %s\n", v6);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, unsigned int a2, _DWORD *a3)
{
__int64 v4; // rax
int v5; // eax
const char *v6; // rax
__int64 result; // rax
const char *v8; // rax
const char *v9; // rax
__int16 v10; // [rsp+8h] [rbp-20h] BYREF
char v11; // [rsp+Bh] [rbp-1Dh] BYREF
int v12[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v12[0] = 3;
v11 = 5;
v10 = get_rand_int(4080LL) + 28672;
if ( a1 - 1 > 0x7E || !a3 )
_assert_fail("pbr <= MAX_PBR_ID && pbr > 0 && from", "ally.c", 0x19u, "iffinder");
v4 = ping(a1, a2, v12, &v11, &v10);
if ( v4 && (v5 = *(_DWORD *)(v4 + 4), *a3 = v5, v5 != a2) && v5 )
{
v8 = (const char *)ip2str(a2);
printf("An interface on %s", v8);
v9 = (const char *)ip2str((unsigned int)*a3);
printf(" is %s\n", v9);
result = 1LL;
}
else
{
v6 = (const char *)ip2str(a2);
printf("No new interface found on %s\n", v6);
result = 0LL;
}
return result;
}

original_code:
int iffinder(int pbr, IP_t dst, IP_t * from)
{
    int nr_try = 3;
    const struct return_info *ri;
    unsigned char ptype = 5;
    unsigned short dport = 0x7000 + get_rand_int(0x0ff0);
    ((void) sizeof ((pbr <= 127 && pbr > 0 && from) ? 1 : 0), __extension__ ({ if (pbr <= 127 && pbr > 0 && from) ; else __assert_fail ("pbr <= MAX_PBR_ID && pbr > 0 && from", "ally.c", 25, __extension__ __PRETTY_FUNCTION__); }));
    if ((ri = ping(pbr, dst, &nr_try, &ptype, &dport)) == ((void *)0)) {
        goto Nofound;
    }
    *from = ri->from;
    if (*from == 0) {
        goto Nofound;
    }
    if (*from != dst) {
        printf("An interface on %s", ip2str(dst));
        printf(" is %s\n", ip2str(*from));
        return 1;
    }
  Nofound:
    printf("No new interface found on %s\n", ip2str(dst));
    return 0;
}

canonical_original_code:
int iffinder(int pbr, unsigned int dst, unsigned int *from)
{
    int nr_try = 3;
    struct return_info *ri;
    unsigned char ptype = 5;
    unsigned short dport = 0x7000 + get_rand_int(0x0ff0);
    ((void) sizeof ((pbr <= 127 && pbr > 0 && from) ? 1 : 0), __extension__ ({ if (pbr <= 127 && pbr > 0 && from) ; else __assert_fail ("pbr <= MAX_PBR_ID && pbr > 0 && from", "ally.c", 25, __extension__ __PRETTY_FUNCTION__); }));
    if ((ri = ping(pbr, dst, &nr_try, &ptype, &dport)) == ((void *)0)) {
        goto Nofound;
    }
    *from = ri->from;
    if (*from == 0) {
        goto Nofound;
    }
    if (*from != dst) {
        printf("An interface on %s", ip2str(dst));
        printf(" is %s\n", ip2str(*from));
        return 1;
    }
  Nofound:
    printf("No new interface found on %s\n", ip2str(dst));
    return 0;
}

variable_types: pbr int

variable_types:
dst
unsigned int

variable_types:
from
unsigned int *

variable_types: struct return_info { unsigned short seq; unsigned char type; unsigned char zero1; unsigned int from; unsigned short id; unsigned char ttl; unsigned char zero2; unsigned int rtt; } *

variable_types:
ptype
unsigned char

variable_types:
dport
unsigned short


before

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

v2 = a1 - a2;
if ( v2 <= 0x7FFF )
{
if ( v2 < -32768 )
v2 += 0xFFFF;
}
else
{
v2 -= 0xFFFF;
}
return (unsigned int)v2 >> 31;
}

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

v2 = a1 - a2;
if ( v2 <= 0x7FFF )
{
if ( v2 < -32768 )
v2 += 0xFFFF;
}
else
{
v2 -= 0xFFFF;
}
return (unsigned int)v2 >> 31;
}

original_code:
int before(unsigned short seq1, unsigned short seq2)
{
    int diff = seq1 - seq2;
    if (diff > 32767) {
        diff -= 65535;
    } else {
        if (diff < -32768) {
            diff += 65535;
        }
    }
    return diff < 0 ? 1 : 0;
}

variable_types: diff int


ally

decompiled_code:
__int64 __fastcall ally(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v4; // rax
unsigned __int16 v5; // r15
char v6; // r13
__int64 v7; // rax
unsigned __int16 v8; // r14
const char *v9; // rax
const char *v10; // rax
__int64 result; // rax
__int64 v12; // rax
char v13; // r15
__int64 v14; // rax
__int64 v15; // rbx
unsigned __int16 v16; // bx
const char *v17; // rax
const char *v18; // rax
unsigned __int16 v19; // [rsp+Eh] [rbp-4Ah]
__int16 v20; // [rsp+18h] [rbp-40h] BYREF
char v21; // [rsp+1Bh] [rbp-3Dh] BYREF
int v22[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v22[0] = 0;
v21 = 0;
v20 = 0;
if ( (unsigned int)(a1 - 1) > 0x7E )
_assert_fail("pbr <= MAX_PBR_ID && pbr > 0", "ally.c", 0x4Fu, "ally");
v22[0] = 3;
v4 = ping(a1, a2, v22, &v21, &v20);
if ( !v4 )
goto LABEL_7;
v5 = *(_WORD *)(v4 + 8);
v6 = *(_BYTE *)(v4 + 2);
v22[0] = 3;
v7 = ping((unsigned int)a1, a3, v22, &v21, &v20);
if ( !v7 )
goto LABEL_7;
if ( (v6 == 0) == *(_BYTE *)(v7 + 2) )
goto LABEL_7;
v8 = *(_WORD *)(v7 + 8);
if ( !(unsigned int)before(v5, v8) )
goto LABEL_7;
if ( !(unsigned int)before(v8, v5 + 200) )
goto LABEL_7;
v22[0] = 3;
v12 = ping((unsigned int)a1, (unsigned int)a2, v22, &v21, &v20);
if ( !v12 )
goto LABEL_7;
v19 = *(_WORD *)(v12 + 8);
v13 = *(_BYTE *)(v12 + 2);
v22[0] = 3;
v14 = ping((unsigned int)a1, a3, v22, &v21, &v20);
v15 = v14;
if ( v14
&& *(_BYTE *)(v14 + 2) == v6
&& v6 == v13
&& (unsigned int)before(v8, v19)
&& (v16 = *(_WORD *)(v15 + 8), (unsigned int)before(v19, v16))
&& (unsigned int)before(v19 - 200, v8)
&& (unsigned int)before(v16 - 200, v19) )
{
v17 = (const char *)ip2str((unsigned int)a2);
printf("Ally %s", v17);
v18 = (const char *)ip2str(a3);
printf(" and %s", v18);
puts(" OK");
result = 1LL;
}
else
{
LABEL_7:
v9 = (const char *)ip2str((unsigned int)a2);
printf("Ally %s", v9);
v10 = (const char *)ip2str(a3);
printf(" and %s", v10);
puts(" Failure");
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v4; // rax
unsigned __int16 v5; // r15
char v6; // r13
__int64 v7; // rax
unsigned __int16 v8; // r14
const char *v9; // rax
const char *v10; // rax
__int64 result; // rax
__int64 v12; // rax
char v13; // r15
__int64 v14; // rax
__int64 v15; // rbx
unsigned __int16 v16; // bx
const char *v17; // rax
const char *v18; // rax
unsigned __int16 v19; // [rsp+Eh] [rbp-4Ah]
__int16 v20; // [rsp+18h] [rbp-40h] BYREF
char v21; // [rsp+1Bh] [rbp-3Dh] BYREF
int v22[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v22[0] = 0;
v21 = 0;
v20 = 0;
if ( (unsigned int)(a1 - 1) > 0x7E )
_assert_fail("pbr <= MAX_PBR_ID && pbr > 0", "ally.c", 0x4Fu, "ally");
v22[0] = 3;
v4 = ping(a1, a2, v22, &v21, &v20);
if ( !v4 )
goto LABEL_7;
v5 = *(_WORD *)(v4 + 8);
v6 = *(_BYTE *)(v4 + 2);
v22[0] = 3;
v7 = ping((unsigned int)a1, a3, v22, &v21, &v20);
if ( !v7 )
goto LABEL_7;
if ( (v6 == 0) == *(_BYTE *)(v7 + 2) )
goto LABEL_7;
v8 = *(_WORD *)(v7 + 8);
if ( !(unsigned int)func1(v5, v8) )
goto LABEL_7;
if ( !(unsigned int)func1(v8, v5 + 200) )
goto LABEL_7;
v22[0] = 3;
v12 = ping((unsigned int)a1, (unsigned int)a2, v22, &v21, &v20);
if ( !v12 )
goto LABEL_7;
v19 = *(_WORD *)(v12 + 8);
v13 = *(_BYTE *)(v12 + 2);
v22[0] = 3;
v14 = ping((unsigned int)a1, a3, v22, &v21, &v20);
v15 = v14;
if ( v14
&& *(_BYTE *)(v14 + 2) == v6
&& v6 == v13
&& (unsigned int)func1(v8, v19)
&& (v16 = *(_WORD *)(v15 + 8), (unsigned int)func1(v19, v16))
&& (unsigned int)func1(v19 - 200, v8)
&& (unsigned int)func1(v16 - 200, v19) )
{
v17 = (const char *)ip2str((unsigned int)a2);
printf("Ally %s", v17);
v18 = (const char *)ip2str(a3);
printf(" and %s", v18);
puts(" OK");
result = 1LL;
}
else
{
LABEL_7:
v9 = (const char *)ip2str((unsigned int)a2);
printf("Ally %s", v9);
v10 = (const char *)ip2str(a3);
printf(" and %s", v10);
puts(" Failure");
result = 0LL;
}
return result;
}

original_code:
int ally(int pbr, IP_t dst1, IP_t dst2)
{
    const struct return_info *ri;
    IP_t from;
    unsigned short id[4] = { 0, 0, 0, 0 };
    unsigned char ttl[4] = { 0, 0, 0, 0 };
    unsigned char type[4] = { 0, 0, 0, 0 };
    int nr_try = 0;
    unsigned char ptype = 0;
    unsigned short dport = 0;
    ((void) sizeof ((pbr <= 127 && pbr > 0) ? 1 : 0), __extension__ ({ if (pbr <= 127 && pbr > 0) ; else __assert_fail ("pbr <= MAX_PBR_ID && pbr > 0", "ally.c", 79, __extension__ __PRETTY_FUNCTION__); }));
    nr_try = 3;
    if ((ri = ping(pbr, dst1, &nr_try, &ptype, &dport)) == ((void *)0)) {
        goto Failure;
    }
    id[0] = ri->id;
    ttl[0] = ri->ttl;
    type[0] = ri->type;
    from = ri->from;
    nr_try = 3;
    if ((ri = ping(pbr, dst2, &nr_try, &ptype, &dport)) == ((void *)0)) {
        goto Failure;
    }
    id[1] = ri->id;
    ttl[1] = ri->ttl;
    type[1] = ri->type;
    if (!type[0] == type[1]) {
        goto Failure;
    }
    if (!(before(id[0], id[1])
          && before(id[1], id[0] + 200))) {
        goto Failure;
    }
    nr_try = 3;
    if ((ri = ping(pbr, dst1, &nr_try, &ptype, &dport)) == ((void *)0)) {
        goto Failure;
    }
    id[2] = ri->id;
    ttl[2] = ri->ttl;
    type[2] = ri->type;
    nr_try = 3;
    if ((ri = ping(pbr, dst2, &nr_try, &ptype, &dport)) == ((void *)0)) {
        goto Failure;
    }
    id[3] = ri->id;
    ttl[3] = ri->ttl;
    type[3] = ri->type;
    if (!(type[2] == type[0] && type[3] == type[0])) {
        goto Failure;
    }
    if (before(id[1], id[2]) && before(id[2], id[3])
        && before(id[2] - 200, id[1]) && before(id[3] - 200, id[2])) {
        goto OK;
    } else {
        goto Failure;
    }
  OK:
    printf("Ally %s", ip2str(dst1));
    printf(" and %s", ip2str(dst2));
    printf(" OK\n");
    return 1;
  Failure:
    printf("Ally %s", ip2str(dst1));
    printf(" and %s", ip2str(dst2));
    printf(" Failure\n");
    return 0;
}

canonical_original_code:
int ally(int pbr, unsigned int dst1, unsigned int dst2)
{
    struct return_info *ri;
    unsigned int from;
    unsigned short id[4] = { 0, 0, 0, 0 };
    unsigned char ttl[4] = { 0, 0, 0, 0 };
    unsigned char type[4] = { 0, 0, 0, 0 };
    int nr_try = 0;
    unsigned char ptype = 0;
    unsigned short dport = 0;
    ((void) sizeof ((pbr <= 127 && pbr > 0) ? 1 : 0), __extension__ ({ if (pbr <= 127 && pbr > 0) ; else __assert_fail ("pbr <= MAX_PBR_ID && pbr > 0", "ally.c", 79, __extension__ __PRETTY_FUNCTION__); }));
    nr_try = 3;
    if ((ri = ping(pbr, dst1, &nr_try, &ptype, &dport)) == ((void *)0)) {
        goto Failure;
    }
    id[0] = ri->id;
    ttl[0] = ri->ttl;
    type[0] = ri->type;
    from = ri->from;
    nr_try = 3;
    if ((ri = ping(pbr, dst2, &nr_try, &ptype, &dport)) == ((void *)0)) {
        goto Failure;
    }
    id[1] = ri->id;
    ttl[1] = ri->ttl;
    type[1] = ri->type;
    if (!type[0] == type[1]) {
        goto Failure;
    }
    if (!(before(id[0], id[1])
          && before(id[1], id[0] + 200))) {
        goto Failure;
    }
    nr_try = 3;
    if ((ri = ping(pbr, dst1, &nr_try, &ptype, &dport)) == ((void *)0)) {
        goto Failure;
    }
    id[2] = ri->id;
    ttl[2] = ri->ttl;
    type[2] = ri->type;
    nr_try = 3;
    if ((ri = ping(pbr, dst2, &nr_try, &ptype, &dport)) == ((void *)0)) {
        goto Failure;
    }
    id[3] = ri->id;
    ttl[3] = ri->ttl;
    type[3] = ri->type;
    if (!(type[2] == type[0] && type[3] == type[0])) {
        goto Failure;
    }
    if (before(id[1], id[2]) && before(id[2], id[3])
        && before(id[2] - 200, id[1]) && before(id[3] - 200, id[2])) {
        goto OK;
    } else {
        goto Failure;
    }
  OK:
    printf("Ally %s", ip2str(dst1));
    printf(" and %s", ip2str(dst2));
    printf(" OK\n");
    return 1;
  Failure:
    printf("Ally %s", ip2str(dst1));
    printf(" and %s", ip2str(dst2));
    printf(" Failure\n");
    return 0;
}

variable_types:
from
unsigned int

variable_types:
id
unsigned short [4]

variable_types:
ttl
unsigned char [4]

variable_types:
type
unsigned char [4]


decompiled_code:
__int64 __fastcall get_ptype_icmp(unsigned __int8 *a1, int a2)
{
unsigned __int8 v2; // al
unsigned int v3; // edx

v2 = *a1;
if ( *a1 == 8 )
return 1;
if ( v2 > 8u )
{
v3 = 0;
if ( v2 == 11 )
v3 = (unsigned int)(a2 - 8) >= 0x1C ? 0xB : 0;
}
else
{
v3 = 7;
if ( v2 )
{
if ( v2 == 3 )
{
v3 = 0;
if ( (unsigned int)(a2 - 8) > 0x1B )
v3 = a1[1] + 12;
}
else
{
v3 = 0;
}
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 *a1, int a2)
{
unsigned __int8 v2; // al
unsigned int v3; // edx

v2 = *a1;
if ( *a1 == 8 )
return 1;
if ( v2 > 8u )
{
v3 = 0;
if ( v2 == 11 )
v3 = (unsigned int)(a2 - 8) >= 0x1C ? 0xB : 0;
}
else
{
v3 = 7;
if ( v2 )
{
if ( v2 == 3 )
{
v3 = 0;
if ( (unsigned int)(a2 - 8) > 0x1B )
v3 = a1[1] + 12;
}
else
{
v3 = 0;
}
}
}
return v3;
}

original_code:
static char get_ptype_icmp(const struct icmphdr *ihp, int size)
{
    int left_size = size;
    switch (ihp->type) {
    case 8:
        return 1;
        break;
    case 0:
        return 7;
        break;
    case 3:
        left_size -= sizeof(struct icmphdr);
        if (left_size < sizeof(struct iphdr) + 8)
            return 0;
        return 12 + ihp->code;
        break;
    case 11:
        left_size -= sizeof(struct icmphdr);
        if (left_size < sizeof(struct iphdr) + 8)
            return 0;
        return 11;
        break;
    default:
        return 0;
    }
    return 0;
}

canonical_original_code:
static char get_ptype_icmp(struct icmphdr *ihp, int size)
{
    int left_size = size;
    switch (ihp->type) {
    case 8:
        return 1;
        break;
    case 0:
        return 7;
        break;
    case 3:
        left_size -= sizeof(struct icmphdr);
        if (left_size < sizeof(struct iphdr) + 8)
            return 0;
        return 12 + ihp->code;
        break;
    case 11:
        left_size -= sizeof(struct icmphdr);
        if (left_size < sizeof(struct iphdr) + 8)
            return 0;
        return 11;
        break;
    default:
        return 0;
    }
    return 0;
}

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

variable_types: size int

return_type: char

user_defined_types: struct iphdr { unsigned int ihl; unsigned int version; 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; }


decompiled_code:
char get_ppk_type()
{
char v0; // dl
char result; // al

v0 = *(_BYTE *)(packet + 37);
result = 2;
if ( v0 != 6 )
{
result = 5;
if ( v0 != 17 )
{
result = 0;
if ( v0 == 1 )
result = *(_BYTE *)(packet + 48) == 8;
}
}
return result;
}

canonical_decompiled_code:
char func2()
{
char v0; // dl
char result; // al

v0 = *(_BYTE *)(packet + 37);
result = 2;
if ( v0 != 6 )
{
result = 5;
if ( v0 != 17 )
{
result = 0;
if ( v0 == 1 )
result = *(_BYTE *)(packet + 48) == 8;
}
}
return result;
}

original_code:
static unsigned char get_ppk_type(void)
{
    struct iphdr *ihp;
    struct icmphdr *php;
    ihp = (struct iphdr *) (_packet + sizeof(struct iphdr) +
                            sizeof(struct icmphdr));
    switch (ihp->protocol) {
    case IPPROTO_TCP:
        return 2;
        break;
    case IPPROTO_UDP:
        return 5;
        break;
    case IPPROTO_ICMP:
        php = (struct icmphdr *) ((char *) ihp + sizeof(struct iphdr));
        if (php->type == 8)
            return 1;
        else
            return 0;
        break;
    default:
        return 0;
    }
    return 0;
}

canonical_original_code:
static unsigned char get_ppk_type()
{
    struct iphdr *ihp;
    struct icmphdr *php;
    ihp = (struct iphdr *) (_packet + sizeof(struct iphdr) +
                            sizeof(struct icmphdr));
    switch (ihp->protocol) {
    case IPPROTO_TCP:
        return 2;
        break;
    case IPPROTO_UDP:
        return 5;
        break;
    case IPPROTO_ICMP:
        php = (struct icmphdr *) ((char *) ihp + sizeof(struct iphdr));
        if (php->type == 8)
            return 1;
        else
            return 0;
        break;
    default:
        return 0;
    }
    return 0;
}

variable_types: struct iphdr { unsigned int ihl; unsigned int version; 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; } *

return_type: unsigned char

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


decompiled_code:
__int64 __fastcall get_pk_type(__int64 a1, unsigned int a2)
{
__int64 result; // rax
unsigned int v3; // esi
char v4; // al

result = 0LL;
if ( a2 > 0x13 )
{
v3 = a2 - 20;
v4 = *(_BYTE *)(a1 + 9);
switch ( v4 )
{
case 6:
result = 0LL;
if ( v3 > 0x13 )
result = get_ptype_tcp(a1 + 20);
break;
case 17:
result = v3 >= 8 ? 5 : 0;
break;
case 1:
result = 0LL;
if ( v3 > 7 )
result = get_ptype_icmp((unsigned __int8 *)(a1 + 20), v3);
break;
default:
result = 0LL;
break;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2)
{
__int64 result; // rax
unsigned int v3; // esi
char v4; // al

result = 0LL;
if ( a2 > 0x13 )
{
v3 = a2 - 20;
v4 = *(_BYTE *)(a1 + 9);
switch ( v4 )
{
case 6:
result = 0LL;
if ( v3 > 0x13 )
result = func0(a1 + 20);
break;
case 17:
result = v3 >= 8 ? 5 : 0;
break;
case 1:
result = 0LL;
if ( v3 > 7 )
result = func1((unsigned __int8 *)(a1 + 20), v3);
break;
default:
result = 0LL;
break;
}
}
return result;
}

original_code:
static unsigned char get_pk_type(const char *packet, int size)
{
    struct tcphdr *thp;
    struct icmphdr *ihp;
    int left_size = size;
    if (left_size < sizeof(struct iphdr)) {
        return 0;
    }
    left_size -= sizeof(struct iphdr);
    switch (((struct iphdr *) packet)->protocol) {
    case IPPROTO_TCP:
        if (left_size < sizeof(struct tcphdr)) {
            return 0;
        }
        thp = (struct tcphdr *) (packet + sizeof(struct iphdr));
        return get_ptype_tcp(thp, left_size);
        break;
    case IPPROTO_ICMP:
        if (left_size < sizeof(struct icmphdr)) {
            return 0;
        }
        ihp = (struct icmphdr *) (packet + sizeof(struct iphdr));
        return get_ptype_icmp(ihp, left_size);
        break;
    case IPPROTO_UDP:
        if (left_size < sizeof(struct udphdr)) {
            return 0;
        }
        return 5;
        break;
    default:
        return 0;
    }
    return 0;
}

canonical_original_code:
static unsigned char get_pk_type(char *packet, int size)
{
    struct tcphdr *thp;
    struct icmphdr *ihp;
    int left_size = size;
    if (left_size < sizeof(struct iphdr)) {
        return 0;
    }
    left_size -= sizeof(struct iphdr);
    switch (((struct iphdr *) packet)->protocol) {
    case IPPROTO_TCP:
        if (left_size < sizeof(struct tcphdr)) {
            return 0;
        }
        thp = (struct tcphdr *) (packet + sizeof(struct iphdr));
        return get_ptype_tcp(thp, left_size);
        break;
    case IPPROTO_ICMP:
        if (left_size < sizeof(struct icmphdr)) {
            return 0;
        }
        ihp = (struct icmphdr *) (packet + sizeof(struct iphdr));
        return get_ptype_icmp(ihp, left_size);
        break;
    case IPPROTO_UDP:
        if (left_size < sizeof(struct udphdr)) {
            return 0;
        }
        return 5;
        break;
    default:
        return 0;
    }
    return 0;
}

variable_types:
packet
char *

variable_types: struct tcphdr { unsigned short source; unsigned short dest; unsigned int seq; unsigned int ack_seq; unsigned short res1; unsigned short doff; unsigned short fin; unsigned short syn; unsigned short rst; unsigned short psh; unsigned short ack; unsigned short urg; unsigned short res2; 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; }


decompiled_code:
_BOOL8 is_response_type()
{
_BOOL4 v0; // edx

if ( (unsigned __int8)type <= 0xAu )
{
if ( w_type == 3 )
{
v0 = (unsigned __int8)(type - 9) <= 1u;
}
else if ( (unsigned __int8)w_type > 3u )
{
v0 = type == 10;
if ( w_type != 4 )
v0 = 0;
}
else if ( w_type == 1 )
{
v0 = type == 7;
}
else if ( w_type == 2 )
{
v0 = type == 8;
}
else
{
v0 = 0;
}
}
else if ( ppk_type != 2 || (v0 = 1, (unsigned __int8)(w_type - 2) > 2u) )
{
v0 = w_type == ppk_type;
}
return v0;
}

canonical_decompiled_code:
_BOOL8 func4()
{
_BOOL4 v0; // edx

if ( (unsigned __int8)type <= 0xAu )
{
if ( w_type == 3 )
{
v0 = (unsigned __int8)(type - 9) <= 1u;
}
else if ( (unsigned __int8)w_type > 3u )
{
v0 = type == 10;
if ( w_type != 4 )
v0 = 0;
}
else if ( w_type == 1 )
{
v0 = type == 7;
}
else if ( w_type == 2 )
{
v0 = type == 8;
}
else
{
v0 = 0;
}
}
else if ( ppk_type != 2 || (v0 = 1, (unsigned __int8)(w_type - 2) > 2u) )
{
v0 = w_type == ppk_type;
}
return v0;
}

original_code:
static int is_response_type(void)
{
    if ((_type>=12?1:0) || _type == 11) {
        if (_ppk_type == 2 &&
            (_w_type == 2 || _w_type == 3 || _w_type == 4))
            return 1;
        if (_w_type == _ppk_type)
            return 1;
        else
            return 0;
    }
    switch (_w_type) {
    case 1:
        if (_type == 7)
            return 1;
        break;
    case 2:
        if (_type == 8)
            return 1;
        break;
    case 3:
        if (_type == 10 || _type == 9)
            return 1;
        break;
    case 4:
        if (_type == 10)
            return 1;
        break;
    case 5:
        return 0;
        break;
    default:
        return 0;
    }
    return 0;
}

canonical_original_code:
static int is_response_type()
{
    if ((_type>=12?1:0) || _type == 11) {
        if (_ppk_type == 2 &&
            (_w_type == 2 || _w_type == 3 || _w_type == 4))
            return 1;
        if (_w_type == _ppk_type)
            return 1;
        else
            return 0;
    }
    switch (_w_type) {
    case 1:
        if (_type == 7)
            return 1;
        break;
    case 2:
        if (_type == 8)
            return 1;
        break;
    case 3:
        if (_type == 10 || _type == 9)
            return 1;
        break;
    case 4:
        if (_type == 10)
            return 1;
        break;
    case 5:
        return 0;
        break;
    default:
        return 0;
    }
    return 0;
}


decompiled_code:
_BOOL8 is_response_port()
{
_BOOL8 result; // rax

if ( (unsigned __int8)type <= 0xAu )
{
result = 1LL;
if ( w_type != 1 )
{
result = 0LL;
if ( (unsigned __int8)(w_type - 2) <= 2u && *(_WORD *)(w_packet + 20) == *(_WORD *)(packet + 22) )
result = *(_WORD *)(w_packet + 22) == *(_WORD *)(packet + 20);
}
}
else if ( (unsigned __int8)w_type > 4u )
{
if ( w_type == 5 )
{
result = 0LL;
if ( *(_WORD *)(w_packet + 20) == *(_WORD *)(packet + 48) )
result = *(_WORD *)(w_packet + 22) == *(_WORD *)(packet + 50);
}
else
{
result = 0LL;
}
}
else if ( (unsigned __int8)w_type > 1u )
{
result = *(_DWORD *)(w_packet + 20) == *(_DWORD *)(packet + 48);
}
else
{
result = w_type == 1;
}
return result;
}

canonical_decompiled_code:
_BOOL8 func5()
{
_BOOL8 result; // rax

if ( (unsigned __int8)type <= 0xAu )
{
result = 1LL;
if ( w_type != 1 )
{
result = 0LL;
if ( (unsigned __int8)(w_type - 2) <= 2u && *(_WORD *)(w_packet + 20) == *(_WORD *)(packet + 22) )
result = *(_WORD *)(w_packet + 22) == *(_WORD *)(packet + 20);
}
}
else if ( (unsigned __int8)w_type > 4u )
{
if ( w_type == 5 )
{
result = 0LL;
if ( *(_WORD *)(w_packet + 20) == *(_WORD *)(packet + 48) )
result = *(_WORD *)(w_packet + 22) == *(_WORD *)(packet + 50);
}
else
{
result = 0LL;
}
}
else if ( (unsigned __int8)w_type > 1u )
{
result = *(_DWORD *)(w_packet + 20) == *(_DWORD *)(packet + 48);
}
else
{
result = w_type == 1;
}
return result;
}

original_code:
static int is_response_port(void)
{
    struct tcphdr *w_thp, *thp;
    struct udphdr *w_uhp, *uhp;
    if ((_type>=12?1:0) || _type == 11) {
        switch (_w_type) {
        case 1:
            return 1;
            break;
        case 2:
        case 3:
        case 4:
            w_thp = (struct tcphdr *) (_w_packet + sizeof(struct iphdr));
            thp = (struct tcphdr *) (_packet + sizeof(struct iphdr)
                                     + sizeof(struct icmphdr) +
                                     sizeof(struct iphdr));
            if (w_thp->source != thp->source || w_thp->dest != thp->dest) {
                return 0;
            }
            return 1;
            break;
        case 5:
            w_uhp = (struct udphdr *) (_w_packet + sizeof(struct iphdr));
            uhp = (struct udphdr *) (_packet + sizeof(struct iphdr)
                                     + sizeof(struct icmphdr) +
                                     sizeof(struct iphdr));
            if (w_uhp->source != uhp->source || w_uhp->dest != uhp->dest) {
                return 0;
            }
            return 1;
            break;
        default:
            return 0;
        }
    }
    switch (_w_type) {
    case 1:
        return 1;
        break;
    case 2:
    case 3:
    case 4:
        w_thp = (struct tcphdr *) (_w_packet + sizeof(struct iphdr));
        thp = (struct tcphdr *) (_packet + sizeof(struct iphdr));
        if (w_thp->source != thp->dest || w_thp->dest != thp->source) {
            return 0;
        }
        return 1;
        break;
    case 5:
        return 0;
        break;
    default:
        return 0;
    }
}

canonical_original_code:
static int is_response_port()
{
    struct tcphdr *w_thp; struct tcphdr *thp;
    struct udphdr *w_uhp; struct udphdr *uhp;
    if ((_type>=12?1:0) || _type == 11) {
        switch (_w_type) {
        case 1:
            return 1;
            break;
        case 2:
        case 3:
        case 4:
            w_thp = (struct tcphdr *) (_w_packet + sizeof(struct iphdr));
            thp = (struct tcphdr *) (_packet + sizeof(struct iphdr)
                                     + sizeof(struct icmphdr) +
                                     sizeof(struct iphdr));
            if (w_thp->source != thp->source || w_thp->dest != thp->dest) {
                return 0;
            }
            return 1;
            break;
        case 5:
            w_uhp = (struct udphdr *) (_w_packet + sizeof(struct iphdr));
            uhp = (struct udphdr *) (_packet + sizeof(struct iphdr)
                                     + sizeof(struct icmphdr) +
                                     sizeof(struct iphdr));
            if (w_uhp->source != uhp->source || w_uhp->dest != uhp->dest) {
                return 0;
            }
            return 1;
            break;
        default:
            return 0;
        }
    }
    switch (_w_type) {
    case 1:
        return 1;
        break;
    case 2:
    case 3:
    case 4:
        w_thp = (struct tcphdr *) (_w_packet + sizeof(struct iphdr));
        thp = (struct tcphdr *) (_packet + sizeof(struct iphdr));
        if (w_thp->source != thp->dest || w_thp->dest != thp->source) {
            return 0;
        }
        return 1;
        break;
    case 5:
        return 0;
        break;
    default:
        return 0;
    }
}

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

user_defined_types: struct tcphdr { unsigned short source; unsigned short dest; unsigned int seq; unsigned int ack_seq; unsigned short res1; unsigned short doff; unsigned short fin; unsigned short syn; unsigned short rst; unsigned short psh; unsigned short ack; unsigned short urg; unsigned short res2; unsigned short window; unsigned short check; unsigned short urg_ptr; }


decompiled_code:
__int16 get_pk_id()
{
__int64 v0; // rax

if ( (unsigned __int8)type <= 0xAu )
v0 = OS_ID_PK[(unsigned __int8)type];
else
v0 = OS_ID_PK[12];
return _bswap_16(*(_WORD *)(packet + v0));
}

canonical_decompiled_code:
__int16 func7()
{
__int64 v0; // rax

if ( (unsigned __int8)type <= 0xAu )
v0 = OS_ID_PK[(unsigned __int8)type];
else
v0 = OS_ID_PK[12];
return func6(*(_WORD *)(packet + v0));
}

original_code:
static unsigned short get_pk_id(void)
{
    unsigned short id;
    if ((_type>=12?1:0) || _type == 11) {
        id = *((unsigned short *) ((char*)_packet+OS_ID_PK[(int)12] ));
    } else {
        id = *((unsigned short *) ((char*)_packet+OS_ID_PK[(int)_type] ));
    }
    return ntohs(id);
}

canonical_original_code:
static unsigned short get_pk_id()
{
    unsigned short id;
    if ((_type>=12?1:0) || _type == 11) {
        id = *((unsigned short *) ((char *)_packet+OS_ID_PK[(int)12] ));
    } else {
        id = *((unsigned short *) ((char *)_packet+OS_ID_PK[(int)_type] ));
    }
    return ntohs(id);
}

variable_types:
id
unsigned short


decompiled_code:
__int64 is_response_ip()
{
__int64 v0; // rbx
unsigned int v1; // edi
__int64 result; // rax
unsigned int v3; // eax
const char *v4; // rax
unsigned int v5; // eax
const char *v6; // rax
unsigned int v7; // eax
const char *v8; // rax
unsigned int v9; // eax
const char *v10; // rax
__int64 v11; // rbx
unsigned int v12; // eax
const char *v13; // rax
unsigned int v14; // eax
const char *v15; // rax
unsigned int v16; // eax
const char *v17; // rax
unsigned int v18; // eax
const char *v19; // rax

if ( (unsigned __int8)type <= 0xAu )
{
v11 = packet;
if ( *(_DWORD *)(w_packet + 12) != *(_DWORD *)(packet + 16)
|| (result = 1LL, *(_DWORD *)(w_packet + 16) != *(_DWORD *)(packet + 12)) )
{
v12 = _bswap_32(*(_DWORD *)(packet + 12));
v13 = (const char *)ip2str(v12);
fprintf(stdout, "-debug- return from %s,", v13);
fflush(stdout);
v14 = _bswap_32(*(_DWORD *)(v11 + 16));
v15 = (const char *)ip2str(v14);
fprintf(stdout, "-debug- to %s,", v15);
fflush(stdout);
v16 = _bswap_32(*(_DWORD *)(w_packet + 12));
v17 = (const char *)ip2str(v16);
fprintf(stdout, "-debug- from %s,", v17);
fflush(stdout);
v18 = _bswap_32(*(_DWORD *)(w_packet + 16));
v19 = (const char *)ip2str(v18);
fprintf(stdout, "-debug- to %s,", v19);
fflush(stdout);
result = 0LL;
}
}
else
{
v0 = packet;
v1 = *(_DWORD *)(packet + 40);
if ( *(_DWORD *)(w_packet + 12) != v1 || (result = 1LL, *(_DWORD *)(w_packet + 16) != *(_DWORD *)(packet + 44)) )
{
v3 = _bswap_32(v1);
v4 = (const char *)ip2str(v3);
fprintf(stdout, "-debug- unreach from %s,", v4);
fflush(stdout);
v5 = _bswap_32(*(_DWORD *)(v0 + 44));
v6 = (const char *)ip2str(v5);
fprintf(stdout, "-debug- to %s,", v6);
fflush(stdout);
v7 = _bswap_32(*(_DWORD *)(w_packet + 12));
v8 = (const char *)ip2str(v7);
fprintf(stdout, "-debug- from %s,", v8);
fflush(stdout);
v9 = _bswap_32(*(_DWORD *)(w_packet + 16));
v10 = (const char *)ip2str(v9);
fprintf(stdout, "-debug- to %s,", v10);
fflush(stdout);
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 v0; // rbx
unsigned int v1; // edi
__int64 result; // rax
unsigned int v3; // eax
const char *v4; // rax
unsigned int v5; // eax
const char *v6; // rax
unsigned int v7; // eax
const char *v8; // rax
unsigned int v9; // eax
const char *v10; // rax
__int64 v11; // rbx
unsigned int v12; // eax
const char *v13; // rax
unsigned int v14; // eax
const char *v15; // rax
unsigned int v16; // eax
const char *v17; // rax
unsigned int v18; // eax
const char *v19; // rax

if ( (unsigned __int8)type <= 0xAu )
{
v11 = packet;
if ( *(_DWORD *)(w_packet + 12) != *(_DWORD *)(packet + 16)
|| (result = 1LL, *(_DWORD *)(w_packet + 16) != *(_DWORD *)(packet + 12)) )
{
v12 = func8(*(_DWORD *)(packet + 12));
v13 = (const char *)ip2str(v12);
fprintf(stdout, "-debug- return from %s,", v13);
fflush(stdout);
v14 = func8(*(_DWORD *)(v11 + 16));
v15 = (const char *)ip2str(v14);
fprintf(stdout, "-debug- to %s,", v15);
fflush(stdout);
v16 = func8(*(_DWORD *)(w_packet + 12));
v17 = (const char *)ip2str(v16);
fprintf(stdout, "-debug- from %s,", v17);
fflush(stdout);
v18 = func8(*(_DWORD *)(w_packet + 16));
v19 = (const char *)ip2str(v18);
fprintf(stdout, "-debug- to %s,", v19);
fflush(stdout);
result = 0LL;
}
}
else
{
v0 = packet;
v1 = *(_DWORD *)(packet + 40);
if ( *(_DWORD *)(w_packet + 12) != v1 || (result = 1LL, *(_DWORD *)(w_packet + 16) != *(_DWORD *)(packet + 44)) )
{
v3 = func8(v1);
v4 = (const char *)ip2str(v3);
fprintf(stdout, "-debug- unreach from %s,", v4);
fflush(stdout);
v5 = func8(*(_DWORD *)(v0 + 44));
v6 = (const char *)ip2str(v5);
fprintf(stdout, "-debug- to %s,", v6);
fflush(stdout);
v7 = func8(*(_DWORD *)(w_packet + 12));
v8 = (const char *)ip2str(v7);
fprintf(stdout, "-debug- from %s,", v8);
fflush(stdout);
v9 = func8(*(_DWORD *)(w_packet + 16));
v10 = (const char *)ip2str(v9);
fprintf(stdout, "-debug- to %s,", v10);
fflush(stdout);
result = 0LL;
}
}
return result;
}

original_code:
static int is_response_ip(void)
{
    struct iphdr *ihp = ((void *)0);
    if ((_type>=12?1:0) || _type == 11) {
        ihp = (struct iphdr *) (_packet +
                                sizeof(struct iphdr) +
                                sizeof(struct icmphdr));
        if (((struct iphdr *) _w_packet)->saddr != ihp->saddr
            || ((struct iphdr *) _w_packet)->daddr != ihp->daddr) {
            do{fprintf(stdout, "-debug- " "unreach from %s,", ip2str(ntohl(ihp->saddr))); fflush(stdout);} while(0);
            do{fprintf(stdout, "-debug- " "to %s,", ip2str(ntohl(ihp->daddr))); fflush(stdout);} while(0);
            do{fprintf(stdout, "-debug- " "from %s,", ip2str(ntohl(((struct iphdr *) _w_packet)->saddr))); fflush(stdout);} while(0);
            do{fprintf(stdout, "-debug- " "to %s,", ip2str(ntohl(((struct iphdr *) _w_packet)->daddr))); fflush(stdout);} while(0);
            return 0;
        }
        return 1;
    }
    ihp = (struct iphdr *) _packet;
    if (((struct iphdr *) _w_packet)->saddr != ihp->daddr ||
        ((struct iphdr *) _w_packet)->daddr != ihp->saddr) {
        do{fprintf(stdout, "-debug- " "return from %s,", ip2str(ntohl(ihp->saddr))); fflush(stdout);} while(0);
        do{fprintf(stdout, "-debug- " "to %s,", ip2str(ntohl(ihp->daddr))); fflush(stdout);} while(0);
        do{fprintf(stdout, "-debug- " "from %s,", ip2str(ntohl(((struct iphdr *) _w_packet)->saddr))); fflush(stdout);} while(0);
        do{fprintf(stdout, "-debug- " "to %s,", ip2str(ntohl(((struct iphdr *) _w_packet)->daddr))); fflush(stdout);} while(0);
        return 0;
    }
    return 1;
}

canonical_original_code:
static int is_response_ip()
{
    struct iphdr *ihp = ((void *)0);
    if ((_type>=12?1:0) || _type == 11) {
        ihp = (struct iphdr *) (_packet +
                                sizeof(struct iphdr) +
                                sizeof(struct icmphdr));
        if (((struct iphdr *) _w_packet)->saddr != ihp->saddr
            || ((struct iphdr *) _w_packet)->daddr != ihp->daddr) {
            do{fprintf(stdout, "-debug- " "unreach from %s,", ip2str(ntohl(ihp->saddr))); fflush(stdout);} while(0);
            do{fprintf(stdout, "-debug- " "to %s,", ip2str(ntohl(ihp->daddr))); fflush(stdout);} while(0);
            do{fprintf(stdout, "-debug- " "from %s,", ip2str(ntohl(((struct iphdr *) _w_packet)->saddr))); fflush(stdout);} while(0);
            do{fprintf(stdout, "-debug- " "to %s,", ip2str(ntohl(((struct iphdr *) _w_packet)->daddr))); fflush(stdout);} while(0);
            return 0;
        }
        return 1;
    }
    ihp = (struct iphdr *) _packet;
    if (((struct iphdr *) _w_packet)->saddr != ihp->daddr ||
        ((struct iphdr *) _w_packet)->daddr != ihp->saddr) {
        do{fprintf(stdout, "-debug- " "return from %s,", ip2str(ntohl(ihp->saddr))); fflush(stdout);} while(0);
        do{fprintf(stdout, "-debug- " "to %s,", ip2str(ntohl(ihp->daddr))); fflush(stdout);} while(0);
        do{fprintf(stdout, "-debug- " "from %s,", ip2str(ntohl(((struct iphdr *) _w_packet)->saddr))); fflush(stdout);} while(0);
        do{fprintf(stdout, "-debug- " "to %s,", ip2str(ntohl(((struct iphdr *) _w_packet)->daddr))); fflush(stdout);} while(0);
        return 0;
    }
    return 1;
}


decompiled_code:
__int16 __fastcall get_pk_typeseq(__int64 a1, unsigned int a2, unsigned __int8 *a3)
{
unsigned __int8 v4; // bl
__int16 result; // ax
__int16 v6; // dx
unsigned __int8 v7; // al

v4 = get_pk_type(a1, a2);
type = v4;
result = 0;
if ( v4 )
{
*a3 = v4;
packet = a1;
v6 = get_pk_id();
result = 0;
if ( v6 == pID )
{
if ( v4 <= 0xAu )
{
result = _bswap_16(*(_WORD *)(a1 + OS_SEQ_PK[v4])) - ((unsigned __int8)(v4 - 9) < 2u);
}
else
{
v7 = get_ppk_type();
ppk_type = v7;
if ( v7 )
{
result = _bswap_16(*(_WORD *)(a1 + OS_SEQ_PK[v7] + 28));
}
else
{
fprintf(stdout, "-debug- --- ppk_type, type %d\n", v4);
fflush(stdout);
result = 0;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int16 __fastcall func10(__int64 a1, unsigned int a2, unsigned __int8 *a3)
{
unsigned __int8 v4; // bl
__int16 result; // ax
__int16 v6; // dx
unsigned __int8 v7; // al

v4 = func3(a1, a2);
type = v4;
result = 0;
if ( v4 )
{
*a3 = v4;
packet = a1;
v6 = func7();
result = 0;
if ( v6 == pID )
{
if ( v4 <= 0xAu )
{
result = func6(*(_WORD *)(a1 + OS_SEQ_PK[v4])) - ((unsigned __int8)(v4 - 9) < 2u);
}
else
{
v7 = func2();
ppk_type = v7;
if ( v7 )
{
result = func6(*(_WORD *)(a1 + OS_SEQ_PK[v7] + 28));
}
else
{
fprintf(stdout, "-debug- --- ppk_type, type %d\n", v4);
fflush(stdout);
result = 0;
}
}
}
}
return result;
}

original_code:
unsigned short get_pk_typeseq(const char *packet, int size,
                              unsigned char *type)
{
    unsigned short seq;
    if ((_type = get_pk_type(packet, size)) == 0) {
        return 0;
    }
    *type = _type;
    _packet = packet;
    if (get_pk_id() != _pID) {
        return 0;
    }
    if ((_type>=12?1:0) || _type == 11) {
        _ppk_type = get_ppk_type();
        if (_ppk_type == 0) {
            do{fprintf(stdout, "-debug- " "--- ppk_type, type %d\n", _type); fflush(stdout);} while(0);
            return 0;
        }
    }
    if ((_type>=12?1:0) || _type == 11) {
        seq = *((unsigned short *) ((char*)_packet + sizeof(struct iphdr) + sizeof(struct icmphdr)+OS_SEQ_PK[(int)_ppk_type] ));
    } else {
        seq = *((unsigned short *) ((char*)_packet+OS_SEQ_PK[(int)_type] ));
    }
    seq = ntohs(seq);
    if (_type == 10 || _type == 9) {
        seq--;
    }
    return seq;
}

canonical_original_code:
unsigned short get_pk_typeseq(char *packet, int size, unsigned char *type)
{
    unsigned short seq;
    if ((_type = get_pk_type(packet, size)) == 0) {
        return 0;
    }
    *type = _type;
    _packet = packet;
    if (get_pk_id() != _pID) {
        return 0;
    }
    if ((_type>=12?1:0) || _type == 11) {
        _ppk_type = get_ppk_type();
        if (_ppk_type == 0) {
            do{fprintf(stdout, "-debug- " "--- ppk_type, type %d\n", _type); fflush(stdout);} while(0);
            return 0;
        }
    }
    if ((_type>=12?1:0) || _type == 11) {
        seq = *((unsigned short *) ((char *)_packet + sizeof(struct iphdr) + sizeof(struct icmphdr)+OS_SEQ_PK[(int)_ppk_type] ));
    } else {
        seq = *((unsigned short *) ((char *)_packet+OS_SEQ_PK[(int)_type] ));
    }
    seq = ntohs(seq);
    if (_type == 10 || _type == 9) {
        seq--;
    }
    return seq;
}

variable_types:
type
unsigned char *

variable_types:
seq
unsigned short


decompiled_code:
__int64 __fastcall is_response(char a1, __int64 a2)
{
unsigned int v2; // ebx
const char *v4; // r12
const char *v5; // rbp
const char *v6; // rax

w_type = a1;
w_packet = a2;
if ( is_response_type() )
{
v2 = is_response_ip();
if ( v2 )
{
v2 = is_response_port();
if ( v2 )
{
v2 = 1;
}
else
{
fwrite("-debug- --- port\n", 1uLL, 0x11uLL, stdout);
fflush(stdout);
}
}
else
{
fprintf(stdout, "-debug- --- IP , type %d\n", (unsigned __int8)type);
fflush(stdout);
}
}
else
{
v2 = 0;
v4 = (const char *)ptype2str((unsigned int)ppk_type);
v5 = (const char *)ptype2str((unsigned int)type);
v6 = (const char *)ptype2str((unsigned int)w_type);
fprintf(stdout, "-debug- --- type %s, return %s %s\n", v6, v5, v4);
fflush(stdout);
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func11(char a1, __int64 a2)
{
unsigned int v2; // ebx
const char *v4; // r12
const char *v5; // rbp
const char *v6; // rax

w_type = a1;
w_packet = a2;
if ( func4() )
{
v2 = func9();
if ( v2 )
{
v2 = func5();
if ( v2 )
{
v2 = 1;
}
else
{
fwrite("-debug- --- port\n", 1uLL, 0x11uLL, stdout);
fflush(stdout);
}
}
else
{
fprintf(stdout, "-debug- --- IP , type %d\n", (unsigned __int8)type);
fflush(stdout);
}
}
else
{
v2 = 0;
v4 = (const char *)ptype2str((unsigned int)ppk_type);
v5 = (const char *)ptype2str((unsigned int)type);
v6 = (const char *)ptype2str((unsigned int)w_type);
fprintf(stdout, "-debug- --- type %s, return %s %s\n", v6, v5, v4);
fflush(stdout);
}
return v2;
}

original_code:
int is_response(unsigned char w_type, const char *w_packet)
{
    _w_type = w_type;
    _w_packet = w_packet;
    if (!is_response_type()) {
        do{fprintf(stdout, "-debug- " "--- type %s, return %s %s\n", ptype2str(_w_type), ptype2str(_type), ptype2str(_ppk_type)); fflush(stdout);} while(0);
        return 0;
    }
    if (!is_response_ip()) {
        do{fprintf(stdout, "-debug- " "--- IP , type %d\n", _type); fflush(stdout);} while(0);
        return 0;
    }
    if (!is_response_port()) {
        do{fprintf(stdout, "-debug- " "--- port\n"); fflush(stdout);} while(0);
        return 0;
    }
    return 1;
}

canonical_original_code:
int is_response(unsigned char w_type, char *w_packet)
{
    _w_type = w_type;
    _w_packet = w_packet;
    if (!is_response_type()) {
        do{fprintf(stdout, "-debug- " "--- type %s, return %s %s\n", ptype2str(_w_type), ptype2str(_type), ptype2str(_ppk_type)); fflush(stdout);} while(0);
        return 0;
    }
    if (!is_response_ip()) {
        do{fprintf(stdout, "-debug- " "--- IP , type %d\n", _type); fflush(stdout);} while(0);
        return 0;
    }
    if (!is_response_port()) {
        do{fprintf(stdout, "-debug- " "--- port\n"); fflush(stdout);} while(0);
        return 0;
    }
    return 1;
}


decompiled_code:
__int64 __fastcall new_packet(int a1, char a2, unsigned int *a3)
{
__int64 v4; // rbp
unsigned int v5; // er12
unsigned int v7; // er14
char v8; // r13

if ( a1 == 6 )
{
v5 = 40;
}
else
{
if ( (a1 & 0xFFFFFFEF) != 1 )
{
fwrite("-warnning- this protocal is unsupported", 1uLL, 0x27uLL, stderr);
fprintf(stderr, " %s:%d %s() ", "fillpack.c", 38LL, "new_packet");
fputc(10, stderr);
*a3 = 0;
return 0LL;
}
v5 = 28;
}
if ( (a2 & 1) != 0 )
{
v7 = get_rand_int(448LL) & 0xFFFFFFFC;
v8 = v5;
v5 += v7;
v4 = safe_malloc(v5);
fill_buf_rand(v4 + v8, v7);
}
else
{
v4 = safe_malloc(v5);
}
*a3 = v5;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, char a2, unsigned int *a3)
{
__int64 v4; // rbp
unsigned int v5; // er12
unsigned int v7; // er14
char v8; // r13

if ( a1 == 6 )
{
v5 = 40;
}
else
{
if ( (a1 & 0xFFFFFFEF) != 1 )
{
fwrite("-warnning- this protocal is unsupported", 1uLL, 0x27uLL, stderr);
fprintf(stderr, " %s:%d %s() ", "fillpack.c", 38LL, "new_packet");
fputc(10, stderr);
*a3 = 0;
return 0LL;
}
v5 = 28;
}
if ( (a2 & 1) != 0 )
{
v7 = get_rand_int(448LL) & 0xFFFFFFFC;
v8 = v5;
v5 += v7;
v4 = safe_malloc(v5);
fill_buf_rand(v4 + v8, v7);
}
else
{
v4 = safe_malloc(v5);
}
*a3 = v5;
return v4;
}

original_code:
char *new_packet(int proto, int option, int *size)
{
    char *packet = ((void *)0);
    int packet_size = 0;
    char padding_offset = 0;
    int padding_len = 0;
    switch (proto) {
    case IPPROTO_TCP:
        packet_size = sizeof(struct iphdr) + sizeof(struct tcphdr);
        break;
    case IPPROTO_UDP:
        packet_size = sizeof(struct iphdr) + sizeof(struct udphdr);
        break;
    case IPPROTO_ICMP:
        packet_size = sizeof(struct iphdr) + sizeof(struct icmphdr);
        break;
    default:
        do{fprintf(stderr, "-warnning- " "this protocal is unsupported"); fprintf(stderr, " %s:%d %s() ", "fillpack.c", 38, __func__); fprintf(stderr, "\n");} while(0);
        *size = 0;
        return ((void *)0);
    }
    if (option & 1) {
        padding_len = get_rand_int(448);
        padding_len = padding_len - padding_len % (sizeof(int));
        padding_offset = packet_size;
        packet_size += padding_len;
    }
    packet = safe_malloc(packet_size);
    if (option & 1) {
        fill_buf_rand(packet + padding_offset, padding_len);
    }
    *size = packet_size;
    return packet;
}

variable_types: proto int

variable_types: option int

variable_types:
size
int *

return_type: char *


decompiled_code:
__int64 del_packet()
{
return safe_free();
}

canonical_decompiled_code:
__int64 func1()
{
return safe_free();
}

original_code:
void del_packet(char *packet)
{
    safe_free(packet);
}


decompiled_code:
__int64 __fastcall fill_ppk_icmpecho(__int64 a1, unsigned int *a2)
{
__int64 v2; // rbp

v2 = new_packet(1, *(_BYTE *)(a1 + 3), a2);
fill_iphdr(
v2,
*a2,
(unsigned __int16)*a2,
pID,
*(unsigned __int8 *)(a1 + 4),
1LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
fill_icmphdr(v2 + 20, *a2 - 20, 8LL, 0LL, pID, SEQ);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int *a2)
{
__int64 v2; // rbp

v2 = func0(1, *(_BYTE *)(a1 + 3), a2);
fill_iphdr(
v2,
*a2,
(unsigned __int16)*a2,
pID,
*(unsigned __int8 *)(a1 + 4),
1LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
fill_icmphdr(v2 + 20, *a2 - 20, 8LL, 0LL, pID, SEQ);
return v2;
}

original_code:
char *fill_ppk_icmpecho(const struct probing_info *pi, int *size)
{
    char *packet = new_packet(IPPROTO_ICMP, pi->option, size);
    fill_iphdr((struct iphdr *) packet, *size, *size, _pID, pi->ttl,
               IPPROTO_ICMP, pi->src, pi->dst);
    fill_icmphdr((struct icmphdr *) (packet + sizeof(struct iphdr)),
                 *size - sizeof(struct iphdr), 8, 0, _pID, _SEQ);
    return packet;
}

canonical_original_code:
char *fill_ppk_icmpecho(struct probing_info *pi, int *size)
{
    char *packet = new_packet(IPPROTO_ICMP, pi->option, size);
    fill_iphdr((struct iphdr *) packet, *size, *size, _pID, pi->ttl,
               IPPROTO_ICMP, pi->src, pi->dst);
    fill_icmphdr((struct icmphdr *) (packet + sizeof(struct iphdr)),
                 *size - sizeof(struct iphdr), 8, 0, _pID, _SEQ);
    return packet;
}

variable_types: struct probing_info { unsigned short seq; unsigned char type; unsigned char option; unsigned char ttl; unsigned char wt; unsigned short zero; unsigned int src; unsigned int dst; unsigned short sport; unsigned short dport; } *


decompiled_code:
__int64 __fastcall fill_ppk_ack(__int64 a1, unsigned int *a2)
{
__int16 v3; // bp
unsigned int v4; // er12
__int64 v5; // r13

v3 = get_rand_int(3LL);
v4 = SEQ + (pID << 16);
v5 = new_packet(6, *(_BYTE *)(a1 + 3), a2);
fill_iphdr(
v5,
*a2,
(unsigned __int16)*a2,
pID,
*(unsigned __int8 *)(a1 + 4),
6LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
fill_tcphdr(
v5 + 20,
*a2 - 20,
*(unsigned __int16 *)(a1 + 16),
*(unsigned __int16 *)(a1 + 18),
v4,
v4,
0LL,
(unsigned __int16)((v3 + 1) << 10),
0LL,
0LL,
0LL,
0LL,
1LL,
0LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int *a2)
{
__int16 v3; // bp
unsigned int v4; // er12
__int64 v5; // r13

v3 = get_rand_int(3LL);
v4 = SEQ + (pID << 16);
v5 = func0(6, *(_BYTE *)(a1 + 3), a2);
fill_iphdr(
v5,
*a2,
(unsigned __int16)*a2,
pID,
*(unsigned __int8 *)(a1 + 4),
6LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
fill_tcphdr(
v5 + 20,
*a2 - 20,
*(unsigned __int16 *)(a1 + 16),
*(unsigned __int16 *)(a1 + 18),
v4,
v4,
0LL,
(unsigned __int16)((v3 + 1) << 10),
0LL,
0LL,
0LL,
0LL,
1LL,
0LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
return v5;
}

original_code:
char *fill_ppk_ack(const struct probing_info *pi, int *size)
{
    int win = ((get_rand_int(3)+1)*1024);
    uint32_t ack_seq = (_pID << 16) + _SEQ;
    char *packet = new_packet(IPPROTO_TCP, pi->option, size);
    fill_iphdr((struct iphdr *) packet, *size, *size, _pID, pi->ttl,
               IPPROTO_TCP, pi->src, pi->dst);
    fill_tcphdr((struct tcphdr *) (packet + sizeof(struct iphdr)),
                *size - sizeof(struct iphdr), pi->sport, pi->dport,
                ack_seq, ack_seq, 0, win, 0, 0, 0, 0, 1, 0, pi->src, pi->dst);
    return packet;
}

canonical_original_code:
char *fill_ppk_ack(struct probing_info *pi, int *size)
{
    int win = ((get_rand_int(3)+1)*1024);
    unsigned int ack_seq = (_pID << 16) + _SEQ;
    char *packet = new_packet(IPPROTO_TCP, pi->option, size);
    fill_iphdr((struct iphdr *) packet, *size, *size, _pID, pi->ttl,
               IPPROTO_TCP, pi->src, pi->dst);
    fill_tcphdr((struct tcphdr *) (packet + sizeof(struct iphdr)),
                *size - sizeof(struct iphdr), pi->sport, pi->dport,
                ack_seq, ack_seq, 0, win, 0, 0, 0, 0, 1, 0, pi->src, pi->dst);
    return packet;
}

variable_types: win int


decompiled_code:
__int64 __fastcall fill_ppk_syn(__int64 a1, unsigned int *a2)
{
__int16 v3; // bp
unsigned int v4; // er13
__int64 v5; // r12

v3 = get_rand_int(3LL);
v4 = SEQ + (pID << 16);
v5 = new_packet(6, *(_BYTE *)(a1 + 3), a2);
fill_iphdr(
v5,
*a2,
(unsigned __int16)*a2,
pID,
*(unsigned __int8 *)(a1 + 4),
6LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
fill_tcphdr(
v5 + 20,
*a2 - 20,
*(unsigned __int16 *)(a1 + 16),
*(unsigned __int16 *)(a1 + 18),
v4,
0LL,
0LL,
(unsigned __int16)((v3 + 1) << 10),
0LL,
1LL,
0LL,
0LL,
0LL,
0LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned int *a2)
{
__int16 v3; // bp
unsigned int v4; // er13
__int64 v5; // r12

v3 = get_rand_int(3LL);
v4 = SEQ + (pID << 16);
v5 = func0(6, *(_BYTE *)(a1 + 3), a2);
fill_iphdr(
v5,
*a2,
(unsigned __int16)*a2,
pID,
*(unsigned __int8 *)(a1 + 4),
6LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
fill_tcphdr(
v5 + 20,
*a2 - 20,
*(unsigned __int16 *)(a1 + 16),
*(unsigned __int16 *)(a1 + 18),
v4,
0LL,
0LL,
(unsigned __int16)((v3 + 1) << 10),
0LL,
1LL,
0LL,
0LL,
0LL,
0LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
return v5;
}

original_code:
char *fill_ppk_syn(const struct probing_info *pi, int *size)
{
    int win = ((get_rand_int(3)+1)*1024);
    uint32_t seq = (_pID << 16) + _SEQ;
    char *packet = new_packet(IPPROTO_TCP, pi->option, size);
    fill_iphdr((struct iphdr *) packet, *size, *size, _pID, pi->ttl,
               IPPROTO_TCP, pi->src, pi->dst);
    fill_tcphdr((struct tcphdr *) (packet + sizeof(struct iphdr)),
                *size - sizeof(struct iphdr), pi->sport, pi->dport,
                seq, 0, 0, win, 0, 1, 0, 0, 0, 0, pi->src, pi->dst);
    return packet;
}

canonical_original_code:
char *fill_ppk_syn(struct probing_info *pi, int *size)
{
    int win = ((get_rand_int(3)+1)*1024);
    unsigned int seq = (_pID << 16) + _SEQ;
    char *packet = new_packet(IPPROTO_TCP, pi->option, size);
    fill_iphdr((struct iphdr *) packet, *size, *size, _pID, pi->ttl,
               IPPROTO_TCP, pi->src, pi->dst);
    fill_tcphdr((struct tcphdr *) (packet + sizeof(struct iphdr)),
                *size - sizeof(struct iphdr), pi->sport, pi->dport,
                seq, 0, 0, win, 0, 1, 0, 0, 0, 0, pi->src, pi->dst);
    return packet;
}

variable_types:
seq
unsigned int


decompiled_code:
__int64 __fastcall fill_ppk_fin(__int64 a1, unsigned int *a2)
{
__int16 v3; // bp
unsigned int v4; // er13
__int64 v5; // r12

v3 = get_rand_int(3LL);
v4 = SEQ + (pID << 16);
v5 = new_packet(6, *(_BYTE *)(a1 + 3), a2);
fill_iphdr(
v5,
*a2,
(unsigned __int16)*a2,
pID,
*(unsigned __int8 *)(a1 + 4),
6LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
fill_tcphdr(
v5 + 20,
*a2 - 20,
*(unsigned __int16 *)(a1 + 16),
*(unsigned __int16 *)(a1 + 18),
v4,
0LL,
0LL,
(unsigned __int16)((v3 + 1) << 10),
1LL,
0LL,
0LL,
0LL,
0LL,
0LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned int *a2)
{
__int16 v3; // bp
unsigned int v4; // er13
__int64 v5; // r12

v3 = get_rand_int(3LL);
v4 = SEQ + (pID << 16);
v5 = func0(6, *(_BYTE *)(a1 + 3), a2);
fill_iphdr(
v5,
*a2,
(unsigned __int16)*a2,
pID,
*(unsigned __int8 *)(a1 + 4),
6LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
fill_tcphdr(
v5 + 20,
*a2 - 20,
*(unsigned __int16 *)(a1 + 16),
*(unsigned __int16 *)(a1 + 18),
v4,
0LL,
0LL,
(unsigned __int16)((v3 + 1) << 10),
1LL,
0LL,
0LL,
0LL,
0LL,
0LL,
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
return v5;
}

original_code:
char *fill_ppk_fin(const struct probing_info *pi, int *size)
{
    int win = ((get_rand_int(3)+1)*1024);
    uint32_t seq = (_pID << 16) + _SEQ;
    char *packet = new_packet(IPPROTO_TCP, pi->option, size);
    fill_iphdr((struct iphdr *) packet, *size, *size, _pID, pi->ttl,
               IPPROTO_TCP, pi->src, pi->dst);
    fill_tcphdr((struct tcphdr *) (packet + sizeof(struct iphdr)),
                *size - sizeof(struct iphdr), pi->sport, pi->dport,
                seq, 0, 0, win, 1, 0, 0, 0, 0, 0, pi->src, pi->dst);
    return packet;
}

canonical_original_code:
char *fill_ppk_fin(struct probing_info *pi, int *size)
{
    int win = ((get_rand_int(3)+1)*1024);
    unsigned int seq = (_pID << 16) + _SEQ;
    char *packet = new_packet(IPPROTO_TCP, pi->option, size);
    fill_iphdr((struct iphdr *) packet, *size, *size, _pID, pi->ttl,
               IPPROTO_TCP, pi->src, pi->dst);
    fill_tcphdr((struct tcphdr *) (packet + sizeof(struct iphdr)),
                *size - sizeof(struct iphdr), pi->sport, pi->dport,
                seq, 0, 0, win, 1, 0, 0, 0, 0, 0, pi->src, pi->dst);
    return packet;
}