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

; 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.rml::MemPoolPolicy" = type { ptr, ptr, i64, i32, i32 }
%class.FixedPoolHead.4 = type { %class.FixedPoolHeadBase }
%class.FixedPoolHeadBase = type { i64, i64, ptr }
%class.PoolIdentityCheck = type { ptr, ptr }
%struct.AllocatedObject = type { ptr }

@.str.20 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.78 = external hidden unnamed_addr constant [19 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 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 zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef) #3

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z17TestPoolDetectionv() #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca %"struct.rml::MemPoolPolicy", align 8
  %3 = alloca [4 x ptr], align 16
  %4 = alloca [4 x %class.FixedPoolHead.4], align 16
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca [4 x ptr], align 16
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %class.PoolIdentityCheck, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 4, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %2) #4
  call void @_ZN3rml13MemPoolPolicyC2EPFPvlRmEPFilS1_mEmbb(ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef @_ZL14fixedBufGetMemlRm, ptr noundef null, i64 noundef 0, i1 noundef zeroext true, i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 32, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 96, ptr %4) #4
  %17 = getelementptr inbounds [4 x %class.FixedPoolHead.4], ptr %4, i32 0, i32 0
  %18 = getelementptr inbounds %class.FixedPoolHead.4, ptr %17, i64 4
  br label %19

19:                                               ; preds = %21, %0
  %20 = phi ptr [ %17, %0 ], [ %22, %21 ]
  invoke void @_ZN13FixedPoolHeadILm4194304EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %20)
          to label %21 unwind label %29

21:                                               ; preds = %19
  %22 = getelementptr inbounds %class.FixedPoolHead.4, ptr %20, i64 1
  %23 = icmp eq ptr %22, %18
  br i1 %23, label %24, label %19

24:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %50, %24
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = icmp slt i32 %26, 4
  br i1 %27, label %39, label %28

28:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %57

29:                                               ; preds = %19
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %5, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %6, align 4
  %33 = icmp eq ptr %17, %20
  br i1 %33, label %38, label %34

34:                                               ; preds = %34, %29
  %35 = phi ptr [ %20, %29 ], [ %36, %34 ]
  %36 = getelementptr inbounds %class.FixedPoolHead.4, ptr %35, i64 -1
  call void @_ZN17FixedPoolHeadBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %36) #4
  %37 = icmp eq ptr %36, %17
  br i1 %37, label %38, label %34

38:                                               ; preds = %34, %29
  br label %176

39:                                               ; preds = %25
  %40 = getelementptr inbounds [4 x %class.FixedPoolHead.4], ptr %4, i64 0, i64 0
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds %class.FixedPoolHead.4, ptr %40, i64 %42
  %44 = ptrtoint ptr %43 to i64
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [4 x ptr], ptr %3, i64 0, i64 %46
  %48 = invoke noundef i32 @_ZN3rml14pool_create_v1ElPKNS_13MemPoolPolicyEPPNS_10MemoryPoolE(i64 noundef %44, ptr noundef %2, ptr noundef %47)
          to label %49 unwind label %53

49:                                               ; preds = %39
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %8, align 4, !tbaa !5
  br label %25, !llvm.loop !9

53:                                               ; preds = %39
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %5, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %168

57:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %130, %57
  %59 = load i32, ptr %9, align 4, !tbaa !5
  %60 = icmp slt i32 %59, 10
  br i1 %60, label %62, label %61

61:                                               ; preds = %58
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %134

62:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  %63 = getelementptr inbounds [4 x ptr], ptr %3, i64 0, i64 0
  %64 = getelementptr inbounds [4 x ptr], ptr %7, i64 0, i64 0
  invoke void @_ZN17PoolIdentityCheckC2EPPN3rml10MemoryPoolEPP15AllocatedObject(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef %63, ptr noundef %64)
          to label %65 unwind label %71

65:                                               ; preds = %62
  %66 = load i32, ptr %9, align 4, !tbaa !5
  %67 = and i32 %66, 1
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %75

69:                                               ; preds = %65
  invoke void @_Z17NativeParallelForIi17PoolIdentityCheckEvT_RKT0_(i32 noundef 4, ptr noundef nonnull align 8 dereferenceable(16) %11)
          to label %70 unwind label %71

70:                                               ; preds = %69
  br label %91

71:                                               ; preds = %69, %62
  %72 = landingpad { ptr, i32 }
          cleanup
  %73 = extractvalue { ptr, i32 } %72, 0
  store ptr %73, ptr %5, align 8
  %74 = extractvalue { ptr, i32 } %72, 1
  store i32 %74, ptr %6, align 4
  br label %133

75:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %83, %75
  %77 = load i32, ptr %12, align 4, !tbaa !5
  %78 = icmp slt i32 %77, 4
  br i1 %78, label %80, label %79

79:                                               ; preds = %76
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %90

80:                                               ; preds = %76
  %81 = load i32, ptr %12, align 4, !tbaa !5
  invoke void @_ZNK17PoolIdentityCheckclEi(ptr noundef nonnull align 8 dereferenceable(16) %11, i32 noundef %81)
          to label %82 unwind label %86

82:                                               ; preds = %80
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %12, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %12, align 4, !tbaa !5
  br label %76, !llvm.loop !11

86:                                               ; preds = %80
  %87 = landingpad { ptr, i32 }
          cleanup
  %88 = extractvalue { ptr, i32 } %87, 0
  store ptr %88, ptr %5, align 8
  %89 = extractvalue { ptr, i32 } %87, 1
  store i32 %89, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %133

90:                                               ; preds = %79
  br label %91

91:                                               ; preds = %90, %70
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %92

92:                                               ; preds = %122, %91
  %93 = load i32, ptr %13, align 4, !tbaa !5
  %94 = icmp slt i32 %93, 4
  br i1 %94, label %96, label %95

95:                                               ; preds = %92
  store i32 11, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %129

96:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %97 = load i32, ptr %13, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [4 x ptr], ptr %7, i64 0, i64 %98
  %100 = load ptr, ptr %99, align 8, !tbaa !12
  %101 = invoke noundef ptr @_ZN3rml13pool_identifyEPv(ptr noundef %100)
          to label %102 unwind label %125

102:                                              ; preds = %96
  store ptr %101, ptr %14, align 8, !tbaa !12
  %103 = load ptr, ptr %14, align 8, !tbaa !12
  %104 = load i32, ptr %13, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [4 x ptr], ptr %7, i64 0, i64 %105
  %107 = load ptr, ptr %106, align 8, !tbaa !12
  %108 = getelementptr inbounds %struct.AllocatedObject, ptr %107, i32 0, i32 0
  %109 = load ptr, ptr %108, align 8, !tbaa !14
  %110 = icmp eq ptr %103, %109
  br i1 %110, label %111, label %112

111:                                              ; preds = %102
  br label %114

112:                                              ; preds = %102
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 761, ptr noundef @.str.78, ptr noundef null)
          to label %113 unwind label %125

113:                                              ; preds = %112
  br label %114

114:                                              ; preds = %113, %111
  %115 = load ptr, ptr %14, align 8, !tbaa !12
  %116 = load i32, ptr %13, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [4 x ptr], ptr %7, i64 0, i64 %117
  %119 = load ptr, ptr %118, align 8, !tbaa !12
  %120 = invoke noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef %115, ptr noundef %119)
          to label %121 unwind label %125

121:                                              ; preds = %114
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %122

122:                                              ; preds = %121
  %123 = load i32, ptr %13, align 4, !tbaa !5
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr %13, align 4, !tbaa !5
  br label %92, !llvm.loop !16

125:                                              ; preds = %114, %112, %96
  %126 = landingpad { ptr, i32 }
          cleanup
  %127 = extractvalue { ptr, i32 } %126, 0
  store ptr %127, ptr %5, align 8
  %128 = extractvalue { ptr, i32 } %126, 1
  store i32 %128, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %133

129:                                              ; preds = %95
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  br label %130

130:                                              ; preds = %129
  %131 = load i32, ptr %9, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %9, align 4, !tbaa !5
  br label %58, !llvm.loop !17

133:                                              ; preds = %125, %86, %71
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %168

134:                                              ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %135

135:                                              ; preds = %153, %134
  %136 = load i32, ptr %15, align 4, !tbaa !5
  %137 = icmp slt i32 %136, 4
  br i1 %137, label %139, label %138

138:                                              ; preds = %135
  store i32 14, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %160

139:                                              ; preds = %135
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #4
  %140 = load i32, ptr %15, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [4 x ptr], ptr %3, i64 0, i64 %141
  %143 = load ptr, ptr %142, align 8, !tbaa !12
  %144 = invoke noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef %143)
          to label %145 unwind label %156

145:                                              ; preds = %139
  %146 = zext i1 %144 to i8
  store i8 %146, ptr %16, align 1, !tbaa !18
  %147 = load i8, ptr %16, align 1, !tbaa !18, !range !20, !noundef !21
  %148 = trunc i8 %147 to i1
  br i1 %148, label %149, label %150

149:                                              ; preds = %145
  br label %152

150:                                              ; preds = %145
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 767, ptr noundef @.str.23, ptr noundef null)
          to label %151 unwind label %156

151:                                              ; preds = %150
  br label %152

152:                                              ; preds = %151, %149
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #4
  br label %153

153:                                              ; preds = %152
  %154 = load i32, ptr %15, align 4, !tbaa !5
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %15, align 4, !tbaa !5
  br label %135, !llvm.loop !22

156:                                              ; preds = %150, %139
  %157 = landingpad { ptr, i32 }
          cleanup
  %158 = extractvalue { ptr, i32 } %157, 0
  store ptr %158, ptr %5, align 8
  %159 = extractvalue { ptr, i32 } %157, 1
  store i32 %159, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %168

160:                                              ; preds = %138
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #4
  %161 = getelementptr inbounds [4 x %class.FixedPoolHead.4], ptr %4, i32 0, i32 0
  %162 = getelementptr inbounds %class.FixedPoolHead.4, ptr %161, i64 4
  br label %163

163:                                              ; preds = %163, %160
  %164 = phi ptr [ %162, %160 ], [ %165, %163 ]
  %165 = getelementptr inbounds %class.FixedPoolHead.4, ptr %164, i64 -1
  call void @_ZN17FixedPoolHeadBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %165) #4
  %166 = icmp eq ptr %165, %161
  br i1 %166, label %167, label %163

167:                                              ; preds = %163
  call void @llvm.lifetime.end.p0(i64 96, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void

168:                                              ; preds = %156, %133, %53
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #4
  %169 = getelementptr inbounds [4 x %class.FixedPoolHead.4], ptr %4, i32 0, i32 0
  %170 = getelementptr inbounds %class.FixedPoolHead.4, ptr %169, i64 4
  br label %171

171:                                              ; preds = %171, %168
  %172 = phi ptr [ %170, %168 ], [ %173, %171 ]
  %173 = getelementptr inbounds %class.FixedPoolHead.4, ptr %172, i64 -1
  call void @_ZN17FixedPoolHeadBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %173) #4
  %174 = icmp eq ptr %173, %169
  br i1 %174, label %175, label %171

175:                                              ; preds = %171
  br label %176

176:                                              ; preds = %175, %38
  call void @llvm.lifetime.end.p0(i64 96, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  br label %177

177:                                              ; preds = %176
  %178 = load ptr, ptr %5, align 8
  %179 = load i32, ptr %6, align 4
  %180 = insertvalue { ptr, i32 } poison, ptr %178, 0
  %181 = insertvalue { ptr, i32 } %180, i32 %179, 1
  resume { ptr, i32 } %181
}

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

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

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

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

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

declare noundef ptr @_ZN3rml13pool_identifyEPv(ptr noundef) #3

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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!15, !13, i64 0}
!15 = !{!"_ZTS15AllocatedObject", !13, i64 0}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = !{!19, !19, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = distinct !{!22, !10}


; 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.rml::MemPoolPolicy" = type { ptr, ptr, i64, i32, i32 }
%class.FixedPoolHead.4 = type { %class.FixedPoolHeadBase }
%class.FixedPoolHeadBase = type { i64, i64, ptr }
%class.PoolIdentityCheck = type { ptr, ptr }

@.str.20 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.78 = external hidden unnamed_addr constant [19 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 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 zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef) local_unnamed_addr #3

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z17TestPoolDetectionv() local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"struct.rml::MemPoolPolicy", align 8
  %2 = alloca [4 x ptr], align 16
  %3 = alloca [4 x %class.FixedPoolHead.4], align 16
  %4 = alloca [4 x ptr], align 16
  %5 = alloca %class.PoolIdentityCheck, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #4
  call void @_ZN3rml13MemPoolPolicyC2EPFPvlRmEPFilS1_mEmbb(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull @_ZL14fixedBufGetMemlRm, ptr noundef null, i64 noundef 0, i1 noundef zeroext true, i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %3) #4
  call void @_ZN13FixedPoolHeadILm4194304EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3)
  %.ptr.1 = getelementptr inbounds i8, ptr %3, i64 24
  invoke void @_ZN13FixedPoolHeadILm4194304EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.1)
          to label %6 unwind label %.preheader42.preheader

6:                                                ; preds = %0
  %.ptr.2 = getelementptr inbounds i8, ptr %3, i64 48
  invoke void @_ZN13FixedPoolHeadILm4194304EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.2)
          to label %7 unwind label %.preheader42.preheader

7:                                                ; preds = %6
  %.ptr.3 = getelementptr inbounds i8, ptr %3, i64 72
  invoke void @_ZN13FixedPoolHeadILm4194304EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.3)
          to label %8 unwind label %.preheader42.preheader

8:                                                ; preds = %7
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #4
  %9 = ptrtoint ptr %3 to i64
  %10 = invoke noundef i32 @_ZN3rml14pool_create_v1ElPKNS_13MemPoolPolicyEPPNS_10MemoryPoolE(i64 noundef %9, ptr noundef nonnull %1, ptr noundef nonnull %2)
          to label %14 unwind label %29

.preheader42.preheader:                           ; preds = %0, %6, %7
  %.ptr.lcssa.ph = phi ptr [ %.ptr.3, %7 ], [ %.ptr.2, %6 ], [ %.ptr.1, %0 ]
  %lpad.thr_comm = landingpad { ptr, i32 }
          cleanup
  br label %.preheader42

.preheader42:                                     ; preds = %.preheader42.preheader, %.preheader42
  %11 = phi ptr [ %12, %.preheader42 ], [ %.ptr.lcssa.ph, %.preheader42.preheader ]
  %12 = getelementptr inbounds i8, ptr %11, i64 -24
  call void @_ZN17FixedPoolHeadBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %12) #4
  %13 = icmp eq ptr %12, %3
  br i1 %13, label %.loopexit, label %.preheader42

14:                                               ; preds = %8
  %15 = ptrtoint ptr %.ptr.1 to i64
  %16 = getelementptr inbounds i8, ptr %2, i64 8
  %17 = invoke noundef i32 @_ZN3rml14pool_create_v1ElPKNS_13MemPoolPolicyEPPNS_10MemoryPoolE(i64 noundef %15, ptr noundef nonnull %1, ptr noundef nonnull %16)
          to label %18 unwind label %29

18:                                               ; preds = %14
  %19 = ptrtoint ptr %.ptr.2 to i64
  %20 = getelementptr inbounds i8, ptr %2, i64 16
  %21 = invoke noundef i32 @_ZN3rml14pool_create_v1ElPKNS_13MemPoolPolicyEPPNS_10MemoryPoolE(i64 noundef %19, ptr noundef nonnull %1, ptr noundef nonnull %20)
          to label %22 unwind label %29

22:                                               ; preds = %18
  %23 = ptrtoint ptr %.ptr.3 to i64
  %24 = getelementptr inbounds i8, ptr %2, i64 24
  %25 = invoke noundef i32 @_ZN3rml14pool_create_v1ElPKNS_13MemPoolPolicyEPPNS_10MemoryPoolE(i64 noundef %23, ptr noundef nonnull %1, ptr noundef nonnull %24)
          to label %.preheader41.preheader unwind label %29

.preheader41.preheader:                           ; preds = %22
  %26 = getelementptr inbounds i8, ptr %4, i64 8
  %27 = getelementptr inbounds i8, ptr %4, i64 16
  %28 = getelementptr inbounds i8, ptr %4, i64 24
  br label %.preheader41

29:                                               ; preds = %22, %18, %14, %8
  %30 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.loopexit

.preheader41:                                     ; preds = %.preheader41.preheader, %82
  %.02849 = phi i32 [ %83, %82 ], [ 0, %.preheader41.preheader ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @_ZN17PoolIdentityCheckC2EPPN3rml10MemoryPoolEPP15AllocatedObject(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull %2, ptr noundef nonnull %4)
  %31 = and i32 %.02849, 1
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %.preheader39.preheader, label %32

.preheader39.preheader:                           ; preds = %.preheader41
  invoke void @_ZNK17PoolIdentityCheckclEi(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef 0)
          to label %.preheader39.1 unwind label %35

32:                                               ; preds = %.preheader41
  invoke void @_Z17NativeParallelForIi17PoolIdentityCheckEvT_RKT0_(i32 noundef 4, ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %.loopexit40 unwind label %33

33:                                               ; preds = %32
  %34 = landingpad { ptr, i32 }
          cleanup
  br label %86

.preheader39.1:                                   ; preds = %.preheader39.preheader
  invoke void @_ZNK17PoolIdentityCheckclEi(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef 1)
          to label %.preheader39.2 unwind label %35

.preheader39.2:                                   ; preds = %.preheader39.1
  invoke void @_ZNK17PoolIdentityCheckclEi(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef 2)
          to label %.preheader39.3 unwind label %35

.preheader39.3:                                   ; preds = %.preheader39.2
  invoke void @_ZNK17PoolIdentityCheckclEi(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef 3)
          to label %.loopexit40 unwind label %35

35:                                               ; preds = %.preheader39.3, %.preheader39.2, %.preheader39.1, %.preheader39.preheader
  %36 = landingpad { ptr, i32 }
          cleanup
  br label %86

.loopexit40:                                      ; preds = %.preheader39.3, %32
  %37 = load ptr, ptr %4, align 16, !tbaa !5
  %38 = invoke noundef ptr @_ZN3rml13pool_identifyEPv(ptr noundef %37)
          to label %41 unwind label %84

.preheader.preheader:                             ; preds = %82
  %39 = load ptr, ptr %2, align 16, !tbaa !5
  %40 = invoke noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef %39)
          to label %87 unwind label %105

41:                                               ; preds = %.loopexit40
  %42 = load ptr, ptr %4, align 16, !tbaa !5
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = icmp eq ptr %38, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 761, ptr noundef nonnull @.str.78, ptr noundef null)
          to label %._crit_edge unwind label %84

._crit_edge:                                      ; preds = %45
  %.pre = load ptr, ptr %4, align 16, !tbaa !5
  br label %46

46:                                               ; preds = %._crit_edge, %41
  %47 = phi ptr [ %.pre, %._crit_edge ], [ %42, %41 ]
  %48 = invoke noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef %38, ptr noundef %47)
          to label %49 unwind label %84

49:                                               ; preds = %46
  %50 = load ptr, ptr %26, align 8, !tbaa !5
  %51 = invoke noundef ptr @_ZN3rml13pool_identifyEPv(ptr noundef %50)
          to label %52 unwind label %84

52:                                               ; preds = %49
  %53 = load ptr, ptr %26, align 8, !tbaa !5
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = icmp eq ptr %51, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 761, ptr noundef nonnull @.str.78, ptr noundef null)
          to label %._crit_edge58 unwind label %84

._crit_edge58:                                    ; preds = %56
  %.pre59 = load ptr, ptr %26, align 8, !tbaa !5
  br label %57

57:                                               ; preds = %._crit_edge58, %52
  %58 = phi ptr [ %.pre59, %._crit_edge58 ], [ %53, %52 ]
  %59 = invoke noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef %51, ptr noundef %58)
          to label %60 unwind label %84

60:                                               ; preds = %57
  %61 = load ptr, ptr %27, align 16, !tbaa !5
  %62 = invoke noundef ptr @_ZN3rml13pool_identifyEPv(ptr noundef %61)
          to label %63 unwind label %84

63:                                               ; preds = %60
  %64 = load ptr, ptr %27, align 16, !tbaa !5
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  %66 = icmp eq ptr %62, %65
  br i1 %66, label %68, label %67

67:                                               ; preds = %63
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 761, ptr noundef nonnull @.str.78, ptr noundef null)
          to label %._crit_edge60 unwind label %84

._crit_edge60:                                    ; preds = %67
  %.pre61 = load ptr, ptr %27, align 16, !tbaa !5
  br label %68

68:                                               ; preds = %._crit_edge60, %63
  %69 = phi ptr [ %.pre61, %._crit_edge60 ], [ %64, %63 ]
  %70 = invoke noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef %62, ptr noundef %69)
          to label %71 unwind label %84

71:                                               ; preds = %68
  %72 = load ptr, ptr %28, align 8, !tbaa !5
  %73 = invoke noundef ptr @_ZN3rml13pool_identifyEPv(ptr noundef %72)
          to label %74 unwind label %84

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

78:                                               ; preds = %74
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 761, ptr noundef nonnull @.str.78, ptr noundef null)
          to label %._crit_edge62 unwind label %84

._crit_edge62:                                    ; preds = %78
  %.pre63 = load ptr, ptr %28, align 8, !tbaa !5
  br label %79

79:                                               ; preds = %._crit_edge62, %74
  %80 = phi ptr [ %.pre63, %._crit_edge62 ], [ %75, %74 ]
  %81 = invoke noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef %73, ptr noundef %80)
          to label %82 unwind label %84

82:                                               ; preds = %79
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  %83 = add nuw nsw i32 %.02849, 1
  %exitcond.not = icmp eq i32 %83, 10
  br i1 %exitcond.not, label %.preheader.preheader, label %.preheader41, !llvm.loop !11

84:                                               ; preds = %79, %78, %71, %68, %67, %60, %57, %56, %49, %46, %45, %.loopexit40
  %85 = landingpad { ptr, i32 }
          cleanup
  br label %86

86:                                               ; preds = %84, %35, %33
  %.pn = phi { ptr, i32 } [ %85, %84 ], [ %34, %33 ], [ %36, %35 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  br label %.loopexit.loopexit

87:                                               ; preds = %.preheader.preheader
  br i1 %40, label %.preheader.1, label %88

88:                                               ; preds = %87
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 767, ptr noundef nonnull @.str.23, ptr noundef null)
          to label %.preheader.1 unwind label %105

.preheader.1:                                     ; preds = %88, %87
  %89 = load ptr, ptr %16, align 8, !tbaa !5
  %90 = invoke noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef %89)
          to label %91 unwind label %105

91:                                               ; preds = %.preheader.1
  br i1 %90, label %.preheader.2, label %92

92:                                               ; preds = %91
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 767, ptr noundef nonnull @.str.23, ptr noundef null)
          to label %.preheader.2 unwind label %105

.preheader.2:                                     ; preds = %92, %91
  %93 = load ptr, ptr %20, align 16, !tbaa !5
  %94 = invoke noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef %93)
          to label %95 unwind label %105

95:                                               ; preds = %.preheader.2
  br i1 %94, label %.preheader.3, label %96

96:                                               ; preds = %95
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 767, ptr noundef nonnull @.str.23, ptr noundef null)
          to label %.preheader.3 unwind label %105

.preheader.3:                                     ; preds = %96, %95
  %97 = load ptr, ptr %24, align 8, !tbaa !5
  %98 = invoke noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef %97)
          to label %99 unwind label %105

99:                                               ; preds = %.preheader.3
  br i1 %98, label %101, label %100

100:                                              ; preds = %99
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 767, ptr noundef nonnull @.str.23, ptr noundef null)
          to label %101 unwind label %105

101:                                              ; preds = %100, %99
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  %102 = getelementptr inbounds i8, ptr %3, i64 72
  call void @_ZN17FixedPoolHeadBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %102) #4
  %103 = getelementptr inbounds i8, ptr %3, i64 48
  call void @_ZN17FixedPoolHeadBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %103) #4
  %104 = getelementptr inbounds i8, ptr %3, i64 24
  call void @_ZN17FixedPoolHeadBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %104) #4
  call void @_ZN17FixedPoolHeadBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #4
  ret void

105:                                              ; preds = %100, %.preheader.3, %96, %.preheader.2, %92, %.preheader.1, %88, %.preheader.preheader
  %106 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.loopexit

.loopexit.loopexit:                               ; preds = %105, %86, %29
  %.pn36 = phi { ptr, i32 } [ %30, %29 ], [ %.pn, %86 ], [ %106, %105 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  %107 = getelementptr inbounds i8, ptr %3, i64 72
  call void @_ZN17FixedPoolHeadBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %107) #4
  %108 = getelementptr inbounds i8, ptr %3, i64 48
  call void @_ZN17FixedPoolHeadBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %108) #4
  %109 = getelementptr inbounds i8, ptr %3, i64 24
  call void @_ZN17FixedPoolHeadBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %109) #4
  call void @_ZN17FixedPoolHeadBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader42, %.loopexit.loopexit
  %.pn36.pn = phi { ptr, i32 } [ %.pn36, %.loopexit.loopexit ], [ %lpad.thr_comm, %.preheader42 ]
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #4
  resume { ptr, i32 } %.pn36.pn
}

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

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

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

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

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

declare noundef ptr @_ZN3rml13pool_identifyEPv(ptr noundef) local_unnamed_addr #3

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 = { 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, !6, i64 0}
!10 = !{!"_ZTS15AllocatedObject", !6, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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