// File: /workspace/github_c_makefile_star2_O0/aerospike[P]aerospike-common/src/main/aerospike/as_msgpack.c
// Function: unpack_blob
static int
unpack_blob(as_unpacker *pk, uint32_t size, as_val **val)
{
	unsigned char type = 0;

	if (size != 0) {
		type = pk->buffer[pk->offset++];
		size--;
	}

	if (type == AS_BYTES_STRING) {
		char *v = cf_strndup((const char *)pk->buffer + pk->offset, size);
		*val = (as_val*)as_string_new(v, true);
	}
	else if (type == AS_BYTES_GEOJSON) {
		char *v = cf_strndup((const char *)pk->buffer + pk->offset, size);
		*val = (as_val *)as_geojson_new(v, true);
	}
	else {
		as_bytes *b;

		if (size != 0) {
			unsigned char *buf = cf_malloc(size);

			if (! buf) {
				return -1;
			}

			memcpy(buf, pk->buffer + pk->offset, size);
			b = as_bytes_new_wrap(buf, size, true);

			if (! b) {
				cf_free(buf);
				return -2;
			}
		}
		else {
			b = as_bytes_new_wrap(NULL, 0, false);
		}

		if (! b) {
			return -3;
		}

		b->type = (as_bytes_type) type;
		*val = (as_val *)b;
	}

	if (! *val) {
		return -4;
	}

	pk->offset += size;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movb $0x0, -0x21(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xe7d4
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
movb (%rax,%rcx), %al
movb %al, -0x21(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movzbl -0x21(%rbp), %eax
cmpl $0x3, %eax
jne 0xe819
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
addq %rax, %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0x84b0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x8070
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe90d
movzbl -0x21(%rbp), %eax
cmpl $0x17, %eax
jne 0xe85e
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
addq %rax, %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0x84b0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x83e0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe90b
cmpl $0x0, -0x14(%rbp)
je 0xe8d4
movl -0x14(%rbp), %eax
movl %eax, %edi
callq 0x8090
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xe885
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe934
movq -0x48(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
addq %rax, %rsi
movl -0x14(%rbp), %eax
movl %eax, %edx
callq 0x86b0
movq -0x48(%rbp), %rdi
movl -0x14(%rbp), %esi
movl $0x1, %edx
callq 0x8080
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xe8d2
movq -0x48(%rbp), %rdi
callq 0x8aa0
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0xe934
jmp 0xe8e5
xorl %eax, %eax
movl %eax, %edi
xorl %edx, %edx
movl %edx, %esi
callq 0x8080
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xe8f5
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0xe934
movzbl -0x21(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe90d
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xe920
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0xe934
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)