// File: CoinXu[P]reviser-compiler/src/parser.cpp
// Function: reviser::compiler::Parser::ConsumeStructArrayDeclare(reviser::compiler::Token const&)
Declare* Parser::ConsumeStructArrayDeclare(const Token& struct_id) {
    Expect(TOKEN_RIGHT_BRACKET);
    Expect(TOKEN_ID);

    Token* sid = CloneToken(struct_id);
    Token* id = CloneToken(token);
    StructValue* sv;

    if (Accept(TOKEN_ASSIGN)) {
      if (Accept(TOKEN_LEFT_BRACKET)) {
        Expect(TOKEN_RIGHT_BRACKET);
        // TODO make TYPE_EMPTY_ARRAY type for data type
        sv = new StructValue(sid, CloneToken(token));
      } else {
        delete sid;
        delete id;
        RuntimeError("unknow struct array default value");
      }
    } else {
      sv = new StructValue(sid, nullptr);
    }

    generator->descriptor->include_struct_array = true;
    RightValue* rv = new RightValue(sv, true);
    return new Declare(TYPE_STRUCT, id, sid, rv, true);
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x70(%rbp)
movl $0x5d, %esi
callq 0xa83a0
movq -0x70(%rbp), %rdi
movl $0x4, %esi
callq 0xa83a0
movq -0x70(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xa81f0
movq -0x70(%rbp), %rdi
movq %rax, -0x18(%rbp)
movq %rdi, %rsi
addq $0x10, %rsi
callq 0xa81f0
movq -0x70(%rbp), %rdi
movq %rax, -0x20(%rbp)
movl $0x3d, %esi
callq 0xa75f0
testb $0x1, %al
jne 0xa9daf
jmp 0xa9f1b
movq -0x70(%rbp), %rdi
movl $0x5b, %esi
callq 0xa75f0
testb $0x1, %al
jne 0xa9dc6
jmp 0xa9e46
movq -0x70(%rbp), %rdi
movl $0x5d, %esi
callq 0xa83a0
movl $0x10, %edi
callq 0x99480
movq -0x70(%rbp), %rdi
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
movq %rdi, %rsi
addq $0x10, %rsi
callq 0xa81f0
movq %rax, -0x78(%rbp)
jmp 0xa9e03
movq -0x78(%rbp), %rdx
movq -0x80(%rbp), %rsi
movq -0x88(%rbp), %rdi
callq 0xb3470
jmp 0xa9e19
movq -0x88(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0xa9f19
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x99440
jmp 0xaa024
movq -0x18(%rbp), %rax
movq %rax, -0x90(%rbp)
cmpq $0x0, %rax
je 0xa9e6f
movq -0x90(%rbp), %rdi
callq 0xa0bf0
movq -0x90(%rbp), %rdi
callq 0x99440
movq -0x20(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
je 0xa9e98
movq -0x98(%rbp), %rdi
callq 0xa0bf0
movq -0x98(%rbp), %rdi
callq 0x99440
leaq -0x59(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x99850
movq -0xa0(%rbp), %rdx
leaq 0x55830(%rip), %rsi     # 0xff6e6
leaq -0x58(%rbp), %rdi
callq 0x99640
jmp 0xa9ec1
movq -0x70(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x58(%rbp), %rsi
callq 0xa82a0
jmp 0xa9ed4
leaq -0x58(%rbp), %rdi
callq 0x992c0
leaq -0x59(%rbp), %rdi
callq 0x994f0
jmp 0xa9f19
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa9f0b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x992c0
leaq -0x59(%rbp), %rdi
callq 0x994f0
jmp 0xaa024
jmp 0xa9f6b
movl $0x10, %edi
callq 0x99480
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xb3470
jmp 0xa9f41
movq -0xa8(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0xa9f6b
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x99440
jmp 0xaa024
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x50(%rax), %rax
movb $0x1, 0x61(%rax)
movl $0x58, %edi
callq 0x99480
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb0(%rbp)
movq -0x28(%rbp), %rsi
movl $0x1, %edx
callq 0xb3380
jmp 0xa9fa2
movq -0xb0(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x20, %edi
callq 0x99480
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x68(%rbp), %r8
movl $0xa, %esi
movl $0x1, %r9d
callq 0xb3580
jmp 0xa9fe2
movq -0xb8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x99440
jmp 0xaa024
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x99440
movq -0x30(%rbp), %rdi
callq 0x99840
nopl (%rax)