// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/test/../vcf.c
// Function: bcf_set_variant_type
static void bcf_set_variant_type(const char *ref, const char *alt, bcf_variant_t *var)
{
    if ( *alt == '*' && !alt[1] ) { var->n = 0; var->type = VCF_OVERLAP; return; }  // overlapping variant

    // The most frequent case
    if ( !ref[1] && !alt[1] )
    {
        if ( *alt == '.' || *ref==*alt ) { var->n = 0; var->type = VCF_REF; return; }
        if ( *alt == 'X' ) { var->n = 0; var->type = VCF_REF; return; }  // mpileup's X allele shouldn't be treated as variant
        var->n = 1; var->type = VCF_SNP; return;
    }
    if ( alt[0]=='<' )
    {
        if ( alt[1]=='X' && alt[2]=='>' ) { var->n = 0; var->type = VCF_REF; return; }  // mpileup's X allele shouldn't be treated as variant
        if ( alt[1]=='*' && alt[2]=='>' ) { var->n = 0; var->type = VCF_REF; return; }
        if ( !strcmp("NON_REF>",alt+1) ) { var->n = 0; var->type = VCF_REF; return; }
        var->type = VCF_OTHER;
        return;
    }

    // Catch "joined before" breakend case
    if ( alt[0]==']' || alt[0] == '[' )
    {
        var->type = VCF_BND; return;
    }

    // Iterate through alt characters that match the reference
    const char *r = ref, *a = alt;
    while (*r && *a && toupper_c(*r)==toupper_c(*a) ) { r++; a++; }     // unfortunately, matching REF,ALT case is not guaranteed

    if ( *a && !*r )
    {
        while ( *a ) a++;
        if ( *(a-1)==']' || *(a-1)=='[' ) { var->type = VCF_BND; return; } // "joined after" breakend
        var->n = (a-alt)-(r-ref); var->type = VCF_INDEL | VCF_INS; return;
    }
    else if ( *r && !*a )
    {
        while ( *r ) r++;
        var->n = (a-alt)-(r-ref); var->type = VCF_INDEL | VCF_DEL; return;
    }
    else if ( !*r && !*a )
    {
        var->n = 0; var->type = VCF_REF; return;
    }

    const char *re = r, *ae = a;
    while ( re[1] ) re++;
    while ( ae[1] ) ae++;
    if ( ae[0]==']' || ae[0]=='[' ) { var->type = VCF_BND; return; }    // "joined after" breakend
    while ( re>r && ae>a && toupper_c(*re)==toupper_c(*ae) ) { re--; ae--; }
    if ( ae==a )
    {
        if ( re==r ) { var->n = 1; var->type = VCF_SNP; return; }
        var->n = -(re-r);
        if ( toupper_c(*re)==toupper_c(*ae) ) { var->type = VCF_INDEL | VCF_DEL; return; }
        var->type = VCF_OTHER; return;
    }
    else if ( re==r )
    {
        var->n = ae-a;
        if ( toupper_c(*re)==toupper_c(*ae) ) { var->type = VCF_INDEL | VCF_INS; return; }
        var->type = VCF_OTHER; return;
    }

    var->type = ( re-r == ae-a ) ? VCF_MNP : VCF_OTHER;
    var->n = ( re-r > ae-a ) ? -(re-r+1) : ae-a+1;

    // should do also complex events, SVs, etc...
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
movzbl (%rsi), %eax
cmpl $0x2a, %eax
jne 0x14cac
cmpb $0x0, 0x1(%r14)
je 0x14cda
cmpb $0x0, 0x1(%r15)
jne 0x14cbe
cmpb $0x0, 0x1(%r14)
je 0x14d53
cmpl $0x3c, %eax
je 0x14ce7
cmpl $0x5b, %eax
je 0x14ccd
cmpl $0x5d, %eax
jne 0x14d24
movl $0x10, (%r12)
jmp 0x14f5a
movq $0x20, (%r12)
jmp 0x14f5a
movzbl 0x1(%r14), %eax
cmpl $0x2a, %eax
je 0x14cf6
cmpl $0x58, %eax
jne 0x14d01
cmpb $0x3e, 0x2(%r14)
je 0x14d93
incq %r14
leaq 0x6e5e1(%rip), %rdi     # 0x832ec
movq %r14, %rsi
callq 0x46e0
testl %eax, %eax
je 0x14d93
movl $0x8, (%r12)
jmp 0x14f5a
xorl %r13d, %r13d
movb (%r15,%r13), %al
movb (%r14,%r13), %bl
testb %al, %al
je 0x14d75
testb %bl, %bl
je 0x14d9d
movsbl %al, %edi
callq 0x14f69
movl %eax, %ebp
movsbl %bl, %edi
callq 0x14f69
cmpb %al, %bpl
jne 0x14dc5
incq %r13
jmp 0x14d27
cmpl $0x2e, %eax
je 0x14d93
cmpb %al, (%r15)
je 0x14d93
cmpl $0x58, %eax
je 0x14d93
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, (%r12)
jmp 0x14f5a
testb %bl, %bl
je 0x14d93
movb $0x1, %cl
xorl %eax, %eax
testb %cl, %cl
je 0x14e2d
leaq (%r14,%rax), %rcx
movb 0x1(%r13,%rcx), %cl
incq %rax
jmp 0x14d7d
andq $0x0, (%r12)
jmp 0x14f5a
xorl %eax, %eax
leaq (%r15,%rax), %rcx
incq %rax
cmpb $0x0, (%r13,%rcx)
jne 0x14d9f
pushq $0x1
popq %rcx
subl %eax, %ecx
movl %ecx, 0x4(%r12)
movl $0x84, (%r12)
jmp 0x14f5a
movq %r12, 0x8(%rsp)
leaq (%r15,%r13), %rax
movq %rax, 0x10(%rsp)
leaq (%r14,%r13), %rcx
xorl %r12d, %r12d
leaq (%r15,%r12), %rax
incq %r12
cmpb $0x0, 0x1(%r13,%rax)
jne 0x14dda
movq 0x10(%rsp), %rax
leaq (%r12,%rax), %rbx
decq %rbx
negq %r12
xorl %r15d, %r15d
leaq (%r14,%r15), %rax
incq %r15
cmpb $0x0, 0x1(%r13,%rax)
jne 0x14dfb
addq %r15, %r14
movzbl -0x1(%r13,%r14), %eax
cmpl $0x5b, %eax
je 0x14e1d
cmpl $0x5d, %eax
jne 0x14e5a
movq 0x8(%rsp), %rax
movl $0x10, (%rax)
jmp 0x14f5a
addq %rax, %r14
movzbl -0x1(%r13,%r14), %ecx
cmpl $0x5d, %ecx
je 0x14ccd
cmpl $0x5b, %ecx
je 0x14ccd
movl %eax, 0x4(%r12)
movl $0x44, (%r12)
jmp 0x14f5a
movq %rcx, %r13
leaq (%r15,%rcx), %r14
decq %r14
cmpq 0x10(%rsp), %rbx
jbe 0x14e96
cmpq %r13, %r14
jbe 0x14e96
movsbl (%rbx), %edi
callq 0x14f69
movl %eax, %ebp
movsbl (%r14), %edi
callq 0x14f69
cmpb %al, %bpl
jne 0x14e96
decq %rbx
decq %r14
incq %r12
decq %r15
jmp 0x14e64
cmpq $0x1, %r15
je 0x14ed2
cmpq $-0x1, %r12
je 0x14f06
movq %r12, %rax
notq %rax
leaq -0x1(%r15), %rcx
movq %r15, %rdx
addq %r12, %rdx
pushq $0x2
popq %rdx
pushq $0x8
popq %rsi
cmovel %edx, %esi
movq 0x8(%rsp), %rdx
movl %esi, (%rdx)
cmpq %rcx, %rax
cmovgl %r12d, %r15d
movl %r15d, 0x4(%rdx)
jmp 0x14f5a
cmpq $-0x1, %r12
je 0x14f37
incl %r12d
movq 0x8(%rsp), %r14
movl %r12d, 0x4(%r14)
movsbl (%rbx), %edi
callq 0x14f69
movl %eax, %ebp
movsbl (%r13), %edi
callq 0x14f69
cmpb %al, %bpl
jne 0x14f4b
movl $0x84, (%r14)
jmp 0x14f5a
decl %r15d
movq 0x8(%rsp), %rbx
movl %r15d, 0x4(%rbx)
movq 0x10(%rsp), %rax
movsbl (%rax), %edi
callq 0x14f69
movl %eax, %ebp
movsbl (%r14), %edi
callq 0x14f69
cmpb %al, %bpl
jne 0x14f54
movl $0x44, (%rbx)
jmp 0x14f5a
movabsq $0x100000001, %rax      # imm = 0x100000001
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
jmp 0x14f5a
movl $0x8, (%r14)
jmp 0x14f5a
movl $0x8, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq