// File: /workspace/github_cpp_makefile_star2_O1/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 $0x88, %rsp
movq %rcx, %r12
movq %rdx, %r13
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 0x38(%rdi), %r15
leaq 0x58(%rdi), %rax
movq %rax, -0x38(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x58(%rdi)
xorl %eax, %eax
movq %rax, 0x68(%rdi)
leaq 0xa8(%rdi), %rcx
movq %rcx, -0x80(%rbp)
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)
leaq 0xd0(%rdi), %rcx
movq %rcx, -0x70(%rbp)
movq %rax, 0xe0(%rdi)
movupd %xmm0, 0xd0(%rdi)
movq 0x3730(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0xc, 0x8(%rax,%rcx)
leaq -0x50(%rbp), %rdi
leaq -0x98(%rbp), %rdx
movq %r12, %rsi
movq %r15, -0x78(%rbp)
callq 0x2a7e
leaq -0x50(%rbp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x2cf4
movq (%r14), %rdi
testq %rdi, %rdi
je 0x18f2
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
leaq -0x50(%rbp), %rdi
leaq -0x98(%rbp), %rdx
movq %r12, %rsi
movq -0x38(%rbp), %r15
callq 0x2a7e
movq %r15, %rdi
movq %r14, %rsi
callq 0x2cf4
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1928
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movslq 0x8(%rbx), %r14
leaq -0x68(%rbp), %rdi
leaq -0x2a(%rbp), %rdx
movq %r12, %rsi
callq 0x2a7e
leaq -0x98(%rbp), %rdi
leaq -0x68(%rbp), %rdx
leaq -0x29(%rbp), %rcx
movq %r14, %rsi
callq 0x2b12
xorpd %xmm0, %xmm0
leaq -0x50(%rbp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x90(%rbx), %rax
movupd 0x98(%rbx), %xmm0
leaq -0x98(%rbp), %r14
movq (%r14), %rcx
movq %rcx, 0x90(%rbx)
movq 0x8(%r14), %rcx
movq %rcx, 0x98(%rbx)
movq 0x10(%r14), %rcx
movq %rcx, 0xa0(%rbx)
movq (%rdi), %rcx
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rsi
movq %rax, (%rdi)
movupd %xmm0, 0x8(%rdi)
movq %rcx, (%r14)
movq %rdx, 0x8(%r14)
movq %rsi, 0x10(%r14)
callq 0x1652
movq %r14, %rdi
callq 0x1652
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x19dd
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movslq 0x8(%rbx), %r14
leaq -0x68(%rbp), %rdi
leaq -0x2a(%rbp), %rdx
movq %r12, %rsi
callq 0x2a7e
leaq -0x98(%rbp), %rdi
leaq -0x68(%rbp), %rdx
leaq -0x29(%rbp), %rcx
movq %r14, %rsi
callq 0x2b12
xorpd %xmm0, %xmm0
leaq -0x50(%rbp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x78(%rbx), %rax
movupd 0x80(%rbx), %xmm0
leaq -0x98(%rbp), %r14
movq (%r14), %rcx
movq %rcx, 0x78(%rbx)
movq 0x8(%r14), %rcx
movq %rcx, 0x80(%rbx)
movq 0x10(%r14), %rcx
movq %rcx, 0x88(%rbx)
movq (%rdi), %rcx
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rsi
movq %rax, (%rdi)
movupd %xmm0, 0x8(%rdi)
movq %rcx, (%r14)
movq %rdx, 0x8(%r14)
movq %rsi, 0x10(%r14)
callq 0x1652
movq %r14, %rdi
callq 0x1652
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x1a8c
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
movslq 0x8(%rbx), %rsi
leaq -0x50(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0x2a7e
leaq -0x50(%rbp), %r14
movq -0x80(%rbp), %rdi
movq %r14, %rsi
callq 0x2cf4
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1ac4
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
leaq -0x50(%rbp), %rdi
leaq -0x98(%rbp), %rdx
movq %r12, %rsi
callq 0x2a7e
movq -0x70(%rbp), %rdi
movq %r14, %rsi
callq 0x2cf4
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1af7
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
testq %r12, %r12
movq -0x78(%rbp), %rax
je 0x1b19
movq (%rax), %rax
xorl %ecx, %ecx
movsd (%r13,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %r12
jne 0x1b05
incl 0x34(%rbx)
movq 0x38(%rbx), %rdi
movq 0x58(%rbx), %rsi
movq 0x40(%rbx), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
callq *(%rbx)
movsd %xmm0, 0x50(%rbx)
leaq -0xb0(%rbp), %rdi
movq %r15, %rsi
callq 0x29fe
leaq -0xb0(%rbp), %rdi
callq 0x1724
movapd %xmm0, %xmm2
movq %r12, %xmm1
punpckldq 0x14de(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x14e6(%rip), %xmm1     # 0x3050
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1b86
sqrtsd %xmm0, %xmm0
jmp 0x1b95
movsd %xmm2, -0x38(%rbp)
callq 0x10a0
movsd -0x38(%rbp), %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, 0x70(%rbx)
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x1bb9
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r12
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x1c0e
movq -0xa0(%rbp), %rsi
jmp 0x1bfb
jmp 0x1c0b
jmp 0x1c0b
jmp 0x1beb
jmp 0x1c0b
movq %rax, %r12
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x1c0e
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x10d0
jmp 0x1c0e
jmp 0x1c0b
jmp 0x1c0b
jmp 0x1c0b
movq %rax, %r12
movq -0x70(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1c29
movq 0xe0(%rbx), %rsi
subq %rdi, %rsi
callq 0x10d0
leaq 0x78(%rbx), %r13
leaq 0x90(%rbx), %r14
movq -0x80(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1c4f
movq 0xb8(%rbx), %rsi
subq %rdi, %rsi
callq 0x10d0
movq %r14, %rdi
callq 0x1652
movq %r13, %rdi
callq 0x1652
movq -0x38(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1c77
movq 0x68(%rbx), %rsi
subq %rdi, %rsi
callq 0x10d0
movq -0x78(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1c8f
movq 0x48(%rbx), %rsi
subq %rdi, %rsi
callq 0x10d0
movq %r12, %rdi
callq 0x1160
nop