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

; 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_array = type { %struct.s2n_blob, i32, i32 }
%struct.s2n_blob = type { ptr, i32, i32, i8 }

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_array_validate(ptr noundef) #0

; 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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @s2n_array_enlarge(ptr noundef, i32 noundef) #0

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

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

18:                                               ; preds = %3
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call i32 @s2n_array_validate(ptr noundef %19)
  %21 = getelementptr inbounds %struct.s2n_result, ptr %9, i32 0, i32 0
  store i32 %20, ptr %21, align 4
  %22 = getelementptr inbounds %struct.s2n_result, ptr %9, i32 0, i32 0
  %23 = load i32, ptr %22, align 4
  %24 = call zeroext i1 @s2n_result_is_ok(i32 %23)
  %25 = xor i1 %24, true
  %26 = xor i1 %25, true
  %27 = zext i1 %26 to i32
  %28 = sext i32 %27 to i64
  %29 = call i64 @llvm.expect.i64(i64 %28, i64 1)
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %31, label %33

31:                                               ; preds = %18
  %32 = getelementptr inbounds %struct.s2n_result, ptr %8, i32 0, i32 0
  store i32 0, ptr %32, align 4, !tbaa !11
  br label %35

33:                                               ; preds = %18
  %34 = getelementptr inbounds %struct.s2n_result, ptr %8, i32 0, i32 0
  store i32 -1, ptr %34, align 4, !tbaa !11
  br label %35

35:                                               ; preds = %33, %31
  %36 = getelementptr inbounds %struct.s2n_result, ptr %8, i32 0, i32 0
  %37 = load i32, ptr %36, align 4
  %38 = call zeroext i1 @s2n_result_is_ok(i32 %37)
  br i1 %38, label %41, label %39

39:                                               ; preds = %35
  %40 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %40, align 4, !tbaa !11
  br label %266

41:                                               ; preds = %35
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %78, label %46

46:                                               ; preds = %43
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  %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 0
  store ptr @.str.11, ptr %50, align 8, !tbaa !13
  %51 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %52 = getelementptr inbounds %struct.s2n_debug_info, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !13
  %54 = getelementptr inbounds i8, ptr %53, i64 21
  %55 = call ptr @strrchr(ptr noundef %54, i32 noundef 47) #8
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %64

57:                                               ; preds = %48
  %58 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %59 = getelementptr inbounds %struct.s2n_debug_info, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !13
  %61 = getelementptr inbounds i8, ptr %60, i64 21
  %62 = call ptr @strrchr(ptr noundef %61, i32 noundef 47) #8
  %63 = getelementptr inbounds i8, ptr %62, i64 1
  br label %69

64:                                               ; preds = %48
  %65 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %66 = getelementptr inbounds %struct.s2n_debug_info, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !13
  %68 = getelementptr inbounds i8, ptr %67, i64 21
  br label %69

69:                                               ; preds = %64, %57
  %70 = phi ptr [ %63, %57 ], [ %68, %64 ]
  %71 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %72 = getelementptr inbounds %struct.s2n_debug_info, ptr %71, i32 0, i32 1
  store ptr %70, ptr %72, align 8, !tbaa !15
  %73 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %73, align 4, !tbaa !9
  %74 = call i32 @s2n_calculate_stacktrace()
  br label %75

75:                                               ; preds = %69
  %76 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %76, align 4, !tbaa !11
  br label %266

77:                                               ; No predecessors!
  br label %78

78:                                               ; preds = %77, %43
  br label %79

79:                                               ; preds = %78
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %6, align 4, !tbaa !9
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.s2n_array, ptr %82, i32 0, i32 1
  %84 = load i32, ptr %83, align 8, !tbaa !16
  %85 = icmp ule i32 %81, %84
  br i1 %85, label %118, label %86

86:                                               ; preds = %80
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  %89 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %90 = getelementptr inbounds %struct.s2n_debug_info, ptr %89, i32 0, i32 0
  store ptr @.str.12, ptr %90, align 8, !tbaa !13
  %91 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %92 = getelementptr inbounds %struct.s2n_debug_info, ptr %91, i32 0, i32 0
  %93 = load ptr, ptr %92, align 8, !tbaa !13
  %94 = getelementptr inbounds i8, ptr %93, i64 21
  %95 = call ptr @strrchr(ptr noundef %94, i32 noundef 47) #8
  %96 = icmp ne ptr %95, null
  br i1 %96, label %97, label %104

97:                                               ; preds = %88
  %98 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %99 = getelementptr inbounds %struct.s2n_debug_info, ptr %98, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8, !tbaa !13
  %101 = getelementptr inbounds i8, ptr %100, i64 21
  %102 = call ptr @strrchr(ptr noundef %101, i32 noundef 47) #8
  %103 = getelementptr inbounds i8, ptr %102, i64 1
  br label %109

104:                                              ; preds = %88
  %105 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %106 = getelementptr inbounds %struct.s2n_debug_info, ptr %105, i32 0, i32 0
  %107 = load ptr, ptr %106, align 8, !tbaa !13
  %108 = getelementptr inbounds i8, ptr %107, i64 21
  br label %109

109:                                              ; preds = %104, %97
  %110 = phi ptr [ %103, %97 ], [ %108, %104 ]
  %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 1
  store ptr %110, ptr %112, align 8, !tbaa !15
  %113 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653252, ptr %113, align 4, !tbaa !9
  %114 = call i32 @s2n_calculate_stacktrace()
  br label %115

115:                                              ; preds = %109
  %116 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %116, align 4, !tbaa !11
  br label %266

117:                                              ; No predecessors!
  br label %118

118:                                              ; preds = %117, %80
  br label %119

119:                                              ; preds = %118
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #9
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %120

120:                                              ; preds = %119
  %121 = load ptr, ptr %5, align 8, !tbaa !5
  %122 = call i32 @s2n_array_capacity(ptr noundef %121, ptr noundef %10)
  %123 = getelementptr inbounds %struct.s2n_result, ptr %11, i32 0, i32 0
  store i32 %122, ptr %123, align 4
  %124 = getelementptr inbounds %struct.s2n_result, ptr %11, i32 0, i32 0
  %125 = load i32, ptr %124, align 4
  %126 = call zeroext i1 @s2n_result_is_ok(i32 %125)
  br i1 %126, label %129, label %127

127:                                              ; preds = %120
  %128 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %128, align 4, !tbaa !11
  store i32 1, ptr %12, align 4
  br label %265

129:                                              ; preds = %120
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %130
  %132 = load ptr, ptr %5, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.s2n_array, ptr %132, i32 0, i32 1
  %134 = load i32, ptr %133, align 8, !tbaa !16
  %135 = load i32, ptr %10, align 4, !tbaa !9
  %136 = icmp uge i32 %134, %135
  br i1 %136, label %137, label %170

137:                                              ; preds = %131
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #9
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %138

138:                                              ; preds = %137
  %139 = load i32, ptr %10, align 4, !tbaa !9
  %140 = call i32 @s2n_mul_overflow(i32 noundef %139, i32 noundef 2, ptr noundef %13)
  %141 = icmp sgt i32 %140, -1
  br i1 %141, label %144, label %142

142:                                              ; preds = %138
  %143 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %143, align 4, !tbaa !11
  store i32 1, ptr %12, align 4
  br label %167

144:                                              ; preds = %138
  br label %145

145:                                              ; preds = %144
  br label %146

146:                                              ; preds = %145
  %147 = load i32, ptr %13, align 4, !tbaa !9
  %148 = icmp ugt i32 %147, 16
  br i1 %148, label %149, label %151

149:                                              ; preds = %146
  %150 = load i32, ptr %13, align 4, !tbaa !9
  br label %152

151:                                              ; preds = %146
  br label %152

152:                                              ; preds = %151, %149
  %153 = phi i32 [ %150, %149 ], [ 16, %151 ]
  store i32 %153, ptr %13, align 4, !tbaa !9
  br label %154

154:                                              ; preds = %152
  %155 = load ptr, ptr %5, align 8, !tbaa !5
  %156 = load i32, ptr %13, align 4, !tbaa !9
  %157 = call i32 @s2n_array_enlarge(ptr noundef %155, i32 noundef %156)
  %158 = getelementptr inbounds %struct.s2n_result, ptr %14, i32 0, i32 0
  store i32 %157, ptr %158, align 4
  %159 = getelementptr inbounds %struct.s2n_result, ptr %14, i32 0, i32 0
  %160 = load i32, ptr %159, align 4
  %161 = call zeroext i1 @s2n_result_is_ok(i32 %160)
  br i1 %161, label %164, label %162

162:                                              ; preds = %154
  %163 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %163, align 4, !tbaa !11
  store i32 1, ptr %12, align 4
  br label %167

164:                                              ; preds = %154
  br label %165

165:                                              ; preds = %164
  br label %166

166:                                              ; preds = %165
  store i32 0, ptr %12, align 4
  br label %167

167:                                              ; preds = %166, %162, %142
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  %168 = load i32, ptr %12, align 4
  switch i32 %168, label %265 [
    i32 0, label %169
  ]

169:                                              ; preds = %167
  br label %170

170:                                              ; preds = %169, %131
  %171 = load i32, ptr %6, align 4, !tbaa !9
  %172 = load ptr, ptr %5, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.s2n_array, ptr %172, i32 0, i32 1
  %174 = load i32, ptr %173, align 8, !tbaa !16
  %175 = icmp ult i32 %171, %174
  br i1 %175, label %176, label %221

176:                                              ; preds = %170
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #9
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %177

177:                                              ; preds = %176
  %178 = load ptr, ptr %5, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.s2n_array, ptr %178, i32 0, i32 1
  %180 = load i32, ptr %179, align 8, !tbaa !16
  %181 = load i32, ptr %6, align 4, !tbaa !9
  %182 = sub i32 %180, %181
  %183 = load ptr, ptr %5, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.s2n_array, ptr %183, i32 0, i32 2
  %185 = load i32, ptr %184, align 4, !tbaa !19
  %186 = call i32 @s2n_mul_overflow(i32 noundef %182, i32 noundef %185, ptr noundef %15)
  %187 = icmp sgt i32 %186, -1
  br i1 %187, label %190, label %188

188:                                              ; preds = %177
  %189 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %189, align 4, !tbaa !11
  store i32 1, ptr %12, align 4
  br label %218

190:                                              ; preds = %177
  br label %191

191:                                              ; preds = %190
  br label %192

192:                                              ; preds = %191
  %193 = load ptr, ptr %5, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.s2n_array, ptr %193, i32 0, i32 0
  %195 = getelementptr inbounds %struct.s2n_blob, ptr %194, i32 0, i32 0
  %196 = load ptr, ptr %195, align 8, !tbaa !20
  %197 = load ptr, ptr %5, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.s2n_array, ptr %197, i32 0, i32 2
  %199 = load i32, ptr %198, align 4, !tbaa !19
  %200 = load i32, ptr %6, align 4, !tbaa !9
  %201 = add i32 %200, 1
  %202 = mul i32 %199, %201
  %203 = zext i32 %202 to i64
  %204 = getelementptr inbounds i8, ptr %196, i64 %203
  %205 = load ptr, ptr %5, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.s2n_array, ptr %205, i32 0, i32 0
  %207 = getelementptr inbounds %struct.s2n_blob, ptr %206, i32 0, i32 0
  %208 = load ptr, ptr %207, align 8, !tbaa !20
  %209 = load ptr, ptr %5, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct.s2n_array, ptr %209, i32 0, i32 2
  %211 = load i32, ptr %210, align 4, !tbaa !19
  %212 = load i32, ptr %6, align 4, !tbaa !9
  %213 = mul i32 %211, %212
  %214 = zext i32 %213 to i64
  %215 = getelementptr inbounds i8, ptr %208, i64 %214
  %216 = load i32, ptr %15, align 4, !tbaa !9
  %217 = zext i32 %216 to i64
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %204, ptr align 1 %215, i64 %217, i1 false)
  store i32 0, ptr %12, align 4
  br label %218

218:                                              ; preds = %192, %188
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  %219 = load i32, ptr %12, align 4
  switch i32 %219, label %265 [
    i32 0, label %220
  ]

220:                                              ; preds = %218
  br label %221

221:                                              ; preds = %220, %170
  %222 = load ptr, ptr %5, align 8, !tbaa !5
  %223 = getelementptr inbounds %struct.s2n_array, ptr %222, i32 0, i32 0
  %224 = getelementptr inbounds %struct.s2n_blob, ptr %223, i32 0, i32 0
  %225 = load ptr, ptr %224, align 8, !tbaa !20
  %226 = load ptr, ptr %5, align 8, !tbaa !5
  %227 = getelementptr inbounds %struct.s2n_array, ptr %226, i32 0, i32 2
  %228 = load i32, ptr %227, align 4, !tbaa !19
  %229 = load i32, ptr %6, align 4, !tbaa !9
  %230 = mul i32 %228, %229
  %231 = zext i32 %230 to i64
  %232 = getelementptr inbounds i8, ptr %225, i64 %231
  %233 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %232, ptr %233, align 8, !tbaa !5
  %234 = load ptr, ptr %5, align 8, !tbaa !5
  %235 = getelementptr inbounds %struct.s2n_array, ptr %234, i32 0, i32 1
  %236 = load i32, ptr %235, align 8, !tbaa !16
  %237 = add i32 %236, 1
  store i32 %237, ptr %235, align 8, !tbaa !16
  br label %238

238:                                              ; preds = %221
  %239 = load ptr, ptr %5, align 8, !tbaa !5
  %240 = call i32 @s2n_array_validate(ptr noundef %239)
  %241 = getelementptr inbounds %struct.s2n_result, ptr %17, i32 0, i32 0
  store i32 %240, ptr %241, align 4
  %242 = getelementptr inbounds %struct.s2n_result, ptr %17, i32 0, i32 0
  %243 = load i32, ptr %242, align 4
  %244 = call zeroext i1 @s2n_result_is_ok(i32 %243)
  %245 = xor i1 %244, true
  %246 = xor i1 %245, true
  %247 = zext i1 %246 to i32
  %248 = sext i32 %247 to i64
  %249 = call i64 @llvm.expect.i64(i64 %248, i64 1)
  %250 = icmp ne i64 %249, 0
  br i1 %250, label %251, label %253

251:                                              ; preds = %238
  %252 = getelementptr inbounds %struct.s2n_result, ptr %16, i32 0, i32 0
  store i32 0, ptr %252, align 4, !tbaa !11
  br label %255

253:                                              ; preds = %238
  %254 = getelementptr inbounds %struct.s2n_result, ptr %16, i32 0, i32 0
  store i32 -1, ptr %254, align 4, !tbaa !11
  br label %255

255:                                              ; preds = %253, %251
  %256 = getelementptr inbounds %struct.s2n_result, ptr %16, i32 0, i32 0
  %257 = load i32, ptr %256, align 4
  %258 = call zeroext i1 @s2n_result_is_ok(i32 %257)
  br i1 %258, label %261, label %259

259:                                              ; preds = %255
  %260 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %260, align 4, !tbaa !11
  store i32 1, ptr %12, align 4
  br label %265

261:                                              ; preds = %255
  br label %262

262:                                              ; preds = %261
  br label %263

263:                                              ; preds = %262
  %264 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 0, ptr %264, align 4, !tbaa !11
  store i32 1, ptr %12, align 4
  br label %265

265:                                              ; preds = %263, %259, %218, %167, %127
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #9
  br label %266

266:                                              ; preds = %265, %115, %75, %39
  %267 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  %268 = load i32, ptr %267, align 4
  ret i32 %268
}

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

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

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 = { 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: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = !{!17, !10, i64 24}
!17 = !{!"s2n_array", !18, i64 0, !10, i64 24, !10, i64 28}
!18 = !{!"s2n_blob", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!19 = !{!17, !10, i64 28}
!20 = !{!17, !6, 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.11 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [88 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_array_validate(ptr noundef) local_unnamed_addr #0

; 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

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

declare i32 @s2n_mul_overflow(i32 noundef, i32 noundef, 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

; Function Attrs: nounwind uwtable
declare hidden i32 @s2n_array_enlarge(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_array_insert(ptr noundef %0, i32 noundef %1, ptr noundef writeonly %2) local_unnamed_addr #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = tail call i32 @s2n_array_validate(ptr noundef %0)
  %8 = tail call zeroext i1 @s2n_result_is_ok(i32 %7)
  %not. = xor i1 %8, true
  %. = sext i1 %not. to i32
  %9 = tail call zeroext i1 @s2n_result_is_ok(i32 %.)
  br i1 %9, label %10, label %78

10:                                               ; preds = %3
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %11, label %19

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

19:                                               ; preds = %10
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %.not37 = icmp ult i32 %21, %1
  br i1 %.not37, label %22, label %30

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

30:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #9
  store i32 0, ptr %4, align 4, !tbaa !11
  %31 = call i32 @s2n_array_capacity(ptr noundef nonnull %0, ptr noundef nonnull %4)
  %32 = call zeroext i1 @s2n_result_is_ok(i32 %31)
  br i1 %32, label %33, label %77

33:                                               ; preds = %30
  %34 = load i32, ptr %20, align 8, !tbaa !13
  %35 = load i32, ptr %4, align 4, !tbaa !11
  %.not39 = icmp ult i32 %34, %35
  br i1 %.not39, label %44, label %36

36:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #9
  store i32 0, ptr %5, align 4, !tbaa !11
  %37 = call i32 @s2n_mul_overflow(i32 noundef %35, i32 noundef 2, ptr noundef nonnull %5) #9
  %38 = icmp sgt i32 %37, -1
  br i1 %38, label %39, label %.critedge

39:                                               ; preds = %36
  %40 = load i32, ptr %5, align 4
  %41 = call i32 @llvm.umax.i32(i32 %40, i32 16)
  store i32 %41, ptr %5, align 4, !tbaa !11
  %42 = call i32 @s2n_array_enlarge(ptr noundef nonnull %0, i32 noundef %41)
  %43 = call zeroext i1 @s2n_result_is_ok(i32 %42)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #9
  br i1 %43, label %._crit_edge, label %77

._crit_edge:                                      ; preds = %39
  %.pre = load i32, ptr %20, align 8, !tbaa !13
  br label %44

44:                                               ; preds = %._crit_edge, %33
  %45 = phi i32 [ %.pre, %._crit_edge ], [ %34, %33 ]
  %46 = icmp ugt i32 %45, %1
  br i1 %46, label %47, label %65

47:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #9
  store i32 0, ptr %6, align 4, !tbaa !11
  %48 = sub i32 %45, %1
  %49 = getelementptr inbounds i8, ptr %0, i64 28
  %50 = load i32, ptr %49, align 4, !tbaa !16
  %51 = call i32 @s2n_mul_overflow(i32 noundef %48, i32 noundef %50, ptr noundef nonnull %6) #9
  %52 = icmp sgt i32 %51, -1
  br i1 %52, label %53, label %.critedge42

53:                                               ; preds = %47
  %54 = load ptr, ptr %0, align 8, !tbaa !17
  %55 = load i32, ptr %49, align 4, !tbaa !16
  %56 = add nuw i32 %1, 1
  %57 = mul i32 %55, %56
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %54, i64 %58
  %60 = mul i32 %55, %1
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds i8, ptr %54, i64 %61
  %63 = load i32, ptr %6, align 4, !tbaa !11
  %64 = zext i32 %63 to i64
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %59, ptr align 1 %62, i64 %64, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #9
  %.pre46 = load i32, ptr %20, align 8, !tbaa !13
  br label %65

65:                                               ; preds = %53, %44
  %66 = phi i32 [ %.pre46, %53 ], [ %45, %44 ]
  %67 = load ptr, ptr %0, align 8, !tbaa !17
  %68 = getelementptr inbounds i8, ptr %0, i64 28
  %69 = load i32, ptr %68, align 4, !tbaa !16
  %70 = mul i32 %69, %1
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds i8, ptr %67, i64 %71
  store ptr %72, ptr %2, align 8, !tbaa !18
  %73 = add i32 %66, 1
  store i32 %73, ptr %20, align 8, !tbaa !13
  %74 = call i32 @s2n_array_validate(ptr noundef nonnull %0)
  %75 = call zeroext i1 @s2n_result_is_ok(i32 %74)
  %not.44 = xor i1 %75, true
  %.43 = sext i1 %not.44 to i32
  %76 = call zeroext i1 @s2n_result_is_ok(i32 %.43)
  %not.45 = xor i1 %76, true
  %spec.select = sext i1 %not.45 to i32
  br label %77

.critedge:                                        ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #9
  br label %77

.critedge42:                                      ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #9
  br label %77

77:                                               ; preds = %65, %.critedge42, %.critedge, %30, %39
  %.sroa.031.3 = phi i32 [ -1, %39 ], [ -1, %30 ], [ -1, %.critedge ], [ -1, %.critedge42 ], [ %spec.select, %65 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #9
  br label %78

78:                                               ; preds = %3, %77, %22, %11
  %.sroa.031.4 = phi i32 [ %.sroa.031.3, %77 ], [ -1, %22 ], [ -1, %11 ], [ -1, %3 ]
  ret i32 %.sroa.031.4
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #7

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 = { 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: readwrite) }
attributes #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !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 24}
!14 = !{!"s2n_array", !15, i64 0, !12, i64 24, !12, i64 28}
!15 = !{!"s2n_blob", !7, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!16 = !{!14, !12, i64 28}
!17 = !{!14, !7, i64 0}
!18 = !{!7, !7, i64 0}


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