#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);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, i, key;
  scanf("%d", &n);
  int a[n];
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  scanf("%d", &key);
  for (i = 0; i < n; i++)
    if (a[i] == key)
      printf("Key found at position %d \n", i + 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a2 <main+0x82>
mov    -0x28(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe71(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116d <main+0x4d>
lea    0xe57(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11fe <main+0xde>
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x10(%rbp),%eax
jne    11eb <main+0xcb>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
jmp    11f0 <main+0xd0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b9 <main+0x99>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xecb(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rsp,%r15
mov    -0x2c(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    118c <main+0x6c>
xor    %r13d,%r13d
lea    0xe97(%rip),%r14
mov    %r12,%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r13
jl     1170 <main+0x50>
lea    0xe6d(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x2c(%rbp),%eax
test   %eax,%eax
jle    11d8 <main+0xb8>
xor    %esi,%esi
lea    0xe57(%rip),%r14
jmp    11bb <main+0x9b>
xchg   %ax,%ax
movslq %eax,%rcx
mov    %rbx,%rsi
cmp    %rcx,%rbx
jge    11d8 <main+0xb8>
mov    (%r12,%rsi,4),%ecx
lea    0x1(%rsi),%rbx
cmp    -0x30(%rbp),%ecx
jne    11b0 <main+0x90>
add    $0x1,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
jmp    11b0 <main+0x90>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [27 x i8] c"Key found at position %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %5
%11 = alloca i32, i64 %9
store i64 %9, i64* %6
store i32 0, i32* %3
br label %12
12: ; preds = %21, %0
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %11, i64 %18
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
br label %21
21: ; preds = %16
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %12
24: ; preds = %12
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 0, i32* %3
br label %26
26: ; preds = %42, %24
%27 = load i32, i32* %3
%28 = load i32, i32* %2
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %45
30: ; preds = %26
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %11, i64 %32
%34 = load i32, i32* %33
%35 = load i32, i32* %4
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %41
37: ; preds = %30
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
%40 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %37, %30
br label %42
42: ; preds = %41
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %26
45: ; preds = %26
store i32 0, i32* %1
%46 = load i8*, i8** %5
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [27 x i8] c"Key found at position %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
%9 = alloca i32, i64 %7
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = getelementptr inbounds i32, i32* %9, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %14)
%16 = add nuw nsw i64 %13, 1
%17 = load i32, i32* %1
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %12, label %20
20: ; preds = %12, %0
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %1
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %40
24: ; preds = %20, %36
%25 = phi i32 [ %37, %36 ], [ %22, %20 ]
%26 = phi i64 [ %31, %36 ], [ 0, %20 ]
%27 = getelementptr inbounds i32, i32* %9, i64 %26
%28 = load i32, i32* %27
%29 = load i32, i32* %2
%30 = icmp eq i32 %28, %29
%31 = add nuw nsw i64 %26, 1
br i1 %30, label %32, label %36
32: ; preds = %24
%33 = trunc i64 %31 to i32
%34 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %1
br label %36
36: ; preds = %24, %32
%37 = phi i32 [ %35, %32 ], [ %25, %24 ]
%38 = sext i32 %37 to i64
%39 = icmp slt i64 %31, %38
br i1 %39, label %24, label %40
40: ; preds = %36, %20
ret i32 0
}