#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 find_number(int *p, int size, int target) {
  int bFound = 0;
  int i = 0;
  for (i; i < size; i++) {
    if (p[i] == target) {
      bFound = 1;
      break;
    }
  }
  if (bFound)
    printf("Number %d exist in position %d\n", target, i);
  else
    printf("Number not found!\n");
}


x86 assembly (clang, -O0):
<find_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116f <find_number+0x5f>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x10(%rbp),%eax
jne    115c <find_number+0x4c>
movl   $0x1,-0x14(%rbp)
jmp    116f <find_number+0x5f>
jmp    1161 <find_number+0x51>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1130 <find_number+0x20>
cmpl   $0x0,-0x14(%rbp)
je     1192 <find_number+0x82>
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a0 <find_number+0x90>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_number>:
test   %esi,%esi
jle    113e <find_number+0x1e>
mov    %esi,%ecx
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
cmp    %edx,(%rdi,%rax,4)
je     114a <find_number+0x2a>
add    $0x1,%rax
cmp    %rax,%rcx
jne    1130 <find_number+0x10>
lea    0xedb(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xeaf(%rip),%rdi
mov    %edx,%esi
mov    %eax,%edx
xor    %eax,%eax
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"Number %d exist in position %d\0A\00"
@.str.1 = [19 x i8] c"Number not found!\0A\00"
define void @find_number(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* %7
store i32 0, i32* %8
%9 = load i32, i32* %8
br label %10
10: ; preds = %24, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load i32*, i32** %4
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = load i32, i32* %6
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %14
store i32 1, i32* %7
br label %27
23: ; preds = %14
br label %24
24: ; preds = %23
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %10
27: ; preds = %22, %10
%28 = load i32, i32* %7
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load i32, i32* %6
%32 = load i32, i32* %8
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %31, i32 %32)
br label %36
34: ; preds = %27
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %34, %30
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"Number %d exist in position %d\0A\00"
@str = [18 x i8] c"Number not found!\00"
define void @find_number(i32* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %18
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %12
%8 = phi i64 [ 0, %5 ], [ %13, %12 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, %2
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, %6
br i1 %14, label %18, label %7
15: ; preds = %7
%16 = trunc i64 %8 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %16)
br label %20
18: ; preds = %12, %3
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
ret void
}