// File: /workspace/github_c_makefile_star2_O2/aerospike[P]aerospike-common/src/main/aerospike/as_msgpack.c
// Function: unpack_size_internal
static inline int64_t
unpack_size_internal(as_unpacker *pk, uint32_t depth)
{
	if (pk->offset >= pk->length) {
		return -1;
	}

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

	switch (type) {
	case 0xc0: // nil
	case 0xc3: // boolean true
	case 0xc2: // boolean false
		return 1;

	case 0xd0: // signed 8 bit integer
	case 0xcc: // unsigned 8 bit integer
		pk->offset++;
		return 1 + 1;

	case 0xd1: // signed 16 bit integer
	case 0xcd: // unsigned 16 bit integer
		pk->offset += 2;
		return 1 + 2;

	case 0xca: // float
	case 0xd2: // signed 32 bit integer
	case 0xce: // unsigned 32 bit integer
		pk->offset += 4;
		return 1 + 4;

	case 0xcb: // double
	case 0xd3: // signed 64 bit integer
	case 0xcf: // unsigned 64 bit integer
		pk->offset += 8;
		return 1 + 8;

	case 0xc4:
	case 0xd9: { // string/raw bytes with 8 bit header
		uint8_t length = pk->buffer[pk->offset++];
		pk->offset += length;
		return 1 + 1 + length;
	}

	case 0xc5:
	case 0xda: { // string/raw bytes with 16 bit header
		uint16_t length = extract_uint16(pk);
		pk->offset += length;
		return 1 + 2 + length;
	}

	case 0xc6:
	case 0xdb: { // string/raw bytes with 32 bit header
		uint32_t length = extract_uint32(pk);
		pk->offset += length;
		return 1 + 4 + length;
	}

	case 0xdc: { // list with 16 bit header
		uint16_t length = extract_uint16(pk);
		int64_t ret = unpack_list_elements_size(pk, length, depth);
		if (ret < 0) {
			return -2;
		}
		return 1 + 2 + ret;
	}

	case 0xdd: { // list with 32 bit header
		uint32_t length = extract_uint32(pk);
		int64_t ret = unpack_list_elements_size(pk, length, depth);
		if (ret < 0) {
			return -3;
		}
		return 1 + 4 + ret;
	}

	case 0xde: { // map with 16 bit header
		uint16_t length = extract_uint16(pk);
		int64_t ret = unpack_map_elements_size(pk, length, depth);
		if (ret < 0) {
			return -4;
		}
		return 1 + 2 + ret;
	}

	case 0xdf: { // map with 32 bit header
		uint32_t length = extract_uint32(pk);
		int64_t ret = unpack_map_elements_size(pk, length, depth);
		if (ret < 0) {
			return -5;
		}
		return 1 + 4 + ret;
	}

	case 0xd4: // fixext 1
		pk->offset += 1 + 1;
		return 1 + 1 + 1;
	case 0xd5: // fixext 2
		pk->offset += 1 + 2;
		return 1 + 1 + 2;
	case 0xd6: // fixext 4
		pk->offset += 1 + 4;
		return 1 + 1 + 4;
	case 0xd7: // fixext 8
		pk->offset += 1 + 8;
		return 1 + 1 + 8;
	case 0xd8: // fixext 16
		pk->offset += 1 + 16;
		return 1 + 1 + 16;
	case 0xc7: { // ext 8
		uint8_t length = pk->buffer[pk->offset++];
		pk->offset += 1 + length;
		return 1 + 1 + 1 + length;
	}
	case 0xc8: { // ext 16
		uint16_t length = extract_uint16(pk);
		pk->offset += 1 + length;
		return 1 + 2 + 1 + length;
	}
	case 0xc9: { // ext 32
		uint32_t length = extract_uint32(pk);
		pk->offset += 1 + length;
		return 1 + 4 + 1 + length;
	}
	default:
		break;
	}

	if ((type & 0xe0) == 0xa0) { // raw bytes with 8 bit combined header
		int length = type & 0x1f;
		pk->offset += length;
		return 1 + length;
	}

	if ((type & 0xf0) == 0x80) { // map with 8 bit combined header
		int64_t ret = unpack_map_elements_size(pk, type & 0x0f, depth);
		if (ret < 0) {
			return -6;
		}
		return 1 + ret;
	}

	if ((type & 0xf0) == 0x90) { // list with 8 bit combined header
		int64_t ret = unpack_list_elements_size(pk, type & 0x0f, depth);
		if (ret < 0) {
			return -7;
		}
		return 1 + ret;
	}

	if (type < 0x80) { // 8 bit combined unsigned integer
		return 1;
	}

	if (type >= 0xe0) { // 8 bit combined signed integer
		return 1;
	}

	return -8;
}

// Assembly:
movl 0x8(%rdi), %ecx
cmpl 0xc(%rdi), %ecx
jae 0xbb8b
pushq %rax
movq (%rdi), %r9
leaq 0x1(%rcx), %r8
movl %esi, %edx
movl %r8d, 0x8(%rdi)
movzbl (%r9,%rcx), %esi
pushq $0x1
popq %rax
leal -0xc0(%rsi), %r10d
cmpl $0x1f, %r10d
ja 0xbc8d
leaq 0x96b8(%rip), %r11      # 0x1522c
movslq (%r11,%r10,4), %r10
addq %r11, %r10
jmpq *%r10
leal 0x5(%rcx), %eax
movl %eax, 0x8(%rdi)
pushq $0x5
jmp 0xbd10
pushq $-0x1
popq %rax
retq
addl $0x3, %ecx
movl %ecx, 0x8(%rdi)
pushq $0x3
jmp 0xbd10
addl $0x9, %ecx
movl %ecx, 0x8(%rdi)
pushq $0x9
jmp 0xbd10
addl $0x2, %ecx
movl %ecx, 0x8(%rdi)
pushq $0x2
jmp 0xbd10
movl (%r9,%r8), %eax
bswapl %eax
leal 0x5(%rcx,%rax), %ecx
addl $0x5, %eax
jmp 0xbcdb
leal 0x2(%rcx), %eax
movl %eax, 0x8(%rdi)
movzbl (%r9,%r8), %eax
leal 0x2(%rcx,%rax), %ecx
addq $0x2, %rax
jmp 0xbcdb
movzwl 0x1(%r9,%rcx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
leal 0x3(%rcx,%rax), %ecx
addl $0x3, %eax
jmp 0xbcdb
leal 0xa(%rcx), %eax
movl %eax, 0x8(%rdi)
pushq $0xa
jmp 0xbd10
leal 0x4(%rcx), %eax
movl %eax, 0x8(%rdi)
pushq $0x4
jmp 0xbd10
movzwl 0x1(%r9,%rcx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
leal 0x4(%rcx,%rax), %ecx
addl $0x4, %eax
jmp 0xbcdb
movl (%r9,%r8), %esi
leal 0x5(%rcx), %eax
movl %eax, 0x8(%rdi)
bswapl %esi
callq 0xc50e
leaq 0x5(%rax), %rcx
testq %rax, %rax
pushq $-0x3
jmp 0xbd01
movzwl 0x1(%r9,%rcx), %eax
addl $0x3, %ecx
movl %ecx, 0x8(%rdi)
rolw $0x8, %ax
movzwl %ax, %esi
callq 0xc5a7
leaq 0x3(%rax), %rcx
testq %rax, %rax
pushq $-0x4
jmp 0xbd01
movl (%r9,%r8), %eax
bswapl %eax
leal 0x6(%rcx,%rax), %ecx
addl $0x6, %eax
jmp 0xbcdb
addl $0x6, %ecx
movl %ecx, 0x8(%rdi)
pushq $0x6
jmp 0xbd10
movl %esi, %ecx
andl $-0x20, %ecx
cmpl $0xa0, %ecx
jne 0xbd16
andl $0x1f, %esi
leal (%rsi,%r8), %eax
incq %rsi
movl %eax, 0x8(%rdi)
movq %rsi, %rax
jmp 0xbd11
movl (%r9,%r8), %esi
leal 0x5(%rcx), %eax
movl %eax, 0x8(%rdi)
bswapl %esi
callq 0xc5a7
leaq 0x5(%rax), %rcx
testq %rax, %rax
pushq $-0x5
jmp 0xbd01
leal 0x2(%rcx), %eax
movl %eax, 0x8(%rdi)
movzbl (%r9,%r8), %eax
leal 0x3(%rcx,%rax), %ecx
addq $0x3, %rax
movl %ecx, 0x8(%rdi)
jmp 0xbd11
movzwl 0x1(%r9,%rcx), %eax
addl $0x3, %ecx
movl %ecx, 0x8(%rdi)
rolw $0x8, %ax
movzwl %ax, %esi
callq 0xc50e
leaq 0x3(%rax), %rcx
testq %rax, %rax
pushq $-0x2
popq %rax
cmovnsq %rcx, %rax
jmp 0xbd11
addl $0x12, %ecx
movl %ecx, 0x8(%rdi)
pushq $0x12
popq %rax
addq $0x8, %rsp
retq
movl %esi, %ecx
andb $-0x10, %cl
cmpb $-0x70, %cl
je 0xbd40
movl %esi, %ecx
andl $-0x10, %ecx
cmpl $0x80, %ecx
jne 0xbd53
andl $0xf, %esi
callq 0xc5a7
leaq 0x1(%rax), %rcx
testq %rax, %rax
pushq $-0x6
jmp 0xbd01
andl $0xf, %esi
callq 0xc50e
leaq 0x1(%rax), %rcx
testq %rax, %rax
pushq $-0x7
jmp 0xbd01
testb %sil, %sil
jns 0xbd11
xorl %eax, %eax
cmpb $-0x20, %sil
setae %al
leaq -0x8(%rax,%rax,8), %rax
jmp 0xbd11