#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(void) {
  int i = 0;
  int point = 0, total_point = 0;
  float average = 0;
  do {
    printf("Enter %d. point: ", i + 1);
    scanf("%d", &point);
    if (point == EOF) {
      break;
    }
    if (point < 0) {
      printf("Point mustn't be smaller than 0!\n");
      printf("Enter the point again\n");
      continue;
    } else {
      total_point += point;
      i++;
    }
  } while (point != EOF);
  { average = (float)total_point / i; }
  printf("Average of the class is: %f", average);
  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)
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    0x2e6e(%rip),%rcx
cmp    (%rcx),%eax
jne    1187 <main+0x67>
jmp    11db <main+0xbb>
cmpl   $0x0,-0xc(%rbp)
jge    11b2 <main+0x92>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c9 <main+0xa9>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c9 <main+0xa9>
mov    -0xc(%rbp),%eax
mov    0x2e15(%rip),%rcx
cmp    (%rcx),%eax
jne    114c <main+0x2c>
cvtsi2ssl -0x10(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe50(%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    0xec8(%rip),%r15
lea    0x4(%rsp),%rbx
mov    0x2e92(%rip),%r13
xor    %r14d,%r14d
xor    %r12d,%r12d
jmp    1184 <main+0x54>
xchg   %ax,%ax
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
mov    0x0(%r13),%ecx
cmp    %ecx,%eax
je     11bd <main+0x8d>
lea    0x1(%r14),%ebp
lea    0xe71(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
mov    0x0(%r13),%ecx
cmp    %ecx,%eax
je     11bd <main+0x8d>
test   %eax,%eax
js     1160 <main+0x30>
add    %eax,%r12d
mov    %ebp,%r14d
cmp    %ecx,%eax
jne    1184 <main+0x54>
cvtsi2ss %r12d,%xmm0
cvtsi2ss %r14d,%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3f(%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 = [18 x i8] c"Enter %d. point: \00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.2 = [34 x i8] c"Point mustn't be smaller than 0!\0A\00"
@.str.3 = [23 x i8] c"Enter the point again\0A\00"
@.str.4 = [28 x i8] c"Average of the class is: %f\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
br label %6
6: ; preds = %28, %0
%7 = load i32, i32* %2
%8 = add nsw i32 %7, 1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %15
14: ; preds = %6
br label %32
15: ; preds = %6
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %28
21: ; preds = %15
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = add nsw i32 %23, %22
store i32 %24, i32* %4
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %27
27: ; preds = %21
br label %28
28: ; preds = %27, %18
%29 = load i32, i32* %3
%30 = load i32, i32* @EOF
%31 = icmp ne i32 %29, %30
br i1 %31, label %6, label %32
32: ; preds = %28, %14
%33 = load i32, i32* %4
%34 = sitofp i32 %33 to float
%35 = load i32, i32* %2
%36 = sitofp i32 %35 to float
%37 = fdiv float %34, %36
store float %37, float* %5
%38 = load float, float* %5
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), double %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter %d. point: \00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.4 = [28 x i8] c"Average of the class is: %f\00"
@str = [33 x i8] c"Point mustn't be smaller than 0!\00"
@str.5 = [22 x i8] c"Enter the point again\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %21, %0
%4 = phi i32 [ 0, %0 ], [ %24, %21 ]
%5 = phi i32 [ 0, %0 ], [ %25, %21 ]
%6 = add nsw i32 %4, 1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %27, label %12
12: ; preds = %3
%13 = icmp slt i32 %9, 0
br i1 %13, label %14, label %19
14: ; preds = %12
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0))
%17 = load i32, i32* %1
%18 = load i32, i32* @EOF
br label %21
19: ; preds = %12
%20 = add nsw i32 %9, %5
br label %21
21: ; preds = %19, %14
%22 = phi i32 [ %18, %14 ], [ %10, %19 ]
%23 = phi i32 [ %17, %14 ], [ %9, %19 ]
%24 = phi i32 [ %4, %14 ], [ %6, %19 ]
%25 = phi i32 [ %5, %14 ], [ %20, %19 ]
%26 = icmp eq i32 %23, %22
br i1 %26, label %27, label %3
27: ; preds = %3, %21
%28 = phi i32 [ %4, %3 ], [ %24, %21 ]
%29 = phi i32 [ %5, %3 ], [ %25, %21 ]
%30 = sitofp i32 %29 to float
%31 = sitofp i32 %28 to float
%32 = fdiv float %30, %31
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), double %33)
ret i32 0
}