; LLVM IR from kmilo17pet/QuarkTS-cpp :: src/kernel.ll (ZNK3qOS4core14getGlobalStateERNS_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 i8 @_ZNK3qOS4core14getGlobalStateERNS_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
  %6 = alloca ptr, align 8
  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 @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  store i8 0, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = call noundef ptr @_ZN3qOS4node12getContainerEv(ptr noundef nonnull align 8 dereferenceable(32) %8) #3
  store ptr %9, ptr %6, align 8, !tbaa !5
  %10 = getelementptr inbounds %"class.qOS::taskEvent", ptr %7, i32 0, i32 6
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp eq ptr %11, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  store i8 4, ptr %5, align 1, !tbaa !9
  br label %35

15:                                               ; preds = %2
  %16 = getelementptr inbounds %"class.qOS::core", ptr %7, i32 0, i32 10
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp eq ptr %17, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %15
  store i8 2, ptr %5, align 1, !tbaa !9
  br label %34

21:                                               ; preds = %15
  %22 = getelementptr inbounds %"class.qOS::core", ptr %7, i32 0, i32 11
  %23 = load ptr, ptr %22, align 8, !tbaa !26
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = icmp eq ptr %23, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %21
  store i8 3, ptr %5, align 1, !tbaa !9
  br label %33

27:                                               ; preds = %21
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = icmp eq ptr null, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  br label %32

31:                                               ; preds = %27
  store i8 1, ptr %5, align 1, !tbaa !9
  br label %32

32:                                               ; preds = %31, %30
  br label %33

33:                                               ; preds = %32, %26
  br label %34

34:                                               ; preds = %33, %20
  br label %35

35:                                               ; preds = %34, %14
  %36 = load i8, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  ret i8 %36
}

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

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


; 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 nounwind uwtable
define dso_local noundef zeroext range(i8 0, 5) i8 @_ZNK3qOS4core14getGlobalStateERNS_4taskE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(800) %0, ptr noundef nonnull align 8 dereferenceable(150) %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef ptr @_ZN3qOS4node12getContainerEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #2
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = icmp eq ptr %5, %1
  br i1 %6, label %17, label %7

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 728
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = icmp eq ptr %9, %3
  br i1 %10, label %17, label %11

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 736
  %13 = load ptr, ptr %12, align 8, !tbaa !23
  %14 = icmp eq ptr %13, %3
  br i1 %14, label %17, label %15

15:                                               ; preds = %11
  %16 = icmp ne ptr %3, null
  %spec.select = zext i1 %16 to i8
  br label %17

17:                                               ; preds = %15, %11, %7, %2
  %.0 = phi i8 [ 4, %2 ], [ 2, %7 ], [ 3, %11 ], [ %spec.select, %15 ]
  ret i8 %.0
}

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

attributes #0 = { 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 = { 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 = { 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, !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 728}
!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}
!23 = !{!14, !12, i64 736}


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