// File: /workspace/github_cpp_makefile_star2_O1/xelia-it[P]mustache/src/mustache-light.cpp
// Function: mustache::Mustache::partialSubstitute(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>>>>, 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>>>>&)
void Mustache::partialSubstitute(const Tokens partialParams, Tokens& newTokens) {
        Variables partialVariables;
        LOG_END("===============================================");

        for (std::vector<string>::size_type i = 1; i != partialParams.size(); i++) {
                LOG("Token: |");
                const string& token = partialParams.at(i);
                LOG(token);
                LOG_END("|");
                if (token.find_first_of("=") == std::string::npos) {
                        error("Bad substitution string: missing '=' in " + token);
                }
                vector<string> pair = split(token, '=');
                if (pair.size() != 2) {
                        error("Bad substitution string: missing separator in " + token);
                }

                VariableConstIterator lb = partialSearchVariable(partialVariables, pair.at(1));

                // map<string, string>::iterator lb = partialVariables.lower_bound(pair.at(0));
                // if (lb != partialVariables.end() && !(partialVariables.key_comp()(pair.at(0), lb->first))) {
                if (lb != partialVariables.end()) {
                        // key already exists
                        // update lb->second if you care to
                        partialVariables.insert(lb, map<string, string>::value_type(pair.at(0), lb->second ));
                } else {
                        // the key does not exist in the map
                        // add it to the map
                        partialVariables.insert(lb, map<string, string>::value_type(pair.at(0), pair.at(1)));
                        // Use lb as a hint to insert,
                        // so it can avoid another lookup
                }
        }

        LOG_END("===============================================");
        for (Tokens::size_type i = 1; i != newTokens.size(); i++) {
                //LOG("  New token: ");
                string tokenToCheck = newTokens.at(i);
                string tokenToCheckPrev = newTokens.at(i-1);
                //LOG_END(tokenToCheck);
                if ((tokenToCheck != TOKEN_START_VARIABLE) &&
                    (tokenToCheck != TOKEN_START_BEGIN_SECTION) &&
                    (tokenToCheck != TOKEN_START_END_SECTION) &&
                    (tokenToCheck != TOKEN_START_IF) &&
                    (tokenToCheck != TOKEN_START_UNLESS) &&
                    (tokenToCheck != TOKEN_START_PARTIAL) &&
                    (tokenToCheck != TOKEN_START_TEMPLATE) &&
                    (tokenToCheck != TOKEN_END)) {

                        // Searching
                        LOG("  Searching: ");
                        LOG(tokenToCheck);

                        VariableIterator lb = partialVariables.find(tokenToCheck);
                        if (lb == partialVariables.end()) {
                                LOG_END(" -> Not Found");
                                continue;
                        }
                        LOG(" -> { ");
                        LOG(lb->first);
                        LOG(" : ");
                        LOG(lb->second);
                        LOG_END(" }");

                        // Substitution
                        LOG("    Substitute: ");
                        string valueToSubstitute = lb->second;
                        LOG(newTokens.at(i));
                        LOG("    at position ");
                        LOG(i);

                        if (valueToSubstitute[0] != '\'' && valueToSubstitute[0] != '\"') {
                                // Simple substitution
                                LOG_END("    with nothing");
                                // newTokens.at(i) = valueToSubstitute;
                        } else {
                                // Substitute literal

                                if (tokenToCheckPrev != TOKEN_START_VARIABLE) {
                                        LOG_END("");
                                        LOG_END("NOT A VARIABLE SKIP LITERAL SUBSTITUTION!");
                                        continue;
                                }

                                if (valueToSubstitute[valueToSubstitute.size() - 1 ] != '\'' && valueToSubstitute[valueToSubstitute.size() - 1] != '\"') {
                                        error("Substitution string " + valueToSubstitute + " not properly closed");
                                }
                                LOG(" with literal ");
                                valueToSubstitute = valueToSubstitute.substr(1, valueToSubstitute.size() - 2);
                                LOG_END(valueToSubstitute);

                                // LOG_END("DUMP BEFORE:");
                                // for (std::vector<string>::size_type j = 0; j != newTokens.size(); j++) {
                                //     LOG(j);
                                //     LOG(" ");
                                //     LOG_END(newTokens.at(j));
                                // }

                                i = i - 1;
                                newTokens.erase(newTokens.begin() + i);
                                newTokens.erase(newTokens.begin() + i);

                                LOG_END("DUMP AFTER:");
                                for (std::vector<string>::size_type j = 0; j != newTokens.size(); j++) {
                                        LOG(j);
                                        LOG(" ");
                                        LOG_END(newTokens.at(j));
                                }

                                LOG("NOW i = ");
                                LOG_END(i);
                        }
                        newTokens.at(i) = valueToSubstitute;
                }
        }
        //partialVariables.clear();
        LOG_END("===============================================");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdx, %rbx
movq %rdi, -0xe0(%rbp)
leaq -0x108(%rbp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq (%rsi), %r15
movq 0x8(%rsi), %rdx
subq %r15, %rdx
cmpq $0x20, %rdx
je 0x1c834
movq %rsi, %r14
sarq $0x5, %rdx
movl $0x1, %r13d
movl $0x20, %r12d
movq $0x0, -0xb0(%rbp)
movq %rbx, -0xb8(%rbp)
cmpq %r13, %rdx
jbe 0x1cc46
addq %r12, %r15
movl $0x1, %ecx
movq %r15, %rdi
leaq 0x145b0(%rip), %rsi     # 0x30c73
xorl %edx, %edx
callq 0x18120
cmpq $-0x1, %rax
je 0x1cc57
leaq -0x88(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq %r15, %rdx
movl $0x3d, %ecx
callq 0x17d30
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rax
subq %rsi, %rax
cmpq $0x40, %rax
jne 0x1cc2a
movq 0x20(%rsi), %rax
movzbl (%rax), %eax
leaq -0x108(%rbp), %rcx
movq %rcx, %r15
cmpl $0x22, %eax
je 0x1c73f
movq %rcx, %r15
cmpl $0x27, %eax
je 0x1c73f
addq $0x20, %rsi
leaq -0x110(%rbp), %rdi
callq 0x181b0
movq %rax, %r15
leaq -0x108(%rbp), %rcx
cmpq %rcx, %r15
je 0x1c787
movq -0x88(%rbp), %rsi
cmpq %rsi, -0x80(%rbp)
je 0x1cc95
leaq 0x40(%r15), %rdx
leaq -0x68(%rbp), %rbx
movq %rbx, %rdi
callq 0x18490
leaq -0x110(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
movq %r15, %rsi
movq %rbx, %rdx
leaq -0xa8(%rbp), %rcx
callq 0x17320
jmp 0x1c7df
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rax
movq %rax, %rdx
subq %rsi, %rdx
sarq $0x5, %rdx
cmpq %rsi, %rax
je 0x1ccb3
cmpq $0x2, %rdx
jb 0x1cca7
leaq 0x20(%rsi), %rdx
leaq -0x68(%rbp), %rbx
movq %rbx, %rdi
callq 0x17a80
leaq -0x110(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
movq %r15, %rsi
movq %rbx, %rdx
leaq -0xa8(%rbp), %rcx
callq 0x17320
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
movq -0xb8(%rbp), %rbx
je 0x1c7f8
callq 0x17b00
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x1c80a
callq 0x17b00
leaq -0x88(%rbp), %rdi
callq 0x177a0
incq %r13
movq (%r14), %r15
movq 0x8(%r14), %rdx
subq %r15, %rdx
sarq $0x5, %rdx
addq $0x20, %r12
cmpq %rdx, %r13
jne 0x1c6a8
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
cmpq $0x20, %rdx
je 0x1cc0c
sarq $0x5, %rdx
movl $0x1, %r12d
cmpq %r12, %rdx
jbe 0x1cc84
movq %r12, %rcx
shlq $0x5, %rcx
leaq -0x58(%rbp), %rdx
movq %rdx, -0x68(%rbp)
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %rdi
callq 0x173d0
leaq -0x1(%r12), %r15
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %r15, %rdx
jbe 0x1cc73
movq %r15, %r13
shlq $0x5, %r13
leaq -0x78(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x173d0
movq -0x60(%rbp), %r14
movq 0x21610(%rip), %rax     # 0x3dee0
cmpq 0x8(%rax), %r14
jne 0x1c8fd
testq %r14, %r14
je 0x1cbcb
movq 0x215fa(%rip), %rax     # 0x3dee0
movq (%rax), %rsi
movq -0x68(%rbp), %rdi
movq %r14, %rdx
callq 0x17be0
testl %eax, %eax
je 0x1cbcb
movq 0x2165c(%rip), %rax     # 0x3df60
cmpq 0x8(%rax), %r14
jne 0x1c931
testq %r14, %r14
je 0x1cbcb
movq 0x21646(%rip), %rax     # 0x3df60
movq (%rax), %rsi
movq -0x68(%rbp), %rdi
movq %r14, %rdx
callq 0x17be0
testl %eax, %eax
je 0x1cbcb
movq 0x21678(%rip), %rax     # 0x3dfb0
cmpq 0x8(%rax), %r14
jne 0x1c965
testq %r14, %r14
je 0x1cbcb
movq 0x21662(%rip), %rax     # 0x3dfb0
movq (%rax), %rsi
movq -0x68(%rbp), %rdi
movq %r14, %rdx
callq 0x17be0
testl %eax, %eax
je 0x1cbcb
movq 0x2163c(%rip), %rax     # 0x3dfa8
cmpq 0x8(%rax), %r14
jne 0x1c999
testq %r14, %r14
je 0x1cbcb
movq 0x21626(%rip), %rax     # 0x3dfa8
movq (%rax), %rsi
movq -0x68(%rbp), %rdi
movq %r14, %rdx
callq 0x17be0
testl %eax, %eax
je 0x1cbcb
movq 0x21500(%rip), %rax     # 0x3dea0
cmpq 0x8(%rax), %r14
jne 0x1c9cd
testq %r14, %r14
je 0x1cbcb
movq 0x214ea(%rip), %rax     # 0x3dea0
movq (%rax), %rsi
movq -0x68(%rbp), %rdi
movq %r14, %rdx
callq 0x17be0
testl %eax, %eax
je 0x1cbcb
movq 0x215ac(%rip), %rax     # 0x3df80
cmpq 0x8(%rax), %r14
jne 0x1ca01
testq %r14, %r14
je 0x1cbcb
movq 0x21596(%rip), %rax     # 0x3df80
movq (%rax), %rsi
movq -0x68(%rbp), %rdi
movq %r14, %rdx
callq 0x17be0
testl %eax, %eax
je 0x1cbcb
movq 0x214e8(%rip), %rax     # 0x3def0
cmpq 0x8(%rax), %r14
jne 0x1ca35
testq %r14, %r14
je 0x1cbcb
movq 0x214d2(%rip), %rax     # 0x3def0
movq (%rax), %rsi
movq -0x68(%rbp), %rdi
movq %r14, %rdx
callq 0x17be0
testl %eax, %eax
je 0x1cbcb
movq 0x2143c(%rip), %rax     # 0x3de78
cmpq 0x8(%rax), %r14
jne 0x1ca69
testq %r14, %r14
je 0x1cbcb
movq 0x21426(%rip), %rax     # 0x3de78
movq (%rax), %rsi
movq -0x68(%rbp), %rdi
movq %r14, %rdx
callq 0x17be0
testl %eax, %eax
je 0x1cbcb
leaq -0x110(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x17700
leaq -0x108(%rbp), %rcx
cmpq %rcx, %rax
je 0x1cbcb
leaq -0x98(%rbp), %rcx
movq %rcx, -0xa8(%rbp)
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
addq %rsi, %rdx
leaq -0xa8(%rbp), %rdi
callq 0x173d0
movq -0xa8(%rbp), %r14
movzbl (%r14), %eax
cmpl $0x22, %eax
je 0x1cac7
cmpl $0x27, %eax
jne 0x1cb7d
movq -0x80(%rbp), %rdx
movq 0x2140e(%rip), %rax     # 0x3dee0
cmpq 0x8(%rax), %rdx
jne 0x1cbb3
testq %rdx, %rdx
je 0x1caff
movq 0x213f8(%rip), %rax     # 0x3dee0
movq (%rax), %rsi
movq -0x88(%rbp), %rdi
callq 0x17be0
testl %eax, %eax
jne 0x1cbb3
movq -0xa0(%rbp), %rcx
movzbl -0x1(%r14,%rcx), %eax
cmpl $0x22, %eax
je 0x1cb1a
cmpl $0x27, %eax
jne 0x1ccd9
addq $-0x2, %rcx
movl $0x1, %edx
leaq -0xd8(%rbp), %r12
movq %r12, %rdi
leaq -0xa8(%rbp), %r14
movq %r14, %rsi
callq 0x17bf0
movq %r14, %rdi
movq %r12, %rsi
callq 0x17d80
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x1cb5f
callq 0x17b00
movq (%rbx), %rsi
addq %r13, %rsi
movq %rbx, %rdi
callq 0x17620
addq (%rbx), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x17620
jmp 0x1cb87
movq %r12, %r15
leaq -0xa8(%rbp), %r14
movq (%rbx), %rdi
movq 0x8(%rbx), %rdx
subq %rdi, %rdx
sarq $0x5, %rdx
cmpq %r15, %rdx
jbe 0x1ccc8
movq %r15, %rax
shlq $0x5, %rax
addq %rax, %rdi
movq %r14, %rsi
callq 0x17560
movq %r15, %r12
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x1cbcb
callq 0x17b00
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x1cbe0
callq 0x17b00
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x1cbf2
callq 0x17b00
incq %r12
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %rdx, %r12
jne 0x1c852
leaq -0x110(%rbp), %rdi
callq 0x17a00
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14123(%rip), %rsi     # 0x30d54
leaq -0x68(%rbp), %rdi
movq %r15, %rdx
callq 0x17a70
leaq -0x68(%rbp), %rsi
callq 0x17e70
leaq 0x17a93(%rip), %rdi     # 0x346e0
movq %r13, %rsi
xorl %eax, %eax
callq 0x18110
leaq 0x140cd(%rip), %rsi     # 0x30d2b
leaq -0x68(%rbp), %rdi
movq %r15, %rdx
callq 0x17a70
leaq -0x68(%rbp), %rsi
callq 0x17e70
leaq 0x17a66(%rip), %rdi     # 0x346e0
movq %r15, %rsi
xorl %eax, %eax
callq 0x18110
leaq 0x17a55(%rip), %rdi     # 0x346e0
movq %r12, %rsi
xorl %eax, %eax
callq 0x18110
leaq 0x17a44(%rip), %rdi     # 0x346e0
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x18110
movl $0x1, %eax
movq %rax, -0xb0(%rbp)
leaq 0x17a26(%rip), %rdi     # 0x346e0
movq -0xb0(%rbp), %rsi
xorl %eax, %eax
callq 0x18110
leaq 0x17a11(%rip), %rdi     # 0x346e0
movq %r15, %rsi
xorl %eax, %eax
callq 0x18110
leaq 0x140a3(%rip), %rsi     # 0x30d83
leaq -0x130(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x17a70
leaq 0x1409e(%rip), %rsi     # 0x30d98
leaq -0x130(%rbp), %rdi
callq 0x18680
leaq -0xc8(%rbp), %rcx
movq %rcx, -0xd8(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x1cd32
movups (%rcx), %xmm0
leaq -0xc8(%rbp), %rdx
movups %xmm0, (%rdx)
jmp 0x1cd43
movq %rdx, -0xd8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xc8(%rbp)
movq 0x8(%rax), %rdx
leaq -0xd8(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
callq 0x17e70
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x1cd86
callq 0x17b00
jmp 0x1cd86
movq %rax, %rbx
leaq -0x120(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1cdaa
callq 0x17b00
jmp 0x1cdaa
jmp 0x1cda7
jmp 0x1cda7
jmp 0x1cda7
jmp 0x1cda7
jmp 0x1cda7
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x1cdc9
callq 0x17b00
jmp 0x1cdc9
jmp 0x1cdc6
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x1ce2f
callq 0x17b00
jmp 0x1ce2f
jmp 0x1ce15
jmp 0x1ce07
jmp 0x1ce15
jmp 0x1ce2c
jmp 0x1ce45
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x1ce18
callq 0x17b00
jmp 0x1ce18
jmp 0x1ce15
jmp 0x1ce15
jmp 0x1ce15
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x17160
jmp 0x1ce18
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x177a0
jmp 0x1ce48
jmp 0x1ce45
jmp 0x1ce45
jmp 0x1ce2c
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x1ce48
callq 0x17b00
jmp 0x1ce48
jmp 0x1ce45
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x17a00
movq %rbx, %rdi
callq 0x184b0