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

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.Maths::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }
%"class.Maths::TVector3" = type { float, float, float }
%"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 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #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 uwtable
define dso_local void @_ZN7Riemann15DynamicAABBTree10RemoveLeafEi(ptr noundef nonnull align 8 dereferenceable(44) %0, i32 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"class.Maths::TAABB3", align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %11 = load ptr, ptr %3, align 8
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = icmp eq i32 %12, %14
  br i1 %15, label %16, label %18

16:                                               ; preds = %2
  %17 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 0
  store i32 -1, ptr %17, align 8, !tbaa !11
  br label %158

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %19 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %21) #4
  %23 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !17
  store i32 %24, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %25 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %27) #4
  %29 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !17
  store i32 %30, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %31 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %31, i64 noundef %33) #4
  %35 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %34, i32 0, i32 2
  %36 = load i32, ptr %35, align 4, !tbaa !18
  %37 = load i32, ptr %4, align 4, !tbaa !9
  %38 = icmp eq i32 %36, %37
  br i1 %38, label %39, label %46

39:                                               ; preds = %18
  %40 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %40, i64 noundef %42) #4
  %44 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %43, i32 0, i32 3
  %45 = load i32, ptr %44, align 8, !tbaa !24
  store i32 %45, ptr %7, align 4, !tbaa !9
  br label %53

46:                                               ; preds = %18
  %47 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %48 = load i32, ptr %5, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %47, i64 noundef %49) #4
  %51 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 4, !tbaa !18
  store i32 %52, ptr %7, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %46, %39
  %54 = phi i32 [ %45, %39 ], [ %52, %46 ]
  store i32 %54, ptr %7, align 4, !tbaa !9
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = icmp ne i32 %55, -1
  br i1 %56, label %57, label %148

57:                                               ; preds = %53
  %58 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %59 = load i32, ptr %6, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %58, i64 noundef %60) #4
  %62 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %61, i32 0, i32 2
  %63 = load i32, ptr %62, align 4, !tbaa !18
  %64 = load i32, ptr %5, align 4, !tbaa !9
  %65 = icmp eq i32 %63, %64
  br i1 %65, label %66, label %73

66:                                               ; preds = %57
  %67 = load i32, ptr %7, align 4, !tbaa !9
  %68 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %68, i64 noundef %70) #4
  %72 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %71, i32 0, i32 2
  store i32 %67, ptr %72, align 4, !tbaa !18
  br label %80

73:                                               ; preds = %57
  %74 = load i32, ptr %7, align 4, !tbaa !9
  %75 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %76 = load i32, ptr %6, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %75, i64 noundef %77) #4
  %79 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %78, i32 0, i32 3
  store i32 %74, ptr %79, align 8, !tbaa !24
  br label %80

80:                                               ; preds = %73, %66
  %81 = load i32, ptr %6, align 4, !tbaa !9
  %82 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %83 = load i32, ptr %7, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %82, i64 noundef %84) #4
  %86 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %85, i32 0, i32 0
  store i32 %81, ptr %86, align 8, !tbaa !17
  %87 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN7Riemann15DynamicAABBTree8FreeNodeEi(ptr noundef nonnull align 8 dereferenceable(44) %11, i32 noundef %87)
  %88 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %88, ptr %7, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %92, %80
  %90 = load i32, ptr %7, align 4, !tbaa !9
  %91 = icmp ne i32 %90, -1
  br i1 %91, label %92, label %147

92:                                               ; preds = %89
  %93 = load i32, ptr %7, align 4, !tbaa !9
  %94 = call noundef i32 @_ZN7Riemann15DynamicAABBTree7BalanceEi(ptr noundef nonnull align 8 dereferenceable(44) %11, i32 noundef %93)
  store i32 %94, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %95 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %96 = load i32, ptr %7, align 4, !tbaa !9
  %97 = sext i32 %96 to i64
  %98 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %95, i64 noundef %97) #4
  %99 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %98, i32 0, i32 2
  %100 = load i32, ptr %99, align 4, !tbaa !18
  store i32 %100, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %101 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %102 = load i32, ptr %7, align 4, !tbaa !9
  %103 = sext i32 %102 to i64
  %104 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %101, i64 noundef %103) #4
  %105 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %104, i32 0, i32 3
  %106 = load i32, ptr %105, align 8, !tbaa !24
  store i32 %106, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #4
  %107 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %108 = load i32, ptr %8, align 4, !tbaa !9
  %109 = sext i32 %108 to i64
  %110 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %107, i64 noundef %109) #4
  %111 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %110, i32 0, i32 1
  %112 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %113 = load i32, ptr %9, align 4, !tbaa !9
  %114 = sext i32 %113 to i64
  %115 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %112, i64 noundef %114) #4
  %116 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %115, i32 0, i32 1
  call void @_ZN5Maths6TAABB3IfEC2ERKS1_S3_(ptr noundef nonnull align 4 dereferenceable(24) %10, ptr noundef nonnull align 4 dereferenceable(24) %111, ptr noundef nonnull align 4 dereferenceable(24) %116)
  %117 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %118 = load i32, ptr %7, align 4, !tbaa !9
  %119 = sext i32 %118 to i64
  %120 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %117, i64 noundef %119) #4
  %121 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %120, i32 0, i32 1
  %122 = call noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(24) %121, ptr noundef nonnull align 4 dereferenceable(24) %10)
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #4
  %123 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %124 = load i32, ptr %8, align 4, !tbaa !9
  %125 = sext i32 %124 to i64
  %126 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %123, i64 noundef %125) #4
  %127 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %126, i32 0, i32 4
  %128 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %129 = load i32, ptr %9, align 4, !tbaa !9
  %130 = sext i32 %129 to i64
  %131 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %128, i64 noundef %130) #4
  %132 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %131, i32 0, i32 4
  %133 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %127, ptr noundef nonnull align 4 dereferenceable(4) %132)
  %134 = load i32, ptr %133, align 4, !tbaa !9
  %135 = add nsw i32 1, %134
  %136 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %137 = load i32, ptr %7, align 4, !tbaa !9
  %138 = sext i32 %137 to i64
  %139 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %136, i64 noundef %138) #4
  %140 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %139, i32 0, i32 4
  store i32 %135, ptr %140, align 4, !tbaa !25
  %141 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %142 = load i32, ptr %7, align 4, !tbaa !9
  %143 = sext i32 %142 to i64
  %144 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %141, i64 noundef %143) #4
  %145 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %144, i32 0, i32 0
  %146 = load i32, ptr %145, align 8, !tbaa !17
  store i32 %146, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %89, !llvm.loop !26

147:                                              ; preds = %89
  br label %157

148:                                              ; preds = %53
  %149 = load i32, ptr %7, align 4, !tbaa !9
  %150 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 0
  store i32 %149, ptr %150, align 8, !tbaa !11
  %151 = getelementptr inbounds %"class.Riemann::DynamicAABBTree", ptr %11, i32 0, i32 2
  %152 = load i32, ptr %7, align 4, !tbaa !9
  %153 = sext i32 %152 to i64
  %154 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %151, i64 noundef %153) #4
  %155 = getelementptr inbounds %"struct.Riemann::DynamicAABBTree::Node", ptr %154, i32 0, i32 0
  store i32 -1, ptr %155, align 8, !tbaa !17
  %156 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN7Riemann15DynamicAABBTree8FreeNodeEi(ptr noundef nonnull align 8 dereferenceable(44) %11, i32 noundef %156)
  br label %157

157:                                              ; preds = %148, %147
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %158

158:                                              ; preds = %157, %16
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann15DynamicAABBTree8FreeNodeEi(ptr noundef nonnull align 8 dereferenceable(44), i32 noundef) #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)) #0 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7Riemann15DynamicAABBTree7BalanceEi(ptr noundef nonnull align 8 dereferenceable(44), i32 noundef) #2 align 2

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 = { 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 #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 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN7Riemann15DynamicAABBTreeE", !10, i64 0, !13, i64 8, !10, i64 32, !10, i64 36, !10, i64 40}
!13 = !{!"_ZTSSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIN7Riemann15DynamicAABBTree4NodeESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15DynamicAABBTree4NodeESaIS2_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15DynamicAABBTree4NodeESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !10, i64 28}
!19 = !{!"_ZTSN7Riemann15DynamicAABBTree4NodeE", !7, i64 0, !20, i64 4, !10, i64 28, !10, i64 32, !10, i64 36, !6, i64 40, !23, i64 48}
!20 = !{!"_ZTSN5Maths6TAABB3IfEE", !21, i64 0, !21, i64 12}
!21 = !{!"_ZTSN5Maths8TVector3IfEE", !22, i64 0, !22, i64 4, !22, i64 8}
!22 = !{!"float", !7, i64 0}
!23 = !{!"bool", !7, i64 0}
!24 = !{!19, !10, i64 32}
!25 = !{!19, !10, i64 36}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.Maths::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }
%"class.Maths::TVector3" = type { float, float, float }

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Riemann15DynamicAABBTree10RemoveLeafEi(ptr noundef nonnull align 8 dereferenceable(44) %0, i32 noundef %1) local_unnamed_addr #2 align 2 {
  %3 = alloca %"class.Maths::TAABB3", align 4
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = icmp eq i32 %4, %1
  br i1 %5, label %6, label %7

6:                                                ; preds = %2
  store i32 -1, ptr %0, align 8, !tbaa !5
  br label %.loopexit

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = sext i32 %1 to i64
  %10 = tail call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %9) #4
  %11 = load i32, ptr %10, align 8, !tbaa !15
  %12 = sext i32 %11 to i64
  %13 = tail call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %12) #4
  %14 = load i32, ptr %13, align 8, !tbaa !15
  %15 = tail call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %12) #4
  %16 = getelementptr inbounds i8, ptr %15, i64 28
  %17 = load i32, ptr %16, align 4, !tbaa !16
  %18 = icmp eq i32 %17, %1
  %19 = tail call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %12) #4
  %. = select i1 %18, i64 32, i64 28
  %20 = getelementptr inbounds i8, ptr %19, i64 %.
  %21 = load i32, ptr %20, align 4, !tbaa !22
  %.not = icmp eq i32 %14, -1
  br i1 %.not, label %63, label %22

22:                                               ; preds = %7
  %23 = sext i32 %14 to i64
  %24 = tail call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %23) #4
  %25 = getelementptr inbounds i8, ptr %24, i64 28
  %26 = load i32, ptr %25, align 4, !tbaa !16
  %27 = icmp eq i32 %26, %11
  %28 = tail call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %23) #4
  br i1 %27, label %29, label %31

29:                                               ; preds = %22
  %30 = getelementptr inbounds i8, ptr %28, i64 28
  store i32 %21, ptr %30, align 4, !tbaa !16
  br label %.lr.ph.preheader

31:                                               ; preds = %22
  %32 = getelementptr inbounds i8, ptr %28, i64 32
  store i32 %21, ptr %32, align 8, !tbaa !23
  br label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %29, %31
  %33 = sext i32 %21 to i64
  %34 = tail call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %33) #4
  store i32 %14, ptr %34, align 8, !tbaa !15
  tail call void @_ZN7Riemann15DynamicAABBTree8FreeNodeEi(ptr noundef nonnull align 8 dereferenceable(44) %0, i32 noundef %11)
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.036 = phi i32 [ %62, %.lr.ph ], [ %14, %.lr.ph.preheader ]
  %35 = call noundef i32 @_ZN7Riemann15DynamicAABBTree7BalanceEi(ptr noundef nonnull align 8 dereferenceable(44) %0, i32 noundef %.036)
  %36 = sext i32 %35 to i64
  %37 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %36) #4
  %38 = getelementptr inbounds i8, ptr %37, i64 28
  %39 = load i32, ptr %38, align 4, !tbaa !16
  %40 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %36) #4
  %41 = getelementptr inbounds i8, ptr %40, i64 32
  %42 = load i32, ptr %41, align 8, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #4
  %43 = sext i32 %39 to i64
  %44 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %43) #4
  %45 = getelementptr inbounds i8, ptr %44, i64 4
  %46 = sext i32 %42 to i64
  %47 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %46) #4
  %48 = getelementptr inbounds i8, ptr %47, i64 4
  call void @_ZN5Maths6TAABB3IfEC2ERKS1_S3_(ptr noundef nonnull align 4 dereferenceable(24) %3, ptr noundef nonnull align 4 dereferenceable(24) %45, ptr noundef nonnull align 4 dereferenceable(24) %48)
  %49 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %36) #4
  %50 = getelementptr inbounds i8, ptr %49, i64 4
  %51 = call noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(24) %50, ptr noundef nonnull align 4 dereferenceable(24) %3)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #4
  %52 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %43) #4
  %53 = getelementptr inbounds i8, ptr %52, i64 36
  %54 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %46) #4
  %55 = getelementptr inbounds i8, ptr %54, i64 36
  %56 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %53, ptr noundef nonnull align 4 dereferenceable(4) %55)
  %57 = load i32, ptr %56, align 4, !tbaa !22
  %58 = add nsw i32 %57, 1
  %59 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %36) #4
  %60 = getelementptr inbounds i8, ptr %59, i64 36
  store i32 %58, ptr %60, align 4, !tbaa !24
  %61 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %36) #4
  %62 = load i32, ptr %61, align 8, !tbaa !15
  %.not34 = icmp eq i32 %62, -1
  br i1 %.not34, label %.loopexit, label %.lr.ph, !llvm.loop !25

63:                                               ; preds = %7
  store i32 %21, ptr %0, align 8, !tbaa !5
  %64 = sext i32 %21 to i64
  %65 = tail call noundef nonnull align 8 dereferenceable(49) ptr @_ZNSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %64) #4
  store i32 -1, ptr %65, align 8, !tbaa !15
  tail call void @_ZN7Riemann15DynamicAABBTree8FreeNodeEi(ptr noundef nonnull align 8 dereferenceable(44) %0, i32 noundef %11)
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %63, %6
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann15DynamicAABBTree8FreeNodeEi(ptr noundef nonnull align 8 dereferenceable(44), i32 noundef) 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: mustprogress uwtable
declare dso_local void @_ZN5Maths6TAABB3IfEC2ERKS1_S3_(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(24)) unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7Riemann15DynamicAABBTree7BalanceEi(ptr noundef nonnull align 8 dereferenceable(44), i32 noundef) local_unnamed_addr #2 align 2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 = !{!"_ZTSN7Riemann15DynamicAABBTreeE", !7, i64 0, !10, i64 8, !7, i64 32, !7, i64 36, !7, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIN7Riemann15DynamicAABBTree4NodeESaIS2_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIN7Riemann15DynamicAABBTree4NodeESaIS2_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15DynamicAABBTree4NodeESaIS2_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15DynamicAABBTree4NodeESaIS2_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!8, !8, i64 0}
!16 = !{!17, !7, i64 28}
!17 = !{!"_ZTSN7Riemann15DynamicAABBTree4NodeE", !8, i64 0, !18, i64 4, !7, i64 28, !7, i64 32, !7, i64 36, !14, i64 40, !21, i64 48}
!18 = !{!"_ZTSN5Maths6TAABB3IfEE", !19, i64 0, !19, i64 12}
!19 = !{!"_ZTSN5Maths8TVector3IfEE", !20, i64 0, !20, i64 4, !20, i64 8}
!20 = !{!"float", !8, i64 0}
!21 = !{!"bool", !8, i64 0}
!22 = !{!7, !7, i64 0}
!23 = !{!17, !7, i64 32}
!24 = !{!17, !7, i64 36}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass