// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
movq %rdx, %r14
movq %rdi, %rbx
cmpl $0x1, %esi
je 0xc3e6
movl %esi, %ebp
testl %esi, %esi
jne 0xc3f9
movq (%rbx), %rax
incq %rax
cmpq 0x8(%rbx), %rax
jb 0xc3c4
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2330
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
xorl %edx, %edx
movb %dl, (%rcx,%rax)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb %dl, (%rcx,%rax)
jmp 0xc689
movl (%r14), %esi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xc9cd
testl %ecx, %ecx
cmovlel %ebp, %ecx
testl %ebp, %ebp
jle 0xc441
movl %ebp, %esi
movl $0x80000001, %edx       # imm = 0x80000001
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %edi, %edi
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
cmpq %rdi, %rsi
jne 0xc410
jmp 0xc44b
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x80000001, %edx       # imm = 0x80000001
cmpl $0x80, %edx
setl %sil
cmpl $-0x7e, %eax
setge %dil
andb %sil, %dil
cmpb $0x1, %dil
jne 0xc520
movq %rbx, %rdi
movl %ecx, %esi
movl $0x1, %edx
callq 0xc692
testl %ebp, %ebp
jle 0xc689
movl %ebp, %r15d
xorl %r12d, %r12d
movl (%r14,%r12,4), %eax
movl %eax, %ecx
negl %ecx
jo 0xc49e
movb $-0x7f, %bpl
cmpl $0x80000001, %eax       # imm = 0x80000001
je 0xc4a1
movl %eax, %ebp
jmp 0xc4a1
movb $-0x80, %bpl
movq (%rbx), %rax
incq %rax
cmpq 0x8(%rbx), %rax
jb 0xc4f2
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2330
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movb %bpl, (%rcx,%rax)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb $0x0, (%rcx,%rax)
incq %r12
cmpq %r12, %r15
jne 0xc486
jmp 0xc689
cmpl $0x8000, %edx           # imm = 0x8000
setl %dl
cmpl $0xffff8002, %eax       # imm = 0xFFFF8002
setge %al
andb %dl, %al
movq %rbx, %rdi
movl %ecx, %esi
cmpb $0x1, %al
jne 0xc5f6
movl $0x2, %edx
callq 0xc692
testl %ebp, %ebp
jle 0xc689
movl %ebp, %r15d
xorl %r12d, %r12d
movl (%r14,%r12,4), %eax
movl %eax, %ecx
negl %ecx
jo 0xc571
movw $0x8001, %bp            # imm = 0x8001
cmpl $0x80000001, %eax       # imm = 0x80000001
je 0xc575
movl %eax, %ebp
jmp 0xc575
movw $0x8000, %bp            # imm = 0x8000
movq (%rbx), %rax
addq $0x3, %rax
cmpq 0x8(%rbx), %rax
jb 0xc5c7
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2330
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movw %bp, (%rcx,%rax)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x2(%rax), %rdx
movq %rdx, (%rbx)
movb $0x0, 0x2(%rcx,%rax)
incq %r12
cmpq %r12, %r15
jne 0xc558
jmp 0xc689
movl $0x3, %edx
callq 0xc692
testl %ebp, %ebp
jle 0xc689
movl %ebp, %r15d
xorl %r12d, %r12d
movq (%rbx), %rax
addq $0x5, %rax
cmpq 0x8(%rbx), %rax
jb 0xc660
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2330
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movl (%r14,%r12,4), %edx
movl %edx, (%rcx,%rax)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x4(%rax), %rdx
movq %rdx, (%rbx)
movb $0x0, 0x4(%rcx,%rax)
incq %r12
cmpq %r12, %r15
jne 0xc60e
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq