Language: C++

#include <iostream>
#include <string>
#include <vector>

enum { PATTERN_1, PATTERN_2, PATTERN_3, PATTERN_4 };


bool can_match(const std::string &str, const std::string &query)
{
    for (int i = 0; i < str.size(); ++i)
        if (str.at(i) != 'x' and
            str.at(i) != query.at(i))
            return false;

    return true;
}


size_t variation(const std::string &byte, size_t offset, size_t size)
{
    size_t out(1);    
    for (size_t i = offset; i < offset + size; ++i)
        if (byte.at(i) == 'x')
            out *= 2;
    return out;
}


bool can_be_pattern_of(int pattern, std::vector<std::string> &input, size_t offset)
{
#define getbyte(i) input.at(offset + i)
    switch (pattern)
    {
    case PATTERN_1:
        if (input.size() - offset >= 1)
        {
            char c = getbyte(0).at(0);
            return (c == '0') or (c == 'x');
        }
        
    case PATTERN_2:
        if (input.size() - offset >= 2)
        {
            return
                can_match(getbyte(0).substr(0, 3), "110")
                and can_match(getbyte(1).substr(0, 2), "10")
                and (getbyte(0).substr(3, 4) != "0000");
        }
        break;
        
    case PATTERN_3:
        if (input.size() - offset >= 3)
        {
            return
                can_match(getbyte(0).substr(0, 4), "1110")
                and can_match(getbyte(1).substr(0, 2), "10")
                and can_match(getbyte(2).substr(0, 2), "10")
                and ((getbyte(0).substr(4, 4) != "0000") or (getbyte(1)[2] != '0'));
        }
        
    case PATTERN_4:
        if (input.size() - offset >= 4)
        {
            return
                can_match(getbyte(0).substr(0, 5), "11110")
                and can_match(getbyte(1).substr(0, 2), "10")
                and can_match(getbyte(2).substr(0, 2), "10")
                and can_match(getbyte(3).substr(0, 2), "10")
                and ((getbyte(0).substr(5, 3) != "000") or (getbyte(1).substr(2, 2) != "00"));
        }
    }
    
    return false;
#undef getbyte
}


size_t count(std::vector<std::string> &input, size_t offset)
{
    if (offset >= input.size()) return 1;
    
#define getbyte(i) input.at(offset + i)
    size_t out(0);

    if (can_be_pattern_of(PATTERN_1, input, offset))
        out += variation(getbyte(0), 1, 7) * count(input, offset + 1);
    
    if (can_be_pattern_of(PATTERN_2, input, offset))
    {
        size_t var_x =
            variation(getbyte(0), 7, 1) *
            variation(getbyte(1), 2, 6);

Compiler output:
a.cc: In function 'size_t count(std::vector<std::__cxx11::basic_string<char> >&, size_t)':
a.cc:92:41: error: expected '}' at end of input
   92 |             variation(getbyte(1), 2, 6);
      |                                         ^
a.cc:89:5: note: to match this '{'
   89 |     {
      |     ^
a.cc:92:41: error: expected '}' at end of input
   92 |             variation(getbyte(1), 2, 6);
      |                                         ^
a.cc:79:1: note: to match this '{'
   79 | {
      | ^
a.cc:92:41: warning: control reaches end of non-void function [-Wreturn-type]
   92 |             variation(getbyte(1), 2, 6);
      |                                         ^