// File: /workspace/github_cpp_makefile_star2_O3/fondoger[P]C0-Compiler/src/grammar.cpp
// Function: pFactor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, DataType&)
static void pFactor(std::string &res, DataType &res_dtype)
{
    std::string id, temp_var;
    std::stringstream ss;
    TabEntry entry;
    DataType temp_dtype;
    // For conveniency, we assume all identifiers here are non-void-function-call
    test3(Symset({IDENTSY, CHARVALUE, LPARENT, PLUS, MINUS, INTVALUE}));
    switch (g_sym) {
        case IDENTSY:   id = g_id;
                        readSymbol(); 
                        if (!tabFind(id, entry)) {
                            // undefined identifier
                            error(ERR_UNDEFINED_IDENTIFIER);
                            return;
                        }
                        // entry.itype might be:
                        // IT_FUNCTION, IT_ARRAY, IT_VARIABLE, IT_CONST

                        // 1. handle functions
                        if (entry.itype == IT_FUNCTION) {
                            pNonVoidFunctionCall(res, res_dtype, id, entry);
                            return;
                        } else if (g_sym == LPARENT) { 
                            // use function call on a not-a-function identifier
                            error(ERR_NOT_A_FUNCTION);
                            return;
                        }
                        // 2. handle arrays
                        if (entry.itype == IT_ARRAY) {
                            pArrayRead(res, res_dtype, id, entry);
                            return;
                        }
                        assert(entry.itype == IT_CONST || entry.itype == IT_VARIABLE);
                        assert(entry.dtype == DT_CHAR || entry.dtype == DT_INT);
                        // 3. handle consts variable
                        if (entry.itype == IT_CONST) {
                            // return consts' character directly
                            if (entry.dtype == DT_CHAR) {
                                res_dtype = DT_CHAR;
                                ss << '\'' << (char)entry.value << '\'';
                            } else {
                                res_dtype = DT_INT;
                                ss << entry.value;
                            }
                            res = ss.str();
                        } 
                        // 4. handle normal variable (int or char)
                        else {
                            // return identifier directly
                            res = id;
                            res_dtype = entry.dtype;
                        }
                        break;
        case CHARVALUE: readSymbol();
                        ss << '\'' << g_char << '\'';
                        res = ss.str();
                        res_dtype = DT_CHAR;
                        break;
        case LPARENT:   readSymbol();
                        pExpression(res, temp_dtype);
                        res_dtype = DT_INT;           // ('p') should be convert to int
                        test3(Symset({RPARENT}));
                        readSymbol();
                        break;
        default:        pSignedInteger();  // a signed integer is stored at g_num
                        ss << g_num;
                        res = ss.str();
                        res_dtype = DT_INT;
                        break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x80(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x108(%rbp), %r13
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
leaq -0x2a0(%rbp), %rdi
callq 0x31f0
movups 0x9da4(%rip), %xmm0     # 0x1c2f0
leaq -0x50(%rbp), %rsi
movaps %xmm0, (%rsi)
movabsq $0x1100000014, %r12     # imm = 0x1100000014
movq %r12, 0x10(%rsi)
leaq -0xb0(%rbp), %rdi
movl $0x6, %edx
callq 0x13dee
movabsq $0x2600000022, %r15     # imm = 0x2600000022
leaq -0x58(%rbp), %rsi
movq %r15, (%rsi)
leaq -0xa8(%rbp), %rdi
movl $0x2, %edx
callq 0x13dee
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0xd8a2
leaq -0x50(%rbp), %rsi
movups 0x9d3e(%rip), %xmm0     # 0x1c2f0
movaps %xmm0, (%rsi)
movq %r12, 0x10(%rsi)
leaq -0x58(%rbp), %rdi
movl $0x6, %edx
callq 0x13dee
leaq 0x17062(%rip), %r12     # 0x29630
movl (%r12), %eax
movq -0x58(%rbp), %rcx
btq %rax, %rcx
jae 0x1276c
cmpl $0x1d, %eax
je 0x126f3
cmpl $0x10, %eax
je 0x1266a
testl %eax, %eax
jne 0x12776
leaq 0x1703b(%rip), %rsi     # 0x29638
leaq -0x90(%rbp), %rdi
callq 0x3160
callq 0x19d18
leaq -0x90(%rbp), %rdi
leaq -0x6c(%rbp), %rsi
callq 0x1a77d
testb %al, %al
je 0x127cc
movl -0x68(%rbp), %eax
cmpl $0x2, %eax
jne 0x12834
cmpl $0x0, -0x64(%rbp)
je 0x12899
leaq -0x90(%rbp), %rdi
callq 0x1a73b
movq %rax, %r15
cmpl $0x1d, (%r12)
jne 0x128c3
movq %r15, %rdi
callq 0x130e5
movq (%r15), %rax
movq 0x8(%r15), %rsi
jmp 0x12960
callq 0x19d18
leaq -0x290(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movb $0x27, (%rsi)
movl $0x1, %edx
callq 0x3340
leaq 0x16fca(%rip), %rcx     # 0x29658
movb (%rcx), %cl
leaq -0x50(%rbp), %rsi
movb %cl, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x3340
leaq -0x50(%rbp), %rsi
movb $0x27, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x3340
leaq -0x288(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3420
leaq -0x50(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3370
movq (%r15), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x126e7
callq 0x32a0
movl $0x2, (%r14)
jmp 0x12909
callq 0x19d18
leaq -0xb4(%rbp), %rsi
movq %rbx, %rdi
callq 0x11c82
movl $0x1, (%r14)
leaq -0x58(%rbp), %rsi
movl $0x1e, (%rsi)
leaq -0xa0(%rbp), %rdi
movl $0x1, %edx
callq 0x13dee
leaq -0x50(%rbp), %rsi
movq %r15, (%rsi)
leaq -0x98(%rbp), %rdi
movl $0x2, %edx
callq 0x13dee
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0xd8a2
leaq -0x58(%rbp), %rsi
movl $0x1e, (%rsi)
leaq -0x50(%rbp), %rdi
movl $0x1, %edx
callq 0x13dee
callq 0x19d18
jmp 0x12909
callq 0x1300e
leaq -0x290(%rbp), %rdi
leaq 0x16ed3(%rip), %rax     # 0x2965c
movl (%rax), %esi
callq 0x3470
leaq -0x288(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3420
leaq -0x50(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3370
movq (%r15), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x127c0
callq 0x32a0
movl $0x1, (%r14)
jmp 0x12909
leaq -0xe8(%rbp), %r14
movq %r14, -0x10(%r14)
leaq -0x50(%rbp), %rsi
movq $0x21, (%rsi)
leaq -0xf8(%rbp), %rdi
xorl %edx, %edx
callq 0x3490
leaq -0xf8(%rbp), %rdi
movq %rax, (%rdi)
movq -0x50(%rbp), %rcx
movq %rcx, 0x10(%rdi)
movups 0x9c1f(%rip), %xmm0     # 0x1c428
movups %xmm0, 0x10(%rax)
movups 0x9c04(%rip), %xmm0     # 0x1c418
movups %xmm0, (%rax)
movb $0x72, 0x20(%rax)
movq %rcx, 0x8(%rdi)
movb $0x0, (%rax,%rcx)
callq 0xdccb
movq -0xf8(%rbp), %rdi
jmp 0x128ff
cmpl $0x1d, (%r12)
jne 0x12878
leaq -0xc8(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x9bed(%rip), %rsi      # 0x1c43a
leaq 0x9c14(%rip), %rdx      # 0x1c468
leaq -0xd8(%rbp), %rdi
callq 0x14396
leaq -0xd8(%rbp), %rdi
callq 0xdccb
movq -0xd8(%rbp), %rdi
jmp 0x128ff
cmpl $0x3, %eax
jne 0x12a4e
leaq -0x90(%rbp), %rdx
leaq -0x6c(%rbp), %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12c13
jmp 0x12909
leaq -0x40(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x9c4f(%rip), %rsi      # 0x1c4f7
leaq 0x9c6e(%rip), %rdx      # 0x1c51d
leaq -0x50(%rbp), %rdi
callq 0x14396
leaq -0x50(%rbp), %rdi
callq 0xdccb
jmp 0x128fb
movq 0x8(%r15), %rax
movq %rax, %rsi
cmpq (%r15), %rax
je 0x12960
leaq -0x40(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x9c3c(%rip), %rsi      # 0x1c51e
leaq 0x9c5f(%rip), %rdx      # 0x1c548
leaq -0x50(%rbp), %rdi
callq 0x14396
leaq -0x50(%rbp), %rdi
callq 0xdccb
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x12909
callq 0x32a0
movq 0x10690(%rip), %rsi     # 0x22fa0
leaq -0x2a0(%rbp), %rdi
callq 0x3210
leaq -0x220(%rbp), %rdi
callq 0x30e0
movq -0x118(%rbp), %rdi
cmpq %r13, %rdi
je 0x12939
callq 0x32a0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x1294e
callq 0x32a0
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subq %rax, %rsi
movl $0xa, -0x58(%rbp)
sarq $0x2, %rsi
leaq -0x50(%rbp), %rdi
callq 0x13ec6
leaq 0x12602(%rip), %rcx     # 0x24f80
leaq -0x58(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x150ec
leaq -0x40(%rbp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x129a5
callq 0x32a0
leaq -0x50(%rbp), %rdi
callq 0x15bcf
leaq -0x50(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3370
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x129ca
callq 0x32a0
movl -0x64(%rbp), %eax
movl %eax, (%r14)
movl $0x17, -0x58(%rbp)
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
leaq 0x9c14(%rip), %rax      # 0x1c5fa
leaq 0x9943(%rip), %rsi      # 0x1c330
cmoveq %rax, %rsi
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
negq %rcx
leaq (%rsi,%rcx), %rdx
addq $0x4, %rdx
callq 0x14396
leaq 0x12571(%rip), %rcx     # 0x24f80
leaq -0x58(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rbx, %rdx
callq 0x150ec
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x12a2d
callq 0x32a0
leaq -0x50(%rbp), %rdi
movl $0xc, (%rdi)
leaq 0x12542(%rip), %rdx     # 0x24f80
movq %rdx, %rsi
movq %rbx, %rcx
callq 0x150ec
jmp 0x12909
cmpl $0x2, %eax
jae 0x12b17
movl -0x64(%rbp), %ecx
leal -0x1(%rcx), %edx
cmpl $0x2, %edx
jae 0x12b36
testl %eax, %eax
je 0x12a84
leaq -0x90(%rbp), %rsi
movq %rbx, %rdi
callq 0x3160
movl -0x64(%rbp), %eax
movl %eax, (%r14)
jmp 0x12909
leaq -0x290(%rbp), %rdi
cmpl $0x2, %ecx
jne 0x12ad4
movl $0x2, (%r14)
leaq -0x50(%rbp), %rsi
movb $0x27, (%rsi)
movl $0x1, %edx
callq 0x3340
movb -0x60(%rbp), %cl
leaq -0x50(%rbp), %rsi
movb %cl, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x3340
leaq -0x50(%rbp), %rsi
movb $0x27, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x3340
jmp 0x12ae3
movl $0x1, (%r14)
movl -0x60(%rbp), %esi
callq 0x3470
leaq -0x288(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3420
leaq -0x50(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3370
movq (%r14), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
jne 0x12904
jmp 0x12909
leaq 0x994b(%rip), %rdi      # 0x1c469
leaq 0x9864(%rip), %rsi      # 0x1c389
leaq 0x9973(%rip), %rcx      # 0x1c49f
movl $0x3bd, %edx            # imm = 0x3BD
callq 0x31b0
leaq 0x998a(%rip), %rdi      # 0x1c4c7
leaq 0x9845(%rip), %rsi      # 0x1c389
leaq 0x9954(%rip), %rcx      # 0x1c49f
movl $0x3be, %edx            # imm = 0x3BE
callq 0x31b0
jmp 0x12bc3
jmp 0x12b5b
jmp 0x12bc3
movq %rax, %rbx
movq -0x50(%rbp), %rdi
jmp 0x12ba0
jmp 0x12bc3
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
jne 0x12ba5
jmp 0x12bc6
jmp 0x12bc3
movq %rax, %rbx
leaq -0x40(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x12ba5
jmp 0x12bc6
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
jmp 0x12ba0
jmp 0x12bc3
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
cmpq %r14, %rdi
je 0x12bc6
callq 0x32a0
jmp 0x12bc6
jmp 0x12bc3
jmp 0x12bc3
jmp 0x12bc3
jmp 0x12bc3
jmp 0x12bc3
jmp 0x12bc3
jmp 0x12bc3
jmp 0x12bc3
movq %rax, %rbx
jmp 0x12be5
jmp 0x12bc3
movq %rax, %rbx
movq 0x103d3(%rip), %rsi     # 0x22fa0
leaq -0x2a0(%rbp), %rdi
callq 0x3210
leaq -0x220(%rbp), %rdi
callq 0x30e0
movq -0x118(%rbp), %rdi
cmpq %r13, %rdi
je 0x12bf6
callq 0x32a0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x12c0b
callq 0x32a0
movq %rbx, %rdi
callq 0x3480