; LLVM IR from jgaeddert/liquid-dsp :: sandbox (ofdmframe_papr_test)

; 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: nounwind uwtable
define dso_local float @ofdmframe_PAPR(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca { float, float }, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store float 0.000000e+00, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store float 0.000000e+00, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %62, %2
  %11 = load i32, ptr %8, align 4, !tbaa !9
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = icmp ult i32 %11, %12
  br i1 %13, label %14, label %65

14:                                               ; preds = %10
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds { float, float }, ptr %15, i64 %17
  %19 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 0
  %20 = load float, ptr %19, align 4
  %21 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 1
  %22 = load float, ptr %21, align 4
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds { float, float }, ptr %23, i64 %25
  %27 = getelementptr inbounds { float, float }, ptr %26, i32 0, i32 0
  %28 = load float, ptr %27, align 4
  %29 = getelementptr inbounds { float, float }, ptr %26, i32 0, i32 1
  %30 = load float, ptr %29, align 4
  %31 = fneg float %30
  %32 = fmul float %20, %28
  %33 = fmul float %22, %31
  %34 = fmul float %20, %31
  %35 = fmul float %22, %28
  %36 = fsub float %32, %33
  %37 = fadd float %34, %35
  %38 = fcmp uno float %36, %36
  br i1 %38, label %39, label %47, !prof !13

39:                                               ; preds = %14
  %40 = fcmp uno float %37, %37
  br i1 %40, label %41, label %47, !prof !13

41:                                               ; preds = %39
  %42 = call <2 x float> @__mulsc3(float noundef %20, float noundef %22, float noundef %28, float noundef %31) #3
  store <2 x float> %42, ptr %9, align 4
  %43 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %44 = load float, ptr %43, align 4
  %45 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %46 = load float, ptr %45, align 4
  br label %47

47:                                               ; preds = %41, %39, %14
  %48 = phi float [ %36, %14 ], [ %36, %39 ], [ %44, %41 ]
  %49 = phi float [ %37, %14 ], [ %37, %39 ], [ %46, %41 ]
  store float %48, ptr %5, align 4, !tbaa !11
  %50 = load float, ptr %5, align 4, !tbaa !11
  %51 = load float, ptr %6, align 4, !tbaa !11
  %52 = fadd float %51, %50
  store float %52, ptr %6, align 4, !tbaa !11
  %53 = load float, ptr %5, align 4, !tbaa !11
  %54 = load float, ptr %7, align 4, !tbaa !11
  %55 = fcmp ogt float %53, %54
  br i1 %55, label %56, label %58

56:                                               ; preds = %47
  %57 = load float, ptr %5, align 4, !tbaa !11
  br label %60

58:                                               ; preds = %47
  %59 = load float, ptr %7, align 4, !tbaa !11
  br label %60

60:                                               ; preds = %58, %56
  %61 = phi float [ %57, %56 ], [ %59, %58 ]
  store float %61, ptr %7, align 4, !tbaa !11
  br label %62

62:                                               ; preds = %60
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = add i32 %63, 1
  store i32 %64, ptr %8, align 4, !tbaa !9
  br label %10, !llvm.loop !14

65:                                               ; preds = %10
  %66 = load float, ptr %6, align 4, !tbaa !11
  %67 = load i32, ptr %4, align 4, !tbaa !9
  %68 = uitofp i32 %67 to float
  %69 = fdiv float %66, %68
  store float %69, ptr %6, align 4, !tbaa !11
  %70 = load float, ptr %7, align 4, !tbaa !11
  %71 = load float, ptr %6, align 4, !tbaa !11
  %72 = fdiv float %70, %71
  %73 = call float @log10f(float noundef %72) #3
  %74 = fmul float 1.000000e+01, %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret float %74
}

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

declare <2 x float> @__mulsc3(float, float, float, float)

; Function Attrs: nounwind
declare float @log10f(float noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"branch_weights", i32 1, i32 1048575}
!14 = distinct !{!14, !15}
!15 = !{!"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: nounwind uwtable
define dso_local float @ofdmframe_PAPR(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext i32 %1 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %18
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %18 ]
  %.021 = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %20, %18 ]
  %.01719 = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %22, %18 ]
  %3 = getelementptr inbounds { float, float }, ptr %0, i64 %indvars.iv
  %4 = load <2 x float>, ptr %3, align 4
  %5 = extractelement <2 x float> %4, i64 1
  %6 = fneg float %5
  %7 = fmul <2 x float> %4, %4
  %shift = shufflevector <2 x float> %7, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %8 = fadd <2 x float> %7, %shift
  %9 = extractelement <2 x float> %8, i64 0
  %10 = fcmp uno float %9, 0.000000e+00
  br i1 %10, label %11, label %18, !prof !5

11:                                               ; preds = %.lr.ph
  %12 = extractelement <2 x float> %4, i64 0
  %13 = fmul float %12, %5
  %14 = fsub float %13, %13
  %15 = fcmp uno float %14, 0.000000e+00
  br i1 %15, label %16, label %18, !prof !5

16:                                               ; preds = %11
  %17 = tail call <2 x float> @__mulsc3(float noundef %12, float noundef %5, float noundef %12, float noundef %6) #2
  %.sroa.0.0.vec.extract = extractelement <2 x float> %17, i64 0
  br label %18

18:                                               ; preds = %16, %11, %.lr.ph
  %19 = phi float [ %9, %.lr.ph ], [ %9, %11 ], [ %.sroa.0.0.vec.extract, %16 ]
  %20 = fadd float %.021, %19
  %21 = fcmp ogt float %19, %.01719
  %22 = select i1 %21, float %19, float %.01719
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !6

._crit_edge:                                      ; preds = %18, %2
  %.017.lcssa = phi float [ 0.000000e+00, %2 ], [ %22, %18 ]
  %.0.lcssa = phi float [ 0.000000e+00, %2 ], [ %20, %18 ]
  %23 = uitofp i32 %1 to float
  %24 = fdiv float %.0.lcssa, %23
  %25 = fdiv float %.017.lcssa, %24
  %26 = tail call float @log10f(float noundef %25) #2
  %27 = fmul float %26, 1.000000e+01
  ret float %27
}

declare <2 x float> @__mulsc3(float, float, float, float) local_unnamed_addr

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { 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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = distinct !{!6, !7}
!7 = !{!"llvm.loop.mustprogress"}


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