; LLVM IR from maliput/maliput :: src/maliput/math/quaternion.ll (ZNK7maliput4math10Quaternion5SlerpEdRKS1_)

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

%"class.maliput::math::Vector4" = type { %"class.maliput::math::VectorBase.2" }
%"class.maliput::math::VectorBase.2" = type { %"struct.std::array.3" }
%"struct.std::array.3" = type { [4 x double] }
%"class.maliput::math::Quaternion" = 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: nounwind
declare double @sin(double noundef) #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK7maliput4math10Quaternion6coeffsEv(ptr dead_on_unwind noalias writable sret(%"class.maliput::math::Vector4") align 8, ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7maliput4math10QuaternionC2ERKNS0_7Vector4E(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK7maliput4math10Quaternion5SlerpEdRKS1_(ptr dead_on_unwind noalias writable sret(%"class.maliput::math::Quaternion") align 8 %0, ptr noundef nonnull align 8 dereferenceable(32) %1, double noundef %2, ptr noundef nonnull align 8 dereferenceable(32) %3) #3 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, 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
  %13 = alloca double, align 8
  %14 = alloca %"class.maliput::math::Vector4", align 8
  %15 = alloca %"class.maliput::math::Vector4", align 8
  %16 = alloca %"class.maliput::math::Vector4", align 8
  %17 = alloca %"class.maliput::math::Vector4", align 8
  %18 = alloca %"class.maliput::math::Vector4", align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store double %2, ptr %6, align 8, !tbaa !9
  store ptr %3, ptr %7, align 8, !tbaa !5
  %19 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = call noundef double @_ZNK7maliput4math10Quaternion3dotERKS1_(ptr noundef nonnull align 8 dereferenceable(32) %19, ptr noundef nonnull align 8 dereferenceable(32) %20)
  store double %21, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %22 = load double, ptr %8, align 8, !tbaa !9
  %23 = call noundef double @_ZSt3absd(double noundef %22)
  store double %23, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %24 = load double, ptr %6, align 8, !tbaa !9
  %25 = fsub double 1.000000e+00, %24
  store double %25, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %26 = load double, ptr %6, align 8, !tbaa !9
  store double %26, ptr %11, align 8, !tbaa !9
  %27 = load double, ptr %9, align 8, !tbaa !9
  %28 = fcmp olt double %27, 0x3FEFFFFFFFFFFFF7
  br i1 %28, label %29, label %46

29:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %30 = load double, ptr %9, align 8, !tbaa !9
  %31 = call double @acos(double noundef %30) #5
  store double %31, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %32 = load double, ptr %12, align 8, !tbaa !9
  %33 = call double @sin(double noundef %32) #5
  store double %33, ptr %13, align 8, !tbaa !9
  %34 = load double, ptr %10, align 8, !tbaa !9
  %35 = load double, ptr %12, align 8, !tbaa !9
  %36 = fmul double %34, %35
  %37 = call double @sin(double noundef %36) #5
  %38 = load double, ptr %13, align 8, !tbaa !9
  %39 = fdiv double %37, %38
  store double %39, ptr %10, align 8, !tbaa !9
  %40 = load double, ptr %11, align 8, !tbaa !9
  %41 = load double, ptr %12, align 8, !tbaa !9
  %42 = fmul double %40, %41
  %43 = call double @sin(double noundef %42) #5
  %44 = load double, ptr %13, align 8, !tbaa !9
  %45 = fdiv double %43, %44
  store double %45, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %46

46:                                               ; preds = %29, %4
  %47 = load double, ptr %8, align 8, !tbaa !9
  %48 = fcmp olt double %47, 0.000000e+00
  br i1 %48, label %49, label %52

49:                                               ; preds = %46
  %50 = load double, ptr %11, align 8, !tbaa !9
  %51 = fneg double %50
  store double %51, ptr %11, align 8, !tbaa !9
  br label %52

52:                                               ; preds = %49, %46
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %15) #5
  %53 = load double, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %16) #5
  call void @_ZNK7maliput4math10Quaternion6coeffsEv(ptr dead_on_unwind writable sret(%"class.maliput::math::Vector4") align 8 %16, ptr noundef nonnull align 8 dereferenceable(32) %19)
  call void @_ZN7maliput4mathmlILm4ENS0_7Vector4EEET0_dRKNS0_10VectorBaseIXT_ES3_EE(ptr dead_on_unwind writable sret(%"class.maliput::math::Vector4") align 8 %15, double noundef %53, ptr noundef nonnull align 8 dereferenceable(32) %16)
  call void @llvm.lifetime.start.p0(i64 32, ptr %17) #5
  %54 = load double, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %18) #5
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZNK7maliput4math10Quaternion6coeffsEv(ptr dead_on_unwind writable sret(%"class.maliput::math::Vector4") align 8 %18, ptr noundef nonnull align 8 dereferenceable(32) %55)
  call void @_ZN7maliput4mathmlILm4ENS0_7Vector4EEET0_dRKNS0_10VectorBaseIXT_ES3_EE(ptr dead_on_unwind writable sret(%"class.maliput::math::Vector4") align 8 %17, double noundef %54, ptr noundef nonnull align 8 dereferenceable(32) %18)
  call void @_ZNK7maliput4math10VectorBaseILm4ENS0_7Vector4EEplERKS3_(ptr dead_on_unwind writable sret(%"class.maliput::math::Vector4") align 8 %14, ptr noundef nonnull align 8 dereferenceable(32) %15, ptr noundef nonnull align 8 dereferenceable(32) %17)
  call void @_ZN7maliput4math10QuaternionC2ERKNS0_7Vector4E(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %14)
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZNK7maliput4math10Quaternion3dotERKS1_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

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

declare void @_ZN7maliput4mathmlILm4ENS0_7Vector4EEET0_dRKNS0_10VectorBaseIXT_ES3_EE(ptr dead_on_unwind writable sret(%"class.maliput::math::Vector4") align 8, double noundef, ptr noundef nonnull align 8 dereferenceable(32)) #4

declare void @_ZNK7maliput4math10VectorBaseILm4ENS0_7Vector4EEplERKS3_(ptr dead_on_unwind writable sret(%"class.maliput::math::Vector4") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #4

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 = { inlinehint 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 = { 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}


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

%"class.maliput::math::Vector4" = type { %"class.maliput::math::VectorBase.2" }
%"class.maliput::math::VectorBase.2" = type { %"struct.std::array.3" }
%"struct.std::array.3" = type { [4 x double] }
%"class.maliput::math::Quaternion" = type { double, double, double, double }

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK7maliput4math10Quaternion6coeffsEv(ptr dead_on_unwind noalias writable sret(%"class.maliput::math::Vector4") align 8, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7maliput4math10QuaternionC2ERKNS0_7Vector4E(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK7maliput4math10Quaternion5SlerpEdRKS1_(ptr dead_on_unwind noalias writable sret(%"class.maliput::math::Quaternion") align 8 %0, ptr noundef nonnull align 8 dereferenceable(32) %1, double noundef %2, ptr noundef nonnull align 8 dereferenceable(32) %3) local_unnamed_addr #3 align 2 {
  %5 = alloca %"class.maliput::math::Vector4", align 8
  %6 = alloca %"class.maliput::math::Vector4", align 8
  %7 = alloca %"class.maliput::math::Vector4", align 8
  %8 = alloca %"class.maliput::math::Vector4", align 8
  %9 = alloca %"class.maliput::math::Vector4", align 8
  %10 = tail call noundef double @_ZNK7maliput4math10Quaternion3dotERKS1_(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %3)
  %11 = tail call noundef double @_ZSt3absd(double noundef %10)
  %12 = fsub double 1.000000e+00, %2
  %13 = fcmp olt double %11, 0x3FEFFFFFFFFFFFF7
  %14 = insertelement <2 x double> poison, double %12, i64 0
  %15 = insertelement <2 x double> %14, double %2, i64 1
  br i1 %13, label %16, label %28

16:                                               ; preds = %4
  %17 = tail call double @acos(double noundef %11) #5
  %18 = tail call double @sin(double noundef %17) #5
  %19 = fmul double %12, %17
  %20 = tail call double @sin(double noundef %19) #5
  %21 = fmul double %17, %2
  %22 = tail call double @sin(double noundef %21) #5
  %23 = insertelement <2 x double> poison, double %20, i64 0
  %24 = insertelement <2 x double> %23, double %22, i64 1
  %25 = insertelement <2 x double> poison, double %18, i64 0
  %26 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> zeroinitializer
  %27 = fdiv <2 x double> %24, %26
  br label %28

28:                                               ; preds = %16, %4
  %29 = phi <2 x double> [ %27, %16 ], [ %15, %4 ]
  %30 = fcmp olt double %10, 0.000000e+00
  %31 = extractelement <2 x double> %29, i64 1
  %32 = fneg double %31
  %.1 = select i1 %30, double %32, double %31
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #5
  call void @_ZNK7maliput4math10Quaternion6coeffsEv(ptr dead_on_unwind nonnull writable sret(%"class.maliput::math::Vector4") align 8 %7, ptr noundef nonnull align 8 dereferenceable(32) %1)
  %33 = extractelement <2 x double> %29, i64 0
  call void @_ZN7maliput4mathmlILm4ENS0_7Vector4EEET0_dRKNS0_10VectorBaseIXT_ES3_EE(ptr dead_on_unwind nonnull writable sret(%"class.maliput::math::Vector4") align 8 %6, double noundef %33, ptr noundef nonnull align 8 dereferenceable(32) %7)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #5
  call void @_ZNK7maliput4math10Quaternion6coeffsEv(ptr dead_on_unwind nonnull writable sret(%"class.maliput::math::Vector4") align 8 %9, ptr noundef nonnull align 8 dereferenceable(32) %3)
  call void @_ZN7maliput4mathmlILm4ENS0_7Vector4EEET0_dRKNS0_10VectorBaseIXT_ES3_EE(ptr dead_on_unwind nonnull writable sret(%"class.maliput::math::Vector4") align 8 %8, double noundef %.1, ptr noundef nonnull align 8 dereferenceable(32) %9)
  call void @_ZNK7maliput4math10VectorBaseILm4ENS0_7Vector4EEplERKS3_(ptr dead_on_unwind nonnull writable sret(%"class.maliput::math::Vector4") align 8 %5, ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull align 8 dereferenceable(32) %8)
  call void @_ZN7maliput4math10QuaternionC2ERKNS0_7Vector4E(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %5)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZNK7maliput4math10Quaternion3dotERKS1_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

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

declare void @_ZN7maliput4mathmlILm4ENS0_7Vector4EEET0_dRKNS0_10VectorBaseIXT_ES3_EE(ptr dead_on_unwind writable sret(%"class.maliput::math::Vector4") align 8, double noundef, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #4

declare void @_ZNK7maliput4math10VectorBaseILm4ENS0_7Vector4EEplERKS3_(ptr dead_on_unwind writable sret(%"class.maliput::math::Vector4") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = { 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)"}


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