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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN4ardb7Channel11GetPipelineEv(ptr noundef nonnull align 8 dereferenceable(256)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb11CoroChannel5CloseEv(ptr noundef nonnull align 8 dereferenceable(72) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %3, i32 0, i32 3
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = icmp ne ptr null, %5
  br i1 %6, label %7, label %20

7:                                                ; preds = %1
  br label %8

8:                                                ; preds = %14, %7
  %9 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %3, i32 0, i32 3
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN4ardb7Channel11GetPipelineEv(ptr noundef nonnull align 8 dereferenceable(256) %10)
  %12 = call noundef ptr @_ZN4ardb15ChannelPipeline11RemoveFirstEv(ptr noundef nonnull align 8 dereferenceable(32) %11)
  %13 = icmp ne ptr null, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %8
  br label %8, !llvm.loop !17

15:                                               ; preds = %8
  %16 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %3, i32 0, i32 3
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = call noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256) %17)
  %19 = getelementptr inbounds %"class.ardb::CoroChannel", ptr %3, i32 0, i32 3
  store ptr null, ptr %19, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %15, %1
  ret void
}

declare noundef ptr @_ZN4ardb15ChannelPipeline11RemoveFirstEv(ptr noundef nonnull align 8 dereferenceable(32)) #2

declare noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256)) #2

attributes #0 = { 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 #1 = { 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 #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" }

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN4ardb7Channel11GetPipelineEv(ptr noundef nonnull align 8 dereferenceable(256)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb11CoroChannel5CloseEv(ptr nocapture noundef nonnull align 8 dereferenceable(72) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %10, label %.preheader

.preheader:                                       ; preds = %1, %.preheader
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN4ardb7Channel11GetPipelineEv(ptr noundef nonnull align 8 dereferenceable(256) %4)
  %6 = tail call noundef ptr @_ZN4ardb15ChannelPipeline11RemoveFirstEv(ptr noundef nonnull align 8 dereferenceable(32) %5)
  %.not1 = icmp eq ptr %6, null
  br i1 %.not1, label %7, label %.preheader, !llvm.loop !16

7:                                                ; preds = %.preheader
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = tail call noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256) %8)
  store ptr null, ptr %2, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %7, %1
  ret void
}

declare noundef ptr @_ZN4ardb15ChannelPipeline11RemoveFirstEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2

declare noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256)) local_unnamed_addr #2

attributes #0 = { 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 #1 = { 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 #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" }

!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, !11, i64 24}
!6 = !{!"_ZTSN4ardb11CoroChannelE", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !14, i64 48, !11, i64 56, !14, i64 64, !15, i64 68}
!7 = !{!"_ZTSN4ardb22ChannelUpstreamHandlerINS_6BufferEEE", !8, i64 0}
!8 = !{!"_ZTSN4ardb22AbstractChannelHandlerINS_6BufferEEE", !9, i64 0}
!9 = !{!"_ZTSN4ardb14ChannelHandlerE"}
!10 = !{!"_ZTSN4ardb8RunnableE"}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"bool", !12, i64 0}
!15 = !{!"int", !12, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass