; LLVM IR from zsiciarz/aquila :: aquila/filter/MelFilter.ll (ZN6Aquila9MelFilter22generateFilterSpectrumEdddm)

; 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::MelFilter" = type { double, %"class.std::vector" }
%"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 }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Aquila9MelFilter22generateFilterSpectrumEdddm(ptr noundef nonnull align 8 dereferenceable(32) %0, double noundef %1, double noundef %2, double noundef %3, i64 noundef %4) #1 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i64, align 8
  %11 = alloca double, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca double, align 8
  %17 = alloca i64, align 8
  %18 = alloca double, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !9
  store double %2, ptr %8, align 8, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !9
  store i64 %4, ptr %10, align 8, !tbaa !11
  %19 = load ptr, ptr %6, align 8
  %20 = getelementptr inbounds %"class.Aquila::MelFilter", ptr %19, i32 0, i32 1
  call void @_ZNSt6vectorIdSaIdEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %20) #4
  %21 = getelementptr inbounds %"class.Aquila::MelFilter", ptr %19, i32 0, i32 1
  %22 = load i64, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store double 0.000000e+00, ptr %11, align 8, !tbaa !9
  call void @_ZNSt6vectorIdSaIdEE6resizeEmRKd(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %22, ptr noundef nonnull align 8 dereferenceable(8) %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %23 = load i64, ptr %10, align 8, !tbaa !11
  %24 = uitofp i64 %23 to double
  %25 = load double, ptr %7, align 8, !tbaa !9
  %26 = fmul double %24, %25
  %27 = getelementptr inbounds %"class.Aquila::MelFilter", ptr %19, i32 0, i32 0
  %28 = load double, ptr %27, align 8, !tbaa !13
  %29 = fdiv double %26, %28
  %30 = fptoui double %29 to i64
  store i64 %30, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %31 = load i64, ptr %10, align 8, !tbaa !11
  %32 = uitofp i64 %31 to double
  %33 = load double, ptr %9, align 8, !tbaa !9
  %34 = fmul double %32, %33
  %35 = getelementptr inbounds %"class.Aquila::MelFilter", ptr %19, i32 0, i32 0
  %36 = load double, ptr %35, align 8, !tbaa !13
  %37 = fdiv double %34, %36
  %38 = fptoui double %37 to i64
  store i64 %38, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %39 = load i64, ptr %10, align 8, !tbaa !11
  %40 = sub i64 %39, 1
  store i64 %40, ptr %14, align 8, !tbaa !11
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %13, ptr noundef nonnull align 8 dereferenceable(8) %14)
  %42 = load i64, ptr %41, align 8, !tbaa !11
  store i64 %42, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  %43 = load i64, ptr %13, align 8, !tbaa !11
  %44 = load i64, ptr %12, align 8, !tbaa !11
  %45 = icmp ule i64 %43, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %5
  store i32 1, ptr %15, align 4
  br label %108

47:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  store double 1.000000e+00, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %48 = load i64, ptr %12, align 8, !tbaa !11
  store i64 %48, ptr %17, align 8, !tbaa !11
  br label %49

49:                                               ; preds = %104, %47
  %50 = load i64, ptr %17, align 8, !tbaa !11
  %51 = load i64, ptr %13, align 8, !tbaa !11
  %52 = icmp ule i64 %50, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %49
  store i32 2, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %107

54:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %55 = load i64, ptr %17, align 8, !tbaa !11
  %56 = uitofp i64 %55 to double
  %57 = getelementptr inbounds %"class.Aquila::MelFilter", ptr %19, i32 0, i32 0
  %58 = load double, ptr %57, align 8, !tbaa !13
  %59 = fmul double %56, %58
  %60 = load i64, ptr %10, align 8, !tbaa !11
  %61 = uitofp i64 %60 to double
  %62 = fdiv double %59, %61
  store double %62, ptr %18, align 8, !tbaa !9
  %63 = load double, ptr %18, align 8, !tbaa !9
  %64 = load double, ptr %7, align 8, !tbaa !9
  %65 = fcmp olt double %63, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %54
  store i32 4, ptr %15, align 4
  br label %101

67:                                               ; preds = %54
  %68 = load double, ptr %18, align 8, !tbaa !9
  %69 = load double, ptr %8, align 8, !tbaa !9
  %70 = fcmp olt double %68, %69
  br i1 %70, label %71, label %83

71:                                               ; preds = %67
  %72 = load double, ptr %18, align 8, !tbaa !9
  %73 = load double, ptr %7, align 8, !tbaa !9
  %74 = fsub double %72, %73
  %75 = fmul double %74, 1.000000e+00
  %76 = load double, ptr %8, align 8, !tbaa !9
  %77 = load double, ptr %7, align 8, !tbaa !9
  %78 = fsub double %76, %77
  %79 = fdiv double %75, %78
  %80 = getelementptr inbounds %"class.Aquila::MelFilter", ptr %19, i32 0, i32 1
  %81 = load i64, ptr %17, align 8, !tbaa !11
  %82 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %80, i64 noundef %81) #4
  store double %79, ptr %82, align 8, !tbaa !9
  br label %100

83:                                               ; preds = %67
  %84 = load double, ptr %18, align 8, !tbaa !9
  %85 = load double, ptr %9, align 8, !tbaa !9
  %86 = fcmp olt double %84, %85
  br i1 %86, label %87, label %99

87:                                               ; preds = %83
  %88 = load double, ptr %9, align 8, !tbaa !9
  %89 = load double, ptr %18, align 8, !tbaa !9
  %90 = fsub double %88, %89
  %91 = fmul double %90, 1.000000e+00
  %92 = load double, ptr %9, align 8, !tbaa !9
  %93 = load double, ptr %8, align 8, !tbaa !9
  %94 = fsub double %92, %93
  %95 = fdiv double %91, %94
  %96 = getelementptr inbounds %"class.Aquila::MelFilter", ptr %19, i32 0, i32 1
  %97 = load i64, ptr %17, align 8, !tbaa !11
  %98 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %96, i64 noundef %97) #4
  store double %95, ptr %98, align 8, !tbaa !9
  br label %99

99:                                               ; preds = %87, %83
  br label %100

100:                                              ; preds = %99, %71
  store i32 0, ptr %15, align 4
  br label %101

101:                                              ; preds = %100, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  %102 = load i32, ptr %15, align 4
  switch i32 %102, label %111 [
    i32 0, label %103
    i32 4, label %104
  ]

103:                                              ; preds = %101
  br label %104

104:                                              ; preds = %103, %101
  %105 = load i64, ptr %17, align 8, !tbaa !11
  %106 = add i64 %105, 1
  store i64 %106, ptr %17, align 8, !tbaa !11
  br label %49, !llvm.loop !19

107:                                              ; preds = %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  store i32 0, ptr %15, align 4
  br label %108

108:                                              ; preds = %107, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %109 = load i32, ptr %15, align 4
  switch i32 %109, label %111 [
    i32 0, label %110
    i32 1, label %110
  ]

110:                                              ; preds = %108, %108
  ret void

111:                                              ; preds = %108, %101
  unreachable
}

; 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 void @_ZNSt6vectorIdSaIdEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

; 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) #2 align 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 = { 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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTSN6Aquila9MelFilterE", !10, i64 0, !15, i64 8}
!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 = distinct !{!19, !20}
!20 = !{!"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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Aquila9MelFilter22generateFilterSpectrumEdddm(ptr noundef nonnull align 8 dereferenceable(32) %0, double noundef %1, double noundef %2, double noundef %3, i64 noundef %4) local_unnamed_addr #1 align 2 {
  %6 = alloca double, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZNSt6vectorIdSaIdEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  store double 0.000000e+00, ptr %6, align 8, !tbaa !5
  call void @_ZNSt6vectorIdSaIdEE6resizeEmRKd(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %4, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  %10 = uitofp i64 %4 to double
  %11 = fmul double %10, %1
  %12 = load double, ptr %0, align 8, !tbaa !9
  %13 = fdiv double %11, %12
  %14 = fptoui double %13 to i64
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %15 = fmul double %10, %3
  %16 = fdiv double %15, %12
  %17 = fptoui double %16 to i64
  store i64 %17, ptr %7, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  %18 = add i64 %4, -1
  store i64 %18, ptr %8, align 8, !tbaa !16
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %20 = load i64, ptr %19, align 8, !tbaa !16
  store i64 %20, ptr %7, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  %.not.not = icmp ugt i64 %20, %14
  br i1 %.not.not, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %5
  %21 = fsub double %3, %2
  %22 = fsub double %2, %1
  br label %23

23:                                               ; preds = %.lr.ph, %40
  %.035 = phi i64 [ %14, %.lr.ph ], [ %41, %40 ]
  %24 = uitofp i64 %.035 to double
  %25 = load double, ptr %0, align 8, !tbaa !9
  %26 = fmul double %25, %24
  %27 = fdiv double %26, %10
  %28 = fcmp olt double %27, %1
  br i1 %28, label %40, label %29

29:                                               ; preds = %23
  %30 = fcmp olt double %27, %2
  br i1 %30, label %31, label %34

31:                                               ; preds = %29
  %32 = fsub double %27, %1
  %33 = fdiv double %32, %22
  br label %.sink.split

34:                                               ; preds = %29
  %35 = fcmp olt double %27, %3
  br i1 %35, label %36, label %40

36:                                               ; preds = %34
  %37 = fsub double %3, %27
  %38 = fdiv double %37, %21
  br label %.sink.split

.sink.split:                                      ; preds = %36, %31
  %.sink = phi double [ %33, %31 ], [ %38, %36 ]
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %.035) #4
  store double %.sink, ptr %39, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %.sink.split, %34, %23
  %41 = add i64 %.035, 1
  %42 = load i64, ptr %7, align 8, !tbaa !16
  %.not33 = icmp ugt i64 %41, %42
  br i1 %.not33, label %.loopexit, label %23, !llvm.loop !18

.loopexit:                                        ; preds = %40, %5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  ret void
}

; Function Attrs: mustprogress 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 void @_ZNSt6vectorIdSaIdEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

; 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 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 = { 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 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN6Aquila9MelFilterE", !6, i64 0, !11, i64 8}
!11 = !{!"_ZTSSt6vectorIdSaIdEE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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