; LLVM IR from narke/Aragveli :: src/kernel/memory (frame)

; 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.anon = type { ptr }
%struct.anon.0 = type { ptr }
%struct.frame = type { i64, i64, %struct.anon.1 }
%struct.anon.1 = type { ptr }
%struct.vbe_mode_info = type <{ i16, i8, i8, i16, i16, i16, i16, i64, i16, i16, i16, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i64, i64, i16, i16, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i64 }>

@free_frames = external dso_local global %struct.anon, align 8
@used_frames = external dso_local global %struct.anon.0, align 8
@__kernel_start = external global i8, align 1
@physical_memory_start = external hidden global i64, align 8
@physical_memory_end = external hidden global i64, align 8
@frames_array = external hidden global ptr, align 8

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

22:                                               ; preds = %5
  store ptr null, ptr @free_frames, align 8, !tbaa !13
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  store ptr null, ptr @used_frames, align 8, !tbaa !13
  br label %26

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26
  %28 = load i64, ptr %7, align 8, !tbaa !5
  %29 = trunc i64 %28 to i32
  %30 = and i32 %29, -4096
  %31 = zext i32 %30 to i64
  store i64 %31, ptr %7, align 8, !tbaa !5
  %32 = and i32 ptrtoint (ptr @__kernel_start to i32), -4096
  %33 = load ptr, ptr %9, align 8, !tbaa !9
  store i32 %32, ptr %33, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 4096, ptr %14, align 4, !tbaa !11
  %34 = load i32, ptr %11, align 4, !tbaa !11
  %35 = sub i32 %34, 1
  %36 = load i32, ptr %14, align 4, !tbaa !11
  %37 = sub i32 %36, 1
  %38 = xor i32 %37, -1
  %39 = and i32 %35, %38
  %40 = load i32, ptr %14, align 4, !tbaa !11
  %41 = add i32 %39, %40
  store i32 %41, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  %42 = load i32, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 4096, ptr %16, align 4, !tbaa !11
  %43 = load i64, ptr %7, align 8, !tbaa !5
  %44 = lshr i64 %43, 12
  %45 = mul i64 %44, 24
  %46 = trunc i64 %45 to i32
  %47 = sub i32 %46, 1
  %48 = load i32, ptr %16, align 4, !tbaa !11
  %49 = sub i32 %48, 1
  %50 = xor i32 %49, -1
  %51 = and i32 %47, %50
  %52 = load i32, ptr %16, align 4, !tbaa !11
  %53 = add i32 %51, %52
  store i32 %53, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  %54 = load i32, ptr %17, align 4, !tbaa !11
  %55 = add i32 %42, %54
  %56 = load ptr, ptr %10, align 8, !tbaa !9
  store i32 %55, ptr %56, align 4, !tbaa !11
  %57 = load ptr, ptr %10, align 8, !tbaa !9
  %58 = load i32, ptr %57, align 4, !tbaa !11
  %59 = zext i32 %58 to i64
  %60 = load i64, ptr %7, align 8, !tbaa !5
  %61 = icmp ugt i64 %59, %60
  br i1 %61, label %62, label %63

62:                                               ; preds = %27
  store i32 -3, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %202

63:                                               ; preds = %27
  store i64 4096, ptr @physical_memory_start, align 8, !tbaa !5
  %64 = load i64, ptr %7, align 8, !tbaa !5
  store i64 %64, ptr @physical_memory_end, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  store i32 4096, ptr %19, align 4, !tbaa !11
  %65 = load i32, ptr %11, align 4, !tbaa !11
  %66 = sub i32 %65, 1
  %67 = load i32, ptr %19, align 4, !tbaa !11
  %68 = sub i32 %67, 1
  %69 = xor i32 %68, -1
  %70 = and i32 %66, %69
  %71 = load i32, ptr %19, align 4, !tbaa !11
  %72 = add i32 %70, %71
  store i32 %72, ptr %20, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  %73 = load i32, ptr %20, align 4, !tbaa !11
  %74 = zext i32 %73 to i64
  %75 = inttoptr i64 %74 to ptr
  store ptr %75, ptr @frames_array, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  store i32 0, ptr %13, align 4, !tbaa !11
  %76 = load ptr, ptr @frames_array, align 8, !tbaa !9
  store ptr %76, ptr %12, align 8, !tbaa !9
  br label %77

77:                                               ; preds = %196, %63
  %78 = load i32, ptr %13, align 4, !tbaa !11
  %79 = zext i32 %78 to i64
  %80 = load i64, ptr @physical_memory_end, align 8, !tbaa !5
  %81 = icmp ult i64 %79, %80
  br i1 %81, label %82, label %201

82:                                               ; preds = %77
  %83 = load ptr, ptr %12, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 8 %83, i8 0, i64 24, i1 false)
  %84 = load i32, ptr %13, align 4, !tbaa !11
  %85 = zext i32 %84 to i64
  %86 = load ptr, ptr %12, align 8, !tbaa !9
  %87 = getelementptr inbounds %struct.frame, ptr %86, i32 0, i32 0
  store i64 %85, ptr %87, align 8, !tbaa !15
  %88 = load i32, ptr %13, align 4, !tbaa !11
  %89 = zext i32 %88 to i64
  %90 = load i64, ptr @physical_memory_start, align 8, !tbaa !5
  %91 = icmp ult i64 %89, %90
  br i1 %91, label %92, label %93

92:                                               ; preds = %82
  store i32 0, ptr %21, align 4, !tbaa !11
  br label %170

93:                                               ; preds = %82
  %94 = load i32, ptr %13, align 4, !tbaa !11
  %95 = zext i32 %94 to i64
  %96 = load i64, ptr @physical_memory_start, align 8, !tbaa !5
  %97 = icmp uge i64 %95, %96
  br i1 %97, label %98, label %106

98:                                               ; preds = %93
  %99 = load i32, ptr %13, align 4, !tbaa !11
  %100 = zext i32 %99 to i64
  %101 = load ptr, ptr %8, align 8, !tbaa !9
  %102 = getelementptr inbounds %struct.vbe_mode_info, ptr %101, i32 0, i32 29
  %103 = load i64, ptr %102, align 1, !tbaa !17
  %104 = icmp ult i64 %100, %103
  br i1 %104, label %105, label %106

105:                                              ; preds = %98
  store i32 2, ptr %21, align 4, !tbaa !11
  br label %169

106:                                              ; preds = %98, %93
  %107 = load i32, ptr %13, align 4, !tbaa !11
  %108 = zext i32 %107 to i64
  %109 = load ptr, ptr %8, align 8, !tbaa !9
  %110 = getelementptr inbounds %struct.vbe_mode_info, ptr %109, i32 0, i32 29
  %111 = load i64, ptr %110, align 1, !tbaa !17
  %112 = icmp uge i64 %108, %111
  br i1 %112, label %113, label %132

113:                                              ; preds = %106
  %114 = load i32, ptr %13, align 4, !tbaa !11
  %115 = zext i32 %114 to i64
  %116 = load ptr, ptr %8, align 8, !tbaa !9
  %117 = getelementptr inbounds %struct.vbe_mode_info, ptr %116, i32 0, i32 29
  %118 = load i64, ptr %117, align 1, !tbaa !17
  %119 = load ptr, ptr %8, align 8, !tbaa !9
  %120 = getelementptr inbounds %struct.vbe_mode_info, ptr %119, i32 0, i32 8
  %121 = load i16, ptr %120, align 1, !tbaa !20
  %122 = zext i16 %121 to i32
  %123 = load ptr, ptr %8, align 8, !tbaa !9
  %124 = getelementptr inbounds %struct.vbe_mode_info, ptr %123, i32 0, i32 10
  %125 = load i16, ptr %124, align 1, !tbaa !21
  %126 = zext i16 %125 to i32
  %127 = mul nsw i32 %122, %126
  %128 = sext i32 %127 to i64
  %129 = add i64 %118, %128
  %130 = icmp ult i64 %115, %129
  br i1 %130, label %131, label %132

131:                                              ; preds = %113
  store i32 1, ptr %21, align 4, !tbaa !11
  br label %168

132:                                              ; preds = %113, %106
  %133 = load i32, ptr %13, align 4, !tbaa !11
  %134 = zext i32 %133 to i64
  %135 = load ptr, ptr %8, align 8, !tbaa !9
  %136 = getelementptr inbounds %struct.vbe_mode_info, ptr %135, i32 0, i32 29
  %137 = load i64, ptr %136, align 1, !tbaa !17
  %138 = load ptr, ptr %8, align 8, !tbaa !9
  %139 = getelementptr inbounds %struct.vbe_mode_info, ptr %138, i32 0, i32 8
  %140 = load i16, ptr %139, align 1, !tbaa !20
  %141 = zext i16 %140 to i32
  %142 = load ptr, ptr %8, align 8, !tbaa !9
  %143 = getelementptr inbounds %struct.vbe_mode_info, ptr %142, i32 0, i32 10
  %144 = load i16, ptr %143, align 1, !tbaa !21
  %145 = zext i16 %144 to i32
  %146 = mul nsw i32 %141, %145
  %147 = sext i32 %146 to i64
  %148 = add i64 %137, %147
  %149 = icmp uge i64 %134, %148
  br i1 %149, label %150, label %154

150:                                              ; preds = %132
  %151 = load i32, ptr %13, align 4, !tbaa !11
  %152 = icmp ult i32 %151, ptrtoint (ptr @__kernel_start to i32)
  br i1 %152, label %153, label %154

153:                                              ; preds = %150
  store i32 2, ptr %21, align 4, !tbaa !11
  br label %167

154:                                              ; preds = %150, %132
  %155 = load i32, ptr %13, align 4, !tbaa !11
  %156 = load ptr, ptr %9, align 8, !tbaa !9
  %157 = load i32, ptr %156, align 4, !tbaa !11
  %158 = icmp uge i32 %155, %157
  br i1 %158, label %159, label %165

159:                                              ; preds = %154
  %160 = load i32, ptr %13, align 4, !tbaa !11
  %161 = load ptr, ptr %10, align 8, !tbaa !9
  %162 = load i32, ptr %161, align 4, !tbaa !11
  %163 = icmp ult i32 %160, %162
  br i1 %163, label %164, label %165

164:                                              ; preds = %159
  store i32 3, ptr %21, align 4, !tbaa !11
  br label %166

165:                                              ; preds = %159, %154
  store i32 2, ptr %21, align 4, !tbaa !11
  br label %166

166:                                              ; preds = %165, %164
  br label %167

167:                                              ; preds = %166, %153
  br label %168

168:                                              ; preds = %167, %131
  br label %169

169:                                              ; preds = %168, %105
  br label %170

170:                                              ; preds = %169, %92
  %171 = load i32, ptr %21, align 4, !tbaa !11
  switch i32 %171, label %194 [
    i32 2, label %172
    i32 1, label %183
    i32 3, label %183
  ]

172:                                              ; preds = %170
  %173 = load ptr, ptr %12, align 8, !tbaa !9
  %174 = getelementptr inbounds %struct.frame, ptr %173, i32 0, i32 1
  store i64 0, ptr %174, align 8, !tbaa !22
  br label %175

175:                                              ; preds = %172
  %176 = load ptr, ptr @free_frames, align 8, !tbaa !13
  %177 = load ptr, ptr %12, align 8, !tbaa !9
  %178 = getelementptr inbounds %struct.frame, ptr %177, i32 0, i32 2
  %179 = getelementptr inbounds %struct.anon.1, ptr %178, i32 0, i32 0
  store ptr %176, ptr %179, align 8, !tbaa !23
  %180 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %180, ptr @free_frames, align 8, !tbaa !13
  br label %181

181:                                              ; preds = %175
  br label %182

182:                                              ; preds = %181
  br label %195

183:                                              ; preds = %170, %170
  %184 = load ptr, ptr %12, align 8, !tbaa !9
  %185 = getelementptr inbounds %struct.frame, ptr %184, i32 0, i32 1
  store i64 1, ptr %185, align 8, !tbaa !22
  br label %186

186:                                              ; preds = %183
  %187 = load ptr, ptr @used_frames, align 8, !tbaa !13
  %188 = load ptr, ptr %12, align 8, !tbaa !9
  %189 = getelementptr inbounds %struct.frame, ptr %188, i32 0, i32 2
  %190 = getelementptr inbounds %struct.anon.1, ptr %189, i32 0, i32 0
  store ptr %187, ptr %190, align 8, !tbaa !23
  %191 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %191, ptr @used_frames, align 8, !tbaa !13
  br label %192

192:                                              ; preds = %186
  br label %193

193:                                              ; preds = %192
  br label %195

194:                                              ; preds = %170
  br label %195

195:                                              ; preds = %194, %193, %182
  br label %196

196:                                              ; preds = %195
  %197 = load i32, ptr %13, align 4, !tbaa !11
  %198 = add i32 %197, 4096
  store i32 %198, ptr %13, align 4, !tbaa !11
  %199 = load ptr, ptr %12, align 8, !tbaa !9
  %200 = getelementptr inbounds %struct.frame, ptr %199, i32 1
  store ptr %200, ptr %12, align 8, !tbaa !9
  br label %77, !llvm.loop !24

201:                                              ; preds = %77
  store i32 0, ptr %6, align 4
  store i32 1, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  br label %202

202:                                              ; preds = %201, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %203 = load i32, ptr %6, align 4
  ret i32 %203
}

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

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

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !10, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"frame", !6, i64 0, !6, i64 8, !14, i64 16}
!17 = !{!18, !6, i64 44}
!18 = !{!"vbe_mode_info", !19, i64 0, !7, i64 2, !7, i64 3, !19, i64 4, !19, i64 6, !19, i64 8, !19, i64 10, !6, i64 12, !19, i64 20, !19, i64 22, !19, i64 24, !7, i64 26, !7, i64 27, !7, i64 28, !7, i64 29, !7, i64 30, !7, i64 31, !7, i64 32, !7, i64 33, !7, i64 34, !7, i64 35, !7, i64 36, !7, i64 37, !7, i64 38, !7, i64 39, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 43, !6, i64 44, !6, i64 52, !19, i64 60, !19, i64 62, !7, i64 64, !7, i64 65, !7, i64 66, !7, i64 67, !7, i64 68, !7, i64 69, !7, i64 70, !7, i64 71, !7, i64 72, !7, i64 73, !6, i64 74}
!19 = !{!"short", !7, i64 0}
!20 = !{!18, !19, i64 20}
!21 = !{!18, !19, i64 24}
!22 = !{!16, !6, i64 8}
!23 = !{!16, !10, i64 16}
!24 = distinct !{!24, !25}
!25 = !{!"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.anon = type { ptr }
%struct.anon.0 = type { ptr }

@free_frames = external dso_local local_unnamed_addr global %struct.anon, align 8
@used_frames = external dso_local local_unnamed_addr global %struct.anon.0, align 8
@__kernel_start = external global i8, align 1
@physical_memory_start = external hidden local_unnamed_addr global i64, align 8
@physical_memory_end = external hidden local_unnamed_addr global i64, align 8
@frames_array = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local range(i32 -3, 1) i32 @frame_setup(i64 noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef %2, ptr nocapture noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  store ptr null, ptr @free_frames, align 8, !tbaa !5
  store ptr null, ptr @used_frames, align 8, !tbaa !5
  %6 = and i64 %0, 4294963200
  %7 = and i32 ptrtoint (ptr @__kernel_start to i32), -4096
  store i32 %7, ptr %2, align 4, !tbaa !10
  %8 = add i32 %4, -1
  %9 = and i32 %8, -4096
  %10 = add i32 %9, 4096
  %11 = lshr exact i64 %6, 12
  %12 = trunc nuw nsw i64 %11 to i32
  %13 = mul nuw nsw i32 %12, 24
  %14 = add nsw i32 %13, -1
  %15 = and i32 %14, -4096
  %16 = add nsw i32 %15, 4096
  %17 = add i32 %16, %10
  store i32 %17, ptr %3, align 4, !tbaa !10
  %18 = zext i32 %17 to i64
  %19 = icmp ult i64 %6, %18
  br i1 %19, label %.loopexit, label %20

20:                                               ; preds = %5
  store i64 4096, ptr @physical_memory_start, align 8, !tbaa !12
  store i64 %6, ptr @physical_memory_end, align 8, !tbaa !12
  %21 = zext i32 %10 to i64
  %22 = inttoptr i64 %21 to ptr
  store ptr %22, ptr @frames_array, align 8, !tbaa !14
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %20
  %23 = getelementptr inbounds i8, ptr %1, i64 44
  %24 = getelementptr inbounds i8, ptr %1, i64 20
  %25 = getelementptr inbounds i8, ptr %1, i64 24
  %used_frames.promoted = load ptr, ptr @used_frames, align 8, !tbaa !5
  %free_frames.promoted = load ptr, ptr @free_frames, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %.lr.ph, %52
  %.0526468 = phi ptr [ %free_frames.promoted, %.lr.ph ], [ %.0526467, %52 ]
  %.0526466 = phi ptr [ %used_frames.promoted, %.lr.ph ], [ %.0526465, %52 ]
  %27 = phi i64 [ 0, %.lr.ph ], [ %55, %52 ]
  %.05264 = phi ptr [ %22, %.lr.ph ], [ %54, %52 ]
  %.05362 = phi i32 [ 0, %.lr.ph ], [ %53, %52 ]
  %28 = getelementptr inbounds i8, ptr %.05264, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %28, i8 0, i64 16, i1 false)
  store i64 %27, ptr %.05264, align 8, !tbaa !15
  %29 = load i64, ptr @physical_memory_start, align 8, !tbaa !12
  %30 = icmp ugt i64 %29, %27
  br i1 %30, label %52, label %31

31:                                               ; preds = %26
  %32 = load i64, ptr %23, align 1, !tbaa !17
  %33 = icmp ugt i64 %32, %27
  br i1 %33, label %.sink.split, label %34

34:                                               ; preds = %31
  %35 = load i16, ptr %24, align 1, !tbaa !20
  %36 = zext i16 %35 to i64
  %37 = load i16, ptr %25, align 1, !tbaa !21
  %38 = zext i16 %37 to i64
  %39 = mul nuw nsw i64 %38, %36
  %40 = add nuw nsw i64 %39, %32
  %41 = icmp ugt i64 %40, %27
  br i1 %41, label %49, label %42

42:                                               ; preds = %34
  %43 = icmp ult i32 %.05362, ptrtoint (ptr @__kernel_start to i32)
  br i1 %43, label %.sink.split, label %44

44:                                               ; preds = %42
  %45 = load i32, ptr %2, align 4, !tbaa !10
  %.not57 = icmp ult i32 %.05362, %45
  br i1 %.not57, label %.sink.split, label %46

46:                                               ; preds = %44
  %47 = load i32, ptr %3, align 4, !tbaa !10
  %48 = icmp ult i32 %.05362, %47
  br i1 %48, label %49, label %.sink.split

49:                                               ; preds = %34, %46
  %50 = getelementptr inbounds i8, ptr %.05264, i64 8
  store i64 1, ptr %50, align 8, !tbaa !22
  br label %.sink.split

.sink.split:                                      ; preds = %42, %31, %46, %44, %49
  %.0526468.sink = phi ptr [ %.0526466, %49 ], [ %.0526468, %44 ], [ %.0526468, %46 ], [ %.0526468, %31 ], [ %.0526468, %42 ]
  %free_frames.sink = phi ptr [ @used_frames, %49 ], [ @free_frames, %44 ], [ @free_frames, %46 ], [ @free_frames, %31 ], [ @free_frames, %42 ]
  %.0526467.ph = phi ptr [ %.0526468, %49 ], [ %.05264, %44 ], [ %.05264, %46 ], [ %.05264, %31 ], [ %.05264, %42 ]
  %.0526465.ph = phi ptr [ %.05264, %49 ], [ %.0526466, %44 ], [ %.0526466, %46 ], [ %.0526466, %31 ], [ %.0526466, %42 ]
  %51 = getelementptr inbounds i8, ptr %.05264, i64 16
  store ptr %.0526468.sink, ptr %51, align 8, !tbaa !23
  store ptr %.05264, ptr %free_frames.sink, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %.sink.split, %26
  %.0526467 = phi ptr [ %.0526468, %26 ], [ %.0526467.ph, %.sink.split ]
  %.0526465 = phi ptr [ %.0526466, %26 ], [ %.0526465.ph, %.sink.split ]
  %53 = add i32 %.05362, 4096
  %54 = getelementptr inbounds i8, ptr %.05264, i64 24
  %55 = zext i32 %53 to i64
  %56 = load i64, ptr @physical_memory_end, align 8, !tbaa !12
  %57 = icmp ugt i64 %56, %55
  br i1 %57, label %26, label %.loopexit, !llvm.loop !24

.loopexit:                                        ; preds = %52, %20, %5
  %.051 = phi i32 [ -3, %5 ], [ 0, %20 ], [ 0, %52 ]
  ret i32 %.051
}

; 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 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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) }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !13, i64 0}
!16 = !{!"frame", !13, i64 0, !13, i64 8, !6, i64 16}
!17 = !{!18, !13, i64 44}
!18 = !{!"vbe_mode_info", !19, i64 0, !8, i64 2, !8, i64 3, !19, i64 4, !19, i64 6, !19, i64 8, !19, i64 10, !13, i64 12, !19, i64 20, !19, i64 22, !19, i64 24, !8, i64 26, !8, i64 27, !8, i64 28, !8, i64 29, !8, i64 30, !8, i64 31, !8, i64 32, !8, i64 33, !8, i64 34, !8, i64 35, !8, i64 36, !8, i64 37, !8, i64 38, !8, i64 39, !8, i64 40, !8, i64 41, !8, i64 42, !8, i64 43, !13, i64 44, !13, i64 52, !19, i64 60, !19, i64 62, !8, i64 64, !8, i64 65, !8, i64 66, !8, i64 67, !8, i64 68, !8, i64 69, !8, i64 70, !8, i64 71, !8, i64 72, !8, i64 73, !13, i64 74}
!19 = !{!"short", !8, i64 0}
!20 = !{!18, !19, i64 20}
!21 = !{!18, !19, i64 24}
!22 = !{!16, !13, i64 8}
!23 = !{!16, !7, i64 16}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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