#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 /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
void imprimir(FILE *file) {
  if (file == NULL)
    fprintf(stderr, "Erro ao abrir o arquivo.txt.");
  char *line = malloc(80);
  while (fgets(line, 80, file) != NULL)
    printf("%s", line);
}


x86 assembly (clang, -O0):
<imprimir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    116c <imprimir+0x2c>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x50,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x50,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11ab <imprimir+0x6b>
mov    -0x10(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
jmp    117a <imprimir+0x3a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imprimir>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %rdi,%rdi
jne    1162 <imprimir+0x22>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x50,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11b0 <imprimir+0x70>
lea    0xe92(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    1190 <imprimir+0x50>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Erro ao abrir o arquivo.txt.\00"
@.str.1 = [3 x i8] c"%s\00"
define void @imprimir(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %6, %1
%10 = call i8* @malloc(i32 80)
store i8* %10, i8** %3
br label %11
11: ; preds = %16, %9
%12 = load i8*, i8** %3
%13 = load i32*, i32** %2
%14 = call i32* @fgets(i8* %12, i32 80, i32* %13)
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %11
19: ; preds = %11
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Erro ao abrir o arquivo.txt.\00"
@.str.1 = [3 x i8] c"%s\00"
define void @imprimir(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %3, %1
%7 = tail call dereferenceable_or_null(80) i8* @malloc(i32 80)
%8 = tail call i32* @fgets(i8* %7, i32 80, i32* %0)
%9 = icmp eq i32* %8, null
br i1 %9, label %14, label %10
10: ; preds = %6, %10
%11 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%12 = tail call i32* @fgets(i8* %7, i32 80, i32* %0)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %10
14: ; preds = %10, %6
ret void
}