// File: /workspace/github_cpp_makefile_star2_O3/CoinXu[P]reviser-compiler/src/parser.cpp
// Function: reviser::compiler::Parser::ConsumeDeclare()
Declare* Parser::ConsumeDeclare() {
    // data type & data type array
    if (Accept(TOKEN_DATA_TYPE)) {
      const string type = PreviousText();
      if (Accept(TOKEN_LEFT_BRACKET)) {
        return ConsumeDataTypeArrayDeclare(type);
      }
      return ConsumeDataTypeDeclare();
    }

    // struct & struct array
    // enum & enum array
    if (Accept(TOKEN_ID)) {
      // TODO support struct array type
      const Token type_id = tokenizer->Previous();
      const string id = type_id.text;
      DeclareType type = generator->descriptor->FindContextVariableTypeById(id);

      if (Accept(TOKEN_LEFT_BRACKET)) {
        if (type == DECLARE_STRUCT) {
          return ConsumeStructArrayDeclare(type_id);
        }

        if (type == DECLARE_ENUM) {
          return ConsumeEnumArrayDeclare(type_id);
        }

        RuntimeError("unknow array type [" + id + "]");
        return nullptr;
      }

      if (type == DECLARE_STRUCT) {
        return ConsumeStructDeclare();
      }

      if (type == DECLARE_ENUM) {
        return ConsumeEnumDeclare();
      }

      if (type == DECLARE_UNDEFINED) {
        RuntimeError("undefined type [" + id + "]");
        return nullptr;
      }

      RuntimeError("unknow type [" + id + "]");
      return nullptr;
    }

    RuntimeError("unexpected token");
    return nullptr;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, %rbx
xorl %esi, %esi
callq 0x2b86e
testb %al, %al
je 0x2c9b3
movq (%rbx), %rdi
callq 0x2f19e
leaq -0xf8(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
addq %rsi, %rdx
leaq -0x108(%rbp), %rdi
callq 0x290da
movq %rbx, %rdi
movl $0x5b, %esi
callq 0x2b86e
testb %al, %al
je 0x2cafc
leaq -0x138(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0x108(%rbp), %rsi
movq -0x100(%rbp), %rdx
addq %rsi, %rdx
leaq -0x148(%rbp), %rdi
callq 0x290da
leaq -0x148(%rbp), %rsi
movq %rbx, %rdi
callq 0x2ce24
movq %rax, %rbx
movq -0x148(%rbp), %rdi
cmpq %r15, %rdi
je 0x2cb07
callq 0x24320
jmp 0x2cb07
movq %rbx, %rdi
movl $0x4, %esi
callq 0x2b86e
testb %al, %al
je 0x2cab2
movq (%rbx), %rdi
callq 0x2f19e
movq %rax, %r14
movl (%rax), %eax
leaq -0x100(%rbp), %rdi
movl %eax, -0x8(%rdi)
leaq -0xf0(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
addq %rsi, %rdx
callq 0x290da
movq 0x38(%r14), %rax
movq %rax, 0x20(%r15)
movups 0x28(%r14), %xmm0
movups %xmm0, 0x10(%r15)
leaq -0x58(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x10(%r15), %rsi
movq -0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %rdi
callq 0x290da
movq 0x8(%rbx), %rax
movq 0x50(%rax), %r14
leaq -0x118(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
leaq -0x128(%rbp), %rdi
callq 0x290da
leaq -0x128(%rbp), %rsi
movq %r14, %rdi
callq 0x32bd4
movl %eax, %r14d
movq -0x128(%rbp), %rdi
cmpq %r13, %rdi
je 0x2ca76
callq 0x24320
movq %rbx, %rdi
movl $0x5b, %esi
callq 0x2b86e
testb %al, %al
je 0x2cb2d
testl %r14d, %r14d
je 0x2cb57
cmpl $0x1, %r14d
jne 0x2cb6b
leaq -0x108(%rbp), %rsi
movq %rbx, %rdi
callq 0x2d790
jmp 0x2cc23
leaq -0x158(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x22aef(%rip), %rsi     # 0x4f5b3
leaq 0x22af8(%rip), %rdx     # 0x4f5c3
leaq -0x168(%rbp), %r14
movq %r14, %rdi
callq 0x29178
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2c2d2
movq -0x168(%rbp), %rdi
cmpq %r15, %rdi
je 0x2caf8
callq 0x24320
xorl %ebx, %ebx
jmp 0x2cb18
movq %rbx, %rdi
callq 0x2cfe2
movq %rax, %rbx
movq -0x108(%rbp), %rdi
cmpq %r14, %rdi
je 0x2cb18
callq 0x24320
movq %rbx, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r14d, %r14d
je 0x2cc1b
cmpl $0x2, %r14d
je 0x2cbc3
cmpl $0x1, %r14d
jne 0x2cc2b
movq %rbx, %rdi
callq 0x2d99c
jmp 0x2cc23
leaq -0x108(%rbp), %rsi
movq %rbx, %rdi
callq 0x2d954
jmp 0x2cd3c
leaq 0x22a0e(%rip), %rsi     # 0x4f580
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x2b4b3
leaq 0x23e9c(%rip), %rsi     # 0x50a22
leaq -0x48(%rbp), %rdi
callq 0x24650
leaq -0xb8(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2cc7a
movq %rdx, -0xc8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xb8(%rbp)
jmp 0x2cc81
leaq 0x229ca(%rip), %rsi     # 0x4f594
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x2b4b3
leaq 0x23e44(%rip), %rsi     # 0x50a22
leaq -0x48(%rbp), %rdi
callq 0x24650
leaq -0x98(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2ccb2
movq %rdx, -0xa8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x98(%rbp)
jmp 0x2ccb9
movq %rbx, %rdi
callq 0x2dc70
movq %rax, %rbx
jmp 0x2cd3e
leaq 0x22973(%rip), %rsi     # 0x4f5a5
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x2b4b3
leaq 0x23ddc(%rip), %rsi     # 0x50a22
leaq -0x48(%rbp), %rdi
callq 0x24650
leaq -0x78(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2ccea
movq %rdx, -0x88(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x78(%rbp)
jmp 0x2ccf1
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq -0xc8(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2c2d2
movq -0xc8(%rbp), %rdi
jmp 0x2cd20
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq -0xa8(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2c2d2
movq -0xa8(%rbp), %rdi
jmp 0x2cd20
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq -0x88(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2c2d2
movq -0x88(%rbp), %rdi
cmpq %r14, %rdi
je 0x2cd2a
callq 0x24320
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2cd3c
callq 0x24320
xorl %ebx, %ebx
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x2cd4c
callq 0x24320
movq -0x100(%rbp), %rdi
cmpq %r15, %rdi
jne 0x2cb13
jmp 0x2cb18
movq %rax, %rbx
movq -0x88(%rbp), %rdi
jmp 0x2cd8b
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
jmp 0x2cd8b
jmp 0x2cd97
jmp 0x2cd97
jmp 0x2cde8
jmp 0x2cde8
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
cmpq %r14, %rdi
je 0x2cd9a
callq 0x24320
jmp 0x2cd9a
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x2cdba
jmp 0x2cdeb
jmp 0x2cde8
movq %rax, %rbx
movq -0x128(%rbp), %rdi
cmpq %r13, %rdi
je 0x2cdeb
callq 0x24320
jmp 0x2cdeb
movq %rax, %rbx
movq -0x148(%rbp), %rdi
cmpq %r15, %rdi
je 0x2ce15
callq 0x24320
jmp 0x2ce15
movq %rax, %rbx
movq -0x168(%rbp), %rdi
jmp 0x2ce00
movq %rax, %rbx
jmp 0x2cdf9
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x2cdf9
callq 0x24320
movq -0x100(%rbp), %rdi
cmpq %r15, %rdi
je 0x2ce0a
callq 0x24320
movq %rbx, %rdi
callq 0x245f0
movq %rax, %rbx
movq -0x108(%rbp), %rdi
cmpq %r14, %rdi
jne 0x2ce05
jmp 0x2ce0a
nop