int TimeWindowOverLap(z1, z2, x1, x2, type)
double z1, z2, x1, x2;
int *type;
{
  int k = 0, ov = 0;
  if (z1 < x1)
    k -= 2;
  else
    k += 2;
  if (z1 < x2)
    k--;
  else
    k++;
  if (z2 < x1)
    k--;
  else
    k++;
  if (z2 < x2)
    k--;
  else
    k++;
  if (abs(k) < 5)
    ov = 1;
  *type = k;
  return (ov);
}


x86 assembly (clang, -O0):
<TimeWindowOverLap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1160 <TimeWindowOverLap+0x50>
mov    -0x2c(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x2c(%rbp)
jmp    1169 <TimeWindowOverLap+0x59>
mov    -0x2c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    118b <TimeWindowOverLap+0x7b>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    1194 <TimeWindowOverLap+0x84>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b6 <TimeWindowOverLap+0xa6>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    11bf <TimeWindowOverLap+0xaf>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11e1 <TimeWindowOverLap+0xd1>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ea <TimeWindowOverLap+0xda>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1030 <abs@plt>
cmp    $0x5,%eax
jge    1202 <TimeWindowOverLap+0xf2>
movl   $0x1,-0x30(%rbp)
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimeWindowOverLap>:
xor    %eax,%eax
ucomisd %xmm0,%xmm2
setbe  %al
mov    %eax,%ecx
shl    $0x2,%ecx
ucomisd %xmm0,%xmm3
lea    -0x2(,%rax,4),%eax
cmovbe %ecx,%eax
xor    %ecx,%ecx
ucomisd %xmm1,%xmm2
setbe  %cl
lea    (%rax,%rcx,2),%eax
xor    %ecx,%ecx
ucomisd %xmm1,%xmm3
setbe  %cl
lea    (%rax,%rcx,2),%ecx
add    $0xfffffffd,%ecx
mov    %ecx,%edx
neg    %edx
cmovs  %ecx,%edx
xor    %eax,%eax
cmp    $0x5,%edx
setb   %al
mov    %ecx,(%rdi)
ret

LLVM IR (-O0):
define i32 @TimeWindowOverLap(double %0, double %1, double %2, double %3, i32* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store i32* %4, i32** %10
store i32 0, i32* %11
store i32 0, i32* %12
%13 = load double, double* %6
%14 = load double, double* %8
%15 = fcmp olt double %13, %14
br i1 %15, label %16, label %19
16: ; preds = %5
%17 = load i32, i32* %11
%18 = sub nsw i32 %17, 2
store i32 %18, i32* %11
br label %22
19: ; preds = %5
%20 = load i32, i32* %11
%21 = add nsw i32 %20, 2
store i32 %21, i32* %11
br label %22
22: ; preds = %19, %16
%23 = load double, double* %6
%24 = load double, double* %9
%25 = fcmp olt double %23, %24
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* %11
%28 = add nsw i32 %27, -1
store i32 %28, i32* %11
br label %32
29: ; preds = %22
%30 = load i32, i32* %11
%31 = add nsw i32 %30, 1
store i32 %31, i32* %11
br label %32
32: ; preds = %29, %26
%33 = load double, double* %7
%34 = load double, double* %8
%35 = fcmp olt double %33, %34
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i32, i32* %11
%38 = add nsw i32 %37, -1
store i32 %38, i32* %11
br label %42
39: ; preds = %32
%40 = load i32, i32* %11
%41 = add nsw i32 %40, 1
store i32 %41, i32* %11
br label %42
42: ; preds = %39, %36
%43 = load double, double* %7
%44 = load double, double* %9
%45 = fcmp olt double %43, %44
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = load i32, i32* %11
%48 = add nsw i32 %47, -1
store i32 %48, i32* %11
br label %52
49: ; preds = %42
%50 = load i32, i32* %11
%51 = add nsw i32 %50, 1
store i32 %51, i32* %11
br label %52
52: ; preds = %49, %46
%53 = load i32, i32* %11
%54 = call i32 @abs(i32 %53)
%55 = icmp slt i32 %54, 5
br i1 %55, label %56, label %57
56: ; preds = %52
store i32 1, i32* %12
br label %57
57: ; preds = %56, %52
%58 = load i32, i32* %11
%59 = load i32*, i32** %10
store i32 %58, i32* %59
%60 = load i32, i32* %12
ret i32 %60
}

LLVM IR (-O2):
define i32 @TimeWindowOverLap(double %0, double %1, double %2, double %3, i32* nocapture writeonly %4) {
%6 = fcmp olt double %0, %2
%7 = select i1 %6, i32 -2, i32 2
%8 = fcmp olt double %0, %3
%9 = add nsw i32 %7, -1
%10 = or i32 %7, 1
%11 = select i1 %8, i32 %9, i32 %10
%12 = fcmp olt double %1, %2
%13 = select i1 %12, i32 -1, i32 1
%14 = add nsw i32 %11, %13
%15 = fcmp olt double %1, %3
%16 = add nsw i32 %14, -1
%17 = or i32 %14, 1
%18 = select i1 %15, i32 %16, i32 %17
%19 = tail call i32 @llvm.abs.i32(i32 %18, i1 true)
%20 = icmp ult i32 %19, 5
%21 = zext i1 %20 to i32
store i32 %18, i32* %4
ret i32 %21
}