#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(void) {
  int a[10] = {2, 6, 4, 8, 10, 12, 89, 68, 45, 37};
  int pass;
  int i;
  int hold;
  printf("Data items in original order\n");
  for (i = 0; i < 10; i++) {
    printf("%4d", a[i]);
  }
  for (pass = 1; pass < 10; pass++) {
    for (i = 0; i < 10 - 1; i++) {
      if (a[i] > a[i + 1]) {
        hold = a[i];
        a[i] = a[i + 1];
        a[i + 1] = hold;
      }
    }
  }
  printf("\nData items in ascending order\n");
  for (i = 0; i < 10; i++) {
    printf("%4d", a[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xec6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    1187 <main+0x67>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xed4(%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   $0x1,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    1218 <main+0xf8>
movl   $0x0,-0x38(%rbp)
cmpl   $0x9,-0x38(%rbp)
jge    1205 <main+0xe5>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jle    11f2 <main+0xd2>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x38(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x3c(%rbp),%ecx
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    11f7 <main+0xd7>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    119f <main+0x7f>
jmp    120a <main+0xea>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118e <main+0x6e>
lea    0xe2b(%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    0xe00(%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    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebf(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaf(%rip),%r12
mov    %r12,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x8,%ebp
mov    %r12,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%ebx
mov    %r12,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xc,%r13d
mov    %r12,%rdi
mov    $0xc,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x59,%r14d
mov    %r12,%rdi
mov    $0x59,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x44,%r15d
mov    %r12,%rdi
mov    $0x44,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2d,%r12d
lea    0xe0e(%rip),%rdi
mov    $0x2d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdfb(%rip),%rdi
mov    $0x25,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x25,%eax
mov    $0x4,%edx
mov    $0x6,%edi
mov    $0x2,%esi
mov    $0x9,%r8d
nopl   0x0(%rax,%rax,1)
cmp    %edi,%esi
mov    %edi,%ecx
cmovg  %esi,%ecx
cmovg  %edi,%esi
cmp    %edx,%ecx
mov    %ecx,%edi
cmovg  %edx,%edi
cmovg  %ecx,%edx
cmp    %ebp,%edx
mov    %ebp,%ecx
cmovg  %edx,%ecx
cmovg  %ebp,%edx
cmp    %ebx,%ecx
mov    %ecx,%ebp
cmovg  %ebx,%ebp
cmovg  %ecx,%ebx
cmp    %r13d,%ebx
mov    %r13d,%ecx
cmovg  %ebx,%ecx
cmovg  %r13d,%ebx
cmp    %r14d,%ecx
mov    %ecx,%r13d
cmovg  %r14d,%r13d
cmovg  %ecx,%r14d
cmp    %r15d,%r14d
mov    %r15d,%ecx
cmovg  %r14d,%ecx
cmovg  %r15d,%r14d
cmp    %r12d,%ecx
mov    %ecx,%r15d
cmovg  %r12d,%r15d
cmovg  %ecx,%r12d
mov    %eax,%ecx
cmp    %eax,%r12d
cmovg  %r12d,%eax
cmovg  %ecx,%r12d
add    $0xffffffff,%r8d
jne    1230 <main+0x100>
mov    %edi,0xc(%rsp)
lea    0xd74(%rip),%rdi
mov    %esi,0x8(%rsp)
mov    %edx,0x10(%rsp)
mov    %eax,0x14(%rsp)
call   1040 <puts@plt>
lea    0xd3b(%rip),%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd29(%rip),%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd17(%rip),%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd05(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xcf5(%rip),%rbp
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    0x14(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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