; LLVM IR from jgaeddert/liquid-dsp :: src/dotprod/src/dotprod_crcf.sse (dotprod_crcf_execute_sse)

; 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"

%struct.dotprod_crcf_s = type { i32, ptr }

; 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: nounwind uwtable
define dso_local i32 @dotprod_crcf_execute_sse(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca <4 x float>, align 16
  %10 = alloca <4 x float>, align 16
  %11 = alloca <4 x float>, align 16
  %12 = alloca <4 x float>, align 16
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca [4 x float], align 16
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %16, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.dotprod_crcf_s, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = mul i32 2, %19
  store i32 %20, ptr %8, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #4
  %21 = call <4 x float> @_mm_setzero_ps()
  store <4 x float> %21, ptr %12, align 16, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %22 = load i32, ptr %8, align 4, !tbaa !12
  %23 = lshr i32 %22, 2
  %24 = shl i32 %23, 2
  store i32 %24, ptr %13, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !12
  br label %25

25:                                               ; preds = %48, %3
  %26 = load i32, ptr %14, align 4, !tbaa !12
  %27 = load i32, ptr %13, align 4, !tbaa !12
  %28 = icmp ult i32 %26, %27
  br i1 %28, label %29, label %51

29:                                               ; preds = %25
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load i32, ptr %14, align 4, !tbaa !12
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds float, ptr %30, i64 %32
  %34 = call <4 x float> @_mm_loadu_ps(ptr noundef %33)
  store <4 x float> %34, ptr %9, align 16, !tbaa !13
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.dotprod_crcf_s, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = load i32, ptr %14, align 4, !tbaa !12
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %37, i64 %39
  %41 = call <4 x float> @_mm_load_ps(ptr noundef %40)
  store <4 x float> %41, ptr %10, align 16, !tbaa !13
  %42 = load <4 x float>, ptr %9, align 16, !tbaa !13
  %43 = load <4 x float>, ptr %10, align 16, !tbaa !13
  %44 = call <4 x float> @_mm_mul_ps(<4 x float> noundef %42, <4 x float> noundef %43)
  store <4 x float> %44, ptr %11, align 16, !tbaa !13
  %45 = load <4 x float>, ptr %12, align 16, !tbaa !13
  %46 = load <4 x float>, ptr %11, align 16, !tbaa !13
  %47 = call <4 x float> @_mm_add_ps(<4 x float> noundef %45, <4 x float> noundef %46)
  store <4 x float> %47, ptr %12, align 16, !tbaa !13
  br label %48

48:                                               ; preds = %29
  %49 = load i32, ptr %14, align 4, !tbaa !12
  %50 = add i32 %49, 4
  store i32 %50, ptr %14, align 4, !tbaa !12
  br label %25, !llvm.loop !15

51:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #4
  %52 = getelementptr inbounds [4 x float], ptr %15, i64 0, i64 0
  %53 = load <4 x float>, ptr %12, align 16, !tbaa !13
  call void @_mm_store_ps(ptr noundef %52, <4 x float> noundef %53)
  %54 = getelementptr inbounds [4 x float], ptr %15, i64 0, i64 2
  %55 = load float, ptr %54, align 8, !tbaa !17
  %56 = getelementptr inbounds [4 x float], ptr %15, i64 0, i64 0
  %57 = load float, ptr %56, align 16, !tbaa !17
  %58 = fadd float %57, %55
  store float %58, ptr %56, align 16, !tbaa !17
  %59 = getelementptr inbounds [4 x float], ptr %15, i64 0, i64 3
  %60 = load float, ptr %59, align 4, !tbaa !17
  %61 = getelementptr inbounds [4 x float], ptr %15, i64 0, i64 1
  %62 = load float, ptr %61, align 4, !tbaa !17
  %63 = fadd float %62, %60
  store float %63, ptr %61, align 4, !tbaa !17
  br label %64

64:                                               ; preds = %101, %51
  %65 = load i32, ptr %14, align 4, !tbaa !12
  %66 = load i32, ptr %8, align 4, !tbaa !12
  %67 = icmp ult i32 %65, %66
  br i1 %67, label %68, label %104

68:                                               ; preds = %64
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load i32, ptr %14, align 4, !tbaa !12
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds float, ptr %69, i64 %71
  %73 = load float, ptr %72, align 4, !tbaa !17
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.dotprod_crcf_s, ptr %74, i32 0, i32 1
  %76 = load ptr, ptr %75, align 8, !tbaa !14
  %77 = load i32, ptr %14, align 4, !tbaa !12
  %78 = zext i32 %77 to i64
  %79 = getelementptr inbounds float, ptr %76, i64 %78
  %80 = load float, ptr %79, align 4, !tbaa !17
  %81 = getelementptr inbounds [4 x float], ptr %15, i64 0, i64 0
  %82 = load float, ptr %81, align 16, !tbaa !17
  %83 = call float @llvm.fmuladd.f32(float %73, float %80, float %82)
  store float %83, ptr %81, align 16, !tbaa !17
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = load i32, ptr %14, align 4, !tbaa !12
  %86 = add i32 %85, 1
  %87 = zext i32 %86 to i64
  %88 = getelementptr inbounds float, ptr %84, i64 %87
  %89 = load float, ptr %88, align 4, !tbaa !17
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.dotprod_crcf_s, ptr %90, i32 0, i32 1
  %92 = load ptr, ptr %91, align 8, !tbaa !14
  %93 = load i32, ptr %14, align 4, !tbaa !12
  %94 = add i32 %93, 1
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds float, ptr %92, i64 %95
  %97 = load float, ptr %96, align 4, !tbaa !17
  %98 = getelementptr inbounds [4 x float], ptr %15, i64 0, i64 1
  %99 = load float, ptr %98, align 4, !tbaa !17
  %100 = call float @llvm.fmuladd.f32(float %89, float %97, float %99)
  store float %100, ptr %98, align 4, !tbaa !17
  br label %101

101:                                              ; preds = %68
  %102 = load i32, ptr %14, align 4, !tbaa !12
  %103 = add i32 %102, 2
  store i32 %103, ptr %14, align 4, !tbaa !12
  br label %64, !llvm.loop !19

104:                                              ; preds = %64
  %105 = getelementptr inbounds [4 x float], ptr %15, i64 0, i64 0
  %106 = load float, ptr %105, align 16, !tbaa !17
  %107 = getelementptr inbounds [4 x float], ptr %15, i64 0, i64 1
  %108 = load float, ptr %107, align 4, !tbaa !17
  %109 = fmul float 0.000000e+00, %108
  %110 = fmul float 1.000000e+00, %108
  %111 = fadd float %106, %109
  %112 = load ptr, ptr %6, align 8, !tbaa !5
  %113 = getelementptr inbounds { float, float }, ptr %112, i32 0, i32 0
  %114 = getelementptr inbounds { float, float }, ptr %112, i32 0, i32 1
  store float %111, ptr %113, align 4
  store float %110, ptr %114, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret i32 0
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_setzero_ps() #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_loadu_ps(ptr noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_load_ps(ptr noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_mul_ps(<4 x float> noundef, <4 x float> noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_add_ps(<4 x float> noundef, <4 x float> noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @_mm_store_ps(ptr noundef, <4 x float> noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="128" "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 = { alwaysinline nounwind uwtable "min-legal-vector-width"="128" "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/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"dotprod_crcf_s", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!10, !6, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = distinct !{!19, !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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @dotprod_crcf_execute_sse(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = alloca [4 x float], align 16
  %5 = load i32, ptr %0, align 8, !tbaa !5
  %6 = shl i32 %5, 1
  %7 = tail call <4 x float> @_mm_setzero_ps()
  %8 = and i32 %6, -4
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = zext i32 %8 to i64
  br label %11

11:                                               ; preds = %.lr.ph, %11
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %11 ]
  %.02627 = phi <4 x float> [ %7, %.lr.ph ], [ %18, %11 ]
  %12 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %13 = tail call <4 x float> @_mm_loadu_ps(ptr noundef %12)
  %14 = load ptr, ptr %9, align 8, !tbaa !11
  %15 = getelementptr inbounds float, ptr %14, i64 %indvars.iv
  %16 = tail call <4 x float> @_mm_load_ps(ptr noundef %15)
  %17 = tail call <4 x float> @_mm_mul_ps(<4 x float> noundef %13, <4 x float> noundef %16)
  %18 = tail call <4 x float> @_mm_add_ps(<4 x float> noundef %.02627, <4 x float> noundef %17)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 4
  %19 = icmp ult i64 %indvars.iv.next, %10
  br i1 %19, label %11, label %._crit_edge.loopexit, !llvm.loop !12

._crit_edge.loopexit:                             ; preds = %11
  %20 = trunc nuw i64 %indvars.iv.next to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %3
  %.026.lcssa = phi <4 x float> [ %7, %3 ], [ %18, %._crit_edge.loopexit ]
  %.0.lcssa = phi i32 [ 0, %3 ], [ %20, %._crit_edge.loopexit ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  call void @_mm_store_ps(ptr noundef nonnull %4, <4 x float> noundef %.026.lcssa)
  %21 = getelementptr inbounds i8, ptr %4, i64 8
  %22 = getelementptr inbounds i8, ptr %4, i64 4
  %23 = load <2 x float>, ptr %21, align 8, !tbaa !14
  %24 = load <2 x float>, ptr %4, align 16, !tbaa !14
  %25 = fadd <2 x float> %23, %24
  store <2 x float> %25, ptr %4, align 16, !tbaa !14
  %26 = icmp ult i32 %.0.lcssa, %6
  %27 = extractelement <2 x float> %25, i64 0
  %28 = extractelement <2 x float> %25, i64 1
  br i1 %26, label %.lr.ph33, label %._crit_edge34

.lr.ph33:                                         ; preds = %._crit_edge
  %29 = getelementptr inbounds i8, ptr %0, i64 8
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = zext i32 %.0.lcssa to i64
  %32 = zext i32 %6 to i64
  br label %33

33:                                               ; preds = %.lr.ph33, %33
  %indvars.iv37 = phi i64 [ %31, %.lr.ph33 ], [ %indvars.iv.next38, %33 ]
  %34 = phi <2 x float> [ %25, %.lr.ph33 ], [ %50, %33 ]
  %35 = getelementptr inbounds float, ptr %1, i64 %indvars.iv37
  %36 = load float, ptr %35, align 4, !tbaa !14
  %37 = getelementptr inbounds float, ptr %30, i64 %indvars.iv37
  %38 = load float, ptr %37, align 4, !tbaa !14
  %39 = or disjoint i64 %indvars.iv37, 1
  %40 = getelementptr inbounds float, ptr %1, i64 %39
  %41 = load float, ptr %40, align 4, !tbaa !14
  %42 = getelementptr inbounds float, ptr %30, i64 %39
  %43 = extractelement <2 x float> %34, i64 0
  %44 = call float @llvm.fmuladd.f32(float %36, float %38, float %43)
  store float %44, ptr %4, align 16, !tbaa !14
  %45 = load float, ptr %42, align 4, !tbaa !14
  %46 = extractelement <2 x float> %34, i64 1
  %47 = call float @llvm.fmuladd.f32(float %41, float %45, float %46)
  store float %47, ptr %22, align 4, !tbaa !14
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 2
  %48 = icmp ult i64 %indvars.iv.next38, %32
  %49 = insertelement <2 x float> poison, float %44, i64 0
  %50 = insertelement <2 x float> %49, float %47, i64 1
  br i1 %48, label %33, label %._crit_edge34, !llvm.loop !16

._crit_edge34:                                    ; preds = %33, %._crit_edge
  %51 = phi float [ %28, %._crit_edge ], [ %47, %33 ]
  %52 = phi float [ %27, %._crit_edge ], [ %44, %33 ]
  %53 = fmul float %51, 0.000000e+00
  %54 = fadd float %52, %53
  %55 = getelementptr inbounds i8, ptr %2, i64 4
  store float %54, ptr %2, align 4
  store float %51, ptr %55, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  ret i32 0
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_setzero_ps() local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_loadu_ps(ptr noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_load_ps(ptr noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_mul_ps(<4 x float> noundef, <4 x float> noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_add_ps(<4 x float> noundef, <4 x float> noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @_mm_store_ps(ptr noundef, <4 x float> noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="128" "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 = { alwaysinline nounwind uwtable "min-legal-vector-width"="128" "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 = { mustprogress 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, !7, i64 0}
!6 = !{!"dotprod_crcf_s", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = distinct !{!16, !13}


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