// File: /workspace/github_cpp_makefile_star2_O2/vsklad[P]cgen/./bal/variables/variablesio.cpp
// Function: bal::operator<<(std::ostream&, bal::VariablesArray const&)
std::ostream& operator << (std::ostream& stream, const VariablesArray& array) {
        const variableid_t size = array.size();
        const variableid_t element_size = array.element_size();
        const variableid_t elements_size = size / element_size;
        
        assert(elements_size * element_size == size);
        
        const literalid_t* literalid = array.data();
        bool bracket_1_open = false;
        
        size_t i = 0;
        while (i < elements_size) {
            if (i > 0) {
                stream << ", ";
            };
            
            // check and process the possible sequence of elements
            size_t elements_sequence_size = 1;
            int elements_sequence_step = 0;
            get_variables_range_sequence_(literalid, size - (i * element_size), element_size,
                                                    elements_sequence_size, elements_sequence_step);
            
            if (i == 0 && !bracket_1_open && size > element_size * elements_sequence_size) {
                stream << "{";
                bracket_1_open = true;
            };

            bool bracket_2_open = false;
            
            size_t j = 0;
            while(j < element_size) {
                size_t k;
                
                // output constant as much as possible, limit to 64 bit, align to 4 bits
                // look ahead bit by bit and compress
                uint64_t constant = 0;
                k = 0;
                while ((k < 64) && (j + k) < element_size) {
                    if (literal_t__is_constant(*(literalid + k))) {
                        constant = (constant << 1) | (literal_t__is_constant_1(*(literalid + k)) ? 1 : 0);
                        k++;
                        continue;
                    };
                    break;
                };
                if (k > 0) {
                    // constants that have number of bits mod 4 != 0, require brackets
                    // because they are split into bin and hex
                    if (j == 0 && ((k < element_size) || (k > 3 && k % 4 != 0)) && !bracket_2_open) {
                        stream << "{";
                        bracket_2_open = true;
                    } else if (j > 0) {
                        stream << ", ";
                    };
                    
                    // output the most significant bits to align to 4 from the lower end of the element
                    // if less than 4 bits total, output everything here
                    const size_t k_prefix = (k <= 3) ? k : ((element_size - j) & 0x3);
                    if (k_prefix > 0 && k > 0) {
                        uint64_t prefix_constant = constant >> (k > k_prefix ? k - k_prefix : 0);
                        stream << "0b";
                        stream << ((k_prefix > 2 && k > 2) ? (prefix_constant & 0b100) ? "1" : "0" : "");
                        stream << ((k_prefix > 1 && k > 1) ? (prefix_constant & 0b010) ? "1" : "0" : "");
                        stream <<                           ((prefix_constant & 0b001) ? "1" : "0");
                        // zero out b_prefix most significant bits
                        constant &= 0xFFFFFFFFFFFFFFFFull >> (64 - k + k_prefix);
                    };
                    
                    if (k > k_prefix) {
                        const size_t k_suffix = (k - k_prefix) & 0x3;
                        if (k - k_prefix > k_suffix) {
                            // output the main part of the constant aligned to 4 bits
                            if (k_prefix > 0) {
                                stream << ", "; // separate from the prefix
                            };
                            stream << "0x" << std::setfill('0') << std::setw((int)((k - k_prefix) >> 2));
                            stream << std::hex << (constant >> k_suffix);
                        };
                        
                        if (k_suffix > 0) {
                            // output the remaining least significant bits
                            if (k > k_suffix) {
                                stream << ", "; // separate from the hex constant
                            };
                            stream << "0b";
                            stream << (k_suffix > 2 ? (constant & 0b100) ? "1" : "0" : "");
                            stream << (k_suffix > 1 ? (constant & 0b010) ? "1" : "0" : "");
                            stream <<                ((constant & 0b001) ? "1" : "0");
                        };
                    };
                    
                    // skip the processed literals
                    literalid += k;
                    j += k;
                };
                
                // output variables as much as possible; compress sequential
                int sequence_step = 0;
                get_variables_sequence_(literalid, element_size - j, k, sequence_step);
                
                // elements_sequence_size == 1 && k > 1 means the sequence is within element
                // therefore must be bracketed in order to avoid confusion
                if (i == 0 && j == 0 && !bracket_1_open && elements_sequence_size == 1 && k > 1) {
                    stream << "{";
                    bracket_1_open = true;
                };
                
                if (k > 0) {
                    // k < element_size means there are more elements to output
                    // k > 1 sequence within element must always be bracketed
                    if (!bracket_2_open && j == 0 && (k < element_size || k > 1)) {
                        stream << "{";
                        bracket_2_open = true;
                    } else if (j > 0) {
                        stream << ", ";
                    };
                    stream << literal_t(*literalid);
                    write_sequence_parameters_(stream, k, sequence_step);
                    // skip the processed literals
                    literalid += k;
                    j += k;
                };
            };
            
            if (bracket_2_open) {
                stream << "}";
            };
            
            write_sequence_parameters_(stream, elements_sequence_size, elements_sequence_step);
            
            // skip processed elements
            i += elements_sequence_size;
            literalid += (elements_sequence_size - 1) * element_size;
        };
        
        if (bracket_1_open) {
            stream << "}";
        };
        return stream;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, -0x30(%rbp)
movl 0x8(%rsi), %ebx
movl 0x1c(%rsi), %r15d
movl %ebx, %eax
xorl %edx, %edx
divl %r15d
movl %eax, %ecx
imull %r15d, %ecx
cmpl %ebx, %ecx
jne 0x302c4
movq (%rsi), %r12
movl %eax, %eax
movq %rax, -0x90(%rbp)
xorl %r13d, %r13d
movq $0x0, -0x58(%rbp)
movq %rbx, -0x88(%rbp)
movq %r15, -0x70(%rbp)
cmpq -0x90(%rbp), %r13
jae 0x3029b
testq %r13, %r13
movq %r13, -0x80(%rbp)
je 0x2fe3a
movq -0x30(%rbp), %rdi
leaq 0x850f(%rip), %rsi      # 0x38316
callq 0xc290
movq $0x1, -0x50(%rbp)
andl $0x0, -0x3c(%rbp)
movq %r13, %rax
imulq %r15, %rax
subq %rax, %rbx
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
leaq -0x50(%rbp), %rcx
leaq -0x3c(%rbp), %r8
callq 0x30359
jmp 0x2fe85
movq $0x1, -0x50(%rbp)
andl $0x0, -0x3c(%rbp)
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
leaq -0x50(%rbp), %rcx
leaq -0x3c(%rbp), %r8
callq 0x30359
testb $0x1, -0x58(%rbp)
jne 0x2fe85
movq -0x50(%rbp), %rax
imulq %r15, %rax
cmpq %rbx, %rax
jae 0x2fe85
movq -0x30(%rbp), %rdi
leaq 0xa411(%rip), %rsi      # 0x3a28b
callq 0xc290
movb $0x1, %al
movq %rax, -0x58(%rbp)
xorl %r13d, %r13d
movq $0x0, -0x48(%rbp)
cmpq %r13, %r15
jbe 0x30253
xorl %eax, %eax
xorl %ebx, %ebx
cmpq $0x3f, %rax
ja 0x2fec2
leaq (%rax,%r13), %rcx
cmpq %r15, %rcx
jae 0x2fec2
cmpl $0x1, (%r12,%rax,4)
ja 0x2fec2
sete %cl
movzbl %cl, %ecx
leaq (%rcx,%rbx,2), %rbx
incq %rax
jmp 0x2fe9d
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x3013a
testq %r13, %r13
je 0x30221
leaq 0x8437(%rip), %rsi      # 0x38316
movq -0x48(%rbp), %rax
movl %eax, %r15d
movq -0x30(%rbp), %rdi
callq 0xc290
movl %r15d, %eax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq -0x70(%rbp), %r15
subl %r13d, %r15d
andl $0x3, %r15d
cmpq $0x4, %rax
cmovbq %rax, %r15
testq %r15, %r15
je 0x2ffde
subq %r15, %rax
movl $0x0, %ecx
cmovaeq %rax, %rcx
movq %rcx, -0x60(%rbp)
movq %rbx, %r14
shrq %cl, %r14
movq -0x30(%rbp), %rdi
leaq 0xe1c5(%rip), %rsi      # 0x3e0fc
callq 0xc290
testb $0x4, %r14b
leaq 0x13ed(%rip), %rsi      # 0x31334
leaq 0x35a0(%rip), %rax      # 0x334ee
cmoveq %rax, %rsi
cmpq $0x3, -0x38(%rbp)
leaq 0xdf86(%rip), %rax      # 0x3dee4
cmovbq %rax, %rsi
cmpq $0x3, %r15
cmovbq %rax, %rsi
movq -0x30(%rbp), %rdi
callq 0xc290
testb $0x2, %r14b
movq -0x30(%rbp), %r14
leaq 0x13b2(%rip), %rsi      # 0x31334
leaq 0x3565(%rip), %rax      # 0x334ee
cmoveq %rax, %rsi
cmpq $0x2, -0x38(%rbp)
leaq 0xdf4b(%rip), %rax      # 0x3dee4
cmovbq %rax, %rsi
cmpq $0x1, %r15
cmoveq %rax, %rsi
movq %r14, %rdi
callq 0xc290
movq -0x60(%rbp), %rax
btq %rax, %rbx
leaq 0x1378(%rip), %rsi      # 0x31334
leaq 0x352b(%rip), %rax      # 0x334ee
cmovaeq %rax, %rsi
movq %r14, %rdi
callq 0xc290
movq -0x38(%rbp), %rax
movl %r15d, %ecx
subl %eax, %ecx
shlq %cl, %rbx
shrq %cl, %rbx
movq %rax, %rcx
subq %r15, %rcx
jbe 0x3012f
movl %ecx, %edx
andl $0x3, %edx
cmpq $0x4, %rcx
movq %rdx, -0x60(%rbp)
jb 0x3007d
testq %r15, %r15
je 0x30012
movq -0x30(%rbp), %rdi
leaq 0x8309(%rip), %rsi      # 0x38316
callq 0xc290
movq -0x30(%rbp), %r14
movq %r14, %rdi
leaq 0xe0df(%rip), %rsi      # 0x3e0ff
callq 0xc290
movq %rax, %rdi
pushq $0x30
popq %rsi
callq 0xc400
movq -0x38(%rbp), %rcx
subq %r15, %rcx
movq (%rax), %rdx
movq -0x18(%rdx), %rdx
shrq $0x2, %rcx
movslq %ecx, %rcx
movq %rcx, 0x10(%rax,%rdx)
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r14,%rax)
movq %rbx, %rsi
movq -0x60(%rbp), %r15
movl %r15d, %ecx
shrq %cl, %rsi
movq %r14, %rdi
callq 0xc190
movq %r15, %rdx
movq -0x38(%rbp), %rax
testq %rdx, %rdx
movq -0x70(%rbp), %r15
je 0x30133
cmpq %rdx, %rax
jbe 0x3009f
movq -0x30(%rbp), %rdi
leaq 0x827c(%rip), %rsi      # 0x38316
callq 0xc290
movq -0x30(%rbp), %r14
movq %r14, %rdi
leaq 0xe04f(%rip), %rsi      # 0x3e0fc
callq 0xc290
testb $0x4, %bl
leaq 0x1278(%rip), %rsi      # 0x31334
leaq 0x342b(%rip), %rax      # 0x334ee
cmoveq %rax, %rsi
cmpq $0x3, -0x60(%rbp)
leaq 0xde11(%rip), %rax      # 0x3dee4
cmovneq %rax, %rsi
movq %r14, %rdi
callq 0xc290
testb $0x2, %bl
leaq 0x124b(%rip), %rsi      # 0x31334
leaq 0x33fe(%rip), %rax      # 0x334ee
cmoveq %rax, %rsi
cmpq $0x1, -0x60(%rbp)
leaq 0xdde4(%rip), %rax      # 0x3dee4
cmoveq %rax, %rsi
movq %r14, %rdi
callq 0xc290
testb $0x1, %bl
leaq 0x121e(%rip), %rsi      # 0x31334
leaq 0x33d1(%rip), %rax      # 0x334ee
cmoveq %rax, %rsi
movq %r14, %rdi
callq 0xc290
movq -0x38(%rbp), %rax
jmp 0x30133
movq -0x70(%rbp), %r15
leaq (%r12,%rax,4), %r12
addq %rax, %r13
andl $0x0, -0x64(%rbp)
movq %r15, %rsi
subq %r13, %rsi
movq %r12, %rdi
leaq -0x38(%rbp), %rdx
leaq -0x64(%rbp), %rcx
callq 0x30431
movq %r13, %rax
orq -0x80(%rbp), %rax
jne 0x30195
movq -0x58(%rbp), %rax
cmpq $0x1, -0x50(%rbp)
notb %al
sete %cl
andb %al, %cl
movq -0x38(%rbp), %rax
cmpq $0x2, %rax
setae %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x30199
movq -0x30(%rbp), %rdi
leaq 0xa101(%rip), %rsi      # 0x3a28b
callq 0xc290
movb $0x1, %al
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
testq %rax, %rax
je 0x2fe90
testq %r13, %r13
jne 0x301ca
testb $0x1, -0x48(%rbp)
jne 0x301ca
cmpl $0x2, %r15d
setae %cl
cmpq $0x1, %rax
setne %al
orb %cl, %al
movb $0x1, %bl
leaq 0xa0c5(%rip), %rsi      # 0x3a28b
jne 0x301dc
jmp 0x301eb
leaq 0x8145(%rip), %rsi      # 0x38316
movq -0x48(%rbp), %rax
movl %eax, %ebx
testq %r13, %r13
je 0x301eb
movq -0x30(%rbp), %rdi
callq 0xc290
movl %ebx, %eax
movq %rax, -0x48(%rbp)
movl (%r12), %eax
movl %eax, -0x74(%rbp)
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
leaq -0x74(%rbp), %rsi
callq 0xeb12
movq -0x38(%rbp), %rsi
movl -0x64(%rbp), %edx
movq %rbx, %rdi
callq 0x2fd08
movq -0x38(%rbp), %rax
leaq (%r12,%rax,4), %r12
addq %rax, %r13
jmp 0x2fe90
cmpq %r15, %rax
jb 0x3023a
cmpq $0x4, %rax
setb %cl
testb $0x3, %al
sete %al
orb %cl, %al
jne 0x2fef6
movb $0x1, %r15b
leaq 0xa047(%rip), %rsi      # 0x3a28b
testb $0x1, -0x48(%rbp)
je 0x2fee6
jmp 0x2fef6
testb $0x1, -0x48(%rbp)
je 0x30269
movq -0x30(%rbp), %rdi
leaq 0xa029(%rip), %rsi      # 0x3a28d
callq 0xc290
movq -0x50(%rbp), %rsi
movl -0x3c(%rbp), %edx
movq -0x30(%rbp), %rdi
callq 0x2fd08
movq -0x50(%rbp), %rax
movq -0x80(%rbp), %r13
addq %rax, %r13
decq %rax
imulq %r15, %rax
leaq (%r12,%rax,4), %r12
movq -0x88(%rbp), %rbx
jmp 0x2fde6
testb $0x1, -0x58(%rbp)
je 0x302b1
leaq 0x9fe5(%rip), %rsi      # 0x3a28d
movq -0x30(%rbp), %rdi
callq 0xc290
movq -0x30(%rbp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xdda6(%rip), %rdi      # 0x3e071
leaq 0xddc4(%rip), %rsi      # 0x3e096
leaq 0xdddd(%rip), %rcx      # 0x3e0b6
movl $0x81, %edx
callq 0xc180
nop