#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 EOF;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int sayi = 0;
  int toplam = 0;
  int sayac = 0;
  float ortalama = 0;
  printf("sayi giriniz (sonlandirmak icin -1): ");
  scanf("%d", &sayi);
  while (sayi != EOF) {
    sayac++;
    toplam = toplam + sayi;
    printf("sayi giriniz (sonlandirmak icin -1): ");
    scanf("%d", &sayi);
  }
  ortalama = toplam / sayac;
  printf("Ortalama: %f, Toplam: %d, Sayac: %d", ortalama, toplam, sayac);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    0x2e74(%rip),%rcx
cmp    (%rcx),%eax
je     11b1 <main+0x91>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    116a <main+0x4a>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe4f(%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
movl   $0x0,0x4(%rsp)
lea    0xec6(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
mov    0x2e89(%rip),%r13
mov    $0x0,%ebp
cmp    0x0(%r13),%eax
je     11b4 <main+0x94>
lea    0xe8f(%rip),%r14
lea    0xecf(%rip),%r15
lea    0x4(%rsp),%r12
xor    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    %eax,%ebx
add    $0x1,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    0x0(%r13),%eax
jne    1190 <main+0x70>
mov    %ebx,%eax
cltd
idiv   %ebp
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5e(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x1,%al
call   1030 <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 = [38 x i8] c"sayi giriniz (sonlandirmak icin -1): \00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.2 = [36 x i8] c"Ortalama: %f, Toplam: %d, Sayac: %d\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* %2
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 ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %12, %0
%9 = load i32, i32* %2
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
store i32 %14, i32* %4
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = add nsw i32 %15, %16
store i32 %17, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
20: ; preds = %8
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = sdiv i32 %21, %22
%24 = sitofp i32 %23 to float
store float %24, float* %5
%25 = load float, float* %5
%26 = fpext float %25 to double
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), double %26, i32 %27, i32 %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"sayi giriniz (sonlandirmak icin -1): \00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.2 = [36 x i8] c"Ortalama: %f, Toplam: %d, Sayac: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %19, label %8
8: ; preds = %0, %8
%9 = phi i32 [ %16, %8 ], [ %5, %0 ]
%10 = phi i32 [ %12, %8 ], [ 0, %0 ]
%11 = phi i32 [ %13, %8 ], [ 0, %0 ]
%12 = add nuw nsw i32 %10, 1
%13 = add nsw i32 %9, %11
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %8
19: ; preds = %8, %0
%20 = phi i32 [ 0, %0 ], [ %13, %8 ]
%21 = phi i32 [ 0, %0 ], [ %12, %8 ]
%22 = sdiv i32 %20, %21
%23 = sitofp i32 %22 to float
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), double %24, i32 %20, i32 %21)
ret i32 0
}