tree_sitter_c2rust_core/
query.rs

1use crate::util::*;
2use crate::*;
3use c2rust_bitfields;
4use std::os;
5pub type __u8 = os::raw::c_uchar;
6pub type __int16_t = os::raw::c_short;
7pub type __u16 = os::raw::c_ushort;
8pub type __int32_t = os::raw::c_int;
9pub type __u32 = os::raw::c_uint;
10pub type int16_t = __int16_t;
11pub type int32_t = __int32_t;
12pub type TSSymbol = u16;
13pub type TSFieldId = u16;
14pub type TSStateId = u16;
15#[derive(Copy, Clone)]
16#[repr(C)]
17pub struct C2RustUnnamed {
18    pub states: *const bool,
19    pub symbol_map: *const TSSymbol,
20    pub create: Option<unsafe extern "C" fn() -> *mut os::raw::c_void>,
21    pub destroy: Option<unsafe extern "C" fn(*mut os::raw::c_void) -> ()>,
22    pub scan: Option<unsafe extern "C" fn(*mut os::raw::c_void, *mut TSLexer, *const bool) -> bool>,
23    pub serialize:
24        Option<unsafe extern "C" fn(*mut os::raw::c_void, *mut os::raw::c_char) -> os::raw::c_uint>,
25    pub deserialize: Option<
26        unsafe extern "C" fn(*mut os::raw::c_void, *const os::raw::c_char, os::raw::c_uint) -> (),
27    >,
28}
29#[derive(Copy, Clone)]
30#[repr(C)]
31pub struct C2RustUnnamed_0 {
32    pub count: u8,
33    pub reusable: bool,
34}
35#[derive(Copy, Clone)]
36#[repr(C)]
37pub struct C2RustUnnamed_1 {
38    pub type_: u8,
39    pub child_count: u8,
40    pub symbol: TSSymbol,
41    pub dynamic_precedence: int16_t,
42    pub production_id: u16,
43}
44#[derive(Copy, Clone)]
45#[repr(C)]
46pub struct C2RustUnnamed_2 {
47    pub type_: u8,
48    pub state: TSStateId,
49    pub extra: bool,
50    pub repetition: bool,
51}
52#[derive(Copy, Clone)]
53#[repr(C)]
54pub struct TSQuery {
55    pub captures: SymbolTable,
56    pub capture_quantifiers: C2RustUnnamed_12,
57    pub predicate_values: SymbolTable,
58    pub steps: C2RustUnnamed_9,
59    pub pattern_map: C2RustUnnamed_8,
60    pub predicate_steps: C2RustUnnamed_7,
61    pub patterns: C2RustUnnamed_6,
62    pub step_offsets: C2RustUnnamed_5,
63    pub negated_fields: C2RustUnnamed_4,
64    pub string_buffer: C2RustUnnamed_3,
65    pub language: *const TSLanguage,
66    pub wildcard_root_pattern_count: u16,
67}
68type C2RustUnnamed_3 = crate::util::StackElement<*mut os::raw::c_char>;
69type C2RustUnnamed_4 = crate::util::StackElement<*mut TSFieldId>;
70type C2RustUnnamed_5 = crate::util::StackElement<*mut StepOffset>;
71#[derive(Copy, Clone)]
72#[repr(C)]
73pub struct StepOffset {
74    pub byte_offset: u32,
75    pub step_index: u16,
76}
77type C2RustUnnamed_6 = crate::util::StackElement<*mut QueryPattern>;
78#[derive(Copy, Clone)]
79#[repr(C)]
80pub struct QueryPattern {
81    pub steps: Slice,
82    pub predicate_steps: Slice,
83    pub start_byte: u32,
84}
85#[derive(Copy, Clone)]
86#[repr(C)]
87pub struct Slice {
88    pub offset: u32,
89    pub length: u32,
90}
91type C2RustUnnamed_7 = crate::util::StackElement<*mut TSQueryPredicateStep>;
92#[derive(Copy, Clone)]
93#[repr(C)]
94pub struct TSQueryPredicateStep {
95    pub type_: TSQueryPredicateStepType,
96    pub value_id: u32,
97}
98pub const TSQueryPredicateStepTypeString: TSQueryPredicateStepType = 2;
99pub const TSQueryPredicateStepTypeCapture: TSQueryPredicateStepType = 1;
100pub const TSQueryPredicateStepTypeDone: TSQueryPredicateStepType = 0;
101type C2RustUnnamed_8 = crate::util::StackElement<*mut PatternEntry>;
102#[derive(Copy, Clone)]
103#[repr(C)]
104pub struct PatternEntry {
105    pub step_index: u16,
106    pub pattern_index: u16,
107    pub is_rooted: bool,
108}
109type C2RustUnnamed_9 = crate::util::StackElement<*mut QueryStep>;
110#[derive(Copy, Clone, BitfieldStruct)]
111#[repr(C)]
112pub struct QueryStep {
113    pub symbol: TSSymbol,
114    pub supertype_symbol: TSSymbol,
115    pub field: TSFieldId,
116    pub capture_ids: [u16; 3],
117    pub depth: u16,
118    pub alternative_index: u16,
119    pub negated_field_list_id: u16,
120    #[bitfield(name = "is_named", ty = "bool", bits = "0..=0")]
121    #[bitfield(name = "is_immediate", ty = "bool", bits = "1..=1")]
122    #[bitfield(name = "is_last_child", ty = "bool", bits = "2..=2")]
123    #[bitfield(name = "is_pass_through", ty = "bool", bits = "3..=3")]
124    #[bitfield(name = "is_dead_end", ty = "bool", bits = "4..=4")]
125    #[bitfield(name = "alternative_is_immediate", ty = "bool", bits = "5..=5")]
126    #[bitfield(name = "contains_captures", ty = "bool", bits = "6..=6")]
127    #[bitfield(name = "root_pattern_guaranteed", ty = "bool", bits = "7..=7")]
128    #[bitfield(name = "parent_pattern_guaranteed", ty = "bool", bits = "8..=8")]
129    pub is_named_is_immediate_is_last_child_is_pass_through_is_dead_end_alternative_is_immediate_contains_captures_root_pattern_guaranteed_parent_pattern_guaranteed:
130        [u8; 2],
131}
132#[derive(Copy, Clone)]
133#[repr(C)]
134pub struct SymbolTable {
135    pub characters: C2RustUnnamed_11,
136    pub slices: C2RustUnnamed_10,
137}
138type C2RustUnnamed_10 = crate::util::StackElement<*mut Slice>;
139type C2RustUnnamed_11 = crate::util::StackElement<*mut os::raw::c_char>;
140type C2RustUnnamed_12 = crate::util::StackElement<*mut CaptureQuantifiers>;
141#[derive(Copy, Clone)]
142#[repr(C)]
143pub struct CaptureQuantifiers {
144    pub contents: *mut u8,
145    pub size: u32,
146    pub capacity: u32,
147}
148#[derive(Copy, Clone)]
149#[repr(C)]
150pub struct TSQueryCursor {
151    pub query: *const TSQuery,
152    pub cursor: TSTreeCursor,
153    pub states: C2RustUnnamed_15,
154    pub finished_states: C2RustUnnamed_14,
155    pub capture_list_pool: CaptureListPool,
156    pub depth: u32,
157    pub start_byte: u32,
158    pub end_byte: u32,
159    pub start_point: TSPoint,
160    pub end_point: TSPoint,
161    pub next_state_id: u32,
162    pub ascending: bool,
163    pub halted: bool,
164    pub did_exceed_match_limit: bool,
165}
166#[derive(Copy, Clone)]
167#[repr(C)]
168pub struct CaptureListPool {
169    pub list: C2RustUnnamed_13,
170    pub empty_list: CaptureList,
171    pub max_capture_list_count: u32,
172    pub free_capture_list_count: u32,
173}
174#[derive(Copy, Clone)]
175#[repr(C)]
176pub struct CaptureList {
177    pub contents: *mut TSQueryCapture,
178    pub size: u32,
179    pub capacity: u32,
180}
181#[derive(Copy, Clone)]
182#[repr(C)]
183pub struct TSQueryCapture {
184    pub node: TSNode,
185    pub index: u32,
186}
187type C2RustUnnamed_13 = crate::util::StackElement<*mut CaptureList>;
188type C2RustUnnamed_14 = crate::util::StackElement<*mut QueryState>;
189#[derive(Copy, Clone, BitfieldStruct)]
190#[repr(C)]
191pub struct QueryState {
192    pub id: u32,
193    pub capture_list_id: u32,
194    pub start_depth: u16,
195    pub step_index: u16,
196    pub pattern_index: u16,
197    #[bitfield(name = "consumed_capture_count", ty = "u16", bits = "0..=11")]
198    #[bitfield(name = "seeking_immediate_match", ty = "bool", bits = "12..=12")]
199    #[bitfield(name = "has_in_progress_alternatives", ty = "bool", bits = "13..=13")]
200    #[bitfield(name = "dead", ty = "bool", bits = "14..=14")]
201    #[bitfield(name = "needs_parent", ty = "bool", bits = "15..=15")]
202    pub consumed_capture_count_seeking_immediate_match_has_in_progress_alternatives_dead_needs_parent:
203        [u8; 2],
204}
205type C2RustUnnamed_15 = crate::util::StackElement<*mut QueryState>;
206pub const TSQuantifierOneOrMore: TSQuantifier = 4;
207pub const TSQuantifierOne: TSQuantifier = 3;
208pub const TSQuantifierZeroOrMore: TSQuantifier = 2;
209pub const TSQuantifierZeroOrOne: TSQuantifier = 1;
210pub const TSQuantifierZero: TSQuantifier = 0;
211#[derive(Copy, Clone)]
212#[repr(C)]
213pub struct TSQueryMatch {
214    pub id: u32,
215    pub pattern_index: u16,
216    pub capture_count: u16,
217    pub captures: *const TSQueryCapture,
218}
219pub const TSQueryErrorLanguage: TSQueryError = 6;
220pub const TSQueryErrorStructure: TSQueryError = 5;
221pub const TSQueryErrorCapture: TSQueryError = 4;
222pub const TSQueryErrorField: TSQueryError = 3;
223pub const TSQueryErrorNodeType: TSQueryError = 2;
224pub const TSQueryErrorSyntax: TSQueryError = 1;
225pub const TSQueryErrorNone: TSQueryError = 0;
226#[derive(Copy, Clone)]
227#[repr(C)]
228pub struct VoidArray {
229    pub contents: *mut os::raw::c_void,
230    pub size: u32,
231    pub capacity: u32,
232}
233#[derive(Copy, Clone)]
234#[repr(C)]
235pub struct StatePredecessorMap {
236    pub contents: *mut TSStateId,
237}
238type C2RustUnnamed_16 = crate::util::StackElement<*mut u16>;
239type C2RustUnnamed_17 = crate::util::StackElement<*mut u32>;
240type C2RustUnnamed_18 = crate::util::StackElement<*mut u16>;
241#[derive(Copy, Clone)]
242#[repr(C)]
243pub struct AnalysisStateSet {
244    pub contents: *mut *mut AnalysisState,
245    pub size: u32,
246    pub capacity: u32,
247}
248#[derive(Copy, Clone)]
249#[repr(C)]
250pub struct AnalysisState {
251    pub stack: [AnalysisStateEntry; 8],
252    pub depth: u16,
253    pub step_index: u16,
254}
255#[derive(Copy, Clone, BitfieldStruct)]
256#[repr(C)]
257pub struct AnalysisStateEntry {
258    pub parse_state: TSStateId,
259    pub parent_symbol: TSSymbol,
260    pub child_index: u16,
261    #[bitfield(name = "field_id", ty = "TSFieldId", bits = "0..=14")]
262    #[bitfield(name = "done", ty = "bool", bits = "15..=15")]
263    pub field_id_done: [u8; 2],
264}
265type C2RustUnnamed_19 = crate::util::StackElement<*mut AnalysisSubgraphNode>;
266#[derive(Copy, Clone, BitfieldStruct)]
267#[repr(C)]
268pub struct AnalysisSubgraphNode {
269    pub state: TSStateId,
270    pub production_id: u16,
271    #[bitfield(name = "child_index", ty = "u8", bits = "0..=6")]
272    #[bitfield(name = "done", ty = "bool", bits = "7..=7")]
273    pub child_index_done: [u8; 1],
274    #[bitfield(padding)]
275    pub c2rust_padding: [u8; 1],
276}
277#[derive(Copy, Clone)]
278#[repr(C)]
279pub struct AnalysisStatePool {
280    pub contents: *mut *mut AnalysisState,
281    pub size: u32,
282    pub capacity: u32,
283}
284type C2RustUnnamed_20 = crate::util::StackElement<*mut AnalysisSubgraph>;
285#[derive(Copy, Clone)]
286#[repr(C)]
287pub struct AnalysisSubgraph {
288    pub symbol: TSSymbol,
289    pub start_states: C2RustUnnamed_22,
290    pub nodes: C2RustUnnamed_21,
291}
292type C2RustUnnamed_21 = crate::util::StackElement<*mut AnalysisSubgraphNode>;
293type C2RustUnnamed_22 = crate::util::StackElement<*mut TSStateId>;
294#[derive(Copy, Clone)]
295#[repr(C)]
296pub struct LookaheadIterator {
297    pub language: *const TSLanguage,
298    pub data: *const u16,
299    pub group_end: *const u16,
300    pub state: TSStateId,
301    pub table_value: u16,
302    pub section_index: u16,
303    pub group_count: u16,
304    pub is_small_state: bool,
305    pub actions: *const TSParseAction,
306    pub symbol: TSSymbol,
307    pub next_state: TSStateId,
308    pub action_count: u16,
309}
310pub const TSParseActionTypeShift: C2RustUnnamed_24 = 0;
311pub const TSParseActionTypeReduce: C2RustUnnamed_24 = 1;
312#[derive(Copy, Clone)]
313#[repr(C)]
314pub struct Stream {
315    pub input: *const os::raw::c_char,
316    pub start: *const os::raw::c_char,
317    pub end: *const os::raw::c_char,
318    pub next: int32_t,
319    pub next_size: u8,
320}
321pub type wint_t = os::raw::c_uint;
322type C2RustUnnamed_23 = crate::util::StackElement<*mut u32>;
323pub type C2RustUnnamed_24 = os::raw::c_uint;
324pub const TSParseActionTypeRecover: C2RustUnnamed_24 = 3;
325pub const TSParseActionTypeAccept: C2RustUnnamed_24 = 2;
326#[inline]
327unsafe extern "C" fn array__reserve(
328    mut self_0: *mut VoidArray,
329    mut element_size: size_t,
330    mut new_capacity: u32,
331) {
332    if new_capacity > (*self_0).capacity {
333        if !((*self_0).contents).is_null() {
334            let ref mut fresh0 = (*self_0).contents;
335            *fresh0 = crate::alloc::ts_realloc(
336                (*self_0).contents,
337                (new_capacity as usize).wrapping_mul(element_size),
338            );
339        } else {
340            let ref mut fresh1 = (*self_0).contents;
341            *fresh1 = crate::alloc::ts_malloc((new_capacity as usize).wrapping_mul(element_size));
342        }
343        (*self_0).capacity = new_capacity;
344    }
345}
346#[inline]
347unsafe extern "C" fn array__splice(
348    mut self_0: *mut VoidArray,
349    mut element_size: size_t,
350    mut index: u32,
351    mut old_count: u32,
352    mut new_count: u32,
353    mut elements: *const os::raw::c_void,
354) {
355    let mut new_size: u32 = ((*self_0).size)
356        .wrapping_add(new_count)
357        .wrapping_sub(old_count);
358    let mut old_end: u32 = index.wrapping_add(old_count);
359    let mut new_end: u32 = index.wrapping_add(new_count);
360    if old_end <= (*self_0).size {
361    } else {
362        panic!();
363    }
364    array__reserve(self_0, element_size, new_size);
365    let mut contents: *mut os::raw::c_char = (*self_0).contents as *mut os::raw::c_char;
366    if (*self_0).size > old_end {
367        std::ptr::copy(
368            contents.offset((old_end as usize).wrapping_mul(element_size) as isize)
369                as *const os::raw::c_void,
370            contents.offset((new_end as usize).wrapping_mul(element_size) as isize)
371                as *mut os::raw::c_void,
372            ((((*self_0).size).wrapping_sub(old_end) as usize).wrapping_mul(element_size)) as usize,
373        );
374    }
375    if new_count > 0 as os::raw::c_int as os::raw::c_uint {
376        if !elements.is_null() {
377            std::ptr::copy_nonoverlapping(
378                elements,
379                contents.offset((index as usize).wrapping_mul(element_size) as isize)
380                    as *mut os::raw::c_void,
381                (new_count as usize).wrapping_mul(element_size),
382            );
383        } else {
384            std::ptr::write_bytes(
385                contents.offset((index as usize).wrapping_mul(element_size) as isize)
386                    as *mut os::raw::c_void,
387                (0 as os::raw::c_int) as u8,
388                ((new_count as usize).wrapping_mul(element_size)) as usize,
389            );
390        }
391    }
392    let ref mut fresh2 = (*self_0).size;
393    *fresh2 =
394        (*fresh2 as os::raw::c_uint).wrapping_add(new_count.wrapping_sub(old_count)) as u32 as u32;
395}
396#[inline]
397unsafe extern "C" fn array__delete(mut self_0: *mut VoidArray) {
398    crate::alloc::ts_free((*self_0).contents);
399    let ref mut fresh3 = (*self_0).contents;
400    *fresh3 = 0 as *mut os::raw::c_void;
401    (*self_0).size = 0 as os::raw::c_int as u32;
402    (*self_0).capacity = 0 as os::raw::c_int as u32;
403}
404#[inline]
405unsafe extern "C" fn array__grow(
406    mut self_0: *mut VoidArray,
407    mut count: size_t,
408    mut element_size: size_t,
409) {
410    let mut new_size: size_t = ((*self_0).size as usize).wrapping_add(count);
411    if new_size > (*self_0).capacity as usize {
412        let mut new_capacity: size_t =
413            ((*self_0).capacity).wrapping_mul(2 as os::raw::c_int as os::raw::c_uint) as size_t;
414        if new_capacity < 8 as os::raw::c_int as usize {
415            new_capacity = 8 as os::raw::c_int as size_t;
416        }
417        if new_capacity < new_size {
418            new_capacity = new_size;
419        }
420        array__reserve(self_0, element_size, new_capacity as u32);
421    }
422}
423#[inline]
424unsafe extern "C" fn array__assign(
425    mut self_0: *mut VoidArray,
426    mut other: *const VoidArray,
427    mut element_size: size_t,
428) {
429    array__reserve(self_0, element_size, (*other).size);
430    (*self_0).size = (*other).size;
431    std::ptr::copy_nonoverlapping(
432        (*other).contents,
433        (*self_0).contents,
434        ((*self_0).size as usize).wrapping_mul(element_size),
435    );
436}
437#[inline]
438unsafe extern "C" fn array__erase(
439    mut self_0: *mut VoidArray,
440    mut element_size: size_t,
441    mut index: u32,
442) {
443    if index < (*self_0).size {
444    } else {
445        panic!();
446    }
447    let mut contents: *mut os::raw::c_char = (*self_0).contents as *mut os::raw::c_char;
448    std::ptr::copy(
449        contents.offset(
450            (index.wrapping_add(1 as os::raw::c_int as os::raw::c_uint) as usize)
451                .wrapping_mul(element_size) as isize,
452        ) as *const os::raw::c_void,
453        contents.offset((index as usize).wrapping_mul(element_size) as isize)
454            as *mut os::raw::c_void,
455        ((((*self_0).size)
456            .wrapping_sub(index)
457            .wrapping_sub(1 as os::raw::c_int as os::raw::c_uint) as usize)
458            .wrapping_mul(element_size)) as usize,
459    );
460    let ref mut fresh4 = (*self_0).size;
461    *fresh4 = (*fresh4).wrapping_sub(1);
462}
463#[inline]
464unsafe extern "C" fn point_lte(mut a: TSPoint, mut b: TSPoint) -> bool {
465    return a.row < b.row || a.row == b.row && a.column <= b.column;
466}
467#[inline]
468unsafe extern "C" fn point_gt(mut a: TSPoint, mut b: TSPoint) -> bool {
469    return a.row > b.row || a.row == b.row && a.column > b.column;
470}
471#[inline]
472unsafe extern "C" fn point_lt(mut a: TSPoint, mut b: TSPoint) -> bool {
473    return a.row < b.row || a.row == b.row && a.column < b.column;
474}
475#[inline]
476unsafe extern "C" fn ts_language_lookaheads(
477    mut self_0: *const TSLanguage,
478    mut state: TSStateId,
479) -> LookaheadIterator {
480    let mut is_small_state: bool = state as os::raw::c_uint >= (*self_0).large_state_count;
481    let mut data: *const u16 = 0 as *const u16;
482    let mut group_end: *const u16 = 0 as *const u16;
483    let mut group_count: u16 = 0 as os::raw::c_int as u16;
484    if is_small_state {
485        let mut index: u32 = *((*self_0).small_parse_table_map)
486            .offset((state as os::raw::c_uint).wrapping_sub((*self_0).large_state_count) as isize);
487        data = &*((*self_0).small_parse_table).offset(index as isize) as *const u16;
488        group_end = data.offset(1 as os::raw::c_int as isize);
489        group_count = *data;
490    } else {
491        data = (&*((*self_0).parse_table)
492            .offset((state as os::raw::c_uint).wrapping_mul((*self_0).symbol_count) as isize)
493            as *const u16)
494            .offset(-(1 as os::raw::c_int as isize));
495    }
496    return {
497        let mut init = LookaheadIterator {
498            language: self_0,
499            data: data,
500            group_end: group_end,
501            state: 0,
502            table_value: 0,
503            section_index: 0,
504            group_count: group_count,
505            is_small_state: is_small_state,
506            actions: 0 as *const TSParseAction,
507            symbol: 65535 as os::raw::c_int as TSSymbol,
508            next_state: 0 as os::raw::c_int as TSStateId,
509            action_count: 0,
510        };
511        init
512    };
513}
514#[inline]
515unsafe extern "C" fn ts_language_alias_at(
516    mut self_0: *const TSLanguage,
517    mut production_id: u32,
518    mut child_index: u32,
519) -> TSSymbol {
520    return (if production_id != 0 {
521        *((*self_0).alias_sequences).offset(
522            production_id
523                .wrapping_mul((*self_0).max_alias_sequence_length as os::raw::c_uint)
524                .wrapping_add(child_index) as isize,
525        ) as os::raw::c_int
526    } else {
527        0 as os::raw::c_int
528    }) as TSSymbol;
529}
530#[inline]
531unsafe extern "C" fn ts_language_field_map(
532    mut self_0: *const TSLanguage,
533    mut production_id: u32,
534    mut start: *mut *const TSFieldMapEntry,
535    mut end: *mut *const TSFieldMapEntry,
536) {
537    if (*self_0).field_count == 0 as os::raw::c_int as os::raw::c_uint {
538        *start = 0 as *const TSFieldMapEntry;
539        *end = 0 as *const TSFieldMapEntry;
540        return;
541    }
542    let mut slice: TSFieldMapSlice = *((*self_0).field_map_slices).offset(production_id as isize);
543    *start = &*((*self_0).field_map_entries).offset(slice.index as isize) as *const TSFieldMapEntry;
544    *end = (&*((*self_0).field_map_entries).offset(slice.index as isize) as *const TSFieldMapEntry)
545        .offset(slice.length as os::raw::c_int as isize);
546}
547#[inline]
548unsafe extern "C" fn ts_lookahead_iterator_next(mut self_0: *mut LookaheadIterator) -> bool {
549    if (*self_0).is_small_state {
550        let ref mut fresh5 = (*self_0).data;
551        *fresh5 = (*fresh5).offset(1);
552        if (*self_0).data == (*self_0).group_end {
553            if (*self_0).group_count as os::raw::c_int == 0 as os::raw::c_int {
554                return false;
555            }
556            let ref mut fresh6 = (*self_0).group_count;
557            *fresh6 = (*fresh6).wrapping_sub(1);
558            let ref mut fresh7 = (*self_0).data;
559            let fresh8 = *fresh7;
560            *fresh7 = (*fresh7).offset(1);
561            (*self_0).table_value = *fresh8;
562            let ref mut fresh9 = (*self_0).data;
563            let fresh10 = *fresh9;
564            *fresh9 = (*fresh9).offset(1);
565            let mut symbol_count: os::raw::c_uint = *fresh10 as os::raw::c_uint;
566            let ref mut fresh11 = (*self_0).group_end;
567            *fresh11 = ((*self_0).data).offset(symbol_count as isize);
568            (*self_0).symbol = *(*self_0).data;
569        } else {
570            (*self_0).symbol = *(*self_0).data;
571            return true;
572        }
573    } else {
574        loop {
575            let ref mut fresh12 = (*self_0).data;
576            *fresh12 = (*fresh12).offset(1);
577            let ref mut fresh13 = (*self_0).symbol;
578            *fresh13 = (*fresh13).wrapping_add(1);
579            if (*self_0).symbol as os::raw::c_uint >= (*(*self_0).language).symbol_count {
580                return false;
581            }
582            (*self_0).table_value = *(*self_0).data;
583            if !((*self_0).table_value == 0) {
584                break;
585            }
586        }
587    }
588    if ((*self_0).symbol as os::raw::c_uint) < (*(*self_0).language).token_count {
589        let mut entry: *const TSParseActionEntry = &*((*(*self_0).language).parse_actions)
590            .offset((*self_0).table_value as isize)
591            as *const TSParseActionEntry;
592        (*self_0).action_count = (*entry).entry.count as u16;
593        let ref mut fresh14 = (*self_0).actions;
594        *fresh14 = entry.offset(1 as os::raw::c_int as isize) as *const TSParseAction;
595        (*self_0).next_state = 0 as os::raw::c_int as TSStateId;
596    } else {
597        (*self_0).action_count = 0 as os::raw::c_int as u16;
598        (*self_0).next_state = (*self_0).table_value;
599    }
600    return true;
601}
602#[inline]
603unsafe extern "C" fn ts_language_aliases_for_symbol(
604    mut self_0: *const TSLanguage,
605    mut original_symbol: TSSymbol,
606    mut start: *mut *const TSSymbol,
607    mut end: *mut *const TSSymbol,
608) {
609    *start = &*((*self_0).public_symbol_map).offset(original_symbol as isize) as *const TSSymbol;
610    *end = (*start).offset(1 as os::raw::c_int as isize);
611    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
612    loop {
613        let fresh15 = i;
614        i = i.wrapping_add(1);
615        let mut symbol: TSSymbol = *((*self_0).alias_map).offset(fresh15 as isize);
616        if symbol as os::raw::c_int == 0 as os::raw::c_int
617            || symbol as os::raw::c_int > original_symbol as os::raw::c_int
618        {
619            break;
620        }
621        let fresh16 = i;
622        i = i.wrapping_add(1);
623        let mut count: u16 = *((*self_0).alias_map).offset(fresh16 as isize);
624        if symbol as os::raw::c_int == original_symbol as os::raw::c_int {
625            *start = &*((*self_0).alias_map).offset(i as isize) as *const u16;
626            *end = &*((*self_0).alias_map).offset(i.wrapping_add(count as os::raw::c_uint) as isize)
627                as *const u16;
628            break;
629        } else {
630            i = i.wrapping_add(count as os::raw::c_uint);
631        }
632    }
633}
634#[inline]
635unsafe extern "C" fn ts_language_state_is_primary(
636    mut self_0: *const TSLanguage,
637    mut state: TSStateId,
638) -> bool {
639    if (*self_0).version >= 14 as os::raw::c_int as os::raw::c_uint {
640        return state as os::raw::c_int
641            == *((*self_0).primary_state_ids).offset(state as isize) as os::raw::c_int;
642    } else {
643        return true;
644    };
645}
646#[inline]
647unsafe extern "C" fn ts_decode_utf8(
648    mut string: *const u8,
649    mut length: u32,
650    mut code_point: *mut int32_t,
651) -> u32 {
652    let mut i: u32 = 0 as os::raw::c_int as u32;
653    let fresh17 = i;
654    i = i.wrapping_add(1);
655    *code_point = *string.offset(fresh17 as isize) as int32_t;
656    if !(*code_point & 0x80 as os::raw::c_int == 0 as os::raw::c_int) {
657        let mut __t: u8 = 0 as os::raw::c_int as u8;
658        if !(i != length
659            && (if *code_point >= 0xe0 as os::raw::c_int {
660                ((if *code_point < 0xf0 as os::raw::c_int {
661                    *code_point &= 0xf as os::raw::c_int;
662                    __t = *string.offset(i as isize);
663                    ((*::std::mem::transmute::<&[u8; 17], &[os::raw::c_char; 17]>(
664                        b" 000000000000\x1000\0",
665                    ))[*code_point as usize] as os::raw::c_int
666                        & (1 as os::raw::c_int) << (__t as os::raw::c_int >> 5 as os::raw::c_int)
667                        != 0
668                        && {
669                            __t = (__t as os::raw::c_int & 0x3f as os::raw::c_int) as u8;
670                            true
671                        }) as os::raw::c_int
672                } else {
673                    *code_point -= 0xf0 as os::raw::c_int;
674                    (*code_point <= 4 as os::raw::c_int
675                        && {
676                            __t = *string.offset(i as isize);
677                            (*::std::mem::transmute::<&[u8; 17], &[os::raw::c_char; 17]>(
678                                b"\0\0\0\0\0\0\0\0\x1E\x0F\x0F\x0F\0\0\0\0\0",
679                            ))
680                                [(__t as os::raw::c_int >> 4 as os::raw::c_int) as usize]
681                                as os::raw::c_int
682                                & (1 as os::raw::c_int) << *code_point
683                                != 0
684                        }
685                        && {
686                            *code_point = *code_point << 6 as os::raw::c_int
687                                | __t as os::raw::c_int & 0x3f as os::raw::c_int;
688                            i = i.wrapping_add(1);
689                            i != length
690                        }
691                        && {
692                            __t = (*string.offset(i as isize) as os::raw::c_int
693                                - 0x80 as os::raw::c_int) as u8;
694                            __t as os::raw::c_int <= 0x3f as os::raw::c_int
695                        }) as os::raw::c_int
696                }) != 0
697                    && {
698                        *code_point = *code_point << 6 as os::raw::c_int | __t as os::raw::c_int;
699                        i = i.wrapping_add(1);
700                        i != length
701                    }) as os::raw::c_int
702            } else {
703                (*code_point >= 0xc2 as os::raw::c_int && {
704                    *code_point &= 0x1f as os::raw::c_int;
705                    true
706                }) as os::raw::c_int
707            }) != 0
708            && {
709                __t = (*string.offset(i as isize) as os::raw::c_int - 0x80 as os::raw::c_int) as u8;
710                __t as os::raw::c_int <= 0x3f as os::raw::c_int
711            }
712            && {
713                *code_point = *code_point << 6 as os::raw::c_int | __t as os::raw::c_int;
714                i = i.wrapping_add(1);
715                true
716            })
717        {
718            *code_point = -(1 as os::raw::c_int);
719        }
720    }
721    return i;
722}
723static mut PARENT_DONE: TSQueryError = 4294967295 as TSQueryError;
724static mut PATTERN_DONE_MARKER: u16 = 65535 as os::raw::c_int as u16;
725static mut NONE: u16 = 65535 as os::raw::c_int as u16;
726static mut WILDCARD_SYMBOL: TSSymbol = 0 as os::raw::c_int as TSSymbol;
727unsafe extern "C" fn stream_advance(mut self_0: *mut Stream) -> bool {
728    let ref mut fresh18 = (*self_0).input;
729    *fresh18 = (*fresh18).offset((*self_0).next_size as os::raw::c_int as isize);
730    if (*self_0).input < (*self_0).end {
731        let mut size: u32 = ts_decode_utf8(
732            (*self_0).input as *const u8,
733            ((*self_0).end).offset_from((*self_0).input) as isize as u32,
734            &mut (*self_0).next,
735        );
736        if size > 0 as os::raw::c_int as os::raw::c_uint {
737            (*self_0).next_size = size as u8;
738            return true;
739        }
740    } else {
741        (*self_0).next_size = 0 as os::raw::c_int as u8;
742        (*self_0).next = '\0' as i32;
743    }
744    return false;
745}
746unsafe extern "C" fn stream_reset(mut self_0: *mut Stream, mut input: *const os::raw::c_char) {
747    let ref mut fresh19 = (*self_0).input;
748    *fresh19 = input;
749    (*self_0).next_size = 0 as os::raw::c_int as u8;
750    stream_advance(self_0);
751}
752unsafe extern "C" fn stream_new(mut string: *const os::raw::c_char, mut length: u32) -> Stream {
753    let mut self_0: Stream = {
754        let mut init = Stream {
755            input: string,
756            start: string,
757            end: string.offset(length as isize),
758            next: 0 as os::raw::c_int,
759            next_size: 0,
760        };
761        init
762    };
763    stream_advance(&mut self_0);
764    return self_0;
765}
766unsafe extern "C" fn stream_skip_whitespace(mut self_0: *mut Stream) {
767    loop {
768        if iswspace((*self_0).next as wint_t) != 0 {
769            stream_advance(self_0);
770        } else {
771            if !((*self_0).next == ';' as i32) {
772                break;
773            }
774            stream_advance(self_0);
775            while (*self_0).next != 0 && (*self_0).next != '\n' as i32 {
776                if !stream_advance(self_0) {
777                    break;
778                }
779            }
780        }
781    }
782}
783unsafe extern "C" fn stream_is_ident_start(mut self_0: *mut Stream) -> bool {
784    return iswalnum((*self_0).next as wint_t) != 0
785        || (*self_0).next == '_' as i32
786        || (*self_0).next == '-' as i32;
787}
788unsafe extern "C" fn stream_scan_identifier(mut stream: *mut Stream) {
789    loop {
790        stream_advance(stream);
791        if !(iswalnum((*stream).next as wint_t) != 0
792            || (*stream).next == '_' as i32
793            || (*stream).next == '-' as i32
794            || (*stream).next == '.' as i32
795            || (*stream).next == '?' as i32
796            || (*stream).next == '!' as i32)
797        {
798            break;
799        }
800    }
801}
802unsafe extern "C" fn stream_offset(mut self_0: *mut Stream) -> u32 {
803    return ((*self_0).input).offset_from((*self_0).start) as isize as u32;
804}
805unsafe extern "C" fn capture_list_pool_new() -> CaptureListPool {
806    return {
807        let mut init = CaptureListPool {
808            list: {
809                let mut init = C2RustUnnamed_13 {
810                    contents: 0 as *mut CaptureList,
811                    size: 0 as os::raw::c_int as u32,
812                    capacity: 0 as os::raw::c_int as u32,
813                };
814                init
815            },
816            empty_list: {
817                let mut init = CaptureList {
818                    contents: 0 as *mut TSQueryCapture,
819                    size: 0 as os::raw::c_int as u32,
820                    capacity: 0 as os::raw::c_int as u32,
821                };
822                init
823            },
824            max_capture_list_count: 4294967295 as os::raw::c_uint,
825            free_capture_list_count: 0 as os::raw::c_int as u32,
826        };
827        init
828    };
829}
830unsafe extern "C" fn capture_list_pool_reset(mut self_0: *mut CaptureListPool) {
831    let mut i: u16 = 0 as os::raw::c_int as u16;
832    while (i as os::raw::c_uint) < (*self_0).list.size {
833        (*((*self_0).list.contents).offset(i as isize)).size = 4294967295 as os::raw::c_uint;
834        i = i.wrapping_add(1);
835    }
836    (*self_0).free_capture_list_count = (*self_0).list.size;
837}
838unsafe extern "C" fn capture_list_pool_delete(mut self_0: *mut CaptureListPool) {
839    let mut i: u16 = 0 as os::raw::c_int as u16;
840    while (i as os::raw::c_uint) < (*self_0).list.size {
841        array__delete(
842            &mut *((*self_0).list.contents).offset(i as isize) as *mut CaptureList
843                as *mut VoidArray,
844        );
845        i = i.wrapping_add(1);
846    }
847    array__delete(&mut (*self_0).list as *mut C2RustUnnamed_13 as *mut VoidArray);
848}
849unsafe extern "C" fn capture_list_pool_get(
850    mut self_0: *const CaptureListPool,
851    mut id: u16,
852) -> *const CaptureList {
853    if id as os::raw::c_uint >= (*self_0).list.size {
854        return &(*self_0).empty_list;
855    }
856    return &mut *((*self_0).list.contents).offset(id as isize) as *mut CaptureList;
857}
858unsafe extern "C" fn capture_list_pool_get_mut(
859    mut self_0: *mut CaptureListPool,
860    mut id: u16,
861) -> *mut CaptureList {
862    if (id as os::raw::c_uint) < (*self_0).list.size {
863    } else {
864        panic!();
865    }
866    return &mut *((*self_0).list.contents).offset(id as isize) as *mut CaptureList;
867}
868unsafe extern "C" fn capture_list_pool_is_empty(mut self_0: *const CaptureListPool) -> bool {
869    return (*self_0).free_capture_list_count == 0 as os::raw::c_int as os::raw::c_uint
870        && (*self_0).list.size >= (*self_0).max_capture_list_count;
871}
872unsafe extern "C" fn capture_list_pool_acquire(mut self_0: *mut CaptureListPool) -> u16 {
873    if (*self_0).free_capture_list_count > 0 as os::raw::c_int as os::raw::c_uint {
874        let mut i: u16 = 0 as os::raw::c_int as u16;
875        while (i as os::raw::c_uint) < (*self_0).list.size {
876            if (*((*self_0).list.contents).offset(i as isize)).size == 4294967295 as os::raw::c_uint
877            {
878                (*((*self_0).list.contents).offset(i as isize)).size = 0 as os::raw::c_int as u32;
879                let ref mut fresh20 = (*self_0).free_capture_list_count;
880                *fresh20 = (*fresh20).wrapping_sub(1);
881                return i;
882            }
883            i = i.wrapping_add(1);
884        }
885    }
886    let mut i_0: u32 = (*self_0).list.size;
887    if i_0 >= (*self_0).max_capture_list_count {
888        return NONE;
889    }
890    let mut list: CaptureList = CaptureList {
891        contents: 0 as *mut TSQueryCapture,
892        size: 0,
893        capacity: 0,
894    };
895    list.size = 0 as os::raw::c_int as u32;
896    list.capacity = 0 as os::raw::c_int as u32;
897    list.contents = 0 as *mut TSQueryCapture;
898    array__grow(
899        &mut (*self_0).list as *mut C2RustUnnamed_13 as *mut VoidArray,
900        1 as os::raw::c_int as size_t,
901        ::std::mem::size_of::<CaptureList>() as usize,
902    );
903    let ref mut fresh21 = (*self_0).list.size;
904    let fresh22 = *fresh21;
905    *fresh21 = (*fresh21).wrapping_add(1);
906    *((*self_0).list.contents).offset(fresh22 as isize) = list;
907    return i_0 as u16;
908}
909unsafe extern "C" fn capture_list_pool_release(mut self_0: *mut CaptureListPool, mut id: u16) {
910    if id as os::raw::c_uint >= (*self_0).list.size {
911        return;
912    }
913    (*((*self_0).list.contents).offset(id as isize)).size = 4294967295 as os::raw::c_uint;
914    let ref mut fresh23 = (*self_0).free_capture_list_count;
915    *fresh23 = (*fresh23).wrapping_add(1);
916}
917unsafe extern "C" fn quantifier_mul(
918    mut left: TSQuantifier,
919    mut right: TSQuantifier,
920) -> TSQuantifier {
921    match left as os::raw::c_uint {
922        0 => return TSQuantifierZero,
923        1 => match right as os::raw::c_uint {
924            0 => return TSQuantifierZero,
925            1 | 3 => return TSQuantifierZeroOrOne,
926            2 | 4 => return TSQuantifierZeroOrMore,
927            _ => {}
928        },
929        2 => match right as os::raw::c_uint {
930            0 => return TSQuantifierZero,
931            1 | 2 | 3 | 4 => return TSQuantifierZeroOrMore,
932            _ => {}
933        },
934        3 => return right,
935        4 => match right as os::raw::c_uint {
936            0 => return TSQuantifierZero,
937            1 | 2 => return TSQuantifierZeroOrMore,
938            3 | 4 => return TSQuantifierOneOrMore,
939            _ => {}
940        },
941        _ => {}
942    }
943    return TSQuantifierZero;
944}
945unsafe extern "C" fn quantifier_join(
946    mut left: TSQuantifier,
947    mut right: TSQuantifier,
948) -> TSQuantifier {
949    match left as os::raw::c_uint {
950        0 => match right as os::raw::c_uint {
951            0 => return TSQuantifierZero,
952            1 | 3 => return TSQuantifierZeroOrOne,
953            2 | 4 => return TSQuantifierZeroOrMore,
954            _ => {}
955        },
956        1 => match right as os::raw::c_uint {
957            0 | 1 | 3 => return TSQuantifierZeroOrOne,
958            2 | 4 => return TSQuantifierZeroOrMore,
959            _ => {}
960        },
961        2 => return TSQuantifierZeroOrMore,
962        3 => match right as os::raw::c_uint {
963            0 | 1 => return TSQuantifierZeroOrOne,
964            2 => return TSQuantifierZeroOrMore,
965            3 => return TSQuantifierOne,
966            4 => return TSQuantifierOneOrMore,
967            _ => {}
968        },
969        4 => match right as os::raw::c_uint {
970            0 | 1 | 2 => return TSQuantifierZeroOrMore,
971            3 | 4 => return TSQuantifierOneOrMore,
972            _ => {}
973        },
974        _ => {}
975    }
976    return TSQuantifierZero;
977}
978unsafe extern "C" fn quantifier_add(
979    mut left: TSQuantifier,
980    mut right: TSQuantifier,
981) -> TSQuantifier {
982    match left as os::raw::c_uint {
983        0 => return right,
984        1 => match right as os::raw::c_uint {
985            0 => return TSQuantifierZeroOrOne,
986            1 | 2 => return TSQuantifierZeroOrMore,
987            3 | 4 => return TSQuantifierOneOrMore,
988            _ => {}
989        },
990        2 => match right as os::raw::c_uint {
991            0 => return TSQuantifierZeroOrMore,
992            1 | 2 => return TSQuantifierZeroOrMore,
993            3 | 4 => return TSQuantifierOneOrMore,
994            _ => {}
995        },
996        3 => match right as os::raw::c_uint {
997            0 => return TSQuantifierOne,
998            1 | 2 | 3 | 4 => return TSQuantifierOneOrMore,
999            _ => {}
1000        },
1001        4 => return TSQuantifierOneOrMore,
1002        _ => {}
1003    }
1004    return TSQuantifierZero;
1005}
1006unsafe extern "C" fn capture_quantifiers_new() -> CaptureQuantifiers {
1007    return {
1008        let mut init = CaptureQuantifiers {
1009            contents: 0 as *mut u8,
1010            size: 0 as os::raw::c_int as u32,
1011            capacity: 0 as os::raw::c_int as u32,
1012        };
1013        init
1014    };
1015}
1016unsafe extern "C" fn capture_quantifiers_delete(mut self_0: *mut CaptureQuantifiers) {
1017    array__delete(self_0 as *mut VoidArray);
1018}
1019unsafe extern "C" fn capture_quantifiers_clear(mut self_0: *mut CaptureQuantifiers) {
1020    (*self_0).size = 0 as os::raw::c_int as u32;
1021}
1022unsafe extern "C" fn capture_quantifiers_replace(
1023    mut self_0: *mut CaptureQuantifiers,
1024    mut quantifiers: *mut CaptureQuantifiers,
1025) {
1026    (*self_0).size = 0 as os::raw::c_int as u32;
1027    array__splice(
1028        self_0 as *mut VoidArray,
1029        ::std::mem::size_of::<u8>() as usize,
1030        (*self_0).size,
1031        0 as os::raw::c_int as u32,
1032        (*quantifiers).size,
1033        (*quantifiers).contents as *const os::raw::c_void,
1034    );
1035}
1036unsafe extern "C" fn capture_quantifier_for_id(
1037    mut self_0: *const CaptureQuantifiers,
1038    mut id: u16,
1039) -> TSQuantifier {
1040    return (if (*self_0).size <= id as os::raw::c_uint {
1041        TSQuantifierZero as os::raw::c_int as os::raw::c_uint
1042    } else {
1043        if (id as u32) < (*self_0).size {
1044        } else {
1045            panic!();
1046        }
1047        *(&mut *((*self_0).contents).offset(id as isize) as *mut u8) as TSQuantifier
1048            as os::raw::c_uint
1049    }) as TSQuantifier;
1050}
1051unsafe extern "C" fn capture_quantifiers_add_for_id(
1052    mut self_0: *mut CaptureQuantifiers,
1053    mut id: u16,
1054    mut quantifier: TSQuantifier,
1055) {
1056    if (*self_0).size <= id as os::raw::c_uint {
1057        array__grow(
1058            self_0 as *mut VoidArray,
1059            ((id as os::raw::c_int + 1 as os::raw::c_int) as os::raw::c_uint)
1060                .wrapping_sub((*self_0).size) as size_t,
1061            ::std::mem::size_of::<u8>() as usize,
1062        );
1063        std::ptr::write_bytes(
1064            ((*self_0).contents).offset((*self_0).size as isize) as *mut os::raw::c_void,
1065            (0 as os::raw::c_int) as u8,
1066            ((((id as os::raw::c_int + 1 as os::raw::c_int) as os::raw::c_uint)
1067                .wrapping_sub((*self_0).size) as usize)
1068                .wrapping_mul(::std::mem::size_of::<u8>() as usize)) as usize,
1069        );
1070        let ref mut fresh24 = (*self_0).size;
1071        *fresh24 = (*fresh24 as os::raw::c_uint).wrapping_add(
1072            ((id as os::raw::c_int + 1 as os::raw::c_int) as os::raw::c_uint)
1073                .wrapping_sub((*self_0).size),
1074        ) as u32 as u32;
1075    }
1076    if (id as u32) < (*self_0).size {
1077    } else {
1078        panic!();
1079    }
1080    let mut own_quantifier: *mut u8 = &mut *((*self_0).contents).offset(id as isize) as *mut u8;
1081    *own_quantifier = quantifier_add(*own_quantifier as TSQuantifier, quantifier) as u8;
1082}
1083unsafe extern "C" fn capture_quantifiers_add_all(
1084    mut self_0: *mut CaptureQuantifiers,
1085    mut quantifiers: *mut CaptureQuantifiers,
1086) {
1087    if (*self_0).size < (*quantifiers).size {
1088        array__grow(
1089            self_0 as *mut VoidArray,
1090            ((*quantifiers).size).wrapping_sub((*self_0).size) as size_t,
1091            ::std::mem::size_of::<u8>() as usize,
1092        );
1093        std::ptr::write_bytes(
1094            ((*self_0).contents).offset((*self_0).size as isize) as *mut os::raw::c_void,
1095            (0 as os::raw::c_int) as u8,
1096            ((((*quantifiers).size).wrapping_sub((*self_0).size) as usize)
1097                .wrapping_mul(::std::mem::size_of::<u8>() as usize)) as usize,
1098        );
1099        let ref mut fresh25 = (*self_0).size;
1100        *fresh25 = (*fresh25 as os::raw::c_uint)
1101            .wrapping_add(((*quantifiers).size).wrapping_sub((*self_0).size))
1102            as u32 as u32;
1103    }
1104    let mut id: u16 = 0 as os::raw::c_int as u16;
1105    while (id as os::raw::c_uint) < (*quantifiers).size {
1106        if (id as u32) < (*quantifiers).size {
1107        } else {
1108            panic!();
1109        }
1110        let mut quantifier: *mut u8 =
1111            &mut *((*quantifiers).contents).offset(id as isize) as *mut u8;
1112        if (id as u32) < (*self_0).size {
1113        } else {
1114            panic!();
1115        }
1116        let mut own_quantifier: *mut u8 = &mut *((*self_0).contents).offset(id as isize) as *mut u8;
1117        *own_quantifier =
1118            quantifier_add(*own_quantifier as TSQuantifier, *quantifier as TSQuantifier) as u8;
1119        id = id.wrapping_add(1);
1120    }
1121}
1122unsafe extern "C" fn capture_quantifiers_mul(
1123    mut self_0: *mut CaptureQuantifiers,
1124    mut quantifier: TSQuantifier,
1125) {
1126    let mut id: u16 = 0 as os::raw::c_int as u16;
1127    while (id as os::raw::c_uint) < (*self_0).size {
1128        if (id as u32) < (*self_0).size {
1129        } else {
1130            panic!();
1131        }
1132        let mut own_quantifier: *mut u8 = &mut *((*self_0).contents).offset(id as isize) as *mut u8;
1133        *own_quantifier = quantifier_mul(*own_quantifier as TSQuantifier, quantifier) as u8;
1134        id = id.wrapping_add(1);
1135    }
1136}
1137unsafe extern "C" fn capture_quantifiers_join_all(
1138    mut self_0: *mut CaptureQuantifiers,
1139    mut quantifiers: *mut CaptureQuantifiers,
1140) {
1141    if (*self_0).size < (*quantifiers).size {
1142        array__grow(
1143            self_0 as *mut VoidArray,
1144            ((*quantifiers).size).wrapping_sub((*self_0).size) as size_t,
1145            ::std::mem::size_of::<u8>() as usize,
1146        );
1147        std::ptr::write_bytes(
1148            ((*self_0).contents).offset((*self_0).size as isize) as *mut os::raw::c_void,
1149            (0 as os::raw::c_int) as u8,
1150            ((((*quantifiers).size).wrapping_sub((*self_0).size) as usize)
1151                .wrapping_mul(::std::mem::size_of::<u8>() as usize)) as usize,
1152        );
1153        let ref mut fresh26 = (*self_0).size;
1154        *fresh26 = (*fresh26 as os::raw::c_uint)
1155            .wrapping_add(((*quantifiers).size).wrapping_sub((*self_0).size))
1156            as u32 as u32;
1157    }
1158    let mut id: u32 = 0 as os::raw::c_int as u32;
1159    while id < (*quantifiers).size {
1160        if id < (*quantifiers).size {
1161        } else {
1162            panic!();
1163        }
1164        let mut quantifier: *mut u8 =
1165            &mut *((*quantifiers).contents).offset(id as isize) as *mut u8;
1166        if id < (*self_0).size {
1167        } else {
1168            panic!();
1169        }
1170        let mut own_quantifier: *mut u8 = &mut *((*self_0).contents).offset(id as isize) as *mut u8;
1171        *own_quantifier =
1172            quantifier_join(*own_quantifier as TSQuantifier, *quantifier as TSQuantifier) as u8;
1173        id = id.wrapping_add(1);
1174    }
1175    let mut id_0: u32 = (*quantifiers).size;
1176    while id_0 < (*self_0).size {
1177        if id_0 < (*self_0).size {
1178        } else {
1179            panic!();
1180        }
1181        let mut own_quantifier_0: *mut u8 =
1182            &mut *((*self_0).contents).offset(id_0 as isize) as *mut u8;
1183        *own_quantifier_0 =
1184            quantifier_join(*own_quantifier_0 as TSQuantifier, TSQuantifierZero) as u8;
1185        id_0 = id_0.wrapping_add(1);
1186    }
1187}
1188unsafe extern "C" fn symbol_table_new() -> SymbolTable {
1189    return {
1190        let mut init = SymbolTable {
1191            characters: {
1192                let mut init = C2RustUnnamed_11 {
1193                    contents: 0 as *mut os::raw::c_char,
1194                    size: 0 as os::raw::c_int as u32,
1195                    capacity: 0 as os::raw::c_int as u32,
1196                };
1197                init
1198            },
1199            slices: {
1200                let mut init = C2RustUnnamed_10 {
1201                    contents: 0 as *mut Slice,
1202                    size: 0 as os::raw::c_int as u32,
1203                    capacity: 0 as os::raw::c_int as u32,
1204                };
1205                init
1206            },
1207        };
1208        init
1209    };
1210}
1211unsafe extern "C" fn symbol_table_delete(mut self_0: *mut SymbolTable) {
1212    array__delete(&mut (*self_0).characters as *mut C2RustUnnamed_11 as *mut VoidArray);
1213    array__delete(&mut (*self_0).slices as *mut C2RustUnnamed_10 as *mut VoidArray);
1214}
1215unsafe extern "C" fn symbol_table_id_for_name(
1216    mut self_0: *const SymbolTable,
1217    mut name: *const os::raw::c_char,
1218    mut length: u32,
1219) -> os::raw::c_int {
1220    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1221    while i < (*self_0).slices.size {
1222        let mut slice: Slice = *((*self_0).slices.contents).offset(i as isize);
1223        if slice.length == length
1224            && strncmp(
1225                &mut *((*self_0).characters.contents).offset(slice.offset as isize),
1226                name,
1227                length as usize,
1228            ) == 0
1229        {
1230            return i as os::raw::c_int;
1231        }
1232        i = i.wrapping_add(1);
1233    }
1234    return -(1 as os::raw::c_int);
1235}
1236unsafe extern "C" fn symbol_table_name_for_id(
1237    mut self_0: *const SymbolTable,
1238    mut id: u16,
1239    mut length: *mut u32,
1240) -> *const os::raw::c_char {
1241    let mut slice: Slice = *((*self_0).slices.contents).offset(id as isize);
1242    *length = slice.length;
1243    return &mut *((*self_0).characters.contents).offset(slice.offset as isize)
1244        as *mut os::raw::c_char;
1245}
1246unsafe extern "C" fn symbol_table_insert_name(
1247    mut self_0: *mut SymbolTable,
1248    mut name: *const os::raw::c_char,
1249    mut length: u32,
1250) -> u16 {
1251    let mut id: os::raw::c_int = symbol_table_id_for_name(self_0, name, length);
1252    if id >= 0 as os::raw::c_int {
1253        return id as u16;
1254    }
1255    let mut slice: Slice = {
1256        let mut init = Slice {
1257            offset: (*self_0).characters.size,
1258            length: length,
1259        };
1260        init
1261    };
1262    array__grow(
1263        &mut (*self_0).characters as *mut C2RustUnnamed_11 as *mut VoidArray,
1264        length.wrapping_add(1 as os::raw::c_int as os::raw::c_uint) as size_t,
1265        ::std::mem::size_of::<os::raw::c_char>() as usize,
1266    );
1267    std::ptr::write_bytes(
1268        ((*self_0).characters.contents).offset((*self_0).characters.size as isize)
1269            as *mut os::raw::c_void,
1270        (0 as os::raw::c_int) as u8,
1271        ((length.wrapping_add(1 as os::raw::c_int as os::raw::c_uint) as usize)
1272            .wrapping_mul(::std::mem::size_of::<os::raw::c_char>() as usize)) as usize,
1273    );
1274    let ref mut fresh27 = (*self_0).characters.size;
1275    *fresh27 = (*fresh27 as os::raw::c_uint)
1276        .wrapping_add(length.wrapping_add(1 as os::raw::c_int as os::raw::c_uint))
1277        as u32 as u32;
1278    std::ptr::copy_nonoverlapping(
1279        name as *const os::raw::c_void,
1280        &mut *((*self_0).characters.contents).offset(slice.offset as isize) as *mut os::raw::c_char
1281            as *mut os::raw::c_void,
1282        length as usize,
1283    );
1284    *((*self_0).characters.contents).offset(
1285        ((*self_0).characters.size).wrapping_sub(1 as os::raw::c_int as os::raw::c_uint) as isize,
1286    ) = 0 as os::raw::c_int as os::raw::c_char;
1287    array__grow(
1288        &mut (*self_0).slices as *mut C2RustUnnamed_10 as *mut VoidArray,
1289        1 as os::raw::c_int as size_t,
1290        ::std::mem::size_of::<Slice>() as usize,
1291    );
1292    let ref mut fresh28 = (*self_0).slices.size;
1293    let fresh29 = *fresh28;
1294    *fresh28 = (*fresh28).wrapping_add(1);
1295    *((*self_0).slices.contents).offset(fresh29 as isize) = slice;
1296    return ((*self_0).slices.size).wrapping_sub(1 as os::raw::c_int as os::raw::c_uint) as u16;
1297}
1298unsafe extern "C" fn query_step__new(
1299    mut symbol: TSSymbol,
1300    mut depth: u16,
1301    mut is_immediate: bool,
1302) -> QueryStep {
1303    return {
1304        let mut init = QueryStep { is_named_is_immediate_is_last_child_is_pass_through_is_dead_end_alternative_is_immediate_contains_captures_root_pattern_guaranteed_parent_pattern_guaranteed : [0 ; 2] , symbol : symbol , supertype_symbol : 0 , field : 0 as os :: raw :: c_int as TSFieldId , capture_ids : [NONE , NONE , NONE] , depth : depth , alternative_index : NONE , negated_field_list_id : 0 as os :: raw :: c_int as u16 , } ;
1305        init.set_is_named(0 as os::raw::c_int != 0);
1306        init.set_is_immediate(is_immediate);
1307        init.set_is_last_child(0 as os::raw::c_int != 0);
1308        init.set_is_pass_through(0 as os::raw::c_int != 0);
1309        init.set_is_dead_end(0 as os::raw::c_int != 0);
1310        init.set_alternative_is_immediate(0 as os::raw::c_int != 0);
1311        init.set_contains_captures(0 as os::raw::c_int != 0);
1312        init.set_root_pattern_guaranteed(0 as os::raw::c_int != 0);
1313        init.set_parent_pattern_guaranteed(false);
1314        init
1315    };
1316}
1317unsafe extern "C" fn query_step__add_capture(mut self_0: *mut QueryStep, mut capture_id: u16) {
1318    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1319    while i < 3 as os::raw::c_int as os::raw::c_uint {
1320        if (*self_0).capture_ids[i as usize] as os::raw::c_int == NONE as os::raw::c_int {
1321            (*self_0).capture_ids[i as usize] = capture_id;
1322            break;
1323        } else {
1324            i = i.wrapping_add(1);
1325        }
1326    }
1327}
1328unsafe extern "C" fn query_step__remove_capture(mut self_0: *mut QueryStep, mut capture_id: u16) {
1329    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1330    while i < 3 as os::raw::c_int as os::raw::c_uint {
1331        if (*self_0).capture_ids[i as usize] as os::raw::c_int == capture_id as os::raw::c_int {
1332            (*self_0).capture_ids[i as usize] = NONE;
1333            while i.wrapping_add(1 as os::raw::c_int as os::raw::c_uint)
1334                < 3 as os::raw::c_int as os::raw::c_uint
1335            {
1336                if (*self_0).capture_ids
1337                    [i.wrapping_add(1 as os::raw::c_int as os::raw::c_uint) as usize]
1338                    as os::raw::c_int
1339                    == NONE as os::raw::c_int
1340                {
1341                    break;
1342                }
1343                (*self_0).capture_ids[i as usize] = (*self_0).capture_ids
1344                    [i.wrapping_add(1 as os::raw::c_int as os::raw::c_uint) as usize];
1345                (*self_0).capture_ids
1346                    [i.wrapping_add(1 as os::raw::c_int as os::raw::c_uint) as usize] = NONE;
1347                i = i.wrapping_add(1);
1348            }
1349            break;
1350        } else {
1351            i = i.wrapping_add(1);
1352        }
1353    }
1354}
1355#[inline]
1356unsafe extern "C" fn state_predecessor_map_new(
1357    mut language: *const TSLanguage,
1358) -> StatePredecessorMap {
1359    return {
1360        let mut init = StatePredecessorMap {
1361            contents: crate::alloc::ts_calloc(
1362                ((*language).state_count as size_t)
1363                    .wrapping_mul((256 as os::raw::c_int + 1 as os::raw::c_int) as usize),
1364                ::std::mem::size_of::<TSStateId>() as usize,
1365            ) as *mut TSStateId,
1366        };
1367        init
1368    };
1369}
1370#[inline]
1371unsafe extern "C" fn state_predecessor_map_delete(mut self_0: *mut StatePredecessorMap) {
1372    crate::alloc::ts_free((*self_0).contents as *mut os::raw::c_void);
1373}
1374#[inline]
1375unsafe extern "C" fn state_predecessor_map_add(
1376    mut self_0: *mut StatePredecessorMap,
1377    mut state: TSStateId,
1378    mut predecessor: TSStateId,
1379) {
1380    let mut index: size_t =
1381        (state as size_t).wrapping_mul((256 as os::raw::c_int + 1 as os::raw::c_int) as usize);
1382    let mut count: *mut TSStateId =
1383        &mut *((*self_0).contents).offset(index as isize) as *mut TSStateId;
1384    if *count as os::raw::c_int == 0 as os::raw::c_int
1385        || (*count as os::raw::c_int) < 256 as os::raw::c_int
1386            && *((*self_0).contents).offset(index.wrapping_add(*count as usize) as isize)
1387                as os::raw::c_int
1388                != predecessor as os::raw::c_int
1389    {
1390        *count = (*count).wrapping_add(1);
1391        *((*self_0).contents).offset(index.wrapping_add(*count as usize) as isize) = predecessor;
1392    }
1393}
1394#[inline]
1395unsafe extern "C" fn state_predecessor_map_get(
1396    mut self_0: *const StatePredecessorMap,
1397    mut state: TSStateId,
1398    mut count: *mut os::raw::c_uint,
1399) -> *const TSStateId {
1400    let mut index: size_t =
1401        (state as size_t).wrapping_mul((256 as os::raw::c_int + 1 as os::raw::c_int) as usize);
1402    *count = *((*self_0).contents).offset(index as isize) as os::raw::c_uint;
1403    return &mut *((*self_0).contents)
1404        .offset(index.wrapping_add(1 as os::raw::c_int as usize) as isize)
1405        as *mut TSStateId;
1406}
1407unsafe extern "C" fn analysis_state__recursion_depth(
1408    mut self_0: *const AnalysisState,
1409) -> os::raw::c_uint {
1410    let mut result: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1411    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1412    while i < (*self_0).depth as os::raw::c_uint {
1413        let mut symbol: TSSymbol = (*self_0).stack[i as usize].parent_symbol;
1414        let mut j: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1415        while j < i {
1416            if (*self_0).stack[j as usize].parent_symbol as os::raw::c_int
1417                == symbol as os::raw::c_int
1418            {
1419                result = result.wrapping_add(1);
1420                break;
1421            } else {
1422                j = j.wrapping_add(1);
1423            }
1424        }
1425        i = i.wrapping_add(1);
1426    }
1427    return result;
1428}
1429#[inline]
1430unsafe extern "C" fn analysis_state__compare_position(
1431    mut self_0: *const *mut AnalysisState,
1432    mut other: *const *mut AnalysisState,
1433) -> os::raw::c_int {
1434    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1435    while i < (**self_0).depth as os::raw::c_uint {
1436        if i >= (**other).depth as os::raw::c_uint {
1437            return -(1 as os::raw::c_int);
1438        }
1439        if ((**self_0).stack[i as usize].child_index as os::raw::c_int)
1440            < (**other).stack[i as usize].child_index as os::raw::c_int
1441        {
1442            return -(1 as os::raw::c_int);
1443        }
1444        if (**self_0).stack[i as usize].child_index as os::raw::c_int
1445            > (**other).stack[i as usize].child_index as os::raw::c_int
1446        {
1447            return 1 as os::raw::c_int;
1448        }
1449        i = i.wrapping_add(1);
1450    }
1451    if ((**self_0).depth as os::raw::c_int) < (**other).depth as os::raw::c_int {
1452        return 1 as os::raw::c_int;
1453    }
1454    if ((**self_0).step_index as os::raw::c_int) < (**other).step_index as os::raw::c_int {
1455        return -(1 as os::raw::c_int);
1456    }
1457    if (**self_0).step_index as os::raw::c_int > (**other).step_index as os::raw::c_int {
1458        return 1 as os::raw::c_int;
1459    }
1460    return 0 as os::raw::c_int;
1461}
1462#[inline]
1463unsafe extern "C" fn analysis_state__compare(
1464    mut self_0: *const *mut AnalysisState,
1465    mut other: *const *mut AnalysisState,
1466) -> os::raw::c_int {
1467    let mut result: os::raw::c_int = analysis_state__compare_position(self_0, other);
1468    if result != 0 as os::raw::c_int {
1469        return result;
1470    }
1471    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1472    while i < (**self_0).depth as os::raw::c_uint {
1473        if ((**self_0).stack[i as usize].parent_symbol as os::raw::c_int)
1474            < (**other).stack[i as usize].parent_symbol as os::raw::c_int
1475        {
1476            return -(1 as os::raw::c_int);
1477        }
1478        if (**self_0).stack[i as usize].parent_symbol as os::raw::c_int
1479            > (**other).stack[i as usize].parent_symbol as os::raw::c_int
1480        {
1481            return 1 as os::raw::c_int;
1482        }
1483        if ((**self_0).stack[i as usize].parse_state as os::raw::c_int)
1484            < (**other).stack[i as usize].parse_state as os::raw::c_int
1485        {
1486            return -(1 as os::raw::c_int);
1487        }
1488        if (**self_0).stack[i as usize].parse_state as os::raw::c_int
1489            > (**other).stack[i as usize].parse_state as os::raw::c_int
1490        {
1491            return 1 as os::raw::c_int;
1492        }
1493        if (((**self_0).stack[i as usize]).field_id() as os::raw::c_int)
1494            < ((**other).stack[i as usize]).field_id() as os::raw::c_int
1495        {
1496            return -(1 as os::raw::c_int);
1497        }
1498        if ((**self_0).stack[i as usize]).field_id() as os::raw::c_int
1499            > ((**other).stack[i as usize]).field_id() as os::raw::c_int
1500        {
1501            return 1 as os::raw::c_int;
1502        }
1503        i = i.wrapping_add(1);
1504    }
1505    return 0 as os::raw::c_int;
1506}
1507#[inline]
1508unsafe extern "C" fn analysis_state__top(
1509    mut self_0: *mut AnalysisState,
1510) -> *mut AnalysisStateEntry {
1511    return &mut *((*self_0).stack)
1512        .as_mut_ptr()
1513        .offset(((*self_0).depth as os::raw::c_int - 1 as os::raw::c_int) as isize)
1514        as *mut AnalysisStateEntry;
1515}
1516#[inline]
1517unsafe extern "C" fn analysis_state__has_supertype(
1518    mut self_0: *mut AnalysisState,
1519    mut symbol: TSSymbol,
1520) -> bool {
1521    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1522    while i < (*self_0).depth as os::raw::c_uint {
1523        if (*self_0).stack[i as usize].parent_symbol as os::raw::c_int == symbol as os::raw::c_int {
1524            return true;
1525        }
1526        i = i.wrapping_add(1);
1527    }
1528    return false;
1529}
1530#[inline]
1531unsafe extern "C" fn analysis_state__clone(mut self_0: *const AnalysisState) -> *mut AnalysisState {
1532    let mut new_state: *mut AnalysisState = crate::alloc::ts_malloc(::std::mem::size_of::<
1533        AnalysisState,
1534    >() as usize) as *mut AnalysisState;
1535    *new_state = *self_0;
1536    return new_state;
1537}
1538#[inline]
1539unsafe extern "C" fn analysis_state_pool__clone_or_reuse(
1540    mut self_0: *mut AnalysisStatePool,
1541    mut borrowed_item: *mut AnalysisState,
1542) -> *mut AnalysisState {
1543    let mut new_item: *mut AnalysisState = 0 as *mut AnalysisState;
1544    if (*self_0).size != 0 {
1545        let ref mut fresh30 = (*self_0).size;
1546        *fresh30 = (*fresh30).wrapping_sub(1);
1547        new_item = *((*self_0).contents).offset(*fresh30 as isize);
1548        *new_item = *borrowed_item;
1549    } else {
1550        new_item = analysis_state__clone(borrowed_item);
1551    }
1552    return new_item;
1553}
1554#[inline]
1555unsafe extern "C" fn analysis_state_set__insert_sorted_by_clone(
1556    mut self_0: *mut AnalysisStateSet,
1557    mut pool: *mut AnalysisStatePool,
1558    mut borrowed_item: *mut AnalysisState,
1559) {
1560    let mut index: os::raw::c_uint = 0;
1561    let mut exists: os::raw::c_uint = 0;
1562    index = 0 as os::raw::c_int as os::raw::c_uint;
1563    exists = 0 as os::raw::c_int as os::raw::c_uint;
1564    let mut size: u32 = ((*self_0).size).wrapping_sub(index);
1565    if !(size == 0 as os::raw::c_int as os::raw::c_uint) {
1566        let mut comparison: os::raw::c_int = 0;
1567        while size > 1 as os::raw::c_int as os::raw::c_uint {
1568            let mut half_size: u32 = size.wrapping_div(2 as os::raw::c_int as os::raw::c_uint);
1569            let mut mid_index: u32 = index.wrapping_add(half_size);
1570            comparison = analysis_state__compare(
1571                &mut *((*self_0).contents).offset(mid_index as isize),
1572                &mut borrowed_item,
1573            );
1574            if comparison <= 0 as os::raw::c_int {
1575                index = mid_index;
1576            }
1577            size = (size as os::raw::c_uint).wrapping_sub(half_size) as u32 as u32;
1578        }
1579        comparison = analysis_state__compare(
1580            &mut *((*self_0).contents).offset(index as isize),
1581            &mut borrowed_item,
1582        );
1583        if comparison == 0 as os::raw::c_int {
1584            exists = 1 as os::raw::c_int as os::raw::c_uint;
1585        } else if comparison < 0 as os::raw::c_int {
1586            index = index.wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
1587        }
1588    }
1589    if exists == 0 {
1590        let mut new_item: *mut AnalysisState =
1591            analysis_state_pool__clone_or_reuse(pool, borrowed_item);
1592        array__splice(
1593            self_0 as *mut VoidArray,
1594            ::std::mem::size_of::<*mut AnalysisState>() as usize,
1595            index,
1596            0 as os::raw::c_int as u32,
1597            1 as os::raw::c_int as u32,
1598            &mut new_item as *mut *mut AnalysisState as *const os::raw::c_void,
1599        );
1600    }
1601}
1602#[inline]
1603unsafe extern "C" fn analysis_state_set__push_by_clone(
1604    mut self_0: *mut AnalysisStateSet,
1605    mut pool: *mut AnalysisStatePool,
1606    mut borrowed_item: *mut AnalysisState,
1607) {
1608    let mut new_item: *mut AnalysisState = analysis_state_pool__clone_or_reuse(pool, borrowed_item);
1609    array__grow(
1610        self_0 as *mut VoidArray,
1611        1 as os::raw::c_int as size_t,
1612        ::std::mem::size_of::<*mut AnalysisState>() as usize,
1613    );
1614    let ref mut fresh31 = (*self_0).size;
1615    let fresh32 = *fresh31;
1616    *fresh31 = (*fresh31).wrapping_add(1);
1617    let ref mut fresh33 = *((*self_0).contents).offset(fresh32 as isize);
1618    *fresh33 = new_item;
1619}
1620#[inline]
1621unsafe extern "C" fn analysis_state_set__clear(
1622    mut self_0: *mut AnalysisStateSet,
1623    mut pool: *mut AnalysisStatePool,
1624) {
1625    array__splice(
1626        pool as *mut VoidArray,
1627        ::std::mem::size_of::<*mut AnalysisState>() as usize,
1628        (*pool).size,
1629        0 as os::raw::c_int as u32,
1630        (*self_0).size,
1631        (*self_0).contents as *const os::raw::c_void,
1632    );
1633    (*self_0).size = 0 as os::raw::c_int as u32;
1634}
1635#[inline]
1636unsafe extern "C" fn analysis_state_set__delete(mut self_0: *mut AnalysisStateSet) {
1637    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1638    while i < (*self_0).size {
1639        crate::alloc::ts_free(*((*self_0).contents).offset(i as isize) as *mut os::raw::c_void);
1640        i = i.wrapping_add(1);
1641    }
1642    array__delete(self_0 as *mut VoidArray);
1643}
1644#[inline]
1645unsafe extern "C" fn analysis_subgraph_node__compare(
1646    mut self_0: *const AnalysisSubgraphNode,
1647    mut other: *const AnalysisSubgraphNode,
1648) -> os::raw::c_int {
1649    if ((*self_0).state as os::raw::c_int) < (*other).state as os::raw::c_int {
1650        return -(1 as os::raw::c_int);
1651    }
1652    if (*self_0).state as os::raw::c_int > (*other).state as os::raw::c_int {
1653        return 1 as os::raw::c_int;
1654    }
1655    if ((*self_0).child_index() as os::raw::c_int) < (*other).child_index() as os::raw::c_int {
1656        return -(1 as os::raw::c_int);
1657    }
1658    if (*self_0).child_index() as os::raw::c_int > (*other).child_index() as os::raw::c_int {
1659        return 1 as os::raw::c_int;
1660    }
1661    if ((*self_0).done() as os::raw::c_int) < (*other).done() as os::raw::c_int {
1662        return -(1 as os::raw::c_int);
1663    }
1664    if (*self_0).done() as os::raw::c_int > (*other).done() as os::raw::c_int {
1665        return 1 as os::raw::c_int;
1666    }
1667    if ((*self_0).production_id as os::raw::c_int) < (*other).production_id as os::raw::c_int {
1668        return -(1 as os::raw::c_int);
1669    }
1670    if (*self_0).production_id as os::raw::c_int > (*other).production_id as os::raw::c_int {
1671        return 1 as os::raw::c_int;
1672    }
1673    return 0 as os::raw::c_int;
1674}
1675#[inline]
1676unsafe extern "C" fn ts_query__pattern_map_search(
1677    mut self_0: *const TSQuery,
1678    mut needle: TSSymbol,
1679    mut result: *mut u32,
1680) -> bool {
1681    let mut base_index: u32 = (*self_0).wildcard_root_pattern_count as u32;
1682    let mut size: u32 = ((*self_0).pattern_map.size).wrapping_sub(base_index);
1683    if size == 0 as os::raw::c_int as os::raw::c_uint {
1684        *result = base_index;
1685        return false;
1686    }
1687    while size > 1 as os::raw::c_int as os::raw::c_uint {
1688        let mut half_size: u32 = size.wrapping_div(2 as os::raw::c_int as os::raw::c_uint);
1689        let mut mid_index: u32 = base_index.wrapping_add(half_size);
1690        let mut mid_symbol: TSSymbol = (*((*self_0).steps.contents).offset(
1691            (*((*self_0).pattern_map.contents).offset(mid_index as isize)).step_index as isize,
1692        ))
1693        .symbol;
1694        if needle as os::raw::c_int > mid_symbol as os::raw::c_int {
1695            base_index = mid_index;
1696        }
1697        size = (size as os::raw::c_uint).wrapping_sub(half_size) as u32 as u32;
1698    }
1699    let mut symbol: TSSymbol = (*((*self_0).steps.contents).offset(
1700        (*((*self_0).pattern_map.contents).offset(base_index as isize)).step_index as isize,
1701    ))
1702    .symbol;
1703    if needle as os::raw::c_int > symbol as os::raw::c_int {
1704        base_index = base_index.wrapping_add(1);
1705        if base_index < (*self_0).pattern_map.size {
1706            symbol = (*((*self_0).steps.contents).offset(
1707                (*((*self_0).pattern_map.contents).offset(base_index as isize)).step_index as isize,
1708            ))
1709            .symbol;
1710        }
1711    }
1712    *result = base_index;
1713    return needle as os::raw::c_int == symbol as os::raw::c_int;
1714}
1715#[inline]
1716unsafe extern "C" fn ts_query__pattern_map_insert(
1717    mut self_0: *mut TSQuery,
1718    mut symbol: TSSymbol,
1719    mut new_entry: PatternEntry,
1720) {
1721    let mut index: u32 = 0;
1722    ts_query__pattern_map_search(self_0, symbol, &mut index);
1723    while index < (*self_0).pattern_map.size {
1724        let mut entry: *mut PatternEntry =
1725            &mut *((*self_0).pattern_map.contents).offset(index as isize) as *mut PatternEntry;
1726        if !((*((*self_0).steps.contents).offset((*entry).step_index as isize)).symbol
1727            as os::raw::c_int
1728            == symbol as os::raw::c_int
1729            && ((*entry).pattern_index as os::raw::c_int)
1730                < new_entry.pattern_index as os::raw::c_int)
1731        {
1732            break;
1733        }
1734        index = index.wrapping_add(1);
1735    }
1736    array__splice(
1737        &mut (*self_0).pattern_map as *mut C2RustUnnamed_8 as *mut VoidArray,
1738        ::std::mem::size_of::<PatternEntry>() as usize,
1739        index,
1740        0 as os::raw::c_int as u32,
1741        1 as os::raw::c_int as u32,
1742        &mut new_entry as *mut PatternEntry as *const os::raw::c_void,
1743    );
1744}
1745unsafe extern "C" fn ts_query__analyze_patterns(
1746    mut self_0: *mut TSQuery,
1747    mut error_offset: *mut os::raw::c_uint,
1748) -> bool {
1749    let mut parent_step_indices: C2RustUnnamed_17 = {
1750        let mut init = C2RustUnnamed_17 {
1751            contents: 0 as *mut u32,
1752            size: 0 as os::raw::c_int as u32,
1753            capacity: 0 as os::raw::c_int as u32,
1754        };
1755        init
1756    };
1757    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1758    while i < (*self_0).steps.size {
1759        let mut step: *mut QueryStep =
1760            &mut *((*self_0).steps.contents).offset(i as isize) as *mut QueryStep;
1761        if (*step).depth as os::raw::c_int == PATTERN_DONE_MARKER as os::raw::c_int {
1762            (*step).set_parent_pattern_guaranteed(1 as os::raw::c_int != 0);
1763            (*step).set_root_pattern_guaranteed(1 as os::raw::c_int != 0);
1764        } else {
1765            let mut has_children: bool = false;
1766            let mut is_wildcard: bool =
1767                (*step).symbol as os::raw::c_int == WILDCARD_SYMBOL as os::raw::c_int;
1768            (*step).set_contains_captures(
1769                (*step).capture_ids[0 as os::raw::c_int as usize] as os::raw::c_int
1770                    != NONE as os::raw::c_int,
1771            );
1772            let mut j: os::raw::c_uint = i.wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
1773            while j < (*self_0).steps.size {
1774                let mut next_step: *mut QueryStep =
1775                    &mut *((*self_0).steps.contents).offset(j as isize) as *mut QueryStep;
1776                if (*next_step).depth as os::raw::c_int == PATTERN_DONE_MARKER as os::raw::c_int
1777                    || (*next_step).depth as os::raw::c_int <= (*step).depth as os::raw::c_int
1778                {
1779                    break;
1780                }
1781                if (*next_step).capture_ids[0 as os::raw::c_int as usize] as os::raw::c_int
1782                    != NONE as os::raw::c_int
1783                {
1784                    (*step).set_contains_captures(1 as os::raw::c_int != 0);
1785                }
1786                if !is_wildcard {
1787                    (*next_step).set_root_pattern_guaranteed(1 as os::raw::c_int != 0);
1788                    (*next_step).set_parent_pattern_guaranteed(1 as os::raw::c_int != 0);
1789                }
1790                has_children = true;
1791                j = j.wrapping_add(1);
1792            }
1793            if has_children as os::raw::c_int != 0 && !is_wildcard {
1794                array__grow(
1795                    &mut parent_step_indices as *mut C2RustUnnamed_17 as *mut VoidArray,
1796                    1 as os::raw::c_int as size_t,
1797                    ::std::mem::size_of::<u32>() as usize,
1798                );
1799                let fresh34 = parent_step_indices.size;
1800                parent_step_indices.size = (parent_step_indices.size).wrapping_add(1);
1801                *(parent_step_indices.contents).offset(fresh34 as isize) = i;
1802            }
1803        }
1804        i = i.wrapping_add(1);
1805    }
1806    let mut subgraphs: C2RustUnnamed_20 = {
1807        let mut init = C2RustUnnamed_20 {
1808            contents: 0 as *mut AnalysisSubgraph,
1809            size: 0 as os::raw::c_int as u32,
1810            capacity: 0 as os::raw::c_int as u32,
1811        };
1812        init
1813    };
1814    let mut i_0: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1815    while i_0 < parent_step_indices.size {
1816        let mut parent_step_index: u32 = *(parent_step_indices.contents).offset(i_0 as isize);
1817        let mut parent_symbol: TSSymbol =
1818            (*((*self_0).steps.contents).offset(parent_step_index as isize)).symbol;
1819        let mut subgraph: AnalysisSubgraph = {
1820            let mut init = AnalysisSubgraph {
1821                symbol: parent_symbol,
1822                start_states: C2RustUnnamed_22 {
1823                    contents: 0 as *mut TSStateId,
1824                    size: 0,
1825                    capacity: 0,
1826                },
1827                nodes: C2RustUnnamed_21 {
1828                    contents: 0 as *mut AnalysisSubgraphNode,
1829                    size: 0,
1830                    capacity: 0,
1831                },
1832            };
1833            init
1834        };
1835        let mut index: os::raw::c_uint = 0;
1836        let mut exists: os::raw::c_uint = 0;
1837        index = 0 as os::raw::c_int as os::raw::c_uint;
1838        exists = 0 as os::raw::c_int as os::raw::c_uint;
1839        let mut size: u32 = (subgraphs.size).wrapping_sub(index);
1840        if !(size == 0 as os::raw::c_int as os::raw::c_uint) {
1841            let mut comparison: os::raw::c_int = 0;
1842            while size > 1 as os::raw::c_int as os::raw::c_uint {
1843                let mut half_size: u32 = size.wrapping_div(2 as os::raw::c_int as os::raw::c_uint);
1844                let mut mid_index: u32 = index.wrapping_add(half_size);
1845                comparison = (*(subgraphs.contents).offset(mid_index as isize)).symbol
1846                    as os::raw::c_int
1847                    - subgraph.symbol as os::raw::c_int;
1848                if comparison <= 0 as os::raw::c_int {
1849                    index = mid_index;
1850                }
1851                size = (size as os::raw::c_uint).wrapping_sub(half_size) as u32 as u32;
1852            }
1853            comparison = (*(subgraphs.contents).offset(index as isize)).symbol as os::raw::c_int
1854                - subgraph.symbol as os::raw::c_int;
1855            if comparison == 0 as os::raw::c_int {
1856                exists = 1 as os::raw::c_int as os::raw::c_uint;
1857            } else if comparison < 0 as os::raw::c_int {
1858                index = index.wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
1859            }
1860        }
1861        if exists == 0 {
1862            array__splice(
1863                &mut subgraphs as *mut C2RustUnnamed_20 as *mut VoidArray,
1864                ::std::mem::size_of::<AnalysisSubgraph>() as usize,
1865                index,
1866                0 as os::raw::c_int as u32,
1867                1 as os::raw::c_int as u32,
1868                &mut subgraph as *mut AnalysisSubgraph as *const os::raw::c_void,
1869            );
1870        }
1871        i_0 = i_0.wrapping_add(1);
1872    }
1873    let mut sym: TSSymbol = (*(*self_0).language).token_count as TSSymbol;
1874    while (sym as os::raw::c_uint) < (*(*self_0).language).symbol_count {
1875        if !(ts_language_symbol_metadata((*self_0).language, sym)).visible {
1876            let mut subgraph_0: AnalysisSubgraph = {
1877                let mut init = AnalysisSubgraph {
1878                    symbol: sym,
1879                    start_states: C2RustUnnamed_22 {
1880                        contents: 0 as *mut TSStateId,
1881                        size: 0,
1882                        capacity: 0,
1883                    },
1884                    nodes: C2RustUnnamed_21 {
1885                        contents: 0 as *mut AnalysisSubgraphNode,
1886                        size: 0,
1887                        capacity: 0,
1888                    },
1889                };
1890                init
1891            };
1892            let mut index_0: os::raw::c_uint = 0;
1893            let mut exists_0: os::raw::c_uint = 0;
1894            index_0 = 0 as os::raw::c_int as os::raw::c_uint;
1895            exists_0 = 0 as os::raw::c_int as os::raw::c_uint;
1896            let mut size_0: u32 = (subgraphs.size).wrapping_sub(index_0);
1897            if !(size_0 == 0 as os::raw::c_int as os::raw::c_uint) {
1898                let mut comparison_0: os::raw::c_int = 0;
1899                while size_0 > 1 as os::raw::c_int as os::raw::c_uint {
1900                    let mut half_size_0: u32 =
1901                        size_0.wrapping_div(2 as os::raw::c_int as os::raw::c_uint);
1902                    let mut mid_index_0: u32 = index_0.wrapping_add(half_size_0);
1903                    comparison_0 = (*(subgraphs.contents).offset(mid_index_0 as isize)).symbol
1904                        as os::raw::c_int
1905                        - subgraph_0.symbol as os::raw::c_int;
1906                    if comparison_0 <= 0 as os::raw::c_int {
1907                        index_0 = mid_index_0;
1908                    }
1909                    size_0 = (size_0 as os::raw::c_uint).wrapping_sub(half_size_0) as u32 as u32;
1910                }
1911                comparison_0 = (*(subgraphs.contents).offset(index_0 as isize)).symbol
1912                    as os::raw::c_int
1913                    - subgraph_0.symbol as os::raw::c_int;
1914                if comparison_0 == 0 as os::raw::c_int {
1915                    exists_0 = 1 as os::raw::c_int as os::raw::c_uint;
1916                } else if comparison_0 < 0 as os::raw::c_int {
1917                    index_0 = index_0.wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
1918                }
1919            }
1920            if exists_0 == 0 {
1921                array__splice(
1922                    &mut subgraphs as *mut C2RustUnnamed_20 as *mut VoidArray,
1923                    ::std::mem::size_of::<AnalysisSubgraph>() as usize,
1924                    index_0,
1925                    0 as os::raw::c_int as u32,
1926                    1 as os::raw::c_int as u32,
1927                    &mut subgraph_0 as *mut AnalysisSubgraph as *const os::raw::c_void,
1928                );
1929            }
1930        }
1931        sym = sym.wrapping_add(1);
1932    }
1933    let mut predecessor_map: StatePredecessorMap = state_predecessor_map_new((*self_0).language);
1934    let mut state: TSStateId = 1 as os::raw::c_int as TSStateId;
1935    while (state as os::raw::c_uint) < (*(*self_0).language).state_count {
1936        let mut subgraph_index: os::raw::c_uint = 0;
1937        let mut exists_1: os::raw::c_uint = 0;
1938        let mut lookahead_iterator: LookaheadIterator =
1939            ts_language_lookaheads((*self_0).language, state);
1940        while ts_lookahead_iterator_next(&mut lookahead_iterator) {
1941            if lookahead_iterator.action_count != 0 {
1942                let mut i_1: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
1943                while i_1 < lookahead_iterator.action_count as os::raw::c_uint {
1944                    let mut action: *const TSParseAction =
1945                        &*(lookahead_iterator.actions).offset(i_1 as isize) as *const TSParseAction;
1946                    if (*action).type_ as os::raw::c_int
1947                        == TSParseActionTypeReduce as os::raw::c_int
1948                    {
1949                        let mut aliases: *const TSSymbol = 0 as *const TSSymbol;
1950                        let mut aliases_end: *const TSSymbol = 0 as *const TSSymbol;
1951                        ts_language_aliases_for_symbol(
1952                            (*self_0).language,
1953                            (*action).reduce.symbol,
1954                            &mut aliases,
1955                            &mut aliases_end,
1956                        );
1957                        let mut symbol: *const TSSymbol = aliases;
1958                        while symbol < aliases_end {
1959                            subgraph_index = 0 as os::raw::c_int as os::raw::c_uint;
1960                            exists_1 = 0 as os::raw::c_int as os::raw::c_uint;
1961                            let mut size_1: u32 = (subgraphs.size).wrapping_sub(subgraph_index);
1962                            if !(size_1 == 0 as os::raw::c_int as os::raw::c_uint) {
1963                                let mut comparison_1: os::raw::c_int = 0;
1964                                while size_1 > 1 as os::raw::c_int as os::raw::c_uint {
1965                                    let mut half_size_1: u32 =
1966                                        size_1.wrapping_div(2 as os::raw::c_int as os::raw::c_uint);
1967                                    let mut mid_index_1: u32 =
1968                                        subgraph_index.wrapping_add(half_size_1);
1969                                    comparison_1 =
1970                                        (*(subgraphs.contents).offset(mid_index_1 as isize)).symbol
1971                                            as os::raw::c_int
1972                                            - *symbol as os::raw::c_int;
1973                                    if comparison_1 <= 0 as os::raw::c_int {
1974                                        subgraph_index = mid_index_1;
1975                                    }
1976                                    size_1 = (size_1 as os::raw::c_uint).wrapping_sub(half_size_1)
1977                                        as u32 as u32;
1978                                }
1979                                comparison_1 =
1980                                    (*(subgraphs.contents).offset(subgraph_index as isize)).symbol
1981                                        as os::raw::c_int
1982                                        - *symbol as os::raw::c_int;
1983                                if comparison_1 == 0 as os::raw::c_int {
1984                                    exists_1 = 1 as os::raw::c_int as os::raw::c_uint;
1985                                } else if comparison_1 < 0 as os::raw::c_int {
1986                                    subgraph_index = subgraph_index
1987                                        .wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
1988                                }
1989                            }
1990                            if exists_1 != 0 {
1991                                let mut subgraph_1: *mut AnalysisSubgraph =
1992                                    &mut *(subgraphs.contents).offset(subgraph_index as isize)
1993                                        as *mut AnalysisSubgraph;
1994                                if (*subgraph_1).nodes.size
1995                                    == 0 as os::raw::c_int as os::raw::c_uint
1996                                    || {
1997                                        if ((*subgraph_1).nodes.size)
1998                                            .wrapping_sub(1 as os::raw::c_int as os::raw::c_uint)
1999                                            < (*subgraph_1).nodes.size
2000                                        {
2001                                        } else {
2002                                            panic!();
2003                                        }
2004                                        (*(&mut *((*subgraph_1).nodes.contents).offset(
2005                                            ((*subgraph_1).nodes.size).wrapping_sub(
2006                                                1 as os::raw::c_int as os::raw::c_uint,
2007                                            ) as isize,
2008                                        )
2009                                            as *mut AnalysisSubgraphNode))
2010                                            .state
2011                                            as os::raw::c_int
2012                                            != state as os::raw::c_int
2013                                    }
2014                                {
2015                                    array__grow(
2016                                        &mut (*subgraph_1).nodes as *mut C2RustUnnamed_21
2017                                            as *mut VoidArray,
2018                                        1 as os::raw::c_int as size_t,
2019                                        ::std::mem::size_of::<AnalysisSubgraphNode>() as usize,
2020                                    );
2021                                    let ref mut fresh35 = (*subgraph_1).nodes.size;
2022                                    let fresh36 = *fresh35;
2023                                    *fresh35 = (*fresh35).wrapping_add(1);
2024                                    *((*subgraph_1).nodes.contents).offset(fresh36 as isize) = {
2025                                        let mut init = AnalysisSubgraphNode {
2026                                            child_index_done: [0; 1],
2027                                            c2rust_padding: [0; 1],
2028                                            state: state,
2029                                            production_id: (*action).reduce.production_id,
2030                                        };
2031                                        init.set_child_index((*action).reduce.child_count);
2032                                        init.set_done(1 as os::raw::c_int != 0);
2033                                        init
2034                                    };
2035                                }
2036                            }
2037                            symbol = symbol.offset(1);
2038                        }
2039                    } else if (*action).type_ as os::raw::c_int
2040                        == TSParseActionTypeShift as os::raw::c_int
2041                        && !(*action).shift.extra
2042                    {
2043                        let mut next_state: TSStateId = (*action).shift.state;
2044                        state_predecessor_map_add(&mut predecessor_map, next_state, state);
2045                    }
2046                    i_1 = i_1.wrapping_add(1);
2047                }
2048            } else if lookahead_iterator.next_state as os::raw::c_int != 0 as os::raw::c_int {
2049                if lookahead_iterator.next_state as os::raw::c_int != state as os::raw::c_int {
2050                    state_predecessor_map_add(
2051                        &mut predecessor_map,
2052                        lookahead_iterator.next_state,
2053                        state,
2054                    );
2055                }
2056                if ts_language_state_is_primary((*self_0).language, state) {
2057                    let mut aliases_0: *const TSSymbol = 0 as *const TSSymbol;
2058                    let mut aliases_end_0: *const TSSymbol = 0 as *const TSSymbol;
2059                    ts_language_aliases_for_symbol(
2060                        (*self_0).language,
2061                        lookahead_iterator.symbol,
2062                        &mut aliases_0,
2063                        &mut aliases_end_0,
2064                    );
2065                    let mut symbol_0: *const TSSymbol = aliases_0;
2066                    while symbol_0 < aliases_end_0 {
2067                        subgraph_index = 0 as os::raw::c_int as os::raw::c_uint;
2068                        exists_1 = 0 as os::raw::c_int as os::raw::c_uint;
2069                        let mut size_2: u32 = (subgraphs.size).wrapping_sub(subgraph_index);
2070                        if !(size_2 == 0 as os::raw::c_int as os::raw::c_uint) {
2071                            let mut comparison_2: os::raw::c_int = 0;
2072                            while size_2 > 1 as os::raw::c_int as os::raw::c_uint {
2073                                let mut half_size_2: u32 =
2074                                    size_2.wrapping_div(2 as os::raw::c_int as os::raw::c_uint);
2075                                let mut mid_index_2: u32 = subgraph_index.wrapping_add(half_size_2);
2076                                comparison_2 = (*(subgraphs.contents).offset(mid_index_2 as isize))
2077                                    .symbol
2078                                    as os::raw::c_int
2079                                    - *symbol_0 as os::raw::c_int;
2080                                if comparison_2 <= 0 as os::raw::c_int {
2081                                    subgraph_index = mid_index_2;
2082                                }
2083                                size_2 = (size_2 as os::raw::c_uint).wrapping_sub(half_size_2)
2084                                    as u32 as u32;
2085                            }
2086                            comparison_2 = (*(subgraphs.contents).offset(subgraph_index as isize))
2087                                .symbol
2088                                as os::raw::c_int
2089                                - *symbol_0 as os::raw::c_int;
2090                            if comparison_2 == 0 as os::raw::c_int {
2091                                exists_1 = 1 as os::raw::c_int as os::raw::c_uint;
2092                            } else if comparison_2 < 0 as os::raw::c_int {
2093                                subgraph_index = subgraph_index
2094                                    .wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
2095                            }
2096                        }
2097                        if exists_1 != 0 {
2098                            let mut subgraph_2: *mut AnalysisSubgraph = &mut *(subgraphs.contents)
2099                                .offset(subgraph_index as isize)
2100                                as *mut AnalysisSubgraph;
2101                            if (*subgraph_2).start_states.size
2102                                == 0 as os::raw::c_int as os::raw::c_uint
2103                                || {
2104                                    if ((*subgraph_2).start_states.size)
2105                                        .wrapping_sub(1 as os::raw::c_int as os::raw::c_uint)
2106                                        < (*subgraph_2).start_states.size
2107                                    {
2108                                    } else {
2109                                        panic!();
2110                                    }
2111                                    *(&mut *((*subgraph_2).start_states.contents).offset(
2112                                        ((*subgraph_2).start_states.size)
2113                                            .wrapping_sub(1 as os::raw::c_int as os::raw::c_uint)
2114                                            as isize,
2115                                    ) as *mut TSStateId)
2116                                        as os::raw::c_int
2117                                        != state as os::raw::c_int
2118                                }
2119                            {
2120                                array__grow(
2121                                    &mut (*subgraph_2).start_states as *mut C2RustUnnamed_22
2122                                        as *mut VoidArray,
2123                                    1 as os::raw::c_int as size_t,
2124                                    ::std::mem::size_of::<TSStateId>() as usize,
2125                                );
2126                                let ref mut fresh37 = (*subgraph_2).start_states.size;
2127                                let fresh38 = *fresh37;
2128                                *fresh37 = (*fresh37).wrapping_add(1);
2129                                *((*subgraph_2).start_states.contents).offset(fresh38 as isize) =
2130                                    state;
2131                            }
2132                        }
2133                        symbol_0 = symbol_0.offset(1);
2134                    }
2135                }
2136            }
2137        }
2138        state = state.wrapping_add(1);
2139    }
2140    let mut next_nodes: C2RustUnnamed_19 = {
2141        let mut init = C2RustUnnamed_19 {
2142            contents: 0 as *mut AnalysisSubgraphNode,
2143            size: 0 as os::raw::c_int as u32,
2144            capacity: 0 as os::raw::c_int as u32,
2145        };
2146        init
2147    };
2148    let mut i_2: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
2149    while i_2 < subgraphs.size {
2150        let mut subgraph_3: *mut AnalysisSubgraph =
2151            &mut *(subgraphs.contents).offset(i_2 as isize) as *mut AnalysisSubgraph;
2152        if (*subgraph_3).nodes.size == 0 as os::raw::c_int as os::raw::c_uint {
2153            array__delete(
2154                &mut (*subgraph_3).start_states as *mut C2RustUnnamed_22 as *mut VoidArray,
2155            );
2156            array__erase(
2157                &mut subgraphs as *mut C2RustUnnamed_20 as *mut VoidArray,
2158                ::std::mem::size_of::<AnalysisSubgraph>() as usize,
2159                i_2,
2160            );
2161            i_2 = i_2.wrapping_sub(1);
2162        } else {
2163            array__assign(
2164                &mut next_nodes as *mut C2RustUnnamed_19 as *mut VoidArray,
2165                &mut (*subgraph_3).nodes as *mut C2RustUnnamed_21 as *const VoidArray,
2166                ::std::mem::size_of::<AnalysisSubgraphNode>() as usize,
2167            );
2168            while next_nodes.size > 0 as os::raw::c_int as os::raw::c_uint {
2169                next_nodes.size = (next_nodes.size).wrapping_sub(1);
2170                let mut node: AnalysisSubgraphNode =
2171                    *(next_nodes.contents).offset(next_nodes.size as isize);
2172                if node.child_index() as os::raw::c_int > 1 as os::raw::c_int {
2173                    let mut predecessor_count: os::raw::c_uint = 0;
2174                    let mut predecessors: *const TSStateId = state_predecessor_map_get(
2175                        &mut predecessor_map,
2176                        node.state,
2177                        &mut predecessor_count,
2178                    );
2179                    let mut j_0: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
2180                    while j_0 < predecessor_count {
2181                        let mut predecessor_node: AnalysisSubgraphNode = {
2182                            let mut init = AnalysisSubgraphNode {
2183                                child_index_done: [0; 1],
2184                                c2rust_padding: [0; 1],
2185                                state: *predecessors.offset(j_0 as isize),
2186                                production_id: node.production_id,
2187                            };
2188                            init.set_child_index(
2189                                (node.child_index() as os::raw::c_int - 1 as os::raw::c_int) as u8,
2190                            );
2191                            init.set_done(0 as os::raw::c_int != 0);
2192                            init
2193                        };
2194                        let mut index_1: os::raw::c_uint = 0;
2195                        let mut exists_2: os::raw::c_uint = 0;
2196                        index_1 = 0 as os::raw::c_int as os::raw::c_uint;
2197                        exists_2 = 0 as os::raw::c_int as os::raw::c_uint;
2198                        let mut size_3: u32 = ((*subgraph_3).nodes.size).wrapping_sub(index_1);
2199                        if !(size_3 == 0 as os::raw::c_int as os::raw::c_uint) {
2200                            let mut comparison_3: os::raw::c_int = 0;
2201                            while size_3 > 1 as os::raw::c_int as os::raw::c_uint {
2202                                let mut half_size_3: u32 =
2203                                    size_3.wrapping_div(2 as os::raw::c_int as os::raw::c_uint);
2204                                let mut mid_index_3: u32 = index_1.wrapping_add(half_size_3);
2205                                comparison_3 = analysis_subgraph_node__compare(
2206                                    &mut *((*subgraph_3).nodes.contents)
2207                                        .offset(mid_index_3 as isize),
2208                                    &mut predecessor_node,
2209                                );
2210                                if comparison_3 <= 0 as os::raw::c_int {
2211                                    index_1 = mid_index_3;
2212                                }
2213                                size_3 = (size_3 as os::raw::c_uint).wrapping_sub(half_size_3)
2214                                    as u32 as u32;
2215                            }
2216                            comparison_3 = analysis_subgraph_node__compare(
2217                                &mut *((*subgraph_3).nodes.contents).offset(index_1 as isize),
2218                                &mut predecessor_node,
2219                            );
2220                            if comparison_3 == 0 as os::raw::c_int {
2221                                exists_2 = 1 as os::raw::c_int as os::raw::c_uint;
2222                            } else if comparison_3 < 0 as os::raw::c_int {
2223                                index_1 =
2224                                    index_1.wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
2225                            }
2226                        }
2227                        if exists_2 == 0 {
2228                            array__splice(
2229                                &mut (*subgraph_3).nodes as *mut C2RustUnnamed_21 as *mut VoidArray,
2230                                ::std::mem::size_of::<AnalysisSubgraphNode>() as usize,
2231                                index_1,
2232                                0 as os::raw::c_int as u32,
2233                                1 as os::raw::c_int as u32,
2234                                &mut predecessor_node as *mut AnalysisSubgraphNode
2235                                    as *const os::raw::c_void,
2236                            );
2237                            array__grow(
2238                                &mut next_nodes as *mut C2RustUnnamed_19 as *mut VoidArray,
2239                                1 as os::raw::c_int as size_t,
2240                                ::std::mem::size_of::<AnalysisSubgraphNode>() as usize,
2241                            );
2242                            let fresh39 = next_nodes.size;
2243                            next_nodes.size = (next_nodes.size).wrapping_add(1);
2244                            *(next_nodes.contents).offset(fresh39 as isize) = predecessor_node;
2245                        }
2246                        j_0 = j_0.wrapping_add(1);
2247                    }
2248                }
2249            }
2250        }
2251        i_2 = i_2.wrapping_add(1);
2252    }
2253    let mut all_patterns_are_valid: bool = true;
2254    let mut states: AnalysisStateSet = {
2255        let mut init = AnalysisStateSet {
2256            contents: 0 as *mut *mut AnalysisState,
2257            size: 0 as os::raw::c_int as u32,
2258            capacity: 0 as os::raw::c_int as u32,
2259        };
2260        init
2261    };
2262    let mut next_states: AnalysisStateSet = {
2263        let mut init = AnalysisStateSet {
2264            contents: 0 as *mut *mut AnalysisState,
2265            size: 0 as os::raw::c_int as u32,
2266            capacity: 0 as os::raw::c_int as u32,
2267        };
2268        init
2269    };
2270    let mut deeper_states: AnalysisStateSet = {
2271        let mut init = AnalysisStateSet {
2272            contents: 0 as *mut *mut AnalysisState,
2273            size: 0 as os::raw::c_int as u32,
2274            capacity: 0 as os::raw::c_int as u32,
2275        };
2276        init
2277    };
2278    let mut state_pool: AnalysisStatePool = {
2279        let mut init = AnalysisStatePool {
2280            contents: 0 as *mut *mut AnalysisState,
2281            size: 0 as os::raw::c_int as u32,
2282            capacity: 0 as os::raw::c_int as u32,
2283        };
2284        init
2285    };
2286    let mut final_step_indices: C2RustUnnamed_18 = {
2287        let mut init = C2RustUnnamed_18 {
2288            contents: 0 as *mut u16,
2289            size: 0 as os::raw::c_int as u32,
2290            capacity: 0 as os::raw::c_int as u32,
2291        };
2292        init
2293    };
2294    let mut i_3: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
2295    while i_3 < parent_step_indices.size {
2296        let mut parent_step_index_0: u16 =
2297            *(parent_step_indices.contents).offset(i_3 as isize) as u16;
2298        let mut parent_depth: u16 =
2299            (*((*self_0).steps.contents).offset(parent_step_index_0 as isize)).depth;
2300        let mut parent_symbol_0: TSSymbol =
2301            (*((*self_0).steps.contents).offset(parent_step_index_0 as isize)).symbol;
2302        if !(parent_symbol_0 as os::raw::c_int
2303            == -(1 as os::raw::c_int) as TSSymbol as os::raw::c_int)
2304        {
2305            let mut subgraph_index_0: os::raw::c_uint = 0;
2306            let mut exists_3: os::raw::c_uint = 0;
2307            subgraph_index_0 = 0 as os::raw::c_int as os::raw::c_uint;
2308            exists_3 = 0 as os::raw::c_int as os::raw::c_uint;
2309            let mut size_4: u32 = (subgraphs.size).wrapping_sub(subgraph_index_0);
2310            if !(size_4 == 0 as os::raw::c_int as os::raw::c_uint) {
2311                let mut comparison_4: os::raw::c_int = 0;
2312                while size_4 > 1 as os::raw::c_int as os::raw::c_uint {
2313                    let mut half_size_4: u32 =
2314                        size_4.wrapping_div(2 as os::raw::c_int as os::raw::c_uint);
2315                    let mut mid_index_4: u32 = subgraph_index_0.wrapping_add(half_size_4);
2316                    comparison_4 = (*(subgraphs.contents).offset(mid_index_4 as isize)).symbol
2317                        as os::raw::c_int
2318                        - parent_symbol_0 as os::raw::c_int;
2319                    if comparison_4 <= 0 as os::raw::c_int {
2320                        subgraph_index_0 = mid_index_4;
2321                    }
2322                    size_4 = (size_4 as os::raw::c_uint).wrapping_sub(half_size_4) as u32 as u32;
2323                }
2324                comparison_4 = (*(subgraphs.contents).offset(subgraph_index_0 as isize)).symbol
2325                    as os::raw::c_int
2326                    - parent_symbol_0 as os::raw::c_int;
2327                if comparison_4 == 0 as os::raw::c_int {
2328                    exists_3 = 1 as os::raw::c_int as os::raw::c_uint;
2329                } else if comparison_4 < 0 as os::raw::c_int {
2330                    subgraph_index_0 =
2331                        subgraph_index_0.wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
2332                }
2333            }
2334            if exists_3 == 0 {
2335                let mut first_child_step_index: os::raw::c_uint =
2336                    (parent_step_index_0 as os::raw::c_int + 1 as os::raw::c_int)
2337                        as os::raw::c_uint;
2338                let mut i_4: u32 = 0;
2339                let mut exists_4: u32 = 0;
2340                i_4 = 0 as os::raw::c_int as u32;
2341                exists_4 = 0 as os::raw::c_int as u32;
2342                let mut size_5: u32 = ((*self_0).step_offsets.size).wrapping_sub(i_4);
2343                if !(size_5 == 0 as os::raw::c_int as os::raw::c_uint) {
2344                    let mut comparison_5: os::raw::c_int = 0;
2345                    while size_5 > 1 as os::raw::c_int as os::raw::c_uint {
2346                        let mut half_size_5: u32 =
2347                            size_5.wrapping_div(2 as os::raw::c_int as os::raw::c_uint);
2348                        let mut mid_index_5: u32 = i_4.wrapping_add(half_size_5);
2349                        comparison_5 = (*((*self_0).step_offsets.contents)
2350                            .offset(mid_index_5 as isize))
2351                        .step_index as os::raw::c_int
2352                            - first_child_step_index as os::raw::c_int;
2353                        if comparison_5 <= 0 as os::raw::c_int {
2354                            i_4 = mid_index_5;
2355                        }
2356                        size_5 =
2357                            (size_5 as os::raw::c_uint).wrapping_sub(half_size_5) as u32 as u32;
2358                    }
2359                    comparison_5 = (*((*self_0).step_offsets.contents).offset(i_4 as isize))
2360                        .step_index as os::raw::c_int
2361                        - first_child_step_index as os::raw::c_int;
2362                    if comparison_5 == 0 as os::raw::c_int {
2363                        exists_4 = 1 as os::raw::c_int as u32;
2364                    } else if comparison_5 < 0 as os::raw::c_int {
2365                        i_4 = (i_4 as os::raw::c_uint)
2366                            .wrapping_add(1 as os::raw::c_int as os::raw::c_uint)
2367                            as u32 as u32;
2368                    }
2369                }
2370                if exists_4 != 0 {
2371                } else {
2372                    panic!();
2373                }
2374                *error_offset =
2375                    (*((*self_0).step_offsets.contents).offset(i_4 as isize)).byte_offset;
2376                all_patterns_are_valid = false;
2377                break;
2378            } else {
2379                let mut subgraph_4: *mut AnalysisSubgraph = &mut *(subgraphs.contents)
2380                    .offset(subgraph_index_0 as isize)
2381                    as *mut AnalysisSubgraph;
2382                analysis_state_set__clear(&mut states, &mut state_pool);
2383                analysis_state_set__clear(&mut deeper_states, &mut state_pool);
2384                let mut j_1: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
2385                while j_1 < (*subgraph_4).start_states.size {
2386                    let mut parse_state: TSStateId =
2387                        *((*subgraph_4).start_states.contents).offset(j_1 as isize);
2388                    analysis_state_set__push_by_clone(&mut states, &mut state_pool, &mut {
2389                        let mut init = AnalysisState {
2390                            stack: [
2391                                {
2392                                    let mut init = AnalysisStateEntry {
2393                                        field_id_done: [0; 2],
2394                                        parse_state: parse_state,
2395                                        parent_symbol: parent_symbol_0,
2396                                        child_index: 0 as os::raw::c_int as u16,
2397                                    };
2398                                    init.set_field_id(0 as os::raw::c_int as TSFieldId);
2399                                    init.set_done(0 as os::raw::c_int != 0);
2400                                    init
2401                                },
2402                                AnalysisStateEntry {
2403                                    parse_state: 0,
2404                                    parent_symbol: 0,
2405                                    child_index: 0,
2406                                    field_id_done: [0; 2],
2407                                },
2408                                AnalysisStateEntry {
2409                                    parse_state: 0,
2410                                    parent_symbol: 0,
2411                                    child_index: 0,
2412                                    field_id_done: [0; 2],
2413                                },
2414                                AnalysisStateEntry {
2415                                    parse_state: 0,
2416                                    parent_symbol: 0,
2417                                    child_index: 0,
2418                                    field_id_done: [0; 2],
2419                                },
2420                                AnalysisStateEntry {
2421                                    parse_state: 0,
2422                                    parent_symbol: 0,
2423                                    child_index: 0,
2424                                    field_id_done: [0; 2],
2425                                },
2426                                AnalysisStateEntry {
2427                                    parse_state: 0,
2428                                    parent_symbol: 0,
2429                                    child_index: 0,
2430                                    field_id_done: [0; 2],
2431                                },
2432                                AnalysisStateEntry {
2433                                    parse_state: 0,
2434                                    parent_symbol: 0,
2435                                    child_index: 0,
2436                                    field_id_done: [0; 2],
2437                                },
2438                                AnalysisStateEntry {
2439                                    parse_state: 0,
2440                                    parent_symbol: 0,
2441                                    child_index: 0,
2442                                    field_id_done: [0; 2],
2443                                },
2444                            ],
2445                            depth: 1 as os::raw::c_int as u16,
2446                            step_index: (parent_step_index_0 as os::raw::c_int
2447                                + 1 as os::raw::c_int)
2448                                as u16,
2449                        };
2450                        init
2451                    });
2452                    j_1 = j_1.wrapping_add(1);
2453                }
2454                let mut can_finish_pattern: bool = false;
2455                let mut did_abort_analysis: bool = false;
2456                let mut recursion_depth_limit: os::raw::c_uint =
2457                    0 as os::raw::c_int as os::raw::c_uint;
2458                let mut prev_final_step_count: os::raw::c_uint =
2459                    0 as os::raw::c_int as os::raw::c_uint;
2460                final_step_indices.size = 0 as os::raw::c_int as u32;
2461                let mut iteration: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
2462                loop {
2463                    if iteration == 256 as os::raw::c_int as os::raw::c_uint {
2464                        did_abort_analysis = true;
2465                        break;
2466                    } else {
2467                        if states.size == 0 as os::raw::c_int as os::raw::c_uint {
2468                            if !(deeper_states.size > 0 as os::raw::c_int as os::raw::c_uint
2469                                && final_step_indices.size > prev_final_step_count)
2470                            {
2471                                break;
2472                            }
2473                            prev_final_step_count = final_step_indices.size;
2474                            recursion_depth_limit = recursion_depth_limit.wrapping_add(1);
2475                            let mut _states: AnalysisStateSet = states;
2476                            states = deeper_states;
2477                            deeper_states = _states;
2478                        } else {
2479                            analysis_state_set__clear(&mut next_states, &mut state_pool);
2480                            let mut current_block_303: u64;
2481                            let mut j_2: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
2482                            while j_2 < states.size {
2483                                let state_0: *mut AnalysisState =
2484                                    *(states.contents).offset(j_2 as isize);
2485                                if next_states.size > 0 as os::raw::c_int as os::raw::c_uint {
2486                                    if (next_states.size)
2487                                        .wrapping_sub(1 as os::raw::c_int as os::raw::c_uint)
2488                                        < next_states.size
2489                                    {
2490                                    } else {
2491                                        panic!();
2492                                    }
2493                                    let mut comparison_6: os::raw::c_int =
2494                                        analysis_state__compare_position(
2495                                            &state_0,
2496                                            &mut *(next_states.contents).offset(
2497                                                (next_states.size).wrapping_sub(
2498                                                    1 as os::raw::c_int as os::raw::c_uint,
2499                                                )
2500                                                    as isize,
2501                                            ),
2502                                        );
2503                                    if comparison_6 == 0 as os::raw::c_int {
2504                                        analysis_state_set__insert_sorted_by_clone(
2505                                            &mut next_states,
2506                                            &mut state_pool,
2507                                            state_0,
2508                                        );
2509                                        current_block_303 = 6648503596396917841;
2510                                    } else if comparison_6 > 0 as os::raw::c_int {
2511                                        while j_2 < states.size {
2512                                            analysis_state_set__push_by_clone(
2513                                                &mut next_states,
2514                                                &mut state_pool,
2515                                                *(states.contents).offset(j_2 as isize),
2516                                            );
2517                                            j_2 = j_2.wrapping_add(1);
2518                                        }
2519                                        break;
2520                                    } else {
2521                                        current_block_303 = 2588063579017527985;
2522                                    }
2523                                } else {
2524                                    current_block_303 = 2588063579017527985;
2525                                }
2526                                match current_block_303 {
2527                                    2588063579017527985 => {
2528                                        let parse_state_0: TSStateId =
2529                                            (*analysis_state__top(state_0)).parse_state;
2530                                        let parent_symbol_1: TSSymbol =
2531                                            (*analysis_state__top(state_0)).parent_symbol;
2532                                        let parent_field_id: TSFieldId =
2533                                            (*analysis_state__top(state_0)).field_id();
2534                                        let child_index: os::raw::c_uint =
2535                                            (*analysis_state__top(state_0)).child_index
2536                                                as os::raw::c_uint;
2537                                        let step_0: *const QueryStep =
2538                                            &mut *((*self_0).steps.contents)
2539                                                .offset((*state_0).step_index as isize)
2540                                                as *mut QueryStep;
2541                                        let mut subgraph_index_1: os::raw::c_uint = 0;
2542                                        let mut exists_5: os::raw::c_uint = 0;
2543                                        subgraph_index_1 = 0 as os::raw::c_int as os::raw::c_uint;
2544                                        exists_5 = 0 as os::raw::c_int as os::raw::c_uint;
2545                                        let mut size_6: u32 =
2546                                            (subgraphs.size).wrapping_sub(subgraph_index_1);
2547                                        if !(size_6 == 0 as os::raw::c_int as os::raw::c_uint) {
2548                                            let mut comparison_7: os::raw::c_int = 0;
2549                                            while size_6 > 1 as os::raw::c_int as os::raw::c_uint {
2550                                                let mut half_size_6: u32 = size_6.wrapping_div(
2551                                                    2 as os::raw::c_int as os::raw::c_uint,
2552                                                );
2553                                                let mut mid_index_6: u32 =
2554                                                    subgraph_index_1.wrapping_add(half_size_6);
2555                                                comparison_7 = (*(subgraphs.contents)
2556                                                    .offset(mid_index_6 as isize))
2557                                                .symbol
2558                                                    as os::raw::c_int
2559                                                    - parent_symbol_1 as os::raw::c_int;
2560                                                if comparison_7 <= 0 as os::raw::c_int {
2561                                                    subgraph_index_1 = mid_index_6;
2562                                                }
2563                                                size_6 = (size_6 as os::raw::c_uint)
2564                                                    .wrapping_sub(half_size_6)
2565                                                    as u32
2566                                                    as u32;
2567                                            }
2568                                            comparison_7 = (*(subgraphs.contents)
2569                                                .offset(subgraph_index_1 as isize))
2570                                            .symbol
2571                                                as os::raw::c_int
2572                                                - parent_symbol_1 as os::raw::c_int;
2573                                            if comparison_7 == 0 as os::raw::c_int {
2574                                                exists_5 = 1 as os::raw::c_int as os::raw::c_uint;
2575                                            } else if comparison_7 < 0 as os::raw::c_int {
2576                                                subgraph_index_1 = subgraph_index_1.wrapping_add(
2577                                                    1 as os::raw::c_int as os::raw::c_uint,
2578                                                );
2579                                            }
2580                                        }
2581                                        if !(exists_5 == 0) {
2582                                            let mut subgraph_5: *const AnalysisSubgraph =
2583                                                &mut *(subgraphs.contents)
2584                                                    .offset(subgraph_index_1 as isize)
2585                                                    as *mut AnalysisSubgraph;
2586                                            let mut lookahead_iterator_0: LookaheadIterator =
2587                                                ts_language_lookaheads(
2588                                                    (*self_0).language,
2589                                                    parse_state_0,
2590                                                );
2591                                            while ts_lookahead_iterator_next(
2592                                                &mut lookahead_iterator_0,
2593                                            ) {
2594                                                let mut sym_0: TSSymbol =
2595                                                    lookahead_iterator_0.symbol;
2596                                                let mut successor: AnalysisSubgraphNode = {
2597                                                    let mut init = AnalysisSubgraphNode {
2598                                                        child_index_done: [0; 1],
2599                                                        c2rust_padding: [0; 1],
2600                                                        state: parse_state_0,
2601                                                        production_id: 0,
2602                                                    };
2603                                                    init.set_child_index(child_index as u8);
2604                                                    init.set_done(false);
2605                                                    init
2606                                                };
2607                                                if lookahead_iterator_0.action_count != 0 {
2608                                                    let mut action_0: *const TSParseAction =
2609                                                        &*(lookahead_iterator_0.actions).offset(
2610                                                            (lookahead_iterator_0.action_count
2611                                                                as os::raw::c_int
2612                                                                - 1 as os::raw::c_int)
2613                                                                as isize,
2614                                                        )
2615                                                            as *const TSParseAction;
2616                                                    if !((*action_0).type_ as os::raw::c_int
2617                                                        == TSParseActionTypeShift as os::raw::c_int)
2618                                                    {
2619                                                        continue;
2620                                                    }
2621                                                    if !(*action_0).shift.extra {
2622                                                        successor.state = (*action_0).shift.state;
2623                                                        successor.set_child_index(
2624                                                            successor.child_index() + 1,
2625                                                        );
2626                                                    }
2627                                                } else {
2628                                                    if !(lookahead_iterator_0.next_state
2629                                                        as os::raw::c_int
2630                                                        != 0 as os::raw::c_int)
2631                                                    {
2632                                                        continue;
2633                                                    }
2634                                                    successor.state =
2635                                                        lookahead_iterator_0.next_state;
2636                                                    successor.set_child_index(
2637                                                        successor.child_index() + 1,
2638                                                    );
2639                                                }
2640                                                let mut node_index: os::raw::c_uint = 0;
2641                                                node_index = 0 as os::raw::c_int as os::raw::c_uint;
2642                                                exists_5 = 0 as os::raw::c_int as os::raw::c_uint;
2643                                                let mut size_7: u32 = ((*subgraph_5).nodes.size)
2644                                                    .wrapping_sub(node_index);
2645                                                if !(size_7
2646                                                    == 0 as os::raw::c_int as os::raw::c_uint)
2647                                                {
2648                                                    let mut comparison_8: os::raw::c_int = 0;
2649                                                    while size_7
2650                                                        > 1 as os::raw::c_int as os::raw::c_uint
2651                                                    {
2652                                                        let mut half_size_7: u32 = size_7
2653                                                            .wrapping_div(
2654                                                                2 as os::raw::c_int
2655                                                                    as os::raw::c_uint,
2656                                                            );
2657                                                        let mut mid_index_7: u32 =
2658                                                            node_index.wrapping_add(half_size_7);
2659                                                        comparison_8 =
2660                                                            analysis_subgraph_node__compare(
2661                                                                &mut *((*subgraph_5)
2662                                                                    .nodes
2663                                                                    .contents)
2664                                                                    .offset(mid_index_7 as isize),
2665                                                                &mut successor,
2666                                                            );
2667                                                        if comparison_8 <= 0 as os::raw::c_int {
2668                                                            node_index = mid_index_7;
2669                                                        }
2670                                                        size_7 = (size_7 as os::raw::c_uint)
2671                                                            .wrapping_sub(half_size_7)
2672                                                            as u32
2673                                                            as u32;
2674                                                    }
2675                                                    comparison_8 = analysis_subgraph_node__compare(
2676                                                        &mut *((*subgraph_5).nodes.contents)
2677                                                            .offset(node_index as isize),
2678                                                        &mut successor,
2679                                                    );
2680                                                    if comparison_8 == 0 as os::raw::c_int {
2681                                                        exists_5 =
2682                                                            1 as os::raw::c_int as os::raw::c_uint;
2683                                                    } else if comparison_8 < 0 as os::raw::c_int {
2684                                                        node_index = node_index.wrapping_add(
2685                                                            1 as os::raw::c_int as os::raw::c_uint,
2686                                                        );
2687                                                    }
2688                                                }
2689                                                while node_index < (*subgraph_5).nodes.size {
2690                                                    let fresh40 = node_index;
2691                                                    node_index = node_index.wrapping_add(1);
2692                                                    let mut node_0: *mut AnalysisSubgraphNode =
2693                                                        &mut *((*subgraph_5).nodes.contents)
2694                                                            .offset(fresh40 as isize)
2695                                                            as *mut AnalysisSubgraphNode;
2696                                                    if (*node_0).state as os::raw::c_int
2697                                                        != successor.state as os::raw::c_int
2698                                                        || (*node_0).child_index() as os::raw::c_int
2699                                                            != successor.child_index()
2700                                                                as os::raw::c_int
2701                                                    {
2702                                                        break;
2703                                                    }
2704                                                    let mut alias: TSSymbol = ts_language_alias_at(
2705                                                        (*self_0).language,
2706                                                        (*node_0).production_id as u32,
2707                                                        child_index,
2708                                                    );
2709                                                    let mut visible_symbol: TSSymbol =
2710                                                        (if alias as os::raw::c_int != 0 {
2711                                                            alias as os::raw::c_int
2712                                                        } else if (*((*(*self_0).language)
2713                                                            .symbol_metadata)
2714                                                            .offset(sym_0 as isize))
2715                                                        .visible
2716                                                            as os::raw::c_int
2717                                                            != 0
2718                                                        {
2719                                                            *((*(*self_0).language)
2720                                                                .public_symbol_map)
2721                                                                .offset(sym_0 as isize)
2722                                                                as os::raw::c_int
2723                                                        } else {
2724                                                            0 as os::raw::c_int
2725                                                        })
2726                                                            as TSSymbol;
2727                                                    let mut field_id: TSFieldId = parent_field_id;
2728                                                    if field_id == 0 {
2729                                                        let mut field_map: *const TSFieldMapEntry =
2730                                                            0 as *const TSFieldMapEntry;
2731                                                        let mut field_map_end : * const TSFieldMapEntry = 0 as * const TSFieldMapEntry ;
2732                                                        ts_language_field_map(
2733                                                            (*self_0).language,
2734                                                            (*node_0).production_id as u32,
2735                                                            &mut field_map,
2736                                                            &mut field_map_end,
2737                                                        );
2738                                                        while field_map != field_map_end {
2739                                                            if !(*field_map).inherited
2740                                                                && (*field_map).child_index
2741                                                                    as os::raw::c_uint
2742                                                                    == child_index
2743                                                            {
2744                                                                field_id = (*field_map).field_id;
2745                                                                break;
2746                                                            } else {
2747                                                                field_map = field_map.offset(1);
2748                                                            }
2749                                                        }
2750                                                    }
2751                                                    let mut next_state_0: AnalysisState = *state_0;
2752                                                    let mut next_state_top : * mut AnalysisStateEntry = analysis_state__top (& mut next_state_0 ,) ;
2753                                                    (*next_state_top).child_index =
2754                                                        successor.child_index() as u16;
2755                                                    (*next_state_top).parse_state = successor.state;
2756                                                    if (*node_0).done() {
2757                                                        (*next_state_top)
2758                                                            .set_done(1 as os::raw::c_int != 0);
2759                                                    }
2760                                                    let mut does_match: bool = false;
2761                                                    if visible_symbol != 0 {
2762                                                        does_match = true;
2763                                                        if (*step_0).symbol as os::raw::c_int
2764                                                            == WILDCARD_SYMBOL as os::raw::c_int
2765                                                        {
2766                                                            if (*step_0).is_named()
2767                                                                as os::raw::c_int
2768                                                                != 0
2769                                                                && !(*((*(*self_0).language)
2770                                                                    .symbol_metadata)
2771                                                                    .offset(
2772                                                                        visible_symbol as isize,
2773                                                                    ))
2774                                                                .named
2775                                                            {
2776                                                                does_match = false;
2777                                                            }
2778                                                        } else if (*step_0).symbol as os::raw::c_int
2779                                                            != visible_symbol as os::raw::c_int
2780                                                        {
2781                                                            does_match = false;
2782                                                        }
2783                                                        if (*step_0).field as os::raw::c_int != 0
2784                                                            && (*step_0).field as os::raw::c_int
2785                                                                != field_id as os::raw::c_int
2786                                                        {
2787                                                            does_match = false;
2788                                                        }
2789                                                        if (*step_0).supertype_symbol
2790                                                            as os::raw::c_int
2791                                                            != 0
2792                                                            && !analysis_state__has_supertype(
2793                                                                state_0,
2794                                                                (*step_0).supertype_symbol,
2795                                                            )
2796                                                        {
2797                                                            does_match = false;
2798                                                        }
2799                                                    } else if sym_0 as os::raw::c_uint
2800                                                        >= (*(*self_0).language).token_count
2801                                                    {
2802                                                        if !(*next_state_top).done() {
2803                                                            if next_state_0.depth as os::raw::c_int
2804                                                                + 1 as os::raw::c_int
2805                                                                >= 8 as os::raw::c_int
2806                                                            {
2807                                                                did_abort_analysis = true;
2808                                                                continue;
2809                                                            } else {
2810                                                                next_state_0.depth = (next_state_0
2811                                                                    .depth)
2812                                                                    .wrapping_add(1);
2813                                                                next_state_top =
2814                                                                    analysis_state__top(
2815                                                                        &mut next_state_0,
2816                                                                    );
2817                                                            }
2818                                                        }
2819                                                        *next_state_top = {
2820                                                            let mut init = AnalysisStateEntry {
2821                                                                field_id_done: [0; 2],
2822                                                                parse_state: parse_state_0,
2823                                                                parent_symbol: sym_0,
2824                                                                child_index: 0 as os::raw::c_int
2825                                                                    as u16,
2826                                                            };
2827                                                            init.set_field_id(field_id);
2828                                                            init.set_done(0 as os::raw::c_int != 0);
2829                                                            init
2830                                                        };
2831                                                        if analysis_state__recursion_depth(
2832                                                            &mut next_state_0,
2833                                                        ) > recursion_depth_limit
2834                                                        {
2835                                                            analysis_state_set__insert_sorted_by_clone (& mut deeper_states , & mut state_pool , & mut next_state_0 ,) ;
2836                                                            continue;
2837                                                        }
2838                                                    }
2839                                                    while next_state_0.depth as os::raw::c_int
2840                                                        > 0 as os::raw::c_int
2841                                                        && (*next_state_top).done()
2842                                                            as os::raw::c_int
2843                                                            != 0
2844                                                    {
2845                                                        next_state_0.depth =
2846                                                            (next_state_0.depth).wrapping_sub(1);
2847                                                        next_state_top =
2848                                                            analysis_state__top(&mut next_state_0);
2849                                                    }
2850                                                    let mut next_step_0: *const QueryStep = step_0;
2851                                                    if does_match {
2852                                                        loop {
2853                                                            next_state_0.step_index =
2854                                                                (next_state_0.step_index)
2855                                                                    .wrapping_add(1);
2856                                                            next_step_0 =
2857                                                                &mut *((*self_0).steps.contents)
2858                                                                    .offset(
2859                                                                        next_state_0.step_index
2860                                                                            as isize,
2861                                                                    )
2862                                                                    as *mut QueryStep;
2863                                                            if (*next_step_0).depth
2864                                                                as os::raw::c_int
2865                                                                == PATTERN_DONE_MARKER
2866                                                                    as os::raw::c_int
2867                                                                || (*next_step_0).depth
2868                                                                    as os::raw::c_int
2869                                                                    <= parent_depth
2870                                                                        as os::raw::c_int
2871                                                                        + 1 as os::raw::c_int
2872                                                            {
2873                                                                break;
2874                                                            }
2875                                                        }
2876                                                    } else if successor.state as os::raw::c_int
2877                                                        == parse_state_0 as os::raw::c_int
2878                                                    {
2879                                                        continue;
2880                                                    }
2881                                                    loop {
2882                                                        if (*next_step_0).is_pass_through() {
2883                                                            next_state_0.step_index =
2884                                                                (next_state_0.step_index)
2885                                                                    .wrapping_add(1);
2886                                                            next_step_0 = next_step_0.offset(1);
2887                                                        } else {
2888                                                            if !(*next_step_0).is_dead_end() {
2889                                                                let mut did_finish_pattern: bool =
2890                                                                    (*((*self_0).steps.contents)
2891                                                                        .offset(
2892                                                                            next_state_0.step_index
2893                                                                                as isize,
2894                                                                        ))
2895                                                                    .depth
2896                                                                        as os::raw::c_int
2897                                                                        != parent_depth
2898                                                                            as os::raw::c_int
2899                                                                            + 1 as os::raw::c_int;
2900                                                                if did_finish_pattern {
2901                                                                    can_finish_pattern = true;
2902                                                                }
2903                                                                if did_finish_pattern
2904                                                                    as os::raw::c_int
2905                                                                    != 0
2906                                                                    || next_state_0.depth
2907                                                                        as os::raw::c_int
2908                                                                        == 0 as os::raw::c_int
2909                                                                {
2910                                                                    let mut index_2 : os :: raw :: c_uint = 0 ;
2911                                                                    let mut exists_6 : os :: raw :: c_uint = 0 ;
2912                                                                    index_2 = 0 as os::raw::c_int
2913                                                                        as os::raw::c_uint;
2914                                                                    exists_6 = 0 as os::raw::c_int
2915                                                                        as os::raw::c_uint;
2916                                                                    let mut size_8: u32 =
2917                                                                        (final_step_indices.size)
2918                                                                            .wrapping_sub(index_2);
2919                                                                    if !(size_8
2920                                                                        == 0 as os::raw::c_int
2921                                                                            as os::raw::c_uint)
2922                                                                    {
2923                                                                        let mut comparison_9 : os :: raw :: c_int = 0 ;
2924                                                                        while size_8
2925                                                                            > 1 as os::raw::c_int
2926                                                                                as os::raw::c_uint
2927                                                                        {
2928                                                                            let mut half_size_8 : u32 = size_8 . wrapping_div (2 as os :: raw :: c_int as os :: raw :: c_uint) ;
2929                                                                            let mut mid_index_8 : u32 = index_2 . wrapping_add (half_size_8) ;
2930                                                                            comparison_9 = * (final_step_indices . contents) . offset (mid_index_8 as isize) as os :: raw :: c_int - next_state_0 . step_index as os :: raw :: c_int ;
2931                                                                            if comparison_9 <= 0 as os :: raw :: c_int { index_2 = mid_index_8 ; }
2932                                                                            size_8 = (size_8
2933                                                                                as os::raw::c_uint)
2934                                                                                .wrapping_sub(
2935                                                                                    half_size_8,
2936                                                                                )
2937                                                                                as u32
2938                                                                                as u32;
2939                                                                        }
2940                                                                        comparison_9 = * (final_step_indices . contents) . offset (index_2 as isize) as os :: raw :: c_int - next_state_0 . step_index as os :: raw :: c_int ;
2941                                                                        if comparison_9
2942                                                                            == 0 as os::raw::c_int
2943                                                                        {
2944                                                                            exists_6 = 1
2945                                                                                as os::raw::c_int
2946                                                                                as os::raw::c_uint;
2947                                                                        } else if comparison_9
2948                                                                            < 0 as os::raw::c_int
2949                                                                        {
2950                                                                            index_2 = index_2 . wrapping_add (1 as os :: raw :: c_int as os :: raw :: c_uint) ;
2951                                                                        }
2952                                                                    }
2953                                                                    if exists_6 == 0 {
2954                                                                        array__splice (& mut final_step_indices as * mut C2RustUnnamed_18 as * mut VoidArray , :: std :: mem :: size_of :: < u16 > () as usize , index_2 , 0 as os :: raw :: c_int as u32 , 1 as os :: raw :: c_int as u32 , & mut next_state_0 . step_index as * mut u16 as * const os :: raw :: c_void ,) ;
2955                                                                    }
2956                                                                } else {
2957                                                                    analysis_state_set__insert_sorted_by_clone (& mut next_states , & mut state_pool , & mut next_state_0 ,) ;
2958                                                                }
2959                                                            }
2960                                                            if !(does_match as os::raw::c_int != 0
2961                                                                && (*next_step_0).alternative_index
2962                                                                    as os::raw::c_int
2963                                                                    != NONE as os::raw::c_int
2964                                                                && (*next_step_0).alternative_index
2965                                                                    as os::raw::c_int
2966                                                                    > next_state_0.step_index
2967                                                                        as os::raw::c_int)
2968                                                            {
2969                                                                break;
2970                                                            }
2971                                                            next_state_0.step_index =
2972                                                                (*next_step_0).alternative_index;
2973                                                            next_step_0 =
2974                                                                &mut *((*self_0).steps.contents)
2975                                                                    .offset(
2976                                                                        next_state_0.step_index
2977                                                                            as isize,
2978                                                                    )
2979                                                                    as *mut QueryStep;
2980                                                        }
2981                                                    }
2982                                                }
2983                                            }
2984                                        }
2985                                    }
2986                                    _ => {}
2987                                }
2988                                j_2 = j_2.wrapping_add(1);
2989                            }
2990                            let mut _states_0: AnalysisStateSet = states;
2991                            states = next_states;
2992                            next_states = _states_0;
2993                        }
2994                        iteration = iteration.wrapping_add(1);
2995                    }
2996                }
2997                if did_abort_analysis {
2998                    let mut j_3: os::raw::c_uint = (parent_step_index_0 as os::raw::c_int
2999                        + 1 as os::raw::c_int)
3000                        as os::raw::c_uint;
3001                    while j_3 < (*self_0).steps.size {
3002                        let mut step_1: *mut QueryStep =
3003                            &mut *((*self_0).steps.contents).offset(j_3 as isize) as *mut QueryStep;
3004                        if (*step_1).depth as os::raw::c_int <= parent_depth as os::raw::c_int
3005                            || (*step_1).depth as os::raw::c_int
3006                                == PATTERN_DONE_MARKER as os::raw::c_int
3007                        {
3008                            break;
3009                        }
3010                        if !(*step_1).is_dead_end() {
3011                            (*step_1).set_parent_pattern_guaranteed(0 as os::raw::c_int != 0);
3012                            (*step_1).set_root_pattern_guaranteed(0 as os::raw::c_int != 0);
3013                        }
3014                        j_3 = j_3.wrapping_add(1);
3015                    }
3016                } else if !can_finish_pattern {
3017                    if final_step_indices.size > 0 as os::raw::c_int as os::raw::c_uint {
3018                    } else {
3019                        panic!();
3020                    }
3021                    if (final_step_indices.size)
3022                        .wrapping_sub(1 as os::raw::c_int as os::raw::c_uint)
3023                        < final_step_indices.size
3024                    {
3025                    } else {
3026                        panic!();
3027                    }
3028                    let mut impossible_step_index: u16 = *(&mut *(final_step_indices.contents)
3029                        .offset(
3030                            (final_step_indices.size)
3031                                .wrapping_sub(1 as os::raw::c_int as os::raw::c_uint)
3032                                as isize,
3033                        ) as *mut u16);
3034                    let mut i_5: u32 = 0;
3035                    let mut exists_7: u32 = 0;
3036                    i_5 = 0 as os::raw::c_int as u32;
3037                    exists_7 = 0 as os::raw::c_int as u32;
3038                    let mut size_9: u32 = ((*self_0).step_offsets.size).wrapping_sub(i_5);
3039                    if !(size_9 == 0 as os::raw::c_int as os::raw::c_uint) {
3040                        let mut comparison_10: os::raw::c_int = 0;
3041                        while size_9 > 1 as os::raw::c_int as os::raw::c_uint {
3042                            let mut half_size_9: u32 =
3043                                size_9.wrapping_div(2 as os::raw::c_int as os::raw::c_uint);
3044                            let mut mid_index_9: u32 = i_5.wrapping_add(half_size_9);
3045                            comparison_10 =
3046                                (*((*self_0).step_offsets.contents).offset(mid_index_9 as isize))
3047                                    .step_index as os::raw::c_int
3048                                    - impossible_step_index as os::raw::c_int;
3049                            if comparison_10 <= 0 as os::raw::c_int {
3050                                i_5 = mid_index_9;
3051                            }
3052                            size_9 =
3053                                (size_9 as os::raw::c_uint).wrapping_sub(half_size_9) as u32 as u32;
3054                        }
3055                        comparison_10 = (*((*self_0).step_offsets.contents).offset(i_5 as isize))
3056                            .step_index as os::raw::c_int
3057                            - impossible_step_index as os::raw::c_int;
3058                        if comparison_10 == 0 as os::raw::c_int {
3059                            exists_7 = 1 as os::raw::c_int as u32;
3060                        } else if comparison_10 < 0 as os::raw::c_int {
3061                            i_5 = (i_5 as os::raw::c_uint)
3062                                .wrapping_add(1 as os::raw::c_int as os::raw::c_uint)
3063                                as u32 as u32;
3064                        }
3065                    }
3066                    if i_5 >= (*self_0).step_offsets.size {
3067                        i_5 = ((*self_0).step_offsets.size)
3068                            .wrapping_sub(1 as os::raw::c_int as os::raw::c_uint);
3069                    }
3070                    *error_offset =
3071                        (*((*self_0).step_offsets.contents).offset(i_5 as isize)).byte_offset;
3072                    all_patterns_are_valid = false;
3073                    break;
3074                } else {
3075                    let mut j_4: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
3076                    while j_4 < final_step_indices.size {
3077                        let mut final_step_index: u32 =
3078                            *(final_step_indices.contents).offset(j_4 as isize) as u32;
3079                        let mut step_2: *mut QueryStep = &mut *((*self_0).steps.contents)
3080                            .offset(final_step_index as isize)
3081                            as *mut QueryStep;
3082                        if (*step_2).depth as os::raw::c_int
3083                            != PATTERN_DONE_MARKER as os::raw::c_int
3084                            && (*step_2).depth as os::raw::c_int > parent_depth as os::raw::c_int
3085                            && !(*step_2).is_dead_end()
3086                        {
3087                            (*step_2).set_parent_pattern_guaranteed(0 as os::raw::c_int != 0);
3088                            (*step_2).set_root_pattern_guaranteed(0 as os::raw::c_int != 0);
3089                        }
3090                        j_4 = j_4.wrapping_add(1);
3091                    }
3092                }
3093            }
3094        }
3095        i_3 = i_3.wrapping_add(1);
3096    }
3097    let mut predicate_capture_ids: C2RustUnnamed_16 = {
3098        let mut init = C2RustUnnamed_16 {
3099            contents: 0 as *mut u16,
3100            size: 0 as os::raw::c_int as u32,
3101            capacity: 0 as os::raw::c_int as u32,
3102        };
3103        init
3104    };
3105    let mut i_6: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
3106    while i_6 < (*self_0).patterns.size {
3107        let mut pattern: *mut QueryPattern =
3108            &mut *((*self_0).patterns.contents).offset(i_6 as isize) as *mut QueryPattern;
3109        predicate_capture_ids.size = 0 as os::raw::c_int as u32;
3110        let mut start: os::raw::c_uint = (*pattern).predicate_steps.offset;
3111        let mut end: os::raw::c_uint = start.wrapping_add((*pattern).predicate_steps.length);
3112        let mut j_5: os::raw::c_uint = start;
3113        while j_5 < end {
3114            let mut step_3: *mut TSQueryPredicateStep = &mut *((*self_0).predicate_steps.contents)
3115                .offset(j_5 as isize)
3116                as *mut TSQueryPredicateStep;
3117            if (*step_3).type_ as os::raw::c_uint
3118                == TSQueryPredicateStepTypeCapture as os::raw::c_int as os::raw::c_uint
3119            {
3120                let mut index_3: os::raw::c_uint = 0;
3121                let mut exists_8: os::raw::c_uint = 0;
3122                index_3 = 0 as os::raw::c_int as os::raw::c_uint;
3123                exists_8 = 0 as os::raw::c_int as os::raw::c_uint;
3124                let mut size_10: u32 = (predicate_capture_ids.size).wrapping_sub(index_3);
3125                if !(size_10 == 0 as os::raw::c_int as os::raw::c_uint) {
3126                    let mut comparison_11: os::raw::c_int = 0;
3127                    while size_10 > 1 as os::raw::c_int as os::raw::c_uint {
3128                        let mut half_size_10: u32 =
3129                            size_10.wrapping_div(2 as os::raw::c_int as os::raw::c_uint);
3130                        let mut mid_index_10: u32 = index_3.wrapping_add(half_size_10);
3131                        comparison_11 = *(predicate_capture_ids.contents)
3132                            .offset(mid_index_10 as isize)
3133                            as os::raw::c_int
3134                            - (*step_3).value_id as os::raw::c_int;
3135                        if comparison_11 <= 0 as os::raw::c_int {
3136                            index_3 = mid_index_10;
3137                        }
3138                        size_10 =
3139                            (size_10 as os::raw::c_uint).wrapping_sub(half_size_10) as u32 as u32;
3140                    }
3141                    comparison_11 = *(predicate_capture_ids.contents).offset(index_3 as isize)
3142                        as os::raw::c_int
3143                        - (*step_3).value_id as os::raw::c_int;
3144                    if comparison_11 == 0 as os::raw::c_int {
3145                        exists_8 = 1 as os::raw::c_int as os::raw::c_uint;
3146                    } else if comparison_11 < 0 as os::raw::c_int {
3147                        index_3 = index_3.wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
3148                    }
3149                }
3150                if exists_8 == 0 {
3151                    array__splice(
3152                        &mut predicate_capture_ids as *mut C2RustUnnamed_16 as *mut VoidArray,
3153                        ::std::mem::size_of::<u16>() as usize,
3154                        index_3,
3155                        0 as os::raw::c_int as u32,
3156                        1 as os::raw::c_int as u32,
3157                        &mut (*step_3).value_id as *mut u32 as *const os::raw::c_void,
3158                    );
3159                }
3160            }
3161            j_5 = j_5.wrapping_add(1);
3162        }
3163        let mut start_0: os::raw::c_uint = (*pattern).steps.offset;
3164        let mut end_0: os::raw::c_uint = start_0.wrapping_add((*pattern).steps.length);
3165        let mut j_6: os::raw::c_uint = start_0;
3166        while j_6 < end_0 {
3167            let mut step_4: *mut QueryStep =
3168                &mut *((*self_0).steps.contents).offset(j_6 as isize) as *mut QueryStep;
3169            let mut k: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
3170            while k < 3 as os::raw::c_int as os::raw::c_uint {
3171                let mut capture_id: u16 = (*step_4).capture_ids[k as usize];
3172                if capture_id as os::raw::c_int == NONE as os::raw::c_int {
3173                    break;
3174                }
3175                let mut index_4: os::raw::c_uint = 0;
3176                let mut exists_9: os::raw::c_uint = 0;
3177                index_4 = 0 as os::raw::c_int as os::raw::c_uint;
3178                exists_9 = 0 as os::raw::c_int as os::raw::c_uint;
3179                let mut size_11: u32 = (predicate_capture_ids.size).wrapping_sub(index_4);
3180                if !(size_11 == 0 as os::raw::c_int as os::raw::c_uint) {
3181                    let mut comparison_12: os::raw::c_int = 0;
3182                    while size_11 > 1 as os::raw::c_int as os::raw::c_uint {
3183                        let mut half_size_11: u32 =
3184                            size_11.wrapping_div(2 as os::raw::c_int as os::raw::c_uint);
3185                        let mut mid_index_11: u32 = index_4.wrapping_add(half_size_11);
3186                        comparison_12 = *(predicate_capture_ids.contents)
3187                            .offset(mid_index_11 as isize)
3188                            as os::raw::c_int
3189                            - capture_id as os::raw::c_int;
3190                        if comparison_12 <= 0 as os::raw::c_int {
3191                            index_4 = mid_index_11;
3192                        }
3193                        size_11 =
3194                            (size_11 as os::raw::c_uint).wrapping_sub(half_size_11) as u32 as u32;
3195                    }
3196                    comparison_12 = *(predicate_capture_ids.contents).offset(index_4 as isize)
3197                        as os::raw::c_int
3198                        - capture_id as os::raw::c_int;
3199                    if comparison_12 == 0 as os::raw::c_int {
3200                        exists_9 = 1 as os::raw::c_int as os::raw::c_uint;
3201                    } else if comparison_12 < 0 as os::raw::c_int {
3202                        index_4 = index_4.wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
3203                    }
3204                }
3205                if exists_9 != 0 {
3206                    (*step_4).set_root_pattern_guaranteed(0 as os::raw::c_int != 0);
3207                    break;
3208                } else {
3209                    k = k.wrapping_add(1);
3210                }
3211            }
3212            j_6 = j_6.wrapping_add(1);
3213        }
3214        i_6 = i_6.wrapping_add(1);
3215    }
3216    let mut done: bool = (*self_0).steps.size == 0 as os::raw::c_int as os::raw::c_uint;
3217    while !done {
3218        done = true;
3219        let mut i_7: os::raw::c_uint =
3220            ((*self_0).steps.size).wrapping_sub(1 as os::raw::c_int as os::raw::c_uint);
3221        while i_7 > 0 as os::raw::c_int as os::raw::c_uint {
3222            let mut step_5: *mut QueryStep =
3223                &mut *((*self_0).steps.contents).offset(i_7 as isize) as *mut QueryStep;
3224            if !((*step_5).depth as os::raw::c_int == PATTERN_DONE_MARKER as os::raw::c_int) {
3225                let mut parent_pattern_guaranteed: bool = false;
3226                loop {
3227                    if (*step_5).root_pattern_guaranteed() {
3228                        parent_pattern_guaranteed = true;
3229                        break;
3230                    } else {
3231                        if (*step_5).alternative_index as os::raw::c_int == NONE as os::raw::c_int
3232                            || ((*step_5).alternative_index as os::raw::c_uint) < i_7
3233                        {
3234                            break;
3235                        }
3236                        step_5 = &mut *((*self_0).steps.contents)
3237                            .offset((*step_5).alternative_index as isize)
3238                            as *mut QueryStep;
3239                    }
3240                }
3241                if !parent_pattern_guaranteed {
3242                    let mut prev_step: *mut QueryStep = &mut *((*self_0).steps.contents)
3243                        .offset(i_7.wrapping_sub(1 as os::raw::c_int as os::raw::c_uint) as isize)
3244                        as *mut QueryStep;
3245                    if !(*prev_step).is_dead_end()
3246                        && (*prev_step).depth as os::raw::c_int
3247                            != PATTERN_DONE_MARKER as os::raw::c_int
3248                        && (*prev_step).root_pattern_guaranteed() as os::raw::c_int != 0
3249                    {
3250                        (*prev_step).set_root_pattern_guaranteed(0 as os::raw::c_int != 0);
3251                        done = false;
3252                    }
3253                }
3254            }
3255            i_7 = i_7.wrapping_sub(1);
3256        }
3257    }
3258    let mut i_8: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
3259    while i_8 < subgraphs.size {
3260        array__delete(
3261            &mut (*(subgraphs.contents).offset(i_8 as isize)).start_states as *mut C2RustUnnamed_22
3262                as *mut VoidArray,
3263        );
3264        array__delete(
3265            &mut (*(subgraphs.contents).offset(i_8 as isize)).nodes as *mut C2RustUnnamed_21
3266                as *mut VoidArray,
3267        );
3268        i_8 = i_8.wrapping_add(1);
3269    }
3270    array__delete(&mut subgraphs as *mut C2RustUnnamed_20 as *mut VoidArray);
3271    let mut i_9: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
3272    while i_9 < state_pool.size {
3273        crate::alloc::ts_free(*(state_pool.contents).offset(i_9 as isize) as *mut os::raw::c_void);
3274        i_9 = i_9.wrapping_add(1);
3275    }
3276    array__delete(&mut state_pool as *mut AnalysisStatePool as *mut VoidArray);
3277    array__delete(&mut next_nodes as *mut C2RustUnnamed_19 as *mut VoidArray);
3278    analysis_state_set__delete(&mut states);
3279    analysis_state_set__delete(&mut next_states);
3280    analysis_state_set__delete(&mut deeper_states);
3281    array__delete(&mut final_step_indices as *mut C2RustUnnamed_18 as *mut VoidArray);
3282    array__delete(&mut parent_step_indices as *mut C2RustUnnamed_17 as *mut VoidArray);
3283    array__delete(&mut predicate_capture_ids as *mut C2RustUnnamed_16 as *mut VoidArray);
3284    state_predecessor_map_delete(&mut predecessor_map);
3285    return all_patterns_are_valid;
3286}
3287unsafe extern "C" fn ts_query__add_negated_fields(
3288    mut self_0: *mut TSQuery,
3289    mut step_index: u16,
3290    mut field_ids: *mut TSFieldId,
3291    mut field_count: u16,
3292) {
3293    let mut step: *mut QueryStep =
3294        &mut *((*self_0).steps.contents).offset(step_index as isize) as *mut QueryStep;
3295    let mut failed_match: bool = false;
3296    let mut match_count: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
3297    let mut start_i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
3298    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
3299    while i < (*self_0).negated_fields.size {
3300        let mut existing_field_id: TSFieldId =
3301            *((*self_0).negated_fields.contents).offset(i as isize);
3302        if existing_field_id as os::raw::c_int == 0 as os::raw::c_int {
3303            if match_count == field_count as os::raw::c_uint {
3304                (*step).negated_field_list_id = start_i as u16;
3305                return;
3306            } else {
3307                start_i = i.wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
3308                match_count = 0 as os::raw::c_int as os::raw::c_uint;
3309                failed_match = false;
3310            }
3311        } else if match_count < field_count as os::raw::c_uint
3312            && existing_field_id as os::raw::c_int
3313                == *field_ids.offset(match_count as isize) as os::raw::c_int
3314            && !failed_match
3315        {
3316            match_count = match_count.wrapping_add(1);
3317        } else {
3318            match_count = 0 as os::raw::c_int as os::raw::c_uint;
3319            failed_match = true;
3320        }
3321        i = i.wrapping_add(1);
3322    }
3323    (*step).negated_field_list_id = (*self_0).negated_fields.size as u16;
3324    array__splice(
3325        &mut (*self_0).negated_fields as *mut C2RustUnnamed_4 as *mut VoidArray,
3326        ::std::mem::size_of::<TSFieldId>() as usize,
3327        (*self_0).negated_fields.size,
3328        0 as os::raw::c_int as u32,
3329        field_count as u32,
3330        field_ids as *const os::raw::c_void,
3331    );
3332    array__grow(
3333        &mut (*self_0).negated_fields as *mut C2RustUnnamed_4 as *mut VoidArray,
3334        1 as os::raw::c_int as size_t,
3335        ::std::mem::size_of::<TSFieldId>() as usize,
3336    );
3337    let ref mut fresh41 = (*self_0).negated_fields.size;
3338    let fresh42 = *fresh41;
3339    *fresh41 = (*fresh41).wrapping_add(1);
3340    *((*self_0).negated_fields.contents).offset(fresh42 as isize) =
3341        0 as os::raw::c_int as TSFieldId;
3342}
3343unsafe extern "C" fn ts_query__parse_string_literal(
3344    mut self_0: *mut TSQuery,
3345    mut stream: *mut Stream,
3346) -> TSQueryError {
3347    let mut string_start: *const os::raw::c_char = (*stream).input;
3348    if (*stream).next != '"' as i32 {
3349        return TSQueryErrorSyntax;
3350    }
3351    stream_advance(stream);
3352    let mut prev_position: *const os::raw::c_char = (*stream).input;
3353    let mut is_escaped: bool = false;
3354    (*self_0).string_buffer.size = 0 as os::raw::c_int as u32;
3355    loop {
3356        if is_escaped {
3357            is_escaped = false;
3358            match (*stream).next {
3359                110 => {
3360                    array__grow(
3361                        &mut (*self_0).string_buffer as *mut C2RustUnnamed_3 as *mut VoidArray,
3362                        1 as os::raw::c_int as size_t,
3363                        ::std::mem::size_of::<os::raw::c_char>() as usize,
3364                    );
3365                    let ref mut fresh43 = (*self_0).string_buffer.size;
3366                    let fresh44 = *fresh43;
3367                    *fresh43 = (*fresh43).wrapping_add(1);
3368                    *((*self_0).string_buffer.contents).offset(fresh44 as isize) =
3369                        '\n' as i32 as os::raw::c_char;
3370                }
3371                114 => {
3372                    array__grow(
3373                        &mut (*self_0).string_buffer as *mut C2RustUnnamed_3 as *mut VoidArray,
3374                        1 as os::raw::c_int as size_t,
3375                        ::std::mem::size_of::<os::raw::c_char>() as usize,
3376                    );
3377                    let ref mut fresh45 = (*self_0).string_buffer.size;
3378                    let fresh46 = *fresh45;
3379                    *fresh45 = (*fresh45).wrapping_add(1);
3380                    *((*self_0).string_buffer.contents).offset(fresh46 as isize) =
3381                        '\r' as i32 as os::raw::c_char;
3382                }
3383                116 => {
3384                    array__grow(
3385                        &mut (*self_0).string_buffer as *mut C2RustUnnamed_3 as *mut VoidArray,
3386                        1 as os::raw::c_int as size_t,
3387                        ::std::mem::size_of::<os::raw::c_char>() as usize,
3388                    );
3389                    let ref mut fresh47 = (*self_0).string_buffer.size;
3390                    let fresh48 = *fresh47;
3391                    *fresh47 = (*fresh47).wrapping_add(1);
3392                    *((*self_0).string_buffer.contents).offset(fresh48 as isize) =
3393                        '\t' as i32 as os::raw::c_char;
3394                }
3395                48 => {
3396                    array__grow(
3397                        &mut (*self_0).string_buffer as *mut C2RustUnnamed_3 as *mut VoidArray,
3398                        1 as os::raw::c_int as size_t,
3399                        ::std::mem::size_of::<os::raw::c_char>() as usize,
3400                    );
3401                    let ref mut fresh49 = (*self_0).string_buffer.size;
3402                    let fresh50 = *fresh49;
3403                    *fresh49 = (*fresh49).wrapping_add(1);
3404                    *((*self_0).string_buffer.contents).offset(fresh50 as isize) =
3405                        '\0' as i32 as os::raw::c_char;
3406                }
3407                _ => {
3408                    array__splice(
3409                        &mut (*self_0).string_buffer as *mut C2RustUnnamed_3 as *mut VoidArray,
3410                        ::std::mem::size_of::<os::raw::c_char>() as usize,
3411                        (*self_0).string_buffer.size,
3412                        0 as os::raw::c_int as u32,
3413                        (*stream).next_size as u32,
3414                        (*stream).input as *const os::raw::c_void,
3415                    );
3416                }
3417            }
3418            prev_position =
3419                ((*stream).input).offset((*stream).next_size as os::raw::c_int as isize);
3420        } else if (*stream).next == '\\' as i32 {
3421            array__splice(
3422                &mut (*self_0).string_buffer as *mut C2RustUnnamed_3 as *mut VoidArray,
3423                ::std::mem::size_of::<os::raw::c_char>() as usize,
3424                (*self_0).string_buffer.size,
3425                0 as os::raw::c_int as u32,
3426                ((*stream).input).offset_from(prev_position) as isize as u32,
3427                prev_position as *const os::raw::c_void,
3428            );
3429            prev_position = ((*stream).input).offset(1 as os::raw::c_int as isize);
3430            is_escaped = true;
3431        } else if (*stream).next == '"' as i32 {
3432            array__splice(
3433                &mut (*self_0).string_buffer as *mut C2RustUnnamed_3 as *mut VoidArray,
3434                ::std::mem::size_of::<os::raw::c_char>() as usize,
3435                (*self_0).string_buffer.size,
3436                0 as os::raw::c_int as u32,
3437                ((*stream).input).offset_from(prev_position) as isize as u32,
3438                prev_position as *const os::raw::c_void,
3439            );
3440            stream_advance(stream);
3441            return TSQueryErrorNone;
3442        } else {
3443            if (*stream).next == '\n' as i32 {
3444                stream_reset(stream, string_start);
3445                return TSQueryErrorSyntax;
3446            }
3447        }
3448        if !stream_advance(stream) {
3449            stream_reset(stream, string_start);
3450            return TSQueryErrorSyntax;
3451        }
3452    }
3453}
3454unsafe extern "C" fn ts_query__parse_predicate(
3455    mut self_0: *mut TSQuery,
3456    mut stream: *mut Stream,
3457) -> TSQueryError {
3458    if !stream_is_ident_start(stream) {
3459        return TSQueryErrorSyntax;
3460    }
3461    let mut predicate_name: *const os::raw::c_char = (*stream).input;
3462    stream_scan_identifier(stream);
3463    let mut length: u32 = ((*stream).input).offset_from(predicate_name) as isize as u32;
3464    let mut id: u16 =
3465        symbol_table_insert_name(&mut (*self_0).predicate_values, predicate_name, length);
3466    array__grow(
3467        &mut (*self_0).predicate_steps as *mut C2RustUnnamed_7 as *mut VoidArray,
3468        1 as os::raw::c_int as size_t,
3469        ::std::mem::size_of::<TSQueryPredicateStep>() as usize,
3470    );
3471    let ref mut fresh51 = (*self_0).predicate_steps.size;
3472    let fresh52 = *fresh51;
3473    *fresh51 = (*fresh51).wrapping_add(1);
3474    *((*self_0).predicate_steps.contents).offset(fresh52 as isize) = {
3475        let mut init = TSQueryPredicateStep {
3476            type_: TSQueryPredicateStepTypeString,
3477            value_id: id as u32,
3478        };
3479        init
3480    };
3481    stream_skip_whitespace(stream);
3482    loop {
3483        if (*stream).next == ')' as i32 {
3484            stream_advance(stream);
3485            stream_skip_whitespace(stream);
3486            array__grow(
3487                &mut (*self_0).predicate_steps as *mut C2RustUnnamed_7 as *mut VoidArray,
3488                1 as os::raw::c_int as size_t,
3489                ::std::mem::size_of::<TSQueryPredicateStep>() as usize,
3490            );
3491            let ref mut fresh53 = (*self_0).predicate_steps.size;
3492            let fresh54 = *fresh53;
3493            *fresh53 = (*fresh53).wrapping_add(1);
3494            *((*self_0).predicate_steps.contents).offset(fresh54 as isize) = {
3495                let mut init = TSQueryPredicateStep {
3496                    type_: TSQueryPredicateStepTypeDone,
3497                    value_id: 0 as os::raw::c_int as u32,
3498                };
3499                init
3500            };
3501            break;
3502        } else {
3503            if (*stream).next == '@' as i32 {
3504                stream_advance(stream);
3505                if !stream_is_ident_start(stream) {
3506                    return TSQueryErrorSyntax;
3507                }
3508                let mut capture_name: *const os::raw::c_char = (*stream).input;
3509                stream_scan_identifier(stream);
3510                let mut length_0: u32 = ((*stream).input).offset_from(capture_name) as isize as u32;
3511                let mut capture_id: os::raw::c_int =
3512                    symbol_table_id_for_name(&mut (*self_0).captures, capture_name, length_0);
3513                if capture_id == -(1 as os::raw::c_int) {
3514                    stream_reset(stream, capture_name);
3515                    return TSQueryErrorCapture;
3516                }
3517                array__grow(
3518                    &mut (*self_0).predicate_steps as *mut C2RustUnnamed_7 as *mut VoidArray,
3519                    1 as os::raw::c_int as size_t,
3520                    ::std::mem::size_of::<TSQueryPredicateStep>() as usize,
3521                );
3522                let ref mut fresh55 = (*self_0).predicate_steps.size;
3523                let fresh56 = *fresh55;
3524                *fresh55 = (*fresh55).wrapping_add(1);
3525                *((*self_0).predicate_steps.contents).offset(fresh56 as isize) = {
3526                    let mut init = TSQueryPredicateStep {
3527                        type_: TSQueryPredicateStepTypeCapture,
3528                        value_id: capture_id as u32,
3529                    };
3530                    init
3531                };
3532            } else if (*stream).next == '"' as i32 {
3533                let mut e: TSQueryError = ts_query__parse_string_literal(self_0, stream);
3534                if e as u64 != 0 {
3535                    return e;
3536                }
3537                let mut id_0: u16 = symbol_table_insert_name(
3538                    &mut (*self_0).predicate_values,
3539                    (*self_0).string_buffer.contents,
3540                    (*self_0).string_buffer.size,
3541                );
3542                array__grow(
3543                    &mut (*self_0).predicate_steps as *mut C2RustUnnamed_7 as *mut VoidArray,
3544                    1 as os::raw::c_int as size_t,
3545                    ::std::mem::size_of::<TSQueryPredicateStep>() as usize,
3546                );
3547                let ref mut fresh57 = (*self_0).predicate_steps.size;
3548                let fresh58 = *fresh57;
3549                *fresh57 = (*fresh57).wrapping_add(1);
3550                *((*self_0).predicate_steps.contents).offset(fresh58 as isize) = {
3551                    let mut init = TSQueryPredicateStep {
3552                        type_: TSQueryPredicateStepTypeString,
3553                        value_id: id_0 as u32,
3554                    };
3555                    init
3556                };
3557            } else if stream_is_ident_start(stream) {
3558                let mut symbol_start: *const os::raw::c_char = (*stream).input;
3559                stream_scan_identifier(stream);
3560                let mut length_1: u32 = ((*stream).input).offset_from(symbol_start) as isize as u32;
3561                let mut id_1: u16 = symbol_table_insert_name(
3562                    &mut (*self_0).predicate_values,
3563                    symbol_start,
3564                    length_1,
3565                );
3566                array__grow(
3567                    &mut (*self_0).predicate_steps as *mut C2RustUnnamed_7 as *mut VoidArray,
3568                    1 as os::raw::c_int as size_t,
3569                    ::std::mem::size_of::<TSQueryPredicateStep>() as usize,
3570                );
3571                let ref mut fresh59 = (*self_0).predicate_steps.size;
3572                let fresh60 = *fresh59;
3573                *fresh59 = (*fresh59).wrapping_add(1);
3574                *((*self_0).predicate_steps.contents).offset(fresh60 as isize) = {
3575                    let mut init = TSQueryPredicateStep {
3576                        type_: TSQueryPredicateStepTypeString,
3577                        value_id: id_1 as u32,
3578                    };
3579                    init
3580                };
3581            } else {
3582                return TSQueryErrorSyntax;
3583            }
3584            stream_skip_whitespace(stream);
3585        }
3586    }
3587    return TSQueryErrorNone;
3588}
3589unsafe extern "C" fn ts_query__parse_pattern(
3590    mut self_0: *mut TSQuery,
3591    mut stream: *mut Stream,
3592    mut depth: u32,
3593    mut is_immediate: bool,
3594    mut capture_quantifiers: *mut CaptureQuantifiers,
3595) -> TSQueryError {
3596    if (*stream).next == 0 as os::raw::c_int {
3597        return TSQueryErrorSyntax;
3598    }
3599    if (*stream).next == ')' as i32 || (*stream).next == ']' as i32 {
3600        return PARENT_DONE;
3601    }
3602    let starting_step_index: u32 = (*self_0).steps.size;
3603    if (*self_0).step_offsets.size == 0 as os::raw::c_int as os::raw::c_uint || {
3604        if ((*self_0).step_offsets.size).wrapping_sub(1 as os::raw::c_int as os::raw::c_uint)
3605            < (*self_0).step_offsets.size
3606        {
3607        } else {
3608            panic!();
3609        }
3610        (*(&mut *((*self_0).step_offsets.contents).offset(
3611            ((*self_0).step_offsets.size).wrapping_sub(1 as os::raw::c_int as os::raw::c_uint)
3612                as isize,
3613        ) as *mut StepOffset))
3614            .step_index as os::raw::c_uint
3615            != starting_step_index
3616    } {
3617        array__grow(
3618            &mut (*self_0).step_offsets as *mut C2RustUnnamed_5 as *mut VoidArray,
3619            1 as os::raw::c_int as size_t,
3620            ::std::mem::size_of::<StepOffset>() as usize,
3621        );
3622        let ref mut fresh61 = (*self_0).step_offsets.size;
3623        let fresh62 = *fresh61;
3624        *fresh61 = (*fresh61).wrapping_add(1);
3625        *((*self_0).step_offsets.contents).offset(fresh62 as isize) = {
3626            let mut init = StepOffset {
3627                byte_offset: stream_offset(stream),
3628                step_index: starting_step_index as u16,
3629            };
3630            init
3631        };
3632    }
3633    if (*stream).next == '[' as i32 {
3634        stream_advance(stream);
3635        stream_skip_whitespace(stream);
3636        let mut branch_step_indices: C2RustUnnamed_23 = {
3637            let mut init = C2RustUnnamed_23 {
3638                contents: 0 as *mut u32,
3639                size: 0 as os::raw::c_int as u32,
3640                capacity: 0 as os::raw::c_int as u32,
3641            };
3642            init
3643        };
3644        let mut branch_capture_quantifiers: CaptureQuantifiers = capture_quantifiers_new();
3645        loop {
3646            let mut start_index: u32 = (*self_0).steps.size;
3647            let mut e: TSQueryError = ts_query__parse_pattern(
3648                self_0,
3649                stream,
3650                depth,
3651                is_immediate,
3652                &mut branch_capture_quantifiers,
3653            );
3654            if e as os::raw::c_uint == PARENT_DONE as os::raw::c_uint {
3655                if (*stream).next == ']' as i32
3656                    && branch_step_indices.size > 0 as os::raw::c_int as os::raw::c_uint
3657                {
3658                    stream_advance(stream);
3659                    break;
3660                } else {
3661                    e = TSQueryErrorSyntax;
3662                }
3663            }
3664            if e as u64 != 0 {
3665                capture_quantifiers_delete(&mut branch_capture_quantifiers);
3666                array__delete(&mut branch_step_indices as *mut C2RustUnnamed_23 as *mut VoidArray);
3667                return e;
3668            }
3669            if start_index == starting_step_index {
3670                capture_quantifiers_replace(capture_quantifiers, &mut branch_capture_quantifiers);
3671            } else {
3672                capture_quantifiers_join_all(capture_quantifiers, &mut branch_capture_quantifiers);
3673            }
3674            array__grow(
3675                &mut branch_step_indices as *mut C2RustUnnamed_23 as *mut VoidArray,
3676                1 as os::raw::c_int as size_t,
3677                ::std::mem::size_of::<u32>() as usize,
3678            );
3679            let fresh63 = branch_step_indices.size;
3680            branch_step_indices.size = (branch_step_indices.size).wrapping_add(1);
3681            *(branch_step_indices.contents).offset(fresh63 as isize) = start_index;
3682            array__grow(
3683                &mut (*self_0).steps as *mut C2RustUnnamed_9 as *mut VoidArray,
3684                1 as os::raw::c_int as size_t,
3685                ::std::mem::size_of::<QueryStep>() as usize,
3686            );
3687            let ref mut fresh64 = (*self_0).steps.size;
3688            let fresh65 = *fresh64;
3689            *fresh64 = (*fresh64).wrapping_add(1);
3690            *((*self_0).steps.contents).offset(fresh65 as isize) =
3691                query_step__new(0 as os::raw::c_int as TSSymbol, depth as u16, false);
3692            capture_quantifiers_clear(&mut branch_capture_quantifiers);
3693        }
3694        let ref mut fresh66 = (*self_0).steps.size;
3695        *fresh66 = (*fresh66).wrapping_sub(1);
3696        let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
3697        while i < (branch_step_indices.size).wrapping_sub(1 as os::raw::c_int as os::raw::c_uint) {
3698            let mut step_index: u32 = *(branch_step_indices.contents).offset(i as isize);
3699            let mut next_step_index: u32 = *(branch_step_indices.contents)
3700                .offset(i.wrapping_add(1 as os::raw::c_int as os::raw::c_uint) as isize);
3701            let mut start_step: *mut QueryStep =
3702                &mut *((*self_0).steps.contents).offset(step_index as isize) as *mut QueryStep;
3703            let mut end_step: *mut QueryStep = &mut *((*self_0).steps.contents).offset(
3704                next_step_index.wrapping_sub(1 as os::raw::c_int as os::raw::c_uint) as isize,
3705            ) as *mut QueryStep;
3706            (*start_step).alternative_index = next_step_index as u16;
3707            (*end_step).alternative_index = (*self_0).steps.size as u16;
3708            (*end_step).set_is_dead_end(1 as os::raw::c_int != 0);
3709            i = i.wrapping_add(1);
3710        }
3711        capture_quantifiers_delete(&mut branch_capture_quantifiers);
3712        array__delete(&mut branch_step_indices as *mut C2RustUnnamed_23 as *mut VoidArray);
3713    } else if (*stream).next == '(' as i32 {
3714        stream_advance(stream);
3715        stream_skip_whitespace(stream);
3716        if (*stream).next == '(' as i32
3717            || (*stream).next == '"' as i32
3718            || (*stream).next == '[' as i32
3719        {
3720            let mut child_is_immediate: bool = false;
3721            let mut child_capture_quantifiers: CaptureQuantifiers = capture_quantifiers_new();
3722            loop {
3723                if (*stream).next == '.' as i32 {
3724                    child_is_immediate = true;
3725                    stream_advance(stream);
3726                    stream_skip_whitespace(stream);
3727                }
3728                let mut e_0: TSQueryError = ts_query__parse_pattern(
3729                    self_0,
3730                    stream,
3731                    depth,
3732                    child_is_immediate,
3733                    &mut child_capture_quantifiers,
3734                );
3735                if e_0 as os::raw::c_uint == PARENT_DONE as os::raw::c_uint {
3736                    if (*stream).next == ')' as i32 {
3737                        stream_advance(stream);
3738                        break;
3739                    } else {
3740                        e_0 = TSQueryErrorSyntax;
3741                    }
3742                }
3743                if e_0 as u64 != 0 {
3744                    capture_quantifiers_delete(&mut child_capture_quantifiers);
3745                    return e_0;
3746                }
3747                capture_quantifiers_add_all(capture_quantifiers, &mut child_capture_quantifiers);
3748                capture_quantifiers_clear(&mut child_capture_quantifiers);
3749                child_is_immediate = false;
3750            }
3751            capture_quantifiers_delete(&mut child_capture_quantifiers);
3752        } else if (*stream).next == '.' as i32 || (*stream).next == '#' as i32 {
3753            stream_advance(stream);
3754            return ts_query__parse_predicate(self_0, stream);
3755        } else {
3756            let mut symbol: TSSymbol = 0;
3757            if stream_is_ident_start(stream) {
3758                let mut node_name: *const os::raw::c_char = (*stream).input;
3759                stream_scan_identifier(stream);
3760                let mut length: u32 = ((*stream).input).offset_from(node_name) as isize as u32;
3761                if length > 0 as os :: raw :: c_int as os :: raw :: c_uint && (* node_name . offset (length . wrapping_sub (1 as os :: raw :: c_int as os :: raw :: c_uint) as isize ,) as os :: raw :: c_int == '!' as i32 || * node_name . offset (length . wrapping_sub (1 as os :: raw :: c_int as os :: raw :: c_uint) as isize ,) as os :: raw :: c_int == '?' as i32) { stream_reset (stream , node_name) ; return ts_query__parse_predicate (self_0 , stream) ; } else { if length == 1 as os :: raw :: c_int as os :: raw :: c_uint && * node_name . offset (0 as os :: raw :: c_int as isize) as os :: raw :: c_int == '_' as i32 { symbol = WILDCARD_SYMBOL ; } else { symbol = ts_language_symbol_for_name ((* self_0) . language , node_name , length , true ,) ; if symbol == 0 { stream_reset (stream , node_name) ; return TSQueryErrorNodeType ; } } }
3762            } else {
3763                return TSQueryErrorSyntax;
3764            }
3765            array__grow(
3766                &mut (*self_0).steps as *mut C2RustUnnamed_9 as *mut VoidArray,
3767                1 as os::raw::c_int as size_t,
3768                ::std::mem::size_of::<QueryStep>() as usize,
3769            );
3770            let ref mut fresh67 = (*self_0).steps.size;
3771            let fresh68 = *fresh67;
3772            *fresh67 = (*fresh67).wrapping_add(1);
3773            *((*self_0).steps.contents).offset(fresh68 as isize) =
3774                query_step__new(symbol, depth as u16, is_immediate);
3775            if ((*self_0).steps.size).wrapping_sub(1 as os::raw::c_int as os::raw::c_uint)
3776                < (*self_0).steps.size
3777            {
3778            } else {
3779                panic!();
3780            }
3781            let mut step: *mut QueryStep = &mut *((*self_0).steps.contents).offset(
3782                ((*self_0).steps.size).wrapping_sub(1 as os::raw::c_int as os::raw::c_uint)
3783                    as isize,
3784            ) as *mut QueryStep;
3785            if (ts_language_symbol_metadata((*self_0).language, symbol)).supertype {
3786                (*step).supertype_symbol = (*step).symbol;
3787                (*step).symbol = WILDCARD_SYMBOL;
3788            }
3789            if symbol as os::raw::c_int == WILDCARD_SYMBOL as os::raw::c_int {
3790                (*step).set_is_named(1 as os::raw::c_int != 0);
3791            }
3792            stream_skip_whitespace(stream);
3793            if (*stream).next == '/' as i32 {
3794                stream_advance(stream);
3795                if !stream_is_ident_start(stream) {
3796                    return TSQueryErrorSyntax;
3797                }
3798                let mut node_name_0: *const os::raw::c_char = (*stream).input;
3799                stream_scan_identifier(stream);
3800                let mut length_0: u32 = ((*stream).input).offset_from(node_name_0) as isize as u32;
3801                (*step).symbol =
3802                    ts_language_symbol_for_name((*self_0).language, node_name_0, length_0, true);
3803                if (*step).symbol == 0 {
3804                    stream_reset(stream, node_name_0);
3805                    return TSQueryErrorNodeType;
3806                }
3807                stream_skip_whitespace(stream);
3808            }
3809            let mut child_is_immediate_0: bool = false;
3810            let mut last_child_step_index: u16 = 0 as os::raw::c_int as u16;
3811            let mut negated_field_count: u16 = 0 as os::raw::c_int as u16;
3812            let mut negated_field_ids: [TSFieldId; 8] = [0; 8];
3813            let mut child_capture_quantifiers_0: CaptureQuantifiers = capture_quantifiers_new();
3814            loop {
3815                if (*stream).next == '!' as i32 {
3816                    stream_advance(stream);
3817                    stream_skip_whitespace(stream);
3818                    if !stream_is_ident_start(stream) {
3819                        capture_quantifiers_delete(&mut child_capture_quantifiers_0);
3820                        return TSQueryErrorSyntax;
3821                    }
3822                    let mut field_name: *const os::raw::c_char = (*stream).input;
3823                    stream_scan_identifier(stream);
3824                    let mut length_1: u32 =
3825                        ((*stream).input).offset_from(field_name) as isize as u32;
3826                    stream_skip_whitespace(stream);
3827                    let mut field_id: TSFieldId =
3828                        ts_language_field_id_for_name((*self_0).language, field_name, length_1);
3829                    if field_id == 0 {
3830                        let ref mut fresh69 = (*stream).input;
3831                        *fresh69 = field_name;
3832                        capture_quantifiers_delete(&mut child_capture_quantifiers_0);
3833                        return TSQueryErrorField;
3834                    }
3835                    if (negated_field_count as os::raw::c_int) < 8 as os::raw::c_int {
3836                        negated_field_ids[negated_field_count as usize] = field_id;
3837                        negated_field_count = negated_field_count.wrapping_add(1);
3838                    }
3839                } else {
3840                    if (*stream).next == '.' as i32 {
3841                        child_is_immediate_0 = true;
3842                        stream_advance(stream);
3843                        stream_skip_whitespace(stream);
3844                    }
3845                    let mut step_index_0: u16 = (*self_0).steps.size as u16;
3846                    let mut e_1: TSQueryError = ts_query__parse_pattern(
3847                        self_0,
3848                        stream,
3849                        depth.wrapping_add(1 as os::raw::c_int as os::raw::c_uint),
3850                        child_is_immediate_0,
3851                        &mut child_capture_quantifiers_0,
3852                    );
3853                    if e_1 as os::raw::c_uint == PARENT_DONE as os::raw::c_uint {
3854                        if (*stream).next == ')' as i32 {
3855                            if child_is_immediate_0 {
3856                                if last_child_step_index as os::raw::c_int == 0 as os::raw::c_int {
3857                                    capture_quantifiers_delete(&mut child_capture_quantifiers_0);
3858                                    return TSQueryErrorSyntax;
3859                                }
3860                                let ref mut fresh70 = *((*self_0).steps.contents)
3861                                    .offset(last_child_step_index as isize);
3862                                (*fresh70).set_is_last_child(1 as os::raw::c_int != 0);
3863                            }
3864                            if negated_field_count != 0 {
3865                                ts_query__add_negated_fields(
3866                                    self_0,
3867                                    starting_step_index as u16,
3868                                    negated_field_ids.as_mut_ptr(),
3869                                    negated_field_count,
3870                                );
3871                            }
3872                            stream_advance(stream);
3873                            break;
3874                        } else {
3875                            e_1 = TSQueryErrorSyntax;
3876                        }
3877                    }
3878                    if e_1 as u64 != 0 {
3879                        capture_quantifiers_delete(&mut child_capture_quantifiers_0);
3880                        return e_1;
3881                    }
3882                    capture_quantifiers_add_all(
3883                        capture_quantifiers,
3884                        &mut child_capture_quantifiers_0,
3885                    );
3886                    last_child_step_index = step_index_0;
3887                    child_is_immediate_0 = false;
3888                    capture_quantifiers_clear(&mut child_capture_quantifiers_0);
3889                }
3890            }
3891            capture_quantifiers_delete(&mut child_capture_quantifiers_0);
3892        }
3893    } else if (*stream).next == '_' as i32 {
3894        stream_advance(stream);
3895        stream_skip_whitespace(stream);
3896        array__grow(
3897            &mut (*self_0).steps as *mut C2RustUnnamed_9 as *mut VoidArray,
3898            1 as os::raw::c_int as size_t,
3899            ::std::mem::size_of::<QueryStep>() as usize,
3900        );
3901        let ref mut fresh71 = (*self_0).steps.size;
3902        let fresh72 = *fresh71;
3903        *fresh71 = (*fresh71).wrapping_add(1);
3904        *((*self_0).steps.contents).offset(fresh72 as isize) =
3905            query_step__new(WILDCARD_SYMBOL, depth as u16, is_immediate);
3906    } else if (*stream).next == '"' as i32 {
3907        let mut string_start: *const os::raw::c_char = (*stream).input;
3908        let mut e_2: TSQueryError = ts_query__parse_string_literal(self_0, stream);
3909        if e_2 as u64 != 0 {
3910            return e_2;
3911        }
3912        let mut symbol_0: TSSymbol = ts_language_symbol_for_name(
3913            (*self_0).language,
3914            (*self_0).string_buffer.contents,
3915            (*self_0).string_buffer.size,
3916            false,
3917        );
3918        if symbol_0 == 0 {
3919            stream_reset(stream, string_start.offset(1 as os::raw::c_int as isize));
3920            return TSQueryErrorNodeType;
3921        }
3922        array__grow(
3923            &mut (*self_0).steps as *mut C2RustUnnamed_9 as *mut VoidArray,
3924            1 as os::raw::c_int as size_t,
3925            ::std::mem::size_of::<QueryStep>() as usize,
3926        );
3927        let ref mut fresh73 = (*self_0).steps.size;
3928        let fresh74 = *fresh73;
3929        *fresh73 = (*fresh73).wrapping_add(1);
3930        *((*self_0).steps.contents).offset(fresh74 as isize) =
3931            query_step__new(symbol_0, depth as u16, is_immediate);
3932    } else if stream_is_ident_start(stream) {
3933        let mut field_name_0: *const os::raw::c_char = (*stream).input;
3934        stream_scan_identifier(stream);
3935        let mut length_2: u32 = ((*stream).input).offset_from(field_name_0) as isize as u32;
3936        stream_skip_whitespace(stream);
3937        if (*stream).next != ':' as i32 {
3938            stream_reset(stream, field_name_0);
3939            return TSQueryErrorSyntax;
3940        }
3941        stream_advance(stream);
3942        stream_skip_whitespace(stream);
3943        let mut field_capture_quantifiers: CaptureQuantifiers = capture_quantifiers_new();
3944        let mut e_3: TSQueryError = ts_query__parse_pattern(
3945            self_0,
3946            stream,
3947            depth,
3948            is_immediate,
3949            &mut field_capture_quantifiers,
3950        );
3951        if e_3 as u64 != 0 {
3952            capture_quantifiers_delete(&mut field_capture_quantifiers);
3953            if e_3 as os::raw::c_uint == PARENT_DONE as os::raw::c_uint {
3954                e_3 = TSQueryErrorSyntax;
3955            }
3956            return e_3;
3957        }
3958        let mut field_id_0: TSFieldId =
3959            ts_language_field_id_for_name((*self_0).language, field_name_0, length_2);
3960        if field_id_0 == 0 {
3961            let ref mut fresh75 = (*stream).input;
3962            *fresh75 = field_name_0;
3963            return TSQueryErrorField;
3964        }
3965        let mut step_index_1: u32 = starting_step_index;
3966        let mut step_0: *mut QueryStep =
3967            &mut *((*self_0).steps.contents).offset(step_index_1 as isize) as *mut QueryStep;
3968        loop {
3969            (*step_0).field = field_id_0;
3970            if !((*step_0).alternative_index as os::raw::c_int != NONE as os::raw::c_int
3971                && (*step_0).alternative_index as os::raw::c_uint > step_index_1
3972                && ((*step_0).alternative_index as os::raw::c_uint) < (*self_0).steps.size)
3973            {
3974                break;
3975            }
3976            step_index_1 = (*step_0).alternative_index as u32;
3977            step_0 =
3978                &mut *((*self_0).steps.contents).offset(step_index_1 as isize) as *mut QueryStep;
3979        }
3980        capture_quantifiers_add_all(capture_quantifiers, &mut field_capture_quantifiers);
3981        capture_quantifiers_delete(&mut field_capture_quantifiers);
3982    } else {
3983        return TSQueryErrorSyntax;
3984    }
3985    stream_skip_whitespace(stream);
3986    let mut quantifier: TSQuantifier = TSQuantifierOne;
3987    loop {
3988        if (*stream).next == '+' as i32 {
3989            quantifier = quantifier_join(TSQuantifierOneOrMore, quantifier);
3990            stream_advance(stream);
3991            stream_skip_whitespace(stream);
3992            let mut repeat_step: QueryStep = query_step__new(WILDCARD_SYMBOL, depth as u16, false);
3993            repeat_step.alternative_index = starting_step_index as u16;
3994            repeat_step.set_is_pass_through(1 as os::raw::c_int != 0);
3995            repeat_step.set_alternative_is_immediate(1 as os::raw::c_int != 0);
3996            array__grow(
3997                &mut (*self_0).steps as *mut C2RustUnnamed_9 as *mut VoidArray,
3998                1 as os::raw::c_int as size_t,
3999                ::std::mem::size_of::<QueryStep>() as usize,
4000            );
4001            let ref mut fresh76 = (*self_0).steps.size;
4002            let fresh77 = *fresh76;
4003            *fresh76 = (*fresh76).wrapping_add(1);
4004            *((*self_0).steps.contents).offset(fresh77 as isize) = repeat_step;
4005        } else if (*stream).next == '*' as i32 {
4006            quantifier = quantifier_join(TSQuantifierZeroOrMore, quantifier);
4007            stream_advance(stream);
4008            stream_skip_whitespace(stream);
4009            let mut repeat_step_0: QueryStep =
4010                query_step__new(WILDCARD_SYMBOL, depth as u16, false);
4011            repeat_step_0.alternative_index = starting_step_index as u16;
4012            repeat_step_0.set_is_pass_through(1 as os::raw::c_int != 0);
4013            repeat_step_0.set_alternative_is_immediate(1 as os::raw::c_int != 0);
4014            array__grow(
4015                &mut (*self_0).steps as *mut C2RustUnnamed_9 as *mut VoidArray,
4016                1 as os::raw::c_int as size_t,
4017                ::std::mem::size_of::<QueryStep>() as usize,
4018            );
4019            let ref mut fresh78 = (*self_0).steps.size;
4020            let fresh79 = *fresh78;
4021            *fresh78 = (*fresh78).wrapping_add(1);
4022            *((*self_0).steps.contents).offset(fresh79 as isize) = repeat_step_0;
4023            let mut step_1: *mut QueryStep = &mut *((*self_0).steps.contents)
4024                .offset(starting_step_index as isize)
4025                as *mut QueryStep;
4026            while (*step_1).alternative_index as os::raw::c_int != NONE as os::raw::c_int {
4027                step_1 = &mut *((*self_0).steps.contents)
4028                    .offset((*step_1).alternative_index as isize)
4029                    as *mut QueryStep;
4030            }
4031            (*step_1).alternative_index = (*self_0).steps.size as u16;
4032        } else if (*stream).next == '?' as i32 {
4033            quantifier = quantifier_join(TSQuantifierZeroOrOne, quantifier);
4034            stream_advance(stream);
4035            stream_skip_whitespace(stream);
4036            let mut step_2: *mut QueryStep = &mut *((*self_0).steps.contents)
4037                .offset(starting_step_index as isize)
4038                as *mut QueryStep;
4039            while (*step_2).alternative_index as os::raw::c_int != NONE as os::raw::c_int {
4040                step_2 = &mut *((*self_0).steps.contents)
4041                    .offset((*step_2).alternative_index as isize)
4042                    as *mut QueryStep;
4043            }
4044            (*step_2).alternative_index = (*self_0).steps.size as u16;
4045        } else {
4046            if !((*stream).next == '@' as i32) {
4047                break;
4048            }
4049            stream_advance(stream);
4050            if !stream_is_ident_start(stream) {
4051                return TSQueryErrorSyntax;
4052            }
4053            let mut capture_name: *const os::raw::c_char = (*stream).input;
4054            stream_scan_identifier(stream);
4055            let mut length_3: u32 = ((*stream).input).offset_from(capture_name) as isize as u32;
4056            stream_skip_whitespace(stream);
4057            let mut capture_id: u16 =
4058                symbol_table_insert_name(&mut (*self_0).captures, capture_name, length_3);
4059            capture_quantifiers_add_for_id(capture_quantifiers, capture_id, TSQuantifierOne);
4060            let mut step_index_2: u32 = starting_step_index;
4061            loop {
4062                let mut step_3: *mut QueryStep = &mut *((*self_0).steps.contents)
4063                    .offset(step_index_2 as isize)
4064                    as *mut QueryStep;
4065                query_step__add_capture(step_3, capture_id);
4066                if !((*step_3).alternative_index as os::raw::c_int != NONE as os::raw::c_int
4067                    && (*step_3).alternative_index as os::raw::c_uint > step_index_2
4068                    && ((*step_3).alternative_index as os::raw::c_uint) < (*self_0).steps.size)
4069                {
4070                    break;
4071                }
4072                step_index_2 = (*step_3).alternative_index as u32;
4073                step_3 = &mut *((*self_0).steps.contents).offset(step_index_2 as isize)
4074                    as *mut QueryStep;
4075            }
4076        }
4077    }
4078    capture_quantifiers_mul(capture_quantifiers, quantifier);
4079    return TSQueryErrorNone;
4080}
4081#[no_mangle]
4082pub unsafe extern "C" fn ts_query_new(
4083    mut language: *const TSLanguage,
4084    mut source: *const os::raw::c_char,
4085    mut source_len: u32,
4086    mut error_offset: *mut u32,
4087    mut error_type: *mut TSQueryError,
4088) -> *mut TSQuery {
4089    if language.is_null()
4090        || (*language).version > 14 as os::raw::c_int as os::raw::c_uint
4091        || (*language).version < 13 as os::raw::c_int as os::raw::c_uint
4092    {
4093        *error_type = TSQueryErrorLanguage;
4094        return 0 as *mut TSQuery;
4095    }
4096    let mut self_0: *mut TSQuery =
4097        crate::alloc::ts_malloc(::std::mem::size_of::<TSQuery>() as usize) as *mut TSQuery;
4098    *self_0 = {
4099        let mut init = TSQuery {
4100            captures: symbol_table_new(),
4101            capture_quantifiers: {
4102                let mut init = C2RustUnnamed_12 {
4103                    contents: 0 as *mut CaptureQuantifiers,
4104                    size: 0 as os::raw::c_int as u32,
4105                    capacity: 0 as os::raw::c_int as u32,
4106                };
4107                init
4108            },
4109            predicate_values: symbol_table_new(),
4110            steps: {
4111                let mut init = C2RustUnnamed_9 {
4112                    contents: 0 as *mut QueryStep,
4113                    size: 0 as os::raw::c_int as u32,
4114                    capacity: 0 as os::raw::c_int as u32,
4115                };
4116                init
4117            },
4118            pattern_map: {
4119                let mut init = C2RustUnnamed_8 {
4120                    contents: 0 as *mut PatternEntry,
4121                    size: 0 as os::raw::c_int as u32,
4122                    capacity: 0 as os::raw::c_int as u32,
4123                };
4124                init
4125            },
4126            predicate_steps: {
4127                let mut init = C2RustUnnamed_7 {
4128                    contents: 0 as *mut TSQueryPredicateStep,
4129                    size: 0 as os::raw::c_int as u32,
4130                    capacity: 0 as os::raw::c_int as u32,
4131                };
4132                init
4133            },
4134            patterns: {
4135                let mut init = C2RustUnnamed_6 {
4136                    contents: 0 as *mut QueryPattern,
4137                    size: 0 as os::raw::c_int as u32,
4138                    capacity: 0 as os::raw::c_int as u32,
4139                };
4140                init
4141            },
4142            step_offsets: {
4143                let mut init = C2RustUnnamed_5 {
4144                    contents: 0 as *mut StepOffset,
4145                    size: 0 as os::raw::c_int as u32,
4146                    capacity: 0 as os::raw::c_int as u32,
4147                };
4148                init
4149            },
4150            negated_fields: {
4151                let mut init = C2RustUnnamed_4 {
4152                    contents: 0 as *mut TSFieldId,
4153                    size: 0 as os::raw::c_int as u32,
4154                    capacity: 0 as os::raw::c_int as u32,
4155                };
4156                init
4157            },
4158            string_buffer: {
4159                let mut init = C2RustUnnamed_3 {
4160                    contents: 0 as *mut os::raw::c_char,
4161                    size: 0 as os::raw::c_int as u32,
4162                    capacity: 0 as os::raw::c_int as u32,
4163                };
4164                init
4165            },
4166            language: language,
4167            wildcard_root_pattern_count: 0 as os::raw::c_int as u16,
4168        };
4169        init
4170    };
4171    array__grow(
4172        &mut (*self_0).negated_fields as *mut C2RustUnnamed_4 as *mut VoidArray,
4173        1 as os::raw::c_int as size_t,
4174        ::std::mem::size_of::<TSFieldId>() as usize,
4175    );
4176    let ref mut fresh80 = (*self_0).negated_fields.size;
4177    let fresh81 = *fresh80;
4178    *fresh80 = (*fresh80).wrapping_add(1);
4179    *((*self_0).negated_fields.contents).offset(fresh81 as isize) =
4180        0 as os::raw::c_int as TSFieldId;
4181    let mut stream: Stream = stream_new(source, source_len);
4182    stream_skip_whitespace(&mut stream);
4183    while stream.input < stream.end {
4184        let mut pattern_index: u32 = (*self_0).patterns.size;
4185        let mut start_step_index: u32 = (*self_0).steps.size;
4186        let mut start_predicate_step_index: u32 = (*self_0).predicate_steps.size;
4187        array__grow(
4188            &mut (*self_0).patterns as *mut C2RustUnnamed_6 as *mut VoidArray,
4189            1 as os::raw::c_int as size_t,
4190            ::std::mem::size_of::<QueryPattern>() as usize,
4191        );
4192        let ref mut fresh82 = (*self_0).patterns.size;
4193        let fresh83 = *fresh82;
4194        *fresh82 = (*fresh82).wrapping_add(1);
4195        *((*self_0).patterns.contents).offset(fresh83 as isize) = {
4196            let mut init = QueryPattern {
4197                steps: {
4198                    let mut init = Slice {
4199                        offset: start_step_index,
4200                        length: 0,
4201                    };
4202                    init
4203                },
4204                predicate_steps: {
4205                    let mut init = Slice {
4206                        offset: start_predicate_step_index,
4207                        length: 0,
4208                    };
4209                    init
4210                },
4211                start_byte: stream_offset(&mut stream),
4212            };
4213            init
4214        };
4215        let mut capture_quantifiers: CaptureQuantifiers = capture_quantifiers_new();
4216        *error_type = ts_query__parse_pattern(
4217            self_0,
4218            &mut stream,
4219            0 as os::raw::c_int as u32,
4220            false,
4221            &mut capture_quantifiers,
4222        );
4223        array__grow(
4224            &mut (*self_0).steps as *mut C2RustUnnamed_9 as *mut VoidArray,
4225            1 as os::raw::c_int as size_t,
4226            ::std::mem::size_of::<QueryStep>() as usize,
4227        );
4228        let ref mut fresh84 = (*self_0).steps.size;
4229        let fresh85 = *fresh84;
4230        *fresh84 = (*fresh84).wrapping_add(1);
4231        *((*self_0).steps.contents).offset(fresh85 as isize) =
4232            query_step__new(0 as os::raw::c_int as TSSymbol, PATTERN_DONE_MARKER, false);
4233        if ((*self_0).patterns.size).wrapping_sub(1 as os::raw::c_int as os::raw::c_uint)
4234            < (*self_0).patterns.size
4235        {
4236        } else {
4237            panic!();
4238        }
4239        let mut pattern: *mut QueryPattern = &mut *((*self_0).patterns.contents).offset(
4240            ((*self_0).patterns.size).wrapping_sub(1 as os::raw::c_int as os::raw::c_uint) as isize,
4241        ) as *mut QueryPattern;
4242        (*pattern).steps.length = ((*self_0).steps.size).wrapping_sub(start_step_index);
4243        (*pattern).predicate_steps.length =
4244            ((*self_0).predicate_steps.size).wrapping_sub(start_predicate_step_index);
4245        if *error_type as u64 != 0 {
4246            if *error_type as os::raw::c_uint == PARENT_DONE as os::raw::c_uint {
4247                *error_type = TSQueryErrorSyntax;
4248            }
4249            *error_offset = stream_offset(&mut stream);
4250            capture_quantifiers_delete(&mut capture_quantifiers);
4251            ts_query_delete(self_0);
4252            return 0 as *mut TSQuery;
4253        }
4254        array__grow(
4255            &mut (*self_0).capture_quantifiers as *mut C2RustUnnamed_12 as *mut VoidArray,
4256            1 as os::raw::c_int as size_t,
4257            ::std::mem::size_of::<CaptureQuantifiers>() as usize,
4258        );
4259        let ref mut fresh86 = (*self_0).capture_quantifiers.size;
4260        let fresh87 = *fresh86;
4261        *fresh86 = (*fresh86).wrapping_add(1);
4262        *((*self_0).capture_quantifiers.contents).offset(fresh87 as isize) = capture_quantifiers;
4263        let mut wildcard_root_alternative_index: u16 = NONE;
4264        loop {
4265            let mut step: *mut QueryStep = &mut *((*self_0).steps.contents)
4266                .offset(start_step_index as isize)
4267                as *mut QueryStep;
4268            if (*step).symbol as os::raw::c_int == WILDCARD_SYMBOL as os::raw::c_int
4269                && (*step).depth as os::raw::c_int == 0 as os::raw::c_int
4270                && (*step).field == 0
4271            {
4272                let mut second_step: *mut QueryStep = &mut *((*self_0).steps.contents).offset(
4273                    start_step_index.wrapping_add(1 as os::raw::c_int as os::raw::c_uint) as isize,
4274                ) as *mut QueryStep;
4275                if (*second_step).symbol as os::raw::c_int != WILDCARD_SYMBOL as os::raw::c_int
4276                    && (*second_step).depth as os::raw::c_int == 1 as os::raw::c_int
4277                {
4278                    wildcard_root_alternative_index = (*step).alternative_index;
4279                    start_step_index = (start_step_index as os::raw::c_uint)
4280                        .wrapping_add(1 as os::raw::c_int as os::raw::c_uint)
4281                        as u32 as u32;
4282                    step = second_step;
4283                }
4284            }
4285            let mut start_depth: u32 = (*step).depth as u32;
4286            let mut is_rooted: bool = start_depth == 0 as os::raw::c_int as os::raw::c_uint;
4287            let mut step_index: u32 =
4288                start_step_index.wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
4289            while step_index < (*self_0).steps.size {
4290                let mut step_0: *mut QueryStep =
4291                    &mut *((*self_0).steps.contents).offset(step_index as isize) as *mut QueryStep;
4292                if (*step_0).is_dead_end() {
4293                    break;
4294                }
4295                if (*step_0).depth as os::raw::c_uint == start_depth {
4296                    is_rooted = false;
4297                    break;
4298                } else {
4299                    step_index = step_index.wrapping_add(1);
4300                }
4301            }
4302            ts_query__pattern_map_insert(self_0, (*step).symbol, {
4303                let mut init = PatternEntry {
4304                    step_index: start_step_index as u16,
4305                    pattern_index: pattern_index as u16,
4306                    is_rooted: is_rooted,
4307                };
4308                init
4309            });
4310            if (*step).symbol as os::raw::c_int == WILDCARD_SYMBOL as os::raw::c_int {
4311                let ref mut fresh88 = (*self_0).wildcard_root_pattern_count;
4312                *fresh88 = (*fresh88).wrapping_add(1);
4313            }
4314            if (*step).alternative_index as os::raw::c_int != NONE as os::raw::c_int {
4315                start_step_index = (*step).alternative_index as u32;
4316                (*step).alternative_index = NONE;
4317            } else {
4318                if !(wildcard_root_alternative_index as os::raw::c_int != NONE as os::raw::c_int) {
4319                    break;
4320                }
4321                start_step_index = wildcard_root_alternative_index as u32;
4322                wildcard_root_alternative_index = NONE;
4323            }
4324        }
4325    }
4326    if !ts_query__analyze_patterns(self_0, error_offset) {
4327        *error_type = TSQueryErrorStructure;
4328        ts_query_delete(self_0);
4329        return 0 as *mut TSQuery;
4330    }
4331    array__delete(&mut (*self_0).string_buffer as *mut C2RustUnnamed_3 as *mut VoidArray);
4332    return self_0;
4333}
4334#[no_mangle]
4335pub unsafe extern "C" fn ts_query_delete(mut self_0: *mut TSQuery) {
4336    if !self_0.is_null() {
4337        array__delete(&mut (*self_0).steps as *mut C2RustUnnamed_9 as *mut VoidArray);
4338        array__delete(&mut (*self_0).pattern_map as *mut C2RustUnnamed_8 as *mut VoidArray);
4339        array__delete(&mut (*self_0).predicate_steps as *mut C2RustUnnamed_7 as *mut VoidArray);
4340        array__delete(&mut (*self_0).patterns as *mut C2RustUnnamed_6 as *mut VoidArray);
4341        array__delete(&mut (*self_0).step_offsets as *mut C2RustUnnamed_5 as *mut VoidArray);
4342        array__delete(&mut (*self_0).string_buffer as *mut C2RustUnnamed_3 as *mut VoidArray);
4343        array__delete(&mut (*self_0).negated_fields as *mut C2RustUnnamed_4 as *mut VoidArray);
4344        symbol_table_delete(&mut (*self_0).captures);
4345        symbol_table_delete(&mut (*self_0).predicate_values);
4346        let mut index: u32 = 0 as os::raw::c_int as u32;
4347        while index < (*self_0).capture_quantifiers.size {
4348            if index < (*self_0).capture_quantifiers.size {
4349            } else {
4350                panic!();
4351            }
4352            let mut capture_quantifiers: *mut CaptureQuantifiers =
4353                &mut *((*self_0).capture_quantifiers.contents).offset(index as isize)
4354                    as *mut CaptureQuantifiers;
4355            capture_quantifiers_delete(capture_quantifiers);
4356            index = index.wrapping_add(1);
4357        }
4358        array__delete(
4359            &mut (*self_0).capture_quantifiers as *mut C2RustUnnamed_12 as *mut VoidArray,
4360        );
4361        crate::alloc::ts_free(self_0 as *mut os::raw::c_void);
4362    }
4363}
4364#[no_mangle]
4365pub unsafe extern "C" fn ts_query_pattern_count(mut self_0: *const TSQuery) -> u32 {
4366    return (*self_0).patterns.size;
4367}
4368#[no_mangle]
4369pub unsafe extern "C" fn ts_query_capture_count(mut self_0: *const TSQuery) -> u32 {
4370    return (*self_0).captures.slices.size;
4371}
4372#[no_mangle]
4373pub unsafe extern "C" fn ts_query_string_count(mut self_0: *const TSQuery) -> u32 {
4374    return (*self_0).predicate_values.slices.size;
4375}
4376#[no_mangle]
4377pub unsafe extern "C" fn ts_query_capture_name_for_id(
4378    mut self_0: *const TSQuery,
4379    mut index: u32,
4380    mut length: *mut u32,
4381) -> *const os::raw::c_char {
4382    return symbol_table_name_for_id(&(*self_0).captures, index as u16, length);
4383}
4384#[no_mangle]
4385pub unsafe extern "C" fn ts_query_capture_quantifier_for_id(
4386    mut self_0: *const TSQuery,
4387    mut pattern_index: u32,
4388    mut capture_index: u32,
4389) -> TSQuantifier {
4390    if pattern_index < (*self_0).capture_quantifiers.size {
4391    } else {
4392        panic!();
4393    }
4394    let mut capture_quantifiers: *mut CaptureQuantifiers =
4395        &mut *((*self_0).capture_quantifiers.contents).offset(pattern_index as isize)
4396            as *mut CaptureQuantifiers;
4397    return capture_quantifier_for_id(capture_quantifiers, capture_index as u16);
4398}
4399#[no_mangle]
4400pub unsafe extern "C" fn ts_query_string_value_for_id(
4401    mut self_0: *const TSQuery,
4402    mut index: u32,
4403    mut length: *mut u32,
4404) -> *const os::raw::c_char {
4405    return symbol_table_name_for_id(&(*self_0).predicate_values, index as u16, length);
4406}
4407#[no_mangle]
4408pub unsafe extern "C" fn ts_query_predicates_for_pattern(
4409    mut self_0: *const TSQuery,
4410    mut pattern_index: u32,
4411    mut step_count: *mut u32,
4412) -> *const TSQueryPredicateStep {
4413    let mut slice: Slice =
4414        (*((*self_0).patterns.contents).offset(pattern_index as isize)).predicate_steps;
4415    *step_count = slice.length;
4416    if ((*self_0).predicate_steps.contents).is_null() {
4417        return 0 as *const TSQueryPredicateStep;
4418    }
4419    return &mut *((*self_0).predicate_steps.contents).offset(slice.offset as isize)
4420        as *mut TSQueryPredicateStep;
4421}
4422#[no_mangle]
4423pub unsafe extern "C" fn ts_query_start_byte_for_pattern(
4424    mut self_0: *const TSQuery,
4425    mut pattern_index: u32,
4426) -> u32 {
4427    return (*((*self_0).patterns.contents).offset(pattern_index as isize)).start_byte;
4428}
4429#[no_mangle]
4430pub unsafe extern "C" fn ts_query_is_pattern_rooted(
4431    mut self_0: *const TSQuery,
4432    mut pattern_index: u32,
4433) -> bool {
4434    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
4435    while i < (*self_0).pattern_map.size {
4436        let mut entry: *mut PatternEntry =
4437            &mut *((*self_0).pattern_map.contents).offset(i as isize) as *mut PatternEntry;
4438        if (*entry).pattern_index as os::raw::c_uint == pattern_index {
4439            if !(*entry).is_rooted {
4440                return false;
4441            }
4442        }
4443        i = i.wrapping_add(1);
4444    }
4445    return true;
4446}
4447#[no_mangle]
4448pub unsafe extern "C" fn ts_query_is_pattern_guaranteed_at_step(
4449    mut self_0: *const TSQuery,
4450    mut byte_offset: u32,
4451) -> bool {
4452    let mut step_index: u32 = 4294967295 as os::raw::c_uint;
4453    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
4454    while i < (*self_0).step_offsets.size {
4455        let mut step_offset: *mut StepOffset =
4456            &mut *((*self_0).step_offsets.contents).offset(i as isize) as *mut StepOffset;
4457        if (*step_offset).byte_offset > byte_offset {
4458            break;
4459        }
4460        step_index = (*step_offset).step_index as u32;
4461        i = i.wrapping_add(1);
4462    }
4463    if step_index < (*self_0).steps.size {
4464        return (*((*self_0).steps.contents).offset(step_index as isize)).root_pattern_guaranteed();
4465    } else {
4466        return false;
4467    };
4468}
4469#[no_mangle]
4470pub unsafe extern "C" fn ts_query__step_is_fallible(
4471    mut self_0: *const TSQuery,
4472    mut step_index: u16,
4473) -> bool {
4474    if (step_index as u32).wrapping_add(1 as os::raw::c_int as os::raw::c_uint)
4475        < (*self_0).steps.size
4476    {
4477    } else {
4478        panic!();
4479    }
4480    let mut step: *mut QueryStep =
4481        &mut *((*self_0).steps.contents).offset(step_index as isize) as *mut QueryStep;
4482    let mut next_step: *mut QueryStep = &mut *((*self_0).steps.contents)
4483        .offset((step_index as os::raw::c_int + 1 as os::raw::c_int) as isize)
4484        as *mut QueryStep;
4485    return (*next_step).depth as os::raw::c_int != PATTERN_DONE_MARKER as os::raw::c_int
4486        && (*next_step).depth as os::raw::c_int > (*step).depth as os::raw::c_int
4487        && !(*next_step).parent_pattern_guaranteed();
4488}
4489#[no_mangle]
4490pub unsafe extern "C" fn ts_query_disable_capture(
4491    mut self_0: *mut TSQuery,
4492    mut name: *const os::raw::c_char,
4493    mut length: u32,
4494) {
4495    let mut id: os::raw::c_int = symbol_table_id_for_name(&mut (*self_0).captures, name, length);
4496    if id != -(1 as os::raw::c_int) {
4497        let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
4498        while i < (*self_0).steps.size {
4499            let mut step: *mut QueryStep =
4500                &mut *((*self_0).steps.contents).offset(i as isize) as *mut QueryStep;
4501            query_step__remove_capture(step, id as u16);
4502            i = i.wrapping_add(1);
4503        }
4504    }
4505}
4506#[no_mangle]
4507pub unsafe extern "C" fn ts_query_disable_pattern(
4508    mut self_0: *mut TSQuery,
4509    mut pattern_index: u32,
4510) {
4511    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
4512    while i < (*self_0).pattern_map.size {
4513        let mut pattern: *mut PatternEntry =
4514            &mut *((*self_0).pattern_map.contents).offset(i as isize) as *mut PatternEntry;
4515        if (*pattern).pattern_index as os::raw::c_uint == pattern_index {
4516            array__erase(
4517                &mut (*self_0).pattern_map as *mut C2RustUnnamed_8 as *mut VoidArray,
4518                ::std::mem::size_of::<PatternEntry>() as usize,
4519                i,
4520            );
4521            i = i.wrapping_sub(1);
4522        }
4523        i = i.wrapping_add(1);
4524    }
4525}
4526#[no_mangle]
4527pub unsafe extern "C" fn ts_query_cursor_new() -> *mut TSQueryCursor {
4528    let mut self_0: *mut TSQueryCursor =
4529        crate::alloc::ts_malloc(::std::mem::size_of::<TSQueryCursor>() as usize)
4530            as *mut TSQueryCursor;
4531    *self_0 = {
4532        let mut init = TSQueryCursor {
4533            query: 0 as *const TSQuery,
4534            cursor: TSTreeCursor {
4535                tree: 0 as *const os::raw::c_void,
4536                id: 0 as *const os::raw::c_void,
4537                context: [0; 2],
4538            },
4539            states: {
4540                let mut init = C2RustUnnamed_15 {
4541                    contents: 0 as *mut QueryState,
4542                    size: 0 as os::raw::c_int as u32,
4543                    capacity: 0 as os::raw::c_int as u32,
4544                };
4545                init
4546            },
4547            finished_states: {
4548                let mut init = C2RustUnnamed_14 {
4549                    contents: 0 as *mut QueryState,
4550                    size: 0 as os::raw::c_int as u32,
4551                    capacity: 0 as os::raw::c_int as u32,
4552                };
4553                init
4554            },
4555            capture_list_pool: capture_list_pool_new(),
4556            depth: 0,
4557            start_byte: 0 as os::raw::c_int as u32,
4558            end_byte: 4294967295 as os::raw::c_uint,
4559            start_point: {
4560                let mut init = TSPoint {
4561                    row: 0 as os::raw::c_int as u32,
4562                    column: 0 as os::raw::c_int as u32,
4563                };
4564                init
4565            },
4566            end_point: {
4567                let mut init = TSPoint {
4568                    row: 4294967295 as os::raw::c_uint,
4569                    column: 4294967295 as os::raw::c_uint,
4570                };
4571                init
4572            },
4573            next_state_id: 0,
4574            ascending: false,
4575            halted: false,
4576            did_exceed_match_limit: false,
4577        };
4578        init
4579    };
4580    array__reserve(
4581        &mut (*self_0).states as *mut C2RustUnnamed_15 as *mut VoidArray,
4582        ::std::mem::size_of::<QueryState>() as usize,
4583        8 as os::raw::c_int as u32,
4584    );
4585    array__reserve(
4586        &mut (*self_0).finished_states as *mut C2RustUnnamed_14 as *mut VoidArray,
4587        ::std::mem::size_of::<QueryState>() as usize,
4588        8 as os::raw::c_int as u32,
4589    );
4590    return self_0;
4591}
4592#[no_mangle]
4593pub unsafe extern "C" fn ts_query_cursor_delete(mut self_0: *mut TSQueryCursor) {
4594    array__delete(&mut (*self_0).states as *mut C2RustUnnamed_15 as *mut VoidArray);
4595    array__delete(&mut (*self_0).finished_states as *mut C2RustUnnamed_14 as *mut VoidArray);
4596    ts_tree_cursor_delete(&mut (*self_0).cursor);
4597    capture_list_pool_delete(&mut (*self_0).capture_list_pool);
4598    crate::alloc::ts_free(self_0 as *mut os::raw::c_void);
4599}
4600#[no_mangle]
4601pub unsafe extern "C" fn ts_query_cursor_did_exceed_match_limit(
4602    mut self_0: *const TSQueryCursor,
4603) -> bool {
4604    return (*self_0).did_exceed_match_limit;
4605}
4606#[no_mangle]
4607pub unsafe extern "C" fn ts_query_cursor_match_limit(mut self_0: *const TSQueryCursor) -> u32 {
4608    return (*self_0).capture_list_pool.max_capture_list_count;
4609}
4610#[no_mangle]
4611pub unsafe extern "C" fn ts_query_cursor_set_match_limit(
4612    mut self_0: *mut TSQueryCursor,
4613    mut limit: u32,
4614) {
4615    (*self_0).capture_list_pool.max_capture_list_count = limit;
4616}
4617#[no_mangle]
4618pub unsafe extern "C" fn ts_query_cursor_exec(
4619    mut self_0: *mut TSQueryCursor,
4620    mut query: *const TSQuery,
4621    mut node: TSNode,
4622) {
4623    (*self_0).states.size = 0 as os::raw::c_int as u32;
4624    (*self_0).finished_states.size = 0 as os::raw::c_int as u32;
4625    ts_tree_cursor_reset(&mut (*self_0).cursor, node);
4626    capture_list_pool_reset(&mut (*self_0).capture_list_pool);
4627    (*self_0).next_state_id = 0 as os::raw::c_int as u32;
4628    (*self_0).depth = 0 as os::raw::c_int as u32;
4629    (*self_0).ascending = false;
4630    (*self_0).halted = false;
4631    let ref mut fresh89 = (*self_0).query;
4632    *fresh89 = query;
4633    (*self_0).did_exceed_match_limit = false;
4634}
4635#[no_mangle]
4636pub unsafe extern "C" fn ts_query_cursor_set_byte_range(
4637    mut self_0: *mut TSQueryCursor,
4638    mut start_byte: u32,
4639    mut end_byte: u32,
4640) {
4641    if end_byte == 0 as os::raw::c_int as os::raw::c_uint {
4642        end_byte = 4294967295 as os::raw::c_uint;
4643    }
4644    (*self_0).start_byte = start_byte;
4645    (*self_0).end_byte = end_byte;
4646}
4647#[no_mangle]
4648pub unsafe extern "C" fn ts_query_cursor_set_point_range(
4649    mut self_0: *mut TSQueryCursor,
4650    mut start_point: TSPoint,
4651    mut end_point: TSPoint,
4652) {
4653    if end_point.row == 0 as os::raw::c_int as os::raw::c_uint
4654        && end_point.column == 0 as os::raw::c_int as os::raw::c_uint
4655    {
4656        end_point = {
4657            let mut init = TSPoint {
4658                row: 4294967295 as os::raw::c_uint,
4659                column: 4294967295 as os::raw::c_uint,
4660            };
4661            init
4662        };
4663    }
4664    (*self_0).start_point = start_point;
4665    (*self_0).end_point = end_point;
4666}
4667unsafe extern "C" fn ts_query_cursor__first_in_progress_capture(
4668    mut self_0: *mut TSQueryCursor,
4669    mut state_index: *mut u32,
4670    mut byte_offset: *mut u32,
4671    mut pattern_index: *mut u32,
4672    mut root_pattern_guaranteed: *mut bool,
4673) -> bool {
4674    let mut result: bool = false;
4675    *state_index = 4294967295 as os::raw::c_uint;
4676    *byte_offset = 4294967295 as os::raw::c_uint;
4677    *pattern_index = 4294967295 as os::raw::c_uint;
4678    let mut current_block_10: u64;
4679    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
4680    while i < (*self_0).states.size {
4681        let mut state: *mut QueryState =
4682            &mut *((*self_0).states.contents).offset(i as isize) as *mut QueryState;
4683        if !(*state).dead() {
4684            let mut captures: *const CaptureList = capture_list_pool_get(
4685                &mut (*self_0).capture_list_pool,
4686                (*state).capture_list_id as u16,
4687            );
4688            if !((*state).consumed_capture_count() as os::raw::c_uint >= (*captures).size) {
4689                let mut node: TSNode = (*((*captures).contents)
4690                    .offset((*state).consumed_capture_count() as isize))
4691                .node;
4692                if ts_node_end_byte(node) <= (*self_0).start_byte
4693                    || point_lte(ts_node_end_point(node), (*self_0).start_point) as os::raw::c_int
4694                        != 0
4695                {
4696                    (*state).set_consumed_capture_count((*state).consumed_capture_count() + 1);
4697                    i = i.wrapping_sub(1);
4698                } else {
4699                    let mut node_start_byte: u32 = ts_node_start_byte(node);
4700                    if !result
4701                        || node_start_byte < *byte_offset
4702                        || node_start_byte == *byte_offset
4703                            && ((*state).pattern_index as os::raw::c_uint) < *pattern_index
4704                    {
4705                        let mut step: *mut QueryStep = &mut *((*(*self_0).query).steps.contents)
4706                            .offset((*state).step_index as isize)
4707                            as *mut QueryStep;
4708                        if !root_pattern_guaranteed.is_null() {
4709                            *root_pattern_guaranteed = (*step).root_pattern_guaranteed();
4710                            current_block_10 = 13242334135786603907;
4711                        } else if (*step).root_pattern_guaranteed() {
4712                            current_block_10 = 4644295000439058019;
4713                        } else {
4714                            current_block_10 = 13242334135786603907;
4715                        }
4716                        match current_block_10 {
4717                            4644295000439058019 => {}
4718                            _ => {
4719                                result = true;
4720                                *state_index = i;
4721                                *byte_offset = node_start_byte;
4722                                *pattern_index = (*state).pattern_index as u32;
4723                            }
4724                        }
4725                    }
4726                }
4727            }
4728        }
4729        i = i.wrapping_add(1);
4730    }
4731    return result;
4732}
4733#[no_mangle]
4734pub unsafe extern "C" fn ts_query_cursor__compare_nodes(
4735    mut left: TSNode,
4736    mut right: TSNode,
4737) -> os::raw::c_int {
4738    if left.id != right.id {
4739        let mut left_start: u32 = ts_node_start_byte(left);
4740        let mut right_start: u32 = ts_node_start_byte(right);
4741        if left_start < right_start {
4742            return -(1 as os::raw::c_int);
4743        }
4744        if left_start > right_start {
4745            return 1 as os::raw::c_int;
4746        }
4747        let mut left_node_count: u32 = ts_node_end_byte(left);
4748        let mut right_node_count: u32 = ts_node_end_byte(right);
4749        if left_node_count > right_node_count {
4750            return -(1 as os::raw::c_int);
4751        }
4752        if left_node_count < right_node_count {
4753            return 1 as os::raw::c_int;
4754        }
4755    }
4756    return 0 as os::raw::c_int;
4757}
4758#[no_mangle]
4759pub unsafe extern "C" fn ts_query_cursor__compare_captures(
4760    mut self_0: *mut TSQueryCursor,
4761    mut left_state: *mut QueryState,
4762    mut right_state: *mut QueryState,
4763    mut left_contains_right: *mut bool,
4764    mut right_contains_left: *mut bool,
4765) {
4766    let mut left_captures: *const CaptureList = capture_list_pool_get(
4767        &mut (*self_0).capture_list_pool,
4768        (*left_state).capture_list_id as u16,
4769    );
4770    let mut right_captures: *const CaptureList = capture_list_pool_get(
4771        &mut (*self_0).capture_list_pool,
4772        (*right_state).capture_list_id as u16,
4773    );
4774    *left_contains_right = true;
4775    *right_contains_left = true;
4776    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
4777    let mut j: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
4778    loop {
4779        if i < (*left_captures).size {
4780            if j < (*right_captures).size {
4781                let mut left: *mut TSQueryCapture =
4782                    &mut *((*left_captures).contents).offset(i as isize) as *mut TSQueryCapture;
4783                let mut right: *mut TSQueryCapture =
4784                    &mut *((*right_captures).contents).offset(j as isize) as *mut TSQueryCapture;
4785                if (*left).node.id == (*right).node.id && (*left).index == (*right).index {
4786                    i = i.wrapping_add(1);
4787                    j = j.wrapping_add(1);
4788                } else {
4789                    match ts_query_cursor__compare_nodes((*left).node, (*right).node) {
4790                        -1 => {
4791                            *right_contains_left = false;
4792                            i = i.wrapping_add(1);
4793                        }
4794                        1 => {
4795                            *left_contains_right = false;
4796                            j = j.wrapping_add(1);
4797                        }
4798                        _ => {
4799                            *right_contains_left = false;
4800                            *left_contains_right = false;
4801                            i = i.wrapping_add(1);
4802                            j = j.wrapping_add(1);
4803                        }
4804                    }
4805                }
4806            } else {
4807                *right_contains_left = false;
4808                break;
4809            }
4810        } else {
4811            if j < (*right_captures).size {
4812                *left_contains_right = false;
4813            }
4814            break;
4815        }
4816    }
4817}
4818unsafe extern "C" fn ts_query_cursor__add_state(
4819    mut self_0: *mut TSQueryCursor,
4820    mut pattern: *const PatternEntry,
4821) {
4822    let mut step: *mut QueryStep = &mut *((*(*self_0).query).steps.contents)
4823        .offset((*pattern).step_index as isize)
4824        as *mut QueryStep;
4825    let mut start_depth: u32 = ((*self_0).depth).wrapping_sub((*step).depth as os::raw::c_uint);
4826    let mut index: u32 = (*self_0).states.size;
4827    while index > 0 as os::raw::c_int as os::raw::c_uint {
4828        let mut prev_state: *mut QueryState = &mut *((*self_0).states.contents)
4829            .offset(index.wrapping_sub(1 as os::raw::c_int as os::raw::c_uint) as isize)
4830            as *mut QueryState;
4831        if ((*prev_state).start_depth as os::raw::c_uint) < start_depth {
4832            break;
4833        }
4834        if (*prev_state).start_depth as os::raw::c_uint == start_depth {
4835            if (*prev_state).pattern_index as os::raw::c_int
4836                == (*pattern).pattern_index as os::raw::c_int
4837                && (*prev_state).step_index as os::raw::c_int
4838                    == (*pattern).step_index as os::raw::c_int
4839            {
4840                return;
4841            }
4842            if (*prev_state).pattern_index as os::raw::c_int
4843                <= (*pattern).pattern_index as os::raw::c_int
4844            {
4845                break;
4846            }
4847        }
4848        index = index.wrapping_sub(1);
4849    }
4850    array__splice(
4851        &mut (*self_0).states as *mut C2RustUnnamed_15 as *mut VoidArray,
4852        ::std::mem::size_of::<QueryState>() as usize,
4853        index,
4854        0 as os::raw::c_int as u32,
4855        1 as os::raw::c_int as u32,
4856        &mut {
4857            let mut init = QueryState { consumed_capture_count_seeking_immediate_match_has_in_progress_alternatives_dead_needs_parent : [0 ; 2] , id : 4294967295 as os :: raw :: c_uint , capture_list_id : NONE as u32 , start_depth : start_depth as u16 , step_index : (* pattern) . step_index , pattern_index : (* pattern) . pattern_index , } ;
4858            init.set_consumed_capture_count(0 as os::raw::c_int as u16);
4859            init.set_seeking_immediate_match(1 as os::raw::c_int != 0);
4860            init.set_has_in_progress_alternatives(0 as os::raw::c_int != 0);
4861            init.set_dead(0 as os::raw::c_int != 0);
4862            init.set_needs_parent((*step).depth as os::raw::c_int == 1 as os::raw::c_int);
4863            init
4864        } as *mut QueryState as *const os::raw::c_void,
4865    );
4866}
4867unsafe extern "C" fn ts_query_cursor__prepare_to_capture(
4868    mut self_0: *mut TSQueryCursor,
4869    mut state: *mut QueryState,
4870    mut state_index_to_preserve: os::raw::c_uint,
4871) -> *mut CaptureList {
4872    if (*state).capture_list_id == NONE as os::raw::c_uint {
4873        (*state).capture_list_id =
4874            capture_list_pool_acquire(&mut (*self_0).capture_list_pool) as u32;
4875        if (*state).capture_list_id == NONE as os::raw::c_uint {
4876            (*self_0).did_exceed_match_limit = true;
4877            let mut state_index: u32 = 0;
4878            let mut byte_offset: u32 = 0;
4879            let mut pattern_index: u32 = 0;
4880            if ts_query_cursor__first_in_progress_capture(
4881                self_0,
4882                &mut state_index,
4883                &mut byte_offset,
4884                &mut pattern_index,
4885                0 as *mut bool,
4886            ) as os::raw::c_int
4887                != 0
4888                && state_index != state_index_to_preserve
4889            {
4890                let mut other_state: *mut QueryState = &mut *((*self_0).states.contents)
4891                    .offset(state_index as isize)
4892                    as *mut QueryState;
4893                (*state).capture_list_id = (*other_state).capture_list_id;
4894                (*other_state).capture_list_id = NONE as u32;
4895                (*other_state).set_dead(1 as os::raw::c_int != 0);
4896                let mut list: *mut CaptureList = capture_list_pool_get_mut(
4897                    &mut (*self_0).capture_list_pool,
4898                    (*state).capture_list_id as u16,
4899                );
4900                (*list).size = 0 as os::raw::c_int as u32;
4901                return list;
4902            } else {
4903                return 0 as *mut CaptureList;
4904            }
4905        }
4906    }
4907    return capture_list_pool_get_mut(
4908        &mut (*self_0).capture_list_pool,
4909        (*state).capture_list_id as u16,
4910    );
4911}
4912unsafe extern "C" fn ts_query_cursor__capture(
4913    mut self_0: *mut TSQueryCursor,
4914    mut state: *mut QueryState,
4915    mut step: *mut QueryStep,
4916    mut node: TSNode,
4917) {
4918    if (*state).dead() {
4919        return;
4920    }
4921    let mut capture_list: *mut CaptureList =
4922        ts_query_cursor__prepare_to_capture(self_0, state, 4294967295 as os::raw::c_uint);
4923    if capture_list.is_null() {
4924        (*state).set_dead(1 as os::raw::c_int != 0);
4925        return;
4926    }
4927    let mut j: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
4928    while j < 3 as os::raw::c_int as os::raw::c_uint {
4929        let mut capture_id: u16 = (*step).capture_ids[j as usize];
4930        if (*step).capture_ids[j as usize] as os::raw::c_int == NONE as os::raw::c_int {
4931            break;
4932        }
4933        array__grow(
4934            capture_list as *mut VoidArray,
4935            1 as os::raw::c_int as size_t,
4936            ::std::mem::size_of::<TSQueryCapture>() as usize,
4937        );
4938        let ref mut fresh90 = (*capture_list).size;
4939        let fresh91 = *fresh90;
4940        *fresh90 = (*fresh90).wrapping_add(1);
4941        *((*capture_list).contents).offset(fresh91 as isize) = {
4942            let mut init = TSQueryCapture {
4943                node: node,
4944                index: capture_id as u32,
4945            };
4946            init
4947        };
4948        j = j.wrapping_add(1);
4949    }
4950}
4951unsafe extern "C" fn ts_query_cursor__copy_state(
4952    mut self_0: *mut TSQueryCursor,
4953    mut state_ref: *mut *mut QueryState,
4954) -> *mut QueryState {
4955    let mut state: *const QueryState = *state_ref;
4956    let mut state_index: u32 = state.offset_from((*self_0).states.contents) as isize as u32;
4957    let mut copy: QueryState = *state;
4958    copy.capture_list_id = NONE as u32;
4959    if (*state).capture_list_id != NONE as os::raw::c_uint {
4960        let mut new_captures: *mut CaptureList =
4961            ts_query_cursor__prepare_to_capture(self_0, &mut copy, state_index);
4962        if new_captures.is_null() {
4963            return 0 as *mut QueryState;
4964        }
4965        let mut old_captures: *const CaptureList = capture_list_pool_get(
4966            &mut (*self_0).capture_list_pool,
4967            (*state).capture_list_id as u16,
4968        );
4969        array__splice(
4970            new_captures as *mut VoidArray,
4971            ::std::mem::size_of::<TSQueryCapture>() as usize,
4972            (*new_captures).size,
4973            0 as os::raw::c_int as u32,
4974            (*old_captures).size,
4975            (*old_captures).contents as *const os::raw::c_void,
4976        );
4977    }
4978    array__splice(
4979        &mut (*self_0).states as *mut C2RustUnnamed_15 as *mut VoidArray,
4980        ::std::mem::size_of::<QueryState>() as usize,
4981        state_index.wrapping_add(1 as os::raw::c_int as os::raw::c_uint),
4982        0 as os::raw::c_int as u32,
4983        1 as os::raw::c_int as u32,
4984        &mut copy as *mut QueryState as *const os::raw::c_void,
4985    );
4986    *state_ref = &mut *((*self_0).states.contents).offset(state_index as isize) as *mut QueryState;
4987    return &mut *((*self_0).states.contents)
4988        .offset(state_index.wrapping_add(1 as os::raw::c_int as os::raw::c_uint) as isize)
4989        as *mut QueryState;
4990}
4991#[inline]
4992unsafe extern "C" fn ts_query_cursor__advance(
4993    mut self_0: *mut TSQueryCursor,
4994    mut stop_on_definite_step: bool,
4995) -> bool {
4996    let mut did_match: bool = false;
4997    loop {
4998        if (*self_0).halted {
4999            while (*self_0).states.size > 0 as os::raw::c_int as os::raw::c_uint {
5000                let ref mut fresh92 = (*self_0).states.size;
5001                *fresh92 = (*fresh92).wrapping_sub(1);
5002                let mut state: QueryState = *((*self_0).states.contents).offset(*fresh92 as isize);
5003                capture_list_pool_release(
5004                    &mut (*self_0).capture_list_pool,
5005                    state.capture_list_id as u16,
5006                );
5007            }
5008        }
5009        if did_match as os::raw::c_int != 0 || (*self_0).halted as os::raw::c_int != 0 {
5010            return did_match;
5011        }
5012        if (*self_0).ascending {
5013            if ts_tree_cursor_goto_next_sibling(&mut (*self_0).cursor) {
5014                (*self_0).ascending = false;
5015            } else if ts_tree_cursor_goto_parent(&mut (*self_0).cursor) {
5016                let ref mut fresh93 = (*self_0).depth;
5017                *fresh93 = (*fresh93).wrapping_sub(1);
5018            } else {
5019                (*self_0).halted = true;
5020            }
5021            let mut deleted_count: u32 = 0 as os::raw::c_int as u32;
5022            let mut current_block_26: u64;
5023            let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
5024            let mut n: os::raw::c_uint = (*self_0).states.size;
5025            while i < n {
5026                let mut state_0: *mut QueryState =
5027                    &mut *((*self_0).states.contents).offset(i as isize) as *mut QueryState;
5028                let mut step: *mut QueryStep = &mut *((*(*self_0).query).steps.contents)
5029                    .offset((*state_0).step_index as isize)
5030                    as *mut QueryStep;
5031                if (*step).depth as os::raw::c_int == PATTERN_DONE_MARKER as os::raw::c_int {
5032                    if (*state_0).start_depth as os::raw::c_uint > (*self_0).depth
5033                        || (*self_0).halted as os::raw::c_int != 0
5034                    {
5035                        array__grow(
5036                            &mut (*self_0).finished_states as *mut C2RustUnnamed_14
5037                                as *mut VoidArray,
5038                            1 as os::raw::c_int as size_t,
5039                            ::std::mem::size_of::<QueryState>() as usize,
5040                        );
5041                        let ref mut fresh94 = (*self_0).finished_states.size;
5042                        let fresh95 = *fresh94;
5043                        *fresh94 = (*fresh94).wrapping_add(1);
5044                        *((*self_0).finished_states.contents).offset(fresh95 as isize) = *state_0;
5045                        did_match = true;
5046                        deleted_count = deleted_count.wrapping_add(1);
5047                        current_block_26 = 11584701595673473500;
5048                    } else {
5049                        current_block_26 = 8704759739624374314;
5050                    }
5051                } else if ((*state_0).start_depth as u32).wrapping_add((*step).depth as u32)
5052                    > (*self_0).depth
5053                {
5054                    capture_list_pool_release(
5055                        &mut (*self_0).capture_list_pool,
5056                        (*state_0).capture_list_id as u16,
5057                    );
5058                    deleted_count = deleted_count.wrapping_add(1);
5059                    current_block_26 = 11584701595673473500;
5060                } else {
5061                    current_block_26 = 8704759739624374314;
5062                }
5063                match current_block_26 {
5064                    8704759739624374314 => {
5065                        if deleted_count > 0 as os::raw::c_int as os::raw::c_uint {
5066                            *((*self_0).states.contents)
5067                                .offset(i.wrapping_sub(deleted_count) as isize) = *state_0;
5068                        }
5069                    }
5070                    _ => {}
5071                }
5072                i = i.wrapping_add(1);
5073            }
5074            let ref mut fresh96 = (*self_0).states.size;
5075            *fresh96 = (*fresh96 as os::raw::c_uint).wrapping_sub(deleted_count) as u32 as u32;
5076        } else {
5077            let mut node: TSNode = ts_tree_cursor_current_node(&mut (*self_0).cursor);
5078            let mut parent_node: TSNode = ts_tree_cursor_parent_node(&mut (*self_0).cursor);
5079            let mut symbol: TSSymbol = ts_node_symbol(node);
5080            let mut is_named: bool = ts_node_is_named(node);
5081            let mut has_later_siblings: bool = false;
5082            let mut has_later_named_siblings: bool = false;
5083            let mut can_have_later_siblings_with_this_field: bool = false;
5084            let mut field_id: TSFieldId = 0 as os::raw::c_int as TSFieldId;
5085            let mut supertypes: [TSSymbol; 8] =
5086                [0 as os::raw::c_int as TSSymbol, 0, 0, 0, 0, 0, 0, 0];
5087            let mut supertype_count: os::raw::c_uint = 8 as os::raw::c_int as os::raw::c_uint;
5088            ts_tree_cursor_current_status(
5089                &mut (*self_0).cursor,
5090                &mut field_id,
5091                &mut has_later_siblings,
5092                &mut has_later_named_siblings,
5093                &mut can_have_later_siblings_with_this_field,
5094                supertypes.as_mut_ptr(),
5095                &mut supertype_count,
5096            );
5097            let mut node_intersects_range: bool = ts_node_end_byte(node) > (*self_0).start_byte
5098                && ts_node_start_byte(node) < (*self_0).end_byte
5099                && point_gt(ts_node_end_point(node), (*self_0).start_point) as os::raw::c_int != 0
5100                && point_lt(ts_node_start_point(node), (*self_0).end_point) as os::raw::c_int != 0;
5101            let mut parent_intersects_range: bool = ts_node_is_null(parent_node) as os::raw::c_int
5102                != 0
5103                || ts_node_end_byte(parent_node) > (*self_0).start_byte
5104                    && ts_node_start_byte(parent_node) < (*self_0).end_byte
5105                    && point_gt(ts_node_end_point(parent_node), (*self_0).start_point)
5106                        as os::raw::c_int
5107                        != 0
5108                    && point_lt(ts_node_start_point(parent_node), (*self_0).end_point)
5109                        as os::raw::c_int
5110                        != 0;
5111            let mut node_is_error: bool =
5112                symbol as os::raw::c_int == -(1 as os::raw::c_int) as TSSymbol as os::raw::c_int;
5113            let mut parent_is_error: bool = !ts_node_is_null(parent_node)
5114                && ts_node_symbol(parent_node) as os::raw::c_int
5115                    == -(1 as os::raw::c_int) as TSSymbol as os::raw::c_int;
5116            if !node_is_error {
5117                let mut i_0: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
5118                while i_0 < (*(*self_0).query).wildcard_root_pattern_count as os::raw::c_uint {
5119                    let mut pattern: *mut PatternEntry =
5120                        &mut *((*(*self_0).query).pattern_map.contents).offset(i_0 as isize)
5121                            as *mut PatternEntry;
5122                    let mut step_0: *mut QueryStep = &mut *((*(*self_0).query).steps.contents)
5123                        .offset((*pattern).step_index as isize)
5124                        as *mut QueryStep;
5125                    if (if (*pattern).is_rooted as os::raw::c_int != 0 {
5126                        node_intersects_range as os::raw::c_int
5127                    } else {
5128                        (parent_intersects_range as os::raw::c_int != 0 && !parent_is_error)
5129                            as os::raw::c_int
5130                    }) != 0
5131                        && ((*step_0).field == 0
5132                            || field_id as os::raw::c_int == (*step_0).field as os::raw::c_int)
5133                        && ((*step_0).supertype_symbol == 0
5134                            || supertype_count > 0 as os::raw::c_int as os::raw::c_uint)
5135                    {
5136                        ts_query_cursor__add_state(self_0, pattern);
5137                    }
5138                    i_0 = i_0.wrapping_add(1);
5139                }
5140            }
5141            let mut i_1: os::raw::c_uint = 0;
5142            if ts_query__pattern_map_search((*self_0).query, symbol, &mut i_1) {
5143                let mut pattern_0: *mut PatternEntry =
5144                    &mut *((*(*self_0).query).pattern_map.contents).offset(i_1 as isize)
5145                        as *mut PatternEntry;
5146                let mut step_1: *mut QueryStep = &mut *((*(*self_0).query).steps.contents)
5147                    .offset((*pattern_0).step_index as isize)
5148                    as *mut QueryStep;
5149                loop {
5150                    if (if (*pattern_0).is_rooted as os::raw::c_int != 0 {
5151                        node_intersects_range as os::raw::c_int
5152                    } else {
5153                        (parent_intersects_range as os::raw::c_int != 0 && !parent_is_error)
5154                            as os::raw::c_int
5155                    }) != 0
5156                        && ((*step_1).field == 0
5157                            || field_id as os::raw::c_int == (*step_1).field as os::raw::c_int)
5158                    {
5159                        ts_query_cursor__add_state(self_0, pattern_0);
5160                    }
5161                    i_1 = i_1.wrapping_add(1);
5162                    if i_1 == (*(*self_0).query).pattern_map.size {
5163                        break;
5164                    }
5165                    pattern_0 = &mut *((*(*self_0).query).pattern_map.contents).offset(i_1 as isize)
5166                        as *mut PatternEntry;
5167                    step_1 = &mut *((*(*self_0).query).steps.contents)
5168                        .offset((*pattern_0).step_index as isize)
5169                        as *mut QueryStep;
5170                    if !((*step_1).symbol as os::raw::c_int == symbol as os::raw::c_int) {
5171                        break;
5172                    }
5173                }
5174            }
5175            let mut i_2: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
5176            let mut copy_count: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
5177            while i_2 < (*self_0).states.size {
5178                let mut state_1: *mut QueryState =
5179                    &mut *((*self_0).states.contents).offset(i_2 as isize) as *mut QueryState;
5180                let mut step_2: *mut QueryStep = &mut *((*(*self_0).query).steps.contents)
5181                    .offset((*state_1).step_index as isize)
5182                    as *mut QueryStep;
5183                (*state_1).set_has_in_progress_alternatives(0 as os::raw::c_int != 0);
5184                copy_count = 0 as os::raw::c_int as os::raw::c_uint;
5185                if !(((*state_1).start_depth as u32).wrapping_add((*step_2).depth as u32)
5186                    != (*self_0).depth)
5187                {
5188                    let mut node_does_match: bool = false;
5189                    if (*step_2).symbol as os::raw::c_int == WILDCARD_SYMBOL as os::raw::c_int {
5190                        node_does_match = !node_is_error
5191                            && (is_named as os::raw::c_int != 0 || !(*step_2).is_named());
5192                    } else {
5193                        node_does_match =
5194                            symbol as os::raw::c_int == (*step_2).symbol as os::raw::c_int;
5195                    }
5196                    let mut later_sibling_can_match: bool = has_later_siblings;
5197                    if (*step_2).is_immediate() as os::raw::c_int != 0
5198                        && is_named as os::raw::c_int != 0
5199                        || (*state_1).seeking_immediate_match() as os::raw::c_int != 0
5200                    {
5201                        later_sibling_can_match = false;
5202                    }
5203                    if (*step_2).is_last_child() as os::raw::c_int != 0
5204                        && has_later_named_siblings as os::raw::c_int != 0
5205                    {
5206                        node_does_match = false;
5207                    }
5208                    if (*step_2).supertype_symbol != 0 {
5209                        let mut has_supertype: bool = false;
5210                        let mut j: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
5211                        while j < supertype_count {
5212                            if supertypes[j as usize] as os::raw::c_int
5213                                == (*step_2).supertype_symbol as os::raw::c_int
5214                            {
5215                                has_supertype = true;
5216                                break;
5217                            } else {
5218                                j = j.wrapping_add(1);
5219                            }
5220                        }
5221                        if !has_supertype {
5222                            node_does_match = false;
5223                        }
5224                    }
5225                    if (*step_2).field != 0 {
5226                        if (*step_2).field as os::raw::c_int == field_id as os::raw::c_int {
5227                            if !can_have_later_siblings_with_this_field {
5228                                later_sibling_can_match = false;
5229                            }
5230                        } else {
5231                            node_does_match = false;
5232                        }
5233                    }
5234                    if (*step_2).negated_field_list_id != 0 {
5235                        let mut negated_field_ids: *mut TSFieldId =
5236                            &mut *((*(*self_0).query).negated_fields.contents)
5237                                .offset((*step_2).negated_field_list_id as isize)
5238                                as *mut TSFieldId;
5239                        loop {
5240                            let mut negated_field_id: TSFieldId = *negated_field_ids;
5241                            if !(negated_field_id != 0) {
5242                                break;
5243                            }
5244                            negated_field_ids = negated_field_ids.offset(1);
5245                            if ((ts_node_child_by_field_id(node, negated_field_id)).id).is_null() {
5246                                continue;
5247                            }
5248                            node_does_match = false;
5249                            break;
5250                        }
5251                    }
5252                    if !node_does_match {
5253                        if !later_sibling_can_match {
5254                            capture_list_pool_release(
5255                                &mut (*self_0).capture_list_pool,
5256                                (*state_1).capture_list_id as u16,
5257                            );
5258                            array__erase(
5259                                &mut (*self_0).states as *mut C2RustUnnamed_15 as *mut VoidArray,
5260                                ::std::mem::size_of::<QueryState>() as usize,
5261                                i_2,
5262                            );
5263                            i_2 = i_2.wrapping_sub(1);
5264                        }
5265                    } else {
5266                        if later_sibling_can_match as os::raw::c_int != 0
5267                            && ((*step_2).contains_captures() as os::raw::c_int != 0
5268                                || ts_query__step_is_fallible(
5269                                    (*self_0).query,
5270                                    (*state_1).step_index,
5271                                ) as os::raw::c_int
5272                                    != 0)
5273                        {
5274                            if !(ts_query_cursor__copy_state(self_0, &mut state_1)).is_null() {
5275                                copy_count = copy_count.wrapping_add(1);
5276                            }
5277                        }
5278                        if (*state_1).needs_parent() {
5279                            let mut parent: TSNode =
5280                                ts_tree_cursor_parent_node(&mut (*self_0).cursor);
5281                            if ts_node_is_null(parent) {
5282                                (*state_1).set_dead(1 as os::raw::c_int != 0);
5283                            } else {
5284                                (*state_1).set_needs_parent(0 as os::raw::c_int != 0);
5285                                let mut skipped_wildcard_step: *mut QueryStep = step_2;
5286                                loop {
5287                                    skipped_wildcard_step = skipped_wildcard_step.offset(-1);
5288                                    if !((*skipped_wildcard_step).is_dead_end() as os::raw::c_int
5289                                        != 0
5290                                        || (*skipped_wildcard_step).is_pass_through()
5291                                            as os::raw::c_int
5292                                            != 0
5293                                        || (*skipped_wildcard_step).depth as os::raw::c_int
5294                                            > 0 as os::raw::c_int)
5295                                    {
5296                                        break;
5297                                    }
5298                                }
5299                                if (*skipped_wildcard_step).capture_ids
5300                                    [0 as os::raw::c_int as usize]
5301                                    as os::raw::c_int
5302                                    != NONE as os::raw::c_int
5303                                {
5304                                    ts_query_cursor__capture(
5305                                        self_0,
5306                                        state_1,
5307                                        skipped_wildcard_step,
5308                                        parent,
5309                                    );
5310                                }
5311                            }
5312                        }
5313                        if (*step_2).capture_ids[0 as os::raw::c_int as usize] as os::raw::c_int
5314                            != NONE as os::raw::c_int
5315                        {
5316                            ts_query_cursor__capture(self_0, state_1, step_2, node);
5317                        }
5318                        if (*state_1).dead() {
5319                            array__erase(
5320                                &mut (*self_0).states as *mut C2RustUnnamed_15 as *mut VoidArray,
5321                                ::std::mem::size_of::<QueryState>() as usize,
5322                                i_2,
5323                            );
5324                            i_2 = i_2.wrapping_sub(1);
5325                        } else {
5326                            let ref mut fresh97 = (*state_1).step_index;
5327                            *fresh97 = (*fresh97).wrapping_add(1);
5328                            (*state_1).set_seeking_immediate_match(0 as os::raw::c_int != 0);
5329                            let mut next_step: *mut QueryStep =
5330                                &mut *((*(*self_0).query).steps.contents)
5331                                    .offset((*state_1).step_index as isize)
5332                                    as *mut QueryStep;
5333                            if stop_on_definite_step as os::raw::c_int != 0
5334                                && (*next_step).root_pattern_guaranteed() as os::raw::c_int != 0
5335                            {
5336                                did_match = true;
5337                            }
5338                            let mut end_index: os::raw::c_uint =
5339                                i_2.wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
5340                            let mut j_0: os::raw::c_uint = i_2;
5341                            while j_0 < end_index {
5342                                let mut state_2: *mut QueryState = &mut *((*self_0).states.contents)
5343                                    .offset(j_0 as isize)
5344                                    as *mut QueryState;
5345                                let mut next_step_0: *mut QueryStep =
5346                                    &mut *((*(*self_0).query).steps.contents)
5347                                        .offset((*state_2).step_index as isize)
5348                                        as *mut QueryStep;
5349                                if (*next_step_0).alternative_index as os::raw::c_int
5350                                    != NONE as os::raw::c_int
5351                                {
5352                                    if (*next_step_0).is_dead_end() {
5353                                        (*state_2).step_index = (*next_step_0).alternative_index;
5354                                        j_0 = j_0.wrapping_sub(1);
5355                                    } else {
5356                                        if (*next_step_0).is_pass_through() {
5357                                            let ref mut fresh98 = (*state_2).step_index;
5358                                            *fresh98 = (*fresh98).wrapping_add(1);
5359                                            j_0 = j_0.wrapping_sub(1);
5360                                        }
5361                                        let mut copy: *mut QueryState =
5362                                            ts_query_cursor__copy_state(self_0, &mut state_2);
5363                                        if !copy.is_null() {
5364                                            end_index = end_index.wrapping_add(1);
5365                                            copy_count = copy_count.wrapping_add(1);
5366                                            (*copy).step_index = (*next_step_0).alternative_index;
5367                                            if (*next_step_0).alternative_is_immediate() {
5368                                                (*copy).set_seeking_immediate_match(
5369                                                    1 as os::raw::c_int != 0,
5370                                                );
5371                                            }
5372                                        }
5373                                    }
5374                                }
5375                                j_0 = j_0.wrapping_add(1);
5376                            }
5377                        }
5378                    }
5379                }
5380                i_2 = i_2.wrapping_add(
5381                    (1 as os::raw::c_int as os::raw::c_uint).wrapping_add(copy_count),
5382                );
5383            }
5384            let mut i_3: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
5385            while i_3 < (*self_0).states.size {
5386                let mut state_3: *mut QueryState =
5387                    &mut *((*self_0).states.contents).offset(i_3 as isize) as *mut QueryState;
5388                if (*state_3).dead() {
5389                    array__erase(
5390                        &mut (*self_0).states as *mut C2RustUnnamed_15 as *mut VoidArray,
5391                        ::std::mem::size_of::<QueryState>() as usize,
5392                        i_3,
5393                    );
5394                    i_3 = i_3.wrapping_sub(1);
5395                } else {
5396                    let mut did_remove: bool = false;
5397                    let mut current_block_148: u64;
5398                    let mut j_1: os::raw::c_uint =
5399                        i_3.wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
5400                    while j_1 < (*self_0).states.size {
5401                        let mut other_state: *mut QueryState = &mut *((*self_0).states.contents)
5402                            .offset(j_1 as isize)
5403                            as *mut QueryState;
5404                        if (*other_state).start_depth as os::raw::c_int
5405                            != (*state_3).start_depth as os::raw::c_int
5406                            || (*other_state).pattern_index as os::raw::c_int
5407                                != (*state_3).pattern_index as os::raw::c_int
5408                        {
5409                            break;
5410                        }
5411                        let mut left_contains_right: bool = false;
5412                        let mut right_contains_left: bool = false;
5413                        ts_query_cursor__compare_captures(
5414                            self_0,
5415                            state_3,
5416                            other_state,
5417                            &mut left_contains_right,
5418                            &mut right_contains_left,
5419                        );
5420                        if left_contains_right {
5421                            if (*state_3).step_index as os::raw::c_int
5422                                == (*other_state).step_index as os::raw::c_int
5423                            {
5424                                capture_list_pool_release(
5425                                    &mut (*self_0).capture_list_pool,
5426                                    (*other_state).capture_list_id as u16,
5427                                );
5428                                array__erase(
5429                                    &mut (*self_0).states as *mut C2RustUnnamed_15
5430                                        as *mut VoidArray,
5431                                    ::std::mem::size_of::<QueryState>() as usize,
5432                                    j_1,
5433                                );
5434                                j_1 = j_1.wrapping_sub(1);
5435                                current_block_148 = 17418136423408909163;
5436                            } else {
5437                                (*other_state)
5438                                    .set_has_in_progress_alternatives(1 as os::raw::c_int != 0);
5439                                current_block_148 = 2860109724005416757;
5440                            }
5441                        } else {
5442                            current_block_148 = 2860109724005416757;
5443                        }
5444                        match current_block_148 {
5445                            2860109724005416757 => {
5446                                if right_contains_left {
5447                                    if (*state_3).step_index as os::raw::c_int
5448                                        == (*other_state).step_index as os::raw::c_int
5449                                    {
5450                                        capture_list_pool_release(
5451                                            &mut (*self_0).capture_list_pool,
5452                                            (*state_3).capture_list_id as u16,
5453                                        );
5454                                        array__erase(
5455                                            &mut (*self_0).states as *mut C2RustUnnamed_15
5456                                                as *mut VoidArray,
5457                                            ::std::mem::size_of::<QueryState>() as usize,
5458                                            i_3,
5459                                        );
5460                                        i_3 = i_3.wrapping_sub(1);
5461                                        did_remove = true;
5462                                        break;
5463                                    } else {
5464                                        (*state_3).set_has_in_progress_alternatives(
5465                                            1 as os::raw::c_int != 0,
5466                                        );
5467                                    }
5468                                }
5469                            }
5470                            _ => {}
5471                        }
5472                        j_1 = j_1.wrapping_add(1);
5473                    }
5474                    if !did_remove {
5475                        let mut next_step_1: *mut QueryStep =
5476                            &mut *((*(*self_0).query).steps.contents)
5477                                .offset((*state_3).step_index as isize)
5478                                as *mut QueryStep;
5479                        if (*next_step_1).depth as os::raw::c_int
5480                            == PATTERN_DONE_MARKER as os::raw::c_int
5481                        {
5482                            if !(*state_3).has_in_progress_alternatives() {
5483                                array__grow(
5484                                    &mut (*self_0).finished_states as *mut C2RustUnnamed_14
5485                                        as *mut VoidArray,
5486                                    1 as os::raw::c_int as size_t,
5487                                    ::std::mem::size_of::<QueryState>() as usize,
5488                                );
5489                                let ref mut fresh99 = (*self_0).finished_states.size;
5490                                let fresh100 = *fresh99;
5491                                *fresh99 = (*fresh99).wrapping_add(1);
5492                                *((*self_0).finished_states.contents).offset(fresh100 as isize) =
5493                                    *state_3;
5494                                array__erase(
5495                                    &mut (*self_0).states as *mut C2RustUnnamed_15
5496                                        as *mut VoidArray,
5497                                    ::std::mem::size_of::<QueryState>() as usize,
5498                                    state_3.offset_from((*self_0).states.contents) as isize as u32,
5499                                );
5500                                did_match = true;
5501                                i_3 = i_3.wrapping_sub(1);
5502                            }
5503                        }
5504                    }
5505                }
5506                i_3 = i_3.wrapping_add(1);
5507            }
5508            let mut should_descend: bool = node_intersects_range;
5509            if !should_descend {
5510                let mut i_4: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
5511                while i_4 < (*self_0).states.size {
5512                    let mut state_4: *mut QueryState =
5513                        &mut *((*self_0).states.contents).offset(i_4 as isize) as *mut QueryState;
5514                    let mut next_step_2: *mut QueryStep = &mut *((*(*self_0).query).steps.contents)
5515                        .offset((*state_4).step_index as isize)
5516                        as *mut QueryStep;
5517                    if (*next_step_2).depth as os::raw::c_int
5518                        != PATTERN_DONE_MARKER as os::raw::c_int
5519                        && ((*state_4).start_depth as os::raw::c_int
5520                            + (*next_step_2).depth as os::raw::c_int)
5521                            as os::raw::c_uint
5522                            > (*self_0).depth
5523                    {
5524                        should_descend = true;
5525                        break;
5526                    } else {
5527                        i_4 = i_4.wrapping_add(1);
5528                    }
5529                }
5530            }
5531            !should_descend;
5532            if should_descend as os::raw::c_int != 0
5533                && ts_tree_cursor_goto_first_child(&mut (*self_0).cursor) as os::raw::c_int != 0
5534            {
5535                let ref mut fresh101 = (*self_0).depth;
5536                *fresh101 = (*fresh101).wrapping_add(1);
5537            } else {
5538                (*self_0).ascending = true;
5539            }
5540        }
5541    }
5542}
5543#[no_mangle]
5544pub unsafe extern "C" fn ts_query_cursor_next_match(
5545    mut self_0: *mut TSQueryCursor,
5546    mut match_0: *mut TSQueryMatch,
5547) -> bool {
5548    if (*self_0).finished_states.size == 0 as os::raw::c_int as os::raw::c_uint {
5549        if !ts_query_cursor__advance(self_0, false) {
5550            return false;
5551        }
5552    }
5553    let mut state: *mut QueryState = &mut *((*self_0).finished_states.contents)
5554        .offset(0 as os::raw::c_int as isize)
5555        as *mut QueryState;
5556    if (*state).id == 4294967295 as os::raw::c_uint {
5557        let ref mut fresh102 = (*self_0).next_state_id;
5558        let fresh103 = *fresh102;
5559        *fresh102 = (*fresh102).wrapping_add(1);
5560        (*state).id = fresh103;
5561    }
5562    (*match_0).id = (*state).id;
5563    (*match_0).pattern_index = (*state).pattern_index;
5564    let mut captures: *const CaptureList = capture_list_pool_get(
5565        &mut (*self_0).capture_list_pool,
5566        (*state).capture_list_id as u16,
5567    );
5568    let ref mut fresh104 = (*match_0).captures;
5569    *fresh104 = (*captures).contents;
5570    (*match_0).capture_count = (*captures).size as u16;
5571    capture_list_pool_release(
5572        &mut (*self_0).capture_list_pool,
5573        (*state).capture_list_id as u16,
5574    );
5575    array__erase(
5576        &mut (*self_0).finished_states as *mut C2RustUnnamed_14 as *mut VoidArray,
5577        ::std::mem::size_of::<QueryState>() as usize,
5578        0 as os::raw::c_int as u32,
5579    );
5580    return true;
5581}
5582#[no_mangle]
5583pub unsafe extern "C" fn ts_query_cursor_remove_match(
5584    mut self_0: *mut TSQueryCursor,
5585    mut match_id: u32,
5586) {
5587    let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
5588    while i < (*self_0).finished_states.size {
5589        let mut state: *const QueryState =
5590            &mut *((*self_0).finished_states.contents).offset(i as isize) as *mut QueryState;
5591        if (*state).id == match_id {
5592            capture_list_pool_release(
5593                &mut (*self_0).capture_list_pool,
5594                (*state).capture_list_id as u16,
5595            );
5596            array__erase(
5597                &mut (*self_0).finished_states as *mut C2RustUnnamed_14 as *mut VoidArray,
5598                ::std::mem::size_of::<QueryState>() as usize,
5599                i,
5600            );
5601            return;
5602        }
5603        i = i.wrapping_add(1);
5604    }
5605    let mut i_0: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
5606    while i_0 < (*self_0).states.size {
5607        let mut state_0: *const QueryState =
5608            &mut *((*self_0).states.contents).offset(i_0 as isize) as *mut QueryState;
5609        if (*state_0).id == match_id {
5610            capture_list_pool_release(
5611                &mut (*self_0).capture_list_pool,
5612                (*state_0).capture_list_id as u16,
5613            );
5614            array__erase(
5615                &mut (*self_0).states as *mut C2RustUnnamed_15 as *mut VoidArray,
5616                ::std::mem::size_of::<QueryState>() as usize,
5617                i_0,
5618            );
5619            return;
5620        }
5621        i_0 = i_0.wrapping_add(1);
5622    }
5623}
5624#[no_mangle]
5625pub unsafe extern "C" fn ts_query_cursor_next_capture(
5626    mut self_0: *mut TSQueryCursor,
5627    mut match_0: *mut TSQueryMatch,
5628    mut capture_index: *mut u32,
5629) -> bool {
5630    loop {
5631        let mut first_unfinished_capture_byte: u32 = 0;
5632        let mut first_unfinished_pattern_index: u32 = 0;
5633        let mut first_unfinished_state_index: u32 = 0;
5634        let mut first_unfinished_state_is_definite: bool = false;
5635        ts_query_cursor__first_in_progress_capture(
5636            self_0,
5637            &mut first_unfinished_state_index,
5638            &mut first_unfinished_capture_byte,
5639            &mut first_unfinished_pattern_index,
5640            &mut first_unfinished_state_is_definite,
5641        );
5642        let mut first_finished_state: *mut QueryState = 0 as *mut QueryState;
5643        let mut first_finished_capture_byte: u32 = first_unfinished_capture_byte;
5644        let mut first_finished_pattern_index: u32 = first_unfinished_pattern_index;
5645        let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
5646        while i < (*self_0).finished_states.size {
5647            let mut state: *mut QueryState =
5648                &mut *((*self_0).finished_states.contents).offset(i as isize) as *mut QueryState;
5649            let mut captures: *const CaptureList = capture_list_pool_get(
5650                &mut (*self_0).capture_list_pool,
5651                (*state).capture_list_id as u16,
5652            );
5653            if (*state).consumed_capture_count() as os::raw::c_uint >= (*captures).size {
5654                capture_list_pool_release(
5655                    &mut (*self_0).capture_list_pool,
5656                    (*state).capture_list_id as u16,
5657                );
5658                array__erase(
5659                    &mut (*self_0).finished_states as *mut C2RustUnnamed_14 as *mut VoidArray,
5660                    ::std::mem::size_of::<QueryState>() as usize,
5661                    i,
5662                );
5663            } else {
5664                let mut node: TSNode = (*((*captures).contents)
5665                    .offset((*state).consumed_capture_count() as isize))
5666                .node;
5667                if ts_node_end_byte(node) <= (*self_0).start_byte {
5668                    (*state).set_consumed_capture_count((*state).consumed_capture_count() + 1);
5669                } else {
5670                    let mut node_start_byte: u32 = ts_node_start_byte(node);
5671                    if node_start_byte < first_finished_capture_byte
5672                        || node_start_byte == first_finished_capture_byte
5673                            && ((*state).pattern_index as os::raw::c_uint)
5674                                < first_finished_pattern_index
5675                    {
5676                        first_finished_state = state;
5677                        first_finished_capture_byte = node_start_byte;
5678                        first_finished_pattern_index = (*state).pattern_index as u32;
5679                    }
5680                    i = i.wrapping_add(1);
5681                }
5682            }
5683        }
5684        let mut state_0: *mut QueryState = 0 as *mut QueryState;
5685        if !first_finished_state.is_null() {
5686            state_0 = first_finished_state;
5687        } else if first_unfinished_state_is_definite {
5688            state_0 = &mut *((*self_0).states.contents)
5689                .offset(first_unfinished_state_index as isize)
5690                as *mut QueryState;
5691        } else {
5692            state_0 = 0 as *mut QueryState;
5693        }
5694        if !state_0.is_null() {
5695            if (*state_0).id == 4294967295 as os::raw::c_uint {
5696                let ref mut fresh105 = (*self_0).next_state_id;
5697                let fresh106 = *fresh105;
5698                *fresh105 = (*fresh105).wrapping_add(1);
5699                (*state_0).id = fresh106;
5700            }
5701            (*match_0).id = (*state_0).id;
5702            (*match_0).pattern_index = (*state_0).pattern_index;
5703            let mut captures_0: *const CaptureList = capture_list_pool_get(
5704                &mut (*self_0).capture_list_pool,
5705                (*state_0).capture_list_id as u16,
5706            );
5707            let ref mut fresh107 = (*match_0).captures;
5708            *fresh107 = (*captures_0).contents;
5709            (*match_0).capture_count = (*captures_0).size as u16;
5710            *capture_index = (*state_0).consumed_capture_count() as u32;
5711            (*state_0).set_consumed_capture_count((*state_0).consumed_capture_count() + 1);
5712            return true;
5713        }
5714        if capture_list_pool_is_empty(&mut (*self_0).capture_list_pool) {
5715            capture_list_pool_release(
5716                &mut (*self_0).capture_list_pool,
5717                (*((*self_0).states.contents).offset(first_unfinished_state_index as isize))
5718                    .capture_list_id as u16,
5719            );
5720            array__erase(
5721                &mut (*self_0).states as *mut C2RustUnnamed_15 as *mut VoidArray,
5722                ::std::mem::size_of::<QueryState>() as usize,
5723                first_unfinished_state_index,
5724            );
5725        }
5726        if !ts_query_cursor__advance(self_0, true)
5727            && (*self_0).finished_states.size == 0 as os::raw::c_int as os::raw::c_uint
5728        {
5729            return false;
5730        }
5731    }
5732}