// File: fondoger[P]C0-Compiler/src/grammar.cpp
// Function: pArrayAssignmentStatement(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
static void pArrayAssignmentStatement(const std::string &id)
{
    TabEntry entry;

    assert(g_sym == LBRACK);
    if (!tabFind(id, entry)) {
        error(ERR_UNDEFINED_IDENTIFIER);
        return;
    }
    if (entry.itype != IT_ARRAY) {
        error(ERR_NOT_AN_ARRAY);
        return;
    }
    readSymbol(); // skip left bracket
    // handle index
    std::string index;    // index
    DataType index_dtype; // index's data type
    pExpression(index, index_dtype);
    if (index_dtype != DT_INT) {
        // array's index must be int type
        error(ERR_EXPECT_INT_ARRAY_INDEX);
    }
    // overflow check for const indexes
    int val;
    if (isConstValue(index, val) &&
        (val < 0 || val >= entry.value)) {
        error(ERR_ARRAY_INDEX_OVERFLOW);
    }
    readSymbol(); // skip right bracket
    test3(Symset({ BECOMES }));
    readSymbol(); // skip = 
    // handle right value
    std::string rvalue;
    DataType rvalue_dtype;
    pExpression(rvalue, rvalue_dtype);
    if (rvalue_dtype != entry.dtype) {
        error(ERR_TYPE_NOT_MATCH);
    }
    // generate middle code
    genMidCode(WARRAY, id, index, rvalue);
    test3(Symset({ SEMICOLON }));
    readSymbol();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdi, -0x8(%rbp)
leaq 0x2d0ba(%rip), %rax     # 0x4b6b0
cmpl $0x1f, (%rax)
jne 0x1e5fd
jmp 0x1e61c
leaq 0x1734d(%rip), %rdi     # 0x35951
leaq 0x16e1d(%rip), %rsi     # 0x35428
movl $0x1eb, %edx            # imm = 0x1EB
leaq 0x1734a(%rip), %rcx     # 0x35961
callq 0x3230
movq -0x8(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x2f100
testb $0x1, %al
jne 0x1e6a9
leaq -0x41(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x3570
movq -0x210(%rbp), %rdx
leaq 0x16f05(%rip), %rsi     # 0x35550
leaq -0x40(%rbp), %rdi
callq 0x3440
jmp 0x1e656
leaq -0x40(%rbp), %rdi
callq 0x18620
jmp 0x1e661
leaq -0x40(%rbp), %rdi
callq 0x35e8
leaq -0x41(%rbp), %rdi
callq 0x3370
jmp 0x1ec32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1e69b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x35e8
leaq -0x41(%rbp), %rdi
callq 0x3370
jmp 0x1ec53
cmpl $0x3, -0x18(%rbp)
je 0x1e72b
leaq -0x79(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x3570
movq -0x218(%rbp), %rdx
leaq 0x172c8(%rip), %rsi     # 0x35995
leaq -0x78(%rbp), %rdi
callq 0x3440
jmp 0x1e6d8
leaq -0x78(%rbp), %rdi
callq 0x18620
jmp 0x1e6e3
leaq -0x78(%rbp), %rdi
callq 0x35e8
leaq -0x79(%rbp), %rdi
callq 0x3370
jmp 0x1ec32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1e71d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x35e8
leaq -0x79(%rbp), %rdi
callq 0x3370
jmp 0x1ec53
callq 0x2e050
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x3450
movq -0x220(%rbp), %rdi
leaq -0xa4(%rbp), %rsi
callq 0x1f630
jmp 0x1e758
cmpl $0x1, -0xa4(%rbp)
je 0x1e804
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x3570
movq -0x228(%rbp), %rdx
leaq 0x17006(%rip), %rsi     # 0x3578c
leaq -0xc8(%rbp), %rdi
callq 0x3440
jmp 0x1e794
leaq -0xc8(%rbp), %rdi
callq 0x18620
jmp 0x1e7a2
leaq -0xc8(%rbp), %rdi
callq 0x35e8
leaq -0xc9(%rbp), %rdi
callq 0x3370
jmp 0x1e804
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1ec47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1e7f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x35e8
leaq -0xc9(%rbp), %rdi
callq 0x3370
jmp 0x1ec47
leaq -0xa0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x27780
movb %al, -0x229(%rbp)
jmp 0x1e81f
movb -0x229(%rbp), %al
testb $0x1, %al
jne 0x1e82e
jmp 0x1e8d4
cmpl $0x0, -0xd0(%rbp)
jl 0x1e846
movl -0xd0(%rbp), %eax
cmpl -0x10(%rbp), %eax
jl 0x1e8d4
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x3570
movq -0x238(%rbp), %rdx
leaq 0x16f46(%rip), %rsi     # 0x357ad
leaq -0xf0(%rbp), %rdi
callq 0x3440
jmp 0x1e875
leaq -0xf0(%rbp), %rdi
callq 0x18620
jmp 0x1e883
leaq -0xf0(%rbp), %rdi
callq 0x35e8
leaq -0xf1(%rbp), %rdi
callq 0x3370
jmp 0x1e8d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1e8c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x35e8
leaq -0xf1(%rbp), %rdi
callq 0x3370
jmp 0x1ec47
callq 0x2e050
jmp 0x1e8db
jmp 0x1e8dd
movl $0x23, -0x114(%rbp)
leaq -0x114(%rbp), %rax
movq %rax, -0x110(%rbp)
movq $0x1, -0x108(%rbp)
movq -0x110(%rbp), %rsi
movq -0x108(%rbp), %rdx
leaq -0x100(%rbp), %rdi
callq 0x227f0
jmp 0x1e91c
movl $0x22, -0x138(%rbp)
movl $0x26, -0x134(%rbp)
leaq -0x138(%rbp), %rax
movq %rax, -0x130(%rbp)
movq $0x2, -0x128(%rbp)
movq -0x130(%rbp), %rsi
movq -0x128(%rbp), %rdx
leaq -0x120(%rbp), %rdi
callq 0x227f0
jmp 0x1e965
movq -0x100(%rbp), %rdi
movq -0x120(%rbp), %rsi
callq 0x18170
jmp 0x1e97a
movl $0x23, -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 0x1e9b9
leaq 0x2ccf0(%rip), %rax     # 0x4b6b0
movl (%rax), %esi
leaq -0x140(%rbp), %rdi
callq 0x18b40
xorb $-0x1, %al
testb $0x1, %al
jne 0x1e9d6
jmp 0x1e9ec
callq 0x2e050
jmp 0x1e9dd
movl $0x1, -0x158(%rbp)
jmp 0x1ec26
jmp 0x1e9ee
jmp 0x1e9f0
callq 0x2e050
jmp 0x1e9f7
leaq -0x178(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x3450
movq -0x240(%rbp), %rdi
leaq -0x17c(%rbp), %rsi
callq 0x1f630
jmp 0x1ea1f
movl -0x17c(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x1eacd
leaq -0x1a1(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x3570
movq -0x248(%rbp), %rdx
leaq 0x16ac3(%rip), %rsi     # 0x35512
leaq -0x1a0(%rbp), %rdi
callq 0x3440
jmp 0x1ea5d
leaq -0x1a0(%rbp), %rdi
callq 0x18620
jmp 0x1ea6b
leaq -0x1a0(%rbp), %rdi
callq 0x35e8
leaq -0x1a1(%rbp), %rdi
callq 0x3370
jmp 0x1eacd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1ec3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1eabc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x35e8
leaq -0x1a1(%rbp), %rdi
callq 0x3370
jmp 0x1ec3b
movl $0xd, -0x1a8(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x1a8(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
leaq -0x178(%rbp), %rcx
callq 0x26340
jmp 0x1eaf7
jmp 0x1eaf9
movl $0x26, -0x1c4(%rbp)
leaq -0x1c4(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq $0x1, -0x1b8(%rbp)
movq -0x1c0(%rbp), %rsi
movq -0x1b8(%rbp), %rdx
leaq -0x1b0(%rbp), %rdi
callq 0x227f0
jmp 0x1eb38
movl $0x22, -0x1e8(%rbp)
movl $0x26, -0x1e4(%rbp)
leaq -0x1e8(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq $0x2, -0x1d8(%rbp)
movq -0x1e0(%rbp), %rsi
movq -0x1d8(%rbp), %rdx
leaq -0x1d0(%rbp), %rdi
callq 0x227f0
jmp 0x1eb81
movq -0x1b0(%rbp), %rdi
movq -0x1d0(%rbp), %rsi
callq 0x18170
jmp 0x1eb96
movl $0x26, -0x204(%rbp)
leaq -0x204(%rbp), %rax
movq %rax, -0x200(%rbp)
movq $0x1, -0x1f8(%rbp)
movq -0x200(%rbp), %rsi
movq -0x1f8(%rbp), %rdx
leaq -0x1f0(%rbp), %rdi
callq 0x227f0
jmp 0x1ebd5
leaq 0x2cad4(%rip), %rax     # 0x4b6b0
movl (%rax), %esi
leaq -0x1f0(%rbp), %rdi
callq 0x18b40
xorb $-0x1, %al
testb $0x1, %al
jne 0x1ebf2
jmp 0x1ec05
callq 0x2e050
jmp 0x1ebf9
movl $0x1, -0x158(%rbp)
jmp 0x1ec1a
jmp 0x1ec07
jmp 0x1ec09
callq 0x2e050
jmp 0x1ec10
movl $0x0, -0x158(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x35e8
leaq -0xa0(%rbp), %rdi
callq 0x35e8
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
leaq -0x178(%rbp), %rdi
callq 0x35e8
leaq -0xa0(%rbp), %rdi
callq 0x35e8
movq -0x50(%rbp), %rdi
callq 0x3560
nopl (%rax)