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

; 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 }

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7Riemann15AABBTreeOffline7ReleaseEv(ptr noundef nonnull align 8 dereferenceable(40) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %6

6:                                                ; preds = %33, %1
  %7 = load i64, ptr %3, align 8, !tbaa !9
  %8 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %5, i32 0, i32 1
  %9 = call noundef i64 @_ZNKSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #3
  %10 = icmp ult i64 %7, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %36

12:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %13 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %5, i32 0, i32 1
  %14 = load i64, ptr %3, align 8, !tbaa !9
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %14) #3
  store ptr %15, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.Riemann::AABBTreeOffline::NodeBlock", ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = icmp eq ptr %18, null
  br i1 %19, label %32, label %20

20:                                               ; preds = %12
  %21 = getelementptr inbounds i8, ptr %18, i64 -8
  %22 = load i64, ptr %21, align 8
  %23 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %18, i64 %22
  %24 = icmp eq ptr %18, %23
  br i1 %24, label %29, label %25

25:                                               ; preds = %25, %20
  %26 = phi ptr [ %23, %20 ], [ %27, %25 ]
  %27 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %26, i64 -1
  call void @_ZN7Riemann19AABBTreeNodeOfflineD2Ev(ptr noundef nonnull align 8 dereferenceable(48) %27) #3
  %28 = icmp eq ptr %27, %18
  br i1 %28, label %29, label %25

29:                                               ; preds = %25, %20
  %30 = mul i64 48, %22
  %31 = add i64 %30, 8
  call void @_ZdaPvm(ptr noundef %21, i64 noundef %31) #4
  br label %32

32:                                               ; preds = %29, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %33

33:                                               ; preds = %32
  %34 = load i64, ptr %3, align 8, !tbaa !9
  %35 = add i64 %34, 1
  store i64 %35, ptr %3, align 8, !tbaa !9
  br label %6, !llvm.loop !14

36:                                               ; preds = %11
  %37 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %5, i32 0, i32 1
  call void @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %37) #3
  %38 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %5, i32 0, i32 2
  store i32 0, ptr %38, align 8, !tbaa !16
  %39 = getelementptr inbounds %"class.Riemann::AABBTreeOffline", ptr %5, i32 0, i32 3
  store i32 0, ptr %39, align 4, !tbaa !22
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann19AABBTreeNodeOfflineD2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPvm(ptr noundef, i64 noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nobuiltin 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 = { nounwind }
attributes #4 = { builtin 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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN7Riemann15AABBTreeOffline9NodeBlockE", !6, i64 0, !13, i64 8, !13, i64 12}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !13, i64 32}
!17 = !{!"_ZTSN7Riemann15AABBTreeOfflineE", !6, i64 0, !18, i64 8, !13, i64 32, !13, i64 36}
!18 = !{!"_ZTSSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!22 = !{!17, !13, i64 36}


; 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 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7Riemann15AABBTreeOffline7ReleaseEv(ptr noundef nonnull align 8 dereferenceable(40) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = tail call noundef i64 @_ZNKSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #2
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %19, %1
  tail call void @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #2
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 0, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 0, ptr %5, align 4, !tbaa !15
  ret void

.lr.ph:                                           ; preds = %1, %19
  %.06 = phi i64 [ %20, %19 ], [ 0, %1 ]
  %6 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.06) #2
  %7 = load ptr, ptr %6, align 8, !tbaa !16
  %8 = icmp eq ptr %7, null
  br i1 %8, label %19, label %9

9:                                                ; preds = %.lr.ph
  %10 = getelementptr inbounds i8, ptr %7, i64 -8
  %11 = load i64, ptr %10, align 8
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %9
  %13 = getelementptr inbounds %"class.Riemann::AABBTreeNodeOffline", ptr %7, i64 %11
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %14 = phi ptr [ %15, %.preheader ], [ %13, %.preheader.preheader ]
  %15 = getelementptr inbounds i8, ptr %14, i64 -48
  tail call void @_ZN7Riemann19AABBTreeNodeOfflineD2Ev(ptr noundef nonnull align 8 dereferenceable(48) %15) #2
  %16 = icmp eq ptr %15, %7
  br i1 %16, label %.loopexit, label %.preheader

.loopexit:                                        ; preds = %.preheader, %9
  %17 = mul i64 %11, 48
  %18 = or disjoint i64 %17, 8
  tail call void @_ZdaPvm(ptr noundef nonnull %10, i64 noundef %18) #3
  br label %19

19:                                               ; preds = %.loopexit, %.lr.ph
  %20 = add nuw i64 %.06, 1
  %21 = tail call noundef i64 @_ZNKSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #2
  %22 = icmp ult i64 %20, %21
  br i1 %22, label %.lr.ph, label %._crit_edge, !llvm.loop !18
}

; 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: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann19AABBTreeNodeOfflineD2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #0 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN7Riemann15AABBTreeOffline9NodeBlockESaIS2_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 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 = { nobuiltin 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 = { nounwind }
attributes #3 = { builtin 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 32}
!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 = !{!6, !14, i64 36}
!16 = !{!17, !7, i64 0}
!17 = !{!"_ZTSN7Riemann15AABBTreeOffline9NodeBlockE", !7, i64 0, !14, i64 8, !14, i64 12}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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