#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 int uintmax_t;
typedef scalar_t__ time_t;

/* Variables and functions */
int INTMAX_MAX;
int UINTMAX_MAX;
double subtract(time_t time1, time_t time0) {
  if (!((time_t)-1 < 0))
    return time1 - time0;
  else {
    uintmax_t dt = (uintmax_t)time1 - (uintmax_t)time0;
    double delta = dt;
    if (UINTMAX_MAX / 2 < INTMAX_MAX) {
      uintmax_t hdt = dt / 2;
      time_t ht1 = time1 / 2;
      time_t ht0 = time0 / 2;
      time_t dht = ht1 - ht0;
      if (2 < dht - hdt + 1) {
        delta = dt + 2.0L * (UINTMAX_MAX - UINTMAX_MAX / 2);
      }
    }
    return delta;
  }
}


x86 assembly (clang, -O0):
<subtract>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2ec6(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    0x2ea5(%rip),%rcx
cmp    (%rcx),%eax
jge    11d9 <subtract+0xd9>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rcx
movslq -0x24(%rbp),%rax
sub    %rax,%rcx
add    $0x1,%rcx
mov    $0x2,%eax
cmp    %rcx,%rax
jge    11d4 <subtract+0xd4>
mov    -0x14(%rbp),%eax
mov    %eax,-0x48(%rbp)
fildl  -0x48(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,%edx
shr    $0x1f,%edx
mov    %eax,%ecx
add    %edx,%ecx
sar    %ecx
sub    %ecx,%eax
mov    %eax,-0x44(%rbp)
fildl  -0x44(%rbp)
fadd   %st,%st(0)
faddp  %st,%st(1)
fstpl  -0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11d9 <subtract+0xd9>
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<subtract>:
mov    %edi,%r9d
sub    %esi,%r9d
cvtsi2sd %r9d,%xmm0
mov    0x2ede(%rip),%rcx
mov    (%rcx),%r8d
mov    %r8d,%edx
shr    $0x1f,%edx
add    %r8d,%edx
sar    %edx
mov    0x2eb9(%rip),%rcx
cmp    (%rcx),%edx
jge    1182 <subtract+0x82>
mov    %r9d,%ecx
shr    $0x1f,%ecx
add    %r9d,%ecx
sar    %ecx
neg    %ecx
mov    %rdi,%rax
shr    $0x3f,%rax
add    %rdi,%rax
sar    %rax
mov    %rsi,%rdi
shr    $0x3f,%rdi
add    %rsi,%rdi
sar    %rdi
sub    %rdi,%rax
movslq %ecx,%rcx
add    %rax,%rcx
cmp    $0x2,%rcx
jl     1182 <subtract+0x82>
mov    %r9d,-0x10(%rsp)
sub    %edx,%r8d
mov    %r8d,-0xc(%rsp)
fildl  -0xc(%rsp)
fadd   %st,%st(0)
fiaddl -0x10(%rsp)
fstpl  -0x8(%rsp)
movsd  -0x8(%rsp),%xmm0
ret

LLVM IR (-O0):
@UINTMAX_MAX = global i32 0
@INTMAX_MAX = global i32 0
define double @subtract(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%11 = load i64, i64* %3
%12 = trunc i64 %11 to i32
%13 = load i64, i64* %4
%14 = trunc i64 %13 to i32
%15 = sub nsw i32 %12, %14
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = sitofp i32 %16 to double
store double %17, double* %6
%18 = load i32, i32* @UINTMAX_MAX
%19 = sdiv i32 %18, 2
%20 = load i32, i32* @INTMAX_MAX
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %49
22: ; preds = %2
%23 = load i32, i32* %5
%24 = sdiv i32 %23, 2
store i32 %24, i32* %7
%25 = load i64, i64* %3
%26 = sdiv i64 %25, 2
store i64 %26, i64* %8
%27 = load i64, i64* %4
%28 = sdiv i64 %27, 2
store i64 %28, i64* %9
%29 = load i64, i64* %8
%30 = load i64, i64* %9
%31 = sub nsw i64 %29, %30
store i64 %31, i64* %10
%32 = load i64, i64* %10
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = sub nsw i64 %32, %34
%36 = add nsw i64 %35, 1
%37 = icmp slt i64 2, %36
br i1 %37, label %38, label %48
38: ; preds = %22
%39 = load i32, i32* %5
%40 = sitofp i32 %39 to x86_fp80
%41 = load i32, i32* @UINTMAX_MAX
%42 = load i32, i32* @UINTMAX_MAX
%43 = sdiv i32 %42, 2
%44 = sub nsw i32 %41, %43
%45 = sitofp i32 %44 to x86_fp80
%46 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK40008000000000000000, x86_fp80 %45, x86_fp80 %40)
%47 = fptrunc x86_fp80 %46 to double
store double %47, double* %6
br label %48
48: ; preds = %38, %22
br label %49
49: ; preds = %48, %2
%50 = load double, double* %6
ret double %50
}

LLVM IR (-O2):
@UINTMAX_MAX = global i32 0
@INTMAX_MAX = global i32 0
define double @subtract(i64 %0, i64 %1) {
%3 = trunc i64 %0 to i32
%4 = trunc i64 %1 to i32
%5 = sub nsw i32 %3, %4
%6 = sitofp i32 %5 to double
%7 = load i32, i32* @UINTMAX_MAX
%8 = sdiv i32 %7, 2
%9 = load i32, i32* @INTMAX_MAX
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %25
11: ; preds = %2
%12 = sdiv i32 %5, -2
%13 = sdiv i64 %0, 2
%14 = sdiv i64 %1, -2
%15 = add nsw i64 %14, %13
%16 = sext i32 %12 to i64
%17 = add i64 %15, %16
%18 = icmp sgt i64 %17, 1
br i1 %18, label %19, label %25
19: ; preds = %11
%20 = sitofp i32 %5 to x86_fp80
%21 = sub nsw i32 %7, %8
%22 = sitofp i32 %21 to x86_fp80
%23 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %22, x86_fp80 0xK40008000000000000000, x86_fp80 %20)
%24 = fptrunc x86_fp80 %23 to double
br label %25
25: ; preds = %11, %19, %2
%26 = phi double [ %6, %2 ], [ %24, %19 ], [ %6, %11 ]
ret double %26
}