// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]kivaloo/liball/../lib/proto_kvlds/proto_kvlds_client.c
// Function: callback_range
static int
callback_range(void * cookie, uint8_t * buf, size_t buflen)
{
	struct range_cookie * C = cookie;
	int failed = 1;
	size_t bufpos = 0;
	size_t nkeys = 0;
	struct kvldskey * next = NULL;
	struct kvldskey ** keys = NULL;
	struct kvldskey ** values = NULL;
	size_t klen;
	size_t i;
	int rc;

	/* If we have a packet, parse it. */
	if (buf != NULL) {
		/* Is the status code sane? */
		if (buflen - bufpos < 4)
			BAD("RANGE", "bogus length");
		if (be32dec(&buf[bufpos]) != 0)
			BAD("RANGE", "bogus status code");
		bufpos += 4;

		/* Parse and sanity-check the number of key-value pairs. */
		if (buflen - bufpos < 4)
			BAD("RANGE", "bogus length");
		nkeys = be32dec(&buf[bufpos]);
		if ((nkeys > 1) && (nkeys > C->max / 2))
			BAD("RANGE", "too many key-value pairs");
		bufpos += 4;

		/* Parse next key. */
		if ((klen = kvldskey_unserialize(&next, &buf[bufpos],
		    buflen - bufpos)) == 0) {
			warnp("Error parsing RANGE response next key");
			goto failed;
		}
		bufpos += klen;

		/* Allocate buffer for keys. */
		if (IMALLOC(keys, nkeys, struct kvldskey *))
			goto failed;
		for (i = 0; i < nkeys; i++)
			keys[i] = NULL;

		/* Allocate buffer for values. */
		if (IMALLOC(values, nkeys, struct kvldskey *))
			goto failed;
		for (i = 0; i < nkeys; i++)
			values[i] = NULL;

		/* Parse keys and values. */
		for (i = 0; i < nkeys; i++) {
			if ((klen = kvldskey_unserialize(&keys[i],
			    &buf[bufpos], buflen - bufpos)) == 0) {
				warnp("Error parsing RANGE response key");
				goto failed;
			}
			bufpos += klen;

			if ((klen = kvldskey_unserialize(&values[i],
			    &buf[bufpos], buflen - bufpos)) == 0) {
				warnp("Error parsing RANGE response value");
				goto failed;
			}
			bufpos += klen;
		}

		/* Make sure we reached the end of the packet. */
		if (buflen != bufpos)
			BAD("RANGE", "wrong length");

		/* We successfully parsed this response. */
		failed = 0;
	}

failed:
	/* If we failed, clean up. */
	if (failed) {
		if (values) {
			for (i = 0; i < nkeys; i++)
				kvldskey_free(values[i]);
			free(values);
			values = NULL;
		}
		if (keys) {
			for (i = 0; i < nkeys; i++)
				kvldskey_free(keys[i]);
			free(keys);
			keys = NULL;
		}
		nkeys = 0;
		kvldskey_free(next);
		next = NULL;
	}

	/* Invoke the upstream callback. */
	rc = (C->callback)(C->cookie, failed, nkeys, next, keys, values);

	/* Free the cookie. */
	free(C);

	/* Return status from callback. */
	return (rc);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq $0x0, 0x28(%rsp)
testq %rsi, %rsi
je 0x64f5
movq %rdx, %r13
cmpq $0x3, %rdx
ja 0x64c3
leaq 0x579b(%rip), %rdi      # 0xbc4e
leaq 0x5809(%rip), %rsi      # 0xbcc3
leaq 0x57b1(%rip), %rdx      # 0xbc72
jmp 0x64e3
movq %rsi, %rbp
movl (%rsi), %eax
bswapl %eax
testl %eax, %eax
je 0x653b
leaq 0x5779(%rip), %rdi      # 0xbc4e
leaq 0x57e7(%rip), %rsi      # 0xbcc3
leaq 0x579c(%rip), %rdx      # 0xbc7f
xorl %eax, %eax
callq 0x516f
callq 0x2090
movl $0x0, (%rax)
movq 0x28(%rsp), %rdi
callq 0x2040
movq $0x0, 0x28(%rsp)
movl $0x1, %esi
xorl %ecx, %ecx
xorl %edx, %edx
xorl %r8d, %r8d
xorl %r12d, %r12d
movq 0x8(%rbx), %rdi
movq %r12, %r9
callq *(%rbx)
movl %eax, %ebp
movq %rbx, %rdi
callq 0x2040
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rax
andq $-0x4, %rax
cmpq $0x4, %rax
je 0x64ac
movl 0x4(%rbp), %ecx
bswapl %ecx
cmpl $0x2, %ecx
jb 0x657c
movq 0x10(%rbx), %rax
shrq %rax
cmpq %rcx, %rax
jae 0x657c
leaq 0x56e5(%rip), %rdi      # 0xbc4e
leaq 0x5753(%rip), %rsi      # 0xbcc3
leaq 0x5752(%rip), %rdx      # 0xbcc9
jmp 0x64e3
movq %rcx, 0x20(%rsp)
leaq 0x8(%rbp), %rsi
leaq -0x8(%r13), %rdx
leaq 0x28(%rsp), %rdi
callq 0x564d
testq %rax, %rax
je 0x6683
movq %rax, %r15
addq $0x8, %r15
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x66ae
leaq (,%rax,8), %r12
movq %r12, %rdi
callq 0x2220
movq %rax, 0x18(%rsp)
testq %rax, %rax
sete %r14b
je 0x64f5
movq 0x18(%rsp), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x21a0
movq %r12, %rdi
callq 0x2220
testq %rax, %rax
sete 0xf(%rsp)
je 0x6705
movq %r12, %rdx
movq %rax, %r12
movb %r14b, 0xe(%rsp)
movq %rbx, 0x10(%rsp)
xorl %ebx, %ebx
movq %rax, %rdi
xorl %esi, %esi
movq %rdx, 0x30(%rsp)
callq 0x21a0
movq 0x18(%rsp), %rax
leaq (%rax,%rbx), %rdi
leaq (%r15,%rbp), %rsi
movq %r13, %rdx
subq %r15, %rdx
callq 0x564d
testq %rax, %rax
je 0x6726
movq %rax, %r14
addq %r15, %r14
leaq (%r12,%rbx), %rdi
leaq (%r14,%rbp), %rsi
movq %r13, %rdx
subq %r14, %rdx
callq 0x564d
testq %rax, %rax
je 0x673c
movq %rax, %r15
addq %r14, %r15
addq $0x8, %rbx
cmpq %rbx, 0x30(%rsp)
jne 0x6619
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r8
movb 0xe(%rsp), %r14b
movb 0xf(%rsp), %bpl
jmp 0x66ba
callq 0x2090
cmpl $0x0, (%rax)
je 0x6713
movq %rax, %r14
leaq 0x5647(%rip), %rdi      # 0xbce2
xorl %eax, %eax
callq 0x5050
movl $0x0, (%r14)
jmp 0x64f5
movb $0x1, %bpl
xorl %r12d, %r12d
xorl %r8d, %r8d
movb $0x1, %r14b
cmpq %r13, %r15
jne 0x66d0
xorl %esi, %esi
movq 0x28(%rsp), %rcx
movq 0x20(%rsp), %rdx
jmp 0x6517
movq %r8, 0x18(%rsp)
leaq 0x5572(%rip), %rdi      # 0xbc4e
leaq 0x55e0(%rip), %rsi      # 0xbcc3
leaq 0x55cc(%rip), %rdx      # 0xbcb6
xorl %eax, %eax
callq 0x516f
callq 0x2090
movl $0x0, (%rax)
testb %bpl, %bpl
je 0x678a
testb %r14b, %r14b
jne 0x64f5
jmp 0x67c1
leaq 0x55c8(%rip), %rdi      # 0xbce2
xorl %eax, %eax
callq 0x516f
jmp 0x64f5
callq 0x2090
cmpl $0x0, (%rax)
je 0x6760
movq %rax, %r14
leaq 0x55ce(%rip), %rdi      # 0xbd08
jmp 0x6750
callq 0x2090
cmpl $0x0, (%rax)
je 0x6769
movq %rax, %r14
leaq 0x55d9(%rip), %rdi      # 0xbd29
xorl %eax, %eax
callq 0x5050
movl $0x0, (%r14)
jmp 0x6777
leaq 0x55a1(%rip), %rdi      # 0xbd08
jmp 0x6770
leaq 0x55b9(%rip), %rdi      # 0xbd29
xorl %eax, %eax
callq 0x516f
testq %r12, %r12
movq 0x10(%rsp), %rbx
movb 0xe(%rsp), %r14b
je 0x6705
movl %r14d, %ebp
movq %rbx, %r14
movq 0x20(%rsp), %r15
testl %r15d, %r15d
je 0x67ad
xorl %ebx, %ebx
movq (%r12,%rbx,8), %rdi
callq 0x2040
incq %rbx
cmpq %rbx, %r15
jne 0x679c
movq %r12, %rdi
callq 0x2040
testb %bpl, %bpl
movq %r14, %rbx
jne 0x64f5
movq %rbx, %r14
movq 0x20(%rsp), %r15
testl %r15d, %r15d
movq 0x18(%rsp), %r12
je 0x67e6
xorl %ebx, %ebx
movq (%r12,%rbx,8), %rdi
callq 0x2040
incq %rbx
cmpq %rbx, %r15
jne 0x67d5
movq %r12, %rdi
callq 0x2040
movq %r14, %rbx
jmp 0x64f5