; LLVM IR from kmilo17pet/QuarkTS-cpp :: src/kernel.ll (ZN3qOS4core11yieldToTaskERNS_4taskE)

; 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.qOS::taskEvent" = type { ptr, i8, i8, i8, i8, i64, ptr, ptr, ptr }
%"class.qOS::core" = type { %"class.qOS::taskEvent", %"class.qOS::task", ptr, ptr, [10 x %"struct.qOS::pq::queueStack_t"], %"class.qOS::prioQueue", i32, %"struct.qOS::notificationSpreader_t", i64, [5 x %"class.qOS::list"], ptr, ptr, %"class.qOS::list" }
%"class.qOS::task" = type <{ %"class.qOS::node", ptr, ptr, ptr, ptr, ptr, i64, [11 x i8], [5 x i8], %"class.qOS::timer", i32, [4 x i8], i64, i32, i32, i32, i8, i8, [2 x i8] }>
%"class.qOS::node" = type { ptr, ptr, ptr, ptr }
%"class.qOS::timer" = type { ptr, i64, i64 }
%"struct.qOS::pq::queueStack_t" = type { ptr, ptr }
%"class.qOS::prioQueue" = type { ptr, i32, ptr, ptr, i64 }
%"struct.qOS::notificationSpreader_t" = type { i8, ptr }
%"class.qOS::list" = type { %"class.qOS::node", ptr, ptr, i64 }

; 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 nounwind uwtable
define dso_local noundef zeroext i1 @_ZN3qOS4core11yieldToTaskERNS_4taskE(ptr noundef nonnull align 8 dereferenceable(800) %0, ptr noundef nonnull align 8 dereferenceable(150) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  store i8 0, ptr %5, align 1, !tbaa !9
  %7 = getelementptr inbounds %"class.qOS::taskEvent", ptr %6, i32 0, i32 6
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = icmp ne ptr null, %8
  br i1 %9, label %10, label %18

10:                                               ; preds = %2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %"class.qOS::taskEvent", ptr %6, i32 0, i32 6
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = icmp ne ptr %11, %13
  br i1 %14, label %15, label %18

15:                                               ; preds = %10
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"class.qOS::core", ptr %6, i32 0, i32 3
  store ptr %16, ptr %17, align 8, !tbaa !15
  store i8 1, ptr %5, align 1, !tbaa !9
  br label %18

18:                                               ; preds = %15, %10, %2
  %19 = load i8, ptr %5, align 1, !tbaa !9, !range !25, !noundef !26
  %20 = trunc i8 %19 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  ret i1 %20
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 }

!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 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 24}
!12 = !{!"_ZTSN3qOS9taskEventE", !13, i64 8, !10, i64 9, !10, i64 10, !10, i64 11, !14, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!13 = !{!"_ZTSN3qOS7triggerE", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !6, i64 208}
!16 = !{!"_ZTSN3qOS4coreE", !12, i64 0, !17, i64 48, !6, i64 200, !6, i64 208, !7, i64 216, !21, i64 376, !20, i64 416, !22, i64 424, !14, i64 440, !7, i64 448, !6, i64 728, !6, i64 736, !24, i64 744}
!17 = !{!"_ZTSN3qOS4taskE", !18, i64 0, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !14, i64 72, !7, i64 80, !19, i64 96, !20, i64 120, !14, i64 128, !20, i64 136, !20, i64 140, !20, i64 144, !7, i64 148, !13, i64 149}
!18 = !{!"_ZTSN3qOS4nodeE", !6, i64 8, !6, i64 16, !6, i64 24}
!19 = !{!"_ZTSN3qOS5timerE", !14, i64 8, !14, i64 16}
!20 = !{!"int", !7, i64 0}
!21 = !{!"_ZTSN3qOS9prioQueueE", !20, i64 8, !6, i64 16, !6, i64 24, !14, i64 32}
!22 = !{!"_ZTSN3qOS22notificationSpreader_tE", !23, i64 0, !6, i64 8}
!23 = !{!"_ZTSN3qOS10notifyModeE", !7, i64 0}
!24 = !{!"_ZTSN3qOS4listE", !18, i64 0, !6, i64 32, !6, i64 40, !14, i64 48}
!25 = !{i8 0, i8 2}
!26 = !{}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef zeroext i1 @_ZN3qOS4core11yieldToTaskERNS_4taskE(ptr nocapture noundef nonnull align 8 dereferenceable(800) %0, ptr noundef nonnull align 8 dereferenceable(150) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp ne ptr %4, null
  %.not5 = icmp ne ptr %4, %1
  %or.cond.not = and i1 %.not, %.not5
  br i1 %or.cond.not, label %5, label %7

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 208
  store ptr %1, ptr %6, align 8, !tbaa !13
  br label %7

7:                                                ; preds = %5, %2
  ret i1 %or.cond.not
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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" }

!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, !12, i64 24}
!6 = !{!"_ZTSN3qOS9taskEventE", !7, i64 8, !10, i64 9, !10, i64 10, !10, i64 11, !11, i64 16, !12, i64 24, !12, i64 32, !12, i64 40}
!7 = !{!"_ZTSN3qOS7triggerE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !12, i64 208}
!14 = !{!"_ZTSN3qOS4coreE", !6, i64 0, !15, i64 48, !12, i64 200, !12, i64 208, !8, i64 216, !19, i64 376, !18, i64 416, !20, i64 424, !11, i64 440, !8, i64 448, !12, i64 728, !12, i64 736, !22, i64 744}
!15 = !{!"_ZTSN3qOS4taskE", !16, i64 0, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !11, i64 72, !8, i64 80, !17, i64 96, !18, i64 120, !11, i64 128, !18, i64 136, !18, i64 140, !18, i64 144, !8, i64 148, !7, i64 149}
!16 = !{!"_ZTSN3qOS4nodeE", !12, i64 8, !12, i64 16, !12, i64 24}
!17 = !{!"_ZTSN3qOS5timerE", !11, i64 8, !11, i64 16}
!18 = !{!"int", !8, i64 0}
!19 = !{!"_ZTSN3qOS9prioQueueE", !18, i64 8, !12, i64 16, !12, i64 24, !11, i64 32}
!20 = !{!"_ZTSN3qOS22notificationSpreader_tE", !21, i64 0, !12, i64 8}
!21 = !{!"_ZTSN3qOS10notifyModeE", !8, i64 0}
!22 = !{!"_ZTSN3qOS4listE", !16, i64 0, !12, i64 32, !12, i64 40, !11, i64 48}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass