; LLVM IR from specinfo-ua/UAPKI :: library/uapki/src (ocsp-helper)

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

%"class.UapkiNS::Ocsp::OcspHelper" = type <{ %"class.std::vector", ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<UapkiNS::Ocsp::OcspHelper::SingleResponseInfo, std::allocator<UapkiNS::Ocsp::OcspHelper::SingleResponseInfo>>::_Vector_impl" }
%"struct.std::_Vector_base<UapkiNS::Ocsp::OcspHelper::SingleResponseInfo, std::allocator<UapkiNS::Ocsp::OcspHelper::SingleResponseInfo>>::_Vector_impl" = type { %"struct.std::_Vector_base<UapkiNS::Ocsp::OcspHelper::SingleResponseInfo, std::allocator<UapkiNS::Ocsp::OcspHelper::SingleResponseInfo>>::_Vector_impl_data" }
%"struct.std::_Vector_base<UapkiNS::Ocsp::OcspHelper::SingleResponseInfo, std::allocator<UapkiNS::Ocsp::OcspHelper::SingleResponseInfo>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.BasicOCSPResponse = type { %struct.ResponseData, %struct.AlgorithmIdentifier, %struct.BIT_STRING_s, ptr, %struct.asn_struct_ctx_s }
%struct.ResponseData = type { ptr, %struct.ResponderID, %struct.OCTET_STRING, %"struct.ResponseData::responses", ptr, %struct.asn_struct_ctx_s }
%struct.ResponderID = type { i32, %"union.ResponderID::ResponderID_u", %struct.asn_struct_ctx_s }
%"union.ResponderID::ResponderID_u" = type { %struct.Name }
%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.13, %struct.asn_struct_ctx_s }
%struct.anon.13 = type { ptr, i32, i32, ptr }
%struct.OCTET_STRING = type { ptr, i32, %struct.asn_struct_ctx_s }
%"struct.ResponseData::responses" = type { %struct.anon.14, %struct.asn_struct_ctx_s }
%struct.anon.14 = type { ptr, i32, i32, ptr }
%struct.AlgorithmIdentifier = type { %struct.ASN__PRIMITIVE_TYPE_s, ptr, %struct.asn_struct_ctx_s }
%struct.ASN__PRIMITIVE_TYPE_s = type { ptr, i32 }
%struct.BIT_STRING_s = type { ptr, i32, i32, %struct.asn_struct_ctx_s }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }

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

declare ptr @get_BasicOCSPResponse_desc() #0

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

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

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

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

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

declare ptr @get_ResponseData_desc() #0

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

11:                                               ; preds = %2
  store i32 4101, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %54

12:                                               ; preds = %2
  br label %13

13:                                               ; preds = %12
  %14 = call ptr @get_BasicOCSPResponse_desc()
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call ptr @asn_decode_ba_with_alloc(ptr noundef %14, ptr noundef %15)
  %17 = getelementptr inbounds %"class.UapkiNS::Ocsp::OcspHelper", ptr %8, i32 0, i32 2
  store ptr %16, ptr %17, align 8, !tbaa !11
  %18 = icmp eq ptr null, %16
  br i1 %18, label %19, label %21

19:                                               ; preds = %13
  store i32 2, ptr %6, align 4, !tbaa !9
  %20 = load i32, ptr %6, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 349, i32 noundef %20)
  br label %52

21:                                               ; preds = %13
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = call ptr @get_ResponseData_desc()
  %26 = getelementptr inbounds %"class.UapkiNS::Ocsp::OcspHelper", ptr %8, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct.BasicOCSPResponse, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %"class.UapkiNS::Ocsp::OcspHelper", ptr %8, i32 0, i32 7
  %30 = call i32 @asn_encode_ba(ptr noundef %25, ptr noundef %28, ptr noundef %29)
  store i32 %30, ptr %6, align 4, !tbaa !9
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %24
  %34 = load i32, ptr %6, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 351, i32 noundef %34)
  br label %52

35:                                               ; preds = %24
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  %39 = getelementptr inbounds %"class.UapkiNS::Ocsp::OcspHelper", ptr %8, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = getelementptr inbounds %struct.BasicOCSPResponse, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds %struct.ResponseData, ptr %41, i32 0, i32 2
  %43 = getelementptr inbounds %"class.UapkiNS::Ocsp::OcspHelper", ptr %8, i32 0, i32 8
  %44 = call noundef i32 @_ZN7UapkiNS4Util15genTimeFromAsn1EPK12OCTET_STRINGRm(ptr noundef %42, ptr noundef nonnull align 8 dereferenceable(8) %43)
  store i32 %44, ptr %6, align 4, !tbaa !9
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %49

47:                                               ; preds = %38
  %48 = load i32, ptr %6, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 353, i32 noundef %48)
  br label %52

49:                                               ; preds = %38
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51, %47, %33, %19
  %53 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %53, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %54

54:                                               ; preds = %52, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %55 = load i32, ptr %3, align 4
  ret i32 %55
}

declare noundef i32 @_ZN7UapkiNS4Util15genTimeFromAsn1EPK12OCTET_STRINGRm(ptr noundef, ptr noundef nonnull align 8 dereferenceable(8)) #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, !6, i64 32}
!12 = !{!"_ZTSN7UapkiNS4Ocsp10OcspHelperE", !13, i64 0, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !17, i64 80, !18, i64 88}
!13 = !{!"_ZTSSt6vectorIN7UapkiNS4Ocsp10OcspHelper18SingleResponseInfoESaIS3_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIN7UapkiNS4Ocsp10OcspHelper18SingleResponseInfoESaIS3_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN7UapkiNS4Ocsp10OcspHelper18SingleResponseInfoESaIS3_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN7UapkiNS4Ocsp10OcspHelper18SingleResponseInfoESaIS3_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTSN7UapkiNS4Ocsp14ResponseStatusE", !7, 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"

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

declare ptr @get_BasicOCSPResponse_desc() local_unnamed_addr #0

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

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

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

declare ptr @get_ResponseData_desc() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS4Ocsp10OcspHelper22parseBasicOcspResponseEPK12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(92) %0, ptr noundef %1) local_unnamed_addr #1 align 2 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %21, label %3

3:                                                ; preds = %2
  %4 = tail call ptr @get_BasicOCSPResponse_desc()
  %5 = tail call ptr @asn_decode_ba_with_alloc(ptr noundef %4, ptr noundef nonnull %1)
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %5, ptr %6, align 8, !tbaa !5
  %7 = icmp eq ptr %5, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %3
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 349, i32 noundef 2)
  br label %21

9:                                                ; preds = %3
  %10 = tail call ptr @get_ResponseData_desc()
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 72
  %13 = tail call i32 @asn_encode_ba(ptr noundef %10, ptr noundef %11, ptr noundef nonnull %12)
  %.not13 = icmp eq i32 %13, 0
  br i1 %.not13, label %15, label %14

14:                                               ; preds = %9
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 351, i32 noundef %13)
  br label %21

15:                                               ; preds = %9
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 120
  %18 = getelementptr inbounds i8, ptr %0, i64 80
  %19 = tail call noundef i32 @_ZN7UapkiNS4Util15genTimeFromAsn1EPK12OCTET_STRINGRm(ptr noundef nonnull %17, ptr noundef nonnull align 8 dereferenceable(8) %18)
  %.not14 = icmp eq i32 %19, 0
  br i1 %.not14, label %21, label %20

20:                                               ; preds = %15
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 353, i32 noundef %19)
  br label %21

21:                                               ; preds = %8, %14, %20, %15, %2
  %.09 = phi i32 [ 4101, %2 ], [ 2, %8 ], [ %13, %14 ], [ %19, %20 ], [ 0, %15 ]
  ret i32 %.09
}

declare noundef i32 @_ZN7UapkiNS4Util15genTimeFromAsn1EPK12OCTET_STRINGRm(ptr noundef, ptr noundef nonnull align 8 dereferenceable(8)) 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 32}
!6 = !{!"_ZTSN7UapkiNS4Ocsp10OcspHelperE", !7, i64 0, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !14, i64 80, !15, i64 88}
!7 = !{!"_ZTSSt6vectorIN7UapkiNS4Ocsp10OcspHelper18SingleResponseInfoESaIS3_EE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseIN7UapkiNS4Ocsp10OcspHelper18SingleResponseInfoESaIS3_EE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseIN7UapkiNS4Ocsp10OcspHelper18SingleResponseInfoESaIS3_EE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseIN7UapkiNS4Ocsp10OcspHelper18SingleResponseInfoESaIS3_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"long", !12, i64 0}
!15 = !{!"_ZTSN7UapkiNS4Ocsp14ResponseStatusE", !12, i64 0}


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