// File: fondoger[P]C0-Compiler/src/grammar.cpp
// Function: pGlobalVariableDefinitionItem(DataType, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
static void pGlobalVariableDefinitionItem(DataType dtype, std::string id) 
{
    if (dtype == DT_VOID) {
        error(ERR_WRONG_VARIABLE_TYPE);
    }
    std::string type_str = (dtype == DT_INT ? "int": "char");
    while (true) {
        // g_sym always points to the one after identifier
        if (g_sym == LBRACK) {       // array definition
            readSymbol(); // skip left bracket
            test3(Symset({INTVALUE}));
            int array_size = g_num;
            assert(g_num >= 0);
            if (array_size == 0) {
                error(ERR_ARRAY_SIZE_ZERO);
            }
            TabEntry entry = { GLOBAL, IT_ARRAY, dtype, array_size, -1 };
            tabInsert(id, entry);
            genMidCode(GVAR, type_str, id, std::to_string(array_size));
            readSymbol(); // skip size number
            test3(Symset({RBRACK}));
            readSymbol(); 
        } else {                    // normal variable definition
            TabEntry entry = { GLOBAL, IT_VARIABLE, dtype, -1, -1 };
            tabInsert(id, entry);
            genMidCode(GVAR, type_str, id, NONE);
        }
        if (g_sym != COMMA) {
            break;
        }
        readSymbol();
        test3(Symset({IDENTSY}));
        id = g_id;
        readSymbol();
    }
    test3(Symset({SEMICOLON}));
    readSymbol();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rsi, -0x278(%rbp)
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x1acb8
leaq -0x31(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x3570
movq -0x280(%rbp), %rdx
leaq 0x1ae1f(%rip), %rsi     # 0x35a7c
leaq -0x30(%rbp), %rdi
callq 0x3440
jmp 0x1ac68
leaq -0x30(%rbp), %rdi
callq 0x18620
jmp 0x1ac73
leaq -0x30(%rbp), %rdi
callq 0x35e8
leaq -0x31(%rbp), %rdi
callq 0x3370
jmp 0x1acb8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1acaa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x35e8
leaq -0x31(%rbp), %rdi
callq 0x3370
jmp 0x1b3ff
movl -0x4(%rbp), %eax
subl $0x1, %eax
leaq 0x1aae4(%rip), %rcx     # 0x357a9
leaq 0x1a3e7(%rip), %rax     # 0x350b3
cmoveq %rcx, %rax
movq %rax, -0x290(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0x3570
movq -0x290(%rbp), %rsi
movq -0x288(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x3440
jmp 0x1ad00
leaq -0x69(%rbp), %rdi
callq 0x3370
jmp 0x1ad0b
leaq 0x3099e(%rip), %rax     # 0x4b6b0
cmpl $0x1f, (%rax)
jne 0x1b101
callq 0x2e050
jmp 0x1ad22
jmp 0x1ad24
movl $0x11, -0x8c(%rbp)
leaq -0x8c(%rbp), %rax
movq %rax, -0x88(%rbp)
movq $0x1, -0x80(%rbp)
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
leaq -0x78(%rbp), %rdi
callq 0x227f0
jmp 0x1ad5a
movl $0x22, -0xb0(%rbp)
movl $0x26, -0xac(%rbp)
leaq -0xb0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq $0x2, -0xa0(%rbp)
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
leaq -0x98(%rbp), %rdi
callq 0x227f0
jmp 0x1ada3
movq -0x78(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x18170
jmp 0x1adb5
movl $0x11, -0xcc(%rbp)
leaq -0xcc(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq $0x1, -0xc0(%rbp)
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
callq 0x227f0
jmp 0x1adf4
leaq 0x308b5(%rip), %rax     # 0x4b6b0
movl (%rax), %esi
leaq -0xb8(%rbp), %rdi
callq 0x18b40
xorb $-0x1, %al
testb $0x1, %al
jne 0x1ae11
jmp 0x1ae52
callq 0x2e050
jmp 0x1ae18
movl $0x1, -0xd0(%rbp)
jmp 0x1b3e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x3370
jmp 0x1b3ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1b3f6
jmp 0x1ae54
jmp 0x1ae56
leaq 0x3087f(%rip), %rax     # 0x4b6dc
movl (%rax), %eax
movl %eax, -0xd4(%rbp)
leaq 0x30870(%rip), %rax     # 0x4b6dc
cmpl $0x0, (%rax)
jl 0x1ae73
jmp 0x1ae92
leaq 0x1ac20(%rip), %rdi     # 0x35a9a
leaq 0x1a5a7(%rip), %rsi     # 0x35428
movl $0x2cd, %edx            # imm = 0x2CD
leaq 0x1ac18(%rip), %rcx     # 0x35aa5
callq 0x3230
cmpl $0x0, -0xd4(%rbp)
jne 0x1af2d
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x3570
movq -0x298(%rbp), %rdx
leaq 0x1ac1f(%rip), %rsi     # 0x35adf
leaq -0xf8(%rbp), %rdi
callq 0x3440
jmp 0x1aece
leaq -0xf8(%rbp), %rdi
callq 0x18620
jmp 0x1aedc
leaq -0xf8(%rbp), %rdi
callq 0x35e8
leaq -0xf9(%rbp), %rdi
callq 0x3370
jmp 0x1af2d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1af1c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x35e8
leaq -0xf9(%rbp), %rdi
callq 0x3370
jmp 0x1b3f6
movq -0x278(%rbp), %rdi
movl $0x0, -0x110(%rbp)
movl $0x3, -0x10c(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x108(%rbp)
movl -0xd4(%rbp), %eax
movl %eax, -0x104(%rbp)
movl $0xffffffff, -0x100(%rbp) # imm = 0xFFFFFFFF
leaq -0x110(%rbp), %rsi
callq 0x2f430
jmp 0x1af75
movl $0x7, -0x114(%rbp)
movl -0xd4(%rbp), %esi
leaq -0x138(%rbp), %rdi
callq 0x22950
jmp 0x1af93
movq -0x278(%rbp), %rdx
leaq -0x114(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x138(%rbp), %rcx
callq 0x26340
jmp 0x1afb3
leaq -0x138(%rbp), %rdi
callq 0x35e8
callq 0x2e050
jmp 0x1afc6
jmp 0x1afc8
movl $0x20, -0x154(%rbp)
leaq -0x154(%rbp), %rax
movq %rax, -0x150(%rbp)
movq $0x1, -0x148(%rbp)
movq -0x150(%rbp), %rsi
movq -0x148(%rbp), %rdx
leaq -0x140(%rbp), %rdi
callq 0x227f0
jmp 0x1b007
movl $0x22, -0x178(%rbp)
movl $0x26, -0x174(%rbp)
leaq -0x178(%rbp), %rax
movq %rax, -0x170(%rbp)
movq $0x2, -0x168(%rbp)
movq -0x170(%rbp), %rsi
movq -0x168(%rbp), %rdx
leaq -0x160(%rbp), %rdi
callq 0x227f0
jmp 0x1b050
movq -0x140(%rbp), %rdi
movq -0x160(%rbp), %rsi
callq 0x18170
jmp 0x1b065
movl $0x20, -0x194(%rbp)
leaq -0x194(%rbp), %rax
movq %rax, -0x190(%rbp)
movq $0x1, -0x188(%rbp)
movq -0x190(%rbp), %rsi
movq -0x188(%rbp), %rdx
leaq -0x180(%rbp), %rdi
callq 0x227f0
jmp 0x1b0a4
leaq 0x30605(%rip), %rax     # 0x4b6b0
movl (%rax), %esi
leaq -0x180(%rbp), %rdi
callq 0x18b40
xorb $-0x1, %al
testb $0x1, %al
jne 0x1b0c1
jmp 0x1b0f4
callq 0x2e050
jmp 0x1b0c8
movl $0x1, -0xd0(%rbp)
jmp 0x1b3e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x35e8
jmp 0x1b3f6
jmp 0x1b0f6
jmp 0x1b0f8
callq 0x2e050
jmp 0x1b0ff
jmp 0x1b173
movq -0x278(%rbp), %rdi
movl $0x0, -0x1a8(%rbp)
movl $0x1, -0x1a4(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x1a0(%rbp)
movl $0xffffffff, -0x19c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x198(%rbp) # imm = 0xFFFFFFFF
leaq -0x1a8(%rbp), %rsi
callq 0x2f430
jmp 0x1b147
movq -0x278(%rbp), %rdx
movl $0x7, -0x1ac(%rbp)
leaq 0x2bea1(%rip), %rcx     # 0x47000
leaq -0x1ac(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x26340
jmp 0x1b171
jmp 0x1b173
leaq 0x30536(%rip), %rax     # 0x4b6b0
cmpl $0x24, (%rax)
je 0x1b184
jmp 0x1b2c1
callq 0x2e050
jmp 0x1b18b
jmp 0x1b18d
movl $0x0, -0x1cc(%rbp)
leaq -0x1cc(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq $0x1, -0x1c0(%rbp)
movq -0x1c8(%rbp), %rsi
movq -0x1c0(%rbp), %rdx
leaq -0x1b8(%rbp), %rdi
callq 0x227f0
jmp 0x1b1cc
movl $0x22, -0x1f0(%rbp)
movl $0x26, -0x1ec(%rbp)
leaq -0x1f0(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq $0x2, -0x1e0(%rbp)
movq -0x1e8(%rbp), %rsi
movq -0x1e0(%rbp), %rdx
leaq -0x1d8(%rbp), %rdi
callq 0x227f0
jmp 0x1b215
movq -0x1b8(%rbp), %rdi
movq -0x1d8(%rbp), %rsi
callq 0x18170
jmp 0x1b22a
movl $0x0, -0x20c(%rbp)
leaq -0x20c(%rbp), %rax
movq %rax, -0x208(%rbp)
movq $0x1, -0x200(%rbp)
movq -0x208(%rbp), %rsi
movq -0x200(%rbp), %rdx
leaq -0x1f8(%rbp), %rdi
callq 0x227f0
jmp 0x1b269
leaq 0x30440(%rip), %rax     # 0x4b6b0
movl (%rax), %esi
leaq -0x1f8(%rbp), %rdi
callq 0x18b40
xorb $-0x1, %al
testb $0x1, %al
jne 0x1b286
jmp 0x1b29c
callq 0x2e050
jmp 0x1b28d
movl $0x1, -0xd0(%rbp)
jmp 0x1b3e4
jmp 0x1b29e
jmp 0x1b2a0
movq -0x278(%rbp), %rdi
leaq 0x3040a(%rip), %rsi     # 0x4b6b8
callq 0x3040
jmp 0x1b2b5
callq 0x2e050
jmp 0x1b2bc
jmp 0x1ad09
jmp 0x1b2c3
movl $0x26, -0x22c(%rbp)
leaq -0x22c(%rbp), %rax
movq %rax, -0x228(%rbp)
movq $0x1, -0x220(%rbp)
movq -0x228(%rbp), %rsi
movq -0x220(%rbp), %rdx
leaq -0x218(%rbp), %rdi
callq 0x227f0
jmp 0x1b302
movl $0x22, -0x250(%rbp)
movl $0x26, -0x24c(%rbp)
leaq -0x250(%rbp), %rax
movq %rax, -0x248(%rbp)
movq $0x2, -0x240(%rbp)
movq -0x248(%rbp), %rsi
movq -0x240(%rbp), %rdx
leaq -0x238(%rbp), %rdi
callq 0x227f0
jmp 0x1b34b
movq -0x218(%rbp), %rdi
movq -0x238(%rbp), %rsi
callq 0x18170
jmp 0x1b360
movl $0x26, -0x26c(%rbp)
leaq -0x26c(%rbp), %rax
movq %rax, -0x268(%rbp)
movq $0x1, -0x260(%rbp)
movq -0x268(%rbp), %rsi
movq -0x260(%rbp), %rdx
leaq -0x258(%rbp), %rdi
callq 0x227f0
jmp 0x1b39f
leaq 0x3030a(%rip), %rax     # 0x4b6b0
movl (%rax), %esi
leaq -0x258(%rbp), %rdi
callq 0x18b40
xorb $-0x1, %al
testb $0x1, %al
jne 0x1b3bc
jmp 0x1b3cf
callq 0x2e050
jmp 0x1b3c3
movl $0x1, -0xd0(%rbp)
jmp 0x1b3e4
jmp 0x1b3d1
jmp 0x1b3d3
callq 0x2e050
jmp 0x1b3da
movl $0x0, -0xd0(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x35e8
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x35e8
movq -0x40(%rbp), %rdi
callq 0x3560
nopl (%rax,%rax)