// File: /workspace/github_cpp_makefile_star2_O2/Nallantli[P]Rossa/main/rossa/util/util.cpp
// Function: util::format(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&)
const std::string util::format(const std::string &fmt, const std::vector<std::string> &args)
{
    std::string in(fmt), out;        // unformatted and formatted strings
    std::regex re_arg("\\{\\d+\\}"); // search for {0}, {1}, ...
    std::regex re_idx("\\d+");       // search for 0, 1, ...
    std::smatch m_arg, m_idx;        // store matches
    size_t idx = 0;                  // index of argument inside {...}

    // Replace all {x} with vbuf[x]
    while (std::regex_search(in, m_arg, re_arg))
    {
        out += m_arg.prefix();
        auto text = m_arg[0].str();
        if (std::regex_search(text, m_idx, re_idx))
        {
            idx = std::stoi(m_idx[0].str());
        }
        if (idx < args.size())
        {
            out += std::regex_replace(text, re_arg, args[idx]);
        }
        in = m_arg.suffix();
    }
    out += in;
    return out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdx, %r14
movq %rdi, %rbp
leaq 0x68(%rsp), %rdi
callq 0x10550
leaq 0x10(%rbp), %rax
movq %rax, (%rbp)
andq $0x0, 0x8(%rbp)
movb $0x0, 0x10(%rbp)
leaq 0x3835b(%rip), %rsi     # 0x77ab8
leaq 0x48(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x3fa8a
leaq 0x3834f(%rip), %rsi     # 0x77ac0
leaq 0x88(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x3fa8a
xorps %xmm0, %xmm0
movq %rsp, %rax
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
leaq 0x20(%rsp), %rax
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
xorl %ebx, %ebx
leaq 0x68(%rsp), %r13
leaq 0xc8(%rsp), %r12
leaq 0xa8(%rsp), %r15
movq %r13, %rdi
movq %rsp, %rsi
leaq 0x48(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3faf0
testb %al, %al
je 0x3f927
movq 0x8(%rsp), %rsi
movq %rsi, %rax
subq (%rsp), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq $0x4, %rax
jb 0x3f7eb
addq $-0x30, %rsi
jmp 0x3f7ef
addq $-0x48, %rsi
movq %r12, %rdi
callq 0x3fb42
movq %rbp, %rdi
movq %r12, %rsi
callq 0x10790
movq %r12, %rdi
callq 0x101d0
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
leaq -0x48(%rcx), %rdi
cmpq $0x48, %rdx
movq %rax, %rsi
cmoveq %rdi, %rsi
cmpq %rax, %rcx
cmoveq %rdi, %rsi
movq %r12, %rdi
callq 0x3fb42
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x88(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3faf0
testb %al, %al
je 0x3f898
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
leaq -0x48(%rcx), %rdi
cmpq $0x48, %rdx
movq %rax, %rsi
cmoveq %rdi, %rsi
cmpq %rax, %rcx
cmoveq %rdi, %rsi
movq %r15, %rdi
callq 0x3fb42
movq %r15, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x3fb7c
movslq %eax, %rbx
movq %r15, %rdi
callq 0x101d0
movq (%r14), %rcx
movq 0x8(%r14), %rax
subq %rcx, %rax
sarq $0x5, %rax
cmpq %rax, %rbx
jae 0x3f8db
movq %rbx, %rax
shlq $0x5, %rax
addq %rax, %rcx
movq %r15, %rdi
movq %r12, %rsi
leaq 0x48(%rsp), %rdx
xorl %r8d, %r8d
callq 0x3fb98
movq %rbp, %rdi
movq %r15, %rsi
callq 0x10790
movq %r15, %rdi
callq 0x101d0
movq 0x8(%rsp), %rsi
movq %rsi, %rax
subq (%rsp), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq $0x4, %rax
jb 0x3f8fb
addq $-0x18, %rsi
jmp 0x3f8ff
addq $-0x48, %rsi
movq %r15, %rdi
callq 0x3fb42
movq %r13, %rdi
movq %r15, %rsi
callq 0x104e0
movq %r15, %rdi
callq 0x101d0
movq %r12, %rdi
callq 0x101d0
jmp 0x3f7b1
leaq 0x68(%rsp), %rsi
movq %rbp, %rdi
callq 0x10790
leaq 0x20(%rsp), %rdi
callq 0x3fcc4
movq %rsp, %rdi
callq 0x3fcc4
leaq 0x88(%rsp), %rdi
callq 0x3fbe8
leaq 0x48(%rsp), %rdi
callq 0x3fbe8
leaq 0x68(%rsp), %rdi
callq 0x101d0
movq %rbp, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3f9ba
movq %rax, %r14
jmp 0x3f9dc
movq %rax, %r14
jmp 0x3f9e6
jmp 0x3f9a6
jmp 0x3f9a6
jmp 0x3f98e
movq %rax, %r14
leaq 0xa8(%rsp), %rdi
callq 0x101d0
jmp 0x3f9a9
jmp 0x3f9ba
jmp 0x3f9a6
jmp 0x3f9a6
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
callq 0x101d0
jmp 0x3f9bd
jmp 0x3f9ba
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x3fcc4
movq %rsp, %rdi
callq 0x3fcc4
leaq 0x88(%rsp), %rdi
callq 0x3fbe8
leaq 0x48(%rsp), %rdi
callq 0x3fbe8
movq %rbp, %rdi
callq 0x101d0
leaq 0x68(%rsp), %rdi
callq 0x101d0
movq %r14, %rdi
callq 0x106f0