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

@maxframe = external dso_local global i32, align 4
@sprtemp = external dso_local global [29 x %struct.spriteframe_t], align 16
@spritename = external dso_local global ptr, align 8
@firstspritelump = external global i32, align 4
@numsprites = external dso_local global i32, align 4
@sprites = external dso_local global ptr, align 8
@lastspritelump = external global i32, align 4
@lumpinfo = external global ptr, align 8
@modifiedgame = external global i32, align 4
@.str.4 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [55 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @R_InitSpriteDefs(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, 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 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 138, ptr @numsprites, align 4, !tbaa !9
  %11 = load i32, ptr @numsprites, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = mul i64 %12, 16
  %14 = trunc i64 %13 to i32
  %15 = call ptr @Z_Malloc(i32 noundef %14, i32 noundef 1, ptr noundef null)
  store ptr %15, ptr @sprites, align 8, !tbaa !5
  %16 = load i32, ptr @firstspritelump, align 4, !tbaa !9
  %17 = sub nsw i32 %16, 1
  store i32 %17, ptr %8, align 4, !tbaa !9
  %18 = load i32, ptr @lastspritelump, align 4, !tbaa !9
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %9, align 4, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %210, %1
  %21 = load i32, ptr %3, align 4, !tbaa !9
  %22 = load i32, ptr @numsprites, align 4, !tbaa !9
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %213

24:                                               ; preds = %20
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = load i32, ptr %3, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds ptr, ptr %25, i64 %27
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  store ptr %29, ptr @spritename, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @sprtemp, i8 -1, i64 812, i1 false)
  store i32 -1, ptr @maxframe, align 4, !tbaa !9
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds ptr, ptr %30, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = call i32 @R_GetIntName(ptr noundef %34)
  store i32 %35, ptr %5, align 4, !tbaa !9
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %4, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %119, %24
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %42, label %122

42:                                               ; preds = %38
  %43 = load ptr, ptr @lumpinfo, align 8, !tbaa !5
  %44 = load i32, ptr %4, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds %struct.lumpinfo_t, ptr %43, i64 %45
  %47 = getelementptr inbounds %struct.lumpinfo_t, ptr %46, i32 0, i32 0
  %48 = getelementptr inbounds [8 x i8], ptr %47, i64 0, i64 0
  %49 = call i32 @R_GetIntName(ptr noundef %48)
  %50 = load i32, ptr %5, align 4, !tbaa !9
  %51 = icmp eq i32 %49, %50
  br i1 %51, label %52, label %118

52:                                               ; preds = %42
  %53 = load ptr, ptr @lumpinfo, align 8, !tbaa !5
  %54 = load i32, ptr %4, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds %struct.lumpinfo_t, ptr %53, i64 %55
  %57 = getelementptr inbounds %struct.lumpinfo_t, ptr %56, i32 0, i32 0
  %58 = getelementptr inbounds [8 x i8], ptr %57, i64 0, i64 4
  %59 = load i8, ptr %58, align 4, !tbaa !11
  %60 = sext i8 %59 to i32
  %61 = sub nsw i32 %60, 65
  store i32 %61, ptr %6, align 4, !tbaa !9
  %62 = load ptr, ptr @lumpinfo, align 8, !tbaa !5
  %63 = load i32, ptr %4, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds %struct.lumpinfo_t, ptr %62, i64 %64
  %66 = getelementptr inbounds %struct.lumpinfo_t, ptr %65, i32 0, i32 0
  %67 = getelementptr inbounds [8 x i8], ptr %66, i64 0, i64 5
  %68 = load i8, ptr %67, align 1, !tbaa !11
  %69 = sext i8 %68 to i32
  %70 = sub nsw i32 %69, 48
  store i32 %70, ptr %7, align 4, !tbaa !9
  %71 = load i32, ptr @modifiedgame, align 4, !tbaa !9
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %81

73:                                               ; preds = %52
  %74 = load ptr, ptr @lumpinfo, align 8, !tbaa !5
  %75 = load i32, ptr %4, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds %struct.lumpinfo_t, ptr %74, i64 %76
  %78 = getelementptr inbounds %struct.lumpinfo_t, ptr %77, i32 0, i32 0
  %79 = getelementptr inbounds [8 x i8], ptr %78, i64 0, i64 0
  %80 = call i32 @W_GetNumForName(ptr noundef %79)
  store i32 %80, ptr %10, align 4, !tbaa !9
  br label %83

81:                                               ; preds = %52
  %82 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %82, ptr %10, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %81, %73
  %84 = load i32, ptr %10, align 4, !tbaa !9
  %85 = load i32, ptr %6, align 4, !tbaa !9
  %86 = load i32, ptr %7, align 4, !tbaa !9
  call void @R_InstallSpriteLump(i32 noundef %84, i32 noundef %85, i32 noundef %86, i32 noundef 0)
  %87 = load ptr, ptr @lumpinfo, align 8, !tbaa !5
  %88 = load i32, ptr %4, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds %struct.lumpinfo_t, ptr %87, i64 %89
  %91 = getelementptr inbounds %struct.lumpinfo_t, ptr %90, i32 0, i32 0
  %92 = getelementptr inbounds [8 x i8], ptr %91, i64 0, i64 6
  %93 = load i8, ptr %92, align 2, !tbaa !11
  %94 = icmp ne i8 %93, 0
  br i1 %94, label %95, label %117

95:                                               ; preds = %83
  %96 = load ptr, ptr @lumpinfo, align 8, !tbaa !5
  %97 = load i32, ptr %4, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds %struct.lumpinfo_t, ptr %96, i64 %98
  %100 = getelementptr inbounds %struct.lumpinfo_t, ptr %99, i32 0, i32 0
  %101 = getelementptr inbounds [8 x i8], ptr %100, i64 0, i64 6
  %102 = load i8, ptr %101, align 2, !tbaa !11
  %103 = sext i8 %102 to i32
  %104 = sub nsw i32 %103, 65
  store i32 %104, ptr %6, align 4, !tbaa !9
  %105 = load ptr, ptr @lumpinfo, align 8, !tbaa !5
  %106 = load i32, ptr %4, align 4, !tbaa !9
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds %struct.lumpinfo_t, ptr %105, i64 %107
  %109 = getelementptr inbounds %struct.lumpinfo_t, ptr %108, i32 0, i32 0
  %110 = getelementptr inbounds [8 x i8], ptr %109, i64 0, i64 7
  %111 = load i8, ptr %110, align 1, !tbaa !11
  %112 = sext i8 %111 to i32
  %113 = sub nsw i32 %112, 48
  store i32 %113, ptr %7, align 4, !tbaa !9
  %114 = load i32, ptr %4, align 4, !tbaa !9
  %115 = load i32, ptr %6, align 4, !tbaa !9
  %116 = load i32, ptr %7, align 4, !tbaa !9
  call void @R_InstallSpriteLump(i32 noundef %114, i32 noundef %115, i32 noundef %116, i32 noundef 1)
  br label %117

117:                                              ; preds = %95, %83
  br label %118

118:                                              ; preds = %117, %42
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %4, align 4, !tbaa !9
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %4, align 4, !tbaa !9
  br label %38, !llvm.loop !12

122:                                              ; preds = %38
  %123 = load i32, ptr @maxframe, align 4, !tbaa !9
  %124 = icmp eq i32 %123, -1
  br i1 %124, label %125, label %131

125:                                              ; preds = %122
  %126 = load ptr, ptr @sprites, align 8, !tbaa !5
  %127 = load i32, ptr %3, align 4, !tbaa !9
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds %struct.spritedef_t, ptr %126, i64 %128
  %130 = getelementptr inbounds %struct.spritedef_t, ptr %129, i32 0, i32 0
  store i32 0, ptr %130, align 8, !tbaa !14
  br label %210

131:                                              ; preds = %122
  %132 = load i32, ptr @maxframe, align 4, !tbaa !9
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr @maxframe, align 4, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %134

134:                                              ; preds = %181, %131
  %135 = load i32, ptr %6, align 4, !tbaa !9
  %136 = load i32, ptr @maxframe, align 4, !tbaa !9
  %137 = icmp slt i32 %135, %136
  br i1 %137, label %138, label %184

138:                                              ; preds = %134
  %139 = load i32, ptr %6, align 4, !tbaa !9
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [29 x %struct.spriteframe_t], ptr @sprtemp, i64 0, i64 %140
  %142 = getelementptr inbounds %struct.spriteframe_t, ptr %141, i32 0, i32 0
  %143 = load i32, ptr %142, align 4, !tbaa !16
  switch i32 %143, label %180 [
    i32 -1, label %144
    i32 0, label %180
    i32 1, label %152
  ]

144:                                              ; preds = %138
  %145 = load ptr, ptr %2, align 8, !tbaa !5
  %146 = load i32, ptr %3, align 4, !tbaa !9
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds ptr, ptr %145, i64 %147
  %149 = load ptr, ptr %148, align 8, !tbaa !5
  %150 = load i32, ptr %6, align 4, !tbaa !9
  %151 = add nsw i32 %150, 65
  call void (ptr, ...) @I_Error(ptr noundef @.str.4, ptr noundef %149, i32 noundef %151) #7
  unreachable

152:                                              ; preds = %138
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %153

153:                                              ; preds = %176, %152
  %154 = load i32, ptr %7, align 4, !tbaa !9
  %155 = icmp slt i32 %154, 8
  br i1 %155, label %156, label %179

156:                                              ; preds = %153
  %157 = load i32, ptr %6, align 4, !tbaa !9
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [29 x %struct.spriteframe_t], ptr @sprtemp, i64 0, i64 %158
  %160 = getelementptr inbounds %struct.spriteframe_t, ptr %159, i32 0, i32 1
  %161 = load i32, ptr %7, align 4, !tbaa !9
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [8 x i16], ptr %160, i64 0, i64 %162
  %164 = load i16, ptr %163, align 2, !tbaa !18
  %165 = sext i16 %164 to i32
  %166 = icmp eq i32 %165, -1
  br i1 %166, label %167, label %175

167:                                              ; preds = %156
  %168 = load ptr, ptr %2, align 8, !tbaa !5
  %169 = load i32, ptr %3, align 4, !tbaa !9
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds ptr, ptr %168, i64 %170
  %172 = load ptr, ptr %171, align 8, !tbaa !5
  %173 = load i32, ptr %6, align 4, !tbaa !9
  %174 = add nsw i32 %173, 65
  call void (ptr, ...) @I_Error(ptr noundef @.str.5, ptr noundef %172, i32 noundef %174) #7
  unreachable

175:                                              ; preds = %156
  br label %176

176:                                              ; preds = %175
  %177 = load i32, ptr %7, align 4, !tbaa !9
  %178 = add nsw i32 %177, 1
  store i32 %178, ptr %7, align 4, !tbaa !9
  br label %153, !llvm.loop !20

179:                                              ; preds = %153
  br label %180

180:                                              ; preds = %179, %138, %138
  br label %181

181:                                              ; preds = %180
  %182 = load i32, ptr %6, align 4, !tbaa !9
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr %6, align 4, !tbaa !9
  br label %134, !llvm.loop !21

184:                                              ; preds = %134
  %185 = load i32, ptr @maxframe, align 4, !tbaa !9
  %186 = load ptr, ptr @sprites, align 8, !tbaa !5
  %187 = load i32, ptr %3, align 4, !tbaa !9
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds %struct.spritedef_t, ptr %186, i64 %188
  %190 = getelementptr inbounds %struct.spritedef_t, ptr %189, i32 0, i32 0
  store i32 %185, ptr %190, align 8, !tbaa !14
  %191 = load i32, ptr @maxframe, align 4, !tbaa !9
  %192 = sext i32 %191 to i64
  %193 = mul i64 %192, 28
  %194 = trunc i64 %193 to i32
  %195 = call ptr @Z_Malloc(i32 noundef %194, i32 noundef 1, ptr noundef null)
  %196 = load ptr, ptr @sprites, align 8, !tbaa !5
  %197 = load i32, ptr %3, align 4, !tbaa !9
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds %struct.spritedef_t, ptr %196, i64 %198
  %200 = getelementptr inbounds %struct.spritedef_t, ptr %199, i32 0, i32 1
  store ptr %195, ptr %200, align 8, !tbaa !22
  %201 = load ptr, ptr @sprites, align 8, !tbaa !5
  %202 = load i32, ptr %3, align 4, !tbaa !9
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds %struct.spritedef_t, ptr %201, i64 %203
  %205 = getelementptr inbounds %struct.spritedef_t, ptr %204, i32 0, i32 1
  %206 = load ptr, ptr %205, align 8, !tbaa !22
  %207 = load i32, ptr @maxframe, align 4, !tbaa !9
  %208 = sext i32 %207 to i64
  %209 = mul i64 %208, 28
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %206, ptr align 16 @sprtemp, i64 %209, i1 false)
  br label %210

210:                                              ; preds = %184, %125
  %211 = load i32, ptr %3, align 4, !tbaa !9
  %212 = add nsw i32 %211, 1
  store i32 %212, ptr %3, align 4, !tbaa !9
  br label %20, !llvm.loop !23

213:                                              ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, 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 4, ptr %3) #6
  ret void
}

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @R_GetIntName(ptr noundef) #0

declare i32 @W_GetNumForName(ptr noundef) #3

; 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) #5

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !10, i64 0}
!15 = !{!"", !10, i64 0, !6, i64 8}
!16 = !{!17, !10, i64 0}
!17 = !{!"", !10, i64 0, !7, i64 4, !7, i64 20}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = distinct !{!20, !13}
!21 = distinct !{!21, !13}
!22 = !{!15, !6, i64 8}
!23 = distinct !{!23, !13}


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

@maxframe = external dso_local local_unnamed_addr global i32, align 4
@sprtemp = external dso_local local_unnamed_addr global [29 x %struct.spriteframe_t], align 16
@spritename = external dso_local local_unnamed_addr global ptr, align 8
@firstspritelump = external local_unnamed_addr global i32, align 4
@numsprites = external dso_local local_unnamed_addr global i32, align 4
@sprites = external dso_local local_unnamed_addr global ptr, align 8
@lastspritelump = external local_unnamed_addr global i32, align 4
@lumpinfo = external local_unnamed_addr global ptr, align 8
@modifiedgame = external local_unnamed_addr global i32, align 4
@.str.4 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [55 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @R_InitSpriteDefs(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  store i32 138, ptr @numsprites, align 4, !tbaa !5
  %2 = tail call ptr @Z_Malloc(i32 noundef 2208, i32 noundef 1, ptr noundef null) #5
  store ptr %2, ptr @sprites, align 8, !tbaa !9
  %3 = load i32, ptr @numsprites, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph66, label %._crit_edge67

.lr.ph66:                                         ; preds = %1
  %5 = load i32, ptr @lastspritelump, align 4, !tbaa !5
  %6 = load i32, ptr @firstspritelump, align 4, !tbaa !5
  %.not54 = icmp sgt i32 %6, %5
  %7 = sext i32 %6 to i64
  %8 = add i32 %5, 1
  br label %9

9:                                                ; preds = %.lr.ph66, %109
  %indvars.iv81 = phi i64 [ 0, %.lr.ph66 ], [ %indvars.iv.next82, %109 ]
  %10 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv81
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr @spritename, align 8, !tbaa !9
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(812) @sprtemp, i8 -1, i64 812, i1 false)
  store i32 -1, ptr @maxframe, align 4, !tbaa !5
  %12 = load ptr, ptr %10, align 8, !tbaa !9
  %13 = tail call i32 @R_GetIntName(ptr noundef %12)
  br i1 %.not54, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9, %45
  %indvars.iv = phi i64 [ %indvars.iv.next, %45 ], [ %7, %9 ]
  %14 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.lumpinfo_t, ptr %14, i64 %indvars.iv
  %16 = tail call i32 @R_GetIntName(ptr noundef %15)
  %17 = icmp eq i32 %16, %13
  br i1 %17, label %18, label %45

18:                                               ; preds = %.lr.ph
  %19 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.lumpinfo_t, ptr %19, i64 %indvars.iv
  %21 = getelementptr inbounds i8, ptr %20, i64 4
  %22 = load i8, ptr %21, align 4, !tbaa !11
  %23 = sext i8 %22 to i32
  %24 = add nsw i32 %23, -65
  %25 = getelementptr inbounds i8, ptr %20, i64 5
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = sext i8 %26 to i32
  %28 = add nsw i32 %27, -48
  %29 = load i32, ptr @modifiedgame, align 4, !tbaa !5
  %.not48 = icmp eq i32 %29, 0
  %30 = trunc nsw i64 %indvars.iv to i32
  br i1 %.not48, label %33, label %31

31:                                               ; preds = %18
  %32 = tail call i32 @W_GetNumForName(ptr noundef nonnull %20) #5
  br label %33

33:                                               ; preds = %18, %31
  %.0 = phi i32 [ %32, %31 ], [ %30, %18 ]
  tail call void @R_InstallSpriteLump(i32 noundef %.0, i32 noundef %24, i32 noundef %28, i32 noundef 0)
  %34 = load ptr, ptr @lumpinfo, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.lumpinfo_t, ptr %34, i64 %indvars.iv
  %36 = getelementptr inbounds i8, ptr %35, i64 6
  %37 = load i8, ptr %36, align 2, !tbaa !11
  %.not49 = icmp eq i8 %37, 0
  br i1 %.not49, label %45, label %38

38:                                               ; preds = %33
  %39 = sext i8 %37 to i32
  %40 = add nsw i32 %39, -65
  %41 = getelementptr inbounds i8, ptr %35, i64 7
  %42 = load i8, ptr %41, align 1, !tbaa !11
  %43 = sext i8 %42 to i32
  %44 = add nsw i32 %43, -48
  tail call void @R_InstallSpriteLump(i32 noundef %30, i32 noundef %40, i32 noundef %44, i32 noundef 1)
  br label %45

45:                                               ; preds = %.lr.ph, %38, %33
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %8, %lftr.wideiv
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %45, %9
  %46 = load i32, ptr @maxframe, align 4, !tbaa !5
  %47 = icmp eq i32 %46, -1
  br i1 %47, label %48, label %51

48:                                               ; preds = %._crit_edge
  %49 = load ptr, ptr @sprites, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.spritedef_t, ptr %49, i64 %indvars.iv81
  store i32 0, ptr %50, align 8, !tbaa !14
  br label %109

51:                                               ; preds = %._crit_edge
  %52 = add nuw i32 %46, 1
  store i32 %52, ptr @maxframe, align 4, !tbaa !5
  %.not5057 = icmp slt i32 %46, 0
  br i1 %.not5057, label %._crit_edge61, label %.lr.ph60.preheader

.lr.ph60.preheader:                               ; preds = %51
  %wide.trip.count = zext i32 %52 to i64
  br label %.lr.ph60

.lr.ph60:                                         ; preds = %.lr.ph60.preheader, %.loopexit
  %indvars.iv77 = phi i64 [ 0, %.lr.ph60.preheader ], [ %indvars.iv.next78, %.loopexit ]
  %53 = getelementptr inbounds [29 x %struct.spriteframe_t], ptr @sprtemp, i64 0, i64 %indvars.iv77
  %54 = load i32, ptr %53, align 4, !tbaa !16
  switch i32 %54, label %.loopexit [
    i32 -1, label %58
    i32 1, label %.preheader
  ]

.preheader:                                       ; preds = %.lr.ph60
  %55 = getelementptr inbounds i8, ptr %53, i64 4
  %56 = load i16, ptr %55, align 4, !tbaa !18
  %57 = icmp eq i16 %56, -1
  br i1 %57, label %91, label %63

58:                                               ; preds = %.lr.ph60
  %59 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv81
  %60 = trunc nuw nsw i64 %indvars.iv77 to i32
  %61 = load ptr, ptr %59, align 8, !tbaa !9
  %62 = add nuw nsw i32 %60, 65
  tail call void (ptr, ...) @I_Error(ptr noundef nonnull @.str.4, ptr noundef %61, i32 noundef %62) #6
  unreachable

63:                                               ; preds = %.preheader
  %64 = getelementptr inbounds i8, ptr %53, i64 6
  %65 = load i16, ptr %64, align 2, !tbaa !18
  %66 = icmp eq i16 %65, -1
  br i1 %66, label %91, label %67

67:                                               ; preds = %63
  %68 = getelementptr inbounds i8, ptr %53, i64 8
  %69 = load i16, ptr %68, align 4, !tbaa !18
  %70 = icmp eq i16 %69, -1
  br i1 %70, label %91, label %71

71:                                               ; preds = %67
  %72 = getelementptr inbounds i8, ptr %53, i64 10
  %73 = load i16, ptr %72, align 2, !tbaa !18
  %74 = icmp eq i16 %73, -1
  br i1 %74, label %91, label %75

75:                                               ; preds = %71
  %76 = getelementptr inbounds i8, ptr %53, i64 12
  %77 = load i16, ptr %76, align 4, !tbaa !18
  %78 = icmp eq i16 %77, -1
  br i1 %78, label %91, label %79

79:                                               ; preds = %75
  %80 = getelementptr inbounds i8, ptr %53, i64 14
  %81 = load i16, ptr %80, align 2, !tbaa !18
  %82 = icmp eq i16 %81, -1
  br i1 %82, label %91, label %83

83:                                               ; preds = %79
  %84 = getelementptr inbounds i8, ptr %53, i64 16
  %85 = load i16, ptr %84, align 4, !tbaa !18
  %86 = icmp eq i16 %85, -1
  br i1 %86, label %91, label %87

87:                                               ; preds = %83
  %88 = getelementptr inbounds i8, ptr %53, i64 18
  %89 = load i16, ptr %88, align 2, !tbaa !18
  %90 = icmp eq i16 %89, -1
  br i1 %90, label %91, label %.loopexit

91:                                               ; preds = %87, %83, %79, %75, %71, %67, %63, %.preheader
  %92 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv81
  %93 = trunc nuw nsw i64 %indvars.iv77 to i32
  %94 = load ptr, ptr %92, align 8, !tbaa !9
  %95 = add nuw nsw i32 %93, 65
  tail call void (ptr, ...) @I_Error(ptr noundef nonnull @.str.5, ptr noundef %94, i32 noundef %95) #6
  unreachable

.loopexit:                                        ; preds = %87, %.lr.ph60
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %exitcond80.not = icmp eq i64 %indvars.iv.next78, %wide.trip.count
  br i1 %exitcond80.not, label %._crit_edge61, label %.lr.ph60, !llvm.loop !20

._crit_edge61:                                    ; preds = %.loopexit, %51
  %96 = load ptr, ptr @sprites, align 8, !tbaa !9
  %97 = getelementptr inbounds %struct.spritedef_t, ptr %96, i64 %indvars.iv81
  store i32 %52, ptr %97, align 8, !tbaa !14
  %98 = load i32, ptr @maxframe, align 4, !tbaa !5
  %99 = mul i32 %98, 28
  %100 = tail call ptr @Z_Malloc(i32 noundef %99, i32 noundef 1, ptr noundef null) #5
  %101 = load ptr, ptr @sprites, align 8, !tbaa !9
  %102 = getelementptr inbounds %struct.spritedef_t, ptr %101, i64 %indvars.iv81, i32 1
  store ptr %100, ptr %102, align 8, !tbaa !21
  %103 = load ptr, ptr @sprites, align 8, !tbaa !9
  %104 = getelementptr inbounds %struct.spritedef_t, ptr %103, i64 %indvars.iv81, i32 1
  %105 = load ptr, ptr %104, align 8, !tbaa !21
  %106 = load i32, ptr @maxframe, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = mul nsw i64 %107, 28
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %105, ptr nonnull align 16 @sprtemp, i64 %108, i1 false)
  br label %109

109:                                              ; preds = %._crit_edge61, %48
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %110 = load i32, ptr @numsprites, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = icmp slt i64 %indvars.iv.next82, %111
  br i1 %112, label %9, label %._crit_edge67, !llvm.loop !22

._crit_edge67:                                    ; preds = %109, %1
  ret void
}

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @R_GetIntName(ptr noundef) local_unnamed_addr #0

declare i32 @W_GetNumForName(ptr noundef) local_unnamed_addr #2

; 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) #4

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !6, i64 0}
!15 = !{!"", !6, i64 0, !10, i64 8}
!16 = !{!17, !6, i64 0}
!17 = !{!"", !6, i64 0, !7, i64 4, !7, i64 20}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = distinct !{!20, !13}
!21 = !{!15, !10, i64 8}
!22 = distinct !{!22, !13}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass