; LLVM IR from openanolis/openssl :: crypto/crmf (crmf_lib)

; 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.ossl_crmf_popo_st = type { i32, %union.anon.1 }
%union.anon.1 = type { ptr }
%struct.ossl_crmf_msg_st = type { ptr, ptr, ptr }
%struct.ossl_crmf_popoprivkey_st = type { i32, %union.anon.2 }
%union.anon.2 = type { ptr }

@.str = external hidden unnamed_addr constant [75 x i8], align 1
@__func__.OSSL_CRMF_MSG_create_popo = external hidden unnamed_addr constant [26 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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @OSSL_CRMF_MSG_create_popo(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #2 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  store i32 %0, ptr %8, align 4, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  store ptr null, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  store ptr null, ptr %15, align 8, !tbaa !9
  %18 = load ptr, ptr %9, align 8, !tbaa !9
  %19 = icmp eq ptr %18, null
  br i1 %19, label %26, label %20

20:                                               ; preds = %6
  %21 = load i32, ptr %8, align 4, !tbaa !5
  %22 = icmp eq i32 %21, 1
  br i1 %22, label %23, label %27

23:                                               ; preds = %20
  %24 = load ptr, ptr %10, align 8, !tbaa !9
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %23, %6
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 402, ptr noundef @__func__.OSSL_CRMF_MSG_create_popo)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 56, i32 noundef 109, ptr noundef null)
  store i32 0, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %108

27:                                               ; preds = %23, %20
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = icmp eq i32 %28, -1
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  br label %99

31:                                               ; preds = %27
  %32 = call ptr @OSSL_CRMF_POPO_new()
  store ptr %32, ptr %14, align 8, !tbaa !9
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  br label %106

35:                                               ; preds = %31
  %36 = load i32, ptr %8, align 4, !tbaa !5
  %37 = load ptr, ptr %14, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.ossl_crmf_popo_st, ptr %37, i32 0, i32 0
  store i32 %36, ptr %38, align 8, !tbaa !11
  %39 = load i32, ptr %8, align 4, !tbaa !5
  switch i32 %39, label %97 [
    i32 0, label %40
    i32 1, label %47
    i32 2, label %72
  ]

40:                                               ; preds = %35
  %41 = call ptr @ASN1_NULL_new()
  %42 = load ptr, ptr %14, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.ossl_crmf_popo_st, ptr %42, i32 0, i32 1
  store ptr %41, ptr %43, align 8, !tbaa !13
  %44 = icmp eq ptr %41, null
  br i1 %44, label %45, label %46

45:                                               ; preds = %40
  br label %106

46:                                               ; preds = %40
  br label %98

47:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %48 = call ptr @OSSL_CRMF_POPOSIGNINGKEY_new()
  store ptr %48, ptr %17, align 8, !tbaa !9
  %49 = load ptr, ptr %17, align 8, !tbaa !9
  %50 = icmp eq ptr %49, null
  br i1 %50, label %51, label %52

51:                                               ; preds = %47
  store i32 3, ptr %16, align 4
  br label %69

52:                                               ; preds = %47
  %53 = load ptr, ptr %17, align 8, !tbaa !9
  %54 = load ptr, ptr %9, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.ossl_crmf_msg_st, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !14
  %57 = load ptr, ptr %10, align 8, !tbaa !9
  %58 = load ptr, ptr %11, align 8, !tbaa !9
  %59 = load ptr, ptr %12, align 8, !tbaa !9
  %60 = load ptr, ptr %13, align 8, !tbaa !9
  %61 = call i32 @create_popo_signature(ptr noundef %53, ptr noundef %56, ptr noundef %57, ptr noundef %58, ptr noundef %59, ptr noundef %60)
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %65, label %63

63:                                               ; preds = %52
  %64 = load ptr, ptr %17, align 8, !tbaa !9
  call void @OSSL_CRMF_POPOSIGNINGKEY_free(ptr noundef %64)
  store i32 3, ptr %16, align 4
  br label %69

65:                                               ; preds = %52
  %66 = load ptr, ptr %17, align 8, !tbaa !9
  %67 = load ptr, ptr %14, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.ossl_crmf_popo_st, ptr %67, i32 0, i32 1
  store ptr %66, ptr %68, align 8, !tbaa !13
  store i32 0, ptr %16, align 4
  br label %69

69:                                               ; preds = %65, %63, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  %70 = load i32, ptr %16, align 4
  switch i32 %70, label %108 [
    i32 0, label %71
    i32 3, label %106
  ]

71:                                               ; preds = %69
  br label %98

72:                                               ; preds = %35
  %73 = call ptr @OSSL_CRMF_POPOPRIVKEY_new()
  %74 = load ptr, ptr %14, align 8, !tbaa !9
  %75 = getelementptr inbounds %struct.ossl_crmf_popo_st, ptr %74, i32 0, i32 1
  store ptr %73, ptr %75, align 8, !tbaa !13
  %76 = icmp eq ptr %73, null
  br i1 %76, label %77, label %78

77:                                               ; preds = %72
  br label %106

78:                                               ; preds = %72
  %79 = call ptr @ASN1_INTEGER_new()
  store ptr %79, ptr %15, align 8, !tbaa !9
  %80 = load ptr, ptr %14, align 8, !tbaa !9
  %81 = getelementptr inbounds %struct.ossl_crmf_popo_st, ptr %80, i32 0, i32 1
  %82 = load ptr, ptr %81, align 8, !tbaa !13
  %83 = getelementptr inbounds %struct.ossl_crmf_popoprivkey_st, ptr %82, i32 0, i32 0
  store i32 1, ptr %83, align 8, !tbaa !16
  %84 = load ptr, ptr %15, align 8, !tbaa !9
  %85 = load ptr, ptr %14, align 8, !tbaa !9
  %86 = getelementptr inbounds %struct.ossl_crmf_popo_st, ptr %85, i32 0, i32 1
  %87 = load ptr, ptr %86, align 8, !tbaa !13
  %88 = getelementptr inbounds %struct.ossl_crmf_popoprivkey_st, ptr %87, i32 0, i32 1
  store ptr %84, ptr %88, align 8, !tbaa !13
  %89 = load ptr, ptr %15, align 8, !tbaa !9
  %90 = icmp eq ptr %89, null
  br i1 %90, label %95, label %91

91:                                               ; preds = %78
  %92 = load ptr, ptr %15, align 8, !tbaa !9
  %93 = call i32 @ASN1_INTEGER_set(ptr noundef %92, i64 noundef 0)
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %96, label %95

95:                                               ; preds = %91, %78
  br label %106

96:                                               ; preds = %91
  br label %98

97:                                               ; preds = %35
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 446, ptr noundef @__func__.OSSL_CRMF_MSG_create_popo)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 56, i32 noundef 115, ptr noundef null)
  br label %106

98:                                               ; preds = %96, %71, %46
  br label %99

99:                                               ; preds = %98, %30
  %100 = load ptr, ptr %9, align 8, !tbaa !9
  %101 = getelementptr inbounds %struct.ossl_crmf_msg_st, ptr %100, i32 0, i32 1
  %102 = load ptr, ptr %101, align 8, !tbaa !18
  call void @OSSL_CRMF_POPO_free(ptr noundef %102)
  %103 = load ptr, ptr %14, align 8, !tbaa !9
  %104 = load ptr, ptr %9, align 8, !tbaa !9
  %105 = getelementptr inbounds %struct.ossl_crmf_msg_st, ptr %104, i32 0, i32 1
  store ptr %103, ptr %105, align 8, !tbaa !18
  store i32 1, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %108

106:                                              ; preds = %97, %95, %77, %69, %45, %34
  %107 = load ptr, ptr %14, align 8, !tbaa !9
  call void @OSSL_CRMF_POPO_free(ptr noundef %107)
  store i32 0, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %108

108:                                              ; preds = %106, %99, %69, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %109 = load i32, ptr %7, align 4
  ret i32 %109
}

declare ptr @OSSL_CRMF_POPO_new() #1

declare ptr @ASN1_NULL_new() #1

declare ptr @OSSL_CRMF_POPOSIGNINGKEY_new() #1

; Function Attrs: nounwind uwtable
declare hidden i32 @create_popo_signature(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare void @OSSL_CRMF_POPOSIGNINGKEY_free(ptr noundef) #1

declare ptr @OSSL_CRMF_POPOPRIVKEY_new() #1

declare ptr @ASN1_INTEGER_new() #1

declare void @OSSL_CRMF_POPO_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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"ossl_crmf_popo_st", !6, i64 0, !7, i64 8}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"ossl_crmf_msg_st", !10, i64 0, !10, i64 8, !10, i64 16}
!16 = !{!17, !6, i64 0}
!17 = !{!"ossl_crmf_popoprivkey_st", !6, i64 0, !7, i64 8}
!18 = !{!15, !10, 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 [75 x i8], align 1
@__func__.OSSL_CRMF_MSG_create_popo = external hidden unnamed_addr constant [26 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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @OSSL_CRMF_MSG_create_popo(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #1 {
  %7 = icmp eq ptr %1, null
  br i1 %7, label %11, label %8

8:                                                ; preds = %6
  %9 = icmp eq i32 %0, 1
  %10 = icmp eq ptr %2, null
  %or.cond = and i1 %9, %10
  br i1 %or.cond, label %11, label %12

11:                                               ; preds = %8, %6
  tail call void @ERR_new() #2
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 402, ptr noundef nonnull @__func__.OSSL_CRMF_MSG_create_popo) #2
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 56, i32 noundef 109, ptr noundef null) #2
  br label %47

12:                                               ; preds = %8
  %13 = icmp eq i32 %0, -1
  br i1 %13, label %44, label %14

14:                                               ; preds = %12
  %15 = tail call ptr @OSSL_CRMF_POPO_new() #2
  %16 = icmp eq ptr %15, null
  br i1 %16, label %.thread, label %17

17:                                               ; preds = %14
  store i32 %0, ptr %15, align 8, !tbaa !5
  switch i32 %0, label %43 [
    i32 0, label %18
    i32 1, label %22
    i32 2, label %31
  ]

18:                                               ; preds = %17
  %19 = tail call ptr @ASN1_NULL_new() #2
  %20 = getelementptr inbounds i8, ptr %15, i64 8
  store ptr %19, ptr %20, align 8, !tbaa !10
  %21 = icmp eq ptr %19, null
  br i1 %21, label %.thread, label %44

22:                                               ; preds = %17
  %23 = tail call ptr @OSSL_CRMF_POPOSIGNINGKEY_new() #2
  %24 = icmp eq ptr %23, null
  br i1 %24, label %.thread, label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr %1, align 8, !tbaa !11
  %27 = tail call i32 @create_popo_signature(ptr noundef nonnull %23, ptr noundef %26, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  %.not37 = icmp eq i32 %27, 0
  br i1 %.not37, label %28, label %29

28:                                               ; preds = %25
  tail call void @OSSL_CRMF_POPOSIGNINGKEY_free(ptr noundef nonnull %23) #2
  br label %.thread

29:                                               ; preds = %25
  %30 = getelementptr inbounds i8, ptr %15, i64 8
  store ptr %23, ptr %30, align 8, !tbaa !10
  br label %44

31:                                               ; preds = %17
  %32 = tail call ptr @OSSL_CRMF_POPOPRIVKEY_new() #2
  %33 = getelementptr inbounds i8, ptr %15, i64 8
  store ptr %32, ptr %33, align 8, !tbaa !10
  %34 = icmp eq ptr %32, null
  br i1 %34, label %.thread, label %35

35:                                               ; preds = %31
  %36 = tail call ptr @ASN1_INTEGER_new() #2
  %37 = load ptr, ptr %33, align 8, !tbaa !10
  store i32 1, ptr %37, align 8, !tbaa !14
  %38 = load ptr, ptr %33, align 8, !tbaa !10
  %39 = getelementptr inbounds i8, ptr %38, i64 8
  store ptr %36, ptr %39, align 8, !tbaa !10
  %40 = icmp eq ptr %36, null
  br i1 %40, label %.thread, label %41

41:                                               ; preds = %35
  %42 = tail call i32 @ASN1_INTEGER_set(ptr noundef nonnull %36, i64 noundef 0) #2
  %.not = icmp eq i32 %42, 0
  br i1 %.not, label %.thread, label %44

43:                                               ; preds = %17
  tail call void @ERR_new() #2
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 446, ptr noundef nonnull @__func__.OSSL_CRMF_MSG_create_popo) #2
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 56, i32 noundef 115, ptr noundef null) #2
  br label %.thread

44:                                               ; preds = %29, %18, %41, %12
  %.031 = phi ptr [ null, %12 ], [ %15, %41 ], [ %15, %29 ], [ %15, %18 ]
  %45 = getelementptr inbounds i8, ptr %1, i64 8
  %46 = load ptr, ptr %45, align 8, !tbaa !16
  tail call void @OSSL_CRMF_POPO_free(ptr noundef %46) #2
  store ptr %.031, ptr %45, align 8, !tbaa !16
  br label %47

.thread:                                          ; preds = %22, %28, %35, %41, %31, %18, %14, %43
  tail call void @OSSL_CRMF_POPO_free(ptr noundef %15) #2
  br label %47

47:                                               ; preds = %.thread, %44, %11
  %.0 = phi i32 [ 0, %11 ], [ 1, %44 ], [ 0, %.thread ]
  ret i32 %.0
}

declare ptr @OSSL_CRMF_POPO_new() local_unnamed_addr #0

declare ptr @ASN1_NULL_new() local_unnamed_addr #0

declare ptr @OSSL_CRMF_POPOSIGNINGKEY_new() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @create_popo_signature(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @OSSL_CRMF_POPOSIGNINGKEY_free(ptr noundef) local_unnamed_addr #0

declare ptr @OSSL_CRMF_POPOPRIVKEY_new() local_unnamed_addr #0

declare ptr @ASN1_INTEGER_new() local_unnamed_addr #0

declare void @OSSL_CRMF_POPO_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 = { 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 = !{!"ossl_crmf_popo_st", !7, i64 0, !8, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"ossl_crmf_msg_st", !13, i64 0, !13, i64 8, !13, i64 16}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"ossl_crmf_popoprivkey_st", !7, i64 0, !8, i64 8}
!16 = !{!12, !13, i64 8}


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