// File: /workspace/github_c_makefile_star2_O2/lh3[P]bgt/vcf.c
// Function: bcf_enc_vint
void bcf_enc_vint(kstring_t *s, int n, const int32_t *a, int wsize)
{
	int32_t max = INT32_MIN + 1, min = INT32_MAX;
	int i;
	if (n == 0) bcf_enc_size(s, 0, BCF_BT_NULL);
	else if (n == 1) bcf_enc_int1(s, a[0]);
	else {
		if (wsize <= 0) wsize = n;
		for (i = 0; i < n; ++i) { // test min and max to determine the actual integer type
			if (a[i] == bcf_int32_missing || a[i] == bcf_int32_end) continue;
			if (max < a[i]) max = a[i];
			if (min > a[i]) min = a[i];
		}
		if (max <= INT8_MAX && min > bcf_int8_end) { // int8_t
			bcf_enc_size(s, wsize, BCF_BT_INT8);
			for (i = 0; i < n; ++i)
				kputc(a[i] == bcf_int32_end? bcf_int8_end : a[i] == bcf_int32_missing? bcf_int8_missing : a[i], s);
		} else if (max <= INT16_MAX && min > bcf_int16_end) { // int16_t
			bcf_enc_size(s, wsize, BCF_BT_INT16);
			for (i = 0; i < n; ++i) {
				int16_t x = a[i] == bcf_int32_end? bcf_int16_end : a[i] == bcf_int32_missing? bcf_int16_missing : a[i];
				kputsn((char*)&x, 2, s);
			}
		} else { // int32_t
			bcf_enc_size(s, wsize, BCF_BT_INT32);
			for (i = 0; i < n; ++i)
				kputsn((char*)&a[i], 4, s);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rdi, %rbx
cmpl $0x1, %esi
je 0xadc3
testl %esi, %esi
jne 0xaddc
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xaf23
movl (%r14), %esi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xafbb
xorl %edi, %edi
testl %esi, %esi
movl $0x0, %r12d
cmovgl %esi, %r12d
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x80000001, %edx       # imm = 0x80000001
cmpq %rdi, %r12
je 0xae25
movl (%r14,%rdi,4), %r8d
cmpl %r8d, %edx
movl %r8d, %r9d
cmovgl %edx, %r9d
cmpl %r8d, %eax
movl %r8d, %r10d
cmovll %eax, %r10d
cmpl $0x80000002, %r8d       # imm = 0x80000002
cmovgel %r9d, %edx
cmovgel %r10d, %eax
incq %rdi
jmp 0xadf4
testl %ecx, %ecx
cmovgl %ecx, %esi
cmpl $0x80, %edx
setl %cl
cmpl $-0x7e, %eax
setge %dil
andb %cl, %dil
cmpb $0x1, %dil
jne 0xae88
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0xaf23
xorl %r15d, %r15d
pushq $-0x7f
popq %rbp
pushq $-0x80
popq %r13
cmpq %r15, %r12
je 0xaf14
movl (%r14,%r15,4), %eax
movl %eax, %ecx
negl %ecx
jo 0xae78
movl %ebp, %edi
cmpl $0x80000001, %eax       # imm = 0x80000001
je 0xae7b
movl %eax, %edi
jmp 0xae7b
movl %r13d, %edi
movq %rbx, %rsi
callq 0xacb6
incq %r15
jmp 0xae58
cmpl $0x8000, %edx           # imm = 0x8000
setl %cl
cmpl $0xffff8002, %eax       # imm = 0xFFFF8002
setge %al
andb %cl, %al
cmpb $0x1, %al
jne 0xaeed
pushq $0x2
popq %rbp
movq %rbx, %rdi
movl %ebp, %edx
callq 0xaf23
xorl %r13d, %r13d
leaq 0x6(%rsp), %r15
cmpq %r13, %r12
je 0xaf14
movl (%r14,%r13,4), %eax
movl %eax, %ecx
negl %ecx
jo 0xaed2
movw $0x8001, %cx            # imm = 0x8001
cmpl $0x80000001, %eax       # imm = 0x80000001
je 0xaed6
movl %eax, %ecx
jmp 0xaed6
movw $0x8000, %cx            # imm = 0x8000
movw %cx, 0x6(%rsp)
movq %r15, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0xac22
incq %r13
jmp 0xaeb4
pushq $0x3
popq %rdx
movq %rbx, %rdi
callq 0xaf23
pushq $0x4
popq %rbp
subq $0x1, %r12
jb 0xaf14
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0xac22
addq $0x4, %r14
jmp 0xaefb
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq