; LLVM IR from specinfo-ua/UAPKI :: library/cm-pkcs12/src/storage/file-storage.ll (ZN16FileStorageParam10setDefaultEPKS_)

; 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.FileStorageParam = type { ptr, ptr, ptr, i64 }

@_ZL18DEFAULT_BAG_CIPHER = external hidden global ptr, align 8
@_ZL15DEFAULT_BAG_KDF = external hidden global ptr, align 8
@_ZL16DEFAULT_MAC_ALGO = external hidden global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN16FileStorageParam10setDefaultEPKS_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %25

8:                                                ; preds = %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.FileStorageParam, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.FileStorageParam, ptr %5, i32 0, i32 0
  store ptr %11, ptr %12, align 8, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.FileStorageParam, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = getelementptr inbounds %struct.FileStorageParam, ptr %5, i32 0, i32 1
  store ptr %15, ptr %16, align 8, !tbaa !12
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.FileStorageParam, ptr %17, i32 0, i32 3
  %19 = load i64, ptr %18, align 8, !tbaa !13
  %20 = getelementptr inbounds %struct.FileStorageParam, ptr %5, i32 0, i32 3
  store i64 %19, ptr %20, align 8, !tbaa !13
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.FileStorageParam, ptr %21, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = getelementptr inbounds %struct.FileStorageParam, ptr %5, i32 0, i32 2
  store ptr %23, ptr %24, align 8, !tbaa !14
  br label %33

25:                                               ; preds = %2
  %26 = load ptr, ptr @_ZL18DEFAULT_BAG_CIPHER, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.FileStorageParam, ptr %5, i32 0, i32 0
  store ptr %26, ptr %27, align 8, !tbaa !9
  %28 = load ptr, ptr @_ZL15DEFAULT_BAG_KDF, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.FileStorageParam, ptr %5, i32 0, i32 1
  store ptr %28, ptr %29, align 8, !tbaa !12
  %30 = getelementptr inbounds %struct.FileStorageParam, ptr %5, i32 0, i32 3
  store i64 10000, ptr %30, align 8, !tbaa !13
  %31 = load ptr, ptr @_ZL16DEFAULT_MAC_ALGO, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.FileStorageParam, ptr %5, i32 0, i32 2
  store ptr %31, ptr %32, align 8, !tbaa !14
  br label %33

33:                                               ; preds = %25, %8
  ret void
}

attributes #0 = { mustprogress 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" }

!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++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS16FileStorageParam", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !11, i64 24}
!14 = !{!10, !6, i64 16}


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

@_ZL18DEFAULT_BAG_CIPHER = external hidden local_unnamed_addr global ptr, align 8
@_ZL15DEFAULT_BAG_KDF = external hidden local_unnamed_addr global ptr, align 8
@_ZL16DEFAULT_MAC_ALGO = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN16FileStorageParam10setDefaultEPKS_(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(32) %0, ptr noundef readonly %1) local_unnamed_addr #0 align 2 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %9, label %3

3:                                                ; preds = %2
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  store ptr %4, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = getelementptr inbounds i8, ptr %1, i64 24
  %7 = load i64, ptr %6, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  br label %11

9:                                                ; preds = %2
  %10 = load ptr, ptr @_ZL18DEFAULT_BAG_CIPHER, align 8, !tbaa !12
  store ptr %10, ptr %0, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %9, %3
  %.sink7.in = phi ptr [ @_ZL15DEFAULT_BAG_KDF, %9 ], [ %5, %3 ]
  %.sink6 = phi i64 [ 10000, %9 ], [ %7, %3 ]
  %.sink.in = phi ptr [ @_ZL16DEFAULT_MAC_ALGO, %9 ], [ %8, %3 ]
  %.sink = load ptr, ptr %.sink.in, align 8, !tbaa !12
  %.sink7 = load ptr, ptr %.sink7.in, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %.sink7, ptr %12, align 8
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %.sink6, ptr %13, align 8
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %.sink, ptr %14, align 8
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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, !7, i64 0}
!6 = !{!"_ZTS16FileStorageParam", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass