#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*/ printf(char *, ...);
int rand();
void mod_shell_sort() {
  int a[20], i, j, gap, t, x;
  for (i = 0; i < 20; i++) {
    a[i] = rand();
  }
  for (gap = 1; gap < 20 / 3; gap = 3 * gap + 1)
    ;
  printf("gap %d\n", gap);
  for (x = 0; x < 20; x++)
    printf("%8d", a[x]);
  printf("\n");
  while (gap > 0) {
    for (i = gap; i < 20; i++) {
      for (j = i - gap; j >= 0; j = j - gap) {
        if (a[j] > a[j + gap]) {
          t = a[j];
          a[j] = a[j + gap];
          a[j + gap] = t;
        } else {
          break;
        }
      }
    }
    gap = gap / 3;
  }
  for (i = 0; i < 20; i++)
    printf("%8d", a[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<mod_shell_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x54(%rbp)
cmpl   $0x14,-0x54(%rbp)
jge    1158 <mod_shell_sort+0x38>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %eax,%ecx
movslq -0x54(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    112f <mod_shell_sort+0xf>
movl   $0x1,-0x5c(%rbp)
cmpl   $0x6,-0x5c(%rbp)
jge    117d <mod_shell_sort+0x5d>
jmp    116e <mod_shell_sort+0x4e>
imul   $0x3,-0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    115f <mod_shell_sort+0x3f>
mov    -0x5c(%rbp),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0x14,-0x64(%rbp)
jge    11c3 <mod_shell_sort+0xa3>
movslq -0x64(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1195 <mod_shell_sort+0x75>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x5c(%rbp)
jle    128a <mod_shell_sort+0x16a>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x14,-0x54(%rbp)
jge    1277 <mod_shell_sort+0x157>
mov    -0x54(%rbp),%eax
sub    -0x5c(%rbp),%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jl     1264 <mod_shell_sort+0x144>
movslq -0x58(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
mov    -0x58(%rbp),%ecx
add    -0x5c(%rbp),%ecx
movslq %ecx,%rcx
cmp    -0x50(%rbp,%rcx,4),%eax
jle    124c <mod_shell_sort+0x12c>
movslq -0x58(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
mov    %eax,-0x60(%rbp)
mov    -0x58(%rbp),%eax
add    -0x5c(%rbp),%eax
cltq
mov    -0x50(%rbp,%rax,4),%ecx
movslq -0x58(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x60(%rbp),%ecx
mov    -0x58(%rbp),%eax
add    -0x5c(%rbp),%eax
cltq
mov    %ecx,-0x50(%rbp,%rax,4)
jmp    1251 <mod_shell_sort+0x131>
jmp    1264 <mod_shell_sort+0x144>
jmp    1256 <mod_shell_sort+0x136>
mov    -0x58(%rbp),%eax
sub    -0x5c(%rbp),%eax
mov    %eax,-0x58(%rbp)
jmp    11f4 <mod_shell_sort+0xd4>
jmp    1269 <mod_shell_sort+0x149>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11e1 <mod_shell_sort+0xc1>
mov    -0x5c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x5c(%rbp)
jmp    11d1 <mod_shell_sort+0xb1>
movl   $0x0,-0x54(%rbp)
cmpl   $0x14,-0x54(%rbp)
jge    12bf <mod_shell_sort+0x19f>
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%esi
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1291 <mod_shell_sort+0x171>
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod_shell_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0xc(%rsp)
mov    %eax,0x40(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x10(%rsp)
mov    %eax,0x44(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x14(%rsp)
mov    %eax,0x48(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x18(%rsp)
mov    %eax,0x4c(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x1c(%rsp)
mov    %eax,0x50(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x20(%rsp)
mov    %eax,0x54(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x24(%rsp)
mov    %eax,0x58(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x3c(%rsp)
mov    %eax,0x5c(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x38(%rsp)
mov    %eax,0x60(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x34(%rsp)
mov    %eax,0x64(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x30(%rsp)
mov    %eax,0x68(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x2c(%rsp)
mov    %eax,0x6c(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x28(%rsp)
mov    %eax,0x70(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0xa4(%rsp)
mov    %eax,0x74(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x8(%rsp)
mov    %eax,0x78(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%r13d
mov    %eax,0x7c(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x98(%rsp)
mov    %eax,0x80(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%r15d
mov    %eax,0x84(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x9c(%rsp)
mov    %eax,0x88(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0xa0(%rsp)
mov    %eax,0x8c(%rsp)
lea    0xd76(%rip),%rdi
mov    $0xd,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd6b(%rip),%r12
mov    %r12,%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x14(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x18(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x1c(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x20(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x24(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x3c(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x38(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x34(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x30(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x2c(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x28(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0xa4(%rsp),%ebp
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13d,%ebx
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x98(%rsp),%esi
mov    %esi,%r13d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r15d,%r14d
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x9c(%rsp),%esi
mov    %esi,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0xa0(%rsp),%esi
mov    %esi,%r12d
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jle    13ea <mod_shell_sort+0x2ba>
mov    %ebp,0x40(%rsp)
mov    %eax,0x74(%rsp)
mov    0x10(%rsp),%eax
mov    0x8(%rsp),%ecx
cmp    %ecx,%eax
jle    13fe <mod_shell_sort+0x2ce>
mov    %ecx,0x44(%rsp)
mov    %eax,0x78(%rsp)
mov    0x14(%rsp),%edi
cmp    %ebx,%edi
mov    0x24(%rsp),%eax
mov    0x20(%rsp),%ecx
mov    0x1c(%rsp),%edx
mov    0x18(%rsp),%esi
jg     16c4 <mod_shell_sort+0x594>
cmp    %r13d,%esi
jg     16d5 <mod_shell_sort+0x5a5>
cmp    %r14d,%edx
jg     16ea <mod_shell_sort+0x5ba>
cmp    %r15d,%ecx
jg     16ff <mod_shell_sort+0x5cf>
cmp    %r12d,%eax
jle    1446 <mod_shell_sort+0x316>
mov    %r12d,0x58(%rsp)
mov    %eax,0x8c(%rsp)
xor    %eax,%eax
jmp    1459 <mod_shell_sort+0x329>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
cmp    $0x10,%eax
je     14bd <mod_shell_sort+0x38d>
mov    0x40(%rsp,%rax,4),%ecx
mov    0x50(%rsp,%rax,4),%edx
cmp    %edx,%ecx
jle    1450 <mod_shell_sort+0x320>
mov    %edx,0x40(%rsp,%rax,4)
mov    %ecx,0x50(%rsp,%rax,4)
cmp    $0x4,%rax
jb     1450 <mod_shell_sort+0x320>
mov    0x30(%rsp,%rax,4),%ecx
mov    0x40(%rsp,%rax,4),%edx
cmp    %edx,%ecx
jle    1450 <mod_shell_sort+0x320>
mov    %edx,0x30(%rsp,%rax,4)
mov    %ecx,0x40(%rsp,%rax,4)
cmp    $0x8,%rax
jb     1450 <mod_shell_sort+0x320>
mov    0x20(%rsp,%rax,4),%ecx
mov    0x30(%rsp,%rax,4),%edx
cmp    %edx,%ecx
jle    1450 <mod_shell_sort+0x320>
mov    %edx,0x20(%rsp,%rax,4)
mov    %ecx,0x30(%rsp,%rax,4)
cmp    $0xc,%rax
jb     1450 <mod_shell_sort+0x320>
mov    0x10(%rsp,%rax,4),%ecx
mov    0x20(%rsp,%rax,4),%edx
cmp    %edx,%ecx
jle    1450 <mod_shell_sort+0x320>
mov    %edx,0x10(%rsp,%rax,4)
mov    %ecx,0x20(%rsp,%rax,4)
jmp    1450 <mod_shell_sort+0x320>
mov    $0x1,%eax
jmp    14d9 <mod_shell_sort+0x3a9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rax
cmp    $0x14,%eax
je     14fc <mod_shell_sort+0x3cc>
mov    %rax,%rcx
nopl   0x0(%rax)
mov    0x3c(%rsp,%rcx,4),%edx
mov    0x40(%rsp,%rcx,4),%esi
cmp    %esi,%edx
jle    14d0 <mod_shell_sort+0x3a0>
mov    %esi,0x3c(%rsp,%rcx,4)
mov    %edx,0x40(%rsp,%rcx,4)
add    $0xffffffffffffffff,%rcx
jg     14e0 <mod_shell_sort+0x3b0>
jmp    14d0 <mod_shell_sort+0x3a0>
mov    0x40(%rsp),%esi
mov    0x44(%rsp),%r13d
mov    0x48(%rsp),%r12d
mov    0x4c(%rsp),%r15d
mov    0x50(%rsp),%r14d
mov    0x54(%rsp),%ebx
mov    0x58(%rsp),%eax
mov    %eax,0x28(%rsp)
mov    0x5c(%rsp),%eax
mov    %eax,0x2c(%rsp)
mov    0x60(%rsp),%eax
mov    %eax,0x30(%rsp)
mov    0x64(%rsp),%eax
mov    %eax,0x34(%rsp)
mov    0x68(%rsp),%eax
mov    %eax,0x38(%rsp)
mov    0x6c(%rsp),%eax
mov    %eax,0x3c(%rsp)
mov    0x70(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    0x74(%rsp),%eax
mov    %eax,0xc(%rsp)
mov    0x78(%rsp),%eax
mov    %eax,0x10(%rsp)
mov    0x7c(%rsp),%eax
mov    %eax,0x14(%rsp)
mov    0x80(%rsp),%eax
mov    %eax,0x18(%rsp)
mov    0x84(%rsp),%eax
mov    %eax,0x1c(%rsp)
mov    0x88(%rsp),%eax
mov    %eax,0x20(%rsp)
mov    0x8c(%rsp),%eax
mov    %eax,0x24(%rsp)
lea    0xa6d(%rip),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x28(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x2c(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x30(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x34(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x38(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x3c(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x14(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x18(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x1c(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x20(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x24(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
mov    %ebx,0x48(%rsp)
mov    %edi,0x7c(%rsp)
cmp    %r13d,%esi
jle    1423 <mod_shell_sort+0x2f3>
mov    %r13d,0x4c(%rsp)
mov    %esi,0x80(%rsp)
cmp    %r14d,%edx
jle    142c <mod_shell_sort+0x2fc>
mov    %r14d,0x50(%rsp)
mov    %edx,0x84(%rsp)
cmp    %r15d,%ecx
jle    1435 <mod_shell_sort+0x305>
mov    %r15d,0x54(%rsp)
mov    %ecx,0x88(%rsp)
cmp    %r12d,%eax
jg     143a <mod_shell_sort+0x30a>
jmp    1446 <mod_shell_sort+0x316>

LLVM IR (-O0):
@.str = [8 x i8] c"gap %d\0A\00"
@.str.1 = [4 x i8] c"%8d\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @mod_shell_sort() {
%1 = alloca [20 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %2
br label %7
7: ; preds = %15, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 20
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = call i32 (...) @rand()
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %13
store i32 %11, i32* %14
br label %15
15: ; preds = %10
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %7
18: ; preds = %7
store i32 1, i32* %4
br label %19
19: ; preds = %23, %18
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 6
br i1 %21, label %22, label %27
22: ; preds = %19
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
%25 = mul nsw i32 3, %24
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %19
27: ; preds = %19
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %28)
store i32 0, i32* %6
br label %30
30: ; preds = %39, %27
%31 = load i32, i32* %6
%32 = icmp slt i32 %31, 20
br i1 %32, label %33, label %42
33: ; preds = %30
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %33
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %30
42: ; preds = %30
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %101, %42
%45 = load i32, i32* %4
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %104
47: ; preds = %44
%48 = load i32, i32* %4
store i32 %48, i32* %2
br label %49
49: ; preds = %98, %47
%50 = load i32, i32* %2
%51 = icmp slt i32 %50, 20
br i1 %51, label %52, label %101
52: ; preds = %49
%53 = load i32, i32* %2
%54 = load i32, i32* %4
%55 = sub nsw i32 %53, %54
store i32 %55, i32* %3
br label %56
56: ; preds = %93, %52
%57 = load i32, i32* %3
%58 = icmp sge i32 %57, 0
br i1 %58, label %59, label %97
59: ; preds = %56
%60 = load i32, i32* %3
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %61
%63 = load i32, i32* %62
%64 = load i32, i32* %3
%65 = load i32, i32* %4
%66 = add nsw i32 %64, %65
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = icmp sgt i32 %63, %69
br i1 %70, label %71, label %91
71: ; preds = %59
%72 = load i32, i32* %3
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %73
%75 = load i32, i32* %74
store i32 %75, i32* %5
%76 = load i32, i32* %3
%77 = load i32, i32* %4
%78 = add nsw i32 %76, %77
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %79
%81 = load i32, i32* %80
%82 = load i32, i32* %3
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %83
store i32 %81, i32* %84
%85 = load i32, i32* %5
%86 = load i32, i32* %3
%87 = load i32, i32* %4
%88 = add nsw i32 %86, %87
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %89
store i32 %85, i32* %90
br label %92
91: ; preds = %59
br label %97
92: ; preds = %71
br label %93
93: ; preds = %92
%94 = load i32, i32* %3
%95 = load i32, i32* %4
%96 = sub nsw i32 %94, %95
store i32 %96, i32* %3
br label %56
97: ; preds = %91, %56
br label %98
98: ; preds = %97
%99 = load i32, i32* %2
%100 = add nsw i32 %99, 1
store i32 %100, i32* %2
br label %49
101: ; preds = %49
%102 = load i32, i32* %4
%103 = sdiv i32 %102, 3
store i32 %103, i32* %4
br label %44
104: ; preds = %44
store i32 0, i32* %2
br label %105
105: ; preds = %114, %104
%106 = load i32, i32* %2
%107 = icmp slt i32 %106, 20
br i1 %107, label %108, label %117
108: ; preds = %105
%109 = load i32, i32* %2
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %110
%112 = load i32, i32* %111
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %112)
br label %114
114: ; preds = %108
%115 = load i32, i32* %2
%116 = add nsw i32 %115, 1
store i32 %116, i32* %2
br label %105
117: ; preds = %105
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"gap %d\0A\00"
@.str.1 = [4 x i8] c"%8d\00"
define void @mod_shell_sort() {
%1 = alloca [20 x i32]
%2 = bitcast [20 x i32]* %1 to i8*
%3 = tail call i32 (...) @rand()
%4 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
store i32 %3, i32* %4
%5 = tail call i32 (...) @rand()
%6 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 1
store i32 %5, i32* %6
%7 = tail call i32 (...) @rand()
%8 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 2
store i32 %7, i32* %8
%9 = tail call i32 (...) @rand()
%10 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 3
store i32 %9, i32* %10
%11 = tail call i32 (...) @rand()
%12 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 4
store i32 %11, i32* %12
%13 = tail call i32 (...) @rand()
%14 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 5
store i32 %13, i32* %14
%15 = tail call i32 (...) @rand()
%16 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 6
store i32 %15, i32* %16
%17 = tail call i32 (...) @rand()
%18 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 7
store i32 %17, i32* %18
%19 = tail call i32 (...) @rand()
%20 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 8
store i32 %19, i32* %20
%21 = tail call i32 (...) @rand()
%22 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 9
store i32 %21, i32* %22
%23 = tail call i32 (...) @rand()
%24 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 10
store i32 %23, i32* %24
%25 = tail call i32 (...) @rand()
%26 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 11
store i32 %25, i32* %26
%27 = tail call i32 (...) @rand()
%28 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 12
store i32 %27, i32* %28
%29 = tail call i32 (...) @rand()
%30 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 13
store i32 %29, i32* %30
%31 = tail call i32 (...) @rand()
%32 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 14
store i32 %31, i32* %32
%33 = tail call i32 (...) @rand()
%34 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 15
store i32 %33, i32* %34
%35 = tail call i32 (...) @rand()
%36 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 16
store i32 %35, i32* %36
%37 = tail call i32 (...) @rand()
%38 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 17
store i32 %37, i32* %38
%39 = tail call i32 (...) @rand()
%40 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 18
store i32 %39, i32* %40
%41 = tail call i32 (...) @rand()
%42 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 19
store i32 %41, i32* %42
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 13)
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%64 = tail call i32 @putchar(i32 10)
%65 = icmp sgt i32 %3, %29
br i1 %65, label %108, label %109
66: ; preds = %191
%67 = load i32, i32* %4
%68 = load i32, i32* %6
%69 = load i32, i32* %8
%70 = load i32, i32* %10
%71 = load i32, i32* %12
%72 = load i32, i32* %14
%73 = load i32, i32* %16
%74 = load i32, i32* %18
%75 = load i32, i32* %20
%76 = load i32, i32* %22
%77 = load i32, i32* %24
%78 = load i32, i32* %26
%79 = load i32, i32* %28
%80 = load i32, i32* %30
%81 = load i32, i32* %32
%82 = load i32, i32* %34
%83 = load i32, i32* %36
%84 = load i32, i32* %38
%85 = load i32, i32* %40
%86 = load i32, i32* %42
%87 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %67)
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %68)
%89 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %69)
%90 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %70)
%91 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %71)
%92 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %72)
%93 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %73)
%94 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %74)
%95 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %75)
%96 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %76)
%97 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %77)
%98 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %78)
%99 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %79)
%100 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %80)
%101 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %81)
%102 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %82)
%103 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %83)
%104 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %84)
%105 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %85)
%106 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %86)
%107 = tail call i32 @putchar(i32 10)
ret void
108: ; preds = %0
store i32 %29, i32* %4
store i32 %3, i32* %30
br label %109
109: ; preds = %108, %0
%110 = icmp sgt i32 %5, %31
br i1 %110, label %111, label %112
111: ; preds = %109
store i32 %31, i32* %6
store i32 %5, i32* %32
br label %112
112: ; preds = %111, %109
%113 = icmp sgt i32 %7, %33
br i1 %113, label %114, label %115
114: ; preds = %112
store i32 %33, i32* %8
store i32 %7, i32* %34
br label %115
115: ; preds = %114, %112
%116 = icmp sgt i32 %9, %35
br i1 %116, label %117, label %118
117: ; preds = %115
store i32 %35, i32* %10
store i32 %9, i32* %36
br label %118
118: ; preds = %117, %115
%119 = icmp sgt i32 %11, %37
br i1 %119, label %120, label %121
120: ; preds = %118
store i32 %37, i32* %12
store i32 %11, i32* %38
br label %121
121: ; preds = %120, %118
%122 = icmp sgt i32 %13, %39
br i1 %122, label %123, label %124
123: ; preds = %121
store i32 %39, i32* %14
store i32 %13, i32* %40
br label %124
124: ; preds = %123, %121
%125 = icmp sgt i32 %15, %41
br i1 %125, label %126, label %127
126: ; preds = %124
store i32 %41, i32* %16
store i32 %15, i32* %42
br label %127
127: ; preds = %124, %126
br label %128
128: ; preds = %127, %171
%129 = phi i64 [ %174, %171 ], [ 0, %127 ]
%130 = phi i32 [ %172, %171 ], [ 4, %127 ]
%131 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %129
%132 = load i32, i32* %131
%133 = zext i32 %130 to i64
%134 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %133
%135 = load i32, i32* %134
%136 = icmp sgt i32 %132, %135
br i1 %136, label %137, label %171
137: ; preds = %128
store i32 %135, i32* %131
store i32 %132, i32* %134
%138 = add nsw i64 %129, -4
%139 = icmp ugt i64 %129, 3
br i1 %139, label %140, label %171
140: ; preds = %137
%141 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %138
%142 = load i32, i32* %141
%143 = shl i64 %129, 32
%144 = ashr exact i64 %143, 32
%145 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %144
%146 = load i32, i32* %145
%147 = icmp sgt i32 %142, %146
br i1 %147, label %148, label %171
148: ; preds = %140
store i32 %146, i32* %141
store i32 %142, i32* %145
%149 = add nsw i64 %129, -8
%150 = icmp ugt i64 %129, 7
br i1 %150, label %151, label %171
151: ; preds = %148
%152 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %149
%153 = load i32, i32* %152
%154 = shl i64 %138, 32
%155 = ashr exact i64 %154, 32
%156 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %155
%157 = load i32, i32* %156
%158 = icmp sgt i32 %153, %157
br i1 %158, label %159, label %171
159: ; preds = %151
store i32 %157, i32* %152
store i32 %153, i32* %156
%160 = icmp ugt i64 %129, 11
br i1 %160, label %161, label %171
161: ; preds = %159
%162 = add nsw i64 %129, -12
%163 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %162
%164 = load i32, i32* %163
%165 = shl i64 %149, 32
%166 = ashr exact i64 %165, 32
%167 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %166
%168 = load i32, i32* %167
%169 = icmp sgt i32 %164, %168
br i1 %169, label %170, label %171
170: ; preds = %161
store i32 %168, i32* %163
store i32 %164, i32* %167
br label %171
171: ; preds = %170, %161, %159, %151, %148, %140, %128, %137
%172 = add nuw nsw i32 %130, 1
%173 = icmp eq i32 %172, 20
%174 = add nuw nsw i64 %129, 1
br i1 %173, label %175, label %128
175: ; preds = %171, %191
%176 = phi i64 [ %194, %191 ], [ 0, %171 ]
%177 = phi i32 [ %192, %191 ], [ 1, %171 ]
br label %178
178: ; preds = %187, %175
%179 = phi i64 [ %188, %187 ], [ %176, %175 ]
%180 = phi i32 [ %190, %187 ], [ %177, %175 ]
%181 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %179
%182 = load i32, i32* %181
%183 = sext i32 %180 to i64
%184 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %183
%185 = load i32, i32* %184
%186 = icmp sgt i32 %182, %185
br i1 %186, label %187, label %191
187: ; preds = %178
store i32 %185, i32* %181
store i32 %182, i32* %184
%188 = add nsw i64 %179, -1
%189 = icmp sgt i64 %179, 0
%190 = trunc i64 %179 to i32
br i1 %189, label %178, label %191
191: ; preds = %178, %187
%192 = add nuw nsw i32 %177, 1
%193 = icmp eq i32 %192, 20
%194 = add nuw nsw i64 %176, 1
br i1 %193, label %66, label %175
}