// File: /workspace/github_c_makefile_star2_O3/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 %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x7e4c
testl %eax, %eax
je 0x81f2
leaq 0x4(%rbx), %rsi
movl $0x13, %eax
movl $0xffffff68, %edx       # imm = 0xFFFFFF68
movl %eax, %ecx
movzbl (%rsi,%rcx), %edi
testl %edi, %edi
jne 0x820a
addl $0x8, %edx
addl $-0x1, %eax
jb 0x81d9
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x8228
leaq 0x163f(%rip), %rdi      # 0x9838
xorl %eax, %eax
callq 0x362c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x8378
movl $0x7, %eax
movl %edi, %r8d
movl %eax, %ecx
shll %cl, %r8d
testb %r8b, %r8b
js 0x8226
addl $-0x1, %eax
jb 0x820f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subl %edx, %eax
movq 0xb8(%rbx), %rcx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testq %rcx, %rcx
je 0x8283
movl $0x13, %edx
movl $0xffffff68, %edi       # imm = 0xFFFFFF68
movl %edx, %r8d
movzbl 0x4(%rcx,%r8), %r8d
testl %r8d, %r8d
jne 0x8265
addl $0x8, %edi
addl $-0x1, %edx
jb 0x8248
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
jmp 0x8283
movl $0x7, %edx
movl %r8d, %r9d
movl %edx, %ecx
shll %cl, %r9d
testb %r9b, %r9b
js 0x8281
addl $-0x1, %edx
jb 0x826a
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
subl %edi, %edx
cmpl %edx, %eax
cmovgl %eax, %edx
cmpl $0x9e, %edx
jg 0x8378
leal 0x1(%rdx), %eax
movl 0x10(%rsi), %ecx
movl %ecx, 0x10(%rsp)
movups (%rsi), %xmm0
movaps %xmm0, (%rsp)
movl %eax, %ecx
andb $0x7, %cl
movl $0x80, %esi
shrl %cl, %esi
addl $0x8, %edx
testl %eax, %eax
cmovnsl %eax, %edx
sarl $0x3, %edx
movslq %edx, %rax
orb %sil, (%rsp,%rax)
movl $0x1, %edi
movl $0xc0, %esi
callq 0x21a0
testq %rax, %rax
je 0x8378
movq %rax, %r15
movq %rbx, %rdi
callq 0x80e9
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 0x7e4c
movl 0x1c(%rbx), %ecx
testl %eax, %eax
je 0x835b
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 0x8373
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 $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq