aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/ia64/fpu/libm_lgammaf.S
blob: 7697cc69ed0601edd52c9a9ff3e7c7c7cd441b6c (plain)
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
.file "libm_lgammaf.s"


// Copyright (c) 2002 - 2005, Intel Corporation
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote
// products derived from this software without specific prior written
// permission.

// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,INCLUDING,BUT NOT
// LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT,INDIRECT,INCIDENTAL,SPECIAL,
// EXEMPLARY,OR CONSEQUENTIAL DAMAGES (INCLUDING,BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA,OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY,WHETHER IN CONTRACT,STRICT LIABILITY OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE,EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Intel Corporation is the author of this code,and requests that all
// problem reports or change requests be submitted to it directly at
// http://www.intel.com/software/products/opensource/libraries/num.htm.
//
//*********************************************************************
//
// History:
// 01/10/02  Initial version
// 01/25/02  Corrected parameter store, load, and tag for __libm_error_support
// 02/01/02  Added support of SIGN(GAMMA(x)) calculation
// 05/20/02  Cleaned up namespace and sf0 syntax
// 09/16/02  Improved accuracy on intervals reduced to [1;1.25]
// 10/21/02  Now it returns SIGN(GAMMA(x))=-1 for negative zero
// 02/10/03  Reordered header: .section, .global, .proc, .align
// 07/22/03  Reformatted some data tables
// 03/31/05  Reformatted delimiters between data tables
//
//*********************************************************************
//
//*********************************************************************
//
// Function: __libm_lgammaf(float x, int* signgam, int szsigngam)
// computes the principle value of the logarithm of the GAMMA function
// of x. Signum of GAMMA(x) is stored to memory starting at the address
// specified by the signgam.
//
//*********************************************************************
//
// Resources Used:
//
//    Floating-Point Registers: f6-f15
//                              f32-f97
//
//    General Purpose Registers:
//      r8-r11
//      r14-r30
//      r32-r36
//      r37-r40 (Used to pass arguments to error handling routine)
//
//    Predicate Registers:      p6-p15
//
//*********************************************************************
//
// IEEE Special Conditions:
//
//    lgamma(+inf) = +inf
//    lgamma(-inf) = +inf
//    lgamma(+/-0) = +inf
//    lgamma(x<0, x - integer) = +inf
//    lgamma(SNaN) = QNaN
//    lgamma(QNaN) = QNaN
//
//*********************************************************************
//
// Overview
//
// The method consists of three cases.
//
// If      2^13 <= x < OVERFLOW_BOUNDARY  use case lgammaf_pstirling;
// else if 1 < x < 2^13                   use case lgammaf_regular;
// else if -9 < x < 1                     use case lgammaf_negrecursion;
// else if -2^13 <  x < -9                use case lgammaf_negpoly;
// else if x < -2^13                      use case lgammaf_negstirling;
// else if x is close to negative
//         roots of ln(GAMMA(x))          use case lgammaf_negroots;
//
//
// Case 2^13 <= x < OVERFLOW_BOUNDARY
// ----------------------------------
//   Here we use algorithm based on the Stirling formula:
//     ln(GAMMA(x)) = ln(sqrt(2*Pi)) + (x-0.5)*ln(x) - x
//
// Case 1 < x < 2^13
// -----------------
//   To calculate ln(GAMMA(x)) for such arguments we use polynomial
//   approximation on following intervals: [1.0; 1.25), [1.25; 1.5),
//   [1.5, 1.75), [1.75; 2), [2; 4), [2^i; 2^(i+1)), i=1..8
//
//   Following variants of approximation and argument reduction are used:
//    1. [1.0; 1.25)
//       ln(GAMMA(x)) ~ (x-1.0)*P7(x)
//
//    2. [1.25; 1.5)
//       ln(GAMMA(x)) ~ ln(GAMMA(x0))+(x-x0)*P8(x-x0),
//       where x0 - point of local minimum on [1;2] rounded to nearest double
//       precision number.
//
//    3. [1.5; 1.75)
//       ln(GAMMA(x)) ~ P8(x)
//
//    4. [1.75; 2.0)
//       ln(GAMMA(x)) ~ (x-2)*P7(x)
//
//    5. [2; 4)
//       ln(GAMMA(x)) ~ (x-2)*P10(x)
//
//    6. [2^i; 2^(i+1)), i=2..8
//       ln(GAMMA(x)) ~ P10((x-2^i)/2^i)
//
// Case -9 < x < 1
// ---------------
//   Here we use the recursive formula:
//   ln(GAMMA(x)) = ln(GAMMA(x+1)) - ln(x)
//
//   Using this formula we reduce argument to base interval [1.0; 2.0]
//
// Case -2^13 < x < -9
// --------------------
//   Here we use the formula:
//   ln(GAMMA(x)) = ln(Pi/(|x|*GAMMA(|x|)*sin(Pi*|x|))) =
//   = -ln(|x|) - ln((GAMMA(|x|)) - ln(sin(Pi*r)/(Pi*r)) - ln(|r|)
//   where r = x - rounded_to_nearest(x), i.e |r| <= 0.5 and
//   ln(sin(Pi*r)/(Pi*r)) is approximated by 8-degree polynomial of r^2
//
// Case x < -2^13
// --------------
//   Here we use algorithm based on the Stirling formula:
//   ln(GAMMA(x)) = -ln(sqrt(2*Pi)) + (|x|-0.5)ln(x) - |x| -
//   - ln(sin(Pi*r)/(Pi*r)) - ln(|r|)
//   where r = x - rounded_to_nearest(x).
//
// Neighbourhoods of negative roots
// --------------------------------
//   Here we use polynomial approximation
//   ln(GAMMA(x-x0)) = ln(GAMMA(x0)) + (x-x0)*P14(x-x0),
//   where x0 is a root of ln(GAMMA(x)) rounded to nearest double
//   precision number.
//
//
// Claculation of logarithm
// ------------------------
//   Consider  x = 2^N * xf so
//   ln(x) = ln(frcpa(x)*x/frcpa(x))
//         = ln(1/frcpa(x)) + ln(frcpa(x)*x)
//
//   frcpa(x) = 2^(-N) * frcpa(xf)
//
//   ln(1/frcpa(x)) = -ln(2^(-N)) - ln(frcpa(xf))
//                  = N*ln(2) - ln(frcpa(xf))
//                  = N*ln(2) + ln(1/frcpa(xf))
//
//   ln(x) = ln(1/frcpa(x)) + ln(frcpa(x)*x) =
//         = N*ln(2) + ln(1/frcpa(xf)) + ln(frcpa(x)*x)
//         = N*ln(2) + T + ln(frcpa(x)*x)
//
//   Let r = 1 - frcpa(x)*x, note that r is quite small by
//   absolute value so
//
//   ln(x) = N*ln(2) + T + ln(1+r) ~ N*ln(2) + T + Series(r),
//   where T - is precomputed tabular value,
//   Series(r) = (P3*r + P2)*r^2 + (P1*r + 1)
//
//*********************************************************************

GR_TAG                 = r8
GR_ad_Data             = r8
GR_ad_Co               = r9
GR_ad_SignGam          = r10
GR_ad_Ce               = r10
GR_SignExp             = r11

GR_ad_C650             = r14
GR_ad_RootCo           = r14
GR_ad_C0               = r15
GR_Dx                  = r15
GR_Ind                 = r16
GR_Offs                = r17
GR_IntNum              = r17
GR_ExpBias             = r18
GR_ExpMask             = r19
GR_Ind4T               = r20
GR_RootInd             = r20
GR_Sig                 = r21
GR_Exp                 = r22
GR_PureExp             = r23
GR_ad_C43              = r24
GR_StirlBound          = r25
GR_ad_T                = r25
GR_IndX8               = r25
GR_Neg2                = r25
GR_2xDx                = r25
GR_SingBound           = r26
GR_IndX2               = r26
GR_Neg4                = r26
GR_ad_RootCe           = r26
GR_Arg                 = r27
GR_ExpOf2              = r28
GR_fff7                = r28
GR_Root                = r28
GR_ReqBound            = r28
GR_N                   = r29
GR_ad_Root             = r30
GR_ad_OvfBound         = r30
GR_SignOfGamma         = r31

GR_SAVE_B0             = r33
GR_SAVE_PFS            = r34
GR_SAVE_GP             = r35
GR_SAVE_SP             = r36

GR_Parameter_X         = r37
GR_Parameter_Y         = r38
GR_Parameter_RESULT    = r39
GR_Parameter_TAG       = r40

//*********************************************************************

FR_X                   = f10
FR_Y                   = f1 // lgammaf is single argument function
FR_RESULT              = f8

FR_x                   = f6
FR_x2                  = f7

FR_x3                  = f9
FR_x4                  = f10
FR_xm2                 = f11
FR_w                   = f11
FR_w2                  = f12
FR_Q32                 = f13
FR_Q10                 = f14
FR_InvX                = f15

FR_NormX               = f32

FR_A0                  = f33
FR_A1                  = f34
FR_A2                  = f35
FR_A3                  = f36
FR_A4                  = f37
FR_A5                  = f38
FR_A6                  = f39
FR_A7                  = f40
FR_A8                  = f41
FR_A9                  = f42
FR_A10                 = f43

FR_int_N               = f44
FR_P3                  = f45
FR_P2                  = f46
FR_P1                  = f47
FR_LocalMin            = f48
FR_Ln2                 = f49
FR_05                  = f50
FR_LnSqrt2Pi           = f51
FR_3                   = f52
FR_r                   = f53
FR_r2                  = f54
FR_T                   = f55
FR_N                   = f56
FR_xm05                = f57
FR_int_Ln              = f58
FR_P32                 = f59
FR_P10                 = f60

FR_Xf                  = f61
FR_InvXf               = f62
FR_rf                  = f63
FR_rf2                 = f64
FR_Tf                  = f65
FR_Nf                  = f66
FR_xm05f               = f67
FR_P32f                = f68
FR_P10f                = f69
FR_Lnf                 = f70
FR_Xf2                 = f71
FR_Xf4                 = f72
FR_Xf8                 = f73
FR_Ln                  = f74
FR_xx                  = f75
FR_Root                = f75
FR_Req                 = f76
FR_1pXf                = f77

FR_S16                 = f78
FR_R3                  = f78
FR_S14                 = f79
FR_R2                  = f79
FR_S12                 = f80
FR_R1                  = f80
FR_S10                 = f81
FR_R0                  = f81
FR_S8                  = f82
FR_rx                  = f82
FR_S6                  = f83
FR_rx2                 = f84
FR_S4                  = f84
FR_S2                  = f85

FR_Xp1                 = f86
FR_Xp2                 = f87
FR_Xp3                 = f88
FR_Xp4                 = f89
FR_Xp5                 = f90
FR_Xp6                 = f91
FR_Xp7                 = f92
FR_Xp8                 = f93
FR_OverflowBound       = f93

FR_2                   = f94
FR_tmp                 = f95
FR_int_Ntrunc          = f96
FR_Ntrunc              = f97

//*********************************************************************

RODATA
.align 32
LOCAL_OBJECT_START(lgammaf_data)
log_table_1:
data8 0xbfd0001008f39d59 // P3
data8 0x3fd5556073e0c45a // P2
data8 0x3fe62e42fefa39ef // ln(2)
data8 0x3fe0000000000000 // 0.5
//
data8 0x3F60040155D5889E //ln(1/frcpa(1+   0/256)
data8 0x3F78121214586B54 //ln(1/frcpa(1+   1/256)
data8 0x3F841929F96832F0 //ln(1/frcpa(1+   2/256)
data8 0x3F8C317384C75F06 //ln(1/frcpa(1+   3/256)
data8 0x3F91A6B91AC73386 //ln(1/frcpa(1+   4/256)
data8 0x3F95BA9A5D9AC039 //ln(1/frcpa(1+   5/256)
data8 0x3F99D2A8074325F4 //ln(1/frcpa(1+   6/256)
data8 0x3F9D6B2725979802 //ln(1/frcpa(1+   7/256)
data8 0x3FA0C58FA19DFAAA //ln(1/frcpa(1+   8/256)
data8 0x3FA2954C78CBCE1B //ln(1/frcpa(1+   9/256)
data8 0x3FA4A94D2DA96C56 //ln(1/frcpa(1+  10/256)
data8 0x3FA67C94F2D4BB58 //ln(1/frcpa(1+  11/256)
data8 0x3FA85188B630F068 //ln(1/frcpa(1+  12/256)
data8 0x3FAA6B8ABE73AF4C //ln(1/frcpa(1+  13/256)
data8 0x3FAC441E06F72A9E //ln(1/frcpa(1+  14/256)
data8 0x3FAE1E6713606D07 //ln(1/frcpa(1+  15/256)
data8 0x3FAFFA6911AB9301 //ln(1/frcpa(1+  16/256)
data8 0x3FB0EC139C5DA601 //ln(1/frcpa(1+  17/256)
data8 0x3FB1DBD2643D190B //ln(1/frcpa(1+  18/256)
data8 0x3FB2CC7284FE5F1C //ln(1/frcpa(1+  19/256)
data8 0x3FB3BDF5A7D1EE64 //ln(1/frcpa(1+  20/256)
data8 0x3FB4B05D7AA012E0 //ln(1/frcpa(1+  21/256)
data8 0x3FB580DB7CEB5702 //ln(1/frcpa(1+  22/256)
data8 0x3FB674F089365A7A //ln(1/frcpa(1+  23/256)
data8 0x3FB769EF2C6B568D //ln(1/frcpa(1+  24/256)
data8 0x3FB85FD927506A48 //ln(1/frcpa(1+  25/256)
data8 0x3FB9335E5D594989 //ln(1/frcpa(1+  26/256)
data8 0x3FBA2B0220C8E5F5 //ln(1/frcpa(1+  27/256)
data8 0x3FBB0004AC1A86AC //ln(1/frcpa(1+  28/256)
data8 0x3FBBF968769FCA11 //ln(1/frcpa(1+  29/256)
data8 0x3FBCCFEDBFEE13A8 //ln(1/frcpa(1+  30/256)
data8 0x3FBDA727638446A2 //ln(1/frcpa(1+  31/256)
data8 0x3FBEA3257FE10F7A //ln(1/frcpa(1+  32/256)
data8 0x3FBF7BE9FEDBFDE6 //ln(1/frcpa(1+  33/256)
data8 0x3FC02AB352FF25F4 //ln(1/frcpa(1+  34/256)
data8 0x3FC097CE579D204D //ln(1/frcpa(1+  35/256)
data8 0x3FC1178E8227E47C //ln(1/frcpa(1+  36/256)
data8 0x3FC185747DBECF34 //ln(1/frcpa(1+  37/256)
data8 0x3FC1F3B925F25D41 //ln(1/frcpa(1+  38/256)
data8 0x3FC2625D1E6DDF57 //ln(1/frcpa(1+  39/256)
data8 0x3FC2D1610C86813A //ln(1/frcpa(1+  40/256)
data8 0x3FC340C59741142E //ln(1/frcpa(1+  41/256)
data8 0x3FC3B08B6757F2A9 //ln(1/frcpa(1+  42/256)
data8 0x3FC40DFB08378003 //ln(1/frcpa(1+  43/256)
data8 0x3FC47E74E8CA5F7C //ln(1/frcpa(1+  44/256)
data8 0x3FC4EF51F6466DE4 //ln(1/frcpa(1+  45/256)
data8 0x3FC56092E02BA516 //ln(1/frcpa(1+  46/256)
data8 0x3FC5D23857CD74D5 //ln(1/frcpa(1+  47/256)
data8 0x3FC6313A37335D76 //ln(1/frcpa(1+  48/256)
data8 0x3FC6A399DABBD383 //ln(1/frcpa(1+  49/256)
data8 0x3FC70337DD3CE41B //ln(1/frcpa(1+  50/256)
data8 0x3FC77654128F6127 //ln(1/frcpa(1+  51/256)
data8 0x3FC7E9D82A0B022D //ln(1/frcpa(1+  52/256)
data8 0x3FC84A6B759F512F //ln(1/frcpa(1+  53/256)
data8 0x3FC8AB47D5F5A310 //ln(1/frcpa(1+  54/256)
data8 0x3FC91FE49096581B //ln(1/frcpa(1+  55/256)
data8 0x3FC981634011AA75 //ln(1/frcpa(1+  56/256)
data8 0x3FC9F6C407089664 //ln(1/frcpa(1+  57/256)
data8 0x3FCA58E729348F43 //ln(1/frcpa(1+  58/256)
data8 0x3FCABB55C31693AD //ln(1/frcpa(1+  59/256)
data8 0x3FCB1E104919EFD0 //ln(1/frcpa(1+  60/256)
data8 0x3FCB94EE93E367CB //ln(1/frcpa(1+  61/256)
data8 0x3FCBF851C067555F //ln(1/frcpa(1+  62/256)
data8 0x3FCC5C0254BF23A6 //ln(1/frcpa(1+  63/256)
data8 0x3FCCC000C9DB3C52 //ln(1/frcpa(1+  64/256)
data8 0x3FCD244D99C85674 //ln(1/frcpa(1+  65/256)
data8 0x3FCD88E93FB2F450 //ln(1/frcpa(1+  66/256)
data8 0x3FCDEDD437EAEF01 //ln(1/frcpa(1+  67/256)
data8 0x3FCE530EFFE71012 //ln(1/frcpa(1+  68/256)
data8 0x3FCEB89A1648B971 //ln(1/frcpa(1+  69/256)
data8 0x3FCF1E75FADF9BDE //ln(1/frcpa(1+  70/256)
data8 0x3FCF84A32EAD7C35 //ln(1/frcpa(1+  71/256)
data8 0x3FCFEB2233EA07CD //ln(1/frcpa(1+  72/256)
data8 0x3FD028F9C7035C1C //ln(1/frcpa(1+  73/256)
data8 0x3FD05C8BE0D9635A //ln(1/frcpa(1+  74/256)
data8 0x3FD085EB8F8AE797 //ln(1/frcpa(1+  75/256)
data8 0x3FD0B9C8E32D1911 //ln(1/frcpa(1+  76/256)
data8 0x3FD0EDD060B78081 //ln(1/frcpa(1+  77/256)
data8 0x3FD122024CF0063F //ln(1/frcpa(1+  78/256)
data8 0x3FD14BE2927AECD4 //ln(1/frcpa(1+  79/256)
data8 0x3FD180618EF18ADF //ln(1/frcpa(1+  80/256)
data8 0x3FD1B50BBE2FC63B //ln(1/frcpa(1+  81/256)
data8 0x3FD1DF4CC7CF242D //ln(1/frcpa(1+  82/256)
data8 0x3FD214456D0EB8D4 //ln(1/frcpa(1+  83/256)
data8 0x3FD23EC5991EBA49 //ln(1/frcpa(1+  84/256)
data8 0x3FD2740D9F870AFB //ln(1/frcpa(1+  85/256)
data8 0x3FD29ECDABCDFA04 //ln(1/frcpa(1+  86/256)
data8 0x3FD2D46602ADCCEE //ln(1/frcpa(1+  87/256)
data8 0x3FD2FF66B04EA9D4 //ln(1/frcpa(1+  88/256)
data8 0x3FD335504B355A37 //ln(1/frcpa(1+  89/256)
data8 0x3FD360925EC44F5D //ln(1/frcpa(1+  90/256)
data8 0x3FD38BF1C3337E75 //ln(1/frcpa(1+  91/256)
data8 0x3FD3C25277333184 //ln(1/frcpa(1+  92/256)
data8 0x3FD3EDF463C1683E //ln(1/frcpa(1+  93/256)
data8 0x3FD419B423D5E8C7 //ln(1/frcpa(1+  94/256)
data8 0x3FD44591E0539F49 //ln(1/frcpa(1+  95/256)
data8 0x3FD47C9175B6F0AD //ln(1/frcpa(1+  96/256)
data8 0x3FD4A8B341552B09 //ln(1/frcpa(1+  97/256)
data8 0x3FD4D4F3908901A0 //ln(1/frcpa(1+  98/256)
data8 0x3FD501528DA1F968 //ln(1/frcpa(1+  99/256)
data8 0x3FD52DD06347D4F6 //ln(1/frcpa(1+ 100/256)
data8 0x3FD55A6D3C7B8A8A //ln(1/frcpa(1+ 101/256)
data8 0x3FD5925D2B112A59 //ln(1/frcpa(1+ 102/256)
data8 0x3FD5BF406B543DB2 //ln(1/frcpa(1+ 103/256)
data8 0x3FD5EC433D5C35AE //ln(1/frcpa(1+ 104/256)
data8 0x3FD61965CDB02C1F //ln(1/frcpa(1+ 105/256)
data8 0x3FD646A84935B2A2 //ln(1/frcpa(1+ 106/256)
data8 0x3FD6740ADD31DE94 //ln(1/frcpa(1+ 107/256)
data8 0x3FD6A18DB74A58C5 //ln(1/frcpa(1+ 108/256)
data8 0x3FD6CF31058670EC //ln(1/frcpa(1+ 109/256)
data8 0x3FD6F180E852F0BA //ln(1/frcpa(1+ 110/256)
data8 0x3FD71F5D71B894F0 //ln(1/frcpa(1+ 111/256)
data8 0x3FD74D5AEFD66D5C //ln(1/frcpa(1+ 112/256)
data8 0x3FD77B79922BD37E //ln(1/frcpa(1+ 113/256)
data8 0x3FD7A9B9889F19E2 //ln(1/frcpa(1+ 114/256)
data8 0x3FD7D81B037EB6A6 //ln(1/frcpa(1+ 115/256)
data8 0x3FD8069E33827231 //ln(1/frcpa(1+ 116/256)
data8 0x3FD82996D3EF8BCB //ln(1/frcpa(1+ 117/256)
data8 0x3FD85855776DCBFB //ln(1/frcpa(1+ 118/256)
data8 0x3FD8873658327CCF //ln(1/frcpa(1+ 119/256)
data8 0x3FD8AA75973AB8CF //ln(1/frcpa(1+ 120/256)
data8 0x3FD8D992DC8824E5 //ln(1/frcpa(1+ 121/256)
data8 0x3FD908D2EA7D9512 //ln(1/frcpa(1+ 122/256)
data8 0x3FD92C59E79C0E56 //ln(1/frcpa(1+ 123/256)
data8 0x3FD95BD750EE3ED3 //ln(1/frcpa(1+ 124/256)
data8 0x3FD98B7811A3EE5B //ln(1/frcpa(1+ 125/256)
data8 0x3FD9AF47F33D406C //ln(1/frcpa(1+ 126/256)
data8 0x3FD9DF270C1914A8 //ln(1/frcpa(1+ 127/256)
data8 0x3FDA0325ED14FDA4 //ln(1/frcpa(1+ 128/256)
data8 0x3FDA33440224FA79 //ln(1/frcpa(1+ 129/256)
data8 0x3FDA57725E80C383 //ln(1/frcpa(1+ 130/256)
data8 0x3FDA87D0165DD199 //ln(1/frcpa(1+ 131/256)
data8 0x3FDAAC2E6C03F896 //ln(1/frcpa(1+ 132/256)
data8 0x3FDADCCC6FDF6A81 //ln(1/frcpa(1+ 133/256)
data8 0x3FDB015B3EB1E790 //ln(1/frcpa(1+ 134/256)
data8 0x3FDB323A3A635948 //ln(1/frcpa(1+ 135/256)
data8 0x3FDB56FA04462909 //ln(1/frcpa(1+ 136/256)
data8 0x3FDB881AA659BC93 //ln(1/frcpa(1+ 137/256)
data8 0x3FDBAD0BEF3DB165 //ln(1/frcpa(1+ 138/256)
data8 0x3FDBD21297781C2F //ln(1/frcpa(1+ 139/256)
data8 0x3FDC039236F08819 //ln(1/frcpa(1+ 140/256)
data8 0x3FDC28CB1E4D32FD //ln(1/frcpa(1+ 141/256)
data8 0x3FDC4E19B84723C2 //ln(1/frcpa(1+ 142/256)
data8 0x3FDC7FF9C74554C9 //ln(1/frcpa(1+ 143/256)
data8 0x3FDCA57B64E9DB05 //ln(1/frcpa(1+ 144/256)
data8 0x3FDCCB130A5CEBB0 //ln(1/frcpa(1+ 145/256)
data8 0x3FDCF0C0D18F326F //ln(1/frcpa(1+ 146/256)
data8 0x3FDD232075B5A201 //ln(1/frcpa(1+ 147/256)
data8 0x3FDD490246DEFA6B //ln(1/frcpa(1+ 148/256)
data8 0x3FDD6EFA918D25CD //ln(1/frcpa(1+ 149/256)
data8 0x3FDD9509707AE52F //ln(1/frcpa(1+ 150/256)
data8 0x3FDDBB2EFE92C554 //ln(1/frcpa(1+ 151/256)
data8 0x3FDDEE2F3445E4AF //ln(1/frcpa(1+ 152/256)
data8 0x3FDE148A1A2726CE //ln(1/frcpa(1+ 153/256)
data8 0x3FDE3AFC0A49FF40 //ln(1/frcpa(1+ 154/256)
data8 0x3FDE6185206D516E //ln(1/frcpa(1+ 155/256)
data8 0x3FDE882578823D52 //ln(1/frcpa(1+ 156/256)
data8 0x3FDEAEDD2EAC990C //ln(1/frcpa(1+ 157/256)
data8 0x3FDED5AC5F436BE3 //ln(1/frcpa(1+ 158/256)
data8 0x3FDEFC9326D16AB9 //ln(1/frcpa(1+ 159/256)
data8 0x3FDF2391A2157600 //ln(1/frcpa(1+ 160/256)
data8 0x3FDF4AA7EE03192D //ln(1/frcpa(1+ 161/256)
data8 0x3FDF71D627C30BB0 //ln(1/frcpa(1+ 162/256)
data8 0x3FDF991C6CB3B379 //ln(1/frcpa(1+ 163/256)
data8 0x3FDFC07ADA69A910 //ln(1/frcpa(1+ 164/256)
data8 0x3FDFE7F18EB03D3E //ln(1/frcpa(1+ 165/256)
data8 0x3FE007C053C5002E //ln(1/frcpa(1+ 166/256)
data8 0x3FE01B942198A5A1 //ln(1/frcpa(1+ 167/256)
data8 0x3FE02F74400C64EB //ln(1/frcpa(1+ 168/256)
data8 0x3FE04360BE7603AD //ln(1/frcpa(1+ 169/256)
data8 0x3FE05759AC47FE34 //ln(1/frcpa(1+ 170/256)
data8 0x3FE06B5F1911CF52 //ln(1/frcpa(1+ 171/256)
data8 0x3FE078BF0533C568 //ln(1/frcpa(1+ 172/256)
data8 0x3FE08CD9687E7B0E //ln(1/frcpa(1+ 173/256)
data8 0x3FE0A10074CF9019 //ln(1/frcpa(1+ 174/256)
data8 0x3FE0B5343A234477 //ln(1/frcpa(1+ 175/256)
data8 0x3FE0C974C89431CE //ln(1/frcpa(1+ 176/256)
data8 0x3FE0DDC2305B9886 //ln(1/frcpa(1+ 177/256)
data8 0x3FE0EB524BAFC918 //ln(1/frcpa(1+ 178/256)
data8 0x3FE0FFB54213A476 //ln(1/frcpa(1+ 179/256)
data8 0x3FE114253DA97D9F //ln(1/frcpa(1+ 180/256)
data8 0x3FE128A24F1D9AFF //ln(1/frcpa(1+ 181/256)
data8 0x3FE1365252BF0865 //ln(1/frcpa(1+ 182/256)
data8 0x3FE14AE558B4A92D //ln(1/frcpa(1+ 183/256)
data8 0x3FE15F85A19C765B //ln(1/frcpa(1+ 184/256)
data8 0x3FE16D4D38C119FA //ln(1/frcpa(1+ 185/256)
data8 0x3FE18203C20DD133 //ln(1/frcpa(1+ 186/256)
data8 0x3FE196C7BC4B1F3B //ln(1/frcpa(1+ 187/256)
data8 0x3FE1A4A738B7A33C //ln(1/frcpa(1+ 188/256)
data8 0x3FE1B981C0C9653D //ln(1/frcpa(1+ 189/256)
data8 0x3FE1CE69E8BB106B //ln(1/frcpa(1+ 190/256)
data8 0x3FE1DC619DE06944 //ln(1/frcpa(1+ 191/256)
data8 0x3FE1F160A2AD0DA4 //ln(1/frcpa(1+ 192/256)
data8 0x3FE2066D7740737E //ln(1/frcpa(1+ 193/256)
data8 0x3FE2147DBA47A394 //ln(1/frcpa(1+ 194/256)
data8 0x3FE229A1BC5EBAC3 //ln(1/frcpa(1+ 195/256)
data8 0x3FE237C1841A502E //ln(1/frcpa(1+ 196/256)
data8 0x3FE24CFCE6F80D9A //ln(1/frcpa(1+ 197/256)
data8 0x3FE25B2C55CD5762 //ln(1/frcpa(1+ 198/256)
data8 0x3FE2707F4D5F7C41 //ln(1/frcpa(1+ 199/256)
data8 0x3FE285E0842CA384 //ln(1/frcpa(1+ 200/256)
data8 0x3FE294294708B773 //ln(1/frcpa(1+ 201/256)
data8 0x3FE2A9A2670AFF0C //ln(1/frcpa(1+ 202/256)
data8 0x3FE2B7FB2C8D1CC1 //ln(1/frcpa(1+ 203/256)
data8 0x3FE2C65A6395F5F5 //ln(1/frcpa(1+ 204/256)
data8 0x3FE2DBF557B0DF43 //ln(1/frcpa(1+ 205/256)
data8 0x3FE2EA64C3F97655 //ln(1/frcpa(1+ 206/256)
data8 0x3FE3001823684D73 //ln(1/frcpa(1+ 207/256)
data8 0x3FE30E97E9A8B5CD //ln(1/frcpa(1+ 208/256)
data8 0x3FE32463EBDD34EA //ln(1/frcpa(1+ 209/256)
data8 0x3FE332F4314AD796 //ln(1/frcpa(1+ 210/256)
data8 0x3FE348D90E7464D0 //ln(1/frcpa(1+ 211/256)
data8 0x3FE35779F8C43D6E //ln(1/frcpa(1+ 212/256)
data8 0x3FE36621961A6A99 //ln(1/frcpa(1+ 213/256)
data8 0x3FE37C299F3C366A //ln(1/frcpa(1+ 214/256)
data8 0x3FE38AE2171976E7 //ln(1/frcpa(1+ 215/256)
data8 0x3FE399A157A603E7 //ln(1/frcpa(1+ 216/256)
data8 0x3FE3AFCCFE77B9D1 //ln(1/frcpa(1+ 217/256)
data8 0x3FE3BE9D503533B5 //ln(1/frcpa(1+ 218/256)
data8 0x3FE3CD7480B4A8A3 //ln(1/frcpa(1+ 219/256)
data8 0x3FE3E3C43918F76C //ln(1/frcpa(1+ 220/256)
data8 0x3FE3F2ACB27ED6C7 //ln(1/frcpa(1+ 221/256)
data8 0x3FE4019C2125CA93 //ln(1/frcpa(1+ 222/256)
data8 0x3FE4181061389722 //ln(1/frcpa(1+ 223/256)
data8 0x3FE42711518DF545 //ln(1/frcpa(1+ 224/256)
data8 0x3FE436194E12B6BF //ln(1/frcpa(1+ 225/256)
data8 0x3FE445285D68EA69 //ln(1/frcpa(1+ 226/256)
data8 0x3FE45BCC464C893A //ln(1/frcpa(1+ 227/256)
data8 0x3FE46AED21F117FC //ln(1/frcpa(1+ 228/256)
data8 0x3FE47A1527E8A2D3 //ln(1/frcpa(1+ 229/256)
data8 0x3FE489445EFFFCCC //ln(1/frcpa(1+ 230/256)
data8 0x3FE4A018BCB69835 //ln(1/frcpa(1+ 231/256)
data8 0x3FE4AF5A0C9D65D7 //ln(1/frcpa(1+ 232/256)
data8 0x3FE4BEA2A5BDBE87 //ln(1/frcpa(1+ 233/256)
data8 0x3FE4CDF28F10AC46 //ln(1/frcpa(1+ 234/256)
data8 0x3FE4DD49CF994058 //ln(1/frcpa(1+ 235/256)
data8 0x3FE4ECA86E64A684 //ln(1/frcpa(1+ 236/256)
data8 0x3FE503C43CD8EB68 //ln(1/frcpa(1+ 237/256)
data8 0x3FE513356667FC57 //ln(1/frcpa(1+ 238/256)
data8 0x3FE522AE0738A3D8 //ln(1/frcpa(1+ 239/256)
data8 0x3FE5322E26867857 //ln(1/frcpa(1+ 240/256)
data8 0x3FE541B5CB979809 //ln(1/frcpa(1+ 241/256)
data8 0x3FE55144FDBCBD62 //ln(1/frcpa(1+ 242/256)
data8 0x3FE560DBC45153C7 //ln(1/frcpa(1+ 243/256)
data8 0x3FE5707A26BB8C66 //ln(1/frcpa(1+ 244/256)
data8 0x3FE587F60ED5B900 //ln(1/frcpa(1+ 245/256)
data8 0x3FE597A7977C8F31 //ln(1/frcpa(1+ 246/256)
data8 0x3FE5A760D634BB8B //ln(1/frcpa(1+ 247/256)
data8 0x3FE5B721D295F10F //ln(1/frcpa(1+ 248/256)
data8 0x3FE5C6EA94431EF9 //ln(1/frcpa(1+ 249/256)
data8 0x3FE5D6BB22EA86F6 //ln(1/frcpa(1+ 250/256)
data8 0x3FE5E6938645D390 //ln(1/frcpa(1+ 251/256)
data8 0x3FE5F673C61A2ED2 //ln(1/frcpa(1+ 252/256)
data8 0x3FE6065BEA385926 //ln(1/frcpa(1+ 253/256)
data8 0x3FE6164BFA7CC06B //ln(1/frcpa(1+ 254/256)
data8 0x3FE62643FECF9743 //ln(1/frcpa(1+ 255/256)
//
// [2;4)
data8 0xBEB2CC7A38B9355F,0x3F035F2D1833BF4C // A10,A9
data8 0xBFF51BAA7FD27785,0x3FFC9D5D5B6CDEFF // A2,A1
data8 0xBF421676F9CB46C7,0x3F7437F2FA1436C6 // A8,A7
data8 0xBFD7A7041DE592FE,0x3FE9F107FEE8BD29 // A4,A3
// [4;8)
data8 0x3F6BBBD68451C0CD,0xBF966EC3272A16F7 // A10,A9
data8 0x40022A24A39AD769,0x4014190EDF49C8C5 // A2,A1
data8 0x3FB130FD016EE241,0xBFC151B46E635248 // A8,A7
data8 0x3FDE8F611965B5FE,0xBFEB5110EB265E3D // A4,A3
// [8;16)
data8 0x3F736EF93508626A,0xBF9FE5DBADF58AF1 // A10,A9
data8 0x40110A9FC5192058,0x40302008A6F96B29 // A2,A1
data8 0x3FB8E74E0CE1E4B5,0xBFC9B5DA78873656 // A8,A7
data8 0x3FE99D0DF10022DC,0xBFF829C0388F9484 // A4,A3
// [16;32)
data8 0x3F7FFF9D6D7E9269,0xBFAA780A249AEDB1 // A10,A9
data8 0x402082A807AEA080,0x4045ED9868408013 // A2,A1
data8 0x3FC4E1E54C2F99B7,0xBFD5DE2D6FFF1490 // A8,A7
data8 0x3FF75FC89584AE87,0xC006B4BADD886CAE // A4,A3
// [32;64)
data8 0x3F8CE54375841A5F,0xBFB801ABCFFA1BE2 // A10,A9
data8 0x403040A8B1815BDA,0x405B99A917D24B7A // A2,A1
data8 0x3FD30CAB81BFFA03,0xBFE41AEF61ECF48B // A8,A7
data8 0x400650CC136BEC43,0xC016022046E8292B // A4,A3
// [64;128)
data8 0x3F9B69BD22CAA8B8,0xBFC6D48875B7A213 // A10,A9
data8 0x40402028CCAA2F6D,0x40709AACEB3CBE0F // A2,A1
data8 0x3FE22C6A5924761E,0xBFF342F5F224523D // A8,A7
data8 0x4015CD405CCA331F,0xC025AAD10482C769 // A4,A3
// [128;256)
data8 0x3FAAAD9CD0E40D06,0xBFD63FC8505D80CB // A10,A9
data8 0x40501008D56C2648,0x408364794B0F4376 // A2,A1
data8 0x3FF1BE0126E00284,0xC002D8E3F6F7F7CA // A8,A7
data8 0x40258C757E95D860,0xC0357FA8FD398011 // A4,A3
// [256;512)
data8 0x3FBA4DAC59D49FEB,0xBFE5F476D1C43A77 // A10,A9
data8 0x40600800D890C7C6,0x40962C42AAEC8EF0 // A2,A1
data8 0x40018680ECF19B89,0xC012A3EB96FB7BA4 // A8,A7
data8 0x40356C4CDD3B60F9,0xC0456A34BF18F440 // A4,A3
// [512;1024)
data8 0x3FCA1B54F6225A5A,0xBFF5CD67BA10E048 // A10,A9
data8 0x407003FED94C58C2,0x40A8F30B4ACBCD22 // A2,A1
data8 0x40116A135EB66D8C,0xC022891B1CED527E // A8,A7
data8 0x40455C4617FDD8BC,0xC0555F82729E59C4 // A4,A3
// [1024;2048)
data8 0x3FD9FFF9095C6EC9,0xC005B88CB25D76C9 // A10,A9
data8 0x408001FE58FA734D,0x40BBB953BAABB0F3 // A2,A1
data8 0x40215B2F9FEB5D87,0xC0327B539DEA5058 // A8,A7
data8 0x40555444B3E8D64D,0xC0655A2B26F9FC8A // A4,A3
// [2048;4096)
data8 0x3FE9F065A1C3D6B1,0xC015ACF6FAE8D78D // A10,A9
data8 0x409000FE383DD2B7,0x40CE7F5C1E8BCB8B // A2,A1
data8 0x40315324E5DB2EBE,0xC04274194EF70D18 // A8,A7
data8 0x4065504353FF2207,0xC075577FE1BFE7B6 // A4,A3
// [4096;8192)
data8 0x3FF9E6FBC6B1C70D,0xC025A62DAF76F85D // A10,A9
data8 0x40A0007E2F61EBE8,0x40E0A2A23FB5F6C3 // A2,A1
data8 0x40414E9BC0A0141A,0xC0527030F2B69D43 // A8,A7
data8 0x40754E417717B45B,0xC085562A447258E5 // A4,A3
//
data8 0xbfdffffffffaea15 // P1
data8 0x3FDD8B618D5AF8FE // point of local minimum on [1;2]
data8 0x3FED67F1C864BEB5 // ln(sqrt(2*Pi))
data8 0x4008000000000000 // 3.0
//
data8 0xBF9E1C289FB224AB,0x3FBF7422445C9460 // A6,A5
data8 0xBFF01E76D66F8D8A // A0
data8 0xBFE2788CFC6F91DA // A1 [1.0;1.25)
data8 0x3FCB8CC69000EB5C,0xBFD41997A0C2C641 // A6,A5
data8 0x3FFCAB0BFA0EA462 // A0
data8 0xBFBF19B9BCC38A42 // A0 [1.25;1.5)
data8 0x3FD51EE4DE0A364C,0xBFE00D7F98A16E4B // A6,A5
data8 0x40210CE1F327E9E4 // A0
data8 0x4001DB08F9DFA0CC // A0 [1.5;1.75)
data8 0x3FE24F606742D252,0xBFEC81D7D12574EC // A6,A5
data8 0x403BE636A63A9C27 // A0
data8 0x4000A0CB38D6CF0A // A0 [1.75;2.0)
data8 0x3FF1029A9DD542B4,0xBFFAD37C209D3B25 // A6,A5
data8 0x405385E6FD9BE7EA // A0
data8 0x478895F1C0000000 // Overflow boundary
data8 0x400062D97D26B523,0xC00A03E1529FF023 // A6,A5
data8 0x4069204C51E566CE // A0
data8 0x0000000000000000 // pad
data8 0x40101476B38FD501,0xC0199DE7B387C0FC // A6,A5
data8 0x407EB8DAEC83D759 // A0
data8 0x0000000000000000 // pad
data8 0x401FDB008D65125A,0xC0296B506E665581 // A6,A5
data8 0x409226D93107EF66 // A0
data8 0x0000000000000000 // pad
data8 0x402FB3EAAF3E7B2D,0xC039521142AD8E0D // A6,A5
data8 0x40A4EFA4F072792E // A0
data8 0x0000000000000000 // pad
data8 0x403FA024C66B2563,0xC0494569F250E691 // A6,A5
data8 0x40B7B747C9235BB8 // A0
data8 0x0000000000000000 // pad
data8 0x404F9607D6DA512C,0xC0593F0B2EDDB4BC // A6,A5
data8 0x40CA7E29C5F16DE2 // A0
data8 0x0000000000000000 // pad
data8 0x405F90C5F613D98D,0xC0693BD130E50AAF // A6,A5
data8 0x40DD4495238B190C // A0
data8 0x0000000000000000 // pad
//
// polynomial approximation of ln(sin(Pi*x)/(Pi*x)), |x| <= 0.5
data8 0xBFD58731A486E820,0xBFA4452CC28E15A9 // S16,S14
data8 0xBFD013F6E1B86C4F,0xBFD5B3F19F7A341F // S8,S6
data8 0xBFC86A0D5252E778,0xBFC93E08C9EE284B // S12,S10
data8 0xBFE15132555C9EDD,0xBFFA51A662480E35 // S4,S2
//
// [1.0;1.25)
data8 0xBFA697D6775F48EA,0x3FB9894B682A98E7 // A9,A8
data8 0xBFCA8969253CFF55,0x3FD15124EFB35D9D // A5,A4
data8 0xBFC1B00158AB719D,0x3FC5997D04E7F1C1 // A7,A6
data8 0xBFD9A4D50BAFF989,0x3FEA51A661F5176A // A3,A2
// [1.25;1.5)
data8 0x3F838E0D35A6171A,0xBF831BBBD61313B7 // A8,A7
data8 0x3FB08B40196425D0,0xBFC2E427A53EB830 // A4,A3
data8 0x3F9285DDDC20D6C3,0xBFA0C90C9C223044 // A6,A5
data8 0x3FDEF72BC8F5287C,0x3D890B3DAEBC1DFC // A2,A1
// [1.5;1.75)
data8 0x3F65D5A7EB31047F,0xBFA44EAC9BFA7FDE // A8,A7
data8 0x40051FEFE7A663D8,0xC012A5CFE00A2522 // A4,A3
data8 0x3FD0E1583AB00E08,0xBFF084AF95883BA5 // A6,A5
data8 0x40185982877AE0A2,0xC015F83DB73B57B7 // A2,A1
// [1.75;2.0)
data8 0x3F4A9222032EB39A,0xBF8CBC9587EEA5A3 // A8,A7
data8 0x3FF795400783BE49,0xC00851BC418B8A25 // A4,A3
data8 0x3FBBC992783E8C5B,0xBFDFA67E65E89B29 // A6,A5
data8 0x4012B408F02FAF88,0xC013284CE7CB0C39 // A2,A1
//
// roots
data8 0xC003A7FC9600F86C // -2.4570247382208005860
data8 0xC009260DBC9E59AF // -3.1435808883499798405
data8 0xC005FB410A1BD901 // -2.7476826467274126919
data8 0xC00FA471547C2FE5 // -3.9552942848585979085
//
// polynomial approximation of ln(GAMMA(x)) near roots
// near -2.4570247382208005860
data8 0x3FF694A6058D9592,0x40136EEBB003A92B // R3,R2
data8 0x3FF83FE966AF5360,0x3C90323B6D1FE86D // R1,R0
// near -3.1435808883499798405
data8 0x405C11371268DA38,0x4039D4D2977D2C23 // R3,R2
data8 0x401F20A65F2FAC62,0x3CDE9605E3AE7A62 // R1,R0
// near -2.7476826467274126919
data8 0xC034185AC31314FF,0x4023267F3C28DFE3 // R3,R2
data8 0xBFFEA12DA904B194,0x3CA8FB8530BA7689 // R1,R0
// near -2.7476826467274126919
data8 0xC0AD25359E70C888,0x406F76DEAEA1B8C6 // R3,R2
data8 0xC034B99D966C5644,0xBCBDDC0336980B58 // R1,R0
LOCAL_OBJECT_END(lgammaf_data)

//*********************************************************************

.section .text
GLOBAL_LIBM_ENTRY(__libm_lgammaf)
{ .mfi
      getf.exp      GR_SignExp = f8
      frcpa.s1      FR_InvX,p0 = f1,f8
      mov           GR_ExpOf2 = 0x10000
}
{ .mfi
      addl          GR_ad_Data = @ltoff(lgammaf_data),gp
      fcvt.fx.s1    FR_int_N = f8
      mov           GR_ExpMask = 0x1ffff
};;
{ .mfi
      getf.sig      GR_Sig = f8
      fclass.m      p13,p0 = f8,0x1EF // is x NaTVal, NaN,
                                      // +/-0, +/-INF or +/-deno?
      mov           GR_ExpBias = 0xffff
}
{ .mfi
      ld8           GR_ad_Data = [GR_ad_Data]
      fma.s1        FR_Xp1 = f8,f1,f1
      mov           GR_StirlBound = 0x1000C
};;
{ .mfi
      setf.exp      FR_2 = GR_ExpOf2
      fmerge.se     FR_x = f1,f8
      dep.z         GR_Ind = GR_SignExp,3,4
}
{ .mfi
      cmp.eq        p8,p0 = GR_SignExp,GR_ExpBias
      fcvt.fx.trunc.s1 FR_int_Ntrunc = f8
      and           GR_Exp = GR_ExpMask,GR_SignExp
};;
{ .mfi
      add           GR_ad_C650 = 0xB20,GR_ad_Data
      fcmp.lt.s1    p14,p15 = f8,f0
      extr.u        GR_Ind4T = GR_Sig,55,8
}
{ .mfb
      sub           GR_PureExp = GR_Exp,GR_ExpBias
      fnorm.s1      FR_NormX = f8
      // jump if x is NaTVal, NaN, +/-0, +/-INF or +/-deno
(p13) br.cond.spnt  lgammaf_spec
};;
lgammaf_core:
{ .mfi
      ldfpd         FR_P1,FR_LocalMin = [GR_ad_C650],16
      fms.s1        FR_xm2 = f8,f1,f1
      add           GR_ad_Co = 0x820,GR_ad_Data
}
{ .mib
      ldfpd         FR_P3,FR_P2 = [GR_ad_Data],16
      cmp.ltu       p9,p0 = GR_SignExp,GR_ExpBias
      // jump if x is from the interval [1; 2)
(p8)  br.cond.spnt  lgammaf_1_2
};;
{ .mfi
      setf.sig      FR_int_Ln = GR_PureExp
      fms.s1        FR_r = FR_InvX,f8,f1
      shladd        GR_ad_Co = GR_Ind,3,GR_ad_Co
}
{ .mib
      ldfpd         FR_LnSqrt2Pi,FR_3 = [GR_ad_C650],16
      cmp.lt        p13,p12 = GR_Exp,GR_StirlBound
      // jump if x is from the interval (0; 1)
(p9)  br.cond.spnt  lgammaf_0_1
};;
{ .mfi
      ldfpd         FR_Ln2,FR_05 = [GR_ad_Data],16
      fma.s1        FR_Xp2 = f1,f1,FR_Xp1 // (x+2)
      shladd        GR_ad_C650 = GR_Ind,2,GR_ad_C650
}
{ .mfi
      add           GR_ad_Ce = 0x20,GR_ad_Co
      nop.f         0
      add           GR_ad_C43 = 0x30,GR_ad_Co
};;
{ .mfi
      // load coefficients of polynomial approximation
      // of ln(GAMMA(x)), 2 <= x < 2^13
(p13) ldfpd         FR_A10,FR_A9 = [GR_ad_Co],16
      fcvt.xf       FR_N = FR_int_N
      cmp.eq.unc    p6,p7 = GR_ExpOf2,GR_SignExp
}
{ .mib
(p13) ldfpd         FR_A8,FR_A7 = [GR_ad_Ce]
(p14) cmp.le.unc    p9,p0 = GR_StirlBound,GR_Exp
      // jump if x is less or equal to -2^13
(p9)  br.cond.spnt  lgammaf_negstirling
};;
.pred.rel "mutex",p6,p7
{ .mfi
(p13) ldfpd         FR_A6,FR_A5 = [GR_ad_C650],16
(p6)  fma.s1        FR_x = f0,f0,FR_NormX
      shladd        GR_ad_T = GR_Ind4T,3,GR_ad_Data
}
{ .mfi
(p13) ldfpd         FR_A4,FR_A3 = [GR_ad_C43]
(p7)  fms.s1        FR_x = FR_x,f1,f1
(p14) mov           GR_ReqBound = 0x20005
};;
{ .mfi
(p13) ldfpd         FR_A2,FR_A1 = [GR_ad_Co],16
      fms.s1        FR_xm2 = FR_xm2,f1,f1
(p14) extr.u        GR_Arg = GR_Sig,60,4
}
{ .mfi
      mov           GR_SignOfGamma = 1 // set sign of gamma(x) to 1
      fcvt.xf       FR_Ntrunc = FR_int_Ntrunc
      nop.i         0
};;
{ .mfi
      ldfd          FR_T = [GR_ad_T]
      fma.s1        FR_r2 = FR_r,FR_r,f0
      shl           GR_ReqBound = GR_ReqBound,3
}
{ .mfi
      add           GR_ad_Co = 0xCA0,GR_ad_Data
      fnma.s1       FR_Req = FR_Xp1,FR_NormX,f0 // -x*(x+1)
(p14) shladd        GR_Arg = GR_Exp,4,GR_Arg
};;
{ .mfi
(p13) ldfd          FR_A0 = [GR_ad_C650]
      fma.s1        FR_Xp3 = FR_2,f1,FR_Xp1 // (x+3)
(p14) cmp.le.unc    p9,p0 = GR_Arg,GR_ReqBound
}
{ .mfi
(p14) add           GR_ad_Ce = 0x20,GR_ad_Co
      fma.s1        FR_Xp4 = FR_2,FR_2,FR_NormX // (x+4)
(p15) add           GR_ad_OvfBound = 0xBB8,GR_ad_Data
};;
{ .mfi
      // load coefficients of polynomial approximation
      // of ln(sin(Pi*xf)/(Pi*xf)), |xf| <= 0.5
(p14) ldfpd         FR_S16,FR_S14 = [GR_ad_Co],16
(p14) fms.s1        FR_Xf = FR_NormX,f1,FR_N  // xf = x - [x]
(p14) sub           GR_SignOfGamma = r0,GR_SignOfGamma // set sign of
                                                       // gamma(x) to -1
}
{ .mfb
(p14) ldfpd         FR_S12,FR_S10 = [GR_ad_Ce],16
      fma.s1        FR_Xp5 = FR_2,FR_2,FR_Xp1 // (x+5)
      // jump if x is from the interval (-9; 0)
(p9)  br.cond.spnt  lgammaf_negrecursion
};;
{ .mfi
(p14) ldfpd         FR_S8,FR_S6 = [GR_ad_Co],16
      fma.s1        FR_P32 = FR_P3,FR_r,FR_P2
      nop.i         0
}
{ .mfb
(p14) ldfpd         FR_S4,FR_S2 = [GR_ad_Ce],16
      fma.s1        FR_x2 = FR_x,FR_x,f0
      // jump if x is from the interval (-2^13; -9)
(p14) br.cond.spnt  lgammaf_negpoly
};;
{ .mfi
      ldfd          FR_OverflowBound = [GR_ad_OvfBound]
(p12) fcvt.xf       FR_N = FR_int_Ln
      // set p9  if signgum is 32-bit int
      // set p10 if signgum is 64-bit int
      cmp.eq        p10,p9 = 8,r34
}
{ .mfi
      nop.m         0
(p12) fma.s1        FR_P10 = FR_P1,FR_r,f1
      nop.i         0
};;
.pred.rel "mutex",p6,p7
.pred.rel "mutex",p9,p10
{ .mfi
      // store sign of gamma(x) as 32-bit int
(p9)  st4           [r33] = GR_SignOfGamma
(p6)  fma.s1        FR_xx = FR_x,FR_xm2,f0
      nop.i         0
}
{ .mfi
      // store sign of gamma(x) as 64-bit int
(p10) st8           [r33] = GR_SignOfGamma
(p7)  fma.s1        FR_xx = f0,f0,FR_x
      nop.i         0
};;
{ .mfi
      nop.m         0
(p13) fma.s1        FR_A9 = FR_A10,FR_x,FR_A9
      nop.i         0
}
{ .mfi
      nop.m         0
(p13) fma.s1        FR_A7 = FR_A8,FR_x,FR_A7
      nop.i         0
};;
{ .mfi
      nop.m         0
(p13) fma.s1        FR_A5 = FR_A6,FR_x,FR_A5
      nop.i         0
}
{ .mfi
      nop.m         0
(p13) fma.s1        FR_A3 = FR_A4,FR_x,FR_A3
      nop.i         0
};;
{ .mfi
      nop.m         0
(p15) fcmp.eq.unc.s1 p8,p0 = FR_NormX,FR_2 // is input argument 2.0?
      nop.i         0
}
{ .mfi
      nop.m         0
(p13) fma.s1        FR_A1 = FR_A2,FR_x,FR_A1
      nop.i         0
};;
{ .mfi
      nop.m         0
(p12) fma.s1        FR_T = FR_N,FR_Ln2,FR_T
      nop.i         0
}
{ .mfi
      nop.m         0
(p12) fma.s1        FR_P32 = FR_P32,FR_r2,FR_P10
      nop.i         0
};;
{ .mfi
      nop.m         0
(p13) fma.s1        FR_x4 = FR_x2,FR_x2,f0
      nop.i         0
}
{ .mfi
      nop.m         0
(p13) fma.s1        FR_x3 = FR_x2,FR_xx,f0
      nop.i         0
};;
{ .mfi
      nop.m         0
(p13) fma.s1        FR_A7 = FR_A9,FR_x2,FR_A7
      nop.i         0
}
{ .mfb
      nop.m         0
(p8)  fma.s.s0      f8 = f0,f0,f0
(p8)  br.ret.spnt   b0 // fast exit for 2.0
};;
{ .mfi
      nop.m         0
(p6)  fma.s1        FR_A0 = FR_A0,FR_xm2,f0
      nop.i         0
}
{ .mfi
      nop.m         0
(p13) fma.s1        FR_A3 = FR_A5,FR_x2,FR_A3
      nop.i         0
};;
{ .mfi
      nop.m         0
(p15) fcmp.le.unc.s1 p8,p0 = FR_OverflowBound,FR_NormX // overflow test
      nop.i         0
}
{ .mfi
      nop.m         0
(p12) fms.s1        FR_xm05 = FR_NormX,f1,FR_05
      nop.i         0
};;
{ .mfi
      nop.m         0
(p12) fma.s1        FR_Ln = FR_P32,FR_r,FR_T
      nop.i         0
}
{ .mfi
      nop.m         0
(p12) fms.s1        FR_LnSqrt2Pi = FR_LnSqrt2Pi,f1,FR_NormX
      nop.i         0
};;
{ .mfi
      nop.m         0
(p13) fma.s1        FR_A0 = FR_A1,FR_xx,FR_A0
      nop.i         0
}
{ .mfb
      nop.m         0
(p13) fma.s1        FR_A3 = FR_A7,FR_x4,FR_A3
      // jump if result overflows
(p8)  br.cond.spnt  lgammaf_overflow
};;
.pred.rel "mutex",p12,p13
{ .mfi
      nop.m         0
(p12) fma.s.s0      f8 = FR_Ln,FR_xm05,FR_LnSqrt2Pi
      nop.i         0
}
{ .mfb
      nop.m         0
(p13) fma.s.s0      f8 = FR_A3,FR_x3,FR_A0
      br.ret.sptk   b0
};;
// branch for calculating of ln(GAMMA(x)) for 0 < x < 1
//---------------------------------------------------------------------
.align 32
lgammaf_0_1:
{ .mfi
      getf.sig      GR_Ind = FR_Xp1
      fma.s1        FR_r2 = FR_r,FR_r,f0
      mov           GR_fff7 = 0xFFF7
}
{ .mfi
      ldfpd         FR_Ln2,FR_05 = [GR_ad_Data],16
      fma.s1        FR_P32 = FR_P3,FR_r,FR_P2
      // input argument can't be equal to 1.0
      cmp.eq        p0,p14 = r0,r0
};;
{ .mfi
      getf.exp      GR_Exp = FR_w
      fcvt.xf       FR_N = FR_int_Ln
      add           GR_ad_Co = 0xCE0,GR_ad_Data
}
{ .mfi
      shladd        GR_ad_T = GR_Ind4T,3,GR_ad_Data
      fma.s1        FR_P10 = FR_P1,FR_r,f1
      add           GR_ad_Ce = 0xD00,GR_ad_Data
};;
{ .mfi
      ldfd          FR_T = [GR_ad_T]
      fma.s1        FR_w2 = FR_w,FR_w,f0
      extr.u        GR_Ind = GR_Ind,61,2
}
{ .mfi
      nop.m         0
      fma.s1        FR_Q32 = FR_P3,FR_w,FR_P2
////      add           GR_ad_C0 = 0xB30,GR_ad_Data
      add           GR_ad_C0 = 0xB38,GR_ad_Data
};;
{ .mfi
      and           GR_Exp = GR_Exp,GR_ExpMask
      nop.f         0
      shladd        GR_IndX8 = GR_Ind,3,r0
}
{ .mfi
      shladd        GR_IndX2 = GR_Ind,1,r0
      fma.s1        FR_Q10 = FR_P1,FR_w,f1
      cmp.eq        p6,p15 = 0,GR_Ind
};;
{ .mfi
      shladd        GR_ad_Co = GR_IndX8,3,GR_ad_Co
(p6)  fma.s1        FR_x = f0,f0,FR_NormX
      shladd        GR_ad_C0 = GR_IndX2,4,GR_ad_C0
}
{ .mfi
      shladd        GR_ad_Ce = GR_IndX8,3,GR_ad_Ce
      nop.f         0
(p15) cmp.eq.unc    p7,p8 = 1,GR_Ind
};;
.pred.rel "mutex",p7,p8
{ .mfi
      ldfpd         FR_A8,FR_A7 = [GR_ad_Co],16
(p7)  fms.s1        FR_x = FR_NormX,f1,FR_LocalMin
      cmp.ge        p10,p11 = GR_Exp,GR_fff7
}
{ .mfb
      ldfpd         FR_A6,FR_A5 = [GR_ad_Ce],16
(p8)  fma.s1        FR_x = f1,f1,FR_NormX
      br.cond.sptk  lgamma_0_2_core
};;
// branch for calculating of ln(GAMMA(x)) for 1 <= x < 2
//---------------------------------------------------------------------
.align 32
lgammaf_1_2:
{ .mfi
      add           GR_ad_Co = 0xCF0,GR_ad_Data
      fcmp.eq.s1    p14,p0 = f1,FR_NormX // is input argument 1.0?
      extr.u        GR_Ind = GR_Sig,61,2
}
{ .mfi
      add           GR_ad_Ce = 0xD10,GR_ad_Data
      nop.f         0
////      add           GR_ad_C0 = 0xB40,GR_ad_Data
      add           GR_ad_C0 = 0xB48,GR_ad_Data
};;
{ .mfi
      shladd        GR_IndX8 = GR_Ind,3,r0
      nop.f         0
      shladd        GR_IndX2 = GR_Ind,1,r0
}
{ .mfi
      cmp.eq        p6,p15 = 0,GR_Ind // p6 <- x from [1;1.25)
      nop.f         0
      cmp.ne        p9,p0 = r0,r0
};;
{ .mfi
      shladd        GR_ad_Co = GR_IndX8,3,GR_ad_Co
(p6)  fms.s1        FR_x = FR_NormX,f1,f1 // reduced x for [1;1.25)
      shladd        GR_ad_C0 = GR_IndX2,4,GR_ad_C0
}
{ .mfi
      shladd        GR_ad_Ce = GR_IndX8,3,GR_ad_Ce
(p14) fma.s.s0      f8 = f0,f0,f0
(p15) cmp.eq.unc    p7,p8 = 1,GR_Ind // p7 <- x from [1.25;1.5)
};;
.pred.rel "mutex",p7,p8
{ .mfi
      ldfpd         FR_A8,FR_A7 = [GR_ad_Co],16
(p7)  fms.s1        FR_x = FR_xm2,f1,FR_LocalMin
      nop.i         0
}
{ .mfi
      ldfpd         FR_A6,FR_A5 = [GR_ad_Ce],16
(p8)  fma.s1        FR_x = f0,f0,FR_NormX
(p9)  cmp.eq.unc    p10,p11 = r0,r0
};;
lgamma_0_2_core:
{ .mmi
      ldfpd         FR_A4,FR_A3 = [GR_ad_Co],16
      ldfpd         FR_A2,FR_A1 = [GR_ad_Ce],16
      mov           GR_SignOfGamma = 1 // set sign of gamma(x) to 1
};;
{ .mfi
//      add           GR_ad_C0 = 8,GR_ad_C0
      ldfd          FR_A0 = [GR_ad_C0]
      nop.f         0
      // set p13 if signgum is 32-bit int
      // set p15 if signgum is 64-bit int
      cmp.eq        p15,p13 = 8,r34
};;
.pred.rel "mutex",p13,p15
{ .mmf
      // store sign of gamma(x)
(p13) st4           [r33] = GR_SignOfGamma // as 32-bit int
(p15) st8           [r33] = GR_SignOfGamma // as 64-bit int
(p11) fma.s1        FR_Q32 = FR_Q32,FR_w2,FR_Q10
};;
{ .mfb
      nop.m         0
(p10) fma.s1        FR_P32 = FR_P32,FR_r2,FR_P10
(p14) br.ret.spnt   b0 // fast exit for 1.0
};;
{ .mfi
      nop.m         0
(p10) fma.s1        FR_T = FR_N,FR_Ln2,FR_T
      cmp.eq        p6,p7 = 0,GR_Ind // p6 <- x from [1;1.25)
}
{ .mfi
      nop.m         0
      fma.s1        FR_x2 = FR_x,FR_x,f0
      cmp.eq        p8,p0 = r0,r0 // set p8 to 1 that means we on [1;2]
};;
{ .mfi
      nop.m         0
(p11) fma.s1        FR_Ln = FR_Q32,FR_w,f0
      nop.i         0
}
{ .mfi
      nop.m         0
      nop.f         0
      nop.i         0
};;
.pred.rel "mutex",p6,p7
{ .mfi
      nop.m         0
(p6)  fma.s1        FR_xx = f0,f0,FR_x
      nop.i         0
}
{ .mfi
      nop.m         0
(p7)  fma.s1        FR_xx = f0,f0,f1
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_A7 = FR_A8,FR_x,FR_A7
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_A5 = FR_A6,FR_x,FR_A5
(p9)  cmp.ne        p8,p0 = r0,r0 // set p8 to 0 that means we on [0;1]
};;
{ .mfi
      nop.m         0
      fma.s1        FR_A3 = FR_A4,FR_x,FR_A3
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_A1 = FR_A2,FR_x,FR_A1
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_x4 = FR_x2,FR_x2,f0
      nop.i         0
}
{ .mfi
      nop.m         0
(p10) fma.s1        FR_Ln = FR_P32,FR_r,FR_T
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_A5 = FR_A7,FR_x2,FR_A5
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_A1 = FR_A3,FR_x2,FR_A1
      nop.i         0
};;
.pred.rel "mutex",p9,p8
{ .mfi
      nop.m         0
(p9)  fms.d.s1      FR_A0 = FR_A0,FR_xx,FR_Ln
      nop.i         0
}
{ .mfi
      nop.m         0
(p8)  fms.s1        FR_A0 = FR_A0,FR_xx,f0
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.d.s1      FR_A1 = FR_A5,FR_x4,FR_A1
      nop.i         0
}
{ .mfi
      nop.m         0
      nop.f         0
      nop.i         0
};;
.pred.rel "mutex",p6,p7
{ .mfi
      nop.m         0
(p6)  fma.s.s0      f8 = FR_A1,FR_x2,FR_A0
      nop.i         0
}
{ .mfb
      nop.m         0
(p7)  fma.s.s0      f8 = FR_A1,FR_x,FR_A0
      br.ret.sptk   b0
};;
// branch for calculating of ln(GAMMA(x)) for -9 < x < 1
//---------------------------------------------------------------------
.align 32
lgammaf_negrecursion:
{ .mfi
      getf.sig      GR_N = FR_int_Ntrunc
      fms.s1        FR_1pXf = FR_Xp2,f1,FR_Ntrunc // 1 + (x+1) - [x]
      mov           GR_Neg2 = 2
}
{ .mfi
      add           GR_ad_Co = 0xCE0,GR_ad_Data
      fms.s1        FR_Xf = FR_Xp1,f1,FR_Ntrunc // (x+1) - [x]
      mov           GR_Neg4 = 4
};;
{ .mfi
      add           GR_ad_Ce = 0xD00,GR_ad_Data
      fma.s1        FR_Xp6 = FR_2,FR_2,FR_Xp2 // (x+6)
      add           GR_ad_C0 = 0xB30,GR_ad_Data
}
{ .mfi
      sub           GR_Neg2 = r0,GR_Neg2
      fma.s1        FR_Xp7 = FR_2,FR_3,FR_Xp1 // (x+7)
      sub           GR_Neg4 = r0,GR_Neg4
};;
{ .mfi
      cmp.ne        p8,p0 = r0,GR_N
      fcmp.eq.s1    p13,p0 = FR_NormX,FR_Ntrunc
      and           GR_IntNum = 0xF,GR_N
}
{ .mfi
      cmp.lt        p6,p0 = GR_N,GR_Neg2
      fma.s1        FR_Xp8 = FR_2,FR_3,FR_Xp2 // (x+8)
      cmp.lt        p7,p0 = GR_N,GR_Neg4
};;
{ .mfi
      getf.d        GR_Arg = FR_NormX
(p6)  fma.s1        FR_Xp2 = FR_Xp2,FR_Xp3,f0
(p8)  tbit.z.unc    p14,p15 = GR_IntNum,0
}
{ .mfi
      sub           GR_RootInd = 0xE,GR_IntNum
(p7)  fma.s1        FR_Xp4 = FR_Xp4,FR_Xp5,f0
      add           GR_ad_Root = 0xDE0,GR_ad_Data
};;
{ .mfi
      shladd        GR_ad_Root = GR_RootInd,3,GR_ad_Root
      fms.s1        FR_x = FR_Xp1,f1,FR_Ntrunc // (x+1) - [x]
      nop.i         0
}
{ .mfb
      nop.m         0
      nop.f         0
(p13) br.cond.spnt  lgammaf_singularity
};;
.pred.rel "mutex",p14,p15
{ .mfi
      cmp.gt        p6,p0 = 0xA,GR_IntNum
(p14) fma.s1        FR_Req = FR_Req,FR_Xf,f0
      cmp.gt        p7,p0 = 0xD,GR_IntNum
}
{ .mfi
(p15) mov           GR_SignOfGamma = 1 // set sign of gamma(x) to 1
(p15) fnma.s1       FR_Req = FR_Req,FR_Xf,f0
      cmp.leu       p0,p13 = 2,GR_RootInd
};;
{ .mfi
      nop.m         0
(p6)  fma.s1        FR_Xp6 = FR_Xp6,FR_Xp7,f0
(p13) add           GR_ad_RootCo = 0xE00,GR_ad_Data
};;
{ .mfi
      nop.m         0
      fcmp.eq.s1    p12,p11 = FR_1pXf,FR_2
      nop.i         0
};;
{ .mfi
      getf.sig      GR_Sig = FR_1pXf
      fcmp.le.s1    p9,p0 = FR_05,FR_Xf
      nop.i         0
}
{ .mfi
(p13) shladd        GR_RootInd = GR_RootInd,4,r0
(p7)  fma.s1        FR_Xp2 = FR_Xp2,FR_Xp4,f0
(p8)  cmp.gt.unc    p10,p0 = 0x9,GR_IntNum
};;
.pred.rel "mutex",p11,p12
{ .mfi
      nop.m         0
(p10) fma.s1        FR_Req = FR_Req,FR_Xp8,f0
(p11) extr.u        GR_Ind = GR_Sig,61,2
}
{ .mfi
(p13) add           GR_RootInd = GR_RootInd,GR_RootInd
      nop.f         0
(p12) mov           GR_Ind = 3
};;
{ .mfi
      shladd        GR_IndX2 = GR_Ind,1,r0
      nop.f         0
      cmp.gt        p14,p0 = 2,GR_Ind
}
{ .mfi
      shladd        GR_IndX8 = GR_Ind,3,r0
      nop.f         0
      cmp.eq        p6,p0 = 1,GR_Ind
};;
.pred.rel "mutex",p6,p9
{ .mfi
      shladd        GR_ad_Co = GR_IndX8,3,GR_ad_Co
(p6)  fms.s1        FR_x = FR_Xf,f1,FR_LocalMin
      cmp.gt        p10,p0 = 0xB,GR_IntNum
}
{ .mfi
      shladd        GR_ad_Ce = GR_IndX8,3,GR_ad_Ce
(p9)  fma.s1        FR_x = f0,f0,FR_1pXf
      shladd        GR_ad_C0 = GR_IndX2,4,GR_ad_C0
};;
{ .mfi
      // load coefficients of polynomial approximation
      // of ln(GAMMA(x)), 1 <= x < 2
      ldfpd         FR_A8,FR_A7 = [GR_ad_Co],16
(p10) fma.s1        FR_Xp2 = FR_Xp2,FR_Xp6,f0
      add           GR_ad_C0 = 8,GR_ad_C0
}
{ .mfi
      ldfpd         FR_A6,FR_A5 = [GR_ad_Ce],16
      nop.f         0
(p14) add           GR_ad_Root = 0x10,GR_ad_Root
};;
{ .mfi
      ldfpd         FR_A4,FR_A3 = [GR_ad_Co],16
      nop.f         0
      add           GR_ad_RootCe = 0xE10,GR_ad_Data
}
{ .mfi
      ldfpd         FR_A2,FR_A1 = [GR_ad_Ce],16
      nop.f         0
(p14) add           GR_RootInd = 0x40,GR_RootInd
};;
{ .mmi
      ldfd          FR_A0 = [GR_ad_C0]
(p13) add           GR_ad_RootCo = GR_ad_RootCo,GR_RootInd
(p13) add           GR_ad_RootCe = GR_ad_RootCe,GR_RootInd
};;
{ .mmi
(p13) ld8           GR_Root = [GR_ad_Root]
(p13) ldfd          FR_Root = [GR_ad_Root]
      mov           GR_ExpBias = 0xffff
};;
{ .mfi
      nop.m         0
      fma.s1        FR_x2 = FR_x,FR_x,f0
      nop.i         0
}
{ .mlx
(p8)  cmp.gt.unc    p10,p0 = 0xF,GR_IntNum
      movl          GR_Dx = 0x000000014F8B588E
};;
{ .mfi
      // load coefficients of polynomial approximation
      // of ln(GAMMA(x)), x is close to one of negative roots
(p13) ldfpd         FR_R3,FR_R2 = [GR_ad_RootCo]
      // arguments for logarithm
(p10) fma.s1        FR_Req = FR_Req,FR_Xp2,f0
      mov           GR_ExpMask = 0x1ffff
}
{ .mfi
(p13) ldfpd         FR_R1,FR_R0 = [GR_ad_RootCe]
      nop.f         0
      // set p9 if signgum is 32-bit int
      // set p8 if signgum is 64-bit int
      cmp.eq        p8,p9 = 8,r34
};;
.pred.rel "mutex",p9,p8
{ .mfi
(p9)  st4           [r33] = GR_SignOfGamma // as 32-bit int
      fma.s1        FR_A7 = FR_A8,FR_x,FR_A7
(p13) sub           GR_Root = GR_Arg,GR_Root
}
{ .mfi
(p8)  st8           [r33] = GR_SignOfGamma // as 64-bit int
      fma.s1        FR_A5 = FR_A6,FR_x,FR_A5
      nop.i         0
};;
{ .mfi
      nop.m         0
      fms.s1        FR_w = FR_Req,f1,f1
(p13) add           GR_Root = GR_Root,GR_Dx
}
{ .mfi
      nop.m         0
      nop.f         0
(p13) add           GR_2xDx = GR_Dx,GR_Dx
};;
{ .mfi
      nop.m         0
      fma.s1        FR_A3 = FR_A4,FR_x,FR_A3
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_A1 = FR_A2,FR_x,FR_A1
(p13) cmp.leu.unc   p10,p0 = GR_Root,GR_2xDx
};;
{ .mfi
      nop.m         0
      frcpa.s1      FR_InvX,p0 = f1,FR_Req
      nop.i         0
}
{ .mfi
      nop.m         0
(p10) fms.s1        FR_rx = FR_NormX,f1,FR_Root
      nop.i         0
};;
{ .mfi
      getf.exp      GR_SignExp = FR_Req
      fma.s1        FR_x4 = FR_x2,FR_x2,f0
      nop.i         0
};;
{ .mfi
      getf.sig      GR_Sig = FR_Req
      fma.s1        FR_A5 = FR_A7,FR_x2,FR_A5
      nop.i         0
};;
{ .mfi
      sub           GR_PureExp = GR_SignExp,GR_ExpBias
      fma.s1        FR_w2 = FR_w,FR_w,f0
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_Q32 = FR_P3,FR_w,FR_P2
      nop.i         0
};;
{ .mfi
      setf.sig      FR_int_Ln = GR_PureExp
      fma.s1        FR_A1 = FR_A3,FR_x2,FR_A1
      extr.u        GR_Ind4T = GR_Sig,55,8
}
{ .mfi
      nop.m         0
      fma.s1        FR_Q10 = FR_P1,FR_w,f1
      nop.i         0
};;
{ .mfi
      shladd        GR_ad_T = GR_Ind4T,3,GR_ad_Data
      fms.s1        FR_r = FR_InvX,FR_Req,f1
      nop.i         0
}
{ .mfi
      nop.m         0
(p10) fms.s1        FR_rx2 = FR_rx,FR_rx,f0
      nop.i         0
};;
{ .mfi
      ldfd          FR_T = [GR_ad_T]
(p10) fma.s1        FR_R2 = FR_R3,FR_rx,FR_R2
      nop.i         0
}
{ .mfi
      nop.m         0
(p10) fma.s1        FR_R0 = FR_R1,FR_rx,FR_R0
      nop.i         0
};;
{ .mfi
      getf.exp      GR_Exp = FR_w
      fma.s1        FR_A1 = FR_A5,FR_x4,FR_A1
      mov           GR_ExpMask = 0x1ffff
}
{ .mfi
      nop.m         0
      fma.s1        FR_Q32 = FR_Q32, FR_w2,FR_Q10
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_r2 = FR_r,FR_r,f0
      mov           GR_fff7 = 0xFFF7
}
{ .mfi
      nop.m         0
      fma.s1        FR_P32 = FR_P3,FR_r,FR_P2
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_P10 = FR_P1,FR_r,f1
      and           GR_Exp = GR_ExpMask,GR_Exp
}
{ .mfb
      nop.m         0
(p10) fma.s.s0      f8 = FR_R2,FR_rx2,FR_R0
(p10) br.ret.spnt   b0 // exit for arguments close to negative roots
};;
{ .mfi
      nop.m         0
      fcvt.xf       FR_N = FR_int_Ln
      nop.i         0
}
{ .mfi
      cmp.ge        p14,p15 = GR_Exp,GR_fff7
      nop.f         0
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_A0 = FR_A1,FR_x,FR_A0
      nop.i         0
}
{ .mfi
      nop.m         0
(p15) fma.s1        FR_Ln = FR_Q32,FR_w,f0
      nop.i         0
};;
{ .mfi
      nop.m         0
(p14) fma.s1        FR_P32 = FR_P32,FR_r2,FR_P10
      cmp.eq        p6,p7 = 0,GR_Ind
};;
{ .mfi
      nop.m         0
(p14) fma.s1        FR_T = FR_N,FR_Ln2,FR_T
      nop.i         0
};;
{ .mfi
      nop.m         0
(p14) fma.s1        FR_Ln = FR_P32,FR_r,FR_T
      nop.i         0
};;
.pred.rel "mutex",p6,p7
{ .mfi
      nop.m         0
(p6)  fms.s.s0      f8 = FR_A0,FR_x,FR_Ln
      nop.i         0
}
{ .mfb
      nop.m         0
(p7)  fms.s.s0      f8 = FR_A0,f1,FR_Ln
      br.ret.sptk   b0
};;

// branch for calculating of ln(GAMMA(x)) for x < -2^13
//---------------------------------------------------------------------
.align 32
lgammaf_negstirling:
{ .mfi
      shladd        GR_ad_T = GR_Ind4T,3,GR_ad_Data
      fms.s1        FR_Xf = FR_NormX,f1,FR_N  // xf = x - [x]
      mov           GR_SingBound = 0x10016
}
{ .mfi
      add           GR_ad_Co = 0xCA0,GR_ad_Data
      fma.s1        FR_P32 = FR_P3,FR_r,FR_P2
      nop.i         0
};;
{ .mfi
      ldfd          FR_T = [GR_ad_T]
      fcvt.xf       FR_int_Ln = FR_int_Ln
      cmp.le        p6,p0 = GR_SingBound,GR_Exp
}
{ .mfb
      add           GR_ad_Ce = 0x20,GR_ad_Co
      fma.s1        FR_r2 = FR_r,FR_r,f0
(p6)  br.cond.spnt  lgammaf_singularity
};;
{ .mfi
      // load coefficients of polynomial approximation
      // of ln(sin(Pi*xf)/(Pi*xf)), |xf| <= 0.5
      ldfpd         FR_S16,FR_S14 = [GR_ad_Co],16
      fma.s1        FR_P10 = FR_P1,FR_r,f1
      nop.i         0
}
{ .mfi
      ldfpd         FR_S12,FR_S10 = [GR_ad_Ce],16
      fms.s1        FR_xm05 = FR_NormX,f1,FR_05
      nop.i         0
};;
{ .mmi
      ldfpd         FR_S8,FR_S6 = [GR_ad_Co],16
      ldfpd         FR_S4,FR_S2 = [GR_ad_Ce],16
      nop.i         0
};;
{ .mfi
      getf.sig      GR_N = FR_int_Ntrunc // signgam calculation
      fma.s1        FR_Xf2 = FR_Xf,FR_Xf,f0
      nop.i         0
};;
{ .mfi
      nop.m         0
      frcpa.s1      FR_InvXf,p0 = f1,FR_Xf
      nop.i         0
};;
{ .mfi
      getf.d        GR_Arg = FR_Xf
      fcmp.eq.s1    p6,p0 = FR_NormX,FR_N
      mov           GR_ExpBias = 0x3FF
};;
{ .mfi
      nop.m         0
      fma.s1        FR_T = FR_int_Ln,FR_Ln2,FR_T
      extr.u        GR_Exp = GR_Arg,52,11
}
{ .mfi
      nop.m         0
      fma.s1        FR_P32 = FR_P32,FR_r2,FR_P10
      nop.i         0
};;
{ .mfi
      sub           GR_PureExp = GR_Exp,GR_ExpBias
      fma.s1        FR_S14 = FR_S16,FR_Xf2,FR_S14
      extr.u        GR_Ind4T = GR_Arg,44,8
}
{ .mfb
      mov           GR_SignOfGamma = 1 // set signgam to -1
      fma.s1        FR_S10 = FR_S12,FR_Xf2,FR_S10
(p6)  br.cond.spnt  lgammaf_singularity
};;
{ .mfi
      setf.sig      FR_int_Ln = GR_PureExp
      fms.s1        FR_rf = FR_InvXf,FR_Xf,f1
      // set p14 if GR_N is even
      tbit.z        p14,p0 = GR_N,0
}
{ .mfi
      shladd        GR_ad_T = GR_Ind4T,3,GR_ad_Data
      fma.s1        FR_Xf4 = FR_Xf2,FR_Xf2,f0
      nop.i         0
};;
{ .mfi
(p14) sub           GR_SignOfGamma = r0,GR_SignOfGamma // set signgam to -1
      fma.s1        FR_S6 = FR_S8,FR_Xf2,FR_S6
      nop.i         0
}
{ .mfi
      // set p9  if signgum is 32-bit int
      // set p10 if signgum is 64-bit int
      cmp.eq        p10,p9 = 8,r34
      fma.s1        FR_S2 = FR_S4,FR_Xf2,FR_S2
      nop.i         0
};;
{ .mfi
      ldfd          FR_Tf = [GR_ad_T]
      fma.s1        FR_Ln = FR_P32,FR_r,FR_T
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_LnSqrt2Pi = FR_LnSqrt2Pi,f1,FR_NormX
      nop.i         0
};;
.pred.rel "mutex",p9,p10
{ .mfi
(p9)  st4           [r33] = GR_SignOfGamma  // as 32-bit int
      fma.s1        FR_rf2 = FR_rf,FR_rf,f0
      nop.i         0
}
{ .mfi
(p10) st8           [r33] = GR_SignOfGamma  // as 64-bit int
      fma.s1        FR_S10 = FR_S14,FR_Xf4,FR_S10
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_P32f = FR_P3,FR_rf,FR_P2
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_Xf8 = FR_Xf4,FR_Xf4,f0
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_P10f = FR_P1,FR_rf,f1
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_S2 = FR_S6,FR_Xf4,FR_S2
      nop.i         0
};;
{ .mfi
      nop.m         0
      fms.s1        FR_Ln = FR_Ln,FR_xm05,FR_LnSqrt2Pi
      nop.i         0
};;
{ .mfi
      nop.m         0
      fcvt.xf       FR_Nf = FR_int_Ln
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_S2 = FR_S10,FR_Xf8,FR_S2
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_Tf = FR_Nf,FR_Ln2,FR_Tf
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_P32f = FR_P32f,FR_rf2,FR_P10f // ??????
      nop.i         0
};;
{ .mfi
      nop.m         0
      fnma.s1       FR_Ln = FR_S2,FR_Xf2,FR_Ln
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_Lnf = FR_P32f,FR_rf,FR_Tf
      nop.i         0
};;
{ .mfb
      nop.m         0
      fms.s.s0      f8 = FR_Ln,f1,FR_Lnf
      br.ret.sptk   b0
};;
// branch for calculating of ln(GAMMA(x)) for -2^13 < x < -9
//---------------------------------------------------------------------
.align 32
lgammaf_negpoly:
{ .mfi
      getf.d        GR_Arg = FR_Xf
      frcpa.s1      FR_InvXf,p0 = f1,FR_Xf
      mov           GR_ExpBias = 0x3FF
}
{ .mfi
      nop.m         0
      fma.s1        FR_Xf2 = FR_Xf,FR_Xf,f0
      nop.i         0
};;
{ .mfi
      getf.sig      GR_N = FR_int_Ntrunc
      fcvt.xf       FR_N = FR_int_Ln
      mov           GR_SignOfGamma = 1
}
{ .mfi
      nop.m         0
      fma.s1        FR_A9 = FR_A10,FR_x,FR_A9
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_P10 = FR_P1,FR_r,f1
      extr.u        GR_Exp = GR_Arg,52,11
}
{ .mfi
      nop.m         0
      fma.s1        FR_x4 = FR_x2,FR_x2,f0
      nop.i         0
};;
{ .mfi
      sub           GR_PureExp = GR_Exp,GR_ExpBias
      fma.s1        FR_A7 = FR_A8,FR_x,FR_A7
      tbit.z        p14,p0 = GR_N,0
}
{ .mfi
      nop.m         0
      fma.s1        FR_A5 = FR_A6,FR_x,FR_A5
      nop.i         0
};;
{ .mfi
      setf.sig      FR_int_Ln = GR_PureExp
      fma.s1        FR_A3 = FR_A4,FR_x,FR_A3
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_A1 = FR_A2,FR_x,FR_A1
(p14) sub           GR_SignOfGamma = r0,GR_SignOfGamma
};;
{ .mfi
      nop.m         0
      fms.s1        FR_rf = FR_InvXf,FR_Xf,f1
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_Xf4 = FR_Xf2,FR_Xf2,f0
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_S14 = FR_S16,FR_Xf2,FR_S14
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_S10 = FR_S12,FR_Xf2,FR_S10
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_T = FR_N,FR_Ln2,FR_T
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_P32 = FR_P32,FR_r2,FR_P10
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_S6 = FR_S8,FR_Xf2,FR_S6
      extr.u        GR_Ind4T = GR_Arg,44,8
}
{ .mfi
      nop.m         0
      fma.s1        FR_S2 = FR_S4,FR_Xf2,FR_S2
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_A7 = FR_A9,FR_x2,FR_A7
      nop.i         0
}
{ .mfi
      shladd        GR_ad_T = GR_Ind4T,3,GR_ad_Data
      fma.s1        FR_A3 = FR_A5,FR_x2,FR_A3
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_Xf8 = FR_Xf4,FR_Xf4,f0
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_rf2 = FR_rf,FR_rf,f0
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_P32f = FR_P3,FR_rf,FR_P2
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_P10f = FR_P1,FR_rf,f1
      nop.i         0
};;
{ .mfi
      ldfd          FR_Tf = [GR_ad_T]
      fma.s1        FR_Ln = FR_P32,FR_r,FR_T
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_A0 = FR_A1,FR_x,FR_A0
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_S10 = FR_S14,FR_Xf4,FR_S10
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_S2 = FR_S6,FR_Xf4,FR_S2
      nop.i         0
};;
{ .mfi
      nop.m         0
      fcvt.xf       FR_Nf = FR_int_Ln
      nop.i         0
}
{ .mfi
      nop.m         0
      fma.s1        FR_A3 = FR_A7,FR_x4,FR_A3
      nop.i         0
};;
{ .mfi
      nop.m         0
      fcmp.eq.s1    p13,p0 = FR_NormX,FR_Ntrunc
      nop.i         0
}
{ .mfi
      nop.m         0
      fnma.s1       FR_x3 = FR_x2,FR_x,f0 // -x^3
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_P32f = FR_P32f,FR_rf2,FR_P10f
      nop.i         0
};;
{ .mfb
      // set p9  if signgum is 32-bit int
      // set p10 if signgum is 64-bit int
      cmp.eq        p10,p9 = 8,r34
      fma.s1        FR_S2 = FR_S10,FR_Xf8,FR_S2
(p13) br.cond.spnt  lgammaf_singularity
};;
.pred.rel "mutex",p9,p10
{ .mmf
(p9)  st4           [r33] = GR_SignOfGamma  // as 32-bit int
(p10) st8           [r33] = GR_SignOfGamma  // as 64-bit int
      fms.s1        FR_A0 = FR_A3,FR_x3,FR_A0 // -A3*x^3-A0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_Tf = FR_Nf,FR_Ln2,FR_Tf
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_Ln = FR_S2,FR_Xf2,FR_Ln // S2*Xf^2+Ln
      nop.i         0
};;
{ .mfi
      nop.m         0
      fma.s1        FR_Lnf = FR_P32f,FR_rf,FR_Tf
      nop.i         0
};;
{ .mfi
      nop.m         0
      fms.s1        FR_Ln = FR_A0,f1,FR_Ln
      nop.i         0
};;
{ .mfb
      nop.m         0
      fms.s.s0      f8 = FR_Ln,f1,FR_Lnf
      br.ret.sptk   b0
};;
// branch for handling +/-0, NaT, QNaN, +/-INF and denormalised numbers
//---------------------------------------------------------------------
.align 32
lgammaf_spec:
{ .mfi
      getf.exp      GR_SignExp = FR_NormX
      fclass.m      p6,p0 = f8,0x21 // is arg +INF?
      mov           GR_SignOfGamma = 1 // set signgam to 1
};;
{ .mfi
      getf.sig      GR_Sig = FR_NormX
      fclass.m      p7,p0 = f8,0xB // is x deno?
      // set p11 if signgum is 32-bit int
      // set p12 if signgum is 64-bit int
      cmp.eq        p12,p11 = 8,r34
};;
.pred.rel "mutex",p11,p12
{ .mfi
      // store sign of gamma(x) as 32-bit int
(p11) st4           [r33] = GR_SignOfGamma
      fclass.m      p8,p0 = f8,0x1C0 // is arg NaT or NaN?
      dep.z         GR_Ind = GR_SignExp,3,4
}
{ .mib
      // store sign of gamma(x) as 64-bit int
(p12) st8           [r33] = GR_SignOfGamma
      and           GR_Exp = GR_ExpMask,GR_SignExp
(p6)  br.ret.spnt   b0 // exit for +INF
};;
{ .mfi
      sub           GR_PureExp = GR_Exp,GR_ExpBias
      fclass.m      p9,p0 = f8,0x22 // is arg -INF?
      extr.u        GR_Ind4T = GR_Sig,55,8
}
{ .mfb
      nop.m         0
(p7)  fma.s0        FR_tmp = f1,f1,f8
(p7)  br.cond.sptk  lgammaf_core
};;
{ .mfb
      nop.m         0
(p8)  fms.s.s0      f8 = f8,f1,f8
(p8)  br.ret.spnt   b0 // exit for NaT and NaN
};;
{ .mfb
      nop.m         0
(p9)  fmerge.s      f8 = f1,f8
(p9)  br.ret.spnt   b0 // exit -INF
};;
// branch for handling negative integers and +/-0
//---------------------------------------------------------------------
.align 32
lgammaf_singularity:
{ .mfi
      mov           GR_SignOfGamma = 1 // set signgam to 1
      fclass.m      p6,p0 = f8,0x6 // is x -0?
      mov           GR_TAG = 109 // negative
}
{ .mfi
      mov           GR_ad_SignGam = r33
      fma.s1        FR_X = f0,f0,f8
      nop.i         0
};;
{ .mfi
      nop.m         0
      frcpa.s0      f8,p0 = f1,f0
      // set p9  if signgum is 32-bit int
      // set p10 if signgum is 64-bit int
      cmp.eq        p10,p9 = 8,r34
}
{ .mib
      nop.m         0
(p6)  sub           GR_SignOfGamma = r0,GR_SignOfGamma
      br.cond.sptk  lgammaf_libm_err
};;
// overflow (x > OVERFLOV_BOUNDARY)
//---------------------------------------------------------------------
.align 32
lgammaf_overflow:
{ .mfi
      nop.m         0
      nop.f         0
      mov           r8 = 0x1FFFE
};;
{ .mfi
      setf.exp      f9 = r8
      fmerge.s      FR_X = f8,f8
      mov           GR_TAG = 108 // overflow
};;
{ .mfi
      mov           GR_ad_SignGam = r33
      nop.f         0
      // set p9  if signgum is 32-bit int
      // set p10 if signgum is 64-bit int
      cmp.eq        p10,p9 = 8,r34
}
{ .mfi
      nop.m         0
      fma.s.s0      f8 = f9,f9,f0 // Set I,O and +INF result
      nop.i         0
};;
// gate to __libm_error_support#
//---------------------------------------------------------------------
.align 32
lgammaf_libm_err:
{ .mmi
      alloc        r32 = ar.pfs,1,4,4,0
      mov          GR_Parameter_TAG = GR_TAG
      nop.i        0
};;
.pred.rel "mutex",p9,p10
{ .mmi
      // store sign of gamma(x) as 32-bit int
(p9)  st4          [GR_ad_SignGam] = GR_SignOfGamma
      // store sign of gamma(x) as 64-bit int
(p10) st8          [GR_ad_SignGam] = GR_SignOfGamma
      nop.i        0
};;
GLOBAL_LIBM_END(__libm_lgammaf)


LOCAL_LIBM_ENTRY(__libm_error_region)
.prologue
{ .mfi
      add   GR_Parameter_Y=-32,sp             // Parameter 2 value
      nop.f 0
.save ar.pfs,GR_SAVE_PFS
      mov  GR_SAVE_PFS=ar.pfs                 // Save ar.pfs
}
{ .mfi
.fframe 64
      add sp=-64,sp                           // Create new stack
      nop.f 0
      mov GR_SAVE_GP=gp                       // Save gp
};;
{ .mmi
      stfs [GR_Parameter_Y] = FR_Y,16         // STORE Parameter 2 on stack
      add GR_Parameter_X = 16,sp              // Parameter 1 address
.save   b0, GR_SAVE_B0
      mov GR_SAVE_B0=b0                       // Save b0
};;
.body
{ .mib
      stfs [GR_Parameter_X] = FR_X                  // STORE Parameter 1
                                                    // on stack
      add   GR_Parameter_RESULT = 0,GR_Parameter_Y  // Parameter 3 address
      nop.b 0
}
{ .mib
      stfs [GR_Parameter_Y] = FR_RESULT             // STORE Parameter 3
                                                    // on stack
      add   GR_Parameter_Y = -16,GR_Parameter_Y
      br.call.sptk b0=__libm_error_support#         // Call error handling
                                                    // function
};;
{ .mmi
      nop.m 0
      nop.m 0
      add   GR_Parameter_RESULT = 48,sp
};;
{ .mmi
      ldfs  f8 = [GR_Parameter_RESULT]       // Get return result off stack
.restore sp
      add   sp = 64,sp                       // Restore stack pointer
      mov   b0 = GR_SAVE_B0                  // Restore return address
};;
{ .mib
      mov   gp = GR_SAVE_GP                  // Restore gp
      mov   ar.pfs = GR_SAVE_PFS             // Restore ar.pfs
      br.ret.sptk     b0                     // Return
};;

LOCAL_LIBM_END(__libm_error_region)
.type   __libm_error_support#,@function
.global __libm_error_support#