#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ *abri_arquivo();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ vazio_arquivo(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  FILE *farq;
  char c;
  float media_alun, notas[3] = {0, 0, 0};
  int maior_media = 0, cont = 0;
  char ascii = 39;
  farq = abri_arquivo();
  vazio_arquivo(farq);
  fseek(farq, 0, SEEK_SET);
  while (!feof(farq)) {
    while (cont < 2) {
      c = fgetc(farq);
      if (c == ascii)
        cont++;
    }
    cont = 0, media_alun = 0;
    fscanf(farq, "%f", &notas[0]);
    fscanf(farq, "%f", &notas[1]);
    fscanf(farq, "%f", &notas[2]);
    media_alun = (notas[0] + notas[1] + notas[2]) / 3;
    if (media_alun >= 5)
      maior_media++;
  }
  fclose(farq);
  printf("O numero de alunos com media >= 5 e: %d \n", maior_media);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x2c(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movb   $0x27,-0x35(%rbp)
mov    $0x0,%al
call   10a0 <abri_arquivo@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <vazio_arquivo@plt>
mov    -0x18(%rbp),%rdi
mov    0x2df9(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    120e <main+0x7e>
jmp    12de <main+0x14e>
jmp    1213 <main+0x83>
cmpl   $0x2,-0x34(%rbp)
jge    1247 <main+0xb7>
mov    -0x18(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
movsbl -0x35(%rbp),%ecx
cmp    %ecx,%eax
jne    1242 <main+0xb2>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1213 <main+0x83>
movl   $0x0,-0x34(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x2c(%rbp),%rdx
lea    0xda3(%rip),%rsi
call   1070 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x2c(%rbp),%rdx
add    $0x4,%rdx
lea    0xd8b(%rip),%rsi
call   1070 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x2c(%rbp),%rdx
add    $0x8,%rdx
lea    0xd73(%rip),%rsi
call   1070 <fscanf@plt>
movss  -0x2c(%rbp),%xmm0
addss  -0x28(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
movss  0xd53(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
movss  0xd39(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     12d9 <main+0x149>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11f0 <main+0x60>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%esi
lea    0xd1a(%rip),%rdi
call   1050 <printf@plt>
mov    0x2cdb(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
xor    %ebp,%ebp
xor    %eax,%eax
call   1090 <abri_arquivo@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <vazio_arquivo@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1278 <main+0xf8>
xor    %ebp,%ebp
lea    0x10(%rsp),%r15
lea    0xe24(%rip),%r12
lea    0x8(%rsp),%r13
nopl   0x0(%rax)
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1070 <fgetc@plt>
xor    %ecx,%ecx
cmp    $0x27,%al
sete   %cl
add    %ecx,%r14d
cmp    $0x2,%r14d
jb     1200 <main+0x80>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1060 <fscanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
lea    0xc(%rsp),%rdx
call   1060 <fscanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1060 <fscanf@plt>
movss  0x8(%rsp),%xmm0
addss  0xc(%rsp),%xmm0
addss  0x10(%rsp),%xmm0
divss  0xda2(%rip),%xmm0
ucomiss 0xd9f(%rip),%xmm0
sbb    $0xffffffff,%ebp
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     11f0 <main+0x70>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xd84(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%f\00"
@.str.1 = [42 x i8] c"O numero de alunos com media >= 5 e: %d \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
%8 = alloca float
%9 = alloca [3 x float]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = bitcast [3 x float]* %9 to i8*
store i32 0, i32* %10
store i32 0, i32* %11
store i8 39, i8* %12
%14 = call i32* (...) @abri_arquivo()
store i32* %14, i32** %6
%15 = load i32*, i32** %6
%16 = call i32 @vazio_arquivo(i32* %15)
%17 = load i32*, i32** %6
%18 = load i32, i32* @SEEK_SET
%19 = call i32 @fseek(i32* %17, i32 0, i32 %18)
br label %20
20: ; preds = %65, %2
%21 = load i32*, i32** %6
%22 = call i32 @feof(i32* %21)
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
br i1 %24, label %25, label %66
25: ; preds = %20
br label %26
26: ; preds = %40, %25
%27 = load i32, i32* %11
%28 = icmp slt i32 %27, 2
br i1 %28, label %29, label %41
29: ; preds = %26
%30 = load i32*, i32** %6
%31 = call signext i8 @fgetc(i32* %30)
store i8 %31, i8* %7
%32 = load i8, i8* %7
%33 = sext i8 %32 to i32
%34 = load i8, i8* %12
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %33, %35
br i1 %36, label %37, label %40
37: ; preds = %29
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
br label %40
40: ; preds = %37, %29
br label %26
41: ; preds = %26
store i32 0, i32* %11
store float 0.000000e+00, float* %8
%42 = load i32*, i32** %6
%43 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%44 = call i32 @fscanf(i32* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %43)
%45 = load i32*, i32** %6
%46 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%47 = call i32 @fscanf(i32* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %46)
%48 = load i32*, i32** %6
%49 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%50 = call i32 @fscanf(i32* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %49)
%51 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%52 = load float, float* %51
%53 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%54 = load float, float* %53
%55 = fadd float %52, %54
%56 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%57 = load float, float* %56
%58 = fadd float %55, %57
%59 = fdiv float %58, 3.000000e+00
store float %59, float* %8
%60 = load float, float* %8
%61 = fcmp oge float %60, 5.000000e+00
br i1 %61, label %62, label %65
62: ; preds = %41
%63 = load i32, i32* %10
%64 = add nsw i32 %63, 1
store i32 %64, i32* %10
br label %65
65: ; preds = %62, %41
br label %20
66: ; preds = %20
%67 = load i32*, i32** %6
%68 = call i32 @fclose(i32* %67)
%69 = load i32, i32* %10
%70 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %69)
%71 = load i32, i32* @EXIT_SUCCESS
ret i32 %71
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%f\00"
@.str.1 = [42 x i8] c"O numero de alunos com media >= 5 e: %d \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x float]
%4 = bitcast [3 x float]* %3 to i8*
%5 = tail call i32* (...) @abri_arquivo()
%6 = tail call i32 @vazio_arquivo(i32* %5)
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @fseek(i32* %5, i32 0, i32 %7)
%9 = call i32 @feof(i32* %5)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %39
11: ; preds = %2
%12 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 0
%13 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 1
%14 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 2
br label %15
15: ; preds = %11, %24
%16 = phi i32 [ 0, %11 ], [ %36, %24 ]
br label %17
17: ; preds = %15, %17
%18 = phi i32 [ 0, %15 ], [ %22, %17 ]
%19 = call signext i8 @fgetc(i32* %5)
%20 = icmp eq i8 %19, 39
%21 = zext i1 %20 to i32
%22 = add nuw nsw i32 %18, %21
%23 = icmp ult i32 %22, 2
br i1 %23, label %17, label %24
24: ; preds = %17
%25 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %12)
%26 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %13)
%27 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %14)
%28 = load float, float* %12
%29 = load float, float* %13
%30 = fadd float %28, %29
%31 = load float, float* %14
%32 = fadd float %30, %31
%33 = fdiv float %32, 3.000000e+00
%34 = fcmp oge float %33, 5.000000e+00
%35 = zext i1 %34 to i32
%36 = add nuw nsw i32 %16, %35
%37 = call i32 @feof(i32* %5)
%38 = icmp eq i32 %37, 0
br i1 %38, label %15, label %39
39: ; preds = %24, %2
%40 = phi i32 [ 0, %2 ], [ %36, %24 ]
%41 = call i32 @fclose(i32* %5)
%42 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%43 = load i32, i32* @EXIT_SUCCESS
ret i32 %43
}