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

@.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__._ZNK7Riemann8AABBTree9IntersectEPKNS_8GeometryEPPS1_PKNS_15IntersectOptionEPNS_15IntersectResultE = external hidden unnamed_addr constant [115 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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN7Riemann8GeometryESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK7Riemann8AABBTree9IntersectEPKNS_8GeometryEPPS1_PKNS_15IntersectOptionEPNS_15IntersectResultE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %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 ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca %"class.Riemann::StaticStack", align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i8, align 1
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i8, align 1
  %22 = alloca i8, align 1
  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
  %23 = load ptr, ptr %7, align 8
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.Riemann::IntersectResult", ptr %24, i32 0, i32 0
  store i8 0, ptr %25, align 8, !tbaa !9
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.Riemann::IntersectResult", ptr %26, i32 0, i32 2
  call void @_ZNSt6vectorIPN7Riemann8GeometryESaIS2_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %27) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = call noundef nonnull align 4 dereferenceable(24) ptr @_ZNK7Riemann8Geometry28GetBoundingVolume_WorldSpaceEv(ptr noundef nonnull align 8 dereferenceable(204) %28)
  store ptr %29, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %30 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %23, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  store ptr %31, ptr %13, align 8, !tbaa !5
  %32 = load ptr, ptr %13, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %43, label %34

34:                                               ; preds = %5
  %35 = load ptr, ptr %12, align 8, !tbaa !5
  %36 = load ptr, ptr %13, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %"class.Maths::TAABB3", ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds %"class.Maths::TAABB3", ptr %40, i32 0, i32 1
  %42 = call noundef zeroext i1 @_ZNK5Maths6TAABB3IfE9IntersectERKNS_8TVector3IfEES5_(ptr noundef nonnull align 4 dereferenceable(24) %35, ptr noundef nonnull align 4 dereferenceable(12) %38, ptr noundef nonnull align 4 dereferenceable(12) %41)
  br i1 %42, label %44, label %43

43:                                               ; preds = %34, %5
  store i1 false, ptr %6, align 1
  store i32 1, ptr %14, align 4
  br label %162

44:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 132, ptr %15) #5
  call void @_ZN7Riemann11StaticStackIjLi32EEC2Ev(ptr noundef nonnull align 4 dereferenceable(132) %15)
  call void @_ZN7Riemann11StaticStackIjLi32EE4pushEj(ptr noundef nonnull align 4 dereferenceable(132) %15, i32 noundef 0)
  br label %45

45:                                               ; preds = %155, %44
  %46 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE5emptyEv(ptr noundef nonnull align 4 dereferenceable(132) %15)
  %47 = xor i1 %46, true
  br i1 %47, label %48, label %156

48:                                               ; preds = %45
  %49 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %23, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !17
  %51 = call noundef i32 @_ZN7Riemann11StaticStackIjLi32EE3popEv(ptr noundef nonnull align 4 dereferenceable(132) %15)
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %50, i64 %52
  store ptr %53, ptr %13, align 8, !tbaa !5
  br label %54

54:                                               ; preds = %153, %48
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %155

57:                                               ; preds = %54
  %58 = load ptr, ptr %13, align 8, !tbaa !5
  %59 = call noundef zeroext i1 @_ZNK7Riemann21CacheFriendlyAABBTree6IsLeafEv(ptr noundef nonnull align 4 dereferenceable(28) %58)
  br i1 %59, label %60, label %91

60:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  %62 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %23, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !19
  %64 = call noundef ptr @_ZNK7Riemann21CacheFriendlyAABBTree18GetGeometryIndicesEPi(ptr noundef nonnull align 4 dereferenceable(28) %61, ptr noundef %63)
  store ptr %64, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  %66 = call noundef i32 @_ZNK7Riemann21CacheFriendlyAABBTree16GetNumGeometriesEv(ptr noundef nonnull align 4 dereferenceable(28) %65)
  store i32 %66, ptr %17, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 1, ptr %18) #5
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = load ptr, ptr %16, align 8, !tbaa !5
  %69 = load i32, ptr %17, align 4, !tbaa !20
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = load ptr, ptr %11, align 8, !tbaa !5
  %73 = call noundef zeroext i1 @_ZN7RiemannL17OverlapGeometriesEPKNS_8GeometryEPiiPPS0_PKNS_15IntersectOptionEPNS_15IntersectResultE(ptr noundef %67, ptr noundef %68, i32 noundef %69, ptr noundef %70, ptr noundef %71, ptr noundef %72)
  %74 = zext i1 %73 to i8
  store i8 %74, ptr %18, align 1, !tbaa !21
  %75 = load i8, ptr %18, align 1, !tbaa !21, !range !22, !noundef !23
  %76 = trunc i8 %75 to i1
  br i1 %76, label %77, label %88

77:                                               ; preds = %60
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = getelementptr inbounds %"struct.Riemann::IntersectResult", ptr %78, i32 0, i32 2
  %80 = call noundef i64 @_ZNKSt6vectorIPN7Riemann8GeometryESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %79) #5
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = getelementptr inbounds %"struct.Riemann::IntersectOption", ptr %81, i32 0, i32 0
  %83 = load i32, ptr %82, align 8, !tbaa !24
  %84 = zext i32 %83 to i64
  %85 = icmp uge i64 %80, %84
  br i1 %85, label %86, label %87

86:                                               ; preds = %77
  store i1 true, ptr %6, align 1
  store i32 1, ptr %14, align 4
  br label %89

87:                                               ; preds = %77
  br label %88

88:                                               ; preds = %87, %60
  store i32 5, ptr %14, align 4
  br label %89

89:                                               ; preds = %88, %86
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %90 = load i32, ptr %14, align 4
  switch i32 %90, label %161 [
    i32 5, label %155
  ]

91:                                               ; preds = %57
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  call void @_ZN7Riemann15IntersectResult12AddTestCountEi(ptr noundef nonnull align 8 dereferenceable(36) %92, i32 noundef 2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %93 = load ptr, ptr %13, align 8, !tbaa !5
  %94 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %23, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !17
  %96 = call noundef ptr @_ZN7Riemann21CacheFriendlyAABBTree11GetLeftNodeEPS0_(ptr noundef nonnull align 4 dereferenceable(28) %93, ptr noundef %95)
  store ptr %96, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %97 = load ptr, ptr %13, align 8, !tbaa !5
  %98 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %23, i32 0, i32 2
  %99 = load ptr, ptr %98, align 8, !tbaa !17
  %100 = call noundef ptr @_ZN7Riemann21CacheFriendlyAABBTree12GetRightNodeEPS0_(ptr noundef nonnull align 4 dereferenceable(28) %97, ptr noundef %99)
  store ptr %100, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %21) #5
  %101 = load ptr, ptr %12, align 8, !tbaa !5
  %102 = load ptr, ptr %19, align 8, !tbaa !5
  %103 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %102, i32 0, i32 0
  %104 = getelementptr inbounds %"class.Maths::TAABB3", ptr %103, i32 0, i32 0
  %105 = load ptr, ptr %19, align 8, !tbaa !5
  %106 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %105, i32 0, i32 0
  %107 = getelementptr inbounds %"class.Maths::TAABB3", ptr %106, i32 0, i32 1
  %108 = call noundef zeroext i1 @_ZNK5Maths6TAABB3IfE9IntersectERKNS_8TVector3IfEES5_(ptr noundef nonnull align 4 dereferenceable(24) %101, ptr noundef nonnull align 4 dereferenceable(12) %104, ptr noundef nonnull align 4 dereferenceable(12) %107)
  %109 = zext i1 %108 to i8
  store i8 %109, ptr %21, align 1, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 1, ptr %22) #5
  %110 = load ptr, ptr %12, align 8, !tbaa !5
  %111 = load ptr, ptr %20, align 8, !tbaa !5
  %112 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %111, i32 0, i32 0
  %113 = getelementptr inbounds %"class.Maths::TAABB3", ptr %112, i32 0, i32 0
  %114 = load ptr, ptr %20, align 8, !tbaa !5
  %115 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %114, i32 0, i32 0
  %116 = getelementptr inbounds %"class.Maths::TAABB3", ptr %115, i32 0, i32 1
  %117 = call noundef zeroext i1 @_ZNK5Maths6TAABB3IfE9IntersectERKNS_8TVector3IfEES5_(ptr noundef nonnull align 4 dereferenceable(24) %110, ptr noundef nonnull align 4 dereferenceable(12) %113, ptr noundef nonnull align 4 dereferenceable(12) %116)
  %118 = zext i1 %117 to i8
  store i8 %118, ptr %22, align 1, !tbaa !21
  %119 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE4fullEv(ptr noundef nonnull align 4 dereferenceable(132) %15)
  %120 = xor i1 %119, true
  br i1 %120, label %121, label %122

121:                                              ; preds = %91
  br label %124

122:                                              ; preds = %91
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 430, ptr noundef @__PRETTY_FUNCTION__._ZNK7Riemann8AABBTree9IntersectEPKNS_8GeometryEPPS1_PKNS_15IntersectOptionEPNS_15IntersectResultE) #6
  unreachable

123:                                              ; No predecessors!
  br label %124

124:                                              ; preds = %123, %121
  %125 = load i8, ptr %21, align 1, !tbaa !21, !range !22, !noundef !23
  %126 = trunc i8 %125 to i1
  br i1 %126, label %127, label %140

127:                                              ; preds = %124
  %128 = load i8, ptr %22, align 1, !tbaa !21, !range !22, !noundef !23
  %129 = trunc i8 %128 to i1
  br i1 %129, label %130, label %140

130:                                              ; preds = %127
  %131 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %131, ptr %13, align 8, !tbaa !5
  %132 = load ptr, ptr %20, align 8, !tbaa !5
  %133 = getelementptr inbounds %"class.Riemann::AABBTree", ptr %23, i32 0, i32 2
  %134 = load ptr, ptr %133, align 8, !tbaa !17
  %135 = ptrtoint ptr %132 to i64
  %136 = ptrtoint ptr %134 to i64
  %137 = sub i64 %135, %136
  %138 = sdiv exact i64 %137, 28
  %139 = trunc i64 %138 to i32
  call void @_ZN7Riemann11StaticStackIjLi32EE4pushEj(ptr noundef nonnull align 4 dereferenceable(132) %15, i32 noundef %139)
  store i32 4, ptr %14, align 4
  br label %153, !llvm.loop !27

140:                                              ; preds = %127, %124
  %141 = load i8, ptr %21, align 1, !tbaa !21, !range !22, !noundef !23
  %142 = trunc i8 %141 to i1
  br i1 %142, label %143, label %145

143:                                              ; preds = %140
  %144 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %144, ptr %13, align 8, !tbaa !5
  store i32 4, ptr %14, align 4
  br label %153, !llvm.loop !27

145:                                              ; preds = %140
  %146 = load i8, ptr %22, align 1, !tbaa !21, !range !22, !noundef !23
  %147 = trunc i8 %146 to i1
  br i1 %147, label %148, label %150

148:                                              ; preds = %145
  %149 = load ptr, ptr %20, align 8, !tbaa !5
  store ptr %149, ptr %13, align 8, !tbaa !5
  store i32 4, ptr %14, align 4
  br label %153, !llvm.loop !27

150:                                              ; preds = %145
  br label %151

151:                                              ; preds = %150
  br label %152

152:                                              ; preds = %151
  store i32 5, ptr %14, align 4
  br label %153

153:                                              ; preds = %152, %148, %143, %130
  call void @llvm.lifetime.end.p0(i64 1, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  %154 = load i32, ptr %14, align 4
  switch i32 %154, label %164 [
    i32 4, label %54
    i32 5, label %155
  ]

155:                                              ; preds = %153, %89, %54
  br label %45, !llvm.loop !29

156:                                              ; preds = %45
  %157 = load ptr, ptr %11, align 8, !tbaa !5
  %158 = getelementptr inbounds %"struct.Riemann::IntersectResult", ptr %157, i32 0, i32 0
  %159 = load i8, ptr %158, align 8, !tbaa !9, !range !22, !noundef !23
  %160 = trunc i8 %159 to i1
  store i1 %160, ptr %6, align 1
  store i32 1, ptr %14, align 4
  br label %161

161:                                              ; preds = %156, %89
  call void @llvm.lifetime.end.p0(i64 132, ptr %15) #5
  br label %162

162:                                              ; preds = %161, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %163 = load i1, ptr %6, align 1
  ret i1 %163

164:                                              ; preds = %153
  unreachable
}

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

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

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

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN7RiemannL17OverlapGeometriesEPKNS_8GeometryEPiiPPS0_PKNS_15IntersectOptionEPNS_15IntersectResultE(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann15IntersectResult12AddTestCountEi(ptr noundef nonnull align 8 dereferenceable(36), i32 noundef) #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 = !{!"_ZTSN7Riemann15IntersectResultE", !11, i64 0, !12, i64 8, !16, i64 32}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTSSt6vectorIPN7Riemann8GeometryESaIS2_EE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIPN7Riemann8GeometryESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIPN7Riemann8GeometryESaIS2_EE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIPN7Riemann8GeometryESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!"int", !7, i64 0}
!17 = !{!18, !6, i64 16}
!18 = !{!"_ZTSN7Riemann8AABBTreeE", !6, i64 0, !16, i64 8, !6, i64 16}
!19 = !{!18, !6, i64 0}
!20 = !{!16, !16, i64 0}
!21 = !{!11, !11, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!25, !16, i64 0}
!25 = !{!"_ZTSN7Riemann15IntersectOptionE", !16, i64 0, !26, i64 4, !6, i64 24}
!26 = !{!"_ZTSN7Riemann13CollisionDataE", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = distinct !{!29, !28}


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

@.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__._ZNK7Riemann8AABBTree9IntersectEPKNS_8GeometryEPPS1_PKNS_15IntersectOptionEPNS_15IntersectResultE = external hidden unnamed_addr constant [115 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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN7Riemann8GeometryESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK7Riemann8AABBTree9IntersectEPKNS_8GeometryEPPS1_PKNS_15IntersectOptionEPNS_15IntersectResultE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #4 align 2 {
  %6 = alloca %"class.Riemann::StaticStack", align 4
  store i8 0, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  tail call void @_ZNSt6vectorIPN7Riemann8GeometryESaIS2_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #5
  %8 = tail call noundef nonnull align 4 dereferenceable(24) ptr @_ZNK7Riemann8Geometry28GetBoundingVolume_WorldSpaceEv(ptr noundef nonnull align 8 dereferenceable(204) %1)
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !16
  %11 = icmp eq ptr %10, null
  br i1 %11, label %54, label %12

12:                                               ; preds = %5
  %13 = getelementptr inbounds i8, ptr %10, i64 12
  %14 = tail call noundef zeroext i1 @_ZNK5Maths6TAABB3IfE9IntersectERKNS_8TVector3IfEES5_(ptr noundef nonnull align 4 dereferenceable(24) %8, ptr noundef nonnull align 4 dereferenceable(12) %10, ptr noundef nonnull align 4 dereferenceable(12) %13)
  br i1 %14, label %15, label %54

15:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 132, ptr nonnull %6) #5
  call void @_ZN7Riemann11StaticStackIjLi32EEC2Ev(ptr noundef nonnull align 4 dereferenceable(132) %6)
  call void @_ZN7Riemann11StaticStackIjLi32EE4pushEj(ptr noundef nonnull align 4 dereferenceable(132) %6, i32 noundef 0)
  %16 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE5emptyEv(ptr noundef nonnull align 4 dereferenceable(132) %6)
  br i1 %16, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %15, %.critedge
  %17 = load ptr, ptr %9, align 8, !tbaa !16
  %18 = call noundef i32 @_ZN7Riemann11StaticStackIjLi32EE3popEv(ptr noundef nonnull align 4 dereferenceable(132) %6)
  %.not58 = icmp eq ptr %17, null
  br i1 %.not58, label %.critedge, label %.lr.ph60

.lr.ph60:                                         ; preds = %.lr.ph
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %17, i64 %19
  br label %.backedge

.backedge:                                        ; preds = %.backedge.backedge, %.lr.ph60
  %.04159 = phi ptr [ %20, %.lr.ph60 ], [ %.04159.be, %.backedge.backedge ]
  %21 = call noundef zeroext i1 @_ZNK7Riemann21CacheFriendlyAABBTree6IsLeafEv(ptr noundef nonnull align 4 dereferenceable(28) %.04159)
  br i1 %21, label %22, label %31

22:                                               ; preds = %.backedge
  %23 = load ptr, ptr %0, align 8, !tbaa !18
  %24 = call noundef ptr @_ZNK7Riemann21CacheFriendlyAABBTree18GetGeometryIndicesEPi(ptr noundef nonnull align 4 dereferenceable(28) %.04159, ptr noundef %23)
  %25 = call noundef i32 @_ZNK7Riemann21CacheFriendlyAABBTree16GetNumGeometriesEv(ptr noundef nonnull align 4 dereferenceable(28) %.04159)
  %26 = call noundef zeroext i1 @_ZN7RiemannL17OverlapGeometriesEPKNS_8GeometryEPiiPPS0_PKNS_15IntersectOptionEPNS_15IntersectResultE(ptr noundef nonnull %1, ptr noundef %24, i32 noundef %25, ptr noundef %2, ptr noundef %3, ptr noundef nonnull %4)
  br i1 %26, label %27, label %.critedge

27:                                               ; preds = %22
  %28 = call noundef i64 @_ZNKSt6vectorIPN7Riemann8GeometryESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #5
  %29 = load i32, ptr %3, align 8, !tbaa !19
  %30 = zext i32 %29 to i64
  %.not46 = icmp ult i64 %28, %30
  br i1 %.not46, label %.critedge, label %.loopexit

31:                                               ; preds = %.backedge
  call void @_ZN7Riemann15IntersectResult12AddTestCountEi(ptr noundef nonnull align 8 dereferenceable(36) %4, i32 noundef 2)
  %32 = load ptr, ptr %9, align 8, !tbaa !16
  %33 = call noundef ptr @_ZN7Riemann21CacheFriendlyAABBTree11GetLeftNodeEPS0_(ptr noundef nonnull align 4 dereferenceable(28) %.04159, ptr noundef %32)
  %34 = load ptr, ptr %9, align 8, !tbaa !16
  %35 = call noundef ptr @_ZN7Riemann21CacheFriendlyAABBTree12GetRightNodeEPS0_(ptr noundef nonnull align 4 dereferenceable(28) %.04159, ptr noundef %34)
  %36 = getelementptr inbounds i8, ptr %33, i64 12
  %37 = call noundef zeroext i1 @_ZNK5Maths6TAABB3IfE9IntersectERKNS_8TVector3IfEES5_(ptr noundef nonnull align 4 dereferenceable(24) %8, ptr noundef nonnull align 4 dereferenceable(12) %33, ptr noundef nonnull align 4 dereferenceable(12) %36)
  %38 = getelementptr inbounds i8, ptr %35, i64 12
  %39 = call noundef zeroext i1 @_ZNK5Maths6TAABB3IfE9IntersectERKNS_8TVector3IfEES5_(ptr noundef nonnull align 4 dereferenceable(24) %8, ptr noundef nonnull align 4 dereferenceable(12) %35, ptr noundef nonnull align 4 dereferenceable(12) %38)
  %40 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE4fullEv(ptr noundef nonnull align 4 dereferenceable(132) %6)
  br i1 %40, label %41, label %42

41:                                               ; preds = %31
  call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 430, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK7Riemann8AABBTree9IntersectEPKNS_8GeometryEPPS1_PKNS_15IntersectOptionEPNS_15IntersectResultE) #6
  unreachable

42:                                               ; preds = %31
  %brmerge.demorgan = and i1 %37, %39
  br i1 %brmerge.demorgan, label %43, label %50

43:                                               ; preds = %42
  %44 = load ptr, ptr %9, align 8, !tbaa !16
  %45 = ptrtoint ptr %35 to i64
  %46 = ptrtoint ptr %44 to i64
  %47 = sub i64 %45, %46
  %48 = sdiv exact i64 %47, 28
  %49 = trunc i64 %48 to i32
  call void @_ZN7Riemann11StaticStackIjLi32EE4pushEj(ptr noundef nonnull align 4 dereferenceable(132) %6, i32 noundef %49)
  br label %.backedge.backedge

50:                                               ; preds = %42
  %..041 = select i1 %39, ptr %35, ptr %.04159
  %spec.select = or i1 %37, %39
  %spec.select49 = select i1 %37, ptr %33, ptr %..041
  br i1 %spec.select, label %.backedge.backedge, label %.critedge

.backedge.backedge:                               ; preds = %50, %43
  %.04159.be = phi ptr [ %spec.select49, %50 ], [ %33, %43 ]
  br label %.backedge

.critedge:                                        ; preds = %50, %.lr.ph, %22, %27
  %51 = call noundef zeroext i1 @_ZNK7Riemann11StaticStackIjLi32EE5emptyEv(ptr noundef nonnull align 4 dereferenceable(132) %6)
  br i1 %51, label %._crit_edge, label %.lr.ph, !llvm.loop !22

._crit_edge:                                      ; preds = %.critedge, %15
  %52 = load i8, ptr %4, align 8, !tbaa !5, !range !24, !noundef !25
  %53 = trunc nuw i8 %52 to i1
  br label %.loopexit

.loopexit:                                        ; preds = %27, %._crit_edge
  %.3 = phi i1 [ %53, %._crit_edge ], [ true, %27 ]
  call void @llvm.lifetime.end.p0(i64 132, ptr nonnull %6) #5
  br label %54

54:                                               ; preds = %5, %12, %.loopexit
  %.4 = phi i1 [ %.3, %.loopexit ], [ false, %12 ], [ false, %5 ]
  ret i1 %.4
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5Maths6TAABB3IfE9IntersectERKNS_8TVector3IfEES5_(ptr noundef nonnull align 4 dereferenceable(24), 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 hidden noundef zeroext i1 @_ZN7RiemannL17OverlapGeometriesEPKNS_8GeometryEPiiPPS0_PKNS_15IntersectOptionEPNS_15IntersectResultE(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann15IntersectResult12AddTestCountEi(ptr noundef nonnull align 8 dereferenceable(36), i32 noundef) 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 = !{!"_ZTSN7Riemann15IntersectResultE", !7, i64 0, !10, i64 8, !15, i64 32}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIPN7Riemann8GeometryESaIS2_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIPN7Riemann8GeometryESaIS2_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIPN7Riemann8GeometryESaIS2_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIPN7Riemann8GeometryESaIS2_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"int", !8, i64 0}
!16 = !{!17, !14, i64 16}
!17 = !{!"_ZTSN7Riemann8AABBTreeE", !14, i64 0, !15, i64 8, !14, i64 16}
!18 = !{!17, !14, i64 0}
!19 = !{!20, !15, i64 0}
!20 = !{!"_ZTSN7Riemann15IntersectOptionE", !15, i64 0, !21, i64 4, !14, i64 24}
!21 = !{!"_ZTSN7Riemann13CollisionDataE", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{i8 0, i8 2}
!25 = !{}


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