#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*/ clock_t;

/* Variables and functions */
int /*<<< orphan*/ array_creator(int, int *);
int /*<<< orphan*/ busca_binaria(int, int, int *);
int /*<<< orphan*/ busca_sequencial(int, int *, int);
int /*<<< orphan*/ clock();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ tempo(int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, const char *argv[]) {
  int v[5000], x, n;
  clock_t ti1, tf1, ti2, tf2;
  printf("digite o tamanho do vetor:\n");
  scanf("%d", &n);
  array_creator(n, v);
  printf("digite o termo a ser procurado:\n");
  scanf("%d", &x);
  ti1 = clock();
  busca_binaria(x, n, v);
  tf1 = clock();
  printf("Tempo da busca binária: ");
  tempo(ti1, tf1);
  ti2 = clock();
  busca_sequencial(n, v, x);
  tf2 = clock();
  printf("Tempo da busca sequencial: ");
  tempo(ti2, tf2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe70(%rip),%rdi
call   1050 <printf@plt>
lea    0xe80(%rip),%rdi
lea    -0x4e38(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x4e38(%rbp),%edi
lea    -0x4e30(%rbp),%rsi
call   1090 <array_creator@plt>
lea    0xe5e(%rip),%rdi
call   1050 <printf@plt>
lea    0xe4f(%rip),%rdi
lea    -0x4e34(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %eax,-0x4e3c(%rbp)
mov    -0x4e34(%rbp),%edi
mov    -0x4e38(%rbp),%esi
lea    -0x4e30(%rbp),%rdx
call   1030 <busca_binaria@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %eax,-0x4e40(%rbp)
lea    0xe2e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4e3c(%rbp),%edi
mov    -0x4e40(%rbp),%esi
call   1060 <tempo@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %eax,-0x4e44(%rbp)
mov    -0x4e38(%rbp),%edi
lea    -0x4e30(%rbp),%rsi
mov    -0x4e34(%rbp),%edx
call   1080 <busca_sequencial@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %eax,-0x4e48(%rbp)
lea    0xdf9(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4e44(%rbp),%edi
mov    -0x4e48(%rbp),%esi
call   1060 <tempo@plt>
xor    %eax,%eax
add    $0x4e50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x4e30,%rsp
lea    0xea7(%rip),%rdi
call   1040 <puts@plt>
lea    0xe62(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%r14
mov    %r14,%rsi
call   10a0 <array_creator@plt>
lea    0xe91(%rip),%rdi
call   1040 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    %r14,%rdx
call   1030 <busca_binaria@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %eax,%ebp
lea    0xe05(%rip),%rdi
call   1060 <printf@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1070 <tempo@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%edx
mov    %r14,%rsi
call   1090 <busca_sequencial@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %eax,%ebp
lea    0xde8(%rip),%rdi
call   1060 <printf@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1070 <tempo@plt>
xor    %eax,%eax
add    $0x4e30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"digite o tamanho do vetor:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"digite o termo a ser procurado:\0A\00"
@.str.3 = [26 x i8] c"Tempo da busca bin\C3\A1ria: \00"
@.str.4 = [28 x i8] c"Tempo da busca sequencial: \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5000 x i32]
%7 = alloca i32
%8 = alloca i32
%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 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%15 = load i32, i32* %8
%16 = getelementptr inbounds [5000 x i32], [5000 x i32]* %6, i64 0, i64 0
%17 = call i32 @array_creator(i32 %15, i32* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%20 = call i32 (...) @clock()
store i32 %20, i32* %9
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = getelementptr inbounds [5000 x i32], [5000 x i32]* %6, i64 0, i64 0
%24 = call i32 @busca_binaria(i32 %21, i32 %22, i32* %23)
%25 = call i32 (...) @clock()
store i32 %25, i32* %10
%26 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32, i32* %9
%28 = load i32, i32* %10
%29 = call i32 @tempo(i32 %27, i32 %28)
%30 = call i32 (...) @clock()
store i32 %30, i32* %11
%31 = load i32, i32* %8
%32 = getelementptr inbounds [5000 x i32], [5000 x i32]* %6, i64 0, i64 0
%33 = load i32, i32* %7
%34 = call i32 @busca_sequencial(i32 %31, i32* %32, i32 %33)
%35 = call i32 (...) @clock()
store i32 %35, i32* %12
%36 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%37 = load i32, i32* %11
%38 = load i32, i32* %12
%39 = call i32 @tempo(i32 %37, i32 %38)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [26 x i8] c"Tempo da busca bin\C3\A1ria: \00"
@.str.4 = [28 x i8] c"Tempo da busca sequencial: \00"
@str = [27 x i8] c"digite o tamanho do vetor:\00"
@str.5 = [32 x i8] c"digite o termo a ser procurado:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5000 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [5000 x i32]* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%11 = load i32, i32* %5
%12 = getelementptr inbounds [5000 x i32], [5000 x i32]* %3, i64 0, i64 0
%13 = call i32 @array_creator(i32 %11, i32* %12)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%16 = call i32 (...) @clock()
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = call i32 @busca_binaria(i32 %17, i32 %18, i32* %12)
%20 = call i32 (...) @clock()
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @tempo(i32 %16, i32 %20)
%23 = call i32 (...) @clock()
%24 = load i32, i32* %5
%25 = load i32, i32* %4
%26 = call i32 @busca_sequencial(i32 %24, i32* %12, i32 %25)
%27 = call i32 (...) @clock()
%28 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 @tempo(i32 %23, i32 %27)
ret i32 0
}