LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/DReichLab[P]adna/sam.c
// Function: bam_plp_push
int bam_plp_push(bam_plp_t iter, const bam1_t *b)
{
	if (iter->error) return -1;
	if (b) {
		if (b->core.tid < 0) return 0;
		if (b->core.flag & iter->flag_mask) return 0;
		if (iter->tid == b->core.tid && iter->pos == b->core.pos && iter->mp->cnt > iter->maxcnt) return 0;
		bam_copy1(&iter->tail->b, b);
		iter->tail->beg = b->core.pos;
		iter->tail->end = b->core.pos + bam_cigar2rlen(b->core.n_cigar, bam_get_cigar(b));
		iter->tail->s = g_cstate_null; iter->tail->s.end = iter->tail->end - 1; // initialize cstate_t
		if (b->core.tid < iter->max_tid) {
			fprintf(stderr, "[bam_pileup_core] the input is not sorted (chromosomes out of order)\n");
			iter->error = 1;
			return -1;
		}
		if ((b->core.tid == iter->max_tid) && (iter->tail->beg < iter->max_pos)) {
			fprintf(stderr, "[bam_pileup_core] the input is not sorted (reads out of order)\n");
			iter->error = 1;
			return -1;
		}
		iter->max_tid = b->core.tid; iter->max_pos = iter->tail->beg;
		if (iter->tail->end > iter->pos || iter->tail->b.core.tid > iter->tid) {
			iter->tail->next = mp_alloc(iter->mp);
			iter->tail = iter->tail->next;
		}
	} else iter->is_eof = 1;
	return 0;
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x0, 0x3c(%rdi)
je 0xd23b
retq
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
testq %rsi, %rsi
je 0xd358
movl (%r14), %ecx
xorl %eax, %eax
testl %ecx, %ecx
js 0xd361
movl 0xc(%r14), %edx
movl 0x34(%rbx), %esi
testw %dx, %si
jne 0xd361
cmpl %ecx, 0x20(%rbx)
jne 0xd288
movl 0x24(%rbx), %ecx
cmpl 0x4(%r14), %ecx
jne 0xd288
movq (%rbx), %rcx
movl (%rcx), %ecx
cmpl 0x40(%rbx), %ecx
jg 0xd361
movq 0x10(%rbx), %rdi
movq %r14, %rsi
callq 0x8d9f
movl 0x4(%r14), %edx
movq 0x10(%rbx), %rax
movl %edx, 0x30(%rax)
movq 0x8(%r14), %rsi
xorl %r8d, %r8d
movq %rsi, %rdi
shrq $0x30, %rdi
je 0xd2e7
shrl $0x18, %esi
addq 0x28(%r14), %rsi
xorl %r9d, %r9d
xorl %r8d, %r8d
movl (%rsi,%r9,4), %r10d
leal (%r10,%r10), %ecx
movl $0x3c1a7, %r11d         # imm = 0x3C1A7
shrl %cl, %r11d
shll $0x1e, %r11d
sarl $0x1f, %r11d
shrl $0x4, %r10d
andl %r11d, %r10d
addl %r10d, %r8d
incq %r9
cmpq %r9, %rdi
jne 0xd2bc
leaq 0x3c(%rbx), %rdi
addl %edx, %r8d
movl %r8d, 0x34(%rax)
movups 0x161b(%rip), %xmm0     # 0xe914
movups %xmm0, 0x38(%rax)
movq 0x10(%rbx), %r15
movl 0x34(%r15), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x44(%r15)
movl (%r14), %ecx
cmpl 0x28(%rbx), %ecx
jl 0xd380
jne 0xd31f
movl 0x30(%r15), %edx
cmpl 0x2c(%rbx), %edx
jl 0xd387
movl %ecx, 0x28(%rbx)
movl 0x30(%r15), %ecx
movl %ecx, 0x2c(%rbx)
cmpl 0x24(%rbx), %eax
jg 0xd338
movl (%r15), %ecx
xorl %eax, %eax
cmpl 0x20(%rbx), %ecx
jle 0xd361
movq (%rbx), %rax
incl (%rax)
movslq 0x4(%rax), %rcx
testq %rcx, %rcx
je 0xd367
movq 0x10(%rax), %rdx
leaq -0x1(%rcx), %rsi
movl %esi, 0x4(%rax)
movq -0x8(%rdx,%rcx,8), %rax
jmp 0xd376
movl $0x1, 0x30(%rbx)
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movl $0x1, %edi
movl $0x50, %esi
callq 0x21f0
movq %rax, 0x48(%r15)
movq %rax, 0x10(%rbx)
jmp 0xd35f
callq 0x26e3
jmp 0xd38c
callq 0x26bb
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xd361
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht-example.c
// Function: set_nonblocking
static int
set_nonblocking(int fd, int nonblocking)
{
    int rc;
    rc = fcntl(fd, F_GETFL, 0);
    if(rc < 0)
        return -1;

    rc = fcntl(fd, F_SETFL,
               nonblocking ? (rc | O_NONBLOCK) : (rc & ~O_NONBLOCK));
    if(rc < 0)
        return -1;

    return 0;
}

// Assembly:
pushq %rbx
movl %edi, %ebx
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x20d0
testl %eax, %eax
js 0x2f9d
orl $0x800, %eax            # imm = 0x800
movl %ebx, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x20d0
sarl $0x1f, %eax
jmp 0x2fa2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht-example.c
// Function: callback
static void
callback(void *closure,
         int event,
         const unsigned char *info_hash,
         const void *data, size_t data_len)
{
    if(event == DHT_EVENT_SEARCH_DONE)
        printf("Search done.\n");
    else if(event == DHT_EVENT_SEARCH_DONE6)
        printf("IPv6 search done.\n");
    else if(event == DHT_EVENT_VALUES)
        printf("Received %d values.\n", (int)(data_len / 6));
    else if(event == DHT_EVENT_VALUES6)
        printf("Received %d IPv6 values.\n", (int)(data_len / 18));
    else
        printf("Unknown DHT event %d.\n", event);
}

// Assembly:
leal -0x1(%rsi), %eax
cmpl $0x3, %eax
ja 0x3010
leaq 0x605d(%rip), %rcx      # 0x9010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
movq %r8, %rax
mulq %rcx
shrq $0x2, %rdx
leaq 0x616a(%rip), %rdi      # 0x9141
jmp 0x300c
leaq 0x6223(%rip), %rdi      # 0x9203
jmp 0x20a0
leaq 0x6205(%rip), %rdi      # 0x91f1
jmp 0x20a0
movabsq $-0x1c71c71c71c71c71, %rcx # imm = 0xE38E38E38E38E38F
movq %r8, %rax
mulq %rcx
shrq $0x4, %rdx
leaq 0x614a(%rip), %rdi      # 0x9156
movl %edx, %esi
jmp 0x3017
leaq 0x6159(%rip), %rdi      # 0x9170
xorl %eax, %eax
jmp 0x2100
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht-example.c
// Function: dht_hash
void
dht_hash(void *hash_return, int hash_size,
         const void *v1, int len1,
         const void *v2, int len2,
         const void *v3, int len3)
{
    const char *c1 = v1, *c2 = v2, *c3 = v3;
    char key[9];                /* crypt is limited to 8 characters */
    int i;

    memset(key, 0, 9);
#define CRYPT_HAPPY(c) ((c % 0x60) + 0x20)

    for(i = 0; i < 2 && i < len1; i++)
        key[i] = CRYPT_HAPPY(c1[i]);
    for(i = 0; i < 4 && i < len1; i++)
        key[2 + i] = CRYPT_HAPPY(c2[i]);
    for(i = 0; i < 2 && i < len1; i++)
        key[6 + i] = CRYPT_HAPPY(c3[i]);
    strncpy(hash_return, crypt(key, "jc"), hash_size);
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movb $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
testl %ecx, %ecx
jle 0x3089
xorl %eax, %eax
cmpl $0x1, %ecx
setne %al
incq %rax
xorl %esi, %esi
movsbq (%rdx,%rsi), %rdi
imulq $0x2aaaaaab, %rdi, %r9  # imm = 0x2AAAAAAB
movq %r9, %r10
shrq $0x3f, %r10
shrq $0x24, %r9
addl %r10d, %r9d
shll $0x5, %r9d
leal (%r9,%r9,2), %r9d
subl %r9d, %edi
addb $0x20, %dil
movb %dil, 0x8(%rsp,%rsi)
incq %rsi
cmpq %rsi, %rax
jne 0x3053
testl %ecx, %ecx
jle 0x30d2
leal -0x1(%rcx), %edx
cmpl $0x3, %edx
movl $0x3, %eax
cmovbl %edx, %eax
incl %eax
xorl %edx, %edx
movsbq (%r8,%rdx), %rsi
imulq $0x2aaaaaab, %rsi, %rdi # imm = 0x2AAAAAAB
movq %rdi, %r9
shrq $0x3f, %r9
shrq $0x24, %rdi
addl %r9d, %edi
shll $0x5, %edi
leal (%rdi,%rdi,2), %edi
subl %edi, %esi
addb $0x20, %sil
movb %sil, 0xa(%rsp,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x309f
testl %ecx, %ecx
jle 0x311b
movq 0x30(%rsp), %rax
xorl %edx, %edx
cmpl $0x1, %ecx
setne %dl
incq %rdx
xorl %ecx, %ecx
movsbq (%rax,%rcx), %rsi
imulq $0x2aaaaaab, %rsi, %rdi # imm = 0x2AAAAAAB
movq %rdi, %r8
shrq $0x3f, %r8
shrq $0x24, %rdi
addl %r8d, %edi
shll $0x5, %edi
leal (%rdi,%rdi,2), %edi
subl %edi, %esi
addb $0x20, %sil
movb %sil, 0xe(%rsp,%rcx)
incq %rcx
cmpq %rcx, %rdx
jne 0x30e8
leaq 0x601c(%rip), %rsi      # 0x913e
leaq 0x8(%rsp), %rdi
callq 0x2320
movslq %ebp, %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2090
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht-example.c
// Function: dht_random_bytes
int
dht_random_bytes(void *buf, size_t size)
{
    int fd, rc, save;

    fd = open("/dev/urandom", O_RDONLY);
    if(fd < 0)
        return -1;

    rc = read(fd, buf, size);

    save = errno;
    close(fd);
    errno = save;

    return rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x5efb(%rip), %rdi      # 0x9050
xorl %esi, %esi
xorl %eax, %eax
callq 0x22a0
testl %eax, %eax
js 0x318b
movl %eax, %ebp
movl %eax, %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2180
movq %rax, %rbx
callq 0x2060
movq %rax, %r14
movl (%rax), %r15d
movl %ebp, %edi
callq 0x2160
movl %r15d, (%r14)
jmp 0x3190
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: find_bucket
static struct bucket *
find_bucket(unsigned const char *id, int af)
{
    struct bucket *b = af == AF_INET ? buckets : buckets6;

    if(b == NULL)
        return NULL;

    while(1) {
        if(b->next == NULL)
            return b;
        if(id_cmp(id, b->next->first) < 0)
            return b;
        b = b->next;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpl $0x2, %esi
leaq 0xa66d(%rip), %rax      # 0xdc50
leaq 0xa66e(%rip), %rcx      # 0xdc58
cmoveq %rax, %rcx
movq (%rcx), %r15
testq %r15, %r15
je 0x361f
movq %rdi, %rbx
movq %r15, %r14
movq 0xb8(%r15), %r15
testq %r15, %r15
je 0x3622
leaq 0x4(%r15), %rsi
movl $0x14, %edx
movq %rbx, %rdi
callq 0x2190
testl %eax, %eax
jns 0x35f9
jmp 0x3622
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: find_storage
static struct storage *
find_storage(const unsigned char *id)
{
    struct storage *st = storage;

    while(st) {
        if(id_cmp(id, st->id) == 0)
            break;
        st = st->next;
    }
    return st;
}

// Assembly:
movq 0xa62e(%rip), %rax      # 0xdc60
testq %rax, %rax
je 0x366a
movdqu (%rdi), %xmm0
movd 0x10(%rdi), %xmm1
movdqu (%rax), %xmm2
pcmpeqb %xmm0, %xmm2
movd 0x10(%rax), %xmm3
pcmpeqb %xmm1, %xmm3
pand %xmm2, %xmm3
pmovmskb %xmm3, %ecx
cmpl $0xffff, %ecx           # imm = 0xFFFF
je 0x366a
movq 0x28(%rax), %rax
testq %rax, %rax
jne 0x3640
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: debugf
__attribute__ ((format (printf, 1, 2)))
#endif
static void
debugf(const char *format, ...)
{
    va_list args;
    va_start(args, format);
    if(dht_debug)
        vfprintf(dht_debug, format, args);
    va_end(args);
    if(dht_debug)
        fflush(dht_debug);
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, %r10
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x36c9
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rdi, 0x10(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rsp)
movq 0xa510(%rip), %rdi      # 0xdc00
testq %rdi, %rdi
je 0x3700
movq %rsp, %rdx
movq %r10, %rsi
callq 0x22d0
movq 0xa4f9(%rip), %rdi      # 0xdc00
testq %rdi, %rdi
je 0x3711
callq 0x2240
addq $0xd8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: flush_search_node
static void
flush_search_node(struct search_node *n, struct search *sr)
{
    int i = n - sr->nodes, j;
    for(j = i; j < sr->numnodes - 1; j++)
        sr->nodes[j] = sr->nodes[j + 1];
    sr->numnodes--;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
subq %rsi, %rdi
addq $-0x30, %rdi
sarq $0x3, %rdi
movabsq $0x34f72c234f72c235, %rcx # imm = 0x34F72C234F72C235
imulq %rdi, %rcx
movl 0xce0(%rsi), %eax
decl %eax
cmpl %ecx, %eax
jle 0x3788
movslq %ecx, %r15
imulq $0xe8, %r15, %rax
leaq (%rax,%rbx), %r14
addq $0x118, %r14            # imm = 0x118
leaq -0xe8(%r14), %rdi
incq %r15
movl $0xe8, %edx
movq %r14, %rsi
callq 0x2200
movslq 0xce0(%rbx), %rax
decq %rax
addq $0xe8, %r14
cmpq %rax, %r15
jl 0x375b
movl %eax, 0xce0(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: dht_nodes
int
dht_nodes(int af, int *good_return, int *dubious_return, int *cached_return,
          int *incoming_return)
{
    int good = 0, dubious = 0, cached = 0, incoming = 0;
    struct bucket *b = af == AF_INET ? buckets : buckets6;

    while(b) {
        struct node *n = b->nodes;
        while(n) {
            if(node_good(n)) {
                good++;
                if(n->time > n->reply_time)
                    incoming++;
            } else {
                dubious++;
            }
            n = n->next;
        }
        if(b->cached.ss_family > 0)
            cached++;
        b = b->next;
    }
    if(good_return)
        *good_return = good;
    if(dubious_return)
        *dubious_return = dubious;
    if(cached_return)
        *cached_return = cached;
    if(incoming_return)
        *incoming_return = incoming;
    return good + dubious;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpl $0x2, %edi
leaq 0xa06f(%rip), %rax      # 0xdc50
leaq 0xa070(%rip), %rdi      # 0xdc58
cmoveq %rax, %rdi
movq (%rdi), %r11
testq %r11, %r11
je 0x3c7a
movq 0xa011(%rip), %rbx      # 0xdc10
leaq -0x1c20(%rbx), %r14
addq $-0x384, %rbx           # imm = 0xFC7C
xorl %r9d, %r9d
xorl %r10d, %r10d
xorl %eax, %eax
xorl %edi, %edi
movq 0x28(%r11), %r15
testq %r15, %r15
je 0x3c62
cmpl $0x2, 0xb8(%r15)
jg 0x3c3c
cmpq %r14, 0xa8(%r15)
jl 0x3c3c
cmpq %rbx, 0xa0(%r15)
jge 0x3c47
incl %eax
movq 0xc0(%r15), %r15
jmp 0x3c1b
incl %edi
movq 0xa0(%r15), %r12
xorl %ebp, %ebp
cmpq 0xa8(%r15), %r12
setg %bpl
addl %ebp, %r9d
jmp 0x3c3e
cmpw $0x1, 0x30(%r11)
sbbl $-0x1, %r10d
movq 0xb8(%r11), %r11
testq %r11, %r11
jne 0x3c17
jmp 0x3c84
xorl %edi, %edi
xorl %eax, %eax
xorl %r10d, %r10d
xorl %r9d, %r9d
testq %rsi, %rsi
je 0x3c8b
movl %edi, (%rsi)
testq %rdx, %rdx
je 0x3c92
movl %eax, (%rdx)
testq %rcx, %rcx
je 0x3c9a
movl %r10d, (%rcx)
testq %r8, %r8
je 0x3ca2
movl %r9d, (%r8)
addl %edi, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: find_node
static struct node *
find_node(const unsigned char *id, int af)
{
    struct bucket *b = find_bucket(id, af);
    struct node *n;

    if(b == NULL)
        return NULL;

    n = b->nodes;
    while(n) {
        if(id_cmp(n->id, id) == 0)
            return n;
        n = n->next;
    }
    return NULL;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x35d4
testq %rax, %rax
je 0x43a1
movq 0x28(%rax), %rax
testq %rax, %rax
je 0x43a1
movdqu (%rbx), %xmm0
movd 0x10(%rbx), %xmm1
movdqu (%rax), %xmm2
pcmpeqb %xmm0, %xmm2
movd 0x10(%rax), %xmm3
pcmpeqb %xmm1, %xmm3
pand %xmm2, %xmm3
pmovmskb %xmm3, %ecx
cmpl $0xffff, %ecx           # imm = 0xFFFF
je 0x43a3
movq 0xc0(%rax), %rax
testq %rax, %rax
jne 0x4374
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: expire_buckets
static int
expire_buckets(struct bucket *b)
{
    while(b) {
        struct node *n, *p;
        int changed = 0;

        while(b->nodes && b->nodes->pinged >= 4) {
            n = b->nodes;
            b->nodes = n->next;
            b->count--;
            changed = 1;
            free(n);
        }

        p = b->nodes;
        while(p) {
            while(p->next && p->next->pinged >= 4) {
                n = p->next;
                p->next = n->next;
                b->count--;
                changed = 1;
                free(n);
            }
            p = p->next;
        }

        if(changed)
            send_cached_ping(b);

        b = b->next;
    }
    expire_stuff_time = now.tv_sec + 120 + random() % 240;
    return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x46c7
movq %rdi, %rbx
movq 0x28(%rbx), %rdi
xorl %eax, %eax
testq %rdi, %rdi
je 0x4660
cmpl $0x4, 0xb8(%rdi)
jl 0x4660
movq 0xc0(%rdi), %rax
movq %rax, 0x28(%rbx)
decl 0x18(%rbx)
callq 0x2040
movq 0x28(%rbx), %rdi
movl $0x1, %eax
jmp 0x4634
movq 0x28(%rbx), %r14
testq %r14, %r14
je 0x46ab
movq 0xc0(%r14), %rdi
testq %rdi, %rdi
je 0x46a2
cmpl $0x4, 0xb8(%rdi)
jl 0x46a2
movq 0xc0(%rdi), %rax
movq %rax, 0xc0(%r14)
decl 0x18(%rbx)
callq 0x2040
movq 0xc0(%r14), %rdi
movl $0x1, %eax
jmp 0x4670
movq 0xc0(%r14), %r14
jmp 0x4664
testl %eax, %eax
je 0x46b7
movq %rbx, %rdi
callq 0x80ff
movq 0xb8(%rbx), %rbx
testq %rbx, %rbx
jne 0x462e
movq 0x9542(%rip), %rbx      # 0xdc10
callq 0x2230
movq %rax, %rcx
movabsq $-0x7777777777777777, %rdx # imm = 0x8888888888888889
imulq %rdx
addq %rcx, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
imulq $0xf0, %rdx, %rax
subq %rax, %rcx
leaq (%rbx,%rcx), %rax
addq $0x78, %rax
movq %rax, 0x95b3(%rip)      # 0xdcc0
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: dht_uninit
int
dht_uninit(void)
{
    if(dht_socket < 0 && dht_socket6 < 0) {
        errno = EINVAL;
        return -1;
    }

    dht_socket = -1;
    dht_socket6 = -1;

    while(buckets) {
        struct bucket *b = buckets;
        buckets = b->next;
        while(b->nodes) {
            struct node *n = b->nodes;
            b->nodes = n->next;
            free(n);
        }
        free(b);
    }

    while(buckets6) {
        struct bucket *b = buckets6;
        buckets6 = b->next;
        while(b->nodes) {
            struct node *n = b->nodes;
            b->nodes = n->next;
            free(n);
        }
        free(b);
    }

    while(storage) {
        struct storage *st = storage;
        storage = storage->next;
        free(st->peers);
        free(st);
    }

    while(searches) {
        struct search *sr = searches;
        searches = searches->next;
        free(sr);
    }

    return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
cmpl $0x0, 0x7aa8(%rip)      # 0xc1c8
jns 0x4740
cmpl $0x0, 0x7aa3(%rip)      # 0xc1cc
jns 0x4740
callq 0x2060
movl $0x16, (%rax)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x4839
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x7a7d(%rip)      # 0xc1c8
movl %eax, 0x7a7b(%rip)      # 0xc1cc
movq 0x94f8(%rip), %rbx      # 0xdc50
testq %rbx, %rbx
je 0x479a
movq 0x28(%rbx), %rdi
movq 0xb8(%rbx), %r14
testq %rdi, %rdi
je 0x4783
movq 0xc0(%rdi), %rax
movq %rax, 0x28(%rbx)
callq 0x2040
movq 0x28(%rbx), %rdi
jmp 0x4768
movq %rbx, %rdi
callq 0x2040
movq %r14, %rbx
testq %r14, %r14
jne 0x475d
movq %r14, 0x94b6(%rip)      # 0xdc50
movq 0x94b7(%rip), %rbx      # 0xdc58
testq %rbx, %rbx
je 0x4801
movq 0x28(%rbx), %rdi
movq 0xb8(%rbx), %r14
testq %rdi, %rdi
je 0x47cc
movq 0xc0(%rdi), %rax
movq %rax, 0x28(%rbx)
callq 0x2040
movq 0x28(%rbx), %rdi
jmp 0x47b1
movq %rbx, %rdi
callq 0x2040
movq %r14, %rbx
testq %r14, %r14
jne 0x47a6
movq %r14, 0x9475(%rip)      # 0xdc58
jmp 0x4801
movq 0x28(%rbx), %rax
movq %rax, 0x9470(%rip)      # 0xdc60
movq 0x20(%rbx), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
movq 0x9458(%rip), %rbx      # 0xdc60
testq %rbx, %rbx
jne 0x47e5
movq 0x93f4(%rip), %rdi      # 0xdc08
movl $0x1, %ebx
testq %rdi, %rdi
je 0x4839
movq 0xce8(%rdi), %r14
movq %r14, 0x93dc(%rip)      # 0xdc08
callq 0x2040
movq %r14, %rdi
testq %r14, %r14
jne 0x481e
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: is_martian
static int
is_martian(const struct sockaddr *sa)
{
    switch(sa->sa_family) {
    case AF_INET: {
        struct sockaddr_in *sin = (struct sockaddr_in*)sa;
        const unsigned char *address = (const unsigned char*)&sin->sin_addr;
        return sin->sin_port == 0 ||
            (address[0] == 0) ||
            (address[0] == 127) ||
            ((address[0] & 0xE0) == 0xE0);
    }
    case AF_INET6: {
        struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa;
        const unsigned char *address = (const unsigned char*)&sin6->sin6_addr;
        return sin6->sin6_port == 0 ||
            (address[0] == 0xFF) ||
            (address[0] == 0xFE && (address[1] & 0xC0) == 0x80) ||
            (memcmp(address, zeroes, 15) == 0 &&
             (address[15] == 0 || address[15] == 1)) ||
            (memcmp(address, v4prefix, 12) == 0);
    }

    default:
        return 0;
    }
}

// Assembly:
movzwl (%rdi), %eax
cmpl $0xa, %eax
je 0x5e0c
cmpl $0x2, %eax
jne 0x5e57
movb $0x1, %al
cmpw $0x0, 0x2(%rdi)
je 0x5e59
movzbl 0x4(%rdi), %ecx
testl %ecx, %ecx
je 0x5e59
cmpl $0x7f, %ecx
je 0x5e59
cmpb $-0x20, %cl
setae %al
jmp 0x5e59
movb $0x1, %al
cmpw $0x0, 0x2(%rdi)
je 0x5e59
movzbl 0x8(%rdi), %ecx
cmpl $0xff, %ecx
je 0x5e59
cmpl $0xfe, %ecx
jne 0x5e33
movb 0x9(%rdi), %cl
andb $-0x40, %cl
negb %cl
jo 0x5e59
movq 0x8(%rdi), %rcx
orq 0xf(%rdi), %rcx
jne 0x5e43
cmpb $0x2, 0x17(%rdi)
jb 0x5e59
movl 0x10(%rdi), %eax
movl $0xffff0000, %ecx       # imm = 0xFFFF0000
xorq %rax, %rcx
orq 0x8(%rdi), %rcx
sete %al
jmp 0x5e59
xorl %eax, %eax
movzbl %al, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: node_blacklisted
static int
node_blacklisted(const struct sockaddr *sa, int salen)
{
    int i;

    if((unsigned)salen > sizeof(struct sockaddr_storage))
        abort();

    if(dht_blacklisted(sa, salen))
        return 1;

    for(i = 0; i < DHT_MAX_BLACKLISTED; i++) {
        if(memcmp(&blacklist[i], sa, salen) == 0)
            return 1;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpl $0x81, %esi
jae 0x5ebb
movl %esi, %r14d
movq %rdi, %rbx
callq 0x3026
movl $0x1, %ebp
testl %eax, %eax
jne 0x5eb0
movl %r14d, %r14d
xorl %r15d, %r15d
leaq 0x7e42(%rip), %r12      # 0xdcd0
leaq (%r12,%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2260
testl %eax, %eax
je 0x5eb0
subq $-0x80, %r15
cmpq $0x500, %r15            # imm = 0x500
jne 0x5e8e
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x2050
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: debug_printable
static void
debug_printable(const unsigned char *buf, int buflen)
{
    int i;
    if(dht_debug) {
        for(i = 0; i < buflen; i++)
            putc(buf[i] >= 32 && buf[i] <= 126 ? buf[i] : '.', dht_debug);
    }
}

// Assembly:
cmpq $0x0, 0x7d38(%rip)      # 0xdc00
sete %al
testl %esi, %esi
setle %cl
orb %al, %cl
jne 0x5f10
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl %esi, %r14d
xorl %r15d, %r15d
movzbl (%rbx,%r15), %eax
leal -0x20(%rax), %ecx
cmpb $0x5f, %cl
jb 0x5ef4
movl $0x2e, %eax
movzbl %al, %edi
movq 0x7d02(%rip), %rsi      # 0xdc00
callq 0x21b0
incq %r15
cmpq %r15, %r14
jne 0x5ee2
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: token_bucket
static int
token_bucket(void)
{
    if(token_bucket_tokens == 0) {
        token_bucket_tokens = MIN(MAX_TOKEN_BUCKET_TOKENS,
                                  100 * (now.tv_sec - token_bucket_time));
        token_bucket_time = now.tv_sec;
    }

    if(token_bucket_tokens == 0)
        return 0;

    token_bucket_tokens--;
    return 1;
}

// Assembly:
cmpl $0x0, 0x7d90(%rip)      # 0xdca8
jne 0x5f47
movq 0x7cef(%rip), %rax      # 0xdc10
movq %rax, %rcx
subq 0x7d75(%rip), %rcx      # 0xdca0
imull $0x64, %ecx, %edx
cmpq $0x4, %rcx
movl $0x190, %ecx            # imm = 0x190
cmovll %edx, %ecx
movl %ecx, 0x7d68(%rip)      # 0xdca8
movq %rax, 0x7d59(%rip)      # 0xdca0
movl 0x7d5b(%rip), %eax      # 0xdca8
testl %eax, %eax
je 0x5f5f
decl %eax
movl %eax, 0x7d4f(%rip)      # 0xdca8
movl $0x1, %eax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: blacklist_node
static void
blacklist_node(const unsigned char *id, const struct sockaddr *sa, int salen)
{
    int i;

    debugf("Blacklisting broken node.\n");

    if(id) {
        struct node *n;
        struct search *sr;
        /* Make the node easy to discard. */
        n = find_node(id, sa->sa_family);
        if(n) {
            n->pinged = 3;
            pinged(n, NULL);
        }
        /* Discard it from any searches in progress. */
        sr = searches;
        while(sr) {
            for(i = 0; i < sr->numnodes; i++)
                if(id_cmp(sr->nodes[i].id, id) == 0)
                    flush_search_node(&sr->nodes[i], sr);
            sr = sr->next;
        }
    }
    /* And make sure we don't hear from it again. */
    memcpy(&blacklist[next_blacklisted], sa, salen);
    next_blacklisted = (next_blacklisted + 1) % DHT_MAX_BLACKLISTED;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x3829(%rip), %rdi      # 0x97a5
xorl %eax, %eax
callq 0x366b
testq %r14, %r14
je 0x6026
movzwl (%rbx), %esi
movq %r14, %rdi
callq 0x4354
testq %rax, %rax
je 0x5fb0
movl $0x3, 0xb8(%rax)
movq %rax, %rdi
xorl %esi, %esi
callq 0x8017
movq 0x7c51(%rip), %r15      # 0xdc08
testq %r15, %r15
je 0x6026
cmpl $0x0, 0xce0(%r15)
jle 0x601d
leaq 0x30(%r15), %r12
xorl %r13d, %r13d
movdqu (%r12), %xmm0
movdqu (%r14), %xmm1
pcmpeqb %xmm0, %xmm1
movd 0x10(%r12), %xmm0
movd 0x10(%r14), %xmm2
pcmpeqb %xmm0, %xmm2
pand %xmm1, %xmm2
pmovmskb %xmm2, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x6007
movq %r12, %rdi
movq %r15, %rsi
callq 0x3719
incq %r13
movslq 0xce0(%r15), %rax
addq $0xe8, %r12
cmpq %rax, %r13
jl 0x5fcd
movq 0xce8(%r15), %r15
jmp 0x5fb7
movslq 0x7c6b(%rip), %r14      # 0xdc98
movq %r14, %rax
shlq $0x7, %rax
leaq 0x7c95(%rip), %rdi      # 0xdcd0
addq %rax, %rdi
movslq %ebp, %rdx
movq %rbx, %rsi
callq 0x2200
leal 0x1(%r14), %eax
cltq
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
movl %eax, 0x7c28(%rip)      # 0xdc98
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: send_pong
int
send_pong(const struct sockaddr *sa, int salen,
          const unsigned char *tid, int tid_len)
{
    char buf[512];
    int i = 0, rc;
    rc = snprintf(buf + i, 512 - i, "d1:rd2:id20:"); INC(i, rc, 512);
    COPY(buf, i, myid, 20, 512);
    rc = snprintf(buf + i, 512 - i, "e1:t%d:", tid_len); INC(i, rc, 512);
    COPY(buf, i, tid, tid_len, 512);
    ADD_V(buf, i, 512);
    rc = snprintf(buf + i, 512 - i, "1:y1:re"); INC(i, rc, 512);
    return dht_send(buf, i, 0, sa, salen);

 fail:
    errno = ENOSPC;
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movl %ecx, %r12d
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r14
movabsq $0x3a303264693a32, %rax # imm = 0x3A303264693A32
leaq 0x20(%rsp), %rdi
movq %rax, -0x1b(%rdi)
movabsq $0x693a3264723a3164, %rax # imm = 0x693A3264723A3164
movq %rax, -0x20(%rdi)
movl 0x715a(%rip), %eax      # 0xdc40
movl %eax, -0x4(%rdi)
movaps 0x7140(%rip), %xmm0     # 0xdc30
movups %xmm0, -0x14(%rdi)
leaq 0x2e61(%rip), %rdx      # 0x995c
movl $0x1e0, %esi            # imm = 0x1E0
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x6b85
cmpl $0x1e0, %eax            # imm = 0x1E0
jg 0x6b85
addl $0x20, %eax
leal (%rax,%r12), %ebp
cmpl $0x200, %ebp            # imm = 0x200
jg 0x6b85
movl %eax, %eax
leaq (%rsp,%rax), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x2200
cmpb $0x1, 0x7143(%rip)      # 0xdc7c
jne 0x6b5d
cmpl $0x1f7, %ebp            # imm = 0x1F7
ja 0x6b85
movl %ebp, %eax
addl $0x9, %ebp
movb 0x712a(%rip), %cl       # 0xdc78
movb %cl, 0x8(%rsp,%rax)
movq 0x7117(%rip), %rcx      # 0xdc70
movq %rcx, (%rsp,%rax)
movl %ebp, %eax
leaq (%rsp,%rax), %rdi
movl $0x200, %esi            # imm = 0x200
subl %ebp, %esi
leaq 0x2e44(%rip), %rdx      # 0x99b5
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x6b85
addl %ebp, %eax
cmpl $0x200, %eax            # imm = 0x200
jle 0x6ba0
callq 0x2060
movl $0x1c, (%rax)
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %esi
movq %rsp, %rdi
xorl %edx, %edx
movq %r14, %rcx
movl %ebx, %r8d
callq 0x8058
jmp 0x6b90
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: send_error
static int
send_error(const struct sockaddr *sa, int salen,
           unsigned char *tid, int tid_len,
           int code, const char *message)
{
    char buf[512];
    int i = 0, rc, message_len;

    message_len = strlen(message);
    rc = snprintf(buf + i, 512 - i, "d1:eli%de%d:", code, message_len);
    INC(i, rc, 512);
    COPY(buf, i, message, message_len, 512);
    rc = snprintf(buf + i, 512 - i, "e1:t%d:", tid_len); INC(i, rc, 512);
    COPY(buf, i, tid, tid_len, 512);
    ADD_V(buf, i, 512);
    rc = snprintf(buf + i, 512 - i, "1:y1:ee"); INC(i, rc, 512);
    return dht_send(buf, i, 0, sa, salen);

 fail:
    errno = ENOSPC;
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %r8, %r13
movl %ecx, %r12d
movq %rdx, %r15
movl %esi, 0xc(%rsp)
movq %rdi, %r14
movq %r8, %rdi
callq 0x20f0
movq %rax, %rbp
leaq 0x27e0(%rip), %rdx      # 0x99f0
leaq 0x10(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
movl $0xcb, %ecx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x2110
cmpl $0x201, %eax            # imm = 0x201
setae %cl
testl %ebp, %ebp
sets %dl
orb %cl, %dl
jne 0x7314
leal (%rax,%rbp), %ebx
cmpl $0x200, %ebx            # imm = 0x200
jg 0x7314
movl %eax, %eax
leaq (%rsp,%rax), %rdi
addq $0x10, %rdi
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2200
movl %ebx, %eax
leaq (%rsp,%rax), %rdi
addq $0x10, %rdi
movl $0x200, %esi            # imm = 0x200
subl %ebx, %esi
leaq 0x26dc(%rip), %rdx      # 0x995c
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x7314
addl %ebx, %eax
cmpl $0x200, %eax            # imm = 0x200
jg 0x7314
leal (%rax,%r12), %ebp
cmpl $0x200, %ebp            # imm = 0x200
jg 0x7314
movl %eax, %eax
leaq (%rsp,%rax), %rdi
addq $0x10, %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x2200
cmpb $0x1, 0x69b9(%rip)      # 0xdc7c
jne 0x72e8
cmpl $0x1f7, %ebp            # imm = 0x1F7
ja 0x7314
movl %ebp, %eax
addl $0x9, %ebp
movb 0x69a0(%rip), %cl       # 0xdc78
movb %cl, 0x18(%rsp,%rax)
movq 0x698d(%rip), %rcx      # 0xdc70
movq %rcx, 0x10(%rsp,%rax)
movl %ebp, %eax
leaq (%rsp,%rax), %rdi
addq $0x10, %rdi
movl $0x200, %esi            # imm = 0x200
subl %ebp, %esi
leaq 0x26fd(%rip), %rdx      # 0x99fd
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x7314
addl %ebp, %eax
cmpl $0x200, %eax            # imm = 0x200
jle 0x7331
callq 0x2060
movl $0x1c, (%rax)
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %esi
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
movq %r14, %rcx
movl 0xc(%rsp), %r8d
callq 0x8058
jmp 0x731f
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: make_token
static void
make_token(const struct sockaddr *sa, int old, unsigned char *token_return)
{
    void *ip;
    int iplen;
    unsigned short port;

    if(sa->sa_family == AF_INET) {
        struct sockaddr_in *sin = (struct sockaddr_in*)sa;
        ip = &sin->sin_addr;
        iplen = 4;
        port = htons(sin->sin_port);
    } else if(sa->sa_family == AF_INET6) {
        struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa;
        ip = &sin6->sin6_addr;
        iplen = 16;
        port = htons(sin6->sin6_port);
    } else {
        abort();
    }

    dht_hash(token_return, TOKEN_SIZE,
             old ? oldsecret : secret, sizeof(secret),
             ip, iplen, (unsigned char*)&port, 2);
}

// Assembly:
pushq %rax
movzwl (%rdi), %eax
cmpl $0x2, %eax
je 0x7365
cmpl $0xa, %eax
jne 0x73b8
movl $0x10, %r9d
movl $0x8, %r8d
jmp 0x7371
movl $0x4, %r9d
movl $0x4, %r8d
movzwl 0x2(%rdi), %eax
rolw $0x8, %ax
addq %rdi, %r8
leaq 0x6(%rsp), %r10
movw %ax, (%r10)
testl %esi, %esi
leaq 0x6922(%rip), %rcx      # 0xdcb0
leaq 0x6933(%rip), %rax      # 0xdcc8
cmoveq %rcx, %rax
movq %rdx, %rdi
movl $0x8, %esi
movq %rax, %rdx
movl $0x8, %ecx
pushq $0x2
pushq %r10
callq 0x3029
addq $0x10, %rsp
popq %rax
retq
callq 0x2050
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: token_match
static int
token_match(const unsigned char *token, int token_len,
            const struct sockaddr *sa)
{
    unsigned char t[TOKEN_SIZE];
    if(token_len != TOKEN_SIZE)
        return 0;
    make_token(sa, 0, t);
    if(memcmp(t, token, TOKEN_SIZE) == 0)
        return 1;
    make_token(sa, 1, t);
    if(memcmp(t, token, TOKEN_SIZE) == 0)
        return 1;
    return 0;
}

// Assembly:
xorl %eax, %eax
cmpl $0x8, %esi
jne 0x741d
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r14
movq %rdi, %rbx
leaq 0x8(%rsp), %r15
movq %rdx, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x7349
movq (%r15), %rax
cmpq (%rbx), %rax
je 0x740f
leaq 0x8(%rsp), %r15
movq %r14, %rdi
movl $0x1, %esi
movq %r15, %rdx
callq 0x7349
movq (%r15), %rcx
xorl %eax, %eax
cmpq (%rbx), %rcx
sete %al
jmp 0x7414
movl $0x1, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: send_peer_announced
static int
send_peer_announced(const struct sockaddr *sa, int salen,
                    unsigned char *tid, int tid_len)
{
    char buf[512];
    int i = 0, rc;

    rc = snprintf(buf + i, 512 - i, "d1:rd2:id20:"); INC(i, rc, 512);
    COPY(buf, i, myid, 20, 512);
    rc = snprintf(buf + i, 512 - i, "e1:t%d:", tid_len);
    INC(i, rc, 512);
    COPY(buf, i, tid, tid_len, 512);
    ADD_V(buf, i, 512);
    rc = snprintf(buf + i, 512 - i, "1:y1:re"); INC(i, rc, 512);
    return dht_send(buf, i, 0, sa, salen);

 fail:
    errno = ENOSPC;
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movl %ecx, %r12d
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r14
movabsq $0x3a303264693a32, %rax # imm = 0x3A303264693A32
leaq 0x20(%rsp), %rdi
movq %rax, -0x1b(%rdi)
movabsq $0x693a3264723a3164, %rax # imm = 0x693A3264723A3164
movq %rax, -0x20(%rdi)
movl 0x65ea(%rip), %eax      # 0xdc40
movl %eax, -0x4(%rdi)
movaps 0x65d0(%rip), %xmm0     # 0xdc30
movups %xmm0, -0x14(%rdi)
leaq 0x22f1(%rip), %rdx      # 0x995c
movl $0x1e0, %esi            # imm = 0x1E0
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x76f5
cmpl $0x1e0, %eax            # imm = 0x1E0
jg 0x76f5
addl $0x20, %eax
leal (%rax,%r12), %ebp
cmpl $0x200, %ebp            # imm = 0x200
jg 0x76f5
movl %eax, %eax
leaq (%rsp,%rax), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x2200
cmpb $0x1, 0x65d3(%rip)      # 0xdc7c
jne 0x76cd
cmpl $0x1f7, %ebp            # imm = 0x1F7
ja 0x76f5
movl %ebp, %eax
addl $0x9, %ebp
movb 0x65ba(%rip), %cl       # 0xdc78
movb %cl, 0x8(%rsp,%rax)
movq 0x65a7(%rip), %rcx      # 0xdc70
movq %rcx, (%rsp,%rax)
movl %ebp, %eax
leaq (%rsp,%rax), %rdi
movl $0x200, %esi            # imm = 0x200
subl %ebp, %esi
leaq 0x22d4(%rip), %rdx      # 0x99b5
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x76f5
addl %ebp, %eax
cmpl $0x200, %eax            # imm = 0x200
jle 0x7710
callq 0x2060
movl $0x1c, (%rax)
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %esi
movq %rsp, %rdi
xorl %edx, %edx
movq %r14, %rcx
movl %ebx, %r8d
callq 0x8058
jmp 0x7700
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: dht_insert_node
int
dht_insert_node(const unsigned char *id, struct sockaddr *sa, int salen)
{
    struct node *n;

    if(sa->sa_family != AF_INET && sa->sa_family != AF_INET6) {
        errno = EAFNOSUPPORT;
        return -1;
    }

    n = new_node(id, sa, salen, 0);
    return !!n;
}

// Assembly:
pushq %rax
movzwl (%rsi), %eax
orl $0x8, %eax
cmpl $0xa, %eax
jne 0x7ecf
xorl %ecx, %ecx
callq 0x607f
movq %rax, %rcx
xorl %eax, %eax
testq %rcx, %rcx
setne %al
jmp 0x7edf
callq 0x2060
movl $0x61, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: send_ping
int
send_ping(const struct sockaddr *sa, int salen,
          const unsigned char *tid, int tid_len)
{
    char buf[512];
    int i = 0, rc;
    rc = snprintf(buf + i, 512 - i, "d1:ad2:id20:"); INC(i, rc, 512);
    COPY(buf, i, myid, 20, 512);
    rc = snprintf(buf + i, 512 - i, "e1:q4:ping1:t%d:", tid_len);
    INC(i, rc, 512);
    COPY(buf, i, tid, tid_len, 512);
    ADD_V(buf, i, 512);
    rc = snprintf(buf + i, 512 - i, "1:y1:qe"); INC(i, rc, 512);
    return dht_send(buf, i, 0, sa, salen);

 fail:
    errno = ENOSPC;
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r14
movabsq $0x3a303264693a32, %rax # imm = 0x3A303264693A32
leaq 0x20(%rsp), %rdi
movq %rax, -0x1b(%rdi)
movabsq $0x693a3264613a3164, %rax # imm = 0x693A3264613A3164
movq %rax, -0x20(%rdi)
movl 0x5cef(%rip), %eax      # 0xdc40
movl %eax, -0x4(%rdi)
movaps 0x5cd5(%rip), %xmm0     # 0xdc30
movups %xmm0, -0x14(%rdi)
leaq 0x1a31(%rip), %rdx      # 0x9997
movl $0x1e0, %esi            # imm = 0x1E0
movl $0x4, %ecx
xorl %eax, %eax
callq 0x2110
cmpl $0x1e0, %eax            # imm = 0x1E0
ja 0x7fe5
cmpl $0x1dc, %eax            # imm = 0x1DC
jg 0x7fe5
leal 0x24(%rax), %ebp
movl %eax, %ecx
movl (%r15), %edx
movl %edx, 0x20(%rsp,%rcx)
cmpb $0x1, 0x5ce4(%rip)      # 0xdc7c
jne 0x7fbd
cmpl $0x1d3, %eax            # imm = 0x1D3
ja 0x7fe5
movl %ebp, %ecx
addl $0x2d, %eax
movb 0x5ccc(%rip), %dl       # 0xdc78
movb %dl, 0x8(%rsp,%rcx)
movq 0x5cb9(%rip), %rdx      # 0xdc70
movq %rdx, (%rsp,%rcx)
movl %eax, %ebp
movl %ebp, %eax
leaq (%rsp,%rax), %rdi
movl $0x200, %esi            # imm = 0x200
subl %ebp, %esi
leaq 0x1707(%rip), %rdx      # 0x96d8
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x7fe5
addl %ebp, %eax
cmpl $0x200, %eax            # imm = 0x200
jle 0x8003
callq 0x2060
movl $0x1c, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %esi
movq %rsp, %rdi
xorl %edx, %edx
movq %r14, %rcx
movl %ebx, %r8d
callq 0x8058
jmp 0x7ff5
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: pinged
static void
pinged(struct node *n, struct bucket *b)
{
    n->pinged++;
    n->pinged_time = now.tv_sec;
    if(n->pinged >= 3)
        send_cached_ping(b ? b : find_bucket(n->id, n->ss.ss_family));
}

// Assembly:
movl 0xb8(%rdi), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0xb8(%rdi)
movq 0x5be3(%rip), %rcx      # 0xdc10
movq %rcx, 0xb0(%rdi)
cmpl $0x2, %eax
jl 0x8057
testq %rsi, %rsi
jne 0x804f
pushq %rax
movzwl 0x18(%rdi), %esi
callq 0x35d4
movq %rax, %rsi
addq $0x8, %rsp
movq %rsi, %rdi
jmp 0x80ff
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: dht_send
static int
dht_send(const void *buf, size_t len, int flags,
         const struct sockaddr *sa, int salen)
{
    int s;

    if(salen == 0)
        abort();

    if(node_blacklisted(sa, salen)) {
        debugf("Attempting to send to blacklisted node.\n");
        errno = EPERM;
        return -1;
    }

    if(sa->sa_family == AF_INET)
        s = dht_socket;
    else if(sa->sa_family == AF_INET6)
        s = dht_socket6;
    else
        s = -1;

    if(s < 0) {
        errno = EAFNOSUPPORT;
        return -1;
    }

    return dht_sendto(s, buf, len, flags, sa, salen);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testl %r8d, %r8d
je 0x80fa
movl %r8d, %ebx
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r12
movq %rcx, %rdi
movl %r8d, %esi
callq 0x5e5d
testl %eax, %eax
je 0x80ad
leaq 0x1653(%rip), %rdi      # 0x96e0
xorl %eax, %eax
callq 0x366b
callq 0x2060
movl $0x1, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movzwl (%r14), %eax
cmpl $0xa, %eax
je 0x80c8
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
cmpl $0x2, %eax
jne 0x80ce
movl 0x4102(%rip), %edi      # 0xc1c8
jmp 0x80ce
movl 0x40fe(%rip), %edi      # 0xc1cc
testl %edi, %edi
js 0x80ed
movq %r12, %rsi
movl %r15d, %edx
movl %ebp, %ecx
movq %r14, %r8
movl %ebx, %r9d
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x301e
callq 0x2060
movl $0x61, (%rax)
jmp 0x809f
callq 0x2050
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: send_cached_ping
static int
send_cached_ping(struct bucket *b)
{
    unsigned char tid[4];
    int rc;
    /* We set family to 0 when there's no cached node. */
    if(b->cached.ss_family == 0)
        return 0;

    debugf("Sending ping to cached node.\n");
    make_tid(tid, "pn", 0);
    rc = send_ping((struct sockaddr*)&b->cached, b->cachedlen, tid, 4);
    b->cached.ss_family = 0;
    b->cachedlen = 0;
    return rc;
}

// Assembly:
cmpw $0x0, 0x30(%rdi)
je 0x814f
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x30(%rdi), %r14
leaq 0x15f1(%rip), %rdi      # 0x9709
xorl %eax, %eax
callq 0x366b
leaq 0x4(%rsp), %rdx
movl $0x6e70, (%rdx)         # imm = 0x6E70
movl 0xb0(%rbx), %esi
movq %r14, %rdi
callq 0x7f15
movw $0x0, 0x30(%rbx)
movl $0x0, 0xb0(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: add_search_node
static void
add_search_node(const unsigned char *id, const struct sockaddr *sa, int salen)
{
    struct search *sr;
    for(sr = searches; sr; sr = sr->next) {
        if(sr->af == sa->sa_family && sr->numnodes < SEARCH_NODES) {
            struct search_node *n =
                insert_search_node(id, sa, salen, sr, 0, NULL, 0);
            if(n)
                search_send_get_peers(sr, n);
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq 0x5aa9(%rip), %r12      # 0xdc08
testq %r12, %r12
je 0x81bc
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
movzwl (%r14), %eax
cmpl %eax, 0x4(%r12)
jne 0x81af
cmpl $0xd, 0xce0(%r12)
jg 0x81af
movl $0x0, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movq %r12, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x661c
testq %rax, %rax
je 0x81af
movq %r12, %rdi
movq %rax, %rsi
callq 0x685f
movq 0xce8(%r12), %r12
testq %r12, %r12
jne 0x816c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: split_bucket_helper
static int
split_bucket_helper(struct bucket *b, struct node **nodes_return)
{
    struct bucket *new;
    int rc;
    unsigned char new_id[20];

    if(!in_bucket(myid, b)) {
        debugf("Attempted to split wrong bucket.\n");
        return -1;
    }

    rc = bucket_middle(b, new_id);
    if(rc < 0)
        return -1;

    new = calloc(1, sizeof(struct bucket));
    if(new == NULL)
        return -1;

    send_cached_ping(b);

    new->af = b->af;
    memcpy(new->first, new_id, 20);
    new->time = b->time;

    *nodes_return = b->nodes;
    b->nodes = NULL;
    b->count = 0;
    new->next = b->next;
    b->next = new;

    if(in_bucket(myid, b)) {
        new->max_count = b->max_count;
        b->max_count = MAX(b->max_count / 2, 8);
    } else {
        new->max_count = MAX(b->max_count / 2, 8);
    }

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x7e61
testl %eax, %eax
je 0x82ef
leaq 0x4(%rbx), %r15
movq %r15, %rdi
callq 0x8330
movl %eax, %r12d
movq 0xb8(%rbx), %rdi
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x8215
addq $0x4, %rdi
callq 0x8330
cmpl %eax, %r12d
cmovgl %r12d, %eax
cmpl $0x9e, %eax
jg 0x8321
leal 0x1(%rax), %edx
movl 0x10(%r15), %ecx
movl %ecx, 0x10(%rsp)
movups (%r15), %xmm0
movaps %xmm0, (%rsp)
movl %edx, %ecx
andb $0x7, %cl
movl $0x80, %esi
shrl %cl, %esi
addl $0x8, %eax
testl %edx, %edx
cmovnsl %edx, %eax
sarl $0x3, %eax
cltq
orb %sil, (%rsp,%rax)
movl $0x1, %edi
movl $0xc0, %esi
callq 0x21a0
testq %rax, %rax
je 0x8321
movq %rax, %r15
movq %rbx, %rdi
callq 0x80ff
movl (%rbx), %eax
movl %eax, (%r15)
movaps (%rsp), %xmm0
movups %xmm0, 0x4(%r15)
movl 0x10(%rsp), %eax
movl %eax, 0x14(%r15)
movq 0x20(%rbx), %rax
movq %rax, 0x20(%r15)
movq 0x28(%rbx), %rax
movq %rax, (%r14)
movq $0x0, 0x28(%rbx)
movl $0x0, 0x18(%rbx)
movq 0xb8(%rbx), %rax
movq %rax, 0xb8(%r15)
movq %r15, 0xb8(%rbx)
movq %rbx, %rdi
callq 0x7e61
movl 0x1c(%rbx), %ecx
testl %eax, %eax
je 0x8304
movl %ecx, 0x1c(%r15)
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
cmpl $0x10, %ecx
movl $0x8, %ecx
cmovgel %eax, %ecx
movl %ecx, 0x1c(%rbx)
jmp 0x831c
leaq 0x1552(%rip), %rdi      # 0x9848
xorl %eax, %eax
callq 0x366b
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x8321
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
cmpl $0x10, %ecx
movl $0x8, %ecx
cmovgel %eax, %ecx
movl %ecx, 0x1c(%r15)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: lowbit
static int
lowbit(const unsigned char *id)
{
    int i, j;
    for(i = 19; i >= 0; i--)
        if(id[i] != 0)
            break;

    if(i < 0)
        return -1;

    for(j = 7; j >= 0; j--)
        if((id[i] & (0x80 >> j)) != 0)
            break;

    return 8 * i + j;
}

// Assembly:
movl $0x13, %eax
movl %eax, %ecx
cmpb $0x0, (%rdi,%rcx)
jne 0x8347
addl $-0x1, %eax
jb 0x8335
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x836d
movl %eax, %ecx
movzbl (%rdi,%rcx), %edx
movl $0x7, %ecx
movl %edx, %esi
shll %cl, %esi
testb %sil, %sil
js 0x8369
addl $-0x1, %ecx
jb 0x8356
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leal (%rcx,%rax,8), %eax
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
// File: /workspace/github_c_makefile_star2_O1/jech[P]dht/dht.c
// Function: random_node
static struct node *
random_node(struct bucket *b)
{
    struct node *n;
    int nn;

    if(b->count == 0)
        return NULL;

    nn = random() % b->count;
    n = b->nodes;
    while(nn > 0 && n) {
        n = n->next;
        nn--;
    }
    return n;
}

// Assembly:
cmpl $0x0, 0x18(%rdi)
je 0x83ba
pushq %rbx
movq %rdi, %rbx
callq 0x2230
movslq 0x18(%rbx), %rcx
cqto
idivq %rcx
movq 0x28(%rbx), %rax
testq %rdx, %rdx
setg %cl
testq %rax, %rax
setne %sil
andb %cl, %sil
cmpb $0x1, %sil
jne 0x83b8
movq 0xc0(%rax), %rax
cmpl $0x2, %edx
jl 0x83b8
decl %edx
testq %rax, %rax
jne 0x83a5
popq %rbx
retq
xorl %eax, %eax
retq