#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(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 1;
  buffer = malloc(sizeof(int));
  while (!feof(fp)) {
    int c = fgetc(fp);
    if (c != EOF)
      printf("%c", (char)c);
  }
  fclose(fp);
  free(buffer);
  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   1040 <strcpy@plt>
lea    -0x30(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11d2 <main+0x52>
movl   $0x1,-0x4(%rbp)
jmp    124c <main+0xcc>
mov    $0x4,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11fe <main+0x7e>
jmp    1233 <main+0xb3>
mov    -0x40(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    0x2dd4(%rip),%rcx
cmp    (%rcx),%eax
je     122e <main+0xae>
mov    -0x44(%rbp),%eax
lea    0xddc(%rip),%rdi
movsbl %al,%esi
call   1060 <printf@plt>
jmp    11e0 <main+0x60>
mov    -0x40(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x8(%rsi),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     11de <main+0x5e>
mov    %rax,%rbx
mov    $0x4,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     11ef <main+0x6f>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    11e3 <main+0x63>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2df2(%rip),%r12
lea    0xe05(%rip),%r15
jmp    120c <main+0x8c>
nop
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    11ca <main+0x4a>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    (%r12),%eax
je     1200 <main+0x80>
movsbl %al,%esi
mov    %r15,%rdi
call   1060 <printf@plt>
jmp    1200 <main+0x80>

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 1, i32* %3
br label %43
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
%39 = load i32*, i32** %8
%40 = call i32 @fclose(i32* %39)
%41 = load i8*, i8** %7
%42 = call i32 @free(i8* %41)
store i32 0, i32* %3
br label %43
43: ; preds = %38, %19
%44 = load i32, i32* %3
ret i32 %44
}

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 %27, label %10
10: ; preds = %2
%11 = call dereferenceable_or_null(4) i8* @malloc(i32 4)
%12 = call i32 @feof(i32* %8)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %10, %21
%15 = call i32 @fgetc(i32* %8)
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = trunc i32 %15 to i8
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %19)
br label %21
21: ; preds = %18, %14
%22 = call i32 @feof(i32* %8)
%23 = icmp eq i32 %22, 0
br i1 %23, label %14, label %24
24: ; preds = %21, %10
%25 = call i32 @fclose(i32* %8)
%26 = call i32 @free(i8* %11)
br label %27
27: ; preds = %2, %24
%28 = phi i32 [ 0, %24 ], [ 1, %2 ]
ret i32 %28
}