#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 searchInsert(int *, int, int);
int main(int argc, char **argv) {
  int i;
  int *nums = malloc((argc - 2) * sizeof(int));
  for (i = 0; i < argc - 2; i++) {
    nums[i] = atoi(argv[i + 2]);
  }
  printf("%d\n", searchInsert(nums, argc - 2, atoi(argv[1])));
  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    -0x8(%rbp),%eax
sub    $0x2,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    11b6 <main+0x76>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <main+0x34>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    %eax,%edx
call   1060 <searchInsert@plt>
mov    %eax,%esi
lea    0xe15(%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,%r12
mov    %edi,%r15d
lea    -0x2(%r15),%r14d
lea    -0x8(,%r15,4),%edi
ff
call   1040 <malloc@plt>
mov    %rax,%r13
cmp    $0x3,%r15d
jl     1188 <main+0x48>
mov    %r14d,%ebx
xor    %ebp,%ebp
mov    0x10(%r12,%rbp,8),%rdi
call   1050 <atoi@plt>
mov    %eax,0x0(%r13,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1170 <main+0x30>
mov    0x8(%r12),%rdi
call   1050 <atoi@plt>
mov    %r13,%rdi
mov    %r14d,%esi
mov    %eax,%edx
call   1060 <searchInsert@plt>
lea    0xe5a(%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*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = sub nsw i32 %8, 2
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 4
%12 = trunc i64 %11 to i32
%13 = call i32* @malloc(i32 %12)
store i32* %13, i32** %7
store i32 0, i32* %6
br label %14
14: ; preds = %31, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 2
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %34
19: ; preds = %14
%20 = load i8**, i8*** %5
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %20, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
%27 = load i32*, i32** %7
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
store i32 %26, i32* %30
br label %31
31: ; preds = %19
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %14
34: ; preds = %14
%35 = load i32*, i32** %7
%36 = load i32, i32* %4
%37 = sub nsw i32 %36, 2
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @atoi(i8* %40)
%42 = call i32 @searchInsert(i32* %35, i32 %37, i32 %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %42)
ret i32 0
}

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