#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 cart_3d(double *, double *);
int /*<<< orphan*/ isfinite(double);
int /*<<< orphan*/ ls_closest_approach(double *, double *, double *, double *,
                                       double *, double *);
int /*<<< orphan*/ printf(char *);
double ls_ls_dist(double a0[3], double b0[3], double c0[3], double d0[3]) {
  double foo[3], bar[3];
  double dist;
  ls_closest_approach(foo, bar, a0, b0, c0, d0);
  dist = cart_3d(foo, bar);
  if (!isfinite(dist))
    printf("dist is nan\n");
  if (!dist)
    printf("dist is 0\n");
  return dist;
}


x86 assembly (clang, -O0):
<ls_ls_dist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
call   1060 <ls_closest_approach@plt>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1050 <cart_3d@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1040 <isfinite@plt>
cmp    $0x0,%eax
jne    11a6 <ls_ls_dist+0x66>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x68(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ca <ls_ls_dist+0x8a>
jp     11ca <ls_ls_dist+0x8a>
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x68(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ls_ls_dist>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rcx,%r9
mov    %rdx,%r8
mov    %rsi,%rcx
mov    %rdi,%rdx
lea    0x30(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <ls_closest_approach@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <cart_3d@plt>
movsd  %xmm0,0x8(%rsp)
call   1040 <isfinite@plt>
test   %eax,%eax
jne    118e <ls_ls_dist+0x4e>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jne    11b6 <ls_ls_dist+0x76>
jp     11b6 <ls_ls_dist+0x76>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"dist is nan\0A\00"
@.str.1 = [11 x i8] c"dist is 0\0A\00"
define double @ls_ls_dist(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca [3 x double]
%10 = alloca [3 x double]
%11 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%12 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%13 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%14 = load double*, double** %5
%15 = load double*, double** %6
%16 = load double*, double** %7
%17 = load double*, double** %8
%18 = call i32 @ls_closest_approach(double* %12, double* %13, double* %14, double* %15, double* %16, double* %17)
%19 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%20 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%21 = call double @cart_3d(double* %19, double* %20)
store double %21, double* %11
%22 = load double, double* %11
%23 = call i32 @isfinite(double %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %4
%26 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %4
%28 = load double, double* %11
%29 = fcmp une double %28, 0.000000e+00
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = load double, double* %11
ret double %33
}

LLVM IR (-O2):
@str = [12 x i8] c"dist is nan\00"
@str.2 = [10 x i8] c"dist is 0\00"
define double @ls_ls_dist(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = bitcast [3 x double]* %5 to i8*
%8 = bitcast [3 x double]* %6 to i8*
%9 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%10 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%11 = call i32 @ls_closest_approach(double* %9, double* %10, double* %0, double* %1, double* %2, double* %3)
%12 = call double @cart_3d(double* %9, double* %10)
%13 = call i32 @isfinite(double %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %4
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %15, %4
%18 = fcmp une double %12, 0.000000e+00
br i1 %18, label %21, label %19
19: ; preds = %17
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
ret double %12
}