#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*/ executar_benchmark(int *, int, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ ler_arquivo_entrada(int /*<<< orphan*/ *, int **, int *);
int /*<<< orphan*/ ler_parametros(int, char **, char *, char *, int *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  int semente;
  char nome_entrada[100];
  char nome_saida[100];
  int n;
  int *tamanho_array;
  FILE *arquivo_entrada, *arquivo_saida;
  if (!ler_parametros(argc, argv, nome_entrada, nome_saida, &semente)) {
    return -1;
  }
  printf("Lendo %s.\n", nome_entrada);
  arquivo_entrada = fopen(nome_entrada, "r");
  arquivo_saida = fopen(nome_saida, "w");
  ler_arquivo_entrada(arquivo_entrada, &tamanho_array, &n);
  printf("Executando benchmark e imprimindo saida em %s.\n", nome_saida);
  executar_benchmark(tamanho_array, n, arquivo_saida, semente);
  fclose(arquivo_entrada);
  fclose(arquivo_saida);
  free(tamanho_array);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    -0xf0(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1050 <ler_parametros@plt>
cmp    $0x0,%eax
jne    11b9 <main+0x49>
movl   $0xffffffff,-0x4(%rbp)
jmp    126e <main+0xfe>
lea    -0x80(%rbp),%rsi
lea    0xe3c(%rip),%rdi
call   1070 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x108(%rbp)
lea    -0xf0(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x110(%rbp)
mov    -0x108(%rbp),%rdi
lea    -0x100(%rbp),%rsi
lea    -0xf4(%rbp),%rdx
call   1040 <ler_arquivo_entrada@plt>
lea    -0xf0(%rbp),%rsi
lea    0xded(%rip),%rdi
call   1070 <printf@plt>
mov    -0x100(%rbp),%rdi
mov    -0xf4(%rbp),%esi
mov    -0x110(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1080 <executar_benchmark@plt>
mov    -0x108(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x110(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x100(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xf0,%rsp
lea    0x80(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x4(%rsp),%r8
call   1050 <ler_parametros@plt>
test   %eax,%eax
je     122c <main+0xbc>
lea    0xe5e(%rip),%rdi
lea    0x80(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <printf@plt>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
mov    %rax,%r15
lea    0xe42(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
mov    %r15,%rdi
call   1040 <ler_arquivo_entrada@plt>
lea    0xe1d(%rip),%rdi
mov    %r14,%rsi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
mov    (%rsp),%esi
mov    0x4(%rsp),%ecx
mov    %rbx,%rdx
call   1080 <executar_benchmark@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    1231 <main+0xc1>
mov    $0xffffffff,%eax
add    $0xf0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Lendo %s.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [48 x i8] c"Executando benchmark e imprimindo saida em %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%17 = call i32 @ler_parametros(i32 %13, i8** %14, i8* %15, i8* %16, i32* %6)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %2
store i32 -1, i32* %3
br label %42
20: ; preds = %2
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %11
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %26, i32** %12
%27 = load i32*, i32** %11
%28 = call i32 @ler_arquivo_entrada(i32* %27, i32** %10, i32* %9)
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%30 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = load i32*, i32** %10
%32 = load i32, i32* %9
%33 = load i32*, i32** %12
%34 = load i32, i32* %6
%35 = call i32 @executar_benchmark(i32* %31, i32 %32, i32* %33, i32 %34)
%36 = load i32*, i32** %11
%37 = call i32 @fclose(i32* %36)
%38 = load i32*, i32** %12
%39 = call i32 @fclose(i32* %38)
%40 = load i32*, i32** %10
%41 = call i32 @free(i32* %40)
store i32 0, i32* %3
br label %42
42: ; preds = %20, %19
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [11 x i8] c"Lendo %s.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [48 x i8] c"Executando benchmark e imprimindo saida em %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = alloca i32
%7 = alloca i32*
%8 = bitcast i32* %3 to i8*
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32** %7 to i8*
%13 = call i32 @ler_parametros(i32 %0, i8** %1, i8* %9, i8* %10, i32* %3)
%14 = icmp eq i32 %13, 0
br i1 %14, label %29, label %15
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %9)
%17 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @ler_arquivo_entrada(i32* %17, i32** %7, i32* %6)
%20 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%21 = load i32*, i32** %7
%22 = load i32, i32* %6
%23 = load i32, i32* %3
%24 = call i32 @executar_benchmark(i32* %21, i32 %22, i32* %18, i32 %23)
%25 = call i32 @fclose(i32* %17)
%26 = call i32 @fclose(i32* %18)
%27 = load i32*, i32** %7
%28 = call i32 @free(i32* %27)
br label %29
29: ; preds = %2, %15
%30 = phi i32 [ 0, %15 ], [ -1, %2 ]
ret i32 %30
}