//! Generated from basque.sbl by Snowball 3.0.0 - https://snowballstem.org/

#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(unused_mut)]
#![allow(unused_parens)]
#![allow(unused_variables)]
use crate::snowball::Among;
use crate::snowball::SnowballEnv;

#[derive(Clone)]
struct Context {
    i_p2: i32,
    i_p1: i32,
    i_pV: i32,
}

static A_0: &'static [Among<Context>; 109] = &[
    Among("idea", -1, 1, None),
    Among("bidea", 0, 1, None),
    Among("kidea", 0, 1, None),
    Among("pidea", 0, 1, None),
    Among("kundea", -1, 1, None),
    Among("galea", -1, 1, None),
    Among("tailea", -1, 1, None),
    Among("tzailea", -1, 1, None),
    Among("gunea", -1, 1, None),
    Among("kunea", -1, 1, None),
    Among("tzaga", -1, 1, None),
    Among("gaia", -1, 1, None),
    Among("aldia", -1, 1, None),
    Among("taldia", 12, 1, None),
    Among("karia", -1, 1, None),
    Among("garria", -1, 2, None),
    Among("karria", -1, 1, None),
    Among("ka", -1, 1, None),
    Among("tzaka", 17, 1, None),
    Among("la", -1, 1, None),
    Among("mena", -1, 1, None),
    Among("pena", -1, 1, None),
    Among("kina", -1, 1, None),
    Among("ezina", -1, 1, None),
    Among("tezina", 23, 1, None),
    Among("kuna", -1, 1, None),
    Among("tuna", -1, 1, None),
    Among("kizuna", -1, 1, None),
    Among("era", -1, 1, None),
    Among("bera", 28, 1, None),
    Among("arabera", 29, -1, None),
    Among("kera", 28, 1, None),
    Among("pera", 28, 1, None),
    Among("orra", -1, 1, None),
    Among("korra", 33, 1, None),
    Among("dura", -1, 1, None),
    Among("gura", -1, 1, None),
    Among("kura", -1, 1, None),
    Among("tura", -1, 1, None),
    Among("eta", -1, 1, None),
    Among("keta", 39, 1, None),
    Among("gailua", -1, 1, None),
    Among("eza", -1, 1, None),
    Among("erreza", 42, 1, None),
    Among("tza", -1, 2, None),
    Among("gaitza", 44, 1, None),
    Among("kaitza", 44, 1, None),
    Among("kuntza", 44, 1, None),
    Among("ide", -1, 1, None),
    Among("bide", 48, 1, None),
    Among("kide", 48, 1, None),
    Among("pide", 48, 1, None),
    Among("kunde", -1, 1, None),
    Among("tzake", -1, 1, None),
    Among("tzeke", -1, 1, None),
    Among("le", -1, 1, None),
    Among("gale", 55, 1, None),
    Among("taile", 55, 1, None),
    Among("tzaile", 55, 1, None),
    Among("gune", -1, 1, None),
    Among("kune", -1, 1, None),
    Among("tze", -1, 1, None),
    Among("atze", 61, 1, None),
    Among("gai", -1, 1, None),
    Among("aldi", -1, 1, None),
    Among("taldi", 64, 1, None),
    Among("ki", -1, 1, None),
    Among("ari", -1, 1, None),
    Among("kari", 67, 1, None),
    Among("lari", 67, 1, None),
    Among("tari", 67, 1, None),
    Among("etari", 70, 1, None),
    Among("garri", -1, 2, None),
    Among("karri", -1, 1, None),
    Among("arazi", -1, 1, None),
    Among("tarazi", 74, 1, None),
    Among("an", -1, 1, None),
    Among("ean", 76, 1, None),
    Among("rean", 77, 1, None),
    Among("kan", 76, 1, None),
    Among("etan", 76, 1, None),
    Among("atseden", -1, -1, None),
    Among("men", -1, 1, None),
    Among("pen", -1, 1, None),
    Among("kin", -1, 1, None),
    Among("rekin", 84, 1, None),
    Among("ezin", -1, 1, None),
    Among("tezin", 86, 1, None),
    Among("tun", -1, 1, None),
    Among("kizun", -1, 1, None),
    Among("go", -1, 1, None),
    Among("ago", 90, 1, None),
    Among("tio", -1, 1, None),
    Among("dako", -1, 1, None),
    Among("or", -1, 1, None),
    Among("kor", 94, 1, None),
    Among("tzat", -1, 1, None),
    Among("du", -1, 1, None),
    Among("gailu", -1, 1, None),
    Among("tu", -1, 1, None),
    Among("atu", 99, 1, None),
    Among("aldatu", 100, 1, None),
    Among("tatu", 100, 1, None),
    Among("baditu", 99, -1, None),
    Among("ez", -1, 1, None),
    Among("errez", 104, 1, None),
    Among("tzez", 104, 1, None),
    Among("gaitz", -1, 1, None),
    Among("kaitz", -1, 1, None),
];

static A_1: &'static [Among<Context>; 295] = &[
    Among("ada", -1, 1, None),
    Among("kada", 0, 1, None),
    Among("anda", -1, 1, None),
    Among("denda", -1, 1, None),
    Among("gabea", -1, 1, None),
    Among("kabea", -1, 1, None),
    Among("aldea", -1, 1, None),
    Among("kaldea", 6, 1, None),
    Among("taldea", 6, 1, None),
    Among("ordea", -1, 1, None),
    Among("zalea", -1, 1, None),
    Among("tzalea", 10, 1, None),
    Among("gilea", -1, 1, None),
    Among("emea", -1, 1, None),
    Among("kumea", -1, 1, None),
    Among("nea", -1, 1, None),
    Among("enea", 15, 1, None),
    Among("zionea", 15, 1, None),
    Among("unea", 15, 1, None),
    Among("gunea", 18, 1, None),
    Among("pea", -1, 1, None),
    Among("aurrea", -1, 1, None),
    Among("tea", -1, 1, None),
    Among("kotea", 22, 1, None),
    Among("artea", 22, 1, None),
    Among("ostea", 22, 1, None),
    Among("etxea", -1, 1, None),
    Among("ga", -1, 1, None),
    Among("anga", 27, 1, None),
    Among("gaia", -1, 1, None),
    Among("aldia", -1, 1, None),
    Among("taldia", 30, 1, None),
    Among("handia", -1, 1, None),
    Among("mendia", -1, 1, None),
    Among("geia", -1, 1, None),
    Among("egia", -1, 1, None),
    Among("degia", 35, 1, None),
    Among("tegia", 35, 1, None),
    Among("nahia", -1, 1, None),
    Among("ohia", -1, 1, None),
    Among("kia", -1, 1, None),
    Among("tokia", 40, 1, None),
    Among("oia", -1, 1, None),
    Among("koia", 42, 1, None),
    Among("aria", -1, 1, None),
    Among("karia", 44, 1, None),
    Among("laria", 44, 1, None),
    Among("taria", 44, 1, None),
    Among("eria", -1, 1, None),
    Among("keria", 48, 1, None),
    Among("teria", 48, 1, None),
    Among("garria", -1, 2, None),
    Among("larria", -1, 1, None),
    Among("kirria", -1, 1, None),
    Among("duria", -1, 1, None),
    Among("asia", -1, 1, None),
    Among("tia", -1, 1, None),
    Among("ezia", -1, 1, None),
    Among("bizia", -1, 1, None),
    Among("ontzia", -1, 1, None),
    Among("ka", -1, 1, None),
    Among("joka", 60, 3, None),
    Among("aurka", 60, -1, None),
    Among("ska", 60, 1, None),
    Among("xka", 60, 1, None),
    Among("zka", 60, 1, None),
    Among("gibela", -1, 1, None),
    Among("gela", -1, 1, None),
    Among("kaila", -1, 1, None),
    Among("skila", -1, 1, None),
    Among("tila", -1, 1, None),
    Among("ola", -1, 1, None),
    Among("na", -1, 1, None),
    Among("kana", 72, 1, None),
    Among("ena", 72, 1, None),
    Among("garrena", 74, 1, None),
    Among("gerrena", 74, 1, None),
    Among("urrena", 74, 1, None),
    Among("zaina", 72, 1, None),
    Among("tzaina", 78, 1, None),
    Among("kina", 72, 1, None),
    Among("mina", 72, 1, None),
    Among("garna", 72, 1, None),
    Among("una", 72, 1, None),
    Among("duna", 83, 1, None),
    Among("asuna", 83, 1, None),
    Among("tasuna", 85, 1, None),
    Among("ondoa", -1, 1, None),
    Among("kondoa", 87, 1, None),
    Among("ngoa", -1, 1, None),
    Among("zioa", -1, 1, None),
    Among("koa", -1, 1, None),
    Among("takoa", 91, 1, None),
    Among("zkoa", 91, 1, None),
    Among("noa", -1, 1, None),
    Among("zinoa", 94, 1, None),
    Among("aroa", -1, 1, None),
    Among("taroa", 96, 1, None),
    Among("zaroa", 96, 1, None),
    Among("eroa", -1, 1, None),
    Among("oroa", -1, 1, None),
    Among("osoa", -1, 1, None),
    Among("toa", -1, 1, None),
    Among("ttoa", 102, 1, None),
    Among("ztoa", 102, 1, None),
    Among("txoa", -1, 1, None),
    Among("tzoa", -1, 1, None),
    Among("ñoa", -1, 1, None),
    Among("ra", -1, 1, None),
    Among("ara", 108, 1, None),
    Among("dara", 109, 1, None),
    Among("liara", 109, 1, None),
    Among("tiara", 109, 1, None),
    Among("tara", 109, 1, None),
    Among("etara", 113, 1, None),
    Among("tzara", 109, 1, None),
    Among("bera", 108, 1, None),
    Among("kera", 108, 1, None),
    Among("pera", 108, 1, None),
    Among("ora", 108, 2, None),
    Among("tzarra", 108, 1, None),
    Among("korra", 108, 1, None),
    Among("tra", 108, 1, None),
    Among("sa", -1, 1, None),
    Among("osa", 123, 1, None),
    Among("ta", -1, 1, None),
    Among("eta", 125, 1, None),
    Among("keta", 126, 1, None),
    Among("sta", 125, 1, None),
    Among("dua", -1, 1, None),
    Among("mendua", 129, 1, None),
    Among("ordua", 129, 1, None),
    Among("lekua", -1, 1, None),
    Among("burua", -1, 1, None),
    Among("durua", -1, 1, None),
    Among("tsua", -1, 1, None),
    Among("tua", -1, 1, None),
    Among("mentua", 136, 1, None),
    Among("estua", 136, 1, None),
    Among("txua", -1, 1, None),
    Among("zua", -1, 1, None),
    Among("tzua", 140, 1, None),
    Among("za", -1, 1, None),
    Among("eza", 142, 1, None),
    Among("eroza", 142, 1, None),
    Among("tza", 142, 2, None),
    Among("koitza", 145, 1, None),
    Among("antza", 145, 1, None),
    Among("gintza", 145, 1, None),
    Among("kintza", 145, 1, None),
    Among("kuntza", 145, 1, None),
    Among("gabe", -1, 1, None),
    Among("kabe", -1, 1, None),
    Among("kide", -1, 1, None),
    Among("alde", -1, 1, None),
    Among("kalde", 154, 1, None),
    Among("talde", 154, 1, None),
    Among("orde", -1, 1, None),
    Among("ge", -1, 1, None),
    Among("zale", -1, 1, None),
    Among("tzale", 159, 1, None),
    Among("gile", -1, 1, None),
    Among("eme", -1, 1, None),
    Among("kume", -1, 1, None),
    Among("ne", -1, 1, None),
    Among("zione", 164, 1, None),
    Among("une", 164, 1, None),
    Among("gune", 166, 1, None),
    Among("pe", -1, 1, None),
    Among("aurre", -1, 1, None),
    Among("te", -1, 1, None),
    Among("kote", 170, 1, None),
    Among("arte", 170, 1, None),
    Among("oste", 170, 1, None),
    Among("etxe", -1, 1, None),
    Among("gai", -1, 1, None),
    Among("di", -1, 1, None),
    Among("aldi", 176, 1, None),
    Among("taldi", 177, 1, None),
    Among("geldi", 176, -1, None),
    Among("handi", 176, 1, None),
    Among("mendi", 176, 1, None),
    Among("gei", -1, 1, None),
    Among("egi", -1, 1, None),
    Among("degi", 183, 1, None),
    Among("tegi", 183, 1, None),
    Among("nahi", -1, 1, None),
    Among("ohi", -1, 1, None),
    Among("ki", -1, 1, None),
    Among("toki", 188, 1, None),
    Among("oi", -1, 1, None),
    Among("goi", 190, 1, None),
    Among("koi", 190, 1, None),
    Among("ari", -1, 1, None),
    Among("kari", 193, 1, None),
    Among("lari", 193, 1, None),
    Among("tari", 193, 1, None),
    Among("garri", -1, 2, None),
    Among("larri", -1, 1, None),
    Among("kirri", -1, 1, None),
    Among("duri", -1, 1, None),
    Among("asi", -1, 1, None),
    Among("ti", -1, 1, None),
    Among("ontzi", -1, 1, None),
    Among("ñi", -1, 1, None),
    Among("ak", -1, 1, None),
    Among("ek", -1, 1, None),
    Among("tarik", -1, 1, None),
    Among("gibel", -1, 1, None),
    Among("ail", -1, 1, None),
    Among("kail", 209, 1, None),
    Among("kan", -1, 1, None),
    Among("tan", -1, 1, None),
    Among("etan", 212, 1, None),
    Among("en", -1, 4, None),
    Among("ren", 214, 2, None),
    Among("garren", 215, 1, None),
    Among("gerren", 215, 1, None),
    Among("urren", 215, 1, None),
    Among("ten", 214, 4, None),
    Among("tzen", 214, 4, None),
    Among("zain", -1, 1, None),
    Among("tzain", 221, 1, None),
    Among("kin", -1, 1, None),
    Among("min", -1, 1, None),
    Among("dun", -1, 1, None),
    Among("asun", -1, 1, None),
    Among("tasun", 226, 1, None),
    Among("aizun", -1, 1, None),
    Among("ondo", -1, 1, None),
    Among("kondo", 229, 1, None),
    Among("go", -1, 1, None),
    Among("ngo", 231, 1, None),
    Among("zio", -1, 1, None),
    Among("ko", -1, 1, None),
    Among("trako", 234, 5, None),
    Among("tako", 234, 1, None),
    Among("etako", 236, 1, None),
    Among("eko", 234, 1, None),
    Among("tariko", 234, 1, None),
    Among("sko", 234, 1, None),
    Among("tuko", 234, 1, None),
    Among("minutuko", 241, 6, None),
    Among("zko", 234, 1, None),
    Among("no", -1, 1, None),
    Among("zino", 244, 1, None),
    Among("ro", -1, 1, None),
    Among("aro", 246, 1, None),
    Among("igaro", 247, -1, None),
    Among("taro", 247, 1, None),
    Among("zaro", 247, 1, None),
    Among("ero", 246, 1, None),
    Among("giro", 246, 1, None),
    Among("oro", 246, 1, None),
    Among("oso", -1, 1, None),
    Among("to", -1, 1, None),
    Among("tto", 255, 1, None),
    Among("zto", 255, 1, None),
    Among("txo", -1, 1, None),
    Among("tzo", -1, 1, None),
    Among("gintzo", 259, 1, None),
    Among("ño", -1, 1, None),
    Among("zp", -1, 1, None),
    Among("ar", -1, 1, None),
    Among("dar", 263, 1, None),
    Among("behar", 263, 1, None),
    Among("zehar", 263, -1, None),
    Among("liar", 263, 1, None),
    Among("tiar", 263, 1, None),
    Among("tar", 263, 1, None),
    Among("tzar", 263, 1, None),
    Among("or", -1, 2, None),
    Among("kor", 271, 1, None),
    Among("os", -1, 1, None),
    Among("ket", -1, 1, None),
    Among("du", -1, 1, None),
    Among("mendu", 275, 1, None),
    Among("ordu", 275, 1, None),
    Among("leku", -1, 1, None),
    Among("buru", -1, 2, None),
    Among("duru", -1, 1, None),
    Among("tsu", -1, 1, None),
    Among("tu", -1, 1, None),
    Among("tatu", 282, 4, None),
    Among("mentu", 282, 1, None),
    Among("estu", 282, 1, None),
    Among("txu", -1, 1, None),
    Among("zu", -1, 1, None),
    Among("tzu", 287, 1, None),
    Among("gintzu", 288, 1, None),
    Among("z", -1, 1, None),
    Among("ez", 290, 1, None),
    Among("eroz", 290, 1, None),
    Among("tz", 290, 1, None),
    Among("koitz", 293, 1, None),
];

static A_2: &'static [Among<Context>; 19] = &[
    Among("zlea", -1, 2, None),
    Among("keria", -1, 1, None),
    Among("la", -1, 1, None),
    Among("era", -1, 1, None),
    Among("dade", -1, 1, None),
    Among("tade", -1, 1, None),
    Among("date", -1, 1, None),
    Among("tate", -1, 1, None),
    Among("gi", -1, 1, None),
    Among("ki", -1, 1, None),
    Among("ik", -1, 1, None),
    Among("lanik", 10, 1, None),
    Among("rik", 10, 1, None),
    Among("larik", 12, 1, None),
    Among("ztik", 10, 1, None),
    Among("go", -1, 1, None),
    Among("ro", -1, 1, None),
    Among("ero", 16, 1, None),
    Among("to", -1, 1, None),
];

static G_v: &'static [u8; 3] = &[17, 65, 16];

fn r_mark_regions(env: &mut SnowballEnv, context: &mut Context) -> bool {
    context.i_pV = env.limit;
    context.i_p1 = env.limit;
    context.i_p2 = env.limit;
    let v_1 = env.cursor;
    'lab0: loop {
        'lab1: loop {
            let v_2 = env.cursor;
            'lab2: loop {
                if !env.in_grouping(G_v, 97, 117) {
                    break 'lab2;
                }
                'lab3: loop {
                    let v_3 = env.cursor;
                    'lab4: loop {
                        if !env.out_grouping(G_v, 97, 117) {
                            break 'lab4;
                        }
                        if !env.go_out_grouping(G_v, 97, 117) {
                            break 'lab4;
                        }
                        env.next_char();
                        break 'lab3;
                    }
                    env.cursor = v_3;
                    if !env.in_grouping(G_v, 97, 117) {
                        break 'lab2;
                    }
                    if !env.go_in_grouping(G_v, 97, 117) {
                        break 'lab2;
                    }
                    env.next_char();
                    break 'lab3;
                }
                break 'lab1;
            }
            env.cursor = v_2;
            if !env.out_grouping(G_v, 97, 117) {
                break 'lab0;
            }
            'lab5: loop {
                let v_4 = env.cursor;
                'lab6: loop {
                    if !env.out_grouping(G_v, 97, 117) {
                        break 'lab6;
                    }
                    if !env.go_out_grouping(G_v, 97, 117) {
                        break 'lab6;
                    }
                    env.next_char();
                    break 'lab5;
                }
                env.cursor = v_4;
                if !env.in_grouping(G_v, 97, 117) {
                    break 'lab0;
                }
                if env.cursor >= env.limit {
                    break 'lab0;
                }
                env.next_char();
                break 'lab5;
            }
            break 'lab1;
        }
        context.i_pV = env.cursor;
        break 'lab0;
    }
    env.cursor = v_1;
    let v_5 = env.cursor;
    'lab7: loop {
        if !env.go_out_grouping(G_v, 97, 117) {
            break 'lab7;
        }
        env.next_char();
        if !env.go_in_grouping(G_v, 97, 117) {
            break 'lab7;
        }
        env.next_char();
        context.i_p1 = env.cursor;
        if !env.go_out_grouping(G_v, 97, 117) {
            break 'lab7;
        }
        env.next_char();
        if !env.go_in_grouping(G_v, 97, 117) {
            break 'lab7;
        }
        env.next_char();
        context.i_p2 = env.cursor;
        break 'lab7;
    }
    env.cursor = v_5;
    return true;
}

fn r_RV(env: &mut SnowballEnv, context: &mut Context) -> bool {
    return context.i_pV <= env.cursor;
}

fn r_R2(env: &mut SnowballEnv, context: &mut Context) -> bool {
    return context.i_p2 <= env.cursor;
}

fn r_R1(env: &mut SnowballEnv, context: &mut Context) -> bool {
    return context.i_p1 <= env.cursor;
}

fn r_aditzak(env: &mut SnowballEnv, context: &mut Context) -> bool {
    let mut among_var;
    env.ket = env.cursor;
    if (env.cursor - 1 <= env.limit_backward
        || env.current.as_bytes()[(env.cursor - 1) as usize] as u8 >> 5 != 3 as u8
        || ((70566434 as i32 >> (env.current.as_bytes()[(env.cursor - 1) as usize] as u8 & 0x1f))
            & 1)
            == 0)
    {
        return false;
    }

    among_var = env.find_among_b(A_0, context);
    if among_var == 0 {
        return false;
    }
    env.bra = env.cursor;
    match among_var {
        1 => {
            if !r_RV(env, context) {
                return false;
            }
            env.slice_del();
        }
        2 => {
            if !r_R2(env, context) {
                return false;
            }
            env.slice_del();
        }
        _ => (),
    }
    return true;
}

fn r_izenak(env: &mut SnowballEnv, context: &mut Context) -> bool {
    let mut among_var;
    env.ket = env.cursor;
    if (env.cursor <= env.limit_backward
        || env.current.as_bytes()[(env.cursor - 1) as usize] as u8 >> 5 != 3 as u8
        || ((71162402 as i32 >> (env.current.as_bytes()[(env.cursor - 1) as usize] as u8 & 0x1f))
            & 1)
            == 0)
    {
        return false;
    }

    among_var = env.find_among_b(A_1, context);
    if among_var == 0 {
        return false;
    }
    env.bra = env.cursor;
    match among_var {
        1 => {
            if !r_RV(env, context) {
                return false;
            }
            env.slice_del();
        }
        2 => {
            if !r_R2(env, context) {
                return false;
            }
            env.slice_del();
        }
        3 => {
            env.slice_from("jok");
        }
        4 => {
            if !r_R1(env, context) {
                return false;
            }
            env.slice_del();
        }
        5 => {
            env.slice_from("tra");
        }
        6 => {
            env.slice_from("minutu");
        }
        _ => (),
    }
    return true;
}

fn r_adjetiboak(env: &mut SnowballEnv, context: &mut Context) -> bool {
    let mut among_var;
    env.ket = env.cursor;
    if (env.cursor - 1 <= env.limit_backward
        || env.current.as_bytes()[(env.cursor - 1) as usize] as u8 >> 5 != 3 as u8
        || ((35362 as i32 >> (env.current.as_bytes()[(env.cursor - 1) as usize] as u8 & 0x1f)) & 1)
            == 0)
    {
        return false;
    }

    among_var = env.find_among_b(A_2, context);
    if among_var == 0 {
        return false;
    }
    env.bra = env.cursor;
    match among_var {
        1 => {
            if !r_RV(env, context) {
                return false;
            }
            env.slice_del();
        }
        2 => {
            env.slice_from("z");
        }
        _ => (),
    }
    return true;
}

pub fn stem(env: &mut SnowballEnv) -> bool {
    let mut context = &mut Context {
        i_p2: 0,
        i_p1: 0,
        i_pV: 0,
    };
    r_mark_regions(env, context);
    env.limit_backward = env.cursor;
    env.cursor = env.limit;
    'replab0: loop {
        let v_1 = env.limit - env.cursor;
        'lab1: for _ in 0..1 {
            if !r_aditzak(env, context) {
                break 'lab1;
            }
            continue 'replab0;
        }
        env.cursor = env.limit - v_1;
        break 'replab0;
    }
    'replab2: loop {
        let v_2 = env.limit - env.cursor;
        'lab3: for _ in 0..1 {
            if !r_izenak(env, context) {
                break 'lab3;
            }
            continue 'replab2;
        }
        env.cursor = env.limit - v_2;
        break 'replab2;
    }
    let v_3 = env.limit - env.cursor;
    r_adjetiboak(env, context);
    env.cursor = env.limit - v_3;
    env.cursor = env.limit_backward;
    return true;
}
