// File: /workspace/github_cpp_makefile_star2_O2/Mespyr[P]bop-lisp/src/parser.cpp
// Function: read_next(Reader&)
Node read_next(Reader& reader) 
{
    Token token = reader.next();


    // Detect EOF and raise error
    if (reader.eof == true) 
    {
        reader.error = ParsingError{"Unexpected EOF while parsing.", token};
        reader.error_found = true;
        return Node{ATOM};
    }

    if (token.value == "(") 
    {
        Node node{LIST};
        token = reader.peek();
        while (token.value != ")")
        {
            node.nodes.push_back(read_next(reader));
            if (reader.eof == true) 
            {
                reader.error = ParsingError{"Unexpected EOF while parsing.", token};
                reader.error_found = true;
                return node;
            }
            token = reader.peek();
        }
        reader.next();
        return node;
    } 
    else if (token.value == ")") 
    {
        reader.error = ParsingError{"Unexpected ')' token found while parsing.", token};
        reader.error_found = true;
        return Node{ATOM};
    } 

    Node node{ATOM};
    node.atom = create_atom(token);
    return node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x58(%rbp), %rdi
callq 0xbd00
cmpb $0x1, 0x1c(%r14)
jne 0xb7c4
leaq 0x2746(%rip), %rsi      # 0xde81
leaq -0xc8(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x294e
leaq -0xa8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x9f10
xorl %r12d, %r12d
leaq -0xc8(%rbp), %r15
movb %r12b, 0x48(%r15)
leaq 0x20(%r14), %rdi
movq %r15, %rsi
callq 0xbd4c
movq %r15, %rdi
callq 0xb226
movb $0x1, 0x70(%r14)
movl $0x1, (%rbx)
leaq 0x30(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
andq $0x0, 0x18(%rbx)
movq %rax, 0x20(%rbx)
andq $0x0, 0x28(%rbx)
movb %r12b, 0x30(%rbx)
andq $0x0, 0x40(%rbx)
andl $0x0, 0x48(%rbx)
leaq 0x60(%rbx), %rax
movq %rax, 0x50(%rbx)
andq $0x0, 0x58(%rbx)
movb %r12b, 0x60(%rbx)
jmp 0xb9e3
leaq -0x50(%rbp), %r15
leaq 0x26b0(%rip), %rsi      # 0xde7f
movq %r15, %rdi
callq 0x998e
testb %al, %al
je 0xb8b4
andl $0x0, (%rbx)
leaq 0x30(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
andq $0x0, 0x18(%rbx)
movq %rax, 0x20(%rbx)
andq $0x0, 0x28(%rbx)
xorl %eax, %eax
movb %al, 0x30(%rbx)
andq $0x0, 0x40(%rbx)
andl $0x0, 0x48(%rbx)
leaq 0x60(%rbx), %rcx
movq %rcx, 0x50(%rbx)
andq $0x0, 0x58(%rbx)
movb %al, 0x60(%rbx)
leaq -0xc8(%rbp), %rdi
movq %r14, %rsi
callq 0xbd7a
leaq 0x8(%rbx), %r12
leaq -0x58(%rbp), %rdi
leaq -0xc8(%rbp), %r15
movq %r15, %rsi
callq 0xbda8
leaq -0xc0(%rbp), %rdi
callq 0x2130
leaq 0x2506(%rip), %r13      # 0xdd58
leaq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x9ba0
testb %al, %al
je 0xb8f3
movq %r15, %rdi
movq %r14, %rsi
callq 0xb706
movq %r12, %rdi
movq %r15, %rsi
callq 0xc0e4
movq %r15, %rdi
callq 0x99c0
cmpb $0x1, 0x1c(%r14)
je 0xb997
movq %r15, %rdi
movq %r14, %rsi
callq 0xbd7a
leaq -0x58(%rbp), %rdi
movq %r15, %rsi
callq 0xbda8
leaq -0xc0(%rbp), %rdi
callq 0x2130
jmp 0xb852
leaq 0x249d(%rip), %rsi      # 0xdd58
movq %r15, %rdi
callq 0x998e
testb %al, %al
je 0xb90e
leaq 0x25d1(%rip), %rsi      # 0xde9f
leaq -0xc8(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x294e
leaq -0xa8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x9f10
jmp 0xb75b
leaq -0x118(%rbp), %rdi
movq %r14, %rsi
callq 0xbd00
leaq -0x110(%rbp), %rdi
jmp 0xb990
movl $0x1, (%rbx)
leaq 0x30(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
andq $0x0, 0x18(%rbx)
movq %rax, 0x20(%rbx)
andq $0x0, 0x28(%rbx)
xorl %eax, %eax
movb %al, 0x30(%rbx)
andq $0x0, 0x40(%rbx)
andl $0x0, 0x48(%rbx)
leaq 0x60(%rbx), %rcx
movq %rcx, 0x50(%rbx)
andq $0x0, 0x58(%rbx)
movb %al, 0x60(%rbx)
leaq -0xf0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x9f10
leaq -0xc8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xb658
leaq 0x20(%rbx), %rdi
leaq -0xc8(%rbp), %r14
movq %r14, %rsi
callq 0xbdcc
movq %r14, %rdi
callq 0x996e
leaq -0xe8(%rbp), %rdi
callq 0x2130
jmp 0xb9e3
leaq 0x24e3(%rip), %rsi      # 0xde81
leaq -0xc8(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x294e
leaq -0xa8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x9f10
leaq -0xc8(%rbp), %r15
movb $0x0, 0x48(%r15)
leaq 0x20(%r14), %rdi
movq %r15, %rsi
callq 0xbd4c
movq %r15, %rdi
callq 0xb226
movb $0x1, 0x70(%r14)
leaq -0x50(%rbp), %rdi
callq 0x2130
movq %rbx, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0xc8(%rbp), %rdi
jmp 0xba19
jmp 0xba55
movq %rax, %r14
leaq -0xe8(%rbp), %rdi
callq 0x2130
jmp 0xba58
jmp 0xba2a
jmp 0xba55
jmp 0xba3b
jmp 0xba55
jmp 0xba55
movq %rax, %r14
leaq -0xc8(%rbp), %rdi
callq 0x2130
jmp 0xba60
movq %rax, %r14
jmp 0xba60
jmp 0xba55
jmp 0xba55
movq %rax, %r14
leaq -0xc8(%rbp), %rdi
callq 0x99c0
jmp 0xba58
movq %rax, %r14
movq %rbx, %rdi
callq 0x99c0
leaq -0x50(%rbp), %rdi
callq 0x2130
movq %r14, %rdi
callq 0x2380