#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);
int int_time_it(int f()) {
  clock_t begin, end;
  double time_spent;
  begin = clock();
  int output = f();
  end = clock();
  time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  printf("=> Result: %d\n", output);
  printf("=> Time: %fs\n", time_spent);
  return 0;
}


x86 assembly (clang, -O0):
<int_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    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e8a(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_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    %eax,%ebx
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r14,%rax
cvtsi2sd %rax,%xmm0
mov    0x2e9b(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9f(%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 = [15 x i8] c"=> Result: %d\0A\00"
@.str.1 = [14 x i8] c"=> Time: %fs\0A\00"
define i32 @int_time_it(i32 (...)* %0) {
%2 = alloca i32 (...)*
%3 = alloca i64
%4 = alloca i64
%5 = alloca double
%6 = alloca i32
store i32 (...)* %0, i32 (...)** %2
%7 = call i64 (...) @clock()
store i64 %7, i64* %3
%8 = load i32 (...)*, i32 (...)** %2
%9 = call i32 (...) %8()
store i32 %9, i32* %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 i32, i32* %6
%18 = sitofp i32 %17 to double
%19 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 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 i32 0
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [15 x i8] c"=> Result: %d\0A\00"
@.str.1 = [14 x i8] c"=> Time: %fs\0A\00"
define i32 @int_time_it(i32 (...)* nocapture %0) {
%2 = tail call i64 (...) @clock()
%3 = tail call i32 (...) %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 i32 %3 to double
%10 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 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 i32 0
}