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

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

@gamemode = external global i32, align 4
@bcnt = external hidden global i32, align 4
@acceleratestage = external hidden global i32, align 4
@playeringame = external global [4 x i32], align 16
@plrs = external hidden global ptr, align 8
@dm_state = external hidden global i32, align 4
@cnt_pause = external hidden global i32, align 4
@dm_frags = external hidden global [4 x [4 x i32]], align 16
@dm_totals = external hidden global [4 x i32], align 16

; 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: nounwind uwtable
declare dso_local void @WI_updateAnimatedBack() #1

; Function Attrs: nounwind uwtable
declare dso_local void @WI_initNoState() #1

; Function Attrs: nounwind uwtable
declare dso_local void @WI_initShowNextLoc() #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @WI_fragSum(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @WI_updateDeathmatchStats() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @WI_updateAnimatedBack()
  %4 = load i32, ptr @acceleratestage, align 4, !tbaa !5
  %5 = icmp ne i32 %4, 0
  br i1 %5, label %6, label %60

6:                                                ; preds = %0
  %7 = load i32, ptr @dm_state, align 4, !tbaa !5
  %8 = icmp ne i32 %7, 4
  br i1 %8, label %9, label %60

9:                                                ; preds = %6
  store i32 0, ptr @acceleratestage, align 4, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %56, %9
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 4
  br i1 %12, label %13, label %59

13:                                               ; preds = %10
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [4 x i32], ptr @playeringame, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %55

19:                                               ; preds = %13
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %46, %19
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 4
  br i1 %22, label %23, label %49

23:                                               ; preds = %20
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [4 x i32], ptr @playeringame, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %45

29:                                               ; preds = %23
  %30 = load ptr, ptr @plrs, align 8, !tbaa !9
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %30, i64 %32
  %34 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %33, i32 0, i32 5
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [4 x i32], ptr %34, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = load i32, ptr %1, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [4 x [4 x i32]], ptr @dm_frags, i64 0, i64 %40
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [4 x i32], ptr %41, i64 0, i64 %43
  store i32 %38, ptr %44, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %29, %23
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %2, align 4, !tbaa !5
  br label %20, !llvm.loop !11

49:                                               ; preds = %20
  %50 = load i32, ptr %1, align 4, !tbaa !5
  %51 = call i32 @WI_fragSum(i32 noundef %50)
  %52 = load i32, ptr %1, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [4 x i32], ptr @dm_totals, i64 0, i64 %53
  store i32 %51, ptr %54, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %49, %13
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %1, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %1, align 4, !tbaa !5
  br label %10, !llvm.loop !13

59:                                               ; preds = %10
  call void @S_StartSound(ptr noundef null, i32 noundef 82)
  store i32 4, ptr @dm_state, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %59, %6, %0
  %61 = load i32, ptr @dm_state, align 4, !tbaa !5
  %62 = icmp eq i32 %61, 2
  br i1 %62, label %63, label %209

63:                                               ; preds = %60
  %64 = load i32, ptr @bcnt, align 4, !tbaa !5
  %65 = and i32 %64, 3
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %68, label %67

67:                                               ; preds = %63
  call void @S_StartSound(ptr noundef null, i32 noundef 1)
  br label %68

68:                                               ; preds = %67, %63
  store i32 0, ptr %3, align 4, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %199, %68
  %70 = load i32, ptr %1, align 4, !tbaa !5
  %71 = icmp slt i32 %70, 4
  br i1 %71, label %72, label %202

72:                                               ; preds = %69
  %73 = load i32, ptr %1, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [4 x i32], ptr @playeringame, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %198

78:                                               ; preds = %72
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %169, %78
  %80 = load i32, ptr %2, align 4, !tbaa !5
  %81 = icmp slt i32 %80, 4
  br i1 %81, label %82, label %172

82:                                               ; preds = %79
  %83 = load i32, ptr %2, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [4 x i32], ptr @playeringame, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %88, label %168

88:                                               ; preds = %82
  %89 = load i32, ptr %1, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [4 x [4 x i32]], ptr @dm_frags, i64 0, i64 %90
  %92 = load i32, ptr %2, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [4 x i32], ptr %91, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = load ptr, ptr @plrs, align 8, !tbaa !9
  %97 = load i32, ptr %1, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %96, i64 %98
  %100 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %99, i32 0, i32 5
  %101 = load i32, ptr %2, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [4 x i32], ptr %100, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = icmp ne i32 %95, %104
  br i1 %105, label %106, label %168

106:                                              ; preds = %88
  %107 = load ptr, ptr @plrs, align 8, !tbaa !9
  %108 = load i32, ptr %1, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %107, i64 %109
  %111 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %110, i32 0, i32 5
  %112 = load i32, ptr %2, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [4 x i32], ptr %111, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = icmp slt i32 %115, 0
  br i1 %116, label %117, label %126

117:                                              ; preds = %106
  %118 = load i32, ptr %1, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [4 x [4 x i32]], ptr @dm_frags, i64 0, i64 %119
  %121 = load i32, ptr %2, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [4 x i32], ptr %120, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !5
  %125 = add nsw i32 %124, -1
  store i32 %125, ptr %123, align 4, !tbaa !5
  br label %135

126:                                              ; preds = %106
  %127 = load i32, ptr %1, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [4 x [4 x i32]], ptr @dm_frags, i64 0, i64 %128
  %130 = load i32, ptr %2, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [4 x i32], ptr %129, i64 0, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !5
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr %132, align 4, !tbaa !5
  br label %135

135:                                              ; preds = %126, %117
  %136 = load i32, ptr %1, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [4 x [4 x i32]], ptr @dm_frags, i64 0, i64 %137
  %139 = load i32, ptr %2, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [4 x i32], ptr %138, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = icmp sgt i32 %142, 99
  br i1 %143, label %144, label %151

144:                                              ; preds = %135
  %145 = load i32, ptr %1, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [4 x [4 x i32]], ptr @dm_frags, i64 0, i64 %146
  %148 = load i32, ptr %2, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [4 x i32], ptr %147, i64 0, i64 %149
  store i32 99, ptr %150, align 4, !tbaa !5
  br label %151

151:                                              ; preds = %144, %135
  %152 = load i32, ptr %1, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [4 x [4 x i32]], ptr @dm_frags, i64 0, i64 %153
  %155 = load i32, ptr %2, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [4 x i32], ptr %154, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = icmp slt i32 %158, -99
  br i1 %159, label %160, label %167

160:                                              ; preds = %151
  %161 = load i32, ptr %1, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [4 x [4 x i32]], ptr @dm_frags, i64 0, i64 %162
  %164 = load i32, ptr %2, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [4 x i32], ptr %163, i64 0, i64 %165
  store i32 -99, ptr %166, align 4, !tbaa !5
  br label %167

167:                                              ; preds = %160, %151
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %168

168:                                              ; preds = %167, %88, %82
  br label %169

169:                                              ; preds = %168
  %170 = load i32, ptr %2, align 4, !tbaa !5
  %171 = add nsw i32 %170, 1
  store i32 %171, ptr %2, align 4, !tbaa !5
  br label %79, !llvm.loop !14

172:                                              ; preds = %79
  %173 = load i32, ptr %1, align 4, !tbaa !5
  %174 = call i32 @WI_fragSum(i32 noundef %173)
  %175 = load i32, ptr %1, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [4 x i32], ptr @dm_totals, i64 0, i64 %176
  store i32 %174, ptr %177, align 4, !tbaa !5
  %178 = load i32, ptr %1, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [4 x i32], ptr @dm_totals, i64 0, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = icmp sgt i32 %181, 99
  br i1 %182, label %183, label %187

183:                                              ; preds = %172
  %184 = load i32, ptr %1, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [4 x i32], ptr @dm_totals, i64 0, i64 %185
  store i32 99, ptr %186, align 4, !tbaa !5
  br label %187

187:                                              ; preds = %183, %172
  %188 = load i32, ptr %1, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [4 x i32], ptr @dm_totals, i64 0, i64 %189
  %191 = load i32, ptr %190, align 4, !tbaa !5
  %192 = icmp slt i32 %191, -99
  br i1 %192, label %193, label %197

193:                                              ; preds = %187
  %194 = load i32, ptr %1, align 4, !tbaa !5
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [4 x i32], ptr @dm_totals, i64 0, i64 %195
  store i32 -99, ptr %196, align 4, !tbaa !5
  br label %197

197:                                              ; preds = %193, %187
  br label %198

198:                                              ; preds = %197, %72
  br label %199

199:                                              ; preds = %198
  %200 = load i32, ptr %1, align 4, !tbaa !5
  %201 = add nsw i32 %200, 1
  store i32 %201, ptr %1, align 4, !tbaa !5
  br label %69, !llvm.loop !15

202:                                              ; preds = %69
  %203 = load i32, ptr %3, align 4, !tbaa !5
  %204 = icmp ne i32 %203, 0
  br i1 %204, label %208, label %205

205:                                              ; preds = %202
  call void @S_StartSound(ptr noundef null, i32 noundef 82)
  %206 = load i32, ptr @dm_state, align 4, !tbaa !5
  %207 = add nsw i32 %206, 1
  store i32 %207, ptr @dm_state, align 4, !tbaa !5
  br label %208

208:                                              ; preds = %205, %202
  br label %236

209:                                              ; preds = %60
  %210 = load i32, ptr @dm_state, align 4, !tbaa !5
  %211 = icmp eq i32 %210, 4
  br i1 %211, label %212, label %222

212:                                              ; preds = %209
  %213 = load i32, ptr @acceleratestage, align 4, !tbaa !5
  %214 = icmp ne i32 %213, 0
  br i1 %214, label %215, label %221

215:                                              ; preds = %212
  call void @S_StartSound(ptr noundef null, i32 noundef 31)
  %216 = load i32, ptr @gamemode, align 4, !tbaa !5
  %217 = icmp eq i32 %216, 2
  br i1 %217, label %218, label %219

218:                                              ; preds = %215
  call void @WI_initNoState()
  br label %220

219:                                              ; preds = %215
  call void @WI_initShowNextLoc()
  br label %220

220:                                              ; preds = %219, %218
  br label %221

221:                                              ; preds = %220, %212
  br label %235

222:                                              ; preds = %209
  %223 = load i32, ptr @dm_state, align 4, !tbaa !5
  %224 = and i32 %223, 1
  %225 = icmp ne i32 %224, 0
  br i1 %225, label %226, label %234

226:                                              ; preds = %222
  %227 = load i32, ptr @cnt_pause, align 4, !tbaa !5
  %228 = add nsw i32 %227, -1
  store i32 %228, ptr @cnt_pause, align 4, !tbaa !5
  %229 = icmp ne i32 %228, 0
  br i1 %229, label %233, label %230

230:                                              ; preds = %226
  %231 = load i32, ptr @dm_state, align 4, !tbaa !5
  %232 = add nsw i32 %231, 1
  store i32 %232, ptr @dm_state, align 4, !tbaa !5
  store i32 35, ptr @cnt_pause, align 4, !tbaa !5
  br label %233

233:                                              ; preds = %230, %226
  br label %234

234:                                              ; preds = %233, %222
  br label %235

235:                                              ; preds = %234, %221
  br label %236

236:                                              ; preds = %235, %208
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

declare void @S_StartSound(ptr noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync 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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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

@gamemode = external local_unnamed_addr global i32, align 4
@bcnt = external hidden local_unnamed_addr global i32, align 4
@acceleratestage = external hidden local_unnamed_addr global i32, align 4
@playeringame = external local_unnamed_addr global [4 x i32], align 16
@plrs = external hidden local_unnamed_addr global ptr, align 8
@dm_state = external hidden local_unnamed_addr global i32, align 4
@cnt_pause = external hidden local_unnamed_addr global i32, align 4
@dm_frags = external hidden local_unnamed_addr global [4 x [4 x i32]], align 16
@dm_totals = external hidden local_unnamed_addr global [4 x i32], align 16

; Function Attrs: nounwind uwtable
declare dso_local void @WI_updateAnimatedBack() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @WI_initNoState() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @WI_initShowNextLoc() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @WI_updateDeathmatchStats() local_unnamed_addr #0 {
  tail call void @WI_updateAnimatedBack()
  %1 = load i32, ptr @acceleratestage, align 4, !tbaa !5
  %2 = icmp ne i32 %1, 0
  %3 = load i32, ptr @dm_state, align 4
  %4 = icmp ne i32 %3, 4
  %or.cond = select i1 %2, i1 %4, i1 false
  br i1 %or.cond, label %5, label %90

5:                                                ; preds = %0
  store i32 0, ptr @acceleratestage, align 4, !tbaa !5
  %6 = load i32, ptr @playeringame, align 16, !tbaa !5
  %.not61 = icmp eq i32 %6, 0
  br i1 %.not61, label %27, label %7

7:                                                ; preds = %5
  %8 = load ptr, ptr @plrs, align 8
  %9 = getelementptr inbounds i8, ptr %8, i64 20
  %10 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %10, ptr @dm_frags, align 16, !tbaa !5
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 4), align 4, !tbaa !5
  %.not62.1 = icmp eq i32 %11, 0
  br i1 %.not62.1, label %15, label %12

12:                                               ; preds = %7
  %13 = getelementptr inbounds i8, ptr %8, i64 24
  %14 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %14, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 4), align 4, !tbaa !5
  br label %15

15:                                               ; preds = %12, %7
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 8), align 8, !tbaa !5
  %.not62.2 = icmp eq i32 %16, 0
  br i1 %.not62.2, label %20, label %17

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %8, i64 28
  %19 = load i32, ptr %18, align 4, !tbaa !5
  store i32 %19, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 8), align 8, !tbaa !5
  br label %20

20:                                               ; preds = %17, %15
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 12), align 4, !tbaa !5
  %.not62.3 = icmp eq i32 %21, 0
  br i1 %.not62.3, label %25, label %22

22:                                               ; preds = %20
  %23 = getelementptr inbounds i8, ptr %8, i64 32
  %24 = load i32, ptr %23, align 4, !tbaa !5
  store i32 %24, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 12), align 4, !tbaa !5
  br label %25

25:                                               ; preds = %22, %20
  %26 = tail call i32 @WI_fragSum(i32 noundef 0)
  store i32 %26, ptr @dm_totals, align 16, !tbaa !5
  br label %27

27:                                               ; preds = %5, %25
  %28 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 4), align 4, !tbaa !5
  %.not61.1 = icmp eq i32 %28, 0
  br i1 %.not61.1, label %48, label %.preheader.1

.preheader.1:                                     ; preds = %27
  %29 = load ptr, ptr @plrs, align 8
  %30 = load i32, ptr @playeringame, align 16, !tbaa !5
  %.not62.180 = icmp eq i32 %30, 0
  br i1 %.not62.180, label %34, label %31

31:                                               ; preds = %.preheader.1
  %32 = getelementptr inbounds i8, ptr %29, i64 60
  %33 = load i32, ptr %32, align 4, !tbaa !5
  store i32 %33, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 16), align 16, !tbaa !5
  br label %34

34:                                               ; preds = %31, %.preheader.1
  %35 = getelementptr inbounds i8, ptr %29, i64 64
  %36 = load i32, ptr %35, align 4, !tbaa !5
  store i32 %36, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 20), align 4, !tbaa !5
  %37 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 8), align 8, !tbaa !5
  %.not62.2.1 = icmp eq i32 %37, 0
  br i1 %.not62.2.1, label %41, label %38

38:                                               ; preds = %34
  %39 = getelementptr inbounds i8, ptr %29, i64 68
  %40 = load i32, ptr %39, align 4, !tbaa !5
  store i32 %40, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 24), align 8, !tbaa !5
  br label %41

41:                                               ; preds = %38, %34
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 12), align 4, !tbaa !5
  %.not62.3.1 = icmp eq i32 %42, 0
  br i1 %.not62.3.1, label %46, label %43

43:                                               ; preds = %41
  %44 = getelementptr inbounds i8, ptr %29, i64 72
  %45 = load i32, ptr %44, align 4, !tbaa !5
  store i32 %45, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 28), align 4, !tbaa !5
  br label %46

46:                                               ; preds = %43, %41
  %47 = tail call i32 @WI_fragSum(i32 noundef 1)
  store i32 %47, ptr getelementptr inbounds (i8, ptr @dm_totals, i64 4), align 4, !tbaa !5
  br label %48

48:                                               ; preds = %46, %27
  %49 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 8), align 8, !tbaa !5
  %.not61.2 = icmp eq i32 %49, 0
  br i1 %.not61.2, label %69, label %.preheader.2

.preheader.2:                                     ; preds = %48
  %50 = load ptr, ptr @plrs, align 8
  %51 = load i32, ptr @playeringame, align 16, !tbaa !5
  %.not62.281 = icmp eq i32 %51, 0
  br i1 %.not62.281, label %55, label %52

52:                                               ; preds = %.preheader.2
  %53 = getelementptr inbounds i8, ptr %50, i64 100
  %54 = load i32, ptr %53, align 4, !tbaa !5
  store i32 %54, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 32), align 16, !tbaa !5
  br label %55

55:                                               ; preds = %52, %.preheader.2
  %56 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 4), align 4, !tbaa !5
  %.not62.1.2 = icmp eq i32 %56, 0
  br i1 %.not62.1.2, label %60, label %57

57:                                               ; preds = %55
  %58 = getelementptr inbounds i8, ptr %50, i64 104
  %59 = load i32, ptr %58, align 4, !tbaa !5
  store i32 %59, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 36), align 4, !tbaa !5
  br label %60

60:                                               ; preds = %57, %55
  %61 = getelementptr inbounds i8, ptr %50, i64 108
  %62 = load i32, ptr %61, align 4, !tbaa !5
  store i32 %62, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 40), align 8, !tbaa !5
  %63 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 12), align 4, !tbaa !5
  %.not62.3.2 = icmp eq i32 %63, 0
  br i1 %.not62.3.2, label %67, label %64

64:                                               ; preds = %60
  %65 = getelementptr inbounds i8, ptr %50, i64 112
  %66 = load i32, ptr %65, align 4, !tbaa !5
  store i32 %66, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 44), align 4, !tbaa !5
  br label %67

67:                                               ; preds = %64, %60
  %68 = tail call i32 @WI_fragSum(i32 noundef 2)
  store i32 %68, ptr getelementptr inbounds (i8, ptr @dm_totals, i64 8), align 8, !tbaa !5
  br label %69

69:                                               ; preds = %67, %48
  %70 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 12), align 4, !tbaa !5
  %.not61.3 = icmp eq i32 %70, 0
  br i1 %.not61.3, label %.thread, label %.preheader.3

.preheader.3:                                     ; preds = %69
  %71 = load ptr, ptr @plrs, align 8
  %72 = load i32, ptr @playeringame, align 16, !tbaa !5
  %.not62.382 = icmp eq i32 %72, 0
  br i1 %.not62.382, label %76, label %73

73:                                               ; preds = %.preheader.3
  %74 = getelementptr inbounds i8, ptr %71, i64 140
  %75 = load i32, ptr %74, align 4, !tbaa !5
  store i32 %75, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 48), align 16, !tbaa !5
  br label %76

76:                                               ; preds = %73, %.preheader.3
  %77 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 4), align 4, !tbaa !5
  %.not62.1.3 = icmp eq i32 %77, 0
  br i1 %.not62.1.3, label %81, label %78

78:                                               ; preds = %76
  %79 = getelementptr inbounds i8, ptr %71, i64 144
  %80 = load i32, ptr %79, align 4, !tbaa !5
  store i32 %80, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 52), align 4, !tbaa !5
  br label %81

81:                                               ; preds = %78, %76
  %82 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 8), align 8, !tbaa !5
  %.not62.2.3 = icmp eq i32 %82, 0
  br i1 %.not62.2.3, label %86, label %83

83:                                               ; preds = %81
  %84 = getelementptr inbounds i8, ptr %71, i64 148
  %85 = load i32, ptr %84, align 4, !tbaa !5
  store i32 %85, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 56), align 8, !tbaa !5
  br label %86

86:                                               ; preds = %83, %81
  %87 = getelementptr inbounds i8, ptr %71, i64 152
  %88 = load i32, ptr %87, align 4, !tbaa !5
  store i32 %88, ptr getelementptr inbounds (i8, ptr @dm_frags, i64 60), align 4, !tbaa !5
  %89 = tail call i32 @WI_fragSum(i32 noundef 3)
  store i32 %89, ptr getelementptr inbounds (i8, ptr @dm_totals, i64 12), align 4, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %86, %69
  tail call void @S_StartSound(ptr noundef null, i32 noundef 82) #3
  store i32 4, ptr @dm_state, align 4, !tbaa !5
  %.pre = load i32, ptr @acceleratestage, align 4, !tbaa !5
  br label %139

90:                                               ; preds = %0
  switch i32 %3, label %146 [
    i32 2, label %91
    i32 4, label %139
  ]

91:                                               ; preds = %90
  %92 = load i32, ptr @bcnt, align 4, !tbaa !5
  %93 = and i32 %92, 3
  %.not53 = icmp eq i32 %93, 0
  br i1 %.not53, label %94, label %.preheader

94:                                               ; preds = %91
  tail call void @S_StartSound(ptr noundef null, i32 noundef 1) #3
  br label %.preheader

.preheader:                                       ; preds = %94, %91
  br label %95

95:                                               ; preds = %.preheader, %134
  %indvars.iv = phi i64 [ %indvars.iv.next, %134 ], [ 0, %.preheader ]
  %.067 = phi i32 [ %.3, %134 ], [ 0, %.preheader ]
  %96 = getelementptr inbounds [4 x i32], ptr @playeringame, i64 0, i64 %indvars.iv
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %.not55 = icmp eq i32 %97, 0
  br i1 %.not55, label %134, label %.preheader63

.preheader63:                                     ; preds = %95
  %98 = load ptr, ptr @plrs, align 8
  %99 = load i32, ptr @playeringame, align 16, !tbaa !5
  %.not56 = icmp eq i32 %99, 0
  br i1 %.not56, label %106, label %100

100:                                              ; preds = %.preheader63
  %101 = getelementptr inbounds [4 x [4 x i32]], ptr @dm_frags, i64 0, i64 %indvars.iv, i64 0
  %102 = load i32, ptr %101, align 16, !tbaa !5
  %103 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %98, i64 %indvars.iv, i32 5, i64 0
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %.not57 = icmp eq i32 %102, %104
  br i1 %.not57, label %106, label %105

105:                                              ; preds = %100
  %.inv = icmp sgt i32 %104, -1
  %storemerge58.v = select i1 %.inv, i32 1, i32 -1
  %storemerge58 = add nsw i32 %storemerge58.v, %102
  %storemerge59 = tail call i32 @llvm.smin.i32(i32 %storemerge58, i32 99)
  %storemerge60 = tail call i32 @llvm.smax.i32(i32 %storemerge59, i32 -99)
  store i32 %storemerge60, ptr %101, align 16, !tbaa !5
  br label %106

106:                                              ; preds = %.preheader63, %100, %105
  %.2 = phi i32 [ 1, %105 ], [ %.067, %100 ], [ %.067, %.preheader63 ]
  %107 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 4), align 4, !tbaa !5
  %.not56.1 = icmp eq i32 %107, 0
  br i1 %.not56.1, label %114, label %108

108:                                              ; preds = %106
  %109 = getelementptr inbounds [4 x [4 x i32]], ptr @dm_frags, i64 0, i64 %indvars.iv, i64 1
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %98, i64 %indvars.iv, i32 5, i64 1
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %.not57.1 = icmp eq i32 %110, %112
  br i1 %.not57.1, label %114, label %113

113:                                              ; preds = %108
  %.inv.1 = icmp sgt i32 %112, -1
  %storemerge58.v.1 = select i1 %.inv.1, i32 1, i32 -1
  %storemerge58.1 = add nsw i32 %storemerge58.v.1, %110
  %storemerge59.1 = tail call i32 @llvm.smin.i32(i32 %storemerge58.1, i32 99)
  %storemerge60.1 = tail call i32 @llvm.smax.i32(i32 %storemerge59.1, i32 -99)
  store i32 %storemerge60.1, ptr %109, align 4, !tbaa !5
  br label %114

114:                                              ; preds = %113, %108, %106
  %.2.1 = phi i32 [ 1, %113 ], [ %.2, %108 ], [ %.2, %106 ]
  %115 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 8), align 8, !tbaa !5
  %.not56.2 = icmp eq i32 %115, 0
  br i1 %.not56.2, label %122, label %116

116:                                              ; preds = %114
  %117 = getelementptr inbounds [4 x [4 x i32]], ptr @dm_frags, i64 0, i64 %indvars.iv, i64 2
  %118 = load i32, ptr %117, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %98, i64 %indvars.iv, i32 5, i64 2
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %.not57.2 = icmp eq i32 %118, %120
  br i1 %.not57.2, label %122, label %121

121:                                              ; preds = %116
  %.inv.2 = icmp sgt i32 %120, -1
  %storemerge58.v.2 = select i1 %.inv.2, i32 1, i32 -1
  %storemerge58.2 = add nsw i32 %storemerge58.v.2, %118
  %storemerge59.2 = tail call i32 @llvm.smin.i32(i32 %storemerge58.2, i32 99)
  %storemerge60.2 = tail call i32 @llvm.smax.i32(i32 %storemerge59.2, i32 -99)
  store i32 %storemerge60.2, ptr %117, align 8, !tbaa !5
  br label %122

122:                                              ; preds = %121, %116, %114
  %.2.2 = phi i32 [ 1, %121 ], [ %.2.1, %116 ], [ %.2.1, %114 ]
  %123 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 12), align 4, !tbaa !5
  %.not56.3 = icmp eq i32 %123, 0
  br i1 %.not56.3, label %130, label %124

124:                                              ; preds = %122
  %125 = getelementptr inbounds [4 x [4 x i32]], ptr @dm_frags, i64 0, i64 %indvars.iv, i64 3
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %127 = getelementptr inbounds %struct.wbplayerstruct_t, ptr %98, i64 %indvars.iv, i32 5, i64 3
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %.not57.3 = icmp eq i32 %126, %128
  br i1 %.not57.3, label %130, label %129

129:                                              ; preds = %124
  %.inv.3 = icmp sgt i32 %128, -1
  %storemerge58.v.3 = select i1 %.inv.3, i32 1, i32 -1
  %storemerge58.3 = add nsw i32 %storemerge58.v.3, %126
  %storemerge59.3 = tail call i32 @llvm.smin.i32(i32 %storemerge58.3, i32 99)
  %storemerge60.3 = tail call i32 @llvm.smax.i32(i32 %storemerge59.3, i32 -99)
  store i32 %storemerge60.3, ptr %125, align 4, !tbaa !5
  br label %130

130:                                              ; preds = %129, %124, %122
  %.2.3 = phi i32 [ 1, %129 ], [ %.2.2, %124 ], [ %.2.2, %122 ]
  %131 = trunc nuw nsw i64 %indvars.iv to i32
  %132 = tail call i32 @WI_fragSum(i32 noundef %131)
  %133 = getelementptr inbounds [4 x i32], ptr @dm_totals, i64 0, i64 %indvars.iv
  %spec.select = tail call i32 @llvm.smin.i32(i32 %132, i32 99)
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %spec.select, i32 -99)
  store i32 %spec.store.select, ptr %133, align 4
  br label %134

134:                                              ; preds = %130, %95
  %.3 = phi i32 [ %.067, %95 ], [ %.2.3, %130 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 4
  br i1 %exitcond.not, label %135, label %95, !llvm.loop !9

135:                                              ; preds = %134
  %.not54 = icmp eq i32 %.3, 0
  br i1 %.not54, label %136, label %153

136:                                              ; preds = %135
  tail call void @S_StartSound(ptr noundef null, i32 noundef 82) #3
  %137 = load i32, ptr @dm_state, align 4, !tbaa !5
  %138 = add nsw i32 %137, 1
  store i32 %138, ptr @dm_state, align 4, !tbaa !5
  br label %153

139:                                              ; preds = %.thread, %90
  %140 = phi i32 [ %.pre, %.thread ], [ %1, %90 ]
  %.not52 = icmp eq i32 %140, 0
  br i1 %.not52, label %153, label %141

141:                                              ; preds = %139
  tail call void @S_StartSound(ptr noundef null, i32 noundef 31) #3
  %142 = load i32, ptr @gamemode, align 4, !tbaa !5
  %143 = icmp eq i32 %142, 2
  br i1 %143, label %144, label %145

144:                                              ; preds = %141
  tail call void @WI_initNoState()
  br label %153

145:                                              ; preds = %141
  tail call void @WI_initShowNextLoc()
  br label %153

146:                                              ; preds = %90
  %147 = and i32 %3, 1
  %.not = icmp eq i32 %147, 0
  br i1 %.not, label %153, label %148

148:                                              ; preds = %146
  %149 = load i32, ptr @cnt_pause, align 4, !tbaa !5
  %150 = add nsw i32 %149, -1
  store i32 %150, ptr @cnt_pause, align 4, !tbaa !5
  %.not51 = icmp eq i32 %150, 0
  br i1 %.not51, label %151, label %153

151:                                              ; preds = %148
  %152 = add nsw i32 %3, 1
  store i32 %152, ptr @dm_state, align 4, !tbaa !5
  store i32 35, ptr @cnt_pause, align 4, !tbaa !5
  br label %153

153:                                              ; preds = %144, %145, %139, %148, %151, %146, %135, %136
  ret void
}

declare void @S_StartSound(ptr noundef, i32 noundef) local_unnamed_addr #1

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

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

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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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