; LLVM IR from tsotchke/quantum_geometric_tensor :: src/quantum_geometric/core (memory_pool)

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

%union.pthread_mutexattr_t = type { i32 }
%struct.PoolConfig = type { i64, i64, i64, float, i64, i8, i8, i64, i64, i8 }
%struct.MemoryPool = type { ptr, i64, ptr, i64, ptr, i64, i64, i64, %union.pthread_mutex_t, %struct.PoolConfig }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.SizeClass = type { i64, ptr, %union.pthread_mutex_t, i64, i64, i64, i64 }

@.str = external hidden unnamed_addr constant [39 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [45 x i8], align 1
@size_class_table = external hidden global [64 x i64], align 16
@.str.5 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @init_memory_pool(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca %union.pthread_mutexattr_t, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %15, label %14

14:                                               ; preds = %1
  call void (ptr, ...) @geometric_log_error(ptr noundef @.str)
  store ptr null, ptr %2, align 8
  br label %163

15:                                               ; preds = %1
  call void @init_size_classes()
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store ptr null, ptr %4, align 8, !tbaa !5
  %16 = call i32 @posix_memalign(ptr noundef %4, i64 noundef 64, i64 noundef 176) #6
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  call void (ptr, ...) @geometric_log_error(ptr noundef @.str.1)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %162

19:                                               ; preds = %15
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %20, i8 0, i64 176, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store ptr null, ptr %6, align 8, !tbaa !5
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.PoolConfig, ptr %21, i32 0, i32 2
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = mul i64 %23, 88
  %25 = call i32 @posix_memalign(ptr noundef %6, i64 noundef 64, i64 noundef %24) #6
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %19
  call void (ptr, ...) @geometric_log_error(ptr noundef @.str.2)
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %28) #6
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %161

29:                                               ; preds = %19
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.MemoryPool, ptr %31, i32 0, i32 2
  store ptr %30, ptr %32, align 8, !tbaa !14
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.MemoryPool, ptr %33, i32 0, i32 2
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.PoolConfig, ptr %36, i32 0, i32 2
  %38 = load i64, ptr %37, align 8, !tbaa !9
  %39 = mul i64 %38, 88
  call void @llvm.memset.p0.i64(ptr align 8 %35, i8 0, i64 %39, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %40 = call i32 @pthread_mutexattr_init(ptr noundef %7) #6
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %45

42:                                               ; preds = %29
  call void (ptr, ...) @geometric_log_error(ptr noundef @.str.3)
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %43) #6
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %44) #6
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %160

45:                                               ; preds = %29
  %46 = call i32 @pthread_mutexattr_settype(ptr noundef %7, i32 noundef 1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !16
  br label %47

47:                                               ; preds = %111, %45
  %48 = load i32, ptr %8, align 4, !tbaa !16
  %49 = sext i32 %48 to i64
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.PoolConfig, ptr %50, i32 0, i32 2
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = icmp ult i64 %49, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %47
  store i32 2, ptr %5, align 4
  br label %114

55:                                               ; preds = %47
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.MemoryPool, ptr %56, i32 0, i32 2
  %58 = load ptr, ptr %57, align 8, !tbaa !14
  %59 = load i32, ptr %8, align 4, !tbaa !16
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds %struct.SizeClass, ptr %58, i64 %60
  %62 = getelementptr inbounds %struct.SizeClass, ptr %61, i32 0, i32 2
  %63 = call i32 @pthread_mutex_init(ptr noundef %62, ptr noundef %7) #6
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %88

65:                                               ; preds = %55
  %66 = load i32, ptr %8, align 4, !tbaa !16
  call void (ptr, ...) @geometric_log_error(ptr noundef @.str.4, i32 noundef %66)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !16
  br label %67

67:                                               ; preds = %81, %65
  %68 = load i32, ptr %9, align 4, !tbaa !16
  %69 = load i32, ptr %8, align 4, !tbaa !16
  %70 = icmp slt i32 %68, %69
  br i1 %70, label %72, label %71

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

72:                                               ; preds = %67
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.MemoryPool, ptr %73, i32 0, i32 2
  %75 = load ptr, ptr %74, align 8, !tbaa !14
  %76 = load i32, ptr %9, align 4, !tbaa !16
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds %struct.SizeClass, ptr %75, i64 %77
  %79 = getelementptr inbounds %struct.SizeClass, ptr %78, i32 0, i32 2
  %80 = call i32 @pthread_mutex_destroy(ptr noundef %79) #6
  br label %81

81:                                               ; preds = %72
  %82 = load i32, ptr %9, align 4, !tbaa !16
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %9, align 4, !tbaa !16
  br label %67, !llvm.loop !18

84:                                               ; preds = %71
  %85 = call i32 @pthread_mutexattr_destroy(ptr noundef %7) #6
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %86) #6
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %87) #6
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %114

88:                                               ; preds = %55
  %89 = load i32, ptr %8, align 4, !tbaa !16
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [64 x i64], ptr @size_class_table, i64 0, i64 %90
  %92 = load atomic i64, ptr %91 acquire, align 8
  store i64 %92, ptr %10, align 8
  %93 = load i64, ptr %10, align 8, !tbaa !20
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.MemoryPool, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !14
  %97 = load i32, ptr %8, align 4, !tbaa !16
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds %struct.SizeClass, ptr %96, i64 %98
  %100 = getelementptr inbounds %struct.SizeClass, ptr %99, i32 0, i32 0
  store i64 %93, ptr %100, align 8, !tbaa !21
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.PoolConfig, ptr %101, i32 0, i32 7
  %103 = load i64, ptr %102, align 8, !tbaa !23
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.MemoryPool, ptr %104, i32 0, i32 2
  %106 = load ptr, ptr %105, align 8, !tbaa !14
  %107 = load i32, ptr %8, align 4, !tbaa !16
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds %struct.SizeClass, ptr %106, i64 %108
  %110 = getelementptr inbounds %struct.SizeClass, ptr %109, i32 0, i32 4
  store i64 %103, ptr %110, align 8, !tbaa !24
  br label %111

111:                                              ; preds = %88
  %112 = load i32, ptr %8, align 4, !tbaa !16
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %8, align 4, !tbaa !16
  br label %47, !llvm.loop !25

114:                                              ; preds = %84, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  %115 = load i32, ptr %5, align 4
  switch i32 %115, label %160 [
    i32 2, label %116
  ]

116:                                              ; preds = %114
  %117 = load ptr, ptr %4, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.MemoryPool, ptr %117, i32 0, i32 8
  %119 = call i32 @pthread_mutex_init(ptr noundef %118, ptr noundef %7) #6
  %120 = icmp ne i32 %119, 0
  br i1 %120, label %121, label %146

121:                                              ; preds = %116
  call void (ptr, ...) @geometric_log_error(ptr noundef @.str.5)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !16
  br label %122

122:                                              ; preds = %139, %121
  %123 = load i32, ptr %11, align 4, !tbaa !16
  %124 = sext i32 %123 to i64
  %125 = load ptr, ptr %3, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.PoolConfig, ptr %125, i32 0, i32 2
  %127 = load i64, ptr %126, align 8, !tbaa !9
  %128 = icmp ult i64 %124, %127
  br i1 %128, label %130, label %129

129:                                              ; preds = %122
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %142

130:                                              ; preds = %122
  %131 = load ptr, ptr %4, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.MemoryPool, ptr %131, i32 0, i32 2
  %133 = load ptr, ptr %132, align 8, !tbaa !14
  %134 = load i32, ptr %11, align 4, !tbaa !16
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds %struct.SizeClass, ptr %133, i64 %135
  %137 = getelementptr inbounds %struct.SizeClass, ptr %136, i32 0, i32 2
  %138 = call i32 @pthread_mutex_destroy(ptr noundef %137) #6
  br label %139

139:                                              ; preds = %130
  %140 = load i32, ptr %11, align 4, !tbaa !16
  %141 = add nsw i32 %140, 1
  store i32 %141, ptr %11, align 4, !tbaa !16
  br label %122, !llvm.loop !26

142:                                              ; preds = %129
  %143 = call i32 @pthread_mutexattr_destroy(ptr noundef %7) #6
  %144 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %144) #6
  %145 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %145) #6
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %160

146:                                              ; preds = %116
  %147 = call i32 @pthread_mutexattr_destroy(ptr noundef %7) #6
  %148 = load ptr, ptr %4, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.MemoryPool, ptr %148, i32 0, i32 9
  %150 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %149, ptr align 8 %150, i64 72, i1 false), !tbaa.struct !27
  %151 = load ptr, ptr %4, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.MemoryPool, ptr %151, i32 0, i32 3
  store i64 64, ptr %152, align 8, !tbaa !30
  %153 = load ptr, ptr %4, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.MemoryPool, ptr %153, i32 0, i32 5
  store i64 0, ptr %154, align 8, !tbaa !31
  %155 = load ptr, ptr %4, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.MemoryPool, ptr %155, i32 0, i32 6
  store i64 0, ptr %156, align 8, !tbaa !31
  %157 = load ptr, ptr %4, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.MemoryPool, ptr %157, i32 0, i32 7
  store i64 0, ptr %158, align 8, !tbaa !31
  call void (ptr, ...) @geometric_log_info(ptr noundef @.str.6, i32 noundef 64)
  %159 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %159, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %160

160:                                              ; preds = %146, %142, %114, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %161

161:                                              ; preds = %160, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %162

162:                                              ; preds = %161, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  br label %163

163:                                              ; preds = %162, %14
  %164 = load ptr, ptr %2, align 8
  ret ptr %164
}

declare void @geometric_log_error(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare hidden void @init_size_classes() #0

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

; Function Attrs: nounwind
declare i32 @posix_memalign(ptr noundef, i64 noundef, i64 noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @pthread_mutexattr_init(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @pthread_mutexattr_settype(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare i32 @pthread_mutex_init(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind
declare i32 @pthread_mutex_destroy(ptr noundef) #3

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

; Function Attrs: nounwind
declare i32 @pthread_mutexattr_destroy(ptr noundef) #3

; 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

declare void @geometric_log_info(ptr noundef, ...) #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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/C++ TBAA"}
!9 = !{!10, !11, i64 16}
!10 = !{!"PoolConfig", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !11, i64 32, !13, i64 40, !13, i64 41, !11, i64 48, !11, i64 56, !13, i64 64}
!11 = !{!"long", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!15, !6, i64 16}
!15 = !{!"MemoryPool", !6, i64 0, !11, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !10, i64 104}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!11, !11, i64 0}
!21 = !{!22, !11, i64 0}
!22 = !{!"SizeClass", !11, i64 0, !6, i64 8, !7, i64 16, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80}
!23 = !{!10, !11, i64 48}
!24 = !{!22, !11, i64 64}
!25 = distinct !{!25, !19}
!26 = distinct !{!26, !19}
!27 = !{i64 0, i64 8, !20, i64 8, i64 8, !20, i64 16, i64 8, !20, i64 24, i64 4, !28, i64 32, i64 8, !20, i64 40, i64 1, !29, i64 41, i64 1, !29, i64 48, i64 8, !20, i64 56, i64 8, !20, i64 64, i64 1, !29}
!28 = !{!12, !12, i64 0}
!29 = !{!13, !13, i64 0}
!30 = !{!15, !11, i64 24}
!31 = !{!7, !7, i64 0}


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

%union.pthread_mutexattr_t = type { i32 }
%struct.SizeClass = type { i64, ptr, %union.pthread_mutex_t, i64, i64, i64, i64 }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

@.str = external hidden unnamed_addr constant [39 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [45 x i8], align 1
@size_class_table = external hidden local_unnamed_addr global [64 x i64], align 16
@.str.5 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @init_memory_pool(ptr noundef readonly %0) local_unnamed_addr #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %union.pthread_mutexattr_t, align 4
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %1
  tail call void (ptr, ...) @geometric_log_error(ptr noundef nonnull @.str) #8
  br label %80

6:                                                ; preds = %1
  tail call void @init_size_classes()
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  store ptr null, ptr %2, align 8, !tbaa !5
  %7 = call i32 @posix_memalign(ptr noundef nonnull %2, i64 noundef 64, i64 noundef 176) #8
  %.not30 = icmp eq i32 %7, 0
  br i1 %.not30, label %9, label %8

8:                                                ; preds = %6
  call void (ptr, ...) @geometric_log_error(ptr noundef nonnull @.str.1) #8
  br label %79

9:                                                ; preds = %6
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(176) %10, i8 0, i64 176, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  store ptr null, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load i64, ptr %11, align 8, !tbaa !9
  %13 = mul i64 %12, 88
  %14 = call i32 @posix_memalign(ptr noundef nonnull %3, i64 noundef 64, i64 noundef %13) #8
  %.not31 = icmp eq i32 %14, 0
  br i1 %.not31, label %17, label %15

15:                                               ; preds = %9
  call void (ptr, ...) @geometric_log_error(ptr noundef nonnull @.str.2) #8
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %16) #8
  br label %78

17:                                               ; preds = %9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  store ptr %18, ptr %20, align 8, !tbaa !14
  %21 = load i64, ptr %11, align 8, !tbaa !9
  %22 = mul i64 %21, 88
  call void @llvm.memset.p0.i64(ptr align 8 %18, i8 0, i64 %22, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  %23 = call i32 @pthread_mutexattr_init(ptr noundef nonnull %4) #8
  %.not32 = icmp eq i32 %23, 0
  br i1 %.not32, label %27, label %24

24:                                               ; preds = %17
  call void (ptr, ...) @geometric_log_error(ptr noundef nonnull @.str.3) #8
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %25) #8
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %26) #8
  br label %77

27:                                               ; preds = %17
  %28 = call i32 @pthread_mutexattr_settype(ptr noundef nonnull %4, i32 noundef 1) #8
  %29 = load i64, ptr %11, align 8, !tbaa !9
  %.not3437.not = icmp eq i64 %29, 0
  %.pre59 = load ptr, ptr %2, align 8, !tbaa !5
  br i1 %.not3437.not, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %27
  %30 = getelementptr inbounds i8, ptr %0, i64 48
  %.phi.trans.insert = getelementptr inbounds i8, ptr %.pre59, i64 16
  %.pre58 = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !14
  br label %31

31:                                               ; preds = %.lr.ph, %45
  %32 = phi ptr [ %.pre58, %.lr.ph ], [ %50, %45 ]
  %indvars.iv52 = phi i32 [ 0, %.lr.ph ], [ %indvars.iv.next53, %45 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %45 ]
  %33 = getelementptr inbounds %struct.SizeClass, ptr %32, i64 %indvars.iv, i32 2
  %34 = call i32 @pthread_mutex_init(ptr noundef nonnull %33, ptr noundef nonnull %4) #8
  %.not33 = icmp eq i32 %34, 0
  br i1 %.not33, label %45, label %35

35:                                               ; preds = %31
  %36 = trunc nuw nsw i64 %indvars.iv to i32
  call void (ptr, ...) @geometric_log_error(ptr noundef nonnull @.str.4, i32 noundef %36) #8
  %.not45 = icmp eq i64 %indvars.iv, 0
  br i1 %.not45, label %._crit_edge44, label %.lr.ph43.preheader

.lr.ph43.preheader:                               ; preds = %35
  %wide.trip.count = zext i32 %indvars.iv52 to i64
  br label %.lr.ph43

._crit_edge44:                                    ; preds = %.lr.ph43, %35
  %37 = call i32 @pthread_mutexattr_destroy(ptr noundef nonnull %4) #8
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %38) #8
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %39) #8
  br label %77

.lr.ph43:                                         ; preds = %.lr.ph43.preheader, %.lr.ph43
  %indvars.iv49 = phi i64 [ 0, %.lr.ph43.preheader ], [ %indvars.iv.next50, %.lr.ph43 ]
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 16
  %42 = load ptr, ptr %41, align 8, !tbaa !14
  %43 = getelementptr inbounds %struct.SizeClass, ptr %42, i64 %indvars.iv49, i32 2
  %44 = call i32 @pthread_mutex_destroy(ptr noundef nonnull %43) #8
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next50, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge44, label %.lr.ph43, !llvm.loop !16

45:                                               ; preds = %31
  %46 = getelementptr inbounds [64 x i64], ptr @size_class_table, i64 0, i64 %indvars.iv
  %47 = load atomic i64, ptr %46 acquire, align 8
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 16
  %50 = load ptr, ptr %49, align 8, !tbaa !14
  %51 = getelementptr inbounds %struct.SizeClass, ptr %50, i64 %indvars.iv
  store i64 %47, ptr %51, align 8, !tbaa !18
  %52 = load i64, ptr %30, align 8, !tbaa !20
  %53 = getelementptr inbounds %struct.SizeClass, ptr %50, i64 %indvars.iv, i32 4
  store i64 %52, ptr %53, align 8, !tbaa !21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %54 = load i64, ptr %11, align 8, !tbaa !9
  %.not34 = icmp ugt i64 %54, %indvars.iv.next
  %indvars.iv.next53 = add nuw i32 %indvars.iv52, 1
  br i1 %.not34, label %31, label %.critedge, !llvm.loop !22

.critedge:                                        ; preds = %45, %27
  %55 = phi ptr [ %.pre59, %27 ], [ %48, %45 ]
  %56 = getelementptr inbounds i8, ptr %55, i64 64
  %57 = call i32 @pthread_mutex_init(ptr noundef nonnull %56, ptr noundef nonnull %4) #8
  %.not35 = icmp eq i32 %57, 0
  br i1 %.not35, label %70, label %58

58:                                               ; preds = %.critedge
  call void (ptr, ...) @geometric_log_error(ptr noundef nonnull @.str.5) #8
  %59 = load i64, ptr %11, align 8, !tbaa !9
  %.not46 = icmp eq i64 %59, 0
  br i1 %.not46, label %._crit_edge, label %.lr.ph40

._crit_edge:                                      ; preds = %.lr.ph40, %58
  %60 = call i32 @pthread_mutexattr_destroy(ptr noundef nonnull %4) #8
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %61) #8
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %62) #8
  br label %77

.lr.ph40:                                         ; preds = %58, %.lr.ph40
  %indvars.iv55 = phi i64 [ %indvars.iv.next56, %.lr.ph40 ], [ 0, %58 ]
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i64 16
  %65 = load ptr, ptr %64, align 8, !tbaa !14
  %66 = getelementptr inbounds %struct.SizeClass, ptr %65, i64 %indvars.iv55, i32 2
  %67 = call i32 @pthread_mutex_destroy(ptr noundef nonnull %66) #8
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %68 = load i64, ptr %11, align 8, !tbaa !9
  %69 = icmp ugt i64 %68, %indvars.iv.next56
  br i1 %69, label %.lr.ph40, label %._crit_edge, !llvm.loop !23

70:                                               ; preds = %.critedge
  %71 = call i32 @pthread_mutexattr_destroy(ptr noundef nonnull %4) #8
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %72, i64 104
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %73, ptr noundef nonnull align 8 dereferenceable(72) %0, i64 72, i1 false), !tbaa.struct !24
  %74 = getelementptr inbounds i8, ptr %72, i64 24
  store i64 64, ptr %74, align 8, !tbaa !28
  %75 = getelementptr inbounds i8, ptr %72, i64 40
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %75, i8 0, i64 24, i1 false)
  call void (ptr, ...) @geometric_log_info(ptr noundef nonnull @.str.6, i32 noundef 64) #8
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  br label %77

77:                                               ; preds = %._crit_edge44, %70, %._crit_edge, %24
  %.1 = phi ptr [ null, %24 ], [ null, %._crit_edge ], [ %76, %70 ], [ null, %._crit_edge44 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  br label %78

78:                                               ; preds = %77, %15
  %.2 = phi ptr [ null, %15 ], [ %.1, %77 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  br label %79

79:                                               ; preds = %78, %8
  %.3 = phi ptr [ null, %8 ], [ %.2, %78 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  br label %80

80:                                               ; preds = %79, %5
  %.4 = phi ptr [ %.3, %79 ], [ null, %5 ]
  ret ptr %.4
}

declare void @geometric_log_error(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @init_size_classes() local_unnamed_addr #0

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

; Function Attrs: nofree nounwind
declare i32 @posix_memalign(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: nounwind
declare i32 @pthread_mutexattr_init(ptr noundef) local_unnamed_addr #6

; Function Attrs: nounwind
declare i32 @pthread_mutexattr_settype(ptr noundef, i32 noundef) local_unnamed_addr #6

; Function Attrs: nounwind
declare i32 @pthread_mutex_init(ptr noundef, ptr noundef) local_unnamed_addr #6

; Function Attrs: nounwind
declare i32 @pthread_mutex_destroy(ptr noundef) local_unnamed_addr #6

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

; Function Attrs: nounwind
declare i32 @pthread_mutexattr_destroy(ptr noundef) local_unnamed_addr #6

; 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) #7

declare void @geometric_log_info(ptr noundef, ...) local_unnamed_addr #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nofree 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #8 = { 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/C++ TBAA"}
!9 = !{!10, !11, i64 16}
!10 = !{!"PoolConfig", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !11, i64 32, !13, i64 40, !13, i64 41, !11, i64 48, !11, i64 56, !13, i64 64}
!11 = !{!"long", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!15, !6, i64 16}
!15 = !{!"MemoryPool", !6, i64 0, !11, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !10, i64 104}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !11, i64 0}
!19 = !{!"SizeClass", !11, i64 0, !6, i64 8, !7, i64 16, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80}
!20 = !{!10, !11, i64 48}
!21 = !{!19, !11, i64 64}
!22 = distinct !{!22, !17}
!23 = distinct !{!23, !17}
!24 = !{i64 0, i64 8, !25, i64 8, i64 8, !25, i64 16, i64 8, !25, i64 24, i64 4, !26, i64 32, i64 8, !25, i64 40, i64 1, !27, i64 41, i64 1, !27, i64 48, i64 8, !25, i64 56, i64 8, !25, i64 64, i64 1, !27}
!25 = !{!11, !11, i64 0}
!26 = !{!12, !12, i64 0}
!27 = !{!13, !13, i64 0}
!28 = !{!15, !11, i64 24}


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