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

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

@.str.12 = external hidden unnamed_addr constant [84 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.13 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [84 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_kem_generate_keypair(ptr noundef %0) #0 {
  %2 = alloca %struct.s2n_result, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  br label %6

6:                                                ; preds = %1
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %41, label %9

9:                                                ; preds = %6
  br label %10

10:                                               ; preds = %9
  br label %11

11:                                               ; preds = %10
  %12 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %13 = getelementptr inbounds %struct.s2n_debug_info, ptr %12, i32 0, i32 0
  store ptr @.str.12, ptr %13, align 8, !tbaa !9
  %14 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %15 = getelementptr inbounds %struct.s2n_debug_info, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %16, i64 21
  %18 = call ptr @strrchr(ptr noundef %17, i32 noundef 47) #5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %27

20:                                               ; preds = %11
  %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) #5
  %26 = getelementptr inbounds i8, ptr %25, i64 1
  br label %32

27:                                               ; preds = %11
  %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
  br label %32

32:                                               ; preds = %27, %20
  %33 = phi ptr [ %26, %20 ], [ %31, %27 ]
  %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 1
  store ptr %33, ptr %35, align 8, !tbaa !11
  %36 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %36, align 4, !tbaa !12
  %37 = call i32 @s2n_calculate_stacktrace()
  br label %38

38:                                               ; preds = %32
  %39 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %39, align 4, !tbaa !14
  br label %285

40:                                               ; No predecessors!
  br label %41

41:                                               ; preds = %40, %6
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.s2n_kem_params, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !16
  %47 = icmp ne ptr %46, null
  br i1 %47, label %80, label %48

48:                                               ; preds = %43
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  %51 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %52 = getelementptr inbounds %struct.s2n_debug_info, ptr %51, i32 0, i32 0
  store ptr @.str.13, ptr %52, align 8, !tbaa !9
  %53 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %54 = getelementptr inbounds %struct.s2n_debug_info, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  %56 = getelementptr inbounds i8, ptr %55, i64 21
  %57 = call ptr @strrchr(ptr noundef %56, i32 noundef 47) #5
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %66

59:                                               ; preds = %50
  %60 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %61 = getelementptr inbounds %struct.s2n_debug_info, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !9
  %63 = getelementptr inbounds i8, ptr %62, i64 21
  %64 = call ptr @strrchr(ptr noundef %63, i32 noundef 47) #5
  %65 = getelementptr inbounds i8, ptr %64, i64 1
  br label %71

66:                                               ; preds = %50
  %67 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %68 = getelementptr inbounds %struct.s2n_debug_info, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !9
  %70 = getelementptr inbounds i8, ptr %69, i64 21
  br label %71

71:                                               ; preds = %66, %59
  %72 = phi ptr [ %65, %59 ], [ %70, %66 ]
  %73 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %74 = getelementptr inbounds %struct.s2n_debug_info, ptr %73, i32 0, i32 1
  store ptr %72, ptr %74, align 8, !tbaa !11
  %75 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %75, align 4, !tbaa !12
  %76 = call i32 @s2n_calculate_stacktrace()
  br label %77

77:                                               ; preds = %71
  %78 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %78, align 4, !tbaa !14
  br label %285

79:                                               ; No predecessors!
  br label %80

80:                                               ; preds = %79, %43
  br label %81

81:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.s2n_kem_params, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !16
  store ptr %84, ptr %4, align 8, !tbaa !5
  br label %85

85:                                               ; preds = %81
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.s2n_kem, ptr %86, i32 0, i32 7
  %88 = load ptr, ptr %87, align 8, !tbaa !20
  %89 = icmp ne ptr %88, null
  br i1 %89, label %124, label %90

90:                                               ; preds = %85
  br label %91

91:                                               ; preds = %90
  br label %92

92:                                               ; preds = %91
  %93 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %94 = getelementptr inbounds %struct.s2n_debug_info, ptr %93, i32 0, i32 0
  store ptr @.str.14, ptr %94, align 8, !tbaa !9
  %95 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %96 = getelementptr inbounds %struct.s2n_debug_info, ptr %95, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8, !tbaa !9
  %98 = getelementptr inbounds i8, ptr %97, i64 21
  %99 = call ptr @strrchr(ptr noundef %98, i32 noundef 47) #5
  %100 = icmp ne ptr %99, null
  br i1 %100, label %101, label %108

101:                                              ; preds = %92
  %102 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %103 = getelementptr inbounds %struct.s2n_debug_info, ptr %102, i32 0, i32 0
  %104 = load ptr, ptr %103, align 8, !tbaa !9
  %105 = getelementptr inbounds i8, ptr %104, i64 21
  %106 = call ptr @strrchr(ptr noundef %105, i32 noundef 47) #5
  %107 = getelementptr inbounds i8, ptr %106, i64 1
  br label %113

108:                                              ; preds = %92
  %109 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %110 = getelementptr inbounds %struct.s2n_debug_info, ptr %109, i32 0, i32 0
  %111 = load ptr, ptr %110, align 8, !tbaa !9
  %112 = getelementptr inbounds i8, ptr %111, i64 21
  br label %113

113:                                              ; preds = %108, %101
  %114 = phi ptr [ %107, %101 ], [ %112, %108 ]
  %115 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %116 = getelementptr inbounds %struct.s2n_debug_info, ptr %115, i32 0, i32 1
  store ptr %114, ptr %116, align 8, !tbaa !11
  %117 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %117, align 4, !tbaa !12
  %118 = call i32 @s2n_calculate_stacktrace()
  br label %119

119:                                              ; preds = %113
  br label %120

120:                                              ; preds = %119
  %121 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %121, align 4, !tbaa !14
  store i32 1, ptr %5, align 4
  br label %284

122:                                              ; No predecessors!
  br label %123

123:                                              ; preds = %122
  br label %124

124:                                              ; preds = %123, %85
  br label %125

125:                                              ; preds = %124
  br label %126

126:                                              ; preds = %125
  br label %127

127:                                              ; preds = %126
  %128 = load ptr, ptr %3, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.s2n_kem_params, ptr %128, i32 0, i32 1
  %130 = getelementptr inbounds %struct.s2n_blob, ptr %129, i32 0, i32 0
  %131 = load ptr, ptr %130, align 8, !tbaa !23
  %132 = icmp ne ptr %131, null
  br i1 %132, label %167, label %133

133:                                              ; preds = %127
  br label %134

134:                                              ; preds = %133
  br label %135

135:                                              ; preds = %134
  %136 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %137 = getelementptr inbounds %struct.s2n_debug_info, ptr %136, i32 0, i32 0
  store ptr @.str.15, ptr %137, align 8, !tbaa !9
  %138 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %139 = getelementptr inbounds %struct.s2n_debug_info, ptr %138, i32 0, i32 0
  %140 = load ptr, ptr %139, align 8, !tbaa !9
  %141 = getelementptr inbounds i8, ptr %140, i64 21
  %142 = call ptr @strrchr(ptr noundef %141, i32 noundef 47) #5
  %143 = icmp ne ptr %142, null
  br i1 %143, label %144, label %151

144:                                              ; preds = %135
  %145 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %146 = getelementptr inbounds %struct.s2n_debug_info, ptr %145, i32 0, i32 0
  %147 = load ptr, ptr %146, align 8, !tbaa !9
  %148 = getelementptr inbounds i8, ptr %147, i64 21
  %149 = call ptr @strrchr(ptr noundef %148, i32 noundef 47) #5
  %150 = getelementptr inbounds i8, ptr %149, i64 1
  br label %156

151:                                              ; preds = %135
  %152 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %153 = getelementptr inbounds %struct.s2n_debug_info, ptr %152, i32 0, i32 0
  %154 = load ptr, ptr %153, align 8, !tbaa !9
  %155 = getelementptr inbounds i8, ptr %154, i64 21
  br label %156

156:                                              ; preds = %151, %144
  %157 = phi ptr [ %150, %144 ], [ %155, %151 ]
  %158 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %159 = getelementptr inbounds %struct.s2n_debug_info, ptr %158, i32 0, i32 1
  store ptr %157, ptr %159, align 8, !tbaa !11
  %160 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %160, align 4, !tbaa !12
  %161 = call i32 @s2n_calculate_stacktrace()
  br label %162

162:                                              ; preds = %156
  br label %163

163:                                              ; preds = %162
  %164 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %164, align 4, !tbaa !14
  store i32 1, ptr %5, align 4
  br label %284

165:                                              ; No predecessors!
  br label %166

166:                                              ; preds = %165
  br label %167

167:                                              ; preds = %166, %127
  br label %168

168:                                              ; preds = %167
  br label %169

169:                                              ; preds = %168
  br label %170

170:                                              ; preds = %169
  %171 = load ptr, ptr %3, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.s2n_kem_params, ptr %171, i32 0, i32 1
  %173 = getelementptr inbounds %struct.s2n_blob, ptr %172, i32 0, i32 1
  %174 = load i32, ptr %173, align 8, !tbaa !24
  %175 = load ptr, ptr %4, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.s2n_kem, ptr %175, i32 0, i32 3
  %177 = load i16, ptr %176, align 2, !tbaa !25
  %178 = zext i16 %177 to i32
  %179 = icmp eq i32 %174, %178
  br i1 %179, label %214, label %180

180:                                              ; preds = %170
  br label %181

181:                                              ; preds = %180
  br label %182

182:                                              ; preds = %181
  %183 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %184 = getelementptr inbounds %struct.s2n_debug_info, ptr %183, i32 0, i32 0
  store ptr @.str.16, ptr %184, align 8, !tbaa !9
  %185 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %186 = getelementptr inbounds %struct.s2n_debug_info, ptr %185, i32 0, i32 0
  %187 = load ptr, ptr %186, align 8, !tbaa !9
  %188 = getelementptr inbounds i8, ptr %187, i64 21
  %189 = call ptr @strrchr(ptr noundef %188, i32 noundef 47) #5
  %190 = icmp ne ptr %189, null
  br i1 %190, label %191, label %198

191:                                              ; preds = %182
  %192 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %193 = getelementptr inbounds %struct.s2n_debug_info, ptr %192, i32 0, i32 0
  %194 = load ptr, ptr %193, align 8, !tbaa !9
  %195 = getelementptr inbounds i8, ptr %194, i64 21
  %196 = call ptr @strrchr(ptr noundef %195, i32 noundef 47) #5
  %197 = getelementptr inbounds i8, ptr %196, i64 1
  br label %203

198:                                              ; preds = %182
  %199 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %200 = getelementptr inbounds %struct.s2n_debug_info, ptr %199, i32 0, i32 0
  %201 = load ptr, ptr %200, align 8, !tbaa !9
  %202 = getelementptr inbounds i8, ptr %201, i64 21
  br label %203

203:                                              ; preds = %198, %191
  %204 = phi ptr [ %197, %191 ], [ %202, %198 ]
  %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 1
  store ptr %204, ptr %206, align 8, !tbaa !11
  %207 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653194, ptr %207, align 4, !tbaa !12
  %208 = call i32 @s2n_calculate_stacktrace()
  br label %209

209:                                              ; preds = %203
  br label %210

210:                                              ; preds = %209
  %211 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %211, align 4, !tbaa !14
  store i32 1, ptr %5, align 4
  br label %284

212:                                              ; No predecessors!
  br label %213

213:                                              ; preds = %212
  br label %214

214:                                              ; preds = %213, %170
  br label %215

215:                                              ; preds = %214
  br label %216

216:                                              ; preds = %215
  br label %217

217:                                              ; preds = %216
  %218 = load ptr, ptr %3, align 8, !tbaa !5
  %219 = getelementptr inbounds %struct.s2n_kem_params, ptr %218, i32 0, i32 2
  %220 = load ptr, ptr %4, align 8, !tbaa !5
  %221 = getelementptr inbounds %struct.s2n_kem, ptr %220, i32 0, i32 4
  %222 = load i16, ptr %221, align 8, !tbaa !26
  %223 = zext i16 %222 to i32
  %224 = call i32 @s2n_realloc(ptr noundef %219, i32 noundef %223)
  %225 = icmp sgt i32 %224, -1
  br i1 %225, label %228, label %226

226:                                              ; preds = %217
  %227 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %227, align 4, !tbaa !14
  store i32 1, ptr %5, align 4
  br label %284

228:                                              ; preds = %217
  br label %229

229:                                              ; preds = %228
  br label %230

230:                                              ; preds = %229
  br label %231

231:                                              ; preds = %230
  %232 = load ptr, ptr %4, align 8, !tbaa !5
  %233 = getelementptr inbounds %struct.s2n_kem, ptr %232, i32 0, i32 7
  %234 = load ptr, ptr %233, align 8, !tbaa !20
  %235 = load ptr, ptr %4, align 8, !tbaa !5
  %236 = load ptr, ptr %3, align 8, !tbaa !5
  %237 = getelementptr inbounds %struct.s2n_kem_params, ptr %236, i32 0, i32 1
  %238 = getelementptr inbounds %struct.s2n_blob, ptr %237, i32 0, i32 0
  %239 = load ptr, ptr %238, align 8, !tbaa !23
  %240 = load ptr, ptr %3, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.s2n_kem_params, ptr %240, i32 0, i32 2
  %242 = getelementptr inbounds %struct.s2n_blob, ptr %241, i32 0, i32 0
  %243 = load ptr, ptr %242, align 8, !tbaa !27
  %244 = call i32 %234(ptr noundef %235, ptr noundef %239, ptr noundef %243)
  %245 = icmp eq i32 %244, 0
  br i1 %245, label %280, label %246

246:                                              ; preds = %231
  br label %247

247:                                              ; preds = %246
  br label %248

248:                                              ; preds = %247
  %249 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %250 = getelementptr inbounds %struct.s2n_debug_info, ptr %249, i32 0, i32 0
  store ptr @.str.17, ptr %250, align 8, !tbaa !9
  %251 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %252 = getelementptr inbounds %struct.s2n_debug_info, ptr %251, i32 0, i32 0
  %253 = load ptr, ptr %252, align 8, !tbaa !9
  %254 = getelementptr inbounds i8, ptr %253, i64 21
  %255 = call ptr @strrchr(ptr noundef %254, i32 noundef 47) #5
  %256 = icmp ne ptr %255, null
  br i1 %256, label %257, label %264

257:                                              ; preds = %248
  %258 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %259 = getelementptr inbounds %struct.s2n_debug_info, ptr %258, i32 0, i32 0
  %260 = load ptr, ptr %259, align 8, !tbaa !9
  %261 = getelementptr inbounds i8, ptr %260, i64 21
  %262 = call ptr @strrchr(ptr noundef %261, i32 noundef 47) #5
  %263 = getelementptr inbounds i8, ptr %262, i64 1
  br label %269

264:                                              ; preds = %248
  %265 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %266 = getelementptr inbounds %struct.s2n_debug_info, ptr %265, i32 0, i32 0
  %267 = load ptr, ptr %266, align 8, !tbaa !9
  %268 = getelementptr inbounds i8, ptr %267, i64 21
  br label %269

269:                                              ; preds = %264, %257
  %270 = phi ptr [ %263, %257 ], [ %268, %264 ]
  %271 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %272 = getelementptr inbounds %struct.s2n_debug_info, ptr %271, i32 0, i32 1
  store ptr %270, ptr %272, align 8, !tbaa !11
  %273 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653260, ptr %273, align 4, !tbaa !12
  %274 = call i32 @s2n_calculate_stacktrace()
  br label %275

275:                                              ; preds = %269
  br label %276

276:                                              ; preds = %275
  %277 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %277, align 4, !tbaa !14
  store i32 1, ptr %5, align 4
  br label %284

278:                                              ; No predecessors!
  br label %279

279:                                              ; preds = %278
  br label %280

280:                                              ; preds = %279, %231
  br label %281

281:                                              ; preds = %280
  br label %282

282:                                              ; preds = %281
  %283 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 0, ptr %283, align 4, !tbaa !14
  store i32 1, ptr %5, align 4
  br label %284

284:                                              ; preds = %282, %276, %226, %210, %163, %120
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  br label %285

285:                                              ; preds = %284, %77, %38
  %286 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  %287 = load i32, ptr %286, align 4
  ret i32 %287
}

; 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

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

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

; 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 = { nounwind willreturn memory(read) }
attributes #6 = { 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, !13, i64 0}
!15 = !{!"", !13, i64 0}
!16 = !{!17, !6, i64 0}
!17 = !{!"s2n_kem_params", !6, i64 0, !18, i64 8, !18, i64 32, !18, i64 56, !19, i64 80}
!18 = !{!"s2n_blob", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16}
!19 = !{!"_Bool", !7, i64 0}
!20 = !{!21, !6, i64 24}
!21 = !{!"s2n_kem", !6, i64 0, !13, i64 8, !22, i64 12, !22, i64 14, !22, i64 16, !22, i64 18, !22, i64 20, !6, i64 24, !6, i64 32, !6, i64 40}
!22 = !{!"short", !7, i64 0}
!23 = !{!17, !6, i64 8}
!24 = !{!17, !13, i64 16}
!25 = !{!21, !22, i64 14}
!26 = !{!21, !22, i64 16}
!27 = !{!17, !6, i64 32}


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

@.str.12 = external hidden unnamed_addr constant [84 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.13 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [84 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_kem_generate_keypair(ptr noundef %0) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.sink.split, label %2

2:                                                ; preds = %1
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %.not21 = icmp eq ptr %3, null
  br i1 %.not21, label %.sink.split, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %3, i64 24
  %6 = load ptr, ptr %5, align 8, !tbaa !13
  %.not23 = icmp eq ptr %6, null
  br i1 %.not23, label %.sink.split, label %7

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !16
  %.not25 = icmp eq ptr %9, null
  br i1 %.not25, label %.sink.split, label %10

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load i32, ptr %11, align 8, !tbaa !17
  %13 = getelementptr inbounds i8, ptr %3, i64 14
  %14 = load i16, ptr %13, align 2, !tbaa !18
  %15 = zext i16 %14 to i32
  %16 = icmp eq i32 %12, %15
  br i1 %16, label %17, label %.sink.split

17:                                               ; preds = %10
  %18 = getelementptr inbounds i8, ptr %0, i64 32
  %19 = getelementptr inbounds i8, ptr %3, i64 16
  %20 = load i16, ptr %19, align 8, !tbaa !19
  %21 = zext i16 %20 to i32
  %22 = tail call i32 @s2n_realloc(ptr noundef nonnull %18, i32 noundef %21) #4
  %23 = icmp sgt i32 %22, -1
  br i1 %23, label %24, label %37

24:                                               ; preds = %17
  %25 = load ptr, ptr %5, align 8, !tbaa !13
  %26 = load ptr, ptr %8, align 8, !tbaa !16
  %27 = load ptr, ptr %18, align 8, !tbaa !20
  %28 = tail call i32 %25(ptr noundef nonnull %3, ptr noundef %26, ptr noundef %27) #4
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %37, label %.sink.split

.sink.split:                                      ; preds = %24, %10, %7, %4, %2, %1
  %.str.14.sink = phi ptr [ @.str.12, %1 ], [ @.str.13, %2 ], [ @.str.14, %4 ], [ @.str.15, %7 ], [ @.str.16, %10 ], [ @.str.17, %24 ]
  %.sink37 = phi ptr [ getelementptr inbounds (i8, ptr @.str.12, i64 21), %1 ], [ getelementptr inbounds (i8, ptr @.str.13, i64 21), %2 ], [ getelementptr inbounds (i8, ptr @.str.14, i64 21), %4 ], [ getelementptr inbounds (i8, ptr @.str.15, i64 21), %7 ], [ getelementptr inbounds (i8, ptr @.str.16, i64 21), %10 ], [ getelementptr inbounds (i8, ptr @.str.17, i64 21), %24 ]
  %.sink = phi i32 [ 402653193, %1 ], [ 402653193, %2 ], [ 402653193, %4 ], [ 402653193, %7 ], [ 402653194, %10 ], [ 402653260, %24 ]
  %30 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr %.str.14.sink, ptr %30, align 8, !tbaa !21
  %31 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) %.sink37, i32 noundef 47) #5
  %.not24 = icmp eq ptr %31, null
  %32 = getelementptr inbounds i8, ptr %31, i64 1
  %33 = select i1 %.not24, ptr %.sink37, ptr %32
  %34 = getelementptr inbounds i8, ptr %30, i64 8
  store ptr %33, ptr %34, align 8, !tbaa !23
  %35 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 %.sink, ptr %35, align 4, !tbaa !24
  %36 = tail call i32 @s2n_calculate_stacktrace() #4
  br label %37

37:                                               ; preds = %.sink.split, %17, %24
  %.sroa.0.1 = phi i32 [ -1, %17 ], [ 0, %24 ], [ -1, %.sink.split ]
  ret i32 %.sroa.0.1
}

; 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 i32 @s2n_realloc(ptr noundef, i32 noundef) local_unnamed_addr #3

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 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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_kem_params", !7, i64 0, !10, i64 8, !10, i64 32, !10, i64 56, !12, 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 = !{!"_Bool", !8, i64 0}
!13 = !{!14, !7, i64 24}
!14 = !{!"s2n_kem", !7, i64 0, !11, i64 8, !15, i64 12, !15, i64 14, !15, i64 16, !15, i64 18, !15, i64 20, !7, i64 24, !7, i64 32, !7, i64 40}
!15 = !{!"short", !8, i64 0}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !11, i64 16}
!18 = !{!14, !15, i64 14}
!19 = !{!14, !15, i64 16}
!20 = !{!6, !7, i64 32}
!21 = !{!22, !7, i64 0}
!22 = !{!"s2n_debug_info", !7, i64 0, !7, i64 8}
!23 = !{!22, !7, i64 8}
!24 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass