; LLVM IR from sp-nitech/SPTK :: third_party/REAPER/epoch_tracker (fd_filter)

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

; 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 @_ZN4sptk6reaper8FdFilter21RationalApproximationEfPiS2_i(ptr noundef nonnull align 8 dereferenceable(144) %0, float noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #1 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store float %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !11
  %22 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store float 1.000000e+00, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store float 1.000000e+00, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %23 = load float, ptr %7, align 4, !tbaa !9
  %24 = call noundef float @_ZSt4fabsf(float noundef %23)
  store float %24, ptr %11, align 4, !tbaa !9
  %25 = load float, ptr %11, align 4, !tbaa !9
  %26 = fptosi float %25 to i32
  store i32 %26, ptr %19, align 4, !tbaa !11
  %27 = load i32, ptr %19, align 4, !tbaa !11
  store i32 %27, ptr %21, align 4, !tbaa !11
  %28 = load float, ptr %11, align 4, !tbaa !9
  %29 = load i32, ptr %21, align 4, !tbaa !11
  %30 = sitofp i32 %29 to float
  %31 = fsub float %28, %30
  store float %31, ptr %12, align 4, !tbaa !9
  store float 0.000000e+00, ptr %13, align 4, !tbaa !9
  store float 1.000000e+00, ptr %14, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %61, %5
  %33 = load float, ptr %13, align 4, !tbaa !9
  %34 = fadd float %33, 1.000000e+00
  store float %34, ptr %13, align 4, !tbaa !9
  %35 = load i32, ptr %10, align 4, !tbaa !11
  %36 = sitofp i32 %35 to float
  %37 = fcmp ole float %34, %36
  br i1 %37, label %38, label %62

38:                                               ; preds = %32
  %39 = load float, ptr %13, align 4, !tbaa !9
  %40 = load float, ptr %12, align 4, !tbaa !9
  %41 = fmul float %39, %40
  store float %41, ptr %17, align 4, !tbaa !9
  %42 = load float, ptr %17, align 4, !tbaa !9
  %43 = fpext float %42 to double
  %44 = fadd double %43, 5.000000e-01
  %45 = fptosi double %44 to i32
  store i32 %45, ptr %20, align 4, !tbaa !11
  %46 = load float, ptr %17, align 4, !tbaa !9
  %47 = load i32, ptr %20, align 4, !tbaa !11
  %48 = sitofp i32 %47 to float
  %49 = fsub float %46, %48
  %50 = load float, ptr %13, align 4, !tbaa !9
  %51 = fdiv float %49, %50
  %52 = call noundef float @_ZSt4fabsf(float noundef %51)
  store float %52, ptr %18, align 4, !tbaa !9
  %53 = load float, ptr %18, align 4, !tbaa !9
  %54 = load float, ptr %14, align 4, !tbaa !9
  %55 = fcmp olt float %53, %54
  br i1 %55, label %56, label %61

56:                                               ; preds = %38
  %57 = load float, ptr %18, align 4, !tbaa !9
  store float %57, ptr %14, align 4, !tbaa !9
  %58 = load i32, ptr %20, align 4, !tbaa !11
  %59 = sitofp i32 %58 to float
  store float %59, ptr %16, align 4, !tbaa !9
  %60 = load float, ptr %13, align 4, !tbaa !9
  store float %60, ptr %15, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %56, %38
  br label %32, !llvm.loop !13

62:                                               ; preds = %32
  %63 = load i32, ptr %19, align 4, !tbaa !11
  %64 = sitofp i32 %63 to float
  %65 = load float, ptr %15, align 4, !tbaa !9
  %66 = load float, ptr %16, align 4, !tbaa !9
  %67 = call float @llvm.fmuladd.f32(float %64, float %65, float %66)
  %68 = fptosi float %67 to i32
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %68, ptr %69, align 4, !tbaa !11
  %70 = load float, ptr %7, align 4, !tbaa !9
  %71 = fcmp ogt float %70, 0.000000e+00
  br i1 %71, label %72, label %75

72:                                               ; preds = %62
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load i32, ptr %73, align 4, !tbaa !11
  br label %79

75:                                               ; preds = %62
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = load i32, ptr %76, align 4, !tbaa !11
  %78 = sub nsw i32 0, %77
  br label %79

79:                                               ; preds = %75, %72
  %80 = phi i32 [ %74, %72 ], [ %78, %75 ]
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %80, ptr %81, align 4, !tbaa !11
  %82 = load float, ptr %15, align 4, !tbaa !9
  %83 = fptosi float %82 to i32
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %83, ptr %84, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4fabsf(float noundef) #3

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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 nounwind uwtable
define dso_local void @_ZN4sptk6reaper8FdFilter21RationalApproximationEfPiS2_i(ptr nocapture noundef nonnull readnone align 8 dereferenceable(144) %0, float noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3, i32 noundef %4) local_unnamed_addr #0 align 2 {
  %6 = tail call noundef float @_ZSt4fabsf(float noundef %1)
  %7 = fptosi float %6 to i32
  %8 = sitofp i32 %7 to float
  %9 = fsub float %6, %8
  %10 = sitofp i32 %4 to float
  %11 = icmp slt i32 %4, 1
  br i1 %11, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5, %.lr.ph
  %12 = phi float [ %22, %.lr.ph ], [ 1.000000e+00, %5 ]
  %.02837 = phi float [ %.1, %.lr.ph ], [ 1.000000e+00, %5 ]
  %.02936 = phi float [ %.130, %.lr.ph ], [ 1.000000e+00, %5 ]
  %.03135 = phi float [ %.132, %.lr.ph ], [ 1.000000e+00, %5 ]
  %13 = fmul float %9, %12
  %14 = fpext float %13 to double
  %15 = fadd double %14, 5.000000e-01
  %16 = fptosi double %15 to i32
  %17 = sitofp i32 %16 to float
  %18 = fsub float %13, %17
  %19 = fdiv float %18, %12
  %20 = tail call noundef float @_ZSt4fabsf(float noundef %19)
  %21 = fcmp olt float %20, %.02837
  %.132 = select i1 %21, float %17, float %.03135
  %.130 = select i1 %21, float %12, float %.02936
  %.1 = select i1 %21, float %20, float %.02837
  %22 = fadd float %12, 1.000000e+00
  %23 = fcmp ugt float %22, %10
  br i1 %23, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %5
  %.031.lcssa = phi float [ 1.000000e+00, %5 ], [ %.132, %.lr.ph ]
  %.029.lcssa = phi float [ 1.000000e+00, %5 ], [ %.130, %.lr.ph ]
  %24 = tail call float @llvm.fmuladd.f32(float %8, float %.029.lcssa, float %.031.lcssa)
  %25 = fptosi float %24 to i32
  %26 = fcmp ogt float %1, 0.000000e+00
  %27 = sub nsw i32 0, %25
  %28 = select i1 %26, i32 %25, i32 %27
  store i32 %28, ptr %2, align 4, !tbaa !7
  %29 = fptosi float %.029.lcssa to i32
  store i32 %29, ptr %3, align 4, !tbaa !7
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4fabsf(float noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }

!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}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}


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