#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 contar_vocales(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
int main() {
  char cadena[200];
  int contador = 0, vocalestotal = 0, vocaleslinea;
  FILE *fich;
  fich = fopen("datos.txt", "r");
  if (fich == NULL) {
    fprintf(stdout, "error al abrir el fichero\n");
  } else {
    while (fgets(cadena, 200, fich)) {
      vocaleslinea = contar_vocales(cadena);
      fprintf(stdout, "Leo una linea con %d vocales: %s", vocaleslinea, cadena);
      vocalestotal = vocalestotal + vocaleslinea;
      contador = contador + 1;
    }
    fclose(fich);
    fprintf(stdout, "El fichero tiene %d lineas y %d vocales\n", contador,
            vocalestotal);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
lea    0xe83(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xe8(%rbp)
cmpq   $0x0,-0xe8(%rbp)
jne    11ba <main+0x6a>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    126c <main+0x11c>
jmp    11bf <main+0x6f>
lea    -0xd0(%rbp),%rdi
mov    -0xe8(%rbp),%rdx
mov    $0xc8,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     123d <main+0xed>
lea    -0xd0(%rbp),%rdi
call   1030 <contar_vocales@plt>
mov    %eax,-0xdc(%rbp)
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    -0xdc(%rbp),%edx
lea    -0xd0(%rbp),%rcx
lea    0xe17(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0xd8(%rbp),%eax
add    -0xdc(%rbp),%eax
mov    %eax,-0xd8(%rbp)
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    11bf <main+0x6f>
mov    -0xe8(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
mov    -0xd4(%rbp),%edx
mov    -0xd8(%rbp),%ecx
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
lea    0xe98(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11df <main+0x8f>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0xc8,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11f8 <main+0xa8>
mov    %rsp,%r15
lea    0xe8c(%rip),%r12
xor    %ebx,%ebx
xor    %r13d,%r13d
mov    %r15,%rdi
call   1030 <contar_vocales@plt>
mov    %eax,%ebp
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    %r12,%rsi
mov    %ebp,%edx
mov    %r15,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
add    %ebp,%r13d
add    $0x1,%ebx
mov    %r15,%rdi
mov    $0xc8,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11a0 <main+0x50>
jmp    11fd <main+0xad>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1221 <main+0xd1>
xor    %r13d,%r13d
xor    %ebx,%ebx
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
mov    %ebx,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"datos.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdout = global i32 0
@.str.2 = [27 x i8] c"error al abrir el fichero\0A\00"
@.str.3 = [33 x i8] c"Leo una linea con %d vocales: %s\00"
@.str.4 = [41 x i8] c"El fichero tiene %d lineas y %d vocales\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [200 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
%7 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = load i32, i32* @stdout
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %38
13: ; preds = %0
br label %14
14: ; preds = %19, %13
%15 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%16 = load i32*, i32** %6
%17 = call i64 @fgets(i8* %15, i32 200, i32* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %31
19: ; preds = %14
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%21 = call i32 @contar_vocales(i8* %20)
store i32 %21, i32* %5
%22 = load i32, i32* @stdout
%23 = load i32, i32* %5
%24 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %23, i8* %24)
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = add nsw i32 %26, %27
store i32 %28, i32* %4
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %14
31: ; preds = %14
%32 = load i32*, i32** %6
%33 = call i32 @fclose(i32* %32)
%34 = load i32, i32* @stdout
%35 = load i32, i32* %3
%36 = load i32, i32* %4
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %35, i32 %36)
br label %38
38: ; preds = %31, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"datos.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdout = global i32 0
@.str.2 = [27 x i8] c"error al abrir el fichero\0A\00"
@.str.3 = [33 x i8] c"Leo una linea con %d vocales: %s\00"
@.str.4 = [41 x i8] c"El fichero tiene %d lineas y %d vocales\0A\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = call i64 @fgets(i8* %2, i32 200, i32* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %21, label %11
8: ; preds = %0
%9 = load i32, i32* @stdout
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %27
11: ; preds = %5, %11
%12 = phi i32 [ %18, %11 ], [ 0, %5 ]
%13 = phi i32 [ %17, %11 ], [ 0, %5 ]
%14 = call i32 @contar_vocales(i8* %2)
%15 = load i32, i32* @stdout
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %14, i8* %2)
%17 = add nsw i32 %14, %13
%18 = add nuw nsw i32 %12, 1
%19 = call i64 @fgets(i8* %2, i32 200, i32* %3)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %11
21: ; preds = %11, %5
%22 = phi i32 [ 0, %5 ], [ %17, %11 ]
%23 = phi i32 [ 0, %5 ], [ %18, %11 ]
%24 = call i32 @fclose(i32* %3)
%25 = load i32, i32* @stdout
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %23, i32 %22)
br label %27
27: ; preds = %21, %8
ret i32 0
}