// File: /workspace/github_cpp_makefile_star2_O2/jovermann[P]streplace/src/MiscUtils.hpp
// Function: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> ut1::regex_replace<Streplace::applyRule(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, Rule&)::'lambda'(std::__cxx11::match_results<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::sub_match<__gnu_cxx::__normal_iterator<char const*, 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&, std::__cxx11::basic_regex<char, std::__cxx11::regex_traits<char>> const&, Streplace::applyRule(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, Rule&)::'lambda'(std::__cxx11::match_results<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>> const&))
std::string regex_replace(const std::string& s, const std::regex& re, FormatMatch f)
{
    std::string r;

    size_t               endOfMatch = 0;
    std::sregex_iterator end;
    for (std::sregex_iterator it(s.begin(), s.end(), re); it != end; it++)
    {
        r.append(it->prefix());
        r.append(f(*it));
        endOfMatch = it->position(0) + it->length(0);
    }

    r.append(s.substr(endOfMatch));

    return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movq %rdx, %rcx
movq %rsi, %rdx
movb $0x0, 0x10(%rdi)
leaq 0x90(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movaps %xmm0, -0x20(%rax)
movups %xmm0, -0x14(%rax)
movq (%rsi), %rsi
movq %rdx, 0x8(%rsp)
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
xorl %r8d, %r8d
callq 0xdb96
leaq 0x30(%rsp), %r15
xorl %ebp, %ebp
leaq 0x10(%rsp), %r14
leaq 0x50(%rsp), %r13
movq %r14, %rdi
leaq 0x70(%rsp), %rsi
callq 0xdc2a
testb %al, %al
je 0xda70
movq 0x38(%rsp), %rsi
movq %rsi, %rax
subq 0x30(%rsp), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq $0x4, %rax
jb 0xd9ea
addq $-0x30, %rsi
jmp 0xd9ee
addq $-0x48, %rsi
movq %r13, %rdi
callq 0x100d6
movq %rbx, %rdi
movq %r13, %rsi
callq 0x5820
movq %r13, %rdi
callq 0x51f0
movq %r13, %rdi
leaq 0x130(%rsp), %rsi
movq %r15, %rdx
callq 0xdc34
movq %rbx, %rdi
movq %r13, %rsi
callq 0x5820
movq %r13, %rdi
callq 0x51f0
movq %r15, %rdi
xorl %esi, %esi
callq 0xdc50
movq %rax, %r12
movq %r15, %rdi
xorl %esi, %esi
callq 0xdc62
movq %rax, %rbp
leaq 0xb8(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xdc7e
addq %r12, %rbp
leaq 0xd8(%rsp), %rdi
callq 0xe20a
jmp 0xd9b4
movq %r15, %rdi
callq 0xe20a
leaq 0x10(%rsp), %rdi
pushq $-0x1
popq %rcx
movq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x5460
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x5820
leaq 0x10(%rsp), %rdi
callq 0x51f0
leaq 0x90(%rsp), %rdi
callq 0xe20a
movq %rbx, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x51f0
jmp 0xdafc
jmp 0xdad7
movq %rax, %r14
jmp 0xdafc
jmp 0xdaf1
jmp 0xdae0
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0x51f0
jmp 0xdaf4
jmp 0xdaf1
movq %rax, %r14
movq %r15, %rdi
callq 0xe20a
leaq 0x90(%rsp), %rdi
callq 0xe20a
movq %rbx, %rdi
callq 0x51f0
movq %r14, %rdi
callq 0x5730
nop