; LLVM IR from davidesantangelo/krep :: krep (thread_pool_init)

; 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.thread_pool_t = type { ptr, i32, ptr, ptr, %union.pthread_mutex_t, %union.pthread_cond_t, %union.pthread_cond_t, i64, i8 }
%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 }

; 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

; Function Attrs: nounwind
declare i64 @sysconf(i32 noundef) #2

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @thread_pool_init(i32 noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = icmp sle i32 %9, 0
  br i1 %10, label %11, label %18

11:                                               ; preds = %1
  %12 = call i64 @sysconf(i32 noundef 84) #5
  %13 = trunc i64 %12 to i32
  store i32 %13, ptr %3, align 4, !tbaa !5
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = icmp sle i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %11
  store i32 4, ptr %3, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %16, %11
  br label %18

18:                                               ; preds = %17, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %19 = call noalias ptr @malloc(i64 noundef 184) #6
  store ptr %19, ptr %4, align 8, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !9
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %148

23:                                               ; preds = %18
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = mul i64 %25, 8
  %27 = call noalias ptr @malloc(i64 noundef %26) #6
  %28 = load ptr, ptr %4, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.thread_pool_t, ptr %28, i32 0, i32 0
  store ptr %27, ptr %29, align 8, !tbaa !11
  %30 = load ptr, ptr %4, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.thread_pool_t, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = icmp ne ptr %32, null
  br i1 %33, label %36, label %34

34:                                               ; preds = %23
  %35 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %35) #5
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %148

36:                                               ; preds = %23
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = load ptr, ptr %4, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.thread_pool_t, ptr %38, i32 0, i32 1
  store i32 %37, ptr %39, align 8, !tbaa !14
  %40 = load ptr, ptr %4, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.thread_pool_t, ptr %40, i32 0, i32 2
  store ptr null, ptr %41, align 8, !tbaa !15
  %42 = load ptr, ptr %4, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.thread_pool_t, ptr %42, i32 0, i32 3
  store ptr null, ptr %43, align 8, !tbaa !16
  %44 = load ptr, ptr %4, align 8, !tbaa !9
  %45 = getelementptr inbounds %struct.thread_pool_t, ptr %44, i32 0, i32 7
  store i64 0, ptr %45, align 8, !tbaa !17
  %46 = load ptr, ptr %4, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.thread_pool_t, ptr %46, i32 0, i32 8
  store i8 0, ptr %47, align 1, !tbaa !18
  %48 = load ptr, ptr %4, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.thread_pool_t, ptr %48, i32 0, i32 4
  %50 = call i32 @pthread_mutex_init(ptr noundef %49, ptr noundef null) #5
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %57

52:                                               ; preds = %36
  %53 = load ptr, ptr %4, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.thread_pool_t, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !11
  call void @free(ptr noundef %55) #5
  %56 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %56) #5
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %148

57:                                               ; preds = %36
  %58 = load ptr, ptr %4, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.thread_pool_t, ptr %58, i32 0, i32 5
  %60 = call i32 @pthread_cond_init(ptr noundef %59, ptr noundef null) #5
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %70

62:                                               ; preds = %57
  %63 = load ptr, ptr %4, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.thread_pool_t, ptr %63, i32 0, i32 4
  %65 = call i32 @pthread_mutex_destroy(ptr noundef %64) #5
  %66 = load ptr, ptr %4, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct.thread_pool_t, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !11
  call void @free(ptr noundef %68) #5
  %69 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %69) #5
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %148

70:                                               ; preds = %57
  %71 = load ptr, ptr %4, align 8, !tbaa !9
  %72 = getelementptr inbounds %struct.thread_pool_t, ptr %71, i32 0, i32 6
  %73 = call i32 @pthread_cond_init(ptr noundef %72, ptr noundef null) #5
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %86

75:                                               ; preds = %70
  %76 = load ptr, ptr %4, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct.thread_pool_t, ptr %76, i32 0, i32 5
  %78 = call i32 @pthread_cond_destroy(ptr noundef %77) #5
  %79 = load ptr, ptr %4, align 8, !tbaa !9
  %80 = getelementptr inbounds %struct.thread_pool_t, ptr %79, i32 0, i32 4
  %81 = call i32 @pthread_mutex_destroy(ptr noundef %80) #5
  %82 = load ptr, ptr %4, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.thread_pool_t, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !11
  call void @free(ptr noundef %84) #5
  %85 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %85) #5
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %148

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

87:                                               ; preds = %141, %86
  %88 = load i32, ptr %6, align 4, !tbaa !5
  %89 = load i32, ptr %3, align 4, !tbaa !5
  %90 = icmp slt i32 %88, %89
  br i1 %90, label %92, label %91

91:                                               ; preds = %87
  store i32 2, ptr %5, align 4
  br label %144

92:                                               ; preds = %87
  %93 = load ptr, ptr %4, align 8, !tbaa !9
  %94 = getelementptr inbounds %struct.thread_pool_t, ptr %93, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8, !tbaa !11
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds i64, ptr %95, i64 %97
  %99 = load ptr, ptr %4, align 8, !tbaa !9
  %100 = call i32 @pthread_create(ptr noundef %98, ptr noundef null, ptr noundef @thread_pool_worker, ptr noundef %99) #5
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %140

102:                                              ; preds = %92
  %103 = load ptr, ptr %4, align 8, !tbaa !9
  %104 = getelementptr inbounds %struct.thread_pool_t, ptr %103, i32 0, i32 8
  store i8 1, ptr %7, align 1, !tbaa !19
  %105 = load i8, ptr %7, align 1
  store atomic i8 %105, ptr %104 seq_cst, align 8
  %106 = load ptr, ptr %4, align 8, !tbaa !9
  %107 = getelementptr inbounds %struct.thread_pool_t, ptr %106, i32 0, i32 5
  %108 = call i32 @pthread_cond_broadcast(ptr noundef %107) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %109

109:                                              ; preds = %123, %102
  %110 = load i32, ptr %8, align 4, !tbaa !5
  %111 = load i32, ptr %6, align 4, !tbaa !5
  %112 = icmp slt i32 %110, %111
  br i1 %112, label %114, label %113

113:                                              ; preds = %109
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %126

114:                                              ; preds = %109
  %115 = load ptr, ptr %4, align 8, !tbaa !9
  %116 = getelementptr inbounds %struct.thread_pool_t, ptr %115, i32 0, i32 0
  %117 = load ptr, ptr %116, align 8, !tbaa !11
  %118 = load i32, ptr %8, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds i64, ptr %117, i64 %119
  %121 = load i64, ptr %120, align 8, !tbaa !21
  %122 = call i32 @pthread_join(i64 noundef %121, ptr noundef null)
  br label %123

123:                                              ; preds = %114
  %124 = load i32, ptr %8, align 4, !tbaa !5
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %8, align 4, !tbaa !5
  br label %109, !llvm.loop !22

126:                                              ; preds = %113
  %127 = load ptr, ptr %4, align 8, !tbaa !9
  %128 = getelementptr inbounds %struct.thread_pool_t, ptr %127, i32 0, i32 6
  %129 = call i32 @pthread_cond_destroy(ptr noundef %128) #5
  %130 = load ptr, ptr %4, align 8, !tbaa !9
  %131 = getelementptr inbounds %struct.thread_pool_t, ptr %130, i32 0, i32 5
  %132 = call i32 @pthread_cond_destroy(ptr noundef %131) #5
  %133 = load ptr, ptr %4, align 8, !tbaa !9
  %134 = getelementptr inbounds %struct.thread_pool_t, ptr %133, i32 0, i32 4
  %135 = call i32 @pthread_mutex_destroy(ptr noundef %134) #5
  %136 = load ptr, ptr %4, align 8, !tbaa !9
  %137 = getelementptr inbounds %struct.thread_pool_t, ptr %136, i32 0, i32 0
  %138 = load ptr, ptr %137, align 8, !tbaa !11
  call void @free(ptr noundef %138) #5
  %139 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %139) #5
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %144

140:                                              ; preds = %92
  br label %141

141:                                              ; preds = %140
  %142 = load i32, ptr %6, align 4, !tbaa !5
  %143 = add nsw i32 %142, 1
  store i32 %143, ptr %6, align 4, !tbaa !5
  br label %87, !llvm.loop !24

144:                                              ; preds = %126, %91
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %145 = load i32, ptr %5, align 4
  switch i32 %145, label %148 [
    i32 2, label %146
  ]

146:                                              ; preds = %144
  %147 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %147, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %148

148:                                              ; preds = %146, %144, %75, %62, %52, %34, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %149 = load ptr, ptr %2, align 8
  ret ptr %149
}

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

; Function Attrs: nounwind
declare i32 @pthread_cond_init(ptr noundef, ptr noundef) #2

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @thread_pool_worker(ptr noundef) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 = { 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 #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 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !7, i64 32, !7, i64 72, !7, i64 120, !13, i64 168, !7, i64 176}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !10, i64 16}
!16 = !{!12, !10, i64 24}
!17 = !{!12, !13, i64 168}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"_Bool", !7, i64 0}
!21 = !{!13, !13, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


; 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: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind
declare i64 @sysconf(i32 noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @thread_pool_init(i32 noundef %0) local_unnamed_addr #4 {
  %2 = icmp slt i32 %0, 1
  br i1 %2, label %3, label %7

3:                                                ; preds = %1
  %4 = tail call i64 @sysconf(i32 noundef 84) #6
  %5 = trunc i64 %4 to i32
  %6 = icmp slt i32 %5, 1
  %spec.store.select = select i1 %6, i32 4, i32 %5
  br label %7

7:                                                ; preds = %3, %1
  %.049 = phi i32 [ %spec.store.select, %3 ], [ %0, %1 ]
  %8 = tail call noalias dereferenceable_or_null(184) ptr @malloc(i64 noundef 184) #7
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %.loopexit, label %9

9:                                                ; preds = %7
  %10 = sext i32 %.049 to i64
  %11 = shl nsw i64 %10, 3
  %12 = tail call noalias ptr @malloc(i64 noundef %11) #7
  store ptr %12, ptr %8, align 8, !tbaa !5
  %.not52 = icmp eq ptr %12, null
  br i1 %.not52, label %.loopexit.sink.split, label %13

13:                                               ; preds = %9
  %14 = getelementptr inbounds i8, ptr %8, i64 8
  store i32 %.049, ptr %14, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %8, i64 16
  %16 = getelementptr inbounds i8, ptr %8, i64 168
  store i64 0, ptr %16, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %8, i64 176
  store i8 0, ptr %17, align 1, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %8, i64 32
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %15, i8 0, i64 16, i1 false)
  %19 = tail call i32 @pthread_mutex_init(ptr noundef nonnull %18, ptr noundef null) #6
  %.not53 = icmp eq i32 %19, 0
  br i1 %.not53, label %20, label %.loopexit.sink.split.sink.split

20:                                               ; preds = %13
  %21 = getelementptr inbounds i8, ptr %8, i64 72
  %22 = tail call i32 @pthread_cond_init(ptr noundef nonnull %21, ptr noundef null) #6
  %.not54 = icmp eq i32 %22, 0
  br i1 %.not54, label %23, label %.loopexit.sink.split.sink.split.sink.split

23:                                               ; preds = %20
  %24 = getelementptr inbounds i8, ptr %8, i64 120
  %25 = tail call i32 @pthread_cond_init(ptr noundef nonnull %24, ptr noundef null) #6
  %.not55 = icmp eq i32 %25, 0
  br i1 %.not55, label %.preheader, label %.loopexit.sink.split.sink.split.sink.split.sink.split

.preheader:                                       ; preds = %23
  %.not5759 = icmp sgt i32 %.049, 0
  br i1 %.not5759, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %.049 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %36
  %indvars.iv69 = phi i32 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next70, %36 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %36 ]
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds i64, ptr %26, i64 %indvars.iv
  %28 = tail call i32 @pthread_create(ptr noundef %27, ptr noundef null, ptr noundef nonnull @thread_pool_worker, ptr noundef nonnull %8) #6
  %.not56 = icmp eq i32 %28, 0
  br i1 %.not56, label %36, label %29

29:                                               ; preds = %.lr.ph
  store atomic i8 1, ptr %17 seq_cst, align 8
  %30 = tail call i32 @pthread_cond_broadcast(ptr noundef nonnull %21) #6
  %.not63 = icmp eq i64 %indvars.iv, 0
  br i1 %.not63, label %._crit_edge, label %.lr.ph62.preheader

.lr.ph62.preheader:                               ; preds = %29
  %wide.trip.count72 = zext nneg i32 %indvars.iv69 to i64
  br label %.lr.ph62

._crit_edge:                                      ; preds = %.lr.ph62, %29
  %31 = tail call i32 @pthread_cond_destroy(ptr noundef nonnull %24) #6
  br label %.loopexit.sink.split.sink.split.sink.split.sink.split

.lr.ph62:                                         ; preds = %.lr.ph62.preheader, %.lr.ph62
  %indvars.iv66 = phi i64 [ 0, %.lr.ph62.preheader ], [ %indvars.iv.next67, %.lr.ph62 ]
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds i64, ptr %32, i64 %indvars.iv66
  %34 = load i64, ptr %33, align 8, !tbaa !15
  %35 = tail call i32 @pthread_join(i64 noundef %34, ptr noundef null) #6
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %exitcond73.not = icmp eq i64 %indvars.iv.next67, %wide.trip.count72
  br i1 %exitcond73.not, label %._crit_edge, label %.lr.ph62, !llvm.loop !16

36:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  %indvars.iv.next70 = add nuw nsw i32 %indvars.iv69, 1
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !18

.loopexit.sink.split.sink.split.sink.split.sink.split: ; preds = %23, %._crit_edge
  %37 = tail call i32 @pthread_cond_destroy(ptr noundef nonnull %21) #6
  br label %.loopexit.sink.split.sink.split.sink.split

.loopexit.sink.split.sink.split.sink.split:       ; preds = %.loopexit.sink.split.sink.split.sink.split.sink.split, %20
  %38 = tail call i32 @pthread_mutex_destroy(ptr noundef nonnull %18) #6
  br label %.loopexit.sink.split.sink.split

.loopexit.sink.split.sink.split:                  ; preds = %.loopexit.sink.split.sink.split.sink.split, %13
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  tail call void @free(ptr noundef %39) #6
  br label %.loopexit.sink.split

.loopexit.sink.split:                             ; preds = %.loopexit.sink.split.sink.split, %9
  tail call void @free(ptr noundef nonnull %8) #6
  br label %.loopexit

.loopexit:                                        ; preds = %36, %.loopexit.sink.split, %.preheader, %7
  %.1 = phi ptr [ null, %7 ], [ %8, %.preheader ], [ null, %.loopexit.sink.split ], [ %8, %36 ]
  ret ptr %.1
}

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

; Function Attrs: nounwind
declare i32 @pthread_cond_init(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @thread_pool_worker(ptr noundef) #4

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

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 #1 = { 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 #2 = { 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 #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 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !8, i64 32, !8, i64 72, !8, i64 120, !11, i64 168, !8, i64 176}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !11, i64 168}
!14 = !{!8, !8, i64 0}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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