To fill column with profile , process rows to . If bit is set, that cell is already occupied (skip). Otherwise, you must fill it. Two choices: place a vertical tile (occupies current and next column, setting bit in ) or horizontal tile (occupies current column only, but row must also be empty and gets filled).
This recursive function tries all valid placements and accumulates ways to reach each . Only when all rows are processed does become a valid next profile.