#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);
main() {
  double i = 1;
  double temp = 1, j = 1;
  double pi = 0.0;
  while (temp <= 100) {
    pi = (pi + (1 / j));
    i += 2;
    if (j > 0)
      j = i * (-1);
    else
      j = i * 1;
    temp += 2;
  }
  printf("The value of PI is %f\n", pi * 4);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xed9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xecc(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xebf(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeb2(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11e0 <main+0xd0>
movsd  -0x28(%rbp),%xmm0
movsd  0xe92(%rip),%xmm1
divsd  -0x20(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe94(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11b7 <main+0xa7>
movsd  0xe78(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11c9 <main+0xb9>
movsd  0xe41(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe47(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    114e <main+0x3e>
movsd  0xe28(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movsd  0xee7(%rip),%xmm1
xorpd  %xmm0,%xmm0
mov    $0xfffffffd,%eax
movsd  0xede(%rip),%xmm2
movapd 0xeee(%rip),%xmm3
movapd %xmm1,%xmm5
movapd %xmm1,%xmm4
nopw   0x0(%rax,%rax,1)
movapd %xmm1,%xmm6
divsd  %xmm5,%xmm6
addsd  %xmm0,%xmm6
addsd  %xmm2,%xmm4
movapd %xmm4,%xmm0
xorpd  %xmm3,%xmm0
xorpd  %xmm7,%xmm7
cmpltsd %xmm5,%xmm7
movapd %xmm7,%xmm5
andnpd %xmm4,%xmm5
andpd  %xmm0,%xmm7
orpd   %xmm5,%xmm7
movapd %xmm1,%xmm0
divsd  %xmm7,%xmm0
addsd  %xmm6,%xmm0
addsd  %xmm2,%xmm4
movapd %xmm4,%xmm6
xorpd  %xmm3,%xmm6
xorpd  %xmm5,%xmm5
cmpltsd %xmm7,%xmm5
andpd  %xmm5,%xmm6
andnpd %xmm4,%xmm5
orpd   %xmm6,%xmm5
add    $0x4,%eax
cmp    $0x61,%eax
jb     1140 <main+0x30>
mulsd  0xe62(%rip),%xmm0
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"The value of PI is %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store double 1.000000e+00, double* %3
store double 1.000000e+00, double* %4
store double 0.000000e+00, double* %5
br label %6
6: ; preds = %24, %0
%7 = load double, double* %3
%8 = fcmp ole double %7, 1.000000e+02
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = load double, double* %5
%11 = load double, double* %4
%12 = fdiv double 1.000000e+00, %11
%13 = fadd double %10, %12
store double %13, double* %5
%14 = load double, double* %2
%15 = fadd double %14, 2.000000e+00
store double %15, double* %2
%16 = load double, double* %4
%17 = fcmp ogt double %16, 0.000000e+00
br i1 %17, label %18, label %21
18: ; preds = %9
%19 = load double, double* %2
%20 = fmul double %19, -1.000000e+00
store double %20, double* %4
br label %24
21: ; preds = %9
%22 = load double, double* %2
%23 = fmul double %22, 1.000000e+00
store double %23, double* %4
br label %24
24: ; preds = %21, %18
%25 = load double, double* %3
%26 = fadd double %25, 2.000000e+00
store double %26, double* %3
br label %6
27: ; preds = %6
%28 = load double, double* %5
%29 = fmul double %28, 4.000000e+00
%30 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %29)
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [23 x i8] c"The value of PI is %f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi double [ 0.000000e+00, %0 ], [ %13, %1 ]
%3 = phi double [ 1.000000e+00, %0 ], [ %17, %1 ]
%4 = phi i32 [ 1, %0 ], [ %18, %1 ]
%5 = phi double [ 1.000000e+00, %0 ], [ %14, %1 ]
%6 = fdiv double 1.000000e+00, %3
%7 = fadd double %2, %6
%8 = fadd double %5, 2.000000e+00
%9 = fcmp ogt double %3, 0.000000e+00
%10 = fneg double %8
%11 = select i1 %9, double %10, double %8
%12 = fdiv double 1.000000e+00, %11
%13 = fadd double %7, %12
%14 = fadd double %8, 2.000000e+00
%15 = fcmp ogt double %11, 0.000000e+00
%16 = fneg double %14
%17 = select i1 %15, double %16, double %14
%18 = add nuw nsw i32 %4, 4
%19 = icmp ugt i32 %4, 96
br i1 %19, label %20, label %1
20: ; preds = %1
%21 = fmul double %13, 4.000000e+00
%22 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %21)
ret i32 0
}