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

; 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_pbmparameter_st = type { ptr, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [75 x i8], align 1
@__func__.OSSL_CRMF_pbmp_new = external hidden unnamed_addr constant [19 x i8], align 1

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

17:                                               ; preds = %5
  br label %77

18:                                               ; preds = %5
  %19 = load i64, ptr %8, align 8, !tbaa !9
  %20 = call ptr @CRYPTO_malloc(i64 noundef %19, ptr noundef @.str, i32 noundef 54)
  store ptr %20, ptr %13, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  br label %77

23:                                               ; preds = %18
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %13, align 8, !tbaa !5
  %26 = load i64, ptr %8, align 8, !tbaa !9
  %27 = call i32 @RAND_bytes_ex(ptr noundef %24, ptr noundef %25, i64 noundef %26, i32 noundef 0)
  %28 = icmp sle i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %23
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 57, ptr noundef @__func__.OSSL_CRMF_pbmp_new)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 56, i32 noundef 107, ptr noundef null)
  br label %77

30:                                               ; preds = %23
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ossl_crmf_pbmparameter_st, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = load i64, ptr %8, align 8, !tbaa !9
  %36 = trunc i64 %35 to i32
  %37 = call i32 @ASN1_OCTET_STRING_set(ptr noundef %33, ptr noundef %34, i32 noundef %36)
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %40, label %39

39:                                               ; preds = %30
  br label %77

40:                                               ; preds = %30
  %41 = load ptr, ptr %12, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ossl_crmf_pbmparameter_st, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  %44 = load i32, ptr %9, align 4, !tbaa !11
  %45 = call ptr @OBJ_nid2obj(i32 noundef %44)
  %46 = call i32 @X509_ALGOR_set0(ptr noundef %43, ptr noundef %45, i32 noundef -1, ptr noundef null)
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %49, label %48

48:                                               ; preds = %40
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 69, ptr noundef @__func__.OSSL_CRMF_pbmp_new)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 56, i32 noundef 111, ptr noundef null)
  br label %77

49:                                               ; preds = %40
  %50 = load i64, ptr %10, align 8, !tbaa !9
  %51 = icmp ult i64 %50, 100
  br i1 %51, label %52, label %53

52:                                               ; preds = %49
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 84, ptr noundef @__func__.OSSL_CRMF_pbmp_new)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 56, i32 noundef 108, ptr noundef null)
  br label %77

53:                                               ; preds = %49
  %54 = load i64, ptr %10, align 8, !tbaa !9
  %55 = icmp ugt i64 %54, 100000
  br i1 %55, label %56, label %57

56:                                               ; preds = %53
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 88, ptr noundef @__func__.OSSL_CRMF_pbmp_new)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 56, i32 noundef 100, ptr noundef null)
  br label %77

57:                                               ; preds = %53
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ossl_crmf_pbmparameter_st, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !16
  %61 = load i64, ptr %10, align 8, !tbaa !9
  %62 = call i32 @ASN1_INTEGER_set(ptr noundef %60, i64 noundef %61)
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %65, label %64

64:                                               ; preds = %57
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 93, ptr noundef @__func__.OSSL_CRMF_pbmp_new)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 56, i32 noundef 102, ptr noundef null)
  br label %77

65:                                               ; preds = %57
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.ossl_crmf_pbmparameter_st, ptr %66, i32 0, i32 3
  %68 = load ptr, ptr %67, align 8, !tbaa !17
  %69 = load i32, ptr %11, align 4, !tbaa !11
  %70 = call ptr @OBJ_nid2obj(i32 noundef %69)
  %71 = call i32 @X509_ALGOR_set0(ptr noundef %68, ptr noundef %70, i32 noundef -1, ptr noundef null)
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %74, label %73

73:                                               ; preds = %65
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 103, ptr noundef @__func__.OSSL_CRMF_pbmp_new)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 56, i32 noundef 110, ptr noundef null)
  br label %77

74:                                               ; preds = %65
  %75 = load ptr, ptr %13, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %75, ptr noundef @.str, i32 noundef 107)
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %76, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %80

77:                                               ; preds = %73, %64, %56, %52, %48, %39, %29, %22, %17
  %78 = load ptr, ptr %13, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %78, ptr noundef @.str, i32 noundef 110)
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  call void @OSSL_CRMF_PBMPARAMETER_free(ptr noundef %79)
  store ptr null, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %80

80:                                               ; preds = %77, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %81 = load ptr, ptr %6, align 8
  ret ptr %81
}

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

declare ptr @OSSL_CRMF_PBMPARAMETER_new() #2

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) #2

declare i32 @RAND_bytes_ex(ptr noundef, ptr noundef, i64 noundef, i32 noundef) #2

declare void @ERR_new() #2

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

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

declare i32 @ASN1_OCTET_STRING_set(ptr noundef, ptr noundef, i32 noundef) #2

declare i32 @X509_ALGOR_set0(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

declare ptr @OBJ_nid2obj(i32 noundef) #2

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

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) #2

declare void @OSSL_CRMF_PBMPARAMETER_free(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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"ossl_crmf_pbmparameter_st", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!14, !6, i64 8}
!16 = !{!14, !6, i64 16}
!17 = !{!14, !6, i64 24}


; 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_pbmp_new = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @OSSL_CRMF_pbmp_new(ptr noundef %0, i64 noundef %1, i32 noundef %2, i64 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = tail call ptr @OSSL_CRMF_PBMPARAMETER_new() #2
  %7 = icmp eq ptr %6, null
  br i1 %7, label %37, label %8

8:                                                ; preds = %5
  %9 = tail call ptr @CRYPTO_malloc(i64 noundef %1, ptr noundef nonnull @.str, i32 noundef 54) #2
  %10 = icmp eq ptr %9, null
  br i1 %10, label %37, label %11

11:                                               ; preds = %8
  %12 = tail call i32 @RAND_bytes_ex(ptr noundef %0, ptr noundef nonnull %9, i64 noundef %1, i32 noundef 0) #2
  %13 = icmp slt i32 %12, 1
  br i1 %13, label %.sink.split, label %14

14:                                               ; preds = %11
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = trunc i64 %1 to i32
  %17 = tail call i32 @ASN1_OCTET_STRING_set(ptr noundef %15, ptr noundef nonnull %9, i32 noundef %16) #2
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %37, label %18

18:                                               ; preds = %14
  %19 = getelementptr inbounds i8, ptr %6, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !10
  %21 = tail call ptr @OBJ_nid2obj(i32 noundef %2) #2
  %22 = tail call i32 @X509_ALGOR_set0(ptr noundef %20, ptr noundef %21, i32 noundef -1, ptr noundef null) #2
  %.not23 = icmp eq i32 %22, 0
  br i1 %.not23, label %.sink.split, label %23

23:                                               ; preds = %18
  %24 = icmp ult i64 %3, 100
  br i1 %24, label %.sink.split, label %25

25:                                               ; preds = %23
  %26 = icmp ugt i64 %3, 100000
  br i1 %26, label %.sink.split, label %27

27:                                               ; preds = %25
  %28 = getelementptr inbounds i8, ptr %6, i64 16
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = tail call i32 @ASN1_INTEGER_set(ptr noundef %29, i64 noundef %3) #2
  %.not24 = icmp eq i32 %30, 0
  br i1 %.not24, label %.sink.split, label %31

31:                                               ; preds = %27
  %32 = getelementptr inbounds i8, ptr %6, i64 24
  %33 = load ptr, ptr %32, align 8, !tbaa !12
  %34 = tail call ptr @OBJ_nid2obj(i32 noundef %4) #2
  %35 = tail call i32 @X509_ALGOR_set0(ptr noundef %33, ptr noundef %34, i32 noundef -1, ptr noundef null) #2
  %.not25 = icmp eq i32 %35, 0
  br i1 %.not25, label %.sink.split, label %36

36:                                               ; preds = %31
  tail call void @CRYPTO_free(ptr noundef nonnull %9, ptr noundef nonnull @.str, i32 noundef 107) #2
  br label %38

.sink.split:                                      ; preds = %31, %27, %25, %23, %18, %11
  %.sink26 = phi i32 [ 57, %11 ], [ 69, %18 ], [ 84, %23 ], [ 88, %25 ], [ 93, %27 ], [ 103, %31 ]
  %.sink = phi i32 [ 107, %11 ], [ 111, %18 ], [ 108, %23 ], [ 100, %25 ], [ 102, %27 ], [ 110, %31 ]
  tail call void @ERR_new() #2
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef %.sink26, ptr noundef nonnull @__func__.OSSL_CRMF_pbmp_new) #2
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 56, i32 noundef %.sink, ptr noundef null) #2
  br label %37

37:                                               ; preds = %.sink.split, %14, %8, %5
  %.0 = phi ptr [ null, %5 ], [ null, %8 ], [ %9, %14 ], [ %9, %.sink.split ]
  tail call void @CRYPTO_free(ptr noundef %.0, ptr noundef nonnull @.str, i32 noundef 110) #2
  tail call void @OSSL_CRMF_PBMPARAMETER_free(ptr noundef %6) #2
  br label %38

38:                                               ; preds = %37, %36
  %.019 = phi ptr [ null, %37 ], [ %6, %36 ]
  ret ptr %.019
}

declare ptr @OSSL_CRMF_PBMPARAMETER_new() local_unnamed_addr #1

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

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

declare void @ERR_new() local_unnamed_addr #1

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

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

declare i32 @ASN1_OCTET_STRING_set(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @X509_ALGOR_set0(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @OBJ_nid2obj(i32 noundef) local_unnamed_addr #1

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

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

declare void @OSSL_CRMF_PBMPARAMETER_free(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, !7, i64 0}
!6 = !{!"ossl_crmf_pbmparameter_st", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}


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