#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*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int main() {
  FILE *ponteiro_arquivo_de_entrada;
  FILE *ponteiro_arquivo_de_saida;
  char modo[] = "r";
  char arquivo_de_entrada[] = "entrada.txt";
  char arquivo_de_saida[] = "saida.txt";
  ponteiro_arquivo_de_entrada = fopen(arquivo_de_entrada, modo);
  if (ponteiro_arquivo_de_entrada == NULL) {
    fprintf(stderr, "Impossivel abrir arquivo de entrada %s\n",
            arquivo_de_entrada);
    exit(1);
  }
  ponteiro_arquivo_de_saida = fopen(arquivo_de_saida, "w");
  if (ponteiro_arquivo_de_saida == NULL) {
    fprintf(stderr, "Impossivel abrir o arquivo de saida %s\n",
            arquivo_de_saida);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xec1(%rip),%ax
mov    %ax,-0x12(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x1e(%rbp)
mov    0xeb6(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xead(%rip),%ax
mov    %ax,-0x20(%rbp)
lea    -0x1e(%rbp),%rdi
lea    -0x12(%rbp),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11ac <main+0x7c>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    -0x1e(%rbp),%rdx
lea    0xe7b(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    -0x28(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ee <main+0xbe>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rdx
lea    0xe63(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movw   $0x72,0x6(%rsp)
movabs $0x2e61646172746e65,%rax
64 61 2e
mov    %rax,0x18(%rsp)
movl   $0x747874,0x20(%rsp)
movabs $0x78742e6164696173,%rax
2e 74 78
mov    %rax,0x8(%rsp)
movw   $0x74,0x10(%rsp)
lea    0x18(%rsp),%rdi
lea    0x6(%rsp),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     1199 <main+0x69>
lea    0xebb(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1040 <fopen@plt>
test   %rax,%rax
je     11b0 <main+0x80>
xor    %eax,%eax
add    $0x28,%rsp
ret
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
lea    0x18(%rsp),%rdx
jmp    11c5 <main+0x95>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@__const.main.modo = [2 x i8] c"r\00"
@__const.main.arquivo_de_entrada = [12 x i8] c"entrada.txt\00"
@__const.main.arquivo_de_saida = [10 x i8] c"saida.txt\00"
@stderr = global i32 0
@.str = [40 x i8] c"Impossivel abrir arquivo de entrada %s\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [40 x i8] c"Impossivel abrir o arquivo de saida %s\0A\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca [2 x i8]
%4 = alloca [12 x i8]
%5 = alloca [10 x i8]
%6 = bitcast [2 x i8]* %3 to i8*
%7 = bitcast [12 x i8]* %4 to i8*
%8 = bitcast [10 x i8]* %5 to i8*
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%11 = call i32* @fopen(i8* %9, i8* %10)
store i32* %11, i32** %1
%12 = load i32*, i32** %1
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %0
%15 = load i32, i32* @stderr
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %0
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %2
%22 = load i32*, i32** %2
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
@__const.main.arquivo_de_entrada = [12 x i8] c"entrada.txt\00"
@__const.main.arquivo_de_saida = [10 x i8] c"saida.txt\00"
@stderr = global i32 0
@.str = [40 x i8] c"Impossivel abrir arquivo de entrada %s\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [40 x i8] c"Impossivel abrir o arquivo de saida %s\0A\00"
define i32 @main() {
%1 = alloca i16
%2 = alloca [12 x i8]
%3 = alloca [10 x i8]
%4 = bitcast i16* %1 to i8*
store i16 114, i16* %1
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = call i32* @fopen(i8* %5, i8* %4)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %5)
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
%14 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %13
ret i32 0
}