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

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_ZN4sptk6reaper11LpcAnalyzer15ItakuraDistanceEiPfS2_S2_f(ptr noundef nonnull align 8 dereferenceable(48) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, float noundef %5) #2 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store float %5, ptr %12, align 4, !tbaa !11
  %14 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %15 = load ptr, ptr %10, align 8, !tbaa !5
  %16 = load float, ptr %15, align 4, !tbaa !11
  store float %16, ptr %13, align 4, !tbaa !11
  br label %17

17:                                               ; preds = %21, %6
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = add nsw i32 %18, -1
  store i32 %19, ptr %8, align 4, !tbaa !9
  %20 = icmp ne i32 %18, 0
  br i1 %20, label %21, label %30

21:                                               ; preds = %17
  %22 = load ptr, ptr %11, align 8, !tbaa !5
  %23 = getelementptr inbounds float, ptr %22, i32 1
  store ptr %23, ptr %11, align 8, !tbaa !5
  %24 = load float, ptr %22, align 4, !tbaa !11
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = getelementptr inbounds float, ptr %25, i32 1
  store ptr %26, ptr %9, align 8, !tbaa !5
  %27 = load float, ptr %25, align 4, !tbaa !11
  %28 = load float, ptr %13, align 4, !tbaa !11
  %29 = call float @llvm.fmuladd.f32(float %24, float %27, float %28)
  store float %29, ptr %13, align 4, !tbaa !11
  br label %17, !llvm.loop !13

30:                                               ; preds = %17
  %31 = load float, ptr %13, align 4, !tbaa !11
  %32 = load float, ptr %12, align 4, !tbaa !11
  %33 = fdiv float %31, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  ret float %33
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !12, i64 0}
!12 = !{!"float", !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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef float @_ZN4sptk6reaper11LpcAnalyzer15ItakuraDistanceEiPfS2_S2_f(ptr nocapture noundef nonnull readnone align 8 dereferenceable(48) %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, float noundef %5) local_unnamed_addr #1 align 2 {
  %7 = load float, ptr %3, align 4, !tbaa !5
  %.not10 = icmp eq i32 %1, 0
  br i1 %.not10, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %6
  %xtraiter = and i32 %1, 3
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader, %.lr.ph.prol
  %.014.prol = phi float [ %13, %.lr.ph.prol ], [ %7, %.lr.ph.preheader ]
  %.0713.prol = phi i32 [ %8, %.lr.ph.prol ], [ %1, %.lr.ph.preheader ]
  %.0812.prol = phi ptr [ %9, %.lr.ph.prol ], [ %4, %.lr.ph.preheader ]
  %.0911.prol = phi ptr [ %11, %.lr.ph.prol ], [ %2, %.lr.ph.preheader ]
  %prol.iter = phi i32 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader ]
  %8 = add nsw i32 %.0713.prol, -1
  %9 = getelementptr inbounds i8, ptr %.0812.prol, i64 4
  %10 = load float, ptr %.0812.prol, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %.0911.prol, i64 4
  %12 = load float, ptr %.0911.prol, align 4, !tbaa !5
  %13 = tail call float @llvm.fmuladd.f32(float %10, float %12, float %.014.prol)
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !9

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.lcssa.unr = phi float [ poison, %.lr.ph.preheader ], [ %13, %.lr.ph.prol ]
  %.014.unr = phi float [ %7, %.lr.ph.preheader ], [ %13, %.lr.ph.prol ]
  %.0713.unr = phi i32 [ %1, %.lr.ph.preheader ], [ %8, %.lr.ph.prol ]
  %.0812.unr = phi ptr [ %4, %.lr.ph.preheader ], [ %9, %.lr.ph.prol ]
  %.0911.unr = phi ptr [ %2, %.lr.ph.preheader ], [ %11, %.lr.ph.prol ]
  %14 = icmp ult i32 %1, 4
  br i1 %14, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.014 = phi float [ %35, %.lr.ph ], [ %.014.unr, %.lr.ph.prol.loopexit ]
  %.0713 = phi i32 [ %30, %.lr.ph ], [ %.0713.unr, %.lr.ph.prol.loopexit ]
  %.0812 = phi ptr [ %31, %.lr.ph ], [ %.0812.unr, %.lr.ph.prol.loopexit ]
  %.0911 = phi ptr [ %33, %.lr.ph ], [ %.0911.unr, %.lr.ph.prol.loopexit ]
  %15 = getelementptr inbounds i8, ptr %.0812, i64 4
  %16 = load float, ptr %.0812, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %.0911, i64 4
  %18 = load float, ptr %.0911, align 4, !tbaa !5
  %19 = tail call float @llvm.fmuladd.f32(float %16, float %18, float %.014)
  %20 = getelementptr inbounds i8, ptr %.0812, i64 8
  %21 = load float, ptr %15, align 4, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %.0911, i64 8
  %23 = load float, ptr %17, align 4, !tbaa !5
  %24 = tail call float @llvm.fmuladd.f32(float %21, float %23, float %19)
  %25 = getelementptr inbounds i8, ptr %.0812, i64 12
  %26 = load float, ptr %20, align 4, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %.0911, i64 12
  %28 = load float, ptr %22, align 4, !tbaa !5
  %29 = tail call float @llvm.fmuladd.f32(float %26, float %28, float %24)
  %30 = add nsw i32 %.0713, -4
  %31 = getelementptr inbounds i8, ptr %.0812, i64 16
  %32 = load float, ptr %25, align 4, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %.0911, i64 16
  %34 = load float, ptr %27, align 4, !tbaa !5
  %35 = tail call float @llvm.fmuladd.f32(float %32, float %34, float %29)
  %.not.3 = icmp eq i32 %30, 0
  br i1 %.not.3, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %6
  %.0.lcssa = phi float [ %7, %6 ], [ %.lcssa.unr, %.lr.ph.prol.loopexit ], [ %35, %.lr.ph ]
  %36 = fdiv float %.0.lcssa, %5
  ret float %36
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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 = !{!6, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unroll.disable"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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