#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*/ group_sort(int *, int, int, int);
void shell_sort2(int a[], int n) {
  int i, gap;
  for (gap = n / 2; gap > 0; gap /= 2) {
    for (i = 0; i < gap; i++)
      group_sort(a, n, i, gap);
  }
}


x86 assembly (clang, -O0):
<shell_sort2>:
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    1182 <shell_sort2+0x72>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    116a <shell_sort2+0x5a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <group_sort@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113e <shell_sort2+0x2e>
jmp    116f <shell_sort2+0x5f>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
jmp    112d <shell_sort2+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shell_sort2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%esi
jl     116f <shell_sort2+0x5f>
mov    %esi,%r14d
mov    %rdi,%r15
mov    %esi,%r12d
cs nopw 0x0(%rax,%rax,1)
cmp    $0x2,%r12d
jl     116f <shell_sort2+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 <group_sort@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1150 <shell_sort2+0x40>
cmp    $0x4,%r12d
mov    %ebp,%r12d
jge    1130 <shell_sort2+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @shell_sort2(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 = %27, %2
%10 = load i32, i32* %6
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %9
store i32 0, i32* %5
br label %13
13: ; preds = %23, %12
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i32*, i32** %3
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call i32 @group_sort(i32* %18, i32 %19, i32 %20, i32 %21)
br label %23
23: ; preds = %17
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %13
26: ; preds = %13
br label %27
27: ; preds = %26
%28 = load i32, i32* %6
%29 = sdiv i32 %28, 2
store i32 %29, i32* %6
br label %9
30: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @shell_sort2(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %6, label %15
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 @group_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
}