// File: js850[P]lbfgs_cpp/example.cpp
// Function: main
int main(){
  int N = 3;
  int M = 4;
  vector<double> x0(N);

  x0[0] = .13;
  x0[1] = 1.23;
  x0[2] = -5.03;

  LBFGS_ns::LBFGS lbfgs(&func2, &x0[0], N, M);
  lbfgs.set_max_iter(30);
  lbfgs.set_iprint(1);
  lbfgs.run();
  
  double const * x = lbfgs.get_x();
  cout << "final result:\n";
  cout << "x: " << x[0] << " " << x[1] << " " << x[2] << "\n";
  cout << "f: " << lbfgs.get_f() << "\n";
  cout << "rms: " << lbfgs.get_rms() << "\n";
  cout << "nfev: " << lbfgs.get_nfev() << "\n";
  cout << "success: " << lbfgs.success() << "\n";

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movl $0x3, -0x4(%rbp)
movl $0x4, -0x8(%rbp)
movslq -0x4(%rbp), %rax
movq %rax, -0x138(%rbp)
leaq -0x21(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x17b0
movq -0x138(%rbp), %rsi
movq -0x130(%rbp), %rdx
leaq -0x20(%rbp), %rdi
callq 0x17d0
jmp 0x13cd
leaq -0x21(%rbp), %rdi
callq 0x1840
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x140(%rbp)
leaq -0x20(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x1860
movq -0x148(%rbp), %rdi
movabsq $0x3fc0a3d70a3d70a4, %rcx # imm = 0x3FC0A3D70A3D70A4
movq %rcx, (%rax)
movl $0x1, %esi
callq 0x1860
movq -0x148(%rbp), %rdi
movabsq $0x3ff3ae147ae147ae, %rcx # imm = 0x3FF3AE147AE147AE
movq %rcx, (%rax)
movl $0x2, %esi
callq 0x1860
movq -0x148(%rbp), %rdi
movq -0x140(%rbp), %rsi
movabsq $-0x3febe147ae147ae1, %rcx # imm = 0xC0141EB851EB851F
movq %rcx, (%rax)
callq 0x1860
movq %rax, %rdx
movslq -0x4(%rbp), %rcx
movl -0x8(%rbp), %r8d
leaq -0x16f(%rip), %rsi      # 0x12f0
leaq -0x120(%rbp), %rdi
callq 0x25d0
jmp 0x146d
leaq -0x120(%rbp), %rdi
movl $0x1e, %esi
callq 0x1880
jmp 0x1480
leaq -0x120(%rbp), %rdi
movl $0x1, %esi
callq 0x18a0
jmp 0x1493
leaq -0x120(%rbp), %rdi
callq 0x4050
jmp 0x14a1
leaq -0x120(%rbp), %rdi
callq 0x18c0
movq %rax, -0x150(%rbp)
jmp 0x14b6
movq -0x150(%rbp), %rax
movq %rax, -0x128(%rbp)
movq 0x8b0d(%rip), %rdi      # 0x9fd8
leaq 0x4b3e(%rip), %rsi      # 0x6010
callq 0x10b0
jmp 0x14d9
movq 0x8af8(%rip), %rdi      # 0x9fd8
leaq 0x4b38(%rip), %rsi      # 0x601f
callq 0x10b0
movq %rax, -0x158(%rbp)
jmp 0x14f5
movq -0x158(%rbp), %rdi
movq -0x128(%rbp), %rax
movsd (%rax), %xmm0
callq 0x1160
movq %rax, -0x160(%rbp)
jmp 0x1515
movq -0x160(%rbp), %rdi
leaq 0x4ca0(%rip), %rsi      # 0x61c3
callq 0x10b0
movq %rax, -0x168(%rbp)
jmp 0x1531
movq -0x168(%rbp), %rdi
movq -0x128(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0x1160
movq %rax, -0x170(%rbp)
jmp 0x1552
movq -0x170(%rbp), %rdi
leaq 0x4c63(%rip), %rsi      # 0x61c3
callq 0x10b0
movq %rax, -0x178(%rbp)
jmp 0x156e
movq -0x178(%rbp), %rdi
movq -0x128(%rbp), %rax
movsd 0x10(%rax), %xmm0
callq 0x1160
movq %rax, -0x180(%rbp)
jmp 0x158f
movq -0x180(%rbp), %rdi
leaq 0x4ba7(%rip), %rsi      # 0x6144
callq 0x10b0
jmp 0x15a4
movq 0x8a2d(%rip), %rdi      # 0x9fd8
leaq 0x4a71(%rip), %rsi      # 0x6023
callq 0x10b0
movq %rax, -0x188(%rbp)
jmp 0x15c0
leaq -0x120(%rbp), %rdi
callq 0x18f0
movsd %xmm0, -0x190(%rbp)
jmp 0x15d6
movsd -0x190(%rbp), %xmm0
movq -0x188(%rbp), %rdi
callq 0x1160
movq %rax, -0x198(%rbp)
jmp 0x15f3
movq -0x198(%rbp), %rdi
leaq 0x4b43(%rip), %rsi      # 0x6144
callq 0x10b0
jmp 0x1608
movq 0x89c9(%rip), %rdi      # 0x9fd8
leaq 0x4a11(%rip), %rsi      # 0x6027
callq 0x10b0
movq %rax, -0x1a0(%rbp)
jmp 0x1624
leaq -0x120(%rbp), %rdi
callq 0x1910
movsd %xmm0, -0x1a8(%rbp)
jmp 0x163a
movsd -0x1a8(%rbp), %xmm0
movq -0x1a0(%rbp), %rdi
callq 0x1160
movq %rax, -0x1b0(%rbp)
jmp 0x1657
movq -0x1b0(%rbp), %rdi
leaq 0x4adf(%rip), %rsi      # 0x6144
callq 0x10b0
jmp 0x166c
movq 0x8965(%rip), %rdi      # 0x9fd8
leaq 0x49b3(%rip), %rsi      # 0x602d
callq 0x10b0
movq %rax, -0x1b8(%rbp)
jmp 0x1688
leaq -0x120(%rbp), %rdi
callq 0x1930
movl %eax, -0x1bc(%rbp)
jmp 0x169c
movl -0x1bc(%rbp), %esi
movq -0x1b8(%rbp), %rdi
callq 0x1130
movq %rax, -0x1c8(%rbp)
jmp 0x16b7
movq -0x1c8(%rbp), %rdi
leaq 0x4a7f(%rip), %rsi      # 0x6144
callq 0x10b0
jmp 0x16cc
movq 0x8905(%rip), %rdi      # 0x9fd8
leaq 0x495a(%rip), %rsi      # 0x6034
callq 0x10b0
movq %rax, -0x1d0(%rbp)
jmp 0x16e8
leaq -0x120(%rbp), %rdi
callq 0x1950
movb %al, -0x1d1(%rbp)
jmp 0x16fc
movq -0x1d0(%rbp), %rdi
movb -0x1d1(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x1150
movq %rax, -0x1e0(%rbp)
jmp 0x171d
movq -0x1e0(%rbp), %rdi
leaq 0x4a19(%rip), %rsi      # 0x6144
callq 0x10b0
jmp 0x1732
leaq -0x120(%rbp), %rdi
callq 0x1970
leaq -0x20(%rbp), %rdi
callq 0x19e0
xorl %eax, %eax
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x21(%rbp), %rdi
callq 0x1840
jmp 0x1798
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x178f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x1970
leaq -0x20(%rbp), %rdi
callq 0x19e0
movq -0x30(%rbp), %rdi
callq 0x1140
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)