// File: /workspace/github_c_makefile_star2_O0/aerospike[P]aerospike-common/src/main/aerospike/as_msgpack.c
// Function: unpack_str_bin
static inline const uint8_t *
unpack_str_bin(as_unpacker *pk, uint32_t *sz_r)
{
	if (pk->offset >= pk->length) {
		return NULL;
	}

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

	switch (type) {
	case 0xd9:
	case 0xc4: // str/bin with 8 bit header
		if (size < 1) {
			return NULL;
		}
		*sz_r = (uint32_t)pk->buffer[pk->offset++];
		break;
	case 0xc5:
	case 0xda: // str/bin with 16 bit header
		if (size < 2) {
			return NULL;
		}
		*sz_r = (uint32_t)extract_uint16(pk);
		break;
	case 0xc6:
	case 0xdb: // str/bin with 32 bit header
		if (size < 4) {
			return NULL;
		}
		*sz_r = extract_uint32(pk);
		break;
	default:
		if ((type & 0xe0) == 0xa0) { // str bytes with 8 bit combined header
			*sz_r = (uint32_t)(type & 0x1f);
			break;
		}

		return NULL;
	}

	const uint8_t *buf = &pk->buffer[pk->offset];

	pk->offset += *sz_r;

	if (pk->offset > pk->length) {
		return NULL;
	}

	return buf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jb 0x107fd
movq $0x0, -0x8(%rbp)
jmp 0x1096a
movq -0x10(%rbp), %rdx
movq (%rdx), %rax
movl 0x8(%rdx), %ecx
movl %ecx, %esi
incl %esi
movl %esi, 0x8(%rdx)
movb (%rax,%rcx), %al
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movl 0xc(%rax), %eax
subl %ecx, %eax
movl %eax, -0x20(%rbp)
movzbl -0x19(%rbp), %eax
movl %eax, -0x2c(%rbp)
subl $0xc4, %eax
je 0x10876
jmp 0x10833
movl -0x2c(%rbp), %eax
subl $0xc5, %eax
je 0x108ad
jmp 0x1083f
movl -0x2c(%rbp), %eax
subl $0xc6, %eax
je 0x108d4
jmp 0x1084f
movl -0x2c(%rbp), %eax
subl $0xd9, %eax
je 0x10876
jmp 0x1085b
movl -0x2c(%rbp), %eax
subl $0xda, %eax
je 0x108ad
jmp 0x10867
movl -0x2c(%rbp), %eax
subl $0xdb, %eax
je 0x108d4
jmp 0x108fa
cmpl $0x1, -0x20(%rbp)
jae 0x10889
movq $0x0, -0x8(%rbp)
jmp 0x1096a
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rdx
movl 0x8(%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x8(%rdx)
movl %ecx, %ecx
movzbl (%rax,%rcx), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x10923
cmpl $0x2, -0x20(%rbp)
jae 0x108c0
movq $0x0, -0x8(%rbp)
jmp 0x1096a
movq -0x10(%rbp), %rdi
callq 0xe6a0
movzwl %ax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x10923
cmpl $0x4, -0x20(%rbp)
jae 0x108e7
movq $0x0, -0x8(%rbp)
jmp 0x1096a
movq -0x10(%rbp), %rdi
callq 0xe6f0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x10923
movzbl -0x19(%rbp), %eax
andl $0xe0, %eax
cmpl $0xa0, %eax
jne 0x10919
movzbl -0x19(%rbp), %ecx
andl $0x1f, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x10923
movq $0x0, -0x8(%rbp)
jmp 0x1096a
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jbe 0x10962
movq $0x0, -0x8(%rbp)
jmp 0x1096a
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop