; LLVM IR from BigdogManLuo/DSPLibrary :: DSPTools/dq_32_Transformation (transform)

; 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.Phase3 = type { double, double, double }
%struct.Phase2 = type { double, double }

; 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 { double, double } @clarkTransformation(ptr noundef byval(%struct.Phase3) align 8 %0) #1 {
  %2 = alloca %struct.Phase2, align 8
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %5 = getelementptr inbounds %struct.Phase3, ptr %0, i32 0, i32 0
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.Phase3, ptr %0, i32 0, i32 1
  %8 = load double, ptr %7, align 8, !tbaa !10
  %9 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %8, double %6)
  %10 = getelementptr inbounds %struct.Phase3, ptr %0, i32 0, i32 2
  %11 = load double, ptr %10, align 8, !tbaa !11
  %12 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %11, double %9)
  %13 = fmul double 6.667000e-01, %12
  %14 = fptrunc double %13 to float
  store float %14, ptr %3, align 4, !tbaa !12
  %15 = getelementptr inbounds %struct.Phase3, ptr %0, i32 0, i32 1
  %16 = load double, ptr %15, align 8, !tbaa !10
  %17 = getelementptr inbounds %struct.Phase3, ptr %0, i32 0, i32 2
  %18 = load double, ptr %17, align 8, !tbaa !11
  %19 = fsub double %16, %18
  %20 = fmul double 5.773500e-01, %19
  %21 = fptrunc double %20 to float
  store float %21, ptr %4, align 4, !tbaa !12
  %22 = load float, ptr %3, align 4, !tbaa !12
  %23 = fpext float %22 to double
  %24 = getelementptr inbounds %struct.Phase2, ptr %2, i32 0, i32 0
  store double %23, ptr %24, align 8, !tbaa !14
  %25 = load float, ptr %4, align 4, !tbaa !12
  %26 = fpext float %25 to double
  %27 = getelementptr inbounds %struct.Phase2, ptr %2, i32 0, i32 1
  store double %26, ptr %27, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  %28 = load { double, double }, ptr %2, align 8
  ret { double, double } %28
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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, !7, i64 0}
!6 = !{!"Phase3", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"Phase2", !7, i64 0, !7, i64 8}
!16 = !{!15, !7, i64 8}


; 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"

%struct.Phase3 = type { double, double, double }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local { double, double } @clarkTransformation(ptr nocapture noundef readonly byval(%struct.Phase3) align 8 %0) local_unnamed_addr #0 {
  %2 = load double, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load double, ptr %3, align 8, !tbaa !10
  %5 = tail call double @llvm.fmuladd.f64(double %4, double -5.000000e-01, double %2)
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load double, ptr %6, align 8, !tbaa !11
  %8 = tail call double @llvm.fmuladd.f64(double %7, double -5.000000e-01, double %5)
  %9 = fsub double %4, %7
  %10 = insertelement <2 x double> poison, double %8, i64 0
  %11 = insertelement <2 x double> %10, double %9, i64 1
  %12 = fmul <2 x double> %11, <double 6.667000e-01, double 5.773500e-01>
  %13 = fptrunc <2 x double> %12 to <2 x float>
  %14 = fpext <2 x float> %13 to <2 x double>
  %15 = extractelement <2 x double> %14, i64 0
  %.fca.0.insert = insertvalue { double, double } poison, double %15, 0
  %16 = extractelement <2 x double> %14, i64 1
  %.fca.1.insert = insertvalue { double, double } %.fca.0.insert, double %16, 1
  ret { double, double } %.fca.1.insert
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"Phase3", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}


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