#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 EXIT_SUCCESS;
int /*<<< orphan*/ quicksort(int *, int *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ wrt(char *, int *, int);
int main(void) {
  int a[100], i;
  srand(time(NULL));
  for (i = 0; i < 100; ++i)
    a[i] = rand() % 1000;
  wrt("Before", a, 100);
  quicksort(a, a + 100 - 1);
  wrt("After", a, 100);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x64,-0x1a4(%rbp)
jge    11ba <main+0x6a>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
movslq -0x1a4(%rbp),%rax
mov    %edx,-0x1a0(%rbp,%rax,4)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    117c <main+0x2c>
lea    -0x1a0(%rbp),%rsi
lea    0xe38(%rip),%rdi
mov    $0x64,%edx
call   1060 <wrt@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
add    $0x190,%rsi
add    $0xfffffffffffffffc,%rsi
call   1030 <quicksort@plt>
lea    -0x1a0(%rbp),%rsi
lea    0xe09(%rip),%rdi
mov    $0x64,%edx
call   1060 <wrt@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x190,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1170 <main+0x20>
lea    0xe57(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x64,%edx
call   1060 <wrt@plt>
lea    0x18c(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <quicksort@plt>
lea    0xe37(%rip),%rdi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1060 <wrt@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
add    $0x190,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Before\00"
@.str.1 = [6 x i8] c"After\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
store i32 0, i32* %3
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 100
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 1000
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [100 x i32], [100 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 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%20 = call i32 @wrt(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %19, i32 100)
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%23 = getelementptr inbounds i32, i32* %22, i64 100
%24 = getelementptr inbounds i32, i32* %23, i64 -1
%25 = call i32 @quicksort(i32* %21, i32* %24)
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%27 = call i32 @wrt(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %26, i32 100)
%28 = load i32, i32* @EXIT_SUCCESS
ret i32 %28
}

LLVM IR (-O2):
@.str = [7 x i8] c"Before\00"
@.str.1 = [6 x i8] c"After\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %10, %5 ]
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 1000
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %6
store i32 %8, i32* %9
%10 = add nuw nsw i64 %6, 1
%11 = icmp eq i64 %10, 100
br i1 %11, label %12, label %5
12: ; preds = %5
%13 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%14 = call i32 @wrt(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %13, i32 100)
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 99
%16 = call i32 @quicksort(i32* %13, i32* %15)
%17 = call i32 @wrt(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %13, i32 100)
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}