#include <cstdint>
#include <iostream>
#include <limits>

int main() {
    if (std::numeric_limits<unsigned int>::digits != 32 ||
        std::numeric_limits<int>::digits != 31) {
        std::cout << "unsupported-integer-environment\n";
        return 1;
    }
    const std::uint32_t read_bit{1U};
    const std::uint32_t write_bit{2U};
    const std::uint32_t execute_bit{4U};
    std::uint32_t flags{read_bit};
    flags |= write_bit;
    const bool has_write{(flags & write_bit) != 0U};
    const bool has_execute{(flags & execute_bit) != 0U};
    std::cout << "combined=" << flags << " has-write=" << has_write
              << " has-execute=" << has_execute << '\n';
    const std::uint32_t toggled{flags ^ execute_bit};
    const std::uint32_t cleared{toggled & ~write_bit};
    const std::uint32_t inverted_read{~read_bit};
    std::cout << "toggled=" << toggled << " cleared=" << cleared << '\n';
    std::cout << "inverted-read=" << inverted_read << '\n';
    if (!has_write || has_execute || (cleared & write_bit) != 0U ||
        (cleared & execute_bit) == 0U) {
        return 1;
    }
    return 0;
}
