; LLVM IR from stan-dev/math :: lib/boost_1.84.0/libs/container/src (pool_resource)

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

%struct.boost_container_new_t = type { i8 }
%"class.boost::container::pmr::pool_resource" = type { %"struct.boost::container::pmr::pool_options", ptr, %"class.boost::container::pmr::block_list_base", ptr, i64 }
%"struct.boost::container::pmr::pool_options" = type { i64, i64 }
%"class.boost::container::pmr::block_list_base" = type { %"struct.boost::container::pmr::list_node" }
%"struct.boost::container::pmr::list_node" = type { ptr, ptr }
%"class.boost::container::pmr::pool_data_t" = type { %"class.boost::container::pmr::block_slist_base", %"struct.boost::container::pmr::slist_node", i64 }
%"class.boost::container::pmr::block_slist_base" = type { %"struct.boost::container::pmr::slist_node" }
%"struct.boost::container::pmr::slist_node" = type { ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN5boost9container3pmr13pool_resource15priv_pool_indexEm(i64 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5boost9container3pmr13pool_resource15priv_init_poolsEv(ptr noundef nonnull align 8 dereferenceable(56) %0) #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca %struct.boost_container_new_t, align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %11 = getelementptr inbounds %"class.boost::container::pmr::pool_resource", ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds %"struct.boost::container::pmr::pool_options", ptr %11, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = call noundef i64 @_ZN5boost9container3pmr13pool_resource15priv_pool_indexEm(i64 noundef %13)
  %15 = add i64 %14, 1
  store i64 %15, ptr %3, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store ptr null, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.boost::container::pmr::pool_resource", ptr %10, i32 0, i32 1
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %18 = load i64, ptr %3, align 8, !tbaa !15
  %19 = mul i64 24, %18
  %20 = call noundef ptr @_ZN5boost9container3pmr15memory_resource8allocateEmm(ptr noundef nonnull align 8 dereferenceable(8) %17, i64 noundef %19, i64 noundef 16)
  store ptr %20, ptr %4, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.boost::container::pmr::pool_resource", ptr %10, i32 0, i32 3
  store ptr %21, ptr %22, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %23 = load i64, ptr %3, align 8, !tbaa !15
  store i64 %23, ptr %6, align 8, !tbaa !15
  br label %24

24:                                               ; preds = %36, %1
  %25 = load i64, ptr %5, align 8, !tbaa !15
  %26 = load i64, ptr %6, align 8, !tbaa !15
  %27 = icmp ne i64 %25, %26
  br i1 %27, label %29, label %28

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

29:                                               ; preds = %24
  %30 = getelementptr inbounds %"class.boost::container::pmr::pool_resource", ptr %10, i32 0, i32 3
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  %32 = load i64, ptr %5, align 8, !tbaa !15
  %33 = getelementptr inbounds %"class.boost::container::pmr::pool_data_t", ptr %31, i64 %32
  %34 = call noundef ptr @_ZnwmPv21boost_container_new_t(i64 noundef 24, ptr noundef %33)
  invoke void @_ZN5boost9container3pmr11pool_data_tC2Em(ptr noundef nonnull align 8 dereferenceable(24) %34, i64 noundef 1)
          to label %35 unwind label %39

35:                                               ; preds = %29
  br label %36

36:                                               ; preds = %35
  %37 = load i64, ptr %5, align 8, !tbaa !15
  %38 = add i64 %37, 1
  store i64 %38, ptr %5, align 8, !tbaa !15
  br label %24, !llvm.loop !18

39:                                               ; preds = %29
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %8, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %9, align 4
  call void @_ZdlPvS_21boost_container_new_t(ptr noundef %34, ptr noundef %33) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %46

43:                                               ; preds = %28
  %44 = load i64, ptr %3, align 8, !tbaa !15
  %45 = getelementptr inbounds %"class.boost::container::pmr::pool_resource", ptr %10, i32 0, i32 4
  store i64 %44, ptr %45, align 8, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void

46:                                               ; preds = %39
  %47 = load ptr, ptr %8, align 8
  %48 = load i32, ptr %9, align 4
  %49 = insertvalue { ptr, i32 } poison, ptr %47, 0
  %50 = insertvalue { ptr, i32 } %49, i32 %48, 1
  resume { ptr, i32 } %50
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZnwmPv21boost_container_new_t(i64 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5boost9container3pmr11pool_data_tC2Em(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZdlPvS_21boost_container_new_t(ptr noundef, ptr noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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, !12, i64 8}
!10 = !{!"_ZTSN5boost9container3pmr13pool_resourceE", !11, i64 0, !6, i64 16, !13, i64 24, !6, i64 40, !12, i64 48}
!11 = !{!"_ZTSN5boost9container3pmr12pool_optionsE", !12, i64 0, !12, i64 8}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_ZTSN5boost9container3pmr15block_list_baseINS1_17block_list_headerEEE", !14, i64 0}
!14 = !{!"_ZTSN5boost9container3pmr9list_nodeE", !6, i64 0, !6, i64 8}
!15 = !{!12, !12, i64 0}
!16 = !{!10, !6, i64 16}
!17 = !{!10, !6, i64 40}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!10, !12, i64 48}


; 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.boost::container::pmr::pool_data_t" = type { %"class.boost::container::pmr::block_slist_base", %"struct.boost::container::pmr::slist_node", i64 }
%"class.boost::container::pmr::block_slist_base" = type { %"struct.boost::container::pmr::slist_node" }
%"struct.boost::container::pmr::slist_node" = type { ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN5boost9container3pmr13pool_resource15priv_pool_indexEm(i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5boost9container3pmr13pool_resource15priv_init_poolsEv(ptr nocapture noundef nonnull align 8 dereferenceable(56) %0) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = tail call noundef i64 @_ZN5boost9container3pmr13pool_resource15priv_pool_indexEm(i64 noundef %3)
  %5 = add i64 %4, 1
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !14
  %8 = mul i64 %5, 24
  %9 = tail call noundef ptr @_ZN5boost9container3pmr15memory_resource8allocateEmm(ptr noundef nonnull align 8 dereferenceable(8) %7, i64 noundef %8, i64 noundef 16)
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %9, ptr %10, align 8, !tbaa !15
  %.not12 = icmp eq i64 %5, 0
  br i1 %.not12, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %15, %1
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  store i64 %5, ptr %11, align 8, !tbaa !16
  ret void

.lr.ph:                                           ; preds = %1, %15
  %.013 = phi i64 [ %16, %15 ], [ 0, %1 ]
  %12 = load ptr, ptr %10, align 8, !tbaa !15
  %13 = getelementptr inbounds %"class.boost::container::pmr::pool_data_t", ptr %12, i64 %.013
  %14 = tail call noundef ptr @_ZnwmPv21boost_container_new_t(i64 noundef 24, ptr noundef %13)
  invoke void @_ZN5boost9container3pmr11pool_data_tC2Em(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef 1)
          to label %15 unwind label %17

15:                                               ; preds = %.lr.ph
  %16 = add nuw i64 %.013, 1
  %.not = icmp eq i64 %.013, %4
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !17

17:                                               ; preds = %.lr.ph
  %18 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvS_21boost_container_new_t(ptr noundef %14, ptr noundef %13) #2
  resume { ptr, i32 } %18
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZnwmPv21boost_container_new_t(i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5boost9container3pmr11pool_data_tC2Em(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZdlPvS_21boost_container_new_t(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { 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 #2 = { 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, !8, i64 8}
!6 = !{!"_ZTSN5boost9container3pmr13pool_resourceE", !7, i64 0, !11, i64 16, !12, i64 24, !11, i64 40, !8, i64 48}
!7 = !{!"_ZTSN5boost9container3pmr12pool_optionsE", !8, i64 0, !8, i64 8}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTSN5boost9container3pmr15block_list_baseINS1_17block_list_headerEEE", !13, i64 0}
!13 = !{!"_ZTSN5boost9container3pmr9list_nodeE", !11, i64 0, !11, i64 8}
!14 = !{!6, !11, i64 16}
!15 = !{!6, !11, i64 40}
!16 = !{!6, !8, i64 48}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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