// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/btree_sync.c
// Function: serializetree
static int
serializetree(struct btree * T, struct node * N, size_t pagelen,
    uint64_t nextblk, const uint8_t ** bufv, uint64_t * pn)
{
	size_t i;

	/* If this node is not dirty, return immediately. */
	if (N->state != NODE_STATE_DIRTY)
		return (0);

	/* If this node has children, serialize them first. */
	if (N->type == NODE_TYPE_PARENT) {
		for (i = 0; i <= N->nkeys; i++)
			if (serializetree(T, N->v.children[i], pagelen,
			    nextblk, bufv, pn))
				goto err0;
	}

	/* Record this node's page number. */
	N->pagenum = nextblk + *pn;

	/*
	 * Figure out what the oldest leaf number under this node is.  The
	 * oldest not-being-cleaned leaf is computed in makeclean.
	 */
	N->oldestleaf = N->pagenum;
	if (N->type == NODE_TYPE_PARENT) {
		for (i = 0; i <= N->nkeys; i++) {
			if (N->v.children[i]->oldestleaf < N->oldestleaf)
				N->oldestleaf = N->v.children[i]->oldestleaf;
		}
	}

	/* Serialize the page and record the page pointer. */
	if (serialize(T, N, pagelen))
		goto err0;
	bufv[(*pn)++] = N->pagebuf;

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x18(%rbp), %rax
movb 0x1c(%rax), %al
shrb $0x2, %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x2, %eax
je 0xa570
movl $0x0, -0x4(%rbp)
jmp 0xa6b9
movq -0x18(%rbp), %rax
movb 0x1c(%rax), %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xa5dc
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x38(%rcx), %rax
ja 0xa5da
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %r9
callq 0xa530
cmpl $0x0, %eax
je 0xa5ca
jmp 0xa6b2
jmp 0xa5cc
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xa589
jmp 0xa5dc
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %rax
addq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movb 0x1c(%rax), %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xa670
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x38(%rcx), %rax
ja 0xa66e
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0xa65e
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0xa660
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xa616
jmp 0xa670
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xe760
cmpl $0x0, %eax
je 0xa688
jmp 0xa6b2
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rdx
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x4(%rbp)
jmp 0xa6b9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)