; LLVM IR from intel/qpl :: sources/core-iaa/sources/descriptors (hw_compress_descriptor)

; 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.hw_compress_descriptor = type { i32, i32, ptr, ptr, ptr, i32, i16, i16, ptr, i32, i32, i32, [4 x i8] }

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

declare void @call_c_set_zeros_uint8_t(ptr noundef, i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @hw_iaa_descriptor_init_statistic_collector_with_header_gen(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i8 noundef zeroext %4, i32 noundef %5, i32 noundef %6) #2 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i8 %4, ptr %12, align 1, !tbaa !11
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %16, ptr %15, align 8, !tbaa !5
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = load ptr, ptr %15, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %18, i32 0, i32 3
  store ptr %17, ptr %19, align 1, !tbaa !12
  %20 = load i32, ptr %10, align 4, !tbaa !9
  %21 = load ptr, ptr %15, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %21, i32 0, i32 5
  store i32 %20, ptr %22, align 1, !tbaa !15
  %23 = load ptr, ptr %15, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %23, i32 0, i32 4
  store ptr null, ptr %24, align 1, !tbaa !16
  %25 = load ptr, ptr %15, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %25, i32 0, i32 9
  store i32 0, ptr %26, align 1, !tbaa !17
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = load ptr, ptr %15, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %28, i32 0, i32 8
  store ptr %27, ptr %29, align 1, !tbaa !18
  %30 = load ptr, ptr %15, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %30, i32 0, i32 10
  store i32 1568, ptr %31, align 1, !tbaa !19
  %32 = load ptr, ptr %15, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %32, i32 0, i32 12
  %34 = getelementptr inbounds [4 x i8], ptr %33, i64 0, i64 0
  call void @call_c_set_zeros_uint8_t(ptr noundef %34, i32 noundef 4)
  %35 = load ptr, ptr %15, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %35, i32 0, i32 1
  store i32 1124073472, ptr %36, align 1, !tbaa !20
  %37 = load i32, ptr %14, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 0
  %39 = zext i1 %38 to i64
  %40 = select i1 %38, i32 0, i32 65536
  %41 = load ptr, ptr %15, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 1, !tbaa !20
  %44 = or i32 %43, %40
  store i32 %44, ptr %42, align 1, !tbaa !20
  %45 = load ptr, ptr %15, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %45, i32 0, i32 1
  %47 = load i32, ptr %46, align 1, !tbaa !20
  %48 = or i32 %47, 262144
  store i32 %48, ptr %46, align 1, !tbaa !20
  %49 = load i8, ptr %12, align 1, !tbaa !11
  %50 = zext i8 %49 to i32
  %51 = icmp ne i32 %50, 0
  %52 = zext i1 %51 to i64
  %53 = select i1 %51, i32 4194304, i32 0
  %54 = load ptr, ptr %15, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 1, !tbaa !20
  %57 = or i32 %56, %53
  store i32 %57, ptr %55, align 1, !tbaa !20
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %69

60:                                               ; preds = %7
  %61 = load ptr, ptr %15, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %61, i32 0, i32 7
  store i16 28672, ptr %62, align 1, !tbaa !21
  %63 = load ptr, ptr %15, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %63, i32 0, i32 7
  %65 = load i16, ptr %64, align 1, !tbaa !21
  %66 = zext i16 %65 to i32
  %67 = or i32 %66, 2
  %68 = trunc i32 %67 to i16
  store i16 %68, ptr %64, align 1, !tbaa !21
  br label %72

69:                                               ; preds = %7
  %70 = load ptr, ptr %15, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %70, i32 0, i32 7
  store i16 24576, ptr %71, align 1, !tbaa !21
  br label %72

72:                                               ; preds = %69, %60
  %73 = load ptr, ptr %15, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %73, i32 0, i32 11
  store i32 2, ptr %74, align 1, !tbaa !22
  %75 = load ptr, ptr %15, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %75, i32 0, i32 0
  store i32 0, ptr %76, align 1, !tbaa !23
  %77 = load ptr, ptr %15, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %77, i32 0, i32 1
  %79 = load i32, ptr %78, align 1, !tbaa !20
  %80 = and i32 %79, 8
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %85, label %82

82:                                               ; preds = %72
  %83 = load ptr, ptr %15, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %83, i32 0, i32 6
  store i16 0, ptr %84, align 1, !tbaa !24
  br label %85

85:                                               ; preds = %82, %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 16}
!13 = !{!"", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !14, i64 36, !14, i64 38, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !7, i64 60}
!14 = !{!"short", !7, i64 0}
!15 = !{!13, !10, i64 32}
!16 = !{!13, !6, i64 24}
!17 = !{!13, !10, i64 48}
!18 = !{!13, !6, i64 40}
!19 = !{!13, !10, i64 52}
!20 = !{!13, !10, i64 4}
!21 = !{!13, !14, i64 38}
!22 = !{!13, !10, i64 56}
!23 = !{!13, !10, i64 0}
!24 = !{!13, !14, i64 36}


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

declare void @call_c_set_zeros_uint8_t(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @hw_iaa_descriptor_init_statistic_collector_with_header_gen(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i8 noundef zeroext %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #1 {
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %1, ptr %8, align 1, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 %2, ptr %9, align 1, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr null, ptr %10, align 1, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 0, ptr %11, align 1, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %3, ptr %12, align 1, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 1568, ptr %13, align 1, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %0, i64 60
  tail call void @call_c_set_zeros_uint8_t(ptr noundef nonnull %14, i32 noundef 4) #2
  %15 = getelementptr inbounds i8, ptr %0, i64 4
  %.not = icmp eq i32 %6, 0
  %16 = select i1 %.not, i32 1124401152, i32 1124335616
  %.not24 = icmp eq i8 %4, 0
  %17 = select i1 %.not24, i32 0, i32 4194304
  %18 = or disjoint i32 %16, %17
  store i32 %18, ptr %15, align 1, !tbaa !17
  %.not25 = icmp eq i32 %5, 0
  %spec.select = select i1 %.not25, i16 24576, i16 28674
  %19 = getelementptr inbounds i8, ptr %0, i64 38
  store i16 %spec.select, ptr %19, align 1
  %20 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 2, ptr %20, align 1, !tbaa !18
  store i32 0, ptr %0, align 1, !tbaa !19
  %21 = getelementptr inbounds i8, ptr %0, i64 36
  store i16 0, ptr %21, align 1, !tbaa !20
  ret void
}

attributes #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 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, !10, i64 16}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !7, i64 32, !11, i64 36, !11, i64 38, !10, i64 40, !7, i64 48, !7, i64 52, !7, i64 56, !8, i64 60}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!6, !7, i64 32}
!13 = !{!6, !10, i64 24}
!14 = !{!6, !7, i64 48}
!15 = !{!6, !10, i64 40}
!16 = !{!6, !7, i64 52}
!17 = !{!6, !7, i64 4}
!18 = !{!6, !7, i64 56}
!19 = !{!6, !7, i64 0}
!20 = !{!6, !11, i64 36}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass