#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 */
struct timeval {
  double tv_sec;
  scalar_t__ tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, double);
int t(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ timeval_subtract(struct timeval *, struct timeval *,
                                    struct timeval *);
int main() {
  struct timeval start, end, diff;
  int i;
  for (i = 0; i < 30; i++) {
    gettimeofday(&start, NULL);
    int res = t(~(~0 << i), 0, 0);
    gettimeofday(&end, NULL);
    timeval_subtract(&diff, &end, &start);
    printf("%d [%f]\n", res,
           diff.tv_sec + ((double)diff.tv_usec / (1000 * 1000)));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x1e,-0x3c(%rbp)
jge    11dc <main+0x9c>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x3c(%rbp),%ecx
mov    $0xffffffff,%edi
shl    %cl,%edi
xor    $0xffffffff,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <t@plt>
mov    %eax,-0x40(%rbp)
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
lea    -0x38(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <timeval_subtract@plt>
mov    -0x40(%rbp),%esi
movsd  -0x38(%rbp),%xmm0
cvtsi2sdq -0x30(%rbp),%xmm1
movsd  0xe46(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1156 <main+0x16>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
xor    %ebx,%ebx
lea    0x28(%rsp),%r14
lea    0x18(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0xea2(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    $0xffffffff,%edi
mov    %ebx,%ecx
shl    %cl,%edi
not    %edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <t@plt>
mov    %eax,%ebp
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <timeval_subtract@plt>
xorps  %xmm0,%xmm0
cvtsi2sdq 0x10(%rsp),%xmm0
divsd  0xe46(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
mov    %r13,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    $0x1e,%ebx
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { double, i64 }
@.str = [9 x i8] c"%d [%f]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
br label %7
7: ; preds = %27, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 30
br i1 %9, label %10, label %30
10: ; preds = %7
%11 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%12 = load i32, i32* %5
%13 = shl i32 -1, %12
%14 = xor i32 %13, -1
%15 = call i32 @t(i32 %14, i32 0, i32 0)
store i32 %15, i32* %6
%16 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%17 = call i32 @timeval_subtract(%struct.timeval* %4, %struct.timeval* %3, %struct.timeval* %2)
%18 = load i32, i32* %6
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%20 = load double, double* %19
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%22 = load i64, i64* %21
%23 = sitofp i64 %22 to double
%24 = fdiv double %23, 1.000000e+06
%25 = fadd double %20, %24
%26 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %18, double %25)
br label %27
27: ; preds = %10
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %7
30: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { double, i64 }
@.str = [9 x i8] c"%d [%f]\0A\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %1 to i8*
%5 = bitcast %struct.timeval* %2 to i8*
%6 = bitcast %struct.timeval* %3 to i8*
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
br label %9
9: ; preds = %0, %9
%10 = phi i32 [ 0, %0 ], [ %23, %9 ]
%11 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%12 = shl nsw i32 -1, %10
%13 = xor i32 %12, -1
%14 = call i32 @t(i32 %13, i32 0, i32 0)
%15 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%16 = call i32 @timeval_subtract(%struct.timeval* %3, %struct.timeval* %2, %struct.timeval* %1)
%17 = load double, double* %7
%18 = load i64, i64* %8
%19 = sitofp i64 %18 to double
%20 = fdiv double %19, 1.000000e+06
%21 = fadd double %17, %20
%22 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %14, double %21)
%23 = add nuw nsw i32 %10, 1
%24 = icmp eq i32 %23, 30
br i1 %24, label %25, label %9
25: ; preds = %9
ret i32 0
}