; LLVM IR from thuhcsi/Crystal.TTVS :: Xface/XFace/src/XMath/Quaternion.ll (ZN5XMath10Quaternion13FromAxisAngleERKNS_9AxisAngleE)

; 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.XMath::Vector3" = type { float, float, float }
%"class.XMath::Quaternion" = type { float, float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZN5XMath10Quaternion13FromAxisAngleERKNS_9AxisAngleE(ptr noundef nonnull align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(16) %1) #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.XMath::Vector3", align 4
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #4
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNK5XMath9AxisAngle7getAxisEv(ptr dead_on_unwind writable sret(%"class.XMath::Vector3") align 4 %5, ptr noundef nonnull align 4 dereferenceable(16) %10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = invoke noundef float @_ZNK5XMath9AxisAngle8getAngleEv(ptr noundef nonnull align 4 dereferenceable(16) %11)
          to label %13 unwind label %39

13:                                               ; preds = %2
  %14 = fdiv float %12, 2.000000e+00
  %15 = invoke noundef float @_ZSt3sinf(float noundef %14)
          to label %16 unwind label %39

16:                                               ; preds = %13
  store float %15, ptr %6, align 4, !tbaa !9
  %17 = getelementptr inbounds %"class.XMath::Vector3", ptr %5, i32 0, i32 0
  %18 = load float, ptr %17, align 4, !tbaa !11
  %19 = load float, ptr %6, align 4, !tbaa !9
  %20 = fmul float %18, %19
  %21 = getelementptr inbounds %"class.XMath::Quaternion", ptr %9, i32 0, i32 0
  store float %20, ptr %21, align 4, !tbaa !13
  %22 = getelementptr inbounds %"class.XMath::Vector3", ptr %5, i32 0, i32 1
  %23 = load float, ptr %22, align 4, !tbaa !15
  %24 = load float, ptr %6, align 4, !tbaa !9
  %25 = fmul float %23, %24
  %26 = getelementptr inbounds %"class.XMath::Quaternion", ptr %9, i32 0, i32 1
  store float %25, ptr %26, align 4, !tbaa !16
  %27 = getelementptr inbounds %"class.XMath::Vector3", ptr %5, i32 0, i32 2
  %28 = load float, ptr %27, align 4, !tbaa !17
  %29 = load float, ptr %6, align 4, !tbaa !9
  %30 = fmul float %28, %29
  %31 = getelementptr inbounds %"class.XMath::Quaternion", ptr %9, i32 0, i32 2
  store float %30, ptr %31, align 4, !tbaa !18
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = invoke noundef float @_ZNK5XMath9AxisAngle8getAngleEv(ptr noundef nonnull align 4 dereferenceable(16) %32)
          to label %34 unwind label %39

34:                                               ; preds = %16
  %35 = fdiv float %33, 2.000000e+00
  %36 = invoke noundef float @_ZSt3cosf(float noundef %35)
          to label %37 unwind label %39

37:                                               ; preds = %34
  %38 = getelementptr inbounds %"class.XMath::Quaternion", ptr %9, i32 0, i32 3
  store float %36, ptr %38, align 4, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12) %5) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #4
  ret ptr %9

39:                                               ; preds = %34, %16, %13, %2
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %7, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12) %5) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #4
  br label %43

43:                                               ; preds = %39
  %44 = load ptr, ptr %7, align 8
  %45 = load i32, ptr %8, align 4
  %46 = insertvalue { ptr, i32 } poison, ptr %44, 0
  %47 = insertvalue { ptr, i32 } %46, i32 %45, 1
  resume { ptr, i32 } %47
}

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

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK5XMath9AxisAngle7getAxisEv(ptr dead_on_unwind noalias writable sret(%"class.XMath::Vector3") align 4, ptr noundef nonnull align 4 dereferenceable(16)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK5XMath9AxisAngle8getAngleEv(ptr noundef nonnull align 4 dereferenceable(16)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN5XMath7Vector3E", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTSN5XMath10QuaternionE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!15 = !{!12, !10, i64 4}
!16 = !{!14, !10, i64 4}
!17 = !{!12, !10, i64 8}
!18 = !{!14, !10, i64 8}
!19 = !{!14, !10, i64 12}


; 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.XMath::Vector3" = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZN5XMath10Quaternion13FromAxisAngleERKNS_9AxisAngleE(ptr noundef nonnull returned writeonly align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(16) %1) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.XMath::Vector3", align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #4
  call void @_ZNK5XMath9AxisAngle7getAxisEv(ptr dead_on_unwind nonnull writable sret(%"class.XMath::Vector3") align 4 %3, ptr noundef nonnull align 4 dereferenceable(16) %1)
  %4 = call noundef float @_ZNK5XMath9AxisAngle8getAngleEv(ptr noundef nonnull align 4 dereferenceable(16) %1)
  %5 = fmul float %4, 5.000000e-01
  %6 = call noundef float @_ZSt3sinf(float noundef %5)
  %7 = load <2 x float>, ptr %3, align 8, !tbaa !5
  %8 = insertelement <2 x float> poison, float %6, i64 0
  %9 = shufflevector <2 x float> %8, <2 x float> poison, <2 x i32> zeroinitializer
  %10 = fmul <2 x float> %9, %7
  store <2 x float> %10, ptr %0, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %3, i64 8
  %12 = load float, ptr %11, align 8, !tbaa !9
  %13 = fmul float %6, %12
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  store float %13, ptr %14, align 4, !tbaa !11
  %15 = call noundef float @_ZNK5XMath9AxisAngle8getAngleEv(ptr noundef nonnull align 4 dereferenceable(16) %1)
  %16 = fmul float %15, 5.000000e-01
  %17 = call noundef float @_ZSt3cosf(float noundef %16)
  %18 = getelementptr inbounds i8, ptr %0, i64 12
  store float %17, ptr %18, align 4, !tbaa !13
  call void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12) %3) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #4
  ret ptr %0
}

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

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK5XMath9AxisAngle7getAxisEv(ptr dead_on_unwind noalias writable sret(%"class.XMath::Vector3") align 4, ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK5XMath9AxisAngle8getAngleEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3 align 2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTSN5XMath7Vector3E", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN5XMath10QuaternionE", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!13 = !{!12, !6, i64 12}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass