double max_golden(f, xlo, xhi, n, tol, err, flag) double (*f)(), xhi, xlo, tol;
int n, *err;
char flag;
{
  double x0, x1, x2, x3, y0, y1, y2, y3;
  *err = 0;
  if (n > 2) {
    x0 = max_grid(f, xlo, xhi, n, 'x');
    if (xlo < x0)
      xlo = x0 - 1.0 / n;
    if (xhi > x0)
      xhi = x0 + 1.0 / n;
  }
  x0 = xlo;
  y0 = f(xlo);
  x3 = xhi;
  y3 = f(xhi);
  x1 =
      0.6180339887498948482045870 * x0 + (1 - 0.6180339887498948482045870) * x3;
  y1 = f(x1);
  x2 =
      0.6180339887498948482045870 * x3 + (1 - 0.6180339887498948482045870) * x1;
  y2 = f(x2);
  while (fabs(x3 - x0) > tol) {
    if ((y1 >= y0) && (y1 >= y2)) {
      x3 = x2;
      y3 = y2;
      x2 = x1;
      y2 = y1;
      x1 = 0.6180339887498948482045870 * x0 +
           (1 - 0.6180339887498948482045870) * x3;
      y1 = f(x1);
    } else if ((y2 >= y3) && (y2 >= y1)) {
      x0 = x1;
      y0 = y1;
      x1 = x2;
      y1 = y2;
      x2 = 0.6180339887498948482045870 * x3 +
           (1 - 0.6180339887498948482045870) * x1;
      y2 = f(x2);
    } else {
      if (y3 > y0) {
        x0 = x2;
        y0 = y2;
      } else {
        x3 = x1;
        y3 = y1;
      }
      x1 = 0.6180339887498948482045870 * x0 +
           (1 - 0.6180339887498948482045870) * x3;
      y1 = f(x1);
      x2 = 0.6180339887498948482045870 * x3 +
           (1 - 0.6180339887498948482045870) * x1;
      y2 = f(x2);
    }
  }
  if (y0 >= y1)
    return (((flag == 'x') ? x0 : y0));
  if (y3 >= y2)
    return (((flag == 'x') ? x3 : y3));
  return ((y1 > y2) ? ((flag == 'x') ? x1 : y1) : ((flag == 'x') ? x2 : y2));
}


x86 assembly (clang, -O0):
<max_golden>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %cl,%al
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
movsd  %xmm2,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %al,-0x39(%rbp)
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
cmpl   $0x2,-0x24(%rbp)
jle    11db <max_golden+0xcb>
mov    -0x10(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x24(%rbp),%esi
mov    $0x78,%edx
mov    $0x2,%al
call   1030 <max_grid@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a7 <max_golden+0x97>
movsd  -0x48(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm2
movsd  0xe66(%rip),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    11d6 <max_golden+0xc6>
movsd  -0x48(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm2
movsd  0xe37(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11db <max_golden+0xcb>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rcx
movsd  -0x18(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x10(%rbp),%rcx
movsd  -0x20(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x80(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xdf0(%rip),%xmm1
mulsd  -0x60(%rbp),%xmm1
movsd  0xddb(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rcx
movsd  -0x50(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xdb7(%rip),%xmm1
mulsd  -0x50(%rbp),%xmm1
movsd  0xda2(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rcx
movsd  -0x58(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x78(%rbp)
movsd  -0x60(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movaps 0xd8a(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    146a <max_golden+0x35a>
movsd  -0x70(%rbp),%xmm0
ucomisd -0x68(%rbp),%xmm0
jb     132b <max_golden+0x21b>
movsd  -0x70(%rbp),%xmm0
ucomisd -0x78(%rbp),%xmm0
jb     132b <max_golden+0x21b>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xd16(%rip),%xmm1
mulsd  -0x60(%rbp),%xmm1
movsd  0xd01(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rcx
movsd  -0x50(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x70(%rbp)
jmp    1465 <max_golden+0x355>
movsd  -0x78(%rbp),%xmm0
ucomisd -0x80(%rbp),%xmm0
jb     13b1 <max_golden+0x2a1>
movsd  -0x78(%rbp),%xmm0
ucomisd -0x70(%rbp),%xmm0
jb     13b1 <max_golden+0x2a1>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xc90(%rip),%xmm1
mulsd  -0x50(%rbp),%xmm1
movsd  0xc7b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rcx
movsd  -0x58(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x78(%rbp)
jmp    1460 <max_golden+0x350>
movsd  -0x80(%rbp),%xmm0
ucomisd -0x68(%rbp),%xmm0
jbe    13da <max_golden+0x2ca>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    13ee <max_golden+0x2de>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xc15(%rip),%xmm1
mulsd  -0x60(%rbp),%xmm1
movsd  0xc00(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rcx
movsd  -0x50(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xbdc(%rip),%xmm1
mulsd  -0x50(%rbp),%xmm1
movsd  0xbc7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rcx
movsd  -0x58(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x78(%rbp)
jmp    1465 <max_golden+0x355>
jmp    1285 <max_golden+0x175>
movsd  -0x68(%rbp),%xmm0
ucomisd -0x70(%rbp),%xmm0
jb     14b8 <max_golden+0x3a8>
movsbl -0x39(%rbp),%eax
cmp    $0x78,%eax
jne    1499 <max_golden+0x389>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    14a6 <max_golden+0x396>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    15a0 <max_golden+0x490>
movsd  -0x80(%rbp),%xmm0
ucomisd -0x78(%rbp),%xmm0
jb     1506 <max_golden+0x3f6>
movsbl -0x39(%rbp),%eax
cmp    $0x78,%eax
jne    14e7 <max_golden+0x3d7>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    14f4 <max_golden+0x3e4>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    15a0 <max_golden+0x490>
movsd  -0x70(%rbp),%xmm0
ucomisd -0x78(%rbp),%xmm0
jbe    1557 <max_golden+0x447>
movsbl -0x39(%rbp),%eax
cmp    $0x78,%eax
jne    1535 <max_golden+0x425>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
jmp    1542 <max_golden+0x432>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
jmp    1593 <max_golden+0x483>
movsbl -0x39(%rbp),%eax
cmp    $0x78,%eax
jne    1576 <max_golden+0x466>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
jmp    1583 <max_golden+0x473>
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<max_golden>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %ecx,%r14d
movsd  %xmm2,0x38(%rsp)
mov    %rdi,%rbx
movl   $0x0,(%rdx)
cmp    $0x3,%esi
movsd  %xmm1,(%rsp)
jl     1198 <max_golden+0x88>
mov    %esi,%ebp
mov    %rbx,%rdi
mov    $0x78,%edx
mov    $0x2,%al
movaps %xmm0,0x60(%rsp)
call   1030 <max_grid@plt>
movapd 0x60(%rsp),%xmm0
cvtsi2sd %eax,%xmm3
ucomisd %xmm0,%xmm3
jbe    1171 <max_golden+0x61>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd  0xe97(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
movsd  (%rsp),%xmm1
ucomisd %xmm3,%xmm1
jbe    1198 <max_golden+0x88>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd  0xe7d(%rip),%xmm2
divsd  %xmm1,%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%rsp)
movapd %xmm0,0x60(%rsp)
mov    $0x1,%al
call   *%rbx
movapd %xmm0,0x50(%rsp)
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   *%rbx
movsd  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
mulsd  0xe4c(%rip),%xmm0
movapd 0x60(%rsp),%xmm1
mulsd  0xe46(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
mov    $0x1,%al
call   *%rbx
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm1
mulsd  0xe18(%rip),%xmm1
movsd  (%rsp),%xmm0
mulsd  0xe13(%rip),%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,0x40(%rsp)
mov    $0x1,%al
call   *%rbx
movapd 0x60(%rsp),%xmm9
movsd  (%rsp),%xmm6
movapd %xmm0,%xmm5
movapd %xmm6,%xmm0
subsd  %xmm9,%xmm0
andpd  0xdec(%rip),%xmm0
ucomisd 0x38(%rsp),%xmm0
jbe    14cf <max_golden+0x3bf>
movapd 0x50(%rsp),%xmm4
movsd  0xdc9(%rip),%xmm8
movapd 0x40(%rsp),%xmm7
movsd  0x20(%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm0
jmp    1354 <max_golden+0x244>
nopl   0x0(%rax)
movsd  %xmm6,(%rsp)
movsd  %xmm5,0x18(%rsp)
movsd  %xmm1,0x40(%rsp)
cmpltsd %xmm2,%xmm4
andpd  %xmm4,%xmm7
andnpd %xmm9,%xmm4
orpd   %xmm7,%xmm4
movapd %xmm4,0x50(%rsp)
movapd %xmm6,%xmm1
mulsd  %xmm10,%xmm1
movapd %xmm4,%xmm0
mulsd  %xmm8,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,0x20(%rsp)
mov    $0x1,%al
call   *%rbx
movsd  %xmm0,0x10(%rsp)
movapd 0x20(%rsp),%xmm1
mulsd  0xd43(%rip),%xmm1
movsd  (%rsp),%xmm0
mulsd  0xd3e(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   *%rbx
movsd  0x10(%rsp),%xmm11
movapd 0x20(%rsp),%xmm10
movsd  0x8(%rsp),%xmm3
movsd  0xd13(%rip),%xmm8
movapd %xmm0,%xmm5
movapd 0x50(%rsp),%xmm9
movsd  (%rsp),%xmm7
movsd  0x18(%rsp),%xmm4
movsd  0x40(%rsp),%xmm2
movsd  0x38(%rsp),%xmm1
movapd %xmm7,%xmm6
movapd %xmm3,%xmm7
movapd %xmm6,%xmm0
subsd  %xmm9,%xmm0
andpd  0xce0(%rip),%xmm0
ucomisd %xmm1,%xmm0
movapd %xmm11,%xmm0
movapd %xmm10,%xmm3
jbe    14ef <max_golden+0x3df>
ucomisd %xmm4,%xmm0
jb     1400 <max_golden+0x2f0>
ucomisd %xmm5,%xmm0
jb     1400 <max_golden+0x2f0>
movsd  %xmm0,0x10(%rsp)
movapd %xmm7,%xmm1
mulsd  0xc96(%rip),%xmm1
movapd %xmm9,%xmm0
mulsd  %xmm8,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,0x20(%rsp)
mov    $0x1,%al
movapd %xmm9,0x60(%rsp)
movapd %xmm4,0x50(%rsp)
movsd  %xmm5,0x18(%rsp)
movapd %xmm7,0x40(%rsp)
movsd  %xmm3,0x8(%rsp)
call   *%rbx
movapd 0x20(%rsp),%xmm10
movsd  0x8(%rsp),%xmm3
movapd 0x40(%rsp),%xmm7
movsd  0xc4b(%rip),%xmm8
movsd  0x18(%rsp),%xmm2
movapd 0x50(%rsp),%xmm4
movapd 0x60(%rsp),%xmm9
movsd  0x38(%rsp),%xmm1
movapd %xmm0,%xmm11
movsd  0x10(%rsp),%xmm5
jmp    1327 <max_golden+0x217>
cs nopw 0x0(%rax,%rax,1)
ucomisd %xmm2,%xmm5
movsd  0xc03(%rip),%xmm10
jb     14b0 <max_golden+0x3a0>
ucomisd %xmm0,%xmm5
jb     14b0 <max_golden+0x3a0>
movsd  %xmm0,0x10(%rsp)
movapd %xmm7,%xmm1
mulsd  %xmm10,%xmm1
movapd %xmm6,%xmm0
mulsd  %xmm8,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x50(%rsp)
mov    $0x1,%al
movsd  %xmm6,(%rsp)
movsd  %xmm5,0x18(%rsp)
movapd %xmm7,0x40(%rsp)
movsd  %xmm2,0x20(%rsp)
movsd  %xmm3,0x8(%rsp)
call   *%rbx
movsd  0xbaf(%rip),%xmm8
movsd  0x38(%rsp),%xmm1
movapd %xmm0,%xmm5
movsd  0x10(%rsp),%xmm4
movsd  0x8(%rsp),%xmm9
movapd 0x40(%rsp),%xmm10
movsd  0x50(%rsp),%xmm3
movsd  (%rsp),%xmm7
movsd  0x18(%rsp),%xmm11
movsd  0x20(%rsp),%xmm2
jmp    1327 <max_golden+0x217>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
ucomisd %xmm4,%xmm2
movapd %xmm2,%xmm1
ja     1270 <max_golden+0x160>
movapd %xmm3,%xmm6
movapd %xmm4,%xmm5
movapd %xmm0,%xmm1
jmp    1270 <max_golden+0x160>
movsd  0x8(%rsp),%xmm10
movsd  0x10(%rsp),%xmm11
movapd 0x50(%rsp),%xmm4
movapd 0x40(%rsp),%xmm7
movsd  0x20(%rsp),%xmm2
ucomisd %xmm11,%xmm4
jae    1518 <max_golden+0x408>
ucomisd %xmm5,%xmm2
jae    1525 <max_golden+0x415>
ucomisd %xmm5,%xmm11
movzbl %r14b,%eax
jbe    1536 <max_golden+0x426>
cmp    $0x78,%eax
je     1511 <max_golden+0x401>
movapd %xmm11,%xmm10
movapd %xmm10,%xmm9
jmp    1544 <max_golden+0x434>
cmp    $0x78,%r14b
je     1544 <max_golden+0x434>
movapd %xmm4,%xmm9
jmp    1544 <max_golden+0x434>
cmp    $0x78,%r14b
je     152f <max_golden+0x41f>
movapd %xmm2,%xmm6
movapd %xmm6,%xmm9
jmp    1544 <max_golden+0x434>
cmp    $0x78,%eax
je     153f <max_golden+0x42f>
movapd %xmm5,%xmm7
movapd %xmm7,%xmm9
movapd %xmm9,%xmm0
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @max_golden(double (...)* %0, double %1, double %2, i32 %3, double %4, i32* %5, i32 %6) {
%8 = alloca double
%9 = alloca double (...)*
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca double
%14 = alloca i32*
%15 = alloca i8
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = trunc i32 %6 to i8
store double (...)* %0, double (...)** %9
store double %1, double* %10
store double %2, double* %11
store i32 %3, i32* %12
store double %4, double* %13
store i32* %5, i32** %14
store i8 %24, i8* %15
%25 = load i32*, i32** %14
store i32 0, i32* %25
%26 = load i32, i32* %12
%27 = icmp sgt i32 %26, 2
br i1 %27, label %28, label %55
28: ; preds = %7
%29 = load double (...)*, double (...)** %9
%30 = load double, double* %10
%31 = load double, double* %11
%32 = load i32, i32* %12
%33 = call i32 (double (...)*, double, double, i32, i32, ...) bitcast (i32 (...)* @max_grid to i32 (double (...)*, double, double, i32, i32, ...)*)(double (...)* %29, double %30, double %31, i32 %32, i32 120)
%34 = sitofp i32 %33 to double
store double %34, double* %16
%35 = load double, double* %10
%36 = load double, double* %16
%37 = fcmp olt double %35, %36
br i1 %37, label %38, label %44
38: ; preds = %28
%39 = load double, double* %16
%40 = load i32, i32* %12
%41 = sitofp i32 %40 to double
%42 = fdiv double 1.000000e+00, %41
%43 = fsub double %39, %42
store double %43, double* %10
br label %44
44: ; preds = %38, %28
%45 = load double, double* %11
%46 = load double, double* %16
%47 = fcmp ogt double %45, %46
br i1 %47, label %48, label %54
48: ; preds = %44
%49 = load double, double* %16
%50 = load i32, i32* %12
%51 = sitofp i32 %50 to double
%52 = fdiv double 1.000000e+00, %51
%53 = fadd double %49, %52
store double %53, double* %11
br label %54
54: ; preds = %48, %44
br label %55
55: ; preds = %54, %7
%56 = load double, double* %10
store double %56, double* %16
%57 = load double (...)*, double (...)** %9
%58 = load double, double* %10
%59 = bitcast double (...)* %57 to double (double, ...)*
%60 = call double (double, ...) %59(double %58)
store double %60, double* %20
%61 = load double, double* %11
store double %61, double* %19
%62 = load double (...)*, double (...)** %9
%63 = load double, double* %11
%64 = bitcast double (...)* %62 to double (double, ...)*
%65 = call double (double, ...) %64(double %63)
store double %65, double* %23
%66 = load double, double* %16
%67 = load double, double* %19
%68 = fmul double 0x3FD8722191A02D60, %67
%69 = call double @llvm.fmuladd.f64(double 0x3FE3C6EF372FE950, double %66, double %68)
store double %69, double* %17
%70 = load double (...)*, double (...)** %9
%71 = load double, double* %17
%72 = bitcast double (...)* %70 to double (double, ...)*
%73 = call double (double, ...) %72(double %71)
store double %73, double* %21
%74 = load double, double* %19
%75 = load double, double* %17
%76 = fmul double 0x3FD8722191A02D60, %75
%77 = call double @llvm.fmuladd.f64(double 0x3FE3C6EF372FE950, double %74, double %76)
store double %77, double* %18
%78 = load double (...)*, double (...)** %9
%79 = load double, double* %18
%80 = bitcast double (...)* %78 to double (double, ...)*
%81 = call double (double, ...) %80(double %79)
store double %81, double* %22
br label %82
82: ; preds = %159, %55
%83 = load double, double* %19
%84 = load double, double* %16
%85 = fsub double %83, %84
%86 = call double @llvm.fabs.f64(double %85)
%87 = load double, double* %13
%88 = fcmp ogt double %86, %87
br i1 %88, label %89, label %160
89: ; preds = %82
%90 = load double, double* %21
%91 = load double, double* %20
%92 = fcmp oge double %90, %91
br i1 %92, label %93, label %110
93: ; preds = %89
%94 = load double, double* %21
%95 = load double, double* %22
%96 = fcmp oge double %94, %95
br i1 %96, label %97, label %110
97: ; preds = %93
%98 = load double, double* %18
store double %98, double* %19
%99 = load double, double* %22
store double %99, double* %23
%100 = load double, double* %17
store double %100, double* %18
%101 = load double, double* %21
store double %101, double* %22
%102 = load double, double* %16
%103 = load double, double* %19
%104 = fmul double 0x3FD8722191A02D60, %103
%105 = call double @llvm.fmuladd.f64(double 0x3FE3C6EF372FE950, double %102, double %104)
store double %105, double* %17
%106 = load double (...)*, double (...)** %9
%107 = load double, double* %17
%108 = bitcast double (...)* %106 to double (double, ...)*
%109 = call double (double, ...) %108(double %107)
store double %109, double* %21
br label %159
110: ; preds = %93, %89
%111 = load double, double* %22
%112 = load double, double* %23
%113 = fcmp oge double %111, %112
br i1 %113, label %114, label %131
114: ; preds = %110
%115 = load double, double* %22
%116 = load double, double* %21
%117 = fcmp oge double %115, %116
br i1 %117, label %118, label %131
118: ; preds = %114
%119 = load double, double* %17
store double %119, double* %16
%120 = load double, double* %21
store double %120, double* %20
%121 = load double, double* %18
store double %121, double* %17
%122 = load double, double* %22
store double %122, double* %21
%123 = load double, double* %19
%124 = load double, double* %17
%125 = fmul double 0x3FD8722191A02D60, %124
%126 = call double @llvm.fmuladd.f64(double 0x3FE3C6EF372FE950, double %123, double %125)
store double %126, double* %18
%127 = load double (...)*, double (...)** %9
%128 = load double, double* %18
%129 = bitcast double (...)* %127 to double (double, ...)*
%130 = call double (double, ...) %129(double %128)
store double %130, double* %22
br label %158
131: ; preds = %114, %110
%132 = load double, double* %23
%133 = load double, double* %20
%134 = fcmp ogt double %132, %133
br i1 %134, label %135, label %138
135: ; preds = %131
%136 = load double, double* %18
store double %136, double* %16
%137 = load double, double* %22
store double %137, double* %20
br label %141
138: ; preds = %131
%139 = load double, double* %17
store double %139, double* %19
%140 = load double, double* %21
store double %140, double* %23
br label %141
141: ; preds = %138, %135
%142 = load double, double* %16
%143 = load double, double* %19
%144 = fmul double 0x3FD8722191A02D60, %143
%145 = call double @llvm.fmuladd.f64(double 0x3FE3C6EF372FE950, double %142, double %144)
store double %145, double* %17
%146 = load double (...)*, double (...)** %9
%147 = load double, double* %17
%148 = bitcast double (...)* %146 to double (double, ...)*
%149 = call double (double, ...) %148(double %147)
store double %149, double* %21
%150 = load double, double* %19
%151 = load double, double* %17
%152 = fmul double 0x3FD8722191A02D60, %151
%153 = call double @llvm.fmuladd.f64(double 0x3FE3C6EF372FE950, double %150, double %152)
store double %153, double* %18
%154 = load double (...)*, double (...)** %9
%155 = load double, double* %18
%156 = bitcast double (...)* %154 to double (double, ...)*
%157 = call double (double, ...) %156(double %155)
store double %157, double* %22
br label %158
158: ; preds = %141, %118
br label %159
159: ; preds = %158, %97
br label %82
160: ; preds = %82
%161 = load double, double* %20
%162 = load double, double* %21
%163 = fcmp oge double %161, %162
br i1 %163, label %164, label %174
164: ; preds = %160
%165 = load i8, i8* %15
%166 = sext i8 %165 to i32
%167 = icmp eq i32 %166, 120
br i1 %167, label %168, label %170
168: ; preds = %164
%169 = load double, double* %16
br label %172
170: ; preds = %164
%171 = load double, double* %20
br label %172
172: ; preds = %170, %168
%173 = phi double [ %169, %168 ], [ %171, %170 ]
store double %173, double* %8
br label %214
174: ; preds = %160
%175 = load double, double* %23
%176 = load double, double* %22
%177 = fcmp oge double %175, %176
br i1 %177, label %178, label %188
178: ; preds = %174
%179 = load i8, i8* %15
%180 = sext i8 %179 to i32
%181 = icmp eq i32 %180, 120
br i1 %181, label %182, label %184
182: ; preds = %178
%183 = load double, double* %19
br label %186
184: ; preds = %178
%185 = load double, double* %23
br label %186
186: ; preds = %184, %182
%187 = phi double [ %183, %182 ], [ %185, %184 ]
store double %187, double* %8
br label %214
188: ; preds = %174
%189 = load double, double* %21
%190 = load double, double* %22
%191 = fcmp ogt double %189, %190
br i1 %191, label %192, label %202
192: ; preds = %188
%193 = load i8, i8* %15
%194 = sext i8 %193 to i32
%195 = icmp eq i32 %194, 120
br i1 %195, label %196, label %198
196: ; preds = %192
%197 = load double, double* %17
br label %200
198: ; preds = %192
%199 = load double, double* %21
br label %200
200: ; preds = %198, %196
%201 = phi double [ %197, %196 ], [ %199, %198 ]
br label %212
202: ; preds = %188
%203 = load i8, i8* %15
%204 = sext i8 %203 to i32
%205 = icmp eq i32 %204, 120
br i1 %205, label %206, label %208
206: ; preds = %202
%207 = load double, double* %18
br label %210
208: ; preds = %202
%209 = load double, double* %22
br label %210
210: ; preds = %208, %206
%211 = phi double [ %207, %206 ], [ %209, %208 ]
br label %212
212: ; preds = %210, %200
%213 = phi double [ %201, %200 ], [ %211, %210 ]
store double %213, double* %8
br label %214
214: ; preds = %212, %186, %172
%215 = load double, double* %8
ret double %215
}

LLVM IR (-O2):
define double @max_golden(double (...)* %0, double %1, double %2, i32 %3, double %4, i32* nocapture writeonly %5, i32 %6) {
store i32 0, i32* %5
%8 = icmp sgt i32 %3, 2
br i1 %8, label %9, label %24
9: ; preds = %7
%10 = tail call i32 (double (...)*, double, double, i32, i32, ...) bitcast (i32 (...)* @max_grid to i32 (double (...)*, double, double, i32, i32, ...)*)(double (...)* %0, double %1, double %2, i32 %3, i32 120)
%11 = sitofp i32 %10 to double
%12 = fcmp ogt double %11, %1
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = sitofp i32 %3 to double
%15 = fdiv double 1.000000e+00, %14
%16 = fsub double %11, %15
br label %17
17: ; preds = %13, %9
%18 = phi double [ %16, %13 ], [ %1, %9 ]
%19 = fcmp olt double %11, %2
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = sitofp i32 %3 to double
%22 = fdiv double 1.000000e+00, %21
%23 = fadd double %22, %11
br label %24
24: ; preds = %17, %20, %7
%25 = phi double [ %23, %20 ], [ %2, %17 ], [ %2, %7 ]
%26 = phi double [ %18, %20 ], [ %18, %17 ], [ %1, %7 ]
%27 = bitcast double (...)* %0 to double (double, ...)*
%28 = tail call double (double, ...) %27(double %26)
%29 = tail call double (double, ...) %27(double %25)
%30 = fmul double %25, 0x3FD8722191A02D60
%31 = tail call double @llvm.fmuladd.f64(double %26, double 0x3FE3C6EF372FE950, double %30)
%32 = tail call double (double, ...) %27(double %31)
%33 = fmul double %31, 0x3FD8722191A02D60
%34 = tail call double @llvm.fmuladd.f64(double %25, double 0x3FE3C6EF372FE950, double %33)
%35 = tail call double (double, ...) %27(double %34)
%36 = fsub double %25, %26
%37 = tail call double @llvm.fabs.f64(double %36)
%38 = fcmp ogt double %37, %4
br i1 %38, label %39, label %87
39: ; preds = %24, %75
%40 = phi double [ %83, %75 ], [ %29, %24 ]
%41 = phi double [ %82, %75 ], [ %35, %24 ]
%42 = phi double [ %81, %75 ], [ %32, %24 ]
%43 = phi double [ %80, %75 ], [ %28, %24 ]
%44 = phi double [ %79, %75 ], [ %25, %24 ]
%45 = phi double [ %78, %75 ], [ %34, %24 ]
%46 = phi double [ %77, %75 ], [ %31, %24 ]
%47 = phi double [ %76, %75 ], [ %26, %24 ]
%48 = fcmp ult double %42, %43
%49 = fcmp ult double %42, %41
%50 = select i1 %48, i1 true, i1 %49
br i1 %50, label %55, label %51
51: ; preds = %39
%52 = fmul double %45, 0x3FD8722191A02D60
%53 = tail call double @llvm.fmuladd.f64(double %47, double 0x3FE3C6EF372FE950, double %52)
%54 = tail call double (double, ...) %27(double %53)
br label %75
55: ; preds = %39
%56 = fcmp ult double %41, %40
%57 = fcmp ult double %41, %42
%58 = select i1 %56, i1 true, i1 %57
br i1 %58, label %63, label %59
59: ; preds = %55
%60 = fmul double %45, 0x3FD8722191A02D60
%61 = tail call double @llvm.fmuladd.f64(double %44, double 0x3FE3C6EF372FE950, double %60)
%62 = tail call double (double, ...) %27(double %61)
br label %75
63: ; preds = %55
%64 = fcmp ogt double %40, %43
%65 = select i1 %64, double %45, double %47
%66 = select i1 %64, double %44, double %46
%67 = select i1 %64, double %41, double %43
%68 = select i1 %64, double %40, double %42
%69 = fmul double %66, 0x3FD8722191A02D60
%70 = tail call double @llvm.fmuladd.f64(double %65, double 0x3FE3C6EF372FE950, double %69)
%71 = tail call double (double, ...) %27(double %70)
%72 = fmul double %70, 0x3FD8722191A02D60
%73 = tail call double @llvm.fmuladd.f64(double %66, double 0x3FE3C6EF372FE950, double %72)
%74 = tail call double (double, ...) %27(double %73)
br label %75
75: ; preds = %59, %63, %51
%76 = phi double [ %47, %51 ], [ %46, %59 ], [ %65, %63 ]
%77 = phi double [ %53, %51 ], [ %45, %59 ], [ %70, %63 ]
%78 = phi double [ %46, %51 ], [ %61, %59 ], [ %73, %63 ]
%79 = phi double [ %45, %51 ], [ %44, %59 ], [ %66, %63 ]
%80 = phi double [ %43, %51 ], [ %42, %59 ], [ %67, %63 ]
%81 = phi double [ %54, %51 ], [ %41, %59 ], [ %71, %63 ]
%82 = phi double [ %42, %51 ], [ %62, %59 ], [ %74, %63 ]
%83 = phi double [ %41, %51 ], [ %40, %59 ], [ %68, %63 ]
%84 = fsub double %79, %76
%85 = tail call double @llvm.fabs.f64(double %84)
%86 = fcmp ogt double %85, %4
br i1 %86, label %39, label %87
87: ; preds = %75, %24
%88 = phi double [ %26, %24 ], [ %76, %75 ]
%89 = phi double [ %31, %24 ], [ %77, %75 ]
%90 = phi double [ %34, %24 ], [ %78, %75 ]
%91 = phi double [ %25, %24 ], [ %79, %75 ]
%92 = phi double [ %28, %24 ], [ %80, %75 ]
%93 = phi double [ %32, %24 ], [ %81, %75 ]
%94 = phi double [ %35, %24 ], [ %82, %75 ]
%95 = phi double [ %29, %24 ], [ %83, %75 ]
%96 = fcmp ult double %92, %93
br i1 %96, label %101, label %97
97: ; preds = %87
%98 = and i32 %6, 255
%99 = icmp eq i32 %98, 120
%100 = select i1 %99, double %88, double %92
br label %115
101: ; preds = %87
%102 = fcmp ult double %95, %94
br i1 %102, label %107, label %103
103: ; preds = %101
%104 = and i32 %6, 255
%105 = icmp eq i32 %104, 120
%106 = select i1 %105, double %91, double %95
br label %115
107: ; preds = %101
%108 = fcmp ogt double %93, %94
%109 = and i32 %6, 255
%110 = icmp eq i32 %109, 120
br i1 %108, label %111, label %113
111: ; preds = %107
%112 = select i1 %110, double %89, double %93
br label %115
113: ; preds = %107
%114 = select i1 %110, double %90, double %94
br label %115
115: ; preds = %111, %113, %103, %97
%116 = phi double [ %100, %97 ], [ %106, %103 ], [ %112, %111 ], [ %114, %113 ]
ret double %116
}