; LLVM IR from jgaeddert/liquid-dsp :: src/modem/src (modemcf)

; 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.cpfskdem_s = type { i32, i32, i32, float, float, i32, i32, i32, i32, ptr, %union.anon.7, i32, i32, { float, float } }
%union.anon.7 = type { %struct.anon.9 }
%struct.anon.9 = type { ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @cpfskdem_reset(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.cpfskdem_s, ptr %3, i32 0, i32 8
  %5 = load i32, ptr %4, align 8, !tbaa !9
  switch i32 %5, label %12 [
    i32 0, label %6
    i32 1, label %13
  ]

6:                                                ; preds = %1
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.cpfskdem_s, ptr %7, i32 0, i32 10
  %9 = getelementptr inbounds %struct.anon.9, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = call i32 @firfilt_crcf_reset(ptr noundef %10)
  br label %13

12:                                               ; preds = %1
  br label %13

13:                                               ; preds = %12, %6, %1
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.cpfskdem_s, ptr %14, i32 0, i32 11
  store i32 0, ptr %15, align 8, !tbaa !14
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.cpfskdem_s, ptr %16, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !15
  %19 = sub i32 %18, 1
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.cpfskdem_s, ptr %20, i32 0, i32 12
  store i32 %19, ptr %21, align 4, !tbaa !16
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.cpfskdem_s, ptr %22, i32 0, i32 13
  %24 = getelementptr inbounds { float, float }, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds { float, float }, ptr %23, i32 0, i32 1
  store float 0.000000e+00, ptr %24, align 8
  store float 0.000000e+00, ptr %25, align 4
  ret i32 0
}

declare i32 @firfilt_crcf_reset(ptr noundef) #1

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

!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, !11, i64 32}
!10 = !{!"cpfskdem_s", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 12, !12, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !6, i64 40, !7, i64 48, !11, i64 56, !11, i64 60, !7, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!10, !11, i64 56}
!15 = !{!10, !11, i64 4}
!16 = !{!10, !11, i64 60}


; 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
define dso_local noundef i32 @cpfskdem_reset(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %cond = icmp eq i32 %3, 0
  br i1 %cond, label %4, label %8

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = tail call i32 @firfilt_crcf_reset(ptr noundef %6) #2
  br label %8

8:                                                ; preds = %1, %4
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 0, ptr %9, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !14
  %12 = add i32 %11, -1
  %13 = getelementptr inbounds i8, ptr %0, i64 60
  store i32 %12, ptr %13, align 4, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 64
  store <2 x float> zeroinitializer, ptr %14, align 8
  ret i32 0
}

declare i32 @firfilt_crcf_reset(ptr noundef) local_unnamed_addr #1

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

!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 32}
!6 = !{!"cpfskdem_s", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !10, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !11, i64 40, !8, i64 48, !7, i64 56, !7, i64 60, !8, i64 64}
!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 = !{!8, !8, i64 0}
!13 = !{!6, !7, i64 56}
!14 = !{!6, !7, i64 4}
!15 = !{!6, !7, i64 60}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass