int dig_find_intersection(double ax1, double ay1, double ax2, double ay2,
                          double bx1, double by1, double bx2, double by2,
                          double *x, double *y) {
  register double d, r1, r2;
  double t;
  d = ((ax2 - ax1) * (by1 - by2) - (ay2 - ay1) * (bx1 - bx2));
  if (d) {
    r1 = ((bx1 - ax1) * (by1 - by2) - (by1 - ay1) * (bx1 - bx2)) / d;
    r2 = ((ax2 - ax1) * (by1 - ay1) - (ay2 - ay1) * (bx1 - ax1)) / d;
    if (r1 < 0 || r1 > 1 || r2 < 0 || r2 > 1) {
      return 0;
    }
    *x = ax1 + r1 * (ax2 - ax1);
    *y = ay1 + r1 * (ay2 - ay1);
    return 1;
  }
  if (((bx1 - ax1) * (by1 - by2) - (by1 - ay1) * (bx1 - bx2)) ||
      ((ax2 - ax1) * (by1 - ay1) - (ay2 - ay1) * (bx1 - ax1))) {
    return 0;
  }
  if (ax1 != ax2) {
    if (ax1 > ax2) {
      t = ax1;
      ax1 = ax2;
      ax2 = t;
      t = ay1;
      ay1 = ay2;
      ay2 = t;
    }
    if (bx1 > bx2) {
      t = bx1;
      bx1 = bx2;
      bx2 = t;
      t = by1;
      by1 = by2;
      by2 = t;
    }
    if (ax1 > bx2)
      return 0;
    if (ax2 < bx1)
      return 0;
    if (ax1 == bx2) {
      *x = ax1;
      *y = ay1;
      return 1;
    }
    if (ax2 == bx1) {
      *x = ax2;
      *y = ay2;
      return 1;
    }
    if (ax1 > bx1 && ax1 < bx2) {
      *x = ax1;
      *y = ay1;
    } else {
      *x = ax2;
      *y = ay2;
    }
    return -1;
  } else {
    if (ay1 > ay2) {
      t = ay1;
      ay1 = ay2;
      ay2 = t;
      t = ax1;
      ax1 = ax2;
      ax2 = t;
    }
    if (by1 > by2) {
      t = by1;
      by1 = by2;
      by2 = t;
      t = by1;
      by1 = by2;
      by2 = t;
    }
    if (ay1 > by2)
      return 0;
    if (ay2 < by1)
      return 0;
    if (ay1 == by2) {
      *x = ax1;
      *y = ay1;
      return 1;
    }
    if (ay2 == by1) {
      *x = ax2;
      *y = ay2;
      return 1;
    }
    if (ay1 > by1 && ay1 < by2) {
      *x = ax1;
      *y = ay1;
    } else {
      *x = ax2;
      *y = ay2;
    }
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<dig_find_intersection>:
push   %rbp
mov    %rsp,%rbp
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)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
subsd  -0x48(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm3
subsd  -0x40(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a1 <dig_find_intersection+0xa1>
jp     11a1 <dig_find_intersection+0xa1>
jmp    12f5 <dig_find_intersection+0x1f5>
movsd  -0x30(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
subsd  -0x48(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm3
subsd  -0x40(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm3
subsd  -0x10(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x68(%rbp),%xmm0
ja     1295 <dig_find_intersection+0x195>
movsd  -0x68(%rbp),%xmm0
movsd  0xd9a(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1295 <dig_find_intersection+0x195>
xorps  %xmm0,%xmm0
ucomisd -0x70(%rbp),%xmm0
ja     1295 <dig_find_intersection+0x195>
movsd  -0x70(%rbp),%xmm0
movsd  0xd75(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12a1 <dig_find_intersection+0x1a1>
movl   $0x0,-0x4(%rbp)
jmp    1742 <dig_find_intersection+0x642>
movsd  -0x10(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
subsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1742 <dig_find_intersection+0x642>
movsd  -0x30(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
subsd  -0x48(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm3
subsd  -0x40(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13b6 <dig_find_intersection+0x2b6>
jp     13b6 <dig_find_intersection+0x2b6>
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm3
subsd  -0x10(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13b6 <dig_find_intersection+0x2b6>
jp     13b6 <dig_find_intersection+0x2b6>
jmp    13c2 <dig_find_intersection+0x2c2>
movl   $0x0,-0x4(%rbp)
jmp    1742 <dig_find_intersection+0x642>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    13dd <dig_find_intersection+0x2dd>
jp     13dd <dig_find_intersection+0x2dd>
jmp    1592 <dig_find_intersection+0x492>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1429 <dig_find_intersection+0x329>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1475 <dig_find_intersection+0x375>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1491 <dig_find_intersection+0x391>
movl   $0x0,-0x4(%rbp)
jmp    1742 <dig_find_intersection+0x642>
movsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    14b1 <dig_find_intersection+0x3b1>
movl   $0x0,-0x4(%rbp)
jmp    1742 <dig_find_intersection+0x642>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jne    14ed <dig_find_intersection+0x3ed>
jp     14ed <dig_find_intersection+0x3ed>
movsd  -0x10(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1742 <dig_find_intersection+0x642>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jne    1529 <dig_find_intersection+0x429>
jp     1529 <dig_find_intersection+0x429>
movsd  -0x20(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1742 <dig_find_intersection+0x642>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    156c <dig_find_intersection+0x46c>
movsd  -0x10(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    156c <dig_find_intersection+0x46c>
movsd  -0x10(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1586 <dig_find_intersection+0x486>
movsd  -0x20(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1742 <dig_find_intersection+0x642>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    15de <dig_find_intersection+0x4de>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    162a <dig_find_intersection+0x52a>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    1646 <dig_find_intersection+0x546>
movl   $0x0,-0x4(%rbp)
jmp    1742 <dig_find_intersection+0x642>
movsd  -0x28(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1666 <dig_find_intersection+0x566>
movl   $0x0,-0x4(%rbp)
jmp    1742 <dig_find_intersection+0x642>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jne    16a2 <dig_find_intersection+0x5a2>
jp     16a2 <dig_find_intersection+0x5a2>
movsd  -0x10(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1742 <dig_find_intersection+0x642>
movsd  -0x28(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jne    16de <dig_find_intersection+0x5de>
jp     16de <dig_find_intersection+0x5de>
movsd  -0x20(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1742 <dig_find_intersection+0x642>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1721 <dig_find_intersection+0x621>
movsd  -0x18(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1721 <dig_find_intersection+0x621>
movsd  -0x10(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    173b <dig_find_intersection+0x63b>
movsd  -0x20(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<dig_find_intersection>:
movapd %xmm2,%xmm8
subsd  %xmm0,%xmm8
movapd %xmm5,%xmm11
subsd  %xmm7,%xmm11
movapd %xmm3,%xmm9
subsd  %xmm1,%xmm9
movapd %xmm4,%xmm15
subsd  %xmm6,%xmm15
movapd 0xecf(%rip),%xmm12
xorpd  %xmm9,%xmm12
movapd %xmm15,%xmm10
mulsd  %xmm9,%xmm10
movapd %xmm8,%xmm13
mulsd  %xmm11,%xmm13
subsd  %xmm10,%xmm13
movapd %xmm4,%xmm14
subsd  %xmm0,%xmm14
movapd %xmm5,%xmm10
subsd  %xmm1,%xmm10
mulsd  %xmm10,%xmm15
mulsd  %xmm14,%xmm11
subsd  %xmm15,%xmm11
xorpd  %xmm15,%xmm15
ucomisd %xmm15,%xmm13
jne    1184 <dig_find_intersection+0x84>
jnp    1208 <dig_find_intersection+0x108>
mulsd  %xmm12,%xmm14
mulsd  %xmm8,%xmm10
addsd  %xmm14,%xmm10
unpcklpd %xmm11,%xmm10
unpcklpd %xmm13,%xmm13
divpd  %xmm13,%xmm10
xorpd  %xmm2,%xmm2
movapd %xmm10,%xmm3
cmpltpd %xmm2,%xmm3
movmskpd %xmm3,%ecx
xor    %eax,%eax
test   $0x2,%cl
jne    1230 <dig_find_intersection+0x130>
movapd %xmm10,%xmm2
unpckhpd %xmm10,%xmm2
ucomisd 0xe43(%rip),%xmm2
ja     1230 <dig_find_intersection+0x130>
test   $0x1,%cl
jne    1230 <dig_find_intersection+0x130>
ucomisd 0xe33(%rip),%xmm10
ja     1230 <dig_find_intersection+0x130>
mulsd  %xmm2,%xmm8
addsd  %xmm0,%xmm8
movsd  %xmm8,(%rdi)
mulsd  %xmm2,%xmm9
addsd  %xmm1,%xmm9
mov    $0x1,%eax
movapd %xmm9,%xmm3
movsd  %xmm3,(%rsi)
jmp    1230 <dig_find_intersection+0x130>
xor    %eax,%eax
ucomisd %xmm15,%xmm11
jne    1230 <dig_find_intersection+0x130>
jp     1230 <dig_find_intersection+0x130>
mulsd  %xmm12,%xmm14
mulsd  %xmm10,%xmm8
addsd  %xmm14,%xmm8
xorpd  %xmm9,%xmm9
ucomisd %xmm9,%xmm8
jne    1230 <dig_find_intersection+0x130>
jnp    1231 <dig_find_intersection+0x131>
ret
ucomisd %xmm2,%xmm0
jne    1239 <dig_find_intersection+0x139>
jnp    1245 <dig_find_intersection+0x145>
jbe    1255 <dig_find_intersection+0x155>
movapd %xmm1,%xmm5
movapd %xmm0,%xmm7
jmp    1265 <dig_find_intersection+0x165>
ucomisd %xmm3,%xmm1
jbe    129b <dig_find_intersection+0x19b>
movapd %xmm1,%xmm4
movapd %xmm0,%xmm6
jmp    12ab <dig_find_intersection+0x1ab>
movapd %xmm3,%xmm5
movapd %xmm2,%xmm7
movapd %xmm1,%xmm3
movapd %xmm0,%xmm2
movapd %xmm6,%xmm0
minsd  %xmm4,%xmm0
ucomisd %xmm7,%xmm0
ja     1230 <dig_find_intersection+0x130>
maxsd  %xmm6,%xmm4
ucomisd %xmm4,%xmm2
ja     1230 <dig_find_intersection+0x130>
jne    1281 <dig_find_intersection+0x181>
jnp    12c3 <dig_find_intersection+0x1c3>
ucomisd %xmm0,%xmm7
jne    12eb <dig_find_intersection+0x1eb>
jp     12eb <dig_find_intersection+0x1eb>
movsd  %xmm7,(%rdi)
mov    $0x1,%eax
movapd %xmm5,%xmm3
jmp    1202 <dig_find_intersection+0x102>
movapd %xmm3,%xmm4
movapd %xmm2,%xmm6
movapd %xmm1,%xmm3
movapd %xmm0,%xmm2
ucomisd %xmm4,%xmm5
ja     1230 <dig_find_intersection+0x130>
ucomisd %xmm7,%xmm3
ja     1230 <dig_find_intersection+0x130>
jne    12d1 <dig_find_intersection+0x1d1>
jp     12d1 <dig_find_intersection+0x1d1>
movsd  %xmm2,(%rdi)
mov    $0x1,%eax
jmp    1202 <dig_find_intersection+0x102>
ucomisd %xmm5,%xmm4
jne    1307 <dig_find_intersection+0x207>
jp     1307 <dig_find_intersection+0x207>
movsd  %xmm6,(%rdi)
mov    $0x1,%eax
movapd %xmm4,%xmm3
jmp    1202 <dig_find_intersection+0x102>
ucomisd %xmm0,%xmm2
seta   %al
ucomisd %xmm2,%xmm4
seta   %cl
test   %cl,%al
jne    1321 <dig_find_intersection+0x221>
movapd %xmm7,%xmm2
movapd %xmm5,%xmm3
jmp    1321 <dig_find_intersection+0x221>
ucomisd %xmm5,%xmm3
seta   %al
ucomisd %xmm3,%xmm7
seta   %cl
test   %cl,%al
jne    1321 <dig_find_intersection+0x221>
movapd %xmm6,%xmm2
movapd %xmm4,%xmm3
movsd  %xmm2,(%rdi)
mov    $0xffffffff,%eax
jmp    1202 <dig_find_intersection+0x102>

LLVM IR (-O0):
define i32 @dig_find_intersection(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double* %8, double* %9) {
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%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
store double %0, double* %12
store double %1, double* %13
store double %2, double* %14
store double %3, double* %15
store double %4, double* %16
store double %5, double* %17
store double %6, double* %18
store double %7, double* %19
store double* %8, double** %20
store double* %9, double** %21
%26 = load double, double* %14
%27 = load double, double* %12
%28 = fsub double %26, %27
%29 = load double, double* %17
%30 = load double, double* %19
%31 = fsub double %29, %30
%32 = load double, double* %15
%33 = load double, double* %13
%34 = fsub double %32, %33
%35 = load double, double* %16
%36 = load double, double* %18
%37 = fsub double %35, %36
%38 = fmul double %34, %37
%39 = fneg double %38
%40 = call double @llvm.fmuladd.f64(double %28, double %31, double %39)
store double %40, double* %22
%41 = load double, double* %22
%42 = fcmp une double %41, 0.000000e+00
br i1 %42, label %43, label %105
43: ; preds = %10
%44 = load double, double* %16
%45 = load double, double* %12
%46 = fsub double %44, %45
%47 = load double, double* %17
%48 = load double, double* %19
%49 = fsub double %47, %48
%50 = load double, double* %17
%51 = load double, double* %13
%52 = fsub double %50, %51
%53 = load double, double* %16
%54 = load double, double* %18
%55 = fsub double %53, %54
%56 = fmul double %52, %55
%57 = fneg double %56
%58 = call double @llvm.fmuladd.f64(double %46, double %49, double %57)
%59 = load double, double* %22
%60 = fdiv double %58, %59
store double %60, double* %23
%61 = load double, double* %14
%62 = load double, double* %12
%63 = fsub double %61, %62
%64 = load double, double* %17
%65 = load double, double* %13
%66 = fsub double %64, %65
%67 = load double, double* %15
%68 = load double, double* %13
%69 = fsub double %67, %68
%70 = load double, double* %16
%71 = load double, double* %12
%72 = fsub double %70, %71
%73 = fmul double %69, %72
%74 = fneg double %73
%75 = call double @llvm.fmuladd.f64(double %63, double %66, double %74)
%76 = load double, double* %22
%77 = fdiv double %75, %76
store double %77, double* %24
%78 = load double, double* %23
%79 = fcmp olt double %78, 0.000000e+00
br i1 %79, label %89, label %80
80: ; preds = %43
%81 = load double, double* %23
%82 = fcmp ogt double %81, 1.000000e+00
br i1 %82, label %89, label %83
83: ; preds = %80
%84 = load double, double* %24
%85 = fcmp olt double %84, 0.000000e+00
br i1 %85, label %89, label %86
86: ; preds = %83
%87 = load double, double* %24
%88 = fcmp ogt double %87, 1.000000e+00
br i1 %88, label %89, label %90
89: ; preds = %86, %83, %80, %43
store i32 0, i32* %11
br label %282
90: ; preds = %86
%91 = load double, double* %12
%92 = load double, double* %23
%93 = load double, double* %14
%94 = load double, double* %12
%95 = fsub double %93, %94
%96 = call double @llvm.fmuladd.f64(double %92, double %95, double %91)
%97 = load double*, double** %20
store double %96, double* %97
%98 = load double, double* %13
%99 = load double, double* %23
%100 = load double, double* %15
%101 = load double, double* %13
%102 = fsub double %100, %101
%103 = call double @llvm.fmuladd.f64(double %99, double %102, double %98)
%104 = load double*, double** %21
store double %103, double* %104
store i32 1, i32* %11
br label %282
105: ; preds = %10
%106 = load double, double* %16
%107 = load double, double* %12
%108 = fsub double %106, %107
%109 = load double, double* %17
%110 = load double, double* %19
%111 = fsub double %109, %110
%112 = load double, double* %17
%113 = load double, double* %13
%114 = fsub double %112, %113
%115 = load double, double* %16
%116 = load double, double* %18
%117 = fsub double %115, %116
%118 = fmul double %114, %117
%119 = fneg double %118
%120 = call double @llvm.fmuladd.f64(double %108, double %111, double %119)
%121 = fcmp une double %120, 0.000000e+00
br i1 %121, label %139, label %122
122: ; preds = %105
%123 = load double, double* %14
%124 = load double, double* %12
%125 = fsub double %123, %124
%126 = load double, double* %17
%127 = load double, double* %13
%128 = fsub double %126, %127
%129 = load double, double* %15
%130 = load double, double* %13
%131 = fsub double %129, %130
%132 = load double, double* %16
%133 = load double, double* %12
%134 = fsub double %132, %133
%135 = fmul double %131, %134
%136 = fneg double %135
%137 = call double @llvm.fmuladd.f64(double %125, double %128, double %136)
%138 = fcmp une double %137, 0.000000e+00
br i1 %138, label %139, label %140
139: ; preds = %122, %105
store i32 0, i32* %11
br label %282
140: ; preds = %122
%141 = load double, double* %12
%142 = load double, double* %14
%143 = fcmp une double %141, %142
br i1 %143, label %144, label %213
144: ; preds = %140
%145 = load double, double* %12
%146 = load double, double* %14
%147 = fcmp ogt double %145, %146
br i1 %147, label %148, label %155
148: ; preds = %144
%149 = load double, double* %12
store double %149, double* %25
%150 = load double, double* %14
store double %150, double* %12
%151 = load double, double* %25
store double %151, double* %14
%152 = load double, double* %13
store double %152, double* %25
%153 = load double, double* %15
store double %153, double* %13
%154 = load double, double* %25
store double %154, double* %15
br label %155
155: ; preds = %148, %144
%156 = load double, double* %16
%157 = load double, double* %18
%158 = fcmp ogt double %156, %157
br i1 %158, label %159, label %166
159: ; preds = %155
%160 = load double, double* %16
store double %160, double* %25
%161 = load double, double* %18
store double %161, double* %16
%162 = load double, double* %25
store double %162, double* %18
%163 = load double, double* %17
store double %163, double* %25
%164 = load double, double* %19
store double %164, double* %17
%165 = load double, double* %25
store double %165, double* %19
br label %166
166: ; preds = %159, %155
%167 = load double, double* %12
%168 = load double, double* %18
%169 = fcmp ogt double %167, %168
br i1 %169, label %170, label %171
170: ; preds = %166
store i32 0, i32* %11
br label %282
171: ; preds = %166
%172 = load double, double* %14
%173 = load double, double* %16
%174 = fcmp olt double %172, %173
br i1 %174, label %175, label %176
175: ; preds = %171
store i32 0, i32* %11
br label %282
176: ; preds = %171
%177 = load double, double* %12
%178 = load double, double* %18
%179 = fcmp oeq double %177, %178
br i1 %179, label %180, label %185
180: ; preds = %176
%181 = load double, double* %12
%182 = load double*, double** %20
store double %181, double* %182
%183 = load double, double* %13
%184 = load double*, double** %21
store double %183, double* %184
store i32 1, i32* %11
br label %282
185: ; preds = %176
%186 = load double, double* %14
%187 = load double, double* %16
%188 = fcmp oeq double %186, %187
br i1 %188, label %189, label %194
189: ; preds = %185
%190 = load double, double* %14
%191 = load double*, double** %20
store double %190, double* %191
%192 = load double, double* %15
%193 = load double*, double** %21
store double %192, double* %193
store i32 1, i32* %11
br label %282
194: ; preds = %185
%195 = load double, double* %12
%196 = load double, double* %16
%197 = fcmp ogt double %195, %196
br i1 %197, label %198, label %207
198: ; preds = %194
%199 = load double, double* %12
%200 = load double, double* %18
%201 = fcmp olt double %199, %200
br i1 %201, label %202, label %207
202: ; preds = %198
%203 = load double, double* %12
%204 = load double*, double** %20
store double %203, double* %204
%205 = load double, double* %13
%206 = load double*, double** %21
store double %205, double* %206
br label %212
207: ; preds = %198, %194
%208 = load double, double* %14
%209 = load double*, double** %20
store double %208, double* %209
%210 = load double, double* %15
%211 = load double*, double** %21
store double %210, double* %211
br label %212
212: ; preds = %207, %202
store i32 -1, i32* %11
br label %282
213: ; preds = %140
%214 = load double, double* %13
%215 = load double, double* %15
%216 = fcmp ogt double %214, %215
br i1 %216, label %217, label %224
217: ; preds = %213
%218 = load double, double* %13
store double %218, double* %25
%219 = load double, double* %15
store double %219, double* %13
%220 = load double, double* %25
store double %220, double* %15
%221 = load double, double* %12
store double %221, double* %25
%222 = load double, double* %14
store double %222, double* %12
%223 = load double, double* %25
store double %223, double* %14
br label %224
224: ; preds = %217, %213
%225 = load double, double* %17
%226 = load double, double* %19
%227 = fcmp ogt double %225, %226
br i1 %227, label %228, label %235
228: ; preds = %224
%229 = load double, double* %17
store double %229, double* %25
%230 = load double, double* %19
store double %230, double* %17
%231 = load double, double* %25
store double %231, double* %19
%232 = load double, double* %17
store double %232, double* %25
%233 = load double, double* %19
store double %233, double* %17
%234 = load double, double* %25
store double %234, double* %19
br label %235
235: ; preds = %228, %224
%236 = load double, double* %13
%237 = load double, double* %19
%238 = fcmp ogt double %236, %237
br i1 %238, label %239, label %240
239: ; preds = %235
store i32 0, i32* %11
br label %282
240: ; preds = %235
%241 = load double, double* %15
%242 = load double, double* %17
%243 = fcmp olt double %241, %242
br i1 %243, label %244, label %245
244: ; preds = %240
store i32 0, i32* %11
br label %282
245: ; preds = %240
%246 = load double, double* %13
%247 = load double, double* %19
%248 = fcmp oeq double %246, %247
br i1 %248, label %249, label %254
249: ; preds = %245
%250 = load double, double* %12
%251 = load double*, double** %20
store double %250, double* %251
%252 = load double, double* %13
%253 = load double*, double** %21
store double %252, double* %253
store i32 1, i32* %11
br label %282
254: ; preds = %245
%255 = load double, double* %15
%256 = load double, double* %17
%257 = fcmp oeq double %255, %256
br i1 %257, label %258, label %263
258: ; preds = %254
%259 = load double, double* %14
%260 = load double*, double** %20
store double %259, double* %260
%261 = load double, double* %15
%262 = load double*, double** %21
store double %261, double* %262
store i32 1, i32* %11
br label %282
263: ; preds = %254
%264 = load double, double* %13
%265 = load double, double* %17
%266 = fcmp ogt double %264, %265
br i1 %266, label %267, label %276
267: ; preds = %263
%268 = load double, double* %13
%269 = load double, double* %19
%270 = fcmp olt double %268, %269
br i1 %270, label %271, label %276
271: ; preds = %267
%272 = load double, double* %12
%273 = load double*, double** %20
store double %272, double* %273
%274 = load double, double* %13
%275 = load double*, double** %21
store double %274, double* %275
br label %281
276: ; preds = %267, %263
%277 = load double, double* %14
%278 = load double*, double** %20
store double %277, double* %278
%279 = load double, double* %15
%280 = load double*, double** %21
store double %279, double* %280
br label %281
281: ; preds = %276, %271
store i32 -1, i32* %11
br label %282
282: ; preds = %281, %258, %249, %244, %239, %212, %189, %180, %175, %170, %139, %90, %89
%283 = load i32, i32* %11
ret i32 %283
}

LLVM IR (-O2):
define i32 @dig_find_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) {
%11 = fsub double %2, %0
%12 = fsub double %5, %7
%13 = fsub double %3, %1
%14 = fsub double %4, %6
%15 = fneg double %13
%16 = fmul double %14, %15
%17 = tail call double @llvm.fmuladd.f64(double %11, double %12, double %16)
%18 = fcmp une double %17, 0.000000e+00
%19 = fsub double %4, %0
%20 = fsub double %5, %1
%21 = fneg double %20
%22 = fmul double %14, %21
%23 = tail call double @llvm.fmuladd.f64(double %19, double %12, double %22)
br i1 %18, label %24, label %45
24: ; preds = %10
%25 = fmul double %19, %15
%26 = tail call double @llvm.fmuladd.f64(double %11, double %20, double %25)
%27 = insertelement <2 x double> poison, double %26, i64 0
%28 = insertelement <2 x double> %27, double %23, i64 1
%29 = insertelement <2 x double> poison, double %17, i64 0
%30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> zeroinitializer
%31 = fdiv <2 x double> %28, %30
%32 = extractelement <2 x double> %31, i64 1
%33 = fcmp ogt double %32, 1.000000e+00
%34 = fcmp olt <2 x double> %31, zeroinitializer
%35 = extractelement <2 x i1> %34, i64 1
%36 = or i1 %35, %33
%37 = extractelement <2 x i1> %34, i64 0
%38 = select i1 %36, i1 true, i1 %37
%39 = extractelement <2 x double> %31, i64 0
%40 = fcmp ogt double %39, 1.000000e+00
%41 = select i1 %38, i1 true, i1 %40
br i1 %41, label %105, label %42
42: ; preds = %24
%43 = tail call double @llvm.fmuladd.f64(double %32, double %11, double %0)
store double %43, double* %8
%44 = tail call double @llvm.fmuladd.f64(double %32, double %13, double %1)
br label %102
45: ; preds = %10
%46 = fcmp une double %23, 0.000000e+00
br i1 %46, label %105, label %47
47: ; preds = %45
%48 = fmul double %19, %15
%49 = tail call double @llvm.fmuladd.f64(double %11, double %20, double %48)
%50 = fcmp une double %49, 0.000000e+00
br i1 %50, label %105, label %51
51: ; preds = %47
%52 = fcmp une double %0, %2
br i1 %52, label %53, label %79
53: ; preds = %51
%54 = fcmp ogt double %0, %2
br i1 %54, label %55, label %56
55: ; preds = %53
br label %56
56: ; preds = %55, %53
%57 = phi double [ %1, %55 ], [ %3, %53 ]
%58 = phi double [ %0, %55 ], [ %2, %53 ]
%59 = phi double [ %3, %55 ], [ %1, %53 ]
%60 = phi double [ %2, %55 ], [ %0, %53 ]
%61 = fcmp ogt double %4, %6
%62 = select i1 %61, double %6, double %4
%63 = select i1 %61, double %4, double %6
%64 = fcmp ogt double %60, %63
%65 = fcmp olt double %58, %62
%66 = or i1 %65, %64
br i1 %66, label %105, label %67
67: ; preds = %56
%68 = fcmp oeq double %60, %63
br i1 %68, label %69, label %70
69: ; preds = %67
store double %60, double* %8
br label %102
70: ; preds = %67
%71 = fcmp oeq double %58, %62
br i1 %71, label %72, label %73
72: ; preds = %70
store double %58, double* %8
br label %102
73: ; preds = %70
%74 = fcmp ogt double %60, %62
%75 = fcmp olt double %60, %63
%76 = and i1 %74, %75
%77 = select i1 %76, double %60, double %58
%78 = select i1 %76, double %59, double %57
store double %77, double* %8
br label %102
79: ; preds = %51
%80 = fcmp ogt double %1, %3
br i1 %80, label %81, label %82
81: ; preds = %79
br label %82
82: ; preds = %81, %79
%83 = phi double [ %1, %81 ], [ %3, %79 ]
%84 = phi double [ %0, %81 ], [ %2, %79 ]
%85 = phi double [ %3, %81 ], [ %1, %79 ]
%86 = phi double [ %2, %81 ], [ %0, %79 ]
%87 = fcmp ogt double %85, %7
%88 = fcmp olt double %83, %5
%89 = or i1 %88, %87
br i1 %89, label %105, label %90
90: ; preds = %82
%91 = fcmp oeq double %85, %7
br i1 %91, label %92, label %93
92: ; preds = %90
store double %86, double* %8
br label %102
93: ; preds = %90
%94 = fcmp oeq double %83, %5
br i1 %94, label %95, label %96
95: ; preds = %93
store double %84, double* %8
br label %102
96: ; preds = %93
%97 = fcmp ogt double %85, %5
%98 = fcmp olt double %85, %7
%99 = and i1 %97, %98
%100 = select i1 %99, double %86, double %84
%101 = select i1 %99, double %85, double %83
store double %100, double* %8
br label %102
102: ; preds = %42, %69, %72, %73, %92, %95, %96
%103 = phi double [ %101, %96 ], [ %83, %95 ], [ %85, %92 ], [ %78, %73 ], [ %57, %72 ], [ %59, %69 ], [ %44, %42 ]
%104 = phi i32 [ -1, %96 ], [ 1, %95 ], [ 1, %92 ], [ -1, %73 ], [ 1, %72 ], [ 1, %69 ], [ 1, %42 ]
store double %103, double* %9
br label %105
105: ; preds = %102, %82, %56, %45, %47, %24
%106 = phi i32 [ 0, %24 ], [ 0, %47 ], [ 0, %45 ], [ 0, %56 ], [ 0, %82 ], [ %104, %102 ]
ret i32 %106
}