// File: /workspace/github_cpp_makefile_star2_O1/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
xorl %r14d, %r14d
movq %r14, 0x10(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movl $0x18, %edi
callq 0x31c0
movq %rax, (%rsp)
movq %rax, 0x8(%rsp)
leaq 0x18(%rax), %rcx
movq %rcx, 0x10(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq %r14, 0x10(%rax)
movq %rcx, 0x8(%rsp)
movq %r14, 0x30(%rsp)
movapd %xmm0, 0x20(%rsp)
movl $0x18, %edi
callq 0x31c0
leaq 0x20(%rsp), %r14
movq %rax, (%r14)
movq %rax, 0x8(%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)
movq %rsp, %rax
movq (%rax), %rax
movapd 0x5ab1(%rip), %xmm0     # 0x9010
movupd %xmm0, (%rax)
movabsq $0x4020000000000000, %rcx # imm = 0x4020000000000000
movq %rcx, 0x10(%rax)
leaq 0x18(%rsp), %rax
movq %rdx, (%rax)
movq 0x9a70(%rip), %r13      # 0xcff0
leaq 0x5d63(%rip), %rbp      # 0x92ea
leaq 0x5b74(%rip), %r12      # 0x9102
movq (%rsp), %rax
movsd (%rax), %xmm0
mulsd 0x5ac2(%rip), %xmm0     # 0x9060
addsd 0x8(%rax), %xmm0
movq 0x20(%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 0x5a99(%rip), %xmm3     # 0x9068
addsd %xmm3, %xmm0
movsd %xmm0, 0x10(%rcx)
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movapd %xmm0, %xmm2
mulsd 0x5a83(%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 0x5a56(%rip), %xmm0     # 0x9078
movsd %xmm0, 0x18(%rsp)
movq %rbx, %rdi
leaq 0x18(%rsp), %rsi
movq %r14, %rdx
movq %rsp, %rcx
callq 0x3dca
movq (%rsp), %rax
movsd (%rax), %xmm0
movq %r13, %rdi
callq 0x3290
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x31f0
movq (%rsp), %rax
movsd 0x8(%rax), %xmm0
movq %r15, %rdi
callq 0x3290
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x31f0
movq (%rsp), %rax
movsd 0x10(%rax), %xmm0
movq %r15, %rdi
callq 0x3290
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movl $0x7, %edx
movq %r13, %rdi
leaq 0x5a1e(%rip), %rsi      # 0x90ea
callq 0x31f0
movsd 0x18(%rsp), %xmm0
movq %r13, %rdi
callq 0x3290
movq %rax, %r15
movl $0x7, %edx
movq %rax, %rdi
leaq 0x5a01(%rip), %rsi      # 0x90f2
callq 0x31f0
movq 0x20(%rsp), %rax
movsd (%rax), %xmm0
movq %r15, %rdi
callq 0x3290
movq %rax, %r15
movl $0x7, %edx
movq %rax, %rdi
leaq 0x59e1(%rip), %rsi      # 0x90fa
callq 0x31f0
movq 0x20(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq %r15, %rdi
callq 0x3290
movq %rax, %r15
movl $0x7, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x31f0
movq 0x20(%rsp), %rax
movsd 0x10(%rax), %xmm0
movq %r15, %rdi
callq 0x3290
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
cmpb $0x1, 0xc(%rbx)
jne 0x358e
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x37ac
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x31d0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x37c2
movq 0x10(%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 0x37f6
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x37f6
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x31d0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x380c
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x31d0
movq %rbx, %rdi
callq 0x3300