// File: /workspace/github_cpp_makefile_star2_O3/js850[P]lbfgs_cpp/lbfgs.cpp
// Function: LBFGS_ns::LBFGS::LBFGS(double (*)(double*, double*, unsigned long), double const*, unsigned long, int)
LBFGS::LBFGS(
    double (*func)(double *, double *, size_t), 
    double const * x0, 
    size_t N, 
    int M
    //double tol,
    //double maxstep,
    //double max_f_rise,
    //double H0,
    //int maxiter
    )
  :
    func_f_grad_(func),
    M_(M),
    tol_(1e-4),
    maxstep_(0.2),
    max_f_rise_(1e-4),
    maxiter_(1000),
    iprint_(-1),
    iter_number_(0),
    nfev_(0),
    H0_(0.1),
    k_(0)
{
  // set the precision of the printing
  cout << std::setprecision(12);

  // allocate arrays
  x_ = std::vector<double>(N);
  g_ = std::vector<double>(N);

  y_ = std::vector<vector<double> >(M_, vector<double>(N));
  s_ = std::vector<vector<double> >(M_, vector<double>(N));
  rho_ = std::vector<double>(M_);
  step_ = std::vector<double>(N);

  for (size_t j2 = 0; j2 < N; ++j2){
    x_[j2] = x0[j2];
  }
  compute_func_gradient(x_, f_, g_);
  rms_ = vecnorm(g_) / sqrt(N);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, %r15
movq %rdx, %r12
movq %rdi, %rbx
movq %rsi, (%rdi)
movl %r8d, 0x8(%rdi)
movabsq $0x3f1a36e2eb1c432d, %rax # imm = 0x3F1A36E2EB1C432D
movq %rax, 0x10(%rdi)
movabsq $0x3fc999999999999a, %rcx # imm = 0x3FC999999999999A
movq %rcx, 0x18(%rdi)
movq %rax, 0x20(%rdi)
movl $0x3e8, 0x28(%rdi)      # imm = 0x3E8
movl $0xffffffff, 0x2c(%rdi) # imm = 0xFFFFFFFF
leaq 0x58(%rdi), %r14
xorpd %xmm0, %xmm0
movupd %xmm0, 0x58(%rdi)
xorl %eax, %eax
movq %rax, 0x68(%rdi)
movupd %xmm0, 0x30(%rdi)
movupd %xmm0, 0x40(%rdi)
movupd %xmm0, 0x78(%rdi)
movupd %xmm0, 0x88(%rdi)
movupd %xmm0, 0x98(%rdi)
movupd %xmm0, 0xa8(%rdi)
movq %rax, 0xb8(%rdi)
movabsq $0x3fb999999999999a, %rcx # imm = 0x3FB999999999999A
movq %rcx, 0xc0(%rdi)
movl $0x0, 0xc8(%rdi)
movq %rax, 0xe0(%rdi)
movupd %xmm0, 0xd0(%rdi)
movq 0x3751(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0xc, 0x8(%rax,%rcx)
leaq -0x50(%rbp), %rdi
leaq -0x80(%rbp), %rdx
movq %r15, %rsi
callq 0x2ab8
movq 0x38(%rbx), %rdi
movq 0x48(%rbx), %rsi
movq -0x50(%rbp), %rax
movq %rax, 0x38(%rbx)
movq -0x48(%rbp), %rax
movq %rax, 0x40(%rbx)
movq -0x40(%rbp), %rax
movq %rax, 0x48(%rbx)
xorpd %xmm0, %xmm0
movapd %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
testq %rdi, %rdi
je 0x18fa
subq %rdi, %rsi
callq 0x10d0
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x18fa
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
leaq -0x50(%rbp), %rdi
leaq -0x80(%rbp), %rdx
movq %r15, %rsi
callq 0x2ab8
movq 0x58(%rbx), %rdi
movq 0x68(%rbx), %rsi
movq -0x50(%rbp), %rax
movq %rax, 0x58(%rbx)
movq -0x48(%rbp), %rax
movq %rax, 0x60(%rbx)
movq -0x40(%rbp), %rax
movq %rax, 0x68(%rbx)
xorpd %xmm0, %xmm0
movapd %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
testq %rdi, %rdi
je 0x195d
subq %rdi, %rsi
callq 0x10d0
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x195d
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movslq 0x8(%rbx), %r13
leaq -0x68(%rbp), %rdi
leaq -0x2a(%rbp), %rdx
movq %r15, %rsi
callq 0x2ab8
leaq -0x80(%rbp), %rdi
leaq -0x68(%rbp), %rdx
leaq -0x29(%rbp), %rcx
movq %r13, %rsi
callq 0x2b50
movupd 0x90(%rbx), %xmm0
movq 0xa0(%rbx), %rax
leaq -0x80(%rbp), %r13
movq (%r13), %rcx
movq %rcx, 0x90(%rbx)
movq 0x8(%r13), %rcx
movq %rcx, 0x98(%rbx)
movq 0x10(%r13), %rcx
movq %rcx, 0xa0(%rbx)
leaq -0x50(%rbp), %rdi
movupd %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%r13)
movq $0x0, 0x10(%r13)
callq 0x164c
movq %r13, %rdi
callq 0x164c
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x19f9
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movslq 0x8(%rbx), %r13
leaq -0x68(%rbp), %rdi
leaq -0x2a(%rbp), %rdx
movq %r15, %rsi
callq 0x2ab8
leaq -0x80(%rbp), %rdi
leaq -0x68(%rbp), %rdx
leaq -0x29(%rbp), %rcx
movq %r13, %rsi
callq 0x2b50
movupd 0x78(%rbx), %xmm0
movq 0x88(%rbx), %rax
leaq -0x80(%rbp), %r13
movq (%r13), %rcx
movq %rcx, 0x78(%rbx)
movq 0x8(%r13), %rcx
movq %rcx, 0x80(%rbx)
movq 0x10(%r13), %rcx
movq %rcx, 0x88(%rbx)
leaq -0x50(%rbp), %rdi
movupd %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%r13)
movq $0x0, 0x10(%r13)
callq 0x164c
movq %r13, %rdi
callq 0x164c
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x1a8f
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movslq 0x8(%rbx), %rsi
leaq -0x50(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x2ab8
movq 0xa8(%rbx), %rdi
movq 0xb8(%rbx), %rsi
movq -0x50(%rbp), %rax
movq %rax, 0xa8(%rbx)
movq -0x48(%rbp), %rax
movq %rax, 0xb0(%rbx)
movq -0x40(%rbp), %rax
movq %rax, 0xb8(%rbx)
xorpd %xmm0, %xmm0
movapd %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
testq %rdi, %rdi
je 0x1b02
subq %rdi, %rsi
callq 0x10d0
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x1b02
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
leaq -0x50(%rbp), %rdi
leaq -0x80(%rbp), %rdx
movq %r15, %rsi
callq 0x2ab8
movq 0xd0(%rbx), %rdi
movq 0xe0(%rbx), %rsi
movq -0x50(%rbp), %rax
movq %rax, 0xd0(%rbx)
movq -0x48(%rbp), %rax
movq %rax, 0xd8(%rbx)
movq -0x40(%rbp), %rax
movq %rax, 0xe0(%rbx)
xorpd %xmm0, %xmm0
movapd %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
testq %rdi, %rdi
je 0x1b74
subq %rdi, %rsi
callq 0x10d0
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x1b74
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movq 0x38(%rbx), %rdi
testq %r15, %r15
je 0x1b92
xorl %eax, %eax
movsd (%r12,%rax,8), %xmm0
movsd %xmm0, (%rdi,%rax,8)
incq %rax
cmpq %rax, %r15
jne 0x1b7f
incl 0x34(%rbx)
movq 0x58(%rbx), %rsi
movq 0x40(%rbx), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
callq *(%rbx)
movsd %xmm0, 0x50(%rbx)
leaq -0x98(%rbp), %rdi
movq %r14, %rsi
callq 0x2a38
leaq -0x98(%rbp), %rdi
callq 0x1724
movq %r15, %xmm1
punpckldq 0x146d(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1475(%rip), %xmm1     # 0x3050
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
xorps %xmm1, %xmm1
sqrtsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x70(%rbx)
movq -0x98(%rbp), %rdi
testq %rdi, %rdi
je 0x1c12
movq -0x88(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq -0x98(%rbp), %rdi
testq %rdi, %rdi
je 0x1c64
movq -0x88(%rbp), %rsi
jmp 0x1c51
jmp 0x1c61
jmp 0x1c61
jmp 0x1c41
jmp 0x1c61
movq %rax, %r15
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x1c64
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
jmp 0x1c64
jmp 0x1c61
jmp 0x1c61
jmp 0x1c61
movq %rax, %r15
leaq 0xd0(%rbx), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1c82
movq 0xe0(%rbx), %rsi
subq %rdi, %rsi
callq 0x10d0
leaq 0x78(%rbx), %r12
leaq 0x90(%rbx), %r13
movq 0xa8(%rbx), %rdi
testq %rdi, %rdi
je 0x1ca8
movq 0xb8(%rbx), %rsi
subq %rdi, %rsi
callq 0x10d0
movq %r13, %rdi
callq 0x164c
movq %r12, %rdi
callq 0x164c
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1ccc
movq 0x68(%rbx), %rsi
subq %rdi, %rsi
callq 0x10d0
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x1ce1
movq 0x48(%rbx), %rsi
subq %rdi, %rsi
callq 0x10d0
movq %r15, %rdi
callq 0x1160
nop