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

; 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_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 }

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

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_sslv2_record_header_parse(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca [2 x i8], align 1
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.s2n_connection, ptr %13, i32 0, i32 38
  store ptr %14, ptr %10, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %4
  %16 = load ptr, ptr %10, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.s2n_stuffer, ptr %16, i32 0, i32 2
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = load ptr, ptr %10, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.s2n_stuffer, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %22 = sub i32 %18, %21
  %23 = icmp uge i32 %22, 5
  br i1 %23, label %57, label %24

24:                                               ; preds = %15
  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, ptr %28, align 8, !tbaa !14
  %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 !14
  %32 = getelementptr inbounds i8, ptr %31, i64 21
  %33 = call ptr @strrchr(ptr noundef %32, i32 noundef 47) #7
  %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 !14
  %39 = getelementptr inbounds i8, ptr %38, i64 21
  %40 = call ptr @strrchr(ptr noundef %39, i32 noundef 47) #7
  %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 !14
  %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 !16
  %51 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544322, ptr %51, align 4, !tbaa !17
  %52 = call i32 @s2n_calculate_stacktrace()
  br label %53

53:                                               ; preds = %47
  br label %54

54:                                               ; preds = %53
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %213

55:                                               ; No predecessors!
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56, %15
  br label %58

58:                                               ; preds = %57
  br label %59

59:                                               ; preds = %58
  br label %60

60:                                               ; preds = %59
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = call i32 @s2n_stuffer_read_uint16(ptr noundef %61, ptr noundef %62)
  %64 = icmp sgt i32 %63, -1
  br i1 %64, label %66, label %65

65:                                               ; preds = %60
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %213

66:                                               ; preds = %60
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %68
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = load i16, ptr %70, align 2, !tbaa !18
  %72 = zext i16 %71 to i32
  %73 = and i32 %72, 32768
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %108, label %75

75:                                               ; preds = %69
  br label %76

76:                                               ; preds = %75
  br label %77

77:                                               ; preds = %76
  %78 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %79 = getelementptr inbounds %struct.s2n_debug_info, ptr %78, i32 0, i32 0
  store ptr @.str.1, ptr %79, align 8, !tbaa !14
  %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 !14
  %83 = getelementptr inbounds i8, ptr %82, i64 21
  %84 = call ptr @strrchr(ptr noundef %83, i32 noundef 47) #7
  %85 = icmp ne ptr %84, null
  br i1 %85, label %86, label %93

86:                                               ; preds = %77
  %87 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %88 = getelementptr inbounds %struct.s2n_debug_info, ptr %87, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8, !tbaa !14
  %90 = getelementptr inbounds i8, ptr %89, i64 21
  %91 = call ptr @strrchr(ptr noundef %90, i32 noundef 47) #7
  %92 = getelementptr inbounds i8, ptr %91, i64 1
  br label %98

93:                                               ; preds = %77
  %94 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %95 = getelementptr inbounds %struct.s2n_debug_info, ptr %94, i32 0, i32 0
  %96 = load ptr, ptr %95, align 8, !tbaa !14
  %97 = getelementptr inbounds i8, ptr %96, i64 21
  br label %98

98:                                               ; preds = %93, %86
  %99 = phi ptr [ %92, %86 ], [ %97, %93 ]
  %100 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %101 = getelementptr inbounds %struct.s2n_debug_info, ptr %100, i32 0, i32 1
  store ptr %99, ptr %101, align 8, !tbaa !16
  %102 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544322, ptr %102, align 4, !tbaa !17
  %103 = call i32 @s2n_calculate_stacktrace()
  br label %104

104:                                              ; preds = %98
  br label %105

105:                                              ; preds = %104
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %213

106:                                              ; No predecessors!
  br label %107

107:                                              ; preds = %106
  br label %108

108:                                              ; preds = %107, %69
  br label %109

109:                                              ; preds = %108
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr %9, align 8, !tbaa !5
  %112 = load i16, ptr %111, align 2, !tbaa !18
  %113 = zext i16 %112 to i32
  %114 = xor i32 %113, 32768
  %115 = trunc i32 %114 to i16
  store i16 %115, ptr %111, align 2, !tbaa !18
  br label %116

116:                                              ; preds = %110
  %117 = load ptr, ptr %9, align 8, !tbaa !5
  %118 = load i16, ptr %117, align 2, !tbaa !18
  %119 = zext i16 %118 to i32
  %120 = load ptr, ptr %10, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.s2n_stuffer, ptr %120, i32 0, i32 2
  %122 = load i32, ptr %121, align 4, !tbaa !9
  %123 = load ptr, ptr %10, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.s2n_stuffer, ptr %123, i32 0, i32 1
  %125 = load i32, ptr %124, align 8, !tbaa !13
  %126 = sub i32 %122, %125
  %127 = icmp uge i32 %119, %126
  br i1 %127, label %161, label %128

128:                                              ; preds = %116
  br label %129

129:                                              ; preds = %128
  br label %130

130:                                              ; preds = %129
  %131 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %132 = getelementptr inbounds %struct.s2n_debug_info, ptr %131, i32 0, i32 0
  store ptr @.str.2, ptr %132, align 8, !tbaa !14
  %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 0
  %135 = load ptr, ptr %134, align 8, !tbaa !14
  %136 = getelementptr inbounds i8, ptr %135, i64 21
  %137 = call ptr @strrchr(ptr noundef %136, i32 noundef 47) #7
  %138 = icmp ne ptr %137, null
  br i1 %138, label %139, label %146

139:                                              ; preds = %130
  %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 !14
  %143 = getelementptr inbounds i8, ptr %142, i64 21
  %144 = call ptr @strrchr(ptr noundef %143, i32 noundef 47) #7
  %145 = getelementptr inbounds i8, ptr %144, i64 1
  br label %151

146:                                              ; preds = %130
  %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 !14
  %150 = getelementptr inbounds i8, ptr %149, i64 21
  br label %151

151:                                              ; preds = %146, %139
  %152 = phi ptr [ %145, %139 ], [ %150, %146 ]
  %153 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %154 = getelementptr inbounds %struct.s2n_debug_info, ptr %153, i32 0, i32 1
  store ptr %152, ptr %154, align 8, !tbaa !16
  %155 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544322, ptr %155, align 4, !tbaa !17
  %156 = call i32 @s2n_calculate_stacktrace()
  br label %157

157:                                              ; preds = %151
  br label %158

158:                                              ; preds = %157
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %213

159:                                              ; No predecessors!
  br label %160

160:                                              ; preds = %159
  br label %161

161:                                              ; preds = %160, %116
  br label %162

162:                                              ; preds = %161
  br label %163

163:                                              ; preds = %162
  %164 = load ptr, ptr %10, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.s2n_stuffer, ptr %164, i32 0, i32 2
  %166 = load i32, ptr %165, align 4, !tbaa !9
  %167 = load ptr, ptr %10, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.s2n_stuffer, ptr %167, i32 0, i32 1
  %169 = load i32, ptr %168, align 8, !tbaa !13
  %170 = sub i32 %166, %169
  %171 = load ptr, ptr %9, align 8, !tbaa !5
  %172 = load i16, ptr %171, align 2, !tbaa !18
  %173 = zext i16 %172 to i32
  %174 = sub i32 %173, %170
  %175 = trunc i32 %174 to i16
  store i16 %175, ptr %171, align 2, !tbaa !18
  br label %176

176:                                              ; preds = %163
  %177 = load ptr, ptr %10, align 8, !tbaa !5
  %178 = load ptr, ptr %7, align 8, !tbaa !5
  %179 = call i32 @s2n_stuffer_read_uint8(ptr noundef %177, ptr noundef %178)
  %180 = icmp sgt i32 %179, -1
  br i1 %180, label %182, label %181

181:                                              ; preds = %176
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %213

182:                                              ; preds = %176
  br label %183

183:                                              ; preds = %182
  br label %184

184:                                              ; preds = %183
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #6
  call void @llvm.memset.p0.i64(ptr align 1 %12, i8 0, i64 2, i1 false)
  br label %185

185:                                              ; preds = %184
  %186 = load ptr, ptr %10, align 8, !tbaa !5
  %187 = getelementptr inbounds [2 x i8], ptr %12, i64 0, i64 0
  %188 = call i32 @s2n_stuffer_read_bytes(ptr noundef %186, ptr noundef %187, i32 noundef 2)
  %189 = icmp sgt i32 %188, -1
  br i1 %189, label %191, label %190

190:                                              ; preds = %185
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %212

191:                                              ; preds = %185
  br label %192

192:                                              ; preds = %191
  br label %193

193:                                              ; preds = %192
  %194 = getelementptr inbounds [2 x i8], ptr %12, i64 0, i64 0
  %195 = load i8, ptr %194, align 1, !tbaa !20
  %196 = zext i8 %195 to i32
  %197 = mul nsw i32 %196, 10
  %198 = getelementptr inbounds [2 x i8], ptr %12, i64 0, i64 1
  %199 = load i8, ptr %198, align 1, !tbaa !20
  %200 = zext i8 %199 to i32
  %201 = add nsw i32 %197, %200
  %202 = trunc i32 %201 to i8
  %203 = load ptr, ptr %8, align 8, !tbaa !5
  store i8 %202, ptr %203, align 1, !tbaa !20
  br label %204

204:                                              ; preds = %193
  %205 = load ptr, ptr %10, align 8, !tbaa !5
  %206 = call i32 @s2n_stuffer_reread(ptr noundef %205)
  %207 = icmp sgt i32 %206, -1
  br i1 %207, label %209, label %208

208:                                              ; preds = %204
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %212

209:                                              ; preds = %204
  br label %210

210:                                              ; preds = %209
  br label %211

211:                                              ; preds = %210
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %212

212:                                              ; preds = %211, %208, %190
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #6
  br label %213

213:                                              ; preds = %212, %181, %158, %105, %65, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %214 = load i32, ptr %5, align 4
  ret i32 %214
}

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

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

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

declare i32 @s2n_calculate_stacktrace() #4

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

declare i32 @s2n_stuffer_read_uint8(ptr 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

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

declare i32 @s2n_stuffer_reread(ptr noundef) #4

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

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

!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, !12, i64 28}
!10 = !{!"s2n_stuffer", !11, i64 0, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 36, !12, i64 36}
!11 = !{!"s2n_blob", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 24}
!14 = !{!15, !6, i64 0}
!15 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!16 = !{!15, !6, i64 8}
!17 = !{!12, !12, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = !{!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 }

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_sslv2_record_header_parse(ptr noundef %0, ptr noundef %1, ptr nocapture noundef writeonly %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca [2 x i8], align 2
  %6 = getelementptr inbounds i8, ptr %0, i64 1776
  %7 = getelementptr inbounds i8, ptr %0, i64 1804
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 1800
  %10 = load i32, ptr %9, align 8, !tbaa !12
  %11 = sub i32 %8, %10
  %12 = icmp ugt i32 %11, 4
  br i1 %12, label %21, label %13

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

21:                                               ; preds = %4
  %22 = tail call i32 @s2n_stuffer_read_uint16(ptr noundef nonnull %6, ptr noundef %3) #6
  %23 = icmp sgt i32 %22, -1
  br i1 %23, label %24, label %64

24:                                               ; preds = %21
  %25 = load i16, ptr %3, align 2, !tbaa !17
  %.not23 = icmp sgt i16 %25, -1
  br i1 %.not23, label %26, label %34

26:                                               ; preds = %24
  %27 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.1, ptr %27, align 8, !tbaa !13
  %28 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.1, i64 21), i32 noundef 47) #5
  %.not24 = icmp eq ptr %28, null
  %29 = getelementptr inbounds i8, ptr %28, i64 1
  %30 = select i1 %.not24, ptr getelementptr inbounds (i8, ptr @.str.1, i64 21), ptr %29
  %31 = getelementptr inbounds i8, ptr %27, i64 8
  store ptr %30, ptr %31, align 8, !tbaa !15
  %32 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544322, ptr %32, align 4, !tbaa !16
  %33 = tail call i32 @s2n_calculate_stacktrace() #6
  br label %64

34:                                               ; preds = %24
  %35 = and i16 %25, 32767
  store i16 %35, ptr %3, align 2, !tbaa !17
  %36 = zext nneg i16 %35 to i32
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = load i32, ptr %9, align 8, !tbaa !12
  %39 = sub i32 %37, %38
  %.not25 = icmp ugt i32 %39, %36
  br i1 %.not25, label %40, label %48

40:                                               ; preds = %34
  %41 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.2, ptr %41, align 8, !tbaa !13
  %42 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.2, i64 21), i32 noundef 47) #5
  %.not26 = icmp eq ptr %42, null
  %43 = getelementptr inbounds i8, ptr %42, i64 1
  %44 = select i1 %.not26, ptr getelementptr inbounds (i8, ptr @.str.2, i64 21), ptr %43
  %45 = getelementptr inbounds i8, ptr %41, i64 8
  store ptr %44, ptr %45, align 8, !tbaa !15
  %46 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544322, ptr %46, align 4, !tbaa !16
  %47 = tail call i32 @s2n_calculate_stacktrace() #6
  br label %64

48:                                               ; preds = %34
  %49 = trunc i32 %39 to i16
  %50 = sub nsw i16 %35, %49
  store i16 %50, ptr %3, align 2, !tbaa !17
  %51 = tail call i32 @s2n_stuffer_read_uint8(ptr noundef nonnull %6, ptr noundef %1) #6
  %52 = icmp sgt i32 %51, -1
  br i1 %52, label %53, label %64

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %5) #6
  store i16 0, ptr %5, align 2
  %54 = call i32 @s2n_stuffer_read_bytes(ptr noundef nonnull %6, ptr noundef nonnull %5, i32 noundef 2) #6
  %55 = icmp sgt i32 %54, -1
  br i1 %55, label %56, label %63

56:                                               ; preds = %53
  %57 = load i8, ptr %5, align 2, !tbaa !19
  %58 = mul i8 %57, 10
  %59 = getelementptr inbounds i8, ptr %5, i64 1
  %60 = load i8, ptr %59, align 1, !tbaa !19
  %61 = add i8 %58, %60
  store i8 %61, ptr %2, align 1, !tbaa !19
  %62 = call i32 @s2n_stuffer_reread(ptr noundef nonnull %6) #6
  %.lobit = ashr i32 %62, 31
  br label %63

63:                                               ; preds = %56, %53
  %.0 = phi i32 [ -1, %53 ], [ %.lobit, %56 ]
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %5) #6
  br label %64

64:                                               ; preds = %48, %21, %63, %40, %26, %13
  %.1 = phi i32 [ %.0, %63 ], [ -1, %40 ], [ -1, %26 ], [ -1, %13 ], [ -1, %21 ], [ -1, %48 ]
  ret i32 %.1
}

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

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

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

declare i32 @s2n_calculate_stacktrace() local_unnamed_addr #4

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

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

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

declare i32 @s2n_stuffer_reread(ptr noundef) local_unnamed_addr #4

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

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 willreturn memory(argmem: readwrite) }
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 willreturn memory(read) }
attributes #6 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !11, i64 28}
!6 = !{!"s2n_stuffer", !7, i64 0, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 36, !11, i64 36}
!7 = !{!"s2n_blob", !8, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!6, !11, i64 24}
!13 = !{!14, !8, i64 0}
!14 = !{!"s2n_debug_info", !8, i64 0, !8, i64 8}
!15 = !{!14, !8, i64 8}
!16 = !{!11, !11, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"short", !9, i64 0}
!19 = !{!9, !9, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass