#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 TYPE_4__ {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct TYPE_3__ {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct rusage {
  TYPE_2__ ru_utime;
  TYPE_1__ ru_stime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int errno;
scalar_t__ getrusage(int /*<<< orphan*/, struct rusage *);
int getrusage_helper(double *ru_stime, double *ru_utime) {
  struct rusage usage;
  if (getrusage(RUSAGE_SELF, &usage))
    return -errno;
  *ru_stime = (double)usage.ru_stime.tv_sec +
              (double)usage.ru_stime.tv_usec / 1000000.0;
  *ru_utime = (double)usage.ru_utime.tv_sec +
              (double)usage.ru_utime.tv_usec / 1000000.0;
  return 0;
}


x86 assembly (clang, -O0):
<getrusage_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
lea    -0x38(%rbp),%rsi
call   1030 <getrusage@plt>
cmp    $0x0,%rax
je     114f <getrusage_helper+0x3f>
xor    %eax,%eax
mov    0x2e9b(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    119e <getrusage_helper+0x8e>
cvtsi2sdq -0x20(%rbp),%xmm0
cvtsi2sdq -0x28(%rbp),%xmm1
movsd  0xe9d(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
cvtsi2sdq -0x30(%rbp),%xmm0
cvtsi2sdq -0x38(%rbp),%xmm1
movsd  0xe79(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getrusage_helper>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2eb4(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <getrusage@plt>
test   %rax,%rax
je     1142 <getrusage_helper+0x32>
mov    0x2ea4(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
jmp    1187 <getrusage_helper+0x77>
cvtsi2sdq 0x20(%rsp),%xmm0
cvtsi2sdq 0x18(%rsp),%xmm1
movsd  0xea8(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
xorps  %xmm0,%xmm0
cvtsi2sdq 0x10(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x8(%rsp),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64, i64 }
%struct.TYPE_3__ = type { i64, i64 }
@RUSAGE_SELF = global i32 0
@errno = global i32 0
define i32 @getrusage_helper(double* %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca double*
%6 = alloca %struct.rusage
store double* %0, double** %4
store double* %1, double** %5
%7 = load i32, i32* @RUSAGE_SELF
%8 = call i64 @getrusage(i32 %7, %struct.rusage* %6)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @errno
%12 = sub nsw i32 0, %11
store i32 %12, i32* %3
br label %36
13: ; preds = %2
%14 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 1
%15 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %14, i32 0, i32 1
%16 = load i64, i64* %15
%17 = sitofp i64 %16 to double
%18 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 1
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %18, i32 0, i32 0
%20 = load i64, i64* %19
%21 = sitofp i64 %20 to double
%22 = fdiv double %21, 1.000000e+06
%23 = fadd double %17, %22
%24 = load double*, double** %4
store double %23, double* %24
%25 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 0
%26 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %25, i32 0, i32 1
%27 = load i64, i64* %26
%28 = sitofp i64 %27 to double
%29 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 0
%30 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %29, i32 0, i32 0
%31 = load i64, i64* %30
%32 = sitofp i64 %31 to double
%33 = fdiv double %32, 1.000000e+06
%34 = fadd double %28, %33
%35 = load double*, double** %5
store double %34, double* %35
store i32 0, i32* %3
br label %36
36: ; preds = %13, %10
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64, i64 }
%struct.TYPE_3__ = type { i64, i64 }
@RUSAGE_SELF = global i32 0
@errno = global i32 0
define i32 @getrusage_helper(double* nocapture writeonly %0, double* nocapture writeonly %1) {
%3 = alloca %struct.rusage
%4 = bitcast %struct.rusage* %3 to i8*
%5 = load i32, i32* @RUSAGE_SELF
%6 = call i64 @getrusage(i32 %5, %struct.rusage* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* @errno
%10 = sub nsw i32 0, %9
br label %28
11: ; preds = %2
%12 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 1, i32 1
%13 = load i64, i64* %12
%14 = sitofp i64 %13 to double
%15 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 1, i32 0
%16 = load i64, i64* %15
%17 = sitofp i64 %16 to double
%18 = fdiv double %17, 1.000000e+06
%19 = fadd double %18, %14
store double %19, double* %0
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 0, i32 1
%21 = load i64, i64* %20
%22 = sitofp i64 %21 to double
%23 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 0, i32 0
%24 = load i64, i64* %23
%25 = sitofp i64 %24 to double
%26 = fdiv double %25, 1.000000e+06
%27 = fadd double %26, %22
store double %27, double* %1
br label %28
28: ; preds = %11, %8
%29 = phi i32 [ %10, %8 ], [ 0, %11 ]
ret i32 %29
}