#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 */
int /*<<< orphan*/ crossProd(double *, double *, double *);
int /*<<< orphan*/ diffVt(double *, double *, double *);
double dotProd(double *, double *);
double fabs(double);
scalar_t__ isPntInTri(double **, double *, double *, double);
int /*<<< orphan*/ u_line(double, double *, double *, double *);
int intersect(double x[4][3], double u[], double points[4][3]) {
  int pos = 0;
  double tol = 0.000001;
  double eps = 0.000001;
  int face, i, j, k;
  double xc[3];
  double xbar[3][3];
  double xref[3], v1[3], v2[3], normal[3];
  int f_index[4][3] = {{0, 1, 2}, {1, 3, 2}, {0, 2, 3}, {0, 3, 1}};
  double n_dot_u;
  double xr_xc[3], s, pt[3];
  for (i = 0; i < 3; i++)
    xc[i] = 0.25 * (x[0][i] + x[1][i] + x[2][i] + x[3][i]);
  for (face = 0; face < 4; face++) {
    for (j = 0; j < 3; j++)
      for (k = 0; k < 3; k++)
        xbar[j][k] = x[f_index[face][j]][k];
    if (face != 2) {
      for (i = 0; i < 3; i++)
        xref[i] = xbar[0][i];
    } else {
      for (i = 0; i < 3; i++)
        xref[i] = xbar[1][i];
    }
    for (i = 0; i < 3; i++) {
      v1[i] = xbar[1][i] - xbar[0][i];
      v2[i] = xbar[2][i] - xbar[0][i];
    }
    crossProd(v1, v2, normal);
    n_dot_u = dotProd(normal, u);
    if (fabs(n_dot_u) > eps) {
      diffVt(xref, xc, xr_xc);
      s = dotProd(normal, xr_xc) / n_dot_u;
      u_line(s, xc, u, pt);
      if (isPntInTri(xbar, normal, pt, tol)) {
        for (i = 0; i < 3; i++)
          points[pos][i] = pt[i];
        pos += 1;
      }
    } else {
    }
  }
  return pos;
}


x86 assembly (clang, -O0):
<intersect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movsd  0xe7a(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe6d(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    -0x160(%rbp),%rdi
lea    0xe7a(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    121c <intersect+0xbc>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
addsd  0x18(%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
addsd  0x30(%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
addsd  0x48(%rax,%rcx,8),%xmm1
movsd  0xe08(%rip),%xmm0
mulsd  %xmm1,%xmm0
movslq -0x38(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11b7 <intersect+0x57>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    14e2 <intersect+0x382>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x3c(%rbp)
jge    12b9 <intersect+0x159>
movl   $0x0,-0x40(%rbp)
cmpl   $0x3,-0x40(%rbp)
jge    12a6 <intersect+0x146>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rdx
lea    -0x160(%rbp),%rcx
imul   $0xc,%rdx,%rdx
add    %rdx,%rcx
movslq -0x3c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x3c(%rbp),%rcx
lea    -0xb0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x40(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1245 <intersect+0xe5>
jmp    12ab <intersect+0x14b>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1234 <intersect+0xd4>
cmpl   $0x2,-0x34(%rbp)
je     1301 <intersect+0x1a1>
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    12fc <intersect+0x19c>
movslq -0x38(%rbp),%rax
movsd  -0xb0(%rbp,%rax,8),%xmm0
ff ff
movslq -0x38(%rbp),%rax
movsd  %xmm0,-0xd0(%rbp,%rax,8)
ff ff
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12ca <intersect+0x16a>
jmp    133f <intersect+0x1df>
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    133a <intersect+0x1da>
movslq -0x38(%rbp),%rax
movsd  -0x98(%rbp,%rax,8),%xmm0
ff ff
movslq -0x38(%rbp),%rax
movsd  %xmm0,-0xd0(%rbp,%rax,8)
ff ff
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1308 <intersect+0x1a8>
jmp    133f <intersect+0x1df>
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    13a9 <intersect+0x249>
movslq -0x38(%rbp),%rax
movsd  -0x98(%rbp,%rax,8),%xmm0
ff ff
movslq -0x38(%rbp),%rax
subsd  -0xb0(%rbp,%rax,8),%xmm0
ff ff
movslq -0x38(%rbp),%rax
movsd  %xmm0,-0xf0(%rbp,%rax,8)
ff ff
movslq -0x38(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm0
movslq -0x38(%rbp),%rax
subsd  -0xb0(%rbp,%rax,8),%xmm0
ff ff
movslq -0x38(%rbp),%rax
movsd  %xmm0,-0x110(%rbp,%rax,8)
ff ff
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1346 <intersect+0x1e6>
lea    -0xf0(%rbp),%rdi
lea    -0x110(%rbp),%rsi
lea    -0x130(%rbp),%rdx
call   1070 <crossProd@plt>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <dotProd@plt>
movsd  %xmm0,-0x168(%rbp)
ff
movsd  -0x168(%rbp),%xmm0
ff
movaps 0xc26(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    14ca <intersect+0x36a>
lea    -0xd0(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x180(%rbp),%rdx
call   1030 <diffVt@plt>
lea    -0x130(%rbp),%rdi
lea    -0x180(%rbp),%rsi
call   1080 <dotProd@plt>
divsd  -0x168(%rbp),%xmm0
ff
movsd  %xmm0,-0x188(%rbp)
ff
movsd  -0x188(%rbp),%xmm0
ff
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x1a0(%rbp),%rdx
call   1060 <u_line@plt>
lea    -0xb0(%rbp),%rdi
lea    -0x130(%rbp),%rsi
lea    -0x1a0(%rbp),%rdx
movsd  -0x28(%rbp),%xmm0
call   1050 <isPntInTri@plt>
cmp    $0x0,%rax
je     14c5 <intersect+0x365>
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    14bc <intersect+0x35c>
movslq -0x38(%rbp),%rax
movsd  -0x1a0(%rbp,%rax,8),%xmm0
ff ff
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    147f <intersect+0x31f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    14cf <intersect+0x36f>
jmp    14cf <intersect+0x36f>
jmp    14d4 <intersect+0x374>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1223 <intersect+0xc3>
mov    -0x1c(%rbp),%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intersect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
mov    %rdi,%rbx
movupd (%rdi),%xmm0
movupd 0x18(%rdi),%xmm1
addpd  %xmm0,%xmm1
movupd 0x30(%rdi),%xmm0
addpd  %xmm1,%xmm0
movupd 0x48(%rdi),%xmm1
addpd  %xmm0,%xmm1
mulpd  0xe75(%rip),%xmm1
movapd %xmm1,0x100(%rsp)
movsd  0x10(%rdi),%xmm0
addsd  0x28(%rdi),%xmm0
addsd  0x40(%rdi),%xmm0
addsd  0x58(%rdi),%xmm0
mulsd  0xe70(%rip),%xmm0
mov    %rdx,0x10(%rsp)
mov    %rsi,0x18(%rsp)
movsd  %xmm0,0x110(%rsp)
lea    0x38(%rsp),%rbp
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    $0x8,%r14d
lea    0x140(%rsp),%r12
mov    0x18(%rsp),%r15
jmp    1203 <intersect+0xb3>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x38(%rsp),%rbp
add    $0xc,%r14
cmp    $0x38,%r14
je     13c5 <intersect+0x275>
lea    0xe26(%rip),%rdi
movslq -0x8(%r14,%rdi,1),%rax
lea    (%rax,%rax,2),%rax
lea    (%rbx,%rax,8),%rcx
mov    0x10(%rbx,%rax,8),%rdx
mov    %rdx,0x30(%rsp)
movups (%rbx,%rax,8),%xmm0
movaps %xmm0,0x20(%rsp)
movslq -0x4(%r14,%rdi,1),%rax
lea    (%rax,%rax,2),%rax
lea    (%rbx,%rax,8),%rdx
mov    0x10(%rbx,%rax,8),%rsi
mov    %rsi,0x10(%rbp)
movups (%rbx,%rax,8),%xmm0
movups %xmm0,0x0(%rbp)
movslq (%r14,%rdi,1),%rax
lea    (%rax,%rax,2),%rax
mov    0x10(%rbx,%rax,8),%rsi
mov    %rsi,0x28(%rbp)
movups (%rbx,%rax,8),%xmm0
movups %xmm0,0x18(%rbp)
cmp    $0x20,%r14
cmovne %rcx,%rdx
mov    0x10(%rdx),%rax
mov    %rax,0xf0(%rsp)
movups (%rdx),%xmm0
movaps %xmm0,0xe0(%rsp)
movapd 0x20(%rsp),%xmm0
movupd 0x38(%rsp),%xmm1
subpd  %xmm0,%xmm1
movapd %xmm1,0xc0(%rsp)
movapd 0x50(%rsp),%xmm1
subpd  %xmm0,%xmm1
movapd %xmm1,0xa0(%rsp)
movsd  0x48(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0xd0(%rsp)
movsd  0x60(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0xb0(%rsp)
lea    0xc0(%rsp),%rdi
lea    0xa0(%rsp),%rsi
mov    %r12,%rdx
call   1060 <crossProd@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <dotProd@plt>
movapd %xmm0,%xmm1
andpd  0xd09(%rip),%xmm1
ucomisd 0xd19(%rip),%xmm1
jbe    11f5 <intersect+0xa5>
lea    0xe0(%rsp),%rdi
mov    %r12,%rbp
lea    0x100(%rsp),%r13
mov    %r13,%rsi
lea    0x120(%rsp),%r12
mov    %r12,%rdx
movapd %xmm0,0x70(%rsp)
call   1030 <diffVt@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1070 <dotProd@plt>
divsd  0x70(%rsp),%xmm0
mov    %r13,%rdi
mov    %rbp,%r12
mov    %r15,%rsi
lea    0x80(%rsp),%rbp
mov    %rbp,%rdx
call   1050 <u_line@plt>
lea    0x20(%rsp),%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
movsd  0xcaa(%rip),%xmm0
call   1040 <isPntInTri@plt>
test   %rax,%rax
je     11f0 <intersect+0xa0>
mov    0x8(%rsp),%rsi
movslq %esi,%rsi
lea    (%rsi,%rsi,2),%rax
mov    0x90(%rsp),%rcx
mov    0x10(%rsp),%rdx
mov    %rcx,0x10(%rdx,%rax,8)
movapd 0x80(%rsp),%xmm0
movupd %xmm0,(%rdx,%rax,8)
add    $0x1,%esi
mov    %rsi,0x8(%rsp)
jmp    11f0 <intersect+0xa0>
mov    0x8(%rsp),%rax
add    $0x158,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.intersect.f_index = [4 x [3 x i32]] [[3 x i32] [i32 0, i32 1, i32 2], [3 x i32] [i32 1, i32 3, i32 2], [3 x i32] [i32 0, i32 2, i32 3], [3 x i32] [i32 0, i32 3, i32 1]]
define i32 @intersect([3 x double]* %0, double* %1, [3 x double]* %2) {
%4 = alloca [3 x double]*
%5 = alloca double*
%6 = alloca [3 x double]*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [3 x double]
%15 = alloca [3 x [3 x double]]
%16 = alloca [3 x double]
%17 = alloca [3 x double]
%18 = alloca [3 x double]
%19 = alloca [3 x double]
%20 = alloca [4 x [3 x i32]]
%21 = alloca double
%22 = alloca [3 x double]
%23 = alloca double
%24 = alloca [3 x double]
store [3 x double]* %0, [3 x double]** %4
store double* %1, double** %5
store [3 x double]* %2, [3 x double]** %6
store i32 0, i32* %7
store double 0x3EB0C6F7A0B5ED8D, double* %8
store double 0x3EB0C6F7A0B5ED8D, double* %9
%25 = bitcast [4 x [3 x i32]]* %20 to i8*
store i32 0, i32* %11
br label %26
26: ; preds = %61, %3
%27 = load i32, i32* %11
%28 = icmp slt i32 %27, 3
br i1 %28, label %29, label %64
29: ; preds = %26
%30 = load [3 x double]*, [3 x double]** %4
%31 = getelementptr inbounds [3 x double], [3 x double]* %30, i64 0
%32 = load i32, i32* %11
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [3 x double], [3 x double]* %31, i64 0, i64 %33
%35 = load double, double* %34
%36 = load [3 x double]*, [3 x double]** %4
%37 = getelementptr inbounds [3 x double], [3 x double]* %36, i64 1
%38 = load i32, i32* %11
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [3 x double], [3 x double]* %37, i64 0, i64 %39
%41 = load double, double* %40
%42 = fadd double %35, %41
%43 = load [3 x double]*, [3 x double]** %4
%44 = getelementptr inbounds [3 x double], [3 x double]* %43, i64 2
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [3 x double], [3 x double]* %44, i64 0, i64 %46
%48 = load double, double* %47
%49 = fadd double %42, %48
%50 = load [3 x double]*, [3 x double]** %4
%51 = getelementptr inbounds [3 x double], [3 x double]* %50, i64 3
%52 = load i32, i32* %11
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [3 x double], [3 x double]* %51, i64 0, i64 %53
%55 = load double, double* %54
%56 = fadd double %49, %55
%57 = fmul double 2.500000e-01, %56
%58 = load i32, i32* %11
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 %59
store double %57, double* %60
br label %61
61: ; preds = %29
%62 = load i32, i32* %11
%63 = add nsw i32 %62, 1
store i32 %63, i32* %11
br label %26
64: ; preds = %26
store i32 0, i32* %10
br label %65
65: ; preds = %236, %64
%66 = load i32, i32* %10
%67 = icmp slt i32 %66, 4
br i1 %67, label %68, label %239
68: ; preds = %65
store i32 0, i32* %12
br label %69
69: ; preds = %101, %68
%70 = load i32, i32* %12
%71 = icmp slt i32 %70, 3
br i1 %71, label %72, label %104
72: ; preds = %69
store i32 0, i32* %13
br label %73
73: ; preds = %97, %72
%74 = load i32, i32* %13
%75 = icmp slt i32 %74, 3
br i1 %75, label %76, label %100
76: ; preds = %73
%77 = load [3 x double]*, [3 x double]** %4
%78 = load i32, i32* %10
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %20, i64 0, i64 %79
%81 = load i32, i32* %12
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [3 x i32], [3 x i32]* %80, i64 0, i64 %82
%84 = load i32, i32* %83
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [3 x double], [3 x double]* %77, i64 %85
%87 = load i32, i32* %13
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [3 x double], [3 x double]* %86, i64 0, i64 %88
%90 = load double, double* %89
%91 = load i32, i32* %12
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i64 0, i64 %92
%94 = load i32, i32* %13
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [3 x double], [3 x double]* %93, i64 0, i64 %95
store double %90, double* %96
br label %97
97: ; preds = %76
%98 = load i32, i32* %13
%99 = add nsw i32 %98, 1
store i32 %99, i32* %13
br label %73
100: ; preds = %73
br label %101
101: ; preds = %100
%102 = load i32, i32* %12
%103 = add nsw i32 %102, 1
store i32 %103, i32* %12
br label %69
104: ; preds = %69
%105 = load i32, i32* %10
%106 = icmp ne i32 %105, 2
br i1 %106, label %107, label %124
107: ; preds = %104
store i32 0, i32* %11
br label %108
108: ; preds = %120, %107
%109 = load i32, i32* %11
%110 = icmp slt i32 %109, 3
br i1 %110, label %111, label %123
111: ; preds = %108
%112 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i64 0, i64 0
%113 = load i32, i32* %11
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [3 x double], [3 x double]* %112, i64 0, i64 %114
%116 = load double, double* %115
%117 = load i32, i32* %11
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [3 x double], [3 x double]* %16, i64 0, i64 %118
store double %116, double* %119
br label %120
120: ; preds = %111
%121 = load i32, i32* %11
%122 = add nsw i32 %121, 1
store i32 %122, i32* %11
br label %108
123: ; preds = %108
br label %141
124: ; preds = %104
store i32 0, i32* %11
br label %125
125: ; preds = %137, %124
%126 = load i32, i32* %11
%127 = icmp slt i32 %126, 3
br i1 %127, label %128, label %140
128: ; preds = %125
%129 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i64 0, i64 1
%130 = load i32, i32* %11
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds [3 x double], [3 x double]* %129, i64 0, i64 %131
%133 = load double, double* %132
%134 = load i32, i32* %11
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [3 x double], [3 x double]* %16, i64 0, i64 %135
store double %133, double* %136
br label %137
137: ; preds = %128
%138 = load i32, i32* %11
%139 = add nsw i32 %138, 1
store i32 %139, i32* %11
br label %125
140: ; preds = %125
br label %141
141: ; preds = %140, %123
store i32 0, i32* %11
br label %142
142: ; preds = %174, %141
%143 = load i32, i32* %11
%144 = icmp slt i32 %143, 3
br i1 %144, label %145, label %177
145: ; preds = %142
%146 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i64 0, i64 1
%147 = load i32, i32* %11
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds [3 x double], [3 x double]* %146, i64 0, i64 %148
%150 = load double, double* %149
%151 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i64 0, i64 0
%152 = load i32, i32* %11
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds [3 x double], [3 x double]* %151, i64 0, i64 %153
%155 = load double, double* %154
%156 = fsub double %150, %155
%157 = load i32, i32* %11
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 %158
store double %156, double* %159
%160 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i64 0, i64 2
%161 = load i32, i32* %11
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds [3 x double], [3 x double]* %160, i64 0, i64 %162
%164 = load double, double* %163
%165 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i64 0, i64 0
%166 = load i32, i32* %11
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds [3 x double], [3 x double]* %165, i64 0, i64 %167
%169 = load double, double* %168
%170 = fsub double %164, %169
%171 = load i32, i32* %11
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 %172
store double %170, double* %173
br label %174
174: ; preds = %145
%175 = load i32, i32* %11
%176 = add nsw i32 %175, 1
store i32 %176, i32* %11
br label %142
177: ; preds = %142
%178 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 0
%179 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%180 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 0
%181 = call i32 @crossProd(double* %178, double* %179, double* %180)
%182 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 0
%183 = load double*, double** %5
%184 = call double @dotProd(double* %182, double* %183)
store double %184, double* %21
%185 = load double, double* %21
%186 = call double @llvm.fabs.f64(double %185)
%187 = load double, double* %9
%188 = fcmp ogt double %186, %187
br i1 %188, label %189, label %234
189: ; preds = %177
%190 = getelementptr inbounds [3 x double], [3 x double]* %16, i64 0, i64 0
%191 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
%192 = getelementptr inbounds [3 x double], [3 x double]* %22, i64 0, i64 0
%193 = call i32 @diffVt(double* %190, double* %191, double* %192)
%194 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 0
%195 = getelementptr inbounds [3 x double], [3 x double]* %22, i64 0, i64 0
%196 = call double @dotProd(double* %194, double* %195)
%197 = load double, double* %21
%198 = fdiv double %196, %197
store double %198, double* %23
%199 = load double, double* %23
%200 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
%201 = load double*, double** %5
%202 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 0
%203 = call i32 @u_line(double %199, double* %200, double* %201, double* %202)
%204 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i64 0, i64 0
%205 = bitcast [3 x double]* %204 to double**
%206 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 0
%207 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 0
%208 = load double, double* %8
%209 = call i64 @isPntInTri(double** %205, double* %206, double* %207, double %208)
%210 = icmp ne i64 %209, 0
br i1 %210, label %211, label %233
211: ; preds = %189
store i32 0, i32* %11
br label %212
212: ; preds = %227, %211
%213 = load i32, i32* %11
%214 = icmp slt i32 %213, 3
br i1 %214, label %215, label %230
215: ; preds = %212
%216 = load i32, i32* %11
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 %217
%219 = load double, double* %218
%220 = load [3 x double]*, [3 x double]** %6
%221 = load i32, i32* %7
%222 = sext i32 %221 to i64
%223 = getelementptr inbounds [3 x double], [3 x double]* %220, i64 %222
%224 = load i32, i32* %11
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds [3 x double], [3 x double]* %223, i64 0, i64 %225
store double %219, double* %226
br label %227
227: ; preds = %215
%228 = load i32, i32* %11
%229 = add nsw i32 %228, 1
store i32 %229, i32* %11
br label %212
230: ; preds = %212
%231 = load i32, i32* %7
%232 = add nsw i32 %231, 1
store i32 %232, i32* %7
br label %233
233: ; preds = %230, %189
br label %235
234: ; preds = %177
br label %235
235: ; preds = %234, %233
br label %236
236: ; preds = %235
%237 = load i32, i32* %10
%238 = add nsw i32 %237, 1
store i32 %238, i32* %10
br label %65
239: ; preds = %65
%240 = load i32, i32* %7
ret i32 %240
}

LLVM IR (-O2):
@__const.intersect.f_index = [4 x [3 x i32]] [[3 x i32] [i32 0, i32 1, i32 2], [3 x i32] [i32 1, i32 3, i32 2], [3 x i32] [i32 0, i32 2, i32 3], [3 x i32] [i32 0, i32 3, i32 1]]
define i32 @intersect([3 x double]* nocapture %0, double* %1, [3 x double]* nocapture writeonly %2) {
%4 = alloca [3 x double]
%5 = alloca [3 x [3 x double]]
%6 = bitcast [3 x [3 x double]]* %5 to i8*
%7 = alloca [3 x double]
%8 = bitcast [3 x double]* %7 to i8*
%9 = alloca [3 x double]
%10 = alloca [3 x double]
%11 = alloca [3 x double]
%12 = alloca [3 x double]
%13 = alloca [3 x double]
%14 = bitcast [3 x double]* %13 to i8*
%15 = bitcast [3 x double]* %4 to i8*
%16 = bitcast [3 x double]* %9 to i8*
%17 = bitcast [3 x double]* %10 to i8*
%18 = bitcast [3 x double]* %11 to i8*
%19 = bitcast [3 x double]* %12 to i8*
%20 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
%21 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
%22 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 3, i64 0
%23 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%24 = bitcast [3 x double]* %0 to <2 x double>*
%25 = load <2 x double>, <2 x double>* %24
%26 = bitcast double* %20 to <2 x double>*
%27 = load <2 x double>, <2 x double>* %26
%28 = fadd <2 x double> %25, %27
%29 = bitcast double* %21 to <2 x double>*
%30 = load <2 x double>, <2 x double>* %29
%31 = fadd <2 x double> %28, %30
%32 = bitcast double* %22 to <2 x double>*
%33 = load <2 x double>, <2 x double>* %32
%34 = fadd <2 x double> %31, %33
%35 = fmul <2 x double> %34, <double 2.500000e-01, double 2.500000e-01>
%36 = bitcast [3 x double]* %4 to <2 x double>*
store <2 x double> %35, <2 x double>* %36
%37 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
%38 = load double, double* %37
%39 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
%40 = load double, double* %39
%41 = fadd double %38, %40
%42 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
%43 = load double, double* %42
%44 = fadd double %41, %43
%45 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 3, i64 2
%46 = load double, double* %45
%47 = fadd double %44, %46
%48 = fmul double %47, 2.500000e-01
%49 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
store double %48, double* %49
%50 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%51 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%52 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%53 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%54 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%55 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%56 = bitcast [3 x [3 x double]]* %5 to double**
%57 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %5, i64 0, i64 1, i64 0
%58 = bitcast double* %57 to i8*
%59 = bitcast [3 x [3 x double]]* %5 to i8*
%60 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %5, i64 0, i64 2, i64 0
%61 = bitcast double* %60 to i8*
%62 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %5, i64 0, i64 1, i64 2
%63 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %5, i64 0, i64 0, i64 2
%64 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 2
%65 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %5, i64 0, i64 2, i64 2
%66 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
%67 = bitcast [3 x [3 x double]]* %5 to <2 x double>*
%68 = bitcast double* %57 to <2 x double>*
%69 = bitcast [3 x double]* %9 to <2 x double>*
%70 = bitcast double* %60 to <2 x double>*
%71 = bitcast [3 x double]* %10 to <2 x double>*
br label %72
72: ; preds = %3, %118
%73 = phi i64 [ 0, %3 ], [ %120, %118 ]
%74 = phi i32 [ 0, %3 ], [ %119, %118 ]
%75 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* @__const.intersect.f_index, i64 0, i64 %73, i64 0
%76 = load i32, i32* %75
%77 = sext i32 %76 to i64
%78 = getelementptr [3 x double], [3 x double]* %0, i64 %77, i64 0
%79 = bitcast double* %78 to i8*
%80 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* @__const.intersect.f_index, i64 0, i64 %73, i64 1
%81 = load i32, i32* %80
%82 = sext i32 %81 to i64
%83 = getelementptr [3 x double], [3 x double]* %0, i64 %82, i64 0
%84 = bitcast double* %83 to i8*
%85 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* @__const.intersect.f_index, i64 0, i64 %73, i64 2
%86 = load i32, i32* %85
%87 = sext i32 %86 to i64
%88 = getelementptr [3 x double], [3 x double]* %0, i64 %87, i64 0
%89 = bitcast double* %88 to i8*
%90 = icmp eq i64 %73, 2
%91 = select i1 %90, i8* %84, i8* %79
%92 = load <2 x double>, <2 x double>* %67
%93 = load <2 x double>, <2 x double>* %68
%94 = fsub <2 x double> %93, %92
store <2 x double> %94, <2 x double>* %69
%95 = load <2 x double>, <2 x double>* %70
%96 = fsub <2 x double> %95, %92
store <2 x double> %96, <2 x double>* %71
%97 = load double, double* %62
%98 = load double, double* %63
%99 = fsub double %97, %98
store double %99, double* %64
%100 = load double, double* %65
%101 = fsub double %100, %98
store double %101, double* %66
%102 = call i32 @crossProd(double* %50, double* %51, double* %52)
%103 = call double @dotProd(double* %52, double* %1)
%104 = call double @llvm.fabs.f64(double %103)
%105 = fcmp ogt double %104, 0x3EB0C6F7A0B5ED8D
br i1 %105, label %106, label %118
106: ; preds = %72
%107 = call i32 @diffVt(double* %53, double* %23, double* %54)
%108 = call double @dotProd(double* %52, double* %54)
%109 = fdiv double %108, %103
%110 = call i32 @u_line(double %109, double* %23, double* %1, double* %55)
%111 = call i64 @isPntInTri(double** %56, double* %52, double* %55, double 0x3EB0C6F7A0B5ED8D)
%112 = icmp eq i64 %111, 0
br i1 %112, label %118, label %113
113: ; preds = %106
%114 = sext i32 %74 to i64
%115 = getelementptr [3 x double], [3 x double]* %2, i64 %114, i64 0
%116 = bitcast double* %115 to i8*
%117 = add nsw i32 %74, 1
br label %118
118: ; preds = %113, %106, %72
%119 = phi i32 [ %117, %113 ], [ %74, %106 ], [ %74, %72 ]
%120 = add nuw nsw i64 %73, 1
%121 = icmp eq i64 %120, 4
br i1 %121, label %122, label %72
122: ; preds = %118
ret i32 %119
}