// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movl %edi, %r14d
movq $-0x1, -0x80(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0x90(%rbp)
movl %edi, -0x78(%rbp)
movq 0x10(%rsi), %rax
testq %rax, %rax
jne 0x2bd38
movq %r15, %rdi
callq 0x2af00
movq 0x10(%r15), %rax
movq %rax, -0xa0(%rbp)
movq 0x10(%rbx), %rax
testq %rax, %rax
jne 0x2bd54
movq %rbx, %rdi
callq 0x2af00
movq 0x10(%rbx), %rax
movq %rax, -0x98(%rbp)
cmpl $0x19, %r14d
ja 0x2be82
movl $0x1fe0000, %eax        # imm = 0x1FE0000
btl %r14d, %eax
jae 0x2bda9
movq $0x1, -0x80(%rbp)
movq %r15, %rdi
callq 0x2b2f4
testb %al, %al
je 0x2be82
movq %rbx, %rdi
callq 0x2b2f4
testb %al, %al
je 0x2be82
leaq -0xa0(%rbp), %rdi
callq 0x33a80
jmp 0x2be82
movl $0x7e0, %eax            # imm = 0x7E0
btl %r14d, %eax
jae 0x2bed6
movq %r15, %rdi
callq 0x2b2f4
testb %al, %al
jne 0x2bdd0
movq %rbx, %rdi
callq 0x2b2f4
testb %al, %al
jne 0x2bdeb
movq %rbx, %rdi
callq 0x2b2f4
testb %al, %al
jne 0x2be01
movq %r15, %rdi
callq 0x2b2f4
testb %al, %al
je 0x2be01
movq %rbx, %r15
movq %r15, %rdi
callq 0x2b332
movq %rax, %rdi
callq 0x270b4
movq %rax, -0x80(%rbp)
jmp 0x2be4a
movq %r15, %rdi
callq 0x2b332
movq %rax, %r12
movq %rbx, %rdi
callq 0x2b332
movl %r14d, %edi
movq %r12, %rsi
movq %rax, %rdx
callq 0x28620
movq %rax, -0x80(%rbp)
movq %r15, %rdi
callq 0x2b2f4
testb %al, %al
je 0x2be4a
movq %rbx, %rdi
callq 0x2b2f4
testb %al, %al
je 0x2be4a
leaq -0xa0(%rbp), %rdi
callq 0x33a80
cmpl $0xa, %r14d
jne 0x2be82
leaq -0xd8(%rbp), %rdi
movl $0x7, %esi
movl $0x2, %edx
callq 0x26f44
leaq -0xd8(%rbp), %rdi
callq 0x270b4
movq %rax, -0x80(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x27ca8
leaq -0xa0(%rbp), %rdi
callq 0x2af00
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
jne 0x2bead
leaq -0xa0(%rbp), %rdi
callq 0x2af00
movq -0x90(%rbp), %rdi
callq 0x2b006
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x2bba0
movq %rbx, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0xc8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1a52f(%rip), %rsi     # 0x46418
leaq 0x1a59d(%rip), %rdx     # 0x4648d
leaq -0xd8(%rbp), %rdi
callq 0xf868
movq 0x10(%r15), %rsi
testq %rsi, %rsi
jne 0x2bf11
movq %r15, %rdi
callq 0x2af00
movq 0x10(%r15), %rsi
leaq -0x68(%rbp), %rdi
callq 0xe50f
leaq 0x16e30(%rip), %rsi     # 0x42d51
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0xe495
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x4110
leaq -0x38(%rbp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x2bf54
callq 0x42b0
leaq -0x58(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x2bf66
callq 0x42b0
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
jne 0x2bf7b
movq %rbx, %rdi
callq 0x2af00
movq 0x10(%rbx), %rsi
leaq -0x68(%rbp), %rdi
callq 0xe50f
leaq 0x16dce(%rip), %rsi     # 0x42d59
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0xe495
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x4110
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x2bfba
callq 0x42b0
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0x2bfc8
callq 0x42b0
movl $0x28, %edi
callq 0x4190
movq %rax, %rbx
leaq -0xd8(%rbp), %rdx
movq %rax, %rdi
movl $0x10, %esi
callq 0x333ee
leaq 0x2ed80(%rip), %rsi     # 0x5ad70
leaq -0x1da57(%rip), %rdx    # 0xe5a0
movq %rbx, %rdi
callq 0x4540
jmp 0x2c1e5
jmp 0x2c07d
movq %rax, %r14
movq %rbx, %rdi
callq 0x4250
jmp 0x2c080
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x2c029
callq 0x42b0
jmp 0x2c029
movq %rax, %r14
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
jne 0x2c05d
jmp 0x2c080
jmp 0x2c07d
movq %rax, %r14
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c050
callq 0x42b0
jmp 0x2c050
movq %rax, %r14
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c080
callq 0x42b0
jmp 0x2c080
movq %rax, %r14
leaq -0xd8(%rbp), %rdi
callq 0x27ca8
jmp 0x2c263
jmp 0x2c260
movq %rax, %r14
movq -0xd8(%rbp), %rdi
cmpq %r12, %rdi
je 0x2c263
callq 0x42b0
jmp 0x2c263
jmp 0x2c260
movq %rax, %r14
cmpl $0x1, %edx
jne 0x2c263
movq %r14, %rdi
callq 0x4160
movq %rax, %r14
leaq -0xc8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1a34c(%rip), %rsi     # 0x46415
leaq 0x1a3bd(%rip), %rdx     # 0x4648d
leaq -0xd8(%rbp), %rdi
callq 0xf868
movq 0x10(%r15), %rsi
testq %rsi, %rsi
jne 0x2c0f1
movq %r15, %rdi
callq 0x2af00
movq 0x10(%r15), %rsi
leaq -0x68(%rbp), %rdi
callq 0xe50f
leaq 0x16c50(%rip), %rsi     # 0x42d51
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0xe495
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x4110
leaq -0x38(%rbp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x2c134
callq 0x42b0
leaq -0x58(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x2c146
callq 0x42b0
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
jne 0x2c15b
movq %rbx, %rdi
callq 0x2af00
movq 0x10(%rbx), %rsi
leaq -0x68(%rbp), %rdi
callq 0xe50f
leaq 0x16bee(%rip), %rsi     # 0x42d59
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0xe495
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x4110
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x2c19a
callq 0x42b0
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0x2c1a8
callq 0x42b0
leaq -0xd8(%rbp), %rsi
movq %r14, %rdi
callq 0x3383e
movl $0x28, %edi
callq 0x4190
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x338e6
leaq 0x2eb9a(%rip), %rsi     # 0x5ad70
leaq -0x1dc3d(%rip), %rdx    # 0xe5a0
movq %rbx, %rdi
callq 0x4540
jmp 0x2c238
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x2c1fd
callq 0x42b0
jmp 0x2c1fd
movq %rax, %r14
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
jne 0x2c231
jmp 0x2c23b
jmp 0x2c238
movq %rax, %r14
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c224
callq 0x42b0
jmp 0x2c224
movq %rax, %r14
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c23b
callq 0x42b0
jmp 0x2c23b
movq %rax, %r14
movq -0xd8(%rbp), %rdi
cmpq %r12, %rdi
je 0x2c251
callq 0x42b0
jmp 0x2c251
movq %rax, %r14
callq 0x4500
jmp 0x2c263
movq %rax, %rdi
callq 0xe776
movq %rax, %r14
leaq -0xa0(%rbp), %rdi
callq 0x2bba0
movq %r14, %rdi
callq 0x4560
nop