// File: 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
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3450
leaq 0x2c05d(%rip), %rax     # 0x4b6b0
cmpl $0x13, (%rax)
je 0x1f668
leaq 0x2c051(%rip), %rax     # 0x4b6b0
cmpl $0x14, (%rax)
jne 0x1f8fa
leaq 0x2c041(%rip), %rax     # 0x4b6b0
movl (%rax), %eax
subl $0x14, %eax
sete -0x35(%rbp)
callq 0x2e050
jmp 0x1f67f
testb $0x1, -0x35(%rbp)
je 0x1f88b
leaq -0x30(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x1fb70
jmp 0x1f698
leaq -0x30(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x27780
movb %al, -0x17a(%rbp)
jmp 0x1f6ad
movb -0x17a(%rbp), %al
testb $0x1, %al
jne 0x1f6b9
jmp 0x1f6ff
movl -0x48(%rbp), %esi
negl %esi
leaq -0x68(%rbp), %rdi
callq 0x22950
jmp 0x1f6c9
movq -0x8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x33d0
leaq -0x68(%rbp), %rdi
callq 0x35e8
movq -0x10(%rbp), %rax
movl $0x1, (%rax)
jmp 0x1f889
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1fb5a
leaq -0x88(%rbp), %rdi
callq 0x271d0
jmp 0x1f70d
movq -0x8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movq %rsi, -0x190(%rbp)
callq 0x33d0
movq -0x190(%rbp), %rdi
callq 0x35e8
movq -0x10(%rbp), %rax
movl $0x1, (%rax)
movl $0x17, -0x8c(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x3570
movq -0x188(%rbp), %rdx
leaq 0x16044(%rip), %rsi     # 0x357a9
leaq -0xb0(%rbp), %rdi
callq 0x3440
jmp 0x1f773
movq -0x8(%rbp), %rdx
leaq 0x27882(%rip), %rcx     # 0x47000
leaq -0x8c(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x26340
jmp 0x1f793
leaq -0xb0(%rbp), %rdi
callq 0x35e8
leaq -0xb1(%rbp), %rdi
callq 0x3370
movl $0x2, -0xb8(%rbp)
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x3570
movq -0x198(%rbp), %rdx
leaq 0x16625(%rip), %rsi     # 0x35dfb
leaq -0xd8(%rbp), %rdi
callq 0x3440
jmp 0x1f7e4
movq -0x8(%rbp), %rcx
leaq -0xb8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x26340
jmp 0x1f801
leaq -0xd8(%rbp), %rdi
callq 0x35e8
leaq -0xd9(%rbp), %rdi
callq 0x3370
jmp 0x1f889
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f841
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x35e8
leaq -0xb1(%rbp), %rdi
callq 0x3370
jmp 0x1fb5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f878
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x35e8
leaq -0xd9(%rbp), %rdi
callq 0x3370
jmp 0x1fb5a
jmp 0x1f8f8
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1fb70
jmp 0x1f89a
movq -0x8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x27780
movb %al, -0x199(%rbp)
jmp 0x1f8b2
movb -0x199(%rbp), %al
testb $0x1, %al
jne 0x1f8be
jmp 0x1f8ee
movl -0xe0(%rbp), %esi
leaq -0x100(%rbp), %rdi
callq 0x22950
jmp 0x1f8d2
movq -0x8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x33d0
leaq -0x100(%rbp), %rdi
callq 0x35e8
movq -0x10(%rbp), %rax
movl $0x1, (%rax)
jmp 0x1f90b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1fb70
jmp 0x1f909
jmp 0x1f90b
jmp 0x1f90d
movb $0x1, %al
leaq 0x2bd9a(%rip), %rcx     # 0x4b6b0
cmpl $0x13, (%rcx)
movb %al, -0x19a(%rbp)
je 0x1f934
leaq 0x2bd88(%rip), %rax     # 0x4b6b0
cmpl $0x14, (%rax)
sete %al
movb %al, -0x19a(%rbp)
movb -0x19a(%rbp), %al
testb $0x1, %al
jne 0x1f943
jmp 0x1fb48
leaq 0x2bd66(%rip), %rax     # 0x4b6b0
movl (%rax), %eax
subl $0x13, %eax
setne %al
movzbl %al, %eax
incl %eax
movl %eax, -0x104(%rbp)
callq 0x2e050
jmp 0x1f964
leaq -0x30(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x1fb70
jmp 0x1f973
movq -0x8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x27780
movb %al, -0x19b(%rbp)
jmp 0x1f98b
movb -0x19b(%rbp), %al
testb $0x1, %al
jne 0x1f99a
jmp 0x1fa2c
leaq -0x30(%rbp), %rdi
leaq -0x10c(%rbp), %rsi
callq 0x27780
movb %al, -0x19c(%rbp)
jmp 0x1f9b2
movb -0x19c(%rbp), %al
testb $0x1, %al
jne 0x1f9be
jmp 0x1fa2c
cmpl $0x1, -0x104(%rbp)
jne 0x1f9db
movl -0x108(%rbp), %eax
addl -0x10c(%rbp), %eax
movl %eax, -0x1a0(%rbp)
jmp 0x1f9ed
movl -0x108(%rbp), %eax
subl -0x10c(%rbp), %eax
movl %eax, -0x1a0(%rbp)
movl -0x1a0(%rbp), %esi
leaq -0x130(%rbp), %rdi
callq 0x22950
jmp 0x1fa01
movq -0x8(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x33d0
leaq -0x130(%rbp), %rdi
callq 0x35e8
movq -0x10(%rbp), %rax
movl $0x1, (%rax)
jmp 0x1fb43
leaq -0x150(%rbp), %rdi
callq 0x271d0
jmp 0x1fa3a
movl $0x17, -0x154(%rbp)
leaq -0x179(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x3570
movq -0x1a8(%rbp), %rdx
leaq 0x15d44(%rip), %rsi     # 0x357a9
leaq -0x178(%rbp), %rdi
callq 0x3440
jmp 0x1fa73
leaq 0x27586(%rip), %rcx     # 0x47000
leaq -0x154(%rbp), %rdi
leaq -0x178(%rbp), %rsi
leaq -0x150(%rbp), %rdx
callq 0x26340
jmp 0x1fa96
leaq -0x178(%rbp), %rdi
callq 0x35e8
leaq -0x179(%rbp), %rdi
callq 0x3370
movq -0x8(%rbp), %rsi
leaq -0x104(%rbp), %rdi
leaq -0x30(%rbp), %rdx
leaq -0x150(%rbp), %rcx
callq 0x26340
jmp 0x1facb
movq -0x8(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x3040
jmp 0x1fadd
movq -0x10(%rbp), %rax
movl $0x1, (%rax)
leaq -0x150(%rbp), %rdi
callq 0x35e8
jmp 0x1fb43
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1fb1b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x35e8
leaq -0x179(%rbp), %rdi
callq 0x3370
jmp 0x1fb35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x35e8
jmp 0x1fb5a
jmp 0x1f90d
leaq -0x30(%rbp), %rdi
callq 0x35e8
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x35e8
movq -0x40(%rbp), %rdi
callq 0x3560
nopl (%rax)