// File: /workspace/github_c_makefile_star2_O1/debbiemarkslab[P]plmc/src/lib/lbfgs.c
// Function: lbfgs
int lbfgs(
    int n,
    lbfgsfloatval_t *x,
    lbfgsfloatval_t *ptr_fx,
    lbfgs_evaluate_t proc_evaluate,
    lbfgs_progress_t proc_progress,
    void *instance,
    lbfgs_parameter_t *_param
    )
{
    int ret;
    int i, j, k, ls, end, bound;
    lbfgsfloatval_t step;

    /* Constant parameters and their default values. */
    lbfgs_parameter_t param = (_param != NULL) ? (*_param) : _defparam;
    const int m = param.m;

    lbfgsfloatval_t *xp = NULL;
    lbfgsfloatval_t *g = NULL, *gp = NULL, *pg = NULL;
    lbfgsfloatval_t *d = NULL, *w = NULL, *pf = NULL;
    iteration_data_t *lm = NULL, *it = NULL;
    lbfgsfloatval_t ys, yy;
    lbfgsfloatval_t xnorm, gnorm, beta;
    lbfgsfloatval_t fx = 0.;
    lbfgsfloatval_t rate = 0.;
    line_search_proc linesearch = line_search_morethuente;

    /* Construct a callback data. */
    callback_data_t cd;
    cd.n = n;
    cd.instance = instance;
    cd.proc_evaluate = proc_evaluate;
    cd.proc_progress = proc_progress;

#if     defined(USE_SSE) && (defined(__SSE__) || defined(__SSE2__))
    /* Round out the number of variables. */
    n = round_out_variables(n);
#endif/*defined(USE_SSE)*/

    /* Check the input parameters for errors. */
    if (n <= 0) {
        return LBFGSERR_INVALID_N;
    }
#if     defined(USE_SSE) && (defined(__SSE__) || defined(__SSE2__))
    if (n % 8 != 0) {
        return LBFGSERR_INVALID_N_SSE;
    }
    if ((uintptr_t)(const void*)x % 16 != 0) {
        return LBFGSERR_INVALID_X_SSE;
    }
#endif/*defined(USE_SSE)*/
    if (param.epsilon < 0.) {
        return LBFGSERR_INVALID_EPSILON;
    }
    if (param.past < 0) {
        return LBFGSERR_INVALID_TESTPERIOD;
    }
    if (param.delta < 0.) {
        return LBFGSERR_INVALID_DELTA;
    }
    if (param.min_step < 0.) {
        return LBFGSERR_INVALID_MINSTEP;
    }
    if (param.max_step < param.min_step) {
        return LBFGSERR_INVALID_MAXSTEP;
    }
    if (param.ftol < 0.) {
        return LBFGSERR_INVALID_FTOL;
    }
    if (param.linesearch == LBFGS_LINESEARCH_BACKTRACKING_WOLFE ||
        param.linesearch == LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE) {
        if (param.wolfe <= param.ftol || 1. <= param.wolfe) {
            return LBFGSERR_INVALID_WOLFE;
        }
    }
    if (param.gtol < 0.) {
        return LBFGSERR_INVALID_GTOL;
    }
    if (param.xtol < 0.) {
        return LBFGSERR_INVALID_XTOL;
    }
    if (param.max_linesearch <= 0) {
        return LBFGSERR_INVALID_MAXLINESEARCH;
    }
    if (param.orthantwise_c < 0.) {
        return LBFGSERR_INVALID_ORTHANTWISE;
    }
    if (param.orthantwise_start < 0 || n < param.orthantwise_start) {
        return LBFGSERR_INVALID_ORTHANTWISE_START;
    }
    if (param.orthantwise_end < 0) {
        param.orthantwise_end = n;
    }
    if (n < param.orthantwise_end) {
        return LBFGSERR_INVALID_ORTHANTWISE_END;
    }
    if (param.orthantwise_c != 0.) {
        switch (param.linesearch) {
        case LBFGS_LINESEARCH_BACKTRACKING:
            linesearch = line_search_backtracking_owlqn;
            break;
        default:
            /* Only the backtracking method is available. */
            return LBFGSERR_INVALID_LINESEARCH;
        }
    } else {
        switch (param.linesearch) {
        case LBFGS_LINESEARCH_MORETHUENTE:
            linesearch = line_search_morethuente;
            break;
        case LBFGS_LINESEARCH_BACKTRACKING_ARMIJO:
        case LBFGS_LINESEARCH_BACKTRACKING_WOLFE:
        case LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE:
            linesearch = line_search_backtracking;
            break;
        default:
            return LBFGSERR_INVALID_LINESEARCH;
        }
    }

    /* Allocate working space. */
    xp = (lbfgsfloatval_t*)vecalloc(n * sizeof(lbfgsfloatval_t));
    g = (lbfgsfloatval_t*)vecalloc(n * sizeof(lbfgsfloatval_t));
    gp = (lbfgsfloatval_t*)vecalloc(n * sizeof(lbfgsfloatval_t));
    d = (lbfgsfloatval_t*)vecalloc(n * sizeof(lbfgsfloatval_t));
    w = (lbfgsfloatval_t*)vecalloc(n * sizeof(lbfgsfloatval_t));
    if (xp == NULL || g == NULL || gp == NULL || d == NULL || w == NULL) {
        ret = LBFGSERR_OUTOFMEMORY;
        goto lbfgs_exit;
    }

    if (param.orthantwise_c != 0.) {
        /* Allocate working space for OW-LQN. */
        pg = (lbfgsfloatval_t*)vecalloc(n * sizeof(lbfgsfloatval_t));
        if (pg == NULL) {
            ret = LBFGSERR_OUTOFMEMORY;
            goto lbfgs_exit;
        }
    }

    /* Allocate limited memory storage. */
    lm = (iteration_data_t*)vecalloc(m * sizeof(iteration_data_t));
    if (lm == NULL) {
        ret = LBFGSERR_OUTOFMEMORY;
        goto lbfgs_exit;
    }

    /* Initialize the limited memory. */
    for (i = 0;i < m;++i) {
        it = &lm[i];
        it->alpha = 0;
        it->ys = 0;
        it->s = (lbfgsfloatval_t*)vecalloc(n * sizeof(lbfgsfloatval_t));
        it->y = (lbfgsfloatval_t*)vecalloc(n * sizeof(lbfgsfloatval_t));
        if (it->s == NULL || it->y == NULL) {
            ret = LBFGSERR_OUTOFMEMORY;
            goto lbfgs_exit;
        }
    }

    /* Allocate an array for storing previous values of the objective function. */
    if (0 < param.past) {
        pf = (lbfgsfloatval_t*)vecalloc(param.past * sizeof(lbfgsfloatval_t));
    }

    /* Evaluate the function value and its gradient. */
    fx = cd.proc_evaluate(cd.instance, x, g, cd.n, 0);
    if (0. != param.orthantwise_c) {
        /* Compute the L1 norm of the variable and add it to the object value. */
        xnorm = owlqn_x1norm(x, param.orthantwise_start, param.orthantwise_end);
        fx += xnorm * param.orthantwise_c;
        owlqn_pseudo_gradient(
            pg, x, g, n,
            param.orthantwise_c, param.orthantwise_start, param.orthantwise_end
            );
    }

    /* Store the initial value of the objective function. */
    if (pf != NULL) {
        pf[0] = fx;
    }

    /*
        Compute the direction;
        we assume the initial hessian matrix H_0 as the identity matrix.
     */
    if (param.orthantwise_c == 0.) {
        vecncpy(d, g, n);
    } else {
        vecncpy(d, pg, n);
    }

    /*
       Make sure that the initial variables are not a minimizer.
     */
    vec2norm(&xnorm, x, n);
    if (param.orthantwise_c == 0.) {
        vec2norm(&gnorm, g, n);
    } else {
        vec2norm(&gnorm, pg, n);
    }
    if (xnorm < 1.0) xnorm = 1.0;
    if (gnorm / xnorm <= param.epsilon) {
        ret = LBFGS_ALREADY_MINIMIZED;
        goto lbfgs_exit;
    }

    /* Compute the initial step:
        step = 1.0 / sqrt(vecdot(d, d, n))
     */
    vec2norminv(&step, d, n);

    k = 1;
    end = 0;
    for (;;) {
        /* Store the current position and gradient vectors. */
        veccpy(xp, x, n);
        veccpy(gp, g, n);

        /* Search for an optimal step. */
        if (param.orthantwise_c == 0.) {
            ls = linesearch(n, x, &fx, g, d, &step, xp, gp, w, &cd, &param);
        } else {
            ls = linesearch(n, x, &fx, g, d, &step, xp, pg, w, &cd, &param);
            owlqn_pseudo_gradient(
                pg, x, g, n,
                param.orthantwise_c, param.orthantwise_start, param.orthantwise_end
                );
        }
        if (ls < 0) {
            /* Revert to the previous point. */
            veccpy(x, xp, n);
            veccpy(g, gp, n);
            ret = ls;
            goto lbfgs_exit;
        }

        /* Compute x and g norms. */
        vec2norm(&xnorm, x, n);
        if (param.orthantwise_c == 0.) {
            vec2norm(&gnorm, g, n);
        } else {
            vec2norm(&gnorm, pg, n);
        }

        /* Report the progress. */
        if (cd.proc_progress) {
            if ((ret = cd.proc_progress(cd.instance, x, g, fx, xnorm, gnorm, step, cd.n, k, ls))) {
                goto lbfgs_exit;
            }
        }

        /*
            Convergence test.
            The criterion is given by the following formula:
                |g(x)| / \max(1, |x|) < \epsilon
         */
        if (xnorm < 1.0) xnorm = 1.0;
        if (gnorm / xnorm <= param.epsilon) {
            /* Convergence. */
            ret = LBFGS_SUCCESS;
            break;
        }

        /*
            Test for stopping criterion.
            The criterion is given by the following formula:
                (f(past_x) - f(x)) / f(x) < \delta
         */
        if (pf != NULL) {
            /* We don't test the stopping criterion while k < past. */
            if (param.past <= k) {
                /* Compute the relative improvement from the past. */
                rate = (pf[k % param.past] - fx) / fx;

                /* The stopping criterion. */
                if (rate < param.delta) {
                    ret = LBFGS_STOP;
                    break;
                }
            }

            /* Store the current value of the objective function. */
            pf[k % param.past] = fx;
        }

        if (param.max_iterations != 0 && param.max_iterations < k+1) {
            /* Maximum number of iterations. */
            ret = LBFGSERR_MAXIMUMITERATION;
            break;
        }

        /*
            Update vectors s and y:
                s_{k+1} = x_{k+1} - x_{k} = \step * d_{k}.
                y_{k+1} = g_{k+1} - g_{k}.
         */
        it = &lm[end];
        vecdiff(it->s, x, xp, n);
        vecdiff(it->y, g, gp, n);

        /*
            Compute scalars ys and yy:
                ys = y^t \cdot s = 1 / \rho.
                yy = y^t \cdot y.
            Notice that yy is used for scaling the hessian matrix H_0 (Cholesky factor).
         */
        vecdot(&ys, it->y, it->s, n);
        vecdot(&yy, it->y, it->y, n);
        it->ys = ys;

        /*
            Recursive formula to compute dir = -(H \cdot g).
                This is described in page 779 of:
                Jorge Nocedal.
                Updating Quasi-Newton Matrices with Limited Storage.
                Mathematics of Computation, Vol. 35, No. 151,
                pp. 773--782, 1980.
         */
        bound = (m <= k) ? m : k;
        ++k;
        end = (end + 1) % m;

        /* Compute the steepest direction. */
        if (param.orthantwise_c == 0.) {
            /* Compute the negative of gradients. */
            vecncpy(d, g, n);
        } else {
            vecncpy(d, pg, n);
        }

        j = end;
        for (i = 0;i < bound;++i) {
            j = (j + m - 1) % m;    /* if (--j == -1) j = m-1; */
            it = &lm[j];
            /* \alpha_{j} = \rho_{j} s^{t}_{j} \cdot q_{k+1}. */
            vecdot(&it->alpha, it->s, d, n);
            it->alpha /= it->ys;
            /* q_{i} = q_{i+1} - \alpha_{i} y_{i}. */
            vecadd(d, it->y, -it->alpha, n);
        }

        vecscale(d, ys / yy, n);

        for (i = 0;i < bound;++i) {
            it = &lm[j];
            /* \beta_{j} = \rho_{j} y^t_{j} \cdot \gamma_{i}. */
            vecdot(&beta, it->y, d, n);
            beta /= it->ys;
            /* \gamma_{i+1} = \gamma_{i} + (\alpha_{j} - \beta_{j}) s_{j}. */
            vecadd(d, it->s, it->alpha - beta, n);
            j = (j + 1) % m;        /* if (++j == m) j = 0; */
        }

        /*
            Constrain the search direction for orthant-wise updates.
         */
        if (param.orthantwise_c != 0.) {
            for (i = param.orthantwise_start;i < param.orthantwise_end;++i) {
                if (d[i] * pg[i] >= 0) {
                    d[i] = 0;
                }
            }
        }

        /*
            Now the search direction d is ready. We try step = 1 first.
         */
        step = 1.0;
    }

lbfgs_exit:
    /* Return the final value of the objective function. */
    if (ptr_fx != NULL) {
        *ptr_fx = fx;
    }

    vecfree(pf);

    /* Free memory blocks used by this function. */
    if (lm != NULL) {
        for (i = 0;i < m;++i) {
            vecfree(lm[i].s);
            vecfree(lm[i].y);
        }
        vecfree(lm);
    }
    vecfree(pg);
    vecfree(w);
    vecfree(d);
    vecfree(gp);
    vecfree(g);
    vecfree(xp);

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %r9, %r15
movq %rcx, %r13
movq %rsi, %r14
movl %edi, %ebp
movq 0x170(%rsp), %rsi
testq %rsi, %rsi
jne 0x330a
leaq 0xadb6(%rip), %rsi      # 0xe0c0
leaq 0xa8(%rsp), %rdi
movl $0xe, %ecx
rep  movsq (%rsi), %es:(%rdi)
movslq 0xa8(%rsp), %rsi
movq $0x0, 0x50(%rsp)
movl %ebp, 0x118(%rsp)
movq %r15, 0x120(%rsp)
movq %r13, 0x128(%rsp)
movq %r8, 0x130(%rsp)
testl %ebp, %ebp
jle 0x34c3
movl $0xfffffc07, %r12d      # imm = 0xFFFFFC07
xorpd %xmm0, %xmm0
ucomisd 0xb0(%rsp), %xmm0
ja 0x34d1
movslq 0xb8(%rsp), %rbx
testq %rbx, %rbx
js 0x34cb
movl $0xfffffc09, %r12d      # imm = 0xFFFFFC09
xorpd %xmm1, %xmm1
ucomisd 0xc0(%rsp), %xmm1
ja 0x34d1
movsd 0xd8(%rsp), %xmm0
movl $0xfffffc0b, %r12d      # imm = 0xFFFFFC0B
ucomisd %xmm0, %xmm1
ja 0x34d1
movl $0xfffffc0c, %r12d      # imm = 0xFFFFFC0C
ucomisd 0xe0(%rsp), %xmm0
ja 0x34d1
movsd 0xe8(%rsp), %xmm0
movl $0xfffffc0d, %r12d      # imm = 0xFFFFFC0D
ucomisd %xmm0, %xmm1
ja 0x34d1
movl 0xcc(%rsp), %eax
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x2, %ecx
jne 0x3414
movsd 0xf0(%rsp), %xmm1
ucomisd %xmm1, %xmm0
movl $0xfffffc0e, %r12d      # imm = 0xFFFFFC0E
jae 0x34d1
ucomisd 0xac5a(%rip), %xmm1     # 0xe068
jae 0x34d1
movl $0xfffffc0f, %r12d      # imm = 0xFFFFFC0F
xorpd %xmm0, %xmm0
ucomisd 0xf8(%rsp), %xmm0
ja 0x34d1
movl $0xfffffc10, %r12d      # imm = 0xFFFFFC10
ucomisd 0x100(%rsp), %xmm0
ja 0x34d1
cmpl $0x0, 0xd0(%rsp)
jle 0x34e6
movsd 0x108(%rsp), %xmm1
movl $0xfffffc12, %r12d      # imm = 0xFFFFFC12
ucomisd %xmm1, %xmm0
ja 0x34d1
movl $0xfffffc13, %r12d      # imm = 0xFFFFFC13
cmpl %ebp, 0x110(%rsp)
ja 0x34d1
cmpl $0x0, 0x114(%rsp)
jns 0x3485
movl %ebp, 0x114(%rsp)
movl $0xfffffc14, %r12d      # imm = 0xFFFFFC14
cmpl %ebp, 0x114(%rsp)
jg 0x34d1
movl $0xfffffc0a, %r12d      # imm = 0xFFFFFC0A
ucomisd %xmm0, %xmm1
jne 0x34a2
jnp 0x34ee
cmpl $0x2, %eax
jne 0x34d1
movsd %xmm1, 0x18(%rsp)
movq %rdx, 0xa0(%rsp)
movq %rsi, 0x40(%rsp)
leaq 0x12a8(%rip), %rax      # 0x4769
jmp 0x3511
movl $0xfffffc04, %r12d      # imm = 0xFFFFFC04
jmp 0x34d1
movl $0xfffffc08, %r12d      # imm = 0xFFFFFC08
movl %r12d, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xfffffc11, %r12d      # imm = 0xFFFFFC11
jmp 0x34d1
cmpl $0x3, %eax
ja 0x34d1
movsd %xmm1, 0x18(%rsp)
movq %rdx, 0xa0(%rsp)
movq %rsi, 0x40(%rsp)
leaq 0xe893(%rip), %rcx      # 0x11da0
movq (%rcx,%rax,8), %rax
movq %rax, 0x90(%rsp)
movl %ebp, %eax
movq %rax, 0x38(%rsp)
leaq (,%rax,8), %rdi
movq %rdi, 0x10(%rsp)
callq 0x11a0
movq %rax, %r12
testq %rax, %rax
je 0x3549
movq %r12, %rdi
xorl %esi, %esi
movq 0x10(%rsp), %rdx
callq 0x1110
movq %r12, 0x80(%rsp)
movq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x11a0
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x3577
movq 0x20(%rsp), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x1110
movq %r12, %rdi
callq 0x11a0
movq %rax, %r12
testq %rax, %rax
je 0x3596
movq %r12, %rdi
xorl %esi, %esi
movq 0x10(%rsp), %rdx
callq 0x1110
movq %r12, 0x70(%rsp)
movq 0x10(%rsp), %rdi
callq 0x11a0
movq %rax, %r12
testq %rax, %rax
je 0x35bc
movq %r12, %rdi
xorl %esi, %esi
movq 0x10(%rsp), %rdx
callq 0x1110
movq 0x10(%rsp), %rdi
callq 0x11a0
testq %rax, %rax
movq %rax, 0x78(%rsp)
je 0x35e6
movq 0x78(%rsp), %rdi
xorl %esi, %esi
movq 0x10(%rsp), %rdx
callq 0x1110
movq 0x78(%rsp), %rax
testq %rax, %rax
sete %al
movq %r12, 0x48(%rsp)
testq %r12, %r12
sete %cl
cmpq $0x0, 0x70(%rsp)
sete %dl
cmpq $0x0, 0x20(%rsp)
sete %sil
cmpq $0x0, 0x80(%rsp)
sete %dil
orb %sil, %dil
orb %cl, %dl
orb %dil, %dl
orb %al, %dl
movl $0xfffffc02, %r12d      # imm = 0xFFFFFC02
je 0x36f1
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x18(%rsp)
movq 0xa0(%rsp), %rax
testq %rax, %rax
je 0x365f
movsd 0x50(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x30(%rsp), %rdi
callq 0x1050
movq 0x18(%rsp), %r15
testq %r15, %r15
je 0x36ad
movq 0x40(%rsp), %rax
testl %eax, %eax
jle 0x36a5
shlq $0x5, %rax
xorl %ebx, %ebx
movq 0x8(%r15,%rbx), %rdi
movq %rax, %r14
callq 0x1050
movq 0x10(%r15,%rbx), %rdi
callq 0x1050
movq %r14, %rax
addq $0x20, %rbx
cmpq %rbx, %r14
jne 0x3682
movq %r15, %rdi
callq 0x1050
movq 0x28(%rsp), %rdi
callq 0x1050
movq 0x78(%rsp), %rdi
callq 0x1050
movq 0x48(%rsp), %rdi
callq 0x1050
movq 0x70(%rsp), %rdi
callq 0x1050
movq 0x20(%rsp), %rdi
callq 0x1050
movq 0x80(%rsp), %rdi
callq 0x1050
jmp 0x34d1
xorpd %xmm0, %xmm0
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x3703
jnp 0x372e
movq 0x10(%rsp), %rdi
callq 0x11a0
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x362d
movq 0x28(%rsp), %rdi
xorl %esi, %esi
movq 0x10(%rsp), %rdx
callq 0x1110
jmp 0x3737
movq $0x0, 0x28(%rsp)
movq 0x40(%rsp), %rdi
shlq $0x5, %rdi
movq %rdi, 0x60(%rsp)
callq 0x11a0
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x3636
movq 0x18(%rsp), %rdi
xorl %esi, %esi
movq 0x60(%rsp), %rdx
callq 0x1110
cmpl $0x0, 0x40(%rsp)
jle 0x3830
xorl %edx, %edx
movq 0x18(%rsp), %rax
xorl %ecx, %ecx
movq %rcx, (%rax,%rdx)
movq $0x0, 0x30(%rsp)
movq %rdx, 0x58(%rsp)
movq %rcx, 0x18(%rax,%rdx)
movq 0x10(%rsp), %rdi
callq 0x11a0
movq %rax, %rdx
testq %rax, %rax
movq %rax, 0x8(%rsp)
je 0x37c1
movq 0x8(%rsp), %rdi
xorl %esi, %esi
movq 0x10(%rsp), %rdx
callq 0x1110
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %rax
movq 0x58(%rsp), %rcx
movq %rdx, 0x8(%rax,%rcx)
movq 0x10(%rsp), %rdi
callq 0x11a0
movq %rax, %rcx
testq %rax, %rax
je 0x37fd
movq %rcx, 0x68(%rsp)
movq 0x68(%rsp), %rdi
xorl %esi, %esi
movq 0x10(%rsp), %rdx
callq 0x1110
movq 0x68(%rsp), %rcx
movq 0x18(%rsp), %rax
movq 0x58(%rsp), %rdx
movq %rcx, 0x10(%rax,%rdx)
cmpq $0x0, 0x8(%rsp)
je 0x3648
testq %rcx, %rcx
je 0x3648
addq $0x20, %rdx
cmpq %rdx, 0x60(%rsp)
jne 0x3776
testl %ebx, %ebx
je 0x385b
shlq $0x3, %rbx
movq %rbx, %rdi
callq 0x11a0
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x3864
movq 0x30(%rsp), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x1110
jmp 0x3864
movq $0x0, 0x30(%rsp)
xorpd %xmm0, %xmm0
movq %r15, %rdi
movq %r14, %rsi
movq 0x20(%rsp), %rdx
movl %ebp, %ecx
callq *%r13
movsd %xmm0, 0x50(%rsp)
movsd 0x108(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
ucomisd 0xa7db(%rip), %xmm1     # 0xe070
jne 0x3899
jnp 0x38ff
movslq 0x110(%rsp), %r8
movslq 0x114(%rsp), %r9
cmpl %r9d, %r8d
xorpd %xmm3, %xmm3
jge 0x38d3
movapd 0xa7e6(%rip), %xmm1     # 0xe0a0
movq %r8, %rax
movsd (%r14,%rax,8), %xmm2
andpd %xmm1, %xmm2
addsd %xmm2, %xmm3
incq %rax
cmpq %rax, %r9
jne 0x38bd
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm3
addsd %xmm0, %xmm3
movsd %xmm3, 0x50(%rsp)
movq 0x28(%rsp), %rdi
movq %r14, %rsi
movq 0x20(%rsp), %rdx
movl %ebp, %ecx
movapd %xmm1, %xmm0
callq 0x4b97
cmpq $0x0, 0x30(%rsp)
je 0x3916
movsd 0x50(%rsp), %xmm0
movq 0x30(%rsp), %rax
movsd %xmm0, (%rax)
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
jne 0x3959
jp 0x3959
movapd 0xa77e(%rip), %xmm0     # 0xe0b0
movq 0x20(%rsp), %rcx
movq 0x48(%rsp), %rdx
movq 0x38(%rsp), %rsi
movsd (%rcx,%rax,8), %xmm1
xorpd %xmm0, %xmm1
movlpd %xmm1, (%rdx,%rax,8)
incq %rax
cmpq %rax, %rsi
jne 0x3941
jmp 0x3986
movapd 0xa74f(%rip), %xmm0     # 0xe0b0
movq 0x48(%rsp), %rcx
movq 0x28(%rsp), %rdx
movq 0x38(%rsp), %rsi
movsd (%rdx,%rax,8), %xmm1
xorpd %xmm0, %xmm1
movlpd %xmm1, (%rcx,%rax,8)
incq %rax
cmpq %rax, %rsi
jne 0x3970
xorpd %xmm0, %xmm0
xorl %eax, %eax
movsd (%r14,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rsi
jne 0x398c
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x39b2
sqrtsd %xmm0, %xmm0
jmp 0x39b7
callq 0x1210
movsd %xmm0, 0x8(%rsp)
movsd 0x108(%rsp), %xmm0
ucomisd 0xa6a2(%rip), %xmm0     # 0xe070
jne 0x39f9
jp 0x39f9
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq 0x20(%rsp), %rcx
movq 0x38(%rsp), %rdx
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rdx
jne 0x39e2
jmp 0x3a1e
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rdx
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rdx
jne 0x3a09
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x3a2e
sqrtsd %xmm0, %xmm0
jmp 0x3a33
callq 0x1210
movsd 0xa62d(%rip), %xmm1     # 0xe068
maxsd 0x8(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0xb0(%rsp), %xmm1
movl $0x2, %r12d
ucomisd %xmm0, %xmm1
jae 0x3648
movq $0x0, 0x88(%rsp)
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq 0x48(%rsp), %rcx
movq 0x38(%rsp), %rdx
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rdx
jne 0x3a7a
movsd %xmm0, 0x88(%rsp)
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x3aa8
sqrtsd %xmm0, %xmm0
jmp 0x3aad
callq 0x1210
movsd 0xa5b3(%rip), %xmm1     # 0xe068
divsd %xmm0, %xmm1
movq 0x40(%rsp), %r8
leal -0x1(%r8), %eax
movl %eax, 0x9c(%rsp)
movq $0x0, 0x58(%rsp)
movl $0x1, 0x8(%rsp)
movq %r8, 0x40(%rsp)
movq 0x20(%rsp), %r13
movl 0x8(%rsp), %r15d
cmpl %r15d, %r8d
cmovll %r8d, %r15d
movsd %xmm1, 0x88(%rsp)
movq 0x80(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x1190
movq 0x70(%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x1190
movsd 0x108(%rsp), %xmm0
ucomisd 0xa53b(%rip), %xmm0     # 0xe070
jne 0x3b89
jp 0x3b89
subq $0x8, %rsp
movl %ebp, %edi
movq %r14, %rsi
leaq 0x58(%rsp), %rdx
movq %r13, %rcx
movq 0x50(%rsp), %r8
leaq 0x90(%rsp), %r9
leaq 0xb0(%rsp), %rax
pushq %rax
leaq 0x128(%rsp), %rax
pushq %rax
pushq 0x90(%rsp)
pushq 0x90(%rsp)
pushq %r12
callq *0xc0(%rsp)
addq $0x30, %rsp
movl %eax, %r12d
jmp 0x3bff
subq $0x8, %rsp
movl %ebp, %edi
movq %r14, %rsi
leaq 0x58(%rsp), %rdx
movq %r13, %rcx
movq 0x50(%rsp), %r8
leaq 0x90(%rsp), %r9
leaq 0xb0(%rsp), %rax
pushq %rax
leaq 0x128(%rsp), %rax
pushq %rax
pushq 0x90(%rsp)
movq 0x48(%rsp), %rbx
pushq %rbx
pushq %r12
callq *0xc0(%rsp)
addq $0x30, %rsp
movl %eax, %r12d
movsd 0x108(%rsp), %xmm0
movl 0x110(%rsp), %r8d
movl 0x114(%rsp), %r9d
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
movl %ebp, %ecx
callq 0x4b97
testl %r12d, %r12d
js 0x409e
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq 0x38(%rsp), %rcx
movsd (%r14,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rcx
jne 0x3c13
ucomisd 0xa43f(%rip), %xmm0     # 0xe070
jb 0x3c39
sqrtsd %xmm0, %xmm0
jmp 0x3c3e
callq 0x1210
movsd %xmm0, 0x68(%rsp)
movsd 0x108(%rsp), %xmm0
ucomisd 0xa41b(%rip), %xmm0     # 0xe070
jne 0x3c80
jp 0x3c80
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq 0x20(%rsp), %rcx
movq 0x38(%rsp), %rdx
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rdx
jne 0x3c69
jmp 0x3ca5
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rdx
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rdx
jne 0x3c90
ucomisd 0xa3c3(%rip), %xmm0     # 0xe070
jb 0x3cb5
sqrtsd %xmm0, %xmm0
jmp 0x3cba
callq 0x1210
movsd %xmm0, 0x60(%rsp)
movq 0x130(%rsp), %rax
testq %rax, %rax
je 0x3d11
movq 0x120(%rsp), %rdi
movsd 0x50(%rsp), %xmm0
movsd 0x88(%rsp), %xmm3
movl 0x118(%rsp), %ecx
movq %r14, %rsi
movq 0x20(%rsp), %rdx
movsd 0x68(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
movl 0x8(%rsp), %r8d
movl %r12d, %r9d
callq *%rax
testl %eax, %eax
jne 0x40e0
movsd 0xa34f(%rip), %xmm0     # 0xe068
maxsd 0x68(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd 0xb0(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jae 0x40cd
cmpq $0x0, 0x30(%rsp)
je 0x3d9a
movl 0xb8(%rsp), %ecx
cmpl 0x8(%rsp), %ecx
jg 0x3d83
movl 0x8(%rsp), %eax
cltd
idivl %ecx
movq 0x30(%rsp), %rax
movsd (%rax,%rdx,8), %xmm0
movsd 0x50(%rsp), %xmm1
subsd %xmm1, %xmm0
divsd %xmm1, %xmm0
movsd 0xc0(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x40e8
movsd 0x50(%rsp), %xmm0
movl 0x8(%rsp), %eax
cltd
idivl %ecx
movq 0x30(%rsp), %rax
movsd %xmm0, (%rax,%rdx,8)
movl 0xc8(%rsp), %eax
testl %eax, %eax
sete %cl
cmpl 0x8(%rsp), %eax
setg %al
orb %cl, %al
cmpb $0x1, %al
jne 0x40d5
movslq 0x58(%rsp), %rcx
shlq $0x5, %rcx
movq 0x18(%rsp), %rdx
leaq (%rdx,%rcx), %rax
movq 0x8(%rdx,%rcx), %rdx
xorl %ecx, %ecx
movq 0x80(%rsp), %rsi
movq 0x38(%rsp), %r9
movsd (%r14,%rcx,8), %xmm0
subsd (%rsi,%rcx,8), %xmm0
movsd %xmm0, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %r9
jne 0x3ddd
movq 0x10(%rax), %rcx
xorl %esi, %esi
movq 0x20(%rsp), %rdi
movq 0x70(%rsp), %r8
movsd (%rdi,%rsi,8), %xmm0
subsd (%r8,%rsi,8), %xmm0
movsd %xmm0, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %r9
jne 0x3e05
xorpd %xmm1, %xmm1
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm0
mulsd (%rdx,%rsi,8), %xmm0
addsd %xmm0, %xmm1
incq %rsi
cmpq %rsi, %r9
jne 0x3e23
xorpd %xmm2, %xmm2
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm2
incq %rdx
cmpq %rdx, %r9
jne 0x3e3f
movsd %xmm1, 0x18(%rax)
movq 0x58(%rsp), %rax
incl %eax
cltd
idivl 0x40(%rsp)
movsd 0x108(%rsp), %xmm0
ucomisd 0xa1fa(%rip), %xmm0     # 0xe070
movq %rdx, 0x58(%rsp)
jne 0x3eb1
jp 0x3eb1
xorl %eax, %eax
movq 0x20(%rsp), %rcx
movq 0x48(%rsp), %r9
movq 0x38(%rsp), %r10
movapd 0xa218(%rip), %xmm5     # 0xe0b0
movsd (%rcx,%rax,8), %xmm3
xorpd %xmm5, %xmm3
movlpd %xmm3, (%r9,%rax,8)
incq %rax
cmpq %rax, %r10
jne 0x3e98
jmp 0x3ee1
xorl %eax, %eax
movq 0x48(%rsp), %r9
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %r10
movapd 0xa1e6(%rip), %xmm5     # 0xe0b0
movsd (%rcx,%rax,8), %xmm3
xorpd %xmm5, %xmm3
movlpd %xmm3, (%r9,%rax,8)
incq %rax
cmpq %rax, %r10
jne 0x3eca
movq 0x58(%rsp), %rax
movl %eax, %edx
movq 0x40(%rsp), %r8
testl %r8d, %r8d
movq 0x18(%rsp), %r11
movl 0x9c(%rsp), %ebx
jle 0x3f87
xorl %ecx, %ecx
movq 0x58(%rsp), %rax
movl %eax, %edx
addl %ebx, %edx
movl %edx, %eax
cltd
idivl %r8d
movslq %edx, %rdi
shlq $0x5, %rdi
leaq (%r11,%rdi), %rax
movq 0x8(%r11,%rdi), %rsi
movq $0x0, (%r11,%rdi)
xorpd %xmm3, %xmm3
xorl %edi, %edi
movsd (%rsi,%rdi,8), %xmm4
mulsd (%r9,%rdi,8), %xmm4
addsd %xmm4, %xmm3
movsd %xmm3, (%rax)
incq %rdi
cmpq %rdi, %r10
jne 0x3f31
movsd (%rax), %xmm3
divsd 0x18(%rax), %xmm3
movsd %xmm3, (%rax)
movq 0x10(%rax), %rax
xorpd %xmm5, %xmm3
xorl %esi, %esi
movsd (%rax,%rsi,8), %xmm4
mulsd %xmm3, %xmm4
addsd (%r9,%rsi,8), %xmm4
movsd %xmm4, (%r9,%rsi,8)
incq %rsi
cmpq %rsi, %r10
jne 0x3f63
incl %ecx
cmpl %r15d, %ecx
jne 0x3f0b
incl 0x8(%rsp)
divsd %xmm2, %xmm1
xorl %eax, %eax
movsd (%r9,%rax,8), %xmm2
mulsd %xmm1, %xmm2
movsd %xmm2, (%r9,%rax,8)
incq %rax
cmpq %rax, %r10
jne 0x3f91
movq 0x40(%rsp), %r8
testl %r8d, %r8d
movq 0x18(%rsp), %r11
jle 0x4026
xorl %ecx, %ecx
movslq %edx, %rsi
shlq $0x5, %rsi
leaq (%r11,%rsi), %rax
movq 0x10(%r11,%rsi), %rsi
xorpd %xmm1, %xmm1
xorl %edi, %edi
movsd (%rsi,%rdi,8), %xmm2
mulsd (%r9,%rdi,8), %xmm2
addsd %xmm2, %xmm1
incq %rdi
cmpq %rdi, %r10
jne 0x3fd0
divsd 0x18(%rax), %xmm1
movq 0x8(%rax), %rsi
movsd (%rax), %xmm2
subsd %xmm1, %xmm2
xorl %eax, %eax
movsd (%rsi,%rax,8), %xmm1
mulsd %xmm2, %xmm1
addsd (%r9,%rax,8), %xmm1
movsd %xmm1, (%r9,%rax,8)
incq %rax
cmpq %rax, %r10
jne 0x3ffa
incl %edx
movl %edx, %eax
cltd
idivl %r8d
incl %ecx
cmpl %r15d, %ecx
jne 0x3fba
ucomisd 0xa042(%rip), %xmm0     # 0xe070
movsd 0xa032(%rip), %xmm1     # 0xe068
jne 0x403e
jnp 0x3ae4
movslq 0x110(%rsp), %rax
movslq 0x114(%rsp), %rcx
movsd 0xa012(%rip), %xmm1     # 0xe068
cmpl %ecx, %eax
jge 0x3ae4
movq 0x48(%rsp), %rdx
movq 0x28(%rsp), %rsi
xorpd %xmm1, %xmm1
movsd (%rdx,%rax,8), %xmm0
mulsd (%rsi,%rax,8), %xmm0
ucomisd %xmm1, %xmm0
jb 0x4084
movq $0x0, (%rdx,%rax,8)
incq %rax
cmpq %rax, %rcx
jne 0x406c
movsd 0x9fd4(%rip), %xmm1     # 0xe068
movq 0x40(%rsp), %r8
jmp 0x3ae4
movq %r14, %rdi
movq 0x80(%rsp), %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x1190
movq 0x20(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq %rbx, %rdx
callq 0x1190
jmp 0x3648
xorl %r12d, %r12d
jmp 0x3648
movl $0xfffffc1b, %r12d      # imm = 0xFFFFFC1B
jmp 0x3648
movl %eax, %r12d
jmp 0x3648
movl $0x1, %r12d
jmp 0x3648