#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 */
struct pumas_physics {
  int dummy;
};

/* Variables and functions */
double const fabs(double);
int math_find_minimum_bisection(double (*)(struct pumas_physics const *, double,
                                           void *),
                                struct pumas_physics const *, double, double,
                                double, double *, double, int, void *, double *,
                                double *);
int math_find_minimum_brent(double (*)(struct pumas_physics const *, double,
                                       void *),
                            struct pumas_physics const *, double, double,
                            double, double *, double, int, void *, double *,
                            double *);
double stub1(struct pumas_physics const *, double, void *);
double stub2(struct pumas_physics const *, double, void *);
double stub3(struct pumas_physics const *, double, void *);
int math_find_minimum(int algo,
                      double (*f)(const struct pumas_physics *physics, double x,
                                  void *params),
                      const struct pumas_physics *physics, double xa, double xc,
                      const double *fa_p, const double *fc_p, double tol,
                      int max_iter, void *params, double *xopt, double *fopt) {
  double fa, fc;
  if (fa_p == NULL)
    fa = (*f)(physics, xa, params);
  else
    fa = *fa_p;
  if (fc_p == NULL)
    fc = (*f)(physics, xc, params);
  else
    fc = *fc_p;
  const double atol = tol * fabs(xc - xa);
  double xb = 0, fb = 0;
  int i;
  for (i = 0; i < max_iter; i++) {
    xb = 0.5 * (xa + xc);
    fb = (*f)(physics, xb, params);
    if ((fb < fa) && (fb < fc))
      break;
    if (fabs(xc - xa) <= atol) {
      if (xopt != NULL)
        *xopt = xb;
      if (fopt != NULL)
        *fopt = fb;
      return i;
    }
    if (fb < fc) {
      xc = xb;
      fc = fb;
    } else {
      xa = xb;
      fa = fb;
    }
  }
  if (i == max_iter) {
    if (fa < fb) {
      fb = fa;
      xb = xa;
    } else if (fc < fb) {
      fb = fc;
      xb = xc;
    }
    if (xopt != NULL)
      *xopt = xb;
    if (fopt != NULL)
      *fopt = fb;
    return -1;
  }
  int status;
  if (algo == 1) {
    status = math_find_minimum_brent(f, physics, xa, xb, xc, &fb, tol,
                                     max_iter - i, params, xopt, fopt);
  } else {
    status = math_find_minimum_bisection(f, physics, xa, xb, xc, &fb, tol,
                                         max_iter - i, params, xopt, fopt);
  }
  if (status < 0) {
    return -2;
  } else {
    return status + i;
  }
}


x86 assembly (clang, -O0):
<math_find_minimum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
movsd  %xmm2,-0x40(%rbp)
mov    %r9d,-0x44(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1195 <math_find_minimum+0x65>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
mov    0x10(%rbp),%rsi
call   *%rax
movsd  %xmm0,-0x50(%rbp)
jmp    11a2 <math_find_minimum+0x72>
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11ca <math_find_minimum+0x9a>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
mov    0x10(%rbp),%rsi
call   *%rax
movsd  %xmm0,-0x58(%rbp)
jmp    11d7 <math_find_minimum+0xa7>
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1334 <math_find_minimum+0x204>
movsd  -0x20(%rbp),%xmm1
addsd  -0x28(%rbp),%xmm1
movsd  0xdca(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rdi
movsd  -0x68(%rbp),%xmm0
mov    0x10(%rbp),%rsi
call   *%rax
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1284 <math_find_minimum+0x154>
movsd  -0x70(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1284 <math_find_minimum+0x154>
jmp    1334 <math_find_minimum+0x204>
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     12e0 <math_find_minimum+0x1b0>
cmpq   $0x0,0x18(%rbp)
je     12bd <math_find_minimum+0x18d>
movsd  -0x68(%rbp),%xmm0
mov    0x18(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,0x20(%rbp)
je     12d5 <math_find_minimum+0x1a5>
movsd  -0x70(%rbp),%xmm0
mov    0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x74(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1480 <math_find_minimum+0x350>
movsd  -0x70(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    130d <math_find_minimum+0x1dd>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1321 <math_find_minimum+0x1f1>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1326 <math_find_minimum+0x1f6>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1218 <math_find_minimum+0xe8>
mov    -0x74(%rbp),%eax
cmp    -0x44(%rbp),%eax
jne    13d6 <math_find_minimum+0x2a6>
movsd  -0x50(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    136d <math_find_minimum+0x23d>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    139a <math_find_minimum+0x26a>
movsd  -0x58(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1395 <math_find_minimum+0x265>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    139a <math_find_minimum+0x26a>
cmpq   $0x0,0x18(%rbp)
je     13b2 <math_find_minimum+0x282>
movsd  -0x68(%rbp),%xmm0
mov    0x18(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,0x20(%rbp)
je     13ca <math_find_minimum+0x29a>
movsd  -0x70(%rbp),%xmm0
mov    0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1480 <math_find_minimum+0x350>
cmpl   $0x1,-0x8(%rbp)
jne    1423 <math_find_minimum+0x2f3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x20(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
mov    -0x44(%rbp),%ecx
sub    -0x74(%rbp),%ecx
mov    0x10(%rbp),%r8
mov    0x18(%rbp),%r9
mov    0x20(%rbp),%rax
lea    -0x70(%rbp),%rdx
mov    %rax,(%rsp)
call   1050 <math_find_minimum_brent@plt>
mov    %eax,-0x78(%rbp)
jmp    1461 <math_find_minimum+0x331>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x20(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
mov    -0x44(%rbp),%ecx
sub    -0x74(%rbp),%ecx
mov    0x10(%rbp),%r8
mov    0x18(%rbp),%r9
mov    0x20(%rbp),%rax
lea    -0x70(%rbp),%rdx
mov    %rax,(%rsp)
call   1040 <math_find_minimum_bisection@plt>
mov    %eax,-0x78(%rbp)
cmpl   $0x0,-0x78(%rbp)
jge    1477 <math_find_minimum+0x347>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1480 <math_find_minimum+0x350>
mov    -0x78(%rbp),%eax
add    -0x74(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<math_find_minimum>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r9d,%ebx
movsd  %xmm2,0x18(%rsp)
mov    %r8,%rbp
movapd %xmm1,%xmm4
movapd %xmm0,%xmm3
mov    %rdx,%r12
mov    %rsi,%r13
mov    %edi,0x2c(%rsp)
mov    0xb0(%rsp),%r15
test   %rcx,%rcx
je     1169 <math_find_minimum+0x49>
movsd  (%rcx),%xmm5
test   %rbp,%rbp
je     1197 <math_find_minimum+0x77>
movsd  0x0(%rbp),%xmm7
jmp    11cc <math_find_minimum+0xac>
mov    %r12,%rdi
movapd %xmm3,%xmm0
mov    %r15,%rsi
movsd  %xmm3,0x8(%rsp)
movapd %xmm4,0x30(%rsp)
call   *%r13
movapd 0x30(%rsp),%xmm4
movsd  0x8(%rsp),%xmm3
movapd %xmm0,%xmm5
test   %rbp,%rbp
jne    1162 <math_find_minimum+0x42>
mov    %r12,%rdi
movapd %xmm4,%xmm0
mov    %r15,%rsi
movsd  %xmm3,0x8(%rsp)
movapd %xmm4,0x30(%rsp)
movsd  %xmm5,0x20(%rsp)
call   *%r13
movsd  0x20(%rsp),%xmm5
movapd 0x30(%rsp),%xmm4
movsd  0x8(%rsp),%xmm3
movapd %xmm0,%xmm7
mov    0xc0(%rsp),%r14
test   %ebx,%ebx
jle    12cc <math_find_minimum+0x1ac>
movapd %xmm4,%xmm0
subsd  %xmm3,%xmm0
andpd  0xe14(%rip),%xmm0
mulsd  0x18(%rsp),%xmm0
movapd %xmm0,0x60(%rsp)
xor    %ebp,%ebp
jmp    1234 <math_find_minimum+0x114>
nopl   0x0(%rax)
movapd %xmm0,%xmm6
cmpltsd %xmm7,%xmm6
movapd %xmm6,%xmm2
andpd  %xmm1,%xmm2
andnpd %xmm4,%xmm6
orpd   %xmm2,%xmm6
movapd %xmm0,%xmm2
minsd  %xmm7,%xmm2
add    $0x1,%ebp
movapd %xmm2,%xmm7
movapd %xmm6,%xmm4
cmp    %ebp,%ebx
je     12fc <math_find_minimum+0x1dc>
movsd  %xmm7,0x58(%rsp)
movsd  %xmm5,0x20(%rsp)
movapd %xmm4,0x30(%rsp)
movsd  %xmm3,0x8(%rsp)
addsd  %xmm3,%xmm4
mulsd  0xdb8(%rip),%xmm4
mov    %r12,%rdi
movapd %xmm4,0x40(%rsp)
movapd %xmm4,%xmm0
mov    %r15,%rsi
call   *%r13
movsd  0x58(%rsp),%xmm7
movsd  0x20(%rsp),%xmm5
ucomisd %xmm0,%xmm5
jbe    1283 <math_find_minimum+0x163>
ucomisd %xmm0,%xmm7
ja     12d8 <math_find_minimum+0x1b8>
movapd 0x30(%rsp),%xmm4
movapd %xmm4,%xmm1
movsd  0x8(%rsp),%xmm3
subsd  %xmm3,%xmm1
andpd  0xd61(%rip),%xmm1
movapd 0x60(%rsp),%xmm2
ucomisd %xmm1,%xmm2
jae    138c <math_find_minimum+0x26c>
ucomisd %xmm0,%xmm7
movapd 0x40(%rsp),%xmm1
ja     1200 <math_find_minimum+0xe0>
movapd %xmm1,%xmm3
movapd %xmm0,%xmm5
jmp    1200 <math_find_minimum+0xe0>
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
jmp    12ea <math_find_minimum+0x1ca>
movsd  0x8(%rsp),%xmm3
movapd 0x30(%rsp),%xmm4
movapd 0x40(%rsp),%xmm1
movsd  %xmm0,0x10(%rsp)
cmp    %ebx,%ebp
jne    131a <math_find_minimum+0x1fa>
movapd %xmm7,%xmm2
movapd %xmm4,%xmm6
ucomisd %xmm5,%xmm0
jbe    135b <math_find_minimum+0x23b>
movsd  %xmm5,0x10(%rsp)
movapd %xmm5,%xmm0
movapd %xmm3,%xmm1
mov    0xb8(%rsp),%rax
jmp    1377 <math_find_minimum+0x257>
sub    %ebp,%ebx
cmpl   $0x1,0x2c(%rsp)
jne    13ae <math_find_minimum+0x28e>
mov    %r14,(%rsp)
lea    0x10(%rsp),%rdx
mov    %r13,%rdi
mov    %r12,%rsi
movapd %xmm3,%xmm0
movapd %xmm4,%xmm2
movsd  0x18(%rsp),%xmm3
mov    %ebx,%ecx
mov    %r15,%r8
mov    0xb8(%rsp),%r9
call   1040 <math_find_minimum_brent@plt>
jmp    13dd <math_find_minimum+0x2bd>
ucomisd %xmm2,%xmm0
mov    0xb8(%rsp),%rax
jbe    1377 <math_find_minimum+0x257>
movsd  %xmm2,0x10(%rsp)
movapd %xmm2,%xmm0
movapd %xmm6,%xmm1
test   %rax,%rax
je     1380 <math_find_minimum+0x260>
movsd  %xmm1,(%rax)
mov    $0xffffffff,%ebp
test   %r14,%r14
jne    13a7 <math_find_minimum+0x287>
jmp    13e9 <math_find_minimum+0x2c9>
mov    0xb8(%rsp),%rax
test   %rax,%rax
movaps 0x40(%rsp),%xmm1
je     13a2 <math_find_minimum+0x282>
movsd  %xmm1,(%rax)
test   %r14,%r14
je     13e9 <math_find_minimum+0x2c9>
movsd  %xmm0,(%r14)
jmp    13e9 <math_find_minimum+0x2c9>
mov    %r14,(%rsp)
lea    0x10(%rsp),%rdx
mov    %r13,%rdi
mov    %r12,%rsi
movapd %xmm3,%xmm0
movapd %xmm4,%xmm2
movsd  0x18(%rsp),%xmm3
mov    %ebx,%ecx
mov    %r15,%r8
mov    0xb8(%rsp),%r9
call   1030 <math_find_minimum_bisection@plt>
add    %eax,%ebp
test   %eax,%eax
mov    $0xfffffffe,%eax
cmovs  %eax,%ebp
mov    %ebp,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.pumas_physics = type { i32 }
define i32 @math_find_minimum(i32 %0, double (%struct.pumas_physics*, double, i8*)* %1, %struct.pumas_physics* %2, double %3, double %4, double* %5, double* %6, double %7, i32 %8, i8* %9, double* %10, double* %11) {
%13 = alloca i32
%14 = alloca i32
%15 = alloca double (%struct.pumas_physics*, double, i8*)*
%16 = alloca %struct.pumas_physics*
%17 = alloca double
%18 = alloca double
%19 = alloca double*
%20 = alloca double*
%21 = alloca double
%22 = alloca i32
%23 = alloca i8*
%24 = alloca double*
%25 = alloca double*
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca i32
%32 = alloca i32
store i32 %0, i32* %14
store double (%struct.pumas_physics*, double, i8*)* %1, double (%struct.pumas_physics*, double, i8*)** %15
store %struct.pumas_physics* %2, %struct.pumas_physics** %16
store double %3, double* %17
store double %4, double* %18
store double* %5, double** %19
store double* %6, double** %20
store double %7, double* %21
store i32 %8, i32* %22
store i8* %9, i8** %23
store double* %10, double** %24
store double* %11, double** %25
%33 = load double*, double** %19
%34 = icmp eq double* %33, null
br i1 %34, label %35, label %41
35: ; preds = %12
%36 = load double (%struct.pumas_physics*, double, i8*)*, double (%struct.pumas_physics*, double, i8*)** %15
%37 = load %struct.pumas_physics*, %struct.pumas_physics** %16
%38 = load double, double* %17
%39 = load i8*, i8** %23
%40 = call double %36(%struct.pumas_physics* %37, double %38, i8* %39)
store double %40, double* %26
br label %44
41: ; preds = %12
%42 = load double*, double** %19
%43 = load double, double* %42
store double %43, double* %26
br label %44
44: ; preds = %41, %35
%45 = load double*, double** %20
%46 = icmp eq double* %45, null
br i1 %46, label %47, label %53
47: ; preds = %44
%48 = load double (%struct.pumas_physics*, double, i8*)*, double (%struct.pumas_physics*, double, i8*)** %15
%49 = load %struct.pumas_physics*, %struct.pumas_physics** %16
%50 = load double, double* %18
%51 = load i8*, i8** %23
%52 = call double %48(%struct.pumas_physics* %49, double %50, i8* %51)
store double %52, double* %27
br label %56
53: ; preds = %44
%54 = load double*, double** %20
%55 = load double, double* %54
store double %55, double* %27
br label %56
56: ; preds = %53, %47
%57 = load double, double* %21
%58 = load double, double* %18
%59 = load double, double* %17
%60 = fsub double %58, %59
%61 = call double @fabs(double %60)
%62 = fmul double %57, %61
store double %62, double* %28
store double 0.000000e+00, double* %29
store double 0.000000e+00, double* %30
store i32 0, i32* %31
br label %63
63: ; preds = %117, %56
%64 = load i32, i32* %31
%65 = load i32, i32* %22
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %120
67: ; preds = %63
%68 = load double, double* %17
%69 = load double, double* %18
%70 = fadd double %68, %69
%71 = fmul double 5.000000e-01, %70
store double %71, double* %29
%72 = load double (%struct.pumas_physics*, double, i8*)*, double (%struct.pumas_physics*, double, i8*)** %15
%73 = load %struct.pumas_physics*, %struct.pumas_physics** %16
%74 = load double, double* %29
%75 = load i8*, i8** %23
%76 = call double %72(%struct.pumas_physics* %73, double %74, i8* %75)
store double %76, double* %30
%77 = load double, double* %30
%78 = load double, double* %26
%79 = fcmp olt double %77, %78
br i1 %79, label %80, label %85
80: ; preds = %67
%81 = load double, double* %30
%82 = load double, double* %27
%83 = fcmp olt double %81, %82
br i1 %83, label %84, label %85
84: ; preds = %80
br label %120
85: ; preds = %80, %67
%86 = load double, double* %18
%87 = load double, double* %17
%88 = fsub double %86, %87
%89 = call double @fabs(double %88)
%90 = load double, double* %28
%91 = fcmp ole double %89, %90
br i1 %91, label %92, label %106
92: ; preds = %85
%93 = load double*, double** %24
%94 = icmp ne double* %93, null
br i1 %94, label %95, label %98
95: ; preds = %92
%96 = load double, double* %29
%97 = load double*, double** %24
store double %96, double* %97
br label %98
98: ; preds = %95, %92
%99 = load double*, double** %25
%100 = icmp ne double* %99, null
br i1 %100, label %101, label %104
101: ; preds = %98
%102 = load double, double* %30
%103 = load double*, double** %25
store double %102, double* %103
br label %104
104: ; preds = %101, %98
%105 = load i32, i32* %31
store i32 %105, i32* %13
br label %191
106: ; preds = %85
%107 = load double, double* %30
%108 = load double, double* %27
%109 = fcmp olt double %107, %108
br i1 %109, label %110, label %113
110: ; preds = %106
%111 = load double, double* %29
store double %111, double* %18
%112 = load double, double* %30
store double %112, double* %27
br label %116
113: ; preds = %106
%114 = load double, double* %29
store double %114, double* %17
%115 = load double, double* %30
store double %115, double* %26
br label %116
116: ; preds = %113, %110
br label %117
117: ; preds = %116
%118 = load i32, i32* %31
%119 = add nsw i32 %118, 1
store i32 %119, i32* %31
br label %63
120: ; preds = %84, %63
%121 = load i32, i32* %31
%122 = load i32, i32* %22
%123 = icmp eq i32 %121, %122
br i1 %123, label %124, label %152
124: ; preds = %120
%125 = load double, double* %26
%126 = load double, double* %30
%127 = fcmp olt double %125, %126
br i1 %127, label %128, label %131
128: ; preds = %124
%129 = load double, double* %26
store double %129, double* %30
%130 = load double, double* %17
store double %130, double* %29
br label %139
131: ; preds = %124
%132 = load double, double* %27
%133 = load double, double* %30
%134 = fcmp olt double %132, %133
br i1 %134, label %135, label %138
135: ; preds = %131
%136 = load double, double* %27
store double %136, double* %30
%137 = load double, double* %18
store double %137, double* %29
br label %138
138: ; preds = %135, %131
br label %139
139: ; preds = %138, %128
%140 = load double*, double** %24
%141 = icmp ne double* %140, null
br i1 %141, label %142, label %145
142: ; preds = %139
%143 = load double, double* %29
%144 = load double*, double** %24
store double %143, double* %144
br label %145
145: ; preds = %142, %139
%146 = load double*, double** %25
%147 = icmp ne double* %146, null
br i1 %147, label %148, label %151
148: ; preds = %145
%149 = load double, double* %30
%150 = load double*, double** %25
store double %149, double* %150
br label %151
151: ; preds = %148, %145
store i32 -1, i32* %13
br label %191
152: ; preds = %120
%153 = load i32, i32* %14
%154 = icmp eq i32 %153, 1
br i1 %154, label %155, label %169
155: ; preds = %152
%156 = load double (%struct.pumas_physics*, double, i8*)*, double (%struct.pumas_physics*, double, i8*)** %15
%157 = load %struct.pumas_physics*, %struct.pumas_physics** %16
%158 = load double, double* %17
%159 = load double, double* %29
%160 = load double, double* %18
%161 = load double, double* %21
%162 = load i32, i32* %22
%163 = load i32, i32* %31
%164 = sub nsw i32 %162, %163
%165 = load i8*, i8** %23
%166 = load double*, double** %24
%167 = load double*, double** %25
%168 = call i32 @math_find_minimum_brent(double (%struct.pumas_physics*, double, i8*)* %156, %struct.pumas_physics* %157, double %158, double %159, double %160, double* %30, double %161, i32 %164, i8* %165, double* %166, double* %167)
store i32 %168, i32* %32
br label %183
169: ; preds = %152
%170 = load double (%struct.pumas_physics*, double, i8*)*, double (%struct.pumas_physics*, double, i8*)** %15
%171 = load %struct.pumas_physics*, %struct.pumas_physics** %16
%172 = load double, double* %17
%173 = load double, double* %29
%174 = load double, double* %18
%175 = load double, double* %21
%176 = load i32, i32* %22
%177 = load i32, i32* %31
%178 = sub nsw i32 %176, %177
%179 = load i8*, i8** %23
%180 = load double*, double** %24
%181 = load double*, double** %25
%182 = call i32 @math_find_minimum_bisection(double (%struct.pumas_physics*, double, i8*)* %170, %struct.pumas_physics* %171, double %172, double %173, double %174, double* %30, double %175, i32 %178, i8* %179, double* %180, double* %181)
store i32 %182, i32* %32
br label %183
183: ; preds = %169, %155
%184 = load i32, i32* %32
%185 = icmp slt i32 %184, 0
br i1 %185, label %186, label %187
186: ; preds = %183
store i32 -2, i32* %13
br label %191
187: ; preds = %183
%188 = load i32, i32* %32
%189 = load i32, i32* %31
%190 = add nsw i32 %188, %189
store i32 %190, i32* %13
br label %191
191: ; preds = %187, %186, %151, %104
%192 = load i32, i32* %13
ret i32 %192
}

LLVM IR (-O2):
%struct.pumas_physics = type { i32 }
define i32 @math_find_minimum(i32 %0, double (%struct.pumas_physics*, double, i8*)* %1, %struct.pumas_physics* %2, double %3, double %4, double* %5, double* %6, double %7, i32 %8, i8* %9, double* %10, double* %11) {
%13 = alloca double
%14 = icmp eq double* %5, null
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call double %1(%struct.pumas_physics* %2, double %3, i8* %9)
br label %19
17: ; preds = %12
%18 = load double, double* %5
br label %19
19: ; preds = %17, %15
%20 = phi double [ %16, %15 ], [ %18, %17 ]
%21 = icmp eq double* %6, null
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call double %1(%struct.pumas_physics* %2, double %4, i8* %9)
br label %26
24: ; preds = %19
%25 = load double, double* %6
br label %26
26: ; preds = %24, %22
%27 = phi double [ %23, %22 ], [ %25, %24 ]
%28 = fsub double %4, %3
%29 = tail call double @llvm.fabs.f64(double %28)
%30 = fmul double %29, %7
%31 = bitcast double* %13 to i8*
%32 = icmp sgt i32 %8, 0
br i1 %32, label %33, label %62
33: ; preds = %26, %55
%34 = phi i32 [ %60, %55 ], [ 0, %26 ]
%35 = phi double [ %59, %55 ], [ %27, %26 ]
%36 = phi double [ %58, %55 ], [ %20, %26 ]
%37 = phi double [ %57, %55 ], [ %3, %26 ]
%38 = phi double [ %56, %55 ], [ %4, %26 ]
%39 = fadd double %38, %37
%40 = fmul double %39, 5.000000e-01
%41 = tail call double %1(%struct.pumas_physics* %2, double %40, i8* %9)
%42 = fcmp olt double %41, %36
%43 = fcmp olt double %41, %35
%44 = select i1 %42, i1 %43, i1 false
br i1 %44, label %62, label %45
45: ; preds = %33
%46 = fsub double %38, %37
%47 = tail call double @llvm.fabs.f64(double %46)
%48 = fcmp ugt double %47, %30
br i1 %48, label %55, label %49
49: ; preds = %45
%50 = icmp eq double* %10, null
br i1 %50, label %52, label %51
51: ; preds = %49
store double %40, double* %10
br label %52
52: ; preds = %51, %49
%53 = icmp eq double* %11, null
br i1 %53, label %103, label %54
54: ; preds = %52
store double %41, double* %11
br label %103
55: ; preds = %45
%56 = select i1 %43, double %40, double %38
%57 = select i1 %43, double %37, double %40
%58 = select i1 %43, double %36, double %41
%59 = select i1 %43, double %41, double %35
%60 = add nuw nsw i32 %34, 1
%61 = icmp eq i32 %60, %8
br i1 %61, label %71, label %33
62: ; preds = %33, %26
%63 = phi double [ 0.000000e+00, %26 ], [ %41, %33 ]
%64 = phi double [ %4, %26 ], [ %38, %33 ]
%65 = phi double [ %3, %26 ], [ %37, %33 ]
%66 = phi double [ %20, %26 ], [ %36, %33 ]
%67 = phi double [ %27, %26 ], [ %35, %33 ]
%68 = phi i32 [ 0, %26 ], [ %34, %33 ]
%69 = phi double [ 0.000000e+00, %26 ], [ %40, %33 ]
store double %63, double* %13
%70 = icmp eq i32 %68, %8
br i1 %70, label %71, label %91
71: ; preds = %55, %62
%72 = phi double [ %69, %62 ], [ %40, %55 ]
%73 = phi double [ %67, %62 ], [ %59, %55 ]
%74 = phi double [ %66, %62 ], [ %58, %55 ]
%75 = phi double [ %65, %62 ], [ %57, %55 ]
%76 = phi double [ %64, %62 ], [ %56, %55 ]
%77 = phi double [ %63, %62 ], [ %41, %55 ]
%78 = fcmp olt double %74, %77
br i1 %78, label %79, label %80
79: ; preds = %71
store double %74, double* %13
br label %83
80: ; preds = %71
%81 = fcmp olt double %73, %77
br i1 %81, label %82, label %83
82: ; preds = %80
store double %73, double* %13
br label %83
83: ; preds = %80, %82, %79
%84 = phi double [ %74, %79 ], [ %73, %82 ], [ %77, %80 ]
%85 = phi double [ %75, %79 ], [ %76, %82 ], [ %72, %80 ]
%86 = icmp eq double* %10, null
br i1 %86, label %88, label %87
87: ; preds = %83
store double %85, double* %10
br label %88
88: ; preds = %87, %83
%89 = icmp eq double* %11, null
br i1 %89, label %103, label %90
90: ; preds = %88
store double %84, double* %11
br label %103
91: ; preds = %62
%92 = icmp eq i32 %0, 1
%93 = sub nsw i32 %8, %68
br i1 %92, label %94, label %96
94: ; preds = %91
%95 = call i32 @math_find_minimum_brent(double (%struct.pumas_physics*, double, i8*)* %1, %struct.pumas_physics* %2, double %65, double %69, double %64, double* %13, double %7, i32 %93, i8* %9, double* %10, double* %11)
br label %98
96: ; preds = %91
%97 = call i32 @math_find_minimum_bisection(double (%struct.pumas_physics*, double, i8*)* %1, %struct.pumas_physics* %2, double %65, double %69, double %64, double* %13, double %7, i32 %93, i8* %9, double* %10, double* %11)
br label %98
98: ; preds = %96, %94
%99 = phi i32 [ %95, %94 ], [ %97, %96 ]
%100 = icmp slt i32 %99, 0
%101 = add nsw i32 %99, %68
%102 = select i1 %100, i32 -2, i32 %101
br label %103
103: ; preds = %88, %90, %52, %54, %98
%104 = phi i32 [ %102, %98 ], [ %34, %54 ], [ %34, %52 ], [ -1, %90 ], [ -1, %88 ]
ret i32 %104
}