; 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.13 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.14 = 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

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

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

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

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

27:                                               ; preds = %14
  %28 = getelementptr inbounds %struct.s2n_result, ptr %6, i32 0, i32 0
  store i32 0, ptr %28, align 4, !tbaa !11
  br label %31

29:                                               ; preds = %14
  %30 = getelementptr inbounds %struct.s2n_result, ptr %6, i32 0, i32 0
  store i32 -1, ptr %30, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %29, %27
  %32 = getelementptr inbounds %struct.s2n_result, ptr %6, i32 0, i32 0
  %33 = load i32, ptr %32, align 4
  %34 = call zeroext i1 @s2n_result_is_ok(i32 %33)
  br i1 %34, label %37, label %35

35:                                               ; preds = %31
  %36 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 -1, ptr %36, align 4, !tbaa !11
  br label %239

37:                                               ; preds = %31
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %5, align 4, !tbaa !9
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.s2n_array, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 8, !tbaa !13
  %44 = icmp ult i32 %40, %43
  br i1 %44, label %77, label %45

45:                                               ; preds = %39
  br label %46

46:                                               ; preds = %45
  br label %47

47:                                               ; preds = %46
  %48 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %49 = getelementptr inbounds %struct.s2n_debug_info, ptr %48, i32 0, i32 0
  store ptr @.str.13, ptr %49, align 8, !tbaa !16
  %50 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %51 = getelementptr inbounds %struct.s2n_debug_info, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = getelementptr inbounds i8, ptr %52, i64 21
  %54 = call ptr @strrchr(ptr noundef %53, i32 noundef 47) #9
  %55 = icmp ne ptr %54, null
  br i1 %55, label %56, label %63

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

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

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

74:                                               ; preds = %68
  %75 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 -1, ptr %75, align 4, !tbaa !11
  br label %239

76:                                               ; No predecessors!
  br label %77

77:                                               ; preds = %76, %39
  br label %78

78:                                               ; preds = %77
  %79 = load i32, ptr %5, align 4, !tbaa !9
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.s2n_array, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 8, !tbaa !13
  %83 = sub i32 %82, 1
  %84 = icmp ne i32 %79, %83
  br i1 %84, label %85, label %131

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

86:                                               ; preds = %85
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.s2n_array, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 8, !tbaa !13
  %90 = load i32, ptr %5, align 4, !tbaa !9
  %91 = sub i32 %89, %90
  %92 = sub i32 %91, 1
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.s2n_array, ptr %93, i32 0, i32 2
  %95 = load i32, ptr %94, align 4, !tbaa !19
  %96 = call i32 @s2n_mul_overflow(i32 noundef %92, i32 noundef %95, ptr noundef %8)
  %97 = icmp sgt i32 %96, -1
  br i1 %97, label %100, label %98

98:                                               ; preds = %86
  %99 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 -1, ptr %99, align 4, !tbaa !11
  store i32 1, ptr %9, align 4
  br label %128

100:                                              ; preds = %86
  br label %101

101:                                              ; preds = %100
  br label %102

102:                                              ; preds = %101
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.s2n_array, ptr %103, i32 0, i32 0
  %105 = getelementptr inbounds %struct.s2n_blob, ptr %104, i32 0, i32 0
  %106 = load ptr, ptr %105, align 8, !tbaa !20
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.s2n_array, ptr %107, i32 0, i32 2
  %109 = load i32, ptr %108, align 4, !tbaa !19
  %110 = load i32, ptr %5, align 4, !tbaa !9
  %111 = mul i32 %109, %110
  %112 = zext i32 %111 to i64
  %113 = getelementptr inbounds i8, ptr %106, i64 %112
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.s2n_array, ptr %114, i32 0, i32 0
  %116 = getelementptr inbounds %struct.s2n_blob, ptr %115, i32 0, i32 0
  %117 = load ptr, ptr %116, align 8, !tbaa !20
  %118 = load ptr, ptr %4, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.s2n_array, ptr %118, i32 0, i32 2
  %120 = load i32, ptr %119, align 4, !tbaa !19
  %121 = load i32, ptr %5, align 4, !tbaa !9
  %122 = add i32 %121, 1
  %123 = mul i32 %120, %122
  %124 = zext i32 %123 to i64
  %125 = getelementptr inbounds i8, ptr %117, i64 %124
  %126 = load i32, ptr %8, align 4, !tbaa !9
  %127 = zext i32 %126 to i64
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %113, ptr align 1 %125, i64 %127, i1 false)
  store i32 0, ptr %9, align 4
  br label %128

128:                                              ; preds = %102, %98
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #10
  %129 = load i32, ptr %9, align 4
  switch i32 %129, label %242 [
    i32 0, label %130
    i32 1, label %239
  ]

130:                                              ; preds = %128
  br label %131

131:                                              ; preds = %130, %78
  %132 = load ptr, ptr %4, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.s2n_array, ptr %132, i32 0, i32 1
  %134 = load i32, ptr %133, align 8, !tbaa !13
  %135 = add i32 %134, -1
  store i32 %135, ptr %133, align 8, !tbaa !13
  br label %136

136:                                              ; preds = %131
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #10
  %137 = load ptr, ptr %4, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.s2n_array, ptr %137, i32 0, i32 2
  %139 = load i32, ptr %138, align 4, !tbaa !19
  store i32 %139, ptr %10, align 4, !tbaa !9
  %140 = load i32, ptr %10, align 4, !tbaa !9
  %141 = icmp ne i32 %140, 0
  %142 = xor i1 %141, true
  %143 = xor i1 %142, true
  %144 = zext i1 %143 to i32
  %145 = sext i32 %144 to i64
  %146 = call i64 @llvm.expect.i64(i64 %145, i64 1)
  %147 = icmp ne i64 %146, 0
  br i1 %147, label %148, label %208

148:                                              ; preds = %136
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #10
  %149 = load ptr, ptr %4, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.s2n_array, ptr %149, i32 0, i32 0
  %151 = getelementptr inbounds %struct.s2n_blob, ptr %150, i32 0, i32 0
  %152 = load ptr, ptr %151, align 8, !tbaa !20
  %153 = load ptr, ptr %4, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.s2n_array, ptr %153, i32 0, i32 2
  %155 = load i32, ptr %154, align 4, !tbaa !19
  %156 = load ptr, ptr %4, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.s2n_array, ptr %156, i32 0, i32 1
  %158 = load i32, ptr %157, align 8, !tbaa !13
  %159 = mul i32 %155, %158
  %160 = zext i32 %159 to i64
  %161 = getelementptr inbounds i8, ptr %152, i64 %160
  store ptr %161, ptr %11, align 8, !tbaa !5
  br label %162

162:                                              ; preds = %148
  %163 = load ptr, ptr %11, align 8, !tbaa !5
  %164 = icmp ne ptr %163, null
  br i1 %164, label %199, label %165

165:                                              ; preds = %162
  br label %166

166:                                              ; preds = %165
  br label %167

167:                                              ; preds = %166
  %168 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %169 = getelementptr inbounds %struct.s2n_debug_info, ptr %168, i32 0, i32 0
  store ptr @.str.14, ptr %169, align 8, !tbaa !16
  %170 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %171 = getelementptr inbounds %struct.s2n_debug_info, ptr %170, i32 0, i32 0
  %172 = load ptr, ptr %171, align 8, !tbaa !16
  %173 = getelementptr inbounds i8, ptr %172, i64 21
  %174 = call ptr @strrchr(ptr noundef %173, i32 noundef 47) #9
  %175 = icmp ne ptr %174, null
  br i1 %175, label %176, label %183

176:                                              ; preds = %167
  %177 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %178 = getelementptr inbounds %struct.s2n_debug_info, ptr %177, i32 0, i32 0
  %179 = load ptr, ptr %178, align 8, !tbaa !16
  %180 = getelementptr inbounds i8, ptr %179, i64 21
  %181 = call ptr @strrchr(ptr noundef %180, i32 noundef 47) #9
  %182 = getelementptr inbounds i8, ptr %181, i64 1
  br label %188

183:                                              ; preds = %167
  %184 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %185 = getelementptr inbounds %struct.s2n_debug_info, ptr %184, i32 0, i32 0
  %186 = load ptr, ptr %185, align 8, !tbaa !16
  %187 = getelementptr inbounds i8, ptr %186, i64 21
  br label %188

188:                                              ; preds = %183, %176
  %189 = phi ptr [ %182, %176 ], [ %187, %183 ]
  %190 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %191 = getelementptr inbounds %struct.s2n_debug_info, ptr %190, i32 0, i32 1
  store ptr %189, ptr %191, align 8, !tbaa !18
  %192 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %192, align 4, !tbaa !9
  %193 = call i32 @s2n_calculate_stacktrace()
  br label %194

194:                                              ; preds = %188
  br label %195

195:                                              ; preds = %194
  %196 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 -1, ptr %196, align 4, !tbaa !11
  store i32 1, ptr %9, align 4
  br label %205

197:                                              ; No predecessors!
  br label %198

198:                                              ; preds = %197
  br label %199

199:                                              ; preds = %198, %162
  br label %200

200:                                              ; preds = %199
  br label %201

201:                                              ; preds = %200
  %202 = load ptr, ptr %11, align 8, !tbaa !5
  %203 = load i32, ptr %10, align 4, !tbaa !9
  %204 = zext i32 %203 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %202, i8 0, i64 %204, i1 false)
  store i32 0, ptr %9, align 4
  br label %205

205:                                              ; preds = %201, %195
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #10
  %206 = load i32, ptr %9, align 4
  switch i32 %206, label %209 [
    i32 0, label %207
  ]

207:                                              ; preds = %205
  br label %208

208:                                              ; preds = %207, %136
  store i32 0, ptr %9, align 4
  br label %209

209:                                              ; preds = %208, %205
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #10
  %210 = load i32, ptr %9, align 4
  switch i32 %210, label %242 [
    i32 0, label %211
    i32 1, label %239
  ]

211:                                              ; preds = %209
  br label %212

212:                                              ; preds = %211
  br label %213

213:                                              ; preds = %212
  %214 = load ptr, ptr %4, align 8, !tbaa !5
  %215 = call i32 @s2n_array_validate(ptr noundef %214)
  %216 = getelementptr inbounds %struct.s2n_result, ptr %13, i32 0, i32 0
  store i32 %215, ptr %216, align 4
  %217 = getelementptr inbounds %struct.s2n_result, ptr %13, i32 0, i32 0
  %218 = load i32, ptr %217, align 4
  %219 = call zeroext i1 @s2n_result_is_ok(i32 %218)
  %220 = xor i1 %219, true
  %221 = xor i1 %220, true
  %222 = zext i1 %221 to i32
  %223 = sext i32 %222 to i64
  %224 = call i64 @llvm.expect.i64(i64 %223, i64 1)
  %225 = icmp ne i64 %224, 0
  br i1 %225, label %226, label %228

226:                                              ; preds = %213
  %227 = getelementptr inbounds %struct.s2n_result, ptr %12, i32 0, i32 0
  store i32 0, ptr %227, align 4, !tbaa !11
  br label %230

228:                                              ; preds = %213
  %229 = getelementptr inbounds %struct.s2n_result, ptr %12, i32 0, i32 0
  store i32 -1, ptr %229, align 4, !tbaa !11
  br label %230

230:                                              ; preds = %228, %226
  %231 = getelementptr inbounds %struct.s2n_result, ptr %12, i32 0, i32 0
  %232 = load i32, ptr %231, align 4
  %233 = call zeroext i1 @s2n_result_is_ok(i32 %232)
  br i1 %233, label %236, label %234

234:                                              ; preds = %230
  %235 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 -1, ptr %235, align 4, !tbaa !11
  br label %239

236:                                              ; preds = %230
  br label %237

237:                                              ; preds = %236
  %238 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  store i32 0, ptr %238, align 4, !tbaa !11
  br label %239

239:                                              ; preds = %237, %234, %209, %128, %74, %35
  %240 = getelementptr inbounds %struct.s2n_result, ptr %3, i32 0, i32 0
  %241 = load i32, ptr %240, align 4
  ret i32 %241

242:                                              ; preds = %209, %128
  unreachable
}

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 nounwind willreturn memory(argmem: write) }
attributes #7 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #8 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { 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, !10, i64 24}
!14 = !{!"s2n_array", !15, i64 0, !10, i64 24, !10, i64 28}
!15 = !{!"s2n_blob", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!16 = !{!17, !6, i64 0}
!17 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!18 = !{!17, !6, i64 8}
!19 = !{!14, !10, i64 28}
!20 = !{!14, !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.13 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.14 = 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: 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #7

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

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = icmp ugt i32 %9, %1
  br i1 %10, label %19, label %11

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

19:                                               ; preds = %7
  %20 = add i32 %9, -1
  %.not36 = icmp eq i32 %20, %1
  br i1 %.not36, label %40, label %21

21:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #9
  store i32 0, ptr %3, align 4, !tbaa !15
  %22 = xor i32 %1, -1
  %23 = add i32 %9, %22
  %24 = getelementptr inbounds i8, ptr %0, i64 28
  %25 = load i32, ptr %24, align 4, !tbaa !16
  %26 = call i32 @s2n_mul_overflow(i32 noundef %23, i32 noundef %25, ptr noundef nonnull %3) #9
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %39, label %.thread

.thread:                                          ; preds = %21
  %28 = load ptr, ptr %0, align 8, !tbaa !17
  %29 = load i32, ptr %24, align 4, !tbaa !16
  %30 = mul i32 %29, %1
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds i8, ptr %28, i64 %31
  %33 = add nuw i32 %1, 1
  %34 = mul i32 %29, %33
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds i8, ptr %28, i64 %35
  %37 = load i32, ptr %3, align 4, !tbaa !15
  %38 = zext i32 %37 to i64
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %32, ptr align 1 %36, i64 %38, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #9
  %.pre = load i32, ptr %8, align 8, !tbaa !5
  %.pre50 = add i32 %.pre, -1
  br label %40

39:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #9
  br label %62

40:                                               ; preds = %.thread, %19
  %.pre-phi = phi i32 [ %.pre50, %.thread ], [ %20, %19 ]
  store i32 %.pre-phi, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %0, i64 28
  %42 = load i32, ptr %41, align 4, !tbaa !16
  %.not37 = icmp eq i32 %42, 0
  br i1 %.not37, label %58, label %43, !prof !18

43:                                               ; preds = %40
  %44 = load ptr, ptr %0, align 8, !tbaa !17
  %.not38.not = icmp eq ptr %44, null
  br i1 %.not38.not, label %50, label %45

45:                                               ; preds = %43
  %46 = mul i32 %42, %.pre-phi
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds i8, ptr %44, i64 %47
  %49 = zext i32 %42 to i64
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %48, i8 0, i64 %49, i1 false)
  br label %58

50:                                               ; preds = %43
  %51 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.14, ptr %51, align 8, !tbaa !12
  %52 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.14, i64 21), i32 noundef 47) #8
  %.not39 = icmp eq ptr %52, null
  %53 = getelementptr inbounds i8, ptr %52, i64 1
  %54 = select i1 %.not39, ptr getelementptr inbounds (i8, ptr @.str.14, i64 21), ptr %53
  %55 = getelementptr inbounds i8, ptr %51, i64 8
  store ptr %54, ptr %55, align 8, !tbaa !14
  %56 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %56, align 4, !tbaa !15
  %57 = call i32 @s2n_calculate_stacktrace() #9
  br label %62

58:                                               ; preds = %45, %40
  %59 = call i32 @s2n_array_validate(ptr noundef nonnull %0)
  %60 = call zeroext i1 @s2n_result_is_ok(i32 %59)
  %not.48 = xor i1 %60, true
  %.42 = sext i1 %not.48 to i32
  %61 = call zeroext i1 @s2n_result_is_ok(i32 %.42)
  %not.49 = xor i1 %61, true
  %spec.select = sext i1 %not.49 to i32
  br label %62

62:                                               ; preds = %50, %39, %58, %2, %11
  %.sroa.029.5 = phi i32 [ -1, %39 ], [ -1, %50 ], [ -1, %11 ], [ -1, %2 ], [ %spec.select, %58 ]
  ret i32 %.sroa.029.5
}

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: write) }
attributes #7 = { mustprogress 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, !11, i64 24}
!6 = !{!"s2n_array", !7, i64 0, !11, i64 24, !11, i64 28}
!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 = !{!13, !8, i64 0}
!13 = !{!"s2n_debug_info", !8, i64 0, !8, i64 8}
!14 = !{!13, !8, i64 8}
!15 = !{!11, !11, i64 0}
!16 = !{!6, !11, i64 28}
!17 = !{!6, !8, i64 0}
!18 = !{!"branch_weights", !"expected", i32 1, i32 2000}


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