; LLVM IR from Sopiro/Muli :: src/util/math.ll (ZN4muli4Mat36RotateEf)

; 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.muli::Mat3" = type { %"struct.muli::Vec3", %"struct.muli::Vec3", %"struct.muli::Vec3" }
%"struct.muli::Vec3" = type { float, float, float }

; 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: mustprogress uwtable
define dso_local void @_ZN4muli4Mat36RotateEf(ptr dead_on_unwind noalias writable sret(%"struct.muli::Mat3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(36) %1, float noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca %"struct.muli::Mat3", align 4
  store ptr %1, ptr %4, align 8, !tbaa !5
  store float %2, ptr %5, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %10 = load float, ptr %5, align 4, !tbaa !9
  %11 = call float @sinf(float noundef %10) #4
  store float %11, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %12 = load float, ptr %5, align 4, !tbaa !9
  %13 = call float @cosf(float noundef %12) #4
  store float %13, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 36, ptr %8) #4
  %14 = load float, ptr %7, align 4, !tbaa !9
  %15 = getelementptr inbounds %"struct.muli::Mat3", ptr %8, i32 0, i32 0
  %16 = getelementptr inbounds %"struct.muli::Vec3", ptr %15, i32 0, i32 0
  store float %14, ptr %16, align 4, !tbaa !11
  %17 = load float, ptr %6, align 4, !tbaa !9
  %18 = fneg float %17
  %19 = getelementptr inbounds %"struct.muli::Mat3", ptr %8, i32 0, i32 1
  %20 = getelementptr inbounds %"struct.muli::Vec3", ptr %19, i32 0, i32 0
  store float %18, ptr %20, align 4, !tbaa !14
  %21 = getelementptr inbounds %"struct.muli::Mat3", ptr %8, i32 0, i32 2
  %22 = getelementptr inbounds %"struct.muli::Vec3", ptr %21, i32 0, i32 0
  store float 0.000000e+00, ptr %22, align 4, !tbaa !15
  %23 = load float, ptr %6, align 4, !tbaa !9
  %24 = getelementptr inbounds %"struct.muli::Mat3", ptr %8, i32 0, i32 0
  %25 = getelementptr inbounds %"struct.muli::Vec3", ptr %24, i32 0, i32 1
  store float %23, ptr %25, align 4, !tbaa !16
  %26 = load float, ptr %7, align 4, !tbaa !9
  %27 = getelementptr inbounds %"struct.muli::Mat3", ptr %8, i32 0, i32 1
  %28 = getelementptr inbounds %"struct.muli::Vec3", ptr %27, i32 0, i32 1
  store float %26, ptr %28, align 4, !tbaa !17
  %29 = getelementptr inbounds %"struct.muli::Mat3", ptr %8, i32 0, i32 2
  %30 = getelementptr inbounds %"struct.muli::Vec3", ptr %29, i32 0, i32 1
  store float 0.000000e+00, ptr %30, align 4, !tbaa !18
  %31 = getelementptr inbounds %"struct.muli::Mat3", ptr %8, i32 0, i32 0
  %32 = getelementptr inbounds %"struct.muli::Vec3", ptr %31, i32 0, i32 2
  store float 0.000000e+00, ptr %32, align 4, !tbaa !19
  %33 = getelementptr inbounds %"struct.muli::Mat3", ptr %8, i32 0, i32 1
  %34 = getelementptr inbounds %"struct.muli::Vec3", ptr %33, i32 0, i32 2
  store float 0.000000e+00, ptr %34, align 4, !tbaa !20
  %35 = getelementptr inbounds %"struct.muli::Mat3", ptr %8, i32 0, i32 2
  %36 = getelementptr inbounds %"struct.muli::Vec3", ptr %35, i32 0, i32 2
  store float 1.000000e+00, ptr %36, align 4, !tbaa !21
  call void @_ZN4muli3MulERKNS_4Mat3ES2_(ptr dead_on_unwind writable sret(%"struct.muli::Mat3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(36) %9, ptr noundef nonnull align 4 dereferenceable(36) %8)
  call void @llvm.lifetime.end.p0(i64 36, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  ret void
}

; Function Attrs: nounwind
declare float @sinf(float noundef) #2

; Function Attrs: nounwind
declare float @cosf(float noundef) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN4muli3MulERKNS_4Mat3ES2_(ptr dead_on_unwind noalias writable sret(%"struct.muli::Mat3") align 4, ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 4 dereferenceable(36)) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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 = !{!"_ZTSN4muli4Mat3E", !13, i64 0, !13, i64 12, !13, i64 24}
!13 = !{!"_ZTSN4muli4Vec3E", !10, i64 0, !10, i64 4, !10, i64 8}
!14 = !{!12, !10, i64 12}
!15 = !{!12, !10, i64 24}
!16 = !{!12, !10, i64 4}
!17 = !{!12, !10, i64 16}
!18 = !{!12, !10, i64 28}
!19 = !{!12, !10, i64 8}
!20 = !{!12, !10, i64 20}
!21 = !{!12, !10, i64 32}


; 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.muli::Mat3" = type { %"struct.muli::Vec3", %"struct.muli::Vec3", %"struct.muli::Vec3" }
%"struct.muli::Vec3" = type { float, float, float }

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4muli4Mat36RotateEf(ptr dead_on_unwind noalias writable sret(%"struct.muli::Mat3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(36) %1, float noundef %2) local_unnamed_addr #1 align 2 {
  %4 = alloca %"struct.muli::Mat3", align 4
  %5 = tail call float @sinf(float noundef %2) #4
  %6 = tail call float @cosf(float noundef %2) #4
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %4) #4
  store float %6, ptr %4, align 4, !tbaa !5
  %7 = fneg float %5
  %8 = getelementptr inbounds i8, ptr %4, i64 12
  store float %7, ptr %8, align 4, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %4, i64 4
  store float %5, ptr %9, align 4, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %4, i64 16
  store float %6, ptr %10, align 4, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %4, i64 8
  store float 0.000000e+00, ptr %11, align 4, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %4, i64 20
  store <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00>, ptr %12, align 4, !tbaa !15
  call void @_ZN4muli3MulERKNS_4Mat3ES2_(ptr dead_on_unwind writable sret(%"struct.muli::Mat3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(36) %1, ptr noundef nonnull align 4 dereferenceable(36) %4)
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %4) #4
  ret void
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN4muli3MulERKNS_4Mat3ES2_(ptr dead_on_unwind noalias writable sret(%"struct.muli::Mat3") align 4, ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 4 dereferenceable(36)) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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, !8, i64 0}
!6 = !{!"_ZTSN4muli4Mat3E", !7, i64 0, !7, i64 12, !7, i64 24}
!7 = !{!"_ZTSN4muli4Vec3E", !8, i64 0, !8, i64 4, !8, i64 8}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!6, !8, i64 12}
!12 = !{!6, !8, i64 4}
!13 = !{!6, !8, i64 16}
!14 = !{!6, !8, i64 8}
!15 = !{!8, !8, i64 0}


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