; LLVM IR from ponylang/ponyc :: src/libponyrt/mem (heap)

; 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.heap_t = type { [5 x ptr], [5 x ptr], ptr, [4 x ptr], i64, i64 }
%struct.chunk_t = type { ptr, %union.anon, ptr }
%union.anon = type { %struct.anon.0, [8 x i8] }
%struct.anon.0 = type { i64 }

@.str = external hidden unnamed_addr constant [94 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.ponyint_heap_alloc_large = external hidden unnamed_addr constant [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [148 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [26 x i8], align 1

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

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

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local noalias ptr @ponyint_heap_alloc_large(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  %13 = load i32, ptr %8, align 4, !tbaa !11
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %18, label %15

15:                                               ; preds = %4
  %16 = load i32, ptr %8, align 4, !tbaa !11
  %17 = icmp eq i32 %16, -1
  br i1 %17, label %18, label %19

18:                                               ; preds = %15, %4
  br label %20

19:                                               ; preds = %15
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 779, ptr noundef @__func__.ponyint_heap_alloc_large)
  br label %20

20:                                               ; preds = %19, %18
  %21 = load i64, ptr %7, align 8, !tbaa !9
  %22 = call i64 @ponyint_pool_adjust_size(i64 noundef %21)
  store i64 %22, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %23 = load i64, ptr %7, align 8, !tbaa !9
  %24 = call i32 @heap_recycle_index(i64 noundef %23)
  store i32 %24, ptr %10, align 4, !tbaa !11
  %25 = load i32, ptr %10, align 4, !tbaa !11
  %26 = icmp uge i32 %25, 3
  br i1 %26, label %27, label %90

27:                                               ; preds = %20
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.heap_t, ptr %28, i32 0, i32 3
  %30 = getelementptr inbounds [4 x ptr], ptr %29, i64 0, i64 3
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = icmp ne ptr null, %31
  br i1 %32, label %33, label %89

33:                                               ; preds = %27
  %34 = load i64, ptr %7, align 8, !tbaa !9
  %35 = icmp ugt i64 %34, 1024
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  br label %38

37:                                               ; preds = %33
  call void @ponyint_assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i64 noundef 791, ptr noundef @__func__.ponyint_heap_alloc_large)
  br label %38

38:                                               ; preds = %37, %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.heap_t, ptr %39, i32 0, i32 3
  %41 = getelementptr inbounds [4 x ptr], ptr %40, i64 0, i64 3
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  store ptr %42, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store ptr null, ptr %12, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %87, %38
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = icmp ne ptr null, %44
  br i1 %45, label %46, label %53

46:                                               ; preds = %43
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.chunk_t, ptr %47, i32 0, i32 1
  %49 = getelementptr inbounds %struct.anon.0, ptr %48, i32 0, i32 0
  %50 = load i64, ptr %49, align 8, !tbaa !13
  %51 = load i64, ptr %7, align 8, !tbaa !9
  %52 = icmp ule i64 %50, %51
  br label %53

53:                                               ; preds = %46, %43
  %54 = phi i1 [ false, %43 ], [ %52, %46 ]
  br i1 %54, label %55, label %88

55:                                               ; preds = %53
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.chunk_t, ptr %56, i32 0, i32 1
  %58 = getelementptr inbounds %struct.anon.0, ptr %57, i32 0, i32 0
  %59 = load i64, ptr %58, align 8, !tbaa !13
  %60 = load i64, ptr %7, align 8, !tbaa !9
  %61 = icmp eq i64 %59, %60
  br i1 %61, label %62, label %82

62:                                               ; preds = %55
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = icmp eq ptr null, %63
  br i1 %64, label %65, label %72

65:                                               ; preds = %62
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.chunk_t, ptr %66, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !14
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.heap_t, ptr %69, i32 0, i32 3
  %71 = getelementptr inbounds [4 x ptr], ptr %70, i64 0, i64 3
  store ptr %68, ptr %71, align 8, !tbaa !5
  br label %78

72:                                               ; preds = %62
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.chunk_t, ptr %73, i32 0, i32 2
  %75 = load ptr, ptr %74, align 8, !tbaa !14
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.chunk_t, ptr %76, i32 0, i32 2
  store ptr %75, ptr %77, align 8, !tbaa !14
  br label %78

78:                                               ; preds = %72, %65
  %79 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %79, ptr %9, align 8, !tbaa !5
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.chunk_t, ptr %80, i32 0, i32 2
  store ptr null, ptr %81, align 8, !tbaa !14
  br label %88

82:                                               ; preds = %55
  %83 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %83, ptr %12, align 8, !tbaa !5
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.chunk_t, ptr %84, i32 0, i32 2
  %86 = load ptr, ptr %85, align 8, !tbaa !14
  store ptr %86, ptr %11, align 8, !tbaa !5
  br label %87

87:                                               ; preds = %82
  br label %43, !llvm.loop !16

88:                                               ; preds = %78, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %89

89:                                               ; preds = %88, %27
  br label %140

90:                                               ; preds = %20
  %91 = load i32, ptr %10, align 4, !tbaa !11
  %92 = icmp ult i32 %91, 3
  br i1 %92, label %93, label %94

93:                                               ; preds = %90
  br label %95

94:                                               ; preds = %90
  call void @ponyint_assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i64 noundef 816, ptr noundef @__func__.ponyint_heap_alloc_large)
  br label %95

95:                                               ; preds = %94, %93
  %96 = load i32, ptr %10, align 4, !tbaa !11
  %97 = icmp ne i32 0, %96
  br i1 %97, label %98, label %101

98:                                               ; preds = %95
  %99 = load i64, ptr %7, align 8, !tbaa !9
  %100 = icmp ugt i64 %99, 1024
  br i1 %100, label %107, label %101

101:                                              ; preds = %98, %95
  %102 = load i32, ptr %10, align 4, !tbaa !11
  %103 = icmp eq i32 0, %102
  br i1 %103, label %104, label %108

104:                                              ; preds = %101
  %105 = load i64, ptr %7, align 8, !tbaa !9
  %106 = icmp eq i64 1024, %105
  br i1 %106, label %107, label %108

107:                                              ; preds = %104, %98
  br label %109

108:                                              ; preds = %104, %101
  call void @ponyint_assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i64 noundef 817, ptr noundef @__func__.ponyint_heap_alloc_large)
  br label %109

109:                                              ; preds = %108, %107
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.heap_t, ptr %110, i32 0, i32 3
  %112 = load i32, ptr %10, align 4, !tbaa !11
  %113 = zext i32 %112 to i64
  %114 = getelementptr inbounds [4 x ptr], ptr %111, i64 0, i64 %113
  %115 = load ptr, ptr %114, align 8, !tbaa !5
  %116 = icmp ne ptr null, %115
  br i1 %116, label %117, label %139

117:                                              ; preds = %109
  %118 = load ptr, ptr %6, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.heap_t, ptr %118, i32 0, i32 3
  %120 = load i32, ptr %10, align 4, !tbaa !11
  %121 = zext i32 %120 to i64
  %122 = getelementptr inbounds [4 x ptr], ptr %119, i64 0, i64 %121
  %123 = load ptr, ptr %122, align 8, !tbaa !5
  store ptr %123, ptr %9, align 8, !tbaa !5
  %124 = load ptr, ptr %9, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.chunk_t, ptr %124, i32 0, i32 2
  %126 = load ptr, ptr %125, align 8, !tbaa !14
  %127 = load ptr, ptr %6, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.heap_t, ptr %127, i32 0, i32 3
  %129 = load i32, ptr %10, align 4, !tbaa !11
  %130 = zext i32 %129 to i64
  %131 = getelementptr inbounds [4 x ptr], ptr %128, i64 0, i64 %130
  store ptr %126, ptr %131, align 8, !tbaa !5
  %132 = load ptr, ptr %9, align 8, !tbaa !5
  call void @clear_chunk_flags(ptr noundef %132)
  %133 = load i64, ptr %7, align 8, !tbaa !9
  %134 = load ptr, ptr %9, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.chunk_t, ptr %134, i32 0, i32 1
  %136 = getelementptr inbounds %struct.anon.0, ptr %135, i32 0, i32 0
  store i64 %133, ptr %136, align 8, !tbaa !13
  %137 = load ptr, ptr %9, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.chunk_t, ptr %137, i32 0, i32 2
  store ptr null, ptr %138, align 8, !tbaa !14
  br label %139

139:                                              ; preds = %117, %109
  br label %140

140:                                              ; preds = %139, %89
  %141 = load ptr, ptr %9, align 8, !tbaa !5
  %142 = icmp eq ptr null, %141
  br i1 %142, label %143, label %158

143:                                              ; preds = %140
  %144 = call noalias ptr @ponyint_pool_alloc(i64 noundef 0)
  store ptr %144, ptr %9, align 8, !tbaa !5
  %145 = load i64, ptr %7, align 8, !tbaa !9
  %146 = load ptr, ptr %9, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.chunk_t, ptr %146, i32 0, i32 1
  %148 = getelementptr inbounds %struct.anon.0, ptr %147, i32 0, i32 0
  store i64 %145, ptr %148, align 8, !tbaa !13
  %149 = load i64, ptr %7, align 8, !tbaa !9
  %150 = call noalias ptr @ponyint_pool_alloc_size(i64 noundef %149)
  %151 = load ptr, ptr %9, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.chunk_t, ptr %151, i32 0, i32 0
  store ptr %150, ptr %152, align 8, !tbaa !18
  %153 = load ptr, ptr %9, align 8, !tbaa !5
  %154 = call ptr @get_m(ptr noundef %153)
  %155 = load i64, ptr %7, align 8, !tbaa !9
  %156 = load ptr, ptr %9, align 8, !tbaa !5
  %157 = load ptr, ptr %5, align 8, !tbaa !5
  call void @large_pagemap(ptr noundef %154, i64 noundef %155, ptr noundef %156, ptr noundef %157)
  br label %158

158:                                              ; preds = %143, %140
  %159 = load ptr, ptr %9, align 8, !tbaa !5
  %160 = icmp ne ptr %159, null
  br i1 %160, label %161, label %162

161:                                              ; preds = %158
  br label %163

162:                                              ; preds = %158
  call void @ponyint_assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i64 noundef 845, ptr noundef @__func__.ponyint_heap_alloc_large)
  br label %163

163:                                              ; preds = %162, %161
  %164 = load ptr, ptr %9, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.chunk_t, ptr %164, i32 0, i32 0
  %166 = load ptr, ptr %165, align 8, !tbaa !18
  %167 = icmp ne ptr %166, null
  br i1 %167, label %168, label %169

168:                                              ; preds = %163
  br label %170

169:                                              ; preds = %163
  call void @ponyint_assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i64 noundef 846, ptr noundef @__func__.ponyint_heap_alloc_large)
  br label %170

170:                                              ; preds = %169, %168
  %171 = load ptr, ptr %9, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.chunk_t, ptr %171, i32 0, i32 1
  %173 = getelementptr inbounds %struct.anon.0, ptr %172, i32 0, i32 0
  %174 = load i64, ptr %173, align 8, !tbaa !13
  %175 = load i64, ptr %7, align 8, !tbaa !9
  %176 = icmp eq i64 %174, %175
  br i1 %176, label %177, label %178

177:                                              ; preds = %170
  br label %179

178:                                              ; preds = %170
  call void @ponyint_assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i64 noundef 847, ptr noundef @__func__.ponyint_heap_alloc_large)
  br label %179

179:                                              ; preds = %178, %177
  %180 = load ptr, ptr %9, align 8, !tbaa !5
  call void @set_large_chunk_slot(ptr noundef %180, i32 noundef 0)
  %181 = load ptr, ptr %9, align 8, !tbaa !5
  call void @set_chunk_needs_clearing(ptr noundef %181)
  %182 = load ptr, ptr %9, align 8, !tbaa !5
  %183 = load i32, ptr %8, align 4, !tbaa !11
  %184 = and i32 %183, 1
  call void @set_large_chunk_finaliser(ptr noundef %182, i32 noundef %184)
  %185 = load ptr, ptr %6, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.heap_t, ptr %185, i32 0, i32 2
  %187 = load ptr, ptr %186, align 8, !tbaa !19
  %188 = load ptr, ptr %9, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.chunk_t, ptr %188, i32 0, i32 2
  store ptr %187, ptr %189, align 8, !tbaa !14
  %190 = load ptr, ptr %9, align 8, !tbaa !5
  %191 = load ptr, ptr %6, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.heap_t, ptr %191, i32 0, i32 2
  store ptr %190, ptr %192, align 8, !tbaa !19
  %193 = load ptr, ptr %9, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.chunk_t, ptr %193, i32 0, i32 1
  %195 = getelementptr inbounds %struct.anon.0, ptr %194, i32 0, i32 0
  %196 = load i64, ptr %195, align 8, !tbaa !13
  %197 = load ptr, ptr %6, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.heap_t, ptr %197, i32 0, i32 4
  %199 = load i64, ptr %198, align 8, !tbaa !21
  %200 = add i64 %199, %196
  store i64 %200, ptr %198, align 8, !tbaa !21
  %201 = load ptr, ptr %9, align 8, !tbaa !5
  %202 = call ptr @get_m(ptr noundef %201)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret ptr %202
}

; Function Attrs: nounwind uwtable
declare hidden ptr @get_m(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @clear_chunk_flags(ptr noundef) #2

declare noalias ptr @ponyint_pool_alloc(i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @set_chunk_needs_clearing(ptr noundef) #2

declare i64 @ponyint_pool_adjust_size(i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @heap_recycle_index(i64 noundef) #2

declare noalias ptr @ponyint_pool_alloc_size(i64 noundef) #1

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

; Function Attrs: nounwind uwtable
declare hidden void @set_large_chunk_slot(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @set_large_chunk_finaliser(ptr noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #2 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !6, i64 24}
!15 = !{!"chunk_t", !6, i64 0, !7, i64 8, !6, i64 24}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!15, !6, i64 0}
!19 = !{!20, !6, i64 80}
!20 = !{!"heap_t", !7, i64 0, !7, i64 40, !6, i64 80, !7, i64 88, !10, i64 120, !10, i64 128}
!21 = !{!20, !10, i64 120}


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

@.str = external hidden unnamed_addr constant [94 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.ponyint_heap_alloc_large = external hidden unnamed_addr constant [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [148 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [26 x i8], align 1

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noalias ptr @ponyint_heap_alloc_large(ptr noundef %0, ptr nocapture noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = add i32 %3, 1
  %or.cond = icmp ult i32 %5, 2
  br i1 %or.cond, label %7, label %6

6:                                                ; preds = %4
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 779, ptr noundef nonnull @__func__.ponyint_heap_alloc_large) #2
  br label %7

7:                                                ; preds = %4, %6
  %8 = tail call i64 @ponyint_pool_adjust_size(i64 noundef %2) #2
  %9 = tail call i32 @heap_recycle_index(i64 noundef %8)
  %10 = icmp ugt i32 %9, 2
  br i1 %10, label %11, label %29

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %1, i64 112
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %.not72 = icmp eq ptr %13, null
  br i1 %.not72, label %.loopexit, label %14

14:                                               ; preds = %11
  %15 = icmp ugt i64 %8, 1024
  br i1 %15, label %.lr.ph.preheader, label %16

16:                                               ; preds = %14
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i64 noundef 791, ptr noundef nonnull @__func__.ponyint_heap_alloc_large) #2
  %.06679.pre = load ptr, ptr %12, align 8, !tbaa !5
  %.not7380 = icmp eq ptr %.06679.pre, null
  br i1 %.not7380, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %14, %16
  %.06682.ph = phi ptr [ %13, %14 ], [ %.06679.pre, %16 ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %27
  %.06682 = phi ptr [ %.066, %27 ], [ %.06682.ph, %.lr.ph.preheader ]
  %.081 = phi ptr [ %.06682, %27 ], [ null, %.lr.ph.preheader ]
  %17 = getelementptr inbounds i8, ptr %.06682, i64 8
  %18 = load i64, ptr %17, align 8, !tbaa !9
  %.not74 = icmp ugt i64 %18, %8
  br i1 %.not74, label %.loopexit, label %19

19:                                               ; preds = %.lr.ph
  %20 = icmp eq i64 %18, %8
  br i1 %20, label %21, label %27

21:                                               ; preds = %19
  %22 = icmp eq ptr %.081, null
  %23 = getelementptr inbounds i8, ptr %.06682, i64 24
  %24 = load ptr, ptr %23, align 8, !tbaa !10
  %25 = getelementptr inbounds i8, ptr %.081, i64 24
  %.sink = select i1 %22, ptr %12, ptr %25
  store ptr %24, ptr %.sink, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %.06682, i64 24
  store ptr null, ptr %26, align 8, !tbaa !10
  br label %.critedge

27:                                               ; preds = %19
  %28 = getelementptr inbounds i8, ptr %.06682, i64 24
  %.066 = load ptr, ptr %28, align 8, !tbaa !5
  %.not73 = icmp eq ptr %.066, null
  br i1 %.not73, label %.loopexit, label %.lr.ph, !llvm.loop !12

29:                                               ; preds = %7
  %30 = icmp ne i32 %9, 0
  %31 = icmp ugt i64 %8, 1024
  %or.cond3 = and i1 %31, %30
  br i1 %or.cond3, label %36, label %32

32:                                               ; preds = %29
  %33 = icmp eq i32 %9, 0
  %34 = icmp eq i64 %8, 1024
  %or.cond5 = and i1 %34, %33
  br i1 %or.cond5, label %36, label %35

35:                                               ; preds = %32
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i64 noundef 817, ptr noundef nonnull @__func__.ponyint_heap_alloc_large) #2
  br label %36

36:                                               ; preds = %29, %32, %35
  %37 = getelementptr inbounds i8, ptr %1, i64 88
  %38 = zext nneg i32 %9 to i64
  %39 = getelementptr inbounds [4 x ptr], ptr %37, i64 0, i64 %38
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %.not = icmp eq ptr %40, null
  br i1 %.not, label %.loopexit, label %41

41:                                               ; preds = %36
  %42 = getelementptr inbounds i8, ptr %40, i64 24
  %43 = load ptr, ptr %42, align 8, !tbaa !10
  store ptr %43, ptr %39, align 8, !tbaa !5
  tail call void @clear_chunk_flags(ptr noundef nonnull %40)
  %44 = getelementptr inbounds i8, ptr %40, i64 8
  store i64 %8, ptr %44, align 8, !tbaa !9
  store ptr null, ptr %42, align 8, !tbaa !10
  br label %.critedge

.loopexit:                                        ; preds = %27, %.lr.ph, %16, %11, %36
  %45 = tail call noalias ptr @ponyint_pool_alloc(i64 noundef 0) #2
  %46 = getelementptr inbounds i8, ptr %45, i64 8
  store i64 %8, ptr %46, align 8, !tbaa !9
  %47 = tail call noalias ptr @ponyint_pool_alloc_size(i64 noundef %8) #2
  store ptr %47, ptr %45, align 8, !tbaa !14
  %48 = tail call ptr @get_m(ptr noundef nonnull %45)
  tail call void @large_pagemap(ptr noundef %48, i64 noundef %8, ptr noundef nonnull %45, ptr noundef %0)
  br label %.critedge

.critedge:                                        ; preds = %41, %21, %.loopexit
  %.2 = phi ptr [ %45, %.loopexit ], [ %40, %41 ], [ %.06682, %21 ]
  %49 = load ptr, ptr %.2, align 8, !tbaa !14
  %.not75 = icmp eq ptr %49, null
  br i1 %.not75, label %50, label %51

50:                                               ; preds = %.critedge
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i64 noundef 846, ptr noundef nonnull @__func__.ponyint_heap_alloc_large) #2
  br label %51

51:                                               ; preds = %.critedge, %50
  %52 = getelementptr inbounds i8, ptr %.2, i64 8
  %53 = load i64, ptr %52, align 8, !tbaa !9
  %54 = icmp eq i64 %53, %8
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i64 noundef 847, ptr noundef nonnull @__func__.ponyint_heap_alloc_large) #2
  br label %56

56:                                               ; preds = %51, %55
  tail call void @set_large_chunk_slot(ptr noundef nonnull %.2, i32 noundef 0)
  tail call void @set_chunk_needs_clearing(ptr noundef nonnull %.2)
  %57 = and i32 %3, 1
  tail call void @set_large_chunk_finaliser(ptr noundef nonnull %.2, i32 noundef %57)
  %58 = getelementptr inbounds i8, ptr %1, i64 80
  %59 = load ptr, ptr %58, align 8, !tbaa !15
  %60 = getelementptr inbounds i8, ptr %.2, i64 24
  store ptr %59, ptr %60, align 8, !tbaa !10
  store ptr %.2, ptr %58, align 8, !tbaa !15
  %61 = load i64, ptr %52, align 8, !tbaa !9
  %62 = getelementptr inbounds i8, ptr %1, i64 120
  %63 = load i64, ptr %62, align 8, !tbaa !18
  %64 = add i64 %63, %61
  store i64 %64, ptr %62, align 8, !tbaa !18
  %65 = tail call ptr @get_m(ptr noundef nonnull %.2)
  ret ptr %65
}

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

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

declare noalias ptr @ponyint_pool_alloc(i64 noundef) local_unnamed_addr #0

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

declare i64 @ponyint_pool_adjust_size(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @heap_recycle_index(i64 noundef) local_unnamed_addr #1

declare noalias ptr @ponyint_pool_alloc_size(i64 noundef) local_unnamed_addr #0

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

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

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

attributes #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 = { 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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 24}
!11 = !{!"chunk_t", !6, i64 0, !7, i64 8, !6, i64 24}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!11, !6, i64 0}
!15 = !{!16, !6, i64 80}
!16 = !{!"heap_t", !7, i64 0, !7, i64 40, !6, i64 80, !7, i64 88, !17, i64 120, !17, i64 128}
!17 = !{!"long", !7, i64 0}
!18 = !{!16, !17, i64 120}


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