#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 *);
void search(int x[], int size, int num_to_search) {
  int i;
  int number_found = 0;
  for (i = 0; i < size; i++) {
    if (num_to_search == x[i]) {
      number_found = 1;
      break;
    }
  }
  if (number_found == 1) {
    printf("Number found in the array.\n");
  } else {
    printf("Number NOT found in the array.\n");
  }
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116f <search+0x5f>
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    115c <search+0x4c>
movl   $0x1,-0x18(%rbp)
jmp    116f <search+0x5f>
jmp    1161 <search+0x51>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <search+0x20>
cmpl   $0x1,-0x18(%rbp)
jne    118a <search+0x7a>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
jmp    1196 <search+0x86>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
mov    %rdi,%rax
lea    0xee6(%rip),%rdi
test   %esi,%esi
jle    113e <search+0x2e>
mov    %esi,%ecx
xor    %esi,%esi
lea    0xef6(%rip),%r8
nopl   0x0(%rax)
cmp    %edx,(%rax,%rsi,4)
je     1143 <search+0x33>
add    $0x1,%rsi
cmp    %rsi,%rcx
jne    1130 <search+0x20>
jmp    1030 <puts@plt>
mov    %r8,%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"Number found in the array.\0A\00"
@.str.1 = [32 x i8] c"Number NOT found in the array.\0A\00"
define void @search(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %8
store i32 0, i32* %7
br label %9
9: ; preds = %23, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load i32, i32* %6
%15 = load i32*, i32** %4
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = icmp eq i32 %14, %19
br i1 %20, label %21, label %22
21: ; preds = %13
store i32 1, i32* %8
br label %26
22: ; preds = %13
br label %23
23: ; preds = %22
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %9
26: ; preds = %21, %9
%27 = load i32, i32* %8
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %33
31: ; preds = %26
%32 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %31, %29
ret void
}

LLVM IR (-O2):
@str = [31 x i8] c"Number NOT found in the array.\00"
@str.2 = [27 x i8] c"Number found in the array.\00"
define void @search(i32* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %15
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %9
7: ; preds = %9
%8 = icmp eq i64 %14, %6
br i1 %8, label %15, label %9
9: ; preds = %5, %7
%10 = phi i64 [ 0, %5 ], [ %14, %7 ]
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, %2
%14 = add nuw nsw i64 %10, 1
br i1 %13, label %15, label %7
15: ; preds = %7, %9, %3
%16 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.2, i64 0, i64 0), %9 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0), %7 ]
%17 = tail call i32 @puts(i8* dereferenceable(1) %16)
ret void
}