// Sum the first n elements of a global i16 array.  Exercises the
// `arr[i]` indexed-access pattern that the W65816UnLSR pass converts
// back to `lda <global>, X` after LSR turns it into pointer-walking.
unsigned short globalArr[100];

unsigned short globalArrSum(unsigned short n) {
    unsigned short s = 0;
    for (unsigned short i = 0; i < n; i++) s += globalArr[i];
    return s;
}
