// File: /workspace/github_cpp_makefile_star2_O1/Eronana[P]strawberry/src/ast_codegen.cpp
// Function: AST_BinaryOperationExpression::codeGen(Symbol*)
DEF_AST_METHOD(BinaryOperationExpression,AST_CODEGEN)
{
    auto optype=GET_LITERAL(optr).type;
    int label;
    if(optype==TOKEN_LOGIC_AND)
    {
        label=nextLabel();
        PRINTF("dup\n");
        PRINTF("istrue\n");
        PRINTF("jmp label_%d\n",label);
        PRINTF("pop\n");
    }
    else if(optype==TOKEN_LOGIC_OR)
    {
        label=nextLabel();
        PRINTF("dup\n");
        PRINTF("isfalse\n");
        PRINTF("jmp label_%d\n",label);
        PRINTF("pop\n");
    }
    bool isIdentifier=is_identifier(expr);
    if(isIdentifier)loadVariant(symbol,expr);
    else CODEGEN(expr);
    switch(optype)
    {
        case TOKEN_MUL:
            PRINTF("mul\n");
            break;
        case TOKEN_DIV:
            PRINTF("div\n");
            break;
        case TOKEN_MOD:
            PRINTF("mod\n");
            break;
        case TOKEN_ADD:
            PRINTF("add\n");
            break;
        case TOKEN_SUB:
            PRINTF("sub\n");
            break;
        case TOKEN_BITWISE_AND:
            PRINTF("band\n");
            break;
        case TOKEN_BITWISE_XOR:
            PRINTF("xor\n");
            break;
        case TOKEN_BITWISE_OR:
            PRINTF("bor\n");
            break;
        case TOKEN_LEFT_SHIFT:
            PRINTF("shl\n");
            break;
        case TOKEN_RIGHT_SHIFT:
            PRINTF("shr\n");
            break;
        case TOKEN_LESS:
            PRINTF("less\n");
            break;
        case TOKEN_GREATER:
            PRINTF("gt\n");
            break;
        case TOKEN_LESS_EQUAL:
            PRINTF("le\n");
            break;
        case TOKEN_GREATER_EQUAL:
            PRINTF("ge\n");
            break;
        case TOKEN_EQUAL:
            PRINTF("eq\n");
            break;
        case TOKEN_INEQUAL:
            PRINTF("ieq\n");
            break;
        case TOKEN_LOGIC_AND:
        case TOKEN_LOGIC_OR:
            PRINTF("label_%d:\n",label);
            break;
        default:
            break;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x10(%rdi), %rax
movl 0x8(%rax), %r12d
cmpl $0x14, %r12d
je 0x1df8d
cmpl $0x17, %r12d
jne 0x1e01c
callq 0xdb8f
incl 0x11bde(%rip)           # 0x2fb30
movl %eax, %ebx
leaq 0x118ad(%rip), %r13     # 0x2f808
movq (%r13), %rcx
leaq 0x3694(%rip), %rdi      # 0x215fa
movl $0x4, %esi
movl $0x1, %edx
callq 0x64b0
incl 0x11bb5(%rip)           # 0x2fb30
movq (%r13), %rcx
leaq 0x36fb(%rip), %rdi      # 0x21681
movl $0x7, %esi
jmp 0x1dfd1
callq 0xdb8f
incl 0x11b98(%rip)           # 0x2fb30
movl %eax, %ebx
leaq 0x11867(%rip), %r13     # 0x2f808
movq (%r13), %rcx
leaq 0x364e(%rip), %rdi      # 0x215fa
movl $0x4, %esi
movl $0x1, %edx
callq 0x64b0
incl 0x11b6f(%rip)           # 0x2fb30
movq (%r13), %rcx
leaq 0x36cb(%rip), %rdi      # 0x21697
movl $0x8, %esi
movl $0x1, %edx
callq 0x64b0
incl 0x11b4f(%rip)           # 0x2fb30
leaq 0x11820(%rip), %r13     # 0x2f808
movq (%r13), %rdi
leaq 0x3696(%rip), %rsi      # 0x21689
movl %ebx, %edx
xorl %eax, %eax
callq 0x6390
incl 0x11b2e(%rip)           # 0x2fb30
movq (%r13), %rcx
leaq 0x35de(%rip), %rdi      # 0x215eb
movl $0x4, %esi
movl $0x1, %edx
callq 0x64b0
leaq 0x8(%r15), %rdi
callq 0x1d4b2
movq 0x8(%r15), %rsi
testb %al, %al
je 0x1e042
addq $0x18, %rsi
leaq 0x37dc(%rip), %rdx      # 0x21814
movq %r14, %rdi
callq 0x1d3a4
jmp 0x1e04e
movq (%rsi), %rax
movq %rsi, %rdi
movq %r14, %rsi
callq *0x18(%rax)
addl $-0x4, %r12d
cmpl $0x24, %r12d
ja 0x1e175
leaq 0x3455(%rip), %rax      # 0x214b8
movslq (%rax,%r12,4), %rcx
addq %rax, %rcx
jmpq *%rcx
incl 0x11abe(%rip)           # 0x2fb30
leaq 0x1178f(%rip), %rax     # 0x2f808
movq (%rax), %rdi
leaq 0x3667(%rip), %rsi      # 0x216ea
movl %ebx, %edx
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x6390
incl 0x11a95(%rip)           # 0x2fb30
leaq 0x11766(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x362d(%rip), %rdi      # 0x216d9
jmp 0x1e231
incl 0x11a79(%rip)           # 0x2fb30
leaq 0x1174a(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x361d(%rip), %rdi      # 0x216e5
jmp 0x1e1fa
incl 0x11a5d(%rip)           # 0x2fb30
leaq 0x1172e(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x35c6(%rip), %rdi      # 0x216aa
jmp 0x1e1fa
incl 0x11a41(%rip)           # 0x2fb30
leaq 0x11712(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x35ce(%rip), %rdi      # 0x216ce
jmp 0x1e1fa
incl 0x11a25(%rip)           # 0x2fb30
leaq 0x116f6(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3598(%rip), %rdi      # 0x216b4
jmp 0x1e1fa
incl 0x11a09(%rip)           # 0x2fb30
leaq 0x116da(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x35ae(%rip), %rdi      # 0x216e6
jmp 0x1e231
incl 0x119ed(%rip)           # 0x2fb30
leaq 0x116be(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3551(%rip), %rdi      # 0x216a5
jmp 0x1e1fa
incl 0x119d1(%rip)           # 0x2fb30
leaq 0x116a2(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x353f(%rip), %rdi      # 0x216af
jmp 0x1e1fa
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
incl 0x119ab(%rip)           # 0x2fb30
leaq 0x1167c(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x350a(%rip), %rdi      # 0x216a0
jmp 0x1e1fa
incl 0x11992(%rip)           # 0x2fb30
leaq 0x11663(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3515(%rip), %rdi      # 0x216c4
jmp 0x1e1fa
incl 0x11979(%rip)           # 0x2fb30
leaq 0x1164a(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3519(%rip), %rdi      # 0x216e1
jmp 0x1e231
incl 0x11960(%rip)           # 0x2fb30
leaq 0x11631(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x34e8(%rip), %rdi      # 0x216c9
jmp 0x1e1fa
incl 0x11947(%rip)           # 0x2fb30
leaq 0x11618(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x34c5(%rip), %rdi      # 0x216bf
movl $0x4, %esi
jmp 0x1e254
incl 0x11929(%rip)           # 0x2fb30
leaq 0x115fa(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x34a1(%rip), %rdi      # 0x216b9
jmp 0x1e24f
incl 0x11910(%rip)           # 0x2fb30
leaq 0x115e1(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x34ac(%rip), %rdi      # 0x216dd
movl $0x3, %esi
jmp 0x1e254
incl 0x118f2(%rip)           # 0x2fb30
leaq 0x115c3(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3484(%rip), %rdi      # 0x216d3
movl $0x5, %esi
movl $0x1, %edx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x64b0
nop