#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *archivo;
  if (argc == 2) {
    archivo = fopen(argv[1], "r");
  } else {
    archivo = fopen("p26.c", "r");
  }
  char c;
  printf("Contenido del Archivo %s:\n", "p26.c");
  while ((c = fgetc(archivo)) != EOF) {
    printf("%c", c);
  }
  printf("\nFin del Contenido.\n");
  fclose(archivo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    117d <main+0x3d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe91(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
jmp    1194 <main+0x54>
lea    0xe7e(%rip),%rdi
lea    0xe75(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe6d(%rip),%rdi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2e29(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11e1 <main+0xa1>
movsbl -0x19(%rbp),%esi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a9 <main+0x69>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    116f <main+0xf>
mov    0x8(%rsi),%rdi
jmp    1176 <main+0x16>
lea    0xe8c(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xe7c(%rip),%rdi
lea    0xe6f(%rip),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
mov    0x2e3f(%rip),%r14
cmp    (%r14),%al
je     11c5 <main+0x65>
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    (%r14),%al
jne    11b0 <main+0x50>
lea    0xe57(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"p26.c\00"
@.str.2 = [27 x i8] c"Contenido del Archivo %s:\0A\00"
@EOF = global i8 0
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [21 x i8] c"\0AFin del Contenido.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
br label %17
15: ; preds = %2
%16 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
br label %17
17: ; preds = %15, %10
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %26, %17
%20 = load i32*, i32** %6
%21 = call signext i8 @fgetc(i32* %20)
store i8 %21, i8* %7
%22 = sext i8 %21 to i32
%23 = load i8, i8* @EOF
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %22, %24
br i1 %25, label %26, label %30
26: ; preds = %19
%27 = load i8, i8* %7
%28 = sext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %19
30: ; preds = %19
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32*, i32** %6
%33 = call i32 @fclose(i32* %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"p26.c\00"
@.str.2 = [27 x i8] c"Contenido del Archivo %s:\0A\00"
@EOF = global i8 0
@str = [20 x i8] c"\0AFin del Contenido.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %2, %4
%8 = phi i8* [ %6, %4 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %2 ]
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call signext i8 @fgetc(i32* %9)
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %11, %12
br i1 %13, label %21, label %14
14: ; preds = %7, %14
%15 = phi i8 [ %18, %14 ], [ %11, %7 ]
%16 = sext i8 %15 to i32
%17 = tail call i32 @putchar(i32 %16)
%18 = tail call signext i8 @fgetc(i32* %9)
%19 = load i8, i8* @EOF
%20 = icmp eq i8 %18, %19
br i1 %20, label %21, label %14
21: ; preds = %14, %7
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 @fclose(i32* %9)
ret i32 0
}