#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*/ __CrestCall(int, int);
int /*<<< orphan*/ __CrestClearStack(int);
int /*<<< orphan*/ __CrestInt(int *);
int /*<<< orphan*/ __CrestLoad(int, unsigned long, long long);
int /*<<< orphan*/ __CrestReturn(int);
int /*<<< orphan*/ __CrestStore(int, unsigned long);
int /*<<< orphan*/ __globinit_arrayBinSearch();
int /*<<< orphan*/ b(int *, int, int, int);
int main(void) {
  int A[10];
  int l;
  int r;
  int key;
  int __retres5;
  {
    __globinit_arrayBinSearch();
    __CrestCall(1, 1);
    __CrestInt((int *)(&A));
    __CrestInt(&l);
    __CrestInt(&r);
    __CrestInt(&key);
    __CrestLoad(2, (unsigned long)(&l), (long long)l);
    __CrestLoad(3, (unsigned long)(&r), (long long)r);
    __CrestLoad(4, (unsigned long)(&key), (long long)key);
    b(A, l, r, key);
    __CrestClearStack(5);
    __CrestLoad(6, (unsigned long)0, (long long)0);
    __CrestStore(7, (unsigned long)(&__retres5));
    __retres5 = 0;
    __CrestLoad(8, (unsigned long)(&__retres5), (long long)__retres5);
    __CrestReturn(9);
    return (__retres5);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <__globinit_arrayBinSearch@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1070 <__CrestCall@plt>
lea    -0x30(%rbp),%rdi
call   1080 <__CrestInt@plt>
lea    -0x34(%rbp),%rdi
call   1080 <__CrestInt@plt>
lea    -0x38(%rbp),%rdi
call   1080 <__CrestInt@plt>
lea    -0x3c(%rbp),%rdi
call   1080 <__CrestInt@plt>
lea    -0x34(%rbp),%rsi
movslq -0x34(%rbp),%rdx
mov    $0x2,%edi
call   1090 <__CrestLoad@plt>
lea    -0x38(%rbp),%rsi
movslq -0x38(%rbp),%rdx
mov    $0x3,%edi
call   1090 <__CrestLoad@plt>
lea    -0x3c(%rbp),%rsi
movslq -0x3c(%rbp),%rdx
mov    $0x4,%edi
call   1090 <__CrestLoad@plt>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x3c(%rbp),%ecx
call   1030 <b@plt>
mov    $0x5,%edi
call   10a0 <__CrestClearStack@plt>
mov    $0x6,%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1090 <__CrestLoad@plt>
lea    -0x40(%rbp),%rsi
mov    $0x7,%edi
call   1050 <__CrestStore@plt>
movl   $0x0,-0x40(%rbp)
lea    -0x40(%rbp),%rsi
movslq -0x40(%rbp),%rdx
mov    $0x8,%edi
call   1090 <__CrestLoad@plt>
mov    $0x9,%edi
call   1060 <__CrestReturn@plt>
mov    -0x40(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
xor    %eax,%eax
call   1040 <__globinit_arrayBinSearch@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1070 <__CrestCall@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1080 <__CrestInt@plt>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <__CrestInt@plt>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
call   1080 <__CrestInt@plt>
lea    0x4(%rsp),%r12
mov    %r12,%rdi
call   1080 <__CrestInt@plt>
movslq 0xc(%rsp),%rdx
mov    $0x2,%edi
mov    %rbx,%rsi
call   1090 <__CrestLoad@plt>
movslq 0x8(%rsp),%rdx
mov    $0x3,%edi
mov    %r15,%rsi
call   1090 <__CrestLoad@plt>
movslq 0x4(%rsp),%rdx
mov    $0x4,%edi
mov    %r12,%rsi
call   1090 <__CrestLoad@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x4(%rsp),%ecx
mov    %r14,%rdi
call   1030 <b@plt>
mov    $0x5,%edi
call   10a0 <__CrestClearStack@plt>
mov    $0x6,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <__CrestLoad@plt>
mov    %rsp,%rbx
mov    $0x7,%edi
mov    %rbx,%rsi
call   1050 <__CrestStore@plt>
movl   $0x0,(%rsp)
mov    $0x8,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1090 <__CrestLoad@plt>
mov    $0x9,%edi
call   1060 <__CrestReturn@plt>
mov    (%rsp),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (...) @__globinit_arrayBinSearch()
%8 = call i32 @__CrestCall(i32 1, i32 1)
%9 = bitcast [10 x i32]* %2 to i32*
%10 = call i32 @__CrestInt(i32* %9)
%11 = call i32 @__CrestInt(i32* %3)
%12 = call i32 @__CrestInt(i32* %4)
%13 = call i32 @__CrestInt(i32* %5)
%14 = ptrtoint i32* %3 to i64
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = call i32 @__CrestLoad(i32 2, i64 %14, i64 %16)
%18 = ptrtoint i32* %4 to i64
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = call i32 @__CrestLoad(i32 3, i64 %18, i64 %20)
%22 = ptrtoint i32* %5 to i64
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = call i32 @__CrestLoad(i32 4, i64 %22, i64 %24)
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = call i32 @b(i32* %26, i32 %27, i32 %28, i32 %29)
%31 = call i32 @__CrestClearStack(i32 5)
%32 = call i32 @__CrestLoad(i32 6, i64 0, i64 0)
%33 = ptrtoint i32* %6 to i64
%34 = call i32 @__CrestStore(i32 7, i64 %33)
store i32 0, i32* %6
%35 = ptrtoint i32* %6 to i64
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = call i32 @__CrestLoad(i32 8, i64 %35, i64 %37)
%39 = call i32 @__CrestReturn(i32 9)
%40 = load i32, i32* %6
ret i32 %40
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [10 x i32]* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = tail call i32 (...) @__globinit_arrayBinSearch()
%12 = tail call i32 @__CrestCall(i32 1, i32 1)
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%14 = call i32 @__CrestInt(i32* %13)
%15 = call i32 @__CrestInt(i32* %2)
%16 = call i32 @__CrestInt(i32* %3)
%17 = call i32 @__CrestInt(i32* %4)
%18 = ptrtoint i32* %2 to i64
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = call i32 @__CrestLoad(i32 2, i64 %18, i64 %20)
%22 = ptrtoint i32* %3 to i64
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = call i32 @__CrestLoad(i32 3, i64 %22, i64 %24)
%26 = ptrtoint i32* %4 to i64
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = call i32 @__CrestLoad(i32 4, i64 %26, i64 %28)
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = call i32 @b(i32* %13, i32 %30, i32 %31, i32 %32)
%34 = call i32 @__CrestClearStack(i32 5)
%35 = call i32 @__CrestLoad(i32 6, i64 0, i64 0)
%36 = ptrtoint i32* %5 to i64
%37 = call i32 @__CrestStore(i32 7, i64 %36)
store i32 0, i32* %5
%38 = call i32 @__CrestLoad(i32 8, i64 %36, i64 0)
%39 = call i32 @__CrestReturn(i32 9)
%40 = load i32, i32* %5
ret i32 %40
}