// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/dispatch_nmr.c
// Function: callback_range_gotleaf
static int
callback_range_gotleaf(void * cookie, struct node * N)
{
	struct nmr_cookie * C = cookie;
	struct kvpair * kv;
	size_t i;

	/* Scan through the key-value pairs (maybe) copying them. */
	for (i = 0; i < N->nkeys; i++) {
		/* Is this key too small? */
		if (kvldskey_cmp(N->u.pairs[i].k, C->R->range_start) < 0)
			continue;

		/* Is this key too large? */
		if ((C->R->range_end->len > 0) &&
		    (kvldskey_cmp(N->u.pairs[i].k, C->R->range_end) > 0))
			continue;

		/* Does it fit? */
		C->rlen += kvldskey_serial_size(N->u.pairs[i].k);
		C->rlen += kvldskey_serial_size(N->u.pairs[i].v);
		if ((C->nkeys > 0) && (C->R->range_max < C->rlen))
			break;

		/* Add the pair to the heap. */
		if ((kv = malloc(sizeof(struct kvpair))) == NULL)
			goto err0;
		if ((kv->k = kvldskey_dup(N->u.pairs[i].k)) == NULL)
			goto err1;
		if ((kv->v = kvldskey_dup(N->u.pairs[i].v)) == NULL)
			goto err2;
		if (ptrheap_add(C->H, kv))
			goto err3;
		C->nkeys += 1;
	}

	/* If we exited early, adjust the end pointer. */
	if (i < N->nkeys) {
		kvldskey_free(C->end);
		if ((C->end = kvldskey_dup(N->u.pairs[i].k)) == NULL)
			goto err0;
	}

	/* Release the lock picked up by btree_node_descend. */
	btree_node_unlock(C->T, N);

	/* We've handled a leaf. */
	C->leavesleft -= 1;

	/* Are we done all the leaves? */
	if (C->leavesleft == 0) {
		if (rangedone(C))
			goto err0;
	}

	/* Success! */
	return (0);

err3:
	kvldskey_free(kv->v);
err2:
	kvldskey_free(kv->k);
err1:
	free(kv);
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 $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x6be4
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rax), %rsi
callq 0x18660
cmpl $0x0, %eax
jge 0x6a33
jmp 0x6bd3
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jle 0x6a78
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rsi
callq 0x18660
cmpl $0x0, %eax
jle 0x6a78
jmp 0x6bd3
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movzbl (%rax), %eax
movl %eax, %ecx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
addq 0x48(%rax), %rcx
movq %rcx, 0x48(%rax)
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movzbl (%rax), %eax
movl %eax, %ecx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
addq 0x48(%rax), %rcx
movq %rcx, 0x48(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jbe 0x6af4
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl 0xc(%rax), %eax
movq -0x20(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jae 0x6af4
jmp 0x6be4
movl $0x10, %edi
callq 0x22a0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x6b0d
jmp 0x6cb4
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
addq $0x1, %rdi
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movzbl (%rax), %eax
movl %eax, %esi
callq 0x18530
movq -0x28(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x6b59
jmp 0x6cab
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
addq $0x1, %rdi
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movzbl (%rax), %eax
movl %eax, %esi
callq 0x18530
movq -0x28(%rbp), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jne 0x6ba8
jmp 0x6c9f
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x10550
cmpl $0x0, %eax
je 0x6bc3
jmp 0x6c92
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x69f0
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x6c4b
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x2040
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
addq $0x1, %rdi
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movzbl (%rax), %eax
movl %eax, %esi
callq 0x18530
movq -0x20(%rbp), %rcx
movq %rax, 0x30(%rcx)
cmpq $0x0, %rax
jne 0x6c49
jmp 0x6cb4
jmp 0x6c4b
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x6910
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rcx
subq $0x1, %rcx
movq %rcx, 0x50(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jne 0x6c89
movq -0x20(%rbp), %rdi
callq 0x6cd0
cmpl $0x0, %eax
je 0x6c87
jmp 0x6cb4
jmp 0x6c89
movl $0x0, -0x4(%rbp)
jmp 0x6cbb
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2040
movq -0x28(%rbp), %rax
movq (%rax), %rdi
callq 0x2040
movq -0x28(%rbp), %rdi
callq 0x2040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)