; LLVM IR from atlantis13579/Riemann :: Src/Collision/AABBTreeOffline.ll (ZN7Riemann15AABBTreeOffline22BuildCacheFriendlyTreeEv)

; 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::AABBTreeOffline" = type { ptr, %"class.std::vector.0", i32, i32 }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<Riemann::AABBTreeOffline::NodeBlock, std::allocator<Riemann::AABBTreeOffline::NodeBlock>>::_Vector_impl" }
%"struct.std::_Vector_base<Riemann::AABBTreeOffline::NodeBlock, std::allocator<Riemann::AABBTreeOffline::NodeBlock>>::_Vector_impl" = type { %"struct.std::_Vector_base<Riemann::AABBTreeOffline::NodeBlock, std::allocator<Riemann::AABBTreeOffline::NodeBlock>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Riemann::AABBTreeOffline::NodeBlock, std::allocator<Riemann::AABBTreeOffline::NodeBlock>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.Riemann::AABBTreeOffline::NodeBlock" = type { ptr, i32, i32 }
%"class.Riemann::AABBTreeNodeOffline" = type { %"class.Maths::TAABB3", ptr, ptr, i32, i32 }
%"class.Maths::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }
%"class.Maths::TVector3" = type { float, float, float }
%"struct.Riemann::CacheFriendlyAABBTree" = type { %"class.Maths::TAABB3", i32 }

@.str.1 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN7Riemann15AABBTreeOffline22BuildCacheFriendlyTreeEv = external hidden unnamed_addr constant [74 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7Riemann19AABBTreeNodeOffline10IsLeafNodeEv(ptr noundef nonnull align 8 dereferenceable(48)) #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(24)) #0 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #3

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN7Riemann15AABBTreeOffline22BuildCacheFriendlyTreeEv(ptr noundef nonnull align 8 dereferenceable(40) %0) #5 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8
  %18 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %17, i32 0, i32 3
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = icmp sle i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  br label %215

22:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %23 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %17, i32 0, i32 3
  %24 = load i32, ptr %23, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = mul i64 28, %25
  %27 = call noalias noundef nonnull ptr @_Znam(i64 noundef %26) #7
  store ptr %27, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %17, i32 0, i32 3
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = mul i64 28, %31
  call void @llvm.memset.p0.i64(ptr align 4 %28, i8 0, i64 %32, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 0, ptr %6, align 8, !tbaa !17
  br label %33

33:                                               ; preds = %210, %22
  %34 = load i64, ptr %6, align 8, !tbaa !17
  %35 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %17, i32 0, i32 1
  %36 = call noundef i64 @_ZNKSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %35) #6
  %37 = icmp ult i64 %34, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %33
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %213

39:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %40 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %17, i32 0, i32 1
  %41 = load i64, ptr %6, align 8, !tbaa !17
  %42 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %40, i64 noundef %41) #6
  store ptr %42, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.Riemann::AABBTreeOffline::NodeBlock", ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !19
  store ptr %45, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !16
  br label %46

46:                                               ; preds = %206, %39
  %47 = load i32, ptr %10, align 4, !tbaa !16
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.Riemann::AABBTreeOffline::NodeBlock", ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 8, !tbaa !21
  %51 = icmp slt i32 %47, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %46
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %209

53:                                               ; preds = %46
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load i32, ptr %10, align 4, !tbaa !16
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %54, i64 %56
  %58 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load i32, ptr %5, align 4, !tbaa !16
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %59, i64 %61
  %63 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %62, i32 0, i32 0
  %64 = call noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(24) %63, ptr noundef nonnull align 4 dereferenceable(24) %58)
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = load i32, ptr %10, align 4, !tbaa !16
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %65, i64 %67
  %69 = call noundef zeroext i1 @_ZNK7Riemann19AABBTreeNodeOffline10IsLeafNodeEv(ptr noundef nonnull align 8 dereferenceable(48) %68)
  br i1 %69, label %70, label %101

70:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = load i32, ptr %10, align 4, !tbaa !16
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %71, i64 %73
  %75 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %74, i32 0, i32 3
  %76 = load i32, ptr %75, align 8, !tbaa !22
  store i32 %76, ptr %11, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = load i32, ptr %10, align 4, !tbaa !16
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %77, i64 %79
  %81 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %80, i32 0, i32 4
  %82 = load i32, ptr %81, align 4, !tbaa !27
  store i32 %82, ptr %12, align 4, !tbaa !16
  %83 = load i32, ptr %12, align 4, !tbaa !16
  %84 = icmp sle i32 %83, 16
  br i1 %84, label %85, label %86

85:                                               ; preds = %70
  br label %88

86:                                               ; preds = %70
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 224, ptr noundef @__PRETTY_FUNCTION__._ZN7Riemann15AABBTreeOffline22BuildCacheFriendlyTreeEv) #8
  unreachable

87:                                               ; No predecessors!
  br label %88

88:                                               ; preds = %87, %85
  %89 = load i32, ptr %11, align 4, !tbaa !16
  %90 = shl i32 %89, 5
  %91 = load i32, ptr %12, align 4, !tbaa !16
  %92 = and i32 %91, 15
  %93 = shl i32 %92, 1
  %94 = or i32 %90, %93
  %95 = or i32 %94, 1
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = load i32, ptr %5, align 4, !tbaa !16
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %96, i64 %98
  %100 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %99, i32 0, i32 1
  store i32 %95, ptr %100, align 4, !tbaa !28
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %203

101:                                              ; preds = %53
  %102 = load ptr, ptr %9, align 8, !tbaa !5
  %103 = load i32, ptr %10, align 4, !tbaa !16
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %102, i64 %104
  %106 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %105, i32 0, i32 1
  %107 = load ptr, ptr %106, align 8, !tbaa !30
  %108 = icmp ne ptr %107, null
  br i1 %108, label %109, label %110

109:                                              ; preds = %101
  br label %112

110:                                              ; preds = %101
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 230, ptr noundef @__PRETTY_FUNCTION__._ZN7Riemann15AABBTreeOffline22BuildCacheFriendlyTreeEv) #8
  unreachable

111:                                              ; No predecessors!
  br label %112

112:                                              ; preds = %111, %109
  %113 = load ptr, ptr %9, align 8, !tbaa !5
  %114 = load i32, ptr %10, align 4, !tbaa !16
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %113, i64 %115
  %117 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %116, i32 0, i32 2
  %118 = load ptr, ptr %117, align 8, !tbaa !31
  %119 = icmp ne ptr %118, null
  br i1 %119, label %120, label %121

120:                                              ; preds = %112
  br label %123

121:                                              ; preds = %112
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 231, ptr noundef @__PRETTY_FUNCTION__._ZN7Riemann15AABBTreeOffline22BuildCacheFriendlyTreeEv) #8
  unreachable

122:                                              ; No predecessors!
  br label %123

123:                                              ; preds = %122, %120
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 -1, ptr %13, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  store i64 0, ptr %15, align 8, !tbaa !17
  br label %124

124:                                              ; preds = %188, %123
  %125 = load i64, ptr %15, align 8, !tbaa !17
  %126 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %17, i32 0, i32 1
  %127 = call noundef i64 @_ZNKSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %126) #6
  %128 = icmp ult i64 %125, %127
  br i1 %128, label %130, label %129

129:                                              ; preds = %124
  store i32 8, ptr %7, align 4
  br label %191

130:                                              ; preds = %124
  %131 = load ptr, ptr %9, align 8, !tbaa !5
  %132 = load i32, ptr %10, align 4, !tbaa !16
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %131, i64 %133
  %135 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %134, i32 0, i32 1
  %136 = load ptr, ptr %135, align 8, !tbaa !30
  %137 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %17, i32 0, i32 1
  %138 = load i64, ptr %15, align 8, !tbaa !17
  %139 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %137, i64 noundef %138) #6
  %140 = getelementptr inbounds %"struct.Riemann::AABBTreeOffline::NodeBlock", ptr %139, i32 0, i32 0
  %141 = load ptr, ptr %140, align 8, !tbaa !19
  %142 = icmp uge ptr %136, %141
  br i1 %142, label %143, label %180

143:                                              ; preds = %130
  %144 = load ptr, ptr %9, align 8, !tbaa !5
  %145 = load i32, ptr %10, align 4, !tbaa !16
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %144, i64 %146
  %148 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %147, i32 0, i32 1
  %149 = load ptr, ptr %148, align 8, !tbaa !30
  %150 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %17, i32 0, i32 1
  %151 = load i64, ptr %15, align 8, !tbaa !17
  %152 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %150, i64 noundef %151) #6
  %153 = getelementptr inbounds %"struct.Riemann::AABBTreeOffline::NodeBlock", ptr %152, i32 0, i32 0
  %154 = load ptr, ptr %153, align 8, !tbaa !19
  %155 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %17, i32 0, i32 1
  %156 = load i64, ptr %15, align 8, !tbaa !17
  %157 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %155, i64 noundef %156) #6
  %158 = getelementptr inbounds %"struct.Riemann::AABBTreeOffline::NodeBlock", ptr %157, i32 0, i32 1
  %159 = load i32, ptr %158, align 8, !tbaa !21
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %154, i64 %160
  %162 = icmp ult ptr %149, %161
  br i1 %162, label %163, label %180

163:                                              ; preds = %143
  %164 = load ptr, ptr %9, align 8, !tbaa !5
  %165 = load i32, ptr %10, align 4, !tbaa !16
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %164, i64 %166
  %168 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %167, i32 0, i32 1
  %169 = load ptr, ptr %168, align 8, !tbaa !30
  %170 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %17, i32 0, i32 1
  %171 = load i64, ptr %15, align 8, !tbaa !17
  %172 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %170, i64 noundef %171) #6
  %173 = getelementptr inbounds %"struct.Riemann::AABBTreeOffline::NodeBlock", ptr %172, i32 0, i32 0
  %174 = load ptr, ptr %173, align 8, !tbaa !19
  %175 = ptrtoint ptr %169 to i64
  %176 = ptrtoint ptr %174 to i64
  %177 = sub i64 %175, %176
  %178 = sdiv exact i64 %177, 48
  %179 = trunc i64 %178 to i32
  store i32 %179, ptr %13, align 4, !tbaa !16
  store i32 8, ptr %7, align 4
  br label %191

180:                                              ; preds = %143, %130
  %181 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %17, i32 0, i32 1
  %182 = load i64, ptr %15, align 8, !tbaa !17
  %183 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %181, i64 noundef %182) #6
  %184 = getelementptr inbounds %"struct.Riemann::AABBTreeOffline::NodeBlock", ptr %183, i32 0, i32 1
  %185 = load i32, ptr %184, align 8, !tbaa !21
  %186 = load i32, ptr %14, align 4, !tbaa !16
  %187 = add i32 %186, %185
  store i32 %187, ptr %14, align 4, !tbaa !16
  br label %188

188:                                              ; preds = %180
  %189 = load i64, ptr %15, align 8, !tbaa !17
  %190 = add i64 %189, 1
  store i64 %190, ptr %15, align 8, !tbaa !17
  br label %124, !llvm.loop !32

191:                                              ; preds = %163, %129
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %192

192:                                              ; preds = %191
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %193 = load i32, ptr %14, align 4, !tbaa !16
  %194 = load i32, ptr %13, align 4, !tbaa !16
  %195 = add i32 %193, %194
  store i32 %195, ptr %16, align 4, !tbaa !16
  %196 = load i32, ptr %16, align 4, !tbaa !16
  %197 = shl i32 %196, 1
  %198 = load ptr, ptr %4, align 8, !tbaa !5
  %199 = load i32, ptr %5, align 4, !tbaa !16
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %198, i64 %200
  %202 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %201, i32 0, i32 1
  store i32 %197, ptr %202, align 4, !tbaa !28
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %203

203:                                              ; preds = %192, %88
  %204 = load i32, ptr %5, align 4, !tbaa !16
  %205 = add nsw i32 %204, 1
  store i32 %205, ptr %5, align 4, !tbaa !16
  br label %206

206:                                              ; preds = %203
  %207 = load i32, ptr %10, align 4, !tbaa !16
  %208 = add nsw i32 %207, 1
  store i32 %208, ptr %10, align 4, !tbaa !16
  br label %46, !llvm.loop !34

209:                                              ; preds = %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %210

210:                                              ; preds = %209
  %211 = load i64, ptr %6, align 8, !tbaa !17
  %212 = add i64 %211, 1
  store i64 %212, ptr %6, align 8, !tbaa !17
  br label %33, !llvm.loop !35

213:                                              ; preds = %38
  %214 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %214, ptr %2, align 8
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  br label %215

215:                                              ; preds = %213, %21
  %216 = load ptr, ptr %2, align 8
  ret ptr %216
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nobuiltin allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { 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, !15, i64 36}
!10 = !{!"_ZTSN7Riemann15AABBTreeOfflineE", !6, i64 0, !11, i64 8, !15, i64 32, !15, i64 36}
!11 = !{!"_ZTSSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"int", !7, i64 0}
!16 = !{!15, !15, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!20, !6, i64 0}
!20 = !{!"_ZTSN7Riemann15AABBTreeOffline9NodeBlockE", !6, i64 0, !15, i64 8, !15, i64 12}
!21 = !{!20, !15, i64 8}
!22 = !{!23, !15, i64 40}
!23 = !{!"_ZTSN7Riemann19AABBTreeNodeOfflineE", !24, i64 0, !6, i64 24, !6, i64 32, !15, i64 40, !15, i64 44}
!24 = !{!"_ZTSN5Maths6TAABB3IfEE", !25, i64 0, !25, i64 12}
!25 = !{!"_ZTSN5Maths8TVector3IfEE", !26, i64 0, !26, i64 4, !26, i64 8}
!26 = !{!"float", !7, i64 0}
!27 = !{!23, !15, i64 44}
!28 = !{!29, !15, i64 24}
!29 = !{!"_ZTSN7Riemann21CacheFriendlyAABBTreeE", !24, i64 0, !15, i64 24}
!30 = !{!23, !6, i64 24}
!31 = !{!23, !6, i64 32}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}
!34 = distinct !{!34, !33}
!35 = distinct !{!35, !33}


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

@.str.1 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN7Riemann15AABBTreeOffline22BuildCacheFriendlyTreeEv = external hidden unnamed_addr constant [74 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7Riemann19AABBTreeNodeOffline10IsLeafNodeEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN7Riemann15AABBTreeOffline22BuildCacheFriendlyTreeEv(ptr noundef nonnull align 8 dereferenceable(40) %0) local_unnamed_addr #4 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 36
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = icmp slt i32 %3, 1
  br i1 %4, label %.loopexit59, label %5

5:                                                ; preds = %1
  %6 = zext nneg i32 %3 to i64
  %7 = mul nuw nsw i64 %6, 28
  %8 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %7) #5
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 %8, i8 0, i64 %7, i1 false)
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = tail call noundef i64 @_ZNKSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #6
  %.not76 = icmp eq i64 %10, 0
  br i1 %.not76, label %.loopexit59, label %.lr.ph75

.lr.ph75:                                         ; preds = %5, %._crit_edge
  %.05273 = phi i32 [ %.1.lcssa, %._crit_edge ], [ 0, %5 ]
  %.05372 = phi i64 [ %18, %._crit_edge ], [ 0, %5 ]
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %.05372) #6
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %11, i64 8
  %14 = load i32, ptr %13, align 8, !tbaa !17
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph70.preheader, label %._crit_edge

.lr.ph70.preheader:                               ; preds = %.lr.ph75
  %16 = sext i32 %.05273 to i64
  br label %.lr.ph70

._crit_edge.loopexit:                             ; preds = %79
  %17 = trunc nsw i64 %indvars.iv.next to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.lr.ph75
  %.1.lcssa = phi i32 [ %.05273, %.lr.ph75 ], [ %17, %._crit_edge.loopexit ]
  %18 = add nuw i64 %.05372, 1
  %19 = tail call noundef i64 @_ZNKSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #6
  %20 = icmp ult i64 %18, %19
  br i1 %20, label %.lr.ph75, label %.loopexit59, !llvm.loop !18

.lr.ph70:                                         ; preds = %.lr.ph70.preheader, %79
  %indvars.iv81 = phi i64 [ 0, %.lr.ph70.preheader ], [ %indvars.iv.next82, %79 ]
  %indvars.iv = phi i64 [ %16, %.lr.ph70.preheader ], [ %indvars.iv.next, %79 ]
  %21 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %12, i64 %indvars.iv81
  %22 = getelementptr inbounds %"struct.Riemann::CacheFriendlyAABBTree", ptr %8, i64 %indvars.iv
  %23 = tail call noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(24) %22, ptr noundef nonnull align 4 dereferenceable(24) %21)
  %24 = tail call noundef zeroext i1 @_ZNK7Riemann19AABBTreeNodeOffline10IsLeafNodeEv(ptr noundef nonnull align 8 dereferenceable(48) %21)
  br i1 %24, label %25, label %38

25:                                               ; preds = %.lr.ph70
  %26 = getelementptr inbounds i8, ptr %21, i64 44
  %27 = load i32, ptr %26, align 4, !tbaa !20
  %28 = icmp slt i32 %27, 17
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 224, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7Riemann15AABBTreeOffline22BuildCacheFriendlyTreeEv) #7
  unreachable

30:                                               ; preds = %25
  %31 = getelementptr inbounds i8, ptr %21, i64 40
  %32 = load i32, ptr %31, align 8, !tbaa !25
  %33 = shl i32 %32, 5
  %34 = shl i32 %27, 1
  %35 = and i32 %34, 30
  %36 = or disjoint i32 %33, %35
  %37 = or disjoint i32 %36, 1
  br label %79

38:                                               ; preds = %.lr.ph70
  %39 = getelementptr inbounds i8, ptr %21, i64 24
  %40 = load ptr, ptr %39, align 8, !tbaa !26
  %.not = icmp eq ptr %40, null
  br i1 %.not, label %41, label %42

41:                                               ; preds = %38
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 230, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7Riemann15AABBTreeOffline22BuildCacheFriendlyTreeEv) #7
  unreachable

42:                                               ; preds = %38
  %43 = getelementptr inbounds i8, ptr %21, i64 32
  %44 = load ptr, ptr %43, align 8, !tbaa !27
  %.not57 = icmp eq ptr %44, null
  br i1 %.not57, label %46, label %.preheader

.preheader:                                       ; preds = %42
  %45 = tail call noundef i64 @_ZNKSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #6
  %.not77 = icmp eq i64 %45, 0
  br i1 %.not77, label %.loopexit, label %.lr.ph

46:                                               ; preds = %42
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 231, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7Riemann15AABBTreeOffline22BuildCacheFriendlyTreeEv) #7
  unreachable

.lr.ph:                                           ; preds = %.preheader, %69
  %.04967 = phi i64 [ %74, %69 ], [ 0, %.preheader ]
  %.05066 = phi i32 [ %73, %69 ], [ 0, %.preheader ]
  %47 = load ptr, ptr %39, align 8, !tbaa !26
  %48 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %.04967) #6
  %49 = load ptr, ptr %48, align 8, !tbaa !15
  %.not58 = icmp ult ptr %47, %49
  br i1 %.not58, label %69, label %50

50:                                               ; preds = %.lr.ph
  %51 = load ptr, ptr %39, align 8, !tbaa !26
  %52 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %.04967) #6
  %53 = load ptr, ptr %52, align 8, !tbaa !15
  %54 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %.04967) #6
  %55 = getelementptr inbounds i8, ptr %54, i64 8
  %56 = load i32, ptr %55, align 8, !tbaa !17
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %53, i64 %57
  %59 = icmp ult ptr %51, %58
  br i1 %59, label %60, label %69

60:                                               ; preds = %50
  %61 = load ptr, ptr %39, align 8, !tbaa !26
  %62 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %.04967) #6
  %63 = load ptr, ptr %62, align 8, !tbaa !15
  %64 = ptrtoint ptr %61 to i64
  %65 = ptrtoint ptr %63 to i64
  %66 = sub i64 %64, %65
  %67 = sdiv exact i64 %66, 48
  %68 = trunc i64 %67 to i32
  br label %.loopexit

69:                                               ; preds = %50, %.lr.ph
  %70 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %.04967) #6
  %71 = getelementptr inbounds i8, ptr %70, i64 8
  %72 = load i32, ptr %71, align 8, !tbaa !17
  %73 = add i32 %72, %.05066
  %74 = add nuw i64 %.04967, 1
  %75 = tail call noundef i64 @_ZNKSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #6
  %76 = icmp ult i64 %74, %75
  br i1 %76, label %.lr.ph, label %.loopexit, !llvm.loop !28

.loopexit:                                        ; preds = %69, %.preheader, %60
  %.05062 = phi i32 [ %.05066, %60 ], [ 0, %.preheader ], [ %73, %69 ]
  %.051 = phi i32 [ %68, %60 ], [ -1, %.preheader ], [ -1, %69 ]
  %77 = add i32 %.051, %.05062
  %78 = shl i32 %77, 1
  br label %79

79:                                               ; preds = %.loopexit, %30
  %.sink = phi i32 [ %78, %.loopexit ], [ %37, %30 ]
  %80 = getelementptr inbounds i8, ptr %22, i64 24
  store i32 %.sink, ptr %80, align 4, !tbaa !29
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %81 = load i32, ptr %13, align 8, !tbaa !17
  %82 = sext i32 %81 to i64
  %83 = icmp slt i64 %indvars.iv.next82, %82
  br i1 %83, label %.lr.ph70, label %._crit_edge.loopexit, !llvm.loop !31

.loopexit59:                                      ; preds = %._crit_edge, %5, %1
  %.0 = phi ptr [ null, %1 ], [ %8, %5 ], [ %8, %._crit_edge ]
  ret ptr %.0
}

attributes #0 = { 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 #1 = { 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 #2 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { builtin allocsize(0) }
attributes #6 = { nounwind }
attributes #7 = { 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, !14, i64 36}
!6 = !{!"_ZTSN7Riemann15AABBTreeOfflineE", !7, i64 0, !10, i64 8, !14, i64 32, !14, i64 36}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!14 = !{!"int", !8, i64 0}
!15 = !{!16, !7, i64 0}
!16 = !{!"_ZTSN7Riemann15AABBTreeOffline9NodeBlockE", !7, i64 0, !14, i64 8, !14, i64 12}
!17 = !{!16, !14, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !14, i64 44}
!21 = !{!"_ZTSN7Riemann19AABBTreeNodeOfflineE", !22, i64 0, !7, i64 24, !7, i64 32, !14, i64 40, !14, i64 44}
!22 = !{!"_ZTSN5Maths6TAABB3IfEE", !23, i64 0, !23, i64 12}
!23 = !{!"_ZTSN5Maths8TVector3IfEE", !24, i64 0, !24, i64 4, !24, i64 8}
!24 = !{!"float", !8, i64 0}
!25 = !{!21, !14, i64 40}
!26 = !{!21, !7, i64 24}
!27 = !{!21, !7, i64 32}
!28 = distinct !{!28, !19}
!29 = !{!30, !14, i64 24}
!30 = !{!"_ZTSN7Riemann21CacheFriendlyAABBTreeE", !22, i64 0, !14, i64 24}
!31 = distinct !{!31, !19}


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