// File: /workspace/github_c_makefile_star2_O0/debbiemarkslab[P]plmc/src/lib/lbfgs.c
// Function: line_search_morethuente
static int line_search_morethuente(
    int n,
    lbfgsfloatval_t *x,
    lbfgsfloatval_t *f,
    lbfgsfloatval_t *g,
    lbfgsfloatval_t *s,
    lbfgsfloatval_t *stp,
    const lbfgsfloatval_t* xp,
    const lbfgsfloatval_t* gp,
    lbfgsfloatval_t *wa,
    callback_data_t *cd,
    const lbfgs_parameter_t *param
    )
{
    int count = 0;
    int brackt, stage1, uinfo = 0;
    lbfgsfloatval_t dg;
    lbfgsfloatval_t stx, fx, dgx;
    lbfgsfloatval_t sty, fy, dgy;
    lbfgsfloatval_t fxm, dgxm, fym, dgym, fm, dgm;
    lbfgsfloatval_t finit, ftest1, dginit, dgtest;
    lbfgsfloatval_t width, prev_width;
    lbfgsfloatval_t stmin, stmax;

    /* Check the input parameters for errors. */
    if (*stp <= 0.) {
        return LBFGSERR_INVALIDPARAMETERS;
    }

    /* Compute the initial gradient in the search direction. */
    vecdot(&dginit, g, s, n);

    /* Make sure that s points to a descent direction. */
    if (0 < dginit) {
        return LBFGSERR_INCREASEGRADIENT;
    }

    /* Initialize local variables. */
    brackt = 0;
    stage1 = 1;
    finit = *f;
    dgtest = param->ftol * dginit;
    width = param->max_step - param->min_step;
    prev_width = 2.0 * width;

    /*
        The variables stx, fx, dgx contain the values of the step,
        function, and directional derivative at the best step.
        The variables sty, fy, dgy contain the value of the step,
        function, and derivative at the other endpoint of
        the interval of uncertainty.
        The variables stp, f, dg contain the values of the step,
        function, and derivative at the current step.
    */
    stx = sty = 0.;
    fx = fy = finit;
    dgx = dgy = dginit;

    for (;;) {
        /*
            Set the minimum and maximum steps to correspond to the
            present interval of uncertainty.
         */
        if (brackt) {
            stmin = min2(stx, sty);
            stmax = max2(stx, sty);
        } else {
            stmin = stx;
            stmax = *stp + 4.0 * (*stp - stx);
        }

        /* Clip the step in the range of [stpmin, stpmax]. */
        if (*stp < param->min_step) *stp = param->min_step;
        if (param->max_step < *stp) *stp = param->max_step;

        /*
            If an unusual termination is to occur then let
            stp be the lowest point obtained so far.
         */
        if ((brackt && ((*stp <= stmin || stmax <= *stp) || param->max_linesearch <= count + 1 || uinfo != 0)) || (brackt && (stmax - stmin <= param->xtol * stmax))) {
            *stp = stx;
        }

        /*
            Compute the current value of x:
                x <- x + (*stp) * s.
         */
        veccpy(x, xp, n);
        vecadd(x, s, *stp, n);

        /* Evaluate the function and gradient values. */
        *f = cd->proc_evaluate(cd->instance, x, g, cd->n, *stp);
        vecdot(&dg, g, s, n);

        ftest1 = finit + *stp * dgtest;
        ++count;

        /* Test for errors and convergence. */
        if (brackt && ((*stp <= stmin || stmax <= *stp) || uinfo != 0)) {
            /* Rounding errors prevent further progress. */
            return LBFGSERR_ROUNDING_ERROR;
        }
        if (*stp == param->max_step && *f <= ftest1 && dg <= dgtest) {
            /* The step is the maximum value. */
            return LBFGSERR_MAXIMUMSTEP;
        }
        if (*stp == param->min_step && (ftest1 < *f || dgtest <= dg)) {
            /* The step is the minimum value. */
            return LBFGSERR_MINIMUMSTEP;
        }
        if (brackt && (stmax - stmin) <= param->xtol * stmax) {
            /* Relative width of the interval of uncertainty is at most xtol. */
            return LBFGSERR_WIDTHTOOSMALL;
        }
        if (param->max_linesearch <= count) {
            /* Maximum number of iteration. */
            return LBFGSERR_MAXIMUMLINESEARCH;
        }
        if (*f <= ftest1 && fabs(dg) <= param->gtol * (-dginit)) {
            /* The sufficient decrease condition and the directional derivative condition hold. */
            return count;
        }

        /*
            In the first stage we seek a step for which the modified
            function has a nonpositive value and nonnegative derivative.
         */
        if (stage1 && *f <= ftest1 && min2(param->ftol, param->gtol) * dginit <= dg) {
            stage1 = 0;
        }

        /*
            A modified function is used to predict the step only if
            we have not obtained a step for which the modified
            function has a nonpositive function value and nonnegative
            derivative, and if a lower function value has been
            obtained but the decrease is not sufficient.
         */
        if (stage1 && ftest1 < *f && *f <= fx) {
            /* Define the modified function and derivative values. */
            fm = *f - *stp * dgtest;
            fxm = fx - stx * dgtest;
            fym = fy - sty * dgtest;
            dgm = dg - dgtest;
            dgxm = dgx - dgtest;
            dgym = dgy - dgtest;

            /*
                Call update_trial_interval() to update the interval of
                uncertainty and to compute the new step.
             */
            uinfo = update_trial_interval(
                &stx, &fxm, &dgxm,
                &sty, &fym, &dgym,
                stp, &fm, &dgm,
                stmin, stmax, &brackt
                );

            /* Reset the function and gradient values for f. */
            fx = fxm + stx * dgtest;
            fy = fym + sty * dgtest;
            dgx = dgxm + dgtest;
            dgy = dgym + dgtest;
        } else {
            /*
                Call update_trial_interval() to update the interval of
                uncertainty and to compute the new step.
             */
            uinfo = update_trial_interval(
                &stx, &fx, &dgx,
                &sty, &fy, &dgy,
                stp, f, &dg,
                stmin, stmax, &brackt
                );
        }

        /*
            Force a sufficient decrease in the interval of uncertainty.
         */
        if (brackt) {
            if (0.66 * prev_width <= fabs(sty - stx)) {
                *stp = stx + 0.5 * (sty - stx);
            }
            prev_width = width;
            width = fabs(sty - stx);
        }
    }

    return LBFGSERR_LOGICERROR;
}

// Assembly:
pushq %rbx
subq $0x120, %rsp            # imm = 0x120
movq 0x150(%rsp), %rax
movq 0x148(%rsp), %rax
movq 0x140(%rsp), %rax
movq 0x138(%rsp), %rax
movq 0x130(%rsp), %rax
movl %edi, 0x118(%rsp)
movq %rsi, 0x110(%rsp)
movq %rdx, 0x108(%rsp)
movq %rcx, 0x100(%rsp)
movq %r8, 0xf8(%rsp)
movq %r9, 0xf0(%rsp)
movl $0x0, 0xec(%rsp)
movl $0x0, 0xe0(%rsp)
movq 0xf0(%rsp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jb 0x2cf6
movl $0xfffffc1d, 0x11c(%rsp) # imm = 0xFFFFFC1D
jmp 0x36b1
movq 0x100(%rsp), %rsi
movq 0xf8(%rsp), %rdx
movl 0x118(%rsp), %ecx
leaq 0x60(%rsp), %rdi
callq 0x4150
movsd 0x60(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2d36
movl $0xfffffc1e, 0x11c(%rsp) # imm = 0xFFFFFC1E
jmp 0x36b1
movl $0x0, 0xe8(%rsp)
movl $0x1, 0xe4(%rsp)
movq 0x108(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x70(%rsp)
movq 0x150(%rsp), %rax
movsd 0x40(%rax), %xmm0
mulsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x150(%rsp), %rax
movsd 0x38(%rax), %xmm0
movq 0x150(%rsp), %rax
subsd 0x30(%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x162b9(%rip), %xmm0    # 0x19058
mulsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0xb8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0xd0(%rsp)
movsd 0x70(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
movsd %xmm0, 0xc8(%rsp)
movsd 0x60(%rsp), %xmm0
movsd %xmm0, 0xa8(%rsp)
movsd %xmm0, 0xc0(%rsp)
cmpl $0x0, 0xe8(%rsp)
je 0x2e87
movsd 0xd0(%rsp), %xmm1
movsd 0xb8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x2e2a
movsd 0xd0(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0x2e39
movsd 0xb8(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0xd0(%rsp), %xmm0
ucomisd 0xb8(%rsp), %xmm0
jb 0x2e6a
movsd 0xd0(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
jmp 0x2e79
movsd 0xb8(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0x2ecd
movsd 0xd0(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm1
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm0
subsd 0xd0(%rsp), %xmm0
movsd 0x161a1(%rip), %xmm2    # 0x19060
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm1
movq 0x150(%rsp), %rax
movsd 0x30(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x2f05
movq 0x150(%rsp), %rax
movsd 0x30(%rax), %xmm0
movq 0xf0(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x150(%rsp), %rax
movsd 0x38(%rax), %xmm1
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x2f3d
movq 0x150(%rsp), %rax
movsd 0x38(%rax), %xmm0
movq 0xf0(%rsp), %rax
movsd %xmm0, (%rax)
cmpl $0x0, 0xe8(%rsp)
je 0x2f9a
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x40(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jae 0x2fc9
movsd 0x38(%rsp), %xmm1
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jae 0x2fc9
movq 0x150(%rsp), %rax
movl 0x28(%rax), %eax
movl 0xec(%rsp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x2fc9
cmpl $0x0, 0xe0(%rsp)
jne 0x2fc9
cmpl $0x0, 0xe8(%rsp)
je 0x2fde
movsd 0x38(%rsp), %xmm1
subsd 0x40(%rsp), %xmm1
movq 0x150(%rsp), %rax
movsd 0x58(%rax), %xmm0
mulsd 0x38(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x2fde
movsd 0xd0(%rsp), %xmm0
movq 0xf0(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x110(%rsp), %rdi
movq 0x130(%rsp), %rsi
movl 0x118(%rsp), %edx
callq 0x40a0
movq 0x110(%rsp), %rdi
movq 0xf8(%rsp), %rsi
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm0
movl 0x118(%rsp), %edx
callq 0x41d0
movq 0x148(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x148(%rsp), %rcx
movq 0x8(%rcx), %rdi
movq 0x110(%rsp), %rsi
movq 0x100(%rsp), %rdx
movq 0x148(%rsp), %rcx
movl (%rcx), %ecx
movq 0xf0(%rsp), %r8
movsd (%r8), %xmm0
callq *%rax
movq 0x108(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x100(%rsp), %rsi
movq 0xf8(%rsp), %rdx
movl 0x118(%rsp), %ecx
leaq 0xd8(%rsp), %rdi
callq 0x4150
movsd 0x70(%rsp), %xmm1
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x58(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
cmpl $0x0, 0xe8(%rsp)
je 0x311e
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x40(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jae 0x310e
movsd 0x38(%rsp), %xmm1
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jae 0x310e
cmpl $0x0, 0xe0(%rsp)
je 0x311e
movl $0xfffffc17, 0x11c(%rsp) # imm = 0xFFFFFC17
jmp 0x36b1
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm0
movq 0x150(%rsp), %rax
ucomisd 0x38(%rax), %xmm0
jne 0x3178
jp 0x3178
movq 0x108(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x68(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x3178
movsd 0xd8(%rsp), %xmm1
movsd 0x58(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x3178
movl $0xfffffc19, 0x11c(%rsp) # imm = 0xFFFFFC19
jmp 0x36b1
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm0
movq 0x150(%rsp), %rax
ucomisd 0x30(%rax), %xmm0
jne 0x31d2
jp 0x31d2
movsd 0x68(%rsp), %xmm1
movq 0x108(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
ja 0x31c2
movsd 0x58(%rsp), %xmm1
movsd 0xd8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x31d2
movl $0xfffffc18, 0x11c(%rsp) # imm = 0xFFFFFC18
jmp 0x36b1
cmpl $0x0, 0xe8(%rsp)
je 0x3211
movsd 0x38(%rsp), %xmm1
subsd 0x40(%rsp), %xmm1
movq 0x150(%rsp), %rax
movsd 0x58(%rax), %xmm0
mulsd 0x38(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x3211
movl $0xfffffc1c, 0x11c(%rsp) # imm = 0xFFFFFC1C
jmp 0x36b1
movq 0x150(%rsp), %rax
movl 0x28(%rax), %eax
cmpl 0xec(%rsp), %eax
jg 0x3235
movl $0xfffffc1a, 0x11c(%rsp) # imm = 0xFFFFFC1A
jmp 0x36b1
movq 0x108(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x68(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x32a8
movsd 0xd8(%rsp), %xmm1
movaps 0x15e23(%rip), %xmm0    # 0x19080
pand %xmm0, %xmm1
movq 0x150(%rsp), %rax
movsd 0x50(%rax), %xmm0
movsd 0x60(%rsp), %xmm2
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x32a8
movl 0xec(%rsp), %eax
movl %eax, 0x11c(%rsp)
jmp 0x36b1
cmpl $0x0, 0xe4(%rsp)
je 0x333c
movq 0x108(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x68(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x333c
movq 0x150(%rsp), %rax
movsd 0x40(%rax), %xmm1
movq 0x150(%rsp), %rax
movsd 0x50(%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0x3303
movq 0x150(%rsp), %rax
movsd 0x40(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0x3316
movq 0x150(%rsp), %rax
movsd 0x50(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x20(%rsp), %xmm1
mulsd 0x60(%rsp), %xmm1
movsd 0xd8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x333c
movl $0x0, 0xe4(%rsp)
cmpl $0x0, 0xe4(%rsp)
je 0x358c
movsd 0x68(%rsp), %xmm1
movq 0x108(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x358c
movq 0x108(%rsp), %rax
movsd (%rax), %xmm1
movsd 0xc8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x358c
movq 0x108(%rsp), %rax
movsd (%rax), %xmm1
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x58(%rsp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0xc8(%rsp), %xmm1
movsd 0xd0(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xa0(%rsp)
movsd 0xb0(%rsp), %xmm1
movsd 0xb8(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0xd8(%rsp), %xmm0
subsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0xc0(%rsp), %xmm0
subsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x98(%rsp)
movsd 0xa8(%rsp), %xmm0
subsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x88(%rsp)
movq 0xf0(%rsp), %rbx
movsd 0x40(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
leaq 0xd0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x98(%rsp), %rdx
leaq 0xb8(%rsp), %rcx
leaq 0x90(%rsp), %r8
leaq 0x88(%rsp), %r9
leaq 0x80(%rsp), %r11
leaq 0x78(%rsp), %r10
leaq 0xe8(%rsp), %rax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x4300
movl %eax, 0xe0(%rsp)
movsd 0xa0(%rsp), %xmm1
movsd 0xd0(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xc8(%rsp)
movsd 0x90(%rsp), %xmm1
movsd 0xb8(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
movsd 0x98(%rsp), %xmm0
addsd 0x58(%rsp), %xmm0
movsd %xmm0, 0xc0(%rsp)
movsd 0x88(%rsp), %xmm0
addsd 0x58(%rsp), %xmm0
movsd %xmm0, 0xa8(%rsp)
jmp 0x3607
movq 0xf0(%rsp), %rbx
movq 0x108(%rsp), %r11
movsd 0x40(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
leaq 0xd0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
leaq 0xb8(%rsp), %rcx
leaq 0xb0(%rsp), %r8
leaq 0xa8(%rsp), %r9
leaq 0xd8(%rsp), %r10
leaq 0xe8(%rsp), %rax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x4300
movl %eax, 0xe0(%rsp)
cmpl $0x0, 0xe8(%rsp)
je 0x36ac
movsd 0x15a4b(%rip), %xmm1    # 0x19068
mulsd 0x48(%rsp), %xmm1
movsd 0xb8(%rsp), %xmm0
subsd 0xd0(%rsp), %xmm0
movaps 0x15a44(%rip), %xmm2    # 0x19080
pand %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x367d
movsd 0xd0(%rsp), %xmm1
movsd 0xb8(%rsp), %xmm0
subsd 0xd0(%rsp), %xmm0
movsd 0x159af(%rip), %xmm2    # 0x19018
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0xf0(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0xb8(%rsp), %xmm0
subsd 0xd0(%rsp), %xmm0
movaps 0x159de(%rip), %xmm1    # 0x19080
pand %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
jmp 0x2df3
movl 0x11c(%rsp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbx
retq
nopw %cs:(%rax,%rax)