// File: canzarlab[P]Trajan/src/match.cpp
// Function: path_path(array2d&, array2d&, array2d const&, tree const&, tree const&, int, int, int, int)
int path_path(array2d& dp, array2d& pdp, const array2d& matrix, const tree& t1, const tree& t2, const int lx, const int ly, int x, int y)
{
    // trivial case: empty path
    if (x == lx || y == ly)
        return 0;

    // memoization
    int& sol = dp(x, y);
    if (sol != NINF)
        return sol;

    // delete t1 node
    int nsol = path_path(dp, pdp, matrix, t1, t2, lx, ly, t1.par[x], y);
    if (nsol > sol)
        sol = nsol, pdp(x, y) = DEL_1;

    // match x and y
    nsol = matrix(x, y) + path_path(dp, pdp, matrix, t1, t2, lx, ly, t1.par[x], t2.par[y]);
    if (nsol > sol)
        sol = nsol, pdp(x, y) = MATCH;

    // delete t2 node
    nsol = path_path(dp, pdp, matrix, t1, t2, lx, ly, x, t2.par[y]);
    if (nsol > sol)
        sol = nsol, pdp(x, y) = DEL_2;

    return sol;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x68, %rsp
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movl %r9d, -0x3c(%rbp)
movl 0x18(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x496a
movl 0x20(%rbp), %eax
cmpl 0x10(%rbp), %eax
jne 0x4976
movl $0x0, -0xc(%rbp)
jmp 0x4b1a
movq -0x18(%rbp), %rdi
movl 0x18(%rbp), %esi
movl 0x20(%rbp), %edx
callq 0x7820
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpl $0x80000000, (%rax)     # imm = 0x80000000
je 0x49a3
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xc(%rbp)
jmp 0x4b1a
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
movl -0x3c(%rbp), %r9d
movl 0x10(%rbp), %r11d
movq -0x30(%rbp), %rax
movslq 0x18(%rbp), %r10
movl 0x5f14(%rax,%r10,4), %r10d
movl 0x20(%rbp), %eax
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x4930
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x4a10
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rdi
movl 0x18(%rbp), %esi
movl 0x20(%rbp), %edx
callq 0x7820
movl $0x0, (%rax)
movq -0x28(%rbp), %rdi
movl 0x18(%rbp), %esi
movl 0x20(%rbp), %edx
callq 0x79b0
movl (%rax), %eax
movl %eax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
movl -0x3c(%rbp), %r9d
movl 0x10(%rbp), %r11d
movq -0x30(%rbp), %rax
movslq 0x18(%rbp), %r10
movl 0x5f14(%rax,%r10,4), %r10d
movq -0x38(%rbp), %rax
movslq 0x20(%rbp), %rbx
movl 0x5f14(%rax,%rbx,4), %eax
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x4930
movl %eax, %ecx
movl -0x50(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x4aa4
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rdi
movl 0x18(%rbp), %esi
movl 0x20(%rbp), %edx
callq 0x7820
movl $0x2, (%rax)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
movl -0x3c(%rbp), %r9d
movl 0x10(%rbp), %r11d
movl 0x18(%rbp), %r10d
movq -0x38(%rbp), %rax
movslq 0x20(%rbp), %rbx
movl 0x5f14(%rax,%rbx,4), %eax
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x4930
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x4b11
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rdi
movl 0x18(%rbp), %esi
movl 0x20(%rbp), %edx
callq 0x7820
movl $0x1, (%rax)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
addq $0x68, %rsp
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)