It turns out that xx needs to remain a signed int; otherwise we get a segfault.