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

; 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.ScalarField = type { i32, i32, i32, double, double, double, double, double, double, double, double, i8, [7 x i8], %class.Array3d, %class.Array3d.0, %class.Array3d, %class.Array3d.0, i8, %"class.vmath::vec3" }
%class.Array3d = type <{ i32, i32, i32, [4 x i8], ptr, i8, [3 x i8], float, i32, [4 x i8] }>
%class.Array3d.0 = type { i32, i32, i32, ptr, i8, i8, i32 }
%"class.vmath::vec3" = type { float, float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN11ScalarField46_evaluateTricubicFieldFunctionForRadiusSquaredEd(ptr noundef nonnull align 8 dereferenceable(248) %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.ScalarField, ptr %5, i32 0, i32 6
  %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 = fneg double %11
  %14 = call double @llvm.fmuladd.f64(double %13, double %12, double 1.000000e+00)
  %15 = getelementptr inbounds %class.ScalarField, ptr %5, i32 0, i32 7
  %16 = load double, ptr %15, align 8, !tbaa !19
  %17 = load double, ptr %4, align 8, !tbaa !9
  %18 = fmul double %16, %17
  %19 = load double, ptr %4, align 8, !tbaa !9
  %20 = call double @llvm.fmuladd.f64(double %18, double %19, double %14)
  %21 = getelementptr inbounds %class.ScalarField, ptr %5, i32 0, i32 8
  %22 = load double, ptr %21, align 8, !tbaa !20
  %23 = load double, ptr %4, align 8, !tbaa !9
  %24 = fneg double %22
  %25 = call double @llvm.fmuladd.f64(double %24, double %23, double %20)
  ret double %25
}

; 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 40}
!12 = !{!"_ZTS11ScalarField", !13, i64 0, !13, i64 4, !13, 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, !14, i64 80, !15, i64 88, !17, i64 128, !15, i64 160, !17, i64 200, !14, i64 232, !18, i64 236}
!13 = !{!"int", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTS7Array3dIfE", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !14, i64 24, !16, i64 28, !13, i64 32}
!16 = !{!"float", !7, i64 0}
!17 = !{!"_ZTS7Array3dIbE", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !14, i64 24, !14, i64 25, !13, i64 28}
!18 = !{!"_ZTSN5vmath4vec3E", !16, i64 0, !16, i64 4, !16, i64 8}
!19 = !{!12, !10, i64 48}
!20 = !{!12, !10, i64 56}


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

; 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, !10, i64 40}
!6 = !{!"_ZTS11ScalarField", !7, i64 0, !7, i64 4, !7, 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, !11, i64 80, !12, i64 88, !15, i64 128, !12, i64 160, !15, i64 200, !11, i64 232, !16, i64 236}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"_ZTS7Array3dIfE", !7, i64 0, !7, i64 4, !7, i64 8, !13, i64 16, !11, i64 24, !14, i64 28, !7, i64 32}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = !{!"_ZTS7Array3dIbE", !7, i64 0, !7, i64 4, !7, i64 8, !13, i64 16, !11, i64 24, !11, i64 25, !7, i64 28}
!16 = !{!"_ZTSN5vmath4vec3E", !14, i64 0, !14, i64 4, !14, i64 8}
!17 = !{!6, !10, i64 48}
!18 = !{!6, !10, i64 56}


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