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

; 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.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 }
%struct.pspdef_t = type { ptr, i32, i32, i32 }
%struct.wbstartstruct_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x %struct.wbplayerstruct_t] }
%struct.wbplayerstruct_t = type { i32, i32, i32, i32, i32, [4 x i32], i32 }

@consoleplayer = external dso_local global i32, align 4
@gamemode = external global i32, align 4
@gamemap = external dso_local global i32, align 4
@gamestate = external dso_local global i32, align 4
@playeringame = external dso_local global [4 x i32], align 16
@players = external dso_local global [4 x %struct.player_s], align 16
@gameepisode = external dso_local global i32, align 4
@gameaction = external dso_local global i32, align 4
@pars = external dso_local global [4 x [10 x i32]], align 16
@cpars = external dso_local global [32 x i32], align 16
@secretexit = external dso_local global i32, align 4
@automapactive = external global i32, align 4
@wminfo = external dso_local global %struct.wbstartstruct_t, align 4
@totalkills = external dso_local global i32, align 4
@totalitems = external dso_local global i32, align 4
@totalsecret = external dso_local global i32, align 4
@leveltime = external global i32, align 4
@viewactive = external dso_local global i32, align 4
@statcopy = external dso_local global ptr, align 8

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @G_DoCompleted() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 0, ptr @gameaction, align 4, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %15, %0
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = icmp slt i32 %4, 4
  br i1 %5, label %6, label %18

6:                                                ; preds = %3
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [4 x i32], ptr @playeringame, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %12, label %14

12:                                               ; preds = %6
  %13 = load i32, ptr %1, align 4, !tbaa !5
  call void @G_PlayerFinishLevel(i32 noundef %13)
  br label %14

14:                                               ; preds = %12, %6
  br label %15

15:                                               ; preds = %14
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %1, align 4, !tbaa !5
  br label %3, !llvm.loop !9

18:                                               ; preds = %3
  %19 = load i32, ptr @automapactive, align 4, !tbaa !5
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  call void @AM_Stop()
  br label %22

22:                                               ; preds = %21, %18
  %23 = load i32, ptr @gamemode, align 4, !tbaa !5
  %24 = icmp ne i32 %23, 2
  br i1 %24, label %25, label %42

25:                                               ; preds = %22
  %26 = load i32, ptr @gamemap, align 4, !tbaa !5
  switch i32 %26, label %41 [
    i32 8, label %27
    i32 9, label %28
  ]

27:                                               ; preds = %25
  store i32 7, ptr @gameaction, align 4, !tbaa !5
  store i32 1, ptr %2, align 4
  br label %200

28:                                               ; preds = %25
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %37, %28
  %30 = load i32, ptr %1, align 4, !tbaa !5
  %31 = icmp slt i32 %30, 4
  br i1 %31, label %32, label %40

32:                                               ; preds = %29
  %33 = load i32, ptr %1, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %34
  %36 = getelementptr inbounds %struct.player_s, ptr %35, i32 0, i32 34
  store i32 1, ptr %36, align 8, !tbaa !11
  br label %37

37:                                               ; preds = %32
  %38 = load i32, ptr %1, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %1, align 4, !tbaa !5
  br label %29, !llvm.loop !16

40:                                               ; preds = %29
  br label %41

41:                                               ; preds = %40, %25
  br label %42

42:                                               ; preds = %41, %22
  %43 = load i32, ptr @gamemap, align 4, !tbaa !5
  %44 = icmp eq i32 %43, 8
  br i1 %44, label %45, label %49

45:                                               ; preds = %42
  %46 = load i32, ptr @gamemode, align 4, !tbaa !5
  %47 = icmp ne i32 %46, 2
  br i1 %47, label %48, label %49

48:                                               ; preds = %45
  store i32 7, ptr @gameaction, align 4, !tbaa !5
  store i32 1, ptr %2, align 4
  br label %200

49:                                               ; preds = %45, %42
  %50 = load i32, ptr @gamemap, align 4, !tbaa !5
  %51 = icmp eq i32 %50, 9
  br i1 %51, label %52, label %68

52:                                               ; preds = %49
  %53 = load i32, ptr @gamemode, align 4, !tbaa !5
  %54 = icmp ne i32 %53, 2
  br i1 %54, label %55, label %68

55:                                               ; preds = %52
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %64, %55
  %57 = load i32, ptr %1, align 4, !tbaa !5
  %58 = icmp slt i32 %57, 4
  br i1 %58, label %59, label %67

59:                                               ; preds = %56
  %60 = load i32, ptr %1, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %61
  %63 = getelementptr inbounds %struct.player_s, ptr %62, i32 0, i32 34
  store i32 1, ptr %63, align 8, !tbaa !11
  br label %64

64:                                               ; preds = %59
  %65 = load i32, ptr %1, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %1, align 4, !tbaa !5
  br label %56, !llvm.loop !17

67:                                               ; preds = %56
  br label %68

68:                                               ; preds = %67, %52, %49
  %69 = load i32, ptr @consoleplayer, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %70
  %72 = getelementptr inbounds %struct.player_s, ptr %71, i32 0, i32 34
  %73 = load i32, ptr %72, align 8, !tbaa !11
  store i32 %73, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 1), align 4, !tbaa !18
  %74 = load i32, ptr @gameepisode, align 4, !tbaa !5
  %75 = sub nsw i32 %74, 1
  store i32 %75, ptr @wminfo, align 4, !tbaa !20
  %76 = load i32, ptr @gamemap, align 4, !tbaa !5
  %77 = sub nsw i32 %76, 1
  store i32 %77, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 2), align 4, !tbaa !21
  %78 = load i32, ptr @gamemode, align 4, !tbaa !5
  %79 = icmp eq i32 %78, 2
  br i1 %79, label %80, label %95

80:                                               ; preds = %68
  %81 = load i32, ptr @secretexit, align 4, !tbaa !5
  %82 = icmp ne i32 %81, 0
  br i1 %82, label %83, label %88

83:                                               ; preds = %80
  %84 = load i32, ptr @gamemap, align 4, !tbaa !5
  switch i32 %84, label %87 [
    i32 15, label %85
    i32 31, label %86
  ]

85:                                               ; preds = %83
  store i32 30, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 3), align 4, !tbaa !22
  br label %87

86:                                               ; preds = %83
  store i32 31, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 3), align 4, !tbaa !22
  br label %87

87:                                               ; preds = %86, %85, %83
  br label %94

88:                                               ; preds = %80
  %89 = load i32, ptr @gamemap, align 4, !tbaa !5
  switch i32 %89, label %91 [
    i32 31, label %90
    i32 32, label %90
  ]

90:                                               ; preds = %88, %88
  store i32 15, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 3), align 4, !tbaa !22
  br label %93

91:                                               ; preds = %88
  %92 = load i32, ptr @gamemap, align 4, !tbaa !5
  store i32 %92, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 3), align 4, !tbaa !22
  br label %93

93:                                               ; preds = %91, %90
  br label %94

94:                                               ; preds = %93, %87
  br label %113

95:                                               ; preds = %68
  %96 = load i32, ptr @secretexit, align 4, !tbaa !5
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %98, label %99

98:                                               ; preds = %95
  store i32 8, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 3), align 4, !tbaa !22
  br label %112

99:                                               ; preds = %95
  %100 = load i32, ptr @gamemap, align 4, !tbaa !5
  %101 = icmp eq i32 %100, 9
  br i1 %101, label %102, label %109

102:                                              ; preds = %99
  %103 = load i32, ptr @gameepisode, align 4, !tbaa !5
  switch i32 %103, label %108 [
    i32 1, label %104
    i32 2, label %105
    i32 3, label %106
    i32 4, label %107
  ]

104:                                              ; preds = %102
  store i32 3, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 3), align 4, !tbaa !22
  br label %108

105:                                              ; preds = %102
  store i32 5, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 3), align 4, !tbaa !22
  br label %108

106:                                              ; preds = %102
  store i32 6, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 3), align 4, !tbaa !22
  br label %108

107:                                              ; preds = %102
  store i32 2, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 3), align 4, !tbaa !22
  br label %108

108:                                              ; preds = %107, %106, %105, %104, %102
  br label %111

109:                                              ; preds = %99
  %110 = load i32, ptr @gamemap, align 4, !tbaa !5
  store i32 %110, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 3), align 4, !tbaa !22
  br label %111

111:                                              ; preds = %109, %108
  br label %112

112:                                              ; preds = %111, %98
  br label %113

113:                                              ; preds = %112, %94
  %114 = load i32, ptr @totalkills, align 4, !tbaa !5
  store i32 %114, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 4), align 4, !tbaa !23
  %115 = load i32, ptr @totalitems, align 4, !tbaa !5
  store i32 %115, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 5), align 4, !tbaa !24
  %116 = load i32, ptr @totalsecret, align 4, !tbaa !5
  store i32 %116, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 6), align 4, !tbaa !25
  store i32 0, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 7), align 4, !tbaa !26
  %117 = load i32, ptr @gamemode, align 4, !tbaa !5
  %118 = icmp eq i32 %117, 2
  br i1 %118, label %119, label %126

119:                                              ; preds = %113
  %120 = load i32, ptr @gamemap, align 4, !tbaa !5
  %121 = sub nsw i32 %120, 1
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [32 x i32], ptr @cpars, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !5
  %125 = mul nsw i32 35, %124
  store i32 %125, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 8), align 4, !tbaa !27
  br label %135

126:                                              ; preds = %113
  %127 = load i32, ptr @gameepisode, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [4 x [10 x i32]], ptr @pars, i64 0, i64 %128
  %130 = load i32, ptr @gamemap, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [10 x i32], ptr %129, i64 0, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !5
  %134 = mul nsw i32 35, %133
  store i32 %134, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 8), align 4, !tbaa !27
  br label %135

135:                                              ; preds = %126, %119
  %136 = load i32, ptr @consoleplayer, align 4, !tbaa !5
  store i32 %136, ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 9), align 4, !tbaa !28
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %137

137:                                              ; preds = %191, %135
  %138 = load i32, ptr %1, align 4, !tbaa !5
  %139 = icmp slt i32 %138, 4
  br i1 %139, label %140, label %194

140:                                              ; preds = %137
  %141 = load i32, ptr %1, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [4 x i32], ptr @playeringame, i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %145 = load i32, ptr %1, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [4 x %struct.wbplayerstruct_t], ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 10), i64 0, i64 %146
  %148 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %147, i32 0, i32 0
  store i32 %144, ptr %148, align 4, !tbaa !29
  %149 = load i32, ptr %1, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %150
  %152 = getelementptr inbounds %struct.player_s, ptr %151, i32 0, i32 23
  %153 = load i32, ptr %152, align 16, !tbaa !31
  %154 = load i32, ptr %1, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [4 x %struct.wbplayerstruct_t], ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 10), i64 0, i64 %155
  %157 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %156, i32 0, i32 1
  store i32 %153, ptr %157, align 4, !tbaa !32
  %158 = load i32, ptr %1, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %159
  %161 = getelementptr inbounds %struct.player_s, ptr %160, i32 0, i32 24
  %162 = load i32, ptr %161, align 4, !tbaa !33
  %163 = load i32, ptr %1, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [4 x %struct.wbplayerstruct_t], ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 10), i64 0, i64 %164
  %166 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %165, i32 0, i32 2
  store i32 %162, ptr %166, align 4, !tbaa !34
  %167 = load i32, ptr %1, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %168
  %170 = getelementptr inbounds %struct.player_s, ptr %169, i32 0, i32 25
  %171 = load i32, ptr %170, align 8, !tbaa !35
  %172 = load i32, ptr %1, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [4 x %struct.wbplayerstruct_t], ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 10), i64 0, i64 %173
  %175 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %174, i32 0, i32 3
  store i32 %171, ptr %175, align 4, !tbaa !36
  %176 = load i32, ptr @leveltime, align 4, !tbaa !5
  %177 = load i32, ptr %1, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [4 x %struct.wbplayerstruct_t], ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 10), i64 0, i64 %178
  %180 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %179, i32 0, i32 4
  store i32 %176, ptr %180, align 4, !tbaa !37
  %181 = load i32, ptr %1, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [4 x %struct.wbplayerstruct_t], ptr getelementptr inbounds (%struct.wbstartstruct_t, ptr @wminfo, i32 0, i32 10), i64 0, i64 %182
  %184 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %183, i32 0, i32 5
  %185 = getelementptr inbounds [4 x i32], ptr %184, i64 0, i64 0
  %186 = load i32, ptr %1, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %187
  %189 = getelementptr inbounds %struct.player_s, ptr %188, i32 0, i32 13
  %190 = getelementptr inbounds [4 x i32], ptr %189, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %185, ptr align 4 %190, i64 16, i1 false)
  br label %191

191:                                              ; preds = %140
  %192 = load i32, ptr %1, align 4, !tbaa !5
  %193 = add nsw i32 %192, 1
  store i32 %193, ptr %1, align 4, !tbaa !5
  br label %137, !llvm.loop !38

194:                                              ; preds = %137
  store i32 1, ptr @gamestate, align 4, !tbaa !5
  store i32 0, ptr @viewactive, align 4, !tbaa !5
  store i32 0, ptr @automapactive, align 4, !tbaa !5
  %195 = load ptr, ptr @statcopy, align 8, !tbaa !39
  %196 = icmp ne ptr %195, null
  br i1 %196, label %197, label %199

197:                                              ; preds = %194
  %198 = load ptr, ptr @statcopy, align 8, !tbaa !39
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %198, ptr align 4 @wminfo, i64 200, i1 false)
  br label %199

199:                                              ; preds = %197, %194
  call void @WI_Start(ptr noundef @wminfo)
  store i32 0, ptr %2, align 4
  br label %200

200:                                              ; preds = %199, %48, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  %201 = load i32, ptr %2, align 4
  switch i32 %201, label %203 [
    i32 0, label %202
    i32 1, label %202
  ]

202:                                              ; preds = %200, %200
  ret void

203:                                              ; preds = %200
  unreachable
}

; Function Attrs: nounwind uwtable
declare dso_local void @G_PlayerFinishLevel(i32 noundef) #2

declare void @AM_Stop() #3

declare void @WI_Start(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 312}
!12 = !{!"player_s", !13, i64 0, !6, i64 8, !14, i64 12, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !7, i64 48, !7, i64 72, !6, i64 96, !7, i64 100, !6, i64 116, !6, i64 120, !7, i64 124, !7, i64 160, !7, i64 176, !6, i64 192, !6, i64 196, !6, i64 200, !6, i64 204, !6, i64 208, !6, i64 212, !6, i64 216, !13, i64 224, !6, i64 232, !6, i64 236, !13, i64 240, !6, i64 248, !6, i64 252, !6, i64 256, !7, i64 264, !6, i64 312}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!"", !7, i64 0, !7, i64 1, !15, i64 2, !15, i64 4, !7, i64 6, !7, i64 7}
!15 = !{!"short", !7, i64 0}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = !{!19, !6, i64 4}
!19 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !7, i64 40}
!20 = !{!19, !6, i64 0}
!21 = !{!19, !6, i64 8}
!22 = !{!19, !6, i64 12}
!23 = !{!19, !6, i64 16}
!24 = !{!19, !6, i64 20}
!25 = !{!19, !6, i64 24}
!26 = !{!19, !6, i64 28}
!27 = !{!19, !6, i64 32}
!28 = !{!19, !6, i64 36}
!29 = !{!30, !6, i64 0}
!30 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !7, i64 20, !6, i64 36}
!31 = !{!12, !6, i64 208}
!32 = !{!30, !6, i64 4}
!33 = !{!12, !6, i64 212}
!34 = !{!30, !6, i64 8}
!35 = !{!12, !6, i64 216}
!36 = !{!30, !6, i64 12}
!37 = !{!30, !6, i64 16}
!38 = distinct !{!38, !10}
!39 = !{!13, !13, i64 0}


; 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.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 }
%struct.pspdef_t = type { ptr, i32, i32, i32 }
%struct.wbstartstruct_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x %struct.wbplayerstruct_t] }
%struct.wbplayerstruct_t = type { i32, i32, i32, i32, i32, [4 x i32], i32 }

@consoleplayer = external dso_local local_unnamed_addr global i32, align 4
@gamemode = external local_unnamed_addr global i32, align 4
@gamemap = external dso_local local_unnamed_addr global i32, align 4
@gamestate = external dso_local local_unnamed_addr global i32, align 4
@playeringame = external dso_local local_unnamed_addr global [4 x i32], align 16
@players = external dso_local local_unnamed_addr global [4 x %struct.player_s], align 16
@gameepisode = external dso_local local_unnamed_addr global i32, align 4
@gameaction = external dso_local local_unnamed_addr global i32, align 4
@pars = external dso_local local_unnamed_addr global [4 x [10 x i32]], align 16
@cpars = external dso_local local_unnamed_addr global [32 x i32], align 16
@secretexit = external dso_local local_unnamed_addr global i32, align 4
@automapactive = external local_unnamed_addr global i32, align 4
@wminfo = external dso_local global %struct.wbstartstruct_t, align 4
@totalkills = external dso_local local_unnamed_addr global i32, align 4
@totalitems = external dso_local local_unnamed_addr global i32, align 4
@totalsecret = external dso_local local_unnamed_addr global i32, align 4
@leveltime = external local_unnamed_addr global i32, align 4
@viewactive = external dso_local local_unnamed_addr global i32, align 4
@statcopy = external dso_local local_unnamed_addr global ptr, align 8
@switch.table.G_DoCompleted = private unnamed_addr constant [4 x i32] [i32 3, i32 5, i32 6, i32 2], align 4

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

; Function Attrs: nounwind uwtable
define dso_local void @G_DoCompleted() local_unnamed_addr #1 {
  store i32 0, ptr @gameaction, align 4, !tbaa !5
  %1 = load i32, ptr @playeringame, align 16, !tbaa !5
  %.not32 = icmp eq i32 %1, 0
  br i1 %.not32, label %3, label %2

2:                                                ; preds = %0
  tail call void @G_PlayerFinishLevel(i32 noundef 0)
  br label %3

3:                                                ; preds = %0, %2
  %4 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 4), align 4, !tbaa !5
  %.not32.1 = icmp eq i32 %4, 0
  br i1 %.not32.1, label %6, label %5

5:                                                ; preds = %3
  tail call void @G_PlayerFinishLevel(i32 noundef 1)
  br label %6

6:                                                ; preds = %5, %3
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 8), align 8, !tbaa !5
  %.not32.2 = icmp eq i32 %7, 0
  br i1 %.not32.2, label %9, label %8

8:                                                ; preds = %6
  tail call void @G_PlayerFinishLevel(i32 noundef 2)
  br label %9

9:                                                ; preds = %8, %6
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 12), align 4, !tbaa !5
  %.not32.3 = icmp eq i32 %10, 0
  br i1 %.not32.3, label %12, label %11

11:                                               ; preds = %9
  tail call void @G_PlayerFinishLevel(i32 noundef 3)
  br label %12

12:                                               ; preds = %11, %9
  %13 = load i32, ptr @automapactive, align 4, !tbaa !5
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %15, label %14

14:                                               ; preds = %12
  tail call void @AM_Stop() #3
  br label %15

15:                                               ; preds = %14, %12
  %16 = load i32, ptr @gamemode, align 4
  %.not28 = icmp eq i32 %16, 2
  %17 = load i32, ptr @gamemap, align 4, !tbaa !5
  br i1 %.not28, label %.thread34, label %19

.thread34:                                        ; preds = %15
  %18 = icmp ne i32 %17, 9
  br label %.loopexit

19:                                               ; preds = %15
  switch i32 %17, label %.loopexit [
    i32 8, label %20
    i32 9, label %.preheader.preheader
  ]

20:                                               ; preds = %19
  store i32 7, ptr @gameaction, align 4, !tbaa !5
  br label %63

.preheader.preheader:                             ; preds = %19
  store i32 1, ptr getelementptr inbounds (i8, ptr @players, i64 312), align 8, !tbaa !9
  store i32 1, ptr getelementptr inbounds (i8, ptr @players, i64 632), align 8, !tbaa !9
  store i32 1, ptr getelementptr inbounds (i8, ptr @players, i64 952), align 8, !tbaa !9
  store i32 1, ptr getelementptr inbounds (i8, ptr @players, i64 1272), align 8, !tbaa !9
  br label %.loopexit

.loopexit:                                        ; preds = %19, %.preheader.preheader, %.thread34
  %.not46 = phi i1 [ %18, %.thread34 ], [ false, %.preheader.preheader ], [ true, %19 ]
  %21 = phi i32 [ %17, %.thread34 ], [ 9, %.preheader.preheader ], [ %17, %19 ]
  %22 = load i32, ptr @consoleplayer, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %23, i32 34
  %25 = load i32, ptr %24, align 8, !tbaa !9
  store i32 %25, ptr getelementptr inbounds (i8, ptr @wminfo, i64 4), align 4, !tbaa !14
  %26 = load i32, ptr @gameepisode, align 4, !tbaa !5
  %27 = add nsw i32 %26, -1
  store i32 %27, ptr @wminfo, align 4, !tbaa !16
  %28 = add nsw i32 %21, -1
  store i32 %28, ptr getelementptr inbounds (i8, ptr @wminfo, i64 8), align 4, !tbaa !17
  %29 = load i32, ptr @secretexit, align 4, !tbaa !5
  %.not30 = icmp ne i32 %29, 0
  br i1 %.not28, label %30, label %34

30:                                               ; preds = %.loopexit
  br i1 %.not30, label %31, label %33

31:                                               ; preds = %30
  switch i32 %21, label %38 [
    i32 15, label %.sink.split
    i32 31, label %32
  ]

32:                                               ; preds = %31
  br label %.sink.split

33:                                               ; preds = %30
  %.off = add i32 %21, -31
  %switch = icmp ult i32 %.off, 2
  %. = select i1 %switch, i32 15, i32 %21
  br label %.sink.split

34:                                               ; preds = %.loopexit
  %brmerge = select i1 %.not30, i1 true, i1 %.not46
  %.mux = select i1 %.not30, i32 8, i32 %21
  br i1 %brmerge, label %.sink.split, label %35

35:                                               ; preds = %34
  %switch.tableidx = add i32 %26, -1
  %36 = icmp ult i32 %switch.tableidx, 4
  br i1 %36, label %switch.lookup, label %38

switch.lookup:                                    ; preds = %35
  %37 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [4 x i32], ptr @switch.table.G_DoCompleted, i64 0, i64 %37
  %switch.load = load i32, ptr %switch.gep, align 4
  br label %.sink.split

.sink.split:                                      ; preds = %switch.lookup, %34, %33, %31, %32
  %.sink = phi i32 [ 31, %32 ], [ 30, %31 ], [ %., %33 ], [ %.mux, %34 ], [ %switch.load, %switch.lookup ]
  store i32 %.sink, ptr getelementptr inbounds (i8, ptr @wminfo, i64 12), align 4, !tbaa !18
  br label %38

38:                                               ; preds = %35, %.sink.split, %31
  %39 = load i32, ptr @totalkills, align 4, !tbaa !5
  store i32 %39, ptr getelementptr inbounds (i8, ptr @wminfo, i64 16), align 4, !tbaa !19
  %40 = load i32, ptr @totalitems, align 4, !tbaa !5
  store i32 %40, ptr getelementptr inbounds (i8, ptr @wminfo, i64 20), align 4, !tbaa !20
  %41 = load i32, ptr @totalsecret, align 4, !tbaa !5
  store i32 %41, ptr getelementptr inbounds (i8, ptr @wminfo, i64 24), align 4, !tbaa !21
  store i32 0, ptr getelementptr inbounds (i8, ptr @wminfo, i64 28), align 4, !tbaa !22
  %42 = sext i32 %26 to i64
  %43 = sext i32 %21 to i64
  %44 = getelementptr inbounds [4 x [10 x i32]], ptr @pars, i64 0, i64 %42, i64 %43
  %45 = sext i32 %28 to i64
  %46 = getelementptr inbounds [32 x i32], ptr @cpars, i64 0, i64 %45
  %storemerge.in.in = select i1 %.not28, ptr %46, ptr %44
  %storemerge.in = load i32, ptr %storemerge.in.in, align 4, !tbaa !5
  %storemerge = mul nsw i32 %storemerge.in, 35
  store i32 %storemerge, ptr getelementptr inbounds (i8, ptr @wminfo, i64 32), align 4, !tbaa !23
  store i32 %22, ptr getelementptr inbounds (i8, ptr @wminfo, i64 36), align 4, !tbaa !24
  %47 = load i32, ptr @leveltime, align 4, !tbaa !5
  %48 = load i32, ptr @playeringame, align 16, !tbaa !5
  store i32 %48, ptr getelementptr inbounds (i8, ptr @wminfo, i64 40), align 4, !tbaa !25
  %49 = load <2 x i32>, ptr getelementptr inbounds (i8, ptr @players, i64 208), align 16, !tbaa !5
  store <2 x i32> %49, ptr getelementptr inbounds (i8, ptr @wminfo, i64 44), align 4, !tbaa !5
  %50 = load i32, ptr getelementptr inbounds (i8, ptr @players, i64 216), align 8, !tbaa !27
  store i32 %50, ptr getelementptr inbounds (i8, ptr @wminfo, i64 52), align 4, !tbaa !28
  store i32 %47, ptr getelementptr inbounds (i8, ptr @wminfo, i64 56), align 4, !tbaa !29
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) getelementptr inbounds (i8, ptr @wminfo, i64 60), ptr noundef nonnull align 4 dereferenceable(16) getelementptr inbounds (i8, ptr @players, i64 100), i64 16, i1 false)
  %51 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 4), align 4, !tbaa !5
  store i32 %51, ptr getelementptr inbounds (i8, ptr @wminfo, i64 80), align 4, !tbaa !25
  %52 = load <2 x i32>, ptr getelementptr inbounds (i8, ptr @players, i64 528), align 16, !tbaa !5
  store <2 x i32> %52, ptr getelementptr inbounds (i8, ptr @wminfo, i64 84), align 4, !tbaa !5
  %53 = load i32, ptr getelementptr inbounds (i8, ptr @players, i64 536), align 8, !tbaa !27
  store i32 %53, ptr getelementptr inbounds (i8, ptr @wminfo, i64 92), align 4, !tbaa !28
  store i32 %47, ptr getelementptr inbounds (i8, ptr @wminfo, i64 96), align 4, !tbaa !29
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) getelementptr inbounds (i8, ptr @wminfo, i64 100), ptr noundef nonnull align 4 dereferenceable(16) getelementptr inbounds (i8, ptr @players, i64 420), i64 16, i1 false)
  %54 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 8), align 8, !tbaa !5
  store i32 %54, ptr getelementptr inbounds (i8, ptr @wminfo, i64 120), align 4, !tbaa !25
  %55 = load <2 x i32>, ptr getelementptr inbounds (i8, ptr @players, i64 848), align 16, !tbaa !5
  store <2 x i32> %55, ptr getelementptr inbounds (i8, ptr @wminfo, i64 124), align 4, !tbaa !5
  %56 = load i32, ptr getelementptr inbounds (i8, ptr @players, i64 856), align 8, !tbaa !27
  store i32 %56, ptr getelementptr inbounds (i8, ptr @wminfo, i64 132), align 4, !tbaa !28
  store i32 %47, ptr getelementptr inbounds (i8, ptr @wminfo, i64 136), align 4, !tbaa !29
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) getelementptr inbounds (i8, ptr @wminfo, i64 140), ptr noundef nonnull align 4 dereferenceable(16) getelementptr inbounds (i8, ptr @players, i64 740), i64 16, i1 false)
  %57 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 12), align 4, !tbaa !5
  store i32 %57, ptr getelementptr inbounds (i8, ptr @wminfo, i64 160), align 4, !tbaa !25
  %58 = load <2 x i32>, ptr getelementptr inbounds (i8, ptr @players, i64 1168), align 16, !tbaa !5
  store <2 x i32> %58, ptr getelementptr inbounds (i8, ptr @wminfo, i64 164), align 4, !tbaa !5
  %59 = load i32, ptr getelementptr inbounds (i8, ptr @players, i64 1176), align 8, !tbaa !27
  store i32 %59, ptr getelementptr inbounds (i8, ptr @wminfo, i64 172), align 4, !tbaa !28
  store i32 %47, ptr getelementptr inbounds (i8, ptr @wminfo, i64 176), align 4, !tbaa !29
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) getelementptr inbounds (i8, ptr @wminfo, i64 180), ptr noundef nonnull align 4 dereferenceable(16) getelementptr inbounds (i8, ptr @players, i64 1060), i64 16, i1 false)
  store i32 1, ptr @gamestate, align 4, !tbaa !5
  store i32 0, ptr @viewactive, align 4, !tbaa !5
  store i32 0, ptr @automapactive, align 4, !tbaa !5
  %60 = load ptr, ptr @statcopy, align 8, !tbaa !30
  %.not31 = icmp eq ptr %60, null
  br i1 %.not31, label %62, label %61

61:                                               ; preds = %38
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(200) %60, ptr noundef nonnull align 4 dereferenceable(200) @wminfo, i64 200, i1 false)
  br label %62

62:                                               ; preds = %61, %38
  tail call void @WI_Start(ptr noundef nonnull @wminfo) #3
  br label %63

63:                                               ; preds = %62, %20
  ret void
}

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

declare void @AM_Stop() local_unnamed_addr #2

declare void @WI_Start(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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, !6, i64 312}
!10 = !{!"player_s", !11, i64 0, !6, i64 8, !12, i64 12, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !7, i64 48, !7, i64 72, !6, i64 96, !7, i64 100, !6, i64 116, !6, i64 120, !7, i64 124, !7, i64 160, !7, i64 176, !6, i64 192, !6, i64 196, !6, i64 200, !6, i64 204, !6, i64 208, !6, i64 212, !6, i64 216, !11, i64 224, !6, i64 232, !6, i64 236, !11, i64 240, !6, i64 248, !6, i64 252, !6, i64 256, !7, i64 264, !6, i64 312}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"", !7, i64 0, !7, i64 1, !13, i64 2, !13, i64 4, !7, i64 6, !7, i64 7}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !6, i64 4}
!15 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !7, i64 40}
!16 = !{!15, !6, i64 0}
!17 = !{!15, !6, i64 8}
!18 = !{!15, !6, i64 12}
!19 = !{!15, !6, i64 16}
!20 = !{!15, !6, i64 20}
!21 = !{!15, !6, i64 24}
!22 = !{!15, !6, i64 28}
!23 = !{!15, !6, i64 32}
!24 = !{!15, !6, i64 36}
!25 = !{!26, !6, i64 0}
!26 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !7, i64 20, !6, i64 36}
!27 = !{!10, !6, i64 216}
!28 = !{!26, !6, i64 12}
!29 = !{!26, !6, i64 16}
!30 = !{!11, !11, i64 0}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass