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

%struct.firpfbchr_crcf_s = type { i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32 }

; 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 i32 @fft_execute(ptr noundef) #1

declare i32 @windowcf_read(ptr noundef, ptr noundef) #1

declare i32 @dotprod_crcf_execute(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @firpfbchr_crcf_execute(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %49, %2
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.firpfbchr_crcf_s, ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 8, !tbaa !11
  %14 = icmp ult i32 %10, %13
  br i1 %14, label %15, label %52

15:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.firpfbchr_crcf_s, ptr %16, i32 0, i32 9
  %18 = load i32, ptr %17, align 8, !tbaa !13
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = add i32 %18, %19
  %21 = add i32 %20, 1
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.firpfbchr_crcf_s, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = urem i32 %21, %24
  store i32 %25, ptr %7, align 4, !tbaa !9
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.firpfbchr_crcf_s, ptr %26, i32 0, i32 8
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds ptr, ptr %28, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = call i32 @windowcf_read(ptr noundef %32, ptr noundef %6)
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.firpfbchr_crcf_s, ptr %34, i32 0, i32 4
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds ptr, ptr %36, i64 %38
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.firpfbchr_crcf_s, ptr %42, i32 0, i32 6
  %44 = load ptr, ptr %43, align 8, !tbaa !16
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds { float, float }, ptr %44, i64 %46
  %48 = call i32 @dotprod_crcf_execute(ptr noundef %40, ptr noundef %41, ptr noundef %47)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %49

49:                                               ; preds = %15
  %50 = load i32, ptr %5, align 4, !tbaa !9
  %51 = add i32 %50, 1
  store i32 %51, ptr %5, align 4, !tbaa !9
  br label %9, !llvm.loop !17

52:                                               ; preds = %9
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.firpfbchr_crcf_s, ptr %53, i32 0, i32 5
  %55 = load ptr, ptr %54, align 8, !tbaa !19
  %56 = call i32 @fft_execute(ptr noundef %55)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.firpfbchr_crcf_s, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %58, align 8, !tbaa !11
  %60 = uitofp i32 %59 to float
  %61 = fdiv float 1.000000e+00, %60
  store float %61, ptr %8, align 4, !tbaa !20
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %88, %52
  %63 = load i32, ptr %5, align 4, !tbaa !9
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.firpfbchr_crcf_s, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 8, !tbaa !11
  %67 = icmp ult i32 %63, %66
  br i1 %67, label %68, label %91

68:                                               ; preds = %62
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.firpfbchr_crcf_s, ptr %69, i32 0, i32 7
  %71 = load ptr, ptr %70, align 8, !tbaa !22
  %72 = load i32, ptr %5, align 4, !tbaa !9
  %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 = load float, ptr %75, align 4
  %77 = getelementptr inbounds { float, float }, ptr %74, i32 0, i32 1
  %78 = load float, ptr %77, align 4
  %79 = load float, ptr %8, align 4, !tbaa !20
  %80 = fmul float %76, %79
  %81 = fmul float %78, %79
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = load i32, ptr %5, align 4, !tbaa !9
  %84 = zext i32 %83 to i64
  %85 = getelementptr inbounds { float, float }, ptr %82, i64 %84
  %86 = getelementptr inbounds { float, float }, ptr %85, i32 0, i32 0
  %87 = getelementptr inbounds { float, float }, ptr %85, i32 0, i32 1
  store float %80, ptr %86, align 4
  store float %81, ptr %87, align 4
  br label %88

88:                                               ; preds = %68
  %89 = load i32, ptr %5, align 4, !tbaa !9
  %90 = add i32 %89, 1
  store i32 %90, ptr %5, align 4, !tbaa !9
  br label %62, !llvm.loop !23

91:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 0
}

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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"firpfbchr_crcf_s", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56}
!13 = !{!12, !10, i64 56}
!14 = !{!12, !6, i64 48}
!15 = !{!12, !6, i64 16}
!16 = !{!12, !6, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!12, !6, i64 24}
!20 = !{!21, !21, i64 0}
!21 = !{!"float", !7, i64 0}
!22 = !{!12, !6, i64 40}
!23 = distinct !{!23, !18}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

declare i32 @fft_execute(ptr noundef) local_unnamed_addr #1

declare i32 @windowcf_read(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @dotprod_crcf_execute(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @firpfbchr_crcf_execute(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 56
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  br label %9

9:                                                ; preds = %.lr.ph, %9
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %9 ]
  %10 = phi i32 [ %4, %.lr.ph ], [ %27, %9 ]
  %11 = load i32, ptr %5, align 8, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %12 = trunc nuw i64 %indvars.iv.next to i32
  %13 = add i32 %11, %12
  %14 = urem i32 %13, %10
  %15 = load ptr, ptr %6, align 8, !tbaa !12
  %16 = zext i32 %14 to i64
  %17 = getelementptr inbounds ptr, ptr %15, i64 %16
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = call i32 @windowcf_read(ptr noundef %18, ptr noundef nonnull %3) #3
  %20 = load ptr, ptr %7, align 8, !tbaa !14
  %21 = getelementptr inbounds ptr, ptr %20, i64 %indvars.iv
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = load ptr, ptr %3, align 8, !tbaa !13
  %24 = load ptr, ptr %8, align 8, !tbaa !15
  %25 = getelementptr inbounds { float, float }, ptr %24, i64 %16
  %26 = call i32 @dotprod_crcf_execute(ptr noundef %22, ptr noundef %23, ptr noundef %25) #3
  %27 = load i32, ptr %0, align 8, !tbaa !5
  %28 = zext i32 %27 to i64
  %29 = icmp ult i64 %indvars.iv.next, %28
  br i1 %29, label %9, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %9, %2
  %30 = getelementptr inbounds i8, ptr %0, i64 24
  %31 = load ptr, ptr %30, align 8, !tbaa !18
  %32 = call i32 @fft_execute(ptr noundef %31) #3
  %33 = load i32, ptr %0, align 8, !tbaa !5
  %.not27 = icmp eq i32 %33, 0
  br i1 %.not27, label %._crit_edge26, label %.lr.ph25

.lr.ph25:                                         ; preds = %._crit_edge
  %34 = uitofp i32 %33 to float
  %35 = fdiv float 1.000000e+00, %34
  %36 = getelementptr inbounds i8, ptr %0, i64 40
  %37 = insertelement <2 x float> poison, float %35, i64 0
  %38 = shufflevector <2 x float> %37, <2 x float> poison, <2 x i32> zeroinitializer
  br label %39

39:                                               ; preds = %.lr.ph25, %39
  %indvars.iv29 = phi i64 [ 0, %.lr.ph25 ], [ %indvars.iv.next30, %39 ]
  %40 = load ptr, ptr %36, align 8, !tbaa !19
  %41 = getelementptr inbounds { float, float }, ptr %40, i64 %indvars.iv29
  %42 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv29
  %43 = load <2 x float>, ptr %41, align 4
  %44 = fmul <2 x float> %38, %43
  store <2 x float> %44, ptr %42, align 4
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %45 = load i32, ptr %0, align 8, !tbaa !5
  %46 = zext i32 %45 to i64
  %47 = icmp ult i64 %indvars.iv.next30, %46
  br i1 %47, label %39, label %._crit_edge26, !llvm.loop !20

._crit_edge26:                                    ; preds = %39, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret i32 0
}

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass