; LLVM IR from atlantis13579/Riemann :: Src/Collision (AABBTree)

; 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.Maths::TVector3" = type { float, float, float }
%"class.Riemann::StaticStack" = type { i32, [32 x i32] }
%"struct.Riemann::RayCastResult" = type <{ i8, [3 x i8], float, float, %"class.Maths::TVector3", %"class.Maths::TVector3", [4 x i8], ptr, %"class.std::vector.0", i32, [4 x i8] }>
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<Riemann::Geometry *, std::allocator<Riemann::Geometry *>>::_Vector_impl" }
%"struct.std::_Vector_base<Riemann::Geometry *, std::allocator<Riemann::Geometry *>>::_Vector_impl" = type { %"struct.std::_Vector_base<Riemann::Geometry *, std::allocator<Riemann::Geometry *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Riemann::Geometry *, std::allocator<Riemann::Geometry *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.Riemann::RayCastOption" = type { i32, [4 x i8], %"struct.Riemann::RayCastCache", i8, float, i32, %"struct.Riemann::CollisionData", ptr }
%"struct.Riemann::RayCastCache" = type <{ ptr, %"class.Riemann::StaticStack", [4 x i8] }>
%"struct.Riemann::CollisionData" = type { i32, i32, i32, i32 }
%"class.Riemann::AABBTree" = type { ptr, i32, ptr }
%"struct.Riemann::CacheFriendlyAABBTree" = type { %"class.Maths::TAABB3", i32 }
%"class.Maths::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__._ZNK7Riemann8AABBTree7RayCastERK4Ray3PPNS_8GeometryEPKNS_13RayCastOptionEPNS_13RayCastResultE = external hidden unnamed_addr constant [105 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, 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: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann11StaticStackIjLi32EEC2Ev(ptr noundef nonnull align 4 dereferenceable(132)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann11StaticStackIjLi32EE4pushEj(ptr noundef nonnull align 4 dereferenceable(132), i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE5emptyEv(ptr noundef nonnull align 4 dereferenceable(132)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7Riemann11StaticStackIjLi32EE3popEv(ptr noundef nonnull align 4 dereferenceable(132)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7Riemann21CacheFriendlyAABBTree6IsLeafEv(ptr noundef nonnull align 4 dereferenceable(28)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7Riemann21CacheFriendlyAABBTree16GetNumGeometriesEv(ptr noundef nonnull align 4 dereferenceable(28)) #3 align 2

; 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 nounwind uwtable
declare dso_local noundef ptr @_ZN7Riemann21CacheFriendlyAABBTree11GetLeftNodeEPS0_(ptr noundef nonnull align 4 dereferenceable(28), ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7Riemann21CacheFriendlyAABBTree12GetRightNodeEPS0_(ptr noundef nonnull align 4 dereferenceable(28), ptr noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE4fullEv(ptr noundef nonnull align 4 dereferenceable(132)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK7Riemann21CacheFriendlyAABBTree18GetGeometryIndicesEPi(ptr noundef nonnull align 4 dereferenceable(28), ptr noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7Riemann20RayIntersectCacheObjERK4Ray3PKNS_13RayCastOptionEPNS_13RayCastResultE(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef, ptr noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7Riemann17RestoreCacheStackEPKNS_13RayCastOptionEPNS_11StaticStackIjLi32EEE(ptr noundef, ptr noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK7Riemann8AABBTree7RayCastERK4Ray3PPNS_8GeometryEPKNS_13RayCastOptionEPNS_13RayCastResultE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #4 align 2 {
  %6 = alloca i1, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca %"class.Maths::TVector3", align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca %"class.Riemann::StaticStack", align 4
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca %"class.Maths::TVector3", align 4
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca i8, align 1
  %26 = alloca i8, align 1
  %27 = alloca %"class.Maths::TVector3", align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %28 = load ptr, ptr %7, align 8
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %29, i32 0, i32 0
  store i8 0, ptr %30, align 8, !tbaa !9
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %31, i32 0, i32 9
  store i32 0, ptr %32, align 8, !tbaa !19
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %33, i32 0, i32 3
  store float 0x47EFFFFFE0000000, ptr %34, align 8, !tbaa !20
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %35, i32 0, i32 7
  store ptr null, ptr %36, align 8, !tbaa !21
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = call noundef zeroext i1 @_ZN7Riemann20RayIntersectCacheObjERK4Ray3PKNS_13RayCastOptionEPNS_13RayCastResultE(ptr noundef nonnull align 4 dereferenceable(24) %37, ptr noundef %38, ptr noundef %39)
  br i1 %40, label %41, label %66

41:                                               ; preds = %5
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.Riemann::RayCastOption", ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !22
  %45 = icmp eq i32 %44, 1
  br i1 %45, label %46, label %54

46:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 12, ptr %12) #5
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %48, i32 0, i32 3
  %50 = load float, ptr %49, align 8, !tbaa !20
  call void @_ZNK4Ray37PointAtEf(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %12, ptr noundef nonnull align 4 dereferenceable(24) %47, float noundef %50)
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %51, i32 0, i32 4
  %53 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %52, ptr noundef nonnull align 4 dereferenceable(12) %12)
  call void @llvm.lifetime.end.p0(i64 12, ptr %12) #5
  store i1 true, ptr %6, align 1
  br label %294

54:                                               ; preds = %41
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.Riemann::RayCastOption", ptr %55, i32 0, i32 0
  %57 = load i32, ptr %56, align 8, !tbaa !22
  %58 = icmp eq i32 %57, 2
  br i1 %58, label %59, label %64

59:                                               ; preds = %54
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %60, i32 0, i32 8
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %62, i32 0, i32 7
  call void @_ZNSt6vectorIPN7Riemann8GeometryESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %61, ptr noundef nonnull align 8 dereferenceable(8) %63)
  br label %64

64:                                               ; preds = %59, %54
  br label %65

65:                                               ; preds = %64
  br label %66

66:                                               ; preds = %65, %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %67 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %28, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !28
  store ptr %68, ptr %15, align 8, !tbaa !5
  %69 = load ptr, ptr %15, align 8, !tbaa !5
  %70 = icmp eq ptr %69, null
  br i1 %70, label %86, label %71

71:                                               ; preds = %66
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = load ptr, ptr %15, align 8, !tbaa !5
  %74 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds %"class.Maths::TAABB3", ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %15, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %76, i32 0, i32 0
  %78 = getelementptr inbounds %"class.Maths::TAABB3", ptr %77, i32 0, i32 1
  %79 = call noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24) %72, ptr noundef nonnull align 4 dereferenceable(12) %75, ptr noundef nonnull align 4 dereferenceable(12) %78, ptr noundef %13)
  br i1 %79, label %80, label %86

80:                                               ; preds = %71
  %81 = load float, ptr %13, align 4, !tbaa !30
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  %83 = getelementptr inbounds %"struct.Riemann::RayCastOption", ptr %82, i32 0, i32 4
  %84 = load float, ptr %83, align 4, !tbaa !31
  %85 = fcmp oge float %81, %84
  br i1 %85, label %86, label %87

86:                                               ; preds = %80, %71, %66
  store i1 false, ptr %6, align 1
  store i32 1, ptr %16, align 4
  br label %293

87:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 132, ptr %17) #5
  call void @_ZN7Riemann11StaticStackIjLi32EEC2Ev(ptr noundef nonnull align 4 dereferenceable(132) %17)
  %88 = load ptr, ptr %10, align 8, !tbaa !5
  %89 = call noundef zeroext i1 @_ZN7Riemann17RestoreCacheStackEPKNS_13RayCastOptionEPNS_11StaticStackIjLi32EEE(ptr noundef %88, ptr noundef %17)
  br i1 %89, label %91, label %90

90:                                               ; preds = %87
  call void @_ZN7Riemann11StaticStackIjLi32EE4pushEj(ptr noundef nonnull align 4 dereferenceable(132) %17, i32 noundef 0)
  br label %91

91:                                               ; preds = %90, %87
  br label %92

92:                                               ; preds = %272, %91
  %93 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE5emptyEv(ptr noundef nonnull align 4 dereferenceable(132) %17)
  %94 = xor i1 %93, true
  br i1 %94, label %95, label %273

95:                                               ; preds = %92
  %96 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %28, i32 0, i32 2
  %97 = load ptr, ptr %96, align 8, !tbaa !28
  %98 = call noundef i32 @_ZN7Riemann11StaticStackIjLi32EE3popEv(ptr noundef nonnull align 4 dereferenceable(132) %17)
  %99 = zext i32 %98 to i64
  %100 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %97, i64 %99
  store ptr %100, ptr %15, align 8, !tbaa !5
  br label %101

101:                                              ; preds = %270, %95
  %102 = load ptr, ptr %15, align 8, !tbaa !5
  %103 = icmp ne ptr %102, null
  br i1 %103, label %104, label %272

104:                                              ; preds = %101
  %105 = load ptr, ptr %15, align 8, !tbaa !5
  %106 = call noundef zeroext i1 @_ZNK7Riemann21CacheFriendlyAABBTree6IsLeafEv(ptr noundef nonnull align 4 dereferenceable(28) %105)
  br i1 %106, label %107, label %143

107:                                              ; preds = %104
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %108 = load ptr, ptr %15, align 8, !tbaa !5
  %109 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %28, i32 0, i32 0
  %110 = load ptr, ptr %109, align 8, !tbaa !32
  %111 = call noundef ptr @_ZNK7Riemann21CacheFriendlyAABBTree18GetGeometryIndicesEPi(ptr noundef nonnull align 4 dereferenceable(28) %108, ptr noundef %110)
  store ptr %111, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %112 = load ptr, ptr %15, align 8, !tbaa !5
  %113 = call noundef i32 @_ZNK7Riemann21CacheFriendlyAABBTree16GetNumGeometriesEv(ptr noundef nonnull align 4 dereferenceable(28) %112)
  store i32 %113, ptr %19, align 4, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %114 = load ptr, ptr %15, align 8, !tbaa !5
  %115 = call noundef nonnull align 4 dereferenceable(24) ptr @_ZNK7Riemann21CacheFriendlyAABBTree17GetBoundingVolumeEv(ptr noundef nonnull align 4 dereferenceable(28) %114)
  store ptr %115, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  %116 = load ptr, ptr %8, align 8, !tbaa !5
  %117 = load ptr, ptr %18, align 8, !tbaa !5
  %118 = load i32, ptr %19, align 4, !tbaa !33
  %119 = load ptr, ptr %9, align 8, !tbaa !5
  %120 = load ptr, ptr %20, align 8, !tbaa !5
  %121 = load ptr, ptr %10, align 8, !tbaa !5
  %122 = load ptr, ptr %11, align 8, !tbaa !5
  %123 = call noundef i32 @_ZN7RiemannL22RayIntersectGeometriesERK4Ray3PiiPPNS_8GeometryERKN5Maths6TAABB3IfEEPKNS_13RayCastOptionEPNS_13RayCastResultE(ptr noundef nonnull align 4 dereferenceable(24) %116, ptr noundef %117, i32 noundef %118, ptr noundef %119, ptr noundef nonnull align 4 dereferenceable(24) %120, ptr noundef %121, ptr noundef %122)
  store i32 %123, ptr %21, align 4, !tbaa !33
  %124 = load i32, ptr %21, align 4, !tbaa !33
  %125 = icmp sge i32 %124, 0
  br i1 %125, label %126, label %140

126:                                              ; preds = %107
  %127 = load ptr, ptr %10, align 8, !tbaa !5
  %128 = getelementptr inbounds %"struct.Riemann::RayCastOption", ptr %127, i32 0, i32 0
  %129 = load i32, ptr %128, align 8, !tbaa !22
  %130 = icmp eq i32 %129, 1
  br i1 %130, label %131, label %139

131:                                              ; preds = %126
  call void @llvm.lifetime.start.p0(i64 12, ptr %22) #5
  %132 = load ptr, ptr %8, align 8, !tbaa !5
  %133 = load ptr, ptr %11, align 8, !tbaa !5
  %134 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %133, i32 0, i32 3
  %135 = load float, ptr %134, align 8, !tbaa !20
  call void @_ZNK4Ray37PointAtEf(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %22, ptr noundef nonnull align 4 dereferenceable(24) %132, float noundef %135)
  %136 = load ptr, ptr %11, align 8, !tbaa !5
  %137 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %136, i32 0, i32 4
  %138 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %137, ptr noundef nonnull align 4 dereferenceable(12) %22)
  call void @llvm.lifetime.end.p0(i64 12, ptr %22) #5
  store i1 true, ptr %6, align 1
  store i32 1, ptr %16, align 4
  br label %141

139:                                              ; preds = %126
  br label %140

140:                                              ; preds = %139, %107
  store i32 5, ptr %16, align 4
  br label %141

141:                                              ; preds = %140, %131
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  %142 = load i32, ptr %16, align 4
  switch i32 %142, label %292 [
    i32 5, label %272
  ]

143:                                              ; preds = %104
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  %144 = load ptr, ptr %15, align 8, !tbaa !5
  %145 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %28, i32 0, i32 2
  %146 = load ptr, ptr %145, align 8, !tbaa !28
  %147 = call noundef ptr @_ZN7Riemann21CacheFriendlyAABBTree11GetLeftNodeEPS0_(ptr noundef nonnull align 4 dereferenceable(28) %144, ptr noundef %146)
  store ptr %147, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #5
  %148 = load ptr, ptr %15, align 8, !tbaa !5
  %149 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %28, i32 0, i32 2
  %150 = load ptr, ptr %149, align 8, !tbaa !28
  %151 = call noundef ptr @_ZN7Riemann21CacheFriendlyAABBTree12GetRightNodeEPS0_(ptr noundef nonnull align 4 dereferenceable(28) %148, ptr noundef %150)
  store ptr %151, ptr %24, align 8, !tbaa !5
  %152 = load ptr, ptr %11, align 8, !tbaa !5
  call void @_ZN7Riemann13RayCastResult12AddTestCountEi(ptr noundef nonnull align 8 dereferenceable(76) %152, i32 noundef 2)
  call void @llvm.lifetime.start.p0(i64 1, ptr %25) #5
  %153 = load ptr, ptr %23, align 8, !tbaa !5
  %154 = icmp ne ptr %153, null
  br i1 %154, label %155, label %164

155:                                              ; preds = %143
  %156 = load ptr, ptr %8, align 8, !tbaa !5
  %157 = load ptr, ptr %23, align 8, !tbaa !5
  %158 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %157, i32 0, i32 0
  %159 = getelementptr inbounds %"class.Maths::TAABB3", ptr %158, i32 0, i32 0
  %160 = load ptr, ptr %23, align 8, !tbaa !5
  %161 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %160, i32 0, i32 0
  %162 = getelementptr inbounds %"class.Maths::TAABB3", ptr %161, i32 0, i32 1
  %163 = call noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24) %156, ptr noundef nonnull align 4 dereferenceable(12) %159, ptr noundef nonnull align 4 dereferenceable(12) %162, ptr noundef %13)
  br label %164

164:                                              ; preds = %155, %143
  %165 = phi i1 [ false, %143 ], [ %163, %155 ]
  %166 = zext i1 %165 to i8
  store i8 %166, ptr %25, align 1, !tbaa !34
  call void @llvm.lifetime.start.p0(i64 1, ptr %26) #5
  %167 = load ptr, ptr %24, align 8, !tbaa !5
  %168 = icmp ne ptr %167, null
  br i1 %168, label %169, label %178

169:                                              ; preds = %164
  %170 = load ptr, ptr %8, align 8, !tbaa !5
  %171 = load ptr, ptr %24, align 8, !tbaa !5
  %172 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %171, i32 0, i32 0
  %173 = getelementptr inbounds %"class.Maths::TAABB3", ptr %172, i32 0, i32 0
  %174 = load ptr, ptr %24, align 8, !tbaa !5
  %175 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %174, i32 0, i32 0
  %176 = getelementptr inbounds %"class.Maths::TAABB3", ptr %175, i32 0, i32 1
  %177 = call noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24) %170, ptr noundef nonnull align 4 dereferenceable(12) %173, ptr noundef nonnull align 4 dereferenceable(12) %176, ptr noundef %14)
  br label %178

178:                                              ; preds = %169, %164
  %179 = phi i1 [ false, %164 ], [ %177, %169 ]
  %180 = zext i1 %179 to i8
  store i8 %180, ptr %26, align 1, !tbaa !34
  %181 = load ptr, ptr %10, align 8, !tbaa !5
  %182 = getelementptr inbounds %"struct.Riemann::RayCastOption", ptr %181, i32 0, i32 0
  %183 = load i32, ptr %182, align 8, !tbaa !22
  %184 = icmp ne i32 %183, 2
  br i1 %184, label %185, label %220

185:                                              ; preds = %178
  %186 = load i8, ptr %25, align 1, !tbaa !34, !range !35, !noundef !36
  %187 = trunc i8 %186 to i1
  br i1 %187, label %188, label %200

188:                                              ; preds = %185
  %189 = load float, ptr %13, align 4, !tbaa !30
  %190 = load ptr, ptr %11, align 8, !tbaa !5
  %191 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %190, i32 0, i32 3
  %192 = load float, ptr %191, align 8, !tbaa !20
  %193 = fcmp olt float %189, %192
  br i1 %193, label %194, label %200

194:                                              ; preds = %188
  %195 = load float, ptr %13, align 4, !tbaa !30
  %196 = load ptr, ptr %10, align 8, !tbaa !5
  %197 = getelementptr inbounds %"struct.Riemann::RayCastOption", ptr %196, i32 0, i32 4
  %198 = load float, ptr %197, align 4, !tbaa !31
  %199 = fcmp olt float %195, %198
  br label %200

200:                                              ; preds = %194, %188, %185
  %201 = phi i1 [ false, %188 ], [ false, %185 ], [ %199, %194 ]
  %202 = zext i1 %201 to i8
  store i8 %202, ptr %25, align 1, !tbaa !34
  %203 = load i8, ptr %26, align 1, !tbaa !34, !range !35, !noundef !36
  %204 = trunc i8 %203 to i1
  br i1 %204, label %205, label %217

205:                                              ; preds = %200
  %206 = load float, ptr %14, align 4, !tbaa !30
  %207 = load ptr, ptr %11, align 8, !tbaa !5
  %208 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %207, i32 0, i32 3
  %209 = load float, ptr %208, align 8, !tbaa !20
  %210 = fcmp olt float %206, %209
  br i1 %210, label %211, label %217

211:                                              ; preds = %205
  %212 = load float, ptr %14, align 4, !tbaa !30
  %213 = load ptr, ptr %10, align 8, !tbaa !5
  %214 = getelementptr inbounds %"struct.Riemann::RayCastOption", ptr %213, i32 0, i32 4
  %215 = load float, ptr %214, align 4, !tbaa !31
  %216 = fcmp olt float %212, %215
  br label %217

217:                                              ; preds = %211, %205, %200
  %218 = phi i1 [ false, %205 ], [ false, %200 ], [ %216, %211 ]
  %219 = zext i1 %218 to i8
  store i8 %219, ptr %26, align 1, !tbaa !34
  br label %220

220:                                              ; preds = %217, %178
  %221 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE4fullEv(ptr noundef nonnull align 4 dereferenceable(132) %17)
  %222 = xor i1 %221, true
  br i1 %222, label %223, label %224

223:                                              ; preds = %220
  br label %226

224:                                              ; preds = %220
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 304, ptr noundef @__PRETTY_FUNCTION__._ZNK7Riemann8AABBTree7RayCastERK4Ray3PPNS_8GeometryEPKNS_13RayCastOptionEPNS_13RayCastResultE) #6
  unreachable

225:                                              ; No predecessors!
  br label %226

226:                                              ; preds = %225, %223
  %227 = load i8, ptr %25, align 1, !tbaa !34, !range !35, !noundef !36
  %228 = trunc i8 %227 to i1
  br i1 %228, label %229, label %257

229:                                              ; preds = %226
  %230 = load i8, ptr %26, align 1, !tbaa !34, !range !35, !noundef !36
  %231 = trunc i8 %230 to i1
  br i1 %231, label %232, label %257

232:                                              ; preds = %229
  %233 = load float, ptr %13, align 4, !tbaa !30
  %234 = load float, ptr %14, align 4, !tbaa !30
  %235 = fcmp olt float %233, %234
  br i1 %235, label %236, label %246

236:                                              ; preds = %232
  %237 = load ptr, ptr %23, align 8, !tbaa !5
  store ptr %237, ptr %15, align 8, !tbaa !5
  %238 = load ptr, ptr %24, align 8, !tbaa !5
  %239 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %28, i32 0, i32 2
  %240 = load ptr, ptr %239, align 8, !tbaa !28
  %241 = ptrtoint ptr %238 to i64
  %242 = ptrtoint ptr %240 to i64
  %243 = sub i64 %241, %242
  %244 = sdiv exact i64 %243, 28
  %245 = trunc i64 %244 to i32
  call void @_ZN7Riemann11StaticStackIjLi32EE4pushEj(ptr noundef nonnull align 4 dereferenceable(132) %17, i32 noundef %245)
  br label %256

246:                                              ; preds = %232
  %247 = load ptr, ptr %24, align 8, !tbaa !5
  store ptr %247, ptr %15, align 8, !tbaa !5
  %248 = load ptr, ptr %23, align 8, !tbaa !5
  %249 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %28, i32 0, i32 2
  %250 = load ptr, ptr %249, align 8, !tbaa !28
  %251 = ptrtoint ptr %248 to i64
  %252 = ptrtoint ptr %250 to i64
  %253 = sub i64 %251, %252
  %254 = sdiv exact i64 %253, 28
  %255 = trunc i64 %254 to i32
  call void @_ZN7Riemann11StaticStackIjLi32EE4pushEj(ptr noundef nonnull align 4 dereferenceable(132) %17, i32 noundef %255)
  br label %256

256:                                              ; preds = %246, %236
  store i32 4, ptr %16, align 4
  br label %270, !llvm.loop !37

257:                                              ; preds = %229, %226
  %258 = load i8, ptr %25, align 1, !tbaa !34, !range !35, !noundef !36
  %259 = trunc i8 %258 to i1
  br i1 %259, label %260, label %262

260:                                              ; preds = %257
  %261 = load ptr, ptr %23, align 8, !tbaa !5
  store ptr %261, ptr %15, align 8, !tbaa !5
  store i32 4, ptr %16, align 4
  br label %270, !llvm.loop !37

262:                                              ; preds = %257
  %263 = load i8, ptr %26, align 1, !tbaa !34, !range !35, !noundef !36
  %264 = trunc i8 %263 to i1
  br i1 %264, label %265, label %267

265:                                              ; preds = %262
  %266 = load ptr, ptr %24, align 8, !tbaa !5
  store ptr %266, ptr %15, align 8, !tbaa !5
  store i32 4, ptr %16, align 4
  br label %270, !llvm.loop !37

267:                                              ; preds = %262
  br label %268

268:                                              ; preds = %267
  br label %269

269:                                              ; preds = %268
  store i32 5, ptr %16, align 4
  br label %270

270:                                              ; preds = %269, %265, %260, %256
  call void @llvm.lifetime.end.p0(i64 1, ptr %26) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %25) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  %271 = load i32, ptr %16, align 4
  switch i32 %271, label %296 [
    i32 4, label %101
    i32 5, label %272
  ]

272:                                              ; preds = %270, %141, %101
  br label %92, !llvm.loop !39

273:                                              ; preds = %92
  %274 = load ptr, ptr %11, align 8, !tbaa !5
  %275 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %274, i32 0, i32 0
  %276 = load i8, ptr %275, align 8, !tbaa !9, !range !35, !noundef !36
  %277 = trunc i8 %276 to i1
  br i1 %277, label %283, label %278

278:                                              ; preds = %273
  %279 = load ptr, ptr %11, align 8, !tbaa !5
  %280 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %279, i32 0, i32 8
  %281 = call noundef i64 @_ZNKSt6vectorIPN7Riemann8GeometryESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %280) #5
  %282 = icmp ugt i64 %281, 0
  br i1 %282, label %283, label %291

283:                                              ; preds = %278, %273
  call void @llvm.lifetime.start.p0(i64 12, ptr %27) #5
  %284 = load ptr, ptr %8, align 8, !tbaa !5
  %285 = load ptr, ptr %11, align 8, !tbaa !5
  %286 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %285, i32 0, i32 3
  %287 = load float, ptr %286, align 8, !tbaa !20
  call void @_ZNK4Ray37PointAtEf(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %27, ptr noundef nonnull align 4 dereferenceable(24) %284, float noundef %287)
  %288 = load ptr, ptr %11, align 8, !tbaa !5
  %289 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %288, i32 0, i32 4
  %290 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %289, ptr noundef nonnull align 4 dereferenceable(12) %27)
  call void @llvm.lifetime.end.p0(i64 12, ptr %27) #5
  store i1 true, ptr %6, align 1
  store i32 1, ptr %16, align 4
  br label %292

291:                                              ; preds = %278
  store i1 false, ptr %6, align 1
  store i32 1, ptr %16, align 4
  br label %292

292:                                              ; preds = %291, %283, %141
  call void @llvm.lifetime.end.p0(i64 132, ptr %17) #5
  br label %293

293:                                              ; preds = %292, %86
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %294

294:                                              ; preds = %293, %46
  %295 = load i1, ptr %6, align 1
  ret i1 %295

296:                                              ; preds = %270
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4Ray37PointAtEf(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4, ptr noundef nonnull align 4 dereferenceable(24), float noundef) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIPN7Riemann8GeometryESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(24) ptr @_ZNK7Riemann21CacheFriendlyAABBTree17GetBoundingVolumeEv(ptr noundef nonnull align 4 dereferenceable(28)) #3 align 2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN7RiemannL22RayIntersectGeometriesERK4Ray3PiiPPNS_8GeometryERKN5Maths6TAABB3IfEEPKNS_13RayCastOptionEPNS_13RayCastResultE(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef, i32 noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(24), ptr noundef, ptr noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann13RayCastResult12AddTestCountEi(ptr noundef nonnull align 8 dereferenceable(76), i32 noundef) #2 align 2

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

attributes #0 = { noreturn 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 #4 = { 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 }
attributes #6 = { noreturn 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, !11, i64 0}
!10 = !{!"_ZTSN7Riemann13RayCastResultE", !11, i64 0, !12, i64 4, !12, i64 8, !13, i64 12, !13, i64 24, !6, i64 40, !14, i64 48, !18, i64 72}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"_ZTSN5Maths8TVector3IfEE", !12, i64 0, !12, i64 4, !12, i64 8}
!14 = !{!"_ZTSSt6vectorIPN7Riemann8GeometryESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIPN7Riemann8GeometryESaIS2_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIPN7Riemann8GeometryESaIS2_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIPN7Riemann8GeometryESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"int", !7, i64 0}
!19 = !{!10, !18, i64 72}
!20 = !{!10, !12, i64 8}
!21 = !{!10, !6, i64 40}
!22 = !{!23, !24, i64 0}
!23 = !{!"_ZTSN7Riemann13RayCastOptionE", !24, i64 0, !25, i64 8, !11, i64 152, !12, i64 156, !18, i64 160, !27, i64 164, !6, i64 184}
!24 = !{!"_ZTSN7Riemann13RayCastOption11RayCastTypeE", !7, i64 0}
!25 = !{!"_ZTSN7Riemann12RayCastCacheE", !6, i64 0, !26, i64 8}
!26 = !{!"_ZTSN7Riemann11StaticStackIjLi32EEE", !18, i64 0, !7, i64 4}
!27 = !{!"_ZTSN7Riemann13CollisionDataE", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12}
!28 = !{!29, !6, i64 16}
!29 = !{!"_ZTSN7Riemann8AABBTreeE", !6, i64 0, !18, i64 8, !6, i64 16}
!30 = !{!12, !12, i64 0}
!31 = !{!23, !12, i64 156}
!32 = !{!29, !6, i64 0}
!33 = !{!18, !18, i64 0}
!34 = !{!11, !11, i64 0}
!35 = !{i8 0, i8 2}
!36 = !{}
!37 = distinct !{!37, !38}
!38 = !{!"llvm.loop.mustprogress"}
!39 = distinct !{!39, !38}


; 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.Maths::TVector3" = type { float, float, float }
%"class.Riemann::StaticStack" = type { i32, [32 x i32] }
%"struct.Riemann::CacheFriendlyAABBTree" = type { %"class.Maths::TAABB3", i32 }
%"class.Maths::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__._ZNK7Riemann8AABBTree7RayCastERK4Ray3PPNS_8GeometryEPKNS_13RayCastOptionEPNS_13RayCastResultE = external hidden unnamed_addr constant [105 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, 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 nounwind uwtable
declare dso_local void @_ZN7Riemann11StaticStackIjLi32EEC2Ev(ptr noundef nonnull align 4 dereferenceable(132)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann11StaticStackIjLi32EE4pushEj(ptr noundef nonnull align 4 dereferenceable(132), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE5emptyEv(ptr noundef nonnull align 4 dereferenceable(132)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7Riemann11StaticStackIjLi32EE3popEv(ptr noundef nonnull align 4 dereferenceable(132)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7Riemann21CacheFriendlyAABBTree6IsLeafEv(ptr noundef nonnull align 4 dereferenceable(28)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7Riemann21CacheFriendlyAABBTree16GetNumGeometriesEv(ptr noundef nonnull align 4 dereferenceable(28)) local_unnamed_addr #3 align 2

; 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 nounwind uwtable
declare dso_local noundef ptr @_ZN7Riemann21CacheFriendlyAABBTree11GetLeftNodeEPS0_(ptr noundef nonnull align 4 dereferenceable(28), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7Riemann21CacheFriendlyAABBTree12GetRightNodeEPS0_(ptr noundef nonnull align 4 dereferenceable(28), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE4fullEv(ptr noundef nonnull align 4 dereferenceable(132)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK7Riemann21CacheFriendlyAABBTree18GetGeometryIndicesEPi(ptr noundef nonnull align 4 dereferenceable(28), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7Riemann20RayIntersectCacheObjERK4Ray3PKNS_13RayCastOptionEPNS_13RayCastResultE(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7Riemann17RestoreCacheStackEPKNS_13RayCastOptionEPNS_11StaticStackIjLi32EEE(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK7Riemann8AABBTree7RayCastERK4Ray3PPNS_8GeometryEPKNS_13RayCastOptionEPNS_13RayCastResultE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #4 align 2 {
  %6 = alloca %"class.Maths::TVector3", align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca %"class.Riemann::StaticStack", align 4
  %10 = alloca %"class.Maths::TVector3", align 4
  %11 = alloca %"class.Maths::TVector3", align 4
  store i8 0, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %4, i64 72
  store i32 0, ptr %12, align 8, !tbaa !18
  %13 = getelementptr inbounds i8, ptr %4, i64 8
  store float 0x47EFFFFFE0000000, ptr %13, align 8, !tbaa !19
  %14 = getelementptr inbounds i8, ptr %4, i64 40
  store ptr null, ptr %14, align 8, !tbaa !20
  %15 = tail call noundef zeroext i1 @_ZN7Riemann20RayIntersectCacheObjERK4Ray3PKNS_13RayCastOptionEPNS_13RayCastResultE(ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef %3, ptr noundef nonnull %4)
  br i1 %15, label %16, label %24

16:                                               ; preds = %5
  %17 = load i32, ptr %3, align 8, !tbaa !21
  switch i32 %17, label %24 [
    i32 1, label %18
    i32 2, label %22
  ]

18:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #5
  %19 = load float, ptr %13, align 8, !tbaa !19
  call void @_ZNK4Ray37PointAtEf(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector3") align 4 %6, ptr noundef nonnull align 4 dereferenceable(24) %1, float noundef %19)
  %20 = getelementptr inbounds i8, ptr %4, i64 12
  %21 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %20, ptr noundef nonnull align 4 dereferenceable(12) %6)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #5
  br label %120

22:                                               ; preds = %16
  %23 = getelementptr inbounds i8, ptr %4, i64 48
  tail call void @_ZNSt6vectorIPN7Riemann8GeometryESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %23, ptr noundef nonnull align 8 dereferenceable(8) %14)
  br label %24

24:                                               ; preds = %16, %22, %5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #5
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !27
  %27 = icmp eq ptr %26, null
  br i1 %27, label %119, label %28

28:                                               ; preds = %24
  %29 = getelementptr inbounds i8, ptr %26, i64 12
  %30 = call noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef nonnull align 4 dereferenceable(12) %26, ptr noundef nonnull align 4 dereferenceable(12) %29, ptr noundef nonnull %7)
  br i1 %30, label %31, label %119

31:                                               ; preds = %28
  %32 = load float, ptr %7, align 4, !tbaa !29
  %33 = getelementptr inbounds i8, ptr %3, i64 156
  %34 = load float, ptr %33, align 4, !tbaa !30
  %35 = fcmp ult float %32, %34
  br i1 %35, label %36, label %119

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 132, ptr nonnull %9) #5
  call void @_ZN7Riemann11StaticStackIjLi32EEC2Ev(ptr noundef nonnull align 4 dereferenceable(132) %9)
  %37 = call noundef zeroext i1 @_ZN7Riemann17RestoreCacheStackEPKNS_13RayCastOptionEPNS_11StaticStackIjLi32EEE(ptr noundef nonnull %3, ptr noundef nonnull %9)
  br i1 %37, label %39, label %38

38:                                               ; preds = %36
  call void @_ZN7Riemann11StaticStackIjLi32EE4pushEj(ptr noundef nonnull align 4 dereferenceable(132) %9, i32 noundef 0)
  br label %39

39:                                               ; preds = %38, %36
  %40 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE5emptyEv(ptr noundef nonnull align 4 dereferenceable(132) %9)
  br i1 %40, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %39, %.loopexit
  %41 = load ptr, ptr %25, align 8, !tbaa !27
  %42 = call noundef i32 @_ZN7Riemann11StaticStackIjLi32EE3popEv(ptr noundef nonnull align 4 dereferenceable(132) %9)
  %.not86102 = icmp eq ptr %41, null
  br i1 %.not86102, label %.loopexit, label %.lr.ph104

.lr.ph104:                                        ; preds = %.lr.ph
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %41, i64 %43
  br label %45

45:                                               ; preds = %.lr.ph104, %.backedge
  %.075103 = phi ptr [ %44, %.lr.ph104 ], [ %.075.be, %.backedge ]
  %46 = call noundef zeroext i1 @_ZNK7Riemann21CacheFriendlyAABBTree6IsLeafEv(ptr noundef nonnull align 4 dereferenceable(28) %.075103)
  br i1 %46, label %47, label %60

47:                                               ; preds = %45
  %48 = load ptr, ptr %0, align 8, !tbaa !31
  %49 = call noundef ptr @_ZNK7Riemann21CacheFriendlyAABBTree18GetGeometryIndicesEPi(ptr noundef nonnull align 4 dereferenceable(28) %.075103, ptr noundef %48)
  %50 = call noundef i32 @_ZNK7Riemann21CacheFriendlyAABBTree16GetNumGeometriesEv(ptr noundef nonnull align 4 dereferenceable(28) %.075103)
  %51 = call noundef nonnull align 4 dereferenceable(24) ptr @_ZNK7Riemann21CacheFriendlyAABBTree17GetBoundingVolumeEv(ptr noundef nonnull align 4 dereferenceable(28) %.075103)
  %52 = call noundef i32 @_ZN7RiemannL22RayIntersectGeometriesERK4Ray3PiiPPNS_8GeometryERKN5Maths6TAABB3IfEEPKNS_13RayCastOptionEPNS_13RayCastResultE(ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef %49, i32 noundef %50, ptr noundef %2, ptr noundef nonnull align 4 dereferenceable(24) %51, ptr noundef %3, ptr noundef nonnull %4)
  %53 = icmp sgt i32 %52, -1
  br i1 %53, label %54, label %.loopexit

54:                                               ; preds = %47
  %55 = load i32, ptr %3, align 8, !tbaa !21
  %56 = icmp eq i32 %55, 1
  br i1 %56, label %.critedge, label %.loopexit

.critedge:                                        ; preds = %54
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #5
  %57 = load float, ptr %13, align 8, !tbaa !19
  call void @_ZNK4Ray37PointAtEf(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector3") align 4 %10, ptr noundef nonnull align 4 dereferenceable(24) %1, float noundef %57)
  %58 = getelementptr inbounds i8, ptr %4, i64 12
  %59 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %58, ptr noundef nonnull align 4 dereferenceable(12) %10)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #5
  br label %118

60:                                               ; preds = %45
  %61 = load ptr, ptr %25, align 8, !tbaa !27
  %62 = call noundef ptr @_ZN7Riemann21CacheFriendlyAABBTree11GetLeftNodeEPS0_(ptr noundef nonnull align 4 dereferenceable(28) %.075103, ptr noundef %61)
  %63 = load ptr, ptr %25, align 8, !tbaa !27
  %64 = call noundef ptr @_ZN7Riemann21CacheFriendlyAABBTree12GetRightNodeEPS0_(ptr noundef nonnull align 4 dereferenceable(28) %.075103, ptr noundef %63)
  call void @_ZN7Riemann13RayCastResult12AddTestCountEi(ptr noundef nonnull align 8 dereferenceable(76) %4, i32 noundef 2)
  %.not87 = icmp eq ptr %62, null
  br i1 %.not87, label %68, label %65

65:                                               ; preds = %60
  %66 = getelementptr inbounds i8, ptr %62, i64 12
  %67 = call noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef nonnull align 4 dereferenceable(12) %62, ptr noundef nonnull align 4 dereferenceable(12) %66, ptr noundef nonnull %7)
  br label %68

68:                                               ; preds = %65, %60
  %69 = phi i1 [ false, %60 ], [ %67, %65 ]
  %.not88 = icmp eq ptr %64, null
  br i1 %.not88, label %73, label %70

70:                                               ; preds = %68
  %71 = getelementptr inbounds i8, ptr %64, i64 12
  %72 = call noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef nonnull align 4 dereferenceable(12) %64, ptr noundef nonnull align 4 dereferenceable(12) %71, ptr noundef nonnull %8)
  br label %73

73:                                               ; preds = %70, %68
  %74 = phi i1 [ false, %68 ], [ %72, %70 ]
  %75 = load i32, ptr %3, align 8, !tbaa !21
  %.not89 = icmp eq i32 %75, 2
  br i1 %.not89, label %93, label %76

76:                                               ; preds = %73
  br i1 %69, label %77, label %84

77:                                               ; preds = %76
  %78 = load float, ptr %7, align 4, !tbaa !29
  %79 = load float, ptr %13, align 8, !tbaa !19
  %80 = fcmp olt float %78, %79
  br i1 %80, label %81, label %84

81:                                               ; preds = %77
  %82 = load float, ptr %33, align 4, !tbaa !30
  %83 = fcmp olt float %78, %82
  br label %84

84:                                               ; preds = %81, %77, %76
  %85 = phi i1 [ false, %77 ], [ false, %76 ], [ %83, %81 ]
  br i1 %74, label %86, label %93

86:                                               ; preds = %84
  %87 = load float, ptr %8, align 4, !tbaa !29
  %88 = load float, ptr %13, align 8, !tbaa !19
  %89 = fcmp olt float %87, %88
  br i1 %89, label %90, label %93

90:                                               ; preds = %86
  %91 = load float, ptr %33, align 4, !tbaa !30
  %92 = fcmp olt float %87, %91
  br label %93

93:                                               ; preds = %84, %86, %90, %73
  %.073.in = phi i1 [ %69, %73 ], [ %85, %90 ], [ %85, %86 ], [ %85, %84 ]
  %.0.in = phi i1 [ %74, %73 ], [ %92, %90 ], [ false, %86 ], [ false, %84 ]
  %94 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE4fullEv(ptr noundef nonnull align 4 dereferenceable(132) %9)
  br i1 %94, label %95, label %96

95:                                               ; preds = %93
  call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 304, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK7Riemann8AABBTree7RayCastERK4Ray3PPNS_8GeometryEPKNS_13RayCastOptionEPNS_13RayCastResultE) #6
  unreachable

96:                                               ; preds = %93
  %97 = select i1 %.073.in, i1 %.0.in, i1 false
  br i1 %97, label %.backedge.sink.split, label %107

.backedge.sink.split:                             ; preds = %96
  %98 = load float, ptr %7, align 4, !tbaa !29
  %99 = load float, ptr %8, align 4, !tbaa !29
  %100 = fcmp olt float %98, %99
  %101 = load ptr, ptr %25, align 8, !tbaa !27
  %102 = ptrtoint ptr %101 to i64
  %. = select i1 %100, ptr %64, ptr %62
  %.99 = select i1 %100, ptr %62, ptr %64
  %103 = ptrtoint ptr %. to i64
  %104 = sub i64 %103, %102
  %105 = sdiv exact i64 %104, 28
  %106 = trunc i64 %105 to i32
  call void @_ZN7Riemann11StaticStackIjLi32EE4pushEj(ptr noundef nonnull align 4 dereferenceable(132) %9, i32 noundef %106)
  br label %.backedge

107:                                              ; preds = %96
  %..075 = select i1 %.0.in, ptr %64, ptr %.075103
  %spec.select = select i1 %.073.in, i1 true, i1 %.0.in
  %spec.select90 = select i1 %.073.in, ptr %62, ptr %..075
  br i1 %spec.select, label %.backedge, label %.loopexit

.backedge:                                        ; preds = %.backedge.sink.split, %107
  %.075.be = phi ptr [ %spec.select90, %107 ], [ %.99, %.backedge.sink.split ]
  %.not86 = icmp eq ptr %.075.be, null
  br i1 %.not86, label %.loopexit, label %45

.loopexit:                                        ; preds = %.backedge, %107, %.lr.ph, %54, %47
  %108 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE5emptyEv(ptr noundef nonnull align 4 dereferenceable(132) %9)
  br i1 %108, label %._crit_edge, label %.lr.ph, !llvm.loop !32

._crit_edge:                                      ; preds = %.loopexit, %39
  %109 = load i8, ptr %4, align 8, !tbaa !5, !range !34, !noundef !35
  %110 = trunc nuw i8 %109 to i1
  br i1 %110, label %114, label %111

111:                                              ; preds = %._crit_edge
  %112 = getelementptr inbounds i8, ptr %4, i64 48
  %113 = call noundef i64 @_ZNKSt6vectorIPN7Riemann8GeometryESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %112) #5
  %.not = icmp eq i64 %113, 0
  br i1 %.not, label %118, label %114

114:                                              ; preds = %111, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %11) #5
  %115 = load float, ptr %13, align 8, !tbaa !19
  call void @_ZNK4Ray37PointAtEf(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector3") align 4 %11, ptr noundef nonnull align 4 dereferenceable(24) %1, float noundef %115)
  %116 = getelementptr inbounds i8, ptr %4, i64 12
  %117 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %116, ptr noundef nonnull align 4 dereferenceable(12) %11)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %11) #5
  br label %118

118:                                              ; preds = %111, %.critedge, %114
  %.3 = phi i1 [ true, %114 ], [ true, %.critedge ], [ false, %111 ]
  call void @llvm.lifetime.end.p0(i64 132, ptr nonnull %9) #5
  br label %119

119:                                              ; preds = %24, %28, %31, %118
  %.4 = phi i1 [ %.3, %118 ], [ false, %31 ], [ false, %28 ], [ false, %24 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  br label %120

120:                                              ; preds = %119, %18
  %.5 = phi i1 [ true, %18 ], [ %.4, %119 ]
  ret i1 %.5
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4Ray37PointAtEf(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4, ptr noundef nonnull align 4 dereferenceable(24), float noundef) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIPN7Riemann8GeometryESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(24) ptr @_ZNK7Riemann21CacheFriendlyAABBTree17GetBoundingVolumeEv(ptr noundef nonnull align 4 dereferenceable(28)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN7RiemannL22RayIntersectGeometriesERK4Ray3PiiPPNS_8GeometryERKN5Maths6TAABB3IfEEPKNS_13RayCastOptionEPNS_13RayCastResultE(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef, i32 noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(24), ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann13RayCastResult12AddTestCountEi(ptr noundef nonnull align 8 dereferenceable(76), i32 noundef) local_unnamed_addr #2 align 2

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

attributes #0 = { noreturn 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 #4 = { 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 }
attributes #6 = { noreturn 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 = !{!"_ZTSN7Riemann13RayCastResultE", !7, i64 0, !10, i64 4, !10, i64 8, !11, i64 12, !11, i64 24, !12, i64 40, !13, i64 48, !17, i64 72}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"_ZTSN5Maths8TVector3IfEE", !10, i64 0, !10, i64 4, !10, i64 8}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"_ZTSSt6vectorIPN7Riemann8GeometryESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIPN7Riemann8GeometryESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIPN7Riemann8GeometryESaIS2_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIPN7Riemann8GeometryESaIS2_EE17_Vector_impl_dataE", !12, i64 0, !12, i64 8, !12, i64 16}
!17 = !{!"int", !8, i64 0}
!18 = !{!6, !17, i64 72}
!19 = !{!6, !10, i64 8}
!20 = !{!6, !12, i64 40}
!21 = !{!22, !23, i64 0}
!22 = !{!"_ZTSN7Riemann13RayCastOptionE", !23, i64 0, !24, i64 8, !7, i64 152, !10, i64 156, !17, i64 160, !26, i64 164, !12, i64 184}
!23 = !{!"_ZTSN7Riemann13RayCastOption11RayCastTypeE", !8, i64 0}
!24 = !{!"_ZTSN7Riemann12RayCastCacheE", !12, i64 0, !25, i64 8}
!25 = !{!"_ZTSN7Riemann11StaticStackIjLi32EEE", !17, i64 0, !8, i64 4}
!26 = !{!"_ZTSN7Riemann13CollisionDataE", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12}
!27 = !{!28, !12, i64 16}
!28 = !{!"_ZTSN7Riemann8AABBTreeE", !12, i64 0, !17, i64 8, !12, i64 16}
!29 = !{!10, !10, i64 0}
!30 = !{!22, !10, i64 156}
!31 = !{!28, !12, i64 0}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}
!34 = !{i8 0, i8 2}
!35 = !{}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass