// File: 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
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x180(%rbp)
movq %rdi, %rax
movq %rax, -0x178(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x170(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
callq 0x7860
movq $0x0, -0x28(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x1d0e0
jmp 0x1cd5f
movq -0x10(%rbp), %rdi
callq 0x75a0
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7aa0
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rcx
movq -0xc0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
xorl %r8d, %r8d
callq 0x1d130
jmp 0x1cda2
jmp 0x1cda4
leaq -0xb8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x1d260
testb $0x1, %al
jne 0x1cdeb
leaq -0xb8(%rbp), %rdi
callq 0x1d480
jmp 0x1cf50
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x1cfe2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x1cfbb
leaq -0xb8(%rbp), %rdi
callq 0x1d290
movq %rax, %rdi
callq 0x1d2b0
movq %rax, -0x188(%rbp)
jmp 0x1ce08
movq -0x188(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0x1d300
jmp 0x1ce1d
movq -0x180(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x7b30
jmp 0x1ce32
leaq -0xe8(%rbp), %rdi
callq 0x73c0
leaq -0xb8(%rbp), %rdi
callq 0x1d370
movq -0x170(%rbp), %rsi
movq %rax, %rdx
leaq -0x108(%rbp), %rdi
callq 0x1d330
jmp 0x1ce62
movq -0x180(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x7b30
jmp 0x1ce77
leaq -0x108(%rbp), %rdi
callq 0x73c0
leaq -0xb8(%rbp), %rdi
callq 0x1d290
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1d390
movq %rax, -0x190(%rbp)
jmp 0x1cea4
leaq -0xb8(%rbp), %rdi
callq 0x1d290
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1d3d0
movq %rax, -0x198(%rbp)
jmp 0x1cec5
movq -0x198(%rbp), %rcx
movq -0x190(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq -0x148(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
xorl %edx, %edx
callq 0x1d400
jmp 0x1cef1
leaq -0x148(%rbp), %rdi
callq 0x1d480
jmp 0x1cda4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x1cf42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x73c0
jmp 0x1cf42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x73c0
leaq -0xb8(%rbp), %rdi
callq 0x1d480
jmp 0x1cfbb
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x168(%rbp), %rdi
movq $-0x1, %rcx
callq 0x7630
jmp 0x1cf6d
movq -0x180(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x7b30
jmp 0x1cf82
leaq -0x168(%rbp), %rdi
callq 0x73c0
movb $0x1, -0x19(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x1d480
testb $0x1, -0x19(%rbp)
jne 0x1cfd2
jmp 0x1cfc6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x73c0
leaq -0x68(%rbp), %rdi
callq 0x1d480
jmp 0x1cfe2
movq -0x180(%rbp), %rdi
callq 0x73c0
movq -0x178(%rbp), %rax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x180(%rbp), %rdi
callq 0x73c0
movq -0x70(%rbp), %rdi
callq 0x7a30
nopw (%rax,%rax)