PriMagic: Component-Based Synthesis of Loopy and Non-Loopy Programs