#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 find(int *, int, int, int);
scalar_t__ malloc(int);
int *searchRange(int *nums, int numsSize, int target, int *returnSize) {
  int *ret = (int *)malloc(sizeof(int) * 2);
  *returnSize = 2;
  int left = find(nums, numsSize, target, 0);
  if (left < 0) {
    ret[0] = ret[1] = -1;
    return ret;
  }
  int right = find(nums, numsSize, target, 1);
  if (right < 0) {
    ret[0] = ret[1] = -1;
    return ret;
  }
  ret[0] = left;
  ret[1] = right;
  return ret;
}


x86 assembly (clang, -O0):
<searchRange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
xor    %ecx,%ecx
call   1030 <find@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    118e <searchRange+0x6e>
mov    -0x28(%rbp),%rax
movl   $0xffffffff,0x4(%rax)
mov    -0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ec <searchRange+0xcc>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x1,%ecx
call   1030 <find@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jge    11d1 <searchRange+0xb1>
mov    -0x28(%rbp),%rax
movl   $0xffffffff,0x4(%rax)
mov    -0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ec <searchRange+0xcc>
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<searchRange>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%rbx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbp
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
movl   $0x2,(%rbx)
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1030 <find@plt>
test   %eax,%eax
js     117f <searchRange+0x5f>
mov    %eax,%ebx
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    $0x1,%ecx
call   1030 <find@plt>
test   %eax,%eax
js     117f <searchRange+0x5f>
mov    %ebx,(%r12)
mov    %eax,0x4(%r12)
jmp    1187 <searchRange+0x67>
movq   $0xffffffffffffffff,(%r12)
ff
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @searchRange(i32* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%13 = call i64 @malloc(i32 8)
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %10
%15 = load i32*, i32** %9
store i32 2, i32* %15
%16 = load i32*, i32** %6
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = call i32 @find(i32* %16, i32 %17, i32 %18, i32 0)
store i32 %19, i32* %11
%20 = load i32, i32* %11
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %4
%23 = load i32*, i32** %10
%24 = getelementptr inbounds i32, i32* %23, i64 1
store i32 -1, i32* %24
%25 = load i32*, i32** %10
%26 = getelementptr inbounds i32, i32* %25, i64 0
store i32 -1, i32* %26
%27 = load i32*, i32** %10
store i32* %27, i32** %5
br label %49
28: ; preds = %4
%29 = load i32*, i32** %6
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = call i32 @find(i32* %29, i32 %30, i32 %31, i32 1)
store i32 %32, i32* %12
%33 = load i32, i32* %12
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %28
%36 = load i32*, i32** %10
%37 = getelementptr inbounds i32, i32* %36, i64 1
store i32 -1, i32* %37
%38 = load i32*, i32** %10
%39 = getelementptr inbounds i32, i32* %38, i64 0
store i32 -1, i32* %39
%40 = load i32*, i32** %10
store i32* %40, i32** %5
br label %49
41: ; preds = %28
%42 = load i32, i32* %11
%43 = load i32*, i32** %10
%44 = getelementptr inbounds i32, i32* %43, i64 0
store i32 %42, i32* %44
%45 = load i32, i32* %12
%46 = load i32*, i32** %10
%47 = getelementptr inbounds i32, i32* %46, i64 1
store i32 %45, i32* %47
%48 = load i32*, i32** %10
store i32* %48, i32** %5
br label %49
49: ; preds = %41, %35, %22
%50 = load i32*, i32** %5
ret i32* %50
}

LLVM IR (-O2):
define i32* @searchRange(i32* %0, i32 %1, i32 %2, i32* nocapture writeonly %3) {
%5 = tail call i64 @malloc(i32 8)
%6 = inttoptr i64 %5 to i32*
store i32 2, i32* %3
%7 = tail call i32 @find(i32* %0, i32 %1, i32 %2, i32 0)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = getelementptr inbounds i32, i32* %6, i64 1
store i32 -1, i32* %10
store i32 -1, i32* %6
br label %18
11: ; preds = %4
%12 = tail call i32 @find(i32* %0, i32 %1, i32 %2, i32 1)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = getelementptr inbounds i32, i32* %6, i64 1
store i32 -1, i32* %15
store i32 -1, i32* %6
br label %18
16: ; preds = %11
store i32 %7, i32* %6
%17 = getelementptr inbounds i32, i32* %6, i64 1
store i32 %12, i32* %17
br label %18
18: ; preds = %14, %16, %9
ret i32* %6
}