LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/dispatch_nmr.c
// Function: dispatch_nmr_launch
int
dispatch_nmr_launch(struct btree * T, struct proto_kvlds_request * R,
    struct netbuf_write * WQ,
    int (* callback_done)(void *), void * cookie_done)
{
	struct nmr_cookie * C;

	/* Sanity-check: The NMR type must be reasonable. */
	assert((R->type == PROTO_KVLDS_GET) ||
	    (R->type == PROTO_KVLDS_RANGE));

	/* Bake a cookie. */
	if ((C = malloc(sizeof(struct nmr_cookie))) == NULL)
		goto err0;
	C->callback_done = callback_done;
	C->cookie_done = cookie_done;
	C->T = T;
	C->R = R;
	C->WQ = WQ;

	/* Different NMRs need different handling. */
	switch (R->type) {
	case PROTO_KVLDS_GET:
		/* Find the node containing (or not) this key. */
		if (btree_find_leaf(C->T, C->T->root_shadow, C->R->key,
		    callback_get_gotleaf, C))
			goto err1;
		break;
	case PROTO_KVLDS_RANGE:
		/*
		 * Find a node of height 1 or less which is responsible for a
		 * range containing the start key.
		 */
		if (btree_find_range(C->T, C->T->root_shadow,
		    C->R->range_start, 1, callback_range_gotnode, C))
			goto err1;
		break;
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movl 0x8(%rsi), %r13d
movl %r13d, %eax
andl $-0x2, %eax
cmpl $0x130, %eax            # imm = 0x130
jne 0x535b
movq %rcx, %r12
movq %rsi, %r15
movq %rdi, %r14
movl $0x58, %edi
callq 0x22a0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x534a
movq %rax, %rbx
movq %r12, (%rax)
movq 0x8(%rsp), %rax
movq %rax, 0x8(%rbx)
movq %r14, 0x10(%rbx)
movq %r15, 0x18(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x20(%rbx)
xorl %ebp, %ebp
cmpl $0x131, %r13d           # imm = 0x131
je 0x531a
cmpl $0x130, %r13d           # imm = 0x130
jne 0x534a
movq 0x20(%r14), %rsi
movq 0x10(%r15), %rdx
leaq 0x6d(%rip), %rcx        # 0x537a
movq %r14, %rdi
movq %rbx, %r8
callq 0x8064
jmp 0x5339
movq 0x20(%r14), %rsi
movq 0x10(%r15), %rdx
leaq 0x139(%rip), %r8        # 0x5462
movq %r14, %rdi
movl $0x1, %ecx
movq %rbx, %r9
callq 0x838f
testl %eax, %eax
je 0x534a
movq %rbx, %rdi
callq 0x2040
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf389(%rip), %rdi      # 0x146eb
leaq 0xf3c1(%rip), %rsi      # 0x1472a
leaq 0xf3c9(%rip), %rcx      # 0x14739
movl $0x39, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/dispatch_nmr.c
// Function: callback_get_gotleaf
static int
callback_get_gotleaf(void * cookie, struct node * N)
{
	struct nmr_cookie * C = cookie;
	struct kvpair_const * kv;

	/* Find the key in this node. */
	kv = btree_find_kvpair(N, C->R->key);

	/* Send the response. */
	if (kv != NULL) {
		/* Send the requested value back to the client. */
		if (proto_kvlds_response_get(C->WQ, C->R->ID, 0,
		    kv->v))
			goto err1;
	} else {
		/* Send a non-present response back to the client. */
		if (proto_kvlds_response_get(C->WQ, C->R->ID, 1,
		    NULL))
			goto err1;
	}

	/* Schedule the request-done callback. */
	if (!events_immediate_register(C->callback_done, C->cookie_done, 0))
		goto err1;

	/* Unlock the node. */
	btree_node_unlock(C->T, N);

	/* Free the request. */
	proto_kvlds_request_free(C->R);

	/* Free the cookie. */
	free(C);

	/* Success! */
	return (0);

err1:
	btree_node_unlock(C->T, N);
	proto_kvlds_request_free(C->R);
	free(C);

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

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq 0x18(%rdi), %rax
movq 0x10(%rax), %rsi
movq %r14, %rdi
callq 0x7f3c
movq 0x18(%rbx), %rcx
movq 0x20(%rbx), %rdi
movq (%rcx), %rsi
testq %rax, %rax
je 0x53ac
movq 0x8(%rax), %rcx
xorl %edx, %edx
jmp 0x53b3
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x10da6
testl %eax, %eax
je 0x53e0
testq %r14, %r14
je 0x5426
movq 0x10(%rbx), %rax
movq 0x30(%rax), %rdi
movq 0x20(%rdi), %rax
movq (%r14,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x5443
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x5414
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0xba4c
testq %rax, %rax
je 0x53bc
testq %r14, %r14
je 0x542b
movq 0x10(%rbx), %rax
movq 0x30(%rax), %rdi
movq 0x20(%rdi), %rax
movq (%r14,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x5443
xorl %ebp, %ebp
decq %rcx
movq %rcx, (%rax)
jne 0x542b
movq %r14, %rsi
callq 0x10885
jmp 0x542b
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq 0x18(%rbx), %rdi
callq 0x10bd2
movq %rbx, %rdi
callq 0x2040
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0xf236(%rip), %rdi      # 0x14680
leaq 0xf255(%rip), %rsi      # 0x146a6
leaq 0xf267(%rip), %rcx      # 0x146bf
movl $0x88, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree.c
// Function: callback_gc
static int
callback_gc(void * cookie)
{
	struct btree * T = cookie;

	/* The timer is no longer scheduled. */
	T->gc_timer = NULL;

	/*
	 * Instruct the backing store to free everything older than the
	 * oldest leaf node accessible via the B+Tree root.
	 */
	if (proto_lbs_request_free(T->LBS, T->root_shadow->oldestleaf,
	    callback_free_done, NULL))
		goto err0;

	/* Schedule another FREE. */
	if ((T->gc_timer =
	    events_timer_register(callback_gc, T, &free_time)) == NULL)
		goto err0;

	/* Success! */
	return (0);

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

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq $0x0, 0x38(%rdi)
movq 0x18(%rdi), %rdi
movq 0x20(%r14), %rax
movq 0x8(%rax), %rsi
leaq 0x165(%rip), %rdx       # 0x61fe
xorl %ebx, %ebx
xorl %ecx, %ecx
callq 0x117a2
testl %eax, %eax
je 0x60ad
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x60cc
leaq -0x3d(%rip), %rdi       # 0x6077
leaq 0xe975(%rip), %rdx      # 0x14a30
movq %r14, %rsi
callq 0xc738
movq %rax, 0x38(%r14)
testq %rax, %rax
je 0x60a6
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree.c
// Function: btree_free
void
btree_free(struct btree * T)
{

	/* Sanity-check. */
	assert(T->root_shadow == T->root_dirty);

	/* Shut down the background cleaner. */
	btree_cleaning_stop(T->cstate);

	/* Kill the garbage collection timer. */
	if (T->gc_timer != NULL)
		events_timer_cancel(T->gc_timer);

	/* Release the root locks. */
	btree_node_unlock(T, T->root_shadow);
	btree_node_unlock(T, T->root_dirty);

	/* Page out all pages in the tree. */
	btree_node_pageout_recursive(T, T->root_shadow);

	/* Free the (paged-out) root node. */
	node_free(T->root_shadow);

	/* Free the page pool. */
	pool_free(T->P);

	/* Free the tree structure. */
	free(T);
}

// Assembly:
pushq %rbx
movq 0x20(%rdi), %rax
cmpq 0x28(%rdi), %rax
jne 0x6199
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
callq 0x72a0
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x60ff
callq 0xc8b1
movq 0x20(%rbx), %rsi
testq %rsi, %rsi
je 0x6129
movq 0x30(%rbx), %rdi
movq 0x20(%rdi), %rax
movq (%rsi,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x617a
decq %rcx
movq %rcx, (%rax)
jne 0x6129
callq 0x10885
movq 0x28(%rbx), %rsi
testq %rsi, %rsi
je 0x6153
movq 0x30(%rbx), %rdi
movq 0x20(%rdi), %rax
movq (%rsi,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x617a
decq %rcx
movq %rcx, (%rax)
jne 0x6153
callq 0x10885
movq 0x20(%rbx), %rsi
movq %rbx, %rdi
callq 0x8f6d
movq 0x20(%rbx), %rdi
callq 0xace6
movq 0x30(%rbx), %rdi
callq 0x10853
movq %rbx, %rdi
popq %rbx
jmp 0x2040
leaq 0xe4ff(%rip), %rdi      # 0x14680
leaq 0xe51e(%rip), %rsi      # 0x146a6
leaq 0xe530(%rip), %rcx      # 0x146bf
movl $0x88, %edx
callq 0x21c0
leaq 0xe831(%rip), %rdi      # 0x149d1
leaq 0xe673(%rip), %rsi      # 0x1481a
leaq 0xe843(%rip), %rcx      # 0x149f1
movl $0x1a0, %edx            # imm = 0x1A0
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_balance.c
// Function: domerge
static int
domerge(void * cookie)
{
	struct balance_cookie * B = cookie;
	struct btree * T = B->T;

	/* We should have all the nodes we need. */
	assert(B->nmergefetch == 0);

	/* Do the merging. */
	if (domergenode(B, T->root_dirty))
		goto err0;

#ifdef SANITY_CHECKS
	/* Sanity check the B+Tree. */
	btree_sanity(T);
#endif

	/* If the tree is not fully merged, plan more merges. */
	if (T->root_dirty->needmerge) {
		if (planmerge(B))
			goto err0;
	} else {
		/* Remove extraneous root nodes. */
		deroot(B);

		/* We're done!  Schedule the callback and free the cookie. */
		if (!events_immediate_register(B->callback, B->cookie, 0))
			goto err0;
		free(B);
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpq $0x0, 0x18(%rdi)
jne 0x6c75
movq %rdi, %rbx
movq 0x10(%rdi), %r14
movq 0x28(%r14), %rsi
callq 0x6cc2
testl %eax, %eax
je 0x6b0e
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%r14), %rax
testb $0x40, 0x1c(%rax)
jne 0x6c3f
movq 0x10(%rbx), %r14
movq 0x28(%r14), %r15
testb $0x3, 0x1c(%r15)
jne 0x6c19
leaq 0x1c(%r15), %r12
cmpq $0x0, 0x38(%r15)
jne 0x6c19
movq 0x48(%r15), %rax
movq (%rax), %rax
movq %rax, 0x28(%r14)
orb $0x10, 0x1c(%rax)
movq 0x28(%r14), %rsi
movl $0xffffffff, 0x18(%rsi) # imm = 0xFFFFFFFF
testq %rsi, %rsi
je 0x6b7d
movq 0x30(%r14), %rdi
movq 0x20(%rdi), %rax
movq (%rsi,%rax), %rax
movq (%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
testq %rcx, %rcx
jne 0x6b7d
callq 0x107a3
movq 0x28(%r14), %rax
movq $0x0, 0x28(%rax)
andb $-0x11, (%r12)
testq %r15, %r15
je 0x6bec
movq 0x30(%r14), %rdi
movq 0x20(%rdi), %rax
movq (%r15,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x6c56
decq %rcx
movq %rcx, (%rax)
jne 0x6bbb
movq %r15, %rsi
callq 0x10885
movq 0x48(%r15), %rax
movq $0x0, (%rax)
movq 0x30(%r14), %rdi
movq 0x20(%rdi), %rax
movq (%r15,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x6c56
decq %rcx
movq %rcx, (%rax)
jne 0x6bf7
movq %r15, %rsi
callq 0x10885
jmp 0x6bf7
movq 0x48(%r15), %rax
movq $0x0, (%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x8de9
decq 0x48(%r14)
movq 0x28(%r14), %r15
leaq 0x1c(%r15), %r12
testb $0x3, 0x1c(%r15)
je 0x6b33
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0xba4c
testq %rax, %rax
je 0x6afe
movq %rbx, %rdi
callq 0x2040
jmp 0x6b03
movq %rbx, %rdi
callq 0x6593
testl %eax, %eax
jne 0x6afe
xorl %ebp, %ebp
jmp 0x6b03
leaq 0xda23(%rip), %rdi      # 0x14680
leaq 0xda42(%rip), %rsi      # 0x146a6
leaq 0xda54(%rip), %rcx      # 0x146bf
movl $0x88, %edx
callq 0x21c0
leaq 0xded5(%rip), %rdi      # 0x14b51
leaq 0xddd2(%rip), %rsi      # 0x14a55
leaq 0xdedb(%rip), %rcx      # 0x14b65
movl $0x27e, %edx            # imm = 0x27E
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_cleaning.c
// Function: btree_cleaning_start
struct cleaner *
btree_cleaning_start(struct btree * T, double Scost)
{
	struct cleaner * C;

	(void)Scost;

	/* Create a cleaner state structure. */
	if ((C = malloc(sizeof(struct cleaner))) == NULL)
		goto err0;
	C->T = T;
	C->group_pending = 0;
	C->head = NULL;
	C->pending_cleans = 0;

	/**
	 * The optimal rate of cleaning is when the cost accrued to store
	 * garbage (inaccessible pages) is equal to the cost accrued to
	 * cleaning (both deliberate and the cleaning which occurs as a side
	 * effect of modifying operations).
	 *
	 * Based on the page size, the ratio of storage cost to I/O cost, and
	 * conversion factors, we can compute a factor which tells us how
	 * many I/Os we should perform per second per block of garbage.
	 */
	C->cleanrate =
	    ((double)T->pagelen / 1000000000.) *	/* GB per page. */
	    (1.0 / 86400. / 30.) *			/* months per s. */
	    Scost *				/* 10^6 I/Os per GB-month. */
	    1000000.;				/* I/Os per (10^6 I/Os). */

	/**
	 * Every second we will look at how much garbage we have and increase
	 * our "cleaning debt"; when this value gets too large, we'll make a
	 * "payment" on the debt by performing some cleaning.
	 */
	C->cleandebt = 0;
	if ((C->cleantimer =
	    events_timer_register(tick, C, &onesec)) == NULL) {
		warnp("events_timer_register");
		goto err1;
	}

	/* Success! */
	return (C);

err1:
	free(C);
err0:
	/* Failure! */
	return (NULL);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movsd %xmm0, (%rsp)
movq %rdi, %r14
movl $0x38, %edi
callq 0x22a0
testq %rax, %rax
je 0x6fcc
movq %rax, %rbx
movq %r14, (%rax)
movl $0x0, 0x20(%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x28(%rax)
movsd (%r14), %xmm0
unpcklps 0xdc4b(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xdc53(%rip), %xmm0     # 0x14b90
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0xdc5f(%rip), %xmm1     # 0x14bb0
mulsd 0xdc5f(%rip), %xmm1     # 0x14bb8
mulsd (%rsp), %xmm1
mulsd 0xd4ba(%rip), %xmm1     # 0x14420
movsd %xmm1, 0x8(%rax)
movq $0x0, 0x10(%rax)
leaq 0x5f(%rip), %rdi        # 0x6fd9
leaq 0xdc3f(%rip), %rdx      # 0x14bc0
movq %rax, %rsi
callq 0xc738
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x6fce
callq 0x20a0
cmpl $0x0, (%rax)
je 0x6fb6
movq %rax, %r14
leaq 0xd4aa(%rip), %rdi      # 0x14450
xorl %eax, %eax
callq 0x10048
movl $0x0, (%r14)
jmp 0x6fc4
leaq 0xd493(%rip), %rdi      # 0x14450
xorl %eax, %eax
callq 0x10167
movq %rbx, %rdi
callq 0x2040
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_cleaning.c
// Function: btree_cleaning_notify_dirtying
void
btree_cleaning_notify_dirtying(struct cleaner * C, struct node * N)
{
	struct btree * T = C->T;

	/*
	 * Adjust our "cleaning debt" based on this page.  We count a page
	 * which is x% of the maximum age as being x% of a page-cleaning;
	 * this is based on the arbitrary assumption that recently modified
	 * pages are somewhat more likely to be modified again, but not
	 * dramatically so.
	 */
	C->cleandebt -= (double)(T->nextblk - N->pagenum) / (double)(T->npages);

	/*
	 * If this node is waiting to be dirtied by the cleaner, remove it
	 * from the queue.
	 */
	if ((N->type == NODE_TYPE_LEAF) && (N->state == NODE_STATE_CLEAN) &&
	    (N->v.cstate != NULL)) {
		/* Remove the node from the cleaning group. */
		free_cstate(N->v.cstate);
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq (%rdi), %rax
movq 0x10(%rax), %rcx
subq (%rsi), %rcx
movq %rcx, %xmm0
movq 0xda7c(%rip), %xmm1     # 0x14b80
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xda80(%rip), %xmm2     # 0x14b90
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq 0x50(%rax), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm3
movsd 0x10(%rdi), %xmm0
subsd %xmm3, %xmm0
movsd %xmm0, 0x10(%rdi)
movb 0x1c(%rsi), %al
andb $0xf, %al
cmpb $0x1, %al
jne 0x71fe
movq 0x48(%rsi), %rbx
testq %rbx, %rbx
je 0x71fe
movq 0x8(%rbx), %r14
movq 0x18(%rbx), %rax
leaq 0x8(%r14), %rcx
leaq 0x10(%rax), %rdx
testq %rax, %rax
cmoveq %rcx, %rdx
movq 0x10(%rbx), %rcx
movq %rcx, (%rdx)
movq 0x10(%rbx), %rcx
testq %rcx, %rcx
je 0x7190
movq %rax, 0x18(%rcx)
movq (%rbx), %rax
movq $0x0, 0x48(%rax)
movq (%rbx), %rsi
testq %rsi, %rsi
je 0x71ce
movq 0x8(%rbx), %rax
movq (%rax), %rax
movq (%rax), %rax
movq 0x30(%rax), %rdi
movq 0x20(%rdi), %rax
movq (%rsi,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x7206
decq %rcx
movq %rcx, (%rax)
jne 0x71ce
callq 0x10885
movq 0x8(%rbx), %rax
movq (%rax), %rax
decq 0x30(%rax)
cmpq $0x0, 0x8(%r14)
jne 0x71ef
cmpq $0x0, 0x20(%r14)
jne 0x71ef
movq %r14, %rdi
callq 0x766b
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2040
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0xd473(%rip), %rdi      # 0x14680
leaq 0xd492(%rip), %rsi      # 0x146a6
leaq 0xd4a4(%rip), %rcx      # 0x146bf
movl $0x88, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_cleaning.c
// Function: btree_cleaning_clean
int
btree_cleaning_clean(struct cleaner * C)
{
	struct cleaning_group * G;
	struct cleaning_group * Gnext;
	struct cleaning * CC;
	struct cleaning * CCnext;

	/* Scan through the list of groups. */
	for (G = C->head; G != NULL; G = Gnext) {
		/* Record the next group, since G will be freed. */
		Gnext = G->next;

		/* Is this group ready for cleaning? */
		if (G->pending_fetches != 0)
			continue;

		/* Scan through the list of cleaning structures. */
		for (CC = G->head; CC != NULL; CC = CCnext) {
			/* Record the next struct, since CC will be freed. */
			CCnext = CC->next;

			/* Dirty the node. */
			if (btree_node_dirty(C->T, CC->N) == 0)
				goto err0;
		}
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq 0x28(%rdi), %rax
xorl %ebx, %ebx
testq %rax, %rax
je 0x7292
movq %rdi, %r14
movq 0x10(%rax), %r15
cmpq $0x0, 0x20(%rax)
je 0x726e
movq %r15, %rax
testq %r15, %r15
jne 0x7259
jmp 0x7292
movq 0x8(%rax), %r12
testq %r12, %r12
je 0x7264
movq (%r12), %rsi
movq 0x10(%r12), %r12
movq (%r14), %rdi
callq 0x8fed
testq %rax, %rax
jne 0x7272
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_cleaning.c
// Function: btree_cleaning_stop
void
btree_cleaning_stop(struct cleaner * C)
{

	/* Stop the timer if it is running. */
	if (C->cleantimer != NULL) {
		events_timer_cancel(C->cleantimer);
		C->cleantimer = NULL;
	}

	/* Loop until we have no cleaning pending. */
	do {
		/* If we have nodes ready to be dirtied, dirty them. */
		if (btree_cleaning_clean(C)) {
			warnp("Failure dirtying nodes in cleaner");
			exit(1);
		}

		/* Do we have any cleaning groups left? */
		if ((C->group_pending == 0) && (C->pending_cleans == 0))
			break;

		/* Run any available events. */
		if (events_run()) {
			warnp("Error running event loop");
			exit(1);
		}
	} while (1);

	/* We should have no cleaning groups. */
	assert(C->head == NULL);

	/* Free the cleaner state structure. */
	free(C);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0x72ba
callq 0xc8b1
movq $0x0, 0x18(%rbx)
movq %rbx, %rdi
callq 0x7243
testl %eax, %eax
jne 0x72ff
cmpl $0x0, 0x20(%rbx)
jne 0x72d3
cmpq $0x0, 0x30(%rbx)
je 0x72ef
callq 0xb774
testl %eax, %eax
je 0x72ba
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x7325
leaq 0xcfad(%rip), %rdi      # 0x1429a
jmp 0x7310
cmpq $0x0, 0x28(%rbx)
jne 0x7346
movq %rbx, %rdi
popq %rbx
jmp 0x2040
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x7319
leaq 0xd8c0(%rip), %rdi      # 0x14bd0
xorl %eax, %eax
callq 0x10167
jmp 0x733c
movq %rax, %rbx
leaq 0xd8ad(%rip), %rdi      # 0x14bd0
jmp 0x732f
movq %rax, %rbx
leaq 0xcf6b(%rip), %rdi      # 0x1429a
xorl %eax, %eax
callq 0x10048
movl $0x0, (%rbx)
movl $0x1, %edi
callq 0x2370
leaq 0xd8a5(%rip), %rdi      # 0x14bf2
leaq 0xd8ae(%rip), %rsi      # 0x14c02
leaq 0xd8b8(%rip), %rcx      # 0x14c13
movl $0x253, %edx            # imm = 0x253
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_cleaning.c
// Function: free_cg
static void
free_cg(struct cleaning_group * CG)
{
	struct cleaner * C = CG->C;

	/* Sanity-check: The group must have no nodes. */
	assert(CG->head == NULL);
	assert(CG->pending_fetches == 0);

	/* Remove from the list of groups. */
	if (CG->prev != NULL)
		CG->prev->next = CG->next;
	else
		C->head = CG->next;
	if (CG->next != NULL)
		CG->next->prev = CG->prev;

	/* Free the group. */
	free(CG);
}

// Assembly:
pushq %rax
cmpq $0x0, 0x8(%rdi)
jne 0x76aa
cmpq $0x0, 0x20(%rdi)
jne 0x76c9
movq (%rdi), %rcx
movq 0x18(%rdi), %rax
addq $0x28, %rcx
leaq 0x10(%rax), %rdx
testq %rax, %rax
cmoveq %rcx, %rdx
movq 0x10(%rdi), %rcx
movq %rcx, (%rdx)
movq 0x10(%rdi), %rcx
testq %rcx, %rcx
je 0x76a4
movq %rax, 0x18(%rcx)
popq %rax
jmp 0x2040
leaq 0xd602(%rip), %rdi      # 0x14cb3
leaq 0xd54a(%rip), %rsi      # 0x14c02
leaq 0xd605(%rip), %rcx      # 0x14cc4
movl $0x4d, %edx
callq 0x21c0
leaq 0xd61a(%rip), %rdi      # 0x14cea
leaq 0xd52b(%rip), %rsi      # 0x14c02
leaq 0xd5e6(%rip), %rcx      # 0x14cc4
movl $0x4e, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_cleaning.c
// Function: callback_clean
static int
callback_clean(void * cookie, struct node * N)
{
	struct cleaning_group * CG = cookie;
	struct cleaning * C;

	/* This must be a leaf node. */
	assert(N->type == NODE_TYPE_LEAF);

	/* We're not fetching this node any more. */
	CG->pending_fetches--;

	/* If this node is not CLEAN, we don't need to clean it any more. */
	if (N->state != NODE_STATE_CLEAN) {
		CG->C->pending_cleans--;
		btree_node_unlock(CG->C->T, N);
		goto done;
	}

	/* Bake a cookie. */
	if ((C = malloc(sizeof(struct cleaning))) == NULL)
		goto err1;
	C->N = N;
	C->G = CG;

	/* Hook this node into the group. */
	C->next = CG->head;
	C->prev = NULL;
	CG->head = C;
	if (C->next != NULL)
		C->next->prev = C;

	/* Mark this node as pending cleaning. */
	N->v.cstate = C;

done:
	/* Success! */
	return (0);

err1:
	btree_node_unlock(CG->C->T, N);

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

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movb 0x1c(%rsi), %al
andb $0x3, %al
cmpb $0x1, %al
jne 0x7793
movq %rsi, %rbx
movq %rdi, %r14
decq 0x20(%rdi)
testb $0xc, 0x1c(%rsi)
je 0x7744
movq (%r14), %rax
decq 0x30(%rax)
xorl %ebp, %ebp
testq %rbx, %rbx
je 0x777d
movq (%rax), %rax
movq 0x30(%rax), %rdi
movq 0x20(%rdi), %rax
movq (%rbx,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x77b2
decq %rcx
movq %rcx, (%rax)
jne 0x777d
movq %rbx, %rsi
callq 0x10885
jmp 0x777d
movl $0x20, %edi
callq 0x22a0
testq %rax, %rax
je 0x7784
movq %rbx, (%rax)
movq %r14, 0x8(%rax)
movq 0x8(%r14), %rcx
movq %rcx, 0x10(%rax)
movq $0x0, 0x18(%rax)
movq %rax, 0x8(%r14)
testq %rcx, %rcx
je 0x7777
movq %rax, 0x18(%rcx)
movq %rax, 0x48(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rbx, %rbx
je 0x777d
movq (%r14), %rax
jmp 0x7717
leaq 0xd569(%rip), %rdi      # 0x14d03
leaq 0xd461(%rip), %rsi      # 0x14c02
leaq 0xd575(%rip), %rcx      # 0x14d1d
movl $0x83, %edx
callq 0x21c0
leaq 0xcec7(%rip), %rdi      # 0x14680
leaq 0xcee6(%rip), %rsi      # 0x146a6
leaq 0xcef8(%rip), %rcx      # 0x146bf
movl $0x88, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_cleaning.c
// Function: recompute_oncl
static void
recompute_oncl(struct node * N)
{
	size_t i;

	/* If we've gone past the top of the tree, do nothing. */
	if (N == NULL)
		return;

	/* Find the lowest value. */
	N->oldestncleaf = (uint64_t)(-1);
	for (i = 0; i <= N->nkeys; i++) {
		if (N->v.children[i]->oldestncleaf < N->oldestncleaf)
			N->oldestncleaf = N->v.children[i]->oldestncleaf;
	}

	/* Move up the tree. */
	recompute_oncl(N->p_shadow);
}

// Assembly:
testq %rdi, %rdi
je 0x781d
movq $-0x1, 0x10(%rdi)
movq 0x38(%rdi), %rax
movq 0x48(%rdi), %rcx
leaq 0x1(%rax), %rdx
cmpq $0x1, %rdx
adcq $0x1, %rax
movq $-0x1, %rsi
xorl %edx, %edx
movq (%rcx,%rdx,8), %r8
movq 0x10(%r8), %r8
cmpq %rsi, %r8
jae 0x780f
movq %r8, 0x10(%rdi)
movq %r8, %rsi
incq %rdx
cmpq %rdx, %rax
jne 0x77fb
movq 0x20(%rdi), %rdi
jmp 0x77d1
retq
nop
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_mlen.c
// Function: mlen_traverse
static void
mlen_traverse(struct node * N, const struct kvldskey * start,
    const struct kvldskey * end)
{
	size_t i;

	/* If this node is not dirty, we have nothing to do. */
	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++)
			mlen_traverse(N->v.children[i],
			    (i == 0) ? start : N->u.keys[i - 1],
			    (i < N->nkeys) ? N->u.keys[i] : end);
	}

	/* Store the matching prefix length for this node. */
	if ((start == NULL) || (end == NULL))
		N->mlen_t = 0;
	else
		N->mlen_t = (uint8_t)kvldskey_mlen(start, end);
}

// Assembly:
movb 0x1c(%rdi), %al
movl %eax, %ecx
andb $0xc, %cl
cmpb $0x8, %cl
jne 0x78be
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
testb $0x3, %al
jne 0x7891
movq 0x38(%rbx), %rax
xorl %r12d, %r12d
movq %r15, %rsi
testq %r12, %r12
je 0x7868
movq 0x40(%rbx), %rcx
movq -0x8(%rcx,%r12,8), %rsi
movq %r14, %rdx
cmpq %rax, %r12
jae 0x7878
movq 0x40(%rbx), %rax
movq (%rax,%r12,8), %rdx
movq 0x48(%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x782a
incq %r12
movq 0x38(%rbx), %rax
cmpq %rax, %r12
jbe 0x7857
testq %r15, %r15
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
je 0x78a5
xorl %eax, %eax
jmp 0x78b0
movq %r15, %rdi
movq %r14, %rsi
callq 0x103ab
movb %al, 0x1e(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_sync.c
// Function: btree_sync
int
btree_sync(struct btree * T, int (* callback)(void *), void * cookie)
{
	struct write_cookie * WC;
	size_t npages;
	const uint8_t ** bufv;
	uint64_t pn = 0;

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

	/* Figure out how many pages we need to write. */
	npages = ndirty(T->root_dirty);

	/* Allocate a vector to hold pointers to pages. */
	if (IMALLOC(bufv, npages, const uint8_t *))
		goto err1;

	/* Serialize pages and record pointers into the vector. */
	if (serializetree(T, T->root_dirty, T->pagelen, T->nextblk,
	    bufv, &pn))
		goto err2;

	/* Sanity check the number of pages serialized. */
	assert(pn == npages);
	assert(npages <= UINT32_MAX);

	/* Write pages out. */
	if (proto_lbs_request_append_blks(T->LBS, (uint32_t)npages, T->nextblk,
	    T->pagelen, bufv, callback_append, WC)) {
		warnp("Error writing pages");
		goto err2;
	}

	/* Free the page pointers vector. */
	free(bufv);

	/* Success! */
	return (0);

err2:
	free(bufv);
err1:
	free(WC);
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
movq $0x0, 0x10(%rsp)
movl $0x18, %edi
callq 0x22a0
testq %rax, %rax
je 0x792a
movq %rax, %rbx
movq %r15, 0x10(%rax)
movq %r12, (%rax)
movq %r14, 0x8(%rax)
movq 0x28(%r15), %r13
movq %r13, %rdi
callq 0x7a4a
movq %rax, %r12
testq %rax, %rax
je 0x7925
movq %r12, %rax
shrq $0x3d, %rax
je 0x7931
callq 0x20a0
movl $0xc, (%rax)
xorl %r14d, %r14d
jmp 0x7941
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x7984
leaq (,%r12,8), %rdi
callq 0x22a0
movq %rax, %r14
testq %r14, %r14
sete %al
testq %r12, %r12
setne %cl
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %al, %cl
jne 0x797c
movq (%r15), %rdx
movq 0x10(%r15), %rcx
leaq 0x10(%rsp), %r9
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %r8
callq 0x7a9a
testl %eax, %eax
je 0x7995
movq %r14, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq %r12, 0x10(%rsp)
jne 0x7a0c
movq %r12, %rax
shrq $0x20, %rax
jne 0x7a2b
movq 0x18(%r15), %rdi
movq (%r15), %rcx
movq 0x10(%r15), %rdx
movq %rbx, (%rsp)
leaq 0x1cf(%rip), %r9        # 0x7b8e
movl %r12d, %esi
movq %r14, %r8
callq 0x11458
testl %eax, %eax
je 0x79f2
callq 0x20a0
cmpl $0x0, (%rax)
je 0x79f9
movq %rax, %r15
leaq 0xd3cc(%rip), %rdi      # 0x14dae
xorl %eax, %eax
callq 0x10048
movl $0x0, (%r15)
jmp 0x7974
xorl %ebp, %ebp
movq %r14, %rbx
jmp 0x797c
leaq 0xd3ae(%rip), %rdi      # 0x14dae
xorl %eax, %eax
callq 0x10167
jmp 0x7974
leaq 0xd334(%rip), %rdi      # 0x14d47
leaq 0xd33a(%rip), %rsi      # 0x14d54
leaq 0xd340(%rip), %rcx      # 0x14d61
movl $0xe1, %edx
callq 0x21c0
leaq 0xd367(%rip), %rdi      # 0x14d99
leaq 0xd31b(%rip), %rsi      # 0x14d54
leaq 0xd321(%rip), %rcx      # 0x14d61
movl $0xe2, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_sync.c
// Function: ndirty
static size_t
ndirty(struct node * N)
{
	size_t n, i;

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

	/* If this node is not a parent, it is the only dirty node. */
	if (N->type != NODE_TYPE_PARENT)
		return (1);

	/* Otherwise, we have 1 + the sum of children. */
	for (n = 1, i = 0; i <= N->nkeys; i++)
		n += ndirty(N->v.children[i]);
	return (n);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movb 0x1c(%rdi), %al
movl %eax, %ecx
andb $0xc, %cl
cmpb $0x8, %cl
jne 0x7a89
movl $0x1, %ebx
testb $0x3, %al
jne 0x7a8b
movq 0x38(%rdi), %r14
movq 0x48(%rdi), %r15
xorl %r12d, %r12d
movq (%r15,%r12,8), %rdi
callq 0x7a4a
addq %rax, %rbx
incq %r12
cmpq %r14, %r12
jbe 0x7a73
jmp 0x7a8b
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, (%rsp)
movq %rcx, %rbp
movq %rdx, %r12
movb 0x1c(%rsi), %cl
movl %ecx, %edx
andb $0xc, %dl
xorl %eax, %eax
cmpb $0x8, %dl
jne 0x7b7f
movq %r9, %r14
movq %rsi, %r15
movq %rdi, %r13
testb $0x3, %cl
jne 0x7b00
xorl %ebx, %ebx
movq 0x48(%r15), %rax
movq (%rax,%rbx,8), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq %rbp, %rcx
movq (%rsp), %r8
movq %r14, %r9
callq 0x7a9a
testl %eax, %eax
jne 0x7b7a
incq %rbx
cmpq 0x38(%r15), %rbx
jbe 0x7ad2
addq (%r14), %rbp
movq %rbp, (%r15)
movq %rbp, 0x8(%r15)
testb $0x3, 0x1c(%r15)
jne 0x7b47
movq 0x8(%r15), %rdx
movq 0x38(%r15), %rax
movq 0x48(%r15), %rcx
leaq 0x1(%rax), %rsi
cmpq $0x1, %rsi
adcq $0x1, %rax
xorl %esi, %esi
movq (%rcx,%rsi,8), %rdi
movq 0x8(%rdi), %rdi
cmpq %rdx, %rdi
jae 0x7b3f
movq %rdi, 0x8(%r15)
movq %rdi, %rdx
incq %rsi
cmpq %rsi, %rax
jne 0x7b2b
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xa400
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x7b7f
movq 0x50(%r15), %rax
movq (%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
movq (%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
xorl %eax, %eax
jmp 0x7b7f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_sync.c
// Function: callback_append
static int
callback_append(void * cookie, int failed, int status, uint64_t blkno)
{
	struct write_cookie * WC = cookie;
	struct btree * T = WC->T;

	/* Throw a fit if we didn't manage to write the pages. */
	if (failed) {
		warnp("LBS APPEND request failed");
		goto err1;
	}
	if (status) {
		warn0("Failed to write dirty nodes to backing store");
		goto err1;
	}

	/* Record the next available block number. */
	T->nextblk = blkno;

	/* Mark the nodes in the dirty tree as clean. */
	makeclean(T, T->root_dirty);

	/*
	 * Make sure no callbacks are pending on the shadow tree before we
	 * garbage collect it.
	 */
	if (!events_immediate_register(callback_unshadow, WC, 1))
		goto err1;

	/* Success! */
	return (0);

err1:
	free(WC);

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

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
testl %esi, %esi
je 0x7bbd
callq 0x20a0
cmpl $0x0, (%rax)
je 0x7bdc
movq %rax, %r14
leaq 0xd215(%rip), %rdi      # 0x14dc2
xorl %eax, %eax
callq 0x10048
movl $0x0, (%r14)
jmp 0x7bea
testl %edx, %edx
je 0x7bff
leaq 0xd214(%rip), %rdi      # 0x14ddc
xorl %eax, %eax
callq 0x10167
callq 0x20a0
movl $0x0, (%rax)
jmp 0x7bea
leaq 0xd1df(%rip), %rdi      # 0x14dc2
xorl %eax, %eax
callq 0x10167
movq %rbx, %rdi
callq 0x2040
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x10(%rbx), %rdi
movq %rcx, 0x10(%rdi)
movq 0x28(%rdi), %rsi
callq 0x7c30
leaq 0x142(%rip), %rdi       # 0x7d59
movq %rbx, %rsi
movl $0x1, %edx
callq 0xba4c
movq %rax, %rcx
xorl %eax, %eax
testq %rcx, %rcx
jne 0x7bf7
jmp 0x7bea
// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
movl 0x1c(%rsi), %eax
movl %eax, %ecx
shrl $0x2, %ecx
andl $0x3, %ecx
cmpl $0x2, %ecx
je 0x7c6d
cmpl $0x1, %ecx
jne 0x7d2a
leaq 0xd1b4(%rip), %rdi      # 0x14e09
leaq 0xd0f8(%rip), %rsi      # 0x14d54
leaq 0xd1c4(%rip), %rcx      # 0x14e27
movl $0x68, %edx
callq 0x21c0
movq %rsi, %r14
movq %rdi, %rbx
testb $0x3, %al
jne 0x7c93
xorl %r15d, %r15d
movq 0x48(%r14), %rax
movq (%rax,%r15,8), %rsi
movq %rbx, %rdi
callq 0x7c30
incq %r15
cmpq 0x38(%r14), %r15
jbe 0x7c7a
movq (%r14), %rax
movq %rax, 0x10(%r14)
movb 0x1c(%r14), %al
testb $0x3, %al
jne 0x7cd8
movq 0x10(%r14), %rsi
movq 0x38(%r14), %rcx
movq 0x48(%r14), %rdx
leaq 0x1(%rcx), %rdi
cmpq $0x1, %rdi
adcq $0x1, %rcx
xorl %edi, %edi
movq (%rdx,%rdi,8), %r8
movq 0x10(%r8), %r8
cmpq %rsi, %r8
jae 0x7cd0
movq %r8, 0x10(%r14)
movq %r8, %rsi
incq %rdi
cmpq %rdi, %rcx
jne 0x7cbc
andb $-0xd, %al
movb %al, 0x1c(%r14)
movq 0x30(%rbx), %rdi
movq 0x20(%rdi), %rax
movq (%r14,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x7d3a
decq %rcx
movq %rcx, (%rax)
jne 0x7d02
movq %r14, %rsi
callq 0x10885
movq 0x28(%r14), %rsi
movq %rsi, 0x20(%r14)
testq %rsi, %rsi
je 0x7d2a
movq 0x30(%rbx), %rdi
movq 0x20(%rdi), %rax
movq (%rsi,%rax), %rax
movq (%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
testq %rcx, %rcx
je 0x7d30
popq %rbx
popq %r14
popq %r15
retq
popq %rbx
popq %r14
popq %r15
jmp 0x107a3
leaq 0xc93f(%rip), %rdi      # 0x14680
leaq 0xc95e(%rip), %rsi      # 0x146a6
leaq 0xc970(%rip), %rcx      # 0x146bf
movl $0x88, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_sync.c
// Function: callback_unshadow
static int
callback_unshadow(void * cookie)
{
	struct write_cookie * WC = cookie;
	struct btree * T = WC->T;
	struct node * root_shadow;

	/*
	 * Grab the root of the shadow tree, and use the (now clean) dirty
	 * tree as the shadow tree henceforth.
	 */
	root_shadow = T->root_shadow;
	T->root_shadow = T->root_dirty;
	btree_node_lock(T, T->root_shadow);

	/* Kill the old shadow tree, if there was one. */
	if (root_shadow != NULL) {
		/* This isn't a root any more, so release the root lock. */
		btree_node_unlock(T, root_shadow);

		/*
		 * Traverse the tree, re-pointing clean children at their
		 * dirty parents and freeing shadow nodes.
		 */
		unshadow(T, root_shadow);
	}

	/* Update number-of-pages-used value. */
	T->npages = T->nextblk - T->root_dirty->oldestleaf;

	/*
	 * We could issue a FREE call here, but since FREE is only advisory
	 * we need to call it elsewhere as well in order to avoid having data
	 * permanently stored even when it could all be freed.  Since we're
	 * calling FREE elsewhere anyway, don't bother calling it here.
	 */

	/* Register post-sync callback to be performed. */
	if (!events_immediate_register(WC->callback, WC->cookie, 0))
		goto err1;

	/* Free cookie. */
	free(WC);

	/* Success! */
	return (0);

err1:
	free(WC);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x10(%rdi), %r14
movq 0x20(%r14), %r15
movq 0x28(%r14), %rsi
movq %rsi, 0x20(%r14)
testq %rsi, %rsi
je 0x7d98
movq 0x30(%r14), %rdi
movq 0x20(%rdi), %rax
movq (%rsi,%rax), %rax
movq (%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
testq %rcx, %rcx
jne 0x7d98
callq 0x107a3
testq %r15, %r15
je 0x7dcc
movq 0x30(%r14), %rdi
movq 0x20(%rdi), %rax
movq (%r15,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x7e0a
decq %rcx
movq %rcx, (%rax)
jne 0x7dc1
movq %r15, %rsi
callq 0x10885
movq %r14, %rdi
movq %r15, %rsi
callq 0x7e29
movq 0x10(%r14), %rax
movq 0x28(%r14), %rcx
subq 0x8(%rcx), %rax
movq %rax, 0x50(%r14)
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0xba4c
movq %rax, %r14
movq %rbx, %rdi
callq 0x2040
cmpq $0x1, %r14
sbbl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc86f(%rip), %rdi      # 0x14680
leaq 0xc88e(%rip), %rsi      # 0x146a6
leaq 0xc8a0(%rip), %rcx      # 0x146bf
movl $0x88, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_sync.c
// Function: unshadow
static void
unshadow(struct btree * T, struct node * N)
{
	size_t i;

#ifdef SANITY_CHECKS
	/* Sanity check the B+Tree. */
	btree_sanity(T);
#endif

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

	/* If this node is clean, reparent it and return. */
	if (N->state == NODE_STATE_CLEAN) {
		/* Do we need to release a lock on our shadow parent? */
		if (node_hasplock(N))
			btree_node_unlock(T, N->p_shadow);

		/* Our dirty parent is our only parent. */
		N->p_shadow = N->p_dirty;

		/* Acquire a lock on our new shadow parent. */
		if (node_hasplock(N))
			btree_node_lock(T, N->p_shadow);

		/* We're done. */
		return;
	}

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

			/* Clear the child pointer. */
			N->v.children[i] = NULL;
		}
	}

#ifdef SANITY_CHECKS
	/* Sanity check the B+Tree. */
	btree_sanity(T);
#endif

	/* Destroy this node. */
	btree_node_destroy(T, N);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movl 0x1c(%rsi), %eax
movl %eax, %ecx
shrl $0x2, %ecx
andl $0x3, %ecx
je 0x7e86
cmpl $0x2, %ecx
je 0x7efe
testb $0x3, %al
jne 0x7e76
xorl %r15d, %r15d
movq 0x48(%r14), %rax
movq (%rax,%r15,8), %rsi
movq %rbx, %rdi
callq 0x7e29
movq 0x48(%r14), %rax
movq $0x0, (%rax,%r15,8)
incq %r15
cmpq 0x38(%r14), %r15
jbe 0x7e51
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x8de9
andb $0x3, %al
cmpb $0x2, %al
je 0x7eb6
movq 0x20(%r14), %rsi
testq %rsi, %rsi
je 0x7eb6
movq 0x30(%rbx), %rdi
movq 0x20(%rdi), %rax
movq (%rsi,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x7f1d
decq %rcx
movq %rcx, (%rax)
jne 0x7eb6
callq 0x10885
movq 0x28(%r14), %rsi
movq %rsi, 0x20(%r14)
movb 0x1c(%r14), %al
andb $0x3, %al
cmpb $0x2, %al
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x7eee
movq 0x30(%rbx), %rdi
movq 0x20(%rdi), %rax
movq (%rsi,%rax), %rax
movq (%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
testq %rcx, %rcx
je 0x7ef4
popq %rbx
popq %r14
popq %r15
retq
popq %rbx
popq %r14
popq %r15
jmp 0x107a3
leaq 0xcf50(%rip), %rdi      # 0x14e55
leaq 0xce48(%rip), %rsi      # 0x14d54
leaq 0xcf5f(%rip), %rcx      # 0x14e72
movl $0x99, %edx
callq 0x21c0
leaq 0xc75c(%rip), %rdi      # 0x14680
leaq 0xc77b(%rip), %rsi      # 0x146a6
leaq 0xc78d(%rip), %rcx      # 0x146bf
movl $0x88, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_find.c
// Function: btree_find_kvpair
struct kvpair_const *
btree_find_kvpair(struct node * N, const struct kvldskey * k)
{
	size_t min, max, mid;
	int rc;

	/* We must be in a leaf node. */
	assert(N->type == NODE_TYPE_LEAF);

	/*
	 * This key could be anywhere from position 0 (less than key #0) up
	 * to position N->nkeys (greater than key #(nkeys - 1)).
	 */
	min = 0;
	max = N->nkeys;

	/* Keep looking until we figure out where it belongs. */
	while (min != max) {
		/* Compare to the midpoint. */
		mid = min + (max - min) / 2;
		rc = kvldskey_cmp2(k, N->u.pairs[mid].k, N->mlen_t);

		/* Adjust endpoints. */
		if (rc < 0) {
			/* The key is less than key #mid. */
			max = mid;
		} else if (rc > 0) {
			/* The key is greater than key #mid. */
			min = mid + 1;
		} else {
			/* Found it! */
			return (&N->u.pairs[mid]);
		}
	}

	/* We didn't find it. */
	return (NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movb 0x1c(%rdi), %al
andb $0x3, %al
cmpb $0x1, %al
jne 0x7fba
movq %rdi, %rbx
movq 0x38(%rdi), %r12
testq %r12, %r12
je 0x7f9f
movq %rsi, %r14
xorl %r13d, %r13d
movq %r12, %rbp
subq %r13, %rbp
shrq %rbp
addq %r13, %rbp
movq 0x40(%rbx), %rax
movq %rbp, %r15
shlq $0x4, %r15
movq (%rax,%r15), %rsi
movzbl 0x1e(%rbx), %edx
movq %r14, %rdi
callq 0x10377
testl %eax, %eax
js 0x7f97
je 0x7fa4
incq %rbp
movq %rbp, %r13
jmp 0x7f9a
movq %rbp, %r12
cmpq %r12, %r13
jne 0x7f62
xorl %r15d, %r15d
jmp 0x7fa8
addq 0x40(%rbx), %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcd42(%rip), %rdi      # 0x14d03
leaq 0xced7(%rip), %rsi      # 0x14e9f
leaq 0xcedd(%rip), %rcx      # 0x14eac
movl $0x29, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_find.c
// Function: btree_find_child
size_t
btree_find_child(struct node * N, const struct kvldskey * k)
{
	size_t min, max, mid;
	int rc;

	/* We must be in a parent node. */
	assert(N->type == NODE_TYPE_PARENT);

	/* This key could belong anywhere from child 0 up to N->nkeys. */
	min = 0;
	max = N->nkeys;

	/* Keep looking until we figure out where it belongs. */
	while (min != max) {
		/* Compare to the midpoint. */
		mid = min + (max - min) / 2;
		rc = kvldskey_cmp2(k, N->u.keys[mid], N->mlen_t);

		/* Adjust endpoints. */
		if (rc < 0) {
			/* The key is less than key #mid. */
			max = mid;
		} else if (rc > 0) {
			/* The key is greater than or equal to key #mid. */
			min = mid + 1;
		} else {
			/* Found it! */
			return (mid + 1);
		}
	}

	/* This must be it. */
	return (min);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testb $0x3, 0x1c(%rdi)
jne 0x8045
movq %rdi, %r14
movq 0x38(%rdi), %r12
testq %r12, %r12
je 0x8035
movq %rsi, %rbx
xorl %r15d, %r15d
movq %r12, %r13
subq %r15, %r13
shrq %r13
addq %r15, %r13
movq 0x40(%r14), %rax
movq (%rax,%r13,8), %rsi
movzbl 0x1e(%r14), %edx
movq %rbx, %rdi
callq 0x10377
testl %eax, %eax
js 0x802b
incq %r13
movq %r13, %r15
testl %eax, %eax
jne 0x802e
jmp 0x8038
movq %r13, %r12
cmpq %r12, %r15
jne 0x7ffa
jmp 0x8038
xorl %r15d, %r15d
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xceaf(%rip), %rdi      # 0x14efb
leaq 0xce4c(%rip), %rsi      # 0x14e9f
leaq 0xcebd(%rip), %rcx      # 0x14f17
movl $0x55, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_find.c
// Function: btree_find_leaf
int
btree_find_leaf(struct btree * T, struct node * N, const struct kvldskey * k,
    int (* callback)(void *, struct node *), void * cookie)
{
	struct findleaf_cookie * C;

	/* Bake a cookie. */
	if ((C = mpool_findleaf_malloc()) == NULL)
		goto err0;
	C->callback = callback;
	C->callback_range = NULL;
	C->cookie = cookie;
	C->T = T;
	C->N = N;
	C->k = k;
	C->h = 0;
	C->e = NULL;

	/* Lock the node. */
	btree_node_lock(C->T, C->N);

	/* Call into findleaf. */
	if (findleaf(C)) {
		/* Upon error, findleaf has already freed C. */
		goto err0;
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r12
movq %rcx, %r13
movq %rdx, %r15
incq 0x15239(%rip)           # 0x1d2b8
movq %rsi, %rbx
movq %rdi, %r14
movq 0x15214(%rip), %rax     # 0x1d2a0
testq %rax, %rax
je 0x80aa
movq 0x15218(%rip), %rcx     # 0x1d2b0
leaq -0x1(%rax), %rdx
movq %rdx, 0x151fd(%rip)     # 0x1d2a0
movq -0x8(%rcx,%rax,8), %rbp
jmp 0x80dd
incq 0x1520f(%rip)           # 0x1d2c0
cmpl $0x0, 0x15210(%rip)     # 0x1d2c8
jne 0x80d0
movq 0x15217(%rip), %rdi     # 0x1d2d8
callq 0x130a0
movl $0x1, 0x151f8(%rip)     # 0x1d2c8
movl $0x40, %edi
callq 0x22a0
movq %rax, %rbp
testq %rbp, %rbp
je 0x813c
movq %r13, (%rbp)
xorl %r13d, %r13d
movq %r13, 0x8(%rbp)
movq %r12, 0x10(%rbp)
movq %r14, 0x18(%rbp)
movq %rbx, 0x20(%rbp)
movq %r15, 0x28(%rbp)
movl $0x0, 0x30(%rbp)
movq %r13, 0x38(%rbp)
testq %rbx, %rbx
je 0x8130
movq 0x30(%r14), %rdi
movq 0x20(%rdi), %rax
movq (%rbx,%rax), %rax
movq (%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
testq %rcx, %rcx
jne 0x8130
movq %rbx, %rsi
callq 0x107a3
movq %rbp, %rdi
callq 0x8154
testl %eax, %eax
je 0x8142
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/btree_mutate.c
// Function: btree_mutate_mutable
int
btree_mutate_mutable(struct node * N)
{

	/* Sanity check. */
	assert(N->type == NODE_TYPE_LEAF);
	assert(N->state == NODE_STATE_DIRTY);
	assert(N->pagesize == (uint32_t)(-1));
	assert(N->v.H == NULL);

	/* Create a hash table for short-term key-value storage. */
	if ((N->v.H = kvhash_init()) == NULL)
		goto err0;

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbx
movb 0x1c(%rdi), %al
movl %eax, %ecx
andb $0x3, %cl
cmpb $0x1, %cl
jne 0x8711
andb $0xc, %al
cmpb $0x8, %al
jne 0x8730
movq %rdi, %rbx
cmpl $-0x1, 0x18(%rdi)
jne 0x874f
cmpq $0x0, 0x48(%rbx)
jne 0x876e
callq 0x103cc
movq %rax, 0x48(%rbx)
xorl %ecx, %ecx
cmpq $0x1, %rax
sbbl %ecx, %ecx
movl %ecx, %eax
popq %rbx
retq
leaq 0xc5eb(%rip), %rdi      # 0x14d03
leaq 0xc875(%rip), %rsi      # 0x14f94
leaq 0xc87d(%rip), %rcx      # 0x14fa3
movl $0x19, %edx
callq 0x21c0
leaq 0xc894(%rip), %rdi      # 0x14fcb
leaq 0xc856(%rip), %rsi      # 0x14f94
leaq 0xc85e(%rip), %rcx      # 0x14fa3
movl $0x1a, %edx
callq 0x21c0
leaq 0xc892(%rip), %rdi      # 0x14fe8
leaq 0xc837(%rip), %rsi      # 0x14f94
leaq 0xc83f(%rip), %rcx      # 0x14fa3
movl $0x1b, %edx
callq 0x21c0
leaq 0xc891(%rip), %rdi      # 0x15006
leaq 0xc818(%rip), %rsi      # 0x14f94
leaq 0xc820(%rip), %rcx      # 0x14fa3
movl $0x1c, %edx
callq 0x21c0