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

; 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.Riemann::StaticStack.5" = type { i32, [32 x i32] }
%"class.Maths::TVector3" = type { float, float, float }
%"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 }
%"class.Riemann::DynamicAABBTree" = type <{ i32, [4 x i8], %"class.std::vector", i32, i32, i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Riemann::DynamicAABBTree::Node, std::allocator<Riemann::DynamicAABBTree::Node>>::_Vector_impl" }
%"struct.std::_Vector_base<Riemann::DynamicAABBTree::Node, std::allocator<Riemann::DynamicAABBTree::Node>>::_Vector_impl" = type { %"struct.std::_Vector_base<Riemann::DynamicAABBTree::Node, std::allocator<Riemann::DynamicAABBTree::Node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Riemann::DynamicAABBTree::Node, std::allocator<Riemann::DynamicAABBTree::Node>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.Riemann::DynamicAABBTree::Node" = type <{ %union.anon, %"class.Maths::TAABB3", i32, i32, i32, ptr, i8, [7 x i8] }>
%union.anon = type { i32 }
%"class.Maths::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }
%"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] }>
%"class.Riemann::StaticStack" = type { i32, [32 x i32] }
%"struct.Riemann::CollisionData" = type { i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [35 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [89 x i8], align 1
@__PRETTY_FUNCTION__._ZNK7Riemann15DynamicAABBTree7RayCastERK4Ray3PKNS_13RayCastOptionEPNS_13RayCastResultE = external hidden unnamed_addr constant [99 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK7Riemann15DynamicAABBTree7RayCastERK4Ray3PKNS_13RayCastOptionEPNS_13RayCastResultE(ptr noundef nonnull align 8 dereferenceable(44) %0, ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef %2, ptr noundef %3) #1 align 2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca %"class.Riemann::StaticStack.5", align 4
  %15 = alloca %"class.Maths::TVector3", align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i8, align 1
  %19 = alloca i8, align 1
  %20 = alloca %"class.Maths::TVector3", 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
  %21 = load ptr, ptr %6, align 8
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %22, i32 0, i32 0
  store i8 0, ptr %23, align 8, !tbaa !9
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %24, i32 0, i32 9
  store i32 0, ptr %25, align 8, !tbaa !19
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %26, i32 0, i32 3
  store float 0x47EFFFFFE0000000, ptr %27, align 8, !tbaa !20
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %28, i32 0, i32 7
  store ptr null, ptr %29, align 8, !tbaa !21
  %30 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %21, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !22
  %32 = icmp eq i32 %31, -1
  br i1 %32, label %33, label %34

33:                                               ; preds = %4
  store i1 false, ptr %5, align 1
  br label %248

34:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %35 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %21, i32 0, i32 2
  %36 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %21, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !22
  %38 = sext i32 %37 to i64
  %39 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNKSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %35, i64 noundef %38) #5
  store ptr %39, ptr %12, align 8, !tbaa !5
  %40 = load ptr, ptr %12, align 8, !tbaa !5
  %41 = icmp eq ptr %40, null
  br i1 %41, label %57, label %42

42:                                               ; preds = %34
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %44, i32 0, i32 1
  %46 = getelementptr inbounds %"class.Maths::TAABB3", ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %47, i32 0, i32 1
  %49 = getelementptr inbounds %"class.Maths::TAABB3", ptr %48, i32 0, i32 1
  %50 = call noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24) %43, ptr noundef nonnull align 4 dereferenceable(12) %46, ptr noundef nonnull align 4 dereferenceable(12) %49, ptr noundef %10)
  br i1 %50, label %51, label %57

51:                                               ; preds = %42
  %52 = load float, ptr %10, align 4, !tbaa !28
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.Riemann::RayCastOption", ptr %53, i32 0, i32 4
  %55 = load float, ptr %54, align 4, !tbaa !29
  %56 = fcmp oge float %52, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %51, %42, %34
  store i1 false, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %247

58:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 132, ptr %14) #5
  call void @_ZN7Riemann11StaticStackIiLi32EEC2Ev(ptr noundef nonnull align 4 dereferenceable(132) %14)
  %59 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %21, i32 0, i32 0
  %60 = load i32, ptr %59, align 8, !tbaa !22
  call void @_ZN7Riemann11StaticStackIiLi32EE4pushEi(ptr noundef nonnull align 4 dereferenceable(132) %14, i32 noundef %60)
  br label %61

61:                                               ; preds = %226, %58
  %62 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIiLi32EE5emptyEv(ptr noundef nonnull align 4 dereferenceable(132) %14)
  %63 = xor i1 %62, true
  br i1 %63, label %64, label %227

64:                                               ; preds = %61
  %65 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %21, i32 0, i32 2
  %66 = call noundef i32 @_ZN7Riemann11StaticStackIiLi32EE3popEv(ptr noundef nonnull align 4 dereferenceable(132) %14)
  %67 = sext i32 %66 to i64
  %68 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNKSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %65, i64 noundef %67) #5
  store ptr %68, ptr %12, align 8, !tbaa !5
  br label %69

69:                                               ; preds = %224, %64
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %226

72:                                               ; preds = %69
  %73 = load ptr, ptr %12, align 8, !tbaa !5
  %74 = call noundef zeroext i1 @_ZNK7Riemann15DynamicAABBTree4Node6IsLeafEv(ptr noundef nonnull align 8 dereferenceable(49) %73)
  br i1 %74, label %75, label %98

75:                                               ; preds = %72
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %77, i32 0, i32 5
  %79 = load ptr, ptr %78, align 8, !tbaa !35
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = call noundef zeroext i1 @_ZN7RiemannL20RayIntersectGeometryERK4Ray3PvPKNS_13RayCastOptionEPNS_13RayCastResultE(ptr noundef nonnull align 4 dereferenceable(24) %76, ptr noundef %79, ptr noundef %80, ptr noundef %81)
  br i1 %82, label %83, label %97

83:                                               ; preds = %75
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = getelementptr inbounds %"struct.Riemann::RayCastOption", ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 8, !tbaa !38
  %87 = icmp eq i32 %86, 1
  br i1 %87, label %88, label %96

88:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 12, ptr %15) #5
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %90, i32 0, i32 3
  %92 = load float, ptr %91, align 8, !tbaa !20
  call void @_ZNK4Ray37PointAtEf(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %15, ptr noundef nonnull align 4 dereferenceable(24) %89, float noundef %92)
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  %94 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %93, i32 0, i32 4
  %95 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %94, ptr noundef nonnull align 4 dereferenceable(12) %15)
  call void @llvm.lifetime.end.p0(i64 12, ptr %15) #5
  store i1 true, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %246

96:                                               ; preds = %83
  br label %97

97:                                               ; preds = %96, %75
  br label %226

98:                                               ; preds = %72
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %99, i32 0, i32 2
  %101 = load i32, ptr %100, align 4, !tbaa !39
  %102 = icmp ne i32 %101, -1
  br i1 %102, label %103, label %108

103:                                              ; preds = %98
  %104 = load ptr, ptr %12, align 8, !tbaa !5
  %105 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %104, i32 0, i32 3
  %106 = load i32, ptr %105, align 8, !tbaa !40
  %107 = icmp ne i32 %106, -1
  br label %108

108:                                              ; preds = %103, %98
  %109 = phi i1 [ false, %98 ], [ %107, %103 ]
  br i1 %109, label %110, label %111

110:                                              ; preds = %108
  br label %113

111:                                              ; preds = %108
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 94, ptr noundef @__PRETTY_FUNCTION__._ZNK7Riemann15DynamicAABBTree7RayCastERK4Ray3PKNS_13RayCastOptionEPNS_13RayCastResultE) #6
  unreachable

112:                                              ; No predecessors!
  br label %113

113:                                              ; preds = %112, %110
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %114 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %21, i32 0, i32 2
  %115 = load ptr, ptr %12, align 8, !tbaa !5
  %116 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %115, i32 0, i32 2
  %117 = load i32, ptr %116, align 4, !tbaa !39
  %118 = sext i32 %117 to i64
  %119 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNKSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %114, i64 noundef %118) #5
  store ptr %119, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %120 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %21, i32 0, i32 2
  %121 = load ptr, ptr %12, align 8, !tbaa !5
  %122 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %121, i32 0, i32 3
  %123 = load i32, ptr %122, align 8, !tbaa !40
  %124 = sext i32 %123 to i64
  %125 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNKSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %120, i64 noundef %124) #5
  store ptr %125, ptr %17, align 8, !tbaa !5
  %126 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN7Riemann13RayCastResult12AddTestCountEi(ptr noundef nonnull align 8 dereferenceable(76) %126, i32 noundef 2)
  call void @llvm.lifetime.start.p0(i64 1, ptr %18) #5
  %127 = load ptr, ptr %7, align 8, !tbaa !5
  %128 = load ptr, ptr %16, align 8, !tbaa !5
  %129 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %128, i32 0, i32 1
  %130 = getelementptr inbounds %"class.Maths::TAABB3", ptr %129, i32 0, i32 0
  %131 = load ptr, ptr %16, align 8, !tbaa !5
  %132 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %131, i32 0, i32 1
  %133 = getelementptr inbounds %"class.Maths::TAABB3", ptr %132, i32 0, i32 1
  %134 = call noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24) %127, ptr noundef nonnull align 4 dereferenceable(12) %130, ptr noundef nonnull align 4 dereferenceable(12) %133, ptr noundef %10)
  %135 = zext i1 %134 to i8
  store i8 %135, ptr %18, align 1, !tbaa !41
  call void @llvm.lifetime.start.p0(i64 1, ptr %19) #5
  %136 = load ptr, ptr %7, align 8, !tbaa !5
  %137 = load ptr, ptr %17, align 8, !tbaa !5
  %138 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %137, i32 0, i32 1
  %139 = getelementptr inbounds %"class.Maths::TAABB3", ptr %138, i32 0, i32 0
  %140 = load ptr, ptr %17, align 8, !tbaa !5
  %141 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %140, i32 0, i32 1
  %142 = getelementptr inbounds %"class.Maths::TAABB3", ptr %141, i32 0, i32 1
  %143 = call noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24) %136, ptr noundef nonnull align 4 dereferenceable(12) %139, ptr noundef nonnull align 4 dereferenceable(12) %142, ptr noundef %11)
  %144 = zext i1 %143 to i8
  store i8 %144, ptr %19, align 1, !tbaa !41
  %145 = load ptr, ptr %8, align 8, !tbaa !5
  %146 = getelementptr inbounds %"struct.Riemann::RayCastOption", ptr %145, i32 0, i32 0
  %147 = load i32, ptr %146, align 8, !tbaa !38
  %148 = icmp ne i32 %147, 2
  br i1 %148, label %149, label %184

149:                                              ; preds = %113
  %150 = load i8, ptr %18, align 1, !tbaa !41, !range !42, !noundef !43
  %151 = trunc i8 %150 to i1
  br i1 %151, label %152, label %164

152:                                              ; preds = %149
  %153 = load float, ptr %10, align 4, !tbaa !28
  %154 = load ptr, ptr %9, align 8, !tbaa !5
  %155 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %154, i32 0, i32 3
  %156 = load float, ptr %155, align 8, !tbaa !20
  %157 = fcmp olt float %153, %156
  br i1 %157, label %158, label %164

158:                                              ; preds = %152
  %159 = load float, ptr %10, align 4, !tbaa !28
  %160 = load ptr, ptr %8, align 8, !tbaa !5
  %161 = getelementptr inbounds %"struct.Riemann::RayCastOption", ptr %160, i32 0, i32 4
  %162 = load float, ptr %161, align 4, !tbaa !29
  %163 = fcmp olt float %159, %162
  br label %164

164:                                              ; preds = %158, %152, %149
  %165 = phi i1 [ false, %152 ], [ false, %149 ], [ %163, %158 ]
  %166 = zext i1 %165 to i8
  store i8 %166, ptr %18, align 1, !tbaa !41
  %167 = load i8, ptr %19, align 1, !tbaa !41, !range !42, !noundef !43
  %168 = trunc i8 %167 to i1
  br i1 %168, label %169, label %181

169:                                              ; preds = %164
  %170 = load float, ptr %11, align 4, !tbaa !28
  %171 = load ptr, ptr %9, align 8, !tbaa !5
  %172 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %171, i32 0, i32 3
  %173 = load float, ptr %172, align 8, !tbaa !20
  %174 = fcmp olt float %170, %173
  br i1 %174, label %175, label %181

175:                                              ; preds = %169
  %176 = load float, ptr %11, align 4, !tbaa !28
  %177 = load ptr, ptr %8, align 8, !tbaa !5
  %178 = getelementptr inbounds %"struct.Riemann::RayCastOption", ptr %177, i32 0, i32 4
  %179 = load float, ptr %178, align 4, !tbaa !29
  %180 = fcmp olt float %176, %179
  br label %181

181:                                              ; preds = %175, %169, %164
  %182 = phi i1 [ false, %169 ], [ false, %164 ], [ %180, %175 ]
  %183 = zext i1 %182 to i8
  store i8 %183, ptr %19, align 1, !tbaa !41
  br label %184

184:                                              ; preds = %181, %113
  %185 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIiLi32EE4fullEv(ptr noundef nonnull align 4 dereferenceable(132) %14)
  %186 = xor i1 %185, true
  br i1 %186, label %187, label %188

187:                                              ; preds = %184
  br label %190

188:                                              ; preds = %184
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 109, ptr noundef @__PRETTY_FUNCTION__._ZNK7Riemann15DynamicAABBTree7RayCastERK4Ray3PKNS_13RayCastOptionEPNS_13RayCastResultE) #6
  unreachable

189:                                              ; No predecessors!
  br label %190

190:                                              ; preds = %189, %187
  %191 = load i8, ptr %18, align 1, !tbaa !41, !range !42, !noundef !43
  %192 = trunc i8 %191 to i1
  br i1 %192, label %193, label %211

193:                                              ; preds = %190
  %194 = load i8, ptr %19, align 1, !tbaa !41, !range !42, !noundef !43
  %195 = trunc i8 %194 to i1
  br i1 %195, label %196, label %211

196:                                              ; preds = %193
  %197 = load float, ptr %10, align 4, !tbaa !28
  %198 = load float, ptr %11, align 4, !tbaa !28
  %199 = fcmp olt float %197, %198
  br i1 %199, label %200, label %205

200:                                              ; preds = %196
  %201 = load ptr, ptr %12, align 8, !tbaa !5
  %202 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %201, i32 0, i32 3
  %203 = load i32, ptr %202, align 8, !tbaa !40
  call void @_ZN7Riemann11StaticStackIiLi32EE4pushEi(ptr noundef nonnull align 4 dereferenceable(132) %14, i32 noundef %203)
  %204 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %204, ptr %12, align 8, !tbaa !5
  br label %210

205:                                              ; preds = %196
  %206 = load ptr, ptr %12, align 8, !tbaa !5
  %207 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %206, i32 0, i32 2
  %208 = load i32, ptr %207, align 4, !tbaa !39
  call void @_ZN7Riemann11StaticStackIiLi32EE4pushEi(ptr noundef nonnull align 4 dereferenceable(132) %14, i32 noundef %208)
  %209 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %209, ptr %12, align 8, !tbaa !5
  br label %210

210:                                              ; preds = %205, %200
  store i32 4, ptr %13, align 4
  br label %224, !llvm.loop !44

211:                                              ; preds = %193, %190
  %212 = load i8, ptr %18, align 1, !tbaa !41, !range !42, !noundef !43
  %213 = trunc i8 %212 to i1
  br i1 %213, label %214, label %216

214:                                              ; preds = %211
  %215 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %215, ptr %12, align 8, !tbaa !5
  store i32 4, ptr %13, align 4
  br label %224, !llvm.loop !44

216:                                              ; preds = %211
  %217 = load i8, ptr %19, align 1, !tbaa !41, !range !42, !noundef !43
  %218 = trunc i8 %217 to i1
  br i1 %218, label %219, label %221

219:                                              ; preds = %216
  %220 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %220, ptr %12, align 8, !tbaa !5
  store i32 4, ptr %13, align 4
  br label %224, !llvm.loop !44

221:                                              ; preds = %216
  br label %222

222:                                              ; preds = %221
  br label %223

223:                                              ; preds = %222
  store i32 5, ptr %13, align 4
  br label %224

224:                                              ; preds = %223, %219, %214, %210
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %225 = load i32, ptr %13, align 4
  switch i32 %225, label %250 [
    i32 4, label %69
    i32 5, label %226
  ]

226:                                              ; preds = %224, %97, %69
  br label %61, !llvm.loop !46

227:                                              ; preds = %61
  %228 = load ptr, ptr %9, align 8, !tbaa !5
  %229 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %228, i32 0, i32 0
  %230 = load i8, ptr %229, align 8, !tbaa !9, !range !42, !noundef !43
  %231 = trunc i8 %230 to i1
  br i1 %231, label %237, label %232

232:                                              ; preds = %227
  %233 = load ptr, ptr %9, align 8, !tbaa !5
  %234 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %233, i32 0, i32 8
  %235 = call noundef i64 @_ZNKSt6vectorIPN7Riemann8GeometryESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %234) #5
  %236 = icmp ugt i64 %235, 0
  br i1 %236, label %237, label %245

237:                                              ; preds = %232, %227
  call void @llvm.lifetime.start.p0(i64 12, ptr %20) #5
  %238 = load ptr, ptr %7, align 8, !tbaa !5
  %239 = load ptr, ptr %9, align 8, !tbaa !5
  %240 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %239, i32 0, i32 3
  %241 = load float, ptr %240, align 8, !tbaa !20
  call void @_ZNK4Ray37PointAtEf(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %20, ptr noundef nonnull align 4 dereferenceable(24) %238, float noundef %241)
  %242 = load ptr, ptr %9, align 8, !tbaa !5
  %243 = getelementptr inbounds %"struct.Riemann::RayCastResult", ptr %242, i32 0, i32 4
  %244 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %243, ptr noundef nonnull align 4 dereferenceable(12) %20)
  call void @llvm.lifetime.end.p0(i64 12, ptr %20) #5
  store i1 true, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %246

245:                                              ; preds = %232
  store i1 false, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %246

246:                                              ; preds = %245, %237, %88
  call void @llvm.lifetime.end.p0(i64 132, ptr %14) #5
  br label %247

247:                                              ; preds = %246, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %248

248:                                              ; preds = %247, %33
  %249 = load i1, ptr %5, align 1
  ret i1 %249

250:                                              ; preds = %224
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(49) ptr @_ZNKSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 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) #1 align 2

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7Riemann15DynamicAABBTree4Node6IsLeafEv(ptr noundef nonnull align 8 dereferenceable(49)) #3 align 2

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

; 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) #1 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 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 zeroext i1 @_ZNK7Riemann11StaticStackIiLi32EE4fullEv(ptr noundef nonnull align 4 dereferenceable(132)) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #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, !18, i64 0}
!23 = !{!"_ZTSN7Riemann15DynamicAABBTreeE", !18, i64 0, !24, i64 8, !18, i64 32, !18, i64 36, !18, i64 40}
!24 = !{!"_ZTSSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseIN7Riemann15DynamicAABBTree4NodeESaIS2_EE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15DynamicAABBTree4NodeESaIS2_EE12_Vector_implE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15DynamicAABBTree4NodeESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!28 = !{!12, !12, i64 0}
!29 = !{!30, !12, i64 156}
!30 = !{!"_ZTSN7Riemann13RayCastOptionE", !31, i64 0, !32, i64 8, !11, i64 152, !12, i64 156, !18, i64 160, !34, i64 164, !6, i64 184}
!31 = !{!"_ZTSN7Riemann13RayCastOption11RayCastTypeE", !7, i64 0}
!32 = !{!"_ZTSN7Riemann12RayCastCacheE", !6, i64 0, !33, i64 8}
!33 = !{!"_ZTSN7Riemann11StaticStackIjLi32EEE", !18, i64 0, !7, i64 4}
!34 = !{!"_ZTSN7Riemann13CollisionDataE", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12}
!35 = !{!36, !6, i64 40}
!36 = !{!"_ZTSN7Riemann15DynamicAABBTree4NodeE", !7, i64 0, !37, i64 4, !18, i64 28, !18, i64 32, !18, i64 36, !6, i64 40, !11, i64 48}
!37 = !{!"_ZTSN5Maths6TAABB3IfEE", !13, i64 0, !13, i64 12}
!38 = !{!30, !31, i64 0}
!39 = !{!36, !18, i64 28}
!40 = !{!36, !18, i64 32}
!41 = !{!11, !11, i64 0}
!42 = !{i8 0, i8 2}
!43 = !{}
!44 = distinct !{!44, !45}
!45 = !{!"llvm.loop.mustprogress"}
!46 = distinct !{!46, !45}


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

@.str = external hidden unnamed_addr constant [35 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [89 x i8], align 1
@__PRETTY_FUNCTION__._ZNK7Riemann15DynamicAABBTree7RayCastERK4Ray3PKNS_13RayCastOptionEPNS_13RayCastResultE = external hidden unnamed_addr constant [99 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

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

15:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = sext i32 %13 to i64
  %18 = tail call noundef nonnull align 8 dereferenceable(49) ptr @_ZNKSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %17) #5
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  %20 = getelementptr inbounds i8, ptr %18, i64 16
  %21 = call noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef nonnull align 4 dereferenceable(12) %19, ptr noundef nonnull align 4 dereferenceable(12) %20, ptr noundef nonnull %5)
  br i1 %21, label %22, label %100

22:                                               ; preds = %15
  %23 = load float, ptr %5, align 4, !tbaa !27
  %24 = getelementptr inbounds i8, ptr %2, i64 156
  %25 = load float, ptr %24, align 4, !tbaa !28
  %26 = fcmp ult float %23, %25
  br i1 %26, label %27, label %100

27:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 132, ptr nonnull %7) #5
  call void @_ZN7Riemann11StaticStackIiLi32EEC2Ev(ptr noundef nonnull align 4 dereferenceable(132) %7)
  %28 = load i32, ptr %0, align 8, !tbaa !21
  call void @_ZN7Riemann11StaticStackIiLi32EE4pushEi(ptr noundef nonnull align 4 dereferenceable(132) %7, i32 noundef %28)
  %29 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIiLi32EE5emptyEv(ptr noundef nonnull align 4 dereferenceable(132) %7)
  br i1 %29, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %27, %.loopexit
  %30 = call noundef i32 @_ZN7Riemann11StaticStackIiLi32EE3popEv(ptr noundef nonnull align 4 dereferenceable(132) %7)
  %31 = sext i32 %30 to i64
  %32 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNKSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %31) #5
  %33 = call noundef zeroext i1 @_ZNK7Riemann15DynamicAABBTree4Node6IsLeafEv(ptr noundef nonnull align 8 dereferenceable(49) %32)
  br i1 %33, label %._crit_edge81, label %.lr.ph80

._crit_edge81:                                    ; preds = %.backedge, %.lr.ph
  %.056.lcssa = phi ptr [ %32, %.lr.ph ], [ %.056.be, %.backedge ]
  %34 = getelementptr inbounds i8, ptr %.056.lcssa, i64 40
  %35 = load ptr, ptr %34, align 8, !tbaa !34
  %36 = call noundef zeroext i1 @_ZN7RiemannL20RayIntersectGeometryERK4Ray3PvPKNS_13RayCastOptionEPNS_13RayCastResultE(ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef %35, ptr noundef %2, ptr noundef nonnull %3)
  br i1 %36, label %37, label %.loopexit

37:                                               ; preds = %._crit_edge81
  %38 = load i32, ptr %2, align 8, !tbaa !37
  %39 = icmp eq i32 %38, 1
  br i1 %39, label %40, label %.loopexit

40:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %8) #5
  %41 = load float, ptr %11, align 8, !tbaa !19
  call void @_ZNK4Ray37PointAtEf(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector3") align 4 %8, ptr noundef nonnull align 4 dereferenceable(24) %1, float noundef %41)
  %42 = getelementptr inbounds i8, ptr %3, i64 12
  %43 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %42, ptr noundef nonnull align 4 dereferenceable(12) %8)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %8) #5
  br label %99

.lr.ph80:                                         ; preds = %.lr.ph, %.backedge
  %.05679 = phi ptr [ %.056.be, %.backedge ], [ %32, %.lr.ph ]
  %44 = getelementptr inbounds i8, ptr %.05679, i64 28
  %45 = load i32, ptr %44, align 4, !tbaa !38
  %.not63 = icmp eq i32 %45, -1
  br i1 %.not63, label %.critedge, label %46

46:                                               ; preds = %.lr.ph80
  %47 = getelementptr inbounds i8, ptr %.05679, i64 32
  %48 = load i32, ptr %47, align 8, !tbaa !39
  %.not64 = icmp eq i32 %48, -1
  br i1 %.not64, label %.critedge, label %49

.critedge:                                        ; preds = %.lr.ph80, %46
  call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 94, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK7Riemann15DynamicAABBTree7RayCastERK4Ray3PKNS_13RayCastOptionEPNS_13RayCastResultE) #6
  unreachable

49:                                               ; preds = %46
  %50 = sext i32 %45 to i64
  %51 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNKSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %50) #5
  %52 = load i32, ptr %47, align 8, !tbaa !39
  %53 = sext i32 %52 to i64
  %54 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNKSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %53) #5
  call void @_ZN7Riemann13RayCastResult12AddTestCountEi(ptr noundef nonnull align 8 dereferenceable(76) %3, i32 noundef 2)
  %55 = getelementptr inbounds i8, ptr %51, i64 4
  %56 = getelementptr inbounds i8, ptr %51, i64 16
  %57 = call noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef nonnull align 4 dereferenceable(12) %55, ptr noundef nonnull align 4 dereferenceable(12) %56, ptr noundef nonnull %5)
  %58 = getelementptr inbounds i8, ptr %54, i64 4
  %59 = getelementptr inbounds i8, ptr %54, i64 16
  %60 = call noundef zeroext i1 @_ZNK4Ray313IntersectAABBERKN5Maths8TVector3IfEES4_Pf(ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef nonnull align 4 dereferenceable(12) %58, ptr noundef nonnull align 4 dereferenceable(12) %59, ptr noundef nonnull %6)
  %61 = load i32, ptr %2, align 8, !tbaa !37
  %.not65 = icmp eq i32 %61, 2
  br i1 %.not65, label %79, label %62

62:                                               ; preds = %49
  br i1 %57, label %63, label %70

63:                                               ; preds = %62
  %64 = load float, ptr %5, align 4, !tbaa !27
  %65 = load float, ptr %11, align 8, !tbaa !19
  %66 = fcmp olt float %64, %65
  br i1 %66, label %67, label %70

67:                                               ; preds = %63
  %68 = load float, ptr %24, align 4, !tbaa !28
  %69 = fcmp olt float %64, %68
  br label %70

70:                                               ; preds = %67, %63, %62
  %71 = phi i1 [ false, %63 ], [ false, %62 ], [ %69, %67 ]
  br i1 %60, label %72, label %79

72:                                               ; preds = %70
  %73 = load float, ptr %6, align 4, !tbaa !27
  %74 = load float, ptr %11, align 8, !tbaa !19
  %75 = fcmp olt float %73, %74
  br i1 %75, label %76, label %79

76:                                               ; preds = %72
  %77 = load float, ptr %24, align 4, !tbaa !28
  %78 = fcmp olt float %73, %77
  br label %79

79:                                               ; preds = %70, %72, %76, %49
  %.054.in = phi i1 [ %57, %49 ], [ %71, %76 ], [ %71, %72 ], [ %71, %70 ]
  %.0.in = phi i1 [ %60, %49 ], [ %78, %76 ], [ false, %72 ], [ false, %70 ]
  %80 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIiLi32EE4fullEv(ptr noundef nonnull align 4 dereferenceable(132) %7)
  br i1 %80, label %81, label %82

81:                                               ; preds = %79
  call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 109, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK7Riemann15DynamicAABBTree7RayCastERK4Ray3PKNS_13RayCastOptionEPNS_13RayCastResultE) #6
  unreachable

82:                                               ; preds = %79
  %83 = select i1 %.054.in, i1 %.0.in, i1 false
  br i1 %83, label %.backedge.sink.split, label %87

.backedge.sink.split:                             ; preds = %82
  %84 = load float, ptr %5, align 4, !tbaa !27
  %85 = load float, ptr %6, align 4, !tbaa !27
  %86 = fcmp olt float %84, %85
  %. = select i1 %86, ptr %47, ptr %44
  %.82 = select i1 %86, ptr %51, ptr %54
  %.sink = load i32, ptr %., align 4, !tbaa !40
  call void @_ZN7Riemann11StaticStackIiLi32EE4pushEi(ptr noundef nonnull align 4 dereferenceable(132) %7, i32 noundef %.sink)
  br label %.backedge

87:                                               ; preds = %82
  %..056 = select i1 %.0.in, ptr %54, ptr %.05679
  %spec.select = select i1 %.054.in, i1 true, i1 %.0.in
  %spec.select66 = select i1 %.054.in, ptr %51, ptr %..056
  br i1 %spec.select, label %.backedge, label %.loopexit

.backedge:                                        ; preds = %.backedge.sink.split, %87
  %.056.be = phi ptr [ %spec.select66, %87 ], [ %.82, %.backedge.sink.split ]
  %88 = call noundef zeroext i1 @_ZNK7Riemann15DynamicAABBTree4Node6IsLeafEv(ptr noundef nonnull align 8 dereferenceable(49) %.056.be)
  br i1 %88, label %._crit_edge81, label %.lr.ph80

.loopexit:                                        ; preds = %87, %._crit_edge81, %37
  %89 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIiLi32EE5emptyEv(ptr noundef nonnull align 4 dereferenceable(132) %7)
  br i1 %89, label %._crit_edge, label %.lr.ph, !llvm.loop !41

._crit_edge:                                      ; preds = %.loopexit, %27
  %90 = load i8, ptr %3, align 8, !tbaa !5, !range !43, !noundef !44
  %91 = trunc nuw i8 %90 to i1
  br i1 %91, label %95, label %92

92:                                               ; preds = %._crit_edge
  %93 = getelementptr inbounds i8, ptr %3, i64 48
  %94 = call noundef i64 @_ZNKSt6vectorIPN7Riemann8GeometryESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %93) #5
  %.not = icmp eq i64 %94, 0
  br i1 %.not, label %99, label %95

95:                                               ; preds = %92, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #5
  %96 = load float, ptr %11, align 8, !tbaa !19
  call void @_ZNK4Ray37PointAtEf(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector3") align 4 %9, ptr noundef nonnull align 4 dereferenceable(24) %1, float noundef %96)
  %97 = getelementptr inbounds i8, ptr %3, i64 12
  %98 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %97, ptr noundef nonnull align 4 dereferenceable(12) %9)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #5
  br label %99

99:                                               ; preds = %92, %95, %40
  %.055 = phi i1 [ true, %40 ], [ true, %95 ], [ false, %92 ]
  call void @llvm.lifetime.end.p0(i64 132, ptr nonnull %7) #5
  br label %100

100:                                              ; preds = %15, %22, %99
  %.1 = phi i1 [ %.055, %99 ], [ false, %22 ], [ false, %15 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  br label %101

101:                                              ; preds = %4, %100
  %.2 = phi i1 [ %.1, %100 ], [ false, %4 ]
  ret i1 %.2
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(49) ptr @_ZNKSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 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 #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann11StaticStackIiLi32EE4pushEi(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 @_ZNK7Riemann11StaticStackIiLi32EE5emptyEv(ptr noundef nonnull align 4 dereferenceable(132)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7Riemann11StaticStackIiLi32EE3popEv(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 @_ZNK7Riemann15DynamicAABBTree4Node6IsLeafEv(ptr noundef nonnull align 8 dereferenceable(49)) local_unnamed_addr #3 align 2

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

; 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 #1 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 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 zeroext i1 @_ZNK7Riemann11StaticStackIiLi32EE4fullEv(ptr noundef nonnull align 4 dereferenceable(132)) 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #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, !17, i64 0}
!22 = !{!"_ZTSN7Riemann15DynamicAABBTreeE", !17, i64 0, !23, i64 8, !17, i64 32, !17, i64 36, !17, i64 40}
!23 = !{!"_ZTSSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EE", !24, i64 0}
!24 = !{!"_ZTSSt12_Vector_baseIN7Riemann15DynamicAABBTree4NodeESaIS2_EE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15DynamicAABBTree4NodeESaIS2_EE12_Vector_implE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15DynamicAABBTree4NodeESaIS2_EE17_Vector_impl_dataE", !12, i64 0, !12, i64 8, !12, i64 16}
!27 = !{!10, !10, i64 0}
!28 = !{!29, !10, i64 156}
!29 = !{!"_ZTSN7Riemann13RayCastOptionE", !30, i64 0, !31, i64 8, !7, i64 152, !10, i64 156, !17, i64 160, !33, i64 164, !12, i64 184}
!30 = !{!"_ZTSN7Riemann13RayCastOption11RayCastTypeE", !8, i64 0}
!31 = !{!"_ZTSN7Riemann12RayCastCacheE", !12, i64 0, !32, i64 8}
!32 = !{!"_ZTSN7Riemann11StaticStackIjLi32EEE", !17, i64 0, !8, i64 4}
!33 = !{!"_ZTSN7Riemann13CollisionDataE", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12}
!34 = !{!35, !12, i64 40}
!35 = !{!"_ZTSN7Riemann15DynamicAABBTree4NodeE", !8, i64 0, !36, i64 4, !17, i64 28, !17, i64 32, !17, i64 36, !12, i64 40, !7, i64 48}
!36 = !{!"_ZTSN5Maths6TAABB3IfEE", !11, i64 0, !11, i64 12}
!37 = !{!29, !30, i64 0}
!38 = !{!35, !17, i64 28}
!39 = !{!35, !17, i64 32}
!40 = !{!17, !17, i64 0}
!41 = distinct !{!41, !42}
!42 = !{!"llvm.loop.mustprogress"}
!43 = !{i8 0, i8 2}
!44 = !{}


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