// File: /workspace/github_cpp_makefile_star2_O2/acliusBackHome[P]kamaya/dist/ParseExpression.cpp
// Function: ParseExpression::generate_expression(ExpressionType, ParseExpression const&, ParseExpression const&)
const ParseExpression &ParseExpression::generate_expression(
        ExpressionType type,
        const ParseExpression &expr1,
        const ParseExpression &expr2) {
    ParseExpression res;
    res.expr_type = type;
    res.child[0] = get_expr_id(expr1);
    res.child[1] = get_expr_id(expr2);
    switch (type) {
        case E_ADD:
        case E_SUB:
        case E_MUL:
        case E_DIV:
        case E_MOD:
        case E_POW: {
            // 如果其中一个是不可在编译期计算的表达式, 另一个是常量表达式, 则表达式返回值为不可计算表达式的类型
            if ((!expr1.is_const()) && expr2.is_const()) {
                res.ret_type_id = expr1.get_ret_type().get_id();
            } else if (!(expr2.is_const()) && expr1.is_const()) {
                res.ret_type_id = expr2.get_ret_type().get_id();
            } else {
                // 两者都是变量或者两者都是常量
                try {
                    res.ret_type_id = ParseType::convert(type, expr1.get_ret_type(), expr2.get_ret_type());
                } catch (ParseException &exc) {
                    string info = "in ParseExpression::generate_expression("
                                  "ExpressionType type, "
                                  "const ParseExpression &expr1, "
                                  "const ParseExpression &expr2)";
                    info += " expr1=" + to_string(expr1.get_id());
                    info += " expr2=" + to_string(expr2.get_id());
                    exc.push_trace(info);
                    throw exc;
                }
                if (expr1.is_const() && expr2.is_const()) {
                    res.calculate_const();
                }
            }
            // 求幂运算比较特殊(想出来C语言支持求幂运算符的要求的真是天才),
            // 返回值是long double
            if (type == E_POW) {
                ParseType ret_type(T_DOUBLE, S_LONG);
                res.ret_type_id = ret_type.get_id();
            }
            break;
        }
        case E_LOGIC_OR:
        case E_LOGIC_AND:
        case E_G:
        case E_GE:
        case E_EQUAL:
        case E_NE:
        case E_L:
        case E_LE:
            res.ret_type_id = T_BOOL;
            if (expr1.is_const() && expr2.is_const()) {
                res.calculate_const();
            }
            break;
        case E_ADR:
        case E_PTR:
        case E_NEG:
        case E_POS:
        case E_BIT_NOT:
        case E_NOT:
        case E_GET_ITEM:
        case E_UNDEFINED:
        case E_VAR:
        case E_CONST:
        case E_FUN:
        case E_ASSIGN: {
            // 错误调用该函数
            string info = "ParseExpression::generate_expression("
                          "ExpressionType type, "
                          "const ParseExpression &expr1, "
                          "const ParseExpression &expr2)";
            info += " expr1=" + to_string(expr1.get_id());
            info += " expr2=" + to_string(expr2.get_id());
            throw ParseException(EX_EXPRESSION_CAN_NOT_GENERATE, info);
        }
    }
    update(res);
    return get_expression(res.get_id());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xb0, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movl %edi, %r14d
orq $-0x1, -0x70(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0x80(%rbp)
movl %edi, -0x68(%rbp)
movq %rsi, %rdi
callq 0x25a38
movq %rax, -0x90(%rbp)
movq %rbx, %rdi
callq 0x25a38
movq %rax, -0x88(%rbp)
cmpl $0x19, %r14d
ja 0x253f0
movl $0x1fe0000, %eax        # imm = 0x1FE0000
btl %r14d, %eax
jae 0x2531b
movq $0x1, -0x70(%rbp)
movq %r15, %rdi
callq 0x24972
testb %al, %al
je 0x253f0
movq %rbx, %rdi
callq 0x24972
testb %al, %al
je 0x253f0
leaq -0x90(%rbp), %rdi
callq 0x2b9ac
jmp 0x253f0
movl $0x7e0, %eax            # imm = 0x7E0
btl %r14d, %eax
jae 0x25432
movq %r15, %rdi
callq 0x24972
testb %al, %al
jne 0x25342
movq %rbx, %rdi
callq 0x24972
testb %al, %al
jne 0x2535d
movq %rbx, %rdi
callq 0x24972
testb %al, %al
jne 0x25373
movq %r15, %rdi
callq 0x24972
testb %al, %al
je 0x25373
movq %rbx, %r15
movq %r15, %rdi
callq 0x249b0
movq %rax, %rdi
callq 0x212de
movq %rax, -0x70(%rbp)
jmp 0x253bc
movq %r15, %rdi
callq 0x249b0
movq %rax, %r12
movq %rbx, %rdi
callq 0x249b0
movl %r14d, %edi
movq %r12, %rsi
movq %rax, %rdx
callq 0x224c2
movq %rax, -0x70(%rbp)
movq %r15, %rdi
callq 0x24972
testb %al, %al
je 0x253bc
movq %rbx, %rdi
callq 0x24972
testb %al, %al
je 0x253bc
leaq -0x90(%rbp), %rdi
callq 0x2b9ac
cmpl $0xa, %r14d
jne 0x253f0
leaq -0xc8(%rbp), %rdi
pushq $0x7
popq %rsi
pushq $0x2
popq %rdx
callq 0x211b2
leaq -0xc8(%rbp), %rdi
callq 0x212de
movq %rax, -0x70(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x21c36
leaq -0x90(%rbp), %rdi
callq 0x24716
leaq -0x90(%rbp), %rdi
callq 0x25a38
movq %rax, %rdi
callq 0x247e8
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x25150
movq %rbx, %rax
addq $0xb0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15f77(%rip), %rsi     # 0x3b3b0
leaq -0xc8(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x4130
movq %r15, %rdi
callq 0x25a38
leaq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0xc865
leaq 0x12905(%rip), %rsi     # 0x37d69
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0xc837
leaq -0xc8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4580
leaq -0x40(%rbp), %rdi
callq 0x4598
leaq -0x60(%rbp), %rdi
callq 0x4598
movq %rbx, %rdi
callq 0x25a38
leaq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0xc865
leaq 0x128c3(%rip), %rsi     # 0x37d71
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0xc837
leaq -0xc8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4580
leaq -0x40(%rbp), %rdi
callq 0x4598
leaq -0x60(%rbp), %rdi
callq 0x4598
pushq $0x28
popq %rdi
callq 0x4180
movq %rax, %rbx
pushq $0x10
popq %rsi
leaq -0xc8(%rbp), %rdx
movq %rax, %rdi
callq 0x2b53c
leaq 0x2d86f(%rip), %rsi     # 0x52d70
leaq -0x18c60(%rip), %rdx    # 0xc8a8
movq %rbx, %rdi
callq 0x44e0
jmp 0x25675
jmp 0x2555f
movq %rax, %r14
movq %rbx, %rdi
callq 0x4220
jmp 0x25562
jmp 0x2552a
jmp 0x25538
jmp 0x2555f
movq %rax, %r14
leaq -0x40(%rbp), %rdi
callq 0x4598
jmp 0x2553b
movq %rax, %r14
leaq -0x60(%rbp), %rdi
callq 0x4598
jmp 0x25562
movq %rax, %r14
leaq -0xc8(%rbp), %rdi
callq 0x21c36
jmp 0x256bf
jmp 0x256bc
movq %rax, %r14
leaq -0xc8(%rbp), %rdi
callq 0x4598
jmp 0x256bf
jmp 0x256bc
movq %rax, %r14
cmpl $0x1, %edx
jne 0x256bf
movq %r14, %rdi
callq 0x4140
movq %rax, %r14
leaq 0x15e17(%rip), %rsi     # 0x3b3ad
leaq -0xc8(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x4130
movq %r15, %rdi
callq 0x25a38
leaq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0xc865
leaq 0x127a8(%rip), %rsi     # 0x37d69
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0xc837
leaq -0xc8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4580
leaq -0x40(%rbp), %rdi
callq 0x4598
leaq -0x60(%rbp), %rdi
callq 0x4598
movq %rbx, %rdi
callq 0x25a38
leaq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0xc865
leaq 0x12766(%rip), %rsi     # 0x37d71
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0xc837
leaq -0xc8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4580
leaq -0x40(%rbp), %rdi
callq 0x4598
leaq -0x60(%rbp), %rdi
callq 0x4598
leaq -0xc8(%rbp), %rsi
movq %r14, %rdi
callq 0x2b7ea
pushq $0x28
popq %rdi
callq 0x4180
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2b876
leaq 0x2d70a(%rip), %rsi     # 0x52d70
leaq -0x18dc5(%rip), %rdx    # 0xc8a8
movq %rbx, %rdi
callq 0x44e0
jmp 0x25699
jmp 0x2567d
jmp 0x2568b
jmp 0x25699
movq %rax, %r14
leaq -0x40(%rbp), %rdi
callq 0x4598
jmp 0x2568e
movq %rax, %r14
leaq -0x60(%rbp), %rdi
callq 0x4598
jmp 0x2569c
movq %rax, %r14
leaq -0xc8(%rbp), %rdi
callq 0x4598
jmp 0x256ad
movq %rax, %r14
callq 0x44b0
jmp 0x256bf
movq %rax, %rdi
callq 0xca0b
movq %rax, %r14
leaq -0x90(%rbp), %rdi
callq 0x25150
movq %r14, %rdi
callq 0x4500
nop