#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 *, float);
int /*<<< orphan*/ vazio_arquivo(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  FILE *farq;
  char c;
  float notas[3] = {0, 0, 0};
  float media, media_alun;
  int cont = 0;
  farq = abri_arquivo();
  vazio_arquivo(farq);
  fseek(farq, 0, SEEK_SET);
  char ascii = 39;
  while (!feof(farq)) {
    while (cont < 2) {
      c = fgetc(farq);
      if (c == ascii)
        cont++;
    }
    cont = 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 > media)
      media = media_alun;
  }
  fclose(farq);
  printf("A maior Media obtida foi: %.1f \n", 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    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
movl   $0x0,-0x34(%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    0x2e04(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
movb   $0x27,-0x35(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1207 <main+0x77>
jmp    12c9 <main+0x139>
jmp    120c <main+0x7c>
cmpl   $0x2,-0x34(%rbp)
jge    1240 <main+0xb0>
mov    -0x18(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
movsbl -0x35(%rbp),%ecx
cmp    %ecx,%eax
jne    123b <main+0xab>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    120c <main+0x7c>
movl   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rdx
lea    0xdae(%rip),%rsi
call   1070 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rdx
add    $0x4,%rdx
lea    0xd96(%rip),%rsi
call   1070 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rdx
add    $0x8,%rdx
lea    0xd7e(%rip),%rsi
call   1070 <fscanf@plt>
movss  -0x28(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
movss  0xd5e(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
ucomiss -0x2c(%rbp),%xmm0
jbe    12c4 <main+0x134>
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
jmp    11e9 <main+0x59>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movss  -0x2c(%rbp),%xmm0
lea    0xd29(%rip),%rdi
call   1050 <printf@plt>
mov    0x2cee(%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    %eax,%eax
call   1090 <abri_arquivo@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <vazio_arquivo@plt>
mov    0x2e28(%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    1282 <main+0x102>
lea    0xc(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0xe1f(%rip),%r12
lea    0x8(%rsp),%r13
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1070 <fgetc@plt>
xor    %ecx,%ecx
cmp    $0x27,%al
sete   %cl
add    %ecx,%ebp
cmp    $0x2,%ebp
jb     1200 <main+0x80>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1060 <fscanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%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  0xda6(%rip),%xmm0
maxss  0x14(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
mov    %rbx,%rdi
call   1080 <feof@plt>
movss  0x4(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
test   %eax,%eax
je     11f0 <main+0x70>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xd76(%rip),%rdi
movss  0x4(%rsp),%xmm0
call   1050 <printf@plt>
mov    0x2d35(%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 = [33 x i8] c"A maior Media obtida foi: %.1f \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 [3 x float]
%9 = alloca float
%10 = alloca float
%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]* %8 to i8*
store i32 0, i32* %11
%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)
store i8 39, i8* %12
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
%42 = load i32*, i32** %6
%43 = getelementptr inbounds [3 x float], [3 x float]* %8, 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]* %8, 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]* %8, 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]* %8, i64 0, i64 0
%52 = load float, float* %51
%53 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 1
%54 = load float, float* %53
%55 = fadd float %52, %54
%56 = getelementptr inbounds [3 x float], [3 x float]* %8, 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* %10
%60 = load float, float* %10
%61 = load float, float* %9
%62 = fcmp ogt float %60, %61
br i1 %62, label %63, label %65
63: ; preds = %41
%64 = load float, float* %10
store float %64, float* %9
br label %65
65: ; preds = %63, %41
br label %20
66: ; preds = %20
%67 = load i32*, i32** %6
%68 = call i32 @fclose(i32* %67)
%69 = load float, float* %9
%70 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), float %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 = [33 x i8] c"A maior Media obtida foi: %.1f \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 %38
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 float [ undef, %11 ], [ %35, %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 ogt float %33, %16
%35 = select i1 %34, float %33, float %16
%36 = call i32 @feof(i32* %5)
%37 = icmp eq i32 %36, 0
br i1 %37, label %15, label %38
38: ; preds = %24, %2
%39 = phi float [ undef, %2 ], [ %35, %24 ]
%40 = call i32 @fclose(i32* %5)
%41 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), float %39)
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}