; LLVM IR from specinfo-ua/UAPKI :: library/common/pkix (aid)

; 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.DSTU4145Params = type { %struct.DSTUEllipticCurve, ptr, %struct.asn_struct_ctx_s }
%struct.DSTUEllipticCurve = type { i32, %union.DSTUEllipticCurve_u, %struct.asn_struct_ctx_s }
%union.DSTUEllipticCurve_u = type { %struct.ECBinary }
%struct.ECBinary = type { ptr, %struct.BinaryField, i64, %struct.OCTET_STRING, %struct.ASN__PRIMITIVE_TYPE_s, %struct.OCTET_STRING, %struct.asn_struct_ctx_s }
%struct.BinaryField = type { %struct.ASN__PRIMITIVE_TYPE_s, ptr, %struct.asn_struct_ctx_s }
%struct.ASN__PRIMITIVE_TYPE_s = type { ptr, i32 }
%struct.OCTET_STRING = type { ptr, i32, %struct.asn_struct_ctx_s }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }
%struct.AlgorithmIdentifier = type { %struct.ASN__PRIMITIVE_TYPE_s, ptr, %struct.asn_struct_ctx_s }

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

declare ptr @get_AlgorithmIdentifier_desc() #0

; Function Attrs: nounwind uwtable
define dso_local i32 @aid_create_dstu4145_default(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store ptr null, ptr %9, align 8, !tbaa !5
  %10 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 248) #5
  store ptr %10, ptr %9, align 8, !tbaa !5
  %11 = load ptr, ptr %9, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %15

13:                                               ; preds = %3
  store i32 1, ptr %7, align 4, !tbaa !9
  %14 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 46, i32 noundef %14, ptr noundef null)
  br label %65

15:                                               ; preds = %3
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.DSTU4145Params, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %struct.DSTUEllipticCurve, ptr %17, i32 0, i32 0
  store i32 2, ptr %18, align 8, !tbaa !11
  br label %19

19:                                               ; preds = %15
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.DSTU4145Params, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %struct.DSTUEllipticCurve, ptr %22, i32 0, i32 1
  %24 = call i32 @asn_set_oid_from_text(ptr noundef %20, ptr noundef %23)
  store i32 %24, ptr %7, align 4, !tbaa !9
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %19
  %28 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 49, i32 noundef %28)
  br label %65

29:                                               ; preds = %19
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  %32 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 48) #5
  store ptr %32, ptr %8, align 8, !tbaa !5
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %37

35:                                               ; preds = %31
  store i32 1, ptr %7, align 4, !tbaa !9
  %36 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 51, i32 noundef %36, ptr noundef null)
  br label %65

37:                                               ; preds = %31
  br label %38

38:                                               ; preds = %37
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.AlgorithmIdentifier, ptr %40, i32 0, i32 0
  %42 = call i32 @asn_set_oid_from_text(ptr noundef %39, ptr noundef %41)
  store i32 %42, ptr %7, align 4, !tbaa !9
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %47

45:                                               ; preds = %38
  %46 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 53, i32 noundef %46)
  br label %65

47:                                               ; preds = %38
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  %51 = call ptr @get_DSTU4145Params_desc()
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.AlgorithmIdentifier, ptr %53, i32 0, i32 1
  %55 = call i32 @asn_create_any(ptr noundef %51, ptr noundef %52, ptr noundef %54)
  store i32 %55, ptr %7, align 4, !tbaa !9
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %60

58:                                               ; preds = %50
  %59 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 54, i32 noundef %59)
  br label %65

60:                                               ; preds = %50
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %63, ptr %64, align 8, !tbaa !5
  store ptr null, ptr %8, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %62, %58, %45, %35, %27, %13
  %66 = call ptr @get_DSTU4145Params_desc()
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  call void @asn_free(ptr noundef %66, ptr noundef %67)
  %68 = call ptr @get_AlgorithmIdentifier_desc()
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  call void @asn_free(ptr noundef %68, ptr noundef %69)
  %70 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %70
}

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

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

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

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

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

declare ptr @get_DSTU4145Params_desc() #0

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

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

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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind allocsize(0,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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0,1) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"DSTU4145Params", !13, i64 0, !6, i64 216, !14, i64 224}
!13 = !{!"DSTUEllipticCurve", !10, i64 0, !7, i64 8, !14, i64 192}
!14 = !{!"asn_struct_ctx_s", !15, i64 0, !15, i64 2, !10, i64 4, !6, i64 8, !16, i64 16}
!15 = !{!"short", !7, i64 0}
!16 = !{!"long", !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 [18 x i8], align 1

declare ptr @get_AlgorithmIdentifier_desc() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @aid_create_dstu4145_default(ptr noundef %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = tail call noalias dereferenceable_or_null(248) ptr @calloc(i64 noundef 1, i64 noundef 248) #3
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %3
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 46, i32 noundef 1, ptr noundef null) #4
  br label %24

7:                                                ; preds = %3
  store i32 2, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %4, i64 8
  %9 = tail call i32 @asn_set_oid_from_text(ptr noundef %1, ptr noundef nonnull %8) #4
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %11, label %10

10:                                               ; preds = %7
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 49, i32 noundef %9) #4
  br label %24

11:                                               ; preds = %7
  %12 = tail call noalias dereferenceable_or_null(48) ptr @calloc(i64 noundef 1, i64 noundef 48) #3
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 51, i32 noundef 1, ptr noundef null) #4
  br label %24

15:                                               ; preds = %11
  %16 = tail call i32 @asn_set_oid_from_text(ptr noundef %0, ptr noundef nonnull %12) #4
  %.not28 = icmp eq i32 %16, 0
  br i1 %.not28, label %18, label %17

17:                                               ; preds = %15
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 53, i32 noundef %16) #4
  br label %24

18:                                               ; preds = %15
  %19 = tail call ptr @get_DSTU4145Params_desc() #4
  %20 = getelementptr inbounds i8, ptr %12, i64 16
  %21 = tail call i32 @asn_create_any(ptr noundef %19, ptr noundef nonnull %4, ptr noundef nonnull %20) #4
  %.not29 = icmp eq i32 %21, 0
  br i1 %.not29, label %23, label %22

22:                                               ; preds = %18
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 54, i32 noundef %21) #4
  br label %24

23:                                               ; preds = %18
  store ptr %12, ptr %2, align 8, !tbaa !15
  br label %24

24:                                               ; preds = %23, %22, %17, %14, %10, %6
  %.021 = phi i32 [ 1, %6 ], [ %9, %10 ], [ 1, %14 ], [ %16, %17 ], [ %21, %22 ], [ 0, %23 ]
  %.0 = phi ptr [ null, %6 ], [ null, %10 ], [ null, %14 ], [ %12, %17 ], [ %12, %22 ], [ null, %23 ]
  %25 = tail call ptr @get_DSTU4145Params_desc() #4
  tail call void @asn_free(ptr noundef %25, ptr noundef %4) #4
  %26 = tail call ptr @get_AlgorithmIdentifier_desc() #4
  tail call void @asn_free(ptr noundef %26, ptr noundef %.0) #4
  ret i32 %.021
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2

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

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

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

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

declare ptr @get_DSTU4145Params_desc() local_unnamed_addr #0

declare void @asn_free(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 = { 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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0,1) }
attributes #4 = { 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, !8, i64 0}
!6 = !{!"DSTU4145Params", !7, i64 0, !13, i64 216, !11, i64 224}
!7 = !{!"DSTUEllipticCurve", !8, i64 0, !9, i64 8, !11, i64 192}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"asn_struct_ctx_s", !12, i64 0, !12, i64 2, !8, i64 4, !13, i64 8, !14, i64 16}
!12 = !{!"short", !9, i64 0}
!13 = !{!"any pointer", !9, i64 0}
!14 = !{!"long", !9, i64 0}
!15 = !{!13, !13, i64 0}


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