; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R3Isect.ll (Z12R3IntersectsRK6R3SpanRK10R3TriangleP7R3PointPd)

; 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.R3Vector = type { [3 x double] }
%class.R3Point = type { [3 x double] }
%class.R3Span = type { %class.R3Ray, %class.R3Point, double }
%class.R3Ray = type { %class.R3Line }
%class.R3Line = type { %class.R3Point, %class.R3Vector }
%class.R3Plane = type { %class.R3Vector, double }

@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [28 x i8], align 1

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

declare noundef i32 @_Z10R3ContainsRK10R3TriangleRK7R3Point(ptr noundef nonnull align 8 dereferenceable(132), ptr noundef nonnull align 8 dereferenceable(24)) #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

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

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

declare void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK10R3Triangle5PlaneEv(ptr noundef nonnull align 8 dereferenceable(132)) #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z12R3IntersectsRK6R3SpanRK7R3PlaneP7R3PointPd(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z12R3IntersectsRK6R3SpanRK10R3TriangleP7R3PointPd(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(132) %1, ptr noundef %2, ptr noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %class.R3Point, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  %13 = alloca %class.R3Span, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca %class.R3Plane, align 8
  %18 = alloca %class.R3Vector, align 8
  %19 = alloca i32, align 4
  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
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #5
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK10R3Triangle5PlaneEv(ptr noundef nonnull align 8 dereferenceable(132) %21)
  %23 = call noundef i32 @_Z12R3IntersectsRK6R3SpanRK7R3PlaneP7R3PointPd(ptr noundef nonnull align 8 dereferenceable(80) %20, ptr noundef nonnull align 8 dereferenceable(32) %22, ptr noundef %10, ptr noundef %11)
  switch i32 %23, label %113 [
    i32 0, label %24
    i32 1, label %25
    i32 4, label %43
  ]

24:                                               ; preds = %4
  store i32 0, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %115

25:                                               ; preds = %4
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = call noundef i32 @_Z10R3ContainsRK10R3TriangleRK7R3Point(ptr noundef nonnull align 8 dereferenceable(132) %26, ptr noundef nonnull align 8 dereferenceable(24) %10)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  store i32 0, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %115

30:                                               ; preds = %25
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %36

33:                                               ; preds = %30
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %34, ptr noundef nonnull align 8 dereferenceable(24) %10)
  br label %36

36:                                               ; preds = %33, %30
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  %40 = load double, ptr %11, align 8, !tbaa !9
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  store double %40, ptr %41, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %39, %36
  store i32 1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %115

43:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 80, ptr %13) #5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN6R3SpanC1ERKS_(ptr noundef nonnull align 8 dereferenceable(80) %13, ptr noundef nonnull align 8 dereferenceable(80) %44)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = call noundef ptr @_ZNK10R3Triangle6VertexEi(ptr noundef nonnull align 8 dereferenceable(132) %45, i32 noundef 2)
  %47 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100) %46)
  store ptr %47, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 0, ptr %15, align 4, !tbaa !11
  br label %48

48:                                               ; preds = %91, %43
  %49 = load i32, ptr %15, align 4, !tbaa !11
  %50 = icmp slt i32 %49, 3
  br i1 %50, label %52, label %51

51:                                               ; preds = %48
  store i32 3, ptr %12, align 4
  br label %94

52:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load i32, ptr %15, align 4, !tbaa !11
  %55 = call noundef ptr @_ZNK10R3Triangle6VertexEi(ptr noundef nonnull align 8 dereferenceable(132) %53, i32 noundef %54)
  %56 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100) %55)
  store ptr %56, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %17) #5
  %57 = load ptr, ptr %16, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK10R3Triangle6NormalEv(ptr noundef nonnull align 8 dereferenceable(132) %58)
  call void @llvm.lifetime.start.p0(i64 24, ptr %18) #5
  %60 = load ptr, ptr %16, align 8, !tbaa !5
  %61 = load ptr, ptr %14, align 8, !tbaa !5
  call void @_ZmiRK7R3PointS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8 %18, ptr noundef nonnull align 8 dereferenceable(24) %60, ptr noundef nonnull align 8 dereferenceable(24) %61)
  call void @_ZN7R3PlaneC1ERK7R3PointRK8R3VectorS5_(ptr noundef nonnull align 8 dereferenceable(32) %17, ptr noundef nonnull align 8 dereferenceable(24) %57, ptr noundef nonnull align 8 dereferenceable(24) %59, ptr noundef nonnull align 8 dereferenceable(24) %18)
  call void @llvm.lifetime.end.p0(i64 24, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %62 = call noundef i32 @_ZN6R3Span4ClipERK7R3Plane(ptr noundef nonnull align 8 dereferenceable(80) %13, ptr noundef nonnull align 8 dereferenceable(32) %17)
  store i32 %62, ptr %19, align 4, !tbaa !11
  %63 = load i32, ptr %19, align 4, !tbaa !11
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %52
  store i32 0, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %88

66:                                               ; preds = %52
  %67 = load i32, ptr %19, align 4, !tbaa !11
  %68 = icmp eq i32 %67, 1
  br i1 %68, label %69, label %85

69:                                               ; preds = %66
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %76

72:                                               ; preds = %69
  %73 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Span5StartEv(ptr noundef nonnull align 8 dereferenceable(80) %13)
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %74, ptr noundef nonnull align 8 dereferenceable(24) %73)
  br label %76

76:                                               ; preds = %72, %69
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %84

79:                                               ; preds = %76
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Span5StartEv(ptr noundef nonnull align 8 dereferenceable(80) %13)
  %82 = call noundef double @_ZNK6R3Span1TERK7R3Point(ptr noundef nonnull align 8 dereferenceable(80) %80, ptr noundef nonnull align 8 dereferenceable(24) %81)
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  store double %82, ptr %83, align 8, !tbaa !9
  br label %84

84:                                               ; preds = %79, %76
  store i32 1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %88

85:                                               ; preds = %66
  br label %86

86:                                               ; preds = %85
  %87 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %87, ptr %14, align 8, !tbaa !5
  store i32 0, ptr %12, align 4
  br label %88

88:                                               ; preds = %86, %84, %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %89 = load i32, ptr %12, align 4
  switch i32 %89, label %94 [
    i32 0, label %90
  ]

90:                                               ; preds = %88
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %15, align 4, !tbaa !11
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %15, align 4, !tbaa !11
  br label %48, !llvm.loop !13

94:                                               ; preds = %88, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  %95 = load i32, ptr %12, align 4
  switch i32 %95, label %112 [
    i32 3, label %96
  ]

96:                                               ; preds = %94
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  %98 = icmp ne ptr %97, null
  br i1 %98, label %99, label %103

99:                                               ; preds = %96
  %100 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Span5StartEv(ptr noundef nonnull align 8 dereferenceable(80) %13)
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  %102 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %101, ptr noundef nonnull align 8 dereferenceable(24) %100)
  br label %103

103:                                              ; preds = %99, %96
  %104 = load ptr, ptr %9, align 8, !tbaa !5
  %105 = icmp ne ptr %104, null
  br i1 %105, label %106, label %111

106:                                              ; preds = %103
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  %108 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Span5StartEv(ptr noundef nonnull align 8 dereferenceable(80) %13)
  %109 = call noundef double @_ZNK6R3Span1TERK7R3Point(ptr noundef nonnull align 8 dereferenceable(80) %107, ptr noundef nonnull align 8 dereferenceable(24) %108)
  %110 = load ptr, ptr %9, align 8, !tbaa !5
  store double %109, ptr %110, align 8, !tbaa !9
  br label %111

111:                                              ; preds = %106, %103
  store i32 4, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %112

112:                                              ; preds = %111, %94
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr %13) #5
  br label %115

113:                                              ; preds = %4
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str.2)
  br label %114

114:                                              ; preds = %113
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str.1)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %115

115:                                              ; preds = %114, %112, %42, %29, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #5
  %116 = load i32, ptr %5, align 4
  ret i32 %116
}

declare void @_ZN6R3SpanC1ERKS_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK10R3Triangle6VertexEi(ptr noundef nonnull align 8 dereferenceable(132), i32 noundef) #4 align 2

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

declare void @_ZN7R3PlaneC1ERK7R3PointRK8R3VectorS5_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0

declare noundef i32 @_ZN6R3Span4ClipERK7R3Plane(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(32)) #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 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 = { 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 = { 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 #5 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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.R3Vector = type { [3 x double] }
%class.R3Point = type { [3 x double] }
%class.R3Span = type { %class.R3Ray, %class.R3Point, double }
%class.R3Ray = type { %class.R3Line }
%class.R3Line = type { %class.R3Point, %class.R3Vector }
%class.R3Plane = type { %class.R3Vector, double }

@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [28 x i8], align 1

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

declare noundef i32 @_Z10R3ContainsRK10R3TriangleRK7R3Point(ptr noundef nonnull align 8 dereferenceable(132), ptr noundef nonnull align 8 dereferenceable(24)) 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

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

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

declare void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK10R3Triangle5PlaneEv(ptr noundef nonnull align 8 dereferenceable(132)) local_unnamed_addr #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z12R3IntersectsRK6R3SpanRK7R3PlaneP7R3PointPd(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z12R3IntersectsRK6R3SpanRK10R3TriangleP7R3PointPd(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(132) %1, ptr noundef %2, ptr noundef writeonly %3) local_unnamed_addr #3 {
  %5 = alloca %class.R3Point, align 8
  %6 = alloca double, align 8
  %7 = alloca %class.R3Span, align 8
  %8 = alloca %class.R3Plane, align 8
  %9 = alloca %class.R3Vector, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #5
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %10 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK10R3Triangle5PlaneEv(ptr noundef nonnull align 8 dereferenceable(132) %1)
  %11 = call noundef i32 @_Z12R3IntersectsRK6R3SpanRK7R3PlaneP7R3PointPd(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(32) %10, ptr noundef nonnull %5, ptr noundef nonnull %6)
  switch i32 %11, label %55 [
    i32 0, label %56
    i32 1, label %12
    i32 4, label %20
  ]

12:                                               ; preds = %4
  %13 = call noundef i32 @_Z10R3ContainsRK10R3TriangleRK7R3Point(ptr noundef nonnull align 8 dereferenceable(132) %1, ptr noundef nonnull align 8 dereferenceable(24) %5)
  %.not48 = icmp eq i32 %13, 0
  br i1 %.not48, label %56, label %14

14:                                               ; preds = %12
  %.not49 = icmp eq ptr %2, null
  br i1 %.not49, label %17, label %15

15:                                               ; preds = %14
  %16 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %5)
  br label %17

17:                                               ; preds = %15, %14
  %.not50 = icmp eq ptr %3, null
  br i1 %.not50, label %56, label %18

18:                                               ; preds = %17
  %19 = load double, ptr %6, align 8, !tbaa !5
  store double %19, ptr %3, align 8, !tbaa !5
  br label %56

20:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %7) #5
  call void @_ZN6R3SpanC1ERKS_(ptr noundef nonnull align 8 dereferenceable(80) %7, ptr noundef nonnull align 8 dereferenceable(80) %0)
  %21 = call noundef ptr @_ZNK10R3Triangle6VertexEi(ptr noundef nonnull align 8 dereferenceable(132) %1, i32 noundef 2)
  %22 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100) %21)
  %23 = call noundef ptr @_ZNK10R3Triangle6VertexEi(ptr noundef nonnull align 8 dereferenceable(132) %1, i32 noundef 0)
  %24 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100) %23)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #5
  %25 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK10R3Triangle6NormalEv(ptr noundef nonnull align 8 dereferenceable(132) %1)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  call void @_ZmiRK7R3PointS1_(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %9, ptr noundef nonnull align 8 dereferenceable(24) %24, ptr noundef nonnull align 8 dereferenceable(24) %22)
  call void @_ZN7R3PlaneC1ERK7R3PointRK8R3VectorS5_(ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef nonnull align 8 dereferenceable(24) %24, ptr noundef nonnull align 8 dereferenceable(24) %25, ptr noundef nonnull align 8 dereferenceable(24) %9)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  %26 = call noundef i32 @_ZN6R3Span4ClipERK7R3Plane(ptr noundef nonnull align 8 dereferenceable(80) %7, ptr noundef nonnull align 8 dereferenceable(32) %8)
  switch i32 %26, label %35 [
    i32 0, label %.loopexit
    i32 1, label %27
  ]

27:                                               ; preds = %40, %35, %20
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %31, label %28

28:                                               ; preds = %27
  %29 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Span5StartEv(ptr noundef nonnull align 8 dereferenceable(80) %7)
  %30 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %29)
  br label %31

31:                                               ; preds = %28, %27
  %.not45 = icmp eq ptr %3, null
  br i1 %.not45, label %.loopexit, label %32

32:                                               ; preds = %31
  %33 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Span5StartEv(ptr noundef nonnull align 8 dereferenceable(80) %7)
  %34 = call noundef double @_ZNK6R3Span1TERK7R3Point(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(24) %33)
  store double %34, ptr %3, align 8, !tbaa !5
  br label %.loopexit

35:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  %36 = call noundef ptr @_ZNK10R3Triangle6VertexEi(ptr noundef nonnull align 8 dereferenceable(132) %1, i32 noundef 1)
  %37 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100) %36)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #5
  %38 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK10R3Triangle6NormalEv(ptr noundef nonnull align 8 dereferenceable(132) %1)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  call void @_ZmiRK7R3PointS1_(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %9, ptr noundef nonnull align 8 dereferenceable(24) %37, ptr noundef nonnull align 8 dereferenceable(24) %24)
  call void @_ZN7R3PlaneC1ERK7R3PointRK8R3VectorS5_(ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef nonnull align 8 dereferenceable(24) %37, ptr noundef nonnull align 8 dereferenceable(24) %38, ptr noundef nonnull align 8 dereferenceable(24) %9)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  %39 = call noundef i32 @_ZN6R3Span4ClipERK7R3Plane(ptr noundef nonnull align 8 dereferenceable(80) %7, ptr noundef nonnull align 8 dereferenceable(32) %8)
  switch i32 %39, label %40 [
    i32 0, label %.loopexit
    i32 1, label %27
  ]

40:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  %41 = call noundef ptr @_ZNK10R3Triangle6VertexEi(ptr noundef nonnull align 8 dereferenceable(132) %1, i32 noundef 2)
  %42 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100) %41)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #5
  %43 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK10R3Triangle6NormalEv(ptr noundef nonnull align 8 dereferenceable(132) %1)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  call void @_ZmiRK7R3PointS1_(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %9, ptr noundef nonnull align 8 dereferenceable(24) %42, ptr noundef nonnull align 8 dereferenceable(24) %37)
  call void @_ZN7R3PlaneC1ERK7R3PointRK8R3VectorS5_(ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef nonnull align 8 dereferenceable(24) %42, ptr noundef nonnull align 8 dereferenceable(24) %43, ptr noundef nonnull align 8 dereferenceable(24) %9)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  %44 = call noundef i32 @_ZN6R3Span4ClipERK7R3Plane(ptr noundef nonnull align 8 dereferenceable(80) %7, ptr noundef nonnull align 8 dereferenceable(32) %8)
  switch i32 %44, label %45 [
    i32 0, label %.loopexit
    i32 1, label %27
  ]

45:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  %.not46 = icmp eq ptr %2, null
  br i1 %.not46, label %50, label %47

.loopexit:                                        ; preds = %20, %35, %40, %32, %31
  %46 = phi i32 [ 1, %32 ], [ 1, %31 ], [ %44, %40 ], [ %39, %35 ], [ %26, %20 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  br label %54

47:                                               ; preds = %45
  %48 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Span5StartEv(ptr noundef nonnull align 8 dereferenceable(80) %7)
  %49 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %48)
  br label %50

50:                                               ; preds = %47, %45
  %.not47 = icmp eq ptr %3, null
  br i1 %.not47, label %54, label %51

51:                                               ; preds = %50
  %52 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Span5StartEv(ptr noundef nonnull align 8 dereferenceable(80) %7)
  %53 = call noundef double @_ZNK6R3Span1TERK7R3Point(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(24) %52)
  store double %53, ptr %3, align 8, !tbaa !5
  br label %54

54:                                               ; preds = %.loopexit, %50, %51
  %.3 = phi i32 [ %46, %.loopexit ], [ 4, %51 ], [ 4, %50 ]
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %7) #5
  br label %56

55:                                               ; preds = %4
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str.2)
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str.1)
  br label %56

56:                                               ; preds = %17, %18, %12, %4, %55, %54
  %.4 = phi i32 [ 0, %55 ], [ %.3, %54 ], [ %11, %4 ], [ 0, %12 ], [ 1, %18 ], [ 1, %17 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #5
  ret i32 %.4
}

declare void @_ZN6R3SpanC1ERKS_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK10R3Triangle6VertexEi(ptr noundef nonnull align 8 dereferenceable(132), i32 noundef) local_unnamed_addr #4 align 2

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

declare void @_ZN7R3PlaneC1ERK7R3PointRK8R3VectorS5_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0

declare noundef i32 @_ZN6R3Span4ClipERK7R3Plane(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 #5 = { 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++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass