void test_binary_search_iterative_returns_last_index(void) {
  int length = 3;
  int array[] = {1, 2, 3};
  int element = 3;
  int index = binary_search_iterative(array, length, element);
  ((void)((index == 2)
              ? ((void)0)
              : __test_fail("index == 2",
                            "/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_binary_search_iterative.c",
                            __FUNCTION__, 30)));
}


x86 assembly (clang, -O0):
<test_binary_search_iterative_returns_last_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   $0x3,-0x14(%rbp)
lea    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    $0x0,%al
call   1040 <binary_search_iterative@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jne    116d <test_binary_search_iterative_returns_last_index+0x4d>
jmp    118e <test_binary_search_iterative_returns_last_index+0x6e>
lea    0xe98(%rip),%rdi
lea    0xe9c(%rip),%rsi
lea    0xf40(%rip),%rdx
mov    $0x1e,%ecx
mov    $0x0,%al
call   1030 <__test_fail@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_binary_search_iterative_returns_last_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    $0x3,%edx
xor    %eax,%eax
call   1040 <binary_search_iterative@plt>
cmp    $0x2,%eax
je     1176 <test_binary_search_iterative_returns_last_index+0x56>
lea    0xeb0(%rip),%rdi
lea    0xeb4(%rip),%rsi
lea    0xf58(%rip),%rdx
mov    $0x1e,%ecx
xor    %eax,%eax
call   1030 <__test_fail@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.test_binary_search_iterative_returns_last_index.array = [3 x i32] [i32 1, i32 2, i32 3]
@.str = [11 x i8] c"index == 2\00"
@.str.1 = [171 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_binary_search_iterative.c\00"
@__FUNCTION__.test_binary_search_iterative_returns_last_index = [48 x i8] c"test_binary_search_iterative_returns_last_index\00"
define void @test_binary_search_iterative_returns_last_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 3, 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 (...)* @binary_search_iterative 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, 2
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 ([171 x i8], [171 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @__FUNCTION__.test_binary_search_iterative_returns_last_index, i64 0, i64 0), i32 30)
br label %15
15: ; preds = %13, %12
ret void
}

LLVM IR (-O2):
@__const.test_binary_search_iterative_returns_last_index.array = [3 x i32] [i32 1, i32 2, i32 3]
@.str = [11 x i8] c"index == 2\00"
@.str.1 = [171 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_binary_search_iterative.c\00"
@__FUNCTION__.test_binary_search_iterative_returns_last_index = [48 x i8] c"test_binary_search_iterative_returns_last_index\00"
define void @test_binary_search_iterative_returns_last_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 (...)* @binary_search_iterative to i32 (i32*, i32, i32, ...)*)(i32* %3, i32 3, i32 3)
%5 = icmp eq i32 %4, 2
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 ([171 x i8], [171 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @__FUNCTION__.test_binary_search_iterative_returns_last_index, i64 0, i64 0), i32 30)
br label %8
8: ; preds = %0, %6
ret void
}