#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 *, ...);
int main(int argc, char *argv[]) {
  double pi = 0.0;
  for (long i = 1; i < 10000000; i += 4) {
    pi += (4.0 / ((double)i)) - (4.0 / (((double)i) + 2.0));
  }
  printf("Pi = %f\n", pi);
  printf("argc = %d\n", argc);
  if (argc >= 2) {
    printf("Param = %s\n", argv[1]);
  } else {
    printf("argv[1] is not defined");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movq   $0x1,-0x20(%rbp)
cmpq   $0x989680,-0x20(%rbp)
jge    1193 <main+0x83>
cvtsi2sdq -0x20(%rbp),%xmm1
movsd  0xeae(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsi2sdq -0x20(%rbp),%xmm2
movsd  0xea4(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  0xe90(%rip),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    1136 <main+0x26>
movsd  -0x18(%rbp),%xmm0
lea    0xe71(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jl     11dc <main+0xcc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ea <main+0xda>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xorpd  %xmm0,%xmm0
mov    $0x1,%eax
movsd  0xed7(%rip),%xmm1
movapd 0xedf(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm3,%xmm3
cvtsi2sd %rax,%xmm3
movapd %xmm3,%xmm4
addsd  %xmm1,%xmm4
unpcklpd %xmm4,%xmm3
movapd %xmm2,%xmm4
divpd  %xmm3,%xmm4
movapd %xmm4,%xmm3
unpckhpd %xmm4,%xmm3
subsd  %xmm3,%xmm4
addsd  %xmm0,%xmm4
lea    0x4(%rax),%rcx
xorps  %xmm3,%xmm3
cvtsi2sd %rcx,%xmm3
movapd %xmm3,%xmm0
addsd  %xmm1,%xmm0
unpcklpd %xmm0,%xmm3
movapd %xmm2,%xmm0
divpd  %xmm3,%xmm0
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
subsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
lea    0x8(%rax),%rcx
cmp    $0x989678,%rax
mov    %rcx,%rax
jb     1140 <main+0x30>
lea    0xe6e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe69(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x1,%ebp
jle    11e2 <main+0xd2>
mov    0x8(%rbx),%rsi
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11f0 <main+0xe0>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Pi = %f\0A\00"
@.str.1 = [11 x i8] c"argc = %d\0A\00"
@.str.2 = [12 x i8] c"Param = %s\0A\00"
@.str.3 = [23 x i8] c"argv[1] is not defined\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %6
store i64 1, i64* %7
br label %8
8: ; preds = %22, %2
%9 = load i64, i64* %7
%10 = icmp slt i64 %9, 10000000
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load i64, i64* %7
%13 = sitofp i64 %12 to double
%14 = fdiv double 4.000000e+00, %13
%15 = load i64, i64* %7
%16 = sitofp i64 %15 to double
%17 = fadd double %16, 2.000000e+00
%18 = fdiv double 4.000000e+00, %17
%19 = fsub double %14, %18
%20 = load double, double* %6
%21 = fadd double %20, %19
store double %21, double* %6
br label %22
22: ; preds = %11
%23 = load i64, i64* %7
%24 = add nsw i64 %23, 4
store i64 %24, i64* %7
br label %8
25: ; preds = %8
%26 = load double, double* %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %26)
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %4
%31 = icmp sge i32 %30, 2
br i1 %31, label %32, label %37
32: ; preds = %25
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %35)
br label %39
37: ; preds = %25
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %37, %32
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"Pi = %f\0A\00"
@.str.1 = [11 x i8] c"argc = %d\0A\00"
@.str.2 = [12 x i8] c"Param = %s\0A\00"
@.str.3 = [23 x i8] c"argv[1] is not defined\00"
define i32 @main(i32 %0, i8** nocapture %1) {
br label %7
3: ; preds = %7
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %28)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%6 = icmp sgt i32 %0, 1
br i1 %6, label %31, label %35
7: ; preds = %7, %2
%8 = phi i64 [ 1, %2 ], [ %29, %7 ]
%9 = phi double [ 0.000000e+00, %2 ], [ %28, %7 ]
%10 = sitofp i64 %8 to double
%11 = fadd double %10, 2.000000e+00
%12 = insertelement <2 x double> poison, double %10, i64 0
%13 = insertelement <2 x double> %12, double %11, i64 1
%14 = fdiv <2 x double> <double 4.000000e+00, double 4.000000e+00>, %13
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%16 = fsub <2 x double> %14, %15
%17 = extractelement <2 x double> %16, i64 0
%18 = fadd double %9, %17
%19 = add nuw nsw i64 %8, 4
%20 = sitofp i64 %19 to double
%21 = fadd double %20, 2.000000e+00
%22 = insertelement <2 x double> poison, double %20, i64 0
%23 = insertelement <2 x double> %22, double %21, i64 1
%24 = fdiv <2 x double> <double 4.000000e+00, double 4.000000e+00>, %23
%25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%26 = fsub <2 x double> %24, %25
%27 = extractelement <2 x double> %26, i64 0
%28 = fadd double %18, %27
%29 = add nuw nsw i64 %8, 8
%30 = icmp ult i64 %8, 9999992
br i1 %30, label %7, label %3
31: ; preds = %3
%32 = getelementptr inbounds i8*, i8** %1, i64 1
%33 = load i8*, i8** %32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %33)
br label %37
35: ; preds = %3
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
ret i32 0
}