// File: /workspace/github_cpp_makefile_star2_O1/canzarlab[P]Trajan/geno/lbfgsb.cpp
// Function: LBFGSB::lineSearchMT(Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, unsigned long)
Scalar LBFGSB::lineSearchMT(const Vector& deltaX, size_t iter) {
  Scalar const INF = std::numeric_limits<Scalar>::infinity();
  double stp;
  double a1, a2;
  double big  = 1.0e10;
  double ftol = 1.0e-3,
         gtol = 0.9,
         xtol = 0.1;
  Scalar dnorm = deltaX.norm();
  // Determine the maximum step length.
  Scalar stpmx = big;
  if (_constrained) {
    if (iter == 1) {
      stpmx = 1.0;
    } else {
      for (Index i = 0; i < _x.size(); ++i) {
        a1 = deltaX[i];
	//        if (_nbd[i] != 0) {     
	if (_lb[i] != -INF || _ub[i] != INF) {
	  //      if (a1 < zero && _nbd[i] <= 2) {
	  if (a1 < 0.0 && _lb[i] != -INF) {
	    a2 = _lb(i) - _x(i);
            if (a2 >= 0.0) {
              stpmx = 0.0;
            } else if (a1*stpmx < a2) {
              stpmx = a2/a1;
            }
	    //          } else if (a1 > zero && _nbd[i] >= 2) {
          } else if (a1 > 0.0 && _ub[i] != INF) {
            a2 = _ub(i) - _x(i);
            if (a2 <= 0.0) {
              stpmx = 0.0;
            } else if (a1*stpmx > a2) {
              stpmx = a2/a1;
            }
          }
        }
      }
    }
  }
  if (iter == 1 && !_boxed)
    stp = std::min(1.0/dnorm, stpmx);
  else
    stp = 1.0;
  _gNew = _g;
  _fNew = _f;
  TaskType csave = TaskType::START;
  Scalar gd = _gNew.dot(deltaX);
  if (gd >= 0.0) {
    std::cerr << "ascent direction in projection gd = " << gd << std::endl;
    stp = -1;
    return stp;
    //    std::exit(EXIT_FAILURE);
  }
  int funIter = 0;
  TMPContainer TCON;
  do {
    dcsrch(_fNew, gd, stp, ftol, gtol, xtol, 0.0, stpmx, csave, TCON);
    if (TaskType::ERROR == csave)
      std::exit(EXIT_FAILURE);
    if (csave == TaskType::CONVERGENCE || csave == TaskType::WARNING)
      break;
    _xNew = stp * deltaX + _x;
    _genoNLP.functionValueAndGradient(_xNew.data(), _fNew, _gNew.data());
    ++_funEval;
    gd = _gNew.dot(deltaX);
    ++funIter;
    if (funIter >= 19) {
      stp = -1;  // something went wrong
      break;
    }
  } while(true);
  return stp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %r15
movq %rsi, %rbx
movq %rsi, 0x60(%rsp)
cmpq $0x0, 0x8(%rsi)
movq %rdi, 0x8(%rsp)
je 0x176e9
jle 0x17d43
movq (%rbx), %rax
leaq 0xa8(%rsp), %rdi
movq %rax, 0x8(%rdi)
leaq 0x60(%rsp), %rax
movq %rax, 0x18(%rdi)
leaq 0x48(%rsp), %rsi
callq 0xff64
movq 0x8(%rsp), %rdi
jmp 0x176ed
xorpd %xmm0, %xmm0
movsd 0x4620b(%rip), %xmm4    # 0x5d900
cmpb $0x1, 0x258(%rdi)
jne 0x17833
cmpq $0x1, %r15
jne 0x17715
movsd 0x44c98(%rip), %xmm4    # 0x5c3a8
jmp 0x17833
movq 0x18(%rdi), %rax
testq %rax, %rax
jle 0x17833
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
movq 0x8(%rsp), %r11
movq 0x28(%r11), %rsi
movq 0x10(%r11), %rdi
movq 0x20(%r11), %r8
movq 0x38(%r11), %r9
xorl %r10d, %r10d
testq %rdx, %rdx
cmovleq %r10, %rdx
movq 0x30(%r11), %r11
testq %rsi, %rsi
cmovleq %r10, %rsi
movsd 0x461a4(%rip), %xmm8    # 0x5d900
movsd 0x44c74(%rip), %xmm1    # 0x5c3d8
movsd 0x44c44(%rip), %xmm2    # 0x5c3b0
xorpd %xmm3, %xmm3
cmpq %r10, %rdx
je 0x17ceb
cmpq %r10, %rsi
je 0x17c27
movsd (%rcx,%r10,8), %xmm5
movsd (%r8,%r10,8), %xmm6
ucomisd %xmm6, %xmm1
jb 0x177a9
cmpq %r10, %r9
jle 0x17c27
movsd (%r11,%r10,8), %xmm7
ucomisd %xmm2, %xmm7
jae 0x1781d
ucomisd %xmm5, %xmm3
jbe 0x177d4
ucomisd %xmm6, %xmm1
jae 0x177d4
subsd (%rdi,%r10,8), %xmm6
xorpd %xmm4, %xmm4
ucomisd %xmm4, %xmm6
jae 0x17822
movapd %xmm8, %xmm7
mulsd %xmm5, %xmm7
ucomisd %xmm7, %xmm6
jmp 0x1780c
ucomisd %xmm3, %xmm5
jbe 0x1781d
cmpq %r10, %r9
jle 0x17c27
movsd (%r11,%r10,8), %xmm6
ucomisd %xmm2, %xmm6
jae 0x1781d
subsd (%rdi,%r10,8), %xmm6
xorpd %xmm4, %xmm4
ucomisd %xmm6, %xmm4
jae 0x17822
movapd %xmm8, %xmm7
mulsd %xmm5, %xmm7
ucomisd %xmm6, %xmm7
movapd %xmm8, %xmm4
jbe 0x17822
divsd %xmm5, %xmm6
movapd %xmm6, %xmm4
jmp 0x17822
movapd %xmm8, %xmm4
incq %r10
movapd %xmm4, %xmm8
cmpq %r10, %rax
jne 0x17770
movsd 0x44b6d(%rip), %xmm1    # 0x5c3a8
cmpq $0x1, %r15
movq %rbx, 0x38(%rsp)
jne 0x1786e
movq 0x8(%rsp), %rdi
cmpb $0x0, 0x259(%rdi)
jne 0x17873
sqrtsd %xmm0, %xmm0
movsd 0x44b48(%rip), %xmm2    # 0x5c3a8
divsd %xmm0, %xmm2
movapd %xmm4, %xmm1
minsd %xmm2, %xmm1
jmp 0x17873
movq 0x8(%rsp), %rdi
movsd %xmm1, 0x18(%rsp)
leaq 0x248(%rdi), %rbx
movq 0x40(%rdi), %r15
movq 0x48(%rdi), %r12
cmpq %r12, 0x250(%rdi)
movsd %xmm4, 0x28(%rsp)
je 0x178be
testq %r12, %r12
js 0x17d0a
movl $0x1, %ecx
movq %rbx, %rdi
movq %r12, %rsi
movq %r12, %rdx
callq 0x10056
movsd 0x28(%rsp), %xmm4
movq 0x8(%rsp), %rdi
movq 0x250(%rdi), %rax
cmpq %r12, %rax
jne 0x17d29
movq (%rbx), %rcx
movq %rax, %rdx
shrq $0x3f, %rdx
addq %rax, %rdx
andq $-0x2, %rdx
cmpq $0x2, %rax
movq 0x38(%rsp), %r12
jl 0x17900
xorl %esi, %esi
movapd (%r15,%rsi,8), %xmm0
movapd %xmm0, (%rcx,%rsi,8)
addq $0x2, %rsi
cmpq %rdx, %rsi
jl 0x178ec
cmpq %rax, %rdx
jge 0x17918
movsd (%r15,%rdx,8), %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x17905
movsd 0x8(%rdi), %xmm0
movsd %xmm0, 0x230(%rdi)
movl $0x0, 0x24(%rsp)
movq 0x8(%r12), %rax
cmpq %rax, 0x250(%rdi)
jne 0x17c46
movq %rbx, 0x60(%rsp)
movq %r12, 0x68(%rsp)
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
testq %rax, %rax
je 0x17995
jle 0x17ccc
movq (%rbx), %rax
leaq 0xa8(%rsp), %rdi
movq %rax, 0x8(%rdi)
movq (%r12), %rax
movq %rax, 0x18(%rdi)
leaq 0x60(%rsp), %rax
movq %rax, 0x28(%rdi)
leaq 0x48(%rsp), %rsi
callq 0x19afa
movsd 0x28(%rsp), %xmm4
movq 0x8(%rsp), %rdi
xorpd %xmm1, %xmm1
movsd %xmm0, 0x30(%rsp)
ucomisd %xmm1, %xmm0
jae 0x17bab
leaq 0x230(%rdi), %r14
leaq 0x238(%rdi), %rax
movq %rax, 0x40(%rsp)
xorl %r15d, %r15d
xorpd %xmm3, %xmm3
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movsd 0x45f34(%rip), %xmm0    # 0x5d908
movsd 0x45f34(%rip), %xmm1    # 0x5d910
movsd 0x45f34(%rip), %xmm2    # 0x5d918
leaq 0x24(%rsp), %rcx
leaq 0xa8(%rsp), %r8
callq 0x2dff2
movl 0x24(%rsp), %eax
cmpl $0x1, %eax
je 0x17c65
addl $-0x3, %eax
cmpl $0x2, %eax
jb 0x17ba3
movq 0x8(%r12), %rax
testq %rax, %rax
js 0x17c6f
movq 0x8(%rsp), %r8
movq 0x18(%r8), %rbp
cmpq %rbp, %rax
jne 0x17cad
movsd 0x18(%rsp), %xmm2
movq (%r12), %r13
movq 0x10(%r8), %r12
cmpq %rbp, 0x240(%r8)
je 0x17a7b
movapd %xmm2, 0x90(%rsp)
testq %rbp, %rbp
js 0x17d0a
movl $0x1, %ecx
movq 0x40(%rsp), %rdi
movq %rbp, %rsi
movq %rbp, %rdx
callq 0x10056
movq 0x8(%rsp), %r8
movapd 0x90(%rsp), %xmm2
movq 0x240(%r8), %rax
cmpq %rbp, %rax
jne 0x17c8e
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
movq %rax, %rdx
shrq $0x3f, %rdx
addq %rax, %rdx
andq $-0x2, %rdx
cmpq $0x2, %rax
jl 0x17ad0
movapd %xmm2, %xmm0
unpcklpd %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0]
xorl %esi, %esi
movapd (%r13,%rsi,8), %xmm1
mulpd %xmm0, %xmm1
addpd (%r12,%rsi,8), %xmm1
movapd %xmm1, (%rcx,%rsi,8)
addq $0x2, %rsi
cmpq %rdx, %rsi
jl 0x17ab1
cmpq %rax, %rdx
jge 0x17af3
movsd (%r13,%rdx,8), %xmm0
mulsd %xmm2, %xmm0
addsd (%r12,%rdx,8), %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x17ad5
movq (%r8), %rdi
movq 0x238(%r8), %rsi
movq 0x248(%r8), %rcx
movq (%rdi), %rax
movq %r14, %rdx
callq *0x48(%rax)
movq 0x8(%rsp), %rcx
incq 0x50(%rcx)
movq 0x38(%rsp), %r12
movq 0x8(%r12), %rax
cmpq %rax, 0x250(%rcx)
jne 0x17c46
movq %rbx, 0x48(%rsp)
movq %r12, 0x50(%rsp)
testq %rax, %rax
movsd 0x28(%rsp), %xmm4
je 0x17b7d
jle 0x17ccc
movq (%rbx), %rax
movq %rax, 0x68(%rsp)
movq (%r12), %rax
movq %rax, 0x78(%rsp)
leaq 0x48(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x17(%rsp), %rsi
callq 0x19afa
movsd 0x28(%rsp), %xmm4
jmp 0x17b81
xorpd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
incl %r15d
cmpl $0x13, %r15d
jne 0x179bb
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x18(%rsp)
movsd 0x18(%rsp), %xmm0
jmp 0x17c15
movq 0x7043e(%rip), %rbx     # 0x87ff0
leaq 0x46016(%rip), %rsi     # 0x5dbcf
movl $0x24, %edx
movq %rbx, %rdi
callq 0x93a0
movsd 0x30(%rsp), %xmm0
movq %rbx, %rdi
callq 0x9560
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x9320
movsbl %al, %esi
movq %rbx, %rdi
callq 0x9040
movq %rax, %rdi
callq 0x9220
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x18(%rsp)
movsd 0x4478b(%rip), %xmm0    # 0x5c3a0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x455f7(%rip), %rdi     # 0x5d225
leaq 0x4560d(%rip), %rsi     # 0x5d242
leaq 0x46093(%rip), %rcx     # 0x5dccf
movl $0x198, %edx            # imm = 0x198
callq 0x9200
leaq 0x46139(%rip), %rdi     # 0x5dd86
leaq 0x46149(%rip), %rsi     # 0x5dd9d
leaq 0x46159(%rip), %rcx     # 0x5ddb4
movl $0x52, %edx
callq 0x9200
movl $0x1, %edi
callq 0x93d0
leaq 0x448c6(%rip), %rdi     # 0x5c53c
leaq 0x44954(%rip), %rsi     # 0x5c5d1
leaq 0x4496f(%rip), %rcx     # 0x5c5f3
movl $0x4a, %edx
callq 0x9200
leaq 0x453cb(%rip), %rdi     # 0x5d060
leaq 0x4487d(%rip), %rsi     # 0x5c519
leaq 0x56751(%rip), %rcx     # 0x6e3f4
movl $0x2d1, %edx            # imm = 0x2D1
callq 0x9200
leaq 0x4623a(%rip), %rdi     # 0x5deee
leaq 0x4626c(%rip), %rsi     # 0x5df27
leaq 0x5647e(%rip), %rcx     # 0x6e140
movl $0x6e, %edx
callq 0x9200
leaq 0x44cfe(%rip), %rdi     # 0x5c9d1
leaq 0x44d3b(%rip), %rsi     # 0x5ca15
leaq 0x46267(%rip), %rcx     # 0x5df48
movl $0x19d, %edx            # imm = 0x19D
callq 0x9200
leaq 0x45533(%rip), %rdi     # 0x5d225
leaq 0x45549(%rip), %rsi     # 0x5d242
leaq 0x563ab(%rip), %rcx     # 0x6e0ab
movl $0xa2, %edx
callq 0x9200
leaq 0x45147(%rip), %rdi     # 0x5ce58
leaq 0x44f9f(%rip), %rsi     # 0x5ccb7
leaq 0x452c8(%rip), %rcx     # 0x5cfe7
movl $0x11d, %edx            # imm = 0x11D
callq 0x9200
leaq 0x45330(%rip), %rdi     # 0x5d060
leaq 0x447e2(%rip), %rsi     # 0x5c519
leaq 0x455ae(%rip), %rcx     # 0x5d2ec
jmp 0x17ca3
leaq 0x44c87(%rip), %rdi     # 0x5c9d1
leaq 0x44cc4(%rip), %rsi     # 0x5ca15
leaq 0x44cd6(%rip), %rcx     # 0x5ca2e
jmp 0x17ce1