// File: /workspace/github_c_makefile_star2_O3/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 0xc51d
movl %esi, %ebp
testl %esi, %esi
jne 0xc530
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
cmpq 0x8(%rbx), %rdx
jae 0xc57c
movq 0x10(%rbx), %rax
jmp 0xc5c8
movl (%r14), %esi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xcb8d
testl %ecx, %ecx
cmovlel %ebp, %ecx
testl %ebp, %ebp
jle 0xc5df
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 0xc54b
jmp 0xc5e9
movq %rdx, %rax
shrq %rax
orq %rdx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2330
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
xorl %edx, %edx
movb %dl, (%rax,%rcx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb %dl, (%rcx,%rax)
jmp 0xc82e
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 0xc6c1
movq %rbx, %rdi
movl %ecx, %esi
movl $0x1, %edx
callq 0xc837
testl %ebp, %ebp
jle 0xc82e
movl %ebp, %r15d
xorl %r12d, %r12d
movl (%r14,%r12,4), %eax
movl %eax, %ecx
negl %ecx
jo 0xc63c
movb $-0x7f, %bpl
cmpl $0x80000001, %eax       # imm = 0x80000001
je 0xc63f
movl %eax, %ebp
jmp 0xc63f
movb $-0x80, %bpl
movq (%rbx), %rdx
leaq 0x1(%rdx), %rcx
cmpq 0x8(%rbx), %rcx
jae 0xc652
movq 0x10(%rbx), %rax
jmp 0xc69e
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2330
movq %rax, 0x10(%rbx)
movq (%rbx), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, (%rbx)
movb %bpl, (%rax,%rdx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb $0x0, (%rcx,%rax)
incq %r12
cmpq %r12, %r15
jne 0xc624
jmp 0xc82e
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 0xc799
movl $0x2, %edx
callq 0xc837
testl %ebp, %ebp
jle 0xc82e
movl %ebp, %r15d
xorl %r12d, %r12d
movl (%r14,%r12,4), %eax
movl %eax, %ecx
negl %ecx
jo 0xc712
movw $0x8001, %bp            # imm = 0x8001
cmpl $0x80000001, %eax       # imm = 0x80000001
je 0xc716
movl %eax, %ebp
jmp 0xc716
movw $0x8000, %bp            # imm = 0x8000
movq (%rbx), %rcx
leaq 0x3(%rcx), %rax
cmpq 0x8(%rbx), %rax
jae 0xc729
movq 0x10(%rbx), %rax
jmp 0xc771
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), %rcx
movw %bp, (%rax,%rcx)
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 0xc6f9
jmp 0xc82e
movl $0x3, %edx
callq 0xc837
testl %ebp, %ebp
jle 0xc82e
movl %ebp, %r15d
xorl %r12d, %r12d
movq (%rbx), %rcx
leaq 0x5(%rcx), %rax
cmpq 0x8(%rbx), %rax
jae 0xc7c4
movq 0x10(%rbx), %rax
jmp 0xc80c
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), %rcx
movl (%r14,%r12,4), %edx
movl %edx, (%rax,%rcx)
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 0xc7b1
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq