// File: /workspace/github_cpp_makefile_star2_O1/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 $0xa8, %rsp
movsd %xmm2, 0x38(%rsp)
movsd %xmm1, 0x40(%rsp)
movapd %xmm0, %xmm6
movq %r9, %r13
movq %r8, %r14
movq %rcx, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdi, %r12
movq 0x108(%rsp), %rbp
movq 0xf8(%rsp), %r10
movq 0xe0(%rsp), %r15
cmpl $-0x1, (%rbp)
movsd %xmm0, 0x60(%rsp)
je 0x70b0
movl $0x1, (%r12)
testq %r14, %r14
je 0x7794
cmpq $0x0, 0x100(%rsp)
je 0x7794
xorpd %xmm0, %xmm0
ucomisd 0x38(%rsp), %xmm0
ja 0x7794
movq 0x48(%rsp), %rax
ucomisd (%rax), %xmm0
ja 0x7794
movq 0x28(%rsp), %rax
movsd (%rax), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x7794
movq 0x30(%rsp), %rax
ucomisd (%rax), %xmm0
ja 0x7794
xorpd %xmm0, %xmm0
ucomisd 0x40(%rsp), %xmm0
ja 0x77af
ucomisd (%r10), %xmm0
jae 0x77af
movq $0x0, 0x8(%r12)
testq %r14, %r14
je 0x6feb
movq 0xf0(%rsp), %rax
movq 0xe8(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
xorl %ecx, %ecx
movsd (%r15,%rcx,8), %xmm1
mulsd (%rax,%rcx,8), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%r12)
incq %rcx
cmpq %rcx, %r14
jne 0x6fcd
movsd 0x8(%r12), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jae 0x77e6
movw $0x100, 0x10(%r12)      # imm = 0x100
movq 0x110(%rsp), %rax
movq $0x0, (%rax)
movsd %xmm6, 0x18(%r12)
mulsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x20(%r12)
movq 0x30(%rsp), %rax
movsd (%rax), %xmm0
movq 0x28(%rsp), %rax
subsd (%rax), %xmm0
movsd %xmm0, 0x28(%r12)
addsd %xmm0, %xmm0
movsd %xmm0, 0x30(%r12)
testq %r14, %r14
je 0x7072
leaq (,%r14,8), %rdx
movq 0x118(%rsp), %rdi
movq %r13, %rsi
callq 0x32a0
movsd 0x60(%rsp), %xmm6
xorl %eax, %eax
movq %rax, 0x38(%r12)
movsd 0x8(%r12), %xmm0
movsd 0x18(%r12), %xmm1
movsd %xmm1, 0x40(%r12)
movsd %xmm0, 0x48(%r12)
movq %rax, 0x50(%r12)
movsd %xmm1, 0x58(%r12)
movsd %xmm0, 0x60(%r12)
movq 0xf8(%rsp), %r10
movq %r13, 0x80(%rsp)
cmpl $-0x1, (%rbp)
jne 0x7487
movq 0xf0(%rsp), %rax
movq 0xe8(%rsp), %rcx
leaq (%rcx,%rax,8), %r13
leaq 0x10(%r12), %rbx
leaq 0x38(%r12), %rax
movq %rax, 0x58(%rsp)
leaq 0x40(%r12), %rax
movq %rax, 0xa0(%rsp)
leaq 0x48(%r12), %rax
movq %rax, 0x98(%rsp)
leaq 0x50(%r12), %rax
movq %rax, 0x50(%rsp)
leaq 0x58(%r12), %rax
movq %rax, 0x90(%rsp)
leaq 0x60(%r12), %rax
movq %rax, 0x88(%rsp)
movl $0x0, (%rbp)
movq 0x110(%rsp), %rcx
movq (%rcx), %rax
incq %rax
movq %rax, (%rcx)
xorpd %xmm1, %xmm1
testq %r14, %r14
je 0x715f
xorl %ecx, %ecx
movsd (%r15,%rcx,8), %xmm0
mulsd (%r13,%rcx,8), %xmm0
addsd %xmm0, %xmm1
incq %rcx
cmpq %rcx, %r14
jne 0x7146
movsd (%r10), %xmm4
movsd 0x20(%r12), %xmm2
movapd %xmm4, %xmm3
mulsd %xmm2, %xmm3
movsd 0x18(%r12), %xmm0
addsd %xmm3, %xmm0
movb 0x10(%r12), %cl
testb %cl, %cl
je 0x71a5
movsd 0x68(%r12), %xmm5
ucomisd %xmm4, %xmm5
jae 0x763a
ucomisd 0x70(%r12), %xmm4
jae 0x763a
cmpl $0x0, (%r12)
je 0x763a
movq 0x30(%rsp), %rdx
ucomisd (%rdx), %xmm4
jne 0x71cd
jp 0x71cd
ucomisd %xmm6, %xmm0
jb 0x71cd
ucomisd %xmm1, %xmm2
jae 0x75e4
movq 0x28(%rsp), %rdx
ucomisd (%rdx), %xmm4
jne 0x71ee
jp 0x71ee
ucomisd %xmm0, %xmm6
ja 0x76f0
ucomisd %xmm2, %xmm1
jae 0x76f0
cmpq 0x100(%rsp), %rax
jae 0x769a
testb %cl, %cl
je 0x7222
movsd 0x70(%r12), %xmm4
movapd %xmm4, %xmm5
subsd 0x68(%r12), %xmm5
mulsd 0x38(%rsp), %xmm4
ucomisd %xmm5, %xmm4
jae 0x7743
ucomisd %xmm6, %xmm0
jb 0x725a
movapd %xmm1, %xmm4
movapd 0x1dfc(%rip), %xmm7     # 0x9030
xorpd %xmm7, %xmm4
maxsd %xmm1, %xmm4
movsd 0x8(%r12), %xmm5
xorpd %xmm7, %xmm5
movq 0x48(%rsp), %rax
mulsd (%rax), %xmm5
ucomisd %xmm4, %xmm5
jae 0x75dd
ucomisd %xmm6, %xmm0
jb 0x728a
cmpb $0x0, 0x11(%r12)
je 0x728a
movq 0x48(%rsp), %rax
movsd (%rax), %xmm4
minsd 0x40(%rsp), %xmm4
mulsd 0x8(%r12), %xmm4
ucomisd %xmm4, %xmm1
jb 0x728a
movb $0x0, 0x11(%r12)
cmpb $0x1, 0x11(%r12)
jne 0x73a3
movsd 0x40(%r12), %xmm4
ucomisd %xmm6, %xmm4
jb 0x73a3
ucomisd %xmm0, %xmm6
jbe 0x73a3
subsd %xmm3, %xmm6
movsd 0x38(%r12), %xmm3
mulsd %xmm2, %xmm3
subsd %xmm3, %xmm4
movsd %xmm4, 0x8(%rsp)
movsd 0x58(%r12), %xmm3
movsd 0x50(%r12), %xmm4
mulsd %xmm2, %xmm4
subsd %xmm4, %xmm3
movsd %xmm3, 0x78(%rsp)
subsd %xmm2, %xmm1
movsd 0x48(%r12), %xmm3
subsd %xmm2, %xmm3
movsd %xmm3, 0x70(%rsp)
movsd 0x60(%r12), %xmm3
subsd %xmm2, %xmm3
movsd %xmm3, 0x68(%rsp)
movsd 0x68(%r12), %xmm2
movsd 0x70(%r12), %xmm3
movq 0x58(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x70(%rsp), %rdx
movq 0x50(%rsp), %rcx
leaq 0x78(%rsp), %r8
leaq 0x68(%rsp), %r9
movapd %xmm6, %xmm0
pushq %rbx
pushq %r10
callq 0x7b42
addq $0x10, %rsp
movl %eax, (%r12)
movsd 0x20(%r12), %xmm0
movsd 0x38(%r12), %xmm1
mulsd %xmm0, %xmm1
addsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x40(%r12)
movsd 0x50(%r12), %xmm1
mulsd %xmm0, %xmm1
addsd 0x78(%rsp), %xmm1
movsd %xmm1, 0x58(%r12)
movsd 0x70(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x48(%r12)
addsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x60(%r12)
jmp 0x73ef
movsd 0x68(%r12), %xmm2
movsd 0x70(%r12), %xmm3
movq 0x58(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x50(%rsp), %rcx
movq 0x90(%rsp), %r8
movq 0x88(%rsp), %r9
movapd %xmm6, %xmm0
pushq %rbx
pushq %r10
callq 0x7b42
addq $0x10, %rsp
movl %eax, (%r12)
cmpb $0x1, (%rbx)
movq 0xf8(%rsp), %r10
movsd 0x60(%rsp), %xmm6
jne 0x747d
movsd 0x50(%r12), %xmm0
movsd 0x38(%r12), %xmm1
subsd %xmm1, %xmm0
movapd %xmm0, %xmm2
xorpd 0x1c10(%rip), %xmm2     # 0x9030
maxsd %xmm0, %xmm2
movsd 0x30(%r12), %xmm3
mulsd 0x1fe5(%rip), %xmm3     # 0x9418
ucomisd %xmm3, %xmm2
jb 0x744a
mulsd 0x1c57(%rip), %xmm0     # 0x9098
addsd %xmm1, %xmm0
movsd %xmm0, (%r10)
movsd 0x28(%r12), %xmm0
movsd 0x50(%r12), %xmm1
movsd %xmm0, 0x30(%r12)
subsd 0x38(%r12), %xmm1
movapd %xmm1, %xmm0
xorpd 0x1bbe(%rip), %xmm0     # 0x9030
maxsd %xmm1, %xmm0
movsd %xmm0, 0x28(%r12)
cmpl $-0x1, (%rbp)
je 0x7123
movb 0x10(%r12), %al
cmpb $0x1, %al
jne 0x74c1
leaq 0x50(%r12), %rcx
movsd 0x38(%r12), %xmm0
movsd 0x50(%r12), %xmm1
ucomisd %xmm0, %xmm1
leaq 0x38(%r12), %rdx
minsd %xmm0, %xmm1
movsd %xmm1, 0x68(%r12)
cmovaq %rcx, %rdx
movsd (%rdx), %xmm0
jmp 0x74e8
movsd 0x38(%r12), %xmm1
movsd %xmm1, 0x68(%r12)
movsd (%r10), %xmm2
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
mulsd 0x1b8c(%rip), %xmm0     # 0x9070
addsd %xmm2, %xmm0
movsd %xmm0, 0x70(%r12)
movq 0x28(%rsp), %rcx
movsd (%rcx), %xmm1
maxsd (%r10), %xmm1
movsd %xmm1, (%r10)
movq 0x30(%rsp), %rcx
movsd (%rcx), %xmm0
minsd %xmm1, %xmm0
movsd %xmm0, (%r10)
testb %al, %al
movq 0x80(%rsp), %rdi
je 0x7536
movsd 0x68(%r12), %xmm1
ucomisd %xmm0, %xmm1
jae 0x7577
ucomisd 0x70(%r12), %xmm0
jae 0x7577
movq 0x100(%rsp), %rdx
decq %rdx
movq 0x110(%rsp), %rcx
cmpq %rdx, (%rcx)
jae 0x7577
cmpl $0x0, (%r12)
je 0x7577
testb %al, %al
je 0x7583
movsd 0x70(%r12), %xmm0
movsd 0x38(%rsp), %xmm1
mulsd %xmm0, %xmm1
subsd 0x68(%r12), %xmm0
ucomisd %xmm0, %xmm1
jb 0x7583
movsd 0x38(%r12), %xmm0
movsd %xmm0, (%r10)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x75c8
movq 0xf0(%rsp), %rcx
movq 0xe8(%rsp), %rdx
leaq (%rdx,%rcx,8), %rcx
xorl %edx, %edx
movq 0x118(%rsp), %r8
movsd (%r10), %xmm0
mulsd (%rcx,%rdx,8), %xmm0
addsd (%r8,%rdx,8), %xmm0
movsd %xmm0, (%rdi,%rdx,8)
incq %rdx
cmpq %rdx, %r14
jne 0x75ab
movl %eax, (%rbp)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %eax
jmp 0x75c8
movl $0x28, %edi
callq 0x30d0
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2119(%rip), %rsi      # 0x971a
leaq 0x213a(%rip), %rdx      # 0x9742
leaq 0x8(%rsp), %rdi
callq 0x49c8
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x7ae0
leaq 0x56da(%rip), %rsi      # 0xcd00
leaq -0x2c95(%rip), %rdx     # 0x4998
movq %rbx, %rdi
callq 0x32e0
jmp 0x7794
movl $0x28, %edi
callq 0x30d0
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2022(%rip), %rsi      # 0x9679
leaq 0x20bb(%rip), %rdx      # 0x9719
leaq 0x8(%rsp), %rdi
callq 0x49c8
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x7ae0
leaq 0x56ec(%rip), %rax      # 0xcd68
movq %rax, (%rbx)
leaq 0x5692(%rip), %rsi      # 0xcd18
leaq -0x2cf5(%rip), %rdx     # 0x4998
movq %rbx, %rdi
callq 0x32e0
jmp 0x7794
movl $0x28, %edi
callq 0x30d0
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x20b5(%rip), %rsi      # 0x976c
leaq 0x20e2(%rip), %rdx      # 0x97a0
leaq 0x8(%rsp), %rdi
callq 0x49c8
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x7ae0
leaq 0x5624(%rip), %rsi      # 0xcd00
leaq -0x2d4b(%rip), %rdx     # 0x4998
movq %rbx, %rdi
callq 0x32e0
jmp 0x7794
movl $0x28, %edi
callq 0x30d0
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2036(%rip), %rsi      # 0x9743
leaq 0x2057(%rip), %rdx      # 0x976b
leaq 0x8(%rsp), %rdi
callq 0x49c8
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x7ae0
leaq 0x55ce(%rip), %rsi      # 0xcd00
leaq -0x2da1(%rip), %rdx     # 0x4998
movq %rbx, %rdi
callq 0x32e0
jmp 0x7794
movl $0x28, %edi
callq 0x30d0
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2041(%rip), %rsi      # 0x97a1
leaq 0x207a(%rip), %rdx      # 0x97e1
leaq 0x8(%rsp), %rdi
callq 0x49c8
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x7ae0
leaq 0x557b(%rip), %rsi      # 0xcd00
leaq -0x2df4(%rip), %rdx     # 0x4998
movq %rbx, %rdi
callq 0x32e0
movl $0x28, %edi
callq 0x30d0
movq %rax, %rbx
leaq 0x1dbe(%rip), %rsi      # 0x9566
movl $0x1af, %edx            # imm = 0x1AF
jmp 0x77c8
movl $0x28, %edi
callq 0x30d0
movq %rax, %rbx
leaq 0x1da3(%rip), %rsi      # 0x9566
movl $0x1b2, %edx            # imm = 0x1B2
movq %rax, %rdi
callq 0x6bfe
leaq 0x5491(%rip), %rsi      # 0xcc68
leaq -0x2e46(%rip), %rdx     # 0x4998
movq %rbx, %rdi
callq 0x32e0
movl $0x28, %edi
callq 0x30d0
movq %rax, %rbx
movq %rax, %rdi
callq 0x7a76
leaq 0x54e6(%rip), %rsi      # 0xcce8
jmp 0x77d7
jmp 0x7814
jmp 0x7832
jmp 0x7814
jmp 0x7832
jmp 0x7814
jmp 0x7832
jmp 0x7814
jmp 0x7832
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x782e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x31d0
xorl %eax, %eax
jmp 0x7837
movq %rax, %r14
movb $0x1, %al
testb %al, %al
je 0x7843
movq %rbx, %rdi
callq 0x3150
movq %r14, %rdi
callq 0x3300
nop