// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x6159b(%rip), %rdx     # 0xd4b4c
callq 0x14a60
testq %rax, %rax
je 0x73669
movq %rax, %rbp
movq 0x18(%r15), %r13
movq %r13, %rax
shrq $0x10, %rax
movq %rax, 0x10(%rsp)
movzwl %ax, %edi
movl $0x4, %esi
movq %rdi, %r12
callq 0x15e90
movq %rax, %rbx
movl 0xc(%rbp), %ecx
cmpl $0x1, %ecx
je 0x736e4
cmpl $0x2, %ecx
je 0x73671
cmpl $0x3, %ecx
jne 0x737e9
movq %r12, %r11
movq %r13, %rax
shrq $0x28, %rax
je 0x736f4
movq 0x10(%rbp), %rcx
movslq 0x8(%rbp), %rdx
movl 0x4(%rbp), %esi
movl %r13d, %edi
shrl $0x10, %edi
xorl %r8d, %r8d
testl %esi, %esi
jle 0x73659
xorl %r9d, %r9d
movl (%rcx,%r9,4), %r10d
cmpl $0x80000001, %r10d      # imm = 0x80000001
je 0x73659
cmpl $0x2, %r10d
jb 0x73651
sarl %r10d
cmpl %edi, %r10d
jg 0x7387e
movslq %r10d, %r10
incl -0x4(%rbx,%r10,4)
incq %r9
cmpq %r9, %rsi
jne 0x7362a
incq %r8
addq %rdx, %rcx
cmpq %rax, %r8
jne 0x73623
jmp 0x736f4
xorl %r12d, %r12d
jmp 0x738c6
movq %r13, %rax
shrq $0x28, %rax
movq %r12, %r11
je 0x736f4
movq 0x10(%rbp), %rcx
movslq 0x8(%rbp), %rdx
movl 0x4(%rbp), %esi
movl %r13d, %edi
shrl $0x10, %edi
xorl %r8d, %r8d
testl %esi, %esi
jle 0x736d7
xorl %r9d, %r9d
movzwl (%rcx,%r9,2), %r10d
cmpl $0x8001, %r10d          # imm = 0x8001
je 0x736d7
cmpw $0x2, %r10w
jb 0x736cf
movswl %r10w, %r10d
sarl %r10d
decl %r10d
movswl %r10w, %r11d
cmpl %r11d, %edi
jle 0x7387e
movswq %r10w, %r10
incl (%rbx,%r10,4)
movq %r12, %r11
incq %r9
cmpq %r9, %rsi
jne 0x73698
incq %r8
addq %rdx, %rcx
cmpq %rax, %r8
jne 0x73691
jmp 0x736f4
movq %r13, %rax
shrq $0x28, %rax
movq %r12, %r11
jne 0x73821
movq %r14, %r12
movq %r15, 0x8(%rsp)
addl $0x3f, %r11d
shrl $0x6, %r11d
leal (,%r11,8), %r15d
leaq 0x18(%r15), %rdi
movq %r11, %r14
callq 0x14810
movq %rax, %rbp
testq %rax, %rax
je 0x73765
movq %r14, 0x8(%rbp)
movq %r14, (%rbp)
leaq 0x10(%rbp), %rdi
movq %r12, (%rsp)
xorl %r12d, %r12d
xorl %esi, %esi
movq %r15, %rdx
callq 0x14240
movq 0x10(%rsp), %rcx
andl $0x3f, %ecx
movq $-0x1, %rax
shlq %cl, %rax
notq %rax
cmpq $0x1, %rcx
sbbq %r12, %r12
orq %rax, %r12
movq %r12, 0x10(%rbp,%r14,8)
movq (%rsp), %r12
testl $0xfffe0000, %r13d      # imm = 0xFFFE0000
je 0x737c5
movq %r12, %rdi
shrl $0x10, %r13d
xorl %r12d, %r12d
movl $0x1, %ecx
movq 0x8(%rsp), %rsi
cmpl $0x0, (%rbx,%rcx,4)
jne 0x7379f
movl $0x1, %eax
shlq %cl, %rax
movq %rcx, %rdx
shrq $0x6, %rdx
orq %rax, 0x10(%rbp,%rdx,8)
incl %r12d
incq %rcx
cmpq %rcx, %r13
jne 0x73782
testl %r12d, %r12d
je 0x737c5
movq %rbp, %rdx
callq 0x16080
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leal -0x2(,%rcx,2), %r14d
jmp 0x737cb
xorl %r12d, %r12d
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x14dd0
testq %rbp, %rbp
je 0x738bf
movq %rbp, %rdi
callq 0x14dd0
jmp 0x738bf
movq 0x18(%r14), %rax
movslq 0x10(%r15), %rdx
shlq $0x4, %rdx
movq (%rax,%rdx), %r8
movq (%r15), %r9
incq %r9
leaq 0x5f8d5(%rip), %rsi     # 0xd30db
leaq 0x5f907(%rip), %rdx     # 0xd3114
xorl %r14d, %r14d
movl $0x1, %edi
xorl %eax, %eax
callq 0x157b0
jmp 0x738b4
movq 0x10(%rbp), %rcx
movslq 0x8(%rbp), %rdx
movl 0x4(%rbp), %esi
movl %r13d, %edi
shrl $0x10, %edi
xorl %r8d, %r8d
testl %esi, %esi
jle 0x7386e
xorl %r9d, %r9d
movb (%rcx,%r9), %r10b
cmpb $-0x7f, %r10b
je 0x7386e
cmpb $0x2, %r10b
jb 0x73866
sarb %r10b
decb %r10b
movsbl %r10b, %r11d
cmpl %r11d, %edi
jle 0x7387e
movsbq %r10b, %r10
incl (%rbx,%r10,4)
movq %r12, %r11
incq %r9
cmpq %r9, %rsi
jne 0x7383c
incq %r8
addq %rdx, %rcx
cmpq %rax, %r8
jne 0x73835
jmp 0x736f4
movq 0x18(%r14), %rax
movslq 0x10(%r15), %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rcx
movq (%r15), %r8
incq %r8
leaq 0x5f840(%rip), %rsi     # 0xd30db
leaq 0x5f84a(%rip), %rdx     # 0xd30ec
movl $0x1, %edi
xorl %eax, %eax
callq 0x157b0
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x14dd0
xorl %r12d, %r12d
testl %r14d, %r14d
cmovnel %r14d, %r12d
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq