#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 encontrakVETOR(int *, int, int);
int /*<<< orphan*/ leVETOR(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int vetor[80], n = 0, k;
  do {
    printf("Introduza o n de inteiros a ler: ");
    scanf("%d", &n);
  } while (n < 1 || n >= 80);
  printf("Introduza o k a procurar: ");
  scanf("%d", &k);
  leVETOR(vetor, n);
  printf("Existe %d na posicao %d\n", k, encontrakVETOR(vetor, n, k));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x154(%rbp)
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x154(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x154(%rbp)
mov    %al,-0x159(%rbp)
jl     11a2 <main+0x62>
cmpl   $0x50,-0x154(%rbp)
setge  %al
mov    %al,-0x159(%rbp)
mov    -0x159(%rbp),%al
test   $0x1,%al
jne    115c <main+0x1c>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe5d(%rip),%rdi
lea    -0x158(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x150(%rbp),%rdi
mov    -0x154(%rbp),%esi
call   1050 <leVETOR@plt>
mov    -0x158(%rbp),%eax
mov    %eax,-0x160(%rbp)
lea    -0x150(%rbp),%rdi
mov    -0x154(%rbp),%esi
mov    -0x158(%rbp),%edx
call   1030 <encontrakVETOR@plt>
mov    -0x160(%rbp),%esi
mov    %eax,%edx
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x158,%rsp
movl   $0x0,0x8(%rsp)
lea    0xea4(%rip),%r14
lea    0xebf(%rip),%r15
lea    0x8(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%eax
add    $0xffffffb0,%eax
cmp    $0xffffffb1,%eax
jb     1170 <main+0x30>
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%esi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <leVETOR@plt>
mov    0xc(%rsp),%ebp
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1030 <encontrakVETOR@plt>
lea    0xe66(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x158,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Introduza o n de inteiros a ler: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Introduza o k a procurar: \00"
@.str.3 = [25 x i8] c"Existe %d na posicao %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %14, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %8
8: ; preds = %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 1
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = load i32, i32* %3
%13 = icmp sge i32 %12, 80
br label %14
14: ; preds = %11, %8
%15 = phi i1 [ true, %8 ], [ %13, %11 ]
br i1 %15, label %5, label %16
16: ; preds = %14
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%19 = getelementptr inbounds [80 x i32], [80 x i32]* %2, i64 0, i64 0
%20 = load i32, i32* %3
%21 = call i32 @leVETOR(i32* %19, i32 %20)
%22 = load i32, i32* %4
%23 = getelementptr inbounds [80 x i32], [80 x i32]* %2, i64 0, i64 0
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = call i32 @encontrakVETOR(i32* %23, i32 %24, i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"Introduza o n de inteiros a ler: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Introduza o k a procurar: \00"
@.str.3 = [25 x i8] c"Existe %d na posicao %d\0A\00"
define i32 @main() {
%1 = alloca [80 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [80 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i32* %3 to i8*
br label %7
7: ; preds = %7, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = add i32 %10, -80
%12 = icmp ult i32 %11, -79
br i1 %12, label %7, label %13
13: ; preds = %7
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%16 = getelementptr inbounds [80 x i32], [80 x i32]* %1, i64 0, i64 0
%17 = load i32, i32* %2
%18 = call i32 @leVETOR(i32* %16, i32 %17)
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = call i32 @encontrakVETOR(i32* %16, i32 %20, i32 %19)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %19, i32 %21)
ret i32 0
}