// File: /workspace/github_c_makefile_star2_O1/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
movq $-0x1, %rax
cmpl 0xc(%rdi), %ecx
jae 0xcf2f
pushq %rax
movl %esi, %edx
movq (%rdi), %r8
leal 0x1(%rcx), %r9d
movl %r9d, 0x8(%rdi)
movzbl (%r8,%rcx), %esi
movl $0x1, %eax
leal -0xc0(%rsi), %r10d
cmpl $0x1f, %r10d
ja 0xce9d
leaq 0xb4e7(%rip), %r11      # 0x1822c
movslq (%r11,%r10,4), %r10
addq %r11, %r10
jmpq *%r10
addl $0x5, %ecx
movl %ecx, 0x8(%rdi)
movl $0x5, %eax
jmp 0xcf2b
addl $0x3, %ecx
movl %ecx, 0x8(%rdi)
movl $0x3, %eax
jmp 0xcf2b
addl $0x9, %ecx
movl %ecx, 0x8(%rdi)
movl $0x9, %eax
jmp 0xcf2b
addl $0x2, %ecx
movl %ecx, 0x8(%rdi)
movl $0x2, %eax
jmp 0xcf2b
movl %r9d, %eax
movl (%r8,%rax), %eax
bswapl %eax
leal 0x5(%rcx,%rax), %ecx
movl %ecx, 0x8(%rdi)
addl $0x5, %eax
jmp 0xcf2b
leal 0x2(%rcx), %eax
movl %eax, 0x8(%rdi)
movl %r9d, %eax
movzbl (%r8,%rax), %eax
leal 0x2(%rcx,%rax), %ecx
movl %ecx, 0x8(%rdi)
addq $0x2, %rax
jmp 0xcf2b
movl %r9d, %eax
movzwl (%r8,%rax), %eax
rolw $0x8, %ax
movzwl %ax, %eax
leal 0x3(%rcx,%rax), %ecx
movl %ecx, 0x8(%rdi)
addl $0x3, %eax
jmp 0xcf2b
addl $0xa, %ecx
movl %ecx, 0x8(%rdi)
movl $0xa, %eax
jmp 0xcf2b
addl $0x4, %ecx
movl %ecx, 0x8(%rdi)
movl $0x4, %eax
jmp 0xcf2b
movl %r9d, %eax
movzwl (%r8,%rax), %eax
rolw $0x8, %ax
movzwl %ax, %eax
leal 0x4(%rcx,%rax), %ecx
movl %ecx, 0x8(%rdi)
addl $0x4, %eax
jmp 0xcf2b
movl %r9d, %eax
movl (%r8,%rax), %esi
bswapl %esi
addl $0x5, %ecx
movl %ecx, 0x8(%rdi)
callq 0xd847
leaq 0x5(%rax), %rcx
testq %rax, %rax
movq $-0x3, %rax
jmp 0xcf27
movl %r9d, %eax
movzwl (%r8,%rax), %eax
rolw $0x8, %ax
addl $0x3, %ecx
movl %ecx, 0x8(%rdi)
movzwl %ax, %esi
callq 0xd8ec
leaq 0x3(%rax), %rcx
testq %rax, %rax
movq $-0x4, %rax
jmp 0xcf27
movl %r9d, %eax
movl (%r8,%rax), %eax
bswapl %eax
leal 0x6(%rcx,%rax), %ecx
movl %ecx, 0x8(%rdi)
addl $0x6, %eax
jmp 0xcf2b
addl $0x6, %ecx
movl %ecx, 0x8(%rdi)
movl $0x6, %eax
jmp 0xcf2b
movl %esi, %ecx
andl $-0x20, %ecx
cmpl $0xa0, %ecx
jne 0xcf3d
andl $0x1f, %esi
addl %esi, %r9d
movl %r9d, 0x8(%rdi)
incq %rsi
movq %rsi, %rax
jmp 0xcf2b
movl %r9d, %eax
movl (%r8,%rax), %esi
bswapl %esi
addl $0x5, %ecx
movl %ecx, 0x8(%rdi)
callq 0xd8ec
leaq 0x5(%rax), %rcx
testq %rax, %rax
movq $-0x5, %rax
jmp 0xcf27
leal 0x2(%rcx), %eax
movl %eax, 0x8(%rdi)
movl %r9d, %eax
movzbl (%r8,%rax), %eax
leal 0x3(%rcx,%rax), %ecx
movl %ecx, 0x8(%rdi)
addq $0x3, %rax
jmp 0xcf2b
movl %r9d, %eax
movzwl (%r8,%rax), %eax
rolw $0x8, %ax
addl $0x3, %ecx
movl %ecx, 0x8(%rdi)
movzwl %ax, %esi
callq 0xd847
leaq 0x3(%rax), %rcx
testq %rax, %rax
movq $-0x2, %rax
cmovnsq %rcx, %rax
addq $0x8, %rsp
retq
addl $0x12, %ecx
movl %ecx, 0x8(%rdi)
movl $0x12, %eax
jmp 0xcf2b
movl %esi, %ecx
andb $-0x10, %cl
cmpb $-0x70, %cl
je 0xcf6c
movl %esi, %ecx
andl $-0x10, %ecx
cmpl $0x80, %ecx
jne 0xcf84
andl $0xf, %esi
callq 0xd8ec
leaq 0x1(%rax), %rcx
testq %rax, %rax
movq $-0x6, %rax
jmp 0xcf27
andl $0xf, %esi
callq 0xd847
leaq 0x1(%rax), %rcx
testq %rax, %rax
movq $-0x7, %rax
jmp 0xcf27
testb %sil, %sil
jns 0xcf2b
xorl %eax, %eax
cmpb $-0x20, %sil
setae %al
leaq -0x8(%rax,%rax,8), %rax
jmp 0xcf2b