// File: /workspace/github_cpp_makefile_star2_O3/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, %r15d
movl %edx, %r12d
movq %rdi, %r14
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 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 0x9617
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 0xe0(%r14), %rax
movq 0xe8(%r14), %rcx
cmpq %rax, %rcx
movl %r15d, -0x68(%rbp)
je 0x96a1
xorl %r13d, %r13d
leaq -0xc0(%rbp), %r15
movslq (%rax,%r13,8), %rdx
cmpq $-0x1, %rdx
je 0x968f
movl 0x4(%rax,%r13,8), %eax
shlq $0x20, %rax
addq %r13, %rax
leaq (%rdx,%rdx,2), %rcx
movq -0x30(%rbp), %rdx
leaq (%rdx,%rcx,8), %rdi
movq %rax, -0xc0(%rbp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x9679
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x9681
movq %r15, %rdx
callq 0x8236
movq 0xe0(%r14), %rax
movq 0xe8(%r14), %rcx
incq %r13
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r13, %rdx
ja 0x963c
xorps %xmm0, %xmm0
leaq -0xc0(%rbp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
movq %r14, %rdi
movl %r12d, %esi
movq -0x30(%rbp), %rcx
callq 0x9b7e
movq -0xc0(%rbp), %r12
movq -0xb8(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpq %rax, %r12
je 0x97ec
leaq 0x70(%r14), %rax
movq %rax, -0x100(%rbp)
leaq 0x8(%r14), %rax
movq %rax, -0x80(%rbp)
movslq (%r12), %rax
movq 0xf8(%r14), %rcx
movl -0x68(%rbp), %edx
addl %edx, (%rcx,%rax,4)
movq -0x100(%rbp), %rdi
movq %r12, %rsi
callq 0x9d62
movq (%rax), %r13
movq 0x8(%rax), %rbx
cmpq %rbx, %r13
movq %r12, -0x90(%rbp)
je 0x97db
movl (%r12), %eax
movslq %eax, %rcx
movq 0xf8(%r14), %rdx
movl (%rdx,%rcx,4), %r15d
movl (%r13), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, -0x50(%rbp)
movq -0x80(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x7ac2
addl (%rax), %r15d
movslq (%r13), %rax
movq 0xf8(%r14), %rcx
subl (%rcx,%rax,4), %r15d
jns 0x97ce
movq %r12, %rax
movq %rbx, %r12
movl (%rax), %eax
movl (%r13), %ecx
movq %rcx, %rdx
shlq $0x20, %rdx
orq %rax, %rdx
movl %r15d, -0x50(%rbp)
movq %rdx, -0x4c(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movl %ecx, -0x58(%rbp)
leaq -0xf0(%rbp), %r15
movq %r15, %rdi
leaq -0x60(%rbp), %rbx
movq %rbx, %rsi
callq 0xa3b2
movq %r15, -0x50(%rbp)
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rcx
leaq -0x50(%rbp), %r8
callq 0xa40c
movq %r12, %rbx
movq -0x90(%rbp), %r12
addq $0x4, %r13
cmpq %rbx, %r13
jne 0x972d
addq $0x4, %r12
cmpq -0x88(%rbp), %r12
jne 0x96f6
cmpq $0x0, -0xc8(%rbp)
movq -0x30(%rbp), %r15
je 0x9a7b
leaq 0x8(%r14), %rax
movq %rax, -0x80(%rbp)
leaq 0x70(%r14), %rax
movq %rax, -0x88(%rbp)
leaq -0x50(%rbp), %rbx
movq -0xd8(%rbp), %rsi
movq 0x20(%rsi), %rax
movq %rax, -0x78(%rbp)
movl 0x28(%rsi), %eax
movl %eax, -0x70(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0xa55e
movq -0x80(%rbp), %rdi
leaq -0x74(%rbp), %rsi
callq 0xa5a0
movslq -0x74(%rbp), %rcx
movl (%rax), %eax
movslq -0x70(%rbp), %rdx
movq 0xe0(%r14), %rsi
movl %ecx, (%rsi,%rdx,8)
movl %eax, 0x4(%rsi,%rdx,8)
movl -0x78(%rbp), %eax
movl -0x70(%rbp), %edx
shlq $0x20, %rax
orq %rdx, %rax
leaq (%rcx,%rcx,2), %rcx
leaq (%r15,%rcx,8), %rdi
movq %rax, -0x50(%rbp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x9888
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x9890
movq %rbx, %rdx
callq 0x8236
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movl -0x70(%rbp), %esi
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x9b7e
movq -0x50(%rbp), %r15
movq -0x48(%rbp), %rdi
cmpq %rdi, %r15
je 0x98d9
movq 0xf8(%r14), %rax
movq %r15, %rcx
movslq (%rcx), %rdx
movl -0x78(%rbp), %esi
addl %esi, (%rax,%rdx,4)
addq $0x4, %rcx
cmpq %rdi, %rcx
jne 0x98c7
movq %rdi, -0x68(%rbp)
movq -0xd8(%rbp), %r13
leaq -0xe8(%rbp), %rax
cmpq %rax, %r13
je 0x9a4d
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq 0x28(%r13), %rdx
callq 0xa4b0
cmpq -0x48(%rbp), %rax
je 0x9929
leaq 0x20(%r13), %rsi
leaq -0xf0(%rbp), %rbx
movq %rbx, %rdi
callq 0xa784
movq %rbx, %rdi
movq %rax, %rsi
callq 0xa842
movq %r13, %rdi
callq 0x21e0
movq %rax, %r13
leaq -0xe8(%rbp), %rax
cmpq %rax, %r13
jne 0x98f4
movq -0x50(%rbp), %r15
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x9a4d
movq -0x88(%rbp), %rdi
movq %r15, %rsi
callq 0x9d62
movq (%rax), %r13
movq 0x8(%rax), %r12
cmpq %r12, %r13
movq %r12, -0x90(%rbp)
je 0x9a49
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %r13, %rdx
callq 0xa4b0
cmpq -0x48(%rbp), %rax
jne 0x9a3c
movl (%r15), %eax
movslq %eax, %rcx
movq 0xf8(%r14), %rdx
movl (%rdx,%rcx,4), %ebx
movl (%r13), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, -0x60(%rbp)
movq -0x80(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x7ac2
addl (%rax), %ebx
movslq (%r13), %rax
movq 0xf8(%r14), %rcx
subl (%rcx,%rax,4), %ebx
jns 0x9a3c
movq %r15, %rax
movq %r14, %r15
movq %rax, %r12
movl (%rax), %eax
movl (%r13), %ecx
movq %rcx, %rdx
shlq $0x20, %rdx
orq %rax, %rdx
movl %ebx, -0x60(%rbp)
movq %rdx, -0x5c(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x110(%rbp)
movl %ecx, -0x108(%rbp)
leaq -0xf0(%rbp), %rbx
movq %rbx, %rdi
leaq -0x110(%rbp), %r14
movq %r14, %rsi
callq 0xa3b2
movq %rbx, -0x60(%rbp)
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rcx
leaq -0x60(%rbp), %r8
callq 0xa40c
movq %r15, %r14
movq %r12, %r15
movq -0x90(%rbp), %r12
addq $0x4, %r13
cmpq %r12, %r13
jne 0x9977
addq $0x4, %r15
cmpq -0x68(%rbp), %r15
jne 0x9951
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
movq -0x30(%rbp), %r15
leaq -0x50(%rbp), %rbx
je 0x9a6d
callq 0x2170
cmpq $0x0, -0xc8(%rbp)
jne 0x9815
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x9a8c
callq 0x2170
movq -0xa0(%rbp), %rax
cmpq -0xa8(%rbp), %rax
je 0x9ac0
movq -0x98(%rbp), %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rbx
movq -0x18(%r15,%rbx), %rdi
testq %rdi, %rdi
je 0x9aba
callq 0x2170
addq $-0x18, %rbx
jne 0x9aab
movq -0xf8(%rbp), %rsp
leaq -0xf0(%rbp), %rdi
callq 0x9d0a
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9b02
movq %rax, %r14
movq -0x30(%rbp), %r15
jmp 0x9b35
jmp 0x9af1
jmp 0x9af1
movq %rax, %r14
jmp 0x9b24
jmp 0x9b0f
jmp 0x9b02
jmp 0x9b0f
jmp 0x9b02
jmp 0x9b0f
jmp 0x9b0f
movq %rax, %r14
movq -0x30(%rbp), %r15
jmp 0x9b24
jmp 0x9b0f
jmp 0x9b0f
movq %rax, %r14
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
movq -0x30(%rbp), %r15
je 0x9b24
callq 0x2170
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x9b35
callq 0x2170
movq -0xa0(%rbp), %rax
cmpq -0xa8(%rbp), %rax
je 0x9b69
movq -0x98(%rbp), %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rbx
movq -0x18(%r15,%rbx), %rdi
testq %rdi, %rdi
je 0x9b63
callq 0x2170
addq $-0x18, %rbx
jne 0x9b54
leaq -0xf0(%rbp), %rdi
callq 0x9d0a
movq %r14, %rdi
callq 0x2280
nop