vortex-jit 0.4.1

Rust bindings for the VORTEX JIT compiler — a profile-guided optimizing JIT with input-shape-keyed profiles, phase partitioning, ensemble aggregation, T1 code persistence, and append-only crash-safe profile patching.
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
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
/* automatically generated by rust-bindgen 0.69.5 */

#[repr(C)]
#[derive(Default)]
pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
impl<T> __IncompleteArrayField<T> {
    #[inline]
    pub const fn new() -> Self {
        __IncompleteArrayField(::std::marker::PhantomData, [])
    }
    #[inline]
    pub fn as_ptr(&self) -> *const T {
        self as *const _ as *const T
    }
    #[inline]
    pub fn as_mut_ptr(&mut self) -> *mut T {
        self as *mut _ as *mut T
    }
    #[inline]
    pub unsafe fn as_slice(&self, len: usize) -> &[T] {
        ::std::slice::from_raw_parts(self.as_ptr(), len)
    }
    #[inline]
    pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
        ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
    }
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        fmt.write_str("__IncompleteArrayField")
    }
}
pub const VORTEX_CACHE_MAX_SIZE: u32 = 268435456;
pub const VORTEX_T1_THRESHOLD: u32 = 1000;
pub const VORTEX_T2_THRESHOLD: u32 = 10000;
pub const VORTEX_COMPILE_THREADS: u32 = 0;
pub const VORTEX_T3_THRESHOLD: u32 = 100000;
pub const VTX_TAG_BITS: u32 = 3;
pub const VTX_TAG_MASK: u32 = 7;
pub const VTX_SMI_MAX: u64 = 70368744177663;
pub const VTX_SMI_MIN: i64 = -70368744177664;
pub const VTX_POLY_LIMIT: u32 = 4;
pub const VTX_MAX_TRACE_LENGTH: u32 = 1048576;
pub const VTX_MAX_TREE_DEPTH: u32 = 64;
pub const VTX_MAX_HYPERBLOCK_NODES: u32 = 4194304;
pub const VTX_MAX_NATIVE_SIZE: u32 = 268435456;
pub const VTX_CACHE_SEGMENT_SIZE: u32 = 1048576;
pub const VTX_ARENA_PAGE_SIZE: u32 = 65536;
pub const VTX_FRAME_ALIGNMENT: u32 = 16;
pub const VTX_INLINE_THRESHOLD: f64 = 0.6;
pub const VTX_INLINE_SIZE_LIMIT: u32 = 4096;
pub const VTX_INLINE_DEPTH_CHAIN: u32 = 16;
pub const VTX_INLINE_BUDGET_CHAIN: u32 = 16384;
pub const VTX_GUARD_ALPHA: f64 = 0.1;
pub const VTX_GUARD_WEAKEN_THRESHOLD: f64 = 0.01;
pub const VTX_GUARD_ABANDON_THRESHOLD: f64 = 0.25;
pub const VTX_VALUE_STABILITY_THRESHOLD: f64 = 0.95;
pub const VTX_VALUE_MIN_OBSERVATIONS: u32 = 100;
pub const VTX_VALUE_SAMPLE_INTERVAL_DEFAULT: u32 = 64;
pub const VTX_VALUE_SAMPLE_INTERVAL_STABLE: u32 = 256;
pub const VTX_VALUE_SAMPLE_INTERVAL_UNSTABLE: u32 = 16;
pub const VTX_NULL_PAGE_LIMIT: u32 = 65536;
pub const VTX_PROFILE_DIVERGENCE_THRESHOLD: f64 = 0.5;
pub const VTX_SIDE_EXIT_THRESHOLD: u32 = 5;
pub const VTX_STITCH_THRESHOLD: u32 = 10;
pub const VTX_LOOP_CV_THRESHOLD: f64 = 0.8;
pub const VTX_SPILL_THRESHOLD: f64 = 0.1;
pub const VTX_INLINE_DEOPT_THRESHOLD: f64 = 0.05;
pub const VTX_PHASE_MIN_METHODS: u32 = 3;
pub const VTX_PHASE_MIN_FREQUENCY: u32 = 1000;
pub const VTX_CONFIDENCE_THRESHOLD_BRANCH: u32 = 100;
pub const VTX_CONFIDENCE_THRESHOLD_CALL_TARGET: u32 = 50;
pub const VTX_CONFIDENCE_THRESHOLD_TYPE_DIST: u32 = 200;
pub const VTX_CONFIDENCE_THRESHOLD_LOOP_TRIP: u32 = 50;
pub const VTX_CONFIDENCE_THRESHOLD_FIELD_SHAPE: u32 = 100;
pub const VTX_PROMOTION_CONFIDENCE_T2: f64 = 0.5;
pub const VTX_PROMOTION_CONFIDENCE_T3: f64 = 0.75;
pub const VTX_PROMOTION_CONFIDENCE_T4: f64 = 0.9;
pub const VTX_RECOMP_HYSTERESIS_CONSECUTIVE: u32 = 3;
pub const VTX_RECOMP_QUEUE_SOFT_CAP: u32 = 64;
pub const VTX_RECOMP_QUEUE_HARD_CAP: u32 = 256;
pub const VTX_RECOMP_COALESCE_WINDOW_SEC: u32 = 1;
pub const VTX_RECOMP_COALESCE_MAX_DUPLICATES: u32 = 5;
pub const VTX_LRU_UPDATE_INTERVAL: u32 = 100;
pub const VTX_BENCH_WARMUP: u32 = 100;
pub const VTX_BENCH_ITERATIONS: u32 = 1000000;
pub const VTX_FEEDBACK_WINDOW: u32 = 10000;
pub const VTX_PROFILE_TYPE_BUFFER_SIZE: u32 = 32;
pub const VTX_GVN_MAX_ITERATIONS: u32 = 100;
pub const VTX_PIPELINE_MAX_ITERATIONS: u32 = 20;
pub const VTX_MAX_FIELDS_PER_OBJ: u32 = 256;
pub const VTX_TAG_SMI: u32 = 0;
pub const VTX_TAG_HEAP_PTR: u32 = 1;
pub const VTX_TAG_DOUBLE: u32 = 2;
pub const VTX_TAG_BOOL: u32 = 3;
pub const VTX_TAG_NULL: u32 = 4;
pub const VTX_TAG_UNDEFINED: u32 = 5;
pub const VTX_NAN_BOX_HEADER: u64 = 9221120237041090560;
pub const VTX_NAN_DATA_SHIFT: u32 = 3;
pub const VTX_NAN_DATA_MASK: u64 = 281474976710655;
pub const VTX_TYPE_INVALID: u32 = 0;
pub const VTX_TYPE_OBJECT: u32 = 1;
pub const VTX_TYPE_SMI: u32 = 2;
pub const VTX_SHAPE_INVALID: u32 = 0;
pub const VTX_SHAPE_OBJECT: u32 = 1;
pub const VTX_SYMBOL_TABLE_INITIAL_CAPACITY: u32 = 256;
pub const VTX_SYMBOL_INVALID: u32 = 4294967295;
pub const VTX_TYPE_SYSTEM_INITIAL_CAPACITY: u32 = 64;
pub const VTX_GC_YOUNG_SIZE: u32 = 4194304;
pub const VTX_GC_OLD_SIZE: u32 = 67108864;
pub const VTX_GC_PROMOTION_AGE: u32 = 3;
pub const VTX_GC_ROOT_STACK_SIZE: u32 = 4096;
pub const VTX_GC_REMEMBERED_SET_INIT: u32 = 256;
pub const VTX_CARD_SIZE: u32 = 512;
pub const VTX_CARD_SHIFT: u32 = 9;
pub const VTX_CARD_CLEAN: u32 = 0;
pub const VTX_CARD_DIRTY: u32 = 1;
pub const VTX_CALL_ARG_REGS: u32 = 6;
pub const VTX_SAFEOINT_MAX_THREADS: u32 = 256;
pub const VTX_FRAME_STACK_BLOCK_SIZE: u32 = 262144;
pub const VTX_FRAME_MAX_STACK_DEPTH: u32 = 1024;
pub const VTX_FRAME_MAX_LOCALS: u32 = 1024;
pub const VTX_CATCH_NONE: u32 = 4294967295;
pub const VTX_TIER_UP_INITIAL_COUNT: u32 = 10000;
pub const VTX_PROFILER_LRU_SIZE: u32 = 8;
pub const VTX_TYPE_FEEDBACK_BUFFER_SIZE: u32 = 32;
pub const VTX_TYPE_FREQ_MAX_SLOTS: u32 = 8;
pub const VTX_TYPE_SIGNATURE_MAX_SLOTS: u32 = 8;
pub const VTX_TYPE_STABILITY_WINDOW: u32 = 1000;
pub const VTX_SHAPE_STABILITY_WINDOW: u32 = 500;
pub const VTX_PQ_INITIAL_CAPACITY: u32 = 64;
pub const VTX_COMPILE_PRIORITY_LOW: u32 = 100;
pub const VTX_COMPILE_PRIORITY_NORMAL: u32 = 1000;
pub const VTX_COMPILE_PRIORITY_HIGH: u32 = 5000;
pub const VTX_MARKOV_MAX_PHASES: u32 = 16;
pub const VTX_MARKOV_MAX_METHODS: u32 = 256;
pub const VTX_FRAME_CALLER_RBP_OFFSET: u32 = 0;
pub const VTX_FRAME_PROFILE_DATA_OFFSET: u32 = 8;
pub const VTX_FRAME_DEOPT_INFO_OFFSET: u32 = 16;
pub const VTX_FRAME_METHOD_PTR_OFFSET: u32 = 24;
pub const VTX_FRAME_RETURN_ADDR_OFFSET: u32 = 32;
pub const VTX_FRAME_SAVED_RBX_OFFSET: i32 = -8;
pub const VTX_FRAME_SAVED_R12_OFFSET: i32 = -16;
pub const VTX_FRAME_SAVED_REGS_COUNT: u32 = 2;
pub const VTX_FRAME_SAVED_REGS_SIZE: u32 = 16;
pub const VTX_FRAME_HEADER_SLOTS_ABOVE: u32 = 4;
pub const VTX_EXPR_REG_COUNT: u32 = 4;
pub const VTX_GUARDS_INITIAL_CAPACITY: u32 = 32;
pub const VTX_NODE_INITIAL_INPUT_CAPACITY: u32 = 4;
pub const VTX_NODE_INITIAL_USE_CAPACITY: u32 = 4;
pub const VTX_NODE_TABLE_INITIAL_CAPACITY: u32 = 256;
pub const VTX_DEOPT_NO_HANDLER: u32 = 4294967295;
pub const VTX_STF_CALL_SITE: u32 = 1;
pub const VTX_STF_GUARD: u32 = 2;
pub const VTX_STF_SAFEPPOINT: u32 = 4;
pub const VTX_STF_ALLOCATION: u32 = 8;
pub const VTX_STF_OSR_ENTRY: u32 = 16;
pub const VTX_SIDE_TABLE_INITIAL_CAPACITY: u32 = 64;
pub const VTX_DEOPT_STUBS_INITIAL_CAPACITY: u32 = 32;
pub const VTX_RELOC_INITIAL_CAPACITY: u32 = 64;
pub const VTX_METHOD_REGISTRY_INITIAL_CAPACITY: u32 = 256;
pub const VTX_TYPEID_MEGAMORPHIC: u32 = 4294967294;
pub const VTX_PROFILE_INITIAL_METHOD_CAPACITY: u32 = 256;
pub const VTX_PROFILE_INITIAL_EDGE_CAPACITY: u32 = 512;
pub const VTX_TRIP_STABILITY_WINDOW: u32 = 500;
pub const VTX_PHASE_NONE: u32 = 4294967295;
pub const VTX_PHASE_PARTITION_INITIAL_CAPACITY: u32 = 16;
pub const VTX_INLINE_FEATURE_COUNT: u32 = 15;
pub const VTX_FEEDBACK_INITIAL_CAPACITY: u32 = 256;
pub const VTX_DEOPTLESS_MAX_VERSIONS: u32 = 8;
pub const VTX_PHASE_MATCH_THRESHOLD: f64 = 0.5;
pub const VTX_PHASE_SIGNATURE_SIZE: u32 = 10;
pub const VTX_VERSION_INITIAL_CAPACITY: u32 = 256;
pub const VTX_FDI_INITIAL_CAPACITY: u32 = 64;
pub const VTX_PHASE_REACT_MAX_PARKED: u32 = 16;
pub const VTX_PHASE_HASH_NONE: u32 = 0;
pub const VTX_PHASE_REACT_INITIAL_CAPACITY: u32 = 256;
pub const VTX_PHASE_REACT_DEFAULT_CODE_BUDGET: u32 = 8388608;
pub const VTX_ORCHESTRATOR_CHECK_INTERVAL_MS: u32 = 100;
pub const VTX_ORCHESTRATOR_MIN_PROFILE_OBS: u32 = 100;
pub const VTX_ORCHESTRATOR_PROACTIVE_COMPILE_LIMIT: u32 = 8;
pub const VTX_SPEC_VERSION_MAX: u32 = 64;
pub const VTX_SPEC_VERSION_MAX_ARGS: u32 = 4;
pub const VTX_SPEC_VERSION_FREQUENCY_THRESHOLD: f64 = 0.1;
pub const VTX_SPEC_VERSION_MIN_OBSERVATIONS: u32 = 500;
pub const VTX_SPEC_VERSION_STABILITY_THRESHOLD: f64 = 0.9;
pub const VTX_LOOP_VERSION_MAX: u32 = 8;
pub const VTX_LOOP_VERSION_MIN_TRIP_COUNT: u32 = 100;
pub const VTX_LOOP_VERSION_FREQUENCY_THRESHOLD: f64 = 0.7;
pub const VTX_LOOP_VERSION_MIN_OBSERVATIONS: u32 = 200;
pub const VTX_SPEC_VERSION_INITIAL_CAPACITY: u32 = 256;
pub const VTX_LOOP_VERSION_INITIAL_CAPACITY: u32 = 4;
pub const VTX_DEOPT_SITE_WINDOW_NS: u32 = 1000000000;
pub const VTX_DEOPT_SITE_FAIL_THRESHOLD: u32 = 100;
pub const VTX_DEOPT_BATCH_WINDOW_NS: u32 = 1000000;
pub const VTX_DEOPT_BATCH_MAX_PENDING: u32 = 64;
pub const VTX_DEOPT_GLOBAL_WINDOW_NS: u32 = 1000000000;
pub const VTX_DEOPT_GLOBAL_FAIL_THRESHOLD: u32 = 10000;
pub const VTX_DEOPT_COORD_MAX_SITES: u32 = 4096;
pub const VTX_VERSIONED_CACHE_MAX_METHODS: u32 = 4096;
pub const VTX_VERSIONED_CACHE_MAX_RETIRED: u32 = 8;
pub const VTX_CODE_BUFFER_INITIAL_CAPACITY: u32 = 4096;
pub const VTX_POLY_IC_SIZE: u32 = 4;
pub const VTX_POLY_IC_TYPE_IDS_OFFSET: u32 = 0;
pub const VTX_POLY_IC_TARGETS_OFFSET: u32 = 16;
pub const VTX_POLY_IC_COUNT_OFFSET: u32 = 48;
pub const VTX_POLY_IC_ENTRY_SIZE_TYPE: u32 = 4;
pub const VTX_POLY_IC_ENTRY_SIZE_TARGET: u32 = 8;
pub const VTX_DEP_SET_INITIAL_CAPACITY: u32 = 8;
pub const VTX_INVERTED_INDEX_CAPACITY: u32 = 256;
pub const VTX_GUARD_DEP_INITIAL_CAPACITY: u32 = 16;
pub const VTX_PROFILE_MAGIC: u32 = 1448038996;
pub const VTX_PROFILE_VERSION: u32 = 2;
pub const VTX_PROFILE_HASH_SIZE: u32 = 32;
pub const VTX_T1_CACHE_MAGIC: u32 = 1448039473;
pub const VTX_T1_CACHE_VERSION: u32 = 1;
pub const VTX_T1_CACHE_MAX_METHODS: u32 = 4096;
pub const VTX_T1_CACHE_MAX_CODE_SIZE: u32 = 16777216;
pub const VTX_GBDT_MAX_TREES: u32 = 100;
pub const VTX_GBDT_MAX_DEPTH: u32 = 5;
pub const VTX_GBDT_DEFAULT_TREE_COUNT: u32 = 30;
pub const VTX_GBDT_DEFAULT_DEPTH: u32 = 3;
pub const VTX_GBDT_LEAF_MARKER: u32 = 65535;
pub const VTX_GBDT_MAX_NODES_PER_TREE: u32 = 64;
pub const VTX_GBDT_MAX_TOTAL_NODES: u32 = 6400;
pub const VTX_MAX_CHAIN_DEPTH: u32 = 4;
pub const VTX_CHAIN_INLINE_BUDGET: u32 = 1024;
pub const VTX_CPU_SSE2: u32 = 1;
pub const VTX_CPU_AVX2: u32 = 2;
pub const VTX_CPU_AVX512: u32 = 4;
pub const VTX_VREG_COUNT_INITIAL: u32 = 256;
pub const VTX_VREG_FLAG_NONE: u32 = 0;
pub const VTX_VREG_FLAG_FIXED: u32 = 1;
pub const VTX_VREG_FLAG_XMM: u32 = 2;
pub const VTX_INST_MAX_OPERANDS: u32 = 3;
pub const VTX_INST_FLAG_NONE: u32 = 0;
pub const VTX_INST_FLAG_HAS_IMM: u32 = 1;
pub const VTX_INST_FLAG_HAS_MEM: u32 = 2;
pub const VTX_INST_FLAG_HAS_COND: u32 = 4;
pub const VTX_INST_FLAG_CLOBBER_RAX: u32 = 8;
pub const VTX_INST_FLAG_CLOBBER_RDX: u32 = 16;
pub const VTX_INST_FLAG_CLOBBER_RCX: u32 = 32;
pub const VTX_INST_FLAG_IS_CALL: u32 = 64;
pub const VTX_INST_FLAG_IS_GUARD: u32 = 128;
pub const VTX_INST_FLAG_IS_DEOPT: u32 = 256;
pub const VTX_INST_FLAG_IS_BRANCH: u32 = 512;
pub const VTX_INST_FLAG_CLOBBER_RSI: u32 = 1024;
pub const VTX_INST_FLAG_CLOBBER_RDI: u32 = 2048;
pub const VTX_INST_FLAG_CLOBBER_R8: u32 = 4096;
pub const VTX_INST_FLAG_CLOBBER_R9: u32 = 8192;
pub const VTX_INST_FLAG_CLOBBER_R10: u32 = 16384;
pub const VTX_INST_FLAG_CLOBBER_R11: u32 = 32768;
pub const VTX_INST_FLAG_PHI_COPY: u32 = 65536;
pub const VTX_INST_FLAG_SPILL_LOAD: u32 = 131072;
pub const VTX_INST_FLAG_SPILL_STORE: u32 = 262144;
pub const VTX_INST_FLAG_FUSED: u32 = 524288;
pub const VTX_INST_FLAG_IS_SSE: u32 = 1048576;
pub const VTX_INST_FLAG_IS_SAFEPOINT: u32 = 2097152;
pub const VTX_INST_FLAG_IMPLICIT_NULL: u32 = 4194304;
pub const VTX_INST_FLAG_VALUE_GUARD: u32 = 8388608;
pub const VTX_INST_FLAG_NO_TEST: u32 = 16777216;
pub const VTX_INST_FLAG_NO_COALESCE: u32 = 33554432;
pub const VTX_INST_FLAG_TARGET_SET: u32 = 67108864;
pub const VTX_INST_BLOCK_INITIAL_CAPACITY: u32 = 64;
pub const VTX_PHYS_REG_COUNT: u32 = 14;
pub const VTX_CALLER_SAVED_COUNT: u32 = 9;
pub const VTX_CALLEE_SAVED_COUNT: u32 = 5;
pub const VTX_REG_RESERVED_MASK: u32 = 15408;
pub const VTX_CALLER_SAVED_MASK: u32 = 4039;
pub const VTX_CALLEE_SAVED_MASK: u32 = 61448;
pub const VTX_XMM_COUNT: u32 = 16;
pub const VTX_XMM0: u32 = 0;
pub const VTX_XMM1: u32 = 1;
pub const VTX_XMM2: u32 = 2;
pub const VTX_XMM3: u32 = 3;
pub const VTX_XMM4: u32 = 4;
pub const VTX_XMM5: u32 = 5;
pub const VTX_XMM6: u32 = 6;
pub const VTX_XMM7: u32 = 7;
pub const VTX_XMM8: u32 = 8;
pub const VTX_XMM9: u32 = 9;
pub const VTX_XMM10: u32 = 10;
pub const VTX_XMM11: u32 = 11;
pub const VTX_XMM12: u32 = 12;
pub const VTX_XMM13: u32 = 13;
pub const VTX_XMM14: u32 = 14;
pub const VTX_XMM15: u32 = 15;
pub const VTX_XMM_RESERVED_MASK: u32 = 49152;
pub const VTX_XMM_ALL_MASK: u32 = 65535;
pub const VTX_XMM_ALLOCATABLE_MASK: u32 = 16383;
pub const VTX_EMIT_INITIAL_CAPACITY: u32 = 4096;
pub const VTX_GUARD_DESC_INITIAL_CAPACITY: u32 = 32;
pub const VTX_ENSEMBLE_MAX_RUNS: u32 = 5;
pub const VTX_ENSEMBLE_MIN_RUNS: u32 = 2;
pub const VTX_ENSEMBLE_MIN_SAMPLES: u32 = 1000;
pub const VTX_ENSEMBLE_MIN_DURATION_S: f64 = 1.0;
pub const VTX_ENSEMBLE_QUALITY_THRESHOLD: f64 = 0.3;
pub const VTX_ENSEMBLE_VALIDATION_WINDOW_S: u32 = 30;
pub const VTX_ENSEMBLE_ROLLBACK_DEOPT_RATE: f64 = 0.1;
pub const VTX_INPUT_SHAPE_DEFAULT: u32 = 0;
pub const VTX_INPUT_SHAPE_VERSION: u32 = 1;
pub const VTX_INPUT_SHAPE_MAX_PER_METHOD: u32 = 8;
pub const VTX_INPUT_SHAPE_MIN_SAMPLES_FOR_MULTI_VERSION: u32 = 100;
pub const VTX_SHAPE_DISPATCH_MAX_VERSIONS: u32 = 8;
pub const VTX_PATCH_LOG_MAGIC: u32 = 1448103756;
pub const VTX_PATCH_LOG_VERSION: u32 = 1;
pub const VTX_PATCH_LOG_MAX_PAYLOAD: u32 = 65536;
pub const VTX_PATCH_LOG_COMPACTION_THRESHOLD: u32 = 1000;
#[repr(C)]
#[derive(Copy, Clone)]
pub union __atomic_wide_counter {
    pub __value64: ::std::os::raw::c_ulonglong,
    pub __value32: __atomic_wide_counter__bindgen_ty_1,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct __atomic_wide_counter__bindgen_ty_1 {
    pub __low: ::std::os::raw::c_uint,
    pub __high: ::std::os::raw::c_uint,
}
impl Default for __atomic_wide_counter {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __pthread_internal_list {
    pub __prev: *mut __pthread_internal_list,
    pub __next: *mut __pthread_internal_list,
}
impl Default for __pthread_internal_list {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
pub type __pthread_list_t = __pthread_internal_list;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __pthread_mutex_s {
    pub __lock: ::std::os::raw::c_int,
    pub __count: ::std::os::raw::c_uint,
    pub __owner: ::std::os::raw::c_int,
    pub __nusers: ::std::os::raw::c_uint,
    pub __kind: ::std::os::raw::c_int,
    pub __spins: ::std::os::raw::c_short,
    pub __elision: ::std::os::raw::c_short,
    pub __list: __pthread_list_t,
}
impl Default for __pthread_mutex_s {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct __pthread_cond_s {
    pub __wseq: __atomic_wide_counter,
    pub __g1_start: __atomic_wide_counter,
    pub __g_size: [::std::os::raw::c_uint; 2usize],
    pub __g1_orig_size: ::std::os::raw::c_uint,
    pub __wrefs: ::std::os::raw::c_uint,
    pub __g_signals: [::std::os::raw::c_uint; 2usize],
    pub __unused_initialized_1: ::std::os::raw::c_uint,
    pub __unused_initialized_2: ::std::os::raw::c_uint,
}
impl Default for __pthread_cond_s {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
pub type pthread_t = ::std::os::raw::c_ulong;
#[repr(C)]
#[derive(Copy, Clone)]
pub union pthread_mutex_t {
    pub __data: __pthread_mutex_s,
    pub __size: [::std::os::raw::c_char; 40usize],
    pub __align: ::std::os::raw::c_long,
}
impl Default for pthread_mutex_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union pthread_cond_t {
    pub __data: __pthread_cond_s,
    pub __size: [::std::os::raw::c_char; 48usize],
    pub __align: ::std::os::raw::c_longlong,
}
impl Default for pthread_cond_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " VORTEX Arena Allocator\n\n Region-based allocator used throughout the compiler pipeline.\n Each compilation gets its own arena; when compilation finishes,\n the entire arena is freed. No individual free — only wholesale reset.\n\n Pages are allocated via mmap and tracked in a singly-linked list.\n Allocations are 16-byte aligned within each page."]
pub type vtx_arena_page_t = vtx_arena_page;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_arena_page {
    pub next: *mut vtx_arena_page_t,
    pub size: usize,
    pub used: usize,
}
impl Default for vtx_arena_page {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_arena_t {
    pub first_page: *mut vtx_arena_page_t,
    pub current_page: *mut vtx_arena_page_t,
    pub total_allocated: usize,
}
impl Default for vtx_arena_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize an arena with its initial 64KB page.\n Returns 0 on success, -1 on failure (mmap error)."]
    pub fn vtx_arena_init(arena: *mut vtx_arena_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Allocate `size` bytes from the arena with 16-byte alignment.\n If the current page doesn't have enough space, a new 64KB page\n (or larger if size requires it) is allocated via mmap.\n Returns a valid pointer on success, NULL on failure."]
    pub fn vtx_arena_alloc(arena: *mut vtx_arena_t, size: usize) -> *mut ::std::os::raw::c_void;
}
extern "C" {
    #[doc = " Reset the arena: free all pages except the first, and reset\n the allocation position within the first page to the beginning."]
    pub fn vtx_arena_reset(arena: *mut vtx_arena_t);
}
extern "C" {
    #[doc = " Destroy the arena: munmap all pages and zero out the struct."]
    pub fn vtx_arena_destroy(arena: *mut vtx_arena_t);
}
extern "C" {
    #[doc = " Return total number of bytes currently allocated from this arena."]
    pub fn vtx_arena_total_allocated(arena: *const vtx_arena_t) -> usize;
}
pub type vtx_value_t = u64;
#[doc = " Heap object layout:\n\n   +-------------------+\n   | type_id   (4)     |  Type descriptor index\n   | gc_mark   (1)     |  GC mark bit\n   | gc_age    (1)     |  Number of young-gen collections survived\n   | gc_pinned (1)     |  1 if pinned (cannot be moved by GC)\n   | gc_remembered (1) |  1 if in old gen remembered set\n   | size      (4)     |  Total size in bytes including this header\n   | shape_id  (4)     |  Shape/layout fingerprint\n   | field_count (4)   |  Number of fields following this header\n   +-------------------+\n   | fields[0]  (8)    |  Field 0 (tagged value)\n   | fields[1]  (8)    |  Field 1\n   | ...               |\n   +-------------------+\n\n The header is padded to 8-byte alignment. Fields are vtx_value_t (8 bytes each)."]
#[repr(C)]
#[derive(Debug, Default)]
pub struct vtx_heap_object_t {
    pub type_id: u32,
    pub gc_mark: u8,
    pub gc_age: u8,
    pub gc_pinned: u8,
    pub gc_remembered: u8,
    pub size: u32,
    pub shape_id: u32,
    pub field_count: u32,
    pub fields: __IncompleteArrayField<vtx_value_t>,
}
extern "C" {
    #[doc = " Initialize a heap object header. Does NOT initialize fields."]
    pub fn vtx_heap_object_init(
        obj: *mut vtx_heap_object_t,
        type_id: u32,
        shape_id: u32,
        field_count: u32,
        total_size: u32,
    );
}
extern "C" {
    #[doc = " Get the type_id from a tagged value that is a heap pointer."]
    pub fn vtx_value_typeid(v: vtx_value_t) -> u32;
}
pub const vtx_opcode_t_VT_OP_HALT: vtx_opcode_t = 0;
pub const vtx_opcode_t_VT_OP_NOP: vtx_opcode_t = 1;
pub const vtx_opcode_t_VT_OP_LOAD_LOCAL: vtx_opcode_t = 2;
pub const vtx_opcode_t_VT_OP_STORE_LOCAL: vtx_opcode_t = 3;
pub const vtx_opcode_t_VT_OP_LOAD_FIELD: vtx_opcode_t = 4;
pub const vtx_opcode_t_VT_OP_STORE_FIELD: vtx_opcode_t = 5;
pub const vtx_opcode_t_VT_OP_LOAD_CONST_INT: vtx_opcode_t = 6;
pub const vtx_opcode_t_VT_OP_LOAD_CONST_FLOAT: vtx_opcode_t = 7;
pub const vtx_opcode_t_VT_OP_LOAD_CONST_STR: vtx_opcode_t = 8;
pub const vtx_opcode_t_VT_OP_LOAD_NULL: vtx_opcode_t = 9;
pub const vtx_opcode_t_VT_OP_LOAD_TRUE: vtx_opcode_t = 10;
pub const vtx_opcode_t_VT_OP_LOAD_FALSE: vtx_opcode_t = 11;
pub const vtx_opcode_t_VT_OP_LOAD_UNDEFINED: vtx_opcode_t = 12;
pub const vtx_opcode_t_VT_OP_IADD: vtx_opcode_t = 13;
pub const vtx_opcode_t_VT_OP_ISUB: vtx_opcode_t = 14;
pub const vtx_opcode_t_VT_OP_IMUL: vtx_opcode_t = 15;
pub const vtx_opcode_t_VT_OP_IDIV: vtx_opcode_t = 16;
pub const vtx_opcode_t_VT_OP_IMOD: vtx_opcode_t = 17;
pub const vtx_opcode_t_VT_OP_FADD: vtx_opcode_t = 18;
pub const vtx_opcode_t_VT_OP_FSUB: vtx_opcode_t = 19;
pub const vtx_opcode_t_VT_OP_FMUL: vtx_opcode_t = 20;
pub const vtx_opcode_t_VT_OP_FDIV: vtx_opcode_t = 21;
pub const vtx_opcode_t_VT_OP_ISHL: vtx_opcode_t = 22;
pub const vtx_opcode_t_VT_OP_ISHR: vtx_opcode_t = 23;
pub const vtx_opcode_t_VT_OP_IAND: vtx_opcode_t = 24;
pub const vtx_opcode_t_VT_OP_IOR: vtx_opcode_t = 25;
pub const vtx_opcode_t_VT_OP_IXOR: vtx_opcode_t = 26;
pub const vtx_opcode_t_VT_OP_INEG: vtx_opcode_t = 27;
pub const vtx_opcode_t_VT_OP_INOT: vtx_opcode_t = 28;
pub const vtx_opcode_t_VT_OP_ICMP_EQ: vtx_opcode_t = 29;
pub const vtx_opcode_t_VT_OP_ICMP_NE: vtx_opcode_t = 30;
pub const vtx_opcode_t_VT_OP_ICMP_LT: vtx_opcode_t = 31;
pub const vtx_opcode_t_VT_OP_ICMP_LE: vtx_opcode_t = 32;
pub const vtx_opcode_t_VT_OP_ICMP_GT: vtx_opcode_t = 33;
pub const vtx_opcode_t_VT_OP_ICMP_GE: vtx_opcode_t = 34;
pub const vtx_opcode_t_VT_OP_FCMP_EQ: vtx_opcode_t = 35;
pub const vtx_opcode_t_VT_OP_FCMP_NE: vtx_opcode_t = 36;
pub const vtx_opcode_t_VT_OP_FCMP_LT: vtx_opcode_t = 37;
pub const vtx_opcode_t_VT_OP_FCMP_LE: vtx_opcode_t = 38;
pub const vtx_opcode_t_VT_OP_FCMP_GT: vtx_opcode_t = 39;
pub const vtx_opcode_t_VT_OP_FCMP_GE: vtx_opcode_t = 40;
pub const vtx_opcode_t_VT_OP_GOTO: vtx_opcode_t = 41;
pub const vtx_opcode_t_VT_OP_IF_TRUE: vtx_opcode_t = 42;
pub const vtx_opcode_t_VT_OP_IF_FALSE: vtx_opcode_t = 43;
pub const vtx_opcode_t_VT_OP_CALL_STATIC: vtx_opcode_t = 44;
pub const vtx_opcode_t_VT_OP_CALL_VIRTUAL: vtx_opcode_t = 45;
pub const vtx_opcode_t_VT_OP_CALL_INTERFACE: vtx_opcode_t = 46;
pub const vtx_opcode_t_VT_OP_RETURN: vtx_opcode_t = 47;
pub const vtx_opcode_t_VT_OP_RETURN_VALUE: vtx_opcode_t = 48;
pub const vtx_opcode_t_VT_OP_NEW: vtx_opcode_t = 49;
pub const vtx_opcode_t_VT_OP_NEWARRAY: vtx_opcode_t = 50;
pub const vtx_opcode_t_VT_OP_CHECKCAST: vtx_opcode_t = 51;
pub const vtx_opcode_t_VT_OP_INSTANCEOF: vtx_opcode_t = 52;
pub const vtx_opcode_t_VT_OP_ARRAY_LOAD: vtx_opcode_t = 53;
pub const vtx_opcode_t_VT_OP_ARRAY_STORE: vtx_opcode_t = 54;
pub const vtx_opcode_t_VT_OP_ARRAY_LENGTH: vtx_opcode_t = 55;
pub const vtx_opcode_t_VT_OP_THROW: vtx_opcode_t = 56;
pub const vtx_opcode_t_VT_OP_CATCH: vtx_opcode_t = 57;
pub const vtx_opcode_t_VT_OP_CATCH_TYPED: vtx_opcode_t = 58;
pub const vtx_opcode_t_VT_OP_MONITOR_ENTER: vtx_opcode_t = 59;
pub const vtx_opcode_t_VT_OP_MONITOR_EXIT: vtx_opcode_t = 60;
pub const vtx_opcode_t_VT_OP_DUP: vtx_opcode_t = 61;
pub const vtx_opcode_t_VT_OP_POP: vtx_opcode_t = 62;
pub const vtx_opcode_t_VT_OP_SWAP: vtx_opcode_t = 63;
pub const vtx_opcode_t_VT_OP_ISNULL: vtx_opcode_t = 64;
pub const vtx_opcode_t_VT_OP_TYPEOF: vtx_opcode_t = 65;
pub const vtx_opcode_t_VT_OP_CALL_RUNTIME: vtx_opcode_t = 66;
pub const vtx_opcode_t_VT_OP_COUNT: vtx_opcode_t = 67;
#[doc = " VORTEX Bytecode Format\n\n Variable-length instruction stream. Each instruction consists of:\n   - 1 byte: opcode\n   - 0, 1, or 2 bytes: operand (depending on opcode)\n\n Operands are stored in big-endian format (2-byte operands).\n The constant pool contains tagged values indexed by LOAD_CONST_* operands."]
pub type vtx_opcode_t = ::std::os::raw::c_uint;
#[doc = " Per-opcode metadata: name, stack input/output counts, operand info."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_opcode_info_t {
    pub name: *const ::std::os::raw::c_char,
    pub stack_input_count: u8,
    pub stack_output_count: u8,
    pub has_operand: bool,
    pub operand_size: u8,
}
impl Default for vtx_opcode_info_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " A bytecode module: code + constant pool."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_bytecode_t {
    pub code: *const u8,
    pub length: usize,
    pub constant_pool: *mut vtx_value_t,
    pub constant_count: u32,
    pub max_locals: u16,
    pub max_stack: u16,
}
impl Default for vtx_bytecode_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Read the opcode at the given PC."]
    pub fn vtx_bytecode_opcode_at(bc: *const vtx_bytecode_t, pc: usize) -> vtx_opcode_t;
}
extern "C" {
    #[doc = " Read a 2-byte big-endian operand at pc+1.\n Returns the 16-bit unsigned operand value."]
    pub fn vtx_bytecode_read_operand(bc: *const vtx_bytecode_t, pc: usize) -> u16;
}
extern "C" {
    #[doc = " Compute the net stack effect of an opcode (output_count - input_count).\n Returns a negative number if the opcode pops more than it pushes."]
    pub fn vtx_bytecode_stack_effect(opcode: vtx_opcode_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Compute the actual maximum operand stack depth by abstract interpretation.\n\n Walks the bytecode tracking stack depth at each PC, handling branches\n via a worklist algorithm. This produces an accurate max_stack that\n accounts for all control-flow paths, even when the bytecode's declared\n max_stack is too low (a common cause of spill-index-out-of-bounds bugs).\n\n @param bc          The bytecode module\n @param max_locals  Number of local variable slots (for context)\n @return            The computed maximum stack depth (at least 0)"]
    pub fn vtx_bytecode_compute_max_stack(bc: *const vtx_bytecode_t, max_locals: u32) -> u32;
}
extern "C" {
    #[doc = " Disassemble one instruction at `pc` into the provided buffer.\n Returns the PC of the next instruction (pc + instruction length).\n Writes at most bufsize-1 characters plus a null terminator."]
    pub fn vtx_bytecode_disassemble_op(
        bc: *const vtx_bytecode_t,
        pc: usize,
        buf: *mut ::std::os::raw::c_char,
        bufsize: usize,
    ) -> usize;
}
extern "C" {
    #[doc = " Compute the length (in bytes) of the instruction at `pc`."]
    pub fn vtx_bytecode_insn_length(bc: *const vtx_bytecode_t, pc: usize) -> usize;
}
extern "C" {
    #[doc = " Scan the bytecode stream for the highest local index referenced by\n any LOAD_LOCAL or STORE_LOCAL instruction. Used as a fallback when\n the bytecode file format does not include an explicit max_locals\n field (VOBC v1 files, or files loaded by main_new.c's own loader).\n\n Without this scan, max_locals stays as uninitialized arena memory,\n causing the locals array to be undersized — STORE_LOCAL N then\n aliases with the operand stack, producing silent data corruption.\n\n @param bc  The bytecode module (must have code + length populated)\n @return    The highest local index used (0 if no locals are referenced)"]
    pub fn vtx_bytecode_scan_max_locals(bc: *const vtx_bytecode_t) -> u16;
}
#[doc = " VORTEX Type System\n\n Types are represented as TypeIDs that index into a type descriptor table.\n Type descriptors contain: name, field layout, method table, parent type,\n implemented interfaces, and shape ID.\n\n Type identity is structural for interfaces, nominal for classes.\n Inline caches support monomorphic, polymorphic (up to VTX_POLY_LIMIT\n types per site), and megamorphic transitions."]
pub type vtx_typeid_t = u32;
pub type vtx_shapeid_t = u32;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_field_desc_t {
    pub name: *const ::std::os::raw::c_char,
    pub type_: vtx_typeid_t,
    pub offset: u32,
}
impl Default for vtx_field_desc_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_method_desc_t {
    pub name: *const ::std::os::raw::c_char,
    pub signature: *const ::std::os::raw::c_char,
    pub bytecode: *mut vtx_bytecode_t,
    pub compiled_code: *mut ::std::os::raw::c_void,
    pub vtable_index: u32,
    pub arg_count: u32,
    pub method_symbol_id: u32,
    pub is_virtual: bool,
}
impl Default for vtx_method_desc_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
pub type vtx_type_desc_t = vtx_type_desc;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_type_desc {
    pub name: *const ::std::os::raw::c_char,
    pub type_id: vtx_typeid_t,
    pub parent_type: vtx_typeid_t,
    pub field_count: u32,
    pub fields: *mut vtx_field_desc_t,
    pub method_count: u32,
    pub methods: *mut vtx_method_desc_t,
    pub shape_id: vtx_shapeid_t,
    pub instance_size: u32,
    pub vtable: *mut *mut ::std::os::raw::c_void,
    pub vtable_size: u32,
    pub interface_count: u32,
    pub interfaces: *mut vtx_typeid_t,
}
impl Default for vtx_type_desc {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_symbol_t {
    pub name: *const ::std::os::raw::c_char,
    pub hash: u32,
    pub length: u32,
}
impl Default for vtx_symbol_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_symbol_table_t {
    pub symbols: *mut vtx_symbol_t,
    pub symbol_count: u32,
    pub symbol_capacity: u32,
    pub hash_buckets: *mut u32,
    pub hash_bucket_count: u32,
}
impl Default for vtx_symbol_table_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_type_system_t {
    pub types: *mut vtx_type_desc_t,
    pub type_count: u32,
    pub capacity: u32,
    pub shape_counter: vtx_shapeid_t,
    pub symbol_table: vtx_symbol_table_t,
}
impl Default for vtx_type_system_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the type system with the root Object type pre-registered.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_type_system_init(ts: *mut vtx_type_system_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the type system and free all allocated memory."]
    pub fn vtx_type_system_destroy(ts: *mut vtx_type_system_t);
}
extern "C" {
    #[doc = " Intern a string: returns the symbol ID, creating a new entry if needed.\n The name pointer must remain valid for the lifetime of the type system."]
    pub fn vtx_symbol_intern(
        ts: *mut vtx_type_system_t,
        name: *const ::std::os::raw::c_char,
    ) -> u32;
}
extern "C" {
    #[doc = " Look up a symbol by name: returns VTX_SYMBOL_INVALID if not found."]
    pub fn vtx_symbol_lookup(
        ts: *const vtx_type_system_t,
        name: *const ::std::os::raw::c_char,
    ) -> u32;
}
extern "C" {
    #[doc = " Get a symbol's name by ID. Returns NULL if the symbol ID is invalid."]
    pub fn vtx_symbol_name(
        ts: *const vtx_type_system_t,
        symbol_id: u32,
    ) -> *const ::std::os::raw::c_char;
}
extern "C" {
    #[doc = " Get/set the global type system instance.\n Used by the interpreter and runtime stubs for type queries."]
    pub fn vtx_get_current_type_system() -> *mut vtx_type_system_t;
}
extern "C" {
    pub fn vtx_set_current_type_system(ts: *mut vtx_type_system_t);
}
extern "C" {
    #[doc = " Register a new type. Returns the new TypeID on success,\n VTX_TYPE_INVALID on failure.\n\n The type system takes ownership of the fields and methods arrays\n (but NOT the strings they point to — those must outlive the type system)."]
    pub fn vtx_type_register(
        ts: *mut vtx_type_system_t,
        name: *const ::std::os::raw::c_char,
        parent_id: vtx_typeid_t,
        field_count: u32,
        fields: *mut vtx_field_desc_t,
        method_count: u32,
        methods: *mut vtx_method_desc_t,
    ) -> vtx_typeid_t;
}
extern "C" {
    #[doc = " Get a type descriptor by ID. Returns NULL if the ID is invalid."]
    pub fn vtx_type_get(ts: *const vtx_type_system_t, id: vtx_typeid_t) -> *const vtx_type_desc_t;
}
extern "C" {
    #[doc = " Check if child_id is a subtype of parent_id by walking the parent chain.\n A type is considered a subtype of itself."]
    pub fn vtx_type_is_subtype(
        ts: *const vtx_type_system_t,
        child_id: vtx_typeid_t,
        parent_id: vtx_typeid_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Check if obj_typeid is an instance of target_typeid.\n This includes subtype checking AND interface implementation checking."]
    pub fn vtx_type_is_instance(
        ts: *const vtx_type_system_t,
        obj_typeid: vtx_typeid_t,
        target_typeid: vtx_typeid_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Resolve a method by name for a given type.\n For virtual methods, walks the vtable. For non-virtual, looks up directly.\n Returns NULL if not found."]
    pub fn vtx_type_resolve_method(
        ts: *const vtx_type_system_t,
        typeid: vtx_typeid_t,
        method_name: *const ::std::os::raw::c_char,
    ) -> *const vtx_method_desc_t;
}
extern "C" {
    #[doc = " Compute the instance size for a type based on its field layout\n with alignment rules. The instance size includes the heap object header."]
    pub fn vtx_type_instance_size(ts: *mut vtx_type_system_t, typeid: vtx_typeid_t) -> u32;
}
extern "C" {
    #[doc = " Compute a shape ID for the type. The shape is a layout fingerprint based\n on field offsets and types. Two types with the same shape have compatible\n field layouts and can share inline cache entries."]
    pub fn vtx_type_compute_shape(
        ts: *mut vtx_type_system_t,
        typeid: vtx_typeid_t,
    ) -> vtx_shapeid_t;
}
extern "C" {
    #[doc = " Add an interface to a type's implemented interfaces list.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_type_add_interface(
        ts: *mut vtx_type_system_t,
        impl_type: vtx_typeid_t,
        interface_type: vtx_typeid_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " RT-13 fix: Update the vtable entry for a method after it has been compiled.\n Must be called when a method's compiled_code pointer changes (e.g., after JIT\n compilation) so that virtual dispatch through the vtable uses the new code.\n\n @param ts        Type system\n @param typeid    Type that owns the method\n @param method    Pointer to the method descriptor (must be in the type's methods array)\n @return          0 on success, -1 on failure"]
    pub fn vtx_type_update_vtable(
        ts: *mut vtx_type_system_t,
        typeid: vtx_typeid_t,
        method: *const vtx_method_desc_t,
    ) -> ::std::os::raw::c_int;
}
pub const vtx_ic_state_t_VT_IC_MONOMORPHIC: vtx_ic_state_t = 0;
pub const vtx_ic_state_t_VT_IC_POLYMORPHIC: vtx_ic_state_t = 1;
pub const vtx_ic_state_t_VT_IC_MEGAMORPHIC: vtx_ic_state_t = 2;
pub type vtx_ic_state_t = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_ic_entry_t {
    pub typeid_: vtx_typeid_t,
    pub method: *const vtx_method_desc_t,
}
impl Default for vtx_ic_entry_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_inline_cache_t {
    pub state: vtx_ic_state_t,
    pub entries: [vtx_ic_entry_t; 5usize],
    pub count: u32,
    pub lock: ::std::os::raw::c_int,
}
impl Default for vtx_inline_cache_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize an inline cache to empty monomorphic state."]
    pub fn vtx_ic_init(ic: *mut vtx_inline_cache_t);
}
extern "C" {
    #[doc = " Look up a method in the inline cache for the given typeid.\n Returns the method pointer if found, NULL otherwise."]
    pub fn vtx_ic_lookup(
        ic: *const vtx_inline_cache_t,
        typeid_: vtx_typeid_t,
    ) -> *const vtx_method_desc_t;
}
extern "C" {
    #[doc = " Update the inline cache with a new typeid → method mapping.\n Transitions the state: monomorphic → polymorphic → megamorphic."]
    pub fn vtx_ic_update(
        ic: *mut vtx_inline_cache_t,
        typeid_: vtx_typeid_t,
        method: *const vtx_method_desc_t,
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_safepoint_manager {
    _unused: [u8; 0],
}
pub const vtx_gc_mode_t_VTX_GC_GENERATIONAL: vtx_gc_mode_t = 0;
pub const vtx_gc_mode_t_VTX_GC_NONE: vtx_gc_mode_t = 1;
pub const vtx_gc_mode_t_VTX_GC_MANUAL: vtx_gc_mode_t = 2;
pub const vtx_gc_mode_t_VTX_GC_ARENA: vtx_gc_mode_t = 3;
pub type vtx_gc_mode_t = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_semi_space_t {
    pub start: *mut u8,
    pub current: *mut u8,
    pub size: usize,
}
impl Default for vtx_semi_space_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
pub type vtx_free_node_t = vtx_free_node;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_free_node {
    pub pad_type_id: u32,
    pub gc_mark: u8,
    pub pad_age: u8,
    pub pad_pinned: u8,
    pub pad_remembered: u8,
    pub size_low: u32,
    pub size_high: u32,
    pub next: *mut vtx_free_node_t,
}
impl Default for vtx_free_node {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_old_gen_t {
    pub start: *mut u8,
    pub size: usize,
    pub used: usize,
    pub free_list: *mut vtx_free_node_t,
}
impl Default for vtx_old_gen_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_remembered_entry_t {
    pub obj: *mut vtx_heap_object_t,
}
impl Default for vtx_remembered_entry_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_root_entry_t {
    pub value: vtx_value_t,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_gc_t {
    pub young_from: vtx_semi_space_t,
    pub young_to: vtx_semi_space_t,
    pub old_gen: vtx_old_gen_t,
    pub root_stack: *mut vtx_root_entry_t,
    pub root_count: u32,
    pub root_capacity: u32,
    pub remembered_set: *mut vtx_remembered_entry_t,
    pub remembered_count: u32,
    pub remembered_capacity: u32,
    pub type_system: *mut vtx_type_system_t,
    pub collection_requested: bool,
    pub collections_done: u32,
    pub pinned_objects: *mut *mut vtx_heap_object_t,
    pub pinned_count: u32,
    pub pinned_capacity: u32,
    pub mode: vtx_gc_mode_t,
    pub fn_write_barrier: ::std::option::Option<
        unsafe extern "C" fn(
            gc: *mut vtx_gc_t,
            obj: *mut vtx_heap_object_t,
            field_offset: u32,
            value: vtx_value_t,
        ),
    >,
    pub fn_safepoint: ::std::option::Option<unsafe extern "C" fn(gc: *mut vtx_gc_t)>,
    pub fn_root_push:
        ::std::option::Option<unsafe extern "C" fn(gc: *mut vtx_gc_t, value: vtx_value_t)>,
    pub fn_root_pop: ::std::option::Option<unsafe extern "C" fn(gc: *mut vtx_gc_t) -> vtx_value_t>,
    pub manual_free_list: *mut vtx_free_node_t,
    pub arena_save_point: *mut u8,
    pub card_table: *mut u8,
    pub card_table_size: usize,
    pub heap_base: *mut u8,
    pub heap_size: usize,
    pub safepoint_mgr: *mut ::std::os::raw::c_void,
    pub jit_root_scan_fn: ::std::option::Option<unsafe extern "C" fn(gc: *mut vtx_gc_t)>,
}
impl Default for vtx_gc_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the garbage collector. Requires a type_system for\n object size/field layout information.\n The mode parameter selects the GC strategy.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_gc_init(
        gc: *mut vtx_gc_t,
        ts: *mut vtx_type_system_t,
        mode: vtx_gc_mode_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the garbage collector and release all memory."]
    pub fn vtx_gc_destroy(gc: *mut vtx_gc_t);
}
extern "C" {
    #[doc = " Allocate a heap object of the given size with the given type_id.\n Allocates in the young generation using bump-pointer allocation.\n Returns a pointer to the initialized heap object, or NULL on failure.\n The object header is initialized; fields are set to VTX_VALUE_UNDEFINED."]
    pub fn vtx_gc_alloc(
        gc: *mut vtx_gc_t,
        size: usize,
        type_id: vtx_typeid_t,
    ) -> *mut vtx_heap_object_t;
}
extern "C" {
    #[doc = " Check if collection has been requested and if so, perform a young-gen\n collection. This should be called at safe points (backward branches,\n method calls)."]
    pub fn vtx_gc_safepoint(gc: *mut vtx_gc_t);
}
extern "C" {
    #[doc = " Push a value onto the GC root stack. The value (if it contains a\n heap pointer) will be traced during collection."]
    pub fn vtx_gc_root_push(gc: *mut vtx_gc_t, value: vtx_value_t);
}
extern "C" {
    #[doc = " Pop a value from the GC root stack."]
    pub fn vtx_gc_root_pop(gc: *mut vtx_gc_t) -> vtx_value_t;
}
extern "C" {
    #[doc = " Generational write barrier. Call this when storing a value into a\n field of an object. If the object is in old gen and the value is\n a young-gen pointer, the object is added to the remembered set."]
    pub fn vtx_gc_write_barrier(
        gc: *mut vtx_gc_t,
        obj: *mut vtx_heap_object_t,
        field_offset: u32,
        value: vtx_value_t,
    );
}
extern "C" {
    #[doc = " Card marking write barrier. Replaces the old 10-branch barrier with\n ~3 instructions on the fast path: check if value is young-gen, compute\n card index, mark card dirty. Used in generational mode."]
    pub fn vtx_gc_write_barrier_card(
        gc: *mut vtx_gc_t,
        obj: *mut vtx_heap_object_t,
        field_offset: u32,
        value: vtx_value_t,
    );
}
extern "C" {
    #[doc = " Card-table dirty-marking helper. Marks the card containing the\n given field address as dirty (0xFF). Called by the JIT write\n barrier runtime helper (vtx_helpers_write_barrier) and by the\n GC internals during card-table scanning.\n\n @param gc          GC instance (must not be NULL)\n @param field_addr  Address of the field that was written"]
    pub fn vtx_gc_card_mark_dirty(gc: *mut vtx_gc_t, field_addr: *const ::std::os::raw::c_void);
}
extern "C" {
    #[doc = " Perform a young-generation collection (copying collector).\n Copies live objects from young_from to young_to, then swaps.\n Promotes survivors that have survived >= VTX_GC_PROMOTION_AGE collections."]
    pub fn vtx_gc_collect_young(gc: *mut vtx_gc_t);
}
extern "C" {
    #[doc = " Perform an old-generation collection (mark-sweep).\n Marks all reachable objects from roots, then sweeps unreachable ones."]
    pub fn vtx_gc_collect_old(gc: *mut vtx_gc_t);
}
extern "C" {
    #[doc = " Pin an object so it won't be moved during young-gen collection.\n Used when JIT code holds raw pointers to the object."]
    pub fn vtx_gc_pin(gc: *mut vtx_gc_t, obj: *mut vtx_heap_object_t);
}
extern "C" {
    #[doc = " Unpin an object."]
    pub fn vtx_gc_unpin(gc: *mut vtx_gc_t, obj: *mut vtx_heap_object_t);
}
extern "C" {
    #[doc = " Check if an object is pinned."]
    pub fn vtx_gc_is_pinned(gc: *mut vtx_gc_t, obj: *mut vtx_heap_object_t) -> bool;
}
extern "C" {
    #[doc = " Set the GC mode at runtime. This reconfigures the function pointers\n and may adjust internal state for the new mode."]
    pub fn vtx_gc_set_mode(gc: *mut vtx_gc_t, mode: vtx_gc_mode_t);
}
extern "C" {
    #[doc = " Get the current GC mode."]
    pub fn vtx_gc_get_mode(gc: *const vtx_gc_t) -> vtx_gc_mode_t;
}
extern "C" {
    #[doc = " Manual mode: free a previously allocated object.\n Adds the block to a free list for O(1) free.\n Only valid when mode is VTX_GC_MANUAL."]
    pub fn vtx_gc_manual_free(gc: *mut vtx_gc_t, ptr: *mut ::std::os::raw::c_void, size: usize);
}
extern "C" {
    #[doc = " Arena mode: save current allocation point.\n Only valid when mode is VTX_GC_ARENA."]
    pub fn vtx_gc_arena_enter(gc: *mut vtx_gc_t);
}
extern "C" {
    #[doc = " Arena mode: restore to saved allocation point (free everything since enter).\n Only valid when mode is VTX_GC_ARENA."]
    pub fn vtx_gc_arena_leave(gc: *mut vtx_gc_t);
}
extern "C" {
    #[doc = " Get the current GC instance (thread-local in a full VM; global for now).\n This is used by runtime helpers (e.g., write barrier) that need GC access\n but are called from JIT-compiled code which doesn't pass a GC pointer."]
    pub fn vtx_get_current_gc() -> *mut vtx_gc_t;
}
extern "C" {
    #[doc = " Set the current GC instance. Called during VM initialization."]
    pub fn vtx_set_current_gc(gc: *mut vtx_gc_t);
}
extern "C" {
    #[doc = " Check if a pointer falls within the young generation from-space."]
    pub fn vtx_gc_in_young(gc: *const vtx_gc_t, ptr: *const ::std::os::raw::c_void) -> bool;
}
extern "C" {
    #[doc = " Check if a pointer falls within the old generation."]
    pub fn vtx_gc_in_old(gc: *const vtx_gc_t, ptr: *const ::std::os::raw::c_void) -> bool;
}
extern "C" {
    #[doc = " Get the total number of bytes allocated in young gen."]
    pub fn vtx_gc_young_used(gc: *const vtx_gc_t) -> usize;
}
extern "C" {
    #[doc = " Get the total number of bytes used in old gen."]
    pub fn vtx_gc_old_used(gc: *const vtx_gc_t) -> usize;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_method_desc {
    _unused: [u8; 0],
}
extern "C" {
    #[doc = " Type check: verify that a value's heap object is an instance of\n the expected type. Returns true if the check passes.\n If the value is not a heap pointer, returns false."]
    pub fn vtx_helpers_type_check(
        ts: *const vtx_type_system_t,
        obj_value: vtx_value_t,
        expected_typeid: vtx_typeid_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Null check: returns true if the value is NOT null.\n Calls abort() (trap) if the value IS null. This is a runtime trap\n used by the interpreter and JIT code."]
    pub fn vtx_helpers_null_check(value: vtx_value_t) -> bool;
}
extern "C" {
    #[doc = " Bounds check: returns true if 0 <= index < length.\n Calls abort() (trap) if the index is out of bounds."]
    pub fn vtx_helpers_bounds_check(index: i64, length: i64) -> bool;
}
extern "C" {
    #[doc = " Check if integer addition would overflow.\n Returns true if a + b does NOT overflow int64_t."]
    pub fn vtx_helpers_overflow_check_iadd(a: i64, b: i64) -> bool;
}
extern "C" {
    #[doc = " Check if integer multiplication would overflow.\n Returns true if a * b does NOT overflow int64_t."]
    pub fn vtx_helpers_overflow_check_imul(a: i64, b: i64) -> bool;
}
extern "C" {
    #[doc = " Resolve a virtual method call using inline caching.\n First attempts IC lookup; on miss, does a full vtable walk and\n updates the IC.\n\n Returns the resolved method descriptor, or NULL if not found."]
    pub fn vtx_helpers_resolve_virtual(
        ts: *mut vtx_type_system_t,
        ic: *mut vtx_inline_cache_t,
        obj_value: vtx_value_t,
        method_name: *const ::std::os::raw::c_char,
    ) -> *const vtx_method_desc_t;
}
extern "C" {
    #[doc = " Resolve an interface method call using inline caching.\n Similar to virtual resolution but also checks interface implementations.\n\n Returns the resolved method descriptor, or NULL if not found."]
    pub fn vtx_helpers_resolve_interface(
        ts: *mut vtx_type_system_t,
        ic: *mut vtx_inline_cache_t,
        obj_value: vtx_value_t,
        interface_typeid: vtx_typeid_t,
        method_name: *const ::std::os::raw::c_char,
    ) -> *const vtx_method_desc_t;
}
extern "C" {
    #[doc = " Compare two string objects stored as heap objects.\n Both values must be heap pointers to string objects.\n Returns <0, 0, >0 like strcmp.\n\n String objects have their character data stored starting at field index 0\n as a sequence of bytes. The first field (fields[0]) stores the length\n as an SMI, and subsequent fields store the character data packed into\n vtx_value_t words.\n\n Actually, for simplicity, we store strings with:\n   field[0] = length (SMI)\n   field[1] through field[N] = packed char data in vtx_value_t slots\n\n For a simpler approach, we store the string data as a C string\n in the fields array starting at offset 1."]
    pub fn vtx_helpers_string_compare(a: vtx_value_t, b: vtx_value_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Get the C-string data from a string heap object.\n Returns a pointer to a null-terminated string, or \"\" if not a string."]
    pub fn vtx_helpers_string_data(str_value: vtx_value_t) -> *const ::std::os::raw::c_char;
}
extern "C" {
    #[doc = " Get the length of a string heap object."]
    pub fn vtx_helpers_string_length(str_value: vtx_value_t) -> u32;
}
extern "C" {
    #[doc = " GC write barrier: must be called after storing a reference to an object.\n Implements a card-table based write barrier for generational GC.\n Marks the card containing [obj + offset] as dirty so the GC can\n find cross-generational references during young-gen collection.\n\n @param obj           Pointer to the heap object containing the field\n @param field_offset  Byte offset of the field within the object"]
    pub fn vtx_helpers_write_barrier(obj: *mut ::std::os::raw::c_void, field_offset: u32);
}
extern "C" {
    #[doc = " Call a method with arguments passed in registers.\n\n B7/B8 fix: The JIT entry calling convention (T2) is:\n   RDI = method_ptr, RSI = deopt_info, RDX = profile_data,\n   RCX = args array pointer, R8 = arg_count\n\n The baseline codegen sets up exactly these registers and calls this\n helper. The helper ignores deopt_info/profile_data (they are\n per-callsite values that the callee resolves from its own\n compiled_code metadata), looks up the interpreter via\n vtx_get_current_interp(), and dispatches to vtx_interp_run().\n\n @param method        Method descriptor for the target method\n @param deopt_info    Deopt info pointer (NULL for fresh calls — ignored)\n @param profile_data  Profile data pointer (NULL or sentinel 1 — ignored)\n @param args          Array of argument values (already in the right order)\n @param arg_count     Number of arguments in the args array\n @return              The method's return value"]
    pub fn vtx_runtime_call_reg(
        method: *const vtx_method_desc_t,
        deopt_info: *mut ::std::os::raw::c_void,
        profile_data: *mut ::std::os::raw::c_void,
        args: *mut vtx_value_t,
        arg_count: u32,
    ) -> vtx_value_t;
}
extern "C" {
    #[doc = " Call a virtual method with register-based dispatch.\n\n B7/B8 fix: Uses the same JIT entry calling convention as\n vtx_runtime_call_reg. The receiver is args[0]; the method name is\n derived from `method->name`. The receiver's type is used to resolve\n the actual target method.\n\n @param method        Method descriptor (provides method name) — this is\n                      the statically-known method at the call site\n @param deopt_info    Deopt info pointer (NULL — ignored)\n @param profile_data  Profile data pointer (NULL or sentinel 1 — ignored)\n @param args          Array of argument values; args[0] is the receiver\n @param arg_count     Number of arguments in the args array (incl. receiver)\n @return              The method's return value"]
    pub fn vtx_runtime_call_virtual_reg(
        method: *const vtx_method_desc_t,
        deopt_info: *mut ::std::os::raw::c_void,
        profile_data: *mut ::std::os::raw::c_void,
        args: *mut vtx_value_t,
        arg_count: u32,
    ) -> vtx_value_t;
}
extern "C" {
    #[doc = " Call an interface method with register-based dispatch.\n\n B7/B8 fix: Uses the JIT entry calling convention. The interface\n typeid is derived from the receiver's type via the type system.\n\n @param method        Method descriptor (provides method name)\n @param deopt_info    Deopt info pointer (NULL — ignored)\n @param profile_data  Profile data pointer (NULL or sentinel 1 — ignored)\n @param args          Array of argument values; args[0] is the receiver\n @param arg_count     Number of arguments (incl. receiver)\n @return              The method's return value"]
    pub fn vtx_runtime_call_interface_reg(
        method: *const vtx_method_desc_t,
        deopt_info: *mut ::std::os::raw::c_void,
        profile_data: *mut ::std::os::raw::c_void,
        args: *mut vtx_value_t,
        arg_count: u32,
    ) -> vtx_value_t;
}
extern "C" {
    #[doc = " Dispatch a runtime builtin call from JIT-compiled code.\n\n The JIT emits CALL_RUNTIME with a runtime function ID (0-6).\n This function dispatches to the correct implementation:\n   0 = typeof, 1 = monitor_enter, 2 = monitor_exit, 3 = throw,\n   4 = print_ln, 5 = print, 6 = exit\n\n @param func_id  Runtime function ID (from the bytecode operand)\n @param arg      The argument value (popped from the stack)\n @return         Result value (undefined for void calls, SMI for typeof/exit)"]
    pub fn vtx_runtime_builtin_call(func_id: u32, arg: vtx_value_t) -> vtx_value_t;
}
pub const vtx_thread_state_t_VTX_THREAD_STATE_RUNNING: vtx_thread_state_t = 0;
pub const vtx_thread_state_t_VTX_THREAD_STATE_SAFEPOINT: vtx_thread_state_t = 1;
pub const vtx_thread_state_t_VTX_THREAD_STATE_GC: vtx_thread_state_t = 2;
pub const vtx_thread_state_t_VTX_THREAD_STATE_EXITED: vtx_thread_state_t = 3;
pub type vtx_thread_state_t = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_safepoint_thread_t {
    pub tid: pthread_t,
    pub state: vtx_thread_state_t,
    pub safepoint_count: u32,
    pub total_wait_ns: u64,
}
impl Default for vtx_safepoint_thread_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_safepoint_manager_t {
    pub gc: *mut vtx_gc_t,
    pub mutex: pthread_mutex_t,
    pub all_safepointed: pthread_cond_t,
    pub released: pthread_cond_t,
    pub threads: [vtx_safepoint_thread_t; 256usize],
    pub thread_count: u32,
    pub active_count: u32,
    pub safepoint_requested: bool,
    pub safepoint_id: u32,
    pub safepointed_count: u32,
    pub total_safepoints: u64,
    pub total_wait_ns: u64,
}
impl Default for vtx_safepoint_manager_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn vtx_safepoint_manager_init(
        mgr: *mut vtx_safepoint_manager_t,
        gc: *mut vtx_gc_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_safepoint_manager_destroy(mgr: *mut vtx_safepoint_manager_t);
}
extern "C" {
    pub fn vtx_safepoint_thread_register(
        mgr: *mut vtx_safepoint_manager_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_safepoint_thread_unregister(mgr: *mut vtx_safepoint_manager_t);
}
extern "C" {
    pub fn vtx_safepoint_mgr_check(mgr: *mut vtx_safepoint_manager_t);
}
extern "C" {
    pub fn vtx_safepoint_request_all(mgr: *mut vtx_safepoint_manager_t) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_safepoint_release_all(mgr: *mut vtx_safepoint_manager_t) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_safepoint_stats_str(
        mgr: *const vtx_safepoint_manager_t,
        buf: *mut ::std::os::raw::c_char,
        bufsize: usize,
    );
}
extern "C" {
    pub fn vtx_safepoint_thread_count(mgr: *const vtx_safepoint_manager_t) -> u32;
}
pub type vtx_frame_t = vtx_frame;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_frame {
    pub locals: *mut vtx_value_t,
    pub operand_stack: *mut vtx_value_t,
    pub stack_top: ::std::os::raw::c_int,
    pub stack_capacity: ::std::os::raw::c_int,
    pub return_pc: u32,
    pub caller: *mut vtx_frame_t,
    pub method: *const vtx_method_desc_t,
    pub bytecode: *mut vtx_bytecode_t,
    pub monitored_types: *mut u32,
    pub locals_count: u32,
    pub catch_handler_pc: u32,
    pub catch_type: vtx_typeid_t,
    pub exception: vtx_value_t,
}
impl Default for vtx_frame {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " A single 256KB block in the frame stack. Blocks are chained together\n to allow the frame stack to grow beyond a single block."]
pub type vtx_frame_block_t = vtx_frame_block;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_frame_block {
    pub memory: *mut u8,
    pub size: usize,
    pub used: usize,
    pub prev: *mut vtx_frame_block_t,
}
impl Default for vtx_frame_block {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " The frame stack is a chain of pre-allocated memory blocks from which\n frames are carved out sequentially. This avoids malloc in the dispatch loop.\n When a block is full, a new block is allocated and becomes the current block.\n When the top frame is destroyed, if the current block is empty, it is\n freed and the previous block becomes current."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_frame_stack_t {
    pub current: *mut vtx_frame_block_t,
    pub block_size: usize,
    pub block_count: u32,
}
impl Default for vtx_frame_stack_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the frame stack allocator.\n Allocates the first 256KB block.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_frame_stack_init(fs: *mut vtx_frame_stack_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the frame stack allocator and release all blocks."]
    pub fn vtx_frame_stack_destroy(fs: *mut vtx_frame_stack_t);
}
extern "C" {
    #[doc = " Get the total bytes currently in use across all blocks."]
    pub fn vtx_frame_stack_used(fs: *const vtx_frame_stack_t) -> usize;
}
extern "C" {
    #[doc = " Create a new frame for executing the given method.\n Allocates locals and operand stack from the frame stack.\n If the current block doesn't have enough space, a new block is allocated.\n Returns the new frame, or NULL if out of memory."]
    pub fn vtx_frame_create(
        method: *const vtx_method_desc_t,
        caller_frame: *mut vtx_frame_t,
        return_pc: u32,
        fs: *mut vtx_frame_stack_t,
    ) -> *mut vtx_frame_t;
}
extern "C" {
    #[doc = " Destroy a frame, returning its memory to the frame stack.\n Since frames are LIFO, this moves the used pointer back.\n If the current block becomes empty and has a previous block,\n the empty block is freed."]
    pub fn vtx_frame_destroy(frame: *mut vtx_frame_t, fs: *mut vtx_frame_stack_t);
}
pub const vtx_compile_tier_t_VT_TIER_T0: vtx_compile_tier_t = 0;
pub const vtx_compile_tier_t_VT_TIER_T1: vtx_compile_tier_t = 1;
pub const vtx_compile_tier_t_VT_TIER_T2: vtx_compile_tier_t = 2;
pub const vtx_compile_tier_t_VT_TIER_T3: vtx_compile_tier_t = 3;
#[doc = " VORTEX Profiling Counters\n\n Per-method profile data collected by the interpreter (T0).\n Used to make compilation tier decisions and feed the optimizer.\n\n All counters are saturating — they never overflow."]
pub type vtx_compile_tier_t = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_tier_up_state_t {
    pub tier_up_counter: i32,
    pub compilation_requested: bool,
}
#[doc = " Per-call-site IC data: up to VTX_POLY_LIMIT type observations.\n This is separate from the runtime inline cache (vtx_inline_cache_t)\n in that it stores the raw observations for profiling purposes,\n while the IC is used for dispatch optimization."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_call_site_profile_t {
    pub entries: [vtx_ic_entry_t; 4usize],
    pub count: u32,
}
impl Default for vtx_call_site_profile_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Per-method profiling data."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_profile_data_t {
    pub method: *const vtx_method_desc_t,
    pub invocation_count: u64,
    pub backward_branch_count: u64,
    pub call_site_types: *mut vtx_call_site_profile_t,
    pub call_site_count: u32,
    pub branch_taken_counts: *mut u32,
    pub branch_total_counts: *mut u32,
    pub branch_array_size: u32,
    pub field_shape_ids: *mut u32,
    pub field_array_size: u32,
    pub compiled_tier: vtx_compile_tier_t,
    pub deopt_count: u32,
    pub tier_up: vtx_tier_up_state_t,
}
impl Default for vtx_profile_data_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_profiler_t {
    pub data: *mut vtx_profile_data_t,
    pub count: u32,
    pub capacity: u32,
    pub lru: [vtx_profiler_t__bindgen_ty_1; 8usize],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_profiler_t__bindgen_ty_1 {
    pub method: *const vtx_method_desc_t,
    pub pd: *mut vtx_profile_data_t,
}
impl Default for vtx_profiler_t__bindgen_ty_1 {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
impl Default for vtx_profiler_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the profiler.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_profiler_init(profiler: *mut vtx_profiler_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the profiler and release all memory."]
    pub fn vtx_profiler_destroy(profiler: *mut vtx_profiler_t);
}
extern "C" {
    #[doc = " Get or create profile data for the given method.\n If the method is not yet being profiled, a new entry is created.\n Returns a pointer to the profile data, or NULL on failure."]
    pub fn vtx_profiler_get_method_data(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
    ) -> *mut vtx_profile_data_t;
}
extern "C" {
    #[doc = " Record a method invocation. Increments the invocation counter\n (saturating at UINT64_MAX)."]
    pub fn vtx_profiler_record_invocation(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
    );
}
extern "C" {
    #[doc = " Record a backward branch execution. Increments the backward_branch_count\n (saturating at UINT64_MAX)."]
    pub fn vtx_profiler_record_backward_branch(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
    );
}
extern "C" {
    #[doc = " Record a branch outcome at the given PC.\n Increments the taken and total counters (saturating at UINT32_MAX)."]
    pub fn vtx_profiler_record_branch(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
        pc: u32,
        taken: bool,
    );
}
extern "C" {
    #[doc = " Record the receiver type at a call site.\n The call site is identified by its bytecode PC (call_pc)."]
    pub fn vtx_profiler_record_call_type(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
        call_pc: u32,
        typeid_: vtx_typeid_t,
    );
}
extern "C" {
    #[doc = " Record the shape ID at a field access site.\n The field access is identified by its bytecode PC (field_pc)."]
    pub fn vtx_profiler_record_field_shape(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
        field_pc: u32,
        shapeid: vtx_shapeid_t,
    );
}
extern "C" {
    #[doc = " Compute the \"heat\" of a method: a weighted score combining\n invocation count and backward branch density.\n\n heat = invocation_count + backward_branch_count * 2\n\n This means a method with many loop iterations is hotter than one\n that's called often but does little work per call."]
    pub fn vtx_profiler_method_heat(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
    ) -> u64;
}
extern "C" {
    #[doc = " Check if a method should be compiled at T1 (baseline JIT).\n Returns true if heat > VORTEX_T1_THRESHOLD."]
    pub fn vtx_profiler_should_compile_t1(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Check if a method should be compiled at T2 (optimizing JIT).\n Returns true if heat > VORTEX_T2_THRESHOLD."]
    pub fn vtx_profiler_should_compile_t2(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Get the call site profile data for a given method and PC.\n Returns the call site profile, or NULL if not found."]
    pub fn vtx_profiler_get_call_site_profile(
        profiler: *const vtx_profiler_t,
        method: *const vtx_method_desc_t,
        call_pc: u32,
    ) -> *const vtx_call_site_profile_t;
}
extern "C" {
    #[doc = " Get the branch probability (taken / total) at a given PC.\n Returns 0.5 if no data is available."]
    pub fn vtx_profiler_get_branch_probability(
        profiler: *const vtx_profiler_t,
        method: *const vtx_method_desc_t,
        pc: u32,
    ) -> f64;
}
extern "C" {
    #[doc = " Get the field shape ID observed at a given PC.\n Returns VTX_SHAPE_INVALID if no data is available."]
    pub fn vtx_profiler_get_field_shape(
        profiler: *const vtx_profiler_t,
        method: *const vtx_method_desc_t,
        field_pc: u32,
    ) -> vtx_shapeid_t;
}
extern "C" {
    #[doc = " Record a deoptimization from the given method.\n Increments deopt_count (saturating at UINT32_MAX)."]
    pub fn vtx_profiler_record_deopt(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
    );
}
extern "C" {
    #[doc = " Set the compilation tier for a method."]
    pub fn vtx_profiler_set_compiled_tier(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
        tier: vtx_compile_tier_t,
    );
}
extern "C" {
    #[doc = " D7: Check and decrement the tier-up counter for a method.\n\n This is designed to be called from the interpreter dispatch loop at\n backward branches. It decrements the counter and returns true when\n the counter reaches zero (indicating the method should be compiled).\n\n After returning true, the compilation_requested flag is set so that\n subsequent calls are no-ops (the method has already been queued).\n\n The caller is responsible for triggering the actual compilation\n (e.g., via vtx_request_compilation or the compilation thread pool).\n\n @param profiler  The profiler\n @param method    The method being executed\n @return          true if the method should be compiled, false otherwise"]
    pub fn vtx_profiler_tier_up_check(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
    ) -> bool;
}
extern "C" {
    #[doc = " D7: Reset the tier-up counter for a method (e.g., after recompilation\n for a higher tier). This allows the method to be detected as hot\n again for the next tier transition.\n\n @param profiler          The profiler\n @param method            The method to reset\n @param new_initial_count The new initial counter value (0 for default)"]
    pub fn vtx_profiler_tier_up_reset(
        profiler: *mut vtx_profiler_t,
        method: *const vtx_method_desc_t,
        new_initial_count: i32,
    );
}
extern "C" {
    #[doc = " Look up a virtual method using an inline cache.\n\n Algorithm:\n   1. If receiver is a heap pointer, extract its typeid\n   2. Check the IC for a cached mapping (monomorphic fast path)\n   3. On miss, do a full vtable walk via vtx_type_resolve_method\n   4. Update the IC with the new mapping\n\n The IC transitions through states:\n   - Monomorphic (1 entry): direct match on typeid\n   - Polymorphic (2..VTX_POLY_LIMIT entries): linear scan\n   - Megamorphic (>VTX_POLY_LIMIT types): vtable fallback, no IC update\n\n Returns the resolved method descriptor, or NULL if not found."]
    pub fn vtx_lookup_method(
        ts: *mut vtx_type_system_t,
        ic: *mut vtx_inline_cache_t,
        receiver: vtx_value_t,
        method_name: *const ::std::os::raw::c_char,
    ) -> *const vtx_method_desc_t;
}
extern "C" {
    #[doc = " Look up an interface method using an inline cache.\n\n Algorithm:\n   1. If receiver is a heap pointer, extract its typeid\n   2. Check the IC for a cached mapping\n   3. On miss, verify that the receiver's type implements the interface\n   4. Walk the type hierarchy to find the method\n   5. Update the IC\n\n Returns the resolved method descriptor, or NULL if not found."]
    pub fn vtx_lookup_interface_method(
        ts: *mut vtx_type_system_t,
        ic: *mut vtx_inline_cache_t,
        receiver: vtx_value_t,
        interface_typeid: vtx_typeid_t,
        method_name: *const ::std::os::raw::c_char,
    ) -> *const vtx_method_desc_t;
}
extern "C" {
    #[doc = " Look up a static method by name from a given type.\n No IC is used for static calls (the target is always the same).\n\n Returns the resolved method descriptor, or NULL if not found."]
    pub fn vtx_lookup_static_method(
        ts: *mut vtx_type_system_t,
        typeid_: vtx_typeid_t,
        method_name: *const ::std::os::raw::c_char,
    ) -> *const vtx_method_desc_t;
}
#[doc = " A call site observation: receiver type and result type."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_tf_call_observation_t {
    pub receiver_typeid: vtx_typeid_t,
    pub result_typeid: vtx_typeid_t,
}
#[doc = " A field access observation: holder shape and value type."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_tf_field_observation_t {
    pub holder_shapeid: vtx_shapeid_t,
    pub value_typeid: vtx_typeid_t,
}
#[doc = " A branch observation: taken or not taken."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_tf_branch_observation_t {
    pub taken: bool,
}
#[doc = " A single (type_id, count) entry in the per-type frequency table.\n Tracks how many times a specific receiver type was observed at a call site."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_type_freq_entry_t {
    pub type_id: vtx_typeid_t,
    pub count: u32,
}
#[doc = " Per-type frequency distribution for a single call site.\n Enables accurate KL divergence computation for recompilation decisions.\n Without this, the KL divergence is meaningless because uniform weights\n are used (each observed type gets equal weight regardless of actual\n frequency)."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_type_freq_t {
    pub entries: [vtx_type_freq_entry_t; 8usize],
    pub entry_count: u32,
    pub total_count: u32,
}
#[doc = " A stable-type signature: the tuple (receiver_type, arg1_type, ..., result_type)\n observed at a call site. When all types in the signature have been stable\n for VTX_TYPE_STABILITY_WINDOW consecutive observations, the site is marked\n as hyper-stable and receives a single composite guard."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_type_signature_t {
    pub types: [vtx_typeid_t; 8usize],
    pub slot_count: u32,
    pub stability_count: u32,
    pub is_hyper_stable: bool,
}
#[doc = " Call site feedback: circular buffer of call observations."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_tf_call_site_t {
    pub observations: [vtx_tf_call_observation_t; 32usize],
    pub write_index: u8,
    pub count: u8,
    pub type_freq: vtx_type_freq_t,
    pub stable_signature: vtx_type_signature_t,
}
#[doc = " Field access feedback: circular buffer of field observations."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_tf_field_site_t {
    pub observations: [vtx_tf_field_observation_t; 32usize],
    pub write_index: u8,
    pub count: u8,
    pub last_shapeid: vtx_shapeid_t,
    pub shape_stability_count: u32,
    pub is_shape_stable: bool,
}
#[doc = " Branch feedback: circular buffer of branch observations."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_tf_branch_site_t {
    pub observations: [vtx_tf_branch_observation_t; 32usize],
    pub write_index: u8,
    pub count: u8,
}
#[doc = " The type feedback collector manages arrays of per-site feedback.\n Sites are indexed by an integer (typically derived from bytecode PC)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_type_feedback_t {
    pub call_sites: *mut vtx_tf_call_site_t,
    pub call_site_count: u32,
    pub field_sites: *mut vtx_tf_field_site_t,
    pub field_site_count: u32,
    pub branch_sites: *mut vtx_tf_branch_site_t,
    pub branch_site_count: u32,
}
impl Default for vtx_type_feedback_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the type feedback collector with the given maximum\n number of sites for each category.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_type_feedback_init(
        feedback: *mut vtx_type_feedback_t,
        max_sites: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the type feedback collector and release all memory."]
    pub fn vtx_type_feedback_destroy(feedback: *mut vtx_type_feedback_t);
}
extern "C" {
    #[doc = " Ensure the feedback arrays can accommodate the given site index.\n Grows the arrays if necessary.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_type_feedback_ensure_site(
        feedback: *mut vtx_type_feedback_t,
        site_index: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Record a call site observation: receiver type and result type.\n site_index identifies which call site this observation belongs to."]
    pub fn vtx_type_feedback_record_call(
        feedback: *mut vtx_type_feedback_t,
        site_index: u32,
        receiver_typeid: vtx_typeid_t,
        result_typeid: vtx_typeid_t,
    );
}
extern "C" {
    #[doc = " Record a field access observation: holder shape and value type.\n site_index identifies which field site this observation belongs to."]
    pub fn vtx_type_feedback_record_field(
        feedback: *mut vtx_type_feedback_t,
        site_index: u32,
        holder_shapeid: vtx_shapeid_t,
        value_typeid: vtx_typeid_t,
    );
}
extern "C" {
    #[doc = " Record a branch observation.\n site_index identifies which branch site this observation belongs to."]
    pub fn vtx_type_feedback_record_branch(
        feedback: *mut vtx_type_feedback_t,
        site_index: u32,
        taken: bool,
    );
}
extern "C" {
    #[doc = " Get the dominant receiver type at a call site, weighted by recency.\n Uses exponential decay weighting:\n   weight[i] = 0.9^distance, where distance is how many positions\n   ago the observation was written (most recent = distance 1).\n\n Returns VTX_TYPE_INVALID if no observations."]
    pub fn vtx_type_feedback_get_dominant_call_type(
        feedback: *const vtx_type_feedback_t,
        site_index: u32,
    ) -> vtx_typeid_t;
}
extern "C" {
    #[doc = " Get the dominant field shape at a field access site, weighted by recency.\n Uses exponential decay weighting like call site queries.\n\n Returns VTX_SHAPE_INVALID if no observations."]
    pub fn vtx_type_feedback_get_dominant_field_shape(
        feedback: *const vtx_type_feedback_t,
        site_index: u32,
    ) -> vtx_shapeid_t;
}
extern "C" {
    #[doc = " Get the dominant value type at a field access site, weighted by recency.\n Uses exponential decay weighting.\n\n Returns VTX_TYPE_INVALID if no observations."]
    pub fn vtx_type_feedback_get_dominant_field_value_type(
        feedback: *const vtx_type_feedback_t,
        site_index: u32,
    ) -> vtx_typeid_t;
}
extern "C" {
    #[doc = " Get the branch probability (taken / total) at a branch site.\n Uses exponential decay weighting for recency.\n Returns 0.5 (unknown) if no observations."]
    pub fn vtx_type_feedback_get_branch_probability(
        feedback: *const vtx_type_feedback_t,
        site_index: u32,
    ) -> f64;
}
extern "C" {
    #[doc = " Get the number of unique receiver types observed at a call site."]
    pub fn vtx_type_feedback_get_call_site_type_count(
        feedback: *const vtx_type_feedback_t,
        site_index: u32,
    ) -> u32;
}
extern "C" {
    #[doc = " Get the per-type frequency distribution for a call site.\n Returns a pointer to the type_freq structure embedded in the call site.\n Returns NULL if the site does not exist.\n\n The returned pointer is valid as long as the feedback structure is valid\n and the site is not re-allocated (i.e., until vtx_type_feedback_destroy)."]
    pub fn vtx_type_feedback_get_type_freq(
        feedback: *const vtx_type_feedback_t,
        site_index: u32,
    ) -> *const vtx_type_freq_t;
}
extern "C" {
    #[doc = " Compute KL divergence between two per-type frequency distributions.\n KL(P || Q) = sum_i P(i) * log(P(i) / Q(i))\n where P = current distribution, Q = compiled-time distribution.\n\n New types not seen at compilation time receive a large penalty (10.0)\n to ensure they trigger recompilation.\n\n Returns 0.0 if either distribution has zero total observations."]
    pub fn vtx_type_freq_kl_divergence(
        current: *const vtx_type_freq_t,
        compiled: *const vtx_type_freq_t,
    ) -> f64;
}
extern "C" {
    #[doc = " Update the stable-type signature for a call site with a new observation.\n If the new observation matches the existing signature, increment stability.\n If it differs, reset the signature and stability counter.\n\n @param site       The call site to update\n @param receiver   Receiver type ID\n @param result     Result type ID"]
    pub fn vtx_tf_call_site_update_signature(
        site: *mut vtx_tf_call_site_t,
        receiver: vtx_typeid_t,
        result: vtx_typeid_t,
    );
}
extern "C" {
    #[doc = " Check if a call site is hyper-stable (signature stable for\n VTX_TYPE_STABILITY_WINDOW observations).\n\n @param site  The call site\n @return      true if hyper-stable"]
    pub fn vtx_tf_call_site_is_hyper_stable(site: *const vtx_tf_call_site_t) -> bool;
}
extern "C" {
    #[doc = " Get the stable-type signature for a call site.\n Returns NULL if the site has no observations yet.\n\n @param site  The call site\n @return      Pointer to the signature, or NULL"]
    pub fn vtx_tf_call_site_get_signature(
        site: *const vtx_tf_call_site_t,
    ) -> *const vtx_type_signature_t;
}
extern "C" {
    #[doc = " Compute a 64-bit hash of a type signature for fast comparison.\n Used by composite guards to check the entire signature in one CMP.\n\n @param sig   The type signature\n @return      64-bit hash value"]
    pub fn vtx_type_signature_hash(sig: *const vtx_type_signature_t) -> u64;
}
extern "C" {
    #[doc = " Check if a field site's shape has been stable for long enough\n to warrant shape-specialized code generation."]
    pub fn vtx_tf_field_site_is_shape_stable(site: *const vtx_tf_field_site_t) -> bool;
}
extern "C" {
    #[doc = " Get the stable shape ID for a field site.\n Returns VTX_SHAPE_INVALID if the site is not shape-stable."]
    pub fn vtx_tf_field_site_get_stable_shape(site: *const vtx_tf_field_site_t) -> vtx_shapeid_t;
}
#[doc = " A single compilation task in the priority queue."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_compile_task_t {
    pub method_id: u32,
    pub tier: vtx_compile_tier_t,
    pub heat: u32,
    pub priority: i64,
    pub submit_time: u64,
    pub task_fn: ::std::option::Option<unsafe extern "C" fn(arg: *mut ::std::os::raw::c_void)>,
    pub arg: *mut ::std::os::raw::c_void,
    pub arena: *mut vtx_arena_t,
}
impl Default for vtx_compile_task_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_priority_queue_t {
    pub tasks: *mut vtx_compile_task_t,
    pub count: u32,
    pub capacity: u32,
    pub mutex: pthread_mutex_t,
    pub lock_free: bool,
    pub starvation_threshold_ns: u64,
    pub total_pushed: u64,
    pub total_popped: u64,
    pub max_queue_depth: u64,
}
impl Default for vtx_priority_queue_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the priority queue.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_pq_init(pq: *mut vtx_priority_queue_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the priority queue and free memory."]
    pub fn vtx_pq_destroy(pq: *mut vtx_priority_queue_t);
}
extern "C" {
    #[doc = " Push a task onto the priority queue.\n The task is copied into the queue (the caller can free their copy).\n Returns 0 on success, -1 on failure."]
    pub fn vtx_pq_push(
        pq: *mut vtx_priority_queue_t,
        task: *const vtx_compile_task_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Pop the highest-priority task from the queue.\n Returns true if a task was popped, false if the queue is empty."]
    pub fn vtx_pq_pop(pq: *mut vtx_priority_queue_t, out_task: *mut vtx_compile_task_t) -> bool;
}
extern "C" {
    #[doc = " Peek at the highest-priority task without removing it.\n Returns true if a task was found, false if the queue is empty."]
    pub fn vtx_pq_peek(pq: *const vtx_priority_queue_t, out_task: *mut vtx_compile_task_t) -> bool;
}
extern "C" {
    #[doc = " Get the number of tasks in the queue."]
    pub fn vtx_pq_count(pq: *const vtx_priority_queue_t) -> u32;
}
extern "C" {
    #[doc = " Check if the queue is empty."]
    pub fn vtx_pq_is_empty(pq: *const vtx_priority_queue_t) -> bool;
}
extern "C" {
    #[doc = " Compute the effective priority of a task.\n Higher value = higher priority.\n\n Priority formula:\n   effective_priority = (tier * TIER_WEIGHT) + (heat * HEAT_WEIGHT) + starvation_boost\n\n   starvation_boost = max(0, (wait_time - threshold) / DIVISOR)\n\n This ensures:\n   - Tier dominates (T3 is always prioritized over T2)\n   - Within same tier, hotter methods are compiled first\n   - Tasks waiting too long get a boost to prevent starvation"]
    pub fn vtx_pq_task_priority(
        task: *const vtx_compile_task_t,
        starvation_threshold_ns: u64,
    ) -> i64;
}
pub const vtx_worker_state_t_VTX_WORKER_IDLE: vtx_worker_state_t = 0;
pub const vtx_worker_state_t_VTX_WORKER_COMPILING: vtx_worker_state_t = 1;
pub const vtx_worker_state_t_VTX_WORKER_SHUTDOWN: vtx_worker_state_t = 2;
#[doc = " VORTEX Compilation Thread Pool\n\n Fixed-size thread pool for concurrent method compilation. Worker threads\n pull compilation tasks from a shared priority queue.\n\n Design:\n   - VTX_COMPILE_THREADS workers (default = CPU cores - 1, minimum 1)\n   - Each worker thread has its own arena allocator for compilation\n   - Workers block on a condition variable when the queue is empty\n   - Tasks are prioritized by tier, heat, and wait time\n   - Graceful shutdown: set a shutdown flag, signal all workers,\n     wait for them to finish their current task\n\n Thread safety:\n   - The priority queue is protected by its own mutex\n   - The thread pool has a separate mutex for the condition variable\n   - No locks are held during compilation (each worker has its own arena)"]
pub type vtx_worker_state_t = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_worker_t {
    pub thread: pthread_t,
    pub worker_id: u32,
    pub state: vtx_worker_state_t,
    pub arena: vtx_arena_t,
    pub tasks_completed: u64,
    pub current_method: u32,
    pub current_tier: vtx_compile_tier_t,
}
impl Default for vtx_worker_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Compilation callback: invoked by worker threads when a task has\n method_id set but task_fn is NULL. The callback looks up the method,\n runs the pipeline, and installs the compiled code.\n\n @param method_id  Method to compile\n @param tier       Compilation tier\n @param context    User-provided context (e.g. compile context)\n @return           0 on success, -1 on failure"]
pub type vtx_compile_callback_t = ::std::option::Option<
    unsafe extern "C" fn(
        method_id: u32,
        tier: vtx_compile_tier_t,
        context: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_threadpool_t {
    pub workers: *mut vtx_worker_t,
    pub num_workers: u32,
    pub shutdown: bool,
    pub task_queue: vtx_priority_queue_t,
    pub pool_mutex: pthread_mutex_t,
    pub work_available: pthread_cond_t,
    pub compile_callback: vtx_compile_callback_t,
    pub compile_callback_context: *mut ::std::os::raw::c_void,
    pub total_tasks_completed: u64,
    pub total_tasks_submitted: u64,
    pub total_compile_time_ns: u64,
}
impl Default for vtx_threadpool_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the thread pool with the given number of worker threads.\n Creates worker threads and starts them waiting for tasks.\n\n @param pool        Thread pool to initialize\n @param num_threads Number of worker threads (0 = use VORTEX_COMPILE_THREADS)\n @return            0 on success, -1 on failure"]
    pub fn vtx_threadpool_init(
        pool: *mut vtx_threadpool_t,
        num_threads: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Set the compilation callback for the thread pool.\n\n When a worker receives a task with method_id set but task_fn == NULL,\n it calls this callback to perform the compilation. This is the fix\n for the critical bug where orchestrator-submitted tasks (which have\n method_id but no task_fn) were silently discarded.\n\n Must be called BEFORE starting any compilation tasks.\n\n @param pool     Thread pool\n @param callback Compilation callback function\n @param context  Context pointer passed to the callback"]
    pub fn vtx_threadpool_set_compile_callback(
        pool: *mut vtx_threadpool_t,
        callback: vtx_compile_callback_t,
        context: *mut ::std::os::raw::c_void,
    );
}
extern "C" {
    #[doc = " Shutdown the thread pool. Signals all workers to stop, waits for\n them to finish their current task, then destroys resources.\n\n @param pool Thread pool to shut down"]
    pub fn vtx_threadpool_shutdown(pool: *mut vtx_threadpool_t);
}
extern "C" {
    #[doc = " Submit a compilation task to the thread pool.\n\n @param pool     Thread pool\n @param task_fn  Function to execute for compilation\n @param arg      Argument to pass to task_fn\n @param priority Task priority (higher = compiled sooner)\n @return         0 on success, -1 on failure"]
    pub fn vtx_threadpool_submit(
        pool: *mut vtx_threadpool_t,
        task_fn: ::std::option::Option<unsafe extern "C" fn(arg: *mut ::std::os::raw::c_void)>,
        arg: *mut ::std::os::raw::c_void,
        priority: i64,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Submit a full compilation task (with all metadata) to the thread pool.\n\n @param pool Thread pool\n @param task Task to submit\n @return     0 on success, -1 on failure"]
    pub fn vtx_threadpool_submit_task(
        pool: *mut vtx_threadpool_t,
        task: *const vtx_compile_task_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Get the number of idle workers."]
    pub fn vtx_threadpool_idle_workers(pool: *const vtx_threadpool_t) -> u32;
}
extern "C" {
    #[doc = " Get the number of tasks in the queue."]
    pub fn vtx_threadpool_queue_depth(pool: *const vtx_threadpool_t) -> u32;
}
extern "C" {
    #[doc = " Check if the thread pool is shutting down."]
    pub fn vtx_threadpool_is_shutdown(pool: *const vtx_threadpool_t) -> bool;
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_phase_desc_t {
    pub phase_id: u32,
    pub dominant_method_ids: [u32; 8usize],
    pub dominant_method_counts: [u32; 8usize],
    pub dominant_method_count: u32,
    pub total_calls: u64,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_markov_t {
    pub transition_matrix: [[u32; 16usize]; 16usize],
    pub current_phase: u32,
    pub phases: [vtx_phase_desc_t; 16usize],
    pub phase_count: u32,
    pub method_phase_map: [u32; 256usize],
    pub total_transitions: u64,
    pub is_trained: bool,
    pub current_phase_method_calls: [u32; 256usize],
    pub current_phase_total_calls: u64,
    pub min_observations: u32,
}
impl Default for vtx_markov_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn vtx_markov_init(mk: *mut vtx_markov_t) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_markov_record_transition(mk: *mut vtx_markov_t, from_phase: u32, to_phase: u32);
}
extern "C" {
    pub fn vtx_markov_record_method_call(mk: *mut vtx_markov_t, method_id: u32);
}
extern "C" {
    pub fn vtx_markov_predict_next(mk: *mut vtx_markov_t, current_phase: u32) -> u32;
}
extern "C" {
    pub fn vtx_markov_transition_prob(mk: *mut vtx_markov_t, from: u32, to: u32) -> f64;
}
extern "C" {
    pub fn vtx_markov_predict_hot_methods(
        mk: *mut vtx_markov_t,
        next_phase: u32,
        method_ids: *mut u32,
        max_methods: u32,
    ) -> u32;
}
extern "C" {
    pub fn vtx_markov_detect_transition(mk: *mut vtx_markov_t, new_phase: *mut u32) -> bool;
}
#[doc = " VORTEX Segmented Code Cache\n\n The code cache is divided into segments of VTX_CACHE_SEGMENT_SIZE (1MB).\n Each segment is an mmap'd region of executable memory. Segments are\n allocated on demand and freed when empty.\n\n Allocation flow:\n   1. Request N bytes from vtx_code_cache_alloc()\n   2. If current segment has space, allocate from it\n   3. If not, allocate a new segment\n   4. After filling, mprotect to PROT_EXEC|PROT_READ\n\n Thread safety: The code cache is NOT thread-safe. The caller must\n synchronize access (e.g., via the compilation thread pool's lock)."]
pub type vtx_code_segment_t = vtx_code_segment;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_code_segment {
    pub memory: *mut u8,
    pub size: u32,
    pub used: u32,
    pub method_count: u32,
    pub writable: bool,
    pub next: *mut vtx_code_segment_t,
    pub free_list: *mut vtx_code_segment__bindgen_ty_1,
    pub free_count: u32,
    pub free_capacity: u32,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_code_segment__bindgen_ty_1 {
    pub offset: u32,
    pub size: u32,
}
impl Default for vtx_code_segment {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_code_cache {
    pub segments: *mut vtx_code_segment_t,
    pub current_segment: *mut vtx_code_segment_t,
    pub segment_count: u32,
    pub total_size: u64,
    pub max_size: u64,
}
impl Default for vtx_code_cache {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
pub type vtx_code_cache_t = vtx_code_cache;
extern "C" {
    #[doc = " Initialize the code cache.\n The max_size defaults to VORTEX_CACHE_MAX_SIZE.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_code_cache_init(
        cache: *mut vtx_code_cache_t,
        max_size: u64,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the code cache and unmap all segments."]
    pub fn vtx_code_cache_destroy(cache: *mut vtx_code_cache_t);
}
extern "C" {
    #[doc = " Allocate `size` bytes of executable memory from the code cache.\n The returned pointer is aligned to 16 bytes.\n\n After writing code to the allocated memory, call\n vtx_code_cache_finalize() to make the memory executable.\n\n Returns a pointer to the allocated memory, or NULL on failure."]
    pub fn vtx_code_cache_alloc(
        cache: *mut vtx_code_cache_t,
        size: u32,
    ) -> *mut ::std::os::raw::c_void;
}
extern "C" {
    #[doc = " Finalize the current segment: make it executable (PROT_EXEC|PROT_READ).\n Must be called after writing code to the allocated memory.\n\n Returns 0 on success, -1 on failure."]
    pub fn vtx_code_cache_finalize(cache: *mut vtx_code_cache_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Make a specific range executable.\n @param cache  Code cache\n @param ptr    Pointer within the cache memory\n @param size   Size of the range\n @return       0 on success, -1 on failure"]
    pub fn vtx_code_cache_make_exec(
        cache: *mut vtx_code_cache_t,
        ptr: *mut ::std::os::raw::c_void,
        size: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Make a specific range writable (for patching).\n @param cache  Code cache\n @param ptr    Pointer within the cache memory\n @param size   Size of the range\n @return       0 on success, -1 on failure"]
    pub fn vtx_code_cache_make_writable(
        cache: *mut vtx_code_cache_t,
        ptr: *mut ::std::os::raw::c_void,
        size: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Get the total number of bytes used in the cache."]
    pub fn vtx_code_cache_total_used(cache: *const vtx_code_cache_t) -> u64;
}
extern "C" {
    #[doc = " Get the total number of segments."]
    pub fn vtx_code_cache_segment_count(cache: *const vtx_code_cache_t) -> u32;
}
extern "C" {
    #[doc = " Check if the cache has exceeded its maximum size."]
    pub fn vtx_code_cache_is_full(cache: *const vtx_code_cache_t) -> bool;
}
extern "C" {
    #[doc = " Free a method's code from its segment.\n If the segment becomes empty, it is freed (unmapped).\n\n @param cache     Code cache\n @param code_ptr  Pointer to the method's code in the cache\n @param code_size Size of the method's code\n @return          0 on success, -1 on failure"]
    pub fn vtx_code_cache_free(
        cache: *mut vtx_code_cache_t,
        code_ptr: *mut ::std::os::raw::c_void,
        code_size: u32,
    ) -> ::std::os::raw::c_int;
}
#[doc = " The side table: a sorted array of entries mapping native PC offsets\n to FrameState indices and register maps."]
pub type vtx_side_table_t = vtx_side_table_struct;
#[doc = " Per-method deoptimization information stored in the JIT frame.\n Maps native PC offsets to bytecode PCs and stack states for deopt."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_deopt_info_t {
    pub method: *const vtx_method_desc_t,
    pub native_offsets: *mut u32,
    pub pc_map: *mut u32,
    pub pc_map_count: u32,
    pub stack_depth_map: *mut u32,
    pub side_table: *mut vtx_side_table_t,
}
impl Default for vtx_deopt_info_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Describes the layout of a compiled method's stack frame.\n All offsets are relative to RBP. Negative offsets point below RBP\n (locals and spills), positive offsets point above RBP (header).\n\n The total_frame_size is the number of bytes to subtract from RSP\n during prologue (locals + spills, not including the 4 pushed header values\n and the saved RBP which are handled by push instructions)."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_jit_frame_layout_t {
    pub max_locals: u32,
    pub max_stack: u32,
    pub max_spills: u32,
    pub locals_base: i32,
    pub spill_base: i32,
    pub total_frame_size: u32,
    pub frame_bottom: i32,
}
extern "C" {
    #[doc = " Compute the JIT frame layout for a method.\n\n Layout:\n   1. Frame header above RBP (pushed by prologue + CALL).\n   2. Locals below RBP, starting at RBP-8, growing downward.\n   3. Expression stack spills below locals, growing downward.\n      Spill slots = max(0, max_stack - VTX_EXPR_REG_COUNT).\n   4. Total frame size = locals_bytes + spill_bytes, rounded to 16.\n\n @param method  The method descriptor (provides max_locals, max_stack)\n @return        The computed frame layout"]
    pub fn vtx_frame_layout_compute(method: *const vtx_method_desc_t) -> vtx_jit_frame_layout_t;
}
extern "C" {
    #[doc = " Determine which physical register or spill slot holds the Nth element\n of the expression stack.\n\n The topmost VTX_EXPR_REG_COUNT (4) values are in registers:\n   TOS   → RAX (reg 0), TOS-1 → RCX (reg 1),\n   TOS-2 → RDX (reg 2), TOS-3 → RBX (reg 3).\n Values deeper than that are spilled to the frame.\n\n @param stack_index  0-based index from the bottom of the expression stack\n @param stack_depth  current depth of the expression stack\n @param layout       frame layout (for spill offset computation)\n @param[out] reg     set to the register number (0=RAX,1=RCX,2=RDX,3=RBX)\n                     if the value is in a register, or -1 if spilled\n @param[out] spill_offset  set to the RBP-relative offset if spilled,\n                           or 0 if in a register"]
    pub fn vtx_frame_layout_expr_location(
        stack_index: u32,
        stack_depth: u32,
        layout: *const vtx_jit_frame_layout_t,
        reg: *mut ::std::os::raw::c_int,
        spill_offset: *mut i32,
    );
}
pub const vtx_guard_kind_t_VTX_GUARD_TYPE_CHECK: vtx_guard_kind_t = 0;
pub const vtx_guard_kind_t_VTX_GUARD_NULL_CHECK: vtx_guard_kind_t = 1;
pub const vtx_guard_kind_t_VTX_GUARD_BOUNDS_CHECK: vtx_guard_kind_t = 2;
pub const vtx_guard_kind_t_VTX_GUARD_OVERFLOW: vtx_guard_kind_t = 3;
pub const vtx_guard_kind_t_VTX_GUARD_DIV_ZERO: vtx_guard_kind_t = 4;
#[doc = " VORTEX Baseline JIT Guard Emission\n\n Guards are speculative checks inserted by the baseline compiler.\n If a guard fails, execution transfers to a deopt stub that\n reconstructs the interpreter frame state and resumes in the\n interpreter at the correct bytecode PC.\n\n Each guard records metadata needed for deoptimization:\n   - Bytecode PC where the guard was inserted\n   - Guard kind (type check, null check, bounds check, overflow)\n   - Expected value (e.g., expected TypeID)\n   - Deopt continuation (bytecode PC to resume in interpreter)\n   - Stack depth at the guard point\n\n Guard emission writes x86-64 machine code into a code buffer.\n The emitted code performs the check and conditionally jumps to\n a deopt stub on failure."]
pub type vtx_guard_kind_t = ::std::os::raw::c_uint;
#[doc = " Metadata for a single guard. Recorded during compilation so that\n deopt stubs can be generated after the main code is emitted."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_guard_info_t {
    pub kind: vtx_guard_kind_t,
    pub bytecode_pc: u32,
    pub native_pc_offset: u32,
    pub deopt_continuation: u32,
    pub stack_depth: u32,
    pub expected_value: u64,
    pub branch_offset: i32,
}
impl Default for vtx_guard_info_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_guard_array_t {
    pub guards: *mut vtx_guard_info_t,
    pub count: u32,
    pub capacity: u32,
}
impl Default for vtx_guard_array_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize a guard array.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_guard_array_init(arr: *mut vtx_guard_array_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a guard array and free memory."]
    pub fn vtx_guard_array_destroy(arr: *mut vtx_guard_array_t);
}
extern "C" {
    #[doc = " Add a guard info record to the array.\n Returns the index of the new guard, or UINT32_MAX on failure."]
    pub fn vtx_guard_array_add(arr: *mut vtx_guard_array_t, guard: vtx_guard_info_t) -> u32;
}
pub const vtx_reg_t_VTX_REG_RAX: vtx_reg_t = 0;
pub const vtx_reg_t_VTX_REG_RCX: vtx_reg_t = 1;
pub const vtx_reg_t_VTX_REG_RDX: vtx_reg_t = 2;
pub const vtx_reg_t_VTX_REG_RBX: vtx_reg_t = 3;
pub const vtx_reg_t_VTX_REG_RSP: vtx_reg_t = 4;
pub const vtx_reg_t_VTX_REG_RBP: vtx_reg_t = 5;
pub const vtx_reg_t_VTX_REG_RSI: vtx_reg_t = 6;
pub const vtx_reg_t_VTX_REG_RDI: vtx_reg_t = 7;
pub const vtx_reg_t_VTX_REG_R8: vtx_reg_t = 8;
pub const vtx_reg_t_VTX_REG_R9: vtx_reg_t = 9;
pub const vtx_reg_t_VTX_REG_R10: vtx_reg_t = 10;
pub const vtx_reg_t_VTX_REG_R11: vtx_reg_t = 11;
pub const vtx_reg_t_VTX_REG_R12: vtx_reg_t = 12;
pub const vtx_reg_t_VTX_REG_R13: vtx_reg_t = 13;
pub const vtx_reg_t_VTX_REG_R14: vtx_reg_t = 14;
pub const vtx_reg_t_VTX_REG_R15: vtx_reg_t = 15;
pub const vtx_reg_t_VTX_REG_NONE: vtx_reg_t = 255;
#[doc = " Register numbering used by the baseline compiler.\n These correspond to x86-64 physical registers."]
pub type vtx_reg_t = ::std::os::raw::c_uint;
pub type vtx_code_buffer_t = vtx_code_buffer;
extern "C" {
    #[doc = " Emit a type check guard: verify that the object in `obj_reg` has the\n expected TypeID. If the type doesn't match, jump to a deopt stub.\n\n Generated code sequence:\n   1. Extract the heap object pointer from the tagged value in obj_reg\n   2. Load the type_id from the object header at offset 0\n   3. Compare against expected_typeid\n   4. If not equal, jump to deopt stub\n\n @param buf             Code buffer to emit into\n @param obj_reg         Register holding the tagged value (heap pointer)\n @param expected_typeid Expected TypeID to check against\n @param guard_info      Guard metadata (bytecode_pc, stack_depth, etc.)\n                        native_pc_offset is set by this function\n @param guard_arr       Guard array to record the guard (for deopt stub gen)"]
    pub fn vtx_guard_emit_type_check(
        buf: *mut vtx_code_buffer_t,
        obj_reg: vtx_reg_t,
        expected_typeid: vtx_typeid_t,
        guard_info: vtx_guard_info_t,
        guard_arr: *mut vtx_guard_array_t,
    );
}
extern "C" {
    #[doc = " Emit a null check guard: verify that the value in `obj_reg` is not null.\n If the value is null, jump to a deopt stub.\n\n Generated code sequence:\n   1. Test the tagged value against VTX_VALUE_NULL\n   2. If equal, jump to deopt stub\n\n Alternatively (for heap pointers):\n   1. Test the raw pointer value\n   2. If zero, jump to deopt stub\n\n @param buf         Code buffer to emit into\n @param obj_reg     Register holding the value to check\n @param guard_info  Guard metadata\n @param guard_arr   Guard array to record the guard"]
    pub fn vtx_guard_emit_null_check(
        buf: *mut vtx_code_buffer_t,
        obj_reg: vtx_reg_t,
        guard_info: vtx_guard_info_t,
        guard_arr: *mut vtx_guard_array_t,
    );
}
extern "C" {
    #[doc = " Emit a bounds check guard: verify that 0 <= index < length.\n If the index is out of bounds, jump to a deopt stub.\n\n Generated code sequence:\n   1. Compare index_reg (sign-extended) against 0 (unsigned comparison)\n   2. If below (index < 0 unsigned), jump to deopt\n   3. Compare index_reg against length_reg\n   4. If above-or-equal, jump to deopt\n\n @param buf          Code buffer to emit into\n @param index_reg    Register holding the index value\n @param length_reg   Register holding the length value\n @param guard_info   Guard metadata\n @param guard_arr    Guard array to record the guard"]
    pub fn vtx_guard_emit_bounds_check(
        buf: *mut vtx_code_buffer_t,
        index_reg: vtx_reg_t,
        length_reg: vtx_reg_t,
        guard_info: vtx_guard_info_t,
        guard_arr: *mut vtx_guard_array_t,
    );
}
extern "C" {
    #[doc = " Emit an overflow check guard for integer addition.\n Uses the CPU's overflow flag after an add instruction.\n\n Generated code sequence:\n   1. After the add instruction, check the overflow flag (JO)\n   2. If overflow, jump to deopt stub\n\n @param buf         Code buffer to emit into\n @param guard_info  Guard metadata\n @param guard_arr   Guard array to record the guard"]
    pub fn vtx_guard_emit_overflow_check(
        buf: *mut vtx_code_buffer_t,
        guard_info: vtx_guard_info_t,
        guard_arr: *mut vtx_guard_array_t,
    );
}
extern "C" {
    #[doc = " Emit a division-by-zero guard.\n\n Generated code sequence:\n   1. Test the divisor register\n   2. If zero, jump to deopt stub\n\n @param buf          Code buffer to emit into\n @param divisor_reg  Register holding the divisor value\n @param guard_info   Guard metadata\n @param guard_arr    Guard array to record the guard"]
    pub fn vtx_guard_emit_div_zero_check(
        buf: *mut vtx_code_buffer_t,
        divisor_reg: vtx_reg_t,
        guard_info: vtx_guard_info_t,
        guard_arr: *mut vtx_guard_array_t,
    );
}
#[doc = " VORTEX Sea-of-Nodes IR — Node Taxonomy\n\n Every value, control point, memory operation, allocation, and deoptimization\n marker in the IR is represented as a Node. Nodes reference each other by\n NodeID (uint32_t). The graph is stored in a flat node table with growing\n capacity. NodeIDs are never reused within a compilation.\n\n Node inputs form a directed graph. Control, memory, and data edges are\n distinguished by per-node flags, not by input position — the consumer\n inspects the producer's flags to determine edge kind."]
pub type vtx_nodeid_t = u32;
pub const vtx_node_opcode_t_VTX_OP_Start: vtx_node_opcode_t = 0;
pub const vtx_node_opcode_t_VTX_OP_End: vtx_node_opcode_t = 1;
pub const vtx_node_opcode_t_VTX_OP_If: vtx_node_opcode_t = 2;
pub const vtx_node_opcode_t_VTX_OP_Goto: vtx_node_opcode_t = 3;
pub const vtx_node_opcode_t_VTX_OP_Switch: vtx_node_opcode_t = 4;
pub const vtx_node_opcode_t_VTX_OP_LoopBegin: vtx_node_opcode_t = 5;
pub const vtx_node_opcode_t_VTX_OP_LoopEnd: vtx_node_opcode_t = 6;
pub const vtx_node_opcode_t_VTX_OP_Return: vtx_node_opcode_t = 7;
pub const vtx_node_opcode_t_VTX_OP_Unwind: vtx_node_opcode_t = 8;
pub const vtx_node_opcode_t_VTX_OP_Catch: vtx_node_opcode_t = 9;
pub const vtx_node_opcode_t_VTX_OP_Province: vtx_node_opcode_t = 10;
pub const vtx_node_opcode_t_VTX_OP_Constant: vtx_node_opcode_t = 11;
pub const vtx_node_opcode_t_VTX_OP_Parameter: vtx_node_opcode_t = 12;
pub const vtx_node_opcode_t_VTX_OP_Add: vtx_node_opcode_t = 13;
pub const vtx_node_opcode_t_VTX_OP_Sub: vtx_node_opcode_t = 14;
pub const vtx_node_opcode_t_VTX_OP_Mul: vtx_node_opcode_t = 15;
pub const vtx_node_opcode_t_VTX_OP_Div: vtx_node_opcode_t = 16;
pub const vtx_node_opcode_t_VTX_OP_Mod: vtx_node_opcode_t = 17;
pub const vtx_node_opcode_t_VTX_OP_Shl: vtx_node_opcode_t = 18;
pub const vtx_node_opcode_t_VTX_OP_Shr: vtx_node_opcode_t = 19;
pub const vtx_node_opcode_t_VTX_OP_Sar: vtx_node_opcode_t = 20;
pub const vtx_node_opcode_t_VTX_OP_And: vtx_node_opcode_t = 21;
pub const vtx_node_opcode_t_VTX_OP_Or: vtx_node_opcode_t = 22;
pub const vtx_node_opcode_t_VTX_OP_Xor: vtx_node_opcode_t = 23;
pub const vtx_node_opcode_t_VTX_OP_Neg: vtx_node_opcode_t = 24;
pub const vtx_node_opcode_t_VTX_OP_Not: vtx_node_opcode_t = 25;
pub const vtx_node_opcode_t_VTX_OP_Cmp: vtx_node_opcode_t = 26;
pub const vtx_node_opcode_t_VTX_OP_CmpP: vtx_node_opcode_t = 27;
pub const vtx_node_opcode_t_VTX_OP_CmpF: vtx_node_opcode_t = 28;
pub const vtx_node_opcode_t_VTX_OP_CmpD: vtx_node_opcode_t = 29;
pub const vtx_node_opcode_t_VTX_OP_AddF: vtx_node_opcode_t = 30;
pub const vtx_node_opcode_t_VTX_OP_SubF: vtx_node_opcode_t = 31;
pub const vtx_node_opcode_t_VTX_OP_MulF: vtx_node_opcode_t = 32;
pub const vtx_node_opcode_t_VTX_OP_DivF: vtx_node_opcode_t = 33;
pub const vtx_node_opcode_t_VTX_OP_NegF: vtx_node_opcode_t = 34;
pub const vtx_node_opcode_t_VTX_OP_Min: vtx_node_opcode_t = 35;
pub const vtx_node_opcode_t_VTX_OP_Max: vtx_node_opcode_t = 36;
pub const vtx_node_opcode_t_VTX_OP_Load: vtx_node_opcode_t = 37;
pub const vtx_node_opcode_t_VTX_OP_Store: vtx_node_opcode_t = 38;
pub const vtx_node_opcode_t_VTX_OP_LoadField: vtx_node_opcode_t = 39;
pub const vtx_node_opcode_t_VTX_OP_StoreField: vtx_node_opcode_t = 40;
pub const vtx_node_opcode_t_VTX_OP_LoadIndexed: vtx_node_opcode_t = 41;
pub const vtx_node_opcode_t_VTX_OP_StoreIndexed: vtx_node_opcode_t = 42;
pub const vtx_node_opcode_t_VTX_OP_MemBar: vtx_node_opcode_t = 43;
pub const vtx_node_opcode_t_VTX_OP_Initialize: vtx_node_opcode_t = 44;
pub const vtx_node_opcode_t_VTX_OP_CallStatic: vtx_node_opcode_t = 45;
pub const vtx_node_opcode_t_VTX_OP_CallVirtual: vtx_node_opcode_t = 46;
pub const vtx_node_opcode_t_VTX_OP_CallInterface: vtx_node_opcode_t = 47;
pub const vtx_node_opcode_t_VTX_OP_CallRuntime: vtx_node_opcode_t = 48;
pub const vtx_node_opcode_t_VTX_OP_CheckCast: vtx_node_opcode_t = 49;
pub const vtx_node_opcode_t_VTX_OP_InstanceOf: vtx_node_opcode_t = 50;
pub const vtx_node_opcode_t_VTX_OP_Guard: vtx_node_opcode_t = 51;
pub const vtx_node_opcode_t_VTX_OP_Phi: vtx_node_opcode_t = 52;
pub const vtx_node_opcode_t_VTX_OP_Region: vtx_node_opcode_t = 53;
pub const vtx_node_opcode_t_VTX_OP_Proj: vtx_node_opcode_t = 54;
pub const vtx_node_opcode_t_VTX_OP_ExceptProj: vtx_node_opcode_t = 55;
pub const vtx_node_opcode_t_VTX_OP_NewObject: vtx_node_opcode_t = 56;
pub const vtx_node_opcode_t_VTX_OP_NewArray: vtx_node_opcode_t = 57;
pub const vtx_node_opcode_t_VTX_OP_Allocate: vtx_node_opcode_t = 58;
pub const vtx_node_opcode_t_VTX_OP_InitializeKlass: vtx_node_opcode_t = 59;
pub const vtx_node_opcode_t_VTX_OP_Deopt: vtx_node_opcode_t = 60;
pub const vtx_node_opcode_t_VTX_OP_DeoptGuard: vtx_node_opcode_t = 61;
pub const vtx_node_opcode_t_VTX_OP_FrameState: vtx_node_opcode_t = 62;
pub const vtx_node_opcode_t_VTX_OP_VectorLoad: vtx_node_opcode_t = 63;
pub const vtx_node_opcode_t_VTX_OP_VectorStore: vtx_node_opcode_t = 64;
pub const vtx_node_opcode_t_VTX_OP_VectorAdd: vtx_node_opcode_t = 65;
pub const vtx_node_opcode_t_VTX_OP_VectorMul: vtx_node_opcode_t = 66;
pub const vtx_node_opcode_t_VTX_OP_UnboxInt: vtx_node_opcode_t = 67;
pub const vtx_node_opcode_t_VTX_OP_BoxInt: vtx_node_opcode_t = 68;
pub const vtx_node_opcode_t_VTX_NODE_OP_COUNT: vtx_node_opcode_t = 69;
pub type vtx_node_opcode_t = ::std::os::raw::c_uint;
pub const vtx_nodetype_t_VTX_TYPE_Bottom: vtx_nodetype_t = 0;
pub const vtx_nodetype_t_VTX_TYPE_Int: vtx_nodetype_t = 1;
pub const vtx_nodetype_t_VTX_TYPE_Float: vtx_nodetype_t = 2;
pub const vtx_nodetype_t_VTX_TYPE_Ptr: vtx_nodetype_t = 3;
pub const vtx_nodetype_t_VTX_TYPE_Void: vtx_nodetype_t = 4;
pub const vtx_nodetype_t_VTX_TYPE_Top: vtx_nodetype_t = 5;
#[doc = " Each node carries a type from a simple lattice:\n\n   Top (unreachable / not yet computed)\n    |\n   Int / Float / Ptr / Void  (concrete types)\n    |\n   Bottom (overdefined / multiple types meet)"]
pub type vtx_nodetype_t = ::std::os::raw::c_uint;
pub const vtx_node_flags_t_VTX_NF_NONE: vtx_node_flags_t = 0;
pub const vtx_node_flags_t_VTX_NF_CONTROL: vtx_node_flags_t = 1;
pub const vtx_node_flags_t_VTX_NF_MEMORY: vtx_node_flags_t = 2;
pub const vtx_node_flags_t_VTX_NF_DATA: vtx_node_flags_t = 4;
pub const vtx_node_flags_t_VTX_NF_SIDE_EFFECT: vtx_node_flags_t = 8;
pub const vtx_node_flags_t_VTX_NF_PINNED: vtx_node_flags_t = 16;
pub const vtx_node_flags_t_VTX_NF_WRITE_BARRIER: vtx_node_flags_t = 32;
pub const vtx_node_flags_t_VTX_NF_RAW_INT: vtx_node_flags_t = 64;
pub type vtx_node_flags_t = ::std::os::raw::c_uint;
#[doc = " For VTX_OP_Constant nodes, the value field holds the actual constant.\n We use a tagged union discriminated by the node's vtx_nodetype_t."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_constval_t {
    pub kind: vtx_nodetype_t,
    pub as_: vtx_constval_t__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union vtx_constval_t__bindgen_ty_1 {
    pub int_val: i64,
    pub float_val: f64,
    pub ptr_val: *mut ::std::os::raw::c_void,
}
impl Default for vtx_constval_t__bindgen_ty_1 {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
impl Default for vtx_constval_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
pub const vtx_cond_t_VTX_COND_EQ: vtx_cond_t = 0;
pub const vtx_cond_t_VTX_COND_NE: vtx_cond_t = 1;
pub const vtx_cond_t_VTX_COND_LT: vtx_cond_t = 2;
pub const vtx_cond_t_VTX_COND_LE: vtx_cond_t = 3;
pub const vtx_cond_t_VTX_COND_GT: vtx_cond_t = 4;
pub const vtx_cond_t_VTX_COND_GE: vtx_cond_t = 5;
pub const vtx_cond_t_VTX_COND_ULT: vtx_cond_t = 6;
pub const vtx_cond_t_VTX_COND_ULE: vtx_cond_t = 7;
pub const vtx_cond_t_VTX_COND_UGT: vtx_cond_t = 8;
pub const vtx_cond_t_VTX_COND_UGE: vtx_cond_t = 9;
pub const vtx_cond_t_VTX_COND_ALWAYS: vtx_cond_t = 10;
pub const vtx_cond_t_VTX_COND_NEVER: vtx_cond_t = 11;
pub type vtx_cond_t = ::std::os::raw::c_uint;
#[doc = " Use-def list: nodes that reference this node as an input.\n This is the inverse of the inputs array. For each node N that\n has N->inputs[i] == this->id, there is a use entry (N, i).\n\n This enables O(K) traversal of a node's users (where K is the\n number of users) instead of O(N²) scanning of all nodes."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_use_entry {
    pub user_id: vtx_nodeid_t,
    pub input_index: u32,
}
#[doc = " Use-def list: nodes that reference this node as an input.\n This is the inverse of the inputs array. For each node N that\n has N->inputs[i] == this->id, there is a use entry (N, i).\n\n This enables O(K) traversal of a node's users (where K is the\n number of users) instead of O(N²) scanning of all nodes."]
pub type vtx_use_entry_t = vtx_use_entry;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_node_t {
    pub id: vtx_nodeid_t,
    pub opcode: vtx_node_opcode_t,
    pub type_: vtx_nodetype_t,
    pub flags: vtx_node_flags_t,
    pub inputs: *mut vtx_nodeid_t,
    pub input_count: u32,
    pub input_capacity: u32,
    pub constval: vtx_constval_t,
    pub cond: vtx_cond_t,
    pub local_index: u32,
    pub field_offset: u32,
    pub method_index: u32,
    pub type_id: u32,
    pub bytecode_pc: u32,
    pub frame_state: vtx_nodeid_t,
    pub output_count: u32,
    pub uses: *mut vtx_use_entry_t,
    pub use_count: u32,
    pub use_capacity: u32,
    pub value_number: u32,
    pub dead: bool,
    pub mark: bool,
}
impl Default for vtx_node_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_node_opcode_info_t {
    pub name: *const ::std::os::raw::c_char,
    pub default_flags: vtx_node_flags_t,
    pub fixed_inputs: u32,
}
impl Default for vtx_node_opcode_info_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_node_table_t {
    pub nodes: *mut vtx_node_t,
    pub count: u32,
    pub capacity: u32,
    pub next_id: vtx_nodeid_t,
}
impl Default for vtx_node_table_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize a node table with initial capacity.\n Returns 0 on success, -1 on failure (allocation error)."]
    pub fn vtx_node_table_init(
        table: *mut vtx_node_table_t,
        initial_capacity: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a node table and free all memory (inputs arrays + nodes array)."]
    pub fn vtx_node_table_destroy(table: *mut vtx_node_table_t);
}
extern "C" {
    #[doc = " Create a new node in the table with the given opcode.\n Sets id, opcode, type (Top), flags (from opcode metadata), empty inputs.\n Returns the new node's ID, or VTX_NODEID_INVALID on failure."]
    pub fn vtx_node_create(table: *mut vtx_node_table_t, opcode: vtx_node_opcode_t)
        -> vtx_nodeid_t;
}
extern "C" {
    #[doc = " Look up a node by ID. Returns NULL if the ID is invalid or out of range."]
    pub fn vtx_node_get(table: *mut vtx_node_table_t, id: vtx_nodeid_t) -> *mut vtx_node_t;
}
extern "C" {
    #[doc = " Look up a const node by ID. Returns NULL if the ID is invalid."]
    pub fn vtx_node_get_const(
        table: *const vtx_node_table_t,
        id: vtx_nodeid_t,
    ) -> *const vtx_node_t;
}
extern "C" {
    #[doc = " Add an input edge from this node to the producer with the given ID.\n Increments the producer's output_count.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_node_add_input(
        table: *mut vtx_node_table_t,
        consumer: vtx_nodeid_t,
        producer: vtx_nodeid_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Remove the input at the given index from the consumer node.\n Decrements the producer's output_count.\n Shifts subsequent inputs down by one.\n Returns 0 on success, -1 on failure (index out of bounds)."]
    pub fn vtx_node_remove_input(
        table: *mut vtx_node_table_t,
        consumer: vtx_nodeid_t,
        index: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Replace the input at the given index with a new producer.\n Decrements old producer's output_count and increments new producer's output_count.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_node_replace_input(
        table: *mut vtx_node_table_t,
        consumer: vtx_nodeid_t,
        index: u32,
        new_producer: vtx_nodeid_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Find the first input index that matches the given producer ID.\n Returns the index, or -1 if not found."]
    pub fn vtx_node_find_input(
        node: *const vtx_node_t,
        producer: vtx_nodeid_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Compute the default type for a given opcode (before any propagation)."]
    pub fn vtx_node_default_type(opcode: vtx_node_opcode_t) -> vtx_nodetype_t;
}
extern "C" {
    #[doc = " Get the human-readable name for an opcode."]
    pub fn vtx_node_opcode_name(opcode: vtx_node_opcode_t) -> *const ::std::os::raw::c_char;
}
extern "C" {
    #[doc = " Get the human-readable name for a node type."]
    pub fn vtx_nodetype_name(t: vtx_nodetype_t) -> *const ::std::os::raw::c_char;
}
extern "C" {
    #[doc = " Check whether a node has side effects and must be kept by DCE."]
    pub fn vtx_node_is_side_effecting(opcode: vtx_node_opcode_t) -> bool;
}
extern "C" {
    #[doc = " Check whether a node is a control node."]
    pub fn vtx_node_is_control(opcode: vtx_node_opcode_t) -> bool;
}
extern "C" {
    #[doc = " Check whether a node is a memory node."]
    pub fn vtx_node_is_memory(opcode: vtx_node_opcode_t) -> bool;
}
extern "C" {
    #[doc = " Check whether a node is a pure data node."]
    pub fn vtx_node_is_data(opcode: vtx_node_opcode_t) -> bool;
}
extern "C" {
    #[doc = " Check whether two constant values are equal."]
    pub fn vtx_constval_equal(a: vtx_constval_t, b: vtx_constval_t) -> bool;
}
extern "C" {
    #[doc = " Hash a constant value."]
    pub fn vtx_constval_hash(v: vtx_constval_t) -> u32;
}
extern "C" {
    #[doc = " Clear all mark bits in the node table."]
    pub fn vtx_node_table_clear_marks(table: *mut vtx_node_table_t);
}
extern "C" {
    #[doc = " Clear all dead flags in the node table."]
    pub fn vtx_node_table_clear_dead(table: *mut vtx_node_table_t);
}
extern "C" {
    #[doc = " Get a pointer to the first use entry of a node.\n Returns NULL if the node has no uses."]
    pub fn vtx_node_uses_begin(node: *mut vtx_node_t) -> *mut vtx_use_entry_t;
}
extern "C" {
    #[doc = " Get a pointer one past the last use entry of a node."]
    pub fn vtx_node_uses_end(node: *mut vtx_node_t) -> *mut vtx_use_entry_t;
}
extern "C" {
    #[doc = " Get a const pointer to the first use entry of a node."]
    pub fn vtx_node_uses_begin_const(node: *const vtx_node_t) -> *const vtx_use_entry_t;
}
extern "C" {
    #[doc = " Get a const pointer one past the last use entry of a node."]
    pub fn vtx_node_uses_end_const(node: *const vtx_node_t) -> *const vtx_use_entry_t;
}
extern "C" {
    #[doc = " Replace ALL uses of old_id with new_id throughout the graph.\n This is the O(K) version of what was previously O(N²) —\n it walks old_id's use list and updates each user's input.\n\n Returns 0 on success, -1 on failure."]
    pub fn vtx_node_replace_all_uses(
        table: *mut vtx_node_table_t,
        old_id: vtx_nodeid_t,
        new_id: vtx_nodeid_t,
    ) -> ::std::os::raw::c_int;
}
#[doc = " Callback type for vtx_node_for_each_user.\n Called with (table, user_id, input_index, context).\n Return 0 to continue iteration, non-zero to stop."]
pub type vtx_user_callback_t = ::std::option::Option<
    unsafe extern "C" fn(
        table: *mut vtx_node_table_t,
        user_id: vtx_nodeid_t,
        input_index: u32,
        context: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
extern "C" {
    #[doc = " Iterate over all users of a node, calling fn for each use entry.\n Stops early if fn returns non-zero.\n Returns the last return value from fn (0 if all calls returned 0)."]
    pub fn vtx_node_for_each_user(
        table: *mut vtx_node_table_t,
        node_id: vtx_nodeid_t,
        fn_: vtx_user_callback_t,
        context: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Remove a use entry (user_id, input_index) from the producer's use-def list.\n This is the public wrapper around the internal node_remove_use helper.\n Used by passes like DCE that need to maintain use-def list consistency\n when disconnecting edges without going through the full add/remove input API."]
    pub fn vtx_node_remove_use_entry(
        producer: *mut vtx_node_t,
        user_id: vtx_nodeid_t,
        input_index: u32,
    );
}
extern "C" {
    #[doc = " Add a use entry (user_id, input_index) to the producer's use-def list.\n This is the public wrapper around the internal node_add_use helper.\n Used by passes that need to maintain use-def list consistency when\n adding edges without going through the full add input API."]
    pub fn vtx_node_add_use_entry(
        producer: *mut vtx_node_t,
        user_id: vtx_nodeid_t,
        input_index: u32,
    );
}
#[doc = " Represents the state of a single monitor (lock) held at a deopt point.\n The monitor_object is a NodeID that evaluates to the locked object."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_monitor_state_t {
    pub monitor_object: vtx_nodeid_t,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_exception_state_t {
    pub handler_pc: u32,
    pub catch_type: vtx_typeid_t,
}
#[doc = " Complete execution state at a single deopt point.\n\n locals and stack are arrays of NodeIDs. Each NodeID represents the\n SoN node that produces the value in that slot at the deopt point.\n VTX_NODEID_INVALID means the slot is undefined/unused.\n\n The structure is allocated from an arena (no individual free)."]
pub type vtx_frame_state_t = vtx_frame_state;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_frame_state {
    pub bytecode_pc: u32,
    pub method_id: u32,
    pub locals: *mut vtx_nodeid_t,
    pub local_count: u32,
    pub stack: *mut vtx_nodeid_t,
    pub stack_count: u32,
    pub monitors: *mut vtx_monitor_state_t,
    pub monitor_count: u32,
    pub exception: vtx_exception_state_t,
    pub caller: *mut vtx_frame_state_t,
    pub relock_needed: bool,
}
impl Default for vtx_frame_state {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Create a FrameState allocated from the given arena.\n Allocates locals and stack arrays from the arena.\n Returns NULL on allocation failure.\n\n @param arena      Arena to allocate from\n @param pc         Bytecode PC at the deopt point\n @param method_id  Method identifier\n @param local_count Number of local variable slots\n @param stack_count Number of operand stack slots"]
    pub fn vtx_frame_state_create(
        arena: *mut vtx_arena_t,
        pc: u32,
        method_id: u32,
        local_count: u32,
        stack_count: u32,
    ) -> *mut vtx_frame_state_t;
}
extern "C" {
    #[doc = " Create a chain of FrameStates representing a full call stack.\n The frames array is ordered from innermost (callee) to outermost (caller).\n Each frame's `caller` pointer is set to the next frame in the array.\n\n @param arena       Arena to allocate from\n @param frame_pcs   Array of bytecode PCs (innermost first)\n @param method_ids  Array of method IDs (innermost first)\n @param local_counts  Array of local counts (innermost first)\n @param stack_counts   Array of stack counts (innermost first)\n @param depth       Number of frames in the chain\n @return The innermost FrameState (head of the chain), or NULL on failure"]
    pub fn vtx_frame_state_chain_create(
        arena: *mut vtx_arena_t,
        frame_pcs: *const u32,
        method_ids: *const u32,
        local_counts: *const u32,
        stack_counts: *const u32,
        depth: u32,
    ) -> *mut vtx_frame_state_t;
}
extern "C" {
    #[doc = " Walk the caller chain and return the depth (number of frames)."]
    pub fn vtx_frame_state_chain_depth(fs: *const vtx_frame_state_t) -> u32;
}
extern "C" {
    #[doc = " Find the FrameState for the nth caller (0 = self, 1 = caller, etc.).\n Returns NULL if n exceeds the chain depth."]
    pub fn vtx_frame_state_nth_caller(
        fs: *const vtx_frame_state_t,
        n: u32,
    ) -> *const vtx_frame_state_t;
}
#[doc = " A single entry in the register map: which register holds which NodeID.\n The register number is architecture-specific (e.g., RAX=0, RCX=1, etc.\n on x86-64)."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_reg_map_entry_t {
    pub register_number: u32,
    pub node_id: vtx_nodeid_t,
}
#[doc = " A single entry in the side table: maps a native PC offset to a FrameState\n and provides the register map for reconstructing values."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_side_table_entry_t {
    pub native_pc_offset: u32,
    pub frame_state_index: u32,
    pub register_map: *mut vtx_reg_map_entry_t,
    pub register_map_count: u32,
    pub flags: u32,
}
impl Default for vtx_side_table_entry_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " The side table: a sorted array of entries mapping native PC offsets\n to FrameState indices and register maps."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_side_table_struct {
    pub entries: *mut vtx_side_table_entry_t,
    pub entry_count: u32,
    pub entry_capacity: u32,
    pub frame_states: *mut *mut vtx_frame_state_t,
    pub frame_state_count: u32,
    pub frame_state_capacity: u32,
}
impl Default for vtx_side_table_struct {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Build a new side table. If arena is non-NULL, entries are allocated from it.\n If arena is NULL, entries are allocated with malloc.\n Returns a new side table, or NULL on failure."]
    pub fn vtx_side_table_build(arena: *mut vtx_arena_t) -> *mut vtx_side_table_t;
}
extern "C" {
    #[doc = " Destroy a side table and free all memory.\n Only frees malloc'd tables (not arena-allocated ones)."]
    pub fn vtx_side_table_destroy(table: *mut vtx_side_table_t);
}
extern "C" {
    #[doc = " Add an entry to the side table. Entries must be added in increasing\n native_pc_offset order (this is natural since code is emitted sequentially).\n Returns the index of the new entry, or UINT32_MAX on failure.\n\n @param table             The side table\n @param native_pc_offset  Native PC offset of the deopt point\n @param frame_state_index Index into the FrameState array\n @param flags             Bit flags for this entry\n @return Entry index, or UINT32_MAX on failure"]
    pub fn vtx_side_table_add_entry(
        table: *mut vtx_side_table_t,
        native_pc_offset: u32,
        frame_state_index: u32,
        flags: u32,
    ) -> u32;
}
extern "C" {
    #[doc = " Add a register map entry to the most recently added side table entry.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_side_table_add_register(
        table: *mut vtx_side_table_t,
        register_number: u32,
        node_id: vtx_nodeid_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Register a FrameState with the side table. Returns the index.\n The FrameState pointer is stored; it must remain valid for the\n lifetime of the side table."]
    pub fn vtx_side_table_add_frame_state(
        table: *mut vtx_side_table_t,
        fs: *mut vtx_frame_state_t,
    ) -> u32;
}
extern "C" {
    #[doc = " Get a FrameState by index."]
    pub fn vtx_side_table_get_frame_state(
        table: *const vtx_side_table_t,
        index: u32,
    ) -> *mut vtx_frame_state_t;
}
extern "C" {
    #[doc = " Look up the side table entry for a given native PC offset.\n Uses binary search on the sorted entries array.\n\n If an exact match is not found, returns the entry with the largest\n native_pc_offset that is <= the given pc. This is correct because\n the side table entry at or before the PC describes the state at that point.\n\n Returns the frame_state_index, or UINT32_MAX if no entry exists\n at or before the given PC."]
    pub fn vtx_side_table_lookup(table: *const vtx_side_table_t, native_pc_offset: u32) -> u32;
}
extern "C" {
    #[doc = " Look up the full side table entry for a given native PC offset.\n Same semantics as vtx_side_table_lookup, but returns the full entry.\n Returns NULL if no entry is found."]
    pub fn vtx_side_table_lookup_entry(
        table: *const vtx_side_table_t,
        native_pc_offset: u32,
    ) -> *const vtx_side_table_entry_t;
}
extern "C" {
    #[doc = " Get a side table entry by its index."]
    pub fn vtx_side_table_get_entry(
        table: *const vtx_side_table_t,
        index: u32,
    ) -> *const vtx_side_table_entry_t;
}
extern "C" {
    #[doc = " Get the number of entries in the side table."]
    pub fn vtx_side_table_entry_count(table: *const vtx_side_table_t) -> u32;
}
extern "C" {
    #[doc = " Look up the NodeID held in a specific register at a given native PC.\n Returns VTX_NODEID_INVALID if the register is not mapped at that PC."]
    pub fn vtx_side_table_find_register(
        table: *const vtx_side_table_t,
        native_pc_offset: u32,
        register_number: u32,
    ) -> vtx_nodeid_t;
}
extern "C" {
    #[doc = " Get the full register map for a given native PC offset.\n Sets *out_count to the number of register map entries.\n Returns a pointer to the first entry, or NULL if no entry found."]
    pub fn vtx_side_table_get_register_map(
        table: *const vtx_side_table_t,
        native_pc_offset: u32,
        out_count: *mut u32,
    ) -> *const vtx_reg_map_entry_t;
}
extern "C" {
    #[doc = " Record a safepoint with GC root map at the given native PC offset.\n\n Creates a side table entry at the given native PC offset, flagged with\n VTX_STF_SAFEPPOINT, and records the GC root map (which NodeIDs hold\n object references at this point). The root_node_ids array must remain\n valid for the lifetime of the side table (typically arena-allocated).\n\n @param table             The side table\n @param native_pc_offset  Native PC offset of the safepoint\n @param root_node_ids     Array of NodeIDs that are GC roots at this point\n @param root_count        Number of entries in root_node_ids\n @return                  0 on success, -1 on failure"]
    pub fn vtx_side_table_record_safepoint(
        table: *mut vtx_side_table_t,
        native_pc_offset: u32,
        root_node_ids: *const u32,
        root_count: u32,
    ) -> ::std::os::raw::c_int;
}
#[doc = " VORTEX Baseline JIT Deoptimization Stub Generation\n\n For each guard that can fail, a deopt stub is generated. When a guard\n fails, execution jumps to the deopt stub which:\n\n   1. Saves all live register values into the JIT frame (locals and\n      spill slots) so the interpreter can find them.\n   2. Reconstructs the interpreter operand stack from the JIT frame\n      state: register-resident values are stored into the interpreter\n      stack frame, spill slot values are copied.\n   3. Restores the interpreter frame pointer from the JIT frame header.\n   4. Sets the interpreter's bytecode PC to the deopt continuation point.\n   5. Jumps to the interpreter dispatch loop.\n\n The deopt stubs are appended after the main method code in the same\n code buffer. Each stub is a self-contained sequence that does not\n fall through to the next stub."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_deopt_stub_t {
    pub native_code: *mut u8,
    pub native_code_size: u32,
    pub native_code_offset: u32,
    pub guard_index: u32,
    pub bytecode_pc: u32,
    pub stack_depth: u32,
    pub frame_state_index: u32,
}
impl Default for vtx_deopt_stub_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_deopt_stub_array_t {
    pub stubs: *mut vtx_deopt_stub_t,
    pub count: u32,
    pub capacity: u32,
}
impl Default for vtx_deopt_stub_array_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize a deopt stub array.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_deopt_stub_array_init(arr: *mut vtx_deopt_stub_array_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a deopt stub array."]
    pub fn vtx_deopt_stub_array_destroy(arr: *mut vtx_deopt_stub_array_t);
}
extern "C" {
    #[doc = " Add a deopt stub to the array.\n Returns the index, or UINT32_MAX on failure."]
    pub fn vtx_deopt_stub_array_add(
        arr: *mut vtx_deopt_stub_array_t,
        stub: vtx_deopt_stub_t,
    ) -> u32;
}
#[doc = " Context for deopt stub generation. Passed between the stub emitter\n and the code generator to resolve addresses and offsets."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_deopt_context_t {
    pub code_buf: *mut vtx_code_buffer_t,
    pub guards: *mut vtx_guard_array_t,
    pub frame_layout: vtx_jit_frame_layout_t,
    pub side_table: *mut vtx_side_table_t,
    pub arena: *mut vtx_arena_t,
    pub code_start: *mut u8,
    pub method_id: u32,
    pub stub_array: *mut vtx_deopt_stub_array_t,
}
impl Default for vtx_deopt_context_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Generate deopt stubs for all guards in the guard array.\n\n For each guard, emits a deopt stub after the main method code.\n Patches the guard's conditional jump to point to the stub.\n\n Each stub performs:\n   1. Save all expression stack registers (RAX, RCX, RDX, RBX) to\n      their spill slots in the JIT frame.\n   2. Set up the interpreter frame pointer from the JIT frame's\n      caller RBP slot.\n   3. Store the bytecode PC (deopt continuation) into a well-known\n      location that the interpreter reads on entry.\n   4. Copy locals from the JIT frame to the interpreter frame.\n   5. Reconstruct the interpreter operand stack from the saved\n      register values and spill slots.\n   6. Jump to the interpreter dispatch loop entry point.\n\n @param ctx  Deopt context with all necessary references\n @return     Number of stubs generated, or -1 on failure"]
    pub fn vtx_deopt_stubs_emit_all(ctx: *mut vtx_deopt_context_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Generate a single deopt stub for a specific guard.\n\n @param ctx          Deopt context\n @param guard_index  Index of the guard in the guard array\n @return             The deopt stub descriptor, or NULL on failure"]
    pub fn vtx_deopt_stub_emit(
        ctx: *mut vtx_deopt_context_t,
        guard_index: u32,
    ) -> *const vtx_deopt_stub_t;
}
extern "C" {
    #[doc = " Patch all guard conditional jumps to point to their deopt stubs.\n Must be called after all stubs have been emitted.\n\n @param ctx  Deopt context\n @return     0 on success, -1 on failure"]
    pub fn vtx_deopt_stubs_patch_guards(ctx: *mut vtx_deopt_context_t) -> ::std::os::raw::c_int;
}
#[doc = " Get the address of the interpreter re-entry point.\n This is where deopt stubs jump to resume interpretation.\n The re-entry point expects:\n   - RBP = interpreter frame pointer\n   - RIP-relative stored bytecode PC\n   - Operand stack reconstructed in the interpreter frame\n\n This function returns a function pointer that the runtime must\n provide (the interpreter dispatch loop entry)."]
pub type vtx_interp_entry_t = ::std::option::Option<unsafe extern "C" fn()>;
extern "C" {
    #[doc = " Set the interpreter entry point for deopt stubs to jump to.\n Must be called before any deopt stubs are generated."]
    pub fn vtx_deopt_set_interp_entry(entry: vtx_interp_entry_t);
}
extern "C" {
    #[doc = " Get the current interpreter entry point."]
    pub fn vtx_deopt_get_interp_entry() -> vtx_interp_entry_t;
}
extern "C" {
    pub fn vtx_deopt_interp_entry_wrapper();
}
extern "C" {
    #[doc = " Deoptimization runtime function. Called by deopt stubs to transition\n from JIT code back to the interpreter.\n\n This function:\n   1. Reads the deopt info from the current frame\n   2. Reconstructs the interpreter frame\n   3. Returns the interpreter frame pointer and bytecode PC\n\n @param jit_rbp    The JIT frame's RBP value\n @param native_pc  The native PC where deopt occurred\n @return           The interpreter frame pointer (or NULL on error)"]
    pub fn vtx_deopt_runtime_transition(
        jit_rbp: *mut ::std::os::raw::c_void,
        native_pc: u32,
    ) -> *mut ::std::os::raw::c_void;
}
#[doc = " Configuration for tier-aware deoptimization (Proposal #5).\n When a deopt stub is entered, it checks whether a lower-tier compiled\n version exists before falling back to the interpreter."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_deopt_tier_config_t {
    pub prefer_lower_tier: bool,
    pub require_same_frame_layout: bool,
}
#[doc = " Polymorphic inline cache for virtual/interface dispatch.\n\n Each CALL_VIRTUAL / CALL_INTERFACE site gets its own IC.\n The emitted machine code probes the type_ids array; on a hit,\n it calls the corresponding target directly.  On a miss, it\n falls through to the runtime helper which updates the IC.\n\n Layout (designed for cache-friendly access from emitted code):\n   offset  0: type_ids[0..3]  — 4 × uint32_t = 16 bytes, contiguous\n   offset 16: targets[0..3]   — 4 × void*    = 32 bytes, contiguous\n   offset 48: count            — uint32_t\n   offset 52: misses           — uint32_t"]
pub type vtx_poly_ic_t = vtx_poly_ic;
#[doc = " VORTEX Code Cache — Shared Compiled Code Type Definitions\n\n This header contains the canonical definition of vtx_compiled_code_t,\n which is used by both the baseline JIT code generator and the deopt/OSR\n subsystems."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_bc_pc_map_entry_t {
    pub bytecode_pc: u32,
    pub native_offset: u32,
    pub stack_depth: u32,
}
#[doc = " The result of compilation: contains the generated native code\n and all associated metadata.\n\n Fields from baseline/codegen.h:\n   code, code_size, frame_layout, guards, deopt_stubs, side_table,\n   deopt_info, bc_pc_map, bc_pc_map_count, native_to_bc_pc,\n   native_to_bc_pc_count, method\n\n Fields from deopt/osr.h:\n   entry_point, method_id, stack_slots, local_slots"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_compiled_code_t {
    pub code: *mut u8,
    pub code_size: u32,
    pub frame_layout: vtx_jit_frame_layout_t,
    pub guards: vtx_guard_array_t,
    pub deopt_stubs: vtx_deopt_stub_array_t,
    pub side_table: *mut vtx_side_table_t,
    pub deopt_info: *mut vtx_deopt_info_t,
    pub bc_pc_map: *mut vtx_bc_pc_map_entry_t,
    pub bc_pc_map_count: u32,
    pub native_to_bc_pc: *mut u32,
    pub native_to_bc_pc_count: u32,
    pub method: *const vtx_method_desc_t,
    pub poly_ics: *mut *mut vtx_poly_ic_t,
    pub poly_ic_count: u32,
    pub entry_point: *mut ::std::os::raw::c_void,
    pub method_id: u32,
    pub stack_slots: u32,
    pub local_slots: u32,
}
impl Default for vtx_compiled_code_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
pub const vtx_reloc_kind_t_VTX_RELOC_REL32: vtx_reloc_kind_t = 0;
pub const vtx_reloc_kind_t_VTX_RELOC_ABS64: vtx_reloc_kind_t = 1;
pub const vtx_reloc_kind_t_VTX_RELOC_RIP_REL32: vtx_reloc_kind_t = 2;
#[doc = " VORTEX Relocations and Fixups\n\n Handles fixups for:\n   - Forward branches (patched after target is emitted)\n   - Call targets (patched after callee is compiled)\n   - Constant pool references (RIP-relative)\n   - Deopt handler addresses (absolute)\n\n Relocations are recorded during code emission and applied in a final\n pass once all code positions are known."]
pub type vtx_reloc_kind_t = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_reloc_t {
    pub kind: vtx_reloc_kind_t,
    pub offset: u32,
    pub target_offset: u32,
    pub target_address: u64,
    pub symbol: u32,
    pub addend: i32,
    pub is_external: bool,
}
impl Default for vtx_reloc_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_reloc_table_t {
    pub entries: *mut vtx_reloc_t,
    pub count: u32,
    pub capacity: u32,
}
impl Default for vtx_reloc_table_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize a relocation table.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_reloc_table_init(
        table: *mut vtx_reloc_table_t,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a relocation table."]
    pub fn vtx_reloc_table_destroy(table: *mut vtx_reloc_table_t);
}
extern "C" {
    #[doc = " Add a relocation entry to the table.\n Returns the index of the new entry, or UINT32_MAX on failure.\n\n @param table          Relocation table\n @param kind           Relocation type\n @param offset         Offset in code buffer where fixup goes\n @param target_offset  Target offset (for REL32)\n @param target_address Absolute target address (for ABS64)\n @param symbol         Symbol index (0 = none)\n @param addend         Additional offset\n @param arena          Arena for allocation"]
    pub fn vtx_reloc_add(
        table: *mut vtx_reloc_table_t,
        kind: vtx_reloc_kind_t,
        offset: u32,
        target_offset: u32,
        target_address: u64,
        symbol: u32,
        addend: i32,
        arena: *mut vtx_arena_t,
    ) -> u32;
}
extern "C" {
    #[doc = " Apply all relocations to the code buffer.\n\n For REL32: patch the 32-bit value at `offset` with\n   (target_offset - offset - 4 + addend)\n\n For ABS64: patch the 64-bit value at `offset` with\n   (target_address + addend)\n\n For RIP_REL32: patch the 32-bit value at `offset` with\n   (target_offset - (offset + 4) + addend)\n\n @param table       Relocation table\n @param code_buffer Code buffer to patch\n @param code_size   Size of the code buffer\n @return            0 on success, -1 on failure"]
    pub fn vtx_reloc_apply_all(
        table: *mut vtx_reloc_table_t,
        code_buffer: *mut u8,
        code_size: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Add a forward branch relocation.\n Convenience function for the common case of a JCC/JMP that targets\n a not-yet-emitted location.\n\n @param table          Relocation table\n @param patch_offset   Offset of the 32-bit displacement to patch\n @param source_offset  Offset of the branch instruction start\n @param target_offset  Offset of the branch target (0 = unknown, will be set later)\n @param arena          Arena"]
    pub fn vtx_reloc_add_branch(
        table: *mut vtx_reloc_table_t,
        patch_offset: u32,
        source_offset: u32,
        target_offset: u32,
        arena: *mut vtx_arena_t,
    ) -> u32;
}
extern "C" {
    #[doc = " Add a call target relocation.\n\n @param table          Relocation table\n @param patch_offset   Offset of the 32-bit displacement\n @param target_address Absolute address of the callee\n @param arena          Arena"]
    pub fn vtx_reloc_add_call(
        table: *mut vtx_reloc_table_t,
        patch_offset: u32,
        target_address: u64,
        arena: *mut vtx_arena_t,
    ) -> u32;
}
extern "C" {
    #[doc = " Add a deopt handler address relocation (absolute 64-bit).\n\n @param table          Relocation table\n @param patch_offset   Offset of the 64-bit address to patch\n @param handler_addr   Address of the deopt handler\n @param arena          Arena"]
    pub fn vtx_reloc_add_deopt_handler(
        table: *mut vtx_reloc_table_t,
        patch_offset: u32,
        handler_addr: u64,
        arena: *mut vtx_arena_t,
    ) -> u32;
}
extern "C" {
    #[doc = " Apply deferred external call relocations at install time.\n\n When code is installed in the code cache, the base address changes\n from the temporary emission buffer to the final code cache address.\n External call relocations (calls to runtime helpers) use REL32 relative\n addressing, so the displacement depends on the code's final address.\n\n This function must be called AFTER the code has been copied to its\n final location in the code cache, and BEFORE the code is made executable.\n\n Only relocations marked is_external=true are processed. Intra-code\n relocations were already resolved by vtx_reloc_apply_all() and are\n not affected.\n\n @param table          Relocation table\n @param code_base      Final base address of the installed code\n @param code_buffer    Writable pointer to the installed code\n @param code_size      Size of the code\n @return               0 on success, -1 on failure"]
    pub fn vtx_reloc_apply_external(
        table: *mut vtx_reloc_table_t,
        code_base: *const ::std::os::raw::c_void,
        code_buffer: *mut u8,
        code_size: u32,
    ) -> ::std::os::raw::c_int;
}
#[doc = " Per-method state for the clock (Second Chance) eviction algorithm.\n The use_bit is set when the method is called (touch) and cleared\n by the clock hand during eviction scanning. Methods with a cleared\n use_bit are eviction candidates."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_clock_state_t {
    pub clock_hand: u32,
    pub use_bit: bool,
}
#[doc = " Metadata for a compiled method, stored separately from the code.\n This includes everything needed for deoptimization and invalidation."]
pub type vtx_compiled_method_t = vtx_compiled_method;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_compiled_method {
    pub method_id: u32,
    pub method_desc: *const vtx_method_desc_t,
    pub code_start: *mut u8,
    pub code_size: u32,
    pub side_table: *mut vtx_side_table_t,
    pub deopt_info: *mut vtx_deopt_info_t,
    pub reloc_table: *mut vtx_reloc_table_t,
    pub dep_type_ids: *mut u32,
    pub dep_type_count: u32,
    pub dep_shape_ids: *mut u32,
    pub dep_shape_count: u32,
    pub last_used_timestamp: u64,
    pub call_count: u32,
    pub clock_state: vtx_clock_state_t,
    pub poly_ics: *mut *mut vtx_poly_ic_t,
    pub poly_ic_count: u32,
    pub is_installed: bool,
    pub is_valid: bool,
    pub frame_layout: vtx_jit_frame_layout_t,
    pub bc_pc_map: *mut vtx_bc_pc_map_entry_t,
    pub bc_pc_map_count: u32,
    pub next: *mut vtx_compiled_method_t,
}
impl Default for vtx_compiled_method {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_method_registry {
    pub methods: *mut *mut vtx_compiled_method_t,
    pub method_count: u32,
    pub capacity: u32,
    pub capacity_mask: u32,
    pub clock_hand: u32,
    pub malloc_allocated: bool,
}
impl Default for vtx_method_registry {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
pub type vtx_method_registry_t = vtx_method_registry;
extern "C" {
    #[doc = " Initialize the method registry."]
    pub fn vtx_method_registry_init(
        registry: *mut vtx_method_registry_t,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the method registry."]
    pub fn vtx_method_registry_destroy(registry: *mut vtx_method_registry_t);
}
extern "C" {
    #[doc = " Register a compiled method in the registry."]
    pub fn vtx_method_registry_add(
        registry: *mut vtx_method_registry_t,
        method: *mut vtx_compiled_method_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Look up a compiled method by its method_id."]
    pub fn vtx_method_registry_get(
        registry: *mut vtx_method_registry_t,
        method_id: u32,
    ) -> *mut vtx_compiled_method_t;
}
extern "C" {
    #[doc = " Remove a compiled method from the registry."]
    pub fn vtx_method_registry_remove(
        registry: *mut vtx_method_registry_t,
        method_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Install a compiled method into the code cache.\n\n Steps:\n   1. Allocate space in the cache for the compiled code\n   2. Copy the code into the cache\n   3. Make the code executable\n   4. Register the method in the registry\n   5. Update the method's code pointer atomically\n\n @param cache       Code cache\n @param registry    Method registry\n @param method      Method descriptor\n @param code        Compiled code bytes\n @param code_size   Size of compiled code\n @param side_table  Deoptimization side table (ownership transferred)\n @param reloc_table Relocation table (for external call fixups at install time)\n @param dep_types   Array of TypeIDs this method depends on\n @param dep_type_count Number of TypeIDs\n @param dep_shapes  Array of ShapeIDs this method depends on\n @param dep_shape_count Number of ShapeIDs\n @param arena       Arena for allocations\n @param poly_ics    Array of polymorphic inline cache pointers (ownership transferred)\n @param poly_ic_count Number of ICs in the array\n @return            true on success, false on failure"]
    pub fn vtx_install_method(
        cache: *mut vtx_code_cache_t,
        registry: *mut vtx_method_registry_t,
        method: *const vtx_method_desc_t,
        method_id: u32,
        code: *const u8,
        code_size: u32,
        side_table: *mut vtx_side_table_t,
        reloc_table: *mut vtx_reloc_table_t,
        dep_types: *const u32,
        dep_type_count: u32,
        dep_shapes: *const u32,
        dep_shape_count: u32,
        arena: *mut vtx_arena_t,
        poly_ics: *mut *mut vtx_poly_ic_t,
        poly_ic_count: u32,
        frame_layout: *const vtx_jit_frame_layout_t,
        bc_pc_map: *const vtx_bc_pc_map_entry_t,
        bc_pc_map_count: u32,
    ) -> bool;
}
extern "C" {
    #[doc = " Uninstall a method: mark it as not compiled and free its metadata.\n The code in the cache is freed separately (when the segment is empty).\n\n @param cache       Code cache\n @param registry    Method registry\n @param method_id   Method ID to uninstall\n @return            0 on success, -1 on failure"]
    pub fn vtx_uninstall_method(
        cache: *mut vtx_code_cache_t,
        registry: *mut vtx_method_registry_t,
        method_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Get the entry point for a compiled method.\n Returns NULL if the method is not compiled or not installed."]
    pub fn vtx_method_entry_point(
        method: *const vtx_compiled_method_t,
    ) -> *mut ::std::os::raw::c_void;
}
#[doc = " Records the receiver types observed at a single call site.\n Up to VTX_POLY_LIMIT types are stored; once exceeded the site is megamorphic."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_callsite_profile_t {
    pub types: [vtx_typeid_t; 4usize],
    pub count: u32,
    pub megamorphic: bool,
}
#[doc = " Records taken / not-taken counts for a single branch bytecode PC.\n Both counters use saturating increment."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_branch_profile_t {
    pub bytecode_pc: u32,
    pub taken: u64,
    pub not_taken: u64,
}
#[doc = " Records the shape IDs observed at a single field access site.\n Up to VTX_POLY_LIMIT shapes are stored; once exceeded the site is megamorphic."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_field_profile_t {
    pub field_offset: u32,
    pub shapes: [vtx_shapeid_t; 4usize],
    pub count: u32,
    pub megamorphic: bool,
}
#[doc = " Records the back-edge count for a single loop (identified by its header PC)."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_loop_profile_t {
    pub loop_header_pc: u32,
    pub backedge_count: u64,
    pub last_trip_count: u64,
    pub trip_stability_count: u32,
    pub is_trip_stable: bool,
}
#[doc = " Complete profile data for a single method.\n\n Call sites, branches, field accesses, and loops are stored in dynamically\n grown arrays keyed by bytecode PC or field offset. Lookup is linear scan\n (the arrays are small: typical methods have < 100 sites of each kind)."]
pub type vtx_profile_method_t = vtx_profile_method;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_profile_method {
    pub method_id: u32,
    pub invocation_count: u64,
    pub call_sites: *mut vtx_callsite_profile_t,
    pub call_site_count: u32,
    pub call_site_capacity: u32,
    pub branches: *mut vtx_branch_profile_t,
    pub branch_count: u32,
    pub branch_capacity: u32,
    pub field_accesses: *mut vtx_field_profile_t,
    pub field_access_count: u32,
    pub field_access_capacity: u32,
    pub loops: *mut vtx_loop_profile_t,
    pub loop_count: u32,
    pub loop_capacity: u32,
}
impl Default for vtx_profile_method {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " A directed edge in the method call graph: caller → callee with frequency."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_call_edge_t {
    pub caller_method_id: u32,
    pub callee_method_id: u32,
    pub frequency: u64,
}
#[doc = " A directed edge in the phase transition graph.\n Represents a transition from one phase (SCC) to another."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_phase_transition_t {
    pub from_phase_id: u32,
    pub to_phase_id: u32,
    pub frequency: u64,
}
#[doc = " Global profile data spanning all methods.\n\n Owns the method profile array, the call graph edges, and the phase\n transition graph. The phase transition graph is populated by\n vtx_phase_detect() in phase.h."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_profile_global_t {
    pub methods: *mut vtx_profile_method_t,
    pub method_count: u32,
    pub method_capacity: u32,
    pub call_edges: *mut vtx_call_edge_t,
    pub call_edge_count: u32,
    pub call_edge_capacity: u32,
    pub phase_transitions: *mut vtx_phase_transition_t,
    pub phase_transition_count: u32,
    pub phase_transition_capacity: u32,
    pub phase_graph: *mut vtx_phase_graph,
}
impl Default for vtx_profile_global_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize a global profile structure. Allocates initial arrays.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_profile_global_init(global: *mut vtx_profile_global_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a global profile structure and free all memory."]
    pub fn vtx_profile_global_destroy(global: *mut vtx_profile_global_t);
}
extern "C" {
    #[doc = " Add a new method profile for the given method_id.\n Returns a pointer to the new method profile, or NULL on failure.\n If a profile for method_id already exists, returns the existing one."]
    pub fn vtx_profile_add_method(
        global: *mut vtx_profile_global_t,
        method_id: u32,
    ) -> *mut vtx_profile_method_t;
}
extern "C" {
    #[doc = " Look up a method profile by method_id.\n Returns the profile, or NULL if not found."]
    pub fn vtx_profile_get_method(
        global: *const vtx_profile_global_t,
        method_id: u32,
    ) -> *mut vtx_profile_method_t;
}
extern "C" {
    #[doc = " Record a method invocation. Increments the invocation counter (saturating).\n Creates the method profile if it does not exist."]
    pub fn vtx_profile_record_invocation(global: *mut vtx_profile_global_t, method_id: u32);
}
extern "C" {
    #[doc = " Record a receiver type observation at a call site.\n Creates the method profile and call site entry if they do not exist.\n If the call site is already megamorphic, this is a no-op.\n If the type is already recorded, this is a no-op.\n If VTX_POLY_LIMIT distinct types have been seen and this is a new type,\n the site transitions to megamorphic."]
    pub fn vtx_profile_record_callsite_type(
        global: *mut vtx_profile_global_t,
        method_id: u32,
        callsite_index: u32,
        receiver_type: vtx_typeid_t,
    );
}
extern "C" {
    #[doc = " Record a branch outcome at the given bytecode PC.\n Creates the method profile and branch entry if they do not exist.\n taken=true increments the taken counter; taken=false increments not_taken.\n Both use saturating arithmetic."]
    pub fn vtx_profile_record_branch(
        global: *mut vtx_profile_global_t,
        method_id: u32,
        bytecode_pc: u32,
        taken: bool,
    );
}
extern "C" {
    #[doc = " Record a field access shape observation.\n Creates the method profile and field access entry if they do not exist.\n If the site is already megamorphic, this is a no-op.\n If the shape is already recorded, this is a no-op.\n If VTX_POLY_LIMIT distinct shapes have been seen and this is a new shape,\n the site transitions to megamorphic."]
    pub fn vtx_profile_record_field_shape(
        global: *mut vtx_profile_global_t,
        method_id: u32,
        field_offset: u32,
        shape_id: vtx_shapeid_t,
    );
}
extern "C" {
    #[doc = " Record a loop back-edge at the given loop header PC.\n Creates the method profile and loop entry if they do not exist.\n Increments the back-edge counter (saturating)."]
    pub fn vtx_profile_record_loop_backedge(
        global: *mut vtx_profile_global_t,
        method_id: u32,
        loop_header_pc: u32,
    );
}
extern "C" {
    #[doc = " Record a call graph edge (caller → callee).\n If an edge with the same (caller, callee) pair already exists,\n increments its frequency (saturating). Otherwise creates a new edge."]
    pub fn vtx_profile_record_call_edge(
        global: *mut vtx_profile_global_t,
        caller_method_id: u32,
        callee_method_id: u32,
    );
}
extern "C" {
    #[doc = " Get the callsite profile for a method at the given callsite index.\n Returns NULL if the method or callsite does not exist."]
    pub fn vtx_profile_get_callsite(
        global: *const vtx_profile_global_t,
        method_id: u32,
        callsite_index: u32,
    ) -> *const vtx_callsite_profile_t;
}
extern "C" {
    #[doc = " Get the branch profile for a method at the given bytecode PC.\n Returns NULL if the method or branch does not exist."]
    pub fn vtx_profile_get_branch(
        global: *const vtx_profile_global_t,
        method_id: u32,
        bytecode_pc: u32,
    ) -> *const vtx_branch_profile_t;
}
extern "C" {
    #[doc = " Compute the branch taken probability for a branch profile.\n Returns 0.0 if no observations, otherwise taken / (taken + not_taken)."]
    pub fn vtx_profile_branch_probability(branch: *const vtx_branch_profile_t) -> f64;
}
extern "C" {
    #[doc = " Check if a method is \"hot\" (invocation count >= threshold)."]
    pub fn vtx_profile_method_is_hot(method: *const vtx_profile_method_t, threshold: u64) -> bool;
}
extern "C" {
    #[doc = " Record a loop trip count observation and update stability tracking.\n If the new trip count matches the previous observation, increment\n the stability counter. If it differs, reset the counter.\n\n @param global      Global profile\n @param method_id   Method ID\n @param loop_header_pc  Bytecode PC of the loop header\n @param trip_count  Trip count observed for this entry"]
    pub fn vtx_profile_record_trip_count(
        global: *mut vtx_profile_global_t,
        method_id: u32,
        loop_header_pc: u32,
        trip_count: u64,
    );
}
extern "C" {
    #[doc = " Check if a loop is trip-stable (trip count constant for\n VTX_TRIP_STABILITY_WINDOW observations).\n\n @param global         Global profile\n @param method_id      Method ID\n @param loop_header_pc Loop header PC\n @return               true if trip-stable"]
    pub fn vtx_profile_is_trip_stable(
        global: *const vtx_profile_global_t,
        method_id: u32,
        loop_header_pc: u32,
    ) -> bool;
}
extern "C" {
    #[doc = " Get the stable trip count for a trip-stable loop.\n Returns 0 if the loop is not trip-stable.\n\n @param global         Global profile\n @param method_id      Method ID\n @param loop_header_pc Loop header PC\n @return               Stable trip count, or 0"]
    pub fn vtx_profile_get_stable_trip_count(
        global: *const vtx_profile_global_t,
        method_id: u32,
        loop_header_pc: u32,
    ) -> u64;
}
#[doc = " A single phase: an SCC in the call graph that meets the size and\n frequency thresholds."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_phase_t {
    pub phase_id: u32,
    pub method_ids: *mut u32,
    pub method_count: u32,
    pub method_capacity: u32,
    pub total_frequency: u64,
    pub is_significant: bool,
}
impl Default for vtx_phase_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " The phase graph: the result of phase detection.\n Contains the list of phases and the transitions between them."]
pub type vtx_phase_graph_t = vtx_phase_graph;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_phase_graph {
    pub phases: *mut vtx_phase_t,
    pub phase_count: u32,
    pub phase_capacity: u32,
    pub transitions: *mut vtx_phase_transition_t,
    pub transition_count: u32,
    pub transition_capacity: u32,
    pub method_to_phase: *mut u32,
    pub method_to_phase_capacity: u32,
}
impl Default for vtx_phase_graph {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Detect phases from the call graph in the global profile.\n Returns a newly allocated phase graph (caller must free with\n vtx_phase_graph_destroy), or NULL on failure.\n\n Algorithm:\n   1. Build adjacency lists from the call edges in the profile.\n   2. Run Tarjan's SCC algorithm.\n   3. For each SCC, compute total invocation frequency.\n   4. Mark SCCs as significant if they meet the thresholds.\n   5. Phase transitions = inter-SCC edges between significant SCCs."]
    pub fn vtx_phase_detect(global: *const vtx_profile_global_t) -> *mut vtx_phase_graph_t;
}
extern "C" {
    #[doc = " Destroy a phase graph and free all memory."]
    pub fn vtx_phase_graph_destroy(graph: *mut vtx_phase_graph_t);
}
extern "C" {
    #[doc = " Check if the program is transitioning from one phase to another.\n A transition occurs when the current top-of-stack method changes\n from one phase to a different phase.\n\n prev_top_method: the method_id of the previous top-of-stack method.\n curr_top_method: the method_id of the current top-of-stack method.\n\n Returns true if there is a phase transition (different phases).\n Returns false if both methods are in the same phase, or if either\n method is not in any phase, or if either is VTX_PHASE_NONE."]
    pub fn vtx_phase_is_entering(
        graph: *const vtx_phase_graph_t,
        prev_top_method: u32,
        curr_top_method: u32,
    ) -> bool;
}
extern "C" {
    #[doc = " Look up the phase ID for a method. Returns VTX_PHASE_NONE if not in any phase."]
    pub fn vtx_phase_for_method(graph: *const vtx_phase_graph_t, method_id: u32) -> u32;
}
extern "C" {
    #[doc = " Get a phase by its ID. Returns NULL if not found."]
    pub fn vtx_phase_get_by_id(
        graph: *const vtx_phase_graph_t,
        phase_id: u32,
    ) -> *const vtx_phase_t;
}
#[doc = " A single phase's profile storage.\n\n The `profile` is a fully-owned vtx_profile_global_t — the partition\n manager initializes and destroys it."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_phase_profile_entry_t {
    pub phase_id: u32,
    pub profile: vtx_profile_global_t,
    pub transition_count: u64,
    pub last_transition_ns: u64,
    pub valid: bool,
}
impl Default for vtx_phase_profile_entry_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Phase-aware profile partition manager.\n\n Owns N per-phase profile globals and tracks which one is currently\n \"active\" (i.e., the one the interpreter is recording to and the\n orchestrator is reading from for recomp decisions).\n\n Lifecycle:\n   1. init()  — creates the default phase (VTX_PHASE_NONE) and makes\n                it active.\n   2. transition(new_phase) — saves the current active phase's stats,\n                              creates the new phase if needed, makes it\n                              active.\n   3. get_active() — returns the currently-active profile (used by\n                     the recording path and the orchestrator).\n   4. destroy() — destroys all per-phase profiles."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_phase_partition_t {
    pub entries: *mut vtx_phase_profile_entry_t,
    pub entry_count: u32,
    pub entry_capacity: u32,
    pub active_index: u32,
    pub total_transitions: u64,
    pub total_phase_creations: u64,
}
impl Default for vtx_phase_partition_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the partition manager.\n\n Creates the default phase (phase_id == VTX_PHASE_NONE) and makes it\n active. The default phase is where all recording goes until the first\n explicit transition.\n\n Returns 0 on success, -1 on failure."]
    pub fn vtx_phase_partition_init(part: *mut vtx_phase_partition_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the partition manager and all per-phase profiles."]
    pub fn vtx_phase_partition_destroy(part: *mut vtx_phase_partition_t);
}
extern "C" {
    #[doc = " Get the currently-active phase's profile.\n\n This is the profile that:\n   - The interpreter records to (via the orchestrator's wiring)\n   - The orchestrator reads from for recomp decisions\n   - The compiler uses for speculative optimization\n\n Returns NULL only if init() failed."]
    pub fn vtx_phase_partition_get_active(
        part: *mut vtx_phase_partition_t,
    ) -> *mut vtx_profile_global_t;
}
extern "C" {
    #[doc = " Get the phase_id of the currently-active phase.\n Returns VTX_PHASE_NONE for the default phase."]
    pub fn vtx_phase_partition_active_phase(part: *const vtx_phase_partition_t) -> u32;
}
extern "C" {
    #[doc = " Transition to a new phase.\n\n   1. Records transition stats for the outgoing phase.\n   2. Looks up (or creates) the entry for `new_phase_id`.\n   3. Makes that entry the active phase.\n\n If `new_phase_id` is the same as the currently-active phase, this is\n a no-op (returns the active profile without modifying state).\n\n After this call, vtx_phase_partition_get_active() returns the new\n phase's profile. The interpreter's recording pointer must be updated\n by the caller.\n\n @param part          Partition manager\n @param new_phase_id  Phase to transition to (VTX_PHASE_NONE for default)\n @param now_ns        Monotonic timestamp (pass 0 to use internal clock)\n @return              The new active profile, or NULL on failure"]
    pub fn vtx_phase_partition_transition(
        part: *mut vtx_phase_partition_t,
        new_phase_id: u32,
        now_ns: u64,
    ) -> *mut vtx_profile_global_t;
}
extern "C" {
    #[doc = " Get the profile for a specific phase, or NULL if it doesn't exist.\n\n Does NOT change the active phase. Use this to inspect or save a\n phase's profile (e.g., for persistence or preemptive recompilation\n of the predicted-next phase)."]
    pub fn vtx_phase_partition_get_phase(
        part: *mut vtx_phase_partition_t,
        phase_id: u32,
    ) -> *mut vtx_profile_global_t;
}
extern "C" {
    #[doc = " Get or create the profile for a specific phase.\n\n If the phase doesn't exist, it's created (but NOT made active —\n call transition() for that). Returns the phase's profile."]
    pub fn vtx_phase_partition_get_or_create(
        part: *mut vtx_phase_partition_t,
        phase_id: u32,
    ) -> *mut vtx_profile_global_t;
}
extern "C" {
    #[doc = " Number of distinct phases tracked (including the default phase)."]
    pub fn vtx_phase_partition_phase_count(part: *const vtx_phase_partition_t) -> u32;
}
extern "C" {
    #[doc = " Given a phase graph and a target phase, populate `out_methods` with\n the method IDs that are hot in that phase and should be preemptively\n recompiled when entering the phase.\n\n The methods are sorted by descending invocation_count in the phase's\n profile (so the hottest come first). At most `out_capacity` methods\n are written.\n\n @param part          Partition manager\n @param graph         Phase graph (from vtx_phase_detect)\n @param phase_id      Target phase\n @param out_methods   Output array\n @param out_capacity  Max methods to write\n @return              Number of methods written (may be 0)"]
    pub fn vtx_phase_partition_hot_methods_for_phase(
        part: *mut vtx_phase_partition_t,
        graph: *const vtx_phase_graph_t,
        phase_id: u32,
        out_methods: *mut u32,
        out_capacity: u32,
    ) -> u32;
}
extern "C" {
    #[doc = " Get aggregate partition statistics.\n\n @param part                 Partition manager\n @param total_transitions    Out: total phase transitions\n @param total_creations      Out: total phases created\n @param active_phase_id      Out: currently-active phase ID"]
    pub fn vtx_phase_partition_stats(
        part: *const vtx_phase_partition_t,
        total_transitions: *mut u64,
        total_creations: *mut u64,
        active_phase_id: *mut u32,
    );
}
#[doc = " VORTEX SoN Graph — Construction from Bytecode\n\n The graph is the central data structure for the Sea-of-Nodes IR.\n It owns the node table and provides the entry point for building\n the graph from a bytecode method.\n\n Construction algorithm:\n  1. Create Start node + Parameter projections (one per method parameter).\n  2. Walk bytecode in linear order, identifying basic block boundaries.\n  3. Each basic block entry becomes a Region node (or LoopBegin for loop headers).\n  4. Within each block, emit data nodes for arithmetic, memory nodes for\n     loads/stores (threaded as a chain), and control nodes for branches.\n  5. At Region merge points, insert Phi nodes for variables that differ\n     across predecessors.\n  6. Loop back-edges connect to LoopBegin nodes; LoopEnd marks the latch.\n  7. Memory state is threaded: each memory-consuming node takes the previous\n     memory node as input and produces a new memory state."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_block_info_t {
    pub start_pc: usize,
    pub end_pc: usize,
    pub is_loop_header: bool,
    pub is_loop_end: bool,
    pub is_catch_handler: bool,
    pub is_unreachable: bool,
    pub region_node: vtx_nodeid_t,
    pub control_node: vtx_nodeid_t,
    pub memory_node: vtx_nodeid_t,
    pub exception_target: vtx_nodeid_t,
    pub locals: *mut vtx_nodeid_t,
    pub pred_indices: *mut u32,
    pub pred_count: u32,
    pub pred_capacity: u32,
    pub succ_indices: *mut u32,
    pub succ_count: u32,
    pub succ_capacity: u32,
    pub exit_stack: *mut vtx_nodeid_t,
    pub exit_sp: i32,
}
impl Default for vtx_block_info_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_graph_t {
    pub node_table: vtx_node_table_t,
    pub start_node: vtx_nodeid_t,
    pub entry_control: vtx_nodeid_t,
    pub entry_memory: vtx_nodeid_t,
    pub parameter_count: u32,
    pub parameters: *mut vtx_nodeid_t,
    pub blocks: *mut vtx_block_info_t,
    pub block_count: u32,
    pub block_capacity: u32,
}
impl Default for vtx_graph_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize an empty graph. Creates the node table and Start node.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_graph_init(graph: *mut vtx_graph_t, max_params: u32) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the graph and free all memory."]
    pub fn vtx_graph_destroy(graph: *mut vtx_graph_t);
}
extern "C" {
    #[doc = " Build the SoN graph from bytecode.\n\n This is the main entry point: walks the bytecode, identifies basic blocks,\n constructs the Sea-of-Nodes IR with proper control flow, memory chains,\n and Phi nodes at merge points.\n\n The graph must be initialized before calling this function.\n The arena is used for temporary construction data (block info, locals).\n\n Returns 0 on success, -1 on failure."]
    pub fn vtx_graph_build(
        graph: *mut vtx_graph_t,
        bytecode: *const vtx_bytecode_t,
        method: *const vtx_method_desc_t,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Look up a node in the graph by ID. Convenience wrapper."]
    pub fn vtx_graph_node(graph: *mut vtx_graph_t, id: vtx_nodeid_t) -> *mut vtx_node_t;
}
extern "C" {
    #[doc = " Get the total number of nodes in the graph."]
    pub fn vtx_graph_node_count(graph: *const vtx_graph_t) -> u32;
}
extern "C" {
    #[doc = " Print the graph to stderr for debugging."]
    pub fn vtx_graph_print(graph: *const vtx_graph_t);
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_inline_features_t {
    pub features: [f64; 15usize],
}
#[doc = " Context needed for feature extraction beyond the graph and profile.\n The caller provides this to avoid the feature extractor needing\n knowledge of the entire compilation infrastructure."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_inline_context_t {
    pub caller_bytecode_size: u32,
    pub call_depth: u32,
    pub inline_history: u32,
    pub callee_bytecode_size: u32,
    pub callee_method_id: u32,
    pub callee_deopt_count: u64,
    pub callee_invocation_count: u64,
    pub caller_node_count: u32,
    pub callee_graph: *const vtx_graph_t,
}
impl Default for vtx_inline_context_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Extract features for a call site.\n\n @param graph    The caller's SoN graph\n @param call_node The call node (CallStatic/CallVirtual/CallInterface) NodeID\n @param profile  Global profile data (may be NULL if no profiling available)\n @param context  Additional context for extraction\n @return         Populated feature vector"]
    pub fn vtx_features_extract(
        graph: *const vtx_graph_t,
        call_node: vtx_nodeid_t,
        profile: *const vtx_profile_global_t,
        context: *const vtx_inline_context_t,
    ) -> vtx_inline_features_t;
}
extern "C" {
    #[doc = " Get the human-readable name of a feature by index.\n Returns \"unknown\" if the index is out of range."]
    pub fn vtx_feature_name(index: u32) -> *const ::std::os::raw::c_char;
}
extern "C" {
    #[doc = " Normalize a feature vector to [0, 1] range using known bounds.\n Each feature has a principled maximum derived from system limits:\n   - sizes capped at VTX_INLINE_SIZE_LIMIT\n   - frequencies capped at UINT64_MAX (saturating)\n   - ratios already in [0, 1]\n   - depths capped at VTX_MAX_TREE_DEPTH"]
    pub fn vtx_features_normalize(features: *mut vtx_inline_features_t);
}
extern "C" {
    #[doc = " Write a feature vector as a CSV line (without trailing newline).\n Format: f0,f1,...,f14\n Writes at most buf_size bytes including null terminator.\n Returns the number of characters written (excluding null), or -1 on error."]
    pub fn vtx_features_to_csv(
        features: *const vtx_inline_features_t,
        buf: *mut ::std::os::raw::c_char,
        buf_size: usize,
    ) -> ::std::os::raw::c_int;
}
pub const vtx_inline_outcome_t_VTX_OUTCOME_UNKNOWN: vtx_inline_outcome_t = 0;
pub const vtx_inline_outcome_t_VTX_OUTCOME_PROFITABLE: vtx_inline_outcome_t = 1;
pub const vtx_inline_outcome_t_VTX_OUTCOME_UNPROFITABLE: vtx_inline_outcome_t = 2;
#[doc = " VORTEX ML Inliner — Online Feedback\n\n Tracks inlining decision outcomes to enable:\n   1. Runtime detection of unprofitable inlines (deopt at inlined guard)\n   2. Confirmation of profitable inlines (stable execution for window)\n   3. CSV export of feature→label data for offline model retraining\n   4. Recompilation triggers when inlining decisions prove suboptimal\n\n Each inlining decision is recorded with:\n   - call_site_id: unique identifier for the call site\n   - features: the feature vector that was used for the decision\n   - inlined: whether the decision was to inline\n   - outcome: not yet determined at decision time\n\n Outcomes are recorded later:\n   - If a deoptimization occurs at an inlined call site's guard,\n     the inlining is marked as potentially unprofitable.\n   - If the compiled code runs stably for VTX_FEEDBACK_WINDOW executions\n     without deopt at that site, the inlining is marked as profitable.\n\n Thread safety: this module is NOT thread-safe. The caller must\n synchronize access if used from multiple threads."]
pub type vtx_inline_outcome_t = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_inline_decision_t {
    pub call_site_id: u64,
    pub method_id: u32,
    pub features: vtx_inline_features_t,
    pub inlined: bool,
    pub outcome: vtx_inline_outcome_t,
    pub execution_count: u64,
    pub deopt_count: u64,
    pub decision_timestamp: u64,
}
impl Default for vtx_inline_decision_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_inline_feedback_t {
    pub decisions: *mut vtx_inline_decision_t,
    pub decision_count: u32,
    pub decision_capacity: u32,
    pub profitable_count: u32,
    pub unprofitable_count: u32,
    pub unknown_count: u32,
}
impl Default for vtx_inline_feedback_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize a feedback tracker.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_feedback_init(feedback: *mut vtx_inline_feedback_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a feedback tracker and free all memory."]
    pub fn vtx_feedback_destroy(feedback: *mut vtx_inline_feedback_t);
}
extern "C" {
    #[doc = " Record an inlining decision.\n\n @param feedback     Feedback tracker\n @param call_site_id Unique identifier for the call site\n @param features     Feature vector used for the decision\n @param inlined      Whether the decision was to inline\n @return             0 on success, -1 on failure"]
    pub fn vtx_feedback_record_decision(
        feedback: *mut vtx_inline_feedback_t,
        call_site_id: u64,
        method_id: u32,
        features: *const vtx_inline_features_t,
        inlined: bool,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Record an outcome for a previously recorded decision.\n\n If the decision has already been marked with an outcome, this\n updates the outcome only if the new outcome is worse\n (PROFITABLE → UNPROFITABLE is allowed; UNPROFITABLE → PROFITABLE is not).\n\n @param feedback     Feedback tracker\n @param call_site_id Call site identifier\n @param profitable   true if the inlining was profitable, false if not\n @return             0 on success, -1 if call_site_id not found"]
    pub fn vtx_feedback_record_outcome(
        feedback: *mut vtx_inline_feedback_t,
        call_site_id: u64,
        profitable: bool,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Increment the execution count for a call site.\n Called each time the compiled code containing this inlined call site executes.\n\n If the execution count reaches VTX_FEEDBACK_WINDOW and the outcome\n is still UNKNOWN, automatically mark it as PROFITABLE.\n\n @param feedback     Feedback tracker\n @param call_site_id Call site identifier"]
    pub fn vtx_feedback_increment_executions(
        feedback: *mut vtx_inline_feedback_t,
        call_site_id: u64,
    );
}
extern "C" {
    #[doc = " Increment the deopt count for a call site.\n Called when a deoptimization occurs at an inlined call site's guard.\n\n If the deopt rate exceeds VTX_INLINE_DEOPT_THRESHOLD, automatically\n mark the outcome as UNPROFITABLE.\n\n @param feedback     Feedback tracker\n @param call_site_id Call site identifier"]
    pub fn vtx_feedback_increment_deopts(feedback: *mut vtx_inline_feedback_t, call_site_id: u64);
}
extern "C" {
    #[doc = " Check whether a call site should be recompiled with a different\n inlining strategy.\n\n A site should be recompiled if:\n   - It was inlined and the outcome is UNPROFITABLE\n   - It was NOT inlined but the call site is now hot and the\n     features suggest inlining would be profitable (heuristic check)\n\n @param feedback     Feedback tracker\n @param call_site_id Call site identifier\n @return             true if recompilation is recommended"]
    pub fn vtx_feedback_should_recompile(
        feedback: *mut vtx_inline_feedback_t,
        call_site_id: u64,
    ) -> bool;
}
extern "C" {
    #[doc = " Look up the decision for a call site.\n Returns NULL if no decision has been recorded for this call site."]
    pub fn vtx_feedback_lookup(
        feedback: *const vtx_inline_feedback_t,
        call_site_id: u64,
    ) -> *const vtx_inline_decision_t;
}
extern "C" {
    #[doc = " Write all recorded decisions with known outcomes to a CSV file.\n\n Format: one line per decision\n   f0,f1,...,f14,label\n where label is 1 for PROFITABLE, 0 for UNPROFITABLE.\n Decisions with UNKNOWN outcome are excluded.\n\n @param feedback Feedback tracker\n @param filename Path to the output CSV file\n @return         Number of records written, or -1 on error"]
    pub fn vtx_feedback_write_csv(
        feedback: *const vtx_inline_feedback_t,
        filename: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
#[doc = " A guard identifier: the NodeID of the DeoptGuard node in the SoN graph."]
pub type vtx_guard_id_t = vtx_nodeid_t;
#[doc = " A deoptless continuation version: compiled code with a specific guard removed."]
pub type vtx_deoptless_version_t = vtx_deoptless_version;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_deoptless_version {
    pub method_id: u32,
    pub failed_guard_id: vtx_guard_id_t,
    pub continuation_code: *mut ::std::os::raw::c_void,
    pub continuation_size: u32,
    pub next_version: *mut vtx_deoptless_version_t,
    pub version_number: u32,
    pub guard_branch_offset: u32,
    pub code_start: *mut u8,
    pub graph: *mut vtx_graph_t,
    pub parent_version: *mut vtx_deoptless_version_t,
    pub original_jcc_disp: i32,
    pub is_patched: bool,
}
impl Default for vtx_deoptless_version {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Per-method version table: tracks all continuation versions for a method."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_deoptless_table_struct {
    pub method_id: u32,
    pub versions: *mut vtx_deoptless_version_t,
    pub version_count: u32,
    pub original_code: *mut ::std::os::raw::c_void,
    pub original_graph: *mut vtx_graph_t,
    pub failed_guards: *mut vtx_guard_id_t,
    pub failed_guard_count: u32,
    pub failed_guard_capacity: u32,
    pub decision_vector_hash: u64,
    pub compiled_profile_hash: u64,
}
impl Default for vtx_deoptless_table_struct {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Per-method version table: tracks all continuation versions for a method."]
pub type vtx_deoptless_table_t = vtx_deoptless_table_struct;
extern "C" {
    #[doc = " Create a continuation version of the graph with the specified guard removed.\n\n Steps:\n   1. Clone the original graph (or start from the last version's graph).\n   2. Find the DeoptGuard node identified by failed_guard_id.\n   3. Replace the guard with an unconditional branch (removing the speculation).\n   4. Invalidate all optimizations that depended on this guard:\n      - CheckCast nodes that were guarded by this guard become unconditional\n      - Inlined methods that were guarded by this guard are un-inlined\n      - Constant-folded values that depended on this guard are un-folded\n   5. Re-run GVN and DCE on the modified graph.\n   6. Return the new graph.\n\n @param graph          The original SoN graph (NOT modified)\n @param failed_guard_id The NodeID of the DeoptGuard that failed\n @param arena          Arena for allocations during graph manipulation\n @return A new graph with the guard removed, or NULL on failure"]
    pub fn vtx_deoptless_create_continuation(
        graph: *mut vtx_graph_t,
        failed_guard_id: vtx_guard_id_t,
        arena: *mut vtx_arena_t,
    ) -> *mut vtx_graph_t;
}
extern "C" {
    #[doc = " Install a deoptless continuation version. This compiles the continuation\n graph into native code and patches the guard's failure path to jump\n directly to the continuation code instead of the deopt stub.\n\n @param version  The continuation version to install (must have continuation_code set)\n @return true on success, false on failure"]
    pub fn vtx_deoptless_install(version: *mut vtx_deoptless_version_t) -> bool;
}
extern "C" {
    #[doc = " Initialize a deoptless version table for a method."]
    pub fn vtx_deoptless_table_init(
        table: *mut vtx_deoptless_table_t,
        method_id: u32,
        original_code: *mut ::std::os::raw::c_void,
        original_graph: *mut vtx_graph_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a deoptless version table and free all versions."]
    pub fn vtx_deoptless_table_destroy(table: *mut vtx_deoptless_table_t);
}
extern "C" {
    #[doc = " Look up a continuation version by the failed guard ID.\n Returns the version, or NULL if not found."]
    pub fn vtx_deoptless_find_version(
        table: *const vtx_deoptless_table_t,
        failed_guard_id: vtx_guard_id_t,
    ) -> *mut vtx_deoptless_version_t;
}
extern "C" {
    #[doc = " Add a continuation version to the table.\n If the table is at capacity (VTX_DEOPTLESS_MAX_VERSIONS),\n the oldest version is evicted.\n Returns the added version, or NULL on failure."]
    pub fn vtx_deoptless_add_version(
        table: *mut vtx_deoptless_table_t,
        failed_guard_id: vtx_guard_id_t,
        continuation_code: *mut ::std::os::raw::c_void,
        continuation_size: u32,
    ) -> *mut vtx_deoptless_version_t;
}
extern "C" {
    #[doc = " Check if deoptless deoptimization is possible for a guard.\n Returns false if the version table is full and the guard has no version yet."]
    pub fn vtx_deoptless_can_deoptless(
        table: *const vtx_deoptless_table_t,
        failed_guard_id: vtx_guard_id_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Evict the oldest continuation version from the table.\n Called when the table is full and a new version is needed."]
    pub fn vtx_deoptless_evict_oldest(table: *mut vtx_deoptless_table_t);
}
extern "C" {
    #[doc = " Create an incremental continuation: remove a single guard from the\n latest version's graph (or the original graph if no versions exist).\n\n This is the key improvement: instead of generating each continuation\n from the original graph (which creates combinatorial explosion), we\n chain them: V2 is generated from V1's graph with one more guard removed.\n\n @param table        The deoptless version table\n @param failed_guard_id  The guard that just failed\n @param arena        Arena for graph allocations\n @return             New graph with the guard removed, or NULL on failure"]
    pub fn vtx_deoptless_create_incremental_continuation(
        table: *mut vtx_deoptless_table_t,
        failed_guard_id: vtx_guard_id_t,
        arena: *mut vtx_arena_t,
    ) -> *mut vtx_graph_t;
}
extern "C" {
    #[doc = " Find the latest version in the chain that can be used as a base\n for the next incremental continuation.\n\n @param table  The deoptless version table\n @return       The latest version with a graph, or NULL"]
    pub fn vtx_deoptless_find_latest_version(
        table: *const vtx_deoptless_table_t,
    ) -> *mut vtx_deoptless_version_t;
}
extern "C" {
    #[doc = " Check if a guard has already been removed in any active continuation.\n\n @param table       The deoptless version table\n @param guard_id    The guard to check\n @return            true if this guard has already been removed"]
    pub fn vtx_deoptless_is_guard_removed(
        table: *const vtx_deoptless_table_t,
        guard_id: vtx_guard_id_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Record a failed guard ID in the table's tracking array.\n\n @param table       The deoptless version table\n @param guard_id    The guard that failed\n @return            0 on success, -1 on failure"]
    pub fn vtx_deoptless_record_failed_guard(
        table: *mut vtx_deoptless_table_t,
        guard_id: vtx_guard_id_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Compute a decision vector hash from the current graph's guard assumptions.\n The hash encodes all speculation decisions as a compact fingerprint.\n Two graphs with the same decision vector hash make the same speculative\n assumptions, so recompilation would produce identical code.\n\n @param graph  The SoN graph\n @return       64-bit hash of the speculation decisions"]
    pub fn vtx_deoptless_compute_decision_hash(graph: *const vtx_graph_t) -> u64;
}
extern "C" {
    #[doc = " Check if recompilation is needed by comparing the current profile\n hash against the compiled profile hash.\n\n @param table           Deoptless version table\n @param current_hash    Hash of the current profile state\n @return                true if recompilation is needed (hashes differ)"]
    pub fn vtx_deoptless_needs_recompilation(
        table: *const vtx_deoptless_table_t,
        current_hash: u64,
    ) -> bool;
}
extern "C" {
    #[doc = " Compute a 64-bit hash of the current profile state for a method.\n Used to detect profile changes that might affect speculation decisions.\n\n @param type_feedback   Type feedback data\n @param method_id       Method ID\n @return                64-bit hash"]
    pub fn vtx_profile_compute_hash(
        type_feedback: *const vtx_type_feedback_t,
        method_id: u32,
    ) -> u64;
}
#[doc = " A snapshot of the currently executing methods, used to match\n against known phases."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_phase_signature_t {
    pub method_ids: [u32; 10usize],
    pub count: u32,
    pub insert_pos: u32,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_sota_phase_t {
    pub phase_graph: *mut vtx_phase_graph_t,
    pub current_sig: vtx_phase_signature_t,
    pub predicted_phase: u32,
    pub precompiled_methods: *mut u32,
    pub precompiled_count: u32,
    pub precompiled_capacity: u32,
    pub predictions_made: u32,
    pub predictions_correct: u32,
    pub predictions_wrong: u32,
    pub hits_in_current_prediction: u32,
}
impl Default for vtx_sota_phase_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the phase prediction system.\n If phase_graph is non-NULL, it is used for predictions (takes ownership).\n If NULL, predictions are disabled until a graph is loaded.\n\n @param phase       Phase prediction state to initialize\n @param phase_graph Phase graph from previous run (may be NULL)\n @param arena       Arena for allocations\n @return            0 on success, -1 on failure"]
    pub fn vtx_sota_phase_init(
        phase: *mut vtx_sota_phase_t,
        phase_graph: *mut vtx_phase_graph_t,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the phase prediction system.\n Does NOT destroy the phase_graph (caller owns it)."]
    pub fn vtx_sota_phase_destroy(phase: *mut vtx_sota_phase_t);
}
extern "C" {
    #[doc = " Record a method entry for phase monitoring.\n Updates the current signature with the new method ID.\n\n @param phase     Phase prediction state\n @param method_id Method that was just entered"]
    pub fn vtx_sota_phase_record_method(phase: *mut vtx_sota_phase_t, method_id: u32);
}
extern "C" {
    #[doc = " Update the phase graph with a newly entered method.\n\n When a method is entered at the top level, this function:\n   1. Adds the method to the sliding window signature\n   2. Checks if the current method's phase matches the predicted phase\n   3. If a phase transition is detected, triggers prediction evaluation\n   4. If the method was pre-compiled by a phase prediction, records a hit\n\n This is the primary entry point called from the interpreter/JIT at each\n method entry to keep the phase monitor up-to-date.\n\n @param phase     Phase prediction state\n @param entered_method Method that was just entered"]
    pub fn vtx_sota_phase_update(phase: *mut vtx_sota_phase_t, entered_method: u32);
}
extern "C" {
    #[doc = " Predict which methods should be pre-compiled based on the\n current method call pattern.\n\n Compares the current signature against all known phases\n using Jaccard similarity. Returns the method IDs that\n should be queued for compilation.\n\n @param phase         Phase prediction state\n @param[out] methods  Array of method IDs to pre-compile (arena-allocated)\n @param[out] count    Number of methods in the array\n @return              0 on success, -1 on failure"]
    pub fn vtx_sota_phase_predict(
        phase: *mut vtx_sota_phase_t,
        arena: *mut vtx_arena_t,
        methods: *mut *mut u32,
        count: *mut u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Predict which methods should be pre-compiled based on an explicit\n set of current top-level method call patterns.\n\n This variant accepts an explicit array of current method IDs\n rather than using the internal sliding window. Useful when\n the caller has already computed the hot method set.\n\n Computes Jaccard similarity between the provided method set\n and each known phase's method set. Returns the method IDs\n from the best-matching phase that should be queued for\n T2/T3 compilation.\n\n @param phase            Phase prediction state\n @param current_methods  Array of current top-level method IDs\n @param method_count     Number of methods in the array\n @param arena            Arena for output allocation\n @param[out] out_methods Array of method IDs to pre-compile (arena-allocated)\n @param[out] out_count   Number of methods in the output array\n @return                 0 on success, -1 on failure"]
    pub fn vtx_sota_phase_predict_with_methods(
        phase: *mut vtx_sota_phase_t,
        current_methods: *const u32,
        method_count: u32,
        arena: *mut vtx_arena_t,
        out_methods: *mut *mut u32,
        out_count: *mut u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Compute Jaccard similarity between two sets of method IDs.\n\n Jaccard(A, B) = |A ∩ B| / |A ∪ B|\n\n Returns a value in [0, 1]. 1.0 means identical sets."]
    pub fn vtx_sota_phase_jaccard(
        set_a: *const u32,
        count_a: u32,
        set_b: *const u32,
        count_b: u32,
    ) -> f64;
}
extern "C" {
    #[doc = " Compute Jaccard similarity between the current signature\n and a phase's method set."]
    pub fn vtx_sota_phase_match_score(
        phase: *const vtx_sota_phase_t,
        phase_def: *const vtx_phase_t,
    ) -> f64;
}
extern "C" {
    #[doc = " Record that a pre-compiled method was actually called (prediction correct).\n\n @param phase     Phase prediction state\n @param method_id Method that was called"]
    pub fn vtx_sota_phase_record_hit(phase: *mut vtx_sota_phase_t, method_id: u32);
}
extern "C" {
    #[doc = " Record that the current phase prediction has ended\n (e.g., the program has moved to a different phase).\n Updates prediction accuracy statistics.\n\n @param phase Phase prediction state"]
    pub fn vtx_sota_phase_end_prediction(phase: *mut vtx_sota_phase_t);
}
pub const vtx_version_state_t_VTX_VERSION_COMPILING: vtx_version_state_t = 0;
pub const vtx_version_state_t_VTX_VERSION_ACTIVE: vtx_version_state_t = 1;
pub const vtx_version_state_t_VTX_VERSION_DEPRECATED: vtx_version_state_t = 2;
pub const vtx_version_state_t_VTX_VERSION_INVALIDATED: vtx_version_state_t = 3;
pub const vtx_version_state_t_VTX_VERSION_FREED: vtx_version_state_t = 4;
pub const vtx_version_state_t_VTX_VERSION_PARKED: vtx_version_state_t = 5;
#[doc = " VORTEX Code Version Management\n\n Manages multiple compiled versions of a single method. This is essential\n for concurrent compilation and tiered optimization:\n\n   - While T2 compiles in the background, T1 code continues to run\n   - When T2 finishes, T1 is deprecated (not removed — running threads\n     may still be executing it)\n   - T1 is freed only after all threads have exited the old version\n   - Deoptless continuations create alternative versions with failed\n     speculations removed\n   - Class loads may invalidate specific versions\n\n Version lifecycle:\n\n   Compiling → Active → Deprecated → Freed\n                    ↓\n               Invalidated\n\n Transitions:\n   Compiling → Active:    compilation finished, code installed\n   Active → Deprecated:   a newer version is installed\n   Deprecated → Freed:    no threads are executing this version\n   Active → Invalidated:  a dependency was broken (class load, etc.)\n   Compiling → Invalidated: compilation was cancelled\n\n Thread safety:\n   - Version state transitions are protected by a per-method mutex\n   - Reference counting tracks how many threads are executing each version\n   - A version is freed only when refcount drops to zero after deprecation"]
pub type vtx_version_state_t = ::std::os::raw::c_uint;
extern "C" {
    pub fn vtx_version_state_name(s: vtx_version_state_t) -> *const ::std::os::raw::c_char;
}
#[doc = " A single compiled version of a method. Multiple versions can exist\n simultaneously (e.g., T1 active while T2 compiles, or deoptless\n continuation alongside the main version)."]
pub type vtx_code_version_t = vtx_code_version;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_code_version {
    pub method_id: u32,
    pub version_id: u32,
    pub tier: vtx_compile_tier_t,
    pub state: vtx_version_state_t,
    pub compiled: *mut vtx_compiled_method_t,
    pub refcount: i32,
    pub compile_start_ns: u64,
    pub compile_end_ns: u64,
    pub activate_ns: u64,
    pub deprecate_ns: u64,
    pub next_version: *mut vtx_code_version_t,
    pub prev_version: *mut vtx_code_version_t,
    pub is_deoptless: bool,
    pub deoptless_guard_id: u32,
}
impl Default for vtx_code_version {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Per-method version chain: linked list of versions from oldest to newest."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_method_versions_t {
    pub method_id: u32,
    pub newest: *mut vtx_code_version_t,
    pub oldest: *mut vtx_code_version_t,
    pub version_count: u32,
    pub method_mutex: pthread_mutex_t,
}
impl Default for vtx_method_versions_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_version_manager_t {
    pub methods: *mut *mut vtx_method_versions_t,
    pub method_count: u32,
    pub capacity: u32,
    pub global_mutex: pthread_mutex_t,
    pub total_versions_created: u32,
    pub total_versions_deprecated: u32,
    pub total_versions_invalidated: u32,
    pub total_versions_freed: u32,
    pub arena: *mut vtx_arena_t,
}
impl Default for vtx_version_manager_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the version manager.\n\n @param manager Version manager to initialize\n @param arena   Arena for allocating version structures\n @return        0 on success, -1 on failure"]
    pub fn vtx_version_manager_init(
        manager: *mut vtx_version_manager_t,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the version manager and free all resources."]
    pub fn vtx_version_manager_destroy(manager: *mut vtx_version_manager_t);
}
extern "C" {
    #[doc = " Create a new code version for a method (in Compiling state).\n\n @param manager   Version manager\n @param method_id Method ID\n @param tier      Compilation tier\n @return          New code version, or NULL on failure"]
    pub fn vtx_version_create_compiling(
        manager: *mut vtx_version_manager_t,
        method_id: u32,
        tier: vtx_compile_tier_t,
    ) -> *mut vtx_code_version_t;
}
extern "C" {
    #[doc = " Install a compiled version: transition from Compiling → Active.\n\n @param manager   Version manager\n @param method_id Method ID\n @param version   The version to install\n @param compiled  The compiled method metadata\n @return          0 on success, -1 on failure"]
    pub fn vtx_version_install(
        manager: *mut vtx_version_manager_t,
        method_id: u32,
        version: *mut vtx_code_version_t,
        compiled: *mut vtx_compiled_method_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Deprecate a version: transition from Active → Deprecated.\n This happens when a newer version is installed.\n\n The deprecated version is not freed immediately — it remains in\n memory until all threads have exited it (refcount drops to zero).\n\n @param manager Version manager\n @param version The version to deprecate\n @return        0 on success, -1 on failure"]
    pub fn vtx_version_deprecate(
        manager: *mut vtx_version_manager_t,
        version: *mut vtx_code_version_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Invalidate all versions of a method.\n This happens when a class load breaks a dependency.\n\n All active and compiling versions are transitioned to Invalidated.\n Deprecated versions are also invalidated if they haven't been freed yet.\n\n @param manager   Version manager\n @param method_id Method ID to invalidate\n @return          Number of versions invalidated"]
    pub fn vtx_version_invalidate(manager: *mut vtx_version_manager_t, method_id: u32) -> u32;
}
extern "C" {
    #[doc = " Free a deprecated version whose refcount has dropped to zero.\n Transition: Deprecated → Freed.\n\n @param manager Version manager\n @param version The version to free\n @return        0 on success, -1 on failure"]
    pub fn vtx_version_free(
        manager: *mut vtx_version_manager_t,
        version: *mut vtx_code_version_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Increment the reference count of a version (a thread is entering it)."]
    pub fn vtx_version_enter(version: *mut vtx_code_version_t);
}
extern "C" {
    #[doc = " Decrement the reference count of a version (a thread is leaving it).\n If the count drops to zero and the version is deprecated, it is freed.\n\n @param manager Version manager\n @param version The version being exited\n @return        true if the version was freed, false otherwise"]
    pub fn vtx_version_exit(
        manager: *mut vtx_version_manager_t,
        version: *mut vtx_code_version_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Get the active version for a method.\n Returns NULL if no active version exists."]
    pub fn vtx_version_get_active(
        manager: *mut vtx_version_manager_t,
        method_id: u32,
    ) -> *mut vtx_code_version_t;
}
extern "C" {
    #[doc = " Get the newest version for a method (regardless of state).\n Returns NULL if no versions exist."]
    pub fn vtx_version_get_newest(
        manager: *mut vtx_version_manager_t,
        method_id: u32,
    ) -> *mut vtx_code_version_t;
}
extern "C" {
    #[doc = " Get the number of versions for a method."]
    pub fn vtx_version_count(manager: *mut vtx_version_manager_t, method_id: u32) -> u32;
}
extern "C" {
    #[doc = " Check if a specific version is still valid for execution."]
    pub fn vtx_version_is_executable(version: *const vtx_code_version_t) -> bool;
}
extern "C" {
    #[doc = " Find the highest active version for a method at or below the given tier.\n Used for direct T3→T2 deoptimization: when a T3 guard fails and deoptless\n is unavailable, find a T2 version to jump to instead of the interpreter.\n\n @param manager   Version manager\n @param method_id Method ID\n @param max_tier  Maximum tier to consider (e.g., VTX_TIER_OPTIMIZING for T2)\n @return          Active version at or below max_tier, or NULL if none found"]
    pub fn vtx_version_find_tier(
        manager: *mut vtx_version_manager_t,
        method_id: u32,
        max_tier: vtx_compile_tier_t,
    ) -> *mut vtx_code_version_t;
}
#[doc = " VORTEX SOTA — Continuous Background Recompilation\n\n Monitors profile data in real-time and triggers recompilation when\n type profiles diverge from the assumptions used during the previous\n compilation.\n\n The key metric is KL divergence (Kullback-Leibler) between the\n type profile at compilation time and the current type profile.\n When KL divergence exceeds VTX_PROFILE_DIVERGENCE_THRESHOLD (0.5),\n the method is queued for recompilation with updated profile data.\n\n The new version is compiled in the background and installed at the\n next safe point, with zero pause to the executing application.\n\n KL divergence measures how much information is lost when using the\n old profile to approximate the current profile. A value of 0 means\n identical distributions; values > 0.5 indicate significant divergence.\n\n Formula:\n   KL(P || Q) = Σ P(i) * ln(P(i) / Q(i))\n where P = current profile, Q = compilation-time profile\n\n Smoothing: to avoid ln(0), we add a small epsilon (1e-6) to both\n P(i) and Q(i) before computing the ratio."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_recomp_check_t {
    pub should_recompile: bool,
    pub kl_divergence: f64,
    pub divergent_call_sites: u32,
    pub method_id: u32,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_recomp_queue_entry_t {
    pub method_id: u32,
    pub kl_divergence: f64,
    pub enqueue_time_ns: u64,
    pub processed: bool,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_recomp_snapshot {
    _unused: [u8; 0],
}
pub type vtx_recomp_snapshot_t = vtx_recomp_snapshot;
#[doc = " Per-method hysteresis state for KL-divergence recompilation.\n\n Without hysteresis, the orchestrator fires recomp on every divergent\n sample. A workload that oscillates between two phases causes the same\n method to be recompiled repeatedly — thrashing.\n\n Hysteresis requires VTX_RECOMP_HYSTERESIS_CONSECUTIVE consecutive\n divergent samples before triggering recompilation. A non-divergent\n sample resets the counter to zero.\n\n The state is keyed by method_id and stored in a small hash table\n inside vtx_sota_recomp_t. Lookups are O(1) amortized."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_recomp_hysteresis_t {
    pub method_id: u32,
    pub consecutive_divergent: u32,
    pub last_recomp_time_ns: u64,
    pub recomp_count_in_window: u64,
    pub window_start_ns: u64,
    pub valid: bool,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_sota_recomp_t {
    pub snapshots: *mut vtx_recomp_snapshot_t,
    pub snapshot_count: u32,
    pub snapshot_capacity: u32,
    pub recomp_queue: *mut vtx_recomp_queue_entry_t,
    pub recomp_queue_count: u32,
    pub recomp_queue_capacity: u32,
    pub hysteresis: *mut vtx_recomp_hysteresis_t,
    pub hysteresis_count: u32,
    pub hysteresis_capacity: u32,
    pub total_dropped_soft_cap: u64,
    pub total_dropped_hard_cap: u64,
    pub total_coalesced: u64,
    pub total_checks: u64,
    pub total_recompilations_triggered: u64,
    pub total_false_positives: u64,
    pub total_hysteresis_blocks: u64,
}
impl Default for vtx_sota_recomp_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the recompilation monitor.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_sota_recomp_init(recomp: *mut vtx_sota_recomp_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the recompilation monitor and free memory."]
    pub fn vtx_sota_recomp_destroy(recomp: *mut vtx_sota_recomp_t);
}
extern "C" {
    #[doc = " Save a profile snapshot for a method at compilation time.\n This snapshot is used later for KL divergence comparison.\n\n @param recomp     Recompilation monitor\n @param method_id  Method that was compiled\n @param profile    Global profile data at compilation time\n @return           0 on success, -1 on failure"]
    pub fn vtx_sota_recomp_save_snapshot(
        recomp: *mut vtx_sota_recomp_t,
        method_id: u32,
        profile: *const vtx_profile_global_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Remove the snapshot for a method (e.g., when the method is invalidated)."]
    pub fn vtx_sota_recomp_remove_snapshot(recomp: *mut vtx_sota_recomp_t, method_id: u32);
}
extern "C" {
    #[doc = " Check if a compiled method should be recompiled based on\n profile divergence.\n\n Compares the current type profile at each call site with the\n snapshot taken at compilation time. If the KL divergence at\n any call site exceeds VTX_PROFILE_DIVERGENCE_THRESHOLD,\n recommends recompilation.\n\n @param recomp     Recompilation monitor\n @param profile    Current global profile data\n @param method_id  Method to check\n @return           Check result with should_recompile flag and details"]
    pub fn vtx_sota_recomp_check(
        recomp: *const vtx_sota_recomp_t,
        profile: *const vtx_profile_global_t,
        method_id: u32,
    ) -> vtx_recomp_check_t;
}
extern "C" {
    #[doc = " Compute KL divergence between two type distributions.\n\n Each distribution is represented as an array of (type_id, frequency) pairs.\n The frequencies are normalized to probabilities internally.\n\n @param types_a    Type IDs in distribution A (current)\n @param freqs_a    Frequencies for distribution A\n @param count_a    Number of entries in distribution A\n @param types_b    Type IDs in distribution B (compilation-time)\n @param freqs_b    Frequencies for distribution B\n @param count_b    Number of entries in distribution B\n @return           KL divergence value (>= 0)"]
    pub fn vtx_kl_divergence(
        types_a: *const vtx_typeid_t,
        freqs_a: *const u64,
        count_a: u32,
        types_b: *const vtx_typeid_t,
        freqs_b: *const u64,
        count_b: u32,
    ) -> f64;
}
extern "C" {
    #[doc = " Compute KL divergence between two call site profiles.\n Convenience wrapper that extracts type distributions."]
    pub fn vtx_kl_divergence_callsite(
        current: *const vtx_callsite_profile_t,
        compiled: *const vtx_callsite_profile_t,
    ) -> f64;
}
extern "C" {
    #[doc = " Compute KL divergence between two per-type frequency distributions.\n Uses the D5 per-type frequency data for accurate divergence measurement.\n New types not seen at compilation time receive a large penalty (10.0).\n\n @param current   Current per-type frequency distribution\n @param compiled  Per-type frequency distribution at compilation time\n @return          KL divergence value (>= 0)"]
    pub fn vtx_recomp_kl_divergence_freq(
        current: *const vtx_type_freq_t,
        compiled: *const vtx_type_freq_t,
    ) -> f64;
}
extern "C" {
    #[doc = " Compute KL divergence between two method profiles.\n\n This compares the type distributions at each call site between\n the old (compilation-time) profile and the new (current) profile.\n Returns the maximum KL divergence across all call sites.\n\n A high divergence means the current execution pattern has shifted\n significantly from what was assumed at compilation time, and\n recompilation would likely produce better code.\n\n @param old_profile  Method profile at compilation time\n @param new_profile  Current method profile\n @return             Maximum KL divergence across call sites (>= 0)"]
    pub fn vtx_sota_recomp_compute_divergence(
        old_profile: *const vtx_profile_method_t,
        new_profile: *const vtx_profile_method_t,
    ) -> f64;
}
extern "C" {
    #[doc = " Queue a method for recompilation with updated profile data.\n\n The method is added to the recompilation queue. A background\n compilation worker will pick it up, compile it with the\n current profile, and install the new version at the next\n safe point.\n\n If the method is already in the queue, this is a no-op\n (we don't queue duplicate compilations).\n\n @param recomp      Recompilation monitor\n @param method_id   Method to recompile\n @param new_profile Current profile data (snapshot is taken internally)"]
    pub fn vtx_sota_recomp_queue(
        recomp: *mut vtx_sota_recomp_t,
        method_id: u32,
        new_profile: *const vtx_profile_global_t,
    );
}
extern "C" {
    #[doc = " Dequeue the next method to recompile.\n\n Returns the method_id of the next unprocessed entry, or\n VTX_PHASE_NONE if the queue is empty.\n\n @param recomp Recompilation monitor\n @return       Method ID to recompile, or VTX_PHASE_NONE"]
    pub fn vtx_sota_recomp_dequeue(recomp: *mut vtx_sota_recomp_t) -> u32;
}
extern "C" {
    #[doc = " Check if the recompilation queue has pending entries."]
    pub fn vtx_sota_recomp_has_pending(recomp: *const vtx_sota_recomp_t) -> bool;
}
extern "C" {
    #[doc = " Hysteresis-aware recompilation check.\n\n This is the same as vtx_sota_recomp_check(), but it tracks consecutive\n divergent samples per method and only returns should_recompile=true\n after VTX_RECOMP_HYSTERESIS_CONSECUTIVE consecutive divergent checks.\n A non-divergent check resets the per-method counter.\n\n Use this in the orchestrator instead of the raw check to prevent\n recomp thrashing under oscillating workloads.\n\n @param recomp     Recompilation monitor\n @param profile    Current global profile data\n @param method_id  Method to check\n @return           Check result; should_recompile is true only if the\n                   hysteresis threshold has been reached"]
    pub fn vtx_sota_recomp_check_hysteresis(
        recomp: *mut vtx_sota_recomp_t,
        profile: *const vtx_profile_global_t,
        method_id: u32,
    ) -> vtx_recomp_check_t;
}
extern "C" {
    #[doc = " Reset the hysteresis counter for a method (e.g., after a successful\n recompilation, so the counter doesn't immediately fire again).\n\n @param recomp     Recompilation monitor\n @param method_id  Method whose counter to reset"]
    pub fn vtx_sota_recomp_hysteresis_reset(recomp: *mut vtx_sota_recomp_t, method_id: u32);
}
extern "C" {
    #[doc = " Get the current consecutive-divergent count for a method.\n Returns 0 if no state exists for the method."]
    pub fn vtx_sota_recomp_hysteresis_count(
        recomp: *const vtx_sota_recomp_t,
        method_id: u32,
    ) -> u32;
}
extern "C" {
    #[doc = " Backpressure-aware queue submission.\n\n Same as vtx_sota_recomp_queue(), but enforces backpressure:\n\n   - HARD CAP: if the queue is at VTX_RECOMP_QUEUE_HARD_CAP, the entry\n     is rejected (returns false). The orchestrator will re-check the\n     method on the next tick.\n\n   - SOFT CAP: if the queue is above VTX_RECOMP_QUEUE_SOFT_CAP, the\n     lowest-priority unprocessed entry (lowest KL divergence) is\n     evicted before the new entry is added. This keeps the queue\n     drained under sustained divergence.\n\n   - COALESCE: if the same method is already queued (unprocessed) AND\n     was recompiled at least VTX_RECOMP_COALESCE_MAX_DUPLICATES times\n     within VTX_RECOMP_COALESCE_WINDOW_SEC, the older entry is removed\n     and replaced with the newer one (with updated KL divergence).\n\n @param recomp       Recompilation monitor\n @param method_id    Method to recompile\n @param new_profile  Current profile data\n @param now_ns       Current monotonic time in nanoseconds (used for\n                     coalesce windowing; pass 0 to disable coalescing)\n @return             true if the entry was queued, false if rejected\n                     by the hard cap"]
    pub fn vtx_sota_recomp_queue_backpressure(
        recomp: *mut vtx_sota_recomp_t,
        method_id: u32,
        new_profile: *const vtx_profile_global_t,
        now_ns: u64,
    ) -> bool;
}
extern "C" {
    #[doc = " Get backpressure statistics.\n\n @param recomp                Recompilation monitor\n @param dropped_soft_cap      Out: entries dropped because queue > soft cap\n @param dropped_hard_cap      Out: entries rejected because queue >= hard cap\n @param coalesced             Out: older entries merged into newer\n @param hysteresis_blocks     Out: would-have-fired but blocked by hysteresis"]
    pub fn vtx_sota_recomp_backpressure_stats(
        recomp: *const vtx_sota_recomp_t,
        dropped_soft_cap: *mut u64,
        dropped_hard_cap: *mut u64,
        coalesced: *mut u64,
        hysteresis_blocks: *mut u64,
    );
}
#[doc = " VORTEX SOTA — Feedback-Directed Inlining Recompilation\n\n Tracks inlining decision outcomes and triggers targeted recompilation\n when inlining proves unprofitable. Maintains multiple compiled versions\n with different inlining strategies, switching based on performance.\n\n When an inlined call site causes repeated deoptimizations:\n   1. Record the call site as \"unprofitable inline\"\n   2. Queue a recompilation of the method with that call site\n      forced to no-inline\n   3. Install the new version at the next safe point\n   4. The old version remains active for threads still executing it\n      (version coexistence via the version manager)\n\n When an un-inlined call site would benefit from inlining:\n   1. Record the call site as \"missed inline opportunity\"\n   2. Queue recompilation with that call site forced to inline\n   3. Same version management as above\n\n The FDI system works closely with the inliner feedback module,\n adding the ability to trigger recompilations based on feedback."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_fdi_method_record_t {
    pub method_id: u32,
    pub has_unprofitable_inlines: bool,
    pub has_missed_inlines: bool,
    pub unprofitable_site_count: u32,
    pub missed_site_count: u32,
    pub no_inline_sites: *mut u64,
    pub no_inline_count: u32,
    pub no_inline_capacity: u32,
    pub force_inline_sites: *mut u64,
    pub force_inline_count: u32,
    pub force_inline_capacity: u32,
    pub current_version_id: u32,
    pub recompilation_count: u32,
    pub deopt_count_at_inlined_sites: u64,
    pub total_executions: u64,
    pub spill_rate: f64,
    pub deopt_rate: f64,
    pub spill_count: u64,
    pub total_instructions: u64,
    pub alternative_versions: *mut u32,
    pub alternative_version_count: u32,
    pub alternative_version_capacity: u32,
    pub best_version_id: u32,
    pub best_version_score: f64,
}
impl Default for vtx_fdi_method_record_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_sota_fdi_t {
    pub records: *mut vtx_fdi_method_record_t,
    pub record_count: u32,
    pub record_capacity: u32,
    pub feedback: *mut vtx_inline_feedback_t,
    pub total_recompilations: u32,
    pub total_methods_improved: u32,
    pub total_methods_worse: u32,
}
impl Default for vtx_sota_fdi_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the FDI system.\n\n @param fdi      FDI state to initialize\n @param feedback Inline feedback tracker (not owned, must outlive FDI)\n @return         0 on success, -1 on failure"]
    pub fn vtx_sota_fdi_init(
        fdi: *mut vtx_sota_fdi_t,
        feedback: *mut vtx_inline_feedback_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the FDI system and free memory."]
    pub fn vtx_sota_fdi_destroy(fdi: *mut vtx_sota_fdi_t);
}
extern "C" {
    #[doc = " Evaluate whether a method should be recompiled with different\n inlining decisions based on feedback.\n\n Checks:\n   1. Are any inlined call sites in this method marked as unprofitable?\n   2. Are any non-inlined call sites in this method now good inline candidates?\n   3. Has the method's deopt rate exceeded VTX_INLINE_DEOPT_THRESHOLD?\n\n @param fdi       FDI state\n @param method_id Method to evaluate\n @return          true if recompilation is recommended"]
    pub fn vtx_sota_fdi_evaluate(fdi: *mut vtx_sota_fdi_t, method_id: u32) -> bool;
}
extern "C" {
    #[doc = " Get the recompilation directive for a method.\n Returns the set of call sites to force no-inline and force inline.\n\n @param fdi                FDI state\n @param method_id          Method to get directives for\n @param[out] no_inline     Array of call site IDs to force no-inline (arena-allocated)\n @param[out] no_inline_count Number of no-inline sites\n @param[out] force_inline  Array of call site IDs to force inline (arena-allocated)\n @param[out] force_inline_count Number of force-inline sites\n @return                   0 on success, -1 on failure"]
    pub fn vtx_sota_fdi_get_directives(
        fdi: *mut vtx_sota_fdi_t,
        method_id: u32,
        arena: *mut vtx_arena_t,
        no_inline: *mut *mut u64,
        no_inline_count: *mut u32,
        force_inline: *mut *mut u64,
        force_inline_count: *mut u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Record that a deoptimization occurred at an inlined call site.\n This may trigger a recompilation recommendation.\n\n @param fdi          FDI state\n @param method_id    Method containing the inlined call site\n @param call_site_id Call site where deopt occurred"]
    pub fn vtx_sota_fdi_record_deopt(fdi: *mut vtx_sota_fdi_t, method_id: u32, call_site_id: u64);
}
extern "C" {
    #[doc = " Record that a method execution completed successfully.\n Used to compute deopt rates and detect when inlining is profitable.\n\n @param fdi       FDI state\n @param method_id Method that executed"]
    pub fn vtx_sota_fdi_record_execution(fdi: *mut vtx_sota_fdi_t, method_id: u32);
}
extern "C" {
    #[doc = " Record that a recompilation was completed for a method.\n Updates the current version tracking.\n\n @param fdi          FDI state\n @param method_id    Method that was recompiled\n @param new_version  New version ID"]
    pub fn vtx_sota_fdi_record_recompilation(
        fdi: *mut vtx_sota_fdi_t,
        method_id: u32,
        new_version: u32,
    );
}
extern "C" {
    #[doc = " Record performance metrics for a compiled method.\n\n Tracks spill rate and deopt rate to detect when inlining is\n unprofitable. When either rate exceeds its threshold:\n   - spill_rate > VTX_SPILL_THRESHOLD (10%): inlining increased register\n     pressure beyond available registers, causing excessive spills\n   - deopt_rate > VTX_INLINE_DEOPT_THRESHOLD (5%): inlined guards are\n     failing too often, making the inlined code path useless\n\n If either threshold is exceeded, the method is flagged for\n recompilation with different inlining decisions.\n\n This also feeds back to the ML model immediately: the feature\n vector and outcome are recorded for the next training cycle.\n\n @param fdi         FDI state\n @param method_id   Method to record performance for\n @param spill_rate  Register spill rate (0.0 to 1.0)\n @param deopt_rate  Deoptimization rate (0.0 to 1.0)"]
    pub fn vtx_sota_fdi_record_performance(
        fdi: *mut vtx_sota_fdi_t,
        method_id: u32,
        spill_rate: f64,
        deopt_rate: f64,
    );
}
extern "C" {
    #[doc = " Get the best replacement version for a method.\n\n If a method has multiple compiled versions with different inlining\n decisions, this function returns the version that has the best\n performance so far. This enables dynamic switching between\n compiled versions at safe points.\n\n If no better version exists, returns the current version ID.\n\n @param fdi       FDI state\n @param method_id Method to query\n @return          Version ID of the best-performing version"]
    pub fn vtx_sota_fdi_get_replacement_version(fdi: *mut vtx_sota_fdi_t, method_id: u32) -> u32;
}
extern "C" {
    #[doc = " Register an alternative compiled version for a method.\n\n When a recompilation produces a new version with different inlining\n decisions, it is registered here. The FDI system tracks multiple\n versions and can switch between them based on performance.\n\n @param fdi         FDI state\n @param method_id   Method that has a new alternative version\n @param version_id  New version ID"]
    pub fn vtx_sota_fdi_register_version(fdi: *mut vtx_sota_fdi_t, method_id: u32, version_id: u32);
}
extern "C" {
    #[doc = " Update the performance score of a specific version.\n\n The score is computed as:\n   score = (1 - spill_rate) * (1 - deopt_rate) * execution_speedup\n Higher is better. This is used to determine which version to use.\n\n @param fdi         FDI state\n @param method_id   Method\n @param version_id  Version to update\n @param score       Performance score (higher is better)"]
    pub fn vtx_sota_fdi_update_version_score(
        fdi: *mut vtx_sota_fdi_t,
        method_id: u32,
        version_id: u32,
        score: f64,
    );
}
extern "C" {
    #[doc = " Get the next method that FDI recommends for recompilation.\n\n Iterates over all tracked methods and returns the method_id of\n the next method that vtx_sota_fdi_evaluate() recommends for\n recompilation. Returns VTX_PHASE_NONE if no more candidates exist.\n\n Each call advances an internal cursor so that repeated calls\n enumerate all candidates without duplication.\n\n @param fdi       FDI state\n @return          Method ID of the next recompilation candidate,\n                  or VTX_PHASE_NONE if no more candidates"]
    pub fn vtx_sota_fdi_next_recompile_candidate(fdi: *mut vtx_sota_fdi_t) -> u32;
}
#[doc = " A phase hash: identifies a specific execution phase.\n Computed from the call stack's type signature at the time\n of compilation. Same phase hash = same type behavior expected.\n\n The hash is computed using FNV-1a over the type feedback for a method,\n capturing the dominant type at each call site and the shape at each\n field access site. This is similar to vtx_profile_compute_hash() in\n deoptless.c but focuses on the current phase's type distribution rather\n than the full profile history."]
pub type vtx_phase_hash_t = u64;
#[doc = " Phase-version entry: maps a phase hash to a parked version.\n\n Each entry records the phase hash that the version was compiled for,\n a pointer to the parked code version, and metadata for LRU eviction\n (park time) and reactivation statistics.\n\n An entry becomes invalid when its parked version is freed due to\n memory pressure. The entry slot is then available for reuse."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_phase_version_entry_t {
    pub phase_hash: vtx_phase_hash_t,
    pub parked_version: *mut vtx_code_version_t,
    pub method_id: u32,
    pub park_time_ns: u64,
    pub reactivate_count: u64,
    pub is_valid: bool,
}
impl Default for vtx_phase_version_entry_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Per-method phase-version registry.\n Tracks parked versions for each execution phase of a single method.\n\n The entries array is a fixed-size open-addressing table with linear\n probing. Phase hash collisions are handled by chaining to the next\n free slot. The table is deliberately small (16 entries) because:\n   1. Most methods have 2-4 distinct phases\n   2. Parked versions consume memory, so we cap the total\n   3. Linear scan over 16 entries is faster than a hash table for\n      these sizes"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_phase_version_registry_t {
    pub method_id: u32,
    pub entries: [vtx_phase_version_entry_t; 16usize],
    pub entry_count: u32,
    pub current_phase_hash: vtx_phase_hash_t,
    pub total_reactivations: u32,
    pub total_recompilations: u32,
    pub total_evictions: u32,
}
impl Default for vtx_phase_version_registry_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Global phase-reactive version manager.\n\n Manages per-method registries and enforces a global code budget for\n parked versions. When the budget is exceeded, the least recently parked\n versions are evicted first (LRU policy based on park_time_ns).\n\n Thread safety: all operations on the manager are protected by the\n manager_mutex. Individual version state transitions are additionally\n protected by the version manager's per-method mutex."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_phase_react_manager_t {
    pub registries: *mut vtx_phase_version_registry_t,
    pub registry_count: u32,
    pub registry_capacity: u32,
    pub parked_code_budget: usize,
    pub parked_code_used: usize,
    pub manager_mutex: pthread_mutex_t,
    pub total_parked_versions: u32,
    pub total_reactivated_versions: u32,
    pub total_evicted_versions: u32,
}
impl Default for vtx_phase_react_manager_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the phase-reactive version manager.\n\n @param mgr         Manager to initialize\n @param code_budget Total bytes of code that may be parked before\n                    eviction kicks in. Use VTX_PHASE_REACT_DEFAULT_CODE_BUDGET\n                    for the default (8 MB).\n @return            0 on success, -1 on failure"]
    pub fn vtx_phase_react_manager_init(
        mgr: *mut vtx_phase_react_manager_t,
        code_budget: usize,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the phase-reactive version manager and release all resources.\n Does NOT free the parked code versions themselves — those are owned\n by the version manager (compile/version.h). This only frees the\n registry structures.\n\n @param mgr  Manager to destroy"]
    pub fn vtx_phase_react_manager_destroy(mgr: *mut vtx_phase_react_manager_t);
}
extern "C" {
    #[doc = " Get or create a phase-version registry for a method.\n\n The registry is created on first access for a method_id.\n Subsequent calls with the same method_id return the existing registry.\n\n Thread safety: caller must NOT hold manager_mutex (this function\n acquires it internally).\n\n @param mgr        Phase-reactive manager\n @param method_id  Method ID\n @return           Pointer to the registry, or NULL on failure"]
    pub fn vtx_phase_react_get_registry(
        mgr: *mut vtx_phase_react_manager_t,
        method_id: u32,
    ) -> *mut vtx_phase_version_registry_t;
}
extern "C" {
    #[doc = " Park the current active version for a method's current phase.\n\n Called when:\n   1. A phase transition is detected (the method is about to switch\n      to a different execution phase)\n   2. A newer version is installed (the current version becomes deprecated)\n\n The version's state is transitioned from Active to Parked. Its compiled\n code remains in memory and can be reactivated when the same phase recurs.\n\n If the registry is full (VTX_PHASE_REACT_MAX_PARKED entries), the\n oldest parked version (by park_time_ns) is evicted to make room.\n\n If memory pressure is high (parked_code_used > parked_code_budget),\n the oldest parked versions across all methods are evicted before\n parking the new one.\n\n @param mgr         Phase-reactive manager\n @param method_id   Method ID\n @param version     The version to park (must be Active or Deprecated)\n @param phase_hash  The phase hash this version was compiled for\n @return            0 on success, -1 on failure"]
    pub fn vtx_phase_react_park(
        mgr: *mut vtx_phase_react_manager_t,
        method_id: u32,
        version: *mut vtx_code_version_t,
        phase_hash: vtx_phase_hash_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Try to reactivate a parked version for a given phase.\n\n Looks up the phase hash in the method's registry. If a valid parked\n version exists, it is transitioned from Parked → Active and returned.\n The reactivation is O(1): no recompilation, no code generation.\n\n If no parked version exists for the given phase, returns NULL.\n The caller should then trigger background compilation for the new phase.\n\n Thread safety: acquires manager_mutex internally. The caller is\n responsible for installing the reactivated version as the method's\n active code (via the version manager).\n\n @param mgr         Phase-reactive manager\n @param method_id   Method ID\n @param phase_hash  The phase hash to look up\n @return            The reactivated version, or NULL if no parked version exists"]
    pub fn vtx_phase_react_try_reactivate(
        mgr: *mut vtx_phase_react_manager_t,
        method_id: u32,
        phase_hash: vtx_phase_hash_t,
    ) -> *mut vtx_code_version_t;
}
extern "C" {
    #[doc = " Evict the oldest parked version for a method (LRU eviction).\n\n Finds the entry with the smallest park_time_ns and frees the\n associated parked version. The entry is marked as invalid and\n the slot becomes available for reuse.\n\n Called when the per-method registry is full, or when global\n memory pressure requires eviction.\n\n @param mgr        Phase-reactive manager\n @param method_id  Method ID\n @return           0 on success, -1 if no valid parked version to evict"]
    pub fn vtx_phase_react_evict_oldest(
        mgr: *mut vtx_phase_react_manager_t,
        method_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Evict parked versions globally until the code budget is satisfied.\n\n Iterates over all registries and evicts the oldest parked versions\n (by park_time_ns) until parked_code_used <= parked_code_budget.\n\n This is called after parking a new version to ensure the budget\n constraint is maintained.\n\n @param mgr  Phase-reactive manager\n @return     Number of versions evicted"]
    pub fn vtx_phase_react_evict_for_budget(mgr: *mut vtx_phase_react_manager_t) -> u32;
}
extern "C" {
    #[doc = " Check if memory pressure requires eviction.\n\n Returns true if the total size of parked code exceeds the budget.\n\n @param mgr  Phase-reactive manager\n @return     true if eviction is needed"]
    pub fn vtx_phase_react_needs_eviction(mgr: *const vtx_phase_react_manager_t) -> bool;
}
extern "C" {
    #[doc = " Compute a phase hash from the current execution context.\n\n The hash captures the type signature of the current call stack:\n   1. The dominant type at each call site (top type from type_freq)\n   2. The shape at each field access site\n\n This is similar to vtx_profile_compute_hash() in deoptless.c but\n focuses on the current phase's type distribution rather than the\n full profile history. The hash uses FNV-1a for robust distribution.\n\n Two execution contexts with the same phase hash are expected to\n exhibit the same type behavior, so a version compiled for one\n should work for the other without recompilation.\n\n @param type_feedback  Type feedback data for the method\n @param method_id      Method ID\n @return               Phase hash, or VTX_PHASE_HASH_NONE on failure"]
    pub fn vtx_phase_react_compute_hash(
        type_feedback: *const vtx_type_feedback_t,
        method_id: u32,
    ) -> vtx_phase_hash_t;
}
extern "C" {
    #[doc = " Get global phase-reactive statistics.\n\n @param mgr               Phase-reactive manager\n @param total_parked      Output: total parked versions currently held\n @param total_reactivated Output: total successful reactivations\n @param total_evicted     Output: total evicted versions"]
    pub fn vtx_phase_react_get_stats(
        mgr: *const vtx_phase_react_manager_t,
        total_parked: *mut u32,
        total_reactivated: *mut u32,
        total_evicted: *mut u32,
    );
}
extern "C" {
    #[doc = " Get per-method phase-reactive statistics.\n\n @param registry           Per-method registry\n @param reactivations      Output: successful reactivations for this method\n @param recompilations     Output: recompilations that could have been avoided\n @param evictions          Output: evicted parked versions for this method"]
    pub fn vtx_phase_react_get_method_stats(
        registry: *const vtx_phase_version_registry_t,
        reactivations: *mut u32,
        recompilations: *mut u32,
        evictions: *mut u32,
    );
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_orchestrator_struct {
    pub markov: *mut vtx_markov_t,
    pub phase_detector: *mut vtx_sota_phase_t,
    pub recomp: *mut vtx_sota_recomp_t,
    pub fdi: *mut vtx_sota_fdi_t,
    pub phase_react: *mut vtx_phase_react_manager_t,
    pub threadpool: *mut vtx_threadpool_t,
    pub type_feedback: *mut vtx_type_feedback_t,
    pub profile: *mut vtx_profile_global_t,
    pub inline_feedback: *mut vtx_inline_feedback_t,
    pub phase_partition: *mut vtx_phase_partition_t,
    pub deoptless_tables: *mut *mut vtx_deoptless_table_t,
    pub deoptless_table_count: u32,
    pub orchestrator_thread: pthread_t,
    pub mutex: pthread_mutex_t,
    pub wake_cond: pthread_cond_t,
    pub running: bool,
    pub shutdown_requested: bool,
    pub check_interval_ms: u32,
    pub min_profile_observations: u32,
    pub proactive_compile_limit: u32,
    pub total_checks: u64,
    pub total_phase_predictions: u64,
    pub total_proactive_compiles: u64,
    pub total_recomp_triggers: u64,
    pub total_fdi_recompiles: u64,
    pub total_phase_reactivations: u64,
    pub total_phase_partition_transitions: u64,
    pub total_phase_preemptive_recompiles: u64,
    pub decision_submit_counts: [u64; 8usize],
    pub decision_deopt_count: u64,
}
impl Default for vtx_orchestrator_struct {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
pub type vtx_orchestrator_t = vtx_orchestrator_struct;
extern "C" {
    #[doc = " Initialize the runtime orchestrator.\n\n All subsystem pointers are stored but NOT owned — the caller must\n ensure they remain valid for the lifetime of the orchestrator.\n Any pointer may be NULL to disable that particular wiring.\n\n @param orch         Orchestrator to initialize\n @param markov       Markov chain (may be NULL)\n @param phase        Phase detector (may be NULL)\n @param recomp       Recomp monitor (may be NULL)\n @param fdi          FDI tracker (may be NULL)\n @param threadpool   Compilation threadpool (may be NULL)\n @param phase_react  Phase-reactive manager (may be NULL)\n @param type_feedback Runtime type feedback (may be NULL)\n @param profile      Global profile data (may be NULL)\n @param inline_feedback Inline feedback tracker (may be NULL)\n @return             0 on success, -1 on failure"]
    pub fn vtx_orchestrator_init(
        orch: *mut vtx_orchestrator_t,
        markov: *mut vtx_markov_t,
        phase: *mut vtx_sota_phase_t,
        recomp: *mut vtx_sota_recomp_t,
        fdi: *mut vtx_sota_fdi_t,
        threadpool: *mut vtx_threadpool_t,
        phase_react: *mut vtx_phase_react_manager_t,
        type_feedback: *mut vtx_type_feedback_t,
        profile: *mut vtx_profile_global_t,
        inline_feedback: *mut vtx_inline_feedback_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Start the orchestrator background thread.\n\n The thread wakes up periodically and on explicit events to\n perform wiring functions (proactive compilation, drift checks, etc.)\n\n @param orch  Orchestrator to start\n @return      0 on success, -1 on failure"]
    pub fn vtx_orchestrator_start(orch: *mut vtx_orchestrator_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Stop the orchestrator background thread and wait for it to finish.\n\n @param orch  Orchestrator to stop"]
    pub fn vtx_orchestrator_stop(orch: *mut vtx_orchestrator_t);
}
extern "C" {
    #[doc = " Destroy the orchestrator and release resources.\n Stops the background thread if running.\n\n @param orch  Orchestrator to destroy"]
    pub fn vtx_orchestrator_destroy(orch: *mut vtx_orchestrator_t);
}
extern "C" {
    #[doc = " Notify the orchestrator that a method entry occurred.\n\n This feeds the method entry to the Markov chain and phase detector,\n which may trigger proactive compilation for the predicted next phase.\n\n @param orch         Orchestrator\n @param method_id    Method that was just entered"]
    pub fn vtx_orchestrator_on_method_entry(orch: *mut vtx_orchestrator_t, method_id: u32);
}
extern "C" {
    #[doc = " Notify the orchestrator that a deoptimization occurred.\n\n This feeds the deopt event to FDI, which tracks unprofitable inlines\n and may recommend recompilation with different inlining decisions.\n Also records the failed guard in the guard metadata system.\n\n @param orch         Orchestrator\n @param method_id    Method where the deopt occurred\n @param call_site_id Call site where the deopt occurred\n @param guard_id     Guard that failed (may be VTX_GUARD_ID_INVALID)"]
    pub fn vtx_orchestrator_on_deopt(
        orch: *mut vtx_orchestrator_t,
        method_id: u32,
        call_site_id: u64,
        guard_id: u32,
    );
}
extern "C" {
    #[doc = " Notify the orchestrator that a compilation completed.\n\n This saves a profile snapshot in the recomp monitor (so we can\n detect drift later) and records the new version in FDI.\n\n @param orch         Orchestrator\n @param method_id    Method that was compiled\n @param version_id   New version ID"]
    pub fn vtx_orchestrator_on_compile_done(
        orch: *mut vtx_orchestrator_t,
        method_id: u32,
        version_id: u32,
    );
}
extern "C" {
    #[doc = " Wake the orchestrator immediately (e.g., after a burst of deopts).\n\n Normally the orchestrator wakes on its timer. This forces an\n immediate check, which is useful when the system detects that\n something has changed significantly (e.g., a phase transition\n was detected by the interpreter).\n\n @param orch  Orchestrator to wake"]
    pub fn vtx_orchestrator_wake(orch: *mut vtx_orchestrator_t);
}
extern "C" {
    #[doc = " Attach a phase-aware profile partition to the orchestrator.\n\n After this call, the orchestrator will:\n   - Read from the partition's active phase profile (instead of the\n     static `profile` pointer) for recomp decisions.\n   - On phase transitions detected by the phase detector, call\n     vtx_phase_partition_transition() to swap the active profile.\n   - After a transition, preemptively recompile the new phase's hot\n     methods using the new phase's profile.\n\n The orchestrator does NOT own the partition — the caller must keep it\n alive for the orchestrator's lifetime and destroy it after\n vtx_orchestrator_stop().\n\n Pass NULL to detach (revert to the single-profile mode).\n\n @param orch   Orchestrator\n @param part   Phase partition (may be NULL)"]
    pub fn vtx_orchestrator_set_phase_partition(
        orch: *mut vtx_orchestrator_t,
        part: *mut vtx_phase_partition_t,
    );
}
extern "C" {
    #[doc = " Manually trigger a phase partition transition.\n\n Called by the interpreter/runtime when a phase transition is detected\n outside the orchestrator's periodic check (e.g., immediately when\n the phase detector fires). This swaps the active profile and queues\n preemptive recompilation of the new phase's hot methods.\n\n If no partition is attached, this is a no-op.\n\n @param orch          Orchestrator\n @param new_phase_id  Phase to transition to"]
    pub fn vtx_orchestrator_phase_transition(orch: *mut vtx_orchestrator_t, new_phase_id: u32);
}
extern "C" {
    #[doc = " Get orchestrator statistics."]
    pub fn vtx_orchestrator_get_stats(
        orch: *const vtx_orchestrator_t,
        total_checks: *mut u64,
        total_phase_predictions: *mut u64,
        total_proactive_compiles: *mut u64,
        total_recomp_triggers: *mut u64,
        total_fdi_recompiles: *mut u64,
        total_phase_reactivations: *mut u64,
    );
}
extern "C" {
    #[doc = " Get Sprint 2 partition statistics.\n\n @param orch                              Orchestrator\n @param total_partition_transitions       Out: phase profile swaps\n @param total_preemptive_recompiles       Out: methods recompiled on phase entry"]
    pub fn vtx_orchestrator_get_partition_stats(
        orch: *const vtx_orchestrator_t,
        total_partition_transitions: *mut u64,
        total_preemptive_recompiles: *mut u64,
    );
}
#[doc = " A type signature for method versioning: the concrete types observed\n at each argument position.\n\n Named vtx_spec_type_sig_t to avoid collision with vtx_type_signature_t\n in interp/type_feedback.h, which tracks call-site receiver+result types\n for composite guard optimization. This structure tracks argument types\n for method-level versioning decisions.\n\n The signature_hash is an FNV-1a hash of arg_types, consistent with\n the hash functions used in deopt/deoptless.c and compile/phase_react.c.\n It enables O(1) signature comparison in the dispatch hot path."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_spec_type_sig_t {
    pub arg_types: [u32; 4usize],
    pub arg_count: u32,
    pub signature_hash: u64,
}
#[doc = " A type-specialized version of a method.\n\n Each version is compiled with the assumption that arguments match\n the type signature. The guard_id identifies the DeoptGuard that\n checks the type signature at the method entry point. If the guard\n fails, execution transfers to the generic version or the interpreter.\n\n The stability metric tracks how often this version's guard succeeds:\n   stability = execution_count / (execution_count + deopt_count)\n\n When stability drops below VTX_SPEC_VERSION_STABILITY_THRESHOLD,\n the version is a candidate for deactivation.\n\n Versions are stored in a prepend-based linked list (newest first)\n for O(1) insertion and preferential access to recently created versions."]
pub type vtx_spec_version_t = vtx_spec_version;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_spec_version {
    pub method_id: u32,
    pub signature: vtx_spec_type_sig_t,
    pub code_version: *mut vtx_code_version_t,
    pub execution_count: u64,
    pub deopt_count: u64,
    pub stability: f64,
    pub is_active: bool,
    pub is_compiling: bool,
    pub guard_id: u32,
    pub next: *mut vtx_spec_version_t,
}
impl Default for vtx_spec_version {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Per-method spec version registry.\n\n Tracks all type-specialized versions for a single method, plus\n per-argument type profiling data used to decide which type\n signatures are worth creating versions for.\n\n The arg_profiles array tracks the top 4 types observed at each\n argument position with their frequencies. This data drives the\n decision of whether to create a new specialized version:\n   - If a type's frequency >= VTX_SPEC_VERSION_FREQUENCY_THRESHOLD\n     and total observations >= VTX_SPEC_VERSION_MIN_OBSERVATIONS,\n     that type is a candidate for specialization.\n   - The combination of specialized types across arguments forms\n     the signature for the new version.\n\n Statistics track the dispatch efficiency: how often calls hit a\n specialized version (direct_hits) vs. fall through to the generic\n fallback (generic_fallbacks)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_spec_version_registry_t {
    pub method_id: u32,
    pub versions: *mut vtx_spec_version_t,
    pub version_count: u32,
    pub default_version: *mut vtx_spec_version_t,
    pub hot_version: *mut vtx_spec_version_t,
    pub arg_profiles: [vtx_spec_version_registry_t__bindgen_ty_1; 4usize],
    pub total_dispatches: u64,
    pub direct_hits: u64,
    pub generic_fallbacks: u64,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_spec_version_registry_t__bindgen_ty_1 {
    pub top_type_ids: [u32; 4usize],
    pub top_frequencies: [f64; 4usize],
    pub total_observations: u64,
}
impl Default for vtx_spec_version_registry_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " A loop version: a clone of a loop body with specific type assumptions.\n\n The key insight is that the type guard moves OUTSIDE the loop.\n Instead of checking the type on every iteration, we check once\n before entering the loop and execute the type-specialized loop body.\n\n For a loop that iterates N times:\n   - Without versioning: N type checks inside the loop\n   - With versioning:    1 type check before the loop\n   - Savings:            (N-1) type checks eliminated\n\n The guard_id identifies the pre-loop guard that checks:\n   - The loop items are all of item_type_id\n   - (Optionally) the loop trip count matches the expected range\n\n If the pre-loop guard fails, execution falls through to the\n generic (unversioned) loop."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_loop_version_t {
    pub method_id: u32,
    pub loop_header_pc: u32,
    pub item_type_id: u32,
    pub code_version: *mut vtx_code_version_t,
    pub guard_id: u32,
    pub execution_count: u64,
    pub is_active: bool,
}
impl Default for vtx_loop_version_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Per-loop version registry.\n\n Tracks all type-specialized versions for a single loop.\n The versions array is dynamically growing (unlike method registries\n which use linked lists) because the number of loop versions is\n typically small (1-3) and array access is faster for dispatch."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_loop_version_registry_t {
    pub method_id: u32,
    pub loop_header_pc: u32,
    pub versions: *mut vtx_loop_version_t,
    pub version_count: u32,
    pub version_capacity: u32,
    pub active_version: u32,
}
impl Default for vtx_loop_version_registry_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Global method versioning manager.\n\n Manages per-method registries for type-specialized versioning (2B)\n and per-loop registries for loop versioning (2C). The manager\n provides thread-safe access to all registries via a single mutex.\n\n Loop versioning registries are stored in a separate array indexed\n by a combined (method_id, loop_header_pc) key. In practice, most\n methods have 0-2 hot loops, so a flat array with linear scan is\n efficient. A hash table could be used if this becomes a bottleneck.\n\n The loop_versioning_stats field tracks the aggregate impact of\n loop versioning: how many loops have been versioned, how many\n type guards were hoisted out of loops, and the estimated total\n number of per-iteration type checks eliminated."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_spec_version_manager_t {
    pub registries: *mut vtx_spec_version_registry_t,
    pub registry_count: u32,
    pub registry_capacity: u32,
    pub mutex: pthread_mutex_t,
    pub loop_registries: *mut vtx_loop_version_registry_t,
    pub loop_registry_count: u32,
    pub loop_registry_capacity: u32,
    pub loop_versioning_stats: vtx_spec_version_manager_t__bindgen_ty_1,
    pub total_versions_created: u32,
    pub total_versions_deopted: u32,
    pub total_direct_dispatches: u32,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_spec_version_manager_t__bindgen_ty_1 {
    pub total_loops_versioned: u32,
    pub guards_hoisted: u32,
    pub estimated_checks_saved: u64,
}
impl Default for vtx_spec_version_manager_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the spec version manager.\n\n Allocates the registries array with VTX_SPEC_VERSION_INITIAL_CAPACITY\n entries and initializes the global mutex.\n\n @param mgr  Manager to initialize\n @return     0 on success, -1 on failure"]
    pub fn vtx_spec_version_manager_init(
        mgr: *mut vtx_spec_version_manager_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the spec version manager and release all resources.\n\n Frees all version structures, registries, and loop registries.\n Does NOT free the vtx_code_version_t objects — those are owned\n by the version manager (compile/version.h).\n\n @param mgr  Manager to destroy"]
    pub fn vtx_spec_version_manager_destroy(mgr: *mut vtx_spec_version_manager_t);
}
extern "C" {
    #[doc = " Get or create a spec version registry for a method.\n\n The registry is created on first access for a method_id.\n Subsequent calls with the same method_id return the existing registry.\n\n Thread safety: acquires mgr->mutex internally.\n\n @param mgr        Spec version manager\n @param method_id  Method ID\n @return           Pointer to the registry, or NULL on failure"]
    pub fn vtx_spec_version_get_registry(
        mgr: *mut vtx_spec_version_manager_t,
        method_id: u32,
    ) -> *mut vtx_spec_version_registry_t;
}
extern "C" {
    #[doc = " Find a type-specialized version matching the given type signature.\n\n Searches the registry's linked list for a version whose signature\n matches. Uses signature_hash for fast O(1) rejection, then verifies\n with vtx_spec_type_sig_equal for full comparison.\n\n Thread safety: caller must hold mgr->mutex or ensure the registry\n is not being concurrently modified.\n\n @param registry   Per-method registry\n @param signature  Type signature to search for\n @return           Matching version, or NULL if not found"]
    pub fn vtx_spec_version_find(
        registry: *const vtx_spec_version_registry_t,
        signature: *const vtx_spec_type_sig_t,
    ) -> *mut vtx_spec_version_t;
}
extern "C" {
    #[doc = " Create a type-specialized version for the given type signature.\n\n Allocates a new vtx_spec_version_t, initializes it with the\n signature, and prepends it to the registry's linked list.\n The version starts in is_compiling=true, is_active=false state.\n\n If the registry is at capacity (VTX_SPEC_VERSION_MAX versions),\n the least stable version is evicted to make room.\n\n Thread safety: acquires mgr->mutex internally.\n\n @param mgr        Spec version manager\n @param method_id  Method ID\n @param signature  Type signature for the new version\n @return           New version, or NULL on failure"]
    pub fn vtx_spec_version_create(
        mgr: *mut vtx_spec_version_manager_t,
        method_id: u32,
        signature: *const vtx_spec_type_sig_t,
    ) -> *mut vtx_spec_version_t;
}
extern "C" {
    #[doc = " Check whether a type signature is worth creating a version for.\n\n A signature should be specialized when:\n   1. At least one argument position has a type with frequency\n      >= VTX_SPEC_VERSION_FREQUENCY_THRESHOLD\n   2. Total dispatch observations >= VTX_SPEC_VERSION_MIN_OBSERVATIONS\n   3. The registry is not at capacity, or a less-stable version\n      can be evicted\n\n Thread safety: caller must hold mgr->mutex or ensure the registry\n is not being concurrently modified.\n\n @param registry   Per-method registry\n @param signature  Type signature to evaluate\n @return           true if specialization is recommended"]
    pub fn vtx_spec_version_should_specialize(
        registry: *const vtx_spec_version_registry_t,
        signature: *const vtx_spec_type_sig_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Record a method dispatch with the given type signature.\n\n Updates the registry's dispatch statistics and argument type profiles.\n If the signature matches an existing specialized version, increments\n that version's execution_count. Otherwise, increments generic_fallbacks.\n\n The argument type profiles are updated for each position: the observed\n type is either inserted into the top-4 list or increments an existing\n entry's frequency.\n\n Thread safety: acquires mgr->mutex internally.\n\n @param registry   Per-method registry (must be valid)\n @param signature  Type signature of the dispatch arguments"]
    pub fn vtx_spec_version_record_dispatch(
        registry: *mut vtx_spec_version_registry_t,
        signature: *const vtx_spec_type_sig_t,
    );
}
extern "C" {
    #[doc = " Compute the FNV-1a hash of a type signature.\n\n Uses the same FNV-1a constants as deopt/deoptless.c and\n compile/phase_react.c for consistency:\n   offset_basis = 14695981039346656037ULL\n   prime        = 1099511628211ULL\n\n The hash is computed over arg_types[0..arg_count-1], each hashed\n byte-by-byte for robust distribution.\n\n @param sig  Type signature\n @return     64-bit FNV-1a hash"]
    pub fn vtx_spec_type_sig_hash(sig: *const vtx_spec_type_sig_t) -> u64;
}
extern "C" {
    #[doc = " Compare two type signatures for equality.\n\n Two signatures are equal if and only if:\n   - arg_count is the same\n   - All arg_types[0..arg_count-1] are the same\n\n Uses signature_hash for fast rejection before full comparison.\n\n @param a  First signature\n @param b  Second signature\n @return   true if the signatures are equal"]
    pub fn vtx_spec_type_sig_equal(
        a: *const vtx_spec_type_sig_t,
        b: *const vtx_spec_type_sig_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Initialize a type signature from an array of argument type IDs.\n\n Sets arg_types[0..arg_count-1] from the input array, zeroes\n remaining positions, and computes the signature_hash.\n\n @param sig        Signature to initialize (must not be NULL)\n @param arg_count  Number of argument types (must be <= VTX_SPEC_VERSION_MAX_ARGS)\n @param arg_types  Array of type IDs (may be NULL if arg_count is 0)"]
    pub fn vtx_spec_type_sig_init(
        sig: *mut vtx_spec_type_sig_t,
        arg_count: u32,
        arg_types: *const u32,
    );
}
extern "C" {
    #[doc = " Get or create a loop version registry for a loop.\n\n The registry is created on first access for the given\n (method_id, loop_header_pc) pair. Subsequent calls return\n the existing registry.\n\n Thread safety: acquires mgr->mutex internally.\n\n @param mgr             Spec version manager\n @param method_id       Method ID containing the loop\n @param loop_header_pc  Bytecode PC of the loop header\n @return                Pointer to the registry, or NULL on failure"]
    pub fn vtx_loop_version_get_registry(
        mgr: *mut vtx_spec_version_manager_t,
        method_id: u32,
        loop_header_pc: u32,
    ) -> *mut vtx_loop_version_registry_t;
}
extern "C" {
    #[doc = " Create a loop version for the given item type.\n\n Allocates a new vtx_loop_version_t, initializes it, and adds it\n to the registry's versions array. The version starts in\n is_active=false state.\n\n If the registry is at capacity (VTX_LOOP_VERSION_MAX versions),\n the version with the lowest execution_count is evicted.\n\n Thread safety: acquires mgr->mutex internally.\n\n @param mgr             Spec version manager\n @param method_id       Method ID containing the loop\n @param loop_header_pc  Bytecode PC of the loop header\n @param item_type_id    Assumed type of loop items\n @return                New loop version, or NULL on failure"]
    pub fn vtx_loop_version_create(
        mgr: *mut vtx_spec_version_manager_t,
        method_id: u32,
        loop_header_pc: u32,
        item_type_id: u32,
    ) -> *mut vtx_loop_version_t;
}
extern "C" {
    #[doc = " Find a loop version matching the given item type.\n\n Searches the registry's versions array for a version with\n the specified item_type_id. Returns NULL if not found.\n\n Thread safety: caller must hold mgr->mutex or ensure the registry\n is not being concurrently modified.\n\n @param registry       Per-loop registry\n @param item_type_id   Item type to search for\n @return               Matching loop version, or NULL"]
    pub fn vtx_loop_version_find(
        registry: *const vtx_loop_version_registry_t,
        item_type_id: u32,
    ) -> *mut vtx_loop_version_t;
}
extern "C" {
    #[doc = " Check whether a loop should be versioned for the given item type.\n\n A loop should be versioned when:\n   1. The item type's frequency >= VTX_LOOP_VERSION_FREQUENCY_THRESHOLD\n   2. The loop has been observed at least VTX_LOOP_VERSION_MIN_OBSERVATIONS\n      times\n   3. The expected trip count >= VTX_LOOP_VERSION_MIN_TRIP_COUNT\n      (amortizes the pre-loop guard cost)\n\n Thread safety: caller must hold mgr->mutex or ensure the registry\n is not being concurrently modified.\n\n @param registry       Per-loop registry\n @param item_type_id   Item type to evaluate\n @param frequency      Observed frequency of this item type (0.0-1.0)\n @return               true if loop versioning is recommended"]
    pub fn vtx_loop_should_version(
        registry: *const vtx_loop_version_registry_t,
        item_type_id: u32,
        frequency: f64,
    ) -> bool;
}
extern "C" {
    #[doc = " Get global spec versioning statistics.\n\n @param mgr                 Spec version manager\n @param versions_created    Output: total type-specialized versions created\n @param versions_deopted    Output: total versions that deopted excessively\n @param direct_dispatches   Output: total dispatches hitting specialized versions"]
    pub fn vtx_spec_version_get_stats(
        mgr: *const vtx_spec_version_manager_t,
        versions_created: *mut u32,
        versions_deopted: *mut u32,
        direct_dispatches: *mut u32,
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_deopt_site_limiter_t {
    pub failure_times_ns: *mut u64,
    pub capacity: u32,
    pub head: u32,
    pub count: u32,
    pub poisoned: bool,
    pub total_failures: u64,
    pub first_failure_ns: u64,
}
impl Default for vtx_deopt_site_limiter_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn vtx_deopt_site_init(
        sl: *mut vtx_deopt_site_limiter_t,
        capacity: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_deopt_site_destroy(sl: *mut vtx_deopt_site_limiter_t);
}
extern "C" {
    pub fn vtx_deopt_site_record_failure(sl: *mut vtx_deopt_site_limiter_t, now_ns: u64) -> bool;
}
extern "C" {
    pub fn vtx_deopt_site_is_poisoned(sl: *const vtx_deopt_site_limiter_t) -> bool;
}
extern "C" {
    pub fn vtx_deopt_site_rate_per_sec(sl: *const vtx_deopt_site_limiter_t, now_ns: u64) -> f64;
}
extern "C" {
    pub fn vtx_deopt_site_reset(sl: *mut vtx_deopt_site_limiter_t);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_deopt_batcher_t {
    pub pending_sites: *mut u32,
    pub pending_times_ns: *mut u64,
    pub capacity: u32,
    pub count: u32,
    pub batch_start_ns: u64,
    pub total_batches: u64,
    pub total_deopts_coalesced: u64,
}
impl Default for vtx_deopt_batcher_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn vtx_deopt_batcher_init(
        b: *mut vtx_deopt_batcher_t,
        capacity: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_deopt_batcher_destroy(b: *mut vtx_deopt_batcher_t);
}
extern "C" {
    pub fn vtx_deopt_batcher_add(b: *mut vtx_deopt_batcher_t, site_id: u32, now_ns: u64) -> bool;
}
extern "C" {
    pub fn vtx_deopt_batcher_flush(
        b: *mut vtx_deopt_batcher_t,
        out_sites: *mut u32,
        out_capacity: u32,
        now_ns: u64,
    ) -> u32;
}
extern "C" {
    pub fn vtx_deopt_batcher_should_flush(b: *const vtx_deopt_batcher_t, now_ns: u64) -> bool;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_deopt_budget_t {
    pub deopt_times_ns: *mut u64,
    pub capacity: u32,
    pub head: u32,
    pub count: u32,
    pub budget_exceeded: bool,
    pub total_deopts: u64,
    pub suppress_start_ns: u64,
}
impl Default for vtx_deopt_budget_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn vtx_deopt_budget_init(
        gb: *mut vtx_deopt_budget_t,
        capacity: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_deopt_budget_destroy(gb: *mut vtx_deopt_budget_t);
}
extern "C" {
    pub fn vtx_deopt_budget_record(gb: *mut vtx_deopt_budget_t, now_ns: u64) -> bool;
}
extern "C" {
    pub fn vtx_deopt_budget_is_suppressed(gb: *const vtx_deopt_budget_t, now_ns: u64) -> bool;
}
extern "C" {
    pub fn vtx_deopt_budget_rate_per_sec(gb: *const vtx_deopt_budget_t, now_ns: u64) -> f64;
}
pub const vtx_deopt_decision_t_DEOPT_COORD_POISONED: vtx_deopt_decision_t = 0;
pub const vtx_deopt_decision_t_DEOPT_COORD_BATCH: vtx_deopt_decision_t = 1;
pub const vtx_deopt_decision_t_DEOPT_COORD_DEOPTLESS: vtx_deopt_decision_t = 2;
pub const vtx_deopt_decision_t_DEOPT_COORD_FULL_DEOPT: vtx_deopt_decision_t = 3;
pub const vtx_deopt_decision_t_DEOPT_COORD_SUPPRESSED: vtx_deopt_decision_t = 4;
#[doc = " VORTEX Deopt Coordinator\n ========================\n\n Audit priority #7 (Hardening) — integration layer:\n\n   \"Deopt storm resilience — the deoptless path and OSR work, but you\n    need: rate limiting, deopt batching, deopt budget.\"\n\n The rate_limit.c module provides the three primitives (per-site limiter,\n batcher, global budget) as standalone, tested units. This coordinator\n WIRING them into the actual deopt path:\n\n   1. When a guard fails at runtime, the runtime calls\n      vtx_deopt_coord_on_guard_fail(coord, site_id, now_ns).\n\n   2. The coordinator records the failure in:\n      - the per-site limiter (poisons the site if rate > 100/sec)\n      - the global budget (suppresses T2/T3 if total > 10000/sec)\n      - the batcher (coalesces pending deopts into 1ms windows)\n\n   3. The coordinator returns a decision:\n      - DEOPT_COORD_POISONED: site is poisoned → fall back to\n        interpreter permanently for this site. Do NOT recompile.\n      - DEOPT_COORD_BATCH: add to batch, defer recompilation.\n      - DEOPT_COORD_DEOPTLESS: try the deoptless continuation path.\n      - DEOPT_COORD_FULL_DEOPT: full deopt to interpreter (last resort).\n      - DEOPT_COORD_SUPPRESSED: global budget exceeded → don't recompile,\n        just fall back to interpreter for now.\n\n   4. When the batcher flushes, the coordinator triggers ONE recompilation\n      for all pending sites (via a caller-provided callback).\n\n This coordinator is OPTIONAL — the runtime can call it if present, or\n fall back to the old \"always full deopt\" path if not. This allows\n incremental rollout."]
pub type vtx_deopt_decision_t = ::std::os::raw::c_uint;
pub type vtx_deopt_recompile_fn = ::std::option::Option<
    unsafe extern "C" fn(site_ids: *const u32, count: u32, user_data: *mut ::std::os::raw::c_void),
>;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_deopt_coord_t {
    pub sites: [vtx_deopt_site_limiter_t; 4096usize],
    pub sites_inited: [bool; 4096usize],
    pub site_ids: [u32; 4096usize],
    pub batcher: vtx_deopt_batcher_t,
    pub budget: vtx_deopt_budget_t,
    pub recompile_fn: vtx_deopt_recompile_fn,
    pub recompile_user_data: *mut ::std::os::raw::c_void,
    pub total_guard_failures: u64,
    pub total_poisoned: u64,
    pub total_deoptless: u64,
    pub total_full_deopts: u64,
    pub total_suppressed: u64,
    pub total_batches_flushed: u64,
}
impl Default for vtx_deopt_coord_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn vtx_deopt_coord_init(
        coord: *mut vtx_deopt_coord_t,
        recompile_fn: vtx_deopt_recompile_fn,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_deopt_coord_destroy(coord: *mut vtx_deopt_coord_t);
}
extern "C" {
    pub fn vtx_deopt_coord_on_guard_fail(
        coord: *mut vtx_deopt_coord_t,
        site_id: u32,
        now_ns: u64,
    ) -> vtx_deopt_decision_t;
}
extern "C" {
    pub fn vtx_deopt_coord_is_poisoned(coord: *const vtx_deopt_coord_t, site_id: u32) -> bool;
}
extern "C" {
    pub fn vtx_deopt_coord_is_suppressed(coord: *const vtx_deopt_coord_t, now_ns: u64) -> bool;
}
extern "C" {
    pub fn vtx_deopt_coord_flush(coord: *mut vtx_deopt_coord_t, now_ns: u64) -> u32;
}
extern "C" {
    pub fn vtx_deopt_coord_stats_str(
        coord: *const vtx_deopt_coord_t,
        buf: *mut ::std::os::raw::c_char,
        bufsize: usize,
    );
}
pub type vtx_versioned_code_version_t = vtx_versioned_code_version;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_versioned_code_version {
    pub method_id: u32,
    pub version_number: u32,
    pub code_ptr: *mut ::std::os::raw::c_void,
    pub code_size: u32,
    pub is_active: bool,
    pub is_retired: bool,
    pub on_stack_count: i32,
    pub retire_time_ns: u64,
    pub next: *mut vtx_versioned_code_version_t,
}
impl Default for vtx_versioned_code_version {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_versioned_cache_t {
    pub cache: *mut vtx_code_cache_t,
    pub versions: [*mut vtx_versioned_code_version_t; 4096usize],
    pub next_version_number: [u32; 4096usize],
    pub total_active: u32,
    pub total_retired: u32,
    pub total_compactions: u64,
    pub total_force_frees: u64,
}
impl Default for vtx_versioned_cache_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn vtx_versioned_cache_init(
        vc: *mut vtx_versioned_cache_t,
        cache: *mut vtx_code_cache_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_versioned_cache_destroy(vc: *mut vtx_versioned_cache_t);
}
extern "C" {
    pub fn vtx_versioned_cache_install(
        vc: *mut vtx_versioned_cache_t,
        method_id: u32,
        code_ptr: *mut ::std::os::raw::c_void,
        code_size: u32,
    ) -> u32;
}
extern "C" {
    pub fn vtx_versioned_cache_get_active(
        vc: *const vtx_versioned_cache_t,
        method_id: u32,
    ) -> *mut vtx_versioned_code_version_t;
}
extern "C" {
    pub fn vtx_versioned_cache_on_enter(vc: *mut vtx_versioned_cache_t, method_id: u32);
}
extern "C" {
    pub fn vtx_versioned_cache_on_exit(vc: *mut vtx_versioned_cache_t, method_id: u32);
}
extern "C" {
    pub fn vtx_versioned_cache_patch(
        vc: *mut vtx_versioned_cache_t,
        method_id: u32,
        patch_offset: u32,
        new_bytes: *const u8,
        len: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_versioned_cache_reclaim(vc: *mut vtx_versioned_cache_t) -> u32;
}
extern "C" {
    pub fn vtx_versioned_cache_compact(vc: *mut vtx_versioned_cache_t) -> u64;
}
extern "C" {
    pub fn vtx_versioned_cache_stats_str(
        vc: *const vtx_versioned_cache_t,
        buf: *mut ::std::os::raw::c_char,
        bufsize: usize,
    );
}
#[doc = " Global compilation context shared between the interpreter and\n the compilation thread pool. Initialized once at startup."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_compile_context_t {
    pub threadpool: *mut vtx_threadpool_t,
    pub code_cache: *mut vtx_code_cache_t,
    pub method_registry: *mut vtx_method_registry_t,
    pub global_arena: *mut vtx_arena_t,
    pub orchestrator: *mut vtx_orchestrator_t,
    pub spec_version_mgr: *mut vtx_spec_version_manager_t,
    pub deopt_coord: *mut vtx_deopt_coord_t,
    pub versioned_cache: *mut vtx_versioned_cache_t,
    pub safepoint_mgr: *mut vtx_safepoint_manager_t,
    pub deoptless_tables: *mut *mut vtx_deoptless_table_t,
    pub deoptless_table_count: u32,
    pub deoptless_table_capacity: u32,
    pub type_feedback: *const vtx_type_feedback_t,
    pub markov: *mut vtx_markov_t,
    pub profiler: *mut vtx_profiler_t,
    pub method_lookup: ::std::option::Option<
        unsafe extern "C" fn(
            method_id: u32,
            context: *mut ::std::os::raw::c_void,
        ) -> *const vtx_method_desc_t,
    >,
    pub method_lookup_context: *mut ::std::os::raw::c_void,
    pub compilation_requested: *mut bool,
    pub compilation_requested_count: u32,
    pub compilation_requested_capacity: u32,
    pub tier_decision:
        ::std::option::Option<unsafe extern "C" fn(execution_count: u64) -> vtx_compile_tier_t>,
}
impl Default for vtx_compile_context_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the compilation context.\n All pointers are stored but NOT owned.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_compile_context_init(ctx: *mut vtx_compile_context_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the compilation context and free internal resources."]
    pub fn vtx_compile_context_destroy(ctx: *mut vtx_compile_context_t);
}
extern "C" {
    #[doc = " Set the method lookup callback.\n The callback takes a method_id and returns the method descriptor."]
    pub fn vtx_compile_context_set_method_lookup(
        ctx: *mut vtx_compile_context_t,
        lookup: ::std::option::Option<
            unsafe extern "C" fn(
                arg1: u32,
                arg2: *mut ::std::os::raw::c_void,
            ) -> *const vtx_method_desc_t,
        >,
        context: *mut ::std::os::raw::c_void,
    );
}
extern "C" {
    #[doc = " Request compilation of a method.\n\n Called from the interpreter's dispatch loop when a method's\n execution count exceeds the tier-up threshold. Submits the\n method for background compilation on the thread pool.\n\n If the method has already been submitted (compilation_requested\n flag is set), this is a no-op.\n\n @param ctx      Compilation context\n @param method   Method that needs compilation"]
    pub fn vtx_request_compilation(
        ctx: *mut vtx_compile_context_t,
        method: *const vtx_method_desc_t,
        execution_count: u64,
    );
}
extern "C" {
    #[doc = " Check if a method has been submitted for compilation."]
    pub fn vtx_is_compilation_requested(ctx: *const vtx_compile_context_t, method_id: u32) -> bool;
}
extern "C" {
    #[doc = " Clear the compilation-requested flag for a method.\n Called after compilation completes or fails."]
    pub fn vtx_clear_compilation_requested(ctx: *mut vtx_compile_context_t, method_id: u32);
}
extern "C" {
    #[doc = " Wire the compile context to its threadpool.\n\n This sets the threadpool's compile_callback to a function that\n looks up the method by ID, compiles it (T1 baseline or T2+ pipeline),\n and installs the result in the code cache.\n\n Must be called after setting ctx->threadpool, ctx->code_cache,\n ctx->method_registry, and ctx->method_lookup.\n\n Returns 0 on success, -1 if ctx or ctx->threadpool is NULL."]
    pub fn vtx_compile_context_wire_threadpool(
        ctx: *mut vtx_compile_context_t,
    ) -> ::std::os::raw::c_int;
}
#[doc = " Per-method IC storage: one inline cache per bytecode position.\n Only call site PCs will actually use their ICs, but this makes\n indexing trivial (just use the call site's PC as the index)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_method_ic_storage_t {
    pub method: *const vtx_method_desc_t,
    pub ics: *mut vtx_inline_cache_t,
    pub count: u32,
}
impl Default for vtx_method_ic_storage_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " The interpreter state."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_interp_t {
    pub frame_stack: vtx_frame_stack_t,
    pub current_frame: *mut vtx_frame_t,
    pub profiler: vtx_profiler_t,
    pub type_feedback: vtx_type_feedback_t,
    pub type_system: *mut vtx_type_system_t,
    pub gc: *mut vtx_gc_t,
    pub compile_ctx: *mut vtx_compile_context_t,
    pub dispatch_table: *mut *mut ::std::os::raw::c_void,
    pub running: bool,
    pub deopt_pending: bool,
    pub deopt_method_id: u32,
    pub deopt_resume_pc: u32,
    pub deopt_resume_pending: bool,
    pub jit_reenter_pending: bool,
    pub osr_pending: bool,
    pub osr_loop_header_pc: u32,
    pub exception: vtx_value_t,
    pub method_ics: *mut vtx_method_ic_storage_t,
    pub method_ic_count: u32,
    pub method_ic_capacity: u32,
}
impl Default for vtx_interp_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the interpreter.\n Builds the dispatch table, initializes the frame stack,\n profiler, and type feedback collector.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_interp_init(
        interp: *mut vtx_interp_t,
        ts: *mut vtx_type_system_t,
        gc: *mut vtx_gc_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the interpreter and release all resources."]
    pub fn vtx_interp_destroy(interp: *mut vtx_interp_t);
}
extern "C" {
    #[doc = " Set the deopt resume PC for a frame. Called by the deopt runtime\n transition after reconstructing the interpreter frame. The dispatch\n loop checks deopt_resume_pending and resumes at deopt_resume_pc."]
    pub fn vtx_interp_set_deopt_pc(frame: *mut vtx_frame_t, pc: u32);
}
extern "C" {
    #[doc = " Execute a method with the given arguments.\n\n Creates a new frame for the method, copies arguments into locals,\n and runs the dispatch loop until the method returns.\n\n Returns the method's return value (VTX_VALUE_UNDEFINED for void methods)."]
    pub fn vtx_interp_run(
        interp: *mut vtx_interp_t,
        method: *const vtx_method_desc_t,
        args: *mut vtx_value_t,
        arg_count: u32,
    ) -> vtx_value_t;
}
extern "C" {
    #[doc = " Get the inline cache for a specific call site in a method.\n If the IC doesn't exist yet, it is created.\n Returns the IC, or NULL on failure."]
    pub fn vtx_interp_get_ic(
        interp: *mut vtx_interp_t,
        method: *const vtx_method_desc_t,
        call_pc: u32,
    ) -> *mut vtx_inline_cache_t;
}
extern "C" {
    #[doc = " Handle an uncaught exception: unwind all frames and return\n the exception value."]
    pub fn vtx_interp_handle_uncaught(
        interp: *mut vtx_interp_t,
        exception: vtx_value_t,
    ) -> vtx_value_t;
}
extern "C" {
    #[doc = " Set the compilation context on the interpreter.\n When set, the interpreter will request JIT compilation for hot\n methods via vtx_request_compilation(). This is the wiring that\n connects the interpreter's hot-code detection to the JIT pipeline.\n\n Must be called after vtx_interp_init() and before vtx_interp_run().\n The ctx pointer is stored but NOT owned by the interpreter."]
    pub fn vtx_interp_set_compile_ctx(interp: *mut vtx_interp_t, ctx: *mut vtx_compile_context_t);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_runtime_t {
    pub type_system: vtx_type_system_t,
    pub gc: vtx_gc_t,
    pub interp: *mut vtx_interp_t,
    pub code_cache: vtx_code_cache_t,
    pub method_registry: vtx_method_registry_t,
    pub arena: vtx_arena_t,
    pub orchestrator: *mut vtx_orchestrator_t,
    pub threadpool: *mut vtx_threadpool_t,
    pub initialized: ::std::os::raw::c_int,
}
impl Default for vtx_runtime_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn vtx_runtime_create(rt: *mut vtx_runtime_t) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_runtime_destroy(rt: *mut vtx_runtime_t);
}
extern "C" {
    pub fn vtx_runtime_run(rt: *mut vtx_runtime_t, bc: *const vtx_bytecode_t) -> vtx_value_t;
}
extern "C" {
    pub fn vtx_runtime_run_with_args(
        rt: *mut vtx_runtime_t,
        bc: *const vtx_bytecode_t,
        args: *const vtx_value_t,
        arg_count: u32,
    ) -> vtx_value_t;
}
extern "C" {
    pub fn vtx_runtime_interp(rt: *mut vtx_runtime_t) -> *mut vtx_interp_t;
}
extern "C" {
    pub fn vtx_runtime_type_system(rt: *mut vtx_runtime_t) -> *mut vtx_type_system_t;
}
extern "C" {
    pub fn vtx_runtime_gc(rt: *mut vtx_runtime_t) -> *mut vtx_gc_t;
}
extern "C" {
    pub fn vtx_runtime_code_cache(rt: *mut vtx_runtime_t) -> *mut vtx_code_cache_t;
}
extern "C" {
    pub fn vtx_runtime_compile_ctx(rt: *mut vtx_runtime_t) -> *mut vtx_compile_context_t;
}
extern "C" {
    pub fn vtx_runtime_start_threadpool(
        rt: *mut vtx_runtime_t,
        nthreads: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_runtime_stop_threadpool(rt: *mut vtx_runtime_t);
}
extern "C" {
    pub fn vtx_bytecode_load(
        path: *const ::std::os::raw::c_char,
        arena: *mut vtx_arena_t,
    ) -> *mut vtx_bytecode_t;
}
extern "C" {
    #[doc = " Emit code to increment the method invocation counter.\n\n Generated code:\n   1. Load profile_data pointer from [RBP + VTX_FRAME_PROFILE_DATA_OFFSET]\n   2. Increment invocation_count (saturating at UINT64_MAX)\n      inc qword ptr [profile_data + VTX_PD_INVOCATION_COUNT_OFFSET]\n      ; or: add qword ptr [...], 1 + jno skip + mov qword ptr [...], UINT64_MAX\n\n @param buf           Code buffer to emit into\n @param profile_data  If non-NULL, can be used for direct address;\n                      if NULL, load from frame"]
    pub fn vtx_instrument_emit_invocation_increment(
        buf: *mut vtx_code_buffer_t,
        profile_data: *mut vtx_profile_data_t,
    );
}
extern "C" {
    #[doc = " Emit code to record the receiver type at a call site.\n\n This records the TypeID of the receiver in the call site's type\n profile array. The profile data is used by the T2 optimizer for\n speculative inlining and inline cache optimization.\n\n Generated code:\n   1. Load profile_data pointer from frame\n   2. Compute call_site_types[call_site_pc] address\n   3. Load the current count of type observations\n   4. If count < VTX_POLY_LIMIT, store the new TypeID at entries[count]\n   5. Increment count (saturating)\n\n @param buf           Code buffer to emit into\n @param profile_data  Profile data structure (may be NULL)\n @param call_site_pc  Bytecode PC of the call site\n @param receiver_reg  Register holding the receiver value (tagged)\n @param typeid_reg    Register holding the TypeID to record\n                      (if VTX_REG_NONE, will extract from receiver_reg)"]
    pub fn vtx_instrument_emit_call_type_record(
        buf: *mut vtx_code_buffer_t,
        profile_data: *mut vtx_profile_data_t,
        call_site_pc: u32,
        receiver_reg: vtx_reg_t,
        typeid_reg: vtx_reg_t,
    );
}
extern "C" {
    #[doc = " Emit code to record a branch outcome.\n\n This increments both the taken count (if taken) and the total count\n for the branch at the given bytecode PC.\n\n Generated code:\n   1. Load profile_data pointer from frame\n   2. Increment branch_total_counts[branch_pc] (saturating at UINT32_MAX)\n   3. If taken, increment branch_taken_counts[branch_pc]\n\n @param buf           Code buffer to emit into\n @param profile_data  Profile data structure (may be NULL)\n @param branch_pc     Bytecode PC of the branch instruction\n @param taken         True if the branch is taken, false otherwise\n                      (the JIT knows this at compile time for unconditional\n                       branches; for conditional, emit on the taken path)"]
    pub fn vtx_instrument_emit_branch_record(
        buf: *mut vtx_code_buffer_t,
        profile_data: *mut vtx_profile_data_t,
        branch_pc: u32,
        taken: bool,
    );
}
extern "C" {
    #[doc = " Emit code to increment the backward branch counter.\n Used at loop back-edges to track loop iteration counts.\n\n Generated code:\n   1. Load profile_data pointer from frame\n   2. Increment backward_branch_count (saturating at UINT64_MAX)\n\n @param buf           Code buffer to emit into\n @param profile_data  Profile data structure (may be NULL)"]
    pub fn vtx_instrument_emit_backward_branch_increment(
        buf: *mut vtx_code_buffer_t,
        profile_data: *mut vtx_profile_data_t,
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_code_buffer {
    pub bytes: *mut u8,
    pub position: u32,
    pub capacity: u32,
}
impl Default for vtx_code_buffer {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize a code buffer with the given initial capacity.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_code_buffer_init(
        buf: *mut vtx_code_buffer_t,
        initial_capacity: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a code buffer and free its memory."]
    pub fn vtx_code_buffer_destroy(buf: *mut vtx_code_buffer_t);
}
extern "C" {
    #[doc = " Ensure the buffer has at least `needed` bytes of free space.\n Reallocates if necessary.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_code_buffer_ensure_capacity(
        buf: *mut vtx_code_buffer_t,
        needed: u32,
    ) -> ::std::os::raw::c_int;
}
#[doc = " Records a forward branch that needs to be patched once the target\n position is known. Used for GOTO, IF_TRUE, IF_FALSE targets."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_branch_fixup_t {
    pub patch_position: u32,
    pub source_offset: u32,
    pub target_bc_pc: u16,
    pub is_32bit: bool,
}
#[doc = " Polymorphic inline cache for virtual/interface dispatch.\n\n Each CALL_VIRTUAL / CALL_INTERFACE site gets its own IC.\n The emitted machine code probes the type_ids array; on a hit,\n it calls the corresponding target directly.  On a miss, it\n falls through to the runtime helper which updates the IC.\n\n Layout (designed for cache-friendly access from emitted code):\n   offset  0: type_ids[0..3]  — 4 × uint32_t = 16 bytes, contiguous\n   offset 16: targets[0..3]   — 4 × void*    = 32 bytes, contiguous\n   offset 48: count            — uint32_t\n   offset 52: misses           — uint32_t"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_poly_ic {
    pub type_ids: [u32; 4usize],
    pub targets: [*mut ::std::os::raw::c_void; 4usize],
    pub count: u32,
    pub misses: u32,
}
impl Default for vtx_poly_ic {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Destroy a compiled code struct and free all associated memory.\n Does NOT free the code buffer itself (that's managed by the code cache)."]
    pub fn vtx_compiled_code_destroy(code: *mut vtx_compiled_code_t);
}
extern "C" {
    #[doc = " Compile a method using the baseline JIT.\n\n Performs a single pass over the bytecode, emitting x86-64 machine code\n for each instruction. Guards are emitted for potentially speculative\n operations. Profiling instrumentation is inserted at key points.\n Deopt stubs are generated after the main code.\n\n If both cache and registry are non-NULL, the compiled code is installed\n into the code cache via vtx_install_method() which handles allocation,\n mprotect, and atomic code pointer updates. Otherwise, the code is\n malloc'd and the caller must handle installation.\n\n @param method       The method to compile\n @param profile_data Profile data for this method (may be NULL for first compilation)\n @param arena        Arena for temporary allocations during compilation\n @param cache        Code cache for proper code installation (may be NULL)\n @param registry     Method registry for code installation (may be NULL)\n @return             Compiled code struct, or NULL on failure"]
    pub fn vtx_baseline_compile(
        method: *const vtx_method_desc_t,
        profile_data: *mut vtx_profile_data_t,
        arena: *mut vtx_arena_t,
        cache: *mut vtx_code_cache_t,
        registry: *mut vtx_method_registry_t,
    ) -> *mut vtx_compiled_code_t;
}
extern "C" {
    #[doc = " Run GVN on the graph. Modifies the graph in place.\n Returns the number of nodes eliminated."]
    pub fn vtx_gvn_run(graph: *mut vtx_graph_t) -> u32;
}
extern "C" {
    #[doc = " Compute a hash for a node suitable for GVN.\n The hash considers: opcode, type, input value numbers, condition code,\n constant value (if Constant opcode), and other auxiliary data."]
    pub fn vtx_gvn_node_hash(node: *const vtx_node_t, table: *const vtx_node_table_t) -> u32;
}
extern "C" {
    #[doc = " Check if two nodes are congruent (same value number).\n Returns true if they are provably the same computation."]
    pub fn vtx_gvn_nodes_congruent(
        a: *const vtx_node_t,
        b: *const vtx_node_t,
        table: *const vtx_node_table_t,
    ) -> bool;
}
pub const vtx_lattice_tag_t_VTX_LATTICE_TOP: vtx_lattice_tag_t = 0;
pub const vtx_lattice_tag_t_VTX_LATTICE_CONSTANT: vtx_lattice_tag_t = 1;
pub const vtx_lattice_tag_t_VTX_LATTICE_BOTTOM: vtx_lattice_tag_t = 2;
#[doc = " VORTEX Sparse Conditional Constant Propagation (SCCP)\n\n Implements the SCCP algorithm on the Sea-of-Nodes IR.\n\n Lattice per node:\n   Top       — unreachable / not yet visited\n   Constant  — known constant value\n   Bottom    — overdefined (variable, multiple possible values)\n\n Propagation rules per opcode:\n   - Arithmetic on constants → constant result (fold)\n   - Phi with one non-Top input → that input\n   - Phi with all same constant → that constant\n   - CheckCast with known type → no-op (replace with input)\n   - Guard with always-true condition → remove\n   - Comparison of constants → constant result\n   - Neg/Not on constant → constant result\n\n Conditional propagation:\n   - At If nodes with a constant condition, only propagate into the\n     reachable branch. Unreachable branches keep their lattice values at Top.\n\n Fixed-point iteration:\n   - Worklist of nodes whose lattice value has changed.\n   - Process until worklist is empty.\n   - Nodes remaining at Top after convergence are unreachable (dead).\n\n The graph is modified in place: constant-folded nodes are replaced with\n Constant nodes, and unreachable nodes are marked dead."]
pub type vtx_lattice_tag_t = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_lattice_val_t {
    pub tag: vtx_lattice_tag_t,
    pub value: vtx_constval_t,
}
impl Default for vtx_lattice_val_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn vtx_lattice_meet(a: vtx_lattice_val_t, b: vtx_lattice_val_t) -> vtx_lattice_val_t;
}
extern "C" {
    #[doc = " Run SCCP on the graph. Modifies the graph in place:\n   - Replaces foldable expressions with Constant nodes\n   - Marks unreachable nodes as dead\n   - Simplifies Phis with one input\n\n Returns the number of nodes simplified or marked unreachable."]
    pub fn vtx_constant_prop_run(graph: *mut vtx_graph_t) -> u32;
}
extern "C" {
    #[doc = " Run DCE on the graph. Modifies the graph in place.\n Returns the number of nodes removed."]
    pub fn vtx_dce_run(graph: *mut vtx_graph_t) -> u32;
}
#[doc = " VORTEX SoN → Basic Block Scheduling\n\n Converts the Sea-of-Nodes graph back into a scheduled form (basic blocks)\n suitable for lowering to machine code.\n\n Algorithm:\n   1. Identify control nodes and build the basic block skeleton.\n   2. Assign each data node to its earliest legal block:\n      - Must be in a block that dominates all its uses.\n      - Must respect memory dependencies (load after store).\n      - Must be in a block that is dominated by all its inputs.\n   3. Hoist loop-invariant nodes out of loops.\n   4. Sink condition-dependent nodes into their target blocks.\n   5. Place guards as early as possible (fail-fast).\n   6. Place allocations as late as possible (avoid unnecessary allocation).\n\n The schedule is a list of basic blocks, each containing an ordered list\n of node IDs. The ordering respects data dependencies within the block."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_schedule_block_t {
    pub nodes: *mut vtx_nodeid_t,
    pub node_count: u32,
    pub node_capacity: u32,
    pub region_node: vtx_nodeid_t,
    pub block_id: u32,
    pub loop_depth: u32,
    pub is_loop_header: bool,
    pub is_catch: bool,
    pub succ_blocks: *mut u32,
    pub succ_count: u32,
    pub succ_capacity: u32,
    pub pred_blocks: *mut u32,
    pub pred_count: u32,
    pub pred_capacity: u32,
    pub df_blocks: *mut u32,
    pub df_count: u32,
    pub df_capacity: u32,
}
impl Default for vtx_schedule_block_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_schedule_t {
    pub blocks: *mut vtx_schedule_block_t,
    pub count: u32,
    pub capacity: u32,
    pub node_block: *mut u32,
    pub node_block_count: u32,
}
impl Default for vtx_schedule_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Run the scheduler on the graph. Produces a schedule structure.\n The arena is used for temporary allocations during scheduling.\n\n Returns 0 on success, -1 on failure. The caller must free the\n schedule with vtx_schedule_destroy."]
    pub fn vtx_schedule_run(
        graph: *mut vtx_graph_t,
        arena: *mut vtx_arena_t,
        schedule: *mut vtx_schedule_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a schedule and free all memory."]
    pub fn vtx_schedule_destroy(schedule: *mut vtx_schedule_t);
}
extern "C" {
    #[doc = " Get the block index that a node is scheduled in.\n Returns (uint32_t)-1 if the node is not scheduled."]
    pub fn vtx_schedule_node_block(schedule: *const vtx_schedule_t, node_id: vtx_nodeid_t) -> u32;
}
extern "C" {
    #[doc = " Print the schedule to stderr for debugging."]
    pub fn vtx_schedule_print(schedule: *const vtx_schedule_t, graph: *const vtx_graph_t);
}
extern "C" {
    #[doc = " Compute dominance frontiers for each block.\n For each block b, DF(b) is the set of blocks where b's dominance ends —\n i.e., blocks that are successors of blocks dominated by b, but are not\n themselves dominated by b. This is used for SSA Phi node placement.\n\n The frontier sets are stored as arrays of block indices in each\n vtx_schedule_block_t, using the df_blocks and df_count fields."]
    pub fn vtx_compute_dominance_frontiers(
        blocks: *mut vtx_schedule_block_t,
        count: u32,
        dom: *const u32,
        start_block: u32,
    );
}
extern "C" {
    #[doc = " VORTEX Loop-Invariant Code Motion (LICM)\n\n Moves loop-invariant computations out of loop bodies into preheaders.\n\n A node is loop-invariant if:\n   1. It is not pinned (not a Phi, Region, FrameState, etc.)\n   2. It has no side effects\n   3. It is not a control or memory node\n   4. All of its inputs are defined outside the loop OR are themselves\n      loop-invariant\n\n Guard nodes can be hoisted if the guarded condition doesn't change\n inside the loop.\n\n Memory loads (Load/LoadField/LoadIndexed) can be hoisted ONLY if there\n is no potentially-aliasing store (Store/StoreField/StoreIndexed) in the\n loop body.\n\n With TBAA (Type-Based Alias Analysis), this check is refined:\n a load of one type (e.g., int[]) can be hoisted past a store of a\n different type (e.g., ref[]) because they can never alias. This\n enables 50%+ of loop-invariant load hoisting.\n\n Prerequisites: Graph must be scheduled (vtx_schedule_run already called).\n\n @param graph    The SoN graph\n @param schedule The schedule (identifies loop structure)\n @param arena    Arena for temporary allocations\n @return         Number of nodes hoisted, or -1 on error"]
    pub fn vtx_licm_run(
        graph: *mut vtx_graph_t,
        schedule: *const vtx_schedule_t,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
#[doc = " VORTEX Bounds Check Elimination\n\n Eliminates redundant array bounds check guards using range analysis\n and induction variable analysis.\n A bounds check is redundant if:\n   - The index's range is provably within the array length\n   - A dominating guard already proves the same condition\n   - (NEW) Induction variable analysis proves the index is within\n     bounds across all loop iterations\n\n Algorithm:\n   1. Run induction variable analysis to identify IVs and their ranges\n   2. Walk the schedule and find all Guard nodes that are bounds checks\n      (Guard(i < len) or Guard(i >= 0 && i < len))\n   3. Build a range analysis: for each node, compute [min, max] range\n   4. After Guard(i < len), constrain i's max to len-1\n   5. After Guard(i >= 0), constrain i's min to 0\n   6. If a subsequent Guard(i < len) sees i in range [0, len-1], eliminate it\n   7. Also eliminate dominated guards: if Guard(i < len) at block B1\n      dominates Guard(i < len) at block B2 with the same len, the dominated\n      guard is redundant\n   8. (NEW) If the index is an IV whose range is provably within [0, len),\n      eliminate the guard"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_range_t {
    pub min: i64,
    pub max: i64,
    pub is_const: bool,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_range_table_t {
    pub ranges: *mut vtx_range_t,
    pub count: u32,
}
impl Default for vtx_range_table_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Eliminate redundant bounds check guards using range analysis.\n\n @param graph    The Sea-of-Nodes graph\n @param schedule The schedule (provides block order and dominance)\n @param arena    Arena allocator for temporary data\n\n @return Number of guards eliminated, or -1 on error"]
    pub fn vtx_bounds_check_run(
        graph: *mut vtx_graph_t,
        schedule: *const vtx_schedule_t,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Compute the range for a node based on its opcode and inputs.\n This is the transfer function for range propagation.\n\n @param node   The node to compute range for\n @param table  The node table\n @param ranges The current range map (indexed by node ID)"]
    pub fn vtx_bounds_compute_range(
        node: *const vtx_node_t,
        table: *const vtx_node_table_t,
        ranges: *const vtx_range_t,
        range_count: u32,
    ) -> vtx_range_t;
}
extern "C" {
    #[doc = " Check if a Guard node represents a bounds check (i < len).\n\n A Guard is a bounds check if:\n   - Its condition input is a Cmp node\n   - The Cmp compares an index against a length\n   - The condition is LT (i < len)\n\n @param node    The Guard node\n @param table   The node table\n @param index   [out] Set to the node ID of the index being checked\n @param length  [out] Set to the node ID of the array length\n\n @return true if this is a bounds check guard"]
    pub fn vtx_bounds_is_bounds_check(
        node: *const vtx_node_t,
        table: *const vtx_node_table_t,
        index: *mut vtx_nodeid_t,
        length: *mut vtx_nodeid_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Check if a Guard node represents a non-negative check (i >= 0).\n\n @param node    The Guard node\n @param table   The node table\n @param index   [out] Set to the node ID of the index being checked\n\n @return true if this is a non-negative check guard"]
    pub fn vtx_bounds_is_nonneg_check(
        node: *const vtx_node_t,
        table: *const vtx_node_table_t,
        index: *mut vtx_nodeid_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Strength reduction pass: replaces expensive ops with cheaper equivalents\n when the divisor/multiplier is a power of two.\n\n   Mul(x, 2^k)  → Shl(x, k)\n   Div(x, 1)    → x\n   Mul(x, 1)    → x\n   Mul(x, 0)    → 0\n\n Note: Div(x, 2^k) → Shr(x, k) and Mod(x, 2^k) → And(x, 2^k-1) are\n NOT applied because C's / and % truncate toward zero, while SAR and\n AND round toward -infinity. This causes mismatches for negative\n dividends. A future fix can add range analysis to prove non-negativity.\n\n @param graph  The IR graph\n @return       Number of nodes replaced"]
    pub fn vtx_strength_reduce_run(graph: *mut vtx_graph_t) -> u32;
}
extern "C" {
    #[doc = " Unroll loops by duplicating their body.\n\n Conservative implementation: only unrolls small loops (<= 20 body nodes)\n with a single back-edge. The actual body replication is a future\n enhancement — currently just marks the loop with the unroll factor.\n\n @param graph     The IR graph\n @param schedule  The schedule (for loop structure)\n @param arena     Arena for allocations\n @param factor    Unroll factor (2, 3, or 4)\n @return          Number of loops unrolled"]
    pub fn vtx_loop_unroll_run(
        graph: *mut vtx_graph_t,
        schedule: *const vtx_schedule_t,
        arena: *mut vtx_arena_t,
        factor: u32,
    ) -> u32;
}
extern "C" {
    #[doc = " SMI tag elision pass: marks straight-line arithmetic chains as RAW_INT\n so the isel skips per-op untag/retag. One untag at chain entry, one\n retag at chain exit, instead of untag+retag per op.\n\n @param graph  The IR graph\n @return       Number of nodes marked RAW_INT"]
    pub fn vtx_smi_tag_elision_run(graph: *mut vtx_graph_t) -> u32;
}
extern "C" {
    #[doc = " Run representation inference on the graph.\n\n Inserts UnboxInt nodes before arithmetic chains and BoxInt nodes at\n chain exits. Marks arithmetic nodes as RAW_INT so the isel emits\n raw arithmetic instead of per-op untag/retag.\n\n @param graph   The IR graph (modified in-place)\n @param arena   Arena for temporary allocations\n @return        Number of UnboxInt/BoxInt nodes inserted"]
    pub fn vtx_rep_infer_run(graph: *mut vtx_graph_t, arena: *mut vtx_arena_t) -> u32;
}
extern "C" {
    #[doc = " Evict methods using the clock (second chance) algorithm until the\n cache is under the max size. O(1) amortized per eviction.\n\n @param cache       Code cache\n @param registry    Method registry\n @param current_ts  Current global timestamp (monotonically increasing)\n @return            Number of methods evicted, or -1 on failure"]
    pub fn vtx_evict_lru(
        cache: *mut vtx_code_cache_t,
        registry: *mut vtx_method_registry_t,
        current_ts: u64,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Update the use bit for a method (clock eviction touch).\n Called when a method is invoked. Sets the use_bit so the clock\n algorithm gives the method a \"second chance\" during eviction.\n The timestamp is also updated every VTX_LRU_UPDATE_INTERVAL calls\n for diagnostics.\n\n @param method  The compiled method\n @param ts      Current global timestamp"]
    pub fn vtx_evict_touch(method: *mut vtx_compiled_method_t, ts: u64);
}
extern "C" {
    #[doc = " Find the next eviction candidate using the clock (second chance)\n algorithm. O(1) amortized per call.\n Returns the method, or NULL if the registry is empty."]
    pub fn vtx_evict_find_lru(registry: *mut vtx_method_registry_t) -> *mut vtx_compiled_method_t;
}
extern "C" {
    #[doc = " Evict a specific method from the cache.\n\n @param cache     Code cache\n @param registry  Method registry\n @param method    The method to evict\n @return          0 on success, -1 on failure"]
    pub fn vtx_evict_method(
        cache: *mut vtx_code_cache_t,
        registry: *mut vtx_method_registry_t,
        method: *mut vtx_compiled_method_t,
    ) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_dep_set_t {
    pub method_ids: *mut u32,
    pub count: u32,
    pub capacity: u32,
}
impl Default for vtx_dep_set_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " A guard-level dependency: maps (TypeID, guard_id) instead of just TypeID.\n This enables fine-grained invalidation that only patches affected guards\n rather than invalidating entire methods."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_guard_dep_t {
    pub type_id: u32,
    pub guard_id: u32,
    pub method_id: u32,
    pub guard_branch_offset: u32,
    pub code_start: *mut u8,
}
impl Default for vtx_guard_dep_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
pub type vtx_guard_dep_entry_t = vtx_guard_dep_entry;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_guard_dep_entry {
    pub type_id: u32,
    pub deps: *mut vtx_guard_dep_t,
    pub dep_count: u32,
    pub dep_capacity: u32,
    pub next: *mut vtx_guard_dep_entry_t,
}
impl Default for vtx_guard_dep_entry {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_guard_dep_index_t {
    pub buckets: [*mut vtx_guard_dep_entry_t; 256usize],
    pub entry_count: u32,
    pub arena: *mut vtx_arena_t,
}
impl Default for vtx_guard_dep_index_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Inverted index: TypeID → set of methods.\n Implemented as a hash table for O(1) average lookup."]
pub type vtx_index_entry_t = vtx_index_entry;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_index_entry {
    pub key: u64,
    pub dep_set: vtx_dep_set_t,
    pub next: *mut vtx_index_entry_t,
}
impl Default for vtx_index_entry {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_inverted_index_t {
    pub buckets: [*mut vtx_index_entry_t; 256usize],
    pub entry_count: u32,
    pub arena: *mut vtx_arena_t,
}
impl Default for vtx_inverted_index_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the inverted index."]
    pub fn vtx_inverted_index_init(
        index: *mut vtx_inverted_index_t,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the inverted index."]
    pub fn vtx_inverted_index_destroy(index: *mut vtx_inverted_index_t);
}
extern "C" {
    #[doc = " Add a dependency: method `method_id` depends on `typeid`."]
    pub fn vtx_inverted_index_add(
        index: *mut vtx_inverted_index_t,
        typeid_: u64,
        method_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Add a shape dependency: method `method_id` depends on `shapeid`."]
    pub fn vtx_inverted_index_add_shape(
        index: *mut vtx_inverted_index_t,
        shapeid: u32,
        method_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Remove a method from all dependency sets.\n Call this when a method is uninstalled or invalidated."]
    pub fn vtx_inverted_index_remove_method(
        index: *mut vtx_inverted_index_t,
        method_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Look up the set of methods that depend on `typeid`.\n Returns the dep set, or NULL if no methods depend on this type."]
    pub fn vtx_inverted_index_lookup(
        index: *mut vtx_inverted_index_t,
        typeid_: u64,
    ) -> *const vtx_dep_set_t;
}
extern "C" {
    #[doc = " Invalidate all methods that depend on the given TypeID.\n\n This is called when a class is loaded or redefined. All compiled\n methods whose guards reference this TypeID are found via the\n inverted index, marked as not-compiled, and their metadata is freed.\n\n @param typeid_    The TypeID that triggered invalidation\n @param cache      Code cache\n @param registry   Method registry\n @param index      Inverted index\n @return           Number of methods invalidated, or -1 on failure"]
    pub fn vtx_invalidate_dependencies(
        typeid_: u64,
        cache: *mut vtx_code_cache_t,
        registry: *mut vtx_method_registry_t,
        index: *mut vtx_inverted_index_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Invalidate all methods that depend on the given ShapeID.\n\n Called when an object's shape changes (e.g., property added/removed).\n\n @param shapeid    The ShapeID that triggered invalidation\n @param cache      Code cache\n @param registry   Method registry\n @param index      Inverted index\n @return           Number of methods invalidated, or -1 on failure"]
    pub fn vtx_invalidate_shape(
        shapeid: vtx_shapeid_t,
        cache: *mut vtx_code_cache_t,
        registry: *mut vtx_method_registry_t,
        index: *mut vtx_inverted_index_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Register a method's dependencies in the inverted index.\n Called during method installation.\n\n @param index      Inverted index\n @param method     The compiled method\n @return           0 on success, -1 on failure"]
    pub fn vtx_invalidate_register(
        index: *mut vtx_inverted_index_t,
        method: *const vtx_compiled_method_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_guard_dep_index_init(
        index: *mut vtx_guard_dep_index_t,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_guard_dep_index_destroy(index: *mut vtx_guard_dep_index_t);
}
extern "C" {
    pub fn vtx_guard_dep_index_add(
        index: *mut vtx_guard_dep_index_t,
        type_id: u32,
        guard_id: u32,
        method_id: u32,
        guard_branch_offset: u32,
        code_start: *mut u8,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_guard_dep_index_lookup(
        index: *mut vtx_guard_dep_index_t,
        type_id: u32,
        out_count: *mut u32,
    ) -> *const vtx_guard_dep_t;
}
extern "C" {
    #[doc = " Fine-grained invalidation: only patch guards that depend on the\n changed TypeID, leaving other guards in the method active.\n\n For each guard that depends on typeid_:\n   1. Patch the guard's JCC in the compiled code to jump to a deopt stub\n   2. The method's other guards remain active\n   3. No recompilation is needed unless all guards are invalidated\n\n This avoids the \"nuclear option\" of invalidating entire methods.\n\n @param typeid_   The TypeID that triggered invalidation\n @param index     Guard-level dependency index\n @param cache     Code cache (for deopt stub allocation)\n @return          Number of guards patched, or -1 on failure"]
    pub fn vtx_invalidate_guard_fine_grained(
        typeid_: u32,
        index: *mut vtx_guard_dep_index_t,
        cache: *mut vtx_code_cache_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Compute SHA-256 hash of bytecode data for version gating.\n Implemented in sha256.c (public domain, FIPS 180-4)."]
    pub fn vtx_profile_compute_bytecode_hash(bytecode: *const u8, len: usize, hash: *mut u8);
}
extern "C" {
    #[doc = " Save global profile data to a binary file.\n Returns true on success, false on failure.\n The file is written atomically (write to temp, then rename).\n File permissions are set to 0600 (owner read/write only).\n\n @param global         The profile data to save\n @param filename       Output filename\n @param bytecode_hash  SHA-256 hash of the bytecode this profile was\n                       collected against. Stored in the header so that\n                       a profile from a different bytecode version is\n                       automatically rejected on load. May be NULL to\n                       skip the hash (not recommended for production)."]
    pub fn vtx_profile_save(
        global: *const vtx_profile_global_t,
        filename: *const ::std::os::raw::c_char,
        bytecode_hash: *const u8,
    ) -> bool;
}
extern "C" {
    #[doc = " Load global profile data from a binary file.\n If the file's version doesn't match VTX_PROFILE_VERSION, the file is ignored\n and false is returned. If the CRC32 doesn't match, false is returned.\n If expected_hash is non-NULL and the stored bytecode hash doesn't match,\n false is returned (profile is from a different bytecode version).\n On success, the loaded data is MERGED into the existing global profile\n (existing data is preserved and augmented with loaded data).\n Returns true on success, false on failure."]
    pub fn vtx_profile_load(
        global: *mut vtx_profile_global_t,
        filename: *const ::std::os::raw::c_char,
        expected_hash: *const u8,
    ) -> bool;
}
extern "C" {
    #[doc = " Register an atexit handler that saves the profile to the given filename.\n The global pointer is captured at registration time.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_profile_register_atexit(
        global: *mut vtx_profile_global_t,
        filename: *const ::std::os::raw::c_char,
        bytecode_hash: *const u8,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Unregister the atexit handler. Clears the stored global pointer\n so the atexit handler will not attempt to access a destroyed global.\n Must be called before destroying the registered global."]
    pub fn vtx_profile_unregister_atexit();
}
#[doc = " A single method's persisted T1 code descriptor.\n\n This is the on-disk format. The code itself is in the code blob at\n `code_offset`."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_t1_persist_method_t {
    pub method_id: u32,
    pub code_offset: u32,
    pub code_size: u32,
    pub entry_offset: u32,
    pub stack_slots: u32,
    pub local_slots: u32,
    pub reloc_count: u32,
}
#[doc = " A single persisted relocation entry."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_t1_persist_reloc_t {
    pub kind: u32,
    pub offset: u32,
    pub target_offset: u32,
    pub target_address: u64,
    pub addend: i32,
}
extern "C" {
    #[doc = " Save a collection of T1 compiled methods to a T1 cache file.\n\n @param filename       Output filename\n @param bytecode_hash  SHA-256 hash of the bytecode (for version gating)\n @param methods        Array of compiled code pointers (T1 only)\n @param method_count   Number of methods\n @return               true on success, false on failure"]
    pub fn vtx_t1_cache_save(
        filename: *const ::std::os::raw::c_char,
        bytecode_hash: *const u8,
        methods: *mut *const vtx_compiled_code_t,
        method_count: u32,
    ) -> bool;
}
#[doc = " Loaded T1 cache: an mmap'd code blob with per-method descriptors.\n\n The code blob is mmap'd as PROT_READ|PROT_EXEC. Method entry points\n are computed as (code_base + entry_offset)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_t1_cache_t {
    pub bytecode_hash: [u8; 32usize],
    pub method_count: u32,
    pub total_code_size: u32,
    pub methods: *mut vtx_t1_persist_method_t,
    pub method_reloc_offsets: *mut u32,
    pub relocs: *mut vtx_t1_persist_reloc_t,
    pub reloc_count: u32,
    pub code_base: *mut ::std::os::raw::c_void,
    pub code_map_size: usize,
    pub code_fd: ::std::os::raw::c_int,
    pub load_time_ns: u64,
    pub relocations_applied: bool,
}
impl Default for vtx_t1_cache_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Load a T1 cache file, mmap the code, and apply relocations.\n\n If the file's bytecode hash doesn't match `expected_hash`, the load\n fails (returns false). If the CRC doesn't match, the load fails.\n\n On success, the caller can call vtx_t1_cache_get_entry() to get the\n native entry point for any method in the cache.\n\n @param cache          Cache structure to populate (caller allocates)\n @param filename       T1 cache file path\n @param expected_hash  Expected bytecode hash (for version gating)\n @return               true on success, false on failure (bad magic,\n                       version mismatch, CRC failure, hash mismatch,\n                       or relocation error)"]
    pub fn vtx_t1_cache_load(
        cache: *mut vtx_t1_cache_t,
        filename: *const ::std::os::raw::c_char,
        expected_hash: *const u8,
    ) -> bool;
}
extern "C" {
    #[doc = " Get the native entry point for a method in the loaded T1 cache.\n\n Returns NULL if the method is not in the cache.\n\n @param cache      Loaded T1 cache\n @param method_id  Method to look up\n @return           Native entry point, or NULL"]
    pub fn vtx_t1_cache_get_entry(
        cache: *const vtx_t1_cache_t,
        method_id: u32,
    ) -> *mut ::std::os::raw::c_void;
}
extern "C" {
    #[doc = " Check if a method is present in the loaded T1 cache."]
    pub fn vtx_t1_cache_has_method(cache: *const vtx_t1_cache_t, method_id: u32) -> bool;
}
extern "C" {
    #[doc = " Destroy a loaded T1 cache: unmap the code blob and free descriptors."]
    pub fn vtx_t1_cache_destroy(cache: *mut vtx_t1_cache_t);
}
extern "C" {
    #[doc = " Get T1 cache statistics.\n\n @param cache             Loaded T1 cache\n @param method_count      Out: number of methods in cache\n @param code_size         Out: total native code size\n @param load_time_ns      Out: time spent loading\n @param relocations       Out: number of relocations applied"]
    pub fn vtx_t1_cache_stats(
        cache: *const vtx_t1_cache_t,
        method_count: *mut u32,
        code_size: *mut u32,
        load_time_ns: *mut u64,
        relocations: *mut u32,
    );
}
extern "C" {
    #[doc = " Build the T1 cache filename for a given bytecode hash.\n\n Format: <dir>/<hash_hex>.t1c\n\n @param dir         Profile directory\n @param hash_hex    Bytecode hash as 32-char hex string\n @param out         Output buffer\n @param out_size    Size of output buffer\n @return            0 on success, -1 on overflow"]
    pub fn vtx_t1_cache_filename(
        dir: *const ::std::os::raw::c_char,
        hash_hex: *const ::std::os::raw::c_char,
        out: *mut ::std::os::raw::c_char,
        out_size: usize,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Verify the graph integrity. Returns true if all checks pass.\n\n When VORTEX_ENABLE_VERIFY is not defined, this function returns true\n without doing any work."]
    pub fn vtx_verify_graph(graph: *const vtx_graph_t) -> bool;
}
extern "C" {
    #[doc = " Verify the graph after DCE — additionally checks that no dead nodes\n exist (since DCE should have removed them all) and that memory chains\n are properly wired (each memory node has a memory chain input)."]
    pub fn vtx_verify_graph_post_dce(graph: *const vtx_graph_t) -> bool;
}
pub const vtx_escape_state_t_VTX_ESCAPE_NONE: vtx_escape_state_t = 0;
pub const vtx_escape_state_t_VTX_ESCAPE_ARG: vtx_escape_state_t = 1;
pub const vtx_escape_state_t_VTX_ESCAPE_GLOBAL: vtx_escape_state_t = 2;
#[doc = " VORTEX Partial Escape Analysis — Flow-Sensitive Escape Analysis\n\n Determines for each allocation whether it escapes the current compilation\n unit. An allocation \"escapes\" if it can be observed outside the compiled\n method — i.e., the allocated object's identity (not just its value) is\n needed at runtime.\n\n Escape states form a lattice:\n\n   NoEscape     — the object is never observable outside this method\n   ArgEscape    — the object escapes through method arguments but not\n                  globally; callees may observe it but cannot store it\n                  into a globally-visible location\n   GlobalEscape — the object is globally visible (stored into a static\n                  field, returned, or escapes through an unknown callee)\n\n   NoEscape ≤ ArgEscape ≤ GlobalEscape\n\n The analysis is flow-sensitive: it computes per-basic-block entry/exit\n states using a standard dataflow framework. At merge points (Region/Phi\n nodes), states are joined (max over the lattice). The worklist algorithm\n iterates until a fixed point is reached.\n\n Escape triggers:\n   - Stored into a field of a GlobalEscape object → GlobalEscape\n   - Stored into a field of an ArgEscape object   → ArgEscape\n   - Passed as argument to an unknown function     → ArgEscape (conservative:\n                                                     callee may store globally)\n   - Returned from the current method               → GlobalEscape\n   - Stored into a global/static field               → GlobalEscape\n   - Used in a monitor enter/exit                    → GlobalEscape\n   - Stored into an array element of escaping array  → propagates array's state\n   - Used as receiver of a virtual call              → ArgEscape (may dispatch\n                                                       to unknown method)"]
pub type vtx_escape_state_t = ::std::os::raw::c_uint;
extern "C" {
    pub fn vtx_escape_state_name(s: vtx_escape_state_t) -> *const ::std::os::raw::c_char;
}
#[doc = " Maps allocation NodeIDs to their escape states.\n Stored as a flat array indexed by NodeID for O(1) lookup.\n\n Only allocation nodes (VTX_OP_NewObject, VTX_OP_NewArray, VTX_OP_Allocate)\n have entries; non-allocation nodes have state VTX_ESCAPE_NONE (unused)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_escape_map_t {
    pub states: *mut vtx_escape_state_t,
    pub state_count: u32,
    pub alloc_ids: *mut vtx_nodeid_t,
    pub alloc_count: u32,
    pub alloc_capacity: u32,
}
impl Default for vtx_escape_map_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " The dataflow state for one basic block: a snapshot of the escape map\n at block entry and exit. The transfer function walks the block's nodes\n and updates the exit state based on how each node uses allocations."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_pea_block_state_t {
    pub entry_state: *mut vtx_escape_state_t,
    pub exit_state: *mut vtx_escape_state_t,
    pub state_count: u32,
    pub entry_changed: bool,
}
impl Default for vtx_pea_block_state_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " The result of running PEA on a graph. Contains the final escape state\n for every allocation, plus the per-block dataflow states for use by\n downstream transforms (cross-object SR, materialization, virtual objects).\n\n All memory is arena-allocated; destroy by freeing the arena."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_pea_analysis_t {
    pub escape_map: vtx_escape_map_t,
    pub block_states: *mut vtx_pea_block_state_t,
    pub block_state_count: u32,
    pub total_allocs: u32,
    pub no_escape_count: u32,
    pub arg_escape_count: u32,
    pub global_escape_count: u32,
    pub iterations: u32,
}
impl Default for vtx_pea_analysis_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Run flow-sensitive partial escape analysis on the graph.\n\n Algorithm:\n   1. Identify all allocation nodes in the graph.\n   2. Initialize all allocations to NoEscape.\n   3. Build per-block entry/exit state arrays.\n   4. Iterate using a reverse-postorder worklist:\n      a. For each block, compute entry state as join of predecessor exit states.\n      b. Apply the transfer function: walk each node, update escape states.\n      c. If exit state changed, add successors to the worklist.\n   5. Stop at fixed point (no state changes).\n\n The analysis result is allocated from the given arena.\n Returns the analysis result, or NULL on failure.\n\n @param graph  The SoN graph to analyze\n @param arena  Arena for allocating the result\n @return       Analysis result, or NULL on failure"]
    pub fn vtx_pea_run(graph: *mut vtx_graph_t, arena: *mut vtx_arena_t)
        -> *mut vtx_pea_analysis_t;
}
extern "C" {
    #[doc = " Get the escape state for a node from the analysis result.\n Returns VTX_ESCAPE_GLOBAL for non-allocation nodes (conservative default)."]
    pub fn vtx_pea_get_escape(
        analysis: *const vtx_pea_analysis_t,
        node_id: vtx_nodeid_t,
    ) -> vtx_escape_state_t;
}
extern "C" {
    #[doc = " Check if a node is a scalar-replaceable allocation (NoEscape)."]
    pub fn vtx_pea_is_scalar_replaceable(
        analysis: *const vtx_pea_analysis_t,
        node_id: vtx_nodeid_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Get the entry escape state for a specific allocation in a specific block."]
    pub fn vtx_pea_block_entry_state(
        analysis: *const vtx_pea_analysis_t,
        block_idx: u32,
        alloc_id: vtx_nodeid_t,
    ) -> vtx_escape_state_t;
}
extern "C" {
    #[doc = " Get the exit escape state for a specific allocation in a specific block."]
    pub fn vtx_pea_block_exit_state(
        analysis: *const vtx_pea_analysis_t,
        block_idx: u32,
        alloc_id: vtx_nodeid_t,
    ) -> vtx_escape_state_t;
}
#[doc = " An edge in the allocation graph: a field store from one allocation\n to another (container.field = value)."]
pub type vtx_alloc_edge_t = vtx_alloc_edge;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_alloc_edge {
    pub container_id: vtx_nodeid_t,
    pub value_id: vtx_nodeid_t,
    pub field_offset: u32,
    pub store_node_id: vtx_nodeid_t,
    pub next: *mut vtx_alloc_edge_t,
    pub rev_next: *mut vtx_alloc_edge_t,
}
impl Default for vtx_alloc_edge {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " The allocation graph: maps each allocation to the list of outgoing\n edges (field stores from this allocation to other allocations)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_alloc_graph_t {
    pub alloc_edges: *mut *mut vtx_alloc_edge_t,
    pub edge_array_size: u32,
    pub all_edges: *mut vtx_alloc_edge_t,
    pub edge_count: u32,
    pub edge_capacity: u32,
    pub reverse_edges: *mut *mut vtx_alloc_edge_t,
    pub reverse_array_size: u32,
}
impl Default for vtx_alloc_graph_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " For each allocation, the effective escape state after cross-object\n analysis. This may be lower than the raw escape state from the\n base analysis: an ArgEscape or GlobalEscape object may have effective\n NoEscape if its only escape path goes through a container field that\n is never read at the escape point."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_effective_escape_t {
    pub effective_states: *mut vtx_escape_state_t,
    pub state_count: u32,
    pub scalar_fields: *mut u32,
    pub scalar_field_count: u32,
}
impl Default for vtx_effective_escape_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Maps a (allocation, field_offset) pair to the NodeID of the scalar\n local variable that replaces the field access. Used to rewrite\n LoadField/StoreField nodes."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_sr_mapping_t {
    pub alloc_id: vtx_nodeid_t,
    pub field_offset: u32,
    pub local_id: vtx_nodeid_t,
}
#[doc = " The complete scalar replacement result: all mappings from\n (alloc, field) → local variable."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_cross_sr_result_t {
    pub mappings: *mut vtx_sr_mapping_t,
    pub mapping_count: u32,
    pub mapping_capacity: u32,
    pub allocs_replaced: u32,
    pub field_accesses_rewritten: u32,
    pub edges_analyzed: u32,
}
impl Default for vtx_cross_sr_result_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Run cross-object scalar replacement on the graph.\n\n This transforms the graph in place:\n   - Creates scalar local variable nodes for each field of\n     scalar-replaceable allocations\n   - Rewrites LoadField/StoreField accesses to use the locals\n   - Removes allocation nodes for fully scalar-replaced objects\n\n @param graph    The SoN graph (modified in place)\n @param analysis The escape analysis result from vtx_pea_run()\n @param arena    Arena for allocating temporary data\n @return         Result structure, or NULL on failure"]
    pub fn vtx_cross_object_sr_run(
        graph: *mut vtx_graph_t,
        analysis: *const vtx_pea_analysis_t,
        arena: *mut vtx_arena_t,
    ) -> *mut vtx_cross_sr_result_t;
}
extern "C" {
    #[doc = " Get the scalar local NodeID for a given (allocation, field) pair.\n Returns VTX_NODEID_INVALID if no mapping exists."]
    pub fn vtx_cross_sr_get_local(
        result: *const vtx_cross_sr_result_t,
        alloc_id: vtx_nodeid_t,
        field_offset: u32,
    ) -> vtx_nodeid_t;
}
extern "C" {
    #[doc = " Check if an allocation was fully scalar-replaced."]
    pub fn vtx_cross_sr_is_replaced(
        result: *const vtx_cross_sr_result_t,
        alloc_id: vtx_nodeid_t,
    ) -> bool;
}
pub const vtx_virtual_state_t_VTX_VIRTUAL_UNKNOWN: vtx_virtual_state_t = 0;
pub const vtx_virtual_state_t_VTX_VIRTUAL_YES: vtx_virtual_state_t = 1;
pub const vtx_virtual_state_t_VTX_VIRTUAL_NO: vtx_virtual_state_t = 2;
#[doc = " VORTEX Virtual Object Tracking\n\n Non-escaping objects are marked as \"virtual\" — no allocation code is\n generated for them. All field accesses to virtual objects are rewritten\n to local variable accesses. Virtual objects exist only in the compiler's\n analysis; at runtime, they are just a collection of local variables.\n\n Key properties:\n   - Virtual objects never cause heap allocation\n   - Field accesses to virtual objects are zero-cost (register/stack access)\n   - Virtual objects are tracked through Phi nodes: a Phi of virtual\n     objects is virtual if both inputs are virtual with the same type\n   - If a Phi merges objects of different types or one virtual and one\n     non-virtual, all inputs must be materialized\n\n This pass runs after the base escape analysis and cross-object SR.\n It finalizes the virtual/non-virtual classification and rewrites\n all field accesses."]
pub type vtx_virtual_state_t = ::std::os::raw::c_uint;
#[doc = " Information about a single virtual object: its type and the mapping\n from field offsets to the NodeIDs that produce the current field values."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_virtual_obj_t {
    pub alloc_id: vtx_nodeid_t,
    pub type_id: u32,
    pub state: vtx_virtual_state_t,
    pub field_offsets: *mut u32,
    pub field_values: *mut vtx_nodeid_t,
    pub field_count: u32,
    pub field_capacity: u32,
}
impl Default for vtx_virtual_obj_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_virtual_result_t {
    pub virtual_states: *mut vtx_virtual_state_t,
    pub state_count: u32,
    pub virtual_objs: *mut vtx_virtual_obj_t,
    pub virtual_obj_count: u32,
    pub virtual_obj_capacity: u32,
    pub total_allocs: u32,
    pub virtual_count: u32,
    pub non_virtual_count: u32,
    pub phis_resolved: u32,
    pub field_accesses_rewritten: u32,
}
impl Default for vtx_virtual_result_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Run virtual object tracking on the graph.\n\n This pass:\n   1. Classifies each NoEscape allocation as virtual\n   2. Tracks virtual objects through Phi nodes\n   3. Rewrites all field accesses to virtual objects as local variable access\n   4. Eliminates allocation nodes for virtual objects\n\n Must run after escape analysis and before materialization (materialization\n handles objects that need to become non-virtual at escape/deopt points).\n\n @param graph    The SoN graph (modified in place)\n @param analysis The escape analysis result\n @param arena    Arena for allocating temporary data\n @return         Virtual tracking result, or NULL on failure"]
    pub fn vtx_virtual_run(
        graph: *mut vtx_graph_t,
        analysis: *const vtx_pea_analysis_t,
        arena: *mut vtx_arena_t,
    ) -> *mut vtx_virtual_result_t;
}
extern "C" {
    #[doc = " Check if an allocation is virtual."]
    pub fn vtx_virtual_is_virtual(
        result: *const vtx_virtual_result_t,
        alloc_id: vtx_nodeid_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Get the current value NodeID for a field of a virtual object.\n Returns VTX_NODEID_INVALID if the object is not virtual or the\n field is not tracked."]
    pub fn vtx_virtual_get_field(
        result: *const vtx_virtual_result_t,
        alloc_id: vtx_nodeid_t,
        field_offset: u32,
    ) -> vtx_nodeid_t;
}
extern "C" {
    #[doc = " Get the virtual object info for an allocation.\n Returns NULL if the allocation is not virtual."]
    pub fn vtx_virtual_get_obj(
        result: *const vtx_virtual_result_t,
        alloc_id: vtx_nodeid_t,
    ) -> *const vtx_virtual_obj_t;
}
#[doc = " Describes a single point where a scalar-replaced object must be\n materialized. Contains the node where materialization is inserted\n and the list of fields to store."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_materialize_point_t {
    pub escape_node_id: vtx_nodeid_t,
    pub alloc_id: vtx_nodeid_t,
    pub type_id: u32,
    pub field_offsets: *mut u32,
    pub field_local_ids: *mut vtx_nodeid_t,
    pub field_count: u32,
    pub materialized_obj_id: vtx_nodeid_t,
    pub predecessor_control: vtx_nodeid_t,
}
impl Default for vtx_materialize_point_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_materialize_result_t {
    pub points: *mut vtx_materialize_point_t,
    pub point_count: u32,
    pub point_capacity: u32,
    pub objects_materialized: u32,
    pub fields_stored: u32,
    pub deopt_points_handled: u32,
}
impl Default for vtx_materialize_result_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Run the materialization pass on the graph.\n\n Scans for deopt points and escape points that reference scalar-replaced\n objects, and inserts NewObject + StoreField nodes to reify those objects.\n\n This pass must run AFTER cross-object scalar replacement, so it can\n identify which objects were scalar-replaced and what their field values\n are.\n\n @param graph          The SoN graph (modified in place — new nodes inserted)\n @param analysis       The escape analysis result\n @param virtual_result The virtual object tracking result (may be NULL if\n                       virtual pass was not run; when provided, field values\n                       are read from virtual field maps instead of dead\n                       StoreField nodes)\n @param arena          Arena for allocating temporary data\n @return               Materialization result, or NULL on failure"]
    pub fn vtx_materialize_run(
        graph: *mut vtx_graph_t,
        analysis: *const vtx_pea_analysis_t,
        virtual_result: *const vtx_virtual_result_t,
        arena: *mut vtx_arena_t,
    ) -> *mut vtx_materialize_result_t;
}
extern "C" {
    #[doc = " Get the materialized object NodeID for a given allocation at a given\n escape point. Returns VTX_NODEID_INVALID if the object was not\n materialized at that point."]
    pub fn vtx_materialize_get_obj(
        result: *const vtx_materialize_result_t,
        alloc_id: vtx_nodeid_t,
        escape_node_id: vtx_nodeid_t,
    ) -> vtx_nodeid_t;
}
extern "C" {
    #[doc = " Check if an allocation was materialized at any point."]
    pub fn vtx_materialize_is_materialized(
        result: *const vtx_materialize_result_t,
        alloc_id: vtx_nodeid_t,
    ) -> bool;
}
#[doc = " A single node in a GBDT tree. Internal nodes test a feature against\n a threshold; leaf nodes contribute a value to the prediction sum.\n\n Types are chosen for compactness:\n   uint16_t feature_index: 15 features, 0xFFFF = leaf marker\n   float    threshold:     sufficient precision for normalized [0,1] features\n   int16_t  left_child:    indices within a tree (< 32768 nodes per tree)\n   int16_t  right_child:   same\n   float    leaf_value:    small values summed across trees"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_gbdt_node_t {
    pub feature_index: u16,
    pub threshold: f32,
    pub left_child: i32,
    pub right_child: i32,
    pub leaf_value: f32,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_gbdt_tree_desc_t {
    pub root_index: u32,
    pub node_count: u32,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_gbdt_model_t {
    pub nodes: *mut vtx_gbdt_node_t,
    pub node_count: u32,
    pub node_capacity: u32,
    pub trees: [vtx_gbdt_tree_desc_t; 100usize],
    pub tree_count: u32,
    pub max_depth: u32,
    pub init_score: f64,
    pub owns_nodes: bool,
}
impl Default for vtx_gbdt_model_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize an empty GBDT model.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_gbdt_model_init(model: *mut vtx_gbdt_model_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a GBDT model and free owned memory."]
    pub fn vtx_gbdt_model_destroy(model: *mut vtx_gbdt_model_t);
}
extern "C" {
    #[doc = " Load a GBDT model from a flat data array.\n\n The data array layout:\n   [0]     : init_score (double)\n   [1]     : tree_count (uint32_t cast to double)\n   [2]     : max_depth (uint32_t cast to double)\n   [3..]   : for each tree:\n               node_count (uint32_t as double)\n               then node_count * 5 doubles:\n                 feature_index, threshold, left_child, right_child, leaf_value\n\n @param model  Model to load into\n @param data   Flat array of doubles\n @param count  Number of doubles in the data array\n @return       0 on success, -1 on failure"]
    pub fn vtx_gbdt_load_model(
        model: *mut vtx_gbdt_model_t,
        data: *const f64,
        count: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Load the default conservative model.\n This model uses 30 trees of depth 3 with simple heuristics:\n   - Inline if callee is small (normalized size < 0.15)\n   - Inline if receiver type is certain (> 0.8)\n   - Inline if call frequency is high\n   - Don't inline if call depth is too deep\n   - Don't inline if callee deopt rate is high\n   - Positive for constant arguments\n   - Positive for hot callees\n   - Negative for try/catch and virtual calls in some contexts\n\n The default model is always available and can be used until\n a real model is trained from production data.\n\n @param model  Model to load into\n @return       0 on success, -1 on failure"]
    pub fn vtx_gbdt_load_default_model(model: *mut vtx_gbdt_model_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Run GBDT inference on a feature vector.\n\n Traverses each tree from root to leaf, summing leaf values.\n Applies sigmoid transformation to produce output in [0, 1].\n\n @param model    Trained GBDT model\n @param features Feature vector for a call site\n @return         Score in [0, 1]. Above VTX_INLINE_THRESHOLD → inline."]
    pub fn vtx_gbdt_infer(
        model: *const vtx_gbdt_model_t,
        features: *const vtx_inline_features_t,
    ) -> f64;
}
pub type vtx_callee_lookup_fn = ::std::option::Option<
    unsafe extern "C" fn(
        method_index: u32,
        context: *mut ::std::os::raw::c_void,
    ) -> *const vtx_graph_t,
>;
#[doc = " VORTEX ML Inliner — Inlining Transform\n\n Performs the actual inlining of a callee graph into a caller graph\n at a specific call site. The transform follows the Sea-of-Nodes\n inlining algorithm:\n\n   1. Clone the callee's SoN subgraph into the caller's node table\n   2. Replace Parameter nodes in the clone with the call's argument nodes\n   3. Replace Return nodes in the clone with Phi nodes merging into the caller\n   4. Thread the callee's memory chain into the caller's memory chain\n   5. Add FrameState at the inlined entry point for deoptimization\n   6. Run GVN on the inlined subgraph to eliminate redundancies\n\n The caller graph is modified in place. The callee graph is NOT modified.\n\n Important: After inlining, the caller may need DCE and re-scheduling.\n The transform does NOT run these passes automatically — the caller\n must schedule them."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_inline_result_t {
    pub success: bool,
    pub nodes_added: u32,
    pub nodes_removed: u32,
    pub phis_created: u32,
    pub return_value_node: vtx_nodeid_t,
    pub new_memory_node: vtx_nodeid_t,
}
#[doc = " Result of a chain inlining operation.\n Tracks the cumulative statistics across all levels of inlining."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_chain_inline_result_t {
    pub chain_depth: u32,
    pub cumulative_node_count: u32,
    pub sites_inlined: u32,
    pub budget_exhausted: bool,
    pub depth_exhausted: bool,
}
extern "C" {
    #[doc = " Inline a callee graph into a caller graph at a specific call site.\n\n @param caller_graph  The caller's SoN graph (modified in place)\n @param call_node     The call node (CallStatic/CallVirtual/CallInterface) NodeID\n @param callee_graph  The callee's SoN graph (NOT modified, treated as read-only)\n @param arena         Arena for temporary allocations during inlining\n @return              Result structure indicating success/failure and metrics"]
    pub fn vtx_inline_transform(
        caller_graph: *mut vtx_graph_t,
        call_node: vtx_nodeid_t,
        callee_graph: *const vtx_graph_t,
        arena: *mut vtx_arena_t,
    ) -> vtx_inline_result_t;
}
extern "C" {
    #[doc = " Check whether a call node can be inlined.\n\n A call can be inlined if:\n   - The call node exists and is not dead\n   - The callee graph is non-empty\n   - The callee is not too large (node count < VTX_INLINE_SIZE_LIMIT)\n   - The inlining depth has not been exceeded\n   - The call is not recursive (callee == caller)\n\n @param caller_graph  The caller's SoN graph\n @param call_node     The call node to check\n @param callee_graph  The callee's SoN graph\n @param current_depth Current inlining depth\n @return              true if the call can be inlined"]
    pub fn vtx_inline_can_inline(
        caller_graph: *const vtx_graph_t,
        call_node: vtx_nodeid_t,
        callee_graph: *const vtx_graph_t,
        current_depth: u32,
    ) -> bool;
}
extern "C" {
    #[doc = " Perform chain inlining for a hyper-stable call site.\n\n Recursively inlines the callee and scans the inlined subgraph for\n further hyper-stable call sites. The chain terminates when:\n   (a) a call site is not hyper-stable\n   (b) cumulative inlined size exceeds VTX_CHAIN_INLINE_BUDGET\n   (c) chain depth exceeds VTX_MAX_CHAIN_DEPTH\n\n Each level receives a composite guard (from Proposal #2), so the total\n guard cost for a 4-deep chain is 4 compares regardless of argument count.\n\n @param graph           The SoN graph (modified in place)\n @param call_node       The initial call site NodeID to start chaining from\n @param type_feedback   Type feedback for checking hyper-stability\n @param callee_lookup   Function to look up callee graphs by method_index\n @param lookup_context  Context for callee_lookup\n @param arena           Arena for temporary allocations\n @return                Chain inline result with depth and statistics"]
    pub fn vtx_inline_chain(
        graph: *mut vtx_graph_t,
        call_node: vtx_nodeid_t,
        type_feedback: *const vtx_type_feedback_t,
        callee_lookup: vtx_callee_lookup_fn,
        lookup_context: *mut ::std::os::raw::c_void,
        arena: *mut vtx_arena_t,
    ) -> vtx_chain_inline_result_t;
}
pub const vtx_loop_vectorize_t_VTX_LOOP_CANT_VECTORIZE: vtx_loop_vectorize_t = 0;
pub const vtx_loop_vectorize_t_VTX_LOOP_MAYBE_VECTORIZE: vtx_loop_vectorize_t = 1;
pub const vtx_loop_vectorize_t_VTX_LOOP_CAN_VECTORIZE_SSE2: vtx_loop_vectorize_t = 2;
pub const vtx_loop_vectorize_t_VTX_LOOP_CAN_VECTORIZE_AVX2: vtx_loop_vectorize_t = 3;
pub type vtx_loop_vectorize_t = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_loop_spec_result_t {
    pub vectorizability: vtx_loop_vectorize_t,
    pub mean_trip_count: f64,
    pub cv_trip_count: f64,
    pub profiled_iterations: u64,
    pub has_loop_carried_dep: bool,
    pub has_aliased_access: bool,
    pub has_unknown_call: bool,
    pub is_stride1: bool,
    pub stride: u32,
    pub element_size: u32,
    pub tbaa_proves_no_alias: bool,
    pub needs_xor_checksum_guard: bool,
    pub xor_checksum_expected: u64,
    pub vector_width: u32,
    pub peel_count: u32,
}
impl Default for vtx_loop_spec_result_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_sota_loop_spec_t {
    pub loops_checked: u32,
    pub loops_vectorized: u32,
    pub vectorization_attempts_failed: u32,
}
extern "C" {
    #[doc = " Initialize the loop speculation module."]
    pub fn vtx_sota_loop_spec_init(spec: *mut vtx_sota_loop_spec_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the loop speculation module."]
    pub fn vtx_sota_loop_spec_destroy(spec: *mut vtx_sota_loop_spec_t);
}
extern "C" {
    #[doc = " Check if a loop can be speculatively vectorized.\n\n Analyzes the loop body for:\n   - Predictable trip count (from profile data)\n   - Stride-1 access pattern\n   - No loop-carried dependencies\n   - No aliasing between array accesses\n   - No calls to unknown functions\n\n @param spec      Loop spec module\n @param profile   Global profile data (for trip count statistics)\n @param graph     The SoN graph\n @param loop_node The LoopBegin node ID\n @return          Analysis result with vectorizability and parameters"]
    pub fn vtx_sota_loop_spec_check(
        spec: *mut vtx_sota_loop_spec_t,
        profile: *const vtx_profile_global_t,
        graph: *const vtx_graph_t,
        loop_node: vtx_nodeid_t,
    ) -> vtx_loop_spec_result_t;
}
extern "C" {
    #[doc = " Transform a loop by emitting speculative SIMD code.\n\n The transformation:\n   1. Computes the vector width based on CPU features and element size\n   2. Emits a pre-loop for alignment (peel iterations)\n   3. Emits the vectorized loop body with SIMD operations\n   4. Emits a post-loop for remaining iterations\n   5. Adds guards for: alignment, aliasing, trip count\n   6. On guard failure → deopt to the original scalar loop\n\n @param graph        The SoN graph (modified in place)\n @param loop_node    The LoopBegin node ID\n @param cpu_features CPU feature flags (VTX_CPU_SSE2, VTX_CPU_AVX2, etc.)\n @param spec_result  Result from vtx_sota_loop_spec_check\n @param arena        Arena for temporary allocations\n @return             true if transformation was applied, false if not"]
    pub fn vtx_sota_loop_spec_transform(
        graph: *mut vtx_graph_t,
        loop_node: vtx_nodeid_t,
        cpu_features: u32,
        spec_result: *const vtx_loop_spec_result_t,
        arena: *mut vtx_arena_t,
    ) -> bool;
}
#[doc = " Result of a loop unrolling analysis."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_loop_unroll_result_t {
    pub can_unroll: bool,
    pub unroll_factor: u32,
    pub constant_trip_count: u64,
    pub requires_guard: bool,
}
extern "C" {
    #[doc = " Check if a loop can be speculatively unrolled.\n\n A loop can be unrolled when:\n   - The trip count is small and constant (from profiling)\n   - The CV of trip counts is below VTX_LOOP_CV_THRESHOLD\n   - The loop body is small enough that unrolling won't exceed\n     VTX_MAX_NATIVE_SIZE\n\n Unrolling is beneficial when the loop overhead (branch, induction\n variable update) is significant relative to the loop body.\n\n @param spec      Loop spec module\n @param profile   Global profile data\n @param graph     The SoN graph\n @param loop_node The LoopBegin node ID\n @return          Unroll analysis result"]
    pub fn vtx_sota_loop_unroll_check(
        spec: *mut vtx_sota_loop_spec_t,
        profile: *const vtx_profile_global_t,
        graph: *const vtx_graph_t,
        loop_node: vtx_nodeid_t,
    ) -> vtx_loop_unroll_result_t;
}
extern "C" {
    #[doc = " Transform a loop by unrolling it with a trip count guard.\n\n The transformation:\n   1. Emits a DeoptGuard that the trip count equals the expected value\n   2. Copies the loop body N times (where N = unroll_factor)\n   3. Removes the loop back-edge (since the trip count is known)\n   4. On guard failure → deopt to the original loop\n\n @param graph        The SoN graph (modified in place)\n @param loop_node    The LoopBegin node ID\n @param unroll_result Result from vtx_sota_loop_unroll_check\n @param arena        Arena for temporary allocations\n @return             true if transformation was applied"]
    pub fn vtx_sota_loop_unroll_transform(
        graph: *mut vtx_graph_t,
        loop_node: vtx_nodeid_t,
        unroll_result: *const vtx_loop_unroll_result_t,
        arena: *mut vtx_arena_t,
    ) -> bool;
}
extern "C" {
    #[doc = " Compute the coefficient of variation from a set of trip count observations.\n CV = stddev / mean. A low CV (< VTX_LOOP_CV_THRESHOLD) indicates\n a predictable trip count.\n\n @param trip_counts Array of observed trip counts\n @param count       Number of observations\n @return            Coefficient of variation, or INFINITY if mean is 0"]
    pub fn vtx_loop_cv(trip_counts: *const u64, count: u32) -> f64;
}
extern "C" {
    #[doc = " Compute the vector width for a given element size and CPU features.\n Returns the number of elements that fit in one vector register.\n\n SSE2: 128 bits → 4 floats, 2 doubles, 4 int32, 2 int64\n AVX2: 256 bits → 8 floats, 4 doubles, 8 int32, 4 int64"]
    pub fn vtx_loop_vector_width(element_size: u32, cpu_features: u32) -> u32;
}
extern "C" {
    #[doc = " Detect the CPU features available at runtime.\n Uses CPUID on x86-64."]
    pub fn vtx_cpu_detect_features() -> u32;
}
extern "C" {
    #[doc = " Detect CPU features at runtime (alias for vtx_cpu_detect_features).\n Returns a bitmask with VTX_CPU_SSE2, VTX_CPU_AVX2, VTX_CPU_AVX512 set\n according to what the CPU supports.\n\n SSE2 is always available on x86-64 (baseline).\n AVX2 requires CPUID leaf 7, EBX bit 5."]
    pub fn vtx_sota_loop_detect_cpu_features() -> u32;
}
#[doc = " VORTEX Mid-Tier (T1.5) — Type-Specialized Compilation\n\n Between the baseline T1 and the optimizing T2, the mid-tier provides\n type-specialized compilation with minimal analysis. This reduces warmup\n time by 3-5x compared to waiting for T2 compilation.\n\n Key differences from T1 (baseline):\n   - Uses type feedback to specialize operations (e.g., \"this is always int\")\n   - Eliminates type checks for monomorphic call sites\n   - Inline caches are pre-populated from type feedback\n\n Key differences from T2 (optimizing):\n   - No PEA / escape analysis / scalar replacement\n   - No inlining of non-trivial methods\n   - No LICM / bounds check elimination\n   - Compilation is ~10x faster than T2"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_midtier_config_t {
    pub use_type_feedback: bool,
    pub inline_max_size: u32,
    pub specialize_arithmetic: bool,
    pub methods_compiled: u32,
    pub sites_specialized: u32,
    pub guards_inserted: u32,
    pub compilation_time_ns: u64,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_midtier_result_t {
    pub code: *mut u8,
    pub code_size: u32,
    pub guards_inserted: u32,
    pub sites_specialized: u32,
}
impl Default for vtx_midtier_result_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn vtx_midtier_config_default() -> vtx_midtier_config_t;
}
extern "C" {
    pub fn vtx_midtier_compile(
        method: *const vtx_method_desc_t,
        type_feedback: *const vtx_type_feedback_t,
        ts: *mut vtx_type_system_t,
        arena: *mut vtx_arena_t,
    ) -> *mut vtx_midtier_result_t;
}
extern "C" {
    #[doc = " Run profile-guided block layout on the schedule.\n\n Reorders blocks so that hot paths fall through (no branch needed)\n and cold paths are pushed to the end. Uses branch probability data\n from the profiler to decide which successor is \"hot\".\n\n @param schedule   The schedule to reorder (modified in-place)\n @param graph      The SoN graph (for looking up If node bytecode PCs)\n @param profiler   Profiler data (may be NULL — falls back to heuristic)\n @param method     Method descriptor (for profiler lookup)\n @return           Number of blocks reordered (0 if no change)"]
    pub fn vtx_block_layout_run(
        schedule: *mut vtx_schedule_t,
        graph: *const vtx_graph_t,
        profiler: *const vtx_profiler_t,
        method: *const vtx_method_desc_t,
    ) -> u32;
}
pub const vtx_x86_opcode_t_VTX_X86_NOP: vtx_x86_opcode_t = 0;
pub const vtx_x86_opcode_t_VTX_X86_ADD: vtx_x86_opcode_t = 1;
pub const vtx_x86_opcode_t_VTX_X86_SUB: vtx_x86_opcode_t = 2;
pub const vtx_x86_opcode_t_VTX_X86_IMUL: vtx_x86_opcode_t = 3;
pub const vtx_x86_opcode_t_VTX_X86_IDIV: vtx_x86_opcode_t = 4;
pub const vtx_x86_opcode_t_VTX_X86_MUL: vtx_x86_opcode_t = 5;
pub const vtx_x86_opcode_t_VTX_X86_IMUL_FULL: vtx_x86_opcode_t = 6;
pub const vtx_x86_opcode_t_VTX_X86_NEG: vtx_x86_opcode_t = 7;
pub const vtx_x86_opcode_t_VTX_X86_NOT: vtx_x86_opcode_t = 8;
pub const vtx_x86_opcode_t_VTX_X86_INC: vtx_x86_opcode_t = 9;
pub const vtx_x86_opcode_t_VTX_X86_DEC: vtx_x86_opcode_t = 10;
pub const vtx_x86_opcode_t_VTX_X86_SHL: vtx_x86_opcode_t = 11;
pub const vtx_x86_opcode_t_VTX_X86_SHR: vtx_x86_opcode_t = 12;
pub const vtx_x86_opcode_t_VTX_X86_SAR: vtx_x86_opcode_t = 13;
pub const vtx_x86_opcode_t_VTX_X86_ROL: vtx_x86_opcode_t = 14;
pub const vtx_x86_opcode_t_VTX_X86_ROR: vtx_x86_opcode_t = 15;
pub const vtx_x86_opcode_t_VTX_X86_AND: vtx_x86_opcode_t = 16;
pub const vtx_x86_opcode_t_VTX_X86_OR: vtx_x86_opcode_t = 17;
pub const vtx_x86_opcode_t_VTX_X86_XOR: vtx_x86_opcode_t = 18;
pub const vtx_x86_opcode_t_VTX_X86_CMP: vtx_x86_opcode_t = 19;
pub const vtx_x86_opcode_t_VTX_X86_TEST: vtx_x86_opcode_t = 20;
pub const vtx_x86_opcode_t_VTX_X86_MOV: vtx_x86_opcode_t = 21;
pub const vtx_x86_opcode_t_VTX_X86_MOVZX: vtx_x86_opcode_t = 22;
pub const vtx_x86_opcode_t_VTX_X86_MOVSX: vtx_x86_opcode_t = 23;
pub const vtx_x86_opcode_t_VTX_X86_CMOV: vtx_x86_opcode_t = 24;
pub const vtx_x86_opcode_t_VTX_X86_XCHG: vtx_x86_opcode_t = 25;
pub const vtx_x86_opcode_t_VTX_X86_LEA: vtx_x86_opcode_t = 26;
pub const vtx_x86_opcode_t_VTX_X86_CQO: vtx_x86_opcode_t = 27;
pub const vtx_x86_opcode_t_VTX_X86_CDQ: vtx_x86_opcode_t = 28;
pub const vtx_x86_opcode_t_VTX_X86_CDQE: vtx_x86_opcode_t = 29;
pub const vtx_x86_opcode_t_VTX_X86_SETCC: vtx_x86_opcode_t = 30;
pub const vtx_x86_opcode_t_VTX_X86_BSWAP: vtx_x86_opcode_t = 31;
pub const vtx_x86_opcode_t_VTX_X86_BSF: vtx_x86_opcode_t = 32;
pub const vtx_x86_opcode_t_VTX_X86_BSR: vtx_x86_opcode_t = 33;
pub const vtx_x86_opcode_t_VTX_X86_POPCNT: vtx_x86_opcode_t = 34;
pub const vtx_x86_opcode_t_VTX_X86_BT: vtx_x86_opcode_t = 35;
pub const vtx_x86_opcode_t_VTX_X86_PUSH: vtx_x86_opcode_t = 36;
pub const vtx_x86_opcode_t_VTX_X86_POP: vtx_x86_opcode_t = 37;
pub const vtx_x86_opcode_t_VTX_X86_JMP: vtx_x86_opcode_t = 38;
pub const vtx_x86_opcode_t_VTX_X86_JCC: vtx_x86_opcode_t = 39;
pub const vtx_x86_opcode_t_VTX_X86_CALL: vtx_x86_opcode_t = 40;
pub const vtx_x86_opcode_t_VTX_X86_RET: vtx_x86_opcode_t = 41;
pub const vtx_x86_opcode_t_VTX_X86_LAHF: vtx_x86_opcode_t = 42;
pub const vtx_x86_opcode_t_VTX_X86_SAHF: vtx_x86_opcode_t = 43;
pub const vtx_x86_opcode_t_VTX_X86_UCOMISD: vtx_x86_opcode_t = 44;
pub const vtx_x86_opcode_t_VTX_X86_COMISD: vtx_x86_opcode_t = 45;
pub const vtx_x86_opcode_t_VTX_X86_ADDSD: vtx_x86_opcode_t = 46;
pub const vtx_x86_opcode_t_VTX_X86_SUBSD: vtx_x86_opcode_t = 47;
pub const vtx_x86_opcode_t_VTX_X86_MULSD: vtx_x86_opcode_t = 48;
pub const vtx_x86_opcode_t_VTX_X86_DIVSD: vtx_x86_opcode_t = 49;
pub const vtx_x86_opcode_t_VTX_X86_SQRTSD: vtx_x86_opcode_t = 50;
pub const vtx_x86_opcode_t_VTX_X86_XORPS: vtx_x86_opcode_t = 51;
pub const vtx_x86_opcode_t_VTX_X86_MOVSD: vtx_x86_opcode_t = 52;
pub const vtx_x86_opcode_t_VTX_X86_MOVSD_LOAD: vtx_x86_opcode_t = 53;
pub const vtx_x86_opcode_t_VTX_X86_MOVSD_STORE: vtx_x86_opcode_t = 54;
pub const vtx_x86_opcode_t_VTX_X86_CVTSI2SD: vtx_x86_opcode_t = 55;
pub const vtx_x86_opcode_t_VTX_X86_CVTSD2SI: vtx_x86_opcode_t = 56;
pub const vtx_x86_opcode_t_VTX_X86_CVTTSD2SI: vtx_x86_opcode_t = 57;
pub const vtx_x86_opcode_t_VTX_X86_CVTSI2SS: vtx_x86_opcode_t = 58;
pub const vtx_x86_opcode_t_VTX_X86_CVTSS2SI: vtx_x86_opcode_t = 59;
pub const vtx_x86_opcode_t_VTX_X86_CVTTSS2SI: vtx_x86_opcode_t = 60;
pub const vtx_x86_opcode_t_VTX_X86_MOVQ_XMM_R64: vtx_x86_opcode_t = 61;
pub const vtx_x86_opcode_t_VTX_X86_MOVQ_R64_XMM: vtx_x86_opcode_t = 62;
pub const vtx_x86_opcode_t_VTX_X86_SAFEPOINT_POLL: vtx_x86_opcode_t = 63;
pub const vtx_x86_opcode_t_VTX_X86_SAFEPOINT_POLL_GUARD_PAGE: vtx_x86_opcode_t = 64;
pub const vtx_x86_opcode_t_VTX_X86_MOVAPD: vtx_x86_opcode_t = 65;
pub const vtx_x86_opcode_t_VTX_X86_ADDPD: vtx_x86_opcode_t = 66;
pub const vtx_x86_opcode_t_VTX_X86_MULPD: vtx_x86_opcode_t = 67;
pub const vtx_x86_opcode_t_VTX_X86_MINPD: vtx_x86_opcode_t = 68;
pub const vtx_x86_opcode_t_VTX_X86_MAXPD: vtx_x86_opcode_t = 69;
pub const vtx_x86_opcode_t_VTX_X86_ANDPD: vtx_x86_opcode_t = 70;
pub const vtx_x86_opcode_t_VTX_X86_XORPD: vtx_x86_opcode_t = 71;
pub const vtx_x86_opcode_t_VTX_X86_SUBPD: vtx_x86_opcode_t = 72;
pub const vtx_x86_opcode_t_VTX_X86_DIVPD: vtx_x86_opcode_t = 73;
pub const vtx_x86_opcode_t_VTX_X86_MOVDQA: vtx_x86_opcode_t = 74;
pub const vtx_x86_opcode_t_VTX_X86_MOVDQU: vtx_x86_opcode_t = 75;
pub const vtx_x86_opcode_t_VTX_X86_PADDD: vtx_x86_opcode_t = 76;
pub const vtx_x86_opcode_t_VTX_X86_PSUBD: vtx_x86_opcode_t = 77;
pub const vtx_x86_opcode_t_VTX_X86_PMULLD: vtx_x86_opcode_t = 78;
pub const vtx_x86_opcode_t_VTX_X86_PXOR: vtx_x86_opcode_t = 79;
pub const vtx_x86_opcode_t_VTX_X86_PAND: vtx_x86_opcode_t = 80;
pub const vtx_x86_opcode_t_VTX_X86_POR: vtx_x86_opcode_t = 81;
pub const vtx_x86_opcode_t_VTX_X86_PCMPEQD: vtx_x86_opcode_t = 82;
pub const vtx_x86_opcode_t_VTX_X86_MOVAPS: vtx_x86_opcode_t = 83;
pub const vtx_x86_opcode_t_VTX_X86_ADDPS: vtx_x86_opcode_t = 84;
pub const vtx_x86_opcode_t_VTX_X86_MULPS: vtx_x86_opcode_t = 85;
pub const vtx_x86_opcode_t_VTX_X86_SUBPS: vtx_x86_opcode_t = 86;
pub const vtx_x86_opcode_t_VTX_X86_DIVPS: vtx_x86_opcode_t = 87;
pub const vtx_x86_opcode_t_VTX_X86_MINPS: vtx_x86_opcode_t = 88;
pub const vtx_x86_opcode_t_VTX_X86_MAXPS: vtx_x86_opcode_t = 89;
pub const vtx_x86_opcode_t_VTX_X86_CMPPS: vtx_x86_opcode_t = 90;
pub const vtx_x86_opcode_t_VTX_X86_ADDSS: vtx_x86_opcode_t = 91;
pub const vtx_x86_opcode_t_VTX_X86_SUBSS: vtx_x86_opcode_t = 92;
pub const vtx_x86_opcode_t_VTX_X86_MULSS: vtx_x86_opcode_t = 93;
pub const vtx_x86_opcode_t_VTX_X86_DIVSS: vtx_x86_opcode_t = 94;
pub const vtx_x86_opcode_t_VTX_X86_SQRTSS: vtx_x86_opcode_t = 95;
pub const vtx_x86_opcode_t_VTX_X86_UCOMISS: vtx_x86_opcode_t = 96;
pub const vtx_x86_opcode_t_VTX_X86_MOVSS: vtx_x86_opcode_t = 97;
pub const vtx_x86_opcode_t_VTX_X86_DIV: vtx_x86_opcode_t = 98;
pub const vtx_x86_opcode_t_VTX_X86_RDTSC: vtx_x86_opcode_t = 99;
pub const vtx_x86_opcode_t_VTX_X86_RDTSCP: vtx_x86_opcode_t = 100;
pub const vtx_x86_opcode_t_VTX_X86_CMPXCHG: vtx_x86_opcode_t = 101;
pub const vtx_x86_opcode_t_VTX_X86_XADD: vtx_x86_opcode_t = 102;
pub const vtx_x86_opcode_t_VTX_X86_LFENCE: vtx_x86_opcode_t = 103;
pub const vtx_x86_opcode_t_VTX_X86_MFENCE: vtx_x86_opcode_t = 104;
pub const vtx_x86_opcode_t_VTX_X86_SFENCE: vtx_x86_opcode_t = 105;
pub const vtx_x86_opcode_t_VTX_X86_ROUNDSD: vtx_x86_opcode_t = 106;
pub const vtx_x86_opcode_t_VTX_X86_ROUNDSS: vtx_x86_opcode_t = 107;
pub const vtx_x86_opcode_t_VTX_X86_MOVSD_RIP: vtx_x86_opcode_t = 108;
pub const vtx_x86_opcode_t_VTX_X86_VMOVAPD_256: vtx_x86_opcode_t = 109;
pub const vtx_x86_opcode_t_VTX_X86_VADDPD_256: vtx_x86_opcode_t = 110;
pub const vtx_x86_opcode_t_VTX_X86_VSUBPD_256: vtx_x86_opcode_t = 111;
pub const vtx_x86_opcode_t_VTX_X86_VMULPD_256: vtx_x86_opcode_t = 112;
pub const vtx_x86_opcode_t_VTX_X86_VDIVPD_256: vtx_x86_opcode_t = 113;
pub const vtx_x86_opcode_t_VTX_X86_VMINPD_256: vtx_x86_opcode_t = 114;
pub const vtx_x86_opcode_t_VTX_X86_VMAXPD_256: vtx_x86_opcode_t = 115;
pub const vtx_x86_opcode_t_VTX_X86_VXORPD_256: vtx_x86_opcode_t = 116;
pub const vtx_x86_opcode_t_VTX_X86_VANDPD_256: vtx_x86_opcode_t = 117;
pub const vtx_x86_opcode_t_VTX_X86_VCMPPD_256: vtx_x86_opcode_t = 118;
pub const vtx_x86_opcode_t_VTX_X86_VMOVAPS_256: vtx_x86_opcode_t = 119;
pub const vtx_x86_opcode_t_VTX_X86_VADDPS_256: vtx_x86_opcode_t = 120;
pub const vtx_x86_opcode_t_VTX_X86_VSUBPS_256: vtx_x86_opcode_t = 121;
pub const vtx_x86_opcode_t_VTX_X86_VMULPS_256: vtx_x86_opcode_t = 122;
pub const vtx_x86_opcode_t_VTX_X86_VDIVPS_256: vtx_x86_opcode_t = 123;
pub const vtx_x86_opcode_t_VTX_X86_VMOVDQA_256: vtx_x86_opcode_t = 124;
pub const vtx_x86_opcode_t_VTX_X86_VPADDD_256: vtx_x86_opcode_t = 125;
pub const vtx_x86_opcode_t_VTX_X86_VPSUBD_256: vtx_x86_opcode_t = 126;
pub const vtx_x86_opcode_t_VTX_X86_VPMULLD_256: vtx_x86_opcode_t = 127;
pub const vtx_x86_opcode_t_VTX_X86_VPXOR_256: vtx_x86_opcode_t = 128;
pub const vtx_x86_opcode_t_VTX_X86_VPAND_256: vtx_x86_opcode_t = 129;
pub const vtx_x86_opcode_t_VTX_X86_VPOR_256: vtx_x86_opcode_t = 130;
pub const vtx_x86_opcode_t_VTX_X86_VZEROUPPER: vtx_x86_opcode_t = 131;
pub const vtx_x86_opcode_t_VTX_X86_VZEROALL: vtx_x86_opcode_t = 132;
pub const vtx_x86_opcode_t_VTX_X86_VBROADCASTSD: vtx_x86_opcode_t = 133;
pub const vtx_x86_opcode_t_VTX_X86_VBROADCASTSS: vtx_x86_opcode_t = 134;
pub const vtx_x86_opcode_t_VTX_X86_VPERM2F128: vtx_x86_opcode_t = 135;
pub const vtx_x86_opcode_t_VTX_X86_VINSERTF128: vtx_x86_opcode_t = 136;
pub const vtx_x86_opcode_t_VTX_X86_VEXTRACTF128: vtx_x86_opcode_t = 137;
pub const vtx_x86_opcode_t_VTX_X86_OPCODE_COUNT: vtx_x86_opcode_t = 138;
pub type vtx_x86_opcode_t = ::std::os::raw::c_uint;
pub const vtx_opnd_kind_t_VTX_OPND_NONE: vtx_opnd_kind_t = 0;
pub const vtx_opnd_kind_t_VTX_OPND_VREG: vtx_opnd_kind_t = 1;
pub const vtx_opnd_kind_t_VTX_OPND_PREG: vtx_opnd_kind_t = 2;
pub const vtx_opnd_kind_t_VTX_OPND_IMM: vtx_opnd_kind_t = 3;
pub const vtx_opnd_kind_t_VTX_OPND_MEM: vtx_opnd_kind_t = 4;
pub const vtx_opnd_kind_t_VTX_OPND_LABEL: vtx_opnd_kind_t = 5;
pub const vtx_opnd_kind_t_VTX_OPND_SPILL: vtx_opnd_kind_t = 6;
pub type vtx_opnd_kind_t = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_x86_memop_t {
    pub base_vreg: u32,
    pub index_vreg: u32,
    pub base_phys: u8,
    pub index_phys: u8,
    pub scale: u8,
    pub disp: i32,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_inst_t {
    pub opcode: vtx_x86_opcode_t,
    pub opnd_kinds: [vtx_opnd_kind_t; 3usize],
    pub operands: [u32; 3usize],
    pub imm: i64,
    pub mem: vtx_x86_memop_t,
    pub cond: vtx_cond_t,
    pub flags: u32,
    pub source_node: vtx_nodeid_t,
    pub native_offset: u32,
}
impl Default for vtx_inst_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_inst_block_t {
    pub insts: *mut vtx_inst_t,
    pub inst_count: u32,
    pub inst_capacity: u32,
    pub block_id: u32,
}
impl Default for vtx_inst_block_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_inst_stream_t {
    pub blocks: *mut vtx_inst_block_t,
    pub block_count: u32,
    pub block_capacity: u32,
    pub vreg_count: u32,
    pub node_to_vreg: *mut u32,
    pub node_to_vreg_count: u32,
    pub vreg_fixed_reg: *mut u8,
    pub vreg_fixed_reg_count: u32,
    pub smi_scratch_vreg: u32,
    pub smi_mask_vreg: u32,
    pub uses_smi: bool,
    pub schedule: *const vtx_schedule_t,
}
impl Default for vtx_inst_stream_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Select x86-64 instructions from the scheduled SoN graph.\n\n Walks each block in the schedule, mapping each SoN node to x86-64\n instructions. Value-producing nodes are assigned virtual registers.\n Guard/DeoptGuard nodes emit compare + conditional jump instructions.\n\n @param schedule  The scheduled SoN graph\n @param arena     Arena for allocations (node_to_vreg, blocks, instructions)\n @return          Instruction stream, or NULL on failure"]
    pub fn vtx_isel_select(
        schedule: *const vtx_schedule_t,
        graph: *const vtx_graph_t,
        arena: *mut vtx_arena_t,
    ) -> *mut vtx_inst_stream_t;
}
extern "C" {
    #[doc = " Get the virtual register assigned to a node.\n Returns VTX_VREG_INVALID if the node has no vreg."]
    pub fn vtx_isel_node_vreg(stream: *const vtx_inst_stream_t, node_id: vtx_nodeid_t) -> u32;
}
extern "C" {
    #[doc = " Allocate a new virtual register in the stream.\n Returns the new vreg id, or VTX_VREG_INVALID on failure."]
    pub fn vtx_isel_alloc_vreg(stream: *mut vtx_inst_stream_t, arena: *mut vtx_arena_t) -> u32;
}
extern "C" {
    #[doc = " Allocate a new virtual register fixed to a specific physical register.\n Returns the new vreg id, or VTX_VREG_INVALID on failure."]
    pub fn vtx_isel_alloc_vreg_fixed(
        stream: *mut vtx_inst_stream_t,
        arena: *mut vtx_arena_t,
        phys_reg: u8,
    ) -> u32;
}
extern "C" {
    #[doc = " Map a node to a virtual register (overwriting any previous mapping)."]
    pub fn vtx_isel_map_node_vreg(
        stream: *mut vtx_inst_stream_t,
        node_id: vtx_nodeid_t,
        vreg: u32,
        arena: *mut vtx_arena_t,
    );
}
extern "C" {
    #[doc = " Append an instruction to a block.\n Returns the instruction index, or UINT32_MAX on failure."]
    pub fn vtx_isel_emit_inst(
        block: *mut vtx_inst_block_t,
        inst: vtx_inst_t,
        arena: *mut vtx_arena_t,
    ) -> u32;
}
extern "C" {
    #[doc = " Ensure a block has capacity for at least `needed` more instructions.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_isel_block_ensure_capacity(
        block: *mut vtx_inst_block_t,
        needed: u32,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Get the human-readable name for an x86 opcode."]
    pub fn vtx_x86_opcode_name(opcode: vtx_x86_opcode_t) -> *const ::std::os::raw::c_char;
}
pub const vtx_reg_class_t_VTX_REG_CLASS_GPR: vtx_reg_class_t = 0;
pub const vtx_reg_class_t_VTX_REG_CLASS_XMM: vtx_reg_class_t = 1;
pub const vtx_reg_class_t_VTX_REG_CLASS_COUNT: vtx_reg_class_t = 2;
#[doc = " VORTEX Linear Scan Register Allocator\n\n Assigns physical registers to virtual registers using a linear scan\n algorithm. Computes live intervals for each virtual register, sorts\n by start point, and iteratively assigns physical registers.\n\n Register allocation policy:\n   - Caller-saved first: RAX, RCX, RDX, RSI, RDI, R8-R11\n   - Callee-saved next: RBX, R12-R15 (with save/restore)\n   - RBP/RSP reserved (never assigned)\n   - Spill slots at fixed offsets from RBP\n\n When no free register is available, the interval with the furthest\n end point is evicted (spilled)."]
pub type vtx_reg_class_t = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_live_range {
    pub start: u32,
    pub end: u32,
    pub phys_reg: u8,
    pub spill_slot: u32,
    pub next: *mut vtx_live_range,
}
impl Default for vtx_live_range {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
pub type vtx_live_range_t = vtx_live_range;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_live_interval {
    pub vreg: u32,
    pub first_range: *mut vtx_live_range_t,
    pub last_range: *mut vtx_live_range_t,
    pub start: u32,
    pub end: u32,
    pub phys_reg: u8,
    pub spill_slot: u32,
    pub is_fixed: bool,
    pub fixed_reg: u8,
    pub is_spilled: bool,
    pub is_remat: bool,
    pub use_count: u32,
    pub loop_depth: u32,
    pub coalesce_src: u32,
    pub reg_class: vtx_reg_class_t,
    pub split_parent: *mut vtx_live_interval,
    pub split_child: *mut vtx_live_interval,
}
impl Default for vtx_live_interval {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
pub type vtx_live_interval_t = vtx_live_interval;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_regalloc_result_t {
    pub vreg_to_phys: *mut u8,
    pub vreg_to_phys_count: u32,
    pub vreg_to_spill: *mut u32,
    pub vreg_to_spill_count: u32,
    pub vreg_is_remat: *mut bool,
    pub vreg_remat_imm: *mut i64,
    pub vreg_remat_count: u32,
    pub spill_count: u32,
    pub callee_saved_mask: u32,
    pub frame_size: u32,
    pub interval_count: u32,
    pub intervals: *mut vtx_live_interval_t,
    pub is_leaf: bool,
}
impl Default for vtx_regalloc_result_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Run the linear scan register allocator on the instruction stream.\n\n Computes live intervals, assigns physical registers, and inserts\n spill/fill code as needed.\n\n @param stream  The instruction stream (with virtual registers)\n @param arena   Arena for allocations\n @return        Register allocation result, or NULL on failure"]
    pub fn vtx_regalloc_run(
        stream: *mut vtx_inst_stream_t,
        arena: *mut vtx_arena_t,
    ) -> *mut vtx_regalloc_result_t;
}
extern "C" {
    #[doc = " Apply the register allocation result to the instruction stream.\n Replaces virtual register references with physical register references.\n Inserts spill/fill instructions where needed.\n\n @param stream  The instruction stream to modify\n @param result  The register allocation result\n @param arena   Arena for new instructions\n @return        0 on success, -1 on failure"]
    pub fn vtx_regalloc_apply(
        stream: *mut vtx_inst_stream_t,
        result: *const vtx_regalloc_result_t,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Get the physical register assigned to a virtual register.\n Returns 0xFF (VTX_REG_NONE) if not assigned."]
    pub fn vtx_regalloc_phys_reg(result: *const vtx_regalloc_result_t, vreg: u32) -> u8;
}
extern "C" {
    #[doc = " Get the spill slot assigned to a virtual register.\n Returns VTX_NO_SPILL if not spilled."]
    pub fn vtx_regalloc_spill_slot(result: *const vtx_regalloc_result_t, vreg: u32) -> u32;
}
extern "C" {
    #[doc = " Split a live interval at the given position.\n\n The interval is divided into two parts:\n   - First half: [start, position) — keeps the current register assignment\n   - Second half: [position, end) — becomes a new interval needing a register\n\n If the second half can get a free register, it does; otherwise it's spilled.\n At the split point, spill/reload code is inserted as needed.\n\n @param interval  The interval to split (modified in place to become first half)\n @param position  The split position (must be within the interval's range)\n @param arena     Arena for allocations\n @return          The new second-half interval, or NULL on failure"]
    pub fn vtx_regalloc_split_interval(
        interval: *mut vtx_live_interval_t,
        position: u32,
        arena: *mut vtx_arena_t,
    ) -> *mut vtx_live_interval_t;
}
extern "C" {
    #[doc = " Find the NodeID that is currently in a given physical register at a\n given instruction position.\n\n Uses the register allocator's live interval data to determine which\n vreg (and thus which SoN node) occupies the physical register at\n the specified instruction position.\n\n @param result   Register allocation result\n @param stream   Instruction stream (for vreg → NodeID reverse mapping)\n @param position Instruction position (sequential instruction index)\n @param phys_reg Physical register number to look up\n @return         NodeID occupying the register, or VTX_NODEID_INVALID"]
    pub fn vtx_regalloc_node_at_position(
        result: *const vtx_regalloc_result_t,
        stream: *const vtx_inst_stream_t,
        position: u32,
        phys_reg: u8,
    ) -> vtx_nodeid_t;
}
extern "C" {
    #[doc = " Get the set of physical registers that are live at a given instruction\n position, along with their defining NodeIDs.\n\n @param result       Register allocation result\n @param position     Instruction position (sequential instruction index)\n @param out_regs     Output array of physical register numbers (caller-allocated)\n @param out_nodeids  Output array of NodeIDs (caller-allocated, parallel to out_regs)\n @param max_entries  Maximum number of entries the output arrays can hold\n @return             Number of live register entries written"]
    pub fn vtx_regalloc_live_regs_at_position(
        result: *const vtx_regalloc_result_t,
        position: u32,
        out_regs: *mut u8,
        out_nodeids: *mut vtx_nodeid_t,
        max_entries: u32,
    ) -> u32;
}
extern "C" {
    #[doc = " Split live intervals at loop boundaries.\n\n Audit priority #5: \"Split live ranges at loop boundaries.\"\n\n When a live interval spans a loop boundary (enters or exits a loop),\n splitting it at the boundary allows the loop body to use a different\n register than the loop preheader/postheader. This reduces register\n pressure inside the loop, which is where it matters most.\n\n This function scans all live intervals and splits any that cross a\n loop boundary. The loop boundaries are determined from the schedule's\n loop header information.\n\n @param result   Register allocation result (intervals will be modified)\n @param stream   Instruction stream (for loop boundary positions)\n @param arena    Arena for new interval allocations\n @return         Number of intervals split"]
    pub fn vtx_regalloc_split_at_loop_boundaries(
        result: *mut vtx_regalloc_result_t,
        stream: *const vtx_inst_stream_t,
        arena: *mut vtx_arena_t,
    ) -> u32;
}
extern "C" {
    #[doc = " Check if a vreg is a candidate for rematerialization.\n\n Audit priority #5: \"Rematerialization of constants instead of spilling.\"\n\n Instead of spilling a value to memory and reloading it, we can\n sometimes just recompute it. This is cheaper for:\n   - Constants: `mov reg, imm` is 1 instruction, vs. spill+reload = 2+\n   - Simple arithmetic: `lea reg, [base+disp]` is 1 instruction\n\n This function checks if the vreg's defining instruction is a simple\n constant load or LEA that can be rematerialized.\n\n @param stream   Instruction stream\n @param vreg     Virtual register to check\n @return         true if the vreg can be rematerialized"]
    pub fn vtx_regalloc_can_rematerialize(stream: *const vtx_inst_stream_t, vreg: u32) -> bool;
}
extern "C" {
    #[doc = " Get the rematerialization cost for a vreg.\n\n Returns the number of instructions needed to rematerialize the value.\n Lower is better. Returns UINT32_MAX if rematerialization is not possible.\n\n @param stream   Instruction stream\n @param vreg     Virtual register to check\n @return         Instruction count, or UINT32_MAX"]
    pub fn vtx_regalloc_rematerialize_cost(stream: *const vtx_inst_stream_t, vreg: u32) -> u32;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_x86_emit_t {
    pub buffer: *mut u8,
    pub position: u32,
    pub capacity: u32,
    pub relocs: *mut vtx_reloc_table_t,
    pub reloc_arena: *mut vtx_arena_t,
    pub label_offsets: *mut u32,
    pub label_count: u32,
    pub const_pool: vtx_x86_emit_t__bindgen_ty_1,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_x86_emit_t__bindgen_ty_1 {
    pub values: *mut u64,
    pub ref_offsets: *mut u32,
    pub count: u32,
    pub capacity: u32,
}
impl Default for vtx_x86_emit_t__bindgen_ty_1 {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
impl Default for vtx_x86_emit_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the emitter with an initial buffer capacity.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_x86_emit_init(
        emit: *mut vtx_x86_emit_t,
        initial_capacity: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the emitter and free the code buffer."]
    pub fn vtx_x86_emit_destroy(emit: *mut vtx_x86_emit_t);
}
extern "C" {
    #[doc = " Ensure the buffer has at least `needed` bytes of free space.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_x86_emit_ensure(emit: *mut vtx_x86_emit_t, needed: u32) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Emit a REX.W + opcode + ModR/M for register-register instructions.\n For example: add r64, r64 → REX.W 01 ModR/M\n @param e        Emitter\n @param opcode   Primary opcode byte\n @param opcode2  Secondary opcode byte (0 = none, e.g. 0F prefix)\n @param reg      Destination or source register (goes in reg field)\n @param rm       Source or destination register (goes in r/m field)\n @param direction 0=reg is r/m, rm is reg (opcode /r); 1=reg is reg, rm is r/m"]
    pub fn vtx_x86_emit_rr(e: *mut vtx_x86_emit_t, opcode: u8, opcode2: u8, reg: u8, rm: u8);
}
extern "C" {
    #[doc = " Emit a REX.W + opcode + ModR/M for register-immediate instructions.\n The immediate is sign-extended from 32 bits to 64 bits.\n @param e        Emitter\n @param opcode   Primary opcode byte (e.g. 81 for imm32, 83 for imm8)\n @param reg_ext  Opcode extension in ModR/M reg field (e.g. 0=ADD, 5=SUB)\n @param rm       Target register\n @param imm      Immediate value\n @param imm_size 4 for imm32, 1 for imm8"]
    pub fn vtx_x86_emit_ri(
        e: *mut vtx_x86_emit_t,
        opcode: u8,
        reg_ext: u8,
        rm: u8,
        imm: i64,
        imm_size: ::std::os::raw::c_int,
    );
}
extern "C" {
    #[doc = " Emit a REX.W + opcode + ModR/M for register-memory instructions.\n Memory is [base + disp].\n @param e         Emitter\n @param opcode    Primary opcode byte\n @param opcode2   Secondary opcode byte (0 = none)\n @param reg       Register operand\n @param base      Base register\n @param disp      Displacement\n @param is_load   true=load (reg ← mem), false=store (mem ← reg)"]
    pub fn vtx_x86_emit_rm(
        e: *mut vtx_x86_emit_t,
        opcode: u8,
        opcode2: u8,
        reg: u8,
        base: u8,
        disp: i32,
        is_load: bool,
    );
}
extern "C" {
    #[doc = " Emit a REX.W + opcode + ModR/M + SIB for [base + index*scale + disp].\n @param e         Emitter\n @param opcode    Primary opcode byte\n @param opcode2   Secondary opcode byte (0 = none)\n @param reg       Register operand\n @param base      Base register\n @param index     Index register\n @param scale     Scale (1, 2, 4, 8)\n @param disp      Displacement\n @param is_load   true=load (reg ← mem), false=store (mem ← reg)"]
    pub fn vtx_x86_emit_sib_mem(
        e: *mut vtx_x86_emit_t,
        opcode: u8,
        opcode2: u8,
        reg: u8,
        base: u8,
        index: u8,
        scale: u8,
        disp: i32,
        is_load: bool,
    );
}
extern "C" {
    #[doc = " Emit mov r64, imm64 (movabs). Uses the B8+rd encoding with REX.W."]
    pub fn vtx_x86_emit_mov_imm64(e: *mut vtx_x86_emit_t, reg: u8, imm: u64);
}
extern "C" {
    #[doc = " Emit mov r/m64, imm32 (sign-extended to 64 bits).\n Uses C7 /0 encoding with REX.W."]
    pub fn vtx_x86_emit_mov_imm32(e: *mut vtx_x86_emit_t, reg: u8, imm: i32);
}
extern "C" {
    pub fn vtx_x86_emit_add_rr(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_add_ri(e: *mut vtx_x86_emit_t, dst: u8, imm: i32);
}
extern "C" {
    pub fn vtx_x86_emit_sub_rr(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_sub_ri(e: *mut vtx_x86_emit_t, dst: u8, imm: i32);
}
extern "C" {
    pub fn vtx_x86_emit_imul_rr(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_imul_ri(e: *mut vtx_x86_emit_t, dst: u8, imm: i32);
}
extern "C" {
    pub fn vtx_x86_emit_idiv_r(e: *mut vtx_x86_emit_t, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_imul_full_r(e: *mut vtx_x86_emit_t, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_shl_ri(e: *mut vtx_x86_emit_t, dst: u8, count: u8);
}
extern "C" {
    pub fn vtx_x86_emit_shl_cl(e: *mut vtx_x86_emit_t, dst: u8);
}
extern "C" {
    pub fn vtx_x86_emit_shr_ri(e: *mut vtx_x86_emit_t, dst: u8, count: u8);
}
extern "C" {
    pub fn vtx_x86_emit_shr_cl(e: *mut vtx_x86_emit_t, dst: u8);
}
extern "C" {
    pub fn vtx_x86_emit_sar_ri(e: *mut vtx_x86_emit_t, dst: u8, count: u8);
}
extern "C" {
    pub fn vtx_x86_emit_sar_cl(e: *mut vtx_x86_emit_t, dst: u8);
}
extern "C" {
    pub fn vtx_x86_emit_and_rr(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_and_ri(e: *mut vtx_x86_emit_t, dst: u8, imm: i32);
}
extern "C" {
    pub fn vtx_x86_emit_or_rr(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_or_ri(e: *mut vtx_x86_emit_t, dst: u8, imm: i32);
}
extern "C" {
    pub fn vtx_x86_emit_xor_rr(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_xor_ri(e: *mut vtx_x86_emit_t, dst: u8, imm: i32);
}
extern "C" {
    pub fn vtx_x86_emit_cmp_rr(e: *mut vtx_x86_emit_t, a: u8, b: u8);
}
extern "C" {
    pub fn vtx_x86_emit_cmp_ri(e: *mut vtx_x86_emit_t, reg: u8, imm: i32);
}
extern "C" {
    pub fn vtx_x86_emit_test_rr(e: *mut vtx_x86_emit_t, a: u8, b: u8);
}
extern "C" {
    pub fn vtx_x86_emit_test_ri(e: *mut vtx_x86_emit_t, reg: u8, imm: i32);
}
extern "C" {
    pub fn vtx_x86_emit_mov_rr(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_mov_rmem(e: *mut vtx_x86_emit_t, dst: u8, base: u8, disp: i32);
}
extern "C" {
    pub fn vtx_x86_emit_mov_memr(e: *mut vtx_x86_emit_t, base: u8, disp: i32, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_lea_rmem(e: *mut vtx_x86_emit_t, dst: u8, base: u8, disp: i32);
}
extern "C" {
    pub fn vtx_x86_emit_neg_r(e: *mut vtx_x86_emit_t, reg: u8);
}
extern "C" {
    pub fn vtx_x86_emit_not_r(e: *mut vtx_x86_emit_t, reg: u8);
}
extern "C" {
    pub fn vtx_x86_emit_cqo(e: *mut vtx_x86_emit_t);
}
extern "C" {
    pub fn vtx_x86_emit_setcc(e: *mut vtx_x86_emit_t, cond: u8, reg: u8);
}
extern "C" {
    pub fn vtx_x86_emit_cmovcc(e: *mut vtx_x86_emit_t, cond: u8, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_push_r(e: *mut vtx_x86_emit_t, reg: u8);
}
extern "C" {
    pub fn vtx_x86_emit_pop_r(e: *mut vtx_x86_emit_t, reg: u8);
}
extern "C" {
    pub fn vtx_x86_emit_jmp_rel32(e: *mut vtx_x86_emit_t, offset: i32);
}
extern "C" {
    pub fn vtx_x86_emit_jcc_rel32(e: *mut vtx_x86_emit_t, cond: u8, offset: i32);
}
extern "C" {
    pub fn vtx_x86_emit_call_rel32(e: *mut vtx_x86_emit_t, offset: i32);
}
extern "C" {
    pub fn vtx_x86_emit_ret(e: *mut vtx_x86_emit_t);
}
extern "C" {
    pub fn vtx_x86_emit_nop(e: *mut vtx_x86_emit_t);
}
extern "C" {
    #[doc = " Emit UCOMISD xmm, xmm — unordered compare scalar double.\n Sets EFLAGS for floating-point comparison."]
    pub fn vtx_x86_emit_ucomisd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    #[doc = " Emit ADDSD xmm, xmm — scalar double-precision add.\n Encoding: F2 0F 58 /r"]
    pub fn vtx_x86_emit_addsd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    #[doc = " Emit SUBSD xmm, xmm — scalar double-precision subtract.\n Encoding: F2 0F 5C /r"]
    pub fn vtx_x86_emit_subsd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    #[doc = " Emit MULSD xmm, xmm — scalar double-precision multiply.\n Encoding: F2 0F 59 /r"]
    pub fn vtx_x86_emit_mulsd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    #[doc = " Emit DIVSD xmm, xmm — scalar double-precision divide.\n Encoding: F2 0F 5E /r"]
    pub fn vtx_x86_emit_divsd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    #[doc = " Emit XORPS xmm, xmm — bitwise XOR of 128-bit operands.\n Used for float negation by XORing with a sign-bit mask.\n Encoding: 0F 57 /r"]
    pub fn vtx_x86_emit_xorps(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    #[doc = " Emit MOVSD xmm, xmm — move scalar double between XMM registers.\n Encoding: F2 0F 10 /r (load) or F2 0F 11 /r (store).\n For reg-reg move: F2 0F 10 ModR/M(mod=11)"]
    pub fn vtx_x86_emit_movsd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_addss(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_subss(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_mulss(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_divss(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_sqrtss(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_ucomiss(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_movss(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_cvtsi2sd(e: *mut vtx_x86_emit_t, dst_xmm: u8, src_gpr: u8);
}
extern "C" {
    pub fn vtx_x86_emit_cvtsd2si(e: *mut vtx_x86_emit_t, dst_gpr: u8, src_xmm: u8);
}
extern "C" {
    pub fn vtx_x86_emit_cvttsd2si(e: *mut vtx_x86_emit_t, dst_gpr: u8, src_xmm: u8);
}
extern "C" {
    pub fn vtx_x86_emit_cvtsi2ss(e: *mut vtx_x86_emit_t, dst_xmm: u8, src_gpr: u8);
}
extern "C" {
    pub fn vtx_x86_emit_cvtss2si(e: *mut vtx_x86_emit_t, dst_gpr: u8, src_xmm: u8);
}
extern "C" {
    pub fn vtx_x86_emit_cvttss2si(e: *mut vtx_x86_emit_t, dst_gpr: u8, src_xmm: u8);
}
extern "C" {
    pub fn vtx_x86_emit_movq_xmm_r64(e: *mut vtx_x86_emit_t, dst_xmm: u8, src_gpr: u8);
}
extern "C" {
    pub fn vtx_x86_emit_movq_r64_xmm(e: *mut vtx_x86_emit_t, dst_gpr: u8, src_xmm: u8);
}
extern "C" {
    pub fn vtx_x86_emit_comisd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_sqrtsd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_movsd_load(e: *mut vtx_x86_emit_t, dst_xmm: u8, base: u8, disp: i32);
}
extern "C" {
    pub fn vtx_x86_emit_movsd_store(e: *mut vtx_x86_emit_t, base: u8, disp: i32, src_xmm: u8);
}
extern "C" {
    pub fn vtx_x86_emit_bswap(e: *mut vtx_x86_emit_t, reg: u8);
}
extern "C" {
    pub fn vtx_x86_emit_bsf(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_bsr(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_popcnt(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_rol_ri(e: *mut vtx_x86_emit_t, dst: u8, count: u8);
}
extern "C" {
    pub fn vtx_x86_emit_rol_cl(e: *mut vtx_x86_emit_t, dst: u8);
}
extern "C" {
    pub fn vtx_x86_emit_ror_ri(e: *mut vtx_x86_emit_t, dst: u8, count: u8);
}
extern "C" {
    pub fn vtx_x86_emit_ror_cl(e: *mut vtx_x86_emit_t, dst: u8);
}
extern "C" {
    pub fn vtx_x86_emit_cdqe(e: *mut vtx_x86_emit_t);
}
extern "C" {
    pub fn vtx_x86_emit_div_r(e: *mut vtx_x86_emit_t, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_rdtsc(e: *mut vtx_x86_emit_t);
}
extern "C" {
    pub fn vtx_x86_emit_rdtscp(e: *mut vtx_x86_emit_t);
}
extern "C" {
    pub fn vtx_x86_emit_cmpxchg(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_xadd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_lfence(e: *mut vtx_x86_emit_t);
}
extern "C" {
    pub fn vtx_x86_emit_mfence(e: *mut vtx_x86_emit_t);
}
extern "C" {
    pub fn vtx_x86_emit_sfence(e: *mut vtx_x86_emit_t);
}
extern "C" {
    pub fn vtx_x86_emit_roundsd(e: *mut vtx_x86_emit_t, dst: u8, src: u8, mode: u8);
}
extern "C" {
    pub fn vtx_x86_emit_roundss(e: *mut vtx_x86_emit_t, dst: u8, src: u8, mode: u8);
}
extern "C" {
    pub fn vtx_x86_emit_movsd_rip(e: *mut vtx_x86_emit_t, dst_xmm: u8, double_bits: u64);
}
extern "C" {
    pub fn vtx_x86_emit_vmovapd_256(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vaddpd_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vsubpd_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vmulpd_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vdivpd_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vminpd_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vmaxpd_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vxorpd_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vandpd_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vcmppd_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8, pred: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vmovaps_256(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vaddps_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vsubps_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vmulps_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vdivps_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vmovdqa_256(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vpaddd_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vpsubd_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vpmulld_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vpxor_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vpand_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vpor_256(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vzeroupper(e: *mut vtx_x86_emit_t);
}
extern "C" {
    pub fn vtx_x86_emit_vzeroall(e: *mut vtx_x86_emit_t);
}
extern "C" {
    pub fn vtx_x86_emit_vbroadcastsd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vbroadcastss(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vperm2f128(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8, ctrl: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vinsertf128(e: *mut vtx_x86_emit_t, dst: u8, src1: u8, src2: u8, imm8: u8);
}
extern "C" {
    pub fn vtx_x86_emit_vextractf128(e: *mut vtx_x86_emit_t, dst: u8, src: u8, imm8: u8);
}
extern "C" {
    pub fn vtx_x86_emit_subpd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_divpd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_movdqa(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_movdqu(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_paddd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_psubd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_pmulld(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_pxor(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_pand(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_por(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_pcmpeqd(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_movaps(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_addps(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_mulps(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_subps(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_divps(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_minps(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_maxps(e: *mut vtx_x86_emit_t, dst: u8, src: u8);
}
extern "C" {
    pub fn vtx_x86_emit_cmpps(e: *mut vtx_x86_emit_t, dst: u8, src: u8, pred: u8);
}
extern "C" {
    #[doc = " Emit safepoint poll at a loop back-edge.\n Emits:\n   cmpq [vtx_safepoint_flag], 0   (RIP-relative, 8 bytes)\n   jne  deopt_stub                (rel32, 6 bytes)\n\n The CMP uses RIP-relative addressing to access the global\n vtx_safepoint_flag. A VTX_RELOC_RIP_REL32 external relocation is\n recorded so the displacement is patched at code install time.\n\n The JNE has its displacement set to 0 (placeholder). It is marked\n with VTX_INST_FLAG_IS_GUARD in the instruction stream and will be\n patched by the guard emission pipeline to jump to a deopt stub.\n\n @param e  Emitter context (must have relocs initialized)\n @return   0 on success, -1 on failure"]
    pub fn vtx_x86_emit_safepoint_poll(e: *mut vtx_x86_emit_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Emit a zero-cost guard page safepoint poll at a loop back-edge.\n Replaces the CMP+JCC approach with a single MOV load.\n\n When the guard page is readable (normal operation), the MOV completes\n silently — zero overhead beyond a single load instruction. When a\n safepoint is requested, the page is mprotected to PROT_NONE, causing\n the MOV to SIGSEGV. The signal handler catches the fault, processes\n the safepoint, re-arms the page, and returns.\n\n Emitted code:\n   movq rax, [rip + disp32]    ; 7 bytes (REX.W + 8B + ModR/M + disp32)\n   ; loaded value is discarded — rax is a scratch register\n\n Total: 7 bytes (vs. 14 bytes for CMP+JCC). No compare, no branch,\n no branch-prediction entry consumed.\n\n A VTX_RELOC_RIP_REL32 external relocation is recorded so the\n displacement is patched at code install time to point to the\n guard page. The special stub_id -6 is used to mark this as a\n guard page relocation (distinct from -5 which is the flag-based\n safepoint poll).\n\n @param e  Emitter context (must have relocs initialized)\n @return   0 on success, -1 on failure"]
    pub fn vtx_x86_emit_safepoint_poll_guard_page(e: *mut vtx_x86_emit_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Emit function prologue:\n   push rbp\n   mov rbp, rsp\n   sub rsp, frame_size\n   push callee-saved registers (for each bit set in callee_saved_mask)\n\n @param e                  Emitter\n @param frame_size         Frame size in bytes (locals + spills, aligned)\n @param callee_saved_mask  Bitmask of callee-saved registers to save"]
    pub fn vtx_x86_emit_prologue(
        e: *mut vtx_x86_emit_t,
        frame_size: u32,
        callee_saved_mask: u32,
        arg_count: u32,
        max_locals: u32,
        is_leaf: bool,
    );
}
extern "C" {
    #[doc = " Emit SMI constant initialization in the prologue.\n Loads R10 = VTX_NAN_BOX_HEADER and R11 = VTX_NAN_DATA_MASK once.\n Called after vtx_x86_emit_prologue() if the function uses SMI arithmetic."]
    pub fn vtx_x86_emit_smi_constants(e: *mut vtx_x86_emit_t);
}
extern "C" {
    #[doc = " Emit function epilogue:\n   pop callee-saved registers\n   mov rsp, rbp\n   pop rbp\n   ret\n is_leaf must match the value passed to vtx_x86_emit_prologue()."]
    pub fn vtx_x86_emit_epilogue(e: *mut vtx_x86_emit_t, callee_saved_mask: u32, is_leaf: bool);
}
extern "C" {
    #[doc = " Emit the entire instruction stream into the code buffer.\n Uses the register allocation result to resolve physical registers.\n\n @param emit     Emitter context\n @param stream   Instruction stream (after register allocation)\n @param result   Register allocation result\n @param arena    Arena for temporary allocations\n @return         0 on success, -1 on failure"]
    pub fn vtx_x86_emit_function(
        emit: *mut vtx_x86_emit_t,
        stream: *mut vtx_inst_stream_t,
        result: *const vtx_regalloc_result_t,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Apply peephole optimizations to the instruction stream.\n Must be called after register allocation (physical registers resolved).\n Optimizations applied:\n   - Eliminate redundant MOV reg, reg (src == dst)\n   - CMP reg, 0 → TEST reg, reg (1 byte shorter)\n   - Fold ADD/SUB with 0 into NOP\n   - Eliminate dead code (write to unused register)\n\n @param stream   Instruction stream (modified in place)\n @param result   Register allocation result\n @return         Number of instructions eliminated"]
    pub fn vtx_peephole_optimize(
        stream: *mut vtx_inst_stream_t,
        result: *const vtx_regalloc_result_t,
    ) -> u32;
}
extern "C" {
    #[doc = " Optimize branch layout in the instruction stream.\n Must be called after peephole optimization and before emission.\n Optimizations applied:\n   - Invert JCC + JMP to fall-through where possible\n   - Use short jumps (2 bytes) when target is within ±127 bytes\n   - Align loop headers to 16-byte boundaries for I-cache performance\n\n @param stream   Instruction stream (modified in place)\n @param emit     Emitter context (for position tracking)\n @param result   Register allocation result\n @return         0 on success, -1 on failure"]
    pub fn vtx_branch_optimize(
        stream: *mut vtx_inst_stream_t,
        emit: *mut vtx_x86_emit_t,
        result: *const vtx_regalloc_result_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Map VTX condition code to x86-64 condition code byte.\n Returns the x86 condition code (0-15) for JCC/SETCC/CMOVcc."]
    pub fn vtx_cond_to_x86(cond: vtx_cond_t) -> u8;
}
#[doc = " VORTEX Guard Emission for JIT-compiled Code\n\n Emits guard checks and deoptimization stubs from SoN Guard/DeoptGuard\n nodes. For each guard:\n   1. Emit a compare + conditional jump in the main code stream\n   2. If the guard fails, jump to a deopt stub\n   3. Record a side table entry (native PC, live registers, frame_state_index)\n\n Deopt stubs are emitted after the main code and perform:\n   1. Save all live registers to the frame\n   2. Load the deopt handler address\n   3. Jump to the deopt runtime"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_guard_desc_t {
    pub guard_node: vtx_nodeid_t,
    pub cond: vtx_cond_t,
    pub bytecode_pc: u32,
    pub frame_state_index: u32,
    pub type_id: u32,
    pub shape_id: u32,
    pub jcc_native_offset: u32,
    pub deopt_stub_offset: u32,
    pub is_implicit_null: bool,
    pub is_value_guard: bool,
    pub expected_value: u64,
}
impl Default for vtx_guard_desc_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_guard_desc_array_t {
    pub guards: *mut vtx_guard_desc_t,
    pub count: u32,
    pub capacity: u32,
}
impl Default for vtx_guard_desc_array_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize a guard descriptor array."]
    pub fn vtx_guard_desc_array_init(
        arr: *mut vtx_guard_desc_array_t,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Add a guard descriptor."]
    pub fn vtx_guard_desc_array_add(
        arr: *mut vtx_guard_desc_array_t,
        guard: vtx_guard_desc_t,
        arena: *mut vtx_arena_t,
    ) -> u32;
}
extern "C" {
    #[doc = " Lower guard nodes into x86-64 instructions and record side table entries.\n\n For each guard in the guard array:\n   1. Emits a compare + conditional jump into the emit buffer\n   2. Records a side table entry with the native PC, live registers,\n      and frame state index\n   3. The deopt stubs are emitted after the main code by emit_deopt_stubs\n\n @param guards      Array of guard descriptors\n @param inst_stream Instruction stream (for finding live registers at guard points)\n @param emit        x86-64 code emitter (main code section)\n @param side_table  Side table to record deopt entries\n @param arena       Arena for allocations\n @return            Number of guards lowered, or -1 on failure"]
    pub fn vtx_guard_emit_lower(
        guards: *mut vtx_guard_desc_array_t,
        inst_stream: *mut vtx_inst_stream_t,
        emit: *mut vtx_x86_emit_t,
        side_table: *mut vtx_side_table_t,
        arena: *mut vtx_arena_t,
        ra: *const vtx_regalloc_result_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Emit deopt stubs after the main code.\n\n For each guard, emits a deopt stub that:\n   1. Pushes all callee-saved registers\n   2. Stores the frame state index in RDI\n   3. Loads the deopt handler address\n   4. Jumps to the deopt runtime\n\n @param guards      Array of guard descriptors\n @param emit        x86-64 code emitter (will append stubs)\n @param side_table  Side table for recording native PCs\n @param code_start  Start address of the compiled code (for offset calculation)\n @param arena       Arena for allocations\n @return            Number of stubs emitted, or -1 on failure"]
    pub fn vtx_guard_emit_deopt_stubs(
        guards: *mut vtx_guard_desc_array_t,
        emit: *mut vtx_x86_emit_t,
        side_table: *mut vtx_side_table_t,
        code_start: *mut u8,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Patch guard conditional jumps to point to their deopt stubs.\n\n After both main code and deopt stubs are emitted, this function\n patches the 32-bit displacement in each guard's JCC instruction\n to point to the corresponding deopt stub.\n\n @param guards      Array of guard descriptors\n @param emit        x86-64 code emitter (code buffer to patch)\n @param code_start  Start of the compiled code\n @param arena       Arena for allocations\n @return            0 on success, -1 on failure"]
    pub fn vtx_guard_emit_patch(
        guards: *mut vtx_guard_desc_array_t,
        emit: *mut vtx_x86_emit_t,
        code_start: *mut u8,
        arena: *mut vtx_arena_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Set the global deopt handler function pointer.\n\n The deopt handler is called when a guard fails. It receives:\n   - RDI = frame_state_index (which FrameState to use for reconstitution)\n   - RSI = native_pc_offset (where in the compiled code the failure occurred)\n\n If no handler is set, a default stub is used that prints diagnostic\n information and calls abort().\n\n @param handler  Function pointer for the deopt handler"]
    pub fn vtx_guard_emit_set_deopt_handler(handler: *mut ::std::os::raw::c_void);
}
extern "C" {
    #[doc = " Get the current deopt handler function pointer.\n Returns NULL if no handler has been set (the default stub will be used)."]
    pub fn vtx_guard_emit_get_deopt_handler() -> *mut ::std::os::raw::c_void;
}
extern "C" {
    #[doc = " Emit a predicated guard using CMOVCC + conditional INT3.\n Used for guards with very low failure rates where branch\n misprediction penalty exceeds the cost of always-decoded deopt path.\n\n The emission strategy:\n   1. Evaluate the guard condition into a register\n   2. CMOVCC: conditionally set a flag byte to 0xCC (INT3 opcode)\n   3. The flag byte is placed right after the CMOVCC\n   4. If the condition fails, the flag becomes 0xCC → INT3 fires → deopt handler\n   5. If the condition passes, the flag remains 0x90 (NOP) → no trap\n\n @param guard       Guard descriptor\n @param code_buf    Output code buffer\n @param buf_size    Size of code buffer\n @return            Number of bytes emitted, or -1 on failure"]
    pub fn vtx_guard_emit_predicated(
        guard: *const vtx_guard_desc_t,
        code_buf: *mut u8,
        buf_size: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Emit an implicit null check — no code emitted.\n\n When the guard page / SIGSEGV mechanism is available, null checks\n can be made implicit: instead of emitting TEST reg,reg + JCC, we\n simply let the next memory load from that register trigger SIGSEGV\n if the pointer is null. The signal handler catches the fault and\n performs deoptimization.\n\n This function marks the guard as implicit_null and sets jcc_native_offset\n to UINT32_MAX (no JCC to patch). The actual \"guard\" is the subsequent\n load instruction from the checked register, which will SIGSEGV on null.\n\n The side table entry is recorded so the SIGSEGV handler can find the\n deopt metadata for this code location.\n\n Hot-path cost: 0 instructions (the load was going to happen anyway).\n Cold-path cost: SIGSEGV signal delivery + handler (~1-2 microseconds).\n\n Prerequisites:\n   - vtx_guard_page_init() must have been called (guard page available)\n   - The checked register must be used by a subsequent load instruction\n   - The load must be at an offset < VTX_NULL_PAGE_LIMIT (64KB) from null\n\n @param guard       Guard descriptor (is_implicit_null will be set to true)\n @param code_buf    Output code buffer (unused, but required for API consistency)\n @param buf_size    Size of code buffer\n @return            0 bytes emitted (always succeeds if guard != NULL)"]
    pub fn vtx_guard_emit_implicit_null(
        guard: *mut vtx_guard_desc_t,
        code_buf: *mut u8,
        buf_size: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Emit a value speculation guard — CMP + JCC for now, guard-page in future.\n\n Value speculation guards verify that a loaded value matches a previously\n observed constant. When the guard passes, all downstream uses of the\n value can be constant-folded, enabling:\n   - Dead code elimination of branches that depend on the constant\n   - Loop unrolling with known trip counts\n   - Strength reduction (e.g., multiply by constant → shifts)\n\n Current emission (CMP+JCC, same as type guard):\n   mov rax, [obj + field_offset]    ; load the field\n   cmp rax, <expected_value>         ; is it the expected constant?\n   jne deopt_stub                    ; if not, deopt\n   ; rax is now \"proven\" constant → replace all uses with <expected_value>\n\n Future emission (guard page, zero-cost):\n   mov rax, [obj + field_offset]    ; load the field\n   mov rbx, [value_check_page + rax*8] ; trap if wrong value\n   ; rax is \"proven\" to be <expected_value> → constant fold\n\n @param guard       Guard descriptor (is_value_guard must be true,\n                    expected_value must be set)\n @param code_buf    Output code buffer\n @param buf_size    Size of code buffer\n @return            Number of bytes emitted, or -1 on failure"]
    pub fn vtx_guard_emit_value_guard(
        guard: *const vtx_guard_desc_t,
        code_buf: *mut u8,
        buf_size: u32,
    ) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_pipeline_config_t {
    pub run_gvn: bool,
    pub run_sccp: bool,
    pub run_dce: bool,
    pub run_licm: bool,
    pub run_bounds_check: bool,
    pub run_pea: bool,
    pub run_inlining: bool,
    pub run_verify: bool,
    pub run_speculative: bool,
    pub run_loop_spec: bool,
    pub run_vectorize: bool,
    pub run_midtier: bool,
    pub run_block_layout: bool,
    pub run_rep_infer: bool,
    pub gvn_iterations: ::std::os::raw::c_int,
    pub sccp_iterations: ::std::os::raw::c_int,
    pub dce_iterations: ::std::os::raw::c_int,
    pub inline_size_limit: ::std::os::raw::c_int,
    pub callee_lookup: vtx_callee_lookup_fn,
    pub callee_lookup_context: *mut ::std::os::raw::c_void,
    pub type_feedback: *const vtx_type_feedback_t,
    pub shared_gbdt_model: *mut vtx_gbdt_model_t,
    pub owns_gbdt_model: bool,
    pub markov: *mut vtx_markov_t,
    pub profiler: *const vtx_profiler_t,
    pub code_cache: *mut vtx_code_cache,
    pub method_registry: *mut vtx_method_registry,
    pub method: *const vtx_method_desc_t,
    pub install_arena: *mut vtx_arena_t,
    pub orchestrator: *mut vtx_orchestrator_t,
    pub versioned_cache: *mut vtx_versioned_cache_t,
    pub deoptless_tables: *mut *mut vtx_deoptless_table_t,
    pub deoptless_table_count: u32,
    pub deoptless_table_capacity: u32,
}
impl Default for vtx_pipeline_config_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_pipeline_stats_t {
    pub gvn_nodes_merged: u32,
    pub sccp_constants_propagated: u32,
    pub dce_nodes_removed: u32,
    pub licm_nodes_hoisted: u32,
    pub bounds_checks_eliminated: u32,
    pub pea_allocs_eliminated: u32,
    pub inlining_decisions: u32,
    pub inlines_performed: u32,
    pub loops_vectorized: u32,
    pub total_pipeline_time_ns: i64,
    pub gvn_time_ns: i64,
    pub sccp_time_ns: i64,
    pub dce_time_ns: i64,
    pub licm_time_ns: i64,
    pub bounds_check_time_ns: i64,
    pub pea_time_ns: i64,
    pub inlining_time_ns: i64,
    pub loop_spec_time_ns: i64,
    pub schedule_time_ns: i64,
    pub block_layout_time_ns: i64,
    pub lowering_time_ns: i64,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_compile_result_t {
    pub success: bool,
    pub graph: *mut vtx_graph_t,
    pub schedule: *mut vtx_schedule_t,
    pub stats: vtx_pipeline_stats_t,
    pub native_code: *mut u8,
    pub native_size: u32,
    pub side_table: *mut vtx_side_table_t,
    pub reloc_table: *mut vtx_reloc_table_t,
}
impl Default for vtx_compile_result_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn vtx_pipeline_config_t1() -> vtx_pipeline_config_t;
}
extern "C" {
    pub fn vtx_pipeline_config_t1_5() -> vtx_pipeline_config_t;
}
extern "C" {
    pub fn vtx_pipeline_config_t2() -> vtx_pipeline_config_t;
}
extern "C" {
    pub fn vtx_pipeline_config_t3() -> vtx_pipeline_config_t;
}
extern "C" {
    #[doc = " Initialize the shared GBDT model on a pipeline config.\n Call this once before the first compilation to avoid creating\n a new model on every compilation. The model is reused across\n all subsequent compilations with this config.\n\n @param config  Pipeline configuration (must not be NULL)\n @return        0 on success, -1 on failure"]
    pub fn vtx_pipeline_config_init_shared_model(
        config: *mut vtx_pipeline_config_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a pipeline config's shared resources (GBDT model).\n Call this when the config is no longer needed.\n\n @param config  Pipeline configuration (must not be NULL)"]
    pub fn vtx_pipeline_config_destroy(config: *mut vtx_pipeline_config_t);
}
extern "C" {
    #[doc = " Compute heat-adapted speculation thresholds for a method.\n The hotter a method, the more aggressive the speculation:\n   - Very hot methods (E > 10M): lower inline threshold, stronger guards, more deoptless\n   - Cold methods (E < 1000): default conservative thresholds\n\n Uses logarithmic scaling to avoid extreme values.\n\n @param execution_count  Method execution count from profile\n @return                 Dynamically adapted pipeline config"]
    pub fn vtx_pipeline_config_heat_adapted(execution_count: u64) -> vtx_pipeline_config_t;
}
extern "C" {
    pub fn vtx_pipeline_run(
        graph: *mut vtx_graph_t,
        config: *const vtx_pipeline_config_t,
        arena: *mut vtx_arena_t,
        result: *mut vtx_compile_result_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_compile_result_destroy(result: *mut vtx_compile_result_t);
}
pub const vtx_decision_reason_t_VTX_DECISION_REASON_PROACTIVE: vtx_decision_reason_t = 0;
pub const vtx_decision_reason_t_VTX_DECISION_REASON_DRIFT: vtx_decision_reason_t = 1;
pub const vtx_decision_reason_t_VTX_DECISION_REASON_FDI: vtx_decision_reason_t = 2;
pub const vtx_decision_reason_t_VTX_DECISION_REASON_DEOPTLESS: vtx_decision_reason_t = 3;
pub const vtx_decision_reason_t_VTX_DECISION_REASON_DEOPT: vtx_decision_reason_t = 4;
pub const vtx_decision_reason_t_VTX_DECISION_REASON_PHASE: vtx_decision_reason_t = 5;
pub const vtx_decision_reason_t_VTX_DECISION_REASON_COUNT: vtx_decision_reason_t = 6;
pub type vtx_decision_reason_t = ::std::os::raw::c_uint;
extern "C" {
    pub fn vtx_decision_record_deopt(
        orch: *mut vtx_orchestrator_t,
        method_id: u32,
        call_site_id: u64,
        guard_id: u32,
    );
}
extern "C" {
    pub fn vtx_decision_submit_compile(
        orch: *mut vtx_orchestrator_t,
        task: *mut vtx_compile_task_t,
        reason: vtx_decision_reason_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn vtx_decision_submit_counts(orch: *const vtx_orchestrator_t, counts_out: *mut u64);
}
extern "C" {
    pub fn vtx_decision_deopt_count(orch: *const vtx_orchestrator_t) -> u64;
}
extern "C" {
    #[doc = " Merge all data from `source` into `target`. Target is modified in place.\n Source is not modified.\n\n After this call, target contains the union of both profiles."]
    pub fn vtx_profile_merge_into(
        target: *mut vtx_profile_global_t,
        source: *const vtx_profile_global_t,
    );
}
extern "C" {
    #[doc = " Merge a single method profile into the global target.\n If the method does not exist in target, it is added.\n If it exists, its data is merged.\n\n This is the function called by the persistence loader for each method."]
    pub fn vtx_profile_merge_method(
        target: *mut vtx_profile_global_t,
        source_method: *const vtx_profile_method_t,
    );
}
extern "C" {
    #[doc = " Merge a single callsite profile: union the type observations from source\n into target. If the combined type count exceeds VTX_POLY_LIMIT, target\n becomes megamorphic."]
    pub fn vtx_profile_merge_callsite(
        target: *mut vtx_callsite_profile_t,
        source: *const vtx_callsite_profile_t,
    );
}
extern "C" {
    #[doc = " Merge branch profiles: add source counts into target (saturating).\n This is equivalent to weight-averaging since the counts are additive."]
    pub fn vtx_profile_merge_branch(
        target: *mut vtx_branch_profile_t,
        source: *const vtx_branch_profile_t,
    );
}
extern "C" {
    #[doc = " Merge field access profiles: union the shape observations from source\n into target. Same rule as callsite merging."]
    pub fn vtx_profile_merge_field(
        target: *mut vtx_field_profile_t,
        source: *const vtx_field_profile_t,
    );
}
extern "C" {
    #[doc = " Merge loop profiles: sum the back-edge counts (saturating)."]
    pub fn vtx_profile_merge_loop(
        target: *mut vtx_loop_profile_t,
        source: *const vtx_loop_profile_t,
    );
}
pub const vtx_confidence_level_t_VTX_CONFIDENCE_LOW: vtx_confidence_level_t = 0;
pub const vtx_confidence_level_t_VTX_CONFIDENCE_MEDIUM: vtx_confidence_level_t = 1;
pub const vtx_confidence_level_t_VTX_CONFIDENCE_HIGH: vtx_confidence_level_t = 2;
#[doc = " Confidence classification for a single profile datum.\n\n LOW    — below the promotion gate (T1 only, no speculation)\n MEDIUM — meets the T2 gate (T2 speculation OK, T3 not yet)\n HIGH   — meets the T3/T4 gate (full speculation OK)"]
pub type vtx_confidence_level_t = ::std::os::raw::c_uint;
extern "C" {
    #[doc = " Branch-direction confidence in [0.0, 1.0].\n\n Based on the total observation count (taken + not_taken) relative to\n VTX_CONFIDENCE_THRESHOLD_BRANCH. A branch with 100 samples has confidence\n 1.0; a branch with 50 samples has confidence 0.5; a branch with 0 samples\n has confidence 0.0.\n\n @param branch  Branch profile (may be NULL → returns 0.0)\n @return        Confidence in [0.0, 1.0]"]
    pub fn vtx_confidence_branch(branch: *const vtx_branch_profile_t) -> f64;
}
extern "C" {
    #[doc = " Call-target (monomorphic) confidence in [0.0, 1.0].\n\n Based on the invocation count observed at the call site relative to\n VTX_CONFIDENCE_THRESHOLD_CALL_TARGET. A megamorphic site is always\n confidence 0.0 (we cannot speculate on a single target).\n\n @param callsite  Call-site profile (may be NULL → returns 0.0)\n @return          Confidence in [0.0, 1.0]"]
    pub fn vtx_confidence_call_target(callsite: *const vtx_callsite_profile_t) -> f64;
}
extern "C" {
    #[doc = " Type-distribution confidence in [0.0, 1.0].\n\n Based on the total observation count across all observed types at the\n call site relative to VTX_CONFIDENCE_THRESHOLD_TYPE_DIST. Megamorphic\n sites are confidence 0.0 (we cannot speculate on a stable distribution).\n\n @param callsite  Call-site profile (may be NULL → returns 0.0)\n @return          Confidence in [0.0, 1.0]"]
    pub fn vtx_confidence_type_dist(callsite: *const vtx_callsite_profile_t) -> f64;
}
extern "C" {
    #[doc = " Loop trip-count confidence in [0.0, 1.0].\n\n Based on the backedge count relative to VTX_CONFIDENCE_THRESHOLD_LOOP_TRIP.\n A trip-stable loop with sufficient samples is confidence 1.0; an unstable\n loop is confidence 0.0.\n\n @param loop  Loop profile (may be NULL → returns 0.0)\n @return      Confidence in [0.0, 1.0]"]
    pub fn vtx_confidence_loop_trip(loop_: *const vtx_loop_profile_t) -> f64;
}
extern "C" {
    #[doc = " Field-shape confidence in [0.0, 1.0].\n\n Based on the observation count at the field site relative to\n VTX_CONFIDENCE_THRESHOLD_FIELD_SHAPE. Megamorphic sites are confidence 0.0.\n\n @param field  Field-access profile (may be NULL → returns 0.0)\n @return       Confidence in [0.0, 1.0]"]
    pub fn vtx_confidence_field_shape(field: *const vtx_field_profile_t) -> f64;
}
extern "C" {
    #[doc = " Aggregate confidence for a single method.\n\n The aggregate is the MINIMUM of:\n   - branch confidence averaged across all profiled branches (weighted\n     by sample count, so a branch with 0 samples doesn't drag the average\n     down)\n   - call-site type-distribution confidence (same weighting)\n   - loop trip-count confidence\n   - field-shape confidence\n\n The minimum (not the mean) is used because speculation is only as safe\n as its weakest link: if any one feature is low-confidence, the whole\n method's speculation is low-confidence.\n\n @param method  Method profile (may be NULL → returns 0.0)\n @return        Aggregate confidence in [0.0, 1.0]"]
    pub fn vtx_confidence_method(method: *const vtx_profile_method_t) -> f64;
}
extern "C" {
    #[doc = " Classify a confidence value into a tier-promotion level.\n\n   < VTX_PROMOTION_CONFIDENCE_T2 → LOW    (T1 only)\n   < VTX_PROMOTION_CONFIDENCE_T3 → MEDIUM (T2 OK)\n   else                          → HIGH   (T3/T4 OK)\n\n @param confidence  Confidence in [0.0, 1.0]\n @return            Classification"]
    pub fn vtx_confidence_classify(confidence: f64) -> vtx_confidence_level_t;
}
extern "C" {
    #[doc = " Check whether a method is eligible for promotion to a given tier,\n considering BOTH heat and confidence.\n\n   tier 1 (T1)  — always eligible (T1 is non-speculative)\n   tier 2 (T2)  — hot AND confidence >= VTX_PROMOTION_CONFIDENCE_T2\n   tier 3 (T3)  — hot AND confidence >= VTX_PROMOTION_CONFIDENCE_T3\n   tier 4 (T4)  — hot AND confidence >= VTX_PROMOTION_CONFIDENCE_T4\n\n @param method     Method profile\n @param hot_thresh Heat threshold (invocation count) — caller passes the\n                   tier's own heat threshold\n @param tier       Target tier (1..4)\n @return           true if eligible for promotion"]
    pub fn vtx_confidence_eligible_for_tier(
        method: *const vtx_profile_method_t,
        hot_thresh: u64,
        tier: u32,
    ) -> bool;
}
extern "C" {
    #[doc = " Probe VORTEX_DETERMINISTIC at startup and cache the result.\n\n This is called once during JIT initialization (vortex_main). Subsequent\n calls to vtx_deterministic_enabled() return the cached value without\n re-reading the environment.\n\n The env var is checked as:\n   VORTEX_DETERMINISTIC=1   → enabled\n   VORTEX_DETERMINISTIC=0   → disabled (explicit)\n   VORTEX_DETERMINISTIC=    → disabled (empty)\n   VORTEX_DETERMINISTIC unset → disabled\n\n Any other value (e.g. \"true\", \"yes\") is treated as enabled for\n convenience — only \"0\" and \"\" explicitly disable."]
    pub fn vtx_deterministic_init();
}
extern "C" {
    #[doc = " Returns true if deterministic mode is enabled.\n\n Callers should consult this before making any decision that could\n introduce nondeterminism:\n   - Threadpool size selection\n   - Orchestrator sleep interval\n   - Adaptive guard decay rate\n   - Profile persistence enable/disable\n   - Compilation priority tie-breaking"]
    pub fn vtx_deterministic_enabled() -> bool;
}
extern "C" {
    #[doc = " Returns the deterministic-mode threadpool size (1 if enabled, 0 otherwise).\n\n Use this when sizing the compilation threadpool:\n   uint32_t nthreads = vtx_deterministic_threads();\n   if (nthreads == 0) nthreads = VORTEX_COMPILE_THREADS;  // default"]
    pub fn vtx_deterministic_threads() -> u32;
}
extern "C" {
    #[doc = " Returns the deterministic-mode orchestrator check interval in milliseconds.\n\n When deterministic mode is enabled, this is a fixed 100ms (no jitter).\n When disabled, returns 0 (use the default VTX_ORCHESTRATOR_CHECK_INTERVAL_MS)."]
    pub fn vtx_deterministic_check_interval_ms() -> u32;
}
extern "C" {
    #[doc = " Returns true if profile persistence should be disabled.\n\n In deterministic mode, we disable profile load/save so that each run\n starts from a clean slate and produces identical compilation decisions."]
    pub fn vtx_deterministic_disable_persistence() -> bool;
}
extern "C" {
    #[doc = " Returns true if adaptive guard EWMA decay should be frozen.\n\n In deterministic mode, time-based decay introduces nondeterminism because\n it depends on wall-clock time. Freezing the EWMA means guards either fire\n or don't based purely on observed failure counts, which is reproducible."]
    pub fn vtx_deterministic_freeze_guard_ewma() -> bool;
}
extern "C" {
    #[doc = " Build the filename for a specific phase's profile.\n\n Format: <dir>/<hash_hex>.<phase_label>.prof\n   where phase_label is \"default\" for VTX_PHASE_NONE, else the decimal\n   phase ID.\n\n @param dir         Profile directory (NUL-terminated)\n @param hash_hex    Bytecode hash as 32-char hex string (NUL-terminated)\n @param phase_id    Phase ID (VTX_PHASE_NONE for default)\n @param out         Output buffer\n @param out_size    Size of output buffer (recommended: 600+)\n @return            0 on success, -1 on buffer overflow"]
    pub fn vtx_phase_partition_filename(
        dir: *const ::std::os::raw::c_char,
        hash_hex: *const ::std::os::raw::c_char,
        phase_id: u32,
        out: *mut ::std::os::raw::c_char,
        out_size: usize,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Save all phases' profiles to a directory.\n\n For each valid phase entry in `part`, saves its profile to:\n   <dir>/<hash_hex>.<phase_label>.prof\n\n The bytecode hash is included in each file's header so that a stale\n profile from a different bytecode version is automatically rejected\n on load.\n\n @param part         Partition manager\n @param dir          Profile directory (must exist)\n @param hash_hex     Bytecode hash as 32-char hex string\n @param bytecode_hash Raw 32-byte bytecode hash (passed to vtx_profile_save)\n @return             Number of phases saved, or -1 on error"]
    pub fn vtx_phase_partition_save_all(
        part: *mut vtx_phase_partition_t,
        dir: *const ::std::os::raw::c_char,
        hash_hex: *const ::std::os::raw::c_char,
        bytecode_hash: *const u8,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Load all phase profiles from a directory.\n\n Scans the directory for files matching <hash_hex>.*.prof, parses each\n one, and adds the corresponding phase entry to `part`. The active\n phase is set to the default (VTX_PHASE_NONE) after loading.\n\n Files that fail to load (bad magic, version mismatch, CRC failure,\n hash mismatch) are silently skipped.\n\n @param part           Partition manager (must be initialized)\n @param dir            Profile directory\n @param hash_hex       Bytecode hash as 32-char hex string\n @param expected_hash  Raw 32-byte bytecode hash for version gating\n @return               Number of phases loaded, or -1 on error"]
    pub fn vtx_phase_partition_load_all(
        part: *mut vtx_phase_partition_t,
        dir: *const ::std::os::raw::c_char,
        hash_hex: *const ::std::os::raw::c_char,
        expected_hash: *const u8,
    ) -> ::std::os::raw::c_int;
}
#[doc = " Metadata for a single run's profile.\n\n This is what gets stored alongside each profile snapshot in the\n ensemble. The quality score is derived from these fields."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_ensemble_run_meta_t {
    pub sample_count: u64,
    pub deopt_count: u64,
    pub deopt_rate: f64,
    pub runtime_duration_s: f64,
    pub timestamp_ns: u64,
    pub quality: f64,
    pub demoted: bool,
}
#[doc = " A single entry in the ensemble: a profile snapshot + its metadata."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_ensemble_entry_t {
    pub profile: vtx_profile_global_t,
    pub meta: vtx_ensemble_run_meta_t,
    pub valid: bool,
}
impl Default for vtx_ensemble_entry_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Ensemble profile manager.\n\n Stores the last K runs and computes a robust aggregate. The aggregate\n is stored in `working_profile` — this is what the JIT reads from.\n\n The `previous_aggregate` is kept so that rollback can restore it."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_ensemble_t {
    pub runs: [vtx_ensemble_entry_t; 5usize],
    pub run_count: u32,
    pub next_slot: u32,
    pub working_profile: *mut vtx_profile_global_t,
    pub previous_aggregate: *mut vtx_profile_global_t,
    pub owned_working: *mut vtx_profile_global_t,
    pub owned_previous: *mut vtx_profile_global_t,
    pub pending_validation: bool,
    pub validation_start_ns: u64,
    pub total_aggregates_computed: u64,
    pub total_rollbacks: u64,
    pub total_demotions: u64,
}
impl Default for vtx_ensemble_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the ensemble manager.\n\n Does NOT allocate the working profile — that happens on the first\n call to compute_aggregate().\n\n Returns 0 on success, -1 on failure."]
    pub fn vtx_ensemble_init(ens: *mut vtx_ensemble_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the ensemble and free all owned profiles."]
    pub fn vtx_ensemble_destroy(ens: *mut vtx_ensemble_t);
}
extern "C" {
    #[doc = " Add a completed run's profile to the ensemble.\n\n The run's profile is COPIED into the ensemble (the caller retains\n ownership of the original). The metadata is stored alongside it.\n\n If the ensemble is full (K runs), the OLDEST run is evicted (FIFO).\n\n After adding, the run's quality score is computed automatically.\n Runs below the quality threshold are marked as demoted and excluded\n from future aggregates.\n\n @param ens       Ensemble manager\n @param profile   The run's profile data (copied)\n @param meta      Run metadata (quality field is computed internally)\n @return          0 on success, -1 on failure"]
    pub fn vtx_ensemble_add_run(
        ens: *mut vtx_ensemble_t,
        profile: *const vtx_profile_global_t,
        meta: vtx_ensemble_run_meta_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Compute the quality score for a run given its metadata.\n\n   quality = (sample_count / MIN_SAMPLES) * (1.0 - deopt_rate) * (duration / MIN_DURATION)\n   clamped to [0, 1]\n\n A run with 1000+ samples, 0% deopt rate, and 1+ second duration has\n quality 1.0. A run with 100 samples, 50% deopt rate, and 0.5s duration\n has quality = 0.1 * 0.5 * 0.5 = 0.025 — demoted.\n\n @param meta  Run metadata (quality field is updated)"]
    pub fn vtx_ensemble_compute_quality(meta: *mut vtx_ensemble_run_meta_t);
}
extern "C" {
    #[doc = " Check if a run is demoted (quality below threshold)."]
    pub fn vtx_ensemble_run_is_demoted(meta: *const vtx_ensemble_run_meta_t) -> bool;
}
extern "C" {
    #[doc = " Compute the robust aggregate from the non-demoted runs.\n\n The aggregate is stored in the ensemble's working_profile (allocated\n if needed). The previous working_profile is moved to\n previous_aggregate for potential rollback.\n\n Aggregate rules:\n   - Branch probabilities: median P(taken) across non-demoted runs\n   - Type distributions: mode — types seen in >50% of runs\n   - Shape sets: intersection — shapes seen in ALL non-demoted runs\n   - Loop backedge counts: median across runs\n   - Invocation counts: median across runs\n\n If fewer than VTX_ENSEMBLE_MIN_RUNS non-demoted runs exist, the\n aggregate is just the most recent non-demoted run (no robustness\n benefit, but still usable).\n\n After computing, the working_profile is marked as \"pending\n validation.\" Call vtx_ensemble_validate() after\n VTX_ENSEMBLE_VALIDATION_WINDOW_S seconds to confirm it.\n\n @param ens  Ensemble manager\n @return     The working profile, or NULL on failure"]
    pub fn vtx_ensemble_compute_aggregate(ens: *mut vtx_ensemble_t) -> *mut vtx_profile_global_t;
}
extern "C" {
    #[doc = " Get the current working profile (the aggregate the JIT should use).\n Returns NULL if no aggregate has been computed yet."]
    pub fn vtx_ensemble_get_working(ens: *mut vtx_ensemble_t) -> *mut vtx_profile_global_t;
}
extern "C" {
    #[doc = " Validate the current working profile.\n\n Called after VTX_ENSEMBLE_VALIDATION_WINDOW_S seconds of use. If the\n observed deopt rate is below the rollback threshold, the working\n profile is marked as validated. If it exceeds the threshold, the\n ensemble rolls back to the previous validated aggregate.\n\n @param ens              Ensemble manager\n @param observed_deopt_rate  Deopt rate observed during the validation window\n @return                 true if validated, false if rolled back"]
    pub fn vtx_ensemble_validate(ens: *mut vtx_ensemble_t, observed_deopt_rate: f64) -> bool;
}
extern "C" {
    #[doc = " Force an immediate rollback to the previous validated aggregate.\n\n Called when the system detects that the current aggregate is bad\n (e.g., a burst of deopts before the validation window expires).\n\n @param ens  Ensemble manager\n @return     true if rolled back, false if no previous aggregate exists"]
    pub fn vtx_ensemble_rollback(ens: *mut vtx_ensemble_t) -> bool;
}
extern "C" {
    #[doc = " Check if the current working profile is pending validation."]
    pub fn vtx_ensemble_is_pending_validation(ens: *const vtx_ensemble_t) -> bool;
}
extern "C" {
    #[doc = " Get ensemble statistics.\n\n @param ens                    Ensemble manager\n @param run_count              Out: number of runs stored\n @param demoted_count          Out: number of demoted runs\n @param total_aggregates       Out: total aggregates computed\n @param total_rollbacks        Out: total rollbacks performed\n @param total_demotions        Out: total runs demoted"]
    pub fn vtx_ensemble_stats(
        ens: *const vtx_ensemble_t,
        run_count: *mut u32,
        demoted_count: *mut u32,
        total_aggregates: *mut u64,
        total_rollbacks: *mut u64,
        total_demotions: *mut u64,
    );
}
pub const vtx_size_bin_t_VTX_SIZE_BIN_EMPTY: vtx_size_bin_t = 0;
pub const vtx_size_bin_t_VTX_SIZE_BIN_ONE: vtx_size_bin_t = 1;
pub const vtx_size_bin_t_VTX_SIZE_BIN_TINY: vtx_size_bin_t = 2;
pub const vtx_size_bin_t_VTX_SIZE_BIN_SMALL: vtx_size_bin_t = 3;
pub const vtx_size_bin_t_VTX_SIZE_BIN_MEDIUM: vtx_size_bin_t = 4;
pub const vtx_size_bin_t_VTX_SIZE_BIN_LARGE: vtx_size_bin_t = 5;
pub const vtx_size_bin_t_VTX_SIZE_BIN_COUNT: vtx_size_bin_t = 6;
#[doc = " Coarse bins for collection sizes and loop trip counts.\n\n The bins are chosen so that optimization decisions don't change within\n a bin:\n   - BIN_EMPTY (0):   no elements → skip the loop entirely\n   - BIN_ONE (1):     exactly 1 → no loop, direct access\n   - BIN_TINY (2):    2-4 → unroll fully\n   - BIN_SMALL (3):   5-16 → unroll partially\n   - BIN_MEDIUM (4):  17-256 → vectorize\n   - BIN_LARGE (5):   257+ → don't unroll, streaming\n\n 6 bins captures >99% of real-world workloads without shape explosion."]
pub type vtx_size_bin_t = ::std::os::raw::c_uint;
extern "C" {
    #[doc = " Bin a collection size or loop trip count.\n\n @param count  The size/trip count to bin\n @return       The bin enum value"]
    pub fn vtx_size_bin(count: u64) -> vtx_size_bin_t;
}
extern "C" {
    #[doc = " Get a human-readable name for a size bin."]
    pub fn vtx_size_bin_name(bin: vtx_size_bin_t) -> *const ::std::os::raw::c_char;
}
#[doc = " A 64-bit input shape signature.\n\n VTX_INPUT_SHAPE_DEFAULT is the \"no shape\" / \"shapeless\" value — used\n for methods that haven't been shape-profiled yet, or for methods where\n shape-keying is disabled."]
pub type vtx_input_shape_t = u64;
extern "C" {
    #[doc = " Compute an input shape signature from the observed input characteristics.\n\n @param arg_type_fingerprint   XOR of argument type IDs (8 bits used)\n @param receiver_type_fingerprint  XOR of receiver type IDs (8 bits used)\n @param dominant_size_bin      Dominant collection size bin (0-5)\n @param dominant_trip_bin      Dominant loop trip count bin (0-5)\n @param call_site_count        Number of distinct call sites (8 bits used)\n @param field_shape_fingerprint  XOR of field shape IDs (8 bits used)\n @return                       64-bit shape signature"]
    pub fn vtx_input_shape_make(
        arg_type_fingerprint: u8,
        receiver_type_fingerprint: u8,
        dominant_size_bin: vtx_size_bin_t,
        dominant_trip_bin: vtx_size_bin_t,
        call_site_count: u8,
        field_shape_fingerprint: u8,
    ) -> vtx_input_shape_t;
}
extern "C" {
    #[doc = " Check if two input shapes are equivalent (same signature)."]
    pub fn vtx_input_shape_equals(a: vtx_input_shape_t, b: vtx_input_shape_t) -> bool;
}
extern "C" {
    #[doc = " Decode the dominant size bin from a shape signature."]
    pub fn vtx_input_shape_size_bin(shape: vtx_input_shape_t) -> vtx_size_bin_t;
}
extern "C" {
    #[doc = " Decode the dominant trip count bin from a shape signature."]
    pub fn vtx_input_shape_trip_bin(shape: vtx_input_shape_t) -> vtx_size_bin_t;
}
#[doc = " A per-shape profile entry: one method's profile data for one input shape.\n\n This wraps vtx_profile_method_t with shape-specific metadata. The\n underlying profile data (branches, call sites, loops, fields) is\n stored in the embedded vtx_profile_method_t."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_shape_profile_entry_t {
    pub shape: vtx_input_shape_t,
    pub method: vtx_profile_method_t,
    pub sample_count: u64,
    pub first_seen_ns: u64,
    pub last_seen_ns: u64,
    pub valid: bool,
}
impl Default for vtx_shape_profile_entry_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Per-method input-shape-keyed profile table.\n\n Holds up to VTX_INPUT_SHAPE_MAX_PER_METHOD shape-specific profile\n entries. When a new shape is observed and the table is full, the\n least-recently-used shape is evicted (its data is merged into the\n default shape).\n\n The table also maintains a \"default\" entry (shape == VTX_INPUT_SHAPE_DEFAULT)\n for observations that don't match any tracked shape, or for methods\n where shape-keying is disabled."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_input_shape_table_t {
    pub method_id: u32,
    pub entries: [vtx_shape_profile_entry_t; 8usize],
    pub entry_count: u32,
    pub total_observations: u64,
    pub shape_transitions: u64,
    pub shape_evictions: u64,
}
impl Default for vtx_input_shape_table_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize a shape-keyed profile table for a method.\n\n Creates a default-shape entry (VTX_INPUT_SHAPE_DEFAULT) so that\n observations can be recorded even before shape-keying kicks in.\n\n @param table      Table to initialize\n @param method_id  Method ID this table is for\n @return           0 on success, -1 on failure"]
    pub fn vtx_input_shape_table_init(
        table: *mut vtx_input_shape_table_t,
        method_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a shape-keyed profile table and free all per-shape profiles."]
    pub fn vtx_input_shape_table_destroy(table: *mut vtx_input_shape_table_t);
}
extern "C" {
    #[doc = " Get or create the profile entry for a specific input shape.\n\n If the shape doesn't exist in the table:\n   - If the table is full, evict the LRU shape (merge into default)\n   - Create a new entry for the requested shape\n\n Returns a pointer to the shape's profile method, or NULL on failure.\n\n @param table  Shape table\n @param shape  Input shape signature\n @param now_ns Current monotonic time (0 to use internal clock)\n @return       Pointer to the shape's vtx_profile_method_t, or NULL"]
    pub fn vtx_input_shape_table_get_or_create(
        table: *mut vtx_input_shape_table_t,
        shape: vtx_input_shape_t,
        now_ns: u64,
    ) -> *mut vtx_profile_method_t;
}
extern "C" {
    #[doc = " Get the profile entry for the default shape (VTX_INPUT_SHAPE_DEFAULT).\n\n This is the \"catch-all\" shape for methods that haven't been shape-\n profiled, or for observations that don't match any tracked shape."]
    pub fn vtx_input_shape_table_get_default(
        table: *mut vtx_input_shape_table_t,
    ) -> *mut vtx_profile_method_t;
}
extern "C" {
    #[doc = " Get the profile entry for a specific shape, or NULL if it doesn't exist.\n\n Does NOT create a new entry — use get_or_create for that."]
    pub fn vtx_input_shape_table_get(
        table: *mut vtx_input_shape_table_t,
        shape: vtx_input_shape_t,
    ) -> *mut vtx_profile_method_t;
}
extern "C" {
    #[doc = " Record an observation of a specific input shape.\n\n Updates the sample count and last_seen timestamp. Called by the\n interpreter when it detects a shape transition.\n\n @param table  Shape table\n @param shape  Input shape that was observed\n @param now_ns Current monotonic time (0 to use internal clock)"]
    pub fn vtx_input_shape_table_record_observation(
        table: *mut vtx_input_shape_table_t,
        shape: vtx_input_shape_t,
        now_ns: u64,
    );
}
extern "C" {
    #[doc = " Number of distinct shapes tracked (including the default shape)."]
    pub fn vtx_input_shape_table_shape_count(table: *const vtx_input_shape_table_t) -> u32;
}
extern "C" {
    #[doc = " Get the dominant (most-observed) input shape for a method.\n\n Returns VTX_INPUT_SHAPE_DEFAULT if the table is empty or all shapes\n have equal sample counts.\n\n @param table  Shape table\n @return       The dominant shape signature"]
    pub fn vtx_input_shape_table_dominant_shape(
        table: *const vtx_input_shape_table_t,
    ) -> vtx_input_shape_t;
}
extern "C" {
    #[doc = " Check if a method has multiple distinct input shapes that would\n benefit from multi-version compilation.\n\n Returns true if there are 2+ shapes with sample_count above\n VTX_INPUT_SHAPE_MIN_SAMPLES_FOR_MULTI_VERSION."]
    pub fn vtx_input_shape_table_needs_multi_version(table: *const vtx_input_shape_table_t)
        -> bool;
}
extern "C" {
    #[doc = " Get shape table statistics.\n\n @param table                Shape table\n @param shape_count          Out: number of distinct shapes\n @param total_observations   Out: total observations across all shapes\n @param transitions          Out: shape transitions\n @param evictions            Out: LRU evictions\n @param dominant_shape       Out: dominant shape signature"]
    pub fn vtx_input_shape_table_stats(
        table: *const vtx_input_shape_table_t,
        shape_count: *mut u32,
        total_observations: *mut u64,
        transitions: *mut u64,
        evictions: *mut u64,
        dominant_shape: *mut vtx_input_shape_t,
    );
}
#[doc = " Global manager holding per-method shape tables.\n\n This sits above vtx_profile_global_t. The orchestrator queries this\n manager to get the shape-specific profile for a method when making\n compilation decisions."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_input_shape_manager_t {
    pub tables: *mut *mut vtx_input_shape_table_t,
    pub table_count: u32,
    pub table_capacity: u32,
    pub total_shape_observations: u64,
    pub total_multi_version_methods: u64,
}
impl Default for vtx_input_shape_manager_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the global shape manager."]
    pub fn vtx_input_shape_manager_init(
        mgr: *mut vtx_input_shape_manager_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the global shape manager and all per-method tables."]
    pub fn vtx_input_shape_manager_destroy(mgr: *mut vtx_input_shape_manager_t);
}
extern "C" {
    #[doc = " Get or create the shape table for a method.\n\n @param mgr        Shape manager\n @param method_id  Method ID\n @return           Pointer to the method's shape table, or NULL on failure"]
    pub fn vtx_input_shape_manager_get_or_create(
        mgr: *mut vtx_input_shape_manager_t,
        method_id: u32,
    ) -> *mut vtx_input_shape_table_t;
}
extern "C" {
    #[doc = " Get the shape table for a method, or NULL if it doesn't exist."]
    pub fn vtx_input_shape_manager_get(
        mgr: *mut vtx_input_shape_manager_t,
        method_id: u32,
    ) -> *mut vtx_input_shape_table_t;
}
extern "C" {
    #[doc = " Get the shape-specific profile for a method + shape combination.\n\n This is the primary query for the JIT: \"give me the profile data for\n method M when called with input shape S\". Returns the default shape's\n profile if the specific shape doesn't exist.\n\n @param mgr        Shape manager\n @param method_id  Method ID\n @param shape      Input shape\n @return           Pointer to the shape's profile method, or NULL"]
    pub fn vtx_input_shape_manager_get_profile(
        mgr: *mut vtx_input_shape_manager_t,
        method_id: u32,
        shape: vtx_input_shape_t,
    ) -> *mut vtx_profile_method_t;
}
extern "C" {
    #[doc = " Get manager statistics."]
    pub fn vtx_input_shape_manager_stats(
        mgr: *const vtx_input_shape_manager_t,
        total_observations: *mut u64,
        multi_version_methods: *mut u64,
        table_count: *mut u32,
    );
}
#[doc = " A single (shape → compiled_code) mapping.\n\n The compiled_code pointer is opaque — the dispatch table doesn't know\n the details of the compiled code, it just stores the entry point."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_shape_version_t {
    pub shape: vtx_input_shape_t,
    pub compiled_code: *mut ::std::os::raw::c_void,
    pub code_metadata: *mut ::std::os::raw::c_void,
    pub compile_time_ns: u64,
    pub call_count: u64,
    pub valid: bool,
}
impl Default for vtx_shape_version_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Per-method shape dispatch table.\n\n Holds up to VTX_SHAPE_DISPATCH_MAX_VERSIONS shape-specific compiled\n versions. The first entry (index 0) is always the \"default\" version\n (shape == VTX_INPUT_SHAPE_DEFAULT) — the fallback when no shape-\n specific version matches."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_shape_dispatch_t {
    pub method_id: u32,
    pub versions: [vtx_shape_version_t; 8usize],
    pub version_count: u32,
    pub mutex: pthread_mutex_t,
}
impl Default for vtx_shape_dispatch_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Global shape dispatch manager.\n\n Holds per-method dispatch tables. The interpreter queries this at\n call time to find the right compiled version for the current input shape."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vtx_shape_dispatch_mgr_t {
    pub tables: *mut *mut vtx_shape_dispatch_t,
    pub table_count: u32,
    pub table_capacity: u32,
    pub global_mutex: pthread_mutex_t,
    pub total_dispatches: u64,
    pub total_default_fallbacks: u64,
    pub total_versions_compiled: u64,
}
impl Default for vtx_shape_dispatch_mgr_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Initialize the global shape dispatch manager."]
    pub fn vtx_shape_dispatch_mgr_init(mgr: *mut vtx_shape_dispatch_mgr_t)
        -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy the global shape dispatch manager."]
    pub fn vtx_shape_dispatch_mgr_destroy(mgr: *mut vtx_shape_dispatch_mgr_t);
}
extern "C" {
    #[doc = " Install a shape-specific compiled version for a method.\n\n Called by the JIT compiler after compiling a version specialized for\n a particular input shape. If the table is full, the LRU shape-version\n is evicted.\n\n @param mgr            Dispatch manager\n @param method_id      Method ID\n @param shape          Input shape this version is specialized for\n @param compiled_code  Entry point of the compiled code\n @param code_metadata  Optional metadata (may be NULL)\n @return               0 on success, -1 on failure"]
    pub fn vtx_shape_dispatch_install(
        mgr: *mut vtx_shape_dispatch_mgr_t,
        method_id: u32,
        shape: vtx_input_shape_t,
        compiled_code: *mut ::std::os::raw::c_void,
        code_metadata: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Install the default (shapeless) compiled version for a method.\n\n This is the fallback version used when no shape-specific version\n matches. Every method that participates in shape dispatch must have\n a default version installed.\n\n @param mgr            Dispatch manager\n @param method_id      Method ID\n @param compiled_code  Entry point of the compiled code\n @param code_metadata  Optional metadata (may be NULL)\n @return               0 on success, -1 on failure"]
    pub fn vtx_shape_dispatch_install_default(
        mgr: *mut vtx_shape_dispatch_mgr_t,
        method_id: u32,
        compiled_code: *mut ::std::os::raw::c_void,
        code_metadata: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Look up the compiled version for a method + input shape.\n\n This is the hot-path call-time query. It's lock-free: the caller\n reads the versions array without acquiring the mutex. Writes\n (installs) use atomic swaps to ensure readers never see a torn\n pointer.\n\n If a shape-specific version exists, it's returned. Otherwise, the\n default version is returned. If no default exists either, NULL is\n returned (the caller should use the interpreter).\n\n @param mgr        Dispatch manager\n @param method_id  Method ID\n @param shape      Current input shape\n @return           Compiled code entry point, or NULL"]
    pub fn vtx_shape_dispatch_lookup(
        mgr: *mut vtx_shape_dispatch_mgr_t,
        method_id: u32,
        shape: vtx_input_shape_t,
    ) -> *mut ::std::os::raw::c_void;
}
extern "C" {
    #[doc = " Record a dispatch (for statistics).\n\n Called by the interpreter after a successful lookup to track whether\n the shape-specific version or the default was used.\n\n @param mgr              Dispatch manager\n @param shape_specific   true if a shape-specific version was used,\n                         false if the default was used"]
    pub fn vtx_shape_dispatch_record(mgr: *mut vtx_shape_dispatch_mgr_t, shape_specific: bool);
}
extern "C" {
    #[doc = " Check if a method has multiple shape-specific versions installed.\n\n Returns the number of shape-specific versions (excluding the default).\n If >0, the method benefits from shape-keyed dispatch."]
    pub fn vtx_shape_dispatch_version_count(
        mgr: *mut vtx_shape_dispatch_mgr_t,
        method_id: u32,
    ) -> u32;
}
extern "C" {
    #[doc = " Get the dispatch table for a method (for introspection).\n Returns NULL if the method has no dispatch table."]
    pub fn vtx_shape_dispatch_get_table(
        mgr: *mut vtx_shape_dispatch_mgr_t,
        method_id: u32,
    ) -> *mut vtx_shape_dispatch_t;
}
extern "C" {
    #[doc = " Get dispatch statistics.\n\n @param mgr                    Dispatch manager\n @param total_dispatches       Out: total shape-specific calls\n @param total_default_fallbacks Out: calls that fell back to default\n @param total_versions_compiled Out: shape-specific versions compiled\n @param table_count            Out: number of methods with dispatch tables"]
    pub fn vtx_shape_dispatch_stats(
        mgr: *const vtx_shape_dispatch_mgr_t,
        total_dispatches: *mut u64,
        total_default_fallbacks: *mut u64,
        total_versions_compiled: *mut u64,
        table_count: *mut u32,
    );
}
pub const vtx_patch_entry_type_t_VTX_PATCH_METHOD_SNAPSHOT: vtx_patch_entry_type_t = 1;
pub const vtx_patch_entry_type_t_VTX_PATCH_BRANCH_UPDATE: vtx_patch_entry_type_t = 2;
pub const vtx_patch_entry_type_t_VTX_PATCH_CALLSITE_UPDATE: vtx_patch_entry_type_t = 3;
pub const vtx_patch_entry_type_t_VTX_PATCH_LOOP_UPDATE: vtx_patch_entry_type_t = 4;
pub const vtx_patch_entry_type_t_VTX_PATCH_FIELD_UPDATE: vtx_patch_entry_type_t = 5;
pub const vtx_patch_entry_type_t_VTX_PATCH_INVOCATION_COUNT: vtx_patch_entry_type_t = 6;
pub const vtx_patch_entry_type_t_VTX_PATCH_COMPACTION_MARKER: vtx_patch_entry_type_t = 7;
#[doc = " Entry types."]
pub type vtx_patch_entry_type_t = ::std::os::raw::c_uint;
#[doc = " Append-only patch log handle.\n\n The log is opened for appending (O_APPEND) so writes are atomic at\n the OS level. Multiple processes can't safely share a log (use the\n profile directory's per-hash files)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_patch_log_t {
    pub fd: ::std::os::raw::c_int,
    pub filename: [::std::os::raw::c_char; 512usize],
    pub entry_count: u32,
    pub bytes_written: u64,
    pub writable: bool,
}
impl Default for vtx_patch_log_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Open a patch log for appending (writing).\n\n Creates the file if it doesn't exist, with 0600 permissions. If the\n file exists, validates the header (magic, version, bytecode hash).\n If the header is invalid, the file is truncated and re-created.\n\n @param log           Log handle (caller allocates)\n @param filename      Path to the .vpl file\n @param bytecode_hash SHA-256 hash of the bytecode (for version gating)\n @return              0 on success, -1 on failure"]
    pub fn vtx_patch_log_open(
        log: *mut vtx_patch_log_t,
        filename: *const ::std::os::raw::c_char,
        bytecode_hash: *const u8,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Open a patch log for reading (replay).\n\n Validates the header. The caller then calls vtx_patch_log_replay()\n to apply the deltas to a profile.\n\n @param log           Log handle (caller allocates)\n @param filename      Path to the .vpl file\n @param expected_hash Expected bytecode hash (NULL to skip check)\n @return              0 on success, -1 on failure"]
    pub fn vtx_patch_log_open_read(
        log: *mut vtx_patch_log_t,
        filename: *const ::std::os::raw::c_char,
        expected_hash: *const u8,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Close the patch log."]
    pub fn vtx_patch_log_close(log: *mut vtx_patch_log_t);
}
extern "C" {
    #[doc = " Append a full method snapshot to the log.\n\n This is the \"compaction\" entry — it captures the complete current\n state of a method's profile. Used during background compaction and\n as the initial entry when saving a profile for the first time.\n\n @param log     Log handle (must be open for writing)\n @param method  Method profile to snapshot\n @return        0 on success, -1 on failure"]
    pub fn vtx_patch_log_append_snapshot(
        log: *mut vtx_patch_log_t,
        method: *const vtx_profile_method_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Append a branch update delta.\n\n @param log         Log handle\n @param method_id   Method ID\n @param bytecode_pc Branch bytecode PC\n @param taken       Taken count\n @param not_taken   Not-taken count\n @return            0 on success, -1 on failure"]
    pub fn vtx_patch_log_append_branch(
        log: *mut vtx_patch_log_t,
        method_id: u32,
        bytecode_pc: u32,
        taken: u64,
        not_taken: u64,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Append a callsite type update delta.\n\n @param log           Log handle\n @param method_id     Method ID\n @param callsite_index Call site index\n @param type_id       Observed type ID\n @return              0 on success, -1 on failure"]
    pub fn vtx_patch_log_append_callsite(
        log: *mut vtx_patch_log_t,
        method_id: u32,
        callsite_index: u32,
        type_id: vtx_typeid_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Append a loop backedge update delta.\n\n @param log            Log handle\n @param method_id      Method ID\n @param loop_header_pc Loop header bytecode PC\n @param backedge_count Backedge count\n @return               0 on success, -1 on failure"]
    pub fn vtx_patch_log_append_loop(
        log: *mut vtx_patch_log_t,
        method_id: u32,
        loop_header_pc: u32,
        backedge_count: u64,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Append a field shape update delta.\n\n @param log          Log handle\n @param method_id    Method ID\n @param field_offset Field offset\n @param shape_id     Observed shape ID\n @return             0 on success, -1 on failure"]
    pub fn vtx_patch_log_append_field(
        log: *mut vtx_patch_log_t,
        method_id: u32,
        field_offset: u32,
        shape_id: vtx_shapeid_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Append an invocation count update delta.\n\n @param log         Log handle\n @param method_id   Method ID\n @param count_delta Invocation count delta to add\n @return            0 on success, -1 on failure"]
    pub fn vtx_patch_log_append_invocation(
        log: *mut vtx_patch_log_t,
        method_id: u32,
        count_delta: u64,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Append a compaction marker.\n\n This marks the point where all prior entries have been subsumed by\n a snapshot. On replay, entries before the last compaction marker\n can be skipped (the snapshot captures their state).\n\n @param log  Log handle\n @return     0 on success, -1 on failure"]
    pub fn vtx_patch_log_append_compaction_marker(
        log: *mut vtx_patch_log_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Replay the patch log, applying all deltas to a profile.\n\n Reads each entry in order, validates its CRC, and applies the delta\n to the given profile. Entries with bad CRCs are skipped (crash\n recovery). Entries before the last compaction marker are skipped\n (they're subsumed by the snapshot).\n\n @param log     Log handle (must be open for reading)\n @param profile Profile to apply deltas to\n @return        Number of entries applied, or -1 on fatal error"]
    pub fn vtx_patch_log_replay(
        log: *mut vtx_patch_log_t,
        profile: *mut vtx_profile_global_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Compact the patch log.\n\n Reads the current log, computes the final profile state for each\n method, writes a new log containing just METHOD_SNAPSHOT entries +\n a COMPACTION_MARKER, then atomically replaces the old log.\n\n After compaction, the log is small (one snapshot per method) and\n replay is fast.\n\n @param log           Log handle (must be open for writing)\n @param profile       Current profile state (the source of truth for\n                      the snapshots). If NULL, the log is replayed\n                      first to build the profile, then compacted.\n @return              0 on success, -1 on failure"]
    pub fn vtx_patch_log_compact(
        log: *mut vtx_patch_log_t,
        profile: *const vtx_profile_global_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Get patch log statistics.\n\n @param log             Log handle\n @param entry_count     Out: entries written since open\n @param bytes_written   Out: bytes appended since open\n @param fd              Out: file descriptor (-1 if closed)"]
    pub fn vtx_patch_log_stats(
        log: *const vtx_patch_log_t,
        entry_count: *mut u32,
        bytes_written: *mut u64,
        fd: *mut ::std::os::raw::c_int,
    );
}
extern "C" {
    #[doc = " Build the patch log filename for a given bytecode hash.\n\n Format: <dir>/<hash_hex>.vpl"]
    pub fn vtx_patch_log_filename(
        dir: *const ::std::os::raw::c_char,
        hash_hex: *const ::std::os::raw::c_char,
        out: *mut ::std::os::raw::c_char,
        out_size: usize,
    ) -> ::std::os::raw::c_int;
}
pub const vtx_frame_kind_t_VTX_FRAME_INTERPRETED: vtx_frame_kind_t = 0;
pub const vtx_frame_kind_t_VTX_FRAME_COMPILED: vtx_frame_kind_t = 1;
pub const vtx_frame_kind_t_VTX_FRAME_NATIVE: vtx_frame_kind_t = 2;
pub const vtx_frame_kind_t_VTX_FRAME_DEOPTLESS: vtx_frame_kind_t = 3;
pub const vtx_frame_kind_t_VTX_FRAME_STUB: vtx_frame_kind_t = 4;
#[doc = " The kind of a frame encountered during stack walking."]
pub type vtx_frame_kind_t = ::std::os::raw::c_uint;
#[doc = " A single reconstructed interpreter frame. This is the output of stack\n walking: for each physical or logical frame on the compiled stack,\n we produce one of these with the interpreter-visible state."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_reconstructed_frame_t {
    pub method_id: u32,
    pub bytecode_pc: u32,
    pub locals: *mut vtx_value_t,
    pub local_count: u32,
    pub stack: *mut vtx_value_t,
    pub stack_count: u32,
    pub original_kind: vtx_frame_kind_t,
    pub is_inlined: bool,
    pub is_materialized: bool,
    pub compressed_snapshot: *mut u8,
    pub snapshot_size: u32,
}
impl Default for vtx_reconstructed_frame_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " The result of stack walking: an array of reconstructed interpreter frames."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_reconstructed_stack_t {
    pub frames: *mut vtx_reconstructed_frame_t,
    pub frame_count: u32,
    pub frame_capacity: u32,
}
impl Default for vtx_reconstructed_stack_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Maps a code entry point to its side table.\n Used during stack walking to look up the side table for each compiled frame."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_code_descriptor_t {
    pub code_start: *mut ::std::os::raw::c_void,
    pub code_size: u32,
    pub side_table: *mut vtx_side_table_t,
}
impl Default for vtx_code_descriptor_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Registry of all compiled code descriptors, used for side table lookup."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_side_table_registry_t {
    pub descriptors: *mut vtx_code_descriptor_t,
    pub descriptor_count: u32,
    pub descriptor_capacity: u32,
}
impl Default for vtx_side_table_registry_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Configuration for a stack walk operation."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_stack_walk_config_t {
    pub start_fp: *mut ::std::os::raw::c_void,
    pub registry: *mut vtx_side_table_registry_t,
    pub node_table: *const vtx_node_table_t,
    pub frame_states: *mut *mut vtx_frame_state_t,
    pub frame_state_count: u32,
    pub max_depth: u32,
}
impl Default for vtx_stack_walk_config_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Walk the compiled frame stack starting from the given frame pointer.\n\n For each compiled frame:\n   1. Look up the side table from the registry using the frame's code pointer.\n   2. Determine the native PC (from the saved return address minus 1).\n   3. Look up the FrameState from the side table.\n   4. For inlined methods, the FrameState chain contains multiple logical frames.\n   5. Reconstruct each logical frame as an interpreter frame.\n\n For each interpreter frame:\n   1. Read the method pointer, PC, locals, and stack directly.\n   2. Add to the reconstructed stack.\n\n Returns a newly allocated reconstructed stack (caller must free with\n vtx_reconstructed_stack_destroy), or NULL on failure."]
    pub fn vtx_stack_walk(config: *const vtx_stack_walk_config_t)
        -> *mut vtx_reconstructed_stack_t;
}
extern "C" {
    #[doc = " Create an empty reconstructed stack."]
    pub fn vtx_reconstructed_stack_create() -> *mut vtx_reconstructed_stack_t;
}
extern "C" {
    #[doc = " Destroy a reconstructed stack and free all frame memory."]
    pub fn vtx_reconstructed_stack_destroy(stack: *mut vtx_reconstructed_stack_t);
}
extern "C" {
    #[doc = " Add a reconstructed frame to the stack.\n Returns 0 on success, -1 on failure."]
    pub fn vtx_reconstructed_stack_add_frame(
        stack: *mut vtx_reconstructed_stack_t,
        frame: *const vtx_reconstructed_frame_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Initialize a side table registry."]
    pub fn vtx_side_table_registry_init(
        registry: *mut vtx_side_table_registry_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Destroy a side table registry."]
    pub fn vtx_side_table_registry_destroy(registry: *mut vtx_side_table_registry_t);
}
extern "C" {
    #[doc = " Register a compiled code range with its side table."]
    pub fn vtx_side_table_registry_add(
        registry: *mut vtx_side_table_registry_t,
        code_start: *mut ::std::os::raw::c_void,
        code_size: u32,
        side_table: *mut vtx_side_table_t,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Look up the side table for a code address.\n Returns the side table, or NULL if not found."]
    pub fn vtx_side_table_registry_lookup(
        registry: *const vtx_side_table_registry_t,
        code_addr: *const ::std::os::raw::c_void,
    ) -> *mut vtx_side_table_t;
}
extern "C" {
    #[doc = " Read the saved frame pointer from a compiled frame.\n On x86-64, this is the value at [fp + 0].\n Returns 0 on success, -1 on failure (e.g., invalid fp)."]
    pub fn vtx_stack_walk_read_caller_fp(
        fp: *mut ::std::os::raw::c_void,
        out_caller_fp: *mut *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Read the return address from a compiled frame.\n On x86-64, this is the value at [fp + 8].\n Returns 0 on success, -1 on failure."]
    pub fn vtx_stack_walk_read_return_addr(
        fp: *mut ::std::os::raw::c_void,
        out_return_addr: *mut *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Determine the kind of frame at the given frame pointer.\n Uses heuristics: if the code at the return address falls within a known\n compiled code range, it's a compiled frame. Otherwise it's native or\n interpreted."]
    pub fn vtx_stack_walk_classify_frame(
        registry: *const vtx_side_table_registry_t,
        fp: *mut ::std::os::raw::c_void,
    ) -> vtx_frame_kind_t;
}
extern "C" {
    #[doc = " Compress a frame's locals and operand stack into a compact snapshot.\n Uses run-length encoding: consecutive identical values are stored as\n (value, count). For typical interpreter frames (many nulls and zeros),\n this achieves 3-5x compression.\n\n @param frame  The frame to compress (must have locals/stack populated)\n @return       Newly allocated compressed buffer, or NULL on failure.\n               Caller must free() the returned buffer."]
    pub fn vtx_frame_compress(frame: *const vtx_reconstructed_frame_t) -> *mut u8;
}
extern "C" {
    #[doc = " Decompress a snapshot and populate the frame's locals/stack.\n This is called on demand when the interpreter needs to return into\n a frame that was lazily materialized.\n\n @param frame  The frame to decompress into (must have compressed_snapshot set)\n @return       0 on success, -1 on failure"]
    pub fn vtx_frame_decompress(frame: *mut vtx_reconstructed_frame_t) -> ::std::os::raw::c_int;
}
extern "C" {
    #[doc = " Materialize a single frame on demand.\n If the frame is already materialized, this is a no-op.\n If the frame has a compressed snapshot, decompress it.\n\n @param frame  The frame to materialize\n @return       0 on success, -1 on failure"]
    pub fn vtx_frame_materialize_on_demand(
        frame: *mut vtx_reconstructed_frame_t,
    ) -> ::std::os::raw::c_int;
}
#[doc = " Monitor state entry: tracks which objects are locked by this frame.\n Each entry records the local variable index holding the locked object\n and the object value itself (resolved at deopt time)."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vtx_osr_monitor_entry_t {
    pub local_index: u32,
    pub object: vtx_value_t,
}
#[doc = " Enhanced representation of an interpreter frame for OSR transitions.\n Matches the real interpreter frame from src/interp/frame.h more closely,\n including monitor state, exception handlers, return address, and frame kind."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_interp_frame_t {
    pub method_id: u32,
    pub bytecode_pc: u32,
    pub locals: *mut vtx_value_t,
    pub local_count: u32,
    pub stack: *mut vtx_value_t,
    pub stack_top: u32,
    pub stack_capacity: u32,
    pub caller: *mut vtx_frame_state_t,
    pub osr_active: bool,
    pub monitors: *mut vtx_osr_monitor_entry_t,
    pub monitor_count: u32,
    pub monitor_capacity: u32,
    pub catch_handler_pc: u32,
    pub return_pc: u32,
    pub frame_kind: vtx_frame_kind_t,
}
impl Default for vtx_interp_frame_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[doc = " Information provided when a guard fails and OSR down is needed.\n This is populated by the deopt stub before calling vtx_osr_down.\n This is distinct from vtx_deopt_info_t (which is the static per-method\n deopt metadata) — this struct contains the dynamic runtime state\n at the point of deoptimization."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vtx_osr_deopt_context_t {
    pub method_id: u32,
    pub native_pc: u32,
    pub frame_state: *mut vtx_frame_state_t,
    pub side_table: *mut vtx_side_table_t,
    pub frame_pointer: *mut ::std::os::raw::c_void,
    pub register_map: *mut vtx_value_t,
    pub register_count: u32,
}
impl Default for vtx_osr_deopt_context_t {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    #[doc = " Perform OSR up: replace the interpreter frame with a compiled frame\n and transfer control to the compiled code.\n\n Steps:\n   1. Verify the compiled code exists for the method at the loop header.\n   2. Build a FrameState from the interpreter's current local/stack state.\n   3. Set up the JIT frame: copy locals and stack into the JIT frame layout.\n   4. Patch the return address to point into the compiled code.\n   5. Transfer execution to the compiled code's entry point.\n\n @param interp         Current interpreter frame\n @param method_id      Method being executed\n @param compiled_code  Compiled code descriptor for the method\n @param loop_header_pc Bytecode PC of the loop header (OSR entry point)\n @return true if OSR up was successful, false if not"]
    pub fn vtx_osr_up(
        interp: *mut vtx_interp_frame_t,
        method_id: u32,
        compiled_code: *const vtx_compiled_code_t,
        loop_header_pc: u32,
    ) -> bool;
}
extern "C" {
    #[doc = " Perform OSR down: replace the compiled frame with an interpreter frame\n and resume execution in the interpreter.\n\n Steps:\n   1. Look up the FrameState from the side table using the native PC.\n   2. Reconstruct the interpreter operand stack from the FrameState:\n      - For each NodeID in the FrameState, evaluate the node to get a value.\n      - Map NodeIDs to values using the register map and frame state.\n   3. Reconstruct the interpreter local variables similarly.\n   4. Handle monitors: relock any monitors that were held in compiled code.\n   5. Handle exception handlers: set up the active handler from FrameState.\n   6. Walk the caller chain and reconstruct caller interpreter frames.\n   7. Transfer execution to the interpreter dispatch loop at the deopt PC.\n\n @param interp   Interpreter state to resume (output: populated with frame)\n @param deopt_info Information about the deoptimization point\n @return The interpreter resume frame, or NULL on failure"]
    pub fn vtx_osr_down(
        interp: *mut vtx_interp_frame_t,
        deopt_ctx: *const vtx_osr_deopt_context_t,
    ) -> *mut vtx_interp_frame_t;
}
extern "C" {
    #[doc = " Build an interpreter frame from a FrameState and a value resolution function.\n\n @param fs           The FrameState to convert\n @param node_to_value Function that maps a NodeID to its current vtx_value_t\n @param context      Opaque context passed to node_to_value\n @return A newly allocated interpreter frame, or NULL on failure"]
    pub fn vtx_osr_build_interp_frame(
        fs: *const vtx_frame_state_t,
        node_to_value: ::std::option::Option<
            unsafe extern "C" fn(
                arg1: vtx_nodeid_t,
                arg2: *mut ::std::os::raw::c_void,
            ) -> vtx_value_t,
        >,
        context: *mut ::std::os::raw::c_void,
    ) -> *mut vtx_interp_frame_t;
}
extern "C" {
    #[doc = " Resolve a NodeID to its value at deopt time.\n Uses the register map and frame state to look up the value.\n\n @param node_id      The NodeID to resolve\n @param register_map Array of values indexed by NodeID (from side table)\n @param map_size     Size of the register map array\n @return The resolved value, or VTX_VALUE_UNDEFINED if not found"]
    pub fn vtx_osr_resolve_node(
        node_id: vtx_nodeid_t,
        register_map: *const vtx_value_t,
        map_size: u32,
    ) -> vtx_value_t;
}