; LLVM IR from aws/s2n-tls :: crypto (s2n_certificate)

; 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.s2n_debug_info = type { ptr, ptr }
%struct.s2n_result = type { i32 }
%struct.s2n_cert_chain_and_key = type { ptr, ptr, %struct.s2n_blob, %struct.s2n_blob, ptr, ptr, ptr }
%struct.s2n_blob = type { ptr, i32, i32, i8 }

@_s2n_debug_info = external thread_local global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local global i32, align 4
@.str.15 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [95 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #0

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strrchr(ptr noundef, i32 noundef) #1

declare i32 @s2n_calculate_stacktrace() #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @s2n_result_is_ok(i32) #3

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #6

declare ptr @s2n_ensure_memmove_trace(ptr noundef, ptr noundef, i64 noundef) #2

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

declare i32 @s2n_blob_char_to_lower(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_cert_chain_and_key_load_cns(ptr noundef %0, ptr noundef %1) #7 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca %struct.s2n_result, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %2
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.s2n_cert_chain_and_key, ptr %18, i32 0, i32 5
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = icmp ne ptr %20, null
  br i1 %21, label %53, label %22

22:                                               ; preds = %17
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %26 = getelementptr inbounds %struct.s2n_debug_info, ptr %25, i32 0, i32 0
  store ptr @.str.15, ptr %26, align 8, !tbaa !13
  %27 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %28 = getelementptr inbounds %struct.s2n_debug_info, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %29, i64 21
  %31 = call ptr @strrchr(ptr noundef %30, i32 noundef 47) #8
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %40

33:                                               ; preds = %24
  %34 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %35 = getelementptr inbounds %struct.s2n_debug_info, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = getelementptr inbounds i8, ptr %36, i64 21
  %38 = call ptr @strrchr(ptr noundef %37, i32 noundef 47) #8
  %39 = getelementptr inbounds i8, ptr %38, i64 1
  br label %45

40:                                               ; preds = %24
  %41 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %42 = getelementptr inbounds %struct.s2n_debug_info, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  %44 = getelementptr inbounds i8, ptr %43, i64 21
  br label %45

45:                                               ; preds = %40, %33
  %46 = phi ptr [ %39, %33 ], [ %44, %40 ]
  %47 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %48 = getelementptr inbounds %struct.s2n_debug_info, ptr %47, i32 0, i32 1
  store ptr %46, ptr %48, align 8, !tbaa !15
  %49 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %49, align 4, !tbaa !16
  %50 = call i32 @s2n_calculate_stacktrace()
  br label %51

51:                                               ; preds = %45
  store i32 -1, ptr %3, align 4
  br label %274

52:                                               ; No predecessors!
  br label %53

53:                                               ; preds = %52, %17
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = icmp ne ptr %56, null
  br i1 %57, label %89, label %58

58:                                               ; preds = %55
  br label %59

59:                                               ; preds = %58
  br label %60

60:                                               ; preds = %59
  %61 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %62 = getelementptr inbounds %struct.s2n_debug_info, ptr %61, i32 0, i32 0
  store ptr @.str.16, ptr %62, align 8, !tbaa !13
  %63 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %64 = getelementptr inbounds %struct.s2n_debug_info, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !13
  %66 = getelementptr inbounds i8, ptr %65, i64 21
  %67 = call ptr @strrchr(ptr noundef %66, i32 noundef 47) #8
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %76

69:                                               ; preds = %60
  %70 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %71 = getelementptr inbounds %struct.s2n_debug_info, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !13
  %73 = getelementptr inbounds i8, ptr %72, i64 21
  %74 = call ptr @strrchr(ptr noundef %73, i32 noundef 47) #8
  %75 = getelementptr inbounds i8, ptr %74, i64 1
  br label %81

76:                                               ; preds = %60
  %77 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %78 = getelementptr inbounds %struct.s2n_debug_info, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !13
  %80 = getelementptr inbounds i8, ptr %79, i64 21
  br label %81

81:                                               ; preds = %76, %69
  %82 = phi ptr [ %75, %69 ], [ %80, %76 ]
  %83 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %84 = getelementptr inbounds %struct.s2n_debug_info, ptr %83, i32 0, i32 1
  store ptr %82, ptr %84, align 8, !tbaa !15
  %85 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %85, align 4, !tbaa !16
  %86 = call i32 @s2n_calculate_stacktrace()
  br label %87

87:                                               ; preds = %81
  store i32 -1, ptr %3, align 4
  br label %274

88:                                               ; No predecessors!
  br label %89

89:                                               ; preds = %88, %55
  br label %90

90:                                               ; preds = %89
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #9
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = call ptr @X509_get_subject_name(ptr noundef %91)
  store ptr %92, ptr %6, align 8, !tbaa !5
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = icmp ne ptr %93, null
  br i1 %94, label %96, label %95

95:                                               ; preds = %90
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %273

96:                                               ; preds = %90
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #9
  store i32 -1, ptr %8, align 4, !tbaa !16
  br label %97

97:                                               ; preds = %270, %268, %96
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = load i32, ptr %8, align 4, !tbaa !16
  %100 = call i32 @X509_NAME_get_index_by_NID(ptr noundef %98, i32 noundef 13, i32 noundef %99)
  store i32 %100, ptr %8, align 4, !tbaa !16
  %101 = icmp sge i32 %100, 0
  br i1 %101, label %102, label %271

102:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #9
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = load i32, ptr %8, align 4, !tbaa !16
  %105 = call ptr @X509_NAME_get_entry(ptr noundef %103, i32 noundef %104)
  store ptr %105, ptr %9, align 8, !tbaa !5
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  %107 = icmp ne ptr %106, null
  br i1 %107, label %109, label %108

108:                                              ; preds = %102
  store i32 14, ptr %7, align 4
  br label %268, !llvm.loop !17

109:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #9
  %110 = load ptr, ptr %9, align 8, !tbaa !5
  %111 = call ptr @X509_NAME_ENTRY_get_data(ptr noundef %110)
  store ptr %111, ptr %10, align 8, !tbaa !5
  %112 = load ptr, ptr %10, align 8, !tbaa !5
  %113 = icmp ne ptr %112, null
  br i1 %113, label %115, label %114

114:                                              ; preds = %109
  store i32 14, ptr %7, align 4
  br label %267, !llvm.loop !17

115:                                              ; preds = %109
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  %116 = load ptr, ptr %10, align 8, !tbaa !5
  %117 = call i32 @ASN1_STRING_to_UTF8(ptr noundef %11, ptr noundef %116)
  store i32 %117, ptr %12, align 4, !tbaa !16
  %118 = load i32, ptr %12, align 4, !tbaa !16
  %119 = icmp slt i32 %118, 0
  br i1 %119, label %120, label %121

120:                                              ; preds = %115
  call void @llvm.memset.p0.i64(ptr align 8 %11, i8 0, i64 8, i1 false)
  store i32 14, ptr %7, align 4
  br label %266, !llvm.loop !17

121:                                              ; preds = %115
  %122 = load i32, ptr %12, align 4, !tbaa !16
  %123 = icmp eq i32 %122, 0
  br i1 %123, label %124, label %125

124:                                              ; preds = %121
  br label %264

125:                                              ; preds = %121
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #9
  store ptr null, ptr %13, align 8, !tbaa !5
  br label %126

126:                                              ; preds = %125
  %127 = load ptr, ptr %4, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.s2n_cert_chain_and_key, ptr %127, i32 0, i32 5
  %129 = load ptr, ptr %128, align 8, !tbaa !9
  %130 = call i32 @s2n_array_pushback(ptr noundef %129, ptr noundef %13)
  %131 = getelementptr inbounds %struct.s2n_result, ptr %14, i32 0, i32 0
  store i32 %130, ptr %131, align 4
  %132 = getelementptr inbounds %struct.s2n_result, ptr %14, i32 0, i32 0
  %133 = load i32, ptr %132, align 4
  %134 = call zeroext i1 @s2n_result_is_ok(i32 %133)
  br i1 %134, label %136, label %135

135:                                              ; preds = %126
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %261

136:                                              ; preds = %126
  br label %137

137:                                              ; preds = %136
  br label %138

138:                                              ; preds = %137
  %139 = load ptr, ptr %13, align 8, !tbaa !5
  %140 = icmp eq ptr %139, null
  br i1 %140, label %141, label %174

141:                                              ; preds = %138
  br label %142

142:                                              ; preds = %141
  br label %143

143:                                              ; preds = %142
  %144 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %145 = getelementptr inbounds %struct.s2n_debug_info, ptr %144, i32 0, i32 0
  store ptr @.str.17, ptr %145, align 8, !tbaa !13
  %146 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %147 = getelementptr inbounds %struct.s2n_debug_info, ptr %146, i32 0, i32 0
  %148 = load ptr, ptr %147, align 8, !tbaa !13
  %149 = getelementptr inbounds i8, ptr %148, i64 21
  %150 = call ptr @strrchr(ptr noundef %149, i32 noundef 47) #8
  %151 = icmp ne ptr %150, null
  br i1 %151, label %152, label %159

152:                                              ; preds = %143
  %153 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %154 = getelementptr inbounds %struct.s2n_debug_info, ptr %153, i32 0, i32 0
  %155 = load ptr, ptr %154, align 8, !tbaa !13
  %156 = getelementptr inbounds i8, ptr %155, i64 21
  %157 = call ptr @strrchr(ptr noundef %156, i32 noundef 47) #8
  %158 = getelementptr inbounds i8, ptr %157, i64 1
  br label %164

159:                                              ; preds = %143
  %160 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %161 = getelementptr inbounds %struct.s2n_debug_info, ptr %160, i32 0, i32 0
  %162 = load ptr, ptr %161, align 8, !tbaa !13
  %163 = getelementptr inbounds i8, ptr %162, i64 21
  br label %164

164:                                              ; preds = %159, %152
  %165 = phi ptr [ %158, %152 ], [ %163, %159 ]
  %166 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %167 = getelementptr inbounds %struct.s2n_debug_info, ptr %166, i32 0, i32 1
  store ptr %165, ptr %167, align 8, !tbaa !15
  %168 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653240, ptr %168, align 4, !tbaa !16
  %169 = call i32 @s2n_calculate_stacktrace()
  br label %170

170:                                              ; preds = %164
  br label %171

171:                                              ; preds = %170
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %261

172:                                              ; No predecessors!
  br label %173

173:                                              ; preds = %172
  br label %174

174:                                              ; preds = %173, %138
  %175 = load ptr, ptr %13, align 8, !tbaa !5
  %176 = load i32, ptr %12, align 4, !tbaa !16
  %177 = call i32 @s2n_alloc(ptr noundef %175, i32 noundef %176)
  %178 = icmp slt i32 %177, 0
  br i1 %178, label %179, label %183

179:                                              ; preds = %174
  br label %180

180:                                              ; preds = %179
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %261

181:                                              ; No predecessors!
  br label %182

182:                                              ; preds = %181
  br label %183

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

184:                                              ; preds = %183
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #9
  %185 = load i32, ptr %12, align 4, !tbaa !16
  store i32 %185, ptr %15, align 4, !tbaa !16
  %186 = load i32, ptr %15, align 4, !tbaa !16
  %187 = icmp ne i32 %186, 0
  %188 = xor i1 %187, true
  %189 = xor i1 %188, true
  %190 = zext i1 %189 to i32
  %191 = sext i32 %190 to i64
  %192 = call i64 @llvm.expect.i64(i64 %191, i64 1)
  %193 = icmp ne i64 %192, 0
  br i1 %193, label %194, label %244

194:                                              ; preds = %184
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #9
  %195 = load ptr, ptr %13, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.s2n_blob, ptr %195, i32 0, i32 0
  %197 = load ptr, ptr %196, align 8, !tbaa !19
  %198 = load ptr, ptr %11, align 8, !tbaa !5
  %199 = load i32, ptr %15, align 4, !tbaa !16
  %200 = sext i32 %199 to i64
  %201 = call ptr @s2n_ensure_memmove_trace(ptr noundef %197, ptr noundef %198, i64 noundef %200)
  store ptr %201, ptr %16, align 8, !tbaa !5
  br label %202

202:                                              ; preds = %194
  %203 = load ptr, ptr %16, align 8, !tbaa !5
  %204 = icmp ne ptr %203, null
  br i1 %204, label %238, label %205

205:                                              ; preds = %202
  br label %206

206:                                              ; preds = %205
  br label %207

207:                                              ; preds = %206
  %208 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %209 = getelementptr inbounds %struct.s2n_debug_info, ptr %208, i32 0, i32 0
  store ptr @.str.18, ptr %209, align 8, !tbaa !13
  %210 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %211 = getelementptr inbounds %struct.s2n_debug_info, ptr %210, i32 0, i32 0
  %212 = load ptr, ptr %211, align 8, !tbaa !13
  %213 = getelementptr inbounds i8, ptr %212, i64 21
  %214 = call ptr @strrchr(ptr noundef %213, i32 noundef 47) #8
  %215 = icmp ne ptr %214, null
  br i1 %215, label %216, label %223

216:                                              ; preds = %207
  %217 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %218 = getelementptr inbounds %struct.s2n_debug_info, ptr %217, i32 0, i32 0
  %219 = load ptr, ptr %218, align 8, !tbaa !13
  %220 = getelementptr inbounds i8, ptr %219, i64 21
  %221 = call ptr @strrchr(ptr noundef %220, i32 noundef 47) #8
  %222 = getelementptr inbounds i8, ptr %221, i64 1
  br label %228

223:                                              ; preds = %207
  %224 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %225 = getelementptr inbounds %struct.s2n_debug_info, ptr %224, i32 0, i32 0
  %226 = load ptr, ptr %225, align 8, !tbaa !13
  %227 = getelementptr inbounds i8, ptr %226, i64 21
  br label %228

228:                                              ; preds = %223, %216
  %229 = phi ptr [ %222, %216 ], [ %227, %223 ]
  %230 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %231 = getelementptr inbounds %struct.s2n_debug_info, ptr %230, i32 0, i32 1
  store ptr %229, ptr %231, align 8, !tbaa !15
  %232 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %232, align 4, !tbaa !16
  %233 = call i32 @s2n_calculate_stacktrace()
  br label %234

234:                                              ; preds = %228
  br label %235

235:                                              ; preds = %234
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %241

236:                                              ; No predecessors!
  br label %237

237:                                              ; preds = %236
  br label %238

238:                                              ; preds = %237, %202
  br label %239

239:                                              ; preds = %238
  br label %240

240:                                              ; preds = %239
  store i32 0, ptr %7, align 4
  br label %241

241:                                              ; preds = %240, %235
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #9
  %242 = load i32, ptr %7, align 4
  switch i32 %242, label %245 [
    i32 0, label %243
  ]

243:                                              ; preds = %241
  br label %244

244:                                              ; preds = %243, %184
  store i32 0, ptr %7, align 4
  br label %245

245:                                              ; preds = %244, %241
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  %246 = load i32, ptr %7, align 4
  switch i32 %246, label %261 [
    i32 0, label %247
  ]

247:                                              ; preds = %245
  br label %248

248:                                              ; preds = %247
  br label %249

249:                                              ; preds = %248
  %250 = load i32, ptr %12, align 4, !tbaa !16
  %251 = load ptr, ptr %13, align 8, !tbaa !5
  %252 = getelementptr inbounds %struct.s2n_blob, ptr %251, i32 0, i32 1
  store i32 %250, ptr %252, align 8, !tbaa !20
  br label %253

253:                                              ; preds = %249
  %254 = load ptr, ptr %13, align 8, !tbaa !5
  %255 = call i32 @s2n_blob_char_to_lower(ptr noundef %254)
  %256 = icmp sgt i32 %255, -1
  br i1 %256, label %258, label %257

257:                                              ; preds = %253
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %261

258:                                              ; preds = %253
  br label %259

259:                                              ; preds = %258
  br label %260

260:                                              ; preds = %259
  store i32 0, ptr %7, align 4
  br label %261

261:                                              ; preds = %260, %257, %245, %180, %171, %135
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #9
  %262 = load i32, ptr %7, align 4
  switch i32 %262, label %266 [
    i32 0, label %263
  ]

263:                                              ; preds = %261
  br label %264

264:                                              ; preds = %263, %124
  br label %265

265:                                              ; preds = %264
  store i32 0, ptr %7, align 4
  br label %266

266:                                              ; preds = %265, %261, %120
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  call void @OPENSSL_free_pointer(ptr noundef %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #9
  br label %267

267:                                              ; preds = %266, %114
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #9
  br label %268

268:                                              ; preds = %267, %108
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #9
  %269 = load i32, ptr %7, align 4
  switch i32 %269, label %272 [
    i32 0, label %270
    i32 14, label %97
  ]

270:                                              ; preds = %268
  br label %97, !llvm.loop !17

271:                                              ; preds = %97
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %272

272:                                              ; preds = %271, %268
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #9
  br label %273

273:                                              ; preds = %272, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #9
  br label %274

274:                                              ; preds = %273, %87, %51
  %275 = load i32, ptr %3, align 4
  ret i32 %275
}

declare ptr @X509_get_subject_name(ptr noundef) #2

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

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

declare ptr @X509_NAME_ENTRY_get_data(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @OPENSSL_free_pointer(ptr noundef) #3

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

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nounwind willreturn memory(read) "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 = { "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 = { inlinehint 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #7 = { 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 #8 = { nounwind willreturn memory(read) }
attributes #9 = { 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, !6, i64 72}
!10 = !{!"s2n_cert_chain_and_key", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 40, !6, i64 64, !6, i64 72, !6, i64 80}
!11 = !{!"s2n_blob", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = !{!12, !12, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!11, !6, i64 0}
!20 = !{!11, !12, i64 8}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.s2n_debug_info = type { ptr, ptr }

@_s2n_debug_info = external thread_local local_unnamed_addr global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local local_unnamed_addr global i32, align 4
@.str.15 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [95 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strrchr(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @s2n_calculate_stacktrace() local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @s2n_result_is_ok(i32) local_unnamed_addr #3

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

declare i32 @s2n_alloc(ptr noundef, i32 noundef) local_unnamed_addr #2

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

declare ptr @s2n_ensure_memmove_trace(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare i32 @s2n_array_pushback(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @s2n_blob_char_to_lower(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @s2n_cert_chain_and_key_load_cns(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #5 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 72
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %7, label %15

7:                                                ; preds = %2
  %8 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.15, ptr %8, align 8, !tbaa !12
  %9 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.15, i64 21), i32 noundef 47) #6
  %.not45 = icmp eq ptr %9, null
  %10 = getelementptr inbounds i8, ptr %9, i64 1
  %11 = select i1 %.not45, ptr getelementptr inbounds (i8, ptr @.str.15, i64 21), ptr %10
  %12 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr %11, ptr %12, align 8, !tbaa !14
  %13 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %13, align 4, !tbaa !15
  %14 = tail call i32 @s2n_calculate_stacktrace() #7
  br label %.loopexit

15:                                               ; preds = %2
  %.not46 = icmp eq ptr %1, null
  br i1 %.not46, label %16, label %24

16:                                               ; preds = %15
  %17 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.16, ptr %17, align 8, !tbaa !12
  %18 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.16, i64 21), i32 noundef 47) #6
  %.not47 = icmp eq ptr %18, null
  %19 = getelementptr inbounds i8, ptr %18, i64 1
  %20 = select i1 %.not47, ptr getelementptr inbounds (i8, ptr @.str.16, i64 21), ptr %19
  %21 = getelementptr inbounds i8, ptr %17, i64 8
  store ptr %20, ptr %21, align 8, !tbaa !14
  %22 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %22, align 4, !tbaa !15
  %23 = tail call i32 @s2n_calculate_stacktrace() #7
  br label %.loopexit

24:                                               ; preds = %15
  %25 = tail call ptr @X509_get_subject_name(ptr noundef nonnull %1) #7
  %.not48 = icmp eq ptr %25, null
  br i1 %.not48, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %24
  %26 = tail call i32 @X509_NAME_get_index_by_NID(ptr noundef nonnull %25, i32 noundef 13, i32 noundef -1) #7
  %27 = icmp sgt i32 %26, -1
  br i1 %27, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %28 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %29 = getelementptr inbounds i8, ptr %28, i64 8
  %30 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  br label %31

31:                                               ; preds = %.lr.ph, %.backedge
  %32 = phi i32 [ %26, %.lr.ph ], [ %67, %.backedge ]
  %33 = call ptr @X509_NAME_get_entry(ptr noundef nonnull %25, i32 noundef %32) #7
  %.not49 = icmp eq ptr %33, null
  br i1 %.not49, label %.backedge, label %34, !llvm.loop !16

34:                                               ; preds = %31
  %35 = call ptr @X509_NAME_ENTRY_get_data(ptr noundef nonnull %33) #7
  %.not50 = icmp eq ptr %35, null
  br i1 %.not50, label %.backedge, label %36, !llvm.loop !16

36:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %37 = call i32 @ASN1_STRING_to_UTF8(ptr noundef nonnull %3, ptr noundef nonnull %35) #7
  %38 = icmp slt i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  store i64 0, ptr %3, align 8
  br label %66, !llvm.loop !16

40:                                               ; preds = %36
  %41 = icmp eq i32 %37, 0
  br i1 %41, label %66, label %42

42:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  store ptr null, ptr %4, align 8, !tbaa !18
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = call i32 @s2n_array_pushback(ptr noundef %43, ptr noundef nonnull %4) #7
  %45 = call zeroext i1 @s2n_result_is_ok(i32 %44)
  br i1 %45, label %46, label %.critedge55

46:                                               ; preds = %42
  %47 = load ptr, ptr %4, align 8, !tbaa !18
  %48 = icmp eq ptr %47, null
  br i1 %48, label %.critedge55.sink.split, label %49

49:                                               ; preds = %46
  %50 = call i32 @s2n_alloc(ptr noundef nonnull %47, i32 noundef %37) #7
  %51 = icmp slt i32 %50, 0
  br i1 %51, label %.critedge55, label %52

52:                                               ; preds = %49
  %53 = load ptr, ptr %4, align 8, !tbaa !18
  %54 = load ptr, ptr %53, align 8, !tbaa !19
  %55 = load ptr, ptr %3, align 8, !tbaa !18
  %56 = zext nneg i32 %37 to i64
  %57 = call ptr @s2n_ensure_memmove_trace(ptr noundef %54, ptr noundef %55, i64 noundef %56) #7
  %.not51.not.not = icmp eq ptr %57, null
  br i1 %.not51.not.not, label %.critedge55.sink.split, label %.critedge56

.critedge56:                                      ; preds = %52
  %58 = load ptr, ptr %4, align 8, !tbaa !18
  %59 = getelementptr inbounds i8, ptr %58, i64 8
  store i32 %37, ptr %59, align 8, !tbaa !20
  %60 = call i32 @s2n_blob_char_to_lower(ptr noundef %58) #7
  %61 = icmp sgt i32 %60, -1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br i1 %61, label %66, label %.thread61

.critedge55.sink.split:                           ; preds = %52, %46
  %.str.18.sink = phi ptr [ @.str.17, %46 ], [ @.str.18, %52 ]
  %.sink68 = phi ptr [ getelementptr inbounds (i8, ptr @.str.17, i64 21), %46 ], [ getelementptr inbounds (i8, ptr @.str.18, i64 21), %52 ]
  %.sink = phi i32 [ 402653240, %46 ], [ 402653193, %52 ]
  store ptr %.str.18.sink, ptr %28, align 8, !tbaa !12
  %62 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) %.sink68, i32 noundef 47) #6
  %.not52 = icmp eq ptr %62, null
  %63 = getelementptr inbounds i8, ptr %62, i64 1
  %64 = select i1 %.not52, ptr %.sink68, ptr %63
  store ptr %64, ptr %29, align 8, !tbaa !14
  store i32 %.sink, ptr %30, align 4, !tbaa !15
  %65 = call i32 @s2n_calculate_stacktrace() #7
  br label %.critedge55

.critedge55:                                      ; preds = %49, %42, %.critedge55.sink.split
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br label %.thread61

.thread61:                                        ; preds = %.critedge56, %.critedge55
  call void @OPENSSL_free_pointer(ptr noundef nonnull %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  br label %.loopexit

66:                                               ; preds = %.critedge56, %40, %39
  call void @OPENSSL_free_pointer(ptr noundef nonnull %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  br label %.backedge

.backedge:                                        ; preds = %34, %31, %66
  %67 = call i32 @X509_NAME_get_index_by_NID(ptr noundef nonnull %25, i32 noundef 13, i32 noundef %32) #7
  %68 = icmp sgt i32 %67, -1
  br i1 %68, label %31, label %.loopexit, !llvm.loop !16

.loopexit:                                        ; preds = %.backedge, %.thread61, %.preheader, %24, %16, %7
  %.11 = phi i32 [ -1, %16 ], [ -1, %7 ], [ 0, %24 ], [ 0, %.preheader ], [ -1, %.thread61 ], [ 0, %.backedge ]
  ret i32 %.11
}

declare ptr @X509_get_subject_name(ptr noundef) local_unnamed_addr #2

declare i32 @X509_NAME_get_index_by_NID(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare ptr @X509_NAME_get_entry(ptr noundef, i32 noundef) local_unnamed_addr #2

declare ptr @X509_NAME_ENTRY_get_data(ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @OPENSSL_free_pointer(ptr noundef) local_unnamed_addr #3

declare i32 @ASN1_STRING_to_UTF8(ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { "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 = { inlinehint 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 willreturn memory(read) }
attributes #7 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 72}
!6 = !{!"s2n_cert_chain_and_key", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 40, !7, i64 64, !7, i64 72, !7, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"s2n_blob", !7, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"s2n_debug_info", !7, i64 0, !7, i64 8}
!14 = !{!13, !7, i64 8}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!7, !7, i64 0}
!19 = !{!10, !7, i64 0}
!20 = !{!10, !11, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LowerExpectIntrinsicPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass