// File: /workspace/github_cpp_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %r9
movq %rsi, %r10
movq %rdi, %rbx
movl 0xc8(%rdi), %eax
cltd
idivl 0x8(%rdi)
movq 0x40(%rdi), %rax
subq 0x38(%rdi), %rax
sarq $0x3, %rax
movq (%r8), %rdi
movq (%r9), %r8
movslq %edx, %r13
imulq $0x18, %r13, %r14
movq 0x90(%rbx), %rsi
addq %r14, %rsi
movq (%rcx), %rcx
movq (%r10), %rdx
movq 0x78(%rbx), %r9
addq %r14, %r9
xorl %r10d, %r10d
cmpq %rax, %r10
jae 0x24d9
movsd (%rdi,%r10,8), %xmm0
subsd (%r8,%r10,8), %xmm0
movq (%rsi), %r11
movsd %xmm0, (%r11,%r10,8)
movsd (%rcx,%r10,8), %xmm0
subsd (%rdx,%r10,8), %xmm0
movq (%r9), %r11
movsd %xmm0, (%r11,%r10,8)
incq %r10
jmp 0x24a5
leaq -0x98(%rbp), %r15
movq %r15, %rdi
callq 0x269c
movq 0x78(%rbx), %rsi
addq %r14, %rsi
leaq -0x80(%rbp), %rdi
callq 0x269c
leaq -0x80(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x17a0
movsd %xmm0, -0x30(%rbp)
movq %r12, %rdi
callq 0x1666
movq %r15, %rdi
callq 0x1666
movsd -0x30(%rbp), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x2548
jp 0x2548
movq 0x2aa4(%rip), %rdi      # 0x4fd8
leaq 0xbf6(%rip), %rsi       # 0x3131
callq 0x10b0
movsd 0xb58(%rip), %xmm1      # 0x30a0
movsd 0xb50(%rip), %xmm0      # 0x30a0
movsd %xmm1, -0x30(%rbp)
divsd %xmm1, %xmm0
movq 0xa8(%rbx), %rax
movsd %xmm0, (%rax,%r13,8)
movq 0x90(%rbx), %rsi
addq %r14, %rsi
leaq -0x68(%rbp), %r15
movq %r15, %rdi
callq 0x269c
addq 0x90(%rbx), %r14
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
callq 0x269c
leaq -0x68(%rbp), %r14
leaq -0x50(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x17a0
movsd %xmm0, -0x38(%rbp)
movq %r15, %rdi
callq 0x1666
movq %r14, %rdi
callq 0x1666
xorpd %xmm0, %xmm0
movsd -0x38(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x25e3
jp 0x25e3
movq 0x2a09(%rip), %rdi      # 0x4fd8
leaq 0xb78(%rip), %rsi       # 0x314e
callq 0x10b0
movsd 0xabd(%rip), %xmm1      # 0x30a0
movsd -0x30(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0xc0(%rbx)
incl 0xc8(%rbx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x260b
movq %rax, %rbx
movq %r15, %rdi
callq 0x1666
movq %rbx, %rdi
callq 0x1150