; LLVM IR from nubot-nudt/simatch :: src/auto_referee/src/Quaternion.ll (ZN6gazebo4math10Quaternion11SetFromAxisEdddd)

; 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.gazebo::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: 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 @cos(double noundef) #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6gazebo4math5equalIdEEbRKT_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6gazebo4math10Quaternion11SetFromAxisEdddd(ptr noundef nonnull align 8 dereferenceable(32) %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4) #3 align 2 {
  %6 = alloca ptr, 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
  %13 = alloca double, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !9
  store double %2, ptr %8, align 8, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !9
  store double %4, ptr %10, align 8, !tbaa !9
  %14 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %15 = load double, ptr %7, align 8, !tbaa !9
  %16 = load double, ptr %7, align 8, !tbaa !9
  %17 = load double, ptr %8, align 8, !tbaa !9
  %18 = load double, ptr %8, align 8, !tbaa !9
  %19 = fmul double %17, %18
  %20 = call double @llvm.fmuladd.f64(double %15, double %16, double %19)
  %21 = load double, ptr %9, align 8, !tbaa !9
  %22 = load double, ptr %9, align 8, !tbaa !9
  %23 = call double @llvm.fmuladd.f64(double %21, double %22, double %20)
  store double %23, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store double 0.000000e+00, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store double 0x3EB0C6F7A0B5ED8D, ptr %13, align 8, !tbaa !9
  %24 = call noundef zeroext i1 @_ZN6gazebo4math5equalIdEEbRKT_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %13)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br i1 %24, label %25, label %30

25:                                               ; preds = %5
  %26 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %14, i32 0, i32 0
  store double 1.000000e+00, ptr %26, align 8, !tbaa !11
  %27 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %14, i32 0, i32 1
  store double 0.000000e+00, ptr %27, align 8, !tbaa !13
  %28 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %14, i32 0, i32 2
  store double 0.000000e+00, ptr %28, align 8, !tbaa !14
  %29 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %14, i32 0, i32 3
  store double 0.000000e+00, ptr %29, align 8, !tbaa !15
  br label %53

30:                                               ; preds = %5
  %31 = load double, ptr %10, align 8, !tbaa !9
  %32 = fmul double %31, 5.000000e-01
  store double %32, ptr %10, align 8, !tbaa !9
  %33 = load double, ptr %10, align 8, !tbaa !9
  %34 = call double @sin(double noundef %33) #5
  %35 = load double, ptr %11, align 8, !tbaa !9
  %36 = call double @sqrt(double noundef %35) #5
  %37 = fdiv double %34, %36
  store double %37, ptr %11, align 8, !tbaa !9
  %38 = load double, ptr %10, align 8, !tbaa !9
  %39 = call double @cos(double noundef %38) #5
  %40 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %14, i32 0, i32 0
  store double %39, ptr %40, align 8, !tbaa !11
  %41 = load double, ptr %7, align 8, !tbaa !9
  %42 = load double, ptr %11, align 8, !tbaa !9
  %43 = fmul double %41, %42
  %44 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %14, i32 0, i32 1
  store double %43, ptr %44, align 8, !tbaa !13
  %45 = load double, ptr %8, align 8, !tbaa !9
  %46 = load double, ptr %11, align 8, !tbaa !9
  %47 = fmul double %45, %46
  %48 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %14, i32 0, i32 2
  store double %47, ptr %48, align 8, !tbaa !14
  %49 = load double, ptr %9, align 8, !tbaa !9
  %50 = load double, ptr %11, align 8, !tbaa !9
  %51 = fmul double %49, %50
  %52 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %14, i32 0, i32 3
  store double %51, ptr %52, align 8, !tbaa !15
  br label %53

53:                                               ; preds = %30, %25
  call void @_ZN6gazebo4math10Quaternion9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(32) %14)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  ret void
}

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 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 = { 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 #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}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN6gazebo4math10QuaternionE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 24}


; 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 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: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(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 nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6gazebo4math5equalIdEEbRKT_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6gazebo4math10Quaternion11SetFromAxisEdddd(ptr noundef nonnull align 8 dereferenceable(32) %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4) local_unnamed_addr #3 align 2 {
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %9 = fmul double %2, %2
  %10 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %9)
  %11 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %10)
  store double %11, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  store double 0.000000e+00, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  store double 0x3EB0C6F7A0B5ED8D, ptr %8, align 8, !tbaa !5
  %12 = call noundef zeroext i1 @_ZN6gazebo4math5equalIdEEbRKT_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br i1 %12, label %27, label %13

13:                                               ; preds = %5
  %14 = fmul double %4, 5.000000e-01
  %15 = call double @sin(double noundef %14) #5
  %16 = load double, ptr %6, align 8, !tbaa !5
  %17 = call double @sqrt(double noundef %16) #5
  %18 = fdiv double %15, %17
  store double %18, ptr %6, align 8, !tbaa !5
  %19 = call double @cos(double noundef %14) #5
  %20 = load double, ptr %6, align 8, !tbaa !5
  %21 = insertelement <2 x double> poison, double %20, i64 0
  %22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
  %23 = insertelement <2 x double> poison, double %1, i64 0
  %24 = insertelement <2 x double> %23, double %2, i64 1
  %25 = fmul <2 x double> %22, %24
  %26 = fmul double %20, %3
  br label %27

27:                                               ; preds = %5, %13
  %.sink15 = phi double [ %19, %13 ], [ 1.000000e+00, %5 ]
  %.sink = phi double [ %26, %13 ], [ 0.000000e+00, %5 ]
  %28 = phi <2 x double> [ %25, %13 ], [ zeroinitializer, %5 ]
  store double %.sink15, ptr %0, align 8
  %29 = getelementptr inbounds i8, ptr %0, i64 8
  store <2 x double> %28, ptr %29, align 8
  %30 = getelementptr inbounds i8, ptr %0, i64 24
  store double %.sink, ptr %30, align 8
  call void @_ZN6gazebo4math10Quaternion9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  ret void
}

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #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"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass