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

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

@channels = external hidden global ptr, align 8
@S_sfx = external global [0 x %struct.sfxinfo_struct], align 8
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@snd_SfxVolume = external dso_local global i32, align 4
@players = external global [4 x %struct.player_s], align 16
@consoleplayer = 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

; Function Attrs: nounwind uwtable
define dso_local void @S_StartSoundAtVolume(ptr noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %15, ptr %13, align 8, !tbaa !5
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = icmp slt i32 %16, 1
  br i1 %17, label %21, label %18

18:                                               ; preds = %3
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = icmp sgt i32 %19, 109
  br i1 %20, label %21, label %23

21:                                               ; preds = %18, %3
  %22 = load i32, ptr %5, align 4, !tbaa !9
  call void (ptr, ...) @I_Error(ptr noundef @.str.1, i32 noundef %22) #5
  unreachable

23:                                               ; preds = %18
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [0 x %struct.sfxinfo_struct], ptr @S_sfx, i64 0, i64 %25
  store ptr %26, ptr %11, align 8, !tbaa !5
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.sfxinfo_struct, ptr %27, i32 0, i32 3
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %53

31:                                               ; preds = %23
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.sfxinfo_struct, ptr %32, i32 0, i32 4
  %34 = load i32, ptr %33, align 8, !tbaa !13
  store i32 %34, ptr %9, align 4, !tbaa !9
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.sfxinfo_struct, ptr %35, i32 0, i32 2
  %37 = load i32, ptr %36, align 4, !tbaa !14
  store i32 %37, ptr %10, align 4, !tbaa !9
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.sfxinfo_struct, ptr %38, i32 0, i32 5
  %40 = load i32, ptr %39, align 4, !tbaa !15
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = add nsw i32 %41, %40
  store i32 %42, ptr %6, align 4, !tbaa !9
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = icmp slt i32 %43, 1
  br i1 %44, label %45, label %46

45:                                               ; preds = %31
  store i32 1, ptr %14, align 4
  br label %185

46:                                               ; preds = %31
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = load i32, ptr @snd_SfxVolume, align 4, !tbaa !9
  %49 = icmp sgt i32 %47, %48
  br i1 %49, label %50, label %52

50:                                               ; preds = %46
  %51 = load i32, ptr @snd_SfxVolume, align 4, !tbaa !9
  store i32 %51, ptr %6, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %50, %46
  br label %54

53:                                               ; preds = %23
  store i32 128, ptr %9, align 4, !tbaa !9
  store i32 64, ptr %10, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %53, %52
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %102

57:                                               ; preds = %54
  %58 = load ptr, ptr %13, align 8, !tbaa !5
  %59 = load i32, ptr @consoleplayer, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.player_s, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 16, !tbaa !16
  %64 = icmp ne ptr %58, %63
  br i1 %64, label %65, label %102

65:                                               ; preds = %57
  %66 = load i32, ptr @consoleplayer, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %67
  %69 = getelementptr inbounds %struct.player_s, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 16, !tbaa !16
  %71 = load ptr, ptr %13, align 8, !tbaa !5
  %72 = call i32 @S_AdjustSoundParams(ptr noundef %70, ptr noundef %71, ptr noundef %6, ptr noundef %8, ptr noundef %9)
  store i32 %72, ptr %7, align 4, !tbaa !9
  %73 = load ptr, ptr %13, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.mobj_s, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 8, !tbaa !20
  %76 = load i32, ptr @consoleplayer, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %77
  %79 = getelementptr inbounds %struct.player_s, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 16, !tbaa !16
  %81 = getelementptr inbounds %struct.mobj_s, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 8, !tbaa !20
  %83 = icmp eq i32 %75, %82
  br i1 %83, label %84, label %97

84:                                               ; preds = %65
  %85 = load ptr, ptr %13, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.mobj_s, ptr %85, i32 0, i32 2
  %87 = load i32, ptr %86, align 4, !tbaa !24
  %88 = load i32, ptr @consoleplayer, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %89
  %91 = getelementptr inbounds %struct.player_s, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 16, !tbaa !16
  %93 = getelementptr inbounds %struct.mobj_s, ptr %92, i32 0, i32 2
  %94 = load i32, ptr %93, align 4, !tbaa !24
  %95 = icmp eq i32 %87, %94
  br i1 %95, label %96, label %97

96:                                               ; preds = %84
  store i32 128, ptr %8, align 4, !tbaa !9
  br label %97

97:                                               ; preds = %96, %84, %65
  %98 = load i32, ptr %7, align 4, !tbaa !9
  %99 = icmp ne i32 %98, 0
  br i1 %99, label %101, label %100

100:                                              ; preds = %97
  store i32 1, ptr %14, align 4
  br label %185

101:                                              ; preds = %97
  br label %103

102:                                              ; preds = %57, %54
  store i32 128, ptr %8, align 4, !tbaa !9
  br label %103

103:                                              ; preds = %102, %101
  %104 = load i32, ptr %5, align 4, !tbaa !9
  %105 = icmp sge i32 %104, 10
  br i1 %105, label %106, label %124

106:                                              ; preds = %103
  %107 = load i32, ptr %5, align 4, !tbaa !9
  %108 = icmp sle i32 %107, 13
  br i1 %108, label %109, label %124

109:                                              ; preds = %106
  %110 = call i32 @M_Random()
  %111 = and i32 %110, 15
  %112 = sub nsw i32 8, %111
  %113 = load i32, ptr %9, align 4, !tbaa !9
  %114 = add nsw i32 %113, %112
  store i32 %114, ptr %9, align 4, !tbaa !9
  %115 = load i32, ptr %9, align 4, !tbaa !9
  %116 = icmp slt i32 %115, 0
  br i1 %116, label %117, label %118

117:                                              ; preds = %109
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %123

118:                                              ; preds = %109
  %119 = load i32, ptr %9, align 4, !tbaa !9
  %120 = icmp sgt i32 %119, 255
  br i1 %120, label %121, label %122

121:                                              ; preds = %118
  store i32 255, ptr %9, align 4, !tbaa !9
  br label %122

122:                                              ; preds = %121, %118
  br label %123

123:                                              ; preds = %122, %117
  br label %146

124:                                              ; preds = %106, %103
  %125 = load i32, ptr %5, align 4, !tbaa !9
  %126 = icmp ne i32 %125, 32
  br i1 %126, label %127, label %145

127:                                              ; preds = %124
  %128 = load i32, ptr %5, align 4, !tbaa !9
  %129 = icmp ne i32 %128, 87
  br i1 %129, label %130, label %145

130:                                              ; preds = %127
  %131 = call i32 @M_Random()
  %132 = and i32 %131, 31
  %133 = sub nsw i32 16, %132
  %134 = load i32, ptr %9, align 4, !tbaa !9
  %135 = add nsw i32 %134, %133
  store i32 %135, ptr %9, align 4, !tbaa !9
  %136 = load i32, ptr %9, align 4, !tbaa !9
  %137 = icmp slt i32 %136, 0
  br i1 %137, label %138, label %139

138:                                              ; preds = %130
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %144

139:                                              ; preds = %130
  %140 = load i32, ptr %9, align 4, !tbaa !9
  %141 = icmp sgt i32 %140, 255
  br i1 %141, label %142, label %143

142:                                              ; preds = %139
  store i32 255, ptr %9, align 4, !tbaa !9
  br label %143

143:                                              ; preds = %142, %139
  br label %144

144:                                              ; preds = %143, %138
  br label %145

145:                                              ; preds = %144, %127, %124
  br label %146

146:                                              ; preds = %145, %123
  %147 = load ptr, ptr %13, align 8, !tbaa !5
  call void @S_StopSound(ptr noundef %147)
  %148 = load ptr, ptr %13, align 8, !tbaa !5
  %149 = load ptr, ptr %11, align 8, !tbaa !5
  %150 = call i32 @S_getChannel(ptr noundef %148, ptr noundef %149)
  store i32 %150, ptr %12, align 4, !tbaa !9
  %151 = load i32, ptr %12, align 4, !tbaa !9
  %152 = icmp slt i32 %151, 0
  br i1 %152, label %153, label %154

153:                                              ; preds = %146
  store i32 1, ptr %14, align 4
  br label %185

154:                                              ; preds = %146
  %155 = load ptr, ptr %11, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.sfxinfo_struct, ptr %155, i32 0, i32 8
  %157 = load i32, ptr %156, align 4, !tbaa !25
  %158 = icmp slt i32 %157, 0
  br i1 %158, label %159, label %164

159:                                              ; preds = %154
  %160 = load ptr, ptr %11, align 8, !tbaa !5
  %161 = call i32 @I_GetSfxLumpNum(ptr noundef %160)
  %162 = load ptr, ptr %11, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.sfxinfo_struct, ptr %162, i32 0, i32 8
  store i32 %161, ptr %163, align 4, !tbaa !25
  br label %164

164:                                              ; preds = %159, %154
  %165 = load ptr, ptr %11, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.sfxinfo_struct, ptr %165, i32 0, i32 7
  %167 = load i32, ptr %166, align 8, !tbaa !26
  %168 = add nsw i32 %167, 1
  store i32 %168, ptr %166, align 8, !tbaa !26
  %169 = icmp slt i32 %167, 0
  br i1 %169, label %170, label %173

170:                                              ; preds = %164
  %171 = load ptr, ptr %11, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.sfxinfo_struct, ptr %171, i32 0, i32 7
  store i32 1, ptr %172, align 8, !tbaa !26
  br label %173

173:                                              ; preds = %170, %164
  %174 = load i32, ptr %5, align 4, !tbaa !9
  %175 = load i32, ptr %6, align 4, !tbaa !9
  %176 = load i32, ptr %8, align 4, !tbaa !9
  %177 = load i32, ptr %9, align 4, !tbaa !9
  %178 = load i32, ptr %10, align 4, !tbaa !9
  %179 = call i32 @I_StartSound(i32 noundef %174, i32 noundef %175, i32 noundef %176, i32 noundef %177, i32 noundef %178)
  %180 = load ptr, ptr @channels, align 8, !tbaa !5
  %181 = load i32, ptr %12, align 4, !tbaa !9
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds %struct.channel_t, ptr %180, i64 %182
  %184 = getelementptr inbounds %struct.channel_t, ptr %183, i32 0, i32 2
  store i32 %179, ptr %184, align 8, !tbaa !27
  store i32 0, ptr %14, align 4
  br label %185

185:                                              ; preds = %173, %153, %100, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %186 = load i32, ptr %14, align 4
  switch i32 %186, label %188 [
    i32 0, label %187
    i32 1, label %187
  ]

187:                                              ; preds = %185, %185
  ret void

188:                                              ; preds = %185
  unreachable
}

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

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

declare i32 @M_Random() #3

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

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

declare i32 @I_GetSfxLumpNum(ptr noundef) #3

declare i32 @I_StartSound(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

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 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { noreturn }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"sfxinfo_struct", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !10, i64 24, !10, i64 28, !6, i64 32, !10, i64 40, !10, i64 44}
!13 = !{!12, !10, i64 24}
!14 = !{!12, !10, i64 12}
!15 = !{!12, !10, i64 28}
!16 = !{!17, !6, i64 0}
!17 = !{!"player_s", !6, i64 0, !10, i64 8, !18, i64 12, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !7, i64 48, !7, i64 72, !10, i64 96, !7, i64 100, !10, i64 116, !10, i64 120, !7, i64 124, !7, i64 160, !7, i64 176, !10, i64 192, !10, i64 196, !10, i64 200, !10, i64 204, !10, i64 208, !10, i64 212, !10, i64 216, !6, i64 224, !10, i64 232, !10, i64 236, !6, i64 240, !10, i64 248, !10, i64 252, !10, i64 256, !7, i64 264, !10, i64 312}
!18 = !{!"", !7, i64 0, !7, i64 1, !19, i64 2, !19, i64 4, !7, i64 6, !7, i64 7}
!19 = !{!"short", !7, i64 0}
!20 = !{!21, !10, i64 24}
!21 = !{!"mobj_s", !22, i64 0, !10, i64 24, !10, i64 28, !10, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !6, i64 136, !10, i64 144, !6, i64 152, !10, i64 160, !10, i64 164, !10, i64 168, !10, i64 172, !6, i64 176, !10, i64 184, !10, i64 188, !6, i64 192, !10, i64 200, !23, i64 204, !6, i64 216}
!22 = !{!"thinker_s", !6, i64 0, !6, i64 8, !7, i64 16}
!23 = !{!"", !19, i64 0, !19, i64 2, !19, i64 4, !19, i64 6, !19, i64 8}
!24 = !{!21, !10, i64 28}
!25 = !{!12, !10, i64 44}
!26 = !{!12, !10, i64 40}
!27 = !{!28, !10, i64 16}
!28 = !{!"", !6, i64 0, !6, i64 8, !10, i64 16}


; 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.sfxinfo_struct = type { ptr, i32, i32, ptr, i32, i32, ptr, i32, i32 }
%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.channel_t = type { ptr, ptr, i32 }

@channels = external hidden local_unnamed_addr global ptr, align 8
@S_sfx = external global [0 x %struct.sfxinfo_struct], align 8
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@snd_SfxVolume = external dso_local local_unnamed_addr global i32, align 4
@players = external local_unnamed_addr global [4 x %struct.player_s], align 16
@consoleplayer = external local_unnamed_addr global i32, align 4

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

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

; Function Attrs: nounwind uwtable
define dso_local void @S_StartSoundAtVolume(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %2, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  %7 = add i32 %1, -110
  %or.cond = icmp ult i32 %7, -109
  br i1 %or.cond, label %8, label %9

8:                                                ; preds = %3
  tail call void (ptr, ...) @I_Error(ptr noundef nonnull @.str.1, i32 noundef %1) #5
  unreachable

9:                                                ; preds = %3
  %10 = zext nneg i32 %1 to i64
  %11 = getelementptr inbounds [0 x %struct.sfxinfo_struct], ptr @S_sfx, i64 0, i64 %10
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %27, label %14

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %11, i64 24
  %16 = load i32, ptr %15, align 8, !tbaa !12
  store i32 %16, ptr %6, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %11, i64 12
  %18 = load i32, ptr %17, align 4, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %11, i64 28
  %20 = load i32, ptr %19, align 4, !tbaa !14
  %21 = add nsw i32 %20, %2
  store i32 %21, ptr %4, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 1
  br i1 %22, label %98, label %23

23:                                               ; preds = %14
  %24 = load i32, ptr @snd_SfxVolume, align 4, !tbaa !5
  %25 = icmp sgt i32 %21, %24
  br i1 %25, label %26, label %28

26:                                               ; preds = %23
  store i32 %24, ptr %4, align 4, !tbaa !5
  br label %28

27:                                               ; preds = %9
  store i32 128, ptr %6, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %23, %26, %27
  %.0 = phi i32 [ %18, %26 ], [ %18, %23 ], [ 64, %27 ]
  %.not43 = icmp eq ptr %0, null
  br i1 %.not43, label %53, label %29

29:                                               ; preds = %28
  %30 = load i32, ptr @consoleplayer, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %31
  %33 = load ptr, ptr %32, align 16, !tbaa !15
  %.not44 = icmp eq ptr %33, %0
  br i1 %.not44, label %53, label %34

34:                                               ; preds = %29
  %35 = call i32 @S_AdjustSoundParams(ptr noundef %33, ptr noundef nonnull %0, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %36 = getelementptr inbounds i8, ptr %0, i64 24
  %37 = load i32, ptr %36, align 8, !tbaa !19
  %38 = load i32, ptr @consoleplayer, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %39
  %41 = load ptr, ptr %40, align 16, !tbaa !15
  %42 = getelementptr inbounds i8, ptr %41, i64 24
  %43 = load i32, ptr %42, align 8, !tbaa !19
  %44 = icmp eq i32 %37, %43
  br i1 %44, label %45, label %52

45:                                               ; preds = %34
  %46 = getelementptr inbounds i8, ptr %0, i64 28
  %47 = load i32, ptr %46, align 4, !tbaa !23
  %48 = getelementptr inbounds i8, ptr %41, i64 28
  %49 = load i32, ptr %48, align 4, !tbaa !23
  %50 = icmp eq i32 %47, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %45
  store i32 128, ptr %5, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %51, %45, %34
  %.not45 = icmp eq i32 %35, 0
  br i1 %.not45, label %98, label %54

53:                                               ; preds = %29, %28
  store i32 128, ptr %5, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %52, %53
  %55 = add nsw i32 %1, -10
  %or.cond3 = icmp ult i32 %55, 4
  br i1 %or.cond3, label %56, label %66

56:                                               ; preds = %54
  %57 = call i32 @M_Random() #4
  %58 = and i32 %57, 15
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %reass.sub46 = sub i32 %59, %58
  %60 = add i32 %reass.sub46, 8
  store i32 %60, ptr %6, align 4, !tbaa !5
  %61 = icmp slt i32 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %56
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %77

63:                                               ; preds = %56
  %64 = icmp ugt i32 %60, 255
  br i1 %64, label %65, label %77

65:                                               ; preds = %63
  store i32 255, ptr %6, align 4, !tbaa !5
  br label %77

66:                                               ; preds = %54
  switch i32 %1, label %67 [
    i32 87, label %77
    i32 32, label %77
  ]

67:                                               ; preds = %66
  %68 = call i32 @M_Random() #4
  %69 = and i32 %68, 31
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %reass.sub = sub i32 %70, %69
  %71 = add i32 %reass.sub, 16
  store i32 %71, ptr %6, align 4, !tbaa !5
  %72 = icmp slt i32 %71, 0
  br i1 %72, label %73, label %74

73:                                               ; preds = %67
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %77

74:                                               ; preds = %67
  %75 = icmp ugt i32 %71, 255
  br i1 %75, label %76, label %77

76:                                               ; preds = %74
  store i32 255, ptr %6, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %66, %66, %74, %76, %73, %62, %65, %63
  call void @S_StopSound(ptr noundef %0)
  %78 = call i32 @S_getChannel(ptr noundef %0, ptr noundef nonnull %11)
  %79 = icmp slt i32 %78, 0
  br i1 %79, label %98, label %80

80:                                               ; preds = %77
  %81 = getelementptr inbounds i8, ptr %11, i64 44
  %82 = load i32, ptr %81, align 4, !tbaa !24
  %83 = icmp slt i32 %82, 0
  br i1 %83, label %84, label %86

84:                                               ; preds = %80
  %85 = call i32 @I_GetSfxLumpNum(ptr noundef nonnull %11) #4
  store i32 %85, ptr %81, align 4, !tbaa !24
  br label %86

86:                                               ; preds = %84, %80
  %87 = getelementptr inbounds i8, ptr %11, i64 40
  %88 = load i32, ptr %87, align 8, !tbaa !25
  %89 = add nsw i32 %88, 1
  %90 = icmp slt i32 %88, 0
  %spec.select = select i1 %90, i32 1, i32 %89
  store i32 %spec.select, ptr %87, align 8, !tbaa !25
  %91 = load i32, ptr %4, align 4, !tbaa !5
  %92 = load i32, ptr %5, align 4, !tbaa !5
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = call i32 @I_StartSound(i32 noundef %1, i32 noundef %91, i32 noundef %92, i32 noundef %93, i32 noundef %.0) #4
  %95 = load ptr, ptr @channels, align 8, !tbaa !26
  %96 = zext nneg i32 %78 to i64
  %97 = getelementptr inbounds %struct.channel_t, ptr %95, i64 %96, i32 2
  store i32 %94, ptr %97, align 8, !tbaa !27
  br label %98

98:                                               ; preds = %77, %52, %14, %86
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  ret void
}

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

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

declare i32 @M_Random() local_unnamed_addr #3

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

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

declare i32 @I_GetSfxLumpNum(ptr noundef) local_unnamed_addr #3

declare i32 @I_StartSound(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { noreturn nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 16}
!10 = !{!"sfxinfo_struct", !11, i64 0, !6, i64 8, !6, i64 12, !11, i64 16, !6, i64 24, !6, i64 28, !11, i64 32, !6, i64 40, !6, i64 44}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!10, !6, i64 12}
!14 = !{!10, !6, i64 28}
!15 = !{!16, !11, i64 0}
!16 = !{!"player_s", !11, i64 0, !6, i64 8, !17, 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}
!17 = !{!"", !7, i64 0, !7, i64 1, !18, i64 2, !18, i64 4, !7, i64 6, !7, i64 7}
!18 = !{!"short", !7, i64 0}
!19 = !{!20, !6, i64 24}
!20 = !{!"mobj_s", !21, i64 0, !6, i64 24, !6, i64 28, !6, i64 32, !11, i64 40, !11, i64 48, !6, i64 56, !6, i64 60, !6, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !6, i64 96, !6, i64 100, !6, i64 104, !6, i64 108, !6, i64 112, !6, i64 116, !6, i64 120, !6, i64 124, !6, i64 128, !11, i64 136, !6, i64 144, !11, i64 152, !6, i64 160, !6, i64 164, !6, i64 168, !6, i64 172, !11, i64 176, !6, i64 184, !6, i64 188, !11, i64 192, !6, i64 200, !22, i64 204, !11, i64 216}
!21 = !{!"thinker_s", !11, i64 0, !11, i64 8, !7, i64 16}
!22 = !{!"", !18, i64 0, !18, i64 2, !18, i64 4, !18, i64 6, !18, i64 8}
!23 = !{!20, !6, i64 28}
!24 = !{!10, !6, i64 44}
!25 = !{!10, !6, i64 40}
!26 = !{!11, !11, i64 0}
!27 = !{!28, !6, i64 16}
!28 = !{!"", !11, i64 0, !11, i64 8, !6, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass