; LLVM IR from specinfo-ua/UAPKI :: library/uapki/src (store-json)

; 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.Name = type { i32, %"union.Name::Name_u", %struct.asn_struct_ctx_s }
%"union.Name::Name_u" = type { %struct.RDNSequence }
%struct.RDNSequence = type { %struct.anon, %struct.asn_struct_ctx_s }
%struct.anon = type { ptr, i32, i32, ptr }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }
%struct.RelativeDistinguishedName = type { %struct.anon.0, %struct.asn_struct_ctx_s }
%struct.anon.0 = type { ptr, i32, i32, ptr }
%struct.AttributeTypeAndValue = type { %struct.ASN__PRIMITIVE_TYPE_s, %struct.ANY, %struct.asn_struct_ctx_s }
%struct.ASN__PRIMITIVE_TYPE_s = type { ptr, i32 }
%struct.ANY = type { ptr, i32, %struct.asn_struct_ctx_s }

; 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 noundef i32 @_ZN7UapkiNS4Util15decodeAnyStringEPKhmRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(32)) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS14rdnameFromNameERK4NamePKcRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(32) %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = 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
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.Name, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = icmp ne i32 %16, 1
  br i1 %17, label %18, label %19

18:                                               ; preds = %3
  store i32 4145, ptr %4, align 4
  br label %101

19:                                               ; preds = %3
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  store i32 4101, ptr %4, align 4
  br label %101

23:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !16
  br label %24

24:                                               ; preds = %95, %23
  %25 = load i32, ptr %8, align 4, !tbaa !16
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.Name, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %struct.RDNSequence, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %struct.anon, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 8, !tbaa !17
  %31 = icmp slt i32 %25, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %24
  store i32 2, ptr %9, align 4
  br label %98

33:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.Name, ptr %34, i32 0, i32 1
  %36 = getelementptr inbounds %struct.RDNSequence, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.anon, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  %39 = load i32, ptr %8, align 4, !tbaa !16
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds ptr, ptr %38, i64 %40
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  store ptr %42, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !16
  br label %43

43:                                               ; preds = %86, %33
  %44 = load i32, ptr %11, align 4, !tbaa !16
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.RelativeDistinguishedName, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds %struct.anon.0, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %47, align 8, !tbaa !18
  %49 = icmp slt i32 %44, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %43
  store i32 5, ptr %9, align 4
  br label %89

51:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.RelativeDistinguishedName, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds %struct.anon.0, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !21
  %56 = load i32, ptr %11, align 4, !tbaa !16
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds ptr, ptr %55, i64 %57
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  store ptr %59, ptr %12, align 8, !tbaa !5
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.AttributeTypeAndValue, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = call zeroext i1 @OID_is_equal_oid(ptr noundef %61, ptr noundef %62)
  br i1 %63, label %64, label %82

64:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.AttributeTypeAndValue, ptr %65, i32 0, i32 1
  %67 = getelementptr inbounds %struct.ANY, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !22
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.AttributeTypeAndValue, ptr %69, i32 0, i32 1
  %71 = getelementptr inbounds %struct.ANY, ptr %70, i32 0, i32 1
  %72 = load i32, ptr %71, align 8, !tbaa !26
  %73 = sext i32 %72 to i64
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = call noundef i32 @_ZN7UapkiNS4Util15decodeAnyStringEPKhmRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %68, i64 noundef %73, ptr noundef nonnull align 8 dereferenceable(32) %74)
  store i32 %75, ptr %13, align 4, !tbaa !16
  %76 = load i32, ptr %13, align 4, !tbaa !16
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %80

78:                                               ; preds = %64
  %79 = load i32, ptr %13, align 4, !tbaa !16
  store i32 %79, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %81

80:                                               ; preds = %64
  store i32 5, ptr %9, align 4
  br label %81

81:                                               ; preds = %80, %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %83

82:                                               ; preds = %51
  store i32 0, ptr %9, align 4
  br label %83

83:                                               ; preds = %82, %81
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %84 = load i32, ptr %9, align 4
  switch i32 %84, label %89 [
    i32 0, label %85
  ]

85:                                               ; preds = %83
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %11, align 4, !tbaa !16
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %11, align 4, !tbaa !16
  br label %43, !llvm.loop !27

89:                                               ; preds = %83, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  %90 = load i32, ptr %9, align 4
  switch i32 %90, label %92 [
    i32 5, label %91
  ]

91:                                               ; preds = %89
  store i32 0, ptr %9, align 4
  br label %92

92:                                               ; preds = %91, %89
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %93 = load i32, ptr %9, align 4
  switch i32 %93, label %98 [
    i32 0, label %94
  ]

94:                                               ; preds = %92
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %8, align 4, !tbaa !16
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %8, align 4, !tbaa !16
  br label %24, !llvm.loop !29

98:                                               ; preds = %92, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %99 = load i32, ptr %9, align 4
  switch i32 %99, label %103 [
    i32 2, label %100
    i32 1, label %101
  ]

100:                                              ; preds = %98
  store i32 0, ptr %4, align 4
  br label %101

101:                                              ; preds = %100, %98, %22, %18
  %102 = load i32, ptr %4, align 4
  ret i32 %102

103:                                              ; preds = %98
  unreachable
}

declare zeroext i1 @OID_is_equal_oid(ptr 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 = { 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 #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++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS4Name", !11, i64 0, !7, i64 8, !12, i64 56}
!11 = !{!"_ZTS7Name_PR", !7, i64 0}
!12 = !{!"_ZTS16asn_struct_ctx_s", !13, i64 0, !13, i64 2, !14, i64 4, !6, i64 8, !15, i64 16}
!13 = !{!"short", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!14, !14, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !14, i64 8}
!19 = !{!"_ZTS25RelativeDistinguishedName", !20, i64 0, !12, i64 24}
!20 = !{!"_ZTSN25RelativeDistinguishedNameUt_E", !6, i64 0, !14, i64 8, !14, i64 12, !6, i64 16}
!21 = !{!19, !6, i64 0}
!22 = !{!23, !6, i64 16}
!23 = !{!"_ZTS21AttributeTypeAndValue", !24, i64 0, !25, i64 16, !12, i64 56}
!24 = !{!"_ZTS21ASN__PRIMITIVE_TYPE_s", !6, i64 0, !14, i64 8}
!25 = !{!"_ZTS3ANY", !6, i64 0, !14, i64 8, !12, i64 16}
!26 = !{!23, !14, i64 24}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = distinct !{!29, !28}


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

declare noundef i32 @_ZN7UapkiNS4Util15decodeAnyStringEPKhmRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS14rdnameFromNameERK4NamePKcRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(80) %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(32) %2) local_unnamed_addr #1 {
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 1
  br i1 %.not, label %5, label %.loopexit

5:                                                ; preds = %3
  %.not33 = icmp eq ptr %1, null
  br i1 %.not33, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %5
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i32, ptr %6, align 8, !tbaa !15
  %.not4547 = icmp sgt i32 %7, 0
  br i1 %.not4547, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  br label %9

9:                                                ; preds = %.lr.ph, %.thread39
  %indvars.iv54 = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next55, %.thread39 ]
  %10 = load ptr, ptr %8, align 8, !tbaa !15
  %11 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv54
  %12 = load ptr, ptr %11, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %12, i64 8
  %14 = load i32, ptr %13, align 8, !tbaa !17
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.thread, label %.thread39

16:                                               ; preds = %.thread
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = load i32, ptr %13, align 8, !tbaa !17
  %18 = sext i32 %17 to i64
  %19 = icmp slt i64 %indvars.iv.next, %18
  br i1 %19, label %.thread, label %.thread39, !llvm.loop !20

.thread:                                          ; preds = %9, %16
  %indvars.iv = phi i64 [ %indvars.iv.next, %16 ], [ 0, %9 ]
  %20 = load ptr, ptr %12, align 8, !tbaa !22
  %21 = getelementptr inbounds ptr, ptr %20, i64 %indvars.iv
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %23 = tail call zeroext i1 @OID_is_equal_oid(ptr noundef %22, ptr noundef nonnull %1)
  br i1 %23, label %24, label %16

24:                                               ; preds = %.thread
  %25 = getelementptr inbounds i8, ptr %22, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !23
  %27 = getelementptr inbounds i8, ptr %22, i64 24
  %28 = load i32, ptr %27, align 8, !tbaa !27
  %29 = sext i32 %28 to i64
  %30 = tail call noundef i32 @_ZN7UapkiNS4Util15decodeAnyStringEPKhmRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %26, i64 noundef %29, ptr noundef nonnull align 8 dereferenceable(32) %2)
  %.not34 = icmp eq i32 %30, 0
  br i1 %.not34, label %.thread39, label %.loopexit

.thread39:                                        ; preds = %16, %9, %24
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %31 = load i32, ptr %6, align 8, !tbaa !15
  %32 = sext i32 %31 to i64
  %.not45 = icmp slt i64 %indvars.iv.next55, %32
  br i1 %.not45, label %9, label %.loopexit, !llvm.loop !28

.loopexit:                                        ; preds = %.thread39, %24, %.preheader, %5, %3
  %.6 = phi i32 [ 4145, %3 ], [ 4101, %5 ], [ 0, %.preheader ], [ 0, %.thread39 ], [ %30, %24 ]
  ret i32 %.6
}

declare zeroext i1 @OID_is_equal_oid(ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #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 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 = !{!"_ZTS4Name", !7, i64 0, !8, i64 8, !10, i64 56}
!7 = !{!"_ZTS7Name_PR", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS16asn_struct_ctx_s", !11, i64 0, !11, i64 2, !12, i64 4, !13, i64 8, !14, i64 16}
!11 = !{!"short", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"long", !8, i64 0}
!15 = !{!8, !8, i64 0}
!16 = !{!13, !13, i64 0}
!17 = !{!18, !12, i64 8}
!18 = !{!"_ZTS25RelativeDistinguishedName", !19, i64 0, !10, i64 24}
!19 = !{!"_ZTSN25RelativeDistinguishedNameUt_E", !13, i64 0, !12, i64 8, !12, i64 12, !13, i64 16}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!18, !13, i64 0}
!23 = !{!24, !13, i64 16}
!24 = !{!"_ZTS21AttributeTypeAndValue", !25, i64 0, !26, i64 16, !10, i64 56}
!25 = !{!"_ZTS21ASN__PRIMITIVE_TYPE_s", !13, i64 0, !12, i64 8}
!26 = !{!"_ZTS3ANY", !13, i64 0, !12, i64 8, !10, i64 16}
!27 = !{!24, !12, i64 24}
!28 = distinct !{!28, !21}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass