// File: /workspace/github_cpp_makefile_star2_O2/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, %r12d
leaq -0x108(%rbp), %rax
andl $0x0, (%rax)
movl %edx, -0x58(%rbp)
andq $0x0, 0x8(%rax)
movq %rdi, %r14
movq %rsp, -0xc8(%rbp)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq 0xe0(%rdi), %rcx
movq 0xe8(%rdi), %rdx
movq %rdx, %rax
subq %rcx, %rax
sarq $0x3, %rax
movq %rsp, %rbx
movq %rax, -0xb8(%rbp)
imulq $0x18, %rax, %r15
leaq 0xf(%r15), %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
movq %rcx, -0x90(%rbp)
movq %rdx, -0x88(%rbp)
cmpq %rcx, %rdx
je 0x9d1e
leaq -0x18(%r15), %rcx
pushq $0x18
popq %rsi
movq %rcx, %rax
xorl %edx, %edx
divq %rsi
subq %rdx, %rcx
addq $0x18, %rcx
movq %rbx, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x20d0
movq %r15, -0xc0(%rbp)
movq %rbx, -0x30(%rbp)
xorl %r13d, %r13d
leaq -0xb0(%rbp), %r15
movl %r12d, %ebx
movq 0xe0(%r14), %rax
movq 0xe8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
jbe 0x9d82
movslq (%rax,%r13,8), %rcx
cmpq $-0x1, %rcx
je 0x9d7d
movl 0x4(%rax,%r13,8), %eax
shlq $0x20, %rax
addq %r13, %rax
imulq $0x18, %rcx, %rdi
addq -0x30(%rbp), %rdi
movq %rax, -0xb0(%rbp)
movq %r15, %rsi
callq 0x88dc
incq %r13
jmp 0x9d36
xorps %xmm0, %xmm0
leaq -0xb0(%rbp), %rdx
movaps %xmm0, (%rdx)
andq $0x0, 0x10(%rdx)
movq %r14, %rdi
movl -0x58(%rbp), %esi
movq -0x30(%rbp), %r12
movq %r12, %rcx
callq 0xa168
movq -0xb0(%rbp), %r13
movq -0xa8(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq 0x70(%r14), %rax
movq %rax, -0x98(%rbp)
leaq 0x8(%r14), %rax
movq %rax, -0x58(%rbp)
cmpq -0xd0(%rbp), %r13
je 0x9e9a
movslq (%r13), %rax
movq 0xf8(%r14), %rcx
addl %ebx, (%rcx,%rax,4)
movq -0x98(%rbp), %rdi
movq %r13, %rsi
callq 0xa322
movq (%rax), %r12
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
cmpq -0x80(%rbp), %r12
je 0x9e8d
movl (%r13), %eax
movslq %eax, %rcx
movq 0xf8(%r14), %rdx
movl (%rdx,%rcx,4), %r15d
movl (%r12), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, -0x50(%rbp)
movq -0x58(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x7ed0
addl (%rax), %r15d
movslq (%r12), %rax
movq 0xf8(%r14), %rcx
subl (%rcx,%rax,4), %r15d
jns 0x9e84
movl (%r13), %eax
movl (%r12), %ecx
movq %rcx, %rdx
shlq $0x20, %rdx
orq %rax, %rdx
movl %r15d, -0x50(%rbp)
movq %rdx, -0x4c(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x78(%rbp)
movl %ecx, -0x70(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xaabc
addq $0x4, %r12
jmp 0x9e03
addq $0x4, %r13
movq -0x30(%rbp), %r12
jmp 0x9dce
leaq -0x50(%rbp), %rbx
cmpq $0x0, -0xe8(%rbp)
je 0xa084
movq -0xf8(%rbp), %rsi
movq 0x20(%rsi), %rax
movq %rax, -0x68(%rbp)
movl 0x28(%rsi), %eax
movl %eax, -0x60(%rbp)
leaq -0x110(%rbp), %rdi
callq 0xacd8
movq -0x58(%rbp), %rdi
leaq -0x64(%rbp), %rsi
callq 0xad38
movslq -0x64(%rbp), %rcx
movl (%rax), %eax
movslq -0x60(%rbp), %rdx
movq 0xe0(%r14), %rsi
movl %ecx, (%rsi,%rdx,8)
movl %eax, 0x4(%rsi,%rdx,8)
movl -0x68(%rbp), %eax
movl -0x60(%rbp), %edx
shlq $0x20, %rax
orq %rdx, %rax
imulq $0x18, %rcx, %rdi
addq %r12, %rdi
movq %rax, -0x50(%rbp)
movq %rbx, %rsi
callq 0x88dc
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
andq $0x0, -0x40(%rbp)
movl -0x60(%rbp), %esi
movq %r14, %rdi
movq %rbx, %rdx
movq %r12, %rcx
callq 0xa168
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
movq 0xf8(%r14), %rdx
cmpq %rcx, %rax
je 0x9f52
movslq (%rax), %rsi
movl -0x68(%rbp), %edi
addl %edi, (%rdx,%rsi,4)
addq $0x4, %rax
jmp 0x9f3e
movq -0xf8(%rbp), %r15
leaq -0x108(%rbp), %rax
cmpq %rax, %r15
je 0x9f99
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq 0x28(%r15), %rdx
callq 0xac4a
cmpq -0x48(%rbp), %rax
je 0x9f8c
leaq 0x20(%r15), %rsi
leaq -0x110(%rbp), %rdi
callq 0xaf90
movq %r15, %rdi
callq 0x2190
movq %rax, %r15
jmp 0x9f59
movq -0x50(%rbp), %r13
movq -0x48(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq -0x80(%rbp), %r13
leaq -0x50(%rbp), %rbx
je 0xa077
movq -0x98(%rbp), %rdi
movq %r13, %rsi
callq 0xa322
movq (%rax), %r15
movq 0x8(%rax), %r12
cmpq %r12, %r15
je 0xa06a
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %r15, %rdx
callq 0xac4a
cmpq -0x48(%rbp), %rax
jne 0xa061
movl (%r13), %eax
movslq %eax, %rcx
movq 0xf8(%r14), %rdx
movl (%rdx,%rcx,4), %ebx
movl (%r15), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, -0x78(%rbp)
movq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x7ed0
addl (%rax), %ebx
movslq (%r15), %rax
movq 0xf8(%r14), %rcx
subl (%rcx,%rax,4), %ebx
jns 0xa061
movl (%r13), %eax
movl (%r15), %ecx
movq %rcx, %rdx
shlq $0x20, %rdx
orq %rax, %rdx
movl %ebx, -0x78(%rbp)
movq %rdx, -0x74(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xe0(%rbp)
movl %ecx, -0xd8(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0xaabc
addq $0x4, %r15
jmp 0x9fc9
addq $0x4, %r13
movq -0x30(%rbp), %r12
jmp 0x9fa5
movq %rbx, %rdi
callq 0x8d96
jmp 0x9e9e
leaq -0xb0(%rbp), %rdi
callq 0x8d96
movq -0x88(%rbp), %rax
cmpq -0x90(%rbp), %rax
movq -0xc0(%rbp), %rbx
je 0xa0ba
addq $-0x18, %r12
leaq (%r12,%rbx), %rdi
callq 0x7880
addq $-0x18, %rbx
jne 0xa0ab
movq -0xc8(%rbp), %rsp
leaq -0x110(%rbp), %rdi
callq 0xa2cc
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa0ed
movq %rax, %r14
movq -0x30(%rbp), %r12
jmp 0xa128
jmp 0xa0ed
jmp 0xa0fa
jmp 0xa0ed
movq %rax, %r14
jmp 0xa11c
jmp 0xa0ff
jmp 0xa0ff
jmp 0xa0fa
jmp 0xa0fa
movq %rax, %r14
jmp 0xa113
movq %rax, %r14
movq -0x30(%rbp), %r12
jmp 0xa11c
jmp 0xa10c
jmp 0xa10c
movq %rax, %r14
movq -0x30(%rbp), %r12
leaq -0x50(%rbp), %rdi
callq 0x8d96
leaq -0xb0(%rbp), %rdi
callq 0x8d96
movq -0x88(%rbp), %rax
cmpq -0x90(%rbp), %rax
je 0xa153
addq $-0x18, %r12
imulq $0x18, -0xb8(%rbp), %rbx
leaq (%r12,%rbx), %rdi
callq 0x7880
addq $-0x18, %rbx
jne 0xa144
leaq -0x110(%rbp), %rdi
callq 0xa2cc
movq %r14, %rdi
callq 0x2240
nop