// File: /workspace/github_cpp_makefile_star2_O3/js850[P]lbfgs_cpp/lbfgs.cpp
// Function: LBFGS_ns::LBFGS::compute_lbfgs_step()
void LBFGS::compute_lbfgs_step()
{
  if (k_ == 0){ 
    double gnorm = vecnorm(g_);
    if (gnorm > 1.) gnorm = 1. / gnorm;
    for (size_t j2 = 0; j2 < x_.size(); ++j2){
      step_[j2] = - gnorm * H0_ * g_[j2];
    }
    return;
  } 

  step_ = g_;

  int jmin = std::max(0, k_ - M_);
  int jmax = k_;
  int i;
  double beta;
  vector<double> alpha(M_);

  // loop backwards through the memory
  for (int j = jmax - 1; j >= jmin; --j){
    i = j % M_;
    //cout << "    i " << i << " j " << j << "\n";
    alpha[i] = rho_[i] * vecdot(s_[i], step_);
    for (size_t j2 = 0; j2 < step_.size(); ++j2){
      step_[j2] -= alpha[i] * y_[i][j2];
    }
  }

  // scale the step size by H0
  for (size_t j2 = 0; j2 < step_.size(); ++j2){
    step_[j2] *= H0_;
  }

  // loop forwards through the memory
  for (int j = jmin; j < jmax; ++j){
    i = j % M_;
    //cout << "    i " << i << " j " << j << "\n";
    beta = rho_[i] * vecdot(y_[i], step_);
    for (size_t j2 = 0; j2 < step_.size(); ++j2){
      step_[j2] += s_[i][j2] * (alpha[i] - beta);
    }
  }

  // invert the step to point downhill
  for (size_t j2 = 0; j2 < x_.size(); ++j2){
    step_[j2] *= -1;
  }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbx
leaq 0x58(%rdi), %rsi
cmpl $0x0, 0xc8(%rdi)
je 0x202f
leaq 0xd0(%rbx), %rdi
movq %rdi, -0x70(%rbp)
callq 0x2bf2
movl 0xc8(%rbx), %r14d
movslq 0x8(%rbx), %rsi
movl %r14d, %eax
subl %esi, %eax
xorl %r15d, %r15d
testl %eax, %eax
cmovgl %eax, %r15d
leaq -0x58(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x2ab8
cmpl %r15d, %r14d
movl %r14d, -0x30(%rbp)
jle 0x20dd
movl %r15d, -0x38(%rbp)
decl %r14d
movl %r14d, %eax
cltd
idivl 0x8(%rbx)
movslq %edx, %r12
movq 0xa8(%rbx), %rax
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, -0x40(%rbp)
leaq (%r12,%r12,2), %r13
leaq (,%r13,8), %rsi
addq 0x78(%rbx), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x2a38
leaq -0xe8(%rbp), %r15
movq %r15, %rdi
movq -0x70(%rbp), %rsi
callq 0x2a38
leaq -0xa0(%rbp), %rdi
movq %r15, %rsi
callq 0x16b0
movsd -0x40(%rbp), %xmm1
mulsd %xmm0, %xmm1
movq -0x58(%rbp), %rax
movsd %xmm1, (%rax,%r12,8)
movq -0xe8(%rbp), %rdi
testq %rdi, %rdi
je 0x1fa4
movq -0xd8(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x1fbf
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movq 0xd0(%rbx), %rax
movq 0xd8(%rbx), %rdx
movq %rdx, %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rax, %rdx
je 0x201d
movq -0x58(%rbp), %rsi
movq 0x90(%rbx), %rdi
movq (%rdi,%r13,8), %rdi
cmpq $0x1, %rcx
movq %rcx, %r8
adcq $0x0, %r8
xorl %r9d, %r9d
movsd (%rsi,%r12,8), %xmm0
movsd (%rax,%r9,8), %xmm1
mulsd (%rdi,%r9,8), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%rax,%r9,8)
incq %r9
cmpq %r9, %r8
jne 0x1ff9
movl -0x38(%rbp), %r15d
cmpl %r15d, %r14d
jg 0x1f19
jmp 0x20f5
leaq -0xb8(%rbp), %r14
movq %r14, %rdi
callq 0x2a38
movq %r14, %rdi
callq 0x1724
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
je 0x206a
movq -0xa8(%rbp), %rsi
subq %rdi, %rsi
movaps %xmm0, -0x70(%rbp)
callq 0x10d0
movapd -0x70(%rbp), %xmm0
movq 0x40(%rbx), %rax
subq 0x38(%rbx), %rax
je 0x227a
sarq $0x3, %rax
movsd 0xffc(%rip), %xmm2      # 0x3080
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
cmpltsd %xmm0, %xmm2
andpd %xmm2, %xmm1
andnpd %xmm0, %xmm2
orpd %xmm1, %xmm2
xorpd 0xfcb(%rip), %xmm2      # 0x3070
movq 0x58(%rbx), %rcx
movq 0xd0(%rbx), %rdx
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %esi, %esi
movsd 0xc0(%rbx), %xmm1
mulsd %xmm2, %xmm1
mulsd (%rcx,%rsi,8), %xmm1
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x20ba
jmp 0x227a
movq 0xd0(%rbx), %rax
movq 0xd8(%rbx), %rdx
movq %rdx, %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rax, %rdx
je 0x211e
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
movsd 0xc0(%rbx), %xmm0
mulsd (%rax,%rdx,8), %xmm0
movsd %xmm0, (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x2104
cmpl %r15d, -0x30(%rbp)
jle 0x222f
movl %r15d, %r12d
movl %r15d, %eax
cltd
idivl 0x8(%rbx)
movl %edx, %r13d
movq 0xa8(%rbx), %rax
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, -0x40(%rbp)
leaq (,%r13,2), %r14
addq %r13, %r14
leaq (,%r14,8), %rsi
addq 0x90(%rbx), %rsi
leaq -0x88(%rbp), %rdi
callq 0x2a38
leaq -0xd0(%rbp), %r15
movq %r15, %rdi
movq -0x70(%rbp), %rsi
callq 0x2a38
leaq -0x88(%rbp), %rdi
movq %r15, %rsi
callq 0x16b0
movsd %xmm0, -0x38(%rbp)
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x21af
movq -0xc0(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0x21c7
movq -0x78(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movq 0xd0(%rbx), %rax
movq 0xd8(%rbx), %rcx
subq %rax, %rcx
movsd -0x40(%rbp), %xmm1
je 0x221f
mulsd -0x38(%rbp), %xmm1
sarq $0x3, %rcx
movq 0x78(%rbx), %rdx
movq (%rdx,%r14,8), %rdx
movq -0x58(%rbp), %rsi
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edi, %edi
movsd (%rsi,%r13,8), %xmm0
subsd %xmm1, %xmm0
mulsd (%rdx,%rdi,8), %xmm0
addsd (%rax,%rdi,8), %xmm0
movsd %xmm0, (%rax,%rdi,8)
incq %rdi
cmpq %rdi, %rcx
jne 0x21fe
movl %r12d, %r15d
incl %r15d
cmpl -0x30(%rbp), %r15d
jne 0x2128
movq 0x40(%rbx), %rcx
subq 0x38(%rbx), %rcx
je 0x2265
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
movapd 0xe21(%rip), %xmm0      # 0x3070
movsd (%rax,%rdx,8), %xmm1
xorpd %xmm0, %xmm1
movlpd %xmm1, (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x224f
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x227a
movq -0x48(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
je 0x22f8
movq -0xa8(%rbp), %rsi
jmp 0x22f0
movq %rax, %rbx
jmp 0x22f8
jmp 0x22c0
movq %rax, %rbx
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0x22e3
movq -0x78(%rbp), %rsi
jmp 0x22db
movq %rax, %rbx
jmp 0x22e3
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x22e3
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x22f8
movq -0x48(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movq %rbx, %rdi
callq 0x1160