; LLVM IR from jgaeddert/liquid-dsp :: src/dotprod/src (dotprod_cccf)

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

14:                                               ; preds = %61, %4
  %15 = load i32, ptr %10, align 4, !tbaa !9
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = icmp ult i32 %15, %16
  br i1 %17, label %18, label %64

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

42:                                               ; preds = %18
  %43 = fcmp uno float %40, %40
  br i1 %43, label %44, label %50, !prof !11

44:                                               ; preds = %42
  %45 = call <2 x float> @__mulsc3(float noundef %24, float noundef %26, float noundef %32, float noundef %34) #2
  store <2 x float> %45, ptr %11, align 4
  %46 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %47 = load float, ptr %46, align 4
  %48 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  %49 = load float, ptr %48, align 4
  br label %50

50:                                               ; preds = %44, %42, %18
  %51 = phi float [ %39, %18 ], [ %39, %42 ], [ %47, %44 ]
  %52 = phi float [ %40, %18 ], [ %40, %42 ], [ %49, %44 ]
  %53 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %54 = load float, ptr %53, align 4
  %55 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %56 = load float, ptr %55, align 4
  %57 = fadd float %54, %51
  %58 = fadd float %56, %52
  %59 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %60 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %57, ptr %59, align 4
  store float %58, ptr %60, align 4
  br label %61

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

64:                                               ; preds = %14
  %65 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %66 = load float, ptr %65, align 4
  %67 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %68 = load float, ptr %67, align 4
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds { float, float }, ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds { float, float }, ptr %69, i32 0, i32 1
  store float %66, ptr %70, align 4
  store float %68, ptr %71, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  ret i32 0
}

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!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 = !{!"branch_weights", i32 1, i32 1048575}
!12 = distinct !{!12, !13}
!13 = !{!"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 noundef i32 @dotprod_cccf_run(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i32 noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %31
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %31 ]
  %5 = phi <2 x float> [ zeroinitializer, %.lr.ph.preheader ], [ %33, %31 ]
  %6 = getelementptr inbounds { float, float }, ptr %0, i64 %indvars.iv
  %7 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv
  %8 = load float, ptr %7, align 4
  %9 = getelementptr inbounds i8, ptr %7, i64 4
  %10 = load float, ptr %9, align 4
  %11 = load <2 x float>, ptr %6, align 4
  %12 = insertelement <2 x float> poison, float %10, i64 0
  %13 = shufflevector <2 x float> %12, <2 x float> poison, <2 x i32> zeroinitializer
  %14 = fmul <2 x float> %11, %13
  %15 = shufflevector <2 x float> %14, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %16 = insertelement <2 x float> poison, float %8, i64 0
  %17 = shufflevector <2 x float> %16, <2 x float> poison, <2 x i32> zeroinitializer
  %18 = fmul <2 x float> %11, %17
  %19 = fsub <2 x float> %18, %15
  %20 = fadd <2 x float> %18, %15
  %21 = shufflevector <2 x float> %19, <2 x float> %20, <2 x i32> <i32 0, i32 3>
  %22 = extractelement <2 x float> %19, i64 0
  %23 = fcmp uno float %22, 0.000000e+00
  br i1 %23, label %24, label %31, !prof !5

24:                                               ; preds = %.lr.ph
  %25 = extractelement <2 x float> %20, i64 1
  %26 = fcmp uno float %25, 0.000000e+00
  br i1 %26, label %27, label %31, !prof !5

27:                                               ; preds = %24
  %28 = extractelement <2 x float> %11, i64 0
  %29 = extractelement <2 x float> %11, i64 1
  %30 = tail call <2 x float> @__mulsc3(float noundef %28, float noundef %29, float noundef %8, float noundef %10) #1
  br label %31

31:                                               ; preds = %27, %24, %.lr.ph
  %32 = phi <2 x float> [ %21, %.lr.ph ], [ %21, %24 ], [ %30, %27 ]
  %33 = fadd <2 x float> %5, %32
  %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 = %31, %4
  %34 = phi <2 x float> [ zeroinitializer, %4 ], [ %33, %31 ]
  store <2 x float> %34, ptr %3, align 4
  ret i32 0
}

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

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 = { 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