// File: /workspace/github_c_makefile_star2_O3/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 0x8d38
movl %r8d, %r13d
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
andb $0x3, %al
cmpb $0x2, %al
jne 0x8cc7
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8b44
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x8d27
movq 0x20(%rbx), %rsi
testq %rsi, %rsi
je 0x8c18
movq 0x30(%r14), %rdi
movq 0x20(%rdi), %rax
movq (%rsi,%rax), %rax
movq (%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
testq %rcx, %rcx
jne 0x8c18
callq 0x1070f
movq 0x28(%rbx), %rsi
testq %rsi, %rsi
je 0x8c41
movq 0x30(%r14), %rdi
movq 0x20(%rdi), %rax
movq (%rsi,%rax), %rax
movq (%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
testq %rcx, %rcx
jne 0x8c41
callq 0x1070f
movl $0x20, %edi
callq 0x22a0
movq %rax, 0x40(%rbx)
testq %rax, %rax
je 0x8cad
movq (%r14), %rcx
movq %rcx, 0x10(%rax)
movq %r14, 0x8(%rax)
movl %r13d, 0x18(%rax)
movl $0x10, %esi
xorl %edi, %edi
callq 0xaba8
movq 0x40(%rbx), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x8ca4
movq (%r14), %rdx
movq 0x18(%r14), %rdi
movq (%rbx), %rsi
leaq 0x7d3(%rip), %rcx       # 0x945f
movq %rbx, %r8
callq 0x111f0
testl %eax, %eax
je 0x8cc3
movq 0x40(%rbx), %rax
movq (%rax), %rdi
callq 0xac50
movq 0x40(%rbx), %rdi
callq 0x2040
movq 0x30(%r14), %rdi
movq %rbx, %rsi
callq 0x10770
movq $0x0, 0x30(%rbx)
jmp 0x8d27
orb $0x3, 0x1c(%rbx)
testl %r13d, %r13d
jne 0x8cd7
movq 0x40(%rbx), %rax
movl $0x0, 0x18(%rax)
leaq 0x8(%rsp), %rsi
movq %r12, (%rsi)
movq %r15, 0x8(%rsi)
movq 0x40(%rbx), %rax
movq (%rax), %rdi
movl $0x1, %edx
movl $0x10, %ecx
callq 0xad17
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x8d27
movq 0x30(%r14), %rdi
movq 0x20(%rdi), %rax
movq (%rbx,%rax), %rax
movq (%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
xorl %ebp, %ebp
testq %rcx, %rcx
jne 0x8d27
movq %rbx, %rsi
callq 0x1070f
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc4a7(%rip), %rdi      # 0x151e6
leaq 0xc2db(%rip), %rsi      # 0x15021
leaq 0xc4d2(%rip), %rcx      # 0x1521f
movl $0xc8, %edx
callq 0x21c0