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

/* Variables and functions */
double LONG_MAX;
double LONG_MIN;
scalar_t__ isnan(double);
time_t sas_convert_time(double time, time_t epoch) {
  time += epoch;
  if (isnan(time))
    return 0;
  if (time > (double)LONG_MAX)
    return LONG_MAX;
  if (time < (double)LONG_MIN)
    return LONG_MIN;
  return time;
}


x86 assembly (clang, -O0):
<sas_convert_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     1152 <sas_convert_time+0x42>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b6 <sas_convert_time+0xa6>
movsd  -0x10(%rbp),%xmm0
mov    0x2e7a(%rip),%rax
ucomisd (%rax),%xmm0
jbe    117d <sas_convert_time+0x6d>
mov    0x2e69(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b6 <sas_convert_time+0xa6>
movsd  -0x10(%rbp),%xmm1
mov    0x2e5f(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ac <sas_convert_time+0x9c>
mov    0x2e4a(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b6 <sas_convert_time+0xa6>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sas_convert_time>:
push   %rax
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1030 <isnan@plt>
xorpd  %xmm0,%xmm0
test   %rax,%rax
je     112a <sas_convert_time+0x1a>
pop    %rax
ret
mov    0x2ea7(%rip),%rax
movsd  (%rax),%xmm0
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1128 <sas_convert_time+0x18>
mov    0x2ea1(%rip),%rax
movsd  (%rax),%xmm0
maxsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@LONG_MAX = global double 0.000000e+00
@LONG_MIN = global double 0.000000e+00
define double @sas_convert_time(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %5
%7 = load double, double* %4
%8 = fadd double %7, %6
store double %8, double* %4
%9 = load double, double* %4
%10 = call i64 @isnan(double %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %2
store double 0.000000e+00, double* %3
br label %27
13: ; preds = %2
%14 = load double, double* %4
%15 = load double, double* @LONG_MAX
%16 = fcmp ogt double %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load double, double* @LONG_MAX
store double %18, double* %3
br label %27
19: ; preds = %13
%20 = load double, double* %4
%21 = load double, double* @LONG_MIN
%22 = fcmp olt double %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = load double, double* @LONG_MIN
store double %24, double* %3
br label %27
25: ; preds = %19
%26 = load double, double* %4
store double %26, double* %3
br label %27
27: ; preds = %25, %23, %17, %12
%28 = load double, double* %3
ret double %28
}

LLVM IR (-O2):
@LONG_MAX = global double 0.000000e+00
@LONG_MIN = global double 0.000000e+00
define double @sas_convert_time(double %0, double %1) {
%3 = fadd double %0, %1
%4 = tail call i64 @isnan(double %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = load double, double* @LONG_MAX
%8 = fcmp ogt double %3, %7
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = load double, double* @LONG_MIN
%11 = fcmp olt double %3, %10
%12 = select i1 %11, double %10, double %3
br label %13
13: ; preds = %9, %6, %2
%14 = phi double [ 0.000000e+00, %2 ], [ %7, %6 ], [ %12, %9 ]
ret double %14
}