#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*/ cross(double *, double *, double *);
int /*<<< orphan*/ diff_3d(double *, double *, double *);
double norm_3d(double *);
double p_l_dist(double *, double *, double *);
int /*<<< orphan*/ scale_3d(double *, double *, double);
double l_l_dist(double a0[3], double b0[3], double c0[3], double d0[3]) {
  double b[3], foo[3], c[3], d[3];
  double cdpl;
  diff_3d(b, b0, a0);
  scale_3d(b, b, 1.0 / norm_3d(b));
  diff_3d(foo, c0, a0);
  cross(c, foo, b);
  diff_3d(foo, d0, a0);
  cross(d, foo, b);
  diff_3d(d, d, c);
  cross(foo, c, d);
  cdpl = norm_3d(d);
  if (cdpl)
    return norm_3d(foo) / cdpl;
  return p_l_dist(c0, a0, b0);
}


x86 assembly (clang, -O0):
<l_l_dist>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1070 <diff_3d@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <norm_3d@plt>
mov    -0xb8(%rbp),%rdi
mov    -0xb0(%rbp),%rsi
movaps %xmm0,%xmm1
movsd  0xe4c(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1040 <scale_3d@plt>
lea    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1070 <diff_3d@plt>
lea    -0x80(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1060 <cross@plt>
lea    -0x60(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1070 <diff_3d@plt>
lea    -0xa0(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1060 <cross@plt>
lea    -0xa0(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1070 <diff_3d@plt>
lea    -0x60(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
call   1060 <cross@plt>
lea    -0xa0(%rbp),%rdi
call   1030 <norm_3d@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1263 <l_l_dist+0x113>
jp     1263 <l_l_dist+0x113>
jmp    127e <l_l_dist+0x12e>
lea    -0x60(%rbp),%rdi
call   1030 <norm_3d@plt>
divsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    1294 <l_l_dist+0x144>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <p_l_dist@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<l_l_dist>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rcx,%r13
mov    %rdx,%rbx
mov    %rdi,%r12
lea    0x70(%rsp),%r15
mov    %r15,%rdi
mov    %rsi,(%rsp)
mov    %r12,%rdx
call   1070 <diff_3d@plt>
mov    %r15,%rdi
call   1030 <norm_3d@plt>
movsd  0xe72(%rip),%xmm1
divsd  %xmm0,%xmm1
mov    %r15,%rdi
mov    %r15,%rsi
movapd %xmm1,%xmm0
call   1040 <scale_3d@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,0x8(%rsp)
mov    %rbx,%rsi
mov    %r12,%rdx
call   1070 <diff_3d@plt>
lea    0x50(%rsp),%r14
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1060 <cross@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1070 <diff_3d@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1060 <cross@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <diff_3d@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <cross@plt>
mov    %rbx,%rdi
call   1030 <norm_3d@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    121d <l_l_dist+0xcd>
jnp    1233 <l_l_dist+0xe3>
lea    0x10(%rsp),%rdi
movsd  %xmm0,(%rsp)
call   1030 <norm_3d@plt>
divsd  (%rsp),%xmm0
jmp    1244 <l_l_dist+0xf4>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
mov    (%rsp),%rdx
call   1050 <p_l_dist@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @l_l_dist(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 [3 x double]
%11 = alloca [3 x double]
%12 = alloca [3 x double]
%13 = alloca [3 x double]
%14 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
%15 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%16 = load double*, double** %7
%17 = load double*, double** %6
%18 = call i32 @diff_3d(double* %15, double* %16, double* %17)
%19 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%20 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%21 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%22 = call double @norm_3d(double* %21)
%23 = fdiv double 1.000000e+00, %22
%24 = call i32 @scale_3d(double* %19, double* %20, double %23)
%25 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%26 = load double*, double** %8
%27 = load double*, double** %6
%28 = call i32 @diff_3d(double* %25, double* %26, double* %27)
%29 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%30 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%31 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%32 = call i32 @cross(double* %29, double* %30, double* %31)
%33 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%34 = load double*, double** %9
%35 = load double*, double** %6
%36 = call i32 @diff_3d(double* %33, double* %34, double* %35)
%37 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%38 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%39 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%40 = call i32 @cross(double* %37, double* %38, double* %39)
%41 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%42 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%43 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%44 = call i32 @diff_3d(double* %41, double* %42, double* %43)
%45 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%46 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%47 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%48 = call i32 @cross(double* %45, double* %46, double* %47)
%49 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%50 = call double @norm_3d(double* %49)
store double %50, double* %14
%51 = load double, double* %14
%52 = fcmp une double %51, 0.000000e+00
br i1 %52, label %53, label %58
53: ; preds = %4
%54 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%55 = call double @norm_3d(double* %54)
%56 = load double, double* %14
%57 = fdiv double %55, %56
store double %57, double* %5
br label %63
58: ; preds = %4
%59 = load double*, double** %8
%60 = load double*, double** %6
%61 = load double*, double** %7
%62 = call double @p_l_dist(double* %59, double* %60, double* %61)
store double %62, double* %5
br label %63
63: ; preds = %58, %53
%64 = load double, double* %5
ret double %64
}

LLVM IR (-O2):
define double @l_l_dist(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = bitcast [3 x double]* %5 to i8*
%10 = bitcast [3 x double]* %6 to i8*
%11 = bitcast [3 x double]* %7 to i8*
%12 = bitcast [3 x double]* %8 to i8*
%13 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%14 = call i32 @diff_3d(double* %13, double* %1, double* %0)
%15 = call double @norm_3d(double* %13)
%16 = fdiv double 1.000000e+00, %15
%17 = call i32 @scale_3d(double* %13, double* %13, double %16)
%18 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%19 = call i32 @diff_3d(double* %18, double* %2, double* %0)
%20 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%21 = call i32 @cross(double* %20, double* %18, double* %13)
%22 = call i32 @diff_3d(double* %18, double* %3, double* %0)
%23 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%24 = call i32 @cross(double* %23, double* %18, double* %13)
%25 = call i32 @diff_3d(double* %23, double* %23, double* %20)
%26 = call i32 @cross(double* %18, double* %20, double* %23)
%27 = call double @norm_3d(double* %23)
%28 = fcmp une double %27, 0.000000e+00
br i1 %28, label %29, label %32
29: ; preds = %4
%30 = call double @norm_3d(double* %18)
%31 = fdiv double %30, %27
br label %34
32: ; preds = %4
%33 = call double @p_l_dist(double* %2, double* %0, double* %1)
br label %34
34: ; preds = %32, %29
%35 = phi double [ %31, %29 ], [ %33, %32 ]
ret double %35
}