; LLVM IR from intel/qpl :: sources/core-sw/dispatcher/dispatcher.ll (ZN3qpl7core_sw10dispatcher15detect_platformEv)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5cpuidPii(ptr noundef, i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z7_xgetbvj(i32 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i8 @_ZN3qpl7core_sw10dispatcher15detect_platformEv() #0 {
  %1 = alloca i8, align 1
  %2 = alloca [4 x i32], align 16
  %3 = alloca i8, align 1
  %4 = alloca i8, align 1
  %5 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %1) #2
  store i8 0, ptr %1, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #2
  %6 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 0
  call void @_Z5cpuidPii(ptr noundef %6, i32 noundef 7)
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #2
  %7 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 1
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = and i32 %8, -805109760
  %10 = icmp eq i32 %9, -805109760
  %11 = zext i1 %10 to i8
  store i8 %11, ptr %3, align 1, !tbaa !11
  %12 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 0
  call void @_Z5cpuidPii(ptr noundef %12, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  %13 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 2
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = and i32 %14, 134217728
  %16 = icmp ne i32 %15, 0
  %17 = zext i1 %16 to i8
  store i8 %17, ptr %4, align 1, !tbaa !11
  %18 = load i8, ptr %4, align 1, !tbaa !11, !range !13, !noundef !14
  %19 = trunc i8 %18 to i1
  br i1 %19, label %20, label %36

20:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %21 = call noundef i64 @_Z7_xgetbvj(i32 noundef 0)
  store i64 %21, ptr %5, align 8, !tbaa !15
  %22 = load i64, ptr %5, align 8, !tbaa !15
  %23 = and i64 %22, 224
  %24 = icmp eq i64 %23, 224
  br i1 %24, label %25, label %35

25:                                               ; preds = %20
  %26 = load i64, ptr %5, align 8, !tbaa !15
  %27 = and i64 %26, 6
  %28 = icmp eq i64 %27, 6
  br i1 %28, label %29, label %34

29:                                               ; preds = %25
  %30 = load i8, ptr %3, align 1, !tbaa !11, !range !13, !noundef !14
  %31 = trunc i8 %30 to i1
  br i1 %31, label %32, label %33

32:                                               ; preds = %29
  store i8 2, ptr %1, align 1, !tbaa !5
  br label %33

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

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

35:                                               ; preds = %34, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %36

36:                                               ; preds = %35, %0
  %37 = load i8, ptr %1, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %1) #2
  ret i8 %37
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"_ZTSN3qpl7core_sw10dispatcher6arch_tE", !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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"long long", !7, i64 0}


; 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
declare dso_local void @_Z5cpuidPii(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z7_xgetbvj(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext range(i8 0, 3) i8 @_ZN3qpl7core_sw10dispatcher15detect_platformEv() local_unnamed_addr #0 {
  %1 = alloca [4 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #2
  call void @_Z5cpuidPii(ptr noundef nonnull %1, i32 noundef 7)
  %2 = getelementptr inbounds i8, ptr %1, i64 4
  %3 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z5cpuidPii(ptr noundef nonnull %1, i32 noundef 1)
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = and i32 %5, 134217728
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %13, label %7

7:                                                ; preds = %0
  %8 = and i32 %3, -805109760
  %9 = icmp eq i32 %8, -805109760
  %10 = call noundef i64 @_Z7_xgetbvj(i32 noundef 0)
  %11 = and i64 %10, 230
  %or.cond = icmp eq i64 %11, 230
  %12 = select i1 %or.cond, i1 %9, i1 false
  %spec.select6 = select i1 %12, i8 2, i8 0
  br label %13

13:                                               ; preds = %7, %0
  %.1 = phi i8 [ 0, %0 ], [ %spec.select6, %7 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #2
  ret i8 %.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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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