#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_stime;
  TYPE_1__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ exit(int);
scalar_t__ getrusage(int /*<<< orphan*/, struct rusage *);
double ptime_ms_d(void) {
  double t;
  struct rusage info;
  if (getrusage(RUSAGE_SELF, &info))
    exit(1);
  t = ((double)info.ru_utime.tv_sec + (double)info.ru_stime.tv_sec) * 1000.0 +
      ((double)info.ru_utime.tv_usec + (double)info.ru_stime.tv_usec) / 1000.0;
  return (t);
}


x86 assembly (clang, -O0):
<ptime_ms_d>:
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
je     114e <ptime_ms_d+0x2e>
mov    $0x1,%edi
call   1040 <exit@plt>
cvtsi2sdq -0x10(%rbp),%xmm0
cvtsi2sdq -0x20(%rbp),%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdq -0x18(%rbp),%xmm1
cvtsi2sdq -0x28(%rbp),%xmm2
addsd  %xmm2,%xmm1
movsd  0xe8a(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xe7e(%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):
<ptime_ms_d>:
sub    $0x28,%rsp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <getrusage@plt>
test   %rax,%rax
jne    117c <ptime_ms_d+0x5c>
cvtsi2sdq 0x20(%rsp),%xmm1
cvtsi2sdq 0x10(%rsp),%xmm0
cvtsi2sdq 0x18(%rsp),%xmm2
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x8(%rsp),%xmm1
addsd  %xmm2,%xmm1
movsd  0xe95(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x28,%rsp
ret
mov    $0x1,%edi
call   1040 <exit@plt>

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
define double @ptime_ms_d() {
%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 %8
6: ; preds = %0
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 1
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 1
%11 = load i64, i64* %10
%12 = sitofp i64 %11 to double
%13 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %13, i32 0, i32 1
%15 = load i64, i64* %14
%16 = sitofp i64 %15 to double
%17 = fadd double %12, %16
%18 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, 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 = 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 i64, i64* %23
%25 = sitofp i64 %24 to double
%26 = fadd double %21, %25
%27 = fdiv double %26, 1.000000e+03
%28 = call double @llvm.fmuladd.f64(double %17, double 1.000000e+03, double %27)
store double %28, double* %1
%29 = load double, double* %1
ret double %29
}

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
define double @ptime_ms_d() {
%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 %8, label %6
6: ; preds = %0
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1, i32 1
%10 = load i64, i64* %9
%11 = sitofp i64 %10 to double
%12 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 1
%13 = load i64, i64* %12
%14 = sitofp i64 %13 to double
%15 = fadd double %11, %14
%16 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1, i32 0
%17 = load i64, i64* %16
%18 = sitofp i64 %17 to double
%19 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 0
%20 = load i64, i64* %19
%21 = sitofp i64 %20 to double
%22 = fadd double %18, %21
%23 = fdiv double %22, 1.000000e+03
%24 = call double @llvm.fmuladd.f64(double %15, double 1.000000e+03, double %23)
ret double %24
}