// #target: macos-x64

module test;
import std::io;
fn void main()
{
	int x = 222;
	int y = 223;
	long z = 0;
	z = (long)x + y;
	z *= x;
	int g = 0;
	int* gp = &g;
	int[4] a = { 3, 4, 5, 6 };
	int* xa = &a;
	usz asf = 1;
	int aa = 3;
	asm
	{

	  movl x, 4;
	  movl [gp], x;
	  movl x, 1;
	  movl [xa + asf * 4 + 4], x;
	  movl $eax, (23 + x);
	  movl x, $eax;
	  movq [&z], 33;
	  addl aa, 22;
	}
	io::printfn("aa: %d", aa);
	io::printfn("Z: %d", z);
	io::printfn("x: %d", x);
	io::printfn("G was: %d", g);
	foreach(int abc : a) io::printfn("%d", abc);

}

/* #expect: test.ll

  %4 = load ptr, ptr %gp, align 8
  %5 = load ptr, ptr %xa, align 8
  %6 = load i64, ptr %asf, align 8
  %7 = load i32, ptr %x, align 4
  %add3 = add i32 23, %7
  %8 = load i32, ptr %aa, align 4
  %9 = call { i32, i32 } asm sideeffect alignstack "movl $$4, $0\0Amovl $0, ($3)\0Amovl $$1, $0\0Amovl $0, 4($4,$5,4)\0Amovl $6, %eax\0Amovl %eax, $0\0Amovq $$33, $1\0Aaddl $$22, $2\0A", "=&r,=*&m,=r,r,r,r,r,2,~{cc},~{rax},~{flags},~{dirflag},~{fspr}"(ptr elementtype(i64) %z, ptr %4, ptr %5, i64 %6, i32 %add3, i32 %8)
  %10 = extractvalue { i32, i32 } %9, 0
  store i32 %10, ptr %x, align 4
  %11 = extractvalue { i32, i32 } %9, 1
  store i32 %11, ptr %aa, align 4
