// File: /workspace/github_c_makefile_star2_O3/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 %rbx
pushq %rax
movl 0x8(%rdi), %ecx
movq (%rdi), %rax
movq %rsi, %rbx
cmpl 0xc(%rdi), %ecx
jae 0xb21a
movzbl (%rax,%rcx), %edx
addl $0xffffff39, %edx       # imm = 0xFFFFFF39
cmpl $0x11, %edx
ja 0xb21a
movl $0x3e007, %esi          # imm = 0x3E007
btl %edx, %esi
jae 0xb21a
xorl %esi, %esi
xorl %ebp, %ebp
callq 0xcb72
movq $0x0, (%rbx)
jmp 0xb3e5
leal 0x1(%rcx), %edx
movl %edx, 0x8(%rdi)
movzbl (%rax,%rcx), %esi
leal -0xc0(%rsi), %r8d
cmpl $0x1f, %r8d
ja 0xb40f
leaq 0xced0(%rip), %r9       # 0x1810c
movslq (%r9,%r8,4), %r8
addq %r9, %r8
jmpq *%r8
addl $0x2, %ecx
movl %ecx, 0x8(%rdi)
movl %edx, %ecx
movzbl (%rax,%rcx), %esi
jmp 0xb276
movl %edx, %edx
addl $0x5, %ecx
movl (%rax,%rdx), %esi
movl %ecx, 0x8(%rdi)
bswapl %esi
jmp 0xb276
movl %edx, %edx
addl $0x3, %ecx
movzwl (%rax,%rdx), %eax
movl %ecx, 0x8(%rdi)
rolw $0x8, %ax
movzwl %ax, %esi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xb497
movl %edx, %edx
addl $0x9, %ecx
movq (%rax,%rdx), %rax
bswapq %rax
jmp 0xb2c3
movl %edx, %edx
addl $0x5, %ecx
movl (%rax,%rdx), %eax
movl %ecx, 0x8(%rdi)
bswapl %eax
movslq %eax, %rdi
jmp 0xb3db
movl %edx, %edx
addl $0x5, %ecx
movl (%rax,%rdx), %esi
movl %ecx, 0x8(%rdi)
bswapl %esi
jmp 0xb401
movl %edx, %edx
addl $0x5, %ecx
movl (%rax,%rdx), %eax
bswapl %eax
movl %ecx, 0x8(%rdi)
movq %rax, %rdi
jmp 0xb3db
movl %edx, %edx
addl $0x5, %ecx
movl (%rax,%rdx), %esi
movl %ecx, 0x8(%rdi)
bswapl %esi
jmp 0xb309
movl %edx, %edx
addl $0x9, %ecx
movq (%rax,%rdx), %rax
movl %ecx, 0x8(%rdi)
bswapq %rax
movq %rax, %xmm0
jmp 0xb3b1
movl %edx, %edx
addl $0x3, %ecx
movzwl (%rax,%rdx), %eax
movl %ecx, 0x8(%rdi)
rolw $0x8, %ax
movzwl %ax, %esi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xb6ac
movl %edx, %edx
addl $0x3, %ecx
movzwl (%rax,%rdx), %eax
movl %ecx, 0x8(%rdi)
rolw $0x8, %ax
movzwl %ax, %edi
jmp 0xb3db
leal 0x2(%rcx), %esi
movl %edx, %edx
addl $0x3, %ecx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %esi, 0x8(%rdi)
movb (%rax,%rdx), %dl
movl %ecx, 0x8(%rdi)
cmpb $-0x1, %dl
jne 0xb3e5
movl %esi, %ecx
movzbl (%rax,%rcx), %eax
testl %eax, %eax
je 0xb460
cmpl $0x1, %eax
jne 0xb3e5
movq 0x14c34(%rip), %rax     # 0x1ffa0
jmp 0xb3e0
addl $0x2, %ecx
movl %ecx, 0x8(%rdi)
movl %edx, %ecx
movzbl (%rax,%rcx), %edi
jmp 0xb3db
movl $0x1, %edi
callq 0x89c0
jmp 0xb3e0
movq 0x14c51(%rip), %rax     # 0x1ffe0
jmp 0xb3e0
xorl %edi, %edi
xorl %ebp, %ebp
callq 0x89c0
jmp 0xb3e2
movl %edx, %edx
addl $0x5, %ecx
movl (%rax,%rdx), %eax
movl %ecx, 0x8(%rdi)
bswapl %eax
movd %eax, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x8b10
jmp 0xb3e0
movl %edx, %edx
addl $0x3, %ecx
movzwl (%rax,%rdx), %eax
movl %ecx, 0x8(%rdi)
rolw $0x8, %ax
movswq %ax, %rdi
jmp 0xb3db
addl $0x2, %ecx
movl %ecx, 0x8(%rdi)
movl %edx, %ecx
movsbq (%rax,%rcx), %rdi
callq 0x85b0
xorl %ebp, %ebp
movq %rax, (%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movl %edx, %edx
addl $0x3, %ecx
movzwl (%rax,%rdx), %eax
movl %ecx, 0x8(%rdi)
rolw $0x8, %ax
movzwl %ax, %esi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xb5a0
movl %esi, %eax
andl $-0x20, %eax
cmpl $0xa0, %eax
jne 0xb423
andl $0x1f, %esi
jmp 0xb276
movl %esi, %eax
andb $-0x10, %al
cmpb $-0x70, %al
je 0xb43f
movl %esi, %eax
andl $-0x10, %eax
cmpl $0x80, %eax
jne 0xb444
andl $0xf, %esi
jmp 0xb309
andl $0xf, %esi
jmp 0xb401
testb %sil, %sil
jns 0xb458
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
cmpb $-0x20, %sil
jb 0xb3e5
orq $-0x20, %rsi
movq %rsi, %rdi
jmp 0xb3db
movq 0x14b21(%rip), %rax     # 0x1ff88
jmp 0xb3e0