; LLVM IR from intel/qpl :: sources/middle-layer/dispatcher (hw_device)

; 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.qpl::ml::dispatcher::hw_device" = type { %"struct.std::array", i32, i64, i64, i64, i32, i32, i64, %"class.qpl::ml::dispatcher::queue_selector" }
%"struct.std::array" = type { [100 x %"class.qpl::ml::dispatcher::hw_queue"] }
%"class.qpl::ml::dispatcher::hw_queue" = type { ptr, i8, i32, i64, ptr, %"struct.std::atomic", i8, %"struct.std::array.0", i8, i32, i64 }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i64 }
%"struct.std::array.0" = type { [8 x i32] }
%"class.qpl::ml::dispatcher::queue_selector" = type { %"class.std::unordered_map", %"class.std::map" }
%"class.std::unordered_map" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<unsigned long, std::pair<const unsigned long, qpl::ml::util::bitmask128>, std::_Select1st<std::pair<const unsigned long, qpl::ml::util::bitmask128>>, std::less<unsigned long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<unsigned long, std::pair<const unsigned long, qpl::ml::util::bitmask128>, std::_Select1st<std::pair<const unsigned long, qpl::ml::util::bitmask128>>, std::less<unsigned long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK3qpl2ml10dispatcher9hw_device28is_matching_user_numa_policyEi(ptr noundef nonnull align 8 dereferenceable(9752) %0, i32 noundef %1) #0 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %6 = load ptr, ptr %4, align 8
  %7 = getelementptr inbounds %"class.qpl::ml::dispatcher::hw_device", ptr %6, i32 0, i32 4
  %8 = load i64, ptr %7, align 8, !tbaa !11
  %9 = icmp eq i64 %8, -1
  br i1 %9, label %13, label %10

10:                                               ; preds = %2
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = icmp eq i32 %11, -3
  br i1 %12, label %13, label %14

13:                                               ; preds = %10, %2
  store i1 true, ptr %3, align 1
  br label %49

14:                                               ; preds = %10
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = icmp sge i32 %15, 0
  br i1 %16, label %17, label %23

17:                                               ; preds = %14
  %18 = getelementptr inbounds %"class.qpl::ml::dispatcher::hw_device", ptr %6, i32 0, i32 4
  %19 = load i64, ptr %18, align 8, !tbaa !11
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = icmp eq i64 %19, %21
  store i1 %22, ptr %3, align 1
  br label %49

23:                                               ; preds = %14
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = icmp eq i32 %24, -2
  br i1 %25, label %26, label %32

26:                                               ; preds = %23
  %27 = getelementptr inbounds %"class.qpl::ml::dispatcher::hw_device", ptr %6, i32 0, i32 4
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = call noundef i32 @_ZN3qpl2ml4util11get_numa_idEv() #2
  %30 = sext i32 %29 to i64
  %31 = icmp eq i64 %28, %30
  store i1 %31, ptr %3, align 1
  br label %49

32:                                               ; preds = %23
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = icmp eq i32 %33, -1
  br i1 %34, label %35, label %48

35:                                               ; preds = %32
  %36 = getelementptr inbounds %"class.qpl::ml::dispatcher::hw_device", ptr %6, i32 0, i32 4
  %37 = load i64, ptr %36, align 8, !tbaa !11
  %38 = call noundef i32 @_ZN3qpl2ml4util11get_numa_idEv() #2
  %39 = sext i32 %38 to i64
  %40 = icmp eq i64 %37, %39
  br i1 %40, label %46, label %41

41:                                               ; preds = %35
  %42 = getelementptr inbounds %"class.qpl::ml::dispatcher::hw_device", ptr %6, i32 0, i32 7
  %43 = load i64, ptr %42, align 8, !tbaa !29
  %44 = call noundef i64 @_ZN3qpl2ml4util13get_socket_idEv() #2
  %45 = icmp eq i64 %43, %44
  br label %46

46:                                               ; preds = %41, %35
  %47 = phi i1 [ true, %35 ], [ %45, %41 ]
  store i1 %47, ptr %3, align 1
  br label %49

48:                                               ; preds = %32
  store i1 false, ptr %3, align 1
  br label %49

49:                                               ; preds = %48, %46, %26, %17, %13
  %50 = load i1, ptr %3, align 1
  ret i1 %50
}

; Function Attrs: nounwind
declare noundef i32 @_ZN3qpl2ml4util11get_numa_idEv() #1

; Function Attrs: nounwind
declare noundef i64 @_ZN3qpl2ml4util13get_socket_idEv() #1

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 = { 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 = { 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, !14, i64 9624}
!12 = !{!"_ZTSN3qpl2ml10dispatcher9hw_deviceE", !13, i64 0, !10, i64 9600, !14, i64 9608, !14, i64 9616, !14, i64 9624, !10, i64 9632, !10, i64 9636, !14, i64 9640, !15, i64 9648}
!13 = !{!"_ZTSSt5arrayIN3qpl2ml10dispatcher8hw_queueELm100EE", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSN3qpl2ml10dispatcher14queue_selectorE", !16, i64 0, !21, i64 56}
!16 = !{!"_ZTSSt13unordered_mapIjN3qpl2ml4util10bitmask128ESt4hashIjESt8equal_toIjESaISt4pairIKjS3_EEE", !17, i64 0}
!17 = !{!"_ZTSSt10_HashtableIjSt4pairIKjN3qpl2ml4util10bitmask128EESaIS6_ENSt8__detail10_Select1stESt8equal_toIjESt4hashIjENS8_18_Mod_range_hashingENS8_20_Default_ranged_hashENS8_20_Prime_rehash_policyENS8_17_Hashtable_traitsILb0ELb0ELb1EEEE", !6, i64 0, !14, i64 8, !18, i64 16, !14, i64 24, !19, i64 32, !6, i64 48}
!18 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!19 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !20, i64 0, !14, i64 8}
!20 = !{!"float", !7, i64 0}
!21 = !{!"_ZTSSt3mapImN3qpl2ml4util10bitmask128ESt4lessImESaISt4pairIKmS3_EEE", !22, i64 0}
!22 = !{!"_ZTSSt8_Rb_treeImSt4pairIKmN3qpl2ml4util10bitmask128EESt10_Select1stIS6_ESt4lessImESaIS6_EE", !23, i64 0}
!23 = !{!"_ZTSNSt8_Rb_treeImSt4pairIKmN3qpl2ml4util10bitmask128EESt10_Select1stIS6_ESt4lessImESaIS6_EE13_Rb_tree_implISA_Lb1EEE", !24, i64 0, !26, i64 8}
!24 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessImEE", !25, i64 0}
!25 = !{!"_ZTSSt4lessImE"}
!26 = !{!"_ZTSSt15_Rb_tree_header", !27, i64 0, !14, i64 32}
!27 = !{!"_ZTSSt18_Rb_tree_node_base", !28, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!28 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!29 = !{!12, !14, i64 9640}


; 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 i1 @_ZNK3qpl2ml10dispatcher9hw_device28is_matching_user_numa_policyEi(ptr nocapture noundef nonnull readonly align 8 dereferenceable(9752) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 9624
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i64 %4, -1
  %6 = icmp eq i32 %1, -3
  %or.cond = or i1 %6, %5
  br i1 %or.cond, label %26, label %7

7:                                                ; preds = %2
  %8 = icmp sgt i32 %1, -1
  br i1 %8, label %9, label %12

9:                                                ; preds = %7
  %10 = zext nneg i32 %1 to i64
  %11 = icmp eq i64 %4, %10
  br label %26

12:                                               ; preds = %7
  switch i32 %1, label %26 [
    i32 -2, label %13
    i32 -1, label %17
  ]

13:                                               ; preds = %12
  %14 = tail call noundef i32 @_ZN3qpl2ml4util11get_numa_idEv() #2
  %15 = sext i32 %14 to i64
  %16 = icmp eq i64 %4, %15
  br label %26

17:                                               ; preds = %12
  %18 = tail call noundef i32 @_ZN3qpl2ml4util11get_numa_idEv() #2
  %19 = sext i32 %18 to i64
  %20 = icmp eq i64 %4, %19
  br i1 %20, label %26, label %21

21:                                               ; preds = %17
  %22 = getelementptr inbounds i8, ptr %0, i64 9640
  %23 = load i64, ptr %22, align 8, !tbaa !27
  %24 = tail call noundef i64 @_ZN3qpl2ml4util13get_socket_idEv() #2
  %25 = icmp eq i64 %23, %24
  br label %26

26:                                               ; preds = %12, %17, %21, %2, %13, %9
  %.0 = phi i1 [ %11, %9 ], [ %16, %13 ], [ true, %2 ], [ true, %17 ], [ %25, %21 ], [ false, %12 ]
  ret i1 %.0
}

; Function Attrs: nounwind
declare noundef i32 @_ZN3qpl2ml4util11get_numa_idEv() local_unnamed_addr #1

; Function Attrs: nounwind
declare noundef i64 @_ZN3qpl2ml4util13get_socket_idEv() local_unnamed_addr #1

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 = { 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 = { 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, !11, i64 9624}
!6 = !{!"_ZTSN3qpl2ml10dispatcher9hw_deviceE", !7, i64 0, !10, i64 9600, !11, i64 9608, !11, i64 9616, !11, i64 9624, !10, i64 9632, !10, i64 9636, !11, i64 9640, !12, i64 9648}
!7 = !{!"_ZTSSt5arrayIN3qpl2ml10dispatcher8hw_queueELm100EE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"_ZTSN3qpl2ml10dispatcher14queue_selectorE", !13, i64 0, !19, i64 56}
!13 = !{!"_ZTSSt13unordered_mapIjN3qpl2ml4util10bitmask128ESt4hashIjESt8equal_toIjESaISt4pairIKjS3_EEE", !14, i64 0}
!14 = !{!"_ZTSSt10_HashtableIjSt4pairIKjN3qpl2ml4util10bitmask128EESaIS6_ENSt8__detail10_Select1stESt8equal_toIjESt4hashIjENS8_18_Mod_range_hashingENS8_20_Default_ranged_hashENS8_20_Prime_rehash_policyENS8_17_Hashtable_traitsILb0ELb0ELb1EEEE", !15, i64 0, !11, i64 8, !16, i64 16, !11, i64 24, !17, i64 32, !15, i64 48}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !15, i64 0}
!17 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !18, i64 0, !11, i64 8}
!18 = !{!"float", !8, i64 0}
!19 = !{!"_ZTSSt3mapImN3qpl2ml4util10bitmask128ESt4lessImESaISt4pairIKmS3_EEE", !20, i64 0}
!20 = !{!"_ZTSSt8_Rb_treeImSt4pairIKmN3qpl2ml4util10bitmask128EESt10_Select1stIS6_ESt4lessImESaIS6_EE", !21, i64 0}
!21 = !{!"_ZTSNSt8_Rb_treeImSt4pairIKmN3qpl2ml4util10bitmask128EESt10_Select1stIS6_ESt4lessImESaIS6_EE13_Rb_tree_implISA_Lb1EEE", !22, i64 0, !24, i64 8}
!22 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessImEE", !23, i64 0}
!23 = !{!"_ZTSSt4lessImE"}
!24 = !{!"_ZTSSt15_Rb_tree_header", !25, i64 0, !11, i64 32}
!25 = !{!"_ZTSSt18_Rb_tree_node_base", !26, i64 0, !15, i64 8, !15, i64 16, !15, i64 24}
!26 = !{!"_ZTSSt14_Rb_tree_color", !8, i64 0}
!27 = !{!6, !11, i64 9640}


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