; LLVM IR from BrunoLevy/learn-fpga :: LiteX/software/Doom/mc1-doom/src (p_map)

; 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.mobj_s = type { %struct.thinker_s, i32, i32, i32, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i32, ptr, i32, i32, i32, i32, ptr, i32, i32, ptr, i32, %struct.mapthing_t, ptr }
%struct.thinker_s = type { ptr, ptr, %union.actionf_t }
%union.actionf_t = type { ptr }
%struct.mapthing_t = type { i16, i16, i16, i16, i16 }
%struct.subsector_s = type { ptr, i16, i16 }
%struct.sector_t = type { i32, i32, i16, i16, i16, i16, i16, i32, ptr, [4 x i32], %struct.degenmobj_t, i32, ptr, ptr, i32, ptr }
%struct.degenmobj_t = type { %struct.thinker_s, i32, i32, i32 }

@tmthing = external dso_local global ptr, align 8
@tmx = external dso_local global i32, align 4
@tmy = external dso_local global i32, align 4
@tmflags = external dso_local global i32, align 4
@tmbbox = external dso_local global [4 x i32], align 16
@ceilingline = external dso_local global ptr, align 8
@tmdropoffz = external dso_local global i32, align 4
@tmfloorz = external dso_local global i32, align 4
@tmceilingz = external dso_local global i32, align 4
@validcount = external global i32, align 4
@numspechit = external dso_local global i32, align 4
@bmaporgx = external global i32, align 4
@bmaporgy = external global i32, align 4

; 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 ptr @R_PointInSubsector(i32 noundef, i32 noundef) #1

declare i32 @P_BlockThingsIterator(i32 noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @PIT_CheckLine(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @PIT_CheckThing(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @P_CheckPosition(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %16, ptr @tmthing, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.mobj_s, ptr %17, i32 0, i32 24
  %19 = load i32, ptr %18, align 8, !tbaa !11
  store i32 %19, ptr @tmflags, align 4, !tbaa !9
  %20 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %20, ptr @tmx, align 4, !tbaa !9
  %21 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %21, ptr @tmy, align 4, !tbaa !9
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = load ptr, ptr @tmthing, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.mobj_s, ptr %23, i32 0, i32 14
  %25 = load i32, ptr %24, align 8, !tbaa !16
  %26 = add nsw i32 %22, %25
  store i32 %26, ptr @tmbbox, align 16, !tbaa !9
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = load ptr, ptr @tmthing, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.mobj_s, ptr %28, i32 0, i32 14
  %30 = load i32, ptr %29, align 8, !tbaa !16
  %31 = sub nsw i32 %27, %30
  store i32 %31, ptr getelementptr inbounds ([4 x i32], ptr @tmbbox, i64 0, i64 1), align 4, !tbaa !9
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = load ptr, ptr @tmthing, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mobj_s, ptr %33, i32 0, i32 14
  %35 = load i32, ptr %34, align 8, !tbaa !16
  %36 = add nsw i32 %32, %35
  store i32 %36, ptr getelementptr inbounds ([4 x i32], ptr @tmbbox, i64 0, i64 3), align 4, !tbaa !9
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = load ptr, ptr @tmthing, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.mobj_s, ptr %38, i32 0, i32 14
  %40 = load i32, ptr %39, align 8, !tbaa !16
  %41 = sub nsw i32 %37, %40
  store i32 %41, ptr getelementptr inbounds ([4 x i32], ptr @tmbbox, i64 0, i64 2), align 8, !tbaa !9
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = call ptr @R_PointInSubsector(i32 noundef %42, i32 noundef %43)
  store ptr %44, ptr %14, align 8, !tbaa !5
  store ptr null, ptr @ceilingline, align 8, !tbaa !5
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.subsector_s, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = getelementptr inbounds %struct.sector_t, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 8, !tbaa !19
  store i32 %49, ptr @tmdropoffz, align 4, !tbaa !9
  store i32 %49, ptr @tmfloorz, align 4, !tbaa !9
  %50 = load ptr, ptr %14, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.subsector_s, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !17
  %53 = getelementptr inbounds %struct.sector_t, ptr %52, i32 0, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !22
  store i32 %54, ptr @tmceilingz, align 4, !tbaa !9
  %55 = load i32, ptr @validcount, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr @validcount, align 4, !tbaa !9
  store i32 0, ptr @numspechit, align 4, !tbaa !9
  %57 = load i32, ptr @tmflags, align 4, !tbaa !9
  %58 = and i32 %57, 4096
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %3
  store i32 1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %150

61:                                               ; preds = %3
  %62 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @tmbbox, i64 0, i64 2), align 8, !tbaa !9
  %63 = load i32, ptr @bmaporgx, align 4, !tbaa !9
  %64 = sub nsw i32 %62, %63
  %65 = sub nsw i32 %64, 2097152
  %66 = ashr i32 %65, 23
  store i32 %66, ptr %8, align 4, !tbaa !9
  %67 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @tmbbox, i64 0, i64 3), align 4, !tbaa !9
  %68 = load i32, ptr @bmaporgx, align 4, !tbaa !9
  %69 = sub nsw i32 %67, %68
  %70 = add nsw i32 %69, 2097152
  %71 = ashr i32 %70, 23
  store i32 %71, ptr %9, align 4, !tbaa !9
  %72 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @tmbbox, i64 0, i64 1), align 4, !tbaa !9
  %73 = load i32, ptr @bmaporgy, align 4, !tbaa !9
  %74 = sub nsw i32 %72, %73
  %75 = sub nsw i32 %74, 2097152
  %76 = ashr i32 %75, 23
  store i32 %76, ptr %10, align 4, !tbaa !9
  %77 = load i32, ptr @tmbbox, align 16, !tbaa !9
  %78 = load i32, ptr @bmaporgy, align 4, !tbaa !9
  %79 = sub nsw i32 %77, %78
  %80 = add nsw i32 %79, 2097152
  %81 = ashr i32 %80, 23
  store i32 %81, ptr %11, align 4, !tbaa !9
  %82 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %82, ptr %12, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %104, %61
  %84 = load i32, ptr %12, align 4, !tbaa !9
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = icmp sle i32 %84, %85
  br i1 %86, label %87, label %107

87:                                               ; preds = %83
  %88 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %88, ptr %13, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %100, %87
  %90 = load i32, ptr %13, align 4, !tbaa !9
  %91 = load i32, ptr %11, align 4, !tbaa !9
  %92 = icmp sle i32 %90, %91
  br i1 %92, label %93, label %103

93:                                               ; preds = %89
  %94 = load i32, ptr %12, align 4, !tbaa !9
  %95 = load i32, ptr %13, align 4, !tbaa !9
  %96 = call i32 @P_BlockThingsIterator(i32 noundef %94, i32 noundef %95, ptr noundef @PIT_CheckThing)
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %99, label %98

98:                                               ; preds = %93
  store i32 0, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %150

99:                                               ; preds = %93
  br label %100

100:                                              ; preds = %99
  %101 = load i32, ptr %13, align 4, !tbaa !9
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %13, align 4, !tbaa !9
  br label %89, !llvm.loop !23

103:                                              ; preds = %89
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %12, align 4, !tbaa !9
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %12, align 4, !tbaa !9
  br label %83, !llvm.loop !25

107:                                              ; preds = %83
  %108 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @tmbbox, i64 0, i64 2), align 8, !tbaa !9
  %109 = load i32, ptr @bmaporgx, align 4, !tbaa !9
  %110 = sub nsw i32 %108, %109
  %111 = ashr i32 %110, 23
  store i32 %111, ptr %8, align 4, !tbaa !9
  %112 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @tmbbox, i64 0, i64 3), align 4, !tbaa !9
  %113 = load i32, ptr @bmaporgx, align 4, !tbaa !9
  %114 = sub nsw i32 %112, %113
  %115 = ashr i32 %114, 23
  store i32 %115, ptr %9, align 4, !tbaa !9
  %116 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @tmbbox, i64 0, i64 1), align 4, !tbaa !9
  %117 = load i32, ptr @bmaporgy, align 4, !tbaa !9
  %118 = sub nsw i32 %116, %117
  %119 = ashr i32 %118, 23
  store i32 %119, ptr %10, align 4, !tbaa !9
  %120 = load i32, ptr @tmbbox, align 16, !tbaa !9
  %121 = load i32, ptr @bmaporgy, align 4, !tbaa !9
  %122 = sub nsw i32 %120, %121
  %123 = ashr i32 %122, 23
  store i32 %123, ptr %11, align 4, !tbaa !9
  %124 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %124, ptr %12, align 4, !tbaa !9
  br label %125

125:                                              ; preds = %146, %107
  %126 = load i32, ptr %12, align 4, !tbaa !9
  %127 = load i32, ptr %9, align 4, !tbaa !9
  %128 = icmp sle i32 %126, %127
  br i1 %128, label %129, label %149

129:                                              ; preds = %125
  %130 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %130, ptr %13, align 4, !tbaa !9
  br label %131

131:                                              ; preds = %142, %129
  %132 = load i32, ptr %13, align 4, !tbaa !9
  %133 = load i32, ptr %11, align 4, !tbaa !9
  %134 = icmp sle i32 %132, %133
  br i1 %134, label %135, label %145

135:                                              ; preds = %131
  %136 = load i32, ptr %12, align 4, !tbaa !9
  %137 = load i32, ptr %13, align 4, !tbaa !9
  %138 = call i32 @P_BlockLinesIterator(i32 noundef %136, i32 noundef %137, ptr noundef @PIT_CheckLine)
  %139 = icmp ne i32 %138, 0
  br i1 %139, label %141, label %140

140:                                              ; preds = %135
  store i32 0, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %150

141:                                              ; preds = %135
  br label %142

142:                                              ; preds = %141
  %143 = load i32, ptr %13, align 4, !tbaa !9
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %13, align 4, !tbaa !9
  br label %131, !llvm.loop !26

145:                                              ; preds = %131
  br label %146

146:                                              ; preds = %145
  %147 = load i32, ptr %12, align 4, !tbaa !9
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %12, align 4, !tbaa !9
  br label %125, !llvm.loop !27

149:                                              ; preds = %125
  store i32 1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %150

150:                                              ; preds = %149, %140, %98, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %151 = load i32, ptr %4, align 4
  ret i32 %151
}

declare i32 @P_BlockLinesIterator(i32 noundef, i32 noundef, ptr noundef) #1

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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 160}
!12 = !{!"mobj_s", !13, i64 0, !10, i64 24, !10, i64 28, !10, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !6, i64 136, !10, i64 144, !6, i64 152, !10, i64 160, !10, i64 164, !10, i64 168, !10, i64 172, !6, i64 176, !10, i64 184, !10, i64 188, !6, i64 192, !10, i64 200, !14, i64 204, !6, i64 216}
!13 = !{!"thinker_s", !6, i64 0, !6, i64 8, !7, i64 16}
!14 = !{!"", !15, i64 0, !15, i64 2, !15, i64 4, !15, i64 6, !15, i64 8}
!15 = !{!"short", !7, i64 0}
!16 = !{!12, !10, i64 104}
!17 = !{!18, !6, i64 0}
!18 = !{!"subsector_s", !6, i64 0, !15, i64 8, !15, i64 10}
!19 = !{!20, !10, i64 0}
!20 = !{!"", !10, i64 0, !10, i64 4, !15, i64 8, !15, i64 10, !15, i64 12, !15, i64 14, !15, i64 16, !10, i64 20, !6, i64 24, !7, i64 32, !21, i64 48, !10, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !6, i64 120}
!21 = !{!"", !13, i64 0, !10, i64 24, !10, i64 28, !10, i64 32}
!22 = !{!20, !10, i64 4}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = distinct !{!26, !24}
!27 = distinct !{!27, !24}


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

@tmthing = external dso_local local_unnamed_addr global ptr, align 8
@tmx = external dso_local local_unnamed_addr global i32, align 4
@tmy = external dso_local local_unnamed_addr global i32, align 4
@tmflags = external dso_local local_unnamed_addr global i32, align 4
@tmbbox = external dso_local local_unnamed_addr global [4 x i32], align 16
@ceilingline = external dso_local local_unnamed_addr global ptr, align 8
@tmdropoffz = external dso_local local_unnamed_addr global i32, align 4
@tmfloorz = external dso_local local_unnamed_addr global i32, align 4
@tmceilingz = external dso_local local_unnamed_addr global i32, align 4
@validcount = external local_unnamed_addr global i32, align 4
@numspechit = external dso_local local_unnamed_addr global i32, align 4
@bmaporgx = external local_unnamed_addr global i32, align 4
@bmaporgy = external local_unnamed_addr global i32, align 4

declare ptr @R_PointInSubsector(i32 noundef, i32 noundef) local_unnamed_addr #0

declare i32 @P_BlockThingsIterator(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @PIT_CheckLine(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @PIT_CheckThing(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @P_CheckPosition(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  store ptr %0, ptr @tmthing, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 160
  %5 = load i32, ptr %4, align 8, !tbaa !9
  store i32 %5, ptr @tmflags, align 4, !tbaa !15
  store i32 %1, ptr @tmx, align 4, !tbaa !15
  store i32 %2, ptr @tmy, align 4, !tbaa !15
  %6 = getelementptr inbounds i8, ptr %0, i64 104
  %7 = load i32, ptr %6, align 8, !tbaa !16
  %8 = add nsw i32 %7, %2
  store i32 %8, ptr @tmbbox, align 16, !tbaa !15
  %9 = sub nsw i32 %2, %7
  store i32 %9, ptr getelementptr inbounds (i8, ptr @tmbbox, i64 4), align 4, !tbaa !15
  %10 = add nsw i32 %7, %1
  store i32 %10, ptr getelementptr inbounds (i8, ptr @tmbbox, i64 12), align 4, !tbaa !15
  %11 = sub nsw i32 %1, %7
  store i32 %11, ptr getelementptr inbounds (i8, ptr @tmbbox, i64 8), align 8, !tbaa !15
  %12 = tail call ptr @R_PointInSubsector(i32 noundef %1, i32 noundef %2) #2
  store ptr null, ptr @ceilingline, align 8, !tbaa !5
  %13 = load ptr, ptr %12, align 8, !tbaa !17
  %14 = load i32, ptr %13, align 8, !tbaa !19
  store i32 %14, ptr @tmdropoffz, align 4, !tbaa !15
  store i32 %14, ptr @tmfloorz, align 4, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %13, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !22
  store i32 %16, ptr @tmceilingz, align 4, !tbaa !15
  %17 = load i32, ptr @validcount, align 4, !tbaa !15
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr @validcount, align 4, !tbaa !15
  store i32 0, ptr @numspechit, align 4, !tbaa !15
  %19 = load i32, ptr @tmflags, align 4, !tbaa !15
  %20 = and i32 %19, 4096
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %21, label %.loopexit

21:                                               ; preds = %3
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @tmbbox, i64 8), align 8, !tbaa !15
  %23 = load i32, ptr @bmaporgx, align 4, !tbaa !15
  %24 = add i32 %22, -2097152
  %25 = sub i32 %24, %23
  %26 = ashr i32 %25, 23
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @tmbbox, i64 12), align 4, !tbaa !15
  %reass.sub = sub i32 %27, %23
  %28 = add i32 %reass.sub, 2097152
  %29 = ashr i32 %28, 23
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @tmbbox, i64 4), align 4, !tbaa !15
  %31 = load i32, ptr @bmaporgy, align 4, !tbaa !15
  %32 = add i32 %30, -2097152
  %33 = sub i32 %32, %31
  %34 = ashr i32 %33, 23
  %35 = load i32, ptr @tmbbox, align 16, !tbaa !15
  %reass.sub55 = sub i32 %35, %31
  %36 = add i32 %reass.sub55, 2097152
  %37 = ashr i32 %36, 23
  %.not3547 = icmp sgt i32 %26, %29
  %.not3945 = icmp sgt i32 %34, %37
  %or.cond = select i1 %.not3547, i1 true, i1 %.not3945
  br i1 %or.cond, label %._crit_edge49, label %.preheader43

.preheader43:                                     ; preds = %21, %._crit_edge
  %.03348 = phi i32 [ %42, %._crit_edge ], [ %26, %21 ]
  br label %40

38:                                               ; preds = %40
  %39 = add nsw i32 %.03246, 1
  %exitcond.not = icmp eq i32 %.03246, %37
  br i1 %exitcond.not, label %._crit_edge, label %40, !llvm.loop !23

40:                                               ; preds = %.preheader43, %38
  %.03246 = phi i32 [ %34, %.preheader43 ], [ %39, %38 ]
  %41 = tail call i32 @P_BlockThingsIterator(i32 noundef %.03348, i32 noundef %.03246, ptr noundef nonnull @PIT_CheckThing) #2
  %.not40 = icmp eq i32 %41, 0
  br i1 %.not40, label %.loopexit, label %38

._crit_edge:                                      ; preds = %38
  %42 = add nsw i32 %.03348, 1
  %exitcond61.not = icmp eq i32 %.03348, %29
  br i1 %exitcond61.not, label %._crit_edge49.loopexit59, label %.preheader43, !llvm.loop !25

._crit_edge49.loopexit59:                         ; preds = %._crit_edge
  %.pre = load i32, ptr getelementptr inbounds (i8, ptr @tmbbox, i64 8), align 8, !tbaa !15
  %.pre66 = load i32, ptr @bmaporgx, align 4, !tbaa !15
  %.pre67 = load i32, ptr getelementptr inbounds (i8, ptr @tmbbox, i64 12), align 4, !tbaa !15
  %.pre68 = load i32, ptr getelementptr inbounds (i8, ptr @tmbbox, i64 4), align 4, !tbaa !15
  %.pre69 = load i32, ptr @bmaporgy, align 4, !tbaa !15
  %.pre70 = load i32, ptr @tmbbox, align 16, !tbaa !15
  %.pre71 = sub nsw i32 %.pre67, %.pre66
  %.pre72 = sub nsw i32 %.pre70, %.pre69
  br label %._crit_edge49

._crit_edge49:                                    ; preds = %._crit_edge49.loopexit59, %21
  %.pre-phi73 = phi i32 [ %.pre72, %._crit_edge49.loopexit59 ], [ %reass.sub55, %21 ]
  %.pre-phi = phi i32 [ %.pre71, %._crit_edge49.loopexit59 ], [ %reass.sub, %21 ]
  %43 = phi i32 [ %.pre69, %._crit_edge49.loopexit59 ], [ %31, %21 ]
  %44 = phi i32 [ %.pre68, %._crit_edge49.loopexit59 ], [ %30, %21 ]
  %45 = phi i32 [ %.pre66, %._crit_edge49.loopexit59 ], [ %23, %21 ]
  %46 = phi i32 [ %.pre, %._crit_edge49.loopexit59 ], [ %22, %21 ]
  %47 = sub nsw i32 %46, %45
  %48 = ashr i32 %47, 23
  %49 = ashr i32 %.pre-phi, 23
  %50 = sub nsw i32 %44, %43
  %51 = ashr i32 %50, 23
  %52 = ashr i32 %.pre-phi73, 23
  %.not3653 = icmp sgt i32 %48, %49
  %.not3750 = icmp sgt i32 %51, %52
  %or.cond76 = select i1 %.not3653, i1 true, i1 %.not3750
  br i1 %or.cond76, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %._crit_edge49, %._crit_edge52
  %.13454 = phi i32 [ %57, %._crit_edge52 ], [ %48, %._crit_edge49 ]
  br label %55

53:                                               ; preds = %55
  %54 = add nsw i32 %.151, 1
  %exitcond63.not = icmp eq i32 %.151, %52
  br i1 %exitcond63.not, label %._crit_edge52, label %55, !llvm.loop !26

55:                                               ; preds = %.preheader, %53
  %.151 = phi i32 [ %51, %.preheader ], [ %54, %53 ]
  %56 = tail call i32 @P_BlockLinesIterator(i32 noundef %.13454, i32 noundef %.151, ptr noundef nonnull @PIT_CheckLine) #2
  %.not38 = icmp eq i32 %56, 0
  br i1 %.not38, label %.loopexit, label %53

._crit_edge52:                                    ; preds = %53
  %57 = add nsw i32 %.13454, 1
  %exitcond65.not = icmp eq i32 %.13454, %49
  br i1 %exitcond65.not, label %.loopexit, label %.preheader, !llvm.loop !27

.loopexit:                                        ; preds = %40, %._crit_edge52, %55, %._crit_edge49, %3
  %.0 = phi i32 [ 1, %3 ], [ 1, %._crit_edge49 ], [ 0, %55 ], [ 1, %._crit_edge52 ], [ 0, %40 ]
  ret i32 %.0
}

declare i32 @P_BlockLinesIterator(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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 = !{!10, !12, i64 160}
!10 = !{!"mobj_s", !11, i64 0, !12, i64 24, !12, i64 28, !12, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 60, !12, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124, !12, i64 128, !6, i64 136, !12, i64 144, !6, i64 152, !12, i64 160, !12, i64 164, !12, i64 168, !12, i64 172, !6, i64 176, !12, i64 184, !12, i64 188, !6, i64 192, !12, i64 200, !13, i64 204, !6, i64 216}
!11 = !{!"thinker_s", !6, i64 0, !6, i64 8, !7, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !14, i64 0, !14, i64 2, !14, i64 4, !14, i64 6, !14, i64 8}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !12, i64 0}
!16 = !{!10, !12, i64 104}
!17 = !{!18, !6, i64 0}
!18 = !{!"subsector_s", !6, i64 0, !14, i64 8, !14, i64 10}
!19 = !{!20, !12, i64 0}
!20 = !{!"", !12, i64 0, !12, i64 4, !14, i64 8, !14, i64 10, !14, i64 12, !14, i64 14, !14, i64 16, !12, i64 20, !6, i64 24, !7, i64 32, !21, i64 48, !12, i64 88, !6, i64 96, !6, i64 104, !12, i64 112, !6, i64 120}
!21 = !{!"", !11, i64 0, !12, i64 24, !12, i64 28, !12, i64 32}
!22 = !{!20, !12, i64 4}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = distinct !{!26, !24}
!27 = distinct !{!27, !24}


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