; LLVM IR from stan-dev/math :: lib/tbb_2020.3/src/test/test_malloc_pools.ll (Z14TestSharedPoolv)

; 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.tbb::atomic" = type { %"struct.tbb::internal::atomic_impl_with_arithmetic" }
%"struct.tbb::internal::atomic_impl_with_arithmetic" = type { %"struct.tbb::internal::atomic_impl" }
%"struct.tbb::internal::atomic_impl" = type { %"struct.tbb::internal::aligned_storage" }
%"struct.tbb::internal::aligned_storage" = type { i32 }
%"struct.rml::MemPoolPolicy" = type { ptr, ptr, i64, i32, i32 }
%class.SharedPoolRun = type { i8 }

@.str.20 = external hidden unnamed_addr constant [93 x i8], align 1
@_ZL11liveRegions = external hidden global %"struct.tbb::atomic", align 4
@.str.23 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [36 x i8], align 1
@_ZL9MaxThread = external hidden global i32, align 4
@_ZL9MinThread = external hidden global i32, align 4
@.str.30 = external hidden unnamed_addr constant [8 x i8], align 1

; 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 uwtable
declare dso_local void @_Z11ReportErrorPKciS0_S0_(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL12getMallocMemlRm(i64 noundef, ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL12putMallocMemlPvm(i64 noundef, ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rml13MemPoolPolicyC2EPFPvlRmEPFilS1_mEmbb(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef, i64 noundef, i1 noundef zeroext, i1 noundef zeroext) unnamed_addr #2 align 2

declare noundef i32 @_ZN3rml14pool_create_v1ElPKNS_13MemPoolPolicyEPPNS_10MemoryPoolE(i64 noundef, ptr noundef, ptr noundef) #3

declare noundef ptr @_ZN3rml11pool_mallocEPNS_10MemoryPoolEm(ptr noundef, i64 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4)) #1 align 2

declare noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z14TestSharedPoolv() #1 {
  %1 = alloca %"struct.rml::MemPoolPolicy", align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %class.SharedPoolRun, align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 32, ptr %1) #7
  call void @_ZN3rml13MemPoolPolicyC2EPFPvlRmEPFilS1_mEmbb(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef @_ZL12getMallocMemlRm, ptr noundef @_ZL12putMallocMemlPvm, i64 noundef 0, i1 noundef zeroext false, i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  %11 = call noundef i32 @_ZN3rml14pool_create_v1ElPKNS_13MemPoolPolicyEPPNS_10MemoryPoolE(i64 noundef 0, ptr noundef %1, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  %12 = load i32, ptr @_ZL9MaxThread, align 4, !tbaa !5
  %13 = mul nsw i32 %12, 100
  %14 = sext i32 %13 to i64
  %15 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %14, i64 8)
  %16 = extractvalue { i64, i1 } %15, 1
  %17 = extractvalue { i64, i1 } %15, 0
  %18 = select i1 %16, i64 -1, i64 %17
  %19 = call noalias noundef nonnull ptr @_Znam(i64 noundef %18) #8
  store ptr %19, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %20 = load i32, ptr @_ZL9MaxThread, align 4, !tbaa !5
  %21 = mul nsw i32 %20, 100
  %22 = sext i32 %21 to i64
  %23 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %22, i64 8)
  %24 = extractvalue { i64, i1 } %23, 1
  %25 = extractvalue { i64, i1 } %23, 0
  %26 = select i1 %24, i64 -1, i64 %25
  %27 = call noalias noundef nonnull ptr @_Znam(i64 noundef %26) #8
  store ptr %27, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %28 = load i32, ptr @_ZL9MinThread, align 4, !tbaa !5
  store i32 %28, ptr %5, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %68, %0
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = load i32, ptr @_ZL9MaxThread, align 4, !tbaa !5
  %32 = icmp sle i32 %30, %31
  br i1 %32, label %34, label %33

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

34:                                               ; preds = %29
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = load ptr, ptr %2, align 8, !tbaa !9
  %37 = load ptr, ptr %3, align 8, !tbaa !9
  %38 = load ptr, ptr %4, align 8, !tbaa !9
  call void @_ZN13SharedPoolRun4initEiPN3rml10MemoryPoolEPPvS4_(i32 noundef %35, ptr noundef %36, ptr noundef %37, ptr noundef %38)
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %39 = load ptr, ptr %2, align 8, !tbaa !9
  %40 = call noundef ptr @_ZN3rml11pool_mallocEPNS_10MemoryPoolEm(ptr noundef %39, i64 noundef 10485760)
  store ptr %40, ptr %8, align 8, !tbaa !9
  %41 = load ptr, ptr %8, align 8, !tbaa !9
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %44

43:                                               ; preds = %34
  br label %45

44:                                               ; preds = %34
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 179, ptr noundef @.str.30, ptr noundef null)
  br label %45

45:                                               ; preds = %44, %43
  %46 = load i32, ptr %5, align 4, !tbaa !5
  call void @_Z17NativeParallelForIi13SharedPoolRunEvT_RKT0_(i32 noundef %46, ptr noundef nonnull align 1 dereferenceable(1) %7)
  %47 = load ptr, ptr %2, align 8, !tbaa !9
  %48 = load ptr, ptr %8, align 8, !tbaa !9
  %49 = call noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef %47, ptr noundef %48)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %64, %45
  %51 = load i32, ptr %9, align 4, !tbaa !5
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = mul nsw i32 %52, 100
  %54 = icmp slt i32 %51, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %50
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %67

56:                                               ; preds = %50
  %57 = load ptr, ptr %2, align 8, !tbaa !9
  %58 = load ptr, ptr %4, align 8, !tbaa !9
  %59 = load i32, ptr %9, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds ptr, ptr %58, i64 %60
  %62 = load ptr, ptr %61, align 8, !tbaa !9
  %63 = call noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef %57, ptr noundef %62)
  br label %64

64:                                               ; preds = %56
  %65 = load i32, ptr %9, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %9, align 4, !tbaa !5
  br label %50, !llvm.loop !11

67:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #7
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %5, align 4, !tbaa !5
  br label %29, !llvm.loop !13

71:                                               ; preds = %33
  %72 = load ptr, ptr %4, align 8, !tbaa !9
  %73 = icmp eq ptr %72, null
  br i1 %73, label %75, label %74

74:                                               ; preds = %71
  call void @_ZdaPv(ptr noundef %72) #9
  br label %75

75:                                               ; preds = %74, %71
  %76 = load ptr, ptr %3, align 8, !tbaa !9
  %77 = icmp eq ptr %76, null
  br i1 %77, label %79, label %78

78:                                               ; preds = %75
  call void @_ZdaPv(ptr noundef %76) #9
  br label %79

79:                                               ; preds = %78, %75
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #7
  %80 = load ptr, ptr %2, align 8, !tbaa !9
  %81 = call noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef %80)
  %82 = zext i1 %81 to i8
  store i8 %82, ptr %10, align 1, !tbaa !14
  %83 = load i8, ptr %10, align 1, !tbaa !14, !range !16, !noundef !17
  %84 = trunc i8 %83 to i1
  br i1 %84, label %85, label %86

85:                                               ; preds = %79
  br label %87

86:                                               ; preds = %79
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 191, ptr noundef @.str.23, ptr noundef null)
  br label %87

87:                                               ; preds = %86, %85
  %88 = call noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) @_ZL11liveRegions)
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %91, label %90

90:                                               ; preds = %87
  br label %92

91:                                               ; preds = %87
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 192, ptr noundef @.str.26, ptr noundef @.str.27)
  br label %92

92:                                               ; preds = %91, %90
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %1) #7
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #4

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13SharedPoolRun4initEiPN3rml10MemoryPoolEPPvS4_(i32 noundef, ptr noundef, ptr noundef, ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z17NativeParallelForIi13SharedPoolRunEvT_RKT0_(i32 noundef, ptr noundef nonnull align 1 dereferenceable(1)) #1

declare noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef, ptr noundef) #3

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { "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 nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}


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

%"struct.tbb::atomic" = type { %"struct.tbb::internal::atomic_impl_with_arithmetic" }
%"struct.tbb::internal::atomic_impl_with_arithmetic" = type { %"struct.tbb::internal::atomic_impl" }
%"struct.tbb::internal::atomic_impl" = type { %"struct.tbb::internal::aligned_storage" }
%"struct.tbb::internal::aligned_storage" = type { i32 }
%"struct.rml::MemPoolPolicy" = type { ptr, ptr, i64, i32, i32 }
%class.SharedPoolRun = type { i8 }

@.str.20 = external hidden unnamed_addr constant [93 x i8], align 1
@_ZL11liveRegions = external hidden global %"struct.tbb::atomic", align 4
@.str.23 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [36 x i8], align 1
@_ZL9MaxThread = external hidden local_unnamed_addr global i32, align 4
@_ZL9MinThread = external hidden local_unnamed_addr global i32, align 4
@.str.30 = external hidden unnamed_addr constant [8 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11ReportErrorPKciS0_S0_(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL12getMallocMemlRm(i64 noundef, ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL12putMallocMemlPvm(i64 noundef, ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rml13MemPoolPolicyC2EPFPvlRmEPFilS1_mEmbb(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef, i64 noundef, i1 noundef zeroext, i1 noundef zeroext) unnamed_addr #2 align 2

declare noundef i32 @_ZN3rml14pool_create_v1ElPKNS_13MemPoolPolicyEPPNS_10MemoryPoolE(i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare noundef ptr @_ZN3rml11pool_mallocEPNS_10MemoryPoolEm(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

declare noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z14TestSharedPoolv() local_unnamed_addr #1 {
  %1 = alloca %"struct.rml::MemPoolPolicy", align 8
  %2 = alloca ptr, align 8
  %3 = alloca %class.SharedPoolRun, align 1
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #6
  call void @_ZN3rml13MemPoolPolicyC2EPFPvlRmEPFilS1_mEmbb(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull @_ZL12getMallocMemlRm, ptr noundef nonnull @_ZL12putMallocMemlPvm, i64 noundef 0, i1 noundef zeroext false, i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %4 = call noundef i32 @_ZN3rml14pool_create_v1ElPKNS_13MemPoolPolicyEPPNS_10MemoryPoolE(i64 noundef 0, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %5 = load i32, ptr @_ZL9MaxThread, align 4, !tbaa !5
  %6 = mul nsw i32 %5, 100
  %7 = sext i32 %6 to i64
  %8 = icmp slt i32 %5, 0
  %9 = shl nsw i64 %7, 3
  %10 = select i1 %8, i64 -1, i64 %9
  %11 = call noalias noundef nonnull ptr @_Znam(i64 noundef %10) #7
  %12 = call noalias noundef nonnull ptr @_Znam(i64 noundef %10) #7
  %13 = load i32, ptr @_ZL9MinThread, align 4, !tbaa !5
  %.not19 = icmp sgt i32 %13, %5
  br i1 %.not19, label %._crit_edge23, label %.lr.ph22.preheader

.lr.ph22.preheader:                               ; preds = %0
  %14 = sext i32 %13 to i64
  br label %.lr.ph22

.lr.ph22:                                         ; preds = %.lr.ph22.preheader, %._crit_edge
  %indvars.iv25 = phi i64 [ %14, %.lr.ph22.preheader ], [ %indvars.iv.next26, %._crit_edge ]
  %15 = load ptr, ptr %2, align 8, !tbaa !9
  %16 = trunc nsw i64 %indvars.iv25 to i32
  call void @_ZN13SharedPoolRun4initEiPN3rml10MemoryPoolEPPvS4_(i32 noundef %16, ptr noundef %15, ptr noundef nonnull %11, ptr noundef nonnull %12)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #6
  %17 = load ptr, ptr %2, align 8, !tbaa !9
  %18 = call noundef ptr @_ZN3rml11pool_mallocEPNS_10MemoryPoolEm(ptr noundef %17, i64 noundef 10485760)
  %.not17 = icmp eq ptr %18, null
  br i1 %.not17, label %19, label %20

19:                                               ; preds = %.lr.ph22
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 179, ptr noundef nonnull @.str.30, ptr noundef null)
  br label %20

20:                                               ; preds = %.lr.ph22, %19
  call void @_Z17NativeParallelForIi13SharedPoolRunEvT_RKT0_(i32 noundef %16, ptr noundef nonnull align 1 dereferenceable(1) %3)
  %21 = load ptr, ptr %2, align 8, !tbaa !9
  %22 = call noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef %21, ptr noundef %18)
  %23 = mul nsw i64 %indvars.iv25, 100
  %24 = icmp sgt i64 %indvars.iv25, 0
  br i1 %24, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %20
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #6
  %indvars.iv.next26 = add nsw i64 %indvars.iv25, 1
  %25 = load i32, ptr @_ZL9MaxThread, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %.not.not = icmp slt i64 %indvars.iv25, %26
  br i1 %.not.not, label %.lr.ph22, label %._crit_edge23, !llvm.loop !11

.lr.ph:                                           ; preds = %20, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %20 ]
  %27 = load ptr, ptr %2, align 8, !tbaa !9
  %28 = getelementptr inbounds ptr, ptr %12, i64 %indvars.iv
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = call noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef %27, ptr noundef %29)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %31 = icmp slt i64 %indvars.iv.next, %23
  br i1 %31, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge23:                                    ; preds = %._crit_edge, %0
  call void @_ZdaPv(ptr noundef nonnull %12) #8
  call void @_ZdaPv(ptr noundef nonnull %11) #8
  %32 = load ptr, ptr %2, align 8, !tbaa !9
  %33 = call noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef %32)
  br i1 %33, label %35, label %34

34:                                               ; preds = %._crit_edge23
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 191, ptr noundef nonnull @.str.23, ptr noundef null)
  br label %35

35:                                               ; preds = %._crit_edge23, %34
  %36 = call noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) @_ZL11liveRegions)
  %.not16 = icmp eq i32 %36, 0
  br i1 %.not16, label %38, label %37

37:                                               ; preds = %35
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 192, ptr noundef nonnull @.str.26, ptr noundef nonnull @.str.27)
  br label %38

38:                                               ; preds = %35, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #6
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13SharedPoolRun4initEiPN3rml10MemoryPoolEPPvS4_(i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z17NativeParallelForIi13SharedPoolRunEvT_RKT0_(i32 noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1

declare noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { "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 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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