; LLVM IR from yinqiwen/ardb :: src/common/coro/coro_channel.ll (ZN4ardb11CoroChannelC2EPNS_7ChannelE)

; 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::CoroChannel" = type { %"class.ardb::ChannelUpstreamHandler", %"class.ardb::Runnable", ptr, ptr, ptr, ptr, i8, ptr, i8, i32 }
%"class.ardb::ChannelUpstreamHandler" = type { %"class.ardb::AbstractChannelHandler" }
%"class.ardb::AbstractChannelHandler" = type { %"class.ardb::ChannelHandler" }
%"class.ardb::ChannelHandler" = type { ptr }
%"class.ardb::Runnable" = type { ptr }

@_ZTVN4ardb11CoroChannelE = external dso_local unnamed_addr constant { [16 x ptr], [5 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb11CoroChannelC2EPNS_7ChannelE(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @_ZN4ardb22ChannelUpstreamHandlerINS_6BufferEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #4
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  call void @_ZN4ardb8RunnableC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #4
  store ptr getelementptr inbounds inrange(-16, 112) ({ [16 x ptr], [5 x ptr] }, ptr @_ZTVN4ardb11CoroChannelE, i32 0, i32 0, i32 2), ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr getelementptr inbounds inrange(-16, 24) ({ [16 x ptr], [5 x ptr] }, ptr @_ZTVN4ardb11CoroChannelE, i32 0, i32 1, i32 2), ptr %9, align 8, !tbaa !9
  %10 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %7, i32 0, i32 2
  store ptr null, ptr %10, align 8, !tbaa !11
  %11 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %7, i32 0, i32 3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %12, ptr %11, align 8, !tbaa !19
  %13 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %7, i32 0, i32 4
  store ptr null, ptr %13, align 8, !tbaa !20
  %14 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %7, i32 0, i32 5
  store ptr null, ptr %14, align 8, !tbaa !21
  %15 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %7, i32 0, i32 6
  store i8 0, ptr %15, align 8, !tbaa !22
  %16 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %7, i32 0, i32 7
  store ptr null, ptr %16, align 8, !tbaa !23
  %17 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %7, i32 0, i32 8
  store i8 0, ptr %17, align 8, !tbaa !24
  %18 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %7, i32 0, i32 9
  store i32 -1, ptr %18, align 4, !tbaa !25
  %19 = invoke noundef nonnull align 8 dereferenceable(184) ptr @_ZN4ardb9Scheduler16CurrentSchedulerEv()
          to label %20 unwind label %28

20:                                               ; preds = %2
  %21 = invoke noundef ptr @_ZN4ardb9Scheduler19GetCurrentCoroutineEv(ptr noundef nonnull align 8 dereferenceable(184) %19)
          to label %22 unwind label %28

22:                                               ; preds = %20
  %23 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %7, i32 0, i32 4
  store ptr %21, ptr %23, align 8, !tbaa !20
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = invoke noundef nonnull align 8 dereferenceable(288) ptr @_ZN4ardb7Channel10GetServiceEv(ptr noundef nonnull align 8 dereferenceable(256) %24)
          to label %26 unwind label %28

26:                                               ; preds = %22
  %27 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %7, i32 0, i32 2
  store ptr %25, ptr %27, align 8, !tbaa !11
  ret void

28:                                               ; preds = %22, %20, %2
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %5, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %6, align 4
  %32 = getelementptr inbounds i8, ptr %7, i64 8
  call void @_ZN4ardb8RunnableD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %32) #4
  call void @_ZN4ardb14ChannelHandlerD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #4
  br label %33

33:                                               ; preds = %28
  %34 = load ptr, ptr %5, align 8
  %35 = load i32, ptr %6, align 4
  %36 = insertvalue { ptr, i32 } poison, ptr %34, 0
  %37 = insertvalue { ptr, i32 } %36, i32 %35, 1
  resume { ptr, i32 } %37
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4ardb22ChannelUpstreamHandlerINS_6BufferEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4ardb8RunnableC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

declare noundef nonnull align 8 dereferenceable(184) ptr @_ZN4ardb9Scheduler16CurrentSchedulerEv() #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4ardb9Scheduler19GetCurrentCoroutineEv(ptr noundef nonnull align 8 dereferenceable(184)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(288) ptr @_ZN4ardb7Channel10GetServiceEv(ptr noundef nonnull align 8 dereferenceable(256)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4ardb8RunnableD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4ardb14ChannelHandlerD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

attributes #0 = { 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 #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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nounwind 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 }

!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, !6, i64 16}
!12 = !{!"_ZTSN4ardb11CoroChannelE", !13, i64 0, !16, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !17, i64 48, !6, i64 56, !17, i64 64, !18, i64 68}
!13 = !{!"_ZTSN4ardb22ChannelUpstreamHandlerINS_6BufferEEE", !14, i64 0}
!14 = !{!"_ZTSN4ardb22AbstractChannelHandlerINS_6BufferEEE", !15, i64 0}
!15 = !{!"_ZTSN4ardb14ChannelHandlerE"}
!16 = !{!"_ZTSN4ardb8RunnableE"}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!12, !6, i64 24}
!20 = !{!12, !6, i64 32}
!21 = !{!12, !6, i64 40}
!22 = !{!12, !17, i64 48}
!23 = !{!12, !6, i64 56}
!24 = !{!12, !17, i64 64}
!25 = !{!12, !18, i64 68}


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

@_ZTVN4ardb11CoroChannelE = external dso_local unnamed_addr constant { [16 x ptr], [5 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb11CoroChannelC2EPNS_7ChannelE(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN4ardb22ChannelUpstreamHandlerINS_6BufferEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #5
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN4ardb8RunnableC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  store ptr getelementptr inbounds inrange(-16, 112) (i8, ptr @_ZTVN4ardb11CoroChannelE, i64 16), ptr %0, align 8, !tbaa !5
  store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN4ardb11CoroChannelE, i64 144), ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr null, ptr %4, align 8, !tbaa !8
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %1, ptr %5, align 8, !tbaa !18
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr null, ptr %7, align 8, !tbaa !19
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  store i8 0, ptr %8, align 8, !tbaa !20
  %9 = getelementptr inbounds i8, ptr %0, i64 68
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %6, i8 0, i64 17, i1 false)
  store i32 -1, ptr %9, align 4, !tbaa !21
  %10 = invoke noundef nonnull align 8 dereferenceable(184) ptr @_ZN4ardb9Scheduler16CurrentSchedulerEv()
          to label %11 unwind label %14

11:                                               ; preds = %2
  %12 = tail call noundef ptr @_ZN4ardb9Scheduler19GetCurrentCoroutineEv(ptr noundef nonnull align 8 dereferenceable(184) %10)
  store ptr %12, ptr %6, align 8, !tbaa !22
  %13 = tail call noundef nonnull align 8 dereferenceable(288) ptr @_ZN4ardb7Channel10GetServiceEv(ptr noundef nonnull align 8 dereferenceable(256) %1)
  store ptr %13, ptr %4, align 8, !tbaa !8
  ret void

14:                                               ; preds = %2
  %15 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN4ardb8RunnableD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  tail call void @_ZN4ardb14ChannelHandlerD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #5
  resume { ptr, i32 } %15
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4ardb22ChannelUpstreamHandlerINS_6BufferEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4ardb8RunnableC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

declare noundef nonnull align 8 dereferenceable(184) ptr @_ZN4ardb9Scheduler16CurrentSchedulerEv() local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4ardb9Scheduler19GetCurrentCoroutineEv(ptr noundef nonnull align 8 dereferenceable(184)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(288) ptr @_ZN4ardb7Channel10GetServiceEv(ptr noundef nonnull align 8 dereferenceable(256)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4ardb8RunnableD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4ardb14ChannelHandlerD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

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

attributes #0 = { 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 #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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nounwind 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 nounwind willreturn memory(argmem: write) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !14, i64 16}
!9 = !{!"_ZTSN4ardb11CoroChannelE", !10, i64 0, !13, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !16, i64 48, !14, i64 56, !16, i64 64, !17, i64 68}
!10 = !{!"_ZTSN4ardb22ChannelUpstreamHandlerINS_6BufferEEE", !11, i64 0}
!11 = !{!"_ZTSN4ardb22AbstractChannelHandlerINS_6BufferEEE", !12, i64 0}
!12 = !{!"_ZTSN4ardb14ChannelHandlerE"}
!13 = !{!"_ZTSN4ardb8RunnableE"}
!14 = !{!"any pointer", !15, i64 0}
!15 = !{!"omnipotent char", !7, i64 0}
!16 = !{!"bool", !15, i64 0}
!17 = !{!"int", !15, i64 0}
!18 = !{!9, !14, i64 24}
!19 = !{!9, !14, i64 56}
!20 = !{!9, !16, i64 64}
!21 = !{!9, !17, i64 68}
!22 = !{!9, !14, i64 32}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass