; LLVM IR from ctlst-tech/catpilot :: os/freertos/services/cli (service)

; 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.sched_param = type { i32 }
%struct.cli_service = type { i32, ptr, ptr, ptr, ptr, i32, i32, i32, %struct.pthread_mutex_internal, %struct.pthread_cond_internal, i32, i32 }
%struct.pthread_mutex_internal = type { i64, %struct.xSTATIC_QUEUE, ptr, %struct.pthread_mutexattr_internal }
%struct.xSTATIC_QUEUE = type { [3 x ptr], %union.anon, [2 x %struct.xSTATIC_LIST], [3 x i64], [2 x i8], i8 }
%union.anon = type { ptr }
%struct.xSTATIC_LIST = type { i64, ptr, %struct.xSTATIC_MINI_LIST_ITEM }
%struct.xSTATIC_MINI_LIST_ITEM = type { i32, [2 x ptr] }
%struct.pthread_mutexattr_internal = type { i32 }
%struct.pthread_cond_internal = type { i64, %struct.xSTATIC_QUEUE, i32 }

@cli_service_start.init = external hidden global i32, align 4

; 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 uwtable
declare dso_local ptr @cli_echo(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @cli_invoker(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @cli_service_start(i32 noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca %struct.sched_param, align 4
  %14 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  %15 = load i32, ptr @cli_service_start.init, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %3
  store i32 0, ptr %4, align 4
  br label %213

18:                                               ; preds = %3
  store i32 1, ptr @cli_service_start.init, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %19 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 392) #6
  store ptr %19, ptr %8, align 8, !tbaa !9
  %20 = load ptr, ptr %8, align 8, !tbaa !9
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %212

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

38:                                               ; preds = %23
  br label %143

39:                                               ; preds = %23
  %40 = load ptr, ptr %8, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.cli_service, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !11
  %43 = sext i32 %42 to i64
  %44 = call noalias ptr @calloc(i64 noundef %43, i64 noundef 1) #6
  %45 = load ptr, ptr %8, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.cli_service, ptr %45, i32 0, i32 2
  store ptr %44, ptr %46, align 8, !tbaa !19
  %47 = load ptr, ptr %8, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.cli_service, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !19
  %50 = icmp eq ptr %49, null
  br i1 %50, label %51, label %52

51:                                               ; preds = %39
  br label %143

52:                                               ; preds = %39
  %53 = load ptr, ptr %8, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.cli_service, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 8, !tbaa !11
  %56 = sext i32 %55 to i64
  %57 = call noalias ptr @calloc(i64 noundef %56, i64 noundef 1) #6
  %58 = load ptr, ptr %8, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.cli_service, ptr %58, i32 0, i32 3
  store ptr %57, ptr %59, align 8, !tbaa !20
  %60 = load ptr, ptr %8, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.cli_service, ptr %60, i32 0, i32 3
  %62 = load ptr, ptr %61, align 8, !tbaa !20
  %63 = icmp eq ptr %62, null
  br i1 %63, label %64, label %65

64:                                               ; preds = %52
  br label %143

65:                                               ; preds = %52
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  %68 = sext i32 %67 to i64
  %69 = call noalias ptr @calloc(i64 noundef %68, i64 noundef 8) #6
  %70 = load ptr, ptr %8, align 8, !tbaa !9
  %71 = getelementptr inbounds %struct.cli_service, ptr %70, i32 0, i32 4
  store ptr %69, ptr %71, align 8, !tbaa !21
  %72 = load ptr, ptr %8, align 8, !tbaa !9
  %73 = getelementptr inbounds %struct.cli_service, ptr %72, i32 0, i32 4
  %74 = load ptr, ptr %73, align 8, !tbaa !21
  %75 = icmp eq ptr %74, null
  br i1 %75, label %76, label %77

76:                                               ; preds = %65
  br label %143

77:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %106, %77
  %79 = load i32, ptr %10, align 4, !tbaa !5
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  %82 = icmp slt i32 %79, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %78
  store i32 3, ptr %9, align 4
  br label %109

84:                                               ; preds = %78
  %85 = load ptr, ptr %8, align 8, !tbaa !9
  %86 = getelementptr inbounds %struct.cli_service, ptr %85, i32 0, i32 0
  %87 = load i32, ptr %86, align 8, !tbaa !11
  %88 = sext i32 %87 to i64
  %89 = call noalias ptr @calloc(i64 noundef %88, i64 noundef 1) #6
  %90 = load ptr, ptr %8, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct.cli_service, ptr %90, i32 0, i32 4
  %92 = load ptr, ptr %91, align 8, !tbaa !21
  %93 = load i32, ptr %10, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds ptr, ptr %92, i64 %94
  store ptr %89, ptr %95, align 8, !tbaa !9
  %96 = load ptr, ptr %8, align 8, !tbaa !9
  %97 = getelementptr inbounds %struct.cli_service, ptr %96, i32 0, i32 4
  %98 = load ptr, ptr %97, align 8, !tbaa !21
  %99 = load i32, ptr %10, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds ptr, ptr %98, i64 %100
  %102 = load ptr, ptr %101, align 8, !tbaa !9
  %103 = icmp eq ptr %102, null
  br i1 %103, label %104, label %105

104:                                              ; preds = %84
  store i32 2, ptr %9, align 4
  br label %109

105:                                              ; preds = %84
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr %10, align 4, !tbaa !5
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %10, align 4, !tbaa !5
  br label %78, !llvm.loop !22

109:                                              ; preds = %104, %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %110 = load i32, ptr %9, align 4
  switch i32 %110, label %212 [
    i32 3, label %111
    i32 2, label %143
  ]

111:                                              ; preds = %109
  %112 = load ptr, ptr %8, align 8, !tbaa !9
  %113 = getelementptr inbounds %struct.cli_service, ptr %112, i32 0, i32 4
  %114 = load ptr, ptr %113, align 8, !tbaa !21
  %115 = getelementptr inbounds ptr, ptr %114, i64 0
  %116 = load ptr, ptr %115, align 8, !tbaa !9
  %117 = getelementptr inbounds i8, ptr %116, i64 0
  store i8 0, ptr %117, align 1, !tbaa !24
  %118 = load i32, ptr %6, align 4, !tbaa !5
  %119 = icmp slt i32 %118, 2
  br i1 %119, label %120, label %121

120:                                              ; preds = %111
  store i32 2, ptr %6, align 4, !tbaa !5
  br label %121

121:                                              ; preds = %120, %111
  %122 = load i32, ptr %6, align 4, !tbaa !5
  %123 = load ptr, ptr %8, align 8, !tbaa !9
  %124 = getelementptr inbounds %struct.cli_service, ptr %123, i32 0, i32 10
  store i32 %122, ptr %124, align 8, !tbaa !25
  %125 = load ptr, ptr %8, align 8, !tbaa !9
  %126 = getelementptr inbounds %struct.cli_service, ptr %125, i32 0, i32 11
  store i32 0, ptr %126, align 4, !tbaa !26
  %127 = load ptr, ptr %8, align 8, !tbaa !9
  %128 = getelementptr inbounds %struct.cli_service, ptr %127, i32 0, i32 8
  %129 = call i32 @pthread_mutex_init(ptr noundef %128, ptr noundef null)
  %130 = load ptr, ptr %8, align 8, !tbaa !9
  %131 = getelementptr inbounds %struct.cli_service, ptr %130, i32 0, i32 9
  %132 = call i32 @pthread_cond_init(ptr noundef %131, ptr noundef null)
  %133 = call i32 @pthread_attr_init(ptr noundef %12)
  %134 = call i32 @pthread_attr_getschedparam(ptr noundef %12, ptr noundef %13)
  %135 = load i32, ptr %7, align 4, !tbaa !5
  %136 = getelementptr inbounds %struct.sched_param, ptr %13, i32 0, i32 0
  store i32 %135, ptr %136, align 4, !tbaa !27
  %137 = call i32 @pthread_attr_setschedparam(ptr noundef %12, ptr noundef %13)
  %138 = call i32 @pthread_attr_setstacksize(ptr noundef %12, i64 noundef 2048)
  %139 = load ptr, ptr %8, align 8, !tbaa !9
  %140 = call i32 @pthread_create(ptr noundef %11, ptr noundef %12, ptr noundef @cli_echo, ptr noundef %139)
  %141 = load ptr, ptr %8, align 8, !tbaa !9
  %142 = call i32 @pthread_create(ptr noundef %11, ptr noundef %12, ptr noundef @cli_invoker, ptr noundef %141)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %212

143:                                              ; preds = %109, %76, %64, %51, %38
  %144 = load ptr, ptr %8, align 8, !tbaa !9
  %145 = icmp ne ptr %144, null
  br i1 %145, label %146, label %211

146:                                              ; preds = %143
  %147 = load ptr, ptr %8, align 8, !tbaa !9
  %148 = getelementptr inbounds %struct.cli_service, ptr %147, i32 0, i32 1
  %149 = load ptr, ptr %148, align 8, !tbaa !18
  %150 = icmp ne ptr %149, null
  br i1 %150, label %151, label %155

151:                                              ; preds = %146
  %152 = load ptr, ptr %8, align 8, !tbaa !9
  %153 = getelementptr inbounds %struct.cli_service, ptr %152, i32 0, i32 1
  %154 = load ptr, ptr %153, align 8, !tbaa !18
  call void @free(ptr noundef %154) #5
  br label %155

155:                                              ; preds = %151, %146
  %156 = load ptr, ptr %8, align 8, !tbaa !9
  %157 = getelementptr inbounds %struct.cli_service, ptr %156, i32 0, i32 2
  %158 = load ptr, ptr %157, align 8, !tbaa !19
  %159 = icmp ne ptr %158, null
  br i1 %159, label %160, label %164

160:                                              ; preds = %155
  %161 = load ptr, ptr %8, align 8, !tbaa !9
  %162 = getelementptr inbounds %struct.cli_service, ptr %161, i32 0, i32 2
  %163 = load ptr, ptr %162, align 8, !tbaa !19
  call void @free(ptr noundef %163) #5
  br label %164

164:                                              ; preds = %160, %155
  %165 = load ptr, ptr %8, align 8, !tbaa !9
  %166 = getelementptr inbounds %struct.cli_service, ptr %165, i32 0, i32 3
  %167 = load ptr, ptr %166, align 8, !tbaa !20
  %168 = icmp ne ptr %167, null
  br i1 %168, label %169, label %173

169:                                              ; preds = %164
  %170 = load ptr, ptr %8, align 8, !tbaa !9
  %171 = getelementptr inbounds %struct.cli_service, ptr %170, i32 0, i32 3
  %172 = load ptr, ptr %171, align 8, !tbaa !20
  call void @free(ptr noundef %172) #5
  br label %173

173:                                              ; preds = %169, %164
  %174 = load ptr, ptr %8, align 8, !tbaa !9
  %175 = getelementptr inbounds %struct.cli_service, ptr %174, i32 0, i32 4
  %176 = load ptr, ptr %175, align 8, !tbaa !21
  %177 = icmp ne ptr %176, null
  br i1 %177, label %178, label %209

178:                                              ; preds = %173
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %179

179:                                              ; preds = %202, %178
  %180 = load i32, ptr %14, align 4, !tbaa !5
  %181 = load i32, ptr %6, align 4, !tbaa !5
  %182 = icmp slt i32 %180, %181
  br i1 %182, label %184, label %183

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

184:                                              ; preds = %179
  %185 = load ptr, ptr %8, align 8, !tbaa !9
  %186 = getelementptr inbounds %struct.cli_service, ptr %185, i32 0, i32 4
  %187 = load ptr, ptr %186, align 8, !tbaa !21
  %188 = load i32, ptr %14, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds ptr, ptr %187, i64 %189
  %191 = load ptr, ptr %190, align 8, !tbaa !9
  %192 = icmp ne ptr %191, null
  br i1 %192, label %193, label %201

193:                                              ; preds = %184
  %194 = load ptr, ptr %8, align 8, !tbaa !9
  %195 = getelementptr inbounds %struct.cli_service, ptr %194, i32 0, i32 4
  %196 = load ptr, ptr %195, align 8, !tbaa !21
  %197 = load i32, ptr %14, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds ptr, ptr %196, i64 %198
  %200 = load ptr, ptr %199, align 8, !tbaa !9
  call void @free(ptr noundef %200) #5
  br label %201

201:                                              ; preds = %193, %184
  br label %202

202:                                              ; preds = %201
  %203 = load i32, ptr %14, align 4, !tbaa !5
  %204 = add nsw i32 %203, 1
  store i32 %204, ptr %14, align 4, !tbaa !5
  br label %179, !llvm.loop !29

205:                                              ; preds = %183
  %206 = load ptr, ptr %8, align 8, !tbaa !9
  %207 = getelementptr inbounds %struct.cli_service, ptr %206, i32 0, i32 4
  %208 = load ptr, ptr %207, align 8, !tbaa !21
  call void @free(ptr noundef %208) #5
  br label %209

209:                                              ; preds = %205, %173
  %210 = load ptr, ptr %8, align 8, !tbaa !9
  call void @free(ptr noundef %210) #5
  br label %211

211:                                              ; preds = %209, %143
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %212

212:                                              ; preds = %211, %121, %109, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %213

213:                                              ; preds = %212, %17
  %214 = load i32, ptr %4, align 4
  ret i32 %214
}

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

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

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

declare i32 @pthread_attr_init(ptr noundef) #3

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

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

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

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

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

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

!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, !6, i64 0}
!12 = !{!"cli_service", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !6, i64 40, !6, i64 44, !6, i64 48, !13, i64 56, !17, i64 224, !6, i64 384, !6, i64 388}
!13 = !{!"pthread_mutex_internal", !14, i64 0, !15, i64 8, !10, i64 152, !16, i64 160}
!14 = !{!"long", !7, i64 0}
!15 = !{!"xSTATIC_QUEUE", !7, i64 0, !7, i64 24, !7, i64 32, !7, i64 112, !7, i64 136, !7, i64 138}
!16 = !{!"pthread_mutexattr_internal", !6, i64 0}
!17 = !{!"pthread_cond_internal", !14, i64 0, !15, i64 8, !6, i64 152}
!18 = !{!12, !10, i64 8}
!19 = !{!12, !10, i64 16}
!20 = !{!12, !10, i64 24}
!21 = !{!12, !10, i64 32}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!7, !7, i64 0}
!25 = !{!12, !6, i64 384}
!26 = !{!12, !6, i64 388}
!27 = !{!28, !6, i64 0}
!28 = !{!"sched_param", !6, i64 0}
!29 = distinct !{!29, !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"

%struct.sched_param = type { i32 }

@cli_service_start.init = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local ptr @cli_echo(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @cli_invoker(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @cli_service_start(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.sched_param, align 4
  %7 = load i32, ptr @cli_service_start.init, align 4, !tbaa !5
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %8, label %52

8:                                                ; preds = %3
  store i32 1, ptr @cli_service_start.init, align 4, !tbaa !5
  %9 = tail call noalias dereferenceable_or_null(392) ptr @calloc(i64 noundef 1, i64 noundef 392) #6
  %10 = icmp eq ptr %9, null
  br i1 %10, label %52, label %11

11:                                               ; preds = %8
  store i32 %0, ptr %9, align 8, !tbaa !9
  %12 = sext i32 %0 to i64
  %13 = tail call noalias ptr @calloc(i64 noundef %12, i64 noundef 1) #6
  %14 = getelementptr inbounds i8, ptr %9, i64 8
  store ptr %13, ptr %14, align 8, !tbaa !17
  %15 = icmp eq ptr %13, null
  br i1 %15, label %.thread99, label %16

16:                                               ; preds = %11
  %17 = tail call noalias ptr @calloc(i64 noundef %12, i64 noundef 1) #6
  %18 = getelementptr inbounds i8, ptr %9, i64 16
  store ptr %17, ptr %18, align 8, !tbaa !18
  %19 = icmp eq ptr %17, null
  br i1 %19, label %.thread99.sink.split, label %20

20:                                               ; preds = %16
  %21 = tail call noalias ptr @calloc(i64 noundef %12, i64 noundef 1) #6
  %22 = getelementptr inbounds i8, ptr %9, i64 24
  store ptr %21, ptr %22, align 8, !tbaa !19
  %23 = icmp eq ptr %21, null
  br i1 %23, label %.thread68.thread90, label %24

24:                                               ; preds = %20
  %25 = add i32 %1, 1
  %26 = sext i32 %25 to i64
  %27 = tail call noalias ptr @calloc(i64 noundef %26, i64 noundef 8) #6
  %28 = getelementptr inbounds i8, ptr %9, i64 32
  store ptr %27, ptr %28, align 8, !tbaa !20
  %29 = icmp eq ptr %27, null
  br i1 %29, label %.thread68.thread90, label %.preheader70

.preheader70:                                     ; preds = %24
  %.not5971 = icmp sgt i32 %1, -1
  tail call void @llvm.assume(i1 %.not5971)
  %wide.trip.count = zext i32 %25 to i64
  br label %.lr.ph

30:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !21

.lr.ph:                                           ; preds = %.preheader70, %30
  %indvars.iv = phi i64 [ 0, %.preheader70 ], [ %indvars.iv.next, %30 ]
  %31 = tail call noalias ptr @calloc(i64 noundef %12, i64 noundef 1) #6
  %32 = getelementptr inbounds ptr, ptr %27, i64 %indvars.iv
  store ptr %31, ptr %32, align 8, !tbaa !23
  %33 = icmp eq ptr %31, null
  br i1 %33, label %.thread68.thread90, label %30

._crit_edge.loopexit:                             ; preds = %30
  %.pre = load ptr, ptr %27, align 8, !tbaa !23
  store i8 0, ptr %.pre, align 1, !tbaa !24
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %1, i32 2)
  %34 = getelementptr inbounds i8, ptr %9, i64 384
  store i32 %spec.store.select, ptr %34, align 8, !tbaa !25
  %35 = getelementptr inbounds i8, ptr %9, i64 56
  %36 = tail call i32 @pthread_mutex_init(ptr noundef nonnull %35, ptr noundef null) #7
  %37 = getelementptr inbounds i8, ptr %9, i64 224
  %38 = tail call i32 @pthread_cond_init(ptr noundef nonnull %37, ptr noundef null) #7
  %39 = call i32 @pthread_attr_init(ptr noundef nonnull %5) #7
  %40 = call i32 @pthread_attr_getschedparam(ptr noundef nonnull %5, ptr noundef nonnull %6) #7
  store i32 %2, ptr %6, align 4, !tbaa !26
  %41 = call i32 @pthread_attr_setschedparam(ptr noundef nonnull %5, ptr noundef nonnull %6) #7
  %42 = call i32 @pthread_attr_setstacksize(ptr noundef nonnull %5, i64 noundef 2048) #7
  %43 = call i32 @pthread_create(ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull @cli_echo, ptr noundef nonnull %9) #7
  %44 = call i32 @pthread_create(ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull @cli_invoker, ptr noundef nonnull %9) #7
  br label %52

.thread68.thread90:                               ; preds = %.lr.ph, %24, %20
  %.pre838693 = phi ptr [ null, %20 ], [ null, %24 ], [ %27, %.lr.ph ]
  tail call void @free(ptr noundef nonnull %13) #7
  tail call void @free(ptr noundef nonnull %17) #7
  %.not62 = icmp eq ptr %21, null
  br i1 %.not62, label %46, label %45

45:                                               ; preds = %.thread68.thread90
  tail call void @free(ptr noundef nonnull %21) #7
  %.phi.trans.insert = getelementptr inbounds i8, ptr %9, i64 32
  %.pre82 = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !20
  br label %46

46:                                               ; preds = %45, %.thread68.thread90
  %.pre83 = phi ptr [ %.pre82, %45 ], [ %.pre838693, %.thread68.thread90 ]
  %.not63 = icmp eq ptr %.pre83, null
  br i1 %.not63, label %.thread99, label %.preheader

.preheader:                                       ; preds = %46
  %47 = icmp sgt i32 %1, 0
  br i1 %47, label %.lr.ph74.preheader, label %.thread99.sink.split

.lr.ph74.preheader:                               ; preds = %.preheader
  %wide.trip.count80 = zext nneg i32 %1 to i64
  br label %.lr.ph74

.lr.ph74:                                         ; preds = %.lr.ph74.preheader, %51
  %indvars.iv77 = phi i64 [ 0, %.lr.ph74.preheader ], [ %indvars.iv.next78, %51 ]
  %48 = getelementptr inbounds ptr, ptr %.pre83, i64 %indvars.iv77
  %49 = load ptr, ptr %48, align 8, !tbaa !23
  %.not64 = icmp eq ptr %49, null
  br i1 %.not64, label %51, label %50

50:                                               ; preds = %.lr.ph74
  tail call void @free(ptr noundef nonnull %49) #7
  br label %51

51:                                               ; preds = %.lr.ph74, %50
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %exitcond81.not = icmp eq i64 %indvars.iv.next78, %wide.trip.count80
  br i1 %exitcond81.not, label %.thread99.sink.split, label %.lr.ph74, !llvm.loop !28

.thread99.sink.split:                             ; preds = %51, %.preheader, %16
  %.sink = phi ptr [ %13, %16 ], [ %.pre83, %.preheader ], [ %.pre83, %51 ]
  tail call void @free(ptr noundef nonnull %.sink) #7
  br label %.thread99

.thread99:                                        ; preds = %.thread99.sink.split, %11, %46
  tail call void @free(ptr noundef nonnull %9) #7
  br label %52

52:                                               ; preds = %._crit_edge.loopexit, %.thread99, %8, %3
  %.1 = phi i32 [ 0, %3 ], [ -1, %.thread99 ], [ 0, %._crit_edge.loopexit ], [ -1, %8 ]
  ret i32 %.1
}

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

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

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

declare i32 @pthread_attr_init(ptr noundef) local_unnamed_addr #2

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

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

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #5

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
attributes #6 = { nounwind allocsize(0,1) }
attributes #7 = { 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 0}
!10 = !{!"cli_service", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !6, i64 40, !6, i64 44, !6, i64 48, !12, i64 56, !16, i64 224, !6, i64 384, !6, i64 388}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"pthread_mutex_internal", !13, i64 0, !14, i64 8, !11, i64 152, !15, i64 160}
!13 = !{!"long", !7, i64 0}
!14 = !{!"xSTATIC_QUEUE", !7, i64 0, !7, i64 24, !7, i64 32, !7, i64 112, !7, i64 136, !7, i64 138}
!15 = !{!"pthread_mutexattr_internal", !6, i64 0}
!16 = !{!"pthread_cond_internal", !13, i64 0, !14, i64 8, !6, i64 152}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !11, i64 16}
!19 = !{!10, !11, i64 24}
!20 = !{!10, !11, i64 32}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!11, !11, i64 0}
!24 = !{!7, !7, i64 0}
!25 = !{!10, !6, i64 384}
!26 = !{!27, !6, i64 0}
!27 = !{!"sched_param", !6, i64 0}
!28 = distinct !{!28, !22}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass