// File: /workspace/github_cpp_makefile_star2_O3/fondoger[P]C0-Compiler/src/grammar.cpp
// Function: pArrayRead(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, DataType&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, _TabEntry const&)
static void pArrayRead(std::string &res, DataType &res_dtype,
        const std::string &id, const TabEntry &entry)
{
    if (g_sym != LBRACK) {
        error(ERR_EXPECT_ARRAY_ELEMENT);
    }
    test3(Symset({LBRACK}));
    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);
    }
    res = genTempVar();
    res_dtype = entry.dtype;
    genMidCode(TEMP, (res_dtype == DT_INT ? "int": "char"), res, NONE);
    genMidCode(RARRAY, id, index, res);
    test3(Symset({RBRACK}));
    readSymbol();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rcx, %r15
movq %rdx, -0x80(%rbp)
movq %rsi, -0x88(%rbp)
movq %rdi, %rbx
leaq 0x169f1(%rip), %rax     # 0x29630
cmpl $0x1f, (%rax)
je 0x12cb8
leaq -0x100(%rbp), %r12
movq %r12, -0x10(%r12)
leaq -0x78(%rbp), %r13
movq $0x23, (%r13)
leaq -0x110(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x3490
movq %rax, (%r14)
movq (%r13), %rcx
movq %rcx, 0x10(%r14)
movups 0x9937(%rip), %xmm0     # 0x1c5b9
movups %xmm0, (%rax)
movups 0x993d(%rip), %xmm0     # 0x1c5c9
movups %xmm0, 0x10(%rax)
movl $0x79617272, 0x1f(%rax) # imm = 0x79617272
movq %rcx, 0x8(%r14)
movb $0x0, (%rax,%rcx)
movq %r14, %rdi
callq 0xdccb
movq -0x110(%rbp), %rdi
cmpq %r12, %rdi
je 0x12cb8
callq 0x32a0
movq %r15, -0x90(%rbp)
movq %rbx, %r15
movl $0x1f, %ebx
leaq -0x50(%rbp), %r13
movl %ebx, (%r13)
leaq -0xf0(%rbp), %r14
movl $0x1, %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x13dee
movabsq $0x2600000022, %rax     # imm = 0x2600000022
leaq -0x78(%rbp), %rsi
movq %rax, (%rsi)
leaq -0xe8(%rbp), %r12
movl $0x2, %edx
movq %r12, %rdi
callq 0x13dee
movq (%r14), %rdi
movq (%r12), %rsi
callq 0xd8a2
movl %ebx, (%r13)
leaq -0x78(%rbp), %r14
leaq -0x50(%rbp), %rsi
movl $0x1, %edx
movq %r14, %rdi
callq 0x13dee
movq (%r14), %rbx
leaq 0x168f6(%rip), %rax     # 0x29630
movl (%rax), %r14d
callq 0x19d18
btq %r14, %rbx
jae 0x12f9a
leaq -0x68(%rbp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
leaq -0x78(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x11c82
cmpl $0x1, -0x58(%rbp)
movq %r15, %rbx
movq -0x90(%rbp), %r15
je 0x12dec
leaq -0xd0(%rbp), %r14
movq %r14, -0x10(%r14)
leaq -0x50(%rbp), %rsi
movq $0x20, (%rsi)
leaq -0xe0(%rbp), %rdi
xorl %edx, %edx
callq 0x3490
leaq -0xe0(%rbp), %rdi
movq %rax, (%rdi)
movq -0x50(%rbp), %rcx
movq %rcx, 0x10(%rdi)
movups 0x9830(%rip), %xmm0     # 0x1c5ed
movups %xmm0, 0x10(%rax)
movups 0x9815(%rip), %xmm0     # 0x1c5dd
movups %xmm0, (%rax)
movq %rcx, 0x8(%rdi)
movq (%rdi), %rax
movb $0x0, (%rax,%rcx)
callq 0xdccb
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x12dec
callq 0x32a0
leaq -0x78(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x163ae
testb %al, %al
je 0x12e72
movl -0x54(%rbp), %eax
testl %eax, %eax
js 0x12e0a
cmpl 0xc(%r15), %eax
jl 0x12e72
leaq -0xb0(%rbp), %r14
movq %r14, -0x10(%r14)
leaq -0x50(%rbp), %rsi
movq $0x14, (%rsi)
leaq -0xc0(%rbp), %rdi
xorl %edx, %edx
callq 0x3490
leaq -0xc0(%rbp), %rdi
movq %rax, (%rdi)
movq -0x50(%rbp), %rcx
movq %rcx, 0x10(%rdi)
movups 0x97b7(%rip), %xmm0     # 0x1c5fe
movups %xmm0, (%rax)
movl $0x776f6c66, 0x10(%rax) # imm = 0x776F6C66
movq %rcx, 0x8(%rdi)
movq (%rdi), %rax
movb $0x0, (%rax,%rcx)
callq 0xdccb
movq -0xc0(%rbp), %rdi
cmpq %r14, %rdi
je 0x12e72
callq 0x32a0
leaq -0x50(%rbp), %rdi
callq 0x15bcf
leaq -0x50(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3370
movq (%r14), %rdi
leaq -0x40(%rbp), %r14
cmpq %r14, %rdi
je 0x12e9b
callq 0x32a0
movl 0x8(%r15), %eax
movq -0x88(%rbp), %rcx
movl %eax, (%rcx)
movl $0x17, -0x2c(%rbp)
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
leaq 0x973c(%rip), %rax      # 0x1c5fa
leaq 0x946b(%rip), %rsi      # 0x1c330
cmoveq %rax, %rsi
leaq -0x50(%rbp), %rdi
movq %r14, (%rdi)
negq %rcx
leaq (%rsi,%rcx), %rdx
addq $0x4, %rdx
callq 0x14396
leaq 0x12099(%rip), %rcx     # 0x24f80
leaq -0x2c(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rbx, %rdx
callq 0x150ec
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x12f05
callq 0x32a0
leaq -0x50(%rbp), %rdi
movl $0xe, (%rdi)
leaq -0x78(%rbp), %rdx
movq -0x80(%rbp), %rsi
movq %rbx, %rcx
callq 0x150ec
leaq -0x2c(%rbp), %rsi
movl $0x20, (%rsi)
leaq -0xa0(%rbp), %rdi
movl $0x1, %edx
callq 0x13dee
leaq -0x50(%rbp), %rsi
movabsq $0x2600000022, %rax     # imm = 0x2600000022
movq %rax, (%rsi)
leaq -0x98(%rbp), %rdi
movl $0x2, %edx
callq 0x13dee
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0xd8a2
leaq -0x2c(%rbp), %rsi
movl $0x20, (%rsi)
leaq -0x50(%rbp), %rdi
movl $0x1, %edx
callq 0x13dee
callq 0x19d18
movq -0x78(%rbp), %rdi
cmpq %r12, %rdi
je 0x12f9a
callq 0x32a0
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
jmp 0x12fe1
jmp 0x12ff5
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
jmp 0x12fe1
jmp 0x12ff5
movq %rax, %rbx
movq -0x110(%rbp), %rdi
jmp 0x12ffc
jmp 0x12ff5
jmp 0x12ff5
jmp 0x12ff5
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x12ff8
callq 0x32a0
jmp 0x12ff8
jmp 0x12ff5
jmp 0x12ff5
jmp 0x12ff5
jmp 0x12ff5
movq %rax, %rbx
movq -0x78(%rbp), %rdi
cmpq %r12, %rdi
je 0x13006
callq 0x32a0
movq %rbx, %rdi
callq 0x3480