// File: /workspace/github_cpp_makefile_star2_O2/Mespyr[P]bop-lisp/src/parser.cpp
// Function: tokenize(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
TokenList tokenize(std::string code) 
{
    TokenList stream;
    std::string word;
    bool string_has_started = false;
    bool in_comment = false;

    unsigned int line = 1;

    for (int i = 0; i < code.length(); i++)
    {
        char buf = code.at(i);
        if (buf == '\n') 
        {
            line++;
        }
        if (buf == ';' and !string_has_started) 
        {
            in_comment = !in_comment;
        } 
        else if(in_comment);

        else if (buf == '\'') 
        {
            word.push_back(buf);
            if(!string_has_started) 
            {
                string_has_started = true;
            } 
            else 
            {
                Token tok{line, word};
                stream.token_stream.push_back(tok);
                string_has_started = false;
                word = "";
            }
        } 
        else if (string_has_started) 
        {
            word.push_back(buf);
        }
        else if (isspace(buf)) 
        {
            if (word != "") 
            {
                Token tok{line, word};
                stream.token_stream.push_back(tok);
            }
            word = "";
        } 
        else if (buf == '(') 
        {
            if (word != "") 
            {
                Token tok{line, word};
                stream.token_stream.push_back(tok);
            }
            Token tok{line, "("};
            stream.token_stream.push_back(tok);
            word = "";
        }
        else if (buf == ')') 
        {
            if (word != "") 
            {
                Token tok{line, word};
                stream.token_stream.push_back(tok);
            }
            Token tok{line, ")"};
            stream.token_stream.push_back(tok);
            word = "";
        }
        else 
        {
            word.push_back(buf);
        }
    }

    return stream;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r14
andq $0x0, 0x10(%rdi)
leaq -0x78(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorps %xmm0, %xmm0
movq %rdi, -0x38(%rbp)
movups %xmm0, (%rdi)
movb $0x0, (%rax)
pushq $0x1
popq %rbx
xorl %r13d, %r13d
movl $0x0, -0x30(%rbp)
movq $0x0, -0x68(%rbp)
cmpq %r13, 0x8(%r14)
jbe 0xb4f3
movl %ebx, %r12d
movq %r14, %rdi
movq %r13, %rsi
callq 0x23c0
movsbl (%rax), %r15d
xorl %ebx, %ebx
cmpl $0xa, %r15d
sete %bl
addl %r12d, %ebx
cmpl $0x3b, %r15d
jne 0xb2d7
testb $0x1, -0x30(%rbp)
je 0xb349
testb $0x1, -0x68(%rbp)
je 0xb35b
jmp 0xb3d2
testb $0x1, -0x68(%rbp)
jne 0xb3d2
cmpb $0x27, %r15b
jne 0xb355
leaq -0x88(%rbp), %rdi
pushq $0x27
popq %rsi
callq 0x21c0
testb $0x1, -0x30(%rbp)
je 0xb3cd
movl %r12d, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x22d0
movq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xbca0
leaq -0x88(%rbp), %rdi
leaq 0x1d65(%rip), %rsi      # 0xd094
callq 0x23b0
leaq -0x58(%rbp), %rdi
callq 0x2130
movl $0x0, -0x30(%rbp)
jmp 0xb3d2
movq -0x68(%rbp), %rax
xorb $0x1, %al
movq %rax, -0x68(%rbp)
jmp 0xb3d2
testb $0x1, -0x30(%rbp)
je 0xb36c
leaq -0x88(%rbp), %rdi
movl %r15d, %esi
callq 0x21c0
jmp 0xb3d2
movl %r15d, %edi
callq 0x2060
testl %eax, %eax
je 0xb3da
leaq -0x88(%rbp), %rdi
leaq 0x1d0e(%rip), %rsi      # 0xd094
callq 0x9ba0
testb %al, %al
je 0xb3b8
movl %ebx, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x22d0
movq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xbca0
leaq -0x58(%rbp), %rdi
callq 0x2130
leaq -0x88(%rbp), %rdi
leaq 0x1cce(%rip), %rsi      # 0xd094
callq 0x23b0
jmp 0xb3d2
movb $0x1, %al
movl %eax, -0x30(%rbp)
incq %r13
jmp 0xb290
cmpb $0x29, %r15b
je 0xb46c
movzbl %r15b, %eax
cmpl $0x28, %eax
jne 0xb35b
leaq -0x88(%rbp), %rdi
leaq 0x1c95(%rip), %rsi      # 0xd094
callq 0x9ba0
testb %al, %al
je 0xb432
movl %r12d, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x22d0
movq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xbca0
leaq -0x58(%rbp), %rdi
callq 0x2130
movl %r12d, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq 0x2a3e(%rip), %rsi      # 0xde7f
leaq -0x29(%rbp), %rdx
callq 0x294e
movq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xbca0
leaq -0x88(%rbp), %rdi
leaq 0x1c2f(%rip), %rsi      # 0xd094
callq 0x23b0
jmp 0xb4e5
leaq -0x88(%rbp), %rdi
leaq 0x1c1a(%rip), %rsi      # 0xd094
callq 0x9ba0
testb %al, %al
je 0xb4ad
movl %r12d, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x22d0
movq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xbca0
leaq -0x58(%rbp), %rdi
callq 0x2130
movl %r12d, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq 0x289c(%rip), %rsi      # 0xdd58
leaq -0x29(%rbp), %rdx
callq 0x294e
movq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xbca0
leaq -0x88(%rbp), %rdi
leaq 0x1bb4(%rip), %rsi      # 0xd094
callq 0x23b0
leaq -0x58(%rbp), %rdi
callq 0x2130
jmp 0xb3d2
leaq -0x88(%rbp), %rdi
callq 0x2130
movq -0x38(%rbp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb536
jmp 0xb528
jmp 0xb536
jmp 0xb528
jmp 0xb536
jmp 0xb536
jmp 0xb528
jmp 0xb528
jmp 0xb528
jmp 0xb536
jmp 0xb536
movq %rax, %r14
leaq -0x58(%rbp), %rdi
callq 0x2130
jmp 0xb539
movq %rax, %r14
leaq -0x88(%rbp), %rdi
callq 0x2130
movq -0x38(%rbp), %rdi
callq 0xaf54
movq %r14, %rdi
callq 0x2380