// File: /workspace/github_cpp_makefile_star2_O3/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 0x9b2c(%rip), %rdi      # 0xcff0
leaq 0x5bfd(%rip), %rsi      # 0x90c8
movl $0x21, %edx
callq 0x31f0
movl $0x18, %edi
callq 0x31c0
movq %rax, %r15
movq %rax, 0x10(%rsp)
addq $0x18, %rax
movq %rax, 0x20(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%r15)
movq $0x0, 0x10(%r15)
movq %rax, 0x18(%rsp)
movl $0x18, %edi
callq 0x31c0
leaq 0x28(%rsp), %r14
movq %rax, (%r14)
movq %rax, %rcx
addq $0x18, %rcx
movq %rcx, 0x10(%r14)
xorl %edx, %edx
movq %rdx, 0x10(%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq %rcx, 0x8(%r14)
movapd 0x5ad3(%rip), %xmm0     # 0x9010
movupd %xmm0, (%r15)
movabsq $0x4020000000000000, %rax # imm = 0x4020000000000000
movq %rax, 0x10(%r15)
leaq 0x8(%rsp), %rax
movq %rdx, (%rax)
movq 0x9a91(%rip), %r13      # 0xcff0
leaq 0x5d84(%rip), %rbp      # 0x92ea
leaq 0x5b95(%rip), %r15      # 0x9102
movq 0x10(%rsp), %rax
movsd (%rax), %xmm0
mulsd 0x5ae2(%rip), %xmm0     # 0x9060
addsd 0x8(%rax), %xmm0
movq 0x28(%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 0x5ab9(%rip), %xmm3     # 0x9068
addsd %xmm3, %xmm0
movsd %xmm0, 0x10(%rcx)
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movapd %xmm0, %xmm2
mulsd 0x5aa3(%rip), %xmm2     # 0x9070
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 0x5a76(%rip), %xmm0     # 0x9078
movsd %xmm0, 0x8(%rsp)
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
movq %r14, %rdx
leaq 0x10(%rsp), %rcx
callq 0x3daa
movq 0x10(%rsp), %rax
movsd (%rax), %xmm0
movq %r13, %rdi
callq 0x3290
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x31f0
movq 0x10(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq %r12, %rdi
callq 0x3290
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x31f0
movq 0x10(%rsp), %rax
movsd 0x10(%rax), %xmm0
movq %r12, %rdi
callq 0x3290
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movl $0x7, %edx
movq %r13, %rdi
leaq 0x5a39(%rip), %rsi      # 0x90ea
callq 0x31f0
movsd 0x8(%rsp), %xmm0
movq %r13, %rdi
callq 0x3290
movq %rax, %r12
movl $0x7, %edx
movq %rax, %rdi
leaq 0x5a1c(%rip), %rsi      # 0x90f2
callq 0x31f0
movq 0x28(%rsp), %rax
movsd (%rax), %xmm0
movq %r12, %rdi
callq 0x3290
movq %rax, %r12
movl $0x7, %edx
movq %rax, %rdi
leaq 0x59fc(%rip), %rsi      # 0x90fa
callq 0x31f0
movq 0x28(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq %r12, %rdi
callq 0x3290
movq %rax, %r12
movl $0x7, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x31f0
movq 0x28(%rsp), %rax
movsd 0x10(%rax), %xmm0
movq %r12, %rdi
callq 0x3290
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
cmpb $0x1, 0xc(%rbx)
jne 0x356d
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x3791
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x31d0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x37a8
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x31d0
movsd 0x40(%rsp), %xmm0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x37dc
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x37dc
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x31d0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x37f3
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x31d0
movq %rbx, %rdi
callq 0x3300