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

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

@stderr = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [62 x i8], align 1
@__FUNCTION__.x509_certs_verify = external hidden unnamed_addr constant [18 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [17 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_cert_verify_by_ca_cert(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_cert_get_issuer(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_cert_print(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_certs_get_cert_by_subject(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_cert_check(ptr noundef, i64 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @x509_certs_verify(ptr noundef %0, i64 noundef %1, i32 noundef %2, ptr noundef %3, i64 noundef %4, i32 noundef %5, ptr noundef %6) #2 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i64, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i64, align 8
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i64 %1, ptr %10, align 8, !tbaa !9
  store i32 %2, ptr %11, align 4, !tbaa !11
  store ptr %3, ptr %12, align 8, !tbaa !5
  store i64 %4, ptr %13, align 8, !tbaa !9
  store i32 %5, ptr %14, align 4, !tbaa !11
  store ptr %6, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  store i32 0, ptr %23, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #3
  %26 = load i32, ptr %11, align 4, !tbaa !11
  switch i32 %26, label %29 [
    i32 0, label %27
    i32 1, label %28
  ]

27:                                               ; preds = %7
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %35

28:                                               ; preds = %7
  store i32 1, ptr %16, align 4, !tbaa !11
  br label %35

29:                                               ; preds = %7
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1788, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %33

33:                                               ; preds = %30
  br label %34

34:                                               ; preds = %33
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

35:                                               ; preds = %28, %27
  %36 = call i32 @x509_cert_from_der(ptr noundef %17, ptr noundef %18, ptr noundef %9, ptr noundef %10)
  %37 = icmp ne i32 %36, 1
  br i1 %37, label %38, label %44

38:                                               ; preds = %35
  br label %39

39:                                               ; preds = %38
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1794, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %42

42:                                               ; preds = %39
  br label %43

43:                                               ; preds = %42
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

44:                                               ; preds = %35
  %45 = load ptr, ptr %17, align 8, !tbaa !5
  %46 = load i64, ptr %18, align 8, !tbaa !9
  %47 = load i32, ptr %16, align 4, !tbaa !11
  %48 = call i32 @x509_cert_check(ptr noundef %45, i64 noundef %46, i32 noundef %47, ptr noundef %24)
  %49 = icmp ne i32 %48, 1
  br i1 %49, label %50, label %60

50:                                               ; preds = %44
  br label %51

51:                                               ; preds = %50
  %52 = load ptr, ptr @stderr, align 8, !tbaa !5
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1798, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %54

54:                                               ; preds = %51
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = load ptr, ptr %17, align 8, !tbaa !5
  %58 = load i64, ptr %18, align 8, !tbaa !9
  %59 = call i32 @x509_cert_print(ptr noundef %56, i32 noundef 0, i32 noundef 10, ptr noundef @.str.30, ptr noundef %57, i64 noundef %58)
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

60:                                               ; preds = %44
  br label %61

61:                                               ; preds = %131, %60
  %62 = load i64, ptr %10, align 8, !tbaa !9
  %63 = icmp ne i64 %62, 0
  br i1 %63, label %64, label %136

64:                                               ; preds = %61
  %65 = call i32 @x509_cert_from_der(ptr noundef %19, ptr noundef %20, ptr noundef %9, ptr noundef %10)
  %66 = icmp ne i32 %65, 1
  br i1 %66, label %67, label %73

67:                                               ; preds = %64
  br label %68

68:                                               ; preds = %67
  %69 = load ptr, ptr @stderr, align 8, !tbaa !5
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %69, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1806, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %71

71:                                               ; preds = %68
  br label %72

72:                                               ; preds = %71
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

73:                                               ; preds = %64
  %74 = load ptr, ptr %19, align 8, !tbaa !5
  %75 = load i64, ptr %20, align 8, !tbaa !9
  %76 = call i32 @x509_cert_check(ptr noundef %74, i64 noundef %75, i32 noundef 4, ptr noundef %24)
  %77 = icmp ne i32 %76, 1
  br i1 %77, label %78, label %88

78:                                               ; preds = %73
  br label %79

79:                                               ; preds = %78
  %80 = load ptr, ptr @stderr, align 8, !tbaa !5
  %81 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %80, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1810, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %82

82:                                               ; preds = %79
  br label %83

83:                                               ; preds = %82
  %84 = load ptr, ptr @stderr, align 8, !tbaa !5
  %85 = load ptr, ptr %19, align 8, !tbaa !5
  %86 = load i64, ptr %20, align 8, !tbaa !9
  %87 = call i32 @x509_cert_print(ptr noundef %84, i32 noundef 0, i32 noundef 10, ptr noundef @.str.31, ptr noundef %85, i64 noundef %86)
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

88:                                               ; preds = %73
  %89 = load i32, ptr %23, align 4, !tbaa !11
  %90 = icmp eq i32 %89, 0
  br i1 %90, label %91, label %101

91:                                               ; preds = %88
  %92 = load i32, ptr %24, align 4, !tbaa !11
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %100

94:                                               ; preds = %91
  br label %95

95:                                               ; preds = %94
  %96 = load ptr, ptr @stderr, align 8, !tbaa !5
  %97 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %96, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1817, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %98

98:                                               ; preds = %95
  br label %99

99:                                               ; preds = %98
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

100:                                              ; preds = %91
  br label %101

101:                                              ; preds = %100, %88
  %102 = load i32, ptr %24, align 4, !tbaa !11
  %103 = icmp sge i32 %102, 0
  br i1 %103, label %104, label %108

104:                                              ; preds = %101
  %105 = load i32, ptr %23, align 4, !tbaa !11
  %106 = load i32, ptr %24, align 4, !tbaa !11
  %107 = icmp sgt i32 %105, %106
  br i1 %107, label %112, label %108

108:                                              ; preds = %104, %101
  %109 = load i32, ptr %23, align 4, !tbaa !11
  %110 = load i32, ptr %14, align 4, !tbaa !11
  %111 = icmp sgt i32 %109, %110
  br i1 %111, label %112, label %118

112:                                              ; preds = %108, %104
  br label %113

113:                                              ; preds = %112
  %114 = load ptr, ptr @stderr, align 8, !tbaa !5
  %115 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %114, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1823, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %116

116:                                              ; preds = %113
  br label %117

117:                                              ; preds = %116
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

118:                                              ; preds = %108
  %119 = load ptr, ptr %17, align 8, !tbaa !5
  %120 = load i64, ptr %18, align 8, !tbaa !9
  %121 = load ptr, ptr %19, align 8, !tbaa !5
  %122 = load i64, ptr %20, align 8, !tbaa !9
  %123 = call i32 @x509_cert_verify_by_ca_cert(ptr noundef %119, i64 noundef %120, ptr noundef %121, i64 noundef %122, ptr noundef @.str.32, i64 noundef 16)
  %124 = icmp ne i32 %123, 1
  br i1 %124, label %125, label %131

125:                                              ; preds = %118
  br label %126

126:                                              ; preds = %125
  %127 = load ptr, ptr @stderr, align 8, !tbaa !5
  %128 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %127, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1829, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %129

129:                                              ; preds = %126
  br label %130

130:                                              ; preds = %129
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

131:                                              ; preds = %118
  %132 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %132, ptr %17, align 8, !tbaa !5
  %133 = load i64, ptr %20, align 8, !tbaa !9
  store i64 %133, ptr %18, align 8, !tbaa !9
  %134 = load i32, ptr %23, align 4, !tbaa !11
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %23, align 4, !tbaa !11
  br label %61, !llvm.loop !13

136:                                              ; preds = %61
  %137 = load ptr, ptr %17, align 8, !tbaa !5
  %138 = load i64, ptr %18, align 8, !tbaa !9
  %139 = call i32 @x509_cert_get_issuer(ptr noundef %137, i64 noundef %138, ptr noundef %21, ptr noundef %22)
  %140 = icmp ne i32 %139, 1
  br i1 %140, label %141, label %147

141:                                              ; preds = %136
  br label %142

142:                                              ; preds = %141
  %143 = load ptr, ptr @stderr, align 8, !tbaa !5
  %144 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %143, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1839, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %145

145:                                              ; preds = %142
  br label %146

146:                                              ; preds = %145
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

147:                                              ; preds = %136
  %148 = load ptr, ptr %12, align 8, !tbaa !5
  %149 = load i64, ptr %13, align 8, !tbaa !9
  %150 = load ptr, ptr %21, align 8, !tbaa !5
  %151 = load i64, ptr %22, align 8, !tbaa !9
  %152 = call i32 @x509_certs_get_cert_by_subject(ptr noundef %148, i64 noundef %149, ptr noundef %150, i64 noundef %151, ptr noundef %19, ptr noundef %20)
  %153 = icmp ne i32 %152, 1
  br i1 %153, label %154, label %160

154:                                              ; preds = %147
  br label %155

155:                                              ; preds = %154
  %156 = load ptr, ptr @stderr, align 8, !tbaa !5
  %157 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %156, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1844, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %158

158:                                              ; preds = %155
  br label %159

159:                                              ; preds = %158
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

160:                                              ; preds = %147
  %161 = load ptr, ptr %19, align 8, !tbaa !5
  %162 = load i64, ptr %20, align 8, !tbaa !9
  %163 = call i32 @x509_cert_check(ptr noundef %161, i64 noundef %162, i32 noundef 4, ptr noundef %24)
  %164 = icmp ne i32 %163, 1
  br i1 %164, label %165, label %171

165:                                              ; preds = %160
  br label %166

166:                                              ; preds = %165
  %167 = load ptr, ptr @stderr, align 8, !tbaa !5
  %168 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %167, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1849, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %169

169:                                              ; preds = %166
  br label %170

170:                                              ; preds = %169
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

171:                                              ; preds = %160
  %172 = load i32, ptr %24, align 4, !tbaa !11
  %173 = icmp sge i32 %172, 0
  br i1 %173, label %174, label %178

174:                                              ; preds = %171
  %175 = load i32, ptr %23, align 4, !tbaa !11
  %176 = load i32, ptr %24, align 4, !tbaa !11
  %177 = icmp sgt i32 %175, %176
  br i1 %177, label %182, label %178

178:                                              ; preds = %174, %171
  %179 = load i32, ptr %23, align 4, !tbaa !11
  %180 = load i32, ptr %14, align 4, !tbaa !11
  %181 = icmp sgt i32 %179, %180
  br i1 %181, label %182, label %188

182:                                              ; preds = %178, %174
  br label %183

183:                                              ; preds = %182
  %184 = load ptr, ptr @stderr, align 8, !tbaa !5
  %185 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %184, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1854, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %186

186:                                              ; preds = %183
  br label %187

187:                                              ; preds = %186
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

188:                                              ; preds = %178
  %189 = load ptr, ptr %17, align 8, !tbaa !5
  %190 = load i64, ptr %18, align 8, !tbaa !9
  %191 = load ptr, ptr %19, align 8, !tbaa !5
  %192 = load i64, ptr %20, align 8, !tbaa !9
  %193 = call i32 @x509_cert_verify_by_ca_cert(ptr noundef %189, i64 noundef %190, ptr noundef %191, i64 noundef %192, ptr noundef @.str.32, i64 noundef 16)
  %194 = icmp ne i32 %193, 1
  br i1 %194, label %195, label %201

195:                                              ; preds = %188
  br label %196

196:                                              ; preds = %195
  %197 = load ptr, ptr @stderr, align 8, !tbaa !5
  %198 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %197, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1859, ptr noundef @__FUNCTION__.x509_certs_verify) #3
  br label %199

199:                                              ; preds = %196
  br label %200

200:                                              ; preds = %199
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

201:                                              ; preds = %188
  store i32 1, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %202

202:                                              ; preds = %201, %200, %187, %170, %159, %146, %130, %117, %99, %83, %72, %55, %43, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  %203 = load i32, ptr %8, align 4
  ret i32 %203
}

attributes #0 = { nocallback nofree nosync 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 = { 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 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [62 x i8], align 1
@__FUNCTION__.x509_certs_verify = external hidden unnamed_addr constant [18 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_cert_verify_by_ca_cert(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_cert_get_issuer(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_cert_from_der(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_cert_print(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_certs_get_cert_by_subject(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_cert_check(ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @x509_certs_verify(ptr noundef %0, i64 noundef %1, i32 noundef %2, ptr noundef %3, i64 noundef %4, i32 noundef %5, ptr nocapture noundef readnone %6) local_unnamed_addr #2 {
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %16) #3
  %switch = icmp ult i32 %2, 2
  br i1 %switch, label %20, label %17

17:                                               ; preds = %7
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1788, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  br label %129

20:                                               ; preds = %7
  %21 = call i32 @x509_cert_from_der(ptr noundef nonnull %10, ptr noundef nonnull %11, ptr noundef nonnull %8, ptr noundef nonnull %9)
  %.not = icmp eq i32 %21, 1
  br i1 %.not, label %25, label %22

22:                                               ; preds = %20
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1794, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  br label %129

25:                                               ; preds = %20
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = load i64, ptr %11, align 8, !tbaa !9
  %28 = call i32 @x509_cert_check(ptr noundef %26, i64 noundef %27, i32 noundef %2, ptr noundef nonnull %16)
  %.not17 = icmp eq i32 %28, 1
  br i1 %.not17, label %.preheader, label %49

.preheader:                                       ; preds = %25
  %29 = load i64, ptr %9, align 8, !tbaa !9
  %.not1835 = icmp eq i64 %29, 0
  br i1 %.not1835, label %.preheader.._crit_edge_crit_edge, label %.lr.ph.preheader

.preheader.._crit_edge_crit_edge:                 ; preds = %.preheader
  %.pre = load ptr, ptr %10, align 8, !tbaa !5
  %.pre42 = load i64, ptr %11, align 8, !tbaa !9
  br label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.preheader
  %30 = call i32 @x509_cert_from_der(ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef nonnull %8, ptr noundef nonnull %9)
  %.not23.peel = icmp eq i32 %30, 1
  br i1 %.not23.peel, label %31, label %.loopexit

31:                                               ; preds = %.lr.ph.preheader
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = load i64, ptr %13, align 8, !tbaa !9
  %34 = call i32 @x509_cert_check(ptr noundef %32, i64 noundef %33, i32 noundef 4, ptr noundef nonnull %16)
  %.not24.peel = icmp eq i32 %34, 1
  br i1 %.not24.peel, label %35, label %.loopexit38

35:                                               ; preds = %31
  %36 = load i32, ptr %16, align 4
  %.not43 = icmp eq i32 %36, 0
  br i1 %.not43, label %37, label %69

37:                                               ; preds = %35
  %38 = icmp slt i32 %5, 0
  br i1 %38, label %.loopexit40, label %39

39:                                               ; preds = %37
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = load i64, ptr %11, align 8, !tbaa !9
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = load i64, ptr %13, align 8, !tbaa !9
  %44 = call i32 @x509_cert_verify_by_ca_cert(ptr noundef %40, i64 noundef %41, ptr noundef %42, i64 noundef %43, ptr noundef nonnull @.str.32, i64 noundef 16)
  %.not25.peel = icmp eq i32 %44, 1
  br i1 %.not25.peel, label %45, label %.loopexit41

45:                                               ; preds = %39
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %46, ptr %10, align 8, !tbaa !5
  %47 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %47, ptr %11, align 8, !tbaa !9
  %48 = load i64, ptr %9, align 8, !tbaa !9
  %.not18.peel = icmp eq i64 %48, 0
  br i1 %.not18.peel, label %._crit_edge, label %.lr.ph

49:                                               ; preds = %25
  %50 = load ptr, ptr @stderr, align 8, !tbaa !5
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1798, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  %52 = load ptr, ptr @stderr, align 8, !tbaa !5
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = load i64, ptr %11, align 8, !tbaa !9
  %55 = call i32 @x509_cert_print(ptr noundef %52, i32 noundef 0, i32 noundef 10, ptr noundef nonnull @.str.30, ptr noundef %53, i64 noundef %54)
  br label %129

.lr.ph:                                           ; preds = %45, %87
  %.036 = phi i32 [ %90, %87 ], [ 1, %45 ]
  %56 = call i32 @x509_cert_from_der(ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef nonnull %8, ptr noundef nonnull %9)
  %.not23 = icmp eq i32 %56, 1
  br i1 %.not23, label %59, label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph.preheader
  %57 = load ptr, ptr @stderr, align 8, !tbaa !5
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1806, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  br label %129

59:                                               ; preds = %.lr.ph
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = load i64, ptr %13, align 8, !tbaa !9
  %62 = call i32 @x509_cert_check(ptr noundef %60, i64 noundef %61, i32 noundef 4, ptr noundef nonnull %16)
  %.not24 = icmp eq i32 %62, 1
  br i1 %.not24, label %72, label %.loopexit38

.loopexit38:                                      ; preds = %59, %31
  %63 = load ptr, ptr @stderr, align 8, !tbaa !5
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1810, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  %65 = load ptr, ptr @stderr, align 8, !tbaa !5
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = load i64, ptr %13, align 8, !tbaa !9
  %68 = call i32 @x509_cert_print(ptr noundef %65, i32 noundef 0, i32 noundef 10, ptr noundef nonnull @.str.31, ptr noundef %66, i64 noundef %67)
  br label %129

69:                                               ; preds = %35
  %70 = load ptr, ptr @stderr, align 8, !tbaa !5
  %71 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %70, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1817, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  br label %129

72:                                               ; preds = %59
  %73 = load i32, ptr %16, align 4
  %74 = icmp sgt i32 %73, -1
  %75 = icmp sgt i32 %.036, %73
  %or.cond26 = select i1 %74, i1 %75, i1 false
  %76 = icmp sgt i32 %.036, %5
  %or.cond27 = select i1 %or.cond26, i1 true, i1 %76
  br i1 %or.cond27, label %.loopexit40, label %79

.loopexit40:                                      ; preds = %72, %37
  %77 = load ptr, ptr @stderr, align 8, !tbaa !5
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %77, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1823, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  br label %129

79:                                               ; preds = %72
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = load i64, ptr %11, align 8, !tbaa !9
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = load i64, ptr %13, align 8, !tbaa !9
  %84 = call i32 @x509_cert_verify_by_ca_cert(ptr noundef %80, i64 noundef %81, ptr noundef %82, i64 noundef %83, ptr noundef nonnull @.str.32, i64 noundef 16)
  %.not25 = icmp eq i32 %84, 1
  br i1 %.not25, label %87, label %.loopexit41

.loopexit41:                                      ; preds = %79, %39
  %85 = load ptr, ptr @stderr, align 8, !tbaa !5
  %86 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %85, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1829, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  br label %129

87:                                               ; preds = %79
  %88 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %88, ptr %10, align 8, !tbaa !5
  %89 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %89, ptr %11, align 8, !tbaa !9
  %90 = add nuw nsw i32 %.036, 1
  %91 = load i64, ptr %9, align 8, !tbaa !9
  %.not18 = icmp eq i64 %91, 0
  br i1 %.not18, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %87, %45, %.preheader.._crit_edge_crit_edge
  %92 = phi i64 [ %.pre42, %.preheader.._crit_edge_crit_edge ], [ %47, %45 ], [ %89, %87 ]
  %93 = phi ptr [ %.pre, %.preheader.._crit_edge_crit_edge ], [ %46, %45 ], [ %88, %87 ]
  %.0.lcssa = phi i32 [ 0, %.preheader.._crit_edge_crit_edge ], [ 1, %45 ], [ %90, %87 ]
  %94 = call i32 @x509_cert_get_issuer(ptr noundef %93, i64 noundef %92, ptr noundef nonnull %14, ptr noundef nonnull %15)
  %.not19 = icmp eq i32 %94, 1
  br i1 %.not19, label %98, label %95

95:                                               ; preds = %._crit_edge
  %96 = load ptr, ptr @stderr, align 8, !tbaa !5
  %97 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %96, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1839, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  br label %129

98:                                               ; preds = %._crit_edge
  %99 = load ptr, ptr %14, align 8, !tbaa !5
  %100 = load i64, ptr %15, align 8, !tbaa !9
  %101 = call i32 @x509_certs_get_cert_by_subject(ptr noundef %3, i64 noundef %4, ptr noundef %99, i64 noundef %100, ptr noundef nonnull %12, ptr noundef nonnull %13)
  %.not20 = icmp eq i32 %101, 1
  br i1 %.not20, label %105, label %102

102:                                              ; preds = %98
  %103 = load ptr, ptr @stderr, align 8, !tbaa !5
  %104 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %103, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1844, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  br label %129

105:                                              ; preds = %98
  %106 = load ptr, ptr %12, align 8, !tbaa !5
  %107 = load i64, ptr %13, align 8, !tbaa !9
  %108 = call i32 @x509_cert_check(ptr noundef %106, i64 noundef %107, i32 noundef 4, ptr noundef nonnull %16)
  %.not21 = icmp eq i32 %108, 1
  br i1 %.not21, label %112, label %109

109:                                              ; preds = %105
  %110 = load ptr, ptr @stderr, align 8, !tbaa !5
  %111 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %110, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1849, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  br label %129

112:                                              ; preds = %105
  %113 = load i32, ptr %16, align 4, !tbaa !14
  %114 = icmp sgt i32 %113, -1
  %115 = icmp sgt i32 %.0.lcssa, %113
  %or.cond28 = select i1 %114, i1 %115, i1 false
  %116 = icmp sgt i32 %.0.lcssa, %5
  %or.cond29 = select i1 %or.cond28, i1 true, i1 %116
  br i1 %or.cond29, label %117, label %120

117:                                              ; preds = %112
  %118 = load ptr, ptr @stderr, align 8, !tbaa !5
  %119 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %118, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1854, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  br label %129

120:                                              ; preds = %112
  %121 = load ptr, ptr %10, align 8, !tbaa !5
  %122 = load i64, ptr %11, align 8, !tbaa !9
  %123 = load ptr, ptr %12, align 8, !tbaa !5
  %124 = load i64, ptr %13, align 8, !tbaa !9
  %125 = call i32 @x509_cert_verify_by_ca_cert(ptr noundef %121, i64 noundef %122, ptr noundef %123, i64 noundef %124, ptr noundef nonnull @.str.32, i64 noundef 16)
  %.not22 = icmp eq i32 %125, 1
  br i1 %.not22, label %129, label %126

126:                                              ; preds = %120
  %127 = load ptr, ptr @stderr, align 8, !tbaa !5
  %128 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %127, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1859, ptr noundef nonnull @__FUNCTION__.x509_certs_verify) #4
  br label %129

129:                                              ; preds = %120, %126, %117, %109, %102, %95, %.loopexit41, %.loopexit40, %69, %.loopexit38, %.loopexit, %49, %22, %17
  %.014 = phi i32 [ -1, %17 ], [ -1, %22 ], [ -1, %49 ], [ -1, %.loopexit ], [ -1, %.loopexit38 ], [ -1, %69 ], [ -1, %.loopexit40 ], [ -1, %.loopexit41 ], [ -1, %95 ], [ -1, %102 ], [ -1, %109 ], [ -1, %117 ], [ -1, %126 ], [ 1, %120 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #3
  ret i32 %.014
}

attributes #0 = { mustprogress nocallback nofree nosync 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 = { 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 }
attributes #4 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12, !13}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.peeled.count", i32 1}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass