LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/DReichLab[P]adna/sam.c
// Function: bam_mplp_init
bam_mplp_t bam_mplp_init(int n, bam_plp_auto_f func, void **data)
{
	int i;
	bam_mplp_t iter;
	iter = (bam_mplp_t)calloc(1, sizeof(struct __bam_mplp_t));
	iter->pos = (uint64_t*)calloc(n, 8);
	iter->n_plp = (int*)calloc(n, sizeof(int));
	iter->plp = (const bam_pileup1_t**)calloc(n, sizeof(void*));
	iter->iter = (bam_plp_t*)calloc(n, sizeof(void*));
	iter->n = n;
	iter->min = (uint64_t)-1;
	for (i = 0; i < n; ++i) {
		iter->iter[i] = bam_plp_init(func, data[i]);
		iter->pos[i] = iter->min;
	}
	return iter;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %ebp
pushq $0x1
popq %rdi
pushq $0x30
popq %rsi
callq 0x21f0
movq %rax, %r15
movslq %ebp, %r12
pushq $0x8
popq %rbp
movq %r12, %rdi
movq %rbp, %rsi
callq 0x21f0
movq %rax, %r13
movq %rax, 0x10(%r15)
pushq $0x4
popq %rsi
movq %r12, %rdi
callq 0x21f0
movq %rax, 0x20(%r15)
movq %r12, %rdi
movq %rbp, %rsi
callq 0x21f0
movq %rax, 0x28(%r15)
movq %r12, %rdi
movq %rbp, %rsi
callq 0x21f0
movq %rax, %rbp
movq %rax, 0x18(%r15)
movl %r12d, (%r15)
movq %r15, (%rsp)
orq $-0x1, 0x8(%r15)
xorl %r15d, %r15d
testl %r12d, %r12d
cmovlel %r15d, %r12d
cmpq %r15, %r12
je 0xaf74
movq (%rbx,%r15,8), %rsi
movq %r14, %rdi
callq 0xa5a3
movq %rax, (%rbp,%r15,8)
orq $-0x1, (%r13,%r15,8)
incq %r15
jmp 0xaf53
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DReichLab[P]adna/sam.c
// Function: bam_mplp_auto
int bam_mplp_auto(bam_mplp_t iter, int *_tid, int *_pos, int *n_plp, const bam_pileup1_t **plp)
{
	int i, ret = 0;
	uint64_t new_min = (uint64_t)-1;
	for (i = 0; i < iter->n; ++i) {
		if (iter->pos[i] == iter->min) {
			int tid, pos;
			iter->plp[i] = bam_plp_auto(iter->iter[i], &tid, &pos, &iter->n_plp[i]);
			iter->pos[i] = (uint64_t)tid<<32 | pos;
		}
		if (iter->plp[i] && iter->pos[i] < new_min) new_min = iter->pos[i];
	}
	iter->min = new_min;
	if (new_min == (uint64_t)-1) return 0;
	*_tid = new_min>>32; *_pos = (uint32_t)new_min;
	for (i = 0; i < iter->n; ++i) {
		if (iter->pos[i] == iter->min) { // FIXME: valgrind reports "uninitialised value(s) at this line"
			n_plp[i] = iter->n_plp[i], plp[i] = iter->plp[i];
			++ret;
		} else n_plp[i] = 0, plp[i] = 0;
	}
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq %rdi, %r15
pushq $-0x1
popq %r13
xorl %ebp, %ebp
xorl %r12d, %r12d
movslq (%r15), %rax
cmpq %rax, %r12
jge 0xb0b7
movq 0x10(%r15), %rax
movq (%rax,%rbp,2), %rax
cmpq 0x8(%r15), %rax
jne 0xb09a
movq 0x18(%r15), %rax
movq (%rax,%rbp,2), %rdi
movq 0x20(%r15), %rcx
addq %rbp, %rcx
leaq 0x4(%rsp), %rsi
movq %rsp, %rdx
callq 0xadc7
movq 0x28(%r15), %rcx
movq %rax, (%rcx,%rbp,2)
movl 0x4(%rsp), %ecx
shlq $0x20, %rcx
movslq (%rsp), %rax
orq %rcx, %rax
movq 0x10(%r15), %rcx
movq %rax, (%rcx,%rbp,2)
movq 0x28(%r15), %rcx
cmpq %r13, %rax
cmovaeq %r13, %rax
cmpq $0x0, (%rcx,%rbp,2)
cmovneq %rax, %r13
incq %r12
addq $0x4, %rbp
jmp 0xb049
movq %r13, 0x8(%r15)
cmpq $-0x1, %r13
je 0xb111
movq %r13, %rax
shrq $0x20, %rax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx)
movq 0x10(%rsp), %rax
movl %r13d, (%rax)
xorl %ecx, %ecx
xorl %eax, %eax
movslq (%r15), %rdx
cmpq %rdx, %rcx
jge 0xb113
movq 0x10(%r15), %rdx
cmpq %r13, (%rdx,%rcx,8)
jne 0xb100
movq 0x20(%r15), %rdx
movq 0x28(%r15), %rsi
movl (%rdx,%rcx,4), %edx
movq (%rsi,%rcx,8), %rsi
incl %eax
jmp 0xb104
xorl %edx, %edx
xorl %esi, %esi
movl %edx, (%r14,%rcx,4)
movq %rsi, (%rbx,%rcx,8)
incq %rcx
jmp 0xb0db
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x3
popq %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x20d0
testl %eax, %eax
js 0x2d8b
orl $0x800, %eax            # imm = 0x800
pushq $0x4
popq %rsi
movl %ebx, %edi
movl %eax, %edx
xorl %eax, %eax
callq 0x20d0
sarl $0x1f, %eax
jmp 0x2d8e
pushq $-0x1
popq %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x2dea
leaq 0x5271(%rip), %rcx      # 0x8010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
pushq $0x6
popq %rcx
movq %r8, %rax
xorl %edx, %edx
divq %rcx
leaq 0x5387(%rip), %rdi      # 0x8141
jmp 0x2de6
leaq 0x5440(%rip), %rdi      # 0x8203
jmp 0x20a0
leaq 0x5422(%rip), %rdi      # 0x81f1
jmp 0x20a0
pushq $0x12
popq %rcx
movq %r8, %rax
xorl %edx, %edx
divq %rcx
leaq 0x5370(%rip), %rdi      # 0x8156
movl %eax, %esi
jmp 0x2df1
leaq 0x537f(%rip), %rdi      # 0x8170
xorl %eax, %eax
jmp 0x2100
// File: /workspace/github_c_makefile_star2_O2/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
movq 0x30(%rsp), %rsi
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movslq %ecx, %rcx
xorl %edi, %edi
movb $0x60, %r9b
cmpq $0x1, %rdi
ja 0x2e46
cmpq %rcx, %rdi
jge 0x2e46
movsbl (%rdx,%rdi), %eax
idivb %r9b
movsbl %ah, %eax
addb $0x20, %al
movb %al, 0x8(%rsp,%rdi)
incq %rdi
jmp 0x2e26
xorl %edx, %edx
movb $0x60, %dil
cmpq $0x3, %rdx
ja 0x2e6c
cmpq %rcx, %rdx
jge 0x2e6c
movsbl (%r8,%rdx), %eax
idivb %dil
movsbl %ah, %eax
addb $0x20, %al
movb %al, 0xa(%rsp,%rdx)
incq %rdx
jmp 0x2e4b
xorl %edx, %edx
movb $0x60, %dil
cmpq $0x1, %rdx
ja 0x2e91
cmpq %rcx, %rdx
jge 0x2e91
movsbl (%rsi,%rdx), %eax
idivb %dil
movsbl %ah, %eax
addb $0x20, %al
movb %al, 0xe(%rsp,%rdx)
incq %rdx
jmp 0x2e71
leaq 0x52a6(%rip), %rsi      # 0x813e
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_O2/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 0x5185(%rip), %rdi      # 0x8050
xorl %esi, %esi
xorl %eax, %eax
callq 0x22a0
testl %eax, %eax
js 0x2f01
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 0x2f04
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0xa9a5(%rip), %rax      # 0xdc50
leaq 0xa9a6(%rip), %rcx      # 0xdc58
cmoveq %rax, %rcx
movq (%rcx), %r15
testq %r15, %r15
je 0x32e2
movq %rdi, %rbx
movq %r15, %r14
movq 0xb8(%r15), %r15
testq %r15, %r15
je 0x32e5
leaq 0x4(%r15), %rsi
movq %rbx, %rdi
callq 0x33d2
testl %eax, %eax
jns 0x32c1
jmp 0x32e5
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0xa964(%rip), %rbx      # 0xdc60
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x3319
movq %r14, %rdi
movq %rbx, %rsi
callq 0x33d2
testl %eax, %eax
je 0x3319
addq $0x28, %rbx
jmp 0x32fc
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x3382
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 0xa857(%rip), %rdi      # 0xdc00
testq %rdi, %rdi
je 0x33b9
movq %rsp, %rdx
movq %r10, %rsi
callq 0x22d0
movq 0xa840(%rip), %rdi      # 0xdc00
testq %rdi, %rdi
je 0x33ca
callq 0x2240
addq $0xd8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/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
leaq -0x30(%rdi), %rax
movl $0xe8, %ecx
cqto
idivq %rcx
movslq %eax, %r15
imulq $0xe8, %r15, %rax
leaq (%rax,%rsi), %r14
addq $0x118, %r14            # imm = 0x118
movslq 0xce0(%rbx), %rax
decq %rax
cmpq %rax, %r15
jge 0x3437
leaq -0xe8(%r14), %rdi
incq %r15
movl $0xe8, %edx
movq %r14, %rsi
callq 0x2200
addq $0xe8, %r14
jmp 0x3408
movl %eax, 0xce0(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/jech[P]dht/dht.c
// Function: insert_search_bucket
static void
insert_search_bucket(struct bucket *b, struct search *sr)
{
    struct node *n;
    n = b->nodes;
    while(n) {
        insert_search_node(n->id, (struct sockaddr*)&n->ss, n->sslen,
                           sr, 0, NULL, 0);
        n = n->next;
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
addq $0x28, %r14
movq (%r14), %r14
testq %r14, %r14
je 0x3482
leaq 0x18(%r14), %rsi
movl 0x98(%r14), %edx
andl $0x0, (%rsp)
movq %r14, %rdi
movq %rbx, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x620b
addq $0xc0, %r14
jmp 0x3451
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/jech[P]dht/dht.c
// Function: previous_bucket
static struct bucket *
previous_bucket(struct bucket *b)
{
    struct bucket *p = b->af == AF_INET ? buckets : buckets6;

    if(b == p)
        return NULL;

    while(1) {
        if(p->next == NULL)
            return NULL;
        if(p->next == b)
            return p;
        p = p->next;
    }
}

// Assembly:
cmpl $0x2, (%rdi)
leaq 0xa7bc(%rip), %rax      # 0xdc50
leaq 0xa7bd(%rip), %rcx      # 0xdc58
cmoveq %rax, %rcx
movq (%rcx), %rcx
cmpq %rdi, %rcx
je 0x34bc
movq %rcx, %rax
movq 0xb8(%rcx), %rcx
testq %rcx, %rcx
je 0x34bc
cmpq %rdi, %rcx
jne 0x34a7
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
cmpl $0x2, %edi
leaq 0xa3b0(%rip), %rax      # 0xdc50
leaq 0xa3b1(%rip), %rcx      # 0xdc58
cmoveq %rax, %rcx
movq (%rcx), %r12
xorl %ebx, %ebx
xorl %ebp, %ebp
xorl %r15d, %r15d
xorl %r14d, %r14d
testq %r12, %r12
je 0x3911
leaq 0x28(%r12), %r13
movq (%r13), %r13
testq %r13, %r13
je 0x38fc
movq %r13, %rdi
callq 0x3956
testl %eax, %eax
je 0x38f1
incl %ebx
movq 0xa0(%r13), %rax
xorl %ecx, %ecx
cmpq 0xa8(%r13), %rax
setg %cl
addl %ecx, %r14d
jmp 0x38f3
incl %ebp
addq $0xc0, %r13
jmp 0x38c2
cmpw $0x1, 0x30(%r12)
sbbl $-0x1, %r15d
movq 0xb8(%r12), %r12
jmp 0x38b8
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rdx
je 0x392c
movl %ebx, (%rsi)
testq %rdx, %rdx
je 0x3933
movl %ebp, (%rdx)
testq %rcx, %rcx
je 0x393b
movl %r15d, (%rcx)
testq %rax, %rax
je 0x3943
movl %r14d, (%rax)
addl %ebx, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jech[P]dht/dht.c
// Function: node_good
static int
node_good(struct node *node)
{
    return
        node->pinged <= 2 &&
        node->reply_time >= now.tv_sec - 7200 &&
        node->time >= now.tv_sec - 900;
}

// Assembly:
xorl %eax, %eax
cmpl $0x2, 0xb8(%rdi)
jg 0x398b
movq 0xa2a8(%rip), %rcx      # 0xdc10
leaq -0x1c20(%rcx), %rdx
cmpq %rdx, 0xa8(%rdi)
jl 0x398b
addq $-0x384, %rcx           # imm = 0xFC7C
xorl %eax, %eax
cmpq %rcx, 0xa0(%rdi)
setge %al
retq
// File: /workspace/github_c_makefile_star2_O2/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 %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
callq 0x329c
testq %rax, %rax
je 0x3fa8
movq %rax, %rbx
addq $0x28, %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x3fa8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x33d2
testl %eax, %eax
je 0x3faa
addq $0xc0, %rbx
jmp 0x3f88
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/jech[P]dht/dht.c
// Function: rotate_secrets
static int
rotate_secrets(void)
{
    int rc;

    rotate_secrets_time = now.tv_sec + 900 + random() % 1800;

    memcpy(oldsecret, secret, sizeof(secret));
    rc = dht_random_bytes(secret, sizeof(secret));

    if(rc < 0)
        return -1;

    return 1;
}

// Assembly:
pushq %rbx
movq 0x9a63(%rip), %rbx      # 0xdc10
callq 0x2230
movl $0x708, %ecx            # imm = 0x708
cqto
idivq %rcx
leaq (%rbx,%rdx), %rax
addq $0x384, %rax            # imm = 0x384
movq %rax, 0x9aeb(%rip)      # 0xdcb8
leaq 0x9adc(%rip), %rdi      # 0xdcb0
movq 0x9ad5(%rip), %rax      # 0xdcb0
movq %rax, 0x9ae6(%rip)      # 0xdcc8
pushq $0x8
popq %rsi
callq 0x2eb7
sarl $0x1f, %eax
orl $0x1, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
pushq $0x1
popq %rbp
testq %rbx, %rbx
je 0x427c
xorl %eax, %eax
movq 0x28(%rbx), %r14
testq %r14, %r14
je 0x4262
cmpl $0x3, 0xb8(%r14)
jle 0x4262
movq 0xc0(%r14), %rax
movq %rax, 0x28(%rbx)
decl 0x18(%rbx)
movq %r14, %rdi
callq 0x2040
movl %ebp, %eax
jmp 0x4203
movq 0xc0(%r14), %rdi
testq %rdi, %rdi
je 0x425f
cmpl $0x4, 0xb8(%rdi)
jl 0x425f
movq 0xc0(%rdi), %rax
movq %rax, 0xc0(%r14)
decl 0x18(%rbx)
callq 0x2040
movl %ebp, %eax
jmp 0x4230
movq %rdi, %r14
testq %r14, %r14
jne 0x4230
testl %eax, %eax
je 0x4273
movq %rbx, %rdi
callq 0x75ba
movq 0xb8(%rbx), %rbx
jmp 0x41fc
movq 0x998d(%rip), %rbx      # 0xdc10
callq 0x2230
movl $0xf0, %ecx
cqto
idivq %rcx
leaq (%rbx,%rdx), %rax
addq $0x78, %rax
movq %rax, 0x9a1f(%rip)      # 0xdcc0
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
cmpl $0x0, 0x7f1a(%rip)      # 0xc1c8
jns 0x42cb
cmpl $0x0, 0x7f15(%rip)      # 0xc1cc
jns 0x42cb
callq 0x2060
movl $0x16, (%rax)
pushq $-0x1
popq %rbx
movl %ebx, %eax
popq %rbx
retq
orl $-0x1, 0x7ef6(%rip)     # 0xc1c8
orl $-0x1, 0x7ef3(%rip)     # 0xc1cc
movq 0x9970(%rip), %rbx      # 0xdc50
testq %rbx, %rbx
je 0x4349
movq 0xb8(%rbx), %rax
movq %rax, 0x995d(%rip)      # 0xdc50
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x430e
movq 0xc0(%rdi), %rax
movq %rax, 0x28(%rbx)
callq 0x2040
jmp 0x42f3
movq %rbx, %rdi
callq 0x2040
jmp 0x42d9
movq 0xb8(%rbx), %rax
movq %rax, 0x9932(%rip)      # 0xdc58
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x4341
movq 0xc0(%rdi), %rax
movq %rax, 0x28(%rbx)
callq 0x2040
jmp 0x4326
movq %rbx, %rdi
callq 0x2040
movq 0x9908(%rip), %rbx      # 0xdc58
testq %rbx, %rbx
jne 0x4318
jmp 0x4373
movq 0x28(%rbx), %rax
movq %rax, 0x98fe(%rip)      # 0xdc60
movq 0x20(%rbx), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
movq 0x98e6(%rip), %rbx      # 0xdc60
testq %rbx, %rbx
jne 0x4357
pushq $0x1
popq %rbx
movq 0x987f(%rip), %rdi      # 0xdc08
testq %rdi, %rdi
je 0x42c7
movq 0xce8(%rdi), %rax
movq %rax, 0x9868(%rip)      # 0xdc08
callq 0x2040
jmp 0x4382
// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movzwl (%rdi), %eax
cmpl $0xa, %eax
je 0x5af1
cmpl $0x2, %eax
jne 0x5b50
movb $0x1, %bpl
cmpw $0x0, 0x2(%rbx)
je 0x5b52
movzbl 0x4(%rbx), %eax
testl %eax, %eax
je 0x5b52
cmpl $0x7f, %eax
je 0x5b52
cmpb $-0x20, %al
setae %bpl
jmp 0x5b52
movb $0x1, %bpl
cmpw $0x0, 0x2(%rbx)
je 0x5b52
leaq 0x8(%rbx), %r14
movzbl (%r14), %eax
cmpl $0xff, %eax
je 0x5b52
cmpl $0xfe, %eax
jne 0x5b1a
movb 0x9(%rbx), %al
andb $-0x40, %al
negb %al
jo 0x5b52
leaq 0x270f(%rip), %rsi      # 0x8230
pushq $0xf
popq %rdx
movq %r14, %rdi
callq 0x2260
testl %eax, %eax
jne 0x5b36
cmpb $0x2, 0x17(%rbx)
jb 0x5b52
leaq 0x2713(%rip), %rsi      # 0x8250
pushq $0xc
popq %rdx
movq %r14, %rdi
callq 0x2260
testl %eax, %eax
sete %bpl
jmp 0x5b52
xorl %ebp, %ebp
movzbl %bpl, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x5bbd
movl %esi, %r14d
movq %rdi, %rbx
callq 0x2e00
pushq $0x1
popq %rbp
testl %eax, %eax
jne 0x5bb2
movl %r14d, %r14d
xorl %edi, %edi
leaq 0x8147(%rip), %r15      # 0xdcd0
leaq 0x80(%rdi), %r12
cmpq $0x580, %r12            # imm = 0x580
je 0x5bb0
addq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2260
movq %r12, %rdi
testl %eax, %eax
jne 0x5b89
jmp 0x5bb2
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_O2/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, 0x8036(%rip)      # 0xdc00
je 0x5c16
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
xorl %r15d, %r15d
testl %esi, %esi
cmovlel %r15d, %ebx
pushq $0x2e
popq %rbp
cmpq %r15, %rbx
je 0x5c0c
movzbl (%r14,%r15), %eax
leal -0x20(%rax), %ecx
cmpb $0x5f, %cl
jb 0x5bf8
movl %ebp, %eax
movzbl %al, %edi
movq 0x7ffe(%rip), %rsi      # 0xdc00
callq 0x21b0
incq %r15
jmp 0x5be4
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x2b64(%rip), %rdi      # 0x8795
xorl %eax, %eax
callq 0x3324
testq %r14, %r14
je 0x5cb2
movzwl (%rbx), %esi
movq %r14, %rdi
callq 0x3f70
testq %rax, %rax
je 0x5c61
movl $0x3, 0xb8(%rax)
movq %rax, %rdi
xorl %esi, %esi
callq 0x74d5
leaq 0x7fa0(%rip), %r15      # 0xdc08
movq (%r15), %r15
testq %r15, %r15
je 0x5cb2
leaq 0x30(%r15), %r12
xorl %r13d, %r13d
movslq 0xce0(%r15), %rax
cmpq %rax, %r13
jge 0x5ca9
movq %r12, %rdi
movq %r14, %rsi
callq 0x33d2
testl %eax, %eax
jne 0x5c9d
movq %r12, %rdi
movq %r15, %rsi
callq 0x33da
incq %r13
addq $0xe8, %r12
jmp 0x5c77
addq $0xce8, %r15            # imm = 0xCE8
jmp 0x5c68
movslq 0x7fdf(%rip), %r14      # 0xdc98
movq %r14, %rax
shlq $0x7, %rax
leaq 0x8009(%rip), %rdi      # 0xdcd0
addq %rax, %rdi
movslq %ebp, %rdx
movq %rbx, %rsi
callq 0x2200
leal 0x1(%r14), %eax
pushq $0xa
popq %rcx
cltd
idivl %ecx
movl %edx, 0x7fb3(%rip)      # 0xdc98
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jech[P]dht/dht.c
// Function: find_search
static struct search *
find_search(unsigned short tid, int af)
{
    struct search *sr = searches;
    while(sr) {
        if(sr->tid == tid && sr->af == af)
            return sr;
        sr = sr->next;
    }
    return NULL;
}

// Assembly:
leaq 0x7a18(%rip), %rax      # 0xdc08
movq (%rax), %rax
testq %rax, %rax
je 0x620a
cmpw %di, (%rax)
jne 0x6202
cmpl %esi, 0x4(%rax)
je 0x620a
addq $0xce8, %rax            # imm = 0xCE8
jmp 0x61f0
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x1de7(%rip), %rdx      # 0x89e0
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 0x6cfd
leal (%rax,%rbp), %ebx
cmpl $0x200, %ebx            # imm = 0x200
ja 0x6cfd
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 0x1ce3(%rip), %rdx      # 0x894c
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x6cfd
addl %ebx, %eax
cmpl $0x200, %eax            # imm = 0x200
ja 0x6cfd
leal (%rax,%r12), %ebp
cmpl $0x200, %ebp            # imm = 0x200
jg 0x6cfd
movl %eax, %eax
leaq (%rsp,%rax), %rdi
addq $0x10, %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x2200
cmpb $0x1, 0x6fd0(%rip)      # 0xdc7c
jne 0x6cd1
cmpl $0x1f7, %ebp            # imm = 0x1F7
ja 0x6cfd
movl %ebp, %eax
addl $0x9, %ebp
movb 0x6fb7(%rip), %cl       # 0xdc78
movb %cl, 0x18(%rsp,%rax)
movq 0x6fa4(%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 0x1d04(%rip), %rdx      # 0x89ed
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x6cfd
addl %ebp, %eax
cmpl $0x200, %eax            # imm = 0x200
jle 0x6d1a
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 0x7516
jmp 0x6d08
// File: /workspace/github_c_makefile_star2_O2/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 0x6d48
cmpl $0xa, %eax
jne 0x6d90
pushq $0x10
popq %r9
pushq $0x8
jmp 0x6d4e
pushq $0x4
popq %r9
pushq $0x4
popq %r8
movzwl 0x2(%rdi), %eax
rolw $0x8, %ax
addq %rdi, %r8
leaq 0x6(%rsp), %r10
movw %ax, (%r10)
testl %esi, %esi
leaq 0x6f43(%rip), %rcx      # 0xdcb0
leaq 0x6f54(%rip), %rax      # 0xdcc8
cmoveq %rcx, %rax
pushq $0x8
popq %rcx
movq %rdx, %rdi
movl %ecx, %esi
movq %rax, %rdx
pushq $0x2
pushq %r10
callq 0x2e03
popq %rax
popq %rcx
popq %rax
retq
callq 0x2050
// File: /workspace/github_c_makefile_star2_O2/jech[P]dht/dht.c
// Function: neighbourhood_maintenance
static int
neighbourhood_maintenance(int af)
{
    unsigned char id[20];
    struct bucket *b = find_bucket(myid, af);
    struct bucket *q;
    struct node *n;

    if(b == NULL)
        return 0;

    memcpy(id, myid, 20);
    id[19] = random() & 0xFF;
    q = b;
    if(q->next && (q->count == 0 || (random() & 7) == 0))
        q = b->next;
    if(q->count == 0 || (random() & 7) == 0) {
        struct bucket *r;
        r = previous_bucket(b);
        if(r && r->count > 0)
            q = r;
    }

    if(q) {
        /* Since our node-id is the same in both DHTs, it's probably
           profitable to query both families. */
        int want = dht_socket >= 0 && dht_socket6 >= 0 ? (WANT4 | WANT6) : -1;
        n = random_node(q);
        if(n) {
            unsigned char tid[4];
            debugf("Sending find_node for%s neighborhood maintenance.\n",
                   af == AF_INET6 ? " IPv6" : "");
            make_tid(tid, "fn", 0);
            send_find_node((struct sockaddr*)&n->ss, n->sslen,
                           tid, 4, id, want,
                           n->reply_time >= now.tv_sec - 15);
            pinged(n, q);
        }
        return 1;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edi, %ebp
leaq 0x6c20(%rip), %rdi      # 0xdc30
movl %ebp, %esi
callq 0x329c
testq %rax, %rax
je 0x7134
movq %rax, %r14
movl 0x6c17(%rip), %eax      # 0xdc40
movl %eax, 0x20(%rsp)
movaps 0x6bfc(%rip), %xmm0     # 0xdc30
movaps %xmm0, 0x10(%rsp)
callq 0x2230
movb %al, 0x23(%rsp)
movq 0xb8(%r14), %rax
movq %r14, %rbx
testq %rax, %rax
je 0x706e
cmpl $0x0, 0x18(%r14)
movq %rax, %rbx
je 0x706e
callq 0x2230
movq %r14, %rbx
testb $0x7, %al
jne 0x706e
movq 0xb8(%r14), %rbx
cmpl $0x0, 0x18(%rbx)
je 0x707d
callq 0x2230
testb $0x7, %al
jne 0x7092
movq %r14, %rdi
callq 0x348a
testq %rax, %rax
je 0x7092
cmpl $0x0, 0x18(%rax)
cmovgq %rax, %rbx
movl 0x512f(%rip), %r15d     # 0xc1c8
movl 0x512c(%rip), %r13d     # 0xc1cc
movq %rbx, %rdi
callq 0x782a
pushq $0x1
popq %r14
testq %rax, %rax
je 0x7137
movq %rax, %r12
orl %r13d, %r15d
sarl $0x1f, %r15d
orl $0x3, %r15d
cmpl $0xa, %ebp
leaq 0x1466(%rip), %rax      # 0x8533
leaq 0x1244(%rip), %rsi      # 0x8318
cmoveq %rax, %rsi
leaq 0x1875(%rip), %rdi      # 0x8954
xorl %eax, %eax
callq 0x3324
leaq 0xc(%rsp), %rdx
movl $0x6e66, (%rdx)         # imm = 0x6E66
movq %r12, %rdi
addq $0x18, %rdi
movl 0x98(%r12), %esi
movq 0x6b09(%rip), %rax      # 0xdc10
addq $-0xf, %rax
xorl %r9d, %r9d
cmpq %rax, 0xa8(%r12)
setge %r9b
leaq 0x10(%rsp), %rcx
movl %r15d, %r8d
callq 0x7864
movq %r12, %rdi
movq %rbx, %rsi
callq 0x74d5
jmp 0x7137
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x7393
xorl %ecx, %ecx
callq 0x5cf4
movq %rax, %rcx
xorl %eax, %eax
testq %rcx, %rcx
setne %al
jmp 0x73a1
callq 0x2060
movl $0x61, (%rax)
pushq $-0x1
popq %rax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x682d(%rip), %eax      # 0xdc40
movl %eax, -0x4(%rdi)
movaps 0x6813(%rip), %xmm0     # 0xdc30
movups %xmm0, -0x14(%rdi)
leaq 0x155f(%rip), %rdx      # 0x8987
pushq $0x4
popq %rcx
movl $0x1e0, %esi            # imm = 0x1E0
xorl %eax, %eax
callq 0x2110
cmpl $0x1e0, %eax            # imm = 0x1E0
ja 0x74a5
cmpl $0x1dc, %eax            # imm = 0x1DC
ja 0x74a5
leal 0x24(%rax), %ebp
movl %eax, %ecx
movl (%r15), %edx
movl %edx, 0x20(%rsp,%rcx)
cmpb $0x1, 0x6824(%rip)      # 0xdc7c
jne 0x747d
cmpl $0x1d3, %eax            # imm = 0x1D3
ja 0x74a5
movl %ebp, %ecx
addl $0x2d, %eax
movb 0x680c(%rip), %dl       # 0xdc78
movb %dl, 0x8(%rsp,%rcx)
movq 0x67f9(%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 0x1237(%rip), %rdx      # 0x86c8
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x74a5
addl %ebp, %eax
cmpl $0x200, %eax            # imm = 0x200
jbe 0x74c1
callq 0x2060
movl $0x1c, (%rax)
pushq $-0x1
popq %rax
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 0x7516
jmp 0x74b3
// File: /workspace/github_c_makefile_star2_O2/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 0x6725(%rip), %rcx      # 0xdc10
movq %rcx, 0xb0(%rdi)
cmpl $0x2, %eax
jl 0x7515
testq %rsi, %rsi
jne 0x750d
pushq %rax
movzwl 0x18(%rdi), %esi
callq 0x329c
movq %rax, %rsi
addq $0x8, %rsp
movq %rsi, %rdi
jmp 0x75ba
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x75b5
movl %r8d, %ebx
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r12
movq %rcx, %rdi
movl %r8d, %esi
callq 0x5b5b
testl %eax, %eax
je 0x755f
leaq 0x1185(%rip), %rdi      # 0x86d0
xorl %eax, %eax
callq 0x3324
callq 0x2060
movl $0x1, (%rax)
jmp 0x75a9
movzwl (%r14), %eax
cmpl $0x2, %eax
je 0x7576
cmpl $0xa, %eax
jne 0x759e
leaq 0x4c58(%rip), %rax      # 0xc1cc
jmp 0x757d
leaq 0x4c4b(%rip), %rax      # 0xc1c8
movl (%rax), %edi
testl %edi, %edi
js 0x759e
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 0x2df8
callq 0x2060
movl $0x61, (%rax)
pushq $-0x1
popq %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x2050
// File: /workspace/github_c_makefile_star2_O2/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 0x7606
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x30(%rdi), %r14
leaq 0x1126(%rip), %rdi      # 0x86f9
xorl %eax, %eax
callq 0x3324
leaq 0x4(%rsp), %rdx
movl $0x6e70, (%rdx)         # imm = 0x6E70
movl 0xb0(%rbx), %esi
movq %r14, %rdi
callq 0x73d7
andw $0x0, 0x30(%rbx)
andl $0x0, 0xb0(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/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
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x65ea(%rip), %r12      # 0xdc08
movq (%r12), %r12
testq %r12, %r12
je 0x7670
movzwl (%r14), %eax
cmpl %eax, 0x4(%r12)
jne 0x7667
cmpl $0xd, 0xce0(%r12)
jg 0x7667
andl $0x0, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movq %r12, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x620b
testq %rax, %rax
je 0x7667
movq %r12, %rdi
movq %rax, %rsi
callq 0x63da
addq $0xce8, %r12            # imm = 0xCE8
jmp 0x761e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x7331
testl %eax, %eax
je 0x778e
leaq 0x4(%rbx), %r15
movq %r15, %rdi
callq 0x77c5
movl %eax, %r12d
movq 0xb8(%rbx), %rdi
pushq $-0x1
popq %rbp
movl %ebp, %eax
testq %rdi, %rdi
je 0x76c4
addq $0x4, %rdi
callq 0x77c5
cmpl %eax, %r12d
cmovgl %r12d, %eax
cmpl $0x9e, %eax
jg 0x77b6
incl %eax
movl 0x10(%r15), %ecx
movl %ecx, 0x10(%rsp)
movups (%r15), %xmm0
movaps %xmm0, (%rsp)
movl %eax, %ecx
andb $0x7, %cl
movl $0x80, %esi
shrl %cl, %esi
pushq $0x8
popq %r12
cltd
idivl %r12d
cltq
orb %sil, (%rsp,%rax)
pushq $0x1
popq %rdi
movl $0xc0, %esi
callq 0x21a0
testq %rax, %rax
je 0x77b6
movq %rax, %r15
movq %rbx, %rdi
callq 0x75ba
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)
andq $0x0, 0x28(%rbx)
andl $0x0, 0x18(%rbx)
movq 0xb8(%rbx), %rax
movq %rax, 0xb8(%r15)
movq %r15, 0xb8(%rbx)
movq %rbx, %rdi
callq 0x7331
movl 0x1c(%rbx), %ecx
testl %eax, %eax
je 0x77a0
movl %ecx, 0x1c(%r15)
pushq $0x2
popq %rsi
movl %ecx, %eax
cltd
idivl %esi
cmpl $0x10, %ecx
cmovgel %eax, %r12d
movl %r12d, 0x1c(%rbx)
jmp 0x77b3
leaq 0x10a3(%rip), %rdi      # 0x8838
xorl %eax, %eax
callq 0x3324
pushq $-0x1
jmp 0x77b5
pushq $0x2
popq %rsi
movl %ecx, %eax
cltd
idivl %esi
cmpl $0x10, %ecx
cmovgel %eax, %r12d
movl %r12d, 0x1c(%r15)
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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:
pushq $0x13
popq %rdx
pushq $-0x1
popq %rax
testl %edx, %edx
js 0x77f9
movl %edx, %ecx
movzbl (%rdi,%rcx), %esi
testl %esi, %esi
jne 0x77dd
decl %edx
jmp 0x77cb
pushq $0x7
popq %rcx
pushq $-0x1
popq %rax
testl %ecx, %ecx
js 0x77f6
movl %esi, %edi
shll %cl, %edi
testb %dil, %dil
js 0x77f4
decl %ecx
jmp 0x77e3
movl %ecx, %eax
leal (%rax,%rdx,8), %eax
retq
// File: /workspace/github_c_makefile_star2_O2/jech[P]dht/dht.c
// Function: xorcmp
static int
xorcmp(const unsigned char *id1, const unsigned char *id2,
       const unsigned char *ref)
{
    int i;
    for(i = 0; i < 20; i++) {
        unsigned char xor1, xor2;
        if(id1[i] == id2[i])
            continue;
        xor1 = id1[i] ^ ref[i];
        xor2 = id2[i] ^ ref[i];
        if(xor1 < xor2)
            return -1;
        else
            return 1;
    }
    return 0;
}

// Assembly:
xorl %eax, %eax
xorl %r8d, %r8d
cmpq $0x14, %r8
je 0x7829
movb (%rdi,%r8), %cl
movb (%rsi,%r8), %r9b
incq %r8
cmpb %r9b, %cl
je 0x77ff
movb -0x1(%rdx,%r8), %al
xorb %al, %cl
xorb %al, %r9b
xorl %eax, %eax
cmpb %r9b, %cl
sbbl %eax, %eax
orl $0x1, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbx
cmpl $0x0, 0x18(%rdi)
je 0x785d
movq %rdi, %rbx
callq 0x2230
movslq 0x18(%rbx), %rcx
cqto
idivq %rcx
addq $0x28, %rbx
movq (%rbx), %rbx
testl %edx, %edx
jle 0x785f
testq %rbx, %rbx
je 0x785f
addq $0xc0, %rbx
decl %edx
jmp 0x7846
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/jech[P]dht/dht.c
// Function: buffer_closest_nodes
static int
buffer_closest_nodes(unsigned char *nodes, int numnodes,
                     const unsigned char *id, struct bucket *b)
{
    struct node *n = b->nodes;
    while(n) {
        if(node_good(n))
            numnodes = insert_closest_node(nodes, numnodes, id, n);
        n = n->next;
    }
    return numnodes;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movl %esi, 0x4(%rsp)
movq %rdi, 0x8(%rsp)
addq $0x28, %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x7b74
movq %rbx, %rdi
callq 0x3956
testl %eax, %eax
je 0x7b68
movzwl 0x18(%rbx), %ecx
pushq $0x1a
popq %rax
cmpl $0x2, %ecx
je 0x7a5c
cmpl $0xa, %ecx
jne 0x7b87
pushq $0x26
popq %rax
movl %ecx, 0x14(%rsp)
movl %eax, %r13d
movl 0x4(%rsp), %eax
testl %eax, %eax
movl $0x0, %ebp
cmovgl %eax, %ebp
movq 0x8(%rsp), %r12
xorl %r15d, %r15d
cmpq %r15, %rbp
je 0x7aae
movq %rbx, %rdi
movq %r12, %rsi
callq 0x33d2
testl %eax, %eax
je 0x7b68
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x77fa
testl %eax, %eax
js 0x7aab
incq %r15
addq %r13, %r12
jmp 0x7a79
movl %r15d, %ebp
cmpl $0x8, %ebp
movl 0x14(%rsp), %esi
je 0x7b68
xorl %eax, %eax
movl 0x4(%rsp), %edx
cmpl $0x8, %edx
setl %al
movl %edx, %ecx
addl %eax, %edx
movl %edx, 0x4(%rsp)
addl %ecx, %eax
decl %eax
cmpl %eax, %ebp
jge 0x7b07
leal 0x1(%rbp), %edi
imull %r13d, %edi
movq 0x8(%rsp), %rax
addq %rax, %rdi
movl %ebp, %esi
imull %r13d, %esi
addq %rax, %rsi
movl %ebp, %eax
notl %eax
addl 0x4(%rsp), %eax
imull %r13d, %eax
movslq %eax, %rdx
callq 0x2290
movzwl 0x18(%rbx), %esi
cmpw $0xa, %si
je 0x7b3c
movzwl %si, %eax
cmpl $0x2, %eax
jne 0x7b87
movl %ebp, %eax
imulq %r13, %rax
movl 0x10(%rbx), %ecx
movq 0x8(%rsp), %rdx
addq %rdx, %rax
addq $0x18, %rax
movl %ecx, -0x8(%rax)
movups (%rbx), %xmm0
movups %xmm0, -0x18(%rax)
movl 0x1c(%rbx), %ecx
movl %ecx, -0x4(%rax)
jmp 0x7b61
imull %r13d, %ebp
movl 0x10(%rbx), %ecx
movq 0x8(%rsp), %rax
addq %rbp, %rax
addq $0x24, %rax
movl %ecx, -0x14(%rax)
movups (%rbx), %xmm0
movups %xmm0, -0x24(%rax)
movups 0x20(%rbx), %xmm0
movups %xmm0, -0x10(%rax)
movzwl 0x1a(%rbx), %ecx
movw %cx, (%rax)
addq $0xc0, %rbx
jmp 0x7a28
movl 0x4(%rsp), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2050