// File: vsklad[P]cgen/./bal/cnf/cnf/cnfclauses.hpp
// Function: void bal::caca_expand_flags<(unsigned short)3, (unsigned short)4, (unsigned short)1, (unsigned short)2, (unsigned short)3>(unsigned short&)
inline void caca_expand_flags(clause_flags_t& value) {
        static_assert(2 <= size1 && size1 < size2 && size2 <= 4, "expansion is possible to c3 or c4");
        static_assert(0 <= l0_index && l0_index < l1_index && l1_index < l2_index, "invalid indexes");
        static_assert(size1 != 3 || l2_index < size2, "the third index is only used for c3->c4");
        static_assert(size1 == 3 || l2_index == size2, "the third index is only used for c3->c4");
        if (size1 == 2) {
            if (l1_index < 3) {
                if (l0_index == 0 && l1_index == 1) {
                    value |= (value << 4);
                } else if (l0_index == 0 && l1_index == 2) {
                    value = (value & 0x0003) | ((value & 0x000C) << 2);
                    value |= value << 2;
                } else if (l0_index == 1 && l1_index == 2) {
                    value = (value & 0x0001) | ((value & 0x0002) << 1) |
                    ((value & 0x0004) << 2) | ((value & 0x0008) << 3);
                    value |= value << 1;
                };
                if (size2 == 4) {
                    value |= (value << 8);
                };
            } else {
                _assert_level_0(_c2_is_single_clause_flags(value));
                if (l0_index == 0) {
                    value = (value == 1 ? 0x0055 : value == 2 ? 0x00AA : value == 4 ? 0x5500 : 0xAA00);
                } else if (l0_index == 1) {
                    value = (value == 1 ? 0x0033 : value == 2 ? 0x00CC : value == 4 ? 0x3300 : 0xCC00);
                } else {
                    value = (value == 1 ? 0x000F : value == 2 ? 0x00F0 : value == 4 ? 0x0F00 : 0xF000);
                };
            };
        } else {
            if (l0_index == 0 && l1_index == 1 && l2_index == 2) {
                value |= (value << 8);
            } else if (l0_index == 0 && l1_index == 1 && l2_index == 3) {
                value = (value & 0x000F) | ((value & 0x00FF) << 4) | ((value & 0x00F0) << 8);
            } else if (l0_index == 0 && l1_index == 2 && l2_index == 3) {
                value = (value & 0x0003) | ((value & 0x000C) << 2) | ((value & 0x0030) << 4) | ((value & 0x00C0) << 6);
                value |= value << 2;
            } else if (l0_index == 1 && l1_index == 2 && l2_index == 3) {
                value = (value & 0x0001) | ((value & 0x0002) << 1) | ((value & 0x0004) << 2) | ((value & 0x0008) << 3) |
                            ((value & 0x0010) << 4) | ((value & 0x0020) << 5) | ((value & 0x0040) << 6) | ((value & 0x0080) << 7);
                value |= value << 1;
            };
        };
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movzwl (%rax), %eax
andl $0x1, %eax
movq -0x8(%rbp), %rcx
movzwl (%rcx), %ecx
andl $0x2, %ecx
shll %ecx
orl %ecx, %eax
movq -0x8(%rbp), %rcx
movzwl (%rcx), %ecx
andl $0x4, %ecx
shll $0x2, %ecx
orl %ecx, %eax
movq -0x8(%rbp), %rcx
movzwl (%rcx), %ecx
andl $0x8, %ecx
shll $0x3, %ecx
orl %ecx, %eax
movq -0x8(%rbp), %rcx
movzwl (%rcx), %ecx
andl $0x10, %ecx
shll $0x4, %ecx
orl %ecx, %eax
movq -0x8(%rbp), %rcx
movzwl (%rcx), %ecx
andl $0x20, %ecx
shll $0x5, %ecx
orl %ecx, %eax
movq -0x8(%rbp), %rcx
movzwl (%rcx), %ecx
andl $0x40, %ecx
shll $0x6, %ecx
orl %ecx, %eax
movq -0x8(%rbp), %rcx
movzwl (%rcx), %ecx
andl $0x80, %ecx
shll $0x7, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, (%rax)
movq -0x8(%rbp), %rax
movzwl (%rax), %edx
shll %edx
movq -0x8(%rbp), %rax
movzwl (%rax), %ecx
orl %edx, %ecx
movw %cx, (%rax)
popq %rbp
retq
nop