#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ print_array(int *);
int rand();
int /*<<< orphan*/ stdout;
int main() {
  int iarray[20];
  int x, y, holder;
  for (x = 0; x < 20; x++)
    iarray[x] = (int)(rand() % 100);
  fprintf(stdout, "Before Sort\n---------------\n");
  print_array(iarray);
  for (x = 0; x < 20; x++)
    for (y = 0; y < 20 - 1; y++)
      if (iarray[y] > iarray[y + 1]) {
        holder = iarray[y + 1];
        iarray[y + 1] = iarray[y];
        iarray[y] = holder;
      }
  fprintf(stdout, "\nAfter Sort\n---------------\n");
  print_array(iarray);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x14,-0x64(%rbp)
jge    1175 <main+0x45>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
movslq -0x64(%rbp),%rax
mov    %edx,-0x60(%rbp,%rax,4)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1146 <main+0x16>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
call   1040 <fprintf@plt>
lea    -0x60(%rbp),%rdi
call   1030 <print_array@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0x14,-0x64(%rbp)
jge    1224 <main+0xf4>
movl   $0x0,-0x68(%rbp)
cmpl   $0x13,-0x68(%rbp)
jge    1211 <main+0xe1>
movslq -0x68(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%eax
mov    -0x68(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x60(%rbp,%rcx,4),%eax
jle    11fe <main+0xce>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x60(%rbp,%rax,4),%eax
mov    %eax,-0x6c(%rbp)
movslq -0x68(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%ecx
mov    -0x68(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x60(%rbp,%rax,4)
mov    -0x6c(%rbp),%ecx
movslq -0x68(%rbp),%rax
mov    %ecx,-0x60(%rbp,%rax,4)
jmp    1203 <main+0xd3>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11ab <main+0x7b>
jmp    1216 <main+0xe6>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    119a <main+0x6a>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
lea    0xde9(%rip),%rsi
call   1040 <fprintf@plt>
lea    -0x60(%rbp),%rdi
call   1030 <print_array@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x14,%rbx
jne    1140 <main+0x10>
mov    0x2e6a(%rip),%rbx
mov    (%rbx),%edi
lea    0xe81(%rip),%rsi
call   1040 <fprintf@plt>
mov    %rsp,%rdi
call   1030 <print_array@plt>
xor    %eax,%eax
jmp    1198 <main+0x68>
add    $0x1,%eax
cmp    $0x14,%eax
je     11ec <main+0xbc>
mov    $0x2,%ecx
mov    (%rsp),%edx
jmp    11b6 <main+0x86>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %esi,%edx
add    $0x2,%rcx
mov    -0x4(%rsp,%rcx,4),%esi
cmp    %esi,%edx
jle    11d0 <main+0xa0>
mov    %edx,-0x4(%rsp,%rcx,4)
mov    %esi,-0x8(%rsp,%rcx,4)
cmp    $0x14,%rcx
jne    11d8 <main+0xa8>
jmp    1190 <main+0x60>
xchg   %ax,%ax
mov    %esi,%edx
cmp    $0x14,%rcx
je     1190 <main+0x60>
mov    (%rsp,%rcx,4),%esi
cmp    %esi,%edx
jle    11b0 <main+0x80>
mov    %edx,(%rsp,%rcx,4)
mov    %esi,-0x4(%rsp,%rcx,4)
add    $0x2,%rcx
jmp    11b6 <main+0x86>
mov    (%rbx),%edi
lea    0xe28(%rip),%rsi
call   1040 <fprintf@plt>
mov    %rsp,%rdi
call   1030 <print_array@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@stdout = global i32 0
@.str = [29 x i8] c"Before Sort\0A---------------\0A\00"
@.str.1 = [29 x i8] c"\0AAfter Sort\0A---------------\0A\00"
define i32 @main() {
%1 = alloca [20 x i32]
%2 = bitcast [20 x i32]* %1 to i8*
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %8, %3 ]
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 100
%7 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %4
store i32 %6, i32* %7
%8 = add nuw nsw i64 %4, 1
%9 = icmp eq i64 %8, 20
br i1 %9, label %10, label %3
10: ; preds = %3
%11 = load i32, i32* @stdout
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%14 = call i32 @print_array(i32* %13)
br label %15
15: ; preds = %10, %39
%16 = phi i32 [ 0, %10 ], [ %40, %39 ]
%17 = load i32, i32* %13
br label %18
18: ; preds = %37, %15
%19 = phi i32 [ %17, %15 ], [ %38, %37 ]
%20 = phi i64 [ 0, %15 ], [ %31, %37 ]
%21 = or i64 %20, 1
%22 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp sgt i32 %19, %23
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %20
store i32 %19, i32* %22
store i32 %23, i32* %26
br label %27
27: ; preds = %18, %25
%28 = phi i32 [ %23, %18 ], [ %19, %25 ]
%29 = icmp eq i64 %21, 19
br i1 %29, label %39, label %30
30: ; preds = %27
%31 = add nuw nsw i64 %20, 2
%32 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = icmp sgt i32 %28, %33
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %21
store i32 %28, i32* %32
store i32 %33, i32* %36
br label %37
37: ; preds = %35, %30
%38 = phi i32 [ %33, %30 ], [ %28, %35 ]
br label %18
39: ; preds = %27
%40 = add nuw nsw i32 %16, 1
%41 = icmp eq i32 %40, 20
br i1 %41, label %42, label %15
42: ; preds = %39
%43 = load i32, i32* @stdout
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%45 = call i32 @print_array(i32* %13)
ret i32 0
}