; LLVM IR from kacperks/Fractal_Engine :: Engine/Thirdparty/cmake/Engine/Thirdparty/cmake/openal-soft/common/polyphase/7cc64d80 (ZN15PPhaseResampler4initEjj)

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

%struct.PPhaseResampler = type { i32, i32, i32, i32, %"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: mustprogress uwtable
define dso_local void @_ZN15PPhaseResampler4initEjj(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %1, i32 noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = call noundef i32 @_ZN12_GLOBAL__N_13GcdEjj(i32 noundef %14, i32 noundef %15)
  store i32 %16, ptr %7, align 4, !tbaa !9
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = udiv i32 %17, %18
  %20 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 0
  store i32 %19, ptr %20, align 8, !tbaa !11
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = udiv i32 %21, %22
  %24 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 1
  store i32 %23, ptr %24, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %25 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 0
  %26 = load i32, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !17
  %29 = icmp ugt i32 %26, %28
  br i1 %29, label %30, label %39

30:                                               ; preds = %3
  %31 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !11
  %33 = uitofp i32 %32 to double
  %34 = fdiv double 4.750000e-01, %33
  store double %34, ptr %8, align 8, !tbaa !18
  %35 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !11
  %37 = uitofp i32 %36 to double
  %38 = fdiv double 5.000000e-02, %37
  store double %38, ptr %9, align 8, !tbaa !18
  br label %48

39:                                               ; preds = %3
  %40 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 1
  %41 = load i32, ptr %40, align 4, !tbaa !17
  %42 = uitofp i32 %41 to double
  %43 = fdiv double 4.750000e-01, %42
  store double %43, ptr %8, align 8, !tbaa !18
  %44 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !17
  %46 = uitofp i32 %45 to double
  %47 = fdiv double 5.000000e-02, %46
  store double %47, ptr %9, align 8, !tbaa !18
  br label %48

48:                                               ; preds = %39, %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %49 = load double, ptr %9, align 8, !tbaa !18
  %50 = call noundef i32 @_ZN12_GLOBAL__N_115CalcKaiserOrderEdd(double noundef 1.800000e+02, double noundef %49)
  %51 = add i32 %50, 1
  %52 = udiv i32 %51, 2
  store i32 %52, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %53 = call noundef double @_ZN12_GLOBAL__N_114CalcKaiserBetaEd(double noundef 1.800000e+02)
  store double %53, ptr %11, align 8, !tbaa !18
  %54 = load i32, ptr %10, align 4, !tbaa !9
  %55 = mul i32 %54, 2
  %56 = add i32 %55, 1
  %57 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 2
  store i32 %56, ptr %57, align 8, !tbaa !20
  %58 = load i32, ptr %10, align 4, !tbaa !9
  %59 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 3
  store i32 %58, ptr %59, align 4, !tbaa !21
  %60 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 4
  %61 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 2
  %62 = load i32, ptr %61, align 8, !tbaa !20
  %63 = zext i32 %62 to i64
  call void @_ZNSt6vectorIdSaIdEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %60, i64 noundef %63)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %82, %48
  %65 = load i32, ptr %12, align 4, !tbaa !9
  %66 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 2
  %67 = load i32, ptr %66, align 8, !tbaa !20
  %68 = icmp ult i32 %65, %67
  br i1 %68, label %70, label %69

69:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %85

70:                                               ; preds = %64
  %71 = load i32, ptr %10, align 4, !tbaa !9
  %72 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 0
  %73 = load i32, ptr %72, align 8, !tbaa !11
  %74 = uitofp i32 %73 to double
  %75 = load double, ptr %8, align 8, !tbaa !18
  %76 = load i32, ptr %12, align 4, !tbaa !9
  %77 = call noundef double @_ZN12_GLOBAL__N_110SincFilterEjdddj(i32 noundef %71, double noundef 0x4032E0941C8216C7, double noundef %74, double noundef %75, i32 noundef %76)
  %78 = getelementptr inbounds %struct.PPhaseResampler, ptr %13, i32 0, i32 4
  %79 = load i32, ptr %12, align 4, !tbaa !9
  %80 = zext i32 %79 to i64
  %81 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %78, i64 noundef %80) #3
  store double %77, ptr %81, align 8, !tbaa !18
  br label %82

82:                                               ; preds = %70
  %83 = load i32, ptr %12, align 4, !tbaa !9
  %84 = add i32 %83, 1
  store i32 %84, ptr %12, align 4, !tbaa !9
  br label %64, !llvm.loop !22

85:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

; 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 hidden noundef i32 @_ZN12_GLOBAL__N_13GcdEjj(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN12_GLOBAL__N_115CalcKaiserOrderEdd(double noundef, double noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZN12_GLOBAL__N_114CalcKaiserBetaEd(double noundef) #2

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

; Function Attrs: mustprogress uwtable
declare hidden noundef double @_ZN12_GLOBAL__N_110SincFilterEjdddj(i32 noundef, double noundef, double noundef, double noundef, i32 noundef) #0

; 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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 }

!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 = !{!"_ZTS15PPhaseResampler", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !13, i64 16}
!13 = !{!"_ZTSSt6vectorIdSaIdEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!12, !10, i64 4}
!18 = !{!19, !19, i64 0}
!19 = !{!"double", !7, i64 0}
!20 = !{!12, !10, i64 8}
!21 = !{!12, !10, i64 12}
!22 = distinct !{!22, !23}
!23 = !{!"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 uwtable
define dso_local void @_ZN15PPhaseResampler4initEjj(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = tail call noundef i32 @_ZN12_GLOBAL__N_13GcdEjj(i32 noundef %1, i32 noundef %2)
  %5 = udiv i32 %2, %4
  store i32 %5, ptr %0, align 8, !tbaa !5
  %6 = udiv i32 %1, %4
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %6, ptr %7, align 4, !tbaa !15
  %. = tail call i32 @llvm.umax.i32(i32 %5, i32 %6)
  %.pn = uitofp i32 %. to double
  %.015 = fdiv double 4.750000e-01, %.pn
  %.016 = fdiv double 5.000000e-02, %.pn
  %8 = tail call noundef i32 @_ZN12_GLOBAL__N_115CalcKaiserOrderEdd(double noundef 1.800000e+02, double noundef %.016)
  %9 = add i32 %8, 1
  %10 = lshr i32 %9, 1
  %11 = tail call noundef double @_ZN12_GLOBAL__N_114CalcKaiserBetaEd(double noundef 1.800000e+02)
  %12 = or i32 %9, 1
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %12, ptr %13, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %10, ptr %14, align 4, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = zext i32 %12 to i64
  tail call void @_ZNSt6vectorIdSaIdEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %16)
  %17 = load i32, ptr %13, align 8, !tbaa !16
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %3
  ret void

.lr.ph:                                           ; preds = %3, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %3 ]
  %18 = load i32, ptr %0, align 8, !tbaa !5
  %19 = uitofp i32 %18 to double
  %20 = trunc nuw i64 %indvars.iv to i32
  %21 = tail call noundef double @_ZN12_GLOBAL__N_110SincFilterEjdddj(i32 noundef %10, double noundef 0x4032E0941C8216C7, double noundef %19, double noundef %.015, i32 noundef %20)
  %22 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %indvars.iv) #3
  store double %21, ptr %22, align 8, !tbaa !18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr %13, align 8, !tbaa !16
  %24 = zext i32 %23 to i64
  %25 = icmp ult i64 %indvars.iv.next, %24
  br i1 %25, label %.lr.ph, label %._crit_edge, !llvm.loop !20
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN12_GLOBAL__N_13GcdEjj(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN12_GLOBAL__N_115CalcKaiserOrderEdd(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZN12_GLOBAL__N_114CalcKaiserBetaEd(double noundef) local_unnamed_addr #1

; 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: mustprogress uwtable
declare hidden noundef double @_ZN12_GLOBAL__N_110SincFilterEjdddj(i32 noundef, double noundef, double noundef, double noundef, i32 noundef) local_unnamed_addr #0

; 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 #1 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #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 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"_ZTS15PPhaseResampler", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIdSaIdEE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!6, !7, i64 4}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !7, i64 12}
!18 = !{!19, !19, i64 0}
!19 = !{!"double", !8, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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