#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 main() {
  int km, toplam_km;
  float litre, toplam_litre, ort, genel_ort;
  printf("Cıkmak icin kilometreyi -1 giriniz\n");
  toplam_km = 0;
  toplam_litre = 0;
  printf("Kac kilometre yol alindi giriniz:");
  scanf("%d", &km);
  while (km != -1) {
    printf("Kac litre benzin harcandi giriniz:");
    scanf("%f", &litre);
    ort = (float)km / litre;
    toplam_km = toplam_km + km;
    toplam_litre = toplam_litre + litre;
    printf("Ortalama kilometre/litre=%.2f\n", ort);
    printf("Kac kilometre yol alindi giriniz:");
    scanf("%d", &km);
  }
  if (km == -1 && litre == 0) {
    printf("Program sonlandirlilmistir");
  }
  if (km == -1 && litre != 0) {
    genel_ort = toplam_km / toplam_litre;
    printf("Toplam ortalama Kilometre/litre=%.2f", genel_ort);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
je     11f9 <main+0xd9>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cvtsi2ssl -0x8(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5e(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    116c <main+0x4c>
cmpl   $0xffffffff,-0x8(%rbp)
jne    1228 <main+0x108>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1228 <main+0x108>
jp     1228 <main+0x108>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
jne    1274 <main+0x154>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    124e <main+0x12e>
jp     124e <main+0x12e>
jmp    1274 <main+0x154>
cvtsi2ssl -0xc(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3d(%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
sub    $0x18,%rsp
lea    0xf65(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0xffffffff,0x8(%rsp)
je     1262 <main+0x132>
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0x10(%rsp),%r12
lea    0xec0(%rip),%r13
lea    0xe6e(%rip),%rbx
lea    0xe89(%rip),%rbp
lea    0x8(%rsp),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe83(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x10(%rsp),%xmm1
divss  %xmm1,%xmm0
add    %eax,%r15d
movss  0xc(%rsp),%xmm2
addss  %xmm1,%xmm2
movss  %xmm2,0xc(%rsp)
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0xffffffff,0x8(%rsp)
jne    11b0 <main+0x80>
cvtsi2ss %r15d,%xmm3
movss  0x10(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1270 <main+0x140>
jp     1270 <main+0x140>
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
movss  %xmm3,0x14(%rsp)
call   1040 <printf@plt>
movss  0x14(%rsp),%xmm3
movss  0x10(%rsp),%xmm0
cmpl   $0xffffffff,0x8(%rsp)
sete   %al
jmp    1272 <main+0x142>
mov    $0x1,%al
xorps  %xmm3,%xmm3
xorps  %xmm2,%xmm2
test   %al,%al
jne    127c <main+0x14c>
jmp    129f <main+0x16f>
mov    $0x1,%al
movss  0xc(%rsp),%xmm2
test   %al,%al
je     129f <main+0x16f>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1286 <main+0x156>
jnp    129f <main+0x16f>
divss  %xmm2,%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
lea    0xded(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"C\C4\B1kmak icin kilometreyi -1 giriniz\0A\00"
@.str.1 = [34 x i8] c"Kac kilometre yol alindi giriniz:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [35 x i8] c"Kac litre benzin harcandi giriniz:\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [31 x i8] c"Ortalama kilometre/litre=%.2f\0A\00"
@.str.6 = [27 x i8] c"Program sonlandirlilmistir\00"
@.str.7 = [37 x i8] c"Toplam ortalama Kilometre/litre=%.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
store float 0.000000e+00, float* %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %11
11: ; preds = %14, %0
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %32
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %4)
%17 = load i32, i32* %2
%18 = sitofp i32 %17 to float
%19 = load float, float* %4
%20 = fdiv float %18, %19
store float %20, float* %6
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = add nsw i32 %21, %22
store i32 %23, i32* %3
%24 = load float, float* %5
%25 = load float, float* %4
%26 = fadd float %24, %25
store float %26, float* %5
%27 = load float, float* %6
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), double %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %11
32: ; preds = %11
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = load float, float* %4
%37 = fcmp oeq float %36, 0.000000e+00
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %40
40: ; preds = %38, %35, %32
%41 = load i32, i32* %2
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %54
43: ; preds = %40
%44 = load float, float* %4
%45 = fcmp une float %44, 0.000000e+00
br i1 %45, label %46, label %54
46: ; preds = %43
%47 = load i32, i32* %3
%48 = sitofp i32 %47 to float
%49 = load float, float* %5
%50 = fdiv float %48, %49
store float %50, float* %7
%51 = load float, float* %7
%52 = fpext float %51 to double
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), double %52)
br label %54
54: ; preds = %46, %43, %40
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [34 x i8] c"Kac kilometre yol alindi giriniz:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [35 x i8] c"Kac litre benzin harcandi giriniz:\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [31 x i8] c"Ortalama kilometre/litre=%.2f\0A\00"
@.str.6 = [27 x i8] c"Program sonlandirlilmistir\00"
@.str.7 = [37 x i8] c"Toplam ortalama Kilometre/litre=%.2f\00"
@str = [36 x i8] c"C\C4\B1kmak icin kilometreyi -1 giriniz\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = bitcast i32* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, -1
br i1 %9, label %36, label %10
10: ; preds = %0, %10
%11 = phi i32 [ %19, %10 ], [ 0, %0 ]
%12 = phi float [ %20, %10 ], [ 0.000000e+00, %0 ]
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %2)
%15 = load i32, i32* %1
%16 = sitofp i32 %15 to float
%17 = load float, float* %2
%18 = fdiv float %16, %17
%19 = add nsw i32 %15, %11
%20 = fadd float %12, %17
%21 = fpext float %18 to double
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), double %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%25 = load i32, i32* %1
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %10
27: ; preds = %10
%28 = load float, float* %2
%29 = sitofp i32 %19 to float
%30 = fcmp oeq float %28, 0.000000e+00
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%33 = load i32, i32* %1
%34 = load float, float* %2
%35 = icmp eq i32 %33, -1
br label %36
36: ; preds = %0, %31, %27
%37 = phi float [ %29, %31 ], [ %29, %27 ], [ 0.000000e+00, %0 ]
%38 = phi float [ %20, %31 ], [ %20, %27 ], [ 0.000000e+00, %0 ]
%39 = phi float [ %34, %31 ], [ %28, %27 ], [ undef, %0 ]
%40 = phi i1 [ %35, %31 ], [ true, %27 ], [ true, %0 ]
%41 = fcmp une float %39, 0.000000e+00
%42 = select i1 %40, i1 %41, i1 false
br i1 %42, label %43, label %47
43: ; preds = %36
%44 = fdiv float %37, %38
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), double %45)
br label %47
47: ; preds = %43, %36
ret i32 0
}