#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 sayi, sayici = 0, toplam = 0;
  float ortalama = 0;
  printf("9999 girdiginizde ortalma alinir program sonlanir.\n");
  for (sayici = 0; sayi != 9999;) {
    printf("Sayi giriniz:");
    scanf("%d", &sayi);
    if (sayi != 9999) {
      toplam = toplam + sayi;
      sayici++;
    }
  }
  ortalama = (float)toplam / sayici;
  printf("Girilen sayilarin toplami = %d\n", toplam);
  printf("Girilen sayilarin adeti = %d\n", sayici);
  printf("Girilen sayilarin ortalamasi=%.2f", ortalama);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x270f,-0x8(%rbp)
je     11a9 <main+0x89>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x270f,-0x8(%rbp)
je     11a4 <main+0x84>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115a <main+0x3a>
cvtsi2ssl -0x10(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe95(%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   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf2f(%rip),%rdi
call   1030 <puts@plt>
xor    %r13d,%r13d
mov    $0xffffffff,%ebp
lea    0xeaa(%rip),%r14
lea    0xeb1(%rip),%r15
lea    0x4(%rsp),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x270f,%eax
mov    %eax,%ecx
cmove  %r13d,%ecx
add    %ecx,%ebx
add    $0x1,%ebp
cmp    $0x270f,%eax
jne    1170 <main+0x40>
sete   %al
cvtsi2ss %ebx,%xmm1
add    $0x1,%al
movzbl %al,%r14d
and    $0x1,%r14d
add    %ebp,%r14d
cvtsi2ss %r14d,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,(%rsp)
lea    0xe48(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe58(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5c(%rip),%rdi
mov    $0x1,%al
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 = [52 x i8] c"9999 girdiginizde ortalma alinir program sonlanir.\0A\00"
@.str.1 = [14 x i8] c"Sayi giriniz:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [32 x i8] c"Girilen sayilarin toplami = %d\0A\00"
@.str.4 = [30 x i8] c"Girilen sayilarin adeti = %d\0A\00"
@.str.5 = [34 x i8] c"Girilen sayilarin ortalamasi=%.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store float 0.000000e+00, float* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %7
7: ; preds = %21, %0
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 9999
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 9999
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = add nsw i32 %16, %17
store i32 %18, i32* %4
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %21
21: ; preds = %15, %10
br label %7
22: ; preds = %7
%23 = load i32, i32* %4
%24 = sitofp i32 %23 to float
%25 = load i32, i32* %3
%26 = sitofp i32 %25 to float
%27 = fdiv float %24, %26
store float %27, float* %5
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = load float, float* %5
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), double %33)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"Sayi giriniz:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [32 x i8] c"Girilen sayilarin toplami = %d\0A\00"
@.str.4 = [30 x i8] c"Girilen sayilarin adeti = %d\0A\00"
@.str.5 = [34 x i8] c"Girilen sayilarin ortalamasi=%.2f\00"
@str = [51 x i8] c"9999 girdiginizde ortalma alinir program sonlanir.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ %15, %4 ], [ 0, %0 ]
%6 = phi i32 [ %13, %4 ], [ 0, %0 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 9999
%11 = xor i1 %10, true
%12 = zext i1 %11 to i32
%13 = add nuw nsw i32 %6, %12
%14 = select i1 %10, i32 0, i32 %9
%15 = add nsw i32 %14, %5
br i1 %10, label %16, label %4
16: ; preds = %4
%17 = sitofp i32 %15 to float
%18 = sitofp i32 %13 to float
%19 = fdiv float %17, %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %13)
%22 = fpext float %19 to double
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), double %22)
ret i32 0
}