// File: /workspace/github_cpp_makefile_star2_O2/canzarlab[P]Trajan/geno/lbfgsb.cpp
// Function: LBFGSB::subsm()
void LBFGSB::subsm() {
  Vector tmp2 = _M * _c;
  Vector tmp3 = _S * tmp2.head(_S.cols()) + _Y * tmp2.tail(_Y.cols());
  Vector r = (tmp3 - (_g + _theta*(_xCP - _x))).cwiseProduct(_workingSet);
  Vector wv(_M.rows());
  wv.head(_Y.cols()) = _Y.transpose() * r;
  wv.tail(_S.cols()) = _S.transpose() * r;
  wv.tail(_S.cols()) *= _theta;

  wv.head(_Y.cols()) = _Q * wv.head(_Y.cols());
  wv.tail(_S.cols()) = _Q * wv.tail(_S.cols());
  Vector wvl = wv;
  _L.triangularView<Eigen::Lower>().solveInPlace(wvl);
  wvl = _E*wvl;
 _L.transpose().triangularView<Eigen::Upper>().solveInPlace(wvl);
  wvl.tail(_S.cols()) *= _theta;
  wvl.head(_Y.cols()) = _Q.transpose() * wvl.head(_Y.cols());
  wvl.tail(_S.cols()) = _Q.transpose() * wvl.tail(_S.cols());


  Vector tmp8 = _Y * wvl.head(_Y.cols()) + _S * wvl.tail(_S.cols());
  Vector d = 1.0/_theta * r + 1.0 / (_theta * _theta) * tmp8;
  d = d.cwiseProduct(_workingSet);


  _xSubspace = _xCP + d;
  // Project _xSubspace back to bounds.
  _xSubspace = _xSubspace.array().max(_lb.array()).min(_ub.array());

  const Scalar machinePrecision = std::numeric_limits<Scalar>::epsilon();
  Scalar dummy = (_xSubspace - _x).dot(_g);
  if (dummy < 0 || d.norm() < machinePrecision)
  {
    return;
  }

  if (_verbose)
    printf("\npositive directional derivative, using backtracking line search\n");

  // Backtrack solution
  Vector alphaLB = (d.array() >= 0).select(std::numeric_limits<Scalar>::infinity(), (_lb - _xCP).cwiseQuotient(d));
  Vector alphaUB = (d.array() <= 0).select(std::numeric_limits<Scalar>::infinity(), (_ub - _xCP).cwiseQuotient(d));

  Index indexLB;
  Scalar minAlphaLB = alphaLB.minCoeff(&indexLB);
  Index indexUB;
  Scalar minAlphaUB = alphaUB.minCoeff(&indexUB);

  Index index2 = 0;
  Scalar alpha = std::min(minAlphaLB, minAlphaUB);
  if (alpha == minAlphaUB)
    index2 = 1;

  if (alpha < 1) {
    _xSubspace = _xCP + d * alpha;
    // Just to eliminate roundoff errors.
    if (0 == index2)  // Did we hit a lower bound?
      _xSubspace(indexLB) = _lb(indexLB);
    else
      _xSubspace(indexUB) = _ub(indexUB);
  } else {
    _xSubspace = _xCP + d;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rdi, %r14
addq $0x110, %rdi            # imm = 0x110
leaq 0x200(%r14), %rsi
callq 0x13926
leaq 0x60(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
leaq 0x258(%rsp), %rbx
movq %rbx, %rdi
callq 0x27f96
movq 0xb8(%r14), %rdx
leaq 0x1e0(%rsp), %rdi
movq %rbx, %rsi
callq 0xd304
leaq 0xa8(%r14), %r12
leaq 0x148(%rsp), %rdi
leaq 0x1e0(%rsp), %rdx
movq %r12, %rsi
callq 0x2803a
movq 0xd0(%r14), %rdx
leaq 0x1a8(%rsp), %rdi
leaq 0x258(%rsp), %rsi
callq 0xdb4a
leaq 0xc0(%r14), %r15
leaq 0xe8(%rsp), %rdi
leaq 0x1a8(%rsp), %rdx
movq %r15, %rsi
callq 0x2803a
leaq 0x60(%rsp), %rdi
leaq 0x148(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0x13966
leaq 0x248(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x280ea
leaq 0x1d0(%r14), %r13
leaq 0x10(%r14), %rdx
leaq 0x1a8(%rsp), %rdi
movq %r13, %rsi
movq %rdx, 0x228(%rsp)
callq 0x1367c
leaq 0xd8(%r14), %rbx
leaq 0x1e0(%rsp), %rdi
leaq 0x1a8(%rsp), %rdx
movq %rbx, %rsi
callq 0x139b9
leaq 0x40(%r14), %rsi
leaq 0xe8(%rsp), %rdi
leaq 0x1e0(%rsp), %rdx
movq %rsi, 0x220(%rsp)
callq 0x1399e
leaq 0x148(%rsp), %rdi
leaq 0x248(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0x13982
leaq 0x1e0(%r14), %rdx
leaq 0x60(%rsp), %rdi
leaq 0x148(%rsp), %rsi
movq %rdx, 0x28(%rsp)
callq 0x13a10
leaq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2842a
movq 0x118(%r14), %rax
leaq 0x60(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x18(%rsp), %rdi
callq 0xcea2
leaq 0xe8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x50(%rsp), %rsi
callq 0x132a2
movq %rax, 0x148(%rsp)
movq %rdx, 0x150(%rsp)
movq 0xd0(%r14), %rdx
leaq 0x60(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xd304
leaq 0x60(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x26d87
leaq 0xe8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x50(%rsp), %rsi
callq 0x132a2
movq %rax, 0x148(%rsp)
movq %rdx, 0x150(%rsp)
movq 0xb8(%r14), %rdx
leaq 0x60(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xdb4a
leaq 0x60(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x26d87
movq %r12, (%rsp)
movq 0xb8(%r14), %rdx
leaq 0x60(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xdb4a
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x13a2c
movq 0xd0(%r14), %rdx
leaq 0x148(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xd304
leaq 0x128(%r14), %r12
leaq 0x60(%rsp), %rdi
leaq 0x148(%rsp), %rdx
movq %r12, %rsi
callq 0x2803a
movq 0xd0(%r14), %rdx
leaq 0xe8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xd304
leaq 0xe8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x28897
movq 0xb8(%r14), %rdx
leaq 0x148(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xdb4a
leaq 0x60(%rsp), %rdi
leaq 0x148(%rsp), %rdx
movq %r12, %rsi
callq 0x2803a
movq 0xb8(%r14), %rdx
leaq 0xe8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xdb4a
leaq 0xe8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x28897
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xe746
leaq 0x158(%r14), %rbp
leaq 0x60(%rsp), %rdi
movq %rbp, (%rdi)
leaq 0x8(%rsp), %rsi
callq 0x28940
leaq 0x170(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x13926
leaq 0x60(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
leaq 0x8(%rsp), %rdi
callq 0x2989d
leaq 0x60(%rsp), %rdi
movq %rbp, (%rdi)
leaq 0x8(%rsp), %rsi
callq 0x2992a
movq 0xb8(%r14), %rdx
leaq 0x60(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xdb4a
movq %r13, %rbp
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x13a2c
movq %r12, 0x1e0(%rsp)
movq 0xd0(%r14), %rdx
leaq 0x148(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xd304
leaq 0x60(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
leaq 0x148(%rsp), %rdx
callq 0x2a1e2
movq 0xd0(%r14), %rdx
leaq 0xe8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xd304
leaq 0xe8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2a22b
movq %r12, 0x1e0(%rsp)
movq 0xb8(%r14), %rdx
leaq 0x148(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xdb4a
leaq 0x60(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
leaq 0x148(%rsp), %rdx
callq 0x2a1e2
movq 0xb8(%r14), %rdx
leaq 0xe8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xdb4a
movq (%rsp), %r12
leaq 0xe8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2a22b
movq 0xd0(%r14), %rdx
leaq 0x1e0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xd304
leaq 0x148(%rsp), %rdi
leaq 0x1e0(%rsp), %rdx
movq %r15, %rsi
callq 0x2803a
movq 0xb8(%r14), %rdx
leaq 0x1a8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xdb4a
leaq 0xe8(%rsp), %rdi
leaq 0x1a8(%rsp), %rdx
movq %r12, %rsi
callq 0x2803a
leaq 0x60(%rsp), %rdi
leaq 0x148(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0x13966
leaq 0x238(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x280ea
movsd 0x41d7d(%rip), %xmm0    # 0x53820
divsd (%rbx), %xmm0
leaq 0x1e0(%rsp), %rsi
movsd %xmm0, (%rsi)
leaq 0x148(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0xdbac
movsd (%rbx), %xmm0
mulsd %xmm0, %xmm0
movsd 0x41d4b(%rip), %xmm1    # 0x53820
divsd %xmm0, %xmm1
leaq 0x40(%rsp), %rsi
movsd %xmm1, (%rsi)
leaq 0xe8(%rsp), %rdi
leaq 0x238(%rsp), %rdx
callq 0xdbac
leaq 0x60(%rsp), %rdi
leaq 0x148(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0x13a68
leaq 0x1a8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2a504
leaq 0x60(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x13286
leaq 0x1a8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x14098
leaq 0x60(%rsp), %rdi
leaq 0x1a8(%rsp), %rdx
movq %rbp, %rsi
callq 0x13a84
leaq 0x210(%r14), %rbx
leaq 0x60(%rsp), %rsi
movq %rbx, %rdi
callq 0x2a776
leaq 0xe8(%rsp), %rsi
movq %rbx, (%rsi)
leaq 0x20(%r14), %r15
leaq 0x1e0(%rsp), %rdx
movq %r15, (%rdx)
leaq 0x148(%rsp), %rdi
callq 0x13aa0
leaq 0x30(%r14), %r13
leaq 0x40(%rsp), %rdx
movq %r13, (%rdx)
leaq 0x60(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x13abc
leaq 0x60(%rsp), %rsi
movq %rbx, %rdi
callq 0x2a965
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
movq 0x228(%rsp), %rdx
callq 0x1367c
leaq 0x60(%rsp), %rdi
movq 0x220(%rsp), %rsi
callq 0x13ad8
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x11e83
leaq 0x1a8(%rsp), %r12
movq %r12, %rdi
callq 0x13b08
movsd 0x41bfc(%rip), %xmm1    # 0x53810
ucomisd %xmm0, %xmm1
ja 0x11e83
cmpb $0x1, 0x58(%r14)
jne 0x11c31
leaq 0x5aafc(%rip), %rdi     # 0x6c728
callq 0x9520
leaq 0x138(%rsp), %rsi
movq %r12, (%rsi)
leaq 0x30(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0x148(%rsp), %rdi
callq 0x13b14
movabsq $0x7ff0000000000000, %r12 # imm = 0x7FF0000000000000
movq %r12, 0x38(%rsp)
leaq 0x1e0(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x1367c
leaq 0xe8(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
leaq 0x1a8(%rsp), %r14
movq %r14, %rdx
callq 0x13ba6
leaq 0x60(%rsp), %rdi
leaq 0x148(%rsp), %rsi
leaq 0x38(%rsp), %rdx
leaq 0xe8(%rsp), %rcx
callq 0x13b58
leaq 0x40(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2aefc
leaq 0x30(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x38(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0xe8(%rsp), %rdi
callq 0x13bc2
movq %r12, 0x230(%rsp)
leaq 0x1e0(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x1367c
leaq 0x148(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
leaq 0x1a8(%rsp), %rdx
callq 0x13ba6
leaq 0x60(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
leaq 0x230(%rsp), %rdx
leaq 0x148(%rsp), %rcx
callq 0x13c06
leaq 0x138(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2b1a2
leaq 0x40(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x13c50
movsd %xmm0, (%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
callq 0x13c50
movsd %xmm0, 0x28(%rsp)
movapd %xmm0, %xmm1
minsd (%rsp), %xmm1
movsd %xmm1, 0x30(%rsp)
movsd 0x41a8b(%rip), %xmm0    # 0x53820
movsd %xmm1, (%rsp)
ucomisd %xmm1, %xmm0
jbe 0x11e16
leaq 0x148(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x13c96
leaq 0x60(%rsp), %rdi
leaq 0x148(%rsp), %rdx
movq %rbp, %rsi
callq 0x13c7a
leaq 0x60(%rsp), %rsi
movq %rbx, %rdi
callq 0x2b441
movsd (%rsp), %xmm0
ucomisd 0x28(%rsp), %xmm0
jne 0x11deb
jnp 0x11e3a
movq 0xe8(%rsp), %rsi
movq %r15, %rdi
callq 0xd27a
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
movq 0xe8(%rsp), %rsi
movq %rbx, %rdi
callq 0xd27a
jmp 0x11e63
leaq 0x60(%rsp), %rdi
leaq 0x1a8(%rsp), %rdx
movq %rbp, %rsi
callq 0x13a84
leaq 0x60(%rsp), %rsi
movq %rbx, %rdi
callq 0x2a776
jmp 0x11e6c
movq 0x1e0(%rsp), %rsi
movq %r13, %rdi
callq 0xd27a
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
movq 0x1e0(%rsp), %rsi
movq %rbx, %rdi
callq 0xd27a
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x138(%rsp), %rdi
callq 0x93c0
movq 0x40(%rsp), %rdi
callq 0x93c0
movq 0x1a8(%rsp), %rdi
callq 0x93c0
movq 0x238(%rsp), %rdi
callq 0x93c0
movq 0x8(%rsp), %rdi
callq 0x93c0
movq 0x18(%rsp), %rdi
callq 0x93c0
movq 0x50(%rsp), %rdi
callq 0x93c0
movq 0x248(%rsp), %rdi
callq 0x93c0
movq 0x258(%rsp), %rdi
callq 0x93c0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x11ef3
jmp 0x11ef3
jmp 0x11ef3
jmp 0x11ef3
jmp 0x11f07
jmp 0x11f31
movq %rax, %rbx
movq 0x138(%rsp), %rdi
callq 0x93c0
jmp 0x11f0a
jmp 0x11f31
movq %rax, %rbx
movq 0x40(%rsp), %rdi
callq 0x93c0
jmp 0x11f34
jmp 0x11f31
jmp 0x11f31
jmp 0x11f64
jmp 0x11f76
jmp 0x11f76
jmp 0x11f5d
jmp 0x11f5d
jmp 0x11f5d
movq %rax, %rbx
jmp 0x11f8d
jmp 0x11f31
jmp 0x11f31
jmp 0x11f31
movq %rax, %rbx
movq 0x1a8(%rsp), %rdi
callq 0x93c0
jmp 0x11f67
jmp 0x11f76
jmp 0x11f76
jmp 0x11f76
jmp 0x11f76
jmp 0x11f76
jmp 0x11f76
jmp 0x11f76
jmp 0x11f5d
jmp 0x11f5d
jmp 0x11f5d
jmp 0x11f5d
jmp 0x11f5d
jmp 0x11f5d
movq %rax, %rbx
jmp 0x11f83
jmp 0x11fb9
movq %rax, %rbx
movq 0x238(%rsp), %rdi
callq 0x93c0
jmp 0x11f79
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0x93c0
movq 0x18(%rsp), %rdi
callq 0x93c0
movq 0x50(%rsp), %rdi
callq 0x93c0
movq 0x248(%rsp), %rdi
callq 0x93c0
movq 0x258(%rsp), %rdi
callq 0x93c0
movq %rbx, %rdi
callq 0x9640
movq %rax, %rbx
jmp 0x11fa4
movq %rax, %rbx
jmp 0x11f97
nop