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

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

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

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

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

declare void @S_StartSound(ptr noundef, i32 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @EV_DoPlat(ptr noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  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 8, ptr %10) #3
  store i32 -1, ptr %8, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !9
  %11 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %11, label %17 [
    i32 0, label %12
  ]

12:                                               ; preds = %3
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.line_s, ptr %13, i32 0, i32 6
  %15 = load i16, ptr %14, align 4, !tbaa !11
  %16 = sext i16 %15 to i32
  call void @P_ActivateInStasis(i32 noundef %16)
  br label %18

17:                                               ; preds = %3
  br label %18

18:                                               ; preds = %17, %12
  br label %19

19:                                               ; preds = %233, %33, %18
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = call i32 @P_FindSectorFromLineTag(ptr noundef %20, i32 noundef %21)
  store i32 %22, ptr %8, align 4, !tbaa !9
  %23 = icmp sge i32 %22, 0
  br i1 %23, label %24, label %235

24:                                               ; preds = %19
  %25 = load ptr, ptr @sectors, align 8, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds %struct.sector_t, ptr %25, i64 %27
  store ptr %28, ptr %10, align 8, !tbaa !5
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.sector_t, ptr %29, i32 0, i32 13
  %31 = load ptr, ptr %30, align 8, !tbaa !14
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %34

33:                                               ; preds = %24
  br label %19, !llvm.loop !18

34:                                               ; preds = %24
  store i32 1, ptr %9, align 4, !tbaa !9
  %35 = call ptr @Z_Malloc(i32 noundef 72, i32 noundef 51, ptr noundef null)
  store ptr %35, ptr %7, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.plat_t, ptr %36, i32 0, i32 0
  call void @P_AddThinker(ptr noundef %37)
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.plat_t, ptr %39, i32 0, i32 11
  store i32 %38, ptr %40, align 4, !tbaa !20
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.plat_t, ptr %42, i32 0, i32 1
  store ptr %41, ptr %43, align 8, !tbaa !22
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.plat_t, ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !22
  %48 = getelementptr inbounds %struct.sector_t, ptr %47, i32 0, i32 13
  store ptr %44, ptr %48, align 8, !tbaa !14
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.plat_t, ptr %49, i32 0, i32 0
  %51 = getelementptr inbounds %struct.thinker_s, ptr %50, i32 0, i32 2
  store ptr @T_PlatRaise, ptr %51, align 8, !tbaa !23
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.plat_t, ptr %52, i32 0, i32 9
  store i32 0, ptr %53, align 4, !tbaa !24
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.line_s, ptr %54, i32 0, i32 6
  %56 = load i16, ptr %55, align 4, !tbaa !11
  %57 = sext i16 %56 to i32
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.plat_t, ptr %58, i32 0, i32 10
  store i32 %57, ptr %59, align 8, !tbaa !25
  %60 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %60, label %233 [
    i32 3, label %61
    i32 2, label %92
    i32 1, label %122
    i32 4, label %154
    i32 0, label %186
  ]

61:                                               ; preds = %34
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.plat_t, ptr %62, i32 0, i32 2
  store i32 32768, ptr %63, align 8, !tbaa !26
  %64 = load ptr, ptr @sides, align 8, !tbaa !5
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.line_s, ptr %65, i32 0, i32 7
  %67 = getelementptr inbounds [2 x i16], ptr %66, i64 0, i64 0
  %68 = load i16, ptr %67, align 2, !tbaa !27
  %69 = sext i16 %68 to i64
  %70 = getelementptr inbounds %struct.side_t, ptr %64, i64 %69
  %71 = getelementptr inbounds %struct.side_t, ptr %70, i32 0, i32 5
  %72 = load ptr, ptr %71, align 8, !tbaa !28
  %73 = getelementptr inbounds %struct.sector_t, ptr %72, i32 0, i32 2
  %74 = load i16, ptr %73, align 8, !tbaa !30
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.sector_t, ptr %75, i32 0, i32 2
  store i16 %74, ptr %76, align 8, !tbaa !30
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.sector_t, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 8, !tbaa !31
  %81 = call i32 @P_FindNextHighestFloor(ptr noundef %77, i32 noundef %80)
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.plat_t, ptr %82, i32 0, i32 4
  store i32 %81, ptr %83, align 8, !tbaa !32
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.plat_t, ptr %84, i32 0, i32 5
  store i32 0, ptr %85, align 4, !tbaa !33
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.plat_t, ptr %86, i32 0, i32 7
  store i32 0, ptr %87, align 4, !tbaa !34
  %88 = load ptr, ptr %10, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.sector_t, ptr %88, i32 0, i32 5
  store i16 0, ptr %89, align 2, !tbaa !35
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.sector_t, ptr %90, i32 0, i32 10
  call void @S_StartSound(ptr noundef %91, i32 noundef 22)
  br label %233

92:                                               ; preds = %34
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.plat_t, ptr %93, i32 0, i32 2
  store i32 32768, ptr %94, align 8, !tbaa !26
  %95 = load ptr, ptr @sides, align 8, !tbaa !5
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.line_s, ptr %96, i32 0, i32 7
  %98 = getelementptr inbounds [2 x i16], ptr %97, i64 0, i64 0
  %99 = load i16, ptr %98, align 2, !tbaa !27
  %100 = sext i16 %99 to i64
  %101 = getelementptr inbounds %struct.side_t, ptr %95, i64 %100
  %102 = getelementptr inbounds %struct.side_t, ptr %101, i32 0, i32 5
  %103 = load ptr, ptr %102, align 8, !tbaa !28
  %104 = getelementptr inbounds %struct.sector_t, ptr %103, i32 0, i32 2
  %105 = load i16, ptr %104, align 8, !tbaa !30
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.sector_t, ptr %106, i32 0, i32 2
  store i16 %105, ptr %107, align 8, !tbaa !30
  %108 = load ptr, ptr %10, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.sector_t, ptr %108, i32 0, i32 0
  %110 = load i32, ptr %109, align 8, !tbaa !31
  %111 = load i32, ptr %6, align 4, !tbaa !9
  %112 = mul nsw i32 %111, 65536
  %113 = add nsw i32 %110, %112
  %114 = load ptr, ptr %7, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.plat_t, ptr %114, i32 0, i32 4
  store i32 %113, ptr %115, align 8, !tbaa !32
  %116 = load ptr, ptr %7, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.plat_t, ptr %116, i32 0, i32 5
  store i32 0, ptr %117, align 4, !tbaa !33
  %118 = load ptr, ptr %7, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.plat_t, ptr %118, i32 0, i32 7
  store i32 0, ptr %119, align 4, !tbaa !34
  %120 = load ptr, ptr %10, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.sector_t, ptr %120, i32 0, i32 10
  call void @S_StartSound(ptr noundef %121, i32 noundef 22)
  br label %233

122:                                              ; preds = %34
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.plat_t, ptr %123, i32 0, i32 2
  store i32 262144, ptr %124, align 8, !tbaa !26
  %125 = load ptr, ptr %10, align 8, !tbaa !5
  %126 = call i32 @P_FindLowestFloorSurrounding(ptr noundef %125)
  %127 = load ptr, ptr %7, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.plat_t, ptr %127, i32 0, i32 3
  store i32 %126, ptr %128, align 4, !tbaa !36
  %129 = load ptr, ptr %7, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.plat_t, ptr %129, i32 0, i32 3
  %131 = load i32, ptr %130, align 4, !tbaa !36
  %132 = load ptr, ptr %10, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.sector_t, ptr %132, i32 0, i32 0
  %134 = load i32, ptr %133, align 8, !tbaa !31
  %135 = icmp sgt i32 %131, %134
  br i1 %135, label %136, label %142

136:                                              ; preds = %122
  %137 = load ptr, ptr %10, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.sector_t, ptr %137, i32 0, i32 0
  %139 = load i32, ptr %138, align 8, !tbaa !31
  %140 = load ptr, ptr %7, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.plat_t, ptr %140, i32 0, i32 3
  store i32 %139, ptr %141, align 4, !tbaa !36
  br label %142

142:                                              ; preds = %136, %122
  %143 = load ptr, ptr %10, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.sector_t, ptr %143, i32 0, i32 0
  %145 = load i32, ptr %144, align 8, !tbaa !31
  %146 = load ptr, ptr %7, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.plat_t, ptr %146, i32 0, i32 4
  store i32 %145, ptr %147, align 8, !tbaa !32
  %148 = load ptr, ptr %7, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.plat_t, ptr %148, i32 0, i32 5
  store i32 105, ptr %149, align 4, !tbaa !33
  %150 = load ptr, ptr %7, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.plat_t, ptr %150, i32 0, i32 7
  store i32 1, ptr %151, align 4, !tbaa !34
  %152 = load ptr, ptr %10, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.sector_t, ptr %152, i32 0, i32 10
  call void @S_StartSound(ptr noundef %153, i32 noundef 18)
  br label %233

154:                                              ; preds = %34
  %155 = load ptr, ptr %7, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.plat_t, ptr %155, i32 0, i32 2
  store i32 524288, ptr %156, align 8, !tbaa !26
  %157 = load ptr, ptr %10, align 8, !tbaa !5
  %158 = call i32 @P_FindLowestFloorSurrounding(ptr noundef %157)
  %159 = load ptr, ptr %7, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.plat_t, ptr %159, i32 0, i32 3
  store i32 %158, ptr %160, align 4, !tbaa !36
  %161 = load ptr, ptr %7, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.plat_t, ptr %161, i32 0, i32 3
  %163 = load i32, ptr %162, align 4, !tbaa !36
  %164 = load ptr, ptr %10, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.sector_t, ptr %164, i32 0, i32 0
  %166 = load i32, ptr %165, align 8, !tbaa !31
  %167 = icmp sgt i32 %163, %166
  br i1 %167, label %168, label %174

168:                                              ; preds = %154
  %169 = load ptr, ptr %10, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.sector_t, ptr %169, i32 0, i32 0
  %171 = load i32, ptr %170, align 8, !tbaa !31
  %172 = load ptr, ptr %7, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.plat_t, ptr %172, i32 0, i32 3
  store i32 %171, ptr %173, align 4, !tbaa !36
  br label %174

174:                                              ; preds = %168, %154
  %175 = load ptr, ptr %10, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.sector_t, ptr %175, i32 0, i32 0
  %177 = load i32, ptr %176, align 8, !tbaa !31
  %178 = load ptr, ptr %7, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.plat_t, ptr %178, i32 0, i32 4
  store i32 %177, ptr %179, align 8, !tbaa !32
  %180 = load ptr, ptr %7, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.plat_t, ptr %180, i32 0, i32 5
  store i32 105, ptr %181, align 4, !tbaa !33
  %182 = load ptr, ptr %7, align 8, !tbaa !5
  %183 = getelementptr inbounds %struct.plat_t, ptr %182, i32 0, i32 7
  store i32 1, ptr %183, align 4, !tbaa !34
  %184 = load ptr, ptr %10, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.sector_t, ptr %184, i32 0, i32 10
  call void @S_StartSound(ptr noundef %185, i32 noundef 18)
  br label %233

186:                                              ; preds = %34
  %187 = load ptr, ptr %7, align 8, !tbaa !5
  %188 = getelementptr inbounds %struct.plat_t, ptr %187, i32 0, i32 2
  store i32 65536, ptr %188, align 8, !tbaa !26
  %189 = load ptr, ptr %10, align 8, !tbaa !5
  %190 = call i32 @P_FindLowestFloorSurrounding(ptr noundef %189)
  %191 = load ptr, ptr %7, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.plat_t, ptr %191, i32 0, i32 3
  store i32 %190, ptr %192, align 4, !tbaa !36
  %193 = load ptr, ptr %7, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.plat_t, ptr %193, i32 0, i32 3
  %195 = load i32, ptr %194, align 4, !tbaa !36
  %196 = load ptr, ptr %10, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.sector_t, ptr %196, i32 0, i32 0
  %198 = load i32, ptr %197, align 8, !tbaa !31
  %199 = icmp sgt i32 %195, %198
  br i1 %199, label %200, label %206

200:                                              ; preds = %186
  %201 = load ptr, ptr %10, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.sector_t, ptr %201, i32 0, i32 0
  %203 = load i32, ptr %202, align 8, !tbaa !31
  %204 = load ptr, ptr %7, align 8, !tbaa !5
  %205 = getelementptr inbounds %struct.plat_t, ptr %204, i32 0, i32 3
  store i32 %203, ptr %205, align 4, !tbaa !36
  br label %206

206:                                              ; preds = %200, %186
  %207 = load ptr, ptr %10, align 8, !tbaa !5
  %208 = call i32 @P_FindHighestFloorSurrounding(ptr noundef %207)
  %209 = load ptr, ptr %7, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct.plat_t, ptr %209, i32 0, i32 4
  store i32 %208, ptr %210, align 8, !tbaa !32
  %211 = load ptr, ptr %7, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.plat_t, ptr %211, i32 0, i32 4
  %213 = load i32, ptr %212, align 8, !tbaa !32
  %214 = load ptr, ptr %10, align 8, !tbaa !5
  %215 = getelementptr inbounds %struct.sector_t, ptr %214, i32 0, i32 0
  %216 = load i32, ptr %215, align 8, !tbaa !31
  %217 = icmp slt i32 %213, %216
  br i1 %217, label %218, label %224

218:                                              ; preds = %206
  %219 = load ptr, ptr %10, align 8, !tbaa !5
  %220 = getelementptr inbounds %struct.sector_t, ptr %219, i32 0, i32 0
  %221 = load i32, ptr %220, align 8, !tbaa !31
  %222 = load ptr, ptr %7, align 8, !tbaa !5
  %223 = getelementptr inbounds %struct.plat_t, ptr %222, i32 0, i32 4
  store i32 %221, ptr %223, align 8, !tbaa !32
  br label %224

224:                                              ; preds = %218, %206
  %225 = load ptr, ptr %7, align 8, !tbaa !5
  %226 = getelementptr inbounds %struct.plat_t, ptr %225, i32 0, i32 5
  store i32 105, ptr %226, align 4, !tbaa !33
  %227 = call i32 @P_Random()
  %228 = and i32 %227, 1
  %229 = load ptr, ptr %7, align 8, !tbaa !5
  %230 = getelementptr inbounds %struct.plat_t, ptr %229, i32 0, i32 7
  store i32 %228, ptr %230, align 4, !tbaa !34
  %231 = load ptr, ptr %10, align 8, !tbaa !5
  %232 = getelementptr inbounds %struct.sector_t, ptr %231, i32 0, i32 10
  call void @S_StartSound(ptr noundef %232, i32 noundef 18)
  br label %233

233:                                              ; preds = %224, %174, %142, %92, %61, %34
  %234 = load ptr, ptr %7, align 8, !tbaa !5
  call void @P_AddActivePlat(ptr noundef %234)
  br label %19, !llvm.loop !18

235:                                              ; preds = %19
  %236 = load i32, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i32 %236
}

; Function Attrs: nounwind uwtable
declare dso_local void @P_ActivateInStasis(i32 noundef) #0

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_FindNextHighestFloor(ptr noundef, i32 noundef) #2

declare i32 @P_FindLowestFloorSurrounding(ptr noundef) #2

declare i32 @P_FindHighestFloorSurrounding(ptr noundef) #2

declare i32 @P_Random() #2

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

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 = { "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, !13, i64 28}
!12 = !{!"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}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !6, i64 104}
!15 = !{!"", !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, !16, i64 48, !10, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !6, i64 120}
!16 = !{!"", !17, i64 0, !10, i64 24, !10, i64 28, !10, i64 32}
!17 = !{!"thinker_s", !6, i64 0, !6, i64 8, !7, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !10, i64 68}
!21 = !{!"", !17, i64 0, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68}
!22 = !{!21, !6, i64 24}
!23 = !{!7, !7, i64 0}
!24 = !{!21, !10, i64 60}
!25 = !{!21, !10, i64 64}
!26 = !{!21, !10, i64 32}
!27 = !{!13, !13, i64 0}
!28 = !{!29, !6, i64 16}
!29 = !{!"", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !6, i64 16}
!30 = !{!15, !13, i64 8}
!31 = !{!15, !10, i64 0}
!32 = !{!21, !10, i64 40}
!33 = !{!21, !10, i64 44}
!34 = !{!21, !10, i64 52}
!35 = !{!15, !13, i64 14}
!36 = !{!21, !10, i64 36}


; 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 }
%struct.side_t = type { i32, i32, i16, i16, i16, ptr }

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

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

declare void @S_StartSound(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @EV_DoPlat(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %cond = icmp eq i32 %1, 0
  br i1 %cond, label %4, label %8

4:                                                ; preds = %3
  %5 = getelementptr inbounds i8, ptr %0, i64 28
  %6 = load i16, ptr %5, align 4, !tbaa !5
  %7 = sext i16 %6 to i32
  tail call void @P_ActivateInStasis(i32 noundef %7)
  br label %8

8:                                                ; preds = %3, %4
  %9 = getelementptr inbounds i8, ptr %0, i64 28
  %10 = getelementptr inbounds i8, ptr %0, i64 30
  %11 = shl nsw i32 %2, 16
  br label %.outer

.outer:                                           ; preds = %93, %8
  %.078.ph = phi i32 [ 1, %93 ], [ 0, %8 ]
  %.0.ph = phi i32 [ %13, %93 ], [ -1, %8 ]
  br label %12

12:                                               ; preds = %.outer, %15
  %.0 = phi i32 [ %13, %15 ], [ %.0.ph, %.outer ]
  %13 = tail call i32 @P_FindSectorFromLineTag(ptr noundef %0, i32 noundef %.0) #3
  %14 = icmp sgt i32 %13, -1
  br i1 %14, label %15, label %94

15:                                               ; preds = %12
  %16 = load ptr, ptr @sectors, align 8, !tbaa !12
  %17 = zext nneg i32 %13 to i64
  %18 = getelementptr inbounds %struct.sector_t, ptr %16, i64 %17
  %19 = getelementptr inbounds i8, ptr %18, i64 104
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %.not = icmp eq ptr %20, null
  br i1 %.not, label %21, label %12, !llvm.loop !17

21:                                               ; preds = %15
  %22 = getelementptr inbounds i8, ptr %18, i64 104
  %23 = tail call ptr @Z_Malloc(i32 noundef 72, i32 noundef 51, ptr noundef null) #3
  tail call void @P_AddThinker(ptr noundef %23) #3
  %24 = getelementptr inbounds i8, ptr %23, i64 68
  store i32 %1, ptr %24, align 4, !tbaa !19
  %25 = getelementptr inbounds i8, ptr %23, i64 24
  store ptr %18, ptr %25, align 8, !tbaa !21
  store ptr %23, ptr %22, align 8, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %23, i64 16
  store ptr @T_PlatRaise, ptr %26, align 8, !tbaa !22
  %27 = getelementptr inbounds i8, ptr %23, i64 60
  store i32 0, ptr %27, align 4, !tbaa !23
  %28 = load i16, ptr %9, align 4, !tbaa !5
  %29 = sext i16 %28 to i32
  %30 = getelementptr inbounds i8, ptr %23, i64 64
  store i32 %29, ptr %30, align 8, !tbaa !24
  switch i32 %1, label %93 [
    i32 3, label %31
    i32 2, label %47
    i32 1, label %62
    i32 4, label %71
    i32 0, label %80
  ]

31:                                               ; preds = %21
  %32 = getelementptr inbounds i8, ptr %23, i64 32
  store i32 32768, ptr %32, align 8, !tbaa !25
  %33 = load ptr, ptr @sides, align 8, !tbaa !12
  %34 = load i16, ptr %10, align 2, !tbaa !26
  %35 = sext i16 %34 to i64
  %36 = getelementptr inbounds %struct.side_t, ptr %33, i64 %35, i32 5
  %37 = load ptr, ptr %36, align 8, !tbaa !27
  %38 = getelementptr inbounds i8, ptr %37, i64 8
  %39 = load i16, ptr %38, align 8, !tbaa !29
  %40 = getelementptr inbounds i8, ptr %18, i64 8
  store i16 %39, ptr %40, align 8, !tbaa !29
  %41 = load i32, ptr %18, align 8, !tbaa !30
  %42 = tail call i32 @P_FindNextHighestFloor(ptr noundef nonnull %18, i32 noundef %41) #3
  %43 = getelementptr inbounds i8, ptr %23, i64 40
  store i32 %42, ptr %43, align 8, !tbaa !31
  %44 = getelementptr inbounds i8, ptr %23, i64 44
  store i32 0, ptr %44, align 4, !tbaa !32
  %45 = getelementptr inbounds i8, ptr %23, i64 52
  store i32 0, ptr %45, align 4, !tbaa !33
  %46 = getelementptr inbounds i8, ptr %18, i64 14
  store i16 0, ptr %46, align 2, !tbaa !34
  br label %.sink.split

47:                                               ; preds = %21
  %48 = getelementptr inbounds i8, ptr %23, i64 32
  store i32 32768, ptr %48, align 8, !tbaa !25
  %49 = load ptr, ptr @sides, align 8, !tbaa !12
  %50 = load i16, ptr %10, align 2, !tbaa !26
  %51 = sext i16 %50 to i64
  %52 = getelementptr inbounds %struct.side_t, ptr %49, i64 %51, i32 5
  %53 = load ptr, ptr %52, align 8, !tbaa !27
  %54 = getelementptr inbounds i8, ptr %53, i64 8
  %55 = load i16, ptr %54, align 8, !tbaa !29
  %56 = getelementptr inbounds i8, ptr %18, i64 8
  store i16 %55, ptr %56, align 8, !tbaa !29
  %57 = load i32, ptr %18, align 8, !tbaa !30
  %58 = add nsw i32 %57, %11
  %59 = getelementptr inbounds i8, ptr %23, i64 40
  store i32 %58, ptr %59, align 8, !tbaa !31
  %60 = getelementptr inbounds i8, ptr %23, i64 44
  store i32 0, ptr %60, align 4, !tbaa !32
  %61 = getelementptr inbounds i8, ptr %23, i64 52
  store i32 0, ptr %61, align 4, !tbaa !33
  br label %.sink.split

62:                                               ; preds = %21
  %63 = getelementptr inbounds i8, ptr %23, i64 32
  store i32 262144, ptr %63, align 8, !tbaa !25
  %64 = tail call i32 @P_FindLowestFloorSurrounding(ptr noundef nonnull %18) #3
  %65 = getelementptr inbounds i8, ptr %23, i64 36
  %66 = load i32, ptr %18, align 8, !tbaa !30
  %spec.store.select = tail call i32 @llvm.smin.i32(i32 %64, i32 %66)
  store i32 %spec.store.select, ptr %65, align 4
  %67 = load i32, ptr %18, align 8, !tbaa !30
  %68 = getelementptr inbounds i8, ptr %23, i64 40
  store i32 %67, ptr %68, align 8, !tbaa !31
  %69 = getelementptr inbounds i8, ptr %23, i64 44
  store i32 105, ptr %69, align 4, !tbaa !32
  %70 = getelementptr inbounds i8, ptr %23, i64 52
  store i32 1, ptr %70, align 4, !tbaa !33
  br label %.sink.split

71:                                               ; preds = %21
  %72 = getelementptr inbounds i8, ptr %23, i64 32
  store i32 524288, ptr %72, align 8, !tbaa !25
  %73 = tail call i32 @P_FindLowestFloorSurrounding(ptr noundef nonnull %18) #3
  %74 = getelementptr inbounds i8, ptr %23, i64 36
  %75 = load i32, ptr %18, align 8, !tbaa !30
  %spec.store.select84 = tail call i32 @llvm.smin.i32(i32 %73, i32 %75)
  store i32 %spec.store.select84, ptr %74, align 4
  %76 = load i32, ptr %18, align 8, !tbaa !30
  %77 = getelementptr inbounds i8, ptr %23, i64 40
  store i32 %76, ptr %77, align 8, !tbaa !31
  %78 = getelementptr inbounds i8, ptr %23, i64 44
  store i32 105, ptr %78, align 4, !tbaa !32
  %79 = getelementptr inbounds i8, ptr %23, i64 52
  store i32 1, ptr %79, align 4, !tbaa !33
  br label %.sink.split

80:                                               ; preds = %21
  %81 = getelementptr inbounds i8, ptr %23, i64 32
  store i32 65536, ptr %81, align 8, !tbaa !25
  %82 = tail call i32 @P_FindLowestFloorSurrounding(ptr noundef nonnull %18) #3
  %83 = getelementptr inbounds i8, ptr %23, i64 36
  %84 = load i32, ptr %18, align 8, !tbaa !30
  %spec.store.select85 = tail call i32 @llvm.smin.i32(i32 %82, i32 %84)
  store i32 %spec.store.select85, ptr %83, align 4
  %85 = tail call i32 @P_FindHighestFloorSurrounding(ptr noundef nonnull %18) #3
  %86 = getelementptr inbounds i8, ptr %23, i64 40
  %87 = load i32, ptr %18, align 8, !tbaa !30
  %spec.store.select86 = tail call i32 @llvm.smax.i32(i32 %85, i32 %87)
  store i32 %spec.store.select86, ptr %86, align 8
  %88 = getelementptr inbounds i8, ptr %23, i64 44
  store i32 105, ptr %88, align 4, !tbaa !32
  %89 = tail call i32 @P_Random() #3
  %90 = and i32 %89, 1
  %91 = getelementptr inbounds i8, ptr %23, i64 52
  store i32 %90, ptr %91, align 4, !tbaa !33
  br label %.sink.split

.sink.split:                                      ; preds = %31, %47, %62, %71, %80
  %.sink95 = phi i32 [ 18, %80 ], [ 18, %71 ], [ 18, %62 ], [ 22, %47 ], [ 22, %31 ]
  %92 = getelementptr inbounds i8, ptr %18, i64 48
  tail call void @S_StartSound(ptr noundef nonnull %92, i32 noundef %.sink95) #3
  br label %93

93:                                               ; preds = %.sink.split, %21
  tail call void @P_AddActivePlat(ptr noundef nonnull %23)
  br label %.outer, !llvm.loop !17

94:                                               ; preds = %12
  ret i32 %.078.ph
}

; Function Attrs: nounwind uwtable
declare dso_local void @P_ActivateInStasis(i32 noundef) local_unnamed_addr #0

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_FindNextHighestFloor(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @P_FindLowestFloorSurrounding(ptr noundef) local_unnamed_addr #1

declare i32 @P_FindHighestFloorSurrounding(ptr noundef) local_unnamed_addr #1

declare i32 @P_Random() local_unnamed_addr #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #2

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


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