Income taxes | Income taxes Income (loss) before income taxes consisted of the following: Year ended December 31, (in thousands) 2017 2016 2015 Domestic $ (123,325 ) $ (200,595 ) $ 13,562 Foreign (53,062 ) (174,579 ) 39,023 $ (176,387 ) $ (375,174 ) $ 52,585 Income tax expense consisted of the following: Year ended December 31, (in thousands) 2017 2016 2015 Current Federal $ (1,857 ) $ (2,925 ) $ 18,548 State 240 (356 ) 3,007 Foreign 10,631 8,542 6,539 Total current 9,014 5,261 28,094 Deferred Federal (248 ) 37,573 (11,211 ) State — 4,436 (204 ) Foreign (2,280 ) (3,441 ) (225 ) Total deferred (2,528 ) 38,568 (11,640 ) Income tax expense $ 6,486 $ 43,829 $ 16,454 As of December 31, 2017 , $4.5 million of earnings had been indefinitely reinvested outside the U.S., primarily in active non-U.S. business operations. We do not intend to repatriate these earnings to fund U.S. operations and, accordingly, we do not provide for U.S. state income and foreign withholding tax on these earnings. See also TCJA discussion below. Year ended December 31, 2017 2016 2015 (dollars in thousands) $ % $ % $ % Reconciliation to statutory rate Tax at federal statutory rate $ (61,735 ) (35.0 )% $ (131,311 ) (35.0 )% $ 18,405 35.0 % Change in valuation allowance (38,016 ) (21.6 ) 101,878 27.2 8,555 16.3 DTA rate change impact due to TCJA 74,943 42.5 — — — — Impact of foreign operations 34,039 19.3 84,491 22.5 6,434 12.2 Stock-based compensation 12,001 6.8 15,718 4.2 2,390 4.5 State taxes, net of federal benefit (6,469 ) (3.7 ) (14,195 ) (3.8 ) 1,454 2.8 Tax credits (9,957 ) (5.6 ) (12,992 ) (3.5 ) (21,891 ) (41.6 ) Other 1,680 1.0 240 0.1 1,107 2.1 Income tax provision at effective tax rate $ 6,486 3.7 % $ 43,829 11.7 % $ 16,454 31.3 % The effective tax rate of 2017 resulted from a significant benefit on pre-tax book losses, offset by the valuation allowance on U.S. federal and state net deferred tax assets and by income taxes paid at lower rates in profitable foreign jurisdictions (primarily wholly owned subsidiaries in Europe). In addition, due to the U.S. enactment of the TCJA, U.S. deferred tax assets were revalued by $74.9 million at the statutory rate of 21% which will be effective January 1, 2018, with a corresponding valuation allowance adjustment. In addition, AMT credits of $0.2 million become refundable under the TCJA and $0.2 million of valuation allowance was released. The effective tax rate of 2016 resulted from a significant benefit on pre-tax book losses, offset by the establishment of a valuation allowance on all U.S. federal and state net deferred tax assets and by income taxes paid at lower rates in profitable foreign jurisdictions (primarily wholly owned subsidiaries in Europe). Overall, the provision for income taxes in each period has differed from the tax computed at U.S. federal statutory tax rates due to change in valuation allowance, the effect of non-U.S. operations, deductible and non-deductible stock-based compensation expense, states taxes, federal research and development tax credits, and other adjustments. The lower effective tax rates of 2016 compared to 2015 resulted from a significant benefit on pre-tax book losses, offset by the establishment of a valuation allowance on all U.S. federal and state net deferred tax assets and by income taxes paid at lower rates in profitable foreign jurisdictions (primarily wholly owned subsidiaries in Europe). The provision for income taxes in each period has differed from the tax computed at U.S. federal statutory tax rates due to change in valuation allowance, the effect of non-U.S. operations, deductible and non-deductible stock-based compensation expense, states taxes, federal research and development tax credits, and other adjustments. Deferred income taxes reflect the net tax effects of temporary differences between the carrying amounts of assets and liabilities for financial reporting purposes and the amounts used for income tax purposes. Significant components of the Company’s deferred tax assets and liabilities were as follows: Year ended December 31, (in thousands) 2017 2016 Deferred tax assets: Net operating loss carryforwards $ 113,378 $ 30,193 Tax credit carryforwards 66,983 22,341 Stock-based compensation 13,055 26,656 Allowance for returns 5,452 6,336 Intangible assets 770 — Accruals and reserves 18,981 26,587 Total deferred tax assets 218,619 112,113 Valuation allowance (217,884 ) (110,433 ) Total deferred tax assets, net of valuation allowance 735 1,680 Deferred tax liabilities: Depreciation and amortization (292 ) (1,714 ) Intangible assets — (2,540 ) Total deferred tax liabilities (292 ) (4,254 ) Net deferred tax assets (liabilities) $ 443 $ (2,574 ) Recognition of deferred tax assets is appropriate when realization of such assets is more likely than not. Based upon the weight of available evidence, the Company believes it is not more likely than not that the U.S. deferred tax assets will be realized. Accordingly, a valuation allowance has been established and maintained against U.S. deferred tax assets. The foreign deferred tax assets in each jurisdiction are minimal and are supported by taxable income or in the case of acquired companies, by the future reversal of deferred tax liabilities. It is more likely than not that the Company’s foreign deferred tax assets will be realized and thus, no valuation allowance is required on foreign deferred tax assets. The Company will continue to assess the realizability of the deferred tax assets in each of the applicable jurisdictions going forward. The Company’s valuation allowance increased by $107.5 million to $217.9 million as of December 31, 2017 , primarily due to the impact of the ASU 2016-09 adoption that resulted in an increase in U.S. deferred tax assets of $163.0 million and current year movement on U.S. deferred tax assets of $36.9 million , offset by a decrease due to $17.5 million attributable to the debt discount on convertible debt, and a $74.9 million decrease due to the change in future tax rate under the enacted TCJA on December 22, 2017. As of December 31, 2016 , the Company had established a valuation allowance of $110.4 million on all U.S. federal and state deferred tax assets. As of December 31, 2017 , the Company’s federal, California and other state net operating loss carryforwards for income tax purposes were $456.1 million , $210.3 million and $233.7 million , net of reserves, respectively and federal and California state tax credit carryforwards were $39.6 million and $34.4 million , net of reserves, respectively. If not utilized, federal loss, federal credit and California loss carryforwards will begin to expire from 2030 to 2037, while other state loss carryforwards will begin to expire from 2019 to 2037. California tax credits may be carried forward indefinitely. Under the provisions of §382 of the Internal Revenue Code, a change of control may impose an annual limitation on the amount of the Company’s net operating loss and tax credit carryforwards that can be used to reduce future tax liabilities. Of the Company’s total $456.1 million federal net operating loss carryforwards, approximately $8.1 million was from one of our 2016 acquisitions. These acquired tax attributes are subject to an annual limitation of $1.7 million per year for federal purposes and will begin to expire in the year 2034, if not utilized. Uncertain income tax positions. The Company had gross unrecognized tax benefits of $58.6 million , $56.9 million and $36.3 million , as of December 31, 2017 , 2016 and 2015 , respectively. For fiscal 2017 , 2016 and 2015 , total unrecognized income tax benefits in the amount of $19.8 million , $24.1 million and $31.0 million , respectively, if recognized, would reduce income tax expense after considering the impact of the change in valuation allowance in the U.S. A material portion of our gross unrecognized tax benefits, if recognized, would increase the Company’s net operating loss carryforward, which would be offset by a full valuation allowance based on present circumstances. These unrecognized tax benefits relate primarily to unresolved matters with taxing authorities regarding the Company’s transfer pricing positions and tax positions based on the Company’s interpretation of certain U.S. trial and appellate court decisions, which remain subject to appeal and therefore could be overturned in future periods. Management believes events that could occur in the next 12 months and cause a material change in unrecognized tax benefits include, but are not limited to, the completion of examinations by the U.S. or foreign taxing authorities and the expiration of statute of limitations on the Company’s tax returns. Although the completion, settlement and closure of any audits is uncertain, it is reasonably possible based on the receipt of the Joint Committee approval of the federal claimed income tax refund relating to the carryback of 2014 and 2015 net operating losses on December 18, 2017, and the IRS Closing Agreement received on January 24, 2018, that over the next twelve-month period, our unrecognized tax benefits as of December 31, 2017 , will decrease in the range of $15.0 million to $20.0 million , of which approximately $2.0 million to $3.0 million benefit would impact our effective tax rate. Such reduction is due to the resolution of certain issues, primarily related to transfer pricing and the R&D credit, raised in connection with our federal examination. Thus, we believe that that the total amount of unrecognized tax benefits will decrease within the next 12 months. However, for all other jurisdictions, given the number of years remaining that are subject to examination, the range of the reasonably possible change cannot be estimated reliably. A reconciliation of the beginning and ending amount of the unrecognized income tax benefits are as follows: Year ended December 31, (in thousands) 2017 2016 2015 Gross balance at January 1 $ 56,909 $ 36,273 $ 16,558 Gross increase related to current year tax positions 20,002 20,594 19,948 Gross decrease related to tax rate change for current year tax positions (2,299 ) — — Gross increase related to prior year tax positions — 130 108 Gross decrease related to prior year tax positions (3,927 ) (88 ) (341 ) Gross decrease related to tax rate change for prior year tax positions (12,101 ) — — $ 58,584 $ 56,909 $ 36,273 Due to the U.S. enactment of the TCJA, U.S. unrecognized income tax benefits that reduce federal tax attributes are revalued at the statutory rate of 21% . Total gross decreases to unrecognized tax benefits were $14.4 million relating to the change in tax rates from 35% to 21% . The Company’s policy is to account for interest and penalties related to income tax liabilities within the provision for income taxes. The balances of accrued interest and penalties recorded in the balance sheets and provision were not material for any period presented. The Company files income tax returns in U.S. and non-U.S. jurisdictions. The Company is subject to federal, state and foreign income tax examinations for calendar tax years ending 2012 through 2016. The tax authorities could choose to audit the tax years beyond the statute of limitation period due to tax attribute carryforwards from prior years, making adjustments only to carryforward attributes. The Company has been under examination by the Internal Revenue Service for the 2012 through 2015 tax years. IRS audit fieldwork has been completed and the claimed income tax refund of approximately $32.9 million relating to the carryback of 2014 and 2015 net operating losses was approved by the Congressional Joint Committee on Taxation (JCT) on December 18, 2017. See also Note 14 Subsequent Events for additional information. U.S. Tax Reform. The Tax Cuts and Job Act (TCJA) of 2017, enacted on December 22, 2017, contains significant changes to U.S. tax law, including lowering the U.S. corporate income tax rate to 21%, implementing a territorial tax system, and imposing a one-time tax on deemed repatriated earnings of foreign subsidiaries. The TCJA reduces the U.S. statutory tax rate from 35% to 21% , effective January 1, 2018. During the three months ended December 31, 2017, the Company recorded a $74.9 million tax expense representing the detriment of remeasuring its U.S. deferred tax liabilities at the lower 21% statutory tax rate, as well as a corresponding full valuation allowance for the same amount resulting in no impact to our Statement of Operations. The TCJA also implements a territorial tax system. Under the territorial tax system, in general, the Company’s foreign earnings will no longer be subject to tax in the U.S. As part of transitioning to the territorial tax system the TCJA includes a mandatory deemed repatriation of all undistributed foreign earnings that are subject to a U.S. income tax. The Company estimates that the deemed repatriation will not result in any additional U.S. income tax. This preliminary estimate may be impacted by a number of additional considerations, including, but not limited to, the issuance of final regulations and the Company's ongoing analysis of the new law. As of December 31, 2017 , the Company has approximately $4.5 million of undistributed earnings for certain non-U.S. subsidiaries that have been indefinitely reinvested outside the U.S. These undistributed earnings do not result in a one-time deemed repatriation tax due to our overall accumulated foreign deficit, however these earnings could be subject to additional foreign and state income taxes if they are repatriated. The Company has historically asserted its intent to reinvest these earnings in foreign operations indefinitely and continues to do so. We do not intend to repatriate these earnings to fund U.S. operations and, accordingly, we do not provide for U.S. state income and foreign withholding tax on these earnings. While the TJCA provides for a territorial tax system, beginning in 2018, it includes two new U.S. tax base erosion provisions, the global intangible low-taxed income (GILTI) provisions and the base-erosion and anti-abuse tax (BEAT) provisions. The GILTI provisions require the Company to include in its U.S. income tax return foreign subsidiary earnings in excess of an allowable return on the foreign subsidiary’s tangible assets. The Company does not expect that this GILTI income inclusion will result in significant U.S. tax beginning in 2018. The BEAT provisions in the TCJA eliminates the deduction of certain base-erosion payments made to related foreign corporations and impose a minimum tax if greater than regular tax. The Company does not expect that the BEAT provision will result in significant U.S. tax beginning in 2018. In addition, the Company intends to account for the GILTI taxes in the period in which it is incurred, and therefore has not provided any deferred tax impacts of GILTI in its consolidated financial statements for the year ended December 31, 2017. On December 22, 2017, the SEC staff issued Staff Accounting Bulletin No. 118 (SAB 118) to address the application of U.S. GAAP in situations when a registrant does not have the necessary information available, prepared, or analyzed (including computations) in reasonable detail to complete the accounting for certain income tax effects of the TCJA. The Company has recognized the provisional tax impacts related to deemed repatriated earnings and the revaluation of deferred tax assets and liabilities to the extent needed and included these amounts in its consolidated financial statements for the year ended December 31, 2017 . The ultimate impact may differ from these provisional amounts, possibly materially, due to, among other things, additional analysis, changes in interpretations and assumptions the Company has made, additional regulatory guidance that may be issued, and actions the Company may take as a result of the TCJA. The accounting is expected to be complete when the 2017 U.S. corporate income tax return is filed in 2018. |