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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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: mustprogress uwtable
define dso_local noundef ptr @_ZN6SoLoud3Bus7calcFFTEv(ptr noundef nonnull align 8 dereferenceable(2216) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca [1024 x float], align 16
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  %8 = getelementptr inbounds %"class.SoLoud::Bus", ptr %7, i32 0, i32 1
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %83

11:                                               ; preds = %1
  %12 = getelementptr inbounds %"class.SoLoud::AudioSource", ptr %7, i32 0, i32 12
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %83

15:                                               ; preds = %11
  %16 = getelementptr inbounds %"class.SoLoud::AudioSource", ptr %7, i32 0, i32 12
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  call void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %17)
  call void @llvm.lifetime.start.p0(i64 4096, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !16
  br label %18

18:                                               ; preds = %46, %15
  %19 = load i32, ptr %4, align 4, !tbaa !16
  %20 = icmp slt i32 %19, 256
  br i1 %20, label %21, label %49

21:                                               ; preds = %18
  %22 = getelementptr inbounds %"class.SoLoud::Bus", ptr %7, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %"class.SoLoud::BusInstance", ptr %23, i32 0, i32 6
  %25 = load i32, ptr %4, align 4, !tbaa !16
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [256 x float], ptr %24, i64 0, i64 %26
  %28 = load float, ptr %27, align 4, !tbaa !17
  %29 = load i32, ptr %4, align 4, !tbaa !16
  %30 = mul nsw i32 %29, 2
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [1024 x float], ptr %3, i64 0, i64 %31
  store float %28, ptr %32, align 4, !tbaa !17
  %33 = load i32, ptr %4, align 4, !tbaa !16
  %34 = mul nsw i32 %33, 2
  %35 = add nsw i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [1024 x float], ptr %3, i64 0, i64 %36
  store float 0.000000e+00, ptr %37, align 4, !tbaa !17
  %38 = load i32, ptr %4, align 4, !tbaa !16
  %39 = add nsw i32 %38, 512
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [1024 x float], ptr %3, i64 0, i64 %40
  store float 0.000000e+00, ptr %41, align 4, !tbaa !17
  %42 = load i32, ptr %4, align 4, !tbaa !16
  %43 = add nsw i32 %42, 768
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [1024 x float], ptr %3, i64 0, i64 %44
  store float 0.000000e+00, ptr %45, align 4, !tbaa !17
  br label %46

46:                                               ; preds = %21
  %47 = load i32, ptr %4, align 4, !tbaa !16
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %4, align 4, !tbaa !16
  br label %18, !llvm.loop !18

49:                                               ; preds = %18
  %50 = getelementptr inbounds %"class.SoLoud::AudioSource", ptr %7, i32 0, i32 12
  %51 = load ptr, ptr %50, align 8, !tbaa !15
  call void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %51)
  %52 = getelementptr inbounds [1024 x float], ptr %3, i64 0, i64 0
  call void @_ZN6SoLoud3FFT7fft1024EPf(ptr noundef %52)
  store i32 0, ptr %4, align 4, !tbaa !16
  br label %53

53:                                               ; preds = %79, %49
  %54 = load i32, ptr %4, align 4, !tbaa !16
  %55 = icmp slt i32 %54, 256
  br i1 %55, label %56, label %82

56:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %57 = load i32, ptr %4, align 4, !tbaa !16
  %58 = mul nsw i32 %57, 2
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [1024 x float], ptr %3, i64 0, i64 %59
  %61 = load float, ptr %60, align 4, !tbaa !17
  store float %61, ptr %5, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %62 = load i32, ptr %4, align 4, !tbaa !16
  %63 = mul nsw i32 %62, 2
  %64 = add nsw i32 %63, 1
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1024 x float], ptr %3, i64 0, i64 %65
  %67 = load float, ptr %66, align 4, !tbaa !17
  store float %67, ptr %6, align 4, !tbaa !17
  %68 = load float, ptr %5, align 4, !tbaa !17
  %69 = load float, ptr %5, align 4, !tbaa !17
  %70 = load float, ptr %6, align 4, !tbaa !17
  %71 = load float, ptr %6, align 4, !tbaa !17
  %72 = fmul float %70, %71
  %73 = call float @llvm.fmuladd.f32(float %68, float %69, float %72)
  %74 = call noundef float @_ZSt4sqrtf(float noundef %73)
  %75 = getelementptr inbounds %"class.SoLoud::Bus", ptr %7, i32 0, i32 4
  %76 = load i32, ptr %4, align 4, !tbaa !16
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [256 x float], ptr %75, i64 0, i64 %77
  store float %74, ptr %78, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %79

79:                                               ; preds = %56
  %80 = load i32, ptr %4, align 4, !tbaa !16
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %4, align 4, !tbaa !16
  br label %53, !llvm.loop !20

82:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4096, ptr %3) #5
  br label %83

83:                                               ; preds = %82, %11, %1
  %84 = getelementptr inbounds %"class.SoLoud::Bus", ptr %7, i32 0, i32 4
  %85 = getelementptr inbounds [256 x float], ptr %84, i64 0, i64 0
  ret ptr %85
}

declare void @_ZN6SoLoud3FFT7fft1024EPf(ptr noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #4

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 = { inlinehint mustprogress 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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, !6, i64 152}
!10 = !{!"_ZTSN6SoLoud3BusE", !11, i64 0, !6, i64 152, !12, i64 160, !12, i64 164, !7, i64 168, !7, i64 1192}
!11 = !{!"_ZTSN6SoLoud11AudioSourceE", !12, i64 8, !13, i64 12, !13, i64 16, !12, i64 20, !12, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !12, i64 40, !13, i64 44, !7, i64 48, !6, i64 112, !6, i64 120, !6, i64 128, !12, i64 136, !14, i64 144}
!12 = !{!"int", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!11, !6, i64 112}
!16 = !{!12, !12, i64 0}
!17 = !{!13, !13, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN6SoLoud3Bus7calcFFTEv(ptr noundef nonnull align 8 dereferenceable(2216) %0) local_unnamed_addr #2 align 2 {
  %2 = alloca [1024 x float], align 16
  %3 = getelementptr inbounds i8, ptr %0, i64 152
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %37, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 112
  %7 = load ptr, ptr %6, align 8, !tbaa !14
  %.not17 = icmp eq ptr %7, null
  br i1 %.not17, label %37, label %8

8:                                                ; preds = %5
  tail call void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %7)
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %2) #5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 568
  br label %11

11:                                               ; preds = %8, %11
  %indvars.iv = phi i64 [ 0, %8 ], [ %indvars.iv.next, %11 ]
  %12 = getelementptr inbounds [256 x float], ptr %10, i64 0, i64 %indvars.iv
  %13 = load float, ptr %12, align 4, !tbaa !15
  %14 = shl nuw nsw i64 %indvars.iv, 1
  %15 = getelementptr inbounds [1024 x float], ptr %2, i64 0, i64 %14
  store float %13, ptr %15, align 8, !tbaa !15
  %16 = or disjoint i64 %14, 1
  %17 = getelementptr inbounds [1024 x float], ptr %2, i64 0, i64 %16
  store float 0.000000e+00, ptr %17, align 4, !tbaa !15
  %18 = or disjoint i64 %indvars.iv, 512
  %19 = getelementptr inbounds [1024 x float], ptr %2, i64 0, i64 %18
  store float 0.000000e+00, ptr %19, align 4, !tbaa !15
  %20 = or disjoint i64 %indvars.iv, 768
  %21 = getelementptr inbounds [1024 x float], ptr %2, i64 0, i64 %20
  store float 0.000000e+00, ptr %21, align 4, !tbaa !15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 256
  br i1 %exitcond.not, label %22, label %11, !llvm.loop !16

22:                                               ; preds = %11
  %23 = load ptr, ptr %6, align 8, !tbaa !14
  tail call void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %23)
  call void @_ZN6SoLoud3FFT7fft1024EPf(ptr noundef nonnull %2)
  %24 = getelementptr inbounds i8, ptr %0, i64 168
  br label %25

25:                                               ; preds = %22, %25
  %indvars.iv21 = phi i64 [ 0, %22 ], [ %indvars.iv.next22, %25 ]
  %26 = shl nuw nsw i64 %indvars.iv21, 1
  %27 = getelementptr inbounds [1024 x float], ptr %2, i64 0, i64 %26
  %28 = load float, ptr %27, align 8, !tbaa !15
  %29 = or disjoint i64 %26, 1
  %30 = getelementptr inbounds [1024 x float], ptr %2, i64 0, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !15
  %32 = fmul float %31, %31
  %33 = call float @llvm.fmuladd.f32(float %28, float %28, float %32)
  %34 = call noundef float @_ZSt4sqrtf(float noundef %33)
  %35 = getelementptr inbounds [256 x float], ptr %24, i64 0, i64 %indvars.iv21
  store float %34, ptr %35, align 4, !tbaa !15
  %indvars.iv.next22 = add nuw nsw i64 %indvars.iv21, 1
  %exitcond24.not = icmp eq i64 %indvars.iv.next22, 256
  br i1 %exitcond24.not, label %36, label %25, !llvm.loop !18

36:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %2) #5
  br label %37

37:                                               ; preds = %36, %5, %1
  %38 = getelementptr inbounds i8, ptr %0, i64 168
  ret ptr %38
}

declare void @_ZN6SoLoud3FFT7fft1024EPf(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #4

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 = { inlinehint mustprogress 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 #4 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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, !12, i64 152}
!6 = !{!"_ZTSN6SoLoud3BusE", !7, i64 0, !12, i64 152, !8, i64 160, !8, i64 164, !9, i64 168, !9, i64 1192}
!7 = !{!"_ZTSN6SoLoud11AudioSourceE", !8, i64 8, !11, i64 12, !11, i64 16, !8, i64 20, !8, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !8, i64 40, !11, i64 44, !9, i64 48, !12, i64 112, !12, i64 120, !12, i64 128, !8, i64 136, !13, i64 144}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"float", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"double", !9, i64 0}
!14 = !{!7, !12, i64 112}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass