// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movl $0xfffffc1d, %eax       # imm = 0xFFFFFC1D
xorpd %xmm0, %xmm0
ucomisd (%r9), %xmm0
jae 0x2a6b
movq %rsi, %r13
movq 0x90(%rsp), %rbp
movq 0x88(%rsp), %rbx
movq 0x80(%rsp), %r14
movsd (%rdx), %xmm1
movsd %xmm1, 0x28(%rsp)
xorl %eax, %eax
testl %edi, %edi
movl $0x0, %r12d
cmovgl %edi, %r12d
movapd 0x97c2(%rip), %xmm1     # 0xc0a0
cmpq %rax, %r12
je 0x2905
movsd (%r14,%rax,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x28fa
jp 0x28fa
movsd (%rbx,%rax,8), %xmm2
xorpd %xmm1, %xmm2
movsd %xmm2, (%rbp,%rax,8)
incq %rax
jmp 0x28de
movl %edi, 0x14(%rsp)
movq %rdx, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq %r9, 0x8(%rsp)
movq %r13, %rdi
movq %r14, %rsi
movl 0x14(%rsp), %r15d
movl %r15d, %edx
callq 0x2d92
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
movq %r13, %rdi
movq 0x38(%rsp), %rsi
movl %r15d, %edx
callq 0x2dfb
movq 0xa0(%rsp), %rcx
movslq 0x68(%rcx), %rax
movslq 0x6c(%rcx), %rcx
movq 0x20(%rsp), %r15
xorpd %xmm1, %xmm1
cmpq %rcx, %rax
jge 0x2984
movsd (%r13,%rax,8), %xmm0
mulsd (%rbp,%rax,8), %xmm0
ucomisd %xmm0, %xmm1
jb 0x297f
andq $0x0, (%r13,%rax,8)
incq %rax
jmp 0x2961
movq 0x98(%rsp), %r8
movq 0x8(%r8), %rdi
movl (%r8), %ecx
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
movq %r13, %rsi
movq 0x30(%rsp), %rdx
callq *0x10(%r8)
movsd %xmm0, 0x40(%rsp)
movsd %xmm0, (%r15)
movq 0xa0(%rsp), %r15
movl 0x68(%r15), %esi
movl 0x6c(%r15), %edx
movq %r13, %rdi
callq 0x2c71
mulsd 0x60(%r15), %xmm0
addsd 0x40(%rsp), %xmm0
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
xorpd %xmm1, %xmm1
xorl %edx, %edx
movq 0x18(%rsp), %rax
cmpq %rdx, %r12
je 0x2a0b
movsd (%r13,%rdx,8), %xmm2
subsd (%r14,%rdx,8), %xmm2
mulsd (%rbx,%rdx,8), %xmm2
addsd %xmm2, %xmm1
incq %rdx
jmp 0x29eb
mulsd 0x40(%r15), %xmm1
incl %eax
addsd 0x28(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jae 0x2a6b
movq 0x8(%rsp), %rdx
movsd (%rdx), %xmm0
movsd 0x30(%r15), %xmm1
ucomisd %xmm0, %xmm1
ja 0x2a58
ucomisd 0x38(%r15), %xmm0
ja 0x2a5f
cmpl %eax, 0x28(%r15)
jle 0x2a66
movq %rax, 0x18(%rsp)
mulsd 0x9601(%rip), %xmm0     # 0xc050
movsd %xmm0, (%rdx)
jmp 0x291c
movl $0xfffffc18, %eax       # imm = 0xFFFFFC18
jmp 0x2a6b
movl $0xfffffc19, %eax       # imm = 0xFFFFFC19
jmp 0x2a6b
movl $0xfffffc1a, %eax       # imm = 0xFFFFFC1A
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq