; LLVM IR from intel/qpl :: tools/utils/hw_dispatcher/test_hw_queue.ll (ZN3qpl4test8hw_queue20initialize_new_queueEPv)

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

%struct.accfg_op_config = type { [8 x i32] }
%"class.qpl::test::hw_queue" = type { ptr, i32, i8, %"struct.std::array", i64, i64 }
%"struct.std::array" = type { [8 x i32] }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN3qpl4test8hw_queue20initialize_new_queueEPv(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef %1) #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [64 x i8], align 16
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %struct.accfg_op_config, align 4
  %11 = alloca i32, align 4
  %12 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %14, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %7) #4
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = invoke i32 @qpl_test_accfg_wq_get_state(ptr noundef %15)
          to label %17 unwind label %79

17:                                               ; preds = %2
  %18 = icmp ne i32 1, %16
  br i1 %18, label %19, label %20

19:                                               ; preds = %17
  store i32 4, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %77

20:                                               ; preds = %17
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = invoke i32 @qpl_test_accfg_wq_get_mode(ptr noundef %21)
          to label %23 unwind label %79

23:                                               ; preds = %20
  %24 = icmp ne i32 0, %22
  br i1 %24, label %25, label %26

25:                                               ; preds = %23
  store i32 4, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %77

26:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds [64 x i8], ptr %7, i64 0, i64 0
  %29 = invoke i32 @qpl_test_accfg_wq_get_user_dev_path(ptr noundef %27, ptr noundef %28, i64 noundef 63)
          to label %30 unwind label %79

30:                                               ; preds = %26
  store i32 %29, ptr %9, align 4, !tbaa !9
  %31 = load i32, ptr %9, align 4, !tbaa !9
  %32 = icmp sgt i32 0, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  store i32 3, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %76

34:                                               ; preds = %30
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = invoke i32 @qpl_test_accfg_wq_get_priority(ptr noundef %35)
          to label %37 unwind label %79

37:                                               ; preds = %34
  %38 = getelementptr inbounds %"class.qpl::test::hw_queue", ptr %13, i32 0, i32 1
  store i32 %36, ptr %38, align 8, !tbaa !11
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = invoke i64 @qpl_test_accfg_wq_get_size(ptr noundef %39)
          to label %41 unwind label %79

41:                                               ; preds = %37
  %42 = getelementptr inbounds %"class.qpl::test::hw_queue", ptr %13, i32 0, i32 4
  store i64 %40, ptr %42, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = invoke i32 @qpl_test_accfg_wq_get_op_config(ptr noundef %43, ptr noundef %10)
          to label %45 unwind label %79

45:                                               ; preds = %41
  store i32 %44, ptr %11, align 4, !tbaa !9
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %50

48:                                               ; preds = %45
  %49 = getelementptr inbounds %"class.qpl::test::hw_queue", ptr %13, i32 0, i32 2
  store i8 0, ptr %49, align 4, !tbaa !17
  br label %71

50:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  store i8 0, ptr %12, align 1, !tbaa !18
  br label %51

51:                                               ; preds = %66, %50
  %52 = load i8, ptr %12, align 1, !tbaa !18
  %53 = zext i8 %52 to i32
  %54 = icmp ult i32 %53, 8
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  br label %69

56:                                               ; preds = %51
  %57 = getelementptr inbounds %struct.accfg_op_config, ptr %10, i32 0, i32 0
  %58 = load i8, ptr %12, align 1, !tbaa !18
  %59 = zext i8 %58 to i64
  %60 = getelementptr inbounds [8 x i32], ptr %57, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !9
  %62 = getelementptr inbounds %"class.qpl::test::hw_queue", ptr %13, i32 0, i32 3
  %63 = load i8, ptr %12, align 1, !tbaa !18
  %64 = zext i8 %63 to i64
  %65 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %62, i64 noundef %64) #4
  store i32 %61, ptr %65, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %56
  %67 = load i8, ptr %12, align 1, !tbaa !18
  %68 = add i8 %67, 1
  store i8 %68, ptr %12, align 1, !tbaa !18
  br label %51, !llvm.loop !19

69:                                               ; preds = %55
  %70 = getelementptr inbounds %"class.qpl::test::hw_queue", ptr %13, i32 0, i32 2
  store i8 1, ptr %70, align 4, !tbaa !17
  br label %71

71:                                               ; preds = %69, %48
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = invoke i64 @qpl_test_accfg_wq_get_max_transfer_size(ptr noundef %72)
          to label %74 unwind label %79

74:                                               ; preds = %71
  %75 = getelementptr inbounds %"class.qpl::test::hw_queue", ptr %13, i32 0, i32 5
  store i64 %73, ptr %75, align 8, !tbaa !21
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #4
  br label %76

76:                                               ; preds = %74, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %77

77:                                               ; preds = %76, %25, %19
  call void @llvm.lifetime.end.p0(i64 64, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %78 = load i32, ptr %3, align 4
  ret i32 %78

79:                                               ; preds = %71, %41, %37, %34, %26, %20, %2
  %80 = landingpad { ptr, i32 }
          catch ptr null
  %81 = extractvalue { ptr, i32 } %80, 0
  call void @__clang_call_terminate(ptr %81) #5
  unreachable
}

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

declare i32 @qpl_test_accfg_wq_get_state(ptr noundef) #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #3

declare i32 @qpl_test_accfg_wq_get_mode(ptr noundef) #2

declare i32 @qpl_test_accfg_wq_get_user_dev_path(ptr noundef, ptr noundef, i64 noundef) #2

declare i32 @qpl_test_accfg_wq_get_priority(ptr noundef) #2

declare i64 @qpl_test_accfg_wq_get_size(ptr noundef) #2

declare i32 @qpl_test_accfg_wq_get_op_config(ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32), i64 noundef) #0 align 2

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

declare i64 @qpl_test_accfg_wq_get_max_transfer_size(ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { noinline noreturn nounwind uwtable "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 #4 = { nounwind }
attributes #5 = { noreturn 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, !10, i64 8}
!12 = !{!"_ZTSN3qpl4test8hw_queueE", !10, i64 8, !13, i64 12, !14, i64 16, !15, i64 48, !15, i64 56}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSSt5arrayIjLm8EE", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!12, !15, i64 48}
!17 = !{!12, !13, i64 12}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!12, !15, i64 56}


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

%struct.accfg_op_config = type { [8 x i32] }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 5) i32 @_ZN3qpl4test8hw_queue20initialize_new_queueEPv(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef %1) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca [64 x i8], align 16
  %4 = alloca %struct.accfg_op_config, align 4
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %3) #4
  %5 = invoke i32 @qpl_test_accfg_wq_get_state(ptr noundef %1)
          to label %6 unwind label %53

6:                                                ; preds = %2
  %.not = icmp eq i32 %5, 1
  br i1 %.not, label %7, label %52

7:                                                ; preds = %6
  %8 = invoke i32 @qpl_test_accfg_wq_get_mode(ptr noundef %1)
          to label %9 unwind label %53

9:                                                ; preds = %7
  %.not16 = icmp eq i32 %8, 0
  br i1 %.not16, label %10, label %52

10:                                               ; preds = %9
  %11 = invoke i32 @qpl_test_accfg_wq_get_user_dev_path(ptr noundef %1, ptr noundef nonnull %3, i64 noundef 63)
          to label %12 unwind label %53

12:                                               ; preds = %10
  %13 = icmp slt i32 %11, 0
  br i1 %13, label %52, label %14

14:                                               ; preds = %12
  %15 = invoke i32 @qpl_test_accfg_wq_get_priority(ptr noundef %1)
          to label %16 unwind label %53

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %15, ptr %17, align 8, !tbaa !5
  %18 = invoke i64 @qpl_test_accfg_wq_get_size(ptr noundef %1)
          to label %19 unwind label %53

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %0, i64 48
  store i64 %18, ptr %20, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #4
  %21 = invoke i32 @qpl_test_accfg_wq_get_op_config(ptr noundef %1, ptr noundef nonnull %4)
          to label %22 unwind label %53

22:                                               ; preds = %19
  %.not17 = icmp eq i32 %21, 0
  br i1 %.not17, label %.preheader, label %47

.preheader:                                       ; preds = %22
  %23 = getelementptr inbounds i8, ptr %0, i64 16
  %24 = load i32, ptr %4, align 4, !tbaa !14
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %23, i64 noundef 0) #4
  store i32 %24, ptr %25, align 4, !tbaa !14
  %26 = getelementptr inbounds i8, ptr %4, i64 4
  %27 = load i32, ptr %26, align 4, !tbaa !14
  %28 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %23, i64 noundef 1) #4
  store i32 %27, ptr %28, align 4, !tbaa !14
  %29 = getelementptr inbounds i8, ptr %4, i64 8
  %30 = load i32, ptr %29, align 4, !tbaa !14
  %31 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %23, i64 noundef 2) #4
  store i32 %30, ptr %31, align 4, !tbaa !14
  %32 = getelementptr inbounds i8, ptr %4, i64 12
  %33 = load i32, ptr %32, align 4, !tbaa !14
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %23, i64 noundef 3) #4
  store i32 %33, ptr %34, align 4, !tbaa !14
  %35 = getelementptr inbounds i8, ptr %4, i64 16
  %36 = load i32, ptr %35, align 4, !tbaa !14
  %37 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %23, i64 noundef 4) #4
  store i32 %36, ptr %37, align 4, !tbaa !14
  %38 = getelementptr inbounds i8, ptr %4, i64 20
  %39 = load i32, ptr %38, align 4, !tbaa !14
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %23, i64 noundef 5) #4
  store i32 %39, ptr %40, align 4, !tbaa !14
  %41 = getelementptr inbounds i8, ptr %4, i64 24
  %42 = load i32, ptr %41, align 4, !tbaa !14
  %43 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %23, i64 noundef 6) #4
  store i32 %42, ptr %43, align 4, !tbaa !14
  %44 = getelementptr inbounds i8, ptr %4, i64 28
  %45 = load i32, ptr %44, align 4, !tbaa !14
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %23, i64 noundef 7) #4
  store i32 %45, ptr %46, align 4, !tbaa !14
  br label %47

47:                                               ; preds = %22, %.preheader
  %.sink = phi i8 [ 1, %.preheader ], [ 0, %22 ]
  %48 = getelementptr inbounds i8, ptr %0, i64 12
  store i8 %.sink, ptr %48, align 4, !tbaa !15
  %49 = invoke i64 @qpl_test_accfg_wq_get_max_transfer_size(ptr noundef %1)
          to label %50 unwind label %53

50:                                               ; preds = %47
  %51 = getelementptr inbounds i8, ptr %0, i64 56
  store i64 %49, ptr %51, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  br label %52

52:                                               ; preds = %50, %12, %9, %6
  %.1 = phi i32 [ 4, %6 ], [ 4, %9 ], [ 0, %50 ], [ 3, %12 ]
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #4
  ret i32 %.1

53:                                               ; preds = %47, %19, %16, %14, %10, %7, %2
  %54 = landingpad { ptr, i32 }
          catch ptr null
  %55 = extractvalue { ptr, i32 } %54, 0
  call void @__clang_call_terminate(ptr %55) #5
  unreachable
}

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

declare i32 @qpl_test_accfg_wq_get_state(ptr noundef) local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #3

declare i32 @qpl_test_accfg_wq_get_mode(ptr noundef) local_unnamed_addr #2

declare i32 @qpl_test_accfg_wq_get_user_dev_path(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare i32 @qpl_test_accfg_wq_get_priority(ptr noundef) local_unnamed_addr #2

declare i64 @qpl_test_accfg_wq_get_size(ptr noundef) local_unnamed_addr #2

declare i32 @qpl_test_accfg_wq_get_op_config(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

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

declare i64 @qpl_test_accfg_wq_get_max_transfer_size(ptr noundef) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { noinline noreturn nounwind uwtable "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 #4 = { nounwind }
attributes #5 = { noreturn 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, !7, i64 8}
!6 = !{!"_ZTSN3qpl4test8hw_queueE", !7, i64 8, !10, i64 12, !11, i64 16, !12, i64 48, !12, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSSt5arrayIjLm8EE", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!6, !12, i64 48}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !10, i64 12}
!16 = !{!6, !12, i64 56}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass