#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 *, char);
int imprimir(void) {
  char ch;
  FILE *dados;
  dados = fopen("errors.err", "r");
  while ((ch = fgetc(dados)) != EOF)
    printf("%c", ch);
  fclose(dados);
  return 0;
}


x86 assembly (clang, -O0):
<imprimir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x1(%rbp)
movsbl %al,%eax
mov    0x2e73(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1195 <imprimir+0x55>
lea    0xe84(%rip),%rdi
movsbl -0x1(%rbp),%esi
call   1040 <printf@plt>
jmp    115f <imprimir+0x1f>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imprimir>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fgetc@plt>
mov    0x2e7e(%rip),%r15
cmp    (%r15),%al
je     1198 <imprimir+0x58>
lea    0xe95(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    (%r15),%al
jne    1180 <imprimir+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"errors.err\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [3 x i8] c"%c\00"
define i32 @imprimir() {
%1 = alloca i8
%2 = alloca i32*
%3 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
br label %4
4: ; preds = %11, %0
%5 = load i32*, i32** %2
%6 = call signext i8 @fgetc(i32* %5)
store i8 %6, i8* %1
%7 = sext i8 %6 to i32
%8 = load i8, i8* @EOF
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %7, %9
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = load i8, i8* %1
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %12)
br label %4
14: ; preds = %4
%15 = load i32*, i32** %2
%16 = call i32 @fclose(i32* %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"errors.err\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [3 x i8] c"%c\00"
define i32 @imprimir() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call signext i8 @fgetc(i32* %1)
%3 = load i8, i8* @EOF
%4 = icmp eq i8 %2, %3
br i1 %4, label %11, label %5
5: ; preds = %0, %5
%6 = phi i8 [ %8, %5 ], [ %2, %0 ]
%7 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %6)
%8 = tail call signext i8 @fgetc(i32* %1)
%9 = load i8, i8* @EOF
%10 = icmp eq i8 %8, %9
br i1 %10, label %11, label %5
11: ; preds = %5, %0
%12 = tail call i32 @fclose(i32* %1)
ret i32 0
}