double max_quad(f, xlo, xhi, n, tol, err, flag) double (*f)(), xhi, xlo, tol;
int n, *err;
char flag;
{
  double x0, x1, x2, xnew, y0, y1, y2, ynew, a, b;
  *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(x0);
  x2 = xhi;
  y2 = f(x2);
  x1 = (x0 + x2) / 2;
  y1 = f(x1);
  while (x2 - x0 > tol) {
    if ((y0 > y1) | (y2 > y1)) {
      if (y0 > y2) {
        x2 = x1;
        y2 = y1;
      } else {
        x0 = x1;
        y0 = y1;
      }
      x1 = (x0 + x2) / 2;
      y1 = f(x1);
    } else {
      a = (y1 - y0) * (x2 - x1) + (y1 - y2) * (x1 - x0);
      b = ((y1 - y0) * (x2 - x1) * (x2 + x1) +
           (y1 - y2) * (x1 - x0) * (x1 + x0)) /
          2;
      if ((a <= 0) | (b < x0 * a) | (b > x2 * a)) {
        xnew = ((x2 - x1) > (x1 - x0)) ? (x1 + x2) / 2 : (x0 + x1) / 2;
      } else {
        xnew = b / a;
        if (10 * xnew < (9 * x0 + x1))
          xnew = (9 * x0 + x1) / 10;
        if (10 * xnew > (9 * x2 + x1))
          xnew = (9 * x2 + x1) / 10;
        if (fabs(xnew - x1) < 0.001 * (x2 - x0)) {
          if ((x2 - x1) > (x1 - x0))
            xnew = (99 * x1 + x2) / 100;
          else
            xnew = (99 * x1 + x0) / 100;
        }
      }
      ynew = f(xnew);
      if (xnew > x1) {
        if (ynew >= y1) {
          x0 = x1;
          y0 = y1;
          x1 = xnew;
          y1 = ynew;
        } else {
          x2 = xnew;
          y2 = ynew;
        }
      } else {
        if (ynew >= y1) {
          x2 = x1;
          y2 = y1;
          x1 = xnew;
          y1 = ynew;
        } else {
          x0 = xnew;
          y0 = ynew;
        }
      }
    }
  }
  return (((flag == 'x') ? x1 : y1));
}


x86 assembly (clang, -O0):
<max_quad>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %cl,%al
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
movsd  %xmm2,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %al,-0x31(%rbp)
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
cmpl   $0x2,-0x1c(%rbp)
jle    11db <max_quad+0xcb>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    -0x1c(%rbp),%esi
mov    $0x78,%edx
mov    $0x2,%al
call   1030 <max_grid@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a7 <max_quad+0x97>
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm2
movsd  0xe66(%rip),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    11d6 <max_quad+0xc6>
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm2
movsd  0xe37(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11db <max_quad+0xcb>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rcx
movsd  -0x40(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rcx
movsd  -0x50(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  0xde3(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rcx
movsd  -0x48(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    16b7 <max_quad+0x5a7>
movsd  -0x60(%rbp),%xmm0
ucomisd -0x68(%rbp),%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
movsd  -0x70(%rbp),%xmm0
ucomisd -0x68(%rbp),%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmp    $0x0,%eax
je     12f4 <max_quad+0x1e4>
movsd  -0x60(%rbp),%xmm0
ucomisd -0x70(%rbp),%xmm0
jbe    12ae <max_quad+0x19e>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    12c2 <max_quad+0x1b2>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  0xd34(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rcx
movsd  -0x48(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x68(%rbp)
jmp    16b2 <max_quad+0x5a2>
movsd  -0x68(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
subsd  -0x48(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
subsd  -0x70(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm3
subsd  -0x40(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x68(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
subsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x50(%rbp),%xmm2
addsd  -0x48(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
subsd  -0x70(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm3
subsd  -0x40(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movsd  -0x48(%rbp),%xmm3
addsd  -0x40(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xc83(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
xorps  %xmm0,%xmm0
ucomisd -0x80(%rbp),%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x40(%rbp),%xmm0
mulsd  -0x80(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x50(%rbp),%xmm1
mulsd  -0x80(%rbp),%xmm1
ucomisd %xmm1,%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmp    $0x0,%eax
je     145d <max_quad+0x34d>
movsd  -0x50(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
subsd  -0x40(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    142d <max_quad+0x31d>
movsd  -0x48(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  0xbec(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    144b <max_quad+0x33b>
movsd  -0x40(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  0xbc9(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x58(%rbp)
jmp    15df <max_quad+0x4cf>
movsd  -0x88(%rbp),%xmm0
ff
divsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xba1(%rip),%xmm1
mulsd  -0x58(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  0xb82(%rip),%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    14cb <max_quad+0x3bb>
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xb5e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xb56(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xb45(%rip),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  0xb26(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1527 <max_quad+0x417>
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xb02(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xafa(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
subsd  -0x48(%rbp),%xmm1
movaps 0xb08(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm2
subsd  -0x40(%rbp),%xmm2
movsd  0xad2(%rip),%xmm0
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    15da <max_quad+0x4ca>
movsd  -0x50(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
subsd  -0x40(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    15aa <max_quad+0x49a>
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  0xaa4(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xa8c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    15d5 <max_quad+0x4c5>
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  0xa74(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xa5c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    15da <max_quad+0x4ca>
jmp    15df <max_quad+0x4cf>
mov    -0x8(%rbp),%rcx
movsd  -0x58(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x78(%rbp)
movsd  -0x58(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    1657 <max_quad+0x547>
movsd  -0x78(%rbp),%xmm0
ucomisd -0x68(%rbp),%xmm0
jb     163e <max_quad+0x52e>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1652 <max_quad+0x542>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    16ad <max_quad+0x59d>
movsd  -0x78(%rbp),%xmm0
ucomisd -0x68(%rbp),%xmm0
jb     1694 <max_quad+0x584>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    16a8 <max_quad+0x598>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    16ad <max_quad+0x59d>
jmp    16b2 <max_quad+0x5a2>
jmp    1240 <max_quad+0x130>
movsbl -0x31(%rbp),%eax
cmp    $0x78,%eax
jne    16d6 <max_quad+0x5c6>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
jmp    16e3 <max_quad+0x5d3>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<max_quad>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %ecx,%r14d
movsd  %xmm2,0x28(%rsp)
mov    %rdi,%rbx
movl   $0x0,(%rdx)
cmp    $0x3,%esi
movapd %xmm1,0x10(%rsp)
jl     1198 <max_quad+0x88>
mov    %esi,%ebp
mov    %rbx,%rdi
mov    $0x78,%edx
mov    $0x2,%al
movsd  %xmm0,0x8(%rsp)
call   1030 <max_grid@plt>
movsd  0x8(%rsp),%xmm0
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
ucomisd %xmm0,%xmm2
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
jbe    1176 <max_quad+0x66>
movsd  0xe92(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
movapd 0x10(%rsp),%xmm3
ucomisd %xmm2,%xmm3
jbe    1198 <max_quad+0x88>
movsd  0xe7e(%rip),%xmm3
divsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
movapd %xmm3,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   *%rbx
movsd  %xmm0,0x20(%rsp)
movaps 0x10(%rsp),%xmm0
mov    $0x1,%al
call   *%rbx
movaps %xmm0,0x40(%rsp)
movapd 0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
mulsd  0xe46(%rip),%xmm0
movapd %xmm0,0x30(%rsp)
mov    $0x1,%al
call   *%rbx
movapd 0x10(%rsp),%xmm10
movsd  0x8(%rsp),%xmm8
movapd %xmm0,%xmm5
movapd %xmm10,%xmm7
subsd  %xmm8,%xmm7
ucomisd 0x28(%rsp),%xmm7
jbe    1553 <max_quad+0x443>
movapd 0x40(%rsp),%xmm2
movsd  0x20(%rsp),%xmm6
movapd 0x30(%rsp),%xmm1
jmp    12b1 <max_quad+0x1a1>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm5,0x10(%rsp)
movapd %xmm2,%xmm5
movapd %xmm1,%xmm8
movsd  %xmm8,0x8(%rsp)
movsd  %xmm5,0x30(%rsp)
cmpltsd %xmm6,%xmm2
andpd  %xmm2,%xmm1
andnpd %xmm10,%xmm2
orpd   %xmm1,%xmm2
movapd %xmm2,0x40(%rsp)
movapd %xmm2,%xmm0
addsd  %xmm8,%xmm0
mulsd  0xdab(%rip),%xmm0
movapd %xmm0,0x50(%rsp)
mov    $0x1,%al
call   *%rbx
movapd 0x50(%rsp),%xmm4
movsd  0x8(%rsp),%xmm8
movapd %xmm0,%xmm5
movapd 0x40(%rsp),%xmm10
movsd  0x10(%rsp),%xmm6
movsd  0x30(%rsp),%xmm2
movsd  0x28(%rsp),%xmm1
movapd %xmm10,%xmm7
subsd  %xmm8,%xmm7
ucomisd %xmm1,%xmm7
movapd %xmm4,%xmm1
jbe    1559 <max_quad+0x449>
ucomisd %xmm5,%xmm6
ja     1400 <max_quad+0x2f0>
ucomisd %xmm5,%xmm2
ja     1400 <max_quad+0x2f0>
movapd %xmm5,%xmm0
movsd  %xmm6,0x20(%rsp)
subsd  %xmm6,%xmm0
movapd %xmm10,%xmm9
subsd  %xmm1,%xmm9
movapd %xmm5,0x50(%rsp)
movapd %xmm5,%xmm6
subsd  %xmm2,%xmm6
movapd %xmm1,%xmm11
subsd  %xmm8,%xmm11
mulsd  %xmm11,%xmm6
mulsd  %xmm9,%xmm0
movapd %xmm0,%xmm4
addsd  %xmm6,%xmm4
movapd %xmm1,%xmm3
addsd  %xmm10,%xmm3
movapd %xmm1,%xmm5
addsd  %xmm8,%xmm5
mulsd  %xmm5,%xmm6
mulsd  %xmm3,%xmm0
addsd  %xmm6,%xmm0
mulsd  0xce3(%rip),%xmm0
movapd %xmm10,%xmm6
mulsd  %xmm4,%xmm6
ucomisd %xmm6,%xmm0
movapd %xmm2,0x40(%rsp)
ja     1420 <max_quad+0x310>
xorpd  %xmm6,%xmm6
ucomisd %xmm4,%xmm6
jae    1420 <max_quad+0x310>
movapd %xmm8,%xmm6
mulsd  %xmm4,%xmm6
ucomisd %xmm0,%xmm6
ja     1420 <max_quad+0x310>
divsd  %xmm4,%xmm0
movapd %xmm0,%xmm4
movsd  0xca1(%rip),%xmm5
mulsd  %xmm5,%xmm4
movapd %xmm8,%xmm3
mulsd  0xc98(%rip),%xmm3
addsd  %xmm1,%xmm3
ucomisd %xmm4,%xmm3
jbe    139a <max_quad+0x28a>
divsd  %xmm5,%xmm3
movapd %xmm3,%xmm0
movapd %xmm0,%xmm4
mulsd  %xmm5,%xmm4
movapd %xmm10,%xmm3
mulsd  0xc71(%rip),%xmm3
addsd  %xmm1,%xmm3
ucomisd %xmm3,%xmm4
jbe    13c1 <max_quad+0x2b1>
divsd  %xmm5,%xmm3
movapd %xmm3,%xmm0
movapd %xmm0,%xmm3
subsd  %xmm1,%xmm3
andpd  0xc7f(%rip),%xmm3
mulsd  0xc4f(%rip),%xmm7
ucomisd %xmm3,%xmm7
jbe    145a <max_quad+0x34a>
movapd %xmm1,%xmm0
ucomisd %xmm11,%xmm9
jbe    1445 <max_quad+0x335>
mulsd  0xc3e(%rip),%xmm0
addsd  %xmm10,%xmm0
jmp    1452 <max_quad+0x342>
nopl   0x0(%rax)
ucomisd %xmm2,%xmm6
jbe    1220 <max_quad+0x110>
movsd  %xmm6,0x10(%rsp)
jmp    122f <max_quad+0x11f>
cs nopw 0x0(%rax,%rax,1)
nop
cmpltsd %xmm9,%xmm11
andpd  %xmm11,%xmm3
andnpd %xmm5,%xmm11
orpd   %xmm3,%xmm11
mulsd  0xbd2(%rip),%xmm11
movapd %xmm11,%xmm0
jmp    145a <max_quad+0x34a>
mulsd  0xbe3(%rip),%xmm0
addsd  %xmm8,%xmm0
divsd  0xbde(%rip),%xmm0
movapd %xmm0,0x60(%rsp)
movapd %xmm10,0x10(%rsp)
movsd  %xmm8,0x8(%rsp)
mov    $0x1,%al
movapd %xmm1,0x30(%rsp)
call   *%rbx
movapd 0x60(%rsp),%xmm10
movapd 0x30(%rsp),%xmm7
ucomisd %xmm7,%xmm10
movapd 0x50(%rsp),%xmm5
movapd %xmm5,%xmm1
cmpnlesd %xmm0,%xmm1
movapd %xmm1,%xmm2
andpd  %xmm7,%xmm2
movapd %xmm1,%xmm4
andnpd %xmm10,%xmm4
orpd   %xmm2,%xmm4
jbe    1500 <max_quad+0x3f0>
ucomisd %xmm5,%xmm0
movapd 0x40(%rsp),%xmm3
movsd  0x20(%rsp),%xmm6
jb     14cd <max_quad+0x3bd>
movapd 0x10(%rsp),%xmm10
movapd %xmm5,%xmm6
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm8
jb     14e3 <max_quad+0x3d3>
movapd %xmm3,%xmm2
movapd %xmm7,%xmm8
andpd  %xmm1,%xmm5
andnpd %xmm0,%xmm1
orpd   %xmm1,%xmm5
jmp    1293 <max_quad+0x183>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
ucomisd %xmm5,%xmm0
movapd %xmm0,%xmm9
movapd 0x10(%rsp),%xmm6
movapd 0x40(%rsp),%xmm2
jb     1522 <max_quad+0x412>
movapd %xmm7,%xmm6
movsd  0x20(%rsp),%xmm9
movsd  0x8(%rsp),%xmm3
jb     1533 <max_quad+0x423>
movapd %xmm5,%xmm2
movapd %xmm3,%xmm10
movapd %xmm10,%xmm8
andpd  %xmm1,%xmm5
andnpd %xmm0,%xmm1
orpd   %xmm1,%xmm5
movapd %xmm6,%xmm10
movapd %xmm9,%xmm6
jmp    1293 <max_quad+0x183>
movapd 0x30(%rsp),%xmm4
cmp    $0x78,%r14b
je     1563 <max_quad+0x453>
movapd %xmm5,%xmm4
movapd %xmm4,%xmm0
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @max_quad(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 i32
%12 = alloca double
%13 = alloca i32*
%14 = alloca i8
%15 = alloca double
%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 = alloca double
%25 = trunc i32 %6 to i8
store double (...)* %0, double (...)** %8
store double %1, double* %9
store double %2, double* %10
store i32 %3, i32* %11
store double %4, double* %12
store i32* %5, i32** %13
store i8 %25, i8* %14
%26 = load i32*, i32** %13
store i32 0, i32* %26
%27 = load i32, i32* %11
%28 = icmp sgt i32 %27, 2
br i1 %28, label %29, label %56
29: ; preds = %7
%30 = load double (...)*, double (...)** %8
%31 = load double, double* %9
%32 = load double, double* %10
%33 = load i32, i32* %11
%34 = call i32 (double (...)*, double, double, i32, i32, ...) bitcast (i32 (...)* @max_grid to i32 (double (...)*, double, double, i32, i32, ...)*)(double (...)* %30, double %31, double %32, i32 %33, i32 120)
%35 = sitofp i32 %34 to double
store double %35, double* %15
%36 = load double, double* %9
%37 = load double, double* %15
%38 = fcmp olt double %36, %37
br i1 %38, label %39, label %45
39: ; preds = %29
%40 = load double, double* %15
%41 = load i32, i32* %11
%42 = sitofp i32 %41 to double
%43 = fdiv double 1.000000e+00, %42
%44 = fsub double %40, %43
store double %44, double* %9
br label %45
45: ; preds = %39, %29
%46 = load double, double* %10
%47 = load double, double* %15
%48 = fcmp ogt double %46, %47
br i1 %48, label %49, label %55
49: ; preds = %45
%50 = load double, double* %15
%51 = load i32, i32* %11
%52 = sitofp i32 %51 to double
%53 = fdiv double 1.000000e+00, %52
%54 = fadd double %50, %53
store double %54, double* %10
br label %55
55: ; preds = %49, %45
br label %56
56: ; preds = %55, %7
%57 = load double, double* %9
store double %57, double* %15
%58 = load double (...)*, double (...)** %8
%59 = load double, double* %15
%60 = bitcast double (...)* %58 to double (double, ...)*
%61 = call double (double, ...) %60(double %59)
store double %61, double* %19
%62 = load double, double* %10
store double %62, double* %17
%63 = load double (...)*, double (...)** %8
%64 = load double, double* %17
%65 = bitcast double (...)* %63 to double (double, ...)*
%66 = call double (double, ...) %65(double %64)
store double %66, double* %21
%67 = load double, double* %15
%68 = load double, double* %17
%69 = fadd double %67, %68
%70 = fdiv double %69, 2.000000e+00
store double %70, double* %16
%71 = load double (...)*, double (...)** %8
%72 = load double, double* %16
%73 = bitcast double (...)* %71 to double (double, ...)*
%74 = call double (double, ...) %73(double %72)
store double %74, double* %20
br label %75
75: ; preds = %279, %56
%76 = load double, double* %17
%77 = load double, double* %15
%78 = fsub double %76, %77
%79 = load double, double* %12
%80 = fcmp ogt double %78, %79
br i1 %80, label %81, label %280
81: ; preds = %75
%82 = load double, double* %19
%83 = load double, double* %20
%84 = fcmp ogt double %82, %83
%85 = zext i1 %84 to i32
%86 = load double, double* %21
%87 = load double, double* %20
%88 = fcmp ogt double %86, %87
%89 = zext i1 %88 to i32
%90 = or i32 %85, %89
%91 = icmp ne i32 %90, 0
br i1 %91, label %92, label %111
92: ; preds = %81
%93 = load double, double* %19
%94 = load double, double* %21
%95 = fcmp ogt double %93, %94
br i1 %95, label %96, label %99
96: ; preds = %92
%97 = load double, double* %16
store double %97, double* %17
%98 = load double, double* %20
store double %98, double* %21
br label %102
99: ; preds = %92
%100 = load double, double* %16
store double %100, double* %15
%101 = load double, double* %20
store double %101, double* %19
br label %102
102: ; preds = %99, %96
%103 = load double, double* %15
%104 = load double, double* %17
%105 = fadd double %103, %104
%106 = fdiv double %105, 2.000000e+00
store double %106, double* %16
%107 = load double (...)*, double (...)** %8
%108 = load double, double* %16
%109 = bitcast double (...)* %107 to double (double, ...)*
%110 = call double (double, ...) %109(double %108)
store double %110, double* %20
br label %279
111: ; preds = %81
%112 = load double, double* %20
%113 = load double, double* %19
%114 = fsub double %112, %113
%115 = load double, double* %17
%116 = load double, double* %16
%117 = fsub double %115, %116
%118 = load double, double* %20
%119 = load double, double* %21
%120 = fsub double %118, %119
%121 = load double, double* %16
%122 = load double, double* %15
%123 = fsub double %121, %122
%124 = fmul double %120, %123
%125 = call double @llvm.fmuladd.f64(double %114, double %117, double %124)
store double %125, double* %23
%126 = load double, double* %20
%127 = load double, double* %19
%128 = fsub double %126, %127
%129 = load double, double* %17
%130 = load double, double* %16
%131 = fsub double %129, %130
%132 = fmul double %128, %131
%133 = load double, double* %17
%134 = load double, double* %16
%135 = fadd double %133, %134
%136 = load double, double* %20
%137 = load double, double* %21
%138 = fsub double %136, %137
%139 = load double, double* %16
%140 = load double, double* %15
%141 = fsub double %139, %140
%142 = fmul double %138, %141
%143 = load double, double* %16
%144 = load double, double* %15
%145 = fadd double %143, %144
%146 = fmul double %142, %145
%147 = call double @llvm.fmuladd.f64(double %132, double %135, double %146)
%148 = fdiv double %147, 2.000000e+00
store double %148, double* %24
%149 = load double, double* %23
%150 = fcmp ole double %149, 0.000000e+00
%151 = zext i1 %150 to i32
%152 = load double, double* %24
%153 = load double, double* %15
%154 = load double, double* %23
%155 = fmul double %153, %154
%156 = fcmp olt double %152, %155
%157 = zext i1 %156 to i32
%158 = or i32 %151, %157
%159 = load double, double* %24
%160 = load double, double* %17
%161 = load double, double* %23
%162 = fmul double %160, %161
%163 = fcmp ogt double %159, %162
%164 = zext i1 %163 to i32
%165 = or i32 %158, %164
%166 = icmp ne i32 %165, 0
br i1 %166, label %167, label %187
167: ; preds = %111
%168 = load double, double* %17
%169 = load double, double* %16
%170 = fsub double %168, %169
%171 = load double, double* %16
%172 = load double, double* %15
%173 = fsub double %171, %172
%174 = fcmp ogt double %170, %173
br i1 %174, label %175, label %180
175: ; preds = %167
%176 = load double, double* %16
%177 = load double, double* %17
%178 = fadd double %176, %177
%179 = fdiv double %178, 2.000000e+00
br label %185
180: ; preds = %167
%181 = load double, double* %15
%182 = load double, double* %16
%183 = fadd double %181, %182
%184 = fdiv double %183, 2.000000e+00
br label %185
185: ; preds = %180, %175
%186 = phi double [ %179, %175 ], [ %184, %180 ]
store double %186, double* %18
br label %244
187: ; preds = %111
%188 = load double, double* %24
%189 = load double, double* %23
%190 = fdiv double %188, %189
store double %190, double* %18
%191 = load double, double* %18
%192 = fmul double 1.000000e+01, %191
%193 = load double, double* %15
%194 = load double, double* %16
%195 = call double @llvm.fmuladd.f64(double 9.000000e+00, double %193, double %194)
%196 = fcmp olt double %192, %195
br i1 %196, label %197, label %202
197: ; preds = %187
%198 = load double, double* %15
%199 = load double, double* %16
%200 = call double @llvm.fmuladd.f64(double 9.000000e+00, double %198, double %199)
%201 = fdiv double %200, 1.000000e+01
store double %201, double* %18
br label %202
202: ; preds = %197, %187
%203 = load double, double* %18
%204 = fmul double 1.000000e+01, %203
%205 = load double, double* %17
%206 = load double, double* %16
%207 = call double @llvm.fmuladd.f64(double 9.000000e+00, double %205, double %206)
%208 = fcmp ogt double %204, %207
br i1 %208, label %209, label %214
209: ; preds = %202
%210 = load double, double* %17
%211 = load double, double* %16
%212 = call double @llvm.fmuladd.f64(double 9.000000e+00, double %210, double %211)
%213 = fdiv double %212, 1.000000e+01
store double %213, double* %18
br label %214
214: ; preds = %209, %202
%215 = load double, double* %18
%216 = load double, double* %16
%217 = fsub double %215, %216
%218 = call double @llvm.fabs.f64(double %217)
%219 = load double, double* %17
%220 = load double, double* %15
%221 = fsub double %219, %220
%222 = fmul double 1.000000e-03, %221
%223 = fcmp olt double %218, %222
br i1 %223, label %224, label %243
224: ; preds = %214
%225 = load double, double* %17
%226 = load double, double* %16
%227 = fsub double %225, %226
%228 = load double, double* %16
%229 = load double, double* %15
%230 = fsub double %228, %229
%231 = fcmp ogt double %227, %230
br i1 %231, label %232, label %237
232: ; preds = %224
%233 = load double, double* %16
%234 = load double, double* %17
%235 = call double @llvm.fmuladd.f64(double 9.900000e+01, double %233, double %234)
%236 = fdiv double %235, 1.000000e+02
store double %236, double* %18
br label %242
237: ; preds = %224
%238 = load double, double* %16
%239 = load double, double* %15
%240 = call double @llvm.fmuladd.f64(double 9.900000e+01, double %238, double %239)
%241 = fdiv double %240, 1.000000e+02
store double %241, double* %18
br label %242
242: ; preds = %237, %232
br label %243
243: ; preds = %242, %214
br label %244
244: ; preds = %243, %185
%245 = load double (...)*, double (...)** %8
%246 = load double, double* %18
%247 = bitcast double (...)* %245 to double (double, ...)*
%248 = call double (double, ...) %247(double %246)
store double %248, double* %22
%249 = load double, double* %18
%250 = load double, double* %16
%251 = fcmp ogt double %249, %250
br i1 %251, label %252, label %265
252: ; preds = %244
%253 = load double, double* %22
%254 = load double, double* %20
%255 = fcmp oge double %253, %254
br i1 %255, label %256, label %261
256: ; preds = %252
%257 = load double, double* %16
store double %257, double* %15
%258 = load double, double* %20
store double %258, double* %19
%259 = load double, double* %18
store double %259, double* %16
%260 = load double, double* %22
store double %260, double* %20
br label %264
261: ; preds = %252
%262 = load double, double* %18
store double %262, double* %17
%263 = load double, double* %22
store double %263, double* %21
br label %264
264: ; preds = %261, %256
br label %278
265: ; preds = %244
%266 = load double, double* %22
%267 = load double, double* %20
%268 = fcmp oge double %266, %267
br i1 %268, label %269, label %274
269: ; preds = %265
%270 = load double, double* %16
store double %270, double* %17
%271 = load double, double* %20
store double %271, double* %21
%272 = load double, double* %18
store double %272, double* %16
%273 = load double, double* %22
store double %273, double* %20
br label %277
274: ; preds = %265
%275 = load double, double* %18
store double %275, double* %15
%276 = load double, double* %22
store double %276, double* %19
br label %277
277: ; preds = %274, %269
br label %278
278: ; preds = %277, %264
br label %279
279: ; preds = %278, %102
br label %75
280: ; preds = %75
%281 = load i8, i8* %14
%282 = sext i8 %281 to i32
%283 = icmp eq i32 %282, 120
br i1 %283, label %284, label %286
284: ; preds = %280
%285 = load double, double* %16
br label %288
286: ; preds = %280
%287 = load double, double* %20
br label %288
288: ; preds = %286, %284
%289 = phi double [ %285, %284 ], [ %287, %286 ]
ret double %289
}

LLVM IR (-O2):
define double @max_quad(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 = fadd double %25, %26
%31 = fmul double %30, 5.000000e-01
%32 = tail call double (double, ...) %27(double %31)
%33 = fsub double %25, %26
%34 = fcmp ogt double %33, %4
br i1 %34, label %35, label %130
35: ; preds = %24, %121
%36 = phi double [ %128, %121 ], [ %33, %24 ]
%37 = phi double [ %127, %121 ], [ %26, %24 ]
%38 = phi double [ %126, %121 ], [ %29, %24 ]
%39 = phi double [ %125, %121 ], [ %32, %24 ]
%40 = phi double [ %124, %121 ], [ %28, %24 ]
%41 = phi double [ %123, %121 ], [ %25, %24 ]
%42 = phi double [ %122, %121 ], [ %31, %24 ]
%43 = fcmp ogt double %40, %39
%44 = fcmp ogt double %38, %39
%45 = or i1 %43, %44
br i1 %45, label %46, label %55
46: ; preds = %35
%47 = fcmp ogt double %40, %38
%48 = select i1 %47, double %42, double %41
%49 = select i1 %47, double %40, double %39
%50 = select i1 %47, double %39, double %38
%51 = select i1 %47, double %37, double %42
%52 = fadd double %51, %48
%53 = fmul double %52, 5.000000e-01
%54 = tail call double (double, ...) %27(double %53)
br label %121
55: ; preds = %35
%56 = fsub double %39, %40
%57 = fsub double %41, %42
%58 = fsub double %39, %38
%59 = fsub double %42, %37
%60 = fmul double %58, %59
%61 = tail call double @llvm.fmuladd.f64(double %56, double %57, double %60)
%62 = fmul double %57, %56
%63 = fadd double %42, %41
%64 = fadd double %42, %37
%65 = fmul double %64, %60
%66 = tail call double @llvm.fmuladd.f64(double %62, double %63, double %65)
%67 = fmul double %66, 5.000000e-01
%68 = fcmp ole double %61, 0.000000e+00
%69 = fmul double %37, %61
%70 = fcmp olt double %67, %69
%71 = or i1 %68, %70
%72 = fmul double %41, %61
%73 = fcmp ogt double %67, %72
%74 = or i1 %73, %71
br i1 %74, label %75, label %79
75: ; preds = %55
%76 = fcmp ogt double %57, %59
%77 = select i1 %76, double %63, double %64
%78 = fmul double %77, 5.000000e-01
br label %103
79: ; preds = %55
%80 = fdiv double %67, %61
%81 = fmul double %80, 1.000000e+01
%82 = tail call double @llvm.fmuladd.f64(double %37, double 9.000000e+00, double %42)
%83 = fcmp olt double %81, %82
%84 = fdiv double %82, 1.000000e+01
%85 = select i1 %83, double %84, double %80
%86 = fmul double %85, 1.000000e+01
%87 = tail call double @llvm.fmuladd.f64(double %41, double 9.000000e+00, double %42)
%88 = fcmp ogt double %86, %87
%89 = fdiv double %87, 1.000000e+01
%90 = select i1 %88, double %89, double %85
%91 = fsub double %90, %42
%92 = tail call double @llvm.fabs.f64(double %91)
%93 = fmul double %36, 1.000000e-03
%94 = fcmp olt double %92, %93
br i1 %94, label %95, label %103
95: ; preds = %79
%96 = fcmp ogt double %57, %59
br i1 %96, label %97, label %100
97: ; preds = %95
%98 = tail call double @llvm.fmuladd.f64(double %42, double 9.900000e+01, double %41)
%99 = fdiv double %98, 1.000000e+02
br label %103
100: ; preds = %95
%101 = tail call double @llvm.fmuladd.f64(double %42, double 9.900000e+01, double %37)
%102 = fdiv double %101, 1.000000e+02
br label %103
103: ; preds = %79, %100, %97, %75
%104 = phi double [ %78, %75 ], [ %99, %97 ], [ %102, %100 ], [ %90, %79 ]
%105 = tail call double (double, ...) %27(double %104)
%106 = fcmp ogt double %104, %42
%107 = fcmp ult double %105, %39
%108 = select i1 %107, double %42, double %104
br i1 %106, label %109, label %115
109: ; preds = %103
%110 = select i1 %107, double %104, double %41
%111 = select i1 %107, double %40, double %39
%112 = select i1 %107, double %39, double %105
%113 = select i1 %107, double %105, double %38
%114 = select i1 %107, double %37, double %42
br label %121
115: ; preds = %103
%116 = select i1 %107, double %41, double %42
%117 = select i1 %107, double %105, double %40
%118 = select i1 %107, double %39, double %105
%119 = select i1 %107, double %38, double %39
%120 = select i1 %107, double %104, double %37
br label %121
121: ; preds = %115, %109, %46
%122 = phi double [ %53, %46 ], [ %108, %109 ], [ %108, %115 ]
%123 = phi double [ %48, %46 ], [ %110, %109 ], [ %116, %115 ]
%124 = phi double [ %49, %46 ], [ %111, %109 ], [ %117, %115 ]
%125 = phi double [ %54, %46 ], [ %112, %109 ], [ %118, %115 ]
%126 = phi double [ %50, %46 ], [ %113, %109 ], [ %119, %115 ]
%127 = phi double [ %51, %46 ], [ %114, %109 ], [ %120, %115 ]
%128 = fsub double %123, %127
%129 = fcmp ogt double %128, %4
br i1 %129, label %35, label %130
130: ; preds = %121, %24
%131 = phi double [ %31, %24 ], [ %122, %121 ]
%132 = phi double [ %32, %24 ], [ %125, %121 ]
%133 = and i32 %6, 255
%134 = icmp eq i32 %133, 120
%135 = select i1 %134, double %131, double %132
ret double %135
}