#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int bolen;
  printf("Gregory–Leibniz yontemiyle pi sayisi hesaplanirken seri her cift "
         "terimde kendini tekrar etmektedir, bu yuzden cift sayili terim "
         "giriniz\n");
  int aranan_terim_sayisi = 0;
  while (aranan_terim_sayisi != -1) {
    printf("Serinin kac terimiyle pi sayisi hesaplansin giriniz(cikmak icin -1 "
           "giriniz):");
    scanf("%d", &aranan_terim_sayisi);
    if (aranan_terim_sayisi == -1) {
      printf("Programdan ciktiniz :)");
      break;
    }
    if (aranan_terim_sayisi % 2 == 0) {
      aranan_terim_sayisi = aranan_terim_sayisi * 2;
      int terim_sayisi = 2;
      float pi = 0;
      float seri;
      for (bolen = 1; bolen <= aranan_terim_sayisi; bolen = bolen + 4) {
        seri = (float)4 / bolen - ((float)4 / (bolen + 2));
        pi = pi + seri;
        printf("Seri = %f\n", seri);
        printf("pi sayisi = %.5f\n", pi);
        printf("Kullanilan terim sayisi = %d\n", terim_sayisi);
        terim_sayisi = terim_sayisi + 2;
      }
    } else {
      printf("Terim sayisini cift sayi giriniz!!\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
je     1275 <main+0x155>
lea    0xf3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf79(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0xffffffff,-0xc(%rbp)
jne    1189 <main+0x69>
lea    0xf62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1275 <main+0x155>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1262 <main+0x142>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     125d <main+0x13d>
cvtsi2ssl -0x8(%rbp),%xmm1
movss  0xe2b(%rip),%xmm0
divss  %xmm1,%xmm0
mov    -0x8(%rbp),%eax
add    $0x2,%eax
cvtsi2ss %eax,%xmm2
movss  0xe15(%rip),%xmm1
divss  %xmm2,%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xedf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xed3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x8(%rbp)
jmp    11bc <main+0x9c>
jmp    1270 <main+0x150>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1144 <main+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf70(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,(%rsp)
mov    %rsp,%r12
lea    0xf1f(%rip),%r13
lea    0xf23(%rip),%rbx
lea    0xf2e(%rip),%rbp
jmp    1188 <main+0x58>
nopl   0x0(%rax,%rax,1)
lea    0xfc5(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%eax
cmp    $0xffffffff,%eax
je     1271 <main+0x141>
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%ecx
cmp    $0xffffffff,%ecx
je     1263 <main+0x133>
test   $0x1,%cl
jne    1170 <main+0x40>
lea    (%rcx,%rcx,1),%eax
mov    %eax,(%rsp)
test   %ecx,%ecx
movaps 0xe3b(%rip),%xmm2
jle    117f <main+0x4f>
mov    $0x2,%r14d
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x1,%r15d
nopl   0x0(%rax)
lea    0x2(%r15),%eax
movd   %r15d,%xmm0
movd   %eax,%xmm1
punpckldq %xmm1,%xmm0
cvtdq2ps %xmm0,%xmm0
movaps %xmm2,%xmm1
divps  %xmm0,%xmm1
movaps %xmm1,%xmm0
shufps $0x55,%xmm1,%xmm0
subss  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movaps 0xdb2(%rip),%xmm2
add    $0x2,%r14d
mov    (%rsp),%eax
add    $0x4,%r15d
cmp    %eax,%r15d
jle    11e0 <main+0xb0>
jmp    117f <main+0x4f>
lea    0xdf6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [139 x i8] c"Gregory\E2\80\93Leibniz yontemiyle pi sayisi hesaplanirken seri her cift terimde kendini tekrar etmektedir, bu yuzden cift sayili terim giriniz\0A\00"
@.str.1 = [77 x i8] c"Serinin kac terimiyle pi sayisi hesaplansin giriniz(cikmak icin -1 giriniz):\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [23 x i8] c"Programdan ciktiniz :)\00"
@.str.4 = [11 x i8] c"Seri = %f\0A\00"
@.str.5 = [18 x i8] c"pi sayisi = %.5f\0A\00"
@.str.6 = [30 x i8] c"Kullanilan terim sayisi = %d\0A\00"
@.str.7 = [36 x i8] c"Terim sayisini cift sayi giriniz!!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %8
8: ; preds = %57, %0
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, -1
br i1 %10, label %11, label %58
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %58
18: ; preds = %11
%19 = load i32, i32* %3
%20 = srem i32 %19, 2
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %55
22: ; preds = %18
%23 = load i32, i32* %3
%24 = mul nsw i32 %23, 2
store i32 %24, i32* %3
store i32 2, i32* %4
store float 0.000000e+00, float* %5
store i32 1, i32* %2
br label %25
25: ; preds = %51, %22
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %54
29: ; preds = %25
%30 = load i32, i32* %2
%31 = sitofp i32 %30 to float
%32 = fdiv float 4.000000e+00, %31
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 2
%35 = sitofp i32 %34 to float
%36 = fdiv float 4.000000e+00, %35
%37 = fsub float %32, %36
store float %37, float* %6
%38 = load float, float* %5
%39 = load float, float* %6
%40 = fadd float %38, %39
store float %40, float* %5
%41 = load float, float* %6
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), double %42)
%44 = load float, float* %5
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), double %45)
%47 = load i32, i32* %4
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 2
store i32 %50, i32* %4
br label %51
51: ; preds = %29
%52 = load i32, i32* %2
%53 = add nsw i32 %52, 4
store i32 %53, i32* %2
br label %25
54: ; preds = %25
br label %57
55: ; preds = %18
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
br label %57
57: ; preds = %55, %54
br label %8
58: ; preds = %16, %8
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [77 x i8] c"Serinin kac terimiyle pi sayisi hesaplansin giriniz(cikmak icin -1 giriniz):\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [23 x i8] c"Programdan ciktiniz :)\00"
@.str.4 = [11 x i8] c"Seri = %f\0A\00"
@.str.5 = [18 x i8] c"pi sayisi = %.5f\0A\00"
@.str.6 = [30 x i8] c"Kullanilan terim sayisi = %d\0A\00"
@str = [138 x i8] c"Gregory\E2\80\93Leibniz yontemiyle pi sayisi hesaplanirken seri her cift terimde kendini tekrar etmektedir, bu yuzden cift sayili terim giriniz\00"
@str.8 = [35 x i8] c"Terim sayisini cift sayi giriniz!!\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([138 x i8], [138 x i8]* @str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %4
4: ; preds = %0, %42
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %45
11: ; preds = %4
%12 = and i32 %7, 1
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %39
14: ; preds = %11
%15 = shl nsw i32 %7, 1
store i32 %15, i32* %1
%16 = icmp slt i32 %7, 1
br i1 %16, label %42, label %17
17: ; preds = %14, %17
%18 = phi i32 [ %36, %17 ], [ 1, %14 ]
%19 = phi float [ %29, %17 ], [ 0.000000e+00, %14 ]
%20 = phi i32 [ %35, %17 ], [ 2, %14 ]
%21 = add nuw nsw i32 %18, 2
%22 = insertelement <2 x i32> poison, i32 %18, i64 0
%23 = insertelement <2 x i32> %22, i32 %21, i64 1
%24 = sitofp <2 x i32> %23 to <2 x float>
%25 = fdiv <2 x float> <float 4.000000e+00, float 4.000000e+00>, %24
%26 = shufflevector <2 x float> %25, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%27 = fsub <2 x float> %25, %26
%28 = extractelement <2 x float> %27, i64 0
%29 = fadd float %19, %28
%30 = fpext float %28 to double
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), double %30)
%32 = fpext float %29 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), double %32)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %20)
%35 = add nuw nsw i32 %20, 2
%36 = add nuw nsw i32 %18, 4
%37 = load i32, i32* %1
%38 = icmp sgt i32 %36, %37
br i1 %38, label %42, label %17
39: ; preds = %11
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.8, i64 0, i64 0))
%41 = load i32, i32* %1
br label %42
42: ; preds = %17, %14, %39
%43 = phi i32 [ %15, %14 ], [ %41, %39 ], [ %37, %17 ]
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %4
45: ; preds = %42, %9
ret i32 0
}