#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 elemanSayisi = 0, toplam = 0;
  int sayilar[10];
  int tasiyici;
  float ortalama;
  while (1) {
    printf("Sayi giriniz. Cikis icin 0\n");
    scanf("%d", &tasiyici);
    if (tasiyici == 0) {
      printf("Cikis istegi alindi. Hesaplaniyor...\n");
      break;
    } else {
      toplam += tasiyici;
      elemanSayisi++;
    }
  }
  ortalama = (float)toplam / (float)elemanSayisi;
  printf("Ortalama: %.2f\n ", ortalama);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x44(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x44(%rbp)
jne    1178 <main+0x58>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118f <main+0x6f>
mov    -0x44(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x48(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe93(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xec4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11bf <main+0x8f>
pxor   %xmm2,%xmm2
lea    0xebb(%rip),%r14
lea    0xea0(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movd   %eax,%xmm0
movaps 0xe75(%rip),%xmm1
movss  %xmm0,%xmm1
paddd  %xmm1,%xmm2
movdqa %xmm2,0x10(%rsp)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movdqa 0x10(%rsp),%xmm2
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    1180 <main+0x50>
cvtdq2ps %xmm2,%xmm0
jmp    11c2 <main+0x92>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
movaps 0x10(%rsp),%xmm1
movaps %xmm1,%xmm0
shufps $0x55,%xmm1,%xmm0
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe22(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Sayi giriniz. Cikis icin 0\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"Cikis istegi alindi. Hesaplaniyor...\0A\00"
@.str.3 = [17 x i8] c"Ortalama: %.2f\0A \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca float
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %7
7: ; preds = %0, %20
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %21
14: ; preds = %7
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = add nsw i32 %16, %15
store i32 %17, i32* %3
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %20
20: ; preds = %14
br label %7
21: ; preds = %12
%22 = load i32, i32* %3
%23 = sitofp i32 %22 to float
%24 = load i32, i32* %2
%25 = sitofp i32 %24 to float
%26 = fdiv float %23, %25
store float %26, float* %6
%27 = load float, float* %6
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %28)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [17 x i8] c"Ortalama: %.2f\0A \00"
@str = [27 x i8] c"Sayi giriniz. Cikis icin 0\00"
@str.4 = [37 x i8] c"Cikis istegi alindi. Hesaplaniyor...\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 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 = icmp eq i32 %5, 0
br i1 %6, label %9, label %17
7: ; preds = %17
%8 = sitofp <2 x i32> %21 to <2 x float>
br label %9
9: ; preds = %7, %0
%10 = phi <2 x float> [ zeroinitializer, %0 ], [ %8, %7 ]
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.4, i64 0, i64 0))
%12 = extractelement <2 x float> %10, i64 0
%13 = extractelement <2 x float> %10, i64 1
%14 = fdiv float %12, %13
%15 = fpext float %14 to double
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %15)
ret i32 0
17: ; preds = %0, %17
%18 = phi i32 [ %24, %17 ], [ %5, %0 ]
%19 = phi <2 x i32> [ %21, %17 ], [ zeroinitializer, %0 ]
%20 = insertelement <2 x i32> <i32 poison, i32 1>, i32 %18, i64 0
%21 = add nsw <2 x i32> %19, %20
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%24 = load i32, i32* %1
%25 = icmp eq i32 %24, 0
br i1 %25, label %7, label %17
}