#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 /*<<< orphan*/ printf(char *, double);
int buscaSequencial(int *vetor, int tam, int valor) {
  double comparacoes = 0;
  int i;
  for (i = 0; i < tam; i++) {
    comparacoes++;
    if (valor == vetor[i]) {
      printf("Tamanho: %d\n", tam);
      printf("Quant. de Comparacoes: %.0f\n", comparacoes);
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<buscaSequencial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a3 <buscaSequencial+0x93>
movsd  0xebb(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x24(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    1190 <buscaSequencial+0x80>
cvtsi2sdl -0x14(%rbp),%xmm0
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11aa <buscaSequencial+0x9a>
jmp    1195 <buscaSequencial+0x85>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1131 <buscaSequencial+0x21>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buscaSequencial>:
push   %rbx
sub    $0x10,%rsp
mov    $0xffffffff,%eax
test   %esi,%esi
jle    1171 <buscaSequencial+0x61>
mov    %esi,%ecx
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
movsd  0xed2(%rip),%xmm0
xchg   %ax,%ax
addsd  %xmm0,%xmm1
cmp    %edx,(%rdi,%rbx,4)
je     1144 <buscaSequencial+0x34>
add    $0x1,%rbx
cmp    %rbx,%rcx
jne    1130 <buscaSequencial+0x20>
jmp    1171 <buscaSequencial+0x61>
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
lea    0xeb6(%rip),%rdi
movsd  %xmm1,0x8(%rsp)
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Tamanho: %d\0A\00"
@.str.1 = [29 x i8] c"Quant. de Comparacoes: %.0f\0A\00"
define i32 @buscaSequencial(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store double 0.000000e+00, double* %8
store i32 0, i32* %9
br label %10
10: ; preds = %32, %3
%11 = load i32, i32* %9
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %35
14: ; preds = %10
%15 = load double, double* %8
%16 = fadd double %15, 1.000000e+00
store double %16, double* %8
%17 = load i32, i32* %7
%18 = load i32*, i32** %5
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load i32, i32* %21
%23 = icmp eq i32 %17, %22
br i1 %23, label %24, label %31
24: ; preds = %14
%25 = load i32, i32* %6
%26 = sitofp i32 %25 to double
%27 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %26)
%28 = load double, double* %8
%29 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double %28)
%30 = load i32, i32* %9
store i32 %30, i32* %4
br label %36
31: ; preds = %14
br label %32
32: ; preds = %31
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %10
35: ; preds = %10
store i32 -1, i32* %4
br label %36
36: ; preds = %35, %24
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
@.str = [13 x i8] c"Tamanho: %d\0A\00"
@.str.1 = [29 x i8] c"Quant. de Comparacoes: %.0f\0A\00"
define i32 @buscaSequencial(i32* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %22
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %19
%8 = phi i64 [ 0, %5 ], [ %20, %19 ]
%9 = phi double [ 0.000000e+00, %5 ], [ %10, %19 ]
%10 = fadd double %9, 1.000000e+00
%11 = getelementptr inbounds i32, i32* %0, i64 %8
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, %2
br i1 %13, label %14, label %19
14: ; preds = %7
%15 = trunc i64 %8 to i32
%16 = sitofp i32 %1 to double
%17 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %16)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double %10)
br label %22
19: ; preds = %7
%20 = add nuw nsw i64 %8, 1
%21 = icmp eq i64 %20, %6
br i1 %21, label %22, label %7
22: ; preds = %19, %3, %14
%23 = phi i32 [ %15, %14 ], [ -1, %3 ], [ -1, %19 ]
ret i32 %23
}