#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, float, float,
                           float, float);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, float *,
                          float *, float *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  FILE *fnotas = NULL;
  char dni[11];
  float nota1 = 0;
  float nota2 = 0;
  float nota3 = 0;
  float nota_final = 0;
  if (argc != 2)
    printf("Error: Debe especificar el nombre de un fichero\n");
  else {
    fnotas = fopen(argv[1], "r");
    if (fnotas == NULL)
      printf("Error: No se puede abrir el fichero\n");
    else {
      fscanf(fnotas, "%s %f %f %f", dni, &nota1, &nota2, &nota3);
      while (feof(fnotas) == 0) {
        nota_final = (nota1 + nota2 + nota3) / 3;
        fprintf(stdout, "%s %.2f %.2f %.2f %.2f\n", dni, nota1, nota2, nota3,
                nota_final);
        fscanf(fnotas, "%s %f %f %f", dni, &nota1, &nota2, &nota3);
      }
      fclose(fnotas);
    }
  }
  return 0;
}


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)
movq   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b9 <main+0x59>
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
jmp    12a0 <main+0x140>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ed <main+0x8d>
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
jmp    129b <main+0x13b>
mov    -0x18(%rbp),%rdi
lea    -0x23(%rbp),%rdx
lea    0xe60(%rip),%rsi
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
lea    -0x30(%rbp),%r9
call   1050 <fscanf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
jne    1292 <main+0x132>
movss  -0x28(%rbp),%xmm0
addss  -0x2c(%rbp),%xmm0
addss  -0x30(%rbp),%xmm0
movss  0xdc9(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    -0x23(%rbp),%rdx
movss  -0x28(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
movss  -0x30(%rbp),%xmm2
movss  -0x34(%rbp),%xmm3
lea    0xe00(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x23(%rbp),%rdx
lea    0xde0(%rip),%rsi
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
lea    -0x30(%rbp),%r9
call   1050 <fscanf@plt>
jmp    120d <main+0xad>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    12a0 <main+0x140>
xor    %eax,%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,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
cmp    $0x2,%edi
jne    126a <main+0x10a>
mov    0x8(%rsi),%rdi
lea    0xe6b(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1273 <main+0x113>
mov    %rax,%rbx
lea    0xe55(%rip),%rsi
lea    0xd(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %rsp,%r9
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %rax,%rax
jne    1260 <main+0x100>
lea    0xd(%rsp),%r15
lea    0xe1e(%rip),%r12
lea    0x8(%rsp),%r13
lea    0x4(%rsp),%rbp
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nop
movss  0x8(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
movaps %xmm0,%xmm3
addss  %xmm1,%xmm3
movss  (%rsp),%xmm2
addss  %xmm2,%xmm3
divss  0xddc(%rip),%xmm3
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
lea    0xdde(%rip),%rsi
mov    %r15,%rdx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
mov    %r14,%r9
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %rax,%rax
je     1200 <main+0xa0>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    127f <main+0x11f>
lea    0xddd(%rip),%rdi
jmp    127a <main+0x11a>
lea    0xdb0(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Error: Debe especificar el nombre de un fichero\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [37 x i8] c"Error: No se puede abrir el fichero\0A\00"
@.str.3 = [12 x i8] c"%s %f %f %f\00"
@stdout = global i32 0
@.str.4 = [24 x i8] c"%s %.2f %.2f %.2f %.2f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [11 x i8]
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store float 0.000000e+00, float* %8
store float 0.000000e+00, float* %9
store float 0.000000e+00, float* %10
store float 0.000000e+00, float* %11
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %54
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %53
25: ; preds = %16
%26 = load i32*, i32** %6
%27 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%28 = call i32 @fscanf(i32* %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %27, float* %8, float* %9, float* %10)
br label %29
29: ; preds = %33, %25
%30 = load i32*, i32** %6
%31 = call i64 @feof(i32* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %50
33: ; preds = %29
%34 = load float, float* %8
%35 = load float, float* %9
%36 = fadd float %34, %35
%37 = load float, float* %10
%38 = fadd float %36, %37
%39 = fdiv float %38, 3.000000e+00
store float %39, float* %11
%40 = load i32, i32* @stdout
%41 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%42 = load float, float* %8
%43 = load float, float* %9
%44 = load float, float* %10
%45 = load float, float* %11
%46 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %41, float %42, float %43, float %44, float %45)
%47 = load i32*, i32** %6
%48 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%49 = call i32 @fscanf(i32* %47, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %48, float* %8, float* %9, float* %10)
br label %29
50: ; preds = %29
%51 = load i32*, i32** %6
%52 = call i32 @fclose(i32* %51)
br label %53
53: ; preds = %50, %23
br label %54
54: ; preds = %53, %14
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [12 x i8] c"%s %f %f %f\00"
@stdout = global i32 0
@.str.4 = [24 x i8] c"%s %.2f %.2f %.2f %.2f\0A\00"
@str = [36 x i8] c"Error: No se puede abrir el fichero\00"
@str.5 = [48 x i8] c"Error: Debe especificar el nombre de un fichero\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [11 x i8]
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%8 = bitcast float* %4 to i8*
store float 0.000000e+00, float* %4
%9 = bitcast float* %5 to i8*
store float 0.000000e+00, float* %5
%10 = bitcast float* %6 to i8*
store float 0.000000e+00, float* %6
%11 = icmp eq i32 %0, 2
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.5, i64 0, i64 0))
br label %39
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %39
21: ; preds = %14
%22 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %7, float* %4, float* %5, float* %6)
%23 = call i64 @feof(i32* %17)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %37
25: ; preds = %21, %25
%26 = load float, float* %4
%27 = load float, float* %5
%28 = fadd float %26, %27
%29 = load float, float* %6
%30 = fadd float %28, %29
%31 = fdiv float %30, 3.000000e+00
%32 = load i32, i32* @stdout
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %7, float %26, float %27, float %29, float %31)
%34 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %7, float* %4, float* %5, float* %6)
%35 = call i64 @feof(i32* %17)
%36 = icmp eq i64 %35, 0
br i1 %36, label %25, label %37
37: ; preds = %25, %21
%38 = call i32 @fclose(i32* %17)
br label %39
39: ; preds = %19, %37, %12
ret i32 0
}