#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
int main() {
  FILE *tx;
  char c;
  char string[101];
  tx = fopen("texto.txt", "r");
  if (!tx) {
    printf("\nErro na abertura do arquivo!!!\n\n");
    system("pause");
    return (0);
  }
  printf("\tTexto presente no arquivo texto.txt:\n\n");
  while (!feof(tx)) {
    c = fgetc(tx);
    printf("%c", c);
  }
  printf("\n\n");
  fclose(tx);
  system("pause");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ba <main+0x5a>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe85(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    1233 <main+0xd3>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11e6 <main+0x86>
jmp    1209 <main+0xa9>
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11c8 <main+0x68>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe07(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe88(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     11d4 <main+0x64>
mov    %rax,%rbx
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    11be <main+0x4e>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    11a0 <main+0x30>
lea    0xe6c(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    11e0 <main+0x70>
lea    0xe37(%rip),%rdi
call   1040 <puts@plt>
lea    0xe25(%rip),%rdi
call   1060 <system@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"texto.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [34 x i8] c"\0AErro na abertura do arquivo!!!\0A\0A\00"
@.str.3 = [6 x i8] c"pause\00"
@.str.4 = [40 x i8] c"\09Texto presente no arquivo texto.txt:\0A\0A\00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8
%4 = alloca [101 x i8]
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = icmp ne i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %29
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
br label %13
13: ; preds = %18, %11
%14 = load i32*, i32** %2
%15 = call i32 @feof(i32* %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = load i32*, i32** %2
%20 = call signext i8 @fgetc(i32* %19)
store i8 %20, i8* %3
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %22)
br label %13
24: ; preds = %13
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%26 = load i32*, i32** %2
%27 = call i32 @fclose(i32* %26)
%28 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %29
29: ; preds = %24, %8
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [10 x i8] c"texto.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [6 x i8] c"pause\00"
@str = [33 x i8] c"\0AErro na abertura do arquivo!!!\0A\00"
@str.7 = [39 x i8] c"\09Texto presente no arquivo texto.txt:\0A\00"
@str.8 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %18
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.7, i64 0, i64 0))
%7 = tail call i32 @feof(i32* %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %5, %9
%10 = tail call signext i8 @fgetc(i32* %1)
%11 = sext i8 %10 to i32
%12 = tail call i32 @putchar(i32 %11)
%13 = tail call i32 @feof(i32* %1)
%14 = icmp eq i32 %13, 0
br i1 %14, label %9, label %15
15: ; preds = %9, %5
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.8, i64 0, i64 0))
%17 = tail call i32 @fclose(i32* %1)
br label %18
18: ; preds = %15, %3
%19 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}