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

; 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.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.lumpinfo_t = type { [8 x i8], i32, i32, i32 }
%struct.side_t = type { i32, i32, i16, i16, i16, ptr }
%struct.texture_t = type { [8 x i8], i16, i16, i16, [1 x %struct.texpatch_t] }
%struct.texpatch_t = type { i32, i32, i32 }
%struct.mobj_s = type { %struct.thinker_s, i32, i32, i32, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i32, ptr, i32, i32, i32, i32, ptr, i32, i32, ptr, i32, %struct.mapthing_t, ptr }
%struct.mapthing_t = type { i16, i16, i16, i16, i16 }
%struct.spritedef_t = type { i32, ptr }
%struct.spriteframe_t = type { i32, [8 x i16], [8 x i8] }

@textures = external dso_local global ptr, align 8
@numtextures = external dso_local global i32, align 4
@firstflat = external dso_local global i32, align 4
@numflats = external dso_local global i32, align 4
@firstspritelump = external dso_local global i32, align 4
@demoplayback = external global i32, align 4
@numsectors = external global i32, align 4
@sectors = external global ptr, align 8
@flatmemory = external dso_local global i32, align 4
@lumpinfo = external global ptr, align 8
@numsides = external global i32, align 4
@sides = external global ptr, align 8
@skytexture = external global i32, align 4
@texturememory = external dso_local global i32, align 4
@numsprites = external global i32, align 4
@thinkercap = external global %struct.thinker_s, align 8
@spritememory = external dso_local global i32, align 4
@sprites = 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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @R_PrecacheLevel() #5 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %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 ptr, align 8
  %11 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %12 = load i32, ptr @demoplayback, align 4, !tbaa !5
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %0
  store i32 1, ptr %11, align 4
  br label %274

15:                                               ; preds = %0
  %16 = load i32, ptr @numflats, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = call noalias ptr @malloc(i64 noundef %17) #7
  store ptr %18, ptr %1, align 8, !tbaa !9
  %19 = load ptr, ptr %1, align 8, !tbaa !9
  %20 = load i32, ptr @numflats, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %19, i8 0, i64 %21, i1 false)
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %45, %15
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = load i32, ptr @numsectors, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %48

26:                                               ; preds = %22
  %27 = load ptr, ptr %1, align 8, !tbaa !9
  %28 = load ptr, ptr @sectors, align 8, !tbaa !9
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds %struct.sector_t, ptr %28, i64 %30
  %32 = getelementptr inbounds %struct.sector_t, ptr %31, i32 0, i32 2
  %33 = load i16, ptr %32, align 8, !tbaa !11
  %34 = sext i16 %33 to i64
  %35 = getelementptr inbounds i8, ptr %27, i64 %34
  store i8 1, ptr %35, align 1, !tbaa !16
  %36 = load ptr, ptr %1, align 8, !tbaa !9
  %37 = load ptr, ptr @sectors, align 8, !tbaa !9
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds %struct.sector_t, ptr %37, i64 %39
  %41 = getelementptr inbounds %struct.sector_t, ptr %40, i32 0, i32 3
  %42 = load i16, ptr %41, align 2, !tbaa !17
  %43 = sext i16 %42 to i64
  %44 = getelementptr inbounds i8, ptr %36, i64 %43
  store i8 1, ptr %44, align 1, !tbaa !16
  br label %45

45:                                               ; preds = %26
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %4, align 4, !tbaa !5
  br label %22, !llvm.loop !18

48:                                               ; preds = %22
  store i32 0, ptr @flatmemory, align 4, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %75, %48
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = load i32, ptr @numflats, align 4, !tbaa !5
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %53, label %78

53:                                               ; preds = %49
  %54 = load ptr, ptr %1, align 8, !tbaa !9
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %54, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !16
  %59 = icmp ne i8 %58, 0
  br i1 %59, label %60, label %74

60:                                               ; preds = %53
  %61 = load i32, ptr @firstflat, align 4, !tbaa !5
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = add nsw i32 %61, %62
  store i32 %63, ptr %7, align 4, !tbaa !5
  %64 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds %struct.lumpinfo_t, ptr %64, i64 %66
  %68 = getelementptr inbounds %struct.lumpinfo_t, ptr %67, i32 0, i32 3
  %69 = load i32, ptr %68, align 4, !tbaa !20
  %70 = load i32, ptr @flatmemory, align 4, !tbaa !5
  %71 = add nsw i32 %70, %69
  store i32 %71, ptr @flatmemory, align 4, !tbaa !5
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = call ptr @W_CacheLumpNum(i32 noundef %72, i32 noundef 101)
  br label %74

74:                                               ; preds = %60, %53
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %4, align 4, !tbaa !5
  br label %49, !llvm.loop !22

78:                                               ; preds = %49
  %79 = load i32, ptr @numtextures, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = call noalias ptr @malloc(i64 noundef %80) #7
  store ptr %81, ptr %2, align 8, !tbaa !9
  %82 = load ptr, ptr %2, align 8, !tbaa !9
  %83 = load i32, ptr @numtextures, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %82, i8 0, i64 %84, i1 false)
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %117, %78
  %86 = load i32, ptr %4, align 4, !tbaa !5
  %87 = load i32, ptr @numsides, align 4, !tbaa !5
  %88 = icmp slt i32 %86, %87
  br i1 %88, label %89, label %120

89:                                               ; preds = %85
  %90 = load ptr, ptr %2, align 8, !tbaa !9
  %91 = load ptr, ptr @sides, align 8, !tbaa !9
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds %struct.side_t, ptr %91, i64 %93
  %95 = getelementptr inbounds %struct.side_t, ptr %94, i32 0, i32 2
  %96 = load i16, ptr %95, align 8, !tbaa !23
  %97 = sext i16 %96 to i64
  %98 = getelementptr inbounds i8, ptr %90, i64 %97
  store i8 1, ptr %98, align 1, !tbaa !16
  %99 = load ptr, ptr %2, align 8, !tbaa !9
  %100 = load ptr, ptr @sides, align 8, !tbaa !9
  %101 = load i32, ptr %4, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds %struct.side_t, ptr %100, i64 %102
  %104 = getelementptr inbounds %struct.side_t, ptr %103, i32 0, i32 4
  %105 = load i16, ptr %104, align 4, !tbaa !25
  %106 = sext i16 %105 to i64
  %107 = getelementptr inbounds i8, ptr %99, i64 %106
  store i8 1, ptr %107, align 1, !tbaa !16
  %108 = load ptr, ptr %2, align 8, !tbaa !9
  %109 = load ptr, ptr @sides, align 8, !tbaa !9
  %110 = load i32, ptr %4, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds %struct.side_t, ptr %109, i64 %111
  %113 = getelementptr inbounds %struct.side_t, ptr %112, i32 0, i32 3
  %114 = load i16, ptr %113, align 2, !tbaa !26
  %115 = sext i16 %114 to i64
  %116 = getelementptr inbounds i8, ptr %108, i64 %115
  store i8 1, ptr %116, align 1, !tbaa !16
  br label %117

117:                                              ; preds = %89
  %118 = load i32, ptr %4, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %4, align 4, !tbaa !5
  br label %85, !llvm.loop !27

120:                                              ; preds = %85
  %121 = load ptr, ptr %2, align 8, !tbaa !9
  %122 = load i32, ptr @skytexture, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds i8, ptr %121, i64 %123
  store i8 1, ptr %124, align 1, !tbaa !16
  store i32 0, ptr @texturememory, align 4, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %125

125:                                              ; preds = %172, %120
  %126 = load i32, ptr %4, align 4, !tbaa !5
  %127 = load i32, ptr @numtextures, align 4, !tbaa !5
  %128 = icmp slt i32 %126, %127
  br i1 %128, label %129, label %175

129:                                              ; preds = %125
  %130 = load ptr, ptr %2, align 8, !tbaa !9
  %131 = load i32, ptr %4, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds i8, ptr %130, i64 %132
  %134 = load i8, ptr %133, align 1, !tbaa !16
  %135 = icmp ne i8 %134, 0
  br i1 %135, label %137, label %136

136:                                              ; preds = %129
  br label %172

137:                                              ; preds = %129
  %138 = load ptr, ptr @textures, align 8, !tbaa !9
  %139 = load i32, ptr %4, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds ptr, ptr %138, i64 %140
  %142 = load ptr, ptr %141, align 8, !tbaa !9
  store ptr %142, ptr %8, align 8, !tbaa !9
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %143

143:                                              ; preds = %168, %137
  %144 = load i32, ptr %5, align 4, !tbaa !5
  %145 = load ptr, ptr %8, align 8, !tbaa !9
  %146 = getelementptr inbounds %struct.texture_t, ptr %145, i32 0, i32 3
  %147 = load i16, ptr %146, align 4, !tbaa !28
  %148 = sext i16 %147 to i32
  %149 = icmp slt i32 %144, %148
  br i1 %149, label %150, label %171

150:                                              ; preds = %143
  %151 = load ptr, ptr %8, align 8, !tbaa !9
  %152 = getelementptr inbounds %struct.texture_t, ptr %151, i32 0, i32 4
  %153 = load i32, ptr %5, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [1 x %struct.texpatch_t], ptr %152, i64 0, i64 %154
  %156 = getelementptr inbounds %struct.texpatch_t, ptr %155, i32 0, i32 2
  %157 = load i32, ptr %156, align 4, !tbaa !30
  store i32 %157, ptr %7, align 4, !tbaa !5
  %158 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %159 = load i32, ptr %7, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds %struct.lumpinfo_t, ptr %158, i64 %160
  %162 = getelementptr inbounds %struct.lumpinfo_t, ptr %161, i32 0, i32 3
  %163 = load i32, ptr %162, align 4, !tbaa !20
  %164 = load i32, ptr @texturememory, align 4, !tbaa !5
  %165 = add nsw i32 %164, %163
  store i32 %165, ptr @texturememory, align 4, !tbaa !5
  %166 = load i32, ptr %7, align 4, !tbaa !5
  %167 = call ptr @W_CacheLumpNum(i32 noundef %166, i32 noundef 101)
  br label %168

168:                                              ; preds = %150
  %169 = load i32, ptr %5, align 4, !tbaa !5
  %170 = add nsw i32 %169, 1
  store i32 %170, ptr %5, align 4, !tbaa !5
  br label %143, !llvm.loop !32

171:                                              ; preds = %143
  br label %172

172:                                              ; preds = %171, %136
  %173 = load i32, ptr %4, align 4, !tbaa !5
  %174 = add nsw i32 %173, 1
  store i32 %174, ptr %4, align 4, !tbaa !5
  br label %125, !llvm.loop !33

175:                                              ; preds = %125
  %176 = load i32, ptr @numsprites, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = call noalias ptr @malloc(i64 noundef %177) #7
  store ptr %178, ptr %3, align 8, !tbaa !9
  %179 = load ptr, ptr %3, align 8, !tbaa !9
  %180 = load i32, ptr @numsprites, align 4, !tbaa !5
  %181 = sext i32 %180 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %179, i8 0, i64 %181, i1 false)
  %182 = load ptr, ptr getelementptr inbounds (%struct.thinker_s, ptr @thinkercap, i32 0, i32 1), align 8, !tbaa !34
  store ptr %182, ptr %9, align 8, !tbaa !9
  br label %183

183:                                              ; preds = %199, %175
  %184 = load ptr, ptr %9, align 8, !tbaa !9
  %185 = icmp ne ptr %184, @thinkercap
  br i1 %185, label %186, label %203

186:                                              ; preds = %183
  %187 = load ptr, ptr %9, align 8, !tbaa !9
  %188 = getelementptr inbounds %struct.thinker_s, ptr %187, i32 0, i32 2
  %189 = load ptr, ptr %188, align 8, !tbaa !16
  %190 = icmp eq ptr %189, @P_MobjThinker
  br i1 %190, label %191, label %198

191:                                              ; preds = %186
  %192 = load ptr, ptr %3, align 8, !tbaa !9
  %193 = load ptr, ptr %9, align 8, !tbaa !9
  %194 = getelementptr inbounds %struct.mobj_s, ptr %193, i32 0, i32 7
  %195 = load i32, ptr %194, align 4, !tbaa !35
  %196 = zext i32 %195 to i64
  %197 = getelementptr inbounds i8, ptr %192, i64 %196
  store i8 1, ptr %197, align 1, !tbaa !16
  br label %198

198:                                              ; preds = %191, %186
  br label %199

199:                                              ; preds = %198
  %200 = load ptr, ptr %9, align 8, !tbaa !9
  %201 = getelementptr inbounds %struct.thinker_s, ptr %200, i32 0, i32 1
  %202 = load ptr, ptr %201, align 8, !tbaa !34
  store ptr %202, ptr %9, align 8, !tbaa !9
  br label %183, !llvm.loop !38

203:                                              ; preds = %183
  store i32 0, ptr @spritememory, align 4, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %204

204:                                              ; preds = %267, %203
  %205 = load i32, ptr %4, align 4, !tbaa !5
  %206 = load i32, ptr @numsprites, align 4, !tbaa !5
  %207 = icmp slt i32 %205, %206
  br i1 %207, label %208, label %270

208:                                              ; preds = %204
  %209 = load ptr, ptr %3, align 8, !tbaa !9
  %210 = load i32, ptr %4, align 4, !tbaa !5
  %211 = sext i32 %210 to i64
  %212 = getelementptr inbounds i8, ptr %209, i64 %211
  %213 = load i8, ptr %212, align 1, !tbaa !16
  %214 = icmp ne i8 %213, 0
  br i1 %214, label %216, label %215

215:                                              ; preds = %208
  br label %267

216:                                              ; preds = %208
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %217

217:                                              ; preds = %263, %216
  %218 = load i32, ptr %5, align 4, !tbaa !5
  %219 = load ptr, ptr @sprites, align 8, !tbaa !9
  %220 = load i32, ptr %4, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds %struct.spritedef_t, ptr %219, i64 %221
  %223 = getelementptr inbounds %struct.spritedef_t, ptr %222, i32 0, i32 0
  %224 = load i32, ptr %223, align 8, !tbaa !39
  %225 = icmp slt i32 %218, %224
  br i1 %225, label %226, label %266

226:                                              ; preds = %217
  %227 = load ptr, ptr @sprites, align 8, !tbaa !9
  %228 = load i32, ptr %4, align 4, !tbaa !5
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds %struct.spritedef_t, ptr %227, i64 %229
  %231 = getelementptr inbounds %struct.spritedef_t, ptr %230, i32 0, i32 1
  %232 = load ptr, ptr %231, align 8, !tbaa !41
  %233 = load i32, ptr %5, align 4, !tbaa !5
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds %struct.spriteframe_t, ptr %232, i64 %234
  store ptr %235, ptr %10, align 8, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %236

236:                                              ; preds = %259, %226
  %237 = load i32, ptr %6, align 4, !tbaa !5
  %238 = icmp slt i32 %237, 8
  br i1 %238, label %239, label %262

239:                                              ; preds = %236
  %240 = load i32, ptr @firstspritelump, align 4, !tbaa !5
  %241 = load ptr, ptr %10, align 8, !tbaa !9
  %242 = getelementptr inbounds %struct.spriteframe_t, ptr %241, i32 0, i32 1
  %243 = load i32, ptr %6, align 4, !tbaa !5
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [8 x i16], ptr %242, i64 0, i64 %244
  %246 = load i16, ptr %245, align 2, !tbaa !42
  %247 = sext i16 %246 to i32
  %248 = add nsw i32 %240, %247
  store i32 %248, ptr %7, align 4, !tbaa !5
  %249 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %250 = load i32, ptr %7, align 4, !tbaa !5
  %251 = sext i32 %250 to i64
  %252 = getelementptr inbounds %struct.lumpinfo_t, ptr %249, i64 %251
  %253 = getelementptr inbounds %struct.lumpinfo_t, ptr %252, i32 0, i32 3
  %254 = load i32, ptr %253, align 4, !tbaa !20
  %255 = load i32, ptr @spritememory, align 4, !tbaa !5
  %256 = add nsw i32 %255, %254
  store i32 %256, ptr @spritememory, align 4, !tbaa !5
  %257 = load i32, ptr %7, align 4, !tbaa !5
  %258 = call ptr @W_CacheLumpNum(i32 noundef %257, i32 noundef 101)
  br label %259

259:                                              ; preds = %239
  %260 = load i32, ptr %6, align 4, !tbaa !5
  %261 = add nsw i32 %260, 1
  store i32 %261, ptr %6, align 4, !tbaa !5
  br label %236, !llvm.loop !43

262:                                              ; preds = %236
  br label %263

263:                                              ; preds = %262
  %264 = load i32, ptr %5, align 4, !tbaa !5
  %265 = add nsw i32 %264, 1
  store i32 %265, ptr %5, align 4, !tbaa !5
  br label %217, !llvm.loop !44

266:                                              ; preds = %217
  br label %267

267:                                              ; preds = %266, %215
  %268 = load i32, ptr %4, align 4, !tbaa !5
  %269 = add nsw i32 %268, 1
  store i32 %269, ptr %4, align 4, !tbaa !5
  br label %204, !llvm.loop !45

270:                                              ; preds = %204
  %271 = load ptr, ptr %3, align 8, !tbaa !9
  call void @free(ptr noundef %271) #6
  %272 = load ptr, ptr %2, align 8, !tbaa !9
  call void @free(ptr noundef %272) #6
  %273 = load ptr, ptr %1, align 8, !tbaa !9
  call void @free(ptr noundef %273) #6
  store i32 0, ptr %11, align 4
  br label %274

274:                                              ; preds = %270, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #6
  %275 = load i32, ptr %11, align 4
  switch i32 %275, label %277 [
    i32 0, label %276
    i32 1, label %276
  ]

276:                                              ; preds = %274, %274
  ret void

277:                                              ; preds = %274
  unreachable
}

declare void @P_MobjThinker(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind "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 #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"", !6, i64 0, !6, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !13, i64 14, !13, i64 16, !6, i64 20, !10, i64 24, !7, i64 32, !14, i64 48, !6, i64 88, !10, i64 96, !10, i64 104, !6, i64 112, !10, i64 120}
!13 = !{!"short", !7, i64 0}
!14 = !{!"", !15, i64 0, !6, i64 24, !6, i64 28, !6, i64 32}
!15 = !{!"thinker_s", !10, i64 0, !10, i64 8, !7, i64 16}
!16 = !{!7, !7, i64 0}
!17 = !{!12, !13, i64 10}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !6, i64 16}
!21 = !{!"", !7, i64 0, !6, i64 8, !6, i64 12, !6, i64 16}
!22 = distinct !{!22, !19}
!23 = !{!24, !13, i64 8}
!24 = !{!"", !6, i64 0, !6, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !10, i64 16}
!25 = !{!24, !13, i64 12}
!26 = !{!24, !13, i64 10}
!27 = distinct !{!27, !19}
!28 = !{!29, !13, i64 12}
!29 = !{!"", !7, i64 0, !13, i64 8, !13, i64 10, !13, i64 12, !7, i64 16}
!30 = !{!31, !6, i64 8}
!31 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8}
!32 = distinct !{!32, !19}
!33 = distinct !{!33, !19}
!34 = !{!15, !10, i64 8}
!35 = !{!36, !6, i64 60}
!36 = !{!"mobj_s", !15, i64 0, !6, i64 24, !6, i64 28, !6, i64 32, !10, i64 40, !10, i64 48, !6, i64 56, !6, i64 60, !6, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !6, i64 96, !6, i64 100, !6, i64 104, !6, i64 108, !6, i64 112, !6, i64 116, !6, i64 120, !6, i64 124, !6, i64 128, !10, i64 136, !6, i64 144, !10, i64 152, !6, i64 160, !6, i64 164, !6, i64 168, !6, i64 172, !10, i64 176, !6, i64 184, !6, i64 188, !10, i64 192, !6, i64 200, !37, i64 204, !10, i64 216}
!37 = !{!"", !13, i64 0, !13, i64 2, !13, i64 4, !13, i64 6, !13, i64 8}
!38 = distinct !{!38, !19}
!39 = !{!40, !6, i64 0}
!40 = !{!"", !6, i64 0, !10, i64 8}
!41 = !{!40, !10, i64 8}
!42 = !{!13, !13, i64 0}
!43 = distinct !{!43, !19}
!44 = distinct !{!44, !19}
!45 = distinct !{!45, !19}


; 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 }
%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.lumpinfo_t = type { [8 x i8], i32, i32, i32 }
%struct.side_t = type { i32, i32, i16, i16, i16, ptr }
%struct.texpatch_t = type { i32, i32, i32 }
%struct.spritedef_t = type { i32, ptr }
%struct.spriteframe_t = type { i32, [8 x i16], [8 x i8] }

@textures = external dso_local local_unnamed_addr global ptr, align 8
@numtextures = external dso_local local_unnamed_addr global i32, align 4
@firstflat = external dso_local local_unnamed_addr global i32, align 4
@numflats = external dso_local local_unnamed_addr global i32, align 4
@firstspritelump = external dso_local local_unnamed_addr global i32, align 4
@demoplayback = external local_unnamed_addr global i32, align 4
@numsectors = external local_unnamed_addr global i32, align 4
@sectors = external local_unnamed_addr global ptr, align 8
@flatmemory = external dso_local local_unnamed_addr global i32, align 4
@lumpinfo = external local_unnamed_addr global ptr, align 8
@numsides = external local_unnamed_addr global i32, align 4
@sides = external local_unnamed_addr global ptr, align 8
@skytexture = external local_unnamed_addr global i32, align 4
@texturememory = external dso_local local_unnamed_addr global i32, align 4
@numsprites = external local_unnamed_addr global i32, align 4
@thinkercap = external global %struct.thinker_s, align 8
@spritememory = external dso_local local_unnamed_addr global i32, align 4
@sprites = external local_unnamed_addr global ptr, align 8

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @R_PrecacheLevel() local_unnamed_addr #2 {
  %1 = load i32, ptr @demoplayback, align 4, !tbaa !5
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %2, label %254

2:                                                ; preds = %0
  %3 = load i32, ptr @numflats, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  %calloc125 = tail call ptr @calloc(i64 1, i64 %4)
  %5 = load i32, ptr @numsectors, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %7 = load ptr, ptr @sectors, align 8, !tbaa !9
  %wide.trip.count = zext nneg i32 %5 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %8 = icmp eq i32 %5, 1
  br i1 %8, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %9

9:                                                ; preds = %9, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.1, %9 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %9 ]
  %10 = getelementptr inbounds %struct.sector_t, ptr %7, i64 %indvars.iv, i32 2
  %11 = load i16, ptr %10, align 8, !tbaa !11
  %12 = sext i16 %11 to i64
  %13 = getelementptr inbounds i8, ptr %calloc125, i64 %12
  store i8 1, ptr %13, align 1, !tbaa !16
  %14 = getelementptr inbounds %struct.sector_t, ptr %7, i64 %indvars.iv, i32 3
  %15 = load i16, ptr %14, align 2, !tbaa !17
  %16 = sext i16 %15 to i64
  %17 = getelementptr inbounds i8, ptr %calloc125, i64 %16
  store i8 1, ptr %17, align 1, !tbaa !16
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %18 = getelementptr inbounds %struct.sector_t, ptr %7, i64 %indvars.iv.next, i32 2
  %19 = load i16, ptr %18, align 8, !tbaa !11
  %20 = sext i16 %19 to i64
  %21 = getelementptr inbounds i8, ptr %calloc125, i64 %20
  store i8 1, ptr %21, align 1, !tbaa !16
  %22 = getelementptr inbounds %struct.sector_t, ptr %7, i64 %indvars.iv.next, i32 3
  %23 = load i16, ptr %22, align 2, !tbaa !17
  %24 = sext i16 %23 to i64
  %25 = getelementptr inbounds i8, ptr %calloc125, i64 %24
  store i8 1, ptr %25, align 1, !tbaa !16
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %9, !llvm.loop !18

._crit_edge.loopexit.unr-lcssa:                   ; preds = %9, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %9 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %26 = getelementptr inbounds %struct.sector_t, ptr %7, i64 %indvars.iv.unr, i32 2
  %27 = load i16, ptr %26, align 8, !tbaa !11
  %28 = sext i16 %27 to i64
  %29 = getelementptr inbounds i8, ptr %calloc125, i64 %28
  store i8 1, ptr %29, align 1, !tbaa !16
  %30 = getelementptr inbounds %struct.sector_t, ptr %7, i64 %indvars.iv.unr, i32 3
  %31 = load i16, ptr %30, align 2, !tbaa !17
  %32 = sext i16 %31 to i64
  %33 = getelementptr inbounds i8, ptr %calloc125, i64 %32
  store i8 1, ptr %33, align 1, !tbaa !16
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %2
  store i32 0, ptr @flatmemory, align 4, !tbaa !5
  %34 = icmp sgt i32 %3, 0
  br i1 %34, label %.lr.ph71, label %._crit_edge72

.lr.ph71:                                         ; preds = %._crit_edge, %49
  %35 = phi i32 [ %50, %49 ], [ %3, %._crit_edge ]
  %indvars.iv98 = phi i64 [ %indvars.iv.next99, %49 ], [ 0, %._crit_edge ]
  %36 = getelementptr inbounds i8, ptr %calloc125, i64 %indvars.iv98
  %37 = load i8, ptr %36, align 1, !tbaa !16
  %.not66 = icmp eq i8 %37, 0
  br i1 %.not66, label %49, label %38

38:                                               ; preds = %.lr.ph71
  %39 = load i32, ptr @firstflat, align 4, !tbaa !5
  %40 = trunc nuw nsw i64 %indvars.iv98 to i32
  %41 = add nsw i32 %39, %40
  %42 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %43 = sext i32 %41 to i64
  %44 = getelementptr inbounds %struct.lumpinfo_t, ptr %42, i64 %43, i32 3
  %45 = load i32, ptr %44, align 4, !tbaa !20
  %46 = load i32, ptr @flatmemory, align 4, !tbaa !5
  %47 = add nsw i32 %46, %45
  store i32 %47, ptr @flatmemory, align 4, !tbaa !5
  %48 = tail call ptr @W_CacheLumpNum(i32 noundef %41, i32 noundef 101) #4
  %.pre = load i32, ptr @numflats, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %.lr.ph71, %38
  %50 = phi i32 [ %35, %.lr.ph71 ], [ %.pre, %38 ]
  %indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 1
  %51 = sext i32 %50 to i64
  %52 = icmp slt i64 %indvars.iv.next99, %51
  br i1 %52, label %.lr.ph71, label %._crit_edge72, !llvm.loop !22

._crit_edge72:                                    ; preds = %49, %._crit_edge
  %53 = load i32, ptr @numtextures, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %calloc124 = tail call ptr @calloc(i64 1, i64 %54)
  %55 = load i32, ptr @numsides, align 4, !tbaa !5
  %56 = icmp sgt i32 %55, 0
  br i1 %56, label %.lr.ph75, label %._crit_edge76

.lr.ph75:                                         ; preds = %._crit_edge72
  %57 = load ptr, ptr @sides, align 8, !tbaa !9
  %wide.trip.count104 = zext nneg i32 %55 to i64
  %xtraiter127 = and i64 %wide.trip.count104, 1
  %58 = icmp eq i32 %55, 1
  br i1 %58, label %._crit_edge76.loopexit.unr-lcssa, label %.lr.ph75.new

.lr.ph75.new:                                     ; preds = %.lr.ph75
  %unroll_iter129 = and i64 %wide.trip.count104, 2147483646
  br label %59

59:                                               ; preds = %59, %.lr.ph75.new
  %indvars.iv101 = phi i64 [ 0, %.lr.ph75.new ], [ %indvars.iv.next102.1, %59 ]
  %niter130 = phi i64 [ 0, %.lr.ph75.new ], [ %niter130.next.1, %59 ]
  %60 = getelementptr inbounds %struct.side_t, ptr %57, i64 %indvars.iv101, i32 2
  %61 = load i16, ptr %60, align 8, !tbaa !23
  %62 = sext i16 %61 to i64
  %63 = getelementptr inbounds i8, ptr %calloc124, i64 %62
  store i8 1, ptr %63, align 1, !tbaa !16
  %64 = getelementptr inbounds %struct.side_t, ptr %57, i64 %indvars.iv101, i32 4
  %65 = load i16, ptr %64, align 4, !tbaa !25
  %66 = sext i16 %65 to i64
  %67 = getelementptr inbounds i8, ptr %calloc124, i64 %66
  store i8 1, ptr %67, align 1, !tbaa !16
  %68 = getelementptr inbounds %struct.side_t, ptr %57, i64 %indvars.iv101, i32 3
  %69 = load i16, ptr %68, align 2, !tbaa !26
  %70 = sext i16 %69 to i64
  %71 = getelementptr inbounds i8, ptr %calloc124, i64 %70
  store i8 1, ptr %71, align 1, !tbaa !16
  %indvars.iv.next102 = or disjoint i64 %indvars.iv101, 1
  %72 = getelementptr inbounds %struct.side_t, ptr %57, i64 %indvars.iv.next102, i32 2
  %73 = load i16, ptr %72, align 8, !tbaa !23
  %74 = sext i16 %73 to i64
  %75 = getelementptr inbounds i8, ptr %calloc124, i64 %74
  store i8 1, ptr %75, align 1, !tbaa !16
  %76 = getelementptr inbounds %struct.side_t, ptr %57, i64 %indvars.iv.next102, i32 4
  %77 = load i16, ptr %76, align 4, !tbaa !25
  %78 = sext i16 %77 to i64
  %79 = getelementptr inbounds i8, ptr %calloc124, i64 %78
  store i8 1, ptr %79, align 1, !tbaa !16
  %80 = getelementptr inbounds %struct.side_t, ptr %57, i64 %indvars.iv.next102, i32 3
  %81 = load i16, ptr %80, align 2, !tbaa !26
  %82 = sext i16 %81 to i64
  %83 = getelementptr inbounds i8, ptr %calloc124, i64 %82
  store i8 1, ptr %83, align 1, !tbaa !16
  %indvars.iv.next102.1 = add nuw nsw i64 %indvars.iv101, 2
  %niter130.next.1 = add i64 %niter130, 2
  %niter130.ncmp.1 = icmp eq i64 %niter130.next.1, %unroll_iter129
  br i1 %niter130.ncmp.1, label %._crit_edge76.loopexit.unr-lcssa, label %59, !llvm.loop !27

._crit_edge76.loopexit.unr-lcssa:                 ; preds = %59, %.lr.ph75
  %indvars.iv101.unr = phi i64 [ 0, %.lr.ph75 ], [ %indvars.iv.next102.1, %59 ]
  %lcmp.mod128.not = icmp eq i64 %xtraiter127, 0
  br i1 %lcmp.mod128.not, label %._crit_edge76, label %._crit_edge76.loopexit.epilog-lcssa

._crit_edge76.loopexit.epilog-lcssa:              ; preds = %._crit_edge76.loopexit.unr-lcssa
  %84 = getelementptr inbounds %struct.side_t, ptr %57, i64 %indvars.iv101.unr, i32 2
  %85 = load i16, ptr %84, align 8, !tbaa !23
  %86 = sext i16 %85 to i64
  %87 = getelementptr inbounds i8, ptr %calloc124, i64 %86
  store i8 1, ptr %87, align 1, !tbaa !16
  %88 = getelementptr inbounds %struct.side_t, ptr %57, i64 %indvars.iv101.unr, i32 4
  %89 = load i16, ptr %88, align 4, !tbaa !25
  %90 = sext i16 %89 to i64
  %91 = getelementptr inbounds i8, ptr %calloc124, i64 %90
  store i8 1, ptr %91, align 1, !tbaa !16
  %92 = getelementptr inbounds %struct.side_t, ptr %57, i64 %indvars.iv101.unr, i32 3
  %93 = load i16, ptr %92, align 2, !tbaa !26
  %94 = sext i16 %93 to i64
  %95 = getelementptr inbounds i8, ptr %calloc124, i64 %94
  store i8 1, ptr %95, align 1, !tbaa !16
  br label %._crit_edge76

._crit_edge76:                                    ; preds = %._crit_edge76.loopexit.epilog-lcssa, %._crit_edge76.loopexit.unr-lcssa, %._crit_edge72
  %96 = load i32, ptr @skytexture, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds i8, ptr %calloc124, i64 %97
  store i8 1, ptr %98, align 1, !tbaa !16
  store i32 0, ptr @texturememory, align 4, !tbaa !5
  %99 = icmp sgt i32 %53, 0
  br i1 %99, label %.lr.ph82, label %._crit_edge83

.lr.ph82:                                         ; preds = %._crit_edge76, %.loopexit67
  %100 = phi i32 [ %124, %.loopexit67 ], [ %53, %._crit_edge76 ]
  %indvars.iv109 = phi i64 [ %indvars.iv.next110, %.loopexit67 ], [ 0, %._crit_edge76 ]
  %101 = getelementptr inbounds i8, ptr %calloc124, i64 %indvars.iv109
  %102 = load i8, ptr %101, align 1, !tbaa !16
  %.not65 = icmp eq i8 %102, 0
  br i1 %.not65, label %.loopexit67, label %103

103:                                              ; preds = %.lr.ph82
  %104 = load ptr, ptr @textures, align 8, !tbaa !9
  %105 = getelementptr inbounds ptr, ptr %104, i64 %indvars.iv109
  %106 = load ptr, ptr %105, align 8, !tbaa !9
  %107 = getelementptr inbounds i8, ptr %106, i64 12
  %108 = load i16, ptr %107, align 4, !tbaa !28
  %109 = icmp sgt i16 %108, 0
  br i1 %109, label %.lr.ph79, label %.loopexit67

.lr.ph79:                                         ; preds = %103
  %110 = getelementptr inbounds i8, ptr %106, i64 16
  br label %111

111:                                              ; preds = %.lr.ph79, %111
  %indvars.iv106 = phi i64 [ 0, %.lr.ph79 ], [ %indvars.iv.next107, %111 ]
  %112 = getelementptr inbounds [1 x %struct.texpatch_t], ptr %110, i64 0, i64 %indvars.iv106, i32 2
  %113 = load i32, ptr %112, align 4, !tbaa !30
  %114 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %115 = sext i32 %113 to i64
  %116 = getelementptr inbounds %struct.lumpinfo_t, ptr %114, i64 %115, i32 3
  %117 = load i32, ptr %116, align 4, !tbaa !20
  %118 = load i32, ptr @texturememory, align 4, !tbaa !5
  %119 = add nsw i32 %118, %117
  store i32 %119, ptr @texturememory, align 4, !tbaa !5
  %120 = tail call ptr @W_CacheLumpNum(i32 noundef %113, i32 noundef 101) #4
  %indvars.iv.next107 = add nuw nsw i64 %indvars.iv106, 1
  %121 = load i16, ptr %107, align 4, !tbaa !28
  %122 = sext i16 %121 to i64
  %123 = icmp slt i64 %indvars.iv.next107, %122
  br i1 %123, label %111, label %.loopexit67.loopexit, !llvm.loop !32

.loopexit67.loopexit:                             ; preds = %111
  %.pre122 = load i32, ptr @numtextures, align 4, !tbaa !5
  br label %.loopexit67

.loopexit67:                                      ; preds = %.loopexit67.loopexit, %103, %.lr.ph82
  %124 = phi i32 [ %.pre122, %.loopexit67.loopexit ], [ %100, %103 ], [ %100, %.lr.ph82 ]
  %indvars.iv.next110 = add nuw nsw i64 %indvars.iv109, 1
  %125 = sext i32 %124 to i64
  %126 = icmp slt i64 %indvars.iv.next110, %125
  br i1 %126, label %.lr.ph82, label %._crit_edge83, !llvm.loop !33

._crit_edge83:                                    ; preds = %.loopexit67, %._crit_edge76
  %127 = load i32, ptr @numsprites, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %calloc = tail call ptr @calloc(i64 1, i64 %128)
  %.05984 = load ptr, ptr getelementptr inbounds (i8, ptr @thinkercap, i64 8), align 8, !tbaa !34
  %.not6385 = icmp eq ptr %.05984, @thinkercap
  br i1 %.not6385, label %._crit_edge89, label %.lr.ph88

.lr.ph88:                                         ; preds = %._crit_edge83, %137
  %.05986 = phi ptr [ %.059, %137 ], [ %.05984, %._crit_edge83 ]
  %129 = getelementptr inbounds i8, ptr %.05986, i64 16
  %130 = load ptr, ptr %129, align 8, !tbaa !16
  %131 = icmp eq ptr %130, @P_MobjThinker
  br i1 %131, label %132, label %137

132:                                              ; preds = %.lr.ph88
  %133 = getelementptr inbounds i8, ptr %.05986, i64 60
  %134 = load i32, ptr %133, align 4, !tbaa !35
  %135 = zext i32 %134 to i64
  %136 = getelementptr inbounds i8, ptr %calloc, i64 %135
  store i8 1, ptr %136, align 1, !tbaa !16
  br label %137

137:                                              ; preds = %.lr.ph88, %132
  %138 = getelementptr inbounds i8, ptr %.05986, i64 8
  %.059 = load ptr, ptr %138, align 8, !tbaa !34
  %.not63 = icmp eq ptr %.059, @thinkercap
  br i1 %.not63, label %._crit_edge89, label %.lr.ph88, !llvm.loop !38

._crit_edge89:                                    ; preds = %137, %._crit_edge83
  store i32 0, ptr @spritememory, align 4, !tbaa !5
  %139 = icmp sgt i32 %127, 0
  br i1 %139, label %.lr.ph95, label %._crit_edge96

.lr.ph95:                                         ; preds = %._crit_edge89, %.loopexit
  %140 = phi i32 [ %251, %.loopexit ], [ %127, %._crit_edge89 ]
  %indvars.iv119 = phi i64 [ %indvars.iv.next120, %.loopexit ], [ 0, %._crit_edge89 ]
  %141 = getelementptr inbounds i8, ptr %calloc, i64 %indvars.iv119
  %142 = load i8, ptr %141, align 1, !tbaa !16
  %.not64 = icmp eq i8 %142, 0
  br i1 %.not64, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %.lr.ph95
  %143 = load ptr, ptr @sprites, align 8, !tbaa !9
  %144 = getelementptr inbounds %struct.spritedef_t, ptr %143, i64 %indvars.iv119
  %145 = load i32, ptr %144, align 8, !tbaa !39
  %146 = icmp sgt i32 %145, 0
  br i1 %146, label %.lr.ph92, label %.loopexit

.lr.ph92:                                         ; preds = %.preheader, %.lr.ph92
  %indvars.iv116 = phi i64 [ %indvars.iv.next117, %.lr.ph92 ], [ 0, %.preheader ]
  %147 = phi ptr [ %246, %.lr.ph92 ], [ %143, %.preheader ]
  %148 = getelementptr inbounds %struct.spritedef_t, ptr %147, i64 %indvars.iv119, i32 1
  %149 = load ptr, ptr %148, align 8, !tbaa !41
  %150 = load i32, ptr @firstspritelump, align 4, !tbaa !5
  %151 = getelementptr inbounds %struct.spriteframe_t, ptr %149, i64 %indvars.iv116, i32 1, i64 0
  %152 = load i16, ptr %151, align 2, !tbaa !42
  %153 = sext i16 %152 to i32
  %154 = add nsw i32 %150, %153
  %155 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %156 = sext i32 %154 to i64
  %157 = getelementptr inbounds %struct.lumpinfo_t, ptr %155, i64 %156, i32 3
  %158 = load i32, ptr %157, align 4, !tbaa !20
  %159 = load i32, ptr @spritememory, align 4, !tbaa !5
  %160 = add nsw i32 %159, %158
  store i32 %160, ptr @spritememory, align 4, !tbaa !5
  %161 = tail call ptr @W_CacheLumpNum(i32 noundef %154, i32 noundef 101) #4
  %162 = load i32, ptr @firstspritelump, align 4, !tbaa !5
  %163 = getelementptr inbounds %struct.spriteframe_t, ptr %149, i64 %indvars.iv116, i32 1, i64 1
  %164 = load i16, ptr %163, align 2, !tbaa !42
  %165 = sext i16 %164 to i32
  %166 = add nsw i32 %162, %165
  %167 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %168 = sext i32 %166 to i64
  %169 = getelementptr inbounds %struct.lumpinfo_t, ptr %167, i64 %168, i32 3
  %170 = load i32, ptr %169, align 4, !tbaa !20
  %171 = load i32, ptr @spritememory, align 4, !tbaa !5
  %172 = add nsw i32 %171, %170
  store i32 %172, ptr @spritememory, align 4, !tbaa !5
  %173 = tail call ptr @W_CacheLumpNum(i32 noundef %166, i32 noundef 101) #4
  %174 = load i32, ptr @firstspritelump, align 4, !tbaa !5
  %175 = getelementptr inbounds %struct.spriteframe_t, ptr %149, i64 %indvars.iv116, i32 1, i64 2
  %176 = load i16, ptr %175, align 2, !tbaa !42
  %177 = sext i16 %176 to i32
  %178 = add nsw i32 %174, %177
  %179 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %180 = sext i32 %178 to i64
  %181 = getelementptr inbounds %struct.lumpinfo_t, ptr %179, i64 %180, i32 3
  %182 = load i32, ptr %181, align 4, !tbaa !20
  %183 = load i32, ptr @spritememory, align 4, !tbaa !5
  %184 = add nsw i32 %183, %182
  store i32 %184, ptr @spritememory, align 4, !tbaa !5
  %185 = tail call ptr @W_CacheLumpNum(i32 noundef %178, i32 noundef 101) #4
  %186 = load i32, ptr @firstspritelump, align 4, !tbaa !5
  %187 = getelementptr inbounds %struct.spriteframe_t, ptr %149, i64 %indvars.iv116, i32 1, i64 3
  %188 = load i16, ptr %187, align 2, !tbaa !42
  %189 = sext i16 %188 to i32
  %190 = add nsw i32 %186, %189
  %191 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %192 = sext i32 %190 to i64
  %193 = getelementptr inbounds %struct.lumpinfo_t, ptr %191, i64 %192, i32 3
  %194 = load i32, ptr %193, align 4, !tbaa !20
  %195 = load i32, ptr @spritememory, align 4, !tbaa !5
  %196 = add nsw i32 %195, %194
  store i32 %196, ptr @spritememory, align 4, !tbaa !5
  %197 = tail call ptr @W_CacheLumpNum(i32 noundef %190, i32 noundef 101) #4
  %198 = load i32, ptr @firstspritelump, align 4, !tbaa !5
  %199 = getelementptr inbounds %struct.spriteframe_t, ptr %149, i64 %indvars.iv116, i32 1, i64 4
  %200 = load i16, ptr %199, align 2, !tbaa !42
  %201 = sext i16 %200 to i32
  %202 = add nsw i32 %198, %201
  %203 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %204 = sext i32 %202 to i64
  %205 = getelementptr inbounds %struct.lumpinfo_t, ptr %203, i64 %204, i32 3
  %206 = load i32, ptr %205, align 4, !tbaa !20
  %207 = load i32, ptr @spritememory, align 4, !tbaa !5
  %208 = add nsw i32 %207, %206
  store i32 %208, ptr @spritememory, align 4, !tbaa !5
  %209 = tail call ptr @W_CacheLumpNum(i32 noundef %202, i32 noundef 101) #4
  %210 = load i32, ptr @firstspritelump, align 4, !tbaa !5
  %211 = getelementptr inbounds %struct.spriteframe_t, ptr %149, i64 %indvars.iv116, i32 1, i64 5
  %212 = load i16, ptr %211, align 2, !tbaa !42
  %213 = sext i16 %212 to i32
  %214 = add nsw i32 %210, %213
  %215 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %216 = sext i32 %214 to i64
  %217 = getelementptr inbounds %struct.lumpinfo_t, ptr %215, i64 %216, i32 3
  %218 = load i32, ptr %217, align 4, !tbaa !20
  %219 = load i32, ptr @spritememory, align 4, !tbaa !5
  %220 = add nsw i32 %219, %218
  store i32 %220, ptr @spritememory, align 4, !tbaa !5
  %221 = tail call ptr @W_CacheLumpNum(i32 noundef %214, i32 noundef 101) #4
  %222 = load i32, ptr @firstspritelump, align 4, !tbaa !5
  %223 = getelementptr inbounds %struct.spriteframe_t, ptr %149, i64 %indvars.iv116, i32 1, i64 6
  %224 = load i16, ptr %223, align 2, !tbaa !42
  %225 = sext i16 %224 to i32
  %226 = add nsw i32 %222, %225
  %227 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %228 = sext i32 %226 to i64
  %229 = getelementptr inbounds %struct.lumpinfo_t, ptr %227, i64 %228, i32 3
  %230 = load i32, ptr %229, align 4, !tbaa !20
  %231 = load i32, ptr @spritememory, align 4, !tbaa !5
  %232 = add nsw i32 %231, %230
  store i32 %232, ptr @spritememory, align 4, !tbaa !5
  %233 = tail call ptr @W_CacheLumpNum(i32 noundef %226, i32 noundef 101) #4
  %234 = load i32, ptr @firstspritelump, align 4, !tbaa !5
  %235 = getelementptr inbounds %struct.spriteframe_t, ptr %149, i64 %indvars.iv116, i32 1, i64 7
  %236 = load i16, ptr %235, align 2, !tbaa !42
  %237 = sext i16 %236 to i32
  %238 = add nsw i32 %234, %237
  %239 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %240 = sext i32 %238 to i64
  %241 = getelementptr inbounds %struct.lumpinfo_t, ptr %239, i64 %240, i32 3
  %242 = load i32, ptr %241, align 4, !tbaa !20
  %243 = load i32, ptr @spritememory, align 4, !tbaa !5
  %244 = add nsw i32 %243, %242
  store i32 %244, ptr @spritememory, align 4, !tbaa !5
  %245 = tail call ptr @W_CacheLumpNum(i32 noundef %238, i32 noundef 101) #4
  %indvars.iv.next117 = add nuw nsw i64 %indvars.iv116, 1
  %246 = load ptr, ptr @sprites, align 8, !tbaa !9
  %247 = getelementptr inbounds %struct.spritedef_t, ptr %246, i64 %indvars.iv119
  %248 = load i32, ptr %247, align 8, !tbaa !39
  %249 = sext i32 %248 to i64
  %250 = icmp slt i64 %indvars.iv.next117, %249
  br i1 %250, label %.lr.ph92, label %.loopexit.loopexit, !llvm.loop !43

.loopexit.loopexit:                               ; preds = %.lr.ph92
  %.pre123 = load i32, ptr @numsprites, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.preheader, %.lr.ph95
  %251 = phi i32 [ %.pre123, %.loopexit.loopexit ], [ %140, %.preheader ], [ %140, %.lr.ph95 ]
  %indvars.iv.next120 = add nuw nsw i64 %indvars.iv119, 1
  %252 = sext i32 %251 to i64
  %253 = icmp slt i64 %indvars.iv.next120, %252
  br i1 %253, label %.lr.ph95, label %._crit_edge96, !llvm.loop !44

._crit_edge96:                                    ; preds = %.loopexit, %._crit_edge89
  tail call void @free(ptr noundef %calloc) #4
  tail call void @free(ptr noundef %calloc124) #4
  tail call void @free(ptr noundef %calloc125) #4
  br label %254

254:                                              ; preds = %0, %._crit_edge96
  ret void
}

declare void @P_MobjThinker(ptr noundef) #0

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"", !6, i64 0, !6, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !13, i64 14, !13, i64 16, !6, i64 20, !10, i64 24, !7, i64 32, !14, i64 48, !6, i64 88, !10, i64 96, !10, i64 104, !6, i64 112, !10, i64 120}
!13 = !{!"short", !7, i64 0}
!14 = !{!"", !15, i64 0, !6, i64 24, !6, i64 28, !6, i64 32}
!15 = !{!"thinker_s", !10, i64 0, !10, i64 8, !7, i64 16}
!16 = !{!7, !7, i64 0}
!17 = !{!12, !13, i64 10}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !6, i64 16}
!21 = !{!"", !7, i64 0, !6, i64 8, !6, i64 12, !6, i64 16}
!22 = distinct !{!22, !19}
!23 = !{!24, !13, i64 8}
!24 = !{!"", !6, i64 0, !6, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !10, i64 16}
!25 = !{!24, !13, i64 12}
!26 = !{!24, !13, i64 10}
!27 = distinct !{!27, !19}
!28 = !{!29, !13, i64 12}
!29 = !{!"", !7, i64 0, !13, i64 8, !13, i64 10, !13, i64 12, !7, i64 16}
!30 = !{!31, !6, i64 8}
!31 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8}
!32 = distinct !{!32, !19}
!33 = distinct !{!33, !19}
!34 = !{!15, !10, i64 8}
!35 = !{!36, !6, i64 60}
!36 = !{!"mobj_s", !15, i64 0, !6, i64 24, !6, i64 28, !6, i64 32, !10, i64 40, !10, i64 48, !6, i64 56, !6, i64 60, !6, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !6, i64 96, !6, i64 100, !6, i64 104, !6, i64 108, !6, i64 112, !6, i64 116, !6, i64 120, !6, i64 124, !6, i64 128, !10, i64 136, !6, i64 144, !10, i64 152, !6, i64 160, !6, i64 164, !6, i64 168, !6, i64 172, !10, i64 176, !6, i64 184, !6, i64 188, !10, i64 192, !6, i64 200, !37, i64 204, !10, i64 216}
!37 = !{!"", !13, i64 0, !13, i64 2, !13, i64 4, !13, i64 6, !13, i64 8}
!38 = distinct !{!38, !19}
!39 = !{!40, !6, i64 0}
!40 = !{!"", !6, i64 0, !10, i64 8}
!41 = !{!40, !10, i64 8}
!42 = !{!13, !13, i64 0}
!43 = distinct !{!43, !19}
!44 = distinct !{!44, !19}


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