; 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 nounwind uwtable
define dso_local void @_ZN4sptk6reaper8FdFilter13MakeLinearFirEfPiPf(ptr noundef nonnull align 8 dereferenceable(144) %0, float noundef %1, ptr noundef %2, ptr noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = load i32, ptr %15, align 4, !tbaa !11
  %17 = srem i32 %16, 2
  %18 = icmp ne i32 %17, 1
  br i1 %18, label %19, label %24

19:                                               ; preds = %4
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = add nsw i32 %21, 1
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %22, ptr %23, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %19, %4
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load i32, ptr %25, align 4, !tbaa !11
  %27 = add nsw i32 %26, 1
  %28 = sdiv i32 %27, 2
  store i32 %28, ptr %10, align 4, !tbaa !11
  store double 0x401921FB54442D18, ptr %11, align 8, !tbaa !13
  %29 = load float, ptr %6, align 4, !tbaa !9
  %30 = fpext float %29 to double
  %31 = fmul double 2.000000e+00, %30
  %32 = fptrunc double %31 to float
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds float, ptr %33, i64 0
  store float %32, ptr %34, align 4, !tbaa !9
  store double 0x400921FB54442D18, ptr %13, align 8, !tbaa !13
  %35 = load double, ptr %11, align 8, !tbaa !13
  %36 = load float, ptr %6, align 4, !tbaa !9
  %37 = fpext float %36 to double
  %38 = fmul double %35, %37
  store double %38, ptr %12, align 8, !tbaa !13
  store i32 1, ptr %9, align 4, !tbaa !11
  br label %39

39:                                               ; preds = %59, %24
  %40 = load i32, ptr %9, align 4, !tbaa !11
  %41 = load i32, ptr %10, align 4, !tbaa !11
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %43, label %62

43:                                               ; preds = %39
  %44 = load i32, ptr %9, align 4, !tbaa !11
  %45 = sitofp i32 %44 to double
  %46 = load double, ptr %12, align 8, !tbaa !13
  %47 = fmul double %45, %46
  %48 = call double @sin(double noundef %47) #4
  %49 = load double, ptr %13, align 8, !tbaa !13
  %50 = load i32, ptr %9, align 4, !tbaa !11
  %51 = sitofp i32 %50 to double
  %52 = fmul double %49, %51
  %53 = fdiv double %48, %52
  %54 = fptrunc double %53 to float
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = load i32, ptr %9, align 4, !tbaa !11
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds float, ptr %55, i64 %57
  store float %54, ptr %58, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %43
  %60 = load i32, ptr %9, align 4, !tbaa !11
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %9, align 4, !tbaa !11
  br label %39, !llvm.loop !15

62:                                               ; preds = %39
  %63 = load double, ptr %11, align 8, !tbaa !13
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load i32, ptr %64, align 4, !tbaa !11
  %66 = sitofp i32 %65 to double
  %67 = fdiv double %63, %66
  store double %67, ptr %12, align 8, !tbaa !13
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %68

68:                                               ; preds = %91, %62
  %69 = load i32, ptr %9, align 4, !tbaa !11
  %70 = load i32, ptr %10, align 4, !tbaa !11
  %71 = icmp slt i32 %69, %70
  br i1 %71, label %72, label %94

72:                                               ; preds = %68
  %73 = load double, ptr %12, align 8, !tbaa !13
  %74 = load i32, ptr %9, align 4, !tbaa !11
  %75 = sitofp i32 %74 to double
  %76 = fadd double %75, 5.000000e-01
  %77 = fmul double %73, %76
  %78 = call double @cos(double noundef %77) #4
  %79 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %78, double 5.000000e-01)
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = load i32, ptr %10, align 4, !tbaa !11
  %82 = load i32, ptr %9, align 4, !tbaa !11
  %83 = sub nsw i32 %81, %82
  %84 = sub nsw i32 %83, 1
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds float, ptr %80, i64 %85
  %87 = load float, ptr %86, align 4, !tbaa !9
  %88 = fpext float %87 to double
  %89 = fmul double %88, %79
  %90 = fptrunc double %89 to float
  store float %90, ptr %86, align 4, !tbaa !9
  br label %91

91:                                               ; preds = %72
  %92 = load i32, ptr %9, align 4, !tbaa !11
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %9, align 4, !tbaa !11
  br label %68, !llvm.loop !17

94:                                               ; preds = %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret void
}

; Function Attrs: nounwind
declare double @sin(double noundef) #2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 nofree nounwind memory(write, argmem: readwrite) uwtable
define dso_local void @_ZN4sptk6reaper8FdFilter13MakeLinearFirEfPiPf(ptr nocapture noundef nonnull readnone align 8 dereferenceable(144) %0, float noundef %1, ptr nocapture noundef %2, ptr nocapture noundef %3) local_unnamed_addr #0 align 2 {
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = and i32 %5, -2147483647
  %.not = icmp eq i32 %6, 1
  br i1 %.not, label %9, label %7

7:                                                ; preds = %4
  %8 = add nsw i32 %5, 1
  store i32 %8, ptr %2, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %7, %4
  %10 = phi i32 [ %8, %7 ], [ %5, %4 ]
  %11 = add nsw i32 %10, 1
  %12 = sdiv i32 %11, 2
  %13 = fpext float %1 to double
  %14 = fmul float %1, 2.000000e+00
  store float %14, ptr %3, align 4, !tbaa !9
  %15 = fmul double %13, 0x401921FB54442D18
  %16 = icmp sgt i32 %10, 2
  br i1 %16, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %9
  %smax = tail call i32 @llvm.smax.i32(i32 %12, i32 2)
  %wide.trip.count = zext nneg i32 %smax to i64
  %17 = add nsw i64 %wide.trip.count, -1
  %xtraiter = and i64 %17, 1
  %18 = icmp slt i32 %10, 5
  br i1 %18, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %17, -2
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %19 = trunc nuw nsw i64 %indvars.iv to i32
  %20 = uitofp nneg i32 %19 to double
  %21 = fmul double %15, %20
  %22 = tail call double @sin(double noundef %21) #4
  %23 = fmul double %20, 0x400921FB54442D18
  %24 = fdiv double %22, %23
  %25 = fptrunc double %24 to float
  %26 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  store float %25, ptr %26, align 4, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = trunc nuw nsw i64 %indvars.iv.next to i32
  %28 = uitofp nneg i32 %27 to double
  %29 = fmul double %15, %28
  %30 = tail call double @sin(double noundef %29) #4
  %31 = fmul double %28, 0x400921FB54442D18
  %32 = fdiv double %30, %31
  %33 = fptrunc double %32 to float
  %34 = getelementptr inbounds float, ptr %3, i64 %indvars.iv.next
  store float %33, ptr %34, align 4, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !11

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next.1, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %35 = trunc nuw nsw i64 %indvars.iv.unr to i32
  %36 = uitofp nneg i32 %35 to double
  %37 = fmul double %15, %36
  %38 = tail call double @sin(double noundef %37) #4
  %39 = fmul double %36, 0x400921FB54442D18
  %40 = fdiv double %38, %39
  %41 = fptrunc double %40 to float
  %42 = getelementptr inbounds float, ptr %3, i64 %indvars.iv.unr
  store float %41, ptr %42, align 4, !tbaa !9
  br label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %.pre = load i32, ptr %2, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %9
  %43 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %10, %9 ]
  %44 = sitofp i32 %43 to double
  %45 = fdiv double 0x401921FB54442D18, %44
  %46 = icmp sgt i32 %10, 0
  br i1 %46, label %.lr.ph31.preheader, label %._crit_edge32

.lr.ph31.preheader:                               ; preds = %._crit_edge
  %47 = zext nneg i32 %12 to i64
  %smax37 = tail call i32 @llvm.smax.i32(i32 %12, i32 1)
  %wide.trip.count38 = zext nneg i32 %smax37 to i64
  %48 = getelementptr float, ptr %3, i64 %47
  br label %.lr.ph31

.lr.ph31:                                         ; preds = %.lr.ph31.preheader, %.lr.ph31
  %indvars.iv34 = phi i64 [ 0, %.lr.ph31.preheader ], [ %indvars.iv.next35, %.lr.ph31 ]
  %49 = trunc nuw nsw i64 %indvars.iv34 to i32
  %50 = uitofp nneg i32 %49 to double
  %51 = fadd double %50, 5.000000e-01
  %52 = fmul double %45, %51
  %53 = tail call double @cos(double noundef %52) #4
  %54 = tail call double @llvm.fmuladd.f64(double %53, double -5.000000e-01, double 5.000000e-01)
  %55 = xor i64 %indvars.iv34, -1
  %56 = getelementptr float, ptr %48, i64 %55
  %57 = load float, ptr %56, align 4, !tbaa !9
  %58 = fpext float %57 to double
  %59 = fmul double %54, %58
  %60 = fptrunc double %59 to float
  store float %60, ptr %56, align 4, !tbaa !9
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %exitcond39.not = icmp eq i64 %indvars.iv.next35, %wide.trip.count38
  br i1 %exitcond39.not, label %._crit_edge32, label %.lr.ph31, !llvm.loop !13

._crit_edge32:                                    ; preds = %.lr.ph31, %._crit_edge
  ret void
}

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3

attributes #0 = { mustprogress nofree nounwind memory(write, argmem: readwrite) 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 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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