#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_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ geraCodigo(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                              int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(void) {
  FILE *fEntrada;
  FILE *fConsulta;
  FILE *fAltera;
  fEntrada = fopen("entrada", "r");
  fConsulta = fopen("consulta", "w");
  fAltera = fopen("altera", "w");
  if (!fEntrada || !fConsulta || !fAltera) {
    fprintf(stderr, "erro ao abrir!\n");
    exit(EXIT_FAILURE);
  }
  geraCodigo(fEntrada, fConsulta, fAltera);
  fclose(fAltera);
  fclose(fConsulta);
  fclose(fEntrada);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe8d(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe81(%rip),%rdi
lea    0xe78(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11c5 <main+0x75>
cmpq   $0x0,-0x18(%rbp)
je     11c5 <main+0x75>
cmpq   $0x0,-0x20(%rbp)
jne    11e8 <main+0x98>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <geraCodigo@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xea4(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xe98(%rip),%rdi
lea    0xe9a(%rip),%rbx
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
lea    0xe8a(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fopen@plt>
test   %r14,%r14
je     11d3 <main+0x83>
test   %r15,%r15
je     11d3 <main+0x83>
mov    %rax,%rbx
test   %rax,%rax
je     11d3 <main+0x83>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <geraCodigo@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
lea    0xe39(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"entrada\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"consulta\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [7 x i8] c"altera\00"
@stderr = global i32 0
@.str.5 = [16 x i8] c"erro ao abrir!\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 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 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %6, i32** %3
%7 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %2
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %16
10: ; preds = %0
%11 = load i32*, i32** %3
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32*, i32** %4
%15 = icmp ne i32* %14, null
br i1 %15, label %21, label %16
16: ; preds = %13, %10, %0
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %13
%22 = load i32*, i32** %2
%23 = load i32*, i32** %3
%24 = load i32*, i32** %4
%25 = call i32 @geraCodigo(i32* %22, i32* %23, i32* %24)
%26 = load i32*, i32** %4
%27 = call i32 @fclose(i32* %26)
%28 = load i32*, i32** %3
%29 = call i32 @fclose(i32* %28)
%30 = load i32*, i32** %2
%31 = call i32 @fclose(i32* %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"entrada\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"consulta\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [7 x i8] c"altera\00"
@stderr = global i32 0
@.str.5 = [16 x i8] c"erro ao abrir!\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 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 i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%4 = icmp ne i32* %1, null
%5 = icmp ne i32* %2, null
%6 = and i1 %4, %5
%7 = icmp ne i32* %3, null
%8 = and i1 %6, %7
br i1 %8, label %14, label %9
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = tail call i32 @geraCodigo(i32* %1, i32* %2, i32* %3)
%16 = tail call i32 @fclose(i32* %3)
%17 = tail call i32 @fclose(i32* %2)
%18 = tail call i32 @fclose(i32* %1)
ret i32 0
}