// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/bcf_sr_sort.c
// Function: pairing_score
static uint32_t pairing_score(sr_sort_t *srt, int ivset, int jvset)
{
    varset_t *iv = &srt->vset[ivset];
    varset_t *jv = &srt->vset[jvset];

    // Restrictive logic: the strictest type from a group is selected,
    // so that, for example, snp+ref does not lead to the inclusion of an indel
    int i,j;
    uint32_t min = UINT32_MAX;
    for (i=0; i<iv->nvar; i++)
    {
        var_t *ivar = &srt->var[iv->var[i]];
        for (j=0; j<jv->nvar; j++)
        {
            var_t *jvar = &srt->var[jv->var[j]];
            if ( srt->pair & BCF_SR_PAIR_EXACT )
            {
                if ( ivar->type != jvar->type ) continue;
                if ( !strcmp(ivar->str,jvar->str) ) return UINT32_MAX;  // exact match, best possibility
                if ( multi_is_exact(ivar,jvar) ) return UINT32_MAX; // identical alleles
                continue;
            }
            if ( ivar->type==jvar->type && !strcmp(ivar->str,jvar->str) ) return UINT32_MAX;  // exact match, best possibility
            if ( ivar->type & jvar->type && multi_is_subset(ivar,jvar) ) return UINT32_MAX; // one of the alleles is identical

            uint32_t score = SR_SCORE(srt,ivar->type,jvar->type);
            if ( !score ) return 0;     // some of the varsets in the two groups are not compatible, will not pair
            if ( min>score ) min = score;
        }
    }
    if ( srt->pair & BCF_SR_PAIR_EXACT ) return 0;

    assert( min!=UINT32_MAX );

    uint32_t cnt = 0;
    for (i=0; i<iv->nvar; i++) cnt += srt->var[iv->var[i]].nvcf;
    for (j=0; j<jv->nvar; j++) cnt += srt->var[jv->var[j]].nvcf;

    return (1u<<(28+min)) + cnt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x148(%rax), %rax
movslq -0x14(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x148(%rax), %rax
movslq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xe2057
movq -0x10(%rbp), %rax
movq 0x108(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x2c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xe2047
movq -0x10(%rbp), %rax
movq 0x108(%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x30(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c0(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0xe1f93
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x48(%rbp), %rcx
cmpl 0x8(%rcx), %eax
je 0xe1f4c
jmp 0xe2039
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rsi
callq 0x46b0
cmpl $0x0, %eax
jne 0xe1f70
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe2146
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xe3360
cmpl $0x0, %eax
je 0xe1f8e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe2146
jmp 0xe2039
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x48(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0xe1fc7
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rsi
callq 0x46b0
cmpl $0x0, %eax
jne 0xe1fc7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe2146
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x48(%rbp), %rcx
andl 0x8(%rcx), %eax
cmpl $0x0, %eax
je 0xe1ff8
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xe3530
cmpl $0x0, %eax
je 0xe1ff8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe2146
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
movl 0x8(%rcx), %ecx
shll $0x4, %ecx
movq -0x48(%rbp), %rdx
orl 0x8(%rdx), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0xe2029
movl $0x0, -0x4(%rbp)
jmp 0xe2146
movl -0x34(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jbe 0xe2037
movl -0x4c(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0xe2039
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xe1ef0
jmp 0xe2049
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xe1eb4
movq -0x10(%rbp), %rax
movl 0x1c0(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0xe2075
movl $0x0, -0x4(%rbp)
jmp 0xe2146
cmpl $-0x1, -0x34(%rbp)
je 0xe207d
jmp 0xe209c
leaq 0x36d0b(%rip), %rdi     # 0x118d8f
leaq 0x36c3b(%rip), %rsi     # 0x118cc6
movl $0xb9, %edx
leaq 0x36d08(%rip), %rcx     # 0x118d9f
callq 0x42d0
movl $0x0, -0x50(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xe20eb
movq -0x10(%rbp), %rax
movq 0x108(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x2c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xe20aa
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xe2133
movq -0x10(%rbp), %rax
movq 0x108(%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x30(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xe20f2
movl -0x34(%rbp), %ecx
addl $0x1c, %ecx
movl $0x1, %eax
shll %cl, %eax
addl -0x50(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop