First off, a disclaimer: This information is worth exactly what you paid for it - nothing. If you want the best answer, see the answer about consulting a lawyer. If you want to do your own research, here's a really good place to start. After research, still consult a lawyer. I mean it. Not all my information may be correct or accurate, so take it at face value.
Globally, there is no easy way to define the laws and regulations surrounding your question. The answer is found in patent laws, since copyright has only so much power over that area.
The fact that the software is not directly reverse engineered bypasses most of Copyright laws as far as I'm aware based on all the research I've done; you will DEFINITELY want to make sure I'm right on this one - it holds true in India, and I think similar concepts apply in the U.S. and other places. That leaves us with the oh-so-nebulous world of patents!
Software patents are a very big gray area. I hope you're ready to do some reading. I'm going to share the most relevant ones. You're on your own for anything else.
United States
In the United States, patent law excludes abstract ideas, which has led to some software not being patentable. At the same time, there has been a trend of growth in the number of software patents granted in the United States, so there can be major problems if your software, which has the same functionality as the patent-holder's software, is based on the same design specs. While reverse engineering the software for interoperability would be protected, creating a clone of it with different code would be illegal under patent law.
There are also the legal factors of Copyright and Trademark. The Digital Millenium Copyright Act (DMCA) provides further clarification on copyright (Wikipedia also does a good job summarizing it). Trademark law is handled similarly to patents, but there are other restrictions. However, for the purposes of length, I'll let you discover that (Google is your friend here).
Further Reading and resources:
UK and European Union
Substantive law in the United Kingdom generally excludes computer software from being patentable, as stated in The Patents Act of 1977. In the European Union, the European Patent Convention (EPC) specifies what an invention is, and software does not fall under that category (see also European Patent Office's (EPO's) Patents for Software?). UK courts have taken the view that the differences between the text of Section 1 of the Patents Act and Article 52 of the EPC should be ignored since Section 1 was to transpose Article 52 of the EPC into UK law; therefore, the EPC was the definitive text.
Case law in the UK has a very sporadic history of whether software is patentable. Currently, the UK Intellectual Property Office (UKIPO) and the EPO have diverged significantly in practice. There has been a rise in the number of patents granted. There have been more Patent office decisions than there have been Court decisions on the matter.
Further Reading and resources:
India
Most of the stuff for India is covered in your other question, especially the sources cited in my answer there (especially the paper Software Patent and Copyright Laws in India, which argues why software should be patentable). Unless the laws have changed significantly, you'd be safer here.
Finally...
You probably wouldn't be safe selling the software on a global market, since the majority of the market is seeing a growth in the number of software patents granted. There are also so many other legal factors that you'd be at great risk.
There are some exceptions, of course, which is how OpenOffice exists (for example); however, it has different functionality from Microsoft Office, which makes it an exception, even if the base functionality is exactly the same.
You're kind of on your own for the rest of the research (I've given you and anyone else a good starting point).