// File: sharmaeklavya2[P]ddos-on-anycast/src/lib/network_grow.cpp
// Function: Network::expand_node(int, GraphGen&, int)
void Network::expand_node(int u, GraphGen& graph_gen, int seed) {
    if(is_virtual(u) > 0) {
        fprintf(stderr, "Attempt to expand a virtual node\n");
        return;
    }

    rng_t rng1(seed);

    ipvec l;
    int n = graph_gen(l, rng1());

    int ufirst = make_new_vertices(n, u);
    int uend = ufirst + n;
    int d = depth[u];
    for(int v=ufirst; v<uend; ++v) {
        depthwise[d].push_back(v);
    }

    // connect in_nbrs
    for(iipair& p: l) {
        int u = ufirst + p.first, v = ufirst + p.second;
        add_in_edge(u, v);
    }

    // reconnect previous connections
    for(int v: side_nbrs[u]) {
        if(!find_and_erase(side_nbrs[v], u)) {
            cerr << "Couldn't find " << u << " in side_nbrs[" << v << "] = " << side_nbrs[v] << endl;
        }
        int u2 = iunidist(ufirst, ufirst + n - 1, rng1);
        add_side_edge(u2, v);
    }
    for(int v: up_nbrs[u]) {
        if(!find_and_erase(down_nbrs[v], u)) {
            cerr << "Couldn't find " << u << " in down_nbrs[" << v << "] = " << down_nbrs[v] << endl;
        }
        int u2 = iunidist(ufirst, ufirst + n - 1, rng1);
        /*
        if(u2 < 0) {
            fprintf(stderr, "ufirst=%d, n=%d, u2=%d, u=%d\n", ufirst, n, u2, u);
        }
        */
        add_upward_edge(u2, v);
    }
    for(int v: down_nbrs[u]) {
        if(!find_and_erase(up_nbrs[v], u)) {
            cerr << "Couldn't find " << u << " in up_nbrs[" << v << "] = " << up_nbrs[v] << endl;
        }
        int u2 = iunidist(ufirst, ufirst + n - 1, rng1);
        add_upward_edge(v, u2);
    }
}

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, 0x1c0(%rsp)
movl %esi, 0x1bc(%rsp)
movq %rdx, 0x1b0(%rsp)
movl %ecx, 0x1ac(%rsp)
movq 0x1c0(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
movl 0x1bc(%rsp), %esi
callq 0x4830
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jle 0x8aa8
movq 0x24536(%rip), %rax     # 0x2cfc8
movq (%rax), %rdi
leaq 0x18a34(%rip), %rsi     # 0x214d0
movb $0x0, %al
callq 0x2180
jmp 0x92c0
movslq 0x1ac(%rsp), %rsi
leaq 0x1a0(%rsp), %rdi
movq %rdi, 0xb8(%rsp)
callq 0x9f10
leaq 0x188(%rsp), %rdi
callq 0x4a50
movq 0xb8(%rsp), %rdi
movq 0x1b0(%rsp), %rax
movq %rax, 0xc0(%rsp)
callq 0x9f40
movq %rax, 0xc8(%rsp)
jmp 0x8af9
movq 0xc0(%rsp), %rdi
movq 0xc8(%rsp), %rax
movl %eax, %edx
movq (%rdi), %rax
movq (%rax), %rax
leaq 0x188(%rsp), %rsi
callq *%rax
movl %eax, 0xb4(%rsp)
jmp 0x8b24
movq 0xd0(%rsp), %rdi
movl 0xb4(%rsp), %eax
movl %eax, 0x184(%rsp)
movl 0x184(%rsp), %esi
movl 0x1bc(%rsp), %edx
callq 0x2720
movl %eax, 0xb0(%rsp)
jmp 0x8b56
movq 0xd0(%rsp), %rdi
movl 0xb0(%rsp), %eax
movl %eax, 0x170(%rsp)
movl 0x170(%rsp), %eax
addl 0x184(%rsp), %eax
movl %eax, 0x16c(%rsp)
addq $0x30, %rdi
movslq 0x1bc(%rsp), %rsi
callq 0x4860
movl (%rax), %eax
movl %eax, 0x168(%rsp)
movl 0x170(%rsp), %eax
movl %eax, 0x164(%rsp)
movl 0x164(%rsp), %eax
cmpl 0x16c(%rsp), %eax
jge 0x8c22
movq 0xd0(%rsp), %rdi
addq $0xa8, %rdi
movslq 0x168(%rsp), %rsi
callq 0x46a0
movq %rax, %rdi
leaq 0x164(%rsp), %rsi
callq 0x46f0
jmp 0x8be7
jmp 0x8be9
movl 0x164(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x164(%rsp)
jmp 0x8ba9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x4ae0
jmp 0x92c8
leaq 0x188(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x158(%rsp), %rdi
callq 0x7280
movq %rax, 0x150(%rsp)
movq 0x158(%rsp), %rdi
callq 0x7100
movq %rax, 0x148(%rsp)
leaq 0x150(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x9f70
testb $0x1, %al
jne 0x8c77
jmp 0x8cf2
leaq 0x150(%rsp), %rdi
callq 0x9fb0
movq 0xd0(%rsp), %rdi
movq %rax, 0x140(%rsp)
movl 0x170(%rsp), %eax
movq 0x140(%rsp), %rcx
movl (%rcx), %ecx
addl %ecx, %eax
movl %eax, 0x13c(%rsp)
movl 0x170(%rsp), %eax
movq 0x140(%rsp), %rcx
movl 0x4(%rcx), %ecx
addl %ecx, %eax
movl %eax, 0x138(%rsp)
movl 0x13c(%rsp), %esi
movl 0x138(%rsp), %edx
callq 0x28d0
jmp 0x8cde
jmp 0x8ce0
leaq 0x150(%rsp), %rdi
callq 0x9fc0
jmp 0x8c5c
movq 0xd0(%rsp), %rdi
addq $0x60, %rdi
movslq 0x1bc(%rsp), %rsi
callq 0x46a0
movq %rax, 0x130(%rsp)
movq 0x130(%rsp), %rdi
callq 0x5bf0
movq %rax, 0x128(%rsp)
movq 0x130(%rsp), %rdi
callq 0x5a70
movq %rax, 0x120(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x9fe0
testb $0x1, %al
jne 0x8d5b
jmp 0x8ef2
leaq 0x128(%rsp), %rdi
callq 0xa020
movq 0xd0(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x11c(%rsp)
addq $0x60, %rdi
movslq 0x11c(%rsp), %rsi
callq 0x46a0
movq %rax, %rdi
movl 0x1bc(%rsp), %esi
callq 0xa030
movb %al, 0xaf(%rsp)
jmp 0x8da2
movb 0xaf(%rsp), %al
testb $0x1, %al
jne 0x8e8d
jmp 0x8db3
movq 0x2422e(%rip), %rdi     # 0x2cfe8
leaq 0x18731(%rip), %rsi     # 0x214f2
callq 0x2140
movq %rax, 0xa0(%rsp)
jmp 0x8dd0
movq 0xa0(%rsp), %rdi
movl 0x1bc(%rsp), %esi
callq 0x21e0
movq %rax, 0x98(%rsp)
jmp 0x8dee
movq 0x98(%rsp), %rdi
leaq 0x18704(%rip), %rsi     # 0x21501
callq 0x2140
movq %rax, 0x90(%rsp)
jmp 0x8e0c
movq 0x90(%rsp), %rdi
movl 0x11c(%rsp), %esi
callq 0x21e0
movq %rax, 0x88(%rsp)
jmp 0x8e2a
movq 0x88(%rsp), %rdi
leaq 0x186d7(%rip), %rsi     # 0x21510
callq 0x2140
movq %rax, 0x80(%rsp)
jmp 0x8e48
movq 0xd0(%rsp), %rdi
addq $0x60, %rdi
movslq 0x11c(%rsp), %rsi
callq 0x46a0
movq 0x80(%rsp), %rdi
movq %rax, %rsi
callq 0x4ce0
movq %rax, 0x78(%rsp)
jmp 0x8e78
movq 0x78(%rsp), %rdi
movq 0x24134(%rip), %rsi     # 0x2cfb8
callq 0x2170
jmp 0x8e8b
jmp 0x8e8d
movl 0x170(%rsp), %edi
movl 0x184(%rsp), %eax
movl %eax, %ecx
movl %edi, %eax
leal -0x1(%rax,%rcx), %esi
leaq 0x1a0(%rsp), %rdx
callq 0x92e0
movl %eax, 0x74(%rsp)
jmp 0x8eb6
movq 0xd0(%rsp), %rdi
movl 0x74(%rsp), %eax
movl %eax, 0x118(%rsp)
movl 0x118(%rsp), %esi
movl 0x11c(%rsp), %edx
callq 0x2870
jmp 0x8ede
jmp 0x8ee0
leaq 0x128(%rsp), %rdi
callq 0xa0b0
jmp 0x8d3d
movq 0xd0(%rsp), %rdi
addq $0x78, %rdi
movslq 0x1bc(%rsp), %rsi
callq 0x46a0
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rdi
callq 0x5bf0
movq %rax, 0x108(%rsp)
movq 0x110(%rsp), %rdi
callq 0x5a70
movq %rax, 0x100(%rsp)
leaq 0x108(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x9fe0
testb $0x1, %al
jne 0x8f5b
jmp 0x90d4
leaq 0x108(%rsp), %rdi
callq 0xa020
movq 0xd0(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0xfc(%rsp)
addq $0x90, %rdi
movslq 0xfc(%rsp), %rsi
callq 0x46a0
movq %rax, %rdi
movl 0x1bc(%rsp), %esi
callq 0xa030
movb %al, 0x73(%rsp)
jmp 0x8fa2
movb 0x73(%rsp), %al
testb $0x1, %al
jne 0x906f
jmp 0x8fb0
movq 0x24031(%rip), %rdi     # 0x2cfe8
leaq 0x18534(%rip), %rsi     # 0x214f2
callq 0x2140
movq %rax, 0x68(%rsp)
jmp 0x8fca
movq 0x68(%rsp), %rdi
movl 0x1bc(%rsp), %esi
callq 0x21e0
movq %rax, 0x60(%rsp)
jmp 0x8fe2
movq 0x60(%rsp), %rdi
leaq 0x18527(%rip), %rsi     # 0x21515
callq 0x2140
movq %rax, 0x58(%rsp)
jmp 0x8ffa
movq 0x58(%rsp), %rdi
movl 0xfc(%rsp), %esi
callq 0x21e0
movq %rax, 0x50(%rsp)
jmp 0x9012
movq 0x50(%rsp), %rdi
leaq 0x184f2(%rip), %rsi     # 0x21510
callq 0x2140
movq %rax, 0x48(%rsp)
jmp 0x902a
movq 0xd0(%rsp), %rdi
addq $0x90, %rdi
movslq 0xfc(%rsp), %rsi
callq 0x46a0
movq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x4ce0
movq %rax, 0x40(%rsp)
jmp 0x905a
movq 0x40(%rsp), %rdi
movq 0x23f52(%rip), %rsi     # 0x2cfb8
callq 0x2170
jmp 0x906d
jmp 0x906f
movl 0x170(%rsp), %edi
movl 0x184(%rsp), %eax
movl %eax, %ecx
movl %edi, %eax
leal -0x1(%rax,%rcx), %esi
leaq 0x1a0(%rsp), %rdx
callq 0x92e0
movl %eax, 0x3c(%rsp)
jmp 0x9098
movq 0xd0(%rsp), %rdi
movl 0x3c(%rsp), %eax
movl %eax, 0xf8(%rsp)
movl 0xf8(%rsp), %esi
movl 0xfc(%rsp), %edx
callq 0x2960
jmp 0x90c0
jmp 0x90c2
leaq 0x108(%rsp), %rdi
callq 0xa0b0
jmp 0x8f3d
movq 0xd0(%rsp), %rdi
addq $0x90, %rdi
movslq 0x1bc(%rsp), %rsi
callq 0x46a0
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x5bf0
movq %rax, 0xe8(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x5a70
movq %rax, 0xe0(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x9fe0
testb $0x1, %al
jne 0x9140
jmp 0x92b3
leaq 0xe8(%rsp), %rdi
callq 0xa020
movq 0xd0(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0xdc(%rsp)
addq $0x78, %rdi
movslq 0xdc(%rsp), %rsi
callq 0x46a0
movq %rax, %rdi
movl 0x1bc(%rsp), %esi
callq 0xa030
movb %al, 0x3b(%rsp)
jmp 0x9184
movb 0x3b(%rsp), %al
testb $0x1, %al
jne 0x924e
jmp 0x9192
movq 0x23e4f(%rip), %rdi     # 0x2cfe8
leaq 0x18352(%rip), %rsi     # 0x214f2
callq 0x2140
movq %rax, 0x30(%rsp)
jmp 0x91ac
movq 0x30(%rsp), %rdi
movl 0x1bc(%rsp), %esi
callq 0x21e0
movq %rax, 0x28(%rsp)
jmp 0x91c4
movq 0x28(%rsp), %rdi
leaq 0x18354(%rip), %rsi     # 0x21524
callq 0x2140
movq %rax, 0x20(%rsp)
jmp 0x91dc
movq 0x20(%rsp), %rdi
movl 0xdc(%rsp), %esi
callq 0x21e0
movq %rax, 0x18(%rsp)
jmp 0x91f4
movq 0x18(%rsp), %rdi
leaq 0x18310(%rip), %rsi     # 0x21510
callq 0x2140
movq %rax, 0x10(%rsp)
jmp 0x920c
movq 0xd0(%rsp), %rdi
addq $0x78, %rdi
movslq 0xdc(%rsp), %rsi
callq 0x46a0
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x4ce0
movq %rax, 0x8(%rsp)
jmp 0x9239
movq 0x8(%rsp), %rdi
movq 0x23d73(%rip), %rsi     # 0x2cfb8
callq 0x2170
jmp 0x924c
jmp 0x924e
movl 0x170(%rsp), %edi
movl 0x184(%rsp), %eax
movl %eax, %ecx
movl %edi, %eax
leal -0x1(%rax,%rcx), %esi
leaq 0x1a0(%rsp), %rdx
callq 0x92e0
movl %eax, 0x4(%rsp)
jmp 0x9277
movq 0xd0(%rsp), %rdi
movl 0x4(%rsp), %eax
movl %eax, 0xd8(%rsp)
movl 0xdc(%rsp), %esi
movl 0xd8(%rsp), %edx
callq 0x2960
jmp 0x929f
jmp 0x92a1
leaq 0xe8(%rsp), %rdi
callq 0xa0b0
jmp 0x9122
leaq 0x188(%rsp), %rdi
callq 0x4ae0
addq $0x1c8, %rsp            # imm = 0x1C8
retq
movq 0x178(%rsp), %rdi
callq 0x21f0
nopw %cs:(%rax,%rax)