#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 a[6] = {1, 5, 3, 2, 4, 7};
  int i, j, key;
  int length = 6;
  for (j = 1; j < length; j++) {
    key = a[j];
    for (i = j - 1; i >= 0 && a[i] > key; i--) {
      a[i + 1] = a[i];
    }
    a[i + 1] = key;
  }
  for (i = 0; i < length; i++) {
    printf("%d ", a[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xed4(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x6,-0x30(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    11dd <main+0xcd>
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x24(%rbp)
mov    %al,-0x31(%rbp)
jl     118e <main+0x7e>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
cmp    -0x2c(%rbp),%eax
setg   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    119e <main+0x8e>
jmp    11c0 <main+0xb0>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    116e <main+0x5e>
mov    -0x2c(%rbp),%ecx
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114e <main+0x3e>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1214 <main+0x104>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e4 <main+0xd4>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0xef4(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xebd(%rip),%xmm0
movups %xmm0,0x4(%rsp)
mov    0x14(%rsp),%eax
mov    $0x5,%ecx
cmp    $0x4,%eax
jg     11a3 <main+0x83>
movl   $0x5,0x14(%rsp)
mov    0xc(%rsp),%edx
mov    $0x4,%ecx
cmp    %eax,%edx
jle    11a3 <main+0x83>
mov    %edx,0x10(%rsp)
mov    0x8(%rsp),%edx
mov    $0x3,%ecx
cmp    %eax,%edx
jle    11a3 <main+0x83>
mov    %edx,0xc(%rsp)
mov    0x4(%rsp),%edx
mov    $0x2,%ecx
cmp    %eax,%edx
jle    11a3 <main+0x83>
mov    %edx,0x8(%rsp)
mov    (%rsp),%edx
mov    $0x1,%ecx
cmp    %eax,%edx
jle    11a3 <main+0x83>
mov    %edx,0x4(%rsp)
xor    %ecx,%ecx
mov    %eax,(%rsp,%rcx,4)
mov    (%rsp),%esi
lea    0xe78(%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    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

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