/* PBXA64 Release Template bounded-C sample
 * Theme: 09_network_protocols
 * Focus: packet framing, ports, and protocol checksums
 * This is deliberately freestanding: scalar algorithms only, no global data.
 */
static int sample_mix(int value, int salt) {
    int shifted = (value * 17 + salt * 31) % 1000003;
    return shifted ^ (salt * 13);
}

static int sample_series(int start_value, int count) {
    int i = 0;
    int total = 0;
    int current = start_value;
    for (i = 1; i <= count; ++i) {
        current = sample_mix(current, i + 481);
        if ((i % 3) == 0) total += current;
        if ((i % 5) == 0) total ^= current;
    }
    return total + current;
}

static int sample_invariant(int checksum) {
    int normalized = checksum % 97;
    return normalized < 0 ? normalized + 97 : normalized;
}

int main(void) {
    int checksum = sample_series(481, 19);
    checksum += sample_invariant(checksum);
    return checksum == checksum ? 0 : 1;
}
