; LLVM IR from heroseh/cgm :: cgm (CgmMat3x2_mul)

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

%union.CgmVec2 = type { %struct.anon }
%struct.anon = type { float, float }

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local void @CgmMat3x2_mul(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %union.CgmVec2, align 4
  %8 = alloca %union.CgmVec2, align 4
  %9 = alloca %union.CgmVec2, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds [3 x %union.CgmVec2], ptr %10, i64 0, i64 0
  %12 = getelementptr inbounds %struct.anon, ptr %7, i32 0, i32 0
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds [3 x %union.CgmVec2], ptr %13, i64 0, i64 0
  %15 = getelementptr inbounds %struct.anon, ptr %14, i32 0, i32 0
  %16 = load float, ptr %15, align 4, !tbaa !9
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds [3 x %union.CgmVec2], ptr %17, i64 0, i64 0
  %19 = getelementptr inbounds %struct.anon, ptr %18, i32 0, i32 0
  %20 = load float, ptr %19, align 4, !tbaa !9
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds [3 x %union.CgmVec2], ptr %21, i64 0, i64 0
  %23 = getelementptr inbounds %struct.anon, ptr %22, i32 0, i32 1
  %24 = load float, ptr %23, align 4, !tbaa !9
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds [3 x %union.CgmVec2], ptr %25, i64 0, i64 1
  %27 = getelementptr inbounds %struct.anon, ptr %26, i32 0, i32 0
  %28 = load float, ptr %27, align 4, !tbaa !9
  %29 = fmul float %24, %28
  %30 = call float @llvm.fmuladd.f32(float %16, float %20, float %29)
  store float %30, ptr %12, align 4, !tbaa !10
  %31 = getelementptr inbounds %struct.anon, ptr %7, i32 0, i32 1
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds [3 x %union.CgmVec2], ptr %32, i64 0, i64 0
  %34 = getelementptr inbounds %struct.anon, ptr %33, i32 0, i32 0
  %35 = load float, ptr %34, align 4, !tbaa !9
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds [3 x %union.CgmVec2], ptr %36, i64 0, i64 0
  %38 = getelementptr inbounds %struct.anon, ptr %37, i32 0, i32 1
  %39 = load float, ptr %38, align 4, !tbaa !9
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds [3 x %union.CgmVec2], ptr %40, i64 0, i64 0
  %42 = getelementptr inbounds %struct.anon, ptr %41, i32 0, i32 1
  %43 = load float, ptr %42, align 4, !tbaa !9
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds [3 x %union.CgmVec2], ptr %44, i64 0, i64 1
  %46 = getelementptr inbounds %struct.anon, ptr %45, i32 0, i32 1
  %47 = load float, ptr %46, align 4, !tbaa !9
  %48 = fmul float %43, %47
  %49 = call float @llvm.fmuladd.f32(float %35, float %39, float %48)
  store float %49, ptr %31, align 4, !tbaa !13
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !14
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds [3 x %union.CgmVec2], ptr %50, i64 0, i64 1
  %52 = getelementptr inbounds %struct.anon, ptr %8, i32 0, i32 0
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds [3 x %union.CgmVec2], ptr %53, i64 0, i64 1
  %55 = getelementptr inbounds %struct.anon, ptr %54, i32 0, i32 0
  %56 = load float, ptr %55, align 4, !tbaa !9
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds [3 x %union.CgmVec2], ptr %57, i64 0, i64 0
  %59 = getelementptr inbounds %struct.anon, ptr %58, i32 0, i32 0
  %60 = load float, ptr %59, align 4, !tbaa !9
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds [3 x %union.CgmVec2], ptr %61, i64 0, i64 1
  %63 = getelementptr inbounds %struct.anon, ptr %62, i32 0, i32 1
  %64 = load float, ptr %63, align 4, !tbaa !9
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds [3 x %union.CgmVec2], ptr %65, i64 0, i64 1
  %67 = getelementptr inbounds %struct.anon, ptr %66, i32 0, i32 0
  %68 = load float, ptr %67, align 4, !tbaa !9
  %69 = fmul float %64, %68
  %70 = call float @llvm.fmuladd.f32(float %56, float %60, float %69)
  store float %70, ptr %52, align 4, !tbaa !10
  %71 = getelementptr inbounds %struct.anon, ptr %8, i32 0, i32 1
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds [3 x %union.CgmVec2], ptr %72, i64 0, i64 1
  %74 = getelementptr inbounds %struct.anon, ptr %73, i32 0, i32 0
  %75 = load float, ptr %74, align 4, !tbaa !9
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds [3 x %union.CgmVec2], ptr %76, i64 0, i64 0
  %78 = getelementptr inbounds %struct.anon, ptr %77, i32 0, i32 1
  %79 = load float, ptr %78, align 4, !tbaa !9
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds [3 x %union.CgmVec2], ptr %80, i64 0, i64 1
  %82 = getelementptr inbounds %struct.anon, ptr %81, i32 0, i32 1
  %83 = load float, ptr %82, align 4, !tbaa !9
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds [3 x %union.CgmVec2], ptr %84, i64 0, i64 1
  %86 = getelementptr inbounds %struct.anon, ptr %85, i32 0, i32 1
  %87 = load float, ptr %86, align 4, !tbaa !9
  %88 = fmul float %83, %87
  %89 = call float @llvm.fmuladd.f32(float %75, float %79, float %88)
  store float %89, ptr %71, align 4, !tbaa !13
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %51, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !14
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds [3 x %union.CgmVec2], ptr %90, i64 0, i64 2
  %92 = getelementptr inbounds %struct.anon, ptr %9, i32 0, i32 0
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds [3 x %union.CgmVec2], ptr %93, i64 0, i64 2
  %95 = getelementptr inbounds %struct.anon, ptr %94, i32 0, i32 0
  %96 = load float, ptr %95, align 4, !tbaa !9
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = getelementptr inbounds [3 x %union.CgmVec2], ptr %97, i64 0, i64 0
  %99 = getelementptr inbounds %struct.anon, ptr %98, i32 0, i32 0
  %100 = load float, ptr %99, align 4, !tbaa !9
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds [3 x %union.CgmVec2], ptr %101, i64 0, i64 2
  %103 = getelementptr inbounds %struct.anon, ptr %102, i32 0, i32 1
  %104 = load float, ptr %103, align 4, !tbaa !9
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  %106 = getelementptr inbounds [3 x %union.CgmVec2], ptr %105, i64 0, i64 1
  %107 = getelementptr inbounds %struct.anon, ptr %106, i32 0, i32 0
  %108 = load float, ptr %107, align 4, !tbaa !9
  %109 = fmul float %104, %108
  %110 = call float @llvm.fmuladd.f32(float %96, float %100, float %109)
  %111 = load ptr, ptr %6, align 8, !tbaa !5
  %112 = getelementptr inbounds [3 x %union.CgmVec2], ptr %111, i64 0, i64 2
  %113 = getelementptr inbounds %struct.anon, ptr %112, i32 0, i32 0
  %114 = load float, ptr %113, align 4, !tbaa !9
  %115 = fadd float %110, %114
  store float %115, ptr %92, align 4, !tbaa !10
  %116 = getelementptr inbounds %struct.anon, ptr %9, i32 0, i32 1
  %117 = load ptr, ptr %5, align 8, !tbaa !5
  %118 = getelementptr inbounds [3 x %union.CgmVec2], ptr %117, i64 0, i64 2
  %119 = getelementptr inbounds %struct.anon, ptr %118, i32 0, i32 0
  %120 = load float, ptr %119, align 4, !tbaa !9
  %121 = load ptr, ptr %6, align 8, !tbaa !5
  %122 = getelementptr inbounds [3 x %union.CgmVec2], ptr %121, i64 0, i64 0
  %123 = getelementptr inbounds %struct.anon, ptr %122, i32 0, i32 1
  %124 = load float, ptr %123, align 4, !tbaa !9
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = getelementptr inbounds [3 x %union.CgmVec2], ptr %125, i64 0, i64 2
  %127 = getelementptr inbounds %struct.anon, ptr %126, i32 0, i32 1
  %128 = load float, ptr %127, align 4, !tbaa !9
  %129 = load ptr, ptr %6, align 8, !tbaa !5
  %130 = getelementptr inbounds [3 x %union.CgmVec2], ptr %129, i64 0, i64 1
  %131 = getelementptr inbounds %struct.anon, ptr %130, i32 0, i32 1
  %132 = load float, ptr %131, align 4, !tbaa !9
  %133 = fmul float %128, %132
  %134 = call float @llvm.fmuladd.f32(float %120, float %124, float %133)
  %135 = load ptr, ptr %6, align 8, !tbaa !5
  %136 = getelementptr inbounds [3 x %union.CgmVec2], ptr %135, i64 0, i64 2
  %137 = getelementptr inbounds %struct.anon, ptr %136, i32 0, i32 1
  %138 = load float, ptr %137, align 4, !tbaa !9
  %139 = fadd float %134, %138
  store float %139, ptr %116, align 4, !tbaa !13
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %91, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !14
  ret void
}

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

!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/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 0}
!11 = !{!"", !12, i64 0, !12, i64 4}
!12 = !{!"float", !7, i64 0}
!13 = !{!11, !12, i64 4}
!14 = !{i64 0, i64 8, !9}


; 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 norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @CgmMat3x2_mul(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = load float, ptr %1, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = load float, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  %8 = load <2 x float>, ptr %2, align 4, !tbaa !5
  %9 = load <2 x float>, ptr %7, align 4, !tbaa !5
  %10 = insertelement <2 x float> poison, float %6, i64 0
  %11 = shufflevector <2 x float> %10, <2 x float> poison, <2 x i32> zeroinitializer
  %12 = fmul <2 x float> %11, %9
  %13 = insertelement <2 x float> poison, float %4, i64 0
  %14 = shufflevector <2 x float> %13, <2 x float> poison, <2 x i32> zeroinitializer
  %15 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %14, <2 x float> %8, <2 x float> %12)
  store <2 x float> %15, ptr %0, align 4
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = getelementptr inbounds i8, ptr %1, i64 8
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 12
  %20 = load float, ptr %19, align 4, !tbaa !5
  %21 = load <2 x float>, ptr %2, align 4, !tbaa !5
  %22 = load <2 x float>, ptr %7, align 4, !tbaa !5
  %23 = insertelement <2 x float> poison, float %20, i64 0
  %24 = shufflevector <2 x float> %23, <2 x float> poison, <2 x i32> zeroinitializer
  %25 = fmul <2 x float> %24, %22
  %26 = insertelement <2 x float> poison, float %18, i64 0
  %27 = shufflevector <2 x float> %26, <2 x float> poison, <2 x i32> zeroinitializer
  %28 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %27, <2 x float> %21, <2 x float> %25)
  store <2 x float> %28, ptr %16, align 4
  %29 = getelementptr inbounds i8, ptr %0, i64 16
  %30 = getelementptr inbounds i8, ptr %1, i64 16
  %31 = load float, ptr %30, align 4, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %1, i64 20
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %2, i64 16
  %35 = load <2 x float>, ptr %2, align 4, !tbaa !5
  %36 = load <2 x float>, ptr %7, align 4, !tbaa !5
  %37 = insertelement <2 x float> poison, float %33, i64 0
  %38 = shufflevector <2 x float> %37, <2 x float> poison, <2 x i32> zeroinitializer
  %39 = fmul <2 x float> %38, %36
  %40 = insertelement <2 x float> poison, float %31, i64 0
  %41 = shufflevector <2 x float> %40, <2 x float> poison, <2 x i32> zeroinitializer
  %42 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %41, <2 x float> %35, <2 x float> %39)
  %43 = load <2 x float>, ptr %34, align 4, !tbaa !5
  %44 = fadd <2 x float> %43, %42
  store <2 x float> %44, ptr %29, align 4
  ret void
}

; 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>) #1

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


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