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

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
double time_stamp() {
  double result = 0;
  struct rusage usage;
  if (!getrusage(RUSAGE_SELF, &usage)) {
    result += usage.ru_utime.tv_sec + 1e-6 * usage.ru_utime.tv_usec;
    result += usage.ru_stime.tv_sec + 1e-6 * usage.ru_stime.tv_usec;
  }
  return result;
}


x86 assembly (clang, -O0):
<time_stamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    0x2eb9(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <getrusage@plt>
cmp    $0x0,%eax
jne    1185 <time_stamp+0x75>
cvtsi2sdq -0x10(%rbp),%xmm1
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xeb2(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
cvtsi2sdq -0x20(%rbp),%xmm1
cvtsi2sdl -0x28(%rbp),%xmm0
movsd  0xe8d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_stamp>:
sub    $0x28,%rsp
mov    0x2ec5(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <getrusage@plt>
xorps  %xmm0,%xmm0
test   %eax,%eax
je     1133 <time_stamp+0x23>
add    $0x28,%rsp
ret
xorps  %xmm0,%xmm0
cvtsi2sdq 0x20(%rsp),%xmm0
cvtsi2sdl 0x18(%rsp),%xmm1
movsd  0xeb5(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
xorpd  %xmm3,%xmm3
cvtsi2sdq 0x10(%rsp),%xmm4
xorps  %xmm0,%xmm0
cvtsi2sdl 0x8(%rsp),%xmm0
addsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm0
addsd  %xmm4,%xmm0
addsd  %xmm3,%xmm0
add    $0x28,%rsp
ret

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

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