int get_intersection(double x0, double y0, double x1, double y1, double xd0,
                     double yd0, double xd1, double yd1, double *xmin,
                     double *ymin, double *xmax, double *ymax) {
  double tmp;
  if (x0 > x1) {
    tmp = x0;
    x0 = x1;
    x1 = tmp;
  }
  if (y0 > y1) {
    tmp = y0;
    y0 = y1;
    y1 = tmp;
  }
  if (xd0 > xd1) {
    tmp = xd0;
    xd0 = xd1;
    xd1 = tmp;
  }
  if (yd0 > yd1) {
    tmp = yd0;
    yd0 = yd1;
    yd1 = tmp;
  }
  if (x0 > xd1 || xd0 > x1 || y0 > yd1 || yd0 > y1)
    return 0;
  *xmin = (x0 < xd0 ? xd0 : x0);
  *xmax = (x1 > xd1 ? xd1 : x1);
  *ymin = (y0 < yd0 ? yd0 : y0);
  *ymax = (y1 > yd1 ? yd1 : y1);
  return 1;
}


x86 assembly (clang, -O0):
<get_intersection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  %xmm6,-0x40(%rbp)
movsd  %xmm7,-0x48(%rbp)
mov    %rdi,-0x50(%rbp)
mov    %rsi,-0x58(%rbp)
mov    %rdx,-0x60(%rbp)
mov    %rcx,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    116e <get_intersection+0x6e>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    119c <get_intersection+0x9c>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    11ca <get_intersection+0xca>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    11f8 <get_intersection+0xf8>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
ja     1238 <get_intersection+0x138>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
ja     1238 <get_intersection+0x138>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
ja     1238 <get_intersection+0x138>
movsd  -0x38(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1244 <get_intersection+0x144>
movl   $0x0,-0x4(%rbp)
jmp    133d <get_intersection+0x23d>
movsd  -0x10(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1267 <get_intersection+0x167>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    1271 <get_intersection+0x171>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    129d <get_intersection+0x19d>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    12a7 <get_intersection+0x1a7>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
mov    -0x60(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12da <get_intersection+0x1da>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    12e7 <get_intersection+0x1e7>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    1319 <get_intersection+0x219>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    1326 <get_intersection+0x226>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
mov    -0x68(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_intersection>:
movapd %xmm1,%xmm8
maxsd  %xmm3,%xmm8
movapd %xmm7,%xmm9
minsd  %xmm5,%xmm9
xor    %eax,%eax
ucomisd %xmm8,%xmm9
ja     117f <get_intersection+0x7f>
movapd %xmm2,%xmm11
minsd  %xmm0,%xmm11
movapd %xmm4,%xmm10
maxsd  %xmm6,%xmm10
ucomisd %xmm10,%xmm11
ja     117f <get_intersection+0x7f>
maxsd  %xmm2,%xmm0
minsd  %xmm4,%xmm6
ucomisd %xmm0,%xmm6
ja     117f <get_intersection+0x7f>
minsd  %xmm1,%xmm3
maxsd  %xmm7,%xmm5
ucomisd %xmm5,%xmm3
ja     117f <get_intersection+0x7f>
maxsd  %xmm11,%xmm6
movsd  %xmm6,(%rdi)
minsd  %xmm0,%xmm10
movsd  %xmm10,(%rdx)
maxsd  %xmm3,%xmm9
movsd  %xmm9,(%rsi)
minsd  %xmm8,%xmm5
movsd  %xmm5,(%rcx)
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @get_intersection(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double* %8, double* %9, double* %10, double* %11) {
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double*
%23 = alloca double*
%24 = alloca double*
%25 = alloca double*
%26 = alloca double
store double %0, double* %14
store double %1, double* %15
store double %2, double* %16
store double %3, double* %17
store double %4, double* %18
store double %5, double* %19
store double %6, double* %20
store double %7, double* %21
store double* %8, double** %22
store double* %9, double** %23
store double* %10, double** %24
store double* %11, double** %25
%27 = load double, double* %14
%28 = load double, double* %16
%29 = fcmp ogt double %27, %28
br i1 %29, label %30, label %34
30: ; preds = %12
%31 = load double, double* %14
store double %31, double* %26
%32 = load double, double* %16
store double %32, double* %14
%33 = load double, double* %26
store double %33, double* %16
br label %34
34: ; preds = %30, %12
%35 = load double, double* %15
%36 = load double, double* %17
%37 = fcmp ogt double %35, %36
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load double, double* %15
store double %39, double* %26
%40 = load double, double* %17
store double %40, double* %15
%41 = load double, double* %26
store double %41, double* %17
br label %42
42: ; preds = %38, %34
%43 = load double, double* %18
%44 = load double, double* %20
%45 = fcmp ogt double %43, %44
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load double, double* %18
store double %47, double* %26
%48 = load double, double* %20
store double %48, double* %18
%49 = load double, double* %26
store double %49, double* %20
br label %50
50: ; preds = %46, %42
%51 = load double, double* %19
%52 = load double, double* %21
%53 = fcmp ogt double %51, %52
br i1 %53, label %54, label %58
54: ; preds = %50
%55 = load double, double* %19
store double %55, double* %26
%56 = load double, double* %21
store double %56, double* %19
%57 = load double, double* %26
store double %57, double* %21
br label %58
58: ; preds = %54, %50
%59 = load double, double* %14
%60 = load double, double* %20
%61 = fcmp ogt double %59, %60
br i1 %61, label %74, label %62
62: ; preds = %58
%63 = load double, double* %18
%64 = load double, double* %16
%65 = fcmp ogt double %63, %64
br i1 %65, label %74, label %66
66: ; preds = %62
%67 = load double, double* %15
%68 = load double, double* %21
%69 = fcmp ogt double %67, %68
br i1 %69, label %74, label %70
70: ; preds = %66
%71 = load double, double* %19
%72 = load double, double* %17
%73 = fcmp ogt double %71, %72
br i1 %73, label %74, label %75
74: ; preds = %70, %66, %62, %58
store i32 0, i32* %13
br label %116
75: ; preds = %70
%76 = load double, double* %14
%77 = load double, double* %18
%78 = fcmp olt double %76, %77
br i1 %78, label %79, label %81
79: ; preds = %75
%80 = load double, double* %18
br label %83
81: ; preds = %75
%82 = load double, double* %14
br label %83
83: ; preds = %81, %79
%84 = phi double [ %80, %79 ], [ %82, %81 ]
%85 = load double*, double** %22
store double %84, double* %85
%86 = load double, double* %16
%87 = load double, double* %20
%88 = fcmp ogt double %86, %87
br i1 %88, label %89, label %91
89: ; preds = %83
%90 = load double, double* %20
br label %93
91: ; preds = %83
%92 = load double, double* %16
br label %93
93: ; preds = %91, %89
%94 = phi double [ %90, %89 ], [ %92, %91 ]
%95 = load double*, double** %24
store double %94, double* %95
%96 = load double, double* %15
%97 = load double, double* %19
%98 = fcmp olt double %96, %97
br i1 %98, label %99, label %101
99: ; preds = %93
%100 = load double, double* %19
br label %103
101: ; preds = %93
%102 = load double, double* %15
br label %103
103: ; preds = %101, %99
%104 = phi double [ %100, %99 ], [ %102, %101 ]
%105 = load double*, double** %23
store double %104, double* %105
%106 = load double, double* %17
%107 = load double, double* %21
%108 = fcmp ogt double %106, %107
br i1 %108, label %109, label %111
109: ; preds = %103
%110 = load double, double* %21
br label %113
111: ; preds = %103
%112 = load double, double* %17
br label %113
113: ; preds = %111, %109
%114 = phi double [ %110, %109 ], [ %112, %111 ]
%115 = load double*, double** %25
store double %114, double* %115
store i32 1, i32* %13
br label %116
116: ; preds = %113, %74
%117 = load i32, i32* %13
ret i32 %117
}

LLVM IR (-O2):
define i32 @get_intersection(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double* nocapture writeonly %8, double* nocapture writeonly %9, double* nocapture writeonly %10, double* nocapture writeonly %11) {
%13 = fcmp ogt double %0, %2
%14 = select i1 %13, double %0, double %2
%15 = select i1 %13, double %2, double %0
%16 = fcmp ogt double %1, %3
%17 = select i1 %16, double %1, double %3
%18 = select i1 %16, double %3, double %1
%19 = fcmp ogt double %4, %6
%20 = select i1 %19, double %6, double %4
%21 = select i1 %19, double %4, double %6
%22 = fcmp ogt double %5, %7
%23 = select i1 %22, double %7, double %5
%24 = select i1 %22, double %5, double %7
%25 = fcmp ogt double %15, %21
%26 = fcmp ogt double %20, %14
%27 = or i1 %25, %26
%28 = fcmp ogt double %18, %24
%29 = or i1 %27, %28
%30 = fcmp ogt double %23, %17
%31 = or i1 %30, %29
br i1 %31, label %41, label %32
32: ; preds = %12
%33 = fcmp olt double %15, %20
%34 = select i1 %33, double %20, double %15
store double %34, double* %8
%35 = fcmp ogt double %14, %21
%36 = select i1 %35, double %21, double %14
store double %36, double* %10
%37 = fcmp olt double %18, %23
%38 = select i1 %37, double %23, double %18
store double %38, double* %9
%39 = fcmp ogt double %17, %24
%40 = select i1 %39, double %24, double %17
store double %40, double* %11
br label %41
41: ; preds = %12, %32
%42 = phi i32 [ 1, %32 ], [ 0, %12 ]
ret i32 %42
}