/* Generated by re2c */
// re2c $INPUT -o $OUTPUT -i
#include <assert.h>
#include <string.h>

#define YYMAXFILL 2




static int lex_simple(const char *str, unsigned int len) {
    const char *YYCURSOR = str, *YYLIMIT = str + len, *YYMARKER;
    
{
	char yych;
	if (YYLIMIT <= YYCURSOR) goto yy8;
	yych = *YYCURSOR;
	switch (yych) {
		case 'a': goto yy3;
		case 'b': goto yy4;
		case 'c': goto yy5;
		default: goto yy1;
	}
yy1:
	++YYCURSOR;
yy2:
	{ return 1; }
yy3:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) goto yy9;
	{ return 3; }
yy4:
	++YYCURSOR;
	{ return 4; }
yy5:
	YYMARKER = ++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) goto yy10;
	yych = *YYCURSOR;
	switch (yych) {
		case 'c': goto yy6;
		default: goto yy2;
	}
yy6:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) goto yy10;
	yych = *YYCURSOR;
	switch (yych) {
		case 'c': goto yy6;
		default: goto yy7;
	}
yy7:
	YYCURSOR = YYMARKER;
	goto yy2;
yy8:
	{ return 0; }
yy9:
	{ return 2; }
yy10:
	{ return 5; }
}

}

static int lex_eof(const char *str, unsigned int len) {
    const char *YYCURSOR = str, *YYLIMIT = str + len, *YYMARKER;
    
{
	char yych;
yyFillLabel0:
	yych = *YYCURSOR;
	switch (yych) {
		case 'a': goto yy14;
		case 'b': goto yy15;
		case 'c': goto yy16;
		default:
			if (YYLIMIT <= YYCURSOR) {
				if (0) goto yyFillLabel0;
				goto yy19;
			}
			goto yy12;
	}
yy12:
	++YYCURSOR;
yy13:
	{ return 1; }
yy14:
	++YYCURSOR;
	if (YYCURSOR == YYLIMIT) goto yy20;
	{ return 3; }
yy15:
	++YYCURSOR;
	{ return 4; }
yy16:
	YYMARKER = ++YYCURSOR;
yyFillLabel1:
	yych = *YYCURSOR;
	switch (yych) {
		case 'c': goto yy17;
		default:
			if (YYLIMIT <= YYCURSOR) {
				if (0) goto yyFillLabel1;
				goto yy21;
			}
			goto yy13;
	}
yy17:
	++YYCURSOR;
yyFillLabel2:
	yych = *YYCURSOR;
	switch (yych) {
		case 'c': goto yy17;
		default:
			if (YYLIMIT <= YYCURSOR) {
				if (0) goto yyFillLabel2;
				goto yy21;
			}
			goto yy18;
	}
yy18:
	YYCURSOR = YYMARKER;
	goto yy13;
yy19:
	{ return 0; }
yy20:
	{ return 2; }
yy21:
	{ return 5; }
}

}

static int lex_scc(const char *str, unsigned int len) {
    static char buf[256];
    char *end = buf + len, *YYCURSOR = buf, *YYLIMIT = end + YYMAXFILL, *YYMARKER;
    memcpy(buf, str, len);
    memset(end, 0, YYMAXFILL);
    
{
	char yych;
	if (YYCURSOR == end) goto yy30;
	if ((YYLIMIT - YYCURSOR) < 2) return -1;
	yych = *YYCURSOR;
	switch (yych) {
		case 'a': goto yy25;
		case 'b': goto yy26;
		case 'c': goto yy27;
		default: goto yy23;
	}
yy23:
	++YYCURSOR;
yy24:
	{ return 1; }
yy25:
	++YYCURSOR;
	if (YYCURSOR == end) goto yy31;
	{ return 3; }
yy26:
	++YYCURSOR;
	{ return 4; }
yy27:
	YYMARKER = ++YYCURSOR;
	if (YYCURSOR == end) goto yy32;
	yych = *YYCURSOR;
	switch (yych) {
		case 'c': goto yy28;
		default: goto yy24;
	}
yy28:
	++YYCURSOR;
	if (YYCURSOR == end) goto yy32;
	if (YYLIMIT <= YYCURSOR) return -1;
	yych = *YYCURSOR;
	switch (yych) {
		case 'c': goto yy28;
		default: goto yy29;
	}
yy29:
	YYCURSOR = YYMARKER;
	goto yy24;
yy30:
	{ return 0; }
yy31:
	{ return 2; }
yy32:
	{ return 5; }
}

}

#define TEST(s, r) do { \
    assert(lex_simple(s, sizeof(s) - 1) == r); \
    assert(lex_eof(s, sizeof(s) - 1) == r); \
    assert(lex_scc(s, sizeof(s) - 1) == r); \
} while (0)

int main() {
    TEST("", 0);
    TEST("a", 2);
    TEST("ax", 3);
    TEST("b", 4);
    TEST("bx", 4);
    TEST("ccc", 5);
    return 0;
}
