#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_vector(int *);
int /*<<< orphan*/ quick_sort(int *, int /*<<< orphan*/, int);
int random();
int /*<<< orphan*/ srandomdev();
int main(void) {
  int vector[20], element;
  for (element = 0; element < 20; ++element) {
    srandomdev();
    vector[element] = random() % 10;
  }
  quick_sort(vector, 0, 20 - 1);
  print_vector(vector);
  return 0;
}


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    118c <main+0x4c>
mov    $0x0,%al
call   1040 <srandomdev@plt>
mov    $0x0,%al
call   1030 <random@plt>
mov    $0xa,%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    1156 <main+0x16>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x13,%edx
call   1060 <quick_sort@plt>
lea    -0x60(%rbp),%rdi
call   1050 <print_vector@plt>
xor    %eax,%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   1040 <srandomdev@plt>
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x14,%rbx
jne    1150 <main+0x10>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x13,%edx
call   1060 <quick_sort@plt>
mov    %rbx,%rdi
call   1050 <print_vector@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %14, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 20
br i1 %6, label %7, label %17
7: ; preds = %4
%8 = call i32 (...) @srandomdev()
%9 = call i32 (...) @random()
%10 = srem i32 %9, 10
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %12
store i32 %10, i32* %13
br label %14
14: ; preds = %7
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %4
17: ; preds = %4
%18 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%19 = call i32 @quick_sort(i32* %18, i32 0, i32 19)
%20 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%21 = call i32 @print_vector(i32* %20)
ret i32 0
}

LLVM IR (-O2):
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 ], [ %9, %3 ]
%5 = tail call i32 (...) @srandomdev()
%6 = tail call i32 (...) @random()
%7 = srem i32 %6, 10
%8 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %4
store i32 %7, i32* %8
%9 = add nuw nsw i64 %4, 1
%10 = icmp eq i64 %9, 20
br i1 %10, label %11, label %3
11: ; preds = %3
%12 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%13 = call i32 @quick_sort(i32* %12, i32 0, i32 19)
%14 = call i32 @print_vector(i32* %12)
ret i32 0
}