; 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

; 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_set_1_pass_header_gen(ptr noundef %0, ptr noundef %1, i8 noundef zeroext %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i8 %2, ptr %8, align 1, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !10
  store i32 %4, ptr %10, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %12, ptr %11, align 8, !tbaa !5
  %13 = load i32, ptr %10, align 4, !tbaa !10
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %23

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

18:                                               ; preds = %15
  %19 = load ptr, ptr %11, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %19, i32 0, i32 8
  store ptr null, ptr %20, align 1, !tbaa !12
  %21 = load ptr, ptr %11, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %21, i32 0, i32 10
  store i32 0, ptr %22, align 1, !tbaa !15
  br label %29

23:                                               ; preds = %15, %5
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %25, i32 0, i32 8
  store ptr %24, ptr %26, align 1, !tbaa !12
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %27, i32 0, i32 10
  store i32 1568, ptr %28, align 1, !tbaa !15
  br label %29

29:                                               ; preds = %23, %18
  %30 = load i8, ptr %8, align 1, !tbaa !9
  %31 = zext i8 %30 to i32
  %32 = icmp ne i32 %31, 0
  %33 = zext i1 %32 to i64
  %34 = select i1 %32, i32 4194304, i32 0
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 1, !tbaa !16
  %38 = or i32 %37, %34
  store i32 %38, ptr %36, align 1, !tbaa !16
  %39 = load i32, ptr %9, align 4, !tbaa !10
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %54

41:                                               ; preds = %29
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %42, i32 0, i32 7
  %44 = load i16, ptr %43, align 1, !tbaa !17
  %45 = zext i16 %44 to i32
  %46 = or i32 %45, 12288
  %47 = trunc i32 %46 to i16
  store i16 %47, ptr %43, align 1, !tbaa !17
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %48, i32 0, i32 7
  %50 = load i16, ptr %49, align 1, !tbaa !17
  %51 = zext i16 %50 to i32
  %52 = or i32 %51, 2
  %53 = trunc i32 %52 to i16
  store i16 %53, ptr %49, align 1, !tbaa !17
  br label %61

54:                                               ; preds = %29
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %55, i32 0, i32 7
  %57 = load i16, ptr %56, align 1, !tbaa !17
  %58 = zext i16 %57 to i32
  %59 = or i32 %58, 8192
  %60 = trunc i32 %59 to i16
  store i16 %60, ptr %56, align 1, !tbaa !17
  br label %61

61:                                               ; preds = %54, %41
  %62 = load i32, ptr %10, align 4, !tbaa !10
  %63 = icmp ne i32 %62, 0
  %64 = zext i1 %63 to i64
  %65 = select i1 %63, i32 0, i32 65536
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %66, i32 0, i32 1
  %68 = load i32, ptr %67, align 1, !tbaa !16
  %69 = or i32 %68, %65
  store i32 %69, ptr %67, align 1, !tbaa !16
  %70 = load i32, ptr %9, align 4, !tbaa !10
  %71 = icmp ne i32 %70, 0
  %72 = zext i1 %71 to i64
  %73 = select i1 %71, i32 0, i32 262144
  %74 = load ptr, ptr %11, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %74, i32 0, i32 1
  %76 = load i32, ptr %75, align 1, !tbaa !16
  %77 = or i32 %76, %73
  store i32 %77, ptr %75, align 1, !tbaa !16
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.hw_compress_descriptor, ptr %78, i32 0, i32 11
  store i32 0, ptr %79, align 1, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  ret void
}

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @hw_iaa_descriptor_set_1_pass_header_gen(ptr nocapture noundef %0, ptr noundef %1, i8 noundef zeroext %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = icmp ne i32 %4, 0
  %7 = icmp ne i32 %3, 0
  %or.cond = and i1 %7, %6
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = getelementptr inbounds i8, ptr %0, i64 52
  %.not19 = icmp eq i8 %2, 0
  %10 = select i1 %.not19, i32 0, i32 4194304
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  br i1 %or.cond, label %.thread, label %14

.thread:                                          ; preds = %5
  store ptr null, ptr %8, align 1, !tbaa !5
  store i32 0, ptr %9, align 1, !tbaa !12
  %12 = load i32, ptr %11, align 1, !tbaa !13
  %13 = or i32 %12, %10
  store i32 %13, ptr %11, align 1, !tbaa !13
  br label %17

14:                                               ; preds = %5
  store ptr %1, ptr %8, align 1, !tbaa !5
  store i32 1568, ptr %9, align 1, !tbaa !12
  %15 = load i32, ptr %11, align 1, !tbaa !13
  %16 = or i32 %15, %10
  store i32 %16, ptr %11, align 1, !tbaa !13
  %spec.select = select i1 %7, i16 12290, i16 8192
  %spec.select23 = select i1 %7, i32 0, i32 262144
  br label %17

17:                                               ; preds = %14, %.thread
  %.sink22 = phi i16 [ 12290, %.thread ], [ %spec.select, %14 ]
  %18 = phi i32 [ %13, %.thread ], [ %16, %14 ]
  %19 = phi i32 [ 0, %.thread ], [ %spec.select23, %14 ]
  %20 = getelementptr inbounds i8, ptr %0, i64 38
  %21 = load i16, ptr %20, align 1, !tbaa !14
  %22 = or i16 %21, %.sink22
  store i16 %22, ptr %20, align 1, !tbaa !14
  %23 = select i1 %6, i32 0, i32 65536
  %24 = or i32 %18, %23
  %25 = or i32 %24, %19
  store i32 %25, ptr %11, align 1, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 0, ptr %26, align 1, !tbaa !15
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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" }

!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 40}
!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 52}
!13 = !{!6, !7, i64 4}
!14 = !{!6, !11, i64 38}
!15 = !{!6, !7, i64 56}


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