// File: /workspace/github_cpp_makefile_star2_O3/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, 0x38(%rsp)
cmpq $0x0, 0x28(%rdx)
je 0x9265
movq 0x108(%rsp), %rax
movq 0x100(%rsp), %rdx
movq $0x0, 0x68(%rsp)
testb %r9b, %r9b
movq %rdi, 0x98(%rsp)
movq %rsi, 0x28(%rsp)
movl %r9d, 0x44(%rsp)
je 0x9271
movq 0x8(%rax), %rax
addq 0x8(%rdx), %rax
movq %rax, 0x70(%rsp)
jmp 0x927a
leaq 0x10(%rdi), %rcx
movq %rcx, (%rdi)
jmp 0x954b
movq $0x0, 0x70(%rsp)
movslq %ecx, %rax
movq %rax, 0x30(%rsp)
movq 0x38(%rsp), %rax
leaq 0x8(%rax), %r12
movl 0x4(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movl %ecx, 0x40(%rsp)
leaq 0x8(%rsp), %r15
leaq 0xa8(%rsp), %r13
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movq $0x0, 0x50(%rsp)
movb $0x0, 0x58(%rsp)
movq 0x38(%rsp), %rax
movq 0x18(%rax), %r14
cmpq %r12, %r14
je 0x946b
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x78d2
cmpb $0x0, 0x44(%rsp)
je 0x9362
movq %r13, %rdi
movq 0x100(%rsp), %rsi
movq %r15, %rdx
callq 0x9aab
movq 0x108(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r13, %rdi
callq 0x3120
movq %rbp, 0xa0(%rsp)
movq %r13, %rbp
movq %r15, %r13
movq %r12, %r15
leaq 0x88(%rsp), %r12
movq %r12, 0x78(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x9383
movq %rdx, 0x78(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x88(%rsp)
jmp 0x938b
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rcx
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rdx
callq 0x3580
movq %rax, %rbx
jmp 0x9415
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x80(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rcx
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rdx
callq 0x3580
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x93df
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
movq %r15, %r12
je 0x9407
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3390
movq %r13, %r15
movq %rbp, %r13
movq 0xa0(%rsp), %rbp
movq 0x38(%rsp), %rax
cmpq 0x18(%rax), %r14
je 0x9425
cmpq %rbp, %rbx
jae 0x9435
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
callq 0x3210
movq %rbx, %rbp
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9451
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3390
movq %r14, %rdi
callq 0x3250
movq %rax, %r14
cmpq %r12, %rax
jne 0x92d5
cmpq $-0x1, %rbp
je 0x94e4
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x74f8
leaq 0x18(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x78d2
movq 0x50(%rsp), %rdx
addq 0x70(%rsp), %rdx
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r8
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
callq 0x33d0
movq 0x10(%rsp), %rax
addq %rbp, %rax
movq %rax, 0x30(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x94e0
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3390
xorl %ebx, %ebx
jmp 0x94f6
movq $-0x1, %rbp
movb $0x1, %bl
movq $-0x1, 0x30(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x9512
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3390
testb %bl, %bl
jne 0x9537
cmpl $0x0, 0x4(%rsp)
je 0x92ab
movq 0x68(%rsp), %rax
incl %eax
movq %rax, 0x68(%rsp)
cmpl 0x40(%rsp), %eax
jne 0x92ab
movq 0x98(%rsp), %rdi
leaq 0x10(%rdi), %rcx
movq %rcx, (%rdi)
movq 0x28(%rsp), %rsi
movq (%rsi), %rdx
leaq 0x10(%rsi), %rax
cmpq %rax, %rdx
je 0x9563
movq %rdx, (%rdi)
movq (%rax), %rcx
movq %rcx, 0x10(%rdi)
jmp 0x9569
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 0x95c5
jmp 0x95e6
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x95c8
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3390
jmp 0x95c8
jmp 0x95c5
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x95e9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3390
jmp 0x95e9
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x9605
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3390
movq %rbx, %rdi
callq 0x3590