; LLVM IR from Water-Melon/Melon :: src (mln_event)

; 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.mln_event_desc_s = type { ptr, ptr, ptr, ptr, i32, i32, %union.anon }
%union.anon = type { %struct.mln_event_fd_s }
%struct.mln_event_fd_s = type { i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64 }
%struct.mln_event_s = type { %union.pthread_mutex_t, %union.pthread_mutex_t, %union.pthread_mutex_t, ptr, ptr, i32, i32, %struct.fd_set, %struct.fd_set, %struct.fd_set, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.fd_set = type { [16 x i64] }
%struct.rbtree_s = type { ptr, ptr, ptr, ptr, ptr, %struct.mln_rbtree_node_s, ptr, ptr, ptr, ptr, ptr, i64, i8 }
%struct.mln_rbtree_node_s = type { ptr, ptr, ptr, ptr, ptr, ptr, i32 }

; 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
declare i32 @pthread_mutex_lock(ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @mln_event_rbtree_fd_cmp(ptr noundef nonnull, ptr noundef nonnull) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @mln_event_fd_set(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5) #3 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca %struct.mln_event_desc_s, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.mln_event_s, ptr %21, i32 0, i32 0
  %23 = call i32 @pthread_mutex_lock(ptr noundef %22) #5
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = icmp eq i32 %24, 128
  br i1 %25, label %26, label %32

26:                                               ; preds = %6
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = load i32, ptr %9, align 4, !tbaa !9
  call void @mln_event_fd_clr_set(ptr noundef %27, i32 noundef %28)
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.mln_event_s, ptr %29, i32 0, i32 0
  %31 = call i32 @pthread_mutex_unlock(ptr noundef %30) #5
  store i32 0, ptr %7, align 4
  br label %176

32:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 136, ptr %14) #5
  call void @llvm.memset.p0.i64(ptr align 8 %14, i8 0, i64 136, i1 false)
  %33 = getelementptr inbounds %struct.mln_event_desc_s, ptr %14, i32 0, i32 4
  store i32 0, ptr %33, align 8, !tbaa !11
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = getelementptr inbounds %struct.mln_event_desc_s, ptr %14, i32 0, i32 6
  %36 = getelementptr inbounds %struct.mln_event_fd_s, ptr %35, i32 0, i32 0
  store i32 %34, ptr %36, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.mln_event_s, ptr %37, i32 0, i32 10
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  store ptr %39, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %40 = load ptr, ptr %16, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.rbtree_s, ptr %40, i32 0, i32 6
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  store ptr %42, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  br label %43

43:                                               ; preds = %67, %32
  %44 = load ptr, ptr %17, align 8, !tbaa !5
  %45 = load ptr, ptr %16, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.rbtree_s, ptr %45, i32 0, i32 5
  %47 = icmp ne ptr %44, %46
  br i1 %47, label %48, label %54

48:                                               ; preds = %43
  %49 = load ptr, ptr %17, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !21
  %52 = call i32 @mln_event_rbtree_fd_cmp(ptr noundef %14, ptr noundef %51)
  store i32 %52, ptr %18, align 4, !tbaa !9
  %53 = icmp ne i32 %52, 0
  br label %54

54:                                               ; preds = %48, %43
  %55 = phi i1 [ false, %43 ], [ %53, %48 ]
  br i1 %55, label %56, label %68

56:                                               ; preds = %54
  %57 = load i32, ptr %18, align 4, !tbaa !9
  %58 = icmp slt i32 %57, 0
  br i1 %58, label %59, label %63

59:                                               ; preds = %56
  %60 = load ptr, ptr %17, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %60, i32 0, i32 4
  %62 = load ptr, ptr %61, align 8, !tbaa !22
  store ptr %62, ptr %17, align 8, !tbaa !5
  br label %67

63:                                               ; preds = %56
  %64 = load ptr, ptr %17, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %64, i32 0, i32 5
  %66 = load ptr, ptr %65, align 8, !tbaa !23
  store ptr %66, ptr %17, align 8, !tbaa !5
  br label %67

67:                                               ; preds = %63, %59
  br label %43, !llvm.loop !24

68:                                               ; preds = %54
  %69 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %69, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %70 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %70, ptr %15, align 8, !tbaa !5
  %71 = load ptr, ptr %15, align 8, !tbaa !5
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.mln_event_s, ptr %72, i32 0, i32 10
  %74 = load ptr, ptr %73, align 8, !tbaa !14
  %75 = getelementptr inbounds %struct.rbtree_s, ptr %74, i32 0, i32 5
  %76 = icmp eq ptr %71, %75
  br i1 %76, label %150, label %77

77:                                               ; preds = %68
  %78 = load i32, ptr %10, align 4, !tbaa !9
  %79 = and i32 %78, 64
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %110

81:                                               ; preds = %77
  %82 = load i32, ptr %10, align 4, !tbaa !9
  %83 = and i32 %82, 16
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %87

85:                                               ; preds = %81
  %86 = load i32, ptr %9, align 4, !tbaa !9
  call void @mln_event_fd_nonblock_set(i32 noundef %86)
  br label %87

87:                                               ; preds = %85, %81
  %88 = load i32, ptr %10, align 4, !tbaa !9
  %89 = and i32 %88, 32
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %93

91:                                               ; preds = %87
  %92 = load i32, ptr %9, align 4, !tbaa !9
  call void @mln_event_fd_block_set(i32 noundef %92)
  br label %93

93:                                               ; preds = %91, %87
  %94 = load ptr, ptr %8, align 8, !tbaa !5
  %95 = load ptr, ptr %15, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %95, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8, !tbaa !21
  %98 = load i32, ptr %9, align 4, !tbaa !9
  %99 = load i32, ptr %10, align 4, !tbaa !9
  %100 = load i32, ptr %11, align 4, !tbaa !9
  %101 = load ptr, ptr %12, align 8, !tbaa !5
  %102 = load ptr, ptr %13, align 8, !tbaa !5
  %103 = call i32 @mln_event_fd_append_set(ptr noundef %94, ptr noundef %97, i32 noundef %98, i32 noundef %99, i32 noundef %100, ptr noundef %101, ptr noundef %102, i32 noundef 1)
  %104 = icmp slt i32 %103, 0
  br i1 %104, label %105, label %109

105:                                              ; preds = %93
  %106 = load ptr, ptr %8, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.mln_event_s, ptr %106, i32 0, i32 0
  %108 = call i32 @pthread_mutex_unlock(ptr noundef %107) #5
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %175

109:                                              ; preds = %93
  br label %146

110:                                              ; preds = %77
  %111 = load i32, ptr %10, align 4, !tbaa !9
  %112 = and i32 %111, 16
  %113 = icmp ne i32 %112, 0
  br i1 %113, label %114, label %116

114:                                              ; preds = %110
  %115 = load i32, ptr %9, align 4, !tbaa !9
  call void @mln_event_fd_nonblock_set(i32 noundef %115)
  br label %118

116:                                              ; preds = %110
  %117 = load i32, ptr %9, align 4, !tbaa !9
  call void @mln_event_fd_block_set(i32 noundef %117)
  br label %118

118:                                              ; preds = %116, %114
  %119 = load ptr, ptr %8, align 8, !tbaa !5
  %120 = load ptr, ptr %15, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %120, i32 0, i32 0
  %122 = load ptr, ptr %121, align 8, !tbaa !21
  %123 = load i32, ptr %9, align 4, !tbaa !9
  %124 = load i32, ptr %10, align 4, !tbaa !9
  %125 = load i32, ptr %11, align 4, !tbaa !9
  %126 = load ptr, ptr %12, align 8, !tbaa !5
  %127 = load ptr, ptr %13, align 8, !tbaa !5
  %128 = load ptr, ptr %15, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %128, i32 0, i32 0
  %130 = load ptr, ptr %129, align 8, !tbaa !21
  %131 = getelementptr inbounds %struct.mln_event_desc_s, ptr %130, i32 0, i32 6
  %132 = getelementptr inbounds %struct.mln_event_fd_s, ptr %131, i32 0, i32 2
  %133 = load i32, ptr %132, align 8
  %134 = lshr i32 %133, 1
  %135 = and i32 %134, 1
  %136 = icmp ne i32 %135, 0
  %137 = zext i1 %136 to i64
  %138 = select i1 %136, i32 0, i32 1
  %139 = call i32 @mln_event_fd_normal_set(ptr noundef %119, ptr noundef %122, i32 noundef %123, i32 noundef %124, i32 noundef %125, ptr noundef %126, ptr noundef %127, i32 noundef %138)
  %140 = icmp slt i32 %139, 0
  br i1 %140, label %141, label %145

141:                                              ; preds = %118
  %142 = load ptr, ptr %8, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.mln_event_s, ptr %142, i32 0, i32 0
  %144 = call i32 @pthread_mutex_unlock(ptr noundef %143) #5
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %175

145:                                              ; preds = %118
  br label %146

146:                                              ; preds = %145, %109
  %147 = load ptr, ptr %8, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.mln_event_s, ptr %147, i32 0, i32 0
  %149 = call i32 @pthread_mutex_unlock(ptr noundef %148) #5
  store i32 0, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %175

150:                                              ; preds = %68
  %151 = load i32, ptr %10, align 4, !tbaa !9
  %152 = and i32 %151, 16
  %153 = icmp ne i32 %152, 0
  br i1 %153, label %154, label %156

154:                                              ; preds = %150
  %155 = load i32, ptr %9, align 4, !tbaa !9
  call void @mln_event_fd_nonblock_set(i32 noundef %155)
  br label %158

156:                                              ; preds = %150
  %157 = load i32, ptr %9, align 4, !tbaa !9
  call void @mln_event_fd_block_set(i32 noundef %157)
  br label %158

158:                                              ; preds = %156, %154
  %159 = load ptr, ptr %8, align 8, !tbaa !5
  %160 = load i32, ptr %9, align 4, !tbaa !9
  %161 = load i32, ptr %10, align 4, !tbaa !9
  %162 = load i32, ptr %11, align 4, !tbaa !9
  %163 = load ptr, ptr %12, align 8, !tbaa !5
  %164 = load ptr, ptr %13, align 8, !tbaa !5
  %165 = call i32 @mln_event_fd_normal_set(ptr noundef %159, ptr noundef null, i32 noundef %160, i32 noundef %161, i32 noundef %162, ptr noundef %163, ptr noundef %164, i32 noundef 0)
  %166 = icmp slt i32 %165, 0
  br i1 %166, label %167, label %171

167:                                              ; preds = %158
  %168 = load ptr, ptr %8, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.mln_event_s, ptr %168, i32 0, i32 0
  %170 = call i32 @pthread_mutex_unlock(ptr noundef %169) #5
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %175

171:                                              ; preds = %158
  %172 = load ptr, ptr %8, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.mln_event_s, ptr %172, i32 0, i32 0
  %174 = call i32 @pthread_mutex_unlock(ptr noundef %173) #5
  store i32 0, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %175

175:                                              ; preds = %171, %167, %146, %141, %105
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 136, ptr %14) #5
  br label %176

176:                                              ; preds = %175, %26
  %177 = load i32, ptr %7, align 4
  ret i32 %177
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mln_event_fd_clr_set(ptr noundef nonnull, i32 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mln_event_fd_nonblock_set(i32 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mln_event_fd_block_set(i32 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @mln_event_fd_append_set(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @mln_event_fd_normal_set(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"mln_event_desc_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !7, i64 40}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !6, i64 528}
!15 = !{!"mln_event_s", !7, i64 0, !7, i64 40, !7, i64 80, !6, i64 120, !6, i64 128, !10, i64 136, !10, i64 136, !10, i64 140, !16, i64 144, !16, i64 272, !16, i64 400, !6, i64 528, !6, i64 536, !6, i64 544, !6, i64 552, !6, i64 560, !6, i64 568, !6, i64 576}
!16 = !{!"", !7, i64 0}
!17 = !{!18, !6, i64 96}
!18 = !{!"rbtree_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !19, i64 40, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !20, i64 136, !10, i64 144}
!19 = !{!"mln_rbtree_node_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 48}
!20 = !{!"long", !7, i64 0}
!21 = !{!19, !6, i64 0}
!22 = !{!19, !6, i64 32}
!23 = !{!19, !6, i64 40}
!24 = distinct !{!24, !25}
!25 = !{!"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.mln_event_desc_s = type { ptr, ptr, ptr, ptr, i32, i32, %union.anon }
%union.anon = type { %struct.mln_event_fd_s }
%struct.mln_event_fd_s = type { i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64 }

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @mln_event_rbtree_fd_cmp(ptr noundef nonnull, ptr noundef nonnull) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @mln_event_fd_set(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #3 {
  %7 = alloca %struct.mln_event_desc_s, align 8
  %8 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull %0) #5
  %9 = icmp eq i32 %2, 128
  br i1 %9, label %10, label %12

10:                                               ; preds = %6
  tail call void @mln_event_fd_clr_set(ptr noundef %0, i32 noundef %1)
  %11 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull %0) #5
  br label %62

12:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 136, ptr nonnull %7) #5
  %13 = getelementptr inbounds i8, ptr %7, i64 40
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(136) %7, i8 0, i64 136, i1 false)
  store i32 %1, ptr %13, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 528
  %15 = load ptr, ptr %14, align 8, !tbaa !8
  %16 = getelementptr inbounds i8, ptr %15, i64 96
  %17 = getelementptr inbounds i8, ptr %15, i64 40
  %.05566 = load ptr, ptr %16, align 8, !tbaa !13
  %.not67 = icmp eq ptr %.05566, %17
  br i1 %.not67, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %12, %20
  %.05568 = phi ptr [ %.055, %20 ], [ %.05566, %12 ]
  %18 = load ptr, ptr %.05568, align 8, !tbaa !14
  %19 = call i32 @mln_event_rbtree_fd_cmp(ptr noundef %7, ptr noundef %18)
  %.not59 = icmp eq i32 %19, 0
  br i1 %.not59, label %.critedge.loopexit, label %20

20:                                               ; preds = %.lr.ph
  %21 = icmp slt i32 %19, 0
  %.156.in.v = select i1 %21, i64 32, i64 40
  %.156.in = getelementptr inbounds i8, ptr %.05568, i64 %.156.in.v
  %.055 = load ptr, ptr %.156.in, align 8, !tbaa !13
  %.not = icmp eq ptr %.055, %17
  br i1 %.not, label %.critedge.loopexit, label %.lr.ph, !llvm.loop !16

.critedge.loopexit:                               ; preds = %20, %.lr.ph
  %.055.lcssa.ph = phi ptr [ %.05568, %.lr.ph ], [ %.055, %20 ]
  %.pre = load ptr, ptr %14, align 8, !tbaa !8
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %12
  %22 = phi ptr [ %15, %12 ], [ %.pre, %.critedge.loopexit ]
  %.055.lcssa = phi ptr [ %.05566, %12 ], [ %.055.lcssa.ph, %.critedge.loopexit ]
  %23 = getelementptr inbounds i8, ptr %22, i64 40
  %24 = icmp eq ptr %.055.lcssa, %23
  br i1 %24, label %54, label %25

25:                                               ; preds = %.critedge
  %26 = and i32 %2, 64
  %.not60 = icmp eq i32 %26, 0
  %27 = and i32 %2, 16
  %.not61 = icmp eq i32 %27, 0
  br i1 %.not60, label %39, label %28

28:                                               ; preds = %25
  br i1 %.not61, label %30, label %29

29:                                               ; preds = %28
  call void @mln_event_fd_nonblock_set(i32 noundef %1)
  br label %30

30:                                               ; preds = %29, %28
  %31 = and i32 %2, 32
  %.not64 = icmp eq i32 %31, 0
  br i1 %.not64, label %33, label %32

32:                                               ; preds = %30
  call void @mln_event_fd_block_set(i32 noundef %1)
  br label %33

33:                                               ; preds = %32, %30
  %34 = load ptr, ptr %.055.lcssa, align 8, !tbaa !14
  %35 = call i32 @mln_event_fd_append_set(ptr noundef nonnull %0, ptr noundef %34, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, i32 noundef 1)
  %36 = icmp slt i32 %35, 0
  br i1 %36, label %37, label %52

37:                                               ; preds = %33
  %38 = call i32 @pthread_mutex_unlock(ptr noundef nonnull %0) #5
  br label %61

39:                                               ; preds = %25
  br i1 %.not61, label %41, label %40

40:                                               ; preds = %39
  call void @mln_event_fd_nonblock_set(i32 noundef %1)
  br label %42

41:                                               ; preds = %39
  call void @mln_event_fd_block_set(i32 noundef %1)
  br label %42

42:                                               ; preds = %41, %40
  %43 = load ptr, ptr %.055.lcssa, align 8, !tbaa !14
  %44 = getelementptr inbounds i8, ptr %43, i64 48
  %45 = load i32, ptr %44, align 8
  %46 = lshr i32 %45, 1
  %.lobit = and i32 %46, 1
  %47 = xor i32 %.lobit, 1
  %48 = call i32 @mln_event_fd_normal_set(ptr noundef nonnull %0, ptr noundef %43, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, i32 noundef %47)
  %49 = icmp slt i32 %48, 0
  br i1 %49, label %50, label %52

50:                                               ; preds = %42
  %51 = call i32 @pthread_mutex_unlock(ptr noundef nonnull %0) #5
  br label %61

52:                                               ; preds = %42, %33
  %53 = call i32 @pthread_mutex_unlock(ptr noundef nonnull %0) #5
  br label %61

54:                                               ; preds = %.critedge
  %55 = and i32 %2, 16
  %.not65 = icmp eq i32 %55, 0
  br i1 %.not65, label %57, label %56

56:                                               ; preds = %54
  call void @mln_event_fd_nonblock_set(i32 noundef %1)
  br label %58

57:                                               ; preds = %54
  call void @mln_event_fd_block_set(i32 noundef %1)
  br label %58

58:                                               ; preds = %57, %56
  %59 = call i32 @mln_event_fd_normal_set(ptr noundef nonnull %0, ptr noundef null, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, i32 noundef 0)
  %60 = call i32 @pthread_mutex_unlock(ptr noundef nonnull %0) #5
  %.lobit71 = ashr i32 %59, 31
  br label %61

61:                                               ; preds = %58, %52, %50, %37
  %.0 = phi i32 [ -1, %37 ], [ 0, %52 ], [ -1, %50 ], [ %.lobit71, %58 ]
  call void @llvm.lifetime.end.p0(i64 136, ptr nonnull %7) #5
  br label %62

62:                                               ; preds = %61, %10
  %.1 = phi i32 [ 0, %10 ], [ %.0, %61 ]
  ret i32 %.1
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mln_event_fd_clr_set(ptr noundef nonnull, i32 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mln_event_fd_nonblock_set(i32 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mln_event_fd_block_set(i32 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @mln_event_fd_append_set(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @mln_event_fd_normal_set(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 528}
!9 = !{!"mln_event_s", !6, i64 0, !6, i64 40, !6, i64 80, !10, i64 120, !10, i64 128, !11, i64 136, !11, i64 136, !11, i64 140, !12, i64 144, !12, i64 272, !12, i64 400, !10, i64 528, !10, i64 536, !10, i64 544, !10, i64 552, !10, i64 560, !10, i64 568, !10, i64 576}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!"", !6, i64 0}
!13 = !{!10, !10, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"mln_rbtree_node_s", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !11, i64 48, !11, i64 48}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass