; LLVM IR from jingweizhanghuai/Morn :: src/ptc (morn_thread_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"

%struct.HandleThreadPool = type { ptr, i32, ptr, i32, i32, i32, i32, i32, %struct.MThreadSignal, ptr }
%struct.MThreadSignal = type { %union.pthread_mutex_t, %union.pthread_cond_t, %union.pthread_rwlock_t, i32 }
%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 }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }
%union.pthread_rwlock_t = type { %struct.__pthread_rwlock_arch_t }
%struct.__pthread_rwlock_arch_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i8, [7 x i8], i64, i32 }
%struct.MList = type { i32, ptr }
%struct.ThreadPoolData = type { i64, %struct.MThreadSignal, ptr, ptr, ptr, ptr, i32 }

@.str = external hidden unnamed_addr constant [82 x i8], align 1
@__FUNCTION__.ThreadPoolNumber = external hidden unnamed_addr constant [17 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@ThreadPoolNumber.Sgn_valid = external hidden global i32, align 4
@.str.3 = external hidden unnamed_addr constant [20 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: nounwind
declare i32 @pthread_mutex_init(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind
declare i32 @pthread_rwlock_init(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) #1

; Function Attrs: nounwind
declare i32 @pthread_cond_signal(ptr noundef) #1

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) #1

declare i32 @pthread_join(i64 noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @ThreadFunc(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @ThreadPoolNumber(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %14, ptr %5, align 4, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.HandleThreadPool, ptr %15, i32 0, i32 7
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %23

19:                                               ; preds = %2
  %20 = call i32 (...) @mThreadID()
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.HandleThreadPool, ptr %21, i32 0, i32 7
  store i32 %20, ptr %22, align 8, !tbaa !11
  br label %38

23:                                               ; preds = %2
  br label %24

24:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.HandleThreadPool, ptr %25, i32 0, i32 7
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = call i32 (...) @mThreadID()
  %29 = icmp ne i32 %27, %28
  %30 = zext i1 %29 to i32
  store i32 %30, ptr %6, align 4, !tbaa !9
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %24
  %34 = load i32, ptr %6, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %34, i32 noundef -1, ptr noundef @.str, i32 noundef 99, ptr noundef @__FUNCTION__.ThreadPoolNumber, ptr noundef @.str.2)
  br label %35

35:                                               ; preds = %33, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37, %19
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.HandleThreadPool, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 8, !tbaa !14
  %43 = icmp eq i32 %39, %42
  br i1 %43, label %44, label %45

44:                                               ; preds = %38
  store i32 1, ptr %7, align 4
  br label %168

45:                                               ; preds = %38
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.HandleThreadPool, ptr %47, i32 0, i32 1
  %49 = load i32, ptr %48, align 8, !tbaa !14
  %50 = icmp slt i32 %46, %49
  br i1 %50, label %51, label %129

51:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %52 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %52, ptr %8, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %125, %51
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.HandleThreadPool, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 8, !tbaa !14
  %58 = icmp slt i32 %54, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %53
  store i32 4, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %128

60:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.HandleThreadPool, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !15
  %64 = getelementptr inbounds %struct.MList, ptr %63, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !16
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds ptr, ptr %65, i64 %67
  %69 = load ptr, ptr %68, align 8, !tbaa !5
  store ptr %69, ptr %9, align 8, !tbaa !5
  br label %70

70:                                               ; preds = %75, %60
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.ThreadPoolData, ptr %71, i32 0, i32 6
  %73 = load volatile i32, ptr %72, align 8, !tbaa !18
  %74 = icmp eq i32 %73, 1
  br i1 %74, label %75, label %76

75:                                               ; preds = %70
  br label %70, !llvm.loop !21

76:                                               ; preds = %70
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.ThreadPoolData, ptr %77, i32 0, i32 3
  store ptr null, ptr %78, align 8, !tbaa !23
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.ThreadPoolData, ptr %79, i32 0, i32 6
  store volatile i32 1, ptr %80, align 8, !tbaa !18
  br label %81

81:                                               ; preds = %76
  br label %82

82:                                               ; preds = %81
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr @ThreadPoolNumber.Sgn_valid, align 4, !tbaa !9
  %85 = icmp eq i32 %84, 0
  br i1 %85, label %86, label %102

86:                                               ; preds = %83
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.ThreadPoolData, ptr %87, i32 0, i32 1
  %89 = getelementptr inbounds %struct.MThreadSignal, ptr %88, i32 0, i32 3
  %90 = atomicrmw xchg ptr %89, i32 -1135873169 seq_cst, align 8
  %91 = icmp ne i32 %90, -1135873169
  br i1 %91, label %92, label %101

92:                                               ; preds = %86
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.ThreadPoolData, ptr %93, i32 0, i32 1
  %95 = getelementptr inbounds %struct.MThreadSignal, ptr %94, i32 0, i32 0
  %96 = call i32 @pthread_mutex_init(ptr noundef %95, ptr noundef null) #4
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.ThreadPoolData, ptr %97, i32 0, i32 1
  %99 = getelementptr inbounds %struct.MThreadSignal, ptr %98, i32 0, i32 2
  %100 = call i32 @pthread_rwlock_init(ptr noundef %99, ptr noundef null) #4
  br label %101

101:                                              ; preds = %92, %86
  store i32 1, ptr @ThreadPoolNumber.Sgn_valid, align 4, !tbaa !9
  br label %102

102:                                              ; preds = %101, %83
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103
  %105 = load ptr, ptr %9, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.ThreadPoolData, ptr %105, i32 0, i32 1
  %107 = getelementptr inbounds %struct.MThreadSignal, ptr %106, i32 0, i32 0
  %108 = call i32 @pthread_mutex_lock(ptr noundef %107) #4
  br label %109

109:                                              ; preds = %104
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr %9, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.ThreadPoolData, ptr %111, i32 0, i32 1
  %113 = getelementptr inbounds %struct.MThreadSignal, ptr %112, i32 0, i32 1
  %114 = call i32 @pthread_cond_signal(ptr noundef %113) #4
  %115 = load ptr, ptr %9, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.ThreadPoolData, ptr %115, i32 0, i32 1
  %117 = getelementptr inbounds %struct.MThreadSignal, ptr %116, i32 0, i32 0
  %118 = call i32 @pthread_mutex_unlock(ptr noundef %117) #4
  br label %119

119:                                              ; preds = %110
  br label %120

120:                                              ; preds = %119
  %121 = load ptr, ptr %9, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.ThreadPoolData, ptr %121, i32 0, i32 0
  %123 = load i64, ptr %122, align 8, !tbaa !24
  %124 = call i32 @pthread_join(i64 noundef %123, ptr noundef null)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %125

125:                                              ; preds = %120
  %126 = load i32, ptr %8, align 4, !tbaa !9
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %8, align 4, !tbaa !9
  br label %53, !llvm.loop !25

128:                                              ; preds = %59
  br label %163

129:                                              ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.HandleThreadPool, ptr %130, i32 0, i32 1
  %132 = load i32, ptr %131, align 8, !tbaa !14
  store i32 %132, ptr %10, align 4, !tbaa !9
  br label %133

133:                                              ; preds = %159, %129
  %134 = load i32, ptr %10, align 4, !tbaa !9
  %135 = load i32, ptr %5, align 4, !tbaa !9
  %136 = icmp slt i32 %134, %135
  br i1 %136, label %138, label %137

137:                                              ; preds = %133
  store i32 15, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %162

138:                                              ; preds = %133
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %139 = load ptr, ptr %4, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.HandleThreadPool, ptr %139, i32 0, i32 0
  %141 = load ptr, ptr %140, align 8, !tbaa !15
  %142 = call ptr @mListWrite(ptr noundef %141, i32 noundef -1, ptr noundef null, i32 noundef 200)
  store ptr %142, ptr %11, align 8, !tbaa !5
  %143 = load ptr, ptr %11, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.ThreadPoolData, ptr %143, i32 0, i32 6
  store volatile i32 0, ptr %144, align 8, !tbaa !18
  br label %145

145:                                              ; preds = %138
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %146 = load ptr, ptr %11, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.ThreadPoolData, ptr %146, i32 0, i32 0
  %148 = load ptr, ptr %11, align 8, !tbaa !5
  %149 = call i32 @pthread_create(ptr noundef %147, ptr noundef null, ptr noundef @ThreadFunc, ptr noundef %148) #4
  %150 = icmp ne i32 %149, 0
  %151 = zext i1 %150 to i32
  store i32 %151, ptr %12, align 4, !tbaa !9
  %152 = load i32, ptr %12, align 4, !tbaa !9
  %153 = icmp ne i32 %152, 0
  br i1 %153, label %154, label %156

154:                                              ; preds = %145
  %155 = load i32, ptr %12, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %155, i32 noundef -1, ptr noundef @.str, i32 noundef 120, ptr noundef @__FUNCTION__.ThreadPoolNumber, ptr noundef @.str.3)
  br label %156

156:                                              ; preds = %154, %145
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %157

157:                                              ; preds = %156
  br label %158

158:                                              ; preds = %157
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %159

159:                                              ; preds = %158
  %160 = load i32, ptr %10, align 4, !tbaa !9
  %161 = add nsw i32 %160, 1
  store i32 %161, ptr %10, align 4, !tbaa !9
  br label %133, !llvm.loop !26

162:                                              ; preds = %137
  br label %163

163:                                              ; preds = %162, %128
  br label %164

164:                                              ; preds = %163
  %165 = load i32, ptr %5, align 4, !tbaa !9
  %166 = load ptr, ptr %4, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.HandleThreadPool, ptr %166, i32 0, i32 1
  store i32 %165, ptr %167, align 8, !tbaa !14
  store i32 0, ptr %7, align 4
  br label %168

168:                                              ; preds = %164, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %169 = load i32, ptr %7, align 4
  switch i32 %169, label %171 [
    i32 0, label %170
    i32 1, label %170
  ]

170:                                              ; preds = %168, %168
  ret void

171:                                              ; preds = %168
  unreachable
}

declare i32 @mThreadID(...) #2

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #2

declare ptr @mListWrite(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind
declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = { 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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 40}
!12 = !{!"HandleThreadPool", !6, i64 0, !10, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !13, i64 48, !6, i64 200}
!13 = !{!"MThreadSignal", !7, i64 0, !7, i64 40, !7, i64 88, !10, i64 144}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !6, i64 0}
!16 = !{!17, !6, i64 8}
!17 = !{!"MList", !10, i64 0, !6, i64 8}
!18 = !{!19, !10, i64 192}
!19 = !{!"ThreadPoolData", !20, i64 0, !13, i64 8, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !10, i64 192}
!20 = !{!"long", !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!19, !6, i64 168}
!24 = !{!19, !20, i64 0}
!25 = distinct !{!25, !22}
!26 = distinct !{!26, !22}


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

@.str = external hidden unnamed_addr constant [82 x i8], align 1
@__FUNCTION__.ThreadPoolNumber = external hidden unnamed_addr constant [17 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@ThreadPoolNumber.Sgn_valid = external hidden local_unnamed_addr global i32, align 4
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1

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

; Function Attrs: nounwind
declare i32 @pthread_rwlock_init(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind
declare i32 @pthread_cond_signal(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) local_unnamed_addr #0

declare i32 @pthread_join(i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @ThreadFunc(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @ThreadPoolNumber(ptr nocapture noundef readonly %0, ptr nocapture noundef %1) local_unnamed_addr #2 {
  %3 = load i32, ptr %0, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 40
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %6 = icmp eq i32 %5, 0
  %7 = tail call i32 (...) @mThreadID() #3
  br i1 %6, label %8, label %9

8:                                                ; preds = %2
  store i32 %7, ptr %4, align 8, !tbaa !9
  br label %11

9:                                                ; preds = %2
  %.not41 = icmp eq i32 %5, %7
  br i1 %.not41, label %11, label %10

10:                                               ; preds = %9
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 99, ptr noundef nonnull @__FUNCTION__.ThreadPoolNumber, ptr noundef nonnull @.str.2) #3
  br label %11

11:                                               ; preds = %9, %10, %8
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = icmp eq i32 %3, %13
  br i1 %14, label %59, label %15

15:                                               ; preds = %11
  %16 = icmp slt i32 %3, %13
  br i1 %16, label %.lr.ph47.preheader, label %.preheader43

.preheader43:                                     ; preds = %15
  %17 = icmp slt i32 %13, %3
  br i1 %17, label %.lr.ph, label %.loopexit

.lr.ph47.preheader:                               ; preds = %15
  %18 = sext i32 %3 to i64
  br label %.lr.ph47

.lr.ph47:                                         ; preds = %.lr.ph47.preheader, %41
  %indvars.iv = phi i64 [ %18, %.lr.ph47.preheader ], [ %indvars.iv.next, %41 ]
  %19 = load ptr, ptr %1, align 8, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = getelementptr inbounds ptr, ptr %21, i64 %indvars.iv
  %23 = load ptr, ptr %22, align 8, !tbaa !17
  %24 = getelementptr inbounds i8, ptr %23, i64 192
  br label %25

25:                                               ; preds = %25, %.lr.ph47
  %26 = load volatile i32, ptr %24, align 8, !tbaa !18
  %27 = icmp eq i32 %26, 1
  br i1 %27, label %25, label %28, !llvm.loop !21

28:                                               ; preds = %25
  %29 = getelementptr inbounds i8, ptr %23, i64 168
  store ptr null, ptr %29, align 8, !tbaa !23
  store volatile i32 1, ptr %24, align 8, !tbaa !18
  %30 = load i32, ptr @ThreadPoolNumber.Sgn_valid, align 4, !tbaa !5
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %41

32:                                               ; preds = %28
  %33 = getelementptr inbounds i8, ptr %23, i64 152
  %34 = atomicrmw xchg ptr %33, i32 -1135873169 seq_cst, align 8
  %.not = icmp eq i32 %34, -1135873169
  br i1 %.not, label %40, label %35

35:                                               ; preds = %32
  %36 = getelementptr inbounds i8, ptr %23, i64 8
  %37 = tail call i32 @pthread_mutex_init(ptr noundef nonnull %36, ptr noundef null) #3
  %38 = getelementptr inbounds i8, ptr %23, i64 96
  %39 = tail call i32 @pthread_rwlock_init(ptr noundef nonnull %38, ptr noundef null) #3
  br label %40

40:                                               ; preds = %35, %32
  store i32 1, ptr @ThreadPoolNumber.Sgn_valid, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %40, %28
  %42 = getelementptr inbounds i8, ptr %23, i64 8
  %43 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull %42) #3
  %44 = getelementptr inbounds i8, ptr %23, i64 48
  %45 = tail call i32 @pthread_cond_signal(ptr noundef nonnull %44) #3
  %46 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull %42) #3
  %47 = load i64, ptr %23, align 8, !tbaa !24
  %48 = tail call i32 @pthread_join(i64 noundef %47, ptr noundef null) #3
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %49 = load i32, ptr %12, align 8, !tbaa !13
  %50 = sext i32 %49 to i64
  %51 = icmp slt i64 %indvars.iv.next, %50
  br i1 %51, label %.lr.ph47, label %.loopexit, !llvm.loop !25

.lr.ph:                                           ; preds = %.preheader43, %57
  %.03745 = phi i32 [ %58, %57 ], [ %13, %.preheader43 ]
  %52 = load ptr, ptr %1, align 8, !tbaa !14
  %53 = tail call ptr @mListWrite(ptr noundef %52, i32 noundef -1, ptr noundef null, i32 noundef 200) #3
  %54 = getelementptr inbounds i8, ptr %53, i64 192
  store volatile i32 0, ptr %54, align 8, !tbaa !18
  %55 = tail call i32 @pthread_create(ptr noundef %53, ptr noundef null, ptr noundef nonnull @ThreadFunc, ptr noundef %53) #3
  %.not42 = icmp eq i32 %55, 0
  br i1 %.not42, label %57, label %56

56:                                               ; preds = %.lr.ph
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 120, ptr noundef nonnull @__FUNCTION__.ThreadPoolNumber, ptr noundef nonnull @.str.3) #3
  br label %57

57:                                               ; preds = %56, %.lr.ph
  %58 = add i32 %.03745, 1
  %exitcond.not = icmp eq i32 %58, %3
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !26

.loopexit:                                        ; preds = %57, %41, %.preheader43
  store i32 %3, ptr %12, align 8, !tbaa !13
  br label %59

59:                                               ; preds = %11, %.loopexit
  ret void
}

declare i32 @mThreadID(...) local_unnamed_addr #1

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

declare ptr @mListWrite(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { 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 #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 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !6, i64 40}
!10 = !{!"HandleThreadPool", !11, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !12, i64 48, !11, i64 200}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"MThreadSignal", !7, i64 0, !7, i64 40, !7, i64 88, !6, i64 144}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !11, i64 0}
!15 = !{!16, !11, i64 8}
!16 = !{!"MList", !6, i64 0, !11, i64 8}
!17 = !{!11, !11, i64 0}
!18 = !{!19, !6, i64 192}
!19 = !{!"ThreadPoolData", !20, i64 0, !12, i64 8, !11, i64 160, !11, i64 168, !11, i64 176, !11, i64 184, !6, i64 192}
!20 = !{!"long", !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!19, !11, i64 168}
!24 = !{!19, !20, i64 0}
!25 = distinct !{!25, !22}
!26 = distinct !{!26, !22}


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