; LLVM IR from flashlight/flashlight :: flashlight/pkg/speech/audio/feature/Dct.ll (ZN2fl3lib5audio3DctC2Eii)

; 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.std::allocator" = type { i8 }
%"class.fl::lib::audio::Dct" = type { i32, i32, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2fl3lib5audio3DctC2Eii(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %"class.std::allocator", align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %13 = load ptr, ptr %4, align 8
  %14 = getelementptr inbounds %"class.fl::lib::audio::Dct", ptr %13, i32 0, i32 0
  %15 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %15, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds %"class.fl::lib::audio::Dct", ptr %13, i32 0, i32 1
  %17 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %17, ptr %16, align 4, !tbaa !17
  %18 = getelementptr inbounds %"class.fl::lib::audio::Dct", ptr %13, i32 0, i32 2
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = mul nsw i32 %19, %20
  %22 = sext i32 %21 to i64
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  call void @_ZNSaIfEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #4
  invoke void @_ZNSt6vectorIfSaIfEEC2EmRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %22, ptr noundef nonnull align 1 dereferenceable(1) %7)
          to label %23 unwind label %31

23:                                               ; preds = %3
  call void @_ZNSt15__new_allocatorIfED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store i64 0, ptr %10, align 8, !tbaa !18
  br label %24

24:                                               ; preds = %76, %23
  %25 = load i64, ptr %10, align 8, !tbaa !18
  %26 = getelementptr inbounds %"class.fl::lib::audio::Dct", ptr %13, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = icmp ult i64 %25, %28
  br i1 %29, label %35, label %30

30:                                               ; preds = %24
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %79

31:                                               ; preds = %3
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %8, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %9, align 4
  call void @_ZNSt15__new_allocatorIfED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  br label %80

35:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 0, ptr %12, align 8, !tbaa !18
  br label %36

36:                                               ; preds = %72, %35
  %37 = load i64, ptr %12, align 8, !tbaa !18
  %38 = getelementptr inbounds %"class.fl::lib::audio::Dct", ptr %13, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !17
  %40 = sext i32 %39 to i64
  %41 = icmp ult i64 %37, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %36
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %75

43:                                               ; preds = %36
  %44 = getelementptr inbounds %"class.fl::lib::audio::Dct", ptr %13, i32 0, i32 0
  %45 = load i32, ptr %44, align 8, !tbaa !11
  %46 = sitofp i32 %45 to double
  %47 = fdiv double 2.000000e+00, %46
  %48 = call double @sqrt(double noundef %47) #4
  %49 = load i64, ptr %12, align 8, !tbaa !18
  %50 = uitofp i64 %49 to double
  %51 = fmul double 0x400921FB54442D18, %50
  %52 = load i64, ptr %10, align 8, !tbaa !18
  %53 = uitofp i64 %52 to double
  %54 = fadd double %53, 5.000000e-01
  %55 = fmul double %51, %54
  %56 = getelementptr inbounds %"class.fl::lib::audio::Dct", ptr %13, i32 0, i32 0
  %57 = load i32, ptr %56, align 8, !tbaa !11
  %58 = sitofp i32 %57 to double
  %59 = fdiv double %55, %58
  %60 = call double @cos(double noundef %59) #4
  %61 = fmul double %48, %60
  %62 = fptrunc double %61 to float
  %63 = getelementptr inbounds %"class.fl::lib::audio::Dct", ptr %13, i32 0, i32 2
  %64 = load i64, ptr %10, align 8, !tbaa !18
  %65 = getelementptr inbounds %"class.fl::lib::audio::Dct", ptr %13, i32 0, i32 1
  %66 = load i32, ptr %65, align 4, !tbaa !17
  %67 = sext i32 %66 to i64
  %68 = mul i64 %64, %67
  %69 = load i64, ptr %12, align 8, !tbaa !18
  %70 = add i64 %68, %69
  %71 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %63, i64 noundef %70) #4
  store float %62, ptr %71, align 4, !tbaa !20
  br label %72

72:                                               ; preds = %43
  %73 = load i64, ptr %12, align 8, !tbaa !18
  %74 = add i64 %73, 1
  store i64 %74, ptr %12, align 8, !tbaa !18
  br label %36, !llvm.loop !22

75:                                               ; preds = %42
  br label %76

76:                                               ; preds = %75
  %77 = load i64, ptr %10, align 8, !tbaa !18
  %78 = add i64 %77, 1
  store i64 %78, ptr %10, align 8, !tbaa !18
  br label %24, !llvm.loop !24

79:                                               ; preds = %30
  ret void

80:                                               ; preds = %31
  %81 = load ptr, ptr %8, align 8
  %82 = load i32, ptr %9, align 4
  %83 = insertvalue { ptr, i32 } poison, ptr %81, 0
  %84 = insertvalue { ptr, i32 } %83, i32 %82, 1
  resume { ptr, i32 } %84
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIfEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

; Function Attrs: nounwind
declare double @cos(double noundef) #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIfED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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, !10, i64 0}
!12 = !{!"_ZTSN2fl3lib5audio3DctE", !10, i64 0, !10, i64 4, !13, i64 8}
!13 = !{!"_ZTSSt6vectorIfSaIfEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!12, !10, i64 4}
!18 = !{!19, !19, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"float", !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


; 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.std::allocator" = type { i8 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2fl3lib5audio3DctC2Eii(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::allocator", align 1
  store i32 %1, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %2, ptr %5, align 4, !tbaa !15
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = mul nsw i32 %2, %1
  %8 = sext i32 %7 to i64
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #4
  call void @_ZNSaIfEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #4
  invoke void @_ZNSt6vectorIfSaIfEEC2EmRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %8, ptr noundef nonnull align 1 dereferenceable(1) %4)
          to label %9 unwind label %15

9:                                                ; preds = %3
  call void @_ZNSt15__new_allocatorIfED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #4
  %10 = load i32, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %._crit_edge17, label %.preheader.preheader

.preheader.preheader:                             ; preds = %9
  %.pre = load i32, ptr %5, align 4, !tbaa !15
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %11 = phi i32 [ %17, %._crit_edge ], [ %10, %.preheader.preheader ]
  %12 = phi i32 [ %18, %._crit_edge ], [ %.pre, %.preheader.preheader ]
  %.01416 = phi i64 [ %19, %._crit_edge ], [ 0, %.preheader.preheader ]
  %.not18 = icmp eq i32 %12, 0
  br i1 %.not18, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %13 = uitofp i64 %.01416 to double
  %14 = fadd double %13, 5.000000e-01
  br label %22

._crit_edge17:                                    ; preds = %._crit_edge, %9
  ret void

15:                                               ; preds = %3
  %16 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt15__new_allocatorIfED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #4
  resume { ptr, i32 } %16

._crit_edge.loopexit:                             ; preds = %22
  %.pre19 = load i32, ptr %0, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %17 = phi i32 [ %.pre19, %._crit_edge.loopexit ], [ %11, %.preheader ]
  %18 = phi i32 [ %42, %._crit_edge.loopexit ], [ 0, %.preheader ]
  %19 = add nuw i64 %.01416, 1
  %20 = sext i32 %17 to i64
  %21 = icmp ult i64 %19, %20
  br i1 %21, label %.preheader, label %._crit_edge17, !llvm.loop !16

22:                                               ; preds = %.lr.ph, %22
  %.015 = phi i64 [ 0, %.lr.ph ], [ %41, %22 ]
  %23 = load i32, ptr %0, align 8, !tbaa !5
  %24 = sitofp i32 %23 to double
  %25 = fdiv double 2.000000e+00, %24
  %26 = call double @sqrt(double noundef %25) #4
  %27 = uitofp i64 %.015 to double
  %28 = fmul double %27, 0x400921FB54442D18
  %29 = fmul double %14, %28
  %30 = load i32, ptr %0, align 8, !tbaa !5
  %31 = sitofp i32 %30 to double
  %32 = fdiv double %29, %31
  %33 = call double @cos(double noundef %32) #4
  %34 = fmul double %26, %33
  %35 = fptrunc double %34 to float
  %36 = load i32, ptr %5, align 4, !tbaa !15
  %37 = sext i32 %36 to i64
  %38 = mul i64 %.01416, %37
  %39 = add i64 %38, %.015
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %39) #4
  store float %35, ptr %40, align 4, !tbaa !18
  %41 = add nuw i64 %.015, 1
  %42 = load i32, ptr %5, align 4, !tbaa !15
  %43 = sext i32 %42 to i64
  %44 = icmp ult i64 %41, %43
  br i1 %44, label %22, label %._crit_edge.loopexit, !llvm.loop !20
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIfEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIfED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !7, i64 0}
!6 = !{!"_ZTSN2fl3lib5audio3DctE", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIfSaIfEE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!6, !7, i64 4}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !19, i64 0}
!19 = !{!"float", !8, i64 0}
!20 = distinct !{!20, !17}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass