; LLVM IR from openssl/openssl :: crypto/ml_dsa (ml_dsa_key_compress)

; 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: 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
declare dso_local void @ossl_ml_dsa_key_compress_decompose(i32 noundef, i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_ml_dsa_key_compress_use_hint(i32 noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %11 = load i32, ptr %6, align 4, !tbaa !5
  %12 = load i32, ptr %7, align 4, !tbaa !5
  call void @ossl_ml_dsa_key_compress_decompose(i32 noundef %11, i32 noundef %12, ptr noundef %8, ptr noundef %9)
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %17

15:                                               ; preds = %3
  %16 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %16, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %54

17:                                               ; preds = %3
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = icmp eq i32 %18, 261888
  br i1 %19, label %20, label %33

20:                                               ; preds = %17
  %21 = load i32, ptr %9, align 4, !tbaa !5
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %27

23:                                               ; preds = %20
  %24 = load i32, ptr %8, align 4, !tbaa !5
  %25 = add i32 %24, 1
  %26 = and i32 %25, 15
  br label %31

27:                                               ; preds = %20
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = sub i32 %28, 1
  %30 = and i32 %29, 15
  br label %31

31:                                               ; preds = %27, %23
  %32 = phi i32 [ %26, %23 ], [ %30, %27 ]
  store i32 %32, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %54

33:                                               ; preds = %17
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = icmp sgt i32 %34, 0
  br i1 %35, label %36, label %45

36:                                               ; preds = %33
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = icmp eq i32 %37, 43
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  br label %43

40:                                               ; preds = %36
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = add i32 %41, 1
  br label %43

43:                                               ; preds = %40, %39
  %44 = phi i32 [ 0, %39 ], [ %42, %40 ]
  store i32 %44, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %54

45:                                               ; preds = %33
  %46 = load i32, ptr %8, align 4, !tbaa !5
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %45
  br label %52

49:                                               ; preds = %45
  %50 = load i32, ptr %8, align 4, !tbaa !5
  %51 = sub i32 %50, 1
  br label %52

52:                                               ; preds = %49, %48
  %53 = phi i32 [ 43, %48 ], [ %51, %49 ]
  store i32 %53, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %54

54:                                               ; preds = %52, %43, %31, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %55 = load i32, ptr %4, align 4
  ret i32 %55
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @ossl_ml_dsa_key_compress_decompose(i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_ml_dsa_key_compress_use_hint(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #2
  call void @ossl_ml_dsa_key_compress_decompose(i32 noundef %1, i32 noundef %2, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %6 = icmp eq i32 %0, 0
  br i1 %6, label %7, label %9

7:                                                ; preds = %3
  %8 = load i32, ptr %4, align 4, !tbaa !5
  br label %26

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

12:                                               ; preds = %9
  %13 = load i32, ptr %4, align 4
  %.inv = icmp slt i32 %11, 1
  %.in.v = select i1 %.inv, i32 15, i32 1
  %.in = add i32 %.in.v, %13
  %14 = and i32 %.in, 15
  br label %26

15:                                               ; preds = %9
  %16 = icmp sgt i32 %11, 0
  %17 = load i32, ptr %4, align 4
  br i1 %16, label %18, label %22

18:                                               ; preds = %15
  %19 = icmp eq i32 %17, 43
  %20 = add i32 %17, 1
  %21 = select i1 %19, i32 0, i32 %20
  br label %26

22:                                               ; preds = %15
  %23 = icmp eq i32 %17, 0
  %24 = add i32 %17, -1
  %25 = select i1 %23, i32 43, i32 %24
  br label %26

26:                                               ; preds = %22, %18, %12, %7
  %.0 = phi i32 [ %8, %7 ], [ %14, %12 ], [ %21, %18 ], [ %25, %22 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #2
  ret i32 %.0
}

attributes #0 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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