// File: /workspace/github_cpp_makefile_star2_O2/yogesh1q2w[P]Dynamic-Graph-Algorithms/SPT.cpp
// Function: SPT::modify_inc(int, int, int, int)
void SPT::modify_inc(int u, int v, int oldwt, int diff) {
    set<int> M;
    unordered_map<int,int> M_inc;
    M.insert(v);
    M_inc[v] = diff;
    multiset<pair<int,pair<int,int>>> Q;
    Q.insert(make_pair(diff,make_pair(u,v)));
    
    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) {
        int min_inc = diff;
        pair<int,int> e_min_inc = make_pair(u,v);
        for(auto &sd: revadj[d]) {
            if(find(desc_v.begin(),desc_v.end(),sd) == desc_v.end()) {
                min_inc = min(dist[sd] + weight[make_pair(sd,d)] - dist[d], min_inc);
                e_min_inc = make_pair(d,sd);
            }
        }
        if(min_inc < M_inc[d]) {
            Q.insert(make_pair(min_inc,e_min_inc));
            M_inc[d] = min_inc;
        }
        for(auto &k:treeadj[d]) {
            M.insert(k.first);
            M_inc[k.first] = M_inc[d];
        }
    }

    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;
            M.erase(i);
        }
        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: M) {
                if(M.find(i) == M.end() && find(desc_end_e1.begin(),desc_end_e1.end(),j) == desc_end_e1.end() && weight.find(make_pair(i,j)) != weight.end()) {
                    int min_inc = dist[i] + weight[make_pair(i,j)] - dist[j];
                    if(min_inc < M_inc[j]) {
                        M_inc[j] = min_inc;
                        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 $0x178, %rsp            # imm = 0x178
movl %r8d, -0x80(%rbp)
movl %esi, -0x7c(%rbp)
movq %rdi, %r15
leaq -0x2c(%rbp), %rsi
leaq -0x158(%rbp), %r12
andl $0x0, (%r12)
andq $0x0, 0x8(%r12)
movq %r12, 0x10(%r12)
movq %r12, 0x18(%r12)
andq $0x0, 0x20(%r12)
movl %edx, (%rsi)
leaq -0x168(%rbp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq -0x160(%rbp), %rdi
callq 0x4f4c
leaq -0x198(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x3880
movl -0x80(%rbp), %esi
movl %esi, (%rax)
leaq -0x128(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movl -0x2c(%rbp), %eax
movq %rax, %rcx
shlq $0x20, %rcx
movl -0x7c(%rbp), %edx
orq %rcx, %rdx
movl %esi, -0xb0(%rbp)
movq %rdx, -0xac(%rbp)
movq -0xb0(%rbp), %rcx
leaq -0x50(%rbp), %rsi
movq %rcx, (%rsi)
movl %eax, 0x8(%rsi)
leaq -0x130(%rbp), %rdi
callq 0xaabc
movq %rsp, -0xd8(%rbp)
movq 0xe0(%r15), %rcx
movq 0xe8(%r15), %rdx
movq %rdx, %rax
subq %rcx, %rax
sarq $0x3, %rax
movq %rsp, %rbx
movq %rax, -0xc8(%rbp)
imulq $0x18, %rax, %r14
leaq 0xf(%r14), %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
movq %rcx, -0xc0(%rbp)
movq %rdx, -0xb8(%rbp)
cmpq %rcx, %rdx
je 0x969b
leaq -0x18(%r14), %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 %r14, -0xd0(%rbp)
movq %rbx, -0x58(%rbp)
xorl %ebx, %ebx
leaq -0xb0(%rbp), %r14
movq 0xe0(%r15), %rax
movq 0xe8(%r15), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
jbe 0x96fa
movslq (%rax,%rbx,8), %rcx
cmpq $-0x1, %rcx
je 0x96f5
movl 0x4(%rax,%rbx,8), %eax
shlq $0x20, %rax
addq %rbx, %rax
imulq $0x18, %rcx, %rdi
addq -0x58(%rbp), %rdi
movq %rax, -0xb0(%rbp)
movq %r14, %rsi
callq 0x88dc
incq %rbx
jmp 0x96af
xorps %xmm0, %xmm0
leaq -0xb0(%rbp), %rdx
movaps %xmm0, (%rdx)
andq $0x0, 0x10(%rdx)
movl -0x2c(%rbp), %esi
movq %r15, %rdi
movq -0x58(%rbp), %rcx
callq 0xa168
movq -0xb0(%rbp), %r13
movq -0xa8(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq 0xa8(%r15), %rax
movq %rax, -0xe0(%rbp)
leaq 0x8(%r15), %rax
movq %rax, -0x98(%rbp)
movq %r15, -0x90(%rbp)
cmpq -0xe8(%rbp), %r13
je 0x9b47
movl -0x2c(%rbp), %ebx
movq -0xe0(%rbp), %rdi
movq %r13, %rsi
callq 0xa322
movq (%rax), %r14
movq 0x8(%rax), %r12
movl -0x7c(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x80(%rbp), %r15d
movq %r12, -0xf0(%rbp)
cmpq %r12, %r14
je 0x9822
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
movq %r14, %rdx
callq 0xac4a
cmpq -0xa8(%rbp), %rax
jne 0x9819
movl %r15d, %r12d
movl (%r14), %eax
movslq %eax, %rcx
movq -0x90(%rbp), %r15
movq 0xf8(%r15), %rdx
movl (%rdx,%rcx,4), %ebx
movl (%r13), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, -0x50(%rbp)
movq -0x98(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x7ed0
addl (%rax), %ebx
movslq (%r13), %rax
movq 0xf8(%r15), %rcx
subl (%rcx,%rax,4), %ebx
movl %r12d, %r15d
cmpl %ebx, %r12d
cmovgel %ebx, %r15d
movl (%r13), %eax
movl %eax, -0x88(%rbp)
movl (%r14), %ebx
movq -0xf0(%rbp), %r12
addq $0x4, %r14
jmp 0x978a
leaq -0x198(%rbp), %rdi
movq %r13, %rsi
callq 0x3880
leaq -0x158(%rbp), %r12
cmpl (%rax), %r15d
jge 0x9882
movl %r15d, -0x50(%rbp)
movq %rbx, %rax
shlq $0x20, %rax
movl -0x88(%rbp), %ecx
orq %rax, %rcx
movq %rcx, -0x4c(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
movl %ebx, -0x60(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xaabc
leaq -0x198(%rbp), %rdi
movq %r13, %rsi
callq 0x3880
movl %r15d, (%rax)
movslq (%r13), %rax
imulq $0x18, %rax, %rax
movq -0x58(%rbp), %rcx
movq (%rcx,%rax), %r14
movq 0x8(%rcx,%rax), %rbx
cmpq %rbx, %r14
je 0x98d5
leaq -0x160(%rbp), %rdi
movq %r14, %rsi
callq 0x4f4c
leaq -0x198(%rbp), %rdi
movq %r13, %rsi
callq 0x3880
movl (%rax), %r15d
leaq -0x198(%rbp), %rdi
movq %r14, %rsi
callq 0x3880
movl %r15d, (%rax)
addq $0x8, %r14
jmp 0x9897
addq $0x4, %r13
jmp 0x9750
movq -0x118(%rbp), %rsi
movq 0x20(%rsi), %rax
movq %rax, -0x78(%rbp)
movl 0x28(%rsi), %eax
movl %eax, -0x70(%rbp)
leaq -0x130(%rbp), %rdi
callq 0xacd8
movq -0x98(%rbp), %rdi
leaq -0x74(%rbp), %rsi
callq 0xad38
movslq -0x74(%rbp), %rcx
movl (%rax), %eax
movslq -0x70(%rbp), %rdx
movq -0x90(%rbp), %r14
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
imulq $0x18, %rcx, %rdi
movq -0x58(%rbp), %rbx
addq %rbx, %rdi
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %r15
movq %r15, %rsi
callq 0x88dc
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
andq $0x0, -0x40(%rbp)
movl -0x70(%rbp), %esi
movq %r14, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0xa168
movq -0x50(%rbp), %r14
movq -0x48(%rbp), %rbx
cmpq %rbx, %r14
je 0x99ac
movslq (%r14), %rax
movq -0x90(%rbp), %rcx
movq 0xf8(%rcx), %rcx
movl -0x78(%rbp), %edx
addl %edx, (%rcx,%rax,4)
leaq -0x160(%rbp), %rdi
movq %r14, %rsi
callq 0xae1a
addq $0x4, %r14
jmp 0x997b
movq -0x118(%rbp), %r14
leaq -0x128(%rbp), %rax
cmpq %rax, %r14
je 0x99f3
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq 0x28(%r14), %rdx
callq 0xac4a
cmpq -0x48(%rbp), %rax
je 0x99e6
leaq 0x20(%r14), %rsi
leaq -0x130(%rbp), %rdi
callq 0xaf90
movq %r14, %rdi
callq 0x2190
movq %rax, %r14
jmp 0x99b3
movq -0x50(%rbp), %r14
movq -0x48(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpq -0x88(%rbp), %r14
je 0x9b3e
movq -0x148(%rbp), %r13
cmpq %r12, %r13
je 0x9b35
leaq -0x160(%rbp), %rdi
movq %r14, %rsi
callq 0x664c
cmpq %r12, %rax
jne 0x9a4d
leaq 0x20(%r13), %r15
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %r15, %rdx
callq 0xac4a
cmpq -0x48(%rbp), %rax
je 0x9a5a
movq %r13, %rdi
callq 0x2190
movq %rax, %r13
jmp 0x9a16
movl (%r14), %eax
movl (%r15), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, -0x68(%rbp)
movq -0x98(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xaa90
testq %rax, %rax
je 0x9a4d
movl (%r14), %eax
movslq %eax, %rcx
movq -0x90(%rbp), %r12
movq 0xf8(%r12), %rdx
movl (%rdx,%rcx,4), %ebx
movl (%r15), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, -0x68(%rbp)
movq -0x98(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x7ed0
addl (%rax), %ebx
movslq (%r15), %rax
movq 0xf8(%r12), %rcx
subl (%rcx,%rax,4), %ebx
leaq -0x198(%rbp), %rdi
movq %r15, %rsi
callq 0x3880
leaq -0x158(%rbp), %r12
cmpl (%rax), %ebx
jge 0x9a4d
leaq -0x198(%rbp), %rdi
movq %r15, %rsi
callq 0x3880
movl %ebx, (%rax)
movl (%r14), %eax
movl (%r15), %ecx
movq %rcx, %rdx
shlq $0x20, %rdx
orq %rax, %rdx
movl %ebx, -0x68(%rbp)
movq %rdx, -0x64(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x100(%rbp)
movl %ecx, -0xf8(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xaabc
jmp 0x9a4d
addq $0x4, %r14
jmp 0x9a02
leaq -0x50(%rbp), %rdi
callq 0x8d96
cmpq $0x0, -0x108(%rbp)
jne 0x98de
leaq -0xb0(%rbp), %rdi
callq 0x8d96
movq -0xb8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
movq -0x58(%rbp), %rbx
movq -0xd0(%rbp), %r14
je 0x9b8f
addq $-0x18, %rbx
leaq (%rbx,%r14), %rdi
callq 0x7880
addq $-0x18, %r14
jne 0x9b80
movq -0xd8(%rbp), %rsp
leaq -0x130(%rbp), %rdi
callq 0xa2cc
leaq -0x198(%rbp), %rdi
callq 0x4bcc
leaq -0x160(%rbp), %rdi
callq 0x5ca0
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9bf6
movq %rax, %r14
jmp 0x9c48
movq %rax, %r14
jmp 0x9c54
jmp 0x9bf6
movq %rax, %r14
jmp 0x9c19
jmp 0x9c01
jmp 0x9bf6
jmp 0x9bf6
jmp 0x9bf6
jmp 0x9bf6
jmp 0x9bf6
jmp 0x9bf6
jmp 0x9c01
jmp 0x9c01
jmp 0x9c01
jmp 0x9bf6
jmp 0x9c01
jmp 0x9c01
movq %rax, %r14
jmp 0x9c0d
jmp 0x9c01
jmp 0x9c01
jmp 0x9c01
movq %rax, %r14
leaq -0x50(%rbp), %rdi
callq 0x8d96
leaq -0xb0(%rbp), %rdi
callq 0x8d96
movq -0xb8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
je 0x9c48
movq -0x58(%rbp), %r15
addq $-0x18, %r15
imulq $0x18, -0xc8(%rbp), %rbx
leaq (%r15,%rbx), %rdi
callq 0x7880
addq $-0x18, %rbx
jne 0x9c39
leaq -0x130(%rbp), %rdi
callq 0xa2cc
leaq -0x198(%rbp), %rdi
callq 0x4bcc
leaq -0x160(%rbp), %rdi
callq 0x5ca0
movq %r14, %rdi
callq 0x2240