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

; 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::AudioSource" = type { ptr, i32, float, float, i32, i32, float, float, float, i32, float, [8 x ptr], ptr, ptr, ptr, i32, double }
%"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] }>
%"class.SoLoud::AudioSourceInstance" = type { ptr, i32, i32, i32, float, [8 x float], float, float, float, float, i32, float, float, double, double, %"class.SoLoud::Fader", %"class.SoLoud::Fader", %"class.SoLoud::Fader", %"class.SoLoud::Fader", %"class.SoLoud::Fader", i32, [8 x float], i32, i32, [8 x ptr], [2 x ptr], i32, i32, i32, double }

; 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 @_ZN6SoLoud6Soloud15stopAudioSourceERNS_11AudioSourceE(ptr noundef nonnull align 8 dereferenceable(138833) %0, ptr noundef nonnull align 8 dereferenceable(152) %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %"class.SoLoud::AudioSource", ptr %7, i32 0, i32 5
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %43

11:                                               ; preds = %2
  call void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !14
  br label %12

12:                                               ; preds = %39, %11
  %13 = load i32, ptr %5, align 4, !tbaa !14
  %14 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %6, i32 0, i32 8
  %15 = load i32, ptr %14, align 4, !tbaa !15
  %16 = icmp slt i32 %13, %15
  br i1 %16, label %17, label %42

17:                                               ; preds = %12
  %18 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %6, i32 0, i32 16
  %19 = load i32, ptr %5, align 4, !tbaa !14
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [1024 x ptr], ptr %18, i64 0, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %38

24:                                               ; preds = %17
  %25 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %6, i32 0, i32 16
  %26 = load i32, ptr %5, align 4, !tbaa !14
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [1024 x ptr], ptr %25, i64 0, i64 %27
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance", ptr %29, i32 0, i32 22
  %31 = load i32, ptr %30, align 4, !tbaa !20
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %"class.SoLoud::AudioSource", ptr %32, i32 0, i32 5
  %34 = load i32, ptr %33, align 8, !tbaa !9
  %35 = icmp eq i32 %31, %34
  br i1 %35, label %36, label %38

36:                                               ; preds = %24
  %37 = load i32, ptr %5, align 4, !tbaa !14
  call void @_ZN6SoLoud6Soloud18stopVoice_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %6, i32 noundef %37)
  br label %38

38:                                               ; preds = %36, %24, %17
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %5, align 4, !tbaa !14
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %5, align 4, !tbaa !14
  br label %12, !llvm.loop !22

42:                                               ; preds = %12
  call void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %43

43:                                               ; preds = %42, %2
  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, !11, i64 24}
!10 = !{!"_ZTSN6SoLoud11AudioSourceE", !11, i64 8, !12, i64 12, !12, i64 16, !11, i64 20, !11, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !11, i64 40, !12, i64 44, !7, i64 48, !6, i64 112, !6, i64 120, !6, i64 128, !11, i64 136, !13, i64 144}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!16, !11, i64 52}
!16 = !{!"_ZTSN6SoLoud6SoloudE", !6, i64 0, !6, i64 8, !17, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !11, i64 52, !18, i64 56, !11, i64 80, !18, i64 88, !6, i64 112, !18, i64 120, !6, i64 144, !7, i64 152, !11, i64 8344, !11, i64 8348, !11, i64 8352, !11, i64 8356, !6, i64 8360, !11, i64 8368, !11, i64 8372, !12, i64 8376, !12, i64 8380, !11, i64 8384, !11, i64 8388, !19, i64 8392, !13, i64 8440, !13, 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, !12, i64 11736, !7, i64 11740, !7, i64 11840, !6, i64 134720, !11, i64 134728, !7, i64 134732, !11, i64 138828, !17, i64 138832}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTSN6SoLoud18AlignedFloatBufferE", !6, i64 0, !6, i64 8, !11, i64 16}
!19 = !{!"_ZTSN6SoLoud5FaderE", !12, i64 0, !12, i64 4, !12, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !12, i64 40, !11, i64 44}
!20 = !{!21, !11, i64 380}
!21 = !{!"_ZTSN6SoLoud19AudioSourceInstanceE", !11, i64 8, !11, i64 12, !11, i64 16, !12, i64 20, !7, i64 24, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !11, i64 72, !12, i64 76, !12, i64 80, !13, i64 88, !13, i64 96, !19, i64 104, !19, i64 152, !19, i64 200, !19, i64 248, !19, i64 296, !11, i64 344, !7, i64 348, !11, i64 380, !11, i64 384, !7, i64 392, !7, i64 456, !11, i64 472, !11, i64 476, !11, i64 480, !13, i64 488}
!22 = distinct !{!22, !23}
!23 = !{!"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 @_ZN6SoLoud6Soloud15stopAudioSourceERNS_11AudioSourceE(ptr noundef nonnull align 8 dereferenceable(138833) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(152) %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 24
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %25, label %5

5:                                                ; preds = %2
  tail call void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %0)
  %6 = getelementptr inbounds i8, ptr %0, i64 52
  %7 = load i32, ptr %6, align 4, !tbaa !13
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 152
  br label %10

10:                                               ; preds = %.lr.ph, %21
  %11 = phi i32 [ %7, %.lr.ph ], [ %22, %21 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %21 ]
  %12 = getelementptr inbounds [1024 x ptr], ptr %9, i64 0, i64 %indvars.iv
  %13 = load ptr, ptr %12, align 8, !tbaa !18
  %.not8 = icmp eq ptr %13, null
  br i1 %.not8, label %21, label %14

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %13, i64 380
  %16 = load i32, ptr %15, align 4, !tbaa !19
  %17 = load i32, ptr %3, align 8, !tbaa !5
  %18 = icmp eq i32 %16, %17
  br i1 %18, label %19, label %21

19:                                               ; preds = %14
  %20 = trunc nuw nsw i64 %indvars.iv to i32
  tail call void @_ZN6SoLoud6Soloud18stopVoice_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %20)
  %.pre = load i32, ptr %6, align 4, !tbaa !13
  br label %21

21:                                               ; preds = %10, %14, %19
  %22 = phi i32 [ %11, %10 ], [ %11, %14 ], [ %.pre, %19 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = sext i32 %22 to i64
  %24 = icmp slt i64 %indvars.iv.next, %23
  br i1 %24, label %10, label %._crit_edge, !llvm.loop !21

._crit_edge:                                      ; preds = %21, %5
  tail call void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %0)
  br label %25

25:                                               ; preds = %._crit_edge, %2
  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, !7, i64 24}
!6 = !{!"_ZTSN6SoLoud11AudioSourceE", !7, i64 8, !10, i64 12, !10, i64 16, !7, i64 20, !7, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !7, i64 40, !10, i64 44, !8, i64 48, !11, i64 112, !11, i64 120, !11, i64 128, !7, i64 136, !12, i64 144}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"double", !8, i64 0}
!13 = !{!14, !7, i64 52}
!14 = !{!"_ZTSN6SoLoud6SoloudE", !11, i64 0, !11, i64 8, !15, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !7, i64 48, !7, i64 52, !16, i64 56, !7, i64 80, !16, i64 88, !11, i64 112, !16, i64 120, !11, i64 144, !8, i64 152, !7, i64 8344, !7, i64 8348, !7, i64 8352, !7, i64 8356, !11, i64 8360, !7, i64 8368, !7, i64 8372, !10, i64 8376, !10, i64 8380, !7, i64 8384, !7, i64 8388, !17, i64 8392, !12, i64 8440, !12, 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, !10, i64 11736, !8, i64 11740, !8, i64 11840, !11, i64 134720, !7, i64 134728, !8, i64 134732, !7, i64 138828, !15, i64 138832}
!15 = !{!"bool", !8, i64 0}
!16 = !{!"_ZTSN6SoLoud18AlignedFloatBufferE", !11, i64 0, !11, i64 8, !7, i64 16}
!17 = !{!"_ZTSN6SoLoud5FaderE", !10, i64 0, !10, i64 4, !10, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !10, i64 40, !7, i64 44}
!18 = !{!11, !11, i64 0}
!19 = !{!20, !7, i64 380}
!20 = !{!"_ZTSN6SoLoud19AudioSourceInstanceE", !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 20, !8, i64 24, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !7, i64 72, !10, i64 76, !10, i64 80, !12, i64 88, !12, i64 96, !17, i64 104, !17, i64 152, !17, i64 200, !17, i64 248, !17, i64 296, !7, i64 344, !8, i64 348, !7, i64 380, !7, i64 384, !8, i64 392, !8, i64 456, !7, i64 472, !7, i64 476, !7, i64 480, !12, i64 488}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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