// File: shangjingbo1226[P]MACFP/src/methods/MACFP.cpp
// Function: dfs(int, int, int, int, int, int, int, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>>&)
void dfs(int l, int r, int firstPosition, int lastPosition, int firstChunkStart, int lastChunkEnd, int remainDistance, vector<PII> &supports)
{
    ULL key = firstChunkStart;
    key = key * MAGIC + lastChunkEnd;
    key = key * MAGIC + firstPosition;
    key = key * MAGIC + lastPosition;

    if (explored.count(key)) {
        return;
    }
    explored.insert(key);

    if (!checkByPrefixSum(l, r, firstChunkStart, lastChunkEnd, firstPosition, lastPosition, remainDistance)) {
        return;
    }

    counter ++;

    vector<int> left = expandLeft(l, firstChunkStart, firstPosition, remainDistance);
    int leftStart = remainDistance + 1, leftEnd = 0;
    for (int i = 0; i <= remainDistance; ++ i) {
        if (left[i] != -1) {
            leftStart = min(leftStart, i);
            leftEnd = i;
        }
    }
    if (leftStart > leftEnd) {
        return;
    }

    vector<int> right = expandRight(r, lastChunkEnd, lastPosition, remainDistance);
    int rightStart = remainDistance + 1, rightEnd = 0;
    for (int i = 0; i <= remainDistance; ++ i) {
        if (right[i] != -1) {
            rightStart = min(rightStart, i);
            rightEnd = i;
        }
    }
    if (rightStart > rightEnd) {
        return;
    }

    for (int leftK = leftStart; leftK <= leftEnd; ++ leftK) {
        if (left[leftK] == -1) {
            continue;
        }
        for (int rightK = rightStart; rightK <= rightEnd && rightK <= remainDistance - leftK; ++ rightK) {
            if (right[rightK] == -1) {
                continue;
            }
            if (max(l, left[leftK]) <= min(r, right[rightK])) {
                continue;
            }
            supports.push_back(make_pair(left[leftK], right[rightK]));
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movl %r8d, -0x14(%rbp)
movl %r9d, -0x18(%rbp)
movslq -0x14(%rbp), %rax
movq %rax, -0x20(%rbp)
imulq $0xabcdef, -0x20(%rbp), %rax # imm = 0xABCDEF
movslq -0x18(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
imulq $0xabcdef, -0x20(%rbp), %rax # imm = 0xABCDEF
movslq -0xc(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
imulq $0xabcdef, -0x20(%rbp), %rax # imm = 0xABCDEF
movslq -0x10(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
leaq 0x5f8147a(%rip), %rdi   # 0x5f874a8
leaq -0x20(%rbp), %rsi
callq 0x8f40
cmpq $0x0, %rax
je 0x6042
jmp 0x63c3
leaq 0x5f8145f(%rip), %rdi   # 0x5f874a8
leaq -0x20(%rbp), %rsi
callq 0x8f70
movq %rax, -0x30(%rbp)
movb %dl, -0x28(%rbp)
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0xc(%rbp), %r8d
movl -0x10(%rbp), %r9d
movl 0x10(%rbp), %eax
movl %eax, (%rsp)
callq 0x5cc0
testb $0x1, %al
jne 0x6081
jmp 0x63c3
movl 0x5f81419(%rip), %eax   # 0x5f874a0
addl $0x1, %eax
movl %eax, 0x5f81410(%rip)   # 0x5f874a0
movl -0x4(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0xc(%rbp), %ecx
movl 0x10(%rbp), %r8d
leaq -0x48(%rbp), %rdi
callq 0x47e0
movl 0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl 0x10(%rbp), %eax
jg 0x611f
movslq -0x54(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x8590
cmpl $-0x1, (%rax)
je 0x6112
leaq -0x4c(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x8b30
movq %rax, -0xa8(%rbp)
jmp 0x60ed
movq -0xa8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0x6112
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x63cc
jmp 0x6114
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x60bd
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jle 0x6133
movl $0x1, -0x68(%rbp)
jmp 0x63ba
movl -0x8(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x10(%rbp), %ecx
movl 0x10(%rbp), %r8d
leaq -0x80(%rbp), %rdi
callq 0x5210
jmp 0x614b
movl 0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
movl $0x0, -0x88(%rbp)
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl 0x10(%rbp), %eax
jg 0x61f4
movslq -0x8c(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x8590
cmpl $-0x1, (%rax)
je 0x61de
leaq -0x84(%rbp), %rdi
leaq -0x8c(%rbp), %rsi
callq 0x8b30
movq %rax, -0xb0(%rbp)
jmp 0x61a7
movq -0xb0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x84(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x88(%rbp)
jmp 0x61de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x8640
jmp 0x63cc
jmp 0x61e0
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x616b
movl -0x84(%rbp), %eax
cmpl -0x88(%rbp), %eax
jle 0x620e
movl $0x1, -0x68(%rbp)
jmp 0x63b1
movl -0x4c(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
cmpl -0x50(%rbp), %eax
jg 0x63aa
movslq -0x90(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x8590
cmpl $-0x1, (%rax)
jne 0x6240
jmp 0x6396
movl -0x84(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %ecx
xorl %eax, %eax
cmpl -0x88(%rbp), %ecx
movb %al, -0xb1(%rbp)
jg 0x627c
movl -0x94(%rbp), %eax
movl 0x10(%rbp), %ecx
subl -0x90(%rbp), %ecx
cmpl %ecx, %eax
setle %al
movb %al, -0xb1(%rbp)
movb -0xb1(%rbp), %al
testb $0x1, %al
jne 0x628b
jmp 0x6394
movslq -0x94(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x8590
cmpl $-0x1, (%rax)
jne 0x62a5
jmp 0x6380
movslq -0x90(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x8590
movq %rax, %rsi
leaq -0x4(%rbp), %rdi
callq 0x8be0
movq %rax, -0xc0(%rbp)
jmp 0x62ca
movq -0xc0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xcc(%rbp)
movslq -0x94(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x8590
movq %rax, %rsi
leaq -0x8(%rbp), %rdi
callq 0x8b30
movq %rax, -0xc8(%rbp)
jmp 0x62fe
movl -0xcc(%rbp), %eax
movq -0xc8(%rbp), %rcx
cmpl (%rcx), %eax
jg 0x6311
jmp 0x6380
movq 0x18(%rbp), %rax
movq %rax, -0xe8(%rbp)
movslq -0x90(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x8590
movq %rax, -0xe0(%rbp)
movslq -0x94(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x8590
movq -0xe0(%rbp), %rdi
movq %rax, %rsi
callq 0x8fe0
movq %rax, -0xd8(%rbp)
jmp 0x635b
movq -0xe8(%rbp), %rdi
movq -0xd8(%rbp), %rax
movq %rax, -0x9c(%rbp)
leaq -0x9c(%rbp), %rsi
callq 0x8fb0
jmp 0x637e
jmp 0x6380
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x624c
jmp 0x6396
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x6217
movl $0x0, -0x68(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x8640
leaq -0x48(%rbp), %rdi
callq 0x8640
addq $0xf0, %rsp
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x8640
movq -0x60(%rbp), %rdi
callq 0x3420
nop