; LLVM IR from sp-nitech/SPTK :: third_party/REAPER/epoch_tracker/fft_reaper.ll (ZN4sptk6reaper3FFT8flog_magEPfS2_S2_i)

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

22:                                               ; preds = %5
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %76

25:                                               ; preds = %22
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %76

28:                                               ; preds = %25
  %29 = load i32, ptr %11, align 4, !tbaa !9
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %76

31:                                               ; preds = %28
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = load i32, ptr %11, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds float, ptr %32, i64 %34
  store ptr %35, ptr %12, align 8, !tbaa !5
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds float, ptr %36, i64 %38
  store ptr %39, ptr %13, align 8, !tbaa !5
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds float, ptr %40, i64 %42
  store ptr %43, ptr %14, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %70, %31
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = icmp ugt ptr %45, %46
  br i1 %47, label %48, label %75

48:                                               ; preds = %44
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  %50 = getelementptr inbounds float, ptr %49, i32 -1
  store ptr %50, ptr %12, align 8, !tbaa !5
  %51 = load float, ptr %50, align 4, !tbaa !11
  store float %51, ptr %15, align 4, !tbaa !11
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = getelementptr inbounds float, ptr %52, i32 -1
  store ptr %53, ptr %13, align 8, !tbaa !5
  %54 = load float, ptr %53, align 4, !tbaa !11
  store float %54, ptr %16, align 4, !tbaa !11
  %55 = load float, ptr %15, align 4, !tbaa !11
  %56 = load float, ptr %15, align 4, !tbaa !11
  %57 = load float, ptr %16, align 4, !tbaa !11
  %58 = load float, ptr %16, align 4, !tbaa !11
  %59 = fmul float %57, %58
  %60 = call float @llvm.fmuladd.f32(float %55, float %56, float %59)
  store float %60, ptr %17, align 4, !tbaa !11
  %61 = load float, ptr %17, align 4, !tbaa !11
  %62 = fpext float %61 to double
  %63 = fcmp ogt double %62, 0.000000e+00
  br i1 %63, label %64, label %69

64:                                               ; preds = %48
  %65 = load float, ptr %17, align 4, !tbaa !11
  %66 = call noundef float @_ZSt5log10f(float noundef %65)
  %67 = fpext float %66 to double
  %68 = fmul double 1.000000e+01, %67
  br label %70

69:                                               ; preds = %48
  br label %70

70:                                               ; preds = %69, %64
  %71 = phi double [ %68, %64 ], [ -2.000000e+02, %69 ]
  %72 = fptrunc double %71 to float
  %73 = load ptr, ptr %14, align 8, !tbaa !5
  %74 = getelementptr inbounds float, ptr %73, i32 -1
  store ptr %74, ptr %14, align 8, !tbaa !5
  store float %72, ptr %74, align 4, !tbaa !11
  br label %44, !llvm.loop !13

75:                                               ; preds = %44
  store i1 true, ptr %6, align 1
  store i32 1, ptr %18, align 4
  br label %77

76:                                               ; preds = %28, %25, %22, %5
  store i1 false, ptr %6, align 1
  store i32 1, ptr %18, align 4
  br label %77

77:                                               ; preds = %76, %75
  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 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %78 = load i1, ptr %6, align 1
  ret i1 %78
}

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

; 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 @_ZSt5log10f(float noundef) #3

; 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 = { 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 = !{!"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 nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4sptk6reaper3FFT8flog_magEPfS2_S2_i(ptr nocapture noundef nonnull readnone align 8 dereferenceable(32) %0, ptr noundef readonly %1, ptr noundef readonly %2, ptr noundef writeonly %3, i32 noundef %4) local_unnamed_addr #0 align 2 {
  %6 = icmp ne ptr %1, null
  %7 = icmp ne ptr %2, null
  %or.cond = and i1 %6, %7
  %8 = icmp ne ptr %3, null
  %or.cond3 = and i1 %or.cond, %8
  %9 = icmp sgt i32 %4, 0
  %or.cond41 = and i1 %or.cond3, %9
  br i1 %or.cond41, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %5
  %10 = zext nneg i32 %4 to i64
  %11 = getelementptr inbounds float, ptr %3, i64 %10
  %12 = getelementptr inbounds float, ptr %2, i64 %10
  %13 = getelementptr inbounds float, ptr %1, i64 %10
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %25
  %.02736 = phi ptr [ %14, %25 ], [ %13, %.lr.ph.preheader ]
  %.02835 = phi ptr [ %16, %25 ], [ %12, %.lr.ph.preheader ]
  %.02934 = phi ptr [ %28, %25 ], [ %11, %.lr.ph.preheader ]
  %14 = getelementptr inbounds i8, ptr %.02736, i64 -4
  %15 = load float, ptr %14, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %.02835, i64 -4
  %17 = load float, ptr %16, align 4, !tbaa !5
  %18 = fmul float %17, %17
  %19 = tail call float @llvm.fmuladd.f32(float %15, float %15, float %18)
  %20 = fcmp ogt float %19, 0.000000e+00
  br i1 %20, label %21, label %25

21:                                               ; preds = %.lr.ph
  %22 = tail call noundef float @_ZSt5log10f(float noundef %19)
  %23 = fpext float %22 to double
  %24 = fmul double %23, 1.000000e+01
  br label %25

25:                                               ; preds = %.lr.ph, %21
  %26 = phi double [ %24, %21 ], [ -2.000000e+02, %.lr.ph ]
  %27 = fptrunc double %26 to float
  %28 = getelementptr inbounds i8, ptr %.02934, i64 -4
  store float %27, ptr %28, align 4, !tbaa !5
  %29 = icmp ugt ptr %28, %3
  br i1 %29, label %.lr.ph, label %.loopexit, !llvm.loop !9

.loopexit:                                        ; preds = %25, %5
  %30 = icmp ne i32 %4, 0
  %or.cond5 = and i1 %or.cond3, %30
  ret i1 %or.cond5
}

; 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 @_ZSt5log10f(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 = !{!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.mustprogress"}


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