float addRecursive(int from, int to) {
  int N = 1 + to - from;
  int h;
  if (N < 1)
    return 0;
  if (N == 1)
    return 1.0 / (float)from;
  if (N == 2)
    return 1.0 / (float)from + 1.0 / (float)to;
  h = (to + from) / 2;
  return addRecursive(from, h) + addRecursive(h + 1, to);
}


x86 assembly (clang, -O0):
<addRecursive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jge    1141 <addRecursive+0x31>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11f4 <addRecursive+0xe4>
cmpl   $0x1,-0x10(%rbp)
jne    116e <addRecursive+0x5e>
cvtsi2ssl -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xea4(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11f4 <addRecursive+0xe4>
cmpl   $0x2,-0x10(%rbp)
jne    11b4 <addRecursive+0xa4>
cvtsi2ssl -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe77(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe62(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11f4 <addRecursive+0xe4>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <addRecursive@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
mov    -0xc(%rbp),%esi
call   1030 <addRecursive@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addRecursive>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%eax
sub    %edi,%eax
add    $0x1,%eax
test   %eax,%eax
jle    113c <addRecursive+0x2c>
mov    %esi,%ebx
cmp    $0x2,%eax
je     1141 <addRecursive+0x31>
cmp    $0x1,%eax
jne    1171 <addRecursive+0x61>
cvtsi2ss %edi,%xmm1
movss  0xeda(%rip),%xmm0
divss  %xmm1,%xmm0
jmp    119c <addRecursive+0x8c>
xorps  %xmm0,%xmm0
jmp    119c <addRecursive+0x8c>
movd   %ebx,%xmm0
movd   %edi,%xmm1
punpckldq %xmm0,%xmm1
cvtdq2ps %xmm1,%xmm0
cvtps2pd %xmm0,%xmm0
movapd 0xea5(%rip),%xmm1
divpd  %xmm0,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
jmp    119c <addRecursive+0x8c>
lea    (%rbx,%rdi,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %ebp,%esi
call   1030 <addRecursive@plt>
movss  %xmm0,0x4(%rsp)
add    $0x1,%ebp
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <addRecursive@plt>
addss  0x4(%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define float @addRecursive(i32 %0, i32 %1) {
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = add nsw i32 1, %8
%10 = load i32, i32* %4
%11 = sub nsw i32 %9, %10
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %2
store float 0.000000e+00, float* %3
br label %51
15: ; preds = %2
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i32, i32* %4
%20 = sitofp i32 %19 to float
%21 = fpext float %20 to double
%22 = fdiv double 1.000000e+00, %21
%23 = fptrunc double %22 to float
store float %23, float* %3
br label %51
24: ; preds = %15
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 2
br i1 %26, label %27, label %38
27: ; preds = %24
%28 = load i32, i32* %4
%29 = sitofp i32 %28 to float
%30 = fpext float %29 to double
%31 = fdiv double 1.000000e+00, %30
%32 = load i32, i32* %5
%33 = sitofp i32 %32 to float
%34 = fpext float %33 to double
%35 = fdiv double 1.000000e+00, %34
%36 = fadd double %31, %35
%37 = fptrunc double %36 to float
store float %37, float* %3
br label %51
38: ; preds = %24
%39 = load i32, i32* %5
%40 = load i32, i32* %4
%41 = add nsw i32 %39, %40
%42 = sdiv i32 %41, 2
store i32 %42, i32* %7
%43 = load i32, i32* %4
%44 = load i32, i32* %7
%45 = call float @addRecursive(i32 %43, i32 %44)
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
%48 = load i32, i32* %5
%49 = call float @addRecursive(i32 %47, i32 %48)
%50 = fadd float %45, %49
store float %50, float* %3
br label %51
51: ; preds = %38, %27, %18, %14
%52 = load float, float* %3
ret float %52
}

LLVM IR (-O2):
define float @addRecursive(i32 %0, i32 %1) {
%3 = sub i32 1, %0
%4 = add i32 %3, %1
%5 = icmp slt i32 %4, 1
br i1 %5, label %20, label %6
6: ; preds = %2
switch i32 %4, label %22 [
i32 1, label %7
i32 2, label %10
]
7: ; preds = %6
%8 = sitofp i32 %0 to float
%9 = fdiv float 1.000000e+00, %8
br label %20
10: ; preds = %6
%11 = insertelement <2 x i32> poison, i32 %0, i64 0
%12 = insertelement <2 x i32> %11, i32 %1, i64 1
%13 = sitofp <2 x i32> %12 to <2 x float>
%14 = fpext <2 x float> %13 to <2 x double>
%15 = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %14
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%17 = fadd <2 x double> %15, %16
%18 = extractelement <2 x double> %17, i64 0
%19 = fptrunc double %18 to float
br label %20
20: ; preds = %7, %10, %2, %22
%21 = phi float [ %28, %22 ], [ %9, %7 ], [ %19, %10 ], [ 0.000000e+00, %2 ]
ret float %21
22: ; preds = %6
%23 = add nsw i32 %1, %0
%24 = sdiv i32 %23, 2
%25 = tail call float @addRecursive(i32 %0, i32 %24)
%26 = add nsw i32 %24, 1
%27 = tail call float @addRecursive(i32 %26, i32 %1)
%28 = fadd float %25, %27
br label %20
}