#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 */
double the_middle_of2(double, double);
double the_middle_of(double a, double b) {
  double r = 0;
  double s = a + b;
  while (r + r < s) {
    r += 1.0;
  }
  return the_middle_of2(r - 1.0, s - (r - 1.0));
}


x86 assembly (clang, -O0):
<the_middle_of>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
addsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1169 <the_middle_of+0x59>
movsd  0xea6(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1139 <the_middle_of+0x29>
movsd  -0x18(%rbp),%xmm0
movsd  0xe8a(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  0xe74(%rip),%xmm3
subsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
call   1030 <the_middle_of2@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<the_middle_of>:
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jbe    114c <the_middle_of+0x3c>
movsd  0xede(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
addsd  %xmm1,%xmm0
movapd %xmm0,%xmm3
addsd  %xmm0,%xmm3
ucomisd %xmm3,%xmm2
ja     1130 <the_middle_of+0x20>
addsd  0xeb6(%rip),%xmm0
jmp    1154 <the_middle_of+0x44>
movsd  0xeac(%rip),%xmm0
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm1
jmp    1030 <the_middle_of2@plt>

LLVM IR (-O0):
define double @the_middle_of(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %3
store double %1, double* %4
store double 0.000000e+00, double* %5
%7 = load double, double* %3
%8 = load double, double* %4
%9 = fadd double %7, %8
store double %9, double* %6
br label %10
10: ; preds = %16, %2
%11 = load double, double* %5
%12 = load double, double* %5
%13 = fadd double %11, %12
%14 = load double, double* %6
%15 = fcmp olt double %13, %14
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load double, double* %5
%18 = fadd double %17, 1.000000e+00
store double %18, double* %5
br label %10
19: ; preds = %10
%20 = load double, double* %5
%21 = fsub double %20, 1.000000e+00
%22 = load double, double* %6
%23 = load double, double* %5
%24 = fsub double %23, 1.000000e+00
%25 = fsub double %22, %24
%26 = call double @the_middle_of2(double %21, double %25)
ret double %26
}

LLVM IR (-O2):
define double @the_middle_of(double %0, double %1) {
%3 = fadd double %0, %1
%4 = fcmp ogt double %3, 0.000000e+00
br i1 %4, label %5, label %12
5: ; preds = %2, %5
%6 = phi double [ %7, %5 ], [ 0.000000e+00, %2 ]
%7 = fadd double %6, 1.000000e+00
%8 = fadd double %7, %7
%9 = fcmp olt double %8, %3
br i1 %9, label %5, label %10
10: ; preds = %5
%11 = fadd double %7, -1.000000e+00
br label %12
12: ; preds = %10, %2
%13 = phi double [ -1.000000e+00, %2 ], [ %11, %10 ]
%14 = fsub double %3, %13
%15 = tail call double @the_middle_of2(double %13, double %14)
ret double %15
}