; LLVM IR from pupnp/pupnp :: upnp/src/threadutil (ThreadPool)

; 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.THREADPOOL = type { %union.pthread_mutex_t, %union.pthread_cond_t, %union.pthread_cond_t, i32, i32, i32, i32, i32, i32, %struct.FREELIST, %struct.LINKEDLIST, %struct.LINKEDLIST, %struct.LINKEDLIST, ptr, %struct.THREADPOOLATTR, %struct.TPOOLSTATS }
%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 }
%struct.FREELIST = type { ptr, i64, i32, i32 }
%struct.LINKEDLIST = type { %struct.LISTNODE, %struct.LISTNODE, i64, %struct.FREELIST, ptr, ptr }
%struct.LISTNODE = type { ptr, ptr, ptr }
%struct.THREADPOOLATTR = type { i32, i32, i64, i32, i32, i32, i32, i32 }
%struct.TPOOLSTATS = type { double, i32, double, double, i32, double, double, i32, double, double, double, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.THREADPOOLJOB = type { ptr, ptr, ptr, %struct.timeval, i32, i32 }
%struct.timeval = type { i64, i64 }

; 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_lock(ptr noundef) #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ThreadPoolShutdown(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store ptr null, ptr %5, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %10, label %9

9:                                                ; preds = %1
  store i32 22, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %209

10:                                               ; preds = %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.THREADPOOL, ptr %11, i32 0, i32 0
  %13 = call i32 @pthread_mutex_lock(ptr noundef %12) #4
  br label %14

14:                                               ; preds = %45, %10
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.THREADPOOL, ptr %15, i32 0, i32 12
  %17 = getelementptr inbounds %struct.LINKEDLIST, ptr %16, i32 0, i32 2
  %18 = load i64, ptr %17, align 8, !tbaa !9
  %19 = icmp ne i64 %18, 0
  br i1 %19, label %20, label %52

20:                                               ; preds = %14
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.THREADPOOL, ptr %21, i32 0, i32 12
  %23 = call ptr @ListHead(ptr noundef %22)
  store ptr %23, ptr %4, align 8, !tbaa !5
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %30

26:                                               ; preds = %20
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.THREADPOOL, ptr %27, i32 0, i32 0
  %29 = call i32 @pthread_mutex_unlock(ptr noundef %28) #4
  store i32 22, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %209

30:                                               ; preds = %20
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.LISTNODE, ptr %31, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !19
  store ptr %33, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.THREADPOOLJOB, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !20
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %45

38:                                               ; preds = %30
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.THREADPOOLJOB, ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !20
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.THREADPOOLJOB, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !23
  call void %41(ptr noundef %44)
  br label %45

45:                                               ; preds = %38, %30
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  call void @FreeThreadPoolJob(ptr noundef %46, ptr noundef %47)
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.THREADPOOL, ptr %48, i32 0, i32 12
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = call ptr @ListDelNode(ptr noundef %49, ptr noundef %50, i32 noundef 0)
  br label %14, !llvm.loop !24

52:                                               ; preds = %14
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.THREADPOOL, ptr %53, i32 0, i32 12
  %55 = call i32 @ListDestroy(ptr noundef %54, i32 noundef 0)
  br label %56

56:                                               ; preds = %87, %52
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.THREADPOOL, ptr %57, i32 0, i32 11
  %59 = getelementptr inbounds %struct.LINKEDLIST, ptr %58, i32 0, i32 2
  %60 = load i64, ptr %59, align 8, !tbaa !26
  %61 = icmp ne i64 %60, 0
  br i1 %61, label %62, label %94

62:                                               ; preds = %56
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.THREADPOOL, ptr %63, i32 0, i32 11
  %65 = call ptr @ListHead(ptr noundef %64)
  store ptr %65, ptr %4, align 8, !tbaa !5
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = icmp eq ptr %66, null
  br i1 %67, label %68, label %72

68:                                               ; preds = %62
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.THREADPOOL, ptr %69, i32 0, i32 0
  %71 = call i32 @pthread_mutex_unlock(ptr noundef %70) #4
  store i32 22, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %209

72:                                               ; preds = %62
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.LISTNODE, ptr %73, i32 0, i32 2
  %75 = load ptr, ptr %74, align 8, !tbaa !19
  store ptr %75, ptr %5, align 8, !tbaa !5
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.THREADPOOLJOB, ptr %76, i32 0, i32 2
  %78 = load ptr, ptr %77, align 8, !tbaa !20
  %79 = icmp ne ptr %78, null
  br i1 %79, label %80, label %87

80:                                               ; preds = %72
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.THREADPOOLJOB, ptr %81, i32 0, i32 2
  %83 = load ptr, ptr %82, align 8, !tbaa !20
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.THREADPOOLJOB, ptr %84, i32 0, i32 1
  %86 = load ptr, ptr %85, align 8, !tbaa !23
  call void %83(ptr noundef %86)
  br label %87

87:                                               ; preds = %80, %72
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  call void @FreeThreadPoolJob(ptr noundef %88, ptr noundef %89)
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.THREADPOOL, ptr %90, i32 0, i32 11
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = call ptr @ListDelNode(ptr noundef %91, ptr noundef %92, i32 noundef 0)
  br label %56, !llvm.loop !27

94:                                               ; preds = %56
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.THREADPOOL, ptr %95, i32 0, i32 11
  %97 = call i32 @ListDestroy(ptr noundef %96, i32 noundef 0)
  br label %98

98:                                               ; preds = %129, %94
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.THREADPOOL, ptr %99, i32 0, i32 10
  %101 = getelementptr inbounds %struct.LINKEDLIST, ptr %100, i32 0, i32 2
  %102 = load i64, ptr %101, align 8, !tbaa !28
  %103 = icmp ne i64 %102, 0
  br i1 %103, label %104, label %136

104:                                              ; preds = %98
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.THREADPOOL, ptr %105, i32 0, i32 10
  %107 = call ptr @ListHead(ptr noundef %106)
  store ptr %107, ptr %4, align 8, !tbaa !5
  %108 = load ptr, ptr %4, align 8, !tbaa !5
  %109 = icmp eq ptr %108, null
  br i1 %109, label %110, label %114

110:                                              ; preds = %104
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.THREADPOOL, ptr %111, i32 0, i32 0
  %113 = call i32 @pthread_mutex_unlock(ptr noundef %112) #4
  store i32 22, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %209

114:                                              ; preds = %104
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.LISTNODE, ptr %115, i32 0, i32 2
  %117 = load ptr, ptr %116, align 8, !tbaa !19
  store ptr %117, ptr %5, align 8, !tbaa !5
  %118 = load ptr, ptr %5, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.THREADPOOLJOB, ptr %118, i32 0, i32 2
  %120 = load ptr, ptr %119, align 8, !tbaa !20
  %121 = icmp ne ptr %120, null
  br i1 %121, label %122, label %129

122:                                              ; preds = %114
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.THREADPOOLJOB, ptr %123, i32 0, i32 2
  %125 = load ptr, ptr %124, align 8, !tbaa !20
  %126 = load ptr, ptr %5, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.THREADPOOLJOB, ptr %126, i32 0, i32 1
  %128 = load ptr, ptr %127, align 8, !tbaa !23
  call void %125(ptr noundef %128)
  br label %129

129:                                              ; preds = %122, %114
  %130 = load ptr, ptr %3, align 8, !tbaa !5
  %131 = load ptr, ptr %5, align 8, !tbaa !5
  call void @FreeThreadPoolJob(ptr noundef %130, ptr noundef %131)
  %132 = load ptr, ptr %3, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.THREADPOOL, ptr %132, i32 0, i32 10
  %134 = load ptr, ptr %4, align 8, !tbaa !5
  %135 = call ptr @ListDelNode(ptr noundef %133, ptr noundef %134, i32 noundef 0)
  br label %98, !llvm.loop !29

136:                                              ; preds = %98
  %137 = load ptr, ptr %3, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.THREADPOOL, ptr %137, i32 0, i32 10
  %139 = call i32 @ListDestroy(ptr noundef %138, i32 noundef 0)
  %140 = load ptr, ptr %3, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.THREADPOOL, ptr %140, i32 0, i32 13
  %142 = load ptr, ptr %141, align 8, !tbaa !30
  %143 = icmp ne ptr %142, null
  br i1 %143, label %144, label %164

144:                                              ; preds = %136
  %145 = load ptr, ptr %3, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.THREADPOOL, ptr %145, i32 0, i32 13
  %147 = load ptr, ptr %146, align 8, !tbaa !30
  store ptr %147, ptr %5, align 8, !tbaa !5
  %148 = load ptr, ptr %5, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.THREADPOOLJOB, ptr %148, i32 0, i32 2
  %150 = load ptr, ptr %149, align 8, !tbaa !20
  %151 = icmp ne ptr %150, null
  br i1 %151, label %152, label %159

152:                                              ; preds = %144
  %153 = load ptr, ptr %5, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.THREADPOOLJOB, ptr %153, i32 0, i32 2
  %155 = load ptr, ptr %154, align 8, !tbaa !20
  %156 = load ptr, ptr %5, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.THREADPOOLJOB, ptr %156, i32 0, i32 1
  %158 = load ptr, ptr %157, align 8, !tbaa !23
  call void %155(ptr noundef %158)
  br label %159

159:                                              ; preds = %152, %144
  %160 = load ptr, ptr %3, align 8, !tbaa !5
  %161 = load ptr, ptr %5, align 8, !tbaa !5
  call void @FreeThreadPoolJob(ptr noundef %160, ptr noundef %161)
  %162 = load ptr, ptr %3, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.THREADPOOL, ptr %162, i32 0, i32 13
  store ptr null, ptr %163, align 8, !tbaa !30
  br label %164

164:                                              ; preds = %159, %136
  %165 = load ptr, ptr %3, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.THREADPOOL, ptr %165, i32 0, i32 4
  store i32 1, ptr %166, align 4, !tbaa !31
  %167 = load ptr, ptr %3, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.THREADPOOL, ptr %167, i32 0, i32 1
  %169 = call i32 @pthread_cond_broadcast(ptr noundef %168) #4
  br label %170

170:                                              ; preds = %175, %164
  %171 = load ptr, ptr %3, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.THREADPOOL, ptr %171, i32 0, i32 5
  %173 = load i32, ptr %172, align 8, !tbaa !32
  %174 = icmp sgt i32 %173, 0
  br i1 %174, label %175, label %181

175:                                              ; preds = %170
  %176 = load ptr, ptr %3, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.THREADPOOL, ptr %176, i32 0, i32 2
  %178 = load ptr, ptr %3, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.THREADPOOL, ptr %178, i32 0, i32 0
  %180 = call i32 @pthread_cond_wait(ptr noundef %177, ptr noundef %179)
  br label %170, !llvm.loop !33

181:                                              ; preds = %170
  br label %182

182:                                              ; preds = %187, %181
  %183 = load ptr, ptr %3, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.THREADPOOL, ptr %183, i32 0, i32 1
  %185 = call i32 @pthread_cond_destroy(ptr noundef %184) #4
  %186 = icmp ne i32 %185, 0
  br i1 %186, label %187, label %188

187:                                              ; preds = %182
  br label %182, !llvm.loop !34

188:                                              ; preds = %182
  br label %189

189:                                              ; preds = %194, %188
  %190 = load ptr, ptr %3, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.THREADPOOL, ptr %190, i32 0, i32 2
  %192 = call i32 @pthread_cond_destroy(ptr noundef %191) #4
  %193 = icmp ne i32 %192, 0
  br i1 %193, label %194, label %195

194:                                              ; preds = %189
  br label %189, !llvm.loop !35

195:                                              ; preds = %189
  %196 = load ptr, ptr %3, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.THREADPOOL, ptr %196, i32 0, i32 9
  %198 = call i32 @FreeListDestroy(ptr noundef %197)
  %199 = load ptr, ptr %3, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.THREADPOOL, ptr %199, i32 0, i32 0
  %201 = call i32 @pthread_mutex_unlock(ptr noundef %200) #4
  br label %202

202:                                              ; preds = %207, %195
  %203 = load ptr, ptr %3, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct.THREADPOOL, ptr %203, i32 0, i32 0
  %205 = call i32 @pthread_mutex_destroy(ptr noundef %204) #4
  %206 = icmp ne i32 %205, 0
  br i1 %206, label %207, label %208

207:                                              ; preds = %202
  br label %202, !llvm.loop !36

208:                                              ; preds = %202
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %209

209:                                              ; preds = %208, %110, %68, %26, %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %210 = load i32, ptr %2, align 4
  ret i32 %210
}

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

declare i32 @pthread_cond_wait(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @FreeThreadPoolJob(ptr noundef, ptr noundef) #2

declare ptr @ListDelNode(ptr noundef, ptr noundef, i32 noundef) #3

declare ptr @ListHead(ptr noundef) #3

declare i32 @ListDestroy(ptr noundef, i32 noundef) #3

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

declare i32 @FreeListDestroy(ptr noundef) #3

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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !13, i64 424}
!10 = !{!"THREADPOOL", !7, i64 0, !7, i64 40, !7, i64 88, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !11, i64 152, !11, i64 156, !12, i64 160, !14, i64 184, !14, i64 280, !14, i64 376, !6, i64 472, !16, i64 480, !17, i64 520}
!11 = !{!"int", !7, i64 0}
!12 = !{!"FREELIST", !6, i64 0, !13, i64 8, !11, i64 16, !11, i64 20}
!13 = !{!"long", !7, i64 0}
!14 = !{!"LINKEDLIST", !15, i64 0, !15, i64 24, !13, i64 48, !12, i64 56, !6, i64 80, !6, i64 88}
!15 = !{!"LISTNODE", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!"THREADPOOLATTR", !11, i64 0, !11, i64 4, !13, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32}
!17 = !{!"TPOOLSTATS", !18, i64 0, !11, i64 8, !18, i64 16, !18, i64 24, !11, i64 32, !18, i64 40, !18, i64 48, !11, i64 56, !18, i64 64, !18, i64 72, !18, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116}
!18 = !{!"double", !7, i64 0}
!19 = !{!15, !6, i64 16}
!20 = !{!21, !6, i64 16}
!21 = !{!"THREADPOOLJOB", !6, i64 0, !6, i64 8, !6, i64 16, !22, i64 24, !11, i64 40, !11, i64 44}
!22 = !{!"timeval", !13, i64 0, !13, i64 8}
!23 = !{!21, !6, i64 8}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!10, !13, i64 328}
!27 = distinct !{!27, !25}
!28 = !{!10, !13, i64 232}
!29 = distinct !{!29, !25}
!30 = !{!10, !6, i64 472}
!31 = !{!10, !11, i64 140}
!32 = !{!10, !11, i64 144}
!33 = distinct !{!33, !25}
!34 = distinct !{!34, !25}
!35 = distinct !{!35, !25}
!36 = distinct !{!36, !25}


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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 23) i32 @ThreadPoolShutdown(ptr noundef %0) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.loopexit, label %2

2:                                                ; preds = %1
  %3 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull %0) #3
  %4 = getelementptr inbounds i8, ptr %0, i64 376
  %5 = getelementptr inbounds i8, ptr %0, i64 424
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %.not6885 = icmp eq i64 %6, 0
  br i1 %.not6885, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %19
  %7 = tail call ptr @ListHead(ptr noundef nonnull %4) #3
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %11

9:                                                ; preds = %.lr.ph
  %10 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull %0) #3
  br label %.loopexit

11:                                               ; preds = %.lr.ph
  %12 = getelementptr inbounds i8, ptr %7, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !18
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !19
  %.not78 = icmp eq ptr %15, null
  br i1 %.not78, label %19, label %16

16:                                               ; preds = %11
  %17 = getelementptr inbounds i8, ptr %13, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !22
  tail call void %15(ptr noundef %18) #3
  br label %19

19:                                               ; preds = %16, %11
  tail call void @FreeThreadPoolJob(ptr noundef %0, ptr noundef nonnull %13)
  %20 = tail call ptr @ListDelNode(ptr noundef nonnull %4, ptr noundef nonnull %7, i32 noundef 0) #3
  %21 = load i64, ptr %5, align 8, !tbaa !5
  %.not68 = icmp eq i64 %21, 0
  br i1 %.not68, label %._crit_edge, label %.lr.ph, !llvm.loop !23

._crit_edge:                                      ; preds = %19, %2
  %22 = tail call i32 @ListDestroy(ptr noundef nonnull %4, i32 noundef 0) #3
  %23 = getelementptr inbounds i8, ptr %0, i64 280
  %24 = getelementptr inbounds i8, ptr %0, i64 328
  %25 = load i64, ptr %24, align 8, !tbaa !25
  %.not6986 = icmp eq i64 %25, 0
  br i1 %.not6986, label %._crit_edge89, label %.lr.ph88

.lr.ph88:                                         ; preds = %._crit_edge, %38
  %26 = tail call ptr @ListHead(ptr noundef nonnull %23) #3
  %27 = icmp eq ptr %26, null
  br i1 %27, label %28, label %30

28:                                               ; preds = %.lr.ph88
  %29 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull %0) #3
  br label %.loopexit

30:                                               ; preds = %.lr.ph88
  %31 = getelementptr inbounds i8, ptr %26, i64 16
  %32 = load ptr, ptr %31, align 8, !tbaa !18
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %34 = load ptr, ptr %33, align 8, !tbaa !19
  %.not77 = icmp eq ptr %34, null
  br i1 %.not77, label %38, label %35

35:                                               ; preds = %30
  %36 = getelementptr inbounds i8, ptr %32, i64 8
  %37 = load ptr, ptr %36, align 8, !tbaa !22
  tail call void %34(ptr noundef %37) #3
  br label %38

38:                                               ; preds = %35, %30
  tail call void @FreeThreadPoolJob(ptr noundef %0, ptr noundef nonnull %32)
  %39 = tail call ptr @ListDelNode(ptr noundef nonnull %23, ptr noundef nonnull %26, i32 noundef 0) #3
  %40 = load i64, ptr %24, align 8, !tbaa !25
  %.not69 = icmp eq i64 %40, 0
  br i1 %.not69, label %._crit_edge89, label %.lr.ph88, !llvm.loop !26

._crit_edge89:                                    ; preds = %38, %._crit_edge
  %41 = tail call i32 @ListDestroy(ptr noundef nonnull %23, i32 noundef 0) #3
  %42 = getelementptr inbounds i8, ptr %0, i64 184
  %43 = getelementptr inbounds i8, ptr %0, i64 232
  %44 = load i64, ptr %43, align 8, !tbaa !27
  %.not7091 = icmp eq i64 %44, 0
  br i1 %.not7091, label %._crit_edge94, label %.lr.ph93

.lr.ph93:                                         ; preds = %._crit_edge89, %57
  %45 = tail call ptr @ListHead(ptr noundef nonnull %42) #3
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %49

47:                                               ; preds = %.lr.ph93
  %48 = tail call i32 @pthread_mutex_unlock(ptr noundef %0) #3
  br label %.loopexit

49:                                               ; preds = %.lr.ph93
  %50 = getelementptr inbounds i8, ptr %45, i64 16
  %51 = load ptr, ptr %50, align 8, !tbaa !18
  %52 = getelementptr inbounds i8, ptr %51, i64 16
  %53 = load ptr, ptr %52, align 8, !tbaa !19
  %.not76 = icmp eq ptr %53, null
  br i1 %.not76, label %57, label %54

54:                                               ; preds = %49
  %55 = getelementptr inbounds i8, ptr %51, i64 8
  %56 = load ptr, ptr %55, align 8, !tbaa !22
  tail call void %53(ptr noundef %56) #3
  br label %57

57:                                               ; preds = %54, %49
  tail call void @FreeThreadPoolJob(ptr noundef %0, ptr noundef nonnull %51)
  %58 = tail call ptr @ListDelNode(ptr noundef nonnull %42, ptr noundef nonnull %45, i32 noundef 0) #3
  %59 = load i64, ptr %43, align 8, !tbaa !27
  %.not70 = icmp eq i64 %59, 0
  br i1 %.not70, label %._crit_edge94, label %.lr.ph93, !llvm.loop !28

._crit_edge94:                                    ; preds = %57, %._crit_edge89
  %60 = tail call i32 @ListDestroy(ptr noundef nonnull %42, i32 noundef 0) #3
  %61 = getelementptr inbounds i8, ptr %0, i64 472
  %62 = load ptr, ptr %61, align 8, !tbaa !29
  %.not71 = icmp eq ptr %62, null
  br i1 %.not71, label %70, label %63

63:                                               ; preds = %._crit_edge94
  %64 = getelementptr inbounds i8, ptr %62, i64 16
  %65 = load ptr, ptr %64, align 8, !tbaa !19
  %.not72 = icmp eq ptr %65, null
  br i1 %.not72, label %69, label %66

66:                                               ; preds = %63
  %67 = getelementptr inbounds i8, ptr %62, i64 8
  %68 = load ptr, ptr %67, align 8, !tbaa !22
  tail call void %65(ptr noundef %68) #3
  br label %69

69:                                               ; preds = %66, %63
  tail call void @FreeThreadPoolJob(ptr noundef nonnull %0, ptr noundef nonnull %62)
  store ptr null, ptr %61, align 8, !tbaa !29
  br label %70

70:                                               ; preds = %69, %._crit_edge94
  %71 = getelementptr inbounds i8, ptr %0, i64 140
  store i32 1, ptr %71, align 4, !tbaa !30
  %72 = getelementptr inbounds i8, ptr %0, i64 40
  %73 = tail call i32 @pthread_cond_broadcast(ptr noundef nonnull %72) #3
  %74 = getelementptr inbounds i8, ptr %0, i64 144
  %75 = load i32, ptr %74, align 8, !tbaa !31
  %76 = icmp sgt i32 %75, 0
  br i1 %76, label %.lr.ph97, label %.preheader79.preheader

.lr.ph97:                                         ; preds = %70
  %77 = getelementptr inbounds i8, ptr %0, i64 88
  br label %78

78:                                               ; preds = %.lr.ph97, %78
  %79 = tail call i32 @pthread_cond_wait(ptr noundef nonnull %77, ptr noundef nonnull %0) #3
  %80 = load i32, ptr %74, align 8, !tbaa !31
  %81 = icmp sgt i32 %80, 0
  br i1 %81, label %78, label %.preheader79.preheader, !llvm.loop !32

.preheader79.preheader:                           ; preds = %78, %70
  br label %.preheader79

.preheader79:                                     ; preds = %.preheader79.preheader, %.preheader79
  %82 = tail call i32 @pthread_cond_destroy(ptr noundef nonnull %72) #3
  %.not73 = icmp eq i32 %82, 0
  br i1 %.not73, label %.preheader, label %.preheader79, !llvm.loop !33

.preheader:                                       ; preds = %.preheader79
  %83 = getelementptr inbounds i8, ptr %0, i64 88
  br label %84

84:                                               ; preds = %.preheader, %84
  %85 = tail call i32 @pthread_cond_destroy(ptr noundef nonnull %83) #3
  %.not74 = icmp eq i32 %85, 0
  br i1 %.not74, label %86, label %84, !llvm.loop !34

86:                                               ; preds = %84
  %87 = getelementptr inbounds i8, ptr %0, i64 160
  %88 = tail call i32 @FreeListDestroy(ptr noundef nonnull %87) #3
  %89 = tail call i32 @pthread_mutex_unlock(ptr noundef %0) #3
  br label %90

90:                                               ; preds = %90, %86
  %91 = tail call i32 @pthread_mutex_destroy(ptr noundef %0) #3
  %.not75 = icmp eq i32 %91, 0
  br i1 %.not75, label %.loopexit, label %90, !llvm.loop !35

.loopexit:                                        ; preds = %90, %1, %47, %28, %9
  %.0 = phi i32 [ 22, %9 ], [ 22, %28 ], [ 22, %47 ], [ 22, %1 ], [ 0, %90 ]
  ret i32 %.0
}

declare i32 @pthread_cond_wait(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @FreeThreadPoolJob(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ListDelNode(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare ptr @ListHead(ptr noundef) local_unnamed_addr #2

declare i32 @ListDestroy(ptr noundef, i32 noundef) local_unnamed_addr #2

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

declare i32 @FreeListDestroy(ptr noundef) local_unnamed_addr #2

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 = { 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 #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 }

!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, !12, i64 424}
!6 = !{!"THREADPOOL", !7, i64 0, !7, i64 40, !7, i64 88, !9, i64 136, !9, i64 140, !9, i64 144, !9, i64 148, !9, i64 152, !9, i64 156, !10, i64 160, !13, i64 184, !13, i64 280, !13, i64 376, !11, i64 472, !15, i64 480, !16, i64 520}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"FREELIST", !11, i64 0, !12, i64 8, !9, i64 16, !9, i64 20}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"LINKEDLIST", !14, i64 0, !14, i64 24, !12, i64 48, !10, i64 56, !11, i64 80, !11, i64 88}
!14 = !{!"LISTNODE", !11, i64 0, !11, i64 8, !11, i64 16}
!15 = !{!"THREADPOOLATTR", !9, i64 0, !9, i64 4, !12, i64 8, !9, i64 16, !9, i64 20, !9, i64 24, !9, i64 28, !9, i64 32}
!16 = !{!"TPOOLSTATS", !17, i64 0, !9, i64 8, !17, i64 16, !17, i64 24, !9, i64 32, !17, i64 40, !17, i64 48, !9, i64 56, !17, i64 64, !17, i64 72, !17, i64 80, !9, i64 88, !9, i64 92, !9, i64 96, !9, i64 100, !9, i64 104, !9, i64 108, !9, i64 112, !9, i64 116}
!17 = !{!"double", !7, i64 0}
!18 = !{!14, !11, i64 16}
!19 = !{!20, !11, i64 16}
!20 = !{!"THREADPOOLJOB", !11, i64 0, !11, i64 8, !11, i64 16, !21, i64 24, !9, i64 40, !9, i64 44}
!21 = !{!"timeval", !12, i64 0, !12, i64 8}
!22 = !{!20, !11, i64 8}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!6, !12, i64 328}
!26 = distinct !{!26, !24}
!27 = !{!6, !12, i64 232}
!28 = distinct !{!28, !24}
!29 = !{!6, !11, i64 472}
!30 = !{!6, !9, i64 140}
!31 = !{!6, !9, i64 144}
!32 = distinct !{!32, !24}
!33 = distinct !{!33, !24}
!34 = distinct !{!34, !24}
!35 = distinct !{!35, !24}


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