// File: /workspace/github_c_makefile_star2_O0/aerospike[P]aerospike-common/src/main/aerospike/as_msgpack.c
// Function: as_unpack_peek_type
as_val_t
as_unpack_peek_type(const as_unpacker *pk)
{
	if (pk->length <= pk->offset) {
		return AS_UNDEF;
	}

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

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

	case 0xc3: // boolean true
	case 0xc2: // boolean false
		return AS_BOOLEAN;

	case 0xd0: // signed 8 bit integer
	case 0xcc: // unsigned 8 bit integer
	case 0xd1: // signed 16 bit integer
	case 0xcd: // unsigned 16 bit integer
	case 0xd2: // signed 32 bit integer
	case 0xce: // unsigned 32 bit integer
	case 0xd3: // signed 64 bit integer
	case 0xcf: // unsigned 64 bit integer
		return AS_INTEGER;

	case 0xca: // float
	case 0xcb: // double
		return AS_DOUBLE;

	case 0xc4:
	case 0xd9: { // string/raw bytes with 8 bit header
		uint8_t type1 = pk->buffer[pk->offset + 2];
		return bytes_internal_type_to_as_val_t(type1);
	}

	case 0xc5:
	case 0xda: { // string/raw bytes with 16 bit header
		uint8_t type1 = pk->buffer[pk->offset + 3];
		return bytes_internal_type_to_as_val_t(type1);
	}

	case 0xc6:
	case 0xdb: { // string/raw bytes with 32 bit header
		uint8_t type1 = pk->buffer[pk->offset + 5];
		return bytes_internal_type_to_as_val_t(type1);
	}

	case 0xdc: // list with 16 bit header
	case 0xdd: // list with 32 bit header
		return AS_LIST;

	case 0xde: // map with 16 bit header
	case 0xdf: // map with 32 bit header
		return AS_MAP;

	case 0xd4: { // fixext1
		uint8_t ext_type = pk->buffer[pk->offset + 1];

		if (ext_type == ASVAL_CMP_EXT_TYPE) {
			uint8_t data = pk->buffer[pk->offset + 2];

			if (data == ASVAL_CMP_WILDCARD) {
				return AS_CMP_WILDCARD;
			}

			if (data == ASVAL_CMP_INF) {
				return AS_CMP_INF;
			}
		}

		return AS_CMP_EXT;
	}
	case 0xd5: // fixext2
	case 0xd6: // fixext4
	case 0xd7: // fixext8
	case 0xd8: // fixext16
	case 0xc7: // ext8
	case 0xc8: // ext16
	case 0xc9: // ext32
		return AS_CMP_EXT;
	default:
		if ((type & 0xe0) == 0xa0) { // raw bytes with 8 bit combined header
			uint8_t type1 = pk->buffer[pk->offset + 1];
			return bytes_internal_type_to_as_val_t(type1);
		}

		if ((type & 0xf0) == 0x80) { // map with 8 bit combined header
			return AS_MAP;
		}

		if ((type & 0xf0) == 0x90) { // list with 8 bit combined header
			return AS_LIST;
		}

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

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

		break;
	}

	return AS_UNDEF;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
ja 0xfb45
movb $0x0, -0x1(%rbp)
jmp 0xfd35
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movl 0x8(%rcx), %ecx
movb (%rax,%rcx), %al
movb %al, -0x11(%rbp)
movzbl -0x11(%rbp), %eax
addl $0xffffff40, %eax       # imm = 0xFFFFFF40
movl %eax, %ecx
movq %rcx, -0x20(%rbp)
subl $0x1f, %eax
ja 0xfcaa
movq -0x20(%rbp), %rax
leaq 0x17618(%rip), %rcx     # 0x27190
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x1, -0x1(%rbp)
jmp 0xfd35
movb $0x2, -0x1(%rbp)
jmp 0xfd35
movb $0x3, -0x1(%rbp)
jmp 0xfd35
movb $0xa, -0x1(%rbp)
jmp 0xfd35
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %al
movb %al, -0x12(%rbp)
movzbl -0x12(%rbp), %edi
callq 0xfd40
movb %al, -0x1(%rbp)
jmp 0xfd35
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %al
movb %al, -0x13(%rbp)
movzbl -0x13(%rbp), %edi
callq 0xfd40
movb %al, -0x1(%rbp)
jmp 0xfd35
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
addl $0x5, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %al
movb %al, -0x14(%rbp)
movzbl -0x14(%rbp), %edi
callq 0xfd40
movb %al, -0x1(%rbp)
jmp 0xfd35
movb $0x5, -0x1(%rbp)
jmp 0xfd35
movb $0x6, -0x1(%rbp)
jmp 0xfd35
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %al
movb %al, -0x15(%rbp)
movzbl -0x15(%rbp), %eax
cmpl $0xff, %eax
jne 0xfc98
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %al
movb %al, -0x16(%rbp)
movzbl -0x16(%rbp), %eax
cmpl $0x0, %eax
jne 0xfc84
movb $0xd, -0x1(%rbp)
jmp 0xfd35
movzbl -0x16(%rbp), %eax
cmpl $0x1, %eax
jne 0xfc96
movb $0xe, -0x1(%rbp)
jmp 0xfd35
jmp 0xfc98
movb $0xc, -0x1(%rbp)
jmp 0xfd35
movb $0xc, -0x1(%rbp)
jmp 0xfd35
movzbl -0x11(%rbp), %eax
andl $0xe0, %eax
cmpl $0xa0, %eax
jne 0xfce1
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %al
movb %al, -0x17(%rbp)
movzbl -0x17(%rbp), %edi
callq 0xfd40
movb %al, -0x1(%rbp)
jmp 0xfd35
movzbl -0x11(%rbp), %eax
andl $0xf0, %eax
cmpl $0x80, %eax
jne 0xfcf7
movb $0x6, -0x1(%rbp)
jmp 0xfd35
movzbl -0x11(%rbp), %eax
andl $0xf0, %eax
cmpl $0x90, %eax
jne 0xfd0d
movb $0x5, -0x1(%rbp)
jmp 0xfd35
movzbl -0x11(%rbp), %eax
cmpl $0x80, %eax
jge 0xfd1e
movb $0x3, -0x1(%rbp)
jmp 0xfd35
movzbl -0x11(%rbp), %eax
cmpl $0xe0, %eax
jl 0xfd2f
movb $0x3, -0x1(%rbp)
jmp 0xfd35
jmp 0xfd31
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x20, %rsp
popq %rbp
retq
nop