#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*/ p_all(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quick_sort(int *, int /*<<< orphan*/, int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(void) {
  int ary[5], i, mod;
  srand((unsigned int)time(NULL));
  for (i = 0, mod = 5 << 3; i < 5; i++)
    ary[i] = rand() % (mod);
  printf("排序前: ");
  p_all(ary, 5);
  quick_sort(ary, 0, 5 - 1);
  printf("排序後: ");
  p_all(ary, 5);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x28,-0x28(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    11b8 <main+0x58>
mov    $0x0,%al
call   1080 <rand@plt>
cltd
idivl  -0x28(%rbp)
movslq -0x24(%rbp),%rax
mov    %edx,-0x20(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118d <main+0x2d>
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1070 <p_all@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <quick_sort@plt>
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1070 <p_all@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
shl    $0x3,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
shl    $0x3,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
shl    $0x3,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
shl    $0x3,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
shl    $0x3,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
lea    0xdba(%rip),%rdi
call   1030 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <p_all@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <quick_sort@plt>
lea    0xd9b(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <p_all@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"\E6\8E\92\E5\BA\8F\E5\89\8D: \00"
@.str.1 = [12 x i8] c"\E6\8E\92\E5\BA\8F\E5\BE\8C: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = call i32 @srand(i32 %6)
store i32 0, i32* %3
store i32 40, i32* %4
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = call i32 (...) @rand()
%13 = load i32, i32* %4
%14 = srem i32 %12, %13
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %16
store i32 %14, i32* %17
br label %18
18: ; preds = %11
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %8
21: ; preds = %8
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%24 = call i32 @p_all(i32* %23, i32 5)
%25 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%26 = call i32 @quick_sort(i32* %25, i32 0, i32 4)
%27 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%28 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%29 = call i32 @p_all(i32* %28, i32 5)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"\E6\8E\92\E5\BA\8F\E5\89\8D: \00"
@.str.1 = [12 x i8] c"\E6\8E\92\E5\BA\8F\E5\BE\8C: \00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = tail call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = tail call i32 @srand(i32 %4)
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 40
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
store i32 %7, i32* %8
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 40
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
store i32 %10, i32* %11
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 40
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
store i32 %13, i32* %14
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 40
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
store i32 %16, i32* %17
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 40
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
store i32 %19, i32* %20
%21 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @p_all(i32* %8, i32 5)
%23 = call i32 @quick_sort(i32* %8, i32 0, i32 4)
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @p_all(i32* %8, i32 5)
ret i32 0
}