; LLVM IR from specinfo-ua/UAPKI :: library/common/pkix (private-key)

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

@OID_DSTU4145_WITH_DSTU7564 = external global ptr, align 8
@OID_DSTU4145_WITH_GOST3411 = external global ptr, align 8
@OID_EC_KEY = external global ptr, align 8
@OID_ECKCDSA = external global ptr, align 8
@OID_ECGDSA_STD = external global ptr, align 8
@OID_GOST_KEY_3410_2012_256 = external global ptr, align 8
@OID_GOST_KEY_3410_2012_512 = external global ptr, align 8
@OID_SM2 = external global ptr, align 8
@OID_RSA = external global ptr, align 8
@.str = external hidden unnamed_addr constant [26 x i8], align 1

declare zeroext i1 @oid_is_parent(ptr noundef, ptr noundef) #0

declare zeroext i1 @oid_is_equal(ptr noundef, ptr noundef) #0

; 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) #0

declare ptr @asn_decode_ba_with_alloc(ptr noundef, ptr noundef) #0

declare ptr @get_PrivateKeyInfo_desc() #0

declare void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) #0

declare i32 @asn_oid_to_text(ptr noundef, ptr noundef) #0

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

declare void @asn_free(ptr noundef, ptr noundef) #0

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

declare i32 @signature_from_oid(ptr noundef) #0

declare i32 @hash_from_oid(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @private_key_check_algo(ptr noundef, i32 noundef) #3

declare i64 @ba_get_len(ptr noundef) #0

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

20:                                               ; preds = %6
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %25, label %23

23:                                               ; preds = %20
  store i32 2, ptr %13, align 4, !tbaa !11
  %24 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 1002, i32 noundef %24, ptr noundef null)
  br label %227

25:                                               ; preds = %20
  br label %26

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26
  br label %28

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

31:                                               ; preds = %28
  store i32 2, ptr %13, align 4, !tbaa !11
  %32 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 1003, i32 noundef %32, ptr noundef null)
  br label %227

33:                                               ; preds = %28
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = load i64, ptr %9, align 8, !tbaa !9
  %38 = icmp ugt i64 %37, 0
  br i1 %38, label %41, label %39

39:                                               ; preds = %36
  store i32 2, ptr %13, align 4, !tbaa !11
  %40 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 1004, i32 noundef %40, ptr noundef null)
  br label %227

41:                                               ; preds = %36
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %49, label %47

47:                                               ; preds = %44
  store i32 2, ptr %13, align 4, !tbaa !11
  %48 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 1005, i32 noundef %48, ptr noundef null)
  br label %227

49:                                               ; preds = %44
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %57, label %55

55:                                               ; preds = %52
  store i32 2, ptr %13, align 4, !tbaa !11
  %56 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 1006, i32 noundef %56, ptr noundef null)
  br label %227

57:                                               ; preds = %52
  br label %58

58:                                               ; preds = %57
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = call i32 @signature_from_oid(ptr noundef %60)
  store i32 %61, ptr %15, align 4, !tbaa !11
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %63, label %68

63:                                               ; preds = %59
  br label %64

64:                                               ; preds = %63
  store i32 1047, ptr %13, align 4, !tbaa !11
  %65 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 1009, i32 noundef %65, ptr noundef null)
  br label %227

66:                                               ; No predecessors!
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67, %59
  %69 = load i32, ptr %15, align 4, !tbaa !11
  %70 = icmp ne i32 8, %69
  br i1 %70, label %71, label %81

71:                                               ; preds = %68
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = call i32 @hash_from_oid(ptr noundef %72)
  store i32 %73, ptr %14, align 4, !tbaa !11
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %80

75:                                               ; preds = %71
  br label %76

76:                                               ; preds = %75
  store i32 1047, ptr %13, align 4, !tbaa !11
  %77 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 1014, i32 noundef %77, ptr noundef null)
  br label %227

78:                                               ; No predecessors!
  br label %79

79:                                               ; preds = %78
  br label %80

80:                                               ; preds = %79, %71
  br label %100

81:                                               ; preds = %68
  br label %82

82:                                               ; preds = %81
  %83 = load ptr, ptr %11, align 8, !tbaa !5
  %84 = call i32 @hash_from_rsa_pss(ptr noundef %83, ptr noundef %14)
  store i32 %84, ptr %13, align 4, !tbaa !11
  %85 = load i32, ptr %13, align 4, !tbaa !11
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %87, label %89

87:                                               ; preds = %82
  %88 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 1018, i32 noundef %88)
  br label %227

89:                                               ; preds = %82
  br label %90

90:                                               ; preds = %89
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %14, align 4, !tbaa !11
  %93 = icmp eq i32 %92, 0
  br i1 %93, label %94, label %99

94:                                               ; preds = %91
  br label %95

95:                                               ; preds = %94
  store i32 1047, ptr %13, align 4, !tbaa !11
  %96 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 1020, i32 noundef %96, ptr noundef null)
  br label %227

97:                                               ; No predecessors!
  br label %98

98:                                               ; preds = %97
  br label %99

99:                                               ; preds = %98, %91
  br label %100

100:                                              ; preds = %99, %80
  %101 = load i32, ptr %14, align 4, !tbaa !11
  %102 = call i64 @hash_get_size(i32 noundef %101)
  store i64 %102, ptr %17, align 8, !tbaa !9
  store i64 0, ptr %16, align 8, !tbaa !9
  br label %103

103:                                              ; preds = %121, %100
  %104 = load i64, ptr %16, align 8, !tbaa !9
  %105 = load i64, ptr %9, align 8, !tbaa !9
  %106 = icmp ult i64 %104, %105
  br i1 %106, label %107, label %124

107:                                              ; preds = %103
  %108 = load ptr, ptr %8, align 8, !tbaa !5
  %109 = load i64, ptr %16, align 8, !tbaa !9
  %110 = getelementptr inbounds ptr, ptr %108, i64 %109
  %111 = load ptr, ptr %110, align 8, !tbaa !5
  %112 = call i64 @ba_get_len(ptr noundef %111)
  %113 = load i64, ptr %17, align 8, !tbaa !9
  %114 = icmp ne i64 %112, %113
  br i1 %114, label %115, label %120

115:                                              ; preds = %107
  br label %116

116:                                              ; preds = %115
  store i32 1052, ptr %13, align 4, !tbaa !11
  %117 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 1028, i32 noundef %117, ptr noundef null)
  br label %227

118:                                              ; No predecessors!
  br label %119

119:                                              ; preds = %118
  br label %120

120:                                              ; preds = %119, %107
  br label %121

121:                                              ; preds = %120
  %122 = load i64, ptr %16, align 8, !tbaa !9
  %123 = add i64 %122, 1
  store i64 %123, ptr %16, align 8, !tbaa !9
  br label %103, !llvm.loop !13

124:                                              ; preds = %103
  br label %125

125:                                              ; preds = %124
  %126 = call ptr @get_PrivateKeyInfo_desc()
  %127 = load ptr, ptr %7, align 8, !tbaa !5
  %128 = call ptr @asn_decode_ba_with_alloc(ptr noundef %126, ptr noundef %127)
  store ptr %128, ptr %18, align 8, !tbaa !5
  %129 = icmp eq ptr null, %128
  br i1 %129, label %130, label %132

130:                                              ; preds = %125
  store i32 2, ptr %13, align 4, !tbaa !11
  %131 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 1032, i32 noundef %131)
  br label %227

132:                                              ; preds = %125
  br label %133

133:                                              ; preds = %132
  br label %134

134:                                              ; preds = %133
  br label %135

135:                                              ; preds = %134
  %136 = load ptr, ptr %18, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.PrivateKeyInfo, ptr %136, i32 0, i32 1
  %138 = getelementptr inbounds %struct.AlgorithmIdentifier, ptr %137, i32 0, i32 0
  %139 = call i32 @asn_oid_to_text(ptr noundef %138, ptr noundef %19)
  store i32 %139, ptr %13, align 4, !tbaa !11
  %140 = load i32, ptr %13, align 4, !tbaa !11
  %141 = icmp ne i32 %140, 0
  br i1 %141, label %142, label %144

142:                                              ; preds = %135
  %143 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 1033, i32 noundef %143)
  br label %227

144:                                              ; preds = %135
  br label %145

145:                                              ; preds = %144
  br label %146

146:                                              ; preds = %145
  %147 = load ptr, ptr %19, align 8, !tbaa !5
  %148 = load i32, ptr %15, align 4, !tbaa !11
  %149 = call zeroext i1 @private_key_check_algo(ptr noundef %147, i32 noundef %148)
  br i1 %149, label %155, label %150

150:                                              ; preds = %146
  br label %151

151:                                              ; preds = %150
  store i32 1053, ptr %13, align 4, !tbaa !11
  %152 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 1036, i32 noundef %152, ptr noundef null)
  br label %227

153:                                              ; No predecessors!
  br label %154

154:                                              ; preds = %153
  br label %155

155:                                              ; preds = %154, %146
  br label %156

156:                                              ; preds = %155
  %157 = load i64, ptr %9, align 8, !tbaa !9
  %158 = mul i64 8, %157
  %159 = call noalias ptr @calloc(i64 noundef 1, i64 noundef %158) #6
  %160 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %159, ptr %160, align 8, !tbaa !5
  %161 = icmp eq ptr null, %159
  br i1 %161, label %162, label %164

162:                                              ; preds = %156
  store i32 1, ptr %13, align 4, !tbaa !11
  %163 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 1039, i32 noundef %163, ptr noundef null)
  br label %227

164:                                              ; preds = %156
  br label %165

165:                                              ; preds = %164
  br label %166

166:                                              ; preds = %165
  %167 = load ptr, ptr @OID_DSTU4145_WITH_GOST3411, align 8, !tbaa !5
  %168 = load ptr, ptr %19, align 8, !tbaa !5
  %169 = call zeroext i1 @oid_is_parent(ptr noundef %167, ptr noundef %168)
  br i1 %169, label %198, label %170

170:                                              ; preds = %166
  %171 = load ptr, ptr @OID_DSTU4145_WITH_DSTU7564, align 8, !tbaa !5
  %172 = load ptr, ptr %19, align 8, !tbaa !5
  %173 = call zeroext i1 @oid_is_parent(ptr noundef %171, ptr noundef %172)
  br i1 %173, label %198, label %174

174:                                              ; preds = %170
  %175 = load ptr, ptr @OID_EC_KEY, align 8, !tbaa !5
  %176 = load ptr, ptr %19, align 8, !tbaa !5
  %177 = call zeroext i1 @oid_is_equal(ptr noundef %175, ptr noundef %176)
  br i1 %177, label %198, label %178

178:                                              ; preds = %174
  %179 = load ptr, ptr @OID_ECKCDSA, align 8, !tbaa !5
  %180 = load ptr, ptr %19, align 8, !tbaa !5
  %181 = call zeroext i1 @oid_is_equal(ptr noundef %179, ptr noundef %180)
  br i1 %181, label %198, label %182

182:                                              ; preds = %178
  %183 = load ptr, ptr @OID_ECGDSA_STD, align 8, !tbaa !5
  %184 = load ptr, ptr %19, align 8, !tbaa !5
  %185 = call zeroext i1 @oid_is_parent(ptr noundef %183, ptr noundef %184)
  br i1 %185, label %198, label %186

186:                                              ; preds = %182
  %187 = load ptr, ptr @OID_GOST_KEY_3410_2012_256, align 8, !tbaa !5
  %188 = load ptr, ptr %19, align 8, !tbaa !5
  %189 = call zeroext i1 @oid_is_equal(ptr noundef %187, ptr noundef %188)
  br i1 %189, label %198, label %190

190:                                              ; preds = %186
  %191 = load ptr, ptr @OID_GOST_KEY_3410_2012_512, align 8, !tbaa !5
  %192 = load ptr, ptr %19, align 8, !tbaa !5
  %193 = call zeroext i1 @oid_is_equal(ptr noundef %191, ptr noundef %192)
  br i1 %193, label %198, label %194

194:                                              ; preds = %190
  %195 = load ptr, ptr @OID_SM2, align 8, !tbaa !5
  %196 = load ptr, ptr %19, align 8, !tbaa !5
  %197 = call zeroext i1 @oid_is_equal(ptr noundef %195, ptr noundef %196)
  br i1 %197, label %198, label %207

198:                                              ; preds = %194, %190, %186, %182, %178, %174, %170, %166
  %199 = load ptr, ptr %18, align 8, !tbaa !5
  %200 = load i32, ptr %15, align 4, !tbaa !11
  %201 = load i32, ptr %14, align 4, !tbaa !11
  %202 = load ptr, ptr %8, align 8, !tbaa !5
  %203 = load i64, ptr %9, align 8, !tbaa !9
  %204 = load ptr, ptr %12, align 8, !tbaa !5
  %205 = load ptr, ptr %204, align 8, !tbaa !5
  %206 = call i32 @private_key_sign_ec(ptr noundef %199, i32 noundef %200, i32 noundef %201, ptr noundef %202, i64 noundef %203, ptr noundef %205)
  store i32 %206, ptr %13, align 4, !tbaa !11
  br label %226

207:                                              ; preds = %194
  %208 = load ptr, ptr @OID_RSA, align 8, !tbaa !5
  %209 = load ptr, ptr %19, align 8, !tbaa !5
  %210 = call zeroext i1 @oid_is_equal(ptr noundef %208, ptr noundef %209)
  br i1 %210, label %211, label %220

211:                                              ; preds = %207
  %212 = load ptr, ptr %18, align 8, !tbaa !5
  %213 = load i32, ptr %15, align 4, !tbaa !11
  %214 = load i32, ptr %14, align 4, !tbaa !11
  %215 = load ptr, ptr %8, align 8, !tbaa !5
  %216 = load i64, ptr %9, align 8, !tbaa !9
  %217 = load ptr, ptr %12, align 8, !tbaa !5
  %218 = load ptr, ptr %217, align 8, !tbaa !5
  %219 = call i32 @private_key_sign_rsa(ptr noundef %212, i32 noundef %213, i32 noundef %214, ptr noundef %215, i64 noundef %216, ptr noundef %218)
  store i32 %219, ptr %13, align 4, !tbaa !11
  br label %225

220:                                              ; preds = %207
  br label %221

221:                                              ; preds = %220
  store i32 1047, ptr %13, align 4, !tbaa !11
  %222 = load i32, ptr %13, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 1055, i32 noundef %222, ptr noundef null)
  br label %227

223:                                              ; No predecessors!
  br label %224

224:                                              ; preds = %223
  br label %225

225:                                              ; preds = %224, %211
  br label %226

226:                                              ; preds = %225, %198
  br label %227

227:                                              ; preds = %226, %221, %162, %151, %142, %130, %116, %95, %87, %76, %64, %55, %47, %39, %31, %23
  %228 = load i32, ptr %13, align 4, !tbaa !11
  %229 = icmp ne i32 %228, 0
  br i1 %229, label %230, label %234

230:                                              ; preds = %227
  %231 = load ptr, ptr %12, align 8, !tbaa !5
  %232 = load ptr, ptr %231, align 8, !tbaa !5
  call void @free(ptr noundef %232) #5
  %233 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr null, ptr %233, align 8, !tbaa !5
  br label %234

234:                                              ; preds = %230, %227
  %235 = load ptr, ptr %19, align 8, !tbaa !5
  call void @free(ptr noundef %235) #5
  %236 = call ptr @get_PrivateKeyInfo_desc()
  %237 = load ptr, ptr %18, align 8, !tbaa !5
  call void @asn_free(ptr noundef %236, ptr noundef %237)
  %238 = load i32, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  ret i32 %238
}

declare i64 @hash_get_size(i32 noundef) #0

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #4

; Function Attrs: nounwind uwtable
declare hidden i32 @private_key_sign_ec(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @private_key_sign_rsa(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 allocsize(0,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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0,1) }

!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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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"

@OID_DSTU4145_WITH_DSTU7564 = external local_unnamed_addr global ptr, align 8
@OID_DSTU4145_WITH_GOST3411 = external local_unnamed_addr global ptr, align 8
@OID_EC_KEY = external local_unnamed_addr global ptr, align 8
@OID_ECKCDSA = external local_unnamed_addr global ptr, align 8
@OID_ECGDSA_STD = external local_unnamed_addr global ptr, align 8
@OID_GOST_KEY_3410_2012_256 = external local_unnamed_addr global ptr, align 8
@OID_GOST_KEY_3410_2012_512 = external local_unnamed_addr global ptr, align 8
@OID_SM2 = external local_unnamed_addr global ptr, align 8
@OID_RSA = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [26 x i8], align 1

declare zeroext i1 @oid_is_parent(ptr noundef, ptr noundef) local_unnamed_addr #0

declare zeroext i1 @oid_is_equal(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress 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) local_unnamed_addr #0

declare ptr @asn_decode_ba_with_alloc(ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @get_PrivateKeyInfo_desc() local_unnamed_addr #0

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

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

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

declare void @asn_free(ptr noundef, ptr noundef) local_unnamed_addr #0

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

declare i32 @signature_from_oid(ptr noundef) local_unnamed_addr #0

declare i32 @hash_from_oid(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @private_key_check_algo(ptr noundef, i32 noundef) local_unnamed_addr #3

declare i64 @ba_get_len(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @private_key_sign(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #3 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  store ptr null, ptr %8, align 8, !tbaa !9
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %9, label %10

9:                                                ; preds = %6
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 1002, i32 noundef 2, ptr noundef null) #5
  br label %.thread

10:                                               ; preds = %6
  %.not62 = icmp eq ptr %1, null
  br i1 %.not62, label %11, label %12

11:                                               ; preds = %10
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 1003, i32 noundef 2, ptr noundef null) #5
  br label %.thread

12:                                               ; preds = %10
  %.not63 = icmp eq i64 %2, 0
  br i1 %.not63, label %13, label %14

13:                                               ; preds = %12
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 1004, i32 noundef 2, ptr noundef null) #5
  br label %.thread

14:                                               ; preds = %12
  %.not64 = icmp eq ptr %3, null
  br i1 %.not64, label %15, label %16

15:                                               ; preds = %14
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 1005, i32 noundef 2, ptr noundef null) #5
  br label %.thread

16:                                               ; preds = %14
  %.not65 = icmp eq ptr %5, null
  br i1 %.not65, label %17, label %18

17:                                               ; preds = %16
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 1006, i32 noundef 2, ptr noundef null) #5
  br label %.thread

18:                                               ; preds = %16
  %19 = tail call i32 @signature_from_oid(ptr noundef nonnull %3) #5
  switch i32 %19, label %21 [
    i32 0, label %20
    i32 8, label %25
  ]

20:                                               ; preds = %18
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 1009, i32 noundef 1047, ptr noundef null) #5
  br label %.thread

21:                                               ; preds = %18
  %22 = tail call i32 @hash_from_oid(ptr noundef nonnull %3) #5
  store i32 %22, ptr %7, align 4, !tbaa !5
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %32

24:                                               ; preds = %21
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 1014, i32 noundef 1047, ptr noundef null) #5
  br label %.thread

25:                                               ; preds = %18
  %26 = call i32 @hash_from_rsa_pss(ptr noundef %4, ptr noundef nonnull %7)
  %.not67 = icmp eq i32 %26, 0
  br i1 %.not67, label %28, label %27

27:                                               ; preds = %25
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 1018, i32 noundef %26) #5
  br label %.thread

28:                                               ; preds = %25
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 1020, i32 noundef 1047, ptr noundef null) #5
  br label %.thread

32:                                               ; preds = %28, %21
  %33 = phi i32 [ %29, %28 ], [ %22, %21 ]
  %34 = call i64 @hash_get_size(i32 noundef %33) #5
  br label %37

35:                                               ; preds = %37
  %36 = add nuw i64 %.05278, 1
  %exitcond.not = icmp eq i64 %36, %2
  br i1 %exitcond.not, label %42, label %37, !llvm.loop !11

37:                                               ; preds = %32, %35
  %.05278 = phi i64 [ 0, %32 ], [ %36, %35 ]
  %38 = getelementptr inbounds ptr, ptr %1, i64 %.05278
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = call i64 @ba_get_len(ptr noundef %39) #5
  %.not69 = icmp eq i64 %40, %34
  br i1 %.not69, label %35, label %41

41:                                               ; preds = %37
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 1028, i32 noundef 1052, ptr noundef null) #5
  br label %.thread

42:                                               ; preds = %35
  %43 = call ptr @get_PrivateKeyInfo_desc() #5
  %44 = call ptr @asn_decode_ba_with_alloc(ptr noundef %43, ptr noundef nonnull %0) #5
  %45 = icmp eq ptr %44, null
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 1032, i32 noundef 2) #5
  br label %.thread

47:                                               ; preds = %42
  %48 = getelementptr inbounds i8, ptr %44, i64 16
  %49 = call i32 @asn_oid_to_text(ptr noundef nonnull %48, ptr noundef nonnull %8) #5
  %.not68 = icmp eq i32 %49, 0
  br i1 %.not68, label %51, label %50

50:                                               ; preds = %47
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 1033, i32 noundef %49) #5
  br label %.thread

51:                                               ; preds = %47
  %52 = load ptr, ptr %8, align 8, !tbaa !9
  %53 = call zeroext i1 @private_key_check_algo(ptr noundef %52, i32 noundef %19)
  br i1 %53, label %55, label %54

54:                                               ; preds = %51
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 1036, i32 noundef 1053, ptr noundef null) #5
  br label %.thread

55:                                               ; preds = %51
  %56 = shl i64 %2, 3
  %57 = call noalias ptr @calloc(i64 noundef 1, i64 noundef %56) #6
  store ptr %57, ptr %5, align 8, !tbaa !9
  %58 = icmp eq ptr %57, null
  br i1 %58, label %59, label %60

59:                                               ; preds = %55
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 1039, i32 noundef 1, ptr noundef null) #5
  br label %.thread

60:                                               ; preds = %55
  %61 = load ptr, ptr @OID_DSTU4145_WITH_GOST3411, align 8, !tbaa !9
  %62 = load ptr, ptr %8, align 8, !tbaa !9
  %63 = call zeroext i1 @oid_is_parent(ptr noundef %61, ptr noundef %62) #5
  br i1 %63, label %92, label %64

64:                                               ; preds = %60
  %65 = load ptr, ptr @OID_DSTU4145_WITH_DSTU7564, align 8, !tbaa !9
  %66 = load ptr, ptr %8, align 8, !tbaa !9
  %67 = call zeroext i1 @oid_is_parent(ptr noundef %65, ptr noundef %66) #5
  br i1 %67, label %92, label %68

68:                                               ; preds = %64
  %69 = load ptr, ptr @OID_EC_KEY, align 8, !tbaa !9
  %70 = load ptr, ptr %8, align 8, !tbaa !9
  %71 = call zeroext i1 @oid_is_equal(ptr noundef %69, ptr noundef %70) #5
  br i1 %71, label %92, label %72

72:                                               ; preds = %68
  %73 = load ptr, ptr @OID_ECKCDSA, align 8, !tbaa !9
  %74 = load ptr, ptr %8, align 8, !tbaa !9
  %75 = call zeroext i1 @oid_is_equal(ptr noundef %73, ptr noundef %74) #5
  br i1 %75, label %92, label %76

76:                                               ; preds = %72
  %77 = load ptr, ptr @OID_ECGDSA_STD, align 8, !tbaa !9
  %78 = load ptr, ptr %8, align 8, !tbaa !9
  %79 = call zeroext i1 @oid_is_parent(ptr noundef %77, ptr noundef %78) #5
  br i1 %79, label %92, label %80

80:                                               ; preds = %76
  %81 = load ptr, ptr @OID_GOST_KEY_3410_2012_256, align 8, !tbaa !9
  %82 = load ptr, ptr %8, align 8, !tbaa !9
  %83 = call zeroext i1 @oid_is_equal(ptr noundef %81, ptr noundef %82) #5
  br i1 %83, label %92, label %84

84:                                               ; preds = %80
  %85 = load ptr, ptr @OID_GOST_KEY_3410_2012_512, align 8, !tbaa !9
  %86 = load ptr, ptr %8, align 8, !tbaa !9
  %87 = call zeroext i1 @oid_is_equal(ptr noundef %85, ptr noundef %86) #5
  br i1 %87, label %92, label %88

88:                                               ; preds = %84
  %89 = load ptr, ptr @OID_SM2, align 8, !tbaa !9
  %90 = load ptr, ptr %8, align 8, !tbaa !9
  %91 = call zeroext i1 @oid_is_equal(ptr noundef %89, ptr noundef %90) #5
  br i1 %91, label %92, label %96

92:                                               ; preds = %88, %84, %80, %76, %72, %68, %64, %60
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = load ptr, ptr %5, align 8, !tbaa !9
  %95 = call i32 @private_key_sign_ec(ptr noundef nonnull %44, i32 noundef %19, i32 noundef %93, ptr noundef nonnull %1, i64 noundef %2, ptr noundef %94)
  br label %105

96:                                               ; preds = %88
  %97 = load ptr, ptr @OID_RSA, align 8, !tbaa !9
  %98 = load ptr, ptr %8, align 8, !tbaa !9
  %99 = call zeroext i1 @oid_is_equal(ptr noundef %97, ptr noundef %98) #5
  br i1 %99, label %100, label %104

100:                                              ; preds = %96
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = load ptr, ptr %5, align 8, !tbaa !9
  %103 = call i32 @private_key_sign_rsa(ptr noundef nonnull %44, i32 noundef %19, i32 noundef %101, ptr noundef nonnull %1, i64 noundef %2, ptr noundef %102)
  br label %105

104:                                              ; preds = %96
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 1055, i32 noundef 1047, ptr noundef null) #5
  br label %.thread

105:                                              ; preds = %92, %100
  %.051 = phi i32 [ %95, %92 ], [ %103, %100 ]
  %.not70 = icmp eq i32 %.051, 0
  br i1 %.not70, label %107, label %.thread

.thread:                                          ; preds = %9, %11, %13, %15, %17, %31, %27, %54, %104, %59, %50, %46, %41, %24, %20, %105
  %.076 = phi ptr [ %44, %105 ], [ null, %9 ], [ null, %11 ], [ null, %13 ], [ null, %15 ], [ null, %17 ], [ null, %31 ], [ null, %27 ], [ %44, %54 ], [ %44, %104 ], [ %44, %59 ], [ %44, %50 ], [ null, %46 ], [ null, %41 ], [ null, %24 ], [ null, %20 ]
  %.05174 = phi i32 [ %.051, %105 ], [ 2, %9 ], [ 2, %11 ], [ 2, %13 ], [ 2, %15 ], [ 2, %17 ], [ 1047, %31 ], [ %26, %27 ], [ 1053, %54 ], [ 1047, %104 ], [ 1, %59 ], [ %49, %50 ], [ 2, %46 ], [ 1052, %41 ], [ 1047, %24 ], [ 1047, %20 ]
  %106 = load ptr, ptr %5, align 8, !tbaa !9
  call void @free(ptr noundef %106) #5
  store ptr null, ptr %5, align 8, !tbaa !9
  br label %107

107:                                              ; preds = %.thread, %105
  %.077 = phi ptr [ %.076, %.thread ], [ %44, %105 ]
  %.05175 = phi i32 [ %.05174, %.thread ], [ 0, %105 ]
  %108 = load ptr, ptr %8, align 8, !tbaa !9
  call void @free(ptr noundef %108) #5
  %109 = call ptr @get_PrivateKeyInfo_desc() #5
  call void @asn_free(ptr noundef %109, ptr noundef %.077) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  ret i32 %.05175
}

declare i64 @hash_get_size(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden i32 @private_key_sign_ec(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @private_key_sign_rsa(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(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 }
attributes #6 = { nounwind allocsize(0,1) }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass