#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 dotProduct(double *, double *);
int /*<<< orphan*/ normalize(double *);
int /*<<< orphan*/ sqr(double);
double sqrt(int /*<<< orphan*/);
double *subVector(double *, double *);
double planeIntersection(double *Ro, double *Rd, double *position,
                         double *normal) {
  double t = 0;
  normalize(normal);
  double denom = dotProduct(normal, Rd);
  if (sqrt(sqr(denom)) > 0.00001) {
    t = (-dotProduct(subVector(Ro, position), normal)) / denom;
  }
  return t;
}


x86 assembly (clang, -O0):
<planeIntersection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <normalize@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <dotProduct@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1060 <sqr@plt>
mov    %eax,%edi
call   1070 <sqrt@plt>
movsd  0xe5c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e8 <planeIntersection+0x98>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <subVector@plt>
mov    %rax,%rdi
mov    -0x20(%rbp),%rsi
call   1050 <dotProduct@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<planeIntersection>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rcx,%rdi
call   1040 <normalize@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <dotProduct@plt>
movsd  %xmm0,(%rsp)
call   1060 <sqr@plt>
mov    %eax,%edi
call   1070 <sqrt@plt>
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd 0xe68(%rip),%xmm1
jbe    11bd <planeIntersection+0x6d>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <subVector@plt>
mov    %rax,%rdi
mov    %r12,%rsi
call   1050 <dotProduct@plt>
xorpd  0xe58(%rip),%xmm0
divsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @planeIntersection(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
store double 0.000000e+00, double* %9
%11 = load double*, double** %8
%12 = call i32 @normalize(double* %11)
%13 = load double*, double** %8
%14 = load double*, double** %6
%15 = call double @dotProduct(double* %13, double* %14)
store double %15, double* %10
%16 = load double, double* %10
%17 = call i32 @sqr(double %16)
%18 = call double @sqrt(i32 %17)
%19 = fcmp ogt double %18, 1.000000e-05
br i1 %19, label %20, label %29
20: ; preds = %4
%21 = load double*, double** %5
%22 = load double*, double** %7
%23 = call double* @subVector(double* %21, double* %22)
%24 = load double*, double** %8
%25 = call double @dotProduct(double* %23, double* %24)
%26 = fneg double %25
%27 = load double, double* %10
%28 = fdiv double %26, %27
store double %28, double* %9
br label %29
29: ; preds = %20, %4
%30 = load double, double* %9
ret double %30
}

LLVM IR (-O2):
define double @planeIntersection(double* %0, double* %1, double* %2, double* %3) {
%5 = tail call i32 @normalize(double* %3)
%6 = tail call double @dotProduct(double* %3, double* %1)
%7 = tail call i32 @sqr(double %6)
%8 = tail call double @sqrt(i32 %7)
%9 = fcmp ogt double %8, 1.000000e-05
br i1 %9, label %10, label %15
10: ; preds = %4
%11 = tail call double* @subVector(double* %0, double* %2)
%12 = tail call double @dotProduct(double* %11, double* %3)
%13 = fneg double %12
%14 = fdiv double %13, %6
br label %15
15: ; preds = %10, %4
%16 = phi double [ %14, %10 ], [ 0.000000e+00, %4 ]
ret double %16
}