// #target: macos-x64
module test;
fn int main()
{
	int[<4>] x = { 1, 2, 3, 4 };
	int[<4>] z = $$matrix_mul(x, x, 2, 2, 2);
	int[<2>] a = { 1, 2 };
	int[<3>] b = { 1, 2, 3 };
	int[<6>] c = $$matrix_mul(a, b, 2, 1, 3);
	c = $$matrix_transpose(c, 2, 3);
	return 0;
}

/* #expect: test.ll

define i32 @main() #0 {
entry:
  %x = alloca <4 x i32>, align 16
  %z = alloca <4 x i32>, align 16
  %a = alloca <2 x i32>, align 8
  %b = alloca <3 x i32>, align 16
  %c = alloca <6 x i32>, align 32
  store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, ptr %x, align 16
  %0 = load <4 x i32>, ptr %x, align 16
  %1 = load <4 x i32>, ptr %x, align 16
  %2 = call <4 x i32> @llvm.matrix.multiply.v4i32.v4i32.v4i32(<4 x i32> %0, <4 x i32> %1, i32 2, i32 2, i32 2)
  store <4 x i32> %2, ptr %z, align 16
  store <2 x i32> <i32 1, i32 2>, ptr %a, align 8
  store <4 x i32> <i32 1, i32 2, i32 3, i32 undef>, ptr %b, align 16
  %3 = load <2 x i32>, ptr %a, align 8
  %4 = load <4 x i32>, ptr %b, align 16
  %extractvec = shufflevector <4 x i32> %4, <4 x i32> poison, <3 x i32> <i32 0, i32 1, i32 2>
  %5 = call <6 x i32> @llvm.matrix.multiply.v6i32.v2i32.v3i32(<2 x i32> %3, <3 x i32> %extractvec, i32 2, i32 1, i32 3)
  %expandvec = shufflevector <6 x i32> %5, <6 x i32> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 poison, i32 poison>
  store <8 x i32> %expandvec, ptr %c, align 32
  %6 = load <8 x i32>, ptr %c, align 32
  %extractvec1 = shufflevector <8 x i32> %6, <8 x i32> poison, <6 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5>
  %7 = call <6 x i32> @llvm.matrix.transpose.v6i32(<6 x i32> %extractvec1, i32 2, i32 3)
  %expandvec2 = shufflevector <6 x i32> %7, <6 x i32> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 poison, i32 poison>
  store <8 x i32> %expandvec2, ptr %c, align 32
  ret i32 0
}