// File: /workspace/github_cpp_makefile_star2_O2/redpony[P]libpopt/optimize_test.cc
// Function: TestOptimizer(Optimizer*)
double TestOptimizer(Optimizer* opt) {
  cerr << "TESTING NON-PERSISTENT OPTIMIZER\n";

  // f(x,y) = 4x1^2 + x1*x2 + x2^2 + x3^2 + 6x3 + 5
  // df/dx1 = 8*x1 + x2
  // df/dx2 = 2*x2 + x1
  // df/dx3 = 2*x3 + 6
  vector<double> x(3);
  vector<double> g(3);
  x[0] = 8;
  x[1] = 8;
  x[2] = 8;
  double obj = 0;
  do {
    g[0] = 8 * x[0] + x[1];
    g[1] = 2 * x[1] + x[0];
    g[2] = 2 * x[2] + 6;
    obj = 4 * x[0]*x[0] + x[0] * x[1] + x[1]*x[1] + x[2]*x[2] + 6 * x[2] + 5;
    opt->Optimize(obj, g, &x);

    cerr << x[0] << " " << x[1] << " " << x[2] << endl;
    cerr << "   obj=" << obj << "\td/dx1=" << g[0] << " d/dx2=" << g[1] << " d/dx3=" << g[2] << endl;
  } while (!opt->HasConverged());
  return obj;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0x8b5c(%rip), %rdi      # 0xbff0
leaq 0x4bfd(%rip), %rsi      # 0x8098
callq 0x3190
leaq 0x28(%rsp), %rdi
pushq $0x3
popq %r14
leaq 0x10(%rsp), %rdx
movq %r14, %rsi
callq 0x3aec
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
movq %r14, %rsi
callq 0x3aec
leaq 0x28(%rsp), %rax
movq (%rax), %rax
movapd 0x4b38(%rip), %xmm0     # 0x8010
movupd %xmm0, (%rax)
movabsq $0x4020000000000000, %rcx # imm = 0x4020000000000000
movq %rcx, 0x10(%rax)
leaq 0x8(%rsp), %rax
andq $0x0, (%rax)
movq 0x8af6(%rip), %r13      # 0xbff0
leaq 0x4db9(%rip), %rbp      # 0x82ba
leaq 0x4bba(%rip), %r12      # 0x80c2
leaq 0x4bbb(%rip), %r15      # 0x80ca
leaq 0x4bbc(%rip), %r14      # 0x80d2
movq 0x28(%rsp), %rax
movsd (%rax), %xmm0
mulsd 0x4b09(%rip), %xmm0     # 0x8030
addsd 0x8(%rax), %xmm0
movq 0x10(%rsp), %rcx
movsd %xmm0, (%rcx)
movsd 0x8(%rax), %xmm0
addsd %xmm0, %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x8(%rcx)
movsd 0x10(%rax), %xmm0
addsd %xmm0, %xmm0
movsd 0x4ae0(%rip), %xmm3     # 0x8038
addsd %xmm3, %xmm0
movsd %xmm0, 0x10(%rcx)
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movapd %xmm0, %xmm2
mulsd 0x4aca(%rip), %xmm2     # 0x8040
mulsd %xmm0, %xmm2
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
movsd 0x10(%rax), %xmm0
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
addsd %xmm1, %xmm2
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
addsd 0x4a9d(%rip), %xmm0     # 0x8048
movsd %xmm0, 0x8(%rsp)
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x28(%rsp), %rcx
callq 0x3b3e
movq 0x28(%rsp), %rax
movsd (%rax), %xmm0
movq %r13, %rdi
callq 0x3270
movq %rax, %rdi
movq %rbp, %rsi
callq 0x3190
movq 0x28(%rsp), %rcx
movsd 0x8(%rcx), %xmm0
movq %rax, %rdi
callq 0x3270
movq %rax, %rdi
movq %rbp, %rsi
callq 0x3190
movq 0x28(%rsp), %rcx
movsd 0x10(%rcx), %xmm0
movq %rax, %rdi
callq 0x3270
movq %rax, %rdi
callq 0x30c0
movq %r13, %rdi
leaq 0x4a95(%rip), %rsi      # 0x80ba
callq 0x3190
movsd 0x8(%rsp), %xmm0
movq %rax, %rdi
callq 0x3270
movq %rax, %rdi
movq %r12, %rsi
callq 0x3190
movq 0x10(%rsp), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x3270
movq %rax, %rdi
movq %r15, %rsi
callq 0x3190
movq 0x10(%rsp), %rcx
movsd 0x8(%rcx), %xmm0
movq %rax, %rdi
callq 0x3270
movq %rax, %rdi
movq %r14, %rsi
callq 0x3190
movq 0x10(%rsp), %rcx
movsd 0x10(%rcx), %xmm0
movq %rax, %rdi
callq 0x3270
movq %rax, %rdi
callq 0x30c0
cmpb $0x1, 0xc(%rbx)
jne 0x3516
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x4682
leaq 0x28(%rsp), %rdi
callq 0x4682
movsd 0x40(%rsp), %xmm0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x36e7
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4682
leaq 0x28(%rsp), %rdi
callq 0x4682
movq %rbx, %rdi
callq 0x32e0