// File: /workspace/github_cpp_makefile_star2_O2/fondoger[P]C0-Compiler/src/grammar.cpp
// Function: pExpression(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, DataType&)
static void pExpression(std::string &res, DataType &res_dtype)
{
    std::string temp_var;
    DataType temp_dtype;
    if (g_sym == PLUS || g_sym == MINUS) {
        bool isMinus = (g_sym == MINUS);
        readSymbol();
        if (isMinus) {
            pTerm(temp_var, temp_dtype); // no use of tempvar_dtype
            int val;
            if (isConstValue(temp_var, val)) {
                res = std::to_string(-val);
                res_dtype = DT_INT;
            } else {
                res = genTempVar();
                res_dtype = DT_INT;
                genMidCode(TEMP, "int", res, NONE);
                genMidCode(SUB, "0", temp_var, res);
            }
        } else {
            // no need to generate code for '+'
            pTerm(res, res_dtype);
            int t;
            if (isConstValue(res, t)) {
                res = std::to_string(t);
            }
            res_dtype = DT_INT;
        }
    } else {
        pTerm(res, res_dtype);
    }
    while (g_sym == PLUS || g_sym == MINUS) {
        OpCode op = (g_sym == PLUS ? ADD : SUB);
        readSymbol();
        pTerm(temp_var, temp_dtype); // no use of tempvar_dtype
        int t1, t2;
        if (isConstValue(res, t1) && isConstValue(temp_var, t2)) {
            // if both operands ares const value, we can calculate it
            res = std::to_string( op == ADD ? t1 + t2 : t1 - t2 );
            res_dtype = DT_INT;
        }
        else {
            std::string new_res = genTempVar();
            genMidCode(TEMP, "int", new_res, NONE);
            genMidCode(op, res, temp_var, new_res);
            res = new_res;
            res_dtype = DT_INT;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x80, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x70(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x16e22(%rip), %r12     # 0x24610
movl (%r12), %r15d
leal -0x13(%r15), %eax
cmpl $0x1, %eax
ja 0xd83d
callq 0x13808
cmpl $0x14, %r15d
jne 0xd84d
leaq -0x80(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0xdab0
leaq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x10a5d
testb %al, %al
je 0xd883
xorl %esi, %esi
subl -0xa0(%rbp), %esi
leaq -0x50(%rbp), %rdi
callq 0xef70
jmp 0xd957
movq %r14, %rdi
movq %rbx, %rsi
callq 0xdab0
jmp 0xd974
movq %r14, %rdi
movq %rbx, %rsi
callq 0xdab0
leaq -0xa0(%rbp), %rsi
movq %r14, %rdi
callq 0x10a5d
testb %al, %al
je 0xd96e
movl -0xa0(%rbp), %esi
leaq -0x50(%rbp), %rdi
callq 0xef70
jmp 0xd957
leaq -0x50(%rbp), %rdi
callq 0x1065a
leaq -0x50(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x3310
movq %r15, %rdi
callq 0x3498
movl $0x1, (%rbx)
movl $0x17, -0x24(%rbp)
leaq 0x8d9e(%rip), %rsi      # 0x16655
leaq -0x50(%rbp), %rdi
leaq -0x28(%rbp), %rdx
callq 0x30f0
leaq 0x12695(%rip), %rcx     # 0x1ff60
leaq -0x24(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %r14, %rdx
callq 0x100d0
leaq -0x50(%rbp), %rdi
callq 0x3498
movl $0x2, -0x24(%rbp)
leaq 0x92ad(%rip), %rsi      # 0x16b9f
leaq -0x50(%rbp), %rdi
leaq -0x28(%rbp), %rdx
callq 0x30f0
leaq -0x24(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x80(%rbp), %rdx
movq %r14, %rcx
callq 0x100d0
jmp 0xd94c
jmp 0xda8c
jmp 0xda9c
jmp 0xda8c
jmp 0xda9c
jmp 0xda9c
jmp 0xda9c
jmp 0xda9c
jmp 0xda9c
jmp 0xda9c
jmp 0xda9c
jmp 0xda9c
leaq -0x50(%rbp), %rdi
callq 0x3498
jmp 0xd974
leaq -0x50(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x3310
movq %r15, %rdi
callq 0x3498
movl $0x1, (%rbx)
movl (%r12), %eax
leal -0x13(%rax), %ecx
cmpl $0x1, %ecx
ja 0xda5c
xorl %ecx, %ecx
cmpl $0x13, %eax
setne %cl
incl %ecx
movl %ecx, -0x24(%rbp)
callq 0x13808
leaq -0x80(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0xdab0
leaq -0x28(%rbp), %rsi
movq %r14, %rdi
callq 0x10a5d
testb %al, %al
je 0xd9e3
leaq -0x80(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x10a5d
testb %al, %al
je 0xd9e3
movl -0x58(%rbp), %eax
movl %eax, %esi
negl %esi
cmpl $0x1, -0x24(%rbp)
cmovel %eax, %esi
addl -0x28(%rbp), %esi
leaq -0x50(%rbp), %rdi
callq 0xef70
jmp 0xd957
leaq -0x50(%rbp), %rdi
callq 0x1065a
movl $0x17, -0x54(%rbp)
leaq 0x8c5b(%rip), %rsi      # 0x16655
leaq -0xa0(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x30f0
leaq 0x1254f(%rip), %rcx     # 0x1ff60
leaq -0x54(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x100d0
leaq -0xa0(%rbp), %rdi
callq 0x3498
leaq -0x24(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq -0x50(%rbp), %rcx
movq %r14, %rsi
callq 0x100d0
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x3160
movl $0x1, (%rbx)
jmp 0xd94c
leaq -0x80(%rbp), %rdi
callq 0x3498
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0xda9c
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x3498
jmp 0xda8f
jmp 0xda9c
jmp 0xda8c
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3498
jmp 0xda9f
jmp 0xda9c
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x3498
movq %rbx, %rdi
callq 0x3430