#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_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  double tv_sec;
  scalar_t__ tv_usec;
};
struct rusage {
  TYPE_1__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ assert(int);
int getrusage(int /*<<< orphan*/, struct rusage *);
double my_clock(void) {
  struct rusage ru;
  int cc = getrusage(RUSAGE_SELF, &ru);
  assert(cc == 0);
  return (ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec * 1e-6);
}


x86 assembly (clang, -O0):
<my_clock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1040 <getrusage@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movsd  -0x10(%rbp),%xmm1
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_clock>:
sub    $0x18,%rsp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1040 <getrusage@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
cvtsi2sdq 0x10(%rsp),%xmm0
mulsd  0xead(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { double, i64 }
@RUSAGE_SELF = global i32 0
define double @my_clock() {
%1 = alloca %struct.rusage
%2 = alloca i32
%3 = load i32, i32* @RUSAGE_SELF
%4 = call i32 @getrusage(i32 %3, %struct.rusage* %1)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 0
%10 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %9, i32 0, i32 0
%11 = load double, double* %10
%12 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 0
%13 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %12, i32 0, i32 1
%14 = load i64, i64* %13
%15 = sitofp i64 %14 to double
%16 = call double @llvm.fmuladd.f64(double %15, double 0x3EB0C6F7A0B5ED8D, double %11)
ret double %16
}

LLVM IR (-O2):
%struct.rusage = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { double, i64 }
@RUSAGE_SELF = global i32 0
define double @my_clock() {
%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
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 0
%9 = load double, double* %8
%10 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 1
%11 = load i64, i64* %10
%12 = sitofp i64 %11 to double
%13 = call double @llvm.fmuladd.f64(double %12, double 0x3EB0C6F7A0B5ED8D, double %9)
ret double %13
}