#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 EOF;
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  char nombre[20];
  char *buffer;
  FILE *fp;
  strcpy(nombre, argv[1]);
  fp = fopen(nombre, "r");
  if (fp == NULL)
    return 2;
  buffer = malloc(sizeof(int));
  while (!feof(fp)) {
    int c = fgetc(fp);
    if (c != EOF)
      printf("%c", (char)c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x30(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11b2 <main+0x52>
movl   $0x2,-0x4(%rbp)
jmp    121a <main+0xba>
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11de <main+0x7e>
jmp    1213 <main+0xb3>
mov    -0x40(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    0x2df4(%rip),%rcx
cmp    (%rcx),%eax
je     120e <main+0xae>
mov    -0x44(%rbp),%eax
lea    0xdfc(%rip),%rdi
movsbl %al,%esi
call   1040 <printf@plt>
jmp    11c0 <main+0x60>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x8(%rsi),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c6 <main+0x76>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <feof@plt>
xor    %r14d,%r14d
test   %eax,%eax
jne    11cc <main+0x7c>
mov    0x2e52(%rip),%rbp
lea    0xe65(%rip),%r15
jmp    11ac <main+0x5c>
nop
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11cc <main+0x7c>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    0x0(%rbp),%eax
je     11a0 <main+0x50>
movsbl %al,%esi
mov    %r15,%rdi
call   1040 <printf@plt>
jmp    11a0 <main+0x50>
mov    $0x2,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
@.str.1 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x i8]
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strcpy(i8* %10, i8* %13)
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %8
%17 = load i32*, i32** %8
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %20
19: ; preds = %2
store i32 2, i32* %3
br label %39
20: ; preds = %2
%21 = call i8* @malloc(i32 4)
store i8* %21, i8** %7
br label %22
22: ; preds = %37, %20
%23 = load i32*, i32** %8
%24 = call i32 @feof(i32* %23)
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
br i1 %26, label %27, label %38
27: ; preds = %22
%28 = load i32*, i32** %8
%29 = call i32 @fgetc(i32* %28)
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = load i32, i32* @EOF
%32 = icmp ne i32 %30, %31
br i1 %32, label %33, label %37
33: ; preds = %27
%34 = load i32, i32* %9
%35 = trunc i32 %34 to i8
%36 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %35)
br label %37
37: ; preds = %33, %27
br label %22
38: ; preds = %22
store i32 0, i32* %3
br label %39
39: ; preds = %38, %19
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
@.str.1 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = call i32 @strcpy(i8* %4, i8* %6)
%8 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %23, label %10
10: ; preds = %2
%11 = call i32 @feof(i32* %8)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10, %20
%14 = call i32 @fgetc(i32* %8)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = trunc i32 %14 to i8
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %18)
br label %20
20: ; preds = %17, %13
%21 = call i32 @feof(i32* %8)
%22 = icmp eq i32 %21, 0
br i1 %22, label %13, label %23
23: ; preds = %20, %10, %2
%24 = phi i32 [ 2, %2 ], [ 0, %10 ], [ 0, %20 ]
ret i32 %24
}