#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*/ print(int *, int);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sort(int *, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int Data1[5] = {5, 10, 2, 6, 3}, Data2[10], Data3[30], i;
  sort(Data1, 5);
  printf("Sorted: ");
  print(Data1, 5);
  printf("Read 10 values: ");
  for (i = 0; i < 10; i++)
    scanf("%d", &Data2[i]);
  sort(Data2, 10);
  printf("\nSorted: ");
  print(Data2, 10);
  srand(time(NULL));
  for (i = 0; i < 30; i++)
    Data3[i] = rand() % 100;
  printf("Unsorted: ");
  print(Data3, 30);
  sort(Data3, 30);
  printf("Sorted: ");
  print(Data3, 30);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe77(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe74(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe72(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1040 <sort@plt>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1050 <print@plt>
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xd4(%rbp)
cmpl   $0xa,-0xd4(%rbp)
jge    121e <main+0xae>
movslq -0xd4(%rbp),%rax
lea    -0x50(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe20(%rip),%rdi
call   1080 <scanf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    11df <main+0x6f>
lea    -0x50(%rbp),%rdi
mov    $0xa,%esi
call   1040 <sort@plt>
lea    0xdf5(%rip),%rdi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    $0xa,%esi
call   1050 <print@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0x0,-0xd4(%rbp)
cmpl   $0x1e,-0xd4(%rbp)
jge    129e <main+0x12e>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
movslq -0xd4(%rbp),%rax
mov    %edx,-0xd0(%rbp,%rax,4)
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1260 <main+0xf0>
lea    0xd8d(%rip),%rdi
call   1030 <printf@plt>
lea    -0xd0(%rbp),%rdi
mov    $0x1e,%esi
call   1050 <print@plt>
lea    -0xd0(%rbp),%rdi
mov    $0x1e,%esi
call   1040 <sort@plt>
lea    0xd56(%rip),%rdi
call   1030 <printf@plt>
lea    -0xd0(%rbp),%rdi
mov    $0x1e,%esi
call   1050 <print@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xc8,%rsp
mov    0xe90(%rip),%eax
mov    %eax,0x40(%rsp)
movaps 0xe75(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <sort@plt>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <print@plt>
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
lea    0xe57(%rip),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1040 <sort@plt>
lea    0xdc3(%rip),%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <print@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <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,0x50(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x1e,%rbx
jne    1290 <main+0x120>
lea    0xd6b(%rip),%rdi
call   1030 <printf@plt>
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1050 <print@plt>
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1040 <sort@plt>
lea    0xd37(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1050 <print@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.Data1 = [5 x i32] [i32 5, i32 10, i32 2, i32 6, i32 3]
@.str = [9 x i8] c"Sorted: \00"
@.str.1 = [17 x i8] c"Read 10 values: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [10 x i8] c"\0ASorted: \00"
@.str.4 = [11 x i8] c"Unsorted: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca [10 x i32]
%4 = alloca [30 x i32]
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [5 x i32]* %2 to i8*
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%8 = call i32 @sort(i32* %7, i32 5)
%9 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%11 = call i32 @print(i32* %10, i32 5)
%12 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %13
13: ; preds = %21, %0
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 10
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %18
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %19)
br label %21
21: ; preds = %16
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %13
24: ; preds = %13
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%26 = call i32 @sort(i32* %25, i32 10)
%27 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%29 = call i32 @print(i32* %28, i32 10)
%30 = call i32 @time(i32* null)
%31 = call i32 @srand(i32 %30)
store i32 0, i32* %5
br label %32
32: ; preds = %41, %24
%33 = load i32, i32* %5
%34 = icmp slt i32 %33, 30
br i1 %34, label %35, label %44
35: ; preds = %32
%36 = call i32 (...) @rand()
%37 = srem i32 %36, 100
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [30 x i32], [30 x i32]* %4, i64 0, i64 %39
store i32 %37, i32* %40
br label %41
41: ; preds = %35
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %32
44: ; preds = %32
%45 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%46 = getelementptr inbounds [30 x i32], [30 x i32]* %4, i64 0, i64 0
%47 = call i32 @print(i32* %46, i32 30)
%48 = getelementptr inbounds [30 x i32], [30 x i32]* %4, i64 0, i64 0
%49 = call i32 @sort(i32* %48, i32 30)
%50 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%51 = getelementptr inbounds [30 x i32], [30 x i32]* %4, i64 0, i64 0
%52 = call i32 @print(i32* %51, i32 30)
ret i32 0
}

LLVM IR (-O2):
@__const.main.Data1 = [5 x i32] [i32 5, i32 10, i32 2, i32 6, i32 3]
@.str = [9 x i8] c"Sorted: \00"
@.str.1 = [17 x i8] c"Read 10 values: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [10 x i8] c"\0ASorted: \00"
@.str.4 = [11 x i8] c"Unsorted: \00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca [10 x i32]
%3 = alloca [30 x i32]
%4 = bitcast [5 x i32]* %1 to i8*
%5 = bitcast [10 x i32]* %2 to i8*
%6 = bitcast [30 x i32]* %3 to i8*
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%8 = call i32 @sort(i32* %7, i32 5)
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @print(i32* %7, i32 5)
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %12)
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 1
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %14)
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 2
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %16)
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 3
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %18)
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 4
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %20)
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 5
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %22)
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 6
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %24)
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 7
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %26)
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 8
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %28)
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 9
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %30)
%32 = call i32 @sort(i32* %12, i32 10)
%33 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @print(i32* %12, i32 10)
%35 = call i32 @time(i32* null)
%36 = call i32 @srand(i32 %35)
br label %37
37: ; preds = %0, %37
%38 = phi i64 [ 0, %0 ], [ %42, %37 ]
%39 = call i32 (...) @rand()
%40 = srem i32 %39, 100
%41 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 %38
store i32 %40, i32* %41
%42 = add nuw nsw i64 %38, 1
%43 = icmp eq i64 %42, 30
br i1 %43, label %44, label %37
44: ; preds = %37
%45 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%46 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 0
%47 = call i32 @print(i32* %46, i32 30)
%48 = call i32 @sort(i32* %46, i32 30)
%49 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%50 = call i32 @print(i32* %46, i32 30)
ret i32 0
}