; LLVM IR from specinfo-ua/UAPKI :: library/cm-pkcs12/src/storage (content-info)

; 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.ContentInfo = 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 }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }

@.str = external hidden unnamed_addr constant [33 x i8], align 1
@OID_PKCS7_DATA = external global ptr, align 8
@OID_PKCS7_SIGNED_DATA = external global ptr, align 8
@OID_PKCS7_DIGESTED_DATA = external global ptr, align 8
@OID_PKCS7_ENCRYPTED_DATA = external global ptr, align 8
@OID_PKCS7_ENVELOPED_DATA = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @cinfo_get_type(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %2
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %11, label %9

9:                                                ; preds = %6
  store i32 2, ptr %5, align 4, !tbaa !9
  %10 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 45, i32 noundef %10, ptr noundef null)
  br label %63

11:                                               ; preds = %6
  br label %12

12:                                               ; preds = %11
  br label %13

13:                                               ; preds = %12
  br label %14

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

17:                                               ; preds = %14
  store i32 2, ptr %5, align 4, !tbaa !9
  %18 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 46, i32 noundef %18, ptr noundef null)
  br label %63

19:                                               ; preds = %14
  br label %20

20:                                               ; preds = %19
  br label %21

21:                                               ; preds = %20
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ContentInfo, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr @OID_PKCS7_DATA, align 8, !tbaa !5
  %25 = call zeroext i1 @OID_is_equal_oid(ptr noundef %23, ptr noundef %24)
  br i1 %25, label %26, label %28

26:                                               ; preds = %21
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 1, ptr %27, align 4, !tbaa !9
  br label %62

28:                                               ; preds = %21
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ContentInfo, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr @OID_PKCS7_SIGNED_DATA, align 8, !tbaa !5
  %32 = call zeroext i1 @OID_is_equal_oid(ptr noundef %30, ptr noundef %31)
  br i1 %32, label %33, label %35

33:                                               ; preds = %28
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 2, ptr %34, align 4, !tbaa !9
  br label %61

35:                                               ; preds = %28
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ContentInfo, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr @OID_PKCS7_DIGESTED_DATA, align 8, !tbaa !5
  %39 = call zeroext i1 @OID_is_equal_oid(ptr noundef %37, ptr noundef %38)
  br i1 %39, label %40, label %42

40:                                               ; preds = %35
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 3, ptr %41, align 4, !tbaa !9
  br label %60

42:                                               ; preds = %35
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ContentInfo, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr @OID_PKCS7_ENCRYPTED_DATA, align 8, !tbaa !5
  %46 = call zeroext i1 @OID_is_equal_oid(ptr noundef %44, ptr noundef %45)
  br i1 %46, label %47, label %49

47:                                               ; preds = %42
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 4, ptr %48, align 4, !tbaa !9
  br label %59

49:                                               ; preds = %42
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ContentInfo, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr @OID_PKCS7_ENVELOPED_DATA, align 8, !tbaa !5
  %53 = call zeroext i1 @OID_is_equal_oid(ptr noundef %51, ptr noundef %52)
  br i1 %53, label %54, label %56

54:                                               ; preds = %49
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 5, ptr %55, align 4, !tbaa !9
  br label %58

56:                                               ; preds = %49
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 0, ptr %57, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %56, %54
  br label %59

59:                                               ; preds = %58, %47
  br label %60

60:                                               ; preds = %59, %40
  br label %61

61:                                               ; preds = %60, %33
  br label %62

62:                                               ; preds = %61, %26
  br label %63

63:                                               ; preds = %62, %17, %9
  %64 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %64
}

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

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

declare zeroext i1 @OID_is_equal_oid(ptr noundef, ptr noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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 [33 x i8], align 1
@OID_PKCS7_DATA = external local_unnamed_addr global ptr, align 8
@OID_PKCS7_SIGNED_DATA = external local_unnamed_addr global ptr, align 8
@OID_PKCS7_DIGESTED_DATA = external local_unnamed_addr global ptr, align 8
@OID_PKCS7_ENCRYPTED_DATA = external local_unnamed_addr global ptr, align 8
@OID_PKCS7_ENVELOPED_DATA = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @cinfo_get_type(ptr noundef %0, ptr noundef writeonly %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %2
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 45, i32 noundef 2, ptr noundef null) #2
  br label %27

4:                                                ; preds = %2
  %.not17 = icmp eq ptr %1, null
  br i1 %.not17, label %5, label %6

5:                                                ; preds = %4
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 46, i32 noundef 2, ptr noundef null) #2
  br label %27

6:                                                ; preds = %4
  %7 = load ptr, ptr @OID_PKCS7_DATA, align 8, !tbaa !5
  %8 = tail call zeroext i1 @OID_is_equal_oid(ptr noundef nonnull %0, ptr noundef %7) #2
  br i1 %8, label %9, label %10

9:                                                ; preds = %6
  store i32 1, ptr %1, align 4, !tbaa !9
  br label %27

10:                                               ; preds = %6
  %11 = load ptr, ptr @OID_PKCS7_SIGNED_DATA, align 8, !tbaa !5
  %12 = tail call zeroext i1 @OID_is_equal_oid(ptr noundef nonnull %0, ptr noundef %11) #2
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  store i32 2, ptr %1, align 4, !tbaa !9
  br label %27

14:                                               ; preds = %10
  %15 = load ptr, ptr @OID_PKCS7_DIGESTED_DATA, align 8, !tbaa !5
  %16 = tail call zeroext i1 @OID_is_equal_oid(ptr noundef nonnull %0, ptr noundef %15) #2
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  store i32 3, ptr %1, align 4, !tbaa !9
  br label %27

18:                                               ; preds = %14
  %19 = load ptr, ptr @OID_PKCS7_ENCRYPTED_DATA, align 8, !tbaa !5
  %20 = tail call zeroext i1 @OID_is_equal_oid(ptr noundef nonnull %0, ptr noundef %19) #2
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  store i32 4, ptr %1, align 4, !tbaa !9
  br label %27

22:                                               ; preds = %18
  %23 = load ptr, ptr @OID_PKCS7_ENVELOPED_DATA, align 8, !tbaa !5
  %24 = tail call zeroext i1 @OID_is_equal_oid(ptr noundef nonnull %0, ptr noundef %23) #2
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  store i32 5, ptr %1, align 4, !tbaa !9
  br label %27

26:                                               ; preds = %22
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %9, %17, %25, %26, %21, %13, %5, %3
  %.0 = phi i32 [ 0, %9 ], [ 0, %13 ], [ 0, %17 ], [ 0, %21 ], [ 0, %25 ], [ 0, %26 ], [ 2, %5 ], [ 2, %3 ]
  ret i32 %.0
}

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

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

attributes #0 = { 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 #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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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