#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 */

/* Variables and functions */
double fabs(double);
int ClipWithBorder(double delta, double diff, double *tEnter, double *tLeave) {
  double t;
  t = diff / delta;
  if (fabs(t) < 1.e-5)
    return 0;
  if (delta < 0.0) {
    if (t > *tLeave)
      return 0;
    else if (t > *tEnter)
      *tEnter = t;
  } else {
    if (t < *tEnter)
      return 0;
    else if (t < *tLeave)
      *tLeave = t;
  }
  return 1;
}


x86 assembly (clang, -O0):
<ClipWithBorder>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movaps 0xedf(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xec3(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1153 <ClipWithBorder+0x53>
movl   $0x0,-0x4(%rbp)
jmp    1202 <ClipWithBorder+0x102>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11aa <ClipWithBorder+0xaa>
movsd  -0x30(%rbp),%xmm0
mov    -0x28(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    1180 <ClipWithBorder+0x80>
movl   $0x0,-0x4(%rbp)
jmp    1202 <ClipWithBorder+0x102>
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    11a0 <ClipWithBorder+0xa0>
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11a5 <ClipWithBorder+0xa5>
jmp    11fb <ClipWithBorder+0xfb>
movsd  -0x30(%rbp),%xmm1
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    11cd <ClipWithBorder+0xcd>
movl   $0x0,-0x4(%rbp)
jmp    1202 <ClipWithBorder+0x102>
movsd  -0x30(%rbp),%xmm1
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f1 <ClipWithBorder+0xf1>
movsd  -0x30(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11f6 <ClipWithBorder+0xf6>
jmp    11fb <ClipWithBorder+0xfb>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ClipWithBorder>:
divsd  %xmm0,%xmm1
movapd 0xef4(%rip),%xmm2
andpd  %xmm1,%xmm2
xor    %eax,%eax
movsd  0xef6(%rip),%xmm3
ucomisd %xmm2,%xmm3
ja     113b <ClipWithBorder+0x3b>
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jbe    113c <ClipWithBorder+0x3c>
ucomisd (%rsi),%xmm1
ja     113b <ClipWithBorder+0x3b>
mov    $0x1,%eax
ucomisd (%rdi),%xmm1
ja     1158 <ClipWithBorder+0x58>
ret
movsd  (%rdi),%xmm0
ucomisd %xmm1,%xmm0
ja     113b <ClipWithBorder+0x3b>
movsd  (%rsi),%xmm0
mov    $0x1,%eax
ucomisd %xmm1,%xmm0
mov    %rsi,%rdi
jbe    113b <ClipWithBorder+0x3b>
movsd  %xmm1,(%rdi)
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @ClipWithBorder(double %0, double %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double*
%9 = alloca double*
%10 = alloca double
store double %0, double* %6
store double %1, double* %7
store double* %2, double** %8
store double* %3, double** %9
%11 = load double, double* %7
%12 = load double, double* %6
%13 = fdiv double %11, %12
store double %13, double* %10
%14 = load double, double* %10
%15 = call double @llvm.fabs.f64(double %14)
%16 = fcmp olt double %15, 1.000000e-05
br i1 %16, label %17, label %18
17: ; preds = %4
store i32 0, i32* %5
br label %54
18: ; preds = %4
%19 = load double, double* %6
%20 = fcmp olt double %19, 0.000000e+00
br i1 %20, label %21, label %37
21: ; preds = %18
%22 = load double, double* %10
%23 = load double*, double** %9
%24 = load double, double* %23
%25 = fcmp ogt double %22, %24
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 0, i32* %5
br label %54
27: ; preds = %21
%28 = load double, double* %10
%29 = load double*, double** %8
%30 = load double, double* %29
%31 = fcmp ogt double %28, %30
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load double, double* %10
%34 = load double*, double** %8
store double %33, double* %34
br label %35
35: ; preds = %32, %27
br label %36
36: ; preds = %35
br label %53
37: ; preds = %18
%38 = load double, double* %10
%39 = load double*, double** %8
%40 = load double, double* %39
%41 = fcmp olt double %38, %40
br i1 %41, label %42, label %43
42: ; preds = %37
store i32 0, i32* %5
br label %54
43: ; preds = %37
%44 = load double, double* %10
%45 = load double*, double** %9
%46 = load double, double* %45
%47 = fcmp olt double %44, %46
br i1 %47, label %48, label %51
48: ; preds = %43
%49 = load double, double* %10
%50 = load double*, double** %9
store double %49, double* %50
br label %51
51: ; preds = %48, %43
br label %52
52: ; preds = %51
br label %53
53: ; preds = %52, %36
store i32 1, i32* %5
br label %54
54: ; preds = %53, %42, %26, %17
%55 = load i32, i32* %5
ret i32 %55
}

LLVM IR (-O2):
define i32 @ClipWithBorder(double %0, double %1, double* nocapture %2, double* nocapture %3) {
%5 = fdiv double %1, %0
%6 = tail call double @llvm.fabs.f64(double %5)
%7 = fcmp olt double %6, 1.000000e-05
br i1 %7, label %24, label %8
8: ; preds = %4
%9 = fcmp olt double %0, 0.000000e+00
br i1 %9, label %10, label %16
10: ; preds = %8
%11 = load double, double* %3
%12 = fcmp ogt double %5, %11
br i1 %12, label %24, label %13
13: ; preds = %10
%14 = load double, double* %2
%15 = fcmp ogt double %5, %14
br i1 %15, label %22, label %24
16: ; preds = %8
%17 = load double, double* %2
%18 = fcmp olt double %5, %17
br i1 %18, label %24, label %19
19: ; preds = %16
%20 = load double, double* %3
%21 = fcmp olt double %5, %20
br i1 %21, label %22, label %24
22: ; preds = %19, %13
%23 = phi double* [ %2, %13 ], [ %3, %19 ]
store double %5, double* %23
br label %24
24: ; preds = %22, %13, %19, %16, %10, %4
%25 = phi i32 [ 0, %4 ], [ 0, %10 ], [ 0, %16 ], [ 1, %19 ], [ 1, %13 ], [ 1, %22 ]
ret i32 %25
}