; LLVM IR from jgaeddert/liquid-dsp :: src/filter/src (filter_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"

@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.52 = external hidden unnamed_addr constant [67 x i8], align 1

; 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

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @firinterp_cccf_create(i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @firinterp_cccf_create_linear(i32 noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = icmp ult i32 %7, 1
  br i1 %8, label %9, label %11

9:                                                ; preds = %1
  %10 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.42, i32 noundef 152, ptr noundef @.str.52, ptr noundef @.str.3)
  store ptr %10, ptr %2, align 8
  br label %63

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = mul i32 2, %12
  %14 = zext i32 %13 to i64
  %15 = call ptr @llvm.stacksave.p0()
  store ptr %15, ptr %5, align 8
  %16 = alloca { float, float }, i64 %14, align 16
  store i64 %14, ptr %6, align 8
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %32, %11
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = icmp ult i32 %18, %19
  br i1 %20, label %21, label %35

21:                                               ; preds = %17
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = uitofp i32 %22 to float
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = uitofp i32 %24 to float
  %26 = fdiv float %23, %25
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds { float, float }, ptr %16, i64 %28
  %30 = getelementptr inbounds { float, float }, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds { float, float }, ptr %29, i32 0, i32 1
  store float %26, ptr %30, align 8
  store float 0.000000e+00, ptr %31, align 4
  br label %32

32:                                               ; preds = %21
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = add i32 %33, 1
  store i32 %34, ptr %4, align 4, !tbaa !5
  br label %17, !llvm.loop !9

35:                                               ; preds = %17
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %54, %35
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = icmp ult i32 %37, %38
  br i1 %39, label %40, label %57

40:                                               ; preds = %36
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = uitofp i32 %41 to float
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = uitofp i32 %43 to float
  %45 = fdiv float %42, %44
  %46 = fsub float 1.000000e+00, %45
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = add i32 %47, %48
  %50 = zext i32 %49 to i64
  %51 = getelementptr inbounds { float, float }, ptr %16, i64 %50
  %52 = getelementptr inbounds { float, float }, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds { float, float }, ptr %51, i32 0, i32 1
  store float %46, ptr %52, align 8
  store float 0.000000e+00, ptr %53, align 4
  br label %54

54:                                               ; preds = %40
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = add i32 %55, 1
  store i32 %56, ptr %4, align 4, !tbaa !5
  br label %36, !llvm.loop !11

57:                                               ; preds = %36
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = mul i32 2, %59
  %61 = call ptr @firinterp_cccf_create(i32 noundef %58, ptr noundef %16, i32 noundef %60)
  store ptr %61, ptr %2, align 8
  %62 = load ptr, ptr %5, align 8
  call void @llvm.stackrestore.p0(ptr %62)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %63

63:                                               ; preds = %57, %9
  %64 = load ptr, ptr %2, align 8
  ret ptr %64
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nocallback nofree nosync nounwind willreturn }
attributes #3 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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

@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.52 = external hidden unnamed_addr constant [67 x i8], align 1

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @firinterp_cccf_create(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @firinterp_cccf_create_linear(i32 noundef %0) local_unnamed_addr #2 {
  %2 = icmp eq i32 %0, 0
  br i1 %2, label %3, label %5

3:                                                ; preds = %1
  %4 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.42, i32 noundef 152, ptr noundef nonnull @.str.52, ptr noundef nonnull @.str.3) #3
  br label %70

5:                                                ; preds = %1
  %6 = shl i32 %0, 1
  %7 = zext i32 %6 to i64
  %8 = tail call ptr @llvm.stacksave.p0()
  %9 = alloca { float, float }, i64 %7, align 16
  %10 = uitofp i32 %0 to float
  %wide.trip.count = zext i32 %0 to i64
  %min.iters.check = icmp ult i32 %0, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %5
  %n.vec = and i64 %wide.trip.count, 4294967292
  %broadcast.splatinsert = insertelement <4 x float> poison, float %10, i64 0
  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %11 = uitofp <4 x i32> %vec.ind to <4 x float>
  %12 = fdiv <4 x float> %11, %broadcast.splat
  %13 = getelementptr inbounds { float, float }, ptr %9, i64 %index
  %interleaved.vec = shufflevector <4 x float> %12, <4 x float> zeroinitializer, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
  store <8 x float> %interleaved.vec, ptr %13, align 16
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %14 = icmp eq i64 %index.next, %n.vec
  br i1 %14, label %middle.block, label %vector.body, !llvm.loop !5

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

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

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %15 = trunc nuw i64 %indvars.iv to i32
  %16 = uitofp i32 %15 to float
  %17 = fdiv float %16, %10
  %18 = getelementptr inbounds { float, float }, ptr %9, i64 %indvars.iv
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  store float %17, ptr %18, align 8
  store float 0.000000e+00, ptr %19, align 4
  %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 %.preheader.preheader, label %scalar.ph, !llvm.loop !9

.preheader.preheader:                             ; preds = %scalar.ph, %middle.block
  %min.iters.check34 = icmp ult i32 %0, 8
  br i1 %min.iters.check34, label %.preheader.preheader48, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.preheader.preheader
  %20 = add nsw i64 %wide.trip.count, -1
  %21 = trunc i64 %20 to i32
  %22 = xor i32 %0, -1
  %23 = icmp ult i32 %22, %21
  %24 = icmp ugt i64 %20, 4294967295
  %25 = or i1 %23, %24
  %26 = shl nuw nsw i64 %wide.trip.count, 3
  %scevgep = getelementptr i8, ptr %9, i64 %26
  %mul.result = shl nsw i64 %20, 3
  %27 = getelementptr i8, ptr %scevgep, i64 %mul.result
  %28 = icmp ult ptr %27, %scevgep
  %29 = or disjoint i64 %26, 4
  %scevgep28 = getelementptr i8, ptr %9, i64 %29
  %mul.result30 = shl nsw i64 %20, 3
  %30 = getelementptr i8, ptr %scevgep28, i64 %mul.result30
  %31 = icmp ult ptr %30, %scevgep28
  %32 = or i1 %28, %25
  %33 = or i1 %31, %32
  br i1 %33, label %.preheader.preheader48, label %vector.ph35

vector.ph35:                                      ; preds = %vector.scevcheck
  %n.vec37 = and i64 %wide.trip.count, 4294967292
  %broadcast.splatinsert43 = insertelement <4 x float> poison, float %10, i64 0
  %broadcast.splat44 = shufflevector <4 x float> %broadcast.splatinsert43, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body39

vector.body39:                                    ; preds = %vector.body39, %vector.ph35
  %index40 = phi i64 [ 0, %vector.ph35 ], [ %index.next46, %vector.body39 ]
  %vec.ind41 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph35 ], [ %vec.ind.next42, %vector.body39 ]
  %34 = trunc i64 %index40 to i32
  %35 = uitofp <4 x i32> %vec.ind41 to <4 x float>
  %36 = fdiv <4 x float> %35, %broadcast.splat44
  %37 = fsub <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %36
  %38 = add i32 %34, %0
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds { float, float }, ptr %9, i64 %39
  %interleaved.vec45 = shufflevector <4 x float> %37, <4 x float> zeroinitializer, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
  store <8 x float> %interleaved.vec45, ptr %40, align 8
  %index.next46 = add nuw i64 %index40, 4
  %vec.ind.next42 = add <4 x i32> %vec.ind41, <i32 4, i32 4, i32 4, i32 4>
  %41 = icmp eq i64 %index.next46, %n.vec37
  br i1 %41, label %middle.block32, label %vector.body39, !llvm.loop !10

middle.block32:                                   ; preds = %vector.body39
  %cmp.n47 = icmp eq i64 %n.vec37, %wide.trip.count
  br i1 %cmp.n47, label %.loopexit, label %.preheader.preheader48

.preheader.preheader48:                           ; preds = %middle.block32, %vector.scevcheck, %.preheader.preheader
  %indvars.iv23.ph = phi i64 [ 0, %vector.scevcheck ], [ 0, %.preheader.preheader ], [ %n.vec37, %middle.block32 ]
  %xtraiter = and i64 %wide.trip.count, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader.prol.loopexit, label %.preheader.prol

.preheader.prol:                                  ; preds = %.preheader.preheader48
  %42 = trunc nuw i64 %indvars.iv23.ph to i32
  %43 = uitofp i32 %42 to float
  %44 = fdiv float %43, %10
  %45 = fsub float 1.000000e+00, %44
  %46 = add i32 %42, %0
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds { float, float }, ptr %9, i64 %47
  %49 = getelementptr inbounds i8, ptr %48, i64 4
  store float %45, ptr %48, align 8
  store float 0.000000e+00, ptr %49, align 4
  %indvars.iv.next24.prol = or disjoint i64 %indvars.iv23.ph, 1
  br label %.preheader.prol.loopexit

.preheader.prol.loopexit:                         ; preds = %.preheader.prol, %.preheader.preheader48
  %indvars.iv23.unr = phi i64 [ %indvars.iv23.ph, %.preheader.preheader48 ], [ %indvars.iv.next24.prol, %.preheader.prol ]
  %50 = add nsw i64 %wide.trip.count, -1
  %51 = icmp eq i64 %indvars.iv23.ph, %50
  br i1 %51, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %.preheader.prol.loopexit, %.preheader
  %indvars.iv23 = phi i64 [ %indvars.iv.next24.1, %.preheader ], [ %indvars.iv23.unr, %.preheader.prol.loopexit ]
  %52 = trunc nuw i64 %indvars.iv23 to i32
  %53 = uitofp i32 %52 to float
  %54 = fdiv float %53, %10
  %55 = fsub float 1.000000e+00, %54
  %56 = add i32 %52, %0
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds { float, float }, ptr %9, i64 %57
  %59 = getelementptr inbounds i8, ptr %58, i64 4
  store float %55, ptr %58, align 8
  store float 0.000000e+00, ptr %59, align 4
  %60 = trunc i64 %indvars.iv23 to i32
  %61 = add i32 %60, 1
  %62 = uitofp i32 %61 to float
  %63 = fdiv float %62, %10
  %64 = fsub float 1.000000e+00, %63
  %65 = add i32 %61, %0
  %66 = zext i32 %65 to i64
  %67 = getelementptr inbounds { float, float }, ptr %9, i64 %66
  %68 = getelementptr inbounds i8, ptr %67, i64 4
  store float %64, ptr %67, align 8
  store float 0.000000e+00, ptr %68, align 4
  %indvars.iv.next24.1 = add nuw nsw i64 %indvars.iv23, 2
  %exitcond27.not.1 = icmp eq i64 %indvars.iv.next24.1, %wide.trip.count
  br i1 %exitcond27.not.1, label %.loopexit, label %.preheader, !llvm.loop !11

.loopexit:                                        ; preds = %.preheader.prol.loopexit, %.preheader, %middle.block32
  %69 = call ptr @firinterp_cccf_create(i32 noundef %0, ptr noundef nonnull %9, i32 noundef %6)
  call void @llvm.stackrestore.p0(ptr %8)
  br label %70

70:                                               ; preds = %.loopexit, %3
  %.0 = phi ptr [ %4, %3 ], [ %69, %.loopexit ]
  ret ptr %.0
}

attributes #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 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #2 = { 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 #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 = distinct !{!5, !6, !7, !8}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.isvectorized", i32 1}
!8 = !{!"llvm.loop.unroll.runtime.disable"}
!9 = distinct !{!9, !6, !8, !7}
!10 = distinct !{!10, !6, !7, !8}
!11 = distinct !{!11, !6, !7}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass