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

/* Variables and functions */
int busca(int, int, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
void main(void) {
  int elementoProcurado = 9;
  int tamanhoDoVetor = 5;
  int vetor[] = {10, 34, 2, 9, 45};
  int resultado = busca(elementoProcurado, tamanhoDoVetor, vetor);
  if (resultado == -1) {
    printf("Elemento não encontrado!");
    exit(1);
  }
  printf("O indice onde %d esta eh o %d\n", elementoProcurado, resultado);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x9,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeae(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x20(%rbp),%rdx
call   1040 <busca@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1199 <main+0x69>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    0xed6(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xebb(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdx
mov    $0x9,%edi
mov    $0x5,%esi
call   1040 <busca@plt>
cmp    $0xffffffff,%eax
je     117a <main+0x4a>
lea    0xec7(%rip),%rdi
mov    $0x9,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x18,%rsp
ret
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@__const.main.vetor = [5 x i32] [i32 10, i32 34, i32 2, i32 9, i32 45]
@.str = [26 x i8] c"Elemento n\C3\A3o encontrado!\00"
@.str.1 = [31 x i8] c"O indice onde %d esta eh o %d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i32]
%4 = alloca i32
store i32 9, i32* %1
store i32 5, i32* %2
%5 = bitcast [5 x i32]* %3 to i8*
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%9 = call i32 @busca(i32 %6, i32 %7, i32* %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = load i32, i32* %1
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
ret void
}

LLVM IR (-O2):
@__const.main.vetor = [5 x i32] [i32 10, i32 34, i32 2, i32 9, i32 45]
@.str = [26 x i8] c"Elemento n\C3\A3o encontrado!\00"
@.str.1 = [31 x i8] c"O indice onde %d esta eh o %d\0A\00"
define void @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%4 = call i32 @busca(i32 9, i32 5, i32* %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 9, i32 %4)
ret void
}