// File: /workspace/github_c_makefile_star2_O2/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 $0x128, %rsp            # imm = 0x128
movl %ecx, %r14d
movq %rdx, 0x60(%rsp)
movl %ecx, %eax
orl %esi, %eax
setns %al
cmpl $0x7ffffffd, %ecx       # imm = 0x7FFFFFFD
setl %cl
testb %al, %cl
jne 0x6b723
callq 0x4050
movl $0x16, (%rax)
movl $0x80000000, %ebp       # imm = 0x80000000
jmp 0x6b736
movl %esi, %ebx
testl %esi, %esi
sete %al
testl %r14d, %r14d
sete %cl
xorl %ebp, %ebp
orb %al, %cl
je 0x6b74a
movl %ebp, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %r12
cmpq $0x0, 0x160(%rsp)
setne %bpl
cmpq $0x0, 0x168(%rsp)
setne %dil
movl %ebx, %eax
subl %r14d, %eax
movl %r14d, %ecx
cmovgl %ebx, %ecx
movq %r9, 0x80(%rsp)
movl 0x8(%r9), %edx
cmpl %edx, %ecx
cmovgel %edx, %ecx
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
cmpl %edx, %ecx
cmovgl %ecx, %edx
movq %rdx, 0x20(%rsp)
leal 0x1(,%rdx,2), %esi
cmpl %ebx, %esi
cmovgel %ebx, %esi
leaq 0x6(%rsi,%rsi,2), %r13
leal 0x1(%r14), %ecx
pushq $-0x1
popq %rax
xorl %edx, %edx
divq %rcx
xorl %edx, %edx
divq %r13
cmpq $0x7, %rax
ja 0x6b7cc
callq 0x4050
movl $0xc, (%rax)
jmp 0x6b71c
movq %r8, %r15
movb %dil, 0x68(%rsp)
movq %rsi, 0x8(%rsp)
movq %r13, 0x58(%rsp)
movq %rcx, 0x70(%rsp)
imulq %rcx, %r13
pushq $0x8
popq %rsi
movq %r13, %rdi
callq 0x4300
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x6b813
andb 0x68(%rsp), %bpl
je 0x6b81d
pushq $0x8
popq %rsi
movq %r13, %rdi
callq 0x4300
testq %rax, %rax
jne 0x6b81f
xorl %ebx, %ebx
xorl %r14d, %r14d
jmp 0x6bf80
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movl %r14d, %r13d
leaq 0x10(,%r13,8), %rdi
callq 0x4680
testq %rax, %rax
je 0x6bf73
movq %rax, (%rsp)
movq %r13, 0x78(%rsp)
leaq (,%r13,4), %rdi
callq 0x4680
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x6bf77
movb %bpl, 0x34(%rsp)
movss 0x2f692(%rip), %xmm0    # 0x9af00
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x6b8b3
jp 0x6b8b3
xorl %r13d, %r13d
leaq 0x2f67e(%rip), %rbp     # 0x9af00
cmpq $-0x100, %r13
je 0x6b8b3
cvtsi2sd %r13d, %xmm1
movsd 0xe6b0(%rip), %xmm0     # 0x79f48
divsd %xmm0, %xmm1
callq 0x48c0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rbp)
decq %r13
addq $0x4, %rbp
jmp 0x6b882
movq 0x28(%rsp), %rax
andl $0x0, (%rax)
xorl %eax, %eax
testl %r14d, %r14d
movl $0x0, %esi
cmovgl %r14d, %esi
pushq $0x1e
popq %rcx
movq 0x58(%rsp), %r13
leaq 0x2f628(%rip), %rdi     # 0x9af00
cmpq %rax, %rsi
je 0x6b8fe
movq %rcx, %rdx
testq %r15, %r15
je 0x6b8ea
movzbl (%r15,%rax), %edx
movss (%rdi,%rdx,4), %xmm0
movq 0x28(%rsp), %rdx
movss %xmm0, (%rdx,%rax,4)
incq %rax
jmp 0x6b8d8
movq %rsi, 0xe8(%rsp)
leal 0x2(,%r14,2), %eax
cvtsi2sd %eax, %xmm1
movsd 0x9a16(%rip), %xmm0     # 0x75330
movapd %xmm0, %xmm6
divsd %xmm1, %xmm6
movq 0x80(%rsp), %rax
movss (%rax), %xmm2
movss 0x4(%rax), %xmm3
movss 0x15165(%rip), %xmm4    # 0x80aa0
movaps %xmm4, %xmm5
subss %xmm2, %xmm5
movaps %xmm5, %xmm1
subss %xmm2, %xmm1
movapd %xmm0, %xmm13
movsd %xmm6, 0x50(%rsp)
subsd %xmm6, %xmm13
cvtss2sd %xmm2, %xmm14
subss %xmm3, %xmm4
cvtss2sd %xmm4, %xmm15
cvtss2sd %xmm3, %xmm3
movaps %xmm3, 0x80(%rsp)
cvtsi2ss %ebx, %xmm3
divss %xmm3, %xmm5
cvtss2sd %xmm5, %xmm11
divss %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq (%rsp), %rcx
movq %rax, (%rcx)
movq 0x18(%rsp), %r8
movq %rax, 0x18(%r8)
movq 0x20(%rsp), %rcx
leal 0x1(%rcx), %esi
cmpl %ebx, %esi
cmovgel %ebx, %esi
pushq $0x1
popq %rax
subl %ecx, %eax
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %edi
cmovgl %eax, %edi
testl %esi, %esi
movl $0x0, %edx
movq %rsi, 0xd8(%rsp)
cmovgl %esi, %edx
movq %rdi, 0xd0(%rsp)
leal (%rdi,%rdi,2), %edi
pushq $0x7
popq %rsi
subl %edi, %esi
leaq (%r8,%r13,8), %rdi
movsd 0xd7e2(%rip), %xmm3     # 0x791d0
movsd %xmm2, 0xe0(%rsp)
mulsd %xmm2, %xmm3
xorpd %xmm2, %xmm2
movsd 0x15088(%rip), %xmm12   # 0x80a90
movq 0x28(%rsp), %r10
cmpq %rcx, %rdx
je 0x6ba79
movb (%r12,%rcx), %r8b
movapd %xmm0, %xmm4
cmpb $0x3, %r8b
ja 0x6ba4f
movq 0x60(%rsp), %r9
movb (%r9), %r9b
movapd %xmm0, %xmm4
cmpb $0x3, %r9b
ja 0x6ba4f
cvtss2sd (%r10), %xmm5
cmpb %r9b, %r8b
jne 0x6ba46
movapd %xmm0, %xmm4
subsd %xmm5, %xmm4
jmp 0x6ba4f
mulsd %xmm12, %xmm5
movapd %xmm5, %xmm4
leal -0x1(%rsi), %r8d
mulsd %xmm11, %xmm4
movslq %r8d, %r8
movsd %xmm4, (%rdi,%r8,8)
movslq %esi, %rsi
movsd %xmm3, (%rdi,%rsi,8)
addsd %xmm3, %xmm4
addsd %xmm4, %xmm2
addl $0x3, %esi
incq %rcx
jmp 0x6ba0d
cvtss2sd %xmm1, %xmm0
mulsd %xmm13, %xmm0
movsd %xmm0, 0x68(%rsp)
mulsd %xmm13, %xmm14
movapd %xmm13, %xmm0
mulsd %xmm15, %xmm0
mulsd 0x80(%rsp), %xmm13
movq (%rsp), %rcx
movsd %xmm2, 0x8(%rcx)
pushq $0x2
popq %rcx
subl 0x20(%rsp), %ecx
movslq %r14d, %rdx
movq %rdx, 0x10(%rsp)
movapd %xmm0, 0x110(%rsp)
unpcklpd %xmm15, %xmm0           # xmm0 = xmm0[0],xmm15[0]
movq 0x8(%rsp), %rdx
imulq $0x18, %rdx, %rsi
leaq 0x30(%rsi), %rdi
movq %rdi, 0x48(%rsp)
imulq $0x30, %rdx, %rdi
movq 0x18(%rsp), %rdx
addq %rdx, %rdi
movq %rdi, 0x8(%rsp)
movq %rsi, 0xc8(%rsp)
addq %rsi, %rdx
movq %rdx, 0x40(%rsp)
pushq $0x2
popq %r9
xorl %r11d, %r11d
cmpl $0x2, %ecx
pushq $0x1
popq %rdi
movl %edi, %esi
cmovgel %ecx, %esi
testl %ecx, %ecx
movl $0x0, %r8d
cmovgl %ecx, %r8d
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
cmpq 0x10(%rsp), %r9
jg 0x6bd37
leal (%rsi,%rsi,2), %esi
leal (%r8,%r8,2), %r8d
movl %esi, %r10d
subl %r8d, %r10d
addl $0x3, %r10d
leal (%rdx,%rdx,2), %edx
subl %edx, %esi
cmpl $0x2, %ecx
movl %edi, %r15d
cmovgel %ecx, %r15d
imulq %r9, %r13
movq 0x20(%rsp), %rdx
leal (%rdx,%r9), %r8d
movl %r9d, %ebp
subl %edx, %ebp
cmpl $0x2, %ebp
movl %edi, %edx
cmovgel %ebp, %edx
cmpl %ebx, %r8d
cmovgel %ebx, %r8d
testl %ebp, %ebp
movl $0x0, %edi
cmovlel %edi, %ebp
subl %ebp, %edx
movq 0x18(%rsp), %rdi
leaq (%rdi,%r13,8), %r13
leal (%rdx,%rdx,2), %edx
addl $0x3, %edx
movslq %edx, %rdx
movsd (%r13,%rdx,8), %xmm7
movsd 0x10(%r13,%rdx,8), %xmm6
movslq %r10d, %rdx
movq 0x8(%rsp), %rdi
leaq (%rdi,%rdx,8), %r13
movslq %esi, %rdx
movq 0x40(%rsp), %rsi
leaq (%rsi,%rdx,8), %rbp
movq 0x28(%rsp), %rdx
cvtss2sd -0x4(%rdx,%r9,4), %xmm1
movq 0x60(%rsp), %rdx
movb -0x1(%rdx,%r9), %r10b
movsd 0x9760(%rip), %xmm3     # 0x75330
movapd %xmm3, %xmm2
subsd %xmm1, %xmm2
mulsd %xmm12, %xmm1
movsd %xmm1, 0x90(%rsp)
movsd %xmm2, 0x98(%rsp)
movaps 0xe5ea(%rip), %xmm1     # 0x7a1e0
movaps %xmm1, 0xa0(%rsp)
movapd %xmm3, %xmm1
movq (%rsp), %rdx
divsd -0x8(%rdx,%r9,8), %xmm1
movsd 0x68(%rsp), %xmm2
mulsd %xmm1, %xmm2
movapd %xmm1, %xmm3
unpcklpd %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0]
mulpd %xmm0, %xmm3
mulsd 0xd5a5(%rip), %xmm1     # 0x791d0
movapd %xmm14, %xmm4
mulsd %xmm1, %xmm4
mulsd %xmm13, %xmm1
movslq %r8d, %rsi
unpcklpd %xmm14, %xmm1           # xmm1 = xmm1[0],xmm14[0]
xorps %xmm5, %xmm5
cmpq %rsi, %r15
jg 0x6bd17
cmpb $0x4, %r10b
setae %dl
movb -0x1(%r12,%r15), %r8b
cmpb $0x4, %r8b
setae %dil
orb %dl, %dil
xorl %edx, %edx
cmpb %r10b, %r8b
sete %dl
movzbl %dil, %edi
movsd 0x30(%rbp,%r11), %xmm9
mulsd %xmm2, %xmm9
movupd 0x38(%rbp,%r11), %xmm8
mulpd %xmm3, %xmm8
shll $0x4, %edi
leal (%rdi,%rdx,8), %edx
addsd %xmm8, %xmm9
unpckhpd %xmm8, %xmm8            # xmm8 = xmm8[1,1]
addsd %xmm9, %xmm8
mulsd 0x90(%rsp,%rdx), %xmm8
movsd 0x48(%rbp,%r11), %xmm9
movsd 0x50(%rbp,%r11), %xmm10
unpcklpd %xmm7, %xmm10           # xmm10 = xmm10[0],xmm7[0]
mulpd %xmm1, %xmm10
movsd %xmm8, 0x60(%r13,%r11)
movapd %xmm4, %xmm7
unpcklpd %xmm6, %xmm7            # xmm7 = xmm7[0],xmm6[0]
unpcklpd 0x80(%rsp), %xmm9       # xmm9 = xmm9[0],mem[0]
mulpd %xmm7, %xmm9
addpd %xmm10, %xmm9
movupd %xmm9, 0x68(%r13,%r11)
movapd %xmm8, %xmm7
addsd %xmm9, %xmm8
unpckhpd %xmm9, %xmm9            # xmm9 = xmm9[1,1]
movapd %xmm9, %xmm6
addsd %xmm8, %xmm9
addsd %xmm9, %xmm5
incq %r15
addq $0x18, %r13
addq $0x18, %rbp
jmp 0x6bc44
movq (%rsp), %rdx
movsd %xmm5, (%rdx,%r9,8)
incq %r9
incl %ecx
addq 0x48(%rsp), %r11
incl %eax
movq 0x58(%rsp), %r13
jmp 0x6bb01
movq (%rsp), %rax
movq 0x78(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd 0x95e3(%rip), %xmm0     # 0x75330
movl %r14d, %eax
subl 0x20(%rsp), %eax
xorl %r15d, %r15d
testl %eax, %eax
movl $0x0, %edx
movl %eax, 0x48(%rsp)
cmovgl %eax, %edx
movsd %xmm1, 0xb8(%rsp)
divsd %xmm1, %xmm0
movq %r13, %rdi
imulq %rcx, %rdi
movq 0x18(%rsp), %rax
leaq (%rax,%rdi,8), %rax
testl %ebx, %ebx
cmovgl %ebx, %r15d
movq %rdx, 0xb0(%rsp)
leal (%rdx,%rdx,2), %edx
pushq $0x3
popq %rcx
subl %edx, %ecx
xorpd %xmm1, %xmm1
movsd %xmm1, 0x8(%rsp)
movq %r15, %rdx
movsd 0x50(%rsp), %xmm3
subq $0x1, %rdx
jb 0x6bdf5
cmpl $0x7ffffffc, %ecx       # imm = 0x7FFFFFFC
ja 0x6bdf0
leal 0x3(%rcx), %esi
cmpq %rsi, %r13
jbe 0x6bdf0
movsd (%rax,%rsi,8), %xmm1
mulsd %xmm0, %xmm1
movsd 0x8(%rax,%rsi,8), %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm3, %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, 0x8(%rsp)
addl $0x3, %ecx
jmp 0x6bdab
movq %rdi, 0xc0(%rsp)
movq (%rsp), %rax
movq 0x70(%rsp), %rcx
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movslq %ecx, %r13
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
xorl %ebp, %ebp
movsd 0x14c71(%rip), %xmm1    # 0x80a98
movsd 0x9501(%rip), %xmm0     # 0x75330
movsd %xmm11, 0x70(%rsp)
movsd %xmm13, 0x40(%rsp)
movapd %xmm14, 0x100(%rsp)
movaps %xmm15, 0xf0(%rsp)
cmpq %r13, %rbp
jg 0x6be96
mulsd (%rax,%rbp,8), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x6be91
callq 0x4390
movq (%rsp), %rax
mulsd 0x973f(%rip), %xmm0     # 0x755b0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x14c0f(%rip), %xmm1    # 0x80a98
movsd 0x949f(%rip), %xmm0     # 0x75330
incq %rbp
jmp 0x6be50
cvtsi2sd %ebx, %xmm1
mulsd %xmm1, %xmm0
cvtsi2sd %r14d, %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x4390
mulsd 0x96f8(%rip), %xmm0     # 0x755b0
addsd 0x10(%rsp), %xmm0
addsd 0x96fa(%rip), %xmm0     # 0x755c0
cvttsd2si %xmm0, %ebp
cmpb $0x0, 0x34(%rsp)
je 0x6bf9f
movl %ebp, 0x34(%rsp)
movq 0x38(%rsp), %r9
movq 0xc0(%rsp), %r10
leaq (%r9,%r10,8), %rax
movsd 0x50(%rsp), %xmm0
divsd 0xb8(%rsp), %xmm0
divsd 0x8(%rsp), %xmm0
movq 0xb0(%rsp), %rcx
leal (%rcx,%rcx,2), %ecx
pushq $0x7
popq %rdx
subl %ecx, %edx
movq 0x58(%rsp), %r13
movsd 0x70(%rsp), %xmm10
movsd 0xe0(%rsp), %xmm11
movsd 0x14b62(%rip), %xmm12   # 0x80a90
movsd 0x40(%rsp), %xmm13
movapd 0x100(%rsp), %xmm14
movapd 0xf0(%rsp), %xmm15
subq $0x1, %r15
jb 0x6bfc1
leal -0x4(%rdx), %ecx
cmpl $0x7ffffffc, %ecx       # imm = 0x7FFFFFFC
ja 0x6bf6e
leal -0x1(%rdx), %ecx
cmpq %rcx, %r13
jbe 0x6bf6e
movsd %xmm0, (%rax,%rcx,8)
movl %edx, %ecx
movsd %xmm0, (%rax,%rcx,8)
addl $0x3, %edx
jmp 0x6bf49
xorl %ebx, %ebx
jmp 0x6bf7b
movq (%rsp), %rbx
movq 0x38(%rsp), %r14
movq 0x18(%rsp), %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x45c0
movq %rbx, %rdi
callq 0x45c0
jmp 0x6b71c
movq 0x18(%rsp), %rdi
callq 0x45c0
movq (%rsp), %rdi
callq 0x45c0
movq 0x28(%rsp), %rdi
callq 0x45c0
jmp 0x6b736
movapd %xmm14, %xmm0
movsd 0xd202(%rip), %xmm1     # 0x791d0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm13
movslq %ebx, %rax
movq 0x20(%rsp), %r8
leal (%r8,%r14), %ecx
leal -0x1(%r14), %edx
movq %r13, %rsi
imulq %rdx, %rsi
leaq (%r9,%rsi,8), %rsi
movq %rsi, 0x8(%rsp)
leal (%r14,%r8), %edi
decl %edi
subl %r8d, %edx
pushq $-0x30
popq %rsi
subq 0xc8(%rsp), %rsi
movq %rsi, 0x40(%rsp)
leaq (%r9,%r10,8), %rsi
addq $0x18, %rsi
movq %rsi, 0x50(%rsp)
movsd 0x930b(%rip), %xmm1     # 0x75330
movq $0x0, 0x10(%rsp)
movl 0x48(%rsp), %r8d
cmpl %edi, %ebx
movl %edi, %esi
cmovll %ebx, %esi
testl %edx, %edx
movl $0x0, %r10d
cmovgl %edx, %r10d
testl %r8d, %r8d
movl $0x0, %r11d
cmovgl %r8d, %r11d
movq 0x78(%rsp), %r14
cmpl $0x1, %r14d
jle 0x6c270
movl %r8d, 0x48(%rsp)
decl %ecx
cmpl %ecx, %ebx
movl %ecx, %r9d
cmovll %ebx, %r9d
movapd %xmm1, %xmm2
cmpq $0x2, %r14
jne 0x6c080
xorpd %xmm2, %xmm2
leal (%rsi,%rsi,2), %esi
addl $0x3, %esi
leal (%r10,%r10,2), %ebp
movl %esi, %r10d
subl %ebp, %r10d
leal (%r11,%r11,2), %r11d
subl %r11d, %esi
decq %r14
movl %r14d, %r11d
movq %r13, %r15
imulq %r11, %r15
movl %r14d, %ebp
movq 0x20(%rsp), %r8
subl %r8d, %ebp
cmpl $0x2, %ebp
movq %r14, %r13
pushq $0x1
popq %r14
cmovgel %ebp, %r14d
movq %r13, 0x78(%rsp)
addl %r8d, %r13d
cmpl %ebx, %r13d
cmovgel %ebx, %r13d
testl %ebp, %ebp
movl $0x0, %r8d
cmovlel %r8d, %ebp
subl %ebp, %r13d
movq 0x38(%rsp), %r8
leaq (%r8,%r15,8), %rbp
movq 0x28(%rsp), %r8
cvtss2sd (%r8,%r11,4), %xmm3
movq 0x60(%rsp), %r8
movb (%r8,%r11), %r15b
movapd %xmm1, %xmm4
subsd %xmm3, %xmm4
mulsd %xmm12, %xmm3
movsd %xmm3, 0x90(%rsp)
movsd %xmm4, 0x98(%rsp)
movaps 0xe0c2(%rip), %xmm3     # 0x7a1e0
movaps %xmm3, 0xa0(%rsp)
leal 0x3(%r13,%r13,2), %r13d
movslq %r13d, %r13
movsd 0x28(%rbp,%r13,8), %xmm5
movslq %r10d, %r10
movq 0x8(%rsp), %r8
leaq (%r8,%r10,8), %r10
movslq %esi, %rsi
movq 0x50(%rsp), %r8
leaq (%r8,%rsi,8), %rsi
movapd %xmm1, %xmm3
movq (%rsp), %r8
divsd (%r8,%r11,8), %xmm3
movslq %r9d, %r9
movapd %xmm3, %xmm4
unpcklpd %xmm3, %xmm4            # xmm4 = xmm4[0],xmm3[0]
movq 0x10(%rsp), %r11
cmpq %r14, %r9
jl 0x6c24b
xorpd %xmm6, %xmm6
cmpq %rax, %r9
jge 0x6c1b9
cmpb $0x4, %r15b
setae %bpl
movb (%r12,%r9), %r13b
cmpb $0x4, %r13b
setae %r8b
orb %bpl, %r8b
xorl %ebp, %ebp
cmpb %r15b, %r13b
sete %bpl
movzbl %r8b, %r8d
shll $0x4, %r8d
leal (%r8,%rbp,8), %r8d
movsd 0x90(%rsp,%r8), %xmm6
mulsd (%rsi,%r11), %xmm6
movsd -0x10(%rsi,%r11), %xmm8
mulsd %xmm13, %xmm8
movapd %xmm14, %xmm9
mulsd %xmm5, %xmm9
mulsd 0x80(%rsp), %xmm5
movapd %xmm6, %xmm7
mulsd %xmm15, %xmm7
addsd %xmm5, %xmm7
mulsd %xmm2, %xmm7
movapd %xmm6, %xmm5
mulsd 0x110(%rsp), %xmm5
addsd %xmm8, %xmm5
movsd %xmm5, 0x8(%r10,%r11)
movsd -0x10(%rsi,%r11), %xmm8
mulsd %xmm0, %xmm8
mulsd 0x68(%rsp), %xmm6
addsd %xmm8, %xmm6
addsd %xmm9, %xmm6
unpcklpd %xmm5, %xmm6            # xmm6 = xmm6[0],xmm5[0]
mulpd %xmm4, %xmm6
movupd %xmm6, (%r10,%r11)
movapd %xmm3, %xmm5
mulsd %xmm7, %xmm5
movsd %xmm5, 0x10(%r10,%r11)
decq %r9
addq $-0x18, %r11
movapd %xmm7, %xmm5
jmp 0x6c16b
decl %edi
decl %edx
movq 0x10(%rsp), %rsi
addq 0x40(%rsp), %rsi
movq %rsi, 0x10(%rsp)
movl 0x48(%rsp), %r8d
decl %r8d
movq 0x58(%rsp), %r13
jmp 0x6c033
movq 0xd8(%rsp), %rcx
movl %ecx, %eax
leal (%rcx,%rcx,2), %ecx
movq 0xd0(%rsp), %rdx
leal (%rdx,%rdx,2), %edx
subl %edx, %ecx
addl $0x3, %ecx
xorpd %xmm0, %xmm0
movsd 0x9097(%rip), %xmm1     # 0x75330
movq 0x38(%rsp), %r10
movq 0xe8(%rsp), %r15
pushq $0x1
popq %rdi
testl %eax, %eax
jle 0x6c331
movb -0x1(%r12,%rax), %dl
movapd %xmm1, %xmm2
cmpb $0x3, %dl
ja 0x6c2f5
movq 0x60(%rsp), %rsi
movb (%rsi), %sil
movapd %xmm1, %xmm2
cmpb $0x3, %sil
ja 0x6c2f5
movq 0x28(%rsp), %rdi
cvtss2sd (%rdi), %xmm3
cmpb %sil, %dl
jne 0x6c2e9
movapd %xmm1, %xmm2
subsd %xmm3, %xmm2
jmp 0x6c2f2
mulsd %xmm12, %xmm3
movapd %xmm3, %xmm2
pushq $0x1
popq %rdi
movl %ecx, %edx
cmpq %rdx, %r13
jbe 0x6c326
addq %r13, %rdx
mulsd (%r10,%rdx,8), %xmm2
movsd 0x8(%r10,%rdx,8), %xmm3
mulsd 0xcebc(%rip), %xmm3     # 0x791d0
mulsd %xmm11, %xmm3
mulsd %xmm10, %xmm2
addsd %xmm3, %xmm2
addsd %xmm2, %xmm0
decq %rax
addl $-0x3, %ecx
jmp 0x6c2a9
movq (%rsp), %rax
divsd (%rax), %xmm0
movsd %xmm0, 0x18(%r10)
incl %r15d
movl %edi, %ebp
subl 0x20(%rsp), %ebp
pushq $0x1
popq %r14
pushq $0x63
popq %r12
cmpl $0x2, %ebp
movl %edi, %ecx
cmovgel %ebp, %ecx
testl %ebp, %ebp
movl $0x0, %edx
cmovgl %ebp, %edx
cmpq %r15, %r14
je 0x6c488
leal -0x4(,%rcx,4), %eax
leal (%rcx,%rcx,2), %ecx
leal (%rdx,%rdx,2), %edx
subl %edx, %ecx
addl $0x4, %ecx
movq %r13, %r8
imulq %r14, %r8
movl %r14d, %edx
movq 0x20(%rsp), %rsi
subl %esi, %edx
cmpl $0x2, %edx
cmovll %edi, %edx
addl %r14d, %esi
cmpl %ebx, %esi
cmovgel %ebx, %esi
movq 0x18(%rsp), %rdi
leaq (%rdi,%r8,8), %rdi
movsd 0x8f83(%rip), %xmm0     # 0x75330
movq (%rsp), %r9
divsd (%r9,%r14,8), %xmm0
leaq (%r10,%r8,8), %r8
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
pushq $-0x1
popq %r9
cmpl %esi, %edx
jg 0x6c42c
leal -0x1(%rcx), %r10d
movslq %r10d, %r10
movsd (%rdi,%r10,8), %xmm3
mulsd %xmm0, %xmm3
mulsd (%r8,%r10,8), %xmm3
movslq %ecx, %rcx
movsd (%rdi,%rcx,8), %xmm4
mulsd %xmm0, %xmm4
mulsd (%r8,%rcx,8), %xmm4
xorl %r10d, %r10d
ucomisd %xmm3, %xmm4
seta %r10b
movapd %xmm4, %xmm5
maxsd %xmm3, %xmm5
addl %eax, %r10d
ucomisd %xmm2, %xmm5
cmoval %r10d, %r9d
maxsd %xmm2, %xmm5
addsd %xmm3, %xmm4
addsd %xmm4, %xmm1
incl %edx
addl $0x4, %eax
addl $0x3, %ecx
movapd %xmm5, %xmm2
jmp 0x6c3c7
divsd %xmm1, %xmm2
movq 0x160(%rsp), %rax
movl %r9d, -0x4(%rax,%r14,4)
movsd 0x8eeb(%rip), %xmm0     # 0x75330
subsd %xmm2, %xmm0
callq 0x4390
mulsd 0x915a(%rip), %xmm0     # 0x755b0
addsd 0x9162(%rip), %xmm0     # 0x755c0
cvttsd2si %xmm0, %eax
cmpl $0x65, %eax
cmovgel %r12d, %eax
movq 0x168(%rsp), %rcx
movb %al, -0x1(%rcx,%r14)
incq %r14
incl %ebp
movq 0x38(%rsp), %r10
pushq $0x1
popq %rdi
jmp 0x6c350
movq 0x18(%rsp), %rdi
movq %r10, %rbx
callq 0x45c0
movq %rbx, %rdi
callq 0x45c0
movq (%rsp), %rdi
callq 0x45c0
movq 0x28(%rsp), %rdi
callq 0x45c0
movl 0x34(%rsp), %ebp
jmp 0x6b736
nopl (%rax)