#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 */
typedef double time_t;
struct timespec {
  double tv_sec;
  double tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
double strtod(char const *, char **);
int /*<<< orphan*/ usage_and_exit();
void get_delay(struct timespec *delay, const char *s) {
  char *ptr;
  double n;
  n = strtod(s, &ptr);
  if (*ptr) {
    fprintf(stderr, "invalid delay: '%s'\n", s);
    usage_and_exit();
  }
  if ((((n) == (1.0 / 0.0)) || ((n) == (-1.0 / 0.0))) || ((n) != (n)) ||
      n <= 0.0) {
    fprintf(stderr, "delay out of range: '%s'\n", s);
    usage_and_exit();
  }
  delay->tv_sec = (time_t)n;
  delay->tv_nsec = (n - delay->tv_sec) * 1e9;
}


x86 assembly (clang, -O0):
<get_delay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     117f <get_delay+0x4f>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xea5(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1050 <usage_and_exit@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xe74(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11a1 <get_delay+0x71>
jp     11a1 <get_delay+0x71>
jmp    11e7 <get_delay+0xb7>
movsd  -0x20(%rbp),%xmm0
movsd  0xe5a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11c3 <get_delay+0x93>
jp     11c3 <get_delay+0x93>
jmp    11e7 <get_delay+0xb7>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    11e7 <get_delay+0xb7>
jp     11e7 <get_delay+0xb7>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1207 <get_delay+0xd7>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe32(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1050 <usage_and_exit@plt>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
movsd  0xde7(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_delay>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <strtod@plt>
mov    0x10(%rsp),%rax
cmpb   $0x0,(%rax)
movsd  %xmm0,0x8(%rsp)
je     117f <get_delay+0x4f>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
lea    0xeae(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1050 <usage_and_exit@plt>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11a1 <get_delay+0x71>
ucomisd 0xe6f(%rip),%xmm0
jae    11a1 <get_delay+0x71>
movsd  0xe6d(%rip),%xmm1
ucomisd %xmm0,%xmm1
jb     11c6 <get_delay+0x96>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1050 <usage_and_exit@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14)
subsd  %xmm0,%xmm0
mulsd  0xe39(%rip),%xmm0
movsd  %xmm0,0x8(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timespec = type { double, double }
@stderr = global i32 0
@.str = [21 x i8] c"invalid delay: '%s'\0A\00"
@.str.1 = [26 x i8] c"delay out of range: '%s'\0A\00"
define void @get_delay(%struct.timespec* %0, i8* %1) {
%3 = alloca %struct.timespec*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
store %struct.timespec* %0, %struct.timespec** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call double @strtod(i8* %7, i8** %5)
store double %8, double* %6
%9 = load i8*, i8** %5
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %4
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 (...) @usage_and_exit()
br label %17
17: ; preds = %12, %2
%18 = load double, double* %6
%19 = fcmp oeq double %18, 0x7FF0000000000000
br i1 %19, label %30, label %20
20: ; preds = %17
%21 = load double, double* %6
%22 = fcmp oeq double %21, 0xFFF0000000000000
br i1 %22, label %30, label %23
23: ; preds = %20
%24 = load double, double* %6
%25 = load double, double* %6
%26 = fcmp une double %24, %25
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = load double, double* %6
%29 = fcmp ole double %28, 0.000000e+00
br i1 %29, label %30, label %35
30: ; preds = %27, %23, %20, %17
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %4
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = call i32 (...) @usage_and_exit()
br label %35
35: ; preds = %30, %27
%36 = load double, double* %6
%37 = load %struct.timespec*, %struct.timespec** %3
%38 = getelementptr inbounds %struct.timespec, %struct.timespec* %37, i32 0, i32 0
store double %36, double* %38
%39 = load double, double* %6
%40 = load %struct.timespec*, %struct.timespec** %3
%41 = getelementptr inbounds %struct.timespec, %struct.timespec* %40, i32 0, i32 0
%42 = load double, double* %41
%43 = fsub double %39, %42
%44 = fmul double %43, 1.000000e+09
%45 = load %struct.timespec*, %struct.timespec** %3
%46 = getelementptr inbounds %struct.timespec, %struct.timespec* %45, i32 0, i32 1
store double %44, double* %46
ret void
}

LLVM IR (-O2):
%struct.timespec = type { double, double }
@stderr = global i32 0
@.str = [21 x i8] c"invalid delay: '%s'\0A\00"
@.str.1 = [26 x i8] c"delay out of range: '%s'\0A\00"
define void @get_delay(%struct.timespec* nocapture writeonly %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call double @strtod(i8* %1, i8** %3)
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %1)
%12 = tail call i32 (...) @usage_and_exit()
br label %13
13: ; preds = %9, %2
%14 = fcmp oeq double %5, 0x7FF0000000000000
%15 = fcmp oeq double %5, 0xFFF0000000000000
%16 = or i1 %14, %15
%17 = fcmp ule double %5, 0.000000e+00
%18 = or i1 %17, %16
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%22 = tail call i32 (...) @usage_and_exit()
br label %23
23: ; preds = %13, %19
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 0
store double %5, double* %24
%25 = fsub double %5, %5
%26 = fmul double %25, 1.000000e+09
%27 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 1
store double %26, double* %27
ret void
}