; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/core/soloud_core_basicops.ll (ZN6SoLoud6Soloud7stopAllEv)

; 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"

%"class.SoLoud::Soloud" = type <{ ptr, ptr, i8, [7 x i8], ptr, ptr, ptr, i32, i32, %"class.SoLoud::AlignedFloatBuffer", i32, [4 x i8], %"class.SoLoud::AlignedFloatBuffer", ptr, %"class.SoLoud::AlignedFloatBuffer", ptr, [1024 x ptr], i32, i32, i32, i32, ptr, i32, i32, float, float, i32, i32, %"class.SoLoud::Fader", double, double, [8 x ptr], [8 x ptr], [8 x float], [256 x float], [256 x float], [256 x float], [3 x float], [3 x float], [3 x float], [3 x float], float, [24 x float], [4 x i8], [1024 x %"class.SoLoud::AudioSourceInstance3dData"], ptr, i32, [1024 x i32], i32, i8, [7 x i8] }>
%"class.SoLoud::AlignedFloatBuffer" = type <{ ptr, ptr, i32, [4 x i8] }>
%"class.SoLoud::Fader" = type { float, float, float, double, double, double, float, i32 }
%"class.SoLoud::AudioSourceInstance3dData" = type <{ [3 x float], [3 x float], float, float, float, i32, float, [4 x i8], ptr, ptr, i32, float, float, [8 x float], i32, i32, [4 x i8] }>

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

declare void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833)) #1

declare void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833)) #1

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

declare void @_ZN6SoLoud6Soloud18stopVoice_internalEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud6Soloud7stopAllEv(ptr noundef nonnull align 8 dereferenceable(138833) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %4)
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %12, %1
  %6 = load i32, ptr %3, align 4, !tbaa !9
  %7 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %4, i32 0, i32 8
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = icmp slt i32 %6, %8
  br i1 %9, label %10, label %15

10:                                               ; preds = %5
  %11 = load i32, ptr %3, align 4, !tbaa !9
  call void @_ZN6SoLoud6Soloud18stopVoice_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %4, i32 noundef %11)
  br label %12

12:                                               ; preds = %10
  %13 = load i32, ptr %3, align 4, !tbaa !9
  %14 = add nsw i32 %13, 1
  store i32 %14, ptr %3, align 4, !tbaa !9
  br label %5, !llvm.loop !18

15:                                               ; preds = %5
  call void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 52}
!12 = !{!"_ZTSN6SoLoud6SoloudE", !6, i64 0, !6, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !14, i64 56, !10, i64 80, !14, i64 88, !6, i64 112, !14, i64 120, !6, i64 144, !7, i64 152, !10, i64 8344, !10, i64 8348, !10, i64 8352, !10, i64 8356, !6, i64 8360, !10, i64 8368, !10, i64 8372, !15, i64 8376, !15, i64 8380, !10, i64 8384, !10, i64 8388, !16, i64 8392, !17, i64 8440, !17, i64 8448, !7, i64 8456, !7, i64 8520, !7, i64 8584, !7, i64 8616, !7, i64 9640, !7, i64 10664, !7, i64 11688, !7, i64 11700, !7, i64 11712, !7, i64 11724, !15, i64 11736, !7, i64 11740, !7, i64 11840, !6, i64 134720, !10, i64 134728, !7, i64 134732, !10, i64 138828, !13, i64 138832}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN6SoLoud18AlignedFloatBufferE", !6, i64 0, !6, i64 8, !10, i64 16}
!15 = !{!"float", !7, i64 0}
!16 = !{!"_ZTSN6SoLoud5FaderE", !15, i64 0, !15, i64 4, !15, i64 8, !17, i64 16, !17, i64 24, !17, i64 32, !15, i64 40, !10, i64 44}
!17 = !{!"double", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; 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"

declare void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833)) local_unnamed_addr #0

declare void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833)) local_unnamed_addr #0

declare void @_ZN6SoLoud6Soloud18stopVoice_internalEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud6Soloud7stopAllEv(ptr noundef nonnull align 8 dereferenceable(138833) %0) local_unnamed_addr #1 align 2 {
  tail call void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 52
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.03 = phi i32 [ %5, %.lr.ph ], [ 0, %1 ]
  tail call void @_ZN6SoLoud6Soloud18stopVoice_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %.03)
  %5 = add nuw nsw i32 %.03, 1
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = icmp slt i32 %5, %6
  br i1 %7, label %.lr.ph, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph, %1
  tail call void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %0)
  ret void
}

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

!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, !11, i64 52}
!6 = !{!"_ZTSN6SoLoud6SoloudE", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !11, i64 48, !11, i64 52, !12, i64 56, !11, i64 80, !12, i64 88, !7, i64 112, !12, i64 120, !7, i64 144, !8, i64 152, !11, i64 8344, !11, i64 8348, !11, i64 8352, !11, i64 8356, !7, i64 8360, !11, i64 8368, !11, i64 8372, !13, i64 8376, !13, i64 8380, !11, i64 8384, !11, i64 8388, !14, i64 8392, !15, i64 8440, !15, i64 8448, !8, i64 8456, !8, i64 8520, !8, i64 8584, !8, i64 8616, !8, i64 9640, !8, i64 10664, !8, i64 11688, !8, i64 11700, !8, i64 11712, !8, i64 11724, !13, i64 11736, !8, i64 11740, !8, i64 11840, !7, i64 134720, !11, i64 134728, !8, i64 134732, !11, i64 138828, !10, i64 138832}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"_ZTSN6SoLoud18AlignedFloatBufferE", !7, i64 0, !7, i64 8, !11, i64 16}
!13 = !{!"float", !8, i64 0}
!14 = !{!"_ZTSN6SoLoud5FaderE", !13, i64 0, !13, i64 4, !13, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !13, i64 40, !11, i64 44}
!15 = !{!"double", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass