; LLVM IR from QUILL-PIC/Quill :: src/mc.ll (ZN14spatial_region13bear_particleEdR8vector3dS1_ddd)

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

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

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

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN14spatial_region13bear_particleEdR8vector3dS1_ddd(ptr noundef nonnull align 8 dereferenceable(608) %0, double noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %3, double noundef %4, double noundef %5, double noundef %6) #3 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca ptr, align 8
  %16 = alloca double, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store double %1, ptr %9, align 8, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store double %4, ptr %12, align 8, !tbaa !9
  store double %5, ptr %13, align 8, !tbaa !9
  store double %6, ptr %14, align 8, !tbaa !9
  %17 = load ptr, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %18 = call noundef ptr @_ZN14spatial_region12new_particleEv(ptr noundef nonnull align 8 dereferenceable(608) %17)
  store ptr %18, ptr %15, align 8, !tbaa !5
  %19 = load double, ptr %9, align 8, !tbaa !9
  %20 = load ptr, ptr %15, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.particle, ptr %20, i32 0, i32 8
  store double %19, ptr %21, align 8, !tbaa !11
  %22 = load double, ptr %14, align 8, !tbaa !9
  %23 = load ptr, ptr %15, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.particle, ptr %23, i32 0, i32 7
  store double %22, ptr %24, align 8, !tbaa !14
  %25 = load double, ptr %12, align 8, !tbaa !9
  %26 = load ptr, ptr %15, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.particle, ptr %26, i32 0, i32 6
  store double %25, ptr %27, align 8, !tbaa !15
  %28 = load double, ptr %13, align 8, !tbaa !9
  %29 = load ptr, ptr %15, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.particle, ptr %29, i32 0, i32 9
  store double %28, ptr %30, align 8, !tbaa !16
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.vector3d, ptr %31, i32 0, i32 0
  %33 = load double, ptr %32, align 8, !tbaa !17
  %34 = load ptr, ptr %15, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.particle, ptr %34, i32 0, i32 0
  store double %33, ptr %35, align 8, !tbaa !19
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.vector3d, ptr %36, i32 0, i32 1
  %38 = load double, ptr %37, align 8, !tbaa !20
  %39 = load ptr, ptr %15, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.particle, ptr %39, i32 0, i32 1
  store double %38, ptr %40, align 8, !tbaa !21
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.vector3d, ptr %41, i32 0, i32 2
  %43 = load double, ptr %42, align 8, !tbaa !22
  %44 = load ptr, ptr %15, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.particle, ptr %44, i32 0, i32 2
  store double %43, ptr %45, align 8, !tbaa !23
  %46 = load double, ptr %9, align 8, !tbaa !9
  %47 = fcmp oeq double %46, 0.000000e+00
  br i1 %47, label %48, label %73

48:                                               ; preds = %7
  %49 = load double, ptr %12, align 8, !tbaa !9
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.vector3d, ptr %50, i32 0, i32 0
  %52 = load double, ptr %51, align 8, !tbaa !17
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.vector3d, ptr %53, i32 0, i32 0
  %55 = load double, ptr %54, align 8, !tbaa !17
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.vector3d, ptr %56, i32 0, i32 1
  %58 = load double, ptr %57, align 8, !tbaa !20
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.vector3d, ptr %59, i32 0, i32 1
  %61 = load double, ptr %60, align 8, !tbaa !20
  %62 = fmul double %58, %61
  %63 = call double @llvm.fmuladd.f64(double %52, double %55, double %62)
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.vector3d, ptr %64, i32 0, i32 2
  %66 = load double, ptr %65, align 8, !tbaa !22
  %67 = load ptr, ptr %11, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.vector3d, ptr %67, i32 0, i32 2
  %69 = load double, ptr %68, align 8, !tbaa !22
  %70 = call double @llvm.fmuladd.f64(double %66, double %69, double %63)
  %71 = call double @sqrt(double noundef %70) #5
  %72 = fdiv double %49, %71
  store double %72, ptr %16, align 8, !tbaa !9
  br label %100

73:                                               ; preds = %7
  %74 = load double, ptr %12, align 8, !tbaa !9
  %75 = load double, ptr %12, align 8, !tbaa !9
  %76 = call double @llvm.fmuladd.f64(double %74, double %75, double -1.000000e+00)
  %77 = load ptr, ptr %11, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.vector3d, ptr %77, i32 0, i32 0
  %79 = load double, ptr %78, align 8, !tbaa !17
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.vector3d, ptr %80, i32 0, i32 0
  %82 = load double, ptr %81, align 8, !tbaa !17
  %83 = load ptr, ptr %11, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.vector3d, ptr %83, i32 0, i32 1
  %85 = load double, ptr %84, align 8, !tbaa !20
  %86 = load ptr, ptr %11, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.vector3d, ptr %86, i32 0, i32 1
  %88 = load double, ptr %87, align 8, !tbaa !20
  %89 = fmul double %85, %88
  %90 = call double @llvm.fmuladd.f64(double %79, double %82, double %89)
  %91 = load ptr, ptr %11, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.vector3d, ptr %91, i32 0, i32 2
  %93 = load double, ptr %92, align 8, !tbaa !22
  %94 = load ptr, ptr %11, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.vector3d, ptr %94, i32 0, i32 2
  %96 = load double, ptr %95, align 8, !tbaa !22
  %97 = call double @llvm.fmuladd.f64(double %93, double %96, double %90)
  %98 = fdiv double %76, %97
  %99 = call double @sqrt(double noundef %98) #5
  store double %99, ptr %16, align 8, !tbaa !9
  br label %100

100:                                              ; preds = %73, %48
  %101 = load double, ptr %16, align 8, !tbaa !9
  %102 = load ptr, ptr %11, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.vector3d, ptr %102, i32 0, i32 0
  %104 = load double, ptr %103, align 8, !tbaa !17
  %105 = fmul double %101, %104
  %106 = load ptr, ptr %15, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.particle, ptr %106, i32 0, i32 3
  store double %105, ptr %107, align 8, !tbaa !24
  %108 = load double, ptr %16, align 8, !tbaa !9
  %109 = load ptr, ptr %11, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.vector3d, ptr %109, i32 0, i32 1
  %111 = load double, ptr %110, align 8, !tbaa !20
  %112 = fmul double %108, %111
  %113 = load ptr, ptr %15, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.particle, ptr %113, i32 0, i32 4
  store double %112, ptr %114, align 8, !tbaa !25
  %115 = load double, ptr %16, align 8, !tbaa !9
  %116 = load ptr, ptr %11, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.vector3d, ptr %116, i32 0, i32 2
  %118 = load double, ptr %117, align 8, !tbaa !22
  %119 = fmul double %115, %118
  %120 = load ptr, ptr %15, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.particle, ptr %120, i32 0, i32 5
  store double %119, ptr %121, align 8, !tbaa !26
  %122 = load ptr, ptr %15, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.particle, ptr %122, i32 0, i32 10
  store i32 0, ptr %123, align 8, !tbaa !27
  %124 = load ptr, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  ret ptr %124
}

declare noundef ptr @_ZN14spatial_region12new_particleEv(ptr noundef nonnull align 8 dereferenceable(608)) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nounwind "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 #3 = { 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 #4 = { "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 #5 = { 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 64}
!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 56}
!15 = !{!12, !10, i64 48}
!16 = !{!12, !10, i64 72}
!17 = !{!18, !10, i64 0}
!18 = !{!"_ZTS8vector3d", !10, i64 0, !10, i64 8, !10, i64 16}
!19 = !{!12, !10, i64 0}
!20 = !{!18, !10, i64 8}
!21 = !{!12, !10, i64 8}
!22 = !{!18, !10, i64 16}
!23 = !{!12, !10, i64 16}
!24 = !{!12, !10, i64 24}
!25 = !{!12, !10, i64 32}
!26 = !{!12, !10, i64 40}
!27 = !{!12, !13, i64 80}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN14spatial_region13bear_particleEdR8vector3dS1_ddd(ptr noundef nonnull align 8 dereferenceable(608) %0, double noundef %1, ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %2, ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %3, double noundef %4, double noundef %5, double noundef %6) local_unnamed_addr #2 align 2 {
  %8 = tail call noundef ptr @_ZN14spatial_region12new_particleEv(ptr noundef nonnull align 8 dereferenceable(608) %0)
  %9 = getelementptr inbounds i8, ptr %8, i64 64
  store double %1, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %8, i64 56
  store double %6, ptr %10, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %8, i64 48
  store double %4, ptr %11, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %8, i64 72
  store double %5, ptr %12, align 8, !tbaa !14
  %13 = load <2 x double>, ptr %2, align 8, !tbaa !15
  store <2 x double> %13, ptr %8, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %2, i64 16
  %15 = load double, ptr %14, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %8, i64 16
  store double %15, ptr %16, align 8, !tbaa !18
  %17 = fcmp oeq double %1, 0.000000e+00
  br i1 %17, label %18, label %28

18:                                               ; preds = %7
  %19 = load <2 x double>, ptr %3, align 8, !tbaa !15
  %20 = fmul <2 x double> %19, %19
  %21 = extractelement <2 x double> %20, i64 1
  %22 = extractelement <2 x double> %19, i64 0
  %23 = tail call double @llvm.fmuladd.f64(double %22, double %22, double %21)
  %24 = getelementptr inbounds i8, ptr %3, i64 16
  %25 = load double, ptr %24, align 8, !tbaa !16
  %26 = tail call double @llvm.fmuladd.f64(double %25, double %25, double %23)
  %sqrt = tail call double @llvm.sqrt.f64(double %26)
  %27 = fdiv double %4, %sqrt
  br label %45

28:                                               ; preds = %7
  %29 = load double, ptr %3, align 8, !tbaa !19
  %30 = getelementptr inbounds i8, ptr %3, i64 8
  %31 = load double, ptr %30, align 8, !tbaa !20
  %32 = fmul double %31, %31
  %33 = tail call double @llvm.fmuladd.f64(double %29, double %29, double %32)
  %34 = getelementptr inbounds i8, ptr %3, i64 16
  %35 = load double, ptr %34, align 8, !tbaa !16
  %36 = insertelement <2 x double> poison, double %4, i64 0
  %37 = insertelement <2 x double> %36, double %35, i64 1
  %38 = insertelement <2 x double> <double -1.000000e+00, double poison>, double %33, i64 1
  %39 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %37, <2 x double> %37, <2 x double> %38)
  %40 = extractelement <2 x double> %39, i64 0
  %41 = extractelement <2 x double> %39, i64 1
  %42 = fdiv double %40, %41
  %43 = tail call double @sqrt(double noundef %42) #5
  %44 = load <2 x double>, ptr %3, align 8, !tbaa !15
  %.pre44 = load double, ptr %34, align 8, !tbaa !16
  br label %45

45:                                               ; preds = %28, %18
  %46 = phi double [ %25, %18 ], [ %.pre44, %28 ]
  %.0 = phi double [ %27, %18 ], [ %43, %28 ]
  %47 = phi <2 x double> [ %19, %18 ], [ %44, %28 ]
  %48 = insertelement <2 x double> poison, double %.0, i64 0
  %49 = shufflevector <2 x double> %48, <2 x double> poison, <2 x i32> zeroinitializer
  %50 = fmul <2 x double> %49, %47
  %51 = getelementptr inbounds i8, ptr %8, i64 24
  store <2 x double> %50, ptr %51, align 8, !tbaa !15
  %52 = fmul double %.0, %46
  %53 = getelementptr inbounds i8, ptr %8, i64 40
  store double %52, ptr %53, align 8, !tbaa !21
  %54 = getelementptr inbounds i8, ptr %8, i64 80
  store i32 0, ptr %54, align 8, !tbaa !22
  ret ptr %8
}

declare noundef ptr @_ZN14spatial_region12new_particleEv(ptr noundef nonnull align 8 dereferenceable(608)) local_unnamed_addr #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "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 = { 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 #3 = { "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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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, !7, i64 64}
!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 = !{!6, !7, i64 56}
!13 = !{!6, !7, i64 48}
!14 = !{!6, !7, i64 72}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !7, i64 16}
!17 = !{!"_ZTS8vector3d", !7, i64 0, !7, i64 8, !7, i64 16}
!18 = !{!6, !7, i64 16}
!19 = !{!17, !7, i64 0}
!20 = !{!17, !7, i64 8}
!21 = !{!6, !7, i64 40}
!22 = !{!6, !10, i64 80}


; Effective O3 passes: AggressiveInstCombinePass,BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass