#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 clen = 1, pi = 0;
  int i, znak = 1, imenitel = 1;
  for (i = 0; i < 100; i++) {
    pi += clen;
    imenitel += 2;
    znak = -znak;
    clen = (double)znak / imenitel;
  }
  pi *= 4;
  printf("pi (priblizno) = %lf\n", pi);
  return 0;
}


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)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jge    1194 <main+0x84>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
cvtsi2sdl -0x20(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1149 <main+0x39>
movsd  0xe6c(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movsd  0xee7(%rip),%xmm1
xorpd  %xmm0,%xmm0
mov    $0x5,%eax
movsd  0xede(%rip),%xmm2
movapd %xmm1,%xmm3
xchg   %ax,%ax
movapd %xmm0,%xmm4
lea    -0x2(%rax),%ecx
xorps  %xmm5,%xmm5
cvtsi2sd %ecx,%xmm5
addsd  %xmm3,%xmm4
movapd %xmm2,%xmm0
divsd  %xmm5,%xmm0
xorps  %xmm5,%xmm5
cvtsi2sd %eax,%xmm5
addsd  %xmm4,%xmm0
movapd %xmm1,%xmm3
divsd  %xmm5,%xmm3
add    $0x4,%eax
cmp    $0xcd,%eax
jne    1130 <main+0x20>
mulsd  0xea1(%rip),%xmm0
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"pi (priblizno) = %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store double 0.000000e+00, double* %3
store i32 1, i32* %5
store i32 1, i32* %6
store i32 0, i32* %4
br label %7
7: ; preds = %23, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 100
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = load double, double* %2
%12 = load double, double* %3
%13 = fadd double %12, %11
store double %13, double* %3
%14 = load i32, i32* %6
%15 = add nsw i32 %14, 2
store i32 %15, i32* %6
%16 = load i32, i32* %5
%17 = sub nsw i32 0, %16
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = sitofp i32 %18 to double
%20 = load i32, i32* %6
%21 = sitofp i32 %20 to double
%22 = fdiv double %19, %21
store double %22, double* %2
br label %23
23: ; preds = %10
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %7
26: ; preds = %7
%27 = load double, double* %3
%28 = fmul double %27, 4.000000e+00
store double %28, double* %3
%29 = load double, double* %3
%30 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), double %29)
ret i32 0
}

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