// File: /workspace/github_cpp_makefile_star2_O1/gasparfm[P]anapache/lib/gcommon/gstr.cpp
// Function: GCommon::replace(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<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>>>>>, int, int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::string replace(std::string source, std::map<std::string,std::string>strMap, int offset, int times, bool delimiters, std::string before, std::string after)
  {
    int total = 0;
    std::string::size_type pos=offset;
    std::string::size_type newPos;
    std::string::size_type lowerPos;
    std::string::size_type delsize;

    if (strMap.size() == 0)
      return source;

    if (delimiters)
      delsize = before.length() + after.length();

    do
      {
	std::string rep;
	for (auto i=strMap.begin(); i!=strMap.end(); ++i)
	  {
	    auto fromStr = i->first;
	    newPos = (delimiters)?
	      source.find(before + fromStr + after, pos):
	      source.find(fromStr, pos);

	    if ( (i==strMap.begin()) || (newPos<lowerPos) )
	      {
		rep = fromStr;
		lowerPos = newPos;
	      }
	  }

	pos = lowerPos;
	if (pos == std::string::npos)
	  break;

	std::string toStr = strMap[rep];
	source.replace(pos, rep.length()+((delimiters)?delsize:0), toStr);
	pos+=toStr.size();

      } while ( (times==0) || (++total<times) );

    return source;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %r8d, 0x4(%rsp)
movq %rdx, 0x8(%rsp)
cmpq $0x0, 0x28(%rdx)
je 0x932b
movl %r9d, %ebp
movq 0x108(%rsp), %rax
movq 0x100(%rsp), %rdx
movq $0x0, 0x68(%rsp)
testb %bpl, %bpl
movq %rdi, 0x80(%rsp)
movq %rsi, 0x30(%rsp)
je 0x9337
movq 0x8(%rax), %rax
addq 0x8(%rdx), %rax
movq %rax, 0x70(%rsp)
jmp 0x9340
leaq 0x10(%rdi), %rcx
movq %rcx, (%rdi)
jmp 0x95e3
movq $0x0, 0x70(%rsp)
movslq %ecx, %rax
movq %rax, 0x38(%rsp)
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
leaq 0x98(%rsp), %r13
movl 0x4(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movl %ecx, 0x44(%rsp)
leaq 0x10(%rsp), %r15
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movq $0x0, 0x50(%rsp)
movb $0x0, 0x58(%rsp)
movq 0x8(%rsp), %rax
movq 0x18(%rax), %r14
cmpq 0x78(%rsp), %r14
je 0x9506
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x7998
movq %r15, %rax
testb %bpl, %bpl
je 0x9454
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
movq 0x100(%rsp), %rsi
movq %r15, %rdx
callq 0x9b73
movq 0x108(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %rbx, %rdi
callq 0x3120
movq %r13, 0x88(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x9429
movq %rdx, 0x88(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x98(%rsp)
jmp 0x9431
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x90(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x88(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rcx
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rdx
callq 0x3580
movq %rax, %rbx
testb %bpl, %bpl
je 0x94b4
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0x948f
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x94b4
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x8(%rsp), %rax
cmpq 0x18(%rax), %r14
je 0x94c4
cmpq %r12, %rbx
jae 0x94d4
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
callq 0x3210
movq %rbx, %r12
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x94f0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3390
movq %r14, %rdi
callq 0x3250
movq %rax, %r14
cmpq 0x78(%rsp), %rax
jne 0x93a2
cmpq $-0x1, %r12
je 0x9583
movq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x75be
leaq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x7998
movq 0x50(%rsp), %rdx
addq 0x70(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %r8
movq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x33d0
movq 0x18(%rsp), %rax
addq %r12, %rax
movq %rax, 0x38(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x958c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3390
jmp 0x958c
movq $-0x1, 0x38(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x95a8
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3390
cmpq $-0x1, %r12
je 0x95cf
cmpl $0x0, 0x4(%rsp)
je 0x9376
movq 0x68(%rsp), %rax
incl %eax
movq %rax, 0x68(%rsp)
cmpl 0x44(%rsp), %eax
jne 0x9376
movq 0x80(%rsp), %rdi
leaq 0x10(%rdi), %rcx
movq %rcx, (%rdi)
movq 0x30(%rsp), %rsi
movq (%rsi), %rdx
leaq 0x10(%rsi), %rax
cmpq %rax, %rdx
je 0x95fb
movq %rdx, (%rdi)
movq (%rax), %rcx
movq %rcx, 0x10(%rdi)
jmp 0x9601
movups (%rax), %xmm0
movups %xmm0, (%rcx)
movq 0x8(%rsi), %rcx
movq %rcx, 0x8(%rdi)
movq %rax, (%rsi)
movq $0x0, 0x8(%rsi)
movb $0x0, 0x10(%rsi)
movq %rdi, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x965d
jmp 0x967e
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x9660
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3390
jmp 0x9660
jmp 0x965d
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x9681
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3390
jmp 0x9681
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x969d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3390
movq %rbx, %rdi
callq 0x3590