// File: /workspace/github_c_makefile_star2_O2/aerospike[P]aerospike-common/src/main/aerospike/as_msgpack.c
// Function: as_pack_val
int
as_pack_val(as_packer *pk, const as_val *val)
{
	if (! val) {
		return -1;
	}

	int rc = 0;

	// TODO - Make all of these const.
	switch (as_val_type(val)) {
	case AS_NIL:
		rc = pack_byte(pk, 0xc0, true);
		break;
	case AS_BOOLEAN:
		rc = pack_as_boolean(pk, (const as_boolean *)val);
		break;
	case AS_INTEGER:
		rc = pack_as_integer(pk, (const as_integer *)val);
		break;
	case AS_DOUBLE:
		rc = pack_as_double(pk, (const as_double *)val);
		break;
	case AS_STRING:
		rc = pack_string(pk, (as_string *)val);
		break;
	case AS_BYTES:
		rc = pack_bytes(pk, (const as_bytes *)val);
		break;
	case AS_LIST:
		rc = pack_list(pk, (as_list *)val);
		break;
	case AS_MAP:
		rc = pack_map(pk, (const as_map *)val);
		break;
	case AS_REC:
		rc = pack_rec(pk, (const as_rec *)val);
		break;
	case AS_PAIR:
		rc = pack_pair(pk, (as_pair *)val);
		break;
	case AS_GEOJSON:
		rc = pack_geojson(pk, (as_geojson *)val);
		break;
	case AS_CMP_WILDCARD:
		rc = as_pack_wildcard_internal(pk, true);
		break;
	case AS_CMP_INF:
		rc = as_pack_inf_internal(pk, true);
		break;
	default:
		return -2;
	}

	return rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
pushq $-0x1
popq %rbp
testq %rsi, %rsi
je 0xab27
movzbl 0x4(%rsi), %ecx
movq %rsi, %r14
pushq $-0x2
popq %rax
decl %ecx
cmpl $0xd, %ecx
ja 0xab29
leaq 0xa7c2(%rip), %rdx      # 0x150d4
movq %rdi, %rbx
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl $0xc0, %esi
jmp 0xaa4a
movq %r14, %rdi
callq 0x8aa0
leal 0x1(%rax), %esi
movq %rbx, %rdi
movq %rax, %r15
callq 0xb547
testl %eax, %eax
jne 0xab27
pushq $0x17
jmp 0xa9f6
movq %r14, %rdi
callq 0xc37c
cmpl $0xf, %eax
ja 0xaae2
orb $-0x70, %al
movzbl %al, %esi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0xabce
jmp 0xab64
pushq $0x1
popq %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xac3c
movq %r14, %rdi
callq 0xc3b4
movl 0x8(%r14), %ecx
testb $0x1, %cl
jne 0xaafe
testb $0x2, %cl
jne 0xab27
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %eax, %esi
callq 0xb8b9
jmp 0xab96
pushq $0x1
popq %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xac2b
movq %r14, %rdi
callq 0x8320
movq %rax, %r15
leal 0x1(%rax), %esi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0xb653
testl %eax, %eax
jne 0xab27
pushq $0x3
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0xabce
testl %eax, %eax
movl %ebp, %eax
jne 0xab29
movq 0x10(%r14), %rsi
pushq $0x1
popq %rcx
movq %rbx, %rdi
movl %r15d, %edx
jmp 0xaad3
movq 0x8(%r14), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xb406
cmpb $0x1, 0x8(%r14)
movl $0xc3, %esi
sbbl $0x0, %esi
pushq $0x1
popq %rdx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xabce
pushq $0x1
jmp 0xaa7c
leaq 0x7(%rsp), %rsi
movb $-0x6e, (%rsi)
pushq $0x1
popq %rcx
movq %rbx, %rdi
movl %ecx, %edx
callq 0xb54f
testl %eax, %eax
je 0xab34
pushq $-0x1
popq %rax
jmp 0xab29
movsd 0x8(%r14), %xmm0
pushq $0x1
popq %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xb4f1
movl 0xc(%r14), %esi
movq %rbx, %rdi
incl %esi
callq 0xb547
testl %eax, %eax
jne 0xab27
movzbl 0x1c(%r14), %esi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0xabce
testl %eax, %eax
movl %ebp, %eax
jne 0xab29
movq 0x10(%r14), %rsi
movl 0xc(%r14), %edx
pushq $0x1
popq %rcx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xb54f
cmpl $0xffff, %eax           # imm = 0xFFFF
ja 0xab52
movzwl %ax, %edx
pushq $0x1
popq %rcx
movq %rbx, %rdi
movl $0xdc, %esi
callq 0xb7ef
jmp 0xab64
incl %eax
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %eax, %esi
callq 0xb8b9
testl %eax, %eax
jne 0xab27
movzbl 0x8(%r14), %edx
pushq $0x1
popq %rcx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xb923
testl %eax, %eax
je 0xab8b
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0x8ad0
testl %eax, %eax
jne 0xab29
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x8ad0
jmp 0xab29
pushq $0x1
popq %rcx
movq %rbx, %rdi
movl $0xdd, %esi
movl %eax, %edx
callq 0xb47d
testl %eax, %eax
movl %ebp, %eax
jne 0xab29
movq 0x10(%r14), %rcx
pushq $0x1
popq %rax
testq %rcx, %rcx
je 0xab29
movq 0xf0(%rcx), %rcx
testq %rcx, %rcx
je 0xab29
leaq 0x18c8(%rip), %rsi      # 0xc451
jmp 0xabbc
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xb2f2
testl %eax, %eax
movl %ebp, %eax
jne 0xab29
movq 0x10(%r14), %rcx
pushq $0x1
popq %rax
testq %rcx, %rcx
je 0xab29
movq 0x40(%rcx), %rcx
testq %rcx, %rcx
je 0xab29
leaq 0x18ab(%rip), %rsi      # 0xc467
movq %r14, %rdi
movq %rbx, %rdx
callq *%rcx
xorb $0x1, %al
movzbl %al, %eax
jmp 0xab29