#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 */
int /*<<< orphan*/ printf(char *, float);
int main() {
  int i, j, n = 1;
  float v, sum = 0;
  for (i = 1; i <= 39; i = i + 2) {
    v = (float)i / (float)n;
    sum = sum + v;
    n = n * 2;
  }
  printf("%0.2f\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x27,-0x8(%rbp)
jg     1178 <main+0x68>
cvtsi2ssl -0x8(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    1135 <main+0x25>
movss  -0x18(%rbp),%xmm0
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x1,%eax
xorps  %xmm0,%xmm0
mov    $0x1,%ecx
nopl   (%rax)
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
xorps  %xmm2,%xmm2
cvtsi2ss %ecx,%xmm2
divss  %xmm2,%xmm1
addss  %xmm0,%xmm1
lea    (%rcx,%rcx,1),%edx
lea    0x2(%rax),%esi
xorps  %xmm0,%xmm0
cvtsi2ss %esi,%xmm0
xorps  %xmm2,%xmm2
cvtsi2ss %edx,%xmm2
divss  %xmm2,%xmm0
addss  %xmm1,%xmm0
shl    $0x2,%ecx
lea    0x4(%rax),%edx
cmp    $0x24,%eax
mov    %edx,%eax
jb     1120 <main+0x10>
push   %rax
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%0.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store i32 1, i32* %4
store float 0.000000e+00, float* %6
store i32 1, i32* %2
br label %7
7: ; preds = %21, %0
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 39
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = load i32, i32* %2
%12 = sitofp i32 %11 to float
%13 = load i32, i32* %4
%14 = sitofp i32 %13 to float
%15 = fdiv float %12, %14
store float %15, float* %5
%16 = load float, float* %6
%17 = load float, float* %5
%18 = fadd float %16, %17
store float %18, float* %6
%19 = load i32, i32* %4
%20 = mul nsw i32 %19, 2
store i32 %20, i32* %4
br label %21
21: ; preds = %10
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 2
store i32 %23, i32* %2
br label %7
24: ; preds = %7
%25 = load float, float* %6
%26 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), float %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%0.2f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi float [ 0.000000e+00, %0 ], [ %14, %1 ]
%3 = phi i32 [ 1, %0 ], [ %16, %1 ]
%4 = phi i32 [ 1, %0 ], [ %15, %1 ]
%5 = sitofp i32 %3 to float
%6 = sitofp i32 %4 to float
%7 = fdiv float %5, %6
%8 = fadd float %2, %7
%9 = shl nsw i32 %4, 1
%10 = add nuw nsw i32 %3, 2
%11 = sitofp i32 %10 to float
%12 = sitofp i32 %9 to float
%13 = fdiv float %11, %12
%14 = fadd float %8, %13
%15 = shl nsw i32 %4, 2
%16 = add nuw nsw i32 %3, 4
%17 = icmp ult i32 %3, 36
br i1 %17, label %1, label %18
18: ; preds = %1
%19 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), float %14)
ret i32 0
}