#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 num[10] = {6, 15, 12, 7, 9, 23, 2, 10, 4, 20};
  int temp;
  int i, j;
  int key = 0;
  int data = 0;
  for (i = 0; i < 10; i++)
    printf("%2d ", num[i]);
  for (i = 0; i < 10; i++) {
    temp = num[i];
    for (j = i; j > 0 && num[j - 1] > temp; j--) {
      num[j] = num[j - 1];
    }
    num[j] = temp;
  }
  printf("\n");
  for (i = 0; i < 10; i++)
    printf("%2d ", num[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xec6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    1187 <main+0x67>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1159 <main+0x39>
movl   $0x0,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    1218 <main+0xf8>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x3c(%rbp)
mov    %al,-0x45(%rbp)
jle    11cd <main+0xad>
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%eax
cmp    -0x34(%rbp),%eax
setg   %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    11dd <main+0xbd>
jmp    11ff <main+0xdf>
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x3c(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    11a9 <main+0x89>
mov    -0x34(%rbp),%ecx
movslq -0x3c(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    118e <main+0x6e>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    125b <main+0x13b>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    122d <main+0x10d>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    0xef1(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xed6(%rip),%r14
xor    %ebx,%ebx
mov    $0x6,%ebp
mov    %r14,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0xf,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0xc,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x17,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x14,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    120f <main+0xef>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
shl    $0x22,%rbx
mov    %ebp,(%rsp,%rbx,1)
mov    $0x1,%ebx
mov    (%rsp,%rbx,4),%ebp
mov    %rbx,%rax
test   %rbx,%rbx
je     1200 <main+0xe0>
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rax),%rcx
mov    %ecx,%edx
mov    (%rsp,%rdx,4),%edx
cmp    %ebp,%edx
jle    123f <main+0x11f>
mov    %edx,(%rsp,%rax,4)
lea    0x1(%rcx),%rdx
mov    %rcx,%rax
cmp    $0x1,%rdx
jg     1220 <main+0x100>
xor    %eax,%eax
cltq
mov    %ebp,(%rsp,%rax,4)
add    $0x1,%rbx
cmp    $0xa,%rbx
je     1253 <main+0x133>
mov    (%rsp,%rbx,4),%ebp
jmp    120f <main+0xef>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%esi
lea    0xdc1(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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