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

; 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 }
%struct.msghdr = type { ptr, i32, ptr, i64, ptr, i64, i32 }

@s2n_recvmsg_fn = external dso_local global ptr, align 8
@_s2n_debug_info = external thread_local global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local global i32, align 4
@.str.22 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [88 x i8], align 1

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

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

declare i32 @s2n_calculate_stacktrace() #2

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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

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

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

21:                                               ; preds = %6
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %56, label %24

24:                                               ; preds = %21
  br label %25

25:                                               ; preds = %24
  br label %26

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

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

42:                                               ; preds = %26
  %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 0
  %45 = load ptr, ptr %44, align 8, !tbaa !11
  %46 = getelementptr inbounds i8, ptr %45, i64 21
  br label %47

47:                                               ; preds = %42, %35
  %48 = phi ptr [ %41, %35 ], [ %46, %42 ]
  %49 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %50 = getelementptr inbounds %struct.s2n_debug_info, ptr %49, i32 0, i32 1
  store ptr %48, ptr %50, align 8, !tbaa !13
  %51 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %51, align 4, !tbaa !14
  %52 = call i32 @s2n_calculate_stacktrace()
  br label %53

53:                                               ; preds = %47
  %54 = getelementptr inbounds %struct.s2n_result, ptr %7, i32 0, i32 0
  store i32 -1, ptr %54, align 4, !tbaa !16
  br label %267

55:                                               ; No predecessors!
  br label %56

56:                                               ; preds = %55, %21
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = icmp ne ptr %59, null
  br i1 %60, label %93, label %61

61:                                               ; preds = %58
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62
  %64 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %65 = getelementptr inbounds %struct.s2n_debug_info, ptr %64, i32 0, i32 0
  store ptr @.str.23, ptr %65, align 8, !tbaa !11
  %66 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %67 = getelementptr inbounds %struct.s2n_debug_info, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !11
  %69 = getelementptr inbounds i8, ptr %68, i64 21
  %70 = call ptr @strrchr(ptr noundef %69, i32 noundef 47) #8
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %79

72:                                               ; preds = %63
  %73 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %74 = getelementptr inbounds %struct.s2n_debug_info, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !11
  %76 = getelementptr inbounds i8, ptr %75, i64 21
  %77 = call ptr @strrchr(ptr noundef %76, i32 noundef 47) #8
  %78 = getelementptr inbounds i8, ptr %77, i64 1
  br label %84

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

84:                                               ; preds = %79, %72
  %85 = phi ptr [ %78, %72 ], [ %83, %79 ]
  %86 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %87 = getelementptr inbounds %struct.s2n_debug_info, ptr %86, i32 0, i32 1
  store ptr %85, ptr %87, align 8, !tbaa !13
  %88 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %88, align 4, !tbaa !14
  %89 = call i32 @s2n_calculate_stacktrace()
  br label %90

90:                                               ; preds = %84
  %91 = getelementptr inbounds %struct.s2n_result, ptr %7, i32 0, i32 0
  store i32 -1, ptr %91, align 4, !tbaa !16
  br label %267

92:                                               ; No predecessors!
  br label %93

93:                                               ; preds = %92, %58
  br label %94

94:                                               ; preds = %93
  br label %95

95:                                               ; preds = %94
  %96 = load ptr, ptr %12, align 8, !tbaa !5
  %97 = icmp ne ptr %96, null
  br i1 %97, label %130, label %98

98:                                               ; preds = %95
  br label %99

99:                                               ; preds = %98
  br label %100

100:                                              ; preds = %99
  %101 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %102 = getelementptr inbounds %struct.s2n_debug_info, ptr %101, i32 0, i32 0
  store ptr @.str.24, ptr %102, align 8, !tbaa !11
  %103 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %104 = getelementptr inbounds %struct.s2n_debug_info, ptr %103, i32 0, i32 0
  %105 = load ptr, ptr %104, align 8, !tbaa !11
  %106 = getelementptr inbounds i8, ptr %105, i64 21
  %107 = call ptr @strrchr(ptr noundef %106, i32 noundef 47) #8
  %108 = icmp ne ptr %107, null
  br i1 %108, label %109, label %116

109:                                              ; preds = %100
  %110 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %111 = getelementptr inbounds %struct.s2n_debug_info, ptr %110, i32 0, i32 0
  %112 = load ptr, ptr %111, align 8, !tbaa !11
  %113 = getelementptr inbounds i8, ptr %112, i64 21
  %114 = call ptr @strrchr(ptr noundef %113, i32 noundef 47) #8
  %115 = getelementptr inbounds i8, ptr %114, i64 1
  br label %121

116:                                              ; preds = %100
  %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
  br label %121

121:                                              ; preds = %116, %109
  %122 = phi ptr [ %115, %109 ], [ %120, %116 ]
  %123 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %124 = getelementptr inbounds %struct.s2n_debug_info, ptr %123, i32 0, i32 1
  store ptr %122, ptr %124, align 8, !tbaa !13
  %125 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %125, align 4, !tbaa !14
  %126 = call i32 @s2n_calculate_stacktrace()
  br label %127

127:                                              ; preds = %121
  %128 = getelementptr inbounds %struct.s2n_result, ptr %7, i32 0, i32 0
  store i32 -1, ptr %128, align 4, !tbaa !16
  br label %267

129:                                              ; No predecessors!
  br label %130

130:                                              ; preds = %129, %95
  br label %131

131:                                              ; preds = %130
  br label %132

132:                                              ; preds = %131
  %133 = load ptr, ptr %10, align 8, !tbaa !5
  %134 = icmp ne ptr %133, null
  br i1 %134, label %167, label %135

135:                                              ; preds = %132
  br label %136

136:                                              ; preds = %135
  br label %137

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

146:                                              ; preds = %137
  %147 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %148 = getelementptr inbounds %struct.s2n_debug_info, ptr %147, i32 0, i32 0
  %149 = load ptr, ptr %148, align 8, !tbaa !11
  %150 = getelementptr inbounds i8, ptr %149, i64 21
  %151 = call ptr @strrchr(ptr noundef %150, i32 noundef 47) #8
  %152 = getelementptr inbounds i8, ptr %151, i64 1
  br label %158

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

158:                                              ; preds = %153, %146
  %159 = phi ptr [ %152, %146 ], [ %157, %153 ]
  %160 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %161 = getelementptr inbounds %struct.s2n_debug_info, ptr %160, i32 0, i32 1
  store ptr %159, ptr %161, align 8, !tbaa !13
  %162 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %162, align 4, !tbaa !14
  %163 = call i32 @s2n_calculate_stacktrace()
  br label %164

164:                                              ; preds = %158
  %165 = getelementptr inbounds %struct.s2n_result, ptr %7, i32 0, i32 0
  store i32 -1, ptr %165, align 4, !tbaa !16
  br label %267

166:                                              ; No predecessors!
  br label %167

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

168:                                              ; preds = %167
  br label %169

169:                                              ; preds = %168
  %170 = load i64, ptr %11, align 8, !tbaa !9
  %171 = icmp ugt i64 %170, 0
  br i1 %171, label %204, label %172

172:                                              ; preds = %169
  br label %173

173:                                              ; preds = %172
  br label %174

174:                                              ; preds = %173
  %175 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %176 = getelementptr inbounds %struct.s2n_debug_info, ptr %175, i32 0, i32 0
  store ptr @.str.26, ptr %176, align 8, !tbaa !11
  %177 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %178 = getelementptr inbounds %struct.s2n_debug_info, ptr %177, i32 0, i32 0
  %179 = load ptr, ptr %178, align 8, !tbaa !11
  %180 = getelementptr inbounds i8, ptr %179, i64 21
  %181 = call ptr @strrchr(ptr noundef %180, i32 noundef 47) #8
  %182 = icmp ne ptr %181, null
  br i1 %182, label %183, label %190

183:                                              ; preds = %174
  %184 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %185 = getelementptr inbounds %struct.s2n_debug_info, ptr %184, i32 0, i32 0
  %186 = load ptr, ptr %185, align 8, !tbaa !11
  %187 = getelementptr inbounds i8, ptr %186, i64 21
  %188 = call ptr @strrchr(ptr noundef %187, i32 noundef 47) #8
  %189 = getelementptr inbounds i8, ptr %188, i64 1
  br label %195

190:                                              ; preds = %174
  %191 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %192 = getelementptr inbounds %struct.s2n_debug_info, ptr %191, i32 0, i32 0
  %193 = load ptr, ptr %192, align 8, !tbaa !11
  %194 = getelementptr inbounds i8, ptr %193, i64 21
  br label %195

195:                                              ; preds = %190, %183
  %196 = phi ptr [ %189, %183 ], [ %194, %190 ]
  %197 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %198 = getelementptr inbounds %struct.s2n_debug_info, ptr %197, i32 0, i32 1
  store ptr %196, ptr %198, align 8, !tbaa !13
  %199 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653194, ptr %199, align 4, !tbaa !14
  %200 = call i32 @s2n_calculate_stacktrace()
  br label %201

201:                                              ; preds = %195
  %202 = getelementptr inbounds %struct.s2n_result, ptr %7, i32 0, i32 0
  store i32 -1, ptr %202, align 4, !tbaa !16
  br label %267

203:                                              ; No predecessors!
  br label %204

204:                                              ; preds = %203, %169
  br label %205

205:                                              ; preds = %204
  %206 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 1, ptr %206, align 4, !tbaa !14
  %207 = load ptr, ptr %9, align 8, !tbaa !5
  store i8 0, ptr %207, align 1, !tbaa !18
  %208 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 0, ptr %208, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #9
  %209 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 0
  %210 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %210, ptr %209, align 8, !tbaa !19
  %211 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 1
  %212 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %212, ptr %211, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 56, ptr %15) #9
  %213 = getelementptr inbounds %struct.msghdr, ptr %15, i32 0, i32 0
  store ptr null, ptr %213, align 8, !tbaa !22
  %214 = getelementptr inbounds %struct.msghdr, ptr %15, i32 0, i32 1
  store i32 0, ptr %214, align 8, !tbaa !24
  %215 = getelementptr inbounds %struct.msghdr, ptr %15, i32 0, i32 2
  store ptr %14, ptr %215, align 8, !tbaa !25
  %216 = getelementptr inbounds %struct.msghdr, ptr %15, i32 0, i32 3
  store i64 1, ptr %216, align 8, !tbaa !26
  %217 = getelementptr inbounds %struct.msghdr, ptr %15, i32 0, i32 4
  store ptr null, ptr %217, align 8, !tbaa !27
  %218 = getelementptr inbounds %struct.msghdr, ptr %15, i32 0, i32 5
  store i64 0, ptr %218, align 8, !tbaa !28
  %219 = getelementptr inbounds %struct.msghdr, ptr %15, i32 0, i32 6
  store i32 0, ptr %219, align 8, !tbaa !29
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #9
  call void @llvm.memset.p0.i64(ptr align 16 %16, i8 0, i64 24, i1 false)
  %220 = getelementptr inbounds %struct.msghdr, ptr %15, i32 0, i32 5
  store i64 24, ptr %220, align 8, !tbaa !28
  %221 = getelementptr inbounds [24 x i8], ptr %16, i64 0, i64 0
  %222 = getelementptr inbounds %struct.msghdr, ptr %15, i32 0, i32 4
  store ptr %221, ptr %222, align 8, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #9
  store i64 0, ptr %17, align 8, !tbaa !9
  br label %223

223:                                              ; preds = %235, %205
  %224 = call ptr @__errno_location() #10
  store i32 0, ptr %224, align 4, !tbaa !14
  %225 = load ptr, ptr @s2n_recvmsg_fn, align 8, !tbaa !5
  %226 = load ptr, ptr %8, align 8, !tbaa !5
  %227 = call i64 %225(ptr noundef %226, ptr noundef %15)
  store i64 %227, ptr %17, align 8, !tbaa !9
  br label %228

228:                                              ; preds = %223
  %229 = load i64, ptr %17, align 8, !tbaa !9
  %230 = icmp slt i64 %229, 0
  br i1 %230, label %231, label %235

231:                                              ; preds = %228
  %232 = call ptr @__errno_location() #10
  %233 = load i32, ptr %232, align 4, !tbaa !14
  %234 = icmp eq i32 %233, 4
  br label %235

235:                                              ; preds = %231, %228
  %236 = phi i1 [ false, %228 ], [ %234, %231 ]
  br i1 %236, label %223, label %237, !llvm.loop !30

237:                                              ; preds = %235
  br label %238

238:                                              ; preds = %237
  %239 = load i64, ptr %17, align 8, !tbaa !9
  %240 = call i32 @s2n_io_check_read_result(i64 noundef %239)
  %241 = getelementptr inbounds %struct.s2n_result, ptr %18, i32 0, i32 0
  store i32 %240, ptr %241, align 4
  %242 = getelementptr inbounds %struct.s2n_result, ptr %18, i32 0, i32 0
  %243 = load i32, ptr %242, align 4
  %244 = call zeroext i1 @s2n_result_is_ok(i32 %243)
  br i1 %244, label %247, label %245

245:                                              ; preds = %238
  %246 = getelementptr inbounds %struct.s2n_result, ptr %7, i32 0, i32 0
  store i32 -1, ptr %246, align 4, !tbaa !16
  store i32 1, ptr %19, align 4
  br label %266

247:                                              ; preds = %238
  br label %248

248:                                              ; preds = %247
  br label %249

249:                                              ; preds = %248
  br label %250

250:                                              ; preds = %249
  %251 = load ptr, ptr %9, align 8, !tbaa !5
  %252 = call i32 @s2n_ktls_get_control_data(ptr noundef %15, i32 noundef 0, ptr noundef %251)
  %253 = getelementptr inbounds %struct.s2n_result, ptr %20, i32 0, i32 0
  store i32 %252, ptr %253, align 4
  %254 = getelementptr inbounds %struct.s2n_result, ptr %20, i32 0, i32 0
  %255 = load i32, ptr %254, align 4
  %256 = call zeroext i1 @s2n_result_is_ok(i32 %255)
  br i1 %256, label %259, label %257

257:                                              ; preds = %250
  %258 = getelementptr inbounds %struct.s2n_result, ptr %7, i32 0, i32 0
  store i32 -1, ptr %258, align 4, !tbaa !16
  store i32 1, ptr %19, align 4
  br label %266

259:                                              ; preds = %250
  br label %260

260:                                              ; preds = %259
  br label %261

261:                                              ; preds = %260
  %262 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 0, ptr %262, align 4, !tbaa !14
  %263 = load i64, ptr %17, align 8, !tbaa !9
  %264 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 %263, ptr %264, align 8, !tbaa !9
  %265 = getelementptr inbounds %struct.s2n_result, ptr %7, i32 0, i32 0
  store i32 0, ptr %265, align 4, !tbaa !16
  store i32 1, ptr %19, align 4
  br label %266

266:                                              ; preds = %261, %257, %245
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 56, ptr %15) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #9
  br label %267

267:                                              ; preds = %266, %201, %164, %127, %90, %53
  %268 = getelementptr inbounds %struct.s2n_result, ptr %7, i32 0, i32 0
  %269 = load i32, ptr %268, align 4
  ret i32 %269
}

declare i32 @s2n_io_check_read_result(i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 #7 = { 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 #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind }
attributes #10 = { nounwind willreturn memory(none) }

!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 = !{!7, !7, i64 0}
!19 = !{!20, !6, i64 0}
!20 = !{!"iovec", !6, i64 0, !10, i64 8}
!21 = !{!20, !10, i64 8}
!22 = !{!23, !6, i64 0}
!23 = !{!"msghdr", !6, i64 0, !15, i64 8, !6, i64 16, !10, i64 24, !6, i64 32, !10, i64 40, !15, i64 48}
!24 = !{!23, !15, i64 8}
!25 = !{!23, !6, i64 16}
!26 = !{!23, !10, i64 24}
!27 = !{!23, !6, i64 32}
!28 = !{!23, !10, i64 40}
!29 = !{!23, !15, i64 48}
!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.iovec = type { ptr, i64 }
%struct.msghdr = type { ptr, i32, ptr, i64, ptr, i64, i32 }

@s2n_recvmsg_fn = external dso_local local_unnamed_addr global ptr, align 8
@_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.22 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [88 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_ktls_recvmsg(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef writeonly %4, ptr noundef writeonly %5) local_unnamed_addr #4 {
  %7 = alloca %struct.iovec, align 8
  %8 = alloca %struct.msghdr, align 8
  %9 = alloca [24 x i8], align 16
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %10, label %18

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

18:                                               ; preds = %6
  %.not28 = icmp eq ptr %5, null
  br i1 %.not28, label %19, label %27

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

27:                                               ; preds = %18
  %.not30 = icmp eq ptr %4, null
  br i1 %.not30, label %28, label %36

28:                                               ; preds = %27
  %29 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.24, ptr %29, align 8, !tbaa !5
  %30 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.24, i64 21), i32 noundef 47) #8
  %.not31 = icmp eq ptr %30, null
  %31 = getelementptr inbounds i8, ptr %30, i64 1
  %32 = select i1 %.not31, ptr getelementptr inbounds (i8, ptr @.str.24, i64 21), ptr %31
  %33 = getelementptr inbounds i8, ptr %29, i64 8
  store ptr %32, ptr %33, align 8, !tbaa !10
  %34 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %34, align 4, !tbaa !11
  %35 = tail call i32 @s2n_calculate_stacktrace() #9
  br label %77

36:                                               ; preds = %27
  %.not32 = icmp eq ptr %2, null
  br i1 %.not32, label %37, label %45

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

45:                                               ; preds = %36
  %.not34 = icmp eq i64 %3, 0
  br i1 %.not34, label %46, label %54

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

54:                                               ; preds = %45
  store i32 1, ptr %4, align 4, !tbaa !11
  store i8 0, ptr %1, align 1, !tbaa !13
  store i64 0, ptr %5, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #9
  store ptr %2, ptr %7, align 8, !tbaa !16
  %55 = getelementptr inbounds i8, ptr %7, i64 8
  store i64 %3, ptr %55, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %8) #9
  store ptr null, ptr %8, align 8, !tbaa !19
  %56 = getelementptr inbounds i8, ptr %8, i64 8
  store i32 0, ptr %56, align 8, !tbaa !21
  %57 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %7, ptr %57, align 8, !tbaa !22
  %58 = getelementptr inbounds i8, ptr %8, i64 24
  store i64 1, ptr %58, align 8, !tbaa !23
  %59 = getelementptr inbounds i8, ptr %8, i64 32
  %60 = getelementptr inbounds i8, ptr %8, i64 40
  %61 = getelementptr inbounds i8, ptr %8, i64 48
  store i32 0, ptr %61, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %9, i8 0, i64 24, i1 false)
  store i64 24, ptr %60, align 8, !tbaa !24
  store ptr %9, ptr %59, align 8, !tbaa !25
  %62 = tail call ptr @__errno_location() #10
  br label %63

63:                                               ; preds = %67, %54
  store i32 0, ptr %62, align 4, !tbaa !11
  %64 = load ptr, ptr @s2n_recvmsg_fn, align 8, !tbaa !26
  %65 = call i64 %64(ptr noundef %0, ptr noundef nonnull %8) #9
  %66 = icmp slt i64 %65, 0
  br i1 %66, label %67, label %.critedge

67:                                               ; preds = %63
  %68 = load i32, ptr %62, align 4, !tbaa !11
  %69 = icmp eq i32 %68, 4
  br i1 %69, label %63, label %.critedge, !llvm.loop !27

.critedge:                                        ; preds = %63, %67
  %70 = call i32 @s2n_io_check_read_result(i64 noundef %65) #9
  %71 = call zeroext i1 @s2n_result_is_ok(i32 %70)
  br i1 %71, label %72, label %76

72:                                               ; preds = %.critedge
  %73 = call i32 @s2n_ktls_get_control_data(ptr noundef nonnull %8, i32 noundef 0, ptr noundef nonnull %1)
  %74 = call zeroext i1 @s2n_result_is_ok(i32 %73)
  br i1 %74, label %75, label %76

75:                                               ; preds = %72
  store i32 0, ptr %4, align 4, !tbaa !11
  store i64 %65, ptr %5, align 8, !tbaa !14
  br label %76

76:                                               ; preds = %72, %.critedge, %75
  %.sroa.017.0 = phi i32 [ 0, %75 ], [ -1, %.critedge ], [ -1, %72 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #9
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %8) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #9
  br label %77

77:                                               ; preds = %76, %46, %37, %28, %19, %10
  %.sroa.017.1 = phi i32 [ %.sroa.017.0, %76 ], [ -1, %46 ], [ -1, %37 ], [ -1, %28 ], [ -1, %19 ], [ -1, %10 ]
  ret i32 %.sroa.017.1
}

declare i32 @s2n_io_check_read_result(i64 noundef) local_unnamed_addr #2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 #7 = { 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 #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind }
attributes #10 = { nounwind willreturn memory(none) }

!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 = !{!8, !8, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!17, !7, i64 0}
!17 = !{!"iovec", !7, i64 0, !15, i64 8}
!18 = !{!17, !15, i64 8}
!19 = !{!20, !7, i64 0}
!20 = !{!"msghdr", !7, i64 0, !12, i64 8, !7, i64 16, !15, i64 24, !7, i64 32, !15, i64 40, !12, i64 48}
!21 = !{!20, !12, i64 8}
!22 = !{!20, !7, i64 16}
!23 = !{!20, !15, i64 24}
!24 = !{!20, !15, i64 40}
!25 = !{!20, !7, i64 32}
!26 = !{!7, !7, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass