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

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

@mobjinfo = external global [137 x %struct.mobjinfo_t], align 16
@gameskill = external global i32, align 4
@deathmatch = external global i32, align 4
@deathmatch_p = external global ptr, align 8
@deathmatchstarts = external global [10 x %struct.mapthing_t], align 16
@playerstarts = external global [4 x %struct.mapthing_t], align 16
@netgame = external global i32, align 4
@.str = external hidden unnamed_addr constant [45 x i8], align 1
@nomonsters = external global i32, align 4
@totalkills = external global i32, align 4
@totalitems = external global i32, align 4

; 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 i32 @P_Random() #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @P_SpawnPlayer(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @P_SpawnMapThing(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.mapthing_t, ptr %10, i32 0, i32 3
  %12 = load i16, ptr %11, align 2, !tbaa !9
  %13 = sext i16 %12 to i32
  %14 = icmp eq i32 %13, 11
  br i1 %14, label %15, label %24

15:                                               ; preds = %1
  %16 = load ptr, ptr @deathmatch_p, align 8, !tbaa !5
  %17 = icmp ult ptr %16, getelementptr inbounds ([10 x %struct.mapthing_t], ptr @deathmatchstarts, i64 0, i64 10)
  br i1 %17, label %18, label %23

18:                                               ; preds = %15
  %19 = load ptr, ptr @deathmatch_p, align 8, !tbaa !5
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %19, ptr align 2 %20, i64 10, i1 false)
  %21 = load ptr, ptr @deathmatch_p, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.mapthing_t, ptr %21, i32 1
  store ptr %22, ptr @deathmatch_p, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %18, %15
  store i32 1, ptr %9, align 4
  br label %221

24:                                               ; preds = %1
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.mapthing_t, ptr %25, i32 0, i32 3
  %27 = load i16, ptr %26, align 2, !tbaa !9
  %28 = sext i16 %27 to i32
  %29 = icmp sle i32 %28, 4
  br i1 %29, label %30, label %44

30:                                               ; preds = %24
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.mapthing_t, ptr %31, i32 0, i32 3
  %33 = load i16, ptr %32, align 2, !tbaa !9
  %34 = sext i16 %33 to i32
  %35 = sub nsw i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [4 x %struct.mapthing_t], ptr @playerstarts, i64 0, i64 %36
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %37, ptr align 2 %38, i64 10, i1 false), !tbaa.struct !12
  %39 = load i32, ptr @deathmatch, align 4, !tbaa !14
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %43, label %41

41:                                               ; preds = %30
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  call void @P_SpawnPlayer(ptr noundef %42)
  br label %43

43:                                               ; preds = %41, %30
  store i32 1, ptr %9, align 4
  br label %221

44:                                               ; preds = %24
  %45 = load i32, ptr @netgame, align 4, !tbaa !14
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %55, label %47

47:                                               ; preds = %44
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.mapthing_t, ptr %48, i32 0, i32 4
  %50 = load i16, ptr %49, align 2, !tbaa !16
  %51 = sext i16 %50 to i32
  %52 = and i32 %51, 16
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %55

54:                                               ; preds = %47
  store i32 1, ptr %9, align 4
  br label %221

55:                                               ; preds = %47, %44
  %56 = load i32, ptr @gameskill, align 4, !tbaa !14
  %57 = icmp eq i32 %56, 0
  br i1 %57, label %58, label %59

58:                                               ; preds = %55
  store i32 1, ptr %4, align 4, !tbaa !14
  br label %68

59:                                               ; preds = %55
  %60 = load i32, ptr @gameskill, align 4, !tbaa !14
  %61 = icmp eq i32 %60, 4
  br i1 %61, label %62, label %63

62:                                               ; preds = %59
  store i32 4, ptr %4, align 4, !tbaa !14
  br label %67

63:                                               ; preds = %59
  %64 = load i32, ptr @gameskill, align 4, !tbaa !14
  %65 = sub i32 %64, 1
  %66 = shl i32 1, %65
  store i32 %66, ptr %4, align 4, !tbaa !14
  br label %67

67:                                               ; preds = %63, %62
  br label %68

68:                                               ; preds = %67, %58
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.mapthing_t, ptr %69, i32 0, i32 4
  %71 = load i16, ptr %70, align 2, !tbaa !16
  %72 = sext i16 %71 to i32
  %73 = load i32, ptr %4, align 4, !tbaa !14
  %74 = and i32 %72, %73
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %77, label %76

76:                                               ; preds = %68
  store i32 1, ptr %9, align 4
  br label %221

77:                                               ; preds = %68
  store i32 0, ptr %3, align 4, !tbaa !14
  br label %78

78:                                               ; preds = %94, %77
  %79 = load i32, ptr %3, align 4, !tbaa !14
  %80 = icmp slt i32 %79, 137
  br i1 %80, label %81, label %97

81:                                               ; preds = %78
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.mapthing_t, ptr %82, i32 0, i32 3
  %84 = load i16, ptr %83, align 2, !tbaa !9
  %85 = sext i16 %84 to i32
  %86 = load i32, ptr %3, align 4, !tbaa !14
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %87
  %89 = getelementptr inbounds %struct.mobjinfo_t, ptr %88, i32 0, i32 0
  %90 = load i32, ptr %89, align 4, !tbaa !17
  %91 = icmp eq i32 %85, %90
  br i1 %91, label %92, label %93

92:                                               ; preds = %81
  br label %97

93:                                               ; preds = %81
  br label %94

94:                                               ; preds = %93
  %95 = load i32, ptr %3, align 4, !tbaa !14
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %3, align 4, !tbaa !14
  br label %78, !llvm.loop !19

97:                                               ; preds = %92, %78
  %98 = load i32, ptr %3, align 4, !tbaa !14
  %99 = icmp eq i32 %98, 137
  br i1 %99, label %100, label %113

100:                                              ; preds = %97
  %101 = load ptr, ptr %2, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.mapthing_t, ptr %101, i32 0, i32 3
  %103 = load i16, ptr %102, align 2, !tbaa !9
  %104 = sext i16 %103 to i32
  %105 = load ptr, ptr %2, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.mapthing_t, ptr %105, i32 0, i32 0
  %107 = load i16, ptr %106, align 2, !tbaa !21
  %108 = sext i16 %107 to i32
  %109 = load ptr, ptr %2, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.mapthing_t, ptr %109, i32 0, i32 1
  %111 = load i16, ptr %110, align 2, !tbaa !22
  %112 = sext i16 %111 to i32
  call void (ptr, ...) @I_Error(ptr noundef @.str, i32 noundef %104, i32 noundef %108, i32 noundef %112) #6
  unreachable

113:                                              ; preds = %97
  %114 = load i32, ptr @deathmatch, align 4, !tbaa !14
  %115 = icmp ne i32 %114, 0
  br i1 %115, label %116, label %125

116:                                              ; preds = %113
  %117 = load i32, ptr %3, align 4, !tbaa !14
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %118
  %120 = getelementptr inbounds %struct.mobjinfo_t, ptr %119, i32 0, i32 21
  %121 = load i32, ptr %120, align 4, !tbaa !23
  %122 = and i32 %121, 33554432
  %123 = icmp ne i32 %122, 0
  br i1 %123, label %124, label %125

124:                                              ; preds = %116
  store i32 1, ptr %9, align 4
  br label %221

125:                                              ; preds = %116, %113
  %126 = load i32, ptr @nomonsters, align 4, !tbaa !14
  %127 = icmp ne i32 %126, 0
  br i1 %127, label %128, label %140

128:                                              ; preds = %125
  %129 = load i32, ptr %3, align 4, !tbaa !14
  %130 = icmp eq i32 %129, 18
  br i1 %130, label %139, label %131

131:                                              ; preds = %128
  %132 = load i32, ptr %3, align 4, !tbaa !14
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %133
  %135 = getelementptr inbounds %struct.mobjinfo_t, ptr %134, i32 0, i32 21
  %136 = load i32, ptr %135, align 4, !tbaa !23
  %137 = and i32 %136, 4194304
  %138 = icmp ne i32 %137, 0
  br i1 %138, label %139, label %140

139:                                              ; preds = %131, %128
  store i32 1, ptr %9, align 4
  br label %221

140:                                              ; preds = %131, %125
  %141 = load ptr, ptr %2, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.mapthing_t, ptr %141, i32 0, i32 0
  %143 = load i16, ptr %142, align 2, !tbaa !21
  %144 = sext i16 %143 to i32
  %145 = shl i32 %144, 16
  store i32 %145, ptr %6, align 4, !tbaa !14
  %146 = load ptr, ptr %2, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.mapthing_t, ptr %146, i32 0, i32 1
  %148 = load i16, ptr %147, align 2, !tbaa !22
  %149 = sext i16 %148 to i32
  %150 = shl i32 %149, 16
  store i32 %150, ptr %7, align 4, !tbaa !14
  %151 = load i32, ptr %3, align 4, !tbaa !14
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %152
  %154 = getelementptr inbounds %struct.mobjinfo_t, ptr %153, i32 0, i32 21
  %155 = load i32, ptr %154, align 4, !tbaa !23
  %156 = and i32 %155, 256
  %157 = icmp ne i32 %156, 0
  br i1 %157, label %158, label %159

158:                                              ; preds = %140
  store i32 2147483647, ptr %8, align 4, !tbaa !14
  br label %160

159:                                              ; preds = %140
  store i32 -2147483648, ptr %8, align 4, !tbaa !14
  br label %160

160:                                              ; preds = %159, %158
  %161 = load i32, ptr %6, align 4, !tbaa !14
  %162 = load i32, ptr %7, align 4, !tbaa !14
  %163 = load i32, ptr %8, align 4, !tbaa !14
  %164 = load i32, ptr %3, align 4, !tbaa !14
  %165 = call ptr @P_SpawnMobj(i32 noundef %161, i32 noundef %162, i32 noundef %163, i32 noundef %164)
  store ptr %165, ptr %5, align 8, !tbaa !5
  %166 = load ptr, ptr %5, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.mobj_s, ptr %166, i32 0, i32 33
  %168 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %167, ptr align 2 %168, i64 10, i1 false), !tbaa.struct !12
  %169 = load ptr, ptr %5, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.mobj_s, ptr %169, i32 0, i32 22
  %171 = load i32, ptr %170, align 8, !tbaa !24
  %172 = icmp sgt i32 %171, 0
  br i1 %172, label %173, label %182

173:                                              ; preds = %160
  %174 = call i32 @P_Random()
  %175 = load ptr, ptr %5, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.mobj_s, ptr %175, i32 0, i32 22
  %177 = load i32, ptr %176, align 8, !tbaa !24
  %178 = srem i32 %174, %177
  %179 = add nsw i32 1, %178
  %180 = load ptr, ptr %5, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.mobj_s, ptr %180, i32 0, i32 22
  store i32 %179, ptr %181, align 8, !tbaa !24
  br label %182

182:                                              ; preds = %173, %160
  %183 = load ptr, ptr %5, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.mobj_s, ptr %183, i32 0, i32 24
  %185 = load i32, ptr %184, align 8, !tbaa !27
  %186 = and i32 %185, 4194304
  %187 = icmp ne i32 %186, 0
  br i1 %187, label %188, label %191

188:                                              ; preds = %182
  %189 = load i32, ptr @totalkills, align 4, !tbaa !14
  %190 = add nsw i32 %189, 1
  store i32 %190, ptr @totalkills, align 4, !tbaa !14
  br label %191

191:                                              ; preds = %188, %182
  %192 = load ptr, ptr %5, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.mobj_s, ptr %192, i32 0, i32 24
  %194 = load i32, ptr %193, align 8, !tbaa !27
  %195 = and i32 %194, 8388608
  %196 = icmp ne i32 %195, 0
  br i1 %196, label %197, label %200

197:                                              ; preds = %191
  %198 = load i32, ptr @totalitems, align 4, !tbaa !14
  %199 = add nsw i32 %198, 1
  store i32 %199, ptr @totalitems, align 4, !tbaa !14
  br label %200

200:                                              ; preds = %197, %191
  %201 = load ptr, ptr %2, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.mapthing_t, ptr %201, i32 0, i32 2
  %203 = load i16, ptr %202, align 2, !tbaa !28
  %204 = sext i16 %203 to i32
  %205 = sdiv i32 %204, 45
  %206 = mul nsw i32 536870912, %205
  %207 = load ptr, ptr %5, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct.mobj_s, ptr %207, i32 0, i32 6
  store i32 %206, ptr %208, align 8, !tbaa !29
  %209 = load ptr, ptr %2, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct.mapthing_t, ptr %209, i32 0, i32 4
  %211 = load i16, ptr %210, align 2, !tbaa !16
  %212 = sext i16 %211 to i32
  %213 = and i32 %212, 8
  %214 = icmp ne i32 %213, 0
  br i1 %214, label %215, label %220

215:                                              ; preds = %200
  %216 = load ptr, ptr %5, align 8, !tbaa !5
  %217 = getelementptr inbounds %struct.mobj_s, ptr %216, i32 0, i32 24
  %218 = load i32, ptr %217, align 8, !tbaa !27
  %219 = or i32 %218, 32
  store i32 %219, ptr %217, align 8, !tbaa !27
  br label %220

220:                                              ; preds = %215, %200
  store i32 0, ptr %9, align 4
  br label %221

221:                                              ; preds = %220, %139, %124, %76, %54, %43, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  %222 = load i32, ptr %9, align 4
  switch i32 %222, label %224 [
    i32 0, label %223
    i32 1, label %223
  ]

223:                                              ; preds = %221, %221
  ret void

224:                                              ; preds = %221
  unreachable
}

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

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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { 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, !11, i64 6}
!10 = !{!"", !11, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !11, i64 8}
!11 = !{!"short", !7, i64 0}
!12 = !{i64 0, i64 2, !13, i64 2, i64 2, !13, i64 4, i64 2, !13, i64 6, i64 2, !13, i64 8, i64 2, !13}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!10, !11, i64 8}
!17 = !{!18, !15, i64 0}
!18 = !{!"", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16, !15, i64 20, !15, i64 24, !15, i64 28, !15, i64 32, !15, i64 36, !15, i64 40, !15, i64 44, !15, i64 48, !15, i64 52, !15, i64 56, !15, i64 60, !15, i64 64, !15, i64 68, !15, i64 72, !15, i64 76, !15, i64 80, !15, i64 84, !15, i64 88}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!10, !11, i64 0}
!22 = !{!10, !11, i64 2}
!23 = !{!18, !15, i64 84}
!24 = !{!25, !15, i64 144}
!25 = !{!"mobj_s", !26, i64 0, !15, i64 24, !15, i64 28, !15, i64 32, !6, i64 40, !6, i64 48, !15, i64 56, !15, i64 60, !15, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !15, i64 96, !15, i64 100, !15, i64 104, !15, i64 108, !15, i64 112, !15, i64 116, !15, i64 120, !15, i64 124, !15, i64 128, !6, i64 136, !15, i64 144, !6, i64 152, !15, i64 160, !15, i64 164, !15, i64 168, !15, i64 172, !6, i64 176, !15, i64 184, !15, i64 188, !6, i64 192, !15, i64 200, !10, i64 204, !6, i64 216}
!26 = !{!"thinker_s", !6, i64 0, !6, i64 8, !7, i64 16}
!27 = !{!25, !15, i64 160}
!28 = !{!10, !11, i64 4}
!29 = !{!25, !15, i64 56}


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

@mobjinfo = external local_unnamed_addr global [137 x %struct.mobjinfo_t], align 16
@gameskill = external local_unnamed_addr global i32, align 4
@deathmatch = external local_unnamed_addr global i32, align 4
@deathmatch_p = external local_unnamed_addr global ptr, align 8
@deathmatchstarts = external global [10 x %struct.mapthing_t], align 16
@playerstarts = external local_unnamed_addr global [4 x %struct.mapthing_t], align 16
@netgame = external local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [45 x i8], align 1
@nomonsters = external local_unnamed_addr global i32, align 4
@totalkills = external local_unnamed_addr global i32, align 4
@totalitems = external local_unnamed_addr global i32, align 4

declare i32 @P_Random() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @P_SpawnMobj(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @P_SpawnMapThing(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 6
  %3 = load i16, ptr %2, align 2, !tbaa !5
  %4 = sext i16 %3 to i64
  %5 = icmp eq i16 %3, 11
  br i1 %5, label %6, label %12

6:                                                ; preds = %1
  %7 = load ptr, ptr @deathmatch_p, align 8, !tbaa !10
  %8 = icmp ult ptr %7, getelementptr inbounds (i8, ptr @deathmatchstarts, i64 100)
  br i1 %8, label %9, label %120

9:                                                ; preds = %6
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 2 dereferenceable(10) %7, ptr noundef nonnull align 2 dereferenceable(10) %0, i64 10, i1 false)
  %10 = load ptr, ptr @deathmatch_p, align 8, !tbaa !10
  %11 = getelementptr inbounds i8, ptr %10, i64 10
  store ptr %11, ptr @deathmatch_p, align 8, !tbaa !10
  br label %120

12:                                               ; preds = %1
  %13 = icmp slt i16 %3, 5
  br i1 %13, label %14, label %19

14:                                               ; preds = %12
  %15 = add nsw i64 %4, -1
  %16 = getelementptr inbounds [4 x %struct.mapthing_t], ptr @playerstarts, i64 0, i64 %15
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 2 dereferenceable(10) %16, ptr noundef nonnull align 2 dereferenceable(10) %0, i64 10, i1 false), !tbaa.struct !12
  %17 = load i32, ptr @deathmatch, align 4, !tbaa !14
  %.not52 = icmp eq i32 %17, 0
  br i1 %.not52, label %18, label %120

18:                                               ; preds = %14
  tail call void @P_SpawnPlayer(ptr noundef nonnull %0)
  br label %120

19:                                               ; preds = %12
  %20 = load i32, ptr @netgame, align 4, !tbaa !14
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %21, label %25

21:                                               ; preds = %19
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  %23 = load i16, ptr %22, align 2, !tbaa !16
  %24 = and i16 %23, 16
  %.not42 = icmp eq i16 %24, 0
  br i1 %.not42, label %25, label %120

25:                                               ; preds = %21, %19
  %26 = load i32, ptr @gameskill, align 4, !tbaa !14
  switch i32 %26, label %28 [
    i32 0, label %31
    i32 4, label %27
  ]

27:                                               ; preds = %25
  br label %31

28:                                               ; preds = %25
  %29 = add i32 %26, -1
  %30 = shl nuw i32 1, %29
  br label %31

31:                                               ; preds = %25, %27, %28
  %.038 = phi i32 [ 4, %27 ], [ %30, %28 ], [ 1, %25 ]
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load i16, ptr %32, align 2, !tbaa !16
  %34 = sext i16 %33 to i32
  %35 = and i32 %.038, %34
  %.not43 = icmp eq i32 %35, 0
  br i1 %.not43, label %120, label %.preheader

.preheader:                                       ; preds = %31
  %36 = zext nneg i16 %3 to i32
  br label %37

37:                                               ; preds = %54, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next.3, %54 ]
  %38 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %indvars.iv
  %39 = load i32, ptr %38, align 16, !tbaa !17
  %40 = icmp eq i32 %39, %36
  br i1 %40, label %.thread, label %41

41:                                               ; preds = %37
  %exitcond.not = icmp eq i64 %indvars.iv, 136
  br i1 %exitcond.not, label %55, label %42, !llvm.loop !19

42:                                               ; preds = %41
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %43 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %indvars.iv.next
  %44 = load i32, ptr %43, align 4, !tbaa !17
  %45 = icmp eq i32 %44, %36
  br i1 %45, label %.thread, label %46

46:                                               ; preds = %42
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %47 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %indvars.iv.next.1
  %48 = load i32, ptr %47, align 8, !tbaa !17
  %49 = icmp eq i32 %48, %36
  br i1 %49, label %.thread, label %50

50:                                               ; preds = %46
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %51 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %indvars.iv.next.2
  %52 = load i32, ptr %51, align 4, !tbaa !17
  %53 = icmp eq i32 %52, %36
  br i1 %53, label %.thread, label %54

54:                                               ; preds = %50
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  br label %37

55:                                               ; preds = %41
  %56 = load i16, ptr %0, align 2, !tbaa !21
  %57 = sext i16 %56 to i32
  %58 = getelementptr inbounds i8, ptr %0, i64 2
  %59 = load i16, ptr %58, align 2, !tbaa !22
  %60 = sext i16 %59 to i32
  tail call void (ptr, ...) @I_Error(ptr noundef nonnull @.str, i32 noundef %36, i32 noundef %57, i32 noundef %60) #4
  unreachable

.thread:                                          ; preds = %50, %46, %42, %37
  %indvars.iv.lcssa = phi i64 [ %indvars.iv, %37 ], [ %indvars.iv.next, %42 ], [ %indvars.iv.next.1, %46 ], [ %indvars.iv.next.2, %50 ]
  %61 = trunc nuw nsw i64 %indvars.iv.lcssa to i32
  %62 = load i32, ptr @deathmatch, align 4, !tbaa !14
  %.not44 = icmp eq i32 %62, 0
  br i1 %.not44, label %68, label %63

63:                                               ; preds = %.thread
  %64 = and i64 %indvars.iv.lcssa, 4294967295
  %65 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %64, i32 21
  %66 = load i32, ptr %65, align 4, !tbaa !23
  %67 = and i32 %66, 33554432
  %.not45 = icmp eq i32 %67, 0
  br i1 %.not45, label %68, label %120

68:                                               ; preds = %63, %.thread
  %69 = load i32, ptr @nomonsters, align 4, !tbaa !14
  %.not46 = icmp eq i32 %69, 0
  br i1 %.not46, label %._crit_edge, label %70

._crit_edge:                                      ; preds = %68
  %.phi.trans.insert = and i64 %indvars.iv.lcssa, 4294967295
  %.phi.trans.insert58 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %.phi.trans.insert, i32 21
  %.pre = load i32, ptr %.phi.trans.insert58, align 4, !tbaa !23
  br label %77

70:                                               ; preds = %68
  %71 = icmp eq i64 %indvars.iv.lcssa, 18
  br i1 %71, label %120, label %72

72:                                               ; preds = %70
  %73 = and i64 %indvars.iv.lcssa, 4294967295
  %74 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %73, i32 21
  %75 = load i32, ptr %74, align 4, !tbaa !23
  %76 = and i32 %75, 4194304
  %.not47 = icmp eq i32 %76, 0
  br i1 %.not47, label %77, label %120

77:                                               ; preds = %._crit_edge, %72
  %78 = phi i32 [ %.pre, %._crit_edge ], [ %75, %72 ]
  %79 = load i16, ptr %0, align 2, !tbaa !21
  %80 = sext i16 %79 to i32
  %81 = shl nsw i32 %80, 16
  %82 = getelementptr inbounds i8, ptr %0, i64 2
  %83 = load i16, ptr %82, align 2, !tbaa !22
  %84 = sext i16 %83 to i32
  %85 = shl nsw i32 %84, 16
  %86 = and i32 %78, 256
  %.not48 = icmp eq i32 %86, 0
  %. = select i1 %.not48, i32 -2147483648, i32 2147483647
  %87 = tail call ptr @P_SpawnMobj(i32 noundef %81, i32 noundef %85, i32 noundef %., i32 noundef %61)
  %88 = getelementptr inbounds i8, ptr %87, i64 204
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(10) %88, ptr noundef nonnull align 2 dereferenceable(10) %0, i64 10, i1 false), !tbaa.struct !12
  %89 = getelementptr inbounds i8, ptr %87, i64 144
  %90 = load i32, ptr %89, align 8, !tbaa !24
  %91 = icmp sgt i32 %90, 0
  br i1 %91, label %92, label %97

92:                                               ; preds = %77
  %93 = tail call i32 @P_Random() #5
  %94 = load i32, ptr %89, align 8, !tbaa !24
  %95 = srem i32 %93, %94
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %89, align 8, !tbaa !24
  br label %97

97:                                               ; preds = %92, %77
  %98 = getelementptr inbounds i8, ptr %87, i64 160
  %99 = load i32, ptr %98, align 8, !tbaa !27
  %100 = and i32 %99, 4194304
  %.not49 = icmp eq i32 %100, 0
  br i1 %.not49, label %104, label %101

101:                                              ; preds = %97
  %102 = load i32, ptr @totalkills, align 4, !tbaa !14
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr @totalkills, align 4, !tbaa !14
  br label %104

104:                                              ; preds = %101, %97
  %105 = and i32 %99, 8388608
  %.not50 = icmp eq i32 %105, 0
  br i1 %.not50, label %109, label %106

106:                                              ; preds = %104
  %107 = load i32, ptr @totalitems, align 4, !tbaa !14
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr @totalitems, align 4, !tbaa !14
  br label %109

109:                                              ; preds = %106, %104
  %110 = getelementptr inbounds i8, ptr %0, i64 4
  %111 = load i16, ptr %110, align 2, !tbaa !28
  %112 = sdiv i16 %111, 45
  %113 = sext i16 %112 to i32
  %114 = shl nsw i32 %113, 29
  %115 = getelementptr inbounds i8, ptr %87, i64 56
  store i32 %114, ptr %115, align 8, !tbaa !29
  %116 = load i16, ptr %32, align 2, !tbaa !16
  %117 = and i16 %116, 8
  %.not51 = icmp eq i16 %117, 0
  br i1 %.not51, label %120, label %118

118:                                              ; preds = %109
  %119 = or i32 %99, 32
  store i32 %119, ptr %98, align 8, !tbaa !27
  br label %120

120:                                              ; preds = %109, %118, %70, %72, %63, %31, %21, %14, %18, %6, %9
  ret void
}

; Function Attrs: noreturn
declare void @I_Error(ptr 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 = { 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { noreturn nounwind }
attributes #5 = { 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 6}
!6 = !{!"", !7, i64 0, !7, i64 2, !7, i64 4, !7, i64 6, !7, i64 8}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{i64 0, i64 2, !13, i64 2, i64 2, !13, i64 4, i64 2, !13, i64 6, i64 2, !13, i64 8, i64 2, !13}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !8, i64 0}
!16 = !{!6, !7, i64 8}
!17 = !{!18, !15, i64 0}
!18 = !{!"", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16, !15, i64 20, !15, i64 24, !15, i64 28, !15, i64 32, !15, i64 36, !15, i64 40, !15, i64 44, !15, i64 48, !15, i64 52, !15, i64 56, !15, i64 60, !15, i64 64, !15, i64 68, !15, i64 72, !15, i64 76, !15, i64 80, !15, i64 84, !15, i64 88}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!6, !7, i64 0}
!22 = !{!6, !7, i64 2}
!23 = !{!18, !15, i64 84}
!24 = !{!25, !15, i64 144}
!25 = !{!"mobj_s", !26, i64 0, !15, i64 24, !15, i64 28, !15, i64 32, !11, i64 40, !11, i64 48, !15, i64 56, !15, i64 60, !15, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !15, i64 96, !15, i64 100, !15, i64 104, !15, i64 108, !15, i64 112, !15, i64 116, !15, i64 120, !15, i64 124, !15, i64 128, !11, i64 136, !15, i64 144, !11, i64 152, !15, i64 160, !15, i64 164, !15, i64 168, !15, i64 172, !11, i64 176, !15, i64 184, !15, i64 188, !11, i64 192, !15, i64 200, !6, i64 204, !11, i64 216}
!26 = !{!"thinker_s", !11, i64 0, !11, i64 8, !8, i64 16}
!27 = !{!25, !15, i64 160}
!28 = !{!6, !7, i64 4}
!29 = !{!25, !15, i64 56}


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