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

; 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::SignParams" = type { i32, i8, i8, i32, i32, %"struct.UapkiNS::AlgorithmIdentifier", %"struct.UapkiNS::AlgorithmIdentifier", %"struct.UapkiNS::Doc::Sign::SigningDoc::CerDataItem", %"class.UapkiNS::SmartBA", i8, i8, i8, i8, i8, i8, %"struct.UapkiNS::LibraryConfig::OcspParams", %"struct.UapkiNS::LibraryConfig::TspParams", %"struct.UapkiNS::Attribute", %"struct.UapkiNS::Attribute", %"class.std::vector.3" }
%"struct.UapkiNS::AlgorithmIdentifier" = type { %"class.std::__cxx11::basic_string", ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"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 }
%"struct.UapkiNS::LibraryConfig::OcspParams" = type { i64 }
%"struct.UapkiNS::LibraryConfig::TspParams" = type { i8, i8, i64, %"class.std::__cxx11::basic_string", %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.UapkiNS::Attribute" = type { %"class.std::__cxx11::basic_string", ptr }
%"class.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<UapkiNS::Doc::Sign::SigningDoc::CerDataItem *, std::allocator<UapkiNS::Doc::Sign::SigningDoc::CerDataItem *>>::_Vector_impl" }
%"struct.std::_Vector_base<UapkiNS::Doc::Sign::SigningDoc::CerDataItem *, std::allocator<UapkiNS::Doc::Sign::SigningDoc::CerDataItem *>>::_Vector_impl" = type { %"struct.std::_Vector_base<UapkiNS::Doc::Sign::SigningDoc::CerDataItem *, std::allocator<UapkiNS::Doc::Sign::SigningDoc::CerDataItem *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<UapkiNS::Doc::Sign::SigningDoc::CerDataItem *, std::allocator<UapkiNS::Doc::Sign::SigningDoc::CerDataItem *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN7UapkiNS3Doc4Sign10SigningDoc10SignParams18setSignatureFormatENS_15SignatureFormatE(ptr noundef nonnull align 8 dereferenceable(360) %0, i32 noundef %1) #0 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %6 = load ptr, ptr %4, align 8
  %7 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %7, label %19 [
    i32 7, label %8
    i32 6, label %8
    i32 5, label %8
    i32 4, label %11
    i32 3, label %14
    i32 2, label %17
    i32 1, label %20
  ]

8:                                                ; preds = %2, %2, %2
  %9 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::SignParams", ptr %6, i32 0, i32 10
  store i8 1, ptr %9, align 1, !tbaa !11
  %10 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::SignParams", ptr %6, i32 0, i32 1
  store i8 1, ptr %10, align 4, !tbaa !32
  br label %11

11:                                               ; preds = %8, %2
  %12 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::SignParams", ptr %6, i32 0, i32 12
  store i8 1, ptr %12, align 1, !tbaa !33
  %13 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::SignParams", ptr %6, i32 0, i32 13
  store i8 1, ptr %13, align 4, !tbaa !34
  br label %14

14:                                               ; preds = %11, %2
  %15 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::SignParams", ptr %6, i32 0, i32 2
  store i8 1, ptr %15, align 1, !tbaa !35
  %16 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::SignParams", ptr %6, i32 0, i32 14
  store i8 0, ptr %16, align 1, !tbaa !36
  br label %20

17:                                               ; preds = %2
  %18 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::SignParams", ptr %6, i32 0, i32 14
  store i8 1, ptr %18, align 1, !tbaa !36
  br label %20

19:                                               ; preds = %2
  store i32 4101, ptr %3, align 4
  br label %23

20:                                               ; preds = %17, %14, %2
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = getelementptr inbounds %"struct.UapkiNS::Doc::Sign::SigningDoc::SignParams", ptr %6, i32 0, i32 0
  store i32 %21, ptr %22, align 8, !tbaa !37
  store i32 0, ptr %3, align 4
  br label %23

23:                                               ; preds = %20, %19
  %24 = load i32, ptr %3, align 4
  ret i32 %24
}

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, !10, i64 0}
!10 = !{!"_ZTSN7UapkiNS15SignatureFormatE", !7, i64 0}
!11 = !{!12, !13, i64 169}
!12 = !{!"_ZTSN7UapkiNS3Doc4Sign10SigningDoc10SignParamsE", !10, i64 0, !13, i64 4, !13, i64 5, !14, i64 8, !14, i64 12, !15, i64 16, !15, i64 56, !19, i64 96, !20, i64 160, !13, i64 168, !13, i64 169, !13, i64 170, !13, i64 171, !13, i64 172, !13, i64 173, !21, i64 176, !22, i64 184, !27, i64 256, !27, i64 296, !28, i64 336}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTS7HashAlg", !7, i64 0}
!15 = !{!"_ZTSN7UapkiNS19AlgorithmIdentifierE", !16, i64 0, !6, i64 32}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !18, i64 8, !7, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTSN7UapkiNS3Doc4Sign10SigningDoc11CerDataItemE", !6, i64 0, !6, i64 8, !13, i64 16, !20, i64 24, !20, i64 32, !20, i64 40, !6, i64 48, !6, i64 56}
!20 = !{!"_ZTSN7UapkiNS7SmartBAE", !6, i64 0}
!21 = !{!"_ZTSN7UapkiNS13LibraryConfig10OcspParamsE", !18, i64 0}
!22 = !{!"_ZTSN7UapkiNS13LibraryConfig9TspParamsE", !13, i64 0, !13, i64 1, !18, i64 8, !16, i64 16, !23, i64 48}
!23 = !{!"_ZTSSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE", !24, i64 0}
!24 = !{!"_ZTSSt12_Vector_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE12_Vector_implE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!27 = !{!"_ZTSN7UapkiNS9AttributeE", !16, i64 0, !6, i64 32}
!28 = !{!"_ZTSSt6vectorIPN7UapkiNS3Doc4Sign10SigningDoc11CerDataItemESaIS5_EE", !29, i64 0}
!29 = !{!"_ZTSSt12_Vector_baseIPN7UapkiNS3Doc4Sign10SigningDoc11CerDataItemESaIS5_EE", !30, i64 0}
!30 = !{!"_ZTSNSt12_Vector_baseIPN7UapkiNS3Doc4Sign10SigningDoc11CerDataItemESaIS5_EE12_Vector_implE", !31, i64 0}
!31 = !{!"_ZTSNSt12_Vector_baseIPN7UapkiNS3Doc4Sign10SigningDoc11CerDataItemESaIS5_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!32 = !{!12, !13, i64 4}
!33 = !{!12, !13, i64 171}
!34 = !{!12, !13, i64 172}
!35 = !{!12, !13, i64 5}
!36 = !{!12, !13, i64 173}
!37 = !{!12, !10, 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local noundef range(i32 0, 4102) i32 @_ZN7UapkiNS3Doc4Sign10SigningDoc10SignParams18setSignatureFormatENS_15SignatureFormatE(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(360) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  switch i32 %1, label %13 [
    i32 7, label %3
    i32 6, label %3
    i32 5, label %3
    i32 4, label %6
    i32 3, label %9
    i32 2, label %.sink.split
    i32 1, label %12
  ]

3:                                                ; preds = %2, %2, %2
  %4 = getelementptr inbounds i8, ptr %0, i64 169
  store i8 1, ptr %4, align 1, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  store i8 1, ptr %5, align 4, !tbaa !30
  br label %6

6:                                                ; preds = %3, %2
  %7 = getelementptr inbounds i8, ptr %0, i64 171
  store i8 1, ptr %7, align 1, !tbaa !31
  %8 = getelementptr inbounds i8, ptr %0, i64 172
  store i8 1, ptr %8, align 4, !tbaa !32
  br label %9

9:                                                ; preds = %6, %2
  %10 = getelementptr inbounds i8, ptr %0, i64 5
  store i8 1, ptr %10, align 1, !tbaa !33
  br label %.sink.split

.sink.split:                                      ; preds = %2, %9
  %.sink = phi i8 [ 0, %9 ], [ 1, %2 ]
  %11 = getelementptr inbounds i8, ptr %0, i64 173
  store i8 %.sink, ptr %11, align 1, !tbaa !34
  br label %12

12:                                               ; preds = %.sink.split, %2
  store i32 %1, ptr %0, align 8, !tbaa !35
  br label %13

13:                                               ; preds = %2, %12
  %.0 = phi i32 [ 0, %12 ], [ 4101, %2 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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, !10, i64 169}
!6 = !{!"_ZTSN7UapkiNS3Doc4Sign10SigningDoc10SignParamsE", !7, i64 0, !10, i64 4, !10, i64 5, !11, i64 8, !11, i64 12, !12, i64 16, !12, i64 56, !17, i64 96, !18, i64 160, !10, i64 168, !10, i64 169, !10, i64 170, !10, i64 171, !10, i64 172, !10, i64 173, !19, i64 176, !20, i64 184, !25, i64 256, !25, i64 296, !26, i64 336}
!7 = !{!"_ZTSN7UapkiNS15SignatureFormatE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTS7HashAlg", !8, i64 0}
!12 = !{!"_ZTSN7UapkiNS19AlgorithmIdentifierE", !13, i64 0, !15, i64 32}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !14, i64 0, !16, i64 8, !8, i64 16}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !15, i64 0}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"long", !8, i64 0}
!17 = !{!"_ZTSN7UapkiNS3Doc4Sign10SigningDoc11CerDataItemE", !15, i64 0, !15, i64 8, !10, i64 16, !18, i64 24, !18, i64 32, !18, i64 40, !15, i64 48, !15, i64 56}
!18 = !{!"_ZTSN7UapkiNS7SmartBAE", !15, i64 0}
!19 = !{!"_ZTSN7UapkiNS13LibraryConfig10OcspParamsE", !16, i64 0}
!20 = !{!"_ZTSN7UapkiNS13LibraryConfig9TspParamsE", !10, i64 0, !10, i64 1, !16, i64 8, !13, i64 16, !21, i64 48}
!21 = !{!"_ZTSSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE12_Vector_implE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!25 = !{!"_ZTSN7UapkiNS9AttributeE", !13, i64 0, !15, i64 32}
!26 = !{!"_ZTSSt6vectorIPN7UapkiNS3Doc4Sign10SigningDoc11CerDataItemESaIS5_EE", !27, i64 0}
!27 = !{!"_ZTSSt12_Vector_baseIPN7UapkiNS3Doc4Sign10SigningDoc11CerDataItemESaIS5_EE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIPN7UapkiNS3Doc4Sign10SigningDoc11CerDataItemESaIS5_EE12_Vector_implE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIPN7UapkiNS3Doc4Sign10SigningDoc11CerDataItemESaIS5_EE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!30 = !{!6, !10, i64 4}
!31 = !{!6, !10, i64 171}
!32 = !{!6, !10, i64 172}
!33 = !{!6, !10, i64 5}
!34 = !{!6, !10, i64 173}
!35 = !{!6, !7, i64 0}


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