; LLVM IR from openssl/openssl :: crypto/slh_dsa (slh_dsa)

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

@.str = external hidden unnamed_addr constant [74 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_slh_dsa_sign(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i32 noundef %6, ptr noundef %7, ptr noundef %8, i64 noundef %9) #0 {
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca [1024 x i8], align 16
  %23 = alloca ptr, align 8
  %24 = alloca i64, align 8
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  store ptr %0, ptr %12, align 8, !tbaa !5
  store ptr %1, ptr %13, align 8, !tbaa !5
  store i64 %2, ptr %14, align 8, !tbaa !9
  store ptr %3, ptr %15, align 8, !tbaa !5
  store i64 %4, ptr %16, align 8, !tbaa !9
  store ptr %5, ptr %17, align 8, !tbaa !5
  store i32 %6, ptr %18, align 4, !tbaa !11
  store ptr %7, ptr %19, align 8, !tbaa !5
  store ptr %8, ptr %20, align 8, !tbaa !5
  store i64 %9, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1024, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #3
  %27 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 0
  store ptr %27, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #3
  store i64 0, ptr %24, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #3
  store i32 0, ptr %25, align 4, !tbaa !11
  %28 = load ptr, ptr %19, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %42

30:                                               ; preds = %10
  %31 = load ptr, ptr %13, align 8, !tbaa !5
  %32 = load i64, ptr %14, align 8, !tbaa !9
  %33 = load ptr, ptr %15, align 8, !tbaa !5
  %34 = load i64, ptr %16, align 8, !tbaa !9
  %35 = load i32, ptr %18, align 4, !tbaa !11
  %36 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 0
  %37 = call ptr @msg_encode(ptr noundef %31, i64 noundef %32, ptr noundef %33, i64 noundef %34, i32 noundef %35, ptr noundef %36, i64 noundef 1024, ptr noundef %24)
  store ptr %37, ptr %23, align 8, !tbaa !5
  %38 = load ptr, ptr %23, align 8, !tbaa !5
  %39 = icmp eq ptr %38, null
  br i1 %39, label %40, label %41

40:                                               ; preds = %30
  store i32 0, ptr %11, align 4
  store i32 1, ptr %26, align 4
  br label %62

41:                                               ; preds = %30
  br label %42

42:                                               ; preds = %41, %10
  %43 = load ptr, ptr %12, align 8, !tbaa !5
  %44 = load ptr, ptr %23, align 8, !tbaa !5
  %45 = load i64, ptr %24, align 8, !tbaa !9
  %46 = load ptr, ptr %19, align 8, !tbaa !5
  %47 = load ptr, ptr %20, align 8, !tbaa !5
  %48 = load i64, ptr %21, align 8, !tbaa !9
  %49 = load ptr, ptr %17, align 8, !tbaa !5
  %50 = call i32 @slh_sign_internal(ptr noundef %43, ptr noundef %44, i64 noundef %45, ptr noundef %46, ptr noundef %47, i64 noundef %48, ptr noundef %49)
  store i32 %50, ptr %25, align 4, !tbaa !11
  %51 = load ptr, ptr %23, align 8, !tbaa !5
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = icmp ne ptr %51, %52
  br i1 %53, label %54, label %60

54:                                               ; preds = %42
  %55 = load ptr, ptr %23, align 8, !tbaa !5
  %56 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 0
  %57 = icmp ne ptr %55, %56
  br i1 %57, label %58, label %60

58:                                               ; preds = %54
  %59 = load ptr, ptr %23, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %59, ptr noundef @.str, i32 noundef 285)
  br label %60

60:                                               ; preds = %58, %54, %42
  %61 = load i32, ptr %25, align 4, !tbaa !11
  store i32 %61, ptr %11, align 4
  store i32 1, ptr %26, align 4
  br label %62

62:                                               ; preds = %60, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 1024, ptr %22) #3
  %63 = load i32, ptr %11, align 4
  ret i32 %63
}

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

; Function Attrs: nounwind uwtable
declare hidden ptr @msg_encode(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @slh_sign_internal(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) #0

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) #2

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

attributes #0 = { 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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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"

@.str = external hidden unnamed_addr constant [74 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_slh_dsa_sign(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i32 noundef %6, ptr noundef %7, ptr noundef %8, i64 noundef %9) local_unnamed_addr #0 {
  %11 = alloca [1024 x i8], align 16
  %12 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #3
  store i64 0, ptr %12, align 8, !tbaa !5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %16, label %13

13:                                               ; preds = %10
  %14 = call ptr @msg_encode(ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, i32 noundef %6, ptr noundef nonnull %11, i64 noundef 1024, ptr noundef nonnull %12)
  %15 = icmp eq ptr %14, null
  br i1 %15, label %22, label %._crit_edge

._crit_edge:                                      ; preds = %13
  %.pre = load i64, ptr %12, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %._crit_edge, %10
  %17 = phi i64 [ %.pre, %._crit_edge ], [ 0, %10 ]
  %.0 = phi ptr [ %14, %._crit_edge ], [ %11, %10 ]
  %18 = call i32 @slh_sign_internal(ptr noundef %0, ptr noundef nonnull %.0, i64 noundef %17, ptr noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %5)
  %19 = icmp ne ptr %.0, %1
  %20 = icmp ne ptr %.0, %11
  %or.cond = and i1 %19, %20
  br i1 %or.cond, label %21, label %22

21:                                               ; preds = %16
  call void @CRYPTO_free(ptr noundef nonnull %.0, ptr noundef nonnull @.str, i32 noundef 285) #3
  br label %22

22:                                               ; preds = %16, %21, %13
  %.020 = phi i32 [ 0, %13 ], [ %18, %21 ], [ %18, %16 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #3
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %11) #3
  ret i32 %.020
}

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

; Function Attrs: nounwind uwtable
declare hidden ptr @msg_encode(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @slh_sign_internal(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

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


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