// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/vcfutils.c
// Function: bcf_trim_alleles
int bcf_trim_alleles(const bcf_hdr_t *header, bcf1_t *line)
{
    int i, ret = 0, nrm = 0;
    kbitset_t *rm_set = NULL;
    bcf_fmt_t *gt = bcf_get_fmt(header, line, "GT");
    if ( !gt ) return 0;

    int *ac = (int*) calloc(line->n_allele,sizeof(int));

    // check if all alleles are populated
    #define BRANCH(type_t, convert, vector_end) { \
        for (i=0; i<line->n_sample; i++) \
        { \
            uint8_t *p = gt->p + i*gt->size; \
            int ial; \
            for (ial=0; ial<gt->n; ial++) \
            { \
                int32_t val = convert(&p[ial * sizeof(type_t)]); \
                if ( val==vector_end ) break; /* smaller ploidy */ \
                if ( bcf_gt_is_missing(val) ) continue; /* missing allele */ \
                if ( (val>>1)-1 >= line->n_allele ) { \
                    hts_log_error("Allele index is out of bounds at %s:%"PRIhts_pos, header->id[BCF_DT_CTG][line->rid].key, line->pos+1); \
                    ret = -1; \
                    goto clean; \
                } \
                ac[(val>>1)-1]++; \
            }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
leaq 0x4e2d5(%rip), %rdx     # 0xab874
callq 0x14aa0
testq %rax, %rax
je 0x5d64d
movq %rax, %r12
movq 0x18(%r14), %rbp
movl %ebp, %r13d
shrl $0x10, %r13d
pushq $0x4
popq %rsi
movq %r13, %rdi
callq 0x15f40
movq %rax, %rbx
movl 0xc(%r12), %ecx
cmpl $0x1, %ecx
je 0x5d6c4
cmpl $0x2, %ecx
je 0x5d654
cmpl $0x3, %ecx
jne 0x5d768
movq %rbp, %rax
shrq $0x28, %rax
shrl $0x10, %ebp
xorl %ecx, %ecx
xorl %edx, %edx
cmpl %eax, %edx
je 0x5d7cc
movl 0x4(%r12), %esi
testl %esi, %esi
cmovlel %ecx, %esi
movl 0x8(%r12), %edi
imull %edx, %edi
movslq %edi, %rdi
addq 0x10(%r12), %rdi
xorl %r8d, %r8d
cmpq %r8, %rsi
je 0x5d649
movl (%rdi,%r8,4), %r9d
cmpl $0x80000001, %r9d       # imm = 0x80000001
je 0x5d649
cmpl $0x2, %r9d
jb 0x5d644
sarl %r9d
cmpl %ebp, %r9d
jg 0x5d72f
movslq %r9d, %r9
incl -0x4(%rbx,%r9,4)
incq %r8
jmp 0x5d618
incl %edx
jmp 0x5d5f3
xorl %ebp, %ebp
jmp 0x5d7b5
movq %rbp, %rax
shrq $0x28, %rax
shrl $0x10, %ebp
xorl %ecx, %ecx
xorl %edx, %edx
cmpl %eax, %edx
je 0x5d7cc
movl 0x4(%r12), %esi
testl %esi, %esi
cmovlel %ecx, %esi
movl 0x8(%r12), %edi
imull %edx, %edi
movslq %edi, %rdi
addq 0x10(%r12), %rdi
xorl %r8d, %r8d
cmpq %r8, %rsi
je 0x5d6c0
movzwl (%rdi,%r8,2), %r9d
cmpw $0x8001, %r9w           # imm = 0x8001
je 0x5d6c0
cmpw $0x2, %r9w
jb 0x5d6bb
movswl %r9w, %r9d
sarl %r9d
decl %r9d
movswl %r9w, %r10d
cmpl %r10d, %ebp
jle 0x5d72f
movswq %r9w, %r9
incl (%rbx,%r9,4)
incq %r8
jmp 0x5d687
incl %edx
jmp 0x5d662
movq %rbp, %rax
shrq $0x28, %rax
movl %ebp, %ecx
shrl $0x10, %ecx
xorl %edx, %edx
xorl %esi, %esi
cmpl %eax, %esi
je 0x5d7c6
movl 0x4(%r12), %edi
testl %edi, %edi
cmovlel %edx, %edi
movl 0x8(%r12), %r8d
imull %esi, %r8d
movslq %r8d, %r8
addq 0x10(%r12), %r8
xorl %r9d, %r9d
cmpq %r9, %rdi
je 0x5d72b
movb (%r8,%r9), %r10b
cmpb $-0x7f, %r10b
je 0x5d72b
cmpb $0x2, %r10b
jb 0x5d726
sarb %r10b
decb %r10b
movsbl %r10b, %r11d
cmpl %r11d, %ecx
jle 0x5d72f
movsbq %r10b, %r10
incl (%rbx,%r10,4)
incq %r9
jmp 0x5d6fa
incl %esi
jmp 0x5d6d4
movq 0x18(%r15), %rax
movslq 0x10(%r14), %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rcx
movq (%r14), %r8
incq %r8
leaq 0x4c6bf(%rip), %rsi     # 0xa9e0b
leaq 0x4c6c9(%rip), %rdx     # 0xa9e1c
xorl %r12d, %r12d
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x15830
pushq $-0x1
popq %r14
xorl %ebp, %ebp
jmp 0x5d79e
movq 0x18(%r15), %rax
movslq 0x10(%r14), %rdx
shlq $0x4, %rdx
movq (%rax,%rdx), %r8
movq (%r14), %r9
incq %r9
leaq 0x4c686(%rip), %rsi     # 0xa9e0b
leaq 0x4c6b8(%rip), %rdx     # 0xa9e44
xorl %r12d, %r12d
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x15830
xorl %ebp, %ebp
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x14e30
movq %r12, %rdi
callq 0x14e30
testl %r14d, %r14d
cmovnel %r14d, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
shrl $0x10, %ebp
movq %rbp, %r13
movq %r13, %rdi
callq 0x5d82e
movq %rax, %r12
movzwl 0x1a(%r14), %eax
xorl %ebp, %ebp
pushq $0x1
popq %rdx
movq %rdx, %rcx
cmpq %rax, %rcx
jae 0x5d808
cmpl $0x0, (%rbx,%rcx,4)
jne 0x5d803
movq %rdx, %rsi
shlq %cl, %rsi
movq %rcx, %rdi
shrq $0x6, %rdi
orq %rsi, 0x10(%r12,%rdi,8)
incl %ebp
incq %rcx
jmp 0x5d7e4
testl %ebp, %ebp
je 0x5d799
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x16140
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leal -0x2(,%rcx,2), %r14d
jmp 0x5d79e