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

; 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::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::taskEvent" = type { ptr, i8, i8, i8, i8, i64, ptr, ptr, ptr }
%"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 @_ZN3qOS4core6notifyENS_10notifyModeEPv(ptr noundef nonnull align 8 dereferenceable(800) %0, i8 noundef zeroext %1, ptr noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #2
  store i8 0, ptr %7, align 1, !tbaa !11
  %9 = getelementptr inbounds %"class.qOS::core", ptr %8, i32 0, i32 7
  %10 = getelementptr inbounds %"struct.qOS::notificationSpreader_t", ptr %9, i32 0, i32 0
  %11 = load i8, ptr %10, align 8, !tbaa !13
  %12 = icmp eq i8 3, %11
  br i1 %12, label %13, label %27

13:                                               ; preds = %3
  %14 = load i8, ptr %5, align 1, !tbaa !9
  %15 = icmp eq i8 0, %14
  br i1 %15, label %19, label %16

16:                                               ; preds = %13
  %17 = load i8, ptr %5, align 1, !tbaa !9
  %18 = icmp eq i8 1, %17
  br i1 %18, label %19, label %26

19:                                               ; preds = %16, %13
  %20 = load i8, ptr %5, align 1, !tbaa !9
  %21 = getelementptr inbounds %"class.qOS::core", ptr %8, i32 0, i32 7
  %22 = getelementptr inbounds %"struct.qOS::notificationSpreader_t", ptr %21, i32 0, i32 0
  store i8 %20, ptr %22, align 8, !tbaa !13
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.qOS::core", ptr %8, i32 0, i32 7
  %25 = getelementptr inbounds %"struct.qOS::notificationSpreader_t", ptr %24, i32 0, i32 1
  store ptr %23, ptr %25, align 8, !tbaa !25
  store i8 1, ptr %7, align 1, !tbaa !11
  br label %26

26:                                               ; preds = %19, %16
  br label %27

27:                                               ; preds = %26, %3
  %28 = load i8, ptr %7, align 1, !tbaa !11, !range !26, !noundef !27
  %29 = trunc i8 %28 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  ret i1 %29
}

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


; 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 @_ZN3qOS4core6notifyENS_10notifyModeEPv(ptr nocapture noundef nonnull align 8 dereferenceable(800) %0, i8 noundef zeroext %1, ptr noundef %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 424
  %5 = load i8, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i8 %5, 3
  %or.cond = icmp ult i8 %1, 2
  %or.cond6 = and i1 %or.cond, %6
  br i1 %or.cond6, label %7, label %9

7:                                                ; preds = %3
  store i8 %1, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 432
  store ptr %2, ptr %8, align 8, !tbaa !22
  br label %9

9:                                                ; preds = %7, %3
  ret i1 %or.cond6
}

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


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