// File: /workspace/github_c_makefile_star2_O2/debbiemarkslab[P]plmc/src/inference.c
// Function: PLMNegLogPosteriorBlock
static lbfgsfloatval_t PLMNegLogPosteriorBlock(void *instance,
    const lbfgsfloatval_t *x, lbfgsfloatval_t *g, const int n,
    const lbfgsfloatval_t step) {
    /* Compute the the negative log posterior, which is the negative 
       penalized log-(pseudo)likelihood and the objective for MAP inference
    */
    void **d = (void **)instance;
    alignment_t *ali = (alignment_t *) d[0];
    options_t *options = (options_t *) d[1];
    numeric_t *lambdas = (numeric_t *) d[2];

    /* Initialize log-likelihood and gradient */
    lbfgsfloatval_t fx = 0.0;
    for (int i = 0; i < ali->nParams; i++) g[i] = 0;

    /* Block fields hi */
    numeric_t *hi = (numeric_t *)
        malloc(ali->nSites * ali->nCodes * sizeof(numeric_t));
    numeric_t *gHi = (numeric_t *)
        malloc(ali->nSites * ali->nCodes * sizeof(numeric_t));
    for (int i = 0; i < ali->nSites; i++)
        for (int ai = 0; ai < ali->nCodes; ai++) Hi(i, ai) = xHi(i, ai);
    for (int i = 0; i < ali->nSites * ali->nCodes; i++) gHi[i] = 0;

    /* Block couplings eij */
    numeric_t *eij = (numeric_t *) malloc(ali->nSites * ali->nSites
        * ali->nCodes * ali->nCodes * sizeof(numeric_t));
    numeric_t *gEij = (numeric_t *) malloc(ali->nSites * ali->nSites
        * ali->nCodes * ali->nCodes * sizeof(numeric_t));
    for (int i = 0; i < ali->nSites * ali->nSites * ali->nCodes * ali->nCodes;
        i++) eij[i] = 0.0;
    for (int i = 0; i < ali->nSites * ali->nSites * ali->nCodes * ali->nCodes;
        i++) gEij[i] = 0.0;
    for (int i = 0; i < ali->nSites - 1; i++)
        for (int j = i + 1; j < ali->nSites; j++)
            for (int ai = 0; ai < ali->nCodes; ai++)
                for (int aj = 0; aj < ali->nCodes; aj++)
                    Eij(j, aj, i, ai) = Eij(i, ai, j, aj) = xEij(i, j, ai, aj);


    /* Negative log-pseudolikelihood */
    for (int s = 0; s < ali->nSeqs; s++) {
        /* Form potential for conditional log likelihoods at every site */
        numeric_t *H = (numeric_t *)
            malloc(ali->nCodes * ali->nSites * sizeof(numeric_t));
        numeric_t *Z = (numeric_t *) malloc(ali->nSites * sizeof(numeric_t));

        /* Initialize potentials with fields */
        // memcpy(H, hi, ali->nSites * ali->nCodes * sizeof(numeric_t));
        for(int jx = 0; jx < ali->nSites * ali->nCodes; jx++) H[jx] = hi[jx];

        /* Contribute coupling block due to i, ai */
        for (int i = 0; i < ali->nSites; i++) {
            const letter_t ai = seq(s, i);
            const numeric_t *jB = &(Eij(i, ai, 0, 0));
            for(int jx = 0; jx < ali->nSites * ali->nCodes; jx++)
                H[jx] += jB[jx];
        }

        /* Conditional log likelihoods */
        for (int i = 0; i < ali->nSites * ali->nCodes; i++) H[i] = exp(H[i]);
        for (int i = 0; i < ali->nSites; i++) Z[i] = 0;
        for (int i = 0; i < ali->nSites; i++)
            for (int ai = 0; ai < ali->nSites; ai++) Z[i] += Hp(i, ai);
        for (int i = 0; i < ali->nSites; i++)
            for (int ai = 0; ai < ali->nSites; ai++) Hp(i, ai) /= Z[i];

        numeric_t seqFx = 0;
        for (int i = 0; i < ali->nSites; i++)
            seqFx -= ali->weights[s] * log(Hp(i, seq(s, i)));

        for(int jx = 0; jx < ali->nSites * ali->nCodes; jx++)
            H[jx] *= -ali->weights[s];

        for (int i = 0; i < ali->nSites; i++)
            gHi(i, seq(s, i)) -= ali->weights[s];
        for(int jx = 0; jx < ali->nSites * ali->nCodes; jx++) gHi[jx] -= H[jx];

        for (int i = 0; i < ali->nSites - 1; i++)
            for (int j = i; j < ali->nSites; j++)
                gEij(i, seq(s, i), j, seq(s, j)) -= ali->weights[s];

        for (int i = 0; i < ali->nSites; i++) {
            const letter_t ai = seq(s, i);
            numeric_t *jgBlock = &(gEij(i, ai, 0, 0));
            for (int jx = 0; jx < ali->nSites * ali->nCodes; jx++)
                jgBlock[jx] -= H[jx];
        }

        free(H);
        free(Z);
        fx += seqFx;
    }

    for (int i = 0; i < ali->nSites; i++)
        for (int ai = 0; ai < ali->nCodes; ai++)
            dHi(i, ai) += gHi(i, ai);

    for (int i = 0; i < ali->nSites - 1; i++)
        for (int j = i + 1; j < ali->nSites; j++)
            for (int ai = 0; ai < ali->nCodes; ai++)
                for (int aj = 0; aj < ali->nCodes; aj++)
                    dEij(i, j, ai, aj) += gEij(j, aj, i, ai) + gEij(i, ai, j, aj);
    free(hi);
    free(gHi);
    free(eij);
    free(gEij);

    ali->negLogLk = fx;

    /* Gaussian priors */
    for (int i = 0; i < ali->nSites; i++)
        for (int ai = 0; ai < ali->nCodes; ai++) {
            dHi(i, ai) += lambdaHi(i) * 2.0 * xHi(i, ai);
            fx += lambdaHi(i) * xHi(i, ai) * xHi(i, ai);
        }

    for (int i = 0; i < ali->nSites-1; i++)
        for (int j = i + 1; j < ali->nSites; j++)
            for (int ai = 0; ai < ali->nCodes; ai++)
                for (int aj = 0; aj < ali->nCodes; aj++) {
                    dEij(i, j, ai, aj) += lambdaEij(i, j)
                        * 2.0 * xEij(i, j, ai, aj);
                    fx += lambdaEij(i, j)
                        * xEij(i, j, ai, aj) * xEij(i, j, ai, aj);
                }

    fx = PostCondition(x, g, fx, ali, options);
    return fx;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
movq %rcx, 0xc8(%rsp)
movq 0x10(%rdi), %r14
movq %rax, 0x18(%rsp)
movl 0x68(%rax), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x76fb
andq $0x0, (%rbx,%rcx,8)
incq %rcx
jmp 0x76ec
movq 0x18(%rsp), %rax
movl 0x4(%rax), %ecx
movl %ecx, 0x4(%rsp)
movl 0x8(%rax), %r13d
movl %r13d, %ebp
imull %ecx, %ebp
movslq %ebp, %r15
shlq $0x3, %r15
movq %r15, %rdi
callq 0x11a0
movq %rax, 0xa8(%rsp)
movq %r15, %rdi
callq 0x11a0
movq %rax, 0x68(%rsp)
movslq 0x4(%rsp), %rdx
xorl %eax, %eax
testl %r13d, %r13d
movl $0x0, %ecx
cmovgl %r13d, %ecx
movq %rcx, 0x20(%rsp)
movslq %r13d, %rsi
testl %edx, %edx
movl $0x0, %ecx
cmovgl %edx, %ecx
movq %rsi, 0x8(%rsp)
leaq (,%rsi,8), %rsi
movq %rsi, 0x98(%rsp)
movq %rdx, 0x40(%rsp)
leaq (,%rdx,8), %rdx
movq %r12, %rsi
movq 0xa8(%rsp), %rdi
cmpq %rcx, %rax
je 0x77bd
movq %rsi, %r8
xorl %r9d, %r9d
cmpq %r9, 0x20(%rsp)
je 0x77ac
movsd (%r8), %xmm0
movsd %xmm0, (%rdi,%r9,8)
incq %r9
addq %rdx, %r8
jmp 0x7792
incq %rax
addq 0x98(%rsp), %rdi
addq $0x8, %rsi
jmp 0x7787
xorl %eax, %eax
testl %ebp, %ebp
movl $0x0, %ecx
cmovgl %ebp, %ecx
movq 0x68(%rsp), %rdx
cmpq %rax, %rcx
je 0x77dd
andq $0x0, (%rdx,%rax,8)
incq %rax
jmp 0x77ce
movl %ebp, %eax
imull %ebp, %eax
movslq %eax, %r15
leaq (,%r15,8), %rdi
movq %rdi, 0x10(%rsp)
callq 0x11a0
movq %rax, 0xa0(%rsp)
movq 0x10(%rsp), %rdi
callq 0x11a0
movq %r15, %rsi
movq 0xa0(%rsp), %r15
movq %rax, 0x48(%rsp)
xorl %eax, %eax
testl %esi, %esi
cmovlel %eax, %esi
movl 0x4(%rsp), %ecx
cmpq %rax, %rsi
je 0x7833
andq $0x0, (%r15,%rax,8)
incq %rax
jmp 0x7824
xorl %eax, %eax
movq 0x48(%rsp), %rdx
cmpq %rax, %rsi
je 0x7849
andq $0x0, (%rdx,%rax,8)
incq %rax
jmp 0x783a
movq 0x40(%rsp), %rax
cmpl $0x2, %eax
pushq $0x1
popq %rdx
movl %edx, 0x88(%rsp)
cmovgel %eax, %edx
decl %edx
movq %rdx, 0x80(%rsp)
movq 0x8(%rsp), %rsi
leaq (%r15,%rsi,8), %rdx
movq %rdx, 0x60(%rsp)
movq %rsi, %rdx
imulq %rax, %rdx
leaq 0x1(%rdx), %rax
imulq %rsi, %rax
shlq $0x3, %rax
movq %rax, 0x78(%rsp)
leaq (,%rdx,8), %r11
movl %esi, %r9d
imull %r9d, %r9d
imulq %rsi, %rdx
leaq (%r15,%rdx,8), %rax
movq %rax, 0x58(%rsp)
shlq $0x3, %rdx
movq %rdx, 0x70(%rsp)
xorl %r8d, %r8d
movq %r9, 0x90(%rsp)
cmpq 0x80(%rsp), %r8
je 0x7a03
movl 0x88(%rsp), %esi
movslq %esi, %rdi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addl %r8d, %eax
imull %r8d, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movq %rdi, %rcx
addl %esi, %eax
movq %rax, %rsi
imull %r9d, %esi
movq 0x58(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpq 0x40(%rsp), %rcx
jge 0x79e1
movl %ecx, %edi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addl %ecx, %eax
movq %rcx, 0x30(%rsp)
imull %ecx, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
addl %r8d, %eax
imull %r9d, %eax
movq 0x38(%rsp), %rdx
movq %rsi, 0x50(%rsp)
movq %rsi, %rcx
movq 0x28(%rsp), %r9
xorl %esi, %esi
cmpq 0x20(%rsp), %rsi
je 0x79a3
movq %rdx, 0x10(%rsp)
movl %eax, 0x8(%rsp)
xorl %r15d, %r15d
cmpq %r15, %r13
je 0x7989
leal (%rcx,%r15), %r10d
cmpq %rdi, %r8
cmovbl %eax, %r10d
addl %ebp, %r10d
movslq %r10d, %r10
movsd (%r12,%r10,8), %xmm0
movsd %xmm0, (%r9,%r15,8)
movsd %xmm0, (%rdx)
incq %r15
addl %r13d, %eax
addq %r11, %rdx
jmp 0x7958
incq %rsi
addq %r11, %r9
addq %r13, %rcx
movl 0x8(%rsp), %eax
incl %eax
movq 0x10(%rsp), %rdx
addq $0x8, %rdx
jmp 0x7945
movq 0x30(%rsp), %rcx
incq %rcx
movq 0x28(%rsp), %rax
addq 0x98(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x90(%rsp), %r9
movq 0x50(%rsp), %rsi
addq %r9, %rsi
movq 0x38(%rsp), %rax
addq 0x70(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0x7908
incq %r8
incl 0x88(%rsp)
movq 0x78(%rsp), %rax
addq %rax, 0x60(%rsp)
addq %rax, 0x58(%rsp)
movl 0x4(%rsp), %ecx
jmp 0x78be
xorpd %xmm1, %xmm1
pushq $0x1
popq %rax
movl %eax, 0x80(%rsp)
xorl %edx, %edx
movq 0x18(%rsp), %rax
movslq (%rax), %rax
movslq %ecx, %rdi
cmpq %rax, %rdx
movl %ecx, 0x4(%rsp)
movsd %xmm1, 0x58(%rsp)
movq %rdi, 0x70(%rsp)
jge 0x7e57
movq %rdx, 0x8(%rsp)
imull %r13d, %ecx
movl %ecx, 0x10(%rsp)
movslq %ecx, %rbp
leaq (,%rbp,8), %rdi
callq 0x11a0
movq %rax, %r15
movq 0x70(%rsp), %rdi
shlq $0x3, %rdi
callq 0x11a0
movq %rax, %r10
testl %ebp, %ebp
movl $0x0, %eax
cmovlel %eax, %ebp
xorl %eax, %eax
movq 0xa8(%rsp), %rcx
movq 0xa0(%rsp), %r9
cmpq %rax, %rbp
je 0x7a98
movsd (%rcx,%rax,8), %xmm0
movsd %xmm0, (%r15,%rax,8)
incq %rax
jmp 0x7a83
movl 0x4(%rsp), %esi
movl %esi, %eax
imull 0x8(%rsp), %eax
cltq
xorl %ecx, %ecx
testl %esi, %esi
movl $0x0, %edx
cmovgl %esi, %edx
xorl %esi, %esi
movl 0x10(%rsp), %r11d
cmpq %rdx, %rsi
je 0x7b05
leaq (,%rsi,4), %rdi
movq 0x18(%rsp), %r8
addq 0x20(%r8), %rdi
movl (%rdi,%rax,4), %edi
addl %ecx, %edi
imull %r11d, %edi
movslq %edi, %rdi
leaq (%r9,%rdi,8), %rdi
xorl %r8d, %r8d
cmpq %r8, %rbp
je 0x7afd
movsd (%rdi,%r8,8), %xmm0
addsd (%r15,%r8,8), %xmm0
movsd %xmm0, (%r15,%r8,8)
incq %r8
jmp 0x7ae1
incq %rsi
addl %r13d, %ecx
jmp 0x7ab8
xorl %ebp, %ebp
movl 0x4(%rsp), %edx
movq %r10, 0x38(%rsp)
movl %r13d, %eax
imull %edx, %eax
cltq
cmpq %rax, %rbp
jge 0x7b44
movsd (%r15,%rbp,8), %xmm0
callq 0x1230
movq 0x38(%rsp), %r10
movsd %xmm0, (%r15,%rbp,8)
incq %rbp
movq 0x18(%rsp), %rax
movl 0x4(%rax), %edx
movl 0x8(%rax), %r13d
jmp 0x7b10
testl %edx, %edx
movl $0x0, %eax
cmovgl %edx, %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x7b5f
andq $0x0, (%r10,%rcx,8)
incq %rcx
jmp 0x7b50
movslq %r13d, %rcx
movl %edx, %r9d
movl %edx, %edx
shlq $0x3, %rcx
movq %r15, %rsi
xorl %edi, %edi
cmpq %rax, %rdi
je 0x7b9c
xorl %r8d, %r8d
cmpq %r8, %rdx
je 0x7b94
movsd (%rsi,%r8,8), %xmm0
addsd (%r10,%rdi,8), %xmm0
movsd %xmm0, (%r10,%rdi,8)
incq %r8
jmp 0x7b78
incq %rdi
addq %rcx, %rsi
jmp 0x7b70
movq %r15, %rsi
xorl %edi, %edi
cmpq %rax, %rdi
je 0x7bcd
xorl %r8d, %r8d
cmpq %r8, %rdx
je 0x7bc5
movsd (%rsi,%r8,8), %xmm0
divsd (%r10,%rdi,8), %xmm0
movsd %xmm0, (%rsi,%r8,8)
incq %r8
jmp 0x7ba9
incq %rdi
addq %rcx, %rsi
jmp 0x7ba1
xorl %ebp, %ebp
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
cmpl %r9d, %ebp
jge 0x7c40
movq 0x18(%rsp), %r13
movq 0x20(%r13), %rax
movq 0x50(%r13), %rcx
movq 0x8(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, 0x20(%rsp)
imull %edx, %r9d
addl %ebp, %r9d
movslq %r9d, %rcx
movslq (%rax,%rcx,4), %rax
movslq 0x8(%r13), %rcx
movslq %ebp, %rdx
imulq %rcx, %rdx
addq %rax, %rdx
movsd (%r15,%rdx,8), %xmm0
callq 0x1120
mulsd 0x20(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
incl %ebp
movl 0x4(%r13), %r9d
jmp 0x7bd9
movq 0x18(%rsp), %rax
movl 0x8(%rax), %r13d
movslq %r13d, %rdi
movl %edi, %ecx
movl %r9d, 0x4(%rsp)
imull %r9d, %ecx
testl %ecx, %ecx
movl $0x0, %r9d
cmovgl %ecx, %r9d
xorl %edx, %edx
movq 0x8(%rsp), %r8
cmpq %rdx, %r9
je 0x7c97
movq 0x18(%rsp), %rax
movq 0x50(%rax), %rsi
movsd (%rsi,%r8,8), %xmm0
xorpd 0x441a(%rip), %xmm0     # 0xc0a0
mulsd (%r15,%rdx,8), %xmm0
movsd %xmm0, (%r15,%rdx,8)
incq %rdx
jmp 0x7c6a
movq %r9, 0x30(%rsp)
movl %ecx, 0x50(%rsp)
movl 0x4(%rsp), %eax
movl %eax, %edx
imull %r8d, %edx
movslq %edx, %rdx
testl %eax, %eax
movl $0x0, %r11d
cmovgl %eax, %r11d
movl %r8d, %ecx
imull %eax, %ecx
movl %ecx, 0x40(%rsp)
movslq %ecx, %r9
shlq $0x3, %rdi
movq 0x68(%rsp), %r10
movq %r11, 0x20(%rsp)
subq $0x1, %r11
jb 0x7d0b
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rbp
movq 0x50(%rax), %r8
movslq (%rbp,%r9,4), %rbp
movsd (%r10,%rbp,8), %xmm0
movq 0x8(%rsp), %rax
subsd (%r8,%rax,8), %xmm0
movsd %xmm0, (%r10,%rbp,8)
incq %r9
addq %rdi, %r10
jmp 0x7cd4
xorl %edi, %edi
movq 0x30(%rsp), %rcx
cmpq %rdi, %rcx
je 0x7d31
movq 0x68(%rsp), %rax
movsd (%rax,%rdi,8), %xmm0
subsd (%r15,%rdi,8), %xmm0
movsd %xmm0, (%rax,%rdi,8)
incq %rdi
jmp 0x7d12
movl 0x4(%rsp), %eax
cmpl $0x2, %eax
pushq $0x1
popq %rsi
movl %esi, %ecx
cmovgel %eax, %ecx
decl %ecx
movq %rcx, 0x28(%rsp)
movslq 0x40(%rsp), %r8
shlq $0x2, %r8
xorl %r9d, %r9d
xorl %r10d, %r10d
movl 0x4(%rsp), %eax
cmpl %r10d, %eax
movl %r10d, %r11d
cmovgl %eax, %r11d
cmpq 0x28(%rsp), %r10
je 0x7dc8
movq %r10, %rbp
cmpq %rbp, %r11
je 0x7dc0
movq 0x18(%rsp), %rsi
movq 0x20(%rsi), %rax
movq 0x50(%rsi), %rsi
leaq (%rax,%r8), %rdi
movslq (%rdi,%rbp,4), %rdi
leaq (%rax,%r10,4), %rax
movl (%rax,%rdx,4), %eax
addl %r9d, %eax
imull 0x4(%rsp), %eax
addl %ebp, %eax
imull %r13d, %eax
cltq
addq %rdi, %rax
movq 0x48(%rsp), %rdi
movsd (%rdi,%rax,8), %xmm0
movq 0x8(%rsp), %rcx
subsd (%rsi,%rcx,8), %xmm0
movsd %xmm0, (%rdi,%rax,8)
incq %rbp
jmp 0x7d6e
incq %r10
addl %r13d, %r9d
jmp 0x7d56
xorl %edi, %edi
xorl %r8d, %r8d
movl 0x50(%rsp), %ecx
movq 0x30(%rsp), %r11
cmpq 0x20(%rsp), %r8
je 0x7e28
leaq (,%r8,4), %rax
movq 0x18(%rsp), %rsi
addq 0x20(%rsi), %rax
movl (%rax,%rdx,4), %eax
addl %edi, %eax
imull %ecx, %eax
cltq
movq 0x48(%rsp), %rsi
leaq (%rsi,%rax,8), %r9
xorl %r10d, %r10d
cmpq %r10, %r11
je 0x7e20
movsd (%r9,%r10,8), %xmm0
subsd (%r15,%r10,8), %xmm0
movsd %xmm0, (%r9,%r10,8)
incq %r10
jmp 0x7e04
incq %r8
addl %r13d, %edi
jmp 0x7dd6
movq %r15, %rdi
callq 0x1050
movq 0x38(%rsp), %rdi
callq 0x1050
movsd 0x58(%rsp), %xmm1
addsd 0x10(%rsp), %xmm1
movq 0x8(%rsp), %rdx
incq %rdx
movl 0x4(%rsp), %ecx
jmp 0x7a13
xorl %eax, %eax
testl %edi, %edi
movl $0x0, %r9d
cmovgl %ecx, %r9d
movslq %r13d, %rdx
testl %edx, %edx
movl $0x0, %ecx
cmovgl %r13d, %ecx
movq %rdx, %r10
leaq (,%rdx,8), %rdx
movq %rdx, 0x90(%rsp)
leaq (,%rdi,8), %r11
movq %rbx, %rdx
movq 0x68(%rsp), %rsi
cmpq %r9, %rax
je 0x7ed2
movq %rdx, %rdi
xorl %r8d, %r8d
cmpq %r8, %rcx
je 0x7ebc
movsd (%rsi,%r8,8), %xmm0
addsd (%rdi), %xmm0
movsd %xmm0, (%rdi)
incq %r8
addq %r11, %rdi
jmp 0x7ea1
incq %rax
addq 0x90(%rsp), %rsi
addq $0x8, %rdx
movq 0x70(%rsp), %rdi
jmp 0x7e96
movq %r9, 0xc0(%rsp)
cmpl $0x2, %edi
pushq $0x1
popq %rax
movl %eax, %ecx
movl 0x4(%rsp), %eax
cmovgel %eax, %ecx
decl %ecx
movq %rcx, 0x60(%rsp)
movl %r13d, %r15d
imull %eax, %r15d
xorl %r8d, %r8d
movq %r10, %rdx
testl %edx, %edx
movl $0x0, %eax
cmovgl %r13d, %eax
movq %rax, 0x38(%rsp)
movl %edx, %r10d
movq 0x48(%rsp), %rax
leaq (%rax,%rdx,8), %rcx
movq %rcx, 0x78(%rsp)
movq %rdx, %rcx
imulq %rdi, %rcx
incq %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
movq %rcx, 0xd0(%rsp)
movq %r11, %rcx
imulq %rdx, %r11
movl %edx, %ebp
imull %ebp, %ebp
imulq %rdx, %rdx
movq %rcx, 0xb8(%rsp)
imulq %rcx, %rdx
movq %rdx, 0x88(%rsp)
addq %rdx, %rax
movq %rax, 0xb0(%rsp)
movq %rbp, 0x40(%rsp)
cmpq 0x60(%rsp), %r8
je 0x80c4
movl 0x80(%rsp), %esi
movslq %esi, %r9
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addl %r8d, %eax
imull %r8d, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movq %r9, %rdx
addl %esi, %eax
imull %ebp, %eax
movq %rax, 0x50(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpq %rdi, %rdx
jge 0x80a0
movl %edx, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addl %edx, %eax
movq %rdx, 0x98(%rsp)
imull %edx, %eax
cltd
pushq $0x2
popq %rsi
idivl %esi
addl %r8d, %eax
imull %ebp, %eax
movq 0x28(%rsp), %rdx
movq 0x50(%rsp), %rdi
movq 0x30(%rsp), %rbp
xorl %esi, %esi
cmpq 0x38(%rsp), %rsi
je 0x805d
movq %rsi, 0x20(%rsp)
movq %rdx, 0x10(%rsp)
movl %eax, 0x8(%rsp)
xorl %r9d, %r9d
cmpq %r9, %r10
je 0x803e
leal (%rdi,%r9), %esi
cmpq %rcx, %r8
movsd (%rdx), %xmm0
addsd (%rbp,%r9,8), %xmm0
cmovbl %eax, %esi
addl %r15d, %esi
movslq %esi, %rsi
addsd (%rbx,%rsi,8), %xmm0
movsd %xmm0, (%rbx,%rsi,8)
incq %r9
addl %r13d, %eax
addq %r11, %rdx
jmp 0x8009
movq 0x20(%rsp), %rsi
incq %rsi
addq %r11, %rbp
addq %r10, %rdi
movl 0x8(%rsp), %eax
incl %eax
movq 0x10(%rsp), %rdx
addq $0x8, %rdx
jmp 0x7ff1
movq 0x98(%rsp), %rdx
incq %rdx
movq 0x30(%rsp), %rax
addq 0x90(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x40(%rsp), %rbp
addq %rbp, 0x50(%rsp)
movq 0x28(%rsp), %rax
addq 0x88(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x70(%rsp), %rdi
jmp 0x7fb7
incq %r8
incl 0x80(%rsp)
movq 0xd0(%rsp), %rax
addq %rax, 0x78(%rsp)
addq %rax, 0xb0(%rsp)
jmp 0x7f6c
movq 0xa8(%rsp), %rdi
callq 0x1050
movq 0x68(%rsp), %rdi
callq 0x1050
movq 0xa0(%rsp), %rdi
callq 0x1050
movq 0x48(%rsp), %rdi
callq 0x1050
movsd 0x58(%rsp), %xmm0
movq 0x18(%rsp), %rax
movsd %xmm0, 0x70(%rax)
xorl %eax, %eax
testl %r13d, %r13d
movl $0x0, %ecx
cmovgl %r13d, %ecx
movq %rbx, %rdx
movq %r12, %rsi
movq 0xc0(%rsp), %r9
movq 0xb8(%rsp), %r10
cmpq %r9, %rax
je 0x8178
xorl %edi, %edi
movq %rcx, %r8
subq $0x1, %r8
jb 0x816b
movsd (%r14,%rax,8), %xmm1
addsd %xmm1, %xmm1
mulsd (%rsi,%rdi), %xmm1
addsd (%rdx,%rdi), %xmm1
movsd %xmm1, (%rdx,%rdi)
movsd (%rsi,%rdi), %xmm2
movsd (%r14,%rax,8), %xmm1
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm0
addq %r10, %rdi
jmp 0x8130
incq %rax
addq $0x8, %rsi
addq $0x8, %rdx
jmp 0x8126
xorl %r8d, %r8d
testl %r13d, %r13d
movl $0x0, %esi
cmovgl %r13d, %esi
pushq $0x1
popq %rdi
cmpl 0x60(%rsp), %r8d
je 0x828d
leal 0x1(%r8), %r9d
leal -0x1(%r8), %eax
imull %r8d, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movq %rdi, 0x20(%rsp)
movq %rax, 0x10(%rsp)
addl %edi, %eax
imull %ebp, %eax
movl %eax, 0x8(%rsp)
movl %r9d, 0x48(%rsp)
movl %r9d, %r11d
movl 0x4(%rsp), %ecx
cmpl %ecx, %r11d
jge 0x827a
movq 0x10(%rsp), %rax
leal (%r11,%rax), %edi
leal -0x1(%r11), %eax
imull %r11d, %eax
movl %ecx, %r9d
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %eax, %ecx
addl %r8d, %ecx
cmpl %r11d, %r8d
cmovbl %ecx, %edi
addl %r9d, %edi
movslq %edi, %rdx
imull %ebp, %ecx
xorl %ebp, %ebp
movl 0x8(%rsp), %eax
movl %eax, %edi
cmpl %esi, %ebp
je 0x8269
xorl %r9d, %r9d
movl %ecx, %eax
cmpl %r9d, %r13d
je 0x8260
leal (%rdi,%r9), %r10d
cmpl %r11d, %r8d
movsd (%r14,%rdx,8), %xmm1
addsd %xmm1, %xmm1
cmovbl %eax, %r10d
addl %r15d, %r10d
movslq %r10d, %r10
mulsd (%r12,%r10,8), %xmm1
addsd (%rbx,%r10,8), %xmm1
movsd %xmm1, (%rbx,%r10,8)
movsd (%r12,%r10,8), %xmm2
movsd (%r14,%rdx,8), %xmm1
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm0
incl %r9d
addl %r13d, %eax
jmp 0x820e
incl %ebp
incl %ecx
addl %r13d, %edi
jmp 0x8205
incl %r11d
movq 0x40(%rsp), %rbp
addl %ebp, 0x8(%rsp)
jmp 0x81c2
movq 0x20(%rsp), %rdi
incl %edi
movl 0x48(%rsp), %eax
movl %eax, %r8d
jmp 0x818a
movq %r12, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %rdx
movq 0xc8(%rsp), %rcx
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9e58