#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 *search(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;
  pos = search(arr, N, key);
  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
call   1040 <search@plt>
mov    %rax,-0x48(%rbp)
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    $0x38,%rsp
movaps 0xee5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xead(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0xc,%esi
mov    $0xfffffffb,%edx
call   1050 <search@plt>
test   %rax,%rax
je     1186 <main+0x56>
lea    0xebb(%rip),%rdi
mov    %rax,%rsi
mov    $0xfffffffb,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1192 <main+0x62>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%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 = [11 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)
store i32* %10, 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 ([11 x i8], [11 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 = [10 x i8] c"Not found\00"
define i32 @main() {
%1 = alloca [12 x i32]
%2 = bitcast [12 x i32]* %1 to i8*
%3 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 0
%4 = call i32* @search(i32* %3, i32 12, i32 -5)
%5 = icmp eq i32* %4, null
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32* %4, i32 -5)
br label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
ret i32 0
}