// File: /workspace/github_cpp_makefile_star2_O3/xelia-it[P]mustache/src/mustache-light.cpp
// Function: mustache::Mustache::tokenize(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
Mustache::Tokens Mustache::tokenize(const string& view) {
        std::string::size_type start = 0;
        std::string::size_type prev = 0;
        std::string::size_type pos;
        Tokens tokens;

        while ((pos = view.find_first_of("{}", prev)) != std::string::npos) {
                if (view[pos] == '{') {
                        if (view[pos + 1] == '{') {
                                // Insert into tokens text encountered until "{{"
                                tokens.push_back(view.substr(start, pos - start));
                                if (view[pos + 2] == '#') {
                                        tokens.push_back(TOKEN_START_BEGIN_SECTION);
                                        prev = pos + 3;
                                } else if (view[pos + 2] == '=') {
                                        tokens.push_back(TOKEN_START_IF);
                                        prev = pos + 3;
                                } else if (view[pos + 2] == '^') {
                                        tokens.push_back(TOKEN_START_UNLESS);
                                        prev = pos + 3;
                                } else if (view[pos + 2] == '0') {
                                        tokens.push_back(TOKEN_START_EXISTS_TEST);
                                        prev = pos + 3;
                                } else if (view[pos + 2] == '/') {
                                        tokens.push_back(TOKEN_START_END_SECTION);
                                        prev = pos + 3;
                                } else if (view[pos + 2] == '>') {
                                        tokens.push_back(TOKEN_START_PARTIAL);
                                        prev = pos + 3;
                                } else if (view[pos + 2] == '<') {
                                        tokens.push_back(TOKEN_START_TEMPLATE);
                                        prev = pos + 3;
                                } else if (view[pos + 2] == '!') {
                                        tokens.push_back(TOKEN_START_COMMENT);
                                        prev = pos + 3;
                                } else {
                                        if (view[pos + 2] == '{') {
                                                tokens.push_back(TOKEN_START_VARIABLE_UNESCAPED);
                                                prev = pos + 3;
                                        } else {
                                                tokens.push_back(TOKEN_START_VARIABLE);
                                                prev = pos + 2;
                                        }
                                }
                                start = prev;
                        } else {
                                // Single open {: continue..
                                prev = pos + 1;
                        }
                } else {
                        if (view[pos + 1] == '}') {
                                // Trim string inside parenthesis.
                                // Eg: "{{ some }}" => " some " => "some"
                                string token = view.substr(start, pos - start);
                                token = trim(token);
                                // Now save both token and closed parenthesis "}}"
                                tokens.push_back(token);
                                if (view[pos + 2] == '}') {
                                        tokens.push_back(TOKEN_END_UNESCAPED);
                                        prev = pos + 3;
                                } else {
                                        tokens.push_back(TOKEN_END);
                                        prev = pos + 2;
                                }
                                start = prev;
                        } else {
                                // Single close }: continue..
                                prev = pos + 1;
                        }
                }
        }
        // Save last part of the file (if any) as free text
        tokens.push_back(view.substr(start, pos - start));

        return tokens;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0x16059(%rip), %rsi     # 0x2fc7d
xorl %r15d, %r15d
movl $0x2, %ecx
movq %rdx, %rdi
xorl %edx, %edx
callq 0x18100
cmpq $-0x1, %rax
je 0x19ee7
movq %rax, %r12
xorl %r15d, %r15d
movq (%r14), %rcx
leaq 0x1(%r12), %r13
movb 0x1(%rcx,%r12), %al
cmpb $0x7b, (%rcx,%r12)
jne 0x19ce5
cmpb $0x7b, %al
jne 0x19eac
movq %r12, %rcx
subq %r15, %rcx
leaq -0x48(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x17bd0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x185f0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x19c9b
callq 0x17ae0
movq (%r14), %rax
movzbl 0x2(%rax,%r12), %eax
cmpl $0x3b, %eax
jle 0x19d74
cmpl $0x3d, %eax
jle 0x19e30
cmpl $0x3e, %eax
je 0x19e71
cmpl $0x5e, %eax
je 0x19e93
cmpl $0x7b, %eax
jne 0x19ed2
movq %rbx, %rdi
movq 0x23255(%rip), %rsi     # 0x3cf30
callq 0x174f0
jmp 0x19ea2
cmpb $0x7d, %al
jne 0x19eac
movq %r12, %rcx
subq %r15, %rcx
leaq -0x48(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x17bd0
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
addq %rax, %rcx
movq %rcx, -0x60(%rbp)
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x18090
movq -0x50(%rbp), %rax
movq %rax, %rcx
subq -0x48(%rbp), %rcx
movq %rcx, -0x40(%rbp)
movb $0x0, (%rax)
movq -0x48(%rbp), %r15
movq -0x40(%rbp), %rsi
addq %r15, %rsi
movq %r15, %rdi
callq 0x17640
movq -0x48(%rbp), %rcx
movq %r15, %rsi
subq %rcx, %rsi
movq -0x40(%rbp), %rdx
addq %rcx, %rdx
cmpq %rax, %rdx
je 0x19da3
subq %r15, %rax
movq %r13, %rdi
movq %rax, %rdx
callq 0x17d00
jmp 0x19dab
cmpl $0x2e, %eax
jg 0x19e11
cmpl $0x21, %eax
je 0x19e4f
cmpl $0x23, %eax
jne 0x19ed2
movq %rbx, %rdi
movq 0x231c7(%rip), %rsi     # 0x3cf60
callq 0x174f0
jmp 0x19ea2
movq %rsi, -0x40(%rbp)
movb $0x0, (%rcx,%rsi)
movq %r13, %rdi
movq %r13, %rsi
callq 0x17550
movq %rbx, %rdi
movq %r13, %rsi
callq 0x174f0
movq (%r14), %rax
cmpb $0x7d, 0x2(%rax,%r12)
jne 0x19de1
movq %rbx, %rdi
movq 0x23182(%rip), %rsi     # 0x3cf58
callq 0x174f0
addq $0x3, %r12
jmp 0x19df4
movq %rbx, %rdi
movq 0x2308d(%rip), %rsi     # 0x3ce78
callq 0x174f0
addq $0x2, %r12
movq %r12, %r13
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x19e09
callq 0x17ae0
movq %r13, %r15
jmp 0x19eac
cmpl $0x2f, %eax
je 0x19e60
cmpl $0x30, %eax
jne 0x19ed2
movq %rbx, %rdi
movq 0x230f7(%rip), %rsi     # 0x3cf20
callq 0x174f0
jmp 0x19ea2
cmpl $0x3c, %eax
je 0x19e82
cmpl $0x3d, %eax
jne 0x19ed2
movq %rbx, %rdi
movq 0x23160(%rip), %rsi     # 0x3cfa8
callq 0x174f0
jmp 0x19ea2
movq %rbx, %rdi
movq 0x2311f(%rip), %rsi     # 0x3cf78
callq 0x174f0
jmp 0x19ea2
movq %rbx, %rdi
movq 0x23146(%rip), %rsi     # 0x3cfb0
callq 0x174f0
jmp 0x19ea2
movq %rbx, %rdi
movq 0x23105(%rip), %rsi     # 0x3cf80
callq 0x174f0
jmp 0x19ea2
movq %rbx, %rdi
movq 0x23064(%rip), %rsi     # 0x3cef0
callq 0x174f0
jmp 0x19ea2
movq %rbx, %rdi
movq 0x23003(%rip), %rsi     # 0x3cea0
callq 0x174f0
addq $0x3, %r12
movq %r12, %r13
movq %r12, %r15
movl $0x2, %ecx
movq %r14, %rdi
leaq 0x15dc2(%rip), %rsi     # 0x2fc7d
movq %r13, %rdx
callq 0x18100
movq %rax, %r12
cmpq $-0x1, %rax
jne 0x19c46
jmp 0x19ee7
movq %rbx, %rdi
movq 0x23004(%rip), %rsi     # 0x3cee0
callq 0x174f0
addq $0x2, %r12
jmp 0x19ea6
movq %r15, %rcx
notq %rcx
leaq -0x48(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x17bd0
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x185f0
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19f1a
callq 0x17ae0
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
jmp 0x19f51
jmp 0x19f41
jmp 0x19f41
jmp 0x19f41
jmp 0x19f46
movq %rax, %r14
jmp 0x19f5b
movq %rax, %r14
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x19f5b
callq 0x17ae0
movq %rbx, %rdi
callq 0x17790
movq %r14, %rdi
callq 0x18490
nop