#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 Linear_search(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int a[] = {2, 5, 4, 6, 7, 1, 0};
  int v, length, result;
  v = 6;
  length = 7;
  result = Linear_search(a, v, length);
  if (result == -1)
    printf("i=NIL\n");
  else
    printf("i=%d\n", result + 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec2(%rip),%eax
mov    %eax,-0x8(%rbp)
movl   $0x6,-0x24(%rbp)
movl   $0x7,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1040 <Linear_search@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1196 <main+0x76>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <main+0x8a>
mov    -0x2c(%rbp),%esi
add    $0x1,%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movups 0xed1(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x6,%esi
mov    $0x7,%edx
call   1050 <Linear_search@plt>
cmp    $0xffffffff,%eax
je     1177 <main+0x47>
add    $0x1,%eax
lea    0xeb0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1183 <main+0x53>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.main.a = [7 x i32] [i32 2, i32 5, i32 4, i32 6, i32 7, i32 1, i32 0]
@.str = [7 x i8] c"i=NIL\0A\00"
@.str.1 = [6 x i8] c"i=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [7 x i32]* %2 to i8*
store i32 6, i32* %3
store i32 7, i32* %4
%7 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 @Linear_search(i32* %7, i32 %8, i32 %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %19
15: ; preds = %0
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %15, %13
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [7 x i32] [i32 2, i32 5, i32 4, i32 6, i32 7, i32 1, i32 0]
@.str.1 = [6 x i8] c"i=%d\0A\00"
@str = [6 x i8] c"i=NIL\00"
define i32 @main() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%4 = call i32 @Linear_search(i32* %3, i32 6, i32 7)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %11
8: ; preds = %0
%9 = add nuw nsw i32 %4, 1
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %8, %6
ret i32 0
}