; LLVM IR from QUILL-PIC/Quill :: src/containers.ll (ZN8particle16get_displacementEd)

; 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.vector3d = type { double, double, double }
%struct.particle = type { double, double, double, double, double, double, double, double, double, double, i32, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8particle16get_displacementEd(ptr dead_on_unwind noalias writable sret(%struct.vector3d) align 8 %0, ptr noundef nonnull align 8 dereferenceable(104) %1, double noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store double %2, ptr %5, align 8, !tbaa !9
  %7 = load ptr, ptr %4, align 8
  call void @_ZN8vector3dC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %8 = load double, ptr %5, align 8, !tbaa !9
  %9 = getelementptr inbounds %struct.particle, ptr %7, i32 0, i32 6
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = fdiv double %8, %10
  store double %11, ptr %6, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.particle, ptr %7, i32 0, i32 3
  %13 = load double, ptr %12, align 8, !tbaa !14
  %14 = load double, ptr %6, align 8, !tbaa !9
  %15 = fmul double %13, %14
  %16 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 0
  store double %15, ptr %16, align 8, !tbaa !15
  %17 = getelementptr inbounds %struct.particle, ptr %7, i32 0, i32 4
  %18 = load double, ptr %17, align 8, !tbaa !17
  %19 = load double, ptr %6, align 8, !tbaa !9
  %20 = fmul double %18, %19
  %21 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 1
  store double %20, ptr %21, align 8, !tbaa !18
  %22 = getelementptr inbounds %struct.particle, ptr %7, i32 0, i32 5
  %23 = load double, ptr %22, align 8, !tbaa !19
  %24 = load double, ptr %6, align 8, !tbaa !9
  %25 = fmul double %23, %24
  %26 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 2
  store double %25, ptr %26, align 8, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8vector3dC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

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

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

attributes #0 = { mustprogress 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 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 48}
!12 = !{!"_ZTS8particle", !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, i64 80, !6, i64 88, !6, i64 96}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !10, i64 24}
!15 = !{!16, !10, i64 0}
!16 = !{!"_ZTS8vector3d", !10, i64 0, !10, i64 8, !10, i64 16}
!17 = !{!12, !10, i64 32}
!18 = !{!16, !10, i64 8}
!19 = !{!12, !10, i64 40}
!20 = !{!16, !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"

%struct.vector3d = type { double, double, double }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8particle16get_displacementEd(ptr dead_on_unwind noalias nonnull writable sret(%struct.vector3d) align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(104) %1, double noundef %2) local_unnamed_addr #0 align 2 {
  tail call void @_ZN8vector3dC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %4 = getelementptr inbounds i8, ptr %1, i64 48
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = fdiv double %2, %5
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = load <2 x double>, ptr %7, align 8, !tbaa !12
  %9 = insertelement <2 x double> poison, double %6, i64 0
  %10 = shufflevector <2 x double> %9, <2 x double> poison, <2 x i32> zeroinitializer
  %11 = fmul <2 x double> %8, %10
  store <2 x double> %11, ptr %0, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %1, i64 40
  %13 = load double, ptr %12, align 8, !tbaa !13
  %14 = fmul double %6, %13
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  store double %14, ptr %15, align 8, !tbaa !14
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8vector3dC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

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, !7, i64 48}
!6 = !{!"_ZTS8particle", !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, !10, i64 80, !11, i64 88, !11, i64 96}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !7, i64 40}
!14 = !{!15, !7, i64 16}
!15 = !{!"_ZTS8vector3d", !7, i64 0, !7, i64 8, !7, i64 16}


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