#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 pesquisa(int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int vetor[10], resultado, i;
  for (i = 0; i <= 9; i++) {
    vetor[i] = i + 1;
    printf("%d\n", vetor[i]);
  }
  printf("\n\nDigite o valor: ");
  scanf("%d", &i);
  resultado = pesquisa(i, vetor);
  if (resultado >= 0)
    printf("%d está no indice %d\n", i, resultado);
  else
    printf("Valor não encontrado");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x38(%rbp)
cmpl   $0x9,-0x38(%rbp)
jg     117b <main+0x4b>
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq -0x38(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    113f <main+0xf>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe83(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x38(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1050 <pesquisa@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     11cb <main+0x9b>
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <main+0xa9>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xf0d(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movaps 0xe90(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movaps 0xe58(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0x9,0x30(%rsp)
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0xa,0x34(%rsp)
mov    %rbx,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0xa,0xc(%rsp)
lea    0xe17(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe1c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rsi
call   1050 <pesquisa@plt>
test   %eax,%eax
js     1249 <main+0x119>
mov    0xc(%rsp),%esi
lea    0xdf8(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1257 <main+0x127>
lea    0xdfd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [19 x i8] c"\0A\0ADigite o valor: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [23 x i8] c"%d est\C3\A1 no indice %d\0A\00"
@.str.4 = [22 x i8] c"Valor n\C3\A3o encontrado\00"
define void @main() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %3
br label %4
4: ; preds = %18, %0
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 9
br i1 %6, label %7, label %21
7: ; preds = %4
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %11
store i32 %9, i32* %12
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %7
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %4
21: ; preds = %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%24 = load i32, i32* %3
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%26 = call i32 @pesquisa(i32 %24, i32* %25)
store i32 %26, i32* %2
%27 = load i32, i32* %2
%28 = icmp sge i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %21
%30 = load i32, i32* %3
%31 = load i32, i32* %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 %31)
br label %35
33: ; preds = %21
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %33, %29
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [19 x i8] c"\0A\0ADigite o valor: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [23 x i8] c"%d est\C3\A1 no indice %d\0A\00"
@.str.4 = [22 x i8] c"Valor n\C3\A3o encontrado\00"
define void @main() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = bitcast [10 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%9 = bitcast [10 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %9
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 5)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 6)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 7)
%15 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> <i32 5, i32 6, i32 7, i32 8>, <4 x i32>* %15
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8)
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
store i32 9, i32* %17
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 9)
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
store i32 10, i32* %19
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 10)
store i32 10, i32* %2
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%23 = load i32, i32* %2
%24 = call i32 @pesquisa(i32 %23, i32* %5)
%25 = icmp sgt i32 %24, -1
br i1 %25, label %26, label %29
26: ; preds = %0
%27 = load i32, i32* %2
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %24)
br label %31
29: ; preds = %0
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
ret void
}