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

; 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 void @sumsqcf_bench(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca { float, float }, align 4
  %12 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = load i64, ptr %13, align 8, !tbaa !11
  %15 = mul i64 %14, 10
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = zext i32 %16 to i64
  %18 = udiv i64 %15, %17
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %18, ptr %19, align 8, !tbaa !11
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = icmp ult i64 %21, 1
  br i1 %22, label %23, label %25

23:                                               ; preds = %4
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 1, ptr %24, align 8, !tbaa !11
  br label %25

25:                                               ; preds = %23, %4
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  %28 = call ptr @llvm.stacksave.p0()
  store ptr %28, ptr %9, align 8
  %29 = alloca { float, float }, i64 %27, align 16
  store i64 %27, ptr %10, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %30 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %31 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  store float 0.000000e+00, ptr %30, align 4
  store float 0.000000e+00, ptr %31, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store i64 0, ptr %12, align 8, !tbaa !11
  br label %32

32:                                               ; preds = %42, %25
  %33 = load i64, ptr %12, align 8, !tbaa !11
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = zext i32 %34 to i64
  %36 = icmp ult i64 %33, %35
  br i1 %36, label %37, label %45

37:                                               ; preds = %32
  %38 = load i64, ptr %12, align 8, !tbaa !11
  %39 = getelementptr inbounds { float, float }, ptr %29, i64 %38
  %40 = getelementptr inbounds { float, float }, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds { float, float }, ptr %39, i32 0, i32 1
  store float 0x3FC99999A0000000, ptr %40, align 8
  store float 0x3FC99999A0000000, ptr %41, align 4
  br label %42

42:                                               ; preds = %37
  %43 = load i64, ptr %12, align 8, !tbaa !11
  %44 = add i64 %43, 1
  store i64 %44, ptr %12, align 8, !tbaa !11
  br label %32, !llvm.loop !13

45:                                               ; preds = %32
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = call i32 @getrusage(i32 noundef 0, ptr noundef %46) #5
  store i64 0, ptr %12, align 8, !tbaa !11
  br label %48

48:                                               ; preds = %101, %45
  %49 = load i64, ptr %12, align 8, !tbaa !11
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load i64, ptr %50, align 8, !tbaa !11
  %52 = icmp ult i64 %49, %51
  br i1 %52, label %53, label %104

53:                                               ; preds = %48
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = call float @liquid_sumsqcf(ptr noundef %29, i32 noundef %54)
  %56 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %57 = load float, ptr %56, align 4
  %58 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  %59 = load float, ptr %58, align 4
  %60 = fadd float %57, %55
  %61 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %62 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  store float %60, ptr %61, align 4
  store float %59, ptr %62, align 4
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = call float @liquid_sumsqcf(ptr noundef %29, i32 noundef %63)
  %65 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %66 = load float, ptr %65, align 4
  %67 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  %68 = load float, ptr %67, align 4
  %69 = fsub float %66, %64
  %70 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %71 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  store float %69, ptr %70, align 4
  store float %68, ptr %71, align 4
  %72 = load i32, ptr %8, align 4, !tbaa !9
  %73 = call float @liquid_sumsqcf(ptr noundef %29, i32 noundef %72)
  %74 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %75 = load float, ptr %74, align 4
  %76 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  %77 = load float, ptr %76, align 4
  %78 = fadd float %75, %73
  %79 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %80 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  store float %78, ptr %79, align 4
  store float %77, ptr %80, align 4
  %81 = load i32, ptr %8, align 4, !tbaa !9
  %82 = call float @liquid_sumsqcf(ptr noundef %29, i32 noundef %81)
  %83 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %84 = load float, ptr %83, align 4
  %85 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  %86 = load float, ptr %85, align 4
  %87 = fsub float %84, %82
  %88 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %89 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  store float %87, ptr %88, align 4
  store float %86, ptr %89, align 4
  %90 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %91 = load float, ptr %90, align 4
  %92 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  %93 = load float, ptr %92, align 4
  %94 = load i64, ptr %12, align 8, !tbaa !11
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = zext i32 %95 to i64
  %97 = urem i64 %94, %96
  %98 = getelementptr inbounds { float, float }, ptr %29, i64 %97
  %99 = getelementptr inbounds { float, float }, ptr %98, i32 0, i32 0
  %100 = getelementptr inbounds { float, float }, ptr %98, i32 0, i32 1
  store float %91, ptr %99, align 8
  store float %93, ptr %100, align 4
  br label %101

101:                                              ; preds = %53
  %102 = load i64, ptr %12, align 8, !tbaa !11
  %103 = add i64 %102, 1
  store i64 %103, ptr %12, align 8, !tbaa !11
  br label %48, !llvm.loop !15

104:                                              ; preds = %48
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  %106 = call i32 @getrusage(i32 noundef 0, ptr noundef %105) #5
  %107 = load ptr, ptr %7, align 8, !tbaa !5
  %108 = load i64, ptr %107, align 8, !tbaa !11
  %109 = mul i64 %108, 4
  store i64 %109, ptr %107, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %110 = load ptr, ptr %9, align 8
  call void @llvm.stackrestore.p0(ptr %110)
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #1

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

; Function Attrs: nounwind
declare i32 @getrusage(i32 noundef, ptr noundef) #3

declare float @liquid_sumsqcf(ptr noundef, i32 noundef) #4

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 #5 = { 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 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 void @sumsqcf_bench(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = load i64, ptr %2, align 8, !tbaa !5
  %6 = mul i64 %5, 10
  %7 = zext i32 %3 to i64
  %8 = udiv i64 %6, %7
  %9 = icmp ult i64 %6, %7
  %spec.select = select i1 %9, i64 1, i64 %8
  store i64 %spec.select, ptr %2, align 8, !tbaa !5
  %10 = alloca { float, float }, i64 %7, align 16
  %umax = tail call i64 @llvm.umax.i64(i64 %7, i64 1)
  %min.iters.check = icmp ult i32 %3, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %4
  %n.vec = and i64 %umax, 4294967292
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %11 = or disjoint i64 %index, 2
  %12 = getelementptr inbounds { float, float }, ptr %10, i64 %index
  %13 = getelementptr inbounds { float, float }, ptr %10, i64 %11
  store <4 x float> <float 0x3FC99999A0000000, float 0x3FC99999A0000000, float 0x3FC99999A0000000, float 0x3FC99999A0000000>, ptr %12, align 16
  store <4 x float> <float 0x3FC99999A0000000, float 0x3FC99999A0000000, float 0x3FC99999A0000000, float 0x3FC99999A0000000>, ptr %13, align 16
  %index.next = add nuw i64 %index, 4
  %14 = icmp eq i64 %index.next, %n.vec
  br i1 %14, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %7
  br i1 %cmp.n, label %.loopexit, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %4
  %.031.ph = phi i64 [ 0, %4 ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.031 = phi i64 [ %16, %scalar.ph ], [ %.031.ph, %scalar.ph.preheader ]
  %15 = getelementptr inbounds { float, float }, ptr %10, i64 %.031
  store <2 x float> <float 0x3FC99999A0000000, float 0x3FC99999A0000000>, ptr %15, align 8
  %16 = add nuw nsw i64 %.031, 1
  %exitcond.not = icmp eq i64 %16, %umax
  br i1 %exitcond.not, label %.loopexit, label %scalar.ph, !llvm.loop !13

.loopexit:                                        ; preds = %scalar.ph, %middle.block
  %17 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #4
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %18, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.loopexit, %.lr.ph
  %.133 = phi i64 [ %30, %.lr.ph ], [ 0, %.loopexit ]
  %.sroa.0.032 = phi float [ %26, %.lr.ph ], [ 0.000000e+00, %.loopexit ]
  %19 = call float @liquid_sumsqcf(ptr noundef nonnull %10, i32 noundef %3) #4
  %20 = fadd float %.sroa.0.032, %19
  %21 = call float @liquid_sumsqcf(ptr noundef nonnull %10, i32 noundef %3) #4
  %22 = fsub float %20, %21
  %23 = call float @liquid_sumsqcf(ptr noundef nonnull %10, i32 noundef %3) #4
  %24 = fadd float %22, %23
  %25 = call float @liquid_sumsqcf(ptr noundef nonnull %10, i32 noundef %3) #4
  %26 = fsub float %24, %25
  %27 = urem i64 %.133, %7
  %28 = getelementptr inbounds { float, float }, ptr %10, i64 %27
  %29 = getelementptr inbounds i8, ptr %28, i64 4
  store float %26, ptr %28, align 8
  store float 0.000000e+00, ptr %29, align 4
  %30 = add nuw i64 %.133, 1
  %31 = load i64, ptr %2, align 8, !tbaa !5
  %32 = icmp ult i64 %30, %31
  br i1 %32, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %.loopexit
  %33 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #4
  %34 = load i64, ptr %2, align 8, !tbaa !5
  %35 = shl i64 %34, 2
  store i64 %35, ptr %2, align 8, !tbaa !5
  ret void
}

; Function Attrs: nounwind
declare i32 @getrusage(i32 noundef, ptr noundef) local_unnamed_addr #1

declare float @liquid_sumsqcf(ptr noundef, i32 noundef) local_unnamed_addr #2

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

attributes #0 = { 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 = { 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 #2 = { "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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass