; LLVM IR from aws/s2n-tls :: tests/testlib (s2n_ktls_test_utils)

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

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

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

18:                                               ; preds = %2
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %52, label %21

21:                                               ; preds = %18
  br label %22

22:                                               ; preds = %21
  br label %23

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

32:                                               ; preds = %23
  %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) #9
  %38 = getelementptr inbounds i8, ptr %37, i64 1
  br label %44

39:                                               ; preds = %23
  %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
  br label %44

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

50:                                               ; preds = %44
  store i64 -1, ptr %3, align 8
  br label %268

51:                                               ; No predecessors!
  br label %52

52:                                               ; preds = %51, %18
  br label %53

53:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #10
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %54, ptr %6, align 8, !tbaa !5
  br label %55

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

58:                                               ; preds = %55
  br label %59

59:                                               ; preds = %58
  br label %60

60:                                               ; preds = %59
  %61 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %62 = getelementptr inbounds %struct.s2n_debug_info, ptr %61, i32 0, i32 0
  store ptr @.str.1, ptr %62, align 8, !tbaa !11
  %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 !11
  %66 = getelementptr inbounds i8, ptr %65, i64 21
  %67 = call ptr @strrchr(ptr noundef %66, i32 noundef 47) #9
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %76

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

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

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

87:                                               ; preds = %81
  br label %88

88:                                               ; preds = %87
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %267

89:                                               ; No predecessors!
  br label %90

90:                                               ; preds = %89
  br label %91

91:                                               ; preds = %90, %55
  br label %92

92:                                               ; preds = %91
  br label %93

93:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #10
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.s2n_test_ktls_io_stuffer, ptr %94, i32 0, i32 1
  store ptr %95, ptr %8, align 8, !tbaa !5
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.s2n_test_ktls_io_stuffer, ptr %96, i32 0, i32 2
  %98 = load i64, ptr %97, align 8, !tbaa !14
  %99 = add i64 %98, 1
  store i64 %99, ptr %97, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #10
  store i8 0, ptr %9, align 1, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 56, ptr %10) #10
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %100, i64 56, i1 false), !tbaa.struct !20
  br label %101

101:                                              ; preds = %93
  %102 = call i32 @s2n_ktls_get_control_data(ptr noundef %10, i32 noundef 0, ptr noundef %9)
  %103 = getelementptr inbounds %struct.s2n_result, ptr %11, i32 0, i32 0
  store i32 %102, ptr %103, align 4
  %104 = getelementptr inbounds %struct.s2n_result, ptr %11, i32 0, i32 0
  %105 = load i32, ptr %104, align 4
  %106 = call zeroext i1 @s2n_result_is_ok(i32 %105)
  br i1 %106, label %108, label %107

107:                                              ; preds = %101
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %266

108:                                              ; preds = %101
  br label %109

109:                                              ; preds = %108
  br label %110

110:                                              ; preds = %109
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #10
  store i64 0, ptr %12, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #10
  store i64 0, ptr %13, align 8, !tbaa !21
  br label %111

111:                                              ; preds = %233, %110
  %112 = load i64, ptr %13, align 8, !tbaa !21
  %113 = load ptr, ptr %5, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.msghdr, ptr %113, i32 0, i32 3
  %115 = load i64, ptr %114, align 8, !tbaa !22
  %116 = icmp ult i64 %112, %115
  br i1 %116, label %118, label %117

117:                                              ; preds = %111
  store i32 16, ptr %7, align 4
  br label %236

118:                                              ; preds = %111
  br label %119

119:                                              ; preds = %118
  %120 = load ptr, ptr %5, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.msghdr, ptr %120, i32 0, i32 2
  %122 = load ptr, ptr %121, align 8, !tbaa !24
  %123 = icmp ne ptr %122, null
  br i1 %123, label %157, label %124

124:                                              ; preds = %119
  br label %125

125:                                              ; preds = %124
  br label %126

126:                                              ; preds = %125
  %127 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %128 = getelementptr inbounds %struct.s2n_debug_info, ptr %127, i32 0, i32 0
  store ptr @.str.2, ptr %128, align 8, !tbaa !11
  %129 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %130 = getelementptr inbounds %struct.s2n_debug_info, ptr %129, i32 0, i32 0
  %131 = load ptr, ptr %130, align 8, !tbaa !11
  %132 = getelementptr inbounds i8, ptr %131, i64 21
  %133 = call ptr @strrchr(ptr noundef %132, i32 noundef 47) #9
  %134 = icmp ne ptr %133, null
  br i1 %134, label %135, label %142

135:                                              ; preds = %126
  %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
  %138 = load ptr, ptr %137, align 8, !tbaa !11
  %139 = getelementptr inbounds i8, ptr %138, i64 21
  %140 = call ptr @strrchr(ptr noundef %139, i32 noundef 47) #9
  %141 = getelementptr inbounds i8, ptr %140, i64 1
  br label %147

142:                                              ; preds = %126
  %143 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %144 = getelementptr inbounds %struct.s2n_debug_info, ptr %143, i32 0, i32 0
  %145 = load ptr, ptr %144, align 8, !tbaa !11
  %146 = getelementptr inbounds i8, ptr %145, i64 21
  br label %147

147:                                              ; preds = %142, %135
  %148 = phi ptr [ %141, %135 ], [ %146, %142 ]
  %149 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %150 = getelementptr inbounds %struct.s2n_debug_info, ptr %149, i32 0, i32 1
  store ptr %148, ptr %150, align 8, !tbaa !13
  %151 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %151, align 4, !tbaa !9
  %152 = call i32 @s2n_calculate_stacktrace()
  br label %153

153:                                              ; preds = %147
  br label %154

154:                                              ; preds = %153
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %236

155:                                              ; No predecessors!
  br label %156

156:                                              ; preds = %155
  br label %157

157:                                              ; preds = %156, %119
  br label %158

158:                                              ; preds = %157
  br label %159

159:                                              ; preds = %158
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #10
  %160 = load ptr, ptr %5, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.msghdr, ptr %160, i32 0, i32 2
  %162 = load ptr, ptr %161, align 8, !tbaa !24
  %163 = load i64, ptr %13, align 8, !tbaa !21
  %164 = getelementptr inbounds %struct.iovec, ptr %162, i64 %163
  %165 = getelementptr inbounds %struct.iovec, ptr %164, i32 0, i32 0
  %166 = load ptr, ptr %165, align 8, !tbaa !25
  store ptr %166, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #10
  %167 = load ptr, ptr %5, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.msghdr, ptr %167, i32 0, i32 2
  %169 = load ptr, ptr %168, align 8, !tbaa !24
  %170 = load i64, ptr %13, align 8, !tbaa !21
  %171 = getelementptr inbounds %struct.iovec, ptr %169, i64 %170
  %172 = getelementptr inbounds %struct.iovec, ptr %171, i32 0, i32 1
  %173 = load i64, ptr %172, align 8, !tbaa !27
  store i64 %173, ptr %15, align 8, !tbaa !21
  %174 = load ptr, ptr %8, align 8, !tbaa !5
  %175 = load ptr, ptr %14, align 8, !tbaa !5
  %176 = load i64, ptr %15, align 8, !tbaa !21
  %177 = trunc i64 %176 to i32
  %178 = call i32 @s2n_stuffer_write_bytes(ptr noundef %174, ptr noundef %175, i32 noundef %177)
  %179 = icmp ne i32 %178, 0
  br i1 %179, label %180, label %226

180:                                              ; preds = %159
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #10
  %181 = load i64, ptr %15, align 8, !tbaa !21
  %182 = load ptr, ptr %8, align 8, !tbaa !5
  %183 = getelementptr inbounds %struct.s2n_stuffer, ptr %182, i32 0, i32 0
  %184 = getelementptr inbounds %struct.s2n_blob, ptr %183, i32 0, i32 1
  %185 = load i32, ptr %184, align 8, !tbaa !28
  %186 = load ptr, ptr %8, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.s2n_stuffer, ptr %186, i32 0, i32 2
  %188 = load i32, ptr %187, align 4, !tbaa !29
  %189 = sub i32 %185, %188
  %190 = zext i32 %189 to i64
  %191 = icmp ult i64 %181, %190
  br i1 %191, label %192, label %194

192:                                              ; preds = %180
  %193 = load i64, ptr %15, align 8, !tbaa !21
  br label %204

194:                                              ; preds = %180
  %195 = load ptr, ptr %8, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.s2n_stuffer, ptr %195, i32 0, i32 0
  %197 = getelementptr inbounds %struct.s2n_blob, ptr %196, i32 0, i32 1
  %198 = load i32, ptr %197, align 8, !tbaa !28
  %199 = load ptr, ptr %8, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.s2n_stuffer, ptr %199, i32 0, i32 2
  %201 = load i32, ptr %200, align 4, !tbaa !29
  %202 = sub i32 %198, %201
  %203 = zext i32 %202 to i64
  br label %204

204:                                              ; preds = %194, %192
  %205 = phi i64 [ %193, %192 ], [ %203, %194 ]
  store i64 %205, ptr %16, align 8, !tbaa !21
  br label %206

206:                                              ; preds = %204
  %207 = load ptr, ptr %8, align 8, !tbaa !5
  %208 = load ptr, ptr %14, align 8, !tbaa !5
  %209 = load i64, ptr %16, align 8, !tbaa !21
  %210 = trunc i64 %209 to i32
  %211 = call i32 @s2n_stuffer_write_bytes(ptr noundef %207, ptr noundef %208, i32 noundef %210)
  %212 = icmp sgt i32 %211, -1
  br i1 %212, label %214, label %213

213:                                              ; preds = %206
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %225

214:                                              ; preds = %206
  br label %215

215:                                              ; preds = %214
  br label %216

216:                                              ; preds = %215
  %217 = load i64, ptr %16, align 8, !tbaa !21
  %218 = load i64, ptr %12, align 8, !tbaa !21
  %219 = add i64 %218, %217
  store i64 %219, ptr %12, align 8, !tbaa !21
  %220 = load i64, ptr %12, align 8, !tbaa !21
  %221 = icmp ne i64 %220, 0
  br i1 %221, label %222, label %223

222:                                              ; preds = %216
  store i32 16, ptr %7, align 4
  br label %225

223:                                              ; preds = %216
  %224 = call ptr @__errno_location() #8
  store i32 11, ptr %224, align 4, !tbaa !9
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %225

225:                                              ; preds = %223, %222, %213
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #10
  br label %230

226:                                              ; preds = %159
  %227 = load i64, ptr %15, align 8, !tbaa !21
  %228 = load i64, ptr %12, align 8, !tbaa !21
  %229 = add i64 %228, %227
  store i64 %229, ptr %12, align 8, !tbaa !21
  store i32 0, ptr %7, align 4
  br label %230

230:                                              ; preds = %226, %225
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #10
  %231 = load i32, ptr %7, align 4
  switch i32 %231, label %236 [
    i32 0, label %232
  ]

232:                                              ; preds = %230
  br label %233

233:                                              ; preds = %232
  %234 = load i64, ptr %13, align 8, !tbaa !21
  %235 = add i64 %234, 1
  store i64 %235, ptr %13, align 8, !tbaa !21
  br label %111, !llvm.loop !30

236:                                              ; preds = %230, %154, %117
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #10
  %237 = load i32, ptr %7, align 4
  switch i32 %237, label %265 [
    i32 16, label %238
  ]

238:                                              ; preds = %236
  %239 = load i64, ptr %12, align 8, !tbaa !21
  %240 = icmp ne i64 %239, 0
  br i1 %240, label %241, label %263

241:                                              ; preds = %238
  br label %242

242:                                              ; preds = %241
  %243 = load ptr, ptr %6, align 8, !tbaa !5
  %244 = getelementptr inbounds %struct.s2n_test_ktls_io_stuffer, ptr %243, i32 0, i32 0
  %245 = load i8, ptr %9, align 1, !tbaa !19
  %246 = call i32 @s2n_stuffer_write_uint8(ptr noundef %244, i8 noundef zeroext %245)
  %247 = icmp sgt i32 %246, -1
  br i1 %247, label %249, label %248

248:                                              ; preds = %242
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %265

249:                                              ; preds = %242
  br label %250

250:                                              ; preds = %249
  br label %251

251:                                              ; preds = %250
  br label %252

252:                                              ; preds = %251
  %253 = load ptr, ptr %6, align 8, !tbaa !5
  %254 = getelementptr inbounds %struct.s2n_test_ktls_io_stuffer, ptr %253, i32 0, i32 0
  %255 = load i64, ptr %12, align 8, !tbaa !21
  %256 = trunc i64 %255 to i16
  %257 = call i32 @s2n_stuffer_write_uint16(ptr noundef %254, i16 noundef zeroext %256)
  %258 = icmp sgt i32 %257, -1
  br i1 %258, label %260, label %259

259:                                              ; preds = %252
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %265

260:                                              ; preds = %252
  br label %261

261:                                              ; preds = %260
  br label %262

262:                                              ; preds = %261
  br label %263

263:                                              ; preds = %262, %238
  %264 = load i64, ptr %12, align 8, !tbaa !21
  store i64 %264, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %265

265:                                              ; preds = %263, %259, %248, %236
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #10
  br label %266

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

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

268:                                              ; preds = %267, %50
  %269 = load i64, ptr %3, align 8
  ret i64 %269
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #1

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

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

declare i32 @s2n_calculate_stacktrace() #4

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

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

declare i32 @s2n_ktls_get_control_data(ptr noundef, i32 noundef, ptr noundef) #4

declare i32 @s2n_stuffer_write_bytes(ptr noundef, ptr noundef, i32 noundef) #4

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

declare i32 @s2n_stuffer_write_uint8(ptr noundef, i8 noundef zeroext) #4

declare i32 @s2n_stuffer_write_uint16(ptr noundef, i16 noundef zeroext) #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 = { nounwind willreturn memory(none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { "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(argmem: readwrite) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 #8 = { nounwind willreturn memory(none) }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { 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, !18, i64 80}
!15 = !{!"s2n_test_ktls_io_stuffer", !16, i64 0, !16, i64 40, !18, i64 80, !18, i64 88}
!16 = !{!"s2n_stuffer", !17, i64 0, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 36, !10, i64 36}
!17 = !{!"s2n_blob", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!18 = !{!"long", !7, i64 0}
!19 = !{!7, !7, i64 0}
!20 = !{i64 0, i64 8, !5, i64 8, i64 4, !9, i64 16, i64 8, !5, i64 24, i64 8, !21, i64 32, i64 8, !5, i64 40, i64 8, !21, i64 48, i64 4, !9}
!21 = !{!18, !18, i64 0}
!22 = !{!23, !18, i64 24}
!23 = !{!"msghdr", !6, i64 0, !10, i64 8, !6, i64 16, !18, i64 24, !6, i64 32, !18, i64 40, !10, i64 48}
!24 = !{!23, !6, i64 16}
!25 = !{!26, !6, i64 0}
!26 = !{!"iovec", !6, i64 0, !18, i64 8}
!27 = !{!26, !18, i64 8}
!28 = !{!16, !10, i64 8}
!29 = !{!16, !10, i64 28}
!30 = distinct !{!30, !31}
!31 = !{!"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.msghdr = type { ptr, i32, ptr, i64, ptr, i64, i32 }
%struct.iovec = type { ptr, i64 }

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

; Function Attrs: nounwind uwtable
define dso_local i64 @s2n_test_ktls_sendmsg_io_stuffer(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca i8, align 1
  %4 = alloca %struct.msghdr, align 8
  %5 = tail call ptr @__errno_location() #9
  store i32 22, ptr %5, align 4, !tbaa !5
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %6, label %14

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

14:                                               ; preds = %2
  %.not58 = icmp eq ptr %0, null
  br i1 %.not58, label %15, label %23

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

23:                                               ; preds = %14
  %24 = getelementptr inbounds i8, ptr %0, i64 40
  %25 = getelementptr inbounds i8, ptr %0, i64 80
  %26 = load i64, ptr %25, align 8, !tbaa !13
  %27 = add i64 %26, 1
  store i64 %27, ptr %25, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #11
  store i8 0, ptr %3, align 1, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %4) #11
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %4, ptr noundef nonnull align 8 dereferenceable(56) %1, i64 56, i1 false), !tbaa.struct !19
  %28 = call i32 @s2n_ktls_get_control_data(ptr noundef nonnull %4, i32 noundef 0, ptr noundef nonnull %3) #11
  %29 = call zeroext i1 @s2n_result_is_ok(i32 %28)
  br i1 %29, label %.preheader, label %.thread78

.preheader:                                       ; preds = %23
  %30 = getelementptr inbounds i8, ptr %1, i64 24
  %31 = load i64, ptr %30, align 8, !tbaa !22
  %.not92 = icmp eq i64 %31, 0
  br i1 %.not92, label %.thread78, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %32 = getelementptr inbounds i8, ptr %1, i64 16
  br label %33

33:                                               ; preds = %.lr.ph, %62
  %.04291 = phi i64 [ 0, %.lr.ph ], [ %63, %62 ]
  %.04690 = phi i64 [ 0, %.lr.ph ], [ %64, %62 ]
  %34 = load ptr, ptr %32, align 8, !tbaa !24
  %.not60 = icmp eq ptr %34, null
  br i1 %.not60, label %.thread73, label %42

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

42:                                               ; preds = %33
  %43 = getelementptr inbounds %struct.iovec, ptr %34, i64 %.04690
  %44 = load ptr, ptr %43, align 8, !tbaa !25
  %45 = getelementptr inbounds i8, ptr %43, i64 8
  %46 = load i64, ptr %45, align 8, !tbaa !27
  %47 = trunc i64 %46 to i32
  %48 = call i32 @s2n_stuffer_write_bytes(ptr noundef nonnull %24, ptr noundef %44, i32 noundef %47) #11
  %.not62 = icmp eq i32 %48, 0
  br i1 %.not62, label %62, label %49

49:                                               ; preds = %42
  %50 = getelementptr inbounds i8, ptr %0, i64 48
  %51 = load i32, ptr %50, align 8, !tbaa !28
  %52 = getelementptr inbounds i8, ptr %0, i64 68
  %53 = load i32, ptr %52, align 4, !tbaa !29
  %54 = sub i32 %51, %53
  %55 = zext i32 %54 to i64
  %. = call i64 @llvm.umin.i64(i64 %46, i64 %55)
  %56 = trunc nuw i64 %. to i32
  %57 = call i32 @s2n_stuffer_write_bytes(ptr noundef nonnull %24, ptr noundef %44, i32 noundef %56) #11
  %58 = icmp sgt i32 %57, -1
  br i1 %58, label %59, label %.thread78

59:                                               ; preds = %49
  %60 = add i64 %., %.04291
  %.not63 = icmp eq i64 %60, 0
  br i1 %.not63, label %61, label %.thread82

61:                                               ; preds = %59
  store i32 11, ptr %5, align 4, !tbaa !5
  br label %.thread78

62:                                               ; preds = %42
  %63 = add i64 %46, %.04291
  %64 = add nuw i64 %.04690, 1
  %65 = load i64, ptr %30, align 8, !tbaa !22
  %66 = icmp ult i64 %64, %65
  br i1 %66, label %33, label %._crit_edge, !llvm.loop !30

._crit_edge:                                      ; preds = %62
  %.not64 = icmp eq i64 %63, 0
  br i1 %.not64, label %.thread78, label %.thread82

.thread82:                                        ; preds = %59, %._crit_edge
  %.3457285 = phi i64 [ %63, %._crit_edge ], [ %60, %59 ]
  %67 = load i8, ptr %3, align 1, !tbaa !18
  %68 = call i32 @s2n_stuffer_write_uint8(ptr noundef nonnull %0, i8 noundef zeroext %67) #11
  %69 = icmp sgt i32 %68, -1
  br i1 %69, label %70, label %.thread78

70:                                               ; preds = %.thread82
  %71 = trunc i64 %.3457285 to i16
  %72 = call i32 @s2n_stuffer_write_uint16(ptr noundef nonnull %0, i16 noundef zeroext %71) #11
  %73 = icmp sgt i32 %72, -1
  %spec.select = select i1 %73, i64 %.3457285, i64 -1
  br label %.thread78

.thread78:                                        ; preds = %.preheader, %70, %61, %49, %._crit_edge, %.thread73, %.thread82, %23
  %.5 = phi i64 [ -1, %23 ], [ -1, %.thread82 ], [ -1, %.thread73 ], [ 0, %._crit_edge ], [ -1, %49 ], [ -1, %61 ], [ %spec.select, %70 ], [ 0, %.preheader ]
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %4) #11
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #11
  br label %74

74:                                               ; preds = %15, %.thread78, %6
  %.7 = phi i64 [ -1, %6 ], [ %.5, %.thread78 ], [ -1, %15 ]
  ret i64 %.7
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #1

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

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

declare i32 @s2n_calculate_stacktrace() local_unnamed_addr #4

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

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

declare i32 @s2n_ktls_get_control_data(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

declare i32 @s2n_stuffer_write_bytes(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

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

declare i32 @s2n_stuffer_write_uint8(ptr noundef, i8 noundef zeroext) local_unnamed_addr #4

declare i32 @s2n_stuffer_write_uint16(ptr noundef, i16 noundef zeroext) local_unnamed_addr #4

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

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 nofree nosync nounwind willreturn memory(none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 #8 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #9 = { nounwind willreturn memory(none) }
attributes #10 = { nounwind willreturn memory(read) }
attributes #11 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"s2n_debug_info", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!14, !17, i64 80}
!14 = !{!"s2n_test_ktls_io_stuffer", !15, i64 0, !15, i64 40, !17, i64 80, !17, i64 88}
!15 = !{!"s2n_stuffer", !16, i64 0, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 36, !6, i64 36}
!16 = !{!"s2n_blob", !11, i64 0, !6, i64 8, !6, i64 12, !6, i64 16}
!17 = !{!"long", !7, i64 0}
!18 = !{!7, !7, i64 0}
!19 = !{i64 0, i64 8, !20, i64 8, i64 4, !5, i64 16, i64 8, !20, i64 24, i64 8, !21, i64 32, i64 8, !20, i64 40, i64 8, !21, i64 48, i64 4, !5}
!20 = !{!11, !11, i64 0}
!21 = !{!17, !17, i64 0}
!22 = !{!23, !17, i64 24}
!23 = !{!"msghdr", !11, i64 0, !6, i64 8, !11, i64 16, !17, i64 24, !11, i64 32, !17, i64 40, !6, i64 48}
!24 = !{!23, !11, i64 16}
!25 = !{!26, !11, i64 0}
!26 = !{!"iovec", !11, i64 0, !17, i64 8}
!27 = !{!26, !17, i64 8}
!28 = !{!15, !6, i64 8}
!29 = !{!15, !6, i64 28}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


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