// File: /workspace/github_c_makefile_star2_O3/aerospike[P]aerospike-common/src/main/aerospike/as_msgpack.c
// Function: unpack_size_non_recursive
static int64_t
unpack_size_non_recursive(as_unpacker *pk, msgpack_parse_memblock *block,
		msgpack_parse_state *state)
{
	int start = pk->offset;

	while (state) {
		while (state->index >= state->len) {
			if (! msgpack_parse_memblock_has_prev(block)) {
				return (int64_t)(pk->offset - start);
			}

			state = msgpack_parse_memblock_prev(&block);
		}

		if (state->type == AS_LIST) {
			state->index++;
		}
		else if (state->type == AS_MAP) {
			if (state->map_pair == 0) {
				state->map_pair++;
			}
			else {
				state->map_pair = 0;
				state->index++;
			}
		}
		else {
			return -1;
		}

		as_val_t type = as_unpack_peek_type(pk);

		if (type == AS_UNDEF) {
			return -2;
		}

		if (type == AS_LIST ) {
			state = msgpack_parse_memblock_next(&block);

			if (! msgpack_parse_state_list_size_init(state, pk)) {
				return -3;
			}

			continue;
		}

		if (type == AS_MAP) {
			state = msgpack_parse_memblock_next(&block);

			if (! msgpack_parse_state_map_size_init(state, pk)) {
				return -4;
			}

			continue;
		}

		if (unpack_size_internal(pk, 0) < 0) {
			return -5;
		}
	}

	return -6;
}

// Assembly:
testq %rdx, %rdx
je 0xda1c
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl 0x8(%rdi), %r12d
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movl 0xc(%r15), %eax
cmpl 0x8(%r15), %eax
jb 0xd8ee
movq (%r14), %r15
movq 0x1808(%r14), %rax
testq %r15, %r15
je 0xd8c5
cmpq $0x1, %rax
ja 0xd8cf
movq %r14, %rdi
callq 0x8940
movq 0x1808(%r15), %rax
movq %r15, %r14
jmp 0xd8d9
cmpq $0x1, %rax
jbe 0xda0d
decq %rax
movq %rax, 0x1808(%r14)
leaq (%rax,%rax,2), %rcx
movl -0x4(%r14,%rcx,8), %eax
cmpl -0x8(%r14,%rcx,8), %eax
jae 0xd89c
leaq -0x10(%r14,%rcx,8), %r15
movzbl 0x11(%r15), %ecx
cmpl $0x6, %ecx
je 0xd902
cmpl $0x5, %ecx
je 0xd912
jmp 0xda24
cmpb $0x0, 0x10(%r15)
je 0xda03
movb $0x0, 0x10(%r15)
incl %eax
movl %eax, 0xc(%r15)
movq %rbx, %rdi
callq 0x8410
movl %eax, %ebp
cmpb $0x5, %al
je 0xd99a
movzbl %bpl, %eax
cmpl $0x6, %eax
je 0xd94f
testl %eax, %eax
je 0xda2d
movq %rbx, %rdi
xorl %esi, %esi
callq 0xcb72
testq %rax, %rax
jns 0xd892
jmp 0xda48
movq 0x1808(%r14), %r15
cmpq $0x100, %r15            # imm = 0x100
jb 0xd97d
movl $0x1810, %edi           # imm = 0x1810
callq 0x8080
movq %r14, (%rax)
movq %rax, %r14
xorl %r15d, %r15d
movq $0x0, 0x1808(%rax)
leaq 0x1(%r15), %rax
movq %rbx, %rdi
movq %rax, 0x1808(%r14)
callq 0x8a70
testq %rax, %rax
jns 0xd9e0
jmp 0xda36
movq 0x1808(%r14), %r15
cmpq $0x100, %r15            # imm = 0x100
jb 0xd9c8
movl $0x1810, %edi           # imm = 0x1810
callq 0x8080
movq %r14, (%rax)
movq %rax, %r14
xorl %r15d, %r15d
movq $0x0, 0x1808(%rax)
leaq 0x1(%r15), %rax
movq %rbx, %rdi
movq %rax, 0x1808(%r14)
callq 0x85e0
testq %rax, %rax
js 0xda3f
leaq (%r15,%r15,2), %rcx
leaq 0x8(%r14,%rcx,8), %r15
movl $0x0, 0xc(%r15)
movb $0x0, 0x10(%r15)
movl %eax, 0x8(%r15)
movb %bpl, 0x11(%r15)
jmp 0xd892
movb $0x1, 0x10(%r15)
jmp 0xd918
movl 0x8(%rbx), %eax
subl %r12d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq $-0x6, %rax
retq
movq $-0x1, %rax
jmp 0xda13
movq $-0x2, %rax
jmp 0xda13
movq $-0x4, %rax
jmp 0xda13
movq $-0x3, %rax
jmp 0xda13
movq $-0x5, %rax
jmp 0xda13