#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 rand();
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, n, data, flag = 0;
  int a[100];
  printf("how many random number\n");
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    a[i] = rand() % 1000;
    printf("%d\n", a[i]);
  }
  printf("enter number to search\n");
  scanf("%d", &data);
  for (i = 0; i < n; i++) {
    if (a[i] == data) {
      flag = 1;
      break;
    }
  }
  if (flag == 0) {
    printf("value not found\n");
  } else {
    printf("value found\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bb <main+0x8b>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
movslq -0x8(%rbp),%rax
mov    %edx,-0x1b0(%rbp,%rax,4)
movslq -0x8(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116e <main+0x3e>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe48(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    121f <main+0xef>
movslq -0x8(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%eax
cmp    -0x10(%rbp),%eax
jne    120c <main+0xdc>
movl   $0x1,-0x14(%rbp)
jmp    121f <main+0xef>
jmp    1211 <main+0xe1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e0 <main+0xb0>
cmpl   $0x0,-0x14(%rbp)
jne    123c <main+0x10c>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124a <main+0x11a>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1a8,%rsp
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
lea    0xea3(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11c2 <main+0x82>
lea    0xe8e(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rsi
imul   $0x10624dd3,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%esi
mov    %esi,0x10(%rsp,%rbx,4)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
cmp    %rax,%rbx
jl     1180 <main+0x40>
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2b(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
lea    0xe57(%rip),%rdi
test   %eax,%eax
jle    1214 <main+0xd4>
mov    0xc(%rsp),%ecx
xor    %edx,%edx
lea    0xe3a(%rip),%rsi
nopl   0x0(%rax,%rax,1)
cmp    %ecx,0x10(%rsp,%rdx,4)
je     1211 <main+0xd1>
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1200 <main+0xc0>
jmp    1214 <main+0xd4>
mov    %rsi,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
ret

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

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