// File: /workspace/github_cpp_makefile_star2_O2/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, 0x48(%rsp)
movsd %xmm1, 0x40(%rsp)
movq %r9, %rbp
movq %r8, %r14
movq %rcx, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdi, %r12
movq 0xf8(%rsp), %rdx
movq 0xe8(%rsp), %r10
movq 0xe0(%rsp), %rbx
movq 0xd8(%rsp), %r15
movq 0xd0(%rsp), %r13
cmpl $-0x1, (%rdx)
movsd %xmm0, 0x60(%rsp)
je 0x63df
movl $0x1, (%r12)
testq %r14, %r14
je 0x6a31
cmpq $0x0, 0xf0(%rsp)
je 0x6a31
xorpd %xmm1, %xmm1
ucomisd 0x48(%rsp), %xmm1
ja 0x6a31
movq 0x50(%rsp), %rax
ucomisd (%rax), %xmm1
ja 0x6a31
movq 0x8(%rsp), %rax
movsd (%rax), %xmm2
ucomisd %xmm2, %xmm1
ja 0x6a31
movq 0x10(%rsp), %rax
ucomisd (%rax), %xmm2
ja 0x6a31
ucomisd 0x40(%rsp), %xmm1
ja 0x6a4a
ucomisd (%r10), %xmm1
jae 0x6a4a
andq $0x0, 0x8(%r12)
leaq (%r15,%rbx,8), %rax
xorpd %xmm2, %xmm2
xorl %ecx, %ecx
cmpq %rcx, %r14
je 0x6321
movsd (%r13,%rcx,8), %xmm1
mulsd (%rax,%rcx,8), %xmm1
addsd %xmm1, %xmm2
movsd %xmm2, 0x8(%r12)
incq %rcx
jmp 0x6300
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jae 0x6a7f
movw $0x100, 0x10(%r12)      # imm = 0x100
movq 0x100(%rsp), %rax
andq $0x0, (%rax)
movsd %xmm0, 0x18(%r12)
mulsd 0x40(%rsp), %xmm2
movsd %xmm2, 0x20(%r12)
movq 0x10(%rsp), %rax
movsd (%rax), %xmm0
movq 0x8(%rsp), %rax
subsd (%rax), %xmm0
movsd %xmm0, 0x28(%r12)
addsd %xmm0, %xmm0
movsd %xmm0, 0x30(%r12)
leaq (,%r14,8), %rdx
movq 0x108(%rsp), %rdi
movq %rbp, %rsi
callq 0x3280
movsd 0x60(%rsp), %xmm0
andq $0x0, 0x38(%r12)
movsd 0x8(%r12), %xmm2
movsd 0x18(%r12), %xmm1
movsd %xmm1, 0x40(%r12)
movsd %xmm2, 0x48(%r12)
andq $0x0, 0x50(%r12)
movsd %xmm1, 0x58(%r12)
movsd %xmm2, 0x60(%r12)
movq 0xf8(%rsp), %rdx
movq 0xe8(%rsp), %r10
movq %rbp, 0x58(%rsp)
leaq (%r15,%rbx,8), %r15
leaq 0x10(%r12), %rbx
leaq 0x40(%r12), %rax
movq %rax, 0x90(%rsp)
leaq 0x38(%r12), %rax
movq %rax, 0x18(%rsp)
leaq 0x48(%r12), %rax
movq %rax, 0x88(%rsp)
leaq 0x50(%r12), %rbp
leaq 0x58(%r12), %rax
movq %rax, 0x80(%rsp)
leaq 0x60(%r12), %rax
movq %rax, 0x78(%rsp)
cmpl $-0x1, (%rdx)
jne 0x67a9
andl $0x0, (%rdx)
movq 0x100(%rsp), %rcx
movq (%rcx), %rax
incq %rax
movq %rax, (%rcx)
xorpd %xmm1, %xmm1
xorl %ecx, %ecx
cmpq %rcx, %r14
je 0x646b
movsd (%r13,%rcx,8), %xmm2
mulsd (%r15,%rcx,8), %xmm2
addsd %xmm2, %xmm1
incq %rcx
jmp 0x6450
movsd (%r10), %xmm2
movsd 0x20(%r12), %xmm4
movapd %xmm2, %xmm5
mulsd %xmm4, %xmm5
movsd 0x18(%r12), %xmm7
addsd %xmm5, %xmm7
movb 0x10(%r12), %cl
testb %cl, %cl
je 0x64b1
movsd 0x68(%r12), %xmm3
ucomisd %xmm2, %xmm3
jae 0x68d6
ucomisd 0x70(%r12), %xmm2
jae 0x68d6
cmpl $0x0, (%r12)
je 0x68d6
movq 0x10(%rsp), %rsi
ucomisd (%rsi), %xmm2
jne 0x64d9
jp 0x64d9
ucomisd %xmm0, %xmm7
jb 0x64d9
ucomisd %xmm1, %xmm4
jae 0x6964
movq 0x8(%rsp), %rsi
ucomisd (%rsi), %xmm2
jne 0x64fa
jp 0x64fa
ucomisd %xmm7, %xmm0
ja 0x69ab
ucomisd %xmm4, %xmm1
jae 0x69ab
cmpq 0xf0(%rsp), %rax
jae 0x691d
testb %cl, %cl
je 0x652e
movsd 0x70(%r12), %xmm2
movapd %xmm2, %xmm3
subsd 0x68(%r12), %xmm3
mulsd 0x48(%rsp), %xmm2
ucomisd %xmm3, %xmm2
jae 0x69ef
ucomisd %xmm0, %xmm7
jb 0x65a2
movapd %xmm1, %xmm2
movapd 0x1ae0(%rip), %xmm6     # 0x8020
xorpd %xmm6, %xmm2
maxsd %xmm1, %xmm2
movsd 0x8(%r12), %xmm3
xorpd %xmm6, %xmm3
movq 0x50(%rsp), %rax
mulsd (%rax), %xmm3
ucomisd %xmm2, %xmm3
jae 0x68bf
ucomisd %xmm0, %xmm7
setb %cl
movb 0x11(%r12), %al
movl %eax, %edx
xorb $0x1, %dl
orb %cl, %dl
jne 0x65a7
movq 0x50(%rsp), %rcx
movsd (%rcx), %xmm2
minsd 0x40(%rsp), %xmm2
mulsd 0x8(%r12), %xmm2
ucomisd %xmm2, %xmm1
jb 0x65a7
movb $0x0, 0x11(%r12)
jmp 0x66b0
movb 0x11(%r12), %al
testb %al, %al
je 0x66b0
movsd 0x40(%r12), %xmm6
movsd 0x68(%r12), %xmm2
ucomisd %xmm0, %xmm6
movsd 0x70(%r12), %xmm3
jb 0x66be
ucomisd %xmm7, %xmm0
jbe 0x66be
subsd %xmm5, %xmm0
movsd 0x38(%r12), %xmm5
mulsd %xmm4, %xmm5
subsd %xmm5, %xmm6
movsd %xmm6, 0x20(%rsp)
movsd 0x58(%r12), %xmm5
movsd 0x50(%r12), %xmm6
mulsd %xmm4, %xmm6
subsd %xmm6, %xmm5
movsd %xmm5, (%rsp)
subsd %xmm4, %xmm1
movsd 0x48(%r12), %xmm5
subsd %xmm4, %xmm5
movsd %xmm5, 0x70(%rsp)
movsd 0x60(%r12), %xmm5
subsd %xmm4, %xmm5
movsd %xmm5, 0x68(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x70(%rsp), %rdx
movq %rbp, %rcx
movq %rsp, %r8
leaq 0x68(%rsp), %r9
pushq %rbx
pushq %r10
callq 0x6e3e
popq %rcx
popq %rdx
movl %eax, (%r12)
movsd 0x20(%r12), %xmm0
movsd 0x38(%r12), %xmm1
mulsd %xmm0, %xmm1
addsd 0x20(%rsp), %xmm1
movsd %xmm1, 0x40(%r12)
movsd 0x50(%r12), %xmm1
mulsd %xmm0, %xmm1
addsd (%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 0x66f1
movsd 0x68(%r12), %xmm2
movsd 0x70(%r12), %xmm3
movq 0x18(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq %rbp, %rcx
movq 0x80(%rsp), %r8
movq 0x78(%rsp), %r9
pushq %rbx
pushq %r10
callq 0x6e3e
popq %rcx
popq %rdx
movl %eax, (%r12)
cmpb $0x1, (%rbx)
movq 0xf8(%rsp), %rdx
movq 0xe8(%rsp), %r10
movsd 0x60(%rsp), %xmm0
movapd 0x190e(%rip), %xmm6     # 0x8020
jne 0x642d
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 0x1c9f(%rip), %xmm4     # 0x83e8
ucomisd %xmm4, %xmm3
jb 0x6776
mulsd 0x1911(%rip), %xmm5     # 0x8068
addsd %xmm2, %xmm5
movsd %xmm5, (%r10)
movsd (%rbp), %xmm5
movq 0x18(%rsp), %rax
subsd (%rax), %xmm5
movapd %xmm5, %xmm1
xorpd %xmm6, %xmm1
movsd 0x28(%r12), %xmm2
movsd %xmm2, 0x30(%r12)
movapd %xmm5, %xmm2
cmpltsd 0x18ff(%rip), %xmm2     # 0x8090
andpd %xmm2, %xmm1
andnpd %xmm5, %xmm2
orpd %xmm1, %xmm2
movlpd %xmm2, 0x28(%r12)
jmp 0x642d
movb (%rbx), %al
cmpb $0x1, %al
jne 0x67d2
movsd 0x38(%r12), %xmm1
movsd 0x50(%r12), %xmm0
movapd %xmm0, %xmm2
minsd %xmm1, %xmm2
movsd %xmm2, 0x68(%r12)
maxsd %xmm1, %xmm0
jmp 0x67f9
movsd 0x38(%r12), %xmm1
movsd %xmm1, 0x68(%r12)
movsd (%r10), %xmm2
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
mulsd 0x184b(%rip), %xmm0     # 0x8040
addsd %xmm2, %xmm0
movq 0x58(%rsp), %rcx
movq 0x108(%rsp), %rsi
movsd %xmm0, 0x70(%r12)
movq 0x8(%rsp), %rdi
movsd (%rdi), %xmm1
maxsd (%r10), %xmm1
movsd %xmm1, (%r10)
movq 0x10(%rsp), %rdi
movsd (%rdi), %xmm0
minsd %xmm1, %xmm0
movsd %xmm0, (%r10)
testb %al, %al
je 0x684c
movsd 0x68(%r12), %xmm1
ucomisd %xmm0, %xmm1
jae 0x688d
ucomisd 0x70(%r12), %xmm0
jae 0x688d
movq 0xf0(%rsp), %r8
decq %r8
movq 0x100(%rsp), %rdi
cmpq %r8, (%rdi)
jae 0x688d
cmpl $0x0, (%r12)
je 0x688d
testb %al, %al
je 0x689b
movsd 0x70(%r12), %xmm0
movsd 0x48(%rsp), %xmm1
mulsd %xmm0, %xmm1
subsd 0x68(%r12), %xmm0
ucomisd %xmm0, %xmm1
jb 0x689b
movq 0x18(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, (%r10)
xorl %eax, %eax
pushq $-0x1
popq %rdi
cmpq %rax, %r14
je 0x68c2
movsd (%r10), %xmm0
mulsd (%r15,%rax,8), %xmm0
addsd (%rsi,%rax,8), %xmm0
movsd %xmm0, (%rcx,%rax,8)
incq %rax
jmp 0x68a0
pushq $0x1
popq %rdi
movl %edi, (%rdx)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x30d0
movq %rax, %r14
leaq 0x1d61(%rip), %rsi      # 0x8649
leaq 0x20(%rsp), %rdi
movq %rsp, %rdx
callq 0x432a
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x6dd8
leaq 0x541f(%rip), %rsi      # 0xbd28
leaq -0x255a(%rip), %rdx     # 0x43b6
movq %r14, %rdi
callq 0x32c0
jmp 0x6a31
pushq $0x28
popq %rdi
callq 0x30d0
movq %rax, %r14
leaq 0x1e0d(%rip), %rsi      # 0x873c
leaq 0x20(%rsp), %rdi
movq %rsp, %rdx
callq 0x432a
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x6dee
leaq 0x53c0(%rip), %rsi      # 0xbd10
leaq -0x25a1(%rip), %rdx     # 0x43b6
movq %r14, %rdi
callq 0x32c0
jmp 0x6a31
pushq $0x28
popq %rdi
callq 0x30d0
movq %rax, %r14
leaq 0x1d74(%rip), %rsi      # 0x86ea
leaq 0x20(%rsp), %rdi
movq %rsp, %rdx
callq 0x432a
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x6dee
leaq 0x5379(%rip), %rsi      # 0xbd10
leaq -0x25e8(%rip), %rdx     # 0x43b6
movq %r14, %rdi
callq 0x32c0
jmp 0x6a31
pushq $0x28
popq %rdi
callq 0x30d0
movq %rax, %r14
leaq 0x1d56(%rip), %rsi      # 0x8713
leaq 0x20(%rsp), %rdi
movq %rsp, %rdx
callq 0x432a
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x6dee
leaq 0x5332(%rip), %rsi      # 0xbd10
leaq -0x262f(%rip), %rdx     # 0x43b6
movq %r14, %rdi
callq 0x32c0
jmp 0x6a31
pushq $0x28
popq %rdi
callq 0x30d0
movq %rax, %r14
leaq 0x1d70(%rip), %rsi      # 0x8771
leaq 0x20(%rsp), %rdi
movq %rsp, %rdx
callq 0x432a
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x6dee
leaq 0x52ee(%rip), %rsi      # 0xbd10
leaq -0x2673(%rip), %rdx     # 0x43b6
movq %r14, %rdi
callq 0x32c0
pushq $0x28
popq %rdi
callq 0x30d0
movq %rax, %rbx
leaq 0x1af3(%rip), %rsi      # 0x8536
movl $0x1af, %edx            # imm = 0x1AF
jmp 0x6a61
pushq $0x28
popq %rdi
callq 0x30d0
movq %rax, %rbx
leaq 0x1ada(%rip), %rsi      # 0x8536
movl $0x1b2, %edx            # imm = 0x1B2
movq %rax, %rdi
callq 0x60fa
leaq 0x5208(%rip), %rsi      # 0xbc78
leaq -0x26c1(%rip), %rdx     # 0x43b6
movq %rbx, %rdi
callq 0x32c0
pushq $0x28
popq %rdi
callq 0x30d0
movq %rax, %rbx
movq %rax, %rdi
callq 0x6d86
leaq 0x525f(%rip), %rsi      # 0xbcf8
jmp 0x6a70
jmp 0x6aab
jmp 0x6aba
jmp 0x6aab
jmp 0x6aba
jmp 0x6aab
jmp 0x6aba
jmp 0x6aab
jmp 0x6aba
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x30a0
jmp 0x6ac5
movq %rax, %rbx
movq %r14, %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x32e0