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

; 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.2 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [85 x i8], align 1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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: nounwind uwtable
define dso_local i32 @s2n_sendv_with_offset_total_size(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3) #4 {
  %5 = alloca %struct.s2n_result, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %4
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %50, label %18

18:                                               ; preds = %15
  br label %19

19:                                               ; preds = %18
  br label %20

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

29:                                               ; preds = %20
  %30 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %31 = getelementptr inbounds %struct.s2n_debug_info, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = getelementptr inbounds i8, ptr %32, i64 21
  %34 = call ptr @strrchr(ptr noundef %33, i32 noundef 47) #5
  %35 = getelementptr inbounds i8, ptr %34, i64 1
  br label %41

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

41:                                               ; preds = %36, %29
  %42 = phi ptr [ %35, %29 ], [ %40, %36 ]
  %43 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %44 = getelementptr inbounds %struct.s2n_debug_info, ptr %43, i32 0, i32 1
  store ptr %42, ptr %44, align 8, !tbaa !13
  %45 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %45, align 4, !tbaa !14
  %46 = call i32 @s2n_calculate_stacktrace()
  br label %47

47:                                               ; preds = %41
  %48 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  store i32 -1, ptr %48, align 4, !tbaa !16
  br label %264

49:                                               ; No predecessors!
  br label %50

50:                                               ; preds = %49, %15
  br label %51

51:                                               ; preds = %50
  %52 = load i64, ptr %7, align 8, !tbaa !9
  %53 = icmp sgt i64 %52, 0
  br i1 %53, label %54, label %92

54:                                               ; preds = %51
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = icmp ne ptr %56, null
  br i1 %57, label %90, 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.3, 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) #5
  %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) #5
  %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 !14
  %86 = call i32 @s2n_calculate_stacktrace()
  br label %87

87:                                               ; preds = %81
  %88 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  store i32 -1, ptr %88, align 4, !tbaa !16
  br label %264

89:                                               ; No predecessors!
  br label %90

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

91:                                               ; preds = %90
  br label %92

92:                                               ; preds = %91, %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store i64 0, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %93

93:                                               ; preds = %174, %92
  %94 = load i64, ptr %11, align 8, !tbaa !9
  %95 = load i64, ptr %7, align 8, !tbaa !9
  %96 = icmp slt i64 %94, %95
  br i1 %96, label %98, label %97

97:                                               ; preds = %93
  store i32 14, ptr %12, align 4
  br label %177

98:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = load i64, ptr %11, align 8, !tbaa !9
  %101 = getelementptr inbounds %struct.iovec, ptr %99, i64 %100
  %102 = getelementptr inbounds %struct.iovec, ptr %101, i32 0, i32 1
  %103 = load i64, ptr %102, align 8, !tbaa !18
  store i64 %103, ptr %13, align 8, !tbaa !9
  %104 = load i64, ptr %8, align 8, !tbaa !9
  %105 = icmp sgt i64 %104, 0
  br i1 %105, label %106, label %122

106:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %107 = load i64, ptr %8, align 8, !tbaa !9
  %108 = load i64, ptr %13, align 8, !tbaa !9
  %109 = icmp ult i64 %107, %108
  br i1 %109, label %110, label %112

110:                                              ; preds = %106
  %111 = load i64, ptr %8, align 8, !tbaa !9
  br label %114

112:                                              ; preds = %106
  %113 = load i64, ptr %13, align 8, !tbaa !9
  br label %114

114:                                              ; preds = %112, %110
  %115 = phi i64 [ %111, %110 ], [ %113, %112 ]
  store i64 %115, ptr %14, align 8, !tbaa !9
  %116 = load i64, ptr %14, align 8, !tbaa !9
  %117 = load i64, ptr %13, align 8, !tbaa !9
  %118 = sub i64 %117, %116
  store i64 %118, ptr %13, align 8, !tbaa !9
  %119 = load i64, ptr %14, align 8, !tbaa !9
  %120 = load i64, ptr %8, align 8, !tbaa !9
  %121 = sub i64 %120, %119
  store i64 %121, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %122

122:                                              ; preds = %114, %98
  br label %123

123:                                              ; preds = %122
  %124 = load i64, ptr %10, align 8, !tbaa !9
  %125 = icmp uge i64 -1, %124
  br i1 %125, label %126, label %131

126:                                              ; preds = %123
  %127 = load i64, ptr %10, align 8, !tbaa !9
  %128 = sub i64 -1, %127
  %129 = load i64, ptr %13, align 8, !tbaa !9
  %130 = icmp uge i64 %128, %129
  br i1 %130, label %165, label %131

131:                                              ; preds = %126, %123
  br label %132

132:                                              ; preds = %131
  br label %133

133:                                              ; preds = %132
  %134 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %135 = getelementptr inbounds %struct.s2n_debug_info, ptr %134, i32 0, i32 0
  store ptr @.str.4, ptr %135, align 8, !tbaa !11
  %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) #5
  %141 = icmp ne ptr %140, null
  br i1 %141, label %142, label %149

142:                                              ; preds = %133
  %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
  %147 = call ptr @strrchr(ptr noundef %146, i32 noundef 47) #5
  %148 = getelementptr inbounds i8, ptr %147, i64 1
  br label %154

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

154:                                              ; preds = %149, %142
  %155 = phi ptr [ %148, %142 ], [ %153, %149 ]
  %156 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %157 = getelementptr inbounds %struct.s2n_debug_info, ptr %156, i32 0, i32 1
  store ptr %155, ptr %157, align 8, !tbaa !13
  %158 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 469762089, ptr %158, align 4, !tbaa !14
  %159 = call i32 @s2n_calculate_stacktrace()
  br label %160

160:                                              ; preds = %154
  br label %161

161:                                              ; preds = %160
  %162 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  store i32 -1, ptr %162, align 4, !tbaa !16
  store i32 1, ptr %12, align 4
  br label %171

163:                                              ; No predecessors!
  br label %164

164:                                              ; preds = %163
  br label %165

165:                                              ; preds = %164, %126
  br label %166

166:                                              ; preds = %165
  br label %167

167:                                              ; preds = %166
  %168 = load i64, ptr %13, align 8, !tbaa !9
  %169 = load i64, ptr %10, align 8, !tbaa !9
  %170 = add i64 %169, %168
  store i64 %170, ptr %10, align 8, !tbaa !9
  store i32 0, ptr %12, align 4
  br label %171

171:                                              ; preds = %167, %161
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  %172 = load i32, ptr %12, align 4
  switch i32 %172, label %177 [
    i32 0, label %173
  ]

173:                                              ; preds = %171
  br label %174

174:                                              ; preds = %173
  %175 = load i64, ptr %11, align 8, !tbaa !9
  %176 = add nsw i64 %175, 1
  store i64 %176, ptr %11, align 8, !tbaa !9
  br label %93, !llvm.loop !20

177:                                              ; preds = %171, %97
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  %178 = load i32, ptr %12, align 4
  switch i32 %178, label %263 [
    i32 14, label %179
  ]

179:                                              ; preds = %177
  br label %180

180:                                              ; preds = %179
  %181 = load i64, ptr %8, align 8, !tbaa !9
  %182 = icmp eq i64 %181, 0
  br i1 %182, label %217, label %183

183:                                              ; preds = %180
  br label %184

184:                                              ; preds = %183
  br label %185

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

194:                                              ; preds = %185
  %195 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %196 = getelementptr inbounds %struct.s2n_debug_info, ptr %195, i32 0, i32 0
  %197 = load ptr, ptr %196, align 8, !tbaa !11
  %198 = getelementptr inbounds i8, ptr %197, i64 21
  %199 = call ptr @strrchr(ptr noundef %198, i32 noundef 47) #5
  %200 = getelementptr inbounds i8, ptr %199, i64 1
  br label %206

201:                                              ; preds = %185
  %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
  br label %206

206:                                              ; preds = %201, %194
  %207 = phi ptr [ %200, %194 ], [ %205, %201 ]
  %208 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %209 = getelementptr inbounds %struct.s2n_debug_info, ptr %208, i32 0, i32 1
  store ptr %207, ptr %209, align 8, !tbaa !13
  %210 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 469762089, ptr %210, align 4, !tbaa !14
  %211 = call i32 @s2n_calculate_stacktrace()
  br label %212

212:                                              ; preds = %206
  br label %213

213:                                              ; preds = %212
  %214 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  store i32 -1, ptr %214, align 4, !tbaa !16
  store i32 1, ptr %12, align 4
  br label %263

215:                                              ; No predecessors!
  br label %216

216:                                              ; preds = %215
  br label %217

217:                                              ; preds = %216, %180
  br label %218

218:                                              ; preds = %217
  br label %219

219:                                              ; preds = %218
  br label %220

220:                                              ; preds = %219
  %221 = load i64, ptr %10, align 8, !tbaa !9
  %222 = icmp ule i64 %221, 9223372036854775807
  br i1 %222, label %257, label %223

223:                                              ; preds = %220
  br label %224

224:                                              ; preds = %223
  br label %225

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

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

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

246:                                              ; preds = %241, %234
  %247 = phi ptr [ %240, %234 ], [ %245, %241 ]
  %248 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %249 = getelementptr inbounds %struct.s2n_debug_info, ptr %248, i32 0, i32 1
  store ptr %247, ptr %249, align 8, !tbaa !13
  %250 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 469762089, ptr %250, align 4, !tbaa !14
  %251 = call i32 @s2n_calculate_stacktrace()
  br label %252

252:                                              ; preds = %246
  br label %253

253:                                              ; preds = %252
  %254 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  store i32 -1, ptr %254, align 4, !tbaa !16
  store i32 1, ptr %12, align 4
  br label %263

255:                                              ; No predecessors!
  br label %256

256:                                              ; preds = %255
  br label %257

257:                                              ; preds = %256, %220
  br label %258

258:                                              ; preds = %257
  br label %259

259:                                              ; preds = %258
  %260 = load i64, ptr %10, align 8, !tbaa !9
  %261 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %260, ptr %261, align 8, !tbaa !9
  %262 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  store i32 0, ptr %262, align 4, !tbaa !16
  store i32 1, ptr %12, align 4
  br label %263

263:                                              ; preds = %259, %253, %213, %177
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %264

264:                                              ; preds = %263, %87, %47
  %265 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  %266 = load i32, ptr %265, align 4
  ret i32 %266
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !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, !6, i64 0}
!12 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !15, i64 0}
!17 = !{!"", !15, i64 0}
!18 = !{!19, !10, i64 8}
!19 = !{!"iovec", !6, i64 0, !10, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"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.2 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [85 x i8], align 1

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

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

declare i32 @s2n_calculate_stacktrace() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @s2n_sendv_with_offset_total_size(ptr noundef readonly %0, i64 noundef %1, i64 noundef %2, ptr noundef writeonly %3) local_unnamed_addr #3 {
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %5, label %13

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

13:                                               ; preds = %4
  %14 = icmp slt i64 %1, 1
  %15 = icmp ne ptr %0, null
  %or.cond = or i1 %15, %14
  br i1 %or.cond, label %.preheader, label %16

.preheader:                                       ; preds = %13
  %.not4655 = icmp sgt i64 %1, 0
  br i1 %.not4655, label %.lr.ph, label %._crit_edge.thread

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

.lr.ph:                                           ; preds = %.preheader, %40
  %.03058 = phi i64 [ %42, %40 ], [ 0, %.preheader ]
  %.03157 = phi i64 [ %41, %40 ], [ 0, %.preheader ]
  %.03356 = phi i64 [ %.134, %40 ], [ %2, %.preheader ]
  %24 = getelementptr inbounds %struct.iovec, ptr %0, i64 %.03058, i32 1
  %25 = load i64, ptr %24, align 8, !tbaa !13
  %26 = icmp sgt i64 %.03356, 0
  br i1 %26, label %27, label %31

27:                                               ; preds = %.lr.ph
  %28 = tail call i64 @llvm.umin.i64(i64 %.03356, i64 %25)
  %29 = sub i64 %25, %28
  %30 = sub nsw i64 %.03356, %28
  br label %31

31:                                               ; preds = %27, %.lr.ph
  %.134 = phi i64 [ %30, %27 ], [ %.03356, %.lr.ph ]
  %.0 = phi i64 [ %29, %27 ], [ %25, %.lr.ph ]
  %32 = xor i64 %.03157, -1
  %.not44.not = icmp ugt i64 %.0, %32
  br i1 %.not44.not, label %.thread50, label %40

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

40:                                               ; preds = %31
  %41 = add i64 %.0, %.03157
  %42 = add nuw nsw i64 %.03058, 1
  %exitcond.not = icmp eq i64 %42, %1
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

._crit_edge:                                      ; preds = %40
  %43 = icmp eq i64 %.134, 0
  br i1 %43, label %53, label %45

._crit_edge.thread:                               ; preds = %.preheader
  %44 = icmp eq i64 %2, 0
  br i1 %44, label %.thread, label %45

45:                                               ; preds = %._crit_edge.thread, %._crit_edge
  %46 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.5, ptr %46, align 8, !tbaa !5
  %47 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.5, i64 21), i32 noundef 47) #5
  %.not47 = icmp eq ptr %47, null
  %48 = getelementptr inbounds i8, ptr %47, i64 1
  %49 = select i1 %.not47, ptr getelementptr inbounds (i8, ptr @.str.5, i64 21), ptr %48
  %50 = getelementptr inbounds i8, ptr %46, i64 8
  store ptr %49, ptr %50, align 8, !tbaa !10
  %51 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 469762089, ptr %51, align 4, !tbaa !11
  %52 = tail call i32 @s2n_calculate_stacktrace() #6
  br label %63

53:                                               ; preds = %._crit_edge
  %54 = icmp sgt i64 %41, -1
  br i1 %54, label %.thread, label %55

55:                                               ; preds = %53
  %56 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.6, ptr %56, align 8, !tbaa !5
  %57 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.6, i64 21), i32 noundef 47) #5
  %.not48 = icmp eq ptr %57, null
  %58 = getelementptr inbounds i8, ptr %57, i64 1
  %59 = select i1 %.not48, ptr getelementptr inbounds (i8, ptr @.str.6, i64 21), ptr %58
  %60 = getelementptr inbounds i8, ptr %56, i64 8
  store ptr %59, ptr %60, align 8, !tbaa !10
  %61 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 469762089, ptr %61, align 4, !tbaa !11
  %62 = tail call i32 @s2n_calculate_stacktrace() #6
  br label %63

.thread:                                          ; preds = %._crit_edge.thread, %53
  %.031.lcssa6365 = phi i64 [ %41, %53 ], [ 0, %._crit_edge.thread ]
  store i64 %.031.lcssa6365, ptr %3, align 8, !tbaa !18
  br label %63

63:                                               ; preds = %.thread50, %45, %55, %.thread, %16, %5
  %.sroa.0.4 = phi i32 [ -1, %16 ], [ -1, %5 ], [ 0, %.thread ], [ -1, %55 ], [ -1, %45 ], [ -1, %.thread50 ]
  ret i32 %.sroa.0.4
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { "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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !15, i64 8}
!14 = !{!"iovec", !7, i64 0, !15, i64 8}
!15 = !{!"long", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!15, !15, i64 0}


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