// File: /workspace/github_cpp_makefile_star2_O2/vsklad[P]cgen/./bal/variables/variablesio.cpp
// Function: bal::get_variables_range_sequence_(unsigned int const*, unsigned long, unsigned long, unsigned long&, int&)
inline void get_variables_range_sequence_(const literalid_t* const data, const size_t size,
                                                    const size_t range_size,
                                                    size_t& sequence_size, int& sequence_step) {
        assert(size % range_size == 0); // data size is a multiple of range_size
        
        sequence_size = size > 0 ? 1 : 0;
        sequence_step = 0;
        
        if (size > range_size) {
            // assume the step from the first pair of variables from the first and second ranges
            // stop when this step is not the same at any point
            // non-zero step is only applicable to variables; it is zero for everything else
            bool b_first_variable_found = false;
            const literalid_t* p_prev = data;
            const literalid_t* p_curr = p_prev + range_size;
            
            while (p_curr < data + size) {
                bool b_sequence_step_ok = true;
                const literalid_t* p_next = p_curr + range_size;
                
                while(p_curr < p_next) {
                    if (literal_t__is_variable(*p_curr) && literal_t__is_variable(*p_prev)) {
                        if (!b_first_variable_found) {
                            sequence_step = *p_curr - *p_prev;
                            b_first_variable_found = true;
                        } else if (*p_curr - *p_prev != sequence_step) {
                            b_sequence_step_ok = false;
                            break;
                        };
                    } else if (*p_curr != *p_prev) {
                        b_sequence_step_ok = false;
                        break;
                    };
                    p_prev++;
                    p_curr++;
                };
                
                if (!b_sequence_step_ok) {
                    break;
                };
                
                sequence_size++;
                p_next += range_size;
            };
            
            // 2 between literals, 1 between variables
            sequence_step >>= 1;
        };
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r9
movq %rsi, %rax
xorl %edx, %edx
divq %r9
testq %rdx, %rdx
jne 0x30414
xorl %eax, %eax
testq %rsi, %rsi
setne %al
movq %rax, (%rcx)
andl $0x0, (%r8)
cmpq %r9, %rsi
jbe 0x30405
leaq (%rdi,%r9,4), %r10
leaq (%rdi,%rsi,4), %rsi
xorl %edx, %edx
xorl %r11d, %r11d
cmpq %rsi, %r10
jae 0x30400
leaq (%r10,%r9,4), %rbx
movl %edx, %r14d
cmpq %rbx, %r10
jae 0x303f8
movl (%r10), %r15d
leal 0x1(%r15), %r12d
cmpl $0x3, %r12d
jae 0x303c9
cmpl (%rdi), %r15d
jne 0x30400
addq $0x4, %rdi
addq $0x4, %r10
jmp 0x303a8
movl (%rdi), %r12d
leal 0x1(%r12), %r13d
cmpl $0x3, %r13d
jb 0x303ba
subl %r12d, %r15d
testb $0x1, %r11b
je 0x303ea
movb $0x1, %r11b
cmpl %r14d, %r15d
je 0x303bf
jmp 0x30400
movl %r15d, (%r8)
movb $0x1, %r11b
movl %r15d, %edx
movl %r15d, %r14d
jmp 0x303bf
incq %rax
movq %rax, (%rcx)
jmp 0x3039c
sarl %edx
movl %edx, (%r8)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xdce7(%rip), %rdi      # 0x3e102
leaq 0xdc74(%rip), %rsi      # 0x3e096
leaq 0xdcf0(%rip), %rcx      # 0x3e119
pushq $0x43
popq %rdx
callq 0xc180