// File: /workspace/github_cpp_makefile_star2_O1/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), %r15d
movl 0x1c(%rsi), %r13d
movl %r15d, %eax
xorl %edx, %edx
divl %r13d
movl %eax, %ecx
imull %r13d, %ecx
cmpl %r15d, %ecx
jne 0x3fb72
cmpl %r15d, %r13d
ja 0x3fb40
movl %eax, %eax
movq %rax, -0x80(%rbp)
movq (%rsi), %rdi
movq $0x0, -0x40(%rbp)
xorl %r12d, %r12d
movq %r15, -0x88(%rbp)
movq %r13, -0x90(%rbp)
testq %r12, %r12
je 0x3f4c8
movl $0x2, %edx
movq %rdi, %rbx
movq -0x30(%rbp), %rdi
leaq 0x8f06(%rip), %rsi      # 0x483c6
callq 0xc320
movq %rbx, %rdi
movq %r12, %rsi
imulq %r13, %rsi
movq %r15, %rcx
subq %rsi, %rcx
movq %rcx, %rax
xorl %edx, %edx
divq %r13
testq %rdx, %rdx
jne 0x3fb53
xorl %eax, %eax
cmpq %rsi, %r15
setne %al
movq %rax, -0x50(%rbp)
movl $0x0, -0x34(%rbp)
cmpq %r13, %rcx
movq %r12, -0x68(%rbp)
jbe 0x3f591
leaq (%rdi,%r13,4), %rax
leaq (%rdi,%rcx,4), %rcx
movl $0x0, -0x34(%rbp)
xorl %esi, %esi
movq %rdi, %rdx
xorl %edi, %edi
movq %rdx, %r12
cmpq %rcx, %rax
jae 0x3f587
leaq (%rax,%r13,4), %r9
movb $0x1, %r8b
movl %esi, %r10d
movl (%rax), %r11d
leal 0x1(%r11), %ebx
cmpl $0x3, %ebx
jae 0x3f552
cmpl (%rdx), %r11d
jne 0x3f581
addq $0x4, %rdx
addq $0x4, %rax
cmpq %r9, %rax
setb %r8b
jb 0x3f52e
jmp 0x3f57d
movl (%rdx), %ebx
leal 0x1(%rbx), %r14d
cmpl $0x3, %r14d
jb 0x3f53a
subl %ebx, %r11d
testb $0x1, %dil
je 0x3f56e
cmpl %r10d, %r11d
je 0x3f53f
jmp 0x3f581
movl %r11d, %esi
movl %r11d, -0x34(%rbp)
movl %r11d, %r10d
movb $0x1, %dil
jmp 0x3f53f
incq -0x50(%rbp)
testb $0x1, %r8b
je 0x3f51f
sarl -0x34(%rbp)
movq %r12, %rdi
movq -0x68(%rbp), %r12
testq %r12, %r12
jne 0x3f5ca
testb $0x1, -0x40(%rbp)
jne 0x3f5ca
movq -0x50(%rbp), %rax
imulq %r13, %rax
cmpq %r15, %rax
jae 0x3f5ca
movl $0x1, %edx
movq %rdi, %rbx
movq -0x30(%rbp), %rdi
leaq 0xab11(%rip), %rsi      # 0x4a0cd
callq 0xc320
movq %rbx, %rdi
movb $0x1, %al
movq %rax, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %eax, %eax
cmpl $0x1, (%rdi,%rax,4)
ja 0x3f60c
sete %cl
movzbl %cl, %ecx
leaq (%rcx,%rbx,2), %rbx
leaq 0x1(%rax), %r12
cmpq $0x3e, %rax
ja 0x3f602
leaq (%rax,%r15), %rcx
incq %rcx
movq %r12, %rax
cmpq %r13, %rcx
jb 0x3f5d9
leaq (%r15,%r12), %rax
movq %rax, -0x60(%rbp)
jmp 0x3f617
leaq (%r15,%rax), %rcx
movq %rcx, -0x60(%rbp)
movq %rax, %r12
testq %r12, %r12
je 0x3f8ca
testq %r15, %r15
movq %rdi, -0x58(%rbp)
je 0x3f949
movl $0x2, %edx
movq -0x30(%rbp), %rdi
leaq 0x8d89(%rip), %rsi      # 0x483c6
callq 0xc320
subl %r15d, %r13d
andl $0x3, %r13d
cmpq $0x4, %r12
cmovbq %r12, %r13
testq %r13, %r13
je 0x3f72c
movq %r12, %rax
subq %r13, %rax
movl $0x0, %r15d
cmovaeq %rax, %r15
movq %rbx, %r14
movl %r15d, %ecx
shrq %cl, %r14
movl $0x2, %edx
movq -0x30(%rbp), %rdi
leaq 0xe969(%rip), %rsi      # 0x4dfec
callq 0xc320
cmpq $0x3, %r13
setae %al
cmpq $0x3, %r12
setae %cl
andb %al, %cl
testb $0x4, %r14b
leaq 0x1c91(%rip), %rsi      # 0x41334
leaq 0x3e54(%rip), %rax      # 0x434fe
cmoveq %rax, %rsi
testb %cl, %cl
leaq 0xe71d(%rip), %rax      # 0x4ddd4
cmoveq %rax, %rsi
movzbl %cl, %edx
movq -0x30(%rbp), %rdi
callq 0xc320
testb $0x2, %r14b
movq -0x30(%rbp), %r14
leaq 0x1c5e(%rip), %rsi      # 0x41334
leaq 0x3e21(%rip), %rax      # 0x434fe
cmoveq %rax, %rsi
xorl %edx, %edx
cmpq $0x1, %r13
setne %dl
leaq 0xe6e3(%rip), %rax      # 0x4ddd4
cmoveq %rax, %rsi
movq %r14, %rdi
callq 0xc320
btq %r15, %rbx
leaq 0x1c2c(%rip), %rsi      # 0x41334
leaq 0x3def(%rip), %rax      # 0x434fe
cmovaeq %rax, %rsi
movl $0x1, %edx
movq %r14, %rdi
callq 0xc320
movl %r13d, %ecx
subl %r12d, %ecx
shlq %cl, %rbx
shrq %cl, %rbx
movq -0x58(%rbp), %rdi
cmpq $0x4, %r12
jb 0x3f8b9
movq %r12, %r15
subq %r13, %r15
movl %r15d, %r14d
andl $0x3, %r14d
cmpq $0x4, %r15
movq %r14, -0x78(%rbp)
jb 0x3f800
testq %r13, %r13
je 0x3f76f
movl $0x2, %edx
movq -0x30(%rbp), %rdi
leaq 0x8c5c(%rip), %rsi      # 0x483c6
callq 0xc320
movl $0x2, %edx
movq -0x30(%rbp), %r14
movq %r14, %rdi
leaq 0xe86d(%rip), %rsi      # 0x4dfef
callq 0xc320
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %r13
cmpb $0x0, 0xe1(%r14,%rax)
jne 0x3f7b9
movq %r13, %rdi
movl $0x20, %esi
callq 0xc2a0
movb %al, 0xe0(%r13)
movb $0x1, 0xe1(%r13)
movb $0x30, 0xe0(%r13)
movq -0x30(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rcx
shrq $0x2, %r15
movslq %r15d, %rdx
movq %rdx, 0x10(%rdi,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rdi,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%rdi,%rax)
movq %rbx, %rsi
movq -0x78(%rbp), %r14
movl %r14d, %ecx
shrq %cl, %rsi
callq 0xc190
movq -0x58(%rbp), %rdi
testq %r14, %r14
je 0x3f8b9
cmpq %r14, %r12
jbe 0x3f823
movl $0x2, %edx
movq -0x30(%rbp), %rdi
leaq 0x8ba8(%rip), %rsi      # 0x483c6
callq 0xc320
movl $0x2, %edx
movq -0x30(%rbp), %r14
movq %r14, %rdi
leaq 0xe7b6(%rip), %rsi      # 0x4dfec
callq 0xc320
testb $0x4, %bl
leaq 0x1aef(%rip), %rsi      # 0x41334
leaq 0x3cb2(%rip), %r15      # 0x434fe
cmoveq %r15, %rsi
xorl %edx, %edx
movq -0x78(%rbp), %r13
cmpq $0x3, %r13
sete %dl
leaq 0xe570(%rip), %rax      # 0x4ddd4
cmovneq %rax, %rsi
movq %r14, %rdi
callq 0xc320
testb $0x2, %bl
leaq 0x1aba(%rip), %rsi      # 0x41334
cmoveq %r15, %rsi
xorl %edx, %edx
cmpq $0x1, %r13
setne %dl
leaq 0xe546(%rip), %rax      # 0x4ddd4
cmoveq %rax, %rsi
movq %r14, %rdi
callq 0xc320
testb $0x1, %bl
leaq 0x1a90(%rip), %rsi      # 0x41334
cmoveq %r15, %rsi
movl $0x1, %edx
movq %r14, %rdi
callq 0xc320
movq -0x58(%rbp), %rdi
leaq (%rdi,%r12,4), %rdi
movq -0x90(%rbp), %r13
movq -0x60(%rbp), %r8
jmp 0x3f8cd
movq %r15, %r8
movq %r13, %rax
subq %r8, %rax
je 0x3f8e7
movl (%rdi), %edx
xorl %r12d, %r12d
cmpl $0x2, %edx
jae 0x3f8f2
xorl %r15d, %r15d
jmp 0x3f9de
xorl %r15d, %r15d
xorl %r12d, %r12d
jmp 0x3f9de
movl $0x1, %r15d
cmpq $0x1, %rax
je 0x3f9de
cmpl $0x2, %edx
jb 0x3f9de
cmpl $-0x1, %edx
je 0x3f924
movl 0x4(%rdi), %ecx
leal 0x1(%rcx), %esi
cmpl $0x3, %esi
jae 0x3f98e
cmpl $-0x1, %edx
jne 0x3f9de
cmpl $-0x1, 0x4(%rdi)
jne 0x3f9de
cmpl $-0x1, (%rdi,%r15,4)
jne 0x3f9de
incq %r15
cmpq %r15, %rax
jne 0x3f92e
movq %rax, %r15
jmp 0x3f9de
cmpq %r13, %r12
jb 0x3f964
cmpq $0x4, %r12
setb %al
testb $0x3, %r12b
sete %cl
orb %al, %cl
jne 0x3f642
testb $0x1, -0x48(%rbp)
jne 0x3f642
movl $0x1, %edx
movq -0x30(%rbp), %rdi
leaq 0xa74f(%rip), %rsi      # 0x4a0cd
callq 0xc320
movb $0x1, %al
movq %rax, -0x48(%rbp)
jmp 0x3f642
subl %edx, %ecx
testb $0x1, %cl
jne 0x3f9d9
movl $0x2, %r15d
cmpq $0x3, %rax
jb 0x3f9c3
movl (%rdi,%r15,4), %edx
leal 0x1(%rdx), %esi
cmpl $0x3, %esi
jb 0x3f9c3
movl -0x4(%rdi,%r15,4), %esi
addl %ecx, %esi
cmpl %edx, %esi
jne 0x3f9c3
incq %r15
cmpq %r15, %rax
jne 0x3f9a1
movq %rax, %r15
cmpq $0x2, %r15
jne 0x3f9d9
cmpl $-0x2, %ecx
je 0x3f9d9
cmpl $0x2, %ecx
je 0x3f9d9
movl $0x1, %r15d
sarl %ecx
movl %ecx, %r12d
movq %r8, %rax
orq -0x68(%rbp), %rax
jne 0x3fa21
testb $0x1, -0x40(%rbp)
jne 0x3fa21
cmpq $0x1, -0x50(%rbp)
jne 0x3fa21
cmpq $0x2, %r15
jb 0x3fa21
movl $0x1, %edx
movq %r8, %r14
movq %rdi, %rbx
movq -0x30(%rbp), %rdi
leaq 0xa6bd(%rip), %rsi      # 0x4a0cd
callq 0xc320
movq %rbx, %rdi
movq %r14, %r8
movb $0x1, %al
movq %rax, -0x40(%rbp)
testq %r15, %r15
je 0x3fac5
cmpl $0x2, %r13d
setb %al
cmpq $0x1, %r15
sete %cl
testb %cl, %al
movq %r8, -0x60(%rbp)
jne 0x3fa71
testq %r8, %r8
jne 0x3fa71
testb $0x1, -0x48(%rbp)
jne 0x3fa71
movq %r12, %r14
movl $0x1, %edx
movq %rdi, %rbx
movq -0x30(%rbp), %rdi
leaq 0xa66c(%rip), %rsi      # 0x4a0cd
callq 0xc320
movq %rbx, %rdi
movb $0x1, %al
movq %rax, -0x48(%rbp)
jmp 0x3fa94
movq %r12, %r14
testq %r8, %r8
je 0x3fa94
movl $0x2, %edx
movq %rdi, %rbx
movq -0x30(%rbp), %rdi
leaq 0x893a(%rip), %rsi      # 0x483c6
callq 0xc320
movq %rbx, %rdi
movl (%rdi), %eax
movl %eax, -0x6c(%rbp)
movq %rdi, %rbx
movq -0x30(%rbp), %r12
movq %r12, %rdi
leaq -0x6c(%rbp), %rsi
callq 0x10712
movq %r12, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x3f3b0
leaq (%rbx,%r15,4), %rdi
movq -0x60(%rbp), %r8
addq %r15, %r8
movq %r8, %r15
cmpq %r13, %r8
jb 0x3f5d5
movq %rdi, %rbx
testb $0x1, -0x48(%rbp)
je 0x3faef
movl $0x1, %edx
movq -0x30(%rbp), %rdi
leaq 0xa5e5(%rip), %rsi      # 0x4a0cf
callq 0xc320
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %r15
movq %r15, %rsi
movl -0x34(%rbp), %edx
callq 0x3f3b0
movq -0x68(%rbp), %r12
addq %r15, %r12
decq %r15
imulq %r13, %r15
leaq (%rbx,%r15,4), %rdi
cmpq -0x80(%rbp), %r12
movq -0x88(%rbp), %r15
jb 0x3f4a8
testb $0x1, -0x40(%rbp)
je 0x3fb40
leaq 0xa59d(%rip), %rsi      # 0x4a0cf
movl $0x1, %edx
movq -0x30(%rbp), %rdi
callq 0xc320
movq -0x30(%rbp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe498(%rip), %rdi      # 0x4dff2
leaq 0xe425(%rip), %rsi      # 0x4df86
leaq 0xe4a1(%rip), %rcx      # 0x4e009
movl $0x43, %edx
callq 0xc180
leaq 0xe3e8(%rip), %rdi      # 0x4df61
leaq 0xe406(%rip), %rsi      # 0x4df86
leaq 0xe41f(%rip), %rcx      # 0x4dfa6
movl $0x81, %edx
callq 0xc180
nop