; LLVM IR from specinfo-ua/UAPKI :: library/uapki/src/doc-sign.ll (ZN7UapkiNS3Doc4Sign10SigningDoc11CerDataItem3setERKS3_)

; 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.UapkiNS::Doc::Sign::SigningDoc::CerDataItem" = type { ptr, ptr, i8, %"class.UapkiNS::SmartBA", %"class.UapkiNS::SmartBA", %"class.UapkiNS::SmartBA", ptr, ptr }
%"class.UapkiNS::SmartBA" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS3Doc4Sign10SigningDoc11CerDataItem3setERKS3_(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(64) %1) #0 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %7, i32 0, i32 0
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %6, i32 0, i32 0
  store ptr %9, ptr %10, align 8, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %6, i32 0, i32 1
  store ptr %13, ptr %14, align 8, !tbaa !13
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %15, i32 0, i32 2
  %17 = load i8, ptr %16, align 8, !tbaa !14, !range !15, !noundef !16
  %18 = trunc i8 %17 to i1
  %19 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %6, i32 0, i32 2
  %20 = zext i1 %18 to i8
  store i8 %20, ptr %19, align 8, !tbaa !14
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %21, i32 0, i32 7
  %23 = load ptr, ptr %22, align 8, !tbaa !17
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %52

25:                                               ; preds = %2
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %26, i32 0, i32 7
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %29 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %6, i32 0, i32 7
  store ptr %28, ptr %29, align 8, !tbaa !17
  %30 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %6, i32 0, i32 3
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %31, i32 0, i32 3
  %33 = call noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %32)
  %34 = call ptr @ba_copy_with_alloc(ptr noundef %33, i64 noundef 0, i64 noundef 0)
  %35 = call noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %30, ptr noundef %34)
  br i1 %35, label %36, label %50

36:                                               ; preds = %25
  %37 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %6, i32 0, i32 4
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %38, i32 0, i32 4
  %40 = call noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %39)
  %41 = call ptr @ba_copy_with_alloc(ptr noundef %40, i64 noundef 0, i64 noundef 0)
  %42 = call noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %37, ptr noundef %41)
  br i1 %42, label %43, label %50

43:                                               ; preds = %36
  %44 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %6, i32 0, i32 5
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", ptr %45, i32 0, i32 5
  %47 = call noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %46)
  %48 = call ptr @ba_copy_with_alloc(ptr noundef %47, i64 noundef 0, i64 noundef 0)
  %49 = call noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %44, ptr noundef %48)
  br i1 %49, label %51, label %50

50:                                               ; preds = %43, %36, %25
  store i32 4097, ptr %3, align 4
  br label %53

51:                                               ; preds = %43
  br label %52

52:                                               ; preds = %51, %2
  store i32 0, ptr %3, align 4
  br label %53

53:                                               ; preds = %52, %50
  %54 = load i32, ptr %3, align 4
  ret i32 %54
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #1 align 2

declare ptr @ba_copy_with_alloc(ptr noundef, i64 noundef, i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

attributes #0 = { mustprogress 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 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 = { "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 = !{!"_ZTSN7UapkiNS3Doc4Sign10SigningDoc11CerDataItemE", !6, i64 0, !6, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTSN7UapkiNS7SmartBAE", !6, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !11, i64 16}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!10, !6, i64 56}


; 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 uwtable
define dso_local noundef range(i32 0, 4098) i32 @_ZN7UapkiNS3Doc4Sign10SigningDoc11CerDataItem3setERKS3_(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(64) %1) local_unnamed_addr #0 align 2 {
  %3 = load <2 x ptr>, ptr %1, align 8, !tbaa !5
  store <2 x ptr> %3, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 16
  %5 = load i8, ptr %4, align 8, !tbaa !9, !range !13, !noundef !14
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  store i8 %5, ptr %6, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %1, i64 56
  %8 = load ptr, ptr %7, align 8, !tbaa !15
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %28, label %9

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %8, ptr %10, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = getelementptr inbounds i8, ptr %1, i64 24
  %13 = tail call noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %12)
  %14 = tail call ptr @ba_copy_with_alloc(ptr noundef %13, i64 noundef 0, i64 noundef 0)
  %15 = tail call noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef %14)
  br i1 %15, label %16, label %29

16:                                               ; preds = %9
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  %18 = getelementptr inbounds i8, ptr %1, i64 32
  %19 = tail call noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %18)
  %20 = tail call ptr @ba_copy_with_alloc(ptr noundef %19, i64 noundef 0, i64 noundef 0)
  %21 = tail call noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef %20)
  br i1 %21, label %22, label %29

22:                                               ; preds = %16
  %23 = getelementptr inbounds i8, ptr %0, i64 40
  %24 = getelementptr inbounds i8, ptr %1, i64 40
  %25 = tail call noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %24)
  %26 = tail call ptr @ba_copy_with_alloc(ptr noundef %25, i64 noundef 0, i64 noundef 0)
  %27 = tail call noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %23, ptr noundef %26)
  br i1 %27, label %28, label %29

28:                                               ; preds = %22, %2
  br label %29

29:                                               ; preds = %9, %16, %22, %28
  %.0 = phi i32 [ 0, %28 ], [ 4097, %22 ], [ 4097, %16 ], [ 4097, %9 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #1 align 2

declare ptr @ba_copy_with_alloc(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress 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 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 = { "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, !11, i64 16}
!10 = !{!"_ZTSN7UapkiNS3Doc4Sign10SigningDoc11CerDataItemE", !6, i64 0, !6, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTSN7UapkiNS7SmartBAE", !6, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!10, !6, i64 56}


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