#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;
  long tv_usec;
};
struct itimerval {
  TYPE_1__ it_value;
};

/* Variables and functions */
int /*<<< orphan*/ ITIMER_REAL;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *, double);
scalar_t__ setitimer(int /*<<< orphan*/, struct itimerval *,
                     int /*<<< orphan*/ *);
void schedule_oneshot_itimer(double delay) {
  struct itimerval it = {};
  it.it_value.tv_sec = delay;
  it.it_value.tv_usec = (long)(delay * 1e6) % 1000000;
  if (setitimer(ITIMER_REAL, &it, NULL) < 0)
    error(1, errno, "schedule itimer %.3lfs", delay);
}


x86 assembly (clang, -O0):
<schedule_oneshot_itimer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xea1(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x10(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <setitimer@plt>
cmp    $0x0,%rax
jge    11b6 <schedule_oneshot_itimer+0x86>
mov    0x2e3a(%rip),%rax
mov    (%rax),%esi
movsd  -0x8(%rbp),%xmm0
mov    $0x1,%edi
lea    0xe57(%rip),%rdx
call   1050 <error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<schedule_oneshot_itimer>:
sub    $0x18,%rsp
movsd  0xed4(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rcx
movsd  %xmm0,(%rsp)
movsd  %xmm0,0x8(%rsp)
movabs $0x431bde82d7b634db,%rdx
de 1b 43
mov    %rcx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x12,%rdx
add    %rax,%rdx
imul   $0xf4240,%rdx,%rax
sub    %rax,%rcx
mov    %rcx,0x10(%rsp)
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <setitimer@plt>
test   %rax,%rax
js     118c <schedule_oneshot_itimer+0x6c>
add    $0x18,%rsp
ret
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
lea    0xe6c(%rip),%rdx
mov    $0x1,%edi
movsd  (%rsp),%xmm0
add    $0x18,%rsp
jmp    1040 <error@plt>

LLVM IR (-O0):
%struct.itimerval = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { double, i64 }
@ITIMER_REAL = global i32 0
@errno = global i32 0
@.str = [23 x i8] c"schedule itimer %.3lfs\00"
define void @schedule_oneshot_itimer(double %0) {
%2 = alloca double
%3 = alloca %struct.itimerval
store double %0, double* %2
%4 = bitcast %struct.itimerval* %3 to i8*
%5 = load double, double* %2
%6 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%7 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i32 0, i32 0
store double %5, double* %7
%8 = load double, double* %2
%9 = fmul double %8, 1.000000e+06
%10 = fptosi double %9 to i64
%11 = srem i64 %10, 1000000
%12 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%13 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %12, i32 0, i32 1
store i64 %11, i64* %13
%14 = load i32, i32* @ITIMER_REAL
%15 = call i64 @setitimer(i32 %14, %struct.itimerval* %3, i32* null)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %1
%18 = load i32, i32* @errno
%19 = load double, double* %2
%20 = call i32 @error(i32 1, i32 %18, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %19)
br label %21
21: ; preds = %17, %1
ret void
}

LLVM IR (-O2):
%struct.itimerval = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { double, i64 }
@ITIMER_REAL = global i32 0
@errno = global i32 0
@.str = [23 x i8] c"schedule itimer %.3lfs\00"
define void @schedule_oneshot_itimer(double %0) {
%2 = alloca %struct.itimerval
%3 = bitcast %struct.itimerval* %2 to i8*
%4 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 0, i32 0
store double %0, double* %4
%5 = fmul double %0, 1.000000e+06
%6 = fptosi double %5 to i64
%7 = srem i64 %6, 1000000
%8 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 0, i32 1
store i64 %7, i64* %8
%9 = load i32, i32* @ITIMER_REAL
%10 = call i64 @setitimer(i32 %9, %struct.itimerval* %2, i32* null)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i32, i32* @errno
%14 = tail call i32 @error(i32 1, i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %0)
br label %15
15: ; preds = %12, %1
ret void
}