// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, 0xc(%rsp)
movslq %esi, %r13
movq 0x18(%rdi), %rax
cmpl $0x0, (%rax,%r13,4)
jg 0x41cd
movq %rdx, %r8
movq %rdi, %r14
movslq %ecx, %rax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edx, %edx
divq %rcx
cmpq $0x1, %rdx
adcq $0x0, %rdx
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rsi
andq $0x0, 0x10(%rsi)
movaps %xmm0, (%rsi)
imulq $0xbc8f, %rdx, %rax     # imm = 0xBC8F
xorl %edx, %edx
divq %rcx
movq %rdx, 0x20(%rsp)
movq (%r8), %rax
movq %r8, %rdi
callq *(%rax)
movl %eax, %ebx
movq %r14, %rdi
movl %eax, %esi
movl 0xc(%rsp), %edx
callq 0x257a
movl %eax, %r15d
addl %eax, %ebx
movq 0x30(%r14), %rax
movslq (%rax,%r13,4), %rax
imulq $0x18, %rax, %rbp
leaq 0x1c(%rsp), %r12
movl %r15d, %eax
movl %eax, 0x1c(%rsp)
cmpl %ebx, %eax
jge 0x3f33
movq 0xa8(%r14), %rdi
addq %rbp, %rdi
movq %r12, %rsi
callq 0x3326
movl 0x1c(%rsp), %eax
incl %eax
jmp 0x3f11
movq 0x30(%rsp), %r12
movq 0x38(%rsp), %rbp
cmpq %rbp, %r12
je 0x3f5f
movl (%r12), %esi
addl %r15d, %esi
movl 0x4(%r12), %edx
addl %r15d, %edx
movq %r14, %rdi
callq 0x267e
addq $0x8, %r12
jmp 0x3f3d
movq 0x60(%r14), %rax
imulq $0x18, %r13, %rcx
movq (%rax,%rcx), %rbp
movq %rcx, 0x28(%rsp)
movq 0x8(%rax,%rcx), %rax
movq %rax, 0x10(%rsp)
decl %ebx
cmpq 0x10(%rsp), %rbp
je 0x4027
movslq (%rbp), %r13
imulq $0x18, %r13, %r12
movq 0x60(%r14), %rdi
addq %r12, %rdi
movl 0xc(%rsp), %esi
callq 0x47f9
testb %al, %al
jne 0x4002
movq 0xd046(%rip), %rdi      # 0x10ff0
leaq 0x7551(%rip), %rsi      # 0xb502
callq 0x2140
movq %rax, %rdi
movl 0xc(%rsp), %esi
callq 0x21e0
movq %rax, %rdi
leaq 0x7545(%rip), %rsi      # 0xb511
callq 0x2140
movq %rax, %rdi
movl %r13d, %esi
callq 0x21e0
movq %rax, %rdi
leaq 0x753a(%rip), %rsi      # 0xb520
callq 0x2140
addq 0x60(%r14), %r12
movq %rax, %rdi
movq %r12, %rsi
callq 0x3463
movq %rax, %rdi
callq 0x2080
movl %r15d, %edi
movl %ebx, %esi
leaq 0x20(%rsp), %rdx
callq 0x421e
movq %r14, %rdi
movl %eax, %esi
movl %r13d, %edx
callq 0x264c
addq $0x4, %rbp
jmp 0x3f7c
movq 0x78(%r14), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx), %rbp
movq 0x8(%rax,%rcx), %rax
movq %rax, 0x10(%rsp)
cmpq 0x10(%rsp), %rbp
je 0x40ef
movslq (%rbp), %r13
imulq $0x18, %r13, %r12
movq 0x90(%r14), %rdi
addq %r12, %rdi
movl 0xc(%rsp), %esi
callq 0x47f9
testb %al, %al
jne 0x40ca
movq 0xcf81(%rip), %rdi      # 0x10ff0
leaq 0x748c(%rip), %rsi      # 0xb502
callq 0x2140
movq %rax, %rdi
movl 0xc(%rsp), %esi
callq 0x21e0
movq %rax, %rdi
leaq 0x7494(%rip), %rsi      # 0xb525
callq 0x2140
movq %rax, %rdi
movl %r13d, %esi
callq 0x21e0
movq %rax, %rdi
leaq 0x7475(%rip), %rsi      # 0xb520
callq 0x2140
addq 0x90(%r14), %r12
movq %rax, %rdi
movq %r12, %rsi
callq 0x3463
movq %rax, %rdi
callq 0x2080
movl %r15d, %edi
movl %ebx, %esi
leaq 0x20(%rsp), %rdx
callq 0x421e
movq %r14, %rdi
movl %eax, %esi
movl %r13d, %edx
callq 0x26c2
addq $0x4, %rbp
jmp 0x403e
movq 0x90(%r14), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx), %rbp
movq 0x8(%rax,%rcx), %rax
movq %rax, 0x10(%rsp)
cmpq 0x10(%rsp), %rbp
je 0x41b4
movslq (%rbp), %r13
imulq $0x18, %r13, %r12
movq 0x78(%r14), %rdi
addq %r12, %rdi
movl 0xc(%rsp), %esi
callq 0x47f9
testb %al, %al
jne 0x418f
movq 0xceb9(%rip), %rdi      # 0x10ff0
leaq 0x73c4(%rip), %rsi      # 0xb502
callq 0x2140
movq %rax, %rdi
movl 0xc(%rsp), %esi
callq 0x21e0
movq %rax, %rdi
leaq 0x73db(%rip), %rsi      # 0xb534
callq 0x2140
movq %rax, %rdi
movl %r13d, %esi
callq 0x21e0
movq %rax, %rdi
leaq 0x73ad(%rip), %rsi      # 0xb520
callq 0x2140
addq 0x78(%r14), %r12
movq %rax, %rdi
movq %r12, %rsi
callq 0x3463
movq %rax, %rdi
callq 0x2080
movl %r15d, %edi
movl %ebx, %esi
leaq 0x20(%rsp), %rdx
callq 0x421e
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
callq 0x26c2
addq $0x4, %rbp
jmp 0x4109
leaq 0x30(%rsp), %rdi
callq 0x366e
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xcdfc(%rip), %rax      # 0x10fd0
movq (%rax), %rcx
leaq 0x7302(%rip), %rdi      # 0xb4e0
pushq $0x21
popq %rsi
pushq $0x1
popq %rdx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2210
jmp 0x4209
jmp 0x4209
jmp 0x4209
jmp 0x4209
jmp 0x4209
jmp 0x4209
jmp 0x4209
jmp 0x4209
jmp 0x4209
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x366e
movq %rbx, %rdi
callq 0x21f0