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

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.s2n_debug_info = type { ptr, ptr }
%struct.s2n_result = type { i32 }
%struct.s2n_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.1 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [93 x i8], align 1

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

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

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

declare i32 @s2n_calculate_stacktrace() #3

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

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %48, label %16

16:                                               ; preds = %13
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  %19 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %20 = getelementptr inbounds %struct.s2n_debug_info, ptr %19, i32 0, i32 0
  store ptr @.str.1, ptr %20, align 8, !tbaa !9
  %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
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds i8, ptr %23, i64 21
  %25 = call ptr @strrchr(ptr noundef %24, i32 noundef 47) #8
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %34

27:                                               ; preds = %18
  %28 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %29 = getelementptr inbounds %struct.s2n_debug_info, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %30, i64 21
  %32 = call ptr @strrchr(ptr noundef %31, i32 noundef 47) #8
  %33 = getelementptr inbounds i8, ptr %32, i64 1
  br label %39

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

39:                                               ; preds = %34, %27
  %40 = phi ptr [ %33, %27 ], [ %38, %34 ]
  %41 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %42 = getelementptr inbounds %struct.s2n_debug_info, ptr %41, i32 0, i32 1
  store ptr %40, ptr %42, align 8, !tbaa !11
  %43 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %43, align 4, !tbaa !12
  %44 = call i32 @s2n_calculate_stacktrace()
  br label %45

45:                                               ; preds = %39
  %46 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 -1, ptr %46, align 4, !tbaa !14
  br label %213

47:                                               ; No predecessors!
  br label %48

48:                                               ; preds = %47, %13
  br label %49

49:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #9
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.s2n_connection, ptr %50, i32 0, i32 64
  %52 = getelementptr inbounds [256 x i8], ptr %51, i64 0, i64 0
  %53 = call i64 @strlen(ptr noundef %52) #8
  %54 = trunc i64 %53 to i8
  store i8 %54, ptr %6, align 1, !tbaa !16
  br label %55

55:                                               ; preds = %49
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load i8, ptr %6, align 1, !tbaa !16
  %58 = call i32 @s2n_stuffer_write_uint8(ptr noundef %56, i8 noundef zeroext %57)
  %59 = icmp sgt i32 %58, -1
  br i1 %59, label %62, label %60

60:                                               ; preds = %55
  %61 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 -1, ptr %61, align 4, !tbaa !14
  store i32 1, ptr %7, align 4
  br label %212

62:                                               ; preds = %55
  br label %63

63:                                               ; preds = %62
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.s2n_connection, ptr %67, i32 0, i32 64
  %69 = getelementptr inbounds [256 x i8], ptr %68, i64 0, i64 0
  %70 = load i8, ptr %6, align 1, !tbaa !16
  %71 = zext i8 %70 to i32
  %72 = call i32 @s2n_stuffer_write_bytes(ptr noundef %66, ptr noundef %69, i32 noundef %71)
  %73 = icmp sgt i32 %72, -1
  br i1 %73, label %76, label %74

74:                                               ; preds = %65
  %75 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 -1, ptr %75, align 4, !tbaa !14
  store i32 1, ptr %7, align 4
  br label %212

76:                                               ; preds = %65
  br label %77

77:                                               ; preds = %76
  br label %78

78:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #9
  store i8 0, ptr %8, align 1, !tbaa !16
  br label %79

79:                                               ; preds = %78
  %80 = load i8, ptr %6, align 1, !tbaa !16
  %81 = call i32 @s2n_calculate_padding(i8 noundef zeroext %80, ptr noundef %8)
  %82 = getelementptr inbounds %struct.s2n_result, ptr %9, i32 0, i32 0
  store i32 %81, ptr %82, align 4
  %83 = getelementptr inbounds %struct.s2n_result, ptr %9, i32 0, i32 0
  %84 = load i32, ptr %83, align 4
  %85 = call zeroext i1 @s2n_result_is_ok(i32 %84)
  br i1 %85, label %88, label %86

86:                                               ; preds = %79
  %87 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 -1, ptr %87, align 4, !tbaa !14
  store i32 1, ptr %7, align 4
  br label %211

88:                                               ; preds = %79
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89
  br label %91

91:                                               ; preds = %90
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = load i8, ptr %8, align 1, !tbaa !16
  %94 = call i32 @s2n_stuffer_write_uint8(ptr noundef %92, i8 noundef zeroext %93)
  %95 = icmp sgt i32 %94, -1
  br i1 %95, label %98, label %96

96:                                               ; preds = %91
  %97 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 -1, ptr %97, align 4, !tbaa !14
  store i32 1, ptr %7, align 4
  br label %211

98:                                               ; preds = %91
  br label %99

99:                                               ; preds = %98
  br label %100

100:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #9
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = load i8, ptr %8, align 1, !tbaa !16
  %103 = zext i8 %102 to i32
  %104 = call ptr @s2n_stuffer_raw_write(ptr noundef %101, i32 noundef %103)
  store ptr %104, ptr %10, align 8, !tbaa !5
  br label %105

105:                                              ; preds = %100
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = icmp ne ptr %106, null
  br i1 %107, label %142, label %108

108:                                              ; preds = %105
  br label %109

109:                                              ; preds = %108
  br label %110

110:                                              ; preds = %109
  %111 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %112 = getelementptr inbounds %struct.s2n_debug_info, ptr %111, i32 0, i32 0
  store ptr @.str.2, ptr %112, align 8, !tbaa !9
  %113 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %114 = getelementptr inbounds %struct.s2n_debug_info, ptr %113, i32 0, i32 0
  %115 = load ptr, ptr %114, align 8, !tbaa !9
  %116 = getelementptr inbounds i8, ptr %115, i64 21
  %117 = call ptr @strrchr(ptr noundef %116, i32 noundef 47) #8
  %118 = icmp ne ptr %117, null
  br i1 %118, label %119, label %126

119:                                              ; preds = %110
  %120 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %121 = getelementptr inbounds %struct.s2n_debug_info, ptr %120, i32 0, i32 0
  %122 = load ptr, ptr %121, align 8, !tbaa !9
  %123 = getelementptr inbounds i8, ptr %122, i64 21
  %124 = call ptr @strrchr(ptr noundef %123, i32 noundef 47) #8
  %125 = getelementptr inbounds i8, ptr %124, i64 1
  br label %131

126:                                              ; preds = %110
  %127 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %128 = getelementptr inbounds %struct.s2n_debug_info, ptr %127, i32 0, i32 0
  %129 = load ptr, ptr %128, align 8, !tbaa !9
  %130 = getelementptr inbounds i8, ptr %129, i64 21
  br label %131

131:                                              ; preds = %126, %119
  %132 = phi ptr [ %125, %119 ], [ %130, %126 ]
  %133 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %134 = getelementptr inbounds %struct.s2n_debug_info, ptr %133, i32 0, i32 1
  store ptr %132, ptr %134, align 8, !tbaa !11
  %135 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %135, align 4, !tbaa !12
  %136 = call i32 @s2n_calculate_stacktrace()
  br label %137

137:                                              ; preds = %131
  br label %138

138:                                              ; preds = %137
  %139 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 -1, ptr %139, align 4, !tbaa !14
  store i32 1, ptr %7, align 4
  br label %210

140:                                              ; No predecessors!
  br label %141

141:                                              ; preds = %140
  br label %142

142:                                              ; preds = %141, %105
  br label %143

143:                                              ; preds = %142
  br label %144

144:                                              ; preds = %143
  br label %145

145:                                              ; preds = %144
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #9
  %146 = load i8, ptr %8, align 1, !tbaa !16
  store i8 %146, ptr %11, align 1, !tbaa !16
  %147 = load i8, ptr %11, align 1, !tbaa !16
  %148 = icmp ne i8 %147, 0
  %149 = xor i1 %148, true
  %150 = xor i1 %149, true
  %151 = zext i1 %150 to i32
  %152 = sext i32 %151 to i64
  %153 = call i64 @llvm.expect.i64(i64 %152, i64 1)
  %154 = icmp ne i64 %153, 0
  br i1 %154, label %155, label %203

155:                                              ; preds = %145
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #9
  %156 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %156, ptr %12, align 8, !tbaa !5
  br label %157

157:                                              ; preds = %155
  %158 = load ptr, ptr %12, align 8, !tbaa !5
  %159 = icmp ne ptr %158, null
  br i1 %159, label %194, label %160

160:                                              ; preds = %157
  br label %161

161:                                              ; preds = %160
  br label %162

162:                                              ; preds = %161
  %163 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %164 = getelementptr inbounds %struct.s2n_debug_info, ptr %163, i32 0, i32 0
  store ptr @.str.3, ptr %164, align 8, !tbaa !9
  %165 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %166 = getelementptr inbounds %struct.s2n_debug_info, ptr %165, i32 0, i32 0
  %167 = load ptr, ptr %166, align 8, !tbaa !9
  %168 = getelementptr inbounds i8, ptr %167, i64 21
  %169 = call ptr @strrchr(ptr noundef %168, i32 noundef 47) #8
  %170 = icmp ne ptr %169, null
  br i1 %170, label %171, label %178

171:                                              ; preds = %162
  %172 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %173 = getelementptr inbounds %struct.s2n_debug_info, ptr %172, i32 0, i32 0
  %174 = load ptr, ptr %173, align 8, !tbaa !9
  %175 = getelementptr inbounds i8, ptr %174, i64 21
  %176 = call ptr @strrchr(ptr noundef %175, i32 noundef 47) #8
  %177 = getelementptr inbounds i8, ptr %176, i64 1
  br label %183

178:                                              ; preds = %162
  %179 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %180 = getelementptr inbounds %struct.s2n_debug_info, ptr %179, i32 0, i32 0
  %181 = load ptr, ptr %180, align 8, !tbaa !9
  %182 = getelementptr inbounds i8, ptr %181, i64 21
  br label %183

183:                                              ; preds = %178, %171
  %184 = phi ptr [ %177, %171 ], [ %182, %178 ]
  %185 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %186 = getelementptr inbounds %struct.s2n_debug_info, ptr %185, i32 0, i32 1
  store ptr %184, ptr %186, align 8, !tbaa !11
  %187 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %187, align 4, !tbaa !12
  %188 = call i32 @s2n_calculate_stacktrace()
  br label %189

189:                                              ; preds = %183
  br label %190

190:                                              ; preds = %189
  %191 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 -1, ptr %191, align 4, !tbaa !14
  store i32 1, ptr %7, align 4
  br label %200

192:                                              ; No predecessors!
  br label %193

193:                                              ; preds = %192
  br label %194

194:                                              ; preds = %193, %157
  br label %195

195:                                              ; preds = %194
  br label %196

196:                                              ; preds = %195
  %197 = load ptr, ptr %12, align 8, !tbaa !5
  %198 = load i8, ptr %11, align 1, !tbaa !16
  %199 = zext i8 %198 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %197, i8 0, i64 %199, i1 false)
  store i32 0, ptr %7, align 4
  br label %200

200:                                              ; preds = %196, %190
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #9
  %201 = load i32, ptr %7, align 4
  switch i32 %201, label %204 [
    i32 0, label %202
  ]

202:                                              ; preds = %200
  br label %203

203:                                              ; preds = %202, %145
  store i32 0, ptr %7, align 4
  br label %204

204:                                              ; preds = %203, %200
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #9
  %205 = load i32, ptr %7, align 4
  switch i32 %205, label %210 [
    i32 0, label %206
  ]

206:                                              ; preds = %204
  br label %207

207:                                              ; preds = %206
  br label %208

208:                                              ; preds = %207
  %209 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 0, ptr %209, align 4, !tbaa !14
  store i32 1, ptr %7, align 4
  br label %210

210:                                              ; preds = %208, %204, %138
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #9
  br label %211

211:                                              ; preds = %210, %96, %86
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #9
  br label %212

212:                                              ; preds = %211, %74, %60
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #9
  br label %213

213:                                              ; preds = %212, %45
  %214 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  %215 = load i32, ptr %214, align 4
  ret i32 %215
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

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

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

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

declare ptr @s2n_stuffer_raw_write(ptr noundef, i32 noundef) #3

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

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

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { 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, !6, i64 0}
!10 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!11 = !{!10, !6, i64 8}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 0}
!15 = !{!"", !13, i64 0}
!16 = !{!7, !7, i64 0}


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

%struct.s2n_debug_info = type { ptr, ptr }

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

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

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

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

declare i32 @s2n_calculate_stacktrace() local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_write_npn_protocol(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca i8, align 1
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %12

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

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %0, i64 2528
  %14 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %13) #7
  %15 = trunc i64 %14 to i8
  %16 = tail call i32 @s2n_stuffer_write_uint8(ptr noundef %1, i8 noundef zeroext %15) #8
  %17 = icmp sgt i32 %16, -1
  br i1 %17, label %18, label %47

18:                                               ; preds = %12
  %19 = trunc i64 %14 to i32
  %20 = and i32 %19, 255
  %21 = tail call i32 @s2n_stuffer_write_bytes(ptr noundef %1, ptr noundef nonnull %13, i32 noundef %20) #8
  %22 = icmp sgt i32 %21, -1
  br i1 %22, label %23, label %47

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #8
  store i8 0, ptr %3, align 1, !tbaa !13
  %24 = call i32 @s2n_calculate_padding(i8 noundef zeroext %15, ptr noundef nonnull %3)
  %25 = call zeroext i1 @s2n_result_is_ok(i32 %24)
  br i1 %25, label %26, label %46

26:                                               ; preds = %23
  %27 = load i8, ptr %3, align 1, !tbaa !13
  %28 = call i32 @s2n_stuffer_write_uint8(ptr noundef %1, i8 noundef zeroext %27) #8
  %29 = icmp sgt i32 %28, -1
  br i1 %29, label %30, label %46

30:                                               ; preds = %26
  %31 = load i8, ptr %3, align 1, !tbaa !13
  %32 = zext i8 %31 to i32
  %33 = call ptr @s2n_stuffer_raw_write(ptr noundef %1, i32 noundef %32) #8
  %.not26 = icmp eq ptr %33, null
  br i1 %.not26, label %34, label %42

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

42:                                               ; preds = %30
  %43 = load i8, ptr %3, align 1, !tbaa !13
  %.not28 = icmp eq i8 %43, 0
  br i1 %.not28, label %46, label %44, !prof !14

44:                                               ; preds = %42
  %45 = zext i8 %43 to i64
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %33, i8 0, i64 %45, i1 false)
  br label %46

46:                                               ; preds = %34, %44, %42, %26, %23
  %.sroa.018.4 = phi i32 [ -1, %23 ], [ -1, %26 ], [ -1, %34 ], [ 0, %44 ], [ 0, %42 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #8
  br label %47

47:                                               ; preds = %46, %12, %18, %4
  %.sroa.018.6 = phi i32 [ -1, %4 ], [ %.sroa.018.4, %46 ], [ -1, %12 ], [ -1, %18 ]
  ret i32 %.sroa.018.6
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2

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

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

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

declare ptr @s2n_stuffer_raw_write(ptr noundef, i32 noundef) local_unnamed_addr #3

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

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !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 = !{!"branch_weights", !"expected", i32 1, i32 2000}


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