#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*/ *fopen(char *, char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ topSubmissoes(int /*<<< orphan*/ *);
int main() {
  FILE *f;
  f = fopen("submissoes.txt", "r");
  if (topSubmissoes(f) == 0) {
    puts("Erro ao executar funcao.\n");
    fclose(f);
    return 1;
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <topSubmissoes@plt>
cmp    $0x0,%rax
jne    119a <main+0x5a>
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    11aa <main+0x6a>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
lea    0xebe(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <topSubmissoes@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    1179 <main+0x39>
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"submissoes.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [26 x i8] c"Erro ao executar funcao.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 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
%4 = load i32*, i32** %2
%5 = call i64 @topSubmissoes(i32* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32*, i32** %2
%10 = call i32 @fclose(i32* %9)
store i32 1, i32* %1
br label %14
11: ; preds = %0
%12 = load i32*, i32** %2
%13 = call i32 @fclose(i32* %12)
store i32 0, i32* %1
br label %14
14: ; preds = %11, %7
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@.str = [15 x i8] c"submissoes.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [26 x i8] c"Erro ao executar funcao.\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 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 i64 @topSubmissoes(i32* %1)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %6
6: ; preds = %0, %4
%7 = phi i32 [ 1, %4 ], [ 0, %0 ]
%8 = tail call i32 @fclose(i32* %1)
ret i32 %7
}