#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*/ __clear_cache(char *, int *);
int /*<<< orphan*/ bsearch(char ***, char **, int, int, void *);
char *mmap(int /*<<< orphan*/, int, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int);
int main(int ac, char **av) {
  char *jitmem;
  int *je, var;
  jitmem = mmap(0, 256, 7, 0x22, -1, 0);
  je = (int *)jitmem;
  *je++ = 0xe59f000c;
  *je++ = 0xe5901000;
  *je++ = 0xe2811009;
  *je++ = 0xe5801000;
  *je++ = 0xe1a0f00e;
  *je = (int)&var;
  __clear_cache(jitmem, je);
  var = ac;
  bsearch(&av, av, 1, 1, (void *)jitmem);
  printf("ac = %d, var = %d\n", ac, var);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %r9d,%r9d
mov    $0x100,%esi
mov    $0x7,%edx
mov    $0x22,%ecx
mov    $0xffffffff,%r8d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
movl   $0xe59f000c,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
movl   $0xe5901000,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
movl   $0xe2811009,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
movl   $0xe5801000,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
movl   $0xe1a0f00e,(%rax)
lea    -0x24(%rbp),%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1230 <__clear_cache>
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%r8
lea    -0x10(%rbp),%rdi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1050 <bsearch@plt>
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xde1(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret
nopl   0x0(%rax)

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %rsi,0x8(%rsp)
xor    %edi,%edi
mov    $0x100,%esi
mov    $0x7,%edx
mov    $0x22,%ecx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbp
movaps 0xe94(%rip),%xmm0
movups %xmm0,(%rax)
lea    0x14(%rax),%rsi
movl   $0xe1a0f00e,0x10(%rax)
lea    0x4(%rsp),%rax
mov    %eax,0x14(%rbp)
mov    %rbp,%rdi
call   11d0 <__clear_cache>
mov    %r14d,0x4(%rsp)
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
mov    %rbp,%r8
call   1050 <bsearch@plt>
mov    0x4(%rsp),%edx
lea    0xe5c(%rip),%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
nopw   0x0(%rax,%rax,1)

LLVM IR (-O0):
@.str = [19 x i8] c"ac = %d, var = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i8* @mmap(i32 0, i32 256, i32 7, i32 34, i32 -1, i32 0)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = bitcast i8* %10 to i32*
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = getelementptr inbounds i32, i32* %12, i32 1
store i32* %13, i32** %7
store i32 -442564596, i32* %12
%14 = load i32*, i32** %7
%15 = getelementptr inbounds i32, i32* %14, i32 1
store i32* %15, i32** %7
store i32 -443543552, i32* %14
%16 = load i32*, i32** %7
%17 = getelementptr inbounds i32, i32* %16, i32 1
store i32* %17, i32** %7
store i32 -494858231, i32* %16
%18 = load i32*, i32** %7
%19 = getelementptr inbounds i32, i32* %18, i32 1
store i32* %19, i32** %7
store i32 -444592128, i32* %18
%20 = load i32*, i32** %7
%21 = getelementptr inbounds i32, i32* %20, i32 1
store i32* %21, i32** %7
store i32 -509546482, i32* %20
%22 = ptrtoint i32* %8 to i32
%23 = load i32*, i32** %7
store i32 %22, i32* %23
%24 = load i8*, i8** %6
%25 = load i32*, i32** %7
%26 = call i32 @__clear_cache(i8* %24, i32* %25)
%27 = load i32, i32* %4
store i32 %27, i32* %8
%28 = load i8**, i8*** %5
%29 = load i8*, i8** %6
%30 = call i32 @bsearch(i8*** %5, i8** %28, i32 1, i32 1, i8* %29)
%31 = load i32, i32* %4
%32 = load i32, i32* %8
%33 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %31, i32 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"ac = %d, var = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8**
%4 = alloca i32
store i8** %1, i8*** %3
%5 = bitcast i32* %4 to i8*
%6 = tail call i8* @mmap(i32 0, i32 256, i32 7, i32 34, i32 -1, i32 0)
%7 = getelementptr inbounds i8, i8* %6, i64 16
%8 = bitcast i8* %7 to i32*
%9 = bitcast i8* %6 to <4 x i32>*
store <4 x i32> <i32 -442564596, i32 -443543552, i32 -494858231, i32 -444592128>, <4 x i32>* %9
%10 = getelementptr inbounds i8, i8* %6, i64 20
%11 = bitcast i8* %10 to i32*
store i32 -509546482, i32* %8
%12 = ptrtoint i32* %4 to i64
%13 = trunc i64 %12 to i32
store i32 %13, i32* %11
%14 = call i32 @__clear_cache(i8* %6, i32* %11)
store i32 %0, i32* %4
%15 = call i32 @bsearch(i8*** %3, i8** %1, i32 1, i32 1, i8* %6)
%16 = load i32, i32* %4
%17 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %16)
ret i32 0
}