#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 */
typedef int /*<<< orphan*/ time_t;
struct TYPE_4__ {
  double tv_usec;
  scalar_t__ tv_sec;
};
struct TYPE_3__ {
  double tv_usec;
  scalar_t__ tv_sec;
};
struct rusage {
  TYPE_2__ ru_stime;
  TYPE_1__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_CHILDREN;
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void StartTimers(time_t *tstart, double *cputimestart) {
  struct rusage usagebuf;
  *tstart = time(NULL);
  *cputimestart = -1.0;
  if (!getrusage(RUSAGE_SELF, &usagebuf)) {
    *cputimestart = (double)(usagebuf.ru_utime.tv_sec +
                             (usagebuf.ru_utime.tv_usec / (double)1000000) +
                             usagebuf.ru_stime.tv_sec +
                             (usagebuf.ru_stime.tv_usec / (double)1000000));
    if (!getrusage(RUSAGE_CHILDREN, &usagebuf)) {
      *cputimestart += (double)(usagebuf.ru_utime.tv_sec +
                                (usagebuf.ru_utime.tv_usec / (double)1000000) +
                                usagebuf.ru_stime.tv_sec +
                                (usagebuf.ru_stime.tv_usec / (double)1000000));
    }
  }
}


x86 assembly (clang, -O0):
<StartTimers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <time@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
movsd  0xeb3(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1040 <getrusage@plt>
cmp    $0x0,%eax
jne    1214 <StartTimers+0xf4>
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe89(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdq -0x28(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xe6a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1040 <getrusage@plt>
cmp    $0x0,%eax
jne    120f <StartTimers+0xef>
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe2c(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdq -0x28(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xe0d(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
jmp    1214 <StartTimers+0xf4>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StartTimers>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
call   1030 <time@plt>
mov    %eax,(%rbx)
movabs $0xbff0000000000000,%rax
mov    %rax,(%r14)
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1040 <getrusage@plt>
test   %eax,%eax
jne    11f9 <StartTimers+0xd9>
cvtsi2sdq 0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0xe87(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sdq 0x10(%rsp),%xmm0
addsd  %xmm2,%xmm0
divsd  %xmm3,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1040 <getrusage@plt>
test   %eax,%eax
jne    11f9 <StartTimers+0xd9>
xorps  %xmm0,%xmm0
cvtsi2sdq 0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0xe2f(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sdq 0x10(%rsp),%xmm0
addsd  %xmm2,%xmm0
divsd  %xmm3,%xmm1
addsd  %xmm0,%xmm1
addsd  (%r14),%xmm1
movsd  %xmm1,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { double, i64 }
%struct.TYPE_3__ = type { double, i64 }
@RUSAGE_SELF = global i32 0
@RUSAGE_CHILDREN = global i32 0
define void @StartTimers(i32* %0, double* %1) {
%3 = alloca i32*
%4 = alloca double*
%5 = alloca %struct.rusage
store i32* %0, i32** %3
store double* %1, double** %4
%6 = call i32 @time(i32* null)
%7 = load i32*, i32** %3
store i32 %6, i32* %7
%8 = load double*, double** %4
store double -1.000000e+00, double* %8
%9 = load i32, i32* @RUSAGE_SELF
%10 = call i32 @getrusage(i32 %9, %struct.rusage* %5)
%11 = icmp ne i32 %10, 0
br i1 %11, label %60, label %12
12: ; preds = %2
%13 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 1
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 1
%15 = load i64, i64* %14
%16 = sitofp i64 %15 to double
%17 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 1
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 0
%19 = load double, double* %18
%20 = fdiv double %19, 1.000000e+06
%21 = fadd double %16, %20
%22 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %22, i32 0, i32 1
%24 = load i64, i64* %23
%25 = sitofp i64 %24 to double
%26 = fadd double %21, %25
%27 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 0
%28 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %27, i32 0, i32 0
%29 = load double, double* %28
%30 = fdiv double %29, 1.000000e+06
%31 = fadd double %26, %30
%32 = load double*, double** %4
store double %31, double* %32
%33 = load i32, i32* @RUSAGE_CHILDREN
%34 = call i32 @getrusage(i32 %33, %struct.rusage* %5)
%35 = icmp ne i32 %34, 0
br i1 %35, label %59, label %36
36: ; preds = %12
%37 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 1
%38 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i32 0, i32 1
%39 = load i64, i64* %38
%40 = sitofp i64 %39 to double
%41 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 1
%42 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %41, i32 0, i32 0
%43 = load double, double* %42
%44 = fdiv double %43, 1.000000e+06
%45 = fadd double %40, %44
%46 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 0
%47 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %46, i32 0, i32 1
%48 = load i64, i64* %47
%49 = sitofp i64 %48 to double
%50 = fadd double %45, %49
%51 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 0
%52 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %51, i32 0, i32 0
%53 = load double, double* %52
%54 = fdiv double %53, 1.000000e+06
%55 = fadd double %50, %54
%56 = load double*, double** %4
%57 = load double, double* %56
%58 = fadd double %57, %55
store double %58, double* %56
br label %59
59: ; preds = %36, %12
br label %60
60: ; preds = %59, %2
ret void
}

LLVM IR (-O2):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { double, i64 }
%struct.TYPE_3__ = type { double, i64 }
@RUSAGE_SELF = global i32 0
@RUSAGE_CHILDREN = global i32 0
define void @StartTimers(i32* nocapture writeonly %0, double* nocapture %1) {
%3 = alloca %struct.rusage
%4 = bitcast %struct.rusage* %3 to i8*
%5 = tail call i32 @time(i32* null)
store i32 %5, i32* %0
store double -1.000000e+00, double* %1
%6 = load i32, i32* @RUSAGE_SELF
%7 = call i32 @getrusage(i32 %6, %struct.rusage* %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %42
9: ; preds = %2
%10 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 1, i32 1
%11 = load i64, i64* %10
%12 = sitofp i64 %11 to double
%13 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 1, i32 0
%14 = load double, double* %13
%15 = fdiv double %14, 1.000000e+06
%16 = fadd double %15, %12
%17 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 0, i32 1
%18 = load i64, i64* %17
%19 = sitofp i64 %18 to double
%20 = fadd double %16, %19
%21 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 0, i32 0
%22 = load double, double* %21
%23 = fdiv double %22, 1.000000e+06
%24 = fadd double %20, %23
store double %24, double* %1
%25 = load i32, i32* @RUSAGE_CHILDREN
%26 = call i32 @getrusage(i32 %25, %struct.rusage* %3)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %42
28: ; preds = %9
%29 = load i64, i64* %10
%30 = sitofp i64 %29 to double
%31 = load double, double* %13
%32 = fdiv double %31, 1.000000e+06
%33 = fadd double %32, %30
%34 = load i64, i64* %17
%35 = sitofp i64 %34 to double
%36 = fadd double %33, %35
%37 = load double, double* %21
%38 = fdiv double %37, 1.000000e+06
%39 = fadd double %36, %38
%40 = load double, double* %1
%41 = fadd double %40, %39
store double %41, double* %1
br label %42
42: ; preds = %9, %28, %2
ret void
}