#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*/ BubbleSort(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int array[255];
  for (int i = 255; i > 0; --i)
    array[255 - i] = i;
  printf("----before sort-----\n");
  for (int i = 0; i < 255; ++i)
    printf("%d\t", array[i]);
  printf("\n");
  BubbleSort(array, 255);
  printf("----after sort------\n");
  for (int i = 0, count = 1; i < 255; ++i, ++count) {
    printf("%d\t", array[i]);
    if (count % 10 == 0) {
      printf("\n");
    }
  }
  BubbleSort(array, 255);
  printf("\n");
  printf("------after another sort------\n");
  for (int i = 0, count = 1; i < 255; ++i, ++count) {
    printf("%d\t", array[i]);
    if (count % 10 == 0) {
      printf("\n");
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xff,-0x404(%rbp)
cmpl   $0x0,-0x404(%rbp)
jle    1177 <main+0x57>
mov    -0x404(%rbp),%ecx
mov    $0xff,%eax
sub    -0x404(%rbp),%eax
cltq
mov    %ecx,-0x400(%rbp,%rax,4)
mov    -0x404(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x404(%rbp)
jmp    113c <main+0x1c>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x408(%rbp)
cmpl   $0xff,-0x408(%rbp)
jge    11cf <main+0xaf>
movslq -0x408(%rbp),%rax
mov    -0x400(%rbp,%rax,4),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x408(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408(%rbp)
jmp    118f <main+0x6f>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x400(%rbp),%rdi
mov    $0xff,%esi
call   1040 <BubbleSort@plt>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x40c(%rbp)
movl   $0x1,-0x410(%rbp)
cmpl   $0xff,-0x40c(%rbp)
jge    1289 <main+0x169>
movslq -0x40c(%rbp),%rax
mov    -0x400(%rbp,%rax,4),%esi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x410(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1261 <main+0x141>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <main+0x146>
mov    -0x40c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40c(%rbp)
mov    -0x410(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x410(%rbp)
jmp    1210 <main+0xf0>
lea    -0x400(%rbp),%rdi
mov    $0xff,%esi
call   1040 <BubbleSort@plt>
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x414(%rbp)
movl   $0x1,-0x418(%rbp)
cmpl   $0xff,-0x414(%rbp)
jge    1343 <main+0x223>
movslq -0x414(%rbp),%rax
mov    -0x400(%rbp,%rax,4),%esi
lea    0xd27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x418(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    131b <main+0x1fb>
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1320 <main+0x200>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
jmp    12ca <main+0x1aa>
lea    0xd04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
movdqa 0xea9(%rip),%xmm3
mov    $0x1c,%eax
movdqa 0xeab(%rip),%xmm8
movdqa 0xeb2(%rip),%xmm9
movdqa 0xeb9(%rip),%xmm10
movdqa 0xec1(%rip),%xmm4
movdqa 0xec9(%rip),%xmm5
movdqa 0xed1(%rip),%xmm6
movdqa 0xed9(%rip),%xmm7
movdqa 0xee1(%rip),%xmm1
nop
movdqa %xmm3,%xmm0
paddd  %xmm8,%xmm0
movdqa %xmm3,-0x70(%rsp,%rax,4)
movdqa %xmm0,-0x60(%rsp,%rax,4)
movdqa %xmm3,%xmm0
paddd  %xmm9,%xmm0
movdqa %xmm3,%xmm2
paddd  %xmm10,%xmm2
movdqa %xmm0,-0x50(%rsp,%rax,4)
movdqa %xmm2,-0x40(%rsp,%rax,4)
movdqa %xmm3,%xmm0
paddd  %xmm4,%xmm0
movdqa %xmm3,%xmm2
paddd  %xmm5,%xmm2
movdqa %xmm0,-0x30(%rsp,%rax,4)
movdqa %xmm2,-0x20(%rsp,%rax,4)
cmp    $0xfc,%rax
je     121c <main+0xdc>
movdqa %xmm3,%xmm0
paddd  %xmm6,%xmm0
movdqa %xmm3,%xmm2
paddd  %xmm7,%xmm2
movdqa %xmm0,-0x10(%rsp,%rax,4)
movdqa %xmm2,(%rsp,%rax,4)
paddd  %xmm1,%xmm3
add    $0x20,%rax
jmp    11a0 <main+0x60>
movaps 0xe6d(%rip),%xmm0
movaps %xmm0,0x3e0(%rsp)
movabs $0x200000003,%rax
mov    %rax,0x3f0(%rsp)
movl   $0x1,0x3f8(%rsp)
lea    0xe55(%rip),%rdi
call   1040 <puts@plt>
lea    0xe45(%rip),%rbx
xor    %ebp,%ebp
nopl   (%rax)
mov    (%rsp,%rbp,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    $0xff,%rbp
jne    1260 <main+0x120>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rsp,%rdi
mov    $0xff,%esi
call   1060 <BubbleSort@plt>
lea    0xe21(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
mov    $0xcccccccd,%r14d
lea    0xdf1(%rip),%r15
xor    %ebx,%ebx
jmp    12d0 <main+0x190>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
add    $0x1,%ebp
cmp    $0xff,%rbx
je     1303 <main+0x1c3>
mov    %ebp,%eax
imul   %r14,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,1),%r12d
add    $0xffffffff,%r12d
mov    (%rsp,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %ebx,%r12d
jne    12c0 <main+0x180>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    12c0 <main+0x180>
mov    %rsp,%rdi
mov    $0xff,%esi
call   1060 <BubbleSort@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdad(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
mov    $0xcccccccd,%r14d
lea    0xd68(%rip),%r15
xor    %ebx,%ebx
jmp    1350 <main+0x210>
nopl   0x0(%rax)
add    $0x1,%rbx
add    $0x1,%ebp
cmp    $0xff,%rbx
je     1383 <main+0x243>
mov    %ebp,%eax
imul   %r14,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,1),%r12d
add    $0xffffffff,%r12d
mov    (%rsp,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %ebx,%r12d
jne    1340 <main+0x200>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1340 <main+0x200>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\09\00"
@str = [21 x i8] c"----before sort-----\00"
@str.5 = [21 x i8] c"----after sort------\00"
@str.6 = [31 x i8] c"------after another sort------\00"
define i32 @main() {
%1 = alloca [255 x i32]
%2 = bitcast [255 x i32]* %1 to i8*
br label %3
3: ; preds = %27, %0
%4 = phi i64 [ 0, %0 ], [ %34, %27 ]
%5 = phi <4 x i32> [ <i32 255, i32 254, i32 253, i32 252>, %0 ], [ %35, %27 ]
%6 = add <4 x i32> %5, <i32 -4, i32 -4, i32 -4, i32 -4>
%7 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 %4
%8 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> %5, <4 x i32>* %8
%9 = getelementptr inbounds i32, i32* %7, i64 4
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> %6, <4 x i32>* %10
%11 = or i64 %4, 8
%12 = add <4 x i32> %5, <i32 -8, i32 -8, i32 -8, i32 -8>
%13 = add <4 x i32> %5, <i32 -12, i32 -12, i32 -12, i32 -12>
%14 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 %11
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> %12, <4 x i32>* %15
%16 = getelementptr inbounds i32, i32* %14, i64 4
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> %13, <4 x i32>* %17
%18 = or i64 %4, 16
%19 = add <4 x i32> %5, <i32 -16, i32 -16, i32 -16, i32 -16>
%20 = add <4 x i32> %5, <i32 -20, i32 -20, i32 -20, i32 -20>
%21 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 %18
%22 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> %19, <4 x i32>* %22
%23 = getelementptr inbounds i32, i32* %21, i64 4
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> %20, <4 x i32>* %24
%25 = or i64 %4, 24
%26 = icmp eq i64 %25, 248
br i1 %26, label %36, label %27
27: ; preds = %3
%28 = add <4 x i32> %5, <i32 -24, i32 -24, i32 -24, i32 -24>
%29 = add <4 x i32> %5, <i32 -28, i32 -28, i32 -28, i32 -28>
%30 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 %25
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> %28, <4 x i32>* %31
%32 = getelementptr inbounds i32, i32* %30, i64 4
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> %29, <4 x i32>* %33
%34 = add nuw nsw i64 %4, 32
%35 = add <4 x i32> %5, <i32 -32, i32 -32, i32 -32, i32 -32>
br label %3
36: ; preds = %3
%37 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 248
store i32 7, i32* %37
%38 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 249
store i32 6, i32* %38
%39 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 250
store i32 5, i32* %39
%40 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 251
store i32 4, i32* %40
%41 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 252
store i32 3, i32* %41
%42 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 253
store i32 2, i32* %42
%43 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 254
store i32 1, i32* %43
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %50
45: ; preds = %50
%46 = tail call i32 @putchar(i32 10)
%47 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 0
%48 = call i32 @BubbleSort(i32* %47, i32 255)
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
br label %61
50: ; preds = %36, %50
%51 = phi i64 [ 0, %36 ], [ %55, %50 ]
%52 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %53)
%55 = add nuw nsw i64 %51, 1
%56 = icmp eq i64 %55, 255
br i1 %56, label %45, label %50
57: ; preds = %71
%58 = call i32 @BubbleSort(i32* %47, i32 255)
%59 = call i32 @putchar(i32 10)
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.6, i64 0, i64 0))
br label %77
61: ; preds = %45, %71
%62 = phi i64 [ 0, %45 ], [ %72, %71 ]
%63 = phi i32 [ 1, %45 ], [ %73, %71 ]
%64 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 %62
%65 = load i32, i32* %64
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %65)
%67 = urem i32 %63, 10
%68 = icmp eq i32 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %61
%70 = call i32 @putchar(i32 10)
br label %71
71: ; preds = %61, %69
%72 = add nuw nsw i64 %62, 1
%73 = add nuw nsw i32 %63, 1
%74 = icmp eq i64 %72, 255
br i1 %74, label %57, label %61
75: ; preds = %87
%76 = call i32 @putchar(i32 10)
ret i32 0
77: ; preds = %57, %87
%78 = phi i64 [ 0, %57 ], [ %88, %87 ]
%79 = phi i32 [ 1, %57 ], [ %89, %87 ]
%80 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 %78
%81 = load i32, i32* %80
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %81)
%83 = urem i32 %79, 10
%84 = icmp eq i32 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %77
%86 = call i32 @putchar(i32 10)
br label %87
87: ; preds = %77, %85
%88 = add nuw nsw i64 %78, 1
%89 = add nuw nsw i32 %79, 1
%90 = icmp eq i64 %88, 255
br i1 %90, label %75, label %77
}