#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*/ insert_sort(int *, int, int, int);
void shell_sort(int num[], int len) {
  if (len <= 1)
    return;
  int i, j;
  int dlta;
  for (dlta = len / 2; dlta > 0; dlta /= 2) {
    for (i = 0; i < dlta; ++i) {
      insert_sort(num, len, i, dlta);
    }
  }
}


x86 assembly (clang, -O0):
<shell_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jg     112e <shell_sort+0x1e>
jmp    1191 <shell_sort+0x81>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1191 <shell_sort+0x81>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1179 <shell_sort+0x69>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <insert_sort@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114d <shell_sort+0x3d>
jmp    117e <shell_sort+0x6e>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
jmp    113c <shell_sort+0x2c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shell_sort>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%esi
jl     116f <shell_sort+0x5f>
mov    %esi,%r14d
mov    %rdi,%r15
mov    %esi,%r12d
cs nopw 0x0(%rax,%rax,1)
cmp    $0x2,%r12d
jl     116f <shell_sort+0x5f>
mov    %r12d,%ebp
shr    $0x1f,%ebp
add    %r12d,%ebp
sar    %ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1030 <insert_sort@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1150 <shell_sort+0x40>
cmp    $0x4,%r12d
mov    %ebp,%r12d
jge    1130 <shell_sort+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @shell_sort(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = icmp sle i32 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %2
br label %35
11: ; preds = %2
%12 = load i32, i32* %4
%13 = sdiv i32 %12, 2
store i32 %13, i32* %7
br label %14
14: ; preds = %32, %11
%15 = load i32, i32* %7
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %35
17: ; preds = %14
store i32 0, i32* %5
br label %18
18: ; preds = %28, %17
%19 = load i32, i32* %5
%20 = load i32, i32* %7
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i32*, i32** %3
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = load i32, i32* %7
%27 = call i32 @insert_sort(i32* %23, i32 %24, i32 %25, i32 %26)
br label %28
28: ; preds = %22
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %18
31: ; preds = %18
br label %32
32: ; preds = %31
%33 = load i32, i32* %7
%34 = sdiv i32 %33, 2
store i32 %34, i32* %7
br label %14
35: ; preds = %10, %14
ret void
}

LLVM IR (-O2):
define void @shell_sort(i32* %0, i32 %1) {
%3 = icmp slt i32 %1, 2
br i1 %3, label %15, label %6
4: ; preds = %10
%5 = icmp sgt i32 %7, 3
br i1 %5, label %6, label %15
6: ; preds = %2, %4
%7 = phi i32 [ %8, %4 ], [ %1, %2 ]
%8 = sdiv i32 %7, 2
%9 = icmp sgt i32 %7, 1
br i1 %9, label %10, label %15
10: ; preds = %6, %10
%11 = phi i32 [ %13, %10 ], [ 0, %6 ]
%12 = tail call i32 @insert_sort(i32* %0, i32 %1, i32 %11, i32 %8)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, %8
br i1 %14, label %4, label %10
15: ; preds = %4, %6, %2
ret void
}