// Test: Using the same mbstate_t with different sequences/directions
// Clause: 7.31.6 — If an mbstate_t altered by one conversion is reused with a different sequence/direction/LC_CTYPE,
// the behavior is undefined.
#include <wchar.h>
#include <stdio.h>
#include <string.h>

int main(void) {
    mbstate_t st = {0};
    const char *s1 = "\xC3\xA9"; // "é" in UTF-8
    wchar_t wc;
    size_t r1 = mbrtowc(&wc, s1, strlen(s1), &st);
    (void)r1;
    // UB: reuse st with a different string without resetting
    const char *s2 = "A";
    size_t r2 = mbrtowc(&wc, s2, strlen(s2), &st);
    printf("%zu\n", r2);
    return 0;
}
