#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*/ printf(char *, ...);
void readFile(FILE *archivo) {
  char c;
  if (archivo != NULL) {
    c = fgetc(archivo);
    while (c != EOF) {
      printf("%c", c);
      c = fgetc(archivo);
    }
  } else {
    printf("El archivo no existe, se creara!\n");
  }
  fclose(archivo);
}


x86 assembly (clang, -O0):
<readFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1191 <readFile+0x61>
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
mov    0x2e8a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     118c <readFile+0x5c>
movsbl -0x9(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x9(%rbp)
jmp    1153 <readFile+0x23>
jmp    119f <readFile+0x6f>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readFile>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
test   %rdi,%rdi
je     1177 <readFile+0x37>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    0x2e8d(%rip),%r14
cmp    (%r14),%al
je     1183 <readFile+0x43>
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    (%r14),%al
jne    1160 <readFile+0x20>
jmp    1183 <readFile+0x43>
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fclose@plt>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [3 x i8] c"%c\00"
@.str.1 = [34 x i8] c"El archivo no existe, se creara!\0A\00"
define void @readFile(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = icmp ne i32* %4, null
br i1 %5, label %6, label %22
6: ; preds = %1
%7 = load i32*, i32** %2
%8 = call signext i8 @fgetc(i32* %7)
store i8 %8, i8* %3
br label %9
9: ; preds = %15, %6
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = load i8, i8* @EOF
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %11, %13
br i1 %14, label %15, label %21
15: ; preds = %9
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32*, i32** %2
%20 = call signext i8 @fgetc(i32* %19)
store i8 %20, i8* %3
br label %9
21: ; preds = %9
br label %24
22: ; preds = %1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %21
%25 = load i32*, i32** %2
%26 = call i32 @fclose(i32* %25)
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
@str = [33 x i8] c"El archivo no existe, se creara!\00"
define void @readFile(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = tail call signext i8 @fgetc(i32* %0)
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %16, label %7
7: ; preds = %3, %7
%8 = phi i8 [ %11, %7 ], [ %4, %3 ]
%9 = sext i8 %8 to i32
%10 = tail call i32 @putchar(i32 %9)
%11 = tail call signext i8 @fgetc(i32* %0)
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %11, %12
br i1 %13, label %16, label %7
14: ; preds = %1
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %7, %3, %14
%17 = tail call i32 @fclose(i32* %0)
ret void
}