// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rsi
leaq 0x6745(%rip), %rdi      # 0x10c30
callq 0x9840
cmpl $0x0, %eax
jne 0xa50f
leaq 0x234e(%rip), %rdi      # 0xc84a
movb $0x0, %al
callq 0x3aa0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa685
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xa7b0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0xa531
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa685
movl $0x1, %edi
movl $0xc0, %esi
callq 0x21a0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xa557
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa685
movq -0x10(%rbp), %rdi
callq 0xa1f0
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, 0x4(%rax)
movq -0x38(%rbp), %rcx
movq %rcx, 0xc(%rax)
movl -0x30(%rbp), %ecx
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0xb8(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0xb8(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xb8(%rax)
movq -0x10(%rbp), %rsi
leaq 0x6644(%rip), %rdi      # 0x10c30
callq 0x9840
cmpl $0x0, %eax
je 0xa642
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x8, %eax
jl 0xa62c
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x44(%rbp)
jmp 0xa636
movl $0x8, %eax
movl %eax, -0x44(%rbp)
jmp 0xa636
movl -0x44(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
jmp 0xa67e
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x8, %eax
jl 0xa66a
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x48(%rbp)
jmp 0xa674
movl $0x8, %eax
movl %eax, -0x48(%rbp)
jmp 0xa674
movl -0x48(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop