#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*/ printf(char *, ...);
int main(void) {
  int elementoProcurado = 9;
  int tamanhoDoVetor = 0;
  int vetor[] = {};
  int resultado = busca(elementoProcurado, tamanhoDoVetor, vetor);
  if (resultado == -1) {
    printf("Elemento não encontrado!");
    return 1;
  }
  printf("O indice de %d no vetor eh %d\n", elementoProcurado, resultado);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x9,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x10(%rbp),%rdx
call   1040 <busca@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1173 <main+0x53>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    118e <main+0x6e>
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
lea    0xc(%rsp),%rdx
mov    $0x9,%edi
xor    %esi,%esi
call   1040 <busca@plt>
cmp    $0xffffffff,%eax
je     1154 <main+0x34>
lea    0xed6(%rip),%rdi
mov    $0x9,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1167 <main+0x47>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [26 x i8] c"Elemento n\C3\A3o encontrado!\00"
@.str.1 = [31 x i8] c"O indice de %d no vetor eh %d\0A\00"
define i32 @main() {
%1 = alloca [0 x i32]
%2 = bitcast [0 x i32]* %1 to i8*
%3 = getelementptr inbounds [0 x i32], [0 x i32]* %1, i64 0, i64 0
%4 = call i32 @busca(i32 9, i32 0, i32* %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %10
8: ; preds = %0
%9 = 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)
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ 1, %6 ], [ 0, %8 ]
ret i32 %11
}