#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 */
typedef int /*<<< orphan*/ array;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
main() {
  int i, j, k, temp;
  int array[] = {10, 2, 5, 2, 8, 9, 3};
  const int ARRAY_LENGTH = sizeof(array) / sizeof(array[0]);
  for (i = 1; i < ARRAY_LENGTH; i++) {
    j = i;
    while ((j > 0) && (array[j - 1] > array[j])) {
      temp = array[j];
      array[j] = array[j - 1];
      array[j - 1] = temp;
      j--;
    }
  }
  for (k = 0; k < ARRAY_LENGTH; k++) {
    printf("%d\n", array[k]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xed4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed2(%rip),%eax
mov    %eax,-0x18(%rbp)
movl   $0x7,-0x34(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    11ef <main+0xdf>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x35(%rbp)
jle    1190 <main+0x80>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%eax
movslq -0xc(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
setg   %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    11a0 <main+0x90>
jmp    11dc <main+0xcc>
movslq -0xc(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0xc(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x14(%rbp),%ecx
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1167 <main+0x57>
jmp    11e1 <main+0xd1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1157 <main+0x47>
movl   $0x0,-0x10(%rbp)
cmpl   $0x7,-0x10(%rbp)
jge    1222 <main+0x112>
movslq -0x10(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe0d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11f6 <main+0xe6>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

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

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

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