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

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

@.str = external hidden unnamed_addr constant [94 x i8], align 1
@_s2n_debug_info = external thread_local global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local global i32, align 4
@.str.1 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [95 x i8], align 1

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

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %47, label %16

16:                                               ; preds = %13
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  %19 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %20 = getelementptr inbounds %struct.s2n_debug_info, ptr %19, i32 0, i32 0
  store ptr @.str, ptr %20, align 8, !tbaa !9
  %21 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %22 = getelementptr inbounds %struct.s2n_debug_info, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds i8, ptr %23, i64 21
  %25 = call ptr @strrchr(ptr noundef %24, i32 noundef 47) #7
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %34

27:                                               ; preds = %18
  %28 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %29 = getelementptr inbounds %struct.s2n_debug_info, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %30, i64 21
  %32 = call ptr @strrchr(ptr noundef %31, i32 noundef 47) #7
  %33 = getelementptr inbounds i8, ptr %32, i64 1
  br label %39

34:                                               ; preds = %18
  %35 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %36 = getelementptr inbounds %struct.s2n_debug_info, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = getelementptr inbounds i8, ptr %37, i64 21
  br label %39

39:                                               ; preds = %34, %27
  %40 = phi ptr [ %33, %27 ], [ %38, %34 ]
  %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 1
  store ptr %40, ptr %42, align 8, !tbaa !11
  %43 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %43, align 4, !tbaa !12
  %44 = call i32 @s2n_calculate_stacktrace()
  br label %45

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

46:                                               ; No predecessors!
  br label %47

47:                                               ; preds = %46, %13
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %83, label %52

52:                                               ; preds = %49
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  %55 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %56 = getelementptr inbounds %struct.s2n_debug_info, ptr %55, i32 0, i32 0
  store ptr @.str.1, ptr %56, align 8, !tbaa !9
  %57 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %58 = getelementptr inbounds %struct.s2n_debug_info, ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !9
  %60 = getelementptr inbounds i8, ptr %59, i64 21
  %61 = call ptr @strrchr(ptr noundef %60, i32 noundef 47) #7
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %70

63:                                               ; preds = %54
  %64 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %65 = getelementptr inbounds %struct.s2n_debug_info, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !9
  %67 = getelementptr inbounds i8, ptr %66, i64 21
  %68 = call ptr @strrchr(ptr noundef %67, i32 noundef 47) #7
  %69 = getelementptr inbounds i8, ptr %68, i64 1
  br label %75

70:                                               ; preds = %54
  %71 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %72 = getelementptr inbounds %struct.s2n_debug_info, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !9
  %74 = getelementptr inbounds i8, ptr %73, i64 21
  br label %75

75:                                               ; preds = %70, %63
  %76 = phi ptr [ %69, %63 ], [ %74, %70 ]
  %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 1
  store ptr %76, ptr %78, align 8, !tbaa !11
  %79 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %79, align 4, !tbaa !12
  %80 = call i32 @s2n_calculate_stacktrace()
  br label %81

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

82:                                               ; No predecessors!
  br label %83

83:                                               ; preds = %82, %49
  br label %84

84:                                               ; preds = %83
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.s2n_x509_trust_store, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !14
  %88 = icmp ne ptr %87, null
  br i1 %88, label %93, label %89

89:                                               ; preds = %84
  %90 = call ptr @X509_STORE_new()
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.s2n_x509_trust_store, ptr %91, i32 0, i32 0
  store ptr %90, ptr %92, align 8, !tbaa !14
  br label %93

93:                                               ; preds = %89, %84
  call void @llvm.lifetime.start.p0(i64 40, ptr %6) #8
  call void @llvm.memset.p0.i64(ptr align 8 %6, i8 0, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 40, ptr %7) #8
  call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 40, i1 false)
  br label %94

94:                                               ; preds = %93
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = call i32 @s2n_stuffer_alloc_ro_from_string(ptr noundef %6, ptr noundef %95)
  %97 = icmp sgt i32 %96, -1
  br i1 %97, label %99, label %98

98:                                               ; preds = %94
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %246

99:                                               ; preds = %94
  br label %100

100:                                              ; preds = %99
  br label %101

101:                                              ; preds = %100
  br label %102

102:                                              ; preds = %101
  %103 = call i32 @s2n_stuffer_growable_alloc(ptr noundef %7, i32 noundef 2048)
  %104 = icmp sgt i32 %103, -1
  br i1 %104, label %106, label %105

105:                                              ; preds = %102
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %246

106:                                              ; preds = %102
  br label %107

107:                                              ; preds = %106
  br label %108

108:                                              ; preds = %107
  br label %109

109:                                              ; preds = %238, %108
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #8
  call void @llvm.memset.p0.i64(ptr align 8 %9, i8 0, i64 24, i1 false)
  br label %110

110:                                              ; preds = %109
  %111 = call i32 @s2n_stuffer_certificate_from_pem(ptr noundef %6, ptr noundef %7)
  %112 = icmp sgt i32 %111, -1
  br i1 %112, label %114, label %113

113:                                              ; preds = %110
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %234

114:                                              ; preds = %110
  br label %115

115:                                              ; preds = %114
  br label %116

116:                                              ; preds = %115
  br label %117

117:                                              ; preds = %116
  %118 = getelementptr inbounds %struct.s2n_stuffer, ptr %7, i32 0, i32 2
  %119 = load i32, ptr %118, align 4, !tbaa !16
  %120 = getelementptr inbounds %struct.s2n_stuffer, ptr %7, i32 0, i32 1
  %121 = load i32, ptr %120, align 8, !tbaa !19
  %122 = sub i32 %119, %121
  %123 = call i32 @s2n_alloc(ptr noundef %9, i32 noundef %122)
  %124 = icmp sgt i32 %123, -1
  br i1 %124, label %126, label %125

125:                                              ; preds = %117
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %234

126:                                              ; preds = %117
  br label %127

127:                                              ; preds = %126
  br label %128

128:                                              ; preds = %127
  br label %129

129:                                              ; preds = %128
  %130 = call i32 @s2n_stuffer_read(ptr noundef %7, ptr noundef %9)
  %131 = icmp sgt i32 %130, -1
  br i1 %131, label %133, label %132

132:                                              ; preds = %129
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %234

133:                                              ; preds = %129
  br label %134

134:                                              ; preds = %133
  br label %135

135:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  %136 = getelementptr inbounds %struct.s2n_blob, ptr %9, i32 0, i32 0
  %137 = load ptr, ptr %136, align 8, !tbaa !20
  store ptr %137, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  %138 = getelementptr inbounds %struct.s2n_blob, ptr %9, i32 0, i32 1
  %139 = load i32, ptr %138, align 8, !tbaa !21
  %140 = zext i32 %139 to i64
  %141 = call ptr @d2i_X509(ptr noundef null, ptr noundef %10, i64 noundef %140)
  store ptr %141, ptr %11, align 8, !tbaa !5
  br label %142

142:                                              ; preds = %135
  %143 = load ptr, ptr %11, align 8, !tbaa !5
  %144 = icmp eq ptr %143, null
  br i1 %144, label %145, label %178

145:                                              ; preds = %142
  br label %146

146:                                              ; preds = %145
  br label %147

147:                                              ; preds = %146
  %148 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %149 = getelementptr inbounds %struct.s2n_debug_info, ptr %148, i32 0, i32 0
  store ptr @.str.2, ptr %149, align 8, !tbaa !9
  %150 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %151 = getelementptr inbounds %struct.s2n_debug_info, ptr %150, i32 0, i32 0
  %152 = load ptr, ptr %151, align 8, !tbaa !9
  %153 = getelementptr inbounds i8, ptr %152, i64 21
  %154 = call ptr @strrchr(ptr noundef %153, i32 noundef 47) #7
  %155 = icmp ne ptr %154, null
  br i1 %155, label %156, label %163

156:                                              ; preds = %147
  %157 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %158 = getelementptr inbounds %struct.s2n_debug_info, ptr %157, i32 0, i32 0
  %159 = load ptr, ptr %158, align 8, !tbaa !9
  %160 = getelementptr inbounds i8, ptr %159, i64 21
  %161 = call ptr @strrchr(ptr noundef %160, i32 noundef 47) #7
  %162 = getelementptr inbounds i8, ptr %161, i64 1
  br label %168

163:                                              ; preds = %147
  %164 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %165 = getelementptr inbounds %struct.s2n_debug_info, ptr %164, i32 0, i32 0
  %166 = load ptr, ptr %165, align 8, !tbaa !9
  %167 = getelementptr inbounds i8, ptr %166, i64 21
  br label %168

168:                                              ; preds = %163, %156
  %169 = phi ptr [ %162, %156 ], [ %167, %163 ]
  %170 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %171 = getelementptr inbounds %struct.s2n_debug_info, ptr %170, i32 0, i32 1
  store ptr %169, ptr %171, align 8, !tbaa !11
  %172 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544344, ptr %172, align 4, !tbaa !12
  %173 = call i32 @s2n_calculate_stacktrace()
  br label %174

174:                                              ; preds = %168
  br label %175

175:                                              ; preds = %174
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %233

176:                                              ; No predecessors!
  br label %177

177:                                              ; preds = %176
  br label %178

178:                                              ; preds = %177, %142
  br label %179

179:                                              ; preds = %178
  br label %180

180:                                              ; preds = %179
  %181 = load ptr, ptr %4, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.s2n_x509_trust_store, ptr %181, i32 0, i32 0
  %183 = load ptr, ptr %182, align 8, !tbaa !14
  %184 = load ptr, ptr %11, align 8, !tbaa !5
  %185 = call i32 @X509_STORE_add_cert(ptr noundef %183, ptr noundef %184)
  %186 = icmp ne i32 %185, 0
  br i1 %186, label %232, label %187

187:                                              ; preds = %180
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #8
  %188 = call i64 @ERR_get_error()
  store i64 %188, ptr %12, align 8, !tbaa !22
  br label %189

189:                                              ; preds = %187
  %190 = load i64, ptr %12, align 8, !tbaa !22
  %191 = call i32 @ERR_GET_REASON(i64 noundef %190)
  %192 = icmp eq i32 %191, 101
  br i1 %192, label %226, label %193

193:                                              ; preds = %189
  br label %194

194:                                              ; preds = %193
  br label %195

195:                                              ; preds = %194
  %196 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %197 = getelementptr inbounds %struct.s2n_debug_info, ptr %196, i32 0, i32 0
  store ptr @.str.3, ptr %197, align 8, !tbaa !9
  %198 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %199 = getelementptr inbounds %struct.s2n_debug_info, ptr %198, i32 0, i32 0
  %200 = load ptr, ptr %199, align 8, !tbaa !9
  %201 = getelementptr inbounds i8, ptr %200, i64 21
  %202 = call ptr @strrchr(ptr noundef %201, i32 noundef 47) #7
  %203 = icmp ne ptr %202, null
  br i1 %203, label %204, label %211

204:                                              ; preds = %195
  %205 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %206 = getelementptr inbounds %struct.s2n_debug_info, ptr %205, i32 0, i32 0
  %207 = load ptr, ptr %206, align 8, !tbaa !9
  %208 = getelementptr inbounds i8, ptr %207, i64 21
  %209 = call ptr @strrchr(ptr noundef %208, i32 noundef 47) #7
  %210 = getelementptr inbounds i8, ptr %209, i64 1
  br label %216

211:                                              ; preds = %195
  %212 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %213 = getelementptr inbounds %struct.s2n_debug_info, ptr %212, i32 0, i32 0
  %214 = load ptr, ptr %213, align 8, !tbaa !9
  %215 = getelementptr inbounds i8, ptr %214, i64 21
  br label %216

216:                                              ; preds = %211, %204
  %217 = phi ptr [ %210, %204 ], [ %215, %211 ]
  %218 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %219 = getelementptr inbounds %struct.s2n_debug_info, ptr %218, i32 0, i32 1
  store ptr %217, ptr %219, align 8, !tbaa !11
  %220 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544344, ptr %220, align 4, !tbaa !12
  %221 = call i32 @s2n_calculate_stacktrace()
  br label %222

222:                                              ; preds = %216
  br label %223

223:                                              ; preds = %222
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %229

224:                                              ; No predecessors!
  br label %225

225:                                              ; preds = %224
  br label %226

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

227:                                              ; preds = %226
  br label %228

228:                                              ; preds = %227
  store i32 0, ptr %8, align 4
  br label %229

229:                                              ; preds = %228, %223
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  %230 = load i32, ptr %8, align 4
  switch i32 %230, label %233 [
    i32 0, label %231
  ]

231:                                              ; preds = %229
  br label %232

232:                                              ; preds = %231, %180
  store i32 0, ptr %8, align 4
  br label %233

233:                                              ; preds = %232, %229, %175
  call void @X509_free_pointer(ptr noundef %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  br label %234

234:                                              ; preds = %233, %132, %125, %113
  %235 = call i32 @s2n_free(ptr noundef %9)
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #8
  %236 = load i32, ptr %8, align 4
  switch i32 %236, label %246 [
    i32 0, label %237
  ]

237:                                              ; preds = %234
  br label %238

238:                                              ; preds = %237
  %239 = getelementptr inbounds %struct.s2n_stuffer, ptr %6, i32 0, i32 2
  %240 = load i32, ptr %239, align 4, !tbaa !16
  %241 = getelementptr inbounds %struct.s2n_stuffer, ptr %6, i32 0, i32 1
  %242 = load i32, ptr %241, align 8, !tbaa !19
  %243 = sub i32 %240, %242
  %244 = icmp ne i32 %243, 0
  br i1 %244, label %109, label %245, !llvm.loop !24

245:                                              ; preds = %238
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %246

246:                                              ; preds = %245, %234, %105, %98
  %247 = call i32 @s2n_stuffer_free(ptr noundef %7)
  call void @llvm.lifetime.end.p0(i64 40, ptr %7) #8
  %248 = call i32 @s2n_stuffer_free(ptr noundef %6)
  call void @llvm.lifetime.end.p0(i64 40, ptr %6) #8
  br label %249

249:                                              ; preds = %246, %81, %45
  %250 = load i32, ptr %3, align 4
  ret i32 %250
}

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

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

declare i32 @s2n_calculate_stacktrace() #3

declare ptr @X509_STORE_new() #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_stuffer_free(ptr noundef) #3

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

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

declare i32 @s2n_free(ptr noundef) #3

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

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

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

declare ptr @d2i_X509(ptr noundef, ptr noundef, i64 noundef) #3

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

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

declare i64 @ERR_get_error() #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @ERR_GET_REASON(i64 noundef) #6

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 #7 = { nounwind willreturn memory(read) }
attributes #8 = { 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 0}
!10 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!11 = !{!10, !6, i64 8}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"s2n_x509_trust_store", !6, i64 0, !13, i64 8}
!16 = !{!17, !13, i64 28}
!17 = !{!"s2n_stuffer", !18, i64 0, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 36, !13, i64 36}
!18 = !{!"s2n_blob", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16}
!19 = !{!17, !13, i64 24}
!20 = !{!18, !6, i64 0}
!21 = !{!18, !13, i64 8}
!22 = !{!23, !23, i64 0}
!23 = !{!"long", !7, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"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"

%struct.s2n_debug_info = type { ptr, ptr }
%struct.s2n_stuffer = type { %struct.s2n_blob, i32, i32, i32, i8 }
%struct.s2n_blob = type { ptr, i32, i32, i8 }

@.str = external hidden unnamed_addr constant [94 x i8], align 1
@_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.1 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [95 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @s2n_x509_trust_store_add_pem(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.s2n_stuffer, align 8
  %4 = alloca %struct.s2n_stuffer, align 8
  %5 = alloca %struct.s2n_blob, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %8, label %16

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

16:                                               ; preds = %2
  %.not21 = icmp eq ptr %1, null
  br i1 %.not21, label %17, label %25

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

25:                                               ; preds = %16
  %26 = load ptr, ptr %0, align 8, !tbaa !13
  %.not23 = icmp eq ptr %26, null
  br i1 %.not23, label %27, label %29

27:                                               ; preds = %25
  %28 = tail call ptr @X509_STORE_new() #8
  store ptr %28, ptr %0, align 8, !tbaa !13
  br label %29

29:                                               ; preds = %27, %25
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %3) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %3, i8 0, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %4, i8 0, i64 40, i1 false)
  %30 = call i32 @s2n_stuffer_alloc_ro_from_string(ptr noundef nonnull %3, ptr noundef nonnull %1) #8
  %31 = icmp sgt i32 %30, -1
  br i1 %31, label %32, label %.loopexit

32:                                               ; preds = %29
  %33 = call i32 @s2n_stuffer_growable_alloc(ptr noundef nonnull %4, i32 noundef 2048) #8
  %34 = icmp sgt i32 %33, -1
  br i1 %34, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %32
  %35 = getelementptr inbounds i8, ptr %4, i64 28
  %36 = getelementptr inbounds i8, ptr %4, i64 24
  %37 = getelementptr inbounds i8, ptr %5, i64 8
  %38 = getelementptr inbounds i8, ptr %3, i64 28
  %39 = getelementptr inbounds i8, ptr %3, i64 24
  br label %40

40:                                               ; preds = %.preheader, %66
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %5, i8 0, i64 24, i1 false)
  %41 = call i32 @s2n_stuffer_certificate_from_pem(ptr noundef nonnull %3, ptr noundef nonnull %4) #8
  %42 = icmp sgt i32 %41, -1
  br i1 %42, label %43, label %.thread

43:                                               ; preds = %40
  %44 = load i32, ptr %35, align 4, !tbaa !15
  %45 = load i32, ptr %36, align 8, !tbaa !18
  %46 = sub i32 %44, %45
  %47 = call i32 @s2n_alloc(ptr noundef nonnull %5, i32 noundef %46) #8
  %48 = icmp sgt i32 %47, -1
  br i1 %48, label %49, label %.thread

49:                                               ; preds = %43
  %50 = call i32 @s2n_stuffer_read(ptr noundef nonnull %4, ptr noundef nonnull %5) #8
  %51 = icmp sgt i32 %50, -1
  br i1 %51, label %52, label %.thread

52:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #8
  %53 = load ptr, ptr %5, align 8, !tbaa !19
  store ptr %53, ptr %6, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #8
  %54 = load i32, ptr %37, align 8, !tbaa !21
  %55 = zext i32 %54 to i64
  %56 = call ptr @d2i_X509(ptr noundef null, ptr noundef nonnull %6, i64 noundef %55) #8
  store ptr %56, ptr %7, align 8, !tbaa !20
  %57 = icmp eq ptr %56, null
  br i1 %57, label %.critedge, label %58

58:                                               ; preds = %52
  %59 = load ptr, ptr %0, align 8, !tbaa !13
  %60 = call i32 @X509_STORE_add_cert(ptr noundef %59, ptr noundef nonnull %56) #8
  %.not24 = icmp eq i32 %60, 0
  br i1 %.not24, label %61, label %66

61:                                               ; preds = %58
  %62 = call i64 @ERR_get_error() #8
  %63 = call i32 @ERR_GET_REASON(i64 noundef %62)
  %64 = icmp eq i32 %63, 101
  br i1 %64, label %66, label %.critedge

.thread:                                          ; preds = %40, %43, %49
  %65 = call i32 @s2n_free(ptr noundef nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #8
  br label %.loopexit

66:                                               ; preds = %61, %58
  call void @X509_free_pointer(ptr noundef nonnull %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #8
  %67 = call i32 @s2n_free(ptr noundef nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #8
  %68 = load i32, ptr %38, align 4, !tbaa !15
  %69 = load i32, ptr %39, align 8, !tbaa !18
  %.not27 = icmp eq i32 %68, %69
  br i1 %.not27, label %.loopexit, label %40, !llvm.loop !22

.critedge:                                        ; preds = %61, %52
  %.str.3.sink = phi ptr [ @.str.2, %52 ], [ @.str.3, %61 ]
  %.sink35 = phi ptr [ getelementptr inbounds (i8, ptr @.str.2, i64 21), %52 ], [ getelementptr inbounds (i8, ptr @.str.3, i64 21), %61 ]
  %70 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr %.str.3.sink, ptr %70, align 8, !tbaa !5
  %71 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) %.sink35, i32 noundef 47) #7
  %.not25 = icmp eq ptr %71, null
  %72 = getelementptr inbounds i8, ptr %71, i64 1
  %73 = select i1 %.not25, ptr %.sink35, ptr %72
  %74 = getelementptr inbounds i8, ptr %70, i64 8
  store ptr %73, ptr %74, align 8, !tbaa !10
  %75 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544344, ptr %75, align 4, !tbaa !11
  %76 = call i32 @s2n_calculate_stacktrace() #8
  call void @X509_free_pointer(ptr noundef nonnull %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #8
  %77 = call i32 @s2n_free(ptr noundef nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #8
  br label %.loopexit

.loopexit:                                        ; preds = %66, %.critedge, %.thread, %32, %29
  %.5 = phi i32 [ -1, %29 ], [ -1, %32 ], [ -1, %.thread ], [ -1, %.critedge ], [ 0, %66 ]
  %78 = call i32 @s2n_stuffer_free(ptr noundef nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #8
  %79 = call i32 @s2n_stuffer_free(ptr noundef nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #8
  br label %80

80:                                               ; preds = %.loopexit, %17, %8
  %.6 = phi i32 [ %.5, %.loopexit ], [ -1, %17 ], [ -1, %8 ]
  ret i32 %.6
}

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

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

declare i32 @s2n_calculate_stacktrace() local_unnamed_addr #3

declare ptr @X509_STORE_new() 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

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

declare i32 @s2n_stuffer_free(ptr noundef) local_unnamed_addr #3

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

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

declare i32 @s2n_free(ptr noundef) local_unnamed_addr #3

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

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

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

declare ptr @d2i_X509(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

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

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

declare i64 @ERR_get_error() local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @ERR_GET_REASON(i64 noundef) local_unnamed_addr #6

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 #7 = { nounwind willreturn memory(read) }
attributes #8 = { nounwind }

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

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


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