#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
int main() {
  FILE *archivo;
  char caracteres[100];
  archivo = fopen("prueba.txt", "r");
  if (archivo == NULL)
    exit(1);
  printf("\nEl contenido del archivo de prueba es \n\n");
  while (feof(archivo) == 0) {
    fgets(caracteres, 100, archivo);
    printf("%s", caracteres);
  }
  system("PAUSE");
  fclose(archivo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ae <main+0x3e>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
jne    11f8 <main+0x88>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    -0x80(%rbp),%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11bc <main+0x4c>
lea    0xe3b(%rip),%rdi
call   1040 <system@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
lea    0xe70(%rip),%rdi
lea    0xe74(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     121a <main+0x9a>
mov    %rax,%rbx
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    11fa <main+0x7a>
mov    %rsp,%r14
lea    0xe46(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %rax,%rax
je     11d0 <main+0x50>
lea    0xe0f(%rip),%rdi
call   1050 <system@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"prueba.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [42 x i8] c"\0AEl contenido del archivo de prueba es \0A\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [100 x i8]
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %15, %9
%12 = load i32*, i32** %2
%13 = call i64 @feof(i32* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%17 = load i32*, i32** %2
%18 = call i32 @fgets(i8* %16, i32 100, i32* %17)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %19)
br label %11
21: ; preds = %11
%22 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%23 = load i32*, i32** %2
%24 = call i32 @fclose(i32* %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"prueba.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [6 x i8] c"PAUSE\00"
@str = [41 x i8] c"\0AEl contenido del archivo de prueba es \0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 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 %5, label %7
5: ; preds = %0
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%9 = call i64 @feof(i32* %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %7, %11
%12 = call i32 @fgets(i8* %2, i32 100, i32* %3)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%14 = call i64 @feof(i32* %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %11, label %16
16: ; preds = %11, %7
%17 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @fclose(i32* %3)
ret i32 0
}