// File: /workspace/github_c_makefile_star2_O3/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 %r12
pushq %rbx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rsi, %rsi
je 0xb0f6
movq %rsi, %r15
movq %rdi, %r14
movzbl 0x4(%r15), %eax
cmpl $0x8, %eax
jne 0xaaa2
movq 0x10(%r14), %rax
testq %rax, %rax
je 0xaa6b
movl 0x18(%r14), %ecx
leal 0x1(%rcx), %edx
cmpl 0x1c(%r14), %edx
jbe 0xaa65
movq %r14, %rdi
movl $0x1, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rax
movl 0x18(%r14), %ecx
movl %ecx, %ecx
movb $-0x6e, (%rax,%rcx)
movl 0x18(%r14), %eax
cmpl $0x7ffffffe, %eax       # imm = 0x7FFFFFFE
ja 0xb0f6
incl %eax
movq %r14, %rdi
movl %eax, 0x18(%r14)
movq 0x8(%r15), %rsi
callq 0x8a00
testl %eax, %eax
jne 0xaf27
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0xaa28
jmp 0xb0f6
decl %eax
cmpl $0xd, %eax
ja 0xaf1d
leaq 0xd620(%rip), %rcx      # 0x180d4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%r14), %rax
testq %rax, %rax
je 0xaced
movl 0x18(%r14), %ecx
leal 0x1(%rcx), %edx
cmpl 0x1c(%r14), %edx
jbe 0xaaf4
movq %r14, %rdi
movl $0x1, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rax
movl 0x18(%r14), %ecx
movl %ecx, %ecx
movb $-0x40, (%rax,%rcx)
jmp 0xaced
movq %r14, %rdi
movl $0x1, %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xb172
movl 0xc(%r15), %esi
movq %r14, %rdi
movl $0x1, %edx
incl %esi
callq 0xc10b
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rax
testq %rax, %rax
je 0xab6c
movl 0x18(%r14), %ecx
movb 0x1c(%r15), %bpl
leal 0x1(%rcx), %edx
cmpl 0x1c(%r14), %edx
jbe 0xab66
movq %r14, %rdi
movl $0x1, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rax
movl 0x18(%r14), %ecx
movl %ecx, %ecx
movb %bpl, (%rax,%rcx)
movl 0x18(%r14), %eax
cmpl $0x7ffffffe, %eax       # imm = 0x7FFFFFFE
ja 0xb0f6
incl %eax
movl %eax, 0x18(%r14)
movq 0x10(%r14), %rcx
movl 0xc(%r15), %r12d
testq %rcx, %rcx
je 0xabcb
leal (%r12,%rax), %edx
movq 0x10(%r15), %r15
cmpl 0x1c(%r14), %edx
jbe 0xabb7
movq %r14, %rdi
movl %r12d, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rcx
movl 0x18(%r14), %eax
movl %eax, %edi
movq %r15, %rsi
movq %r12, %rdx
addq %rcx, %rdi
callq 0x85c0
movl 0x18(%r14), %eax
movl %eax, %eax
addq %rax, %r12
cmpq $0x7fffffff, %r12       # imm = 0x7FFFFFFF
ja 0xb0f6
movl %r12d, 0x18(%r14)
jmp 0xad02
movq 0x10(%r14), %rax
testq %rax, %rax
je 0xac2b
movl 0x18(%r14), %ecx
movq 0x8(%r15), %r15
leal 0x9(%rcx), %edx
cmpl 0x1c(%r14), %edx
jbe 0xac1d
movq %r14, %rdi
movl $0x9, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rax
movl 0x18(%r14), %ecx
movl %ecx, %ecx
bswapq %r15
movb $-0x35, (%rax,%rcx)
movq %r15, 0x1(%rax,%rcx)
movl 0x18(%r14), %eax
cmpl $0x7ffffff6, %eax       # imm = 0x7FFFFFF6
ja 0xb0f6
addl $0x9, %eax
jmp 0xacfe
movq %r15, %rdi
callq 0x8310
leal 0x1(%rax), %esi
movq %r14, %rdi
movl $0x1, %edx
movq %rax, %r12
callq 0xc10b
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rax
testq %rax, %rax
je 0xaea1
movl 0x18(%r14), %ecx
leal 0x1(%rcx), %edx
cmpl 0x1c(%r14), %edx
jbe 0xac9c
movq %r14, %rdi
movl $0x1, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rax
movl 0x18(%r14), %ecx
movl %ecx, %ecx
movb $0x3, (%rax,%rcx)
jmp 0xaea1
cmpb $0x0, 0x8(%r15)
movq 0x10(%r14), %rax
sete %bpl
testq %rax, %rax
je 0xaced
movl 0x18(%r14), %ecx
leal 0x1(%rcx), %edx
cmpl 0x1c(%r14), %edx
jbe 0xace3
movq %r14, %rdi
movl $0x1, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rax
movl 0x18(%r14), %ecx
xorb $-0x3d, %bpl
movl %ecx, %ecx
movb %bpl, (%rax,%rcx)
movl 0x18(%r14), %eax
cmpl $0x7ffffffe, %eax       # imm = 0x7FFFFFFE
ja 0xb0f6
incl %eax
movl %eax, 0x18(%r14)
xorl %ebx, %ebx
jmp 0xb0f6
movq 0x8(%r15), %rsi
movq %r14, %rdi
movl $0x1, %edx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xbcc9
movq 0x10(%r15), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0xad44
movq 0x10(%rcx), %rcx
testq %rcx, %rcx
je 0xad44
movq %r15, %rdi
callq *%rcx
cmpl $0xf, %eax
ja 0xb032
movq 0x10(%r14), %rsi
testq %rsi, %rsi
je 0xad83
movl 0x18(%r14), %ecx
movl %eax, %ebp
leal 0x1(%rcx), %edx
cmpl 0x1c(%r14), %edx
jbe 0xad79
movq %r14, %rdi
movl $0x1, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rsi
movl 0x18(%r14), %ecx
orb $-0x70, %bpl
movl %ecx, %ecx
movb %bpl, (%rsi,%rcx)
movl 0x18(%r14), %eax
cmpl $0x7ffffffe, %eax       # imm = 0x7FFFFFFE
ja 0xb0f6
incl %eax
movl %eax, 0x18(%r14)
movq 0x10(%r15), %rax
testq %rax, %rax
je 0xae3b
movq 0xf0(%rax), %rax
movl $0x1, %ebx
testq %rax, %rax
je 0xb0f6
leaq 0x28a5(%rip), %rsi      # 0xd666
jmp 0xae29
movq 0x10(%r15), %rax
xorl %esi, %esi
testq %rax, %rax
je 0xadde
movq 0x10(%rax), %rax
testq %rax, %rax
je 0xadde
movq %r15, %rdi
callq *%rax
movl %eax, %esi
movl 0x8(%r15), %eax
testb $0x1, %al
jne 0xaf2e
testb $0x2, %al
jne 0xb0f6
movq %r14, %rdi
movl $0x1, %edx
callq 0xc656
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r15), %rax
testq %rax, %rax
je 0xae3b
movq 0x40(%rax), %rax
movl $0x1, %ebx
testq %rax, %rax
je 0xb0f6
leaq 0x2853(%rip), %rsi      # 0xd67c
movq %r15, %rdi
movq %r14, %rdx
callq *%rax
xorb $0x1, %al
movzbl %al, %ebx
jmp 0xb0f6
movl $0x1, %ebx
jmp 0xb0f6
movq %r15, %rdi
callq 0x89e0
leal 0x1(%rax), %esi
movq %r14, %rdi
movl $0x1, %edx
movq %rax, %r12
callq 0xc10b
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rax
testq %rax, %rax
je 0xaea1
movl 0x18(%r14), %ecx
leal 0x1(%rcx), %edx
cmpl 0x1c(%r14), %edx
jbe 0xae9b
movq %r14, %rdi
movl $0x1, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rax
movl 0x18(%r14), %ecx
movl %ecx, %ecx
movb $0x17, (%rax,%rcx)
movl 0x18(%r14), %eax
cmpl $0x7ffffffe, %eax       # imm = 0x7FFFFFFE
ja 0xb0f6
incl %eax
movl %eax, 0x18(%r14)
movq 0x10(%r14), %rcx
testq %rcx, %rcx
je 0xb095
leal (%rax,%r12), %edx
movq 0x10(%r15), %r15
cmpl 0x1c(%r14), %edx
jbe 0xaeec
movq %r14, %rdi
movl %r12d, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rcx
movl 0x18(%r14), %eax
movl %eax, %edi
movl %r12d, %r12d
movq %r15, %rsi
addq %rcx, %rdi
movq %r12, %rdx
callq 0x85c0
movl 0x18(%r14), %eax
jmp 0xb098
movq %r14, %rdi
movl $0x1, %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xb109
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
jmp 0xb0f6
movl %eax, %ebx
jmp 0xb0f6
incl %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0xc656
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rax
movb 0x8(%r15), %bpl
testq %rax, %rax
je 0xaf84
movl 0x18(%r14), %ecx
leal 0x2(%rcx), %edx
cmpl 0x1c(%r14), %edx
jbe 0xaf7c
movq %r14, %rdi
movl $0x2, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rax
movl 0x18(%r14), %ecx
movl %ecx, %ecx
movw $0xc7, (%rax,%rcx)
movl 0x18(%r14), %eax
cmpl $0x7ffffffd, %eax       # imm = 0x7FFFFFFD
ja 0xb0f6
addl $0x2, %eax
movl %eax, 0x18(%r14)
movq 0x10(%r14), %rcx
testq %rcx, %rcx
je 0xafd0
cmpl 0x1c(%r14), %eax
jb 0xafc6
movq %r14, %rdi
movl $0x1, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rcx
movl 0x18(%r14), %eax
movl %eax, %eax
movb %bpl, (%rcx,%rax)
movl 0x18(%r14), %eax
cmpl $0x7ffffffe, %eax       # imm = 0x7FFFFFFE
ja 0xb0f6
leal 0x1(%rax), %ecx
movl %ecx, 0x18(%r14)
movq 0x10(%r14), %rdx
testq %rdx, %rdx
je 0xb01b
addl $0x2, %eax
cmpl 0x1c(%r14), %eax
jbe 0xb011
movq %r14, %rdi
movl $0x1, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rdx
movl 0x18(%r14), %ecx
movl %ecx, %eax
movb $-0x40, (%rdx,%rax)
movl 0x18(%r14), %ecx
cmpl $0x7ffffffe, %ecx       # imm = 0x7FFFFFFE
ja 0xb0f6
incl %ecx
movl %ecx, 0x18(%r14)
jmp 0xae07
cmpl $0xffff, %eax           # imm = 0xFFFF
ja 0xb0ae
movq 0x10(%r14), %rsi
testq %rsi, %rsi
je 0xb082
movl 0x18(%r14), %ecx
movl %eax, %ebp
leal 0x3(%rcx), %edx
cmpl 0x1c(%r14), %edx
jbe 0xb06e
movq %r14, %rdi
movl $0x3, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rsi
movl 0x18(%r14), %ecx
movl %ebp, %eax
movl %ecx, %ecx
rolw $0x8, %ax
movb $-0x24, (%rsi,%rcx)
movb %al, 0x1(%rsi,%rcx)
movb %ah, 0x2(%rsi,%rcx)
movl 0x18(%r14), %eax
cmpl $0x7ffffffc, %eax       # imm = 0x7FFFFFFC
ja 0xb0f6
addl $0x3, %eax
jmp 0xad94
movl %r12d, %r12d
movl %eax, %eax
addq %r12, %rax
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
ja 0xb0f6
movl %eax, 0x18(%r14)
jmp 0xad02
movq 0x10(%r14), %rsi
testq %rsi, %rsi
je 0xb0eb
movl 0x18(%r14), %ecx
movl %eax, %ebp
leal 0x5(%rcx), %edx
cmpl 0x1c(%r14), %edx
jbe 0xb0df
movq %r14, %rdi
movl $0x5, %esi
callq 0xd5db
testl %eax, %eax
jne 0xb0f6
movq 0x10(%r14), %rsi
movl 0x18(%r14), %ecx
movl %ecx, %ecx
bswapl %ebp
movb $-0x23, (%rsi,%rcx)
movl %ebp, 0x1(%rsi,%rcx)
movl 0x18(%r14), %eax
cmpl $0x7ffffffa, %eax       # imm = 0x7FFFFFFA
jbe 0xb101
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
addl $0x5, %eax
jmp 0xad94