#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 *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  printf("Vetor, (c) 2013.\n");
  int v[3];
  int i;
  for (i = 0; i < 3; i++) {
    v[i] = 100 + i;
  }
  for (i = 0; i < 3; i++) {
    printf("%d\n", v[i]);
  }
  printf("\n");
  int soma = 0;
  for (i = 0; i < 3; i++) {
    soma += v[i];
  }
  printf("%d\n", soma);
  printf("\n");
  int x;
  printf("Informe o valor: ");
  scanf("%d", &x);
  int pos = -1;
  for (i = 0; i < 3; i++) {
    if (v[i] == x) {
      pos = i;
      break;
    }
  }
  printf("%d\n", pos);
  printf("*FIM*");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    116a <main+0x4a>
mov    -0x14(%rbp),%ecx
add    $0x64,%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x10(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <main+0x24>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    119f <main+0x7f>
movslq -0x14(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1171 <main+0x51>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11e1 <main+0xc1>
movslq -0x14(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bb <main+0x9b>
mov    -0x18(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe13(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0xffffffff,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1265 <main+0x145>
movslq -0x14(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%eax
cmp    -0x1c(%rbp),%eax
jne    1252 <main+0x132>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1265 <main+0x145>
jmp    1257 <main+0x137>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    122c <main+0x10c>
mov    -0x20(%rbp),%esi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed3(%rip),%rdi
call   1040 <puts@plt>
lea    0xea8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x65,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x66,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x12f,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe59(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffff9c,%eax
cmp    $0x3,%eax
mov    $0xffffffff,%esi
cmovb  %eax,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Vetor, (c) 2013.\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [18 x i8] c"Informe o valor: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [6 x i8] c"*FIM*\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %8
8: ; preds = %17, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load i32, i32* %3
%13 = add nsw i32 100, %12
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %15
store i32 %13, i32* %16
br label %17
17: ; preds = %11
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %8
20: ; preds = %8
store i32 0, i32* %3
br label %21
21: ; preds = %30, %20
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 3
br i1 %23, label %24, label %33
24: ; preds = %21
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %24
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %21
33: ; preds = %21
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
store i32 0, i32* %3
br label %35
35: ; preds = %45, %33
%36 = load i32, i32* %3
%37 = icmp slt i32 %36, 3
br i1 %37, label %38, label %48
38: ; preds = %35
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = load i32, i32* %4
%44 = add nsw i32 %43, %42
store i32 %44, i32* %4
br label %45
45: ; preds = %38
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %35
48: ; preds = %35
%49 = load i32, i32* %4
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%53 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
store i32 -1, i32* %6
store i32 0, i32* %3
br label %54
54: ; preds = %67, %48
%55 = load i32, i32* %3
%56 = icmp slt i32 %55, 3
br i1 %56, label %57, label %70
57: ; preds = %54
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = load i32, i32* %5
%63 = icmp eq i32 %61, %62
br i1 %63, label %64, label %66
64: ; preds = %57
%65 = load i32, i32* %3
store i32 %65, i32* %6
br label %70
66: ; preds = %57
br label %67
67: ; preds = %66
%68 = load i32, i32* %3
%69 = add nsw i32 %68, 1
store i32 %69, i32* %3
br label %54
70: ; preds = %64, %54
%71 = load i32, i32* %6
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %71)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.3 = [18 x i8] c"Informe o valor: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [6 x i8] c"*FIM*\00"
@str = [17 x i8] c"Vetor, (c) 2013.\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 100)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 101)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 102)
%6 = tail call i32 @putchar(i32 10)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 303)
%8 = tail call i32 @putchar(i32 10)
%9 = bitcast i32* %1 to i8*
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = add i32 %12, -100
%14 = icmp ult i32 %13, 3
%15 = select i1 %14, i32 %13, i32 -1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}