#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);
long long_time_it(long f()) {
  clock_t begin, end;
  double time_spent;
  begin = clock();
  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 0;
}


x86 assembly (clang, -O0):
<long_time_it>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   *-0x8(%rbp)
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e89(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdq -0x28(%rbp),%xmm0
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<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)
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9e(%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 @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 = sitofp 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 @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 = sitofp 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
}