// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x38(%rsi)
je 0x5777
xorl %r13d, %r13d
xorl %r12d, %r12d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq 0x40(%r14), %rax
movq (%rax,%r13), %rdi
movq 0x18(%rbx), %rax
movq 0x10(%rax), %rsi
callq 0x10342
testl %eax, %eax
js 0x5764
movq 0x18(%rbx), %rax
movq 0x18(%rax), %rsi
cmpb $0x0, (%rsi)
je 0x56ac
movq 0x40(%r14), %rax
movq (%rax,%r13), %rdi
callq 0x10342
testl %eax, %eax
jg 0x5764
movq 0x40(%r14), %rax
movq (%rax,%r13), %rax
movzbl (%rax), %eax
movq 0x48(%rbx), %rcx
leaq (%rax,%rcx), %rdx
leaq 0x1(%rax,%rcx), %rax
movq %rax, 0x48(%rbx)
movq 0x40(%r14), %rax
movq 0x8(%rax,%r13), %rax
movzbl (%rax), %eax
addq %rdx, %rax
addq $0x2, %rax
movq %rax, 0x48(%rbx)
cmpq $0x0, 0x40(%rbx)
je 0x56f6
movq 0x18(%rbx), %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
ja 0x577a
movl $0x10, %edi
callq 0x22a0
testq %rax, %rax
je 0x5814
movq %rax, %r15
movq 0x40(%r14), %rax
movq (%rax,%r13), %rdi
movzbl (%rdi), %esi
incq %rdi
callq 0x1028c
movq %rax, (%r15)
testq %rax, %rax
je 0x582f
movq 0x40(%r14), %rax
movq 0x8(%rax,%r13), %rdi
movzbl (%rdi), %esi
incq %rdi
callq 0x1028c
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0x5827
movq 0x28(%rbx), %rdi
movq %r15, %rsi
callq 0xb26d
testl %eax, %eax
jne 0x581e
incq 0x40(%rbx)
incq %r12
addq $0x10, %r13
cmpq 0x38(%r14), %r12
jb 0x566d
jmp 0x577a
xorl %r12d, %r12d
cmpq 0x38(%r14), %r12
jae 0x57a9
movq 0x30(%rbx), %rdi
callq 0x2040
movq 0x40(%r14), %rax
shlq $0x4, %r12
movq (%rax,%r12), %rdi
movzbl (%rdi), %esi
incq %rdi
callq 0x1028c
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0x5814
testq %r14, %r14
je 0x57da
movq 0x10(%rbx), %rax
movq 0x30(%rax), %rdi
movq 0x20(%rdi), %rax
movq (%r14,%rax), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x5a55
decq %rcx
movq %rcx, (%rax)
jne 0x57da
movq %r14, %rsi
callq 0x10885
xorl %ebp, %ebp
decq 0x50(%rbx)
jne 0x59a6
movq 0x18(%rbx), %rax
movq 0x30(%rbx), %rdi
cmpb $0x0, (%rdi)
movq 0x18(%rax), %r12
je 0x5843
cmpb $0x0, (%r12)
je 0x5837
movq %r12, %rsi
callq 0x10342
testl %eax, %eax
js 0x583c
movq 0x18(%rbx), %rax
addq $0x18, %rax
jmp 0x5840
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x59a6
movq 0x8(%r15), %rdi
callq 0x2040
movq (%r15), %rdi
callq 0x2040
movq %r15, %rbx
jmp 0x599e
movq %rdi, %r12
jmp 0x5843
leaq 0x30(%rbx), %rax
movq (%rax), %r12
movq 0x40(%rbx), %r13
testq %r13, %r13
je 0x5860
movq %r13, %rax
shrq $0x3d, %rax
je 0x5865
callq 0x20a0
movl $0xc, (%rax)
xorl %r14d, %r14d
jmp 0x5875
leaq (,%r13,8), %rdi
callq 0x22a0
movq %rax, %r14
testq %r13, %r13
setne %al
testq %r14, %r14
sete %cl
testb %cl, %al
jne 0x597e
testq %r13, %r13
je 0x58a2
movq %r13, %rax
shrq $0x3d, %rax
je 0x58a7
callq 0x20a0
movl $0xc, (%rax)
xorl %r15d, %r15d
jmp 0x58b7
leaq (,%r13,8), %rdi
callq 0x22a0
movq %rax, %r15
testq %r13, %r13
setne %al
testq %r15, %r15
sete %cl
testb %cl, %al
jne 0x5976
testq %r13, %r13
je 0x5914
xorl %ebp, %ebp
movq 0x28(%rbx), %rdi
callq 0xb373
testq %rax, %rax
je 0x5a36
movq %rax, %r13
movq 0x28(%rbx), %rdi
callq 0xb582
movq (%r13), %rax
movq %rax, (%r14,%rbp,8)
movq 0x8(%r13), %rax
movq %rax, (%r15,%rbp,8)
movq %r13, %rdi
callq 0x2040
incq %rbp
movq 0x40(%rbx), %r13
cmpq %r13, %rbp
jb 0x58d2
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rdi
movq (%rax), %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r14, %r8
movq %r15, %r9
callq 0x10e4a
movq 0x40(%rbx), %rcx
testl %eax, %eax
je 0x59b7
testq %rcx, %rcx
je 0x5952
xorl %r12d, %r12d
movq (%r15,%r12,8), %rdi
callq 0x2040
incq %r12
cmpq 0x40(%rbx), %r12
jb 0x5940
cmpq $0x0, 0x40(%rbx)
je 0x596e
xorl %r12d, %r12d
movq (%r14,%r12,8), %rdi
callq 0x2040
incq %r12
cmpq 0x40(%rbx), %r12
jb 0x595c
movq %r15, %rdi
callq 0x2040
movq %r14, %rdi
callq 0x2040
movq 0x28(%rbx), %rdi
callq 0xb5d8
movq 0x30(%rbx), %rdi
callq 0x2040
movq 0x18(%rbx), %rdi
callq 0x10bd2
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x2040
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rcx, %rcx
je 0x59d1
xorl %r12d, %r12d
movq (%r15,%r12,8), %rdi
callq 0x2040
incq %r12
cmpq 0x40(%rbx), %r12
jb 0x59bf
movq %r15, %rdi
callq 0x2040
cmpq $0x0, 0x40(%rbx)
je 0x59f5
xorl %r15d, %r15d
movq (%r14,%r15,8), %rdi
callq 0x2040
incq %r15
cmpq 0x40(%rbx), %r15
jb 0x59e3
movq %r14, %rdi
callq 0x2040
movq 0x28(%rbx), %rdi
callq 0xb5d8
movq 0x30(%rbx), %rdi
callq 0x2040
movq 0x18(%rbx), %rdi
callq 0x10bd2
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0xba4c
testq %rax, %rax
jne 0x599e
jmp 0x5999
leaq 0xed72(%rip), %rdi      # 0x147af
leaq 0xece6(%rip), %rsi      # 0x1472a
leaq 0xed6f(%rip), %rcx      # 0x147ba
movl $0x14e, %edx            # imm = 0x14E
callq 0x21c0
leaq 0xec24(%rip), %rdi      # 0x14680
leaq 0xec43(%rip), %rsi      # 0x146a6
leaq 0xec55(%rip), %rcx      # 0x146bf
movl $0x88, %edx
callq 0x21c0