// File: /workspace/github_c_makefile_star2_O1/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
movq %rsi, %rbx
movl 0x8(%rdi), %ecx
cmpl 0xc(%rdi), %ecx
jae 0xb2f4
movq (%rdi), %rax
movzbl (%rax,%rcx), %eax
addl $0xffffff39, %eax       # imm = 0xFFFFFF39
cmpl $0x11, %eax
ja 0xb2f4
movl $0x3e007, %edx          # imm = 0x3E007
btl %eax, %edx
jae 0xb2f4
xorl %ebp, %ebp
xorl %esi, %esi
callq 0xcd02
movq $0x0, (%rbx)
jmp 0xb4c8
movq (%rdi), %rax
leal 0x1(%rcx), %edx
movl %edx, 0x8(%rdi)
movzbl (%rax,%rcx), %esi
leal -0xc0(%rsi), %r8d
cmpl $0x1f, %r8d
ja 0xb4f2
leaq 0xcdf3(%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 0xb353
movl %edx, %edx
movl (%rax,%rdx), %esi
bswapl %esi
leal 0x5(%rcx), %eax
movl %eax, 0x8(%rdi)
jmp 0xb353
movl %edx, %edx
movzwl (%rax,%rdx), %eax
rolw $0x8, %ax
addl $0x3, %ecx
movl %ecx, 0x8(%rdi)
movzwl %ax, %esi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xb57a
movl %edx, %edx
movq (%rax,%rdx), %rax
bswapq %rax
addl $0x9, %ecx
movl %ecx, 0x8(%rdi)
jmp 0xb3a6
movl %edx, %edx
movl (%rax,%rdx), %eax
bswapl %eax
addl $0x5, %ecx
movl %ecx, 0x8(%rdi)
movslq %eax, %rdi
jmp 0xb4be
movl %edx, %edx
movl (%rax,%rdx), %esi
bswapl %esi
leal 0x5(%rcx), %eax
movl %eax, 0x8(%rdi)
jmp 0xb4e4
movl %edx, %edx
movl (%rax,%rdx), %eax
bswapl %eax
addl $0x5, %ecx
movl %ecx, 0x8(%rdi)
movq %rax, %rdi
jmp 0xb4be
movl %edx, %edx
movl (%rax,%rdx), %esi
bswapl %esi
leal 0x5(%rcx), %eax
movl %eax, 0x8(%rdi)
jmp 0xb3e9
movl %edx, %edx
movq (%rax,%rdx), %rax
bswapq %rax
addl $0x9, %ecx
movl %ecx, 0x8(%rdi)
movq %rax, %xmm0
jmp 0xb494
movl %edx, %edx
movzwl (%rax,%rdx), %eax
rolw $0x8, %ax
addl $0x3, %ecx
movl %ecx, 0x8(%rdi)
movzwl %ax, %esi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xb7e2
movl %edx, %edx
movzwl (%rax,%rdx), %eax
rolw $0x8, %ax
addl $0x3, %ecx
movl %ecx, 0x8(%rdi)
movzwl %ax, %edi
jmp 0xb4be
leal 0x2(%rcx), %esi
movl %esi, 0x8(%rdi)
movl %edx, %edx
movb (%rax,%rdx), %dl
addl $0x3, %ecx
movl %ecx, 0x8(%rdi)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpb $-0x1, %dl
jne 0xb4c8
movl %esi, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
je 0xb543
testl %eax, %eax
jne 0xb4c8
movq 0x14b3c(%rip), %rax     # 0x1ff88
jmp 0xb4c3
addl $0x2, %ecx
movl %ecx, 0x8(%rdi)
movl %edx, %ecx
movzbl (%rax,%rcx), %edi
jmp 0xb4be
movl $0x1, %edi
callq 0x89c0
jmp 0xb4c3
movq 0x14b71(%rip), %rax     # 0x1ffe0
jmp 0xb4c3
xorl %ebp, %ebp
xorl %edi, %edi
callq 0x89c0
movq %rax, (%rbx)
jmp 0xb4c8
movl %edx, %edx
movl (%rax,%rdx), %eax
bswapl %eax
addl $0x5, %ecx
movl %ecx, 0x8(%rdi)
movd %eax, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x8b10
jmp 0xb4c3
movl %edx, %edx
movzwl (%rax,%rdx), %eax
rolw $0x8, %ax
addl $0x3, %ecx
movl %ecx, 0x8(%rdi)
movswq %ax, %rdi
jmp 0xb4be
addl $0x2, %ecx
movl %ecx, 0x8(%rdi)
movl %edx, %ecx
movsbq (%rax,%rcx), %rdi
callq 0x85b0
movq %rax, (%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movl %edx, %edx
movzwl (%rax,%rdx), %eax
rolw $0x8, %ax
addl $0x3, %ecx
movl %ecx, 0x8(%rdi)
movzwl %ax, %esi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xb6a6
movl %esi, %eax
andl $-0x20, %eax
cmpl $0xa0, %eax
jne 0xb506
andl $0x1f, %esi
jmp 0xb353
movl %esi, %eax
andb $-0x10, %al
cmpb $-0x70, %al
je 0xb522
movl %esi, %eax
andl $-0x10, %eax
cmpl $0x80, %eax
jne 0xb527
andl $0xf, %esi
jmp 0xb3e9
andl $0xf, %esi
jmp 0xb4e4
testb %sil, %sil
jns 0xb53b
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
cmpb $-0x20, %sil
jb 0xb4c8
orq $-0x20, %rsi
movq %rsi, %rdi
jmp 0xb4be
movq 0x14a56(%rip), %rax     # 0x1ffa0
jmp 0xb4c3