; LLVM IR from yinqiwen/ardb :: src/common/coro/scheduler.ll (ZN4ardb9Scheduler9StartCoroEjPFvPvES1_)

; 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.ardb::CoroutineContext" = type { ptr, ptr, ptr }
%"class.ardb::Scheduler" = type { %"class.std::stack", %"class.std::stack", %"class.btree::btree_map", %"class.btree::btree_map", ptr }
%"class.std::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<ardb::Coroutine *, std::allocator<ardb::Coroutine *>>::_Deque_impl" }
%"struct.std::_Deque_base<ardb::Coroutine *, std::allocator<ardb::Coroutine *>>::_Deque_impl" = type { %"struct.std::_Deque_base<ardb::Coroutine *, std::allocator<ardb::Coroutine *>>::_Deque_impl_data" }
%"struct.std::_Deque_base<ardb::Coroutine *, std::allocator<ardb::Coroutine *>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"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<unsigned long, ardb::Coroutine *, std::less<unsigned long>, std::allocator<std::pair<const unsigned long, ardb::Coroutine *>>, 256>>::empty_base_handle" }
%"struct.btree::btree<btree::btree_map_params<unsigned long, ardb::Coroutine *, std::less<unsigned long>, std::allocator<std::pair<const unsigned long, ardb::Coroutine *>>, 256>>::empty_base_handle" = type { ptr }
%"struct.ardb::Coroutine" = type { i64, ptr, %struct.coro_context, %struct.coro_stack }
%struct.coro_context = type { ptr }
%struct.coro_stack = type { ptr, i64 }

declare i32 @__gxx_personality_v0(...)

; 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: mustprogress uwtable
declare dso_local void @_ZN4ardb9Scheduler5CleanEv(ptr noundef nonnull align 8 dereferenceable(184)) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4ardb9Scheduler6WakeupEPNS_9CoroutineE(ptr noundef nonnull align 8 dereferenceable(184), ptr noundef) #1 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN4ardb9Scheduler9StartCoroEjPFvPvES1_(ptr noundef nonnull align 8 dereferenceable(184) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #1 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8
  call void @_ZN4ardb9Scheduler5CleanEv(ptr noundef nonnull align 8 dereferenceable(184) %13)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %14 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #5
  store ptr %14, ptr %9, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.ardb::CoroutineContext", ptr %16, i32 0, i32 1
  store ptr %15, ptr %17, align 8, !tbaa !11
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.ardb::CoroutineContext", ptr %18, i32 0, i32 0
  store ptr %13, ptr %19, align 8, !tbaa !13
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.ardb::CoroutineContext", ptr %21, i32 0, i32 2
  store ptr %20, ptr %22, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %23 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #5
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = load i32, ptr %6, align 4, !tbaa !9
  invoke void @_ZN4ardb9CoroutineC1EPFvPvES1_j(ptr noundef nonnull align 8 dereferenceable(40) %23, ptr noundef @_ZN4ardbL15MyCoroutineFuncEPv, ptr noundef %24, i32 noundef %25)
          to label %26 unwind label %36

26:                                               ; preds = %4
  store ptr %23, ptr %10, align 8, !tbaa !5
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.ardb::Scheduler", ptr %13, i32 0, i32 3
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.ardb::Coroutine", ptr %29, i32 0, i32 0
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5btree19btree_map_containerINS_5btreeINS_16btree_map_paramsImPN4ardb9CoroutineESt4lessImESaISt4pairIKmS5_EELi256EEEEEEixERS9_(ptr noundef nonnull align 8 dereferenceable(8) %28, ptr noundef nonnull align 8 dereferenceable(8) %30)
  store ptr %27, ptr %31, align 8, !tbaa !5
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN4ardb9Scheduler6WakeupEPNS_9CoroutineE(ptr noundef nonnull align 8 dereferenceable(184) %13, ptr noundef %32)
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.ardb::Coroutine", ptr %33, i32 0, i32 0
  %35 = load i64, ptr %34, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret i64 %35

36:                                               ; preds = %4
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %11, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %12, align 4
  call void @_ZdlPvm(ptr noundef %23, i64 noundef 40) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %40

40:                                               ; preds = %36
  %41 = load ptr, ptr %11, align 8
  %42 = load i32, ptr %12, align 4
  %43 = insertvalue { ptr, i32 } poison, ptr %41, 0
  %44 = insertvalue { ptr, i32 } %43, i32 %42, 1
  resume { ptr, i32 } %44
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN4ardbL15MyCoroutineFuncEPv(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN5btree19btree_map_containerINS_5btreeINS_16btree_map_paramsImPN4ardb9CoroutineESt4lessImESaISt4pairIKmS5_EELi256EEEEEEixERS9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

declare void @_ZN4ardb9CoroutineC1EPFvPvES1_j(ptr, ptr, ptr, i32)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { nobuiltin allocsize(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 }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN4ardb16CoroutineContextE", !6, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!12, !6, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!16, !17, i64 0}
!16 = !{!"_ZTSN4ardb9CoroutineE", !17, i64 0, !6, i64 8, !18, i64 16, !19, i64 24}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTS12coro_context", !6, i64 0}
!19 = !{!"_ZTS10coro_stack", !6, i64 0, !17, i64 8}


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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4ardb9Scheduler5CleanEv(ptr noundef nonnull align 8 dereferenceable(184)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4ardb9Scheduler6WakeupEPNS_9CoroutineE(ptr noundef nonnull align 8 dereferenceable(184), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN4ardb9Scheduler9StartCoroEjPFvPvES1_(ptr noundef nonnull align 8 dereferenceable(184) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN4ardb9Scheduler5CleanEv(ptr noundef nonnull align 8 dereferenceable(184) %0)
  %5 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %2, ptr %6, align 8, !tbaa !5
  store ptr %0, ptr %5, align 8, !tbaa !10
  %7 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr %3, ptr %7, align 8, !tbaa !11
  %8 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #3
  invoke void @_ZN4ardb9CoroutineC1EPFvPvES1_j(ptr noundef nonnull align 8 dereferenceable(40) %8, ptr noundef nonnull @_ZN4ardbL15MyCoroutineFuncEPv, ptr noundef nonnull %5, i32 noundef %1)
          to label %9 unwind label %13

9:                                                ; preds = %4
  %10 = getelementptr inbounds i8, ptr %0, i64 168
  %11 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5btree19btree_map_containerINS_5btreeINS_16btree_map_paramsImPN4ardb9CoroutineESt4lessImESaISt4pairIKmS5_EELi256EEEEEEixERS9_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %8)
  store ptr %8, ptr %11, align 8, !tbaa !12
  tail call void @_ZN4ardb9Scheduler6WakeupEPNS_9CoroutineE(ptr noundef nonnull align 8 dereferenceable(184) %0, ptr noundef nonnull %8)
  %12 = load i64, ptr %8, align 8, !tbaa !13
  ret i64 %12

13:                                               ; preds = %4
  %14 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %8, i64 noundef 40) #4
  resume { ptr, i32 } %14
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN4ardbL15MyCoroutineFuncEPv(ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN5btree19btree_map_containerINS_5btreeINS_16btree_map_paramsImPN4ardb9CoroutineESt4lessImESaISt4pairIKmS5_EELi256EEEEEEixERS9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

declare void @_ZN4ardb9CoroutineC1EPFvPvES1_j(ptr, ptr, ptr, i32) local_unnamed_addr

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 = { 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 #2 = { nobuiltin allocsize(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 = { builtin allocsize(0) }
attributes #4 = { 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, !7, i64 8}
!6 = !{!"_ZTSN4ardb16CoroutineContextE", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTSN4ardb9CoroutineE", !15, i64 0, !7, i64 8, !16, i64 16, !17, i64 24}
!15 = !{!"long", !8, i64 0}
!16 = !{!"_ZTS12coro_context", !7, i64 0}
!17 = !{!"_ZTS10coro_stack", !7, i64 0, !15, i64 8}


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