#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 */
typedef double clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
double clock();
int /*<<< orphan*/ printf(char *, ...);
int test_hil_32();
int test_hil_64();
int test_hil_64_alt();
int test_tile_serial();
int main() {
  clock_t tic;
  int i;
  for (i = 1; i <= 3; ++i) {
    printf("Take %d\n", i);
    tic = clock();
    printf("1) Testing uint32 hilbert ...");
    printf("ok, %d samples in %.3fs.\n", test_hil_32(),
           1.0 * (clock() - tic) / CLOCKS_PER_SEC);
    tic = clock();
    printf("2) Testing uint64 hilbert ...");
    printf("ok, %d samples in %.3fs.\n", test_hil_64(),
           1.0 * (clock() - tic) / CLOCKS_PER_SEC);
    tic = clock();
    printf("3) Testing uint64 hilbert (z=20) ...");
    printf("ok, %d samples in %.3fs.\n", test_hil_64_alt(),
           1.0 * (clock() - tic) / CLOCKS_PER_SEC);
    tic = clock();
    printf("4) Testing tile coordinate to serial...");
    printf("ok, %d samples in %.3fs.\n", test_tile_serial(),
           1.0 * (clock() - tic) / CLOCKS_PER_SEC);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jg     130b <main+0x1ab>
mov    -0x14(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <clock@plt>
movsd  %xmm0,-0x10(%rbp)
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1040 <test_hil_32@plt>
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1050 <clock@plt>
mov    -0x24(%rbp),%esi
movaps %xmm0,%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xe31(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2e0e(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe4a(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <clock@plt>
movsd  %xmm0,-0x10(%rbp)
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1030 <test_hil_64@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1050 <clock@plt>
mov    -0x20(%rbp),%esi
movaps %xmm0,%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xdd6(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2db3(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdef(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <clock@plt>
movsd  %xmm0,-0x10(%rbp)
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1060 <test_hil_64_alt@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <clock@plt>
mov    -0x1c(%rbp),%esi
movaps %xmm0,%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xd7b(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2d58(%rip),%rax
divsd  (%rax),%xmm0
lea    0xd94(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <clock@plt>
movsd  %xmm0,-0x10(%rbp)
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1080 <test_tile_serial@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <clock@plt>
mov    -0x18(%rbp),%esi
movaps %xmm0,%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xd20(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2cfd(%rip),%rax
divsd  (%rax),%xmm0
lea    0xd39(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1176 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%ebx
mov    0x2e71(%rip),%r13
lea    0xea9(%rip),%r12
lea    0xeff(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe69(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,(%rsp)
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1040 <test_hil_32@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1050 <clock@plt>
subsd  (%rsp),%xmm0
divsd  0x0(%r13),%xmm0
mov    %r12,%rdi
mov    %r15d,%esi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,(%rsp)
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1030 <test_hil_64@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <clock@plt>
subsd  (%rsp),%xmm0
divsd  0x0(%r13),%xmm0
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,(%rsp)
lea    0xe28(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1060 <test_hil_64_alt@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <clock@plt>
subsd  (%rsp),%xmm0
divsd  0x0(%r13),%xmm0
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1080 <test_tile_serial@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <clock@plt>
subsd  (%rsp),%xmm0
divsd  0x0(%r13),%xmm0
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1070 <printf@plt>
add    $0x1,%ebx
cmp    $0x4,%ebx
jne    1190 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Take %d\0A\00"
@.str.1 = [30 x i8] c"1) Testing uint32 hilbert ...\00"
@.str.2 = [26 x i8] c"ok, %d samples in %.3fs.\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.3 = [30 x i8] c"2) Testing uint64 hilbert ...\00"
@.str.4 = [37 x i8] c"3) Testing uint64 hilbert (z=20) ...\00"
@.str.5 = [40 x i8] c"4) Testing tile coordinate to serial...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
br label %4
4: ; preds = %50, %0
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 3
br i1 %6, label %7, label %53
7: ; preds = %4
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call double (...) @clock()
store double %10, double* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (...) @test_hil_32()
%13 = call double (...) @clock()
%14 = load double, double* %2
%15 = fsub double %13, %14
%16 = fmul double 1.000000e+00, %15
%17 = load double, double* @CLOCKS_PER_SEC
%18 = fdiv double %16, %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %12, double %18)
%20 = call double (...) @clock()
store double %20, double* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (...) @test_hil_64()
%23 = call double (...) @clock()
%24 = load double, double* %2
%25 = fsub double %23, %24
%26 = fmul double 1.000000e+00, %25
%27 = load double, double* @CLOCKS_PER_SEC
%28 = fdiv double %26, %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %22, double %28)
%30 = call double (...) @clock()
store double %30, double* %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%32 = call i32 (...) @test_hil_64_alt()
%33 = call double (...) @clock()
%34 = load double, double* %2
%35 = fsub double %33, %34
%36 = fmul double 1.000000e+00, %35
%37 = load double, double* @CLOCKS_PER_SEC
%38 = fdiv double %36, %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %32, double %38)
%40 = call double (...) @clock()
store double %40, double* %2
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%42 = call i32 (...) @test_tile_serial()
%43 = call double (...) @clock()
%44 = load double, double* %2
%45 = fsub double %43, %44
%46 = fmul double 1.000000e+00, %45
%47 = load double, double* @CLOCKS_PER_SEC
%48 = fdiv double %46, %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %42, double %48)
br label %50
50: ; preds = %7
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %4
53: ; preds = %4
%54 = load i32, i32* %1
ret i32 %54
}

LLVM IR (-O2):
@.str = [9 x i8] c"Take %d\0A\00"
@.str.1 = [30 x i8] c"1) Testing uint32 hilbert ...\00"
@.str.2 = [26 x i8] c"ok, %d samples in %.3fs.\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.3 = [30 x i8] c"2) Testing uint64 hilbert ...\00"
@.str.4 = [37 x i8] c"3) Testing uint64 hilbert (z=20) ...\00"
@.str.5 = [40 x i8] c"4) Testing tile coordinate to serial...\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 1, %0 ], [ %36, %1 ]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = tail call double (...) @clock()
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 (...) @test_hil_32()
%7 = tail call double (...) @clock()
%8 = fsub double %7, %4
%9 = load double, double* @CLOCKS_PER_SEC
%10 = fdiv double %8, %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %6, double %10)
%12 = tail call double (...) @clock()
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 (...) @test_hil_64()
%15 = tail call double (...) @clock()
%16 = fsub double %15, %12
%17 = load double, double* @CLOCKS_PER_SEC
%18 = fdiv double %16, %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %14, double %18)
%20 = tail call double (...) @clock()
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%22 = tail call i32 (...) @test_hil_64_alt()
%23 = tail call double (...) @clock()
%24 = fsub double %23, %20
%25 = load double, double* @CLOCKS_PER_SEC
%26 = fdiv double %24, %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %22, double %26)
%28 = tail call double (...) @clock()
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%30 = tail call i32 (...) @test_tile_serial()
%31 = tail call double (...) @clock()
%32 = fsub double %31, %28
%33 = load double, double* @CLOCKS_PER_SEC
%34 = fdiv double %32, %33
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %30, double %34)
%36 = add nuw nsw i32 %2, 1
%37 = icmp eq i32 %36, 4
br i1 %37, label %38, label %1
38: ; preds = %1
ret i32 0
}