// File: /workspace/github_cpp_makefile_star2_O3/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
callq 0x120d4
leaq 0x30(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x143f8
testb %al, %al
je 0x11d5c
xorl %r14d, %r14d
jmp 0x11f14
movq %r15, 0x70(%rsp)
leaq 0x150(%rsp), %rax
leaq 0x18(%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)
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 0x11dc1
movq $-0x30, %rcx
cmpb $0x1, 0x10(%rax,%rcx)
jne 0x11dec
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r14, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x14508
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
jmp 0x11e04
movq %r14, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
xorl %edx, %edx
movq %r14, %rsi
movq %rbx, %rdi
callq 0x5100
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x11e23
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5410
leaq 0x8(%rsp), %rdi
movq 0x88(%rsp), %rsi
leaq 0x50(%rsp), %rdx
movq 0x80(%rsp), %rcx
movq 0x78(%rsp), %r8
callq 0x14582
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x5100
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x11e75
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x68(%rsp), %rdx
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
subq %rax, %rcx
je 0x11e9a
movq (%rax), %r13
movq %r13, %r12
subq %rdx, %r12
cmpq $0x48, %rcx
je 0x11ea5
jmp 0x11eac
movq -0x48(%rax,%rcx), %r13
movq %r13, %r12
subq %rdx, %r12
addq %rcx, %rax
addq $-0x48, %rax
movb 0x10(%rax), %r15b
movq 0x8(%rax), %rbp
leaq 0xd8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
xorl %edx, %edx
callq 0x1219c
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x11ee5
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x5410
leaq 0x30(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x143f8
testb %al, %al
je 0x11d8e
subq %r13, %rbp
xorl %r14d, %r14d
testb %r15b, %r15b
cmovneq %rbp, %r14
addq %r12, %r14
movq 0x70(%rsp), %r15
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x11f2b
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 0x11f6f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x11f8c
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 0x12011
movq 0x40(%rsp), %rsi
incq %rsi
jmp 0x1200c
jmp 0x11fbe
movq %rax, %r15
jmp 0x12011
jmp 0x11ff7
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
jne 0x11fe8
jmp 0x11ffa
jmp 0x11ff7
movq %rax, %r15
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x11ffa
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5410
jmp 0x11ffa
movq %rax, %r15
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x12011
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x5410
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x1202e
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5410
movq (%rbx), %rdi
cmpq 0x28(%rsp), %rdi
je 0x12048
movq 0x28(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x5410
movq %r15, %rdi
callq 0x5720