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

; 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.thinker_s = type { ptr, ptr, %union.actionf_t }
%union.actionf_t = type { ptr }
%struct.ceiling_t = type { %struct.thinker_s, i32, ptr, i32, i32, i32, i32, i32, i32, i32 }
%struct.vldoor_t = type { %struct.thinker_s, i32, ptr, i32, i32, i32, i32, i32 }
%struct.floormove_t = type { %struct.thinker_s, i32, i32, ptr, i32, i32, i16, i32, i32 }
%struct.plat_t = type { %struct.thinker_s, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.lightflash_t = type { %struct.thinker_s, ptr, i32, i32, i32, i32, i32 }
%struct.strobe_t = type { %struct.thinker_s, ptr, i32, i32, i32, i32, i32 }
%struct.glow_t = type { %struct.thinker_s, ptr, i32, i32, i32 }

@save_p = external dso_local global ptr, align 8
@sectors = external global ptr, align 8
@thinkercap = external global %struct.thinker_s, align 8
@activeceilings = external global [30 x ptr], align 16

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; 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
define dso_local void @P_ArchiveSpecials() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %10 = load ptr, ptr getelementptr inbounds (%struct.thinker_s, ptr @thinkercap, i32 0, i32 1), align 8, !tbaa !5
  store ptr %10, ptr %1, align 8, !tbaa !10
  br label %11

11:                                               ; preds = %283, %0
  %12 = load ptr, ptr %1, align 8, !tbaa !10
  %13 = icmp ne ptr %12, @thinkercap
  br i1 %13, label %14, label %287

14:                                               ; preds = %11
  %15 = load ptr, ptr %1, align 8, !tbaa !10
  %16 = getelementptr inbounds %struct.thinker_s, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %65

19:                                               ; preds = %14
  store i32 0, ptr %9, align 4, !tbaa !12
  br label %20

20:                                               ; preds = %32, %19
  %21 = load i32, ptr %9, align 4, !tbaa !12
  %22 = icmp slt i32 %21, 30
  br i1 %22, label %23, label %35

23:                                               ; preds = %20
  %24 = load i32, ptr %9, align 4, !tbaa !12
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [30 x ptr], ptr @activeceilings, i64 0, i64 %25
  %27 = load ptr, ptr %26, align 8, !tbaa !10
  %28 = load ptr, ptr %1, align 8, !tbaa !10
  %29 = icmp eq ptr %27, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %23
  br label %35

31:                                               ; preds = %23
  br label %32

32:                                               ; preds = %31
  %33 = load i32, ptr %9, align 4, !tbaa !12
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %9, align 4, !tbaa !12
  br label %20, !llvm.loop !14

35:                                               ; preds = %30, %20
  %36 = load i32, ptr %9, align 4, !tbaa !12
  %37 = icmp slt i32 %36, 30
  br i1 %37, label %38, label %64

38:                                               ; preds = %35
  %39 = load ptr, ptr @save_p, align 8, !tbaa !10
  %40 = getelementptr inbounds i8, ptr %39, i32 1
  store ptr %40, ptr @save_p, align 8, !tbaa !10
  store i8 0, ptr %39, align 1, !tbaa !11
  %41 = load ptr, ptr @save_p, align 8, !tbaa !10
  %42 = ptrtoint ptr %41 to i64
  %43 = and i64 %42, 3
  %44 = sub i64 4, %43
  %45 = and i64 %44, 3
  %46 = load ptr, ptr @save_p, align 8, !tbaa !10
  %47 = getelementptr inbounds i8, ptr %46, i64 %45
  store ptr %47, ptr @save_p, align 8, !tbaa !10
  %48 = load ptr, ptr @save_p, align 8, !tbaa !10
  store ptr %48, ptr %2, align 8, !tbaa !10
  %49 = load ptr, ptr %2, align 8, !tbaa !10
  %50 = load ptr, ptr %1, align 8, !tbaa !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %49, ptr align 8 %50, i64 72, i1 false)
  %51 = load ptr, ptr @save_p, align 8, !tbaa !10
  %52 = getelementptr inbounds i8, ptr %51, i64 72
  store ptr %52, ptr @save_p, align 8, !tbaa !10
  %53 = load ptr, ptr %2, align 8, !tbaa !10
  %54 = getelementptr inbounds %struct.ceiling_t, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !16
  %56 = load ptr, ptr @sectors, align 8, !tbaa !10
  %57 = ptrtoint ptr %55 to i64
  %58 = ptrtoint ptr %56 to i64
  %59 = sub i64 %57, %58
  %60 = sdiv exact i64 %59, 128
  %61 = inttoptr i64 %60 to ptr
  %62 = load ptr, ptr %2, align 8, !tbaa !10
  %63 = getelementptr inbounds %struct.ceiling_t, ptr %62, i32 0, i32 2
  store ptr %61, ptr %63, align 8, !tbaa !16
  br label %64

64:                                               ; preds = %38, %35
  br label %283

65:                                               ; preds = %14
  %66 = load ptr, ptr %1, align 8, !tbaa !10
  %67 = getelementptr inbounds %struct.thinker_s, ptr %66, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !11
  %69 = icmp eq ptr %68, @T_MoveCeiling
  br i1 %69, label %70, label %96

70:                                               ; preds = %65
  %71 = load ptr, ptr @save_p, align 8, !tbaa !10
  %72 = getelementptr inbounds i8, ptr %71, i32 1
  store ptr %72, ptr @save_p, align 8, !tbaa !10
  store i8 0, ptr %71, align 1, !tbaa !11
  %73 = load ptr, ptr @save_p, align 8, !tbaa !10
  %74 = ptrtoint ptr %73 to i64
  %75 = and i64 %74, 3
  %76 = sub i64 4, %75
  %77 = and i64 %76, 3
  %78 = load ptr, ptr @save_p, align 8, !tbaa !10
  %79 = getelementptr inbounds i8, ptr %78, i64 %77
  store ptr %79, ptr @save_p, align 8, !tbaa !10
  %80 = load ptr, ptr @save_p, align 8, !tbaa !10
  store ptr %80, ptr %2, align 8, !tbaa !10
  %81 = load ptr, ptr %2, align 8, !tbaa !10
  %82 = load ptr, ptr %1, align 8, !tbaa !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %81, ptr align 8 %82, i64 72, i1 false)
  %83 = load ptr, ptr @save_p, align 8, !tbaa !10
  %84 = getelementptr inbounds i8, ptr %83, i64 72
  store ptr %84, ptr @save_p, align 8, !tbaa !10
  %85 = load ptr, ptr %2, align 8, !tbaa !10
  %86 = getelementptr inbounds %struct.ceiling_t, ptr %85, i32 0, i32 2
  %87 = load ptr, ptr %86, align 8, !tbaa !16
  %88 = load ptr, ptr @sectors, align 8, !tbaa !10
  %89 = ptrtoint ptr %87 to i64
  %90 = ptrtoint ptr %88 to i64
  %91 = sub i64 %89, %90
  %92 = sdiv exact i64 %91, 128
  %93 = inttoptr i64 %92 to ptr
  %94 = load ptr, ptr %2, align 8, !tbaa !10
  %95 = getelementptr inbounds %struct.ceiling_t, ptr %94, i32 0, i32 2
  store ptr %93, ptr %95, align 8, !tbaa !16
  br label %283

96:                                               ; preds = %65
  %97 = load ptr, ptr %1, align 8, !tbaa !10
  %98 = getelementptr inbounds %struct.thinker_s, ptr %97, i32 0, i32 2
  %99 = load ptr, ptr %98, align 8, !tbaa !11
  %100 = icmp eq ptr %99, @T_VerticalDoor
  br i1 %100, label %101, label %127

101:                                              ; preds = %96
  %102 = load ptr, ptr @save_p, align 8, !tbaa !10
  %103 = getelementptr inbounds i8, ptr %102, i32 1
  store ptr %103, ptr @save_p, align 8, !tbaa !10
  store i8 1, ptr %102, align 1, !tbaa !11
  %104 = load ptr, ptr @save_p, align 8, !tbaa !10
  %105 = ptrtoint ptr %104 to i64
  %106 = and i64 %105, 3
  %107 = sub i64 4, %106
  %108 = and i64 %107, 3
  %109 = load ptr, ptr @save_p, align 8, !tbaa !10
  %110 = getelementptr inbounds i8, ptr %109, i64 %108
  store ptr %110, ptr @save_p, align 8, !tbaa !10
  %111 = load ptr, ptr @save_p, align 8, !tbaa !10
  store ptr %111, ptr %3, align 8, !tbaa !10
  %112 = load ptr, ptr %3, align 8, !tbaa !10
  %113 = load ptr, ptr %1, align 8, !tbaa !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %112, ptr align 8 %113, i64 64, i1 false)
  %114 = load ptr, ptr @save_p, align 8, !tbaa !10
  %115 = getelementptr inbounds i8, ptr %114, i64 64
  store ptr %115, ptr @save_p, align 8, !tbaa !10
  %116 = load ptr, ptr %3, align 8, !tbaa !10
  %117 = getelementptr inbounds %struct.vldoor_t, ptr %116, i32 0, i32 2
  %118 = load ptr, ptr %117, align 8, !tbaa !18
  %119 = load ptr, ptr @sectors, align 8, !tbaa !10
  %120 = ptrtoint ptr %118 to i64
  %121 = ptrtoint ptr %119 to i64
  %122 = sub i64 %120, %121
  %123 = sdiv exact i64 %122, 128
  %124 = inttoptr i64 %123 to ptr
  %125 = load ptr, ptr %3, align 8, !tbaa !10
  %126 = getelementptr inbounds %struct.vldoor_t, ptr %125, i32 0, i32 2
  store ptr %124, ptr %126, align 8, !tbaa !18
  br label %283

127:                                              ; preds = %96
  %128 = load ptr, ptr %1, align 8, !tbaa !10
  %129 = getelementptr inbounds %struct.thinker_s, ptr %128, i32 0, i32 2
  %130 = load ptr, ptr %129, align 8, !tbaa !11
  %131 = icmp eq ptr %130, @T_MoveFloor
  br i1 %131, label %132, label %158

132:                                              ; preds = %127
  %133 = load ptr, ptr @save_p, align 8, !tbaa !10
  %134 = getelementptr inbounds i8, ptr %133, i32 1
  store ptr %134, ptr @save_p, align 8, !tbaa !10
  store i8 2, ptr %133, align 1, !tbaa !11
  %135 = load ptr, ptr @save_p, align 8, !tbaa !10
  %136 = ptrtoint ptr %135 to i64
  %137 = and i64 %136, 3
  %138 = sub i64 4, %137
  %139 = and i64 %138, 3
  %140 = load ptr, ptr @save_p, align 8, !tbaa !10
  %141 = getelementptr inbounds i8, ptr %140, i64 %139
  store ptr %141, ptr @save_p, align 8, !tbaa !10
  %142 = load ptr, ptr @save_p, align 8, !tbaa !10
  store ptr %142, ptr %4, align 8, !tbaa !10
  %143 = load ptr, ptr %4, align 8, !tbaa !10
  %144 = load ptr, ptr %1, align 8, !tbaa !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %143, ptr align 8 %144, i64 64, i1 false)
  %145 = load ptr, ptr @save_p, align 8, !tbaa !10
  %146 = getelementptr inbounds i8, ptr %145, i64 64
  store ptr %146, ptr @save_p, align 8, !tbaa !10
  %147 = load ptr, ptr %4, align 8, !tbaa !10
  %148 = getelementptr inbounds %struct.floormove_t, ptr %147, i32 0, i32 3
  %149 = load ptr, ptr %148, align 8, !tbaa !20
  %150 = load ptr, ptr @sectors, align 8, !tbaa !10
  %151 = ptrtoint ptr %149 to i64
  %152 = ptrtoint ptr %150 to i64
  %153 = sub i64 %151, %152
  %154 = sdiv exact i64 %153, 128
  %155 = inttoptr i64 %154 to ptr
  %156 = load ptr, ptr %4, align 8, !tbaa !10
  %157 = getelementptr inbounds %struct.floormove_t, ptr %156, i32 0, i32 3
  store ptr %155, ptr %157, align 8, !tbaa !20
  br label %283

158:                                              ; preds = %127
  %159 = load ptr, ptr %1, align 8, !tbaa !10
  %160 = getelementptr inbounds %struct.thinker_s, ptr %159, i32 0, i32 2
  %161 = load ptr, ptr %160, align 8, !tbaa !11
  %162 = icmp eq ptr %161, @T_PlatRaise
  br i1 %162, label %163, label %189

163:                                              ; preds = %158
  %164 = load ptr, ptr @save_p, align 8, !tbaa !10
  %165 = getelementptr inbounds i8, ptr %164, i32 1
  store ptr %165, ptr @save_p, align 8, !tbaa !10
  store i8 3, ptr %164, align 1, !tbaa !11
  %166 = load ptr, ptr @save_p, align 8, !tbaa !10
  %167 = ptrtoint ptr %166 to i64
  %168 = and i64 %167, 3
  %169 = sub i64 4, %168
  %170 = and i64 %169, 3
  %171 = load ptr, ptr @save_p, align 8, !tbaa !10
  %172 = getelementptr inbounds i8, ptr %171, i64 %170
  store ptr %172, ptr @save_p, align 8, !tbaa !10
  %173 = load ptr, ptr @save_p, align 8, !tbaa !10
  store ptr %173, ptr %5, align 8, !tbaa !10
  %174 = load ptr, ptr %5, align 8, !tbaa !10
  %175 = load ptr, ptr %1, align 8, !tbaa !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %174, ptr align 8 %175, i64 72, i1 false)
  %176 = load ptr, ptr @save_p, align 8, !tbaa !10
  %177 = getelementptr inbounds i8, ptr %176, i64 72
  store ptr %177, ptr @save_p, align 8, !tbaa !10
  %178 = load ptr, ptr %5, align 8, !tbaa !10
  %179 = getelementptr inbounds %struct.plat_t, ptr %178, i32 0, i32 1
  %180 = load ptr, ptr %179, align 8, !tbaa !23
  %181 = load ptr, ptr @sectors, align 8, !tbaa !10
  %182 = ptrtoint ptr %180 to i64
  %183 = ptrtoint ptr %181 to i64
  %184 = sub i64 %182, %183
  %185 = sdiv exact i64 %184, 128
  %186 = inttoptr i64 %185 to ptr
  %187 = load ptr, ptr %5, align 8, !tbaa !10
  %188 = getelementptr inbounds %struct.plat_t, ptr %187, i32 0, i32 1
  store ptr %186, ptr %188, align 8, !tbaa !23
  br label %283

189:                                              ; preds = %158
  %190 = load ptr, ptr %1, align 8, !tbaa !10
  %191 = getelementptr inbounds %struct.thinker_s, ptr %190, i32 0, i32 2
  %192 = load ptr, ptr %191, align 8, !tbaa !11
  %193 = icmp eq ptr %192, @T_LightFlash
  br i1 %193, label %194, label %220

194:                                              ; preds = %189
  %195 = load ptr, ptr @save_p, align 8, !tbaa !10
  %196 = getelementptr inbounds i8, ptr %195, i32 1
  store ptr %196, ptr @save_p, align 8, !tbaa !10
  store i8 4, ptr %195, align 1, !tbaa !11
  %197 = load ptr, ptr @save_p, align 8, !tbaa !10
  %198 = ptrtoint ptr %197 to i64
  %199 = and i64 %198, 3
  %200 = sub i64 4, %199
  %201 = and i64 %200, 3
  %202 = load ptr, ptr @save_p, align 8, !tbaa !10
  %203 = getelementptr inbounds i8, ptr %202, i64 %201
  store ptr %203, ptr @save_p, align 8, !tbaa !10
  %204 = load ptr, ptr @save_p, align 8, !tbaa !10
  store ptr %204, ptr %6, align 8, !tbaa !10
  %205 = load ptr, ptr %6, align 8, !tbaa !10
  %206 = load ptr, ptr %1, align 8, !tbaa !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %205, ptr align 8 %206, i64 56, i1 false)
  %207 = load ptr, ptr @save_p, align 8, !tbaa !10
  %208 = getelementptr inbounds i8, ptr %207, i64 56
  store ptr %208, ptr @save_p, align 8, !tbaa !10
  %209 = load ptr, ptr %6, align 8, !tbaa !10
  %210 = getelementptr inbounds %struct.lightflash_t, ptr %209, i32 0, i32 1
  %211 = load ptr, ptr %210, align 8, !tbaa !25
  %212 = load ptr, ptr @sectors, align 8, !tbaa !10
  %213 = ptrtoint ptr %211 to i64
  %214 = ptrtoint ptr %212 to i64
  %215 = sub i64 %213, %214
  %216 = sdiv exact i64 %215, 128
  %217 = inttoptr i64 %216 to ptr
  %218 = load ptr, ptr %6, align 8, !tbaa !10
  %219 = getelementptr inbounds %struct.lightflash_t, ptr %218, i32 0, i32 1
  store ptr %217, ptr %219, align 8, !tbaa !25
  br label %283

220:                                              ; preds = %189
  %221 = load ptr, ptr %1, align 8, !tbaa !10
  %222 = getelementptr inbounds %struct.thinker_s, ptr %221, i32 0, i32 2
  %223 = load ptr, ptr %222, align 8, !tbaa !11
  %224 = icmp eq ptr %223, @T_StrobeFlash
  br i1 %224, label %225, label %251

225:                                              ; preds = %220
  %226 = load ptr, ptr @save_p, align 8, !tbaa !10
  %227 = getelementptr inbounds i8, ptr %226, i32 1
  store ptr %227, ptr @save_p, align 8, !tbaa !10
  store i8 5, ptr %226, align 1, !tbaa !11
  %228 = load ptr, ptr @save_p, align 8, !tbaa !10
  %229 = ptrtoint ptr %228 to i64
  %230 = and i64 %229, 3
  %231 = sub i64 4, %230
  %232 = and i64 %231, 3
  %233 = load ptr, ptr @save_p, align 8, !tbaa !10
  %234 = getelementptr inbounds i8, ptr %233, i64 %232
  store ptr %234, ptr @save_p, align 8, !tbaa !10
  %235 = load ptr, ptr @save_p, align 8, !tbaa !10
  store ptr %235, ptr %7, align 8, !tbaa !10
  %236 = load ptr, ptr %7, align 8, !tbaa !10
  %237 = load ptr, ptr %1, align 8, !tbaa !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %236, ptr align 8 %237, i64 56, i1 false)
  %238 = load ptr, ptr @save_p, align 8, !tbaa !10
  %239 = getelementptr inbounds i8, ptr %238, i64 56
  store ptr %239, ptr @save_p, align 8, !tbaa !10
  %240 = load ptr, ptr %7, align 8, !tbaa !10
  %241 = getelementptr inbounds %struct.strobe_t, ptr %240, i32 0, i32 1
  %242 = load ptr, ptr %241, align 8, !tbaa !25
  %243 = load ptr, ptr @sectors, align 8, !tbaa !10
  %244 = ptrtoint ptr %242 to i64
  %245 = ptrtoint ptr %243 to i64
  %246 = sub i64 %244, %245
  %247 = sdiv exact i64 %246, 128
  %248 = inttoptr i64 %247 to ptr
  %249 = load ptr, ptr %7, align 8, !tbaa !10
  %250 = getelementptr inbounds %struct.strobe_t, ptr %249, i32 0, i32 1
  store ptr %248, ptr %250, align 8, !tbaa !25
  br label %283

251:                                              ; preds = %220
  %252 = load ptr, ptr %1, align 8, !tbaa !10
  %253 = getelementptr inbounds %struct.thinker_s, ptr %252, i32 0, i32 2
  %254 = load ptr, ptr %253, align 8, !tbaa !11
  %255 = icmp eq ptr %254, @T_Glow
  br i1 %255, label %256, label %282

256:                                              ; preds = %251
  %257 = load ptr, ptr @save_p, align 8, !tbaa !10
  %258 = getelementptr inbounds i8, ptr %257, i32 1
  store ptr %258, ptr @save_p, align 8, !tbaa !10
  store i8 6, ptr %257, align 1, !tbaa !11
  %259 = load ptr, ptr @save_p, align 8, !tbaa !10
  %260 = ptrtoint ptr %259 to i64
  %261 = and i64 %260, 3
  %262 = sub i64 4, %261
  %263 = and i64 %262, 3
  %264 = load ptr, ptr @save_p, align 8, !tbaa !10
  %265 = getelementptr inbounds i8, ptr %264, i64 %263
  store ptr %265, ptr @save_p, align 8, !tbaa !10
  %266 = load ptr, ptr @save_p, align 8, !tbaa !10
  store ptr %266, ptr %8, align 8, !tbaa !10
  %267 = load ptr, ptr %8, align 8, !tbaa !10
  %268 = load ptr, ptr %1, align 8, !tbaa !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %267, ptr align 8 %268, i64 48, i1 false)
  %269 = load ptr, ptr @save_p, align 8, !tbaa !10
  %270 = getelementptr inbounds i8, ptr %269, i64 48
  store ptr %270, ptr @save_p, align 8, !tbaa !10
  %271 = load ptr, ptr %8, align 8, !tbaa !10
  %272 = getelementptr inbounds %struct.glow_t, ptr %271, i32 0, i32 1
  %273 = load ptr, ptr %272, align 8, !tbaa !27
  %274 = load ptr, ptr @sectors, align 8, !tbaa !10
  %275 = ptrtoint ptr %273 to i64
  %276 = ptrtoint ptr %274 to i64
  %277 = sub i64 %275, %276
  %278 = sdiv exact i64 %277, 128
  %279 = inttoptr i64 %278 to ptr
  %280 = load ptr, ptr %8, align 8, !tbaa !10
  %281 = getelementptr inbounds %struct.glow_t, ptr %280, i32 0, i32 1
  store ptr %279, ptr %281, align 8, !tbaa !27
  br label %283

282:                                              ; preds = %251
  br label %283

283:                                              ; preds = %282, %256, %225, %194, %163, %132, %101, %70, %64
  %284 = load ptr, ptr %1, align 8, !tbaa !10
  %285 = getelementptr inbounds %struct.thinker_s, ptr %284, i32 0, i32 1
  %286 = load ptr, ptr %285, align 8, !tbaa !5
  store ptr %286, ptr %1, align 8, !tbaa !10
  br label %11, !llvm.loop !29

287:                                              ; preds = %11
  %288 = load ptr, ptr @save_p, align 8, !tbaa !10
  %289 = getelementptr inbounds i8, ptr %288, i32 1
  store ptr %289, ptr @save_p, align 8, !tbaa !10
  store i8 7, ptr %288, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

declare void @T_MoveCeiling(ptr noundef) #3

declare void @T_VerticalDoor(ptr noundef) #3

declare void @T_MoveFloor(ptr noundef) #3

declare void @T_PlatRaise(ptr noundef) #3

declare void @T_LightFlash(ptr noundef) #3

declare void @T_StrobeFlash(ptr noundef) #3

declare void @T_Glow(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { "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 #4 = { 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, !7, i64 8}
!6 = !{!"thinker_s", !7, i64 0, !7, i64 8, !8, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!8, !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !7, i64 32}
!17 = !{!"", !6, i64 0, !13, i64 24, !7, i64 32, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !13, i64 56, !13, i64 60, !13, i64 64}
!18 = !{!19, !7, i64 32}
!19 = !{!"", !6, i64 0, !13, i64 24, !7, i64 32, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !13, i64 56}
!20 = !{!21, !7, i64 32}
!21 = !{!"", !6, i64 0, !13, i64 24, !13, i64 28, !7, i64 32, !13, i64 40, !13, i64 44, !22, i64 48, !13, i64 52, !13, i64 56}
!22 = !{!"short", !8, i64 0}
!23 = !{!24, !7, i64 24}
!24 = !{!"", !6, i64 0, !7, i64 24, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68}
!25 = !{!26, !7, i64 24}
!26 = !{!"", !6, i64 0, !7, i64 24, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48}
!27 = !{!28, !7, i64 24}
!28 = !{!"", !6, i64 0, !7, i64 24, !13, i64 32, !13, i64 36, !13, i64 40}
!29 = distinct !{!29, !15}


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

@save_p = external dso_local local_unnamed_addr global ptr, align 8
@sectors = external local_unnamed_addr global ptr, align 8
@thinkercap = external global %struct.thinker_s, align 8
@activeceilings = external local_unnamed_addr global [30 x ptr], align 16

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @P_ArchiveSpecials() local_unnamed_addr #1 {
  %.04649 = load ptr, ptr getelementptr inbounds (i8, ptr @thinkercap, i64 8), align 8, !tbaa !5
  %.not50 = icmp eq ptr %.04649, @thinkercap
  br i1 %.not50, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.critedge
  %.04651 = phi ptr [ %.046, %.critedge ], [ %.04649, %0 ]
  %1 = getelementptr inbounds i8, ptr %.04651, i64 16
  %2 = load ptr, ptr %1, align 8, !tbaa !10
  %3 = icmp eq ptr %2, null
  br i1 %3, label %.preheader.preheader, label %40

.preheader.preheader:                             ; preds = %.lr.ph
  %4 = load <16 x ptr>, ptr @activeceilings, align 16
  %5 = insertelement <16 x ptr> poison, ptr %.04651, i64 0
  %6 = shufflevector <16 x ptr> %5, <16 x ptr> poison, <16 x i32> zeroinitializer
  %7 = icmp eq <16 x ptr> %4, %6
  %8 = load <8 x ptr>, ptr getelementptr inbounds (i8, ptr @activeceilings, i64 128), align 16
  %9 = insertelement <8 x ptr> poison, ptr %.04651, i64 0
  %10 = shufflevector <8 x ptr> %9, <8 x ptr> poison, <8 x i32> zeroinitializer
  %11 = icmp eq <8 x ptr> %8, %10
  %12 = load <4 x ptr>, ptr getelementptr inbounds (i8, ptr @activeceilings, i64 192), align 16
  %13 = insertelement <4 x ptr> poison, ptr %.04651, i64 0
  %14 = shufflevector <4 x ptr> %13, <4 x ptr> poison, <4 x i32> zeroinitializer
  %15 = icmp eq <4 x ptr> %12, %14
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @activeceilings, i64 224), align 16
  %17 = icmp eq ptr %16, %.04651
  %18 = load ptr, ptr getelementptr inbounds (i8, ptr @activeceilings, i64 232), align 8
  %19 = icmp eq ptr %18, %.04651
  %20 = freeze <16 x i1> %7
  %21 = bitcast <16 x i1> %20 to i16
  %22 = icmp ne i16 %21, 0
  %23 = freeze <8 x i1> %11
  %24 = bitcast <8 x i1> %23 to i8
  %25 = icmp ne i8 %24, 0
  %op.rdx = or i1 %22, %25
  %26 = freeze <4 x i1> %15
  %27 = bitcast <4 x i1> %26 to i4
  %28 = icmp ne i4 %27, 0
  %op.rdx115 = or i1 %op.rdx, %28
  %.fr = freeze i1 %17
  %op.rdx116 = or i1 %op.rdx115, %.fr
  %op.rdx117 = select i1 %op.rdx116, i1 true, i1 %19
  br i1 %op.rdx117, label %29, label %.critedge

29:                                               ; preds = %.preheader.preheader
  %30 = load ptr, ptr @save_p, align 8, !tbaa !11
  %31 = getelementptr inbounds i8, ptr %30, i64 1
  store ptr %31, ptr @save_p, align 8, !tbaa !11
  store i8 0, ptr %30, align 1, !tbaa !10
  %32 = load ptr, ptr @save_p, align 8, !tbaa !11
  %33 = ptrtoint ptr %32 to i64
  %34 = sub i64 0, %33
  %35 = and i64 %34, 3
  %36 = getelementptr inbounds i8, ptr %32, i64 %35
  store ptr %36, ptr @save_p, align 8, !tbaa !11
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %36, ptr noundef nonnull align 8 dereferenceable(72) %.04651, i64 72, i1 false)
  %37 = load ptr, ptr @save_p, align 8, !tbaa !11
  %38 = getelementptr inbounds i8, ptr %37, i64 72
  store ptr %38, ptr @save_p, align 8, !tbaa !11
  %39 = getelementptr inbounds i8, ptr %36, i64 32
  br label %.critedge.sink.split

40:                                               ; preds = %.lr.ph
  %41 = icmp eq ptr %2, @T_MoveCeiling
  br i1 %41, label %42, label %53

42:                                               ; preds = %40
  %43 = load ptr, ptr @save_p, align 8, !tbaa !11
  %44 = getelementptr inbounds i8, ptr %43, i64 1
  store ptr %44, ptr @save_p, align 8, !tbaa !11
  store i8 0, ptr %43, align 1, !tbaa !10
  %45 = load ptr, ptr @save_p, align 8, !tbaa !11
  %46 = ptrtoint ptr %45 to i64
  %47 = sub i64 0, %46
  %48 = and i64 %47, 3
  %49 = getelementptr inbounds i8, ptr %45, i64 %48
  store ptr %49, ptr @save_p, align 8, !tbaa !11
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %49, ptr noundef nonnull align 8 dereferenceable(72) %.04651, i64 72, i1 false)
  %50 = load ptr, ptr @save_p, align 8, !tbaa !11
  %51 = getelementptr inbounds i8, ptr %50, i64 72
  store ptr %51, ptr @save_p, align 8, !tbaa !11
  %52 = getelementptr inbounds i8, ptr %49, i64 32
  br label %.critedge.sink.split

53:                                               ; preds = %40
  %54 = icmp eq ptr %2, @T_VerticalDoor
  br i1 %54, label %55, label %66

55:                                               ; preds = %53
  %56 = load ptr, ptr @save_p, align 8, !tbaa !11
  %57 = getelementptr inbounds i8, ptr %56, i64 1
  store ptr %57, ptr @save_p, align 8, !tbaa !11
  store i8 1, ptr %56, align 1, !tbaa !10
  %58 = load ptr, ptr @save_p, align 8, !tbaa !11
  %59 = ptrtoint ptr %58 to i64
  %60 = sub i64 0, %59
  %61 = and i64 %60, 3
  %62 = getelementptr inbounds i8, ptr %58, i64 %61
  store ptr %62, ptr @save_p, align 8, !tbaa !11
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(64) %62, ptr noundef nonnull align 8 dereferenceable(64) %.04651, i64 64, i1 false)
  %63 = load ptr, ptr @save_p, align 8, !tbaa !11
  %64 = getelementptr inbounds i8, ptr %63, i64 64
  store ptr %64, ptr @save_p, align 8, !tbaa !11
  %65 = getelementptr inbounds i8, ptr %62, i64 32
  br label %.critedge.sink.split

66:                                               ; preds = %53
  %67 = icmp eq ptr %2, @T_MoveFloor
  br i1 %67, label %68, label %79

68:                                               ; preds = %66
  %69 = load ptr, ptr @save_p, align 8, !tbaa !11
  %70 = getelementptr inbounds i8, ptr %69, i64 1
  store ptr %70, ptr @save_p, align 8, !tbaa !11
  store i8 2, ptr %69, align 1, !tbaa !10
  %71 = load ptr, ptr @save_p, align 8, !tbaa !11
  %72 = ptrtoint ptr %71 to i64
  %73 = sub i64 0, %72
  %74 = and i64 %73, 3
  %75 = getelementptr inbounds i8, ptr %71, i64 %74
  store ptr %75, ptr @save_p, align 8, !tbaa !11
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(64) %75, ptr noundef nonnull align 8 dereferenceable(64) %.04651, i64 64, i1 false)
  %76 = load ptr, ptr @save_p, align 8, !tbaa !11
  %77 = getelementptr inbounds i8, ptr %76, i64 64
  store ptr %77, ptr @save_p, align 8, !tbaa !11
  %78 = getelementptr inbounds i8, ptr %75, i64 32
  br label %.critedge.sink.split

79:                                               ; preds = %66
  %80 = icmp eq ptr %2, @T_PlatRaise
  br i1 %80, label %81, label %92

81:                                               ; preds = %79
  %82 = load ptr, ptr @save_p, align 8, !tbaa !11
  %83 = getelementptr inbounds i8, ptr %82, i64 1
  store ptr %83, ptr @save_p, align 8, !tbaa !11
  store i8 3, ptr %82, align 1, !tbaa !10
  %84 = load ptr, ptr @save_p, align 8, !tbaa !11
  %85 = ptrtoint ptr %84 to i64
  %86 = sub i64 0, %85
  %87 = and i64 %86, 3
  %88 = getelementptr inbounds i8, ptr %84, i64 %87
  store ptr %88, ptr @save_p, align 8, !tbaa !11
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %88, ptr noundef nonnull align 8 dereferenceable(72) %.04651, i64 72, i1 false)
  %89 = load ptr, ptr @save_p, align 8, !tbaa !11
  %90 = getelementptr inbounds i8, ptr %89, i64 72
  store ptr %90, ptr @save_p, align 8, !tbaa !11
  %91 = getelementptr inbounds i8, ptr %88, i64 24
  br label %.critedge.sink.split

92:                                               ; preds = %79
  %93 = icmp eq ptr %2, @T_LightFlash
  br i1 %93, label %94, label %105

94:                                               ; preds = %92
  %95 = load ptr, ptr @save_p, align 8, !tbaa !11
  %96 = getelementptr inbounds i8, ptr %95, i64 1
  store ptr %96, ptr @save_p, align 8, !tbaa !11
  store i8 4, ptr %95, align 1, !tbaa !10
  %97 = load ptr, ptr @save_p, align 8, !tbaa !11
  %98 = ptrtoint ptr %97 to i64
  %99 = sub i64 0, %98
  %100 = and i64 %99, 3
  %101 = getelementptr inbounds i8, ptr %97, i64 %100
  store ptr %101, ptr @save_p, align 8, !tbaa !11
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %101, ptr noundef nonnull align 8 dereferenceable(56) %.04651, i64 56, i1 false)
  %102 = load ptr, ptr @save_p, align 8, !tbaa !11
  %103 = getelementptr inbounds i8, ptr %102, i64 56
  store ptr %103, ptr @save_p, align 8, !tbaa !11
  %104 = getelementptr inbounds i8, ptr %101, i64 24
  br label %.critedge.sink.split

105:                                              ; preds = %92
  %106 = icmp eq ptr %2, @T_StrobeFlash
  br i1 %106, label %107, label %118

107:                                              ; preds = %105
  %108 = load ptr, ptr @save_p, align 8, !tbaa !11
  %109 = getelementptr inbounds i8, ptr %108, i64 1
  store ptr %109, ptr @save_p, align 8, !tbaa !11
  store i8 5, ptr %108, align 1, !tbaa !10
  %110 = load ptr, ptr @save_p, align 8, !tbaa !11
  %111 = ptrtoint ptr %110 to i64
  %112 = sub i64 0, %111
  %113 = and i64 %112, 3
  %114 = getelementptr inbounds i8, ptr %110, i64 %113
  store ptr %114, ptr @save_p, align 8, !tbaa !11
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %114, ptr noundef nonnull align 8 dereferenceable(56) %.04651, i64 56, i1 false)
  %115 = load ptr, ptr @save_p, align 8, !tbaa !11
  %116 = getelementptr inbounds i8, ptr %115, i64 56
  store ptr %116, ptr @save_p, align 8, !tbaa !11
  %117 = getelementptr inbounds i8, ptr %114, i64 24
  br label %.critedge.sink.split

118:                                              ; preds = %105
  %119 = icmp eq ptr %2, @T_Glow
  br i1 %119, label %120, label %.critedge

120:                                              ; preds = %118
  %121 = load ptr, ptr @save_p, align 8, !tbaa !11
  %122 = getelementptr inbounds i8, ptr %121, i64 1
  store ptr %122, ptr @save_p, align 8, !tbaa !11
  store i8 6, ptr %121, align 1, !tbaa !10
  %123 = load ptr, ptr @save_p, align 8, !tbaa !11
  %124 = ptrtoint ptr %123 to i64
  %125 = sub i64 0, %124
  %126 = and i64 %125, 3
  %127 = getelementptr inbounds i8, ptr %123, i64 %126
  store ptr %127, ptr @save_p, align 8, !tbaa !11
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %127, ptr noundef nonnull align 8 dereferenceable(48) %.04651, i64 48, i1 false)
  %128 = load ptr, ptr @save_p, align 8, !tbaa !11
  %129 = getelementptr inbounds i8, ptr %128, i64 48
  store ptr %129, ptr @save_p, align 8, !tbaa !11
  %130 = getelementptr inbounds i8, ptr %127, i64 24
  br label %.critedge.sink.split

.critedge.sink.split:                             ; preds = %42, %55, %68, %81, %94, %107, %120, %29
  %.sink = phi ptr [ %39, %29 ], [ %130, %120 ], [ %117, %107 ], [ %104, %94 ], [ %91, %81 ], [ %78, %68 ], [ %65, %55 ], [ %52, %42 ]
  %131 = load ptr, ptr %.sink, align 8, !tbaa !11
  %132 = load ptr, ptr @sectors, align 8, !tbaa !11
  %133 = ptrtoint ptr %131 to i64
  %134 = ptrtoint ptr %132 to i64
  %135 = sub i64 %133, %134
  %136 = ashr exact i64 %135, 7
  %137 = inttoptr i64 %136 to ptr
  store ptr %137, ptr %.sink, align 8, !tbaa !11
  br label %.critedge

.critedge:                                        ; preds = %.critedge.sink.split, %.preheader.preheader, %118
  %138 = getelementptr inbounds i8, ptr %.04651, i64 8
  %.046 = load ptr, ptr %138, align 8, !tbaa !5
  %.not = icmp eq ptr %.046, @thinkercap
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %.critedge, %0
  %139 = load ptr, ptr @save_p, align 8, !tbaa !11
  %140 = getelementptr inbounds i8, ptr %139, i64 1
  store ptr %140, ptr @save_p, align 8, !tbaa !11
  store i8 7, ptr %139, align 1, !tbaa !10
  ret void
}

declare void @T_MoveCeiling(ptr noundef) #2

declare void @T_VerticalDoor(ptr noundef) #2

declare void @T_MoveFloor(ptr noundef) #2

declare void @T_PlatRaise(ptr noundef) #2

declare void @T_LightFlash(ptr noundef) #2

declare void @T_StrobeFlash(ptr noundef) #2

declare void @T_Glow(ptr noundef) #2

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"thinker_s", !7, i64 0, !7, i64 8, !8, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass