#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 *, ...);
main() {
  int i, t, isFinished;
  int a[7] = {9, 4, 8, 2, 5, 6, 1};
  for (i = 0; i < 7; i++) {
    printf("%d ", a[i]);
  }
  printf("\n");
  while (1) {
    isFinished = 1;
    for (i = 0; i < 6; i++) {
      if (a[i + 1] < a[i]) {
        t = a[i];
        a[i] = a[i + 1];
        a[i + 1] = t;
        isFinished = 0;
      }
    }
    if (isFinished == 1) {
      break;
    }
  }
  for (i = 0; i < 7; i++) {
    printf("%d ", a[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    117e <main+0x6e>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1150 <main+0x40>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    1206 <main+0xf6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x8(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jge    11f3 <main+0xe3>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
movl   $0x0,-0x10(%rbp)
jmp    11f8 <main+0xe8>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119a <main+0x8a>
cmpl   $0x1,-0x10(%rbp)
jne    1215 <main+0x105>
jmp    121a <main+0x10a>
jmp    118c <main+0x7c>
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    124f <main+0x13f>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1221 <main+0x111>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%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    0xecb(%rip),%rbx
movl   $0x9,0x10(%rsp)
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x4,0x4(%rsp)
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x8,%r15d
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%r13d
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x5,0x8(%rsp)
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x6,%r12d
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x1,0xc(%rsp)
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp),%eax
mov    %eax,%ecx
mov    0x4(%rsp),%r9d
cmp    %eax,%r9d
mov    %r9d,%edx
mov    %eax,0x14(%rsp)
cmovl  %eax,%edx
mov    %r15d,%r14d
cmovl  %r9d,%eax
mov    %eax,0x10(%rsp)
cmp    %edx,%r15d
mov    %r15d,%r10d
cmovl  %edx,%r10d
mov    %edx,%eax
cmovl  %r15d,%eax
mov    %eax,0x4(%rsp)
mov    %r13d,%r11d
cmp    %r10d,%r13d
mov    %r13d,%ebx
cmovl  %r10d,%ebx
mov    0x8(%rsp),%r8d
mov    %r10d,%edi
cmovl  %r13d,%edi
cmp    %ebx,%r8d
mov    %r8d,%ebp
cmovl  %ebx,%ebp
mov    %ebx,%r15d
cmovl  %r8d,%r15d
mov    %r12d,%esi
cmp    %ebp,%r12d
cmovl  %ebp,%r12d
mov    0xc(%rsp),%eax
mov    %eax,%r13d
mov    %ebp,%ecx
cmovl  %esi,%ecx
mov    %ecx,0x8(%rsp)
cmp    %r12d,%eax
cmovl  %r12d,%eax
mov    %eax,0xc(%rsp)
cmovl  %r13d,%r12d
mov    %r15d,%r13d
mov    %edi,%r15d
jl     11e0 <main+0xc0>
cmp    %ebp,%esi
jl     11e0 <main+0xc0>
cmp    %ebx,%r8d
jl     11e0 <main+0xc0>
cmp    %r10d,%r11d
jl     11e0 <main+0xc0>
cmp    %edx,%r14d
jl     11e0 <main+0xc0>
cmp    0x14(%rsp),%r9d
jl     11e0 <main+0xc0>
lea    0xd56(%rip),%rbx
mov    %rbx,%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1040 <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 = [7 x i32] [i32 9, i32 4, i32 8, i32 2, i32 5, i32 6, i32 1]
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [7 x i32]
store i32 0, i32* %1
%6 = bitcast [7 x i32]* %5 to i8*
store i32 0, i32* %2
br label %7
7: ; preds = %16, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 7
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %10
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %7
19: ; preds = %7
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %62
store i32 1, i32* %4
store i32 0, i32* %2
br label %22
22: ; preds = %55, %21
%23 = load i32, i32* %2
%24 = icmp slt i32 %23, 6
br i1 %24, label %25, label %58
25: ; preds = %22
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = icmp slt i32 %30, %34
br i1 %35, label %36, label %54
36: ; preds = %25
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %38
%40 = load i32, i32* %39
store i32 %40, i32* %3
%41 = load i32, i32* %2
%42 = add nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = load i32, i32* %2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %47
store i32 %45, i32* %48
%49 = load i32, i32* %3
%50 = load i32, i32* %2
%51 = add nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %52
store i32 %49, i32* %53
store i32 0, i32* %4
br label %54
54: ; preds = %36, %25
br label %55
55: ; preds = %54
%56 = load i32, i32* %2
%57 = add nsw i32 %56, 1
store i32 %57, i32* %2
br label %22
58: ; preds = %22
%59 = load i32, i32* %4
%60 = icmp eq i32 %59, 1
br i1 %60, label %61, label %62
61: ; preds = %58
br label %63
62: ; preds = %58
br label %21
63: ; preds = %61
store i32 0, i32* %2
br label %64
64: ; preds = %73, %63
%65 = load i32, i32* %2
%66 = icmp slt i32 %65, 7
br i1 %66, label %67, label %76
67: ; preds = %64
%68 = load i32, i32* %2
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %69
%71 = load i32, i32* %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %71)
br label %73
73: ; preds = %67
%74 = load i32, i32* %2
%75 = add nsw i32 %74, 1
store i32 %75, i32* %2
br label %64
76: ; preds = %64
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%78 = load i32, i32* %1
ret i32 %78
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 9)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 5)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 6)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%8 = tail call i32 @putchar(i32 10)
br label %9
9: ; preds = %9, %0
%10 = phi i32 [ 1, %0 ], [ %35, %9 ]
%11 = phi i32 [ 6, %0 ], [ %36, %9 ]
%12 = phi i32 [ 5, %0 ], [ %33, %9 ]
%13 = phi i32 [ 2, %0 ], [ %29, %9 ]
%14 = phi i32 [ 8, %0 ], [ %26, %9 ]
%15 = phi i32 [ 4, %0 ], [ %22, %9 ]
%16 = phi i32 [ 9, %0 ], [ %19, %9 ]
%17 = icmp slt i32 %15, %16
%18 = select i1 %17, i32 %16, i32 %15
%19 = select i1 %17, i32 %15, i32 %16
%20 = icmp slt i32 %14, %18
%21 = select i1 %20, i32 %18, i32 %14
%22 = select i1 %20, i32 %14, i32 %18
%23 = or i1 %20, %17
%24 = icmp slt i32 %13, %21
%25 = select i1 %24, i32 %21, i32 %13
%26 = select i1 %24, i32 %13, i32 %21
%27 = icmp slt i32 %12, %25
%28 = select i1 %27, i32 %25, i32 %12
%29 = select i1 %27, i32 %12, i32 %25
%30 = or i1 %27, %24
%31 = icmp slt i32 %11, %28
%32 = select i1 %31, i32 %28, i32 %11
%33 = select i1 %31, i32 %11, i32 %28
%34 = icmp slt i32 %10, %32
%35 = select i1 %34, i32 %32, i32 %10
%36 = select i1 %34, i32 %10, i32 %32
%37 = or i1 %34, %31
%38 = select i1 %37, i1 true, i1 %30
%39 = select i1 %38, i1 true, i1 %23
br i1 %39, label %9, label %40
40: ; preds = %9
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %33)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %36)
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
%48 = tail call i32 @putchar(i32 10)
ret i32 0
}