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

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
scalar_t__ getrusage(int /*<<< orphan*/, struct rusage *);
int /*<<< orphan*/ perror(char *);
double current_usertime_secs(void) {
  double usertime, systemtime;
  struct rusage usage;
  if (getrusage(RUSAGE_SELF, &usage) < 0) {
    perror("get rusage");
    return -1;
  }
  usertime = usage.ru_utime.tv_sec + (usage.ru_utime.tv_usec * 1e-6);
  systemtime = usage.ru_stime.tv_sec + (usage.ru_stime.tv_usec * 1e-6);
  return (usertime + systemtime);
}


x86 assembly (clang, -O0):
<current_usertime_secs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <getrusage@plt>
cmp    $0x0,%rax
jge    1162 <current_usertime_secs+0x42>
lea    0xec5(%rip),%rdi
call   1040 <perror@plt>
movsd  0xeb0(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11af <current_usertime_secs+0x8f>
cvtsi2sdl -0x20(%rbp),%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  0xe8c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<current_usertime_secs>:
sub    $0x18,%rsp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <getrusage@plt>
test   %rax,%rax
js     117e <current_usertime_secs+0x5e>
movaps (%rsp),%xmm0
movss  (%rsp),%xmm1
shufps $0xe4,%xmm0,%xmm1
shufps $0xe2,%xmm0,%xmm1
cvtdq2pd %xmm1,%xmm1
movss  0x4(%rsp),%xmm2
shufps $0xf4,%xmm0,%xmm2
shufps $0xf2,%xmm0,%xmm2
cvtdq2pd %xmm2,%xmm2
mulpd  0xe97(%rip),%xmm2
addpd  %xmm1,%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
addsd  %xmm2,%xmm0
add    $0x18,%rsp
ret
lea    0xe93(%rip),%rdi
call   1040 <perror@plt>
movsd  0xe7e(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i32 }
%struct.TYPE_3__ = type { i32, i32 }
@RUSAGE_SELF = global i32 0
@.str = [11 x i8] c"get rusage\00"
define double @current_usertime_secs() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca %struct.rusage
%5 = load i32, i32* @RUSAGE_SELF
%6 = call i64 @getrusage(i32 %5, %struct.rusage* %4)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store double -1.000000e+00, double* %1
br label %32
10: ; preds = %0
%11 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i32 0, i32 1
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = sitofp i32 %13 to double
%15 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i32 0, i32 1
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = sitofp i32 %17 to double
%19 = call double @llvm.fmuladd.f64(double %18, double 0x3EB0C6F7A0B5ED8D, double %14)
store double %19, double* %2
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i32 0, i32 0
%21 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = sitofp i32 %22 to double
%24 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i32 0, i32 0
%25 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %24, i32 0, i32 1
%26 = load i32, i32* %25
%27 = sitofp i32 %26 to double
%28 = call double @llvm.fmuladd.f64(double %27, double 0x3EB0C6F7A0B5ED8D, double %23)
store double %28, double* %3
%29 = load double, double* %2
%30 = load double, double* %3
%31 = fadd double %29, %30
store double %31, double* %1
br label %32
32: ; preds = %10, %8
%33 = load double, double* %1
ret double %33
}

LLVM IR (-O2):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i32 }
%struct.TYPE_3__ = type { i32, i32 }
@RUSAGE_SELF = global i32 0
@.str = [11 x i8] c"get rusage\00"
define double @current_usertime_secs() {
%1 = alloca <4 x i32>
%2 = bitcast <4 x i32>* %1 to %struct.rusage*
%3 = bitcast <4 x i32>* %1 to i8*
%4 = load i32, i32* @RUSAGE_SELF
%5 = call i64 @getrusage(i32 %4, %struct.rusage* %2)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %25
9: ; preds = %0
%10 = load <4 x i32>, <4 x i32>* %1
%11 = shufflevector <4 x i32> %10, <4 x i32> poison, <2 x i32> <i32 2, i32 undef>
%12 = shufflevector <4 x i32> %10, <4 x i32> poison, <2 x i32> <i32 3, i32 undef>
%13 = getelementptr inbounds <4 x i32>, <4 x i32>* %1, i64 0, i64 0
%14 = load i32, i32* %13
%15 = insertelement <2 x i32> %11, i32 %14, i64 1
%16 = sitofp <2 x i32> %15 to <2 x double>
%17 = getelementptr inbounds <4 x i32>, <4 x i32>* %1, i64 0, i64 1
%18 = load i32, i32* %17
%19 = insertelement <2 x i32> %12, i32 %18, i64 1
%20 = sitofp <2 x i32> %19 to <2 x double>
%21 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> <double 0x3EB0C6F7A0B5ED8D, double 0x3EB0C6F7A0B5ED8D>, <2 x double> %16)
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%23 = fadd <2 x double> %21, %22
%24 = extractelement <2 x double> %23, i64 0
br label %25
25: ; preds = %9, %7
%26 = phi double [ -1.000000e+00, %7 ], [ %24, %9 ]
ret double %26
}