// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/kvlds/btree_balance.c
// Function: btree_balance
int
btree_balance(struct btree * T, int (* callback)(void *), void * cookie)
{
	struct balance_cookie * B;

	/* Bake a cookie. */
	if ((B = malloc(sizeof(struct balance_cookie))) == NULL)
		goto err0;
	B->callback = callback;
	B->cookie = cookie;
	B->T = T;

	/* Split nodes as necessary. */
	if (splittree(T))
		goto err1;

	/* Merge nodes as necessary and perform callback. */
	if (planmerge(B))
		goto err1;

	/* Success! */
	return (0);

err1:
	free(B);
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
pushq $0x20
popq %rdi
callq 0x22a0
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0x5668
movq %rax, %r12
movq %r14, (%rax)
movq %rbx, 0x8(%rax)
movq %r15, 0x10(%rax)
movq 0x28(%r15), %rsi
movq %r15, %rdi
callq 0x5703
testl %eax, %eax
jne 0x5660
movq %r12, 0x8(%rsp)
movq 0x28(%r15), %r13
movq %r13, %rdi
callq 0x8e4b
cmpq (%r15), %rax
jbe 0x5604
movq 0x28(%r15), %rbp
movq %r15, %rdi
movq %rbp, %rsi
callq 0x8040
movq %rax, %r14
movq %rax, %r13
decq %r13
setne %bl
movq %r13, %rdi
callq 0x59b0
movq %rax, %r12
testq %rax, %rax
sete %al
testb %bl, %al
jne 0x5658
movq %r14, %rdi
callq 0x59b0
movq %rax, %rbx
testq %rax, %rax
sete %al
testq %r14, %r14
setne %cl
testb %al, %cl
jne 0x5624
movsbl 0x1d(%rbp), %edx
cmpl $0x3f, %edx
jge 0x5679
incl %edx
andq $0x0, (%rsp)
movq %r15, %rdi
xorl %esi, %esi
movq %r13, %rcx
movq %r12, %r8
movq %rbx, %r9
callq 0x767c
testq %rax, %rax
je 0x561c
movq %rax, %r13
incq 0x48(%r15)
orb $0x10, 0x1c(%rax)
movq %r15, %rdi
movq %rax, %rsi
callq 0x59da
andb $-0x11, 0x1c(%rbp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x59ff
movq %r13, 0x28(%rbp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x59da
movq 0x40(%r13), %rdx
movq 0x48(%r13), %rcx
movq %r15, %rdi
movq %rbp, %rsi
leaq 0x10(%rsp), %r8
callq 0x810c
testl %eax, %eax
jne 0x562e
movq 0x38(%r13), %rax
leaq 0x1(%rax), %rcx
cmpq %rcx, 0x10(%rsp)
jne 0x5698
xorl %ebx, %ebx
cmpq %rax, %rbx
ja 0x55fb
movq 0x48(%r13), %rcx
movq (%rcx,%rbx,8), %rcx
movq %r13, 0x28(%rcx)
movq 0x48(%r13), %rcx
movq (%rcx,%rbx,8), %rcx
movb 0x1c(%rcx), %cl
andb $0x3, %cl
cmpb $0x2, %cl
je 0x55f6
movq %r15, %rdi
movq %r13, %rsi
callq 0x59da
movq 0x38(%r13), %rax
incq %rbx
jmp 0x55c3
movq %r13, 0x28(%r15)
jmp 0x54c6
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x56b7
testl %eax, %eax
pushq $-0x1
popq %rbp
jne 0x5660
xorl %ebp, %ebp
jmp 0x5668
movq %rbx, %rdi
callq 0x2040
movq %r12, %rdi
callq 0x2040
jmp 0x5658
orb $0x10, 0x1c(%rbp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x59da
movq %r15, %rdi
movq %r13, %rsi
callq 0x59ff
orq $-0x1, 0x38(%r13)
movq %r15, %rdi
movq %r13, %rsi
callq 0x7921
pushq $-0x1
popq %rbp
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x2040
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc459(%rip), %rdi      # 0x11ad9
leaq 0xc3b6(%rip), %rsi      # 0x11a3d
leaq 0xc45e(%rip), %rcx      # 0x11aec
movl $0xbe, %edx
callq 0x21c0
leaq 0xc483(%rip), %rdi      # 0x11b22
leaq 0xc397(%rip), %rsi      # 0x11a3d
leaq 0xc43f(%rip), %rcx      # 0x11aec
movl $0xd7, %edx
callq 0x21c0