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