// File: /workspace/github_c_makefile_star2_O1/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
movl $0x20, %edi
callq 0x22a0
movq %rax, %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rcx, %rcx
je 0x6523
movq %r14, (%rcx)
movq %rbx, 0x8(%rcx)
movq %rcx, 0x8(%rsp)
movq %r15, 0x10(%rcx)
movq 0x28(%r15), %rsi
movq %r15, %rdi
callq 0x65e6
testl %eax, %eax
jne 0x6514
movq 0x28(%r15), %rdi
callq 0xa703
cmpq (%r15), %rax
jbe 0x6506
movq 0x28(%r15), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x9730
movq %rax, %rbx
movq %rax, %rbp
decq %rbp
je 0x62c8
movabsq $0x1fffffffffffffff, %rax # imm = 0x1FFFFFFFFFFFFFFF
cmpq %rax, %rbp
jbe 0x62cd
callq 0x20a0
movl $0xc, (%rax)
xorl %r12d, %r12d
jmp 0x62dd
leaq (,%rbp,8), %rdi
callq 0x22a0
movq %rax, %r12
testq %r12, %r12
sete %al
testq %rbp, %rbp
setne %cl
testb %al, %cl
jne 0x6493
testq %rbx, %rbx
je 0x6310
movabsq $0x1fffffffffffffff, %rax # imm = 0x1FFFFFFFFFFFFFFF
cmpq %rax, %rbx
jbe 0x6315
callq 0x20a0
movl $0xc, (%rax)
xorl %r14d, %r14d
jmp 0x6325
leaq (,%rbx,8), %rdi
callq 0x22a0
movq %rax, %r14
testq %rbx, %rbx
setne %al
testq %r14, %r14
sete %cl
testb %cl, %al
jne 0x648b
movsbl 0x1d(%r13), %edx
cmpl $0x3f, %edx
jge 0x6536
incl %edx
movq $0x0, (%rsp)
movq %r15, %rdi
xorl %esi, %esi
movq %rbp, %rcx
movq %r12, %r8
movq %r14, %r9
callq 0x8ac8
testq %rax, %rax
je 0x6483
movq %rax, %rbp
incq 0x48(%r15)
orb $0x10, 0x1c(%rax)
movq 0x30(%r15), %rdi
movq 0x20(%rdi), %rax
movq (%rbp,%rax), %rax
movq (%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
testq %rcx, %rcx
jne 0x639c
movq %rbp, %rsi
callq 0x107a3
andb $-0x11, 0x1c(%r13)
testq %r13, %r13
je 0x63cf
movq 0x30(%r15), %rdi
movq 0x20(%rdi), %rax
movq (%r13,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x6555
decq %rcx
movq %rcx, (%rax)
jne 0x63cf
movq %r13, %rsi
callq 0x10885
movq %rbp, 0x28(%r13)
movq 0x30(%r15), %rdi
movq 0x20(%rdi), %rax
movq (%rbp,%rax), %rax
movq (%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
testq %rcx, %rcx
jne 0x63f7
movq %rbp, %rsi
callq 0x107a3
movq 0x40(%rbp), %rdx
movq 0x48(%rbp), %rcx
movq %r15, %rdi
movq %r13, %rsi
leaq 0x10(%rsp), %r8
callq 0x982f
testl %eax, %eax
je 0x64a6
orb $0x10, 0x1c(%r13)
testq %r13, %r13
je 0x6445
movq 0x30(%r15), %rdi
movq 0x20(%rdi), %rax
movq (%r13,%rax), %rax
movq (%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
testq %rcx, %rcx
jne 0x6445
movq %r13, %rsi
callq 0x107a3
movq 0x30(%r15), %rdi
movq 0x20(%rdi), %rax
movq (%rbp,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x6555
decq %rcx
movq %rcx, (%rax)
jne 0x646e
movq %rbp, %rsi
callq 0x10885
movq $-0x1, 0x38(%rbp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x8de9
jmp 0x6493
movq %r14, %rdi
callq 0x2040
movq %r12, %rdi
callq 0x2040
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x6514
movq %rbp, 0x28(%r15)
movq %rbp, %rdi
jmp 0x6286
movq 0x38(%rbp), %rax
incq %rax
cmpq %rax, 0x10(%rsp)
jne 0x6574
xorl %ebx, %ebx
movq 0x48(%rbp), %rax
movq (%rax,%rbx,8), %rax
movq %rbp, 0x28(%rax)
movq 0x48(%rbp), %rax
movq (%rax,%rbx,8), %rax
movb 0x1c(%rax), %al
andb $0x3, %al
cmpb $0x2, %al
je 0x64fb
movq 0x30(%r15), %rdi
movq 0x20(%rdi), %rax
movq (%rbp,%rax), %rax
movq (%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
testq %rcx, %rcx
jne 0x64fb
movq %rbp, %rsi
callq 0x107a3
incq %rbx
cmpq 0x38(%rbp), %rbx
jbe 0x64ba
jmp 0x6495
movq 0x8(%rsp), %rdi
callq 0x6593
testl %eax, %eax
je 0x6532
movq 0x8(%rsp), %rdi
callq 0x2040
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x6523
leaq 0xe5b4(%rip), %rdi      # 0x14af1
leaq 0xe511(%rip), %rsi      # 0x14a55
leaq 0xe5b9(%rip), %rcx      # 0x14b04
movl $0xbe, %edx
callq 0x21c0
leaq 0xe124(%rip), %rdi      # 0x14680
leaq 0xe143(%rip), %rsi      # 0x146a6
leaq 0xe155(%rip), %rcx      # 0x146bf
movl $0x88, %edx
callq 0x21c0
leaq 0xe5bf(%rip), %rdi      # 0x14b3a
leaq 0xe4d3(%rip), %rsi      # 0x14a55
leaq 0xe57b(%rip), %rcx      # 0x14b04
movl $0xd7, %edx
callq 0x21c0