#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);
int searchInsert(int *, int, int);
int main(void) {
  int arr[] = {1, 3, 5, 6};
  int targets[] = {5, 2, 7, 0};
  int res[4];
  int i;
  for (i = 0; i < 4; i++) {
    res[i] = searchInsert(arr, 4, targets[i]);
  }
  for (i = 0; i < 4; i++) {
    printf("%d\n", res[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x4,-0x44(%rbp)
jge    119a <main+0x7a>
lea    -0x20(%rbp),%rdi
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
mov    $0x4,%esi
call   1040 <searchInsert@plt>
mov    %eax,%ecx
movslq -0x44(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1162 <main+0x42>
movl   $0x0,-0x44(%rbp)
cmpl   $0x4,-0x44(%rbp)
jge    11cd <main+0xad>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11a1 <main+0x81>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movaps 0xecd(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x5,%edx
call   1040 <searchInsert@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x2,%edx
call   1040 <searchInsert@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x7,%edx
call   1040 <searchInsert@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %edx,%edx
call   1040 <searchInsert@plt>
mov    %eax,%ebx
lea    0xe7f(%rip),%rbp
mov    %rbp,%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.main.arr = [4 x i32] [i32 1, i32 3, i32 5, i32 6]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%4 = call i32 @searchInsert(i32* %3, i32 4, i32 5)
%5 = call i32 @searchInsert(i32* %3, i32 4, i32 2)
%6 = call i32 @searchInsert(i32* %3, i32 4, i32 7)
%7 = call i32 @searchInsert(i32* %3, i32 4, i32 0)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
ret i32 0
}