#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 atoi(char *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int search(int *, int, int);
int main(int argc, char **argv) {
  int i;
  int target = atoi(argv[1]);
  int size = argc - 2;
  int *nums = malloc(size * sizeof(int));
  for (i = 0; i < argc - 2; i++) {
    nums[i] = atoi(argv[i + 2]);
  }
  printf("%d\n", search(nums, size, target));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    11cb <main+0x8b>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <atoi@plt>
mov    %eax,%edx
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1189 <main+0x49>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <search@plt>
mov    %eax,%esi
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%r12d
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,0x4(%rsp)
lea    -0x2(%r12),%r15d
lea    -0x8(,%r12,4),%edi
ff
call   1050 <malloc@plt>
mov    %rax,%r14
cmp    $0x3,%r12d
jl     1197 <main+0x57>
mov    %r15d,%ebx
xor    %ebp,%ebp
xchg   %ax,%ax
mov    0x10(%r13,%rbp,8),%rdi
call   1060 <atoi@plt>
mov    %eax,(%r14,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1180 <main+0x40>
mov    %r14,%rdi
mov    %r15d,%esi
mov    0x4(%rsp),%edx
call   1040 <search@plt>
lea    0xe53(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %7
%14 = load i32, i32* %4
%15 = sub nsw i32 %14, 2
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 4
%19 = trunc i64 %18 to i32
%20 = call i32* @malloc(i32 %19)
store i32* %20, i32** %9
store i32 0, i32* %6
br label %21
21: ; preds = %38, %2
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 2
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %41
26: ; preds = %21
%27 = load i8**, i8*** %5
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %27, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
%34 = load i32*, i32** %9
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32 %33, i32* %37
br label %38
38: ; preds = %26
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %21
41: ; preds = %21
%42 = load i32*, i32** %9
%43 = load i32, i32* %8
%44 = load i32, i32* %7
%45 = call i32 @search(i32* %42, i32 %43, i32 %44)
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %45)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = add nsw i32 %0, -2
%7 = shl i32 %6, 2
%8 = tail call i32* @malloc(i32 %7)
%9 = icmp sgt i32 %0, 2
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = zext i32 %6 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %19, %12 ]
%14 = add nuw nsw i64 %13, 2
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = getelementptr inbounds i32, i32* %8, i64 %13
store i32 %17, i32* %18
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, %11
br i1 %20, label %21, label %12
21: ; preds = %12, %2
%22 = tail call i32 @search(i32* %8, i32 %6, i32 %5)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
ret i32 0
}