#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int search(int, int *, int);
int main() {
  int a[] = {2, 4, 6, 7, 1, 3, 5, 9, 11, 13, 23, 14, 32};
  int x;
  int loc;
  printf("Enter a number");
  scanf("%d", &x);
  loc = search(x, a, sizeof(a) / sizeof(a[0]));
  if (loc != -1) {
    printf("%d is at the %d place\n", x, loc + 1);
  } else {
    printf("%d does not exist!\n", x);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x34,%edx
call   1050 <memcpy@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x44(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x44(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0xd,%edx
call   1040 <search@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0xffffffff,-0x48(%rbp)
je     11bc <main+0x7c>
mov    -0x44(%rbp),%esi
mov    -0x48(%rbp),%edx
add    $0x1,%edx
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cd <main+0x8d>
mov    -0x44(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
mov    0xef6(%rip),%eax
mov    %eax,0x40(%rsp)
movaps 0xedb(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xebf(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0xd,%edx
call   1040 <search@plt>
mov    0xc(%rsp),%esi
cmp    $0xffffffff,%eax
je     11b2 <main+0x82>
add    $0x1,%eax
lea    0xe9f(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11c0 <main+0x90>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@__const.main.a = [13 x i32] [i32 2, i32 4, i32 6, i32 7, i32 1, i32 3, i32 5, i32 9, i32 11, i32 13, i32 23, i32 14, i32 32]
@.str = [15 x i8] c"Enter a number\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"%d is at the %d place\0A\00"
@.str.3 = [20 x i8] c"%d does not exist!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [13 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [13 x i32]* %2 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 0
%10 = call i32 @search(i32 %8, i32* %9, i32 13)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %18
13: ; preds = %0
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %16)
br label %21
18: ; preds = %0
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %13
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [13 x i32] [i32 2, i32 4, i32 6, i32 7, i32 1, i32 3, i32 5, i32 9, i32 11, i32 13, i32 23, i32 14, i32 32]
@.str = [15 x i8] c"Enter a number\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"%d is at the %d place\0A\00"
@.str.3 = [20 x i8] c"%d does not exist!\0A\00"
define i32 @main() {
%1 = alloca [13 x i32]
%2 = alloca i32
%3 = bitcast [13 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = getelementptr inbounds [13 x i32], [13 x i32]* %1, i64 0, i64 0
%9 = call i32 @search(i32 %7, i32* %8, i32 13)
%10 = icmp eq i32 %9, -1
%11 = load i32, i32* %2
br i1 %10, label %15, label %12
12: ; preds = %0
%13 = add nuw nsw i32 %9, 1
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %13)
br label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %11)
br label %17
17: ; preds = %15, %12
ret i32 0
}