#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*/ do_shell_sort(int *, int, int);
scalar_t__ pow(double, double);
void shell_sort(int arr[], int n) {
  int i;
  int times = (n >> 2) > 1 ? (n >> 2) : 1;
  for (i = 0; i < times; ++i)
    do_shell_sort(arr, n, (int)(pow(2.0, (double)(times - i))) - 1);
}


x86 assembly (clang, -O0):
<shell_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x2,%eax
cmp    $0x1,%eax
jle    114c <shell_sort+0x2c>
mov    -0xc(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    1159 <shell_sort+0x39>
mov    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1159 <shell_sort+0x39>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b6 <shell_sort+0x96>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x10(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xe6e(%rip),%xmm0
call   1040 <pow@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
sub    $0x1,%edx
call   1030 <do_shell_sort@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1166 <shell_sort+0x46>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shell_sort>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
mov    %esi,%eax
sar    $0x2,%eax
test   %eax,%eax
mov    $0x1,%ebp
cmovg  %eax,%ebp
nopl   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd  0xeb1(%rip),%xmm0
call   1040 <pow@plt>
lea    -0x1(%rax),%edx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <do_shell_sort@plt>
add    $0xffffffff,%ebp
jne    1140 <shell_sort+0x20>
pop    %rbx
pop    %r14
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
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = ashr i32 %7, 2
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* %4
%12 = ashr i32 %11, 2
br label %14
13: ; preds = %2
br label %14
14: ; preds = %13, %10
%15 = phi i32 [ %12, %10 ], [ 1, %13 ]
store i32 %15, i32* %6
store i32 0, i32* %5
br label %16
16: ; preds = %31, %14
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = load i32*, i32** %3
%22 = load i32, i32* %4
%23 = load i32, i32* %6
%24 = load i32, i32* %5
%25 = sub nsw i32 %23, %24
%26 = sitofp i32 %25 to double
%27 = call i64 @pow(double 2.000000e+00, double %26)
%28 = trunc i64 %27 to i32
%29 = sub nsw i32 %28, 1
%30 = call i32 @do_shell_sort(i32* %21, i32 %22, i32 %29)
br label %31
31: ; preds = %20
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %16
34: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @shell_sort(i32* %0, i32 %1) {
%3 = ashr i32 %1, 2
%4 = icmp sgt i32 %3, 1
%5 = select i1 %4, i32 %3, i32 1
br label %6
6: ; preds = %2, %6
%7 = phi i32 [ 0, %2 ], [ %14, %6 ]
%8 = sub nsw i32 %5, %7
%9 = sitofp i32 %8 to double
%10 = tail call i64 @pow(double 2.000000e+00, double %9)
%11 = trunc i64 %10 to i32
%12 = add nsw i32 %11, -1
%13 = tail call i32 @do_shell_sort(i32* %0, i32 %1, i32 %12)
%14 = add nuw nsw i32 %7, 1
%15 = icmp eq i32 %14, %5
br i1 %15, label %16, label %6
16: ; preds = %6
ret void
}