#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 very_smart_add(double, double);
double the_middle_of2(double a, double b) {
  double l = a, r = b;
  double check, m;
  while (1) {
    m = very_smart_add(l, r) / 2;
    check = very_smart_add(m, m);
    if (check > very_smart_add(a, b) + 0.0000000001)
      r = m;
    else if (check < very_smart_add(a, b) - 0.0000000001)
      l = m;
    else
      return m;
  }
}


x86 assembly (clang, -O0):
<the_middle_of2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <very_smart_add@plt>
movsd  0xebb(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1030 <very_smart_add@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1030 <very_smart_add@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm2
addsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11b0 <the_middle_of2+0xa0>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1203 <the_middle_of2+0xf3>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1030 <very_smart_add@plt>
movsd  -0x40(%rbp),%xmm1
movsd  0xe2a(%rip),%xmm2
subsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11f3 <the_middle_of2+0xe3>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11fe <the_middle_of2+0xee>
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret
jmp    1203 <the_middle_of2+0xf3>
jmp    1136 <the_middle_of2+0x26>

x86 assembly (clang, -O2):
<the_middle_of2>:
sub    $0x38,%rsp
movsd  %xmm1,0x20(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
movapd %xmm0,%xmm1
nopw   0x0(%rax,%rax,1)
movapd %xmm1,%xmm0
movsd  %xmm1,0x30(%rsp)
movsd  0x8(%rsp),%xmm1
call   1030 <very_smart_add@plt>
mulsd  0xeb3(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movapd %xmm0,%xmm1
call   1030 <very_smart_add@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1030 <very_smart_add@plt>
addsd  0xe8d(%rip),%xmm0
movsd  0x28(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     11b8 <the_middle_of2+0xa8>
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1030 <very_smart_add@plt>
addsd  0xe70(%rip),%xmm0
ucomisd 0x28(%rsp),%xmm0
movsd  0x10(%rsp),%xmm0
movapd %xmm0,%xmm1
ja     1130 <the_middle_of2+0x20>
jmp    11cf <the_middle_of2+0xbf>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x30(%rsp),%xmm1
jmp    1130 <the_middle_of2+0x20>
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @the_middle_of2(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %3
store double %1, double* %4
%9 = load double, double* %3
store double %9, double* %5
%10 = load double, double* %4
store double %10, double* %6
br label %11
11: ; preds = %2, %39
%12 = load double, double* %5
%13 = load double, double* %6
%14 = call double @very_smart_add(double %12, double %13)
%15 = fdiv double %14, 2.000000e+00
store double %15, double* %8
%16 = load double, double* %8
%17 = load double, double* %8
%18 = call double @very_smart_add(double %16, double %17)
store double %18, double* %7
%19 = load double, double* %7
%20 = load double, double* %3
%21 = load double, double* %4
%22 = call double @very_smart_add(double %20, double %21)
%23 = fadd double %22, 1.000000e-10
%24 = fcmp ogt double %19, %23
br i1 %24, label %25, label %27
25: ; preds = %11
%26 = load double, double* %8
store double %26, double* %6
br label %39
27: ; preds = %11
%28 = load double, double* %7
%29 = load double, double* %3
%30 = load double, double* %4
%31 = call double @very_smart_add(double %29, double %30)
%32 = fsub double %31, 1.000000e-10
%33 = fcmp olt double %28, %32
br i1 %33, label %34, label %36
34: ; preds = %27
%35 = load double, double* %8
store double %35, double* %5
br label %38
36: ; preds = %27
%37 = load double, double* %8
ret double %37
38: ; preds = %34
br label %39
39: ; preds = %38, %25
br label %11
}

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