// File: /workspace/github_cpp_makefile_star2_O1/yogesh1q2w[P]Dynamic-Graph-Algorithms/SPT.cpp
// Function: SPT::modify_dec(int, int, int, int)
void SPT::modify_dec(int u, int v, int oldwt, int diff) {
    
    multiset<pair<int,pair<int,int>>> Q;
    
    vector<pair<int,int>> treeadj[spt.size()];
    int root;// get adjacency list representation of tree
    for (int i = 0; i < spt.size(); i++) { 
        if (spt[i].first == -1) 
            root = i; 
        else
            treeadj[spt[i].first].push_back(make_pair(i,spt[i].second));
    }

    vector<int> desc_v;
    descendants(v,desc_v,treeadj);
    for(auto &d: desc_v) {
        dist[d] += diff;
        for(auto &j:adj[d]) {
            int min_inc = dist[d] + weight[make_pair(d,j)] - dist[j];
            if(min_inc < 0)
                Q.insert(make_pair(min_inc,make_pair(d,j)));
        }
    }

    while(!Q.empty()) {
        pair<int,pair<int,int>> e1 = *(Q.begin());
        Q.erase(Q.begin());
        spt[e1.second.second] = make_pair(e1.second.first,weight[e1.second]);
        treeadj[e1.second.first].push_back(make_pair(e1.second.second,e1.first));
        vector<int> desc_end_e1;
        descendants(e1.second.second,desc_end_e1,treeadj);
        for(auto &i:desc_end_e1) {
            dist[i] = dist[i] + e1.first;
        }
        for(auto &i:Q) {
            if(find(desc_end_e1.begin(), desc_end_e1.end(), i.second.second) != desc_end_e1.end())
                Q.erase(i);
        }

        for(auto &i:desc_end_e1) {
            for(auto &j:adj[i]) {
                if(find(desc_end_e1.begin(),desc_end_e1.end(),j) == desc_end_e1.end()) {
                    int min_inc = dist[i] + weight[make_pair(i,j)] - dist[j];
                    if(min_inc < 0) {
                        Q.insert(make_pair(min_inc,make_pair(i,j)));
                    }
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %r8d, -0x90(%rbp)
movl %edx, %r12d
movq %rsp, -0xf8(%rbp)
leaq -0xe8(%rbp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq 0xe0(%rdi), %rdx
movq %rdi, -0x58(%rbp)
movq 0xe8(%rdi), %rsi
movq %rsi, %rax
subq %rdx, %rax
sarq $0x3, %rax
movq %rsp, %rbx
movq %rax, -0x98(%rbp)
leaq (%rax,%rax,2), %rax
leaq 0xf(,%rax,8), %rcx
andq $-0x10, %rcx
subq %rcx, %rbx
movq %rbx, %rsp
movq %rdx, -0xa8(%rbp)
movq %rsi, -0xa0(%rbp)
cmpq %rdx, %rsi
je 0x9a76
leaq -0x18(,%rax,8), %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rcx
shrq $0x4, %rdx
leaq (%rdx,%rdx,2), %rax
leaq 0x18(,%rax,8), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20d0
movq %rbx, -0x30(%rbp)
movq -0x58(%rbp), %rbx
movq 0xe0(%rbx), %rax
cmpq %rax, 0xe8(%rbx)
je 0x9afa
xorl %r13d, %r13d
leaq -0xc0(%rbp), %r15
movslq (%rax,%r13,8), %rcx
cmpq $-0x1, %rcx
je 0x9add
movl 0x4(%rax,%r13,8), %eax
shlq $0x20, %rax
addq %r13, %rax
leaq (%rcx,%rcx,2), %rcx
movq -0x30(%rbp), %rdx
leaq (%rdx,%rcx,8), %rdi
movq %rax, -0xc0(%rbp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x9ad5
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x9add
movq %r15, %rdx
callq 0x8676
incq %r13
movq 0xe0(%rbx), %rax
movq 0xe8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
ja 0x9a98
xorps %xmm0, %xmm0
leaq -0xc0(%rbp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
movq %rbx, %rdi
movl %r12d, %esi
movq -0x30(%rbp), %rcx
callq 0x9fba
movq -0xc0(%rbp), %r12
movq -0xb8(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpq %rax, %r12
je 0x9c3a
leaq 0x70(%rbx), %rax
movq %rax, -0x100(%rbp)
leaq 0x8(%rbx), %rax
movq %rax, -0x80(%rbp)
movslq (%r12), %rax
movq 0xf8(%rbx), %rcx
movl -0x90(%rbp), %edx
addl %edx, (%rcx,%rax,4)
movq -0x100(%rbp), %rdi
movq %r12, %rsi
callq 0xa19e
movq (%rax), %r13
movq 0x8(%rax), %r14
cmpq %r14, %r13
je 0x9c29
movslq (%r12), %rax
movq 0xf8(%rbx), %rcx
movl (%rcx,%rax,4), %r15d
movl (%r12), %eax
movl (%r13), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, -0x50(%rbp)
movq -0x80(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x7f1c
addl (%rax), %r15d
movslq (%r13), %rax
movq 0xf8(%rbx), %rcx
subl (%rcx,%rax,4), %r15d
jns 0x9c20
movq %r14, %rbx
movl (%r12), %eax
movl (%r13), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movl %r15d, -0x50(%rbp)
movq %rcx, -0x4c(%rbp)
movq -0x50(%rbp), %rax
movl -0x48(%rbp), %ecx
movq %rax, -0x68(%rbp)
movl %ecx, -0x60(%rbp)
leaq -0xf0(%rbp), %r15
movq %r15, %rdi
leaq -0x68(%rbp), %r14
movq %r14, %rsi
callq 0xa824
movq %r15, -0x50(%rbp)
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rcx
leaq -0x50(%rbp), %r8
callq 0xa87c
movq %rbx, %r14
movq -0x58(%rbp), %rbx
addq $0x4, %r13
jmp 0x9b79
addq $0x4, %r12
cmpq -0x88(%rbp), %r12
jne 0x9b4f
cmpq $0x0, -0xc8(%rbp)
movq -0x30(%rbp), %r12
je 0x9eb5
movq -0x58(%rbp), %rcx
leaq 0x8(%rcx), %rax
movq %rax, -0x80(%rbp)
leaq 0x70(%rcx), %rax
movq %rax, -0x88(%rbp)
leaq -0xf0(%rbp), %rbx
leaq -0x50(%rbp), %r14
movq -0xd8(%rbp), %rsi
movq 0x20(%rsi), %rax
movq %rax, -0x78(%rbp)
movl 0x28(%rsi), %eax
movl %eax, -0x70(%rbp)
movq %rbx, %rdi
callq 0xa9c2
movq -0x80(%rbp), %rdi
leaq -0x74(%rbp), %rsi
callq 0xaa04
movl -0x74(%rbp), %ecx
movl (%rax), %eax
movslq -0x70(%rbp), %rdx
movq -0x58(%rbp), %rsi
movq 0xe0(%rsi), %rsi
movl %ecx, (%rsi,%rdx,8)
movl %eax, 0x4(%rsi,%rdx,8)
movslq -0x74(%rbp), %rcx
movl -0x78(%rbp), %eax
movl -0x70(%rbp), %edx
shlq $0x20, %rax
orq %rdx, %rax
leaq (%rcx,%rcx,2), %rcx
leaq (%r12,%rcx,8), %rdi
movq %rax, -0x50(%rbp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x9ce4
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x9cec
movq %r14, %rdx
callq 0x8676
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movl -0x70(%rbp), %esi
movq -0x58(%rbp), %rdi
movq %r14, %rdx
movq %r12, %rcx
callq 0x9fba
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
cmpq %rcx, %rax
je 0x9d37
movq -0x58(%rbp), %rdx
movq 0xf8(%rdx), %rdx
movslq (%rax), %rsi
movl -0x78(%rbp), %edi
addl %edi, (%rdx,%rsi,4)
addq $0x4, %rax
cmpq %rcx, %rax
jne 0x9d25
movq -0xd8(%rbp), %r15
leaq -0xe8(%rbp), %rax
cmpq %rax, %r15
je 0x9d85
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq 0x28(%r15), %rdx
callq 0xa920
cmpq -0x48(%rbp), %rax
je 0x9d78
leaq 0x20(%r15), %rsi
movq %rbx, %rdi
callq 0xabec
movq %rbx, %rdi
movq %rax, %rsi
callq 0xacbe
movq %r15, %rdi
callq 0x21e0
movq %rax, %r15
jmp 0x9d3e
movq -0x50(%rbp), %r15
movq -0x48(%rbp), %rax
movq %rax, -0x90(%rbp)
cmpq %rax, %r15
je 0x9e99
movq -0x88(%rbp), %rdi
movq %r15, %rsi
callq 0xa19e
movq (%rax), %r13
movq 0x8(%rax), %r12
cmpq %r12, %r13
je 0x9e79
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %r13, %rdx
callq 0xa920
cmpq -0x48(%rbp), %rax
jne 0x9e70
movslq (%r15), %rax
movq -0x58(%rbp), %r14
movq 0xf8(%r14), %rcx
movl (%rcx,%rax,4), %ebx
movl (%r15), %eax
movl (%r13), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, -0x68(%rbp)
movq -0x80(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x7f1c
addl (%rax), %ebx
movslq (%r13), %rax
movq 0xf8(%r14), %rcx
subl (%rcx,%rax,4), %ebx
jns 0x9e70
movl (%r15), %eax
movl (%r13), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movl %ebx, -0x68(%rbp)
movq %rcx, -0x64(%rbp)
movq -0x68(%rbp), %rax
movl -0x60(%rbp), %ecx
movq %rax, -0x110(%rbp)
movl %ecx, -0x108(%rbp)
leaq -0xf0(%rbp), %rbx
movq %rbx, %rdi
leaq -0x110(%rbp), %r14
movq %r14, %rsi
callq 0xa824
movq %rbx, -0x68(%rbp)
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rcx
leaq -0x68(%rbp), %r8
callq 0xa87c
addq $0x4, %r13
jmp 0x9db3
addq $0x4, %r15
cmpq -0x90(%rbp), %r15
movq -0x30(%rbp), %r12
leaq -0xf0(%rbp), %rbx
leaq -0x50(%rbp), %r14
jne 0x9d9d
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x9ea7
callq 0x2170
cmpq $0x0, -0xc8(%rbp)
jne 0x9c6e
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x9ec6
callq 0x2170
movq -0xa0(%rbp), %rax
cmpq -0xa8(%rbp), %rax
je 0x9efa
movq -0x98(%rbp), %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rbx
movq -0x18(%r12,%rbx), %rdi
testq %rdi, %rdi
je 0x9ef4
callq 0x2170
addq $-0x18, %rbx
jne 0x9ee5
movq -0xf8(%rbp), %rsp
leaq -0xf0(%rbp), %rdi
callq 0xa146
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9f3f
movq %rax, %r14
movq -0x30(%rbp), %r12
jmp 0x9f72
jmp 0x9f2b
jmp 0x9f2b
movq %rax, %r14
jmp 0x9f61
jmp 0x9f3a
jmp 0x9f3f
jmp 0x9f3a
jmp 0x9f3f
jmp 0x9f3a
movq %rax, %r14
jmp 0x9f53
movq %rax, %r14
movq -0x30(%rbp), %r12
jmp 0x9f61
jmp 0x9f4c
jmp 0x9f4c
movq %rax, %r14
movq -0x30(%rbp), %r12
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x9f61
callq 0x2170
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x9f72
callq 0x2170
movq -0xa0(%rbp), %rax
cmpq -0xa8(%rbp), %rax
je 0x9fa6
movq -0x98(%rbp), %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rbx
movq -0x18(%r12,%rbx), %rdi
testq %rdi, %rdi
je 0x9fa0
callq 0x2170
addq $-0x18, %rbx
jne 0x9f91
leaq -0xf0(%rbp), %rdi
callq 0xa146
movq %r14, %rdi
callq 0x2280