#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*/ test_sort(size_t const, size_t const);
int main(void) {
  static const size_t MAX_N = 4 * 1024 * 1024;
  for (size_t i = 0; i < 20; ++i) {
    const size_t n = MAX_N >> i;
    test_sort(n, MAX_N);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x14,-0x10(%rbp)
jae    1161 <main+0x51>
mov    -0x10(%rbp),%rcx
mov    $0x400000,%eax
shr    %cl,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1127 <main+0x17>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x400000,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x200000,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x100000,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x80000,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x40000,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x20000,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x10000,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x8000,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x4000,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x2000,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x1000,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x800,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x400,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x200,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x100,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x80,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x40,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x20,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x10,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
mov    $0x8,%edi
mov    $0x400000,%esi
call   1030 <test_sort@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@main.MAX_N = internal constant i64 4194304
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %2
br label %4
4: ; preds = %12, %0
%5 = load i64, i64* %2
%6 = icmp ult i64 %5, 20
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i64, i64* %2
%9 = lshr i64 4194304, %8
store i64 %9, i64* %3
%10 = load i64, i64* %3
%11 = call i32 @test_sort(i64 %10, i64 4194304)
br label %12
12: ; preds = %7
%13 = load i64, i64* %2
%14 = add i64 %13, 1
store i64 %14, i64* %2
br label %4
15: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @test_sort(i64 4194304, i64 4194304)
%2 = tail call i32 @test_sort(i64 2097152, i64 4194304)
%3 = tail call i32 @test_sort(i64 1048576, i64 4194304)
%4 = tail call i32 @test_sort(i64 524288, i64 4194304)
%5 = tail call i32 @test_sort(i64 262144, i64 4194304)
%6 = tail call i32 @test_sort(i64 131072, i64 4194304)
%7 = tail call i32 @test_sort(i64 65536, i64 4194304)
%8 = tail call i32 @test_sort(i64 32768, i64 4194304)
%9 = tail call i32 @test_sort(i64 16384, i64 4194304)
%10 = tail call i32 @test_sort(i64 8192, i64 4194304)
%11 = tail call i32 @test_sort(i64 4096, i64 4194304)
%12 = tail call i32 @test_sort(i64 2048, i64 4194304)
%13 = tail call i32 @test_sort(i64 1024, i64 4194304)
%14 = tail call i32 @test_sort(i64 512, i64 4194304)
%15 = tail call i32 @test_sort(i64 256, i64 4194304)
%16 = tail call i32 @test_sort(i64 128, i64 4194304)
%17 = tail call i32 @test_sort(i64 64, i64 4194304)
%18 = tail call i32 @test_sort(i64 32, i64 4194304)
%19 = tail call i32 @test_sort(i64 16, i64 4194304)
%20 = tail call i32 @test_sort(i64 8, i64 4194304)
ret i32 0
}