#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*/ puts(char *);
int sequential_search(int *array, int size, int keyword) {
  if (!array) {
    puts("NULL array was passed");
    return -2;
  }
  if (size <= 0) {
    puts("Size of the array is not mentioned correctly");
    return -3;
  }
  int i = 0;
  for (; i < size; i++) {
    if (keyword == array[i]) {
      return i + 1;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<sequential_search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1145 <sequential_search+0x35>
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11b6 <sequential_search+0xa6>
cmpl   $0x0,-0x14(%rbp)
jg     1167 <sequential_search+0x57>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    11b6 <sequential_search+0xa6>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11af <sequential_search+0x9f>
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    119c <sequential_search+0x8c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11b6 <sequential_search+0xa6>
jmp    11a1 <sequential_search+0x91>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <sequential_search+0x5e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sequential_search>:
push   %rax
test   %rdi,%rdi
je     1135 <sequential_search+0x25>
test   %esi,%esi
jle    1148 <sequential_search+0x38>
mov    %esi,%ecx
xor    %eax,%eax
xchg   %ax,%ax
cmp    %edx,(%rdi,%rax,4)
je     115b <sequential_search+0x4b>
add    $0x1,%rax
cmp    %rax,%rcx
jne    1120 <sequential_search+0x10>
mov    $0xffffffff,%eax
pop    %rcx
ret
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
mov    $0xfffffffe,%eax
pop    %rcx
ret
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
mov    $0xfffffffd,%eax
pop    %rcx
ret
add    $0x1,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [22 x i8] c"NULL array was passed\00"
@.str.1 = [45 x i8] c"Size of the array is not mentioned correctly\00"
define i32 @sequential_search(i32* %0, i32 %1, i32 %2) {
%4 = icmp eq i32* %0, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %24
7: ; preds = %3
%8 = icmp slt i32 %1, 1
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = zext i32 %1 to i64
br label %13
11: ; preds = %7
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %24
13: ; preds = %9, %21
%14 = phi i64 [ 0, %9 ], [ %22, %21 ]
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, %2
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = trunc i64 %14 to i32
%20 = add nuw nsw i32 %19, 1
br label %24
21: ; preds = %13
%22 = add nuw nsw i64 %14, 1
%23 = icmp eq i64 %22, %10
br i1 %23, label %24, label %13
24: ; preds = %21, %18, %11, %5
%25 = phi i32 [ -3, %11 ], [ -2, %5 ], [ %20, %18 ], [ -1, %21 ]
ret i32 %25
}