#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);
main() {
  int array[5] = {1, 22, 9, 9, 19912};
  int length = 5;
  int i, j;
  for (i = 1; i < length; ++i) {
    int key = array[i];
    for (j = i - 1; j >= 0; --j) {
      if (key > array[j]) {
        break;
      } else {
        array[j + 1] = array[j];
      }
    }
    array[j + 1] = key;
  }
  for (i = 0; i < length; ++i) {
    printf("%d \t", array[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xed5(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x5,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11d0 <main+0xc0>
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     11b3 <main+0xa3>
mov    -0x30(%rbp),%eax
movslq -0x2c(%rbp),%rcx
cmp    -0x20(%rbp,%rcx,4),%eax
jle    118c <main+0x7c>
jmp    11b3 <main+0xa3>
movslq -0x2c(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x20(%rbp,%rax,4)
jmp    11a5 <main+0x95>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    116c <main+0x5c>
mov    -0x30(%rbp),%ecx
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114c <main+0x3c>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1205 <main+0xf5>
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11d7 <main+0xc7>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x16,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4dc8,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.array = [5 x i32] [i32 1, i32 22, i32 9, i32 9, i32 19912]
@.str = [5 x i8] c"%d \09\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [5 x i32]* %2 to i8*
store i32 5, i32* %3
store i32 1, i32* %4
br label %8
8: ; preds = %49, %0
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %52
12: ; preds = %8
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %14
%16 = load i32, i32* %15
store i32 %16, i32* %6
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 1
store i32 %18, i32* %5
br label %19
19: ; preds = %40, %12
%20 = load i32, i32* %5
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %43
22: ; preds = %19
%23 = load i32, i32* %6
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = icmp sgt i32 %23, %27
br i1 %28, label %29, label %30
29: ; preds = %22
br label %43
30: ; preds = %22
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %37
store i32 %34, i32* %38
br label %39
39: ; preds = %30
br label %40
40: ; preds = %39
%41 = load i32, i32* %5
%42 = add nsw i32 %41, -1
store i32 %42, i32* %5
br label %19
43: ; preds = %29, %19
%44 = load i32, i32* %6
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %47
store i32 %44, i32* %48
br label %49
49: ; preds = %43
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %8
52: ; preds = %8
store i32 0, i32* %4
br label %53
53: ; preds = %63, %52
%54 = load i32, i32* %4
%55 = load i32, i32* %3
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %66
57: ; preds = %53
%58 = load i32, i32* %4
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %57
%64 = load i32, i32* %4
%65 = add nsw i32 %64, 1
store i32 %65, i32* %4
br label %53
66: ; preds = %53
%67 = load i32, i32* %1
ret i32 %67
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d \09\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 1)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 9)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 9)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 22)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 19912)
ret i32 0
}