// File: /workspace/github_c_makefile_star2_O2/aerospike[P]aerospike-common/src/main/aerospike/as_msgpack.c
// Function: as_unpack_val
int
as_unpack_val(as_unpacker *pk, as_val **val)
{
	if (as_unpack_peek_is_ext(pk)) {
		as_unpack_size(pk);
		*val = NULL;
		return 0;
	}

	uint8_t type = pk->buffer[pk->offset++];

	switch (type) {
	case 0xc0: // nil
		return unpack_nil(val);

	case 0xc3: // boolean true
		return unpack_boolean(true, val);
	case 0xc2: // boolean false
		return unpack_boolean(false, val);

	case 0xca: // float
		return unpack_double_val((double)extract_float(pk), val);
	case 0xcb: // double
		return unpack_double_val(extract_double(pk), val);

	case 0xd0: // signed 8 bit integer
		return unpack_integer_val((int64_t)(int8_t)pk->buffer[pk->offset++],
				val);
	case 0xcc: // unsigned 8 bit integer
		return unpack_integer_val((int64_t)pk->buffer[pk->offset++], val);

	case 0xd1: // signed 16 bit integer
		return unpack_integer_val((int64_t)(int16_t)extract_uint16(pk), val);
	case 0xcd: // unsigned 16 bit integer
		return unpack_integer_val((int64_t)extract_uint16(pk), val);

	case 0xd2: // signed 32 bit integer
		return unpack_integer_val((int64_t)(int32_t)extract_uint32(pk), val);
	case 0xce: // unsigned 32 bit integer
		return unpack_integer_val((int64_t)extract_uint32(pk), val);

	case 0xd3: // signed 64 bit integer
	case 0xcf: // unsigned 64 bit integer
		return unpack_integer_val((int64_t)extract_uint64(pk), val);

	case 0xc4:
	case 0xd9: // string/raw bytes with 8 bit header
		return unpack_blob(pk, (uint32_t)pk->buffer[pk->offset++], val);
	case 0xc5:
	case 0xda: // string/raw bytes with 16 bit header
		return unpack_blob(pk, (uint32_t)extract_uint16(pk), val);
	case 0xc6:
	case 0xdb: // string/raw bytes with 32 bit header
		return unpack_blob(pk, extract_uint32(pk), val);

	case 0xdc: // list with 16 bit header
		return unpack_list(pk, (uint32_t)extract_uint16(pk), val);
	case 0xdd: // list with 32 bit header
		return unpack_list(pk, extract_uint32(pk), val);

	case 0xde: // map with 16 bit header
		return unpack_map(pk, (uint32_t)extract_uint16(pk), val);
	case 0xdf: // map with 32 bit header
		return unpack_map(pk, extract_uint32(pk), val);

	case 0xd4: // fixext 1
		return unpack_ext(pk, type, val);

	default:
		if ((type & 0xe0) == 0xa0) { // raw bytes with 8 bit combined header
			return unpack_blob(pk, (uint32_t)(type & 0x1f), val);
		}

		if ((type & 0xf0) == 0x80) { // map with 8 bit combined header
			return unpack_map(pk, (uint32_t)(type & 0x0f), val);
		}

		if ((type & 0xf0) == 0x90) { // list with 8 bit combined header
			return unpack_list(pk, (uint32_t)(type & 0x0f), val);
		}

		if (type < 0x80) { // 8 bit combined unsigned integer
			return unpack_integer_val((int64_t)type, val);
		}

		if (type >= 0xe0) { // 8 bit combined signed integer
			return unpack_integer_val((int64_t)(type & 0x1f) - 32, val);
		}

		return -2;
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
callq 0x8840
testb %al, %al
je 0xac71
movq %r14, %rdi
callq 0x8950
andq $0x0, (%rbx)
jmp 0xae4d
movl 0x8(%r14), %eax
movq (%r14), %rcx
leal 0x1(%rax), %edx
movl %edx, 0x8(%r14)
movzbl (%rcx,%rax), %esi
leal -0xc0(%rsi), %edi
cmpl $0x1f, %edi
ja 0xae79
leaq 0xa473(%rip), %r8       # 0x1510c
movslq (%r8,%rdi,4), %rdi
addq %r8, %rdi
jmpq *%rdi
addl $0x2, %eax
movl %eax, 0x8(%r14)
movl %edx, %eax
movzbl (%rcx,%rax), %esi
jmp 0xacd5
movl %edx, %edx
addl $0x5, %eax
movl (%rcx,%rdx), %esi
movl %eax, 0x8(%r14)
bswapl %esi
jmp 0xacd5
movl %edx, %edx
addl $0x3, %eax
movzwl (%rcx,%rdx), %ecx
movl %eax, 0x8(%r14)
rolw $0x8, %cx
movzwl %cx, %esi
movq %r14, %rdi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %rbp
jmp 0xaf0d
movl %edx, %edx
addl $0x9, %eax
movq (%rcx,%rdx), %rdi
bswapq %rdi
jmp 0xad25
movl %edx, %edx
addl $0x5, %eax
movl (%rcx,%rdx), %ecx
movl %eax, 0x8(%r14)
bswapl %ecx
movslq %ecx, %rdi
jmp 0xae45
movl %edx, %edx
addl $0x5, %eax
movl (%rcx,%rdx), %esi
movl %eax, 0x8(%r14)
bswapl %esi
jmp 0xae6a
movl %edx, %edx
addl $0x5, %eax
movl (%rcx,%rdx), %edi
bswapl %edi
movl %eax, 0x8(%r14)
jmp 0xae45
movl %edx, %edx
addl $0x5, %eax
movl (%rcx,%rdx), %esi
movl %eax, 0x8(%r14)
bswapl %esi
jmp 0xad6c
movl %edx, %edx
addl $0x9, %eax
movq (%rcx,%rdx), %rcx
movl %eax, 0x8(%r14)
bswapq %rcx
movq %rcx, %xmm0
jmp 0xae19
movl %edx, %edx
addl $0x3, %eax
movzwl (%rcx,%rdx), %ecx
movl %eax, 0x8(%r14)
rolw $0x8, %cx
movzwl %cx, %esi
movq %r14, %rdi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %rbp
jmp 0xb0d6
movl %edx, %edx
addl $0x3, %eax
movzwl (%rcx,%rdx), %ecx
movl %eax, 0x8(%r14)
rolw $0x8, %cx
movzwl %cx, %edi
jmp 0xae45
leal 0x2(%rax), %esi
movl %edx, %edx
addl $0x3, %eax
movl %esi, 0x8(%r14)
movb (%rcx,%rdx), %dl
movl %eax, 0x8(%r14)
pushq $-0x1
popq %rbp
cmpb $-0x1, %dl
jne 0xae4f
movl %esi, %eax
movzbl (%rcx,%rax), %eax
testl %eax, %eax
je 0xaece
cmpl $0x1, %eax
jne 0xae4f
movq 0x131cf(%rip), %rax     # 0x1dfa0
jmp 0xae4a
addl $0x2, %eax
movl %eax, 0x8(%r14)
movl %edx, %eax
movzbl (%rcx,%rax), %edi
jmp 0xae45
pushq $0x1
popq %rdi
callq 0x8a80
jmp 0xae4a
movq 0x131ed(%rip), %rax     # 0x1dfe0
jmp 0xae4a
xorl %edi, %edi
xorl %ebp, %ebp
callq 0x8a80
movq %rax, (%rbx)
jmp 0xae4f
movl %edx, %edx
addl $0x5, %eax
movl (%rcx,%rdx), %ecx
movl %eax, 0x8(%r14)
bswapl %ecx
movd %ecx, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x8be0
jmp 0xae4a
movl %edx, %edx
addl $0x3, %eax
movzwl (%rcx,%rdx), %ecx
movl %eax, 0x8(%r14)
rolw $0x8, %cx
movswq %cx, %rdi
jmp 0xae45
addl $0x2, %eax
movl %eax, 0x8(%r14)
movl %edx, %eax
movsbq (%rcx,%rax), %rdi
callq 0x8610
movq %rax, (%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl %edx, %edx
addl $0x3, %eax
movzwl (%rcx,%rdx), %ecx
movl %eax, 0x8(%r14)
rolw $0x8, %cx
movzwl %cx, %esi
movq %r14, %rdi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %rbp
jmp 0xb005
movl %esi, %eax
andl $-0x20, %eax
cmpl $0xa0, %eax
jne 0xae90
andl $0x1f, %esi
movq %r14, %rdi
jmp 0xacd8
movl %esi, %eax
andb $-0x10, %al
cmpb $-0x70, %al
je 0xaeaf
movl %esi, %eax
andl $-0x10, %eax
cmpl $0x80, %eax
jne 0xaeb7
andl $0xf, %esi
movq %r14, %rdi
jmp 0xad6f
andl $0xf, %esi
movq %r14, %rdi
jmp 0xae6d
testb %sil, %sil
jns 0xaec6
cmpb $-0x20, %sil
jb 0xaeda
orq $-0x20, %rsi
movq %rsi, %rdi
jmp 0xae45
movq 0x130b3(%rip), %rax     # 0x1df88
jmp 0xae4a
pushq $-0x2
popq %rbp
jmp 0xae4f