// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/errmod.c
// Function: cal_coef
static int cal_coef(errmod_t *em, double depcorr, double eta)
{
    int k, n, q;
    double sum, sum1;
    double *lC;

    // initialize ->fk
    em->fk = (double*)calloc(256, sizeof(double));
    if (!em->fk) return -1;
    em->fk[0] = 1.0;
    for (n = 1; n < 256; ++n)
        em->fk[n] = pow(1. - depcorr, n) * (1.0 - eta) + eta;

    // initialize ->beta
    em->beta = (double*)calloc(256 * 256 * 64, sizeof(double));
    if (!em->beta) return -1;

    lC = logbinomial_table( 256 );
    if (!lC) return -1;

    for (q = 1; q < 64; ++q) {
        double e = pow(10.0, -q/10.0);
        double le = log(e);
        double le1 = log(1.0 - e);
        for (n = 1; n <= 255; ++n) {
            double *beta = em->beta + (q<<16|n<<8);
            sum1 = lC[n<<8|n] + n*le;
            beta[n] = HUGE_VAL;
            for (k = n - 1; k >= 0; --k, sum1 = sum) {
                sum = sum1 + log1p(exp(lC[n<<8|k] + k*le + (n-k)*le1 - sum1));
                beta[k] = -10. / M_LN10 * (sum1 - sum);
            }
        }
    }

    // initialize ->lhet
    em->lhet = (double*)calloc(256 * 256, sizeof(double));
    if (!em->lhet) {
        free(lC);
        return -1;
    }
    for (n = 0; n < 256; ++n)
        for (k = 0; k < 256; ++k)
            em->lhet[n<<8|k] = lC[n<<8|k] - M_LN2 * n;
    free(lC);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movsd %xmm1, -0x20(%rbp)
movl $0x100, %edi            # imm = 0x100
movl $0x8, %esi
callq 0x16060
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x26397
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x266cc
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsd 0x109c89(%rip), %xmm0   # 0x130030
movsd %xmm0, (%rax)
movl $0x1, -0x28(%rbp)
cmpl $0x100, -0x28(%rbp)     # imm = 0x100
jge 0x26408
movsd 0x109c6d(%rip), %xmm0   # 0x130030
subsd -0x18(%rbp), %xmm0
cvtsi2sdl -0x28(%rbp), %xmm1
callq 0x16660
movsd 0x109c56(%rip), %xmm2   # 0x130030
subsd -0x20(%rbp), %xmm2
movsd -0x20(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x263b2
movl $0x400000, %edi         # imm = 0x400000
movl $0x8, %esi
callq 0x16060
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x26439
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x266cc
movl $0x100, %edi            # imm = 0x100
callq 0x271b0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x2645a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x266cc
movl $0x1, -0x2c(%rbp)
cmpl $0x40, -0x2c(%rbp)
jge 0x26607
xorl %eax, %eax
subl -0x2c(%rbp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x109d1c(%rip), %xmm0   # 0x130198
divsd %xmm0, %xmm1
movsd 0x109d10(%rip), %xmm0   # 0x130198
callq 0x16660
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
callq 0x14e90
movsd %xmm0, -0x58(%rbp)
movsd 0x109b87(%rip), %xmm0   # 0x130030
subsd -0x50(%rbp), %xmm0
callq 0x14e90
movsd %xmm0, -0x60(%rbp)
movl $0x1, -0x28(%rbp)
cmpl $0xff, -0x28(%rbp)
jg 0x265f7
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
shll $0x10, %ecx
movl -0x28(%rbp), %edx
shll $0x8, %edx
orl %edx, %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rax
movl -0x28(%rbp), %ecx
shll $0x8, %ecx
orl -0x28(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
cvtsi2sdl -0x28(%rbp), %xmm0
movsd -0x58(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x68(%rbp), %rax
movslq -0x28(%rbp), %rcx
movsd 0x10ac14(%rip), %xmm0   # 0x131140
movsd %xmm0, (%rax,%rcx,8)
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x265e7
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x48(%rbp), %rax
movl -0x28(%rbp), %ecx
shll $0x8, %ecx
orl -0x24(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
cvtsi2sdl -0x24(%rbp), %xmm1
movsd -0x58(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd -0x60(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
subsd -0x40(%rbp), %xmm0
callq 0x144b0
callq 0x14650
movaps %xmm0, %xmm1
movsd -0x70(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x40(%rbp), %xmm1
subsd -0x38(%rbp), %xmm1
movsd 0x10ab8a(%rip), %xmm0   # 0x131148
mulsd %xmm1, %xmm0
movq -0x68(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x2653a
jmp 0x265e9
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x264bf
jmp 0x265f9
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x26461
movl $0x10000, %edi          # imm = 0x10000
movl $0x8, %esi
callq 0x16060
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x26641
movq -0x48(%rbp), %rdi
callq 0x14ef0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x266cc
movl $0x0, -0x28(%rbp)
cmpl $0x100, -0x28(%rbp)     # imm = 0x100
jge 0x266bc
movl $0x0, -0x24(%rbp)
cmpl $0x100, -0x24(%rbp)     # imm = 0x100
jge 0x266af
movq -0x48(%rbp), %rax
movl -0x28(%rbp), %ecx
shll $0x8, %ecx
orl -0x24(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
cvtsi2sdl -0x28(%rbp), %xmm0
movsd 0x10aab5(%rip), %xmm2   # 0x131138
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x28(%rbp), %ecx
shll $0x8, %ecx
orl -0x24(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x26658
jmp 0x266b1
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x26648
movq -0x48(%rbp), %rdi
callq 0x14ef0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)