; LLVM IR from RiteshKH/Particle-Swarm-Optimiztion-based-Global-Path-planning :: PSO.ll (Z11newparticle5CoordS_dddi)

; 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.Coord = type { double, double, double, double }

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z15generate_randomiddi(i32 noundef, double noundef, double noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z8shortfit5CoordS_(ptr noundef byval(%struct.Coord) align 8, ptr noundef byval(%struct.Coord) align 8) #0

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z11obsdistance5CoordS_ddd(ptr noundef byval(%struct.Coord) align 8, ptr noundef byval(%struct.Coord) align 8, double noundef, double noundef, double noundef) #5

; Function Attrs: mustprogress uwtable
define dso_local void @_Z11newparticle5CoordS_dddi(ptr dead_on_unwind noalias writable sret(%struct.Coord) align 8 %0, ptr noundef byval(%struct.Coord) align 8 %1, ptr noundef byval(%struct.Coord) align 8 %2, double noundef %3, double noundef %4, double noundef %5, i32 noundef %6) #0 {
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  %13 = alloca %struct.Coord, align 8
  %14 = alloca %struct.Coord, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca %struct.Coord, align 8
  %19 = alloca %struct.Coord, align 8
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = alloca double, align 8
  %23 = alloca double, align 8
  %24 = alloca double, align 8
  %25 = alloca double, align 8
  %26 = alloca %struct.Coord, align 8
  %27 = alloca %struct.Coord, align 8
  %28 = alloca %struct.Coord, align 8
  %29 = alloca %struct.Coord, align 8
  store double %3, ptr %8, align 8, !tbaa !5
  store double %4, ptr %9, align 8, !tbaa !5
  store double %5, ptr %10, align 8, !tbaa !5
  store i32 %6, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %30 = load double, ptr %10, align 8, !tbaa !5
  %31 = fmul double %30, 3.000000e-01
  store double %31, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %32 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 1
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = getelementptr inbounds %struct.Coord, ptr %2, i32 0, i32 1
  %35 = load double, ptr %34, align 8, !tbaa !11
  %36 = fsub double %33, %35
  %37 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 0
  %38 = load double, ptr %37, align 8, !tbaa !13
  %39 = getelementptr inbounds %struct.Coord, ptr %2, i32 0, i32 0
  %40 = load double, ptr %39, align 8, !tbaa !13
  %41 = fsub double %38, %40
  %42 = fdiv double %36, %41
  store double %42, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %43 = load double, ptr %15, align 8, !tbaa !5
  %44 = fdiv double 1.000000e+00, %43
  %45 = fmul double -1.000000e+00, %44
  store double %45, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %18, ptr align 8 %1, i64 32, i1 false), !tbaa.struct !14
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %19, ptr align 8 %2, i64 32, i1 false), !tbaa.struct !14
  %46 = load double, ptr %8, align 8, !tbaa !5
  %47 = load double, ptr %9, align 8, !tbaa !5
  %48 = load double, ptr %10, align 8, !tbaa !5
  %49 = call noundef double @_Z11obsdistance5CoordS_ddd(ptr noundef byval(%struct.Coord) align 8 %18, ptr noundef byval(%struct.Coord) align 8 %19, double noundef %46, double noundef %47, double noundef %48)
  store double %49, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %50 = load i32, ptr %11, align 4, !tbaa !9
  %51 = call noundef ptr @_Z15generate_randomiddi(i32 noundef 1, double noundef 0.000000e+00, double noundef 1.000000e+00, i32 noundef %50)
  %52 = getelementptr inbounds double, ptr %51, i64 0
  %53 = load double, ptr %52, align 8, !tbaa !5
  store double %53, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  %54 = load double, ptr %10, align 8, !tbaa !5
  %55 = load double, ptr %20, align 8, !tbaa !5
  %56 = load double, ptr %12, align 8, !tbaa !5
  %57 = call double @llvm.fmuladd.f64(double %55, double %56, double %54)
  store double %57, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  %58 = load double, ptr %21, align 8, !tbaa !5
  %59 = load double, ptr %16, align 8, !tbaa !5
  %60 = call double @pow(double noundef %59, double noundef 2.000000e+00) #6
  %61 = fadd double 1.000000e+00, %60
  %62 = call double @sqrt(double noundef %61) #6
  %63 = fdiv double %58, %62
  %64 = load double, ptr %8, align 8, !tbaa !5
  %65 = fadd double %63, %64
  store double %65, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  %66 = load double, ptr %21, align 8, !tbaa !5
  %67 = load double, ptr %16, align 8, !tbaa !5
  %68 = fmul double %66, %67
  %69 = load double, ptr %16, align 8, !tbaa !5
  %70 = call double @pow(double noundef %69, double noundef 2.000000e+00) #6
  %71 = fadd double 1.000000e+00, %70
  %72 = call double @sqrt(double noundef %71) #6
  %73 = fdiv double %68, %72
  %74 = load double, ptr %9, align 8, !tbaa !5
  %75 = fadd double %73, %74
  store double %75, ptr %23, align 8, !tbaa !5
  %76 = load double, ptr %22, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.Coord, ptr %13, i32 0, i32 0
  store double %76, ptr %77, align 8, !tbaa !13
  %78 = load double, ptr %23, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.Coord, ptr %13, i32 0, i32 1
  store double %78, ptr %79, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #6
  %80 = load double, ptr %21, align 8, !tbaa !5
  %81 = load double, ptr %16, align 8, !tbaa !5
  %82 = call double @pow(double noundef %81, double noundef 2.000000e+00) #6
  %83 = fadd double 1.000000e+00, %82
  %84 = call double @sqrt(double noundef %83) #6
  %85 = fdiv double %80, %84
  %86 = load double, ptr %8, align 8, !tbaa !5
  %87 = call double @llvm.fmuladd.f64(double -1.000000e+00, double %85, double %86)
  store double %87, ptr %24, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #6
  %88 = load double, ptr %21, align 8, !tbaa !5
  %89 = load double, ptr %16, align 8, !tbaa !5
  %90 = fmul double %88, %89
  %91 = load double, ptr %16, align 8, !tbaa !5
  %92 = call double @pow(double noundef %91, double noundef 2.000000e+00) #6
  %93 = fadd double 1.000000e+00, %92
  %94 = call double @sqrt(double noundef %93) #6
  %95 = fdiv double %90, %94
  %96 = load double, ptr %9, align 8, !tbaa !5
  %97 = call double @llvm.fmuladd.f64(double -1.000000e+00, double %95, double %96)
  store double %97, ptr %25, align 8, !tbaa !5
  %98 = load double, ptr %24, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.Coord, ptr %14, i32 0, i32 0
  store double %98, ptr %99, align 8, !tbaa !13
  %100 = load double, ptr %25, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.Coord, ptr %14, i32 0, i32 1
  store double %100, ptr %101, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %26, ptr align 8 %2, i64 32, i1 false), !tbaa.struct !14
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %27, ptr align 8 %13, i64 32, i1 false), !tbaa.struct !14
  %102 = call noundef double @_Z8shortfit5CoordS_(ptr noundef byval(%struct.Coord) align 8 %26, ptr noundef byval(%struct.Coord) align 8 %27)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %28, ptr align 8 %2, i64 32, i1 false), !tbaa.struct !14
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %29, ptr align 8 %14, i64 32, i1 false), !tbaa.struct !14
  %103 = call noundef double @_Z8shortfit5CoordS_(ptr noundef byval(%struct.Coord) align 8 %28, ptr noundef byval(%struct.Coord) align 8 %29)
  %104 = fcmp ole double %102, %103
  br i1 %104, label %105, label %106

105:                                              ; preds = %7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %13, i64 32, i1 false), !tbaa.struct !14
  br label %107

106:                                              ; preds = %7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %14, i64 32, i1 false), !tbaa.struct !14
  br label %107

107:                                              ; preds = %106, %105
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  ret void
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTS5Coord", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!12, !6, i64 0}
!14 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5}


; 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.Coord = type { double, double, double, double }

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z15generate_randomiddi(i32 noundef, double noundef, double noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z8shortfit5CoordS_(ptr noundef byval(%struct.Coord) align 8, ptr noundef byval(%struct.Coord) align 8) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z11obsdistance5CoordS_ddd(ptr noundef byval(%struct.Coord) align 8, ptr noundef byval(%struct.Coord) align 8, double noundef, double noundef, double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z11newparticle5CoordS_dddi(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.Coord) align 8 %0, ptr nocapture noundef readonly byval(%struct.Coord) align 8 %1, ptr nocapture noundef readonly byval(%struct.Coord) align 8 %2, double noundef %3, double noundef %4, double noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = alloca %struct.Coord, align 16
  %9 = alloca %struct.Coord, align 16
  %10 = fmul double %5, 3.000000e-01
  %11 = load <2 x double>, ptr %1, align 8, !tbaa !5
  %12 = load <2 x double>, ptr %2, align 8, !tbaa !5
  %13 = fsub <2 x double> %11, %12
  %14 = extractelement <2 x double> %13, i64 0
  %15 = extractelement <2 x double> %13, i64 1
  %16 = fdiv double %15, %14
  %17 = fdiv double -1.000000e+00, %16
  %18 = tail call noundef double @_Z11obsdistance5CoordS_ddd(ptr noundef nonnull byval(%struct.Coord) align 8 %1, ptr noundef nonnull byval(%struct.Coord) align 8 %2, double noundef %3, double noundef %4, double noundef %5)
  %19 = tail call noundef ptr @_Z15generate_randomiddi(i32 noundef 1, double noundef 0.000000e+00, double noundef 1.000000e+00, i32 noundef %6)
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = tail call double @llvm.fmuladd.f64(double %20, double %10, double %5)
  %square = fmul double %17, %17
  %22 = fadd double %square, 1.000000e+00
  %sqrt42 = tail call double @llvm.sqrt.f64(double %22)
  %23 = fmul double %17, %21
  %24 = insertelement <2 x double> poison, double %21, i64 0
  %25 = insertelement <2 x double> %24, double %23, i64 1
  %26 = insertelement <2 x double> poison, double %sqrt42, i64 0
  %27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
  %28 = fdiv <2 x double> %25, %27
  %29 = insertelement <2 x double> poison, double %3, i64 0
  %30 = insertelement <2 x double> %29, double %4, i64 1
  %31 = fadd <2 x double> %28, %30
  store <2 x double> %31, ptr %8, align 16, !tbaa !5
  %32 = tail call noundef double @_Z8shortfit5CoordS_(ptr noundef nonnull byval(%struct.Coord) align 8 %2, ptr noundef nonnull byval(%struct.Coord) align 8 %8)
  %33 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %28, <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double> %30)
  store <2 x double> %33, ptr %9, align 16, !tbaa !5
  %34 = tail call noundef double @_Z8shortfit5CoordS_(ptr noundef nonnull byval(%struct.Coord) align 8 %2, ptr noundef nonnull byval(%struct.Coord) align 8 %9)
  %35 = fcmp ugt double %32, %34
  %36 = insertelement <2 x i1> poison, i1 %35, i64 0
  %37 = shufflevector <2 x i1> %36, <2 x i1> poison, <2 x i32> zeroinitializer
  %38 = select <2 x i1> %37, <2 x double> %33, <2 x double> %31
  store <2 x double> %38, ptr %0, align 8
  ret void
}

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

; 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>) #3

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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass