// File: /workspace/github_cpp_makefile_star2_O1/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 0x16932(%rip), %rax     # 0x29630
cmpl $0x1f, (%rax)
je 0x12d77
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 0x98bd(%rip), %xmm0     # 0x1c5fe
movups %xmm0, (%rax)
movups 0x98c3(%rip), %xmm0     # 0x1c60e
movups %xmm0, 0x10(%rax)
movl $0x79617272, 0x1f(%rax) # imm = 0x79617272
movq %rcx, 0x8(%r14)
movb $0x0, (%rax,%rcx)
movq %r14, %rdi
callq 0xdcc8
movq -0x110(%rbp), %rdi
cmpq %r12, %rdi
je 0x12d77
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 0x13eac
movabsq $0x2600000022, %rax     # imm = 0x2600000022
leaq -0x78(%rbp), %rsi
movq %rax, (%rsi)
leaq -0xe8(%rbp), %r12
movl $0x2, %edx
movq %r12, %rdi
callq 0x13eac
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 0x13eac
movq (%r14), %rbx
leaq 0x16837(%rip), %rax     # 0x29630
movl (%rax), %r14d
callq 0x19e44
btq %r14, %rbx
jae 0x13059
leaq -0x68(%rbp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
leaq -0x78(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x11d47
cmpl $0x1, -0x58(%rbp)
movq %r15, %rbx
movq -0x90(%rbp), %r15
je 0x12eab
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 0x97b6(%rip), %xmm0     # 0x1c632
movups %xmm0, 0x10(%rax)
movups 0x979b(%rip), %xmm0     # 0x1c622
movups %xmm0, (%rax)
movq %rcx, 0x8(%rdi)
movq (%rdi), %rax
movb $0x0, (%rax,%rcx)
callq 0xdcc8
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x12eab
callq 0x32a0
leaq -0x78(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x16448
testb %al, %al
je 0x12f31
movl -0x54(%rbp), %eax
testl %eax, %eax
js 0x12ec9
cmpl 0xc(%r15), %eax
jl 0x12f31
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 0x973d(%rip), %xmm0     # 0x1c643
movups %xmm0, (%rax)
movl $0x776f6c66, 0x10(%rax) # imm = 0x776F6C66
movq %rcx, 0x8(%rdi)
movq (%rdi), %rax
movb $0x0, (%rax,%rcx)
callq 0xdcc8
movq -0xc0(%rbp), %rdi
cmpq %r14, %rdi
je 0x12f31
callq 0x32a0
leaq -0x50(%rbp), %rdi
callq 0x15c69
leaq -0x50(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3370
movq (%r14), %rdi
leaq -0x40(%rbp), %r14
cmpq %r14, %rdi
je 0x12f5a
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 0x96c2(%rip), %rax      # 0x1c63f
leaq 0x93ac(%rip), %rsi      # 0x1c330
cmoveq %rax, %rsi
leaq -0x50(%rbp), %rdi
movq %r14, (%rdi)
negq %rcx
leaq (%rsi,%rcx), %rdx
addq $0x4, %rdx
callq 0x14454
leaq 0x11fda(%rip), %rcx     # 0x24f80
leaq -0x2c(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rbx, %rdx
callq 0x151b0
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x12fc4
callq 0x32a0
leaq -0x50(%rbp), %rdi
movl $0xe, (%rdi)
leaq -0x78(%rbp), %rdx
movq -0x80(%rbp), %rsi
movq %rbx, %rcx
callq 0x151b0
leaq -0x2c(%rbp), %rsi
movl $0x20, (%rsi)
leaq -0xa0(%rbp), %rdi
movl $0x1, %edx
callq 0x13eac
leaq -0x50(%rbp), %rsi
movabsq $0x2600000022, %rax     # imm = 0x2600000022
movq %rax, (%rsi)
leaq -0x98(%rbp), %rdi
movl $0x2, %edx
callq 0x13eac
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 0x13eac
callq 0x19e44
movq -0x78(%rbp), %rdi
cmpq %r12, %rdi
je 0x13059
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 0x130a0
jmp 0x130b4
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
jmp 0x130a0
jmp 0x130b4
movq %rax, %rbx
movq -0x110(%rbp), %rdi
jmp 0x130bb
jmp 0x130b4
jmp 0x130b4
jmp 0x130b4
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x130b7
callq 0x32a0
jmp 0x130b7
jmp 0x130b4
jmp 0x130b4
jmp 0x130b4
jmp 0x130b4
movq %rax, %rbx
movq -0x78(%rbp), %rdi
cmpq %r12, %rdi
je 0x130c5
callq 0x32a0
movq %rbx, %rdi
callq 0x3480