What's the right "cost basis" for a primary home converted into a rental home?

Purchased a CA home 10yrs ago at 400k, then converted into rental home while its FMV is 700k already. What's the right "cost basis" in this case when calculate the depreciation?  Should be original purchase 400k (+ any improvement cost and then minus land value as I know from IRS code) as the cost basis only as it's way lower than the FMV? 

2nd question, if I moved back into this rental home in 5yrs later (converting it back to be primary home), and later selling it after living 2+yrs, do I need to pay that depreciation recapture tax and why? And will the cost basis choice (between FMV vs. original purchase value) impact this recapture tax please?

 

ps: saw a similar discussion there but not exact same thus I reposted it again and hopefully more experts like @DS30 can help further expand the topic.