; LLVM IR from HRI-EU/Rcs :: src/RcsCore (Rcs_geometry)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare void @Vec3d_sub(ptr noundef, ptr noundef, ptr noundef) #1

declare double @Vec3d_innerProduct(ptr noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nounwind uwtable
define dso_local double @Math_sqrDistLineLine(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #3 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca [2 x [2 x double]], align 16
  %12 = alloca [2 x [2 x double]], align 16
  %13 = alloca [2 x double], align 16
  %14 = alloca [3 x double], align 16
  %15 = alloca double, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = call double @Vec3d_innerProduct(ptr noundef %16, ptr noundef %17)
  %19 = getelementptr inbounds [2 x [2 x double]], ptr %11, i64 0, i64 0
  %20 = getelementptr inbounds [2 x double], ptr %19, i64 0, i64 0
  store double %18, ptr %20, align 16, !tbaa !9
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = call double @Vec3d_innerProduct(ptr noundef %21, ptr noundef %22)
  %24 = fneg double %23
  %25 = getelementptr inbounds [2 x [2 x double]], ptr %11, i64 0, i64 0
  %26 = getelementptr inbounds [2 x double], ptr %25, i64 0, i64 1
  store double %24, ptr %26, align 8, !tbaa !9
  %27 = getelementptr inbounds [2 x [2 x double]], ptr %11, i64 0, i64 0
  %28 = getelementptr inbounds [2 x double], ptr %27, i64 0, i64 1
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds [2 x [2 x double]], ptr %11, i64 0, i64 1
  %31 = getelementptr inbounds [2 x double], ptr %30, i64 0, i64 0
  store double %29, ptr %31, align 16, !tbaa !9
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = call double @Vec3d_innerProduct(ptr noundef %32, ptr noundef %33)
  %35 = getelementptr inbounds [2 x [2 x double]], ptr %11, i64 0, i64 1
  %36 = getelementptr inbounds [2 x double], ptr %35, i64 0, i64 1
  store double %34, ptr %36, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #4
  %37 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 0
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  call void @Vec3d_sub(ptr noundef %37, ptr noundef %38, ptr noundef %39)
  %40 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 0
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = call double @Vec3d_innerProduct(ptr noundef %40, ptr noundef %41)
  %43 = fneg double %42
  %44 = getelementptr inbounds [2 x double], ptr %13, i64 0, i64 0
  store double %43, ptr %44, align 16, !tbaa !9
  %45 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 0
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = call double @Vec3d_innerProduct(ptr noundef %45, ptr noundef %46)
  %48 = getelementptr inbounds [2 x double], ptr %13, i64 0, i64 1
  store double %47, ptr %48, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %49 = getelementptr inbounds [2 x [2 x double]], ptr %12, i64 0, i64 0
  %50 = getelementptr inbounds [2 x [2 x double]], ptr %11, i64 0, i64 0
  %51 = call double @Math_inverse2D(ptr noundef %49, ptr noundef %50)
  store double %51, ptr %15, align 8, !tbaa !9
  %52 = load double, ptr %15, align 8, !tbaa !9
  %53 = fcmp une double %52, 0.000000e+00
  br i1 %53, label %54, label %83

54:                                               ; preds = %5
  %55 = getelementptr inbounds [2 x [2 x double]], ptr %12, i64 0, i64 0
  %56 = getelementptr inbounds [2 x double], ptr %55, i64 0, i64 0
  %57 = load double, ptr %56, align 16, !tbaa !9
  %58 = getelementptr inbounds [2 x double], ptr %13, i64 0, i64 0
  %59 = load double, ptr %58, align 16, !tbaa !9
  %60 = getelementptr inbounds [2 x [2 x double]], ptr %12, i64 0, i64 0
  %61 = getelementptr inbounds [2 x double], ptr %60, i64 0, i64 1
  %62 = load double, ptr %61, align 8, !tbaa !9
  %63 = getelementptr inbounds [2 x double], ptr %13, i64 0, i64 1
  %64 = load double, ptr %63, align 8, !tbaa !9
  %65 = fmul double %62, %64
  %66 = call double @llvm.fmuladd.f64(double %57, double %59, double %65)
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = getelementptr inbounds double, ptr %67, i64 0
  store double %66, ptr %68, align 8, !tbaa !9
  %69 = getelementptr inbounds [2 x [2 x double]], ptr %12, i64 0, i64 1
  %70 = getelementptr inbounds [2 x double], ptr %69, i64 0, i64 0
  %71 = load double, ptr %70, align 16, !tbaa !9
  %72 = getelementptr inbounds [2 x double], ptr %13, i64 0, i64 0
  %73 = load double, ptr %72, align 16, !tbaa !9
  %74 = getelementptr inbounds [2 x [2 x double]], ptr %12, i64 0, i64 1
  %75 = getelementptr inbounds [2 x double], ptr %74, i64 0, i64 1
  %76 = load double, ptr %75, align 8, !tbaa !9
  %77 = getelementptr inbounds [2 x double], ptr %13, i64 0, i64 1
  %78 = load double, ptr %77, align 8, !tbaa !9
  %79 = fmul double %76, %78
  %80 = call double @llvm.fmuladd.f64(double %71, double %73, double %79)
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = getelementptr inbounds double, ptr %81, i64 1
  store double %80, ptr %82, align 8, !tbaa !9
  br label %88

83:                                               ; preds = %5
  %84 = load ptr, ptr %10, align 8, !tbaa !5
  %85 = getelementptr inbounds double, ptr %84, i64 0
  store double 0.000000e+00, ptr %85, align 8, !tbaa !9
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = getelementptr inbounds double, ptr %86, i64 1
  store double 0.000000e+00, ptr %87, align 8, !tbaa !9
  br label %88

88:                                               ; preds = %83, %54
  %89 = load double, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #4
  ret double %89
}

; Function Attrs: nounwind uwtable
declare hidden double @Math_inverse2D(ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare void @Vec3d_sub(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare double @Vec3d_innerProduct(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local double @Math_sqrDistLineLine(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #2 {
  %6 = alloca [2 x [2 x double]], align 16
  %7 = alloca [2 x [2 x double]], align 16
  %8 = alloca [3 x double], align 16
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #4
  %9 = tail call double @Vec3d_innerProduct(ptr noundef %1, ptr noundef %1) #4
  store double %9, ptr %6, align 16, !tbaa !5
  %10 = tail call double @Vec3d_innerProduct(ptr noundef %3, ptr noundef %1) #4
  %11 = fneg double %10
  %12 = getelementptr inbounds i8, ptr %6, i64 8
  store double %11, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %6, i64 16
  store double %11, ptr %13, align 16, !tbaa !5
  %14 = tail call double @Vec3d_innerProduct(ptr noundef %3, ptr noundef %3) #4
  %15 = getelementptr inbounds i8, ptr %6, i64 24
  store double %14, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #4
  call void @Vec3d_sub(ptr noundef nonnull %8, ptr noundef %0, ptr noundef %2) #4
  %16 = call double @Vec3d_innerProduct(ptr noundef nonnull %8, ptr noundef %1) #4
  %17 = call double @Vec3d_innerProduct(ptr noundef nonnull %8, ptr noundef %3) #4
  %18 = call double @Math_inverse2D(ptr noundef nonnull %7, ptr noundef nonnull %6)
  %19 = fcmp une double %18, 0.000000e+00
  br i1 %19, label %20, label %37

20:                                               ; preds = %5
  %21 = fneg double %16
  %22 = load <2 x double>, ptr %7, align 16
  %23 = getelementptr inbounds i8, ptr %7, i64 8
  %24 = load <2 x double>, ptr %23, align 8
  %25 = getelementptr inbounds i8, ptr %7, i64 16
  %26 = load double, ptr %25, align 16, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %7, i64 24
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = insertelement <2 x double> poison, double %17, i64 0
  %30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> zeroinitializer
  %31 = insertelement <2 x double> %24, double %28, i64 1
  %32 = fmul <2 x double> %30, %31
  %33 = insertelement <2 x double> %22, double %26, i64 1
  %34 = insertelement <2 x double> poison, double %21, i64 0
  %35 = shufflevector <2 x double> %34, <2 x double> poison, <2 x i32> zeroinitializer
  %36 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> %35, <2 x double> %32)
  br label %37

37:                                               ; preds = %5, %20
  %38 = phi <2 x double> [ %36, %20 ], [ zeroinitializer, %5 ]
  store <2 x double> %38, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #4
  ret double %18
}

; Function Attrs: nounwind uwtable
declare hidden double @Math_inverse2D(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass