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

@_s2n_debug_info = external thread_local global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local global i32, align 4
@.str.31 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.33 = 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

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

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

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

20:                                               ; preds = %3
  store i32 0, ptr %4, align 4
  br label %268

21:                                               ; preds = %3
  br label %22

22:                                               ; preds = %21
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %59, label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %59, label %28

28:                                               ; preds = %25
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  %31 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %32 = getelementptr inbounds %struct.s2n_debug_info, ptr %31, i32 0, i32 0
  store ptr @.str.31, ptr %32, align 8, !tbaa !11
  %33 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %34 = getelementptr inbounds %struct.s2n_debug_info, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = getelementptr inbounds i8, ptr %35, i64 21
  %37 = call ptr @strrchr(ptr noundef %36, i32 noundef 47) #7
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %46

39:                                               ; preds = %30
  %40 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %41 = getelementptr inbounds %struct.s2n_debug_info, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !11
  %43 = getelementptr inbounds i8, ptr %42, i64 21
  %44 = call ptr @strrchr(ptr noundef %43, i32 noundef 47) #7
  %45 = getelementptr inbounds i8, ptr %44, i64 1
  br label %51

46:                                               ; preds = %30
  %47 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %48 = getelementptr inbounds %struct.s2n_debug_info, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !11
  %50 = getelementptr inbounds i8, ptr %49, i64 21
  br label %51

51:                                               ; preds = %46, %39
  %52 = phi ptr [ %45, %39 ], [ %50, %46 ]
  %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 1
  store ptr %52, ptr %54, align 8, !tbaa !13
  %55 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653194, ptr %55, align 4, !tbaa !9
  %56 = call i32 @s2n_calculate_stacktrace()
  br label %57

57:                                               ; preds = %51
  store i32 -1, ptr %4, align 4
  br label %268

58:                                               ; No predecessors!
  br label %59

59:                                               ; preds = %58, %25, %22
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = call i32 @s2n_stuffer_validate(ptr noundef %62)
  %64 = getelementptr inbounds %struct.s2n_result, ptr %9, i32 0, i32 0
  store i32 %63, ptr %64, align 4
  %65 = getelementptr inbounds %struct.s2n_result, ptr %9, i32 0, i32 0
  %66 = load i32, ptr %65, align 4
  %67 = call zeroext i1 @s2n_result_is_ok(i32 %66)
  %68 = xor i1 %67, true
  %69 = xor i1 %68, true
  %70 = zext i1 %69 to i32
  %71 = sext i32 %70 to i64
  %72 = call i64 @llvm.expect.i64(i64 %71, i64 1)
  %73 = icmp ne i64 %72, 0
  br i1 %73, label %74, label %76

74:                                               ; preds = %61
  %75 = getelementptr inbounds %struct.s2n_result, ptr %8, i32 0, i32 0
  store i32 0, ptr %75, align 4, !tbaa !14
  br label %78

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

78:                                               ; preds = %76, %74
  %79 = getelementptr inbounds %struct.s2n_result, ptr %8, i32 0, i32 0
  %80 = load i32, ptr %79, align 4
  %81 = call zeroext i1 @s2n_result_is_ok(i32 %80)
  br i1 %81, label %83, label %82

82:                                               ; preds = %78
  store i32 -1, ptr %4, align 4
  br label %268

83:                                               ; preds = %78
  br label %84

84:                                               ; preds = %83
  br label %85

85:                                               ; preds = %84
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = load i32, ptr %7, align 4, !tbaa !9
  %88 = call i32 @s2n_stuffer_skip_write(ptr noundef %86, i32 noundef %87)
  %89 = icmp sgt i32 %88, -1
  br i1 %89, label %91, label %90

90:                                               ; preds = %85
  store i32 -1, ptr %4, align 4
  br label %268

91:                                               ; preds = %85
  br label %92

92:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.s2n_stuffer, ptr %93, i32 0, i32 0
  %95 = getelementptr inbounds %struct.s2n_blob, ptr %94, i32 0, i32 0
  %96 = load ptr, ptr %95, align 8, !tbaa !16
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.s2n_stuffer, ptr %97, i32 0, i32 2
  %99 = load i32, ptr %98, align 4, !tbaa !19
  %100 = zext i32 %99 to i64
  %101 = getelementptr inbounds i8, ptr %96, i64 %100
  %102 = load i32, ptr %7, align 4, !tbaa !9
  %103 = zext i32 %102 to i64
  %104 = sub i64 0, %103
  %105 = getelementptr inbounds i8, ptr %101, i64 %104
  store ptr %105, ptr %10, align 8, !tbaa !5
  br label %106

106:                                              ; preds = %92
  %107 = load i32, ptr %7, align 4, !tbaa !9
  %108 = icmp eq i32 %107, 0
  br i1 %108, label %145, label %109

109:                                              ; preds = %106
  %110 = load ptr, ptr %10, align 8, !tbaa !5
  %111 = icmp ne ptr %110, null
  br i1 %111, label %145, label %112

112:                                              ; preds = %109
  br label %113

113:                                              ; preds = %112
  br label %114

114:                                              ; preds = %113
  %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 0
  store ptr @.str.32, ptr %116, align 8, !tbaa !11
  %117 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %118 = getelementptr inbounds %struct.s2n_debug_info, ptr %117, i32 0, i32 0
  %119 = load ptr, ptr %118, align 8, !tbaa !11
  %120 = getelementptr inbounds i8, ptr %119, i64 21
  %121 = call ptr @strrchr(ptr noundef %120, i32 noundef 47) #7
  %122 = icmp ne ptr %121, null
  br i1 %122, label %123, label %130

123:                                              ; preds = %114
  %124 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %125 = getelementptr inbounds %struct.s2n_debug_info, ptr %124, i32 0, i32 0
  %126 = load ptr, ptr %125, align 8, !tbaa !11
  %127 = getelementptr inbounds i8, ptr %126, i64 21
  %128 = call ptr @strrchr(ptr noundef %127, i32 noundef 47) #7
  %129 = getelementptr inbounds i8, ptr %128, i64 1
  br label %135

130:                                              ; preds = %114
  %131 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %132 = getelementptr inbounds %struct.s2n_debug_info, ptr %131, i32 0, i32 0
  %133 = load ptr, ptr %132, align 8, !tbaa !11
  %134 = getelementptr inbounds i8, ptr %133, i64 21
  br label %135

135:                                              ; preds = %130, %123
  %136 = phi ptr [ %129, %123 ], [ %134, %130 ]
  %137 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %138 = getelementptr inbounds %struct.s2n_debug_info, ptr %137, i32 0, i32 1
  store ptr %136, ptr %138, align 8, !tbaa !13
  %139 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %139, align 4, !tbaa !9
  %140 = call i32 @s2n_calculate_stacktrace()
  br label %141

141:                                              ; preds = %135
  br label %142

142:                                              ; preds = %141
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %267

143:                                              ; No predecessors!
  br label %144

144:                                              ; preds = %143
  br label %145

145:                                              ; preds = %144, %109, %106
  br label %146

146:                                              ; preds = %145
  br label %147

147:                                              ; preds = %146
  %148 = load ptr, ptr %10, align 8, !tbaa !5
  %149 = load ptr, ptr %6, align 8, !tbaa !5
  %150 = icmp eq ptr %148, %149
  br i1 %150, label %151, label %177

151:                                              ; preds = %147
  br label %152

152:                                              ; preds = %151
  %153 = load ptr, ptr %5, align 8, !tbaa !5
  %154 = call i32 @s2n_stuffer_validate(ptr noundef %153)
  %155 = getelementptr inbounds %struct.s2n_result, ptr %13, i32 0, i32 0
  store i32 %154, ptr %155, align 4
  %156 = getelementptr inbounds %struct.s2n_result, ptr %13, i32 0, i32 0
  %157 = load i32, ptr %156, align 4
  %158 = call zeroext i1 @s2n_result_is_ok(i32 %157)
  %159 = xor i1 %158, true
  %160 = xor i1 %159, true
  %161 = zext i1 %160 to i32
  %162 = sext i32 %161 to i64
  %163 = call i64 @llvm.expect.i64(i64 %162, i64 1)
  %164 = icmp ne i64 %163, 0
  br i1 %164, label %165, label %167

165:                                              ; preds = %152
  %166 = getelementptr inbounds %struct.s2n_result, ptr %12, i32 0, i32 0
  store i32 0, ptr %166, align 4, !tbaa !14
  br label %169

167:                                              ; preds = %152
  %168 = getelementptr inbounds %struct.s2n_result, ptr %12, i32 0, i32 0
  store i32 -1, ptr %168, align 4, !tbaa !14
  br label %169

169:                                              ; preds = %167, %165
  %170 = getelementptr inbounds %struct.s2n_result, ptr %12, i32 0, i32 0
  %171 = load i32, ptr %170, align 4
  %172 = call zeroext i1 @s2n_result_is_ok(i32 %171)
  br i1 %172, label %174, label %173

173:                                              ; preds = %169
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %267

174:                                              ; preds = %169
  br label %175

175:                                              ; preds = %174
  br label %176

176:                                              ; preds = %175
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %267

177:                                              ; preds = %147
  br label %178

178:                                              ; preds = %177
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %179 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %179, ptr %14, align 4, !tbaa !9
  %180 = load i32, ptr %14, align 4, !tbaa !9
  %181 = icmp ne i32 %180, 0
  %182 = xor i1 %181, true
  %183 = xor i1 %182, true
  %184 = zext i1 %183 to i32
  %185 = sext i32 %184 to i64
  %186 = call i64 @llvm.expect.i64(i64 %185, i64 1)
  %187 = icmp ne i64 %186, 0
  br i1 %187, label %188, label %236

188:                                              ; preds = %178
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %189 = load ptr, ptr %10, align 8, !tbaa !5
  %190 = load ptr, ptr %6, align 8, !tbaa !5
  %191 = load i32, ptr %14, align 4, !tbaa !9
  %192 = zext i32 %191 to i64
  %193 = call ptr @s2n_ensure_memmove_trace(ptr noundef %189, ptr noundef %190, i64 noundef %192)
  store ptr %193, ptr %15, align 8, !tbaa !5
  br label %194

194:                                              ; preds = %188
  %195 = load ptr, ptr %15, align 8, !tbaa !5
  %196 = icmp ne ptr %195, null
  br i1 %196, label %230, label %197

197:                                              ; preds = %194
  br label %198

198:                                              ; preds = %197
  br label %199

199:                                              ; preds = %198
  %200 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %201 = getelementptr inbounds %struct.s2n_debug_info, ptr %200, i32 0, i32 0
  store ptr @.str.33, ptr %201, align 8, !tbaa !11
  %202 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %203 = getelementptr inbounds %struct.s2n_debug_info, ptr %202, i32 0, i32 0
  %204 = load ptr, ptr %203, align 8, !tbaa !11
  %205 = getelementptr inbounds i8, ptr %204, i64 21
  %206 = call ptr @strrchr(ptr noundef %205, i32 noundef 47) #7
  %207 = icmp ne ptr %206, null
  br i1 %207, label %208, label %215

208:                                              ; preds = %199
  %209 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %210 = getelementptr inbounds %struct.s2n_debug_info, ptr %209, i32 0, i32 0
  %211 = load ptr, ptr %210, align 8, !tbaa !11
  %212 = getelementptr inbounds i8, ptr %211, i64 21
  %213 = call ptr @strrchr(ptr noundef %212, i32 noundef 47) #7
  %214 = getelementptr inbounds i8, ptr %213, i64 1
  br label %220

215:                                              ; preds = %199
  %216 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %217 = getelementptr inbounds %struct.s2n_debug_info, ptr %216, i32 0, i32 0
  %218 = load ptr, ptr %217, align 8, !tbaa !11
  %219 = getelementptr inbounds i8, ptr %218, i64 21
  br label %220

220:                                              ; preds = %215, %208
  %221 = phi ptr [ %214, %208 ], [ %219, %215 ]
  %222 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %223 = getelementptr inbounds %struct.s2n_debug_info, ptr %222, i32 0, i32 1
  store ptr %221, ptr %223, align 8, !tbaa !13
  %224 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %224, align 4, !tbaa !9
  %225 = call i32 @s2n_calculate_stacktrace()
  br label %226

226:                                              ; preds = %220
  br label %227

227:                                              ; preds = %226
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %233

228:                                              ; No predecessors!
  br label %229

229:                                              ; preds = %228
  br label %230

230:                                              ; preds = %229, %194
  br label %231

231:                                              ; preds = %230
  br label %232

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

233:                                              ; preds = %232, %227
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  %234 = load i32, ptr %11, align 4
  switch i32 %234, label %237 [
    i32 0, label %235
  ]

235:                                              ; preds = %233
  br label %236

236:                                              ; preds = %235, %178
  store i32 0, ptr %11, align 4
  br label %237

237:                                              ; preds = %236, %233
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  %238 = load i32, ptr %11, align 4
  switch i32 %238, label %267 [
    i32 0, label %239
  ]

239:                                              ; preds = %237
  br label %240

240:                                              ; preds = %239
  br label %241

241:                                              ; preds = %240
  br label %242

242:                                              ; preds = %241
  %243 = load ptr, ptr %5, align 8, !tbaa !5
  %244 = call i32 @s2n_stuffer_validate(ptr noundef %243)
  %245 = getelementptr inbounds %struct.s2n_result, ptr %17, i32 0, i32 0
  store i32 %244, ptr %245, align 4
  %246 = getelementptr inbounds %struct.s2n_result, ptr %17, i32 0, i32 0
  %247 = load i32, ptr %246, align 4
  %248 = call zeroext i1 @s2n_result_is_ok(i32 %247)
  %249 = xor i1 %248, true
  %250 = xor i1 %249, true
  %251 = zext i1 %250 to i32
  %252 = sext i32 %251 to i64
  %253 = call i64 @llvm.expect.i64(i64 %252, i64 1)
  %254 = icmp ne i64 %253, 0
  br i1 %254, label %255, label %257

255:                                              ; preds = %242
  %256 = getelementptr inbounds %struct.s2n_result, ptr %16, i32 0, i32 0
  store i32 0, ptr %256, align 4, !tbaa !14
  br label %259

257:                                              ; preds = %242
  %258 = getelementptr inbounds %struct.s2n_result, ptr %16, i32 0, i32 0
  store i32 -1, ptr %258, align 4, !tbaa !14
  br label %259

259:                                              ; preds = %257, %255
  %260 = getelementptr inbounds %struct.s2n_result, ptr %16, i32 0, i32 0
  %261 = load i32, ptr %260, align 4
  %262 = call zeroext i1 @s2n_result_is_ok(i32 %261)
  br i1 %262, label %264, label %263

263:                                              ; preds = %259
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %267

264:                                              ; preds = %259
  br label %265

265:                                              ; preds = %264
  br label %266

266:                                              ; preds = %265
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %267

267:                                              ; preds = %266, %263, %237, %176, %173, %142
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  br label %268

268:                                              ; preds = %267, %90, %82, %57, %20
  %269 = load i32, ptr %4, align 4
  ret i32 %269
}

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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{!15, !10, i64 0}
!15 = !{!"", !10, i64 0}
!16 = !{!17, !6, i64 0}
!17 = !{!"s2n_stuffer", !18, i64 0, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 36, !10, i64 36}
!18 = !{!"s2n_blob", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!19 = !{!17, !10, i64 28}


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

%struct.s2n_debug_info = type { ptr, ptr }

@_s2n_debug_info = external thread_local local_unnamed_addr global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local local_unnamed_addr global i32, align 4
@.str.31 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.33 = 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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_stuffer_write_bytes(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq i32 %2, 0
  br i1 %4, label %47, label %5

5:                                                ; preds = %3
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %6, label %14

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

14:                                               ; preds = %5
  %15 = tail call i32 @s2n_stuffer_validate(ptr noundef %0)
  %16 = tail call zeroext i1 @s2n_result_is_ok(i32 %15)
  %not. = xor i1 %16, true
  %. = sext i1 %not. to i32
  %17 = tail call zeroext i1 @s2n_result_is_ok(i32 %.)
  br i1 %17, label %18, label %47

18:                                               ; preds = %14
  %19 = tail call i32 @s2n_stuffer_skip_write(ptr noundef %0, i32 noundef %2)
  %20 = icmp sgt i32 %19, -1
  br i1 %20, label %21, label %47

21:                                               ; preds = %18
  %22 = load ptr, ptr %0, align 8, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %0, i64 28
  %24 = load i32, ptr %23, align 4, !tbaa !16
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %22, i64 %25
  %27 = zext i32 %2 to i64
  %28 = sub nsw i64 0, %27
  %29 = getelementptr inbounds i8, ptr %26, i64 %28
  %30 = icmp eq ptr %29, %1
  br i1 %30, label %31, label %35

31:                                               ; preds = %21
  %32 = tail call i32 @s2n_stuffer_validate(ptr noundef nonnull %0)
  %33 = tail call zeroext i1 @s2n_result_is_ok(i32 %32)
  %not.48 = xor i1 %33, true
  %.42 = sext i1 %not.48 to i32
  %34 = tail call zeroext i1 @s2n_result_is_ok(i32 %.42)
  %not.49 = xor i1 %34, true
  %spec.select = sext i1 %not.49 to i32
  br label %47

35:                                               ; preds = %21
  %36 = tail call ptr @s2n_ensure_memmove_trace(ptr noundef nonnull %29, ptr noundef nonnull %1, i64 noundef %27) #6
  %.not40.not.not = icmp eq ptr %36, null
  br i1 %.not40.not.not, label %.critedge, label %.critedge44

.critedge:                                        ; preds = %35
  %37 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.33, ptr %37, align 8, !tbaa !5
  %38 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.33, i64 21), i32 noundef 47) #5
  %.not41 = icmp eq ptr %38, null
  %39 = getelementptr inbounds i8, ptr %38, i64 1
  %40 = select i1 %.not41, ptr getelementptr inbounds (i8, ptr @.str.33, i64 21), ptr %39
  %41 = getelementptr inbounds i8, ptr %37, i64 8
  store ptr %40, ptr %41, align 8, !tbaa !10
  %42 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %42, align 4, !tbaa !11
  %43 = tail call i32 @s2n_calculate_stacktrace() #6
  br label %47

.critedge44:                                      ; preds = %35
  %44 = tail call i32 @s2n_stuffer_validate(ptr noundef nonnull %0)
  %45 = tail call zeroext i1 @s2n_result_is_ok(i32 %44)
  %not.46 = xor i1 %45, true
  %.43 = sext i1 %not.46 to i32
  %46 = tail call zeroext i1 @s2n_result_is_ok(i32 %.43)
  %not.47 = xor i1 %46, true
  %spec.select45 = sext i1 %not.47 to i32
  br label %47

47:                                               ; preds = %.critedge44, %.critedge, %31, %18, %14, %3, %6
  %.4 = phi i32 [ -1, %6 ], [ 0, %3 ], [ -1, %14 ], [ -1, %18 ], [ -1, %.critedge ], [ %spec.select, %31 ], [ %spec.select45, %.critedge44 ]
  ret i32 %.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 = { 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 = { 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, !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_stuffer", !15, i64 0, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 36, !12, i64 36}
!15 = !{!"s2n_blob", !7, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!16 = !{!14, !12, i64 28}


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