#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 */
typedef int /*<<< orphan*/ gaps;

/* Variables and functions */
int /*<<< orphan*/ shellSortPhase(unsigned int *, unsigned int, int const);
int /*<<< orphan*/ tty_puts(char *);
void shellSort(unsigned int *base, unsigned int n) {
  static const int gaps[] = {1, 4, 10, 23, 57, 132, 301, 701};
  int sizeIndex;
  tty_puts("Shell Sort\n");
  for (sizeIndex = sizeof(gaps) / sizeof(gaps[0]) - 1; sizeIndex >= 0;
       --sizeIndex)
    shellSortPhase(base, n, gaps[sizeIndex]);
}


x86 assembly (clang, -O0):
<shellSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeea(%rip),%rdi
call   1040 <tty_puts@plt>
movl   $0x7,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1174 <shellSort+0x54>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movslq -0x10(%rbp),%rcx
lea    0xea2(%rip),%rax
mov    (%rax,%rcx,4),%edx
call   1030 <shellSortPhase@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1142 <shellSort+0x22>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shellSort>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xed1(%rip),%rdi
call   1040 <tty_puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x2bd,%edx
call   1030 <shellSortPhase@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x12d,%edx
call   1030 <shellSortPhase@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x84,%edx
call   1030 <shellSortPhase@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x39,%edx
call   1030 <shellSortPhase@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x17,%edx
call   1030 <shellSortPhase@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0xa,%edx
call   1030 <shellSortPhase@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x4,%edx
call   1030 <shellSortPhase@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <shellSortPhase@plt>

LLVM IR (-O0):
@shellSort.gaps = internal constant [8 x i32] [i32 1, i32 4, i32 10, i32 23, i32 57, i32 132, i32 301, i32 701]
@.str = [12 x i8] c"Shell Sort\0A\00"
define void @shellSort(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = call i32 @tty_puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 7, i32* %5
br label %7
7: ; preds = %18, %2
%8 = load i32, i32* %5
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load i32*, i32** %3
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [8 x i32], [8 x i32]* @shellSort.gaps, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = call i32 @shellSortPhase(i32* %11, i32 %12, i32 %16)
br label %18
18: ; preds = %10
%19 = load i32, i32* %5
%20 = add nsw i32 %19, -1
store i32 %20, i32* %5
br label %7
21: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Shell Sort\0A\00"
define void @shellSort(i32* %0, i32 %1) {
%3 = tail call i32 @tty_puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @shellSortPhase(i32* %0, i32 %1, i32 701)
%5 = tail call i32 @shellSortPhase(i32* %0, i32 %1, i32 301)
%6 = tail call i32 @shellSortPhase(i32* %0, i32 %1, i32 132)
%7 = tail call i32 @shellSortPhase(i32* %0, i32 %1, i32 57)
%8 = tail call i32 @shellSortPhase(i32* %0, i32 %1, i32 23)
%9 = tail call i32 @shellSortPhase(i32* %0, i32 %1, i32 10)
%10 = tail call i32 @shellSortPhase(i32* %0, i32 %1, i32 4)
%11 = tail call i32 @shellSortPhase(i32* %0, i32 %1, i32 1)
ret void
}