#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*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ muestraFichero24(int /*<<< orphan*/ *);
int /*<<< orphan*/ pideNombreArchivo(char *);
int /*<<< orphan*/ printf(char *);
main() {
  FILE *fichero;
  char nombreFichero[5];
  pideNombreArchivo(nombreFichero);
  fichero = fopen(nombreFichero, "r");
  if (fichero != NULL) {
    muestraFichero24(fichero);
    fclose(fichero);
  } else {
    printf("Error no se ha podido abrir el fichero.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x15(%rbp),%rdi
call   1040 <pideNombreArchivo@plt>
lea    -0x15(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119e <main+0x4e>
mov    -0x10(%rbp),%rdi
call   1060 <muestraFichero24@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11aa <main+0x5a>
lea    0xe5d(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xb(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <pideNombreArchivo@plt>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     118b <main+0x3b>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <muestraFichero24@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    1197 <main+0x47>
lea    0xe70(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [40 x i8] c"Error no se ha podido abrir el fichero.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [5 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%5 = call i32 @pideNombreArchivo(i8* %4)
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %15
10: ; preds = %0
%11 = load i32*, i32** %2
%12 = call i32 @muestraFichero24(i32* %11)
%13 = load i32*, i32** %2
%14 = call i32 @fclose(i32* %13)
br label %17
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [40 x i8] c"Error no se ha podido abrir el fichero.\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = call i32 @pideNombreArchivo(i8* %2)
%4 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = call i32 @muestraFichero24(i32* %4)
%8 = call i32 @fclose(i32* %4)
br label %11
9: ; preds = %0
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
ret i32 0
}