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

; 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.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 }
%struct.thinker_s = type { ptr, ptr, %union.actionf_t }
%union.actionf_t = type { ptr }
%struct.floormove_t = type { %struct.thinker_s, i32, i32, ptr, i32, i32, i16, i32, i32 }
%struct.line_s = type { ptr, ptr, i32, i32, i16, i16, i16, [2 x i16], [4 x i32], i32, ptr, ptr, i32, ptr }
%struct.side_t = type { i32, i32, i16, i16, i16, ptr }

@sectors = external global ptr, align 8
@textureheight = external global ptr, align 8

; 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

; Function Attrs: nounwind uwtable
declare dso_local void @T_MoveFloor(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @EV_DoFloor(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i32 -1, ptr %5, align 4, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %408, %26, %2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = call i32 @P_FindSectorFromLineTag(ptr noundef %13, i32 noundef %14)
  store i32 %15, ptr %5, align 4, !tbaa !9
  %16 = icmp sge i32 %15, 0
  br i1 %16, label %17, label %409

17:                                               ; preds = %12
  %18 = load ptr, ptr @sectors, align 8, !tbaa !5
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds %struct.sector_t, ptr %18, i64 %20
  store ptr %21, ptr %8, align 8, !tbaa !5
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.sector_t, ptr %22, i32 0, i32 13
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %17
  br label %12, !llvm.loop !16

27:                                               ; preds = %17
  store i32 1, ptr %6, align 4, !tbaa !9
  %28 = call ptr @Z_Malloc(i32 noundef 64, i32 noundef 51, ptr noundef null)
  store ptr %28, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.floormove_t, ptr %29, i32 0, i32 0
  call void @P_AddThinker(ptr noundef %30)
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.sector_t, ptr %32, i32 0, i32 13
  store ptr %31, ptr %33, align 8, !tbaa !11
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.floormove_t, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %struct.thinker_s, ptr %35, i32 0, i32 2
  store ptr @T_MoveFloor, ptr %36, align 8, !tbaa !18
  %37 = load i32, ptr %4, align 4, !tbaa !9
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.floormove_t, ptr %38, i32 0, i32 1
  store i32 %37, ptr %39, align 8, !tbaa !19
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.floormove_t, ptr %40, i32 0, i32 2
  store i32 0, ptr %41, align 4, !tbaa !21
  %42 = load i32, ptr %4, align 4, !tbaa !9
  switch i32 %42, label %407 [
    i32 0, label %43
    i32 1, label %55
    i32 2, label %67
    i32 9, label %92
    i32 3, label %95
    i32 10, label %129
    i32 4, label %144
    i32 7, label %159
    i32 12, label %175
    i32 8, label %191
    i32 5, label %221
    i32 6, label %311
  ]

43:                                               ; preds = %27
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.floormove_t, ptr %44, i32 0, i32 4
  store i32 -1, ptr %45, align 8, !tbaa !22
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.floormove_t, ptr %47, i32 0, i32 3
  store ptr %46, ptr %48, align 8, !tbaa !23
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.floormove_t, ptr %49, i32 0, i32 8
  store i32 65536, ptr %50, align 8, !tbaa !24
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = call i32 @P_FindHighestFloorSurrounding(ptr noundef %51)
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.floormove_t, ptr %53, i32 0, i32 7
  store i32 %52, ptr %54, align 4, !tbaa !25
  br label %408

55:                                               ; preds = %27
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.floormove_t, ptr %56, i32 0, i32 4
  store i32 -1, ptr %57, align 8, !tbaa !22
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.floormove_t, ptr %59, i32 0, i32 3
  store ptr %58, ptr %60, align 8, !tbaa !23
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.floormove_t, ptr %61, i32 0, i32 8
  store i32 65536, ptr %62, align 8, !tbaa !24
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = call i32 @P_FindLowestFloorSurrounding(ptr noundef %63)
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.floormove_t, ptr %65, i32 0, i32 7
  store i32 %64, ptr %66, align 4, !tbaa !25
  br label %408

67:                                               ; preds = %27
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.floormove_t, ptr %68, i32 0, i32 4
  store i32 -1, ptr %69, align 8, !tbaa !22
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.floormove_t, ptr %71, i32 0, i32 3
  store ptr %70, ptr %72, align 8, !tbaa !23
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.floormove_t, ptr %73, i32 0, i32 8
  store i32 262144, ptr %74, align 8, !tbaa !24
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = call i32 @P_FindHighestFloorSurrounding(ptr noundef %75)
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.floormove_t, ptr %77, i32 0, i32 7
  store i32 %76, ptr %78, align 4, !tbaa !25
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.floormove_t, ptr %79, i32 0, i32 7
  %81 = load i32, ptr %80, align 4, !tbaa !25
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.sector_t, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 8, !tbaa !26
  %85 = icmp ne i32 %81, %84
  br i1 %85, label %86, label %91

86:                                               ; preds = %67
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.floormove_t, ptr %87, i32 0, i32 7
  %89 = load i32, ptr %88, align 4, !tbaa !25
  %90 = add nsw i32 %89, 524288
  store i32 %90, ptr %88, align 4, !tbaa !25
  br label %91

91:                                               ; preds = %86, %67
  br label %408

92:                                               ; preds = %27
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.floormove_t, ptr %93, i32 0, i32 2
  store i32 1, ptr %94, align 4, !tbaa !21
  br label %95

95:                                               ; preds = %92, %27
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.floormove_t, ptr %96, i32 0, i32 4
  store i32 1, ptr %97, align 8, !tbaa !22
  %98 = load ptr, ptr %8, align 8, !tbaa !5
  %99 = load ptr, ptr %9, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.floormove_t, ptr %99, i32 0, i32 3
  store ptr %98, ptr %100, align 8, !tbaa !23
  %101 = load ptr, ptr %9, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.floormove_t, ptr %101, i32 0, i32 8
  store i32 65536, ptr %102, align 8, !tbaa !24
  %103 = load ptr, ptr %8, align 8, !tbaa !5
  %104 = call i32 @P_FindLowestCeilingSurrounding(ptr noundef %103)
  %105 = load ptr, ptr %9, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.floormove_t, ptr %105, i32 0, i32 7
  store i32 %104, ptr %106, align 4, !tbaa !25
  %107 = load ptr, ptr %9, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.floormove_t, ptr %107, i32 0, i32 7
  %109 = load i32, ptr %108, align 4, !tbaa !25
  %110 = load ptr, ptr %8, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.sector_t, ptr %110, i32 0, i32 1
  %112 = load i32, ptr %111, align 4, !tbaa !27
  %113 = icmp sgt i32 %109, %112
  br i1 %113, label %114, label %120

114:                                              ; preds = %95
  %115 = load ptr, ptr %8, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.sector_t, ptr %115, i32 0, i32 1
  %117 = load i32, ptr %116, align 4, !tbaa !27
  %118 = load ptr, ptr %9, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.floormove_t, ptr %118, i32 0, i32 7
  store i32 %117, ptr %119, align 4, !tbaa !25
  br label %120

120:                                              ; preds = %114, %95
  %121 = load i32, ptr %4, align 4, !tbaa !9
  %122 = icmp eq i32 %121, 9
  %123 = zext i1 %122 to i32
  %124 = mul nsw i32 524288, %123
  %125 = load ptr, ptr %9, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.floormove_t, ptr %125, i32 0, i32 7
  %127 = load i32, ptr %126, align 4, !tbaa !25
  %128 = sub nsw i32 %127, %124
  store i32 %128, ptr %126, align 4, !tbaa !25
  br label %408

129:                                              ; preds = %27
  %130 = load ptr, ptr %9, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.floormove_t, ptr %130, i32 0, i32 4
  store i32 1, ptr %131, align 8, !tbaa !22
  %132 = load ptr, ptr %8, align 8, !tbaa !5
  %133 = load ptr, ptr %9, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.floormove_t, ptr %133, i32 0, i32 3
  store ptr %132, ptr %134, align 8, !tbaa !23
  %135 = load ptr, ptr %9, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.floormove_t, ptr %135, i32 0, i32 8
  store i32 262144, ptr %136, align 8, !tbaa !24
  %137 = load ptr, ptr %8, align 8, !tbaa !5
  %138 = load ptr, ptr %8, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.sector_t, ptr %138, i32 0, i32 0
  %140 = load i32, ptr %139, align 8, !tbaa !26
  %141 = call i32 @P_FindNextHighestFloor(ptr noundef %137, i32 noundef %140)
  %142 = load ptr, ptr %9, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.floormove_t, ptr %142, i32 0, i32 7
  store i32 %141, ptr %143, align 4, !tbaa !25
  br label %408

144:                                              ; preds = %27
  %145 = load ptr, ptr %9, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.floormove_t, ptr %145, i32 0, i32 4
  store i32 1, ptr %146, align 8, !tbaa !22
  %147 = load ptr, ptr %8, align 8, !tbaa !5
  %148 = load ptr, ptr %9, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.floormove_t, ptr %148, i32 0, i32 3
  store ptr %147, ptr %149, align 8, !tbaa !23
  %150 = load ptr, ptr %9, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.floormove_t, ptr %150, i32 0, i32 8
  store i32 65536, ptr %151, align 8, !tbaa !24
  %152 = load ptr, ptr %8, align 8, !tbaa !5
  %153 = load ptr, ptr %8, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.sector_t, ptr %153, i32 0, i32 0
  %155 = load i32, ptr %154, align 8, !tbaa !26
  %156 = call i32 @P_FindNextHighestFloor(ptr noundef %152, i32 noundef %155)
  %157 = load ptr, ptr %9, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.floormove_t, ptr %157, i32 0, i32 7
  store i32 %156, ptr %158, align 4, !tbaa !25
  br label %408

159:                                              ; preds = %27
  %160 = load ptr, ptr %9, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.floormove_t, ptr %160, i32 0, i32 4
  store i32 1, ptr %161, align 8, !tbaa !22
  %162 = load ptr, ptr %8, align 8, !tbaa !5
  %163 = load ptr, ptr %9, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.floormove_t, ptr %163, i32 0, i32 3
  store ptr %162, ptr %164, align 8, !tbaa !23
  %165 = load ptr, ptr %9, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.floormove_t, ptr %165, i32 0, i32 8
  store i32 65536, ptr %166, align 8, !tbaa !24
  %167 = load ptr, ptr %9, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.floormove_t, ptr %167, i32 0, i32 3
  %169 = load ptr, ptr %168, align 8, !tbaa !23
  %170 = getelementptr inbounds %struct.sector_t, ptr %169, i32 0, i32 0
  %171 = load i32, ptr %170, align 8, !tbaa !26
  %172 = add nsw i32 %171, 1572864
  %173 = load ptr, ptr %9, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.floormove_t, ptr %173, i32 0, i32 7
  store i32 %172, ptr %174, align 4, !tbaa !25
  br label %408

175:                                              ; preds = %27
  %176 = load ptr, ptr %9, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.floormove_t, ptr %176, i32 0, i32 4
  store i32 1, ptr %177, align 8, !tbaa !22
  %178 = load ptr, ptr %8, align 8, !tbaa !5
  %179 = load ptr, ptr %9, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.floormove_t, ptr %179, i32 0, i32 3
  store ptr %178, ptr %180, align 8, !tbaa !23
  %181 = load ptr, ptr %9, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.floormove_t, ptr %181, i32 0, i32 8
  store i32 65536, ptr %182, align 8, !tbaa !24
  %183 = load ptr, ptr %9, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.floormove_t, ptr %183, i32 0, i32 3
  %185 = load ptr, ptr %184, align 8, !tbaa !23
  %186 = getelementptr inbounds %struct.sector_t, ptr %185, i32 0, i32 0
  %187 = load i32, ptr %186, align 8, !tbaa !26
  %188 = add nsw i32 %187, 33554432
  %189 = load ptr, ptr %9, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct.floormove_t, ptr %189, i32 0, i32 7
  store i32 %188, ptr %190, align 4, !tbaa !25
  br label %408

191:                                              ; preds = %27
  %192 = load ptr, ptr %9, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.floormove_t, ptr %192, i32 0, i32 4
  store i32 1, ptr %193, align 8, !tbaa !22
  %194 = load ptr, ptr %8, align 8, !tbaa !5
  %195 = load ptr, ptr %9, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.floormove_t, ptr %195, i32 0, i32 3
  store ptr %194, ptr %196, align 8, !tbaa !23
  %197 = load ptr, ptr %9, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.floormove_t, ptr %197, i32 0, i32 8
  store i32 65536, ptr %198, align 8, !tbaa !24
  %199 = load ptr, ptr %9, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.floormove_t, ptr %199, i32 0, i32 3
  %201 = load ptr, ptr %200, align 8, !tbaa !23
  %202 = getelementptr inbounds %struct.sector_t, ptr %201, i32 0, i32 0
  %203 = load i32, ptr %202, align 8, !tbaa !26
  %204 = add nsw i32 %203, 1572864
  %205 = load ptr, ptr %9, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.floormove_t, ptr %205, i32 0, i32 7
  store i32 %204, ptr %206, align 4, !tbaa !25
  %207 = load ptr, ptr %3, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct.line_s, ptr %207, i32 0, i32 10
  %209 = load ptr, ptr %208, align 8, !tbaa !28
  %210 = getelementptr inbounds %struct.sector_t, ptr %209, i32 0, i32 2
  %211 = load i16, ptr %210, align 8, !tbaa !30
  %212 = load ptr, ptr %8, align 8, !tbaa !5
  %213 = getelementptr inbounds %struct.sector_t, ptr %212, i32 0, i32 2
  store i16 %211, ptr %213, align 8, !tbaa !30
  %214 = load ptr, ptr %3, align 8, !tbaa !5
  %215 = getelementptr inbounds %struct.line_s, ptr %214, i32 0, i32 10
  %216 = load ptr, ptr %215, align 8, !tbaa !28
  %217 = getelementptr inbounds %struct.sector_t, ptr %216, i32 0, i32 5
  %218 = load i16, ptr %217, align 2, !tbaa !31
  %219 = load ptr, ptr %8, align 8, !tbaa !5
  %220 = getelementptr inbounds %struct.sector_t, ptr %219, i32 0, i32 5
  store i16 %218, ptr %220, align 2, !tbaa !31
  br label %408

221:                                              ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 2147483647, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %222 = load ptr, ptr %9, align 8, !tbaa !5
  %223 = getelementptr inbounds %struct.floormove_t, ptr %222, i32 0, i32 4
  store i32 1, ptr %223, align 8, !tbaa !22
  %224 = load ptr, ptr %8, align 8, !tbaa !5
  %225 = load ptr, ptr %9, align 8, !tbaa !5
  %226 = getelementptr inbounds %struct.floormove_t, ptr %225, i32 0, i32 3
  store ptr %224, ptr %226, align 8, !tbaa !23
  %227 = load ptr, ptr %9, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct.floormove_t, ptr %227, i32 0, i32 8
  store i32 65536, ptr %228, align 8, !tbaa !24
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %229

229:                                              ; preds = %298, %221
  %230 = load i32, ptr %7, align 4, !tbaa !9
  %231 = load ptr, ptr %8, align 8, !tbaa !5
  %232 = getelementptr inbounds %struct.sector_t, ptr %231, i32 0, i32 14
  %233 = load i32, ptr %232, align 8, !tbaa !32
  %234 = icmp slt i32 %230, %233
  br i1 %234, label %235, label %301

235:                                              ; preds = %229
  %236 = load i32, ptr %5, align 4, !tbaa !9
  %237 = load i32, ptr %7, align 4, !tbaa !9
  %238 = call i32 @twoSided(i32 noundef %236, i32 noundef %237)
  %239 = icmp ne i32 %238, 0
  br i1 %239, label %240, label %297

240:                                              ; preds = %235
  %241 = load i32, ptr %5, align 4, !tbaa !9
  %242 = load i32, ptr %7, align 4, !tbaa !9
  %243 = call ptr @getSide(i32 noundef %241, i32 noundef %242, i32 noundef 0)
  store ptr %243, ptr %11, align 8, !tbaa !5
  %244 = load ptr, ptr %11, align 8, !tbaa !5
  %245 = getelementptr inbounds %struct.side_t, ptr %244, i32 0, i32 3
  %246 = load i16, ptr %245, align 2, !tbaa !33
  %247 = sext i16 %246 to i32
  %248 = icmp sge i32 %247, 0
  br i1 %248, label %249, label %268

249:                                              ; preds = %240
  %250 = load ptr, ptr @textureheight, align 8, !tbaa !5
  %251 = load ptr, ptr %11, align 8, !tbaa !5
  %252 = getelementptr inbounds %struct.side_t, ptr %251, i32 0, i32 3
  %253 = load i16, ptr %252, align 2, !tbaa !33
  %254 = sext i16 %253 to i64
  %255 = getelementptr inbounds i32, ptr %250, i64 %254
  %256 = load i32, ptr %255, align 4, !tbaa !9
  %257 = load i32, ptr %10, align 4, !tbaa !9
  %258 = icmp slt i32 %256, %257
  br i1 %258, label %259, label %267

259:                                              ; preds = %249
  %260 = load ptr, ptr @textureheight, align 8, !tbaa !5
  %261 = load ptr, ptr %11, align 8, !tbaa !5
  %262 = getelementptr inbounds %struct.side_t, ptr %261, i32 0, i32 3
  %263 = load i16, ptr %262, align 2, !tbaa !33
  %264 = sext i16 %263 to i64
  %265 = getelementptr inbounds i32, ptr %260, i64 %264
  %266 = load i32, ptr %265, align 4, !tbaa !9
  store i32 %266, ptr %10, align 4, !tbaa !9
  br label %267

267:                                              ; preds = %259, %249
  br label %268

268:                                              ; preds = %267, %240
  %269 = load i32, ptr %5, align 4, !tbaa !9
  %270 = load i32, ptr %7, align 4, !tbaa !9
  %271 = call ptr @getSide(i32 noundef %269, i32 noundef %270, i32 noundef 1)
  store ptr %271, ptr %11, align 8, !tbaa !5
  %272 = load ptr, ptr %11, align 8, !tbaa !5
  %273 = getelementptr inbounds %struct.side_t, ptr %272, i32 0, i32 3
  %274 = load i16, ptr %273, align 2, !tbaa !33
  %275 = sext i16 %274 to i32
  %276 = icmp sge i32 %275, 0
  br i1 %276, label %277, label %296

277:                                              ; preds = %268
  %278 = load ptr, ptr @textureheight, align 8, !tbaa !5
  %279 = load ptr, ptr %11, align 8, !tbaa !5
  %280 = getelementptr inbounds %struct.side_t, ptr %279, i32 0, i32 3
  %281 = load i16, ptr %280, align 2, !tbaa !33
  %282 = sext i16 %281 to i64
  %283 = getelementptr inbounds i32, ptr %278, i64 %282
  %284 = load i32, ptr %283, align 4, !tbaa !9
  %285 = load i32, ptr %10, align 4, !tbaa !9
  %286 = icmp slt i32 %284, %285
  br i1 %286, label %287, label %295

287:                                              ; preds = %277
  %288 = load ptr, ptr @textureheight, align 8, !tbaa !5
  %289 = load ptr, ptr %11, align 8, !tbaa !5
  %290 = getelementptr inbounds %struct.side_t, ptr %289, i32 0, i32 3
  %291 = load i16, ptr %290, align 2, !tbaa !33
  %292 = sext i16 %291 to i64
  %293 = getelementptr inbounds i32, ptr %288, i64 %292
  %294 = load i32, ptr %293, align 4, !tbaa !9
  store i32 %294, ptr %10, align 4, !tbaa !9
  br label %295

295:                                              ; preds = %287, %277
  br label %296

296:                                              ; preds = %295, %268
  br label %297

297:                                              ; preds = %296, %235
  br label %298

298:                                              ; preds = %297
  %299 = load i32, ptr %7, align 4, !tbaa !9
  %300 = add nsw i32 %299, 1
  store i32 %300, ptr %7, align 4, !tbaa !9
  br label %229, !llvm.loop !35

301:                                              ; preds = %229
  %302 = load ptr, ptr %9, align 8, !tbaa !5
  %303 = getelementptr inbounds %struct.floormove_t, ptr %302, i32 0, i32 3
  %304 = load ptr, ptr %303, align 8, !tbaa !23
  %305 = getelementptr inbounds %struct.sector_t, ptr %304, i32 0, i32 0
  %306 = load i32, ptr %305, align 8, !tbaa !26
  %307 = load i32, ptr %10, align 4, !tbaa !9
  %308 = add nsw i32 %306, %307
  %309 = load ptr, ptr %9, align 8, !tbaa !5
  %310 = getelementptr inbounds %struct.floormove_t, ptr %309, i32 0, i32 7
  store i32 %308, ptr %310, align 4, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %408

311:                                              ; preds = %27
  %312 = load ptr, ptr %9, align 8, !tbaa !5
  %313 = getelementptr inbounds %struct.floormove_t, ptr %312, i32 0, i32 4
  store i32 -1, ptr %313, align 8, !tbaa !22
  %314 = load ptr, ptr %8, align 8, !tbaa !5
  %315 = load ptr, ptr %9, align 8, !tbaa !5
  %316 = getelementptr inbounds %struct.floormove_t, ptr %315, i32 0, i32 3
  store ptr %314, ptr %316, align 8, !tbaa !23
  %317 = load ptr, ptr %9, align 8, !tbaa !5
  %318 = getelementptr inbounds %struct.floormove_t, ptr %317, i32 0, i32 8
  store i32 65536, ptr %318, align 8, !tbaa !24
  %319 = load ptr, ptr %8, align 8, !tbaa !5
  %320 = call i32 @P_FindLowestFloorSurrounding(ptr noundef %319)
  %321 = load ptr, ptr %9, align 8, !tbaa !5
  %322 = getelementptr inbounds %struct.floormove_t, ptr %321, i32 0, i32 7
  store i32 %320, ptr %322, align 4, !tbaa !25
  %323 = load ptr, ptr %8, align 8, !tbaa !5
  %324 = getelementptr inbounds %struct.sector_t, ptr %323, i32 0, i32 2
  %325 = load i16, ptr %324, align 8, !tbaa !30
  %326 = load ptr, ptr %9, align 8, !tbaa !5
  %327 = getelementptr inbounds %struct.floormove_t, ptr %326, i32 0, i32 6
  store i16 %325, ptr %327, align 8, !tbaa !36
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %328

328:                                              ; preds = %403, %311
  %329 = load i32, ptr %7, align 4, !tbaa !9
  %330 = load ptr, ptr %8, align 8, !tbaa !5
  %331 = getelementptr inbounds %struct.sector_t, ptr %330, i32 0, i32 14
  %332 = load i32, ptr %331, align 8, !tbaa !32
  %333 = icmp slt i32 %329, %332
  br i1 %333, label %334, label %406

334:                                              ; preds = %328
  %335 = load i32, ptr %5, align 4, !tbaa !9
  %336 = load i32, ptr %7, align 4, !tbaa !9
  %337 = call i32 @twoSided(i32 noundef %335, i32 noundef %336)
  %338 = icmp ne i32 %337, 0
  br i1 %338, label %339, label %402

339:                                              ; preds = %334
  %340 = load i32, ptr %5, align 4, !tbaa !9
  %341 = load i32, ptr %7, align 4, !tbaa !9
  %342 = call ptr @getSide(i32 noundef %340, i32 noundef %341, i32 noundef 0)
  %343 = getelementptr inbounds %struct.side_t, ptr %342, i32 0, i32 5
  %344 = load ptr, ptr %343, align 8, !tbaa !37
  %345 = load ptr, ptr @sectors, align 8, !tbaa !5
  %346 = ptrtoint ptr %344 to i64
  %347 = ptrtoint ptr %345 to i64
  %348 = sub i64 %346, %347
  %349 = sdiv exact i64 %348, 128
  %350 = load i32, ptr %5, align 4, !tbaa !9
  %351 = sext i32 %350 to i64
  %352 = icmp eq i64 %349, %351
  br i1 %352, label %353, label %377

353:                                              ; preds = %339
  %354 = load i32, ptr %5, align 4, !tbaa !9
  %355 = load i32, ptr %7, align 4, !tbaa !9
  %356 = call ptr @getSector(i32 noundef %354, i32 noundef %355, i32 noundef 1)
  store ptr %356, ptr %8, align 8, !tbaa !5
  %357 = load ptr, ptr %8, align 8, !tbaa !5
  %358 = getelementptr inbounds %struct.sector_t, ptr %357, i32 0, i32 0
  %359 = load i32, ptr %358, align 8, !tbaa !26
  %360 = load ptr, ptr %9, align 8, !tbaa !5
  %361 = getelementptr inbounds %struct.floormove_t, ptr %360, i32 0, i32 7
  %362 = load i32, ptr %361, align 4, !tbaa !25
  %363 = icmp eq i32 %359, %362
  br i1 %363, label %364, label %376

364:                                              ; preds = %353
  %365 = load ptr, ptr %8, align 8, !tbaa !5
  %366 = getelementptr inbounds %struct.sector_t, ptr %365, i32 0, i32 2
  %367 = load i16, ptr %366, align 8, !tbaa !30
  %368 = load ptr, ptr %9, align 8, !tbaa !5
  %369 = getelementptr inbounds %struct.floormove_t, ptr %368, i32 0, i32 6
  store i16 %367, ptr %369, align 8, !tbaa !36
  %370 = load ptr, ptr %8, align 8, !tbaa !5
  %371 = getelementptr inbounds %struct.sector_t, ptr %370, i32 0, i32 5
  %372 = load i16, ptr %371, align 2, !tbaa !31
  %373 = sext i16 %372 to i32
  %374 = load ptr, ptr %9, align 8, !tbaa !5
  %375 = getelementptr inbounds %struct.floormove_t, ptr %374, i32 0, i32 5
  store i32 %373, ptr %375, align 4, !tbaa !38
  br label %406

376:                                              ; preds = %353
  br label %401

377:                                              ; preds = %339
  %378 = load i32, ptr %5, align 4, !tbaa !9
  %379 = load i32, ptr %7, align 4, !tbaa !9
  %380 = call ptr @getSector(i32 noundef %378, i32 noundef %379, i32 noundef 0)
  store ptr %380, ptr %8, align 8, !tbaa !5
  %381 = load ptr, ptr %8, align 8, !tbaa !5
  %382 = getelementptr inbounds %struct.sector_t, ptr %381, i32 0, i32 0
  %383 = load i32, ptr %382, align 8, !tbaa !26
  %384 = load ptr, ptr %9, align 8, !tbaa !5
  %385 = getelementptr inbounds %struct.floormove_t, ptr %384, i32 0, i32 7
  %386 = load i32, ptr %385, align 4, !tbaa !25
  %387 = icmp eq i32 %383, %386
  br i1 %387, label %388, label %400

388:                                              ; preds = %377
  %389 = load ptr, ptr %8, align 8, !tbaa !5
  %390 = getelementptr inbounds %struct.sector_t, ptr %389, i32 0, i32 2
  %391 = load i16, ptr %390, align 8, !tbaa !30
  %392 = load ptr, ptr %9, align 8, !tbaa !5
  %393 = getelementptr inbounds %struct.floormove_t, ptr %392, i32 0, i32 6
  store i16 %391, ptr %393, align 8, !tbaa !36
  %394 = load ptr, ptr %8, align 8, !tbaa !5
  %395 = getelementptr inbounds %struct.sector_t, ptr %394, i32 0, i32 5
  %396 = load i16, ptr %395, align 2, !tbaa !31
  %397 = sext i16 %396 to i32
  %398 = load ptr, ptr %9, align 8, !tbaa !5
  %399 = getelementptr inbounds %struct.floormove_t, ptr %398, i32 0, i32 5
  store i32 %397, ptr %399, align 4, !tbaa !38
  br label %406

400:                                              ; preds = %377
  br label %401

401:                                              ; preds = %400, %376
  br label %402

402:                                              ; preds = %401, %334
  br label %403

403:                                              ; preds = %402
  %404 = load i32, ptr %7, align 4, !tbaa !9
  %405 = add nsw i32 %404, 1
  store i32 %405, ptr %7, align 4, !tbaa !9
  br label %328, !llvm.loop !39

406:                                              ; preds = %388, %364, %328
  br label %407

407:                                              ; preds = %406, %27
  br label %408

408:                                              ; preds = %407, %301, %191, %175, %159, %144, %129, %120, %91, %55, %43
  br label %12, !llvm.loop !16

409:                                              ; preds = %12
  %410 = load i32, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %410
}

declare i32 @P_FindSectorFromLineTag(ptr noundef, i32 noundef) #2

declare ptr @Z_Malloc(i32 noundef, i32 noundef, ptr noundef) #2

declare void @P_AddThinker(ptr noundef) #2

declare i32 @P_FindHighestFloorSurrounding(ptr noundef) #2

declare i32 @P_FindLowestFloorSurrounding(ptr noundef) #2

declare i32 @P_FindLowestCeilingSurrounding(ptr noundef) #2

declare i32 @P_FindNextHighestFloor(ptr noundef, i32 noundef) #2

declare i32 @twoSided(i32 noundef, i32 noundef) #2

declare ptr @getSide(i32 noundef, i32 noundef, i32 noundef) #2

declare ptr @getSector(i32 noundef, i32 noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !6, i64 104}
!12 = !{!"", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !13, i64 14, !13, i64 16, !10, i64 20, !6, i64 24, !7, i64 32, !14, i64 48, !10, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !6, i64 120}
!13 = !{!"short", !7, i64 0}
!14 = !{!"", !15, i64 0, !10, i64 24, !10, i64 28, !10, i64 32}
!15 = !{!"thinker_s", !6, i64 0, !6, i64 8, !7, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !10, i64 24}
!20 = !{!"", !15, i64 0, !10, i64 24, !10, i64 28, !6, i64 32, !10, i64 40, !10, i64 44, !13, i64 48, !10, i64 52, !10, i64 56}
!21 = !{!20, !10, i64 28}
!22 = !{!20, !10, i64 40}
!23 = !{!20, !6, i64 32}
!24 = !{!20, !10, i64 56}
!25 = !{!20, !10, i64 52}
!26 = !{!12, !10, i64 0}
!27 = !{!12, !10, i64 4}
!28 = !{!29, !6, i64 56}
!29 = !{!"line_s", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !13, i64 24, !13, i64 26, !13, i64 28, !7, i64 30, !7, i64 36, !10, i64 52, !6, i64 56, !6, i64 64, !10, i64 72, !6, i64 80}
!30 = !{!12, !13, i64 8}
!31 = !{!12, !13, i64 14}
!32 = !{!12, !10, i64 112}
!33 = !{!34, !13, i64 10}
!34 = !{!"", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !6, i64 16}
!35 = distinct !{!35, !17}
!36 = !{!20, !13, i64 48}
!37 = !{!34, !6, i64 16}
!38 = !{!20, !10, i64 44}
!39 = distinct !{!39, !17}


; 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.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 }
%struct.thinker_s = type { ptr, ptr, %union.actionf_t }
%union.actionf_t = type { ptr }

@sectors = external local_unnamed_addr global ptr, align 8
@textureheight = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @T_MoveFloor(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @EV_DoFloor(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 56
  %4 = icmp eq i32 %1, 9
  %.neg = select i1 %4, i32 -524288, i32 0
  br label %.outer

.outer:                                           ; preds = %.loopexit, %2
  %.0143.ph = phi i32 [ 1, %.loopexit ], [ 0, %2 ]
  %.0138.ph = phi i32 [ %6, %.loopexit ], [ -1, %2 ]
  br label %5

5:                                                ; preds = %.outer, %8
  %.0138 = phi i32 [ %6, %8 ], [ %.0138.ph, %.outer ]
  %6 = tail call i32 @P_FindSectorFromLineTag(ptr noundef %0, i32 noundef %.0138) #3
  %7 = icmp sgt i32 %6, -1
  br i1 %7, label %8, label %181

8:                                                ; preds = %5
  %9 = load ptr, ptr @sectors, align 8, !tbaa !5
  %10 = zext nneg i32 %6 to i64
  %11 = getelementptr inbounds %struct.sector_t, ptr %9, i64 %10
  %12 = getelementptr inbounds i8, ptr %11, i64 104
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %14, label %5, !llvm.loop !15

14:                                               ; preds = %8
  %15 = getelementptr inbounds i8, ptr %11, i64 104
  %16 = tail call ptr @Z_Malloc(i32 noundef 64, i32 noundef 51, ptr noundef null) #3
  tail call void @P_AddThinker(ptr noundef %16) #3
  store ptr %16, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  store ptr @T_MoveFloor, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %16, i64 24
  store i32 %1, ptr %18, align 8, !tbaa !18
  %19 = getelementptr inbounds i8, ptr %16, i64 28
  store i32 0, ptr %19, align 4, !tbaa !20
  switch i32 %1, label %.loopexit [
    i32 0, label %20
    i32 1, label %26
    i32 2, label %32
    i32 9, label %41
    i32 3, label %42
    i32 10, label %51
    i32 4, label %58
    i32 7, label %65
    i32 12, label %72
    i32 8, label %79
    i32 5, label %93
    i32 6, label %129
  ]

20:                                               ; preds = %14
  %21 = getelementptr inbounds i8, ptr %16, i64 40
  store i32 -1, ptr %21, align 8, !tbaa !21
  %22 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %11, ptr %22, align 8, !tbaa !22
  %23 = getelementptr inbounds i8, ptr %16, i64 56
  store i32 65536, ptr %23, align 8, !tbaa !23
  %24 = tail call i32 @P_FindHighestFloorSurrounding(ptr noundef nonnull %11) #3
  %25 = getelementptr inbounds i8, ptr %16, i64 52
  store i32 %24, ptr %25, align 4, !tbaa !24
  br label %.loopexit

26:                                               ; preds = %14
  %27 = getelementptr inbounds i8, ptr %16, i64 40
  store i32 -1, ptr %27, align 8, !tbaa !21
  %28 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %11, ptr %28, align 8, !tbaa !22
  %29 = getelementptr inbounds i8, ptr %16, i64 56
  store i32 65536, ptr %29, align 8, !tbaa !23
  %30 = tail call i32 @P_FindLowestFloorSurrounding(ptr noundef nonnull %11) #3
  %31 = getelementptr inbounds i8, ptr %16, i64 52
  store i32 %30, ptr %31, align 4, !tbaa !24
  br label %.loopexit

32:                                               ; preds = %14
  %33 = getelementptr inbounds i8, ptr %16, i64 40
  store i32 -1, ptr %33, align 8, !tbaa !21
  %34 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %11, ptr %34, align 8, !tbaa !22
  %35 = getelementptr inbounds i8, ptr %16, i64 56
  store i32 262144, ptr %35, align 8, !tbaa !23
  %36 = tail call i32 @P_FindHighestFloorSurrounding(ptr noundef nonnull %11) #3
  %37 = getelementptr inbounds i8, ptr %16, i64 52
  store i32 %36, ptr %37, align 4, !tbaa !24
  %38 = load i32, ptr %11, align 8, !tbaa !25
  %.not151 = icmp eq i32 %36, %38
  br i1 %.not151, label %.loopexit, label %39

39:                                               ; preds = %32
  %40 = add nsw i32 %36, 524288
  store i32 %40, ptr %37, align 4, !tbaa !24
  br label %.loopexit

41:                                               ; preds = %14
  store i32 1, ptr %19, align 4, !tbaa !20
  br label %42

42:                                               ; preds = %41, %14
  %43 = getelementptr inbounds i8, ptr %16, i64 40
  store i32 1, ptr %43, align 8, !tbaa !21
  %44 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %11, ptr %44, align 8, !tbaa !22
  %45 = getelementptr inbounds i8, ptr %16, i64 56
  store i32 65536, ptr %45, align 8, !tbaa !23
  %46 = tail call i32 @P_FindLowestCeilingSurrounding(ptr noundef nonnull %11) #3
  %47 = getelementptr inbounds i8, ptr %16, i64 52
  %48 = getelementptr inbounds i8, ptr %11, i64 4
  %49 = load i32, ptr %48, align 4, !tbaa !26
  %spec.store.select = tail call i32 @llvm.smin.i32(i32 %46, i32 %49)
  %50 = add i32 %spec.store.select, %.neg
  store i32 %50, ptr %47, align 4, !tbaa !24
  br label %.loopexit

51:                                               ; preds = %14
  %52 = getelementptr inbounds i8, ptr %16, i64 40
  store i32 1, ptr %52, align 8, !tbaa !21
  %53 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %11, ptr %53, align 8, !tbaa !22
  %54 = getelementptr inbounds i8, ptr %16, i64 56
  store i32 262144, ptr %54, align 8, !tbaa !23
  %55 = load i32, ptr %11, align 8, !tbaa !25
  %56 = tail call i32 @P_FindNextHighestFloor(ptr noundef nonnull %11, i32 noundef %55) #3
  %57 = getelementptr inbounds i8, ptr %16, i64 52
  store i32 %56, ptr %57, align 4, !tbaa !24
  br label %.loopexit

58:                                               ; preds = %14
  %59 = getelementptr inbounds i8, ptr %16, i64 40
  store i32 1, ptr %59, align 8, !tbaa !21
  %60 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %11, ptr %60, align 8, !tbaa !22
  %61 = getelementptr inbounds i8, ptr %16, i64 56
  store i32 65536, ptr %61, align 8, !tbaa !23
  %62 = load i32, ptr %11, align 8, !tbaa !25
  %63 = tail call i32 @P_FindNextHighestFloor(ptr noundef nonnull %11, i32 noundef %62) #3
  %64 = getelementptr inbounds i8, ptr %16, i64 52
  store i32 %63, ptr %64, align 4, !tbaa !24
  br label %.loopexit

65:                                               ; preds = %14
  %66 = getelementptr inbounds i8, ptr %16, i64 40
  store i32 1, ptr %66, align 8, !tbaa !21
  %67 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %11, ptr %67, align 8, !tbaa !22
  %68 = getelementptr inbounds i8, ptr %16, i64 56
  store i32 65536, ptr %68, align 8, !tbaa !23
  %69 = load i32, ptr %11, align 8, !tbaa !25
  %70 = add nsw i32 %69, 1572864
  %71 = getelementptr inbounds i8, ptr %16, i64 52
  store i32 %70, ptr %71, align 4, !tbaa !24
  br label %.loopexit

72:                                               ; preds = %14
  %73 = getelementptr inbounds i8, ptr %16, i64 40
  store i32 1, ptr %73, align 8, !tbaa !21
  %74 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %11, ptr %74, align 8, !tbaa !22
  %75 = getelementptr inbounds i8, ptr %16, i64 56
  store i32 65536, ptr %75, align 8, !tbaa !23
  %76 = load i32, ptr %11, align 8, !tbaa !25
  %77 = add nsw i32 %76, 33554432
  %78 = getelementptr inbounds i8, ptr %16, i64 52
  store i32 %77, ptr %78, align 4, !tbaa !24
  br label %.loopexit

79:                                               ; preds = %14
  %80 = getelementptr inbounds i8, ptr %16, i64 40
  store i32 1, ptr %80, align 8, !tbaa !21
  %81 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %11, ptr %81, align 8, !tbaa !22
  %82 = getelementptr inbounds i8, ptr %16, i64 56
  store i32 65536, ptr %82, align 8, !tbaa !23
  %83 = load i32, ptr %11, align 8, !tbaa !25
  %84 = add nsw i32 %83, 1572864
  %85 = getelementptr inbounds i8, ptr %16, i64 52
  store i32 %84, ptr %85, align 4, !tbaa !24
  %86 = load ptr, ptr %3, align 8, !tbaa !27
  %87 = getelementptr inbounds i8, ptr %86, i64 8
  %88 = load i16, ptr %87, align 8, !tbaa !29
  %89 = getelementptr inbounds i8, ptr %11, i64 8
  store i16 %88, ptr %89, align 8, !tbaa !29
  %90 = getelementptr inbounds i8, ptr %86, i64 14
  %91 = load i16, ptr %90, align 2, !tbaa !30
  %92 = getelementptr inbounds i8, ptr %11, i64 14
  store i16 %91, ptr %92, align 2, !tbaa !30
  br label %.loopexit

93:                                               ; preds = %14
  %94 = getelementptr inbounds i8, ptr %16, i64 40
  store i32 1, ptr %94, align 8, !tbaa !21
  %95 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %11, ptr %95, align 8, !tbaa !22
  %96 = getelementptr inbounds i8, ptr %16, i64 56
  store i32 65536, ptr %96, align 8, !tbaa !23
  %97 = getelementptr inbounds i8, ptr %11, i64 112
  %98 = load i32, ptr %97, align 8, !tbaa !31
  %99 = icmp sgt i32 %98, 0
  br i1 %99, label %.lr.ph163, label %._crit_edge

.lr.ph163:                                        ; preds = %93, %121
  %.0162 = phi i32 [ %.2, %121 ], [ 2147483647, %93 ]
  %.0141161 = phi i32 [ %122, %121 ], [ 0, %93 ]
  %100 = tail call i32 @twoSided(i32 noundef %6, i32 noundef %.0141161) #3
  %.not150 = icmp eq i32 %100, 0
  br i1 %.not150, label %121, label %101

101:                                              ; preds = %.lr.ph163
  %102 = tail call ptr @getSide(i32 noundef %6, i32 noundef %.0141161, i32 noundef 0) #3
  %103 = getelementptr inbounds i8, ptr %102, i64 10
  %104 = load i16, ptr %103, align 2, !tbaa !32
  %105 = icmp sgt i16 %104, -1
  br i1 %105, label %106, label %111

106:                                              ; preds = %101
  %107 = load ptr, ptr @textureheight, align 8, !tbaa !5
  %108 = zext nneg i16 %104 to i64
  %109 = getelementptr inbounds i32, ptr %107, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !34
  %spec.select = tail call i32 @llvm.smin.i32(i32 %110, i32 %.0162)
  br label %111

111:                                              ; preds = %106, %101
  %.1 = phi i32 [ %.0162, %101 ], [ %spec.select, %106 ]
  %112 = tail call ptr @getSide(i32 noundef %6, i32 noundef %.0141161, i32 noundef 1) #3
  %113 = getelementptr inbounds i8, ptr %112, i64 10
  %114 = load i16, ptr %113, align 2, !tbaa !32
  %115 = icmp sgt i16 %114, -1
  br i1 %115, label %116, label %121

116:                                              ; preds = %111
  %117 = load ptr, ptr @textureheight, align 8, !tbaa !5
  %118 = zext nneg i16 %114 to i64
  %119 = getelementptr inbounds i32, ptr %117, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !34
  %spec.select152 = tail call i32 @llvm.smin.i32(i32 %120, i32 %.1)
  br label %121

121:                                              ; preds = %116, %.lr.ph163, %111
  %.2 = phi i32 [ %.1, %111 ], [ %.0162, %.lr.ph163 ], [ %spec.select152, %116 ]
  %122 = add nuw nsw i32 %.0141161, 1
  %123 = load i32, ptr %97, align 8, !tbaa !31
  %124 = icmp slt i32 %122, %123
  br i1 %124, label %.lr.ph163, label %._crit_edge.loopexit, !llvm.loop !35

._crit_edge.loopexit:                             ; preds = %121
  %.pre = load ptr, ptr %95, align 8, !tbaa !22
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %93
  %125 = phi ptr [ %11, %93 ], [ %.pre, %._crit_edge.loopexit ]
  %.0.lcssa = phi i32 [ 2147483647, %93 ], [ %.2, %._crit_edge.loopexit ]
  %126 = load i32, ptr %125, align 8, !tbaa !25
  %127 = add nsw i32 %126, %.0.lcssa
  %128 = getelementptr inbounds i8, ptr %16, i64 52
  store i32 %127, ptr %128, align 4, !tbaa !24
  br label %.loopexit

129:                                              ; preds = %14
  %130 = getelementptr inbounds i8, ptr %16, i64 40
  store i32 -1, ptr %130, align 8, !tbaa !21
  %131 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %11, ptr %131, align 8, !tbaa !22
  %132 = getelementptr inbounds i8, ptr %16, i64 56
  store i32 65536, ptr %132, align 8, !tbaa !23
  %133 = tail call i32 @P_FindLowestFloorSurrounding(ptr noundef nonnull %11) #3
  %134 = getelementptr inbounds i8, ptr %16, i64 52
  store i32 %133, ptr %134, align 4, !tbaa !24
  %135 = getelementptr inbounds i8, ptr %11, i64 8
  %136 = load i16, ptr %135, align 8, !tbaa !29
  %137 = getelementptr inbounds i8, ptr %16, i64 48
  store i16 %136, ptr %137, align 8, !tbaa !36
  %138 = getelementptr inbounds i8, ptr %11, i64 112
  %139 = load i32, ptr %138, align 8, !tbaa !31
  %140 = icmp sgt i32 %139, 0
  br i1 %140, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %129, %176
  %.0139160 = phi ptr [ %.1140, %176 ], [ %11, %129 ]
  %.1142159 = phi i32 [ %177, %176 ], [ 0, %129 ]
  %141 = tail call i32 @twoSided(i32 noundef %6, i32 noundef %.1142159) #3
  %.not149 = icmp eq i32 %141, 0
  br i1 %.not149, label %176, label %142

142:                                              ; preds = %.lr.ph
  %143 = tail call ptr @getSide(i32 noundef %6, i32 noundef %.1142159, i32 noundef 0) #3
  %144 = getelementptr inbounds i8, ptr %143, i64 16
  %145 = load ptr, ptr %144, align 8, !tbaa !37
  %146 = load ptr, ptr @sectors, align 8, !tbaa !5
  %147 = ptrtoint ptr %145 to i64
  %148 = ptrtoint ptr %146 to i64
  %149 = sub i64 %147, %148
  %150 = ashr exact i64 %149, 7
  %151 = icmp eq i64 %150, %10
  br i1 %151, label %152, label %164

152:                                              ; preds = %142
  %153 = tail call ptr @getSector(i32 noundef %6, i32 noundef %.1142159, i32 noundef 1) #3
  %154 = load i32, ptr %153, align 8, !tbaa !25
  %155 = load i32, ptr %134, align 4, !tbaa !24
  %156 = icmp eq i32 %154, %155
  br i1 %156, label %157, label %176

157:                                              ; preds = %152
  %158 = getelementptr inbounds i8, ptr %153, i64 8
  %159 = load i16, ptr %158, align 8, !tbaa !29
  store i16 %159, ptr %137, align 8, !tbaa !36
  %160 = getelementptr inbounds i8, ptr %153, i64 14
  %161 = load i16, ptr %160, align 2, !tbaa !30
  %162 = sext i16 %161 to i32
  %163 = getelementptr inbounds i8, ptr %16, i64 44
  store i32 %162, ptr %163, align 4, !tbaa !38
  br label %.loopexit

164:                                              ; preds = %142
  %165 = tail call ptr @getSector(i32 noundef %6, i32 noundef %.1142159, i32 noundef 0) #3
  %166 = load i32, ptr %165, align 8, !tbaa !25
  %167 = load i32, ptr %134, align 4, !tbaa !24
  %168 = icmp eq i32 %166, %167
  br i1 %168, label %169, label %176

169:                                              ; preds = %164
  %170 = getelementptr inbounds i8, ptr %165, i64 8
  %171 = load i16, ptr %170, align 8, !tbaa !29
  store i16 %171, ptr %137, align 8, !tbaa !36
  %172 = getelementptr inbounds i8, ptr %165, i64 14
  %173 = load i16, ptr %172, align 2, !tbaa !30
  %174 = sext i16 %173 to i32
  %175 = getelementptr inbounds i8, ptr %16, i64 44
  store i32 %174, ptr %175, align 4, !tbaa !38
  br label %.loopexit

176:                                              ; preds = %.lr.ph, %164, %152
  %.1140 = phi ptr [ %153, %152 ], [ %165, %164 ], [ %.0139160, %.lr.ph ]
  %177 = add nuw nsw i32 %.1142159, 1
  %178 = getelementptr inbounds i8, ptr %.1140, i64 112
  %179 = load i32, ptr %178, align 8, !tbaa !31
  %180 = icmp slt i32 %177, %179
  br i1 %180, label %.lr.ph, label %.loopexit, !llvm.loop !39

.loopexit:                                        ; preds = %176, %129, %14, %169, %157, %32, %39, %._crit_edge, %79, %72, %65, %58, %51, %42, %26, %20
  br label %.outer, !llvm.loop !15

181:                                              ; preds = %5
  ret i32 %.0143.ph
}

declare i32 @P_FindSectorFromLineTag(ptr noundef, i32 noundef) local_unnamed_addr #1

declare ptr @Z_Malloc(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @P_AddThinker(ptr noundef) local_unnamed_addr #1

declare i32 @P_FindHighestFloorSurrounding(ptr noundef) local_unnamed_addr #1

declare i32 @P_FindLowestFloorSurrounding(ptr noundef) local_unnamed_addr #1

declare i32 @P_FindLowestCeilingSurrounding(ptr noundef) local_unnamed_addr #1

declare i32 @P_FindNextHighestFloor(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @twoSided(i32 noundef, i32 noundef) local_unnamed_addr #1

declare ptr @getSide(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare ptr @getSector(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !6, i64 104}
!10 = !{!"", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 10, !12, i64 12, !12, i64 14, !12, i64 16, !11, i64 20, !6, i64 24, !7, i64 32, !13, i64 48, !11, i64 88, !6, i64 96, !6, i64 104, !11, i64 112, !6, i64 120}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"", !14, i64 0, !11, i64 24, !11, i64 28, !11, i64 32}
!14 = !{!"thinker_s", !6, i64 0, !6, i64 8, !7, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !11, i64 24}
!19 = !{!"", !14, i64 0, !11, i64 24, !11, i64 28, !6, i64 32, !11, i64 40, !11, i64 44, !12, i64 48, !11, i64 52, !11, i64 56}
!20 = !{!19, !11, i64 28}
!21 = !{!19, !11, i64 40}
!22 = !{!19, !6, i64 32}
!23 = !{!19, !11, i64 56}
!24 = !{!19, !11, i64 52}
!25 = !{!10, !11, i64 0}
!26 = !{!10, !11, i64 4}
!27 = !{!28, !6, i64 56}
!28 = !{!"line_s", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !12, i64 24, !12, i64 26, !12, i64 28, !7, i64 30, !7, i64 36, !11, i64 52, !6, i64 56, !6, i64 64, !11, i64 72, !6, i64 80}
!29 = !{!10, !12, i64 8}
!30 = !{!10, !12, i64 14}
!31 = !{!10, !11, i64 112}
!32 = !{!33, !12, i64 10}
!33 = !{!"", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 10, !12, i64 12, !6, i64 16}
!34 = !{!11, !11, i64 0}
!35 = distinct !{!35, !16}
!36 = !{!19, !12, i64 48}
!37 = !{!33, !6, i64 16}
!38 = !{!19, !11, i64 44}
!39 = distinct !{!39, !16}


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