// #target: macos-x64

module test;
import std::io;

fn void main()
{
	char a = 123;
	char b = 222;
	io::printfn("%s %s", $$sat_add(a, b), $$sat_add((ichar)a, (ichar)30));
	io::printfn("%s %s", $$sat_sub(a, b), $$sat_sub((ichar)-120, (ichar)10));
	b = 3;
	io::printfn("%s %s", $$sat_shl(a, b), $$sat_shl((ichar)a, (ichar)1));
	b = 222;
	char[<2>] x = { 123, 222 };
	char[<2>] y = { 143, 50 };
	ichar[<2>] z = { 120, -120 };
	ichar[<2>] w = { -44, 30 };
	io::printfn("%s %s", $$sat_add(x, y), $$sat_add(z, z));
	io::printfn("%s %s", $$sat_sub(x, y), $$sat_sub(w, z));
	io::printfn("%s %s", $$sat_shl(x, (char[<2>]) { 1, 1 }), $$sat_shl(z, (ichar[<2>]) { 1, 1 }));
}

/* #expect: test.ll


  call i8 @llvm.uadd.sat.i8
  call i8 @llvm.sadd.sat.i8
  call i8 @llvm.usub.sat.i8
  call i8 @llvm.ssub.sat.i8
  call i8 @llvm.ushl.sat.i8
  call i8 @llvm.sshl.sat.i8
  call <2 x i8> @llvm.uadd.sat.v2i8
  call <2 x i8> @llvm.sadd.sat.v2i8
  call <2 x i8> @llvm.usub.sat.v2i8
  call <2 x i8> @llvm.ssub.sat.v2i8
  call <2 x i8> @llvm.ushl.sat.v2i8
  call <2 x i8> @llvm.sshl.sat.v2i8
