#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);
int rand();
int /*<<< orphan*/ show(char *, int *, int);
int /*<<< orphan*/ sort(int *, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int main(void) {
  int i, j, a[10];
  srand(0);
  for (j = 1; j <= 5; j++) {
    for (i = 0; i < 10; i++) {
      a[i] = rand() % 100;
    }
    printf("Test #%d\n", j);
    show("Sorting", a, 10);
    sort(a, 10);
    show("Sorted ", a, 10);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1060 <srand@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jg     1202 <main+0xb2>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11ad <main+0x5d>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
movslq -0x8(%rbp),%rax
mov    %edx,-0x40(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117e <main+0x2e>
mov    -0xc(%rbp),%esi
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe43(%rip),%rdi
mov    $0xa,%edx
call   1050 <show@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1040 <sort@plt>
lea    -0x40(%rbp),%rsi
lea    0xe28(%rip),%rdi
mov    $0xa,%edx
call   1050 <show@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116d <main+0x1d>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
xor    %edi,%edi
call   1060 <srand@plt>
mov    $0x1,%ebx
lea    0xe90(%rip),%r14
lea    0xe93(%rip),%r15
mov    %rsp,%r12
lea    0xe91(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x18(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x1c(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x24(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1050 <show@plt>
mov    %r12,%rdi
mov    $0xa,%esi
call   1040 <sort@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1050 <show@plt>
add    $0x1,%ebx
cmp    $0x6,%ebx
jne    1190 <main+0x40>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Test #%d\0A\00"
@.str.1 = [8 x i8] c"Sorting\00"
@.str.2 = [8 x i8] c"Sorted \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i32]
store i32 0, i32* %1
%5 = call i32 @srand(i32 0)
store i32 1, i32* %3
br label %6
6: ; preds = %31, %0
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 5
br i1 %8, label %9, label %34
9: ; preds = %6
store i32 0, i32* %2
br label %10
10: ; preds = %19, %9
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 100
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %17
store i32 %15, i32* %18
br label %19
19: ; preds = %13
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %10
22: ; preds = %10
%23 = load i32, i32* %3
%24 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%26 = call i32 @show(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %25, i32 10)
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%28 = call i32 @sort(i32* %27, i32 10)
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%30 = call i32 @show(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %29, i32 10)
br label %31
31: ; preds = %22
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %6
34: ; preds = %6
ret i32 0
}

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