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

; 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::Range" = type { float, float }

; 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 uwtable
define dso_local void @_ZN4juce24AudioVisualiserComponent16getChannelAsPathERNS_4PathEPKNS_5RangeIfEEii(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef nonnull align 8 dereferenceable(41) %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #1 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca float, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  %14 = load ptr, ptr %6, align 8
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = load i32, ptr %9, align 4, !tbaa !9
  %17 = mul nsw i32 4, %16
  %18 = add nsw i32 %17, 8
  call void @_ZN4juce4Path16preallocateSpaceEi(ptr noundef nonnull align 8 dereferenceable(41) %15, i32 noundef %18)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %46, %5
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %49

24:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load i32, ptr %10, align 4, !tbaa !9
  %27 = load i32, ptr %11, align 4, !tbaa !9
  %28 = add nsw i32 %26, %27
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = srem i32 %28, %29
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %"class.juce::Range", ptr %25, i64 %31
  %33 = call noundef float @_ZNK4juce5RangeIfE6getEndEv(ptr noundef nonnull align 4 dereferenceable(8) %32) #4
  %34 = fneg float %33
  store float %34, ptr %12, align 4, !tbaa !11
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %40

37:                                               ; preds = %24
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load float, ptr %12, align 4, !tbaa !11
  call void @_ZN4juce4Path15startNewSubPathEff(ptr noundef nonnull align 8 dereferenceable(41) %38, float noundef 0.000000e+00, float noundef %39)
  br label %45

40:                                               ; preds = %24
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = sitofp i32 %42 to float
  %44 = load float, ptr %12, align 4, !tbaa !11
  call void @_ZN4juce4Path6lineToEff(ptr noundef nonnull align 8 dereferenceable(41) %41, float noundef %43, float noundef %44)
  br label %45

45:                                               ; preds = %40, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %11, align 4, !tbaa !9
  br label %19, !llvm.loop !13

49:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %50 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %50, ptr %13, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %56, %49
  %52 = load i32, ptr %13, align 4, !tbaa !9
  %53 = add nsw i32 %52, -1
  store i32 %53, ptr %13, align 4, !tbaa !9
  %54 = icmp sge i32 %53, 0
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %70

56:                                               ; preds = %51
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = sitofp i32 %58 to float
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = load i32, ptr %10, align 4, !tbaa !9
  %62 = load i32, ptr %13, align 4, !tbaa !9
  %63 = add nsw i32 %61, %62
  %64 = load i32, ptr %9, align 4, !tbaa !9
  %65 = srem i32 %63, %64
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds %"class.juce::Range", ptr %60, i64 %66
  %68 = call noundef float @_ZNK4juce5RangeIfE8getStartEv(ptr noundef nonnull align 4 dereferenceable(8) %67) #4
  %69 = fneg float %68
  call void @_ZN4juce4Path6lineToEff(ptr noundef nonnull align 8 dereferenceable(41) %57, float noundef %59, float noundef %69)
  br label %51, !llvm.loop !15

70:                                               ; preds = %55
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN4juce4Path12closeSubPathEv(ptr noundef nonnull align 8 dereferenceable(41) %71)
  ret void
}

declare void @_ZN4juce4Path16preallocateSpaceEi(ptr noundef nonnull align 8 dereferenceable(41), i32 noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK4juce5RangeIfE6getEndEv(ptr noundef nonnull align 4 dereferenceable(8)) #3 align 2

declare void @_ZN4juce4Path15startNewSubPathEff(ptr noundef nonnull align 8 dereferenceable(41), float noundef, float noundef) #2

declare void @_ZN4juce4Path6lineToEff(ptr noundef nonnull align 8 dereferenceable(41), float noundef, float noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK4juce5RangeIfE8getStartEv(ptr noundef nonnull align 4 dereferenceable(8)) #3 align 2

declare void @_ZN4juce4Path12closeSubPathEv(ptr noundef nonnull align 8 dereferenceable(41)) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { "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 = { 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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

%"class.juce::Range" = type { float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce24AudioVisualiserComponent16getChannelAsPathERNS_4PathEPKNS_5RangeIfEEii(ptr nocapture noundef nonnull readnone align 8 dereferenceable(272) %0, ptr noundef nonnull align 8 dereferenceable(41) %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 align 2 {
  %6 = shl nsw i32 %3, 2
  %7 = add nsw i32 %6, 8
  tail call void @_ZN4juce4Path16preallocateSpaceEi(ptr noundef nonnull align 8 dereferenceable(41) %1, i32 noundef %7)
  %8 = icmp sgt i32 %3, 0
  br i1 %8, label %9, label %._crit_edge

9:                                                ; preds = %5
  %10 = srem i32 %4, %3
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds %"class.juce::Range", ptr %2, i64 %11
  %13 = tail call noundef float @_ZNK4juce5RangeIfE6getEndEv(ptr noundef nonnull align 4 dereferenceable(8) %12) #3
  %14 = fneg float %13
  tail call void @_ZN4juce4Path15startNewSubPathEff(ptr noundef nonnull align 8 dereferenceable(41) %1, float noundef 0.000000e+00, float noundef %14)
  %exitcond.peel.not = icmp eq i32 %3, 1
  br i1 %exitcond.peel.not, label %.lr.ph29.preheader, label %.lr.ph.peel.next

.preheader:                                       ; preds = %.lr.ph.peel.next
  br i1 %8, label %.lr.ph29.preheader, label %._crit_edge

.lr.ph29.preheader:                               ; preds = %9, %.preheader
  br label %.lr.ph29

.lr.ph.peel.next:                                 ; preds = %9, %.lr.ph.peel.next
  %.02427 = phi i32 [ %22, %.lr.ph.peel.next ], [ 1, %9 ]
  %15 = add nsw i32 %.02427, %4
  %16 = srem i32 %15, %3
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds %"class.juce::Range", ptr %2, i64 %17
  %19 = tail call noundef float @_ZNK4juce5RangeIfE6getEndEv(ptr noundef nonnull align 4 dereferenceable(8) %18) #3
  %20 = fneg float %19
  %21 = uitofp nneg i32 %.02427 to float
  tail call void @_ZN4juce4Path6lineToEff(ptr noundef nonnull align 8 dereferenceable(41) %1, float noundef %21, float noundef %20)
  %22 = add nuw nsw i32 %.02427, 1
  %exitcond.not = icmp eq i32 %22, %3
  br i1 %exitcond.not, label %.preheader, label %.lr.ph.peel.next, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph29, %5, %.preheader
  tail call void @_ZN4juce4Path12closeSubPathEv(ptr noundef nonnull align 8 dereferenceable(41) %1)
  ret void

.lr.ph29:                                         ; preds = %.lr.ph29.preheader, %.lr.ph29
  %.028 = phi i32 [ %23, %.lr.ph29 ], [ %3, %.lr.ph29.preheader ]
  %23 = add nsw i32 %.028, -1
  %24 = uitofp nneg i32 %23 to float
  %25 = add nsw i32 %23, %4
  %26 = srem i32 %25, %3
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds %"class.juce::Range", ptr %2, i64 %27
  %29 = tail call noundef float @_ZNK4juce5RangeIfE8getStartEv(ptr noundef nonnull align 4 dereferenceable(8) %28) #3
  %30 = fneg float %29
  tail call void @_ZN4juce4Path6lineToEff(ptr noundef nonnull align 8 dereferenceable(41) %1, float noundef %24, float noundef %30)
  %31 = icmp ugt i32 %.028, 1
  br i1 %31, label %.lr.ph29, label %._crit_edge, !llvm.loop !8
}

declare void @_ZN4juce4Path16preallocateSpaceEi(ptr noundef nonnull align 8 dereferenceable(41), i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK4juce5RangeIfE6getEndEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2 align 2

declare void @_ZN4juce4Path15startNewSubPathEff(ptr noundef nonnull align 8 dereferenceable(41), float noundef, float noundef) local_unnamed_addr #1

declare void @_ZN4juce4Path6lineToEff(ptr noundef nonnull align 8 dereferenceable(41), float noundef, float noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK4juce5RangeIfE8getStartEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2 align 2

declare void @_ZN4juce4Path12closeSubPathEv(ptr noundef nonnull align 8 dereferenceable(41)) local_unnamed_addr #1

attributes #0 = { 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 #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 = { 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 #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 = distinct !{!5, !6, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.peeled.count", i32 1}
!8 = distinct !{!8, !6}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass