#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*/ fun();
int /*<<< orphan*/ printf(char *, double);
int main() {
  clock_t t;
  t = clock();
  printf("clock is: %f", (double)t);
  fun();
  t = clock() - t;
  double time_taken = ((double)t) / CLOCKS_PER_SEC;
  printf("fun() took %f seconds to execute \n", time_taken);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm0
lea    0xea9(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <fun@plt>
mov    $0x0,%al
call   1030 <clock@plt>
sub    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm0
mov    0x2e69(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
cvtsi2sd %rax,%xmm0
lea    0xeb9(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <fun@plt>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %rbx,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2e7c(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe96(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"clock is: %f\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [35 x i8] c"fun() took %f seconds to execute \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca double
store i32 0, i32* %1
%4 = call i64 (...) @clock()
store i64 %4, i64* %2
%5 = load i64, i64* %2
%6 = sitofp i64 %5 to double
%7 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %6)
%8 = call i32 (...) @fun()
%9 = call i64 (...) @clock()
%10 = load i64, i64* %2
%11 = sub nsw i64 %9, %10
store i64 %11, i64* %2
%12 = load i64, i64* %2
%13 = sitofp i64 %12 to double
%14 = load double, double* @CLOCKS_PER_SEC
%15 = fdiv double %13, %14
store double %15, double* %3
%16 = load double, double* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), double %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"clock is: %f\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [35 x i8] c"fun() took %f seconds to execute \0A\00"
define i32 @main() {
%1 = tail call i64 (...) @clock()
%2 = sitofp i64 %1 to double
%3 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %2)
%4 = tail call i32 (...) @fun()
%5 = tail call i64 (...) @clock()
%6 = sub nsw i64 %5, %1
%7 = sitofp i64 %6 to double
%8 = load double, double* @CLOCKS_PER_SEC
%9 = fdiv double %7, %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), double %9)
ret i32 0
}