// File: /workspace/github_cpp_makefile_star2_O1/js850[P]lbfgs_cpp/lbfgs.cpp
// Function: LBFGS_ns::LBFGS::update_memory(std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&)
void LBFGS::update_memory(
          std::vector<double> & xold,
          std::vector<double> & gold,
          std::vector<double> & xnew,
          std::vector<double> & gnew
          )
{
  // update the lbfgs memory
  // This updates s_, y_, rho_, and H0_, and k_
  int klocal = k_ % M_;
  for (size_t j2 = 0; j2 < x_.size(); ++j2){
    y_[klocal][j2] = gnew[j2] - gold[j2];
    s_[klocal][j2] = xnew[j2] - xold[j2];
  }

  double ys = vecdot(y_[klocal], s_[klocal]);
  if (ys == 0.) {
    // should print a warning here
    cout << "warning: resetting YS to 1.\n";
    ys = 1.;
  }

  rho_[klocal] = 1. / ys;

  double yy = vecdot(y_[klocal], y_[klocal]);
  if (yy == 0.) {
    // should print a warning here
    cout << "warning: resetting YY to 1.\n";
    yy = 1.;
  }
  H0_ = ys / yy;
//  cout << "    setting H0 " << H0_ 
//    << " ys " << ys 
//    << " yy " << yy 
//    << " rho[i] " << rho_[klocal] 
//    << "\n";

  // increment k
  k_ += 1;
  
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rdx, %r9
movq %rdi, %rbx
movl 0xc8(%rdi), %eax
cltd
idivl 0x8(%rdi)
movq 0x40(%rdi), %rax
movslq %edx, %r12
subq 0x38(%rdi), %rax
je 0x27c6
sarq $0x3, %rax
movq (%r8), %rdx
movq (%r9), %rdi
movq 0x78(%rbx), %r9
movq 0x90(%rbx), %r8
leaq (,%r12,8), %r10
leaq (%r10,%r10,2), %r10
movq (%r8,%r10), %r8
movq (%rcx), %rcx
movq (%rsi), %rsi
movq (%r9,%r10), %r9
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %r10d, %r10d
movsd (%rdx,%r10,8), %xmm0
subsd (%rdi,%r10,8), %xmm0
movsd %xmm0, (%r8,%r10,8)
movsd (%rcx,%r10,8), %xmm0
subsd (%rsi,%r10,8), %xmm0
movsd %xmm0, (%r9,%r10,8)
incq %r10
cmpq %r10, %rax
jne 0x279a
leaq -0x50(%rbp), %r15
leaq (,%r12,8), %rax
leaq (%rax,%rax,2), %r14
movq 0x90(%rbx), %rsi
addq %r14, %rsi
leaq -0x60(%rbp), %rdi
callq 0x29fe
movq 0x78(%rbx), %rsi
addq %r14, %rsi
leaq -0x90(%rbp), %rdi
callq 0x29fe
leaq -0x60(%rbp), %rdi
leaq -0x90(%rbp), %r15
movq %r15, %rsi
callq 0x16b0
movq (%r15), %rdi
testq %rdi, %rdi
movsd %xmm0, -0x28(%rbp)
je 0x282d
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movsd -0x28(%rbp), %xmm0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x2847
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movsd -0x28(%rbp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x2873
jp 0x2873
movq 0x277e(%rip), %rdi      # 0x4fd8
leaq 0x8a0(%rip), %rsi       # 0x3101
movl $0x1c, %edx
callq 0x10e0
movsd 0x7fd(%rip), %xmm0      # 0x3070
leaq -0x38(%rbp), %r15
movsd 0x7f1(%rip), %xmm1      # 0x3070
movsd %xmm0, -0x28(%rbp)
divsd %xmm0, %xmm1
movq 0xa8(%rbx), %rax
movsd %xmm1, (%rax,%r12,8)
movq 0x90(%rbx), %rsi
addq %r14, %rsi
leaq -0x48(%rbp), %rdi
callq 0x29fe
addq 0x90(%rbx), %r14
leaq -0x78(%rbp), %rdi
movq %r14, %rsi
callq 0x29fe
leaq -0x48(%rbp), %rdi
leaq -0x78(%rbp), %r14
movq %r14, %rsi
callq 0x16b0
movsd %xmm0, -0x30(%rbp)
movq (%r14), %rdi
testq %rdi, %rdi
je 0x28e4
movq -0x68(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x28f9
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
xorpd %xmm0, %xmm0
movsd -0x30(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x292a
jp 0x292a
movq 0x26c7(%rip), %rdi      # 0x4fd8
leaq 0x806(%rip), %rsi       # 0x311e
movl $0x1c, %edx
callq 0x10e0
movsd 0x746(%rip), %xmm1      # 0x3070
movsd -0x28(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0xc0(%rbx)
incl 0xc8(%rbx)
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x48(%rbp), %rdi
jmp 0x295e
movq %rax, %rbx
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x296e
movq (%r15), %rsi
subq %rdi, %rsi
callq 0x10d0
movq %rbx, %rdi
callq 0x1160