#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 invert_matrix_3x3(double *, double *);
int /*<<< orphan*/ mult(double *, double *, double *);
int intersect_tri_with_line(const double *plane, const double *l1,
                            const double *l2, double *p, double *t) {
  double M[3 * 3], inv_M[3 * 3];
  double V[3];
  double X[3];
  int is_invert = 0;
  const double *pnt0 = plane;
  const double *pnt1 = plane + 3;
  const double *pnt2 = plane + 6;
  M[0] = l1[0] - l2[0];
  M[1] = pnt1[0] - pnt0[0];
  M[2] = pnt2[0] - pnt0[0];
  M[3] = l1[1] - l2[1];
  M[4] = pnt1[1] - pnt0[1];
  M[5] = pnt2[1] - pnt0[1];
  M[6] = l1[2] - l2[2];
  M[7] = pnt1[2] - pnt0[2];
  M[8] = pnt2[2] - pnt0[2];
  is_invert = invert_matrix_3x3(M, inv_M);
  if (!is_invert)
    return 0;
  V[0] = l1[0] - pnt0[0];
  V[1] = l1[1] - pnt0[1];
  V[2] = l1[2] - pnt0[2];
  mult(inv_M, V, X);
  *t = X[0];
  p[0] = X[1];
  p[1] = X[2];
  return 1;
}


x86 assembly (clang, -O0):
<intersect_tri_with_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x0,-0x114(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x10(%rbp),%rax
add    $0x18,%rax
mov    %rax,-0x128(%rbp)
mov    -0x10(%rbp),%rax
add    $0x30,%rax
mov    %rax,-0x130(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x128(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x120(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x130(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x120(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x128(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x120(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x130(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x120(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x20(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x128(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x120(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x130(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x120(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
lea    -0x80(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
call   1030 <invert_matrix_3x3@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0x0,-0x114(%rbp)
jne    128e <intersect_tri_with_line+0x16e>
movl   $0x0,-0x4(%rbp)
jmp    1335 <intersect_tri_with_line+0x215>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x120(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x120(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x120(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
lea    -0xd0(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
lea    -0x110(%rbp),%rdx
call   1040 <mult@plt>
movsd  -0x110(%rbp),%xmm0
ff
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x108(%rbp),%xmm0
ff
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x100(%rbp),%xmm0
ff
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intersect_tri_with_line>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %r8,%r15
mov    %rcx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
movsd  (%rsi),%xmm0
movhpd 0x18(%rdi),%xmm0
movsd  (%rdx),%xmm1
movsd  (%rdi),%xmm2
unpcklpd %xmm2,%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x40(%rsp)
movsd  0x30(%rdi),%xmm0
movhpd 0x8(%rsi),%xmm0
movhpd 0x8(%rdx),%xmm2
subpd  %xmm2,%xmm0
movapd %xmm0,0x50(%rsp)
movsd  0x8(%rdi),%xmm0
movsd  0x20(%rdi),%xmm1
movhpd 0x38(%rdi),%xmm1
unpcklpd %xmm0,%xmm0
subpd  %xmm0,%xmm1
movapd %xmm1,0x60(%rsp)
movsd  0x10(%rsi),%xmm0
movhpd 0x28(%rdi),%xmm0
movsd  0x10(%rdi),%xmm1
movsd  0x10(%rdx),%xmm2
unpcklpd %xmm1,%xmm2
subpd  %xmm2,%xmm0
movapd %xmm0,0x70(%rsp)
movsd  0x40(%rdi),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x80(%rsp)
lea    0x40(%rsp),%rdi
lea    0x90(%rsp),%rsi
call   1030 <invert_matrix_3x3@plt>
test   %eax,%eax
je     1230 <intersect_tri_with_line+0x110>
movupd (%r12),%xmm0
movupd (%rbx),%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x20(%rsp)
movsd  0x10(%r12),%xmm0
subsd  0x10(%rbx),%xmm0
movsd  %xmm0,0x30(%rsp)
lea    0x90(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <mult@plt>
movsd  (%rsp),%xmm0
movsd  %xmm0,(%r15)
movupd 0x8(%rsp),%xmm0
movupd %xmm0,(%r14)
mov    $0x1,%eax
jmp    1232 <intersect_tri_with_line+0x112>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @intersect_tri_with_line(double* %0, double* %1, double* %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca [9 x double]
%13 = alloca [9 x double]
%14 = alloca [3 x double]
%15 = alloca [3 x double]
%16 = alloca i32
%17 = alloca double*
%18 = alloca double*
%19 = alloca double*
store double* %0, double** %7
store double* %1, double** %8
store double* %2, double** %9
store double* %3, double** %10
store double* %4, double** %11
store i32 0, i32* %16
%20 = load double*, double** %7
store double* %20, double** %17
%21 = load double*, double** %7
%22 = getelementptr inbounds double, double* %21, i64 3
store double* %22, double** %18
%23 = load double*, double** %7
%24 = getelementptr inbounds double, double* %23, i64 6
store double* %24, double** %19
%25 = load double*, double** %8
%26 = getelementptr inbounds double, double* %25, i64 0
%27 = load double, double* %26
%28 = load double*, double** %9
%29 = getelementptr inbounds double, double* %28, i64 0
%30 = load double, double* %29
%31 = fsub double %27, %30
%32 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 0
store double %31, double* %32
%33 = load double*, double** %18
%34 = getelementptr inbounds double, double* %33, i64 0
%35 = load double, double* %34
%36 = load double*, double** %17
%37 = getelementptr inbounds double, double* %36, i64 0
%38 = load double, double* %37
%39 = fsub double %35, %38
%40 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 1
store double %39, double* %40
%41 = load double*, double** %19
%42 = getelementptr inbounds double, double* %41, i64 0
%43 = load double, double* %42
%44 = load double*, double** %17
%45 = getelementptr inbounds double, double* %44, i64 0
%46 = load double, double* %45
%47 = fsub double %43, %46
%48 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 2
store double %47, double* %48
%49 = load double*, double** %8
%50 = getelementptr inbounds double, double* %49, i64 1
%51 = load double, double* %50
%52 = load double*, double** %9
%53 = getelementptr inbounds double, double* %52, i64 1
%54 = load double, double* %53
%55 = fsub double %51, %54
%56 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 3
store double %55, double* %56
%57 = load double*, double** %18
%58 = getelementptr inbounds double, double* %57, i64 1
%59 = load double, double* %58
%60 = load double*, double** %17
%61 = getelementptr inbounds double, double* %60, i64 1
%62 = load double, double* %61
%63 = fsub double %59, %62
%64 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 4
store double %63, double* %64
%65 = load double*, double** %19
%66 = getelementptr inbounds double, double* %65, i64 1
%67 = load double, double* %66
%68 = load double*, double** %17
%69 = getelementptr inbounds double, double* %68, i64 1
%70 = load double, double* %69
%71 = fsub double %67, %70
%72 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 5
store double %71, double* %72
%73 = load double*, double** %8
%74 = getelementptr inbounds double, double* %73, i64 2
%75 = load double, double* %74
%76 = load double*, double** %9
%77 = getelementptr inbounds double, double* %76, i64 2
%78 = load double, double* %77
%79 = fsub double %75, %78
%80 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 6
store double %79, double* %80
%81 = load double*, double** %18
%82 = getelementptr inbounds double, double* %81, i64 2
%83 = load double, double* %82
%84 = load double*, double** %17
%85 = getelementptr inbounds double, double* %84, i64 2
%86 = load double, double* %85
%87 = fsub double %83, %86
%88 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 7
store double %87, double* %88
%89 = load double*, double** %19
%90 = getelementptr inbounds double, double* %89, i64 2
%91 = load double, double* %90
%92 = load double*, double** %17
%93 = getelementptr inbounds double, double* %92, i64 2
%94 = load double, double* %93
%95 = fsub double %91, %94
%96 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 8
store double %95, double* %96
%97 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 0
%98 = getelementptr inbounds [9 x double], [9 x double]* %13, i64 0, i64 0
%99 = call i32 @invert_matrix_3x3(double* %97, double* %98)
store i32 %99, i32* %16
%100 = load i32, i32* %16
%101 = icmp ne i32 %100, 0
br i1 %101, label %103, label %102
102: ; preds = %5
store i32 0, i32* %6
br label %143
103: ; preds = %5
%104 = load double*, double** %8
%105 = getelementptr inbounds double, double* %104, i64 0
%106 = load double, double* %105
%107 = load double*, double** %17
%108 = getelementptr inbounds double, double* %107, i64 0
%109 = load double, double* %108
%110 = fsub double %106, %109
%111 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
store double %110, double* %111
%112 = load double*, double** %8
%113 = getelementptr inbounds double, double* %112, i64 1
%114 = load double, double* %113
%115 = load double*, double** %17
%116 = getelementptr inbounds double, double* %115, i64 1
%117 = load double, double* %116
%118 = fsub double %114, %117
%119 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 1
store double %118, double* %119
%120 = load double*, double** %8
%121 = getelementptr inbounds double, double* %120, i64 2
%122 = load double, double* %121
%123 = load double*, double** %17
%124 = getelementptr inbounds double, double* %123, i64 2
%125 = load double, double* %124
%126 = fsub double %122, %125
%127 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 2
store double %126, double* %127
%128 = getelementptr inbounds [9 x double], [9 x double]* %13, i64 0, i64 0
%129 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
%130 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 0
%131 = call i32 @mult(double* %128, double* %129, double* %130)
%132 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 0
%133 = load double, double* %132
%134 = load double*, double** %11
store double %133, double* %134
%135 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 1
%136 = load double, double* %135
%137 = load double*, double** %10
%138 = getelementptr inbounds double, double* %137, i64 0
store double %136, double* %138
%139 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 2
%140 = load double, double* %139
%141 = load double*, double** %10
%142 = getelementptr inbounds double, double* %141, i64 1
store double %140, double* %142
store i32 1, i32* %6
br label %143
143: ; preds = %103, %102
%144 = load i32, i32* %6
ret i32 %144
}

LLVM IR (-O2):
define i32 @intersect_tri_with_line(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = alloca [9 x double]
%7 = alloca [9 x double]
%8 = alloca [3 x double]
%9 = alloca [3 x double]
%10 = bitcast [9 x double]* %6 to i8*
%11 = bitcast [9 x double]* %7 to i8*
%12 = bitcast [3 x double]* %8 to i8*
%13 = bitcast [3 x double]* %9 to i8*
%14 = getelementptr inbounds double, double* %0, i64 3
%15 = getelementptr inbounds double, double* %0, i64 6
%16 = load double, double* %1
%17 = load double, double* %2
%18 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 0
%19 = load double, double* %14
%20 = load double, double* %0
%21 = insertelement <2 x double> poison, double %16, i64 0
%22 = insertelement <2 x double> %21, double %19, i64 1
%23 = insertelement <2 x double> poison, double %17, i64 0
%24 = insertelement <2 x double> %23, double %20, i64 1
%25 = fsub <2 x double> %22, %24
%26 = bitcast [9 x double]* %6 to <2 x double>*
store <2 x double> %25, <2 x double>* %26
%27 = load double, double* %15
%28 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 2
%29 = getelementptr inbounds double, double* %1, i64 1
%30 = load double, double* %29
%31 = getelementptr inbounds double, double* %2, i64 1
%32 = load double, double* %31
%33 = insertelement <2 x double> poison, double %27, i64 0
%34 = insertelement <2 x double> %33, double %30, i64 1
%35 = insertelement <2 x double> poison, double %20, i64 0
%36 = insertelement <2 x double> %35, double %32, i64 1
%37 = fsub <2 x double> %34, %36
%38 = bitcast double* %28 to <2 x double>*
store <2 x double> %37, <2 x double>* %38
%39 = getelementptr inbounds double, double* %0, i64 4
%40 = load double, double* %39
%41 = getelementptr inbounds double, double* %0, i64 1
%42 = load double, double* %41
%43 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 4
%44 = getelementptr inbounds double, double* %0, i64 7
%45 = load double, double* %44
%46 = insertelement <2 x double> poison, double %40, i64 0
%47 = insertelement <2 x double> %46, double %45, i64 1
%48 = insertelement <2 x double> poison, double %42, i64 0
%49 = shufflevector <2 x double> %48, <2 x double> poison, <2 x i32> zeroinitializer
%50 = fsub <2 x double> %47, %49
%51 = bitcast double* %43 to <2 x double>*
store <2 x double> %50, <2 x double>* %51
%52 = getelementptr inbounds double, double* %1, i64 2
%53 = load double, double* %52
%54 = getelementptr inbounds double, double* %2, i64 2
%55 = load double, double* %54
%56 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 6
%57 = getelementptr inbounds double, double* %0, i64 5
%58 = load double, double* %57
%59 = getelementptr inbounds double, double* %0, i64 2
%60 = load double, double* %59
%61 = insertelement <2 x double> poison, double %53, i64 0
%62 = insertelement <2 x double> %61, double %58, i64 1
%63 = insertelement <2 x double> poison, double %55, i64 0
%64 = insertelement <2 x double> %63, double %60, i64 1
%65 = fsub <2 x double> %62, %64
%66 = bitcast double* %56 to <2 x double>*
store <2 x double> %65, <2 x double>* %66
%67 = getelementptr inbounds double, double* %0, i64 8
%68 = load double, double* %67
%69 = fsub double %68, %60
%70 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 8
store double %69, double* %70
%71 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 0
%72 = call i32 @invert_matrix_3x3(double* %18, double* %71)
%73 = icmp eq i32 %72, 0
br i1 %73, label %93, label %74
74: ; preds = %5
%75 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%76 = bitcast double* %1 to <2 x double>*
%77 = load <2 x double>, <2 x double>* %76
%78 = bitcast double* %0 to <2 x double>*
%79 = load <2 x double>, <2 x double>* %78
%80 = fsub <2 x double> %77, %79
%81 = bitcast [3 x double]* %8 to <2 x double>*
store <2 x double> %80, <2 x double>* %81
%82 = load double, double* %52
%83 = load double, double* %59
%84 = fsub double %82, %83
%85 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 2
store double %84, double* %85
%86 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%87 = call i32 @mult(double* %71, double* %75, double* %86)
%88 = load double, double* %86
store double %88, double* %4
%89 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 1
%90 = bitcast double* %89 to <2 x double>*
%91 = load <2 x double>, <2 x double>* %90
%92 = bitcast double* %3 to <2 x double>*
store <2 x double> %91, <2 x double>* %92
br label %93
93: ; preds = %5, %74
%94 = phi i32 [ 1, %74 ], [ 0, %5 ]
ret i32 %94
}