// File: /workspace/github_cpp_makefile_star2_O1/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 0x9cdb(%rip), %xmm0     # 0x1c2ec
leaq -0x50(%rbp), %rsi
movaps %xmm0, (%rsi)
movabsq $0x1100000014, %r12     # imm = 0x1100000014
movq %r12, 0x10(%rsi)
leaq -0xb0(%rbp), %rdi
movl $0x6, %edx
callq 0x13eac
movabsq $0x2600000022, %r15     # imm = 0x2600000022
leaq -0x58(%rbp), %rsi
movq %r15, (%rsi)
leaq -0xa8(%rbp), %rdi
movl $0x2, %edx
callq 0x13eac
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0xd8a2
leaq -0x50(%rbp), %rsi
movups 0x9c75(%rip), %xmm0     # 0x1c2ec
movaps %xmm0, (%rsi)
movq %r12, 0x10(%rsi)
leaq -0x58(%rbp), %rdi
movl $0x6, %edx
callq 0x13eac
leaq 0x16f9d(%rip), %r12     # 0x29630
movl (%r12), %eax
movq -0x58(%rbp), %rcx
btq %rax, %rcx
jae 0x1282a
cmpl $0x1d, %eax
je 0x127b1
cmpl $0x10, %eax
je 0x12728
testl %eax, %eax
jne 0x12834
leaq 0x16f76(%rip), %rsi     # 0x29638
leaq -0x90(%rbp), %rdi
callq 0x3160
callq 0x19e44
leaq -0x90(%rbp), %rdi
leaq -0x6c(%rbp), %rsi
callq 0x1a8c5
testb %al, %al
je 0x1288a
movl -0x68(%rbp), %eax
cmpl $0x2, %eax
jne 0x128f2
cmpl $0x0, -0x64(%rbp)
je 0x12957
leaq -0x90(%rbp), %rdi
callq 0x1a883
movq %rax, %r15
cmpl $0x1d, (%r12)
jne 0x12981
movq %r15, %rdi
callq 0x131a4
jmp 0x12a1b
callq 0x19e44
leaq -0x290(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movb $0x27, (%rsi)
movl $0x1, %edx
callq 0x3340
leaq 0x16f0c(%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 0x127a5
callq 0x32a0
movl $0x2, (%r14)
jmp 0x129c4
callq 0x19e44
leaq -0xb4(%rbp), %rsi
movq %rbx, %rdi
callq 0x11d47
movl $0x1, (%r14)
leaq -0x58(%rbp), %rsi
movl $0x1e, (%rsi)
leaq -0xa0(%rbp), %rdi
movl $0x1, %edx
callq 0x13eac
leaq -0x50(%rbp), %rsi
movq %r15, (%rsi)
leaq -0x98(%rbp), %rdi
movl $0x2, %edx
callq 0x13eac
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 0x13eac
callq 0x19e44
jmp 0x129c4
callq 0x130cd
leaq -0x290(%rbp), %rdi
leaq 0x16e15(%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 0x1287e
callq 0x32a0
movl $0x1, (%r14)
jmp 0x129c4
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 0x9ba6(%rip), %xmm0     # 0x1c46d
movups %xmm0, 0x10(%rax)
movups 0x9b8b(%rip), %xmm0     # 0x1c45d
movups %xmm0, (%rax)
movb $0x72, 0x20(%rax)
movq %rcx, 0x8(%rdi)
movb $0x0, (%rax,%rcx)
callq 0xdcc8
movq -0xf8(%rbp), %rdi
jmp 0x129ba
cmpl $0x1d, (%r12)
jne 0x12936
leaq -0xc8(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x9b74(%rip), %rsi      # 0x1c47f
leaq 0x9b9b(%rip), %rdx      # 0x1c4ad
leaq -0xd8(%rbp), %rdi
callq 0x14454
leaq -0xd8(%rbp), %rdi
callq 0xdcc8
movq -0xd8(%rbp), %rdi
jmp 0x129ba
cmpl $0x3, %eax
jne 0x12b0d
leaq -0x90(%rbp), %rdx
leaq -0x6c(%rbp), %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12cd2
jmp 0x129c4
leaq -0x40(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x9bd6(%rip), %rsi      # 0x1c53c
leaq 0x9bf5(%rip), %rdx      # 0x1c562
leaq -0x50(%rbp), %rdi
callq 0x14454
leaq -0x50(%rbp), %rdi
callq 0xdcc8
jmp 0x129b6
movq 0x8(%r15), %rax
cmpq (%r15), %rax
je 0x12a1b
leaq -0x40(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x9bc6(%rip), %rsi      # 0x1c563
leaq 0x9be9(%rip), %rdx      # 0x1c58d
leaq -0x50(%rbp), %rdi
callq 0x14454
leaq -0x50(%rbp), %rdi
callq 0xdcc8
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x129c4
callq 0x32a0
movq 0x105d5(%rip), %rsi     # 0x22fa0
leaq -0x2a0(%rbp), %rdi
callq 0x3210
leaq -0x220(%rbp), %rdi
callq 0x30e0
movq -0x118(%rbp), %rdi
cmpq %r13, %rdi
je 0x129f4
callq 0x32a0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x12a09
callq 0x32a0
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xa, -0x58(%rbp)
movq 0x8(%r15), %rsi
subq (%r15), %rsi
sarq $0x2, %rsi
leaq -0x50(%rbp), %rdi
callq 0x13f84
leaq 0x12543(%rip), %rcx     # 0x24f80
leaq -0x58(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x151b0
leaq -0x40(%rbp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x12a64
callq 0x32a0
leaq -0x50(%rbp), %rdi
callq 0x15c69
leaq -0x50(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3370
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x12a89
callq 0x32a0
movl -0x64(%rbp), %eax
movl %eax, (%r14)
movl $0x17, -0x58(%rbp)
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
leaq 0x9b9a(%rip), %rax      # 0x1c63f
leaq 0x9884(%rip), %rsi      # 0x1c330
cmoveq %rax, %rsi
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
negq %rcx
leaq (%rsi,%rcx), %rdx
addq $0x4, %rdx
callq 0x14454
leaq 0x124b2(%rip), %rcx     # 0x24f80
leaq -0x58(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rbx, %rdx
callq 0x151b0
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x12aec
callq 0x32a0
leaq -0x50(%rbp), %rdi
movl $0xc, (%rdi)
leaq 0x12483(%rip), %rdx     # 0x24f80
movq %rdx, %rsi
movq %rbx, %rcx
callq 0x151b0
jmp 0x129c4
cmpl $0x2, %eax
jae 0x12bd6
movl -0x64(%rbp), %ecx
leal -0x1(%rcx), %edx
cmpl $0x2, %edx
jae 0x12bf5
testl %eax, %eax
je 0x12b43
leaq -0x90(%rbp), %rsi
movq %rbx, %rdi
callq 0x3160
movl -0x64(%rbp), %eax
movl %eax, (%r14)
jmp 0x129c4
leaq -0x290(%rbp), %rdi
cmpl $0x2, %ecx
jne 0x12b93
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 0x12ba2
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 0x129bf
jmp 0x129c4
leaq 0x98d1(%rip), %rdi      # 0x1c4ae
leaq 0x97a5(%rip), %rsi      # 0x1c389
leaq 0x98f9(%rip), %rcx      # 0x1c4e4
movl $0x3bd, %edx            # imm = 0x3BD
callq 0x31b0
leaq 0x9910(%rip), %rdi      # 0x1c50c
leaq 0x9786(%rip), %rsi      # 0x1c389
leaq 0x98da(%rip), %rcx      # 0x1c4e4
movl $0x3be, %edx            # imm = 0x3BE
callq 0x31b0
jmp 0x12c82
jmp 0x12c1a
jmp 0x12c82
movq %rax, %rbx
movq -0x50(%rbp), %rdi
jmp 0x12c5f
jmp 0x12c82
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
jne 0x12c64
jmp 0x12c85
jmp 0x12c82
movq %rax, %rbx
leaq -0x40(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x12c64
jmp 0x12c85
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
jmp 0x12c5f
jmp 0x12c82
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
cmpq %r14, %rdi
je 0x12c85
callq 0x32a0
jmp 0x12c85
jmp 0x12c82
jmp 0x12c82
jmp 0x12c82
jmp 0x12c82
jmp 0x12c82
jmp 0x12c82
jmp 0x12c82
jmp 0x12c82
movq %rax, %rbx
jmp 0x12ca4
jmp 0x12c82
movq %rax, %rbx
movq 0x10314(%rip), %rsi     # 0x22fa0
leaq -0x2a0(%rbp), %rdi
callq 0x3210
leaq -0x220(%rbp), %rdi
callq 0x30e0
movq -0x118(%rbp), %rdi
cmpq %r13, %rdi
je 0x12cb5
callq 0x32a0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x12cca
callq 0x32a0
movq %rbx, %rdi
callq 0x3480