; LLVM IR from SOHNE/Dura2D :: src/common/d2BlockAllocator.ll (ZN16d2BlockAllocator8AllocateEi)

; 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.d2SizeMap = type { [641 x i8] }
%class.d2BlockAllocator = type { ptr, i32, i32, [14 x ptr] }
%struct.d2Block = type { ptr }
%struct.d2Chunk = type { i32, ptr }

@_ZL10d2_sizeMap = external hidden global %struct.d2SizeMap, align 1
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__._ZN16d2BlockAllocator8AllocateEi = external hidden unnamed_addr constant [40 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [40 x i8], align 1
@_ZL13d2_blockSizes = external hidden constant [14 x i32], align 16
@.str.3 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #0

; 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: nounwind
declare void @free(ptr noundef) #3

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZN16d2BlockAllocator8AllocateEi(ptr noundef nonnull align 8 dereferenceable(128) %0, i32 noundef %1) #4 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %17 = load ptr, ptr %4, align 8
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  br label %188

21:                                               ; preds = %2
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = icmp slt i32 0, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  br label %27

25:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 115, ptr noundef @__PRETTY_FUNCTION__._ZN16d2BlockAllocator8AllocateEi) #7
  unreachable

26:                                               ; No predecessors!
  br label %27

27:                                               ; preds = %26, %24
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = icmp sgt i32 %28, 640
  br i1 %29, label %30, label %34

30:                                               ; preds = %27
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = call noalias ptr @malloc(i64 noundef %32) #8
  store ptr %33, ptr %3, align 8
  br label %188

34:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #9
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [641 x i8], ptr @_ZL10d2_sizeMap, i64 0, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !11
  %39 = zext i8 %38 to i32
  store i32 %39, ptr %6, align 4, !tbaa !9
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = icmp sle i32 0, %40
  br i1 %41, label %42, label %45

42:                                               ; preds = %34
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = icmp slt i32 %43, 14
  br label %45

45:                                               ; preds = %42, %34
  %46 = phi i1 [ false, %34 ], [ %44, %42 ]
  br i1 %46, label %47, label %48

47:                                               ; preds = %45
  br label %50

48:                                               ; preds = %45
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 120, ptr noundef @__PRETTY_FUNCTION__._ZN16d2BlockAllocator8AllocateEi) #7
  unreachable

49:                                               ; No predecessors!
  br label %50

50:                                               ; preds = %49, %47
  %51 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 3
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [14 x ptr], ptr %51, i64 0, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %71

57:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #9
  %58 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 3
  %59 = load i32, ptr %6, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [14 x ptr], ptr %58, i64 0, i64 %60
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  store ptr %62, ptr %7, align 8, !tbaa !5
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.d2Block, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !12
  %66 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 3
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [14 x ptr], ptr %66, i64 0, i64 %68
  store ptr %65, ptr %69, align 8, !tbaa !5
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %70, ptr %3, align 8
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #9
  br label %187

71:                                               ; preds = %50
  %72 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 1
  %73 = load i32, ptr %72, align 8, !tbaa !14
  %74 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 2
  %75 = load i32, ptr %74, align 4, !tbaa !16
  %76 = icmp eq i32 %73, %75
  br i1 %76, label %77, label %103

77:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #9
  %78 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !17
  store ptr %79, ptr %9, align 8, !tbaa !5
  %80 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 2
  %81 = load i32, ptr %80, align 4, !tbaa !16
  %82 = add nsw i32 %81, 128
  store i32 %82, ptr %80, align 4, !tbaa !16
  %83 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 2
  %84 = load i32, ptr %83, align 4, !tbaa !16
  %85 = sext i32 %84 to i64
  %86 = mul i64 %85, 16
  %87 = call noalias ptr @malloc(i64 noundef %86) #8
  %88 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 0
  store ptr %87, ptr %88, align 8, !tbaa !17
  %89 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 0
  %90 = load ptr, ptr %89, align 8, !tbaa !17
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  %92 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 1
  %93 = load i32, ptr %92, align 8, !tbaa !14
  %94 = sext i32 %93 to i64
  %95 = mul i64 %94, 16
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %90, ptr align 8 %91, i64 %95, i1 false)
  %96 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8, !tbaa !17
  %98 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 1
  %99 = load i32, ptr %98, align 8, !tbaa !14
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds %struct.d2Chunk, ptr %97, i64 %100
  call void @llvm.memset.p0.i64(ptr align 8 %101, i8 0, i64 2048, i1 false)
  %102 = load ptr, ptr %9, align 8, !tbaa !5
  call void @free(ptr noundef %102) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #9
  br label %103

103:                                              ; preds = %77, %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #9
  %104 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 0
  %105 = load ptr, ptr %104, align 8, !tbaa !17
  %106 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 1
  %107 = load i32, ptr %106, align 8, !tbaa !14
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds %struct.d2Chunk, ptr %105, i64 %108
  store ptr %109, ptr %10, align 8, !tbaa !5
  %110 = call noalias ptr @malloc(i64 noundef 16384) #8
  %111 = load ptr, ptr %10, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.d2Chunk, ptr %111, i32 0, i32 1
  store ptr %110, ptr %112, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #9
  %113 = load i32, ptr %6, align 4, !tbaa !9
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [14 x i32], ptr @_ZL13d2_blockSizes, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !9
  store i32 %116, ptr %11, align 4, !tbaa !9
  %117 = load i32, ptr %11, align 4, !tbaa !9
  %118 = load ptr, ptr %10, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.d2Chunk, ptr %118, i32 0, i32 0
  store i32 %117, ptr %119, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  %120 = load i32, ptr %11, align 4, !tbaa !9
  %121 = sdiv i32 16384, %120
  store i32 %121, ptr %12, align 4, !tbaa !9
  %122 = load i32, ptr %12, align 4, !tbaa !9
  %123 = load i32, ptr %11, align 4, !tbaa !9
  %124 = mul nsw i32 %122, %123
  %125 = icmp sle i32 %124, 16384
  br i1 %125, label %126, label %127

126:                                              ; preds = %103
  br label %129

127:                                              ; preds = %103
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 150, ptr noundef @__PRETTY_FUNCTION__._ZN16d2BlockAllocator8AllocateEi) #7
  unreachable

128:                                              ; No predecessors!
  br label %129

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

130:                                              ; preds = %157, %129
  %131 = load i32, ptr %13, align 4, !tbaa !9
  %132 = load i32, ptr %12, align 4, !tbaa !9
  %133 = sub nsw i32 %132, 1
  %134 = icmp slt i32 %131, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %130
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  br label %160

136:                                              ; preds = %130
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #9
  %137 = load ptr, ptr %10, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.d2Chunk, ptr %137, i32 0, i32 1
  %139 = load ptr, ptr %138, align 8, !tbaa !18
  %140 = load i32, ptr %11, align 4, !tbaa !9
  %141 = load i32, ptr %13, align 4, !tbaa !9
  %142 = mul nsw i32 %140, %141
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds i8, ptr %139, i64 %143
  store ptr %144, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #9
  %145 = load ptr, ptr %10, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.d2Chunk, ptr %145, i32 0, i32 1
  %147 = load ptr, ptr %146, align 8, !tbaa !18
  %148 = load i32, ptr %11, align 4, !tbaa !9
  %149 = load i32, ptr %13, align 4, !tbaa !9
  %150 = add nsw i32 %149, 1
  %151 = mul nsw i32 %148, %150
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds i8, ptr %147, i64 %152
  store ptr %153, ptr %15, align 8, !tbaa !5
  %154 = load ptr, ptr %15, align 8, !tbaa !5
  %155 = load ptr, ptr %14, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.d2Block, ptr %155, i32 0, i32 0
  store ptr %154, ptr %156, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #9
  br label %157

157:                                              ; preds = %136
  %158 = load i32, ptr %13, align 4, !tbaa !9
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr %13, align 4, !tbaa !9
  br label %130, !llvm.loop !21

160:                                              ; preds = %135
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #9
  %161 = load ptr, ptr %10, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.d2Chunk, ptr %161, i32 0, i32 1
  %163 = load ptr, ptr %162, align 8, !tbaa !18
  %164 = load i32, ptr %11, align 4, !tbaa !9
  %165 = load i32, ptr %12, align 4, !tbaa !9
  %166 = sub nsw i32 %165, 1
  %167 = mul nsw i32 %164, %166
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds i8, ptr %163, i64 %168
  store ptr %169, ptr %16, align 8, !tbaa !5
  %170 = load ptr, ptr %16, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct.d2Block, ptr %170, i32 0, i32 0
  store ptr null, ptr %171, align 8, !tbaa !12
  %172 = load ptr, ptr %10, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.d2Chunk, ptr %172, i32 0, i32 1
  %174 = load ptr, ptr %173, align 8, !tbaa !18
  %175 = getelementptr inbounds %struct.d2Block, ptr %174, i32 0, i32 0
  %176 = load ptr, ptr %175, align 8, !tbaa !12
  %177 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 3
  %178 = load i32, ptr %6, align 4, !tbaa !9
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [14 x ptr], ptr %177, i64 0, i64 %179
  store ptr %176, ptr %180, align 8, !tbaa !5
  %181 = getelementptr inbounds %class.d2BlockAllocator, ptr %17, i32 0, i32 1
  %182 = load i32, ptr %181, align 8, !tbaa !14
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr %181, align 8, !tbaa !14
  %184 = load ptr, ptr %10, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.d2Chunk, ptr %184, i32 0, i32 1
  %186 = load ptr, ptr %185, align 8, !tbaa !18
  store ptr %186, ptr %3, align 8
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #9
  br label %187

187:                                              ; preds = %160, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  br label %188

188:                                              ; preds = %187, %30, %20
  %189 = load ptr, ptr %3, align 8
  ret ptr %189
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #5

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

attributes #0 = { nounwind allocsize(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 "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 = { 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 #5 = { noreturn nounwind "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: readwrite) }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind allocsize(0) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTS7d2Block", !6, i64 0}
!14 = !{!15, !10, i64 8}
!15 = !{!"_ZTS16d2BlockAllocator", !6, i64 0, !10, i64 8, !10, i64 12, !7, i64 16}
!16 = !{!15, !10, i64 12}
!17 = !{!15, !6, i64 0}
!18 = !{!19, !6, i64 8}
!19 = !{!"_ZTS7d2Chunk", !10, i64 0, !6, i64 8}
!20 = !{!19, !10, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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"

%struct.d2SizeMap = type { [641 x i8] }
%struct.d2Chunk = type { i32, ptr }

@_ZL10d2_sizeMap = external hidden local_unnamed_addr global %struct.d2SizeMap, align 1
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__._ZN16d2BlockAllocator8AllocateEi = external hidden unnamed_addr constant [40 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [40 x i8], align 1
@_ZL13d2_blockSizes = external hidden local_unnamed_addr constant [14 x i32], align 16
@.str.3 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZN16d2BlockAllocator8AllocateEi(ptr nocapture noundef nonnull align 8 dereferenceable(128) %0, i32 noundef %1) local_unnamed_addr #3 align 2 {
  %3 = icmp eq i32 %1, 0
  br i1 %3, label %83, label %4

4:                                                ; preds = %2
  %5 = icmp sgt i32 %1, 0
  br i1 %5, label %7, label %6

6:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 115, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN16d2BlockAllocator8AllocateEi) #6
  unreachable

7:                                                ; preds = %4
  %8 = icmp ugt i32 %1, 640
  %9 = zext nneg i32 %1 to i64
  br i1 %8, label %10, label %12

10:                                               ; preds = %7
  %11 = tail call noalias ptr @malloc(i64 noundef %9) #7
  br label %83

12:                                               ; preds = %7
  %13 = getelementptr inbounds [641 x i8], ptr @_ZL10d2_sizeMap, i64 0, i64 %9
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = icmp ult i8 %14, 14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 120, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN16d2BlockAllocator8AllocateEi) #6
  unreachable

17:                                               ; preds = %12
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = zext nneg i8 %14 to i64
  %20 = getelementptr inbounds [14 x ptr], ptr %18, i64 0, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !8
  %.not = icmp eq ptr %21, null
  br i1 %.not, label %24, label %22

22:                                               ; preds = %17
  %23 = load ptr, ptr %21, align 8, !tbaa !10
  store ptr %23, ptr %20, align 8, !tbaa !8
  br label %83

24:                                               ; preds = %17
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  %26 = load i32, ptr %25, align 8, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %0, i64 12
  %28 = load i32, ptr %27, align 4, !tbaa !15
  %29 = icmp eq i32 %26, %28
  br i1 %29, label %30, label %39

30:                                               ; preds = %24
  %31 = load ptr, ptr %0, align 8, !tbaa !16
  %32 = add nsw i32 %26, 128
  store i32 %32, ptr %27, align 4, !tbaa !15
  %33 = sext i32 %32 to i64
  %34 = shl nsw i64 %33, 4
  %35 = tail call noalias ptr @malloc(i64 noundef %34) #7
  store ptr %35, ptr %0, align 8, !tbaa !16
  %36 = sext i32 %26 to i64
  %37 = shl nsw i64 %36, 4
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %35, ptr align 8 %31, i64 %37, i1 false)
  %38 = getelementptr inbounds %struct.d2Chunk, ptr %35, i64 %36
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(2048) %38, i8 0, i64 2048, i1 false)
  tail call void @free(ptr noundef %31) #8
  %.pre = load i32, ptr %25, align 8, !tbaa !12
  br label %39

39:                                               ; preds = %30, %24
  %40 = phi i32 [ %.pre, %30 ], [ %26, %24 ]
  %41 = load ptr, ptr %0, align 8, !tbaa !16
  %42 = sext i32 %40 to i64
  %43 = getelementptr inbounds %struct.d2Chunk, ptr %41, i64 %42
  %44 = tail call noalias dereferenceable_or_null(16384) ptr @malloc(i64 noundef 16384) #7
  %45 = getelementptr inbounds i8, ptr %43, i64 8
  store ptr %44, ptr %45, align 8, !tbaa !17
  %46 = getelementptr inbounds [14 x i32], ptr @_ZL13d2_blockSizes, i64 0, i64 %19
  %47 = load i32, ptr %46, align 4, !tbaa !19
  store i32 %47, ptr %43, align 8, !tbaa !20
  %48 = sdiv i32 16384, %47
  %49 = mul nsw i32 %48, %47
  %50 = icmp slt i32 %49, 16385
  br i1 %50, label %.preheader, label %56

.preheader:                                       ; preds = %39
  %51 = add nsw i32 %48, -1
  %52 = icmp sgt i32 %48, 1
  br i1 %52, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.preheader
  %53 = sext i32 %47 to i64
  %wide.trip.count = zext nneg i32 %51 to i64
  %54 = add nsw i64 %wide.trip.count, -1
  %xtraiter = and i64 %wide.trip.count, 3
  %55 = icmp ult i64 %54, 3
  br i1 %55, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph

56:                                               ; preds = %39
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 150, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN16d2BlockAllocator8AllocateEi) #6
  unreachable

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %57 = mul nsw i64 %indvars.iv.epil, %53
  %58 = getelementptr inbounds i8, ptr %44, i64 %57
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %59 = mul nsw i64 %indvars.iv.next.epil, %53
  %60 = getelementptr inbounds i8, ptr %44, i64 %59
  store ptr %60, ptr %58, align 8, !tbaa !10
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !21

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %.preheader
  %61 = mul nsw i32 %51, %47
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds i8, ptr %44, i64 %62
  store ptr null, ptr %63, align 8, !tbaa !10
  %64 = load ptr, ptr %44, align 8, !tbaa !10
  store ptr %64, ptr %20, align 8, !tbaa !8
  %65 = add nsw i32 %40, 1
  store i32 %65, ptr %25, align 8, !tbaa !12
  %66 = load ptr, ptr %45, align 8, !tbaa !17
  br label %83

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %67 = mul nsw i64 %indvars.iv, %53
  %68 = getelementptr inbounds i8, ptr %44, i64 %67
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %69 = mul nsw i64 %indvars.iv.next, %53
  %70 = getelementptr inbounds i8, ptr %44, i64 %69
  store ptr %70, ptr %68, align 8, !tbaa !10
  %71 = mul nsw i64 %indvars.iv.next, %53
  %72 = getelementptr inbounds i8, ptr %44, i64 %71
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %73 = mul nsw i64 %indvars.iv.next.1, %53
  %74 = getelementptr inbounds i8, ptr %44, i64 %73
  store ptr %74, ptr %72, align 8, !tbaa !10
  %75 = mul nsw i64 %indvars.iv.next.1, %53
  %76 = getelementptr inbounds i8, ptr %44, i64 %75
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %77 = mul nsw i64 %indvars.iv.next.2, %53
  %78 = getelementptr inbounds i8, ptr %44, i64 %77
  store ptr %78, ptr %76, align 8, !tbaa !10
  %79 = mul nsw i64 %indvars.iv.next.2, %53
  %80 = getelementptr inbounds i8, ptr %44, i64 %79
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %81 = mul nsw i64 %indvars.iv.next.3, %53
  %82 = getelementptr inbounds i8, ptr %44, i64 %81
  store ptr %82, ptr %80, align 8, !tbaa !10
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !23

83:                                               ; preds = %22, %._crit_edge, %2, %10
  %.1 = phi ptr [ %11, %10 ], [ null, %2 ], [ %21, %22 ], [ %66, %._crit_edge ]
  ret ptr %.1
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { mustprogress nounwind willreturn allockind("free") 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 #3 = { 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 #4 = { noreturn nounwind "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { noreturn nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !9, i64 0}
!11 = !{!"_ZTS7d2Block", !9, i64 0}
!12 = !{!13, !14, i64 8}
!13 = !{!"_ZTS16d2BlockAllocator", !9, i64 0, !14, i64 8, !14, i64 12, !6, i64 16}
!14 = !{!"int", !6, i64 0}
!15 = !{!13, !14, i64 12}
!16 = !{!13, !9, i64 0}
!17 = !{!18, !9, i64 8}
!18 = !{!"_ZTS7d2Chunk", !14, i64 0, !9, i64 8}
!19 = !{!14, !14, i64 0}
!20 = !{!18, !14, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.unroll.disable"}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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