; LLVM IR from guanzhi/GmSSL :: src (tls)

; 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.SM2_KEY = type { %struct.SM2_Z256_POINT, [4 x i64] }
%struct.SM2_Z256_POINT = type { [4 x i64], [4 x i64], [4 x i64] }
%struct.TLS_CTX = type { i32, i32, [64 x i32], i64, ptr, i64, ptr, i64, %struct.SM2_KEY, %struct.SM2_KEY, i32, i32 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [57 x i8], align 1
@__FUNCTION__.tls_ctx_set_certificate_and_key = external hidden unnamed_addr constant [32 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

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

declare ptr @tls_protocol_name(i32 noundef) #3

declare i32 @x509_certs_get_cert_by_index(ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

declare void @gmssl_secure_clear(ptr noundef, i64 noundef) #3

declare i32 @x509_certs_new_from_file(ptr noundef, ptr noundef, ptr noundef) #3

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

21:                                               ; preds = %4
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %30

24:                                               ; preds = %21
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %30

27:                                               ; preds = %24
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %36, label %30

30:                                               ; preds = %27, %24, %21, %4
  br label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr @stderr, align 8, !tbaa !5
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2149, ptr noundef @__FUNCTION__.tls_ctx_set_certificate_and_key) #5
  br label %34

34:                                               ; preds = %31
  br label %35

35:                                               ; preds = %34
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %137

36:                                               ; preds = %27
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.TLS_CTX, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !11
  %40 = call ptr @tls_protocol_name(i32 noundef %39)
  %41 = icmp ne ptr %40, null
  br i1 %41, label %48, label %42

42:                                               ; preds = %36
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr @stderr, align 8, !tbaa !5
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2153, ptr noundef @__FUNCTION__.tls_ctx_set_certificate_and_key) #5
  br label %46

46:                                               ; preds = %43
  br label %47

47:                                               ; preds = %46
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %137

48:                                               ; preds = %36
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.TLS_CTX, ptr %49, i32 0, i32 6
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %59

53:                                               ; preds = %48
  br label %54

54:                                               ; preds = %53
  %55 = load ptr, ptr @stderr, align 8, !tbaa !5
  %56 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2157, ptr noundef @__FUNCTION__.tls_ctx_set_certificate_and_key) #5
  br label %57

57:                                               ; preds = %54
  br label %58

58:                                               ; preds = %57
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %137

59:                                               ; preds = %48
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = call i32 @x509_certs_new_from_file(ptr noundef %11, ptr noundef %12, ptr noundef %60)
  %62 = icmp ne i32 %61, 1
  br i1 %62, label %63, label %69

63:                                               ; preds = %59
  br label %64

64:                                               ; preds = %63
  %65 = load ptr, ptr @stderr, align 8, !tbaa !5
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2162, ptr noundef @__FUNCTION__.tls_ctx_set_certificate_and_key) #5
  br label %67

67:                                               ; preds = %64
  br label %68

68:                                               ; preds = %67
  br label %124

69:                                               ; preds = %59
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = call noalias ptr @fopen(ptr noundef %70, ptr noundef @.str.11)
  store ptr %71, ptr %13, align 8, !tbaa !5
  %72 = icmp ne ptr %71, null
  br i1 %72, label %79, label %73

73:                                               ; preds = %69
  br label %74

74:                                               ; preds = %73
  %75 = load ptr, ptr @stderr, align 8, !tbaa !5
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2166, ptr noundef @__FUNCTION__.tls_ctx_set_certificate_and_key) #5
  br label %77

77:                                               ; preds = %74
  br label %78

78:                                               ; preds = %77
  br label %124

79:                                               ; preds = %69
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = load ptr, ptr %13, align 8, !tbaa !5
  %82 = call i32 @sm2_private_key_info_decrypt_from_pem(ptr noundef %14, ptr noundef %80, ptr noundef %81)
  %83 = icmp ne i32 %82, 1
  br i1 %83, label %84, label %90

84:                                               ; preds = %79
  br label %85

85:                                               ; preds = %84
  %86 = load ptr, ptr @stderr, align 8, !tbaa !5
  %87 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %86, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2170, ptr noundef @__FUNCTION__.tls_ctx_set_certificate_and_key) #5
  br label %88

88:                                               ; preds = %85
  br label %89

89:                                               ; preds = %88
  br label %124

90:                                               ; preds = %79
  %91 = load ptr, ptr %11, align 8, !tbaa !5
  %92 = load i64, ptr %12, align 8, !tbaa !17
  %93 = call i32 @x509_certs_get_cert_by_index(ptr noundef %91, i64 noundef %92, i32 noundef 0, ptr noundef %15, ptr noundef %16)
  %94 = icmp ne i32 %93, 1
  br i1 %94, label %100, label %95

95:                                               ; preds = %90
  %96 = load ptr, ptr %15, align 8, !tbaa !5
  %97 = load i64, ptr %16, align 8, !tbaa !17
  %98 = call i32 @x509_cert_get_subject_public_key(ptr noundef %96, i64 noundef %97, ptr noundef %17)
  %99 = icmp ne i32 %98, 1
  br i1 %99, label %100, label %106

100:                                              ; preds = %95, %90
  br label %101

101:                                              ; preds = %100
  %102 = load ptr, ptr @stderr, align 8, !tbaa !5
  %103 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %102, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2175, ptr noundef @__FUNCTION__.tls_ctx_set_certificate_and_key) #5
  br label %104

104:                                              ; preds = %101
  br label %105

105:                                              ; preds = %104
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %137

106:                                              ; preds = %95
  %107 = call i32 @sm2_public_key_equ(ptr noundef %14, ptr noundef %17)
  %108 = icmp ne i32 %107, 1
  br i1 %108, label %109, label %115

109:                                              ; preds = %106
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr @stderr, align 8, !tbaa !5
  %112 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %111, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2179, ptr noundef @__FUNCTION__.tls_ctx_set_certificate_and_key) #5
  br label %113

113:                                              ; preds = %110
  br label %114

114:                                              ; preds = %113
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %137

115:                                              ; preds = %106
  %116 = load ptr, ptr %11, align 8, !tbaa !5
  %117 = load ptr, ptr %6, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.TLS_CTX, ptr %117, i32 0, i32 6
  store ptr %116, ptr %118, align 8, !tbaa !16
  %119 = load i64, ptr %12, align 8, !tbaa !17
  %120 = load ptr, ptr %6, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.TLS_CTX, ptr %120, i32 0, i32 7
  store i64 %119, ptr %121, align 8, !tbaa !18
  %122 = load ptr, ptr %6, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.TLS_CTX, ptr %122, i32 0, i32 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %123, ptr align 8 %14, i64 128, i1 false), !tbaa.struct !19
  store ptr null, ptr %11, align 8, !tbaa !5
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %124

124:                                              ; preds = %115, %89, %78, %68
  call void @gmssl_secure_clear(ptr noundef %14, i64 noundef 128)
  %125 = load ptr, ptr %11, align 8, !tbaa !5
  %126 = icmp ne ptr %125, null
  br i1 %126, label %127, label %129

127:                                              ; preds = %124
  %128 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %128) #5
  br label %129

129:                                              ; preds = %127, %124
  %130 = load ptr, ptr %13, align 8, !tbaa !5
  %131 = icmp ne ptr %130, null
  br i1 %131, label %132, label %135

132:                                              ; preds = %129
  %133 = load ptr, ptr %13, align 8, !tbaa !5
  %134 = call i32 @fclose(ptr noundef %133)
  br label %135

135:                                              ; preds = %132, %129
  %136 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %136, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %137

137:                                              ; preds = %135, %114, %105, %58, %47, %35
  call void @llvm.lifetime.end.p0(i64 128, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %138 = load i32, ptr %5, align 4
  ret i32 %138
}

declare noalias ptr @fopen(ptr noundef, ptr noundef) #3

declare i32 @sm2_private_key_info_decrypt_from_pem(ptr noundef, ptr noundef, ptr noundef) #3

declare i32 @x509_cert_get_subject_public_key(ptr noundef, i64 noundef, ptr noundef) #3

declare i32 @sm2_public_key_equ(ptr noundef, ptr noundef) #3

declare i32 @fclose(ptr noundef) #3

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 = { "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 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 #5 = { 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, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !7, i64 8, !13, i64 264, !6, i64 272, !13, i64 280, !6, i64 288, !13, i64 296, !14, i64 304, !14, i64 432, !10, i64 560, !10, i64 564}
!13 = !{!"long", !7, i64 0}
!14 = !{!"", !15, i64 0, !7, i64 96}
!15 = !{!"", !7, i64 0, !7, i64 32, !7, i64 64}
!16 = !{!12, !6, i64 288}
!17 = !{!13, !13, i64 0}
!18 = !{!12, !13, i64 296}
!19 = !{i64 0, i64 32, !20, i64 32, i64 32, !20, i64 64, i64 32, !20, i64 96, i64 32, !20}
!20 = !{!7, !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"

%struct.SM2_KEY = type { %struct.SM2_Z256_POINT, [4 x i64] }
%struct.SM2_Z256_POINT = type { [4 x i64], [4 x i64], [4 x i64] }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [57 x i8], align 1
@__FUNCTION__.tls_ctx_set_certificate_and_key = external hidden unnamed_addr constant [32 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

declare ptr @tls_protocol_name(i32 noundef) local_unnamed_addr #3

declare i32 @x509_certs_get_cert_by_index(ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

declare void @gmssl_secure_clear(ptr noundef, i64 noundef) local_unnamed_addr #3

declare i32 @x509_certs_new_from_file(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @tls_ctx_set_certificate_and_key(ptr noundef %0, ptr noundef %1, ptr noundef readonly %2, ptr noundef %3) local_unnamed_addr #5 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca %struct.SM2_KEY, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca %struct.SM2_KEY, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #6
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %10) #6
  %11 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %12 = insertelement <4 x ptr> %11, ptr %1, i64 1
  %13 = insertelement <4 x ptr> %12, ptr %2, i64 2
  %14 = insertelement <4 x ptr> %13, ptr %3, i64 3
  %15 = icmp eq <4 x ptr> %14, zeroinitializer
  %16 = bitcast <4 x i1> %15 to i4
  %17 = icmp eq i4 %16, 0
  br i1 %17, label %21, label %18

18:                                               ; preds = %4
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2149, ptr noundef nonnull @__FUNCTION__.tls_ctx_set_certificate_and_key) #7
  br label %75

21:                                               ; preds = %4
  %22 = load i32, ptr %0, align 8, !tbaa !9
  %23 = tail call ptr @tls_protocol_name(i32 noundef %22) #6
  %.not = icmp eq ptr %23, null
  br i1 %.not, label %24, label %27

24:                                               ; preds = %21
  %25 = load ptr, ptr @stderr, align 8, !tbaa !5
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2153, ptr noundef nonnull @__FUNCTION__.tls_ctx_set_certificate_and_key) #7
  br label %75

27:                                               ; preds = %21
  %28 = getelementptr inbounds i8, ptr %0, i64 288
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %.not29 = icmp eq ptr %29, null
  br i1 %.not29, label %33, label %30

30:                                               ; preds = %27
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2157, ptr noundef nonnull @__FUNCTION__.tls_ctx_set_certificate_and_key) #7
  br label %75

33:                                               ; preds = %27
  %34 = call i32 @x509_certs_new_from_file(ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %1) #6
  %.not30 = icmp eq i32 %34, 1
  br i1 %.not30, label %38, label %35

35:                                               ; preds = %33
  %36 = load ptr, ptr @stderr, align 8, !tbaa !5
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2162, ptr noundef nonnull @__FUNCTION__.tls_ctx_set_certificate_and_key) #7
  br label %69

38:                                               ; preds = %33
  %39 = call noalias ptr @fopen(ptr noundef nonnull %2, ptr noundef nonnull @.str.11)
  %.not31 = icmp eq ptr %39, null
  br i1 %.not31, label %40, label %43

40:                                               ; preds = %38
  %41 = load ptr, ptr @stderr, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2166, ptr noundef nonnull @__FUNCTION__.tls_ctx_set_certificate_and_key) #7
  br label %69

43:                                               ; preds = %38
  %44 = call i32 @sm2_private_key_info_decrypt_from_pem(ptr noundef nonnull %7, ptr noundef nonnull %3, ptr noundef nonnull %39) #6
  %.not32 = icmp eq i32 %44, 1
  br i1 %.not32, label %48, label %45

45:                                               ; preds = %43
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2170, ptr noundef nonnull @__FUNCTION__.tls_ctx_set_certificate_and_key) #7
  br label %69

48:                                               ; preds = %43
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = load i64, ptr %6, align 8, !tbaa !16
  %51 = call i32 @x509_certs_get_cert_by_index(ptr noundef %49, i64 noundef %50, i32 noundef 0, ptr noundef nonnull %8, ptr noundef nonnull %9) #6
  %.not33 = icmp eq i32 %51, 1
  br i1 %.not33, label %52, label %56

52:                                               ; preds = %48
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = load i64, ptr %9, align 8, !tbaa !16
  %55 = call i32 @x509_cert_get_subject_public_key(ptr noundef %53, i64 noundef %54, ptr noundef nonnull %10) #6
  %.not34 = icmp eq i32 %55, 1
  br i1 %.not34, label %59, label %56

56:                                               ; preds = %48, %52
  %57 = load ptr, ptr @stderr, align 8, !tbaa !5
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2175, ptr noundef nonnull @__FUNCTION__.tls_ctx_set_certificate_and_key) #7
  br label %75

59:                                               ; preds = %52
  %60 = call i32 @sm2_public_key_equ(ptr noundef nonnull %7, ptr noundef nonnull %10) #6
  %.not35 = icmp eq i32 %60, 1
  br i1 %.not35, label %64, label %61

61:                                               ; preds = %59
  %62 = load ptr, ptr @stderr, align 8, !tbaa !5
  %63 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2179, ptr noundef nonnull @__FUNCTION__.tls_ctx_set_certificate_and_key) #7
  br label %75

64:                                               ; preds = %59
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %65, ptr %28, align 8, !tbaa !15
  %66 = load i64, ptr %6, align 8, !tbaa !16
  %67 = getelementptr inbounds i8, ptr %0, i64 296
  store i64 %66, ptr %67, align 8, !tbaa !17
  %68 = getelementptr inbounds i8, ptr %0, i64 304
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(128) %68, ptr noundef nonnull align 8 dereferenceable(128) %7, i64 128, i1 false), !tbaa.struct !18
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %69

69:                                               ; preds = %64, %45, %40, %35
  %.021 = phi i32 [ -1, %35 ], [ -1, %45 ], [ 1, %64 ], [ -1, %40 ]
  %.0 = phi ptr [ null, %35 ], [ %39, %45 ], [ %39, %64 ], [ null, %40 ]
  call void @gmssl_secure_clear(ptr noundef nonnull %7, i64 noundef 128) #6
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %.not36 = icmp eq ptr %70, null
  br i1 %.not36, label %72, label %71

71:                                               ; preds = %69
  call void @free(ptr noundef nonnull %70) #6
  br label %72

72:                                               ; preds = %71, %69
  %.not37 = icmp eq ptr %.0, null
  br i1 %.not37, label %75, label %73

73:                                               ; preds = %72
  %74 = call i32 @fclose(ptr noundef nonnull %.0)
  br label %75

75:                                               ; preds = %72, %73, %61, %56, %30, %24, %18
  %.022 = phi i32 [ -1, %30 ], [ -1, %56 ], [ -1, %61 ], [ -1, %24 ], [ -1, %18 ], [ %.021, %73 ], [ %.021, %72 ]
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  ret i32 %.022
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #1

declare i32 @sm2_private_key_info_decrypt_from_pem(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @x509_cert_get_subject_public_key(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #3

declare i32 @sm2_public_key_equ(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree nounwind "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { cold 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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 4, !7, i64 8, !12, i64 264, !6, i64 272, !12, i64 280, !6, i64 288, !12, i64 296, !13, i64 304, !13, i64 432, !11, i64 560, !11, i64 564}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"", !14, i64 0, !7, i64 96}
!14 = !{!"", !7, i64 0, !7, i64 32, !7, i64 64}
!15 = !{!10, !6, i64 288}
!16 = !{!12, !12, i64 0}
!17 = !{!10, !12, i64 296}
!18 = !{i64 0, i64 32, !19, i64 32, i64 32, !19, i64 64, i64 32, !19, i64 96, i64 32, !19}
!19 = !{!7, !7, i64 0}


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