// File: /workspace/github_cpp_makefile_star2_O3/blakewford[P]kab/parser.cpp
// Function: parse(char const*, target*)
void parse(const char* json, target* t)
{
    int i = 0;
    object* temp = nullptr;
    char current = json[i];
    parse_state state = UNKNOWN;
    char attribute[MAX_BUFFER_SIZE];
    std::stack<container_object*> object_stack;
    while(current != '\0')
    {
        while(current == ' ')
        {
            i++;
            current = json[i];
        }
        if(current == '{')
        {
            switch(state)
            {
                case UNKNOWN:
                case VALUE:
                    object_stack.push(new container_object(attribute));
                    memset(attribute, '\0', MAX_BUFFER_SIZE);
                    state = ATTRIBUTE_NAME;
                    break;
                case ATTRIBUTE_NAME:
                    assert(0);
                    break;
            }
        }
        else if(current == '}')
        {
            if(temp != nullptr)
            {
                object_stack.top()->add(temp);
            }
            memset(attribute, '\0', MAX_BUFFER_SIZE);
            temp = nullptr;
            container_object* obj = object_stack.top();
            object_stack.pop();
            if(!object_stack.empty())
            {
                object_stack.top()->add(obj);
            }
            else
            {
                //Top level Weave object
                t->populate(obj);
            }
        }
        else if(current == ':')
        {
            switch(state)
            {
                case ATTRIBUTE_NAME:
                    state = VALUE;
                    break;
                case UNKNOWN:
                case VALUE:
                    assert(0);
            }
        }
        else if(current == ',')
        {
            switch(state)
            {
                case VALUE:
                    object_stack.top()->add(temp);
                    memset(attribute, '\0', MAX_BUFFER_SIZE);
                    temp = nullptr;
                    state = ATTRIBUTE_NAME;
                    break;
                case UNKNOWN:
                case ATTRIBUTE_NAME:
                    assert(0);
            }
        }
        else if(current == '"')
        {
            switch(state)
            {
                case ATTRIBUTE_NAME:
                    break;
                case VALUE:
                    if(temp == nullptr)
                    {
                        temp = new string_object(attribute);
                    }
                    break;
                case UNKNOWN:
                    assert(0);
            }
        }
        else
        {
            switch(state)
            {
                case ATTRIBUTE_NAME:
                    attribute[strlen(attribute)] = current;
                    break;
                case VALUE:
                    if(temp == nullptr)
                    {
                        long_object* obj = new long_object(attribute);
                        obj->set_value(atoi(json+i)); //HACK ALERT
                        temp = obj;
                    }
                    switch(temp->get_type())
                    {
                        case STRING:
                            ((string_object*)temp)->add(current);
                            break;
                        case LONG:
                        case CONTAINER:
                            break;
                    }
                    break;
                case UNKNOWN:
                    assert(0);
            }
        }
        current = json[++i];
    }

    if(temp != nullptr) delete temp;
    assert(object_stack.size() == 0);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, 0xa0(%rsp)
movq %rdi, %r15
movb (%rdi), %r14b
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x40e6
testb %r14b, %r14b
je 0x3db0
movq %r15, 0x8(%rsp)
leaq 0x1(%r15), %rax
movq %rax, 0xa8(%rsp)
movabsq $0x100000000, %r15      # imm = 0x100000000
xorl %ebp, %ebp
xorl %r13d, %r13d
movslq %ebx, %r12
leal 0x1(%r12), %ebx
movq 0xa8(%rsp), %rax
addq %r12, %rax
shlq $0x20, %r12
cmpb $0x20, %r14b
jne 0x39c6
movb (%rax), %r14b
incl %ebx
addq %r15, %r12
incq %rax
jmp 0x39b3
movzbl %r14b, %eax
cmpl $0x39, %eax
jle 0x3a59
cmpl $0x3a, %eax
je 0x3ac6
cmpl $0x7b, %eax
je 0x3adb
cmpl $0x7d, %eax
jne 0x3b8e
movq 0x40(%rsp), %rax
testq %rbp, %rbp
je 0x3a21
cmpq 0x48(%rsp), %rax
jne 0x3a10
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movq -0x8(%rax), %rdi
movq %rbp, %rsi
callq 0x3ee6
movq 0x40(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movq 0x48(%rsp), %rdi
cmpq %rdi, %rax
je 0x3c5d
movq -0x8(%rax), %r12
addq $-0x8, %rax
jmp 0x3c9d
cmpl $0x22, %eax
je 0x3b7a
cmpl $0x2c, %eax
jne 0x3b8e
cmpl $0x2, %r13d
jne 0x3e4f
movq 0x40(%rsp), %rax
cmpq 0x48(%rsp), %rax
jne 0x3a92
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movq -0x8(%rax), %rdi
movq %rbp, %rsi
callq 0x3ee6
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movl $0x1, %r13d
jmp 0x3cdd
cmpl $0x1, %r13d
movl $0x2, %r13d
je 0x3d16
jmp 0x3e30
cmpl $0x1, %r13d
je 0x3e11
movl $0x68, %edi
callq 0x2220
movq %rax, %r12
movq %rax, %r13
addq $0x8, %r13
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rax)
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x8(%rax)
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0x20e0
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2190
movl $0x2, 0x48(%r12)
leaq 0x41e1(%rip), %rax      # 0x7d18
movq %rax, (%r12)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%r12)
movq $0x0, 0x60(%r12)
movq %r12, 0xb0(%rsp)
movq 0x40(%rsp), %rax
movq 0x50(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x3ce1
movq %r12, (%rax)
addq $0x8, 0x40(%rsp)
jmp 0x3cf3
cmpl $0x2, %r13d
je 0x3bce
testl %r13d, %r13d
jne 0x3d16
jmp 0x3e8d
cmpl $0x1, %r13d
je 0x3c49
cmpl $0x2, %r13d
jne 0x3e6e
testq %rbp, %rbp
je 0x3d2d
movl $0x2, %r13d
cmpl $0x1, 0x48(%rbp)
jne 0x3d16
leaq 0x4c(%rbp), %rdi
callq 0x20e0
movb %r14b, 0x4c(%rbp,%rax)
jmp 0x3d16
movl $0x2, %r13d
testq %rbp, %rbp
jne 0x3d16
movl $0x90, %edi
callq 0x2220
movq %rax, %rbp
movq %rax, %r12
addq $0x8, %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rax)
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x8(%rax)
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0x20e0
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2190
movl $0x1, 0x48(%rbp)
leaq 0x4133(%rip), %rax      # 0x7d60
movq %rax, (%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x4c(%rbp)
movups %xmm0, 0x5c(%rbp)
movups %xmm0, 0x6c(%rbp)
movups %xmm0, 0x7c(%rbp)
jmp 0x3d16
leaq 0x60(%rsp), %rdi
callq 0x20e0
movb %r14b, 0x60(%rsp,%rax)
jmp 0x3d10
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rax
movq 0x1f8(%rax), %r12
callq 0x21e0
movq 0x58(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x58(%rsp)
movq -0x8(%rax), %rdi
movq %rdi, 0x48(%rsp)
leaq 0x200(%rdi), %rax
movq %rax, 0x50(%rsp)
movl $0x1f8, %eax            # imm = 0x1F8
addq %rdi, %rax
movq %rax, 0x40(%rsp)
cmpq 0x20(%rsp), %rax
je 0x3ccd
cmpq %rdi, %rax
jne 0x3cbf
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movq -0x8(%rax), %rdi
movq %r12, %rsi
callq 0x3ee6
jmp 0x3cdd
movq 0xa0(%rsp), %rdi
movq %r12, %rsi
callq 0x36cc
xorl %ebp, %ebp
jmp 0x3d16
leaq 0x10(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x424e
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x90(%rsp)
movl $0x1, %r13d
movslq %ebx, %rax
movq 0x8(%rsp), %rcx
movb (%rcx,%rax), %r14b
testb %r14b, %r14b
jne 0x399c
jmp 0x3da3
movl $0x58, %edi
callq 0x2220
movq %rax, %rbp
movq %rax, %r13
addq $0x8, %r13
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rax)
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x8(%rax)
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0x20e0
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2190
movl $0x0, 0x48(%rbp)
leaq 0x401b(%rip), %rax      # 0x7d98
movq %rax, (%rbp)
sarq $0x20, %r12
addq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x2310
cltq
movq %rax, 0x50(%rbp)
movl $0x2, %r13d
jmp 0x3d16
testq %rbp, %rbp
je 0x3db0
movq %rbp, %rdi
callq 0x21e0
movq 0x58(%rsp), %rax
movq %rax, %rcx
subq 0x38(%rsp), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
shlq $0x6, %rcx
movq 0x30(%rsp), %rax
movq 0x40(%rsp), %rdx
subq 0x48(%rsp), %rdx
sarq $0x3, %rdx
addq %rcx, %rdx
subq 0x20(%rsp), %rax
sarq $0x3, %rax
addq %rdx, %rax
jne 0x3eac
leaq 0x10(%rsp), %rdi
callq 0x409c
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16f8(%rip), %rdi      # 0x5510
leaq 0x1609(%rip), %rsi      # 0x5428
leaq 0x16b0(%rip), %rcx      # 0x54d6
movl $0x9c, %edx
callq 0x2120
leaq 0x16d9(%rip), %rdi      # 0x5510
leaq 0x15ea(%rip), %rsi      # 0x5428
leaq 0x1691(%rip), %rcx      # 0x54d6
movl $0xbd, %edx
callq 0x2120
leaq 0x16ba(%rip), %rdi      # 0x5510
leaq 0x15cb(%rip), %rsi      # 0x5428
leaq 0x1672(%rip), %rcx      # 0x54d6
movl $0xcc, %edx
callq 0x2120
leaq 0x169b(%rip), %rdi      # 0x5510
leaq 0x15ac(%rip), %rsi      # 0x5428
leaq 0x1653(%rip), %rcx      # 0x54d6
movl $0xf8, %edx
callq 0x2120
leaq 0x167c(%rip), %rdi      # 0x5510
leaq 0x158d(%rip), %rsi      # 0x5428
leaq 0x1634(%rip), %rcx      # 0x54d6
movl $0xdc, %edx
callq 0x2120
leaq 0x1646(%rip), %rdi      # 0x54f9
leaq 0x156e(%rip), %rsi      # 0x5428
leaq 0x1615(%rip), %rcx      # 0x54d6
movl $0xff, %edx
callq 0x2120
jmp 0x3ed1
jmp 0x3ed1
jmp 0x3ed1
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x409c
movq %rbx, %rdi
callq 0x2360