min_infmachine_lltk 0.1.0

The MinInfMachine Low Level Toolkit.
Documentation
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
use min_infmachine_lltk::builder::*;
use min_infmachine_lltk::handler_builder::*;
use min_infmachine_lltk::*;

#[test]
fn test_handler_builder_longdata_safe_ldh() {
    let mut builder = mi_simple_hbuilder_new_1_safe_ldh(None, Some("ma_check_fix"), None);
    builder.add_longdata_handler("md", false, 1);
    builder.ld_call_01("md", (&[143, 54], 0, 0), MINF_MR);
    builder.i(MINF_STOP);
    {
        let (func1b, ret) = builder.add_routine("ma_check_fix", true);
        let mut func1b = func1b.borrow_mut();
        func1b.i(MINF_MR);
        func1b.i(MINF_TBRF);
        func1b.i(MINF_TBB);
        func1b.i((MINF_TBRW1, MINF_TBRW0, ret));
    }
    assert_eq!(
        (
            vec![
                MinInfInstr::new(MINF_MR, MINF_MR, 51, 51),
                (MINF_MR, MINF_MR, 47, 47).into(),
                (MINF_STOP, MINF_STOP, 3, 3).into(),
                (MINF_MARW1, MINF_MARW1, 4, 4).into(),
                (MINF_MARF, MINF_MARF, 5, 5).into(),
                (MINF_MARW1, MINF_MARW1, 6, 6).into(),
                (MINF_MARF, MINF_MARF, 7, 7).into(),
                (MINF_MARW0, MINF_MARW0, 8, 8).into(),
                (MINF_MARF, MINF_MARF, 9, 9).into(),
                (MINF_MARW0, MINF_MARW0, 10, 10).into(),
                (MINF_MARF, MINF_MARF, 12, 12).into(),
                (MINF_MR, MINF_MR, 3, 3).into(),
                (MINF_MR, MINF_MR, 44, 44).into(),
                (MINF_MARW0, MINF_MARW0, 14, 14).into(),
                (MINF_MARF, MINF_MARF, 15, 15).into(),
                (MINF_MARW1, MINF_MARW1, 16, 16).into(),
                (MINF_MARF, MINF_MARF, 17, 17).into(),
                (MINF_MARW1, MINF_MARW1, 18, 18).into(),
                (MINF_MARF, MINF_MARF, 19, 19).into(),
                (MINF_MARW0, MINF_MARW0, 20, 20).into(),
                (MINF_MARF, MINF_MARF, 22, 22).into(),
                (MINF_MR, MINF_MR, 13, 13).into(),
                (MINF_MR, MINF_MR, 11, 11).into(),
                (MINF_MARW0, MINF_MARW0, 24, 24).into(),
                (MINF_MARF, MINF_MARF, 25, 25).into(),
                (MINF_MARW0, MINF_MARW0, 26, 26).into(),
                (MINF_MARF, MINF_MARF, 27, 27).into(),
                (MINF_MARW0, MINF_MARW0, 28, 28).into(),
                (MINF_MARF, MINF_MARF, 29, 29).into(),
                (MINF_MARW1, MINF_MARW1, 30, 30).into(),
                (MINF_MARF, MINF_MARF, 32, 32).into(),
                (MINF_MR, MINF_MR, 23, 23).into(),
                (MINF_MR, MINF_MR, 46, 46).into(),
                (MINF_MARW1, MINF_MARW1, 34, 34).into(),
                (MINF_MARF, MINF_MARF, 35, 35).into(),
                (MINF_MARW1, MINF_MARW1, 36, 36).into(),
                (MINF_MARF, MINF_MARF, 37, 37).into(),
                (MINF_MARW1, MINF_MARW1, 38, 38).into(),
                (MINF_MARF, MINF_MARF, 39, 39).into(),
                (MINF_MARW1, MINF_MARW1, 40, 40).into(),
                (MINF_MARF, MINF_MARF, 42, 42).into(),
                (MINF_MR, MINF_MR, 33, 33).into(),
                (MINF_MR, MINF_MR, 31, 31).into(),
                (MINF_MR, MINF_MR, 21, 21).into(),
                (MINF_MR, MINF_MR, 48, 48).into(),
                (MINF_MR, MINF_MR, 41, 41).into(),
                (MINF_MR, MINF_MR, 43, 43).into(),
                (MINF_MR, MINF_MR, 45, 45).into(),
                (MINF_MR, MINF_MR, 2, 2).into(),
                (MINF_MR, MINF_MR, 53, 53).into(),
                (MINF_MR, MINF_MR, 64, 64).into(),
                (MINF_MR, MINF_MR, 57, 57).into(),
                (MINF_MR, MINF_MR, 1, 1).into(),
                (MINF_MR, MINF_MR, 54, 54).into(),
                (MINF_TBRF, MINF_TBRF, 55, 55).into(),
                (MINF_TBB, MINF_TBB, 56, 56).into(),
                (MINF_TBRW1, MINF_TBRW0, 50, 50).into(),
                (MINF_MARW1, MINF_MARW1, 58, 58).into(),
                (MINF_MARF, MINF_MARF, 59, 59).into(),
                (MINF_MARW0, MINF_MARW0, 60, 60).into(),
                (MINF_MARF, MINF_MARF, 61, 61).into(),
                (MINF_MARW1, MINF_MARW1, 62, 62).into(),
                (MINF_MARF, MINF_MARF, 63, 63).into(),
                (MINF_MR, MINF_MR, 49, 49).into(),
                (MINF_MR, MINF_MR, 52, 52).into(),
            ],
            vec![
                ("ma_check_fix".to_string(), 53),
                ("ma_check_fix:md".to_string(), 57),
                ("ma_check_fix:md_0_putret_x_0".to_string(), 51),
                ("ma_check_fix:md_after_ret_0".to_string(), 1),
                ("ma_check_fix:md_return".to_string(), 52),
                ("ma_check_fix_0_putret_x_0".to_string(), 49),
                ("ma_check_fix_after_ret_0".to_string(), 64),
                ("ma_check_fix_return".to_string(), 50),
                ("md_chunk_368f_16_0_putret_x_0".to_string(), 47),
                ("md_chunk_368f_16_return".to_string(), 48),
                ("md_chunk_36_8_0_putret_x_0".to_string(), 43),
                ("md_chunk_36_8_return".to_string(), 44),
                ("md_chunk_3_4".to_string(), 3),
                ("md_chunk_3_4_0_putret_x_0".to_string(), 11),
                ("md_chunk_3_4_return".to_string(), 12),
                ("md_chunk_6_4".to_string(), 13),
                ("md_chunk_6_4_0_putret_x_0".to_string(), 21),
                ("md_chunk_6_4_return".to_string(), 22),
                ("md_chunk_8_4".to_string(), 23),
                ("md_chunk_8_4_0_putret_x_0".to_string(), 31),
                ("md_chunk_8_4_return".to_string(), 32),
                ("md_chunk_8f_8_0_putret_x_0".to_string(), 45),
                ("md_chunk_8f_8_return".to_string(), 46),
                ("md_chunk_f_4".to_string(), 33),
                ("md_chunk_f_4_0_putret_x_0".to_string(), 41),
                ("md_chunk_f_4_return".to_string(), 42),
                ("md_next_0".to_string(), 2),
            ]
        ),
        builder.to_code()
    );

    let mut builder = mi_simple_hbuilder_new_1_safe_ldh(None, Some("ma_check_fix"), None);
    builder.add_longdata_handler("md", false, 1);
    builder.ld_call_01(
        "md",
        (
            &[0xaa, 0xba, 0x56, 0x51, 0x84, 0xc5, 0xd3, 0xba, 0x56, 0x51],
            0xc,
            4,
        ),
        MINF_MR,
    );
    builder.ld_call_01("md", (&[0x22, 0x33], 0, 0), MINF_MR);
    builder.i(MINF_STOP);
    {
        let (func1b, ret) = builder.add_routine("ma_check_fix", true);
        let mut func1b = func1b.borrow_mut();
        func1b.i(MINF_MR);
        func1b.i(MINF_TBRF);
        func1b.i(MINF_TBB);
        func1b.i((MINF_TBRW1, MINF_TBRW0, ret));
    }
    assert_eq!(
        (
            vec![
                MinInfInstr::new(MINF_MR, MINF_MR, 217, 217),
                (MINF_MR, MINF_MR, 213, 213).into(),
                (MINF_MR, MINF_MR, 192, 192).into(),
                (MINF_STOP, MINF_STOP, 4, 4).into(),
                (MINF_MARW1, MINF_MARW1, 5, 5).into(),
                (MINF_MARF, MINF_MARF, 6, 6).into(),
                (MINF_MARW0, MINF_MARW0, 7, 7).into(),
                (MINF_MARF, MINF_MARF, 8, 8).into(),
                (MINF_MARW0, MINF_MARW0, 9, 9).into(),
                (MINF_MARF, MINF_MARF, 10, 10).into(),
                (MINF_MARW0, MINF_MARW0, 11, 11).into(),
                (MINF_MARF, MINF_MARF, 13, 13).into(),
                (MINF_MR, MINF_MR, 4, 4).into(),
                (MINF_MR, MINF_MR, 74, 74).into(),
                (MINF_MARW0, MINF_MARW0, 15, 15).into(),
                (MINF_MARF, MINF_MARF, 16, 16).into(),
                (MINF_MARW1, MINF_MARW1, 17, 17).into(),
                (MINF_MARF, MINF_MARF, 18, 18).into(),
                (MINF_MARW0, MINF_MARW0, 19, 19).into(),
                (MINF_MARF, MINF_MARF, 20, 20).into(),
                (MINF_MARW0, MINF_MARW0, 21, 21).into(),
                (MINF_MARF, MINF_MARF, 26, 26).into(),
                (MINF_TBRW0, MINF_TBRW0, 23, 23).into(),
                (MINF_TBRF, MINF_TBRF, 14, 14).into(),
                (MINF_TBRW1, MINF_TBRW1, 25, 25).into(),
                (MINF_TBRF, MINF_TBRF, 14, 14).into(),
                (MINF_TBB, MINF_TBB, 27, 27).into(),
                (MINF_TBRW0, MINF_TBRW0, 28, 28).into(),
                (MINF_MR, MINF_MR, 24, 170).into(),
                (MINF_MARW1, MINF_MARW1, 30, 30).into(),
                (MINF_MARF, MINF_MARF, 31, 31).into(),
                (MINF_MARW1, MINF_MARW1, 32, 32).into(),
                (MINF_MARF, MINF_MARF, 33, 33).into(),
                (MINF_MARW0, MINF_MARW0, 34, 34).into(),
                (MINF_MARF, MINF_MARF, 35, 35).into(),
                (MINF_MARW0, MINF_MARW0, 36, 36).into(),
                (MINF_MARF, MINF_MARF, 47, 47).into(),
                (MINF_TBRW0, MINF_TBRW0, 38, 38).into(),
                (MINF_TBRF, MINF_TBRF, 43, 43).into(),
                (MINF_TBRW1, MINF_TBRW1, 40, 40).into(),
                (MINF_TBRF, MINF_TBRF, 43, 43).into(),
                (MINF_TBRW0, MINF_TBRW0, 42, 42).into(),
                (MINF_TBRF, MINF_TBRF, 45, 45).into(),
                (MINF_TBRW0, MINF_TBRW0, 44, 44).into(),
                (MINF_TBRF, MINF_TBRF, 29, 29).into(),
                (MINF_TBRW1, MINF_TBRW1, 46, 46).into(),
                (MINF_TBRF, MINF_TBRF, 29, 29).into(),
                (MINF_TBB, MINF_TBB, 48, 48).into(),
                (MINF_TBRW0, MINF_TBRW0, 49, 49).into(),
                (MINF_TBB, MINF_TBB, 50, 52).into(),
                (MINF_TBRW0, MINF_TBRW0, 51, 51).into(),
                (MINF_MR, MINF_MR, 167, 41).into(),
                (MINF_TBRW0, MINF_TBRW0, 53, 53).into(),
                (MINF_MR, MINF_MR, 172, 172).into(),
                (MINF_MARW0, MINF_MARW0, 55, 55).into(),
                (MINF_MARF, MINF_MARF, 56, 56).into(),
                (MINF_MARW0, MINF_MARW0, 57, 57).into(),
                (MINF_MARF, MINF_MARF, 58, 58).into(),
                (MINF_MARW1, MINF_MARW1, 59, 59).into(),
                (MINF_MARF, MINF_MARF, 60, 60).into(),
                (MINF_MARW0, MINF_MARW0, 61, 61).into(),
                (MINF_MARF, MINF_MARF, 63, 63).into(),
                (MINF_MR, MINF_MR, 54, 54).into(),
                (MINF_MR, MINF_MR, 107, 107).into(),
                (MINF_MARW1, MINF_MARW1, 65, 65).into(),
                (MINF_MARF, MINF_MARF, 66, 66).into(),
                (MINF_MARW0, MINF_MARW0, 67, 67).into(),
                (MINF_MARF, MINF_MARF, 68, 68).into(),
                (MINF_MARW1, MINF_MARW1, 69, 69).into(),
                (MINF_MARF, MINF_MARF, 70, 70).into(),
                (MINF_MARW0, MINF_MARW0, 71, 71).into(),
                (MINF_MARF, MINF_MARF, 82, 82).into(),
                (MINF_TBRW0, MINF_TBRW0, 73, 73).into(),
                (MINF_TBRF, MINF_TBRF, 78, 78).into(),
                (MINF_TBRW1, MINF_TBRW1, 75, 75).into(),
                (MINF_TBRF, MINF_TBRF, 78, 78).into(),
                (MINF_TBRW0, MINF_TBRW0, 77, 77).into(),
                (MINF_TBRF, MINF_TBRF, 80, 80).into(),
                (MINF_TBRW0, MINF_TBRW0, 79, 79).into(),
                (MINF_TBRF, MINF_TBRF, 64, 64).into(),
                (MINF_TBRW1, MINF_TBRW1, 81, 81).into(),
                (MINF_TBRF, MINF_TBRF, 64, 64).into(),
                (MINF_TBB, MINF_TBB, 83, 83).into(),
                (MINF_TBRW0, MINF_TBRW0, 84, 84).into(),
                (MINF_TBB, MINF_TBB, 85, 87).into(),
                (MINF_TBRW0, MINF_TBRW0, 86, 86).into(),
                (MINF_MR, MINF_MR, 176, 174).into(),
                (MINF_TBRW0, MINF_TBRW0, 88, 88).into(),
                (MINF_MR, MINF_MR, 152, 152).into(),
                (MINF_MARW0, MINF_MARW0, 90, 90).into(),
                (MINF_MARF, MINF_MARF, 91, 91).into(),
                (MINF_MARW1, MINF_MARW1, 92, 92).into(),
                (MINF_MARF, MINF_MARF, 93, 93).into(),
                (MINF_MARW1, MINF_MARW1, 94, 94).into(),
                (MINF_MARF, MINF_MARF, 95, 95).into(),
                (MINF_MARW0, MINF_MARW0, 96, 96).into(),
                (MINF_MARF, MINF_MARF, 98, 98).into(),
                (MINF_MR, MINF_MR, 89, 89).into(),
                (MINF_MR, MINF_MR, 72, 72).into(),
                (MINF_MARW0, MINF_MARW0, 100, 100).into(),
                (MINF_MARF, MINF_MARF, 101, 101).into(),
                (MINF_MARW0, MINF_MARW0, 102, 102).into(),
                (MINF_MARF, MINF_MARF, 103, 103).into(),
                (MINF_MARW0, MINF_MARW0, 104, 104).into(),
                (MINF_MARF, MINF_MARF, 105, 105).into(),
                (MINF_MARW1, MINF_MARW1, 106, 106).into(),
                (MINF_MARF, MINF_MARF, 108, 108).into(),
                (MINF_MR, MINF_MR, 99, 99).into(),
                (MINF_MR, MINF_MR, 178, 178).into(),
                (MINF_MARW0, MINF_MARW0, 110, 110).into(),
                (MINF_MARF, MINF_MARF, 111, 111).into(),
                (MINF_MARW1, MINF_MARW1, 112, 112).into(),
                (MINF_MARF, MINF_MARF, 113, 113).into(),
                (MINF_MARW0, MINF_MARW0, 114, 114).into(),
                (MINF_MARF, MINF_MARF, 115, 115).into(),
                (MINF_MARW1, MINF_MARW1, 116, 116).into(),
                (MINF_MARF, MINF_MARF, 127, 127).into(),
                (MINF_TBRW0, MINF_TBRW0, 118, 118).into(),
                (MINF_TBRF, MINF_TBRF, 123, 123).into(),
                (MINF_TBRW1, MINF_TBRW1, 120, 120).into(),
                (MINF_TBRF, MINF_TBRF, 123, 123).into(),
                (MINF_TBRW0, MINF_TBRW0, 122, 122).into(),
                (MINF_TBRF, MINF_TBRF, 125, 125).into(),
                (MINF_TBRW0, MINF_TBRW0, 124, 124).into(),
                (MINF_TBRF, MINF_TBRF, 109, 109).into(),
                (MINF_TBRW1, MINF_TBRW1, 126, 126).into(),
                (MINF_TBRF, MINF_TBRF, 109, 109).into(),
                (MINF_TBB, MINF_TBB, 128, 128).into(),
                (MINF_TBRW0, MINF_TBRW0, 129, 129).into(),
                (MINF_TBB, MINF_TBB, 130, 132).into(),
                (MINF_TBRW0, MINF_TBRW0, 131, 131).into(),
                (MINF_MR, MINF_MR, 119, 180).into(),
                (MINF_TBRW0, MINF_TBRW0, 133, 133).into(),
                (MINF_MR, MINF_MR, 142, 142).into(),
                (MINF_MARW1, MINF_MARW1, 135, 135).into(),
                (MINF_MARF, MINF_MARF, 136, 136).into(),
                (MINF_MARW1, MINF_MARW1, 137, 137).into(),
                (MINF_MARF, MINF_MARF, 138, 138).into(),
                (MINF_MARW0, MINF_MARW0, 139, 139).into(),
                (MINF_MARF, MINF_MARF, 140, 140).into(),
                (MINF_MARW1, MINF_MARW1, 141, 141).into(),
                (MINF_MARF, MINF_MARF, 143, 143).into(),
                (MINF_MR, MINF_MR, 134, 134).into(),
                (MINF_MR, MINF_MR, 185, 185).into(),
                (MINF_MARW0, MINF_MARW0, 145, 145).into(),
                (MINF_MARF, MINF_MARF, 146, 146).into(),
                (MINF_MARW0, MINF_MARW0, 147, 147).into(),
                (MINF_MARF, MINF_MARF, 148, 148).into(),
                (MINF_MARW1, MINF_MARW1, 149, 149).into(),
                (MINF_MARF, MINF_MARF, 150, 150).into(),
                (MINF_MARW1, MINF_MARW1, 151, 151).into(),
                (MINF_MARF, MINF_MARF, 156, 156).into(),
                (MINF_TBRW0, MINF_TBRW0, 153, 153).into(),
                (MINF_TBRF, MINF_TBRF, 144, 144).into(),
                (MINF_TBRW1, MINF_TBRW1, 155, 155).into(),
                (MINF_TBRF, MINF_TBRF, 144, 144).into(),
                (MINF_TBB, MINF_TBB, 157, 157).into(),
                (MINF_TBRW0, MINF_TBRW0, 158, 158).into(),
                (MINF_MR, MINF_MR, 189, 208).into(),
                (MINF_MARW1, MINF_MARW1, 160, 160).into(),
                (MINF_MARF, MINF_MARF, 161, 161).into(),
                (MINF_MARW0, MINF_MARW0, 162, 162).into(),
                (MINF_MARF, MINF_MARF, 163, 163).into(),
                (MINF_MARW1, MINF_MARW1, 164, 164).into(),
                (MINF_MARF, MINF_MARF, 165, 165).into(),
                (MINF_MARW1, MINF_MARW1, 166, 166).into(),
                (MINF_MARF, MINF_MARF, 168, 168).into(),
                (MINF_MR, MINF_MR, 159, 159).into(),
                (MINF_MR, MINF_MR, 191, 191).into(),
                (MINF_MR, MINF_MR, 22, 22).into(),
                (MINF_MR, MINF_MR, 171, 171).into(),
                (MINF_MR, MINF_MR, 39, 39).into(),
                (MINF_MR, MINF_MR, 193, 193).into(),
                (MINF_MR, MINF_MR, 12, 12).into(),
                (MINF_MR, MINF_MR, 198, 198).into(),
                (MINF_MR, MINF_MR, 97, 97).into(),
                (MINF_MR, MINF_MR, 173, 173).into(),
                (MINF_MR, MINF_MR, 62, 62).into(),
                (MINF_MR, MINF_MR, 188, 188).into(),
                (MINF_MR, MINF_MR, 117, 117).into(),
                (MINF_MR, MINF_MR, 181, 181).into(),
                (MINF_TBRW0, MINF_TBRW0, 182, 182).into(),
                (MINF_TBRF, MINF_TBRF, 121, 121).into(),
                (MINF_TBRW1, MINF_TBRW1, 184, 184).into(),
                (MINF_TBRF, MINF_TBRF, 121, 121).into(),
                (MINF_TBB, MINF_TBB, 186, 186).into(),
                (MINF_TBRW0, MINF_TBRW0, 187, 187).into(),
                (MINF_MR, MINF_MR, 202, 204).into(),
                (MINF_MR, MINF_MR, 76, 76).into(),
                (MINF_MR, MINF_MR, 206, 206).into(),
                (MINF_MR, MINF_MR, 37, 37).into(),
                (MINF_MR, MINF_MR, 183, 183).into(),
                (MINF_MR, MINF_MR, 169, 169).into(),
                (MINF_MR, MINF_MR, 3, 3).into(),
                (MINF_TBRW0, MINF_TBRW0, 195, 195).into(),
                (MINF_TBRF, MINF_TBRF, 175, 175).into(),
                (MINF_TBRW1, MINF_TBRW1, 197, 197).into(),
                (MINF_TBRF, MINF_TBRF, 175, 175).into(),
                (MINF_TBB, MINF_TBB, 199, 199).into(),
                (MINF_TBRW0, MINF_TBRW0, 200, 200).into(),
                (MINF_MR, MINF_MR, 210, 154).into(),
                (MINF_MR, MINF_MR, 179, 179).into(),
                (MINF_MR, MINF_MR, 194, 194).into(),
                (MINF_MR, MINF_MR, 190, 190).into(),
                (MINF_MR, MINF_MR, 212, 212).into(),
                (MINF_MR, MINF_MR, 177, 177).into(),
                (MINF_MR, MINF_MR, 203, 203).into(),
                (MINF_MR, MINF_MR, 196, 196).into(),
                (MINF_MR, MINF_MR, 2, 2).into(),
                (MINF_MR, MINF_MR, 201, 201).into(),
                (MINF_MR, MINF_MR, 211, 211).into(),
                (MINF_MR, MINF_MR, 205, 205).into(),
                (MINF_MR, MINF_MR, 214, 214).into(),
                (MINF_MR, MINF_MR, 209, 209).into(),
                (MINF_MR, MINF_MR, 207, 207).into(),
                (MINF_MR, MINF_MR, 219, 219).into(),
                (MINF_MR, MINF_MR, 234, 234).into(),
                (MINF_MR, MINF_MR, 223, 223).into(),
                (MINF_MR, MINF_MR, 1, 1).into(),
                (MINF_MR, MINF_MR, 220, 220).into(),
                (MINF_TBRF, MINF_TBRF, 221, 221).into(),
                (MINF_TBB, MINF_TBB, 222, 222).into(),
                (MINF_TBRW1, MINF_TBRW0, 216, 216).into(),
                (MINF_MARW1, MINF_MARW1, 224, 224).into(),
                (MINF_MARF, MINF_MARF, 225, 225).into(),
                (MINF_MARW1, MINF_MARW1, 226, 226).into(),
                (MINF_MARF, MINF_MARF, 227, 227).into(),
                (MINF_MARW0, MINF_MARW0, 228, 228).into(),
                (MINF_MARF, MINF_MARF, 229, 229).into(),
                (MINF_MARW1, MINF_MARW1, 230, 230).into(),
                (MINF_MARF, MINF_MARF, 231, 231).into(),
                (MINF_MARW1, MINF_MARW1, 232, 232).into(),
                (MINF_MARF, MINF_MARF, 233, 233).into(),
                (MINF_MR, MINF_MR, 215, 215).into(),
                (MINF_MR, MINF_MR, 218, 218).into(),
            ],
            vec![
                ("ma_check_fix".to_string(), 219),
                ("ma_check_fix:md".to_string(), 223),
                ("ma_check_fix:md_0_putret_x_0".to_string(), 217),
                ("ma_check_fix:md_after_ret_0".to_string(), 1),
                ("ma_check_fix:md_return".to_string(), 218),
                ("ma_check_fix_0_putret_x_0".to_string(), 215),
                ("ma_check_fix_after_ret_0".to_string(), 234),
                ("ma_check_fix_return".to_string(), 216),
                ("md_chunk_1_4".to_string(), 4),
                ("md_chunk_1_4_0_putret_x_0".to_string(), 12),
                ("md_chunk_1_4_return".to_string(), 13),
                ("md_chunk_22_8_0_putret_x_0".to_string(), 169),
                ("md_chunk_22_8_return".to_string(), 170),
                ("md_chunk_2_4".to_string(), 14),
                ("md_chunk_2_4_0_putret_x_0".to_string(), 22),
                ("md_chunk_2_4_0_putret_x_1".to_string(), 24),
                ("md_chunk_2_4_return".to_string(), 26),
                ("md_chunk_2_4_return_id_0_0".to_string(), 27),
                ("md_chunk_3322_16_0_putret_x_0".to_string(), 192),
                ("md_chunk_3322_16_return".to_string(), 193),
                ("md_chunk_33_8_0_putret_x_0".to_string(), 171),
                ("md_chunk_33_8_return".to_string(), 172),
                ("md_chunk_3_4".to_string(), 29),
                ("md_chunk_3_4_0_putret_1_0".to_string(), 43),
                ("md_chunk_3_4_0_putret_1_1".to_string(), 45),
                ("md_chunk_3_4_0_putret_x_0".to_string(), 37),
                ("md_chunk_3_4_0_putret_x_1".to_string(), 39),
                ("md_chunk_3_4_0_putret_x_10".to_string(), 41),
                ("md_chunk_3_4_return".to_string(), 47),
                ("md_chunk_3_4_return_id_0_0".to_string(), 48),
                ("md_chunk_3_4_return_id_1_0".to_string(), 50),
                ("md_chunk_3_4_return_id_1_1".to_string(), 52),
                ("md_chunk_4_4".to_string(), 54),
                ("md_chunk_4_4_0_putret_x_0".to_string(), 62),
                ("md_chunk_4_4_return".to_string(), 63),
                ("md_chunk_5156_16_0_putret_x_0".to_string(), 194),
                ("md_chunk_5156_16_0_putret_x_1".to_string(), 196),
                ("md_chunk_5156_16_return".to_string(), 198),
                ("md_chunk_5156_16_return_id_0_0".to_string(), 199),
                ("md_chunk_5156baaa_32_0_putret_x_0".to_string(), 209),
                ("md_chunk_5156baaa_32_return".to_string(), 210),
                ("md_chunk_51_8_0_putret_x_0".to_string(), 173),
                ("md_chunk_51_8_return".to_string(), 174),
                ("md_chunk_56_8_0_putret_x_0".to_string(), 175),
                ("md_chunk_56_8_return".to_string(), 176),
                ("md_chunk_5_4".to_string(), 64),
                ("md_chunk_5_4_0_putret_1_0".to_string(), 78),
                ("md_chunk_5_4_0_putret_1_1".to_string(), 80),
                ("md_chunk_5_4_0_putret_x_0".to_string(), 72),
                ("md_chunk_5_4_0_putret_x_1".to_string(), 74),
                ("md_chunk_5_4_0_putret_x_10".to_string(), 76),
                ("md_chunk_5_4_return".to_string(), 82),
                ("md_chunk_5_4_return_id_0_0".to_string(), 83),
                ("md_chunk_5_4_return_id_1_0".to_string(), 85),
                ("md_chunk_5_4_return_id_1_1".to_string(), 87),
                ("md_chunk_6_4".to_string(), 89),
                ("md_chunk_6_4_0_putret_x_0".to_string(), 97),
                ("md_chunk_6_4_return".to_string(), 98),
                ("md_chunk_84_8_0_putret_x_0".to_string(), 177),
                ("md_chunk_84_8_return".to_string(), 178),
                ("md_chunk_8_4".to_string(), 99),
                ("md_chunk_8_4_0_putret_x_0".to_string(), 107),
                ("md_chunk_8_4_return".to_string(), 108),
                ("md_chunk_a_4".to_string(), 109),
                ("md_chunk_a_4_0_putret_1_0".to_string(), 123),
                ("md_chunk_a_4_0_putret_1_1".to_string(), 125),
                ("md_chunk_a_4_0_putret_x_0".to_string(), 117),
                ("md_chunk_a_4_0_putret_x_1".to_string(), 119),
                ("md_chunk_a_4_0_putret_x_10".to_string(), 121),
                ("md_chunk_a_4_return".to_string(), 127),
                ("md_chunk_a_4_return_id_0_0".to_string(), 128),
                ("md_chunk_a_4_return_id_1_0".to_string(), 130),
                ("md_chunk_a_4_return_id_1_1".to_string(), 132),
                ("md_chunk_aa_8_0_putret_x_0".to_string(), 179),
                ("md_chunk_aa_8_return".to_string(), 180),
                ("md_chunk_b_4".to_string(), 134),
                ("md_chunk_b_4_0_putret_x_0".to_string(), 142),
                ("md_chunk_b_4_return".to_string(), 143),
                ("md_chunk_ba_8_0_putret_x_0".to_string(), 181),
                ("md_chunk_ba_8_0_putret_x_1".to_string(), 183),
                ("md_chunk_ba_8_return".to_string(), 185),
                ("md_chunk_ba_8_return_id_0_0".to_string(), 186),
                ("md_chunk_baaa_16_0_putret_x_0".to_string(), 201),
                ("md_chunk_baaa_16_return".to_string(), 202),
                ("md_chunk_bad3_16_0_putret_x_0".to_string(), 203),
                ("md_chunk_bad3_16_return".to_string(), 204),
                ("md_chunk_bad3c5845156baaa_64_0_putret_x_0".to_string(), 213),
                ("md_chunk_bad3c5845156baaa_64_return".to_string(), 214),
                ("md_chunk_bad3c584_32_0_putret_x_0".to_string(), 211),
                ("md_chunk_bad3c584_32_return".to_string(), 212),
                ("md_chunk_c5156_20_0_putret_x_0".to_string(), 207),
                ("md_chunk_c5156_20_return".to_string(), 208),
                ("md_chunk_c584_16_0_putret_x_0".to_string(), 205),
                ("md_chunk_c584_16_return".to_string(), 206),
                ("md_chunk_c5_8_0_putret_x_0".to_string(), 188),
                ("md_chunk_c5_8_return".to_string(), 189),
                ("md_chunk_c_4".to_string(), 144),
                ("md_chunk_c_4_0_putret_x_0".to_string(), 152),
                ("md_chunk_c_4_0_putret_x_1".to_string(), 154),
                ("md_chunk_c_4_return".to_string(), 156),
                ("md_chunk_c_4_return_id_0_0".to_string(), 157),
                ("md_chunk_d3_8_0_putret_x_0".to_string(), 190),
                ("md_chunk_d3_8_return".to_string(), 191),
                ("md_chunk_d_4".to_string(), 159),
                ("md_chunk_d_4_0_putret_x_0".to_string(), 167),
                ("md_chunk_d_4_return".to_string(), 168),
                ("md_next_0".to_string(), 2),
                ("md_next_1".to_string(), 3),
            ]
        ),
        builder.to_code()
    );
}

#[test]
fn test_handler_builder_longdata_safe_ldh_req_bits_checks() {
    // with temp_buffer return_bits=2. 5 - 2*2 = 1 - generates 1 extra bit in stack to check.
    let mut builder = mi_simple_hbuilder_new_safe_ldh(None, Some(2), Some("ma_check_fix"), None);
    builder.add_longdata_handler("md", false, 1);
    builder.ld_call_01(
        "md",
        (
            &[
                0xab, 0xba, 0xaa, 0xbb, 0xbb, 0xba, 0xba, 0xaa, 0xbb, 0xaa, 0x1a, 0xb1,
            ],
            0,
            0,
        ),
        MINF_MR,
    );
    builder.i(MINF_STOP);
    {
        let (func1b, ret) = builder.add_routine("ma_check_fix", true);
        let mut func1b = func1b.borrow_mut();
        func1b.i(MINF_MR);
        func1b.i(MINF_TBRF);
        func1b.i(MINF_TBB);
        func1b.i((MINF_TBRW1, MINF_TBRW0, ret));
    }
    assert_eq!(
        (
            vec![
                MinInfInstr::new(MINF_MR, MINF_MR, 186, 186),
                (MINF_MR, MINF_MR, 175, 175).into(),
                (MINF_STOP, MINF_STOP, 3, 3).into(),
                (MINF_MARW1, MINF_MARW1, 4, 4).into(),
                (MINF_MARF, MINF_MARF, 5, 5).into(),
                (MINF_MARW0, MINF_MARW0, 6, 6).into(),
                (MINF_MARF, MINF_MARF, 7, 7).into(),
                (MINF_MARW0, MINF_MARW0, 8, 8).into(),
                (MINF_MARF, MINF_MARF, 9, 9).into(),
                (MINF_MARW0, MINF_MARW0, 10, 10).into(),
                (MINF_MARF, MINF_MARF, 15, 15).into(),
                (MINF_TBRW0, MINF_TBRW0, 12, 12).into(),
                (MINF_TBRF, MINF_TBRF, 3, 3).into(),
                (MINF_TBRW1, MINF_TBRW1, 14, 14).into(),
                (MINF_TBRF, MINF_TBRF, 3, 3).into(),
                (MINF_TBB, MINF_TBB, 16, 16).into(),
                (MINF_TBRW0, MINF_TBRW0, 17, 17).into(),
                (MINF_MR, MINF_MR, 101, 75).into(),
                (MINF_MARW0, MINF_MARW0, 19, 19).into(),
                (MINF_MARF, MINF_MARF, 20, 20).into(),
                (MINF_MARW1, MINF_MARW1, 21, 21).into(),
                (MINF_MARF, MINF_MARF, 22, 22).into(),
                (MINF_MARW0, MINF_MARW0, 23, 23).into(),
                (MINF_MARF, MINF_MARF, 24, 24).into(),
                (MINF_MARW1, MINF_MARW1, 25, 25).into(),
                (MINF_MARF, MINF_MARF, 46, 46).into(),
                (MINF_TBRW0, MINF_TBRW0, 27, 27).into(),
                (MINF_TBRF, MINF_TBRF, 36, 36).into(),
                (MINF_TBRW1, MINF_TBRW1, 29, 29).into(),
                (MINF_TBRF, MINF_TBRF, 36, 36).into(),
                (MINF_TBRW0, MINF_TBRW0, 31, 31).into(),
                (MINF_TBRF, MINF_TBRF, 38, 38).into(),
                (MINF_TBRW1, MINF_TBRW1, 33, 33).into(),
                (MINF_TBRF, MINF_TBRF, 38, 38).into(),
                (MINF_TBRW0, MINF_TBRW0, 35, 35).into(),
                (MINF_TBRF, MINF_TBRF, 40, 40).into(),
                (MINF_TBRW0, MINF_TBRW0, 37, 37).into(),
                (MINF_TBRF, MINF_TBRF, 42, 42).into(),
                (MINF_TBRW1, MINF_TBRW1, 39, 39).into(),
                (MINF_TBRF, MINF_TBRF, 42, 42).into(),
                (MINF_TBRW0, MINF_TBRW0, 41, 41).into(),
                (MINF_TBRF, MINF_TBRF, 44, 44).into(),
                (MINF_TBRW0, MINF_TBRW0, 43, 43).into(),
                (MINF_TBRF, MINF_TBRF, 18, 18).into(),
                (MINF_TBRW1, MINF_TBRW1, 45, 45).into(),
                (MINF_TBRF, MINF_TBRF, 18, 18).into(),
                (MINF_TBB, MINF_TBB, 47, 47).into(),
                (MINF_TBRW0, MINF_TBRW0, 48, 48).into(),
                (MINF_TBB, MINF_TBB, 49, 51).into(),
                (MINF_TBRW0, MINF_TBRW0, 50, 50).into(),
                (MINF_TBB, MINF_TBB, 53, 55).into(),
                (MINF_TBRW0, MINF_TBRW0, 52, 52).into(),
                (MINF_TBB, MINF_TBB, 57, 57).into(),
                (MINF_TBRW0, MINF_TBRW0, 54, 54).into(),
                (MINF_MR, MINF_MR, 120, 69).into(),
                (MINF_TBRW0, MINF_TBRW0, 56, 56).into(),
                (MINF_MR, MINF_MR, 32, 112).into(),
                (MINF_TBRW0, MINF_TBRW0, 58, 58).into(),
                (MINF_MR, MINF_MR, 11, 11).into(),
                (MINF_MARW1, MINF_MARW1, 60, 60).into(),
                (MINF_MARF, MINF_MARF, 61, 61).into(),
                (MINF_MARW1, MINF_MARW1, 62, 62).into(),
                (MINF_MARF, MINF_MARF, 63, 63).into(),
                (MINF_MARW0, MINF_MARW0, 64, 64).into(),
                (MINF_MARF, MINF_MARF, 65, 65).into(),
                (MINF_MARW1, MINF_MARW1, 66, 66).into(),
                (MINF_MARF, MINF_MARF, 87, 87).into(),
                (MINF_TBRW0, MINF_TBRW0, 68, 68).into(),
                (MINF_TBRF, MINF_TBRF, 77, 77).into(),
                (MINF_TBRW1, MINF_TBRW1, 70, 70).into(),
                (MINF_TBRF, MINF_TBRF, 77, 77).into(),
                (MINF_TBRW0, MINF_TBRW0, 72, 72).into(),
                (MINF_TBRF, MINF_TBRF, 79, 79).into(),
                (MINF_TBRW1, MINF_TBRW1, 74, 74).into(),
                (MINF_TBRF, MINF_TBRF, 79, 79).into(),
                (MINF_TBRW0, MINF_TBRW0, 76, 76).into(),
                (MINF_TBRF, MINF_TBRF, 81, 81).into(),
                (MINF_TBRW0, MINF_TBRW0, 78, 78).into(),
                (MINF_TBRF, MINF_TBRF, 83, 83).into(),
                (MINF_TBRW1, MINF_TBRW1, 80, 80).into(),
                (MINF_TBRF, MINF_TBRF, 83, 83).into(),
                (MINF_TBRW0, MINF_TBRW0, 82, 82).into(),
                (MINF_TBRF, MINF_TBRF, 85, 85).into(),
                (MINF_TBRW0, MINF_TBRW0, 84, 84).into(),
                (MINF_TBRF, MINF_TBRF, 59, 59).into(),
                (MINF_TBRW1, MINF_TBRW1, 86, 86).into(),
                (MINF_TBRF, MINF_TBRF, 59, 59).into(),
                (MINF_TBB, MINF_TBB, 88, 88).into(),
                (MINF_TBRW0, MINF_TBRW0, 89, 89).into(),
                (MINF_TBB, MINF_TBB, 90, 92).into(),
                (MINF_TBRW0, MINF_TBRW0, 91, 91).into(),
                (MINF_TBB, MINF_TBB, 94, 96).into(),
                (MINF_TBRW0, MINF_TBRW0, 93, 93).into(),
                (MINF_TBB, MINF_TBB, 98, 98).into(),
                (MINF_TBRW0, MINF_TBRW0, 95, 95).into(),
                (MINF_MR, MINF_MR, 26, 133).into(),
                (MINF_TBRW0, MINF_TBRW0, 97, 97).into(),
                (MINF_MR, MINF_MR, 73, 150).into(),
                (MINF_TBRW0, MINF_TBRW0, 99, 99).into(),
                (MINF_MR, MINF_MR, 122, 122).into(),
                (MINF_MR, MINF_MR, 34, 34).into(),
                (MINF_MR, MINF_MR, 121, 121).into(),
                (MINF_TBRW0, MINF_TBRW0, 103, 103).into(),
                (MINF_TBRF, MINF_TBRF, 108, 108).into(),
                (MINF_TBRW1, MINF_TBRW1, 105, 105).into(),
                (MINF_TBRF, MINF_TBRF, 108, 108).into(),
                (MINF_TBRW0, MINF_TBRW0, 107, 107).into(),
                (MINF_TBRF, MINF_TBRF, 110, 110).into(),
                (MINF_TBRW0, MINF_TBRW0, 109, 109).into(),
                (MINF_TBRF, MINF_TBRF, 30, 30).into(),
                (MINF_TBRW1, MINF_TBRW1, 111, 111).into(),
                (MINF_TBRF, MINF_TBRF, 30, 30).into(),
                (MINF_TBB, MINF_TBB, 113, 113).into(),
                (MINF_TBRW0, MINF_TBRW0, 114, 114).into(),
                (MINF_TBB, MINF_TBB, 115, 117).into(),
                (MINF_TBRW0, MINF_TBRW0, 116, 116).into(),
                (MINF_MR, MINF_MR, 140, 158).into(),
                (MINF_TBRW0, MINF_TBRW0, 118, 118).into(),
                (MINF_MR, MINF_MR, 160, 160).into(),
                (MINF_MR, MINF_MR, 67, 67).into(),
                (MINF_MR, MINF_MR, 123, 123).into(),
                (MINF_MR, MINF_MR, 13, 13).into(),
                (MINF_MR, MINF_MR, 162, 162).into(),
                (MINF_TBRW0, MINF_TBRW0, 124, 124).into(),
                (MINF_TBRF, MINF_TBRF, 129, 129).into(),
                (MINF_TBRW1, MINF_TBRW1, 126, 126).into(),
                (MINF_TBRF, MINF_TBRF, 129, 129).into(),
                (MINF_TBRW0, MINF_TBRW0, 128, 128).into(),
                (MINF_TBRF, MINF_TBRF, 131, 131).into(),
                (MINF_TBRW0, MINF_TBRW0, 130, 130).into(),
                (MINF_TBRF, MINF_TBRF, 28, 28).into(),
                (MINF_TBRW1, MINF_TBRW1, 132, 132).into(),
                (MINF_TBRF, MINF_TBRF, 28, 28).into(),
                (MINF_TBB, MINF_TBB, 134, 134).into(),
                (MINF_TBRW0, MINF_TBRW0, 135, 135).into(),
                (MINF_TBB, MINF_TBB, 136, 138).into(),
                (MINF_TBRW0, MINF_TBRW0, 137, 137).into(),
                (MINF_MR, MINF_MR, 164, 166).into(),
                (MINF_TBRW0, MINF_TBRW0, 139, 139).into(),
                (MINF_MR, MINF_MR, 104, 104).into(),
                (MINF_TBRW0, MINF_TBRW0, 141, 141).into(),
                (MINF_TBRF, MINF_TBRF, 146, 146).into(),
                (MINF_TBRW1, MINF_TBRW1, 143, 143).into(),
                (MINF_TBRF, MINF_TBRF, 146, 146).into(),
                (MINF_TBRW0, MINF_TBRW0, 145, 145).into(),
                (MINF_TBRF, MINF_TBRF, 148, 148).into(),
                (MINF_TBRW0, MINF_TBRW0, 147, 147).into(),
                (MINF_TBRF, MINF_TBRF, 71, 71).into(),
                (MINF_TBRW1, MINF_TBRW1, 149, 149).into(),
                (MINF_TBRF, MINF_TBRF, 71, 71).into(),
                (MINF_TBB, MINF_TBB, 151, 151).into(),
                (MINF_TBRW0, MINF_TBRW0, 152, 152).into(),
                (MINF_TBB, MINF_TBB, 153, 155).into(),
                (MINF_TBRW0, MINF_TBRW0, 154, 154).into(),
                (MINF_MR, MINF_MR, 168, 125).into(),
                (MINF_TBRW0, MINF_TBRW0, 156, 156).into(),
                (MINF_MR, MINF_MR, 106, 106).into(),
                (MINF_MR, MINF_MR, 127, 127).into(),
                (MINF_MR, MINF_MR, 170, 170).into(),
                (MINF_MR, MINF_MR, 144, 144).into(),
                (MINF_MR, MINF_MR, 161, 161).into(),
                (MINF_MR, MINF_MR, 100, 100).into(),
                (MINF_MR, MINF_MR, 172, 172).into(),
                (MINF_MR, MINF_MR, 119, 119).into(),
                (MINF_MR, MINF_MR, 167, 167).into(),
                (MINF_MR, MINF_MR, 142, 142).into(),
                (MINF_MR, MINF_MR, 157, 157).into(),
                (MINF_MR, MINF_MR, 102, 102).into(),
                (MINF_MR, MINF_MR, 174, 174).into(),
                (MINF_MR, MINF_MR, 165, 165).into(),
                (MINF_MR, MINF_MR, 176, 176).into(),
                (MINF_MR, MINF_MR, 159, 159).into(),
                (MINF_MR, MINF_MR, 2, 2).into(),
                (MINF_MR, MINF_MR, 163, 163).into(),
                (MINF_MR, MINF_MR, 169, 169).into(),
                (MINF_MR, MINF_MR, 173, 173).into(),
                (MINF_MR, MINF_MR, 171, 171).into(),
                (MINF_TBRW0, MINF_TBRW0, 178, 178).into(),
                (MINF_TBRF, MINF_TBRF, 179, 179).into(),
                (MINF_TBRW0, MINF_TBRW0, 180, 180).into(),
                (MINF_TBRF, MINF_TBRF, 195, 195).into(),
                (MINF_TBB, MINF_TBB, 182, 182).into(),
                (MINF_TBRW0, MINF_TBRW0, 183, 183).into(),
                (MINF_TBB, MINF_TBB, 184, 184).into(),
                (MINF_TBRW0, MINF_TBRW0, 185, 185).into(),
                (MINF_MR, MINF_MR, 206, 206).into(),
                (MINF_TBRW0, MINF_TBRW0, 187, 187).into(),
                (MINF_TBRF, MINF_TBRF, 188, 188).into(),
                (MINF_TBRW0, MINF_TBRW0, 189, 189).into(),
                (MINF_TBRF, MINF_TBRF, 199, 199).into(),
                (MINF_TBB, MINF_TBB, 191, 191).into(),
                (MINF_TBRW0, MINF_TBRW0, 192, 192).into(),
                (MINF_TBB, MINF_TBB, 193, 193).into(),
                (MINF_TBRW0, MINF_TBRW0, 194, 194).into(),
                (MINF_MR, MINF_MR, 1, 1).into(),
                (MINF_MR, MINF_MR, 196, 196).into(),
                (MINF_TBRF, MINF_TBRF, 197, 197).into(),
                (MINF_TBB, MINF_TBB, 198, 198).into(),
                (MINF_TBRW1, MINF_TBRW0, 181, 181).into(),
                (MINF_MARW1, MINF_MARW1, 200, 200).into(),
                (MINF_MARF, MINF_MARF, 201, 201).into(),
                (MINF_MARW1, MINF_MARW1, 202, 202).into(),
                (MINF_MARF, MINF_MARF, 203, 203).into(),
                (MINF_MARW1, MINF_MARW1, 204, 204).into(),
                (MINF_MARF, MINF_MARF, 205, 205).into(),
                (MINF_MR, MINF_MR, 177, 177).into(),
                (MINF_MR, MINF_MR, 190, 190).into(),
            ],
            vec![
                ("ma_check_fix".to_string(), 195),
                ("ma_check_fix:md".to_string(), 199),
                ("ma_check_fix:md_0_putret_1_0".to_string(), 188),
                ("ma_check_fix:md_0_putret_x_0".to_string(), 186),
                ("ma_check_fix:md_after_ret_0".to_string(), 1),
                ("ma_check_fix:md_return".to_string(), 190),
                ("ma_check_fix:md_return_id_0_0".to_string(), 191),
                ("ma_check_fix:md_return_id_1_0".to_string(), 193),
                ("ma_check_fix_0_putret_1_0".to_string(), 179),
                ("ma_check_fix_0_putret_x_0".to_string(), 177),
                ("ma_check_fix_after_ret_0".to_string(), 206),
                ("ma_check_fix_return".to_string(), 181),
                ("ma_check_fix_return_id_0_0".to_string(), 182),
                ("ma_check_fix_return_id_1_0".to_string(), 184),
                ("md_chunk_1_4".to_string(), 3),
                ("md_chunk_1_4_0_putret_x_0".to_string(), 11),
                ("md_chunk_1_4_0_putret_x_1".to_string(), 13),
                ("md_chunk_1_4_return".to_string(), 15),
                ("md_chunk_1_4_return_id_0_0".to_string(), 16),
                ("md_chunk_1a_8_0_putret_x_0".to_string(), 100),
                ("md_chunk_1a_8_return".to_string(), 101),
                ("md_chunk_a_4".to_string(), 18),
                ("md_chunk_a_4_0_putret_1_0".to_string(), 42),
                ("md_chunk_a_4_0_putret_1_1".to_string(), 44),
                ("md_chunk_a_4_0_putret_2_00".to_string(), 36),
                ("md_chunk_a_4_0_putret_2_01".to_string(), 38),
                ("md_chunk_a_4_0_putret_2_10".to_string(), 40),
                ("md_chunk_a_4_0_putret_x_0".to_string(), 26),
                ("md_chunk_a_4_0_putret_x_1".to_string(), 28),
                ("md_chunk_a_4_0_putret_x_10".to_string(), 30),
                ("md_chunk_a_4_0_putret_x_100".to_string(), 34),
                ("md_chunk_a_4_0_putret_x_11".to_string(), 32),
                ("md_chunk_a_4_return".to_string(), 46),
                ("md_chunk_a_4_return_id_0_0".to_string(), 47),
                ("md_chunk_a_4_return_id_1_0".to_string(), 49),
                ("md_chunk_a_4_return_id_1_1".to_string(), 51),
                ("md_chunk_a_4_return_id_2_00".to_string(), 53),
                ("md_chunk_a_4_return_id_2_01".to_string(), 55),
                ("md_chunk_a_4_return_id_2_10".to_string(), 57),
                ("md_chunk_aa_8_0_putret_1_0".to_string(), 108),
                ("md_chunk_aa_8_0_putret_1_1".to_string(), 110),
                ("md_chunk_aa_8_0_putret_x_0".to_string(), 102),
                ("md_chunk_aa_8_0_putret_x_1".to_string(), 104),
                ("md_chunk_aa_8_0_putret_x_10".to_string(), 106),
                ("md_chunk_aa_8_return".to_string(), 112),
                ("md_chunk_aa_8_return_id_0_0".to_string(), 113),
                ("md_chunk_aa_8_return_id_1_0".to_string(), 115),
                ("md_chunk_aa_8_return_id_1_1".to_string(), 117),
                ("md_chunk_aaba_16_0_putret_x_0".to_string(), 157),
                ("md_chunk_aaba_16_return".to_string(), 158),
                ("md_chunk_aabababb_32_0_putret_x_0".to_string(), 169),
                ("md_chunk_aabababb_32_return".to_string(), 170),
                ("md_chunk_aabababbbbaabaab_64_0_putret_x_0".to_string(), 175),
                ("md_chunk_aabababbbbaabaab_64_return".to_string(), 176),
                ("md_chunk_aabb_16_0_putret_x_0".to_string(), 159),
                ("md_chunk_aabb_16_return".to_string(), 160),
                ("md_chunk_ab_8_0_putret_x_0".to_string(), 119),
                ("md_chunk_ab_8_return".to_string(), 120),
                ("md_chunk_b11a_16_0_putret_x_0".to_string(), 161),
                ("md_chunk_b11a_16_return".to_string(), 162),
                ("md_chunk_b11aaabb_32_0_putret_x_0".to_string(), 171),
                ("md_chunk_b11aaabb_32_return".to_string(), 172),
                ("md_chunk_b1_8_0_putret_x_0".to_string(), 121),
                ("md_chunk_b1_8_return".to_string(), 122),
                ("md_chunk_b_4".to_string(), 59),
                ("md_chunk_b_4_0_putret_1_0".to_string(), 83),
                ("md_chunk_b_4_0_putret_1_1".to_string(), 85),
                ("md_chunk_b_4_0_putret_2_00".to_string(), 77),
                ("md_chunk_b_4_0_putret_2_01".to_string(), 79),
                ("md_chunk_b_4_0_putret_2_10".to_string(), 81),
                ("md_chunk_b_4_0_putret_x_0".to_string(), 67),
                ("md_chunk_b_4_0_putret_x_1".to_string(), 69),
                ("md_chunk_b_4_0_putret_x_10".to_string(), 71),
                ("md_chunk_b_4_0_putret_x_100".to_string(), 75),
                ("md_chunk_b_4_0_putret_x_11".to_string(), 73),
                ("md_chunk_b_4_return".to_string(), 87),
                ("md_chunk_b_4_return_id_0_0".to_string(), 88),
                ("md_chunk_b_4_return_id_1_0".to_string(), 90),
                ("md_chunk_b_4_return_id_1_1".to_string(), 92),
                ("md_chunk_b_4_return_id_2_00".to_string(), 94),
                ("md_chunk_b_4_return_id_2_01".to_string(), 96),
                ("md_chunk_b_4_return_id_2_10".to_string(), 98),
                ("md_chunk_ba_8_0_putret_1_0".to_string(), 129),
                ("md_chunk_ba_8_0_putret_1_1".to_string(), 131),
                ("md_chunk_ba_8_0_putret_x_0".to_string(), 123),
                ("md_chunk_ba_8_0_putret_x_1".to_string(), 125),
                ("md_chunk_ba_8_0_putret_x_10".to_string(), 127),
                ("md_chunk_ba_8_return".to_string(), 133),
                ("md_chunk_ba_8_return_id_0_0".to_string(), 134),
                ("md_chunk_ba_8_return_id_1_0".to_string(), 136),
                ("md_chunk_ba_8_return_id_1_1".to_string(), 138),
                ("md_chunk_baab_16_0_putret_x_0".to_string(), 163),
                ("md_chunk_baab_16_return".to_string(), 164),
                ("md_chunk_babb_16_0_putret_x_0".to_string(), 165),
                ("md_chunk_babb_16_return".to_string(), 166),
                ("md_chunk_bb_8_0_putret_1_0".to_string(), 146),
                ("md_chunk_bb_8_0_putret_1_1".to_string(), 148),
                ("md_chunk_bb_8_0_putret_x_0".to_string(), 140),
                ("md_chunk_bb_8_0_putret_x_1".to_string(), 142),
                ("md_chunk_bb_8_0_putret_x_10".to_string(), 144),
                ("md_chunk_bb_8_return".to_string(), 150),
                ("md_chunk_bb_8_return_id_0_0".to_string(), 151),
                ("md_chunk_bb_8_return_id_1_0".to_string(), 153),
                ("md_chunk_bb_8_return_id_1_1".to_string(), 155),
                ("md_chunk_bbaa_16_0_putret_x_0".to_string(), 167),
                ("md_chunk_bbaa_16_return".to_string(), 168),
                ("md_chunk_bbaabaab_32_0_putret_x_0".to_string(), 173),
                ("md_chunk_bbaabaab_32_return".to_string(), 174),
                ("md_next_0".to_string(), 2),
            ]
        ),
        builder.to_code()
    );
    // with tb long data
    //
    let mut builder = mi_simple_hbuilder_new_1_safe_ldh(None, None, Some("tb_check_fix"));
    builder.add_longdata_handler("tb", true, 1);
    builder.ld_call_01(
        "tb",
        (
            &[0xaa, 0xba, 0x56, 0x51, 0x84, 0xc5, 0xd3, 0xba, 0x56, 0x51],
            0xc,
            4,
        ),
        MINF_MR,
    );
    builder.ld_call_01("tb", (&[0x22, 0x33], 0, 0), MINF_MR);
    builder.i(MINF_STOP);
    {
        let (func1b, ret) = builder.add_routine("tb_check_fix", false);
        let mut func1b = func1b.borrow_mut();
        func1b.i(MINF_MR);
        func1b.i(MINF_TBRF);
        func1b.i(MINF_TBB);
        func1b.i((MINF_TBRW1, MINF_TBRW0, ret));
    }
    assert_eq!(
        (
            vec![
                MinInfInstr::new(MINF_MR, MINF_MR, 217, 217),
                (MINF_MR, MINF_MR, 213, 213).into(),
                (MINF_MR, MINF_MR, 192, 192).into(),
                (MINF_STOP, MINF_STOP, 4, 4).into(),
                (MINF_TBRW1, MINF_TBRW1, 5, 5).into(),
                (MINF_TBRF, MINF_TBRF, 6, 6).into(),
                (MINF_TBRW0, MINF_TBRW0, 7, 7).into(),
                (MINF_TBRF, MINF_TBRF, 8, 8).into(),
                (MINF_TBRW0, MINF_TBRW0, 9, 9).into(),
                (MINF_TBRF, MINF_TBRF, 10, 10).into(),
                (MINF_TBRW0, MINF_TBRW0, 11, 11).into(),
                (MINF_TBRF, MINF_TBRF, 13, 13).into(),
                (MINF_MR, MINF_MR, 4, 4).into(),
                (MINF_MR, MINF_MR, 74, 74).into(),
                (MINF_TBRW0, MINF_TBRW0, 15, 15).into(),
                (MINF_TBRF, MINF_TBRF, 16, 16).into(),
                (MINF_TBRW1, MINF_TBRW1, 17, 17).into(),
                (MINF_TBRF, MINF_TBRF, 18, 18).into(),
                (MINF_TBRW0, MINF_TBRW0, 19, 19).into(),
                (MINF_TBRF, MINF_TBRF, 20, 20).into(),
                (MINF_TBRW0, MINF_TBRW0, 21, 21).into(),
                (MINF_TBRF, MINF_TBRF, 26, 26).into(),
                (MINF_MARW0, MINF_MARW0, 23, 23).into(),
                (MINF_MARF, MINF_MARF, 14, 14).into(),
                (MINF_MARW1, MINF_MARW1, 25, 25).into(),
                (MINF_MARF, MINF_MARF, 14, 14).into(),
                (MINF_MAB, MINF_MAB, 27, 27).into(),
                (MINF_MARW0, MINF_MARW0, 28, 28).into(),
                (MINF_MR, MINF_MR, 24, 170).into(),
                (MINF_TBRW1, MINF_TBRW1, 30, 30).into(),
                (MINF_TBRF, MINF_TBRF, 31, 31).into(),
                (MINF_TBRW1, MINF_TBRW1, 32, 32).into(),
                (MINF_TBRF, MINF_TBRF, 33, 33).into(),
                (MINF_TBRW0, MINF_TBRW0, 34, 34).into(),
                (MINF_TBRF, MINF_TBRF, 35, 35).into(),
                (MINF_TBRW0, MINF_TBRW0, 36, 36).into(),
                (MINF_TBRF, MINF_TBRF, 47, 47).into(),
                (MINF_MARW0, MINF_MARW0, 38, 38).into(),
                (MINF_MARF, MINF_MARF, 43, 43).into(),
                (MINF_MARW1, MINF_MARW1, 40, 40).into(),
                (MINF_MARF, MINF_MARF, 43, 43).into(),
                (MINF_MARW0, MINF_MARW0, 42, 42).into(),
                (MINF_MARF, MINF_MARF, 45, 45).into(),
                (MINF_MARW0, MINF_MARW0, 44, 44).into(),
                (MINF_MARF, MINF_MARF, 29, 29).into(),
                (MINF_MARW1, MINF_MARW1, 46, 46).into(),
                (MINF_MARF, MINF_MARF, 29, 29).into(),
                (MINF_MAB, MINF_MAB, 48, 48).into(),
                (MINF_MARW0, MINF_MARW0, 49, 49).into(),
                (MINF_MAB, MINF_MAB, 50, 52).into(),
                (MINF_MARW0, MINF_MARW0, 51, 51).into(),
                (MINF_MR, MINF_MR, 167, 41).into(),
                (MINF_MARW0, MINF_MARW0, 53, 53).into(),
                (MINF_MR, MINF_MR, 172, 172).into(),
                (MINF_TBRW0, MINF_TBRW0, 55, 55).into(),
                (MINF_TBRF, MINF_TBRF, 56, 56).into(),
                (MINF_TBRW0, MINF_TBRW0, 57, 57).into(),
                (MINF_TBRF, MINF_TBRF, 58, 58).into(),
                (MINF_TBRW1, MINF_TBRW1, 59, 59).into(),
                (MINF_TBRF, MINF_TBRF, 60, 60).into(),
                (MINF_TBRW0, MINF_TBRW0, 61, 61).into(),
                (MINF_TBRF, MINF_TBRF, 63, 63).into(),
                (MINF_MR, MINF_MR, 54, 54).into(),
                (MINF_MR, MINF_MR, 107, 107).into(),
                (MINF_TBRW1, MINF_TBRW1, 65, 65).into(),
                (MINF_TBRF, MINF_TBRF, 66, 66).into(),
                (MINF_TBRW0, MINF_TBRW0, 67, 67).into(),
                (MINF_TBRF, MINF_TBRF, 68, 68).into(),
                (MINF_TBRW1, MINF_TBRW1, 69, 69).into(),
                (MINF_TBRF, MINF_TBRF, 70, 70).into(),
                (MINF_TBRW0, MINF_TBRW0, 71, 71).into(),
                (MINF_TBRF, MINF_TBRF, 82, 82).into(),
                (MINF_MARW0, MINF_MARW0, 73, 73).into(),
                (MINF_MARF, MINF_MARF, 78, 78).into(),
                (MINF_MARW1, MINF_MARW1, 75, 75).into(),
                (MINF_MARF, MINF_MARF, 78, 78).into(),
                (MINF_MARW0, MINF_MARW0, 77, 77).into(),
                (MINF_MARF, MINF_MARF, 80, 80).into(),
                (MINF_MARW0, MINF_MARW0, 79, 79).into(),
                (MINF_MARF, MINF_MARF, 64, 64).into(),
                (MINF_MARW1, MINF_MARW1, 81, 81).into(),
                (MINF_MARF, MINF_MARF, 64, 64).into(),
                (MINF_MAB, MINF_MAB, 83, 83).into(),
                (MINF_MARW0, MINF_MARW0, 84, 84).into(),
                (MINF_MAB, MINF_MAB, 85, 87).into(),
                (MINF_MARW0, MINF_MARW0, 86, 86).into(),
                (MINF_MR, MINF_MR, 176, 174).into(),
                (MINF_MARW0, MINF_MARW0, 88, 88).into(),
                (MINF_MR, MINF_MR, 152, 152).into(),
                (MINF_TBRW0, MINF_TBRW0, 90, 90).into(),
                (MINF_TBRF, MINF_TBRF, 91, 91).into(),
                (MINF_TBRW1, MINF_TBRW1, 92, 92).into(),
                (MINF_TBRF, MINF_TBRF, 93, 93).into(),
                (MINF_TBRW1, MINF_TBRW1, 94, 94).into(),
                (MINF_TBRF, MINF_TBRF, 95, 95).into(),
                (MINF_TBRW0, MINF_TBRW0, 96, 96).into(),
                (MINF_TBRF, MINF_TBRF, 98, 98).into(),
                (MINF_MR, MINF_MR, 89, 89).into(),
                (MINF_MR, MINF_MR, 72, 72).into(),
                (MINF_TBRW0, MINF_TBRW0, 100, 100).into(),
                (MINF_TBRF, MINF_TBRF, 101, 101).into(),
                (MINF_TBRW0, MINF_TBRW0, 102, 102).into(),
                (MINF_TBRF, MINF_TBRF, 103, 103).into(),
                (MINF_TBRW0, MINF_TBRW0, 104, 104).into(),
                (MINF_TBRF, MINF_TBRF, 105, 105).into(),
                (MINF_TBRW1, MINF_TBRW1, 106, 106).into(),
                (MINF_TBRF, MINF_TBRF, 108, 108).into(),
                (MINF_MR, MINF_MR, 99, 99).into(),
                (MINF_MR, MINF_MR, 178, 178).into(),
                (MINF_TBRW0, MINF_TBRW0, 110, 110).into(),
                (MINF_TBRF, MINF_TBRF, 111, 111).into(),
                (MINF_TBRW1, MINF_TBRW1, 112, 112).into(),
                (MINF_TBRF, MINF_TBRF, 113, 113).into(),
                (MINF_TBRW0, MINF_TBRW0, 114, 114).into(),
                (MINF_TBRF, MINF_TBRF, 115, 115).into(),
                (MINF_TBRW1, MINF_TBRW1, 116, 116).into(),
                (MINF_TBRF, MINF_TBRF, 127, 127).into(),
                (MINF_MARW0, MINF_MARW0, 118, 118).into(),
                (MINF_MARF, MINF_MARF, 123, 123).into(),
                (MINF_MARW1, MINF_MARW1, 120, 120).into(),
                (MINF_MARF, MINF_MARF, 123, 123).into(),
                (MINF_MARW0, MINF_MARW0, 122, 122).into(),
                (MINF_MARF, MINF_MARF, 125, 125).into(),
                (MINF_MARW0, MINF_MARW0, 124, 124).into(),
                (MINF_MARF, MINF_MARF, 109, 109).into(),
                (MINF_MARW1, MINF_MARW1, 126, 126).into(),
                (MINF_MARF, MINF_MARF, 109, 109).into(),
                (MINF_MAB, MINF_MAB, 128, 128).into(),
                (MINF_MARW0, MINF_MARW0, 129, 129).into(),
                (MINF_MAB, MINF_MAB, 130, 132).into(),
                (MINF_MARW0, MINF_MARW0, 131, 131).into(),
                (MINF_MR, MINF_MR, 119, 180).into(),
                (MINF_MARW0, MINF_MARW0, 133, 133).into(),
                (MINF_MR, MINF_MR, 142, 142).into(),
                (MINF_TBRW1, MINF_TBRW1, 135, 135).into(),
                (MINF_TBRF, MINF_TBRF, 136, 136).into(),
                (MINF_TBRW1, MINF_TBRW1, 137, 137).into(),
                (MINF_TBRF, MINF_TBRF, 138, 138).into(),
                (MINF_TBRW0, MINF_TBRW0, 139, 139).into(),
                (MINF_TBRF, MINF_TBRF, 140, 140).into(),
                (MINF_TBRW1, MINF_TBRW1, 141, 141).into(),
                (MINF_TBRF, MINF_TBRF, 143, 143).into(),
                (MINF_MR, MINF_MR, 134, 134).into(),
                (MINF_MR, MINF_MR, 185, 185).into(),
                (MINF_TBRW0, MINF_TBRW0, 145, 145).into(),
                (MINF_TBRF, MINF_TBRF, 146, 146).into(),
                (MINF_TBRW0, MINF_TBRW0, 147, 147).into(),
                (MINF_TBRF, MINF_TBRF, 148, 148).into(),
                (MINF_TBRW1, MINF_TBRW1, 149, 149).into(),
                (MINF_TBRF, MINF_TBRF, 150, 150).into(),
                (MINF_TBRW1, MINF_TBRW1, 151, 151).into(),
                (MINF_TBRF, MINF_TBRF, 156, 156).into(),
                (MINF_MARW0, MINF_MARW0, 153, 153).into(),
                (MINF_MARF, MINF_MARF, 144, 144).into(),
                (MINF_MARW1, MINF_MARW1, 155, 155).into(),
                (MINF_MARF, MINF_MARF, 144, 144).into(),
                (MINF_MAB, MINF_MAB, 157, 157).into(),
                (MINF_MARW0, MINF_MARW0, 158, 158).into(),
                (MINF_MR, MINF_MR, 189, 208).into(),
                (MINF_TBRW1, MINF_TBRW1, 160, 160).into(),
                (MINF_TBRF, MINF_TBRF, 161, 161).into(),
                (MINF_TBRW0, MINF_TBRW0, 162, 162).into(),
                (MINF_TBRF, MINF_TBRF, 163, 163).into(),
                (MINF_TBRW1, MINF_TBRW1, 164, 164).into(),
                (MINF_TBRF, MINF_TBRF, 165, 165).into(),
                (MINF_TBRW1, MINF_TBRW1, 166, 166).into(),
                (MINF_TBRF, MINF_TBRF, 168, 168).into(),
                (MINF_MR, MINF_MR, 159, 159).into(),
                (MINF_MR, MINF_MR, 191, 191).into(),
                (MINF_MR, MINF_MR, 22, 22).into(),
                (MINF_MR, MINF_MR, 171, 171).into(),
                (MINF_MR, MINF_MR, 39, 39).into(),
                (MINF_MR, MINF_MR, 193, 193).into(),
                (MINF_MR, MINF_MR, 12, 12).into(),
                (MINF_MR, MINF_MR, 198, 198).into(),
                (MINF_MR, MINF_MR, 97, 97).into(),
                (MINF_MR, MINF_MR, 173, 173).into(),
                (MINF_MR, MINF_MR, 62, 62).into(),
                (MINF_MR, MINF_MR, 188, 188).into(),
                (MINF_MR, MINF_MR, 117, 117).into(),
                (MINF_MR, MINF_MR, 181, 181).into(),
                (MINF_MARW0, MINF_MARW0, 182, 182).into(),
                (MINF_MARF, MINF_MARF, 121, 121).into(),
                (MINF_MARW1, MINF_MARW1, 184, 184).into(),
                (MINF_MARF, MINF_MARF, 121, 121).into(),
                (MINF_MAB, MINF_MAB, 186, 186).into(),
                (MINF_MARW0, MINF_MARW0, 187, 187).into(),
                (MINF_MR, MINF_MR, 202, 204).into(),
                (MINF_MR, MINF_MR, 76, 76).into(),
                (MINF_MR, MINF_MR, 206, 206).into(),
                (MINF_MR, MINF_MR, 37, 37).into(),
                (MINF_MR, MINF_MR, 183, 183).into(),
                (MINF_MR, MINF_MR, 169, 169).into(),
                (MINF_MR, MINF_MR, 3, 3).into(),
                (MINF_MARW0, MINF_MARW0, 195, 195).into(),
                (MINF_MARF, MINF_MARF, 175, 175).into(),
                (MINF_MARW1, MINF_MARW1, 197, 197).into(),
                (MINF_MARF, MINF_MARF, 175, 175).into(),
                (MINF_MAB, MINF_MAB, 199, 199).into(),
                (MINF_MARW0, MINF_MARW0, 200, 200).into(),
                (MINF_MR, MINF_MR, 210, 154).into(),
                (MINF_MR, MINF_MR, 179, 179).into(),
                (MINF_MR, MINF_MR, 194, 194).into(),
                (MINF_MR, MINF_MR, 190, 190).into(),
                (MINF_MR, MINF_MR, 212, 212).into(),
                (MINF_MR, MINF_MR, 177, 177).into(),
                (MINF_MR, MINF_MR, 203, 203).into(),
                (MINF_MR, MINF_MR, 196, 196).into(),
                (MINF_MR, MINF_MR, 2, 2).into(),
                (MINF_MR, MINF_MR, 201, 201).into(),
                (MINF_MR, MINF_MR, 211, 211).into(),
                (MINF_MR, MINF_MR, 205, 205).into(),
                (MINF_MR, MINF_MR, 214, 214).into(),
                (MINF_MR, MINF_MR, 209, 209).into(),
                (MINF_MR, MINF_MR, 207, 207).into(),
                (MINF_MR, MINF_MR, 219, 219).into(),
                (MINF_MR, MINF_MR, 234, 234).into(),
                (MINF_MR, MINF_MR, 223, 223).into(),
                (MINF_MR, MINF_MR, 1, 1).into(),
                (MINF_MR, MINF_MR, 220, 220).into(),
                (MINF_TBRF, MINF_TBRF, 221, 221).into(),
                (MINF_TBB, MINF_TBB, 222, 222).into(),
                (MINF_TBRW1, MINF_TBRW0, 216, 216).into(),
                (MINF_TBRW1, MINF_TBRW1, 224, 224).into(),
                (MINF_TBRF, MINF_TBRF, 225, 225).into(),
                (MINF_TBRW1, MINF_TBRW1, 226, 226).into(),
                (MINF_TBRF, MINF_TBRF, 227, 227).into(),
                (MINF_TBRW0, MINF_TBRW0, 228, 228).into(),
                (MINF_TBRF, MINF_TBRF, 229, 229).into(),
                (MINF_TBRW1, MINF_TBRW1, 230, 230).into(),
                (MINF_TBRF, MINF_TBRF, 231, 231).into(),
                (MINF_TBRW1, MINF_TBRW1, 232, 232).into(),
                (MINF_TBRF, MINF_TBRF, 233, 233).into(),
                (MINF_MR, MINF_MR, 215, 215).into(),
                (MINF_MR, MINF_MR, 218, 218).into(),
            ],
            vec![
                ("tb_check_fix".to_string(), 219),
                ("tb_check_fix:tb".to_string(), 223),
                ("tb_check_fix:tb_0_putret_x_0".to_string(), 217),
                ("tb_check_fix:tb_after_ret_0".to_string(), 1),
                ("tb_check_fix:tb_return".to_string(), 218),
                ("tb_check_fix_0_putret_x_0".to_string(), 215),
                ("tb_check_fix_after_ret_0".to_string(), 234),
                ("tb_check_fix_return".to_string(), 216),
                ("tb_chunk_1_4".to_string(), 4),
                ("tb_chunk_1_4_0_putret_x_0".to_string(), 12),
                ("tb_chunk_1_4_return".to_string(), 13),
                ("tb_chunk_22_8_0_putret_x_0".to_string(), 169),
                ("tb_chunk_22_8_return".to_string(), 170),
                ("tb_chunk_2_4".to_string(), 14),
                ("tb_chunk_2_4_0_putret_x_0".to_string(), 22),
                ("tb_chunk_2_4_0_putret_x_1".to_string(), 24),
                ("tb_chunk_2_4_return".to_string(), 26),
                ("tb_chunk_2_4_return_id_0_0".to_string(), 27),
                ("tb_chunk_3322_16_0_putret_x_0".to_string(), 192),
                ("tb_chunk_3322_16_return".to_string(), 193),
                ("tb_chunk_33_8_0_putret_x_0".to_string(), 171),
                ("tb_chunk_33_8_return".to_string(), 172),
                ("tb_chunk_3_4".to_string(), 29),
                ("tb_chunk_3_4_0_putret_1_0".to_string(), 43),
                ("tb_chunk_3_4_0_putret_1_1".to_string(), 45),
                ("tb_chunk_3_4_0_putret_x_0".to_string(), 37),
                ("tb_chunk_3_4_0_putret_x_1".to_string(), 39),
                ("tb_chunk_3_4_0_putret_x_10".to_string(), 41),
                ("tb_chunk_3_4_return".to_string(), 47),
                ("tb_chunk_3_4_return_id_0_0".to_string(), 48),
                ("tb_chunk_3_4_return_id_1_0".to_string(), 50),
                ("tb_chunk_3_4_return_id_1_1".to_string(), 52),
                ("tb_chunk_4_4".to_string(), 54),
                ("tb_chunk_4_4_0_putret_x_0".to_string(), 62),
                ("tb_chunk_4_4_return".to_string(), 63),
                ("tb_chunk_5156_16_0_putret_x_0".to_string(), 194),
                ("tb_chunk_5156_16_0_putret_x_1".to_string(), 196),
                ("tb_chunk_5156_16_return".to_string(), 198),
                ("tb_chunk_5156_16_return_id_0_0".to_string(), 199),
                ("tb_chunk_5156baaa_32_0_putret_x_0".to_string(), 209),
                ("tb_chunk_5156baaa_32_return".to_string(), 210),
                ("tb_chunk_51_8_0_putret_x_0".to_string(), 173),
                ("tb_chunk_51_8_return".to_string(), 174),
                ("tb_chunk_56_8_0_putret_x_0".to_string(), 175),
                ("tb_chunk_56_8_return".to_string(), 176),
                ("tb_chunk_5_4".to_string(), 64),
                ("tb_chunk_5_4_0_putret_1_0".to_string(), 78),
                ("tb_chunk_5_4_0_putret_1_1".to_string(), 80),
                ("tb_chunk_5_4_0_putret_x_0".to_string(), 72),
                ("tb_chunk_5_4_0_putret_x_1".to_string(), 74),
                ("tb_chunk_5_4_0_putret_x_10".to_string(), 76),
                ("tb_chunk_5_4_return".to_string(), 82),
                ("tb_chunk_5_4_return_id_0_0".to_string(), 83),
                ("tb_chunk_5_4_return_id_1_0".to_string(), 85),
                ("tb_chunk_5_4_return_id_1_1".to_string(), 87),
                ("tb_chunk_6_4".to_string(), 89),
                ("tb_chunk_6_4_0_putret_x_0".to_string(), 97),
                ("tb_chunk_6_4_return".to_string(), 98),
                ("tb_chunk_84_8_0_putret_x_0".to_string(), 177),
                ("tb_chunk_84_8_return".to_string(), 178),
                ("tb_chunk_8_4".to_string(), 99),
                ("tb_chunk_8_4_0_putret_x_0".to_string(), 107),
                ("tb_chunk_8_4_return".to_string(), 108),
                ("tb_chunk_a_4".to_string(), 109),
                ("tb_chunk_a_4_0_putret_1_0".to_string(), 123),
                ("tb_chunk_a_4_0_putret_1_1".to_string(), 125),
                ("tb_chunk_a_4_0_putret_x_0".to_string(), 117),
                ("tb_chunk_a_4_0_putret_x_1".to_string(), 119),
                ("tb_chunk_a_4_0_putret_x_10".to_string(), 121),
                ("tb_chunk_a_4_return".to_string(), 127),
                ("tb_chunk_a_4_return_id_0_0".to_string(), 128),
                ("tb_chunk_a_4_return_id_1_0".to_string(), 130),
                ("tb_chunk_a_4_return_id_1_1".to_string(), 132),
                ("tb_chunk_aa_8_0_putret_x_0".to_string(), 179),
                ("tb_chunk_aa_8_return".to_string(), 180),
                ("tb_chunk_b_4".to_string(), 134),
                ("tb_chunk_b_4_0_putret_x_0".to_string(), 142),
                ("tb_chunk_b_4_return".to_string(), 143),
                ("tb_chunk_ba_8_0_putret_x_0".to_string(), 181),
                ("tb_chunk_ba_8_0_putret_x_1".to_string(), 183),
                ("tb_chunk_ba_8_return".to_string(), 185),
                ("tb_chunk_ba_8_return_id_0_0".to_string(), 186),
                ("tb_chunk_baaa_16_0_putret_x_0".to_string(), 201),
                ("tb_chunk_baaa_16_return".to_string(), 202),
                ("tb_chunk_bad3_16_0_putret_x_0".to_string(), 203),
                ("tb_chunk_bad3_16_return".to_string(), 204),
                ("tb_chunk_bad3c5845156baaa_64_0_putret_x_0".to_string(), 213),
                ("tb_chunk_bad3c5845156baaa_64_return".to_string(), 214),
                ("tb_chunk_bad3c584_32_0_putret_x_0".to_string(), 211),
                ("tb_chunk_bad3c584_32_return".to_string(), 212),
                ("tb_chunk_c5156_20_0_putret_x_0".to_string(), 207),
                ("tb_chunk_c5156_20_return".to_string(), 208),
                ("tb_chunk_c584_16_0_putret_x_0".to_string(), 205),
                ("tb_chunk_c584_16_return".to_string(), 206),
                ("tb_chunk_c5_8_0_putret_x_0".to_string(), 188),
                ("tb_chunk_c5_8_return".to_string(), 189),
                ("tb_chunk_c_4".to_string(), 144),
                ("tb_chunk_c_4_0_putret_x_0".to_string(), 152),
                ("tb_chunk_c_4_0_putret_x_1".to_string(), 154),
                ("tb_chunk_c_4_return".to_string(), 156),
                ("tb_chunk_c_4_return_id_0_0".to_string(), 157),
                ("tb_chunk_d3_8_0_putret_x_0".to_string(), 190),
                ("tb_chunk_d3_8_return".to_string(), 191),
                ("tb_chunk_d_4".to_string(), 159),
                ("tb_chunk_d_4_0_putret_x_0".to_string(), 167),
                ("tb_chunk_d_4_return".to_string(), 168),
                ("tb_next_0".to_string(), 2),
                ("tb_next_1".to_string(), 3),
            ]
        ),
        builder.to_code()
    );
    // // with mem_address return_bits=2. 5 - 2*2 = 1 - generates 1 extra bit in stack to check.
    let mut builder = mi_simple_hbuilder_new_safe_ldh(Some(2), None, None, Some("tb_check_fix"));
    builder.add_longdata_handler("tb", true, 1);
    builder.ld_call_01(
        "tb",
        (
            &[
                0xab, 0xba, 0xaa, 0xbb, 0xbb, 0xba, 0xba, 0xaa, 0xbb, 0xaa, 0x1a, 0xb1,
            ],
            0,
            0,
        ),
        MINF_MR,
    );
    builder.i(MINF_STOP);
    {
        let (func1b, ret) = builder.add_routine("tb_check_fix", false);
        let mut func1b = func1b.borrow_mut();
        func1b.i(MINF_MR);
        func1b.i(MINF_TBRF);
        func1b.i(MINF_TBB);
        func1b.i((MINF_TBRW1, MINF_TBRW0, ret));
    }
    assert_eq!(
        (
            vec![
                MinInfInstr::new(MINF_MR, MINF_MR, 186, 186),
                (MINF_MR, MINF_MR, 175, 175).into(),
                (MINF_STOP, MINF_STOP, 3, 3).into(),
                (MINF_TBRW1, MINF_TBRW1, 4, 4).into(),
                (MINF_TBRF, MINF_TBRF, 5, 5).into(),
                (MINF_TBRW0, MINF_TBRW0, 6, 6).into(),
                (MINF_TBRF, MINF_TBRF, 7, 7).into(),
                (MINF_TBRW0, MINF_TBRW0, 8, 8).into(),
                (MINF_TBRF, MINF_TBRF, 9, 9).into(),
                (MINF_TBRW0, MINF_TBRW0, 10, 10).into(),
                (MINF_TBRF, MINF_TBRF, 15, 15).into(),
                (MINF_MARW0, MINF_MARW0, 12, 12).into(),
                (MINF_MARF, MINF_MARF, 3, 3).into(),
                (MINF_MARW1, MINF_MARW1, 14, 14).into(),
                (MINF_MARF, MINF_MARF, 3, 3).into(),
                (MINF_MAB, MINF_MAB, 16, 16).into(),
                (MINF_MARW0, MINF_MARW0, 17, 17).into(),
                (MINF_MR, MINF_MR, 101, 75).into(),
                (MINF_TBRW0, MINF_TBRW0, 19, 19).into(),
                (MINF_TBRF, MINF_TBRF, 20, 20).into(),
                (MINF_TBRW1, MINF_TBRW1, 21, 21).into(),
                (MINF_TBRF, MINF_TBRF, 22, 22).into(),
                (MINF_TBRW0, MINF_TBRW0, 23, 23).into(),
                (MINF_TBRF, MINF_TBRF, 24, 24).into(),
                (MINF_TBRW1, MINF_TBRW1, 25, 25).into(),
                (MINF_TBRF, MINF_TBRF, 46, 46).into(),
                (MINF_MARW0, MINF_MARW0, 27, 27).into(),
                (MINF_MARF, MINF_MARF, 36, 36).into(),
                (MINF_MARW1, MINF_MARW1, 29, 29).into(),
                (MINF_MARF, MINF_MARF, 36, 36).into(),
                (MINF_MARW0, MINF_MARW0, 31, 31).into(),
                (MINF_MARF, MINF_MARF, 38, 38).into(),
                (MINF_MARW1, MINF_MARW1, 33, 33).into(),
                (MINF_MARF, MINF_MARF, 38, 38).into(),
                (MINF_MARW0, MINF_MARW0, 35, 35).into(),
                (MINF_MARF, MINF_MARF, 40, 40).into(),
                (MINF_MARW0, MINF_MARW0, 37, 37).into(),
                (MINF_MARF, MINF_MARF, 42, 42).into(),
                (MINF_MARW1, MINF_MARW1, 39, 39).into(),
                (MINF_MARF, MINF_MARF, 42, 42).into(),
                (MINF_MARW0, MINF_MARW0, 41, 41).into(),
                (MINF_MARF, MINF_MARF, 44, 44).into(),
                (MINF_MARW0, MINF_MARW0, 43, 43).into(),
                (MINF_MARF, MINF_MARF, 18, 18).into(),
                (MINF_MARW1, MINF_MARW1, 45, 45).into(),
                (MINF_MARF, MINF_MARF, 18, 18).into(),
                (MINF_MAB, MINF_MAB, 47, 47).into(),
                (MINF_MARW0, MINF_MARW0, 48, 48).into(),
                (MINF_MAB, MINF_MAB, 49, 51).into(),
                (MINF_MARW0, MINF_MARW0, 50, 50).into(),
                (MINF_MAB, MINF_MAB, 53, 55).into(),
                (MINF_MARW0, MINF_MARW0, 52, 52).into(),
                (MINF_MAB, MINF_MAB, 57, 57).into(),
                (MINF_MARW0, MINF_MARW0, 54, 54).into(),
                (MINF_MR, MINF_MR, 120, 69).into(),
                (MINF_MARW0, MINF_MARW0, 56, 56).into(),
                (MINF_MR, MINF_MR, 32, 112).into(),
                (MINF_MARW0, MINF_MARW0, 58, 58).into(),
                (MINF_MR, MINF_MR, 11, 11).into(),
                (MINF_TBRW1, MINF_TBRW1, 60, 60).into(),
                (MINF_TBRF, MINF_TBRF, 61, 61).into(),
                (MINF_TBRW1, MINF_TBRW1, 62, 62).into(),
                (MINF_TBRF, MINF_TBRF, 63, 63).into(),
                (MINF_TBRW0, MINF_TBRW0, 64, 64).into(),
                (MINF_TBRF, MINF_TBRF, 65, 65).into(),
                (MINF_TBRW1, MINF_TBRW1, 66, 66).into(),
                (MINF_TBRF, MINF_TBRF, 87, 87).into(),
                (MINF_MARW0, MINF_MARW0, 68, 68).into(),
                (MINF_MARF, MINF_MARF, 77, 77).into(),
                (MINF_MARW1, MINF_MARW1, 70, 70).into(),
                (MINF_MARF, MINF_MARF, 77, 77).into(),
                (MINF_MARW0, MINF_MARW0, 72, 72).into(),
                (MINF_MARF, MINF_MARF, 79, 79).into(),
                (MINF_MARW1, MINF_MARW1, 74, 74).into(),
                (MINF_MARF, MINF_MARF, 79, 79).into(),
                (MINF_MARW0, MINF_MARW0, 76, 76).into(),
                (MINF_MARF, MINF_MARF, 81, 81).into(),
                (MINF_MARW0, MINF_MARW0, 78, 78).into(),
                (MINF_MARF, MINF_MARF, 83, 83).into(),
                (MINF_MARW1, MINF_MARW1, 80, 80).into(),
                (MINF_MARF, MINF_MARF, 83, 83).into(),
                (MINF_MARW0, MINF_MARW0, 82, 82).into(),
                (MINF_MARF, MINF_MARF, 85, 85).into(),
                (MINF_MARW0, MINF_MARW0, 84, 84).into(),
                (MINF_MARF, MINF_MARF, 59, 59).into(),
                (MINF_MARW1, MINF_MARW1, 86, 86).into(),
                (MINF_MARF, MINF_MARF, 59, 59).into(),
                (MINF_MAB, MINF_MAB, 88, 88).into(),
                (MINF_MARW0, MINF_MARW0, 89, 89).into(),
                (MINF_MAB, MINF_MAB, 90, 92).into(),
                (MINF_MARW0, MINF_MARW0, 91, 91).into(),
                (MINF_MAB, MINF_MAB, 94, 96).into(),
                (MINF_MARW0, MINF_MARW0, 93, 93).into(),
                (MINF_MAB, MINF_MAB, 98, 98).into(),
                (MINF_MARW0, MINF_MARW0, 95, 95).into(),
                (MINF_MR, MINF_MR, 26, 133).into(),
                (MINF_MARW0, MINF_MARW0, 97, 97).into(),
                (MINF_MR, MINF_MR, 73, 150).into(),
                (MINF_MARW0, MINF_MARW0, 99, 99).into(),
                (MINF_MR, MINF_MR, 122, 122).into(),
                (MINF_MR, MINF_MR, 34, 34).into(),
                (MINF_MR, MINF_MR, 121, 121).into(),
                (MINF_MARW0, MINF_MARW0, 103, 103).into(),
                (MINF_MARF, MINF_MARF, 108, 108).into(),
                (MINF_MARW1, MINF_MARW1, 105, 105).into(),
                (MINF_MARF, MINF_MARF, 108, 108).into(),
                (MINF_MARW0, MINF_MARW0, 107, 107).into(),
                (MINF_MARF, MINF_MARF, 110, 110).into(),
                (MINF_MARW0, MINF_MARW0, 109, 109).into(),
                (MINF_MARF, MINF_MARF, 30, 30).into(),
                (MINF_MARW1, MINF_MARW1, 111, 111).into(),
                (MINF_MARF, MINF_MARF, 30, 30).into(),
                (MINF_MAB, MINF_MAB, 113, 113).into(),
                (MINF_MARW0, MINF_MARW0, 114, 114).into(),
                (MINF_MAB, MINF_MAB, 115, 117).into(),
                (MINF_MARW0, MINF_MARW0, 116, 116).into(),
                (MINF_MR, MINF_MR, 140, 158).into(),
                (MINF_MARW0, MINF_MARW0, 118, 118).into(),
                (MINF_MR, MINF_MR, 160, 160).into(),
                (MINF_MR, MINF_MR, 67, 67).into(),
                (MINF_MR, MINF_MR, 123, 123).into(),
                (MINF_MR, MINF_MR, 13, 13).into(),
                (MINF_MR, MINF_MR, 162, 162).into(),
                (MINF_MARW0, MINF_MARW0, 124, 124).into(),
                (MINF_MARF, MINF_MARF, 129, 129).into(),
                (MINF_MARW1, MINF_MARW1, 126, 126).into(),
                (MINF_MARF, MINF_MARF, 129, 129).into(),
                (MINF_MARW0, MINF_MARW0, 128, 128).into(),
                (MINF_MARF, MINF_MARF, 131, 131).into(),
                (MINF_MARW0, MINF_MARW0, 130, 130).into(),
                (MINF_MARF, MINF_MARF, 28, 28).into(),
                (MINF_MARW1, MINF_MARW1, 132, 132).into(),
                (MINF_MARF, MINF_MARF, 28, 28).into(),
                (MINF_MAB, MINF_MAB, 134, 134).into(),
                (MINF_MARW0, MINF_MARW0, 135, 135).into(),
                (MINF_MAB, MINF_MAB, 136, 138).into(),
                (MINF_MARW0, MINF_MARW0, 137, 137).into(),
                (MINF_MR, MINF_MR, 164, 166).into(),
                (MINF_MARW0, MINF_MARW0, 139, 139).into(),
                (MINF_MR, MINF_MR, 104, 104).into(),
                (MINF_MARW0, MINF_MARW0, 141, 141).into(),
                (MINF_MARF, MINF_MARF, 146, 146).into(),
                (MINF_MARW1, MINF_MARW1, 143, 143).into(),
                (MINF_MARF, MINF_MARF, 146, 146).into(),
                (MINF_MARW0, MINF_MARW0, 145, 145).into(),
                (MINF_MARF, MINF_MARF, 148, 148).into(),
                (MINF_MARW0, MINF_MARW0, 147, 147).into(),
                (MINF_MARF, MINF_MARF, 71, 71).into(),
                (MINF_MARW1, MINF_MARW1, 149, 149).into(),
                (MINF_MARF, MINF_MARF, 71, 71).into(),
                (MINF_MAB, MINF_MAB, 151, 151).into(),
                (MINF_MARW0, MINF_MARW0, 152, 152).into(),
                (MINF_MAB, MINF_MAB, 153, 155).into(),
                (MINF_MARW0, MINF_MARW0, 154, 154).into(),
                (MINF_MR, MINF_MR, 168, 125).into(),
                (MINF_MARW0, MINF_MARW0, 156, 156).into(),
                (MINF_MR, MINF_MR, 106, 106).into(),
                (MINF_MR, MINF_MR, 127, 127).into(),
                (MINF_MR, MINF_MR, 170, 170).into(),
                (MINF_MR, MINF_MR, 144, 144).into(),
                (MINF_MR, MINF_MR, 161, 161).into(),
                (MINF_MR, MINF_MR, 100, 100).into(),
                (MINF_MR, MINF_MR, 172, 172).into(),
                (MINF_MR, MINF_MR, 119, 119).into(),
                (MINF_MR, MINF_MR, 167, 167).into(),
                (MINF_MR, MINF_MR, 142, 142).into(),
                (MINF_MR, MINF_MR, 157, 157).into(),
                (MINF_MR, MINF_MR, 102, 102).into(),
                (MINF_MR, MINF_MR, 174, 174).into(),
                (MINF_MR, MINF_MR, 165, 165).into(),
                (MINF_MR, MINF_MR, 176, 176).into(),
                (MINF_MR, MINF_MR, 159, 159).into(),
                (MINF_MR, MINF_MR, 2, 2).into(),
                (MINF_MR, MINF_MR, 163, 163).into(),
                (MINF_MR, MINF_MR, 169, 169).into(),
                (MINF_MR, MINF_MR, 173, 173).into(),
                (MINF_MR, MINF_MR, 171, 171).into(),
                (MINF_MARW0, MINF_MARW0, 178, 178).into(),
                (MINF_MARF, MINF_MARF, 179, 179).into(),
                (MINF_MARW0, MINF_MARW0, 180, 180).into(),
                (MINF_MARF, MINF_MARF, 195, 195).into(),
                (MINF_MAB, MINF_MAB, 182, 182).into(),
                (MINF_MARW0, MINF_MARW0, 183, 183).into(),
                (MINF_MAB, MINF_MAB, 184, 184).into(),
                (MINF_MARW0, MINF_MARW0, 185, 185).into(),
                (MINF_MR, MINF_MR, 206, 206).into(),
                (MINF_MARW0, MINF_MARW0, 187, 187).into(),
                (MINF_MARF, MINF_MARF, 188, 188).into(),
                (MINF_MARW0, MINF_MARW0, 189, 189).into(),
                (MINF_MARF, MINF_MARF, 199, 199).into(),
                (MINF_MAB, MINF_MAB, 191, 191).into(),
                (MINF_MARW0, MINF_MARW0, 192, 192).into(),
                (MINF_MAB, MINF_MAB, 193, 193).into(),
                (MINF_MARW0, MINF_MARW0, 194, 194).into(),
                (MINF_MR, MINF_MR, 1, 1).into(),
                (MINF_MR, MINF_MR, 196, 196).into(),
                (MINF_TBRF, MINF_TBRF, 197, 197).into(),
                (MINF_TBB, MINF_TBB, 198, 198).into(),
                (MINF_TBRW1, MINF_TBRW0, 181, 181).into(),
                (MINF_TBRW1, MINF_TBRW1, 200, 200).into(),
                (MINF_TBRF, MINF_TBRF, 201, 201).into(),
                (MINF_TBRW1, MINF_TBRW1, 202, 202).into(),
                (MINF_TBRF, MINF_TBRF, 203, 203).into(),
                (MINF_TBRW1, MINF_TBRW1, 204, 204).into(),
                (MINF_TBRF, MINF_TBRF, 205, 205).into(),
                (MINF_MR, MINF_MR, 177, 177).into(),
                (MINF_MR, MINF_MR, 190, 190).into(),
            ],
            vec![
                ("tb_check_fix".to_string(), 195),
                ("tb_check_fix:tb".to_string(), 199),
                ("tb_check_fix:tb_0_putret_1_0".to_string(), 188),
                ("tb_check_fix:tb_0_putret_x_0".to_string(), 186),
                ("tb_check_fix:tb_after_ret_0".to_string(), 1),
                ("tb_check_fix:tb_return".to_string(), 190),
                ("tb_check_fix:tb_return_id_0_0".to_string(), 191),
                ("tb_check_fix:tb_return_id_1_0".to_string(), 193),
                ("tb_check_fix_0_putret_1_0".to_string(), 179),
                ("tb_check_fix_0_putret_x_0".to_string(), 177),
                ("tb_check_fix_after_ret_0".to_string(), 206),
                ("tb_check_fix_return".to_string(), 181),
                ("tb_check_fix_return_id_0_0".to_string(), 182),
                ("tb_check_fix_return_id_1_0".to_string(), 184),
                ("tb_chunk_1_4".to_string(), 3),
                ("tb_chunk_1_4_0_putret_x_0".to_string(), 11),
                ("tb_chunk_1_4_0_putret_x_1".to_string(), 13),
                ("tb_chunk_1_4_return".to_string(), 15),
                ("tb_chunk_1_4_return_id_0_0".to_string(), 16),
                ("tb_chunk_1a_8_0_putret_x_0".to_string(), 100),
                ("tb_chunk_1a_8_return".to_string(), 101),
                ("tb_chunk_a_4".to_string(), 18),
                ("tb_chunk_a_4_0_putret_1_0".to_string(), 42),
                ("tb_chunk_a_4_0_putret_1_1".to_string(), 44),
                ("tb_chunk_a_4_0_putret_2_00".to_string(), 36),
                ("tb_chunk_a_4_0_putret_2_01".to_string(), 38),
                ("tb_chunk_a_4_0_putret_2_10".to_string(), 40),
                ("tb_chunk_a_4_0_putret_x_0".to_string(), 26),
                ("tb_chunk_a_4_0_putret_x_1".to_string(), 28),
                ("tb_chunk_a_4_0_putret_x_10".to_string(), 30),
                ("tb_chunk_a_4_0_putret_x_100".to_string(), 34),
                ("tb_chunk_a_4_0_putret_x_11".to_string(), 32),
                ("tb_chunk_a_4_return".to_string(), 46),
                ("tb_chunk_a_4_return_id_0_0".to_string(), 47),
                ("tb_chunk_a_4_return_id_1_0".to_string(), 49),
                ("tb_chunk_a_4_return_id_1_1".to_string(), 51),
                ("tb_chunk_a_4_return_id_2_00".to_string(), 53),
                ("tb_chunk_a_4_return_id_2_01".to_string(), 55),
                ("tb_chunk_a_4_return_id_2_10".to_string(), 57),
                ("tb_chunk_aa_8_0_putret_1_0".to_string(), 108),
                ("tb_chunk_aa_8_0_putret_1_1".to_string(), 110),
                ("tb_chunk_aa_8_0_putret_x_0".to_string(), 102),
                ("tb_chunk_aa_8_0_putret_x_1".to_string(), 104),
                ("tb_chunk_aa_8_0_putret_x_10".to_string(), 106),
                ("tb_chunk_aa_8_return".to_string(), 112),
                ("tb_chunk_aa_8_return_id_0_0".to_string(), 113),
                ("tb_chunk_aa_8_return_id_1_0".to_string(), 115),
                ("tb_chunk_aa_8_return_id_1_1".to_string(), 117),
                ("tb_chunk_aaba_16_0_putret_x_0".to_string(), 157),
                ("tb_chunk_aaba_16_return".to_string(), 158),
                ("tb_chunk_aabababb_32_0_putret_x_0".to_string(), 169),
                ("tb_chunk_aabababb_32_return".to_string(), 170),
                ("tb_chunk_aabababbbbaabaab_64_0_putret_x_0".to_string(), 175),
                ("tb_chunk_aabababbbbaabaab_64_return".to_string(), 176),
                ("tb_chunk_aabb_16_0_putret_x_0".to_string(), 159),
                ("tb_chunk_aabb_16_return".to_string(), 160),
                ("tb_chunk_ab_8_0_putret_x_0".to_string(), 119),
                ("tb_chunk_ab_8_return".to_string(), 120),
                ("tb_chunk_b11a_16_0_putret_x_0".to_string(), 161),
                ("tb_chunk_b11a_16_return".to_string(), 162),
                ("tb_chunk_b11aaabb_32_0_putret_x_0".to_string(), 171),
                ("tb_chunk_b11aaabb_32_return".to_string(), 172),
                ("tb_chunk_b1_8_0_putret_x_0".to_string(), 121),
                ("tb_chunk_b1_8_return".to_string(), 122),
                ("tb_chunk_b_4".to_string(), 59),
                ("tb_chunk_b_4_0_putret_1_0".to_string(), 83),
                ("tb_chunk_b_4_0_putret_1_1".to_string(), 85),
                ("tb_chunk_b_4_0_putret_2_00".to_string(), 77),
                ("tb_chunk_b_4_0_putret_2_01".to_string(), 79),
                ("tb_chunk_b_4_0_putret_2_10".to_string(), 81),
                ("tb_chunk_b_4_0_putret_x_0".to_string(), 67),
                ("tb_chunk_b_4_0_putret_x_1".to_string(), 69),
                ("tb_chunk_b_4_0_putret_x_10".to_string(), 71),
                ("tb_chunk_b_4_0_putret_x_100".to_string(), 75),
                ("tb_chunk_b_4_0_putret_x_11".to_string(), 73),
                ("tb_chunk_b_4_return".to_string(), 87),
                ("tb_chunk_b_4_return_id_0_0".to_string(), 88),
                ("tb_chunk_b_4_return_id_1_0".to_string(), 90),
                ("tb_chunk_b_4_return_id_1_1".to_string(), 92),
                ("tb_chunk_b_4_return_id_2_00".to_string(), 94),
                ("tb_chunk_b_4_return_id_2_01".to_string(), 96),
                ("tb_chunk_b_4_return_id_2_10".to_string(), 98),
                ("tb_chunk_ba_8_0_putret_1_0".to_string(), 129),
                ("tb_chunk_ba_8_0_putret_1_1".to_string(), 131),
                ("tb_chunk_ba_8_0_putret_x_0".to_string(), 123),
                ("tb_chunk_ba_8_0_putret_x_1".to_string(), 125),
                ("tb_chunk_ba_8_0_putret_x_10".to_string(), 127),
                ("tb_chunk_ba_8_return".to_string(), 133),
                ("tb_chunk_ba_8_return_id_0_0".to_string(), 134),
                ("tb_chunk_ba_8_return_id_1_0".to_string(), 136),
                ("tb_chunk_ba_8_return_id_1_1".to_string(), 138),
                ("tb_chunk_baab_16_0_putret_x_0".to_string(), 163),
                ("tb_chunk_baab_16_return".to_string(), 164),
                ("tb_chunk_babb_16_0_putret_x_0".to_string(), 165),
                ("tb_chunk_babb_16_return".to_string(), 166),
                ("tb_chunk_bb_8_0_putret_1_0".to_string(), 146),
                ("tb_chunk_bb_8_0_putret_1_1".to_string(), 148),
                ("tb_chunk_bb_8_0_putret_x_0".to_string(), 140),
                ("tb_chunk_bb_8_0_putret_x_1".to_string(), 142),
                ("tb_chunk_bb_8_0_putret_x_10".to_string(), 144),
                ("tb_chunk_bb_8_return".to_string(), 150),
                ("tb_chunk_bb_8_return_id_0_0".to_string(), 151),
                ("tb_chunk_bb_8_return_id_1_0".to_string(), 153),
                ("tb_chunk_bb_8_return_id_1_1".to_string(), 155),
                ("tb_chunk_bbaa_16_0_putret_x_0".to_string(), 167),
                ("tb_chunk_bbaa_16_return".to_string(), 168),
                ("tb_chunk_bbaabaab_32_0_putret_x_0".to_string(), 173),
                ("tb_chunk_bbaabaab_32_return".to_string(), 174),
                ("tb_next_0".to_string(), 2),
            ]
        ),
        builder.to_code()
    );
}

#[test]
fn test_handler_builder_longdata_safe_ldh_ldh_start() {
    // with ldh_start - position where put check_fix call
    let mut builder = mi_simple_hbuilder_new_1_safe_ldh(None, Some("ma_check_fix"), None);
    builder.add_longdata_handler("md", false, 1);
    builder.i(MINF_MARW0);
    builder.i(MINF_TBRW0);
    builder.ldh_start("mystart");
    builder.l("mystart");
    builder.ld_call_01("md", (&[143, 54], 0, 0), MINF_MR);
    builder.i(MINF_STOP);
    {
        let (func1b, ret) = builder.add_routine("ma_check_fix", true);
        let mut func1b = func1b.borrow_mut();
        func1b.i(MINF_MR);
        func1b.i(MINF_TBRF);
        func1b.i(MINF_TBB);
        func1b.i((MINF_TBRW1, MINF_TBRW0, ret));
    }
    assert_eq!(
        (
            vec![
                MinInfInstr::new(MINF_MARW0, MINF_MARW0, 1, 1).into(),
                (MINF_TBRW0, MINF_TBRW0, 2, 2).into(),
                (MINF_MR, MINF_MR, 53, 53).into(),
                (MINF_MR, MINF_MR, 49, 49).into(),
                (MINF_STOP, MINF_STOP, 5, 5).into(),
                (MINF_MARW1, MINF_MARW1, 6, 6).into(),
                (MINF_MARF, MINF_MARF, 7, 7).into(),
                (MINF_MARW1, MINF_MARW1, 8, 8).into(),
                (MINF_MARF, MINF_MARF, 9, 9).into(),
                (MINF_MARW0, MINF_MARW0, 10, 10).into(),
                (MINF_MARF, MINF_MARF, 11, 11).into(),
                (MINF_MARW0, MINF_MARW0, 12, 12).into(),
                (MINF_MARF, MINF_MARF, 14, 14).into(),
                (MINF_MR, MINF_MR, 5, 5).into(),
                (MINF_MR, MINF_MR, 46, 46).into(),
                (MINF_MARW0, MINF_MARW0, 16, 16).into(),
                (MINF_MARF, MINF_MARF, 17, 17).into(),
                (MINF_MARW1, MINF_MARW1, 18, 18).into(),
                (MINF_MARF, MINF_MARF, 19, 19).into(),
                (MINF_MARW1, MINF_MARW1, 20, 20).into(),
                (MINF_MARF, MINF_MARF, 21, 21).into(),
                (MINF_MARW0, MINF_MARW0, 22, 22).into(),
                (MINF_MARF, MINF_MARF, 24, 24).into(),
                (MINF_MR, MINF_MR, 15, 15).into(),
                (MINF_MR, MINF_MR, 13, 13).into(),
                (MINF_MARW0, MINF_MARW0, 26, 26).into(),
                (MINF_MARF, MINF_MARF, 27, 27).into(),
                (MINF_MARW0, MINF_MARW0, 28, 28).into(),
                (MINF_MARF, MINF_MARF, 29, 29).into(),
                (MINF_MARW0, MINF_MARW0, 30, 30).into(),
                (MINF_MARF, MINF_MARF, 31, 31).into(),
                (MINF_MARW1, MINF_MARW1, 32, 32).into(),
                (MINF_MARF, MINF_MARF, 34, 34).into(),
                (MINF_MR, MINF_MR, 25, 25).into(),
                (MINF_MR, MINF_MR, 48, 48).into(),
                (MINF_MARW1, MINF_MARW1, 36, 36).into(),
                (MINF_MARF, MINF_MARF, 37, 37).into(),
                (MINF_MARW1, MINF_MARW1, 38, 38).into(),
                (MINF_MARF, MINF_MARF, 39, 39).into(),
                (MINF_MARW1, MINF_MARW1, 40, 40).into(),
                (MINF_MARF, MINF_MARF, 41, 41).into(),
                (MINF_MARW1, MINF_MARW1, 42, 42).into(),
                (MINF_MARF, MINF_MARF, 44, 44).into(),
                (MINF_MR, MINF_MR, 35, 35).into(),
                (MINF_MR, MINF_MR, 33, 33).into(),
                (MINF_MR, MINF_MR, 23, 23).into(),
                (MINF_MR, MINF_MR, 50, 50).into(),
                (MINF_MR, MINF_MR, 43, 43).into(),
                (MINF_MR, MINF_MR, 45, 45).into(),
                (MINF_MR, MINF_MR, 47, 47).into(),
                (MINF_MR, MINF_MR, 4, 4).into(),
                (MINF_MR, MINF_MR, 55, 55).into(),
                (MINF_MR, MINF_MR, 66, 66).into(),
                (MINF_MR, MINF_MR, 59, 59).into(),
                (MINF_MR, MINF_MR, 3, 3).into(),
                (MINF_MR, MINF_MR, 56, 56).into(),
                (MINF_TBRF, MINF_TBRF, 57, 57).into(),
                (MINF_TBB, MINF_TBB, 58, 58).into(),
                (MINF_TBRW1, MINF_TBRW0, 52, 52).into(),
                (MINF_MARW1, MINF_MARW1, 60, 60).into(),
                (MINF_MARF, MINF_MARF, 61, 61).into(),
                (MINF_MARW0, MINF_MARW0, 62, 62).into(),
                (MINF_MARF, MINF_MARF, 63, 63).into(),
                (MINF_MARW1, MINF_MARW1, 64, 64).into(),
                (MINF_MARF, MINF_MARF, 65, 65).into(),
                (MINF_MR, MINF_MR, 51, 51).into(),
                (MINF_MR, MINF_MR, 54, 54).into(),
            ],
            vec![
                ("ma_check_fix".to_string(), 55),
                ("ma_check_fix:md".to_string(), 59),
                ("ma_check_fix:md_0_putret_x_0".to_string(), 53),
                ("ma_check_fix:md_after_ret_0".to_string(), 3),
                ("ma_check_fix:md_return".to_string(), 54),
                ("ma_check_fix_0_putret_x_0".to_string(), 51),
                ("ma_check_fix_after_ret_0".to_string(), 66),
                ("ma_check_fix_return".to_string(), 52),
                ("md_chunk_368f_16_0_putret_x_0".to_string(), 49),
                ("md_chunk_368f_16_return".to_string(), 50),
                ("md_chunk_36_8_0_putret_x_0".to_string(), 45),
                ("md_chunk_36_8_return".to_string(), 46),
                ("md_chunk_3_4".to_string(), 5),
                ("md_chunk_3_4_0_putret_x_0".to_string(), 13),
                ("md_chunk_3_4_return".to_string(), 14),
                ("md_chunk_6_4".to_string(), 15),
                ("md_chunk_6_4_0_putret_x_0".to_string(), 23),
                ("md_chunk_6_4_return".to_string(), 24),
                ("md_chunk_8_4".to_string(), 25),
                ("md_chunk_8_4_0_putret_x_0".to_string(), 33),
                ("md_chunk_8_4_return".to_string(), 34),
                ("md_chunk_8f_8_0_putret_x_0".to_string(), 47),
                ("md_chunk_8f_8_return".to_string(), 48),
                ("md_chunk_f_4".to_string(), 35),
                ("md_chunk_f_4_0_putret_x_0".to_string(), 43),
                ("md_chunk_f_4_return".to_string(), 44),
                ("md_next_0".to_string(), 4),
                ("mystart".to_string(), 2),
            ]
        ),
        builder.to_code()
    );
}

#[test]
fn test_handler_builder_longdata_safe_ldh_in_routines() {
    let mut builder = mi_simple_hbuilder_new_1_safe_ldh(None, Some("ma_check_fix"), None);
    builder.add_longdata_handler("md", false, 1);
    {
        let (func1b, ret) = builder.add_routine("myfunc1", true);
        let mut func1b = func1b.borrow_mut();
        func1b.ld_call_01("md", (&[143, 54], 0, 0), MINF_MR);
        func1b.i((MINF_MR, ret));
    }
    builder.ld_call_01("md", (&[143, 54], 0, 0), MINF_MR);
    builder.call_01("myfunc1", MINF_MR);
    builder.i(MINF_STOP);
    {
        let (func1b, ret) = builder.add_routine("ma_check_fix", true);
        let mut func1b = func1b.borrow_mut();
        func1b.i(MINF_MR);
        func1b.i(MINF_TBRF);
        func1b.i(MINF_TBB);
        func1b.i((MINF_TBRW1, MINF_TBRW0, ret));
    }
    assert_eq!(
        (
            vec![
                MinInfInstr::new(MINF_MR, MINF_MR, 57, 57),
                (MINF_MR, MINF_MR, 50, 50).into(),
                (MINF_MR, MINF_MR, 64, 64).into(),
                (MINF_STOP, MINF_STOP, 4, 4).into(),
                (MINF_MARW1, MINF_MARW1, 5, 5).into(),
                (MINF_MARF, MINF_MARF, 6, 6).into(),
                (MINF_MARW1, MINF_MARW1, 7, 7).into(),
                (MINF_MARF, MINF_MARF, 8, 8).into(),
                (MINF_MARW0, MINF_MARW0, 9, 9).into(),
                (MINF_MARF, MINF_MARF, 10, 10).into(),
                (MINF_MARW0, MINF_MARW0, 11, 11).into(),
                (MINF_MARF, MINF_MARF, 13, 13).into(),
                (MINF_MR, MINF_MR, 4, 4).into(),
                (MINF_MR, MINF_MR, 45, 45).into(),
                (MINF_MARW0, MINF_MARW0, 15, 15).into(),
                (MINF_MARF, MINF_MARF, 16, 16).into(),
                (MINF_MARW1, MINF_MARW1, 17, 17).into(),
                (MINF_MARF, MINF_MARF, 18, 18).into(),
                (MINF_MARW1, MINF_MARW1, 19, 19).into(),
                (MINF_MARF, MINF_MARF, 20, 20).into(),
                (MINF_MARW0, MINF_MARW0, 21, 21).into(),
                (MINF_MARF, MINF_MARF, 23, 23).into(),
                (MINF_MR, MINF_MR, 14, 14).into(),
                (MINF_MR, MINF_MR, 12, 12).into(),
                (MINF_MARW0, MINF_MARW0, 25, 25).into(),
                (MINF_MARF, MINF_MARF, 26, 26).into(),
                (MINF_MARW0, MINF_MARW0, 27, 27).into(),
                (MINF_MARF, MINF_MARF, 28, 28).into(),
                (MINF_MARW0, MINF_MARW0, 29, 29).into(),
                (MINF_MARF, MINF_MARF, 30, 30).into(),
                (MINF_MARW1, MINF_MARW1, 31, 31).into(),
                (MINF_MARF, MINF_MARF, 33, 33).into(),
                (MINF_MR, MINF_MR, 24, 24).into(),
                (MINF_MR, MINF_MR, 47, 47).into(),
                (MINF_MARW1, MINF_MARW1, 35, 35).into(),
                (MINF_MARF, MINF_MARF, 36, 36).into(),
                (MINF_MARW1, MINF_MARW1, 37, 37).into(),
                (MINF_MARF, MINF_MARF, 38, 38).into(),
                (MINF_MARW1, MINF_MARW1, 39, 39).into(),
                (MINF_MARF, MINF_MARF, 40, 40).into(),
                (MINF_MARW1, MINF_MARW1, 41, 41).into(),
                (MINF_MARF, MINF_MARF, 43, 43).into(),
                (MINF_MR, MINF_MR, 34, 34).into(),
                (MINF_MR, MINF_MR, 32, 32).into(),
                (MINF_MR, MINF_MR, 22, 22).into(),
                (MINF_MR, MINF_MR, 52, 52).into(),
                (MINF_MR, MINF_MR, 42, 42).into(),
                (MINF_MR, MINF_MR, 44, 44).into(),
                (MINF_TBRW0, MINF_TBRW0, 49, 49).into(),
                (MINF_TBRF, MINF_TBRF, 46, 46).into(),
                (MINF_TBRW1, MINF_TBRW1, 51, 51).into(),
                (MINF_TBRF, MINF_TBRF, 46, 46).into(),
                (MINF_TBB, MINF_TBB, 53, 53).into(),
                (MINF_TBRW0, MINF_TBRW0, 54, 54).into(),
                (MINF_MR, MINF_MR, 80, 2).into(),
                (MINF_MR, MINF_MR, 66, 66).into(),
                (MINF_MR, MINF_MR, 77, 77).into(),
                (MINF_TBRW0, MINF_TBRW0, 58, 58).into(),
                (MINF_TBRF, MINF_TBRF, 70, 70).into(),
                (MINF_TBRW1, MINF_TBRW1, 60, 60).into(),
                (MINF_TBRF, MINF_TBRF, 70, 70).into(),
                (MINF_TBB, MINF_TBB, 62, 62).into(),
                (MINF_TBRW0, MINF_TBRW0, 63, 63).into(),
                (MINF_MR, MINF_MR, 1, 79).into(),
                (MINF_MR, MINF_MR, 78, 78).into(),
                (MINF_MR, MINF_MR, 3, 3).into(),
                (MINF_MR, MINF_MR, 67, 67).into(),
                (MINF_TBRF, MINF_TBRF, 68, 68).into(),
                (MINF_TBB, MINF_TBB, 69, 69).into(),
                (MINF_TBRW1, MINF_TBRW0, 56, 56).into(),
                (MINF_MARW1, MINF_MARW1, 71, 71).into(),
                (MINF_MARF, MINF_MARF, 72, 72).into(),
                (MINF_MARW1, MINF_MARW1, 73, 73).into(),
                (MINF_MARF, MINF_MARF, 74, 74).into(),
                (MINF_MARW1, MINF_MARW1, 75, 75).into(),
                (MINF_MARF, MINF_MARF, 76, 76).into(),
                (MINF_MR, MINF_MR, 55, 55).into(),
                (MINF_MR, MINF_MR, 61, 61).into(),
                (MINF_MR, MINF_MR, 59, 59).into(),
                (MINF_MR, MINF_MR, 48, 48).into(),
                (MINF_MR, MINF_MR, 65, 65).into(),
            ],
            vec![
                ("ma_check_fix".to_string(), 66),
                ("ma_check_fix:md".to_string(), 70),
                ("ma_check_fix:md_0_putret_x_0".to_string(), 57),
                ("ma_check_fix:md_0_putret_x_1".to_string(), 59),
                ("ma_check_fix:md_after_ret_0".to_string(), 1),
                ("ma_check_fix:md_after_ret_1".to_string(), 79),
                ("ma_check_fix:md_return".to_string(), 61),
                ("ma_check_fix:md_return_id_0_0".to_string(), 62),
                ("ma_check_fix_0_putret_x_0".to_string(), 55),
                ("ma_check_fix_after_ret_0".to_string(), 77),
                ("ma_check_fix_return".to_string(), 56),
                ("md_chunk_368f_16_0_putret_x_0".to_string(), 48),
                ("md_chunk_368f_16_0_putret_x_1".to_string(), 50),
                ("md_chunk_368f_16_return".to_string(), 52),
                ("md_chunk_368f_16_return_id_0_0".to_string(), 53),
                ("md_chunk_36_8_0_putret_x_0".to_string(), 44),
                ("md_chunk_36_8_return".to_string(), 45),
                ("md_chunk_3_4".to_string(), 4),
                ("md_chunk_3_4_0_putret_x_0".to_string(), 12),
                ("md_chunk_3_4_return".to_string(), 13),
                ("md_chunk_6_4".to_string(), 14),
                ("md_chunk_6_4_0_putret_x_0".to_string(), 22),
                ("md_chunk_6_4_return".to_string(), 23),
                ("md_chunk_8_4".to_string(), 24),
                ("md_chunk_8_4_0_putret_x_0".to_string(), 32),
                ("md_chunk_8_4_return".to_string(), 33),
                ("md_chunk_8f_8_0_putret_x_0".to_string(), 46),
                ("md_chunk_8f_8_return".to_string(), 47),
                ("md_chunk_f_4".to_string(), 34),
                ("md_chunk_f_4_0_putret_x_0".to_string(), 42),
                ("md_chunk_f_4_return".to_string(), 43),
                ("md_next_0".to_string(), 80),
                ("md_next_1".to_string(), 2),
                ("myfunc1".to_string(), 78),
                ("myfunc1_0_putret_x_0".to_string(), 64),
                ("myfunc1_after_ret_0".to_string(), 3),
                ("myfunc1_return".to_string(), 65),
            ]
        ),
        builder.to_code()
    );
    // with labels (multiple entries)
    let mut builder = mi_simple_hbuilder_new_1_safe_ldh(None, Some("ma_check_fix"), None);
    builder.add_longdata_handler("md", false, 1);
    {
        let (func1b, ret) = builder.add_routine_with_labels_l(
            "myfunc1",
            ["myfunc1_0", "myfunc1_1", "myfunc1_2", "myfunc1_3"],
            true,
        );
        let mut func1b = func1b.borrow_mut();
        func1b.l("myfunc1_0");
        func1b.ld_call_01("md", (&[33, 57], 0, 0), MINF_MR);
        func1b.i((MINF_MR, &ret));
        func1b.l("myfunc1_1");
        func1b.ld_call_01("md", (&[34, 58], 0, 0), MINF_MR);
        func1b.i((MINF_MR, &ret));
        func1b.l("myfunc1_2");
        func1b.ld_call_01("md", (&[35, 59], 0, 0), MINF_MR);
        func1b.i((MINF_MR, &ret));
        func1b.l("myfunc1_3");
        func1b.ld_call_01("md", (&[36, 60], 0, 0), MINF_MR);
        func1b.i((MINF_MR, &ret));
    }
    builder.ld_call_01("md", (&[143, 54], 0, 0), MINF_MR);
    builder.call_01("myfunc1", MINF_MR);
    builder.i(MINF_STOP);
    {
        let (func1b, ret) = builder.add_routine("ma_check_fix", true);
        let mut func1b = func1b.borrow_mut();
        func1b.i(MINF_MR);
        func1b.i(MINF_TBRF);
        func1b.i(MINF_TBB);
        func1b.i((MINF_TBRW1, MINF_TBRW0, ret));
    }
    assert_eq!(
        (
            vec![
                MinInfInstr::new(MINF_MR, MINF_MR, 210, 210),
                (MINF_MR, MINF_MR, 198, 198).into(),
                (MINF_MR, MINF_MR, 243, 243).into(),
                (MINF_STOP, MINF_STOP, 4, 4).into(),
                (MINF_MARW1, MINF_MARW1, 5, 5).into(),
                (MINF_MARF, MINF_MARF, 6, 6).into(),
                (MINF_MARW0, MINF_MARW0, 7, 7).into(),
                (MINF_MARF, MINF_MARF, 8, 8).into(),
                (MINF_MARW0, MINF_MARW0, 9, 9).into(),
                (MINF_MARF, MINF_MARF, 10, 10).into(),
                (MINF_MARW0, MINF_MARW0, 11, 11).into(),
                (MINF_MARF, MINF_MARF, 13, 13).into(),
                (MINF_MR, MINF_MR, 4, 4).into(),
                (MINF_MR, MINF_MR, 22, 22).into(),
                (MINF_MARW0, MINF_MARW0, 15, 15).into(),
                (MINF_MARF, MINF_MARF, 16, 16).into(),
                (MINF_MARW1, MINF_MARW1, 17, 17).into(),
                (MINF_MARF, MINF_MARF, 18, 18).into(),
                (MINF_MARW0, MINF_MARW0, 19, 19).into(),
                (MINF_MARF, MINF_MARF, 20, 20).into(),
                (MINF_MARW0, MINF_MARW0, 21, 21).into(),
                (MINF_MARF, MINF_MARF, 42, 42).into(),
                (MINF_TBRW0, MINF_TBRW0, 23, 23).into(),
                (MINF_TBRF, MINF_TBRF, 32, 32).into(),
                (MINF_TBRW1, MINF_TBRW1, 25, 25).into(),
                (MINF_TBRF, MINF_TBRF, 32, 32).into(),
                (MINF_TBRW0, MINF_TBRW0, 27, 27).into(),
                (MINF_TBRF, MINF_TBRF, 34, 34).into(),
                (MINF_TBRW1, MINF_TBRW1, 29, 29).into(),
                (MINF_TBRF, MINF_TBRF, 34, 34).into(),
                (MINF_TBRW0, MINF_TBRW0, 31, 31).into(),
                (MINF_TBRF, MINF_TBRF, 36, 36).into(),
                (MINF_TBRW0, MINF_TBRW0, 33, 33).into(),
                (MINF_TBRF, MINF_TBRF, 38, 38).into(),
                (MINF_TBRW1, MINF_TBRW1, 35, 35).into(),
                (MINF_TBRF, MINF_TBRF, 38, 38).into(),
                (MINF_TBRW0, MINF_TBRW0, 37, 37).into(),
                (MINF_TBRF, MINF_TBRF, 40, 40).into(),
                (MINF_TBRW0, MINF_TBRW0, 39, 39).into(),
                (MINF_TBRF, MINF_TBRF, 14, 14).into(),
                (MINF_TBRW1, MINF_TBRW1, 41, 41).into(),
                (MINF_TBRF, MINF_TBRF, 14, 14).into(),
                (MINF_TBB, MINF_TBB, 43, 43).into(),
                (MINF_TBRW0, MINF_TBRW0, 44, 44).into(),
                (MINF_TBB, MINF_TBB, 45, 47).into(),
                (MINF_TBRW0, MINF_TBRW0, 46, 46).into(),
                (MINF_TBB, MINF_TBB, 49, 51).into(),
                (MINF_TBRW0, MINF_TBRW0, 48, 48).into(),
                (MINF_TBB, MINF_TBB, 53, 53).into(),
                (MINF_TBRW0, MINF_TBRW0, 50, 50).into(),
                (MINF_MR, MINF_MR, 179, 26).into(),
                (MINF_TBRW0, MINF_TBRW0, 52, 52).into(),
                (MINF_MR, MINF_MR, 181, 183).into(),
                (MINF_TBRW0, MINF_TBRW0, 54, 54).into(),
                (MINF_MR, MINF_MR, 185, 185).into(),
                (MINF_MARW1, MINF_MARW1, 56, 56).into(),
                (MINF_MARF, MINF_MARF, 57, 57).into(),
                (MINF_MARW1, MINF_MARW1, 58, 58).into(),
                (MINF_MARF, MINF_MARF, 59, 59).into(),
                (MINF_MARW0, MINF_MARW0, 60, 60).into(),
                (MINF_MARF, MINF_MARF, 61, 61).into(),
                (MINF_MARW0, MINF_MARW0, 62, 62).into(),
                (MINF_MARF, MINF_MARF, 85, 85).into(),
                (MINF_TBRW0, MINF_TBRW0, 64, 64).into(),
                (MINF_TBRF, MINF_TBRF, 75, 75).into(),
                (MINF_TBRW1, MINF_TBRW1, 66, 66).into(),
                (MINF_TBRF, MINF_TBRF, 75, 75).into(),
                (MINF_TBRW0, MINF_TBRW0, 68, 68).into(),
                (MINF_TBRF, MINF_TBRF, 77, 77).into(),
                (MINF_TBRW1, MINF_TBRW1, 70, 70).into(),
                (MINF_TBRF, MINF_TBRF, 77, 77).into(),
                (MINF_TBRW0, MINF_TBRW0, 72, 72).into(),
                (MINF_TBRF, MINF_TBRF, 79, 79).into(),
                (MINF_TBRW1, MINF_TBRW1, 74, 74).into(),
                (MINF_TBRF, MINF_TBRF, 79, 79).into(),
                (MINF_TBRW0, MINF_TBRW0, 76, 76).into(),
                (MINF_TBRF, MINF_TBRF, 81, 81).into(),
                (MINF_TBRW1, MINF_TBRW1, 78, 78).into(),
                (MINF_TBRF, MINF_TBRF, 81, 81).into(),
                (MINF_TBRW0, MINF_TBRW0, 80, 80).into(),
                (MINF_TBRF, MINF_TBRF, 83, 83).into(),
                (MINF_TBRW0, MINF_TBRW0, 82, 82).into(),
                (MINF_TBRF, MINF_TBRF, 55, 55).into(),
                (MINF_TBRW1, MINF_TBRW1, 84, 84).into(),
                (MINF_TBRF, MINF_TBRF, 55, 55).into(),
                (MINF_TBB, MINF_TBB, 86, 86).into(),
                (MINF_TBRW0, MINF_TBRW0, 87, 87).into(),
                (MINF_TBB, MINF_TBB, 88, 90).into(),
                (MINF_TBRW0, MINF_TBRW0, 89, 89).into(),
                (MINF_TBB, MINF_TBB, 92, 94).into(),
                (MINF_TBRW0, MINF_TBRW0, 91, 91).into(),
                (MINF_TBB, MINF_TBB, 96, 96).into(),
                (MINF_TBRW0, MINF_TBRW0, 93, 93).into(),
                (MINF_MR, MINF_MR, 189, 191).into(),
                (MINF_TBRW0, MINF_TBRW0, 95, 95).into(),
                (MINF_MR, MINF_MR, 28, 193).into(),
                (MINF_TBRW0, MINF_TBRW0, 97, 97).into(),
                (MINF_MR, MINF_MR, 195, 187).into(),
                (MINF_MARW0, MINF_MARW0, 99, 99).into(),
                (MINF_MARF, MINF_MARF, 100, 100).into(),
                (MINF_MARW0, MINF_MARW0, 101, 101).into(),
                (MINF_MARF, MINF_MARF, 102, 102).into(),
                (MINF_MARW1, MINF_MARW1, 103, 103).into(),
                (MINF_MARF, MINF_MARF, 104, 104).into(),
                (MINF_MARW0, MINF_MARW0, 105, 105).into(),
                (MINF_MARF, MINF_MARF, 107, 107).into(),
                (MINF_MR, MINF_MR, 98, 98).into(),
                (MINF_MR, MINF_MR, 30, 30).into(),
                (MINF_MARW0, MINF_MARW0, 109, 109).into(),
                (MINF_MARF, MINF_MARF, 110, 110).into(),
                (MINF_MARW1, MINF_MARW1, 111, 111).into(),
                (MINF_MARF, MINF_MARF, 112, 112).into(),
                (MINF_MARW1, MINF_MARW1, 113, 113).into(),
                (MINF_MARF, MINF_MARF, 114, 114).into(),
                (MINF_MARW0, MINF_MARW0, 115, 115).into(),
                (MINF_MARF, MINF_MARF, 117, 117).into(),
                (MINF_MR, MINF_MR, 108, 108).into(),
                (MINF_MR, MINF_MR, 73, 73).into(),
                (MINF_MARW0, MINF_MARW0, 119, 119).into(),
                (MINF_MARF, MINF_MARF, 120, 120).into(),
                (MINF_MARW0, MINF_MARW0, 121, 121).into(),
                (MINF_MARF, MINF_MARF, 122, 122).into(),
                (MINF_MARW0, MINF_MARW0, 123, 123).into(),
                (MINF_MARF, MINF_MARF, 124, 124).into(),
                (MINF_MARW1, MINF_MARW1, 125, 125).into(),
                (MINF_MARF, MINF_MARF, 127, 127).into(),
                (MINF_MR, MINF_MR, 118, 118).into(),
                (MINF_MR, MINF_MR, 197, 197).into(),
                (MINF_MARW1, MINF_MARW1, 129, 129).into(),
                (MINF_MARF, MINF_MARF, 130, 130).into(),
                (MINF_MARW0, MINF_MARW0, 131, 131).into(),
                (MINF_MARF, MINF_MARF, 132, 132).into(),
                (MINF_MARW0, MINF_MARW0, 133, 133).into(),
                (MINF_MARF, MINF_MARF, 134, 134).into(),
                (MINF_MARW1, MINF_MARW1, 135, 135).into(),
                (MINF_MARF, MINF_MARF, 137, 137).into(),
                (MINF_MR, MINF_MR, 128, 128).into(),
                (MINF_MR, MINF_MR, 63, 63).into(),
                (MINF_MARW0, MINF_MARW0, 139, 139).into(),
                (MINF_MARF, MINF_MARF, 140, 140).into(),
                (MINF_MARW1, MINF_MARW1, 141, 141).into(),
                (MINF_MARF, MINF_MARF, 142, 142).into(),
                (MINF_MARW0, MINF_MARW0, 143, 143).into(),
                (MINF_MARF, MINF_MARF, 144, 144).into(),
                (MINF_MARW1, MINF_MARW1, 145, 145).into(),
                (MINF_MARF, MINF_MARF, 147, 147).into(),
                (MINF_MR, MINF_MR, 138, 138).into(),
                (MINF_MR, MINF_MR, 65, 65).into(),
                (MINF_MARW1, MINF_MARW1, 149, 149).into(),
                (MINF_MARF, MINF_MARF, 150, 150).into(),
                (MINF_MARW1, MINF_MARW1, 151, 151).into(),
                (MINF_MARF, MINF_MARF, 152, 152).into(),
                (MINF_MARW0, MINF_MARW0, 153, 153).into(),
                (MINF_MARF, MINF_MARF, 154, 154).into(),
                (MINF_MARW1, MINF_MARW1, 155, 155).into(),
                (MINF_MARF, MINF_MARF, 157, 157).into(),
                (MINF_MR, MINF_MR, 148, 148).into(),
                (MINF_MR, MINF_MR, 69, 69).into(),
                (MINF_MARW0, MINF_MARW0, 159, 159).into(),
                (MINF_MARF, MINF_MARF, 160, 160).into(),
                (MINF_MARW0, MINF_MARW0, 161, 161).into(),
                (MINF_MARF, MINF_MARF, 162, 162).into(),
                (MINF_MARW1, MINF_MARW1, 163, 163).into(),
                (MINF_MARF, MINF_MARF, 164, 164).into(),
                (MINF_MARW1, MINF_MARW1, 165, 165).into(),
                (MINF_MARF, MINF_MARF, 167, 167).into(),
                (MINF_MR, MINF_MR, 158, 158).into(),
                (MINF_MR, MINF_MR, 71, 71).into(),
                (MINF_MARW1, MINF_MARW1, 169, 169).into(),
                (MINF_MARF, MINF_MARF, 170, 170).into(),
                (MINF_MARW1, MINF_MARW1, 171, 171).into(),
                (MINF_MARF, MINF_MARF, 172, 172).into(),
                (MINF_MARW1, MINF_MARW1, 173, 173).into(),
                (MINF_MARF, MINF_MARF, 174, 174).into(),
                (MINF_MARW1, MINF_MARW1, 175, 175).into(),
                (MINF_MARF, MINF_MARF, 177, 177).into(),
                (MINF_MR, MINF_MR, 168, 168).into(),
                (MINF_MR, MINF_MR, 126, 126).into(),
                (MINF_MR, MINF_MR, 12, 12).into(),
                (MINF_MR, MINF_MR, 188, 188).into(),
                (MINF_MR, MINF_MR, 24, 24).into(),
                (MINF_MR, MINF_MR, 190, 190).into(),
                (MINF_MR, MINF_MR, 67, 67).into(),
                (MINF_MR, MINF_MR, 192, 192).into(),
                (MINF_MR, MINF_MR, 106, 106).into(),
                (MINF_MR, MINF_MR, 194, 194).into(),
                (MINF_MR, MINF_MR, 116, 116).into(),
                (MINF_MR, MINF_MR, 199, 199).into(),
                (MINF_MR, MINF_MR, 136, 136).into(),
                (MINF_MR, MINF_MR, 201, 201).into(),
                (MINF_MR, MINF_MR, 146, 146).into(),
                (MINF_MR, MINF_MR, 203, 203).into(),
                (MINF_MR, MINF_MR, 156, 156).into(),
                (MINF_MR, MINF_MR, 205, 205).into(),
                (MINF_MR, MINF_MR, 166, 166).into(),
                (MINF_MR, MINF_MR, 207, 207).into(),
                (MINF_MR, MINF_MR, 176, 176).into(),
                (MINF_MR, MINF_MR, 186, 186).into(),
                (MINF_MR, MINF_MR, 196, 196).into(),
                (MINF_MR, MINF_MR, 2, 2).into(),
                (MINF_MR, MINF_MR, 178, 178).into(),
                (MINF_MR, MINF_MR, 266, 266).into(),
                (MINF_MR, MINF_MR, 180, 180).into(),
                (MINF_MR, MINF_MR, 269, 269).into(),
                (MINF_MR, MINF_MR, 182, 182).into(),
                (MINF_MR, MINF_MR, 272, 272).into(),
                (MINF_MR, MINF_MR, 184, 184).into(),
                (MINF_MR, MINF_MR, 275, 275).into(),
                (MINF_MR, MINF_MR, 248, 248).into(),
                (MINF_MR, MINF_MR, 263, 263).into(),
                (MINF_TBRW0, MINF_TBRW0, 211, 211).into(),
                (MINF_TBRF, MINF_TBRF, 220, 220).into(),
                (MINF_TBRW1, MINF_TBRW1, 213, 213).into(),
                (MINF_TBRF, MINF_TBRF, 220, 220).into(),
                (MINF_TBRW0, MINF_TBRW0, 215, 215).into(),
                (MINF_TBRF, MINF_TBRF, 222, 222).into(),
                (MINF_TBRW1, MINF_TBRW1, 217, 217).into(),
                (MINF_TBRF, MINF_TBRF, 222, 222).into(),
                (MINF_TBRW0, MINF_TBRW0, 219, 219).into(),
                (MINF_TBRF, MINF_TBRF, 224, 224).into(),
                (MINF_TBRW0, MINF_TBRW0, 221, 221).into(),
                (MINF_TBRF, MINF_TBRF, 226, 226).into(),
                (MINF_TBRW1, MINF_TBRW1, 223, 223).into(),
                (MINF_TBRF, MINF_TBRF, 226, 226).into(),
                (MINF_TBRW0, MINF_TBRW0, 225, 225).into(),
                (MINF_TBRF, MINF_TBRF, 228, 228).into(),
                (MINF_TBRW0, MINF_TBRW0, 227, 227).into(),
                (MINF_TBRF, MINF_TBRF, 252, 252).into(),
                (MINF_TBRW1, MINF_TBRW1, 229, 229).into(),
                (MINF_TBRF, MINF_TBRF, 252, 252).into(),
                (MINF_TBB, MINF_TBB, 231, 231).into(),
                (MINF_TBRW0, MINF_TBRW0, 232, 232).into(),
                (MINF_TBB, MINF_TBB, 233, 235).into(),
                (MINF_TBRW0, MINF_TBRW0, 234, 234).into(),
                (MINF_TBB, MINF_TBB, 237, 239).into(),
                (MINF_TBRW0, MINF_TBRW0, 236, 236).into(),
                (MINF_TBB, MINF_TBB, 241, 241).into(),
                (MINF_TBRW0, MINF_TBRW0, 238, 238).into(),
                (MINF_MR, MINF_MR, 1, 265).into(),
                (MINF_TBRW0, MINF_TBRW0, 240, 240).into(),
                (MINF_MR, MINF_MR, 268, 271).into(),
                (MINF_TBRW0, MINF_TBRW0, 242, 242).into(),
                (MINF_MR, MINF_MR, 274, 274).into(),
                (MINF_MR, MINF_MR, 264, 264).into(),
                (MINF_MR, MINF_MR, 267, 267).into(),
                (MINF_MR, MINF_MR, 270, 270).into(),
                (MINF_MR, MINF_MR, 273, 273).into(),
                (MINF_MR, MINF_MR, 3, 3).into(),
                (MINF_MR, MINF_MR, 249, 249).into(),
                (MINF_TBRF, MINF_TBRF, 250, 250).into(),
                (MINF_TBB, MINF_TBB, 251, 251).into(),
                (MINF_TBRW1, MINF_TBRW0, 209, 209).into(),
                (MINF_MARW1, MINF_MARW1, 253, 253).into(),
                (MINF_MARF, MINF_MARF, 254, 254).into(),
                (MINF_MARW1, MINF_MARW1, 255, 255).into(),
                (MINF_MARF, MINF_MARF, 256, 256).into(),
                (MINF_MARW0, MINF_MARW0, 257, 257).into(),
                (MINF_MARF, MINF_MARF, 258, 258).into(),
                (MINF_MARW1, MINF_MARW1, 259, 259).into(),
                (MINF_MARF, MINF_MARF, 260, 260).into(),
                (MINF_MARW1, MINF_MARW1, 261, 261).into(),
                (MINF_MARF, MINF_MARF, 262, 262).into(),
                (MINF_MR, MINF_MR, 208, 208).into(),
                (MINF_MR, MINF_MR, 230, 230).into(),
                (MINF_MR, MINF_MR, 212, 212).into(),
                (MINF_MR, MINF_MR, 200, 200).into(),
                (MINF_MR, MINF_MR, 247, 247).into(),
                (MINF_MR, MINF_MR, 214, 214).into(),
                (MINF_MR, MINF_MR, 202, 202).into(),
                (MINF_MR, MINF_MR, 247, 247).into(),
                (MINF_MR, MINF_MR, 216, 216).into(),
                (MINF_MR, MINF_MR, 204, 204).into(),
                (MINF_MR, MINF_MR, 247, 247).into(),
                (MINF_MR, MINF_MR, 218, 218).into(),
                (MINF_MR, MINF_MR, 206, 206).into(),
                (MINF_MR, MINF_MR, 247, 247).into(),
            ],
            vec![
                ("ma_check_fix".to_string(), 248),
                ("ma_check_fix:md".to_string(), 252),
                ("ma_check_fix:md_0_putret_1_0".to_string(), 226),
                ("ma_check_fix:md_0_putret_1_1".to_string(), 228),
                ("ma_check_fix:md_0_putret_2_00".to_string(), 220),
                ("ma_check_fix:md_0_putret_2_01".to_string(), 222),
                ("ma_check_fix:md_0_putret_2_10".to_string(), 224),
                ("ma_check_fix:md_0_putret_x_0".to_string(), 210),
                ("ma_check_fix:md_0_putret_x_1".to_string(), 212),
                ("ma_check_fix:md_0_putret_x_10".to_string(), 214),
                ("ma_check_fix:md_0_putret_x_100".to_string(), 218),
                ("ma_check_fix:md_0_putret_x_11".to_string(), 216),
                ("ma_check_fix:md_after_ret_0".to_string(), 1),
                ("ma_check_fix:md_after_ret_1".to_string(), 265),
                ("ma_check_fix:md_after_ret_2".to_string(), 268),
                ("ma_check_fix:md_after_ret_3".to_string(), 271),
                ("ma_check_fix:md_after_ret_4".to_string(), 274),
                ("ma_check_fix:md_return".to_string(), 230),
                ("ma_check_fix:md_return_id_0_0".to_string(), 231),
                ("ma_check_fix:md_return_id_1_0".to_string(), 233),
                ("ma_check_fix:md_return_id_1_1".to_string(), 235),
                ("ma_check_fix:md_return_id_2_00".to_string(), 237),
                ("ma_check_fix:md_return_id_2_01".to_string(), 239),
                ("ma_check_fix:md_return_id_2_10".to_string(), 241),
                ("ma_check_fix_0_putret_x_0".to_string(), 208),
                ("ma_check_fix_after_ret_0".to_string(), 263),
                ("ma_check_fix_return".to_string(), 209),
                ("md_chunk_1_4".to_string(), 4),
                ("md_chunk_1_4_0_putret_x_0".to_string(), 12),
                ("md_chunk_1_4_return".to_string(), 13),
                ("md_chunk_21_8_0_putret_x_0".to_string(), 178),
                ("md_chunk_21_8_return".to_string(), 179),
                ("md_chunk_22_8_0_putret_x_0".to_string(), 180),
                ("md_chunk_22_8_return".to_string(), 181),
                ("md_chunk_23_8_0_putret_x_0".to_string(), 182),
                ("md_chunk_23_8_return".to_string(), 183),
                ("md_chunk_24_8_0_putret_x_0".to_string(), 184),
                ("md_chunk_24_8_return".to_string(), 185),
                ("md_chunk_2_4".to_string(), 14),
                ("md_chunk_2_4_0_putret_1_0".to_string(), 38),
                ("md_chunk_2_4_0_putret_1_1".to_string(), 40),
                ("md_chunk_2_4_0_putret_2_00".to_string(), 32),
                ("md_chunk_2_4_0_putret_2_01".to_string(), 34),
                ("md_chunk_2_4_0_putret_2_10".to_string(), 36),
                ("md_chunk_2_4_0_putret_x_0".to_string(), 22),
                ("md_chunk_2_4_0_putret_x_1".to_string(), 24),
                ("md_chunk_2_4_0_putret_x_10".to_string(), 26),
                ("md_chunk_2_4_0_putret_x_100".to_string(), 30),
                ("md_chunk_2_4_0_putret_x_11".to_string(), 28),
                ("md_chunk_2_4_return".to_string(), 42),
                ("md_chunk_2_4_return_id_0_0".to_string(), 43),
                ("md_chunk_2_4_return_id_1_0".to_string(), 45),
                ("md_chunk_2_4_return_id_1_1".to_string(), 47),
                ("md_chunk_2_4_return_id_2_00".to_string(), 49),
                ("md_chunk_2_4_return_id_2_01".to_string(), 51),
                ("md_chunk_2_4_return_id_2_10".to_string(), 53),
                ("md_chunk_368f_16_0_putret_x_0".to_string(), 198),
                ("md_chunk_368f_16_return".to_string(), 199),
                ("md_chunk_36_8_0_putret_x_0".to_string(), 186),
                ("md_chunk_36_8_return".to_string(), 187),
                ("md_chunk_3921_16_0_putret_x_0".to_string(), 200),
                ("md_chunk_3921_16_return".to_string(), 201),
                ("md_chunk_39_8_0_putret_x_0".to_string(), 188),
                ("md_chunk_39_8_return".to_string(), 189),
                ("md_chunk_3_4".to_string(), 55),
                ("md_chunk_3_4_0_putret_1_0".to_string(), 81),
                ("md_chunk_3_4_0_putret_1_1".to_string(), 83),
                ("md_chunk_3_4_0_putret_2_00".to_string(), 75),
                ("md_chunk_3_4_0_putret_2_01".to_string(), 77),
                ("md_chunk_3_4_0_putret_2_10".to_string(), 79),
                ("md_chunk_3_4_0_putret_x_0".to_string(), 63),
                ("md_chunk_3_4_0_putret_x_1".to_string(), 65),
                ("md_chunk_3_4_0_putret_x_10".to_string(), 67),
                ("md_chunk_3_4_0_putret_x_100".to_string(), 71),
                ("md_chunk_3_4_0_putret_x_101".to_string(), 73),
                ("md_chunk_3_4_0_putret_x_11".to_string(), 69),
                ("md_chunk_3_4_return".to_string(), 85),
                ("md_chunk_3_4_return_id_0_0".to_string(), 86),
                ("md_chunk_3_4_return_id_1_0".to_string(), 88),
                ("md_chunk_3_4_return_id_1_1".to_string(), 90),
                ("md_chunk_3_4_return_id_2_00".to_string(), 92),
                ("md_chunk_3_4_return_id_2_01".to_string(), 94),
                ("md_chunk_3_4_return_id_2_10".to_string(), 96),
                ("md_chunk_3a22_16_0_putret_x_0".to_string(), 202),
                ("md_chunk_3a22_16_return".to_string(), 203),
                ("md_chunk_3a_8_0_putret_x_0".to_string(), 190),
                ("md_chunk_3a_8_return".to_string(), 191),
                ("md_chunk_3b23_16_0_putret_x_0".to_string(), 204),
                ("md_chunk_3b23_16_return".to_string(), 205),
                ("md_chunk_3b_8_0_putret_x_0".to_string(), 192),
                ("md_chunk_3b_8_return".to_string(), 193),
                ("md_chunk_3c24_16_0_putret_x_0".to_string(), 206),
                ("md_chunk_3c24_16_return".to_string(), 207),
                ("md_chunk_3c_8_0_putret_x_0".to_string(), 194),
                ("md_chunk_3c_8_return".to_string(), 195),
                ("md_chunk_4_4".to_string(), 98),
                ("md_chunk_4_4_0_putret_x_0".to_string(), 106),
                ("md_chunk_4_4_return".to_string(), 107),
                ("md_chunk_6_4".to_string(), 108),
                ("md_chunk_6_4_0_putret_x_0".to_string(), 116),
                ("md_chunk_6_4_return".to_string(), 117),
                ("md_chunk_8_4".to_string(), 118),
                ("md_chunk_8_4_0_putret_x_0".to_string(), 126),
                ("md_chunk_8_4_return".to_string(), 127),
                ("md_chunk_8f_8_0_putret_x_0".to_string(), 196),
                ("md_chunk_8f_8_return".to_string(), 197),
                ("md_chunk_9_4".to_string(), 128),
                ("md_chunk_9_4_0_putret_x_0".to_string(), 136),
                ("md_chunk_9_4_return".to_string(), 137),
                ("md_chunk_a_4".to_string(), 138),
                ("md_chunk_a_4_0_putret_x_0".to_string(), 146),
                ("md_chunk_a_4_return".to_string(), 147),
                ("md_chunk_b_4".to_string(), 148),
                ("md_chunk_b_4_0_putret_x_0".to_string(), 156),
                ("md_chunk_b_4_return".to_string(), 157),
                ("md_chunk_c_4".to_string(), 158),
                ("md_chunk_c_4_0_putret_x_0".to_string(), 166),
                ("md_chunk_c_4_return".to_string(), 167),
                ("md_chunk_f_4".to_string(), 168),
                ("md_chunk_f_4_0_putret_x_0".to_string(), 176),
                ("md_chunk_f_4_return".to_string(), 177),
                ("md_next_0".to_string(), 266),
                ("md_next_1".to_string(), 269),
                ("md_next_2".to_string(), 272),
                ("md_next_3".to_string(), 275),
                ("md_next_4".to_string(), 2),
                ("myfunc1".to_string(), 264),
                ("myfunc1_0".to_string(), 264),
                ("myfunc1_0_putret_x_0".to_string(), 243),
                ("myfunc1_1".to_string(), 267),
                ("myfunc1_1_putret_x_0".to_string(), 244),
                ("myfunc1_2".to_string(), 270),
                ("myfunc1_2_putret_x_0".to_string(), 245),
                ("myfunc1_3".to_string(), 273),
                ("myfunc1_3_putret_x_0".to_string(), 246),
                ("myfunc1_after_ret_0".to_string(), 3),
                ("myfunc1_return".to_string(), 247),
            ]
        ),
        builder.to_code()
    );
}