; 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.epoll_event = type <{ i32, %union.epoll_data }>
%union.epoll_data = type { ptr }
%struct.MerryTask = type { ptr, i64, ptr }
%struct.MerryPipe = type { %union.anon, i8, i8, i8 }
%union.anon = type { [2 x i32] }
%struct.anon = type { i32, i32 }
%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.18 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [47 x i8], align 1

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

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

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

declare void @merry_mutex_lock(ptr noundef) #2

declare void @merry_mutex_unlock(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @merry_subsys_close_all() #3

; Function Attrs: nounwind uwtable
define dso_local ptr @merry_subsys_main(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %struct.epoll_event, align 1
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.epoll_event, align 1
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  %15 = alloca [16 x i8], align 16
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  %19 = alloca %struct.MerryTask, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %20 = load ptr, ptr @stdout, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str.18, ptr noundef null) #5
  %22 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 5), align 8, !tbaa !9
  call void @merry_mutex_lock(ptr noundef %22)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %23 = call i32 @epoll_create1(i32 noundef 0) #5
  store i32 %23, ptr %4, align 4, !tbaa !12
  %24 = load i32, ptr %4, align 4, !tbaa !12
  %25 = icmp eq i32 %24, -1
  br i1 %25, label %26, label %30

26:                                               ; preds = %1
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.19) #5
  call void @merry_requestHdlr_panic(i64 noundef 11, i64 noundef 0)
  %29 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 5), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %29)
  br label %324

30:                                               ; preds = %1
  %31 = load ptr, ptr @stdout, align 8, !tbaa !5
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.20, ptr noundef null) #5
  %33 = getelementptr inbounds %struct.epoll_event, ptr %5, i32 0, i32 0
  store i32 1, ptr %33, align 1, !tbaa !14
  %34 = getelementptr inbounds %struct.epoll_event, ptr %5, i32 0, i32 1
  %35 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 7), align 8, !tbaa !16
  %36 = getelementptr inbounds %struct.MerryPipe, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.anon, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 4, !tbaa !17
  store i32 %38, ptr %34, align 1, !tbaa !17
  %39 = load i32, ptr %4, align 4, !tbaa !12
  %40 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 7), align 8, !tbaa !16
  %41 = getelementptr inbounds %struct.MerryPipe, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds %struct.anon, ptr %41, i32 0, i32 0
  %43 = load i32, ptr %42, align 4, !tbaa !17
  %44 = call i32 @epoll_ctl(i32 noundef %39, i32 noundef 1, i32 noundef %43, ptr noundef %5) #5
  %45 = icmp eq i32 %44, -1
  br i1 %45, label %46, label %50

46:                                               ; preds = %30
  %47 = load ptr, ptr @stderr, align 8, !tbaa !5
  %48 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str.21) #5
  call void @merry_requestHdlr_panic(i64 noundef 11, i64 noundef 0)
  %49 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 5), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %49)
  br label %324

50:                                               ; preds = %30
  %51 = load ptr, ptr @stdout, align 8, !tbaa !5
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef @.str.22, ptr noundef null) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 0, ptr %6, align 8, !tbaa !18
  br label %53

53:                                               ; preds = %100, %50
  %54 = load i64, ptr %6, align 8, !tbaa !18
  %55 = load i64, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 1), align 8, !tbaa !19
  %56 = icmp ult i64 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  store i32 3, ptr %7, align 4
  br label %103

58:                                               ; preds = %53
  %59 = load ptr, ptr @subsys, align 8, !tbaa !20
  %60 = load i64, ptr %6, align 8, !tbaa !18
  %61 = getelementptr inbounds %struct.MerrySubChannel, ptr %59, i64 %60
  %62 = getelementptr inbounds %struct.MerrySubChannel, ptr %61, i32 0, i32 2
  %63 = load i8, ptr %62, align 8, !tbaa !21
  %64 = icmp ne i8 %63, 0
  br i1 %64, label %65, label %72

65:                                               ; preds = %58
  %66 = load ptr, ptr @subsys, align 8, !tbaa !20
  %67 = load i64, ptr %6, align 8, !tbaa !18
  %68 = getelementptr inbounds %struct.MerrySubChannel, ptr %66, i64 %67
  %69 = getelementptr inbounds %struct.MerrySubChannel, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !23
  %71 = icmp ne ptr %70, null
  br i1 %71, label %73, label %72

72:                                               ; preds = %65, %58
  br label %100

73:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #5
  %74 = getelementptr inbounds %struct.epoll_event, ptr %8, i32 0, i32 0
  store i32 1, ptr %74, align 1, !tbaa !14
  %75 = getelementptr inbounds %struct.epoll_event, ptr %8, i32 0, i32 1
  %76 = load ptr, ptr @subsys, align 8, !tbaa !20
  %77 = load i64, ptr %6, align 8, !tbaa !18
  %78 = getelementptr inbounds %struct.MerrySubChannel, ptr %76, i64 %77
  %79 = getelementptr inbounds %struct.MerrySubChannel, ptr %78, i32 0, i32 1
  %80 = load ptr, ptr %79, align 8, !tbaa !23
  %81 = getelementptr inbounds %struct.MerryPipe, ptr %80, i32 0, i32 0
  %82 = getelementptr inbounds %struct.anon, ptr %81, i32 0, i32 0
  %83 = load i32, ptr %82, align 4, !tbaa !17
  store i32 %83, ptr %75, align 1, !tbaa !17
  %84 = load i32, ptr %4, align 4, !tbaa !12
  %85 = getelementptr inbounds %struct.epoll_event, ptr %8, i32 0, i32 1
  %86 = load i32, ptr %85, align 1, !tbaa !17
  %87 = call i32 @epoll_ctl(i32 noundef %84, i32 noundef 1, i32 noundef %86, ptr noundef %8) #5
  %88 = icmp eq i32 %87, -1
  br i1 %88, label %89, label %93

89:                                               ; preds = %73
  %90 = load ptr, ptr @stderr, align 8, !tbaa !5
  %91 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %90, ptr noundef @.str.23) #5
  call void @merry_requestHdlr_panic(i64 noundef 11, i64 noundef 0)
  %92 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 5), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %92)
  store i32 2, ptr %7, align 4
  br label %97

93:                                               ; preds = %73
  %94 = load ptr, ptr @stdout, align 8, !tbaa !5
  %95 = load i64, ptr %6, align 8, !tbaa !18
  %96 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %94, ptr noundef @.str.24, i64 noundef %95) #5
  store i32 0, ptr %7, align 4
  br label %97

97:                                               ; preds = %93, %89
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #5
  %98 = load i32, ptr %7, align 4
  switch i32 %98, label %103 [
    i32 0, label %99
  ]

99:                                               ; preds = %97
  br label %100

100:                                              ; preds = %99, %72
  %101 = load i64, ptr %6, align 8, !tbaa !18
  %102 = add i64 %101, 1
  store i64 %102, ptr %6, align 8, !tbaa !18
  br label %53, !llvm.loop !24

103:                                              ; preds = %97, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %104 = load i32, ptr %7, align 4
  switch i32 %104, label %340 [
    i32 3, label %105
    i32 2, label %324
  ]

105:                                              ; preds = %103
  %106 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 5), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %106)
  br label %107

107:                                              ; preds = %322, %105
  %108 = load i8, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 6), align 8, !tbaa !26
  %109 = icmp ne i8 %108, 0
  %110 = xor i1 %109, true
  br i1 %110, label %111, label %323

111:                                              ; preds = %107
  %112 = load i64, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 1), align 8, !tbaa !19
  %113 = add i64 %112, 1
  %114 = call ptr @llvm.stacksave.p0()
  store ptr %114, ptr %9, align 8
  %115 = alloca %struct.epoll_event, i64 %113, align 16
  store i64 %113, ptr %10, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %116 = load i32, ptr %4, align 4, !tbaa !12
  %117 = load i64, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 1), align 8, !tbaa !19
  %118 = add i64 %117, 1
  %119 = trunc i64 %118 to i32
  %120 = call i32 @epoll_wait(i32 noundef %116, ptr noundef %115, i32 noundef %119, i32 noundef -1)
  store i32 %120, ptr %11, align 4, !tbaa !12
  %121 = load i32, ptr %11, align 4, !tbaa !12
  %122 = icmp eq i32 %121, -1
  br i1 %122, label %123, label %126

123:                                              ; preds = %111
  %124 = load ptr, ptr @stderr, align 8, !tbaa !5
  %125 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %124, ptr noundef @.str.25) #5
  store i32 7, ptr %7, align 4
  br label %319

126:                                              ; preds = %111
  %127 = load ptr, ptr @stdout, align 8, !tbaa !5
  %128 = load i32, ptr %11, align 4, !tbaa !12
  %129 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %127, ptr noundef @.str.26, i32 noundef %128) #5
  %130 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 5), align 8, !tbaa !9
  call void @merry_mutex_lock(ptr noundef %130)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !12
  br label %131

131:                                              ; preds = %312, %126
  %132 = load i32, ptr %12, align 4, !tbaa !12
  %133 = load i32, ptr %11, align 4, !tbaa !12
  %134 = icmp slt i32 %132, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %131
  store i32 8, ptr %7, align 4
  br label %315

136:                                              ; preds = %131
  %137 = load i32, ptr %12, align 4, !tbaa !12
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds %struct.epoll_event, ptr %115, i64 %138
  %140 = getelementptr inbounds %struct.epoll_event, ptr %139, i32 0, i32 1
  %141 = load i32, ptr %140, align 4, !tbaa !17
  %142 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 7), align 8, !tbaa !16
  %143 = getelementptr inbounds %struct.MerryPipe, ptr %142, i32 0, i32 0
  %144 = getelementptr inbounds %struct.anon, ptr %143, i32 0, i32 0
  %145 = load i32, ptr %144, align 4, !tbaa !17
  %146 = icmp eq i32 %141, %145
  br i1 %146, label %147, label %222

147:                                              ; preds = %136
  %148 = load ptr, ptr @stdout, align 8, !tbaa !5
  %149 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %148, ptr noundef @.str.27, ptr noundef null) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #5
  %150 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 7), align 8, !tbaa !16
  %151 = getelementptr inbounds %struct.MerryPipe, ptr %150, i32 0, i32 0
  %152 = getelementptr inbounds %struct.anon, ptr %151, i32 0, i32 0
  %153 = load i32, ptr %152, align 4, !tbaa !17
  %154 = call i64 @read(i32 noundef %153, ptr noundef %13, i64 noundef 1)
  %155 = load i8, ptr %13, align 1, !tbaa !17
  %156 = zext i8 %155 to i32
  switch i32 %156, label %218 [
    i32 0, label %157
    i32 2, label %160
  ]

157:                                              ; preds = %147
  %158 = load ptr, ptr @stdout, align 8, !tbaa !5
  %159 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %158, ptr noundef @.str.28, ptr noundef null) #5
  call void @merry_subsys_close_all()
  call void (...) @merry_os_subsys_stopped()
  store i8 1, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 6), align 8, !tbaa !26
  store i32 2, ptr %7, align 4
  br label %219

160:                                              ; preds = %147
  %161 = load ptr, ptr @stdout, align 8, !tbaa !5
  %162 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %161, ptr noundef @.str.29, ptr noundef null) #5
  %163 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 7), align 8, !tbaa !16
  %164 = getelementptr inbounds %struct.MerryPipe, ptr %163, i32 0, i32 0
  %165 = getelementptr inbounds %struct.anon, ptr %164, i32 0, i32 0
  %166 = load i32, ptr %165, align 4, !tbaa !17
  %167 = call i64 @read(i32 noundef %166, ptr noundef %13, i64 noundef 1)
  %168 = load ptr, ptr @subsys, align 8, !tbaa !20
  %169 = load i8, ptr %13, align 1, !tbaa !17
  %170 = zext i8 %169 to i64
  %171 = getelementptr inbounds %struct.MerrySubChannel, ptr %168, i64 %170
  %172 = getelementptr inbounds %struct.MerrySubChannel, ptr %171, i32 0, i32 1
  %173 = load ptr, ptr %172, align 8, !tbaa !23
  %174 = getelementptr inbounds %struct.MerryPipe, ptr %173, i32 0, i32 0
  %175 = getelementptr inbounds %struct.anon, ptr %174, i32 0, i32 0
  %176 = load i32, ptr %175, align 4, !tbaa !17
  %177 = getelementptr inbounds %struct.epoll_event, ptr %5, i32 0, i32 1
  store i32 %176, ptr %177, align 1, !tbaa !17
  %178 = load ptr, ptr @subsys, align 8, !tbaa !20
  %179 = load i8, ptr %13, align 1, !tbaa !17
  %180 = zext i8 %179 to i64
  %181 = getelementptr inbounds %struct.MerrySubChannel, ptr %178, i64 %180
  %182 = getelementptr inbounds %struct.MerrySubChannel, ptr %181, i32 0, i32 2
  %183 = load i8, ptr %182, align 8, !tbaa !21
  %184 = zext i8 %183 to i32
  %185 = icmp eq i32 %184, 1
  br i1 %185, label %186, label %203

186:                                              ; preds = %160
  %187 = load i32, ptr %4, align 4, !tbaa !12
  %188 = load ptr, ptr @subsys, align 8, !tbaa !20
  %189 = load i8, ptr %13, align 1, !tbaa !17
  %190 = zext i8 %189 to i64
  %191 = getelementptr inbounds %struct.MerrySubChannel, ptr %188, i64 %190
  %192 = getelementptr inbounds %struct.MerrySubChannel, ptr %191, i32 0, i32 1
  %193 = load ptr, ptr %192, align 8, !tbaa !23
  %194 = getelementptr inbounds %struct.MerryPipe, ptr %193, i32 0, i32 0
  %195 = getelementptr inbounds %struct.anon, ptr %194, i32 0, i32 0
  %196 = load i32, ptr %195, align 4, !tbaa !17
  %197 = call i32 @epoll_ctl(i32 noundef %187, i32 noundef 1, i32 noundef %196, ptr noundef %5) #5
  %198 = icmp eq i32 %197, -1
  br i1 %198, label %199, label %203

199:                                              ; preds = %186
  %200 = load ptr, ptr @stderr, align 8, !tbaa !5
  %201 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %200, ptr noundef @.str.30) #5
  %202 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 5), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %202)
  store i32 2, ptr %7, align 4
  br label %219

203:                                              ; preds = %186, %160
  %204 = load ptr, ptr @stdout, align 8, !tbaa !5
  %205 = load i8, ptr %13, align 1, !tbaa !17
  %206 = zext i8 %205 to i32
  %207 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %204, ptr noundef @.str.31, i32 noundef %206) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #5
  store i8 1, ptr %14, align 1, !tbaa !17
  %208 = load ptr, ptr @subsys, align 8, !tbaa !20
  %209 = load i8, ptr %13, align 1, !tbaa !17
  %210 = zext i8 %209 to i64
  %211 = getelementptr inbounds %struct.MerrySubChannel, ptr %208, i64 %210
  %212 = getelementptr inbounds %struct.MerrySubChannel, ptr %211, i32 0, i32 0
  %213 = load ptr, ptr %212, align 8, !tbaa !27
  %214 = getelementptr inbounds %struct.MerryPipe, ptr %213, i32 0, i32 0
  %215 = getelementptr inbounds %struct.anon, ptr %214, i32 0, i32 1
  %216 = load i32, ptr %215, align 4, !tbaa !17
  %217 = call i64 @write(i32 noundef %216, ptr noundef %14, i64 noundef 1)
  store i32 11, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #5
  br label %218

218:                                              ; preds = %203, %147
  store i32 0, ptr %7, align 4
  br label %219

219:                                              ; preds = %218, %199, %157
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #5
  %220 = load i32, ptr %7, align 4
  switch i32 %220, label %315 [
    i32 0, label %221
  ]

221:                                              ; preds = %219
  br label %311

222:                                              ; preds = %136
  %223 = load ptr, ptr @stdout, align 8, !tbaa !5
  %224 = load i32, ptr %12, align 4, !tbaa !12
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds %struct.epoll_event, ptr %115, i64 %225
  %227 = getelementptr inbounds %struct.epoll_event, ptr %226, i32 0, i32 1
  %228 = load i32, ptr %227, align 4, !tbaa !17
  %229 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %223, ptr noundef @.str.32, i32 noundef %228) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #5
  %230 = load i32, ptr %12, align 4, !tbaa !12
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds %struct.epoll_event, ptr %115, i64 %231
  %233 = getelementptr inbounds %struct.epoll_event, ptr %232, i32 0, i32 1
  %234 = load i32, ptr %233, align 4, !tbaa !17
  %235 = getelementptr inbounds [16 x i8], ptr %15, i64 0, i64 0
  %236 = call i64 @read(i32 noundef %234, ptr noundef %235, i64 noundef 16)
  %237 = icmp slt i64 %236, 16
  br i1 %237, label %238, label %241

238:                                              ; preds = %222
  %239 = load ptr, ptr @stderr, align 8, !tbaa !5
  %240 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %239, ptr noundef @.str.33) #5
  store i32 10, ptr %7, align 4
  br label %308

241:                                              ; preds = %222
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %242 = getelementptr inbounds [16 x i8], ptr %15, i64 0, i64 0
  %243 = load i64, ptr %242, align 16, !tbaa !18
  store i64 %243, ptr %16, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %244 = getelementptr inbounds [16 x i8], ptr %15, i64 0, i64 0
  %245 = getelementptr inbounds i8, ptr %244, i64 8
  %246 = load i64, ptr %245, align 8, !tbaa !18
  store i64 %246, ptr %17, align 8, !tbaa !18
  %247 = load i64, ptr %16, align 8, !tbaa !18
  switch i64 %247, label %285 [
    i64 0, label %248
    i64 1, label %259
  ]

248:                                              ; preds = %241
  %249 = load ptr, ptr @stdout, align 8, !tbaa !5
  %250 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %249, ptr noundef @.str.34, ptr noundef null) #5
  %251 = load i32, ptr %4, align 4, !tbaa !12
  %252 = load i32, ptr %12, align 4, !tbaa !12
  %253 = sext i32 %252 to i64
  %254 = getelementptr inbounds %struct.epoll_event, ptr %115, i64 %253
  %255 = getelementptr inbounds %struct.epoll_event, ptr %254, i32 0, i32 1
  %256 = load i32, ptr %255, align 4, !tbaa !17
  %257 = call i32 @epoll_ctl(i32 noundef %251, i32 noundef 2, i32 noundef %256, ptr noundef %5) #5
  call void @merry_requestHdlr_panic(i64 noundef 12, i64 noundef 0)
  %258 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 5), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %258)
  store i32 2, ptr %7, align 4
  br label %307

259:                                              ; preds = %241
  %260 = load ptr, ptr @stdout, align 8, !tbaa !5
  %261 = load i32, ptr %12, align 4, !tbaa !12
  %262 = sext i32 %261 to i64
  %263 = getelementptr inbounds %struct.epoll_event, ptr %115, i64 %262
  %264 = getelementptr inbounds %struct.epoll_event, ptr %263, i32 0, i32 1
  %265 = load i32, ptr %264, align 4, !tbaa !17
  %266 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %260, ptr noundef @.str.35, i32 noundef %265) #5
  %267 = load i32, ptr %4, align 4, !tbaa !12
  %268 = load i32, ptr %12, align 4, !tbaa !12
  %269 = sext i32 %268 to i64
  %270 = getelementptr inbounds %struct.epoll_event, ptr %115, i64 %269
  %271 = getelementptr inbounds %struct.epoll_event, ptr %270, i32 0, i32 1
  %272 = load i32, ptr %271, align 4, !tbaa !17
  %273 = call i32 @epoll_ctl(i32 noundef %267, i32 noundef 2, i32 noundef %272, ptr noundef %5) #5
  %274 = load i64, ptr %17, align 8, !tbaa !18
  %275 = load i64, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 1), align 8, !tbaa !19
  %276 = icmp uge i64 %274, %275
  br i1 %276, label %277, label %281

277:                                              ; preds = %259
  %278 = load ptr, ptr @stderr, align 8, !tbaa !5
  %279 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %278, ptr noundef @.str.36) #5
  call void @merry_requestHdlr_panic(i64 noundef 12, i64 noundef 0)
  %280 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 5), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %280)
  store i32 2, ptr %7, align 4
  br label %307

281:                                              ; preds = %259
  %282 = load ptr, ptr @subsys, align 8, !tbaa !20
  %283 = load i64, ptr %17, align 8, !tbaa !18
  %284 = getelementptr inbounds %struct.MerrySubChannel, ptr %282, i64 %283
  call void @merry_inactivate_channel(ptr noundef %284)
  br label %306

285:                                              ; preds = %241
  %286 = load ptr, ptr @stdout, align 8, !tbaa !5
  %287 = load i64, ptr %16, align 8, !tbaa !18
  %288 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %286, ptr noundef @.str.37, i64 noundef %287) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %289 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 4), align 8, !tbaa !28
  %290 = load i64, ptr %16, align 8, !tbaa !18
  %291 = call ptr @merry_query_tasks(ptr noundef %289, i64 noundef %290)
  store ptr %291, ptr %18, align 8, !tbaa !5
  %292 = icmp ne ptr %291, null
  br i1 %292, label %293, label %305

293:                                              ; preds = %285
  %294 = load i64, ptr %17, align 8, !tbaa !18
  %295 = load ptr, ptr %18, align 8, !tbaa !5
  %296 = getelementptr inbounds %struct.MerryTask, ptr %295, i32 0, i32 2
  %297 = load ptr, ptr %296, align 8, !tbaa !29
  store i64 %294, ptr %297, align 8, !tbaa !18
  %298 = load ptr, ptr %18, align 8, !tbaa !5
  %299 = getelementptr inbounds %struct.MerryTask, ptr %298, i32 0, i32 0
  %300 = load ptr, ptr %299, align 8, !tbaa !31
  call void @merry_cond_signal(ptr noundef %300)
  %301 = load ptr, ptr @stdout, align 8, !tbaa !5
  %302 = load i64, ptr %16, align 8, !tbaa !18
  %303 = load i64, ptr %17, align 8, !tbaa !18
  %304 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %301, ptr noundef @.str.38, i64 noundef %302, i64 noundef %303) #5
  br label %305

305:                                              ; preds = %293, %285
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  br label %306

306:                                              ; preds = %305, %281
  store i32 0, ptr %7, align 4
  br label %307

307:                                              ; preds = %306, %277, %248
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %308

308:                                              ; preds = %307, %238
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #5
  %309 = load i32, ptr %7, align 4
  switch i32 %309, label %315 [
    i32 0, label %310
    i32 10, label %312
  ]

310:                                              ; preds = %308
  br label %311

311:                                              ; preds = %310, %221
  br label %312

312:                                              ; preds = %311, %308
  %313 = load i32, ptr %12, align 4, !tbaa !12
  %314 = add nsw i32 %313, 1
  store i32 %314, ptr %12, align 4, !tbaa !12
  br label %131, !llvm.loop !32

315:                                              ; preds = %308, %219, %135
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %316 = load i32, ptr %7, align 4
  switch i32 %316, label %319 [
    i32 8, label %317
  ]

317:                                              ; preds = %315
  %318 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 5), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %318)
  store i32 0, ptr %7, align 4
  br label %319

319:                                              ; preds = %317, %315, %123
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  %320 = load ptr, ptr %9, align 8
  call void @llvm.stackrestore.p0(ptr %320)
  %321 = load i32, ptr %7, align 4
  switch i32 %321, label %340 [
    i32 0, label %322
    i32 7, label %323
    i32 2, label %324
  ]

322:                                              ; preds = %319
  br label %107, !llvm.loop !33

323:                                              ; preds = %319, %107
  br label %324

324:                                              ; preds = %323, %319, %103, %46, %26
  %325 = load ptr, ptr @stdout, align 8, !tbaa !5
  %326 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %325, ptr noundef @.str.39, ptr noundef null) #5
  br label %327

327:                                              ; preds = %332, %324
  %328 = load ptr, ptr getelementptr inbounds (%struct.MerrySubSys, ptr @subsys, i32 0, i32 4), align 8, !tbaa !28
  %329 = call zeroext i8 @merry_pop_task(ptr noundef %328, ptr noundef %19)
  %330 = zext i8 %329 to i32
  %331 = icmp ne i32 %330, 0
  br i1 %331, label %332, label %337

332:                                              ; preds = %327
  %333 = getelementptr inbounds %struct.MerryTask, ptr %19, i32 0, i32 0
  %334 = load ptr, ptr %333, align 8, !tbaa !31
  call void @merry_cond_signal(ptr noundef %334)
  %335 = load ptr, ptr @stdout, align 8, !tbaa !5
  %336 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %335, ptr noundef @.str.40, ptr noundef null) #5
  br label %327, !llvm.loop !34

337:                                              ; preds = %327
  %338 = load ptr, ptr @stdout, align 8, !tbaa !5
  %339 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %338, ptr noundef @.str.41, ptr noundef null) #5
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %340

340:                                              ; preds = %337, %319, %103
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %341 = load ptr, ptr %2, align 8
  ret ptr %341
}

; Function Attrs: nounwind
declare i32 @epoll_create1(i32 noundef) #0

declare void @merry_requestHdlr_panic(i64 noundef, i64 noundef) #2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

declare i32 @epoll_wait(i32 noundef, ptr noundef, i32 noundef, i32 noundef) #2

declare i64 @read(i32 noundef, ptr noundef, i64 noundef) #2

declare void @merry_os_subsys_stopped(...) #2

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #2

declare void @merry_inactivate_channel(ptr noundef) #2

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

declare void @merry_cond_signal(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

declare zeroext i8 @merry_pop_task(ptr noundef, ptr noundef) #2

attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { nocallback nofree nosync nounwind willreturn }
attributes #5 = { 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 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 0}
!15 = !{!"epoll_event", !13, i64 0, !7, i64 4}
!16 = !{!10, !6, i64 56}
!17 = !{!7, !7, i64 0}
!18 = !{!11, !11, i64 0}
!19 = !{!10, !11, i64 8}
!20 = !{!10, !6, i64 0}
!21 = !{!22, !7, i64 16}
!22 = !{!"MerrySubChannel", !6, i64 0, !6, i64 8, !7, i64 16}
!23 = !{!22, !6, i64 8}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!10, !7, i64 48}
!27 = !{!22, !6, i64 0}
!28 = !{!10, !6, i64 32}
!29 = !{!30, !6, i64 16}
!30 = !{!"MerryTask", !6, i64 0, !11, i64 8, !6, i64 16}
!31 = !{!30, !6, i64 0}
!32 = distinct !{!32, !25}
!33 = distinct !{!33, !25}
!34 = distinct !{!34, !25}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.MerrySubSys = type { ptr, i64, i64, i64, ptr, ptr, i8, ptr }
%struct.epoll_event = type <{ i32, %union.epoll_data }>
%union.epoll_data = type { ptr }
%struct.MerryTask = type { ptr, i64, 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.18 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [47 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

declare void @merry_mutex_lock(ptr noundef) local_unnamed_addr #2

declare void @merry_mutex_unlock(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @merry_subsys_close_all() local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @merry_subsys_main(ptr nocapture noundef readnone %0) local_unnamed_addr #3 {
  %2 = alloca %struct.epoll_event, align 4
  %3 = alloca %struct.epoll_event, align 4
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  %6 = alloca [16 x i8], align 16
  %7 = alloca %struct.MerryTask, align 8
  %8 = load ptr, ptr @stdout, align 8, !tbaa !5
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef nonnull @.str.18, ptr noundef null) #7
  %10 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 40), align 8, !tbaa !9
  tail call void @merry_mutex_lock(ptr noundef %10) #7
  %11 = tail call i32 @epoll_create1(i32 noundef 0) #7
  %12 = icmp eq i32 %11, -1
  br i1 %12, label %13, label %17

13:                                               ; preds = %1
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.19) #8
  tail call void @merry_requestHdlr_panic(i64 noundef 11, i64 noundef 0) #7
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 40), align 8, !tbaa !9
  tail call void @merry_mutex_unlock(ptr noundef %16) #7
  br label %.loopexit

17:                                               ; preds = %1
  %18 = load ptr, ptr @stdout, align 8, !tbaa !5
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.20, ptr noundef null) #7
  store i32 1, ptr %2, align 4, !tbaa !12
  %20 = getelementptr inbounds i8, ptr %2, i64 4
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 56), align 8, !tbaa !15
  %22 = load i32, ptr %21, align 4, !tbaa !16
  store i32 %22, ptr %20, align 4, !tbaa !16
  %23 = load i32, ptr %21, align 4, !tbaa !16
  %24 = call i32 @epoll_ctl(i32 noundef %11, i32 noundef 1, i32 noundef %23, ptr noundef nonnull %2) #7
  %25 = icmp eq i32 %24, -1
  br i1 %25, label %26, label %30

26:                                               ; preds = %17
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.21) #8
  call void @merry_requestHdlr_panic(i64 noundef 11, i64 noundef 0) #7
  %29 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 40), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %29) #7
  br label %.loopexit

30:                                               ; preds = %17
  %31 = load ptr, ptr @stdout, align 8, !tbaa !5
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef nonnull @.str.22, ptr noundef null) #7
  %33 = load i64, ptr getelementptr inbounds (i8, ptr @subsys, i64 8), align 8, !tbaa !17
  %.not92 = icmp eq i64 %33, 0
  br i1 %.not92, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %30
  %34 = getelementptr inbounds i8, ptr %3, i64 4
  %.pre104 = load ptr, ptr @subsys, align 8, !tbaa !18
  br label %35

35:                                               ; preds = %.lr.ph, %50
  %36 = phi i64 [ %33, %.lr.ph ], [ %51, %50 ]
  %37 = phi ptr [ %.pre104, %.lr.ph ], [ %52, %50 ]
  %.080 = phi i64 [ 0, %.lr.ph ], [ %53, %50 ]
  %38 = getelementptr inbounds %struct.MerrySubChannel, ptr %37, i64 %.080
  %39 = getelementptr inbounds i8, ptr %38, i64 16
  %40 = load i8, ptr %39, align 8, !tbaa !19
  %.not = icmp eq i8 %40, 0
  br i1 %.not, label %50, label %41

41:                                               ; preds = %35
  %42 = getelementptr inbounds i8, ptr %38, i64 8
  %43 = load ptr, ptr %42, align 8, !tbaa !21
  %.not50 = icmp eq ptr %43, null
  br i1 %.not50, label %50, label %44

44:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #7
  store i32 1, ptr %3, align 4, !tbaa !12
  %45 = load i32, ptr %43, align 4, !tbaa !16
  store i32 %45, ptr %34, align 4, !tbaa !16
  %46 = call i32 @epoll_ctl(i32 noundef %11, i32 noundef 1, i32 noundef %45, ptr noundef nonnull %3) #7
  %.not51 = icmp eq i32 %46, -1
  br i1 %.not51, label %55, label %47

47:                                               ; preds = %44
  %48 = load ptr, ptr @stdout, align 8, !tbaa !5
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef nonnull @.str.24, i64 noundef %.080) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #7
  %.pre = load ptr, ptr @subsys, align 8, !tbaa !18
  %.pre105 = load i64, ptr getelementptr inbounds (i8, ptr @subsys, i64 8), align 8, !tbaa !17
  br label %50

50:                                               ; preds = %47, %35, %41
  %51 = phi i64 [ %.pre105, %47 ], [ %36, %35 ], [ %36, %41 ]
  %52 = phi ptr [ %.pre, %47 ], [ %37, %35 ], [ %37, %41 ]
  %53 = add nuw i64 %.080, 1
  %54 = icmp ult i64 %53, %51
  br i1 %54, label %35, label %._crit_edge, !llvm.loop !22

55:                                               ; preds = %44
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef nonnull @.str.23) #8
  call void @merry_requestHdlr_panic(i64 noundef 11, i64 noundef 0) #7
  %58 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 40), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %58) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #7
  br label %.loopexit

._crit_edge:                                      ; preds = %50, %30
  %59 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 40), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %59) #7
  %60 = load i8, ptr getelementptr inbounds (i8, ptr @subsys, i64 48), align 8, !tbaa !24
  %.not5285 = icmp eq i8 %60, 0
  br i1 %.not5285, label %.lr.ph87, label %.loopexit

.lr.ph87:                                         ; preds = %._crit_edge
  %61 = getelementptr inbounds i8, ptr %6, i64 8
  br label %62

62:                                               ; preds = %.lr.ph87, %._crit_edge84
  %63 = load i64, ptr getelementptr inbounds (i8, ptr @subsys, i64 8), align 8, !tbaa !17
  %64 = add i64 %63, 1
  %65 = call ptr @llvm.stacksave.p0()
  %66 = alloca %struct.epoll_event, i64 %64, align 16
  %67 = load i64, ptr getelementptr inbounds (i8, ptr @subsys, i64 8), align 8, !tbaa !17
  %68 = trunc i64 %67 to i32
  %69 = add i32 %68, 1
  %70 = call i32 @epoll_wait(i32 noundef %11, ptr noundef nonnull %66, i32 noundef %69, i32 noundef -1) #7
  %71 = icmp eq i32 %70, -1
  br i1 %71, label %72, label %75

72:                                               ; preds = %62
  %73 = load ptr, ptr @stderr, align 8, !tbaa !5
  %74 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef nonnull @.str.25) #8
  br label %.thread70

75:                                               ; preds = %62
  %76 = load ptr, ptr @stdout, align 8, !tbaa !5
  %77 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %76, ptr noundef nonnull @.str.26, i32 noundef %70) #7
  %78 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 40), align 8, !tbaa !9
  call void @merry_mutex_lock(ptr noundef %78) #7
  %79 = icmp sgt i32 %70, 0
  br i1 %79, label %.lr.ph83.preheader, label %._crit_edge84

.lr.ph83.preheader:                               ; preds = %75
  %wide.trip.count = zext nneg i32 %70 to i64
  br label %.lr.ph83

.lr.ph83:                                         ; preds = %.lr.ph83.preheader, %172
  %indvars.iv = phi i64 [ 0, %.lr.ph83.preheader ], [ %indvars.iv.next, %172 ]
  %80 = getelementptr inbounds %struct.epoll_event, ptr %66, i64 %indvars.iv, i32 1
  %81 = load i32, ptr %80, align 4, !tbaa !16
  %82 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 56), align 8, !tbaa !15
  %83 = load i32, ptr %82, align 4, !tbaa !16
  %84 = icmp eq i32 %81, %83
  %85 = load ptr, ptr @stdout, align 8, !tbaa !5
  br i1 %84, label %86, label %132

86:                                               ; preds = %.lr.ph83
  %87 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %85, ptr noundef nonnull @.str.27, ptr noundef null) #7
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #7
  %88 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 56), align 8, !tbaa !15
  %89 = load i32, ptr %88, align 4, !tbaa !16
  %90 = call i64 @read(i32 noundef %89, ptr noundef nonnull %4, i64 noundef 1) #7
  %91 = load i8, ptr %4, align 1, !tbaa !16
  switch i8 %91, label %.thread59 [
    i8 0, label %92
    i8 2, label %95
  ]

92:                                               ; preds = %86
  %93 = load ptr, ptr @stdout, align 8, !tbaa !5
  %94 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %93, ptr noundef nonnull @.str.28, ptr noundef null) #7
  call void @merry_subsys_close_all()
  call void (...) @merry_os_subsys_stopped() #7
  store i8 1, ptr getelementptr inbounds (i8, ptr @subsys, i64 48), align 8, !tbaa !24
  br label %131

95:                                               ; preds = %86
  %96 = load ptr, ptr @stdout, align 8, !tbaa !5
  %97 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %96, ptr noundef nonnull @.str.29, ptr noundef null) #7
  %98 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 56), align 8, !tbaa !15
  %99 = load i32, ptr %98, align 4, !tbaa !16
  %100 = call i64 @read(i32 noundef %99, ptr noundef nonnull %4, i64 noundef 1) #7
  %101 = load ptr, ptr @subsys, align 8, !tbaa !18
  %102 = load i8, ptr %4, align 1, !tbaa !16
  %103 = zext i8 %102 to i64
  %104 = getelementptr inbounds %struct.MerrySubChannel, ptr %101, i64 %103, i32 1
  %105 = load ptr, ptr %104, align 8, !tbaa !21
  %106 = load i32, ptr %105, align 4, !tbaa !16
  store i32 %106, ptr %20, align 4, !tbaa !16
  %107 = getelementptr inbounds %struct.MerrySubChannel, ptr %101, i64 %103
  %108 = getelementptr inbounds i8, ptr %107, i64 16
  %109 = load i8, ptr %108, align 8, !tbaa !19
  %110 = icmp eq i8 %109, 1
  br i1 %110, label %111, label %121

111:                                              ; preds = %95
  %112 = getelementptr inbounds i8, ptr %107, i64 8
  %113 = load ptr, ptr %112, align 8, !tbaa !21
  %114 = load i32, ptr %113, align 4, !tbaa !16
  %115 = call i32 @epoll_ctl(i32 noundef %11, i32 noundef 1, i32 noundef %114, ptr noundef nonnull %2) #7
  %116 = icmp eq i32 %115, -1
  br i1 %116, label %117, label %121

117:                                              ; preds = %111
  %118 = load ptr, ptr @stderr, align 8, !tbaa !5
  %119 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %118, ptr noundef nonnull @.str.30) #8
  %120 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 40), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %120) #7
  br label %131

121:                                              ; preds = %111, %95
  %122 = load ptr, ptr @stdout, align 8, !tbaa !5
  %123 = zext i8 %102 to i32
  %124 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %122, ptr noundef nonnull @.str.31, i32 noundef %123) #7
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #7
  store i8 1, ptr %5, align 1, !tbaa !16
  %125 = load ptr, ptr @subsys, align 8, !tbaa !18
  %126 = getelementptr inbounds %struct.MerrySubChannel, ptr %125, i64 %103
  %127 = load ptr, ptr %126, align 8, !tbaa !25
  %128 = getelementptr inbounds i8, ptr %127, i64 4
  %129 = load i32, ptr %128, align 4, !tbaa !16
  %130 = call i64 @write(i32 noundef %129, ptr noundef nonnull %5, i64 noundef 1) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #7
  br label %.thread59

.thread59:                                        ; preds = %121, %86
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #7
  br label %172

131:                                              ; preds = %117, %92
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #7
  br label %.thread70

132:                                              ; preds = %.lr.ph83
  %133 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %85, ptr noundef nonnull @.str.32, i32 noundef %81) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #7
  %134 = load i32, ptr %80, align 4, !tbaa !16
  %135 = call i64 @read(i32 noundef %134, ptr noundef nonnull %6, i64 noundef 16) #7
  %136 = icmp slt i64 %135, 16
  br i1 %136, label %137, label %140

137:                                              ; preds = %132
  %138 = load ptr, ptr @stderr, align 8, !tbaa !5
  %139 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %138, ptr noundef nonnull @.str.33) #8
  br label %.thread63

140:                                              ; preds = %132
  %141 = load i64, ptr %6, align 16, !tbaa !26
  %142 = load i64, ptr %61, align 8, !tbaa !26
  %143 = load ptr, ptr @stdout, align 8, !tbaa !5
  switch i64 %141, label %160 [
    i64 0, label %144
    i64 1, label %148
  ]

144:                                              ; preds = %140
  %145 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %143, ptr noundef nonnull @.str.34, ptr noundef null) #7
  %146 = load i32, ptr %80, align 4, !tbaa !16
  %147 = call i32 @epoll_ctl(i32 noundef %11, i32 noundef 2, i32 noundef %146, ptr noundef nonnull %2) #7
  br label %170

148:                                              ; preds = %140
  %149 = load i32, ptr %80, align 4, !tbaa !16
  %150 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %143, ptr noundef nonnull @.str.35, i32 noundef %149) #7
  %151 = load i32, ptr %80, align 4, !tbaa !16
  %152 = call i32 @epoll_ctl(i32 noundef %11, i32 noundef 2, i32 noundef %151, ptr noundef nonnull %2) #7
  %153 = load i64, ptr getelementptr inbounds (i8, ptr @subsys, i64 8), align 8, !tbaa !17
  %.not53 = icmp ult i64 %142, %153
  br i1 %.not53, label %157, label %154

154:                                              ; preds = %148
  %155 = load ptr, ptr @stderr, align 8, !tbaa !5
  %156 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %155, ptr noundef nonnull @.str.36) #8
  br label %170

157:                                              ; preds = %148
  %158 = load ptr, ptr @subsys, align 8, !tbaa !18
  %159 = getelementptr inbounds %struct.MerrySubChannel, ptr %158, i64 %142
  call void @merry_inactivate_channel(ptr noundef %159) #7
  br label %.thread63

160:                                              ; preds = %140
  %161 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %143, ptr noundef nonnull @.str.37, i64 noundef %141) #7
  %162 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 32), align 8, !tbaa !27
  %163 = call ptr @merry_query_tasks(ptr noundef %162, i64 noundef %141) #7
  %.not54 = icmp eq ptr %163, null
  br i1 %.not54, label %.thread63, label %164

164:                                              ; preds = %160
  %165 = getelementptr inbounds i8, ptr %163, i64 16
  %166 = load ptr, ptr %165, align 8, !tbaa !28
  store i64 %142, ptr %166, align 8, !tbaa !26
  %167 = load ptr, ptr %163, align 8, !tbaa !30
  call void @merry_cond_signal(ptr noundef %167) #7
  %168 = load ptr, ptr @stdout, align 8, !tbaa !5
  %169 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %168, ptr noundef nonnull @.str.38, i64 noundef %141, i64 noundef %142) #7
  br label %.thread63

.thread63:                                        ; preds = %137, %160, %164, %157
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #7
  br label %172

170:                                              ; preds = %144, %154
  call void @merry_requestHdlr_panic(i64 noundef 12, i64 noundef 0) #7
  %171 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 40), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %171) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #7
  br label %.thread70

172:                                              ; preds = %.thread63, %.thread59
  %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_edge84, label %.lr.ph83, !llvm.loop !31

.thread70:                                        ; preds = %72, %131, %170
  call void @llvm.stackrestore.p0(ptr %65)
  br label %.loopexit

._crit_edge84:                                    ; preds = %172, %75
  %173 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 40), align 8, !tbaa !9
  call void @merry_mutex_unlock(ptr noundef %173) #7
  call void @llvm.stackrestore.p0(ptr %65)
  %174 = load i8, ptr getelementptr inbounds (i8, ptr @subsys, i64 48), align 8, !tbaa !24
  %.not52 = icmp eq i8 %174, 0
  br i1 %.not52, label %62, label %.loopexit

.loopexit:                                        ; preds = %._crit_edge84, %._crit_edge, %.thread70, %55, %26, %13
  %175 = load ptr, ptr @stdout, align 8, !tbaa !5
  %176 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %175, ptr noundef nonnull @.str.39, ptr noundef null) #7
  %177 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 32), align 8, !tbaa !27
  %178 = call zeroext i8 @merry_pop_task(ptr noundef %177, ptr noundef nonnull %7) #7
  %.not5588 = icmp eq i8 %178, 0
  br i1 %.not5588, label %._crit_edge91, label %.lr.ph90

.lr.ph90:                                         ; preds = %.loopexit, %.lr.ph90
  %179 = load ptr, ptr %7, align 8, !tbaa !30
  call void @merry_cond_signal(ptr noundef %179) #7
  %180 = load ptr, ptr @stdout, align 8, !tbaa !5
  %181 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %180, ptr noundef nonnull @.str.40, ptr noundef null) #7
  %182 = load ptr, ptr getelementptr inbounds (i8, ptr @subsys, i64 32), align 8, !tbaa !27
  %183 = call zeroext i8 @merry_pop_task(ptr noundef %182, ptr noundef nonnull %7) #7
  %.not55 = icmp eq i8 %183, 0
  br i1 %.not55, label %._crit_edge91, label %.lr.ph90, !llvm.loop !32

._crit_edge91:                                    ; preds = %.lr.ph90, %.loopexit
  %184 = load ptr, ptr @stdout, align 8, !tbaa !5
  %185 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %184, ptr noundef nonnull @.str.41, ptr noundef null) #7
  ret ptr null
}

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

declare void @merry_requestHdlr_panic(i64 noundef, i64 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #5

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

; Function Attrs: nofree
declare noundef i64 @read(i32 noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #6

declare void @merry_os_subsys_stopped(...) local_unnamed_addr #2

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #6

declare void @merry_inactivate_channel(ptr noundef) local_unnamed_addr #2

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

declare void @merry_cond_signal(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #5

declare zeroext i8 @merry_pop_task(ptr noundef, ptr noundef) local_unnamed_addr #2

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #6 = { nofree "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 }
attributes #8 = { 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 = !{!13, !14, i64 0}
!13 = !{!"epoll_event", !14, i64 0, !7, i64 4}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !6, i64 56}
!16 = !{!7, !7, i64 0}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !6, i64 0}
!19 = !{!20, !7, i64 16}
!20 = !{!"MerrySubChannel", !6, i64 0, !6, i64 8, !7, i64 16}
!21 = !{!20, !6, i64 8}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!10, !7, i64 48}
!25 = !{!20, !6, i64 0}
!26 = !{!11, !11, i64 0}
!27 = !{!10, !6, i64 32}
!28 = !{!29, !6, i64 16}
!29 = !{!"MerryTask", !6, i64 0, !11, i64 8, !6, i64 16}
!30 = !{!29, !6, i64 0}
!31 = distinct !{!31, !23}
!32 = distinct !{!32, !23}


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