#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 scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, double);
unsigned long unsigned_long_time_it(unsigned long f()) {
  clock_t begin, end;
  double time_spent;
  begin = clock();
  unsigned long output = f();
  end = clock();
  time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  printf("=> Result: %ld\n", output);
  printf("=> Time: %fs\n", time_spent);
  return 0L;
}


x86 assembly (clang, -O0):
<unsigned_long_time_it>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %al,-0x29(%rbp)
call   1030 <clock@plt>
mov    %rax,%rcx
mov    -0x29(%rbp),%al
mov    %rcx,-0x10(%rbp)
mov    -0x8(%rbp),%rcx
call   *%rcx
mov    %rax,%rcx
mov    -0x29(%rbp),%al
mov    %rcx,-0x28(%rbp)
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
cvtsi2sd %rax,%xmm0
mov    0x2e78(%rip),%rax
movsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movaps 0xe7c(%rip),%xmm1
movq   -0x28(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe7b(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe74(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unsigned_long_time_it>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r14
xor    %eax,%eax
call   *%rbx
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r14,%rax
cvtsi2sd %rax,%xmm0
mov    0x2e9a(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,(%rsp)
movq   %rbx,%xmm1
punpckldq 0xe9c(%rip),%xmm1
subpd  0xea4(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
movsd  (%rsp),%xmm0
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [16 x i8] c"=> Result: %ld\0A\00"
@.str.1 = [14 x i8] c"=> Time: %fs\0A\00"
define i64 @unsigned_long_time_it(i64 (...)* %0) {
%2 = alloca i64 (...)*
%3 = alloca i64
%4 = alloca i64
%5 = alloca double
%6 = alloca i64
store i64 (...)* %0, i64 (...)** %2
%7 = call i64 (...) @clock()
store i64 %7, i64* %3
%8 = load i64 (...)*, i64 (...)** %2
%9 = call i64 (...) %8()
store i64 %9, i64* %6
%10 = call i64 (...) @clock()
store i64 %10, i64* %4
%11 = load i64, i64* %4
%12 = load i64, i64* %3
%13 = sub nsw i64 %11, %12
%14 = sitofp i64 %13 to double
%15 = load double, double* @CLOCKS_PER_SEC
%16 = fdiv double %14, %15
store double %16, double* %5
%17 = load i64, i64* %6
%18 = uitofp i64 %17 to double
%19 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %18)
%20 = load double, double* %5
%21 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), double %20)
ret i64 0
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [16 x i8] c"=> Result: %ld\0A\00"
@.str.1 = [14 x i8] c"=> Time: %fs\0A\00"
define i64 @unsigned_long_time_it(i64 (...)* nocapture %0) {
%2 = tail call i64 (...) @clock()
%3 = tail call i64 (...) %0()
%4 = tail call i64 (...) @clock()
%5 = sub nsw i64 %4, %2
%6 = sitofp i64 %5 to double
%7 = load double, double* @CLOCKS_PER_SEC
%8 = fdiv double %6, %7
%9 = uitofp i64 %3 to double
%10 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), double %8)
ret i64 0
}