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

; 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] }>
%"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 noundef ptr @_ZNK6SoLoud6Soloud32voiceGroupHandleToArray_internalEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) #1

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

declare void @_ZN6SoLoud5Fader3setEffdd(ptr noundef nonnull align 8 dereferenceable(48), float noundef, float noundef, double noundef, double noundef) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud6Soloud10fadeVolumeEjfd(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1, float noundef %2, double noundef %3) #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca double, align 8
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca [2 x i32], align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !11
  store double %3, ptr %8, align 8, !tbaa !13
  %14 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = call noundef float @_ZN6SoLoud6Soloud9getVolumeEj(ptr noundef nonnull align 8 dereferenceable(138833) %14, i32 noundef %15)
  store float %16, ptr %9, align 4, !tbaa !11
  %17 = load double, ptr %8, align 8, !tbaa !13
  %18 = fcmp ole double %17, 0.000000e+00
  br i1 %18, label %23, label %19

19:                                               ; preds = %4
  %20 = load float, ptr %7, align 4, !tbaa !11
  %21 = load float, ptr %9, align 4, !tbaa !11
  %22 = fcmp oeq float %20, %21
  br i1 %22, label %23, label %26

23:                                               ; preds = %19, %4
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = load float, ptr %7, align 4, !tbaa !11
  call void @_ZN6SoLoud6Soloud9setVolumeEjf(ptr noundef nonnull align 8 dereferenceable(138833) %14, i32 noundef %24, float noundef %25)
  store i32 1, ptr %10, align 4
  br label %67

26:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %27 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %27, ptr %12, align 4, !tbaa !9
  %28 = getelementptr inbounds i32, ptr %12, i64 1
  store i32 0, ptr %28, align 4, !tbaa !9
  call void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %14)
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = call noundef ptr @_ZNK6SoLoud6Soloud32voiceGroupHandleToArray_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %14, i32 noundef %29)
  store ptr %30, ptr %11, align 8, !tbaa !5
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %35

33:                                               ; preds = %26
  %34 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 0
  store ptr %34, ptr %11, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %33, %26
  br label %36

36:                                               ; preds = %63, %35
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %66

40:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = call noundef i32 @_ZNK6SoLoud6Soloud27getVoiceFromHandle_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %14, i32 noundef %42)
  store i32 %43, ptr %13, align 4, !tbaa !9
  %44 = load i32, ptr %13, align 4, !tbaa !9
  %45 = icmp ne i32 %44, -1
  br i1 %45, label %46, label %63

46:                                               ; preds = %40
  %47 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %14, i32 0, i32 16
  %48 = load i32, ptr %13, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1024 x ptr], ptr %47, i64 0, i64 %49
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %52 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance", ptr %51, i32 0, i32 16
  %53 = load float, ptr %9, align 4, !tbaa !11
  %54 = load float, ptr %7, align 4, !tbaa !11
  %55 = load double, ptr %8, align 8, !tbaa !13
  %56 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %14, i32 0, i32 16
  %57 = load i32, ptr %13, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [1024 x ptr], ptr %56, i64 0, i64 %58
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance", ptr %60, i32 0, i32 13
  %62 = load double, ptr %61, align 8, !tbaa !15
  call void @_ZN6SoLoud5Fader3setEffdd(ptr noundef nonnull align 8 dereferenceable(48) %52, float noundef %53, float noundef %54, double noundef %55, double noundef %62)
  br label %63

63:                                               ; preds = %46, %40
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = getelementptr inbounds i32, ptr %64, i32 1
  store ptr %65, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %36, !llvm.loop !18

66:                                               ; preds = %36
  call void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %14)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  store i32 0, ptr %10, align 4
  br label %67

67:                                               ; preds = %66, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %68 = load i32, ptr %10, align 4
  switch i32 %68, label %70 [
    i32 0, label %69
    i32 1, label %69
  ]

69:                                               ; preds = %67, %67
  ret void

70:                                               ; preds = %67
  unreachable
}

declare noundef float @_ZN6SoLoud6Soloud9getVolumeEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) #1

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

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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !14, i64 88}
!16 = !{!"_ZTSN6SoLoud19AudioSourceInstanceE", !10, i64 8, !10, i64 12, !10, i64 16, !12, i64 20, !7, i64 24, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !10, i64 72, !12, i64 76, !12, i64 80, !14, i64 88, !14, i64 96, !17, i64 104, !17, i64 152, !17, i64 200, !17, i64 248, !17, i64 296, !10, i64 344, !7, i64 348, !10, i64 380, !10, i64 384, !7, i64 392, !7, i64 456, !10, i64 472, !10, i64 476, !10, i64 480, !14, i64 488}
!17 = !{!"_ZTSN6SoLoud5FaderE", !12, i64 0, !12, i64 4, !12, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !12, i64 40, !10, i64 44}
!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"

; Function Attrs: mustprogress 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)) local_unnamed_addr #1

declare noundef ptr @_ZNK6SoLoud6Soloud32voiceGroupHandleToArray_internalEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) local_unnamed_addr #1

declare noundef i32 @_ZNK6SoLoud6Soloud27getVoiceFromHandle_internalEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) local_unnamed_addr #1

declare void @_ZN6SoLoud5Fader3setEffdd(ptr noundef nonnull align 8 dereferenceable(48), float noundef, float noundef, double noundef, double noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud6Soloud10fadeVolumeEjfd(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1, float noundef %2, double noundef %3) local_unnamed_addr #2 align 2 {
  %5 = alloca [2 x i32], align 4
  %6 = tail call noundef float @_ZN6SoLoud6Soloud9getVolumeEj(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1)
  %7 = fcmp ole double %3, 0.000000e+00
  %8 = fcmp oeq float %6, %2
  %or.cond = or i1 %7, %8
  br i1 %or.cond, label %9, label %10

9:                                                ; preds = %4
  tail call void @_ZN6SoLoud6Soloud9setVolumeEjf(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1, float noundef %2)
  br label %29

10:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  store i32 %1, ptr %5, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 0, ptr %11, align 4, !tbaa !5
  tail call void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %0)
  %12 = tail call noundef ptr @_ZNK6SoLoud6Soloud32voiceGroupHandleToArray_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1)
  %13 = icmp eq ptr %12, null
  %spec.select = select i1 %13, ptr %5, ptr %12
  %14 = load i32, ptr %spec.select, align 4, !tbaa !5
  %.not25 = icmp eq i32 %14, 0
  br i1 %.not25, label %._crit_edge, label %.lr.ph

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

16:                                               ; preds = %.lr.ph, %26
  %17 = phi i32 [ %14, %.lr.ph ], [ %28, %26 ]
  %.126 = phi ptr [ %spec.select, %.lr.ph ], [ %27, %26 ]
  %18 = tail call noundef i32 @_ZNK6SoLoud6Soloud27getVoiceFromHandle_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %17)
  %.not24 = icmp eq i32 %18, -1
  br i1 %.not24, label %26, label %19

19:                                               ; preds = %16
  %20 = sext i32 %18 to i64
  %21 = getelementptr inbounds [1024 x ptr], ptr %15, i64 0, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %22, i64 152
  %24 = getelementptr inbounds i8, ptr %22, i64 88
  %25 = load double, ptr %24, align 8, !tbaa !11
  tail call void @_ZN6SoLoud5Fader3setEffdd(ptr noundef nonnull align 8 dereferenceable(48) %23, float noundef %6, float noundef %2, double noundef %3, double noundef %25)
  br label %26

26:                                               ; preds = %19, %16
  %27 = getelementptr inbounds i8, ptr %.126, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %.not = icmp eq i32 %28, 0
  br i1 %.not, label %._crit_edge, label %16, !llvm.loop !16

._crit_edge:                                      ; preds = %26, %10
  tail call void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %0)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  br label %29

29:                                               ; preds = %._crit_edge, %9
  ret void
}

declare noundef float @_ZN6SoLoud6Soloud9getVolumeEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !14, i64 88}
!12 = !{!"_ZTSN6SoLoud19AudioSourceInstanceE", !6, i64 8, !6, i64 12, !6, i64 16, !13, i64 20, !7, i64 24, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68, !6, i64 72, !13, i64 76, !13, i64 80, !14, i64 88, !14, i64 96, !15, i64 104, !15, i64 152, !15, i64 200, !15, i64 248, !15, i64 296, !6, i64 344, !7, i64 348, !6, i64 380, !6, i64 384, !7, i64 392, !7, i64 456, !6, i64 472, !6, i64 476, !6, i64 480, !14, i64 488}
!13 = !{!"float", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"_ZTSN6SoLoud5FaderE", !13, i64 0, !13, i64 4, !13, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !13, i64 40, !6, i64 44}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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