// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
movq %rdx, %r15
movq %rsi, %r14
movzbl (%rsi), %eax
cmpl $0x2a, %eax
jne 0x1d1da
cmpb $0x0, 0x1(%r14)
je 0x1d206
cmpb $0x0, 0x1(%rdi)
jne 0x1d1eb
cmpb $0x0, 0x1(%r14)
je 0x1d2c7
cmpl $0x3c, %eax
je 0x1d212
cmpl $0x5b, %eax
je 0x1d1fa
cmpl $0x5d, %eax
jne 0x1d261
movl $0x10, (%r15)
jmp 0x1d43f
movq $0x20, (%r15)
jmp 0x1d43f
movzbl 0x1(%r14), %eax
cmpl $0x2a, %eax
je 0x1d230
cmpl $0x58, %eax
jne 0x1d23b
cmpb $0x3e, 0x2(%r14)
je 0x1d2d9
cmpb $0x2a, %al
jne 0x1d23b
cmpb $0x3e, 0x2(%r14)
je 0x1d2d9
incq %r14
leaq 0x8e30b(%rip), %rdi     # 0xab550
movq %r14, %rsi
callq 0x46e0
testl %eax, %eax
je 0x1d2d9
movl $0x8, (%r15)
jmp 0x1d43f
movb (%rdi), %bl
testb %bl, %bl
sete %bpl
movq %r15, (%rsp)
je 0x1d2e5
movb (%r14), %r15b
testb %r15b, %r15b
je 0x1d2e5
movq %rdi, %r12
callq 0x4090
movq %r12, %rdi
movq (%rax), %rax
leaq 0x1(%r12), %rcx
leaq 0x1(%r14), %rdx
movq %rcx, %r12
movq %rdx, %r13
movzbl %bl, %ecx
movb (%rax,%rcx,4), %cl
movzbl %r15b, %edx
cmpb (%rax,%rdx,4), %cl
jne 0x1d39e
movb (%r12), %bl
testb %bl, %bl
sete %bpl
je 0x1d2eb
movb (%r13), %r15b
leaq 0x1(%r12), %rcx
leaq 0x1(%r13), %rdx
testb %r15b, %r15b
jne 0x1d28e
jmp 0x1d2eb
cmpl $0x2e, %eax
je 0x1d2d9
cmpb %al, (%rdi)
je 0x1d2d9
cmpl $0x58, %eax
jne 0x1d432
movq $0x0, (%r15)
jmp 0x1d43f
movq %rdi, %r12
movq %r14, %r13
movb (%r13), %al
testb $0x1, %bpl
je 0x1d331
testb %al, %al
je 0x1d331
addl %r13d, %edi
addl %r14d, %r12d
notl %r12d
addl %edi, %r12d
incl %r12d
cmpb $0x0, (%r13)
leaq 0x1(%r13), %r13
jne 0x1d305
movzbl -0x2(%r13), %eax
cmpl $0x5d, %eax
je 0x1d322
cmpl $0x5b, %eax
jne 0x1d38b
movq (%rsp), %rax
movl $0x10, (%rax)
jmp 0x1d43f
testb %al, %al
setne %cl
orb %bpl, %cl
testb $0x1, %cl
je 0x1d35c
testb %al, %al
jne 0x1d3a9
xorb $0x1, %bpl
testb $0x1, %bpl
jne 0x1d3a9
movq (%rsp), %rax
movq $0x0, (%rax)
jmp 0x1d43f
xorl %eax, %eax
cmpb $0x0, (%r12,%rax)
leaq 0x1(%rax), %rax
jne 0x1d35e
addl %edi, %r13d
addl %r14d, %r12d
subl %r12d, %r13d
subl %eax, %r13d
incl %r13d
movq (%rsp), %rax
movl %r13d, 0x4(%rax)
movl $0x84, (%rax)
jmp 0x1d43f
movq (%rsp), %rax
movl %r12d, 0x4(%rax)
movl $0x44, (%rax)
jmp 0x1d43f
decq %r12
decq %r13
jmp 0x1d2eb
leaq -0x1(%r12), %r14
leaq -0x2(%r12), %rbp
incq %r14
cmpb $0x0, 0x3(%rbp)
leaq 0x1(%rbp), %rbp
jne 0x1d3b3
leaq -0x1(%r13), %r15
leaq -0x2(%r13), %rbx
incq %rbx
cmpb $0x0, 0x2(%r15)
leaq 0x1(%r15), %r15
jne 0x1d3c8
movzbl (%r15), %eax
cmpl $0x5b, %eax
je 0x1d322
cmpl $0x5d, %eax
je 0x1d322
cmpq %r12, %r14
jbe 0x1d454
cmpq %r13, %r15
jbe 0x1d454
callq 0x4090
movq (%rax), %rcx
xorl %eax, %eax
movzbl (%r14,%rax), %edx
movb (%rcx,%rdx,4), %dl
movzbl (%r15,%rax), %esi
cmpb (%rcx,%rsi,4), %dl
jne 0x1d44e
leaq (%rax,%rbp), %rsi
leaq -0x1(%rax), %rdx
cmpq %r12, %rsi
jbe 0x1d42a
addq %rbx, %rax
cmpq %r13, %rax
movq %rdx, %rax
ja 0x1d400
addq %rdx, %r15
addq %rdx, %r14
jmp 0x1d454
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, (%r15)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %rax, %r15
addq %rax, %r14
movq %r15, %rcx
subq %r13, %rcx
je 0x1d487
movq %r14, %rax
subq %r12, %rax
je 0x1d4bc
leal 0x1(%rcx), %edx
cmpq %rcx, %rax
movl $0x2, %ecx
movl $0x8, %esi
cmovel %ecx, %esi
movq (%rsp), %rcx
movl %esi, (%rcx)
notl %eax
cmovlel %edx, %eax
movl %eax, 0x4(%rcx)
jmp 0x1d43f
cmpq %r12, %r14
je 0x1d4fd
subl %r14d, %r12d
movq (%rsp), %rax
movl %r12d, 0x4(%rax)
movq %rax, %r12
movzbl (%r14), %ebx
callq 0x4090
movq (%rax), %rax
movb (%rax,%rbx,4), %cl
movzbl (%r15), %edx
cmpb (%rax,%rdx,4), %cl
jne 0x1d4f0
movl $0x84, (%r12)
jmp 0x1d43f
movl %r15d, %eax
subl %r13d, %eax
movq (%rsp), %r12
movl %eax, 0x4(%r12)
movzbl (%r14), %ebx
callq 0x4090
movq (%rax), %rax
movb (%rax,%rbx,4), %cl
movzbl (%r15), %edx
cmpb (%rax,%rdx,4), %cl
jne 0x1d4f0
movl $0x44, (%r12)
jmp 0x1d43f
movl $0x8, (%r12)
jmp 0x1d43f
movabsq $0x100000001, %rax      # imm = 0x100000001
movq (%rsp), %rcx
movq %rax, (%rcx)
jmp 0x1d43f
nop