; LLVM IR from Sopiro/Muli :: src/util/block_allocator.ll (ZN4muli14BlockAllocatorC2Ei)

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

%"class.muli::BlockAllocator" = type { %"class.muli::Allocator", i32, i32, [128 x i32], ptr, [128 x ptr] }
%"class.muli::Allocator" = type { ptr }

@_ZTVN4muli14BlockAllocatorE = external dso_local unnamed_addr constant { [7 x ptr] }, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4muli14BlockAllocatorC2Ei(ptr noundef nonnull align 8 dereferenceable(1560) %0, i32 noundef %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  call void @_ZN4muli9AllocatorC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #3
  store ptr getelementptr inbounds inrange(-16, 40) ({ [7 x ptr] }, ptr @_ZTVN4muli14BlockAllocatorE, i32 0, i32 0, i32 2), ptr %6, align 8, !tbaa !11
  %7 = getelementptr inbounds %"class.muli::BlockAllocator", ptr %6, i32 0, i32 1
  store i32 0, ptr %7, align 8, !tbaa !13
  %8 = getelementptr inbounds %"class.muli::BlockAllocator", ptr %6, i32 0, i32 2
  store i32 0, ptr %8, align 4, !tbaa !16
  %9 = getelementptr inbounds %"class.muli::BlockAllocator", ptr %6, i32 0, i32 4
  store ptr null, ptr %9, align 8, !tbaa !17
  %10 = getelementptr inbounds %"class.muli::BlockAllocator", ptr %6, i32 0, i32 5
  %11 = getelementptr inbounds [128 x ptr], ptr %10, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 8 %11, i8 0, i64 1024, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %22, %2
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 128
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %25

16:                                               ; preds = %12
  %17 = load i32, ptr %4, align 4, !tbaa !9
  %18 = getelementptr inbounds %"class.muli::BlockAllocator", ptr %6, i32 0, i32 3
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [128 x i32], ptr %18, i64 0, i64 %20
  store i32 %17, ptr %21, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %16
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %5, align 4, !tbaa !9
  br label %12, !llvm.loop !18

25:                                               ; preds = %15
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4muli9AllocatorC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

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

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

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

attributes #0 = { mustprogress 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 nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTSN4muli14BlockAllocatorE", !15, i64 0, !10, i64 8, !10, i64 12, !7, i64 16, !6, i64 528, !7, i64 536}
!15 = !{!"_ZTSN4muli9AllocatorE"}
!16 = !{!14, !10, i64 12}
!17 = !{!14, !6, i64 528}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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

@_ZTVN4muli14BlockAllocatorE = external dso_local unnamed_addr constant { [7 x ptr] }, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4muli14BlockAllocatorC2Ei(ptr noundef nonnull align 8 dereferenceable(1560) %0, i32 noundef %1) unnamed_addr #0 align 2 {
vector.ph:
  tail call void @_ZN4muli9AllocatorC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #2
  store ptr getelementptr inbounds inrange(-16, 40) (i8, ptr @_ZTVN4muli14BlockAllocatorE, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 0, ptr %2, align 8, !tbaa !8
  %3 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 0, ptr %3, align 4, !tbaa !14
  %4 = getelementptr inbounds i8, ptr %0, i64 528
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1032) %4, i8 0, i64 1032, i1 false)
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %1, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  store <4 x i32> %broadcast.splat, ptr %5, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %6, align 8, !tbaa !15
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  store <4 x i32> %broadcast.splat, ptr %7, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %8, align 8, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %0, i64 80
  %10 = getelementptr inbounds i8, ptr %0, i64 96
  store <4 x i32> %broadcast.splat, ptr %9, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %10, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %0, i64 112
  %12 = getelementptr inbounds i8, ptr %0, i64 128
  store <4 x i32> %broadcast.splat, ptr %11, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 144
  %14 = getelementptr inbounds i8, ptr %0, i64 160
  store <4 x i32> %broadcast.splat, ptr %13, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %14, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %0, i64 176
  %16 = getelementptr inbounds i8, ptr %0, i64 192
  store <4 x i32> %broadcast.splat, ptr %15, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %16, align 8, !tbaa !15
  %17 = getelementptr inbounds i8, ptr %0, i64 208
  %18 = getelementptr inbounds i8, ptr %0, i64 224
  store <4 x i32> %broadcast.splat, ptr %17, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %18, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %0, i64 240
  %20 = getelementptr inbounds i8, ptr %0, i64 256
  store <4 x i32> %broadcast.splat, ptr %19, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %20, align 8, !tbaa !15
  %21 = getelementptr inbounds i8, ptr %0, i64 272
  %22 = getelementptr inbounds i8, ptr %0, i64 288
  store <4 x i32> %broadcast.splat, ptr %21, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %22, align 8, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %0, i64 304
  %24 = getelementptr inbounds i8, ptr %0, i64 320
  store <4 x i32> %broadcast.splat, ptr %23, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %24, align 8, !tbaa !15
  %25 = getelementptr inbounds i8, ptr %0, i64 336
  %26 = getelementptr inbounds i8, ptr %0, i64 352
  store <4 x i32> %broadcast.splat, ptr %25, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %26, align 8, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %0, i64 368
  %28 = getelementptr inbounds i8, ptr %0, i64 384
  store <4 x i32> %broadcast.splat, ptr %27, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %28, align 8, !tbaa !15
  %29 = getelementptr inbounds i8, ptr %0, i64 400
  %30 = getelementptr inbounds i8, ptr %0, i64 416
  store <4 x i32> %broadcast.splat, ptr %29, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %30, align 8, !tbaa !15
  %31 = getelementptr inbounds i8, ptr %0, i64 432
  %32 = getelementptr inbounds i8, ptr %0, i64 448
  store <4 x i32> %broadcast.splat, ptr %31, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %32, align 8, !tbaa !15
  %33 = getelementptr inbounds i8, ptr %0, i64 464
  %34 = getelementptr inbounds i8, ptr %0, i64 480
  store <4 x i32> %broadcast.splat, ptr %33, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %34, align 8, !tbaa !15
  %35 = getelementptr inbounds i8, ptr %0, i64 496
  %36 = getelementptr inbounds i8, ptr %0, i64 512
  store <4 x i32> %broadcast.splat, ptr %35, align 8, !tbaa !15
  store <4 x i32> %broadcast.splat, ptr %36, align 8, !tbaa !15
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4muli9AllocatorC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

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

attributes #0 = { mustprogress 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 nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !11, i64 8}
!9 = !{!"_ZTSN4muli14BlockAllocatorE", !10, i64 0, !11, i64 8, !11, i64 12, !12, i64 16, !13, i64 528, !12, i64 536}
!10 = !{!"_ZTSN4muli9AllocatorE"}
!11 = !{!"int", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"any pointer", !12, i64 0}
!14 = !{!9, !11, i64 12}
!15 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass