// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/probaln.c
// Function: probaln_glocal
int probaln_glocal(const uint8_t *ref, int l_ref, const uint8_t *query,
                   int l_query, const uint8_t *iqual, const probaln_par_t *c,
                   int *state, uint8_t *q)
{
    double *f = NULL, *b = NULL, *s = NULL, m[9], sI, sM, bI, bM;
    float *qual = NULL;
    int bw, bw2, i, k, is_backward = 1, Pr;

    if ( l_ref<0 || l_query<0 || l_query >= INT_MAX - 2) {
        errno = EINVAL;
        return INT_MIN;
    }
    if (l_ref==0 || l_query==0)
        return 0;  // Is this actually invalid??

    /*** initialization ***/
    is_backward = state && q? 1 : 0;
    bw = l_ref > l_query? l_ref : l_query;
    if (bw > c->bw) bw = c->bw;
    if (bw < abs(l_ref - l_query)) bw = abs(l_ref - l_query);
    bw2 = bw * 2 + 1;
    size_t i_dim = bw2 < l_ref ? (size_t) bw2*3+6 : (size_t) l_ref*3+6;

    // allocate the forward and backward matrices f[][] and b[][]
    // and the scaling array s[]
    // Ideally these callocs would be mallocs + initialisation of
    // the few bits needed.
    if (SIZE_MAX / (l_query+1) / i_dim < sizeof(double)) {
        errno = ENOMEM; // Allocation would fail
        return INT_MIN;
    }
    f = calloc((l_query+1)*i_dim, sizeof(double));
    if (!f) goto fail;
    if (is_backward) {
        b = calloc((l_query+1)*i_dim, sizeof(double));
        if (!b) goto fail;
    }

    // s[] is the scaling factor to avoid underflow
    s = malloc((l_query+2) * sizeof(double));
    if (!s) goto fail;

    // initialize qual
    qual = malloc(l_query * sizeof(float));
    if (!qual) goto fail;
    if (g_qual2prob[0] == 0)
        for (i = 0; i < 256; ++i)
            g_qual2prob[i] = pow(10, -i/10.);
    qual[0] = 0.0; // Should be unused
    for (i = 0; i < l_query; ++i)
        qual[i] = g_qual2prob[iqual? iqual[i] : 30];

    // initialize transition probability
    // the value here seems not to affect results; FIXME: need proof
    sM = sI = 1. / (2 * l_query + 2);
    m[0*3+0] = (1 - c->d - c->d) * (1 - sM);
    m[0*3+1] = m[0*3+2] = c->d * (1 - sM);
    m[1*3+0] = (1 - c->e) * (1 - sI);
    m[1*3+1] = c->e * (1 - sI);
    m[1*3+2] = 0.;
    m[2*3+0] = 1 - c->e;
    m[2*3+1] = 0.;
    m[2*3+2] = c->e;
    bM = (1 - c->d) / l_ref; // (bM+bI)*l_ref==1
    bI = c->d / l_ref;

    // f[] and b[] are 2-d arrays of three scores, with rows along the
    // query and columns across the band.  The first query base and
    // first band position appear at index 1 allowing edge conditions
    // to be stored in index 0.  Hence the loops below appear to use
    // 1-based indexing instead of 0-based as you'd normally expect in C,
    // and the sequences are accessed using query[i - 1] and ref[k - 1].

    /*** forward ***/
    // f[0]
    set_u(k, bw, 0, 0);
    f[0*i_dim+k] = s[0] = 1.;
    { // f[1]
        double *fi = &f[1*i_dim], sum;
        int beg = 1, end = l_ref < bw + 1? l_ref : bw + 1;
        for (k = beg, sum = 0.; k <= end; ++k) {
            int u;
            double e = (ref[k - 1] > 3 || query[0] > 3)? 1. : ref[k - 1] == query[0]? 1. - qual[0] : qual[0] * EM;
            set_u(u, bw, 1, k);
            fi[u+0] = e * bM; fi[u+1] = EI * bI;
            sum += fi[u] + fi[u+1];
        }
        s[1] = sum;
    }
    // f[2..l_query]
    for (i = 2; i <= l_query; ++i) {
        double *fi = &f[i*i_dim], *fi1 = &f[(i-1)*i_dim], sum, qli = qual[i-1];
        int beg = 1, end = l_ref, x;
        uint8_t qyi = query[i - 1];
        x = i - bw; beg = beg > x? beg : x; // band start
        x = i + bw; end = end < x? end : x; // band end

        // NB end-beg is almost always 14 (99.9% of the time)
        // Hence not a large volume to parallelise.
        //
        // Maybe stripe in diagonal doing 14 lines together?
        //
        // Consider rotation? 150x14 vs 14x150 so inner loop
        // takes longer.

        double E[] = {
            qli * EM, // 00
            1. - qli, // 01
            1.,       // 10
            1.,       // 11
        };
        double M = 1./s[i-1];

        // Note this code has the original version listed here (albeit
        // with improved formatting), but we do not compile using
        // -DPROBALN_ORIG.  The purpose of this code is to act as an
        // easier(?) to understand version of the heavily optimised
        // version following it and as an easy validation path in case
        // of any differences in results.
#ifdef PROBALN_ORIG
        for (k = beg, sum = 0.; k <= end; ++k) {
            int u, v11, v01, v10;
            double e;
            e = E[(ref[k - 1] > 3 || qyi > 3)*2 + (ref[k - 1] == qyi)];
            set_u(u, bw, i, k);
            set_u(v11, bw, i-1, k-1);
            set_u(v10, bw, i-1, k);
            set_u(v01, bw, i, k-1);
            fi[u+0] = e * (m[0] * M*fi1[v11+0] + m[3] * M*fi1[v11+1] + m[6] * M*fi1[v11+2]);
            fi[u+1] = EI * (m[1] * M*fi1[v10+0] + m[4] * M*fi1[v10+1]);
            fi[u+2] = m[2] * fi[v01+0] + m[8] * fi[v01+2];
            sum += fi[u] + fi[u+1] + fi[u+2];
        }
#else
        // We use EI*(M*m[1]*? + M*m[4]*?) a lot.  So factor it out here.
        double xm[5];
        xm[0] =    M*m[0];
        xm[1] =    M*m[3];
        xm[2] =    M*m[6];
        xm[3] = EI*M*m[1];
        xm[4] = EI*M*m[4];

        {
            int u, v11;
            set_u(u,   bw, i,   beg);
            set_u(v11, bw, i-1, beg-1);
            // Rather than recompute k->{u,v01,v10,v11} each loop
            // we just increment the pointers.
            double *xi = &fi[u];
            double *yi = &fi1[v11];
            // Derived from xi[0,2] in previous loop iter.
            double  l_x0 = m[2]*xi[0];
            double  l_x2 = m[8]*xi[2];
            for (k = beg, sum = 0.; k <= end; ++k, xi+=3, yi+=3) {
                int cond = (ref[k-1] > 3 || qyi > 3)*2 + (ref[k-1] == qyi);

                double z0 = xm[0]*yi[0];
                double z1 = xm[1]*yi[1];
                double z2 = xm[2]*yi[2];
                double z3 = xm[3]*yi[3];
                double z4 = xm[4]*yi[4];

                xi[0] = E[cond] * (z0+z1+z2);
                xi[1] = z3 + z4;
                xi[2] = l_x0 + l_x2;
                sum  += xi[0] + xi[1] + xi[2];

                l_x0 = m[2]*xi[0];
                l_x2 = m[8]*xi[2];
            }
        }
#endif
        s[i] = sum;
    }

    { // f[l_query+1]
        double sum;
        double M = 1./s[l_query];
        // Note that this goes from 1 to l_ref inclusive, but as the
        // alignment is banded not all of the values will have been
        // calculated (the rest are taken as 0), so the summation
        // actually goes over the values set in the last iteration of
        // the previous loop (when i = l_query).  For some reason lost to
        // time this is done by looking for valid values of 'u' instead of
        // working out 'beg' and 'end'.

        // From HTSlib 1.8 to 1.17, the endpoint was incorrectly set
        // to i_dim - 3.  When l_query <= bandwidth, this caused the last
        // column to be missed, and if l_ref == l_query then a match at the end
        // could incorrectly be reported as an insertion.  See #1605.

        for (k = 1, sum = 0.; k <= l_ref; ++k) {
            int u;
            set_u(u, bw, l_query, k);
            if (u < 3 || u >= i_dim) continue;
            sum += M*f[l_query*i_dim + u+0] * sM + M*f[l_query*i_dim + u+1] * sI;
        }
        s[l_query+1] = sum; // the last scaling factor
    }
    { // compute likelihood
        double p = 1., Pr1 = 0.;
        for (i = 0; i <= l_query + 1; ++i) {
            p *= s[i];
            if (p < 1e-100) Pr1 += -4.343 * log(p), p = 1.;
        }
        Pr1 += -4.343 * log(p * l_ref * l_query);
        Pr = (int)(Pr1 + .499);
        if (!is_backward) { // skip backward and MAP
            free(f); free(s); free(qual);
            return Pr;
        }
    }
    /*** backward ***/
    // b[l_query] (b[l_query+1][0]=1 and thus \tilde{b}[][]=1/s[l_query+1]; this is where s[l_query+1] comes from)
    for (k = 1; k <= l_ref; ++k) {
        int u;
        double *bi = &b[l_query*i_dim];
        set_u(u, bw, l_query, k);
        if (u < 3 || u >= i_dim) continue;
        bi[u+0] = sM / s[l_query] / s[l_query+1]; bi[u+1] = sI / s[l_query] / s[l_query+1];
    }
    // b[l_query-1..1]
    for (i = l_query - 1; i >= 1; --i) {
        int beg = 1, end = l_ref, x;
        double *bi = &b[i*i_dim], *bi1 = &b[(i+1)*i_dim], y = (i > 1), qli1 = qual[i];
        uint8_t qyi1 = query[i];
        x = i - bw; beg = beg > x? beg : x;
        x = i + bw; end = end < x? end : x;
        double E[] = {
            qli1 * EM, //000
            1. - qli1, //001
            1.,        //010
            1.,        //011
            //0,0,0,0    //1xx
        };

#ifdef PROBALN_ORIG
        for (k = end; k >= beg; --k) {
            int u, v11, v01, v10;
            double e;
            set_u(u, bw, i, k);
            set_u(v11, bw, i+1, k+1);
            set_u(v10, bw, i+1, k);
            set_u(v01, bw, i, k+1);
            e = (k>=l_ref)?0 :E[(ref[k] > 3 || qyi1 > 3)*2 + (ref[k] == qyi1)] * bi1[v11];
            bi[u+0] = e * m[0] + EI * m[1] * bi1[v10+1] + m[2] * bi[v01+2]; // bi1[v11] has been foled into e.
            bi[u+1] = e * m[3] + EI * m[4] * bi1[v10+1];
            bi[u+2] = (e * m[6] + m[8] * bi[v01+2]) * y;
//          fprintf(stderr, "B (%d,%d;%d): %lg,%lg,%lg\n", i, k, u, bi[u], bi[u+1], bi[u+2]); // DEBUG
        }
        // rescale
        int _beg, _end;
        set_u(_beg, bw, i, beg); set_u(_end, bw, i, end); _end += 2;
        for (k = _beg, y = 1./s[i]; k <= _end; ++k) bi[k] *= y;
#else
        {
            int u, v10;
            set_u(u,   bw, i,   end);
            set_u(v10, bw, i+1, end);
            // Rather than recompute k->{u,v01,v10,v11} each loop
            // we just increment the pointers.
            double *xi = &bi[u];
            double *yi = &bi1[v10];
            // NB xi[5] is equiv to v01+2.
            double xi_5 = xi[5];
            // Manual loop invariant removal
            double e1 = EI*m[1];
            double e4 = EI*m[4];
            // Do renorm too in the same pass.
            double n = 1./s[i];
            for (k = end; k >= beg; --k, xi -= 3, yi -= 3) {
                double e = (k>=l_ref)
                    ? 0
                    : E[(ref[k]>3 || qyi1>3)*2 + (ref[k] == qyi1)] * yi[3];

                xi[1] =  e * m[3] +   e4 * yi[1];
                xi[0] =  e * m[0] +   e1 * yi[1]  + m[2] * xi_5;
                xi[2] = (e * m[6] + m[8] * xi_5) * y;
                // bi[u+2] from this iter becomes bi[v01+2] in next iter
                xi_5 = xi[2];

                // rescale
                xi[1] *= n;
                xi[0] *= n;
                xi[2] *= n;
            }
        }
#endif
    }
    { // b[0]
        int beg = 1, end = l_ref < bw + 1? l_ref : bw + 1;
        double sum = 0.;
        for (k = end; k >= beg; --k) {
            int u;
            double e = (ref[k - 1] > 3 || query[0] > 3)? 1. : ref[k - 1] == query[0]? 1. - qual[0] : qual[0] * EM;
            set_u(u, bw, 1, k);
            if (u < 3 || u >= i_dim) continue;
            sum += e * b[1*i_dim + u+0] * bM + EI * b[1*i_dim + u+1] * bI;
        }
        set_u(k, bw, 0, 0);
        b[0*i_dim + k] = sum / s[0]; // if everything works as is expected, b[0][k] == 1.0
    }
    /*** MAP ***/
    for (i = 1; i <= l_query; ++i) {
        double sum = 0., *fi = &f[i*i_dim], *bi = &b[i*i_dim], max = 0.;
        int beg = 1, end = l_ref, x, max_k = -1;
        x = i - bw; beg = beg > x? beg : x;
        x = i + bw; end = end < x? end : x;
        double M = 1./s[i];
#ifdef PROBALN_ORIG
        for (k = beg; k <= end; ++k) {
            int u;
            double z;
            set_u(u, bw, i, k);
            z = M*fi[u+0] * bi[u+0];
            if (z > max) max = z, max_k = (k-1)<<2 | 0;
            sum += z;
            z = M*fi[u+1] * bi[u+1];
            if (z > max) max = z, max_k = (k-1)<<2 | 1;
            sum += z;
        }
#else
        {
            int u;
            set_u(u, bw, i, beg);
            for (k = beg; k <= end; ++k, u+=3) {
                double z1, z2;
                z1 = M*fi[u+0] * bi[u+0];
                z2 = M*fi[u+1] * bi[u+1];
                int which = z2 > z1; // strictly z2 >= z1 matches old code
                double zm = which ? z2 : z1;
                if (zm > max) {
                    max   = zm;
                    max_k = (k-1)<<2 | which;
                }
                sum += z1 + z2;
            }
        }
#endif
        max /= sum; sum *= s[i]; // if everything works as is expected, sum == 1.0
        if (state) state[i-1] = max_k;
        if (q) k = (int)(-4.343 * log(1. - max) + .499), q[i-1] = k > 100? 99 : k;
#ifdef PROBALN_MAIN
        k = 0;
        set_u(k, bw, 0, 0);
        fprintf(stderr, "(%.10lg,%.10lg) (%d,%d:%c,%c:%d) %lg\n", b[0][k], sum, i-1, max_k>>2,
                "ACGT"[query[i - 1]], "ACGT"[ref[(max_k>>2)]], max_k&3, max); // DEBUG
#endif
    }

    /*** free ***/
    free(f); free(b); free(s); free(qual);
    return Pr;

 fail:
    free(f); free(b); free(s); free(qual);
    return INT_MIN;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movl %esi, %ebx
movl %ecx, %eax
orl %esi, %eax
setns %al
cmpl $0x7ffffffd, %ecx       # imm = 0x7FFFFFFD
setl %sil
testb %al, %sil
jne 0x89ecf
callq 0x4050
movl $0x16, (%rax)
movl $0x80000000, %eax       # imm = 0x80000000
jmp 0x89ee5
movq %rdi, %r12
testl %ebx, %ebx
sete %dil
testl %ecx, %ecx
sete %sil
xorl %eax, %eax
orb %dil, %sil
je 0x89ef7
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r9, %r15
movq %r8, %r14
movq %rdx, 0x88(%rsp)
cmpq $0x0, 0x130(%rsp)
setne %bpl
cmpq $0x0, 0x138(%rsp)
setne %r10b
movl %ebx, %eax
subl %ecx, %eax
movl %ecx, %edi
cmovgl %ebx, %edi
movl 0x8(%r9), %edx
cmpl %edx, %edi
cmovgel %edx, %edi
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
cmpl %esi, %edi
cmovgl %edi, %esi
leal 0x1(,%rsi,2), %r8d
cmpl %ebx, %r8d
cmovgel %ebx, %r8d
leaq (%r8,%r8,2), %r13
addq $0x6, %r13
leal 0x1(%rcx), %edi
movq $-0x1, %rax
xorl %edx, %edx
divq %rdi
xorl %edx, %edx
divq %r13
cmpq $0x7, %rax
ja 0x89f7e
callq 0x4050
movl $0xc, (%rax)
jmp 0x89ec8
movb %r10b, 0x18(%rsp)
movq %r8, 0x68(%rsp)
movq %rcx, 0x10(%rsp)
movq %rsi, 0x38(%rsp)
movq %r13, 0x50(%rsp)
movq %rdi, 0x80(%rsp)
imulq %rdi, %r13
movl $0x8, %esi
movq %r13, %rdi
callq 0x4300
testq %rax, %rax
je 0x89fea
movq %rax, 0x20(%rsp)
andb 0x18(%rsp), %bpl
movb %bpl, 0xf(%rsp)
je 0x89ff4
movl $0x8, %esi
movq %r13, %rdi
callq 0x4300
movq %rax, %r13
testq %rax, %rax
movq 0x10(%rsp), %rax
jne 0x89ffc
xorl %ebx, %ebx
xorl %r13d, %r13d
jmp 0x8a24b
xorl %ebx, %ebx
xorl %r13d, %r13d
jmp 0x8a25c
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
movl %eax, %ebp
leaq 0x10(,%rbp,8), %rdi
callq 0x4680
testq %rax, %rax
je 0x8a249
movq %rax, 0x18(%rsp)
movq %rbp, 0x40(%rsp)
leaq (,%rbp,4), %rdi
callq 0x4680
testq %rax, %rax
je 0x8a252
movq %rax, 0x58(%rsp)
movq %r13, 0x48(%rsp)
movss 0x2aeba(%rip), %xmm0    # 0xb4f00
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x8a08b
jp 0x8a08b
xorl %ebp, %ebp
leaq 0x2aea7(%rip), %r13     # 0xb4f00
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0xfe28(%rip), %xmm0     # 0x99e90
divsd %xmm0, %xmm1
callq 0x48c0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%r13)
decq %rbp
addq $0x4, %r13
cmpq $-0x100, %rbp
jne 0x8a059
movq 0x58(%rsp), %r9
movl $0x0, (%r9)
cmpl $0x0, 0x10(%rsp)
movq 0x38(%rsp), %rdx
movq 0x50(%rsp), %rsi
movq 0x18(%rsp), %r11
movq 0x88(%rsp), %r13
movq 0x40(%rsp), %rdi
leaq 0x2ae41(%rip), %r8      # 0xb4f00
jle 0x8a0e8
xorl %eax, %eax
testq %r14, %r14
je 0x8a0cf
movzbl (%r14,%rax), %ecx
jmp 0x8a0d4
movl $0x1e, %ecx
movss (%r8,%rcx,4), %xmm0
movss %xmm0, (%r9,%rax,4)
incq %rax
cmpq %rax, %rdi
jne 0x8a0c3
movq 0x10(%rsp), %rax
leal 0x2(,%rax,2), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd 0xb18d(%rip), %xmm0     # 0x95290
movapd %xmm0, %xmm6
divsd %xmm1, %xmm6
movss (%r15), %xmm1
movss 0x4(%r15), %xmm2
movss 0x16902(%rip), %xmm3    # 0xa0a20
movaps %xmm3, %xmm4
subss %xmm1, %xmm4
movaps %xmm4, %xmm5
subss %xmm1, %xmm5
cvtss2sd %xmm5, %xmm8
movapd %xmm0, %xmm9
movsd %xmm6, 0x70(%rsp)
subsd %xmm6, %xmm9
cvtss2sd %xmm1, %xmm13
subss %xmm2, %xmm3
cvtss2sd %xmm3, %xmm14
cvtss2sd %xmm2, %xmm15
xorps %xmm2, %xmm2
cvtsi2ss %ebx, %xmm2
divss %xmm2, %xmm4
xorps %xmm6, %xmm6
cvtss2sd %xmm4, %xmm6
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm7
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%r11)
movq 0x20(%rsp), %rax
movq %rcx, 0x18(%rax)
leal 0x1(%rdx), %edi
cmpl %ebx, %edi
cmovgel %ebx, %edi
testl %ebx, %ebx
movq %rdi, 0xc8(%rsp)
jle 0x8a279
leaq (%rax,%rsi,8), %rax
movl $0x1, %ecx
movl $0x1, %esi
subl %edx, %esi
xorl %edx, %edx
testl %esi, %esi
cmovlel %edx, %esi
movsd 0xefed(%rip), %xmm2     # 0x991a8
mulsd %xmm7, %xmm2
cmpl $0x2, %edi
cmovgel %edi, %ecx
leal (%rsi,%rsi,2), %edi
movl $0x7, %esi
subl %edi, %esi
xorps %xmm1, %xmm1
movsd 0x16836(%rip), %xmm3    # 0xa0a10
movq 0x80(%rsp), %r10
movb (%r12,%rdx), %dil
movapd %xmm0, %xmm4
cmpb $0x3, %dil
ja 0x8a21d
movb (%r13), %r8b
movapd %xmm0, %xmm4
cmpb $0x3, %r8b
ja 0x8a21d
xorps %xmm5, %xmm5
cvtss2sd (%r9), %xmm5
cmpb %r8b, %dil
jne 0x8a215
movapd %xmm0, %xmm4
subsd %xmm5, %xmm4
jmp 0x8a21d
mulsd %xmm3, %xmm5
movapd %xmm5, %xmm4
leal -0x1(%rsi), %edi
mulsd %xmm6, %xmm4
movslq %edi, %rdi
movsd %xmm4, (%rax,%rdi,8)
movslq %esi, %rsi
movsd %xmm2, (%rax,%rsi,8)
addsd %xmm2, %xmm4
addsd %xmm4, %xmm1
addl $0x3, %esi
incq %rdx
cmpq %rdx, %rcx
jne 0x8a1e2
jmp 0x8a284
xorl %ebx, %ebx
movq 0x20(%rsp), %rax
jmp 0x8a25c
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rbx
movq %rax, %rdi
callq 0x45c0
movq %r13, %rdi
callq 0x45c0
movq %rbx, %rdi
callq 0x45c0
jmp 0x89ec8
xorps %xmm1, %xmm1
movq 0x80(%rsp), %r10
movsd %xmm7, 0xd0(%rsp)
movsd %xmm6, 0xd8(%rsp)
mulsd %xmm9, %xmm8
movsd %xmm8, 0x98(%rsp)
mulsd %xmm9, %xmm13
movapd %xmm9, %xmm0
mulsd %xmm14, %xmm0
movsd %xmm0, 0x90(%rsp)
mulsd %xmm15, %xmm9
movsd %xmm9, 0x78(%rsp)
movsd %xmm1, 0x8(%r11)
cmpl $0x2, 0x10(%rsp)
movl %ebx, 0x64(%rsp)
jl 0x8a58c
movl $0x2, %eax
movq 0x38(%rsp), %rdx
subl %edx, %eax
movl %edx, %ecx
movq %rcx, 0x30(%rsp)
movq 0x68(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq 0x30(,%rcx,8), %rsi
movq %rsi, 0x28(%rsp)
movq 0x20(%rsp), %r8
leaq (%r8,%rcx,8), %rsi
addq $0x30, %rsi
movl $0x1, %edi
subl %edx, %edi
shlq $0x4, %rcx
addq %rcx, %r8
addq $0x70, %r8
movl $0x2, %r9d
movsd 0x166dc(%rip), %xmm0    # 0xa0a10
movsd 0xaf54(%rip), %xmm1     # 0x95290
movsd 0xee64(%rip), %xmm2     # 0x991a8
cmpl $0x2, %eax
movl $0x1, %r13d
cmovgel %eax, %r13d
testl %edi, %edi
movl $0x0, %ebp
cmovgl %edi, %ebp
testl %eax, %eax
movl $0x0, %r10d
cmovgl %eax, %r10d
movq 0x58(%rsp), %rcx
xorps %xmm3, %xmm3
cvtss2sd -0x4(%rcx,%r9,4), %xmm3
movq %r11, %r14
movq 0x88(%rsp), %rcx
movb -0x1(%rcx,%r9), %r11b
movq %r9, %rcx
subq 0x30(%rsp), %rcx
cmpl $0x2, %ecx
movl $0x1, %r15d
cmovgel %ecx, %r15d
movq 0x38(%rsp), %rdx
addl %r9d, %edx
cmpl %ebx, %edx
cmovgel %ebx, %edx
movapd %xmm1, %xmm4
subsd %xmm3, %xmm4
mulsd %xmm0, %xmm3
movsd %xmm3, 0xa0(%rsp)
movsd %xmm4, 0xa8(%rsp)
movabsq $0x3ff0000000000000, %rbx # imm = 0x3FF0000000000000
movq %rbx, 0xb0(%rsp)
movq %rbx, 0xb8(%rsp)
movapd %xmm1, %xmm3
divsd -0x8(%r14,%r9,8), %xmm3
movapd %xmm3, %xmm4
mulsd %xmm2, %xmm4
xorpd %xmm8, %xmm8
cmpl %edx, %r15d
jg 0x8a55a
leaq -0x1(%r13), %r14
leal (%r13,%r13,2), %ebx
leal (%rbp,%rbp,2), %ebp
movl %ebx, %r13d
subl %ebp, %r13d
movslq %r13d, %r13
leaq (%rsi,%r13,8), %r13
leal (%r10,%r10,2), %r10d
subl %r10d, %ebx
addl $0x3, %ebx
movslq %ebx, %r10
leaq (%r8,%r10,8), %r10
movsd 0x98(%rsp), %xmm5
mulsd %xmm3, %xmm5
movsd 0x90(%rsp), %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm14, %xmm3
movapd %xmm13, %xmm7
mulsd %xmm4, %xmm7
mulsd 0x78(%rsp), %xmm4
movq 0x50(%rsp), %rbx
imulq %r9, %rbx
movq 0x20(%rsp), %rbp
leaq (,%rbx,8), %rbx
addq %rbp, %rbx
testl %ecx, %ecx
movl $0x0, %ebp
cmovlel %ebp, %ecx
subl %ecx, %r15d
leal (%r15,%r15,2), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movsd (%rbx,%rcx,8), %xmm10
movsd 0x10(%rbx,%rcx,8), %xmm9
movslq %edx, %r15
xorl %ecx, %ecx
cmpb $0x4, %r11b
setae %dl
mulsd %xmm15, %xmm9
mulsd %xmm13, %xmm10
addsd %xmm10, %xmm9
movb (%r12,%r14), %bl
cmpb $0x4, %bl
setae %bpl
orb %dl, %bpl
xorl %edx, %edx
cmpb %r11b, %bl
sete %dl
movzbl %bpl, %ebx
movsd (%r13,%rcx), %xmm10
mulsd %xmm5, %xmm10
movsd 0x8(%r13,%rcx), %xmm11
mulsd %xmm6, %xmm11
addsd %xmm10, %xmm11
movsd 0x10(%r13,%rcx), %xmm10
mulsd %xmm3, %xmm10
addsd %xmm11, %xmm10
movsd 0x18(%r13,%rcx), %xmm11
mulsd %xmm7, %xmm11
movsd 0x20(%r13,%rcx), %xmm12
mulsd %xmm4, %xmm12
addsd %xmm11, %xmm12
shll $0x4, %ebx
leal (%rbx,%rdx,8), %edx
mulsd 0xa0(%rsp,%rdx), %xmm10
movsd %xmm10, -0x10(%r10,%rcx)
movsd %xmm12, -0x8(%r10,%rcx)
movsd %xmm9, (%r10,%rcx)
addsd %xmm10, %xmm12
addsd %xmm9, %xmm12
addsd %xmm12, %xmm8
incq %r14
addq $0x18, %rcx
cmpq %r15, %r14
jl 0x8a49c
movq 0x18(%rsp), %r11
movsd %xmm8, (%r11,%r9,8)
incq %r9
incl %eax
movq 0x28(%rsp), %rcx
addq %rcx, %rsi
incl %edi
addq %rcx, %r8
movq 0x80(%rsp), %r10
cmpq %r10, %r9
movl 0x64(%rsp), %ebx
jne 0x8a344
movsd 0xacfc(%rip), %xmm0     # 0x95290
xorpd %xmm1, %xmm1
movsd %xmm1, 0x30(%rsp)
movsd %xmm1, 0x28(%rsp)
testl %ebx, %ebx
movq 0x38(%rsp), %r13
movq 0x50(%rsp), %rbp
movq 0x40(%rsp), %rcx
jle 0x8a647
movapd %xmm0, %xmm1
divsd (%r11,%rcx,8), %xmm1
movq 0x10(%rsp), %rax
subl %r13d, %eax
xorl %edx, %edx
testl %eax, %eax
cmovgl %eax, %edx
movq %rbp, %rax
imulq %rcx, %rax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movl %ebx, %ecx
leal (%rdx,%rdx,2), %esi
movl $0x3, %edx
subl %esi, %edx
xorpd %xmm2, %xmm2
movsd %xmm2, 0x28(%rsp)
movsd 0x70(%rsp), %xmm4
cmpl $0x7ffffffc, %edx       # imm = 0x7FFFFFFC
ja 0x8a63f
leal 0x3(%rdx), %esi
cmpq %rsi, %rbp
jbe 0x8a63f
movsd (%rax,%rsi,8), %xmm2
mulsd %xmm1, %xmm2
movsd 0x8(%rax,%rsi,8), %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm4, %xmm3
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
movsd 0x28(%rsp), %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, 0x28(%rsp)
addl $0x3, %edx
decq %rcx
jne 0x8a600
movsd 0x28(%rsp), %xmm1
movsd %xmm1, (%r11,%r10,8)
cmpl $-0x1, 0x10(%rsp)
movsd %xmm13, 0xf0(%rsp)
movsd %xmm14, 0xe8(%rsp)
movsd %xmm15, 0xe0(%rsp)
jl 0x8a6e4
movq 0x10(%rsp), %rax
leal 0x2(%rax), %r14d
xorpd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0xabfd(%rip), %xmm0     # 0x95290
xorl %r15d, %r15d
movsd 0x1637a(%rip), %xmm1    # 0xa0a18
mulsd (%r11,%r15,8), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x8a6dc
callq 0x4390
movq 0x18(%rsp), %r11
mulsd 0xae64(%rip), %xmm0     # 0x95520
movsd 0x30(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
movsd 0x16344(%rip), %xmm1    # 0xa0a18
movsd 0xabb4(%rip), %xmm0     # 0x95290
incq %r15
cmpq %r15, %r14
jne 0x8a69e
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
mulsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sdl 0x10(%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x4390
mulsd 0xae17(%rip), %xmm0     # 0x95520
addsd 0x30(%rsp), %xmm0
addsd 0xae19(%rip), %xmm0     # 0x95530
cvttsd2si %xmm0, %eax
movl %eax, 0x60(%rsp)
cmpb $0x0, 0xf(%rsp)
je 0x8abc3
testl %ebx, %ebx
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %r8
movsd 0x98(%rsp), %xmm10
movsd 0x78(%rsp), %xmm11
movsd 0xf0(%rsp), %xmm12
movsd 0xe8(%rsp), %xmm13
movsd 0xe0(%rsp), %xmm14
movsd 0x90(%rsp), %xmm15
jle 0x8a7da
movq %rbp, %rax
imulq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movl %r8d, %ecx
subl %r13d, %ecx
xorl %edx, %edx
testl %ecx, %ecx
cmovgl %ecx, %edx
movl %ebx, %ecx
leal (%rdx,%rdx,2), %esi
movl $0x7, %edx
subl %esi, %edx
movq 0x40(%rsp), %r9
leal -0x4(%rdx), %esi
cmpl $0x7ffffffc, %esi       # imm = 0x7FFFFFFC
ja 0x8a7d2
leal -0x1(%rdx), %esi
cmpq %rsi, %rbp
jbe 0x8a7d2
movsd 0x70(%rsp), %xmm0
divsd (%rdi,%r9,8), %xmm0
divsd 0x28(%rsp), %xmm0
movsd %xmm0, (%rax,%rsi,8)
movl %edx, %esi
movsd %xmm0, (%rax,%rsi,8)
addl $0x3, %edx
decq %rcx
jne 0x8a7a1
cmpl $0x2, %r8d
movq 0x40(%rsp), %r8
jl 0x8aac3
movsd 0xe9b7(%rip), %xmm1     # 0x991a8
movapd %xmm12, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm11
movq 0x38(%rsp), %rcx
movq 0x10(%rsp), %rdi
leal -0x1(%rcx,%rdi), %eax
cltq
movslq %ebx, %r10
movl %ecx, %esi
movq 0x50(%rsp), %rdx
movq %rdx, %r9
imulq %r8, %r9
shlq $0x3, %r9
movq %r9, 0x70(%rsp)
subl %ecx, %edi
movq 0x48(%rsp), %rcx
leaq 0x10(%rcx), %r13
movq 0x68(%rsp), %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
movq $-0x30, %r9
subq %rcx, %r9
movq %r9, 0x78(%rsp)
leaq -0x1(%r8), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
movq %rcx, 0x68(%rsp)
leal -0x1(%rdi), %r11d
movsd 0xaa23(%rip), %xmm1     # 0x95290
negq %rsi
movq %rsi, 0x28(%rsp)
movsd 0x16193(%rip), %xmm2    # 0xa0a10
cmpl %eax, %ebx
movl %eax, %r15d
cmovll %ebx, %r15d
testl %edi, %edi
movl $0x0, %ebp
cmovgl %edi, %ebp
testl %r11d, %r11d
movl $0x0, %ecx
cmovgl %r11d, %ecx
movapd %xmm1, %xmm3
cmpq $0x2, %r8
jne 0x8a8aa
xorpd %xmm3, %xmm3
leaq -0x1(%r8), %r14
movq 0x58(%rsp), %rdx
xorps %xmm4, %xmm4
cvtss2sd -0x4(%rdx,%r8,4), %xmm4
movq 0x88(%rsp), %rdx
movb -0x1(%rdx,%r8), %sil
movq %r8, 0x40(%rsp)
movq 0x28(%rsp), %rdx
addq %r8, %rdx
decq %rdx
cmpl $0x2, %edx
movl $0x1, %r8d
cmovgel %edx, %r8d
movq 0x38(%rsp), %r9
movq %r14, 0x30(%rsp)
addl %r14d, %r9d
cmpl %ebx, %r9d
cmovgel %ebx, %r9d
movapd %xmm1, %xmm5
subsd %xmm4, %xmm5
mulsd %xmm2, %xmm4
movsd %xmm4, 0xa0(%rsp)
movsd %xmm5, 0xa8(%rsp)
movabsq $0x3ff0000000000000, %rbx # imm = 0x3FF0000000000000
movq %rbx, 0xb0(%rsp)
movq %rbx, 0xb8(%rsp)
cmpl %r8d, %r9d
jl 0x8aaa1
leal (%r15,%r15,2), %r14d
addl $0x3, %r14d
leal (%rbp,%rbp,2), %ebx
movl %r14d, %ebp
subl %ebx, %ebp
leal (%rcx,%rcx,2), %ecx
subl %ecx, %r14d
cmpq %r10, %rax
movq %r10, %rcx
cmovlq %rax, %rcx
movq 0x50(%rsp), %rbx
imulq 0x30(%rsp), %rbx
testl %edx, %edx
movl $0x0, %r15d
cmovlel %r15d, %edx
subl %edx, %r9d
movq 0x48(%rsp), %rdx
leaq (%rdx,%rbx,8), %rdx
leal (%r9,%r9,2), %r9d
addl $0x3, %r9d
movslq %r9d, %r9
movsd 0x28(%rdx,%r9,8), %xmm5
movslq %ebp, %rdx
movq 0x70(%rsp), %r9
leaq (%r9,%rdx,8), %r15
movslq %r14d, %rdx
movq 0x68(%rsp), %r9
leaq (%r9,%rdx,8), %rdx
movapd %xmm1, %xmm4
movq 0x18(%rsp), %r9
movq 0x40(%rsp), %rbx
divsd -0x8(%r9,%rbx,8), %xmm4
movl %r8d, %r9d
movq %r13, %r8
xorpd %xmm6, %xmm6
cmpq %r10, %rcx
jge 0x8aa08
cmpb $0x4, %sil
setae %bl
movb (%r12,%rcx), %bpl
cmpb $0x4, %bpl
setae %r14b
orb %bl, %r14b
xorl %ebx, %ebx
cmpb %sil, %bpl
sete %bl
movzbl %r14b, %r14d
shll $0x4, %r14d
leal (%r14,%rbx,8), %ebx
movsd 0xa0(%rsp,%rbx), %xmm6
mulsd 0x8(%r8,%r15), %xmm6
movsd -0x8(%r8,%r15), %xmm7
mulsd %xmm11, %xmm7
movapd %xmm6, %xmm8
mulsd %xmm15, %xmm8
addsd %xmm7, %xmm8
movsd %xmm8, -0x8(%r8,%rdx)
movsd -0x8(%r8,%r15), %xmm7
mulsd %xmm0, %xmm7
movapd %xmm6, %xmm9
mulsd %xmm10, %xmm9
addsd %xmm7, %xmm9
movapd %xmm12, %xmm7
mulsd %xmm5, %xmm7
addsd %xmm9, %xmm7
mulsd %xmm14, %xmm5
mulsd %xmm13, %xmm6
addsd %xmm5, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm4, %xmm8
movsd %xmm8, -0x8(%r8,%rdx)
mulsd %xmm4, %xmm7
movsd %xmm7, -0x10(%r8,%rdx)
movapd %xmm4, %xmm5
mulsd %xmm6, %xmm5
movsd %xmm5, (%r8,%rdx)
leaq -0x1(%rcx), %rbx
addq $-0x18, %r8
movapd %xmm6, %xmm5
cmpq %r9, %rcx
movq %rbx, %rcx
jg 0x8a9c5
decq %rax
decl %edi
addq 0x78(%rsp), %r13
decl %r11d
cmpq $0x2, 0x40(%rsp)
movq 0x30(%rsp), %r8
movl 0x64(%rsp), %ebx
jg 0x8a87d
testl %ebx, %ebx
jle 0x8abcd
movl $0x1, %eax
subl 0x38(%rsp), %eax
xorl %edx, %edx
testl %eax, %eax
cmovgl %eax, %edx
movq 0xc8(%rsp), %rcx
movl %ecx, %esi
movl %ecx, %eax
incl %eax
leal (%rcx,%rcx,2), %ecx
leal (%rdx,%rdx,2), %edx
subl %edx, %ecx
addl $0x3, %ecx
leaq (%rsi,%r12), %rdx
decq %rdx
xorpd %xmm0, %xmm0
movsd 0xa789(%rip), %xmm1     # 0x95290
movsd 0xe699(%rip), %xmm2     # 0x991a8
movsd 0x15ef9(%rip), %xmm3    # 0xa0a10
movq 0x138(%rsp), %r13
movq 0x130(%rsp), %r11
movq 0x50(%rsp), %r8
movq 0x48(%rsp), %r9
movq 0x58(%rsp), %r10
movq 0x88(%rsp), %r14
movsd 0xd8(%rsp), %xmm6
movsd 0xd0(%rsp), %xmm7
movb (%rdx), %sil
movapd %xmm1, %xmm4
cmpb $0x3, %sil
ja 0x8ab89
movb (%r14), %dil
movapd %xmm1, %xmm4
cmpb $0x3, %dil
ja 0x8ab89
xorps %xmm5, %xmm5
cvtss2sd (%r10), %xmm5
cmpb %dil, %sil
jne 0x8ab81
movapd %xmm1, %xmm4
subsd %xmm5, %xmm4
jmp 0x8ab89
mulsd %xmm3, %xmm5
movapd %xmm5, %xmm4
movl %ecx, %esi
cmpq %rsi, %r8
jbe 0x8abb4
addq %r8, %rsi
mulsd (%r9,%rsi,8), %xmm4
movsd 0x8(%r9,%rsi,8), %xmm5
mulsd %xmm2, %xmm5
mulsd %xmm7, %xmm5
mulsd %xmm6, %xmm4
addsd %xmm5, %xmm4
addsd %xmm4, %xmm0
decl %eax
addl $-0x3, %ecx
decq %rdx
cmpl $0x1, %eax
jg 0x8ab50
jmp 0x8abe6
movq 0x20(%rsp), %rdi
jmp 0x8ad8b
xorpd %xmm0, %xmm0
movq 0x138(%rsp), %r13
movq 0x130(%rsp), %r11
movq 0x48(%rsp), %r9
movq 0x18(%rsp), %rax
divsd (%rax), %xmm0
movsd %xmm0, 0x18(%r9)
cmpl $0x0, 0x10(%rsp)
jle 0x8ad7c
movq 0x38(%rsp), %rax
movl %eax, %r14d
movl $0x1, %ebp
movl $0x1, %r15d
subl %eax, %r15d
movl $0x1, %r12d
cmpl $0x2, %r15d
movl $0x1, %edi
cmovgel %r15d, %edi
testl %r15d, %r15d
movl $0x0, %esi
cmovgl %r15d, %esi
movl %r12d, %edx
subl %r14d, %edx
cmpl $0x2, %edx
cmovll %ebp, %edx
movq 0x38(%rsp), %rax
addl %r12d, %eax
cmpl %ebx, %eax
cmovgel %ebx, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movsd 0xa645(%rip), %xmm1     # 0x952a0
cmpl %eax, %edx
jg 0x8ad1c
leal (%rdi,%rdi,2), %edx
leal (%rsi,%rsi,2), %ecx
subl %ecx, %edx
addl $0x3, %edx
movl %edi, %esi
decl %esi
leal -0x4(,%rdi,4), %edi
movq 0x50(%rsp), %rcx
imulq %r12, %rcx
movq 0x20(%rsp), %r8
leaq (%r8,%rcx,8), %r8
movsd 0xa5fd(%rip), %xmm0     # 0x95290
movq 0x18(%rsp), %r9
divsd (%r9,%r12,8), %xmm0
movq 0x48(%rsp), %r9
leaq (%r9,%rcx,8), %r9
xorpd %xmm1, %xmm1
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorpd %xmm2, %xmm2
movslq %edx, %rdx
movsd (%r8,%rdx,8), %xmm3
mulsd %xmm0, %xmm3
mulsd (%r9,%rdx,8), %xmm3
leal 0x1(%rdx), %r10d
movslq %r10d, %r10
movsd (%r8,%r10,8), %xmm4
mulsd %xmm0, %xmm4
mulsd (%r9,%r10,8), %xmm4
xorl %r10d, %r10d
ucomisd %xmm3, %xmm4
movapd %xmm1, %xmm5
seta %r10b
movapd %xmm4, %xmm1
maxsd %xmm3, %xmm1
addl %edi, %r10d
ucomisd %xmm5, %xmm1
cmoval %r10d, %ecx
maxsd %xmm5, %xmm1
addsd %xmm3, %xmm4
addsd %xmm4, %xmm2
addl $0x3, %edx
incl %esi
addl $0x4, %edi
cmpl %eax, %esi
jl 0x8acb4
divsd %xmm2, %xmm1
testq %r11, %r11
je 0x8ad26
movl %ecx, -0x4(%r11,%r12,4)
testq %r13, %r13
je 0x8ad68
movsd 0xa55d(%rip), %xmm0     # 0x95290
subsd %xmm1, %xmm0
callq 0x4390
movq 0x130(%rsp), %r11
mulsd 0xa7d4(%rip), %xmm0     # 0x95520
addsd 0xa7dc(%rip), %xmm0     # 0x95530
cvttsd2si %xmm0, %eax
cmpl $0x65, %eax
movl $0x63, %ecx
cmovgel %ecx, %eax
movb %al, -0x1(%r13,%r12)
incq %r12
incl %r15d
cmpq 0x80(%rsp), %r12
jne 0x8ac1c
movq 0x20(%rsp), %rdi
callq 0x45c0
movq 0x48(%rsp), %rdi
callq 0x45c0
movq 0x18(%rsp), %rdi
callq 0x45c0
movq 0x58(%rsp), %rdi
callq 0x45c0
movl 0x60(%rsp), %eax
jmp 0x89ee5
nopl (%rax)