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

; 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 void @_ZN11ScalarField14setPointRadiusEd(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 = load double, ptr %4, align 8, !tbaa !9
  %7 = getelementptr inbounds %class.ScalarField, ptr %5, i32 0, i32 4
  store double %6, ptr %7, align 8, !tbaa !11
  %8 = load double, ptr %4, align 8, !tbaa !9
  %9 = fdiv double 1.000000e+00, %8
  %10 = getelementptr inbounds %class.ScalarField, ptr %5, i32 0, i32 5
  store double %9, ptr %10, align 8, !tbaa !19
  %11 = load double, ptr %4, align 8, !tbaa !9
  %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 = fmul double %17, %18
  %20 = load double, ptr %4, align 8, !tbaa !9
  %21 = fmul double %19, %20
  %22 = fdiv double 1.000000e+00, %21
  %23 = fmul double 0x3FDC71C71C71C71C, %22
  %24 = getelementptr inbounds %class.ScalarField, ptr %5, i32 0, i32 6
  store double %23, ptr %24, align 8, !tbaa !20
  %25 = load double, ptr %4, align 8, !tbaa !9
  %26 = load double, ptr %4, align 8, !tbaa !9
  %27 = fmul double %25, %26
  %28 = load double, ptr %4, align 8, !tbaa !9
  %29 = fmul double %27, %28
  %30 = load double, ptr %4, align 8, !tbaa !9
  %31 = fmul double %29, %30
  %32 = fdiv double 1.000000e+00, %31
  %33 = fmul double 0x3FFE38E38E38E38E, %32
  %34 = getelementptr inbounds %class.ScalarField, ptr %5, i32 0, i32 7
  store double %33, ptr %34, align 8, !tbaa !21
  %35 = load double, ptr %4, align 8, !tbaa !9
  %36 = load double, ptr %4, align 8, !tbaa !9
  %37 = fmul double %35, %36
  %38 = fdiv double 1.000000e+00, %37
  %39 = fmul double 0x40038E38E38E38E4, %38
  %40 = getelementptr inbounds %class.ScalarField, ptr %5, i32 0, i32 8
  store double %39, ptr %40, align 8, !tbaa !22
  ret void
}

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

!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 = !{!"_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 32}
!20 = !{!12, !10, i64 40}
!21 = !{!12, !10, i64 48}
!22 = !{!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: write) uwtable
define dso_local void @_ZN11ScalarField14setPointRadiusEd(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(248) %0, double noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  store double %1, ptr %3, align 8, !tbaa !5
  %4 = fdiv double 1.000000e+00, %1
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  store double %4, ptr %5, align 8, !tbaa !17
  %6 = fmul double %1, %1
  %7 = fmul double %6, %1
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = fmul double %7, %1
  %10 = fmul double %9, %1
  %11 = fmul double %10, %1
  %12 = insertelement <2 x double> poison, double %11, i64 0
  %13 = insertelement <2 x double> %12, double %9, i64 1
  %14 = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %13
  %15 = fmul <2 x double> %14, <double 0x3FDC71C71C71C71C, double 0x3FFE38E38E38E38E>
  store <2 x double> %15, ptr %8, align 8, !tbaa !18
  %16 = fdiv double 1.000000e+00, %6
  %17 = fmul double %16, 0x40038E38E38E38E4
  %18 = getelementptr inbounds i8, ptr %0, i64 56
  store double %17, ptr %18, align 8, !tbaa !19
  ret void
}

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

!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 24}
!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 32}
!18 = !{!10, !10, i64 0}
!19 = !{!6, !10, i64 56}


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