#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*/ merge_sort(int *, int);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ show(int *, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  srand(time(NULL));
  int i, numbers[10];
  for (i = 0; i < 10; ++i) {
    numbers[i] = rand() % 1000;
  }
  printf("排序前的随机数：\n");
  show(numbers, 10);
  merge_sort(numbers, 10);
  printf("归并排序：\n");
  show(numbers, 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11bc <main+0x5c>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
movslq -0x14(%rbp),%rax
mov    %edx,-0x40(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118d <main+0x2d>
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1040 <show@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1070 <merge_sort@plt>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1040 <show@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x18(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x1c(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x24(%rsp)
lea    0xccf(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <show@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <merge_sort@plt>
lea    0xcbf(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <show@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@str = [25 x i8] c"\E6\8E\92\E5\BA\8F\E5\89\8D\E7\9A\84\E9\9A\8F\E6\9C\BA\E6\95\B0\EF\BC\9A\00"
@str.2 = [16 x i8] c"\E5\BD\92\E5\B9\B6\E6\8E\92\E5\BA\8F\EF\BC\9A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i32]
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = bitcast [10 x i32]* %3 to i8*
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 1000
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 %8, i32* %9
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 1000
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
store i32 %11, i32* %12
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 1000
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
store i32 %14, i32* %15
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 1000
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 3
store i32 %17, i32* %18
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 1000
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 4
store i32 %20, i32* %21
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 1000
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 5
store i32 %23, i32* %24
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, 1000
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 6
store i32 %26, i32* %27
%28 = tail call i32 (...) @rand()
%29 = srem i32 %28, 1000
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 7
store i32 %29, i32* %30
%31 = tail call i32 (...) @rand()
%32 = srem i32 %31, 1000
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 8
store i32 %32, i32* %33
%34 = tail call i32 (...) @rand()
%35 = srem i32 %34, 1000
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 9
store i32 %35, i32* %36
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%38 = call i32 @show(i32* %9, i32 10)
%39 = call i32 @merge_sort(i32* %9, i32 10)
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.2, i64 0, i64 0))
%41 = call i32 @show(i32* %9, i32 10)
ret i32 0
}