; LLVM IR from jgaeddert/liquid-dsp :: src/framing/src (gmskframesync)

; 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.gmskframesync_s = type { ptr, i32, i32, float, ptr, ptr, %struct.framesyncstats_s, %struct.framedatastats_s, { float, float }, float, ptr, ptr, i32, float, float, i32, i32, float, ptr, float, float, float, ptr, ptr, i32, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, ptr, i32, i8, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32 }
%struct.framesyncstats_s = type { float, float, float, ptr, i32, i32, i32, i32, i32, i32 }
%struct.framedatastats_s = type { i32, i32, i32, i64 }

; Function Attrs: nounwind uwtable
define dso_local i32 @gmskframesync_update_fi(ptr noundef %0, <2 x float> noundef %1) #0 {
  %3 = alloca { float, float }, align 4
  %4 = alloca ptr, align 8
  %5 = alloca { float, float }, align 4
  %6 = alloca { float, float }, align 4
  store <2 x float> %1, ptr %3, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.gmskframesync_s, ptr %7, i32 0, i32 8
  %9 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %10 = load float, ptr %9, align 8
  %11 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  %12 = load float, ptr %11, align 4
  %13 = fneg float %12
  %14 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 0
  %15 = load float, ptr %14, align 4
  %16 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 1
  %17 = load float, ptr %16, align 4
  %18 = fmul float %10, %15
  %19 = fmul float %13, %17
  %20 = fmul float %10, %17
  %21 = fmul float %13, %15
  %22 = fsub float %18, %19
  %23 = fadd float %20, %21
  %24 = fcmp uno float %22, %22
  br i1 %24, label %25, label %33, !prof !9

25:                                               ; preds = %2
  %26 = fcmp uno float %23, %23
  br i1 %26, label %27, label %33, !prof !9

27:                                               ; preds = %25
  %28 = call <2 x float> @__mulsc3(float noundef %10, float noundef %13, float noundef %15, float noundef %17) #2
  store <2 x float> %28, ptr %5, align 4
  %29 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %30 = load float, ptr %29, align 4
  %31 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %32 = load float, ptr %31, align 4
  br label %33

33:                                               ; preds = %27, %25, %2
  %34 = phi float [ %22, %2 ], [ %22, %25 ], [ %30, %27 ]
  %35 = phi float [ %23, %2 ], [ %23, %25 ], [ %32, %27 ]
  %36 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %37 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  store float %34, ptr %36, align 4
  store float %35, ptr %37, align 4
  %38 = load <2 x float>, ptr %6, align 4
  %39 = call float @cargf(<2 x float> noundef %38) #2
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.gmskframesync_s, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 8, !tbaa !10
  %43 = uitofp i32 %42 to float
  %44 = fmul float %39, %43
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.gmskframesync_s, ptr %45, i32 0, i32 9
  store float %44, ptr %46, align 8, !tbaa !17
  %47 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 0
  %48 = load float, ptr %47, align 4
  %49 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 1
  %50 = load float, ptr %49, align 4
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.gmskframesync_s, ptr %51, i32 0, i32 8
  %53 = getelementptr inbounds { float, float }, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds { float, float }, ptr %52, i32 0, i32 1
  store float %48, ptr %53, align 8
  store float %50, ptr %54, align 4
  ret i32 0
}

; Function Attrs: nounwind
declare float @cargf(<2 x float> noundef) #1

declare <2 x float> @__mulsc3(float, float, float, float)

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 "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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"branch_weights", i32 1, i32 1048575}
!10 = !{!11, !12, i64 8}
!11 = !{!"gmskframesync_s", !6, i64 0, !12, i64 8, !12, i64 12, !13, i64 16, !6, i64 24, !6, i64 32, !14, i64 40, !15, i64 88, !7, i64 112, !13, i64 120, !6, i64 128, !6, i64 136, !12, i64 144, !13, i64 148, !13, i64 152, !12, i64 156, !12, i64 160, !13, i64 164, !6, i64 168, !13, i64 176, !13, i64 180, !13, i64 184, !6, i64 192, !6, i64 200, !12, i64 208, !6, i64 216, !6, i64 224, !12, i64 232, !12, i64 236, !12, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !12, i64 280, !7, i64 284, !12, i64 288, !12, i64 292, !12, i64 296, !12, i64 300, !12, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !12, i64 336, !12, i64 340, !12, i64 344, !12, i64 348, !12, i64 352}
!12 = !{!"int", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44}
!15 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !16, i64 16}
!16 = !{!"long", !7, i64 0}
!17 = !{!11, !13, i64 120}


; 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 @gmskframesync_update_fi(ptr nocapture noundef %0, <2 x float> noundef %1) local_unnamed_addr #0 {
  %3 = extractelement <2 x float> %1, i64 1
  %4 = extractelement <2 x float> %1, i64 0
  %5 = getelementptr inbounds i8, ptr %0, i64 112
  %6 = load <2 x float>, ptr %5, align 8
  %7 = extractelement <2 x float> %6, i64 1
  %8 = fneg float %7
  %9 = extractelement <2 x float> %6, i64 0
  %10 = fmul float %3, %9
  %11 = fmul <2 x float> %6, %1
  %shift = shufflevector <2 x float> %11, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %12 = fadd <2 x float> %11, %shift
  %13 = extractelement <2 x float> %12, i64 0
  %14 = fmul float %4, %7
  %15 = fsub float %10, %14
  %16 = fcmp uno float %13, 0.000000e+00
  %17 = insertelement <2 x float> %12, float %15, i64 1
  br i1 %16, label %18, label %22, !prof !5

18:                                               ; preds = %2
  %19 = fcmp uno float %15, 0.000000e+00
  br i1 %19, label %20, label %22, !prof !5

20:                                               ; preds = %18
  %21 = tail call <2 x float> @__mulsc3(float noundef %9, float noundef %8, float noundef %4, float noundef %3) #2
  br label %22

22:                                               ; preds = %20, %18, %2
  %23 = phi <2 x float> [ %17, %2 ], [ %17, %18 ], [ %21, %20 ]
  %24 = tail call float @cargf(<2 x float> noundef %23) #2
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  %26 = load i32, ptr %25, align 8, !tbaa !6
  %27 = uitofp i32 %26 to float
  %28 = fmul float %24, %27
  %29 = getelementptr inbounds i8, ptr %0, i64 120
  store float %28, ptr %29, align 8, !tbaa !16
  store <2 x float> %1, ptr %5, align 8
  ret i32 0
}

; Function Attrs: nounwind
declare float @cargf(<2 x float> noundef) local_unnamed_addr #1

declare <2 x float> @__mulsc3(float, float, float, float) local_unnamed_addr

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 "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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = !{!7, !11, i64 8}
!7 = !{!"gmskframesync_s", !8, i64 0, !11, i64 8, !11, i64 12, !12, i64 16, !8, i64 24, !8, i64 32, !13, i64 40, !14, i64 88, !9, i64 112, !12, i64 120, !8, i64 128, !8, i64 136, !11, i64 144, !12, i64 148, !12, i64 152, !11, i64 156, !11, i64 160, !12, i64 164, !8, i64 168, !12, i64 176, !12, i64 180, !12, i64 184, !8, i64 192, !8, i64 200, !11, i64 208, !8, i64 216, !8, i64 224, !11, i64 232, !11, i64 236, !11, i64 240, !8, i64 248, !8, i64 256, !8, i64 264, !8, i64 272, !11, i64 280, !9, i64 284, !11, i64 288, !11, i64 292, !11, i64 296, !11, i64 300, !11, i64 304, !8, i64 312, !8, i64 320, !8, i64 328, !11, i64 336, !11, i64 340, !11, i64 344, !11, i64 348, !11, i64 352}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"float", !9, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !8, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44}
!14 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !15, i64 16}
!15 = !{!"long", !9, i64 0}
!16 = !{!7, !12, i64 120}


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