#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*/ insertion_sort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int main(int argc, char **argv) {
  int failed = 0;
  int us1[1] = {-1};
  int us2[5] = {4, 3, 2, 1, 2};
  insertion_sort(us1, 0, 0);
  insertion_sort(us2, 0, 5);
  int prev = us2[0];
  for (int i = 0; i < 5; i++) {
    if (us2[i] < prev) {
      printf("us2 error: index %d, val %d > index %d, val %d\n", i, us2[i],
             i - 1, prev);
      failed = -1;
    }
  }
  return failed;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xebd(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xebe(%rip),%eax
mov    %eax,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1040 <insertion_sort@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <insertion_sort@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x5,-0x38(%rbp)
jge    11e5 <main+0xc5>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
cmp    -0x34(%rbp),%eax
jge    11d2 <main+0xb2>
mov    -0x38(%rbp),%esi
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
mov    -0x38(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x34(%rbp),%r8d
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    11d7 <main+0xb7>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    118f <main+0x6f>
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movl   $0xffffffff,0xc(%rsp)
ff
mov    0xedc(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xec1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xc(%rsp),%rdi
xor    %ebp,%ebp
xor    %esi,%esi
xor    %edx,%edx
call   1040 <insertion_sort@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <insertion_sort@plt>
mov    0x10(%rsp),%ebx
mov    0x14(%rsp),%edx
cmp    %ebx,%edx
jge    118c <main+0x6c>
lea    0xe9c(%rip),%rdi
mov    $0x1,%esi
xor    %ecx,%ecx
mov    %ebx,%r8d
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
mov    0x18(%rsp),%edx
cmp    %ebx,%edx
jge    11b2 <main+0x92>
lea    0xe79(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%ecx
mov    %ebx,%r8d
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
mov    0x1c(%rsp),%edx
cmp    %ebx,%edx
jge    11d8 <main+0xb8>
lea    0xe53(%rip),%rdi
mov    $0x3,%esi
mov    $0x2,%ecx
mov    %ebx,%r8d
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
mov    0x20(%rsp),%edx
cmp    %ebx,%edx
jge    11fe <main+0xde>
lea    0xe2d(%rip),%rdi
mov    $0x4,%esi
mov    $0x3,%ecx
mov    %ebx,%r8d
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

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

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