; LLVM IR from Aeternum-Veritas/Merry :: merry (merry_subsystem)

; 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.MerrySubSys = type { ptr, i64, i64, i64, ptr, ptr, i8, ptr }
%struct.MerrySubChannel = type { ptr, ptr, i8 }

@stdout = external global ptr, align 8
@subsys = external hidden global %struct.MerrySubSys, align 8
@stderr = external global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [67 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @merry_subsys_add_channel() #3 {
  %1 = alloca i64, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = load ptr, ptr @stdout, align 8, !tbaa !5
  %5 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef @.str.6, ptr noundef null) #6
  %6 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 5), align 8, !tbaa !9
  call void @merry_mutex_lock(ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #6
  %7 = call i64 @merry_subsys_find_inactive_channel()
  store i64 %7, ptr %1, align 8, !tbaa !12
  %8 = load i64, ptr %1, align 8, !tbaa !12
  %9 = load i64, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 1), align 8, !tbaa !13
  %10 = add i64 %9, 1
  %11 = icmp ne i64 %8, %10
  br i1 %11, label %12, label %41

12:                                               ; preds = %0
  %13 = load ptr, ptr @subsys, align 8, !tbaa !14
  %14 = load i64, ptr %1, align 8, !tbaa !12
  %15 = getelementptr inbounds %struct.MerrySubChannel, ptr %13, i64 %14
  %16 = getelementptr inbounds %struct.MerrySubChannel, ptr %15, i32 0, i32 1
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %29

19:                                               ; preds = %12
  %20 = load ptr, ptr @subsys, align 8, !tbaa !14
  %21 = load i64, ptr %1, align 8, !tbaa !12
  %22 = getelementptr inbounds %struct.MerrySubChannel, ptr %20, i64 %21
  %23 = call zeroext i8 @merry_create_channel_given(ptr noundef %22)
  %24 = zext i8 %23 to i32
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %26, label %29

26:                                               ; preds = %19
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.7) #6
  store i64 -1, ptr %1, align 8, !tbaa !12
  br label %40

29:                                               ; preds = %19, %12
  %30 = load ptr, ptr @subsys, align 8, !tbaa !14
  %31 = load i64, ptr %1, align 8, !tbaa !12
  %32 = getelementptr inbounds %struct.MerrySubChannel, ptr %30, i64 %31
  %33 = call zeroext i8 @merry_reactivate_channel(ptr noundef %32)
  %34 = zext i8 %33 to i32
  %35 = icmp eq i32 %34, 1
  br i1 %35, label %36, label %39

36:                                               ; preds = %29
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef @.str.8) #6
  store i64 -1, ptr %1, align 8, !tbaa !12
  br label %39

39:                                               ; preds = %36, %29
  br label %40

40:                                               ; preds = %39, %26
  br label %100

41:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  %42 = load i64, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 1), align 8, !tbaa !13
  %43 = add i64 %42, 10
  %44 = mul i64 24, %43
  %45 = call noalias ptr @malloc(i64 noundef %44) #7
  store ptr %45, ptr %2, align 8, !tbaa !5
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = icmp eq ptr %46, null
  br i1 %47, label %48, label %51

48:                                               ; preds = %41
  %49 = load ptr, ptr @stderr, align 8, !tbaa !5
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str.9) #6
  store i64 -1, ptr %1, align 8, !tbaa !12
  br label %99

51:                                               ; preds = %41
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = load ptr, ptr @subsys, align 8, !tbaa !14
  %54 = load i64, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 1), align 8, !tbaa !13
  %55 = mul i64 %54, 24
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %52, ptr align 8 %53, i64 %55, i1 false)
  %56 = load ptr, ptr @subsys, align 8, !tbaa !14
  call void @free(ptr noundef %56) #6
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %57, ptr @subsys, align 8, !tbaa !14
  %58 = load i64, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 1), align 8, !tbaa !13
  store i64 %58, ptr %1, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %59 = load i64, ptr %1, align 8, !tbaa !12
  store i64 %59, ptr %3, align 8, !tbaa !12
  br label %60

60:                                               ; preds = %79, %51
  %61 = load i64, ptr %3, align 8, !tbaa !12
  %62 = load i64, ptr %1, align 8, !tbaa !12
  %63 = add i64 %62, 10
  %64 = icmp ult i64 %61, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %82

66:                                               ; preds = %60
  %67 = load ptr, ptr @subsys, align 8, !tbaa !14
  %68 = load i64, ptr %3, align 8, !tbaa !12
  %69 = getelementptr inbounds %struct.MerrySubChannel, ptr %67, i64 %68
  %70 = getelementptr inbounds %struct.MerrySubChannel, ptr %69, i32 0, i32 2
  store i8 0, ptr %70, align 8, !tbaa !17
  %71 = load ptr, ptr @subsys, align 8, !tbaa !14
  %72 = load i64, ptr %3, align 8, !tbaa !12
  %73 = getelementptr inbounds %struct.MerrySubChannel, ptr %71, i64 %72
  %74 = getelementptr inbounds %struct.MerrySubChannel, ptr %73, i32 0, i32 1
  store ptr null, ptr %74, align 8, !tbaa !15
  %75 = load ptr, ptr @subsys, align 8, !tbaa !14
  %76 = load i64, ptr %3, align 8, !tbaa !12
  %77 = getelementptr inbounds %struct.MerrySubChannel, ptr %75, i64 %76
  %78 = getelementptr inbounds %struct.MerrySubChannel, ptr %77, i32 0, i32 0
  store ptr null, ptr %78, align 8, !tbaa !18
  br label %79

79:                                               ; preds = %66
  %80 = load i64, ptr %3, align 8, !tbaa !12
  %81 = add i64 %80, 1
  store i64 %81, ptr %3, align 8, !tbaa !12
  br label %60, !llvm.loop !19

82:                                               ; preds = %65
  %83 = load i64, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 1), align 8, !tbaa !13
  %84 = add i64 %83, 10
  store i64 %84, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 1), align 8, !tbaa !13
  %85 = load ptr, ptr @subsys, align 8, !tbaa !14
  %86 = load i64, ptr %1, align 8, !tbaa !12
  %87 = getelementptr inbounds %struct.MerrySubChannel, ptr %85, i64 %86
  %88 = call zeroext i8 @merry_create_channel_given(ptr noundef %87)
  %89 = zext i8 %88 to i32
  %90 = icmp eq i32 %89, 1
  br i1 %90, label %91, label %94

91:                                               ; preds = %82
  %92 = load ptr, ptr @stderr, align 8, !tbaa !5
  %93 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %92, ptr noundef @.str.10) #6
  store i64 -1, ptr %1, align 8, !tbaa !12
  br label %98

94:                                               ; preds = %82
  %95 = load ptr, ptr @subsys, align 8, !tbaa !14
  %96 = load i64, ptr %1, align 8, !tbaa !12
  %97 = getelementptr inbounds %struct.MerrySubChannel, ptr %95, i64 %96
  call void @merry_config_channel(ptr noundef %97)
  br label %98

98:                                               ; preds = %94, %91
  br label %99

99:                                               ; preds = %98, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  br label %100

100:                                              ; preds = %99, %40
  %101 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 5), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %101)
  %102 = load i64, ptr %1, align 8, !tbaa !12
  %103 = icmp eq i64 %102, -1
  br i1 %103, label %104, label %107

104:                                              ; preds = %100
  %105 = load ptr, ptr @stderr, align 8, !tbaa !5
  %106 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %105, ptr noundef @.str.11) #6
  br label %110

107:                                              ; preds = %100
  %108 = load ptr, ptr @stdout, align 8, !tbaa !5
  %109 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %108, ptr noundef @.str.12, ptr noundef null) #6
  br label %110

110:                                              ; preds = %107, %104
  %111 = load i64, ptr %1, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #6
  ret i64 %111
}

declare void @merry_mutex_lock(ptr noundef) #4

declare zeroext i8 @merry_create_channel_given(ptr noundef) #4

declare zeroext i8 @merry_reactivate_channel(ptr noundef) #4

; 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) #5

declare void @merry_config_channel(ptr noundef) #4

declare void @merry_mutex_unlock(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden i64 @merry_subsys_find_inactive_channel() #3

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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "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: readwrite) }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 40}
!10 = !{!"MerrySubSys", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !6, i64 32, !6, i64 40, !7, i64 48, !6, i64 56}
!11 = !{!"long", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 8}
!14 = !{!10, !6, i64 0}
!15 = !{!16, !6, i64 8}
!16 = !{!"MerrySubChannel", !6, i64 0, !6, i64 8, !7, i64 16}
!17 = !{!16, !7, i64 16}
!18 = !{!16, !6, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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"

%struct.MerrySubSys = type { ptr, i64, i64, i64, ptr, ptr, i8, ptr }
%struct.MerrySubChannel = type { ptr, ptr, i8 }

@stdout = external local_unnamed_addr global ptr, align 8
@subsys = external hidden local_unnamed_addr global %struct.MerrySubSys, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [67 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @merry_subsys_add_channel() local_unnamed_addr #3 {
  %1 = load ptr, ptr @stdout, align 8, !tbaa !5
  %2 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.6, ptr noundef null) #7
  %3 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 40), align 8, !tbaa !9
  tail call void @merry_mutex_lock(ptr noundef %3) #7
  %4 = tail call i64 @merry_subsys_find_inactive_channel()
  %5 = load i64, ptr getelementptr inbounds (i8, ptr @subsys, i64 8), align 8, !tbaa !12
  %6 = add i64 %5, 1
  %.not = icmp eq i64 %4, %6
  br i1 %.not, label %21, label %7

7:                                                ; preds = %0
  %8 = load ptr, ptr @subsys, align 8, !tbaa !13
  %9 = getelementptr inbounds %struct.MerrySubChannel, ptr %8, i64 %4
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %16

13:                                               ; preds = %7
  %14 = tail call zeroext i8 @merry_create_channel_given(ptr noundef nonnull %9) #7
  %15 = icmp eq i8 %14, 1
  br i1 %15, label %.thread, label %._crit_edge24

._crit_edge24:                                    ; preds = %13
  %.pre = load ptr, ptr @subsys, align 8, !tbaa !13
  br label %16

16:                                               ; preds = %._crit_edge24, %7
  %17 = phi ptr [ %.pre, %._crit_edge24 ], [ %8, %7 ]
  %18 = getelementptr inbounds %struct.MerrySubChannel, ptr %17, i64 %4
  %19 = tail call zeroext i8 @merry_reactivate_channel(ptr noundef %18) #7
  %20 = icmp eq i8 %19, 1
  br i1 %20, label %.thread, label %59

21:                                               ; preds = %0
  %22 = mul i64 %5, 24
  %23 = add i64 %22, 240
  %24 = tail call noalias ptr @malloc(i64 noundef %23) #8
  %25 = icmp eq ptr %24, null
  br i1 %25, label %.thread, label %26

26:                                               ; preds = %21
  %27 = load ptr, ptr @subsys, align 8, !tbaa !13
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %24, ptr align 8 %27, i64 %22, i1 false)
  tail call void @free(ptr noundef %27) #7
  store ptr %24, ptr @subsys, align 8, !tbaa !13
  %28 = load i64, ptr getelementptr inbounds (i8, ptr @subsys, i64 8), align 8, !tbaa !12
  %29 = add i64 %28, 10
  %30 = icmp ult i64 %28, -10
  br i1 %30, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %26
  %31 = getelementptr inbounds %struct.MerrySubChannel, ptr %24, i64 %28
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %31, i8 0, i64 17, i1 false)
  %32 = getelementptr %struct.MerrySubChannel, ptr %24, i64 %28
  %33 = getelementptr i8, ptr %32, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %33, i8 0, i64 17, i1 false)
  %34 = getelementptr %struct.MerrySubChannel, ptr %24, i64 %28
  %35 = getelementptr i8, ptr %34, i64 48
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %35, i8 0, i64 17, i1 false)
  %36 = getelementptr %struct.MerrySubChannel, ptr %24, i64 %28
  %37 = getelementptr i8, ptr %36, i64 72
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %37, i8 0, i64 17, i1 false)
  %38 = getelementptr %struct.MerrySubChannel, ptr %24, i64 %28
  %39 = getelementptr i8, ptr %38, i64 96
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %39, i8 0, i64 17, i1 false)
  %40 = getelementptr %struct.MerrySubChannel, ptr %24, i64 %28
  %41 = getelementptr i8, ptr %40, i64 120
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %41, i8 0, i64 17, i1 false)
  %42 = getelementptr %struct.MerrySubChannel, ptr %24, i64 %28
  %43 = getelementptr i8, ptr %42, i64 144
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %43, i8 0, i64 17, i1 false)
  %44 = getelementptr %struct.MerrySubChannel, ptr %24, i64 %28
  %45 = getelementptr i8, ptr %44, i64 168
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %45, i8 0, i64 17, i1 false)
  %46 = getelementptr %struct.MerrySubChannel, ptr %24, i64 %28
  %47 = getelementptr i8, ptr %46, i64 192
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %47, i8 0, i64 17, i1 false)
  %48 = getelementptr %struct.MerrySubChannel, ptr %24, i64 %28
  %49 = getelementptr i8, ptr %48, i64 216
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %49, i8 0, i64 17, i1 false)
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.preheader, %26
  store i64 %29, ptr getelementptr inbounds (i8, ptr @subsys, i64 8), align 8, !tbaa !12
  %50 = getelementptr inbounds %struct.MerrySubChannel, ptr %24, i64 %28
  %51 = tail call zeroext i8 @merry_create_channel_given(ptr noundef nonnull %50) #7
  %52 = icmp eq i8 %51, 1
  br i1 %52, label %.thread, label %53

53:                                               ; preds = %._crit_edge
  %54 = load ptr, ptr @subsys, align 8, !tbaa !13
  %55 = getelementptr inbounds %struct.MerrySubChannel, ptr %54, i64 %28
  tail call void @merry_config_channel(ptr noundef %55) #7
  br label %59

.thread:                                          ; preds = %._crit_edge, %21, %16, %13
  %.str.7.sink = phi ptr [ @.str.7, %13 ], [ @.str.8, %16 ], [ @.str.9, %21 ], [ @.str.10, %._crit_edge ]
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef nonnull %.str.7.sink) #9
  %58 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 40), align 8, !tbaa !9
  tail call void @merry_mutex_unlock(ptr noundef %58) #7
  br label %62

59:                                               ; preds = %53, %16
  %.1 = phi i64 [ %4, %16 ], [ %28, %53 ]
  %60 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 40), align 8, !tbaa !9
  tail call void @merry_mutex_unlock(ptr noundef %60) #7
  %61 = icmp eq i64 %.1, -1
  br i1 %61, label %62, label %65

62:                                               ; preds = %.thread, %59
  %63 = load ptr, ptr @stderr, align 8, !tbaa !5
  %64 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef nonnull @.str.11) #9
  br label %68

65:                                               ; preds = %59
  %66 = load ptr, ptr @stdout, align 8, !tbaa !5
  %67 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef nonnull @.str.12, ptr noundef null) #7
  br label %68

68:                                               ; preds = %65, %62
  %.121 = phi i64 [ %.1, %65 ], [ -1, %62 ]
  ret i64 %.121
}

declare void @merry_mutex_lock(ptr noundef) local_unnamed_addr #4

declare zeroext i8 @merry_create_channel_given(ptr noundef) local_unnamed_addr #4

declare zeroext i8 @merry_reactivate_channel(ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress 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) #5

declare void @merry_config_channel(ptr noundef) local_unnamed_addr #4

declare void @merry_mutex_unlock(ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden i64 @merry_subsys_find_inactive_channel() local_unnamed_addr #3

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

attributes #0 = { nofree 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 = { 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 = { 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 #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { cold 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, !6, i64 40}
!10 = !{!"MerrySubSys", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !6, i64 32, !6, i64 40, !7, i64 48, !6, i64 56}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !6, i64 0}
!14 = !{!15, !6, i64 8}
!15 = !{!"MerrySubChannel", !6, i64 0, !6, i64 8, !7, i64 16}


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