; LLVM IR from shupx/swarm_sync_sim :: src/fw_plane_sim/src/px4_lib/geo/geo.ll (Z27get_vector_to_next_waypointddddPfS_)

; 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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN4math7radiansIdEET_S1_(double noundef) #0

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z27get_vector_to_next_waypointddddPfS_(double noundef %0, double noundef %1, double noundef %2, double noundef %3, ptr noundef %4, ptr noundef %5) #4 {
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  store double %0, ptr %7, align 8, !tbaa !5
  store double %1, ptr %8, align 8, !tbaa !5
  store double %2, ptr %9, align 8, !tbaa !5
  store double %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %16 = load double, ptr %7, align 8, !tbaa !5
  %17 = call noundef double @_ZN4math7radiansIdEET_S1_(double noundef %16)
  store double %17, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %18 = load double, ptr %9, align 8, !tbaa !5
  %19 = call noundef double @_ZN4math7radiansIdEET_S1_(double noundef %18)
  store double %19, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %20 = load double, ptr %10, align 8, !tbaa !5
  %21 = call noundef double @_ZN4math7radiansIdEET_S1_(double noundef %20)
  %22 = load double, ptr %8, align 8, !tbaa !5
  %23 = call noundef double @_ZN4math7radiansIdEET_S1_(double noundef %22)
  %24 = fsub double %21, %23
  store double %24, ptr %15, align 8, !tbaa !5
  %25 = load double, ptr %13, align 8, !tbaa !5
  %26 = call double @cos(double noundef %25) #5
  %27 = load double, ptr %14, align 8, !tbaa !5
  %28 = call double @sin(double noundef %27) #5
  %29 = load double, ptr %13, align 8, !tbaa !5
  %30 = call double @sin(double noundef %29) #5
  %31 = load double, ptr %14, align 8, !tbaa !5
  %32 = call double @cos(double noundef %31) #5
  %33 = fmul double %30, %32
  %34 = load double, ptr %15, align 8, !tbaa !5
  %35 = call double @cos(double noundef %34) #5
  %36 = fmul double %33, %35
  %37 = fneg double %36
  %38 = call double @llvm.fmuladd.f64(double %26, double %28, double %37)
  %39 = fmul double 6.371000e+06, %38
  %40 = fptrunc double %39 to float
  %41 = load ptr, ptr %11, align 8, !tbaa !9
  store float %40, ptr %41, align 4, !tbaa !11
  %42 = load double, ptr %15, align 8, !tbaa !5
  %43 = call double @sin(double noundef %42) #5
  %44 = fmul double 6.371000e+06, %43
  %45 = load double, ptr %14, align 8, !tbaa !5
  %46 = call double @cos(double noundef %45) #5
  %47 = fmul double %44, %46
  %48 = fptrunc double %47 to float
  %49 = load ptr, ptr %12, align 8, !tbaa !9
  store float %48, ptr %49, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  ret void
}

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" }
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 willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN4math7radiansIdEET_S1_(double noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z27get_vector_to_next_waypointddddPfS_(double noundef %0, double noundef %1, double noundef %2, double noundef %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 {
  %7 = tail call noundef double @_ZN4math7radiansIdEET_S1_(double noundef %0)
  %8 = tail call noundef double @_ZN4math7radiansIdEET_S1_(double noundef %2)
  %9 = tail call noundef double @_ZN4math7radiansIdEET_S1_(double noundef %3)
  %10 = tail call noundef double @_ZN4math7radiansIdEET_S1_(double noundef %1)
  %11 = fsub double %9, %10
  %12 = tail call double @cos(double noundef %7) #3
  %13 = tail call double @sin(double noundef %8) #3
  %14 = tail call double @sin(double noundef %7) #3
  %15 = tail call double @cos(double noundef %8) #3
  %16 = tail call double @cos(double noundef %11) #3
  %17 = fneg double %14
  %18 = fmul double %15, %17
  %19 = fmul double %18, %16
  %20 = tail call double @llvm.fmuladd.f64(double %12, double %13, double %19)
  %21 = fmul double %20, 6.371000e+06
  %22 = fptrunc double %21 to float
  store float %22, ptr %4, align 4, !tbaa !5
  %23 = tail call double @sin(double noundef %11) #3
  %24 = fmul double %23, 6.371000e+06
  %25 = tail call double @cos(double noundef %8) #3
  %26 = fmul double %24, %25
  %27 = fptrunc double %26 to float
  store float %27, ptr %5, align 4, !tbaa !5
  ret void
}

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


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