; LLVM IR from SourangshuGhosh/Fluid-Simulation-for-Computer-Graphics :: src/implicitpointprimitive.ll (ZN22ImplicitPointPrimitive22_evaluateFieldFunctionEd)

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

%class.ImplicitPointPrimitive = type { %"class.vmath::vec3", double, double, double, double }
%"class.vmath::vec3" = type { float, float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN22ImplicitPointPrimitive22_evaluateFieldFunctionEd(ptr noundef nonnull align 8 dereferenceable(48) %0, double noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  %5 = load ptr, ptr %3, align 8
  %6 = getelementptr inbounds %class.ImplicitPointPrimitive, ptr %5, i32 0, i32 2
  %7 = load double, ptr %6, align 8, !tbaa !11
  %8 = load double, ptr %4, align 8, !tbaa !9
  %9 = fmul double %7, %8
  %10 = load double, ptr %4, align 8, !tbaa !9
  %11 = fmul double %9, %10
  %12 = load double, ptr %4, align 8, !tbaa !9
  %13 = fmul double %11, %12
  %14 = load double, ptr %4, align 8, !tbaa !9
  %15 = fmul double %13, %14
  %16 = load double, ptr %4, align 8, !tbaa !9
  %17 = fmul double %15, %16
  %18 = load double, ptr %4, align 8, !tbaa !9
  %19 = fneg double %17
  %20 = call double @llvm.fmuladd.f64(double %19, double %18, double 1.000000e+00)
  %21 = getelementptr inbounds %class.ImplicitPointPrimitive, ptr %5, i32 0, i32 3
  %22 = load double, ptr %21, align 8, !tbaa !15
  %23 = load double, ptr %4, align 8, !tbaa !9
  %24 = fmul double %22, %23
  %25 = load double, ptr %4, align 8, !tbaa !9
  %26 = fmul double %24, %25
  %27 = load double, ptr %4, align 8, !tbaa !9
  %28 = fmul double %26, %27
  %29 = load double, ptr %4, align 8, !tbaa !9
  %30 = call double @llvm.fmuladd.f64(double %28, double %29, double %20)
  %31 = getelementptr inbounds %class.ImplicitPointPrimitive, ptr %5, i32 0, i32 4
  %32 = load double, ptr %31, align 8, !tbaa !16
  %33 = load double, ptr %4, align 8, !tbaa !9
  %34 = fmul double %32, %33
  %35 = load double, ptr %4, align 8, !tbaa !9
  %36 = fneg double %34
  %37 = call double @llvm.fmuladd.f64(double %36, double %35, double %30)
  ret double %37
}

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

attributes #0 = { mustprogress 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 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"_ZTS22ImplicitPointPrimitive", !13, i64 0, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!13 = !{!"_ZTSN5vmath4vec3E", !14, i64 0, !14, i64 4, !14, i64 8}
!14 = !{!"float", !7, i64 0}
!15 = !{!12, !10, i64 32}
!16 = !{!12, !10, i64 40}


; 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: read) uwtable
define dso_local noundef double @_ZN22ImplicitPointPrimitive22_evaluateFieldFunctionEd(ptr nocapture noundef nonnull readonly align 8 dereferenceable(48) %0, double noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = fneg double %4
  %6 = fmul double %5, %1
  %7 = fmul double %6, %1
  %8 = fmul double %7, %1
  %9 = fmul double %8, %1
  %10 = fmul double %9, %1
  %11 = tail call double @llvm.fmuladd.f64(double %10, double %1, double 1.000000e+00)
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load double, ptr %12, align 8, !tbaa !12
  %14 = fmul double %13, %1
  %15 = fmul double %14, %1
  %16 = fmul double %15, %1
  %17 = tail call double @llvm.fmuladd.f64(double %16, double %1, double %11)
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  %19 = load double, ptr %18, align 8, !tbaa !13
  %20 = fneg double %19
  %21 = fmul double %20, %1
  %22 = tail call double @llvm.fmuladd.f64(double %21, double %1, double %17)
  ret double %22
}

; 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, !11, i64 24}
!6 = !{!"_ZTS22ImplicitPointPrimitive", !7, i64 0, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40}
!7 = !{!"_ZTSN5vmath4vec3E", !8, i64 0, !8, i64 4, !8, i64 8}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"double", !9, i64 0}
!12 = !{!6, !11, i64 32}
!13 = !{!6, !11, i64 40}


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