#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
void index_check(int key, int actual_index, int expected_index, int op) {
  if (actual_index != expected_index) {
    printf("Incorrect %s index for %d: %d (actual) vs. %d (expected)\n",
           (op ? "search" : "deletion"), key, actual_index, expected_index);
    printf("\nfail whale :(\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<index_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1188 <index_check+0x68>
mov    -0x10(%rbp),%ecx
lea    0xef7(%rip),%rsi
lea    0xee9(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<index_check>:
mov    %edx,%r8d
cmp    %edx,%esi
jne    1138 <index_check+0x8>
ret
push   %rax
mov    %esi,%eax
mov    %edi,%edx
test   %ecx,%ecx
lea    0xefb(%rip),%rcx
lea    0xeed(%rip),%rsi
cmove  %rcx,%rsi
lea    0xea8(%rip),%rdi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [58 x i8] c"Incorrect %s index for %d: %d (actual) vs. %d (expected)\0A\00"
@.str.1 = [7 x i8] c"search\00"
@.str.2 = [9 x i8] c"deletion\00"
@.str.3 = [16 x i8] c"\0Afail whale :(\0A\00"
define void @index_check(i32 %0, i32 %1, i32 %2, i32 %3) {
%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 %3, i32* %8
%9 = load i32, i32* %6
%10 = load i32, i32* %7
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %23
12: ; preds = %4
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i64
%16 = select i1 %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0)
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %16, i32 %17, i32 %18, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [58 x i8] c"Incorrect %s index for %d: %d (actual) vs. %d (expected)\0A\00"
@.str.1 = [7 x i8] c"search\00"
@.str.2 = [9 x i8] c"deletion\00"
@str = [15 x i8] c"\0Afail whale :(\00"
define void @index_check(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %1, %2
br i1 %5, label %12, label %6
6: ; preds = %4
%7 = icmp eq i32 %3, 0
%8 = select i1 %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %0, i32 %1, i32 %2)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %4
ret void
}