#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*/ free(int *);
int /*<<< orphan*/ printf(char *, int, int);
int *searchRange(int *, int, int, int *);
int main(void) {
  int arr[] = {2, 3, 4, 5, 8, 8, 9, 10};
  int *res = NULL;
  int size;
  res = searchRange(arr, 8, 8, &size);
  printf("begin at: %d\nend at: %d\n", *res, *(res + 1));
  free(res);
  res = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb1(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x8,%edx
lea    -0x3c(%rbp),%rcx
mov    %edx,%esi
call   1050 <searchRange@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%esi
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe81(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x38(%rbp)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rcx
mov    $0x8,%esi
mov    $0x8,%edx
call   1050 <searchRange@plt>
mov    %rax,%rbx
mov    (%rax),%esi
mov    0x4(%rax),%edx
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.arr = [8 x i32] [i32 2, i32 3, i32 4, i32 5, i32 8, i32 8, i32 9, i32 10]
@.str = [25 x i8] c"begin at: %d\0Aend at: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i32]
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [8 x i32]* %2 to i8*
store i32* null, i32** %3
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%7 = call i32* @searchRange(i32* %6, i32 8, i32 8, i32* %4)
store i32* %7, i32** %3
%8 = load i32*, i32** %3
%9 = load i32, i32* %8
%10 = load i32*, i32** %3
%11 = getelementptr inbounds i32, i32* %10, i64 1
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12)
%14 = load i32*, i32** %3
%15 = call i32 @free(i32* %14)
store i32* null, i32** %3
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [8 x i32] [i32 2, i32 3, i32 4, i32 5, i32 8, i32 8, i32 9, i32 10]
@.str = [25 x i8] c"begin at: %d\0Aend at: %d\0A\00"
define i32 @main() {
%1 = alloca [8 x i32]
%2 = alloca i32
%3 = bitcast [8 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%6 = call i32* @searchRange(i32* %5, i32 8, i32 8, i32* %2)
%7 = load i32, i32* %6
%8 = getelementptr inbounds i32, i32* %6, i64 1
%9 = load i32, i32* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9)
%11 = call i32 @free(i32* %6)
ret i32 0
}