; LLVM IR from jgaeddert/liquid-dsp :: src/framing/src (framing_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.qdsync_cccf_s = type { i32, i32, i32, i32, float, ptr, ptr, ptr, i32, i32, ptr, ptr, i32, i32, i32, i32, 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

; Function Attrs: nounwind uwtable
define dso_local i32 @qdsync_cccf_step(ptr noundef %0, <2 x float> noundef %1) #1 {
  %3 = alloca { float, float }, align 4
  %4 = alloca ptr, align 8
  %5 = alloca { float, float }, align 4
  %6 = alloca { float, float }, align 4
  %7 = alloca { float, float }, align 4
  %8 = alloca i32, align 4
  %9 = alloca { float, float }, align 4
  store <2 x float> %1, ptr %3, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.qdsync_cccf_s, ptr %10, i32 0, i32 10
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 0
  %14 = load float, ptr %13, align 4
  %15 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 1
  %16 = load float, ptr %15, align 4
  %17 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %18 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  store float %14, ptr %17, align 4
  store float %16, ptr %18, align 4
  %19 = load <2 x float>, ptr %6, align 4
  %20 = call i32 @nco_crcf_mix_down(ptr noundef %12, <2 x float> noundef %19, ptr noundef %5)
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.qdsync_cccf_s, ptr %21, i32 0, i32 10
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = call i32 @nco_crcf_step(ptr noundef %23)
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.qdsync_cccf_s, ptr %25, i32 0, i32 11
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %29 = load float, ptr %28, align 4
  %30 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %31 = load float, ptr %30, align 4
  %32 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %33 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  store float %29, ptr %32, align 4
  store float %31, ptr %33, align 4
  %34 = load <2 x float>, ptr %7, align 4
  %35 = call i32 @firpfb_crcf_push(ptr noundef %27, <2 x float> noundef %34)
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.qdsync_cccf_s, ptr %36, i32 0, i32 11
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.qdsync_cccf_s, ptr %39, i32 0, i32 14
  %41 = load i32, ptr %40, align 8, !tbaa !14
  %42 = call i32 @firpfb_crcf_execute(ptr noundef %38, i32 noundef %41, ptr noundef %5)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.qdsync_cccf_s, ptr %43, i32 0, i32 13
  %45 = load i32, ptr %44, align 4, !tbaa !15
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %44, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.qdsync_cccf_s, ptr %47, i32 0, i32 13
  %49 = load i32, ptr %48, align 4, !tbaa !15
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.qdsync_cccf_s, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 8, !tbaa !16
  %53 = sub i32 %52, 1
  %54 = icmp uge i32 %49, %53
  %55 = zext i1 %54 to i64
  %56 = select i1 %54, i32 1, i32 0
  store i32 %56, ptr %8, align 4, !tbaa !17
  %57 = load i32, ptr %8, align 4, !tbaa !17
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %76

59:                                               ; preds = %2
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.qdsync_cccf_s, ptr %60, i32 0, i32 2
  %62 = load i32, ptr %61, align 8, !tbaa !16
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.qdsync_cccf_s, ptr %63, i32 0, i32 13
  %65 = load i32, ptr %64, align 4, !tbaa !15
  %66 = sub i32 %65, %62
  store i32 %66, ptr %64, align 4, !tbaa !15
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %69 = load float, ptr %68, align 4
  %70 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %71 = load float, ptr %70, align 4
  %72 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %73 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %69, ptr %72, align 4
  store float %71, ptr %73, align 4
  %74 = load <2 x float>, ptr %9, align 4
  %75 = call i32 @qdsync_cccf_buf_append(ptr noundef %67, <2 x float> noundef %74)
  br label %76

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

declare i32 @nco_crcf_mix_down(ptr noundef, <2 x float> noundef, ptr noundef) #2

declare i32 @nco_crcf_step(ptr noundef) #2

declare i32 @firpfb_crcf_push(ptr noundef, <2 x float> noundef) #2

declare i32 @firpfb_crcf_execute(ptr noundef, i32 noundef, ptr noundef) #2

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

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 = { "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 56}
!10 = !{!"qdsync_cccf_s", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !12, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !11, i64 52, !6, i64 56, !6, i64 64, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !6, i64 88, !11, i64 96}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !6, i64 64}
!14 = !{!10, !11, i64 80}
!15 = !{!10, !11, i64 76}
!16 = !{!10, !11, i64 8}
!17 = !{!11, !11, i64 0}


; 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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @qdsync_cccf_step(ptr noundef %0, <2 x float> noundef %1) local_unnamed_addr #1 {
  %3 = alloca { float, float }, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = getelementptr inbounds i8, ptr %0, i64 56
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = call i32 @nco_crcf_mix_down(ptr noundef %5, <2 x float> noundef %1, ptr noundef nonnull %3) #3
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = call i32 @nco_crcf_step(ptr noundef %7) #3
  %9 = getelementptr inbounds i8, ptr %0, i64 64
  %10 = load ptr, ptr %9, align 8, !tbaa !12
  %11 = load <2 x float>, ptr %3, align 8
  %12 = call i32 @firpfb_crcf_push(ptr noundef %10, <2 x float> noundef %11) #3
  %13 = load ptr, ptr %9, align 8, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %0, i64 80
  %15 = load i32, ptr %14, align 8, !tbaa !13
  %16 = call i32 @firpfb_crcf_execute(ptr noundef %13, i32 noundef %15, ptr noundef nonnull %3) #3
  %17 = getelementptr inbounds i8, ptr %0, i64 76
  %18 = load i32, ptr %17, align 4, !tbaa !14
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %17, align 4, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = load i32, ptr %20, align 8, !tbaa !15
  %22 = add i32 %21, -1
  %.not = icmp ult i32 %19, %22
  br i1 %.not, label %27, label %23

23:                                               ; preds = %2
  %24 = sub i32 %19, %21
  store i32 %24, ptr %17, align 4, !tbaa !14
  %25 = load <2 x float>, ptr %3, align 8
  %26 = call i32 @qdsync_cccf_buf_append(ptr noundef nonnull %0, <2 x float> noundef %25)
  br label %27

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

declare i32 @nco_crcf_mix_down(ptr noundef, <2 x float> noundef, ptr noundef) local_unnamed_addr #2

declare i32 @nco_crcf_step(ptr noundef) local_unnamed_addr #2

declare i32 @firpfb_crcf_push(ptr noundef, <2 x float> noundef) local_unnamed_addr #2

declare i32 @firpfb_crcf_execute(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress 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 = { "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, !11, i64 56}
!6 = !{!"qdsync_cccf_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !7, i64 48, !7, i64 52, !11, i64 56, !11, i64 64, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !11, i64 88, !7, i64 96}
!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 = !{!6, !11, i64 64}
!13 = !{!6, !7, i64 80}
!14 = !{!6, !7, i64 76}
!15 = !{!6, !7, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass