// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/btree_sync.c
// Function: makeclean
static void
makeclean(struct btree * T, struct node * N)
{
	size_t i;

	/* Sanity-check: We should not have reached a shadow node. */
	assert(N->state != NODE_STATE_SHADOW);

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

	/* If this node has children, recurse down. */
	if (N->type == NODE_TYPE_PARENT) {
		for (i = 0; i <= N->nkeys; i++)
			makeclean(T, N->v.children[i]);
	}

	/*
	 * Figure out what the page number of the oldest leaf under this node
	 * which isn't currently being cleaned is.  (We computed the overall
	 * oldest leaf during serializetree since it gets written out.)
	 */
	N->oldestncleaf = N->pagenum;
	if (N->type == NODE_TYPE_PARENT) {
		for (i = 0; i <= N->nkeys; i++) {
			if (N->v.children[i]->oldestncleaf < N->oldestncleaf)
				N->oldestncleaf =
				    N->v.children[i]->oldestncleaf;
		}
	}

	/* Mark this node as clean. */
	N->state = NODE_STATE_CLEAN;

	/* Remove the node-is-dirty lock on the node. */
	btree_node_unlock(T, N);

	/* This node's dirty parent is also its shadow parent. */
	N->p_shadow = N->p_dirty;
	btree_node_lock(T, N->p_shadow);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movb 0x1c(%rax), %al
shrb $0x2, %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x1, %eax
je 0xa7e6
jmp 0xa805
leaq 0x149ec(%rip), %rdi     # 0x1f1d9
leaq 0x14930(%rip), %rsi     # 0x1f124
movl $0x68, %edx
leaq 0x149f7(%rip), %rcx     # 0x1f1f7
callq 0x21d0
movq -0x10(%rbp), %rax
movb 0x1c(%rax), %al
shrb $0x2, %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x2, %eax
je 0xa81e
jmp 0xa92e
movq -0x10(%rbp), %rax
movb 0x1c(%rax), %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xa86e
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x38(%rcx), %rax
ja 0xa86c
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0xa7c0
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xa837
jmp 0xa86e
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movb 0x1c(%rax), %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xa8f0
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x38(%rcx), %rax
ja 0xa8ee
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0xa8de
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xa8e0
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xa896
jmp 0xa8f0
movq -0x10(%rbp), %rax
movb 0x1c(%rax), %cl
andb $-0xd, %cl
orb $0x0, %cl
movb %cl, 0x1c(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xaa20
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0xaa50
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)