#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() {
  double Pi = 0.0, denominateur = 1.0;
  int limite = 0;
  const int iteration = 100000000;
  printf("Series of Leibniz to find PI - programming by Lyes Belhadj");
  printf("\n\nSearch");
  while (limite != iteration) {
    Pi += 4 / denominateur;
    denominateur += 2;
    Pi -= 4 / denominateur;
    denominateur += 2;
    limite++;
    if (limite % (iteration / 10) == 0) {
      printf(".");
    }
  }
  printf("\n\nPi = %.64g\n", Pi);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xed1(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x5f5e100,-0x20(%rbp)
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x5f5e100,-0x1c(%rbp)
je     11f1 <main+0xe1>
movsd  0xe9d(%rip),%xmm0
divsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe7e(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe74(%rip),%xmm1
divsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe51(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x989680,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ec <main+0xdc>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115e <main+0x4e>
movsd  -0x10(%rbp),%xmm0
lea    0xe61(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xeeb(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf16(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0xeb4(%rip),%xmm2
xorpd  %xmm0,%xmm0
mov    $0x1,%ebp
movsd  0xeab(%rip),%xmm3
movsd  0xeab(%rip),%xmm4
jmp    119e <main+0x7e>
nopw   0x0(%rax,%rax,1)
movapd %xmm3,%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
addsd  %xmm4,%xmm2
movapd %xmm3,%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
addsd  %xmm4,%xmm2
add    $0xffffffff,%ebx
add    $0x1,%ebp
cmp    $0xfa0a1f00,%ebx
je     11f0 <main+0xd0>
mov    %ebp,%eax
imul   $0x6b5fca6b,%rax,%rax
shr    $0x36,%rax
imul   $0x989680,%eax,%eax
mov    $0x1,%ecx
sub    %eax,%ecx
cmp    %ebx,%ecx
jne    1170 <main+0x50>
mov    $0x2e,%edi
movsd  %xmm0,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
call   1030 <putchar@plt>
movsd  0xe36(%rip),%xmm4
movsd  0xe26(%rip),%xmm3
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm0
jmp    1170 <main+0x50>
lea    0xe65(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [59 x i8] c"Series of Leibniz to find PI - programming by Lyes Belhadj\00"
@.str.1 = [9 x i8] c"\0A\0ASearch\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [14 x i8] c"\0A\0APi = %.64g\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 1.000000e+00, double* %3
store i32 0, i32* %4
store i32 100000000, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %31, %0
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 100000000
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load double, double* %3
%13 = fdiv double 4.000000e+00, %12
%14 = load double, double* %2
%15 = fadd double %14, %13
store double %15, double* %2
%16 = load double, double* %3
%17 = fadd double %16, 2.000000e+00
store double %17, double* %3
%18 = load double, double* %3
%19 = fdiv double 4.000000e+00, %18
%20 = load double, double* %2
%21 = fsub double %20, %19
store double %21, double* %2
%22 = load double, double* %3
%23 = fadd double %22, 2.000000e+00
store double %23, double* %3
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = srem i32 %26, 10000000
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %11
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %11
br label %8
32: ; preds = %8
%33 = load double, double* %2
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [59 x i8] c"Series of Leibniz to find PI - programming by Lyes Belhadj\00"
@.str.1 = [9 x i8] c"\0A\0ASearch\00"
@.str.3 = [14 x i8] c"\0A\0APi = %.64g\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %3
3: ; preds = %0, %18
%4 = phi double [ 0.000000e+00, %0 ], [ %11, %18 ]
%5 = phi i32 [ 0, %0 ], [ %13, %18 ]
%6 = phi double [ 1.000000e+00, %0 ], [ %12, %18 ]
%7 = fdiv double 4.000000e+00, %6
%8 = fadd double %7, %4
%9 = fadd double %6, 2.000000e+00
%10 = fdiv double 4.000000e+00, %9
%11 = fsub double %8, %10
%12 = fadd double %9, 2.000000e+00
%13 = add nuw nsw i32 %5, 1
%14 = urem i32 %13, 10000000
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = tail call i32 @putchar(i32 46)
br label %18
18: ; preds = %16, %3
%19 = icmp eq i32 %13, 100000000
br i1 %19, label %20, label %3
20: ; preds = %18
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %11)
ret i32 0
}