; LLVM IR from stan-dev/math :: lib/boost_1.84.0/libs/container/src (monotonic_buffer_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"

%"class.boost::container::pmr::monotonic_buffer_resource" = type { %"class.boost::container::pmr::memory_resource", %"class.boost::container::pmr::block_slist", ptr, i64, i64, ptr, i64 }
%"class.boost::container::pmr::memory_resource" = type { ptr }
%"class.boost::container::pmr::block_slist" = type { %"class.boost::container::pmr::block_slist_base", ptr }
%"class.boost::container::pmr::block_slist_base" = type { %"struct.boost::container::pmr::slist_node" }
%"struct.boost::container::pmr::slist_node" = type { ptr }

@_ZTVN5boost9container3pmr25monotonic_buffer_resourceE = external dso_local unnamed_addr constant { [7 x ptr] }, align 8

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

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

; Function Attrs: nounwind
declare noundef ptr @_ZN5boost9container3pmr20get_default_resourceEv() #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5boost9container3pmr11block_slistC2ERNS1_15memory_resourceE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #4

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5boost9container3pmr25monotonic_buffer_resourceC2EPvmPNS1_15memory_resourceE(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  call void @_ZN5boost9container3pmr15memory_resourceC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %10) #7
  store ptr getelementptr inbounds inrange(-16, 40) ({ [7 x ptr] }, ptr @_ZTVN5boost9container3pmr25monotonic_buffer_resourceE, i32 0, i32 0, i32 2), ptr %10, align 8, !tbaa !11
  %11 = getelementptr inbounds %"class.boost::container::pmr::monotonic_buffer_resource", ptr %10, i32 0, i32 1
  %12 = load ptr, ptr %8, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %16

14:                                               ; preds = %4
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  br label %18

16:                                               ; preds = %4
  %17 = call noundef ptr @_ZN5boost9container3pmr20get_default_resourceEv() #7
  br label %18

18:                                               ; preds = %16, %14
  %19 = phi ptr [ %15, %14 ], [ %17, %16 ]
  invoke void @_ZN5boost9container3pmr11block_slistC2ERNS1_15memory_resourceE(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(8) %19)
          to label %20 unwind label %35

20:                                               ; preds = %18
  %21 = getelementptr inbounds %"class.boost::container::pmr::monotonic_buffer_resource", ptr %10, i32 0, i32 2
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %22, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds %"class.boost::container::pmr::monotonic_buffer_resource", ptr %10, i32 0, i32 3
  %24 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %24, ptr %23, align 8, !tbaa !19
  %25 = getelementptr inbounds %"class.boost::container::pmr::monotonic_buffer_resource", ptr %10, i32 0, i32 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 256, ptr %9, align 8, !tbaa !9
  %26 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN5boost9container3dtl9max_valueImEERKT_S5_S5_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %27 unwind label %35

27:                                               ; preds = %20
  %28 = load i64, ptr %26, align 8, !tbaa !9
  %29 = invoke noundef i64 @_ZN5boost9intrusive6detail22previous_or_equal_pow2Em(i64 noundef %28)
          to label %30 unwind label %35

30:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  store i64 %29, ptr %25, align 8, !tbaa !20
  %31 = getelementptr inbounds %"class.boost::container::pmr::monotonic_buffer_resource", ptr %10, i32 0, i32 5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %32, ptr %31, align 8, !tbaa !21
  %33 = getelementptr inbounds %"class.boost::container::pmr::monotonic_buffer_resource", ptr %10, i32 0, i32 6
  %34 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %34, ptr %33, align 8, !tbaa !22
  call void @_ZN5boost9container3pmr25monotonic_buffer_resource20increase_next_bufferEv(ptr noundef nonnull align 8 dereferenceable(64) %10)
  ret void

35:                                               ; preds = %27, %20, %18
  %36 = landingpad { ptr, i32 }
          catch ptr null
  %37 = extractvalue { ptr, i32 } %36, 0
  call void @__clang_call_terminate(ptr %37) #8
  unreachable
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZN5boost9intrusive6detail22previous_or_equal_pow2Em(i64 noundef) #5

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

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

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

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 = { 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 "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 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 = { noinline noreturn nounwind uwtable "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 = { inlinehint 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !6, i64 24}
!14 = !{!"_ZTSN5boost9container3pmr25monotonic_buffer_resourceE", !15, i64 0, !16, i64 8, !6, i64 24, !10, i64 32, !10, i64 40, !6, i64 48, !10, i64 56}
!15 = !{!"_ZTSN5boost9container3pmr15memory_resourceE"}
!16 = !{!"_ZTSN5boost9container3pmr11block_slistE", !17, i64 0, !6, i64 8}
!17 = !{!"_ZTSN5boost9container3pmr16block_slist_baseINS1_18block_slist_headerEEE", !18, i64 0}
!18 = !{!"_ZTSN5boost9container3pmr10slist_nodeE", !6, i64 0}
!19 = !{!14, !10, i64 32}
!20 = !{!14, !10, i64 40}
!21 = !{!14, !6, i64 48}
!22 = !{!14, !10, i64 56}


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

@_ZTVN5boost9container3pmr25monotonic_buffer_resourceE = external dso_local unnamed_addr constant { [7 x ptr] }, align 8

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

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

; Function Attrs: nounwind
declare noundef ptr @_ZN5boost9container3pmr20get_default_resourceEv() local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5boost9container3pmr11block_slistC2ERNS1_15memory_resourceE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5boost9container3pmr25monotonic_buffer_resourceC2EPvmPNS1_15memory_resourceE(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  store i64 %2, ptr %5, align 8, !tbaa !5
  tail call void @_ZN5boost9container3pmr15memory_resourceC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #7
  store ptr getelementptr inbounds inrange(-16, 40) (i8, ptr @_ZTVN5boost9container3pmr25monotonic_buffer_resourceE, i64 16), ptr %0, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %8, label %10

8:                                                ; preds = %4
  %9 = tail call noundef ptr @_ZN5boost9container3pmr20get_default_resourceEv() #7
  br label %10

10:                                               ; preds = %4, %8
  %11 = phi ptr [ %9, %8 ], [ %3, %4 ]
  invoke void @_ZN5boost9container3pmr11block_slistC2ERNS1_15memory_resourceE(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %12 unwind label %23

12:                                               ; preds = %10
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %1, ptr %13, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %2, ptr %14, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  store i64 256, ptr %6, align 8, !tbaa !5
  %15 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5boost9container3dtl9max_valueImEERKT_S5_S5_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = invoke noundef i64 @_ZN5boost9intrusive6detail22previous_or_equal_pow2Em(i64 noundef %16)
          to label %18 unwind label %23

18:                                               ; preds = %12
  %19 = getelementptr inbounds i8, ptr %0, i64 40
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  store i64 %17, ptr %19, align 8, !tbaa !19
  %20 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr %1, ptr %20, align 8, !tbaa !20
  %21 = getelementptr inbounds i8, ptr %0, i64 56
  %22 = load i64, ptr %5, align 8, !tbaa !5
  store i64 %22, ptr %21, align 8, !tbaa !21
  call void @_ZN5boost9container3pmr25monotonic_buffer_resource20increase_next_bufferEv(ptr noundef nonnull align 8 dereferenceable(64) %0)
  ret void

23:                                               ; preds = %12, %10
  %24 = landingpad { ptr, i32 }
          catch ptr null
  %25 = extractvalue { ptr, i32 } %24, 0
  call void @__clang_call_terminate(ptr %25) #8
  unreachable
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZN5boost9intrusive6detail22previous_or_equal_pow2Em(i64 noundef) local_unnamed_addr #5

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

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

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

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 = { 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 "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 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 = { noinline noreturn nounwind uwtable "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 = { inlinehint 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !17, i64 24}
!12 = !{!"_ZTSN5boost9container3pmr25monotonic_buffer_resourceE", !13, i64 0, !14, i64 8, !17, i64 24, !6, i64 32, !6, i64 40, !17, i64 48, !6, i64 56}
!13 = !{!"_ZTSN5boost9container3pmr15memory_resourceE"}
!14 = !{!"_ZTSN5boost9container3pmr11block_slistE", !15, i64 0, !17, i64 8}
!15 = !{!"_ZTSN5boost9container3pmr16block_slist_baseINS1_18block_slist_headerEEE", !16, i64 0}
!16 = !{!"_ZTSN5boost9container3pmr10slist_nodeE", !17, i64 0}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!12, !6, i64 32}
!19 = !{!12, !6, i64 40}
!20 = !{!12, !17, i64 48}
!21 = !{!12, !6, i64 56}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass