#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 scanf(char *, int *);
int main(int argc, char **argv) {
  int arr[1000] = {0}, i, check, search;
  for (i = 0; i <= 1000; i++) {
    arr[i] = i;
  }
  printf("enter a number between 0 and 1000 to search for: ");
  check = scanf("%d", &search);
  if (search > 1000 || check < 1) {
    printf("error, input has to be <= 1000!");
  } else {
    for (i = 0; i <= 1000; i++) {
      if (search == arr[i]) {
        printf("found your number at position %d\n", i);
        break;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xfb0(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1040 <memset@plt>
movl   $0x0,-0xfb4(%rbp)
cmpl   $0x3e8,-0xfb4(%rbp)
jg     119e <main+0x6e>
mov    -0xfb4(%rbp),%ecx
movslq -0xfb4(%rbp),%rax
mov    %ecx,-0xfb0(%rbp,%rax,4)
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    1166 <main+0x36>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0xfbc(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0xfb8(%rbp)
cmpl   $0x3e8,-0xfbc(%rbp)
jg     11e2 <main+0xb2>
cmpl   $0x1,-0xfb8(%rbp)
jge    11f5 <main+0xc5>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1260 <main+0x130>
movl   $0x0,-0xfb4(%rbp)
cmpl   $0x3e8,-0xfb4(%rbp)
jg     125b <main+0x12b>
mov    -0xfbc(%rbp),%eax
movslq -0xfb4(%rbp),%rcx
cmp    -0xfb0(%rbp,%rcx,4),%eax
jne    1242 <main+0x112>
mov    -0xfb4(%rbp),%esi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125b <main+0x12b>
jmp    1247 <main+0x117>
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    11ff <main+0xcf>
jmp    1260 <main+0x130>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xfb0,%rsp
lea    0x10(%rsp),%rdi
xor    %ebx,%ebx
mov    $0xfa0,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movdqa 0xead(%rip),%xmm0
movdqa 0xeb4(%rip),%xmm8
movdqa 0xebb(%rip),%xmm9
movdqa 0xec2(%rip),%xmm10
movdqa 0xec9(%rip),%xmm11
movdqa 0xed0(%rip),%xmm12
movdqa 0xed8(%rip),%xmm6
movdqa 0xee0(%rip),%xmm7
movdqa 0xee8(%rip),%xmm1
movdqa 0xef0(%rip),%xmm2
movdqa 0xef8(%rip),%xmm3
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm4
paddd  %xmm8,%xmm4
movdqa %xmm0,0x10(%rsp,%rbx,4)
movdqa %xmm4,0x20(%rsp,%rbx,4)
movdqa %xmm0,%xmm4
paddd  %xmm9,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm10,%xmm5
movdqa %xmm4,0x30(%rsp,%rbx,4)
movdqa %xmm5,0x40(%rsp,%rbx,4)
movdqa %xmm0,%xmm4
paddd  %xmm11,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm12,%xmm5
movdqa %xmm4,0x50(%rsp,%rbx,4)
movdqa %xmm5,0x60(%rsp,%rbx,4)
movdqa %xmm0,%xmm4
paddd  %xmm6,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm7,%xmm5
movdqa %xmm4,0x70(%rsp,%rbx,4)
movdqa %xmm5,0x80(%rsp,%rbx,4)
movdqa %xmm0,%xmm4
paddd  %xmm1,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm2,%xmm5
movdqa %xmm4,0x90(%rsp,%rbx,4)
movdqa %xmm5,0xa0(%rsp,%rbx,4)
add    $0x28,%rbx
paddd  %xmm3,%xmm0
cmp    $0x3e8,%rbx
jne    11b0 <main+0x80>
movl   $0x3e8,0xfb0(%rsp)
lea    0xe47(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
test   %eax,%eax
jle    12cb <main+0x19b>
mov    0xc(%rsp),%eax
cmp    $0x3e8,%eax
jg     12cb <main+0x19b>
mov    $0x3,%esi
cmp    0x4(%rsp,%rsi,4),%eax
je     12c5 <main+0x195>
nopl   0x0(%rax,%rax,1)
cmp    $0x3eb,%rsi
je     12f3 <main+0x1c3>
cmp    0x8(%rsp,%rsi,4),%eax
je     12db <main+0x1ab>
cmp    0xc(%rsp,%rsi,4),%eax
je     12e1 <main+0x1b1>
cmp    0x10(%rsp,%rsi,4),%eax
je     12e5 <main+0x1b5>
add    $0x4,%rsi
cmp    0x4(%rsp,%rsi,4),%eax
jne    12a0 <main+0x170>
add    $0xfffffffffffffffd,%rsi
jmp    12e5 <main+0x1b5>
lea    0xe13(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    12f3 <main+0x1c3>
add    $0xfffffffffffffffe,%rsi
jmp    12e5 <main+0x1b5>
add    $0xffffffffffffffff,%rsi
lea    0xe19(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xfb0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [50 x i8] c"enter a number between 0 and 1000 to search for: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"error, input has to be <= 1000!\00"
@.str.3 = [34 x i8] c"found your number at position %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [1000 x i32]* %6 to i8*
store i32 0, i32* %7
br label %11
11: ; preds = %19, %2
%12 = load i32, i32* %7
%13 = icmp sle i32 %12, 1000
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i32, i32* %7
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [1000 x i32], [1000 x i32]* %6, i64 0, i64 %17
store i32 %15, i32* %18
br label %19
19: ; preds = %14
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %11
22: ; preds = %11
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
store i32 %24, i32* %8
%25 = load i32, i32* %9
%26 = icmp sgt i32 %25, 1000
br i1 %26, label %30, label %27
27: ; preds = %22
%28 = load i32, i32* %8
%29 = icmp slt i32 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %27, %22
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %51
32: ; preds = %27
store i32 0, i32* %7
br label %33
33: ; preds = %47, %32
%34 = load i32, i32* %7
%35 = icmp sle i32 %34, 1000
br i1 %35, label %36, label %50
36: ; preds = %33
%37 = load i32, i32* %9
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [1000 x i32], [1000 x i32]* %6, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = icmp eq i32 %37, %41
br i1 %42, label %43, label %46
43: ; preds = %36
%44 = load i32, i32* %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %44)
br label %50
46: ; preds = %36
br label %47
47: ; preds = %46
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %33
50: ; preds = %43, %33
br label %51
51: ; preds = %50, %30
ret i32 0
}

LLVM IR (-O2):
@.str = [50 x i8] c"enter a number between 0 and 1000 to search for: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"error, input has to be <= 1000!\00"
@.str.3 = [34 x i8] c"found your number at position %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i32]
%4 = alloca i32
%5 = bitcast [1000 x i32]* %3 to i8*
%6 = bitcast i32* %4 to i8*
br label %7
7: ; preds = %7, %2
%8 = phi i64 [ 0, %2 ], [ %43, %7 ]
%9 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %2 ], [ %44, %7 ]
%10 = add <4 x i32> %9, <i32 4, i32 4, i32 4, i32 4>
%11 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %8
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> %9, <4 x i32>* %12
%13 = getelementptr inbounds i32, i32* %11, i64 4
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> %10, <4 x i32>* %14
%15 = add nuw nsw i64 %8, 8
%16 = add <4 x i32> %9, <i32 8, i32 8, i32 8, i32 8>
%17 = add <4 x i32> %9, <i32 12, i32 12, i32 12, i32 12>
%18 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %15
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %19
%20 = getelementptr inbounds i32, i32* %18, i64 4
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> %17, <4 x i32>* %21
%22 = add nuw nsw i64 %8, 16
%23 = add <4 x i32> %9, <i32 16, i32 16, i32 16, i32 16>
%24 = add <4 x i32> %9, <i32 20, i32 20, i32 20, i32 20>
%25 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %22
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> %23, <4 x i32>* %26
%27 = getelementptr inbounds i32, i32* %25, i64 4
%28 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> %24, <4 x i32>* %28
%29 = add nuw nsw i64 %8, 24
%30 = add <4 x i32> %9, <i32 24, i32 24, i32 24, i32 24>
%31 = add <4 x i32> %9, <i32 28, i32 28, i32 28, i32 28>
%32 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %29
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> %30, <4 x i32>* %33
%34 = getelementptr inbounds i32, i32* %32, i64 4
%35 = bitcast i32* %34 to <4 x i32>*
store <4 x i32> %31, <4 x i32>* %35
%36 = add nuw nsw i64 %8, 32
%37 = add <4 x i32> %9, <i32 32, i32 32, i32 32, i32 32>
%38 = add <4 x i32> %9, <i32 36, i32 36, i32 36, i32 36>
%39 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %36
%40 = bitcast i32* %39 to <4 x i32>*
store <4 x i32> %37, <4 x i32>* %40
%41 = getelementptr inbounds i32, i32* %39, i64 4
%42 = bitcast i32* %41 to <4 x i32>*
store <4 x i32> %38, <4 x i32>* %42
%43 = add nuw nsw i64 %8, 40
%44 = add <4 x i32> %9, <i32 40, i32 40, i32 40, i32 40>
%45 = icmp eq i64 %43, 1000
br i1 %45, label %46, label %7
46: ; preds = %7
%47 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 1000
store i32 1000, i32* %47
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%49 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%50 = load i32, i32* %4
%51 = icmp sgt i32 %50, 1000
%52 = icmp slt i32 %49, 1
%53 = or i1 %52, %51
br i1 %53, label %54, label %56
54: ; preds = %46
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %84
56: ; preds = %46, %82
%57 = phi i64 [ %83, %82 ], [ 0, %46 ]
%58 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = icmp eq i32 %50, %59
br i1 %60, label %61, label %65
61: ; preds = %77, %72, %68, %56
%62 = phi i64 [ %57, %56 ], [ %66, %68 ], [ %73, %72 ], [ %78, %77 ]
%63 = trunc i64 %62 to i32
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %63)
br label %84
65: ; preds = %56
%66 = or i64 %57, 1
%67 = icmp eq i64 %66, 1001
br i1 %67, label %84, label %68
68: ; preds = %65
%69 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %66
%70 = load i32, i32* %69
%71 = icmp eq i32 %50, %70
br i1 %71, label %61, label %72
72: ; preds = %68
%73 = or i64 %57, 2
%74 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %73
%75 = load i32, i32* %74
%76 = icmp eq i32 %50, %75
br i1 %76, label %61, label %77
77: ; preds = %72
%78 = or i64 %57, 3
%79 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %78
%80 = load i32, i32* %79
%81 = icmp eq i32 %50, %80
br i1 %81, label %61, label %82
82: ; preds = %77
%83 = add nuw nsw i64 %57, 4
br label %56
84: ; preds = %65, %61, %54
ret i32 0
}