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

; 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.SphericalFluidSource = type { %class.FluidSource, %"class.vmath::vec3", double }
%class.FluidSource = type { ptr, %"class.vmath::vec3", %"class.vmath::vec3", i8, i8, i32 }
%"class.vmath::vec3" = type { float, float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN20SphericalFluidSource6expandEd(ptr noundef nonnull align 8 dereferenceable(64) %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.SphericalFluidSource, ptr %5, i32 0, i32 2
  %8 = load double, ptr %7, align 8, !tbaa !11
  %9 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %6, double %8)
  store double %9, ptr %7, align 8, !tbaa !11
  %10 = getelementptr inbounds %class.SphericalFluidSource, ptr %5, i32 0, i32 2
  %11 = load double, ptr %10, align 8, !tbaa !11
  %12 = fcmp olt double %11, 0.000000e+00
  br i1 %12, label %13, label %15

13:                                               ; preds = %2
  %14 = getelementptr inbounds %class.SphericalFluidSource, ptr %5, i32 0, i32 2
  store double 0.000000e+00, ptr %14, align 8, !tbaa !11
  br label %15

15:                                               ; preds = %13, %2
  ret void
}

; 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 56}
!12 = !{!"_ZTS20SphericalFluidSource", !13, i64 0, !14, i64 40, !10, i64 56}
!13 = !{!"_ZTS11FluidSource", !14, i64 8, !14, i64 20, !16, i64 32, !17, i64 33, !18, i64 36}
!14 = !{!"_ZTSN5vmath4vec3E", !15, i64 0, !15, i64 4, !15, i64 8}
!15 = !{!"float", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTS15FluidSourceType", !7, i64 0}
!18 = !{!"int", !7, i64 0}


; 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 void @_ZN20SphericalFluidSource6expandEd(ptr nocapture noundef nonnull align 8 dereferenceable(64) %0, double noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 56
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = tail call double @llvm.fmuladd.f64(double %1, double 5.000000e-01, double %4)
  %6 = fcmp olt double %5, 0.000000e+00
  %storemerge = select i1 %6, double 0.000000e+00, double %5
  store double %storemerge, ptr %3, align 8, !tbaa !5
  ret void
}

; 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, !15, i64 56}
!6 = !{!"_ZTS20SphericalFluidSource", !7, i64 0, !8, i64 40, !15, i64 56}
!7 = !{!"_ZTS11FluidSource", !8, i64 8, !8, i64 20, !12, i64 32, !13, i64 33, !14, i64 36}
!8 = !{!"_ZTSN5vmath4vec3E", !9, i64 0, !9, i64 4, !9, i64 8}
!9 = !{!"float", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"bool", !10, i64 0}
!13 = !{!"_ZTS15FluidSourceType", !10, i64 0}
!14 = !{!"int", !10, i64 0}
!15 = !{!"double", !10, i64 0}


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