// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdx, %rdx
je 0xdc17
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
movl 0x8(%rdi), %ebp
movl 0xc(%r12), %eax
cmpl 0x8(%r12), %eax
jb 0xda94
movq (%r15), %r12
testq %r12, %r12
jne 0xda54
cmpq $0x1, 0x1808(%r15)
jbe 0xdc0f
movq 0x1808(%r15), %rax
cmpq $0x1, %rax
ja 0xda6e
movq %r15, %rdi
callq 0x8940
movq %r12, %r15
jmp 0xda78
decq %rax
movq %rax, 0x1808(%r15)
movq 0x1808(%r15), %rax
leaq (%rax,%rax,2), %rcx
movl -0x4(%r15,%rcx,8), %eax
cmpl -0x8(%r15,%rcx,8), %eax
jae 0xda3e
leaq -0x10(%r15,%rcx,8), %r12
movzbl 0x11(%r12), %ecx
cmpl $0x6, %ecx
je 0xdaa9
cmpl $0x5, %ecx
je 0xdabb
jmp 0xdc30
cmpb $0x0, 0x10(%r12)
je 0xdbe8
movb $0x0, 0x10(%r12)
incl %eax
movl %eax, 0xc(%r12)
movq %r14, %rdi
callq 0x8410
movl $0x1, %r13d
testb %al, %al
je 0xdbbe
movzbl %al, %eax
cmpl $0x6, %eax
je 0xdb50
cmpl $0x5, %eax
jne 0xdbc7
cmpq $0x100, 0x1808(%r15) # imm = 0x100
jb 0xdb11
movl $0x1810, %edi           # imm = 0x1810
callq 0x8080
movq %r15, (%rax)
movq $0x0, 0x1808(%rax)
movq %rax, %r15
movq 0x1808(%r15), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x1808(%r15)
leaq (%rax,%rax,2), %rax
leaq 0x8(%r15,%rax,8), %r12
movq %r14, %rdi
callq 0x85e0
testq %rax, %rax
js 0xdbfc
movl $0x0, 0xc(%r12)
movw $0x500, 0x10(%r12)      # imm = 0x500
jmp 0xdbb1
cmpq $0x100, 0x1808(%r15) # imm = 0x100
jb 0xdb78
movl $0x1810, %edi           # imm = 0x1810
callq 0x8080
movq %r15, (%rax)
movq $0x0, 0x1808(%rax)
movq %rax, %r15
movq 0x1808(%r15), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x1808(%r15)
leaq (%rax,%rax,2), %rax
leaq 0x8(%r15,%rax,8), %r12
movq %r14, %rdi
callq 0x8a70
testq %rax, %rax
js 0xdbf3
movl $0x0, 0xc(%r12)
movw $0x600, 0x10(%r12)      # imm = 0x600
movl %eax, 0x8(%r12)
movl $0x2, %r13d
jmp 0xdc03
movq $-0x2, %rbx
jmp 0xdc03
movq %r14, %rdi
xorl %esi, %esi
callq 0xcd02
movq %rax, %r13
shrq $0x3f, %r13
testq %rax, %rax
movq $-0x5, %rax
cmovsq %rax, %rbx
jmp 0xdc03
movb $0x1, 0x10(%r12)
jmp 0xdac2
movq $-0x4, %rbx
jmp 0xdc03
movq $-0x3, %rbx
testb $0x1, %r13b
je 0xda32
jmp 0xdc1e
movl 0x8(%r14), %ebx
subl %ebp, %ebx
jmp 0xdc1e
movq $-0x6, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $-0x1, %rbx
jmp 0xdc1e