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

; 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.vissprite_s = type { ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i32 }
%struct.pspdef_t = type { ptr, i32, i32, i32 }
%struct.state_t = type { i32, i64, i64, %union.actionf_t, i32, i64, i64 }
%union.actionf_t = type { ptr }
%struct.spritedef_t = type { i32, ptr }
%struct.spriteframe_t = type { i32, [8 x i16], [8 x i8] }
%struct.player_s = type { ptr, i32, %struct.ticcmd_t, i32, i32, i32, i32, i32, i32, i32, [6 x i32], [6 x i32], i32, [4 x i32], i32, i32, [9 x i32], [4 x i32], [4 x i32], i32, i32, i32, i32, i32, i32, i32, ptr, i32, i32, ptr, i32, i32, i32, [2 x %struct.pspdef_t], i32 }
%struct.ticcmd_t = type { i8, i8, i16, i16, i8, i8 }

@numsprites = external dso_local global i32, align 4
@sprites = external dso_local global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [47 x i8], align 1
@spriteoffset = external global ptr, align 8
@centerxfrac = external global i32, align 4
@viewwidth = external global i32, align 4
@spritewidth = external global ptr, align 8
@spritetopoffset = external global ptr, align 8
@fixedcolormap = external global ptr, align 8
@colormaps = external global ptr, align 8
@spritelights = external dso_local global ptr, align 8
@pspritescale = external dso_local global i32, align 4
@pspriteiscale = external dso_local global i32, align 4
@viewplayer = 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: noreturn
declare void @I_Error(ptr noundef, ...) #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
declare dso_local void @R_DrawVisSprite(ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @FixedMul(i32 noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @R_DrawPSprite(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca %struct.vissprite_s, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, 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 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 80, ptr %11) #4
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.pspdef_t, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.state_t, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !12
  %18 = load i32, ptr @numsprites, align 4, !tbaa !15
  %19 = icmp uge i32 %17, %18
  br i1 %19, label %20, label %26

20:                                               ; preds = %1
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.pspdef_t, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.state_t, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !12
  call void (ptr, ...) @I_Error(ptr noundef @.str.7, i32 noundef %25) #5
  unreachable

26:                                               ; preds = %1
  %27 = load ptr, ptr @sprites, align 8, !tbaa !5
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.pspdef_t, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.state_t, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !12
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds %struct.spritedef_t, ptr %27, i64 %33
  store ptr %34, ptr %6, align 8, !tbaa !5
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.pspdef_t, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.state_t, ptr %37, i32 0, i32 1
  %39 = load i64, ptr %38, align 8, !tbaa !16
  %40 = and i64 %39, 32767
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.spritedef_t, ptr %41, i32 0, i32 0
  %43 = load i32, ptr %42, align 8, !tbaa !17
  %44 = sext i32 %43 to i64
  %45 = icmp sge i64 %40, %44
  br i1 %45, label %46, label %57

46:                                               ; preds = %26
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.pspdef_t, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.state_t, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 8, !tbaa !12
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.pspdef_t, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.state_t, ptr %54, i32 0, i32 1
  %56 = load i64, ptr %55, align 8, !tbaa !16
  call void (ptr, ...) @I_Error(ptr noundef @.str.8, i32 noundef %51, i64 noundef %56) #5
  unreachable

57:                                               ; preds = %26
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.spritedef_t, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !19
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.pspdef_t, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.state_t, ptr %63, i32 0, i32 1
  %65 = load i64, ptr %64, align 8, !tbaa !16
  %66 = and i64 %65, 32767
  %67 = getelementptr inbounds %struct.spriteframe_t, ptr %60, i64 %66
  store ptr %67, ptr %7, align 8, !tbaa !5
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.spriteframe_t, ptr %68, i32 0, i32 1
  %70 = getelementptr inbounds [8 x i16], ptr %69, i64 0, i64 0
  %71 = load i16, ptr %70, align 4, !tbaa !20
  %72 = sext i16 %71 to i32
  store i32 %72, ptr %8, align 4, !tbaa !15
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.spriteframe_t, ptr %73, i32 0, i32 2
  %75 = getelementptr inbounds [8 x i8], ptr %74, i64 0, i64 0
  %76 = load i8, ptr %75, align 4, !tbaa !22
  %77 = zext i8 %76 to i32
  store i32 %77, ptr %9, align 4, !tbaa !15
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.pspdef_t, ptr %78, i32 0, i32 2
  %80 = load i32, ptr %79, align 4, !tbaa !23
  %81 = sub nsw i32 %80, 10485760
  store i32 %81, ptr %3, align 4, !tbaa !15
  %82 = load ptr, ptr @spriteoffset, align 8, !tbaa !5
  %83 = load i32, ptr %8, align 4, !tbaa !15
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds i32, ptr %82, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !15
  %87 = load i32, ptr %3, align 4, !tbaa !15
  %88 = sub nsw i32 %87, %86
  store i32 %88, ptr %3, align 4, !tbaa !15
  %89 = load i32, ptr @centerxfrac, align 4, !tbaa !15
  %90 = load i32, ptr %3, align 4, !tbaa !15
  %91 = load i32, ptr @pspritescale, align 4, !tbaa !15
  %92 = call i32 @FixedMul(i32 noundef %90, i32 noundef %91)
  %93 = add nsw i32 %89, %92
  %94 = ashr i32 %93, 16
  store i32 %94, ptr %4, align 4, !tbaa !15
  %95 = load i32, ptr %4, align 4, !tbaa !15
  %96 = load i32, ptr @viewwidth, align 4, !tbaa !15
  %97 = icmp sgt i32 %95, %96
  br i1 %97, label %98, label %99

98:                                               ; preds = %57
  store i32 1, ptr %12, align 4
  br label %251

99:                                               ; preds = %57
  %100 = load ptr, ptr @spritewidth, align 8, !tbaa !5
  %101 = load i32, ptr %8, align 4, !tbaa !15
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds i32, ptr %100, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !15
  %105 = load i32, ptr %3, align 4, !tbaa !15
  %106 = add nsw i32 %105, %104
  store i32 %106, ptr %3, align 4, !tbaa !15
  %107 = load i32, ptr @centerxfrac, align 4, !tbaa !15
  %108 = load i32, ptr %3, align 4, !tbaa !15
  %109 = load i32, ptr @pspritescale, align 4, !tbaa !15
  %110 = call i32 @FixedMul(i32 noundef %108, i32 noundef %109)
  %111 = add nsw i32 %107, %110
  %112 = ashr i32 %111, 16
  %113 = sub nsw i32 %112, 1
  store i32 %113, ptr %5, align 4, !tbaa !15
  %114 = load i32, ptr %5, align 4, !tbaa !15
  %115 = icmp slt i32 %114, 0
  br i1 %115, label %116, label %117

116:                                              ; preds = %99
  store i32 1, ptr %12, align 4
  br label %251

117:                                              ; preds = %99
  store ptr %11, ptr %10, align 8, !tbaa !5
  %118 = load ptr, ptr %10, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.vissprite_s, ptr %118, i32 0, i32 14
  store i32 0, ptr %119, align 8, !tbaa !24
  %120 = load ptr, ptr %2, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.pspdef_t, ptr %120, i32 0, i32 3
  %122 = load i32, ptr %121, align 8, !tbaa !26
  %123 = load ptr, ptr @spritetopoffset, align 8, !tbaa !5
  %124 = load i32, ptr %8, align 4, !tbaa !15
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds i32, ptr %123, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !15
  %128 = sub nsw i32 %122, %127
  %129 = sub nsw i32 6586368, %128
  %130 = load ptr, ptr %10, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.vissprite_s, ptr %130, i32 0, i32 11
  store i32 %129, ptr %131, align 4, !tbaa !27
  %132 = load i32, ptr %4, align 4, !tbaa !15
  %133 = icmp slt i32 %132, 0
  br i1 %133, label %134, label %135

134:                                              ; preds = %117
  br label %137

135:                                              ; preds = %117
  %136 = load i32, ptr %4, align 4, !tbaa !15
  br label %137

137:                                              ; preds = %135, %134
  %138 = phi i32 [ 0, %134 ], [ %136, %135 ]
  %139 = load ptr, ptr %10, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.vissprite_s, ptr %139, i32 0, i32 2
  store i32 %138, ptr %140, align 8, !tbaa !28
  %141 = load i32, ptr %5, align 4, !tbaa !15
  %142 = load i32, ptr @viewwidth, align 4, !tbaa !15
  %143 = icmp sge i32 %141, %142
  br i1 %143, label %144, label %147

144:                                              ; preds = %137
  %145 = load i32, ptr @viewwidth, align 4, !tbaa !15
  %146 = sub nsw i32 %145, 1
  br label %149

147:                                              ; preds = %137
  %148 = load i32, ptr %5, align 4, !tbaa !15
  br label %149

149:                                              ; preds = %147, %144
  %150 = phi i32 [ %146, %144 ], [ %148, %147 ]
  %151 = load ptr, ptr %10, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.vissprite_s, ptr %151, i32 0, i32 3
  store i32 %150, ptr %152, align 4, !tbaa !29
  %153 = load i32, ptr @pspritescale, align 4, !tbaa !15
  %154 = load ptr, ptr %10, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.vissprite_s, ptr %154, i32 0, i32 9
  store i32 %153, ptr %155, align 4, !tbaa !30
  %156 = load i32, ptr %9, align 4, !tbaa !15
  %157 = icmp ne i32 %156, 0
  br i1 %157, label %158, label %171

158:                                              ; preds = %149
  %159 = load i32, ptr @pspriteiscale, align 4, !tbaa !15
  %160 = sub nsw i32 0, %159
  %161 = load ptr, ptr %10, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.vissprite_s, ptr %161, i32 0, i32 10
  store i32 %160, ptr %162, align 8, !tbaa !31
  %163 = load ptr, ptr @spritewidth, align 8, !tbaa !5
  %164 = load i32, ptr %8, align 4, !tbaa !15
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds i32, ptr %163, i64 %165
  %167 = load i32, ptr %166, align 4, !tbaa !15
  %168 = sub nsw i32 %167, 1
  %169 = load ptr, ptr %10, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.vissprite_s, ptr %169, i32 0, i32 8
  store i32 %168, ptr %170, align 8, !tbaa !32
  br label %177

171:                                              ; preds = %149
  %172 = load i32, ptr @pspriteiscale, align 4, !tbaa !15
  %173 = load ptr, ptr %10, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.vissprite_s, ptr %173, i32 0, i32 10
  store i32 %172, ptr %174, align 8, !tbaa !31
  %175 = load ptr, ptr %10, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.vissprite_s, ptr %175, i32 0, i32 8
  store i32 0, ptr %176, align 8, !tbaa !32
  br label %177

177:                                              ; preds = %171, %158
  %178 = load ptr, ptr %10, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.vissprite_s, ptr %178, i32 0, i32 2
  %180 = load i32, ptr %179, align 8, !tbaa !28
  %181 = load i32, ptr %4, align 4, !tbaa !15
  %182 = icmp sgt i32 %180, %181
  br i1 %182, label %183, label %197

183:                                              ; preds = %177
  %184 = load ptr, ptr %10, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.vissprite_s, ptr %184, i32 0, i32 10
  %186 = load i32, ptr %185, align 8, !tbaa !31
  %187 = load ptr, ptr %10, align 8, !tbaa !5
  %188 = getelementptr inbounds %struct.vissprite_s, ptr %187, i32 0, i32 2
  %189 = load i32, ptr %188, align 8, !tbaa !28
  %190 = load i32, ptr %4, align 4, !tbaa !15
  %191 = sub nsw i32 %189, %190
  %192 = mul nsw i32 %186, %191
  %193 = load ptr, ptr %10, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.vissprite_s, ptr %193, i32 0, i32 8
  %195 = load i32, ptr %194, align 8, !tbaa !32
  %196 = add nsw i32 %195, %192
  store i32 %196, ptr %194, align 8, !tbaa !32
  br label %197

197:                                              ; preds = %183, %177
  %198 = load i32, ptr %8, align 4, !tbaa !15
  %199 = load ptr, ptr %10, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.vissprite_s, ptr %199, i32 0, i32 12
  store i32 %198, ptr %200, align 8, !tbaa !33
  %201 = load ptr, ptr @viewplayer, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.player_s, ptr %201, i32 0, i32 10
  %203 = getelementptr inbounds [6 x i32], ptr %202, i64 0, i64 2
  %204 = load i32, ptr %203, align 8, !tbaa !15
  %205 = icmp sgt i32 %204, 128
  br i1 %205, label %213, label %206

206:                                              ; preds = %197
  %207 = load ptr, ptr @viewplayer, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct.player_s, ptr %207, i32 0, i32 10
  %209 = getelementptr inbounds [6 x i32], ptr %208, i64 0, i64 2
  %210 = load i32, ptr %209, align 8, !tbaa !15
  %211 = and i32 %210, 8
  %212 = icmp ne i32 %211, 0
  br i1 %212, label %213, label %216

213:                                              ; preds = %206, %197
  %214 = load ptr, ptr %10, align 8, !tbaa !5
  %215 = getelementptr inbounds %struct.vissprite_s, ptr %214, i32 0, i32 13
  store ptr null, ptr %215, align 8, !tbaa !34
  br label %243

216:                                              ; preds = %206
  %217 = load ptr, ptr @fixedcolormap, align 8, !tbaa !5
  %218 = icmp ne ptr %217, null
  br i1 %218, label %219, label %223

219:                                              ; preds = %216
  %220 = load ptr, ptr @fixedcolormap, align 8, !tbaa !5
  %221 = load ptr, ptr %10, align 8, !tbaa !5
  %222 = getelementptr inbounds %struct.vissprite_s, ptr %221, i32 0, i32 13
  store ptr %220, ptr %222, align 8, !tbaa !34
  br label %242

223:                                              ; preds = %216
  %224 = load ptr, ptr %2, align 8, !tbaa !5
  %225 = getelementptr inbounds %struct.pspdef_t, ptr %224, i32 0, i32 0
  %226 = load ptr, ptr %225, align 8, !tbaa !9
  %227 = getelementptr inbounds %struct.state_t, ptr %226, i32 0, i32 1
  %228 = load i64, ptr %227, align 8, !tbaa !16
  %229 = and i64 %228, 32768
  %230 = icmp ne i64 %229, 0
  br i1 %230, label %231, label %235

231:                                              ; preds = %223
  %232 = load ptr, ptr @colormaps, align 8, !tbaa !5
  %233 = load ptr, ptr %10, align 8, !tbaa !5
  %234 = getelementptr inbounds %struct.vissprite_s, ptr %233, i32 0, i32 13
  store ptr %232, ptr %234, align 8, !tbaa !34
  br label %241

235:                                              ; preds = %223
  %236 = load ptr, ptr @spritelights, align 8, !tbaa !5
  %237 = getelementptr inbounds ptr, ptr %236, i64 47
  %238 = load ptr, ptr %237, align 8, !tbaa !5
  %239 = load ptr, ptr %10, align 8, !tbaa !5
  %240 = getelementptr inbounds %struct.vissprite_s, ptr %239, i32 0, i32 13
  store ptr %238, ptr %240, align 8, !tbaa !34
  br label %241

241:                                              ; preds = %235, %231
  br label %242

242:                                              ; preds = %241, %219
  br label %243

243:                                              ; preds = %242, %213
  %244 = load ptr, ptr %10, align 8, !tbaa !5
  %245 = load ptr, ptr %10, align 8, !tbaa !5
  %246 = getelementptr inbounds %struct.vissprite_s, ptr %245, i32 0, i32 2
  %247 = load i32, ptr %246, align 8, !tbaa !28
  %248 = load ptr, ptr %10, align 8, !tbaa !5
  %249 = getelementptr inbounds %struct.vissprite_s, ptr %248, i32 0, i32 3
  %250 = load i32, ptr %249, align 4, !tbaa !29
  call void @R_DrawVisSprite(ptr noundef %244, i32 noundef %247, i32 noundef %250)
  store i32 0, ptr %12, align 4
  br label %251

251:                                              ; preds = %243, %116, %98
  call void @llvm.lifetime.end.p0(i64 80, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, 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 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  %252 = load i32, ptr %12, align 4
  switch i32 %252, label %254 [
    i32 0, label %253
    i32 1, label %253
  ]

253:                                              ; preds = %251, %251
  ret void

254:                                              ; preds = %251
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn "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 = { inlinehint 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 #4 = { nounwind }
attributes #5 = { noreturn }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"", !11, i64 0, !14, i64 8, !14, i64 16, !7, i64 24, !11, i64 32, !14, i64 40, !14, i64 48}
!14 = !{!"long", !7, i64 0}
!15 = !{!11, !11, i64 0}
!16 = !{!13, !14, i64 8}
!17 = !{!18, !11, i64 0}
!18 = !{!"", !11, i64 0, !6, i64 8}
!19 = !{!18, !6, i64 8}
!20 = !{!21, !21, i64 0}
!21 = !{!"short", !7, i64 0}
!22 = !{!7, !7, i64 0}
!23 = !{!10, !11, i64 12}
!24 = !{!25, !11, i64 72}
!25 = !{!"vissprite_s", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !6, i64 64, !11, i64 72}
!26 = !{!10, !11, i64 16}
!27 = !{!25, !11, i64 52}
!28 = !{!25, !11, i64 16}
!29 = !{!25, !11, i64 20}
!30 = !{!25, !11, i64 44}
!31 = !{!25, !11, i64 48}
!32 = !{!25, !11, i64 40}
!33 = !{!25, !11, i64 56}
!34 = !{!25, !6, i64 64}


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

@numsprites = external dso_local local_unnamed_addr global i32, align 4
@sprites = external dso_local local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [47 x i8], align 1
@spriteoffset = external local_unnamed_addr global ptr, align 8
@centerxfrac = external local_unnamed_addr global i32, align 4
@viewwidth = external local_unnamed_addr global i32, align 4
@spritewidth = external local_unnamed_addr global ptr, align 8
@spritetopoffset = external local_unnamed_addr global ptr, align 8
@fixedcolormap = external local_unnamed_addr global ptr, align 8
@colormaps = external local_unnamed_addr global ptr, align 8
@spritelights = external dso_local local_unnamed_addr global ptr, align 8
@pspritescale = external dso_local local_unnamed_addr global i32, align 4
@pspriteiscale = external dso_local local_unnamed_addr global i32, align 4
@viewplayer = external local_unnamed_addr global ptr, align 8

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

; Function Attrs: noreturn
declare void @I_Error(ptr noundef, ...) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @R_DrawVisSprite(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @FixedMul(i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @R_DrawPSprite(ptr nocapture noundef readonly %0) local_unnamed_addr #2 {
  %2 = alloca %struct.vissprite_s, align 8
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %2) #5
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = load i32, ptr %3, align 8, !tbaa !11
  %5 = load i32, ptr @numsprites, align 4, !tbaa !14
  %.not = icmp ult i32 %4, %5
  br i1 %.not, label %7, label %6

6:                                                ; preds = %1
  tail call void (ptr, ...) @I_Error(ptr noundef nonnull @.str.7, i32 noundef %4) #6
  unreachable

7:                                                ; preds = %1
  %8 = load ptr, ptr @sprites, align 8, !tbaa !15
  %9 = zext i32 %4 to i64
  %10 = getelementptr inbounds %struct.spritedef_t, ptr %8, i64 %9
  %11 = getelementptr inbounds i8, ptr %3, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !16
  %13 = and i64 %12, 32767
  %14 = load i32, ptr %10, align 8, !tbaa !17
  %15 = sext i32 %14 to i64
  %.not58 = icmp slt i64 %13, %15
  br i1 %.not58, label %17, label %16

16:                                               ; preds = %7
  tail call void (ptr, ...) @I_Error(ptr noundef nonnull @.str.8, i32 noundef %4, i64 noundef %12) #6
  unreachable

17:                                               ; preds = %7
  %18 = getelementptr inbounds i8, ptr %10, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %20 = getelementptr inbounds %struct.spriteframe_t, ptr %19, i64 %13
  %21 = getelementptr inbounds i8, ptr %20, i64 4
  %22 = load i16, ptr %21, align 4, !tbaa !20
  %23 = sext i16 %22 to i32
  %24 = getelementptr inbounds i8, ptr %20, i64 20
  %25 = load i8, ptr %24, align 4, !tbaa !22
  %26 = getelementptr inbounds i8, ptr %0, i64 12
  %27 = load i32, ptr %26, align 4, !tbaa !23
  %28 = add nsw i32 %27, -10485760
  %29 = load ptr, ptr @spriteoffset, align 8, !tbaa !15
  %30 = sext i16 %22 to i64
  %31 = getelementptr inbounds i32, ptr %29, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !14
  %33 = sub i32 %28, %32
  %34 = load i32, ptr @centerxfrac, align 4, !tbaa !14
  %35 = load i32, ptr @pspritescale, align 4, !tbaa !14
  %36 = tail call i32 @FixedMul(i32 noundef %33, i32 noundef %35)
  %37 = add nsw i32 %36, %34
  %38 = ashr i32 %37, 16
  %39 = load i32, ptr @viewwidth, align 4, !tbaa !14
  %40 = icmp sgt i32 %38, %39
  br i1 %40, label %103, label %41

41:                                               ; preds = %17
  %42 = load ptr, ptr @spritewidth, align 8, !tbaa !15
  %43 = getelementptr inbounds i32, ptr %42, i64 %30
  %44 = load i32, ptr %43, align 4, !tbaa !14
  %45 = add nsw i32 %44, %33
  %46 = load i32, ptr @centerxfrac, align 4, !tbaa !14
  %47 = load i32, ptr @pspritescale, align 4, !tbaa !14
  %48 = tail call i32 @FixedMul(i32 noundef %45, i32 noundef %47)
  %49 = add nsw i32 %48, %46
  %50 = ashr i32 %49, 16
  %51 = icmp slt i32 %50, 1
  br i1 %51, label %103, label %52

52:                                               ; preds = %41
  %53 = getelementptr inbounds i8, ptr %2, i64 72
  store i32 0, ptr %53, align 8, !tbaa !24
  %54 = getelementptr inbounds i8, ptr %0, i64 16
  %55 = load i32, ptr %54, align 8, !tbaa !26
  %56 = load ptr, ptr @spritetopoffset, align 8, !tbaa !15
  %57 = getelementptr inbounds i32, ptr %56, i64 %30
  %58 = load i32, ptr %57, align 4, !tbaa !14
  %reass.sub = sub i32 %58, %55
  %59 = add i32 %reass.sub, 6586368
  %60 = getelementptr inbounds i8, ptr %2, i64 52
  store i32 %59, ptr %60, align 4, !tbaa !27
  %61 = tail call i32 @llvm.smax.i32(i32 %38, i32 0)
  %62 = getelementptr inbounds i8, ptr %2, i64 16
  store i32 %61, ptr %62, align 8, !tbaa !28
  %63 = load i32, ptr @viewwidth, align 4
  %.v = tail call i32 @llvm.smin.i32(i32 %50, i32 %63)
  %64 = add nsw i32 %.v, -1
  %65 = getelementptr inbounds i8, ptr %2, i64 20
  store i32 %64, ptr %65, align 4, !tbaa !29
  %66 = load i32, ptr @pspritescale, align 4, !tbaa !14
  %67 = getelementptr inbounds i8, ptr %2, i64 44
  store i32 %66, ptr %67, align 4, !tbaa !30
  %.not60 = icmp eq i8 %25, 0
  %68 = load i32, ptr @pspriteiscale, align 4, !tbaa !14
  br i1 %.not60, label %76, label %69

69:                                               ; preds = %52
  %70 = sub nsw i32 0, %68
  %71 = getelementptr inbounds i8, ptr %2, i64 48
  store i32 %70, ptr %71, align 8, !tbaa !31
  %72 = load ptr, ptr @spritewidth, align 8, !tbaa !15
  %73 = getelementptr inbounds i32, ptr %72, i64 %30
  %74 = load i32, ptr %73, align 4, !tbaa !14
  %75 = add nsw i32 %74, -1
  br label %78

76:                                               ; preds = %52
  %77 = getelementptr inbounds i8, ptr %2, i64 48
  store i32 %68, ptr %77, align 8, !tbaa !31
  br label %78

78:                                               ; preds = %76, %69
  %79 = phi i32 [ %68, %76 ], [ %70, %69 ]
  %80 = phi i32 [ 0, %76 ], [ %75, %69 ]
  %81 = getelementptr inbounds i8, ptr %2, i64 40
  %82 = icmp slt i32 %38, 0
  %83 = sub nsw i32 %61, %38
  %84 = mul nsw i32 %79, %83
  %85 = select i1 %82, i32 %84, i32 0
  %storemerge = add nsw i32 %80, %85
  store i32 %storemerge, ptr %81, align 8
  %86 = getelementptr inbounds i8, ptr %2, i64 56
  store i32 %23, ptr %86, align 8, !tbaa !32
  %87 = load ptr, ptr @viewplayer, align 8, !tbaa !15
  %88 = getelementptr inbounds i8, ptr %87, i64 56
  %89 = load i32, ptr %88, align 8, !tbaa !14
  %90 = icmp slt i32 %89, 129
  %91 = and i32 %89, 8
  %.not61 = icmp eq i32 %91, 0
  %or.cond = and i1 %90, %.not61
  br i1 %or.cond, label %92, label %101

92:                                               ; preds = %78
  %93 = load ptr, ptr @fixedcolormap, align 8, !tbaa !15
  %.not62 = icmp eq ptr %93, null
  br i1 %.not62, label %.sink.split, label %101

.sink.split:                                      ; preds = %92
  %94 = load ptr, ptr %0, align 8, !tbaa !5
  %95 = getelementptr inbounds i8, ptr %94, i64 8
  %96 = load i64, ptr %95, align 8, !tbaa !16
  %97 = and i64 %96, 32768
  %.not63 = icmp eq i64 %97, 0
  %98 = load ptr, ptr @spritelights, align 8
  %99 = getelementptr inbounds i8, ptr %98, i64 376
  %.sink67 = select i1 %.not63, ptr %99, ptr @colormaps
  %100 = load ptr, ptr %.sink67, align 8, !tbaa !15
  br label %101

101:                                              ; preds = %.sink.split, %92, %78
  %.sink = phi ptr [ null, %78 ], [ %93, %92 ], [ %100, %.sink.split ]
  %102 = getelementptr inbounds i8, ptr %2, i64 64
  store ptr %.sink, ptr %102, align 8, !tbaa !33
  call void @R_DrawVisSprite(ptr noundef nonnull %2, i32 noundef %61, i32 noundef %64)
  br label %103

103:                                              ; preds = %41, %17, %101
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %2) #5
  ret void
}

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

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

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


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass