#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 *, ...);
void pesquisa(int vet[], int num) {
  bool achou = false;
  int i, p;
  for (i = 0; i < 100 && achou == false; i++) {
    if (num == vet[i]) {
      achou = true;
      p = i;
    } else
      achou = false;
  }
  if (achou)
    printf("O valor desejado foi encontrado na -> Posicao : %d com "
           "verificacoes feitas: %d",
           p, p);
  else {
    printf(" O valor desejado nao foi achado.");
    printf(" Posicao : %d, Verificacoes feitas: %d", i, i);
  }
}


x86 assembly (clang, -O0):
<pesquisa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x64,-0x14(%rbp)
mov    %al,-0x19(%rbp)
jge    1146 <pesquisa+0x36>
cmpl   $0x0,-0x10(%rbp)
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1156 <pesquisa+0x46>
jmp    1196 <pesquisa+0x86>
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    117c <pesquisa+0x6c>
movl   $0x1,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1183 <pesquisa+0x73>
movl   $0x0,-0x10(%rbp)
jmp    1188 <pesquisa+0x78>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <pesquisa+0x1d>
cmpl   $0x0,-0x10(%rbp)
je     11b9 <pesquisa+0xa9>
mov    -0x18(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11db <pesquisa+0xcb>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pesquisa>:
push   %rbx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %edx,%r8d
mov    (%rdi,%rax,4),%ecx
lea    0x1(%rax),%rbx
mov    %eax,%edx
cmp    %esi,%ecx
cmovne %r8d,%edx
je     113d <pesquisa+0x2d>
cmp    $0x63,%rax
mov    %rbx,%rax
jb     1120 <pesquisa+0x10>
cmp    %esi,%ecx
jne    114c <pesquisa+0x3c>
lea    0xeb8(%rip),%rdi
mov    %edx,%esi
jmp    1165 <pesquisa+0x55>
lea    0xefc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf10(%rip),%rdi
mov    %ebx,%esi
mov    %ebx,%edx
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [79 x i8] c"O valor desejado foi encontrado na -> Posicao : %d com verificacoes feitas: %d\00"
@.str.1 = [34 x i8] c" O valor desejado nao foi achado.\00"
@.str.2 = [39 x i8] c" Posicao : %d, Verificacoes feitas: %d\00"
define void @pesquisa(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %28, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 100
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 0
br label %14
14: ; preds = %11, %8
%15 = phi i1 [ false, %8 ], [ %13, %11 ]
br i1 %15, label %16, label %31
16: ; preds = %14
%17 = load i32, i32* %4
%18 = load i32*, i32** %3
%19 = load i32, i32* %6
%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 %26
24: ; preds = %16
store i32 1, i32* %5
%25 = load i32, i32* %6
store i32 %25, i32* %7
br label %27
26: ; preds = %16
store i32 0, i32* %5
br label %27
27: ; preds = %26, %24
br label %28
28: ; preds = %27
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %8
31: ; preds = %14
%32 = load i32, i32* %5
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i32, i32* %7
%36 = load i32, i32* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0), i32 %35, i32 %36)
br label %43
38: ; preds = %31
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%40 = load i32, i32* %6
%41 = load i32, i32* %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %41)
br label %43
43: ; preds = %38, %34
ret void
}

LLVM IR (-O2):
@.str = [79 x i8] c"O valor desejado foi encontrado na -> Posicao : %d com verificacoes feitas: %d\00"
@.str.1 = [34 x i8] c" O valor desejado nao foi achado.\00"
@.str.2 = [39 x i8] c" Posicao : %d, Verificacoes feitas: %d\00"
define void @pesquisa(i32* nocapture %0, i32 %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i64 [ 0, %2 ], [ %11, %3 ]
%5 = phi i32 [ undef, %2 ], [ %10, %3 ]
%6 = getelementptr inbounds i32, i32* %0, i64 %4
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, %1
%9 = trunc i64 %4 to i32
%10 = select i1 %8, i32 %9, i32 %5
%11 = add nuw nsw i64 %4, 1
%12 = icmp ugt i64 %4, 98
%13 = or i1 %8, %12
br i1 %13, label %14, label %3
14: ; preds = %3
br i1 %8, label %15, label %17
15: ; preds = %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %10)
br label %21
17: ; preds = %14
%18 = trunc i64 %11 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %18)
br label %21
21: ; preds = %17, %15
ret void
}