#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*/ printf(char *, ...);
int /*<<< orphan*/ search(int *, int, int, int **);
int main() {
  int N = 12;
  int arr[] = {14, 56, 4, 123, 1990, 2017, 312, 43, 4, -5, -4, 4};
  int *pos;
  int key = -5;
  search(arr, N, key, &pos);
  if (pos != NULL)
    printf("Position: %p\nKey: %d\n", pos, key);
  else
    printf("Not found!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xc,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
movl   $0xfffffffb,-0x4c(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x4c(%rbp),%edx
lea    -0x48(%rbp),%rcx
call   1040 <search@plt>
cmpq   $0x0,-0x48(%rbp)
je     119a <main+0x6a>
mov    -0x48(%rbp),%rsi
mov    -0x4c(%rbp),%edx
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a8 <main+0x78>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
movaps 0xee5(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xead(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rcx
mov    $0xc,%esi
mov    $0xfffffffb,%edx
call   1050 <search@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     1190 <main+0x60>
lea    0xeae(%rip),%rdi
mov    $0xfffffffb,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    119c <main+0x6c>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@__const.main.arr = [12 x i32] [i32 14, i32 56, i32 4, i32 123, i32 1990, i32 2017, i32 312, i32 43, i32 4, i32 -5, i32 -4, i32 4]
@.str = [22 x i8] c"Position: %p\0AKey: %d\0A\00"
@.str.1 = [12 x i8] c"Not found!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [12 x i32]
%4 = alloca i32*
%5 = alloca i32
store i32 0, i32* %1
store i32 12, i32* %2
%6 = bitcast [12 x i32]* %3 to i8*
store i32 -5, i32* %5
%7 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
%8 = load i32, i32* %2
%9 = load i32, i32* %5
%10 = call i32 @search(i32* %7, i32 %8, i32 %9, i32** %4)
%11 = load i32*, i32** %4
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %0
%14 = load i32*, i32** %4
%15 = load i32, i32* %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32* %14, i32 %15)
br label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@__const.main.arr = [12 x i32] [i32 14, i32 56, i32 4, i32 123, i32 1990, i32 2017, i32 312, i32 43, i32 4, i32 -5, i32 -4, i32 4]
@.str = [22 x i8] c"Position: %p\0AKey: %d\0A\00"
@str = [11 x i8] c"Not found!\00"
define i32 @main() {
%1 = alloca [12 x i32]
%2 = alloca i32*
%3 = bitcast [12 x i32]* %1 to i8*
%4 = bitcast i32** %2 to i8*
%5 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 0
%6 = call i32 @search(i32* %5, i32 12, i32 -5, i32** %2)
%7 = load i32*, i32** %2
%8 = icmp eq i32* %7, null
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32* %7, i32 -5)
br label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
ret i32 0
}