#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int bfgs_l_min(double (*)(double *, int), void (*)(double *, int, double *),
               double *, int, int, double *, double, int, int *, double, double,
               double, double, double *);
int bfgs_min(double (*)(double *, int), void (*)(double *, int, double *),
             double *, int, double *, double, int, int *, double, double,
             double, double *);
int conjgrad_min_lin(double (*)(double *, int),
                     void (*)(double *, int, double *), double *, int, double *,
                     int, int *, double, double, double, double, double *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(double *);
double macheps();
scalar_t__ malloc(int);
int mvalue(int);
int nel_min(double (*)(double *, int), double *, int, double *, double, int,
            int *, double, double *);
int newton_min_func(double (*)(double *, int),
                    void (*)(double *, int, double *), double *, int, double *,
                    double, int, int *, double, double, double, double *);
int newton_min_trust(double (*)(double *, int),
                     void (*)(double *, int, double *), double *, int, double *,
                     double, double, int, int, int *, double, double, double,
                     double *);
double pow(double, double);
int /*<<< orphan*/ printf(char *);
int fminunc(double (*funcpt)(double *, int),
            void (*funcgrad)(double *, int, double *), int N, double *xi,
            int method, double *xf) {
  int i, retval, MAXITER, niter, m;
  double fsval, eps, gtol, stol, ftol, xtol, delta;
  double *dx;
  dx = (double *)malloc(sizeof(double) * N);
  fsval = 1.0;
  MAXITER = 200 * N;
  niter = 0;
  delta = -1.0;
  eps = macheps();
  for (i = 0; i < N; ++i) {
    dx[i] = 1.0;
  }
  if (method == 0) {
    retval = nel_min(funcpt, xi, N, dx, fsval, MAXITER, &niter, eps, xf);
  } else if (method == 1) {
    gtol = pow(eps, 1.0 / 3.0);
    stol = gtol * gtol;
    if (MAXITER < 1000) {
      MAXITER = 1000;
    }
    retval = newton_min_func(funcpt, funcgrad, xi, N, dx, fsval, MAXITER,
                             &niter, eps, gtol, stol, xf);
  } else if (method == 2) {
    gtol = pow(eps, 1.0 / 3.0);
    stol = gtol * gtol;
    if (MAXITER < 1000) {
      MAXITER = 1000;
    }
    retval = newton_min_trust(funcpt, funcgrad, xi, N, dx, fsval, delta, 0,
                              MAXITER, &niter, eps, gtol, stol, xf);
  } else if (method == 3) {
    gtol = pow(eps, 1.0 / 3.0);
    stol = gtol * gtol;
    if (MAXITER < 1000) {
      MAXITER = 1000;
    }
    retval = newton_min_trust(funcpt, funcgrad, xi, N, dx, fsval, delta, 1,
                              MAXITER, &niter, eps, gtol, stol, xf);
  } else if (method == 4) {
    gtol = pow(eps, 1.0 / 3.0);
    ftol = gtol * gtol;
    xtol = eps;
    if (MAXITER < 1000) {
      MAXITER = 1000;
    }
    retval = conjgrad_min_lin(funcpt, funcgrad, xi, N, dx, MAXITER, &niter, eps,
                              gtol, ftol, xtol, xf);
  } else if (method == 5) {
    gtol = pow(eps, 1.0 / 3.0);
    stol = gtol * gtol;
    if (MAXITER < 1000) {
      MAXITER = 1000;
    }
    retval = bfgs_min(funcpt, funcgrad, xi, N, dx, fsval, MAXITER, &niter, eps,
                      gtol, stol, xf);
  } else if (method == 6) {
    gtol = pow(eps, 1.0 / 3.0);
    ftol = gtol * gtol;
    xtol = eps;
    if (MAXITER < 1000) {
      MAXITER = 1000;
    }
    m = mvalue(N);
    retval = bfgs_l_min(funcpt, funcgrad, xi, N, m, dx, fsval, MAXITER, &niter,
                        eps, gtol, ftol, xtol, xf);
  } else {
    printf("Method Value should be one of 0,1,2,3,4,5 or 6. See Documentation. "
           "\n");
    exit(1);
  }
  free(dx);
  return retval;
}


x86 assembly (clang, -O0):
<fminunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x88(%rbp)
movsd  0xdf8(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
imul   $0xc8,-0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movsd  0xdd2(%rip),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    $0x0,%al
call   10d0 <macheps@plt>
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1278 <fminunc+0xa8>
mov    -0x88(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  0xda3(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1246 <fminunc+0x76>
cmpl   $0x0,-0x24(%rbp)
jne    12bb <fminunc+0xeb>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x88(%rbp),%rcx
movsd  -0x50(%rbp),%xmm0
mov    -0x3c(%rbp),%r8d
movsd  -0x58(%rbp),%xmm1
mov    -0x30(%rbp),%rax
lea    -0x40(%rbp),%r9
mov    %rax,(%rsp)
call   1090 <nel_min@plt>
mov    %eax,-0x38(%rbp)
jmp    1699 <fminunc+0x4c9>
cmpl   $0x1,-0x24(%rbp)
jne    134b <fminunc+0x17b>
movsd  -0x58(%rbp),%xmm0
movsd  0xd3e(%rip),%xmm1
call   10e0 <pow@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
cmpl   $0x3e8,-0x3c(%rbp)
jge    12ff <fminunc+0x12f>
movl   $0x3e8,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x88(%rbp),%r8
movsd  -0x50(%rbp),%xmm0
mov    -0x3c(%rbp),%r9d
movsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm3
mov    -0x30(%rbp),%rax
lea    -0x40(%rbp),%r10
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1080 <newton_min_func@plt>
mov    %eax,-0x38(%rbp)
jmp    1694 <fminunc+0x4c4>
cmpl   $0x2,-0x24(%rbp)
jne    13e8 <fminunc+0x218>
movsd  -0x58(%rbp),%xmm0
movsd  0xcae(%rip),%xmm1
call   10e0 <pow@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
cmpl   $0x3e8,-0x3c(%rbp)
jge    138f <fminunc+0x1bf>
movl   $0x3e8,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x88(%rbp),%r8
movsd  -0x50(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
mov    -0x3c(%rbp),%r11d
movsd  -0x58(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm3
movsd  -0x68(%rbp),%xmm4
mov    -0x30(%rbp),%rax
xor    %r9d,%r9d
lea    -0x40(%rbp),%r10
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1070 <newton_min_trust@plt>
mov    %eax,-0x38(%rbp)
jmp    168f <fminunc+0x4bf>
cmpl   $0x3,-0x24(%rbp)
jne    1488 <fminunc+0x2b8>
movsd  -0x58(%rbp),%xmm0
movsd  0xc11(%rip),%xmm1
call   10e0 <pow@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
cmpl   $0x3e8,-0x3c(%rbp)
jge    142c <fminunc+0x25c>
movl   $0x3e8,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x88(%rbp),%r8
movsd  -0x50(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
mov    -0x3c(%rbp),%r11d
movsd  -0x58(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm3
movsd  -0x68(%rbp),%xmm4
mov    -0x30(%rbp),%rax
mov    $0x1,%r9d
lea    -0x40(%rbp),%r10
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1070 <newton_min_trust@plt>
mov    %eax,-0x38(%rbp)
jmp    168a <fminunc+0x4ba>
cmpl   $0x4,-0x24(%rbp)
jne    1522 <fminunc+0x352>
movsd  -0x58(%rbp),%xmm0
movsd  0xb71(%rip),%xmm1
call   10e0 <pow@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
cmpl   $0x3e8,-0x3c(%rbp)
jge    14d6 <fminunc+0x306>
movl   $0x3e8,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x88(%rbp),%r8
mov    -0x3c(%rbp),%r9d
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm3
mov    -0x30(%rbp),%rax
lea    -0x40(%rbp),%r10
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <conjgrad_min_lin@plt>
mov    %eax,-0x38(%rbp)
jmp    1685 <fminunc+0x4b5>
cmpl   $0x5,-0x24(%rbp)
jne    15b2 <fminunc+0x3e2>
movsd  -0x58(%rbp),%xmm0
movsd  0xad7(%rip),%xmm1
call   10e0 <pow@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
cmpl   $0x3e8,-0x3c(%rbp)
jge    1566 <fminunc+0x396>
movl   $0x3e8,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x88(%rbp),%r8
movsd  -0x50(%rbp),%xmm0
mov    -0x3c(%rbp),%r9d
movsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm3
mov    -0x30(%rbp),%rax
lea    -0x40(%rbp),%r10
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <bfgs_min@plt>
mov    %eax,-0x38(%rbp)
jmp    1680 <fminunc+0x4b0>
cmpl   $0x6,-0x24(%rbp)
jne    1665 <fminunc+0x495>
movsd  -0x58(%rbp),%xmm0
movsd  0xa47(%rip),%xmm1
call   10e0 <pow@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
cmpl   $0x3e8,-0x3c(%rbp)
jge    1600 <fminunc+0x430>
movl   $0x3e8,-0x3c(%rbp)
mov    -0x14(%rbp),%edi
call   10b0 <mvalue@plt>
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x44(%rbp),%r8d
mov    -0x88(%rbp),%r9
movsd  -0x50(%rbp),%xmm0
mov    -0x3c(%rbp),%r11d
movsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm3
movsd  -0x78(%rbp),%xmm4
mov    -0x30(%rbp),%rax
lea    -0x40(%rbp),%r10
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   10c0 <bfgs_l_min@plt>
mov    %eax,-0x38(%rbp)
jmp    167b <fminunc+0x4ab>
lea    0x9ac(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1680 <fminunc+0x4b0>
jmp    1685 <fminunc+0x4b5>
jmp    168a <fminunc+0x4ba>
jmp    168f <fminunc+0x4bf>
jmp    1694 <fminunc+0x4c4>
jmp    1699 <fminunc+0x4c9>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fminunc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,%rbp
mov    %r8d,%r14d
mov    %rcx,0x18(%rsp)
mov    %edx,%r15d
mov    %rsi,0x20(%rsp)
mov    %rdi,%r12
lea    0x0(,%r15,8),%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
movl   $0x0,0xc(%rsp)
xor    %eax,%eax
call   10d0 <macheps@plt>
movapd %xmm0,%xmm2
test   %r15d,%r15d
jle    134d <fminunc+0x17d>
mov    %r15d,%eax
cmp    $0x4,%r15d
jae    1230 <fminunc+0x60>
xor    %ecx,%ecx
jmp    1329 <fminunc+0x159>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rdi
mov    %rdi,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x7,%edx
cmp    $0x1c,%rdi
jae    1256 <fminunc+0x86>
xor    %edi,%edi
jmp    12f5 <fminunc+0x125>
and    $0xfffffffffffffff8,%rsi
xor    %edi,%edi
movapd 0xd9c(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movupd %xmm0,(%rbx,%rdi,8)
movupd %xmm0,0x10(%rbx,%rdi,8)
movupd %xmm0,0x20(%rbx,%rdi,8)
movupd %xmm0,0x30(%rbx,%rdi,8)
movupd %xmm0,0x40(%rbx,%rdi,8)
movupd %xmm0,0x50(%rbx,%rdi,8)
movupd %xmm0,0x60(%rbx,%rdi,8)
movupd %xmm0,0x70(%rbx,%rdi,8)
movupd %xmm0,0x80(%rbx,%rdi,8)
movupd %xmm0,0x90(%rbx,%rdi,8)
movupd %xmm0,0xa0(%rbx,%rdi,8)
movupd %xmm0,0xb0(%rbx,%rdi,8)
movupd %xmm0,0xc0(%rbx,%rdi,8)
movupd %xmm0,0xd0(%rbx,%rdi,8)
movupd %xmm0,0xe0(%rbx,%rdi,8)
movupd %xmm0,0xf0(%rbx,%rdi,8)
add    $0x20,%rdi
add    $0xfffffffffffffff8,%rsi
jne    1270 <fminunc+0xa0>
test   %rdx,%rdx
je     1324 <fminunc+0x154>
lea    (%rbx,%rdi,8),%rsi
add    $0x10,%rsi
shl    $0x5,%rdx
xor    %edi,%edi
movapd 0xcf0(%rip),%xmm0
movupd %xmm0,-0x10(%rsi,%rdi,1)
movupd %xmm0,(%rsi,%rdi,1)
add    $0x20,%rdi
cmp    %rdi,%rdx
jne    1310 <fminunc+0x140>
cmp    %rax,%rcx
je     134d <fminunc+0x17d>
movabs $0x3ff0000000000000,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rdx,(%rbx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1340 <fminunc+0x170>
cmp    $0x6,%r14d
ja     1665 <fminunc+0x495>
imul   $0xc8,%r15d,%r13d
mov    %r14d,%eax
lea    0xcc0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
sub    $0x8,%rsp
movsd  0xc9b(%rip),%xmm0
lea    0x14(%rsp),%r9
mov    %r12,%rdi
mov    0x20(%rsp),%rsi
mov    %r15d,%edx
mov    %rbx,%rcx
mov    %r13d,%r8d
movapd %xmm2,%xmm1
push   %rbp
call   1090 <nel_min@plt>
add    $0x10,%rsp
jmp    164a <fminunc+0x47a>
movsd  0xc62(%rip),%xmm1
movapd %xmm2,%xmm0
movsd  %xmm2,0x10(%rsp)
call   10e0 <pow@plt>
movapd %xmm0,%xmm2
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
cmp    $0x3e9,%r13d
mov    $0x3e8,%r9d
cmovge %r13d,%r9d
lea    0xc(%rsp),%rax
movsd  0xc31(%rip),%xmm0
mov    %r12,%rdi
mov    0x20(%rsp),%rsi
mov    0x18(%rsp),%rdx
mov    %r15d,%ecx
mov    %rbx,%r8
movsd  0x10(%rsp),%xmm1
push   %rbp
push   %rax
call   1080 <newton_min_func@plt>
add    $0x10,%rsp
jmp    164a <fminunc+0x47a>
movsd  0xbf8(%rip),%xmm1
movapd %xmm2,%xmm0
movsd  %xmm2,0x10(%rsp)
call   10e0 <pow@plt>
movapd %xmm0,%xmm3
movapd %xmm0,%xmm4
mulsd  %xmm0,%xmm4
cmp    $0x3e9,%r13d
mov    $0x3e8,%eax
cmovge %r13d,%eax
sub    $0x8,%rsp
lea    0x14(%rsp),%r10
movsd  0xbc4(%rip),%xmm0
movsd  0xbc4(%rip),%xmm1
mov    %r12,%rdi
mov    0x28(%rsp),%rsi
mov    0x20(%rsp),%rdx
mov    %r15d,%ecx
mov    %rbx,%r8
xor    %r9d,%r9d
jmp    14d9 <fminunc+0x309>
movsd  0xb94(%rip),%xmm1
movapd %xmm2,%xmm0
movsd  %xmm2,0x10(%rsp)
call   10e0 <pow@plt>
movapd %xmm0,%xmm3
movapd %xmm0,%xmm4
mulsd  %xmm0,%xmm4
cmp    $0x3e9,%r13d
mov    $0x3e8,%eax
cmovge %r13d,%eax
sub    $0x8,%rsp
lea    0x14(%rsp),%r10
movsd  0xb60(%rip),%xmm0
movsd  0xb60(%rip),%xmm1
mov    %r12,%rdi
mov    0x28(%rsp),%rsi
mov    0x20(%rsp),%rdx
mov    %r15d,%ecx
mov    %rbx,%r8
mov    $0x1,%r9d
movsd  0x18(%rsp),%xmm2
push   %rbp
push   %r10
push   %rax
call   1070 <newton_min_trust@plt>
jmp    1646 <fminunc+0x476>
movsd  0xb1b(%rip),%xmm1
movapd %xmm2,%xmm0
movsd  %xmm2,0x10(%rsp)
call   10e0 <pow@plt>
movapd %xmm0,%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
cmp    $0x3e9,%r13d
mov    $0x3e8,%r9d
cmovge %r13d,%r9d
lea    0xc(%rsp),%rax
mov    %r12,%rdi
mov    0x20(%rsp),%rsi
mov    0x18(%rsp),%rdx
mov    %r15d,%ecx
mov    %rbx,%r8
movsd  0x10(%rsp),%xmm0
movapd %xmm0,%xmm3
push   %rbp
push   %rax
call   1050 <conjgrad_min_lin@plt>
add    $0x10,%rsp
jmp    164a <fminunc+0x47a>
movsd  0xab5(%rip),%xmm1
movapd %xmm2,%xmm0
movsd  %xmm2,0x10(%rsp)
call   10e0 <pow@plt>
movapd %xmm0,%xmm2
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
cmp    $0x3e9,%r13d
mov    $0x3e8,%r9d
cmovge %r13d,%r9d
lea    0xc(%rsp),%rax
movsd  0xa84(%rip),%xmm0
mov    %r12,%rdi
mov    0x20(%rsp),%rsi
mov    0x18(%rsp),%rdx
mov    %r15d,%ecx
mov    %rbx,%r8
movsd  0x10(%rsp),%xmm1
push   %rbp
push   %rax
call   1060 <bfgs_min@plt>
add    $0x10,%rsp
jmp    164a <fminunc+0x47a>
movsd  0xa4b(%rip),%xmm1
movapd %xmm2,%xmm0
movsd  %xmm2,0x10(%rsp)
call   10e0 <pow@plt>
movsd  %xmm0,0x30(%rsp)
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x28(%rsp)
cmp    $0x3e9,%r13d
mov    %rbp,%r14
mov    $0x3e8,%ebp
cmovge %r13d,%ebp
mov    %r15d,%edi
call   10b0 <mvalue@plt>
sub    $0x8,%rsp
lea    0x14(%rsp),%r10
movsd  0xa08(%rip),%xmm0
mov    %r12,%rdi
mov    0x28(%rsp),%rsi
mov    0x20(%rsp),%rdx
mov    %r15d,%ecx
mov    %eax,%r8d
mov    %rbx,%r9
movsd  0x18(%rsp),%xmm1
movsd  0x38(%rsp),%xmm2
movsd  0x30(%rsp),%xmm3
movapd %xmm1,%xmm4
push   %r14
push   %r10
push   %rbp
call   10c0 <bfgs_l_min@plt>
add    $0x20,%rsp
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x9d8(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [69 x i8] c"Method Value should be one of 0,1,2,3,4,5 or 6. See Documentation. \0A\00"
define i32 @fminunc(double (double*, i32)* %0, void (double*, i32, double*)* %1, i32 %2, double* %3, i32 %4, double* %5) {
%7 = alloca double (double*, i32)*
%8 = alloca void (double*, i32, double*)*
%9 = alloca i32
%10 = alloca double*
%11 = alloca i32
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double*
store double (double*, i32)* %0, double (double*, i32)** %7
store void (double*, i32, double*)* %1, void (double*, i32, double*)** %8
store i32 %2, i32* %9
store double* %3, double** %10
store i32 %4, i32* %11
store double* %5, double** %12
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = mul i64 8, %27
%29 = trunc i64 %28 to i32
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to double*
store double* %31, double** %25
store double 1.000000e+00, double* %18
%32 = load i32, i32* %9
%33 = mul nsw i32 200, %32
store i32 %33, i32* %15
store i32 0, i32* %16
store double -1.000000e+00, double* %24
%34 = call double (...) @macheps()
store double %34, double* %19
store i32 0, i32* %13
br label %35
35: ; preds = %44, %6
%36 = load i32, i32* %13
%37 = load i32, i32* %9
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %47
39: ; preds = %35
%40 = load double*, double** %25
%41 = load i32, i32* %13
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
store double 1.000000e+00, double* %43
br label %44
44: ; preds = %39
%45 = load i32, i32* %13
%46 = add nsw i32 %45, 1
store i32 %46, i32* %13
br label %35
47: ; preds = %35
%48 = load i32, i32* %11
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %60
50: ; preds = %47
%51 = load double (double*, i32)*, double (double*, i32)** %7
%52 = load double*, double** %10
%53 = load i32, i32* %9
%54 = load double*, double** %25
%55 = load double, double* %18
%56 = load i32, i32* %15
%57 = load double, double* %19
%58 = load double*, double** %12
%59 = call i32 @nel_min(double (double*, i32)* %51, double* %52, i32 %53, double* %54, double %55, i32 %56, i32* %16, double %57, double* %58)
store i32 %59, i32* %14
br label %227
60: ; preds = %47
%61 = load i32, i32* %11
%62 = icmp eq i32 %61, 1
br i1 %62, label %63, label %85
63: ; preds = %60
%64 = load double, double* %19
%65 = call double @pow(double %64, double 0x3FD5555555555555)
store double %65, double* %20
%66 = load double, double* %20
%67 = load double, double* %20
%68 = fmul double %66, %67
store double %68, double* %21
%69 = load i32, i32* %15
%70 = icmp slt i32 %69, 1000
br i1 %70, label %71, label %72
71: ; preds = %63
store i32 1000, i32* %15
br label %72
72: ; preds = %71, %63
%73 = load double (double*, i32)*, double (double*, i32)** %7
%74 = load void (double*, i32, double*)*, void (double*, i32, double*)** %8
%75 = load double*, double** %10
%76 = load i32, i32* %9
%77 = load double*, double** %25
%78 = load double, double* %18
%79 = load i32, i32* %15
%80 = load double, double* %19
%81 = load double, double* %20
%82 = load double, double* %21
%83 = load double*, double** %12
%84 = call i32 @newton_min_func(double (double*, i32)* %73, void (double*, i32, double*)* %74, double* %75, i32 %76, double* %77, double %78, i32 %79, i32* %16, double %80, double %81, double %82, double* %83)
store i32 %84, i32* %14
br label %226
85: ; preds = %60
%86 = load i32, i32* %11
%87 = icmp eq i32 %86, 2
br i1 %87, label %88, label %111
88: ; preds = %85
%89 = load double, double* %19
%90 = call double @pow(double %89, double 0x3FD5555555555555)
store double %90, double* %20
%91 = load double, double* %20
%92 = load double, double* %20
%93 = fmul double %91, %92
store double %93, double* %21
%94 = load i32, i32* %15
%95 = icmp slt i32 %94, 1000
br i1 %95, label %96, label %97
96: ; preds = %88
store i32 1000, i32* %15
br label %97
97: ; preds = %96, %88
%98 = load double (double*, i32)*, double (double*, i32)** %7
%99 = load void (double*, i32, double*)*, void (double*, i32, double*)** %8
%100 = load double*, double** %10
%101 = load i32, i32* %9
%102 = load double*, double** %25
%103 = load double, double* %18
%104 = load double, double* %24
%105 = load i32, i32* %15
%106 = load double, double* %19
%107 = load double, double* %20
%108 = load double, double* %21
%109 = load double*, double** %12
%110 = call i32 @newton_min_trust(double (double*, i32)* %98, void (double*, i32, double*)* %99, double* %100, i32 %101, double* %102, double %103, double %104, i32 0, i32 %105, i32* %16, double %106, double %107, double %108, double* %109)
store i32 %110, i32* %14
br label %225
111: ; preds = %85
%112 = load i32, i32* %11
%113 = icmp eq i32 %112, 3
br i1 %113, label %114, label %137
114: ; preds = %111
%115 = load double, double* %19
%116 = call double @pow(double %115, double 0x3FD5555555555555)
store double %116, double* %20
%117 = load double, double* %20
%118 = load double, double* %20
%119 = fmul double %117, %118
store double %119, double* %21
%120 = load i32, i32* %15
%121 = icmp slt i32 %120, 1000
br i1 %121, label %122, label %123
122: ; preds = %114
store i32 1000, i32* %15
br label %123
123: ; preds = %122, %114
%124 = load double (double*, i32)*, double (double*, i32)** %7
%125 = load void (double*, i32, double*)*, void (double*, i32, double*)** %8
%126 = load double*, double** %10
%127 = load i32, i32* %9
%128 = load double*, double** %25
%129 = load double, double* %18
%130 = load double, double* %24
%131 = load i32, i32* %15
%132 = load double, double* %19
%133 = load double, double* %20
%134 = load double, double* %21
%135 = load double*, double** %12
%136 = call i32 @newton_min_trust(double (double*, i32)* %124, void (double*, i32, double*)* %125, double* %126, i32 %127, double* %128, double %129, double %130, i32 1, i32 %131, i32* %16, double %132, double %133, double %134, double* %135)
store i32 %136, i32* %14
br label %224
137: ; preds = %111
%138 = load i32, i32* %11
%139 = icmp eq i32 %138, 4
br i1 %139, label %140, label %163
140: ; preds = %137
%141 = load double, double* %19
%142 = call double @pow(double %141, double 0x3FD5555555555555)
store double %142, double* %20
%143 = load double, double* %20
%144 = load double, double* %20
%145 = fmul double %143, %144
store double %145, double* %22
%146 = load double, double* %19
store double %146, double* %23
%147 = load i32, i32* %15
%148 = icmp slt i32 %147, 1000
br i1 %148, label %149, label %150
149: ; preds = %140
store i32 1000, i32* %15
br label %150
150: ; preds = %149, %140
%151 = load double (double*, i32)*, double (double*, i32)** %7
%152 = load void (double*, i32, double*)*, void (double*, i32, double*)** %8
%153 = load double*, double** %10
%154 = load i32, i32* %9
%155 = load double*, double** %25
%156 = load i32, i32* %15
%157 = load double, double* %19
%158 = load double, double* %20
%159 = load double, double* %22
%160 = load double, double* %23
%161 = load double*, double** %12
%162 = call i32 @conjgrad_min_lin(double (double*, i32)* %151, void (double*, i32, double*)* %152, double* %153, i32 %154, double* %155, i32 %156, i32* %16, double %157, double %158, double %159, double %160, double* %161)
store i32 %162, i32* %14
br label %223
163: ; preds = %137
%164 = load i32, i32* %11
%165 = icmp eq i32 %164, 5
br i1 %165, label %166, label %188
166: ; preds = %163
%167 = load double, double* %19
%168 = call double @pow(double %167, double 0x3FD5555555555555)
store double %168, double* %20
%169 = load double, double* %20
%170 = load double, double* %20
%171 = fmul double %169, %170
store double %171, double* %21
%172 = load i32, i32* %15
%173 = icmp slt i32 %172, 1000
br i1 %173, label %174, label %175
174: ; preds = %166
store i32 1000, i32* %15
br label %175
175: ; preds = %174, %166
%176 = load double (double*, i32)*, double (double*, i32)** %7
%177 = load void (double*, i32, double*)*, void (double*, i32, double*)** %8
%178 = load double*, double** %10
%179 = load i32, i32* %9
%180 = load double*, double** %25
%181 = load double, double* %18
%182 = load i32, i32* %15
%183 = load double, double* %19
%184 = load double, double* %20
%185 = load double, double* %21
%186 = load double*, double** %12
%187 = call i32 @bfgs_min(double (double*, i32)* %176, void (double*, i32, double*)* %177, double* %178, i32 %179, double* %180, double %181, i32 %182, i32* %16, double %183, double %184, double %185, double* %186)
store i32 %187, i32* %14
br label %222
188: ; preds = %163
%189 = load i32, i32* %11
%190 = icmp eq i32 %189, 6
br i1 %190, label %191, label %218
191: ; preds = %188
%192 = load double, double* %19
%193 = call double @pow(double %192, double 0x3FD5555555555555)
store double %193, double* %20
%194 = load double, double* %20
%195 = load double, double* %20
%196 = fmul double %194, %195
store double %196, double* %22
%197 = load double, double* %19
store double %197, double* %23
%198 = load i32, i32* %15
%199 = icmp slt i32 %198, 1000
br i1 %199, label %200, label %201
200: ; preds = %191
store i32 1000, i32* %15
br label %201
201: ; preds = %200, %191
%202 = load i32, i32* %9
%203 = call i32 @mvalue(i32 %202)
store i32 %203, i32* %17
%204 = load double (double*, i32)*, double (double*, i32)** %7
%205 = load void (double*, i32, double*)*, void (double*, i32, double*)** %8
%206 = load double*, double** %10
%207 = load i32, i32* %9
%208 = load i32, i32* %17
%209 = load double*, double** %25
%210 = load double, double* %18
%211 = load i32, i32* %15
%212 = load double, double* %19
%213 = load double, double* %20
%214 = load double, double* %22
%215 = load double, double* %23
%216 = load double*, double** %12
%217 = call i32 @bfgs_l_min(double (double*, i32)* %204, void (double*, i32, double*)* %205, double* %206, i32 %207, i32 %208, double* %209, double %210, i32 %211, i32* %16, double %212, double %213, double %214, double %215, double* %216)
store i32 %217, i32* %14
br label %221
218: ; preds = %188
%219 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
%220 = call i32 @exit(i32 1)
unreachable
221: ; preds = %201
br label %222
222: ; preds = %221, %175
br label %223
223: ; preds = %222, %150
br label %224
224: ; preds = %223, %123
br label %225
225: ; preds = %224, %97
br label %226
226: ; preds = %225, %72
br label %227
227: ; preds = %226, %50
%228 = load double*, double** %25
%229 = call i32 @free(double* %228)
%230 = load i32, i32* %14
ret i32 %230
}

LLVM IR (-O2):
@str = [68 x i8] c"Method Value should be one of 0,1,2,3,4,5 or 6. See Documentation. \00"
define i32 @fminunc(double (double*, i32)* %0, void (double*, i32, double*)* %1, i32 %2, double* %3, i32 %4, double* %5) {
%7 = alloca i32
%8 = bitcast i32* %7 to i8*
%9 = shl i32 %2, 3
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to double*
%12 = mul nsw i32 %2, 200
store i32 0, i32* %7
%13 = tail call double (...) @macheps()
%14 = icmp sgt i32 %2, 0
br i1 %14, label %15, label %94
15: ; preds = %6
%16 = zext i32 %2 to i64
%17 = icmp ult i32 %2, 4
br i1 %17, label %87, label %18
18: ; preds = %15
%19 = and i64 %16, 4294967292
%20 = add nsw i64 %19, -4
%21 = lshr exact i64 %20, 2
%22 = add nuw nsw i64 %21, 1
%23 = and i64 %22, 7
%24 = icmp ult i64 %20, 28
br i1 %24, label %72, label %25
25: ; preds = %18
%26 = and i64 %22, 9223372036854775800
br label %27
27: ; preds = %27, %25
%28 = phi i64 [ 0, %25 ], [ %69, %27 ]
%29 = phi i64 [ 0, %25 ], [ %70, %27 ]
%30 = getelementptr inbounds double, double* %11, i64 %28
%31 = bitcast double* %30 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %31
%32 = getelementptr inbounds double, double* %30, i64 2
%33 = bitcast double* %32 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %33
%34 = or i64 %28, 4
%35 = getelementptr inbounds double, double* %11, i64 %34
%36 = bitcast double* %35 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %36
%37 = getelementptr inbounds double, double* %35, i64 2
%38 = bitcast double* %37 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %38
%39 = or i64 %28, 8
%40 = getelementptr inbounds double, double* %11, i64 %39
%41 = bitcast double* %40 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %41
%42 = getelementptr inbounds double, double* %40, i64 2
%43 = bitcast double* %42 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %43
%44 = or i64 %28, 12
%45 = getelementptr inbounds double, double* %11, i64 %44
%46 = bitcast double* %45 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %46
%47 = getelementptr inbounds double, double* %45, i64 2
%48 = bitcast double* %47 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %48
%49 = or i64 %28, 16
%50 = getelementptr inbounds double, double* %11, i64 %49
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %51
%52 = getelementptr inbounds double, double* %50, i64 2
%53 = bitcast double* %52 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %53
%54 = or i64 %28, 20
%55 = getelementptr inbounds double, double* %11, i64 %54
%56 = bitcast double* %55 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %56
%57 = getelementptr inbounds double, double* %55, i64 2
%58 = bitcast double* %57 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %58
%59 = or i64 %28, 24
%60 = getelementptr inbounds double, double* %11, i64 %59
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %61
%62 = getelementptr inbounds double, double* %60, i64 2
%63 = bitcast double* %62 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %63
%64 = or i64 %28, 28
%65 = getelementptr inbounds double, double* %11, i64 %64
%66 = bitcast double* %65 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %66
%67 = getelementptr inbounds double, double* %65, i64 2
%68 = bitcast double* %67 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %68
%69 = add nuw i64 %28, 32
%70 = add i64 %29, 8
%71 = icmp eq i64 %70, %26
br i1 %71, label %72, label %27
72: ; preds = %27, %18
%73 = phi i64 [ 0, %18 ], [ %69, %27 ]
%74 = icmp eq i64 %23, 0
br i1 %74, label %85, label %75
75: ; preds = %72, %75
%76 = phi i64 [ %82, %75 ], [ %73, %72 ]
%77 = phi i64 [ %83, %75 ], [ 0, %72 ]
%78 = getelementptr inbounds double, double* %11, i64 %76
%79 = bitcast double* %78 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %79
%80 = getelementptr inbounds double, double* %78, i64 2
%81 = bitcast double* %80 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %81
%82 = add nuw i64 %76, 4
%83 = add i64 %77, 1
%84 = icmp eq i64 %83, %23
br i1 %84, label %85, label %75
85: ; preds = %75, %72
%86 = icmp eq i64 %19, %16
br i1 %86, label %94, label %87
87: ; preds = %15, %85
%88 = phi i64 [ 0, %15 ], [ %19, %85 ]
br label %89
89: ; preds = %87, %89
%90 = phi i64 [ %92, %89 ], [ %88, %87 ]
%91 = getelementptr inbounds double, double* %11, i64 %90
store double 1.000000e+00, double* %91
%92 = add nuw nsw i64 %90, 1
%93 = icmp eq i64 %92, %16
br i1 %93, label %94, label %89
94: ; preds = %89, %85, %6
switch i32 %4, label %134 [
i32 0, label %95
i32 1, label %97
i32 2, label %103
i32 3, label %109
i32 4, label %115
i32 5, label %121
i32 6, label %127
]
95: ; preds = %94
%96 = call i32 @nel_min(double (double*, i32)* %0, double* %3, i32 %2, double* %11, double 1.000000e+00, i32 %12, i32* %7, double %13, double* %5)
br label %137
97: ; preds = %94
%98 = tail call double @pow(double %13, double 0x3FD5555555555555)
%99 = fmul double %98, %98
%100 = icmp sgt i32 %12, 1000
%101 = select i1 %100, i32 %12, i32 1000
%102 = call i32 @newton_min_func(double (double*, i32)* %0, void (double*, i32, double*)* %1, double* %3, i32 %2, double* %11, double 1.000000e+00, i32 %101, i32* %7, double %13, double %98, double %99, double* %5)
br label %137
103: ; preds = %94
%104 = tail call double @pow(double %13, double 0x3FD5555555555555)
%105 = fmul double %104, %104
%106 = icmp sgt i32 %12, 1000
%107 = select i1 %106, i32 %12, i32 1000
%108 = call i32 @newton_min_trust(double (double*, i32)* %0, void (double*, i32, double*)* %1, double* %3, i32 %2, double* %11, double 1.000000e+00, double -1.000000e+00, i32 0, i32 %107, i32* %7, double %13, double %104, double %105, double* %5)
br label %137
109: ; preds = %94
%110 = tail call double @pow(double %13, double 0x3FD5555555555555)
%111 = fmul double %110, %110
%112 = icmp sgt i32 %12, 1000
%113 = select i1 %112, i32 %12, i32 1000
%114 = call i32 @newton_min_trust(double (double*, i32)* %0, void (double*, i32, double*)* %1, double* %3, i32 %2, double* %11, double 1.000000e+00, double -1.000000e+00, i32 1, i32 %113, i32* %7, double %13, double %110, double %111, double* %5)
br label %137
115: ; preds = %94
%116 = tail call double @pow(double %13, double 0x3FD5555555555555)
%117 = fmul double %116, %116
%118 = icmp sgt i32 %12, 1000
%119 = select i1 %118, i32 %12, i32 1000
%120 = call i32 @conjgrad_min_lin(double (double*, i32)* %0, void (double*, i32, double*)* %1, double* %3, i32 %2, double* %11, i32 %119, i32* %7, double %13, double %116, double %117, double %13, double* %5)
br label %137
121: ; preds = %94
%122 = tail call double @pow(double %13, double 0x3FD5555555555555)
%123 = fmul double %122, %122
%124 = icmp sgt i32 %12, 1000
%125 = select i1 %124, i32 %12, i32 1000
%126 = call i32 @bfgs_min(double (double*, i32)* %0, void (double*, i32, double*)* %1, double* %3, i32 %2, double* %11, double 1.000000e+00, i32 %125, i32* %7, double %13, double %122, double %123, double* %5)
br label %137
127: ; preds = %94
%128 = tail call double @pow(double %13, double 0x3FD5555555555555)
%129 = fmul double %128, %128
%130 = icmp sgt i32 %12, 1000
%131 = select i1 %130, i32 %12, i32 1000
%132 = tail call i32 @mvalue(i32 %2)
%133 = call i32 @bfgs_l_min(double (double*, i32)* %0, void (double*, i32, double*)* %1, double* %3, i32 %2, i32 %132, double* %11, double 1.000000e+00, i32 %131, i32* %7, double %13, double %128, double %129, double %13, double* %5)
br label %137
134: ; preds = %94
%135 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str, i64 0, i64 0))
%136 = tail call i32 @exit(i32 1)
unreachable
137: ; preds = %97, %109, %121, %127, %115, %103, %95
%138 = phi i32 [ %96, %95 ], [ %102, %97 ], [ %108, %103 ], [ %114, %109 ], [ %120, %115 ], [ %126, %121 ], [ %133, %127 ]
%139 = call i32 @free(double* %11)
ret i32 %138
}