// File: /workspace/github_cpp_makefile_star2_O2/pfnet-research[P]pml/src/MDP.cpp
// Function: mdp::mdp_t::merge(mdp::mdp_t&&, mdp::mdp_t&&)
mdp_t mdp_t::merge(mdp_t&& lhs, mdp_t&& rhs) {
    mdp_t result{std::move(lhs)};

    result.variables.reserve(result.variables.size() + rhs.variables.size());
    for (auto&& var : rhs.variables) {
        if (var.is_int() && var.name == "location")
            continue;
        auto found = std::find_if(
                result.variables.begin(), result.variables.end(),
                [&](mdp::variable_t const& var_) {
                    return var_.name == var.name;
                });
        if (found != result.variables.end())
            continue;
        result.variables.emplace_back(std::move(var));
    }

    result.constants.reserve(result.constants.size() + rhs.constants.size());
    for (auto&& cnst : rhs.constants) {
        auto found = std::find_if(
                result.constants.begin(), result.constants.end(),
                [&](mdp::constant_t const& cnst_) {
                    return cnst_.name == cnst.name;
                });
        if (found != result.constants.end())
            continue;
        result.constants.emplace_back(std::move(cnst));
    }

    result.commands.reserve(result.commands.size() + rhs.commands.size());
    std::move(
            rhs.commands.begin(), rhs.commands.end(),
            std::back_inserter(result.commands));
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq %rdi, %rbx
callq 0x9db6
leaq 0x20(%rbx), %rdi
movq 0x28(%rbx), %rax
subq 0x20(%rbx), %rax
pushq $0x30
popq %rcx
cqto
idivq %rcx
movq %rax, %rsi
movq 0x28(%r14), %rax
subq 0x20(%r14), %rax
cqto
idivq %rcx
addq %rax, %rsi
movq %rdi, 0x8(%rsp)
movq %rbx, 0x18(%rsp)
callq 0x9e1e
movq 0x20(%r14), %r12
movq %r14, 0x20(%rsp)
movq 0x28(%r14), %rax
movq %rax, 0x10(%rsp)
cmpq 0x10(%rsp), %r12
je 0x98c9
movl 0x20(%r12), %eax
movl %eax, %ecx
sarl $0x1f, %ecx
cmpl %eax, %ecx
jne 0x97bd
movq %r12, %rdi
leaq 0x2c994(%rip), %rsi     # 0x36144
callq 0x9ec0
testb %al, %al
jne 0x98c0
movq 0x20(%rbx), %r15
movq 0x28(%rbx), %rbx
movq %rbx, %r14
subq %r15, %r14
movq %r14, %rax
cqto
pushq $0x30
popq %rcx
idivq %rcx
movq %rax, %r13
sarq $0x2, %r13
testq %r13, %r13
jle 0x984c
movq %r15, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
jne 0x988b
leaq 0x30(%r15), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
jne 0x98a8
leaq 0x60(%r15), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
jne 0x98a8
leaq 0x90(%r15), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
jne 0x98a8
addq $0xc0, %r15
decq %r13
addq $-0xc0, %r14
jmp 0x97dd
movq %r14, %rax
cqto
pushq $0x30
popq %rcx
idivq %rcx
cmpq $0x1, %rax
je 0x9894
cmpq $0x2, %rax
je 0x987c
cmpq $0x3, %rax
jne 0x98a5
movq %r15, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
jne 0x988b
addq $0x30, %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
je 0x9890
movq %r15, %rbp
jmp 0x98a8
addq $0x30, %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
cmovneq %r15, %rbx
movq %rbx, %rbp
movq 0x18(%rsp), %rbx
cmpq 0x28(%rbx), %rbp
jne 0x98c0
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x9ece
addq $0x30, %r12
jmp 0x978d
leaq 0x38(%rbx), %rdi
movq 0x40(%rbx), %rax
subq 0x38(%rbx), %rax
pushq $0x28
popq %rcx
cqto
idivq %rcx
movq %rax, %rsi
movq 0x20(%rsp), %r14
movq 0x40(%r14), %rax
subq 0x38(%r14), %rax
cqto
idivq %rcx
addq %rax, %rsi
movq %rdi, 0x8(%rsp)
callq 0x9f0a
movq 0x38(%r14), %r12
movq 0x40(%r14), %rax
movq %rax, 0x10(%rsp)
cmpq 0x10(%rsp), %r12
je 0x9a20
movq 0x38(%rbx), %r15
movq 0x40(%rbx), %rbx
movq %rbx, %r14
subq %r15, %r14
movq %r14, %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
movq %rax, %rbp
sarq $0x2, %rbp
testq %rbp, %rbp
jle 0x99a3
movq %r15, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
jne 0x99e2
leaq 0x28(%r15), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
jne 0x99ff
leaq 0x50(%r15), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
jne 0x99ff
leaq 0x78(%r15), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
jne 0x99ff
addq $0xa0, %r15
decq %rbp
addq $-0xa0, %r14
jmp 0x9937
movq %r14, %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
cmpq $0x1, %rax
je 0x99eb
cmpq $0x2, %rax
je 0x99d3
cmpq $0x3, %rax
jne 0x99fc
movq %r15, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
jne 0x99e2
addq $0x28, %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
je 0x99e7
movq %r15, %r13
jmp 0x99ff
addq $0x28, %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0xa5de
testb %al, %al
cmovneq %r15, %rbx
movq %rbx, %r13
movq 0x18(%rsp), %rbx
cmpq 0x40(%rbx), %r13
jne 0x9a17
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x9fac
addq $0x28, %r12
jmp 0x990c
leaq 0x50(%rbx), %r14
movq 0x58(%rbx), %rax
subq 0x50(%rbx), %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
movq %rax, %rsi
movq 0x20(%rsp), %r15
movq 0x58(%r15), %rax
subq 0x50(%r15), %rax
cqto
idivq %rcx
addq %rax, %rsi
movq %r14, %rdi
callq 0x9fe8
movq 0x50(%r15), %rdi
movq 0x58(%r15), %rsi
movq %r14, %rdx
callq 0xaa68
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9a7a
jmp 0x9a7a
movq %rax, %r14
movq 0x18(%rsp), %rdi
callq 0xa08a
movq %r14, %rdi
callq 0x94d0