; 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.msresamp2_cccf_s = type { i32, i32, float, float, float, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, float }

; 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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @msresamp2_cccf_decim_execute(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %13, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.msresamp2_cccf_s, ptr %14, i32 0, i32 12
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  store ptr %16, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %9, align 4, !tbaa !13
  br label %17

17:                                               ; preds = %89, %3
  %18 = load i32, ptr %9, align 4, !tbaa !13
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.msresamp2_cccf_s, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 4, !tbaa !14
  %22 = icmp ult i32 %18, %21
  br i1 %22, label %23, label %92

23:                                               ; preds = %17
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.msresamp2_cccf_s, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !14
  %27 = load i32, ptr %9, align 4, !tbaa !13
  %28 = sub i32 %26, %27
  %29 = sub i32 %28, 1
  %30 = shl i32 1, %29
  store i32 %30, ptr %10, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.msresamp2_cccf_s, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !14
  %34 = load i32, ptr %9, align 4, !tbaa !13
  %35 = sub i32 %33, %34
  %36 = sub i32 %35, 1
  store i32 %36, ptr %12, align 4, !tbaa !13
  store i32 0, ptr %11, align 4, !tbaa !13
  br label %37

37:                                               ; preds = %59, %23
  %38 = load i32, ptr %11, align 4, !tbaa !13
  %39 = load i32, ptr %10, align 4, !tbaa !13
  %40 = icmp ult i32 %38, %39
  br i1 %40, label %41, label %62

41:                                               ; preds = %37
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.msresamp2_cccf_s, ptr %42, i32 0, i32 10
  %44 = load ptr, ptr %43, align 8, !tbaa !15
  %45 = load i32, ptr %12, align 4, !tbaa !13
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds ptr, ptr %44, i64 %46
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = load i32, ptr %11, align 4, !tbaa !13
  %51 = mul i32 2, %50
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds { float, float }, ptr %49, i64 %52
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = load i32, ptr %11, align 4, !tbaa !13
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds { float, float }, ptr %54, i64 %56
  %58 = call i32 @resamp2_cccf_decim_execute(ptr noundef %48, ptr noundef %53, ptr noundef %57)
  br label %59

59:                                               ; preds = %41
  %60 = load i32, ptr %11, align 4, !tbaa !13
  %61 = add i32 %60, 1
  store i32 %61, ptr %11, align 4, !tbaa !13
  br label %37, !llvm.loop !16

62:                                               ; preds = %37
  %63 = load i32, ptr %9, align 4, !tbaa !13
  %64 = urem i32 %63, 2
  %65 = icmp eq i32 %64, 0
  br i1 %65, label %66, label %70

66:                                               ; preds = %62
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.msresamp2_cccf_s, ptr %67, i32 0, i32 12
  %69 = load ptr, ptr %68, align 8, !tbaa !9
  br label %74

70:                                               ; preds = %62
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.msresamp2_cccf_s, ptr %71, i32 0, i32 11
  %73 = load ptr, ptr %72, align 8, !tbaa !18
  br label %74

74:                                               ; preds = %70, %66
  %75 = phi ptr [ %69, %66 ], [ %73, %70 ]
  store ptr %75, ptr %7, align 8, !tbaa !5
  %76 = load i32, ptr %9, align 4, !tbaa !13
  %77 = urem i32 %76, 2
  %78 = icmp eq i32 %77, 0
  br i1 %78, label %79, label %83

79:                                               ; preds = %74
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.msresamp2_cccf_s, ptr %80, i32 0, i32 11
  %82 = load ptr, ptr %81, align 8, !tbaa !18
  br label %87

83:                                               ; preds = %74
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.msresamp2_cccf_s, ptr %84, i32 0, i32 12
  %86 = load ptr, ptr %85, align 8, !tbaa !9
  br label %87

87:                                               ; preds = %83, %79
  %88 = phi ptr [ %82, %79 ], [ %86, %83 ]
  store ptr %88, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %89

89:                                               ; preds = %87
  %90 = load i32, ptr %9, align 4, !tbaa !13
  %91 = add i32 %90, 1
  store i32 %91, ptr %9, align 4, !tbaa !13
  br label %17, !llvm.loop !19

92:                                               ; preds = %17
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds { float, float }, ptr %93, i64 0
  %95 = getelementptr inbounds { float, float }, ptr %94, i32 0, i32 0
  %96 = load float, ptr %95, align 4
  %97 = getelementptr inbounds { float, float }, ptr %94, i32 0, i32 1
  %98 = load float, ptr %97, align 4
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.msresamp2_cccf_s, ptr %99, i32 0, i32 14
  %101 = load float, ptr %100, align 4, !tbaa !20
  %102 = fmul float %96, %101
  %103 = fmul float %98, %101
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = getelementptr inbounds { float, float }, ptr %104, i32 0, i32 0
  %106 = getelementptr inbounds { float, float }, ptr %104, i32 0, i32 1
  store float %102, ptr %105, align 4
  store float %103, ptr %106, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 72}
!10 = !{!"msresamp2_cccf_s", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !11, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !11, i64 80, !12, i64 84}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 4}
!15 = !{!10, !6, i64 56}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!10, !6, i64 64}
!19 = distinct !{!19, !17}
!20 = !{!10, !12, i64 84}


; 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
declare dso_local i32 @resamp2_cccf_decim_execute(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @msresamp2_cccf_decim_execute(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 72
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  br label %9

9:                                                ; preds = %.lr.ph, %26
  %10 = phi i32 [ %6, %.lr.ph ], [ %31, %26 ]
  %.02735.in = phi ptr [ %4, %.lr.ph ], [ %.in30, %26 ]
  %.034 = phi ptr [ %1, %.lr.ph ], [ %29, %26 ]
  %.02833 = phi i32 [ 0, %.lr.ph ], [ %30, %26 ]
  %.02735 = load ptr, ptr %.02735.in, align 8, !tbaa !12
  %11 = xor i32 %.02833, -1
  %12 = add i32 %10, %11
  %13 = zext i32 %12 to i64
  br label %14

14:                                               ; preds = %9, %14
  %.02631 = phi i32 [ 0, %9 ], [ %24, %14 ]
  %15 = load ptr, ptr %7, align 8, !tbaa !13
  %16 = getelementptr inbounds ptr, ptr %15, i64 %13
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  %18 = shl i32 %.02631, 1
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds { float, float }, ptr %.034, i64 %19
  %21 = zext i32 %.02631 to i64
  %22 = getelementptr inbounds { float, float }, ptr %.02735, i64 %21
  %23 = tail call i32 @resamp2_cccf_decim_execute(ptr noundef %17, ptr noundef %20, ptr noundef %22)
  %24 = add i32 %.02631, 1
  %.026.highbits = lshr i32 %24, %12
  %25 = icmp eq i32 %.026.highbits, 0
  br i1 %25, label %14, label %26, !llvm.loop !14

26:                                               ; preds = %14
  %27 = and i32 %.02833, 1
  %28 = icmp eq i32 %27, 0
  %.in = select i1 %28, ptr %4, ptr %8
  %29 = load ptr, ptr %.in, align 8, !tbaa !12
  %.in30 = select i1 %28, ptr %8, ptr %4
  %30 = add nuw i32 %.02833, 1
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = icmp ult i32 %30, %31
  br i1 %32, label %9, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %26, %3
  %.0.lcssa = phi ptr [ %1, %3 ], [ %29, %26 ]
  %33 = getelementptr inbounds i8, ptr %0, i64 84
  %34 = load float, ptr %33, align 4, !tbaa !17
  %35 = load <2 x float>, ptr %.0.lcssa, align 4
  %36 = insertelement <2 x float> poison, float %34, i64 0
  %37 = shufflevector <2 x float> %36, <2 x float> poison, <2 x i32> zeroinitializer
  %38 = fmul <2 x float> %35, %37
  store <2 x float> %38, ptr %2, align 4
  ret i32 0
}

attributes #0 = { 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 #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" }

!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, !7, i64 4}
!6 = !{!"msresamp2_cccf_s", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !7, i64 20, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !7, i64 80, !10, i64 84}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!6, !11, i64 56}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = !{!6, !10, i64 84}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass