; LLVM IR from RiteshKH/Particle-Swarm-Optimiztion-based-Global-Path-planning :: PSO.ll (Z11obsdistance5CoordS_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.Coord = type { double, 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: nounwind
declare double @sqrt(double noundef) #1

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z11obsdistance5CoordS_ddd(ptr noundef byval(%struct.Coord) align 8 %0, ptr noundef byval(%struct.Coord) align 8 %1, double noundef %2, double noundef %3, double noundef %4) #3 {
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  store double %2, ptr %6, align 8, !tbaa !5
  store double %3, ptr %7, align 8, !tbaa !5
  store double %4, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %13 = getelementptr inbounds %struct.Coord, ptr %0, i32 0, i32 1
  %14 = load double, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 1
  %16 = load double, ptr %15, align 8, !tbaa !9
  %17 = fsub double %14, %16
  %18 = getelementptr inbounds %struct.Coord, ptr %0, i32 0, i32 0
  %19 = load double, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 0
  %21 = load double, ptr %20, align 8, !tbaa !11
  %22 = fsub double %19, %21
  %23 = fdiv double %17, %22
  store double %23, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %24 = load double, ptr %9, align 8, !tbaa !5
  %25 = load double, ptr %6, align 8, !tbaa !5
  %26 = load double, ptr %7, align 8, !tbaa !5
  %27 = fneg double %26
  %28 = call double @llvm.fmuladd.f64(double %24, double %25, double %27)
  %29 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 1
  %30 = load double, ptr %29, align 8, !tbaa !9
  %31 = fadd double %28, %30
  %32 = load double, ptr %9, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 0
  %34 = load double, ptr %33, align 8, !tbaa !11
  %35 = fneg double %32
  %36 = call double @llvm.fmuladd.f64(double %35, double %34, double %31)
  %37 = call double @llvm.fabs.f64(double %36)
  store double %37, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %38 = load double, ptr %9, align 8, !tbaa !5
  %39 = call double @pow(double noundef %38, double noundef 2.000000e+00) #4
  %40 = fadd double 1.000000e+00, %39
  %41 = call double @sqrt(double noundef %40) #4
  store double %41, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %42 = load double, ptr %10, align 8, !tbaa !5
  %43 = load double, ptr %11, align 8, !tbaa !5
  %44 = fdiv double %42, %43
  %45 = load double, ptr %8, align 8, !tbaa !5
  %46 = fsub double %44, %45
  store double %46, ptr %12, align 8, !tbaa !5
  %47 = load double, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret double %47
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { 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, !6, i64 8}
!10 = !{!"_ZTS5Coord", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!10, !6, 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"

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

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef double @_Z11obsdistance5CoordS_ddd(ptr nocapture noundef readonly byval(%struct.Coord) align 8 %0, ptr nocapture noundef readonly byval(%struct.Coord) align 8 %1, double noundef %2, double noundef %3, double noundef %4) local_unnamed_addr #1 {
  %6 = load <2 x double>, ptr %0, align 8, !tbaa !5
  %7 = load <2 x double>, ptr %1, align 8, !tbaa !5
  %8 = fsub <2 x double> %6, %7
  %9 = extractelement <2 x double> %8, i64 0
  %10 = extractelement <2 x double> %8, i64 1
  %11 = fdiv double %10, %9
  %12 = fneg double %3
  %13 = tail call double @llvm.fmuladd.f64(double %11, double %2, double %12)
  %14 = extractelement <2 x double> %7, i64 1
  %15 = fadd double %14, %13
  %16 = fneg double %11
  %17 = extractelement <2 x double> %7, i64 0
  %18 = tail call double @llvm.fmuladd.f64(double %16, double %17, double %15)
  %19 = tail call double @llvm.fabs.f64(double %18)
  %square = fmul double %11, %11
  %20 = fadd double %square, 1.000000e+00
  %sqrt = tail call double @llvm.sqrt.f64(double %20)
  %21 = fdiv double %19, %sqrt
  %22 = fsub double %21, %4
  ret double %22
}

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 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,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass