#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct timeval {
  double tv_usec;
  scalar_t__ tv_sec;
};
struct TYPE_2__ {
  double tv_usec;
  scalar_t__ tv_sec;
};
struct rusage {
  TYPE_1__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
void timing(double *wcTime, double *cpuTime) {
  struct timeval tp;
  struct rusage ruse;
  gettimeofday(&tp, NULL);
  *wcTime = (double)(tp.tv_sec + tp.tv_usec / 1000000.0);
  getrusage(RUSAGE_SELF, &ruse);
  *cpuTime = (double)(ruse.ru_utime.tv_sec + ruse.ru_utime.tv_usec / 1000000.0);
}


x86 assembly (clang, -O0):
<timing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xeb0(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1040 <getrusage@plt>
cvtsi2sdq -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xe7b(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timing>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
cvtsi2sdq 0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
divsd  0xeb2(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1040 <getrusage@plt>
xorps  %xmm0,%xmm0
cvtsi2sdq 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
divsd  0xe7f(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { double, i64 }
%struct.rusage = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { double, i64 }
@RUSAGE_SELF = global i32 0
define void @timing(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca %struct.timeval
%6 = alloca %struct.rusage
store double* %0, double** %3
store double* %1, double** %4
%7 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%9 = load i64, i64* %8
%10 = sitofp i64 %9 to double
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%12 = load double, double* %11
%13 = fdiv double %12, 1.000000e+06
%14 = fadd double %10, %13
%15 = load double*, double** %3
store double %14, double* %15
%16 = load i32, i32* @RUSAGE_SELF
%17 = call i32 @getrusage(i32 %16, %struct.rusage* %6)
%18 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %18, i32 0, i32 1
%20 = load i64, i64* %19
%21 = sitofp i64 %20 to double
%22 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %22, i32 0, i32 0
%24 = load double, double* %23
%25 = fdiv double %24, 1.000000e+06
%26 = fadd double %21, %25
%27 = load double*, double** %4
store double %26, double* %27
ret void
}

LLVM IR (-O2):
%struct.timeval = type { double, i64 }
%struct.rusage = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { double, i64 }
@RUSAGE_SELF = global i32 0
define void @timing(double* nocapture writeonly %0, double* nocapture writeonly %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.rusage
%5 = bitcast %struct.timeval* %3 to i8*
%6 = bitcast %struct.rusage* %4 to i8*
%7 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%9 = load i64, i64* %8
%10 = sitofp i64 %9 to double
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%12 = load double, double* %11
%13 = fdiv double %12, 1.000000e+06
%14 = fadd double %13, %10
store double %14, double* %0
%15 = load i32, i32* @RUSAGE_SELF
%16 = call i32 @getrusage(i32 %15, %struct.rusage* %4)
%17 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i64 0, i32 0, i32 1
%18 = load i64, i64* %17
%19 = sitofp i64 %18 to double
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i64 0, i32 0, i32 0
%21 = load double, double* %20
%22 = fdiv double %21, 1.000000e+06
%23 = fadd double %22, %19
store double %23, double* %1
ret void
}