// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/kvlds/btree_node.c
// Function: btree_node_fetch_canfail
static int
btree_node_fetch_canfail(struct btree * T, struct node * N,
    int (* callback)(void *), void * cookie, int canfail)
{
	struct reader r;

	/* Sanity check. */
	assert((N->type == NODE_TYPE_NP) || (N->type == NODE_TYPE_READ));

	/* If we're not already reading, do so. */
	if (N->type == NODE_TYPE_NP) {
		/* Make this page present. */
		if (makepresent(T, N))
			goto err0;
		btree_node_lock(T, N->p_shadow);
		btree_node_lock(T, N->p_dirty);

		/* Create a read-in-progress structure. */
		if ((N->u.reading = malloc(sizeof(struct reading))) == NULL)
			goto err1;
		N->u.reading->pagelen = T->pagelen;
		N->u.reading->T = T;
		N->u.reading->canfail = canfail;

		/* Create a list of reader callbacks. */
		if ((N->u.reading->list = readerlist_init(0)) == NULL)
			goto err2;

		/* Read the page. */
		if (proto_lbs_request_get(T->LBS, N->pagenum, T->pagelen,
		    callback_fetch, N))
			goto err3;

		/* This page is now being read. */
		N->type = NODE_TYPE_READ;
	}

	/* If we can't fail, mark the read as such. */
	if (!canfail)
		N->u.reading->canfail = 0;

	/* Add our callback to the list. */
	r.callback = callback;
	r.cookie = cookie;
	if (readerlist_append(N->u.reading->list, &r, 1))
		goto err0;

	/* Add a lock for this callback. */
	btree_node_lock(T, N);

	/* Success! */
	return (0);

err3:
	readerlist_free(N->u.reading->list);
err2:
	free(N->u.reading);
err1:
	pool_rec_free(T->P, N);
	N->pool_cookie = NULL;
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movb 0x1c(%rsi), %al
testb $0x2, %al
je 0x78f9
movl %r8d, %r13d
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
andb $0x3, %al
pushq $-0x1
popq %rbp
cmpb $0x2, %al
jne 0x78ac
movq %r14, %rdi
movq %rbx, %rsi
callq 0x776e
testl %eax, %eax
jne 0x78e8
movq 0x20(%rbx), %rsi
movq %r14, %rdi
callq 0x7a99
movq 0x28(%rbx), %rsi
movq %r14, %rdi
callq 0x7a99
pushq $0x20
popq %rdi
callq 0x22a0
movq %rax, 0x40(%rbx)
testq %rax, %rax
je 0x7895
movq (%r14), %rcx
movq %rcx, 0x10(%rax)
movq %r14, 0x8(%rax)
movl %r13d, 0x18(%rax)
pushq $0x10
popq %rsi
xorl %edi, %edi
callq 0x9390
movq 0x40(%rbx), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x788c
movq (%r14), %rdx
movq 0x18(%r14), %rdi
movq (%rbx), %rsi
leaq 0x651(%rip), %rcx       # 0x7ec5
movq %rbx, %r8
callq 0xf1f0
testl %eax, %eax
je 0x78a8
movq 0x40(%rbx), %rax
movq (%rax), %rdi
callq 0x9427
movq 0x40(%rbx), %rdi
callq 0x2040
movq 0x30(%r14), %rdi
movq %rbx, %rsi
callq 0xe776
andq $0x0, 0x30(%rbx)
jmp 0x78e8
orb $0x3, 0x1c(%rbx)
testl %r13d, %r13d
jne 0x78b9
movq 0x40(%rbx), %rax
andl $0x0, 0x18(%rax)
leaq 0x8(%rsp), %rsi
movq %r12, (%rsi)
movq %r15, 0x8(%rsi)
movq 0x40(%rbx), %rax
movq (%rax), %rdi
pushq $0x1
popq %rdx
pushq $0x10
popq %rcx
callq 0x94ea
testl %eax, %eax
jne 0x78e8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7a99
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa906(%rip), %rdi      # 0x12206
leaq 0xa73a(%rip), %rsi      # 0x12041
leaq 0xa931(%rip), %rcx      # 0x1223f
movl $0xc8, %edx
callq 0x21c0