; LLVM IR from openanolis/openssl :: crypto/pkcs7 (pk7_attr)

; 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.X509_algor_st = type { ptr, ptr }
%struct.asn1_type_st = type { i32, %union.anon }
%union.anon = type { ptr }

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

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

declare void @ERR_new() #1

declare void @ERR_set_debug(ptr noundef, i32 noundef, ptr noundef) #1

declare void @ERR_set_error(i32 noundef, i32 noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @PKCS7_simple_smimecap(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, 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
  %11 = call ptr @X509_ALGOR_new()
  store ptr %11, ptr %9, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 56, ptr noundef @__func__.PKCS7_simple_smimecap)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 33, i32 noundef 524301, ptr noundef null)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %63

14:                                               ; preds = %3
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.X509_algor_st, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  call void @ASN1_OBJECT_free(ptr noundef %17)
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = call ptr @OBJ_nid2obj(i32 noundef %18)
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.X509_algor_st, ptr %20, i32 0, i32 0
  store ptr %19, ptr %21, align 8, !tbaa !11
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %24, label %51

24:                                               ; preds = %14
  %25 = call ptr @ASN1_TYPE_new()
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.X509_algor_st, ptr %26, i32 0, i32 1
  store ptr %25, ptr %27, align 8, !tbaa !13
  %28 = icmp eq ptr %25, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %24
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 63, ptr noundef @__func__.PKCS7_simple_smimecap)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 33, i32 noundef 524301, ptr noundef null)
  br label %60

30:                                               ; preds = %24
  %31 = call ptr @ASN1_INTEGER_new()
  store ptr %31, ptr %8, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 67, ptr noundef @__func__.PKCS7_simple_smimecap)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 33, i32 noundef 524301, ptr noundef null)
  br label %60

34:                                               ; preds = %30
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = call i32 @ASN1_INTEGER_set(ptr noundef %35, i64 noundef %37)
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %41, label %40

40:                                               ; preds = %34
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 71, ptr noundef @__func__.PKCS7_simple_smimecap)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 33, i32 noundef 524301, ptr noundef null)
  br label %60

41:                                               ; preds = %34
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.X509_algor_st, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !13
  %46 = getelementptr inbounds %struct.asn1_type_st, ptr %45, i32 0, i32 1
  store ptr %42, ptr %46, align 8, !tbaa !14
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.X509_algor_st, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = getelementptr inbounds %struct.asn1_type_st, ptr %49, i32 0, i32 0
  store i32 2, ptr %50, align 8, !tbaa !15
  store ptr null, ptr %8, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %41, %14
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = call ptr @ossl_check_X509_ALGOR_sk_type(ptr noundef %52)
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = call ptr @ossl_check_X509_ALGOR_type(ptr noundef %54)
  %56 = call i32 @OPENSSL_sk_push(ptr noundef %53, ptr noundef %55)
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %59, label %58

58:                                               ; preds = %51
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 79, ptr noundef @__func__.PKCS7_simple_smimecap)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 33, i32 noundef 524303, ptr noundef null)
  br label %60

59:                                               ; preds = %51
  store i32 1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %63

60:                                               ; preds = %58, %40, %33, %29
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  call void @ASN1_INTEGER_free(ptr noundef %61)
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  call void @X509_ALGOR_free(ptr noundef %62)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %63

63:                                               ; preds = %60, %59, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %64 = load i32, ptr %4, align 4
  ret i32 %64
}

declare ptr @X509_ALGOR_new() #1

declare void @ASN1_OBJECT_free(ptr noundef) #1

declare ptr @OBJ_nid2obj(i32 noundef) #1

declare ptr @ASN1_TYPE_new() #1

declare ptr @ASN1_INTEGER_new() #1

declare i32 @ASN1_INTEGER_set(ptr noundef, i64 noundef) #1

declare i32 @OPENSSL_sk_push(ptr noundef, ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @ossl_check_X509_ALGOR_sk_type(ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @ossl_check_X509_ALGOR_type(ptr noundef) #3

declare void @ASN1_INTEGER_free(ptr noundef) #1

declare void @X509_ALGOR_free(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 = { 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 #3 = { inlinehint 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 #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, !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, !6, i64 0}
!12 = !{!"X509_algor_st", !6, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"asn1_type_st", !10, i64 0, !7, i64 8}


; 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 [76 x i8], align 1
@__func__.PKCS7_simple_smimecap = external hidden unnamed_addr constant [22 x i8], align 1

declare void @ERR_new() local_unnamed_addr #0

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

declare void @ERR_set_error(i32 noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @PKCS7_simple_smimecap(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = tail call ptr @X509_ALGOR_new() #3
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %3
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 56, ptr noundef nonnull @__func__.PKCS7_simple_smimecap) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 33, i32 noundef 524301, ptr noundef null) #3
  br label %30

7:                                                ; preds = %3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  tail call void @ASN1_OBJECT_free(ptr noundef %8) #3
  %9 = tail call ptr @OBJ_nid2obj(i32 noundef %1) #3
  store ptr %9, ptr %4, align 8, !tbaa !5
  %10 = icmp sgt i32 %2, 0
  br i1 %10, label %11, label %25

11:                                               ; preds = %7
  %12 = tail call ptr @ASN1_TYPE_new() #3
  %13 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %12, ptr %13, align 8, !tbaa !10
  %14 = icmp eq ptr %12, null
  br i1 %14, label %29, label %15

15:                                               ; preds = %11
  %16 = tail call ptr @ASN1_INTEGER_new() #3
  %17 = icmp eq ptr %16, null
  br i1 %17, label %29, label %18

18:                                               ; preds = %15
  %19 = zext nneg i32 %2 to i64
  %20 = tail call i32 @ASN1_INTEGER_set(ptr noundef nonnull %16, i64 noundef %19) #3
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %29, label %21

21:                                               ; preds = %18
  %22 = load ptr, ptr %13, align 8, !tbaa !10
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  store ptr %16, ptr %23, align 8, !tbaa !11
  %24 = load ptr, ptr %13, align 8, !tbaa !10
  store i32 2, ptr %24, align 8, !tbaa !12
  br label %25

25:                                               ; preds = %21, %7
  %26 = tail call ptr @ossl_check_X509_ALGOR_sk_type(ptr noundef %0)
  %27 = tail call ptr @ossl_check_X509_ALGOR_type(ptr noundef nonnull %4)
  %28 = tail call i32 @OPENSSL_sk_push(ptr noundef %26, ptr noundef %27) #3
  %.not19 = icmp eq i32 %28, 0
  br i1 %.not19, label %29, label %30

29:                                               ; preds = %25, %18, %15, %11
  %.sink20 = phi i32 [ 63, %11 ], [ 67, %15 ], [ 71, %18 ], [ 79, %25 ]
  %.sink = phi i32 [ 524301, %11 ], [ 524301, %15 ], [ 524301, %18 ], [ 524303, %25 ]
  %.1 = phi ptr [ null, %11 ], [ null, %15 ], [ %16, %18 ], [ null, %25 ]
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef %.sink20, ptr noundef nonnull @__func__.PKCS7_simple_smimecap) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 33, i32 noundef %.sink, ptr noundef null) #3
  tail call void @ASN1_INTEGER_free(ptr noundef %.1) #3
  tail call void @X509_ALGOR_free(ptr noundef nonnull %4) #3
  br label %30

30:                                               ; preds = %25, %29, %6
  %.0 = phi i32 [ 0, %6 ], [ 0, %29 ], [ 1, %25 ]
  ret i32 %.0
}

declare ptr @X509_ALGOR_new() local_unnamed_addr #0

declare void @ASN1_OBJECT_free(ptr noundef) local_unnamed_addr #0

declare ptr @OBJ_nid2obj(i32 noundef) local_unnamed_addr #0

declare ptr @ASN1_TYPE_new() local_unnamed_addr #0

declare ptr @ASN1_INTEGER_new() local_unnamed_addr #0

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @ossl_check_X509_ALGOR_sk_type(ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @ossl_check_X509_ALGOR_type(ptr noundef) local_unnamed_addr #2

declare void @ASN1_INTEGER_free(ptr noundef) local_unnamed_addr #0

declare void @X509_ALGOR_free(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 = { inlinehint 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 #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, !7, i64 0}
!6 = !{!"X509_algor_st", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!8, !8, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"asn1_type_st", !14, i64 0, !8, i64 8}
!14 = !{!"int", !8, i64 0}


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