; LLVM IR from jgaeddert/liquid-dsp :: src/filter/src (filter_crcf)

; 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.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [67 x i8], align 1

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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_crcf_create(i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @firinterp_crcf_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.48, i32 noundef 152, ptr noundef @.str.58, ptr noundef @.str.2)
  store ptr %10, ptr %2, align 8
  br label %59

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, 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 = %30, %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 %33

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, ptr %16, i64 %28
  store float %26, ptr %29, align 4, !tbaa !9
  br label %30

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

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

34:                                               ; preds = %50, %33
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = icmp ult i32 %35, %36
  br i1 %37, label %38, label %53

38:                                               ; preds = %34
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = uitofp i32 %39 to float
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = uitofp i32 %41 to float
  %43 = fdiv float %40, %42
  %44 = fsub float 1.000000e+00, %43
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = add i32 %45, %46
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds float, ptr %16, i64 %48
  store float %44, ptr %49, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %38
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = add i32 %51, 1
  store i32 %52, ptr %4, align 4, !tbaa !5
  br label %34, !llvm.loop !13

53:                                               ; preds = %34
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = mul i32 2, %55
  %57 = call ptr @firinterp_crcf_create(i32 noundef %54, ptr noundef %16, i32 noundef %56)
  store ptr %57, ptr %2, align 8
  %58 = load ptr, ptr %5, align 8
  call void @llvm.stackrestore.p0(ptr %58)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %59

59:                                               ; preds = %53, %9
  %60 = load ptr, ptr %2, align 8
  ret ptr %60
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.58 = 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_crcf_create(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @firinterp_crcf_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.48, i32 noundef 152, ptr noundef nonnull @.str.58, ptr noundef nonnull @.str.2) #3
  br label %58

5:                                                ; preds = %1
  %6 = shl i32 %0, 1
  %7 = zext i32 %6 to i64
  %8 = tail call ptr @llvm.stacksave.p0()
  %9 = alloca 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, ptr %9, i64 %index
  store <4 x float> %12, ptr %13, align 16, !tbaa !5
  %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 !9

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, ptr %9, i64 %indvars.iv
  store float %17, ptr %18, align 4, !tbaa !5
  %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 !13

.preheader.preheader:                             ; preds = %scalar.ph, %middle.block
  %min.iters.check30 = icmp ult i32 %0, 4
  br i1 %min.iters.check30, label %.preheader.preheader43, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.preheader.preheader
  %19 = add nsw i64 %wide.trip.count, -1
  %20 = trunc i64 %19 to i32
  %21 = xor i32 %0, -1
  %22 = icmp ult i32 %21, %20
  %23 = icmp ugt i64 %19, 4294967295
  %24 = or i1 %22, %23
  br i1 %24, label %.preheader.preheader43, label %vector.ph31

vector.ph31:                                      ; preds = %vector.scevcheck
  %n.vec33 = and i64 %wide.trip.count, 4294967292
  %broadcast.splatinsert39 = insertelement <4 x float> poison, float %10, i64 0
  %broadcast.splat40 = shufflevector <4 x float> %broadcast.splatinsert39, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body35

vector.body35:                                    ; preds = %vector.body35, %vector.ph31
  %index36 = phi i64 [ 0, %vector.ph31 ], [ %index.next41, %vector.body35 ]
  %vec.ind37 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph31 ], [ %vec.ind.next38, %vector.body35 ]
  %25 = trunc i64 %index36 to i32
  %26 = uitofp <4 x i32> %vec.ind37 to <4 x float>
  %27 = fdiv <4 x float> %26, %broadcast.splat40
  %28 = fsub <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %27
  %29 = add i32 %25, %0
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds float, ptr %9, i64 %30
  store <4 x float> %28, ptr %31, align 4, !tbaa !5
  %index.next41 = add nuw i64 %index36, 4
  %vec.ind.next38 = add <4 x i32> %vec.ind37, <i32 4, i32 4, i32 4, i32 4>
  %32 = icmp eq i64 %index.next41, %n.vec33
  br i1 %32, label %middle.block28, label %vector.body35, !llvm.loop !14

middle.block28:                                   ; preds = %vector.body35
  %cmp.n42 = icmp eq i64 %n.vec33, %wide.trip.count
  br i1 %cmp.n42, label %.loopexit, label %.preheader.preheader43

.preheader.preheader43:                           ; preds = %middle.block28, %vector.scevcheck, %.preheader.preheader
  %indvars.iv23.ph = phi i64 [ 0, %vector.scevcheck ], [ 0, %.preheader.preheader ], [ %n.vec33, %middle.block28 ]
  %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.preheader43
  %33 = trunc nuw i64 %indvars.iv23.ph to i32
  %34 = uitofp i32 %33 to float
  %35 = fdiv float %34, %10
  %36 = fsub float 1.000000e+00, %35
  %37 = add i32 %33, %0
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds float, ptr %9, i64 %38
  store float %36, ptr %39, align 4, !tbaa !5
  %indvars.iv.next24.prol = or disjoint i64 %indvars.iv23.ph, 1
  br label %.preheader.prol.loopexit

.preheader.prol.loopexit:                         ; preds = %.preheader.prol, %.preheader.preheader43
  %indvars.iv23.unr = phi i64 [ %indvars.iv23.ph, %.preheader.preheader43 ], [ %indvars.iv.next24.prol, %.preheader.prol ]
  %40 = add nsw i64 %wide.trip.count, -1
  %41 = icmp eq i64 %indvars.iv23.ph, %40
  br i1 %41, 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 ]
  %42 = trunc nuw i64 %indvars.iv23 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, ptr %9, i64 %47
  store float %45, ptr %48, align 4, !tbaa !5
  %49 = trunc i64 %indvars.iv23 to i32
  %50 = add i32 %49, 1
  %51 = uitofp i32 %50 to float
  %52 = fdiv float %51, %10
  %53 = fsub float 1.000000e+00, %52
  %54 = add i32 %50, %0
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds float, ptr %9, i64 %55
  store float %53, ptr %56, align 4, !tbaa !5
  %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 !15

.loopexit:                                        ; preds = %.preheader.prol.loopexit, %.preheader, %middle.block28
  %57 = call ptr @firinterp_crcf_create(i32 noundef %0, ptr noundef nonnull %9, i32 noundef %6)
  call void @llvm.stackrestore.p0(ptr %8)
  br label %58

58:                                               ; preds = %.loopexit, %3
  %.0 = phi ptr [ %4, %3 ], [ %57, %.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 = !{!6, !6, i64 0}
!6 = !{!"float", !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, !11, !12}
!15 = distinct !{!15, !10, !11}


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