// File: /workspace/github_cpp_makefile_star2_O3/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, 0x8(%rsp)
movslq %esi, %r12
movq 0x18(%rdi), %rax
cmpl $0x0, (%rax,%r12,4)
jg 0x4cfb
movq %rdx, %r8
movq %rdi, %r14
movslq %ecx, %rcx
movabsq $0x200000005, %rdx      # imm = 0x200000005
movq %rcx, %rax
mulq %rdx
movq %rcx, %rax
subq %rdx, %rax
shrq %rax
addq %rdx, %rax
shrq $0x1e, %rax
movq %rax, %rdx
shlq $0x1f, %rdx
subq %rdx, %rax
leaq (%rcx,%rax), %rdx
cmpq $0x1, %rdx
adcq %rcx, %rax
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
imulq $0xbc8f, %rax, %rcx     # imm = 0xBC8F
movabsq $0x800000010001, %rdx   # imm = 0x800000010001
movq %rcx, %rax
mulq %rdx
shrl $0xe, %edx
movq %rdx, %rax
shlq $0x1f, %rax
subq %rax, %rdx
addq %rcx, %rdx
movq %rdx, 0x20(%rsp)
movq (%r8), %rax
movq %r8, %rdi
callq *(%rax)
movl %eax, %ebx
movq %r14, %rdi
movl %eax, %esi
movl 0x8(%rsp), %edx
callq 0x2858
movl %eax, %ebp
addl %ebx, %eax
movq %rax, 0x10(%rsp)
movq 0x30(%r14), %rax
movslq (%rax,%r12,4), %rax
movl %ebp, (%rsp)
testl %ebx, %ebx
jle 0x48a9
leaq (%rax,%rax,2), %rbx
movq %rsp, %r15
movl %ebp, %eax
movq 0xa8(%r14), %rcx
leaq (%rcx,%rbx,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x4893
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x489b
movq %r15, %rdx
callq 0x3d28
movl (%rsp), %eax
incl %eax
movl %eax, (%rsp)
cmpl 0x10(%rsp), %eax
jl 0x4872
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %r15
cmpq %r15, %rbx
je 0x48cf
movl (%rbx), %esi
addl %ebp, %esi
movl 0x4(%rbx), %edx
addl %ebp, %edx
movq %r14, %rdi
callq 0x29ae
addq $0x8, %rbx
jmp 0x48b3
movq 0x60(%r14), %rax
leaq (%r12,%r12,2), %rcx
movq (%rax,%rcx,8), %r15
movq %rcx, 0x28(%rsp)
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
cmpq %rax, %r15
je 0x4a28
movq 0x10(%rsp), %rax
decl %eax
movl %eax, 0xc(%rsp)
movslq (%r15), %r12
movq 0x60(%r14), %rbx
leaq (%r12,%r12,2), %r13
movq (%rbx,%r13,8), %rdi
movq 0x8(%rbx,%r13,8), %rsi
movl 0x8(%rsp), %eax
movl %eax, (%rsp)
movq %rsp, %rdx
callq 0x3c82
leaq (%rbx,%r13,8), %rbx
movq 0x8(%rbx), %rdx
cmpq %rdx, %rax
je 0x4953
leaq 0x4(%rax), %rsi
cmpq %rdx, %rsi
je 0x4946
subq %rsi, %rdx
movq %rax, %rdi
callq 0x21f0
movq 0x8(%rbx), %rdx
addq $-0x4, %rdx
movq %rdx, 0x8(%rbx)
jmp 0x49f1
movl $0xe, %edx
movq 0xc691(%rip), %rdi      # 0x10ff0
leaq 0x7bcc(%rip), %rsi      # 0xc532
callq 0x21a0
movq 0xc67e(%rip), %rdi      # 0x10ff0
movl 0x8(%rsp), %esi
callq 0x2210
movq %rax, %rbx
movl $0xe, %edx
movq %rax, %rdi
leaq 0x7bb4(%rip), %rsi      # 0xc541
callq 0x21a0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2210
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x7ba1(%rip), %rsi      # 0xc550
callq 0x21a0
shlq $0x3, %r13
addq 0x60(%r14), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x39c5
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20d0
movl %ebp, (%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x4(%rsp)
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
movq %rdi, %rdx
callq 0x5a56
movq %r14, %rdi
movl %eax, %esi
movl %r12d, %edx
callq 0x2930
addq $0x4, %r15
cmpq 0x18(%rsp), %r15
jne 0x48fe
movq 0x78(%r14), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %r15
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
cmpq %rax, %r15
je 0x4b83
movq 0x10(%rsp), %rax
decl %eax
movl %eax, 0xc(%rsp)
movslq (%r15), %r12
movq 0x90(%r14), %rbx
leaq (%r12,%r12,2), %r13
movq (%rbx,%r13,8), %rdi
movq 0x8(%rbx,%r13,8), %rsi
movl 0x8(%rsp), %eax
movl %eax, (%rsp)
movq %rsp, %rdx
callq 0x3c82
leaq (%rbx,%r13,8), %rbx
movq 0x8(%rbx), %rdx
cmpq %rdx, %rax
je 0x4aab
leaq 0x4(%rax), %rsi
cmpq %rdx, %rsi
je 0x4a9e
subq %rsi, %rdx
movq %rax, %rdi
callq 0x21f0
movq 0x8(%rbx), %rdx
addq $-0x4, %rdx
movq %rdx, 0x8(%rbx)
jmp 0x4b4c
movl $0xe, %edx
movq 0xc539(%rip), %rdi      # 0x10ff0
leaq 0x7a74(%rip), %rsi      # 0xc532
callq 0x21a0
movq 0xc526(%rip), %rdi      # 0x10ff0
movl 0x8(%rsp), %esi
callq 0x2210
movq %rax, %rbx
movl $0xe, %edx
movq %rax, %rdi
leaq 0x7a70(%rip), %rsi      # 0xc555
callq 0x21a0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2210
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x7a49(%rip), %rsi      # 0xc550
callq 0x21a0
shlq $0x3, %r13
addq 0x90(%r14), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x39c5
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20d0
movl %ebp, (%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x4(%rsp)
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
movq %rdi, %rdx
callq 0x5a56
movq %r14, %rdi
movl %eax, %esi
movl %r12d, %edx
callq 0x2a2c
addq $0x4, %r15
cmpq 0x18(%rsp), %r15
jne 0x4a53
movq 0x90(%r14), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %r15
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
cmpq %rax, %r15
je 0x4cdd
movq 0x10(%rsp), %rax
decl %eax
movq %rax, 0x10(%rsp)
movslq (%r15), %r12
movq 0x78(%r14), %rbx
leaq (%r12,%r12,2), %r13
movq (%rbx,%r13,8), %rdi
movq 0x8(%rbx,%r13,8), %rsi
movl 0x8(%rsp), %eax
movl %eax, (%rsp)
movq %rsp, %rdx
callq 0x3c82
leaq (%rbx,%r13,8), %rbx
movq 0x8(%rbx), %rdx
cmpq %rdx, %rax
je 0x4c07
leaq 0x4(%rax), %rsi
cmpq %rdx, %rsi
je 0x4bfa
subq %rsi, %rdx
movq %rax, %rdi
callq 0x21f0
movq 0x8(%rbx), %rdx
addq $-0x4, %rdx
movq %rdx, 0x8(%rbx)
jmp 0x4ca5
movl $0xe, %edx
movq 0xc3dd(%rip), %rdi      # 0x10ff0
leaq 0x7918(%rip), %rsi      # 0xc532
callq 0x21a0
movq 0xc3ca(%rip), %rdi      # 0x10ff0
movl 0x8(%rsp), %esi
callq 0x2210
movq %rax, %rbx
movl $0xc, %edx
movq %rax, %rdi
leaq 0x7923(%rip), %rsi      # 0xc564
callq 0x21a0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2210
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x78ed(%rip), %rsi      # 0xc550
callq 0x21a0
shlq $0x3, %r13
addq 0x78(%r14), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x39c5
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20d0
movl %ebp, (%rsp)
movq 0x10(%rsp), %rax
movl %eax, 0x4(%rsp)
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
movq %rdi, %rdx
callq 0x5a56
movq %r14, %rdi
movl %r12d, %esi
movl %eax, %edx
callq 0x2a2c
addq $0x4, %r15
cmpq 0x18(%rsp), %r15
jne 0x4bb2
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x4cec
callq 0x2150
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x22f6
jmp 0x4cec
jmp 0x4d14
jmp 0x4d14
jmp 0x4d14
jmp 0x4d14
jmp 0x4d14
jmp 0x4d14
jmp 0x4d14
jmp 0x4d14
jmp 0x4d14
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x4d26
callq 0x2150
movq %rbx, %rdi
callq 0x2220