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

%struct.rresamp_cccf_s = type { i32, i32, i32, 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

declare i32 @liquid_firdes_prototype(i32 noundef, i32 noundef, i32 noundef, float noundef, float noundef, ptr noundef) #3

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

declare i32 @liquid_gcd(i32 noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @rresamp_cccf_set_scale(ptr noundef, <2 x float> noundef) #5

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @rresamp_cccf_create_prototype(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, float noundef %4) #5 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca float, align 4
  %20 = alloca { float, float }, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store float %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = load i32, ptr %8, align 4, !tbaa !5
  %23 = call i32 @liquid_gcd(i32 noundef %21, i32 noundef %22)
  store i32 %23, ptr %11, align 4, !tbaa !5
  %24 = load i32, ptr %11, align 4, !tbaa !5
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = udiv i32 %25, %24
  store i32 %26, ptr %7, align 4, !tbaa !5
  %27 = load i32, ptr %11, align 4, !tbaa !5
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = udiv i32 %28, %27
  store i32 %29, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = icmp ult i32 %30, %31
  %33 = zext i1 %32 to i32
  store i32 %33, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %34 = load i32, ptr %12, align 4, !tbaa !5
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %5
  %37 = load i32, ptr %8, align 4, !tbaa !5
  br label %40

38:                                               ; preds = %5
  %39 = load i32, ptr %7, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %38, %36
  %41 = phi i32 [ %37, %36 ], [ %39, %38 ]
  store i32 %41, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %42 = load i32, ptr %13, align 4, !tbaa !5
  %43 = mul i32 2, %42
  %44 = load i32, ptr %9, align 4, !tbaa !5
  %45 = mul i32 %43, %44
  %46 = add i32 %45, 1
  store i32 %46, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %47 = load i32, ptr %14, align 4, !tbaa !5
  %48 = zext i32 %47 to i64
  %49 = mul i64 %48, 4
  %50 = call noalias ptr @malloc(i64 noundef %49) #7
  store ptr %50, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %51 = load i32, ptr %14, align 4, !tbaa !5
  %52 = zext i32 %51 to i64
  %53 = mul i64 %52, 8
  %54 = call noalias ptr @malloc(i64 noundef %53) #7
  store ptr %54, ptr %16, align 8, !tbaa !11
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = load i32, ptr %13, align 4, !tbaa !5
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = load float, ptr %10, align 4, !tbaa !9
  %59 = load ptr, ptr %15, align 8, !tbaa !11
  %60 = call i32 @liquid_firdes_prototype(i32 noundef %55, i32 noundef %56, i32 noundef %57, float noundef %58, float noundef 0.000000e+00, ptr noundef %59)
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %77, %40
  %62 = load i32, ptr %17, align 4, !tbaa !5
  %63 = load i32, ptr %14, align 4, !tbaa !5
  %64 = icmp ult i32 %62, %63
  br i1 %64, label %65, label %80

65:                                               ; preds = %61
  %66 = load ptr, ptr %15, align 8, !tbaa !11
  %67 = load i32, ptr %17, align 4, !tbaa !5
  %68 = zext i32 %67 to i64
  %69 = getelementptr inbounds float, ptr %66, i64 %68
  %70 = load float, ptr %69, align 4, !tbaa !9
  %71 = load ptr, ptr %16, align 8, !tbaa !11
  %72 = load i32, ptr %17, align 4, !tbaa !5
  %73 = zext i32 %72 to i64
  %74 = getelementptr inbounds { float, float }, ptr %71, i64 %73
  %75 = getelementptr inbounds { float, float }, ptr %74, i32 0, i32 0
  %76 = getelementptr inbounds { float, float }, ptr %74, i32 0, i32 1
  store float %70, ptr %75, align 4
  store float 0.000000e+00, ptr %76, align 4
  br label %77

77:                                               ; preds = %65
  %78 = load i32, ptr %17, align 4, !tbaa !5
  %79 = add i32 %78, 1
  store i32 %79, ptr %17, align 4, !tbaa !5
  br label %61, !llvm.loop !13

80:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %81 = load i32, ptr %7, align 4, !tbaa !5
  %82 = load i32, ptr %8, align 4, !tbaa !5
  %83 = load i32, ptr %9, align 4, !tbaa !5
  %84 = load ptr, ptr %16, align 8, !tbaa !11
  %85 = call ptr @rresamp_cccf_create(i32 noundef %81, i32 noundef %82, i32 noundef %83, ptr noundef %84)
  store ptr %85, ptr %18, align 8, !tbaa !11
  %86 = load i32, ptr %11, align 4, !tbaa !5
  %87 = load ptr, ptr %18, align 8, !tbaa !11
  %88 = getelementptr inbounds %struct.rresamp_cccf_s, ptr %87, i32 0, i32 3
  store i32 %86, ptr %88, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %89 = load ptr, ptr %18, align 8, !tbaa !11
  %90 = call float @rresamp_cccf_get_rate(ptr noundef %89)
  store float %90, ptr %19, align 4, !tbaa !9
  %91 = load ptr, ptr %18, align 8, !tbaa !11
  %92 = load i32, ptr %12, align 4, !tbaa !5
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %97

94:                                               ; preds = %80
  %95 = load float, ptr %19, align 4, !tbaa !9
  %96 = call float @sqrtf(float noundef %95) #6
  br label %101

97:                                               ; preds = %80
  %98 = load float, ptr %19, align 4, !tbaa !9
  %99 = call float @sqrtf(float noundef %98) #6
  %100 = fdiv float 1.000000e+00, %99
  br label %101

101:                                              ; preds = %97, %94
  %102 = phi float [ %96, %94 ], [ %100, %97 ]
  %103 = getelementptr inbounds { float, float }, ptr %20, i32 0, i32 0
  %104 = getelementptr inbounds { float, float }, ptr %20, i32 0, i32 1
  store float %102, ptr %103, align 4
  store float 0.000000e+00, ptr %104, align 4
  %105 = load <2 x float>, ptr %20, align 4
  %106 = call i32 @rresamp_cccf_set_scale(ptr noundef %91, <2 x float> noundef %105)
  %107 = load ptr, ptr %15, align 8, !tbaa !11
  call void @free(ptr noundef %107) #6
  %108 = load ptr, ptr %16, align 8, !tbaa !11
  call void @free(ptr noundef %108) #6
  %109 = load ptr, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  ret ptr %109
}

; Function Attrs: nounwind uwtable
declare dso_local float @rresamp_cccf_get_rate(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 = { "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 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 #5 = { nounwind uwtable "min-legal-vector-width"="64" "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !6, i64 12}
!16 = !{!"rresamp_cccf_s", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !12, i64 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

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

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

declare i32 @liquid_gcd(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @rresamp_cccf_set_scale(ptr noundef, <2 x float> noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @rresamp_cccf_create_prototype(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, float noundef %4) local_unnamed_addr #4 {
  %6 = tail call i32 @liquid_gcd(i32 noundef %1, i32 noundef %2) #7
  %7 = udiv i32 %1, %6
  %8 = udiv i32 %2, %6
  %9 = tail call i32 @llvm.umax.i32(i32 %7, i32 %8)
  %10 = shl i32 %9, 1
  %11 = mul i32 %10, %3
  %12 = or disjoint i32 %11, 1
  %13 = zext i32 %12 to i64
  %14 = shl nuw nsw i64 %13, 2
  %15 = tail call noalias ptr @malloc(i64 noundef %14) #8
  %16 = shl nuw nsw i64 %13, 3
  %17 = tail call noalias ptr @malloc(i64 noundef %16) #8
  %18 = tail call i32 @liquid_firdes_prototype(i32 noundef %0, i32 noundef %9, i32 noundef %3, float noundef %4, float noundef 0.000000e+00, ptr noundef %15) #7
  %19 = zext i32 %11 to i64
  %min.iters.check = icmp ult i32 %11, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

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

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %20 = or disjoint i64 %index, 2
  %21 = getelementptr inbounds float, ptr %15, i64 %index
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %wide.load = load <2 x float>, ptr %21, align 4, !tbaa !5
  %wide.load43 = load <2 x float>, ptr %22, align 4, !tbaa !5
  %23 = getelementptr inbounds { float, float }, ptr %17, i64 %index
  %24 = getelementptr inbounds { float, float }, ptr %17, i64 %20
  %interleaved.vec = shufflevector <2 x float> %wide.load, <2 x float> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec, ptr %23, align 4
  %interleaved.vec44 = shufflevector <2 x float> %wide.load43, <2 x float> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec44, ptr %24, align 4
  %index.next = add nuw i64 %index, 4
  %25 = icmp eq i64 %index.next, %n.vec
  br i1 %25, label %scalar.ph.preheader, label %vector.body, !llvm.loop !9

scalar.ph.preheader:                              ; preds = %vector.body, %5
  %indvars.iv.ph = phi i64 [ 0, %5 ], [ %n.vec, %vector.body ]
  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 ]
  %26 = getelementptr inbounds float, ptr %15, i64 %indvars.iv
  %27 = load float, ptr %26, align 4, !tbaa !5
  %28 = getelementptr inbounds { float, float }, ptr %17, i64 %indvars.iv
  %29 = getelementptr inbounds i8, ptr %28, i64 4
  store float %27, ptr %28, align 4
  store float 0.000000e+00, ptr %29, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.not.not = icmp ult i64 %indvars.iv, %19
  br i1 %.not.not, label %scalar.ph, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %scalar.ph
  %30 = icmp ult i32 %7, %8
  %31 = tail call ptr @rresamp_cccf_create(i32 noundef %7, i32 noundef %8, i32 noundef %3, ptr noundef nonnull %17)
  %32 = getelementptr inbounds i8, ptr %31, i64 12
  store i32 %6, ptr %32, align 4, !tbaa !14
  %33 = tail call float @rresamp_cccf_get_rate(ptr noundef %31)
  %34 = tail call float @sqrtf(float noundef %33) #7
  %35 = fdiv float 1.000000e+00, %34
  %36 = select i1 %30, float %34, float %35
  %.sroa.0.4.vec.insert = insertelement <2 x float> <float poison, float 0.000000e+00>, float %36, i64 0
  %37 = tail call i32 @rresamp_cccf_set_scale(ptr noundef nonnull %31, <2 x float> noundef %.sroa.0.4.vec.insert)
  tail call void @free(ptr noundef nonnull %15) #7
  tail call void @free(ptr noundef nonnull %17) #7
  ret ptr %31
}

; Function Attrs: nounwind uwtable
declare dso_local float @rresamp_cccf_get_rate(ptr noundef) local_unnamed_addr #3

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 uwtable "min-legal-vector-width"="64" "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 = { mustprogress nofree nounwind willreturn memory(write) "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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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 = !{!15, !16, i64 12}
!15 = !{!"rresamp_cccf_s", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12, !17, i64 16}
!16 = !{!"int", !7, i64 0}
!17 = !{!"any pointer", !7, i64 0}


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