void test_linear_search_returns_middle_index(void) {
  int length = 3;
  int array[] = {1, 2, 3};
  int element = 2;
  int index = linear_search(array, length, element);
  ((void)((index == 1)
              ? ((void)0)
              : __test_fail(
                    "index == 1",
                    "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/michaelreneer/"
                    "Algorithms/refs/heads/master/c/test/test_linear_search.c",
                    __FUNCTION__, 22)));
}


x86 assembly (clang, -O0):
<test_linear_search_returns_middle_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x3,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x8(%rbp)
movl   $0x2,-0x14(%rbp)
lea    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    $0x0,%al
call   1030 <linear_search@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    116d <test_linear_search_returns_middle_index+0x4d>
jmp    118e <test_linear_search_returns_middle_index+0x6e>
lea    0xe98(%rip),%rdi
lea    0xe9c(%rip),%rsi
lea    0xf36(%rip),%rdx
mov    $0x16,%ecx
mov    $0x0,%al
call   1040 <__test_fail@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_linear_search_returns_middle_index>:
sub    $0x18,%rsp
mov    0xede(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xecb(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x3,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <linear_search@plt>
cmp    $0x1,%eax
je     1176 <test_linear_search_returns_middle_index+0x56>
lea    0xeb0(%rip),%rdi
lea    0xeb4(%rip),%rsi
lea    0xf4e(%rip),%rdx
mov    $0x16,%ecx
xor    %eax,%eax
call   1040 <__test_fail@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.test_linear_search_returns_middle_index.array = [3 x i32] [i32 1, i32 2, i32 3]
@.str = [11 x i8] c"index == 1\00"
@.str.1 = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/michaelreneer/Algorithms/refs/heads/master/c/test/test_linear_search.c\00"
@__FUNCTION__.test_linear_search_returns_middle_index = [40 x i8] c"test_linear_search_returns_middle_index\00"
define void @test_linear_search_returns_middle_index() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 3, i32* %1
%5 = bitcast [3 x i32]* %2 to i8*
store i32 2, i32* %3
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%7 = load i32, i32* %1
%8 = load i32, i32* %3
%9 = call i32 (i32*, i32, i32, ...) bitcast (i32 (...)* @linear_search to i32 (i32*, i32, i32, ...)*)(i32* %6, i32 %7, i32 %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %0
br label %15
13: ; preds = %0
%14 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @__test_fail to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @__FUNCTION__.test_linear_search_returns_middle_index, i64 0, i64 0), i32 22)
br label %15
15: ; preds = %13, %12
ret void
}

LLVM IR (-O2):
@__const.test_linear_search_returns_middle_index.array = [3 x i32] [i32 1, i32 2, i32 3]
@.str = [11 x i8] c"index == 1\00"
@.str.1 = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/michaelreneer/Algorithms/refs/heads/master/c/test/test_linear_search.c\00"
@__FUNCTION__.test_linear_search_returns_middle_index = [40 x i8] c"test_linear_search_returns_middle_index\00"
define void @test_linear_search_returns_middle_index() {
%1 = alloca [3 x i32]
%2 = bitcast [3 x i32]* %1 to i8*
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%4 = call i32 (i32*, i32, i32, ...) bitcast (i32 (...)* @linear_search to i32 (i32*, i32, i32, ...)*)(i32* %3, i32 3, i32 2)
%5 = icmp eq i32 %4, 1
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @__test_fail to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @__FUNCTION__.test_linear_search_returns_middle_index, i64 0, i64 0), i32 22)
br label %8
8: ; preds = %0, %6
ret void
}