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

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

@.str.20 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZL15currGranularity = external hidden global i64, align 8
@__const._Z11TestEntriesv.size = external hidden unnamed_addr constant [4 x i64], align 16
@__const._Z11TestEntriesv.algn = external hidden unnamed_addr constant [4 x i64], align 16
@.str.52 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.54 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [6 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; 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 #3 align 2

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

declare noundef zeroext i1 @_ZN3rml10pool_resetEPNS_10MemoryPoolE(ptr noundef) #4

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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: mustprogress uwtable
define dso_local void @_Z11TestEntriesv() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [4 x i64], align 16
  %4 = alloca [4 x i64], align 16
  %5 = alloca %"struct.rml::MemPoolPolicy", align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i8, align 1
  %17 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #7
  store i32 4, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 4, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %3) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %3, ptr align 16 @__const._Z11TestEntriesv.size, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr %4) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 @__const._Z11TestEntriesv.algn, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #7
  call void @_ZN3rml13MemPoolPolicyC2EPFPvlRmEPFilS1_mEmbb(ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef @_ZL10getGranMemlRm, ptr noundef @_ZL10putGranMemlPvm, i64 noundef 0, i1 noundef zeroext false, i1 noundef zeroext false)
  store i64 1, ptr @_ZL15currGranularity, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %18 = call noundef i32 @_ZN3rml14pool_create_v1ElPKNS_13MemPoolPolicyEPPNS_10MemoryPoolE(i64 noundef 0, ptr noundef %5, ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %132, %0
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = icmp slt i32 %20, 4
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %135

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

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

27:                                               ; preds = %24
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %131

28:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %29 = load ptr, ptr %6, align 8, !tbaa !11
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [4 x i64], ptr %3, i64 0, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !9
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [4 x i64], ptr %4, i64 0, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !9
  %38 = call noundef ptr @_ZN3rml19pool_aligned_mallocEPNS_10MemoryPoolEmm(ptr noundef %29, i64 noundef %33, i64 noundef %37)
  store ptr %38, ptr %10, align 8, !tbaa !11
  %39 = load ptr, ptr %10, align 8, !tbaa !11
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %52

41:                                               ; preds = %28
  %42 = load ptr, ptr %10, align 8, !tbaa !11
  %43 = ptrtoint ptr %42 to i64
  %44 = load i32, ptr %9, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [4 x i64], ptr %4, i64 0, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !9
  %48 = sub i64 %47, 1
  %49 = and i64 %43, %48
  %50 = icmp eq i64 0, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %41
  br label %53

52:                                               ; preds = %41, %28
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 593, ptr noundef @.str.52, ptr noundef null)
  br label %53

53:                                               ; preds = %52, %51
  %54 = load ptr, ptr %10, align 8, !tbaa !11
  %55 = load i32, ptr %9, align 4, !tbaa !5
  %56 = trunc i32 %55 to i8
  %57 = load i32, ptr %7, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [4 x i64], ptr %3, i64 0, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 1 %54, i8 %56, i64 %60, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %61 = call i32 @rand() #7
  %62 = srem i32 %61, 4
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [4 x i64], ptr %4, i64 0, i64 %63
  %65 = load i64, ptr %64, align 8, !tbaa !9
  store i64 %65, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %66 = call i32 @rand() #7
  %67 = srem i32 %66, 4
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [4 x i64], ptr %3, i64 0, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !9
  store i64 %70, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %71 = load ptr, ptr %6, align 8, !tbaa !11
  %72 = load ptr, ptr %10, align 8, !tbaa !11
  %73 = load i64, ptr %12, align 8, !tbaa !9
  %74 = load i64, ptr %11, align 8, !tbaa !9
  %75 = call noundef ptr @_ZN3rml20pool_aligned_reallocEPNS_10MemoryPoolEPvmm(ptr noundef %71, ptr noundef %72, i64 noundef %73, i64 noundef %74)
  store ptr %75, ptr %13, align 8, !tbaa !11
  %76 = load ptr, ptr %13, align 8, !tbaa !11
  %77 = icmp ne ptr %76, null
  br i1 %77, label %78, label %86

78:                                               ; preds = %53
  %79 = load ptr, ptr %13, align 8, !tbaa !11
  %80 = ptrtoint ptr %79 to i64
  %81 = load i64, ptr %11, align 8, !tbaa !9
  %82 = sub i64 %81, 1
  %83 = and i64 %80, %82
  %84 = icmp eq i64 0, %83
  br i1 %84, label %85, label %86

85:                                               ; preds = %78
  br label %87

86:                                               ; preds = %78, %53
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 599, ptr noundef @.str.53, ptr noundef null)
  br label %87

87:                                               ; preds = %86, %85
  %88 = load ptr, ptr %13, align 8, !tbaa !11
  %89 = load i32, ptr %7, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [4 x i64], ptr %3, i64 0, i64 %90
  %92 = call noundef i64 @_Z3minImmET_RKS0_RKT0_(ptr noundef nonnull align 8 dereferenceable(8) %91, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %93 = load i32, ptr %9, align 4, !tbaa !5
  %94 = call noundef zeroext i1 @_ZL8memEqualPcmi(ptr noundef %88, i64 noundef %92, i32 noundef %93)
  br i1 %94, label %95, label %96

95:                                               ; preds = %87
  br label %97

96:                                               ; preds = %87
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 600, ptr noundef @.str.54, ptr noundef null)
  br label %97

97:                                               ; preds = %96, %95
  %98 = load ptr, ptr %13, align 8, !tbaa !11
  %99 = load i32, ptr %9, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  %101 = trunc i32 %100 to i8
  %102 = load i64, ptr %12, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 1 %98, i8 %101, i64 %102, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %103 = call i32 @rand() #7
  %104 = srem i32 %103, 4
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [4 x i64], ptr %3, i64 0, i64 %105
  %107 = load i64, ptr %106, align 8, !tbaa !9
  store i64 %107, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %108 = load ptr, ptr %6, align 8, !tbaa !11
  %109 = load ptr, ptr %13, align 8, !tbaa !11
  %110 = load i64, ptr %14, align 8, !tbaa !9
  %111 = call noundef ptr @_ZN3rml12pool_reallocEPNS_10MemoryPoolEPvm(ptr noundef %108, ptr noundef %109, i64 noundef %110)
  store ptr %111, ptr %15, align 8, !tbaa !11
  %112 = load ptr, ptr %15, align 8, !tbaa !11
  %113 = icmp ne ptr %112, null
  br i1 %113, label %114, label %115

114:                                              ; preds = %97
  br label %116

115:                                              ; preds = %97
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 605, ptr noundef @.str.55, ptr noundef null)
  br label %116

116:                                              ; preds = %115, %114
  %117 = load ptr, ptr %15, align 8, !tbaa !11
  %118 = call noundef i64 @_Z3minImmET_RKS0_RKT0_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %119 = load i32, ptr %9, align 4, !tbaa !5
  %120 = add nsw i32 %119, 1
  %121 = call noundef zeroext i1 @_ZL8memEqualPcmi(ptr noundef %117, i64 noundef %118, i32 noundef %120)
  br i1 %121, label %122, label %123

122:                                              ; preds = %116
  br label %124

123:                                              ; preds = %116
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 606, ptr noundef @.str.56, ptr noundef null)
  br label %124

124:                                              ; preds = %123, %122
  %125 = load ptr, ptr %6, align 8, !tbaa !11
  %126 = load ptr, ptr %15, align 8, !tbaa !11
  %127 = call noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef %125, ptr noundef %126)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %128

128:                                              ; preds = %124
  %129 = load i32, ptr %9, align 4, !tbaa !5
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr %9, align 4, !tbaa !5
  br label %24, !llvm.loop !13

131:                                              ; preds = %27
  br label %132

132:                                              ; preds = %131
  %133 = load i32, ptr %7, align 4, !tbaa !5
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr %7, align 4, !tbaa !5
  br label %19, !llvm.loop !15

135:                                              ; preds = %22
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #7
  %136 = load ptr, ptr %6, align 8, !tbaa !11
  %137 = call noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef %136)
  %138 = zext i1 %137 to i8
  store i8 %138, ptr %16, align 1, !tbaa !16
  %139 = load i8, ptr %16, align 1, !tbaa !16, !range !18, !noundef !19
  %140 = trunc i8 %139 to i1
  br i1 %140, label %141, label %142

141:                                              ; preds = %135
  br label %143

142:                                              ; preds = %135
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 612, ptr noundef @.str.23, ptr noundef null)
  br label %143

143:                                              ; preds = %142, %141
  call void @llvm.lifetime.start.p0(i64 1, ptr %17) #7
  %144 = call noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef null)
  %145 = zext i1 %144 to i8
  store i8 %145, ptr %17, align 1, !tbaa !16
  %146 = load i8, ptr %17, align 1, !tbaa !16, !range !18, !noundef !19
  %147 = trunc i8 %146 to i1
  br i1 %147, label %149, label %148

148:                                              ; preds = %143
  br label %150

149:                                              ; preds = %143
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 615, ptr noundef @.str.57, ptr noundef null)
  br label %150

150:                                              ; preds = %149, %148
  %151 = call noundef zeroext i1 @_ZN3rml10pool_resetEPNS_10MemoryPoolE(ptr noundef null)
  %152 = zext i1 %151 to i8
  store i8 %152, ptr %17, align 1, !tbaa !16
  %153 = load i8, ptr %17, align 1, !tbaa !16, !range !18, !noundef !19
  %154 = trunc i8 %153 to i1
  br i1 %154, label %156, label %155

155:                                              ; preds = %150
  br label %157

156:                                              ; preds = %150
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.20, i32 noundef 617, ptr noundef @.str.57, ptr noundef null)
  br label %157

157:                                              ; preds = %156, %155
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #7
  ret void
}

declare noundef ptr @_ZN3rml19pool_aligned_mallocEPNS_10MemoryPoolEmm(ptr noundef, i64 noundef, i64 noundef) #4

; Function Attrs: nounwind
declare i32 @rand() #6

declare noundef ptr @_ZN3rml20pool_aligned_reallocEPNS_10MemoryPoolEPvmm(ptr noundef, ptr noundef, i64 noundef, i64 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZL8memEqualPcmi(ptr noundef, i64 noundef, i32 noundef) #3

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

declare noundef ptr @_ZN3rml12pool_reallocEPNS_10MemoryPoolEPvm(ptr noundef, ptr noundef, i64 noundef) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 }

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


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

@.str.20 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZL15currGranularity = external hidden local_unnamed_addr global i64, align 8
@__const._Z11TestEntriesv.size = external hidden unnamed_addr constant [4 x i64], align 16
@__const._Z11TestEntriesv.algn = external hidden unnamed_addr constant [4 x i64], align 16
@.str.52 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.54 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [6 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; 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 #3 align 2

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

declare noundef zeroext i1 @_ZN3rml10pool_resetEPNS_10MemoryPoolE(ptr noundef) local_unnamed_addr #4

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

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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: mustprogress uwtable
define dso_local void @_Z11TestEntriesv() local_unnamed_addr #1 {
  %1 = alloca [4 x i64], align 16
  %2 = alloca %"struct.rml::MemPoolPolicy", align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %1, ptr noundef nonnull align 16 dereferenceable(32) @__const._Z11TestEntriesv.size, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #7
  call void @_ZN3rml13MemPoolPolicyC2EPFPvlRmEPFilS1_mEmbb(ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull @_ZL10getGranMemlRm, ptr noundef nonnull @_ZL10putGranMemlPvm, i64 noundef 0, i1 noundef zeroext false, i1 noundef zeroext false)
  store i64 1, ptr @_ZL15currGranularity, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %6 = call noundef i32 @_ZN3rml14pool_create_v1ElPKNS_13MemPoolPolicyEPPNS_10MemoryPoolE(i64 noundef 0, ptr noundef nonnull %2, ptr noundef nonnull %3)
  br label %.preheader

.preheader:                                       ; preds = %0, %11
  %indvars.iv37 = phi i64 [ 0, %0 ], [ %indvars.iv.next38, %11 ]
  %7 = getelementptr inbounds [4 x i64], ptr %1, i64 0, i64 %indvars.iv37
  br label %12

8:                                                ; preds = %11
  %9 = load ptr, ptr %3, align 8, !tbaa !9
  %10 = call noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef %9)
  br i1 %10, label %70, label %69

11:                                               ; preds = %66
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %exitcond40.not = icmp eq i64 %indvars.iv.next38, 4
  br i1 %exitcond40.not, label %8, label %.preheader, !llvm.loop !11

12:                                               ; preds = %.preheader, %66
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %66 ]
  %13 = load ptr, ptr %3, align 8, !tbaa !9
  %14 = load i64, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds [4 x i64], ptr @__const._Z11TestEntriesv.algn, i64 0, i64 %indvars.iv
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = call noundef ptr @_ZN3rml19pool_aligned_mallocEPNS_10MemoryPoolEmm(ptr noundef %13, i64 noundef %14, i64 noundef %16)
  %.not = icmp eq ptr %17, null
  br i1 %.not, label %23, label %18

18:                                               ; preds = %12
  %19 = ptrtoint ptr %17 to i64
  %20 = add i64 %16, -1
  %21 = and i64 %20, %19
  %22 = icmp eq i64 %21, 0
  br i1 %22, label %24, label %23

23:                                               ; preds = %18, %12
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 593, ptr noundef nonnull @.str.52, ptr noundef null)
  br label %24

24:                                               ; preds = %18, %23
  %25 = trunc nuw nsw i64 %indvars.iv to i32
  %26 = trunc i64 %indvars.iv to i8
  %27 = load i64, ptr %7, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 1 %17, i8 %26, i64 %27, i1 false)
  %28 = call i32 @rand() #7
  %29 = srem i32 %28, 4
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [4 x i64], ptr @__const._Z11TestEntriesv.algn, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %33 = call i32 @rand() #7
  %34 = srem i32 %33, 4
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [4 x i64], ptr %1, i64 0, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !5
  store i64 %37, ptr %4, align 8, !tbaa !5
  %38 = load ptr, ptr %3, align 8, !tbaa !9
  %39 = call noundef ptr @_ZN3rml20pool_aligned_reallocEPNS_10MemoryPoolEPvmm(ptr noundef %38, ptr noundef %17, i64 noundef %37, i64 noundef %32)
  %.not32 = icmp eq ptr %39, null
  br i1 %.not32, label %45, label %40

40:                                               ; preds = %24
  %41 = ptrtoint ptr %39 to i64
  %42 = add i64 %32, -1
  %43 = and i64 %42, %41
  %44 = icmp eq i64 %43, 0
  br i1 %44, label %46, label %45

45:                                               ; preds = %40, %24
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 599, ptr noundef nonnull @.str.53, ptr noundef null)
  br label %46

46:                                               ; preds = %40, %45
  %47 = call noundef i64 @_Z3minImmET_RKS0_RKT0_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %48 = call noundef zeroext i1 @_ZL8memEqualPcmi(ptr noundef %39, i64 noundef %47, i32 noundef %25)
  br i1 %48, label %50, label %49

49:                                               ; preds = %46
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 600, ptr noundef nonnull @.str.54, ptr noundef null)
  br label %50

50:                                               ; preds = %46, %49
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %51 = load i64, ptr %4, align 8, !tbaa !5
  %52 = trunc nuw nsw i64 %indvars.iv.next to i8
  call void @llvm.memset.p0.i64(ptr align 1 %39, i8 %52, i64 %51, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  %53 = call i32 @rand() #7
  %54 = srem i32 %53, 4
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [4 x i64], ptr %1, i64 0, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !5
  store i64 %57, ptr %5, align 8, !tbaa !5
  %58 = load ptr, ptr %3, align 8, !tbaa !9
  %59 = call noundef ptr @_ZN3rml12pool_reallocEPNS_10MemoryPoolEPvm(ptr noundef %58, ptr noundef %39, i64 noundef %57)
  %.not33 = icmp eq ptr %59, null
  br i1 %.not33, label %60, label %61

60:                                               ; preds = %50
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 605, ptr noundef nonnull @.str.55, ptr noundef null)
  br label %61

61:                                               ; preds = %50, %60
  %62 = call noundef i64 @_Z3minImmET_RKS0_RKT0_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %63 = trunc nuw nsw i64 %indvars.iv.next to i32
  %64 = call noundef zeroext i1 @_ZL8memEqualPcmi(ptr noundef %59, i64 noundef %62, i32 noundef %63)
  br i1 %64, label %66, label %65

65:                                               ; preds = %61
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 606, ptr noundef nonnull @.str.56, ptr noundef null)
  br label %66

66:                                               ; preds = %61, %65
  %67 = load ptr, ptr %3, align 8, !tbaa !9
  %68 = call noundef zeroext i1 @_ZN3rml9pool_freeEPNS_10MemoryPoolEPv(ptr noundef %67, ptr noundef %59)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  %exitcond.not = icmp eq i64 %indvars.iv.next, 4
  br i1 %exitcond.not, label %11, label %12, !llvm.loop !13

69:                                               ; preds = %8
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 612, ptr noundef nonnull @.str.23, ptr noundef null)
  br label %70

70:                                               ; preds = %8, %69
  %71 = call noundef zeroext i1 @_ZN3rml12pool_destroyEPNS_10MemoryPoolE(ptr noundef null)
  br i1 %71, label %72, label %73

72:                                               ; preds = %70
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 615, ptr noundef nonnull @.str.57, ptr noundef null)
  br label %73

73:                                               ; preds = %70, %72
  %74 = call noundef zeroext i1 @_ZN3rml10pool_resetEPNS_10MemoryPoolE(ptr noundef null)
  br i1 %74, label %75, label %76

75:                                               ; preds = %73
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.20, i32 noundef 617, ptr noundef nonnull @.str.57, ptr noundef null)
  br label %76

76:                                               ; preds = %73, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #7
  ret void
}

declare noundef ptr @_ZN3rml19pool_aligned_mallocEPNS_10MemoryPoolEmm(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #6

declare noundef ptr @_ZN3rml20pool_aligned_reallocEPNS_10MemoryPoolEPvmm(ptr noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZL8memEqualPcmi(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #3

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

declare noundef ptr @_ZN3rml12pool_reallocEPNS_10MemoryPoolEPvm(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 }

!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 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SROAPass,SimplifyCFGPass