#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() {
  float pi = 1.0;
  float n = 1.0;
  for (int j = 1; j <= 100; j++, n += 1.0) {
    if (j % 2 == 0) {
      pi *= n / (n + 1.0);
    } else {
      pi *= (n + 1.0) / n;
    }
  }
  pi = 2.0 * pi;
  printf("pi = %.7f\n", pi);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xed9(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xecc(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x64,-0x10(%rbp)
jg     1204 <main+0xf4>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119b <main+0x8b>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe98(%rip),%xmm2
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11d3 <main+0xc3>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe64(%rip),%xmm0
addsd  %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11d8 <main+0xc8>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe1e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1140 <main+0x30>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdf3(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
lea    0xdea(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movss  0xee7(%rip),%xmm1
mov    $0x1,%eax
movsd  0xee2(%rip),%xmm2
movaps %xmm1,%xmm3
movaps %xmm1,%xmm0
jmp    1150 <main+0x40>
xchg   %ax,%ax
divsd  %xmm4,%xmm5
movapd %xmm5,%xmm4
cvtss2sd %xmm0,%xmm0
mulsd  %xmm4,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x1,%eax
addss  %xmm1,%xmm3
cmp    $0x65,%eax
je     1168 <main+0x58>
xorps  %xmm4,%xmm4
cvtss2sd %xmm3,%xmm4
movaps %xmm4,%xmm5
addsd  %xmm2,%xmm5
test   $0x1,%al
jne    1130 <main+0x20>
divsd  %xmm5,%xmm4
jmp    1138 <main+0x28>
addss  %xmm0,%xmm0
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"pi = %.7f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
store i32 0, i32* %1
store float 1.000000e+00, float* %2
store float 1.000000e+00, float* %3
store i32 1, i32* %4
br label %5
5: ; preds = %35, %0
%6 = load i32, i32* %4
%7 = icmp sle i32 %6, 100
br i1 %7, label %8, label %42
8: ; preds = %5
%9 = load i32, i32* %4
%10 = srem i32 %9, 2
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load float, float* %3
%14 = fpext float %13 to double
%15 = load float, float* %3
%16 = fpext float %15 to double
%17 = fadd double %16, 1.000000e+00
%18 = fdiv double %14, %17
%19 = load float, float* %2
%20 = fpext float %19 to double
%21 = fmul double %20, %18
%22 = fptrunc double %21 to float
store float %22, float* %2
br label %34
23: ; preds = %8
%24 = load float, float* %3
%25 = fpext float %24 to double
%26 = fadd double %25, 1.000000e+00
%27 = load float, float* %3
%28 = fpext float %27 to double
%29 = fdiv double %26, %28
%30 = load float, float* %2
%31 = fpext float %30 to double
%32 = fmul double %31, %29
%33 = fptrunc double %32 to float
store float %33, float* %2
br label %34
34: ; preds = %23, %12
br label %35
35: ; preds = %34
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
%38 = load float, float* %3
%39 = fpext float %38 to double
%40 = fadd double %39, 1.000000e+00
%41 = fptrunc double %40 to float
store float %41, float* %3
br label %5
42: ; preds = %5
%43 = load float, float* %2
%44 = fpext float %43 to double
%45 = fmul double 2.000000e+00, %44
%46 = fptrunc double %45 to float
store float %46, float* %2
%47 = load float, float* %2
%48 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), float %47)
ret i32 0
}

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