#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct timezone {
  int dummy;
};
struct timeval {
  int tv_sec;
  int tv_usec;
};
struct TYPE_3__ {
  int tv_sec;
  int tv_usec;
};
struct TYPE_4__ {
  int tv_sec;
  int tv_usec;
};
struct rusage {
  TYPE_1__ ru_stime;
  TYPE_2__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
void bcr_gettime(double *rt, double *ct) {
  struct rusage r;
  struct timeval tp;
  struct timezone tzp;
  getrusage(RUSAGE_SELF, &r);
  gettimeofday(&tp, &tzp);
  *ct = r.ru_utime.tv_sec + r.ru_stime.tv_sec +
        1e-6 * (r.ru_utime.tv_usec + r.ru_stime.tv_usec);
  *rt = tp.tv_sec + tp.tv_usec * 1e-6;
}


x86 assembly (clang, -O0):
<bcr_gettime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1040 <getrusage@plt>
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <gettimeofday@plt>
mov    -0x18(%rbp),%eax
add    -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm1
mov    -0x14(%rbp),%eax
add    -0x1c(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe95(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
cvtsi2sdl -0x28(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  0xe73(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bcr_gettime>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2eac(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
call   1040 <getrusage@plt>
lea    0x8(%rsp),%rdi
lea    0x20(%rsp),%rsi
call   1030 <gettimeofday@plt>
mov    0x10(%rsp),%eax
mov    0x14(%rsp),%ecx
add    0x18(%rsp),%eax
cvtsi2sd %eax,%xmm0
add    0x1c(%rsp),%ecx
cvtsi2sd %ecx,%xmm1
movsd  0xe91(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
xorps  %xmm0,%xmm0
cvtsi2sdl 0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_3__, %struct.TYPE_4__ }
%struct.TYPE_3__ = type { i32, i32 }
%struct.TYPE_4__ = type { i32, i32 }
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
@RUSAGE_SELF = global i32 0
define void @bcr_gettime(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca %struct.rusage
%6 = alloca %struct.timeval
%7 = alloca %struct.timezone
store double* %0, double** %3
store double* %1, double** %4
%8 = load i32, i32* @RUSAGE_SELF
%9 = call i32 @getrusage(i32 %8, %struct.rusage* %5)
%10 = call i32 @gettimeofday(%struct.timeval* %6, %struct.timezone* %7)
%11 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 1
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 0
%15 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = add nsw i32 %13, %16
%18 = sitofp i32 %17 to double
%19 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 1
%20 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %19, i32 0, i32 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %22, i32 0, i32 1
%24 = load i32, i32* %23
%25 = add nsw i32 %21, %24
%26 = sitofp i32 %25 to double
%27 = call double @llvm.fmuladd.f64(double 0x3EB0C6F7A0B5ED8D, double %26, double %18)
%28 = load double*, double** %4
store double %27, double* %28
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%30 = load i32, i32* %29
%31 = sitofp i32 %30 to double
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%33 = load i32, i32* %32
%34 = sitofp i32 %33 to double
%35 = call double @llvm.fmuladd.f64(double %34, double 0x3EB0C6F7A0B5ED8D, double %31)
%36 = load double*, double** %3
store double %35, double* %36
ret void
}

LLVM IR (-O2):
%struct.rusage = type { %struct.TYPE_3__, %struct.TYPE_4__ }
%struct.TYPE_3__ = type { i32, i32 }
%struct.TYPE_4__ = type { i32, i32 }
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
@RUSAGE_SELF = global i32 0
define void @bcr_gettime(double* nocapture writeonly %0, double* nocapture writeonly %1) {
%3 = alloca %struct.rusage
%4 = alloca %struct.timeval
%5 = alloca %struct.timezone
%6 = bitcast %struct.rusage* %3 to i8*
%7 = bitcast %struct.timeval* %4 to i8*
%8 = bitcast %struct.timezone* %5 to i8*
%9 = load i32, i32* @RUSAGE_SELF
%10 = call i32 @getrusage(i32 %9, %struct.rusage* %3)
%11 = call i32 @gettimeofday(%struct.timeval* %4, %struct.timezone* %5)
%12 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 1, i32 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 0, i32 0
%15 = load i32, i32* %14
%16 = add nsw i32 %15, %13
%17 = sitofp i32 %16 to double
%18 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 1, i32 1
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 0, i32 1
%21 = load i32, i32* %20
%22 = add nsw i32 %21, %19
%23 = sitofp i32 %22 to double
%24 = call double @llvm.fmuladd.f64(double %23, double 0x3EB0C6F7A0B5ED8D, double %17)
store double %24, double* %1
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%26 = load i32, i32* %25
%27 = sitofp i32 %26 to double
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%29 = load i32, i32* %28
%30 = sitofp i32 %29 to double
%31 = call double @llvm.fmuladd.f64(double %30, double 0x3EB0C6F7A0B5ED8D, double %27)
store double %31, double* %0
ret void
}