LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/dispatch_mr.c
// Function: callback_gotleaf
static int
callback_gotleaf(void * cookie, struct node * N)
{
	struct req_cookie * req = cookie;
	struct batch * B = req->batch;

	/* Record the leaf node. */
	req->leaf = N;

	/* We've found a leaf. */
	B->leavestofind -= 1;

	/* If we've found all of them, move on to the next step. */
	if (B->leavestofind == 0) {
		if (!events_immediate_register(callback_gotleaves, B, 1))
			goto err0;
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rcx
subq $0x1, %rcx
movq %rcx, 0x30(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x56ea
movq -0x28(%rbp), %rsi
leaq -0x106(%rip), %rdi      # 0x55d0
movl $0x1, %edx
callq 0x111b0
cmpq $0x0, %rax
jne 0x56e8
jmp 0x56f3
jmp 0x56ea
movl $0x0, -0x4(%rbp)
jmp 0x56fa
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/dispatch_mr.c
// Function: compar_snp
static int
compar_snp(const void * _x, const void * _y)
{
	const struct nodepair * x = _x;
	const struct nodepair * y = _y;

	if (x->shadow < y->shadow)
		return (-1);
	else if (x->shadow == y->shadow)
		return (0);
	else
		return (1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x6285
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x62a5
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x629e
movl $0x0, -0x4(%rbp)
jmp 0x62a5
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/dispatch_mr.c
// Function: finddirty
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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x38(%rbp), %rdi
movl $0x10, %ecx
leaq -0x94(%rip), %r8        # 0x6250
callq 0x23a0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x6302
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x630a
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/../lib/datastruct/pool.h
// Function: pool_rec_unlock
static inline void
pool_rec_unlock(struct pool * P, void * rec)
{

	/* Make sure the lock count isn't already zero. */
	assert(get_pool_elem(P, rec)->wire_count > 0);

	/* Decrement the wire count. */
	get_pool_elem(P, rec)->wire_count -= 1;

	/* Add to the evictable queue if necessary. */
	if (get_pool_elem(P, rec)->wire_count == 0)
		pool_addqueue(P, rec);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq (%rax,%rcx), %rax
cmpq $0x0, (%rax)
jbe 0x6348
jmp 0x6367
leaq 0x18731(%rip), %rdi     # 0x1ea80
leaq 0x18750(%rip), %rsi     # 0x1eaa6
movl $0x88, %edx
leaq 0x1875d(%rip), %rcx     # 0x1eabf
callq 0x21d0
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq (%rax,%rcx), %rax
movq (%rax), %rcx
subq $0x1, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq (%rax,%rcx), %rax
cmpq $0x0, (%rax)
jne 0x63a4
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x191c0
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x130, 0x8(%rax)       # imm = 0x130
je 0x63e6
movq -0x18(%rbp), %rax
cmpl $0x131, 0x8(%rax)       # imm = 0x131
jne 0x63e8
jmp 0x6407
leaq 0x186fc(%rip), %rdi     # 0x1eaeb
leaq 0x18734(%rip), %rsi     # 0x1eb2a
movl $0x39, %edx
leaq 0x18737(%rip), %rcx     # 0x1eb39
callq 0x21d0
movl $0x58, %edi
callq 0x22a0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x6420
jmp 0x6503
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x3c(%rbp)
subl $0x130, %eax            # imm = 0x130
je 0x647a
jmp 0x646e
movl -0x3c(%rbp), %eax
subl $0x131, %eax            # imm = 0x131
je 0x64b3
jmp 0x64f1
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rax), %rsi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rax), %rdx
movq -0x38(%rbp), %r8
leaq 0x7b(%rip), %rcx        # 0x6520
callq 0xaeb0
cmpl $0x0, %eax
je 0x64b1
jmp 0x64fa
jmp 0x64f1
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rax), %rsi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rax), %rdx
movq -0x38(%rbp), %r9
movl $0x1, %ecx
leaq 0x15d(%rip), %r8        # 0x6640
callq 0xb270
cmpl $0x0, %eax
je 0x64ef
jmp 0x64fa
jmp 0x64f1
movl $0x0, -0x4(%rbp)
jmp 0x650a
movq -0x38(%rbp), %rdi
callq 0x2040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rax), %rsi
callq 0xacc0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x6583
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rsi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
xorl %edx, %edx
callq 0x19a00
cmpl $0x0, %eax
je 0x6581
jmp 0x65fb
jmp 0x65ad
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rsi
movl $0x1, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x19a00
cmpl $0x0, %eax
je 0x65ab
jmp 0x65fb
jmp 0x65ad
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
xorl %edx, %edx
callq 0x111b0
cmpq $0x0, %rax
jne 0x65cb
jmp 0x65fb
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x6910
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x19810
movq -0x20(%rbp), %rdi
callq 0x2040
movl $0x0, -0x4(%rbp)
jmp 0x6629
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x6910
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x19810
movq -0x20(%rbp), %rdi
callq 0x2040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/btree.c
// Function: callback_params
static int
callback_params(void * cookie, int failed, size_t blklen, uint64_t blkno,
    uint64_t lastblk)
{
	struct params_cookie * C = cookie;

	/* Record returned values. */
	C->T->pagelen = blklen;
	C->T->nextblk = blkno;
	C->lastblk = lastblk;

	/* We're done. */
	C->failed = failed;
	C->done = 1;

	/* Success! */
	return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rcx
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0xc(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x30(%rbp), %rax
movl $0x1, 0x14(%rax)
xorl %eax, %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0x1a5(%rip), %rdx       # 0x7c00
xorl %eax, %eax
movl %eax, %ecx
callq 0x1ab90
cmpl $0x0, %eax
je 0x7a6b
jmp 0x7a9b
movq -0x18(%rbp), %rsi
leaq -0x56(%rip), %rdi       # 0x7a20
leaq 0x173b3(%rip), %rdx     # 0x1ee30
callq 0x12560
movq -0x18(%rbp), %rcx
movq %rax, 0x38(%rcx)
cmpq $0x0, %rax
jne 0x7a92
jmp 0x7a9b
movl $0x0, -0x4(%rbp)
jmp 0x7aa2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jne 0x7ad0
jmp 0x7aef
leaq 0x172fa(%rip), %rdi     # 0x1edd1
leaq 0x1713c(%rip), %rsi     # 0x1ec1a
movl $0x1a0, %edx            # imm = 0x1A0
leaq 0x17307(%rip), %rcx     # 0x1edf1
callq 0x21d0
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x97a0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x7b14
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x127a0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x7b70
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x7b70
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0xc4a0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0xfb50
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x19170
movq -0x8(%rbp), %rdi
callq 0x2040
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/btree.c
// Function: callback_free_done
static int
callback_free_done(void * cookie, int failed)
{

	(void)cookie; /* UNUSED */

	/* Throw a fit if the FREE failed. */
	if (failed) {
		warn0("LBS FREE request failed");
		goto err0;
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x7c32
jmp 0x7c17
leaq 0x171f3(%rip), %rdi     # 0x1ee11
movb $0x0, %al
callq 0x182f0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x7c3b
movl $0x0, -0x4(%rbp)
jmp 0x7c42
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/btree_balance.c
// Function: btree_balance
int
btree_balance(struct btree * T, int (* callback)(void *), void * cookie)
{
	struct balance_cookie * B;

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

	/* Split nodes as necessary. */
	if (splittree(T))
		goto err1;

	/* Merge nodes as necessary and perform callback. */
	if (planmerge(B))
		goto err1;

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x20, %edi
callq 0x22a0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x7d0a
jmp 0x7d5f
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rdi
callq 0x7d70
cmpl $0x0, %eax
je 0x7d3d
jmp 0x7d56
movq -0x28(%rbp), %rdi
callq 0x7df0
cmpl $0x0, %eax
je 0x7d4d
jmp 0x7d56
movl $0x0, -0x4(%rbp)
jmp 0x7d66
movq -0x28(%rbp), %rdi
callq 0x2040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/btree_balance.c
// Function: splittree
static int
splittree(struct btree * T)
{
	struct node * R;

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

	/* First, split the children of the root. */
	if (splitchildren(T, T->root_dirty))
		goto err0;

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

	/* Next, split the root (if necessary). */
	while (serialize_size(T->root_dirty) > T->pagelen) {
		/* Try to create a new root. */
		if ((R = splitroot(T, T->root_dirty)) == NULL)
			goto err0;

		/* This is now the dirty root. */
		T->root_dirty = R;
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x7e70
cmpl $0x0, %eax
je 0x7d94
jmp 0x7de0
jmp 0x7d96
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0xecb0
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jbe 0x7dd7
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x82f0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x7dc9
jmp 0x7de0
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0x7d96
movl $0x0, -0x4(%rbp)
jmp 0x7de7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/btree_balance.c
// Function: planmerge
static int
planmerge(struct balance_cookie * B)
{
	struct btree * T = B->T;

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

	/* We're not fetching any nodes yet. */
	B->nmergefetch = 0;

	/*
	 * Figure out what merging (if any) needs to be done, and fetch pages
	 * (if any) required in order to do it.
	 */
	if (planmergenode(B, T->root_dirty))
		goto err0;

	/* If we don't need to fetch any nodes, call into domerge next. */
	if (B->nmergefetch == 0) {
		if (!events_immediate_register(domerge, B, 1))
			goto err0;
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x87d0
cmpl $0x0, %eax
je 0x7e2c
jmp 0x7e5f
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x7e56
movq -0x10(%rbp), %rsi
leaq 0xc9e(%rip), %rdi       # 0x8ae0
movl $0x1, %edx
callq 0x111b0
cmpq $0x0, %rax
jne 0x7e54
jmp 0x7e5f
jmp 0x7e56
movl $0x0, -0x4(%rbp)
jmp 0x7e66
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x8b0d
jmp 0x8b2c
leaq 0x1643d(%rip), %rdi     # 0x1ef51
leaq 0x1633a(%rip), %rsi     # 0x1ee55
movl $0x27e, %edx            # imm = 0x27E
leaq 0x1643e(%rip), %rcx     # 0x1ef65
callq 0x21d0
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x8c30
cmpl $0x0, %eax
je 0x8b44
jmp 0x8ba7
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movb 0x1c(%rax), %al
shrb $0x6, %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x8b6e
movq -0x18(%rbp), %rdi
callq 0x7df0
cmpl $0x0, %eax
je 0x8b6c
jmp 0x8ba7
jmp 0x8b9e
movq -0x18(%rbp), %rdi
callq 0x9060
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
xorl %edx, %edx
callq 0x111b0
cmpq $0x0, %rax
jne 0x8b95
jmp 0x8ba7
movq -0x18(%rbp), %rdi
callq 0x2040
movl $0x0, -0x4(%rbp)
jmp 0x8bae
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/btree_balance.c
// Function: merge_fetch
static int
merge_fetch(void * cookie)
{
	struct balance_cookie * B = cookie;

	/* One fetch done, N-1 left to go. */
	B->nmergefetch -= 1;

	/* Call domerge if we've got everything. */
	if (B->nmergefetch == 0) {
		if (!events_immediate_register(domerge, B, 1))
			goto err0;
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rcx
subq $0x1, %rcx
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x8c0e
movq -0x18(%rbp), %rsi
leaq -0x11a(%rip), %rdi      # 0x8ae0
movl $0x1, %edx
callq 0x111b0
cmpq $0x0, %rax
jne 0x8c0c
jmp 0x8c17
jmp 0x8c0e
movl $0x0, -0x4(%rbp)
jmp 0x8c1e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/btree_balance.c
// Function: deroot
static void
deroot(struct balance_cookie * B)
{
	struct btree * T = B->T;
	struct node * R;

	/* Repeat until the root is a leaf or has 2+ children. */
	while ((T->root_dirty->type == NODE_TYPE_PARENT) &&
	    (T->root_dirty->nkeys == 0)) {
		/* Grab a pointer to the root node. */
		R = T->root_dirty;

		/* Promote its child to roothood. */
		T->root_dirty = R->v.children[0];
		T->root_dirty->root = 1;
		T->root_dirty->pagesize = (uint32_t)(-1);
		btree_node_lock(T, T->root_dirty);
		T->root_dirty->p_dirty = NULL;

		/* The old root is no longer a root. */
		R->root = 0;
		btree_node_unlock(T, R);

		/* The old root no longer has a child. */
		R->v.children[0] = NULL;
		btree_node_unlock(T, R);

		/* Free the old root node. */
		btree_node_destroy(T, R);
		T->nnodes--;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movb 0x1c(%rax), %al
andb $0x3, %al
movzbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x19(%rbp)
jne 0x90a5
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
cmpq $0x0, 0x38(%rax)
sete %al
movb %al, -0x19(%rbp)
movb -0x19(%rbp), %al
testb $0x1, %al
jne 0x90b1
jmp 0x916f
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movb 0x1c(%rax), %cl
andb $-0x11, %cl
orb $0x10, %cl
movb %cl, 0x1c(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl $0xffffffff, 0x18(%rax) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x8650
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq $0x0, 0x28(%rax)
movq -0x18(%rbp), %rax
movb 0x1c(%rax), %cl
andb $-0x11, %cl
orb $0x0, %cl
movb %cl, 0x1c(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x86e0
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x86e0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xc2e0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x48(%rax)
jmp 0x9078
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movl $0x38, %edi
callq 0x22a0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x91aa
jmp 0x92b1
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x20(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %xmm0
movaps 0x14e49(%rip), %xmm1    # 0x1e030
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x14e4d(%rip), %xmm1    # 0x1e040
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x15d7e(%rip), %xmm1    # 0x1ef88
divsd %xmm1, %xmm0
movsd 0x15d6a(%rip), %xmm1    # 0x1ef80
mulsd %xmm1, %xmm0
mulsd -0x18(%rbp), %xmm0
movsd 0x15449(%rip), %xmm1    # 0x1e670
mulsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rax)
movq -0x20(%rbp), %rsi
leaq 0x85(%rip), %rdi        # 0x92d0
leaq 0x15d3e(%rip), %rdx     # 0x1ef90
callq 0x12560
movq -0x20(%rbp), %rcx
movq %rax, 0x18(%rcx)
cmpq $0x0, %rax
jne 0x929e
jmp 0x9267
callq 0x20a0
cmpl $0x0, (%rax)
je 0x928c
leaq 0x154d8(%rip), %rdi     # 0x1e750
movb $0x0, %al
callq 0x180a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x929a
leaq 0x154bd(%rip), %rdi     # 0x1e750
movb $0x0, %al
callq 0x182f0
jmp 0x929c
jmp 0x92a8
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x92b9
movq -0x20(%rbp), %rdi
callq 0x2040
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rdx
movq (%rdx), %rdx
subq %rdx, %rcx
movq %rcx, %xmm1
movaps 0x14b07(%rip), %xmm3    # 0x1e030
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x14b0b(%rip), %xmm2    # 0x1e040
subpd %xmm2, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq 0x50(%rax), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
divsd %xmm0, %xmm1
movq -0x8(%rbp), %rax
movsd 0x10(%rax), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rax)
movq -0x10(%rbp), %rax
movb 0x1c(%rax), %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x95af
movq -0x10(%rbp), %rax
movb 0x1c(%rax), %al
shrb $0x2, %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x95af
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x95af
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x95c0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/btree_cleaning.c
// Function: free_cstate
static void
free_cstate(struct cleaning * C)
{
	struct cleaning_group * CG = C->G;

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

	/* Mark the node as no longer being cleaned. */
	C->N->v.cstate = NULL;

	/* Release node lock held by the cleaner. */
	btree_node_unlock(C->G->C->T, C->N);

	/* This node is no longer pending cleaning. */
	C->G->C->pending_cleans--;

	/* Kill the group if it is now empty. */
	if ((CG->head == NULL) && (CG->pending_fetches == 0))
		free_cg(CG);

	/* Free the node-cleaning state. */
	free(C);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x95f9
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x10(%rax)
jmp 0x9609
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x9628
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0x48(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
callq 0xa010
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x30(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x9687
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x9687
movq -0x10(%rbp), %rdi
callq 0x9d60
movq -0x8(%rbp), %rdi
callq 0x2040
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/btree_cleaning.c
// Function: btree_cleaning_possible
int
btree_cleaning_possible(struct cleaner * C)
{
	struct cleaning_group * G;

	/* Scan through the list of groups. */
	for (G = C->head; G != NULL; G = G->next) {
		/* Is this group ready for cleaning? */
		if (G->pending_fetches == 0)
			return (1);
	}

	/* No groups are ready for cleaning. */
	return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x96df
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x96cf
movl $0x1, -0x4(%rbp)
jmp 0x96e6
jmp 0x96d1
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x96b4
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x977a
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x9728
jmp 0x9770
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x976e
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
callq 0xc5a0
cmpq $0x0, %rax
jne 0x9762
jmp 0x9783
jmp 0x9764
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x9734
jmp 0x9770
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x9708
movl $0x0, -0x4(%rbp)
jmp 0x978a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x97d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x127a0
movq -0x8(%rbp), %rax
movq $0x0, 0x18(%rax)
jmp 0x97d2
movq -0x8(%rbp), %rdi
callq 0x96f0
cmpl $0x0, %eax
je 0x9821
jmp 0x97e2
callq 0x20a0
cmpl $0x0, (%rax)
je 0x9807
leaq 0x157ad(%rip), %rdi     # 0x1efa0
movb $0x0, %al
callq 0x180a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x9815
leaq 0x15792(%rip), %rdi     # 0x1efa0
movb $0x0, %al
callq 0x182f0
jmp 0x9817
movl $0x1, %edi
callq 0x2380
movq -0x8(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jne 0x9838
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x9838
jmp 0x9891
callq 0x10c70
cmpl $0x0, %eax
je 0x9883
jmp 0x9844
callq 0x20a0
cmpl $0x0, (%rax)
je 0x9869
leaq 0x14bfc(%rip), %rdi     # 0x1e451
movb $0x0, %al
callq 0x180a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x9877
leaq 0x14be1(%rip), %rdi     # 0x1e451
movb $0x0, %al
callq 0x182f0
jmp 0x9879
movl $0x1, %edi
callq 0x2380
jmp 0x9885
movb $0x1, %al
testb $0x1, %al
jne 0x97d2
jmp 0x9891
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x989e
jmp 0x98bd
leaq 0x1571d(%rip), %rdi     # 0x1efc2
leaq 0x15726(%rip), %rsi     # 0x1efd2
movl $0x253, %edx            # imm = 0x253
leaq 0x1572b(%rip), %rcx     # 0x1efe3
callq 0x21d0
movq -0x8(%rbp), %rdi
callq 0x2040
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x9d84
jmp 0x9da3
leaq 0x152f8(%rip), %rdi     # 0x1f083
leaq 0x15240(%rip), %rsi     # 0x1efd2
movl $0x4d, %edx
leaq 0x152f6(%rip), %rcx     # 0x1f094
callq 0x21d0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x9db0
jmp 0x9dcf
leaq 0x15303(%rip), %rdi     # 0x1f0ba
leaq 0x15214(%rip), %rsi     # 0x1efd2
movl $0x4e, %edx
leaq 0x152ca(%rip), %rcx     # 0x1f094
callq 0x21d0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x9df0
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x10(%rax)
jmp 0x9e00
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x9e1f
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
callq 0x2040
addq $0x10, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movb 0x1c(%rax), %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x9e5b
jmp 0x9e7a
leaq 0x15271(%rip), %rdi     # 0x1f0d3
leaq 0x15169(%rip), %rsi     # 0x1efd2
movl $0x83, %edx
leaq 0x15278(%rip), %rcx     # 0x1f0ed
callq 0x21d0
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
movb 0x1c(%rax), %al
shrb $0x2, %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x9ec6
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x30(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0xa010
jmp 0x9f42
movl $0x20, %edi
callq 0x22a0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x9edc
jmp 0x9f4b
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x9f36
movq -0x28(%rbp), %rcx
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x48(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x9f65
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0xa010
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x9f85
jmp 0x9ffe
movq -0x8(%rbp), %rax
movq $-0x1, 0x10(%rax)
movq $0x0, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x38(%rcx), %rax
ja 0x9ff1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x9fe1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x9fe3
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x9f99
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x9f70
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movb 0x1c(%rax), %al
shrb $0x2, %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x2, %eax
je 0xa12d
jmp 0xa21f
movq -0x8(%rbp), %rax
movb 0x1c(%rax), %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xa1f1
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x38(%rcx), %rax
ja 0xa1ef
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xa181
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0xa199
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0xa1c5
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
jmp 0xa1cd
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rsi
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rdx
callq 0xa100
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xa14a
jmp 0xa1f1
cmpq $0x0, -0x10(%rbp)
je 0xa1ff
cmpq $0x0, -0x18(%rbp)
jne 0xa209
movq -0x8(%rbp), %rax
movb $0x0, 0x1e(%rax)
jmp 0xa21f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x18730
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, 0x1e(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movb 0x1c(%rax), %al
shrb $0x2, %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x2, %eax
je 0xa41a
movq $0x0, -0x8(%rbp)
jmp 0xa486
movq -0x10(%rbp), %rax
movb 0x1c(%rax), %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0xa435
movq $0x1, -0x8(%rbp)
jmp 0xa486
movq $0x1, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x38(%rcx), %rax
ja 0xa47e
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa3f0
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xa445
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xa739
jmp 0xa702
callq 0x20a0
cmpl $0x0, (%rax)
je 0xa727
leaq 0x14a7f(%rip), %rdi     # 0x1f192
movb $0x0, %al
callq 0x180a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0xa735
leaq 0x14a64(%rip), %rdi     # 0x1f192
movb $0x0, %al
callq 0x182f0
jmp 0xa737
jmp 0xa79f
cmpl $0x0, -0x18(%rbp)
je 0xa75c
jmp 0xa741
leaq 0x14a64(%rip), %rdi     # 0x1f1ac
movb $0x0, %al
callq 0x182f0
callq 0x20a0
movl $0x0, (%rax)
jmp 0xa79f
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0xa7c0
movq -0x28(%rbp), %rsi
leaq 0x1bc(%rip), %rdi       # 0xa940
movl $0x1, %edx
callq 0x111b0
cmpq $0x0, %rax
jne 0xa796
jmp 0xa79f
movl $0x0, -0x4(%rbp)
jmp 0xa7af
movq -0x28(%rbp), %rdi
callq 0x2040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)