; LLVM IR from yinqiwen/ardb :: src/common/channel/channel.ll (ZN4ardb7Channel7OnWriteEv)

; 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"

%"class.ardb::Channel" = type { %"class.ardb::Runnable", %"struct.ardb::ChannelOptions", i8, i8, i32, %"class.ardb::ChannelPipeline", ptr, i32, i32, %"class.ardb::Buffer", %"class.ardb::Buffer", i32, ptr, ptr, ptr, ptr, i8, i8, i8, ptr, ptr, ptr }
%"class.ardb::Runnable" = type { ptr }
%"struct.ardb::ChannelOptions" = type <{ i32, i32, i8, [3 x i8], i32, i8, [3 x i8], i32, i32, i32, i8, i8, [2 x i8] }>
%"class.ardb::ChannelPipeline" = type { ptr, ptr, ptr, %"class.btree::btree_map" }
%"class.btree::btree_map" = type { %"class.btree::btree_map_container" }
%"class.btree::btree_map_container" = type { %"class.btree::btree_unique_container" }
%"class.btree::btree_unique_container" = type { %"class.btree::btree_container" }
%"class.btree::btree_container" = type { %"class.btree::btree" }
%"class.btree::btree" = type { %"struct.btree::btree<btree::btree_map_params<std::__cxx11::basic_string<char>, ardb::ChannelHandlerContext *, std::less<std::__cxx11::basic_string<char>>, std::allocator<std::pair<const std::__cxx11::basic_string<char>, ardb::ChannelHandlerContext *>>, 256>>::empty_base_handle" }
%"struct.btree::btree<btree::btree_map_params<std::__cxx11::basic_string<char>, ardb::ChannelHandlerContext *, std::less<std::__cxx11::basic_string<char>>, std::allocator<std::pair<const std::__cxx11::basic_string<char>, ardb::ChannelHandlerContext *>>, 256>>::empty_base_handle" = type { ptr }
%"class.ardb::Buffer" = type <{ ptr, i64, i64, i64, i8, [7 x i8] }>
%"struct.ardb::SendFileSetting" = type { i32, i64, i64, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [78 x i8], align 1
@__FUNCTION__._ZN4ardb7Channel7OnWriteEv = external hidden unnamed_addr constant [8 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [28 x i8], align 1

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

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

declare i32 @close(i32 noundef) #1

declare noundef ptr @_ZN4ardb10ArdbLogger13GetLogCheckerEv() #1

declare noundef ptr @_ZN4ardb10ArdbLogger13GetLogHandlerEv() #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33)) #2 align 2

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4ardb7Channel13EnableWritingEv(ptr noundef nonnull align 8 dereferenceable(256)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4ardb7Channel14DisableWritingEv(ptr noundef nonnull align 8 dereferenceable(256)) #4 align 2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #5

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb7Channel7OnWriteEv(ptr noundef nonnull align 8 dereferenceable(256) %0) unnamed_addr #4 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds ptr, ptr %11, i64 11
  %13 = load ptr, ptr %12, align 8
  %14 = call noundef zeroext i1 %13(ptr noundef nonnull align 8 dereferenceable(256) %10)
  br i1 %14, label %16, label %15

15:                                               ; preds = %1
  br label %152

16:                                               ; preds = %1
  %17 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 17
  %18 = load i8, ptr %17, align 1, !tbaa !11, !range !26, !noundef !27
  %19 = trunc i8 %18 to i1
  br i1 %19, label %20, label %22

20:                                               ; preds = %16
  %21 = call noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256) %10)
  br label %152

22:                                               ; preds = %16
  br label %23

23:                                               ; preds = %22
  %24 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 10
  %25 = call noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33) %24)
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  br label %152

27:                                               ; preds = %23
  %28 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %29 = load ptr, ptr %28, align 8, !tbaa !28
  %30 = icmp ne ptr null, %29
  br i1 %30, label %31, label %142

31:                                               ; preds = %27
  call void @_ZN4ardb7Channel13EnableWritingEv(ptr noundef nonnull align 8 dereferenceable(256) %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  %32 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %33 = load ptr, ptr %32, align 8, !tbaa !28
  %34 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %33, i32 0, i32 2
  %35 = load i64, ptr %34, align 8, !tbaa !29
  store i64 %35, ptr %3, align 8, !tbaa !31
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %36 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %37 = load ptr, ptr %36, align 8, !tbaa !28
  %38 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %37, i32 0, i32 1
  %39 = load i64, ptr %38, align 8, !tbaa !32
  store i64 %39, ptr %4, align 8, !tbaa !31
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %40 = load ptr, ptr %10, align 8, !tbaa !9
  %41 = getelementptr inbounds ptr, ptr %40, i64 15
  %42 = load ptr, ptr %41, align 8
  %43 = call noundef i32 %42(ptr noundef nonnull align 8 dereferenceable(256) %10)
  %44 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %45 = load ptr, ptr %44, align 8, !tbaa !28
  %46 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !33
  %48 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %49 = load ptr, ptr %48, align 8, !tbaa !28
  %50 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %49, i32 0, i32 1
  %51 = load i64, ptr %3, align 8, !tbaa !31
  %52 = call i64 @sendfile(i32 noundef %43, i32 noundef %47, ptr noundef %50, i64 noundef %51) #7
  %53 = trunc i64 %52 to i32
  store i32 %53, ptr %5, align 4, !tbaa !34
  %54 = load i32, ptr %5, align 4, !tbaa !34
  %55 = icmp slt i32 %54, 0
  br i1 %55, label %56, label %85

56:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %57 = call ptr @__errno_location() #8
  %58 = load i32, ptr %57, align 4, !tbaa !34
  store i32 %58, ptr %6, align 4, !tbaa !34
  %59 = load i32, ptr %6, align 4, !tbaa !34
  %60 = icmp ne i32 %59, 11
  br i1 %60, label %61, label %81

61:                                               ; preds = %56
  %62 = load i32, ptr %5, align 4, !tbaa !34
  %63 = icmp ne i32 %62, 4
  br i1 %63, label %64, label %81

64:                                               ; preds = %61
  br label %65

65:                                               ; preds = %64
  %66 = call noundef ptr @_ZN4ardb10ArdbLogger13GetLogCheckerEv()
  %67 = call noundef zeroext i1 %66(i32 noundef 5)
  br i1 %67, label %68, label %77

68:                                               ; preds = %65
  %69 = call noundef ptr @_ZN4ardb10ArdbLogger13GetLogHandlerEv()
  %70 = load i32, ptr %6, align 4, !tbaa !34
  %71 = call ptr @strerror(i32 noundef %70) #7
  %72 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %73 = load ptr, ptr %72, align 8, !tbaa !28
  %74 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %73, i32 0, i32 1
  %75 = load i64, ptr %74, align 8, !tbaa !32
  %76 = load i64, ptr %3, align 8, !tbaa !31
  call void (i32, ptr, ptr, i32, ptr, ...) %69(i32 noundef 5, ptr noundef @.str, ptr noundef @__FUNCTION__._ZN4ardb7Channel7OnWriteEv, i32 noundef 606, ptr noundef @.str.16, ptr noundef %71, i64 noundef %75, i64 noundef %76)
  br label %77

77:                                               ; preds = %68, %65
  br label %78

78:                                               ; preds = %77
  br label %79

79:                                               ; preds = %78
  %80 = call noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256) %10)
  store i32 1, ptr %7, align 4
  br label %82

81:                                               ; preds = %61, %56
  store i32 0, ptr %7, align 4
  br label %82

82:                                               ; preds = %81, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  %83 = load i32, ptr %7, align 4
  switch i32 %83, label %139 [
    i32 0, label %84
  ]

84:                                               ; preds = %82
  br label %85

85:                                               ; preds = %84, %31
  %86 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %87 = load ptr, ptr %86, align 8, !tbaa !28
  %88 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %87, i32 0, i32 1
  %89 = load i64, ptr %88, align 8, !tbaa !32
  %90 = load i64, ptr %4, align 8, !tbaa !31
  %91 = sub nsw i64 %89, %90
  %92 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %93 = load ptr, ptr %92, align 8, !tbaa !28
  %94 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %93, i32 0, i32 2
  %95 = load i64, ptr %94, align 8, !tbaa !29
  %96 = sub nsw i64 %95, %91
  store i64 %96, ptr %94, align 8, !tbaa !29
  %97 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %98 = load ptr, ptr %97, align 8, !tbaa !28
  %99 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %98, i32 0, i32 2
  %100 = load i64, ptr %99, align 8, !tbaa !29
  %101 = icmp eq i64 %100, 0
  br i1 %101, label %102, label %137

102:                                              ; preds = %85
  %103 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %104 = load ptr, ptr %103, align 8, !tbaa !28
  %105 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %104, i32 0, i32 0
  %106 = load i32, ptr %105, align 8, !tbaa !33
  %107 = call i32 @close(i32 noundef %106)
  %108 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %109 = load ptr, ptr %108, align 8, !tbaa !28
  %110 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %109, i32 0, i32 0
  store i32 -1, ptr %110, align 8, !tbaa !33
  %111 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %112 = load ptr, ptr %111, align 8, !tbaa !28
  %113 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %112, i32 0, i32 4
  %114 = load ptr, ptr %113, align 8, !tbaa !35
  %115 = icmp ne ptr null, %114
  br i1 %115, label %116, label %136

116:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %117 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %118 = load ptr, ptr %117, align 8, !tbaa !28
  %119 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %118, i32 0, i32 4
  %120 = load ptr, ptr %119, align 8, !tbaa !35
  store ptr %120, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %121 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %122 = load ptr, ptr %121, align 8, !tbaa !28
  %123 = getelementptr inbounds %"struct.ardb::SendFileSetting", ptr %122, i32 0, i32 3
  %124 = load ptr, ptr %123, align 8, !tbaa !36
  store ptr %124, ptr %9, align 8, !tbaa !5
  br label %125

125:                                              ; preds = %116
  %126 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  %127 = load ptr, ptr %126, align 8, !tbaa !28
  %128 = icmp eq ptr %127, null
  br i1 %128, label %130, label %129

129:                                              ; preds = %125
  call void @_ZdlPvm(ptr noundef %127, i64 noundef 48) #9
  br label %130

130:                                              ; preds = %129, %125
  %131 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 19
  store ptr null, ptr %131, align 8, !tbaa !28
  br label %132

132:                                              ; preds = %130
  br label %133

133:                                              ; preds = %132
  %134 = load ptr, ptr %8, align 8, !tbaa !5
  %135 = load ptr, ptr %9, align 8, !tbaa !5
  call void %134(ptr noundef %135)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %136

136:                                              ; preds = %133, %102
  br label %138

137:                                              ; preds = %85
  store i32 1, ptr %7, align 4
  br label %139

138:                                              ; preds = %136
  store i32 0, ptr %7, align 4
  br label %139

139:                                              ; preds = %138, %137, %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  %140 = load i32, ptr %7, align 4
  switch i32 %140, label %153 [
    i32 0, label %141
    i32 1, label %152
  ]

141:                                              ; preds = %139
  br label %142

142:                                              ; preds = %141, %27
  %143 = call noundef zeroext i1 @_ZN4ardb21fire_channel_writableEPNS_7ChannelE(ptr noundef %10)
  %144 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 10
  %145 = call noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33) %144)
  br i1 %145, label %152, label %146

146:                                              ; preds = %142
  %147 = getelementptr inbounds %"class.ardb::Channel", ptr %10, i32 0, i32 1
  %148 = getelementptr inbounds %"struct.ardb::ChannelOptions", ptr %147, i32 0, i32 10
  %149 = load i8, ptr %148, align 8, !tbaa !37, !range !26, !noundef !27
  %150 = trunc i8 %149 to i1
  br i1 %150, label %151, label %152

151:                                              ; preds = %146
  call void @_ZN4ardb7Channel14DisableWritingEv(ptr noundef nonnull align 8 dereferenceable(256) %10)
  br label %152

152:                                              ; preds = %151, %146, %142, %139, %26, %20, %15
  ret void

153:                                              ; preds = %139
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256)) #4 align 2

; Function Attrs: nounwind
declare i64 @sendfile(i32 noundef, i32 noundef, ptr noundef, i64 noundef) #3

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #6

declare noundef zeroext i1 @_ZN4ardb21fire_channel_writableEPNS_7ChannelE(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { inlinehint mustprogress 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 #3 = { 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 #4 = { mustprogress 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 willreturn memory(none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nobuiltin 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }
attributes #9 = { builtin 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !16, i64 225}
!12 = !{!"_ZTSN4ardb7ChannelE", !13, i64 0, !14, i64 8, !16, i64 44, !16, i64 45, !15, i64 48, !17, i64 56, !6, i64 88, !15, i64 96, !15, i64 100, !24, i64 104, !24, i64 144, !15, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !16, i64 224, !16, i64 225, !16, i64 226, !6, i64 232, !6, i64 240, !6, i64 248}
!13 = !{!"_ZTSN4ardb8RunnableE"}
!14 = !{!"_ZTSN4ardb14ChannelOptionsE", !15, i64 0, !15, i64 4, !16, i64 8, !15, i64 12, !16, i64 16, !15, i64 20, !15, i64 24, !15, i64 28, !16, i64 32, !16, i64 33}
!15 = !{!"int", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTSN4ardb15ChannelPipelineE", !6, i64 0, !6, i64 8, !6, i64 16, !18, i64 24}
!18 = !{!"_ZTSN5btree9btree_mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS6_ESaISt4pairIKS6_S9_EELi256EEE", !19, i64 0}
!19 = !{!"_ZTSN5btree19btree_map_containerINS_5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS8_ESaISt4pairIKS8_SB_EELi256EEEEEEE", !20, i64 0}
!20 = !{!"_ZTSN5btree22btree_unique_containerINS_5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS8_ESaISt4pairIKS8_SB_EELi256EEEEEEE", !21, i64 0}
!21 = !{!"_ZTSN5btree15btree_containerINS_5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS8_ESaISt4pairIKS8_SB_EELi256EEEEEEE", !22, i64 0}
!22 = !{!"_ZTSN5btree5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS7_ESaISt4pairIKS7_SA_EELi256EEEEE", !23, i64 0}
!23 = !{!"_ZTSN5btree5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS7_ESaISt4pairIKS7_SA_EELi256EEEE17empty_base_handleIS6_PNS_10btree_nodeISH_EEEE", !6, i64 0}
!24 = !{!"_ZTSN4ardb6BufferE", !6, i64 0, !25, i64 8, !25, i64 16, !25, i64 24, !16, i64 32}
!25 = !{!"long", !7, i64 0}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!12, !6, i64 232}
!29 = !{!30, !25, i64 16}
!30 = !{!"_ZTSN4ardb15SendFileSettingE", !15, i64 0, !25, i64 8, !25, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!31 = !{!25, !25, i64 0}
!32 = !{!30, !25, i64 8}
!33 = !{!30, !15, i64 0}
!34 = !{!15, !15, i64 0}
!35 = !{!30, !6, i64 32}
!36 = !{!30, !6, i64 24}
!37 = !{!12, !16, i64 40}


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

@.str = external hidden unnamed_addr constant [78 x i8], align 1
@__FUNCTION__._ZN4ardb7Channel7OnWriteEv = external hidden unnamed_addr constant [8 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [28 x i8], align 1

declare i32 @close(i32 noundef) local_unnamed_addr #0

declare noundef ptr @_ZN4ardb10ArdbLogger13GetLogCheckerEv() local_unnamed_addr #0

declare noundef ptr @_ZN4ardb10ArdbLogger13GetLogHandlerEv() local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33)) local_unnamed_addr #1 align 2

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4ardb7Channel13EnableWritingEv(ptr noundef nonnull align 8 dereferenceable(256)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4ardb7Channel14DisableWritingEv(ptr noundef nonnull align 8 dereferenceable(256)) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb7Channel7OnWriteEv(ptr noundef nonnull align 8 dereferenceable(256) %0) unnamed_addr #3 align 2 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 88
  %4 = load ptr, ptr %3, align 8
  %5 = tail call noundef zeroext i1 %4(ptr noundef nonnull align 8 dereferenceable(256) %0)
  br i1 %5, label %6, label %70

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 225
  %8 = load i8, ptr %7, align 1, !tbaa !8, !range !25, !noundef !26
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %10, label %12

10:                                               ; preds = %6
  %11 = tail call noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256) %0)
  br label %70

12:                                               ; preds = %6
  %13 = getelementptr inbounds i8, ptr %0, i64 144
  %14 = tail call noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33) %13)
  br i1 %14, label %70, label %15

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %0, i64 232
  %17 = load ptr, ptr %16, align 8, !tbaa !27
  %.not = icmp eq ptr %17, null
  br i1 %.not, label %.thread, label %18

18:                                               ; preds = %15
  tail call void @_ZN4ardb7Channel13EnableWritingEv(ptr noundef nonnull align 8 dereferenceable(256) %0)
  %19 = load ptr, ptr %16, align 8, !tbaa !27
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  %21 = load i64, ptr %20, align 8, !tbaa !28
  %22 = getelementptr inbounds i8, ptr %19, i64 8
  %23 = load i64, ptr %22, align 8, !tbaa !30
  %24 = load ptr, ptr %0, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 120
  %26 = load ptr, ptr %25, align 8
  %27 = tail call noundef i32 %26(ptr noundef nonnull align 8 dereferenceable(256) %0)
  %28 = load ptr, ptr %16, align 8, !tbaa !27
  %29 = load i32, ptr %28, align 8, !tbaa !31
  %30 = getelementptr inbounds i8, ptr %28, i64 8
  %31 = tail call i64 @sendfile(i32 noundef %27, i32 noundef %29, ptr noundef nonnull %30, i64 noundef %21) #6
  %32 = and i64 %31, 2147483648
  %.not15 = icmp eq i64 %32, 0
  br i1 %.not15, label %.critedge, label %33

33:                                               ; preds = %18
  %34 = tail call ptr @__errno_location() #7
  %35 = load i32, ptr %34, align 4, !tbaa !32
  %.not16 = icmp eq i32 %35, 11
  br i1 %.not16, label %.critedge, label %36

36:                                               ; preds = %33
  %37 = tail call noundef ptr @_ZN4ardb10ArdbLogger13GetLogCheckerEv()
  %38 = tail call noundef zeroext i1 %37(i32 noundef 5)
  br i1 %38, label %39, label %45

39:                                               ; preds = %36
  %40 = tail call noundef ptr @_ZN4ardb10ArdbLogger13GetLogHandlerEv()
  %41 = tail call ptr @strerror(i32 noundef %35) #6
  %42 = load ptr, ptr %16, align 8, !tbaa !27
  %43 = getelementptr inbounds i8, ptr %42, i64 8
  %44 = load i64, ptr %43, align 8, !tbaa !30
  tail call void (i32, ptr, ptr, i32, ptr, ...) %40(i32 noundef 5, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__._ZN4ardb7Channel7OnWriteEv, i32 noundef 606, ptr noundef nonnull @.str.16, ptr noundef %41, i64 noundef %44, i64 noundef %21)
  br label %45

45:                                               ; preds = %39, %36
  %46 = tail call noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256) %0)
  br label %70

.critedge:                                        ; preds = %33, %18
  %47 = load ptr, ptr %16, align 8, !tbaa !27
  %48 = getelementptr inbounds i8, ptr %47, i64 8
  %49 = load i64, ptr %48, align 8, !tbaa !30
  %.neg = sub i64 %23, %49
  %50 = getelementptr inbounds i8, ptr %47, i64 16
  %51 = load i64, ptr %50, align 8, !tbaa !28
  %52 = add i64 %.neg, %51
  store i64 %52, ptr %50, align 8, !tbaa !28
  %53 = icmp eq i64 %52, 0
  br i1 %53, label %54, label %70

54:                                               ; preds = %.critedge
  %55 = load i32, ptr %47, align 8, !tbaa !31
  %56 = tail call i32 @close(i32 noundef %55)
  %57 = load ptr, ptr %16, align 8, !tbaa !27
  store i32 -1, ptr %57, align 8, !tbaa !31
  %58 = getelementptr inbounds i8, ptr %57, i64 32
  %59 = load ptr, ptr %58, align 8, !tbaa !33
  %.not17 = icmp eq ptr %59, null
  br i1 %.not17, label %.thread, label %60

60:                                               ; preds = %54
  %61 = getelementptr inbounds i8, ptr %57, i64 24
  %62 = load ptr, ptr %61, align 8, !tbaa !34
  tail call void @_ZdlPvm(ptr noundef nonnull %57, i64 noundef 48) #8
  store ptr null, ptr %16, align 8, !tbaa !27
  tail call void %59(ptr noundef %62)
  br label %.thread

.thread:                                          ; preds = %60, %54, %15
  %63 = tail call noundef zeroext i1 @_ZN4ardb21fire_channel_writableEPNS_7ChannelE(ptr noundef nonnull %0)
  %64 = tail call noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33) %13)
  br i1 %64, label %70, label %65

65:                                               ; preds = %.thread
  %66 = getelementptr inbounds i8, ptr %0, i64 40
  %67 = load i8, ptr %66, align 8, !tbaa !35, !range !25, !noundef !26
  %68 = trunc nuw i8 %67 to i1
  br i1 %68, label %69, label %70

69:                                               ; preds = %65
  tail call void @_ZN4ardb7Channel14DisableWritingEv(ptr noundef nonnull align 8 dereferenceable(256) %0)
  br label %70

70:                                               ; preds = %.critedge, %45, %12, %1, %69, %65, %.thread, %10
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256)) local_unnamed_addr #3 align 2

; Function Attrs: nounwind
declare i64 @sendfile(i32 noundef, i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #5

declare noundef zeroext i1 @_ZN4ardb21fire_channel_writableEPNS_7ChannelE(ptr noundef) local_unnamed_addr #0

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress 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 = { mustprogress nofree nosync nounwind willreturn memory(none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nobuiltin nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }
attributes #8 = { builtin 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !14, i64 225}
!9 = !{!"_ZTSN4ardb7ChannelE", !10, i64 0, !11, i64 8, !14, i64 44, !14, i64 45, !12, i64 48, !15, i64 56, !16, i64 88, !12, i64 96, !12, i64 100, !23, i64 104, !23, i64 144, !12, i64 184, !16, i64 192, !16, i64 200, !16, i64 208, !16, i64 216, !14, i64 224, !14, i64 225, !14, i64 226, !16, i64 232, !16, i64 240, !16, i64 248}
!10 = !{!"_ZTSN4ardb8RunnableE"}
!11 = !{!"_ZTSN4ardb14ChannelOptionsE", !12, i64 0, !12, i64 4, !14, i64 8, !12, i64 12, !14, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !14, i64 32, !14, i64 33}
!12 = !{!"int", !13, i64 0}
!13 = !{!"omnipotent char", !7, i64 0}
!14 = !{!"bool", !13, i64 0}
!15 = !{!"_ZTSN4ardb15ChannelPipelineE", !16, i64 0, !16, i64 8, !16, i64 16, !17, i64 24}
!16 = !{!"any pointer", !13, i64 0}
!17 = !{!"_ZTSN5btree9btree_mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS6_ESaISt4pairIKS6_S9_EELi256EEE", !18, i64 0}
!18 = !{!"_ZTSN5btree19btree_map_containerINS_5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS8_ESaISt4pairIKS8_SB_EELi256EEEEEEE", !19, i64 0}
!19 = !{!"_ZTSN5btree22btree_unique_containerINS_5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS8_ESaISt4pairIKS8_SB_EELi256EEEEEEE", !20, i64 0}
!20 = !{!"_ZTSN5btree15btree_containerINS_5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS8_ESaISt4pairIKS8_SB_EELi256EEEEEEE", !21, i64 0}
!21 = !{!"_ZTSN5btree5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS7_ESaISt4pairIKS7_SA_EELi256EEEEE", !22, i64 0}
!22 = !{!"_ZTSN5btree5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS7_ESaISt4pairIKS7_SA_EELi256EEEE17empty_base_handleIS6_PNS_10btree_nodeISH_EEEE", !16, i64 0}
!23 = !{!"_ZTSN4ardb6BufferE", !16, i64 0, !24, i64 8, !24, i64 16, !24, i64 24, !14, i64 32}
!24 = !{!"long", !13, i64 0}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!9, !16, i64 232}
!28 = !{!29, !24, i64 16}
!29 = !{!"_ZTSN4ardb15SendFileSettingE", !12, i64 0, !24, i64 8, !24, i64 16, !16, i64 24, !16, i64 32, !16, i64 40}
!30 = !{!29, !24, i64 8}
!31 = !{!29, !12, i64 0}
!32 = !{!12, !12, i64 0}
!33 = !{!29, !16, i64 32}
!34 = !{!29, !16, i64 24}
!35 = !{!9, !14, i64 40}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass