; LLVM IR from aws/s2n-tls :: tests/unit (s2n_client_auth_handshake_test)

; 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.s2n_connection = type { i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, [22 x i8], [22 x i8], [22 x i8], i32, i32, %struct.s2n_timer, i64, i64, [32 x i8], i8, i8, i8, i8, i8, i8, i8, ptr, ptr, %struct.s2n_secrets, ptr, ptr, %struct.s2n_kex_parameters, %struct.s2n_handshake_parameters, %struct.s2n_psk_parameters, ptr, i8, i32, [5 x i8], %struct.s2n_stuffer, %struct.s2n_stuffer, %struct.s2n_stuffer, %struct.s2n_stuffer, i32, i64, [2 x i8], %struct.s2n_stuffer, i8, i8, i8, i8, %struct.s2n_atomic_flag, %struct.s2n_atomic_flag, %struct.s2n_handshake, i16, i32, i16, i64, i8, i64, i64, i64, %struct.s2n_atomic_flag, %struct.s2n_atomic_flag, [256 x i8], [256 x i8], i32, %struct.s2n_blob, i32, %struct.s2n_blob, %struct.s2n_blob, %struct.s2n_blob, %struct.s2n_client_hello, %struct.s2n_x509_validator, ptr, ptr, i8, i32, %struct.s2n_blob, i32, %struct.s2n_ticket_fields, [138 x i8], %struct.s2n_stuffer, %struct.s2n_blob, %struct.s2n_blob, i8, i8, i8, i16, i16, i32, i32, %struct.s2n_blob, i32, %struct.s2n_post_handshake, %struct.s2n_atomic_flag, i8, i8 }
%struct.s2n_timer = type { i64 }
%struct.s2n_secrets = type { %union.anon, i32 }
%union.anon = type { %struct.s2n_tls13_secrets }
%struct.s2n_tls13_secrets = type { [48 x i8], [48 x i8], [48 x i8], [48 x i8], [48 x i8], [48 x i8], [48 x i8], [48 x i8], i32 }
%struct.s2n_kex_parameters = type { %struct.s2n_dh_params, %struct.s2n_ecc_evp_params, [4 x ptr], %struct.s2n_ecc_evp_params, %struct.s2n_kem_group_params, %struct.s2n_kem_group_params, [8 x ptr], %struct.s2n_kem_params, %struct.s2n_blob, %struct.s2n_blob }
%struct.s2n_dh_params = type { ptr }
%struct.s2n_ecc_evp_params = type { ptr, ptr }
%struct.s2n_kem_group_params = type { ptr, %struct.s2n_kem_params, %struct.s2n_ecc_evp_params }
%struct.s2n_kem_params = type { ptr, %struct.s2n_blob, %struct.s2n_blob, %struct.s2n_blob, i8 }
%struct.s2n_handshake_parameters = type { %struct.s2n_pkey, %struct.s2n_pkey, %struct.s2n_blob, i32, %struct.s2n_sig_scheme_list, ptr, ptr, ptr, [4 x ptr], [4 x ptr], i8, i8, [32 x i8], [32 x i8] }
%struct.s2n_pkey = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.s2n_sig_scheme_list = type { [128 x i16], i8 }
%struct.s2n_psk_parameters = type { i32, %struct.s2n_array, i16, i16, ptr, i32 }
%struct.s2n_array = type { %struct.s2n_blob, i32, i32 }
%struct.s2n_handshake = type { %struct.s2n_stuffer, ptr, [8 x i8], [48 x i8], [48 x i8], i8, i32, i32, i32, i32, %struct.s2n_offered_early_data, i8, i32 }
%struct.s2n_offered_early_data = type { ptr }
%struct.s2n_client_hello = type { %struct.s2n_blob, %struct.s2n_parsed_extensions_list, %struct.s2n_blob, %struct.s2n_blob, %struct.s2n_blob, i8, i8, i8 }
%struct.s2n_parsed_extensions_list = type { [21 x %struct.s2n_parsed_extension], %struct.s2n_blob, i16 }
%struct.s2n_parsed_extension = type { %struct.s2n_blob, i16, i16, i8 }
%struct.s2n_x509_validator = type { ptr, ptr, i8, i8, i16, ptr, i32, ptr, %struct.s2n_cert_validation_info, i8 }
%struct.s2n_cert_validation_info = type { i8, [3 x i8] }
%struct.s2n_ticket_fields = type { %struct.s2n_blob, i32 }
%struct.s2n_stuffer = type { %struct.s2n_blob, i32, i32, i32, i8 }
%struct.s2n_blob = type { ptr, i32, i32, i8 }
%struct.s2n_post_handshake = type { %struct.s2n_stuffer, [4 x i8] }
%struct.s2n_atomic_flag = type { i32 }

@_s2n_debug_info = external thread_local global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local global i32, align 4
@.str.13 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [94 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

; 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) #3

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

declare i32 @s2n_calculate_stacktrace() #5

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_handshake_message_send(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2) #6 {
  %4 = alloca %struct.s2n_result, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.s2n_result, align 4
  %12 = alloca %struct.iovec, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %3
  %16 = load ptr, ptr %5, 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.13, ptr %22, align 8, !tbaa !10
  %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 !10
  %26 = getelementptr inbounds i8, ptr %25, i64 21
  %27 = call ptr @strrchr(ptr noundef %26, i32 noundef 47) #7
  %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 !10
  %33 = getelementptr inbounds i8, ptr %32, i64 21
  %34 = call ptr @strrchr(ptr noundef %33, i32 noundef 47) #7
  %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 !10
  %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 !12
  %45 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %45, align 4, !tbaa !13
  %46 = call i32 @s2n_calculate_stacktrace()
  br label %47

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

49:                                               ; No predecessors!
  br label %50

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

51:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.s2n_connection, ptr %52, i32 0, i32 52
  %54 = getelementptr inbounds %struct.s2n_handshake, ptr %53, i32 0, i32 0
  store ptr %54, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.s2n_stuffer, ptr %55, i32 0, i32 2
  %57 = load i32, ptr %56, align 4, !tbaa !17
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.s2n_stuffer, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %59, align 8, !tbaa !20
  %61 = sub i32 %57, %60
  store i32 %61, ptr %9, align 4, !tbaa !13
  %62 = load i32, ptr %9, align 4, !tbaa !13
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %66

64:                                               ; preds = %51
  %65 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 0, ptr %65, align 4, !tbaa !15
  store i32 1, ptr %10, align 4
  br label %204

66:                                               ; preds = %51
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = call zeroext i1 @s2n_connection_is_quic_enabled(ptr noundef %67)
  br i1 %68, label %69, label %93

69:                                               ; preds = %66
  br label %70

70:                                               ; preds = %69
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = call i32 @s2n_quic_write_handshake_message(ptr noundef %71)
  %73 = getelementptr inbounds %struct.s2n_result, ptr %11, i32 0, i32 0
  store i32 %72, ptr %73, align 4
  %74 = getelementptr inbounds %struct.s2n_result, ptr %11, i32 0, i32 0
  %75 = load i32, ptr %74, align 4
  %76 = call zeroext i1 @s2n_result_is_ok(i32 %75)
  br i1 %76, label %79, label %77

77:                                               ; preds = %70
  %78 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %78, align 4, !tbaa !15
  store i32 1, ptr %10, align 4
  br label %204

79:                                               ; preds = %70
  br label %80

80:                                               ; preds = %79
  br label %81

81:                                               ; preds = %80
  br label %82

82:                                               ; preds = %81
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = call i32 @s2n_flush(ptr noundef %83, ptr noundef %84)
  %86 = icmp sgt i32 %85, -1
  br i1 %86, label %89, label %87

87:                                               ; preds = %82
  %88 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %88, align 4, !tbaa !15
  store i32 1, ptr %10, align 4
  br label %204

89:                                               ; preds = %82
  br label %90

90:                                               ; preds = %89
  br label %91

91:                                               ; preds = %90
  %92 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 0, ptr %92, align 4, !tbaa !15
  store i32 1, ptr %10, align 4
  br label %204

93:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #8
  call void @llvm.memset.p0.i64(ptr align 8 %12, i8 0, i64 16, i1 false)
  %94 = load i32, ptr %9, align 4, !tbaa !13
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds %struct.iovec, ptr %12, i32 0, i32 1
  store i64 %95, ptr %96, align 8, !tbaa !21
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  %98 = load i32, ptr %9, align 4, !tbaa !13
  %99 = call ptr @s2n_stuffer_raw_read(ptr noundef %97, i32 noundef %98)
  %100 = getelementptr inbounds %struct.iovec, ptr %12, i32 0, i32 0
  store ptr %99, ptr %100, align 8, !tbaa !24
  br label %101

101:                                              ; preds = %93
  %102 = getelementptr inbounds %struct.iovec, ptr %12, i32 0, i32 0
  %103 = load ptr, ptr %102, align 8, !tbaa !24
  %104 = icmp ne ptr %103, null
  br i1 %104, label %139, label %105

105:                                              ; preds = %101
  br label %106

106:                                              ; preds = %105
  br label %107

107:                                              ; preds = %106
  %108 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %109 = getelementptr inbounds %struct.s2n_debug_info, ptr %108, i32 0, i32 0
  store ptr @.str.14, ptr %109, align 8, !tbaa !10
  %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 !10
  %113 = getelementptr inbounds i8, ptr %112, i64 21
  %114 = call ptr @strrchr(ptr noundef %113, i32 noundef 47) #7
  %115 = icmp ne ptr %114, null
  br i1 %115, label %116, label %123

116:                                              ; preds = %107
  %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 !10
  %120 = getelementptr inbounds i8, ptr %119, i64 21
  %121 = call ptr @strrchr(ptr noundef %120, i32 noundef 47) #7
  %122 = getelementptr inbounds i8, ptr %121, i64 1
  br label %128

123:                                              ; preds = %107
  %124 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %125 = getelementptr inbounds %struct.s2n_debug_info, ptr %124, i32 0, i32 0
  %126 = load ptr, ptr %125, align 8, !tbaa !10
  %127 = getelementptr inbounds i8, ptr %126, i64 21
  br label %128

128:                                              ; preds = %123, %116
  %129 = phi ptr [ %122, %116 ], [ %127, %123 ]
  %130 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %131 = getelementptr inbounds %struct.s2n_debug_info, ptr %130, i32 0, i32 1
  store ptr %129, ptr %131, align 8, !tbaa !12
  %132 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %132, align 4, !tbaa !13
  %133 = call i32 @s2n_calculate_stacktrace()
  br label %134

134:                                              ; preds = %128
  br label %135

135:                                              ; preds = %134
  %136 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %136, align 4, !tbaa !15
  store i32 1, ptr %10, align 4
  br label %203

137:                                              ; No predecessors!
  br label %138

138:                                              ; preds = %137
  br label %139

139:                                              ; preds = %138, %101
  br label %140

140:                                              ; preds = %139
  br label %141

141:                                              ; preds = %140
  br label %142

142:                                              ; preds = %141
  %143 = load ptr, ptr %8, align 8, !tbaa !5
  %144 = load i32, ptr %9, align 4, !tbaa !13
  %145 = call i32 @s2n_stuffer_rewind_read(ptr noundef %143, i32 noundef %144)
  %146 = icmp sgt i32 %145, -1
  br i1 %146, label %149, label %147

147:                                              ; preds = %142
  %148 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %148, align 4, !tbaa !15
  store i32 1, ptr %10, align 4
  br label %203

149:                                              ; preds = %142
  br label %150

150:                                              ; preds = %149
  br label %151

151:                                              ; preds = %150
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  store i32 0, ptr %13, align 4, !tbaa !13
  br label %152

152:                                              ; preds = %199, %151
  %153 = load i32, ptr %13, align 4, !tbaa !13
  %154 = load i32, ptr %9, align 4, !tbaa !13
  %155 = icmp ult i32 %153, %154
  br i1 %155, label %156, label %200

156:                                              ; preds = %152
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %157 = load ptr, ptr %5, align 8, !tbaa !5
  %158 = load i8, ptr %6, align 1, !tbaa !9
  %159 = load i32, ptr %13, align 4, !tbaa !13
  %160 = zext i32 %159 to i64
  %161 = load i32, ptr %9, align 4, !tbaa !13
  %162 = load i32, ptr %13, align 4, !tbaa !13
  %163 = sub i32 %161, %162
  %164 = zext i32 %163 to i64
  %165 = call i32 @s2n_record_writev(ptr noundef %157, i8 noundef zeroext %158, ptr noundef %12, i32 noundef 1, i64 noundef %160, i64 noundef %164)
  store i32 %165, ptr %14, align 4, !tbaa !13
  br label %166

166:                                              ; preds = %156
  %167 = load i32, ptr %14, align 4, !tbaa !13
  %168 = icmp sgt i32 %167, -1
  br i1 %168, label %171, label %169

169:                                              ; preds = %166
  %170 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %170, align 4, !tbaa !15
  store i32 1, ptr %10, align 4
  br label %197

171:                                              ; preds = %166
  br label %172

172:                                              ; preds = %171
  br label %173

173:                                              ; preds = %172
  %174 = load i32, ptr %14, align 4, !tbaa !13
  %175 = load i32, ptr %13, align 4, !tbaa !13
  %176 = add i32 %175, %174
  store i32 %176, ptr %13, align 4, !tbaa !13
  br label %177

177:                                              ; preds = %173
  %178 = load ptr, ptr %8, align 8, !tbaa !5
  %179 = load i32, ptr %14, align 4, !tbaa !13
  %180 = call i32 @s2n_stuffer_skip_read(ptr noundef %178, i32 noundef %179)
  %181 = icmp sgt i32 %180, -1
  br i1 %181, label %184, label %182

182:                                              ; preds = %177
  %183 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %183, align 4, !tbaa !15
  store i32 1, ptr %10, align 4
  br label %197

184:                                              ; preds = %177
  br label %185

185:                                              ; preds = %184
  br label %186

186:                                              ; preds = %185
  br label %187

187:                                              ; preds = %186
  %188 = load ptr, ptr %5, align 8, !tbaa !5
  %189 = load ptr, ptr %7, align 8, !tbaa !5
  %190 = call i32 @s2n_flush(ptr noundef %188, ptr noundef %189)
  %191 = icmp sgt i32 %190, -1
  br i1 %191, label %194, label %192

192:                                              ; preds = %187
  %193 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %193, align 4, !tbaa !15
  store i32 1, ptr %10, align 4
  br label %197

194:                                              ; preds = %187
  br label %195

195:                                              ; preds = %194
  br label %196

196:                                              ; preds = %195
  store i32 0, ptr %10, align 4
  br label %197

197:                                              ; preds = %196, %192, %182, %169
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  %198 = load i32, ptr %10, align 4
  switch i32 %198, label %202 [
    i32 0, label %199
  ]

199:                                              ; preds = %197
  br label %152, !llvm.loop !25

200:                                              ; preds = %152
  %201 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 0, ptr %201, align 4, !tbaa !15
  store i32 1, ptr %10, align 4
  br label %202

202:                                              ; preds = %200, %197
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %203

203:                                              ; preds = %202, %147, %135
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #8
  br label %204

204:                                              ; preds = %203, %91, %87, %77, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  br label %205

205:                                              ; preds = %204, %47
  %206 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  %207 = load i32, ptr %206, align 4
  ret i32 %207
}

declare zeroext i1 @s2n_connection_is_quic_enabled(ptr noundef) #5

declare i32 @s2n_quic_write_handshake_message(ptr noundef) #5

declare i32 @s2n_flush(ptr noundef, ptr noundef) #5

declare ptr @s2n_stuffer_raw_read(ptr noundef, i32 noundef) #5

declare i32 @s2n_stuffer_rewind_read(ptr noundef, i32 noundef) #5

declare i32 @s2n_record_writev(ptr noundef, i8 noundef zeroext, ptr noundef, i32 noundef, i64 noundef, i64 noundef) #5

declare i32 @s2n_stuffer_skip_read(ptr noundef, i32 noundef) #5

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 0}
!11 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!12 = !{!11, !6, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !14, i64 0}
!16 = !{!"", !14, i64 0}
!17 = !{!18, !14, i64 28}
!18 = !{!"s2n_stuffer", !19, i64 0, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !14, i64 36, !14, i64 36}
!19 = !{!"s2n_blob", !6, i64 0, !14, i64 8, !14, i64 12, !14, i64 16}
!20 = !{!18, !14, i64 24}
!21 = !{!22, !23, i64 8}
!22 = !{!"iovec", !6, i64 0, !23, i64 8}
!23 = !{!"long", !7, i64 0}
!24 = !{!22, !6, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"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.13 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [94 x i8], align 1

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

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

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

; 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: nounwind uwtable
define dso_local i32 @s2n_handshake_message_send(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2) local_unnamed_addr #5 {
  %4 = alloca %struct.iovec, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %13

5:                                                ; preds = %3
  %6 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.13, ptr %6, align 8, !tbaa !5
  %7 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.13, i64 21), i32 noundef 47) #6
  %.not35 = icmp eq ptr %7, null
  %8 = getelementptr inbounds i8, ptr %7, i64 1
  %9 = select i1 %.not35, ptr getelementptr inbounds (i8, ptr @.str.13, 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() #7
  br label %57

13:                                               ; preds = %3
  %14 = getelementptr inbounds i8, ptr %0, i64 2016
  %15 = getelementptr inbounds i8, ptr %0, i64 2044
  %16 = load i32, ptr %15, align 4, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %0, i64 2040
  %18 = load i32, ptr %17, align 8, !tbaa !16
  %19 = sub i32 %16, %18
  %20 = icmp eq i32 %16, %18
  br i1 %20, label %57, label %21

21:                                               ; preds = %13
  %22 = tail call zeroext i1 @s2n_connection_is_quic_enabled(ptr noundef nonnull %0) #7
  br i1 %22, label %23, label %28

23:                                               ; preds = %21
  %24 = tail call i32 @s2n_quic_write_handshake_message(ptr noundef nonnull %0) #7
  %25 = tail call zeroext i1 @s2n_result_is_ok(i32 %24)
  br i1 %25, label %26, label %57

26:                                               ; preds = %23
  %27 = tail call i32 @s2n_flush(ptr noundef nonnull %0, ptr noundef %2) #7
  %.lobit = ashr i32 %27, 31
  br label %57

28:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #7
  %29 = zext i32 %19 to i64
  %30 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %29, ptr %30, align 8, !tbaa !17
  %31 = tail call ptr @s2n_stuffer_raw_read(ptr noundef nonnull %14, i32 noundef %19) #7
  store ptr %31, ptr %4, align 8, !tbaa !20
  %.not36 = icmp eq ptr %31, null
  br i1 %.not36, label %32, label %40

32:                                               ; preds = %28
  %33 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.14, ptr %33, align 8, !tbaa !5
  %34 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.14, i64 21), i32 noundef 47) #6
  %.not37 = icmp eq ptr %34, null
  %35 = getelementptr inbounds i8, ptr %34, i64 1
  %36 = select i1 %.not37, ptr getelementptr inbounds (i8, ptr @.str.14, 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 402653193, ptr %38, align 4, !tbaa !11
  %39 = tail call i32 @s2n_calculate_stacktrace() #7
  br label %.thread

40:                                               ; preds = %28
  %41 = tail call i32 @s2n_stuffer_rewind_read(ptr noundef nonnull %14, i32 noundef %19) #7
  %42 = icmp sgt i32 %41, -1
  br i1 %42, label %.preheader, label %.thread

.preheader:                                       ; preds = %40, %53
  %.0 = phi i32 [ %54, %53 ], [ 0, %40 ]
  %43 = icmp ult i32 %.0, %19
  br i1 %43, label %44, label %.thread

44:                                               ; preds = %.preheader
  %45 = zext i32 %.0 to i64
  %46 = sub i32 %19, %.0
  %47 = zext i32 %46 to i64
  %48 = call i32 @s2n_record_writev(ptr noundef nonnull %0, i8 noundef zeroext %1, ptr noundef nonnull %4, i32 noundef 1, i64 noundef %45, i64 noundef %47) #7
  %49 = icmp sgt i32 %48, -1
  br i1 %49, label %50, label %.thread

50:                                               ; preds = %44
  %51 = call i32 @s2n_stuffer_skip_read(ptr noundef nonnull %14, i32 noundef %48) #7
  %52 = icmp sgt i32 %51, -1
  br i1 %52, label %53, label %.thread

53:                                               ; preds = %50
  %54 = add i32 %48, %.0
  %55 = call i32 @s2n_flush(ptr noundef nonnull %0, ptr noundef %2) #7
  %56 = icmp sgt i32 %55, -1
  br i1 %56, label %.preheader, label %.thread, !llvm.loop !21

.thread:                                          ; preds = %50, %44, %53, %.preheader, %40, %32
  %.sroa.028.3 = phi i32 [ -1, %32 ], [ -1, %40 ], [ -1, %50 ], [ -1, %44 ], [ 0, %.preheader ], [ -1, %53 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  br label %57

57:                                               ; preds = %.thread, %13, %23, %26, %5
  %.sroa.028.5 = phi i32 [ -1, %5 ], [ %.sroa.028.3, %.thread ], [ 0, %13 ], [ -1, %23 ], [ %.lobit, %26 ]
  ret i32 %.sroa.028.5
}

declare zeroext i1 @s2n_connection_is_quic_enabled(ptr noundef) local_unnamed_addr #4

declare i32 @s2n_quic_write_handshake_message(ptr noundef) local_unnamed_addr #4

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

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #6 = { nounwind willreturn memory(read) }
attributes #7 = { 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, !12, i64 28}
!14 = !{!"s2n_stuffer", !15, i64 0, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 36, !12, i64 36}
!15 = !{!"s2n_blob", !7, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!16 = !{!14, !12, i64 24}
!17 = !{!18, !19, i64 8}
!18 = !{!"iovec", !7, i64 0, !19, i64 8}
!19 = !{!"long", !8, i64 0}
!20 = !{!18, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass