#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, ...);
bool search(int A[], int num, int size) {
  int c;
  for (c = 0; c < size; c++) {
    if (A[c] == num) {
      printf("%d is present at location %d.\n", num, c + 1);
      return true;
    } else {
    }
  }
  if (c == size) {
    printf("%d is not present in array.\n", num);
    return false;
  } else {
  }
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1184 <search+0x74>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x14(%rbp),%eax
jne    116c <search+0x5c>
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b2 <search+0xa2>
jmp    1171 <search+0x61>
jmp    1176 <search+0x66>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1129 <search+0x19>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    11ad <search+0x9d>
mov    -0x14(%rbp),%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b2 <search+0xa2>
jmp    11b2 <search+0xa2>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
push   %rbx
test   %edx,%edx
jle    1130 <search+0x20>
mov    %edx,%eax
xor    %edx,%edx
nopl   0x0(%rax)
cmp    %esi,(%rdi,%rdx,4)
je     1144 <search+0x34>
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1120 <search+0x10>
jmp    1132 <search+0x22>
jne    115a <search+0x4a>
lea    0xee6(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    115a <search+0x4a>
add    $0x1,%edx
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [31 x i8] c"%d is present at location %d.\0A\00"
@.str.1 = [29 x i8] c"%d is not present in array.\0A\00"
define i32 @search(i32* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %19
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %16
%8 = phi i64 [ 0, %5 ], [ %17, %16 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, %1
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = trunc i64 %8 to i32
%14 = add nuw nsw i32 %13, 1
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %14)
br label %23
16: ; preds = %7
%17 = add nuw nsw i64 %8, 1
%18 = icmp eq i64 %17, %6
br i1 %18, label %21, label %7
19: ; preds = %3
%20 = icmp eq i32 %2, 0
br i1 %20, label %21, label %23
21: ; preds = %16, %19
%22 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %23
23: ; preds = %19, %21, %12
%24 = phi i32 [ 1, %12 ], [ 0, %21 ], [ undef, %19 ]
ret i32 %24
}