// File: /workspace/github_cpp_makefile_star2_O1/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 $0x118, %rsp            # imm = 0x118
movq %rdx, %rcx
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, 0x28(%rsp)
movq %rax, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0x90(%rsp)
movups %xmm0, 0x9c(%rsp)
movq (%rsi), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
xorl %r8d, %r8d
movq %rbx, 0x20(%rsp)
callq 0x120d8
leaq 0x30(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x143e8
testb %al, %al
je 0x11d7d
xorl %r14d, %r14d
jmp 0x11f26
movq %r15, 0x70(%rsp)
leaq 0x150(%rsp), %rax
leaq 0x10(%rsp), %r14
movq (%rax), %rcx
movq %rcx, 0x88(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x80(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x78(%rsp)
leaq 0x30(%rsp), %r15
movq 0x58(%rsp), %rax
movq %rax, %rdx
subq 0x50(%rsp), %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
movq $-0x48, %rcx
cmpq $0x4, %rdx
jb 0x11de7
movq $-0x30, %rcx
cmpb $0x1, 0x10(%rax,%rcx)
movq 0x20(%rsp), %rbx
jne 0x11e0a
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r14, (%rsp)
movq %rsp, %rdi
callq 0x14500
jmp 0x11e1c
movq %r14, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x5100
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x11e43
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5410
movq %rsp, %rdi
movq 0x88(%rsp), %rsi
leaq 0x50(%rsp), %rdx
movq 0x80(%rsp), %rcx
movq 0x78(%rsp), %r8
callq 0x14574
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x5100
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x11e8c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
leaq -0x48(%rcx), %rsi
cmpq $0x48, %rdx
movq %rax, %rdx
cmoveq %rsi, %rdx
cmpq %rax, %rcx
cmoveq %rsi, %rdx
movq 0x68(%rsp), %r13
movq (%rdx), %rbx
movq 0x8(%rdx), %r12
movb 0x10(%rdx), %bpl
leaq 0xd8(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x121a0
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x11ef1
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x5410
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
callq 0x143e8
testb %al, %al
je 0x11db4
subq %rbx, %r12
subq %r13, %rbx
xorl %r14d, %r14d
testb %bpl, %bpl
cmovneq %r12, %r14
addq %rbx, %r14
movq 0x20(%rsp), %rbx
movq 0x70(%rsp), %r15
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x11f3d
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x5410
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq $-0x1, %rcx
callq 0x5450
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %rbx, %rdi
callq 0x5100
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11f81
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x11f9e
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5410
movq %rbx, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x12010
movq 0x40(%rsp), %rsi
incq %rsi
jmp 0x1200b
jmp 0x11fd0
movq %rax, %r15
jmp 0x12010
jmp 0x11ff6
jmp 0x11fdb
jmp 0x11ff6
movq %rax, %r15
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x11ff9
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5410
jmp 0x11ff9
movq %rax, %r15
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x12010
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x5410
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x1202d
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5410
movq 0x20(%rsp), %rax
movq (%rax), %rdi
cmpq 0x28(%rsp), %rdi
je 0x1204c
movq 0x28(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x5410
movq %r15, %rdi
callq 0x5720