// File: /workspace/github_cpp_makefile_star2_O2/canzarlab[P]Trajan/src/EditDist.cpp
// Function: Distance(std::vector<std::vector<std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>, std::allocator<std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>>>, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>, std::allocator<std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>>>>>&, std::vector<std::vector<std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>, std::allocator<std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>>>, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>, std::allocator<std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>>>>>&, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, int, int, int, int, int, int, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&)
int Distance(vvvvi& DP, vvvvi& P, vvi& T1, vvi& T2, vvi& L1, vvi& L2, vvi& D1, vvi& D2, int n, int m, int i, int j, int k, int l, vector<vector<int>> & cost_matrix)
{
    if (i + j == n)
    {
        P[i][j][k][l] = INS_TREE;
        int cost = 0;
        for (int iter = l+1; iter <= m-k; ++iter)
            cost += cost_matrix[n][L2[k][iter]];
        return cost;
    }
    if (k + l == m)
    {
        P[i][j][k][l] = DEL_TREE;
        int cost = 0;
        for (int iter = j+1; iter <= n-i; ++iter)
            cost += cost_matrix[L1[i][iter]][m];
        return cost;
    }
    int del_i = L1[i][j+1];
    int insert_j = L2[k][l+1];
    int p = D1[i][j + 1], q = D2[k][l + 1];
    int x = n - p - T1[i][j + 1], y = m - q - T2[k][l + 1];
    int o = DP[i][j + 1][k][l] + cost_matrix[del_i][m];
    int a = DP[i][j][k][l + 1] + cost_matrix[n][insert_j];
    int b = DP[i][j + T1[i][j + 1]][k][l + T2[k][l + 1]];
    int c = DP[p + 1][x][q + 1][y];
    int d = cost_matrix[del_i][insert_j];
    int mm = min(min(o, a), b + c + d);
    if (mm == b + c + d)
        P[i][j][k][l] = MATCH;
    else if (mm == o)
        P[i][j][k][l] = DEL_NODE;
    else
        P[i][j][k][l] = INS_NODE;
    return mm;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x78(%rsp), %rbx
movl 0x70(%rsp), %r14d
movl 0x68(%rsp), %r15d
movl 0x60(%rsp), %r12d
movl 0x58(%rsp), %eax
movl 0x50(%rsp), %r11d
movl 0x48(%rsp), %r10d
leal (%r12,%rax), %ebp
cmpl %r10d, %ebp
jne 0x4bb93
cltq
movq (%rsi), %rcx
imulq $0x18, %rax, %rax
movslq %r12d, %rdx
movq (%rcx,%rax), %rax
imulq $0x18, %rdx, %rcx
movslq %r15d, %rdx
movq (%rax,%rcx), %rax
imulq $0x18, %rdx, %rcx
movslq %r14d, %rdx
movq (%rax,%rcx), %rax
movl $0xfffffffe, (%rax,%rdx,4) # imm = 0xFFFFFFFE
subl %r15d, %r11d
movslq %r10d, %rax
imulq $0x18, %rax, %rsi
addq (%rbx), %rsi
addq (%r9), %rcx
movslq %r11d, %rdi
xorl %eax, %eax
cmpq %rdi, %rdx
jge 0x4bd6a
movq (%rcx), %r8
movslq 0x4(%r8,%rdx,4), %r8
incq %rdx
movq (%rsi), %r9
addl (%r9,%r8,4), %eax
jmp 0x4bb76
leal (%r14,%r15), %ebp
cltq
cmpl %r11d, %ebp
jne 0x4bbfa
movq (%rsi), %rsi
imulq $0x18, %rax, %rcx
movslq %r12d, %rdx
movq (%rsi,%rcx), %rsi
imulq $0x18, %rdx, %rdi
movslq %r15d, %r9
movq (%rsi,%rdi), %rsi
imulq $0x18, %r9, %rdi
movslq %r14d, %r9
movq (%rsi,%rdi), %rsi
orl $-0x1, (%rsi,%r9,4)
subl %eax, %r10d
addq (%r8), %rcx
movq (%rbx), %rsi
movslq %r11d, %rdi
movslq %r10d, %r8
xorl %eax, %eax
cmpq %r8, %rdx
jge 0x4bd6a
movq (%rcx), %r9
movslq 0x4(%r9,%rdx,4), %r9
incq %rdx
imulq $0x18, %r9, %r9
movq (%rsi,%r9), %r9
addl (%r9,%rdi,4), %eax
jmp 0x4bbd8
movq 0x38(%rsp), %rbp
imulq $0x18, %rax, %r14
movq %r8, -0x8(%rsp)
movslq %r12d, %r13
movq (%rbp), %rax
movq (%rax,%r14), %rax
movslq 0x4(%rax,%r13,4), %r8
movq %r8, -0x20(%rsp)
movq (%rdx), %rax
movq (%rax,%r14), %rax
movl 0x4(%rax,%r13,4), %ebp
movq %r9, -0x10(%rsp)
movl %r10d, %ebx
subl %r8d, %ebx
subl %ebp, %ebx
movslq %r15d, %rax
imulq $0x18, %rax, %r15
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r15), %rax
movl 0x70(%rsp), %edx
movslq %edx, %rdx
movslq 0x4(%rax,%rdx,4), %r8
movq (%rcx), %rax
movq (%rax,%r15), %rax
movl 0x4(%rax,%rdx,4), %eax
movslq %r11d, %r9
movq %r9, -0x18(%rsp)
subl %r8d, %r11d
subl %eax, %r11d
addl %r12d, %ebp
movq %r14, %r12
movl 0x70(%rsp), %ecx
addl %ecx, %eax
movq (%rdi), %rcx
imulq $0x18, -0x20(%rsp), %rdi
movslq %ebx, %rbx
movq 0x18(%rcx,%rdi), %rdi
imulq $0x18, %rbx, %rbx
movq (%rdi,%rbx), %rdi
imulq $0x18, %r8, %r8
movq 0x18(%rdi,%r8), %rdi
movslq %r11d, %r8
movl (%rdi,%r8,4), %edi
movq (%rcx,%r14), %r11
movslq %ebp, %rcx
imulq $0x18, %rcx, %rcx
movq (%r11,%rcx), %rcx
cltq
movq (%rcx,%r15), %rcx
addl (%rcx,%rax,4), %edi
movq -0x8(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r14), %rax
movslq 0x4(%rax,%r13,4), %rax
imulq $0x18, %r13, %r8
movq 0x18(%r11,%r8), %rcx
movq (%rcx,%r15), %rbx
movq 0x78(%rsp), %rcx
movq (%rcx), %r14
imulq $0x18, %rax, %rax
movq (%r14,%rax), %rax
movq -0x18(%rsp), %rcx
movl (%rax,%rcx,4), %ecx
addl (%rbx,%rdx,4), %ecx
movslq %r10d, %r10
imulq $0x18, %r10, %r10
movq (%r14,%r10), %r10
movq -0x10(%rsp), %r9
movq (%r9), %rbx
movq (%rbx,%r15), %rbx
movslq 0x4(%rbx,%rdx,4), %rbx
addl (%rax,%rbx,4), %edi
movl (%r10,%rbx,4), %eax
movq (%r11,%r8), %r10
movq (%r10,%r15), %r10
addl 0x4(%r10,%rdx,4), %eax
cmpl %ecx, %eax
cmovgel %ecx, %eax
cmpl %eax, %edi
cmovll %edi, %eax
jle 0x4bd4e
movq (%rsi), %rsi
movq (%rsi,%r12), %rsi
movq (%rsi,%r8), %rsi
movq (%rsi,%r15), %rsi
cmpl %ecx, %eax
jne 0x4bd63
movl $0x1, (%rsi,%rdx,4)
movl %ecx, %eax
jmp 0x4bd6a
movq (%rsi), %rcx
movq (%rcx,%r12), %rcx
movq (%rcx,%r8), %rcx
movq (%rcx,%r15), %rcx
andl $0x0, (%rcx,%rdx,4)
jmp 0x4bd6a
movl $0x2, (%rsi,%rdx,4)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq