tree_sitter_c2rust/core_wrapper/core/
node.rs

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
use crate::core_transpiled::util::*;
use crate::core_transpiled::*;
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 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 TSStateId = uint16_t;
pub type TSFieldId = uint16_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed {
    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_0 {
    pub count: uint8_t,
    pub reusable: bool,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_1 {
    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_2 {
    pub type_: uint8_t,
    pub state: TSStateId,
    pub extra: bool,
    pub repetition: bool,
}
type C2RustUnnamed_3 = crate::core_transpiled::util::ScannerStateWithLookahead;
type C2RustUnnamed_4 = crate::core_transpiled::util::LongShortData;
type C2RustUnnamed_5 = crate::core_transpiled::util::ScannerStateLookaheadMeta;
type C2RustUnnamed_6 = crate::core_transpiled::util::ScannerStateLookaheadFirstLeaf;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct TSNode {
    pub context: [uint32_t; 4],
    pub id: *const libc::c_void,
    pub tree: *const TSTree,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct NodeChildIterator {
    pub parent: Subtree,
    pub tree: *const TSTree,
    pub position: Length,
    pub child_index: uint32_t,
    pub structural_child_index: uint32_t,
    pub alias_sequence: *const TSSymbol,
}
#[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_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 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__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 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 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_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_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_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_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_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 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_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 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_total_bytes(mut self_0: Subtree) -> uint32_t {
    return (ts_subtree_total_size(self_0)).bytes;
}
#[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 point_lt(mut a: TSPoint, mut b: TSPoint) -> bool {
    return a.row < b.row || a.row == b.row && a.column < b.column;
}
#[inline]
unsafe extern "C" fn point_lte(mut a: TSPoint, mut b: TSPoint) -> bool {
    return a.row < b.row || a.row == b.row && a.column <= b.column;
}
#[inline]
unsafe extern "C" fn point_eq(mut a: TSPoint, mut b: TSPoint) -> bool {
    return a.row == b.row && a.column == 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 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);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_new(
    mut tree: *const TSTree,
    mut subtree: *const Subtree,
    mut position: Length,
    mut alias: TSSymbol,
) -> TSNode {
    return {
        let mut init = TSNode {
            context: [
                position.bytes,
                position.extent.row,
                position.extent.column,
                alias as uint32_t,
            ],
            id: subtree as *const libc::c_void,
            tree: tree,
        };
        init
    };
}
#[inline]
unsafe extern "C" fn ts_node__null() -> TSNode {
    return ts_node_new(
        0 as *const TSTree,
        0 as *const Subtree,
        length_zero(),
        0 as libc::c_int as TSSymbol,
    );
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_start_byte(mut self_0: TSNode) -> uint32_t {
    return self_0.context[0 as libc::c_int as usize];
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_start_point(mut self_0: TSNode) -> TSPoint {
    return {
        let mut init = TSPoint {
            row: self_0.context[1 as libc::c_int as usize],
            column: self_0.context[2 as libc::c_int as usize],
        };
        init
    };
}
#[inline]
unsafe extern "C" fn ts_node__alias(mut self_0: *const TSNode) -> uint32_t {
    return (*self_0).context[3 as libc::c_int as usize];
}
#[inline]
unsafe extern "C" fn ts_node__subtree(mut self_0: TSNode) -> Subtree {
    return *(self_0.id as *const Subtree);
}
#[inline]
unsafe extern "C" fn ts_node_iterate_children(mut node: *const TSNode) -> NodeChildIterator {
    let mut subtree: Subtree = ts_node__subtree(*node);
    if ts_subtree_child_count(subtree) == 0 as libc::c_int as libc::c_uint {
        return {
            let mut init = NodeChildIterator {
                parent: Subtree {
                    ptr: 0 as *const SubtreeHeapData,
                },
                tree: (*node).tree,
                position: length_zero(),
                child_index: 0 as libc::c_int as uint32_t,
                structural_child_index: 0 as libc::c_int as uint32_t,
                alias_sequence: 0 as *const TSSymbol,
            };
            init
        };
    }
    let mut alias_sequence: *const TSSymbol = ts_language_alias_sequence(
        (*(*node).tree).language,
        (*subtree.ptr).c2rust_unnamed.c2rust_unnamed.production_id as uint32_t,
    );
    return {
        let mut init = NodeChildIterator {
            parent: subtree,
            tree: (*node).tree,
            position: {
                let mut init = Length {
                    bytes: ts_node_start_byte(*node),
                    extent: ts_node_start_point(*node),
                };
                init
            },
            child_index: 0 as libc::c_int as uint32_t,
            structural_child_index: 0 as libc::c_int as uint32_t,
            alias_sequence: alias_sequence,
        };
        init
    };
}
#[inline]
unsafe extern "C" fn ts_node_child_iterator_done(mut self_0: *mut NodeChildIterator) -> bool {
    return (*self_0).child_index == (*(*self_0).parent.ptr).child_count;
}
#[inline]
unsafe extern "C" fn ts_node_child_iterator_next(
    mut self_0: *mut NodeChildIterator,
    mut result: *mut TSNode,
) -> bool {
    if ((*self_0).parent.ptr).is_null() || ts_node_child_iterator_done(self_0) as libc::c_int != 0 {
        return 0 as libc::c_int != 0;
    }
    let mut child: *const Subtree = &mut *if ((*self_0).parent.data).is_inline() as libc::c_int != 0
    {
        0 as *mut Subtree
    } else {
        ((*self_0).parent.ptr as *mut Subtree)
            .offset(-((*(*self_0).parent.ptr).child_count as isize))
    }
    .offset((*self_0).child_index as isize) as *mut Subtree;
    let mut alias_symbol: TSSymbol = 0 as libc::c_int as TSSymbol;
    if !ts_subtree_extra(*child) {
        if !((*self_0).alias_sequence).is_null() {
            alias_symbol =
                *((*self_0).alias_sequence).offset((*self_0).structural_child_index as isize);
        }
        (*self_0).structural_child_index = ((*self_0).structural_child_index).wrapping_add(1);
    }
    if (*self_0).child_index > 0 as libc::c_int as libc::c_uint {
        (*self_0).position = length_add((*self_0).position, ts_subtree_padding(*child));
    }
    *result = ts_node_new((*self_0).tree, child, (*self_0).position, alias_symbol);
    (*self_0).position = length_add((*self_0).position, ts_subtree_size(*child));
    (*self_0).child_index = ((*self_0).child_index).wrapping_add(1);
    return 1 as libc::c_int != 0;
}
#[inline]
unsafe extern "C" fn ts_node_child_iterator_next_sibling_is_empty_adjacent(
    mut self_0: *mut NodeChildIterator,
    mut previous: TSNode,
) -> bool {
    if ((*self_0).parent.ptr).is_null() || ts_node_child_iterator_done(self_0) as libc::c_int != 0 {
        return 0 as libc::c_int != 0;
    }
    if (*self_0).child_index == 0 as libc::c_int as libc::c_uint {
        return 0 as libc::c_int != 0;
    }
    let mut child: *const Subtree = &mut *if ((*self_0).parent.data).is_inline() as libc::c_int != 0
    {
        0 as *mut Subtree
    } else {
        ((*self_0).parent.ptr as *mut Subtree)
            .offset(-((*(*self_0).parent.ptr).child_count as isize))
    }
    .offset((*self_0).child_index as isize) as *mut Subtree;
    let mut alias: TSSymbol = 0 as libc::c_int as TSSymbol;
    if !ts_subtree_extra(*child) {
        if !((*self_0).alias_sequence).is_null() {
            alias = *((*self_0).alias_sequence).offset((*self_0).structural_child_index as isize);
        }
    }
    let mut next: TSNode = ts_node_new((*self_0).tree, child, (*self_0).position, alias);
    return ts_node_end_byte(previous) == ts_node_end_byte(next)
        && ts_node__is_relevant(next, 1 as libc::c_int != 0) as libc::c_int != 0;
}
#[inline]
unsafe extern "C" fn ts_node__is_relevant(mut self_0: TSNode, mut include_anonymous: bool) -> bool {
    let mut tree: Subtree = ts_node__subtree(self_0);
    if include_anonymous {
        return ts_subtree_visible(tree) as libc::c_int != 0 || ts_node__alias(&mut self_0) != 0;
    } else {
        let mut alias: TSSymbol = ts_node__alias(&mut self_0) as TSSymbol;
        if alias != 0 {
            return (ts_language_symbol_metadata((*self_0.tree).language, alias)).named;
        } else {
            return ts_subtree_visible(tree) as libc::c_int != 0
                && ts_subtree_named(tree) as libc::c_int != 0;
        }
    };
}
#[inline]
unsafe extern "C" fn ts_node__relevant_child_count(
    mut self_0: TSNode,
    mut include_anonymous: bool,
) -> uint32_t {
    let mut tree: Subtree = ts_node__subtree(self_0);
    if ts_subtree_child_count(tree) > 0 as libc::c_int as libc::c_uint {
        if include_anonymous {
            return (*tree.ptr)
                .c2rust_unnamed
                .c2rust_unnamed
                .visible_child_count;
        } else {
            return (*tree.ptr).c2rust_unnamed.c2rust_unnamed.named_child_count;
        }
    } else {
        return 0 as libc::c_int as uint32_t;
    };
}
#[inline]
unsafe extern "C" fn ts_node__child(
    mut self_0: TSNode,
    mut child_index: uint32_t,
    mut include_anonymous: bool,
) -> TSNode {
    let mut result: TSNode = self_0;
    let mut did_descend: bool = 1 as libc::c_int != 0;
    while did_descend {
        did_descend = 0 as libc::c_int != 0;
        let mut child: TSNode = TSNode {
            context: [0; 4],
            id: 0 as *const libc::c_void,
            tree: 0 as *const TSTree,
        };
        let mut index: uint32_t = 0 as libc::c_int as uint32_t;
        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut result);
        while ts_node_child_iterator_next(&mut iterator, &mut child) {
            if ts_node__is_relevant(child, include_anonymous) {
                if index == child_index {
                    return child;
                }
                index = index.wrapping_add(1);
            } else {
                let mut grandchild_index: uint32_t = child_index.wrapping_sub(index);
                let mut grandchild_count: uint32_t =
                    ts_node__relevant_child_count(child, include_anonymous);
                if grandchild_index < grandchild_count {
                    did_descend = 1 as libc::c_int != 0;
                    result = child;
                    child_index = grandchild_index;
                    break;
                } else {
                    index = (index as libc::c_uint).wrapping_add(grandchild_count) as uint32_t
                        as uint32_t;
                }
            }
        }
    }
    return ts_node__null();
}
unsafe extern "C" fn ts_subtree_has_trailing_empty_descendant(
    mut self_0: Subtree,
    mut other: Subtree,
) -> bool {
    let mut i: libc::c_uint =
        (ts_subtree_child_count(self_0)).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 (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_total_bytes(child) > 0 as libc::c_int as libc::c_uint {
            break;
        }
        if child.ptr == other.ptr
            || ts_subtree_has_trailing_empty_descendant(child, other) as libc::c_int != 0
        {
            return 1 as libc::c_int != 0;
        }
        i = i.wrapping_sub(1);
    }
    return 0 as libc::c_int != 0;
}
#[inline]
unsafe extern "C" fn ts_node__prev_sibling(
    mut self_0: TSNode,
    mut include_anonymous: bool,
) -> TSNode {
    let mut self_subtree: Subtree = ts_node__subtree(self_0);
    let mut self_is_empty: bool =
        ts_subtree_total_bytes(self_subtree) == 0 as libc::c_int as libc::c_uint;
    let mut target_end_byte: uint32_t = ts_node_end_byte(self_0);
    let mut node: TSNode = ts_node_parent(self_0);
    let mut earlier_node: TSNode = ts_node__null();
    let mut earlier_node_is_relevant: bool = 0 as libc::c_int != 0;
    while !ts_node_is_null(node) {
        let mut earlier_child: TSNode = ts_node__null();
        let mut earlier_child_is_relevant: bool = 0 as libc::c_int != 0;
        let mut found_child_containing_target: bool = 0 as libc::c_int != 0;
        let mut child: TSNode = TSNode {
            context: [0; 4],
            id: 0 as *const libc::c_void,
            tree: 0 as *const TSTree,
        };
        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut node);
        while ts_node_child_iterator_next(&mut iterator, &mut child) {
            if child.id == self_0.id {
                break;
            }
            if iterator.position.bytes > target_end_byte {
                found_child_containing_target = 1 as libc::c_int != 0;
                break;
            } else if iterator.position.bytes == target_end_byte
                && (!self_is_empty
                    || ts_subtree_has_trailing_empty_descendant(
                        ts_node__subtree(child),
                        self_subtree,
                    ) as libc::c_int
                        != 0)
            {
                found_child_containing_target = 1 as libc::c_int != 0;
                break;
            } else if ts_node__is_relevant(child, include_anonymous) {
                earlier_child = child;
                earlier_child_is_relevant = 1 as libc::c_int != 0;
            } else if ts_node__relevant_child_count(child, include_anonymous)
                > 0 as libc::c_int as libc::c_uint
            {
                earlier_child = child;
                earlier_child_is_relevant = 0 as libc::c_int != 0;
            }
        }
        if found_child_containing_target {
            if !ts_node_is_null(earlier_child) {
                earlier_node = earlier_child;
                earlier_node_is_relevant = earlier_child_is_relevant;
            }
            node = child;
        } else if earlier_child_is_relevant {
            return earlier_child;
        } else {
            if !ts_node_is_null(earlier_child) {
                node = earlier_child;
            } else if earlier_node_is_relevant {
                return earlier_node;
            } else {
                node = earlier_node;
                earlier_node = ts_node__null();
                earlier_node_is_relevant = 0 as libc::c_int != 0;
            }
        }
    }
    return ts_node__null();
}
#[inline]
unsafe extern "C" fn ts_node__next_sibling(
    mut self_0: TSNode,
    mut include_anonymous: bool,
) -> TSNode {
    let mut target_end_byte: uint32_t = ts_node_end_byte(self_0);
    let mut node: TSNode = ts_node_parent(self_0);
    let mut later_node: TSNode = ts_node__null();
    let mut later_node_is_relevant: bool = 0 as libc::c_int != 0;
    while !ts_node_is_null(node) {
        let mut later_child: TSNode = ts_node__null();
        let mut later_child_is_relevant: bool = 0 as libc::c_int != 0;
        let mut child_containing_target: TSNode = ts_node__null();
        let mut child: TSNode = TSNode {
            context: [0; 4],
            id: 0 as *const libc::c_void,
            tree: 0 as *const TSTree,
        };
        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut node);
        while ts_node_child_iterator_next(&mut iterator, &mut child) {
            if iterator.position.bytes < target_end_byte {
                continue;
            }
            if ts_node_start_byte(child) <= ts_node_start_byte(self_0) {
                if (ts_node__subtree(child)).ptr != (ts_node__subtree(self_0)).ptr {
                    child_containing_target = child;
                }
            } else if ts_node__is_relevant(child, include_anonymous) {
                later_child = child;
                later_child_is_relevant = 1 as libc::c_int != 0;
                break;
            } else {
                if !(ts_node__relevant_child_count(child, include_anonymous)
                    > 0 as libc::c_int as libc::c_uint)
                {
                    continue;
                }
                later_child = child;
                later_child_is_relevant = 0 as libc::c_int != 0;
                break;
            }
        }
        if !ts_node_is_null(child_containing_target) {
            if !ts_node_is_null(later_child) {
                later_node = later_child;
                later_node_is_relevant = later_child_is_relevant;
            }
            node = child_containing_target;
        } else if later_child_is_relevant {
            return later_child;
        } else {
            if !ts_node_is_null(later_child) {
                node = later_child;
            } else if later_node_is_relevant {
                return later_node;
            } else {
                node = later_node;
            }
        }
    }
    return ts_node__null();
}
#[inline]
unsafe extern "C" fn ts_node__first_child_for_byte(
    mut self_0: TSNode,
    mut goal: uint32_t,
    mut include_anonymous: bool,
) -> TSNode {
    let mut node: TSNode = self_0;
    let mut did_descend: bool = 1 as libc::c_int != 0;
    let mut last_iterator: NodeChildIterator = NodeChildIterator {
        parent: 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,
            },
        },
        tree: 0 as *const TSTree,
        position: Length {
            bytes: 0,
            extent: TSPoint { row: 0, column: 0 },
        },
        child_index: 0,
        structural_child_index: 0,
        alias_sequence: 0 as *const TSSymbol,
    };
    let mut has_last_iterator: bool = 0 as libc::c_int != 0;
    while did_descend {
        did_descend = 0 as libc::c_int != 0;
        let mut child: TSNode = TSNode {
            context: [0; 4],
            id: 0 as *const libc::c_void,
            tree: 0 as *const TSTree,
        };
        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut node);
        loop {
            while ts_node_child_iterator_next(&mut iterator, &mut child) {
                if !(ts_node_end_byte(child) > goal) {
                    continue;
                }
                if ts_node__is_relevant(child, include_anonymous) {
                    return child;
                } else {
                    if !(ts_node_child_count(child) > 0 as libc::c_int as libc::c_uint) {
                        continue;
                    }
                    if iterator.child_index < ts_subtree_child_count(ts_node__subtree(child)) {
                        last_iterator = iterator;
                        has_last_iterator = 1 as libc::c_int != 0;
                    }
                    did_descend = 1 as libc::c_int != 0;
                    node = child;
                    break;
                }
            }
            if !(!did_descend && has_last_iterator as libc::c_int != 0) {
                break;
            }
            iterator = last_iterator;
            has_last_iterator = 0 as libc::c_int != 0;
        }
    }
    return ts_node__null();
}
#[inline]
unsafe extern "C" fn ts_node__descendant_for_byte_range(
    mut self_0: TSNode,
    mut range_start: uint32_t,
    mut range_end: uint32_t,
    mut include_anonymous: bool,
) -> TSNode {
    let mut node: TSNode = self_0;
    let mut last_visible_node: TSNode = self_0;
    let mut did_descend: bool = 1 as libc::c_int != 0;
    while did_descend {
        did_descend = 0 as libc::c_int != 0;
        let mut child: TSNode = TSNode {
            context: [0; 4],
            id: 0 as *const libc::c_void,
            tree: 0 as *const TSTree,
        };
        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut node);
        while ts_node_child_iterator_next(&mut iterator, &mut child) {
            let mut node_end: uint32_t = iterator.position.bytes;
            if node_end < range_end {
                continue;
            }
            let mut is_empty: bool = ts_node_start_byte(child) == node_end;
            if if is_empty as libc::c_int != 0 {
                (node_end < range_start) as libc::c_int
            } else {
                (node_end <= range_start) as libc::c_int
            } != 0
            {
                continue;
            }
            if range_start < ts_node_start_byte(child) {
                break;
            }
            node = child;
            if ts_node__is_relevant(node, include_anonymous) {
                last_visible_node = node;
            }
            did_descend = 1 as libc::c_int != 0;
            break;
        }
    }
    return last_visible_node;
}
#[inline]
unsafe extern "C" fn ts_node__descendant_for_point_range(
    mut self_0: TSNode,
    mut range_start: TSPoint,
    mut range_end: TSPoint,
    mut include_anonymous: bool,
) -> TSNode {
    let mut node: TSNode = self_0;
    let mut last_visible_node: TSNode = self_0;
    let mut did_descend: bool = 1 as libc::c_int != 0;
    while did_descend {
        did_descend = 0 as libc::c_int != 0;
        let mut child: TSNode = TSNode {
            context: [0; 4],
            id: 0 as *const libc::c_void,
            tree: 0 as *const TSTree,
        };
        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut node);
        while ts_node_child_iterator_next(&mut iterator, &mut child) {
            let mut node_end: TSPoint = iterator.position.extent;
            if point_lt(node_end, range_end) {
                continue;
            }
            let mut is_empty: bool = point_eq(ts_node_start_point(child), node_end);
            if if is_empty as libc::c_int != 0 {
                point_lt(node_end, range_start) as libc::c_int
            } else {
                point_lte(node_end, range_start) as libc::c_int
            } != 0
            {
                continue;
            }
            if point_lt(range_start, ts_node_start_point(child)) {
                break;
            }
            node = child;
            if ts_node__is_relevant(node, include_anonymous) {
                last_visible_node = node;
            }
            did_descend = 1 as libc::c_int != 0;
            break;
        }
    }
    return last_visible_node;
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_end_byte(mut self_0: TSNode) -> uint32_t {
    return (ts_node_start_byte(self_0))
        .wrapping_add((ts_subtree_size(ts_node__subtree(self_0))).bytes);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_end_point(mut self_0: TSNode) -> TSPoint {
    return point_add(
        ts_node_start_point(self_0),
        (ts_subtree_size(ts_node__subtree(self_0))).extent,
    );
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_symbol(mut self_0: TSNode) -> TSSymbol {
    let mut symbol: TSSymbol = ts_node__alias(&mut self_0) as TSSymbol;
    if symbol == 0 {
        symbol = ts_subtree_symbol(ts_node__subtree(self_0));
    }
    return ts_language_public_symbol((*self_0.tree).language, symbol);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_type(mut self_0: TSNode) -> *const libc::c_char {
    let mut symbol: TSSymbol = ts_node__alias(&mut self_0) as TSSymbol;
    if symbol == 0 {
        symbol = ts_subtree_symbol(ts_node__subtree(self_0));
    }
    return ts_language_symbol_name((*self_0.tree).language, symbol);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_language(mut self_0: TSNode) -> *const TSLanguage {
    return (*self_0.tree).language;
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_grammar_symbol(mut self_0: TSNode) -> TSSymbol {
    return ts_subtree_symbol(ts_node__subtree(self_0));
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_grammar_type(mut self_0: TSNode) -> *const libc::c_char {
    let mut symbol: TSSymbol = ts_subtree_symbol(ts_node__subtree(self_0));
    return ts_language_symbol_name((*self_0.tree).language, symbol);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_string(mut self_0: TSNode) -> *mut libc::c_char {
    let mut alias_symbol: TSSymbol = ts_node__alias(&mut self_0) as TSSymbol;
    return ts_subtree_string(
        ts_node__subtree(self_0),
        alias_symbol,
        (ts_language_symbol_metadata((*self_0.tree).language, alias_symbol)).visible,
        (*self_0.tree).language,
        0 as libc::c_int != 0,
    );
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_eq(mut self_0: TSNode, mut other: TSNode) -> bool {
    return self_0.tree == other.tree && self_0.id == other.id;
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_is_null(mut self_0: TSNode) -> bool {
    return (self_0.id).is_null();
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_is_extra(mut self_0: TSNode) -> bool {
    return ts_subtree_extra(ts_node__subtree(self_0));
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_is_named(mut self_0: TSNode) -> bool {
    let mut alias: TSSymbol = ts_node__alias(&mut self_0) as TSSymbol;
    return if alias as libc::c_int != 0 {
        (ts_language_symbol_metadata((*self_0.tree).language, alias)).named as libc::c_int
    } else {
        ts_subtree_named(ts_node__subtree(self_0)) as libc::c_int
    } != 0;
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_is_missing(mut self_0: TSNode) -> bool {
    return ts_subtree_missing(ts_node__subtree(self_0));
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_has_changes(mut self_0: TSNode) -> bool {
    return ts_subtree_has_changes(ts_node__subtree(self_0));
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_has_error(mut self_0: TSNode) -> bool {
    return ts_subtree_error_cost(ts_node__subtree(self_0)) > 0 as libc::c_int as libc::c_uint;
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_is_error(mut self_0: TSNode) -> bool {
    let mut symbol: TSSymbol = ts_node_symbol(self_0);
    return symbol as libc::c_int == -(1 as libc::c_int) as TSSymbol as libc::c_int;
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_descendant_count(mut self_0: TSNode) -> uint32_t {
    return (ts_subtree_visible_descendant_count(ts_node__subtree(self_0)))
        .wrapping_add(1 as libc::c_int as libc::c_uint);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_parse_state(mut self_0: TSNode) -> TSStateId {
    return ts_subtree_parse_state(ts_node__subtree(self_0));
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_next_parse_state(mut self_0: TSNode) -> TSStateId {
    let mut language: *const TSLanguage = (*self_0.tree).language;
    let mut state: uint16_t = ts_node_parse_state(self_0);
    if state as libc::c_int == 32767 as libc::c_int * 2 as libc::c_int + 1 as libc::c_int {
        return (32767 as libc::c_int * 2 as libc::c_int + 1 as libc::c_int) as TSStateId;
    }
    let mut symbol: uint16_t = ts_node_grammar_symbol(self_0);
    return ts_language_next_state(language, state, symbol);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_parent(mut self_0: TSNode) -> TSNode {
    let mut node: TSNode = ts_tree_root_node(self_0.tree);
    if node.id == self_0.id {
        return ts_node__null();
    }
    loop {
        let mut next_node: TSNode = ts_node_child_containing_descendant(node, self_0);
        if ts_node_is_null(next_node) {
            break;
        }
        node = next_node;
    }
    return node;
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_child_containing_descendant(
    mut self_0: TSNode,
    mut descendant: TSNode,
) -> TSNode {
    let mut start_byte: uint32_t = ts_node_start_byte(descendant);
    let mut end_byte: uint32_t = ts_node_end_byte(descendant);
    loop {
        let mut iter: NodeChildIterator = ts_node_iterate_children(&mut self_0);
        loop {
            if !ts_node_child_iterator_next(&mut iter, &mut self_0)
                || ts_node_start_byte(self_0) > start_byte
                || self_0.id == descendant.id
            {
                return ts_node__null();
            }
            let mut old: TSNode = self_0;
            while ts_node_child_iterator_next_sibling_is_empty_adjacent(&mut iter, self_0) {
                let mut current_node: TSNode =
                    ts_node_child_containing_descendant(self_0, descendant);
                if !ts_node_is_null(current_node) {
                    return current_node;
                }
                ts_node_child_iterator_next(&mut iter, &mut self_0);
                if self_0.id == descendant.id {
                    return ts_node__null();
                }
            }
            self_0 = old;
            if !(iter.position.bytes < end_byte
                || ts_node_child_count(self_0) == 0 as libc::c_int as libc::c_uint)
            {
                break;
            }
        }
        if ts_node__is_relevant(self_0, 1 as libc::c_int != 0) {
            break;
        }
    }
    return self_0;
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_child_with_descendant(
    mut self_0: TSNode,
    mut descendant: TSNode,
) -> TSNode {
    let mut start_byte: uint32_t = ts_node_start_byte(descendant);
    let mut end_byte: uint32_t = ts_node_end_byte(descendant);
    loop {
        let mut iter: NodeChildIterator = ts_node_iterate_children(&mut self_0);
        loop {
            if !ts_node_child_iterator_next(&mut iter, &mut self_0)
                || ts_node_start_byte(self_0) > start_byte
            {
                return ts_node__null();
            }
            if self_0.id == descendant.id {
                return self_0;
            }
            let mut old: TSNode = self_0;
            while ts_node_child_iterator_next_sibling_is_empty_adjacent(&mut iter, self_0) {
                let mut current_node: TSNode = ts_node_child_with_descendant(self_0, descendant);
                if !ts_node_is_null(current_node) {
                    return current_node;
                }
                ts_node_child_iterator_next(&mut iter, &mut self_0);
                if self_0.id == descendant.id {
                    return self_0;
                }
            }
            self_0 = old;
            if !(iter.position.bytes < end_byte
                || ts_node_child_count(self_0) == 0 as libc::c_int as libc::c_uint)
            {
                break;
            }
        }
        if ts_node__is_relevant(self_0, 1 as libc::c_int != 0) {
            break;
        }
    }
    return self_0;
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_child(mut self_0: TSNode, mut child_index: uint32_t) -> TSNode {
    return ts_node__child(self_0, child_index, 1 as libc::c_int != 0);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_named_child(
    mut self_0: TSNode,
    mut child_index: uint32_t,
) -> TSNode {
    return ts_node__child(self_0, child_index, 0 as libc::c_int != 0);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_child_by_field_id(
    mut self_0: TSNode,
    mut field_id: TSFieldId,
) -> TSNode {
    let mut field_map: *const TSFieldMapEntry = 0 as *const TSFieldMapEntry;
    let mut field_map_end: *const TSFieldMapEntry = 0 as *const TSFieldMapEntry;
    let mut child: TSNode = TSNode {
        context: [0; 4],
        id: 0 as *const libc::c_void,
        tree: 0 as *const TSTree,
    };
    let mut iterator: NodeChildIterator = NodeChildIterator {
        parent: 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,
            },
        },
        tree: 0 as *const TSTree,
        position: Length {
            bytes: 0,
            extent: TSPoint { row: 0, column: 0 },
        },
        child_index: 0,
        structural_child_index: 0,
        alias_sequence: 0 as *const TSSymbol,
    };
    '_recur: loop {
        if field_id == 0 || ts_node_child_count(self_0) == 0 as libc::c_int as libc::c_uint {
            return ts_node__null();
        }
        field_map = 0 as *const TSFieldMapEntry;
        field_map_end = 0 as *const TSFieldMapEntry;
        ts_language_field_map(
            (*self_0.tree).language,
            (*(ts_node__subtree(self_0)).ptr)
                .c2rust_unnamed
                .c2rust_unnamed
                .production_id as uint32_t,
            &mut field_map,
            &mut field_map_end,
        );
        if field_map == field_map_end {
            return ts_node__null();
        }
        while ((*field_map).field_id as libc::c_int) < field_id as libc::c_int {
            field_map = field_map.offset(1);
            if field_map == field_map_end {
                return ts_node__null();
            }
        }
        while (*field_map_end.offset(-(1 as libc::c_int) as isize)).field_id as libc::c_int
            > field_id as libc::c_int
        {
            field_map_end = field_map_end.offset(-1);
            if field_map == field_map_end {
                return ts_node__null();
            }
        }
        child = TSNode {
            context: [0; 4],
            id: 0 as *const libc::c_void,
            tree: 0 as *const TSTree,
        };
        iterator = ts_node_iterate_children(&mut self_0);
        loop {
            if !ts_node_child_iterator_next(&mut iterator, &mut child) {
                break '_recur;
            }
            if ts_subtree_extra(ts_node__subtree(child)) {
                continue;
            }
            let mut index: uint32_t =
                (iterator.structural_child_index).wrapping_sub(1 as libc::c_int as libc::c_uint);
            if index < (*field_map).child_index as libc::c_uint {
                continue;
            }
            if (*field_map).inherited {
                if field_map.offset(1 as libc::c_int as isize) == field_map_end {
                    self_0 = child;
                    break;
                } else {
                    let mut result: TSNode = ts_node_child_by_field_id(child, field_id);
                    if !(result.id).is_null() {
                        return result;
                    }
                    field_map = field_map.offset(1);
                    if field_map == field_map_end {
                        return ts_node__null();
                    }
                }
            } else if ts_node__is_relevant(child, 1 as libc::c_int != 0) {
                return child;
            } else {
                if ts_node_child_count(child) > 0 as libc::c_int as libc::c_uint {
                    return ts_node_child(child, 0 as libc::c_int as uint32_t);
                } else {
                    field_map = field_map.offset(1);
                    if field_map == field_map_end {
                        return ts_node__null();
                    }
                }
            }
        }
    }
    return ts_node__null();
}
#[inline]
unsafe extern "C" fn ts_node__field_name_from_language(
    mut self_0: TSNode,
    mut structural_child_index: uint32_t,
) -> *const libc::c_char {
    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(
        (*self_0.tree).language,
        (*(ts_node__subtree(self_0)).ptr)
            .c2rust_unnamed
            .c2rust_unnamed
            .production_id as uint32_t,
        &mut field_map,
        &mut field_map_end,
    );
    while field_map != field_map_end {
        if !(*field_map).inherited
            && (*field_map).child_index as libc::c_uint == structural_child_index
        {
            return *((*(*self_0.tree).language).field_names)
                .offset((*field_map).field_id as isize);
        }
        field_map = field_map.offset(1);
    }
    return 0 as *const libc::c_char;
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_field_name_for_child(
    mut self_0: TSNode,
    mut child_index: uint32_t,
) -> *const libc::c_char {
    let mut result: TSNode = self_0;
    let mut did_descend: bool = 1 as libc::c_int != 0;
    let mut inherited_field_name: *const libc::c_char = 0 as *const libc::c_char;
    while did_descend {
        did_descend = 0 as libc::c_int != 0;
        let mut child: TSNode = TSNode {
            context: [0; 4],
            id: 0 as *const libc::c_void,
            tree: 0 as *const TSTree,
        };
        let mut index: uint32_t = 0 as libc::c_int as uint32_t;
        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut result);
        while ts_node_child_iterator_next(&mut iterator, &mut child) {
            if ts_node__is_relevant(child, 1 as libc::c_int != 0) {
                if index == child_index {
                    if ts_node_is_extra(child) {
                        return 0 as *const libc::c_char;
                    }
                    let mut field_name: *const libc::c_char = ts_node__field_name_from_language(
                        result,
                        (iterator.structural_child_index)
                            .wrapping_sub(1 as libc::c_int as libc::c_uint),
                    );
                    if !field_name.is_null() {
                        return field_name;
                    }
                    return inherited_field_name;
                }
                index = index.wrapping_add(1);
            } else {
                let mut grandchild_index: uint32_t = child_index.wrapping_sub(index);
                let mut grandchild_count: uint32_t =
                    ts_node__relevant_child_count(child, 1 as libc::c_int != 0);
                if grandchild_index < grandchild_count {
                    let mut field_name_0: *const libc::c_char = ts_node__field_name_from_language(
                        result,
                        (iterator.structural_child_index)
                            .wrapping_sub(1 as libc::c_int as libc::c_uint),
                    );
                    if !field_name_0.is_null() {
                        inherited_field_name = field_name_0;
                    }
                    did_descend = 1 as libc::c_int != 0;
                    result = child;
                    child_index = grandchild_index;
                    break;
                } else {
                    index = (index as libc::c_uint).wrapping_add(grandchild_count) as uint32_t
                        as uint32_t;
                }
            }
        }
    }
    return 0 as *const libc::c_char;
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_field_name_for_named_child(
    mut self_0: TSNode,
    mut named_child_index: uint32_t,
) -> *const libc::c_char {
    let mut result: TSNode = self_0;
    let mut did_descend: bool = 1 as libc::c_int != 0;
    let mut inherited_field_name: *const libc::c_char = 0 as *const libc::c_char;
    while did_descend {
        did_descend = 0 as libc::c_int != 0;
        let mut child: TSNode = TSNode {
            context: [0; 4],
            id: 0 as *const libc::c_void,
            tree: 0 as *const TSTree,
        };
        let mut index: uint32_t = 0 as libc::c_int as uint32_t;
        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut result);
        while ts_node_child_iterator_next(&mut iterator, &mut child) {
            if ts_node__is_relevant(child, 0 as libc::c_int != 0) {
                if index == named_child_index {
                    if ts_node_is_extra(child) {
                        return 0 as *const libc::c_char;
                    }
                    let mut field_name: *const libc::c_char = ts_node__field_name_from_language(
                        result,
                        (iterator.structural_child_index)
                            .wrapping_sub(1 as libc::c_int as libc::c_uint),
                    );
                    if !field_name.is_null() {
                        return field_name;
                    }
                    return inherited_field_name;
                }
                index = index.wrapping_add(1);
            } else {
                let mut named_grandchild_index: uint32_t = named_child_index.wrapping_sub(index);
                let mut grandchild_count: uint32_t =
                    ts_node__relevant_child_count(child, 0 as libc::c_int != 0);
                if named_grandchild_index < grandchild_count {
                    let mut field_name_0: *const libc::c_char = ts_node__field_name_from_language(
                        result,
                        (iterator.structural_child_index)
                            .wrapping_sub(1 as libc::c_int as libc::c_uint),
                    );
                    if !field_name_0.is_null() {
                        inherited_field_name = field_name_0;
                    }
                    did_descend = 1 as libc::c_int != 0;
                    result = child;
                    named_child_index = named_grandchild_index;
                    break;
                } else {
                    index = (index as libc::c_uint).wrapping_add(grandchild_count) as uint32_t
                        as uint32_t;
                }
            }
        }
    }
    return 0 as *const libc::c_char;
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_child_by_field_name(
    mut self_0: TSNode,
    mut name: *const libc::c_char,
    mut name_length: uint32_t,
) -> TSNode {
    let mut field_id: TSFieldId =
        ts_language_field_id_for_name((*self_0.tree).language, name, name_length);
    return ts_node_child_by_field_id(self_0, field_id);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_child_count(mut self_0: TSNode) -> uint32_t {
    let mut tree: Subtree = ts_node__subtree(self_0);
    if ts_subtree_child_count(tree) > 0 as libc::c_int as libc::c_uint {
        return (*tree.ptr)
            .c2rust_unnamed
            .c2rust_unnamed
            .visible_child_count;
    } else {
        return 0 as libc::c_int as uint32_t;
    };
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_named_child_count(mut self_0: TSNode) -> uint32_t {
    let mut tree: Subtree = ts_node__subtree(self_0);
    if ts_subtree_child_count(tree) > 0 as libc::c_int as libc::c_uint {
        return (*tree.ptr).c2rust_unnamed.c2rust_unnamed.named_child_count;
    } else {
        return 0 as libc::c_int as uint32_t;
    };
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_next_sibling(mut self_0: TSNode) -> TSNode {
    return ts_node__next_sibling(self_0, 1 as libc::c_int != 0);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_next_named_sibling(mut self_0: TSNode) -> TSNode {
    return ts_node__next_sibling(self_0, 0 as libc::c_int != 0);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_prev_sibling(mut self_0: TSNode) -> TSNode {
    return ts_node__prev_sibling(self_0, 1 as libc::c_int != 0);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_prev_named_sibling(mut self_0: TSNode) -> TSNode {
    return ts_node__prev_sibling(self_0, 0 as libc::c_int != 0);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_first_child_for_byte(
    mut self_0: TSNode,
    mut byte: uint32_t,
) -> TSNode {
    return ts_node__first_child_for_byte(self_0, byte, 1 as libc::c_int != 0);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_first_named_child_for_byte(
    mut self_0: TSNode,
    mut byte: uint32_t,
) -> TSNode {
    return ts_node__first_child_for_byte(self_0, byte, 0 as libc::c_int != 0);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_descendant_for_byte_range(
    mut self_0: TSNode,
    mut start: uint32_t,
    mut end: uint32_t,
) -> TSNode {
    return ts_node__descendant_for_byte_range(self_0, start, end, 1 as libc::c_int != 0);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_named_descendant_for_byte_range(
    mut self_0: TSNode,
    mut start: uint32_t,
    mut end: uint32_t,
) -> TSNode {
    return ts_node__descendant_for_byte_range(self_0, start, end, 0 as libc::c_int != 0);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_descendant_for_point_range(
    mut self_0: TSNode,
    mut start: TSPoint,
    mut end: TSPoint,
) -> TSNode {
    return ts_node__descendant_for_point_range(self_0, start, end, 1 as libc::c_int != 0);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_named_descendant_for_point_range(
    mut self_0: TSNode,
    mut start: TSPoint,
    mut end: TSPoint,
) -> TSNode {
    return ts_node__descendant_for_point_range(self_0, start, end, 0 as libc::c_int != 0);
}
#[no_mangle]
pub unsafe extern "C" fn ts_node_edit(mut self_0: *mut TSNode, mut edit: *const TSInputEdit) {
    let mut start_byte: uint32_t = ts_node_start_byte(*self_0);
    let mut start_point: TSPoint = ts_node_start_point(*self_0);
    if start_byte >= (*edit).old_end_byte {
        start_byte =
            ((*edit).new_end_byte).wrapping_add(start_byte.wrapping_sub((*edit).old_end_byte));
        start_point = point_add(
            (*edit).new_end_point,
            point_sub(start_point, (*edit).old_end_point),
        );
    } else if start_byte > (*edit).start_byte {
        start_byte = (*edit).new_end_byte;
        start_point = (*edit).new_end_point;
    }
    (*self_0).context[0 as libc::c_int as usize] = start_byte;
    (*self_0).context[1 as libc::c_int as usize] = start_point.row;
    (*self_0).context[2 as libc::c_int as usize] = start_point.column;
}