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

; 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::Mat4" = type { %"struct.muli::Vec4", %"struct.muli::Vec4", %"struct.muli::Vec4", %"struct.muli::Vec4" }
%"struct.muli::Vec4" = type { float, float, float, float }
%"struct.muli::Transform" = type { %"struct.muli::Vec2", %"struct.muli::Rotation" }
%"struct.muli::Vec2" = type { float, float }
%"struct.muli::Rotation" = type { 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4muli4Mat4C2ERKNS_9TransformE(ptr noundef nonnull align 4 dereferenceable(64) %0, ptr noundef nonnull align 4 dereferenceable(16) %1) unnamed_addr #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8
  %13 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 0
  %14 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 1
  %15 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 2
  %16 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store float 0.000000e+00, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store float 1.000000e+00, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store float 0.000000e+00, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store float 1.000000e+00, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.muli::Transform", ptr %17, i32 0, i32 1
  %19 = call noundef float @_ZNK4muli8Rotation8GetAngleEv(ptr noundef nonnull align 4 dereferenceable(8) %18)
  store float %19, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %20 = load float, ptr %9, align 4, !tbaa !9
  %21 = call float @sinf(float noundef %20) #5
  store float %21, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %22 = load float, ptr %9, align 4, !tbaa !9
  %23 = call float @cosf(float noundef %22) #5
  store float %23, ptr %11, align 4, !tbaa !9
  %24 = load float, ptr %11, align 4, !tbaa !9
  %25 = fmul float 1.000000e+00, %24
  %26 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 0
  %27 = getelementptr inbounds %"struct.muli::Vec4", ptr %26, i32 0, i32 0
  store float %25, ptr %27, align 4, !tbaa !11
  %28 = load float, ptr %11, align 4, !tbaa !9
  %29 = load float, ptr %10, align 4, !tbaa !9
  %30 = fmul float 1.000000e+00, %29
  %31 = call float @llvm.fmuladd.f32(float 0.000000e+00, float %28, float %30)
  %32 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 0
  %33 = getelementptr inbounds %"struct.muli::Vec4", ptr %32, i32 0, i32 1
  store float %31, ptr %33, align 4, !tbaa !14
  %34 = load float, ptr %11, align 4, !tbaa !9
  %35 = load float, ptr %10, align 4, !tbaa !9
  %36 = fmul float 0.000000e+00, %35
  %37 = call float @llvm.fmuladd.f32(float -0.000000e+00, float %34, float %36)
  %38 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 0
  %39 = getelementptr inbounds %"struct.muli::Vec4", ptr %38, i32 0, i32 2
  store float %37, ptr %39, align 4, !tbaa !15
  %40 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 0
  %41 = getelementptr inbounds %"struct.muli::Vec4", ptr %40, i32 0, i32 3
  store float 0.000000e+00, ptr %41, align 4, !tbaa !16
  %42 = load float, ptr %10, align 4, !tbaa !9
  %43 = fmul float -1.000000e+00, %42
  %44 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 1
  %45 = getelementptr inbounds %"struct.muli::Vec4", ptr %44, i32 0, i32 0
  store float %43, ptr %45, align 4, !tbaa !17
  %46 = load float, ptr %10, align 4, !tbaa !9
  %47 = load float, ptr %11, align 4, !tbaa !9
  %48 = fmul float 1.000000e+00, %47
  %49 = call float @llvm.fmuladd.f32(float -0.000000e+00, float %46, float %48)
  %50 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 1
  %51 = getelementptr inbounds %"struct.muli::Vec4", ptr %50, i32 0, i32 1
  store float %49, ptr %51, align 4, !tbaa !18
  %52 = load float, ptr %10, align 4, !tbaa !9
  %53 = load float, ptr %11, align 4, !tbaa !9
  %54 = fmul float 0.000000e+00, %53
  %55 = call float @llvm.fmuladd.f32(float 0.000000e+00, float %52, float %54)
  %56 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 1
  %57 = getelementptr inbounds %"struct.muli::Vec4", ptr %56, i32 0, i32 2
  store float %55, ptr %57, align 4, !tbaa !19
  %58 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 1
  %59 = getelementptr inbounds %"struct.muli::Vec4", ptr %58, i32 0, i32 3
  store float 0.000000e+00, ptr %59, align 4, !tbaa !20
  %60 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 2
  %61 = getelementptr inbounds %"struct.muli::Vec4", ptr %60, i32 0, i32 0
  store float 0.000000e+00, ptr %61, align 4, !tbaa !21
  %62 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 2
  %63 = getelementptr inbounds %"struct.muli::Vec4", ptr %62, i32 0, i32 1
  store float -0.000000e+00, ptr %63, align 4, !tbaa !22
  %64 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 2
  %65 = getelementptr inbounds %"struct.muli::Vec4", ptr %64, i32 0, i32 2
  store float 1.000000e+00, ptr %65, align 4, !tbaa !23
  %66 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 2
  %67 = getelementptr inbounds %"struct.muli::Vec4", ptr %66, i32 0, i32 3
  store float 0.000000e+00, ptr %67, align 4, !tbaa !24
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.muli::Transform", ptr %68, i32 0, i32 0
  %70 = getelementptr inbounds %"struct.muli::Vec2", ptr %69, i32 0, i32 0
  %71 = load float, ptr %70, align 4, !tbaa !25
  %72 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 3
  %73 = getelementptr inbounds %"struct.muli::Vec4", ptr %72, i32 0, i32 0
  store float %71, ptr %73, align 4, !tbaa !29
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %"struct.muli::Transform", ptr %74, i32 0, i32 0
  %76 = getelementptr inbounds %"struct.muli::Vec2", ptr %75, i32 0, i32 1
  %77 = load float, ptr %76, align 4, !tbaa !30
  %78 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 3
  %79 = getelementptr inbounds %"struct.muli::Vec4", ptr %78, i32 0, i32 1
  store float %77, ptr %79, align 4, !tbaa !31
  %80 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 3
  %81 = getelementptr inbounds %"struct.muli::Vec4", ptr %80, i32 0, i32 2
  store float 0.000000e+00, ptr %81, align 4, !tbaa !32
  %82 = getelementptr inbounds %"struct.muli::Mat4", ptr %12, i32 0, i32 3
  %83 = getelementptr inbounds %"struct.muli::Vec4", ptr %82, i32 0, i32 3
  store float 1.000000e+00, ptr %83, align 4, !tbaa !33
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN4muli4Mat4E", !13, i64 0, !13, i64 16, !13, i64 32, !13, i64 48}
!13 = !{!"_ZTSN4muli4Vec4E", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!14 = !{!12, !10, i64 4}
!15 = !{!12, !10, i64 8}
!16 = !{!12, !10, i64 12}
!17 = !{!12, !10, i64 16}
!18 = !{!12, !10, i64 20}
!19 = !{!12, !10, i64 24}
!20 = !{!12, !10, i64 28}
!21 = !{!12, !10, i64 32}
!22 = !{!12, !10, i64 36}
!23 = !{!12, !10, i64 40}
!24 = !{!12, !10, i64 44}
!25 = !{!26, !10, i64 0}
!26 = !{!"_ZTSN4muli9TransformE", !27, i64 0, !28, i64 8}
!27 = !{!"_ZTSN4muli4Vec2E", !10, i64 0, !10, i64 4}
!28 = !{!"_ZTSN4muli8RotationE", !10, i64 0, !10, i64 4}
!29 = !{!12, !10, i64 48}
!30 = !{!26, !10, i64 4}
!31 = !{!12, !10, i64 52}
!32 = !{!12, !10, i64 56}
!33 = !{!12, !10, i64 60}


; 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 nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4muli4Mat4C2ERKNS_9TransformE(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(64) %0, ptr noundef nonnull align 4 dereferenceable(16) %1) unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = tail call noundef float @_ZNK4muli8Rotation8GetAngleEv(ptr noundef nonnull align 4 dereferenceable(8) %3)
  %5 = tail call float @sinf(float noundef %4) #3
  %6 = tail call float @cosf(float noundef %4) #3
  store float %6, ptr %0, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  %8 = fmul float %5, 0.000000e+00
  %9 = insertelement <2 x float> poison, float %6, i64 0
  %10 = shufflevector <2 x float> %9, <2 x float> poison, <2 x i32> zeroinitializer
  %11 = insertelement <2 x float> poison, float %5, i64 0
  %12 = insertelement <2 x float> %11, float %8, i64 1
  %13 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %10, <2 x float> <float 0.000000e+00, float -0.000000e+00>, <2 x float> %12)
  store <2 x float> %13, ptr %7, align 4, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  store float 0.000000e+00, ptr %14, align 4, !tbaa !12
  %15 = fneg float %5
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  store float %15, ptr %16, align 4, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %0, i64 20
  %18 = fmul float %6, 0.000000e+00
  %19 = shufflevector <2 x float> %11, <2 x float> poison, <2 x i32> zeroinitializer
  %20 = insertelement <2 x float> %9, float %18, i64 1
  %21 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %19, <2 x float> <float -0.000000e+00, float 0.000000e+00>, <2 x float> %20)
  store <2 x float> %21, ptr %17, align 4, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %0, i64 28
  store <4 x float> <float 0.000000e+00, float 0.000000e+00, float -0.000000e+00, float 1.000000e+00>, ptr %22, align 4, !tbaa !11
  %23 = getelementptr inbounds i8, ptr %0, i64 44
  store float 0.000000e+00, ptr %23, align 4, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %0, i64 48
  %25 = load <2 x float>, ptr %1, align 4, !tbaa !11
  store <2 x float> %25, ptr %24, align 4, !tbaa !11
  %26 = getelementptr inbounds i8, ptr %0, i64 56
  store <2 x float> <float 0.000000e+00, float 1.000000e+00>, ptr %26, align 4, !tbaa !11
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK4muli8Rotation8GetAngleEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #2

attributes #0 = { 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 #1 = { 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 #2 = { 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, !8, i64 0}
!6 = !{!"_ZTSN4muli4Mat4E", !7, i64 0, !7, i64 16, !7, i64 32, !7, i64 48}
!7 = !{!"_ZTSN4muli4Vec4E", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!8, !8, i64 0}
!12 = !{!6, !8, i64 12}
!13 = !{!6, !8, i64 16}
!14 = !{!6, !8, i64 44}


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