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

; 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.iovec = type { ptr, i64 }

@_s2n_debug_info = external thread_local global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local global i32, align 4
@.str.34 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [92 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_stuffer_validate(ptr noundef) #0

; 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: inlinehint nounwind uwtable
declare hidden zeroext i1 @s2n_result_is_ok(i32) #4

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

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

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

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

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

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

24:                                               ; preds = %5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call i32 @s2n_stuffer_validate(ptr noundef %25)
  %27 = getelementptr inbounds %struct.s2n_result, ptr %13, i32 0, i32 0
  store i32 %26, ptr %27, align 4
  %28 = getelementptr inbounds %struct.s2n_result, ptr %13, i32 0, i32 0
  %29 = load i32, ptr %28, align 4
  %30 = call zeroext i1 @s2n_result_is_ok(i32 %29)
  %31 = xor i1 %30, true
  %32 = xor i1 %31, true
  %33 = zext i1 %32 to i32
  %34 = sext i32 %33 to i64
  %35 = call i64 @llvm.expect.i64(i64 %34, i64 1)
  %36 = icmp ne i64 %35, 0
  br i1 %36, label %37, label %39

37:                                               ; preds = %24
  %38 = getelementptr inbounds %struct.s2n_result, ptr %12, i32 0, i32 0
  store i32 0, ptr %38, align 4, !tbaa !13
  br label %41

39:                                               ; preds = %24
  %40 = getelementptr inbounds %struct.s2n_result, ptr %12, i32 0, i32 0
  store i32 -1, ptr %40, align 4, !tbaa !13
  br label %41

41:                                               ; preds = %39, %37
  %42 = getelementptr inbounds %struct.s2n_result, ptr %12, i32 0, i32 0
  %43 = load i32, ptr %42, align 4
  %44 = call zeroext i1 @s2n_result_is_ok(i32 %43)
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  store i32 -1, ptr %6, align 4
  br label %396

46:                                               ; preds = %41
  br label %47

47:                                               ; preds = %46
  br label %48

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

51:                                               ; preds = %48
  br label %52

52:                                               ; preds = %51
  br label %53

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

62:                                               ; preds = %53
  %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 !15
  %66 = getelementptr inbounds i8, ptr %65, i64 21
  %67 = call ptr @strrchr(ptr noundef %66, i32 noundef 47) #7
  %68 = getelementptr inbounds i8, ptr %67, i64 1
  br label %74

69:                                               ; preds = %53
  %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 !15
  %73 = getelementptr inbounds i8, ptr %72, i64 21
  br label %74

74:                                               ; preds = %69, %62
  %75 = phi ptr [ %68, %62 ], [ %73, %69 ]
  %76 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %77 = getelementptr inbounds %struct.s2n_debug_info, ptr %76, i32 0, i32 1
  store ptr %75, ptr %77, align 8, !tbaa !17
  %78 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %78, align 4, !tbaa !11
  %79 = call i32 @s2n_calculate_stacktrace()
  br label %80

80:                                               ; preds = %74
  store i32 -1, ptr %6, align 4
  br label %396

81:                                               ; No predecessors!
  br label %82

82:                                               ; preds = %81, %48
  br label %83

83:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = load i32, ptr %11, align 4, !tbaa !11
  %86 = call ptr @s2n_stuffer_raw_write(ptr noundef %84, i32 noundef %85)
  store ptr %86, ptr %14, align 8, !tbaa !5
  br label %87

87:                                               ; preds = %83
  %88 = load i32, ptr %11, align 4, !tbaa !11
  %89 = icmp eq i32 %88, 0
  br i1 %89, label %126, label %90

90:                                               ; preds = %87
  %91 = load ptr, ptr %14, align 8, !tbaa !5
  %92 = icmp ne ptr %91, null
  br i1 %92, label %126, label %93

93:                                               ; preds = %90
  br label %94

94:                                               ; preds = %93
  br label %95

95:                                               ; preds = %94
  %96 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %97 = getelementptr inbounds %struct.s2n_debug_info, ptr %96, i32 0, i32 0
  store ptr @.str.35, ptr %97, align 8, !tbaa !15
  %98 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %99 = getelementptr inbounds %struct.s2n_debug_info, ptr %98, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8, !tbaa !15
  %101 = getelementptr inbounds i8, ptr %100, i64 21
  %102 = call ptr @strrchr(ptr noundef %101, i32 noundef 47) #7
  %103 = icmp ne ptr %102, null
  br i1 %103, label %104, label %111

104:                                              ; preds = %95
  %105 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %106 = getelementptr inbounds %struct.s2n_debug_info, ptr %105, i32 0, i32 0
  %107 = load ptr, ptr %106, align 8, !tbaa !15
  %108 = getelementptr inbounds i8, ptr %107, i64 21
  %109 = call ptr @strrchr(ptr noundef %108, i32 noundef 47) #7
  %110 = getelementptr inbounds i8, ptr %109, i64 1
  br label %116

111:                                              ; preds = %95
  %112 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %113 = getelementptr inbounds %struct.s2n_debug_info, ptr %112, i32 0, i32 0
  %114 = load ptr, ptr %113, align 8, !tbaa !15
  %115 = getelementptr inbounds i8, ptr %114, i64 21
  br label %116

116:                                              ; preds = %111, %104
  %117 = phi ptr [ %110, %104 ], [ %115, %111 ]
  %118 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %119 = getelementptr inbounds %struct.s2n_debug_info, ptr %118, i32 0, i32 1
  store ptr %117, ptr %119, align 8, !tbaa !17
  %120 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %120, align 4, !tbaa !11
  %121 = call i32 @s2n_calculate_stacktrace()
  br label %122

122:                                              ; preds = %116
  br label %123

123:                                              ; preds = %122
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %395

124:                                              ; No predecessors!
  br label %125

125:                                              ; preds = %124
  br label %126

126:                                              ; preds = %125, %90, %87
  br label %127

127:                                              ; preds = %126
  br label %128

128:                                              ; preds = %127
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %129 = load i32, ptr %11, align 4, !tbaa !11
  %130 = zext i32 %129 to i64
  store i64 %130, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #8
  %131 = load i32, ptr %10, align 4, !tbaa !11
  %132 = zext i32 %131 to i64
  store i64 %132, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  store i64 0, ptr %18, align 8, !tbaa !9
  br label %133

133:                                              ; preds = %388, %128
  %134 = load i64, ptr %18, align 8, !tbaa !9
  %135 = load i64, ptr %9, align 8, !tbaa !9
  %136 = icmp ult i64 %134, %135
  br i1 %136, label %138, label %137

137:                                              ; preds = %133
  store i32 16, ptr %15, align 4
  br label %391

138:                                              ; preds = %133
  %139 = load i64, ptr %17, align 8, !tbaa !9
  %140 = load ptr, ptr %8, align 8, !tbaa !5
  %141 = load i64, ptr %18, align 8, !tbaa !9
  %142 = getelementptr inbounds %struct.iovec, ptr %140, i64 %141
  %143 = getelementptr inbounds %struct.iovec, ptr %142, i32 0, i32 1
  %144 = load i64, ptr %143, align 8, !tbaa !18
  %145 = icmp uge i64 %139, %144
  br i1 %145, label %146, label %154

146:                                              ; preds = %138
  %147 = load ptr, ptr %8, align 8, !tbaa !5
  %148 = load i64, ptr %18, align 8, !tbaa !9
  %149 = getelementptr inbounds %struct.iovec, ptr %147, i64 %148
  %150 = getelementptr inbounds %struct.iovec, ptr %149, i32 0, i32 1
  %151 = load i64, ptr %150, align 8, !tbaa !18
  %152 = load i64, ptr %17, align 8, !tbaa !9
  %153 = sub i64 %152, %151
  store i64 %153, ptr %17, align 8, !tbaa !9
  br label %388

154:                                              ; preds = %138
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #8
  %155 = load ptr, ptr %8, align 8, !tbaa !5
  %156 = load i64, ptr %18, align 8, !tbaa !9
  %157 = getelementptr inbounds %struct.iovec, ptr %155, i64 %156
  %158 = getelementptr inbounds %struct.iovec, ptr %157, i32 0, i32 1
  %159 = load i64, ptr %158, align 8, !tbaa !18
  %160 = load i64, ptr %17, align 8, !tbaa !9
  %161 = sub i64 %159, %160
  store i64 %161, ptr %19, align 8, !tbaa !9
  br label %162

162:                                              ; preds = %154
  %163 = load i64, ptr %19, align 8, !tbaa !9
  %164 = icmp ule i64 %163, 4294967295
  br i1 %164, label %198, label %165

165:                                              ; preds = %162
  br label %166

166:                                              ; preds = %165
  br label %167

167:                                              ; preds = %166
  %168 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %169 = getelementptr inbounds %struct.s2n_debug_info, ptr %168, i32 0, i32 0
  store ptr @.str.36, ptr %169, align 8, !tbaa !15
  %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 0
  %172 = load ptr, ptr %171, align 8, !tbaa !15
  %173 = getelementptr inbounds i8, ptr %172, i64 21
  %174 = call ptr @strrchr(ptr noundef %173, i32 noundef 47) #7
  %175 = icmp ne ptr %174, null
  br i1 %175, label %176, label %183

176:                                              ; preds = %167
  %177 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %178 = getelementptr inbounds %struct.s2n_debug_info, ptr %177, i32 0, i32 0
  %179 = load ptr, ptr %178, align 8, !tbaa !15
  %180 = getelementptr inbounds i8, ptr %179, i64 21
  %181 = call ptr @strrchr(ptr noundef %180, i32 noundef 47) #7
  %182 = getelementptr inbounds i8, ptr %181, i64 1
  br label %188

183:                                              ; preds = %167
  %184 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %185 = getelementptr inbounds %struct.s2n_debug_info, ptr %184, i32 0, i32 0
  %186 = load ptr, ptr %185, align 8, !tbaa !15
  %187 = getelementptr inbounds i8, ptr %186, i64 21
  br label %188

188:                                              ; preds = %183, %176
  %189 = phi ptr [ %182, %176 ], [ %187, %183 ]
  %190 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %191 = getelementptr inbounds %struct.s2n_debug_info, ptr %190, i32 0, i32 1
  store ptr %189, ptr %191, align 8, !tbaa !17
  %192 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653194, ptr %192, align 4, !tbaa !11
  %193 = call i32 @s2n_calculate_stacktrace()
  br label %194

194:                                              ; preds = %188
  br label %195

195:                                              ; preds = %194
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %385

196:                                              ; No predecessors!
  br label %197

197:                                              ; preds = %196
  br label %198

198:                                              ; preds = %197, %162
  br label %199

199:                                              ; preds = %198
  br label %200

200:                                              ; preds = %199
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #8
  %201 = load i64, ptr %19, align 8, !tbaa !9
  %202 = trunc i64 %201 to i32
  store i32 %202, ptr %20, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #8
  %203 = load i64, ptr %16, align 8, !tbaa !9
  %204 = load i32, ptr %20, align 4, !tbaa !11
  %205 = zext i32 %204 to i64
  %206 = icmp ult i64 %203, %205
  br i1 %206, label %207, label %209

207:                                              ; preds = %200
  %208 = load i64, ptr %16, align 8, !tbaa !9
  br label %212

209:                                              ; preds = %200
  %210 = load i32, ptr %20, align 4, !tbaa !11
  %211 = zext i32 %210 to i64
  br label %212

212:                                              ; preds = %209, %207
  %213 = phi i64 [ %208, %207 ], [ %211, %209 ]
  %214 = trunc i64 %213 to i32
  store i32 %214, ptr %21, align 4, !tbaa !11
  br label %215

215:                                              ; preds = %212
  %216 = load ptr, ptr %8, align 8, !tbaa !5
  %217 = load i64, ptr %18, align 8, !tbaa !9
  %218 = getelementptr inbounds %struct.iovec, ptr %216, i64 %217
  %219 = getelementptr inbounds %struct.iovec, ptr %218, i32 0, i32 0
  %220 = load ptr, ptr %219, align 8, !tbaa !20
  %221 = icmp ne ptr %220, null
  br i1 %221, label %255, label %222

222:                                              ; preds = %215
  br label %223

223:                                              ; preds = %222
  br label %224

224:                                              ; preds = %223
  %225 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %226 = getelementptr inbounds %struct.s2n_debug_info, ptr %225, i32 0, i32 0
  store ptr @.str.37, ptr %226, align 8, !tbaa !15
  %227 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %228 = getelementptr inbounds %struct.s2n_debug_info, ptr %227, i32 0, i32 0
  %229 = load ptr, ptr %228, align 8, !tbaa !15
  %230 = getelementptr inbounds i8, ptr %229, i64 21
  %231 = call ptr @strrchr(ptr noundef %230, i32 noundef 47) #7
  %232 = icmp ne ptr %231, null
  br i1 %232, label %233, label %240

233:                                              ; preds = %224
  %234 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %235 = getelementptr inbounds %struct.s2n_debug_info, ptr %234, i32 0, i32 0
  %236 = load ptr, ptr %235, align 8, !tbaa !15
  %237 = getelementptr inbounds i8, ptr %236, i64 21
  %238 = call ptr @strrchr(ptr noundef %237, i32 noundef 47) #7
  %239 = getelementptr inbounds i8, ptr %238, i64 1
  br label %245

240:                                              ; preds = %224
  %241 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %242 = getelementptr inbounds %struct.s2n_debug_info, ptr %241, i32 0, i32 0
  %243 = load ptr, ptr %242, align 8, !tbaa !15
  %244 = getelementptr inbounds i8, ptr %243, i64 21
  br label %245

245:                                              ; preds = %240, %233
  %246 = phi ptr [ %239, %233 ], [ %244, %240 ]
  %247 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %248 = getelementptr inbounds %struct.s2n_debug_info, ptr %247, i32 0, i32 1
  store ptr %246, ptr %248, align 8, !tbaa !17
  %249 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %249, align 4, !tbaa !11
  %250 = call i32 @s2n_calculate_stacktrace()
  br label %251

251:                                              ; preds = %245
  br label %252

252:                                              ; preds = %251
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %384

253:                                              ; No predecessors!
  br label %254

254:                                              ; preds = %253
  br label %255

255:                                              ; preds = %254, %215
  br label %256

256:                                              ; preds = %255
  br label %257

257:                                              ; preds = %256
  br label %258

258:                                              ; preds = %257
  %259 = load i64, ptr %17, align 8, !tbaa !9
  %260 = load ptr, ptr %8, align 8, !tbaa !5
  %261 = load i64, ptr %18, align 8, !tbaa !9
  %262 = getelementptr inbounds %struct.iovec, ptr %260, i64 %261
  %263 = getelementptr inbounds %struct.iovec, ptr %262, i32 0, i32 1
  %264 = load i64, ptr %263, align 8, !tbaa !18
  %265 = icmp ult i64 %259, %264
  br i1 %265, label %299, label %266

266:                                              ; preds = %258
  br label %267

267:                                              ; preds = %266
  br label %268

268:                                              ; preds = %267
  %269 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %270 = getelementptr inbounds %struct.s2n_debug_info, ptr %269, i32 0, i32 0
  store ptr @.str.38, ptr %270, align 8, !tbaa !15
  %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 0
  %273 = load ptr, ptr %272, align 8, !tbaa !15
  %274 = getelementptr inbounds i8, ptr %273, i64 21
  %275 = call ptr @strrchr(ptr noundef %274, i32 noundef 47) #7
  %276 = icmp ne ptr %275, null
  br i1 %276, label %277, label %284

277:                                              ; preds = %268
  %278 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %279 = getelementptr inbounds %struct.s2n_debug_info, ptr %278, i32 0, i32 0
  %280 = load ptr, ptr %279, align 8, !tbaa !15
  %281 = getelementptr inbounds i8, ptr %280, i64 21
  %282 = call ptr @strrchr(ptr noundef %281, i32 noundef 47) #7
  %283 = getelementptr inbounds i8, ptr %282, i64 1
  br label %289

284:                                              ; preds = %268
  %285 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %286 = getelementptr inbounds %struct.s2n_debug_info, ptr %285, i32 0, i32 0
  %287 = load ptr, ptr %286, align 8, !tbaa !15
  %288 = getelementptr inbounds i8, ptr %287, i64 21
  br label %289

289:                                              ; preds = %284, %277
  %290 = phi ptr [ %283, %277 ], [ %288, %284 ]
  %291 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %292 = getelementptr inbounds %struct.s2n_debug_info, ptr %291, i32 0, i32 1
  store ptr %290, ptr %292, align 8, !tbaa !17
  %293 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653194, ptr %293, align 4, !tbaa !11
  %294 = call i32 @s2n_calculate_stacktrace()
  br label %295

295:                                              ; preds = %289
  br label %296

296:                                              ; preds = %295
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %384

297:                                              ; No predecessors!
  br label %298

298:                                              ; preds = %297
  br label %299

299:                                              ; preds = %298, %258
  br label %300

300:                                              ; preds = %299
  br label %301

301:                                              ; preds = %300
  br label %302

302:                                              ; preds = %301
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #8
  %303 = load i32, ptr %21, align 4, !tbaa !11
  store i32 %303, ptr %22, align 4, !tbaa !11
  %304 = load i32, ptr %22, align 4, !tbaa !11
  %305 = icmp ne i32 %304, 0
  %306 = xor i1 %305, true
  %307 = xor i1 %306, true
  %308 = zext i1 %307 to i32
  %309 = sext i32 %308 to i64
  %310 = call i64 @llvm.expect.i64(i64 %309, i64 1)
  %311 = icmp ne i64 %310, 0
  br i1 %311, label %312, label %366

312:                                              ; preds = %302
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #8
  %313 = load ptr, ptr %14, align 8, !tbaa !5
  %314 = load ptr, ptr %8, align 8, !tbaa !5
  %315 = load i64, ptr %18, align 8, !tbaa !9
  %316 = getelementptr inbounds %struct.iovec, ptr %314, i64 %315
  %317 = getelementptr inbounds %struct.iovec, ptr %316, i32 0, i32 0
  %318 = load ptr, ptr %317, align 8, !tbaa !20
  %319 = load i64, ptr %17, align 8, !tbaa !9
  %320 = getelementptr inbounds i8, ptr %318, i64 %319
  %321 = load i32, ptr %22, align 4, !tbaa !11
  %322 = zext i32 %321 to i64
  %323 = call ptr @s2n_ensure_memmove_trace(ptr noundef %313, ptr noundef %320, i64 noundef %322)
  store ptr %323, ptr %23, align 8, !tbaa !5
  br label %324

324:                                              ; preds = %312
  %325 = load ptr, ptr %23, align 8, !tbaa !5
  %326 = icmp ne ptr %325, null
  br i1 %326, label %360, label %327

327:                                              ; preds = %324
  br label %328

328:                                              ; preds = %327
  br label %329

329:                                              ; preds = %328
  %330 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %331 = getelementptr inbounds %struct.s2n_debug_info, ptr %330, i32 0, i32 0
  store ptr @.str.39, ptr %331, align 8, !tbaa !15
  %332 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %333 = getelementptr inbounds %struct.s2n_debug_info, ptr %332, i32 0, i32 0
  %334 = load ptr, ptr %333, align 8, !tbaa !15
  %335 = getelementptr inbounds i8, ptr %334, i64 21
  %336 = call ptr @strrchr(ptr noundef %335, i32 noundef 47) #7
  %337 = icmp ne ptr %336, null
  br i1 %337, label %338, label %345

338:                                              ; preds = %329
  %339 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %340 = getelementptr inbounds %struct.s2n_debug_info, ptr %339, i32 0, i32 0
  %341 = load ptr, ptr %340, align 8, !tbaa !15
  %342 = getelementptr inbounds i8, ptr %341, i64 21
  %343 = call ptr @strrchr(ptr noundef %342, i32 noundef 47) #7
  %344 = getelementptr inbounds i8, ptr %343, i64 1
  br label %350

345:                                              ; preds = %329
  %346 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %347 = getelementptr inbounds %struct.s2n_debug_info, ptr %346, i32 0, i32 0
  %348 = load ptr, ptr %347, align 8, !tbaa !15
  %349 = getelementptr inbounds i8, ptr %348, i64 21
  br label %350

350:                                              ; preds = %345, %338
  %351 = phi ptr [ %344, %338 ], [ %349, %345 ]
  %352 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %353 = getelementptr inbounds %struct.s2n_debug_info, ptr %352, i32 0, i32 1
  store ptr %351, ptr %353, align 8, !tbaa !17
  %354 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %354, align 4, !tbaa !11
  %355 = call i32 @s2n_calculate_stacktrace()
  br label %356

356:                                              ; preds = %350
  br label %357

357:                                              ; preds = %356
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %363

358:                                              ; No predecessors!
  br label %359

359:                                              ; preds = %358
  br label %360

360:                                              ; preds = %359, %324
  br label %361

361:                                              ; preds = %360
  br label %362

362:                                              ; preds = %361
  store i32 0, ptr %15, align 4
  br label %363

363:                                              ; preds = %362, %357
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #8
  %364 = load i32, ptr %15, align 4
  switch i32 %364, label %367 [
    i32 0, label %365
  ]

365:                                              ; preds = %363
  br label %366

366:                                              ; preds = %365, %302
  store i32 0, ptr %15, align 4
  br label %367

367:                                              ; preds = %366, %363
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #8
  %368 = load i32, ptr %15, align 4
  switch i32 %368, label %384 [
    i32 0, label %369
  ]

369:                                              ; preds = %367
  br label %370

370:                                              ; preds = %369
  br label %371

371:                                              ; preds = %370
  %372 = load i32, ptr %21, align 4, !tbaa !11
  %373 = zext i32 %372 to i64
  %374 = load i64, ptr %16, align 8, !tbaa !9
  %375 = sub i64 %374, %373
  store i64 %375, ptr %16, align 8, !tbaa !9
  %376 = load i64, ptr %16, align 8, !tbaa !9
  %377 = icmp eq i64 %376, 0
  br i1 %377, label %378, label %379

378:                                              ; preds = %371
  store i32 16, ptr %15, align 4
  br label %384

379:                                              ; preds = %371
  %380 = load ptr, ptr %14, align 8, !tbaa !5
  %381 = load i32, ptr %21, align 4, !tbaa !11
  %382 = zext i32 %381 to i64
  %383 = getelementptr inbounds i8, ptr %380, i64 %382
  store ptr %383, ptr %14, align 8, !tbaa !5
  store i64 0, ptr %17, align 8, !tbaa !9
  store i32 0, ptr %15, align 4
  br label %384

384:                                              ; preds = %379, %378, %367, %296, %252
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #8
  br label %385

385:                                              ; preds = %384, %195
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #8
  %386 = load i32, ptr %15, align 4
  switch i32 %386, label %391 [
    i32 0, label %387
  ]

387:                                              ; preds = %385
  br label %388

388:                                              ; preds = %387, %146
  %389 = load i64, ptr %18, align 8, !tbaa !9
  %390 = add i64 %389, 1
  store i64 %390, ptr %18, align 8, !tbaa !9
  br label %133, !llvm.loop !21

391:                                              ; preds = %385, %137
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  %392 = load i32, ptr %15, align 4
  switch i32 %392, label %394 [
    i32 16, label %393
  ]

393:                                              ; preds = %391
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %394

394:                                              ; preds = %393, %391
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  br label %395

395:                                              ; preds = %394, %123
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  br label %396

396:                                              ; preds = %395, %80, %45
  %397 = load i32, ptr %6, align 4
  ret i32 %397
}

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 = { 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 #5 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #6 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"", !12, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!17 = !{!16, !6, i64 8}
!18 = !{!19, !10, i64 8}
!19 = !{!"iovec", !6, i64 0, !10, i64 8}
!20 = !{!19, !6, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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.iovec = type { ptr, i64 }

@_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.34 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [92 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_stuffer_validate(ptr noundef) local_unnamed_addr #0

; 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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @s2n_stuffer_writev_bytes(ptr noundef %0, ptr noundef readonly %1, i64 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = tail call i32 @s2n_stuffer_validate(ptr noundef %0)
  %7 = tail call zeroext i1 @s2n_result_is_ok(i32 %6)
  %not. = xor i1 %7, true
  %. = sext i1 %not. to i32
  %8 = tail call zeroext i1 @s2n_result_is_ok(i32 %.)
  br i1 %8, label %9, label %.thread102

9:                                                ; preds = %5
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %.thread102.sink.split, label %10

10:                                               ; preds = %9
  %11 = tail call ptr @s2n_stuffer_raw_write(ptr noundef %0, i32 noundef %4)
  %12 = icmp eq i32 %4, 0
  %13 = icmp ne ptr %11, null
  %or.cond = select i1 %12, i1 true, i1 %13
  br i1 %or.cond, label %14, label %.thread102.sink.split

14:                                               ; preds = %10
  %.not113 = icmp eq i64 %2, 0
  br i1 %.not113, label %.thread102, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %14
  %15 = zext i32 %3 to i64
  %16 = zext i32 %4 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %36
  %.053112 = phi ptr [ %.356, %36 ], [ %11, %.lr.ph.preheader ]
  %.062111 = phi i64 [ %.365, %36 ], [ %16, %.lr.ph.preheader ]
  %.066110 = phi i64 [ %37, %36 ], [ 0, %.lr.ph.preheader ]
  %.067109 = phi i64 [ %.370, %36 ], [ %15, %.lr.ph.preheader ]
  %17 = getelementptr inbounds %struct.iovec, ptr %1, i64 %.066110
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = load i64, ptr %18, align 8, !tbaa !5
  %.not87 = icmp ult i64 %.067109, %19
  br i1 %.not87, label %22, label %20

20:                                               ; preds = %.lr.ph
  %21 = sub i64 %.067109, %19
  br label %36

22:                                               ; preds = %.lr.ph
  %23 = sub i64 %19, %.067109
  %24 = icmp ult i64 %23, 4294967296
  br i1 %24, label %25, label %.thread102.sink.split

25:                                               ; preds = %22
  %26 = tail call i64 @llvm.umin.i64(i64 %.062111, i64 %23)
  %27 = load ptr, ptr %17, align 8, !tbaa !11
  %.not89 = icmp eq ptr %27, null
  br i1 %.not89, label %.thread102.sink.split, label %28

28:                                               ; preds = %25
  %.not92 = icmp eq i64 %26, 0
  br i1 %.not92, label %.critedge96, label %29, !prof !12

29:                                               ; preds = %28
  %30 = getelementptr inbounds i8, ptr %27, i64 %.067109
  %31 = tail call ptr @s2n_ensure_memmove_trace(ptr noundef %.053112, ptr noundef nonnull %30, i64 noundef %26) #6
  %.not93.not = icmp eq ptr %31, null
  br i1 %.not93.not, label %.thread102.sink.split, label %.critedge96

.critedge96:                                      ; preds = %29, %28
  %32 = sub i64 %.062111, %26
  %33 = icmp eq i64 %32, 0
  br i1 %33, label %.thread102, label %34

34:                                               ; preds = %.critedge96
  %35 = getelementptr inbounds i8, ptr %.053112, i64 %26
  br label %36

36:                                               ; preds = %34, %20
  %.370 = phi i64 [ %21, %20 ], [ 0, %34 ]
  %.365 = phi i64 [ %.062111, %20 ], [ %32, %34 ]
  %.356 = phi ptr [ %.053112, %20 ], [ %35, %34 ]
  %37 = add nuw i64 %.066110, 1
  %exitcond.not = icmp eq i64 %37, %2
  br i1 %exitcond.not, label %.thread102, label %.lr.ph, !llvm.loop !13

.thread102.sink.split:                            ; preds = %29, %25, %22, %10, %9
  %.str.36.sink = phi ptr [ @.str.34, %9 ], [ @.str.35, %10 ], [ @.str.36, %22 ], [ @.str.37, %25 ], [ @.str.39, %29 ]
  %.sink122 = phi ptr [ getelementptr inbounds (i8, ptr @.str.34, i64 21), %9 ], [ getelementptr inbounds (i8, ptr @.str.35, i64 21), %10 ], [ getelementptr inbounds (i8, ptr @.str.36, i64 21), %22 ], [ getelementptr inbounds (i8, ptr @.str.37, i64 21), %25 ], [ getelementptr inbounds (i8, ptr @.str.39, i64 21), %29 ]
  %.sink = phi i32 [ 402653193, %9 ], [ 402653193, %10 ], [ 402653194, %22 ], [ 402653193, %25 ], [ 402653193, %29 ]
  %38 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr %.str.36.sink, ptr %38, align 8, !tbaa !15
  %39 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) %.sink122, i32 noundef 47) #7
  %.not88 = icmp eq ptr %39, null
  %40 = getelementptr inbounds i8, ptr %39, i64 1
  %41 = select i1 %.not88, ptr %.sink122, ptr %40
  %42 = getelementptr inbounds i8, ptr %38, i64 8
  store ptr %41, ptr %42, align 8, !tbaa !17
  %43 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 %.sink, ptr %43, align 4, !tbaa !18
  %44 = tail call i32 @s2n_calculate_stacktrace() #6
  br label %.thread102

.thread102:                                       ; preds = %.critedge96, %36, %.thread102.sink.split, %14, %5
  %.10 = phi i32 [ -1, %5 ], [ 0, %14 ], [ -1, %.thread102.sink.split ], [ 0, %36 ], [ 0, %.critedge96 ]
  ret i32 %.10
}

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

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 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { 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, !10, i64 8}
!6 = !{!"iovec", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !7, i64 0}
!16 = !{!"s2n_debug_info", !7, i64 0, !7, i64 8}
!17 = !{!16, !7, i64 8}
!18 = !{!19, !19, i64 0}
!19 = !{!"int", !8, i64 0}


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