; LLVM IR from specinfo-ua/UAPKI :: library/uapki/src (cer-item)

; 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.GeneralNames = type { %struct.anon.14, %struct.asn_struct_ctx_s }
%struct.anon.14 = type { ptr, i32, i32, ptr }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }
%struct.GeneralName = type { i32, %"union.GeneralName::GeneralName_u", %struct.asn_struct_ctx_s }
%"union.GeneralName::GeneralName_u" = type { %struct.ORAddress }
%struct.ORAddress = type { %struct.BuiltInStandardAttributes, ptr, ptr, %struct.asn_struct_ctx_s }
%struct.BuiltInStandardAttributes = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.asn_struct_ctx_s }

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

declare void @asn_free(ptr noundef, ptr noundef) #0

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

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

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) #0

declare void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) #0

declare ptr @asn_decode_ba_with_alloc(ptr noundef, ptr noundef) #0

declare ptr @get_Name_desc() #0

declare i32 @asn_encode_ba(ptr noundef, ptr noundef, ptr noundef) #0

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

14:                                               ; preds = %2
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %18, label %17

17:                                               ; preds = %14, %2
  store i32 4101, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %86

18:                                               ; preds = %14
  br label %19

19:                                               ; preds = %18
  %20 = call ptr @get_GeneralNames_desc()
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = call ptr @asn_decode_ba_with_alloc(ptr noundef %20, ptr noundef %21)
  store ptr %22, ptr %7, align 8, !tbaa !5
  %23 = icmp eq ptr null, %22
  br i1 %23, label %24, label %26

24:                                               ; preds = %19
  store i32 2, ptr %6, align 4, !tbaa !9
  %25 = load i32, ptr %6, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 503, i32 noundef %25)
  br label %82

26:                                               ; preds = %19
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %68, %28
  %30 = load i32, ptr %10, align 4, !tbaa !9
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.GeneralNames, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %struct.anon.14, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 8, !tbaa !13
  %35 = icmp slt i32 %30, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %29
  store i32 5, ptr %9, align 4
  br label %71

37:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.GeneralNames, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds %struct.anon.14, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !19
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds ptr, ptr %41, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  store ptr %45, ptr %11, align 8, !tbaa !5
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.GeneralName, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 8, !tbaa !20
  %49 = icmp eq i32 %48, 5
  br i1 %49, label %50, label %64

50:                                               ; preds = %37
  br label %51

51:                                               ; preds = %50
  %52 = call ptr @get_Name_desc()
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.GeneralName, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = call i32 @asn_encode_ba(ptr noundef %52, ptr noundef %54, ptr noundef %55)
  store i32 %56, ptr %6, align 4, !tbaa !9
  %57 = load i32, ptr %6, align 4, !tbaa !9
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %61

59:                                               ; preds = %51
  %60 = load i32, ptr %6, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 508, i32 noundef %60)
  store i32 4, ptr %9, align 4
  br label %65

61:                                               ; preds = %51
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62
  store i8 1, ptr %8, align 1, !tbaa !11
  store i32 5, ptr %9, align 4
  br label %65

64:                                               ; preds = %37
  store i32 0, ptr %9, align 4
  br label %65

65:                                               ; preds = %64, %63, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  %66 = load i32, ptr %9, align 4
  switch i32 %66, label %71 [
    i32 0, label %67
  ]

67:                                               ; preds = %65
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %10, align 4, !tbaa !9
  br label %29, !llvm.loop !23

71:                                               ; preds = %65, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %72 = load i32, ptr %9, align 4
  switch i32 %72, label %86 [
    i32 5, label %73
    i32 4, label %82
  ]

73:                                               ; preds = %71
  %74 = load i8, ptr %8, align 1, !tbaa !11, !range !25, !noundef !26
  %75 = trunc i8 %74 to i1
  br i1 %75, label %81, label %76

76:                                               ; preds = %73
  br label %77

77:                                               ; preds = %76
  store i32 4145, ptr %6, align 4, !tbaa !9
  %78 = load i32, ptr %6, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 515, i32 noundef %78, ptr noundef null)
  br label %82

79:                                               ; No predecessors!
  br label %80

80:                                               ; preds = %79
  br label %81

81:                                               ; preds = %80, %73
  br label %82

82:                                               ; preds = %81, %77, %71, %24
  %83 = call ptr @get_GeneralNames_desc()
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  call void @asn_free(ptr noundef %83, ptr noundef %84)
  %85 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %85, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %86

86:                                               ; preds = %82, %71, %17
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %87 = load i32, ptr %3, align 4
  ret i32 %87
}

declare ptr @get_GeneralNames_desc() #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTS12GeneralNames", !15, i64 0, !16, i64 24}
!15 = !{!"_ZTSN12GeneralNamesUt_E", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16}
!16 = !{!"_ZTS16asn_struct_ctx_s", !17, i64 0, !17, i64 2, !10, i64 4, !6, i64 8, !18, i64 16}
!17 = !{!"short", !7, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!14, !6, i64 0}
!20 = !{!21, !22, i64 0}
!21 = !{!"_ZTS11GeneralName", !22, i64 0, !7, i64 8, !16, i64 144}
!22 = !{!"_ZTS14GeneralName_PR", !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{i8 0, i8 2}
!26 = !{}


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

declare void @asn_free(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

declare ptr @asn_decode_ba_with_alloc(ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @get_Name_desc() local_unnamed_addr #0

declare i32 @asn_encode_ba(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS4Cert22issuerFromGeneralNamesEPK12ByteArray_stPPS1_(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = icmp ne ptr %0, null
  %4 = icmp ne ptr %1, null
  %or.cond = and i1 %3, %4
  br i1 %or.cond, label %5, label %25

5:                                                ; preds = %2
  %6 = tail call ptr @get_GeneralNames_desc()
  %7 = tail call ptr @asn_decode_ba_with_alloc(ptr noundef %6, ptr noundef nonnull %0)
  %8 = icmp eq ptr %7, null
  br i1 %8, label %13, label %.preheader

.preheader:                                       ; preds = %5
  %9 = getelementptr inbounds i8, ptr %7, i64 8
  %10 = load i32, ptr %9, align 8, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %12 = load ptr, ptr %7, align 8, !tbaa !15
  %wide.trip.count = zext nneg i32 %10 to i64
  br label %15

13:                                               ; preds = %5
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 503, i32 noundef 2)
  br label %.thread51

14:                                               ; preds = %15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %15, !llvm.loop !16

15:                                               ; preds = %.lr.ph, %14
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %14 ]
  %16 = getelementptr inbounds ptr, ptr %12, i64 %indvars.iv
  %17 = load ptr, ptr %16, align 8, !tbaa !18
  %18 = load i32, ptr %17, align 8, !tbaa !19
  %.not33 = icmp eq i32 %18, 5
  br i1 %.not33, label %19, label %14

19:                                               ; preds = %15
  %20 = tail call ptr @get_Name_desc()
  %21 = getelementptr inbounds i8, ptr %17, i64 8
  %22 = tail call i32 @asn_encode_ba(ptr noundef %20, ptr noundef nonnull %21, ptr noundef nonnull %1)
  %.not = icmp eq i32 %22, 0
  br i1 %.not, label %.thread51, label %23

23:                                               ; preds = %19
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 508, i32 noundef %22)
  br label %.thread51

._crit_edge:                                      ; preds = %14, %.preheader
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 515, i32 noundef 4145, ptr noundef null)
  br label %.thread51

.thread51:                                        ; preds = %19, %23, %._crit_edge, %13
  %.3 = phi i32 [ 2, %13 ], [ %22, %23 ], [ 4145, %._crit_edge ], [ 0, %19 ]
  %24 = tail call ptr @get_GeneralNames_desc()
  tail call void @asn_free(ptr noundef %24, ptr noundef %7)
  br label %25

25:                                               ; preds = %2, %.thread51
  %.0 = phi i32 [ %.3, %.thread51 ], [ 4101, %2 ]
  ret i32 %.0
}

declare ptr @get_GeneralNames_desc() 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, !11, i64 8}
!6 = !{!"_ZTS12GeneralNames", !7, i64 0, !12, i64 24}
!7 = !{!"_ZTSN12GeneralNamesUt_E", !8, i64 0, !11, i64 8, !11, i64 12, !8, i64 16}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"_ZTS16asn_struct_ctx_s", !13, i64 0, !13, i64 2, !11, i64 4, !8, i64 8, !14, i64 16}
!13 = !{!"short", !9, i64 0}
!14 = !{!"long", !9, i64 0}
!15 = !{!6, !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!8, !8, i64 0}
!19 = !{!20, !21, i64 0}
!20 = !{!"_ZTS11GeneralName", !21, i64 0, !9, i64 8, !12, i64 144}
!21 = !{!"_ZTS14GeneralName_PR", !9, i64 0}


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