int *l_search_recursive(int *array, int *key, int size, int index) {
  int found, *ptr;
  if (index < size) {
    if (*key == array[index]) {
      found = 1;
      ptr = &found;
      return ptr;
    } else {
      index++;
      l_search_recursive(array, key, size, index);
    }
  } else {
    found = -1;
    ptr = &found;
    return ptr;
  }
}


x86 assembly (clang, -O0):
<l_search_recursive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1186 <l_search_recursive+0x76>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
movslq -0x20(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    1165 <l_search_recursive+0x55>
movl   $0x1,-0x24(%rbp)
lea    -0x24(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <l_search_recursive+0x8d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1030 <l_search_recursive@plt>
jmp    119d <l_search_recursive+0x8d>
movl   $0xffffffff,-0x24(%rbp)
lea    -0x24(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<l_search_recursive>:
push   %rax
cmp    %edx,%ecx
jge    1129 <l_search_recursive+0x19>
mov    (%rsi),%r8d
movslq %ecx,%rax
cmp    (%rdi,%rax,4),%r8d
je     1129 <l_search_recursive+0x19>
add    $0x1,%ecx
call   1030 <l_search_recursive@plt>
lea    0x4(%rsp),%rax
pop    %rcx
ret

LLVM IR (-O0):
define i32* @l_search_recursive(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*
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%12 = load i32, i32* %9
%13 = load i32, i32* %8
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %35
15: ; preds = %4
%16 = load i32*, i32** %7
%17 = load i32, i32* %16
%18 = load i32*, i32** %6
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load i32, i32* %21
%23 = icmp eq i32 %17, %22
br i1 %23, label %24, label %26
24: ; preds = %15
store i32 1, i32* %10
store i32* %10, i32** %11
%25 = load i32*, i32** %11
store i32* %25, i32** %5
br label %37
26: ; preds = %15
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
%29 = load i32*, i32** %6
%30 = load i32*, i32** %7
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = call i32* @l_search_recursive(i32* %29, i32* %30, i32 %31, i32 %32)
br label %34
34: ; preds = %26
br label %37
35: ; preds = %4
store i32 -1, i32* %10
store i32* %10, i32** %11
%36 = load i32*, i32** %11
store i32* %36, i32** %5
br label %37
37: ; preds = %24, %35, %34
%38 = load i32*, i32** %5
ret i32* %38
}

LLVM IR (-O2):
define noalias i32* @l_search_recursive(i32* nocapture %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = icmp slt i32 %3, %2
br i1 %7, label %8, label %17
8: ; preds = %4
%9 = load i32, i32* %1
%10 = sext i32 %3 to i64
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = icmp eq i32 %9, %12
br i1 %13, label %17, label %14
14: ; preds = %8
%15 = add nsw i32 %3, 1
%16 = tail call i32* @l_search_recursive(i32* %0, i32* %1, i32 %2, i32 %15)
br label %17
17: ; preds = %4, %8, %14
ret i32* %5
}