; LLVM IR from zsiciarz/aquila :: aquila/source/generator/PinkNoiseGenerator.ll (ZN6Aquila18PinkNoiseGenerator8generateEm)

; 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.Aquila::SignalSource" = type { ptr, %"class.std::vector", double }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.Aquila::PinkNoiseGenerator" = type { %"class.Aquila::Generator", [20 x double], i32, i32 }
%"class.Aquila::Generator" = type { %"class.Aquila::SignalSource", double, double, double }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Aquila18PinkNoiseGenerator8generateEm(ptr noundef nonnull align 8 dereferenceable(232) %0, i64 noundef %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  %8 = getelementptr inbounds %"class.Aquila::SignalSource", ptr %7, i32 0, i32 1
  %9 = load i64, ptr %4, align 8, !tbaa !9
  call void @_ZNSt6vectorIdSaIdEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %9)
  %10 = getelementptr inbounds %"class.Aquila::PinkNoiseGenerator", ptr %7, i32 0, i32 3
  store i32 65535, ptr %10, align 4, !tbaa !11
  %11 = getelementptr inbounds %"class.Aquila::PinkNoiseGenerator", ptr %7, i32 0, i32 2
  store i32 0, ptr %11, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %22, %2
  %13 = load i64, ptr %5, align 8, !tbaa !9
  %14 = icmp ult i64 %13, 20
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %25

16:                                               ; preds = %12
  %17 = call noundef double @_ZN6Aquila12randomDoubleEv()
  %18 = fsub double %17, 5.000000e-01
  %19 = getelementptr inbounds %"class.Aquila::PinkNoiseGenerator", ptr %7, i32 0, i32 1
  %20 = load i64, ptr %5, align 8, !tbaa !9
  %21 = getelementptr inbounds [20 x double], ptr %19, i64 0, i64 %20
  store double %18, ptr %21, align 8, !tbaa !22
  br label %22

22:                                               ; preds = %16
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = add i64 %23, 1
  store i64 %24, ptr %5, align 8, !tbaa !9
  br label %12, !llvm.loop !23

25:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %26

26:                                               ; preds = %39, %25
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = load i64, ptr %4, align 8, !tbaa !9
  %29 = icmp ult i64 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %42

31:                                               ; preds = %26
  %32 = getelementptr inbounds %"class.Aquila::Generator", ptr %7, i32 0, i32 2
  %33 = load double, ptr %32, align 8, !tbaa !25
  %34 = call noundef double @_ZN6Aquila18PinkNoiseGenerator10pinkSampleEv(ptr noundef nonnull align 8 dereferenceable(232) %7)
  %35 = fmul double %33, %34
  %36 = getelementptr inbounds %"class.Aquila::SignalSource", ptr %7, i32 0, i32 1
  %37 = load i64, ptr %6, align 8, !tbaa !9
  %38 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %36, i64 noundef %37) #4
  store double %35, ptr %38, align 8, !tbaa !22
  br label %39

39:                                               ; preds = %31
  %40 = load i64, ptr %6, align 8, !tbaa !9
  %41 = add i64 %40, 1
  store i64 %41, ptr %6, align 8, !tbaa !9
  br label %26, !llvm.loop !26

42:                                               ; preds = %30
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIdSaIdEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZN6Aquila12randomDoubleEv() #2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN6Aquila18PinkNoiseGenerator10pinkSampleEv(ptr noundef nonnull align 8 dereferenceable(232)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !20, i64 228}
!12 = !{!"_ZTSN6Aquila18PinkNoiseGeneratorE", !13, i64 0, !7, i64 64, !20, i64 224, !20, i64 228}
!13 = !{!"_ZTSN6Aquila9GeneratorE", !14, i64 0, !19, i64 40, !19, i64 48, !19, i64 56}
!14 = !{!"_ZTSN6Aquila12SignalSourceE", !15, i64 8, !19, i64 32}
!15 = !{!"_ZTSSt6vectorIdSaIdEE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"double", !7, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = !{!12, !20, i64 224}
!22 = !{!19, !19, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!13, !19, i64 48}
!26 = distinct !{!26, !24}


; 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 uwtable
define dso_local void @_ZN6Aquila18PinkNoiseGenerator8generateEm(ptr noundef nonnull align 8 dereferenceable(232) %0, i64 noundef %1) unnamed_addr #0 align 2 {
.preheader:
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZNSt6vectorIdSaIdEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %1)
  %3 = getelementptr inbounds i8, ptr %0, i64 228
  store i32 65535, ptr %3, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 224
  store i32 0, ptr %4, align 8, !tbaa !18
  %5 = getelementptr inbounds i8, ptr %0, i64 64
  %6 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %7 = fadd double %6, -5.000000e-01
  store double %7, ptr %5, align 8, !tbaa !19
  %8 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %9 = fadd double %8, -5.000000e-01
  %10 = getelementptr inbounds i8, ptr %0, i64 72
  store double %9, ptr %10, align 8, !tbaa !19
  %11 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %12 = fadd double %11, -5.000000e-01
  %13 = getelementptr inbounds i8, ptr %0, i64 80
  store double %12, ptr %13, align 8, !tbaa !19
  %14 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %15 = fadd double %14, -5.000000e-01
  %16 = getelementptr inbounds i8, ptr %0, i64 88
  store double %15, ptr %16, align 8, !tbaa !19
  %17 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %18 = fadd double %17, -5.000000e-01
  %19 = getelementptr inbounds i8, ptr %0, i64 96
  store double %18, ptr %19, align 8, !tbaa !19
  %20 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %21 = fadd double %20, -5.000000e-01
  %22 = getelementptr inbounds i8, ptr %0, i64 104
  store double %21, ptr %22, align 8, !tbaa !19
  %23 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %24 = fadd double %23, -5.000000e-01
  %25 = getelementptr inbounds i8, ptr %0, i64 112
  store double %24, ptr %25, align 8, !tbaa !19
  %26 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %27 = fadd double %26, -5.000000e-01
  %28 = getelementptr inbounds i8, ptr %0, i64 120
  store double %27, ptr %28, align 8, !tbaa !19
  %29 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %30 = fadd double %29, -5.000000e-01
  %31 = getelementptr inbounds i8, ptr %0, i64 128
  store double %30, ptr %31, align 8, !tbaa !19
  %32 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %33 = fadd double %32, -5.000000e-01
  %34 = getelementptr inbounds i8, ptr %0, i64 136
  store double %33, ptr %34, align 8, !tbaa !19
  %35 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %36 = fadd double %35, -5.000000e-01
  %37 = getelementptr inbounds i8, ptr %0, i64 144
  store double %36, ptr %37, align 8, !tbaa !19
  %38 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %39 = fadd double %38, -5.000000e-01
  %40 = getelementptr inbounds i8, ptr %0, i64 152
  store double %39, ptr %40, align 8, !tbaa !19
  %41 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %42 = fadd double %41, -5.000000e-01
  %43 = getelementptr inbounds i8, ptr %0, i64 160
  store double %42, ptr %43, align 8, !tbaa !19
  %44 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %45 = fadd double %44, -5.000000e-01
  %46 = getelementptr inbounds i8, ptr %0, i64 168
  store double %45, ptr %46, align 8, !tbaa !19
  %47 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %48 = fadd double %47, -5.000000e-01
  %49 = getelementptr inbounds i8, ptr %0, i64 176
  store double %48, ptr %49, align 8, !tbaa !19
  %50 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %51 = fadd double %50, -5.000000e-01
  %52 = getelementptr inbounds i8, ptr %0, i64 184
  store double %51, ptr %52, align 8, !tbaa !19
  %53 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %54 = fadd double %53, -5.000000e-01
  %55 = getelementptr inbounds i8, ptr %0, i64 192
  store double %54, ptr %55, align 8, !tbaa !19
  %56 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %57 = fadd double %56, -5.000000e-01
  %58 = getelementptr inbounds i8, ptr %0, i64 200
  store double %57, ptr %58, align 8, !tbaa !19
  %59 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %60 = fadd double %59, -5.000000e-01
  %61 = getelementptr inbounds i8, ptr %0, i64 208
  store double %60, ptr %61, align 8, !tbaa !19
  %62 = tail call noundef double @_ZN6Aquila12randomDoubleEv()
  %63 = fadd double %62, -5.000000e-01
  %64 = getelementptr inbounds i8, ptr %0, i64 216
  store double %63, ptr %64, align 8, !tbaa !19
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %65 = getelementptr inbounds i8, ptr %0, i64 48
  br label %66

._crit_edge:                                      ; preds = %66, %.preheader
  ret void

66:                                               ; preds = %.lr.ph, %66
  %.010 = phi i64 [ 0, %.lr.ph ], [ %71, %66 ]
  %67 = load double, ptr %65, align 8, !tbaa !20
  %68 = tail call noundef double @_ZN6Aquila18PinkNoiseGenerator10pinkSampleEv(ptr noundef nonnull align 8 dereferenceable(232) %0)
  %69 = fmul double %67, %68
  %70 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.010) #3
  store double %69, ptr %70, align 8, !tbaa !19
  %71 = add nuw i64 %.010, 1
  %exitcond.not = icmp eq i64 %71, %1
  br i1 %exitcond.not, label %._crit_edge, label %66, !llvm.loop !21
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIdSaIdEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZN6Aquila12randomDoubleEv() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN6Aquila18PinkNoiseGenerator10pinkSampleEv(ptr noundef nonnull align 8 dereferenceable(232)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

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 = { 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 #2 = { 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 = !{!6, !17, i64 228}
!6 = !{!"_ZTSN6Aquila18PinkNoiseGeneratorE", !7, i64 0, !14, i64 64, !17, i64 224, !17, i64 228}
!7 = !{!"_ZTSN6Aquila9GeneratorE", !8, i64 0, !16, i64 40, !16, i64 48, !16, i64 56}
!8 = !{!"_ZTSN6Aquila12SignalSourceE", !9, i64 8, !16, i64 32}
!9 = !{!"_ZTSSt6vectorIdSaIdEE", !10, i64 0}
!10 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !11, i64 0}
!11 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !13, i64 0, !13, i64 8, !13, i64 16}
!13 = !{!"any pointer", !14, i64 0}
!14 = !{!"omnipotent char", !15, i64 0}
!15 = !{!"Simple C++ TBAA"}
!16 = !{!"double", !14, i64 0}
!17 = !{!"int", !14, i64 0}
!18 = !{!6, !17, i64 224}
!19 = !{!16, !16, i64 0}
!20 = !{!7, !16, i64 48}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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