// File: /workspace/github_cpp_makefile_star2_O3/redpony[P]libpopt/./lbfgs.h
// Function: scitbx::lbfgs::detail::mcsrch<double, unsigned long>::run(double const&, double const&, double const&, unsigned long, double*, double, double const*, double*, unsigned long, double&, double, double, unsigned long, int&, unsigned long&, double*)
void mcsrch<FloatType, SizeType>::run(
      FloatType const& gtol,
      FloatType const& stpmin,
      FloatType const& stpmax,
      SizeType n,
      FloatType* x,
      FloatType f,
      const FloatType* g,
      FloatType* s,
      SizeType is0,
      FloatType& stp,
      FloatType ftol,
      FloatType xtol,
      SizeType maxfev,
      int& info,
      SizeType& nfev,
      FloatType* wa)
    {
      if (info != -1) {
        infoc = 1;
        if (   n == 0
            || maxfev == 0
            || gtol < FloatType(0)
            || xtol < FloatType(0)
            || stpmin < FloatType(0)
            || stpmax < stpmin) {
          throw error_internal_error(__FILE__, __LINE__);
        }
        if (stp <= FloatType(0) || ftol < FloatType(0)) {
          throw error_internal_error(__FILE__, __LINE__);
        }
        // Compute the initial gradient in the search direction
        // and check that s is a descent direction.
        dginit = FloatType(0);
        for (SizeType j = 0; j < n; j++) {
          dginit += g[j] * s[is0+j];
        }
        if (dginit >= FloatType(0)) {
          throw error_search_direction_not_descent();
        }
        brackt = false;
        stage1 = true;
        nfev = 0;
        finit = f;
        dgtest = ftol*dginit;
        width = stpmax - stpmin;
        width1 = FloatType(2) * width;
        std::copy(x, x+n, wa);
        // 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 = FloatType(0);
        fx = finit;
        dgx = dginit;
        sty = FloatType(0);
        fy = finit;
        dgy = dginit;
      }
      for (;;) {
        if (info != -1) {
          // Set the minimum and maximum steps to correspond
          // to the present interval of uncertainty.
          if (brackt) {
            stmin = std::min(stx, sty);
            stmax = std::max(stx, sty);
          }
          else {
            stmin = stx;
            stmax = stp + FloatType(4) * (stp - stx);
          }
          // Force the step to be within the bounds stpmax and stpmin.
          stp = std::max(stp, stpmin);
          stp = std::min(stp, stpmax);
          // If an unusual termination is to occur then let
          // stp be the lowest point obtained so far.
          if (   (brackt && (stp <= stmin || stp >= stmax))
              || nfev >= maxfev - 1 || infoc == 0
              || (brackt && stmax - stmin <= xtol * stmax)) {
            stp = stx;
          }
          // Evaluate the function and gradient at stp
          // and compute the directional derivative.
          // We return to main program to obtain F and G.
          for (SizeType j = 0; j < n; j++) {
            x[j] = wa[j] + stp * s[is0+j];
          }
          info=-1;
          break;
        }
        info = 0;
        nfev++;
        FloatType dg(0);
        for (SizeType j = 0; j < n; j++) {
          dg += g[j] * s[is0+j];
        }
        FloatType ftest1 = finit + stp*dgtest;
        // Test for convergence.
        if ((brackt && (stp <= stmin || stp >= stmax)) || infoc == 0) {
          throw error_line_search_failed_rounding_errors(
            "Rounding errors prevent further progress."
            " There may not be a step which satisfies the"
            " sufficient decrease and curvature conditions."
            " Tolerances may be too small.");
        }
        if (stp == stpmax && f <= ftest1 && dg <= dgtest) {
          throw error_line_search_failed(
            "The step is at the upper bound stpmax().");
        }
        if (stp == stpmin && (f > ftest1 || dg >= dgtest)) {
          throw error_line_search_failed(
            "The step is at the lower bound stpmin().");
        }
        if (nfev >= maxfev) {
          throw error_line_search_failed(
            "Number of function evaluations has reached maxfev().");
        }
        if (brackt && stmax - stmin <= xtol * stmax) {
          throw error_line_search_failed(
            "Relative width of the interval of uncertainty"
            " is at most xtol().");
        }
        // Check for termination.
        if (f <= ftest1 && abs(dg) <= gtol * (-dginit)) {
          info = 1;
          break;
        }
        // In the first stage we seek a step for which the modified
        // function has a nonpositive value and nonnegative derivative.
        if (   stage1 && f <= ftest1
            && dg >= std::min(ftol, gtol) * dginit) {
          stage1 = false;
        }
        // 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 && f <= fx && f > ftest1) {
          // Define the modified function and derivative values.
          FloatType fm = f - stp*dgtest;
          FloatType fxm = fx - stx*dgtest;
          FloatType fym = fy - sty*dgtest;
          FloatType dgm = dg - dgtest;
          FloatType dgxm = dgx - dgtest;
          FloatType dgym = dgy - dgtest;
          // Call cstep to update the interval of uncertainty
          // and to compute the new step.
          infoc = mcstep(stx, fxm, dgxm, sty, fym, dgym, stp, fm, dgm,
                         brackt, stmin, stmax);
          // Reset the function and gradient values for f.
          fx = fxm + stx*dgtest;
          fy = fym + sty*dgtest;
          dgx = dgxm + dgtest;
          dgy = dgym + dgtest;
        }
        else {
          // Call mcstep to update the interval of uncertainty
          // and to compute the new step.
          infoc = mcstep(stx, fx, dgx, sty, fy, dgy, stp, f, dg,
                         brackt, stmin, stmax);
        }
        // Force a sufficient decrease in the size of the
        // interval of uncertainty.
        if (brackt) {
          if (abs(sty - stx) >= FloatType(0.66) * width1) {
            stp = stx + FloatType(0.5) * (sty - stx);
          }
          width1 = width;
          width = abs(sty - stx);
        }
      }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movsd %xmm2, 0x38(%rsp)
movsd %xmm1, 0x30(%rsp)
movq %r8, %r14
movq %rcx, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdi, %r12
movq 0x108(%rsp), %rdi
movq 0xf8(%rsp), %rsi
movq 0xe8(%rsp), %r10
movq 0xe0(%rsp), %r13
movq 0xd0(%rsp), %rbp
cmpl $-0x1, (%rsi)
movsd %xmm0, 0x58(%rsp)
movq %r9, 0x48(%rsp)
je 0x7080
movl $0x1, (%r12)
testq %r14, %r14
je 0x774b
cmpq $0x0, 0xf0(%rsp)
je 0x774b
xorpd %xmm1, %xmm1
ucomisd 0x38(%rsp), %xmm1
ja 0x774b
movq 0x50(%rsp), %rax
ucomisd (%rax), %xmm1
ja 0x774b
movq 0x20(%rsp), %rax
movsd (%rax), %xmm2
ucomisd %xmm2, %xmm1
ja 0x774b
movq 0x28(%rsp), %rax
ucomisd (%rax), %xmm2
ja 0x774b
ucomisd 0x30(%rsp), %xmm1
ja 0x7766
ucomisd (%r10), %xmm1
jae 0x7766
movq %r9, %r15
movq $0x0, 0x8(%r12)
movq 0xd8(%rsp), %rax
leaq (%rax,%r13,8), %rax
xorpd %xmm2, %xmm2
xorl %ecx, %ecx
movsd (%rbp,%rcx,8), %xmm1
mulsd (%rax,%rcx,8), %xmm1
addsd %xmm1, %xmm2
movsd %xmm2, 0x8(%r12)
incq %rcx
cmpq %rcx, %r14
jne 0x6f9e
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jae 0x779d
movw $0x100, 0x10(%r12)      # imm = 0x100
xorl %ebx, %ebx
movq 0x100(%rsp), %rax
movq %rbx, (%rax)
movsd %xmm0, 0x18(%r12)
mulsd 0x30(%rsp), %xmm2
movsd %xmm2, 0x20(%r12)
movq 0x28(%rsp), %rax
movsd (%rax), %xmm0
movq 0x20(%rsp), %rax
subsd (%rax), %xmm0
movsd %xmm0, 0x28(%r12)
addsd %xmm0, %xmm0
movsd %xmm0, 0x30(%r12)
leaq (,%r14,8), %rdx
movq %r15, %rsi
callq 0x32a0
movsd 0x58(%rsp), %xmm0
movq %rbx, 0x38(%r12)
movsd 0x8(%r12), %xmm2
movsd 0x18(%r12), %xmm1
movsd %xmm1, 0x40(%r12)
movsd %xmm2, 0x48(%r12)
movq %rbx, 0x50(%r12)
movsd %xmm1, 0x58(%r12)
movsd %xmm2, 0x60(%r12)
movq 0xf8(%rsp), %rsi
cmpl $-0x1, (%rsi)
movq 0xe8(%rsp), %r10
je 0x7080
movb 0x10(%r12), %al
jmp 0x744e
movq 0xd8(%rsp), %rax
leaq (%rax,%r13,8), %r13
leaq 0x10(%r12), %r15
leaq 0x40(%r12), %rax
movq %rax, 0x90(%rsp)
leaq 0x38(%r12), %rax
movq %rax, 0x40(%rsp)
leaq 0x48(%r12), %rax
movq %rax, 0x88(%rsp)
leaq 0x50(%r12), %rbx
leaq 0x58(%r12), %rax
movq %rax, 0x80(%rsp)
leaq 0x60(%r12), %rax
movq %rax, 0x78(%rsp)
movl $0x0, (%rsi)
movq 0x100(%rsp), %rcx
movq (%rcx), %rax
incq %rax
movq %rax, (%rcx)
xorpd %xmm1, %xmm1
testq %r14, %r14
je 0x710c
xorl %ecx, %ecx
movsd (%rbp,%rcx,8), %xmm2
mulsd (%r13,%rcx,8), %xmm2
addsd %xmm2, %xmm1
incq %rcx
cmpq %rcx, %r14
jne 0x70f3
movsd (%r10), %xmm2
movsd 0x20(%r12), %xmm4
movapd %xmm2, %xmm5
mulsd %xmm4, %xmm5
movsd 0x18(%r12), %xmm8
addsd %xmm5, %xmm8
movb 0x10(%r12), %cl
testb %cl, %cl
je 0x7153
movsd 0x68(%r12), %xmm3
ucomisd %xmm2, %xmm3
jae 0x7601
ucomisd 0x70(%r12), %xmm2
jae 0x7601
cmpl $0x0, (%r12)
je 0x7601
movq 0x28(%rsp), %rdx
ucomisd (%rdx), %xmm2
jne 0x717c
jp 0x717c
ucomisd %xmm0, %xmm8
jb 0x717c
ucomisd %xmm1, %xmm4
jae 0x75af
movq 0x20(%rsp), %rdx
ucomisd (%rdx), %xmm2
jne 0x719e
jp 0x719e
ucomisd %xmm8, %xmm0
ja 0x76af
ucomisd %xmm4, %xmm1
jae 0x76af
cmpq 0xf0(%rsp), %rax
jae 0x765d
testb %cl, %cl
je 0x71d2
movsd 0x70(%r12), %xmm2
movapd %xmm2, %xmm3
subsd 0x68(%r12), %xmm3
mulsd 0x38(%rsp), %xmm2
ucomisd %xmm3, %xmm2
jae 0x76fe
ucomisd %xmm0, %xmm8
jae 0x71e0
movb 0x11(%r12), %al
jmp 0x723a
movapd %xmm1, %xmm6
movapd 0x1e43(%rip), %xmm9     # 0x9030
xorpd %xmm9, %xmm6
maxsd %xmm1, %xmm6
movq 0x50(%rsp), %rax
movsd (%rax), %xmm2
movsd 0x8(%r12), %xmm3
movapd %xmm3, %xmm7
xorpd %xmm9, %xmm7
mulsd %xmm2, %xmm7
ucomisd %xmm6, %xmm7
jae 0x7596
movb 0x11(%r12), %al
cmpb $0x1, %al
jne 0x723a
minsd 0x30(%rsp), %xmm2
mulsd %xmm2, %xmm3
ucomisd %xmm3, %xmm1
jae 0x7347
testb $0x1, %al
je 0x734d
movsd 0x40(%r12), %xmm6
movsd 0x68(%r12), %xmm2
ucomisd %xmm0, %xmm6
movsd 0x70(%r12), %xmm3
jb 0x735b
ucomisd %xmm8, %xmm0
jbe 0x735b
subsd %xmm5, %xmm0
movsd 0x38(%r12), %xmm5
mulsd %xmm4, %xmm5
subsd %xmm5, %xmm6
movsd %xmm6, (%rsp)
movsd 0x58(%r12), %xmm5
movsd 0x50(%r12), %xmm6
mulsd %xmm4, %xmm6
subsd %xmm6, %xmm5
movsd %xmm5, 0x70(%rsp)
subsd %xmm4, %xmm1
movsd 0x48(%r12), %xmm5
subsd %xmm4, %xmm5
movsd %xmm5, 0x68(%rsp)
movsd 0x60(%r12), %xmm5
subsd %xmm4, %xmm5
movsd %xmm5, 0x60(%rsp)
movq 0x40(%rsp), %rdi
movq %rsp, %rsi
leaq 0x68(%rsp), %rdx
movq %rbx, %rcx
leaq 0x70(%rsp), %r8
leaq 0x60(%rsp), %r9
pushq %r15
pushq %r10
callq 0x7aec
addq $0x10, %rsp
movl %eax, (%r12)
movsd 0x20(%r12), %xmm0
movsd 0x38(%r12), %xmm1
mulsd %xmm0, %xmm1
addsd (%rsp), %xmm1
movsd %xmm1, 0x40(%r12)
movsd 0x50(%r12), %xmm1
mulsd %xmm0, %xmm1
addsd 0x70(%rsp), %xmm1
movsd %xmm1, 0x58(%r12)
movsd 0x68(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x48(%r12)
addsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x60(%r12)
jmp 0x7391
movb $0x0, 0x11(%r12)
movsd 0x68(%r12), %xmm2
movsd 0x70(%r12), %xmm3
movq 0x40(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq %rbx, %rcx
movq 0x80(%rsp), %r8
movq 0x78(%rsp), %r9
pushq %r15
pushq %r10
callq 0x7aec
addq $0x10, %rsp
movl %eax, (%r12)
movb (%r15), %al
cmpb $0x1, %al
movq 0xf8(%rsp), %rsi
movq 0xe8(%rsp), %r10
movsd 0x58(%rsp), %xmm0
movapd 0x1c7c(%rip), %xmm6     # 0x9030
jne 0x7445
movsd 0x50(%r12), %xmm5
movsd 0x38(%r12), %xmm2
subsd %xmm2, %xmm5
movapd %xmm5, %xmm1
xorpd %xmm6, %xmm1
movapd %xmm1, %xmm3
maxsd %xmm5, %xmm3
movsd 0x30(%r12), %xmm4
mulsd 0x202d(%rip), %xmm4     # 0x9418
ucomisd %xmm4, %xmm3
jb 0x7417
mulsd 0x1c9f(%rip), %xmm5     # 0x9098
addsd %xmm2, %xmm5
movsd %xmm5, (%r10)
movsd (%rbx), %xmm5
movq 0x40(%rsp), %rcx
subsd (%rcx), %xmm5
movapd %xmm5, %xmm1
xorpd %xmm6, %xmm1
movsd 0x28(%r12), %xmm2
movsd %xmm2, 0x30(%r12)
movapd %xmm5, %xmm2
cmpltsd 0x1c8e(%rip), %xmm2     # 0x90c0
andpd %xmm2, %xmm1
andnpd %xmm5, %xmm2
orpd %xmm1, %xmm2
movlpd %xmm2, 0x28(%r12)
cmpl $-0x1, (%rsi)
je 0x70d1
testb $0x1, %al
je 0x7475
movsd 0x38(%r12), %xmm1
movsd 0x50(%r12), %xmm0
movapd %xmm0, %xmm2
minsd %xmm1, %xmm2
movsd %xmm2, 0x68(%r12)
maxsd %xmm1, %xmm0
jmp 0x749c
movsd 0x38(%r12), %xmm1
movsd %xmm1, 0x68(%r12)
movsd (%r10), %xmm2
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
mulsd 0x1bd8(%rip), %xmm0     # 0x9070
addsd %xmm2, %xmm0
movq 0x48(%rsp), %rdi
movq 0x108(%rsp), %r8
movq 0xe0(%rsp), %rcx
movsd %xmm0, 0x70(%r12)
movq 0x20(%rsp), %rdx
movsd (%rdx), %xmm0
maxsd (%r10), %xmm0
movsd %xmm0, (%r10)
movq 0x28(%rsp), %rdx
movsd (%rdx), %xmm2
minsd %xmm0, %xmm2
movsd %xmm2, (%r10)
testb $0x1, %al
je 0x7534
movsd 0x68(%r12), %xmm0
ucomisd %xmm2, %xmm0
jae 0x7553
movsd 0x70(%r12), %xmm1
ucomisd %xmm1, %xmm2
jae 0x7553
movq 0xf0(%rsp), %rdx
decq %rdx
movq 0x100(%rsp), %rax
cmpq %rdx, (%rax)
jae 0x7553
cmpl $0x0, (%r12)
je 0x7553
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movsd 0x38(%rsp), %xmm0
mulsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jae 0x7553
jmp 0x755f
movq 0xf0(%rsp), %rdx
decq %rdx
movq 0x100(%rsp), %rax
cmpq %rdx, (%rax)
jae 0x7553
cmpl $0x0, (%r12)
jne 0x755f
movsd 0x38(%r12), %xmm0
movsd %xmm0, (%r10)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x759b
movq 0xd8(%rsp), %rdx
leaq (%rdx,%rcx,8), %rcx
xorl %edx, %edx
movsd (%r10), %xmm0
mulsd (%rcx,%rdx,8), %xmm0
addsd (%r8,%rdx,8), %xmm0
movsd %xmm0, (%rdi,%rdx,8)
incq %rdx
cmpq %rdx, %r14
jne 0x7577
jmp 0x759b
movl $0x1, %eax
movl %eax, (%rsi)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x30d0
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x214e(%rip), %rsi      # 0x971a
leaq 0x216f(%rip), %rdx      # 0x9742
movq %rsp, %rdi
callq 0x49a0
movq %rsp, %rsi
movq %r14, %rdi
callq 0x7a8a
leaq 0x5713(%rip), %rsi      # 0xcd00
leaq -0x2c84(%rip), %rdx     # 0x4970
movq %r14, %rdi
callq 0x32e0
jmp 0x774b
movl $0x28, %edi
callq 0x30d0
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x205b(%rip), %rsi      # 0x9679
leaq 0x20f4(%rip), %rdx      # 0x9719
movq %rsp, %rdi
callq 0x49a0
movq %rsp, %rsi
movq %r14, %rdi
callq 0x7a8a
leaq 0x5729(%rip), %rax      # 0xcd68
movq %rax, (%r14)
leaq 0x56cf(%rip), %rsi      # 0xcd18
leaq -0x2ce0(%rip), %rdx     # 0x4970
movq %r14, %rdi
callq 0x32e0
jmp 0x774b
movl $0x28, %edi
callq 0x30d0
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x20f2(%rip), %rsi      # 0x976c
leaq 0x211f(%rip), %rdx      # 0x97a0
movq %rsp, %rdi
callq 0x49a0
movq %rsp, %rsi
movq %r14, %rdi
callq 0x7a8a
leaq 0x5665(%rip), %rsi      # 0xcd00
leaq -0x2d32(%rip), %rdx     # 0x4970
movq %r14, %rdi
callq 0x32e0
jmp 0x774b
movl $0x28, %edi
callq 0x30d0
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2077(%rip), %rsi      # 0x9743
leaq 0x2098(%rip), %rdx      # 0x976b
movq %rsp, %rdi
callq 0x49a0
movq %rsp, %rsi
movq %r14, %rdi
callq 0x7a8a
leaq 0x5613(%rip), %rsi      # 0xcd00
leaq -0x2d84(%rip), %rdx     # 0x4970
movq %r14, %rdi
callq 0x32e0
jmp 0x774b
movl $0x28, %edi
callq 0x30d0
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2086(%rip), %rsi      # 0x97a1
leaq 0x20bf(%rip), %rdx      # 0x97e1
movq %rsp, %rdi
callq 0x49a0
movq %rsp, %rsi
movq %r14, %rdi
callq 0x7a8a
leaq 0x55c4(%rip), %rsi      # 0xcd00
leaq -0x2dd3(%rip), %rdx     # 0x4970
movq %r14, %rdi
callq 0x32e0
movl $0x28, %edi
callq 0x30d0
movq %rax, %rbx
leaq 0x1e07(%rip), %rsi      # 0x9566
movl $0x1af, %edx            # imm = 0x1AF
jmp 0x777f
movl $0x28, %edi
callq 0x30d0
movq %rax, %rbx
leaq 0x1dec(%rip), %rsi      # 0x9566
movl $0x1b2, %edx            # imm = 0x1B2
movq %rax, %rdi
callq 0x6bd4
leaq 0x54da(%rip), %rsi      # 0xcc68
leaq -0x2e25(%rip), %rdx     # 0x4970
movq %rbx, %rdi
callq 0x32e0
movl $0x28, %edi
callq 0x30d0
movq %rax, %rbx
movq %rax, %rdi
callq 0x7a20
leaq 0x552f(%rip), %rsi      # 0xcce8
jmp 0x778e
jmp 0x77cb
jmp 0x77e6
jmp 0x77cb
jmp 0x77e6
jmp 0x77cb
jmp 0x77e6
jmp 0x77cb
jmp 0x77e6
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x77f1
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x31d0
jmp 0x77f1
movq %rax, %rbx
movq %r14, %rdi
callq 0x3150
movq %rbx, %rdi
callq 0x3300
nop