Mesh deforms after automatic weights (IK and pole vector) 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
I think that’s the main problem is that you need to correct the Pole Angle of your IK bones or they are going to rotate crazy once in Pose mode, -90° for both right and left IK.

Also in Edit mode you need to bend the knees bones a bit forwards so that they’ll bend correctly in Pose mode. And join the 2 pole targets to your main armature. Make sure some bones (controllers, pole targets, root) won’t deform the mesh: Select each of them and disable their Deform option. And it looks like you have a lot of overlapping vertices, so altM > Merge By Distance and play with the parameters.