; LLVM IR from berry-lang/berry :: src (be_mem)

; 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.bvm = type { %struct.bglobaldesc, ptr, ptr, ptr, %struct.bvector, %struct.bvector, ptr, ptr, ptr, ptr, ptr, %struct.bvector, %struct.bmoduledesc, %struct.bstringtable, %struct.bvector, ptr, %struct.bgc, ptr, i8, i64, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.bglobaldesc = type { %struct.anon, %struct.anon.0 }
%struct.anon = type { ptr, %struct.bvector }
%struct.anon.0 = type { ptr, %struct.bvector }
%struct.bmoduledesc = type { ptr, ptr }
%struct.bstringtable = type { ptr, i32, i32 }
%struct.bvector = type { i32, i32, i32, ptr, ptr }
%struct.bgc = type { ptr, ptr, ptr, ptr, ptr, i64, i64, i8, i8 }

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @be_realloc(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store i64 %3, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #6
  store i8 0, ptr %11, align 1, !tbaa !11
  %14 = load i64, ptr %8, align 8, !tbaa !9
  %15 = load i64, ptr %9, align 8, !tbaa !9
  %16 = icmp eq i64 %14, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %4
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %18, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %168

19:                                               ; preds = %4
  br label %20

20:                                               ; preds = %139, %19
  br label %21

21:                                               ; preds = %20
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.bvm, ptr %22, i32 0, i32 31
  %24 = load i32, ptr %23, align 8, !tbaa !13
  %25 = add i32 %24, 1
  store i32 %25, ptr %23, align 8, !tbaa !13
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %31

28:                                               ; preds = %21
  %29 = load i64, ptr %8, align 8, !tbaa !9
  %30 = icmp eq i64 %29, 0
  br i1 %30, label %31, label %35

31:                                               ; preds = %28, %21
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load i64, ptr %9, align 8, !tbaa !9
  %34 = call ptr @malloc_from_pool(ptr noundef %32, i64 noundef %33)
  store ptr %34, ptr %10, align 8, !tbaa !5
  br label %130

35:                                               ; preds = %28
  %36 = load i64, ptr %9, align 8, !tbaa !9
  %37 = icmp eq i64 %36, 0
  br i1 %37, label %38, label %60

38:                                               ; preds = %35
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.bvm, ptr %39, i32 0, i32 32
  %41 = load i32, ptr %40, align 4, !tbaa !22
  %42 = add i32 %41, 1
  store i32 %42, ptr %40, align 4, !tbaa !22
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = icmp eq ptr %43, null
  br i1 %44, label %45, label %46

45:                                               ; preds = %38
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %168

46:                                               ; preds = %38
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.bvm, ptr %47, i32 0, i32 18
  %49 = load i8, ptr %48, align 8, !tbaa !23
  %50 = zext i8 %49 to i32
  %51 = and i32 %50, 4
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %56

53:                                               ; preds = %46
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = load i64, ptr %8, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 1 %54, i8 -1, i64 %55, i1 false)
  br label %56

56:                                               ; preds = %53, %46
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load i64, ptr %8, align 8, !tbaa !9
  call void @free_from_pool(ptr noundef %57, ptr noundef %58, i64 noundef %59)
  br label %155

60:                                               ; preds = %35
  %61 = load i64, ptr %9, align 8, !tbaa !9
  %62 = icmp ne i64 %61, 0
  br i1 %62, label %63, label %128

63:                                               ; preds = %60
  %64 = load i64, ptr %8, align 8, !tbaa !9
  %65 = icmp ne i64 %64, 0
  br i1 %65, label %66, label %128

66:                                               ; preds = %63
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.bvm, ptr %67, i32 0, i32 33
  %69 = load i32, ptr %68, align 8, !tbaa !24
  %70 = add i32 %69, 1
  store i32 %70, ptr %68, align 8, !tbaa !24
  %71 = load i64, ptr %9, align 8, !tbaa !9
  %72 = icmp ule i64 %71, 32
  br i1 %72, label %76, label %73

73:                                               ; preds = %66
  %74 = load i64, ptr %8, align 8, !tbaa !9
  %75 = icmp ule i64 %74, 32
  br i1 %75, label %76, label %123

76:                                               ; preds = %73, %66
  %77 = load i64, ptr %9, align 8, !tbaa !9
  %78 = icmp ule i64 %77, 16
  br i1 %78, label %79, label %84

79:                                               ; preds = %76
  %80 = load i64, ptr %8, align 8, !tbaa !9
  %81 = icmp ule i64 %80, 16
  br i1 %81, label %82, label %84

82:                                               ; preds = %79
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %83, ptr %10, align 8, !tbaa !5
  br label %155

84:                                               ; preds = %79, %76
  %85 = load i64, ptr %9, align 8, !tbaa !9
  %86 = icmp ugt i64 %85, 16
  br i1 %86, label %87, label %98

87:                                               ; preds = %84
  %88 = load i64, ptr %8, align 8, !tbaa !9
  %89 = icmp ugt i64 %88, 16
  br i1 %89, label %90, label %98

90:                                               ; preds = %87
  %91 = load i64, ptr %9, align 8, !tbaa !9
  %92 = icmp ule i64 %91, 32
  br i1 %92, label %93, label %98

93:                                               ; preds = %90
  %94 = load i64, ptr %8, align 8, !tbaa !9
  %95 = icmp ule i64 %94, 32
  br i1 %95, label %96, label %98

96:                                               ; preds = %93
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %97, ptr %10, align 8, !tbaa !5
  br label %155

98:                                               ; preds = %93, %90, %87, %84
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = load i64, ptr %9, align 8, !tbaa !9
  %101 = call ptr @malloc_from_pool(ptr noundef %99, i64 noundef %100)
  store ptr %101, ptr %10, align 8, !tbaa !5
  %102 = load ptr, ptr %10, align 8, !tbaa !5
  %103 = icmp ne ptr %102, null
  br i1 %103, label %104, label %120

104:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %105 = load i64, ptr %8, align 8, !tbaa !9
  %106 = load i64, ptr %9, align 8, !tbaa !9
  %107 = icmp ult i64 %105, %106
  br i1 %107, label %108, label %110

108:                                              ; preds = %104
  %109 = load i64, ptr %8, align 8, !tbaa !9
  br label %112

110:                                              ; preds = %104
  %111 = load i64, ptr %9, align 8, !tbaa !9
  br label %112

112:                                              ; preds = %110, %108
  %113 = phi i64 [ %109, %108 ], [ %111, %110 ]
  store i64 %113, ptr %13, align 8, !tbaa !9
  %114 = load ptr, ptr %10, align 8, !tbaa !5
  %115 = load ptr, ptr %7, align 8, !tbaa !5
  %116 = load i64, ptr %13, align 8, !tbaa !9
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %114, ptr align 1 %115, i64 %116, i1 false)
  %117 = load ptr, ptr %6, align 8, !tbaa !5
  %118 = load ptr, ptr %7, align 8, !tbaa !5
  %119 = load i64, ptr %8, align 8, !tbaa !9
  call void @free_from_pool(ptr noundef %117, ptr noundef %118, i64 noundef %119)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %120

120:                                              ; preds = %112, %98
  br label %121

121:                                              ; preds = %120
  br label %122

122:                                              ; preds = %121
  br label %127

123:                                              ; preds = %73
  %124 = load ptr, ptr %7, align 8, !tbaa !5
  %125 = load i64, ptr %9, align 8, !tbaa !9
  %126 = call ptr @realloc(ptr noundef %124, i64 noundef %125) #7
  store ptr %126, ptr %10, align 8, !tbaa !5
  br label %127

127:                                              ; preds = %123, %122
  br label %128

128:                                              ; preds = %127, %63, %60
  br label %129

129:                                              ; preds = %128
  br label %130

130:                                              ; preds = %129, %31
  %131 = load ptr, ptr %10, align 8, !tbaa !5
  %132 = icmp ne ptr %131, null
  br i1 %132, label %133, label %134

133:                                              ; preds = %130
  br label %155

134:                                              ; preds = %130
  %135 = load i8, ptr %11, align 1, !tbaa !11, !range !25, !noundef !26
  %136 = trunc i8 %135 to i1
  br i1 %136, label %137, label %139

137:                                              ; preds = %134
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  call void @be_throw(ptr noundef %138, i32 noundef 2)
  br label %139

139:                                              ; preds = %137, %134
  %140 = load ptr, ptr %6, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.bvm, ptr %140, i32 0, i32 16
  %142 = getelementptr inbounds %struct.bgc, ptr %141, i32 0, i32 8
  %143 = load i8, ptr %142, align 1, !tbaa !27
  %144 = zext i8 %143 to i32
  %145 = or i32 %144, 4
  %146 = trunc i32 %145 to i8
  store i8 %146, ptr %142, align 1, !tbaa !27
  %147 = load ptr, ptr %6, align 8, !tbaa !5
  call void @be_gc_collect(ptr noundef %147)
  %148 = load ptr, ptr %6, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.bvm, ptr %148, i32 0, i32 16
  %150 = getelementptr inbounds %struct.bgc, ptr %149, i32 0, i32 8
  %151 = load i8, ptr %150, align 1, !tbaa !27
  %152 = zext i8 %151 to i32
  %153 = and i32 %152, -5
  %154 = trunc i32 %153 to i8
  store i8 %154, ptr %150, align 1, !tbaa !27
  store i8 1, ptr %11, align 1, !tbaa !11
  br label %20

155:                                              ; preds = %133, %96, %82, %56
  %156 = load ptr, ptr %6, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.bvm, ptr %156, i32 0, i32 16
  %158 = getelementptr inbounds %struct.bgc, ptr %157, i32 0, i32 5
  %159 = load i64, ptr %158, align 8, !tbaa !28
  %160 = load i64, ptr %9, align 8, !tbaa !9
  %161 = add i64 %159, %160
  %162 = load i64, ptr %8, align 8, !tbaa !9
  %163 = sub i64 %161, %162
  %164 = load ptr, ptr %6, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.bvm, ptr %164, i32 0, i32 16
  %166 = getelementptr inbounds %struct.bgc, ptr %165, i32 0, i32 5
  store i64 %163, ptr %166, align 8, !tbaa !28
  %167 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %167, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %168

168:                                              ; preds = %155, %45, %17
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %169 = load ptr, ptr %5, align 8
  ret ptr %169
}

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

; Function Attrs: nounwind uwtable
declare hidden ptr @malloc_from_pool(ptr noundef, i64 noundef) #1

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

; Function Attrs: nounwind uwtable
declare hidden void @free_from_pool(ptr noundef, ptr noundef, i64 noundef) #1

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

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

declare void @be_throw(ptr noundef, i32 noundef) #5

declare void @be_gc_collect(ptr noundef) #5

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

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !18, i64 448}
!14 = !{!"bvm", !15, i64 0, !6, i64 80, !6, i64 88, !6, i64 96, !17, i64 104, !17, i64 136, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !17, i64 208, !19, i64 240, !20, i64 256, !17, i64 272, !6, i64 304, !21, i64 312, !6, i64 376, !7, i64 384, !10, i64 392, !6, i64 400, !18, i64 408, !18, i64 412, !18, i64 416, !18, i64 420, !18, i64 424, !18, i64 428, !18, i64 432, !18, i64 436, !18, i64 440, !18, i64 444, !18, i64 448, !18, i64 452, !18, i64 456, !18, i64 460, !18, i64 464, !18, i64 468, !18, i64 472, !18, i64 476, !18, i64 480, !18, i64 484, !18, i64 488, !18, i64 492, !18, i64 496}
!15 = !{!"", !16, i64 0, !16, i64 40}
!16 = !{!"", !6, i64 0, !17, i64 8}
!17 = !{!"bvector", !18, i64 0, !18, i64 4, !18, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!"int", !7, i64 0}
!19 = !{!"bmoduledesc", !6, i64 0, !6, i64 8}
!20 = !{!"bstringtable", !6, i64 0, !18, i64 8, !18, i64 12}
!21 = !{!"bgc", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 48, !7, i64 56, !7, i64 57}
!22 = !{!14, !18, i64 452}
!23 = !{!14, !7, i64 384}
!24 = !{!14, !18, i64 456}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!14, !7, i64 369}
!28 = !{!14, !10, i64 352}


; 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"

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @be_realloc(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #1 {
  %5 = icmp eq i64 %2, %3
  br i1 %5, label %69, label %.preheader

.preheader:                                       ; preds = %4
  %6 = getelementptr inbounds i8, ptr %0, i64 448
  %7 = icmp eq ptr %1, null
  %8 = icmp eq i64 %2, 0
  %or.cond = or i1 %7, %8
  %9 = getelementptr inbounds i8, ptr %0, i64 456
  %10 = icmp ult i64 %3, 33
  %11 = icmp ult i64 %2, 33
  %or.cond5 = or i1 %11, %10
  %12 = icmp ult i64 %3, 17
  %13 = icmp ult i64 %2, 17
  %or.cond7 = and i1 %13, %12
  %14 = add i64 %3, -17
  %15 = add i64 %2, -17
  %16 = or i64 %14, %15
  %or.cond13 = icmp ult i64 %16, 16
  %17 = getelementptr inbounds i8, ptr %0, i64 369
  br i1 %or.cond, label %.preheader.split.us, label %.preheader.split

.preheader.split.us:                              ; preds = %.preheader
  %18 = load i32, ptr %6, align 8, !tbaa !5
  %19 = add i32 %18, 1
  store i32 %19, ptr %6, align 8, !tbaa !5
  %20 = tail call ptr @malloc_from_pool(ptr noundef nonnull %0, i64 noundef %3)
  %.not77.us105 = icmp eq ptr %20, null
  br i1 %.not77.us105, label %.thread.us.preheader, label %.loopexit

.thread.us.preheader:                             ; preds = %.preheader.split.us
  %21 = load i8, ptr %17, align 1, !tbaa !18
  %22 = or i8 %21, 4
  store i8 %22, ptr %17, align 1, !tbaa !18
  tail call void @be_gc_collect(ptr noundef nonnull %0) #6
  %23 = load i8, ptr %17, align 1, !tbaa !18
  %24 = and i8 %23, -5
  store i8 %24, ptr %17, align 1, !tbaa !18
  %25 = load i32, ptr %6, align 8, !tbaa !5
  %26 = add i32 %25, 1
  store i32 %26, ptr %6, align 8, !tbaa !5
  %27 = tail call ptr @malloc_from_pool(ptr noundef nonnull %0, i64 noundef %3)
  %.not77.us121 = icmp eq ptr %27, null
  br i1 %.not77.us121, label %.critedge, label %.loopexit

.critedge:                                        ; preds = %.thread.us.preheader, %.critedge
  tail call void @be_throw(ptr noundef nonnull %0, i32 noundef 2) #6
  %28 = load i8, ptr %17, align 1, !tbaa !18
  %29 = or i8 %28, 4
  store i8 %29, ptr %17, align 1, !tbaa !18
  tail call void @be_gc_collect(ptr noundef nonnull %0) #6
  %30 = load i8, ptr %17, align 1, !tbaa !18
  %31 = and i8 %30, -5
  store i8 %31, ptr %17, align 1, !tbaa !18
  %32 = load i32, ptr %6, align 8, !tbaa !5
  %33 = add i32 %32, 1
  store i32 %33, ptr %6, align 8, !tbaa !5
  %34 = tail call ptr @malloc_from_pool(ptr noundef nonnull %0, i64 noundef %3)
  %.not77.us = icmp eq ptr %34, null
  br i1 %.not77.us, label %.critedge, label %.loopexit

.preheader.split:                                 ; preds = %.preheader
  %35 = icmp eq i64 %3, 0
  %36 = load i32, ptr %6, align 8, !tbaa !5
  %37 = add i32 %36, 1
  store i32 %37, ptr %6, align 8, !tbaa !5
  br i1 %35, label %.preheader.split._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader.split
  %38 = load i32, ptr %9, align 8, !tbaa !19
  %39 = add i32 %38, 1
  store i32 %39, ptr %9, align 8, !tbaa !19
  br i1 %or.cond5, label %.lr.ph.split.us, label %.lr.ph.split.split

.lr.ph.split.us:                                  ; preds = %.lr.ph
  %brmerge = or i1 %or.cond7, %or.cond13
  br i1 %brmerge, label %.loopexit, label %.lr.ph.split.us.split.split.split

.lr.ph.split.us.split.split.split:                ; preds = %.lr.ph.split.us
  %40 = tail call ptr @malloc_from_pool(ptr noundef nonnull %0, i64 noundef %3)
  %.not.us102 = icmp eq ptr %40, null
  br i1 %.not.us102, label %.thread.us84, label %.thread80

.critedge108:                                     ; preds = %.thread.us84
  tail call void @be_throw(ptr noundef nonnull %0, i32 noundef 2) #6
  br label %.thread.us84

.thread.us84:                                     ; preds = %.lr.ph.split.us.split.split.split, %.critedge108
  %41 = load i8, ptr %17, align 1, !tbaa !18
  %42 = or i8 %41, 4
  store i8 %42, ptr %17, align 1, !tbaa !18
  tail call void @be_gc_collect(ptr noundef nonnull %0) #6
  %43 = load i8, ptr %17, align 1, !tbaa !18
  %44 = and i8 %43, -5
  store i8 %44, ptr %17, align 1, !tbaa !18
  %45 = load i32, ptr %6, align 8, !tbaa !5
  %46 = add i32 %45, 1
  store i32 %46, ptr %6, align 8, !tbaa !5
  %47 = load i32, ptr %9, align 8, !tbaa !19
  %48 = add i32 %47, 1
  store i32 %48, ptr %9, align 8, !tbaa !19
  %49 = tail call ptr @malloc_from_pool(ptr noundef nonnull %0, i64 noundef %3)
  %.not.us = icmp eq ptr %49, null
  br i1 %.not.us, label %.critedge108, label %.thread80

.lr.ph.split.split:                               ; preds = %.lr.ph
  %50 = tail call ptr @realloc(ptr noundef nonnull %1, i64 noundef %3) #7
  %.not7794 = icmp eq ptr %50, null
  br i1 %.not7794, label %.thread, label %.loopexit

.preheader.split._crit_edge:                      ; preds = %.preheader.split
  %.phi.trans.insert113 = getelementptr inbounds i8, ptr %0, i64 384
  %.pre114 = load i8, ptr %.phi.trans.insert113, align 8, !tbaa !20
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 452
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !21
  %51 = getelementptr inbounds i8, ptr %0, i64 452
  %52 = add i32 %.pre, 1
  store i32 %52, ptr %51, align 4, !tbaa !21
  %53 = and i8 %.pre114, 4
  %.not76 = icmp eq i8 %53, 0
  br i1 %.not76, label %.loopexit.sink.split, label %54

54:                                               ; preds = %.preheader.split._crit_edge
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %1, i8 -1, i64 %2, i1 false)
  br label %.loopexit.sink.split

.thread80:                                        ; preds = %.thread.us84, %.lr.ph.split.us.split.split.split
  %.us-phi101 = phi ptr [ %40, %.lr.ph.split.us.split.split.split ], [ %49, %.thread.us84 ]
  %55 = tail call i64 @llvm.umin.i64(i64 %2, i64 %3)
  tail call void @llvm.memmove.p0.p0.i64(ptr nonnull align 1 %.us-phi101, ptr nonnull align 1 %1, i64 %55, i1 false)
  br label %.loopexit.sink.split

.critedge109:                                     ; preds = %.thread
  tail call void @be_throw(ptr noundef nonnull %0, i32 noundef 2) #6
  br label %.thread

.thread:                                          ; preds = %.lr.ph.split.split, %.critedge109
  %56 = load i8, ptr %17, align 1, !tbaa !18
  %57 = or i8 %56, 4
  store i8 %57, ptr %17, align 1, !tbaa !18
  tail call void @be_gc_collect(ptr noundef nonnull %0) #6
  %58 = load i8, ptr %17, align 1, !tbaa !18
  %59 = and i8 %58, -5
  store i8 %59, ptr %17, align 1, !tbaa !18
  %60 = load i32, ptr %6, align 8, !tbaa !5
  %61 = add i32 %60, 1
  store i32 %61, ptr %6, align 8, !tbaa !5
  %62 = load i32, ptr %9, align 8, !tbaa !19
  %63 = add i32 %62, 1
  store i32 %63, ptr %9, align 8, !tbaa !19
  %64 = tail call ptr @realloc(ptr noundef nonnull %1, i64 noundef %3) #7
  %.not77 = icmp eq ptr %64, null
  br i1 %.not77, label %.critedge109, label %.loopexit

.loopexit.sink.split:                             ; preds = %.preheader.split._crit_edge, %54, %.thread80
  %.2.ph = phi ptr [ %.us-phi101, %.thread80 ], [ null, %54 ], [ null, %.preheader.split._crit_edge ]
  tail call void @free_from_pool(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 noundef %2)
  br label %.loopexit

.loopexit:                                        ; preds = %.thread, %.critedge, %.thread.us.preheader, %.loopexit.sink.split, %.lr.ph.split.us, %.preheader.split.us, %.lr.ph.split.split
  %.2 = phi ptr [ %20, %.preheader.split.us ], [ %50, %.lr.ph.split.split ], [ %1, %.lr.ph.split.us ], [ %.2.ph, %.loopexit.sink.split ], [ %27, %.thread.us.preheader ], [ %34, %.critedge ], [ %64, %.thread ]
  %65 = getelementptr inbounds i8, ptr %0, i64 352
  %66 = load i64, ptr %65, align 8, !tbaa !22
  %67 = sub i64 %3, %2
  %68 = add i64 %67, %66
  store i64 %68, ptr %65, align 8, !tbaa !22
  br label %69

69:                                               ; preds = %4, %.loopexit
  %.0 = phi ptr [ %.2, %.loopexit ], [ %1, %4 ]
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare hidden ptr @malloc_from_pool(ptr noundef, i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden void @free_from_pool(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

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

declare void @be_throw(ptr noundef, i32 noundef) local_unnamed_addr #4

declare void @be_gc_collect(ptr noundef) local_unnamed_addr #4

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

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

!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, !13, i64 448}
!6 = !{!"bvm", !7, i64 0, !9, i64 80, !9, i64 88, !9, i64 96, !12, i64 104, !12, i64 136, !9, i64 168, !9, i64 176, !9, i64 184, !9, i64 192, !9, i64 200, !12, i64 208, !14, i64 240, !15, i64 256, !12, i64 272, !9, i64 304, !16, i64 312, !9, i64 376, !10, i64 384, !17, i64 392, !9, i64 400, !13, i64 408, !13, i64 412, !13, i64 416, !13, i64 420, !13, i64 424, !13, i64 428, !13, i64 432, !13, i64 436, !13, i64 440, !13, i64 444, !13, i64 448, !13, i64 452, !13, i64 456, !13, i64 460, !13, i64 464, !13, i64 468, !13, i64 472, !13, i64 476, !13, i64 480, !13, i64 484, !13, i64 488, !13, i64 492, !13, i64 496}
!7 = !{!"", !8, i64 0, !8, i64 40}
!8 = !{!"", !9, i64 0, !12, i64 8}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"bvector", !13, i64 0, !13, i64 4, !13, i64 8, !9, i64 16, !9, i64 24}
!13 = !{!"int", !10, i64 0}
!14 = !{!"bmoduledesc", !9, i64 0, !9, i64 8}
!15 = !{!"bstringtable", !9, i64 0, !13, i64 8, !13, i64 12}
!16 = !{!"bgc", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24, !9, i64 32, !17, i64 40, !17, i64 48, !10, i64 56, !10, i64 57}
!17 = !{!"long", !10, i64 0}
!18 = !{!6, !10, i64 369}
!19 = !{!6, !13, i64 456}
!20 = !{!6, !10, i64 384}
!21 = !{!6, !13, i64 452}
!22 = !{!6, !17, i64 352}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass