tree_sitter_c2rust/core_wrapper/core/
subtree.rs

1use crate::core_transpiled::util::*;
2use crate::core_transpiled::*;
3use :: c2rust_bitfields;
4use std::os;
5pub type __uint8_t = libc::c_uchar;
6pub type __int16_t = libc::c_short;
7pub type __uint16_t = libc::c_ushort;
8pub type __int32_t = libc::c_int;
9pub type __uint32_t = libc::c_uint;
10pub type __off_t = libc::c_long;
11pub type __off64_t = libc::c_long;
12pub type C2RustUnnamed = libc::c_uint;
13pub const _ISalnum: C2RustUnnamed = 8;
14pub const _ISpunct: C2RustUnnamed = 4;
15pub const _IScntrl: C2RustUnnamed = 2;
16pub const _ISblank: C2RustUnnamed = 1;
17pub const _ISgraph: C2RustUnnamed = 32768;
18pub const _ISprint: C2RustUnnamed = 16384;
19pub const _ISspace: C2RustUnnamed = 8192;
20pub const _ISxdigit: C2RustUnnamed = 4096;
21pub const _ISdigit: C2RustUnnamed = 2048;
22pub const _ISalpha: C2RustUnnamed = 1024;
23pub const _ISlower: C2RustUnnamed = 512;
24pub const _ISupper: C2RustUnnamed = 256;
25pub type int16_t = __int16_t;
26pub type int32_t = __int32_t;
27pub type uint8_t = __uint8_t;
28pub type uint16_t = __uint16_t;
29pub type uint32_t = __uint32_t;
30pub type _IO_lock_t = ();
31use crate::core_transpiled::util::libc::{dup, fclose, fdopen, fputc, fputs, FILE};
32#[derive(Copy, Clone)]
33#[repr(C)]
34pub struct Array {
35    pub contents: *mut libc::c_void,
36    pub size: uint32_t,
37    pub capacity: uint32_t,
38}
39pub type TSStateId = uint16_t;
40pub type TSFieldId = uint16_t;
41#[derive(Copy, Clone)]
42#[repr(C)]
43pub struct C2RustUnnamed_0 {
44    pub states: *const bool,
45    pub symbol_map: *const TSSymbol,
46    pub create: Option<unsafe extern "C" fn() -> *mut libc::c_void>,
47    pub destroy: Option<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
48    pub scan: Option<unsafe extern "C" fn(*mut libc::c_void, *mut TSLexer, *const bool) -> bool>,
49    pub serialize:
50        Option<unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_char) -> libc::c_uint>,
51    pub deserialize:
52        Option<unsafe extern "C" fn(*mut libc::c_void, *const libc::c_char, libc::c_uint) -> ()>,
53}
54#[derive(Copy, Clone)]
55#[repr(C)]
56pub struct C2RustUnnamed_1 {
57    pub count: uint8_t,
58    pub reusable: bool,
59}
60#[derive(Copy, Clone)]
61#[repr(C)]
62pub struct C2RustUnnamed_2 {
63    pub type_: uint8_t,
64    pub child_count: uint8_t,
65    pub symbol: TSSymbol,
66    pub dynamic_precedence: int16_t,
67    pub production_id: uint16_t,
68}
69#[derive(Copy, Clone)]
70#[repr(C)]
71pub struct C2RustUnnamed_3 {
72    pub type_: uint8_t,
73    pub state: TSStateId,
74    pub extra: bool,
75    pub repetition: bool,
76}
77#[derive(Copy, Clone)]
78#[repr(C)]
79pub struct ExternalScannerState {
80    pub c2rust_unnamed: C2RustUnnamed_4,
81    pub length: uint32_t,
82}
83type C2RustUnnamed_4 = crate::core_transpiled::util::LongShortData;
84#[derive(Copy, Clone, BitfieldStruct)]
85#[repr(C)]
86pub struct SubtreeInlineData {
87    #[bitfield(name = "is_inline", ty = "bool", bits = "0..=0")]
88    #[bitfield(name = "visible", ty = "bool", bits = "1..=1")]
89    #[bitfield(name = "named", ty = "bool", bits = "2..=2")]
90    #[bitfield(name = "extra", ty = "bool", bits = "3..=3")]
91    #[bitfield(name = "has_changes", ty = "bool", bits = "4..=4")]
92    #[bitfield(name = "is_missing", ty = "bool", bits = "5..=5")]
93    #[bitfield(name = "is_keyword", ty = "bool", bits = "6..=6")]
94    pub is_inline_visible_named_extra_has_changes_is_missing_is_keyword: [u8; 1],
95    pub symbol: uint8_t,
96    pub parse_state: uint16_t,
97    pub padding_columns: uint8_t,
98    #[bitfield(name = "padding_rows", ty = "uint8_t", bits = "0..=3")]
99    #[bitfield(name = "lookahead_bytes", ty = "uint8_t", bits = "4..=7")]
100    pub padding_rows_lookahead_bytes: [u8; 1],
101    pub padding_bytes: uint8_t,
102    pub size_bytes: uint8_t,
103}
104#[derive(Copy, Clone, BitfieldStruct)]
105#[repr(C)]
106pub struct SubtreeHeapData {
107    pub ref_count: uint32_t,
108    pub padding: Length,
109    pub size: Length,
110    pub lookahead_bytes: uint32_t,
111    pub error_cost: uint32_t,
112    pub child_count: uint32_t,
113    pub symbol: TSSymbol,
114    pub parse_state: TSStateId,
115    #[bitfield(name = "visible", ty = "bool", bits = "0..=0")]
116    #[bitfield(name = "named", ty = "bool", bits = "1..=1")]
117    #[bitfield(name = "extra", ty = "bool", bits = "2..=2")]
118    #[bitfield(name = "fragile_left", ty = "bool", bits = "3..=3")]
119    #[bitfield(name = "fragile_right", ty = "bool", bits = "4..=4")]
120    #[bitfield(name = "has_changes", ty = "bool", bits = "5..=5")]
121    #[bitfield(name = "has_external_tokens", ty = "bool", bits = "6..=6")]
122    #[bitfield(
123        name = "has_external_scanner_state_change",
124        ty = "bool",
125        bits = "7..=7"
126    )]
127    #[bitfield(name = "depends_on_column", ty = "bool", bits = "8..=8")]
128    #[bitfield(name = "is_missing", ty = "bool", bits = "9..=9")]
129    #[bitfield(name = "is_keyword", ty = "bool", bits = "10..=10")]
130    pub visible_named_extra_fragile_left_fragile_right_has_changes_has_external_tokens_has_external_scanner_state_change_depends_on_column_is_missing_is_keyword:
131        [u8; 2],
132    #[bitfield(padding)]
133    pub c2rust_padding: [u8; 2],
134    pub c2rust_unnamed: C2RustUnnamed_5,
135}
136type C2RustUnnamed_5 = crate::core_transpiled::util::ScannerStateWithLookahead;
137type C2RustUnnamed_6 = crate::core_transpiled::util::ScannerStateLookaheadMeta;
138type C2RustUnnamed_7 = crate::core_transpiled::util::ScannerStateLookaheadFirstLeaf;
139#[derive(Copy, Clone)]
140#[repr(C)]
141pub union Subtree {
142    pub data: SubtreeInlineData,
143    pub ptr: *const SubtreeHeapData,
144}
145#[derive(Copy, Clone)]
146#[repr(C)]
147pub union MutableSubtree {
148    pub data: SubtreeInlineData,
149    pub ptr: *mut SubtreeHeapData,
150}
151#[derive(Copy, Clone)]
152#[repr(C)]
153pub struct SubtreeArray {
154    pub contents: *mut Subtree,
155    pub size: uint32_t,
156    pub capacity: uint32_t,
157}
158#[derive(Copy, Clone)]
159#[repr(C)]
160pub struct MutableSubtreeArray {
161    pub contents: *mut MutableSubtree,
162    pub size: uint32_t,
163    pub capacity: uint32_t,
164}
165#[derive(Copy, Clone)]
166#[repr(C)]
167pub struct SubtreePool {
168    pub free_trees: MutableSubtreeArray,
169    pub tree_stack: MutableSubtreeArray,
170}
171type C2RustUnnamed_8 = crate::core_transpiled::util::StackElement<*mut EditEntry>;
172#[derive(Copy, Clone)]
173#[repr(C)]
174pub struct EditEntry {
175    pub tree: *mut Subtree,
176    pub edit: Edit,
177}
178#[derive(Copy, Clone)]
179#[repr(C)]
180pub struct Edit {
181    pub start: Length,
182    pub old_end: Length,
183    pub new_end: Length,
184}
185#[inline]
186unsafe extern "C" fn _array__reserve(
187    mut self_0: *mut Array,
188    mut element_size: size_t,
189    mut new_capacity: uint32_t,
190) {
191    if new_capacity > (*self_0).capacity {
192        if !((*self_0).contents).is_null() {
193            (*self_0).contents = crate::core_transpiled::alloc::ts_realloc(
194                (*self_0).contents,
195                (new_capacity as libc::c_ulong).wrapping_mul(element_size),
196            );
197        } else {
198            (*self_0).contents = crate::core_transpiled::alloc::ts_malloc(
199                (new_capacity as libc::c_ulong).wrapping_mul(element_size),
200            );
201        }
202        (*self_0).capacity = new_capacity;
203    }
204}
205#[inline]
206unsafe extern "C" fn _array__delete(mut self_0: *mut Array) {
207    if !((*self_0).contents).is_null() {
208        crate::core_transpiled::alloc::ts_free((*self_0).contents);
209        (*self_0).contents = 0 as *mut libc::c_void;
210        (*self_0).size = 0 as libc::c_int as uint32_t;
211        (*self_0).capacity = 0 as libc::c_int as uint32_t;
212    }
213}
214#[inline]
215unsafe extern "C" fn _array__grow(
216    mut self_0: *mut Array,
217    mut count: uint32_t,
218    mut element_size: size_t,
219) {
220    let mut new_size: uint32_t = ((*self_0).size).wrapping_add(count);
221    if new_size > (*self_0).capacity {
222        let mut new_capacity: uint32_t =
223            ((*self_0).capacity).wrapping_mul(2 as libc::c_int as libc::c_uint);
224        if new_capacity < 8 as libc::c_int as libc::c_uint {
225            new_capacity = 8 as libc::c_int as uint32_t;
226        }
227        if new_capacity < new_size {
228            new_capacity = new_size;
229        }
230        _array__reserve(self_0, element_size, new_capacity);
231    }
232}
233#[inline]
234unsafe extern "C" fn point__new(mut row: libc::c_uint, mut column: libc::c_uint) -> TSPoint {
235    let mut result: TSPoint = {
236        let mut init = TSPoint {
237            row: row,
238            column: column,
239        };
240        init
241    };
242    return result;
243}
244#[inline]
245unsafe extern "C" fn point_add(mut a: TSPoint, mut b: TSPoint) -> TSPoint {
246    if b.row > 0 as libc::c_int as libc::c_uint {
247        return point__new((a.row).wrapping_add(b.row), b.column);
248    } else {
249        return point__new(a.row, (a.column).wrapping_add(b.column));
250    };
251}
252#[inline]
253unsafe extern "C" fn point_sub(mut a: TSPoint, mut b: TSPoint) -> TSPoint {
254    if a.row > b.row {
255        return point__new((a.row).wrapping_sub(b.row), a.column);
256    } else {
257        return point__new(
258            0 as libc::c_int as libc::c_uint,
259            (a.column).wrapping_sub(b.column),
260        );
261    };
262}
263#[inline]
264unsafe extern "C" fn length_add(mut len1: Length, mut len2: Length) -> Length {
265    let mut result: Length = Length {
266        bytes: 0,
267        extent: TSPoint { row: 0, column: 0 },
268    };
269    result.bytes = (len1.bytes).wrapping_add(len2.bytes);
270    result.extent = point_add(len1.extent, len2.extent);
271    return result;
272}
273#[inline]
274unsafe extern "C" fn length_sub(mut len1: Length, mut len2: Length) -> Length {
275    let mut result: Length = Length {
276        bytes: 0,
277        extent: TSPoint { row: 0, column: 0 },
278    };
279    result.bytes = (len1.bytes).wrapping_sub(len2.bytes);
280    result.extent = point_sub(len1.extent, len2.extent);
281    return result;
282}
283#[inline]
284unsafe extern "C" fn length_zero() -> Length {
285    let mut result: Length = {
286        let mut init = Length {
287            bytes: 0 as libc::c_int as uint32_t,
288            extent: {
289                let mut init = TSPoint {
290                    row: 0 as libc::c_int as uint32_t,
291                    column: 0 as libc::c_int as uint32_t,
292                };
293                init
294            },
295        };
296        init
297    };
298    return result;
299}
300#[inline]
301unsafe extern "C" fn length_saturating_sub(mut len1: Length, mut len2: Length) -> Length {
302    if len1.bytes > len2.bytes {
303        return length_sub(len1, len2);
304    } else {
305        return length_zero();
306    };
307}
308#[inline]
309unsafe extern "C" fn ts_subtree_extra(mut self_0: Subtree) -> bool {
310    return if (self_0.data).is_inline() as libc::c_int != 0 {
311        (self_0.data).extra() as libc::c_int
312    } else {
313        (*self_0.ptr).extra() as libc::c_int
314    } != 0;
315}
316#[inline]
317unsafe extern "C" fn ts_subtree_parse_state(mut self_0: Subtree) -> TSStateId {
318    return (if (self_0.data).is_inline() as libc::c_int != 0 {
319        self_0.data.parse_state as libc::c_int
320    } else {
321        (*self_0.ptr).parse_state as libc::c_int
322    }) as TSStateId;
323}
324#[inline]
325unsafe extern "C" fn ts_subtree_has_changes(mut self_0: Subtree) -> bool {
326    return if (self_0.data).is_inline() as libc::c_int != 0 {
327        (self_0.data).has_changes() as libc::c_int
328    } else {
329        (*self_0.ptr).has_changes() as libc::c_int
330    } != 0;
331}
332#[inline]
333unsafe extern "C" fn ts_subtree_symbol(mut self_0: Subtree) -> TSSymbol {
334    return (if (self_0.data).is_inline() as libc::c_int != 0 {
335        self_0.data.symbol as libc::c_int
336    } else {
337        (*self_0.ptr).symbol as libc::c_int
338    }) as TSSymbol;
339}
340#[inline]
341unsafe extern "C" fn ts_subtree_named(mut self_0: Subtree) -> bool {
342    return if (self_0.data).is_inline() as libc::c_int != 0 {
343        (self_0.data).named() as libc::c_int
344    } else {
345        (*self_0.ptr).named() as libc::c_int
346    } != 0;
347}
348#[inline]
349unsafe extern "C" fn ts_subtree_visible(mut self_0: Subtree) -> bool {
350    return if (self_0.data).is_inline() as libc::c_int != 0 {
351        (self_0.data).visible() as libc::c_int
352    } else {
353        (*self_0.ptr).visible() as libc::c_int
354    } != 0;
355}
356#[inline]
357unsafe extern "C" fn ts_subtree_alloc_size(mut child_count: uint32_t) -> size_t {
358    return (child_count as libc::c_ulong)
359        .wrapping_mul(::core::mem::size_of::<Subtree>() as libc::c_ulong)
360        .wrapping_add(::core::mem::size_of::<SubtreeHeapData>() as libc::c_ulong);
361}
362#[inline]
363unsafe extern "C" fn ts_subtree_lookahead_bytes(mut self_0: Subtree) -> uint32_t {
364    return if (self_0.data).is_inline() as libc::c_int != 0 {
365        (self_0.data).lookahead_bytes() as libc::c_uint
366    } else {
367        (*self_0.ptr).lookahead_bytes
368    };
369}
370#[inline]
371unsafe extern "C" fn ts_subtree_missing(mut self_0: Subtree) -> bool {
372    return if (self_0.data).is_inline() as libc::c_int != 0 {
373        (self_0.data).is_missing() as libc::c_int
374    } else {
375        (*self_0.ptr).is_missing() as libc::c_int
376    } != 0;
377}
378#[inline]
379unsafe extern "C" fn ts_subtree_error_cost(mut self_0: Subtree) -> uint32_t {
380    if ts_subtree_missing(self_0) {
381        return (110 as libc::c_int + 500 as libc::c_int) as uint32_t;
382    } else {
383        return if (self_0.data).is_inline() as libc::c_int != 0 {
384            0 as libc::c_int as libc::c_uint
385        } else {
386            (*self_0.ptr).error_cost
387        };
388    };
389}
390#[inline]
391unsafe extern "C" fn ts_subtree_total_size(mut self_0: Subtree) -> Length {
392    return length_add(ts_subtree_padding(self_0), ts_subtree_size(self_0));
393}
394#[inline]
395unsafe extern "C" fn ts_subtree_size(mut self_0: Subtree) -> Length {
396    if (self_0.data).is_inline() {
397        let mut result: Length = {
398            let mut init = Length {
399                bytes: self_0.data.size_bytes as uint32_t,
400                extent: {
401                    let mut init = TSPoint {
402                        row: 0 as libc::c_int as uint32_t,
403                        column: self_0.data.size_bytes as uint32_t,
404                    };
405                    init
406                },
407            };
408            init
409        };
410        return result;
411    } else {
412        return (*self_0.ptr).size;
413    };
414}
415#[inline]
416unsafe extern "C" fn ts_subtree_padding(mut self_0: Subtree) -> Length {
417    if (self_0.data).is_inline() {
418        let mut result: Length = {
419            let mut init = Length {
420                bytes: self_0.data.padding_bytes as uint32_t,
421                extent: {
422                    let mut init = TSPoint {
423                        row: (self_0.data).padding_rows() as uint32_t,
424                        column: self_0.data.padding_columns as uint32_t,
425                    };
426                    init
427                },
428            };
429            init
430        };
431        return result;
432    } else {
433        return (*self_0.ptr).padding;
434    };
435}
436#[inline]
437unsafe extern "C" fn ts_subtree_repeat_depth(mut self_0: Subtree) -> uint32_t {
438    return (if (self_0.data).is_inline() as libc::c_int != 0 {
439        0 as libc::c_int
440    } else {
441        (*self_0.ptr).c2rust_unnamed.c2rust_unnamed.repeat_depth as libc::c_int
442    }) as uint32_t;
443}
444#[inline]
445unsafe extern "C" fn ts_subtree_visible_descendant_count(mut self_0: Subtree) -> uint32_t {
446    return if (self_0.data).is_inline() as libc::c_int != 0
447        || (*self_0.ptr).child_count == 0 as libc::c_int as libc::c_uint
448    {
449        0 as libc::c_int as libc::c_uint
450    } else {
451        (*self_0.ptr)
452            .c2rust_unnamed
453            .c2rust_unnamed
454            .visible_descendant_count
455    };
456}
457#[inline]
458unsafe extern "C" fn ts_subtree_total_bytes(mut self_0: Subtree) -> uint32_t {
459    return (ts_subtree_total_size(self_0)).bytes;
460}
461#[inline]
462unsafe extern "C" fn ts_subtree_leaf_parse_state(mut self_0: Subtree) -> TSStateId {
463    if (self_0.data).is_inline() {
464        return self_0.data.parse_state;
465    }
466    if (*self_0.ptr).child_count == 0 as libc::c_int as libc::c_uint {
467        return (*self_0.ptr).parse_state;
468    }
469    return (*self_0.ptr)
470        .c2rust_unnamed
471        .c2rust_unnamed
472        .first_leaf
473        .parse_state;
474}
475#[inline]
476unsafe extern "C" fn ts_subtree_child_count(mut self_0: Subtree) -> uint32_t {
477    return if (self_0.data).is_inline() as libc::c_int != 0 {
478        0 as libc::c_int as libc::c_uint
479    } else {
480        (*self_0.ptr).child_count
481    };
482}
483#[inline]
484unsafe extern "C" fn ts_subtree_leaf_symbol(mut self_0: Subtree) -> TSSymbol {
485    if (self_0.data).is_inline() {
486        return self_0.data.symbol as TSSymbol;
487    }
488    if (*self_0.ptr).child_count == 0 as libc::c_int as libc::c_uint {
489        return (*self_0.ptr).symbol;
490    }
491    return (*self_0.ptr)
492        .c2rust_unnamed
493        .c2rust_unnamed
494        .first_leaf
495        .symbol;
496}
497#[inline]
498unsafe extern "C" fn ts_subtree_dynamic_precedence(mut self_0: Subtree) -> int32_t {
499    return if (self_0.data).is_inline() as libc::c_int != 0
500        || (*self_0.ptr).child_count == 0 as libc::c_int as libc::c_uint
501    {
502        0 as libc::c_int
503    } else {
504        (*self_0.ptr)
505            .c2rust_unnamed
506            .c2rust_unnamed
507            .dynamic_precedence
508    };
509}
510#[inline]
511unsafe extern "C" fn ts_subtree_production_id(mut self_0: Subtree) -> uint16_t {
512    if ts_subtree_child_count(self_0) > 0 as libc::c_int as libc::c_uint {
513        return (*self_0.ptr).c2rust_unnamed.c2rust_unnamed.production_id;
514    } else {
515        return 0 as libc::c_int as uint16_t;
516    };
517}
518#[inline]
519unsafe extern "C" fn ts_subtree_fragile_left(mut self_0: Subtree) -> bool {
520    return if (self_0.data).is_inline() as libc::c_int != 0 {
521        0 as libc::c_int
522    } else {
523        (*self_0.ptr).fragile_left() as libc::c_int
524    } != 0;
525}
526#[inline]
527unsafe extern "C" fn ts_subtree_fragile_right(mut self_0: Subtree) -> bool {
528    return if (self_0.data).is_inline() as libc::c_int != 0 {
529        0 as libc::c_int
530    } else {
531        (*self_0.ptr).fragile_right() as libc::c_int
532    } != 0;
533}
534#[inline]
535unsafe extern "C" fn ts_subtree_has_external_tokens(mut self_0: Subtree) -> bool {
536    return if (self_0.data).is_inline() as libc::c_int != 0 {
537        0 as libc::c_int
538    } else {
539        (*self_0.ptr).has_external_tokens() as libc::c_int
540    } != 0;
541}
542#[inline]
543unsafe extern "C" fn ts_subtree_has_external_scanner_state_change(mut self_0: Subtree) -> bool {
544    return if (self_0.data).is_inline() as libc::c_int != 0 {
545        0 as libc::c_int
546    } else {
547        (*self_0.ptr).has_external_scanner_state_change() as libc::c_int
548    } != 0;
549}
550#[inline]
551unsafe extern "C" fn ts_subtree_depends_on_column(mut self_0: Subtree) -> bool {
552    return if (self_0.data).is_inline() as libc::c_int != 0 {
553        0 as libc::c_int
554    } else {
555        (*self_0.ptr).depends_on_column() as libc::c_int
556    } != 0;
557}
558#[inline]
559unsafe extern "C" fn ts_subtree_is_error(mut self_0: Subtree) -> bool {
560    return ts_subtree_symbol(self_0) as libc::c_int
561        == -(1 as libc::c_int) as TSSymbol as libc::c_int;
562}
563#[inline]
564unsafe extern "C" fn ts_subtree_from_mut(mut self_0: MutableSubtree) -> Subtree {
565    let mut result: Subtree = Subtree {
566        data: SubtreeInlineData {
567            is_inline_visible_named_extra_has_changes_is_missing_is_keyword: [0; 1],
568            symbol: 0,
569            parse_state: 0,
570            padding_columns: 0,
571            padding_rows_lookahead_bytes: [0; 1],
572            padding_bytes: 0,
573            size_bytes: 0,
574        },
575    };
576    result.data = self_0.data;
577    return result;
578}
579#[inline]
580unsafe extern "C" fn ts_subtree_to_mut_unsafe(mut self_0: Subtree) -> MutableSubtree {
581    let mut result: MutableSubtree = MutableSubtree {
582        data: SubtreeInlineData {
583            is_inline_visible_named_extra_has_changes_is_missing_is_keyword: [0; 1],
584            symbol: 0,
585            parse_state: 0,
586            padding_columns: 0,
587            padding_rows_lookahead_bytes: [0; 1],
588            padding_bytes: 0,
589            size_bytes: 0,
590        },
591    };
592    result.data = self_0.data;
593    return result;
594}
595#[inline]
596unsafe extern "C" fn ts_language_alias_sequence(
597    mut self_0: *const TSLanguage,
598    mut production_id: uint32_t,
599) -> *const TSSymbol {
600    return if production_id != 0 {
601        &*((*self_0).alias_sequences).offset(
602            production_id.wrapping_mul((*self_0).max_alias_sequence_length as libc::c_uint)
603                as isize,
604        ) as *const TSSymbol
605    } else {
606        0 as *const TSSymbol
607    };
608}
609#[inline]
610unsafe extern "C" fn ts_language_field_map(
611    mut self_0: *const TSLanguage,
612    mut production_id: uint32_t,
613    mut start: *mut *const TSFieldMapEntry,
614    mut end: *mut *const TSFieldMapEntry,
615) {
616    if (*self_0).field_count == 0 as libc::c_int as libc::c_uint {
617        *start = 0 as *const TSFieldMapEntry;
618        *end = 0 as *const TSFieldMapEntry;
619        return;
620    }
621    let mut slice: TSFieldMapSlice = *((*self_0).field_map_slices).offset(production_id as isize);
622    *start = &*((*self_0).field_map_entries).offset(slice.index as isize) as *const TSFieldMapEntry;
623    *end = (&*((*self_0).field_map_entries).offset(slice.index as isize) as *const TSFieldMapEntry)
624        .offset(slice.length as libc::c_int as isize);
625}
626#[inline]
627unsafe extern "C" fn ts_language_write_symbol_as_dot_string(
628    mut self_0: *const TSLanguage,
629    mut f: *mut FILE,
630    mut symbol: TSSymbol,
631) {
632    let mut name: *const libc::c_char = ts_language_symbol_name(self_0, symbol);
633    let mut chr: *const libc::c_char = name;
634    while *chr != 0 {
635        match *chr as libc::c_int {
636            34 | 92 => {
637                fputc('\\' as i32, f);
638                fputc(*chr as libc::c_int, f);
639            }
640            10 => {
641                fputs(b"\\n\0" as *const u8 as *const libc::c_char, f);
642            }
643            9 => {
644                fputs(b"\\t\0" as *const u8 as *const libc::c_char, f);
645            }
646            _ => {
647                fputc(*chr as libc::c_int, f);
648            }
649        }
650        chr = chr.offset(1);
651    }
652}
653#[no_mangle]
654pub unsafe extern "C" fn ts_external_scanner_state_init(
655    mut self_0: *mut ExternalScannerState,
656    mut data: *const libc::c_char,
657    mut length: libc::c_uint,
658) {
659    (*self_0).length = length;
660    if length as libc::c_ulong > ::core::mem::size_of::<[libc::c_char; 24]>() as libc::c_ulong {
661        (*self_0).c2rust_unnamed.long_data =
662            crate::core_transpiled::alloc::ts_malloc(length as size_t) as *mut libc::c_char;
663        std::ptr::copy_nonoverlapping(
664            data as *const libc::c_void,
665            (*self_0).c2rust_unnamed.long_data as *mut libc::c_void,
666            length as libc::c_ulong,
667        );
668    } else {
669        std::ptr::copy_nonoverlapping(
670            data as *const libc::c_void,
671            ((*self_0).c2rust_unnamed.short_data).as_mut_ptr() as *mut libc::c_void,
672            length as libc::c_ulong,
673        );
674    };
675}
676#[no_mangle]
677pub unsafe extern "C" fn ts_external_scanner_state_copy(
678    mut self_0: *const ExternalScannerState,
679) -> ExternalScannerState {
680    let mut result: ExternalScannerState = *self_0;
681    if (*self_0).length as libc::c_ulong
682        > ::core::mem::size_of::<[libc::c_char; 24]>() as libc::c_ulong
683    {
684        result.c2rust_unnamed.long_data =
685            crate::core_transpiled::alloc::ts_malloc((*self_0).length as size_t)
686                as *mut libc::c_char;
687        std::ptr::copy_nonoverlapping(
688            (*self_0).c2rust_unnamed.long_data as *const libc::c_void,
689            result.c2rust_unnamed.long_data as *mut libc::c_void,
690            (*self_0).length as libc::c_ulong,
691        );
692    }
693    return result;
694}
695#[no_mangle]
696pub unsafe extern "C" fn ts_external_scanner_state_delete(mut self_0: *mut ExternalScannerState) {
697    if (*self_0).length as libc::c_ulong
698        > ::core::mem::size_of::<[libc::c_char; 24]>() as libc::c_ulong
699    {
700        crate::core_transpiled::alloc::ts_free(
701            (*self_0).c2rust_unnamed.long_data as *mut libc::c_void,
702        );
703    }
704}
705#[no_mangle]
706pub unsafe extern "C" fn ts_external_scanner_state_data(
707    mut self_0: *const ExternalScannerState,
708) -> *const libc::c_char {
709    if (*self_0).length as libc::c_ulong
710        > ::core::mem::size_of::<[libc::c_char; 24]>() as libc::c_ulong
711    {
712        return (*self_0).c2rust_unnamed.long_data;
713    } else {
714        return ((*self_0).c2rust_unnamed.short_data).as_ptr();
715    };
716}
717#[no_mangle]
718pub unsafe extern "C" fn ts_external_scanner_state_eq(
719    mut self_0: *const ExternalScannerState,
720    mut buffer: *const libc::c_char,
721    mut length: libc::c_uint,
722) -> bool {
723    return (*self_0).length == length
724        && if std::slice::from_raw_parts(
725            ts_external_scanner_state_data(self_0) as *const u8,
726            length as libc::c_ulong,
727        ) == std::slice::from_raw_parts(buffer as *const u8, length as libc::c_ulong)
728        {
729            0
730        } else {
731            1
732        } == 0 as libc::c_int;
733}
734#[no_mangle]
735pub unsafe extern "C" fn ts_subtree_array_copy(
736    mut self_0: SubtreeArray,
737    mut dest: *mut SubtreeArray,
738) {
739    (*dest).size = self_0.size;
740    (*dest).capacity = self_0.capacity;
741    (*dest).contents = self_0.contents;
742    if self_0.capacity > 0 as libc::c_int as libc::c_uint {
743        (*dest).contents = crate::core_transpiled::alloc::ts_calloc(
744            self_0.capacity as size_t,
745            ::core::mem::size_of::<Subtree>() as libc::c_ulong,
746        ) as *mut Subtree;
747        std::ptr::copy_nonoverlapping(
748            self_0.contents as *const libc::c_void,
749            (*dest).contents as *mut libc::c_void,
750            (self_0.size as libc::c_ulong)
751                .wrapping_mul(::core::mem::size_of::<Subtree>() as libc::c_ulong),
752        );
753        let mut i: uint32_t = 0 as libc::c_int as uint32_t;
754        while i < self_0.size {
755            ts_subtree_retain(*((*dest).contents).offset(i as isize));
756            i = i.wrapping_add(1);
757        }
758    }
759}
760#[no_mangle]
761pub unsafe extern "C" fn ts_subtree_array_clear(
762    mut pool: *mut SubtreePool,
763    mut self_0: *mut SubtreeArray,
764) {
765    let mut i: uint32_t = 0 as libc::c_int as uint32_t;
766    while i < (*self_0).size {
767        ts_subtree_release(pool, *((*self_0).contents).offset(i as isize));
768        i = i.wrapping_add(1);
769    }
770    (*self_0).size = 0 as libc::c_int as uint32_t;
771}
772#[no_mangle]
773pub unsafe extern "C" fn ts_subtree_array_delete(
774    mut pool: *mut SubtreePool,
775    mut self_0: *mut SubtreeArray,
776) {
777    ts_subtree_array_clear(pool, self_0);
778    _array__delete(self_0 as *mut Array);
779}
780#[no_mangle]
781pub unsafe extern "C" fn ts_subtree_array_remove_trailing_extras(
782    mut self_0: *mut SubtreeArray,
783    mut destination: *mut SubtreeArray,
784) {
785    (*destination).size = 0 as libc::c_int as uint32_t;
786    while (*self_0).size > 0 as libc::c_int as libc::c_uint {
787        let mut last: Subtree = *((*self_0).contents)
788            .offset(((*self_0).size).wrapping_sub(1 as libc::c_int as libc::c_uint) as isize);
789        if !ts_subtree_extra(last) {
790            break;
791        }
792        (*self_0).size = ((*self_0).size).wrapping_sub(1);
793        _array__grow(
794            destination as *mut Array,
795            1 as libc::c_int as uint32_t,
796            ::core::mem::size_of::<Subtree>() as libc::c_ulong,
797        );
798        let fresh4 = (*destination).size;
799        (*destination).size = ((*destination).size).wrapping_add(1);
800        *((*destination).contents).offset(fresh4 as isize) = last;
801    }
802    ts_subtree_array_reverse(destination);
803}
804#[no_mangle]
805pub unsafe extern "C" fn ts_subtree_array_reverse(mut self_0: *mut SubtreeArray) {
806    let mut i: uint32_t = 0 as libc::c_int as uint32_t;
807    let mut limit: uint32_t = ((*self_0).size).wrapping_div(2 as libc::c_int as libc::c_uint);
808    while i < limit {
809        let mut reverse_index: size_t = ((*self_0).size)
810            .wrapping_sub(1 as libc::c_int as libc::c_uint)
811            .wrapping_sub(i) as size_t;
812        let mut swap: Subtree = *((*self_0).contents).offset(i as isize);
813        *((*self_0).contents).offset(i as isize) =
814            *((*self_0).contents).offset(reverse_index as isize);
815        *((*self_0).contents).offset(reverse_index as isize) = swap;
816        i = i.wrapping_add(1);
817    }
818}
819#[no_mangle]
820pub unsafe extern "C" fn ts_subtree_pool_new(mut capacity: uint32_t) -> SubtreePool {
821    let mut self_0: SubtreePool = {
822        let mut init = SubtreePool {
823            free_trees: {
824                let mut init = MutableSubtreeArray {
825                    contents: 0 as *mut MutableSubtree,
826                    size: 0 as libc::c_int as uint32_t,
827                    capacity: 0 as libc::c_int as uint32_t,
828                };
829                init
830            },
831            tree_stack: {
832                let mut init = MutableSubtreeArray {
833                    contents: 0 as *mut MutableSubtree,
834                    size: 0 as libc::c_int as uint32_t,
835                    capacity: 0 as libc::c_int as uint32_t,
836                };
837                init
838            },
839        };
840        init
841    };
842    _array__reserve(
843        &mut self_0.free_trees as *mut MutableSubtreeArray as *mut Array,
844        ::core::mem::size_of::<MutableSubtree>() as libc::c_ulong,
845        capacity,
846    );
847    return self_0;
848}
849#[no_mangle]
850pub unsafe extern "C" fn ts_subtree_pool_delete(mut self_0: *mut SubtreePool) {
851    if !((*self_0).free_trees.contents).is_null() {
852        let mut i: libc::c_uint = 0 as libc::c_int as libc::c_uint;
853        while i < (*self_0).free_trees.size {
854            crate::core_transpiled::alloc::ts_free(
855                (*((*self_0).free_trees.contents).offset(i as isize)).ptr as *mut libc::c_void,
856            );
857            i = i.wrapping_add(1);
858        }
859        _array__delete(&mut (*self_0).free_trees as *mut MutableSubtreeArray as *mut Array);
860    }
861    if !((*self_0).tree_stack.contents).is_null() {
862        _array__delete(&mut (*self_0).tree_stack as *mut MutableSubtreeArray as *mut Array);
863    }
864}
865unsafe extern "C" fn ts_subtree_pool_allocate(
866    mut self_0: *mut SubtreePool,
867) -> *mut SubtreeHeapData {
868    if (*self_0).free_trees.size > 0 as libc::c_int as libc::c_uint {
869        (*self_0).free_trees.size = ((*self_0).free_trees.size).wrapping_sub(1);
870        return (*((*self_0).free_trees.contents).offset((*self_0).free_trees.size as isize)).ptr;
871    } else {
872        return crate::core_transpiled::alloc::ts_malloc(
873            ::core::mem::size_of::<SubtreeHeapData>() as libc::c_ulong
874        ) as *mut SubtreeHeapData;
875    };
876}
877unsafe extern "C" fn ts_subtree_pool_free(
878    mut self_0: *mut SubtreePool,
879    mut tree: *mut SubtreeHeapData,
880) {
881    if (*self_0).free_trees.capacity > 0 as libc::c_int as libc::c_uint
882        && ((*self_0).free_trees.size).wrapping_add(1 as libc::c_int as libc::c_uint)
883            <= 32 as libc::c_int as libc::c_uint
884    {
885        _array__grow(
886            &mut (*self_0).free_trees as *mut MutableSubtreeArray as *mut Array,
887            1 as libc::c_int as uint32_t,
888            ::core::mem::size_of::<MutableSubtree>() as libc::c_ulong,
889        );
890        let fresh5 = (*self_0).free_trees.size;
891        (*self_0).free_trees.size = ((*self_0).free_trees.size).wrapping_add(1);
892        *((*self_0).free_trees.contents).offset(fresh5 as isize) = MutableSubtree { ptr: tree };
893    } else {
894        crate::core_transpiled::alloc::ts_free(tree as *mut libc::c_void);
895    };
896}
897#[inline]
898unsafe extern "C" fn ts_subtree_can_inline(
899    mut padding: Length,
900    mut size: Length,
901    mut lookahead_bytes: uint32_t,
902) -> bool {
903    return padding.bytes < 255 as libc::c_int as libc::c_uint
904        && padding.extent.row < 16 as libc::c_int as libc::c_uint
905        && padding.extent.column < 255 as libc::c_int as libc::c_uint
906        && size.extent.row == 0 as libc::c_int as libc::c_uint
907        && size.extent.column < 255 as libc::c_int as libc::c_uint
908        && lookahead_bytes < 16 as libc::c_int as libc::c_uint;
909}
910#[no_mangle]
911pub unsafe extern "C" fn ts_subtree_new_leaf(
912    mut pool: *mut SubtreePool,
913    mut symbol: TSSymbol,
914    mut padding: Length,
915    mut size: Length,
916    mut lookahead_bytes: uint32_t,
917    mut parse_state: TSStateId,
918    mut has_external_tokens: bool,
919    mut depends_on_column: bool,
920    mut is_keyword: bool,
921    mut language: *const TSLanguage,
922) -> Subtree {
923    let mut metadata: TSSymbolMetadata = ts_language_symbol_metadata(language, symbol);
924    let mut extra: bool = symbol as libc::c_int == 0 as libc::c_int;
925    let mut is_inline: bool = symbol as libc::c_int <= 255 as libc::c_int
926        && !has_external_tokens
927        && ts_subtree_can_inline(padding, size, lookahead_bytes) as libc::c_int != 0;
928    if is_inline {
929        return Subtree {
930            data: {
931                let mut init = SubtreeInlineData {
932                    is_inline_visible_named_extra_has_changes_is_missing_is_keyword: [0; 1],
933                    padding_rows_lookahead_bytes: [0; 1],
934                    symbol: symbol as uint8_t,
935                    parse_state: parse_state,
936                    padding_columns: padding.extent.column as uint8_t,
937                    padding_bytes: padding.bytes as uint8_t,
938                    size_bytes: size.bytes as uint8_t,
939                };
940                init.set_is_inline(1 as libc::c_int != 0);
941                init.set_visible(metadata.visible);
942                init.set_named(metadata.named);
943                init.set_extra(extra);
944                init.set_has_changes(0 as libc::c_int != 0);
945                init.set_is_missing(0 as libc::c_int != 0);
946                init.set_is_keyword(is_keyword);
947                init.set_padding_rows(padding.extent.row as uint8_t);
948                init.set_lookahead_bytes(lookahead_bytes as uint8_t);
949                init
950            },
951        };
952    } else {
953        let mut data: *mut SubtreeHeapData = ts_subtree_pool_allocate(pool);
954        *data = {
955            let mut init = SubtreeHeapData { visible_named_extra_fragile_left_fragile_right_has_changes_has_external_tokens_has_external_scanner_state_change_depends_on_column_is_missing_is_keyword : [0 ; 2] , c2rust_padding : [0 ; 2] , ref_count : 1 as libc :: c_int as uint32_t , padding : padding , size : size , lookahead_bytes : lookahead_bytes , error_cost : 0 as libc :: c_int as uint32_t , child_count : 0 as libc :: c_int as uint32_t , symbol : symbol , parse_state : parse_state , c2rust_unnamed : C2RustUnnamed_5 { c2rust_unnamed : { let mut init = C2RustUnnamed_6 { visible_child_count : 0 , named_child_count : 0 , visible_descendant_count : 0 , dynamic_precedence : 0 , repeat_depth : 0 , production_id : 0 , first_leaf : { let mut init = C2RustUnnamed_7 { symbol : 0 as libc :: c_int as TSSymbol , parse_state : 0 as libc :: c_int as TSStateId , } ; init } , } ; init } , } , } ;
956            init.set_visible(metadata.visible);
957            init.set_named(metadata.named);
958            init.set_extra(extra);
959            init.set_fragile_left(0 as libc::c_int != 0);
960            init.set_fragile_right(0 as libc::c_int != 0);
961            init.set_has_changes(0 as libc::c_int != 0);
962            init.set_has_external_tokens(has_external_tokens);
963            init.set_has_external_scanner_state_change(0 as libc::c_int != 0);
964            init.set_depends_on_column(depends_on_column);
965            init.set_is_missing(0 as libc::c_int != 0);
966            init.set_is_keyword(is_keyword);
967            init
968        };
969        return Subtree { ptr: data };
970    };
971}
972#[no_mangle]
973pub unsafe extern "C" fn ts_subtree_set_symbol(
974    mut self_0: *mut MutableSubtree,
975    mut symbol: TSSymbol,
976    mut language: *const TSLanguage,
977) {
978    let mut metadata: TSSymbolMetadata = ts_language_symbol_metadata(language, symbol);
979    if ((*self_0).data).is_inline() {
980        if (symbol as libc::c_int) < 255 as libc::c_int {
981        } else {
982            panic!();
983        }
984        (*self_0).data.symbol = symbol as uint8_t;
985        ((*self_0).data).set_named(metadata.named);
986        ((*self_0).data).set_visible(metadata.visible);
987    } else {
988        (*(*self_0).ptr).symbol = symbol;
989        (*(*self_0).ptr).set_named(metadata.named);
990        (*(*self_0).ptr).set_visible(metadata.visible);
991    };
992}
993#[no_mangle]
994pub unsafe extern "C" fn ts_subtree_new_error(
995    mut pool: *mut SubtreePool,
996    mut lookahead_char: int32_t,
997    mut padding: Length,
998    mut size: Length,
999    mut bytes_scanned: uint32_t,
1000    mut parse_state: TSStateId,
1001    mut language: *const TSLanguage,
1002) -> Subtree {
1003    let mut result: Subtree = ts_subtree_new_leaf(
1004        pool,
1005        -(1 as libc::c_int) as TSSymbol,
1006        padding,
1007        size,
1008        bytes_scanned,
1009        parse_state,
1010        0 as libc::c_int != 0,
1011        0 as libc::c_int != 0,
1012        0 as libc::c_int != 0,
1013        language,
1014    );
1015    let mut data: *mut SubtreeHeapData = result.ptr as *mut SubtreeHeapData;
1016    (*data).set_fragile_left(1 as libc::c_int != 0);
1017    (*data).set_fragile_right(1 as libc::c_int != 0);
1018    (*data).c2rust_unnamed.lookahead_char = lookahead_char;
1019    return result;
1020}
1021#[no_mangle]
1022pub unsafe extern "C" fn ts_subtree_clone(mut self_0: Subtree) -> MutableSubtree {
1023    let mut alloc_size: size_t = ts_subtree_alloc_size((*self_0.ptr).child_count);
1024    let mut new_children: *mut Subtree =
1025        crate::core_transpiled::alloc::ts_malloc(alloc_size) as *mut Subtree;
1026    let mut old_children: *mut Subtree = if (self_0.data).is_inline() as libc::c_int != 0 {
1027        0 as *mut Subtree
1028    } else {
1029        (self_0.ptr as *mut Subtree).offset(-((*self_0.ptr).child_count as isize))
1030    };
1031    std::ptr::copy_nonoverlapping(
1032        old_children as *const libc::c_void,
1033        new_children as *mut libc::c_void,
1034        alloc_size,
1035    );
1036    let mut result: *mut SubtreeHeapData = &mut *new_children
1037        .offset((*self_0.ptr).child_count as isize)
1038        as *mut Subtree as *mut SubtreeHeapData;
1039    if (*self_0.ptr).child_count > 0 as libc::c_int as libc::c_uint {
1040        let mut i: uint32_t = 0 as libc::c_int as uint32_t;
1041        while i < (*self_0.ptr).child_count {
1042            ts_subtree_retain(*new_children.offset(i as isize));
1043            i = i.wrapping_add(1);
1044        }
1045    } else if (*self_0.ptr).has_external_tokens() {
1046        (*result).c2rust_unnamed.external_scanner_state =
1047            ts_external_scanner_state_copy(&(*self_0.ptr).c2rust_unnamed.external_scanner_state);
1048    }
1049    ::core::ptr::write_volatile(
1050        &mut (*result).ref_count as *mut uint32_t,
1051        1 as libc::c_int as uint32_t,
1052    );
1053    return MutableSubtree { ptr: result };
1054}
1055#[no_mangle]
1056pub unsafe extern "C" fn ts_subtree_make_mut(
1057    mut pool: *mut SubtreePool,
1058    mut self_0: Subtree,
1059) -> MutableSubtree {
1060    if (self_0.data).is_inline() {
1061        return MutableSubtree { data: self_0.data };
1062    }
1063    if (*self_0.ptr).ref_count == 1 as libc::c_int as libc::c_uint {
1064        return ts_subtree_to_mut_unsafe(self_0);
1065    }
1066    let mut result: MutableSubtree = ts_subtree_clone(self_0);
1067    ts_subtree_release(pool, self_0);
1068    return result;
1069}
1070unsafe extern "C" fn ts_subtree__compress(
1071    mut self_0: MutableSubtree,
1072    mut count: libc::c_uint,
1073    mut language: *const TSLanguage,
1074    mut stack: *mut MutableSubtreeArray,
1075) {
1076    let mut initial_stack_size: libc::c_uint = (*stack).size;
1077    let mut tree: MutableSubtree = self_0;
1078    let mut symbol: TSSymbol = (*tree.ptr).symbol;
1079    let mut i: libc::c_uint = 0 as libc::c_int as libc::c_uint;
1080    while i < count {
1081        if (*tree.ptr).ref_count > 1 as libc::c_int as libc::c_uint
1082            || (*tree.ptr).child_count < 2 as libc::c_int as libc::c_uint
1083        {
1084            break;
1085        }
1086        let mut child: MutableSubtree = ts_subtree_to_mut_unsafe(
1087            *if (tree.data).is_inline() as libc::c_int != 0 {
1088                0 as *mut Subtree
1089            } else {
1090                (tree.ptr as *mut Subtree).offset(-((*tree.ptr).child_count as isize))
1091            }
1092            .offset(0 as libc::c_int as isize),
1093        );
1094        if (child.data).is_inline() as libc::c_int != 0
1095            || (*child.ptr).child_count < 2 as libc::c_int as libc::c_uint
1096            || (*child.ptr).ref_count > 1 as libc::c_int as libc::c_uint
1097            || (*child.ptr).symbol as libc::c_int != symbol as libc::c_int
1098        {
1099            break;
1100        }
1101        let mut grandchild: MutableSubtree = ts_subtree_to_mut_unsafe(
1102            *if (child.data).is_inline() as libc::c_int != 0 {
1103                0 as *mut Subtree
1104            } else {
1105                (child.ptr as *mut Subtree).offset(-((*child.ptr).child_count as isize))
1106            }
1107            .offset(0 as libc::c_int as isize),
1108        );
1109        if (grandchild.data).is_inline() as libc::c_int != 0
1110            || (*grandchild.ptr).child_count < 2 as libc::c_int as libc::c_uint
1111            || (*grandchild.ptr).ref_count > 1 as libc::c_int as libc::c_uint
1112            || (*grandchild.ptr).symbol as libc::c_int != symbol as libc::c_int
1113        {
1114            break;
1115        }
1116        *if (tree.data).is_inline() as libc::c_int != 0 {
1117            0 as *mut Subtree
1118        } else {
1119            (tree.ptr as *mut Subtree).offset(-((*tree.ptr).child_count as isize))
1120        }
1121        .offset(0 as libc::c_int as isize) = ts_subtree_from_mut(grandchild);
1122        *if (child.data).is_inline() as libc::c_int != 0 {
1123            0 as *mut Subtree
1124        } else {
1125            (child.ptr as *mut Subtree).offset(-((*child.ptr).child_count as isize))
1126        }
1127        .offset(0 as libc::c_int as isize) =
1128            *if (grandchild.data).is_inline() as libc::c_int != 0 {
1129                0 as *mut Subtree
1130            } else {
1131                (grandchild.ptr as *mut Subtree).offset(-((*grandchild.ptr).child_count as isize))
1132            }
1133            .offset(
1134                ((*grandchild.ptr).child_count).wrapping_sub(1 as libc::c_int as libc::c_uint)
1135                    as isize,
1136            );
1137        *if (grandchild.data).is_inline() as libc::c_int != 0 {
1138            0 as *mut Subtree
1139        } else {
1140            (grandchild.ptr as *mut Subtree).offset(-((*grandchild.ptr).child_count as isize))
1141        }
1142        .offset(
1143            ((*grandchild.ptr).child_count).wrapping_sub(1 as libc::c_int as libc::c_uint) as isize,
1144        ) = ts_subtree_from_mut(child);
1145        _array__grow(
1146            stack as *mut Array,
1147            1 as libc::c_int as uint32_t,
1148            ::core::mem::size_of::<MutableSubtree>() as libc::c_ulong,
1149        );
1150        let fresh6 = (*stack).size;
1151        (*stack).size = ((*stack).size).wrapping_add(1);
1152        *((*stack).contents).offset(fresh6 as isize) = tree;
1153        tree = grandchild;
1154        i = i.wrapping_add(1);
1155    }
1156    while (*stack).size > initial_stack_size {
1157        (*stack).size = ((*stack).size).wrapping_sub(1);
1158        tree = *((*stack).contents).offset((*stack).size as isize);
1159        let mut child_0: MutableSubtree = ts_subtree_to_mut_unsafe(
1160            *if (tree.data).is_inline() as libc::c_int != 0 {
1161                0 as *mut Subtree
1162            } else {
1163                (tree.ptr as *mut Subtree).offset(-((*tree.ptr).child_count as isize))
1164            }
1165            .offset(0 as libc::c_int as isize),
1166        );
1167        let mut grandchild_0: MutableSubtree = ts_subtree_to_mut_unsafe(
1168            *if (child_0.data).is_inline() as libc::c_int != 0 {
1169                0 as *mut Subtree
1170            } else {
1171                (child_0.ptr as *mut Subtree).offset(-((*child_0.ptr).child_count as isize))
1172            }
1173            .offset(
1174                ((*child_0.ptr).child_count).wrapping_sub(1 as libc::c_int as libc::c_uint)
1175                    as isize,
1176            ),
1177        );
1178        ts_subtree_summarize_children(grandchild_0, language);
1179        ts_subtree_summarize_children(child_0, language);
1180        ts_subtree_summarize_children(tree, language);
1181    }
1182}
1183#[no_mangle]
1184pub unsafe extern "C" fn ts_subtree_balance(
1185    mut self_0: Subtree,
1186    mut pool: *mut SubtreePool,
1187    mut language: *const TSLanguage,
1188) {
1189    (*pool).tree_stack.size = 0 as libc::c_int as uint32_t;
1190    if ts_subtree_child_count(self_0) > 0 as libc::c_int as libc::c_uint
1191        && (*self_0.ptr).ref_count == 1 as libc::c_int as libc::c_uint
1192    {
1193        _array__grow(
1194            &mut (*pool).tree_stack as *mut MutableSubtreeArray as *mut Array,
1195            1 as libc::c_int as uint32_t,
1196            ::core::mem::size_of::<MutableSubtree>() as libc::c_ulong,
1197        );
1198        let fresh7 = (*pool).tree_stack.size;
1199        (*pool).tree_stack.size = ((*pool).tree_stack.size).wrapping_add(1);
1200        *((*pool).tree_stack.contents).offset(fresh7 as isize) = ts_subtree_to_mut_unsafe(self_0);
1201    }
1202    while (*pool).tree_stack.size > 0 as libc::c_int as libc::c_uint {
1203        (*pool).tree_stack.size = ((*pool).tree_stack.size).wrapping_sub(1);
1204        let mut tree: MutableSubtree =
1205            *((*pool).tree_stack.contents).offset((*pool).tree_stack.size as isize);
1206        if (*tree.ptr).c2rust_unnamed.c2rust_unnamed.repeat_depth as libc::c_int > 0 as libc::c_int
1207        {
1208            let mut child1: Subtree = *if (tree.data).is_inline() as libc::c_int != 0 {
1209                0 as *mut Subtree
1210            } else {
1211                (tree.ptr as *mut Subtree).offset(-((*tree.ptr).child_count as isize))
1212            }
1213            .offset(0 as libc::c_int as isize);
1214            let mut child2: Subtree = *if (tree.data).is_inline() as libc::c_int != 0 {
1215                0 as *mut Subtree
1216            } else {
1217                (tree.ptr as *mut Subtree).offset(-((*tree.ptr).child_count as isize))
1218            }
1219            .offset(
1220                ((*tree.ptr).child_count).wrapping_sub(1 as libc::c_int as libc::c_uint) as isize,
1221            );
1222            let mut repeat_delta: libc::c_long = ts_subtree_repeat_depth(child1) as libc::c_long
1223                - ts_subtree_repeat_depth(child2) as libc::c_long;
1224            if repeat_delta > 0 as libc::c_int as libc::c_long {
1225                let mut n: libc::c_uint = repeat_delta as libc::c_uint;
1226                let mut i: libc::c_uint = n.wrapping_div(2 as libc::c_int as libc::c_uint);
1227                while i > 0 as libc::c_int as libc::c_uint {
1228                    ts_subtree__compress(tree, i, language, &mut (*pool).tree_stack);
1229                    n = n.wrapping_sub(i);
1230                    i = i.wrapping_div(2 as libc::c_int as libc::c_uint);
1231                }
1232            }
1233        }
1234        let mut i_0: uint32_t = 0 as libc::c_int as uint32_t;
1235        while i_0 < (*tree.ptr).child_count {
1236            let mut child: Subtree = *if (tree.data).is_inline() as libc::c_int != 0 {
1237                0 as *mut Subtree
1238            } else {
1239                (tree.ptr as *mut Subtree).offset(-((*tree.ptr).child_count as isize))
1240            }
1241            .offset(i_0 as isize);
1242            if ts_subtree_child_count(child) > 0 as libc::c_int as libc::c_uint
1243                && (*child.ptr).ref_count == 1 as libc::c_int as libc::c_uint
1244            {
1245                _array__grow(
1246                    &mut (*pool).tree_stack as *mut MutableSubtreeArray as *mut Array,
1247                    1 as libc::c_int as uint32_t,
1248                    ::core::mem::size_of::<MutableSubtree>() as libc::c_ulong,
1249                );
1250                let fresh8 = (*pool).tree_stack.size;
1251                (*pool).tree_stack.size = ((*pool).tree_stack.size).wrapping_add(1);
1252                *((*pool).tree_stack.contents).offset(fresh8 as isize) =
1253                    ts_subtree_to_mut_unsafe(child);
1254            }
1255            i_0 = i_0.wrapping_add(1);
1256        }
1257    }
1258}
1259#[no_mangle]
1260pub unsafe extern "C" fn ts_subtree_summarize_children(
1261    mut self_0: MutableSubtree,
1262    mut language: *const TSLanguage,
1263) {
1264    if !(self_0.data).is_inline() {
1265    } else {
1266        panic!();
1267    }
1268    (*self_0.ptr)
1269        .c2rust_unnamed
1270        .c2rust_unnamed
1271        .named_child_count = 0 as libc::c_int as uint32_t;
1272    (*self_0.ptr)
1273        .c2rust_unnamed
1274        .c2rust_unnamed
1275        .visible_child_count = 0 as libc::c_int as uint32_t;
1276    (*self_0.ptr).error_cost = 0 as libc::c_int as uint32_t;
1277    (*self_0.ptr).c2rust_unnamed.c2rust_unnamed.repeat_depth = 0 as libc::c_int as uint16_t;
1278    (*self_0.ptr)
1279        .c2rust_unnamed
1280        .c2rust_unnamed
1281        .visible_descendant_count = 0 as libc::c_int as uint32_t;
1282    (*self_0.ptr).set_has_external_tokens(0 as libc::c_int != 0);
1283    (*self_0.ptr).set_depends_on_column(0 as libc::c_int != 0);
1284    (*self_0.ptr).set_has_external_scanner_state_change(0 as libc::c_int != 0);
1285    (*self_0.ptr)
1286        .c2rust_unnamed
1287        .c2rust_unnamed
1288        .dynamic_precedence = 0 as libc::c_int;
1289    let mut structural_index: uint32_t = 0 as libc::c_int as uint32_t;
1290    let mut alias_sequence: *const TSSymbol = ts_language_alias_sequence(
1291        language,
1292        (*self_0.ptr).c2rust_unnamed.c2rust_unnamed.production_id as uint32_t,
1293    );
1294    let mut lookahead_end_byte: uint32_t = 0 as libc::c_int as uint32_t;
1295    let mut children: *const Subtree = if (self_0.data).is_inline() as libc::c_int != 0 {
1296        0 as *mut Subtree
1297    } else {
1298        (self_0.ptr as *mut Subtree).offset(-((*self_0.ptr).child_count as isize))
1299    };
1300    let mut i: uint32_t = 0 as libc::c_int as uint32_t;
1301    while i < (*self_0.ptr).child_count {
1302        let mut child: Subtree = *children.offset(i as isize);
1303        if (*self_0.ptr).size.extent.row == 0 as libc::c_int as libc::c_uint
1304            && ts_subtree_depends_on_column(child) as libc::c_int != 0
1305        {
1306            (*self_0.ptr).set_depends_on_column(1 as libc::c_int != 0);
1307        }
1308        if ts_subtree_has_external_scanner_state_change(child) {
1309            (*self_0.ptr).set_has_external_scanner_state_change(1 as libc::c_int != 0);
1310        }
1311        if i == 0 as libc::c_int as libc::c_uint {
1312            (*self_0.ptr).padding = ts_subtree_padding(child);
1313            (*self_0.ptr).size = ts_subtree_size(child);
1314        } else {
1315            (*self_0.ptr).size = length_add((*self_0.ptr).size, ts_subtree_total_size(child));
1316        }
1317        let mut child_lookahead_end_byte: uint32_t = ((*self_0.ptr).padding.bytes)
1318            .wrapping_add((*self_0.ptr).size.bytes)
1319            .wrapping_add(ts_subtree_lookahead_bytes(child));
1320        if child_lookahead_end_byte > lookahead_end_byte {
1321            lookahead_end_byte = child_lookahead_end_byte;
1322        }
1323        if ts_subtree_symbol(child) as libc::c_int
1324            != -(1 as libc::c_int) as TSSymbol as libc::c_int - 1 as libc::c_int
1325        {
1326            (*self_0.ptr).error_cost = ((*self_0.ptr).error_cost as libc::c_uint)
1327                .wrapping_add(ts_subtree_error_cost(child))
1328                as uint32_t as uint32_t;
1329        }
1330        let mut grandchild_count: uint32_t = ts_subtree_child_count(child);
1331        if (*self_0.ptr).symbol as libc::c_int == -(1 as libc::c_int) as TSSymbol as libc::c_int
1332            || (*self_0.ptr).symbol as libc::c_int
1333                == -(1 as libc::c_int) as TSSymbol as libc::c_int - 1 as libc::c_int
1334        {
1335            if !ts_subtree_extra(child)
1336                && !(ts_subtree_is_error(child) as libc::c_int != 0
1337                    && grandchild_count == 0 as libc::c_int as libc::c_uint)
1338            {
1339                if ts_subtree_visible(child) {
1340                    (*self_0.ptr).error_cost = ((*self_0.ptr).error_cost as libc::c_uint)
1341                        .wrapping_add(100 as libc::c_int as libc::c_uint)
1342                        as uint32_t as uint32_t;
1343                } else if grandchild_count > 0 as libc::c_int as libc::c_uint {
1344                    (*self_0.ptr).error_cost = ((*self_0.ptr).error_cost as libc::c_uint)
1345                        .wrapping_add(
1346                            (100 as libc::c_int as libc::c_uint).wrapping_mul(
1347                                (*child.ptr)
1348                                    .c2rust_unnamed
1349                                    .c2rust_unnamed
1350                                    .visible_child_count,
1351                            ),
1352                        ) as uint32_t as uint32_t;
1353                }
1354            }
1355        }
1356        (*self_0.ptr)
1357            .c2rust_unnamed
1358            .c2rust_unnamed
1359            .dynamic_precedence += ts_subtree_dynamic_precedence(child);
1360        (*self_0.ptr)
1361            .c2rust_unnamed
1362            .c2rust_unnamed
1363            .visible_descendant_count = ((*self_0.ptr)
1364            .c2rust_unnamed
1365            .c2rust_unnamed
1366            .visible_descendant_count as libc::c_uint)
1367            .wrapping_add(ts_subtree_visible_descendant_count(child))
1368            as uint32_t as uint32_t;
1369        if !alias_sequence.is_null()
1370            && *alias_sequence.offset(structural_index as isize) as libc::c_int != 0 as libc::c_int
1371            && !ts_subtree_extra(child)
1372        {
1373            (*self_0.ptr)
1374                .c2rust_unnamed
1375                .c2rust_unnamed
1376                .visible_descendant_count = ((*self_0.ptr)
1377                .c2rust_unnamed
1378                .c2rust_unnamed
1379                .visible_descendant_count)
1380                .wrapping_add(1);
1381            (*self_0.ptr)
1382                .c2rust_unnamed
1383                .c2rust_unnamed
1384                .visible_child_count = ((*self_0.ptr)
1385                .c2rust_unnamed
1386                .c2rust_unnamed
1387                .visible_child_count)
1388                .wrapping_add(1);
1389            if (ts_language_symbol_metadata(
1390                language,
1391                *alias_sequence.offset(structural_index as isize),
1392            ))
1393            .named
1394            {
1395                (*self_0.ptr)
1396                    .c2rust_unnamed
1397                    .c2rust_unnamed
1398                    .named_child_count = ((*self_0.ptr)
1399                    .c2rust_unnamed
1400                    .c2rust_unnamed
1401                    .named_child_count)
1402                    .wrapping_add(1);
1403            }
1404        } else if ts_subtree_visible(child) {
1405            (*self_0.ptr)
1406                .c2rust_unnamed
1407                .c2rust_unnamed
1408                .visible_descendant_count = ((*self_0.ptr)
1409                .c2rust_unnamed
1410                .c2rust_unnamed
1411                .visible_descendant_count)
1412                .wrapping_add(1);
1413            (*self_0.ptr)
1414                .c2rust_unnamed
1415                .c2rust_unnamed
1416                .visible_child_count = ((*self_0.ptr)
1417                .c2rust_unnamed
1418                .c2rust_unnamed
1419                .visible_child_count)
1420                .wrapping_add(1);
1421            if ts_subtree_named(child) {
1422                (*self_0.ptr)
1423                    .c2rust_unnamed
1424                    .c2rust_unnamed
1425                    .named_child_count = ((*self_0.ptr)
1426                    .c2rust_unnamed
1427                    .c2rust_unnamed
1428                    .named_child_count)
1429                    .wrapping_add(1);
1430            }
1431        } else if grandchild_count > 0 as libc::c_int as libc::c_uint {
1432            (*self_0.ptr)
1433                .c2rust_unnamed
1434                .c2rust_unnamed
1435                .visible_child_count = ((*self_0.ptr)
1436                .c2rust_unnamed
1437                .c2rust_unnamed
1438                .visible_child_count as libc::c_uint)
1439                .wrapping_add(
1440                    (*child.ptr)
1441                        .c2rust_unnamed
1442                        .c2rust_unnamed
1443                        .visible_child_count,
1444                ) as uint32_t as uint32_t;
1445            (*self_0.ptr)
1446                .c2rust_unnamed
1447                .c2rust_unnamed
1448                .named_child_count = ((*self_0.ptr)
1449                .c2rust_unnamed
1450                .c2rust_unnamed
1451                .named_child_count as libc::c_uint)
1452                .wrapping_add((*child.ptr).c2rust_unnamed.c2rust_unnamed.named_child_count)
1453                as uint32_t as uint32_t;
1454        }
1455        if ts_subtree_has_external_tokens(child) {
1456            (*self_0.ptr).set_has_external_tokens(1 as libc::c_int != 0);
1457        }
1458        if ts_subtree_is_error(child) {
1459            (*self_0.ptr).set_fragile_right(1 as libc::c_int != 0);
1460            (*self_0.ptr).set_fragile_left((*self_0.ptr).fragile_right());
1461            (*self_0.ptr).parse_state =
1462                (32767 as libc::c_int * 2 as libc::c_int + 1 as libc::c_int) as TSStateId;
1463        }
1464        if !ts_subtree_extra(child) {
1465            structural_index = structural_index.wrapping_add(1);
1466        }
1467        i = i.wrapping_add(1);
1468    }
1469    (*self_0.ptr).lookahead_bytes = lookahead_end_byte
1470        .wrapping_sub((*self_0.ptr).size.bytes)
1471        .wrapping_sub((*self_0.ptr).padding.bytes);
1472    if (*self_0.ptr).symbol as libc::c_int == -(1 as libc::c_int) as TSSymbol as libc::c_int
1473        || (*self_0.ptr).symbol as libc::c_int
1474            == -(1 as libc::c_int) as TSSymbol as libc::c_int - 1 as libc::c_int
1475    {
1476        (*self_0.ptr).error_cost = ((*self_0.ptr).error_cost as libc::c_uint).wrapping_add(
1477            (500 as libc::c_int as libc::c_uint)
1478                .wrapping_add(
1479                    (1 as libc::c_int as libc::c_uint).wrapping_mul((*self_0.ptr).size.bytes),
1480                )
1481                .wrapping_add(
1482                    (30 as libc::c_int as libc::c_uint).wrapping_mul((*self_0.ptr).size.extent.row),
1483                ),
1484        ) as uint32_t as uint32_t;
1485    }
1486    if (*self_0.ptr).child_count > 0 as libc::c_int as libc::c_uint {
1487        let mut first_child: Subtree = *children.offset(0 as libc::c_int as isize);
1488        let mut last_child: Subtree = *children.offset(
1489            ((*self_0.ptr).child_count).wrapping_sub(1 as libc::c_int as libc::c_uint) as isize,
1490        );
1491        (*self_0.ptr)
1492            .c2rust_unnamed
1493            .c2rust_unnamed
1494            .first_leaf
1495            .symbol = ts_subtree_leaf_symbol(first_child);
1496        (*self_0.ptr)
1497            .c2rust_unnamed
1498            .c2rust_unnamed
1499            .first_leaf
1500            .parse_state = ts_subtree_leaf_parse_state(first_child);
1501        if ts_subtree_fragile_left(first_child) {
1502            (*self_0.ptr).set_fragile_left(1 as libc::c_int != 0);
1503        }
1504        if ts_subtree_fragile_right(last_child) {
1505            (*self_0.ptr).set_fragile_right(1 as libc::c_int != 0);
1506        }
1507        if (*self_0.ptr).child_count >= 2 as libc::c_int as libc::c_uint
1508            && !(*self_0.ptr).visible()
1509            && !(*self_0.ptr).named()
1510            && ts_subtree_symbol(first_child) as libc::c_int == (*self_0.ptr).symbol as libc::c_int
1511        {
1512            if ts_subtree_repeat_depth(first_child) > ts_subtree_repeat_depth(last_child) {
1513                (*self_0.ptr).c2rust_unnamed.c2rust_unnamed.repeat_depth =
1514                    (ts_subtree_repeat_depth(first_child))
1515                        .wrapping_add(1 as libc::c_int as libc::c_uint)
1516                        as uint16_t;
1517            } else {
1518                (*self_0.ptr).c2rust_unnamed.c2rust_unnamed.repeat_depth =
1519                    (ts_subtree_repeat_depth(last_child))
1520                        .wrapping_add(1 as libc::c_int as libc::c_uint)
1521                        as uint16_t;
1522            }
1523        }
1524    }
1525}
1526#[no_mangle]
1527pub unsafe extern "C" fn ts_subtree_new_node(
1528    mut symbol: TSSymbol,
1529    mut children: *mut SubtreeArray,
1530    mut production_id: libc::c_uint,
1531    mut language: *const TSLanguage,
1532) -> MutableSubtree {
1533    let mut metadata: TSSymbolMetadata = ts_language_symbol_metadata(language, symbol);
1534    let mut fragile: bool = symbol as libc::c_int == -(1 as libc::c_int) as TSSymbol as libc::c_int
1535        || symbol as libc::c_int
1536            == -(1 as libc::c_int) as TSSymbol as libc::c_int - 1 as libc::c_int;
1537    let mut new_byte_size: size_t = ts_subtree_alloc_size((*children).size);
1538    if ((*children).capacity as libc::c_ulong)
1539        .wrapping_mul(::core::mem::size_of::<Subtree>() as libc::c_ulong)
1540        < new_byte_size
1541    {
1542        (*children).contents = crate::core_transpiled::alloc::ts_realloc(
1543            (*children).contents as *mut libc::c_void,
1544            new_byte_size,
1545        ) as *mut Subtree;
1546        (*children).capacity = new_byte_size
1547            .wrapping_div(::core::mem::size_of::<Subtree>() as libc::c_ulong)
1548            as uint32_t;
1549    }
1550    let mut data: *mut SubtreeHeapData = &mut *((*children).contents)
1551        .offset((*children).size as isize) as *mut Subtree
1552        as *mut SubtreeHeapData;
1553    *data = {
1554        let mut init = SubtreeHeapData { visible_named_extra_fragile_left_fragile_right_has_changes_has_external_tokens_has_external_scanner_state_change_depends_on_column_is_missing_is_keyword : [0 ; 2] , c2rust_padding : [0 ; 2] , ref_count : 1 as libc :: c_int as uint32_t , padding : Length { bytes : 0 , extent : TSPoint { row : 0 , column : 0 } , } , size : Length { bytes : 0 , extent : TSPoint { row : 0 , column : 0 } , } , lookahead_bytes : 0 , error_cost : 0 , child_count : (* children) . size , symbol : symbol , parse_state : 0 , c2rust_unnamed : C2RustUnnamed_5 { c2rust_unnamed : { let mut init = C2RustUnnamed_6 { visible_child_count : 0 , named_child_count : 0 , visible_descendant_count : 0 as libc :: c_int as uint32_t , dynamic_precedence : 0 , repeat_depth : 0 , production_id : production_id as uint16_t , first_leaf : { let mut init = C2RustUnnamed_7 { symbol : 0 as libc :: c_int as TSSymbol , parse_state : 0 as libc :: c_int as TSStateId , } ; init } , } ; init } , } , } ;
1555        init.set_visible(metadata.visible);
1556        init.set_named(metadata.named);
1557        init.set_extra(false);
1558        init.set_fragile_left(fragile);
1559        init.set_fragile_right(fragile);
1560        init.set_has_changes(0 as libc::c_int != 0);
1561        init.set_has_external_tokens(false);
1562        init.set_has_external_scanner_state_change(0 as libc::c_int != 0);
1563        init.set_depends_on_column(false);
1564        init.set_is_missing(false);
1565        init.set_is_keyword(0 as libc::c_int != 0);
1566        init
1567    };
1568    let mut result: MutableSubtree = MutableSubtree { ptr: data };
1569    ts_subtree_summarize_children(result, language);
1570    return result;
1571}
1572#[no_mangle]
1573pub unsafe extern "C" fn ts_subtree_new_error_node(
1574    mut children: *mut SubtreeArray,
1575    mut extra: bool,
1576    mut language: *const TSLanguage,
1577) -> Subtree {
1578    let mut result: MutableSubtree = ts_subtree_new_node(
1579        -(1 as libc::c_int) as TSSymbol,
1580        children,
1581        0 as libc::c_int as libc::c_uint,
1582        language,
1583    );
1584    (*result.ptr).set_extra(extra);
1585    return ts_subtree_from_mut(result);
1586}
1587#[no_mangle]
1588pub unsafe extern "C" fn ts_subtree_new_missing_leaf(
1589    mut pool: *mut SubtreePool,
1590    mut symbol: TSSymbol,
1591    mut padding: Length,
1592    mut lookahead_bytes: uint32_t,
1593    mut language: *const TSLanguage,
1594) -> Subtree {
1595    let mut result: Subtree = ts_subtree_new_leaf(
1596        pool,
1597        symbol,
1598        padding,
1599        length_zero(),
1600        lookahead_bytes,
1601        0 as libc::c_int as TSStateId,
1602        0 as libc::c_int != 0,
1603        0 as libc::c_int != 0,
1604        0 as libc::c_int != 0,
1605        language,
1606    );
1607    if (result.data).is_inline() {
1608        (result.data).set_is_missing(1 as libc::c_int != 0);
1609    } else {
1610        let ref mut fresh9 = *(result.ptr as *mut SubtreeHeapData);
1611        (*fresh9).set_is_missing(1 as libc::c_int != 0);
1612    }
1613    return result;
1614}
1615#[no_mangle]
1616pub unsafe extern "C" fn ts_subtree_retain(mut self_0: Subtree) {
1617    if (self_0.data).is_inline() {
1618        return;
1619    }
1620    if (*self_0.ptr).ref_count > 0 as libc::c_int as libc::c_uint {
1621    } else {
1622        panic!();
1623    }
1624    atomic_inc(&(*self_0.ptr).ref_count as *const uint32_t as *mut uint32_t);
1625    if (*self_0.ptr).ref_count != 0 as libc::c_int as libc::c_uint {
1626    } else {
1627        panic!();
1628    };
1629}
1630#[no_mangle]
1631pub unsafe extern "C" fn ts_subtree_release(mut pool: *mut SubtreePool, mut self_0: Subtree) {
1632    if (self_0.data).is_inline() {
1633        return;
1634    }
1635    (*pool).tree_stack.size = 0 as libc::c_int as uint32_t;
1636    if (*self_0.ptr).ref_count > 0 as libc::c_int as libc::c_uint {
1637    } else {
1638        panic!();
1639    }
1640    if atomic_dec(&(*self_0.ptr).ref_count as *const uint32_t as *mut uint32_t)
1641        == 0 as libc::c_int as libc::c_uint
1642    {
1643        _array__grow(
1644            &mut (*pool).tree_stack as *mut MutableSubtreeArray as *mut Array,
1645            1 as libc::c_int as uint32_t,
1646            ::core::mem::size_of::<MutableSubtree>() as libc::c_ulong,
1647        );
1648        let fresh10 = (*pool).tree_stack.size;
1649        (*pool).tree_stack.size = ((*pool).tree_stack.size).wrapping_add(1);
1650        *((*pool).tree_stack.contents).offset(fresh10 as isize) = ts_subtree_to_mut_unsafe(self_0);
1651    }
1652    while (*pool).tree_stack.size > 0 as libc::c_int as libc::c_uint {
1653        (*pool).tree_stack.size = ((*pool).tree_stack.size).wrapping_sub(1);
1654        let mut tree: MutableSubtree =
1655            *((*pool).tree_stack.contents).offset((*pool).tree_stack.size as isize);
1656        if (*tree.ptr).child_count > 0 as libc::c_int as libc::c_uint {
1657            let mut children: *mut Subtree = if (tree.data).is_inline() as libc::c_int != 0 {
1658                0 as *mut Subtree
1659            } else {
1660                (tree.ptr as *mut Subtree).offset(-((*tree.ptr).child_count as isize))
1661            };
1662            let mut i: uint32_t = 0 as libc::c_int as uint32_t;
1663            while i < (*tree.ptr).child_count {
1664                let mut child: Subtree = *children.offset(i as isize);
1665                if !(child.data).is_inline() {
1666                    if (*child.ptr).ref_count > 0 as libc::c_int as libc::c_uint {
1667                    } else {
1668                        panic!();
1669                    }
1670                    if atomic_dec(&(*child.ptr).ref_count as *const uint32_t as *mut uint32_t)
1671                        == 0 as libc::c_int as libc::c_uint
1672                    {
1673                        _array__grow(
1674                            &mut (*pool).tree_stack as *mut MutableSubtreeArray as *mut Array,
1675                            1 as libc::c_int as uint32_t,
1676                            ::core::mem::size_of::<MutableSubtree>() as libc::c_ulong,
1677                        );
1678                        let fresh11 = (*pool).tree_stack.size;
1679                        (*pool).tree_stack.size = ((*pool).tree_stack.size).wrapping_add(1);
1680                        *((*pool).tree_stack.contents).offset(fresh11 as isize) =
1681                            ts_subtree_to_mut_unsafe(child);
1682                    }
1683                }
1684                i = i.wrapping_add(1);
1685            }
1686            crate::core_transpiled::alloc::ts_free(children as *mut libc::c_void);
1687        } else {
1688            if (*tree.ptr).has_external_tokens() {
1689                ts_external_scanner_state_delete(
1690                    &mut (*tree.ptr).c2rust_unnamed.external_scanner_state,
1691                );
1692            }
1693            ts_subtree_pool_free(pool, tree.ptr);
1694        }
1695    }
1696}
1697#[no_mangle]
1698pub unsafe extern "C" fn ts_subtree_compare(
1699    mut left: Subtree,
1700    mut right: Subtree,
1701    mut pool: *mut SubtreePool,
1702) -> libc::c_int {
1703    _array__grow(
1704        &mut (*pool).tree_stack as *mut MutableSubtreeArray as *mut Array,
1705        1 as libc::c_int as uint32_t,
1706        ::core::mem::size_of::<MutableSubtree>() as libc::c_ulong,
1707    );
1708    let fresh12 = (*pool).tree_stack.size;
1709    (*pool).tree_stack.size = ((*pool).tree_stack.size).wrapping_add(1);
1710    *((*pool).tree_stack.contents).offset(fresh12 as isize) = ts_subtree_to_mut_unsafe(left);
1711    _array__grow(
1712        &mut (*pool).tree_stack as *mut MutableSubtreeArray as *mut Array,
1713        1 as libc::c_int as uint32_t,
1714        ::core::mem::size_of::<MutableSubtree>() as libc::c_ulong,
1715    );
1716    let fresh13 = (*pool).tree_stack.size;
1717    (*pool).tree_stack.size = ((*pool).tree_stack.size).wrapping_add(1);
1718    *((*pool).tree_stack.contents).offset(fresh13 as isize) = ts_subtree_to_mut_unsafe(right);
1719    while (*pool).tree_stack.size > 0 as libc::c_int as libc::c_uint {
1720        (*pool).tree_stack.size = ((*pool).tree_stack.size).wrapping_sub(1);
1721        right = ts_subtree_from_mut(
1722            *((*pool).tree_stack.contents).offset((*pool).tree_stack.size as isize),
1723        );
1724        (*pool).tree_stack.size = ((*pool).tree_stack.size).wrapping_sub(1);
1725        left = ts_subtree_from_mut(
1726            *((*pool).tree_stack.contents).offset((*pool).tree_stack.size as isize),
1727        );
1728        let mut result: libc::c_int = 0 as libc::c_int;
1729        if (ts_subtree_symbol(left) as libc::c_int) < ts_subtree_symbol(right) as libc::c_int {
1730            result = -(1 as libc::c_int);
1731        } else if (ts_subtree_symbol(right) as libc::c_int) < ts_subtree_symbol(left) as libc::c_int
1732        {
1733            result = 1 as libc::c_int;
1734        } else if ts_subtree_child_count(left) < ts_subtree_child_count(right) {
1735            result = -(1 as libc::c_int);
1736        } else if ts_subtree_child_count(right) < ts_subtree_child_count(left) {
1737            result = 1 as libc::c_int;
1738        }
1739        if result != 0 as libc::c_int {
1740            (*pool).tree_stack.size = 0 as libc::c_int as uint32_t;
1741            return result;
1742        }
1743        let mut i: uint32_t = ts_subtree_child_count(left);
1744        while i > 0 as libc::c_int as libc::c_uint {
1745            let mut left_child: Subtree = *if (left.data).is_inline() as libc::c_int != 0 {
1746                0 as *mut Subtree
1747            } else {
1748                (left.ptr as *mut Subtree).offset(-((*left.ptr).child_count as isize))
1749            }
1750            .offset(i.wrapping_sub(1 as libc::c_int as libc::c_uint) as isize);
1751            let mut right_child: Subtree = *if (right.data).is_inline() as libc::c_int != 0 {
1752                0 as *mut Subtree
1753            } else {
1754                (right.ptr as *mut Subtree).offset(-((*right.ptr).child_count as isize))
1755            }
1756            .offset(i.wrapping_sub(1 as libc::c_int as libc::c_uint) as isize);
1757            _array__grow(
1758                &mut (*pool).tree_stack as *mut MutableSubtreeArray as *mut Array,
1759                1 as libc::c_int as uint32_t,
1760                ::core::mem::size_of::<MutableSubtree>() as libc::c_ulong,
1761            );
1762            let fresh14 = (*pool).tree_stack.size;
1763            (*pool).tree_stack.size = ((*pool).tree_stack.size).wrapping_add(1);
1764            *((*pool).tree_stack.contents).offset(fresh14 as isize) =
1765                ts_subtree_to_mut_unsafe(left_child);
1766            _array__grow(
1767                &mut (*pool).tree_stack as *mut MutableSubtreeArray as *mut Array,
1768                1 as libc::c_int as uint32_t,
1769                ::core::mem::size_of::<MutableSubtree>() as libc::c_ulong,
1770            );
1771            let fresh15 = (*pool).tree_stack.size;
1772            (*pool).tree_stack.size = ((*pool).tree_stack.size).wrapping_add(1);
1773            *((*pool).tree_stack.contents).offset(fresh15 as isize) =
1774                ts_subtree_to_mut_unsafe(right_child);
1775            i = i.wrapping_sub(1);
1776        }
1777    }
1778    return 0 as libc::c_int;
1779}
1780#[inline]
1781unsafe extern "C" fn ts_subtree_set_has_changes(mut self_0: *mut MutableSubtree) {
1782    if ((*self_0).data).is_inline() {
1783        ((*self_0).data).set_has_changes(1 as libc::c_int != 0);
1784    } else {
1785        (*(*self_0).ptr).set_has_changes(1 as libc::c_int != 0);
1786    };
1787}
1788#[no_mangle]
1789pub unsafe extern "C" fn ts_subtree_edit(
1790    mut self_0: Subtree,
1791    mut input_edit: *const TSInputEdit,
1792    mut pool: *mut SubtreePool,
1793) -> Subtree {
1794    let mut stack: C2RustUnnamed_8 = {
1795        let mut init = C2RustUnnamed_8 {
1796            contents: 0 as *mut EditEntry,
1797            size: 0 as libc::c_int as uint32_t,
1798            capacity: 0 as libc::c_int as uint32_t,
1799        };
1800        init
1801    };
1802    _array__grow(
1803        &mut stack as *mut C2RustUnnamed_8 as *mut Array,
1804        1 as libc::c_int as uint32_t,
1805        ::core::mem::size_of::<EditEntry>() as libc::c_ulong,
1806    );
1807    let fresh16 = stack.size;
1808    stack.size = (stack.size).wrapping_add(1);
1809    *(stack.contents).offset(fresh16 as isize) = {
1810        let mut init = EditEntry {
1811            tree: &mut self_0,
1812            edit: {
1813                let mut init = Edit {
1814                    start: {
1815                        let mut init = Length {
1816                            bytes: (*input_edit).start_byte,
1817                            extent: (*input_edit).start_point,
1818                        };
1819                        init
1820                    },
1821                    old_end: {
1822                        let mut init = Length {
1823                            bytes: (*input_edit).old_end_byte,
1824                            extent: (*input_edit).old_end_point,
1825                        };
1826                        init
1827                    },
1828                    new_end: {
1829                        let mut init = Length {
1830                            bytes: (*input_edit).new_end_byte,
1831                            extent: (*input_edit).new_end_point,
1832                        };
1833                        init
1834                    },
1835                };
1836                init
1837            },
1838        };
1839        init
1840    };
1841    while stack.size != 0 {
1842        stack.size = (stack.size).wrapping_sub(1);
1843        let mut entry: EditEntry = *(stack.contents).offset(stack.size as isize);
1844        let mut edit: Edit = entry.edit;
1845        let mut is_noop: bool =
1846            edit.old_end.bytes == edit.start.bytes && edit.new_end.bytes == edit.start.bytes;
1847        let mut is_pure_insertion: bool = edit.old_end.bytes == edit.start.bytes;
1848        let mut parent_depends_on_column: bool = ts_subtree_depends_on_column(*entry.tree);
1849        let mut column_shifted: bool = edit.new_end.extent.column != edit.old_end.extent.column;
1850        let mut size: Length = ts_subtree_size(*entry.tree);
1851        let mut padding: Length = ts_subtree_padding(*entry.tree);
1852        let mut total_size: Length = length_add(padding, size);
1853        let mut lookahead_bytes: uint32_t = ts_subtree_lookahead_bytes(*entry.tree);
1854        let mut end_byte: uint32_t = (total_size.bytes).wrapping_add(lookahead_bytes);
1855        if edit.start.bytes > end_byte
1856            || is_noop as libc::c_int != 0 && edit.start.bytes == end_byte
1857        {
1858            continue;
1859        }
1860        if edit.old_end.bytes <= padding.bytes {
1861            padding = length_add(edit.new_end, length_sub(padding, edit.old_end));
1862        } else if edit.start.bytes < padding.bytes {
1863            size = length_saturating_sub(size, length_sub(edit.old_end, padding));
1864            padding = edit.new_end;
1865        } else if edit.start.bytes == padding.bytes && is_pure_insertion as libc::c_int != 0 {
1866            padding = edit.new_end;
1867        } else if edit.start.bytes < total_size.bytes
1868            || edit.start.bytes == total_size.bytes && is_pure_insertion as libc::c_int != 0
1869        {
1870            size = length_add(
1871                length_sub(edit.new_end, padding),
1872                length_saturating_sub(total_size, edit.old_end),
1873            );
1874        }
1875        let mut result: MutableSubtree = ts_subtree_make_mut(pool, *entry.tree);
1876        if (result.data).is_inline() {
1877            if ts_subtree_can_inline(padding, size, lookahead_bytes) {
1878                result.data.padding_bytes = padding.bytes as uint8_t;
1879                (result.data).set_padding_rows(padding.extent.row as uint8_t);
1880                result.data.padding_columns = padding.extent.column as uint8_t;
1881                result.data.size_bytes = size.bytes as uint8_t;
1882            } else {
1883                let mut data: *mut SubtreeHeapData = ts_subtree_pool_allocate(pool);
1884                ::core::ptr::write_volatile(
1885                    &mut (*data).ref_count as *mut uint32_t,
1886                    1 as libc::c_int as uint32_t,
1887                );
1888                (*data).padding = padding;
1889                (*data).size = size;
1890                (*data).lookahead_bytes = lookahead_bytes;
1891                (*data).error_cost = 0 as libc::c_int as uint32_t;
1892                (*data).child_count = 0 as libc::c_int as uint32_t;
1893                (*data).symbol = result.data.symbol as TSSymbol;
1894                (*data).parse_state = result.data.parse_state;
1895                (*data).set_visible((result.data).visible());
1896                (*data).set_named((result.data).named());
1897                (*data).set_extra((result.data).extra());
1898                (*data).set_fragile_left(0 as libc::c_int != 0);
1899                (*data).set_fragile_right(0 as libc::c_int != 0);
1900                (*data).set_has_changes(0 as libc::c_int != 0);
1901                (*data).set_has_external_tokens(0 as libc::c_int != 0);
1902                (*data).set_depends_on_column(0 as libc::c_int != 0);
1903                (*data).set_is_missing((result.data).is_missing());
1904                (*data).set_is_keyword((result.data).is_keyword());
1905                result.ptr = data;
1906            }
1907        } else {
1908            (*result.ptr).padding = padding;
1909            (*result.ptr).size = size;
1910        }
1911        ts_subtree_set_has_changes(&mut result);
1912        *entry.tree = ts_subtree_from_mut(result);
1913        let mut child_left: Length = Length {
1914            bytes: 0,
1915            extent: TSPoint { row: 0, column: 0 },
1916        };
1917        let mut child_right: Length = length_zero();
1918        let mut i: uint32_t = 0 as libc::c_int as uint32_t;
1919        let mut n: uint32_t = ts_subtree_child_count(*entry.tree);
1920        while i < n {
1921            let mut child: *mut Subtree =
1922                &mut *if ((*entry.tree).data).is_inline() as libc::c_int != 0 {
1923                    0 as *mut Subtree
1924                } else {
1925                    ((*entry.tree).ptr as *mut Subtree)
1926                        .offset(-((*(*entry.tree).ptr).child_count as isize))
1927                }
1928                .offset(i as isize) as *mut Subtree;
1929            let mut child_size: Length = ts_subtree_total_size(*child);
1930            child_left = child_right;
1931            child_right = length_add(child_left, child_size);
1932            if !((child_right.bytes).wrapping_add(ts_subtree_lookahead_bytes(*child))
1933                < edit.start.bytes)
1934            {
1935                if (child_left.bytes > edit.old_end.bytes
1936                    || child_left.bytes == edit.old_end.bytes
1937                        && child_size.bytes > 0 as libc::c_int as libc::c_uint
1938                        && i > 0 as libc::c_int as libc::c_uint)
1939                    && (!parent_depends_on_column || child_left.extent.row > padding.extent.row)
1940                    && (!ts_subtree_depends_on_column(*child)
1941                        || !column_shifted
1942                        || child_left.extent.row > edit.old_end.extent.row)
1943                {
1944                    break;
1945                }
1946                let mut child_edit: Edit = {
1947                    let mut init = Edit {
1948                        start: length_saturating_sub(edit.start, child_left),
1949                        old_end: length_saturating_sub(edit.old_end, child_left),
1950                        new_end: length_saturating_sub(edit.new_end, child_left),
1951                    };
1952                    init
1953                };
1954                if child_right.bytes > edit.start.bytes
1955                    || child_right.bytes == edit.start.bytes
1956                        && is_pure_insertion as libc::c_int != 0
1957                {
1958                    edit.new_end = edit.start;
1959                } else {
1960                    child_edit.old_end = child_edit.start;
1961                    child_edit.new_end = child_edit.start;
1962                }
1963                _array__grow(
1964                    &mut stack as *mut C2RustUnnamed_8 as *mut Array,
1965                    1 as libc::c_int as uint32_t,
1966                    ::core::mem::size_of::<EditEntry>() as libc::c_ulong,
1967                );
1968                let fresh17 = stack.size;
1969                stack.size = (stack.size).wrapping_add(1);
1970                *(stack.contents).offset(fresh17 as isize) = {
1971                    let mut init = EditEntry {
1972                        tree: child,
1973                        edit: child_edit,
1974                    };
1975                    init
1976                };
1977            }
1978            i = i.wrapping_add(1);
1979        }
1980    }
1981    _array__delete(&mut stack as *mut C2RustUnnamed_8 as *mut Array);
1982    return self_0;
1983}
1984#[no_mangle]
1985pub unsafe extern "C" fn ts_subtree_last_external_token(mut tree: Subtree) -> Subtree {
1986    if !ts_subtree_has_external_tokens(tree) {
1987        return Subtree {
1988            ptr: 0 as *const SubtreeHeapData,
1989        };
1990    }
1991    while (*tree.ptr).child_count > 0 as libc::c_int as libc::c_uint {
1992        let mut i: uint32_t =
1993            ((*tree.ptr).child_count).wrapping_sub(1 as libc::c_int as libc::c_uint);
1994        while i.wrapping_add(1 as libc::c_int as libc::c_uint) > 0 as libc::c_int as libc::c_uint {
1995            let mut child: Subtree = *if (tree.data).is_inline() as libc::c_int != 0 {
1996                0 as *mut Subtree
1997            } else {
1998                (tree.ptr as *mut Subtree).offset(-((*tree.ptr).child_count as isize))
1999            }
2000            .offset(i as isize);
2001            if ts_subtree_has_external_tokens(child) {
2002                tree = child;
2003                break;
2004            } else {
2005                i = i.wrapping_sub(1);
2006            }
2007        }
2008    }
2009    return tree;
2010}
2011unsafe extern "C" fn ts_subtree__write_char_to_string(
2012    mut str: *mut libc::c_char,
2013    mut n: size_t,
2014    mut chr: int32_t,
2015) -> size_t {
2016    if chr == -(1 as libc::c_int) {
2017        return snwrite!(str, n as usize, "INVALID",).unwrap_or(usize::MAX) as os::raw::c_int
2018            as size_t;
2019    } else if chr == '\0' as i32 {
2020        return snwrite!(str, n as usize, "'\\0'",).unwrap_or(usize::MAX) as os::raw::c_int
2021            as size_t;
2022    } else if chr == '\n' as i32 {
2023        return snwrite!(str, n as usize, "'\\n'",).unwrap_or(usize::MAX) as os::raw::c_int
2024            as size_t;
2025    } else if chr == '\t' as i32 {
2026        return snwrite!(str, n as usize, "'\\t'",).unwrap_or(usize::MAX) as os::raw::c_int
2027            as size_t;
2028    } else if chr == '\r' as i32 {
2029        return snwrite!(str, n as usize, "'\\r'",).unwrap_or(usize::MAX) as os::raw::c_int
2030            as size_t;
2031    } else if (0 as libc::c_int) < chr
2032        && chr < 128 as libc::c_int
2033        && ((chr as u8).is_ascii_graphic() || chr == ' ' as i32)
2034    {
2035        return snwrite!(str, n as usize, "'{}'", chr as u8 as char).unwrap_or(usize::MAX)
2036            as os::raw::c_int as size_t;
2037    } else {
2038        return snwrite!(str, n as usize, "{}", chr).unwrap_or(usize::MAX) as os::raw::c_int
2039            as size_t;
2040    };
2041}
2042static mut ROOT_FIELD: *const libc::c_char = b"__ROOT__\0" as *const u8 as *const libc::c_char;
2043unsafe extern "C" fn ts_subtree__write_to_string(
2044    mut self_0: Subtree,
2045    mut string: *mut libc::c_char,
2046    mut limit: size_t,
2047    mut language: *const TSLanguage,
2048    mut include_all: bool,
2049    mut alias_symbol: TSSymbol,
2050    mut alias_is_named: bool,
2051    mut field_name: *const libc::c_char,
2052) -> size_t {
2053    if (self_0.ptr).is_null() {
2054        return snwrite!(string, limit as usize, "(NULL)",).unwrap_or(usize::MAX) as os::raw::c_int
2055            as size_t;
2056    }
2057    let mut cursor: *mut libc::c_char = string;
2058    let mut writer: *mut *mut libc::c_char = if limit > 1 as libc::c_int as libc::c_ulong {
2059        &mut cursor
2060    } else {
2061        &mut string
2062    };
2063    let mut is_root: bool = field_name == ROOT_FIELD;
2064    let mut is_visible: bool = include_all as libc::c_int != 0
2065        || ts_subtree_missing(self_0) as libc::c_int != 0
2066        || (if alias_symbol as libc::c_int != 0 {
2067            alias_is_named as libc::c_int
2068        } else {
2069            (ts_subtree_visible(self_0) as libc::c_int != 0
2070                && ts_subtree_named(self_0) as libc::c_int != 0) as libc::c_int
2071        }) != 0;
2072    if is_visible {
2073        if !is_root {
2074            cursor = cursor.offset(
2075                snwrite!(*writer, limit as usize, " ",).unwrap_or(usize::MAX) as os::raw::c_int
2076                    as isize,
2077            );
2078            if !field_name.is_null() {
2079                cursor = cursor.offset(
2080                    snwrite!(
2081                        *writer,
2082                        limit as usize,
2083                        "{}: ",
2084                        std::ffi::CStr::from_ptr(field_name).to_string_lossy()
2085                    )
2086                    .unwrap_or(usize::MAX) as os::raw::c_int as isize,
2087                );
2088            }
2089        }
2090        if ts_subtree_is_error(self_0) as libc::c_int != 0
2091            && ts_subtree_child_count(self_0) == 0 as libc::c_int as libc::c_uint
2092            && (*self_0.ptr).size.bytes > 0 as libc::c_int as libc::c_uint
2093        {
2094            cursor = cursor.offset(
2095                snwrite!(*writer, limit as usize, "(UNEXPECTED ",).unwrap_or(usize::MAX)
2096                    as os::raw::c_int as isize,
2097            );
2098            cursor = cursor.offset(ts_subtree__write_char_to_string(
2099                *writer,
2100                limit,
2101                (*self_0.ptr).c2rust_unnamed.lookahead_char,
2102            ) as isize);
2103        } else {
2104            let mut symbol: TSSymbol = (if alias_symbol as libc::c_int != 0 {
2105                alias_symbol as libc::c_int
2106            } else {
2107                ts_subtree_symbol(self_0) as libc::c_int
2108            }) as TSSymbol;
2109            let mut symbol_name: *const libc::c_char = ts_language_symbol_name(language, symbol);
2110            if ts_subtree_missing(self_0) {
2111                cursor = cursor.offset(
2112                    snwrite!(*writer, limit as usize, "(MISSING ",).unwrap_or(usize::MAX)
2113                        as os::raw::c_int as isize,
2114                );
2115                if alias_is_named as libc::c_int != 0
2116                    || ts_subtree_named(self_0) as libc::c_int != 0
2117                {
2118                    cursor = cursor.offset(
2119                        snwrite!(
2120                            *writer,
2121                            limit as usize,
2122                            "{}",
2123                            std::ffi::CStr::from_ptr(symbol_name).to_string_lossy()
2124                        )
2125                        .unwrap_or(usize::MAX) as os::raw::c_int as isize,
2126                    );
2127                } else {
2128                    cursor = cursor.offset(
2129                        snwrite!(
2130                            *writer,
2131                            limit as usize,
2132                            "\"{}\"",
2133                            std::ffi::CStr::from_ptr(symbol_name).to_string_lossy()
2134                        )
2135                        .unwrap_or(usize::MAX) as os::raw::c_int as isize,
2136                    );
2137                }
2138            } else {
2139                cursor = cursor.offset(
2140                    snwrite!(
2141                        *writer,
2142                        limit as usize,
2143                        "({}",
2144                        std::ffi::CStr::from_ptr(symbol_name).to_string_lossy()
2145                    )
2146                    .unwrap_or(usize::MAX) as os::raw::c_int as isize,
2147                );
2148            }
2149        }
2150    } else if is_root {
2151        let mut symbol_0: TSSymbol = (if alias_symbol as libc::c_int != 0 {
2152            alias_symbol as libc::c_int
2153        } else {
2154            ts_subtree_symbol(self_0) as libc::c_int
2155        }) as TSSymbol;
2156        let mut symbol_name_0: *const libc::c_char = ts_language_symbol_name(language, symbol_0);
2157        if ts_subtree_child_count(self_0) > 0 as libc::c_int as libc::c_uint {
2158            cursor = cursor.offset(
2159                snwrite!(
2160                    *writer,
2161                    limit as usize,
2162                    "({}",
2163                    std::ffi::CStr::from_ptr(symbol_name_0).to_string_lossy()
2164                )
2165                .unwrap_or(usize::MAX) as os::raw::c_int as isize,
2166            );
2167        } else if ts_subtree_named(self_0) {
2168            cursor = cursor.offset(
2169                snwrite!(
2170                    *writer,
2171                    limit as usize,
2172                    "({})",
2173                    std::ffi::CStr::from_ptr(symbol_name_0).to_string_lossy()
2174                )
2175                .unwrap_or(usize::MAX) as os::raw::c_int as isize,
2176            );
2177        } else {
2178            cursor = cursor.offset(
2179                snwrite!(
2180                    *writer,
2181                    limit as usize,
2182                    "(\"{}\")",
2183                    std::ffi::CStr::from_ptr(symbol_name_0).to_string_lossy()
2184                )
2185                .unwrap_or(usize::MAX) as os::raw::c_int as isize,
2186            );
2187        }
2188    }
2189    if ts_subtree_child_count(self_0) != 0 {
2190        let mut alias_sequence: *const TSSymbol = ts_language_alias_sequence(
2191            language,
2192            (*self_0.ptr).c2rust_unnamed.c2rust_unnamed.production_id as uint32_t,
2193        );
2194        let mut field_map: *const TSFieldMapEntry = 0 as *const TSFieldMapEntry;
2195        let mut field_map_end: *const TSFieldMapEntry = 0 as *const TSFieldMapEntry;
2196        ts_language_field_map(
2197            language,
2198            (*self_0.ptr).c2rust_unnamed.c2rust_unnamed.production_id as uint32_t,
2199            &mut field_map,
2200            &mut field_map_end,
2201        );
2202        let mut structural_child_index: uint32_t = 0 as libc::c_int as uint32_t;
2203        let mut i: uint32_t = 0 as libc::c_int as uint32_t;
2204        while i < (*self_0.ptr).child_count {
2205            let mut child: Subtree = *if (self_0.data).is_inline() as libc::c_int != 0 {
2206                0 as *mut Subtree
2207            } else {
2208                (self_0.ptr as *mut Subtree).offset(-((*self_0.ptr).child_count as isize))
2209            }
2210            .offset(i as isize);
2211            if ts_subtree_extra(child) {
2212                cursor = cursor.offset(ts_subtree__write_to_string(
2213                    child,
2214                    *writer,
2215                    limit,
2216                    language,
2217                    include_all,
2218                    0 as libc::c_int as TSSymbol,
2219                    0 as libc::c_int != 0,
2220                    0 as *const libc::c_char,
2221                ) as isize);
2222            } else {
2223                let mut subtree_alias_symbol: TSSymbol = (if !alias_sequence.is_null() {
2224                    *alias_sequence.offset(structural_child_index as isize) as libc::c_int
2225                } else {
2226                    0 as libc::c_int
2227                }) as TSSymbol;
2228                let mut subtree_alias_is_named: bool = if subtree_alias_symbol as libc::c_int != 0 {
2229                    (ts_language_symbol_metadata(language, subtree_alias_symbol)).named
2230                        as libc::c_int
2231                } else {
2232                    0 as libc::c_int
2233                } != 0;
2234                let mut child_field_name: *const libc::c_char = if is_visible as libc::c_int != 0 {
2235                    0 as *const libc::c_char
2236                } else {
2237                    field_name
2238                };
2239                let mut map: *const TSFieldMapEntry = field_map;
2240                while map < field_map_end {
2241                    if !(*map).inherited
2242                        && (*map).child_index as libc::c_uint == structural_child_index
2243                    {
2244                        child_field_name =
2245                            *((*language).field_names).offset((*map).field_id as isize);
2246                        break;
2247                    } else {
2248                        map = map.offset(1);
2249                    }
2250                }
2251                cursor = cursor.offset(ts_subtree__write_to_string(
2252                    child,
2253                    *writer,
2254                    limit,
2255                    language,
2256                    include_all,
2257                    subtree_alias_symbol,
2258                    subtree_alias_is_named,
2259                    child_field_name,
2260                ) as isize);
2261                structural_child_index = structural_child_index.wrapping_add(1);
2262            }
2263            i = i.wrapping_add(1);
2264        }
2265    }
2266    if is_visible {
2267        cursor = cursor.offset(
2268            snwrite!(*writer, limit as usize, ")",).unwrap_or(usize::MAX) as os::raw::c_int
2269                as isize,
2270        );
2271    }
2272    return cursor.offset_from(string) as libc::c_long as size_t;
2273}
2274#[no_mangle]
2275pub unsafe extern "C" fn ts_subtree_string(
2276    mut self_0: Subtree,
2277    mut alias_symbol: TSSymbol,
2278    mut alias_is_named: bool,
2279    mut language: *const TSLanguage,
2280    mut include_all: bool,
2281) -> *mut libc::c_char {
2282    let mut scratch_string: [libc::c_char; 1] = [0; 1];
2283    let mut size: size_t = (ts_subtree__write_to_string(
2284        self_0,
2285        scratch_string.as_mut_ptr(),
2286        1 as libc::c_int as size_t,
2287        language,
2288        include_all,
2289        alias_symbol,
2290        alias_is_named,
2291        ROOT_FIELD,
2292    ))
2293    .wrapping_add(1 as libc::c_int as libc::c_ulong);
2294    let mut result: *mut libc::c_char = crate::core_transpiled::alloc::ts_malloc(
2295        size.wrapping_mul(::core::mem::size_of::<libc::c_char>() as libc::c_ulong),
2296    ) as *mut libc::c_char;
2297    ts_subtree__write_to_string(
2298        self_0,
2299        result,
2300        size,
2301        language,
2302        include_all,
2303        alias_symbol,
2304        alias_is_named,
2305        ROOT_FIELD,
2306    );
2307    return result;
2308}
2309#[no_mangle]
2310pub unsafe extern "C" fn ts_subtree__print_dot_graph(
2311    mut self_0: *const Subtree,
2312    mut start_offset: uint32_t,
2313    mut language: *const TSLanguage,
2314    mut alias_symbol: TSSymbol,
2315    mut f: *mut FILE,
2316) {
2317    let mut subtree_symbol: TSSymbol = ts_subtree_symbol(*self_0);
2318    let mut symbol: TSSymbol = (if alias_symbol as libc::c_int != 0 {
2319        alias_symbol as libc::c_int
2320    } else {
2321        subtree_symbol as libc::c_int
2322    }) as TSSymbol;
2323    let mut end_offset: uint32_t = start_offset.wrapping_add(ts_subtree_total_bytes(*self_0));
2324    fwrite!(
2325        f,
2326        "tree_{:p} [label=\"",
2327        self_0 as *mut libc::c_void as *const os::raw::c_int
2328    )
2329    .unwrap_or(usize::MAX) as os::raw::c_int;
2330    ts_language_write_symbol_as_dot_string(language, f, symbol);
2331    fwrite!(f, "\"",).unwrap_or(usize::MAX) as os::raw::c_int;
2332    if ts_subtree_child_count(*self_0) == 0 as libc::c_int as libc::c_uint {
2333        fwrite!(f, ", shape=plaintext",).unwrap_or(usize::MAX) as os::raw::c_int;
2334    }
2335    if ts_subtree_extra(*self_0) {
2336        fwrite!(f, ", fontcolor=gray",).unwrap_or(usize::MAX) as os::raw::c_int;
2337    }
2338    fwrite ! (f , ", tooltip=\"range: {} - {}\nstate: {}\nerror-cost: {}\nhas-changes: {}\ndepends-on-column: {}\ndescendant-count: {}\nrepeat-depth: {}\nlookahead-bytes: {}" , start_offset , end_offset , ts_subtree_parse_state (* self_0) as libc :: c_int , ts_subtree_error_cost (* self_0) , ts_subtree_has_changes (* self_0) as libc :: c_int , ts_subtree_depends_on_column (* self_0) as libc :: c_int , ts_subtree_visible_descendant_count (* self_0) , ts_subtree_repeat_depth (* self_0) , ts_subtree_lookahead_bytes (* self_0)) . unwrap_or (usize :: MAX) as os :: raw :: c_int ;
2339    if ts_subtree_is_error(*self_0) as libc::c_int != 0
2340        && ts_subtree_child_count(*self_0) == 0 as libc::c_int as libc::c_uint
2341        && (*(*self_0).ptr).c2rust_unnamed.lookahead_char != 0 as libc::c_int
2342    {
2343        fwrite!(
2344            f,
2345            "\ncharacter: '{}'",
2346            (*(*self_0).ptr).c2rust_unnamed.lookahead_char as u8 as char
2347        )
2348        .unwrap_or(usize::MAX) as os::raw::c_int;
2349    }
2350    fwrite!(f, "\"]\n",).unwrap_or(usize::MAX) as os::raw::c_int;
2351    let mut child_start_offset: uint32_t = start_offset;
2352    let mut child_info_offset: uint32_t = ((*language).max_alias_sequence_length as libc::c_int
2353        * ts_subtree_production_id(*self_0) as libc::c_int)
2354        as uint32_t;
2355    let mut i: uint32_t = 0 as libc::c_int as uint32_t;
2356    let mut n: uint32_t = ts_subtree_child_count(*self_0);
2357    while i < n {
2358        let mut child: *const Subtree = &mut *if ((*self_0).data).is_inline() as libc::c_int != 0 {
2359            0 as *mut Subtree
2360        } else {
2361            ((*self_0).ptr as *mut Subtree).offset(-((*(*self_0).ptr).child_count as isize))
2362        }
2363        .offset(i as isize) as *mut Subtree;
2364        let mut subtree_alias_symbol: TSSymbol = 0 as libc::c_int as TSSymbol;
2365        if !ts_subtree_extra(*child) && child_info_offset != 0 {
2366            subtree_alias_symbol =
2367                *((*language).alias_sequences).offset(child_info_offset as isize);
2368            child_info_offset = child_info_offset.wrapping_add(1);
2369        }
2370        ts_subtree__print_dot_graph(child, child_start_offset, language, subtree_alias_symbol, f);
2371        fwrite!(
2372            f,
2373            "tree_{:p} -> tree_{:p} [tooltip={}]\n",
2374            self_0 as *mut libc::c_void as *const os::raw::c_int,
2375            child as *mut libc::c_void as *const os::raw::c_int,
2376            i
2377        )
2378        .unwrap_or(usize::MAX) as os::raw::c_int;
2379        child_start_offset = (child_start_offset as libc::c_uint)
2380            .wrapping_add(ts_subtree_total_bytes(*child)) as uint32_t
2381            as uint32_t;
2382        i = i.wrapping_add(1);
2383    }
2384}
2385#[no_mangle]
2386pub unsafe extern "C" fn ts_subtree_print_dot_graph(
2387    mut self_0: Subtree,
2388    mut language: *const TSLanguage,
2389    mut f: *mut FILE,
2390) {
2391    fwrite!(f, "digraph tree {{\n",).unwrap_or(usize::MAX) as os::raw::c_int;
2392    fwrite!(f, "edge [arrowhead=none]\n",).unwrap_or(usize::MAX) as os::raw::c_int;
2393    ts_subtree__print_dot_graph(
2394        &mut self_0,
2395        0 as libc::c_int as uint32_t,
2396        language,
2397        0 as libc::c_int as TSSymbol,
2398        f,
2399    );
2400    fwrite!(f, "}}\n",).unwrap_or(usize::MAX) as os::raw::c_int;
2401}
2402#[no_mangle]
2403pub unsafe extern "C" fn ts_subtree_external_scanner_state(
2404    mut self_0: Subtree,
2405) -> *const ExternalScannerState {
2406    static mut empty_state: ExternalScannerState = {
2407        let mut init = ExternalScannerState {
2408            c2rust_unnamed: C2RustUnnamed_4 {
2409                short_data: [
2410                    0 as libc::c_int as libc::c_char,
2411                    0,
2412                    0,
2413                    0,
2414                    0,
2415                    0,
2416                    0,
2417                    0,
2418                    0,
2419                    0,
2420                    0,
2421                    0,
2422                    0,
2423                    0,
2424                    0,
2425                    0,
2426                    0,
2427                    0,
2428                    0,
2429                    0,
2430                    0,
2431                    0,
2432                    0,
2433                    0,
2434                ],
2435            },
2436            length: 0 as libc::c_int as uint32_t,
2437        };
2438        init
2439    };
2440    if !(self_0.ptr).is_null()
2441        && !(self_0.data).is_inline()
2442        && (*self_0.ptr).has_external_tokens() as libc::c_int != 0
2443        && (*self_0.ptr).child_count == 0 as libc::c_int as libc::c_uint
2444    {
2445        return &(*self_0.ptr).c2rust_unnamed.external_scanner_state;
2446    } else {
2447        return &empty_state;
2448    };
2449}
2450#[no_mangle]
2451pub unsafe extern "C" fn ts_subtree_external_scanner_state_eq(
2452    mut self_0: Subtree,
2453    mut other: Subtree,
2454) -> bool {
2455    let mut state_self: *const ExternalScannerState = ts_subtree_external_scanner_state(self_0);
2456    let mut state_other: *const ExternalScannerState = ts_subtree_external_scanner_state(other);
2457    return ts_external_scanner_state_eq(
2458        state_self,
2459        ts_external_scanner_state_data(state_other),
2460        (*state_other).length,
2461    );
2462}