Blend : https://gofile.io/?c=4od4mq
My self made rig completely deforms after automatic weights. I've altered the rotation of the IK bone, in pose mode and reset the rotation of the bones with alt+G. When I created the bones, I did not pay attention to rotation axes. Did I mention I did not took the time to rename the bones?
What I might think is the problem is the legs, of the original mesh were not completely in T Pose. Furthermore, the lower part of the mesh breaks after the process, which is caused by other problems. I Followed this tutorial https://www.youtube.com/watch?v=PM8mOq9RiNE