; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes (R3MeshSearchTree)

; 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"

%class.R3Point = type { [3 x double] }
%struct.R3MeshIntersection = type { i32, ptr, ptr, ptr, %class.R3Point, double }
%class.R3MeshSearchTree = type { ptr, ptr, i32, i32 }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [98 x i8], align 1
@R3null_point = external global %class.R3Point, align 8
@RN_SMALL_EPSILON = external global double, align 8
@.str.9 = external hidden unnamed_addr constant [157 x i8], align 1

declare void @_Z7RNAbortPKcz(ptr noundef, ...) #0

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(56) ptr @_ZNK16R3MeshSearchTree4BBoxEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK16R3MeshSearchTree11FindClosestERK7R3PointRK8R3VectorR18R3MeshIntersectiondRdPFiS2_S5_P6R3MeshP10R3MeshFacePvESD_P20R3MeshSearchTreeNodeRK5R3Box(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(64), double noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, ptr noundef, ptr noundef, ptr noundef nonnull align 8 dereferenceable(56)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16R3MeshSearchTree11FindClosestERK7R3PointRK8R3VectorR18R3MeshIntersectionddPFiS2_S5_P6R3MeshP10R3MeshFacePvESC_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(64) %3, double noundef %4, double noundef %5, ptr noundef %6, ptr noundef %7) #3 align 2 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca %class.R3Point, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store double %4, ptr %13, align 8, !tbaa !9
  store double %5, ptr %14, align 8, !tbaa !9
  store ptr %6, ptr %15, align 8, !tbaa !5
  store ptr %7, ptr %16, align 8, !tbaa !5
  %20 = load ptr, ptr %9, align 8
  %21 = load ptr, ptr %12, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.R3MeshIntersection, ptr %21, i32 0, i32 0
  store i32 0, ptr %22, align 8, !tbaa !11
  %23 = load ptr, ptr %12, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.R3MeshIntersection, ptr %23, i32 0, i32 1
  store ptr null, ptr %24, align 8, !tbaa !15
  %25 = load ptr, ptr %12, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.R3MeshIntersection, ptr %25, i32 0, i32 2
  store ptr null, ptr %26, align 8, !tbaa !16
  %27 = load ptr, ptr %12, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.R3MeshIntersection, ptr %27, i32 0, i32 3
  store ptr null, ptr %28, align 8, !tbaa !17
  %29 = load ptr, ptr %12, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.R3MeshIntersection, ptr %29, i32 0, i32 4
  %31 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %30, ptr noundef nonnull align 8 dereferenceable(24) @R3null_point)
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.R3MeshIntersection, ptr %32, i32 0, i32 5
  store double 0.000000e+00, ptr %33, align 8, !tbaa !18
  %34 = getelementptr inbounds %class.R3MeshSearchTree, ptr %20, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !19
  %36 = icmp ne ptr %35, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %8
  br label %137

38:                                               ; preds = %8
  %39 = getelementptr inbounds %class.R3MeshSearchTree, ptr %20, i32 0, i32 3
  %40 = load i32, ptr %39, align 4, !tbaa !22
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %39, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %42 = load double, ptr %13, align 8, !tbaa !9
  %43 = load double, ptr %13, align 8, !tbaa !9
  %44 = fmul double %42, %43
  store double %44, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %45 = load double, ptr %14, align 8, !tbaa !9
  %46 = load double, ptr %14, align 8, !tbaa !9
  %47 = fmul double %45, %46
  store double %47, ptr %18, align 8, !tbaa !9
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = load ptr, ptr %12, align 8, !tbaa !5
  %51 = load double, ptr %17, align 8, !tbaa !9
  %52 = load ptr, ptr %15, align 8, !tbaa !5
  %53 = load ptr, ptr %16, align 8, !tbaa !5
  %54 = getelementptr inbounds %class.R3MeshSearchTree, ptr %20, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !19
  %56 = call noundef nonnull align 8 dereferenceable(56) ptr @_ZNK16R3MeshSearchTree4BBoxEv(ptr noundef nonnull align 8 dereferenceable(24) %20)
  call void @_ZNK16R3MeshSearchTree11FindClosestERK7R3PointRK8R3VectorR18R3MeshIntersectiondRdPFiS2_S5_P6R3MeshP10R3MeshFacePvESD_P20R3MeshSearchTreeNodeRK5R3Box(ptr noundef nonnull align 8 dereferenceable(24) %20, ptr noundef nonnull align 8 dereferenceable(24) %48, ptr noundef nonnull align 8 dereferenceable(24) %49, ptr noundef nonnull align 8 dereferenceable(64) %50, double noundef %51, ptr noundef nonnull align 8 dereferenceable(8) %18, ptr noundef %52, ptr noundef %53, ptr noundef %55, ptr noundef nonnull align 8 dereferenceable(56) %56)
  %57 = load double, ptr %18, align 8, !tbaa !9
  %58 = call double @sqrt(double noundef %57) #6
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.R3MeshIntersection, ptr %59, i32 0, i32 5
  store double %58, ptr %60, align 8, !tbaa !18
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.R3MeshIntersection, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 8, !tbaa !11
  %64 = icmp eq i32 %63, 1
  br i1 %64, label %65, label %85

65:                                               ; preds = %38
  %66 = getelementptr inbounds %class.R3MeshSearchTree, ptr %20, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !23
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.R3MeshIntersection, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !15
  %71 = call noundef ptr @_ZNK6R3Mesh12FaceOnVertexEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %67, ptr noundef %70)
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.R3MeshIntersection, ptr %72, i32 0, i32 3
  store ptr %71, ptr %73, align 8, !tbaa !17
  %74 = getelementptr inbounds %class.R3MeshSearchTree, ptr %20, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !23
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.R3MeshIntersection, ptr %76, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !15
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.R3MeshIntersection, ptr %79, i32 0, i32 3
  %81 = load ptr, ptr %80, align 8, !tbaa !17
  %82 = call noundef ptr @_ZNK6R3Mesh12EdgeOnVertexEPK12R3MeshVertexPK10R3MeshFacei(ptr noundef nonnull align 8 dereferenceable(272) %75, ptr noundef %78, ptr noundef %81, i32 noundef 0)
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.R3MeshIntersection, ptr %83, i32 0, i32 2
  store ptr %82, ptr %84, align 8, !tbaa !16
  br label %113

85:                                               ; preds = %38
  %86 = load ptr, ptr %12, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.R3MeshIntersection, ptr %86, i32 0, i32 0
  %88 = load i32, ptr %87, align 8, !tbaa !11
  %89 = icmp eq i32 %88, 2
  br i1 %89, label %90, label %101

90:                                               ; preds = %85
  %91 = load ptr, ptr %12, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.R3MeshIntersection, ptr %91, i32 0, i32 1
  store ptr null, ptr %92, align 8, !tbaa !15
  %93 = getelementptr inbounds %class.R3MeshSearchTree, ptr %20, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !23
  %95 = load ptr, ptr %12, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.R3MeshIntersection, ptr %95, i32 0, i32 2
  %97 = load ptr, ptr %96, align 8, !tbaa !16
  %98 = call noundef ptr @_ZNK6R3Mesh10FaceOnEdgeEPK10R3MeshEdge(ptr noundef nonnull align 8 dereferenceable(272) %94, ptr noundef %97)
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.R3MeshIntersection, ptr %99, i32 0, i32 3
  store ptr %98, ptr %100, align 8, !tbaa !17
  br label %112

101:                                              ; preds = %85
  %102 = load ptr, ptr %12, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.R3MeshIntersection, ptr %102, i32 0, i32 0
  %104 = load i32, ptr %103, align 8, !tbaa !11
  %105 = icmp eq i32 %104, 3
  br i1 %105, label %106, label %111

106:                                              ; preds = %101
  %107 = load ptr, ptr %12, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.R3MeshIntersection, ptr %107, i32 0, i32 1
  store ptr null, ptr %108, align 8, !tbaa !15
  %109 = load ptr, ptr %12, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.R3MeshIntersection, ptr %109, i32 0, i32 2
  store ptr null, ptr %110, align 8, !tbaa !16
  br label %111

111:                                              ; preds = %106, %101
  br label %112

112:                                              ; preds = %111, %90
  br label %113

113:                                              ; preds = %112, %65
  %114 = load ptr, ptr %12, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.R3MeshIntersection, ptr %114, i32 0, i32 0
  %116 = load i32, ptr %115, align 8, !tbaa !11
  %117 = icmp eq i32 %116, 0
  call void @llvm.lifetime.start.p0(i64 24, ptr %19) #6
  br i1 %117, label %132, label %118

118:                                              ; preds = %113
  %119 = load ptr, ptr %12, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.R3MeshIntersection, ptr %119, i32 0, i32 4
  %121 = getelementptr inbounds %class.R3MeshSearchTree, ptr %20, i32 0, i32 0
  %122 = load ptr, ptr %121, align 8, !tbaa !23
  %123 = load ptr, ptr %12, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.R3MeshIntersection, ptr %123, i32 0, i32 3
  %125 = load ptr, ptr %124, align 8, !tbaa !17
  %126 = load ptr, ptr %12, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.R3MeshIntersection, ptr %126, i32 0, i32 4
  call void @_ZNK6R3Mesh18ClosestPointOnFaceEPK10R3MeshFaceRK7R3PointP18R3MeshIntersection(ptr dead_on_unwind writable sret(%class.R3Point) align 8 %19, ptr noundef nonnull align 8 dereferenceable(272) %122, ptr noundef %125, ptr noundef nonnull align 8 dereferenceable(24) %127, ptr noundef null)
  %128 = call noundef double @_Z17R3SquaredDistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24) %120, ptr noundef nonnull align 8 dereferenceable(24) %19)
  %129 = load double, ptr @RN_SMALL_EPSILON, align 8, !tbaa !9
  %130 = call noundef i32 @_Z8RNIsZerodd(double noundef %128, double noundef %129)
  %131 = icmp ne i32 %130, 0
  br label %132

132:                                              ; preds = %118, %113
  %133 = phi i1 [ true, %113 ], [ %131, %118 ]
  %134 = xor i1 %133, true
  call void @llvm.lifetime.end.p0(i64 24, ptr %19) #6
  br i1 %134, label %135, label %136

135:                                              ; preds = %132
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.9, i32 noundef 611, ptr noundef @.str.2)
  br label %136

136:                                              ; preds = %135, %132
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  br label %137

137:                                              ; preds = %136, %37
  ret void
}

; Function Attrs: nounwind
declare double @sqrt(double noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK6R3Mesh12FaceOnVertexEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef) #2 align 2

declare noundef ptr @_ZNK6R3Mesh12EdgeOnVertexEPK12R3MeshVertexPK10R3MeshFacei(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6R3Mesh10FaceOnEdgeEPK10R3MeshEdge(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z8RNIsZerodd(double noundef, double noundef) #2

declare noundef double @_Z17R3SquaredDistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #0

declare void @_ZNK6R3Mesh18ClosestPointOnFaceEPK10R3MeshFaceRK7R3PointP18R3MeshIntersection(ptr dead_on_unwind writable sret(%class.R3Point) align 8, ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #0

attributes #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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 = { mustprogress 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 "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 #5 = { inlinehint mustprogress 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 #6 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS18R3MeshIntersection", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !14, i64 32, !10, i64 56}
!13 = !{!"_ZTS10R3MeshType", !7, i64 0}
!14 = !{!"_ZTS7R3Point", !7, i64 0}
!15 = !{!12, !6, i64 8}
!16 = !{!12, !6, i64 16}
!17 = !{!12, !6, i64 24}
!18 = !{!12, !10, i64 56}
!19 = !{!20, !6, i64 8}
!20 = !{!"_ZTS16R3MeshSearchTree", !6, i64 0, !6, i64 8, !21, i64 16, !21, i64 20}
!21 = !{!"int", !7, i64 0}
!22 = !{!20, !21, i64 20}
!23 = !{!20, !6, 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"

%class.R3Point = type { [3 x double] }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [98 x i8], align 1
@R3null_point = external global %class.R3Point, align 8
@RN_SMALL_EPSILON = external local_unnamed_addr global double, align 8
@.str.9 = external hidden unnamed_addr constant [157 x i8], align 1

declare void @_Z7RNAbortPKcz(ptr noundef, ...) local_unnamed_addr #0

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(56) ptr @_ZNK16R3MeshSearchTree4BBoxEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK16R3MeshSearchTree11FindClosestERK7R3PointRK8R3VectorR18R3MeshIntersectiondRdPFiS2_S5_P6R3MeshP10R3MeshFacePvESD_P20R3MeshSearchTreeNodeRK5R3Box(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(64), double noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, ptr noundef, ptr noundef, ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16R3MeshSearchTree11FindClosestERK7R3PointRK8R3VectorR18R3MeshIntersectionddPFiS2_S5_P6R3MeshP10R3MeshFacePvESC_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(64) %3, double noundef %4, double noundef %5, ptr noundef %6, ptr noundef %7) local_unnamed_addr #3 align 2 {
  %9 = alloca double, align 8
  %10 = alloca %class.R3Point, align 8
  store i32 0, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %3, i64 8
  %12 = getelementptr inbounds i8, ptr %3, i64 16
  %13 = getelementptr inbounds i8, ptr %3, i64 24
  %14 = getelementptr inbounds i8, ptr %3, i64 32
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %11, i8 0, i64 24, i1 false)
  %15 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull align 8 dereferenceable(24) @R3null_point)
  %16 = getelementptr inbounds i8, ptr %3, i64 56
  store double 0.000000e+00, ptr %16, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %.not = icmp eq ptr %18, null
  br i1 %.not, label %52, label %19

19:                                               ; preds = %8
  %20 = getelementptr inbounds i8, ptr %0, i64 20
  %21 = load i32, ptr %20, align 4, !tbaa !17
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %20, align 4, !tbaa !17
  %23 = fmul double %4, %4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #7
  %24 = fmul double %5, %5
  store double %24, ptr %9, align 8, !tbaa !18
  %25 = tail call noundef nonnull align 8 dereferenceable(56) ptr @_ZNK16R3MeshSearchTree4BBoxEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  call void @_ZNK16R3MeshSearchTree11FindClosestERK7R3PointRK8R3VectorR18R3MeshIntersectiondRdPFiS2_S5_P6R3MeshP10R3MeshFacePvESD_P20R3MeshSearchTreeNodeRK5R3Box(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(64) %3, double noundef %23, ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef %6, ptr noundef %7, ptr noundef nonnull %18, ptr noundef nonnull align 8 dereferenceable(56) %25)
  %26 = load double, ptr %9, align 8, !tbaa !18
  %27 = call double @sqrt(double noundef %26) #7
  store double %27, ptr %16, align 8, !tbaa !13
  %28 = load i32, ptr %3, align 8, !tbaa !5
  switch i32 %28, label %40 [
    i32 1, label %29
    i32 2, label %36
    i32 3, label %.thread
  ]

29:                                               ; preds = %19
  %30 = load ptr, ptr %0, align 8, !tbaa !19
  %31 = load ptr, ptr %11, align 8, !tbaa !20
  %32 = call noundef ptr @_ZNK6R3Mesh12FaceOnVertexEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %30, ptr noundef %31)
  store ptr %32, ptr %13, align 8, !tbaa !21
  %33 = load ptr, ptr %0, align 8, !tbaa !19
  %34 = load ptr, ptr %11, align 8, !tbaa !20
  %35 = call noundef ptr @_ZNK6R3Mesh12EdgeOnVertexEPK12R3MeshVertexPK10R3MeshFacei(ptr noundef nonnull align 8 dereferenceable(272) %33, ptr noundef %34, ptr noundef %32, i32 noundef 0)
  store ptr %35, ptr %12, align 8, !tbaa !22
  br label %thread-pre-split

36:                                               ; preds = %19
  store ptr null, ptr %11, align 8, !tbaa !20
  %37 = load ptr, ptr %0, align 8, !tbaa !19
  %38 = load ptr, ptr %12, align 8, !tbaa !22
  %39 = call noundef ptr @_ZNK6R3Mesh10FaceOnEdgeEPK10R3MeshEdge(ptr noundef nonnull align 8 dereferenceable(272) %37, ptr noundef %38)
  store ptr %39, ptr %13, align 8, !tbaa !21
  br label %thread-pre-split

.thread:                                          ; preds = %19
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %11, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %10) #7
  br label %43

thread-pre-split:                                 ; preds = %29, %36
  %.pr = load i32, ptr %3, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %thread-pre-split, %19
  %41 = phi i32 [ %.pr, %thread-pre-split ], [ %28, %19 ]
  %42 = icmp eq i32 %41, 0
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %10) #7
  br i1 %42, label %.critedge, label %43

43:                                               ; preds = %.thread, %40
  %44 = load ptr, ptr %0, align 8, !tbaa !19
  %45 = load ptr, ptr %13, align 8, !tbaa !21
  call void @_ZNK6R3Mesh18ClosestPointOnFaceEPK10R3MeshFaceRK7R3PointP18R3MeshIntersection(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %10, ptr noundef nonnull align 8 dereferenceable(272) %44, ptr noundef %45, ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef null)
  %46 = call noundef double @_Z17R3SquaredDistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull align 8 dereferenceable(24) %10)
  %47 = load double, ptr @RN_SMALL_EPSILON, align 8, !tbaa !18
  %48 = call noundef i32 @_Z8RNIsZerodd(double noundef %46, double noundef %47)
  %49 = icmp eq i32 %48, 0
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #7
  br i1 %49, label %50, label %51

50:                                               ; preds = %43
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.9, i32 noundef 611, ptr noundef nonnull @.str.2)
  br label %51

.critedge:                                        ; preds = %40
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #7
  br label %51

51:                                               ; preds = %.critedge, %50, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #7
  br label %52

52:                                               ; preds = %8, %51
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK6R3Mesh12FaceOnVertexEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef) local_unnamed_addr #2 align 2

declare noundef ptr @_ZNK6R3Mesh12EdgeOnVertexEPK12R3MeshVertexPK10R3MeshFacei(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6R3Mesh10FaceOnEdgeEPK10R3MeshEdge(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z8RNIsZerodd(double noundef, double noundef) local_unnamed_addr #2

declare noundef double @_Z17R3SquaredDistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0

declare void @_ZNK6R3Mesh18ClosestPointOnFaceEPK10R3MeshFaceRK7R3PointP18R3MeshIntersection(ptr dead_on_unwind writable sret(%class.R3Point) align 8, ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

attributes #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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 = { mustprogress 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 = { mustprogress nofree nounwind willreturn memory(write) "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 #5 = { inlinehint mustprogress 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { 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, !7, i64 0}
!6 = !{!"_ZTS18R3MeshIntersection", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !11, i64 32, !12, i64 56}
!7 = !{!"_ZTS10R3MeshType", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTS7R3Point", !8, i64 0}
!12 = !{!"double", !8, i64 0}
!13 = !{!6, !12, i64 56}
!14 = !{!15, !10, i64 8}
!15 = !{!"_ZTS16R3MeshSearchTree", !10, i64 0, !10, i64 8, !16, i64 16, !16, i64 20}
!16 = !{!"int", !8, i64 0}
!17 = !{!15, !16, i64 20}
!18 = !{!12, !12, i64 0}
!19 = !{!15, !10, i64 0}
!20 = !{!6, !10, i64 8}
!21 = !{!6, !10, i64 24}
!22 = !{!6, !10, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass