; LLVM IR from BigdogManLuo/DSPLibrary :: Example/Inversion_3Phase_1.5/empty_sysconfig_337zwt (pid)

; 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.PID = type { double, double, double, double, double, double, double, double, double, double }

; Function Attrs: nounwind uwtable
define dso_local double @PIDCalc(ptr noundef %0, double noundef %1, double noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %9 = load double, ptr %6, align 8, !tbaa !9
  %10 = load double, ptr %5, align 8, !tbaa !9
  %11 = fsub double %9, %10
  store double %11, ptr %8, align 8, !tbaa !9
  %12 = load double, ptr %8, align 8, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.PID, ptr %13, i32 0, i32 5
  %15 = load double, ptr %14, align 8, !tbaa !11
  %16 = fadd double %15, %12
  store double %16, ptr %14, align 8, !tbaa !11
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.PID, ptr %17, i32 0, i32 4
  %19 = load double, ptr %18, align 8, !tbaa !13
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.PID, ptr %20, i32 0, i32 6
  %22 = load double, ptr %21, align 8, !tbaa !14
  %23 = fsub double %19, %22
  store double %23, ptr %7, align 8, !tbaa !9
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.PID, ptr %24, i32 0, i32 4
  %26 = load double, ptr %25, align 8, !tbaa !13
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.PID, ptr %27, i32 0, i32 6
  store double %26, ptr %28, align 8, !tbaa !14
  %29 = load double, ptr %8, align 8, !tbaa !9
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.PID, ptr %30, i32 0, i32 4
  store double %29, ptr %31, align 8, !tbaa !13
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.PID, ptr %32, i32 0, i32 3
  %34 = load double, ptr %33, align 8, !tbaa !15
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.PID, ptr %35, i32 0, i32 0
  %37 = load double, ptr %36, align 8, !tbaa !16
  %38 = load double, ptr %8, align 8, !tbaa !9
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.PID, ptr %39, i32 0, i32 1
  %41 = load double, ptr %40, align 8, !tbaa !17
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.PID, ptr %42, i32 0, i32 5
  %44 = load double, ptr %43, align 8, !tbaa !11
  %45 = fmul double %41, %44
  %46 = call double @llvm.fmuladd.f64(double %37, double %38, double %45)
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.PID, ptr %47, i32 0, i32 2
  %49 = load double, ptr %48, align 8, !tbaa !18
  %50 = load double, ptr %7, align 8, !tbaa !9
  %51 = call double @llvm.fmuladd.f64(double %49, double %50, double %46)
  %52 = fmul double %34, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret double %52
}

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

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

; 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 40}
!12 = !{!"PID", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72}
!13 = !{!12, !10, i64 32}
!14 = !{!12, !10, i64 48}
!15 = !{!12, !10, i64 24}
!16 = !{!12, !10, i64 0}
!17 = !{!12, !10, i64 8}
!18 = !{!12, !10, i64 16}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local double @PIDCalc(ptr nocapture noundef %0, double noundef %1, double noundef %2) local_unnamed_addr #0 {
  %4 = fsub double %2, %1
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = fadd double %4, %6
  store double %7, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load double, ptr %8, align 8, !tbaa !10
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  %11 = load double, ptr %10, align 8, !tbaa !11
  %12 = fsub double %9, %11
  store double %9, ptr %10, align 8, !tbaa !11
  store double %4, ptr %8, align 8, !tbaa !10
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = load double, ptr %13, align 8, !tbaa !12
  %15 = load double, ptr %0, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = load double, ptr %16, align 8, !tbaa !14
  %18 = fmul double %7, %17
  %19 = tail call double @llvm.fmuladd.f64(double %15, double %4, double %18)
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  %21 = load double, ptr %20, align 8, !tbaa !15
  %22 = tail call double @llvm.fmuladd.f64(double %21, double %12, double %19)
  %23 = fmul double %14, %22
  ret double %23
}

; 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: readwrite) 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 40}
!6 = !{!"PID", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 32}
!11 = !{!6, !7, i64 48}
!12 = !{!6, !7, i64 24}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !7, i64 16}


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