// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, 0x10(%rsp)
movq %r8, 0x8(%rsp)
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, (%rsp)
movq %rdi, %r13
movq 0x8(%rcx), %r12
subq (%rcx), %r12
xorl %r14d, %r14d
movq 0x10(%r13), %rax
cmpq 0x8(%r13), %rax
jb 0x16b5c
movq %r13, %rdi
xorl %esi, %esi
movq (%rsp), %rdx
callq 0xb210
movq 0x10(%r13), %rax
movl %r14d, %ebx
cmpb %bpl, (%rax)
je 0x16c64
leal 0x1(%r14), %eax
cmpq %rax, %r12
jae 0x16b87
leal 0xa(%r14), %eax
addq %rax, %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0xb980
movq 0x10(%r13), %rcx
addq $0x2, %rcx
movb $0x1, %al
cmpq 0x8(%r13), %rcx
jb 0x16ba9
movl $0x2, %esi
movl $0x400, %edx            # imm = 0x400
movq %r13, %rdi
callq 0xb190
movq 0x10(%r13), %rcx
notq %rcx
addq 0x8(%r13), %rcx
testb %al, %al
movl $0x2, %eax
cmovneq %rax, %rcx
movq %r13, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %r9
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
callq 0xb3d0
addq $0x90, %rsp
addl %eax, %r14d
jmp 0x16b44
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq