// File: night-shift[P]Srl/include/Srl/In.hpp
// Function: unsigned long Srl::Lib::In::read_substitue<char, std::array<char const, 2ul>, char, std::array<char const, 2ul>, char, std::array<char const, 2ul>, char, std::array<char const, 2ul>, char, std::array<char const, 2ul>, char, std::array<char const, 2ul>, char, std::array<char const, 2ul>, char, std::array<char const, 2ul>, char, std::array<char const, 2ul>, std::function<unsigned long (Srl::Lib::In&, std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long)>, std::array<char const, 2ul>>(std::function<void ()> const&, unsigned char, std::vector<unsigned char, std::allocator<unsigned char>>&, char const&, std::array<char const, 2ul> const&, char const&, std::array<char const, 2ul> const&, char const&, std::array<char const, 2ul> const&, char const&, std::array<char const, 2ul> const&, char const&, std::array<char const, 2ul> const&, char const&, std::array<char const, 2ul> const&, char const&, std::array<char const, 2ul> const&, char const&, std::array<char const, 2ul> const&, char const&, std::array<char const, 2ul> const&, std::function<unsigned long (Srl::Lib::In&, std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long)> const&, std::array<char const, 2ul> const&)
size_t In::read_substitue(const Error& error, uint8_t delimiter,
                              std::vector<uint8_t>& buf, const Tokens&... tokens)
    {
        const size_t max = Aux::max_len<Tokens...>();

        auto steps = 0U;
        auto bufsz = buf.size();

        while(*this->peek(0, error) != delimiter) {

            if(steps + 1 > bufsz) {
                bufsz += steps + 10;
                buf.resize(bufsz);
            }

            auto left = this->try_peek(max) ? max : this->end - this->pos - 1;
            steps += this->substitute_token(buf, steps, left, tokens...);
        }

        return steps;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movb %dl, %al
movq 0x98(%rbp), %rdx
movq 0x90(%rbp), %rdx
movq 0x88(%rbp), %rdx
movq 0x80(%rbp), %rdx
movq 0x78(%rbp), %rdx
movq 0x70(%rbp), %rdx
movq 0x68(%rbp), %rdx
movq 0x60(%rbp), %rdx
movq 0x58(%rbp), %rdx
movq 0x50(%rbp), %rdx
movq 0x48(%rbp), %rdx
movq 0x40(%rbp), %rdx
movq 0x38(%rbp), %rdx
movq 0x30(%rbp), %rdx
movq 0x28(%rbp), %rdx
movq 0x20(%rbp), %rdx
movq 0x18(%rbp), %rdx
movq 0x10(%rbp), %rdx
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movb %al, -0x39(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movq %r9, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x80(%rbp)
movq $0x2, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movq -0x48(%rbp), %rdi
callq 0x37840
movq %rax, -0x70(%rbp)
movq -0x80(%rbp), %rdi
movq -0x38(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x36850
movzbl (%rax), %eax
movzbl -0x39(%rbp), %ecx
cmpl %ecx, %eax
je 0x55065
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
cmpq -0x70(%rbp), %rax
jbe 0x54eb0
movl -0x64(%rbp), %eax
addl $0xa, %eax
movl %eax, %eax
addq -0x70(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x35f00
movq -0x80(%rbp), %rdi
movl $0x2, %esi
callq 0x33830
testb $0x1, %al
jne 0x54ec4
jmp 0x54ed2
movl $0x2, %eax
movq %rax, -0x88(%rbp)
jmp 0x54eec
movq -0x80(%rbp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
subq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rsi
movl -0x64(%rbp), %eax
movl %eax, %edx
movq -0x78(%rbp), %rcx
movq -0x50(%rbp), %r8
movq -0x58(%rbp), %r9
movq 0x10(%rbp), %rax
movq 0x18(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
movq 0x20(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
movq 0x28(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
movq 0x30(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
movq 0x38(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
movq 0x40(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
movq 0x48(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
movq 0x50(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
movq 0x58(%rbp), %rdi
movq %rdi, -0x98(%rbp)
movq 0x60(%rbp), %r13
movq 0x68(%rbp), %r12
movq 0x70(%rbp), %r15
movq 0x78(%rbp), %r14
movq 0x80(%rbp), %rbx
movq 0x88(%rbp), %r11
movq 0x90(%rbp), %r10
movq 0x98(%rbp), %rdi
movq %rdi, -0x90(%rbp)
movq -0x80(%rbp), %rdi
movq %rax, (%rsp)
movq -0xd8(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0xd0(%rbp), %rax
movq %rax, 0x10(%rsp)
movq -0xc8(%rbp), %rax
movq %rax, 0x18(%rsp)
movq -0xc0(%rbp), %rax
movq %rax, 0x20(%rsp)
movq -0xb8(%rbp), %rax
movq %rax, 0x28(%rsp)
movq -0xb0(%rbp), %rax
movq %rax, 0x30(%rsp)
movq -0xa8(%rbp), %rax
movq %rax, 0x38(%rsp)
movq -0xa0(%rbp), %rax
movq %rax, 0x40(%rsp)
movq -0x98(%rbp), %rax
movq %rax, 0x48(%rsp)
movq -0x90(%rbp), %rax
movq %r13, 0x50(%rsp)
movq %r12, 0x58(%rsp)
movq %r15, 0x60(%rsp)
movq %r14, 0x68(%rsp)
movq %rbx, 0x70(%rsp)
movq %r11, 0x78(%rsp)
movq %r10, 0x80(%rsp)
movq %rax, 0x88(%rsp)
callq 0x341b0
movq %rax, %rcx
movl -0x64(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x64(%rbp)
jmp 0x54e65
movl -0x64(%rbp), %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw (%rax,%rax)