#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 bitpat_search(int, int, int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  printf("Found at index %d. Correct result: 2.\n", bitpat_search(0xb, 0x3, 2));
  printf("Found at index %d. Correct result: 5.\n",
         bitpat_search(0x96, 0x6, 3));
  printf("Found at index %d. Correct result: 3.\n",
         bitpat_search(0xf75, 0x5, 3));
  printf("Found at index %d. Correct result: -1.\n",
         bitpat_search(0x965c, 0xf, 4));
  printf("Found at index %d. Correct result: 10.\n",
         bitpat_search(0xffe1, 0xb2, 2));
  printf("Found at index %d. Correct result: -1.\n",
         bitpat_search(0xffe1, 0xb2, 4));
  printf("Found at index %d. Correct result: 10.\n",
         bitpat_search(0xffdf, 0x0, 1));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xb,%edi
mov    $0x3,%esi
mov    $0x2,%edx
call   1030 <bitpat_search@plt>
mov    %eax,%esi
lea    0xeb4(%rip),%rdi
call   1040 <printf@plt>
mov    $0x96,%edi
mov    $0x6,%esi
mov    $0x3,%edx
call   1030 <bitpat_search@plt>
mov    %eax,%esi
lea    0xeb9(%rip),%rdi
call   1040 <printf@plt>
mov    $0xf75,%edi
mov    $0x5,%esi
mov    $0x3,%edx
call   1030 <bitpat_search@plt>
mov    %eax,%esi
lea    0xebe(%rip),%rdi
call   1040 <printf@plt>
mov    $0x965c,%edi
mov    $0xf,%esi
mov    $0x4,%edx
call   1030 <bitpat_search@plt>
mov    %eax,%esi
lea    0xec3(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffe1,%edi
mov    $0xb2,%esi
mov    $0x2,%edx
call   1030 <bitpat_search@plt>
mov    %eax,%esi
lea    0xec9(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffe1,%edi
mov    $0xb2,%esi
mov    $0x4,%edx
call   1030 <bitpat_search@plt>
mov    %eax,%esi
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffdf,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <bitpat_search@plt>
mov    %eax,%esi
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xb,%edi
mov    $0x3,%esi
mov    $0x2,%edx
call   1030 <bitpat_search@plt>
lea    0xec1(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x96,%edi
mov    $0x6,%esi
mov    $0x3,%edx
call   1030 <bitpat_search@plt>
lea    0xec6(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0xf75,%edi
mov    $0x5,%esi
mov    $0x3,%edx
call   1030 <bitpat_search@plt>
lea    0xecb(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x965c,%edi
mov    $0xf,%esi
mov    $0x4,%edx
call   1030 <bitpat_search@plt>
lea    0xed0(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0xffe1,%edi
mov    $0xb2,%esi
mov    $0x2,%edx
call   1030 <bitpat_search@plt>
lea    0xed3(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0xffe1,%edi
mov    $0xb2,%esi
mov    $0x4,%edx
call   1030 <bitpat_search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0xffdf,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <bitpat_search@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Found at index %d. Correct result: 2.\0A\00"
@.str.1 = [39 x i8] c"Found at index %d. Correct result: 5.\0A\00"
@.str.2 = [39 x i8] c"Found at index %d. Correct result: 3.\0A\00"
@.str.3 = [40 x i8] c"Found at index %d. Correct result: -1.\0A\00"
@.str.4 = [40 x i8] c"Found at index %d. Correct result: 10.\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @bitpat_search(i32 11, i32 3, i32 2)
%3 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = call i32 @bitpat_search(i32 150, i32 6, i32 3)
%5 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = call i32 @bitpat_search(i32 3957, i32 5, i32 3)
%7 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = call i32 @bitpat_search(i32 38492, i32 15, i32 4)
%9 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = call i32 @bitpat_search(i32 65505, i32 178, i32 2)
%11 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %10)
%12 = call i32 @bitpat_search(i32 65505, i32 178, i32 4)
%13 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = call i32 @bitpat_search(i32 65503, i32 0, i32 1)
%15 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"Found at index %d. Correct result: 2.\0A\00"
@.str.1 = [39 x i8] c"Found at index %d. Correct result: 5.\0A\00"
@.str.2 = [39 x i8] c"Found at index %d. Correct result: 3.\0A\00"
@.str.3 = [40 x i8] c"Found at index %d. Correct result: -1.\0A\00"
@.str.4 = [40 x i8] c"Found at index %d. Correct result: 10.\0A\00"
define i32 @main() {
%1 = tail call i32 @bitpat_search(i32 11, i32 3, i32 2)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @bitpat_search(i32 150, i32 6, i32 3)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 @bitpat_search(i32 3957, i32 5, i32 3)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = tail call i32 @bitpat_search(i32 38492, i32 15, i32 4)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = tail call i32 @bitpat_search(i32 65505, i32 178, i32 2)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%11 = tail call i32 @bitpat_search(i32 65505, i32 178, i32 4)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = tail call i32 @bitpat_search(i32 65503, i32 0, i32 1)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %13)
ret i32 0
}