// File: /workspace/github_cpp_makefile_star2_O3/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 0x1d9cf
cmpl $0x17, %r12d
jne 0x1da5e
callq 0xdb7b
incl 0x1219c(%rip)           # 0x2fb30
movl %eax, %ebx
leaq 0x11e6b(%rip), %r13     # 0x2f808
movq (%r13), %rcx
leaq 0x3c6e(%rip), %rdi      # 0x21616
movl $0x4, %esi
movl $0x1, %edx
callq 0x64b0
incl 0x12173(%rip)           # 0x2fb30
movq (%r13), %rcx
leaq 0x3cd5(%rip), %rdi      # 0x2169d
movl $0x7, %esi
jmp 0x1da13
callq 0xdb7b
incl 0x12156(%rip)           # 0x2fb30
movl %eax, %ebx
leaq 0x11e25(%rip), %r13     # 0x2f808
movq (%r13), %rcx
leaq 0x3c28(%rip), %rdi      # 0x21616
movl $0x4, %esi
movl $0x1, %edx
callq 0x64b0
incl 0x1212d(%rip)           # 0x2fb30
movq (%r13), %rcx
leaq 0x3ca5(%rip), %rdi      # 0x216b3
movl $0x8, %esi
movl $0x1, %edx
callq 0x64b0
incl 0x1210d(%rip)           # 0x2fb30
leaq 0x11dde(%rip), %r13     # 0x2f808
movq (%r13), %rdi
leaq 0x3c70(%rip), %rsi      # 0x216a5
movl %ebx, %edx
xorl %eax, %eax
callq 0x6390
incl 0x120ec(%rip)           # 0x2fb30
movq (%r13), %rcx
leaq 0x3bb8(%rip), %rdi      # 0x21607
movl $0x4, %esi
movl $0x1, %edx
callq 0x64b0
leaq 0x8(%r15), %rdi
callq 0x1cee6
movq 0x8(%r15), %rsi
testb %al, %al
je 0x1da84
addq $0x18, %rsi
leaq 0x3db6(%rip), %rdx      # 0x21830
movq %r14, %rdi
callq 0x1cdd8
jmp 0x1da90
movq (%rsi), %rax
movq %rsi, %rdi
movq %r14, %rsi
callq *0x18(%rax)
addl $-0x4, %r12d
cmpl $0x24, %r12d
ja 0x1dbb7
leaq 0x3a2f(%rip), %rax      # 0x214d4
movslq (%rax,%r12,4), %rcx
addq %rax, %rcx
jmpq *%rcx
incl 0x1207c(%rip)           # 0x2fb30
leaq 0x11d4d(%rip), %rax     # 0x2f808
movq (%rax), %rdi
leaq 0x3c41(%rip), %rsi      # 0x21706
movl %ebx, %edx
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x6390
incl 0x12053(%rip)           # 0x2fb30
leaq 0x11d24(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3c07(%rip), %rdi      # 0x216f5
jmp 0x1dc73
incl 0x12037(%rip)           # 0x2fb30
leaq 0x11d08(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3bf7(%rip), %rdi      # 0x21701
jmp 0x1dc3c
incl 0x1201b(%rip)           # 0x2fb30
leaq 0x11cec(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3ba0(%rip), %rdi      # 0x216c6
jmp 0x1dc3c
incl 0x11fff(%rip)           # 0x2fb30
leaq 0x11cd0(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3ba8(%rip), %rdi      # 0x216ea
jmp 0x1dc3c
incl 0x11fe3(%rip)           # 0x2fb30
leaq 0x11cb4(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3b72(%rip), %rdi      # 0x216d0
jmp 0x1dc3c
incl 0x11fc7(%rip)           # 0x2fb30
leaq 0x11c98(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3b88(%rip), %rdi      # 0x21702
jmp 0x1dc73
incl 0x11fab(%rip)           # 0x2fb30
leaq 0x11c7c(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3b2b(%rip), %rdi      # 0x216c1
jmp 0x1dc3c
incl 0x11f8f(%rip)           # 0x2fb30
leaq 0x11c60(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3b19(%rip), %rdi      # 0x216cb
jmp 0x1dc3c
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
incl 0x11f69(%rip)           # 0x2fb30
leaq 0x11c3a(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3ae4(%rip), %rdi      # 0x216bc
jmp 0x1dc3c
incl 0x11f50(%rip)           # 0x2fb30
leaq 0x11c21(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3aef(%rip), %rdi      # 0x216e0
jmp 0x1dc3c
incl 0x11f37(%rip)           # 0x2fb30
leaq 0x11c08(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3af3(%rip), %rdi      # 0x216fd
jmp 0x1dc73
incl 0x11f1e(%rip)           # 0x2fb30
leaq 0x11bef(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3ac2(%rip), %rdi      # 0x216e5
jmp 0x1dc3c
incl 0x11f05(%rip)           # 0x2fb30
leaq 0x11bd6(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3a9f(%rip), %rdi      # 0x216db
movl $0x4, %esi
jmp 0x1dc96
incl 0x11ee7(%rip)           # 0x2fb30
leaq 0x11bb8(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3a7b(%rip), %rdi      # 0x216d5
jmp 0x1dc91
incl 0x11ece(%rip)           # 0x2fb30
leaq 0x11b9f(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3a86(%rip), %rdi      # 0x216f9
movl $0x3, %esi
jmp 0x1dc96
incl 0x11eb0(%rip)           # 0x2fb30
leaq 0x11b81(%rip), %rax     # 0x2f808
movq (%rax), %rcx
leaq 0x3a5e(%rip), %rdi      # 0x216ef
movl $0x5, %esi
movl $0x1, %edx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x64b0
nop