// File: vsklad[P]cgen/./bal/variables/variablesio.cpp
// Function: bal::get_variables_sequence_(unsigned int const*, unsigned long, unsigned long&, int&)
inline void get_variables_sequence_(const literalid_t* const data, const size_t size,
                                              size_t& sequence_size, int& sequence_step) {
        sequence_size = 0;
        sequence_step = 0;
        
        if (size > 0 && !literal_t__is_constant(data[0])) {
            sequence_size = 1;
            if (size > 1) {
                if (literal_t__is_variable(data[0]) && literal_t__is_variable(data[1])) {
                    // determine direction
                    sequence_step = data[sequence_size] - data[sequence_size-1];
                    // difference 1 means opposit negation, i.e. no sequence
                    if ((sequence_step & 0x1) == 0) {
                        // determine length, already have 2
                        sequence_size = 2;
                        while (sequence_size < size) {
                            if (literal_t__is_variable(data[sequence_size])) {
                                if (data[sequence_size - 1] + sequence_step == data[sequence_size]) {
                                    sequence_size++;
                                    continue;
                                };
                            };
                            break;
                        };
                        // two variables with step > 1 (2) is not a sequence
                        if (sequence_size == 2 && sequence_step != 2 && sequence_step != -2) {
                            sequence_size = 1;
                        };
                    };
                    // 2 between literals, 1 between variables
                    sequence_step >>= 1;
                } else if (literal_t__is_unassigned(data[0]) && literal_t__is_unassigned(data[1])) {
                    // simply count the unassigned literals
                    while (sequence_size < size && literal_t__is_unassigned(data[sequence_size])) {
                        sequence_size++;
                    };
                };
            };
        };
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
cmpq $0x0, -0x10(%rbp)
jbe 0x59c69
movq -0x8(%rbp), %rax
cmpl $0x1, (%rax)
jbe 0x59c69
movq -0x18(%rbp), %rax
movq $0x1, (%rax)
cmpq $0x1, -0x10(%rbp)
jbe 0x59c67
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpl $0x1, (%rcx)
movb %al, -0x21(%rbp)
jbe 0x59ae2
movq -0x8(%rbp), %rax
cmpl $-0x2, (%rax)
setbe %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
testb $0x1, %al
jne 0x59aee
jmp 0x59c0c
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpl $0x1, 0x4(%rcx)
movb %al, -0x22(%rbp)
jbe 0x59b0b
movq -0x8(%rbp), %rax
cmpl $-0x2, 0x4(%rax)
setbe %al
movb %al, -0x22(%rbp)
movb -0x22(%rbp), %al
testb $0x1, %al
jne 0x59b17
jmp 0x59c0c
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rdx
movq (%rdx), %rdx
subq $0x1, %rdx
subl (%rax,%rdx,4), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x59c00
movq -0x18(%rbp), %rax
movq $0x2, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
jae 0x59bd7
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rdx
xorl %eax, %eax
cmpl $0x1, (%rcx,%rdx,4)
movb %al, -0x23(%rbp)
jbe 0x59b92
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
cmpl $-0x2, (%rax,%rcx,4)
setbe %al
movb %al, -0x23(%rbp)
movb -0x23(%rbp), %al
testb $0x1, %al
jne 0x59b9b
jmp 0x59bd5
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
movl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
addl (%rcx), %eax
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rdx
movq (%rdx), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0x59bd3
movq -0x18(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0x59b5a
jmp 0x59bd5
jmp 0x59bd7
movq -0x18(%rbp), %rax
cmpq $0x2, (%rax)
jne 0x59bfe
movq -0x20(%rbp), %rax
cmpl $0x2, (%rax)
je 0x59bfe
movq -0x20(%rbp), %rax
cmpl $-0x2, (%rax)
je 0x59bfe
movq -0x18(%rbp), %rax
movq $0x1, (%rax)
jmp 0x59c00
movq -0x20(%rbp), %rax
movl (%rax), %ecx
sarl %ecx
movl %ecx, (%rax)
jmp 0x59c65
movq -0x8(%rbp), %rax
cmpl $-0x1, (%rax)
jne 0x59c63
movq -0x8(%rbp), %rax
cmpl $-0x1, 0x4(%rax)
jne 0x59c63
jmp 0x59c21
movq -0x18(%rbp), %rax
movq (%rax), %rcx
xorl %eax, %eax
cmpq -0x10(%rbp), %rcx
movb %al, -0x24(%rbp)
jae 0x59c48
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
cmpl $-0x1, (%rax,%rcx,4)
sete %al
movb %al, -0x24(%rbp)
movb -0x24(%rbp), %al
testb $0x1, %al
jne 0x59c51
jmp 0x59c61
movq -0x18(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0x59c21
jmp 0x59c63
jmp 0x59c65
jmp 0x59c67
jmp 0x59c69
popq %rbp
retq
nopl (%rax,%rax)