; LLVM IR from jgaeddert/liquid-dsp :: src/math/src (polyc)

; 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

declare { double, double } @__muldc3(double, double, double, double)

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

declare { double, double } @__divdc3(double, double, double, double)

; Function Attrs: nounwind uwtable
define dso_local { double, double } @polyc_val_lagrange_barycentric(ptr noundef %0, ptr noundef %1, ptr noundef %2, double noundef %3, double noundef %4, i32 noundef %5) #1 {
  %7 = alloca { double, double }, align 8
  %8 = alloca { double, double }, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca { double, double }, align 8
  %14 = alloca { double, double }, align 8
  %15 = alloca { double, double }, align 8
  %16 = alloca float, align 4
  %17 = alloca i32, align 4
  %18 = alloca { double, double }, align 8
  %19 = alloca i32, align 4
  %20 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 0
  store double %3, ptr %20, align 8
  %21 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 1
  store double %4, ptr %21, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store i32 %5, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #3
  %22 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 0
  %23 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 1
  store double 0.000000e+00, ptr %22, align 8
  store double 0.000000e+00, ptr %23, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #3
  %24 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 0
  %25 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 1
  store double 0.000000e+00, ptr %24, align 8
  store double 0.000000e+00, ptr %25, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store float 0x3EB0C6F7A0000000, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %143, %6
  %27 = load i32, ptr %17, align 4, !tbaa !9
  %28 = load i32, ptr %12, align 4, !tbaa !9
  %29 = icmp ult i32 %27, %28
  br i1 %29, label %30, label %146

30:                                               ; preds = %26
  %31 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 0
  %32 = load double, ptr %31, align 8
  %33 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 1
  %34 = load double, ptr %33, align 8
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = load i32, ptr %17, align 4, !tbaa !9
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds { double, double }, ptr %35, i64 %37
  %39 = getelementptr inbounds { double, double }, ptr %38, i32 0, i32 0
  %40 = load double, ptr %39, align 8
  %41 = getelementptr inbounds { double, double }, ptr %38, i32 0, i32 1
  %42 = load double, ptr %41, align 8
  %43 = fsub double %32, %40
  %44 = fsub double %34, %42
  %45 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 0
  %46 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 1
  store double %43, ptr %45, align 8
  store double %44, ptr %46, align 8
  %47 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 0
  %48 = load double, ptr %47, align 8
  %49 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 1
  %50 = load double, ptr %49, align 8
  %51 = getelementptr inbounds { double, double }, ptr %18, i32 0, i32 0
  %52 = getelementptr inbounds { double, double }, ptr %18, i32 0, i32 1
  store double %48, ptr %51, align 8
  store double %50, ptr %52, align 8
  %53 = getelementptr inbounds { double, double }, ptr %18, i32 0, i32 0
  %54 = load double, ptr %53, align 8
  %55 = getelementptr inbounds { double, double }, ptr %18, i32 0, i32 1
  %56 = load double, ptr %55, align 8
  %57 = call double @cabs(double noundef %54, double noundef %56) #3
  %58 = load float, ptr %16, align 4, !tbaa !11
  %59 = fpext float %58 to double
  %60 = fcmp olt double %57, %59
  br i1 %60, label %61, label %72

61:                                               ; preds = %30
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = load i32, ptr %17, align 4, !tbaa !9
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds { double, double }, ptr %62, i64 %64
  %66 = getelementptr inbounds { double, double }, ptr %65, i32 0, i32 0
  %67 = load double, ptr %66, align 8
  %68 = getelementptr inbounds { double, double }, ptr %65, i32 0, i32 1
  %69 = load double, ptr %68, align 8
  %70 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 0
  %71 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 1
  store double %67, ptr %70, align 8
  store double %69, ptr %71, align 8
  store i32 1, ptr %19, align 4
  br label %160

72:                                               ; preds = %30
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = load i32, ptr %17, align 4, !tbaa !9
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds { double, double }, ptr %73, i64 %75
  %77 = getelementptr inbounds { double, double }, ptr %76, i32 0, i32 0
  %78 = load double, ptr %77, align 8
  %79 = getelementptr inbounds { double, double }, ptr %76, i32 0, i32 1
  %80 = load double, ptr %79, align 8
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = load i32, ptr %17, align 4, !tbaa !9
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds { double, double }, ptr %81, i64 %83
  %85 = getelementptr inbounds { double, double }, ptr %84, i32 0, i32 0
  %86 = load double, ptr %85, align 8
  %87 = getelementptr inbounds { double, double }, ptr %84, i32 0, i32 1
  %88 = load double, ptr %87, align 8
  %89 = fmul double %78, %86
  %90 = fmul double %80, %88
  %91 = fmul double %78, %88
  %92 = fmul double %80, %86
  %93 = fsub double %89, %90
  %94 = fadd double %91, %92
  %95 = fcmp uno double %93, %93
  br i1 %95, label %96, label %102, !prof !13

96:                                               ; preds = %72
  %97 = fcmp uno double %94, %94
  br i1 %97, label %98, label %102, !prof !13

98:                                               ; preds = %96
  %99 = call { double, double } @__muldc3(double noundef %78, double noundef %80, double noundef %86, double noundef %88) #3
  %100 = extractvalue { double, double } %99, 0
  %101 = extractvalue { double, double } %99, 1
  br label %102

102:                                              ; preds = %98, %96, %72
  %103 = phi double [ %93, %72 ], [ %93, %96 ], [ %100, %98 ]
  %104 = phi double [ %94, %72 ], [ %94, %96 ], [ %101, %98 ]
  %105 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 0
  %106 = load double, ptr %105, align 8
  %107 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 1
  %108 = load double, ptr %107, align 8
  %109 = call { double, double } @__divdc3(double noundef %103, double noundef %104, double noundef %106, double noundef %108) #3
  %110 = extractvalue { double, double } %109, 0
  %111 = extractvalue { double, double } %109, 1
  %112 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 0
  %113 = load double, ptr %112, align 8
  %114 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 1
  %115 = load double, ptr %114, align 8
  %116 = fadd double %113, %110
  %117 = fadd double %115, %111
  %118 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 0
  %119 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 1
  store double %116, ptr %118, align 8
  store double %117, ptr %119, align 8
  %120 = load ptr, ptr %11, align 8, !tbaa !5
  %121 = load i32, ptr %17, align 4, !tbaa !9
  %122 = zext i32 %121 to i64
  %123 = getelementptr inbounds { double, double }, ptr %120, i64 %122
  %124 = getelementptr inbounds { double, double }, ptr %123, i32 0, i32 0
  %125 = load double, ptr %124, align 8
  %126 = getelementptr inbounds { double, double }, ptr %123, i32 0, i32 1
  %127 = load double, ptr %126, align 8
  %128 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 0
  %129 = load double, ptr %128, align 8
  %130 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 1
  %131 = load double, ptr %130, align 8
  %132 = call { double, double } @__divdc3(double noundef %125, double noundef %127, double noundef %129, double noundef %131) #3
  %133 = extractvalue { double, double } %132, 0
  %134 = extractvalue { double, double } %132, 1
  %135 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 0
  %136 = load double, ptr %135, align 8
  %137 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 1
  %138 = load double, ptr %137, align 8
  %139 = fadd double %136, %133
  %140 = fadd double %138, %134
  %141 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 0
  %142 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 1
  store double %139, ptr %141, align 8
  store double %140, ptr %142, align 8
  br label %143

143:                                              ; preds = %102
  %144 = load i32, ptr %17, align 4, !tbaa !9
  %145 = add i32 %144, 1
  store i32 %145, ptr %17, align 4, !tbaa !9
  br label %26, !llvm.loop !14

146:                                              ; preds = %26
  %147 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 0
  %148 = load double, ptr %147, align 8
  %149 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 1
  %150 = load double, ptr %149, align 8
  %151 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 0
  %152 = load double, ptr %151, align 8
  %153 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 1
  %154 = load double, ptr %153, align 8
  %155 = call { double, double } @__divdc3(double noundef %148, double noundef %150, double noundef %152, double noundef %154) #3
  %156 = extractvalue { double, double } %155, 0
  %157 = extractvalue { double, double } %155, 1
  %158 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 0
  %159 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 1
  store double %156, ptr %158, align 8
  store double %157, ptr %159, align 8
  store i32 1, ptr %19, align 4
  br label %160

160:                                              ; preds = %146, %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #3
  %161 = load { double, double }, ptr %7, align 8
  ret { double, double } %161
}

; Function Attrs: nounwind
declare double @cabs(double noundef, double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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"

declare { double, double } @__muldc3(double, double, double, double) local_unnamed_addr

declare { double, double } @__divdc3(double, double, double, double) local_unnamed_addr

; Function Attrs: nounwind uwtable
define dso_local { double, double } @polyc_val_lagrange_barycentric(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, double noundef %3, double noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %44
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %44 ]
  %.sroa.618.036 = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %51, %44 ]
  %.sroa.016.035 = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %50, %44 ]
  %.sroa.614.034 = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %58, %44 ]
  %.sroa.012.033 = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %57, %44 ]
  %7 = getelementptr inbounds { double, double }, ptr %0, i64 %indvars.iv
  %8 = load double, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr %7, i64 8
  %10 = load double, ptr %9, align 8
  %11 = fsub double %3, %8
  %12 = fsub double %4, %10
  %13 = tail call double @cabs(double noundef %11, double noundef %12) #2
  %14 = fcmp olt double %13, 0x3EB0C6F7A0000000
  br i1 %14, label %15, label %20

15:                                               ; preds = %.lr.ph
  %16 = getelementptr inbounds { double, double }, ptr %1, i64 %indvars.iv
  %17 = load double, ptr %16, align 8
  %18 = getelementptr inbounds i8, ptr %16, i64 8
  %19 = load double, ptr %18, align 8
  br label %62

20:                                               ; preds = %.lr.ph
  %21 = getelementptr inbounds { double, double }, ptr %2, i64 %indvars.iv
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = getelementptr inbounds { double, double }, ptr %1, i64 %indvars.iv
  %24 = load <2 x double>, ptr %21, align 8
  %25 = load <2 x double>, ptr %23, align 8
  %26 = fmul <2 x double> %24, %25
  %27 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> <i32 1, i32 0>
  %28 = fmul <2 x double> %27, %25
  %shift = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %29 = fsub <2 x double> %26, %shift
  %30 = extractelement <2 x double> %29, i64 0
  %shift55 = shufflevector <2 x double> %28, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %31 = fadd <2 x double> %28, %shift55
  %32 = extractelement <2 x double> %31, i64 0
  %33 = fcmp uno double %30, 0.000000e+00
  br i1 %33, label %34, label %44, !prof !5

34:                                               ; preds = %20
  %35 = fcmp uno double %32, 0.000000e+00
  br i1 %35, label %36, label %44, !prof !5

36:                                               ; preds = %34
  %37 = extractelement <2 x double> %24, i64 0
  %38 = extractelement <2 x double> %24, i64 1
  %39 = extractelement <2 x double> %25, i64 0
  %40 = extractelement <2 x double> %25, i64 1
  %41 = tail call { double, double } @__muldc3(double noundef %37, double noundef %38, double noundef %39, double noundef %40) #2
  %42 = extractvalue { double, double } %41, 0
  %43 = extractvalue { double, double } %41, 1
  br label %44

44:                                               ; preds = %36, %34, %20
  %45 = phi double [ %30, %20 ], [ %30, %34 ], [ %42, %36 ]
  %46 = phi double [ %32, %20 ], [ %32, %34 ], [ %43, %36 ]
  %47 = tail call { double, double } @__divdc3(double noundef %45, double noundef %46, double noundef %11, double noundef %12) #2
  %48 = extractvalue { double, double } %47, 0
  %49 = extractvalue { double, double } %47, 1
  %50 = fadd double %.sroa.016.035, %48
  %51 = fadd double %.sroa.618.036, %49
  %52 = load double, ptr %21, align 8
  %53 = load double, ptr %22, align 8
  %54 = tail call { double, double } @__divdc3(double noundef %52, double noundef %53, double noundef %11, double noundef %12) #2
  %55 = extractvalue { double, double } %54, 0
  %56 = extractvalue { double, double } %54, 1
  %57 = fadd double %.sroa.012.033, %55
  %58 = fadd double %.sroa.614.034, %56
  %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 = %44, %6
  %.sroa.012.0.lcssa = phi double [ 0.000000e+00, %6 ], [ %57, %44 ]
  %.sroa.614.0.lcssa = phi double [ 0.000000e+00, %6 ], [ %58, %44 ]
  %.sroa.016.0.lcssa = phi double [ 0.000000e+00, %6 ], [ %50, %44 ]
  %.sroa.618.0.lcssa = phi double [ 0.000000e+00, %6 ], [ %51, %44 ]
  %59 = tail call { double, double } @__divdc3(double noundef %.sroa.016.0.lcssa, double noundef %.sroa.618.0.lcssa, double noundef %.sroa.012.0.lcssa, double noundef %.sroa.614.0.lcssa) #2
  %60 = extractvalue { double, double } %59, 0
  %61 = extractvalue { double, double } %59, 1
  br label %62

62:                                               ; preds = %._crit_edge, %15
  %.sroa.028.0 = phi double [ %17, %15 ], [ %60, %._crit_edge ]
  %.sroa.3.0 = phi double [ %19, %15 ], [ %61, %._crit_edge ]
  %.fca.0.insert = insertvalue { double, double } poison, double %.sroa.028.0, 0
  %.fca.1.insert = insertvalue { double, double } %.fca.0.insert, double %.sroa.3.0, 1
  ret { double, double } %.fca.1.insert
}

; Function Attrs: nofree nounwind
declare double @cabs(double noundef, double noundef) local_unnamed_addr #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 = { nofree 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 = { 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