// File: /workspace/github_c_makefile_star2_O0/debbiemarkslab[P]plmc/src/lib/lbfgs.c
// Function: line_search_backtracking_owlqn
static int line_search_backtracking_owlqn(
    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 *wp,
    callback_data_t *cd,
    const lbfgs_parameter_t *param
    )
{
    int i, count = 0;
    lbfgsfloatval_t width = 0.5, norm = 0.;
    lbfgsfloatval_t finit = *f, dgtest;

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

    /* Choose the orthant for the new point. */
    for (i = 0;i < n;++i) {
        wp[i] = (xp[i] == 0.) ? -gp[i] : xp[i];
    }

    for (;;) {
        /* Update the current point. */
        veccpy(x, xp, n);
        vecadd(x, s, *stp, n);

        /* The current point is projected onto the orthant. */
        owlqn_project(x, wp, param->orthantwise_start, param->orthantwise_end);

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

        /* Compute the L1 norm of the variables and add it to the object value. */
        norm = owlqn_x1norm(x, param->orthantwise_start, param->orthantwise_end);
        *f += norm * param->orthantwise_c;

        ++count;

        dgtest = 0.;
        for (i = 0;i < n;++i) {
            dgtest += (x[i] - xp[i]) * gp[i];
        }

        if (*f <= finit + param->ftol * dgtest) {
            /* The sufficient decrease condition. */
            return count;
        }

        if (*stp < param->min_step) {
            /* The step is the minimum value. */
            return LBFGSERR_MINIMUMSTEP;
        }
        if (*stp > param->max_step) {
            /* The step is the maximum value. */
            return LBFGSERR_MAXIMUMSTEP;
        }
        if (param->max_linesearch <= count) {
            /* Maximum number of iteration. */
            return LBFGSERR_MAXIMUMLINESEARCH;
        }

        (*stp) *= width;
    }
}

// Assembly:
subq $0x68, %rsp
movq 0x90(%rsp), %rax
movq 0x88(%rsp), %rax
movq 0x80(%rsp), %rax
movq 0x78(%rsp), %rax
movq 0x70(%rsp), %rax
movl %edi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x38(%rsp)
movl $0x0, 0x30(%rsp)
movsd 0x158f5(%rip), %xmm0    # 0x19018
movsd %xmm0, 0x28(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x50(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x38(%rsp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jb 0x375c
movl $0xfffffc1d, 0x64(%rsp) # imm = 0xFFFFFC1D
jmp 0x3a08
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x60(%rsp), %eax
jge 0x37f7
movq 0x70(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x37ba
jp 0x37ba
movq 0x78(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x8(%rsp)
jmp 0x37cf
movq 0x70(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x8(%rsp), %xmm0
movq 0x80(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x3764
jmp 0x37f9
movq 0x58(%rsp), %rdi
movq 0x70(%rsp), %rsi
movl 0x60(%rsp), %edx
callq 0x40a0
movq 0x58(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x38(%rsp), %rax
movsd (%rax), %xmm0
movl 0x60(%rsp), %edx
callq 0x41d0
movq 0x58(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq 0x90(%rsp), %rax
movl 0x68(%rax), %edx
movq 0x90(%rsp), %rax
movl 0x6c(%rax), %ecx
callq 0x4290
movq 0x88(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x88(%rsp), %rcx
movq 0x8(%rcx), %rdi
movq 0x58(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x88(%rsp), %rcx
movl (%rcx), %ecx
movq 0x38(%rsp), %r8
movsd (%r8), %xmm0
callq *%rax
movq 0x50(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x58(%rsp), %rdi
movq 0x90(%rsp), %rax
movl 0x68(%rax), %esi
movq 0x90(%rsp), %rax
movl 0x6c(%rax), %edx
callq 0x3d20
movsd %xmm0, 0x20(%rsp)
movsd 0x20(%rsp), %xmm0
movq 0x90(%rsp), %rax
movsd 0x60(%rax), %xmm2
movq 0x50(%rsp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x60(%rsp), %eax
jge 0x3953
movq 0x58(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x70(%rsp), %rax
movslq 0x34(%rsp), %rcx
subsd (%rax,%rcx,8), %xmm0
movq 0x78(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x10(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x38fb
movq 0x50(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x18(%rsp), %xmm2
movq 0x90(%rsp), %rax
movsd 0x40(%rax), %xmm0
movsd 0x10(%rsp), %xmm3
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x398d
movl 0x30(%rsp), %eax
movl %eax, 0x64(%rsp)
jmp 0x3a08
movq 0x38(%rsp), %rax
movsd (%rax), %xmm1
movq 0x90(%rsp), %rax
movsd 0x30(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x39b3
movl $0xfffffc18, 0x64(%rsp) # imm = 0xFFFFFC18
jmp 0x3a08
movq 0x38(%rsp), %rax
movsd (%rax), %xmm0
movq 0x90(%rsp), %rax
ucomisd 0x38(%rax), %xmm0
jbe 0x39d5
movl $0xfffffc19, 0x64(%rsp) # imm = 0xFFFFFC19
jmp 0x3a08
movq 0x90(%rsp), %rax
movl 0x28(%rax), %eax
cmpl 0x30(%rsp), %eax
jg 0x39f0
movl $0xfffffc1a, 0x64(%rsp) # imm = 0xFFFFFC1A
jmp 0x3a08
movsd 0x28(%rsp), %xmm0
movq 0x38(%rsp), %rax
mulsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x37f9
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)