// File: /workspace/github_cpp_makefile_star2_O2/acliusBackHome[P]kamaya/dist/ParseType.cpp
// Function: ParseType::dfs_convert(std::tuple<ExpressionType, unsigned long, unsigned long> const&)
size_t ParseType::dfs_convert(const OpAble &op_try) {
    const auto record = op_able.find(op_try);
    if (record != op_able.end()) {
        return record->second;
    }
    ExpressionType op_type = get<0>(op_try);
    size_t type1_id = get<1>(op_try), type2_id = get<2>(op_try);
    if (type1_id == type2_id) {
        // 完全一致
        op_able[op_try] = type1_id;
        return type1_id;
    }
    const ParseType &type1 = get_type(type1_id), &type2 = get_type(type2_id);
    if (type1.base_type != T_UNKNOWN && type2.base_type != T_UNKNOWN) {
        // 发现是基础类型的派生
        if (type1.base_type > type2.base_type) {
            op_able[op_try] = type1_id;
            return type1_id;
        }
        if (type1.base_type < type2.base_type) {
            op_able[op_try] = type2_id;
            return type2_id;
        }
        // base_type一致, 比较声明符号
        if (type1.specifier > type2.specifier) {
            op_able[op_try] = type1_id;
            return type1_id;
        }
        if (type1.specifier < type2.specifier) {
            op_able[op_try] = type2_id;
            return type2_id;
        }
        //完全一致
        op_able[op_try] = type1_id;
        return type1_id;
    }
    // 向下一层搜索
    op_trying.insert(op_try);
    // 拿到所有type1和type2能够无条件转化的类型
    vector<size_t> type1_to, type2_to;
    for (const auto &each : op_able) {
        // 遍历目前记录表能够拿到的所有记录
        // 这个可以用多层map进行优化, 但是...现在还没必要...
        const auto &op = each.first;
        if (get<0>(each.first) == E_UNDEFINED) {
            if (get<1>(each.first) == type1_id) {
                type1_to.emplace_back(each.second);
            } else if (get<1>(each.first) == type2_id) {
                type2_to.emplace_back(each.second);
            }
        }
    }
    for (size_t type1_convert_id : type1_to) {
        for (size_t type2_convert_id : type2_to) {
            OpAble op_try_next(op_type, type1_convert_id, type2_convert_id);
            if (op_trying.find(op_try_next) != op_trying.end()) {
                //这个已经有在之前搜索了, 跳过
                // 防止DFS环
                continue;
            }
            size_t try_res = dfs_convert(op_try_next);// op_try_next已经在下一层标记了
            if (try_res != (size_t) -1) {
                // 结果有效
                op_able[op_try] = try_res;
                return try_res;
            }
            // 无效继续搜索
        }
    }
    // 搜索完毕, type1和type2怎么转化都无法得到表达式op_type的返回值
    op_able[op_try] = (size_t) -1;
    return (size_t) -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
leaq 0x31c79(%rip), %rdi     # 0x54328
movq %rbx, %rsi
callq 0x23d46
leaq 0x31c72(%rip), %r15     # 0x54330
cmpq %r15, %rax
je 0x226cc
movq 0x38(%rax), %r14
jmp 0x22848
movq (%rbx), %r13
movq 0x8(%rbx), %r14
cmpq %r13, %r14
jne 0x226ef
leaq 0x31c49(%rip), %rdi     # 0x54328
movq %rbx, %rsi
callq 0x22aec
movq %r14, (%rax)
jmp 0x22848
movq %rbx, -0x30(%rbp)
movl 0x10(%rbx), %eax
movl %eax, -0x34(%rbp)
movq %r14, %rdi
callq 0x21a26
movq %rax, %r12
movq %r13, %rdi
callq 0x21a26
movl (%r12), %ecx
testl %ecx, %ecx
je 0x2272f
movl (%rax), %edx
testl %edx, %edx
je 0x2272f
cmpl %edx, %ecx
jle 0x2285a
leaq 0x31bff(%rip), %rdi     # 0x54328
movq -0x30(%rbp), %rsi
jmp 0x226e2
leaq 0x31bc2(%rip), %rdi     # 0x542f8
movq -0x30(%rbp), %rsi
callq 0x23fb8
leaq -0x80(%rbp), %rbx
andq $0x0, 0x10(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
leaq -0x50(%rbp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq 0x31bdf(%rip), %r12     # 0x54340
cmpq %r15, %r12
je 0x2279b
cmpl $0x0, 0x30(%r12)
jne 0x2278e
movq 0x28(%r12), %rax
movq %rbx, %rdi
cmpq %r14, %rax
je 0x22784
leaq -0x50(%rbp), %rdi
cmpq %r13, %rax
jne 0x2278e
leaq 0x38(%r12), %rsi
callq 0x22b56
movq %r12, %rdi
callq 0x4210
movq %rax, %r12
jmp 0x22761
movq -0x80(%rbp), %rax
movq -0x78(%rbp), %rcx
movq %rcx, -0x58(%rbp)
leaq -0x98(%rbp), %r12
cmpq -0x58(%rbp), %rax
je 0x228a1
movq %rax, -0x60(%rbp)
movq (%rax), %r15
movq -0x50(%rbp), %r13
movq -0x48(%rbp), %rbx
cmpq %rbx, %r13
je 0x22819
movq (%r13), %rax
movq %rax, -0x98(%rbp)
movq %r15, -0x90(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x88(%rbp)
leaq 0x31b0a(%rip), %rdi     # 0x542f8
movq %r12, %rsi
callq 0x2417a
leaq 0x31b03(%rip), %rcx     # 0x54300
cmpq %rcx, %rax
jne 0x22813
movq %r12, %rdi
callq 0x22694
movq %rax, %r14
cmpq $-0x1, %rax
jne 0x22823
addq $0x8, %r13
jmp 0x227c7
movq -0x60(%rbp), %rax
addq $0x8, %rax
jmp 0x227ae
leaq 0x31afe(%rip), %rdi     # 0x54328
movq -0x30(%rbp), %rsi
callq 0x22aec
movq %r14, (%rax)
leaq -0x50(%rbp), %rdi
callq 0xd238
leaq -0x80(%rbp), %rdi
callq 0xd238
movq %r14, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jge 0x22874
leaq 0x31ac5(%rip), %rdi     # 0x54328
movq -0x30(%rbp), %rsi
callq 0x22aec
movq %r13, (%rax)
movq %r13, %r14
jmp 0x22848
movl 0x4(%r12), %ebx
movl 0x4(%rax), %r15d
cmpl %r15d, %ebx
jg 0x22722
leaq 0x31a9b(%rip), %rdi     # 0x54328
movq -0x30(%rbp), %rsi
callq 0x22aec
cmpl %r15d, %ebx
jge 0x226e7
jmp 0x2286c
leaq 0x31a80(%rip), %rdi     # 0x54328
movq -0x30(%rbp), %rsi
callq 0x22aec
orq $-0x1, (%rax)
pushq $-0x1
popq %r14
jmp 0x22836
jmp 0x228c6
jmp 0x228c6
jmp 0x228c6
jmp 0x228c6
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0xd238
leaq -0x80(%rbp), %rdi
callq 0xd238
movq %rbx, %rdi
callq 0x4500
nop