LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/kvlds/dispatch_mr.c
// Function: mpool_reqcookie_free
static struct node *
finddirty(struct nodepair * V, size_t N, struct node * shadow)
{
	struct nodepair * pair;
	struct nodepair k;

	/* Binary search. */
	k.shadow = shadow;
	pair = bsearch(&k, V, N, sizeof(struct nodepair), compar_snp);

	/* If we found the shadow node, return the matching dirty node. */
	if (pair != NULL)
		return (pair->dirty);

	/* Otherwise, return the shadow node we were given. */
	return (shadow);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x4515
movq %rdi, %rbx
movq 0x16e12(%rip), %r12     # 0x1b260
movq 0x16e13(%rip), %r13     # 0x1b268
cmpq %r13, %r12
jae 0x4476
movq 0x16e0f(%rip), %rax     # 0x1b270
leaq 0x1(%r12), %rcx
movq %rcx, 0x16df3(%rip)     # 0x1b260
movq %rbx, (%rax,%r12,8)
jmp 0x4515
movq 0x16dfb(%rip), %rax     # 0x1b278
shrq $0x8, %rax
cmpq %rax, 0x16df8(%rip)     # 0x1b280
jbe 0x4503
testq %r13, %r13
je 0x451f
movq %r13, %rdi
shlq $0x4, %rdi
callq 0x22a0
testq %rax, %rax
je 0x4503
movq %rax, %r14
movq 0x16dc2(%rip), %r15     # 0x1b270
leaq (,%r13,8), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2280
cmpq 0x16dc8(%rip), %r15     # 0x1b290
je 0x44e0
movq %r15, %rdi
callq 0x2040
movq 0x16d8f(%rip), %r13     # 0x1b268
movq 0x16d80(%rip), %r12     # 0x1b260
movq %r14, 0x16d89(%rip)     # 0x1b270
addq %r13, %r13
movq %r13, 0x16d77(%rip)     # 0x1b268
leaq 0x1(%r12), %rax
movq %rax, 0x16d63(%rip)     # 0x1b260
movq %rbx, (%r14,%r12,8)
jmp 0x450b
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0x16d63(%rip)    # 0x1b278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xcff7(%rip), %rdi      # 0x1151d
leaq 0xd001(%rip), %rsi      # 0x1152e
leaq 0xd01c(%rip), %rcx      # 0x11550
pushq $0x5a
popq %rdx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/kvlds/dispatch_mr.c
// Function: callback_synced
static int
callback_synced(void * cookie)
{
	struct batch * B = cookie;
	struct req_cookie * req;
	struct proto_kvlds_request * R;
	size_t i;

	/* Send response packets. */
	for (i = 0; i < B->nreqs; i++) {
		req = B->reqs[i];
		R = req->R;

		switch (R->type) {
		case PROTO_KVLDS_SET:
			if (proto_kvlds_response_set(B->WQ, R->ID))
				goto err0;
			break;
		case PROTO_KVLDS_CAS:
			if (proto_kvlds_response_cas(B->WQ, R->ID,
			    req->opdone ? 0 : 1))
				goto err0;
			break;
		case PROTO_KVLDS_ADD:
			if (proto_kvlds_response_add(B->WQ, R->ID,
			    req->opdone ? 0 : 1))
				goto err0;
			break;
		case PROTO_KVLDS_MODIFY:
			if (proto_kvlds_response_modify(B->WQ, R->ID,
			    req->opdone ? 0 : 1))
				goto err0;
			break;
		case PROTO_KVLDS_DELETE:
			if (proto_kvlds_response_delete(B->WQ, R->ID))
				goto err0;
			break;
		case PROTO_KVLDS_CAD:
			if (proto_kvlds_response_cad(B->WQ, R->ID,
			    req->opdone ? 0 : 1))
				goto err0;
			break;
		}
	}

	/* Schedule completion callback. */
	if (!events_immediate_register(B->callback_done, B->cookie, 0))
		goto err0;

	/* Clean up requests and request cookies. */
	for (i = 0; i < B->nreqs; i++) {
		proto_kvlds_request_free(B->reqs[i]->R);
		mpool_reqcookie_free(B->reqs[i]);
	}

	/* Free batch cookie. */
	free(B->reqs);
	free(B);

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %r14d, %r14d
pushq $-0x1
popq %rbp
leaq 0xd097(%rip), %r15      # 0x11658
cmpq 0x10(%rbx), %r14
jae 0x4622
movq 0x28(%rbx), %rax
movq (%rax,%r14,8), %rax
movq (%rax), %rcx
movl 0x8(%rcx), %edx
leal -0x110(%rdx), %esi
cmpl $0x3, %esi
ja 0x45e9
movslq (%r15,%rsi,4), %rdx
addq %r15, %rdx
jmpq *%rdx
cmpl $0x120, %edx            # imm = 0x120
je 0x460b
cmpl $0x121, %edx            # imm = 0x121
jne 0x461d
movq 0x20(%rbx), %rdi
movq (%rcx), %rsi
xorl %edx, %edx
cmpl $0x0, 0x18(%rax)
sete %dl
jmp 0x4614
movq 0x20(%rbx), %rdi
movq (%rcx), %rsi
xorl %edx, %edx
callq 0xece6
testl %eax, %eax
jne 0x466f
incq %r14
jmp 0x45c1
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
xorl %edx, %edx
callq 0x9f40
testq %rax, %rax
je 0x466f
xorl %r14d, %r14d
movq 0x28(%rbx), %rdi
cmpq 0x10(%rbx), %r14
jae 0x4660
movq (%rdi,%r14,8), %rax
movq (%rax), %rdi
callq 0xeb7a
movq 0x28(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x4432
incq %r14
jmp 0x4638
callq 0x2040
movq %rbx, %rdi
callq 0x2040
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
movq %rdx, (%rsp)
movl 0x8(%rsi), %r13d
movl %r13d, %eax
andl $-0x2, %eax
cmpl $0x130, %eax            # imm = 0x130
jne 0x4747
movq %r8, %rbp
movq %rcx, %rbx
movq %rsi, %r12
movq %rdi, %r15
pushq $0x58
popq %rdi
callq 0x22a0
movq %rax, %r14
pushq $-0x1
popq %rax
testq %r14, %r14
je 0x4738
movq %rbx, (%r14)
movq %rbp, 0x8(%r14)
movq %r15, 0x10(%r14)
movq %r12, 0x18(%r14)
movq (%rsp), %rax
movq %rax, 0x20(%r14)
movq 0x20(%r15), %rsi
movq 0x10(%r12), %rdx
cmpl $0x130, %r13d           # imm = 0x130
jne 0x4710
leaq 0x61(%rip), %rcx        # 0x4764
movq %r15, %rdi
movq %r14, %r8
callq 0x6e81
jmp 0x4725
leaq 0xcb(%rip), %r8         # 0x47e2
pushq $0x1
popq %rcx
movq %r15, %rdi
movq %r14, %r9
callq 0x70ba
testl %eax, %eax
je 0x4736
movq %r14, %rdi
callq 0x2040
pushq $-0x1
popq %rax
jmp 0x4738
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcf85(%rip), %rdi      # 0x116d3
leaq 0xcfbd(%rip), %rsi      # 0x11712
leaq 0xcfc5(%rip), %rcx      # 0x11721
pushq $0x39
popq %rdx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O2/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 0x6d6c
movq 0x18(%rbx), %rcx
movq 0x20(%rbx), %rdi
movq (%rcx), %rsi
testq %rax, %rax
je 0x4796
movq 0x8(%rax), %rcx
xorl %edx, %edx
jmp 0x479b
pushq $0x1
popq %rdx
xorl %ecx, %ecx
callq 0xed4b
testl %eax, %eax
je 0x47a9
pushq $-0x1
popq %rbp
jmp 0x47be
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0x9f40
testq %rax, %rax
je 0x47a4
movq 0x10(%rbx), %rdi
movq %r14, %rsi
callq 0x496f
movq 0x18(%rbx), %rdi
callq 0xeb7a
movq %rbx, %rdi
callq 0x2040
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, 0x38(%rdi)
movq 0x18(%rdi), %rdi
movq 0x20(%r14), %rax
movq 0x8(%rax), %rsi
leaq 0x104(%rip), %rdx       # 0x5449
xorl %ebx, %ebx
xorl %ecx, %ecx
callq 0xf6df
testl %eax, %eax
je 0x5357
pushq $-0x1
popq %rbx
jmp 0x5376
leaq -0x38(%rip), %rdi       # 0x5326
leaq 0xc6b3(%rip), %rdx      # 0x11a18
movq %r14, %rsi
callq 0xaa98
movq %rax, 0x38(%r14)
testq %rax, %rax
je 0x5352
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x53e4
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
callq 0x6246
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x53a5
callq 0xac0b
movq 0x20(%rbx), %rsi
movq %rbx, %rdi
callq 0x5403
movq 0x28(%rbx), %rsi
movq %rbx, %rdi
callq 0x5403
movq 0x20(%rbx), %rsi
movq %rbx, %rdi
callq 0x7a3d
movq 0x20(%rbx), %rdi
callq 0x9388
movq 0x30(%rbx), %rdi
callq 0xe7bc
movq %rbx, %rdi
popq %rbx
jmp 0x2040
leaq 0xc5ce(%rip), %rdi      # 0x119b9
leaq 0xc410(%rip), %rsi      # 0x11802
leaq 0xc5e0(%rip), %rcx      # 0x119d9
movl $0x1a0, %edx            # imm = 0x1A0
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
pushq %rax
cmpq $0x0, 0x18(%rdi)
jne 0x5cbe
movq %rdi, %rbx
movq 0x10(%rdi), %r14
movq 0x28(%r14), %rsi
callq 0x5d09
testl %eax, %eax
je 0x5c05
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%r14), %rax
testb $0x40, 0x1c(%rax)
jne 0x5c81
movq 0x10(%rbx), %r14
movq 0x28(%r14), %r15
testb $0x3, 0x1c(%r15)
jne 0x5c98
cmpq $0x0, 0x38(%r15)
jne 0x5c98
movq 0x48(%r15), %rax
movq (%rax), %rax
movq %rax, 0x28(%r14)
orb $0x10, 0x1c(%rax)
movq 0x28(%r14), %rsi
orl $-0x1, 0x18(%rsi)
movq %r14, %rdi
callq 0x59da
movq 0x28(%r14), %rax
andq $0x0, 0x28(%rax)
andb $-0x11, 0x1c(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x59ff
movq 0x48(%r15), %rax
andq $0x0, (%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x59ff
movq %r14, %rdi
movq %r15, %rsi
callq 0x7921
decq 0x48(%r14)
jmp 0x5c13
movq %rbx, %rdi
callq 0x56b7
testl %eax, %eax
jne 0x5bf5
xorl %ebp, %ebp
jmp 0x5bf8
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0x9f40
testq %rax, %rax
je 0x5bf5
movq %rbx, %rdi
callq 0x2040
jmp 0x5bf8
leaq 0xbe74(%rip), %rdi      # 0x11b39
leaq 0xbd71(%rip), %rsi      # 0x11a3d
leaq 0xbe7a(%rip), %rcx      # 0x11b4d
movl $0x27e, %edx            # imm = 0x27E
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x38
popq %rdi
callq 0x22a0
testq %rax, %rax
je 0x5fcd
movq %rax, %rbx
movq %r14, (%rax)
andl $0x0, 0x20(%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x28(%rax)
movsd (%r14), %xmm0
unpcklps 0xbc34(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xbc3c(%rip), %xmm0     # 0x11b80
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0xbc48(%rip), %xmm1     # 0x11ba0
mulsd 0xbc48(%rip), %xmm1     # 0x11ba8
mulsd (%rsp), %xmm1
mulsd 0xb4b3(%rip), %xmm1     # 0x11420
movsd %xmm1, 0x8(%rax)
andq $0x0, 0x10(%rax)
leaq 0x5c(%rip), %rdi        # 0x5fda
leaq 0xbc2b(%rip), %rdx      # 0x11bb0
movq %rax, %rsi
callq 0xaa98
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x5fcf
callq 0x20a0
cmpl $0x0, (%rax)
je 0x5fb7
movq %rax, %r14
leaq 0xb48e(%rip), %rdi      # 0x11438
xorl %eax, %eax
callq 0xdf55
andl $0x0, (%r14)
jmp 0x5fc5
leaq 0xb47a(%rip), %rdi      # 0x11438
xorl %eax, %eax
callq 0xe0e4
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_O2/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 %r15
pushq %r14
pushq %rbx
movq (%rdi), %rax
movq 0x10(%rax), %rcx
subq (%rsi), %rcx
movq %rcx, %xmm0
movq 0xba6b(%rip), %xmm1     # 0x11b70
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xba6f(%rip), %xmm2     # 0x11b80
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 0x61cc
movq 0x48(%rsi), %rbx
testq %rbx, %rbx
je 0x61cc
movq 0x8(%rbx), %r14
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
leaq 0x8(%r14), %r15
leaq 0x10(%rcx), %rdx
testq %rcx, %rcx
cmoveq %r15, %rdx
movq %rax, (%rdx)
testq %rax, %rax
je 0x6185
movq %rcx, 0x18(%rax)
movq (%rbx), %rax
andq $0x0, 0x48(%rax)
movq (%rbx), %rsi
movq 0x8(%rbx), %rax
movq (%rax), %rax
movq (%rax), %rdi
callq 0x66cf
movq 0x8(%rbx), %rax
movq (%rax), %rax
decq 0x30(%rax)
cmpq $0x0, (%r15)
jne 0x61bf
cmpq $0x0, 0x20(%r14)
jne 0x61bf
movq %r14, %rdi
callq 0x657d
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2040
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x625d
callq 0xac0b
andq $0x0, 0x18(%rbx)
movq %rbx, %rdi
callq 0x61f0
testl %eax, %eax
jne 0x62a2
cmpl $0x0, 0x20(%rbx)
jne 0x6276
cmpq $0x0, 0x30(%rbx)
je 0x6292
callq 0x9d7c
testl %eax, %eax
je 0x625d
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x62c8
leaq 0xb00a(%rip), %rdi      # 0x1129a
jmp 0x62b3
cmpq $0x0, 0x28(%rbx)
jne 0x62e4
movq %rbx, %rdi
popq %rbx
jmp 0x2040
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x62bc
leaq 0xb90d(%rip), %rdi      # 0x11bc0
xorl %eax, %eax
callq 0xe0e4
jmp 0x62dc
movq %rax, %rbx
leaq 0xb8fa(%rip), %rdi      # 0x11bc0
jmp 0x62d2
movq %rax, %rbx
leaq 0xafc8(%rip), %rdi      # 0x1129a
xorl %eax, %eax
callq 0xdf55
andl $0x0, (%rbx)
pushq $0x1
popq %rdi
callq 0x2370
leaq 0xb8f7(%rip), %rdi      # 0x11be2
leaq 0xb900(%rip), %rsi      # 0x11bf2
leaq 0xb90a(%rip), %rcx      # 0x11c03
movl $0x253, %edx            # imm = 0x253
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/kvlds/btree_cleaning.c
// Function: poke
static int
poke(struct cleaner * C)
{
	struct cleaning_group * CG;

	/*
	 * If we're trying to find a group to clean, we need to wait until
	 * that is done before we can look for another group.
	 */
	if (C->group_pending)
		goto done;

	/*
	 * If we're using more than 1/16 of our memory to hold pages which
	 * are being cleaned, stop there; that's plenty.
	 */
	if (C->pending_cleans > C->T->poolsz / 16)
		goto done;

	/*
	 * If the number of nodes we have waiting to be fetched or dirtied
	 * is more than the cleaning debt, we don't need to look for any more
	 * pages to clean yet.
	 */
	if ((double)C->pending_cleans >= C->cleandebt)
		goto done;

	/* We're going to launch a group of node cleans. */
	if ((CG = malloc(sizeof(struct cleaning_group))) == NULL)
		goto err0;
	CG->C = C;
	CG->head = NULL;
	CG->pending_fetches = 1;
	C->group_pending = 1;

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

	/* Find the right group to clean. */
	if (btree_node_descend(C->T, C->T->root_shadow, callback_find, CG))
		goto err1;

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

err1:
	C->head = CG->next;
	C->group_pending = 0;
	free(CG);
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
xorl %ebx, %ebx
cmpl $0x0, 0x20(%rdi)
jne 0x63b8
movq %rdi, %r14
movq (%rdi), %r15
movq 0x30(%rdi), %rax
movq 0x8(%r15), %rcx
shrq $0x4, %rcx
cmpq %rcx, %rax
ja 0x63b8
cvtsi2sd %rax, %xmm0
ucomisd 0x10(%r14), %xmm0
jae 0x63b8
pushq $0x28
popq %rdi
callq 0x22a0
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0x63b6
movq %rax, %r12
movq %r14, (%rax)
andq $0x0, 0x8(%rax)
movq $0x1, 0x20(%rax)
movl $0x1, 0x20(%r14)
movq 0x28(%r14), %rax
movq %rax, 0x10(%r12)
andq $0x0, 0x18(%r12)
movq %r12, 0x28(%r14)
testq %rax, %rax
je 0x6386
movq %r12, 0x18(%rax)
movq 0x20(%r15), %rsi
leaq 0x32(%rip), %rdx        # 0x63c3
movq %r15, %rdi
movq %r12, %rcx
callq 0x7e08
testl %eax, %eax
je 0x63b8
movq 0x10(%r12), %rax
movq %rax, 0x28(%r14)
andl $0x0, 0x20(%r14)
movq %r12, %rdi
callq 0x2040
movl %ebp, %ebx
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x65b8
cmpq $0x0, 0x20(%rdi)
jne 0x65d1
movq (%rdi), %rdx
movq 0x10(%rdi), %rax
movq 0x18(%rdi), %rcx
addq $0x28, %rdx
leaq 0x10(%rcx), %rsi
testq %rcx, %rcx
cmoveq %rdx, %rsi
movq %rax, (%rsi)
testq %rax, %rax
je 0x65b2
movq %rcx, 0x18(%rax)
popq %rax
jmp 0x2040
leaq 0xb6e4(%rip), %rdi      # 0x11ca3
leaq 0xb62c(%rip), %rsi      # 0x11bf2
leaq 0xb6e7(%rip), %rcx      # 0x11cb4
pushq $0x4d
jmp 0x65e8
leaq 0xb702(%rip), %rdi      # 0x11cda
leaq 0xb613(%rip), %rsi      # 0x11bf2
leaq 0xb6ce(%rip), %rcx      # 0x11cb4
pushq $0x4e
popq %rdx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O2/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 %r14
pushq %rbx
pushq %rax
movb 0x1c(%rsi), %al
andb $0x3, %al
cmpb $0x1, %al
jne 0x666e
movq %rsi, %rbx
movq %rdi, %r14
decq 0x20(%rdi)
testb $0xc, 0x1c(%rsi)
je 0x661f
movq (%r14), %rax
decq 0x30(%rax)
movq (%rax), %rdi
movq %rbx, %rsi
callq 0x66cf
jmp 0x6651
pushq $0x20
popq %rdi
callq 0x22a0
testq %rax, %rax
je 0x665b
movq %rbx, (%rax)
movq %r14, 0x8(%rax)
movq 0x8(%r14), %rcx
movq %rcx, 0x10(%rax)
andq $0x0, 0x18(%rax)
movq %rax, 0x8(%r14)
testq %rcx, %rcx
je 0x664d
movq %rax, 0x18(%rcx)
movq %rax, 0x48(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq (%r14), %rax
movq (%rax), %rdi
movq %rbx, %rsi
callq 0x66cf
pushq $-0x1
popq %rax
jmp 0x6653
leaq 0xb67e(%rip), %rdi      # 0x11cf3
leaq 0xb576(%rip), %rsi      # 0x11bf2
leaq 0xb68a(%rip), %rcx      # 0x11d0d
movl $0x83, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O2/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:
pushq $-0x1
popq %rax
testq %rdi, %rdi
je 0x66ce
orq $-0x1, 0x10(%rdi)
movq 0x38(%rdi), %rcx
incq %rcx
movq %rax, %rsi
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x66c8
movq 0x48(%rdi), %r8
movq (%r8,%rdx,8), %r8
movq 0x10(%r8), %r8
cmpq %rsi, %r8
jae 0x66c3
movq %r8, 0x10(%rdi)
movq %r8, %rsi
incq %rdx
jmp 0x66a6
movq 0x20(%rdi), %rdi
jmp 0x6690
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x6771
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
testb $0x3, %al
je 0x6772
testq %r15, %r15
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
je 0x6758
xorl %eax, %eax
jmp 0x6763
movq %r15, %rdi
movq %r14, %rsi
callq 0xe34c
movb %al, 0x1e(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %r12d, %r12d
movq 0x38(%rbx), %rax
cmpq %rax, %r12
ja 0x6744
movq %r15, %rsi
testq %r12, %r12
je 0x678f
movq 0x40(%rbx), %rcx
movq -0x8(%rcx,%r12,8), %rsi
movq %r14, %rdx
cmpq %rax, %r12
jae 0x679f
movq 0x40(%rbx), %rax
movq (%rax,%r12,8), %rdx
movq 0x48(%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x6722
incq %r12
jmp 0x6775
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/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, %r15
movq %rsi, %r13
movq %rdi, %r12
andq $0x0, 0x10(%rsp)
pushq $0x18
popq %rdi
callq 0x22a0
pushq $-0x1
popq %rbx
testq %rax, %rax
je 0x6868
movq %rax, %r14
movq %r12, 0x10(%rax)
movq %r13, (%rax)
movq %r15, 0x8(%rax)
movq 0x28(%r12), %rbp
movq %rbp, %rdi
callq 0x6934
movq %rax, %r13
testq %rax, %rax
je 0x681e
movq %r13, %rax
shrq $0x3d, %rax
je 0x6823
callq 0x20a0
movl $0xc, (%rax)
jmp 0x6860
xorl %r15d, %r15d
jmp 0x6838
leaq (,%r13,8), %rdi
callq 0x22a0
movq %rax, %r15
testq %rax, %rax
je 0x6860
movq (%r12), %rdx
movq 0x10(%r12), %rcx
leaq 0x10(%rsp), %r9
movq %r12, %rdi
movq %rbp, %rsi
movq %r15, %r8
callq 0x6987
testl %eax, %eax
je 0x6879
movq %r15, %rdi
callq 0x2040
movq %r14, %rdi
callq 0x2040
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq %r13, 0x10(%rsp)
jne 0x68f6
movq %r13, %rax
shrq $0x20, %rax
jne 0x6915
movq 0x18(%r12), %rdi
movq (%r12), %rcx
movq 0x10(%r12), %rdx
movq %r14, (%rsp)
leaq 0x1c5(%rip), %r9        # 0x6a6b
movl %r13d, %esi
movq %r15, %r8
callq 0xf3d1
testl %eax, %eax
je 0x68d7
callq 0x20a0
cmpl $0x0, (%rax)
je 0x68e3
movq %rax, %r12
leaq 0xb4d5(%rip), %rdi      # 0x11d9e
xorl %eax, %eax
callq 0xdf55
andl $0x0, (%r12)
jmp 0x6858
movq %r15, %rdi
callq 0x2040
xorl %ebx, %ebx
jmp 0x6868
leaq 0xb4b4(%rip), %rdi      # 0x11d9e
xorl %eax, %eax
callq 0xe0e4
jmp 0x6858
leaq 0xb43a(%rip), %rdi      # 0x11d37
leaq 0xb440(%rip), %rsi      # 0x11d44
leaq 0xb446(%rip), %rcx      # 0x11d51
movl $0xe1, %edx
callq 0x21c0
leaq 0xb46d(%rip), %rdi      # 0x11d89
leaq 0xb421(%rip), %rsi      # 0x11d44
leaq 0xb427(%rip), %rcx      # 0x11d51
movl $0xe2, %edx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O2/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 0x6952
testb $0x3, %al
je 0x6963
pushq $0x1
popq %rbx
jmp 0x6954
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x38(%rdi), %r14
movq 0x48(%rdi), %r15
pushq $0x1
popq %rbx
xorl %r12d, %r12d
cmpq %r14, %r12
ja 0x6954
movq (%r15,%r12,8), %rdi
callq 0x6934
addq %rax, %rbx
incq %r12
jmp 0x6971
// File: /workspace/github_c_makefile_star2_O2/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
movb 0x1c(%rsi), %al
movl %eax, %ecx
andb $0xc, %cl
xorl %ebx, %ebx
cmpb $0x8, %cl
jne 0x6a2f
movq %r9, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r13
pushq $-0x1
popq %rbx
testb $0x3, %al
jne 0x69f7
xorl %ebx, %ebx
cmpq 0x38(%r15), %rbx
ja 0x69f0
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 0x6987
incq %rbx
testl %eax, %eax
je 0x69c1
pushq $-0x1
popq %rbx
jmp 0x6a2f
movb 0x1c(%r15), %al
pushq $-0x1
popq %rbx
addq (%r14), %rbp
movq %rbp, (%r15)
movq %rbp, 0x8(%r15)
testb $0x3, %al
je 0x6a40
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x8b60
testl %eax, %eax
jne 0x6a2f
movq 0x50(%r15), %rax
movq (%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
movq (%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x38(%r15), %rax
movq 0x48(%r15), %rcx
incq %rax
xorl %edx, %edx
cmpq %rdx, %rax
je 0x6a05
movq (%rcx,%rdx,8), %rsi
movq 0x8(%rsi), %rsi
cmpq %rbp, %rsi
jae 0x6a66
movq %rsi, 0x8(%r15)
movq %rsi, %rbp
incq %rdx
jmp 0x6a4d
// File: /workspace/github_c_makefile_star2_O2/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 0x6a97
callq 0x20a0
cmpl $0x0, (%rax)
je 0x6ab3
movq %rax, %r14
leaq 0xb328(%rip), %rdi      # 0x11db2
xorl %eax, %eax
callq 0xdf55
andl $0x0, (%r14)
jmp 0x6ac1
testl %edx, %edx
je 0x6ad4
leaq 0xb32a(%rip), %rdi      # 0x11dcc
xorl %eax, %eax
callq 0xe0e4
callq 0x20a0
andl $0x0, (%rax)
jmp 0x6ac1
leaq 0xb2f8(%rip), %rdi      # 0x11db2
xorl %eax, %eax
callq 0xe0e4
movq %rbx, %rdi
callq 0x2040
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x10(%rbx), %rdi
movq %rcx, 0x10(%rdi)
movq 0x28(%rdi), %rsi
callq 0x6b03
leaq 0xe0(%rip), %rdi        # 0x6bcc
pushq $0x1
popq %rdx
movq %rbx, %rsi
callq 0x9f40
movq %rax, %rcx
xorl %eax, %eax
testq %rcx, %rcx
jne 0x6acc
jmp 0x6ac1
// File: /workspace/github_c_makefile_star2_O2/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 0x6b27
cmpl $0x1, %ecx
je 0x6baf
popq %rbx
popq %r14
popq %r15
retq
movq %rsi, %r14
movq %rdi, %rbx
testb $0x3, %al
jne 0x6b53
xorl %r15d, %r15d
cmpq 0x38(%r14), %r15
ja 0x6b4f
movq 0x48(%r14), %rax
movq (%rax,%r15,8), %rsi
movq %rbx, %rdi
callq 0x6b03
incq %r15
jmp 0x6b34
movb 0x1c(%r14), %al
movq (%r14), %rcx
movq %rcx, 0x10(%r14)
testb $0x3, %al
je 0x6b84
andb $-0xd, %al
movb %al, 0x1c(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6c47
movq 0x28(%r14), %rsi
movq %rsi, 0x20(%r14)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x6c8d
movq 0x38(%r14), %rdx
movq 0x48(%r14), %rsi
incq %rdx
xorl %edi, %edi
cmpq %rdi, %rdx
je 0x6b5e
movq (%rsi,%rdi,8), %r8
movq 0x10(%r8), %r8
cmpq %rcx, %r8
jae 0x6baa
movq %r8, 0x10(%r14)
movq %r8, %rcx
incq %rdi
jmp 0x6b91
leaq 0xb243(%rip), %rdi      # 0x11df9
leaq 0xb187(%rip), %rsi      # 0x11d44
leaq 0xb253(%rip), %rcx      # 0x11e17
pushq $0x68
popq %rdx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O2/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 0x6ce3
cmpl $0x2, %ecx
je 0x6d4b
testb $0x3, %al
je 0x6d17
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x7921
andb $0x3, %al
cmpb $0x2, %al
jne 0x6cf3
movq 0x28(%r14), %rax
movq %rax, 0x20(%r14)
jmp 0x6d11
movq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x6c47
movb 0x1c(%r14), %al
andb $0x3, %al
movq 0x28(%r14), %rsi
movq %rsi, 0x20(%r14)
cmpb $0x2, %al
jne 0x6d3e
popq %rbx
popq %r14
popq %r15
retq
xorl %r15d, %r15d
cmpq 0x38(%r14), %r15
ja 0x6cd3
movq 0x48(%r14), %rax
movq (%rax,%r15,8), %rsi
movq %rbx, %rdi
callq 0x6cb2
movq 0x48(%r14), %rax
andq $0x0, (%rax,%r15,8)
incq %r15
jmp 0x6d1a
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x6c8d
leaq 0xb0f3(%rip), %rdi      # 0x11e45
leaq 0xafeb(%rip), %rsi      # 0x11d44
leaq 0xb102(%rip), %rcx      # 0x11e62
movl $0x99, %edx
callq 0x21c0
nop
// File: /workspace/github_c_makefile_star2_O2/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 0x6de3
movq %rsi, %r14
movq %rdi, %rbx
movq 0x38(%rdi), %r12
xorl %r13d, %r13d
movq %r12, %rbp
subq %r13, %rbp
je 0x6dc9
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 0xe31c
testl %eax, %eax
js 0x6dc4
je 0x6dcd
incq %rbp
movq %rbp, %r13
jmp 0x6d8d
movq %rbp, %r12
jmp 0x6d8d
xorl %eax, %eax
jmp 0x6dd4
addq 0x40(%rbx), %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xaf09(%rip), %rdi      # 0x11cf3
leaq 0xb09e(%rip), %rsi      # 0x11e8f
leaq 0xb0a4(%rip), %rcx      # 0x11e9c
pushq $0x29
popq %rdx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O2/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 0x6e64
movq %rsi, %rbx
movq %rdi, %r14
movq 0x38(%rdi), %r12
xorl %r13d, %r13d
movq %r12, %r15
subq %r13, %r15
je 0x6e54
shrq %r15
addq %r13, %r15
movq 0x40(%r14), %rax
movq (%rax,%r15,8), %rsi
movzbl 0x1e(%r14), %edx
movq %rbx, %rdi
callq 0xe31c
testl %eax, %eax
js 0x6e4f
incq %r15
movq %r15, %r13
testl %eax, %eax
jne 0x6e1c
jmp 0x6e57
movq %r15, %r12
jmp 0x6e1c
movq %r12, %r15
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xb080(%rip), %rdi      # 0x11eeb
leaq 0xb01d(%rip), %rsi      # 0x11e8f
leaq 0xb08e(%rip), %rcx      # 0x11f07
pushq $0x55
popq %rdx
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O2/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, %r13
movq %rcx, %rbp
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r15
callq 0x6ef6
testq %rax, %rax
je 0x6ee0
movq %rax, %r14
movq %rbp, (%rax)
andq $0x0, 0x8(%rax)
movq %r13, 0x10(%rax)
movq %r15, 0x18(%rax)
movq %rbx, 0x20(%rax)
movq %r12, 0x28(%rax)
andl $0x0, 0x30(%rax)
andq $0x0, 0x38(%rax)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x6f54
movq %r14, %rdi
callq 0x6f79
testl %eax, %eax
je 0x6ee5
pushq $-0x1
popq %rax
jmp 0x6ee7
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/kvlds/btree_find.c
// Function: btree_find_range
int
btree_find_range(struct btree * T, struct node * N,
    const struct kvldskey * k, int h,
    int (* callback)(void *, struct node *, struct kvldskey *),
    void * cookie)
{
	struct findleaf_cookie * C;

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

	if ((C->e = kvldskey_create(NULL, 0)) == NULL)
		goto err1;

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

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

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %r15
movq %r8, %r13
movl %ecx, 0x4(%rsp)
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbp
callq 0x6ef6
testq %rax, %rax
je 0x713c
movq %rax, %rbx
andq $0x0, (%rax)
movq %r13, 0x8(%rax)
movq %r15, 0x10(%rax)
movq %rbp, 0x18(%rax)
movq %r12, 0x20(%rax)
movq %r14, 0x28(%rax)
movl 0x4(%rsp), %eax
movl %eax, 0x30(%rbx)
xorl %r14d, %r14d
xorl %edi, %edi
xorl %esi, %esi
callq 0xe268
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x7134
movq 0x18(%rbx), %rdi
movq 0x20(%rbx), %rsi
callq 0x6f54
movq %rbx, %rdi
callq 0x6f79
testl %eax, %eax
jne 0x713c
jmp 0x7140
movq %rbx, %rdi
callq 0x7152
pushq $-0x1
popq %r14
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x7329
andb $0xc, %al
cmpb $0x8, %al
jne 0x7342
movq %rdi, %rbx
cmpl $-0x1, 0x18(%rdi)
jne 0x735b
cmpq $0x0, 0x48(%rbx)
jne 0x7374
callq 0xe36c
movq %rax, 0x48(%rbx)
xorl %ecx, %ecx
cmpq $0x1, %rax
sbbl %ecx, %ecx
movl %ecx, %eax
popq %rbx
retq
leaq 0xa9c3(%rip), %rdi      # 0x11cf3
leaq 0xac38(%rip), %rsi      # 0x11f6f
leaq 0xac40(%rip), %rcx      # 0x11f7e
pushq $0x19
jmp 0x738b
leaq 0xac5d(%rip), %rdi      # 0x11fa6
leaq 0xac1f(%rip), %rsi      # 0x11f6f
leaq 0xac27(%rip), %rcx      # 0x11f7e
pushq $0x1a
jmp 0x738b
leaq 0xac61(%rip), %rdi      # 0x11fc3
leaq 0xac06(%rip), %rsi      # 0x11f6f
leaq 0xac0e(%rip), %rcx      # 0x11f7e
pushq $0x1b
jmp 0x738b
leaq 0xac66(%rip), %rdi      # 0x11fe1
leaq 0xabed(%rip), %rsi      # 0x11f6f
leaq 0xabf5(%rip), %rcx      # 0x11f7e
pushq $0x1c
popq %rdx
callq 0x21c0