// File: /workspace/github_cpp_makefile_star2_O3/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, %r10
movq %rdi, %rbx
movl 0xc8(%rdi), %eax
cltd
idivl 0x8(%rdi)
movq 0x40(%rdi), %rax
subq 0x38(%rdi), %rax
je 0x27fd
movq %rsi, %r9
sarq $0x3, %rax
movq (%r8), %rdi
movq (%r10), %r8
movslq %edx, %r12
movq 0x78(%rbx), %r10
movq 0x90(%rbx), %rsi
leaq (,%r12,8), %rdx
leaq (%rdx,%rdx,2), %r11
movq (%rsi,%r11), %rdx
movq (%rcx), %rcx
movq (%r9), %r9
movq (%r10,%r11), %r10
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %r11d, %r11d
movsd (%rdi,%r11,8), %xmm0
subsd (%r8,%r11,8), %xmm0
movsd %xmm0, (%rdx,%r11,8)
movsd (%rcx,%r11,8), %xmm0
subsd (%r9,%r11,8), %xmm0
movsd %xmm0, (%r10,%r11,8)
incq %r11
cmpq %r11, %rax
jne 0x27cf
jmp 0x2807
movq 0x90(%rbx), %rsi
movslq %edx, %r12
leaq -0x50(%rbp), %r15
leaq (,%r12,8), %rax
leaq (%rax,%rax,2), %r14
addq %r14, %rsi
leaq -0x60(%rbp), %rdi
callq 0x2a38
movq 0x78(%rbx), %rsi
addq %r14, %rsi
leaq -0x90(%rbp), %rdi
callq 0x2a38
leaq -0x60(%rbp), %rdi
leaq -0x90(%rbp), %r15
movq %r15, %rsi
callq 0x16b0
movq (%r15), %rdi
testq %rdi, %rdi
movsd %xmm0, -0x28(%rbp)
je 0x2867
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movsd -0x28(%rbp), %xmm0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x2881
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movsd -0x28(%rbp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x28ad
jp 0x28ad
movq 0x2744(%rip), %rdi      # 0x4fd8
leaq 0x876(%rip), %rsi       # 0x3111
movl $0x1c, %edx
callq 0x10e0
movsd 0x7d3(%rip), %xmm0      # 0x3080
leaq -0x38(%rbp), %r15
movsd 0x7c7(%rip), %xmm1      # 0x3080
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 0x2a38
addq 0x90(%rbx), %r14
leaq -0x78(%rbp), %rdi
movq %r14, %rsi
callq 0x2a38
leaq -0x48(%rbp), %rdi
leaq -0x78(%rbp), %r14
movq %r14, %rsi
callq 0x16b0
movsd %xmm0, -0x30(%rbp)
movq (%r14), %rdi
testq %rdi, %rdi
je 0x291e
movq -0x68(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x2933
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
xorpd %xmm0, %xmm0
movsd -0x30(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x2964
jp 0x2964
movq 0x268d(%rip), %rdi      # 0x4fd8
leaq 0x7dc(%rip), %rsi       # 0x312e
movl $0x1c, %edx
callq 0x10e0
movsd 0x71c(%rip), %xmm1      # 0x3080
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 0x2998
movq %rax, %rbx
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x29a8
movq (%r15), %rsi
subq %rdi, %rsi
callq 0x10d0
movq %rbx, %rdi
callq 0x1160