// File: /workspace/github_c_makefile_star2_O3/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 $0x148, %rsp            # imm = 0x148
movq %r9, %r15
movq %rcx, %r13
movq %rsi, %r14
movl %edi, %ebp
movq 0x180(%rsp), %rsi
testq %rsi, %rsi
je 0x28d6
leaq 0xd8(%rsp), %rax
movl $0xe, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
movl (%rax), %esi
jmp 0x28f2
leaq 0xa7e3(%rip), %rsi      # 0xd0c0
leaq 0xd8(%rsp), %rdi
movl $0xe, %ecx
rep  movsq (%rsi), %es:(%rdi)
movl $0x6, %esi
movq $0x0, 0x60(%rsp)
movl %ebp, 0xb8(%rsp)
movq %r15, 0xc0(%rsp)
movq %r13, 0xc8(%rsp)
movq %r8, 0xd0(%rsp)
testl %ebp, %ebp
jle 0x2a52
movsd 0xe0(%rsp), %xmm2
movl $0xfffffc07, %r12d      # imm = 0xFFFFFC07
xorpd %xmm0, %xmm0
ucomisd %xmm2, %xmm0
ja 0x2a60
movslq 0xe8(%rsp), %rbx
testq %rbx, %rbx
js 0x2a5a
movl $0xfffffc09, %r12d      # imm = 0xFFFFFC09
xorpd %xmm1, %xmm1
ucomisd 0xf0(%rsp), %xmm1
ja 0x2a60
movsd 0x108(%rsp), %xmm0
movl $0xfffffc0b, %r12d      # imm = 0xFFFFFC0B
ucomisd %xmm0, %xmm1
ja 0x2a60
movl $0xfffffc0c, %r12d      # imm = 0xFFFFFC0C
ucomisd 0x110(%rsp), %xmm0
ja 0x2a60
movsd 0x118(%rsp), %xmm0
movl $0xfffffc0d, %r12d      # imm = 0xFFFFFC0D
ucomisd %xmm0, %xmm1
ja 0x2a60
movl 0xfc(%rsp), %eax
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x2, %ecx
jne 0x29e4
movsd 0x120(%rsp), %xmm1
ucomisd %xmm1, %xmm0
movl $0xfffffc0e, %r12d      # imm = 0xFFFFFC0E
jae 0x2a60
ucomisd 0xa686(%rip), %xmm1     # 0xd068
jae 0x2a60
movl $0xfffffc0f, %r12d      # imm = 0xFFFFFC0F
xorpd %xmm0, %xmm0
ucomisd 0x128(%rsp), %xmm0
ja 0x2a60
movl $0xfffffc10, %r12d      # imm = 0xFFFFFC10
ucomisd 0x130(%rsp), %xmm0
ja 0x2a60
cmpl $0x0, 0x100(%rsp)
jle 0x2a75
movsd 0x138(%rsp), %xmm1
movl $0xfffffc12, %r12d      # imm = 0xFFFFFC12
ucomisd %xmm1, %xmm0
ja 0x2a60
movslq 0x140(%rsp), %rcx
movl $0xfffffc13, %r12d      # imm = 0xFFFFFC13
cmpl %ebp, %ecx
ja 0x2a60
movl 0x144(%rsp), %edi
testl %edi, %edi
js 0x2a7d
movl $0xfffffc14, %r12d      # imm = 0xFFFFFC14
cmpl %ebp, %edi
ja 0x2a60
jmp 0x2a86
movl $0xfffffc04, %r12d      # imm = 0xFFFFFC04
jmp 0x2a60
movl $0xfffffc08, %r12d      # imm = 0xFFFFFC08
movl %r12d, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xfffffc11, %r12d      # imm = 0xFFFFFC11
jmp 0x2a60
movl %ebp, 0x144(%rsp)
movl %ebp, %edi
movl $0xfffffc0a, %r12d      # imm = 0xFFFFFC0A
ucomisd %xmm0, %xmm1
jne 0x2a94
jnp 0x2ac7
cmpl $0x2, %eax
jne 0x2a60
movl %edi, 0x54(%rsp)
movq %rcx, 0x68(%rsp)
movsd %xmm2, 0xa8(%rsp)
movsd %xmm1, 0x18(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0xb0(%rsp)
leaq 0x11ac(%rip), %rax      # 0x3c71
jmp 0x2afc
cmpl $0x3, %eax
ja 0x2a60
movl %edi, 0x54(%rsp)
movq %rcx, 0x68(%rsp)
movsd %xmm2, 0xa8(%rsp)
movsd %xmm1, 0x18(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0xb0(%rsp)
leaq 0xe2b0(%rip), %rcx      # 0x10da8
movq (%rcx,%rax,8), %rax
movq %rax, 0x90(%rsp)
movl %ebp, %eax
movq %rax, 0x48(%rsp)
leaq (,%rax,8), %r12
movl $0x1, %edi
movq %r12, %rsi
callq 0x1160
movq %rax, 0x80(%rsp)
movl $0x1, %edi
movq %r12, %rsi
callq 0x1160
movq %rax, 0x28(%rsp)
movl $0x1, %edi
movq %r12, %rsi
callq 0x1160
movq %rax, 0x70(%rsp)
movl $0x1, %edi
movq %r12, %rsi
callq 0x1160
movq %rax, 0x40(%rsp)
movl $0x1, %edi
movq %r12, 0x88(%rsp)
movq %r12, %rsi
callq 0x1160
cmpq $0x0, 0x80(%rsp)
sete %dl
cmpq $0x0, 0x28(%rsp)
sete %cl
orb %dl, %cl
cmpq $0x0, 0x70(%rsp)
sete %sil
cmpq $0x0, 0x40(%rsp)
sete %dl
orb %sil, %dl
orb %cl, %dl
movq %rax, 0x98(%rsp)
testq %rax, %rax
sete %al
orb %dl, %al
movl $0xfffffc02, %r12d      # imm = 0xFFFFFC02
je 0x2bce
xorl %r15d, %r15d
movq $0x0, 0x30(%rsp)
xorl %r13d, %r13d
jmp 0x355b
xorpd %xmm0, %xmm0
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x2be0
jnp 0x2bfe
movl $0x1, %edi
movq 0x88(%rsp), %rsi
callq 0x1160
movq %rax, 0x8(%rsp)
testq %rax, %rax
jne 0x2c07
jmp 0x2bba
movq $0x0, 0x8(%rsp)
movslq 0x38(%rsp), %rsi
shlq $0x5, %rsi
movl $0x1, %edi
callq 0x1160
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x2cea
cmpl $0x0, 0x38(%rsp)
jle 0x2cce
movl 0x38(%rsp), %eax
shlq $0x5, %rax
movq %rax, 0x78(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x10(%rsp)
movq 0x20(%rsp), %rdx
xorl %eax, %eax
movq %rax, (%rdx,%rcx)
movq $0x0, 0x30(%rsp)
movq %rax, 0x18(%rdx,%rcx)
movl $0x1, %edi
movq 0x88(%rsp), %rsi
callq 0x1160
movq %rax, %rdx
movq %rax, 0x58(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rdx, 0x8(%rcx,%rax)
movl $0x1, %edi
movq 0x88(%rsp), %rsi
callq 0x1160
movq 0x10(%rsp), %rcx
movq 0x20(%rsp), %rdx
movq %rax, 0x10(%rdx,%rcx)
cmpq $0x0, 0x58(%rsp)
je 0x3551
testq %rax, %rax
je 0x3551
addq $0x20, %rcx
cmpq %rcx, 0x78(%rsp)
jne 0x2c42
testl %ebx, %ebx
je 0x2d00
shlq $0x3, %rbx
movl $0x1, %edi
movq %rbx, %rsi
callq 0x1160
movq %rax, 0x30(%rsp)
jmp 0x2d09
movq $0x0, 0x30(%rsp)
xorl %r13d, %r13d
movq 0x8(%rsp), %r15
jmp 0x355b
movq $0x0, 0x30(%rsp)
xorpd %xmm0, %xmm0
movq %r15, %rdi
movq %r14, %rsi
movq 0x28(%rsp), %rdx
movl %ebp, %ecx
callq *%r13
movsd 0x18(%rsp), %xmm1
ucomisd 0xa345(%rip), %xmm1     # 0xd070
movsd %xmm0, 0x60(%rsp)
jne 0x2d35
jnp 0x2da8
movl 0x54(%rsp), %eax
cmpl %eax, 0x68(%rsp)
xorpd %xmm3, %xmm3
jge 0x2d6a
movl 0x54(%rsp), %eax
movapd 0xa351(%rip), %xmm1     # 0xd0a0
movq 0x68(%rsp), %rcx
movsd (%r14,%rcx,8), %xmm2
andpd %xmm1, %xmm2
addsd %xmm2, %xmm3
incq %rcx
cmpq %rcx, %rax
jne 0x2d54
movsd 0x18(%rsp), %xmm1
mulsd %xmm1, %xmm3
addsd %xmm0, %xmm3
movsd %xmm3, 0x10(%rsp)
movsd %xmm3, 0x60(%rsp)
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq 0x28(%rsp), %rdx
movl %ebp, %ecx
movapd %xmm1, %xmm0
movq 0x68(%rsp), %r8
movl 0x54(%rsp), %r9d
callq 0x40a1
jmp 0x2dae
movsd %xmm0, 0x10(%rsp)
cmpq $0x0, 0x30(%rsp)
je 0x2dc5
movq 0x30(%rsp), %rax
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
xorpd %xmm0, %xmm0
movsd 0x18(%rsp), %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
jne 0x2e08
jp 0x2e08
movapd 0xa2cf(%rip), %xmm0     # 0xd0b0
movq 0x28(%rsp), %rcx
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rsi
movsd (%rcx,%rax,8), %xmm1
xorpd %xmm0, %xmm1
movlpd %xmm1, (%rdx,%rax,8)
incq %rax
cmpq %rax, %rsi
jne 0x2df0
jmp 0x2e35
movapd 0xa2a0(%rip), %xmm0     # 0xd0b0
movq 0x40(%rsp), %rcx
movq 0x8(%rsp), %rdx
movq 0x48(%rsp), %rsi
movsd (%rdx,%rax,8), %xmm1
xorpd %xmm0, %xmm1
movlpd %xmm1, (%rcx,%rax,8)
incq %rax
cmpq %rax, %rsi
jne 0x2e1f
xorpd %xmm0, %xmm0
xorl %eax, %eax
movsd (%r14,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rsi
jne 0x2e3b
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2e61
sqrtsd %xmm0, %xmm0
jmp 0x2e66
callq 0x1220
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
ucomisd 0xa1f6(%rip), %xmm0     # 0xd070
jne 0x2ea5
jp 0x2ea5
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq 0x28(%rsp), %rcx
movq 0x48(%rsp), %rdx
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rdx
jne 0x2e8e
jmp 0x2eca
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq 0x8(%rsp), %rcx
movq 0x48(%rsp), %rdx
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rdx
jne 0x2eb5
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2eda
sqrtsd %xmm0, %xmm0
jmp 0x2edf
callq 0x1220
movsd 0xa181(%rip), %xmm1     # 0xd068
maxsd 0x10(%rsp), %xmm1
divsd %xmm1, %xmm0
movl $0x2, %r12d
movsd 0xa8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jae 0x3551
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rdx
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rdx
jne 0x2f1a
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2f3f
sqrtsd %xmm0, %xmm0
jmp 0x2f44
callq 0x1220
movsd 0xa11c(%rip), %xmm1     # 0xd068
divsd %xmm0, %xmm1
movq 0x38(%rsp), %r8
leal -0x1(%r8), %eax
movl %eax, 0x68(%rsp)
movq $0x0, 0x10(%rsp)
movl $0x1, 0x58(%rsp)
movq %r8, 0x38(%rsp)
movq 0x28(%rsp), %r13
movl 0x58(%rsp), %r15d
cmpl %r15d, %r8d
cmovll %r8d, %r15d
movsd %xmm1, 0xa0(%rsp)
movq 0x80(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq 0x88(%rsp), %rbx
movq %rbx, %rdx
callq 0x11a0
movq 0x70(%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x11a0
movsd 0x18(%rsp), %xmm0
ucomisd 0xa0a7(%rip), %xmm0     # 0xd070
jne 0x301d
jp 0x301d
subq $0x8, %rsp
movl %ebp, %edi
movq %r14, %rsi
leaq 0x68(%rsp), %rdx
movq %r13, %rcx
movq 0x48(%rsp), %r8
leaq 0xa8(%rsp), %r9
leaq 0xe0(%rsp), %rax
pushq %rax
leaq 0xc8(%rsp), %rax
pushq %rax
pushq 0xb0(%rsp)
pushq 0x90(%rsp)
pushq %r12
callq *0xc0(%rsp)
addq $0x30, %rsp
movl %eax, %r12d
jmp 0x3093
subq $0x8, %rsp
movl %ebp, %edi
movq %r14, %rsi
leaq 0x68(%rsp), %rdx
movq %r13, %rcx
movq 0x48(%rsp), %r8
leaq 0xa8(%rsp), %r9
leaq 0xe0(%rsp), %rax
pushq %rax
leaq 0xc8(%rsp), %rax
pushq %rax
pushq 0xb0(%rsp)
movq 0x28(%rsp), %rbx
pushq %rbx
pushq %r12
callq *0xc0(%rsp)
addq $0x30, %rsp
movl %eax, %r12d
movsd 0x138(%rsp), %xmm0
movl 0x140(%rsp), %r8d
movl 0x144(%rsp), %r9d
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
movl %ebp, %ecx
callq 0x40a1
testl %r12d, %r12d
js 0x350a
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq 0x48(%rsp), %rcx
movsd (%r14,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rcx
jne 0x30a7
ucomisd 0x9fab(%rip), %xmm0     # 0xd070
jb 0x30cd
sqrtsd %xmm0, %xmm0
jmp 0x30d2
callq 0x1220
movsd %xmm0, 0x18(%rsp)
movsd 0x138(%rsp), %xmm0
ucomisd 0x9f87(%rip), %xmm0     # 0xd070
jne 0x3114
jp 0x3114
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq 0x28(%rsp), %rcx
movq 0x48(%rsp), %rdx
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rdx
jne 0x30fd
jmp 0x3139
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq 0x8(%rsp), %rcx
movq 0x48(%rsp), %rdx
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq %rax, %rdx
jne 0x3124
ucomisd 0x9f2f(%rip), %xmm0     # 0xd070
jb 0x3149
sqrtsd %xmm0, %xmm0
jmp 0x314e
callq 0x1220
movsd %xmm0, 0x78(%rsp)
movq 0xd0(%rsp), %rax
testq %rax, %rax
je 0x31a5
movq 0xc0(%rsp), %rdi
movsd 0x60(%rsp), %xmm0
movsd 0xa0(%rsp), %xmm3
movl 0xb8(%rsp), %ecx
movq %r14, %rsi
movq 0x28(%rsp), %rdx
movsd 0x18(%rsp), %xmm1
movsd 0x78(%rsp), %xmm2
movl 0x58(%rsp), %r8d
movl %r12d, %r9d
callq *%rax
testl %eax, %eax
jne 0x3546
movsd 0x9ebb(%rip), %xmm0     # 0xd068
maxsd 0x18(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd 0xe0(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jae 0x3539
cmpq $0x0, 0x30(%rsp)
je 0x3221
movl 0xe8(%rsp), %ecx
movl 0x58(%rsp), %esi
movl %esi, %eax
cltd
idivl %ecx
movsd 0x60(%rsp), %xmm0
cmpl %esi, %ecx
jg 0x3217
movq 0x30(%rsp), %rax
movsd (%rax,%rdx,8), %xmm1
subsd %xmm0, %xmm1
divsd %xmm0, %xmm1
movsd 0xf0(%rsp), %xmm2
ucomisd %xmm1, %xmm2
ja 0x354b
movq 0x30(%rsp), %rax
movsd %xmm0, (%rax,%rdx,8)
movl 0xf8(%rsp), %eax
testl %eax, %eax
sete %cl
cmpl 0x58(%rsp), %eax
setg %al
orb %cl, %al
cmpb $0x1, %al
jne 0x353e
movslq 0x10(%rsp), %rcx
shlq $0x5, %rcx
movq 0x20(%rsp), %rdx
leaq (%rdx,%rcx), %rax
movq 0x8(%rdx,%rcx), %rdx
xorl %ecx, %ecx
movq 0x80(%rsp), %rsi
movq 0x48(%rsp), %r11
movsd (%r14,%rcx,8), %xmm0
subsd (%rsi,%rcx,8), %xmm0
movsd %xmm0, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %r11
jne 0x3264
movq 0x10(%rax), %rcx
xorl %esi, %esi
movq 0x28(%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, %r11
jne 0x328c
xorpd %xmm0, %xmm0
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm1
mulsd (%rdx,%rsi,8), %xmm1
addsd %xmm1, %xmm0
incq %rsi
cmpq %rsi, %r11
jne 0x32aa
xorpd %xmm1, %xmm1
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm1
incq %rdx
cmpq %rdx, %r11
jne 0x32c6
movsd %xmm0, 0x18(%rax)
movq 0x10(%rsp), %rax
incl %eax
cltd
idivl 0x38(%rsp)
movsd 0x138(%rsp), %xmm2
movsd %xmm2, 0x18(%rsp)
ucomisd 0x9d6d(%rip), %xmm2     # 0xd070
movq %rdx, 0x10(%rsp)
jne 0x3339
jp 0x3339
xorl %eax, %eax
movq 0x28(%rsp), %rcx
movq 0x40(%rsp), %r9
movapd 0x9d90(%rip), %xmm4     # 0xd0b0
movsd (%rcx,%rax,8), %xmm2
xorpd %xmm4, %xmm2
movlpd %xmm2, (%r9,%rax,8)
incq %rax
cmpq %rax, %r11
jne 0x3320
jmp 0x3364
xorl %eax, %eax
movq 0x40(%rsp), %r9
movq 0x8(%rsp), %rcx
movapd 0x9d63(%rip), %xmm4     # 0xd0b0
movsd (%rcx,%rax,8), %xmm2
xorpd %xmm4, %xmm2
movlpd %xmm2, (%r9,%rax,8)
incq %rax
cmpq %rax, %r11
jne 0x334d
movq 0x10(%rsp), %rax
movl %eax, %edx
movq 0x38(%rsp), %r8
testl %r8d, %r8d
movq 0x20(%rsp), %r10
movl 0x68(%rsp), %ebx
jle 0x33f7
xorl %ecx, %ecx
movq 0x10(%rsp), %rax
movl %eax, %edx
addl %ebx, %edx
movl %edx, %eax
cltd
idivl %r8d
movslq %edx, %rsi
shlq $0x5, %rsi
leaq (%r10,%rsi), %rax
movq 0x8(%r10,%rsi), %rsi
xorpd %xmm2, %xmm2
xorl %edi, %edi
movsd (%rsi,%rdi,8), %xmm3
mulsd (%r9,%rdi,8), %xmm3
addsd %xmm3, %xmm2
movsd %xmm2, (%rax)
incq %rdi
cmpq %rdi, %r11
jne 0x33a5
divsd 0x18(%rax), %xmm2
movsd %xmm2, (%rax)
movq 0x10(%rax), %rax
xorpd %xmm4, %xmm2
xorl %esi, %esi
movsd (%rax,%rsi,8), %xmm3
mulsd %xmm2, %xmm3
addsd (%r9,%rsi,8), %xmm3
movsd %xmm3, (%r9,%rsi,8)
incq %rsi
cmpq %rsi, %r11
jne 0x33d3
incl %ecx
cmpl %r15d, %ecx
jne 0x3387
incl 0x58(%rsp)
divsd %xmm1, %xmm0
xorl %eax, %eax
movsd (%r9,%rax,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%r9,%rax,8)
incq %rax
cmpq %rax, %r11
jne 0x3401
testl %r8d, %r8d
jle 0x348c
xorl %ecx, %ecx
movslq %edx, %rsi
shlq $0x5, %rsi
leaq (%r10,%rsi), %rax
movq 0x10(%r10,%rsi), %rsi
xorpd %xmm0, %xmm0
xorl %edi, %edi
movsd (%rsi,%rdi,8), %xmm1
mulsd (%r9,%rdi,8), %xmm1
addsd %xmm1, %xmm0
incq %rdi
cmpq %rdi, %r11
jne 0x3436
divsd 0x18(%rax), %xmm0
movq 0x8(%rax), %rsi
movsd (%rax), %xmm1
subsd %xmm0, %xmm1
xorl %eax, %eax
movsd (%rsi,%rax,8), %xmm0
mulsd %xmm1, %xmm0
addsd (%r9,%rax,8), %xmm0
movsd %xmm0, (%r9,%rax,8)
incq %rax
cmpq %rax, %r11
jne 0x3460
incl %edx
movl %edx, %eax
cltd
idivl %r8d
incl %ecx
cmpl %r15d, %ecx
jne 0x3420
movsd 0x18(%rsp), %xmm0
ucomisd 0x9bd6(%rip), %xmm0     # 0xd070
movsd 0x9bc6(%rip), %xmm1     # 0xd068
jne 0x34aa
jnp 0x2f78
movslq 0x140(%rsp), %rax
movslq 0x144(%rsp), %rcx
movsd 0x9ba6(%rip), %xmm1     # 0xd068
cmpl %ecx, %eax
jge 0x2f78
movq 0x40(%rsp), %rdx
movq 0x8(%rsp), %rsi
xorpd %xmm1, %xmm1
movsd (%rdx,%rax,8), %xmm0
mulsd (%rsi,%rax,8), %xmm0
ucomisd %xmm1, %xmm0
jb 0x34f0
movq $0x0, (%rdx,%rax,8)
incq %rax
cmpq %rax, %rcx
jne 0x34d8
movsd 0x9b68(%rip), %xmm1     # 0xd068
movq 0x38(%rsp), %r8
jmp 0x2f78
movq %r14, %rdi
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rbx
movq %rbx, %rdx
callq 0x11a0
movq 0x28(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq %rbx, %rdx
callq 0x11a0
jmp 0x3551
xorl %r12d, %r12d
jmp 0x3551
movl $0xfffffc1b, %r12d      # imm = 0xFFFFFC1B
jmp 0x3551
movl %eax, %r12d
jmp 0x3551
movl $0x1, %r12d
movq 0x8(%rsp), %r15
movq 0x20(%rsp), %r13
movq 0xb0(%rsp), %rax
testq %rax, %rax
je 0x3572
movsd 0x60(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x30(%rsp), %rdi
callq 0x1050
testq %r13, %r13
je 0x35b8
movq 0x38(%rsp), %rax
testl %eax, %eax
jle 0x35b0
movl %eax, %ebx
shlq $0x5, %rbx
xorl %r14d, %r14d
movq 0x8(%r13,%r14), %rdi
callq 0x1050
movq 0x10(%r13,%r14), %rdi
callq 0x1050
addq $0x20, %r14
cmpq %r14, %rbx
jne 0x3593
movq %r13, %rdi
callq 0x1050
movq %r15, %rdi
callq 0x1050
movq 0x98(%rsp), %rdi
callq 0x1050
movq 0x40(%rsp), %rdi
callq 0x1050
movq 0x70(%rsp), %rdi
callq 0x1050
movq 0x28(%rsp), %rdi
callq 0x1050
movq 0x80(%rsp), %rdi
callq 0x1050
jmp 0x2a60