#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*/ pesquisa(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int vetor[100], i, val;
  for (i = 0; i < 100; i++) {
    vetor[i] = rand() % 100;
  }
  for (i = 0; i < 100; i++) {
    printf("Posicao = %d, Valor = %d\n", i, vetor[i]);
  }
  printf(" Entre com o valor a ser pequisado: ");
  scanf("%d", &val);
  pesquisa(vetor, val);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0x0,-0x194(%rbp)
cmpl   $0x64,-0x194(%rbp)
jge    1193 <main+0x53>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
movslq -0x194(%rbp),%rax
mov    %edx,-0x190(%rbp,%rax,4)
mov    -0x194(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x194(%rbp)
jmp    1155 <main+0x15>
movl   $0x0,-0x194(%rbp)
cmpl   $0x64,-0x194(%rbp)
jge    11e0 <main+0xa0>
mov    -0x194(%rbp),%esi
movslq -0x194(%rbp),%rax
mov    -0x190(%rbp,%rax,4),%edx
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x194(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x194(%rbp)
jmp    119d <main+0x5d>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4a(%rip),%rdi
lea    -0x198(%rbp),%rsi
call   1040 <scanf@plt>
lea    -0x190(%rbp),%rdi
mov    -0x198(%rbp),%esi
call   1050 <pesquisa@plt>
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1a8,%rsp
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1150 <main+0x10>
lea    0xe79(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,4),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1190 <main+0x50>
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1050 <pesquisa@plt>
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [26 x i8] c"Posicao = %d, Valor = %d\0A\00"
@.str.1 = [37 x i8] c" Entre com o valor a ser pequisado: \00"
@.str.2 = [3 x i8] c"%d\00"
define void @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %10, %5 ]
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 100
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %6
store i32 %8, i32* %9
%10 = add nuw nsw i64 %6, 1
%11 = icmp eq i64 %10, 100
br i1 %11, label %12, label %5
12: ; preds = %5, %12
%13 = phi i64 [ %18, %12 ], [ 0, %5 ]
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = trunc i64 %13 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %15)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, 100
br i1 %19, label %20, label %12
20: ; preds = %12
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 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 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%24 = load i32, i32* %2
%25 = call i32 @pesquisa(i32* %23, i32 %24)
ret void
}