; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode (juce_audio_basics)

; 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.juce::ToneGeneratorAudioSource" = type <{ %"class.juce::AudioSource", double, double, double, double, float, [4 x i8] }>
%"class.juce::AudioSource" = type { ptr }
%"struct.juce::AudioSourceChannelInfo" = type { ptr, i32, i32 }

; 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: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce11AudioBufferIfE14getNumChannelsEv(ptr noundef nonnull align 8 dereferenceable(289)) #1 align 2

; Function Attrs: nounwind
declare double @sin(double noundef) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4juce24ToneGeneratorAudioSource17getNextAudioBlockERKNS_22AudioSourceChannelInfoE(ptr noundef nonnull align 8 dereferenceable(44) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  %10 = getelementptr inbounds %"class.juce::ToneGeneratorAudioSource", ptr %9, i32 0, i32 4
  %11 = load double, ptr %10, align 8, !tbaa !9
  %12 = fcmp oeq double %11, 0.000000e+00
  br i1 %12, label %13, label %21

13:                                               ; preds = %2
  %14 = getelementptr inbounds %"class.juce::ToneGeneratorAudioSource", ptr %9, i32 0, i32 2
  %15 = load double, ptr %14, align 8, !tbaa !14
  %16 = getelementptr inbounds %"class.juce::ToneGeneratorAudioSource", ptr %9, i32 0, i32 1
  %17 = load double, ptr %16, align 8, !tbaa !15
  %18 = fdiv double %15, %17
  %19 = fdiv double 0x401921FB54442D18, %18
  %20 = getelementptr inbounds %"class.juce::ToneGeneratorAudioSource", ptr %9, i32 0, i32 4
  store double %19, ptr %20, align 8, !tbaa !9
  br label %21

21:                                               ; preds = %13, %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !16
  br label %22

22:                                               ; preds = %63, %21
  %23 = load i32, ptr %5, align 4, !tbaa !16
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.juce::AudioSourceChannelInfo", ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 4, !tbaa !18
  %27 = icmp slt i32 %23, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %22
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %66

29:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %30 = getelementptr inbounds %"class.juce::ToneGeneratorAudioSource", ptr %9, i32 0, i32 5
  %31 = load float, ptr %30, align 8, !tbaa !20
  %32 = getelementptr inbounds %"class.juce::ToneGeneratorAudioSource", ptr %9, i32 0, i32 3
  %33 = load double, ptr %32, align 8, !tbaa !21
  %34 = call double @sin(double noundef %33) #3
  %35 = fptrunc double %34 to float
  %36 = fmul float %31, %35
  store float %36, ptr %7, align 4, !tbaa !22
  %37 = getelementptr inbounds %"class.juce::ToneGeneratorAudioSource", ptr %9, i32 0, i32 4
  %38 = load double, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds %"class.juce::ToneGeneratorAudioSource", ptr %9, i32 0, i32 3
  %40 = load double, ptr %39, align 8, !tbaa !21
  %41 = fadd double %40, %38
  store double %41, ptr %39, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.juce::AudioSourceChannelInfo", ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !23
  %45 = call noundef i32 @_ZNK4juce11AudioBufferIfE14getNumChannelsEv(ptr noundef nonnull align 8 dereferenceable(289) %44) #3
  store i32 %45, ptr %8, align 4, !tbaa !16
  br label %46

46:                                               ; preds = %51, %29
  %47 = load i32, ptr %8, align 4, !tbaa !16
  %48 = add nsw i32 %47, -1
  store i32 %48, ptr %8, align 4, !tbaa !16
  %49 = icmp sge i32 %48, 0
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %62

51:                                               ; preds = %46
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.juce::AudioSourceChannelInfo", ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !23
  %55 = load i32, ptr %8, align 4, !tbaa !16
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.juce::AudioSourceChannelInfo", ptr %56, i32 0, i32 1
  %58 = load i32, ptr %57, align 8, !tbaa !24
  %59 = load i32, ptr %5, align 4, !tbaa !16
  %60 = add nsw i32 %58, %59
  %61 = load float, ptr %7, align 4, !tbaa !22
  call void @_ZN4juce11AudioBufferIfE9setSampleEiif(ptr noundef nonnull align 8 dereferenceable(289) %54, i32 noundef %55, i32 noundef %60, float noundef %61) #3
  br label %46, !llvm.loop !25

62:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %5, align 4, !tbaa !16
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %5, align 4, !tbaa !16
  br label %22, !llvm.loop !27

66:                                               ; preds = %28
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce11AudioBufferIfE9setSampleEiif(ptr noundef nonnull align 8 dereferenceable(289), i32 noundef, i32 noundef, float noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nounwind "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, !12, i64 32}
!10 = !{!"_ZTSN4juce24ToneGeneratorAudioSourceE", !11, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !13, i64 40}
!11 = !{!"_ZTSN4juce11AudioSourceE"}
!12 = !{!"double", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!10, !12, i64 16}
!15 = !{!10, !12, i64 8}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!19, !17, i64 12}
!19 = !{!"_ZTSN4juce22AudioSourceChannelInfoE", !6, i64 0, !17, i64 8, !17, i64 12}
!20 = !{!10, !13, i64 40}
!21 = !{!10, !12, i64 24}
!22 = !{!13, !13, i64 0}
!23 = !{!19, !6, i64 0}
!24 = !{!19, !17, i64 8}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26}


; 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 nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce11AudioBufferIfE14getNumChannelsEv(ptr noundef nonnull align 8 dereferenceable(289)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4juce24ToneGeneratorAudioSource17getNextAudioBlockERKNS_22AudioSourceChannelInfoE(ptr nocapture noundef nonnull align 8 dereferenceable(44) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = fcmp oeq double %4, 0.000000e+00
  br i1 %5, label %6, label %13

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load double, ptr %7, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load double, ptr %9, align 8, !tbaa !13
  %11 = fdiv double %8, %10
  %12 = fdiv double 0x401921FB54442D18, %11
  store double %12, ptr %3, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %6, %2
  %14 = getelementptr inbounds i8, ptr %1, i64 12
  %15 = load i32, ptr %14, align 4, !tbaa !14
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph15, label %._crit_edge16

.lr.ph15:                                         ; preds = %13
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %19 = getelementptr inbounds i8, ptr %1, i64 8
  br label %20

._crit_edge16:                                    ; preds = %._crit_edge, %13
  ret void

20:                                               ; preds = %.lr.ph15, %._crit_edge
  %.01013 = phi i32 [ 0, %.lr.ph15 ], [ %32, %._crit_edge ]
  %21 = load float, ptr %17, align 8, !tbaa !18
  %22 = load double, ptr %18, align 8, !tbaa !19
  %23 = tail call double @sin(double noundef %22) #2
  %24 = fptrunc double %23 to float
  %25 = fmul float %21, %24
  %26 = load double, ptr %3, align 8, !tbaa !5
  %27 = load double, ptr %18, align 8, !tbaa !19
  %28 = fadd double %26, %27
  store double %28, ptr %18, align 8, !tbaa !19
  %29 = load ptr, ptr %1, align 8, !tbaa !20
  %30 = tail call noundef i32 @_ZNK4juce11AudioBufferIfE14getNumChannelsEv(ptr noundef nonnull align 8 dereferenceable(289) %29) #2
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %20
  %32 = add nuw nsw i32 %.01013, 1
  %33 = load i32, ptr %14, align 4, !tbaa !14
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %20, label %._crit_edge16, !llvm.loop !21

.lr.ph:                                           ; preds = %20, %.lr.ph
  %.012 = phi i32 [ %35, %.lr.ph ], [ %30, %20 ]
  %35 = add nsw i32 %.012, -1
  %36 = load ptr, ptr %1, align 8, !tbaa !20
  %37 = load i32, ptr %19, align 8, !tbaa !23
  %38 = add nsw i32 %37, %.01013
  tail call void @_ZN4juce11AudioBufferIfE9setSampleEiif(ptr noundef nonnull align 8 dereferenceable(289) %36, i32 noundef %35, i32 noundef %38, float noundef %25) #2
  %39 = icmp ugt i32 %.012, 1
  br i1 %39, label %.lr.ph, label %._crit_edge, !llvm.loop !24
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce11AudioBufferIfE9setSampleEiif(ptr noundef nonnull align 8 dereferenceable(289), i32 noundef, i32 noundef, float noundef) local_unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn memory(write) "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 = { 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, !8, i64 32}
!6 = !{!"_ZTSN4juce24ToneGeneratorAudioSourceE", !7, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !11, i64 40}
!7 = !{!"_ZTSN4juce11AudioSourceE"}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"float", !9, i64 0}
!12 = !{!6, !8, i64 16}
!13 = !{!6, !8, i64 8}
!14 = !{!15, !17, i64 12}
!15 = !{!"_ZTSN4juce22AudioSourceChannelInfoE", !16, i64 0, !17, i64 8, !17, i64 12}
!16 = !{!"any pointer", !9, i64 0}
!17 = !{!"int", !9, i64 0}
!18 = !{!6, !11, i64 40}
!19 = !{!6, !8, i64 24}
!20 = !{!15, !16, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!15, !17, i64 8}
!24 = distinct !{!24, !22}


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