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

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

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

15:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %50

16:                                               ; preds = %3
  %17 = call ptr @CRYPTO_zalloc(i64 noundef 208, ptr noundef @.str, i32 noundef 96)
  store ptr %17, ptr %8, align 8, !tbaa !5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %46

20:                                               ; preds = %16
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %22, i32 0, i32 2
  store ptr %21, ptr %23, align 8, !tbaa !9
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %25, i32 0, i32 5
  store ptr %24, ptr %26, align 8, !tbaa !12
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %40

29:                                               ; preds = %20
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = call ptr @CRYPTO_strdup(ptr noundef %30, ptr noundef @.str, i32 noundef 101)
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %32, i32 0, i32 3
  store ptr %31, ptr %33, align 8, !tbaa !13
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.slh_dsa_key_st, ptr %34, i32 0, i32 3
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %39

38:                                               ; preds = %29
  br label %48

39:                                               ; preds = %29
  br label %40

40:                                               ; preds = %39, %20
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call i32 @slh_dsa_key_hash_init(ptr noundef %41)
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  br label %48

45:                                               ; preds = %40
  br label %46

46:                                               ; preds = %45, %16
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %47, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %50

48:                                               ; preds = %44, %38
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  call void @ossl_slh_dsa_key_free(ptr noundef %49)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %50

50:                                               ; preds = %48, %46, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %51 = load ptr, ptr %4, align 8
  ret ptr %51
}

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

declare ptr @ossl_slh_dsa_params_get(ptr noundef) #2

declare ptr @CRYPTO_zalloc(i64 noundef, ptr noundef, i32 noundef) #2

declare ptr @CRYPTO_strdup(ptr noundef, ptr noundef, i32 noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @ossl_slh_dsa_key_free(ptr noundef) #0

; 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, !6, i64 136}
!10 = !{!"slh_dsa_key_st", !7, i64 0, !6, i64 128, !6, i64 136, !6, i64 144, !11, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 160}
!13 = !{!10, !6, i64 144}


; 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 [78 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @ossl_slh_dsa_key_new(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = tail call ptr @ossl_slh_dsa_params_get(ptr noundef %2) #2
  %5 = icmp eq ptr %4, null
  br i1 %5, label %18, label %6

6:                                                ; preds = %3
  %7 = tail call ptr @CRYPTO_zalloc(i64 noundef 208, ptr noundef nonnull @.str, i32 noundef 96) #2
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %18, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %7, i64 136
  store ptr %0, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %7, i64 160
  store ptr %4, ptr %10, align 8, !tbaa !11
  %.not18 = icmp eq ptr %1, null
  br i1 %.not18, label %15, label %11

11:                                               ; preds = %8
  %12 = tail call ptr @CRYPTO_strdup(ptr noundef nonnull %1, ptr noundef nonnull @.str, i32 noundef 101) #2
  %13 = getelementptr inbounds i8, ptr %7, i64 144
  store ptr %12, ptr %13, align 8, !tbaa !12
  %14 = icmp eq ptr %12, null
  br i1 %14, label %17, label %15

15:                                               ; preds = %11, %8
  %16 = tail call i32 @slh_dsa_key_hash_init(ptr noundef nonnull %7)
  %.not19 = icmp eq i32 %16, 0
  br i1 %.not19, label %17, label %18

17:                                               ; preds = %15, %11
  tail call void @ossl_slh_dsa_key_free(ptr noundef nonnull %7)
  br label %18

18:                                               ; preds = %6, %15, %3, %17
  %.0 = phi ptr [ null, %17 ], [ null, %3 ], [ %7, %15 ], [ null, %6 ]
  ret ptr %.0
}

declare ptr @ossl_slh_dsa_params_get(ptr noundef) local_unnamed_addr #1

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

declare ptr @CRYPTO_strdup(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @ossl_slh_dsa_key_free(ptr noundef) local_unnamed_addr #0

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 = { "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, !9, i64 136}
!6 = !{!"slh_dsa_key_st", !7, i64 0, !9, i64 128, !9, i64 136, !9, i64 144, !10, i64 152, !9, i64 160, !9, i64 168, !9, i64 176, !9, i64 184, !9, i64 192, !9, i64 200}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!6, !9, i64 160}
!12 = !{!6, !9, i64 144}


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