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

; 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: mustprogress nounwind uwtable
define dso_local noundef double @_Z9smoothfit5CoordS_S_(ptr noundef byval(%struct.Coord) align 8 %0, ptr noundef byval(%struct.Coord) align 8 %1, ptr noundef byval(%struct.Coord) align 8 %2) #2 {
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %7 = getelementptr inbounds %struct.Coord, ptr %0, i32 0, i32 0
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 0
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = fsub double %8, %10
  %12 = getelementptr inbounds %struct.Coord, ptr %2, i32 0, i32 0
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 0
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = fsub double %13, %15
  %17 = getelementptr inbounds %struct.Coord, ptr %0, i32 0, i32 1
  %18 = load double, ptr %17, align 8, !tbaa !10
  %19 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 1
  %20 = load double, ptr %19, align 8, !tbaa !10
  %21 = fsub double %18, %20
  %22 = getelementptr inbounds %struct.Coord, ptr %2, i32 0, i32 1
  %23 = load double, ptr %22, align 8, !tbaa !10
  %24 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 1
  %25 = load double, ptr %24, align 8, !tbaa !10
  %26 = fsub double %23, %25
  %27 = fmul double %21, %26
  %28 = call double @llvm.fmuladd.f64(double %11, double %16, double %27)
  store double %28, ptr %4, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %29 = getelementptr inbounds %struct.Coord, ptr %0, i32 0, i32 0
  %30 = load double, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 0
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = fsub double %30, %32
  %34 = call double @pow(double noundef %33, double noundef 2.000000e+00) #4
  %35 = getelementptr inbounds %struct.Coord, ptr %0, i32 0, i32 1
  %36 = load double, ptr %35, align 8, !tbaa !10
  %37 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 1
  %38 = load double, ptr %37, align 8, !tbaa !10
  %39 = fsub double %36, %38
  %40 = call double @pow(double noundef %39, double noundef 2.000000e+00) #4
  %41 = fadd double %34, %40
  %42 = call double @sqrt(double noundef %41) #4
  %43 = getelementptr inbounds %struct.Coord, ptr %2, i32 0, i32 0
  %44 = load double, ptr %43, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 0
  %46 = load double, ptr %45, align 8, !tbaa !5
  %47 = fsub double %44, %46
  %48 = call double @pow(double noundef %47, double noundef 2.000000e+00) #4
  %49 = getelementptr inbounds %struct.Coord, ptr %2, i32 0, i32 1
  %50 = load double, ptr %49, align 8, !tbaa !10
  %51 = getelementptr inbounds %struct.Coord, ptr %1, i32 0, i32 1
  %52 = load double, ptr %51, align 8, !tbaa !10
  %53 = fsub double %50, %52
  %54 = call double @pow(double noundef %53, double noundef 2.000000e+00) #4
  %55 = fadd double %48, %54
  %56 = call double @sqrt(double noundef %55) #4
  %57 = fmul double %42, %56
  store double %57, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %58 = load double, ptr %4, align 8, !tbaa !11
  %59 = load double, ptr %5, align 8, !tbaa !11
  %60 = fdiv double %58, %59
  %61 = call double @acos(double noundef %60) #4
  store double %61, ptr %6, align 8, !tbaa !11
  %62 = load double, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  ret double %62
}

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

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

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 = { 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) }
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, !7, i64 0}
!6 = !{!"_ZTS5Coord", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!7, !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"

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local noundef double @_Z9smoothfit5CoordS_S_(ptr nocapture noundef readonly byval(%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) local_unnamed_addr #0 {
  %4 = load <2 x double>, ptr %0, align 8
  %5 = load <2 x double>, ptr %1, align 8
  %6 = load double, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load <2 x double>, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load <2 x double>, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr %2, i64 8
  %12 = load double, ptr %11, align 8, !tbaa !10
  %13 = insertelement <2 x double> %4, double %6, i64 1
  %14 = shufflevector <2 x double> %5, <2 x double> poison, <2 x i32> zeroinitializer
  %15 = fsub <2 x double> %13, %14
  %16 = insertelement <2 x double> %8, double %12, i64 1
  %17 = shufflevector <2 x double> %10, <2 x double> poison, <2 x i32> zeroinitializer
  %18 = fsub <2 x double> %16, %17
  %shift = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %19 = fmul <2 x double> %18, %shift
  %20 = extractelement <2 x double> %19, i64 0
  %21 = extractelement <2 x double> %15, i64 0
  %22 = extractelement <2 x double> %15, i64 1
  %23 = tail call double @llvm.fmuladd.f64(double %21, double %22, double %20)
  %24 = fmul <2 x double> %15, %15
  %25 = fmul <2 x double> %18, %18
  %26 = fadd <2 x double> %24, %25
  %27 = tail call <2 x double> @llvm.sqrt.v2f64(<2 x double> %26)
  %shift7 = shufflevector <2 x double> %27, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %28 = fmul <2 x double> %27, %shift7
  %29 = extractelement <2 x double> %28, i64 0
  %30 = fdiv double %23, %29
  %31 = tail call double @acos(double noundef %30) #4
  ret double %31
}

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

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

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

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


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