; LLVM IR from BigdogManLuo/DSPLibrary :: DSPTools/SOGI (SOGI)

; 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.ButterQueue = type { [3 x float], i32, float, float }

; Function Attrs: nounwind uwtable
define dso_local float @SOGICalcQ(ptr noundef %0, float noundef %1, ptr noundef %2, float noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store float %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store float 0.000000e+00, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store float 0.000000e+00, ptr %10, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load float, ptr %6, align 4, !tbaa !9
  call void @InButterQueue(ptr noundef %11, float noundef %12)
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds float, ptr %13, i64 3
  %15 = load float, ptr %14, align 4, !tbaa !9
  %16 = fdiv float 1.000000e+00, %15
  store float %16, ptr %10, align 4, !tbaa !9
  %17 = load float, ptr %10, align 4, !tbaa !9
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds float, ptr %18, i64 0
  %20 = load float, ptr %19, align 4, !tbaa !9
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ButterQueue, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ButterQueue, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !11
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [3 x float], ptr %22, i64 0, i64 %26
  %28 = load float, ptr %27, align 4, !tbaa !9
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds float, ptr %29, i64 1
  %31 = load float, ptr %30, align 4, !tbaa !9
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ButterQueue, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ButterQueue, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = add nsw i32 %36, 2
  %38 = srem i32 %37, 3
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [3 x float], ptr %33, i64 0, i64 %39
  %41 = load float, ptr %40, align 4, !tbaa !9
  %42 = fmul float %31, %41
  %43 = call float @llvm.fmuladd.f32(float %20, float %28, float %42)
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds float, ptr %44, i64 2
  %46 = load float, ptr %45, align 4, !tbaa !9
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ButterQueue, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ButterQueue, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = add nsw i32 %51, 1
  %53 = srem i32 %52, 3
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [3 x float], ptr %48, i64 0, i64 %54
  %56 = load float, ptr %55, align 4, !tbaa !9
  %57 = call float @llvm.fmuladd.f32(float %46, float %56, float %43)
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds float, ptr %58, i64 4
  %60 = load float, ptr %59, align 4, !tbaa !9
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ButterQueue, ptr %61, i32 0, i32 2
  %63 = load float, ptr %62, align 4, !tbaa !14
  %64 = fneg float %60
  %65 = call float @llvm.fmuladd.f32(float %64, float %63, float %57)
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds float, ptr %66, i64 5
  %68 = load float, ptr %67, align 4, !tbaa !9
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ButterQueue, ptr %69, i32 0, i32 3
  %71 = load float, ptr %70, align 4, !tbaa !15
  %72 = fneg float %68
  %73 = call float @llvm.fmuladd.f32(float %72, float %71, float %65)
  %74 = fmul float %17, %73
  store float %74, ptr %9, align 4, !tbaa !9
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.ButterQueue, ptr %75, i32 0, i32 2
  %77 = load float, ptr %76, align 4, !tbaa !14
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.ButterQueue, ptr %78, i32 0, i32 3
  store float %77, ptr %79, align 4, !tbaa !15
  %80 = load float, ptr %9, align 4, !tbaa !9
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.ButterQueue, ptr %81, i32 0, i32 2
  store float %80, ptr %82, align 4, !tbaa !14
  %83 = load float, ptr %8, align 4, !tbaa !9
  %84 = load float, ptr %9, align 4, !tbaa !9
  %85 = fmul float %83, %84
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret float %85
}

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

declare void @InButterQueue(ptr noundef, float noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 12}
!12 = !{!"", !7, i64 0, !13, i64 12, !10, i64 16, !10, i64 20}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 20}


; 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 float @SOGICalcQ(ptr noundef %0, float noundef %1, ptr nocapture noundef readonly %2, float noundef %3) local_unnamed_addr #0 {
  tail call void @InButterQueue(ptr noundef %0, float noundef %1) #3
  %5 = getelementptr inbounds i8, ptr %2, i64 12
  %6 = load float, ptr %5, align 4, !tbaa !5
  %7 = fdiv float 1.000000e+00, %6
  %8 = load float, ptr %2, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [3 x float], ptr %0, i64 0, i64 %11
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %2, i64 4
  %15 = load float, ptr %14, align 4, !tbaa !5
  %16 = add nsw i32 %10, 2
  %17 = srem i32 %16, 3
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [3 x float], ptr %0, i64 0, i64 %18
  %20 = load float, ptr %19, align 4, !tbaa !5
  %21 = fmul float %15, %20
  %22 = tail call float @llvm.fmuladd.f32(float %8, float %13, float %21)
  %23 = getelementptr inbounds i8, ptr %2, i64 8
  %24 = load float, ptr %23, align 4, !tbaa !5
  %25 = add nsw i32 %10, 1
  %26 = srem i32 %25, 3
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [3 x float], ptr %0, i64 0, i64 %27
  %29 = load float, ptr %28, align 4, !tbaa !5
  %30 = tail call float @llvm.fmuladd.f32(float %24, float %29, float %22)
  %31 = getelementptr inbounds i8, ptr %2, i64 16
  %32 = load float, ptr %31, align 4, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  %34 = load float, ptr %33, align 4, !tbaa !12
  %35 = fneg float %32
  %36 = tail call float @llvm.fmuladd.f32(float %35, float %34, float %30)
  %37 = getelementptr inbounds i8, ptr %2, i64 20
  %38 = load float, ptr %37, align 4, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %0, i64 20
  %40 = load float, ptr %39, align 4, !tbaa !13
  %41 = fneg float %38
  %42 = tail call float @llvm.fmuladd.f32(float %41, float %40, float %36)
  %43 = fmul float %7, %42
  store float %34, ptr %39, align 4, !tbaa !13
  store float %43, ptr %33, align 4, !tbaa !12
  %44 = fmul float %43, %3
  ret float %44
}

declare void @InButterQueue(ptr noundef, float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 12}
!10 = !{!"", !7, i64 0, !11, i64 12, !6, i64 16, !6, i64 20}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 16}
!13 = !{!10, !6, i64 20}


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