#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 *, double);
int main() {
  double S = 1.0, i = 3, k = 2;
  while (i <= 39) {
    S = S + (i / k);
    i += 2;
    k *= 2;
  }
  printf("%0.2lf\n", S);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xee9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xed4(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xebf(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeca(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     119a <main+0x8a>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe87(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe75(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1146 <main+0x36>
movsd  -0x10(%rbp),%xmm0
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movsd  0xee7(%rip),%xmm4
mov    $0x3,%eax
movsd  0xee2(%rip),%xmm1
movsd  0xee2(%rip),%xmm2
movsd  0xee2(%rip),%xmm3
cs nopw 0x0(%rax,%rax,1)
movapd %xmm1,%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm4,%xmm0
cmp    $0x25,%eax
ja     1178 <main+0x68>
addsd  %xmm2,%xmm2
lea    0x2(%rax),%ecx
xorps  %xmm4,%xmm4
cvtsi2sd %ecx,%xmm4
divsd  %xmm2,%xmm4
addsd  %xmm4,%xmm0
addsd  %xmm3,%xmm1
addsd  %xmm2,%xmm2
add    $0x4,%eax
movapd %xmm0,%xmm4
jmp    1140 <main+0x30>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%0.2lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store double 3.000000e+00, double* %3
store double 2.000000e+00, double* %4
br label %5
5: ; preds = %8, %0
%6 = load double, double* %3
%7 = fcmp ole double %6, 3.900000e+01
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load double, double* %2
%10 = load double, double* %3
%11 = load double, double* %4
%12 = fdiv double %10, %11
%13 = fadd double %9, %12
store double %13, double* %2
%14 = load double, double* %3
%15 = fadd double %14, 2.000000e+00
store double %15, double* %3
%16 = load double, double* %4
%17 = fmul double %16, 2.000000e+00
store double %17, double* %4
br label %5
18: ; preds = %5
%19 = load double, double* %2
%20 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %19)
ret i32 0
}

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