#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 atoi(char *);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int i = 0, cont, *vet, ch, pos = 0;
  ch = atoi(argv[1]);
  srand(time(NULL));
  for (cont = 0; cont < 1000; cont++) {
    int achou = 0;
    vet = (int *)malloc(10 * sizeof(int));
    for (i = 0; i < 9; i++)
      vet[i] = rand() % 1000;
    for (i = 0; i < 9; i++) {
      if (vet[i] == ch)
        achou = 1;
      pos = pos + 1;
      if (achou == 1) {
        printf("\nEncontrado na posição %d.", i);
        printf("\nForam feitas %d comparações.", pos);
        printf("\nFoi encontrado na %d combinação do vetor\n", cont);
        break;
      }
    }
    free(vet);
  }
  printf("\nFoi encontrado na %d combinação do vetor\n", cont);
  printf("\nForam feitas %d comparações.\n", pos);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3e8,-0x18(%rbp)
jge    12b1 <main+0x141>
movl   $0x0,-0x2c(%rbp)
mov    $0x28,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jge    1216 <main+0xa6>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e4 <main+0x74>
movl   $0x0,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jge    129a <main+0x12a>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x24(%rbp),%eax
jne    1242 <main+0xd2>
movl   $0x1,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x2c(%rbp)
jne    1287 <main+0x117>
mov    -0x14(%rbp),%esi
lea    0xda1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xdaf(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xdc0(%rip),%rdi
call   1040 <printf@plt>
jmp    129a <main+0x12a>
jmp    128c <main+0x11c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    121d <main+0xad>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11bb <main+0x4b>
mov    -0x18(%rbp),%esi
lea    0xd82(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xda0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%r13d
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe81(%rip),%r15
lea    0xe9a(%rip),%r12
xor    %ebp,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x28,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%r14)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x4(%r14)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x8(%r14)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0xc(%r14)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%r14)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x14(%r14)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x18(%r14)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x1c(%r14)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x20(%r14)
cmp    %r13d,(%r14)
jne    1360 <main+0x1f0>
add    $0x1,%ebp
xor    %esi,%esi
jmp    13e0 <main+0x270>
nopw   0x0(%rax,%rax,1)
cmp    %r13d,0x4(%r14)
jne    1370 <main+0x200>
add    $0x2,%ebp
mov    $0x1,%esi
jmp    13e0 <main+0x270>
cmp    %r13d,0x8(%r14)
jne    1380 <main+0x210>
add    $0x3,%ebp
mov    $0x2,%esi
jmp    13e0 <main+0x270>
cmp    %r13d,0xc(%r14)
jne    1390 <main+0x220>
add    $0x4,%ebp
mov    $0x3,%esi
jmp    13e0 <main+0x270>
cmp    %r13d,0x10(%r14)
jne    13a0 <main+0x230>
add    $0x5,%ebp
mov    $0x4,%esi
jmp    13e0 <main+0x270>
cmp    %r13d,0x14(%r14)
jne    13b0 <main+0x240>
add    $0x6,%ebp
mov    $0x5,%esi
jmp    13e0 <main+0x270>
cmp    %r13d,0x18(%r14)
jne    13c0 <main+0x250>
add    $0x7,%ebp
mov    $0x6,%esi
jmp    13e0 <main+0x270>
cmp    %r13d,0x1c(%r14)
jne    13d0 <main+0x260>
add    $0x8,%ebp
mov    $0x7,%esi
jmp    13e0 <main+0x270>
add    $0x9,%ebp
cmp    %r13d,%eax
jne    1400 <main+0x290>
mov    $0x8,%esi
nopl   (%rax)
lea    0xc19(%rip),%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x1,%ebx
cmp    $0x3e8,%ebx
jne    11b0 <main+0x40>
lea    0xc1f(%rip),%rdi
mov    $0x3e8,%esi
call   1040 <printf@plt>
lea    0xc3b(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"\0AEncontrado na posi\C3\A7\C3\A3o %d.\00"
@.str.1 = [32 x i8] c"\0AForam feitas %d compara\C3\A7\C3\B5es.\00"
@.str.2 = [45 x i8] c"\0AFoi encontrado na %d combina\C3\A7\C3\A3o do vetor\0A\00"
@.str.3 = [33 x i8] c"\0AForam feitas %d compara\C3\A7\C3\B5es.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %10
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %9
%16 = call i32 @time(i32* null)
%17 = call i32 @srand(i32 %16)
store i32 0, i32* %7
br label %18
18: ; preds = %69, %2
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 1000
br i1 %20, label %21, label %72
21: ; preds = %18
store i32 0, i32* %11
%22 = call i64 @malloc(i32 40)
%23 = inttoptr i64 %22 to i32*
store i32* %23, i32** %8
store i32 0, i32* %6
br label %24
24: ; preds = %34, %21
%25 = load i32, i32* %6
%26 = icmp slt i32 %25, 9
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = call i32 (...) @rand()
%29 = srem i32 %28, 1000
%30 = load i32*, i32** %8
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
store i32 %29, i32* %33
br label %34
34: ; preds = %27
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %24
37: ; preds = %24
store i32 0, i32* %6
br label %38
38: ; preds = %63, %37
%39 = load i32, i32* %6
%40 = icmp slt i32 %39, 9
br i1 %40, label %41, label %66
41: ; preds = %38
%42 = load i32*, i32** %8
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %9
%48 = icmp eq i32 %46, %47
br i1 %48, label %49, label %50
49: ; preds = %41
store i32 1, i32* %11
br label %50
50: ; preds = %49, %41
%51 = load i32, i32* %10
%52 = add nsw i32 %51, 1
store i32 %52, i32* %10
%53 = load i32, i32* %11
%54 = icmp eq i32 %53, 1
br i1 %54, label %55, label %62
55: ; preds = %50
%56 = load i32, i32* %6
%57 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %10
%59 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %7
%61 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %60)
br label %66
62: ; preds = %50
br label %63
63: ; preds = %62
%64 = load i32, i32* %6
%65 = add nsw i32 %64, 1
store i32 %65, i32* %6
br label %38
66: ; preds = %55, %38
%67 = load i32*, i32** %8
%68 = call i32 @free(i32* %67)
br label %69
69: ; preds = %66
%70 = load i32, i32* %7
%71 = add nsw i32 %70, 1
store i32 %71, i32* %7
br label %18
72: ; preds = %18
%73 = load i32, i32* %7
%74 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %73)
%75 = load i32, i32* %10
%76 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %75)
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
@.str = [29 x i8] c"\0AEncontrado na posi\C3\A7\C3\A3o %d.\00"
@.str.1 = [32 x i8] c"\0AForam feitas %d compara\C3\A7\C3\B5es.\00"
@.str.2 = [45 x i8] c"\0AFoi encontrado na %d combina\C3\A7\C3\A3o do vetor\0A\00"
@.str.3 = [33 x i8] c"\0AForam feitas %d compara\C3\A7\C3\B5es.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = tail call i32 @time(i32* null)
%7 = tail call i32 @srand(i32 %6)
br label %8
8: ; preds = %2, %80
%9 = phi i32 [ 0, %2 ], [ %81, %80 ]
%10 = phi i32 [ 0, %2 ], [ %83, %80 ]
%11 = tail call i64 @malloc(i32 40)
%12 = inttoptr i64 %11 to i32*
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 1000
store i32 %14, i32* %12
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 1000
%17 = getelementptr inbounds i32, i32* %12, i64 1
store i32 %16, i32* %17
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 1000
%20 = getelementptr inbounds i32, i32* %12, i64 2
store i32 %19, i32* %20
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 1000
%23 = getelementptr inbounds i32, i32* %12, i64 3
store i32 %22, i32* %23
%24 = tail call i32 (...) @rand()
%25 = srem i32 %24, 1000
%26 = getelementptr inbounds i32, i32* %12, i64 4
store i32 %25, i32* %26
%27 = tail call i32 (...) @rand()
%28 = srem i32 %27, 1000
%29 = getelementptr inbounds i32, i32* %12, i64 5
store i32 %28, i32* %29
%30 = tail call i32 (...) @rand()
%31 = srem i32 %30, 1000
%32 = getelementptr inbounds i32, i32* %12, i64 6
store i32 %31, i32* %32
%33 = tail call i32 (...) @rand()
%34 = srem i32 %33, 1000
%35 = getelementptr inbounds i32, i32* %12, i64 7
store i32 %34, i32* %35
%36 = tail call i32 (...) @rand()
%37 = srem i32 %36, 1000
%38 = getelementptr inbounds i32, i32* %12, i64 8
store i32 %37, i32* %38
%39 = add i32 %9, 9
%40 = load i32, i32* %12
%41 = icmp eq i32 %40, %5
%42 = add nsw i32 %9, 1
br i1 %41, label %43, label %49
43: ; preds = %77, %73, %69, %65, %61, %57, %53, %49, %8
%44 = phi i32 [ 0, %8 ], [ 1, %49 ], [ 2, %53 ], [ 3, %57 ], [ 4, %61 ], [ 5, %65 ], [ 6, %69 ], [ 7, %73 ], [ 8, %77 ]
%45 = phi i32 [ %42, %8 ], [ %52, %49 ], [ %56, %53 ], [ %60, %57 ], [ %64, %61 ], [ %68, %65 ], [ %72, %69 ], [ %76, %73 ], [ %79, %77 ]
%46 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %44)
%47 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %45)
%48 = tail call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %80
49: ; preds = %8
%50 = load i32, i32* %17
%51 = icmp eq i32 %50, %5
%52 = add nsw i32 %9, 2
br i1 %51, label %43, label %53
53: ; preds = %49
%54 = load i32, i32* %20
%55 = icmp eq i32 %54, %5
%56 = add nsw i32 %9, 3
br i1 %55, label %43, label %57
57: ; preds = %53
%58 = load i32, i32* %23
%59 = icmp eq i32 %58, %5
%60 = add nsw i32 %9, 4
br i1 %59, label %43, label %61
61: ; preds = %57
%62 = load i32, i32* %26
%63 = icmp eq i32 %62, %5
%64 = add nsw i32 %9, 5
br i1 %63, label %43, label %65
65: ; preds = %61
%66 = load i32, i32* %29
%67 = icmp eq i32 %66, %5
%68 = add nsw i32 %9, 6
br i1 %67, label %43, label %69
69: ; preds = %65
%70 = load i32, i32* %32
%71 = icmp eq i32 %70, %5
%72 = add nsw i32 %9, 7
br i1 %71, label %43, label %73
73: ; preds = %69
%74 = load i32, i32* %35
%75 = icmp eq i32 %74, %5
%76 = add nsw i32 %9, 8
br i1 %75, label %43, label %77
77: ; preds = %73
%78 = icmp eq i32 %37, %5
%79 = add nsw i32 %9, 9
br i1 %78, label %43, label %80
80: ; preds = %77, %43
%81 = phi i32 [ %45, %43 ], [ %39, %77 ]
%82 = tail call i32 @free(i32* %12)
%83 = add nuw nsw i32 %10, 1
%84 = icmp eq i32 %83, 1000
br i1 %84, label %85, label %8
85: ; preds = %80
%86 = tail call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 1000)
%87 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %81)
ret i32 0
}