// File: /workspace/github_cpp_makefile_star2_O1/WayfireWM[P]wf-utils/wayfire/lexer/lexer.cpp
// Function: wf::lexer_t::_parse_encapsulated_literal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
variant_t lexer_t::_parse_encapsulated_literal(const std::string &s_bound, const std::string &e_bound)
{
    // Check if the boundary is at the end of the of the line.
    auto begin = _parse_position + s_bound.size();
    if (begin >= _size)
    {
        _parse_position = _size;
        throw std::runtime_error("Lexical parser error. Encapsulated literal is truncated.");
    }

    // Find the next occurrence of the boundary. Avoid escaped ones (\boundary).
    std::size_t found_at = 0;
    auto found = false;
    while (!found)
    {
        auto p = _text.find(e_bound, begin);
        if (p == std::string::npos)
        {
            // Not found before end of line, complain and bail out.
            _parse_position = _size;
            throw std::runtime_error("Lexical parser error. Encapsulated literal is truncated.");
        }

        // check the character before the boundary match to see if it is not an escape.
        if (_text.at(p - 1) != '\\')
        {
            found = true;
            found_at = p;
            break;
        }
    }

    // If we get here, and found == false, it must mean that all the matches were escaped -> trunctated.
    if (!found)
    {
        _parse_position = _size;
        throw std::runtime_error("Lexical parser error. Encapsulated literal is truncated.");
    }

    // Found a good match. The string we want is between _parse_position and (found_at + boundary_length)
    auto length = (found_at + e_bound.size()) - _parse_position;
    auto literal_text = _text.substr(_parse_position, length);
    _parse_position += length;
    return parse_literal(literal_text);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, (%rsp)
movq 0x8(%rdx), %rbp
addq 0x28(%rsi), %rbp
movq (%rsi), %rax
cmpq %rax, %rbp
jae 0x79d9
movq %rcx, %r15
leaq 0x8(%r14), %r13
xorl %r12d, %r12d
xorl %ebx, %ebx
testb $0x1, %bl
jne 0x792b
movq (%r15), %rsi
movq 0x8(%r15), %rcx
movq %r13, %rdi
movq %rbp, %rdx
callq 0x5380
cmpq $-0x1, %rax
je 0x79a0
leaq -0x1(%rax), %rsi
movq 0x10(%r14), %rdx
cmpq %rsi, %rdx
jbe 0x7992
movq (%r13), %rcx
cmpb $0x5c, -0x1(%rcx,%rax)
cmovneq %rax, %r12
movzbl %bl, %ebx
movl $0x1, %eax
cmovnel %eax, %ebx
je 0x78df
testb $0x1, %bl
je 0x79fb
addq 0x8(%r15), %r12
movq 0x28(%r14), %rdx
subq %rdx, %r12
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rcx
callq 0x5250
addq %r12, 0x28(%r14)
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8123
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7980
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5230
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58d1(%rip), %rdi      # 0xd26a
xorl %eax, %eax
callq 0x5300
movq (%r14), %rax
movq %rax, 0x28(%r14)
movl $0x10, %edi
callq 0x5110
movq %rax, %r14
leaq 0x582c(%rip), %rsi      # 0xd1e7
movq %rax, %rdi
callq 0x50d0
movq 0xc626(%rip), %rsi      # 0x13ff0
movq 0xc5e7(%rip), %rdx      # 0x13fb8
movq %r14, %rdi
callq 0x5370
movq %rax, 0x28(%r14)
movl $0x10, %edi
callq 0x5110
movq %rax, %r14
leaq 0x57f6(%rip), %rsi      # 0xd1e7
movq %rax, %rdi
callq 0x50d0
jmp 0x79c3
movq (%r14), %rax
movq %rax, 0x28(%r14)
movl $0x10, %edi
callq 0x5110
movq %rax, %r14
leaq 0x57d1(%rip), %rsi      # 0xd1e7
movq %rax, %rdi
callq 0x50d0
jmp 0x79c3
jmp 0x7a44
jmp 0x7a44
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7a4f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0x7a4f
movq %rax, %rbx
movq %r14, %rdi
callq 0x51a0
movq %rbx, %rdi
callq 0x5390