#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 */
scalar_t__ pow(int, int);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ shell_sort(int *, int);
int /*<<< orphan*/ show(int *, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  srand(time(NULL));
  int i, numbers[10];
  for (i = 0; i < 10; i++) {
    int exp = (int)pow(10, rand() % 4 + 1);
    numbers[i] = rand() % exp;
  }
  printf("排序前的随机数：\n");
  show(numbers, 10);
  printf("希尔排序：\n");
  shell_sort(numbers, 10);
  show(numbers, 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11e2 <main+0x72>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x1,%esi
mov    $0xa,%edi
call   1070 <pow@plt>
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
cltd
idivl  -0x34(%rbp)
movslq -0x8(%rbp),%rax
mov    %edx,-0x30(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1196 <main+0x26>
lea    0xe17(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1040 <show@plt>
lea    0xe17(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1080 <shell_sort@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1040 <show@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%esi
add    $0x1,%esi
mov    $0xa,%edi
call   1070 <pow@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1090 <rand@plt>
cltd
idiv   %r14d
mov    %edx,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0xa,%rbx
jne    1190 <main+0x20>
lea    0xe2a(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <show@plt>
lea    0xe27(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1080 <shell_sort@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <show@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
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\B8\8C\E5\B0\94\E6\8E\92\E5\BA\8F\EF\BC\9A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i32]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
store i32 0, i32* %2
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 4
%13 = add nsw i32 %12, 1
%14 = call i64 @pow(i32 10, i32 %13)
%15 = trunc i64 %14 to i32
store i32 %15, i32* %4
%16 = call i32 (...) @rand()
%17 = load i32, i32* %4
%18 = srem i32 %16, %17
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %20
store i32 %18, i32* %21
br label %22
22: ; preds = %10
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %7
25: ; preds = %7
%26 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%28 = call i32 @show(i32* %27, i32 10)
%29 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%31 = call i32 @shell_sort(i32* %30, i32 10)
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%33 = call i32 @show(i32* %32, 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\B8\8C\E5\B0\94\E6\8E\92\E5\BA\8F\EF\BC\9A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = bitcast [10 x i32]* %1 to i8*
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %15, %5 ]
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 4
%9 = add nsw i32 %8, 1
%10 = tail call i64 @pow(i32 10, i32 %9)
%11 = trunc i64 %10 to i32
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, %11
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %6
store i32 %13, i32* %14
%15 = add nuw nsw i64 %6, 1
%16 = icmp eq i64 %15, 10
br i1 %16, label %17, label %5
17: ; preds = %5
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%20 = call i32 @show(i32* %19, i32 10)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.2, i64 0, i64 0))
%22 = call i32 @shell_sort(i32* %19, i32 10)
%23 = call i32 @show(i32* %19, i32 10)
ret i32 0
}