// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/syncasm.c
// Function: utg_avg_cov
static inline double utg_avg_cov(scg_t *scg, const scg_utg_t *s)
{
    if (s->del) return .0;

    uint64_t i, u;
    double *cov, avg_cov;
    syncmer_t *scm;
    
    scm = scg_a_scm(scg);
    MYCALLOC(cov, s->n);
    // try to use single copy syncmers
    for (i = 0; i < s->n; ++i) {
        u = s->a[i]>>1;
        if (scm_utg_n(scg, u) == 1)
            cov[i] = scm[u].cov;
    }
    qsort(cov, s->n, sizeof(double), dbl_cmpfunc);
    i = 0;
    while (i < s->n && cov[i] < DBL_EPSILON) ++i;

    if (i == s->n) {
        // using all syncmers
        MYBZERO(cov, s->n);
        for (i = 0; i < s->n; ++i)
            cov[i] = scm[s->a[i]>>1].cov;
        qsort(cov, s->n, sizeof(double), dbl_cmpfunc);
        i = 0;
    }
    // calculate average using [Q1-IQR, Q3+IQR]
    avg_cov = average_IQR(&cov[i], s->n - i, 1);
    
    free(cov);
    
    return avg_cov;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x565f
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x5860
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x8, %esi
callq 0x2250
movq %rax, -0x30(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x5716
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x28(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
subq %rcx, %rax
sarq $0x4, %rax
cmpq $0x1, %rax
jne 0x5703
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rcx
shlq $0x5, %rcx
movl 0x10(%rax,%rcx), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cvtsi2sd %eax, %xmm0
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x5705
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x568b
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl $0x8, %edx
leaq 0x63a3(%rip), %rcx      # 0xbad0
callq 0x20d0
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rdx
xorl %eax, %eax
cmpq (%rdx), %rcx
movb %al, -0x41(%rbp)
jae 0x5767
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
movsd 0x2801c(%rip), %xmm0    # 0x2d778
ucomisd (%rax,%rcx,8), %xmm0
seta %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x5770
jmp 0x577e
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x573a
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x5822
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x21f0
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x57fe
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq -0x20(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shlq $0x4, %rcx
andq $-0x20, %rcx
movl 0x10(%rax,%rcx), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cvtsi2sd %eax, %xmm0
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x57ad
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl $0x8, %edx
leaq 0x62bb(%rip), %rcx      # 0xbad0
callq 0x20d0
movq $0x0, -0x20(%rbp)
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
subq -0x20(%rbp), %rax
movl %eax, %esi
movl $0x1, %edx
callq 0xbb20
movsd %xmm0, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x2060
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)