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

; 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.slh_dsa_key_st = type { [128 x i8], ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.slh_dsa_params_st = type { ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64 }

@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; 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

declare void @OPENSSL_cleanse(ptr noundef, i64 noundef) #1

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

17:                                               ; preds = %3
  store i32 0, ptr %4, align 4
  store i32 1, ptr %14, align 4
  br label %107

18:                                               ; preds = %3
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call i64 @ossl_slh_dsa_key_get_priv_len(ptr noundef %19)
  store i64 %20, ptr %8, align 8, !tbaa !11
  %21 = load i64, ptr %8, align 8, !tbaa !11
  %22 = lshr i64 %21, 1
  store i64 %22, ptr %9, align 8, !tbaa !11
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %68

25:                                               ; preds = %18
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call ptr @OSSL_PARAM_locate_const(ptr noundef %26, ptr noundef @.str.1)
  store ptr %27, ptr %11, align 8, !tbaa !5
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %67

30:                                               ; preds = %25
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds [128 x i8], ptr %32, i64 0, i64 0
  store ptr %33, ptr %13, align 8, !tbaa !5
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = load i64, ptr %8, align 8, !tbaa !11
  %36 = call i32 @OSSL_PARAM_get_octet_string(ptr noundef %34, ptr noundef %13, i64 noundef %35, ptr noundef %10)
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %39, label %38

38:                                               ; preds = %30
  store i32 0, ptr %4, align 4
  store i32 1, ptr %14, align 4
  br label %107

39:                                               ; preds = %30
  %40 = load i64, ptr %10, align 8, !tbaa !11
  %41 = load i64, ptr %8, align 8, !tbaa !11
  %42 = icmp eq i64 %40, %41
  br i1 %42, label %43, label %59

43:                                               ; preds = %39
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %44, i32 0, i32 4
  store i32 1, ptr %45, align 8, !tbaa !13
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %46, i32 0, i32 0
  %48 = getelementptr inbounds [128 x i8], ptr %47, i64 0, i64 0
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %49, i32 0, i32 5
  %51 = load ptr, ptr %50, align 8, !tbaa !15
  %52 = getelementptr inbounds %struct.slh_dsa_params_st, ptr %51, i32 0, i32 3
  %53 = load i32, ptr %52, align 8, !tbaa !16
  %54 = mul i32 %53, 2
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds i8, ptr %48, i64 %55
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %57, i32 0, i32 1
  store ptr %56, ptr %58, align 8, !tbaa !18
  store i32 1, ptr %4, align 4
  store i32 1, ptr %14, align 4
  br label %107

59:                                               ; preds = %39
  %60 = load i64, ptr %10, align 8, !tbaa !11
  %61 = load i64, ptr %9, align 8, !tbaa !11
  %62 = icmp ne i64 %60, %61
  br i1 %62, label %63, label %64

63:                                               ; preds = %59
  br label %98

64:                                               ; preds = %59
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %65, i32 0, i32 4
  store i32 1, ptr %66, align 8, !tbaa !13
  br label %67

67:                                               ; preds = %64, %25
  br label %68

68:                                               ; preds = %67, %18
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds [128 x i8], ptr %70, i64 0, i64 0
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %72, i32 0, i32 5
  %74 = load ptr, ptr %73, align 8, !tbaa !15
  %75 = getelementptr inbounds %struct.slh_dsa_params_st, ptr %74, i32 0, i32 3
  %76 = load i32, ptr %75, align 8, !tbaa !16
  %77 = mul i32 %76, 2
  %78 = zext i32 %77 to i64
  %79 = getelementptr inbounds i8, ptr %71, i64 %78
  store ptr %79, ptr %13, align 8, !tbaa !5
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = call ptr @OSSL_PARAM_locate_const(ptr noundef %80, ptr noundef @.str.2)
  store ptr %81, ptr %12, align 8, !tbaa !5
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = icmp eq ptr %82, null
  br i1 %83, label %93, label %84

84:                                               ; preds = %68
  %85 = load ptr, ptr %12, align 8, !tbaa !5
  %86 = load i64, ptr %9, align 8, !tbaa !11
  %87 = call i32 @OSSL_PARAM_get_octet_string(ptr noundef %85, ptr noundef %13, i64 noundef %86, ptr noundef %10)
  %88 = icmp ne i32 %87, 0
  br i1 %88, label %89, label %93

89:                                               ; preds = %84
  %90 = load i64, ptr %10, align 8, !tbaa !11
  %91 = load i64, ptr %9, align 8, !tbaa !11
  %92 = icmp ne i64 %90, %91
  br i1 %92, label %93, label %94

93:                                               ; preds = %89, %84, %68
  br label %98

94:                                               ; preds = %89
  %95 = load ptr, ptr %13, align 8, !tbaa !5
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %96, i32 0, i32 1
  store ptr %95, ptr %97, align 8, !tbaa !18
  store i32 1, ptr %4, align 4
  store i32 1, ptr %14, align 4
  br label %107

98:                                               ; preds = %93, %63
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %99, i32 0, i32 1
  store ptr null, ptr %100, align 8, !tbaa !18
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %101, i32 0, i32 4
  store i32 0, ptr %102, align 8, !tbaa !13
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %103, i32 0, i32 0
  %105 = getelementptr inbounds [128 x i8], ptr %104, i64 0, i64 0
  %106 = load i64, ptr %8, align 8, !tbaa !11
  call void @OPENSSL_cleanse(ptr noundef %105, i64 noundef %106)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %14, align 4
  br label %107

107:                                              ; preds = %98, %94, %43, %38, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %108 = load i32, ptr %4, align 4
  ret i32 %108
}

; Function Attrs: nounwind uwtable
declare dso_local i64 @ossl_slh_dsa_key_get_priv_len(ptr noundef) #2

declare ptr @OSSL_PARAM_locate_const(ptr noundef, ptr noundef) #1

declare i32 @OSSL_PARAM_get_octet_string(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

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 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 152}
!14 = !{!"slh_dsa_key_st", !7, i64 0, !6, i64 128, !6, i64 136, !6, i64 144, !10, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200}
!15 = !{!14, !6, i64 160}
!16 = !{!17, !10, i64 16}
!17 = !{!"slh_dsa_params_st", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !12, i64 56}
!18 = !{!14, !6, i64 128}


; 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.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; 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

declare void @OPENSSL_cleanse(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ossl_slh_dsa_key_fromdata(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  store i64 0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %6 = icmp eq ptr %0, null
  br i1 %6, label %49, label %7

7:                                                ; preds = %3
  %8 = tail call i64 @ossl_slh_dsa_key_get_priv_len(ptr noundef nonnull %0)
  %9 = lshr i64 %8, 1
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %30, label %10

10:                                               ; preds = %7
  %11 = tail call ptr @OSSL_PARAM_locate_const(ptr noundef %1, ptr noundef nonnull @.str.1) #3
  %.not32 = icmp eq ptr %11, null
  br i1 %.not32, label %30, label %12

12:                                               ; preds = %10
  store ptr %0, ptr %5, align 8, !tbaa !9
  %13 = call i32 @OSSL_PARAM_get_octet_string(ptr noundef nonnull %11, ptr noundef nonnull %5, i64 noundef %8, ptr noundef nonnull %4) #3
  %.not33 = icmp eq i32 %13, 0
  br i1 %.not33, label %49, label %14

14:                                               ; preds = %12
  %15 = load i64, ptr %4, align 8, !tbaa !5
  %16 = icmp eq i64 %15, %8
  br i1 %16, label %17, label %27

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %0, i64 152
  store i32 1, ptr %18, align 8, !tbaa !11
  %19 = getelementptr inbounds i8, ptr %0, i64 160
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  %22 = load i32, ptr %21, align 8, !tbaa !15
  %23 = shl i32 %22, 1
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds i8, ptr %0, i64 %24
  %26 = getelementptr inbounds i8, ptr %0, i64 128
  store ptr %25, ptr %26, align 8, !tbaa !17
  br label %49

27:                                               ; preds = %14
  %.not34 = icmp eq i64 %15, %9
  br i1 %.not34, label %28, label %46

28:                                               ; preds = %27
  %29 = getelementptr inbounds i8, ptr %0, i64 152
  store i32 1, ptr %29, align 8, !tbaa !11
  br label %30

30:                                               ; preds = %10, %28, %7
  %31 = getelementptr inbounds i8, ptr %0, i64 160
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %34 = load i32, ptr %33, align 8, !tbaa !15
  %35 = shl i32 %34, 1
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds i8, ptr %0, i64 %36
  store ptr %37, ptr %5, align 8, !tbaa !9
  %38 = call ptr @OSSL_PARAM_locate_const(ptr noundef %1, ptr noundef nonnull @.str.2) #3
  %39 = icmp eq ptr %38, null
  br i1 %39, label %46, label %40

40:                                               ; preds = %30
  %41 = call i32 @OSSL_PARAM_get_octet_string(ptr noundef nonnull %38, ptr noundef nonnull %5, i64 noundef %9, ptr noundef nonnull %4) #3
  %.not35 = icmp ne i32 %41, 0
  %42 = load i64, ptr %4, align 8
  %.not36 = icmp eq i64 %42, %9
  %or.cond = select i1 %.not35, i1 %.not36, i1 false
  br i1 %or.cond, label %43, label %46

43:                                               ; preds = %40
  %44 = load ptr, ptr %5, align 8, !tbaa !9
  %45 = getelementptr inbounds i8, ptr %0, i64 128
  store ptr %44, ptr %45, align 8, !tbaa !17
  br label %49

46:                                               ; preds = %30, %40, %27
  %47 = getelementptr inbounds i8, ptr %0, i64 128
  store ptr null, ptr %47, align 8, !tbaa !17
  %48 = getelementptr inbounds i8, ptr %0, i64 152
  store i32 0, ptr %48, align 8, !tbaa !11
  call void @OPENSSL_cleanse(ptr noundef nonnull %0, i64 noundef %8) #3
  br label %49

49:                                               ; preds = %12, %3, %46, %43, %17
  %.0 = phi i32 [ 1, %17 ], [ 0, %46 ], [ 1, %43 ], [ 0, %3 ], [ 0, %12 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local i64 @ossl_slh_dsa_key_get_priv_len(ptr noundef) local_unnamed_addr #2

declare ptr @OSSL_PARAM_locate_const(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @OSSL_PARAM_get_octet_string(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 152}
!12 = !{!"slh_dsa_key_st", !7, i64 0, !10, i64 128, !10, i64 136, !10, i64 144, !13, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !10, i64 184, !10, i64 192, !10, i64 200}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !10, i64 160}
!15 = !{!16, !13, i64 16}
!16 = !{!"slh_dsa_params_st", !10, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !6, i64 56}
!17 = !{!12, !10, i64 128}


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