; LLVM IR from Softmotions/iowow :: src/utils (iwtp)

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

@.str = external hidden unnamed_addr constant [68 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [1 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

declare i64 @iwrc_set_errno(i64 noundef, i32 noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #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) #4

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

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @_worker_fn(ptr noundef) #6

declare void @iwlog3(i32 noundef, i64 noundef, ptr noundef, i32 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
define dso_local i64 @iwtp_start_by_spec(ptr noundef %0, ptr noundef %1) #6 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca %struct.iwtp, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #10
  store i64 0, ptr %6, align 8, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %21

18:                                               ; preds = %2
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %22, label %21

21:                                               ; preds = %18, %2
  store i64 70017, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %196

22:                                               ; preds = %18
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.iwtp_spec, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %34

27:                                               ; preds = %22
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.iwtp_spec, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = call i64 @strlen(ptr noundef %30) #11
  %32 = icmp ugt i64 %31, 15
  br i1 %32, label %33, label %34

33:                                               ; preds = %27
  store i64 70017, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %196

34:                                               ; preds = %27, %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #10
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.iwtp_spec, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 8, !tbaa !15
  store i32 %37, ptr %8, align 4, !tbaa !16
  %38 = load i32, ptr %8, align 4, !tbaa !16
  %39 = icmp slt i32 %38, 1
  br i1 %39, label %40, label %43

40:                                               ; preds = %34
  %41 = call zeroext i16 @iwp_num_cpu_cores()
  %42 = zext i16 %41 to i32
  store i32 %42, ptr %8, align 4, !tbaa !16
  br label %48

43:                                               ; preds = %34
  %44 = load i32, ptr %8, align 4, !tbaa !16
  %45 = icmp sgt i32 %44, 1023
  br i1 %45, label %46, label %47

46:                                               ; preds = %43
  store i32 1024, ptr %8, align 4, !tbaa !16
  br label %47

47:                                               ; preds = %46, %43
  br label %48

48:                                               ; preds = %47, %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #10
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.iwtp_spec, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %50, align 4, !tbaa !17
  store i32 %51, ptr %9, align 4, !tbaa !16
  %52 = load i32, ptr %9, align 4, !tbaa !16
  %53 = icmp slt i32 %52, 1
  br i1 %53, label %54, label %55

54:                                               ; preds = %48
  store i32 0, ptr %9, align 4, !tbaa !16
  br label %55

55:                                               ; preds = %54, %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #10
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.iwtp_spec, ptr %56, i32 0, i32 3
  %58 = load i32, ptr %57, align 8, !tbaa !18
  store i32 %58, ptr %10, align 4, !tbaa !16
  %59 = load i32, ptr %10, align 4, !tbaa !16
  %60 = icmp sgt i32 %59, 2
  br i1 %60, label %61, label %62

61:                                               ; preds = %55
  store i32 2, ptr %10, align 4, !tbaa !16
  br label %62

62:                                               ; preds = %61, %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #10
  %63 = call noalias ptr @malloc(i64 noundef 176) #12
  store ptr %63, ptr %11, align 8, !tbaa !5
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = icmp ne ptr %64, null
  br i1 %65, label %70, label %66

66:                                               ; preds = %62
  %67 = call ptr @__errno_location() #13
  %68 = load i32, ptr %67, align 4, !tbaa !16
  %69 = call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %68)
  store i64 %69, ptr %6, align 8, !tbaa !9
  br label %178

70:                                               ; preds = %62
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %12, i8 0, i64 176, i1 false)
  %72 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 0
  %73 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 1
  %74 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 2
  %75 = getelementptr inbounds %struct.__pthread_mutex_s, ptr %74, i32 0, i32 0
  %76 = getelementptr inbounds %struct.__pthread_mutex_s, ptr %74, i32 0, i32 1
  %77 = getelementptr inbounds %struct.__pthread_mutex_s, ptr %74, i32 0, i32 2
  %78 = getelementptr inbounds %struct.__pthread_mutex_s, ptr %74, i32 0, i32 3
  %79 = getelementptr inbounds %struct.__pthread_mutex_s, ptr %74, i32 0, i32 4
  store i32 0, ptr %79, align 8, !tbaa !19
  %80 = getelementptr inbounds %struct.__pthread_mutex_s, ptr %74, i32 0, i32 5
  %81 = getelementptr inbounds %struct.__pthread_mutex_s, ptr %74, i32 0, i32 6
  %82 = getelementptr inbounds %struct.__pthread_mutex_s, ptr %74, i32 0, i32 7
  %83 = getelementptr inbounds %struct.__pthread_internal_list, ptr %82, i32 0, i32 0
  %84 = getelementptr inbounds %struct.__pthread_internal_list, ptr %82, i32 0, i32 1
  %85 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 3
  %86 = getelementptr inbounds %struct.__pthread_cond_s, ptr %85, i32 0, i32 0
  %87 = getelementptr inbounds %struct.__pthread_cond_s, ptr %85, i32 0, i32 1
  %88 = getelementptr inbounds %struct.__pthread_cond_s, ptr %85, i32 0, i32 2
  %89 = getelementptr inbounds i32, ptr %88, i64 1
  %90 = getelementptr inbounds %struct.__pthread_cond_s, ptr %85, i32 0, i32 3
  %91 = getelementptr inbounds i32, ptr %90, i64 1
  %92 = getelementptr inbounds %struct.__pthread_cond_s, ptr %85, i32 0, i32 4
  %93 = getelementptr inbounds %struct.__pthread_cond_s, ptr %85, i32 0, i32 5
  %94 = getelementptr inbounds %struct.__pthread_cond_s, ptr %85, i32 0, i32 6
  %95 = getelementptr inbounds i32, ptr %94, i64 1
  %96 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 4
  %97 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 5
  %98 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 6
  %99 = load i32, ptr %8, align 4, !tbaa !16
  store i32 %99, ptr %98, align 8, !tbaa !23
  %100 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 7
  %101 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 8
  %102 = load i32, ptr %10, align 4, !tbaa !16
  store i32 %102, ptr %101, align 8, !tbaa !26
  %103 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 9
  %104 = load i32, ptr %9, align 4, !tbaa !16
  store i32 %104, ptr %103, align 4, !tbaa !27
  %105 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 10
  %106 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 11
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.iwtp_spec, ptr %107, i32 0, i32 4
  %109 = load i8, ptr %108, align 4, !tbaa !28, !range !29, !noundef !30
  %110 = trunc i8 %109 to i1
  %111 = zext i1 %110 to i8
  store i8 %111, ptr %106, align 4, !tbaa !31
  %112 = getelementptr inbounds %struct.iwtp, ptr %12, i32 0, i32 12
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %71, ptr align 8 %12, i64 176, i1 false), !tbaa.struct !32
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.iwtp_spec, ptr %113, i32 0, i32 0
  %115 = load ptr, ptr %114, align 8, !tbaa !11
  %116 = icmp ne ptr %115, null
  br i1 %116, label %117, label %124

117:                                              ; preds = %70
  %118 = load ptr, ptr %4, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.iwtp_spec, ptr %118, i32 0, i32 0
  %120 = load ptr, ptr %119, align 8, !tbaa !11
  %121 = call noalias ptr @strdup(ptr noundef %120) #10
  %122 = load ptr, ptr %11, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.iwtp, ptr %122, i32 0, i32 5
  store ptr %121, ptr %123, align 8, !tbaa !35
  br label %124

124:                                              ; preds = %117, %70
  %125 = load ptr, ptr %11, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.iwtp, ptr %125, i32 0, i32 4
  %127 = load i32, ptr %8, align 4, !tbaa !16
  %128 = sext i32 %127 to i64
  %129 = call i64 @iwulist_init(ptr noundef %126, i64 noundef %128, i64 noundef 8)
  store i64 %129, ptr %6, align 8, !tbaa !9
  %130 = load i64, ptr %6, align 8, !tbaa !9
  %131 = icmp ne i64 %130, 0
  %132 = xor i1 %131, true
  %133 = xor i1 %132, true
  %134 = zext i1 %133 to i32
  %135 = sext i32 %134 to i64
  %136 = call i64 @llvm.expect.i64(i64 %135, i64 0)
  %137 = icmp ne i64 %136, 0
  br i1 %137, label %138, label %139

138:                                              ; preds = %124
  br label %178

139:                                              ; preds = %124
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #10
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %140

140:                                              ; preds = %172, %139
  %141 = load i64, ptr %13, align 8, !tbaa !9
  %142 = load i32, ptr %8, align 4, !tbaa !16
  %143 = sext i32 %142 to i64
  %144 = icmp ult i64 %141, %143
  br i1 %144, label %146, label %145

145:                                              ; preds = %140
  store i32 3, ptr %7, align 4
  br label %175

146:                                              ; preds = %140
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #10
  %147 = load ptr, ptr %11, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.iwtp, ptr %147, i32 0, i32 2
  %149 = call i32 @pthread_mutex_lock(ptr noundef %148) #10
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #10
  %150 = load ptr, ptr %11, align 8, !tbaa !5
  %151 = call i32 @pthread_create(ptr noundef %14, ptr noundef null, ptr noundef @_worker_fn, ptr noundef %150) #10
  store i32 %151, ptr %15, align 4, !tbaa !16
  %152 = load i32, ptr %15, align 4, !tbaa !16
  %153 = icmp ne i32 %152, 0
  br i1 %153, label %154, label %161

154:                                              ; preds = %146
  %155 = load ptr, ptr %11, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.iwtp, ptr %155, i32 0, i32 2
  %157 = call i32 @pthread_mutex_unlock(ptr noundef %156) #10
  %158 = load i32, ptr %15, align 4, !tbaa !16
  %159 = call i64 @iwrc_set_errno(i64 noundef 70008, i32 noundef %158)
  store i64 %159, ptr %6, align 8, !tbaa !9
  %160 = load i64, ptr %6, align 8, !tbaa !9
  call void @iwlog3(i32 noundef 0, i64 noundef %160, ptr noundef @.str, i32 noundef 220, ptr noundef @.str.3)
  store i32 2, ptr %7, align 4
  br label %169

161:                                              ; preds = %146
  %162 = load ptr, ptr %11, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.iwtp, ptr %162, i32 0, i32 4
  %164 = call i64 @iwulist_push(ptr noundef %163, ptr noundef %14)
  br label %165

165:                                              ; preds = %161
  %166 = load ptr, ptr %11, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.iwtp, ptr %166, i32 0, i32 2
  %168 = call i32 @pthread_mutex_unlock(ptr noundef %167) #10
  store i32 0, ptr %7, align 4
  br label %169

169:                                              ; preds = %165, %154
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #10
  %170 = load i32, ptr %7, align 4
  switch i32 %170, label %175 [
    i32 0, label %171
  ]

171:                                              ; preds = %169
  br label %172

172:                                              ; preds = %171
  %173 = load i64, ptr %13, align 8, !tbaa !9
  %174 = add i64 %173, 1
  store i64 %174, ptr %13, align 8, !tbaa !9
  br label %140, !llvm.loop !36

175:                                              ; preds = %169, %145
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #10
  %176 = load i32, ptr %7, align 4
  switch i32 %176, label %195 [
    i32 3, label %177
    i32 2, label %178
  ]

177:                                              ; preds = %175
  br label %178

178:                                              ; preds = %177, %175, %138, %66
  %179 = load i64, ptr %6, align 8, !tbaa !9
  %180 = icmp ne i64 %179, 0
  %181 = xor i1 %180, true
  %182 = xor i1 %181, true
  %183 = zext i1 %182 to i32
  %184 = sext i32 %183 to i64
  %185 = call i64 @llvm.expect.i64(i64 %184, i64 0)
  %186 = icmp ne i64 %185, 0
  br i1 %186, label %187, label %190

187:                                              ; preds = %178
  %188 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %188, align 8, !tbaa !5
  %189 = call i64 @iwtp_shutdown(ptr noundef %11, i1 noundef zeroext false)
  br label %193

190:                                              ; preds = %178
  %191 = load ptr, ptr %11, align 8, !tbaa !5
  %192 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %191, ptr %192, align 8, !tbaa !5
  br label %193

193:                                              ; preds = %190, %187
  %194 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %194, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %195

195:                                              ; preds = %193, %175
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #10
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #10
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #10
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #10
  br label %196

196:                                              ; preds = %195, %33, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #10
  %197 = load i64, ptr %3, align 8
  ret i64 %197
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #7

declare zeroext i16 @iwp_num_cpu_cores() #2

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

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #5

declare i64 @iwulist_init(ptr noundef, i64 noundef, i64 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #9

declare i64 @iwulist_push(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @iwtp_shutdown(ptr noundef, i1 noundef zeroext) #6

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 = { "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 willreturn memory(none) "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: readwrite) }
attributes #5 = { 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 #6 = { 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 #7 = { nounwind willreturn memory(read) "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 #8 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #9 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #10 = { nounwind }
attributes #11 = { nounwind willreturn memory(read) }
attributes #12 = { nounwind allocsize(0) }
attributes #13 = { nounwind willreturn memory(none) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"iwtp_spec", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !14, i64 20}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!12, !13, i64 8}
!16 = !{!13, !13, i64 0}
!17 = !{!12, !13, i64 12}
!18 = !{!12, !13, i64 16}
!19 = !{!20, !13, i64 16}
!20 = !{!"__pthread_mutex_s", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !21, i64 20, !21, i64 22, !22, i64 24}
!21 = !{!"short", !7, i64 0}
!22 = !{!"__pthread_internal_list", !6, i64 0, !6, i64 8}
!23 = !{!24, !13, i64 152}
!24 = !{!"iwtp", !6, i64 0, !6, i64 8, !7, i64 16, !7, i64 56, !25, i64 104, !6, i64 144, !13, i64 152, !13, i64 156, !13, i64 160, !13, i64 164, !13, i64 168, !14, i64 172, !14, i64 173}
!25 = !{!"iwulist", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!26 = !{!24, !13, i64 160}
!27 = !{!24, !13, i64 164}
!28 = !{!12, !14, i64 20}
!29 = !{i8 0, i8 2}
!30 = !{}
!31 = !{!24, !14, i64 172}
!32 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 40, !33, i64 56, i64 48, !33, i64 104, i64 8, !5, i64 112, i64 8, !9, i64 120, i64 8, !9, i64 128, i64 8, !9, i64 136, i64 8, !9, i64 144, i64 8, !5, i64 152, i64 4, !16, i64 156, i64 4, !16, i64 160, i64 4, !16, i64 164, i64 4, !16, i64 168, i64 4, !16, i64 172, i64 1, !34, i64 173, i64 1, !34}
!33 = !{!7, !7, i64 0}
!34 = !{!14, !14, i64 0}
!35 = !{!24, !6, i64 144}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}


; 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 [68 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [1 x i8], align 1

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

declare i64 @iwrc_set_errno(i64 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #3

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

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @_worker_fn(ptr noundef) #5

declare void @iwlog3(i32 noundef, i64 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local i64 @iwtp_start_by_spec(ptr noundef readonly %0, ptr noundef writeonly %1) local_unnamed_addr #5 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = icmp ne ptr %0, null
  %6 = icmp ne ptr %1, null
  %or.cond = and i1 %5, %6
  br i1 %or.cond, label %7, label %61

7:                                                ; preds = %2
  %8 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %12, label %9

9:                                                ; preds = %7
  %10 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %8) #10
  %11 = icmp ugt i64 %10, 15
  br i1 %11, label %61, label %12

12:                                               ; preds = %9, %7
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load i32, ptr %13, align 8, !tbaa !12
  %15 = icmp slt i32 %14, 1
  br i1 %15, label %16, label %19

16:                                               ; preds = %12
  %17 = tail call zeroext i16 @iwp_num_cpu_cores() #11
  %18 = zext i16 %17 to i32
  br label %21

19:                                               ; preds = %12
  %20 = tail call i32 @llvm.umin.i32(i32 %14, i32 1024)
  br label %21

21:                                               ; preds = %19, %16
  %.042 = phi i32 [ %18, %16 ], [ %20, %19 ]
  %22 = getelementptr inbounds i8, ptr %0, i64 12
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  %25 = load i32, ptr %24, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #11
  %26 = tail call noalias dereferenceable_or_null(176) ptr @malloc(i64 noundef 176) #12
  store ptr %26, ptr %3, align 8, !tbaa !15
  %.not52 = icmp eq ptr %26, null
  br i1 %.not52, label %27, label %31

27:                                               ; preds = %21
  %28 = tail call ptr @__errno_location() #13
  %29 = load i32, ptr %28, align 4, !tbaa !16
  %30 = tail call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %29) #11
  br label %.loopexit

31:                                               ; preds = %21
  %spec.store.select3 = tail call i32 @llvm.smin.i32(i32 %25, i32 2)
  %spec.store.select2 = tail call i32 @llvm.smax.i32(i32 %23, i32 0)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %26, i8 0, i64 32, i1 false)
  %.sroa.3.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 36
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(116) %.sroa.3.0..sroa_idx, i8 0, i64 116, i1 false)
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 173
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(3) %.sroa.7.0..sroa_idx, i8 0, i64 3, i1 false)
  %32 = getelementptr inbounds i8, ptr %0, i64 20
  %33 = load i8, ptr %32, align 4, !tbaa !17, !range !18, !noundef !19
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 32
  store i32 0, ptr %.sroa.2.0..sroa_idx, align 8
  %.sroa.37.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 152
  store i32 %.042, ptr %.sroa.37.0..sroa_idx, align 8, !tbaa !16
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 156
  store i32 0, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !16
  %.sroa.48.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 160
  store i32 %spec.store.select3, ptr %.sroa.48.0..sroa_idx, align 8, !tbaa !16
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 164
  store i32 %spec.store.select2, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !16
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 168
  store i32 0, ptr %.sroa.6.0..sroa_idx, align 8, !tbaa !16
  %.sroa.69.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 172
  store i8 %33, ptr %.sroa.69.0..sroa_idx, align 4, !tbaa !20
  %34 = load ptr, ptr %0, align 8, !tbaa !5
  %.not53 = icmp eq ptr %34, null
  br i1 %.not53, label %38, label %35

35:                                               ; preds = %31
  %36 = tail call noalias ptr @strdup(ptr noundef nonnull %34) #11
  %37 = getelementptr inbounds i8, ptr %26, i64 144
  store ptr %36, ptr %37, align 8, !tbaa !21
  br label %38

38:                                               ; preds = %35, %31
  %39 = getelementptr inbounds i8, ptr %26, i64 104
  %40 = zext nneg i32 %.042 to i64
  %41 = tail call i64 @iwulist_init(ptr noundef nonnull %39, i64 noundef %40, i64 noundef 8) #11
  %.not54 = icmp eq i64 %41, 0
  br i1 %.not54, label %.preheader, label %.thread, !prof !25

.preheader:                                       ; preds = %38
  %.not64 = icmp eq i32 %.042, 0
  br i1 %.not64, label %.loopexit.thread, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %51
  %42 = phi ptr [ %45, %51 ], [ %26, %.preheader ]
  %.03763 = phi i64 [ %56, %51 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #11
  %43 = getelementptr inbounds i8, ptr %42, i64 16
  %44 = call i32 @pthread_mutex_lock(ptr noundef nonnull %43) #11
  %45 = load ptr, ptr %3, align 8, !tbaa !15
  %46 = call i32 @pthread_create(ptr noundef nonnull %4, ptr noundef null, ptr noundef nonnull @_worker_fn, ptr noundef %45) #11
  %.not55 = icmp eq i32 %46, 0
  br i1 %.not55, label %51, label %47

47:                                               ; preds = %.lr.ph
  %48 = getelementptr inbounds i8, ptr %45, i64 16
  %49 = call i32 @pthread_mutex_unlock(ptr noundef nonnull %48) #11
  %50 = call i64 @iwrc_set_errno(i64 noundef 70008, i32 noundef %46) #11
  call void @iwlog3(i32 noundef 0, i64 noundef %50, ptr noundef nonnull @.str, i32 noundef 220, ptr noundef nonnull @.str.3) #11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #11
  br label %.loopexit

51:                                               ; preds = %.lr.ph
  %52 = getelementptr inbounds i8, ptr %45, i64 104
  %53 = call i64 @iwulist_push(ptr noundef nonnull %52, ptr noundef nonnull %4) #11
  %54 = getelementptr inbounds i8, ptr %45, i64 16
  %55 = call i32 @pthread_mutex_unlock(ptr noundef nonnull %54) #11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #11
  %56 = add nuw nsw i64 %.03763, 1
  %exitcond.not = icmp eq i64 %56, %40
  br i1 %exitcond.not, label %.loopexit.thread, label %.lr.ph, !llvm.loop !26

.loopexit:                                        ; preds = %47, %27
  %57 = phi ptr [ null, %27 ], [ %45, %47 ]
  %.3 = phi i64 [ %30, %27 ], [ %50, %47 ]
  %.not56 = icmp eq i64 %.3, 0
  br i1 %.not56, label %.loopexit.thread, label %.thread, !prof !28

.thread:                                          ; preds = %38, %.loopexit
  %.362 = phi i64 [ %.3, %.loopexit ], [ %41, %38 ]
  store ptr null, ptr %1, align 8, !tbaa !15
  %58 = call i64 @iwtp_shutdown(ptr noundef nonnull %3, i1 noundef zeroext false)
  br label %60

.loopexit.thread:                                 ; preds = %51, %.preheader, %.loopexit
  %59 = phi ptr [ %57, %.loopexit ], [ %26, %.preheader ], [ %45, %51 ]
  store ptr %59, ptr %1, align 8, !tbaa !15
  br label %60

60:                                               ; preds = %.thread, %.loopexit.thread
  %.0 = phi i64 [ 0, %.loopexit.thread ], [ %.362, %.thread ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #11
  br label %61

61:                                               ; preds = %9, %2, %60
  %.1 = phi i64 [ %.0, %60 ], [ 70017, %2 ], [ 70017, %9 ]
  ret i64 %.1
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #6

declare zeroext i16 @iwp_num_cpu_cores() local_unnamed_addr #2

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #8

declare i64 @iwulist_init(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

declare i64 @iwulist_push(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @iwtp_shutdown(ptr noundef, i1 noundef zeroext) local_unnamed_addr #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #9

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #9

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #9

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 "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 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 #6 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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: write) }
attributes #8 = { mustprogress nofree nounwind willreturn 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 #9 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #10 = { nounwind willreturn memory(read) }
attributes #11 = { nounwind }
attributes #12 = { nounwind allocsize(0) }
attributes #13 = { nounwind willreturn memory(none) }

!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 = !{!"iwtp_spec", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !11, i64 20}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !10, i64 12}
!14 = !{!6, !10, i64 16}
!15 = !{!7, !7, i64 0}
!16 = !{!10, !10, i64 0}
!17 = !{!6, !11, i64 20}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!11, !11, i64 0}
!21 = !{!22, !7, i64 144}
!22 = !{!"iwtp", !7, i64 0, !7, i64 8, !8, i64 16, !8, i64 56, !23, i64 104, !7, i64 144, !10, i64 152, !10, i64 156, !10, i64 160, !10, i64 164, !10, i64 168, !11, i64 172, !11, i64 173}
!23 = !{!"iwulist", !7, i64 0, !24, i64 8, !24, i64 16, !24, i64 24, !24, i64 32}
!24 = !{!"long", !8, i64 0}
!25 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!"branch_weights", !"expected", i32 2146781673, i32 701975}


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