#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 */

/* Type definitions */
struct timespec {
  scalar_t__ tv_nsec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
scalar_t__ errno;
double mono_time() {
  struct timespec now;
  clock_gettime(CLOCK_MONOTONIC, &now);
  if (errno) {
    abort();
  }
  return (double)now.tv_sec + ((double)now.tv_nsec * 1e-9);
}


x86 assembly (clang, -O0):
<mono_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    0x2e97(%rip),%rax
cmpq   $0x0,(%rax)
je     1152 <mono_time+0x32>
mov    $0x0,%al
call   1030 <abort@plt>
cvtsi2sdq -0x8(%rbp),%xmm1
cvtsi2sdq -0x10(%rbp),%xmm0
movsd  0xe9a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mono_time>:
sub    $0x18,%rsp
mov    0x2ebd(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1040 <clock_gettime@plt>
mov    0x2e9a(%rip),%rax
cmpq   $0x0,(%rax)
jne    1163 <mono_time+0x43>
cvtsi2sdq 0x10(%rsp),%xmm1
cvtsi2sdq 0x8(%rsp),%xmm0
mulsd  0xea6(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@CLOCK_MONOTONIC = global i32 0
@errno = global i64 0
define double @mono_time() {
%1 = alloca %struct.timespec
%2 = load i32, i32* @CLOCK_MONOTONIC
%3 = call i32 @clock_gettime(i32 %2, %struct.timespec* %1)
%4 = load i64, i64* @errno
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 (...) @abort()
unreachable
8: ; preds = %0
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%10 = load i64, i64* %9
%11 = sitofp i64 %10 to double
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%13 = load i64, i64* %12
%14 = sitofp i64 %13 to double
%15 = call double @llvm.fmuladd.f64(double %14, double 1.000000e-09, double %11)
ret double %15
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@CLOCK_MONOTONIC = global i32 0
@errno = global i64 0
define double @mono_time() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = load i32, i32* @CLOCK_MONOTONIC
%4 = call i32 @clock_gettime(i32 %3, %struct.timespec* %1)
%5 = load i64, i64* @errno
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 (...) @abort()
unreachable
9: ; preds = %0
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%11 = load i64, i64* %10
%12 = sitofp i64 %11 to double
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%14 = load i64, i64* %13
%15 = sitofp i64 %14 to double
%16 = call double @llvm.fmuladd.f64(double %15, double 1.000000e-09, double %12)
ret double %16
}