#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 findFirst(int *, int, int);
int findLast(int *, int, int);
int *malloc(int);
int /*<<< orphan*/ printf(char *, int, int);
int *searchRange(int *nums, int numsSize, int target, int *returnSize) {
  *returnSize = 2;
  int *p = malloc(sizeof(int) * 2);
  *p = -1;
  *(p + 1) = -1;
  if (numsSize == 0)
    return p;
  *p = findFirst(nums, target, numsSize);
  *(p + 1) = findLast(nums, target, numsSize);
  printf("%d %d\n", *p, *(p + 1));
  return p;
}


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    -0x20(%rbp),%rax
movl   $0x2,(%rax)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x28(%rbp),%rax
movl   $0xffffffff,0x4(%rax)
cmpl   $0x0,-0x14(%rbp)
jne    119a <searchRange+0x5a>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ea <searchRange+0xaa>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <findFirst@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <findLast@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
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    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%r15
movl   $0x2,(%rcx)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movq   $0xffffffffffffffff,(%rax)
test   %ebp,%ebp
je     11a1 <searchRange+0x61>
mov    %r15,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
call   1040 <findFirst@plt>
mov    %eax,%r12d
mov    %eax,(%rbx)
mov    %r15,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
call   1050 <findLast@plt>
mov    %eax,0x4(%rbx)
lea    0xe69(%rip),%rdi
mov    %r12d,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d %d\0A\00"
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*
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%11 = load i32*, i32** %9
store i32 2, i32* %11
%12 = call i32* @malloc(i32 8)
store i32* %12, i32** %10
%13 = load i32*, i32** %10
store i32 -1, i32* %13
%14 = load i32*, i32** %10
%15 = getelementptr inbounds i32, i32* %14, i64 1
store i32 -1, i32* %15
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %4
%19 = load i32*, i32** %10
store i32* %19, i32** %5
br label %39
20: ; preds = %4
%21 = load i32*, i32** %6
%22 = load i32, i32* %8
%23 = load i32, i32* %7
%24 = call i32 @findFirst(i32* %21, i32 %22, i32 %23)
%25 = load i32*, i32** %10
store i32 %24, i32* %25
%26 = load i32*, i32** %6
%27 = load i32, i32* %8
%28 = load i32, i32* %7
%29 = call i32 @findLast(i32* %26, i32 %27, i32 %28)
%30 = load i32*, i32** %10
%31 = getelementptr inbounds i32, i32* %30, i64 1
store i32 %29, i32* %31
%32 = load i32*, i32** %10
%33 = load i32, i32* %32
%34 = load i32*, i32** %10
%35 = getelementptr inbounds i32, i32* %34, i64 1
%36 = load i32, i32* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %33, i32 %36)
%38 = load i32*, i32** %10
store i32* %38, i32** %5
br label %39
39: ; preds = %20, %18
%40 = load i32*, i32** %5
ret i32* %40
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d %d\0A\00"
define noalias i32* @searchRange(i32* %0, i32 %1, i32 %2, i32* nocapture writeonly %3) {
store i32 2, i32* %3
%5 = tail call i32* @malloc(i32 8)
store i32 -1, i32* %5
%6 = getelementptr inbounds i32, i32* %5, i64 1
store i32 -1, i32* %6
%7 = icmp eq i32 %1, 0
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = tail call i32 @findFirst(i32* %0, i32 %2, i32 %1)
store i32 %9, i32* %5
%10 = tail call i32 @findLast(i32* %0, i32 %2, i32 %1)
store i32 %10, i32* %6
%11 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
br label %12
12: ; preds = %4, %8
ret i32* %5
}