#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*/ SEEK_SET;
int /*<<< orphan*/ archivo_lee_pila_dinamica(int /*<<< orphan*/ *);
int /*<<< orphan*/ archivo_lee_pila_estatica(int /*<<< orphan*/ *);
int /*<<< orphan*/ archivo_lee_pila_mantiene(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int main() {
  printf("Hello world!\n");
  FILE *f = fopen("texto.txt", "rt");
  if (f != NULL) {
    printf("Dinamica: \t");
    archivo_lee_pila_dinamica(f);
    fseek(f, 0, SEEK_SET);
    printf("\nEstatica: \t");
    archivo_lee_pila_estatica(f);
    fseek(f, 0, SEEK_SET);
    printf("\nManteniendo: \t");
    archivo_lee_pila_mantiene(f);
    printf("\n");
    fclose(f);
  } else {
    printf("Error abriendo archivo de texto");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     122e <main+0xbe>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1090 <archivo_lee_pila_dinamica@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e13(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <archivo_lee_pila_estatica@plt>
mov    -0x10(%rbp),%rdi
mov    0x2dea(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <archivo_lee_pila_mantiene@plt>
lea    0xdf1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
jmp    123a <main+0xca>
lea    0xe0f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xebb(%rip),%rdi
call   1040 <puts@plt>
lea    0xe59(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     122c <main+0x9c>
mov    %rax,%rbx
lea    0xe4b(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   10b0 <archivo_lee_pila_dinamica@plt>
mov    0x2e0a(%rip),%r14
mov    (%r14),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
lea    0xe2f(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1070 <archivo_lee_pila_estatica@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
lea    0xe1b(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   10a0 <archivo_lee_pila_mantiene@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    1238 <main+0xa8>
lea    0xe03(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Hello world!\0A\00"
@.str.1 = [10 x i8] c"texto.txt\00"
@.str.2 = [3 x i8] c"rt\00"
@.str.3 = [12 x i8] c"Dinamica: \09\00"
@SEEK_SET = global i32 0
@.str.4 = [13 x i8] c"\0AEstatica: \09\00"
@.str.5 = [16 x i8] c"\0AManteniendo: \09\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [32 x i8] c"Error abriendo archivo de texto\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %26
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32*, i32** %2
%10 = call i32 @archivo_lee_pila_dinamica(i32* %9)
%11 = load i32*, i32** %2
%12 = load i32, i32* @SEEK_SET
%13 = call i32 @fseek(i32* %11, i32 0, i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%15 = load i32*, i32** %2
%16 = call i32 @archivo_lee_pila_estatica(i32* %15)
%17 = load i32*, i32** %2
%18 = load i32, i32* @SEEK_SET
%19 = call i32 @fseek(i32* %17, i32 0, i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%21 = load i32*, i32** %2
%22 = call i32 @archivo_lee_pila_mantiene(i32* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%24 = load i32*, i32** %2
%25 = call i32 @fclose(i32* %24)
br label %28
26: ; preds = %0
%27 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
br label %28
28: ; preds = %26, %7
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"texto.txt\00"
@.str.2 = [3 x i8] c"rt\00"
@.str.3 = [12 x i8] c"Dinamica: \09\00"
@SEEK_SET = global i32 0
@.str.4 = [13 x i8] c"\0AEstatica: \09\00"
@.str.5 = [16 x i8] c"\0AManteniendo: \09\00"
@.str.7 = [32 x i8] c"Error abriendo archivo de texto\00"
@str = [13 x i8] c"Hello world!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %17, label %4
4: ; preds = %0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @archivo_lee_pila_dinamica(i32* %2)
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @fseek(i32* %2, i32 0, i32 %7)
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @archivo_lee_pila_estatica(i32* %2)
%11 = load i32, i32* @SEEK_SET
%12 = tail call i32 @fseek(i32* %2, i32 0, i32 %11)
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%14 = tail call i32 @archivo_lee_pila_mantiene(i32* %2)
%15 = tail call i32 @putchar(i32 10)
%16 = tail call i32 @fclose(i32* %2)
br label %19
17: ; preds = %0
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
br label %19
19: ; preds = %17, %4
ret i32 0
}