// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/vcf.c
// Function: bcf_enc_vint
int bcf_enc_vint(kstring_t *s, int n, int32_t *a, int wsize)
{
    int32_t max = INT32_MIN, min = INT32_MAX;
    int i;
    if (n <= 0) {
        return bcf_enc_size(s, 0, BCF_BT_NULL);
    } else if (n == 1) {
        return bcf_enc_int1(s, a[0]);
    } else {
        if (wsize <= 0) wsize = n;

        // Equivalent to:
        // for (i = 0; i < n; ++i) {
        //     if (a[i] == bcf_int32_missing || a[i] == bcf_int32_vector_end )
        //         continue;
        //     if (max < a[i]) max = a[i];
        //     if (min > a[i]) min = a[i];
        // }
        int max4[4] = {INT32_MIN, INT32_MIN, INT32_MIN, INT32_MIN};
        int min4[4] = {INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX};
        for (i = 0; i < (n&~3); i+=4) {
            // bcf_int32_missing    == INT32_MIN and
            // bcf_int32_vector_end == INT32_MIN+1.
            // We skip these, but can mostly avoid explicit checking
            if (max4[0] < a[i+0]) max4[0] = a[i+0];
            if (max4[1] < a[i+1]) max4[1] = a[i+1];
            if (max4[2] < a[i+2]) max4[2] = a[i+2];
            if (max4[3] < a[i+3]) max4[3] = a[i+3];
            if (min4[0] > a[i+0] && a[i+0] > INT32_MIN+1) min4[0] = a[i+0];
            if (min4[1] > a[i+1] && a[i+1] > INT32_MIN+1) min4[1] = a[i+1];
            if (min4[2] > a[i+2] && a[i+2] > INT32_MIN+1) min4[2] = a[i+2];
            if (min4[3] > a[i+3] && a[i+3] > INT32_MIN+1) min4[3] = a[i+3];
        }
        min = min4[0];
        if (min > min4[1]) min = min4[1];
        if (min > min4[2]) min = min4[2];
        if (min > min4[3]) min = min4[3];
        max = max4[0];
        if (max < max4[1]) max = max4[1];
        if (max < max4[2]) max = max4[2];
        if (max < max4[3]) max = max4[3];
        for (; i < n; ++i) {
            if (max < a[i]) max = a[i];
            if (min > a[i] && a[i] > INT32_MIN+1) min = a[i];
        }

        if (max <= BCF_MAX_BT_INT8 && min >= BCF_MIN_BT_INT8) {
            if (bcf_enc_size(s, wsize, BCF_BT_INT8) < 0 ||
                ks_resize(s, s->l + n) < 0)
                return -1;
            uint8_t *p = (uint8_t *) s->s + s->l;
            for (i = 0; i < n; ++i, p++) {
                if ( a[i]==bcf_int32_vector_end )   *p = bcf_int8_vector_end;
                else if ( a[i]==bcf_int32_missing ) *p = bcf_int8_missing;
                else *p = a[i];
            }
            s->l += n;
        } else if (max <= BCF_MAX_BT_INT16 && min >= BCF_MIN_BT_INT16) {
            uint8_t *p;
            if (bcf_enc_size(s, wsize, BCF_BT_INT16) < 0 ||
                ks_resize(s, s->l + n * sizeof(int16_t)) < 0)
                return -1;
            p = (uint8_t *) s->s + s->l;
            for (i = 0; i < n; ++i)
            {
                int16_t x;
                if ( a[i]==bcf_int32_vector_end ) x = bcf_int16_vector_end;
                else if ( a[i]==bcf_int32_missing ) x = bcf_int16_missing;
                else x = a[i];
                i16_to_le(x, p);
                p += sizeof(int16_t);
            }
            s->l += n * sizeof(int16_t);
        } else {
            uint8_t *p;
            if (bcf_enc_size(s, wsize, BCF_BT_INT32) < 0 ||
                ks_resize(s, s->l + n * sizeof(int32_t)) < 0)
                return -1;
            p = (uint8_t *) s->s + s->l;
            for (i = 0; i < n; ++i) {
                i32_to_le(a[i], p);
                p += sizeof(int32_t);
            }
            s->l += n * sizeof(int32_t);
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbp
testl %esi, %esi
jle 0x3209b
movl %esi, %r14d
cmpl $0x1, %esi
jne 0x320ed
movl (%rdx), %r15d
movq (%rbp), %rcx
leaq 0x5(%rcx), %rax
cmpq %rax, 0x8(%rbp)
jae 0x321fc
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r14d, %r14d
testq %rcx, %rcx
cmoveq %rdx, %r14
addq %rax, %r14
movq 0x10(%rbp), %rdi
movq %r14, %rsi
callq 0x4860
testq %rax, %rax
je 0x327e0
movq %rax, 0x10(%rbp)
movq %r14, 0x8(%rbp)
movq (%rbp), %rcx
jmp 0x32200
movq (%rbp), %rcx
leaq 0x1(%rcx), %rax
cmpq %rax, 0x8(%rbp)
jae 0x321e8
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r14d, %r14d
testq %rcx, %rcx
cmoveq %rdx, %r14
addq %rax, %r14
movq 0x10(%rbp), %rdi
movq %r14, %rsi
callq 0x4860
testq %rax, %rax
je 0x327e0
movq %rax, 0x10(%rbp)
movq %r14, 0x8(%rbp)
movq (%rbp), %rcx
jmp 0x321ec
movq %rdx, (%rsp)
testl %ecx, %ecx
cmovlel %r14d, %ecx
movl %ecx, 0xc(%rsp)
movl %r14d, %eax
andl $0x7ffffffc, %eax       # imm = 0x7FFFFFFC
je 0x32223
movq %r14, 0x10(%rsp)
movq %rbp, 0x18(%rsp)
movl %eax, %eax
movq %rax, 0x20(%rsp)
movl $0x80000000, %esi       # imm = 0x80000000
movl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
xorl %edx, %edx
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movl $0x80000000, %ecx       # imm = 0x80000000
movl $0x80000000, %r8d       # imm = 0x80000000
movl $0x80000000, %edi       # imm = 0x80000000
movl $0x80000002, %r13d      # imm = 0x80000002
movl %r11d, %ebp
movq (%rsp), %r11
movl (%r11,%rdx,4), %r15d
movl 0x4(%r11,%rdx,4), %eax
cmpl %r15d, %esi
cmovlel %r15d, %esi
cmpl %eax, %ecx
cmovlel %eax, %ecx
movl 0x8(%r11,%rdx,4), %r14d
cmpl %r14d, %r8d
cmovlel %r14d, %r8d
movl 0xc(%r11,%rdx,4), %r12d
cmpl %r12d, %edi
cmovlel %r12d, %edi
cmpl %r15d, %ebp
movl %r15d, %r11d
cmovll %ebp, %r11d
cmpl %r13d, %r15d
movl %ebx, %r15d
cmovll %ebp, %r11d
cmpl %eax, %ebx
movl %eax, %ebx
cmovll %r15d, %ebx
cmpl %r13d, %eax
movl %r10d, %eax
cmovll %r15d, %ebx
cmpl %r14d, %r10d
movl %r14d, %r10d
cmovll %eax, %r10d
cmpl %r13d, %r14d
movl %r9d, %ebp
cmovll %eax, %r10d
cmpl %r12d, %r9d
movl %r12d, %r9d
cmovll %ebp, %r9d
cmpl %r13d, %r12d
cmovll %ebp, %r9d
addq $0x4, %rdx
cmpq 0x20(%rsp), %rdx
jb 0x3214e
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %r14
jmp 0x32251
movq 0x10(%rbp), %rax
movb $0x0, (%rax,%rcx)
movq (%rbp), %rcx
incq %rcx
jmp 0x32820
movq 0x10(%rbp), %rax
movl %r15d, %edx
negl %edx
jo 0x32399
cmpl $0x80000001, %r15d      # imm = 0x80000001
jne 0x323a1
movw $0x8111, (%rax,%rcx)    # imm = 0x8111
jmp 0x323ba
xorl %edx, %edx
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movl $0x80000000, %edi       # imm = 0x80000000
movl $0x80000000, %r8d       # imm = 0x80000000
movl $0x80000000, %ecx       # imm = 0x80000000
movl $0x80000000, %esi       # imm = 0x80000000
movl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
cmpl %ebx, %r11d
cmovll %r11d, %ebx
cmpl %r10d, %ebx
cmovgel %r10d, %ebx
cmpl %r9d, %ebx
cmovgel %r9d, %ebx
cmpl %ecx, %esi
cmovgl %esi, %ecx
cmpl %r8d, %ecx
cmovlel %r8d, %ecx
cmpl %edi, %ecx
cmovlel %edi, %ecx
cmpl %r14d, %edx
jge 0x322a7
movl %edx, %edx
movl %r14d, %esi
movq (%rsp), %r9
movl (%r9,%rdx,4), %eax
cmpl %eax, %ecx
cmovlel %eax, %ecx
cmpl %eax, %ebx
movl %eax, %edi
cmovll %ebx, %edi
cmpl $0x80000002, %eax       # imm = 0x80000002
cmovgel %edi, %ebx
incq %rdx
cmpq %rdx, %rsi
jne 0x32285
jmp 0x322ab
movq (%rsp), %r9
cmpl $0x7f, %ecx
jg 0x3231b
cmpl $-0x78, %ebx
jl 0x3231b
movq (%rbp), %rcx
movq 0x8(%rbp), %rdx
movl 0xc(%rsp), %ebx
cmpl $0xe, %ebx
jg 0x32426
leaq 0x1(%rcx), %rax
cmpq %rax, %rdx
jae 0x32540
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r12d, %r12d
testq %rcx, %rcx
cmoveq %rdx, %r12
addq %rax, %r12
movq 0x10(%rbp), %rdi
movq %r12, %rsi
callq 0x4860
testq %rax, %rax
je 0x327e0
movq %rax, 0x10(%rbp)
movq %r12, 0x8(%rbp)
movq (%rbp), %rcx
movq (%rsp), %r9
jmp 0x32544
movq (%rbp), %rdx
movq 0x8(%rbp), %rsi
cmpl $0x7fff, %ecx           # imm = 0x7FFF
jg 0x323c8
cmpl $0xffff8008, %ebx       # imm = 0xFFFF8008
jl 0x323c8
movl 0xc(%rsp), %ebx
cmpl $0xe, %ebx
jg 0x324ef
leaq 0x1(%rdx), %rax
cmpq %rax, %rsi
jae 0x325e0
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r12d, %r12d
testq %rcx, %rcx
cmoveq %rdx, %r12
addq %rax, %r12
movq 0x10(%rbp), %rdi
movq %r12, %rsi
callq 0x4860
testq %rax, %rax
je 0x327e0
movq %rax, 0x10(%rbp)
movq %r12, 0x8(%rbp)
movq (%rbp), %rdx
movq (%rsp), %r9
jmp 0x325e4
movw $0x8011, (%rax,%rcx)    # imm = 0x8011
jmp 0x323ba
leal 0x78(%r15), %edx
cmpl $0xf7, %edx
ja 0x32477
movb $0x11, (%rax,%rcx)
movb %r15b, 0x1(%rax,%rcx)
movl $0x2, %ecx
addq (%rbp), %rcx
jmp 0x32820
movl 0xc(%rsp), %ebx
cmpl $0xe, %ebx
jg 0x3249e
leaq 0x1(%rdx), %rax
cmpq %rax, %rsi
jae 0x325a9
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r12d, %r12d
testq %rcx, %rcx
cmoveq %rdx, %r12
addq %rax, %r12
movq 0x10(%rbp), %rdi
movq %r12, %rsi
callq 0x4860
testq %rax, %rax
je 0x327e0
movq %rax, 0x10(%rbp)
movq %r12, 0x8(%rbp)
movq (%rbp), %rdx
movq (%rsp), %r9
jmp 0x325ad
leaq 0x6(%rcx), %rax
cmpq %rax, %rdx
jae 0x32556
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r12d, %r12d
testq %rcx, %rcx
cmoveq %rdx, %r12
addq %rax, %r12
movq 0x10(%rbp), %rdi
movq %r12, %rsi
callq 0x4860
testq %rax, %rax
je 0x327e0
movq %rax, 0x10(%rbp)
movq %r12, 0x8(%rbp)
movq (%rbp), %rcx
movq (%rsp), %r9
jmp 0x3255a
leal 0x7ff8(%r15), %edx
cmpl $0xfff7, %edx           # imm = 0xFFF7
ja 0x32596
movb $0x12, (%rax,%rcx)
movw %r15w, 0x1(%rax,%rcx)
movl $0x3, %ecx
jmp 0x323bf
leaq 0x6(%rdx), %rax
cmpq %rax, %rsi
jae 0x325c0
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r12d, %r12d
testq %rcx, %rcx
cmoveq %rdx, %r12
addq %rax, %r12
movq 0x10(%rbp), %rdi
movq %r12, %rsi
callq 0x4860
testq %rax, %rax
je 0x327e0
movq %rax, 0x10(%rbp)
movq %r12, 0x8(%rbp)
movq (%rbp), %rdx
movq (%rsp), %r9
jmp 0x325c4
leaq 0x6(%rdx), %rax
cmpq %rax, %rsi
jae 0x325f7
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r12d, %r12d
testq %rcx, %rcx
cmoveq %rdx, %r12
addq %rax, %r12
movq 0x10(%rbp), %rdi
movq %r12, %rsi
callq 0x4860
testq %rax, %rax
je 0x327e0
movq %rax, 0x10(%rbp)
movq %r12, 0x8(%rbp)
movq (%rbp), %rdx
movq (%rsp), %r9
jmp 0x325fb
movq 0x10(%rbp), %rax
shlb $0x4, %bl
incb %bl
movb %bl, (%rax,%rcx)
movl $0x1, %ecx
jmp 0x32665
movq 0x10(%rbp), %rax
movb $-0xf, (%rax,%rcx)
cmpl $0x7f, %ebx
ja 0x32576
movb $0x11, 0x1(%rax,%rcx)
movb %bl, 0x2(%rax,%rcx)
movl $0x3, %ecx
jmp 0x32665
cmpl $0x7fff, %ebx           # imm = 0x7FFF
ja 0x32657
movb $0x12, 0x1(%rax,%rcx)
movw %bx, 0x2(%rax,%rcx)
movl $0x4, %ecx
jmp 0x32665
movb $0x13, (%rax,%rcx)
movl %r15d, 0x1(%rax,%rcx)
movl $0x5, %ecx
jmp 0x323bf
movq 0x10(%rbp), %rax
shlb $0x4, %bl
orb $0x3, %bl
movb %bl, (%rax,%rdx)
movl $0x1, %ecx
jmp 0x32701
movq 0x10(%rbp), %rax
movb $-0xd, (%rax,%rdx)
cmpl $0x7f, %ebx
ja 0x32617
movb $0x11, 0x1(%rax,%rdx)
movb %bl, 0x2(%rax,%rdx)
movl $0x3, %ecx
jmp 0x32701
movq 0x10(%rbp), %rax
shlb $0x4, %bl
orb $0x2, %bl
movb %bl, (%rax,%rdx)
movl $0x1, %ecx
jmp 0x3278d
movq 0x10(%rbp), %rax
movb $-0xe, (%rax,%rdx)
cmpl $0x7f, %ebx
ja 0x32637
movb $0x11, 0x1(%rax,%rdx)
movb %bl, 0x2(%rax,%rdx)
movl $0x3, %ecx
jmp 0x3278d
cmpl $0x7fff, %ebx           # imm = 0x7FFF
ja 0x326f3
movb $0x12, 0x1(%rax,%rdx)
movw %bx, 0x2(%rax,%rdx)
movl $0x4, %ecx
jmp 0x32701
cmpl $0x7fff, %ebx           # imm = 0x7FFF
ja 0x3277f
movb $0x12, 0x1(%rax,%rdx)
movw %bx, 0x2(%rax,%rdx)
movl $0x4, %ecx
jmp 0x3278d
movb $0x13, 0x1(%rax,%rcx)
movl %ebx, 0x2(%rax,%rcx)
movl $0x6, %ecx
addq (%rbp), %rcx
movq %rcx, (%rbp)
movl %r14d, %r12d
leaq (%rcx,%r12), %rax
cmpq %rax, 0x8(%rbp)
jae 0x326bb
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r15d, %r15d
testq %rcx, %rcx
cmoveq %rdx, %r15
addq %rax, %r15
movq 0x10(%rbp), %rdi
movq %r15, %rsi
callq 0x4860
testq %rax, %rax
je 0x327e0
movq %rax, 0x10(%rbp)
movq %r15, 0x8(%rbp)
movq (%rbp), %rcx
movq (%rsp), %r9
jmp 0x326bf
movq 0x10(%rbp), %rax
addq %rax, %rcx
xorl %eax, %eax
movl (%r9,%rax,4), %edx
cmpl $0x80000001, %edx       # imm = 0x80000001
je 0x326da
movl %edx, %esi
negl %esi
jno 0x326dc
movb $-0x80, %dl
jmp 0x326dc
movb $-0x7f, %dl
movb %dl, (%rcx,%rax)
incq %rax
cmpq %rax, %r12
jne 0x326c4
movq (%rbp), %rcx
addq %r12, %rcx
jmp 0x32820
movb $0x13, 0x1(%rax,%rdx)
movl %ebx, 0x2(%rax,%rdx)
movl $0x6, %ecx
addq (%rbp), %rcx
movq %rcx, (%rbp)
movl %r14d, %r12d
leaq (%rcx,%r12,4), %rax
cmpq %rax, 0x8(%rbp)
jae 0x32757
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r15d, %r15d
testq %rcx, %rcx
cmoveq %rdx, %r15
addq %rax, %r15
movq 0x10(%rbp), %rdi
movq %r15, %rsi
callq 0x4860
testq %rax, %rax
je 0x327e0
movq %rax, 0x10(%rbp)
movq %r15, 0x8(%rbp)
movq (%rbp), %rcx
movq (%rsp), %r9
jmp 0x3275b
movq 0x10(%rbp), %rax
leaq (,%r12,4), %rdx
addq %rcx, %rax
xorl %esi, %esi
movl (%r9,%rsi,4), %edi
movl %edi, (%rax,%rsi,4)
incq %rsi
cmpq %rsi, %r12
jne 0x32768
addq %rdx, %rcx
jmp 0x32820
movb $0x13, 0x1(%rax,%rdx)
movl %ebx, 0x2(%rax,%rdx)
movl $0x6, %ecx
addq (%rbp), %rcx
movq %rcx, (%rbp)
leal (%r14,%r14), %r13d
leaq (%rcx,%r13), %rax
cmpq %rax, 0x8(%rbp)
jae 0x327e7
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r12d, %r12d
testq %rcx, %rcx
cmoveq %rdx, %r12
addq %rax, %r12
movq 0x10(%rbp), %rdi
movq %r12, %rsi
callq 0x4860
testq %rax, %rax
je 0x327e0
movq %rax, 0x10(%rbp)
movq %r12, 0x8(%rbp)
movq (%rbp), %rcx
movq (%rsp), %r9
jmp 0x327eb
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x32826
movq 0x10(%rbp), %rax
addq %rcx, %rax
movl %r14d, %edx
xorl %esi, %esi
movl (%r9,%rsi,4), %edi
cmpl $0x80000001, %edi       # imm = 0x80000001
je 0x3280d
movl %edi, %r8d
negl %r8d
jno 0x32811
movw $0x8000, %di            # imm = 0x8000
jmp 0x32811
movw $0x8001, %di            # imm = 0x8001
movw %di, (%rax,%rsi,2)
incq %rsi
cmpq %rsi, %rdx
jne 0x327f3
addq %r13, %rcx
movq %rcx, (%rbp)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq