Loops and repeats in proteins as footprints of molecular evolution