#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__ {
  double tv_sec;
  int tv_usec;
};
struct TYPE_3__ {
  double 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 *);
double get_rusage_time(void) {
  struct rusage r;
  if (getrusage(RUSAGE_SELF, &r)) {
    return 0.0;
  }
  return r.ru_utime.tv_sec + r.ru_stime.tv_sec +
         1e-6 * (r.ru_utime.tv_usec + r.ru_stime.tv_usec);
}


x86 assembly (clang, -O0):
<get_rusage_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2ec1(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <getrusage@plt>
cmp    $0x0,%rax
je     1141 <get_rusage_time+0x31>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    116a <get_rusage_time+0x5a>
movsd  -0x18(%rbp),%xmm1
addsd  -0x28(%rbp),%xmm1
mov    -0x10(%rbp),%eax
add    -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xea3(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rusage_time>:
sub    $0x28,%rsp
mov    0x2ec5(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <getrusage@plt>
xorps  %xmm0,%xmm0
test   %rax,%rax
je     1134 <get_rusage_time+0x24>
add    $0x28,%rsp
ret
movsd  0x18(%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
mov    0x10(%rsp),%eax
add    0x20(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xea9(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { double, i32 }
%struct.TYPE_3__ = type { double, i32 }
@RUSAGE_SELF = global i32 0
define double @get_rusage_time() {
%1 = alloca double
%2 = alloca %struct.rusage
%3 = load i32, i32* @RUSAGE_SELF
%4 = call i64 @getrusage(i32 %3, %struct.rusage* %2)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
store double 0.000000e+00, double* %1
br label %24
7: ; preds = %0
%8 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 1
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
%10 = load double, double* %9
%11 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 0
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %11, i32 0, i32 0
%13 = load double, double* %12
%14 = fadd double %10, %13
%15 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 1
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %18, i32 0, i32 1
%20 = load i32, i32* %19
%21 = add nsw i32 %17, %20
%22 = sitofp i32 %21 to double
%23 = call double @llvm.fmuladd.f64(double 0x3EB0C6F7A0B5ED8D, double %22, double %14)
store double %23, double* %1
br label %24
24: ; preds = %7, %6
%25 = load double, double* %1
ret double %25
}

LLVM IR (-O2):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { double, i32 }
%struct.TYPE_3__ = type { double, i32 }
@RUSAGE_SELF = global i32 0
define double @get_rusage_time() {
%1 = alloca %struct.rusage
%2 = bitcast %struct.rusage* %1 to i8*
%3 = load i32, i32* @RUSAGE_SELF
%4 = call i64 @getrusage(i32 %3, %struct.rusage* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %0
%7 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1, i32 0
%8 = load double, double* %7
%9 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 0
%10 = load double, double* %9
%11 = fadd double %8, %10
%12 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 1
%15 = load i32, i32* %14
%16 = add nsw i32 %15, %13
%17 = sitofp i32 %16 to double
%18 = call double @llvm.fmuladd.f64(double %17, double 0x3EB0C6F7A0B5ED8D, double %11)
br label %19
19: ; preds = %0, %6
%20 = phi double [ %18, %6 ], [ 0.000000e+00, %0 ]
ret double %20
}