#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*/ incremental_insert(int *, int, int, int);
void shellsort(int list[], int n) {
  int i, gap;
  for (gap = n / 2; gap > 0; gap = gap / 2) {
    if ((gap % 2) == 0)
      gap++;
    for (i = 0; i < gap; i++)
      incremental_insert(list, i, n - 1, gap);
  }
}


x86 assembly (clang, -O0):
<shellsort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11a2 <shellsort+0x92>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1154 <shellsort+0x44>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    118a <shellsort+0x7a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
mov    -0x14(%rbp),%ecx
call   1030 <incremental_insert@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115b <shellsort+0x4b>
jmp    118f <shellsort+0x7f>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
jmp    112d <shellsort+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shellsort>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%esi
jl     116b <shellsort+0x5b>
mov    %esi,%ebx
mov    %rdi,%r14
lea    -0x1(%rbx),%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%eax
shr    %eax
mov    %eax,%ebx
not    %ebx
and    $0x1,%ebx
add    %eax,%ebx
je     116b <shellsort+0x5b>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
call   1030 <incremental_insert@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1150 <shellsort+0x40>
cmp    $0x2,%ebx
jae    1130 <shellsort+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @shellsort(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %20
4: ; preds = %2
%5 = add nsw i32 %1, -1
br label %8
6: ; preds = %15
%7 = icmp ugt i32 %13, 1
br i1 %7, label %8, label %20
8: ; preds = %4, %6
%9 = phi i32 [ %1, %4 ], [ %13, %6 ]
%10 = lshr i32 %9, 1
%11 = and i32 %10, 1
%12 = xor i32 %11, 1
%13 = add nuw nsw i32 %12, %10
%14 = icmp eq i32 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %8, %15
%16 = phi i32 [ %18, %15 ], [ 0, %8 ]
%17 = tail call i32 @incremental_insert(i32* %0, i32 %16, i32 %5, i32 %13)
%18 = add nuw nsw i32 %16, 1
%19 = icmp eq i32 %18, %13
br i1 %19, label %6, label %15
20: ; preds = %6, %8, %2
ret void
}