// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movl %esi, 0xc(%rsp)
movslq %esi, %r12
movq 0x18(%rdi), %rax
cmpl $0x0, (%rax,%r12,4)
jg 0x4e6a
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
movq %rax, 0x30(%rsp)
xorps %xmm0, %xmm0
leaq 0x40(%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, 0x30(%rsp)
movq (%r8), %rax
movq %r8, %rdi
callq *(%rax)
movl %eax, %ebx
movq %r14, %rdi
movl %eax, %esi
movl 0xc(%rsp), %edx
callq 0x2938
movl %eax, %ebp
addl %ebx, %eax
movq %rax, 0x18(%rsp)
movq 0x30(%r14), %rax
movslq (%rax,%r12,4), %rax
movl %ebp, 0x4(%rsp)
testl %ebx, %ebx
jle 0x49a3
leaq (%rax,%rax,2), %rbx
leaq 0x4(%rsp), %r15
movl %ebp, %eax
movq 0xa8(%r14), %rcx
leaq (%rcx,%rbx,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x498b
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x4993
movq %r15, %rdx
callq 0x3e1c
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
cmpl 0x18(%rsp), %eax
jl 0x496a
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r15
cmpq %r15, %rbx
je 0x49c9
movl (%rbx), %esi
addl %ebp, %esi
movl 0x4(%rbx), %edx
addl %ebp, %edx
movq %r14, %rdi
callq 0x2a8e
addq $0x8, %rbx
jmp 0x49ad
movl %ebp, 0x14(%rsp)
movq 0x60(%r14), %rax
leaq (%r12,%r12,2), %rcx
movq (%rax,%rcx,8), %r15
movq %rcx, 0x38(%rsp)
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %r15
movq %r14, 0x20(%rsp)
je 0x4b4f
movq 0x18(%rsp), %rax
decl %eax
movl %eax, 0x10(%rsp)
leaq 0x4(%rsp), %rbx
movslq (%r15), %r13
movq 0x60(%r14), %r14
leaq (,%r13,2), %r12
addq %r13, %r12
movl 0xc(%rsp), %eax
movl %eax, 0x4(%rsp)
movq (%r14,%r12,8), %rdi
movq 0x8(%r14,%r12,8), %rsi
movq %rbx, %rdx
callq 0x3d83
movq %rax, %rbx
leaq (%r14,%r12,8), %rbp
movq 0x8(%rbp), %r14
cmpq %r14, %rax
je 0x4a66
leaq 0x4(%rbx), %rsi
cmpq %r14, %rsi
je 0x4a58
movq %r14, %rdx
subq %rsi, %rdx
movq %rbx, %rdi
callq 0x21f0
addq $-0x4, 0x8(%rbp)
cmpq %r14, %rbx
jne 0x4b09
movl $0xe, %edx
movq 0xd57e(%rip), %rdi      # 0x11ff0
leaq 0x8ab9(%rip), %rsi      # 0xd532
callq 0x21a0
movq 0xd56b(%rip), %rdi      # 0x11ff0
movl 0xc(%rsp), %esi
callq 0x2210
movq %rax, %rbx
movl $0xe, %edx
movq %rax, %rdi
leaq 0x8aa1(%rip), %rsi      # 0xd541
callq 0x21a0
movq %rbx, %rdi
movl %r13d, %esi
callq 0x2210
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x8a8e(%rip), %rsi      # 0xd550
callq 0x21a0
shlq $0x3, %r12
movq 0x20(%rsp), %rax
addq 0x60(%rax), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3ad7
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 0x14(%rsp), %eax
movl %eax, 0x4(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x8(%rsp)
leaq 0x4(%rsp), %rbx
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
movq %rbx, %rdx
callq 0x5b5e
movq 0x20(%rsp), %r14
movq %r14, %rdi
movl %eax, %esi
movl %r13d, %edx
callq 0x2a10
addq $0x4, %r15
cmpq 0x28(%rsp), %r15
jne 0x4a06
movq 0x78(%r14), %rax
movq 0x38(%rsp), %rcx
movq (%rax,%rcx,8), %r15
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %r15
je 0x4cce
movq 0x18(%rsp), %rax
decl %eax
movl %eax, 0x10(%rsp)
leaq 0x4(%rsp), %rbx
movslq (%r15), %r13
movq 0x90(%r14), %r14
leaq (,%r13,2), %r12
addq %r13, %r12
movl 0xc(%rsp), %eax
movl %eax, 0x4(%rsp)
movq (%r14,%r12,8), %rdi
movq 0x8(%r14,%r12,8), %rsi
movq %rbx, %rdx
callq 0x3d83
movq %rax, %rbx
leaq (%r14,%r12,8), %r14
movq 0x8(%r14), %rbp
cmpq %rbp, %rax
je 0x4be2
leaq 0x4(%rbx), %rsi
cmpq %rbp, %rsi
je 0x4bd4
movq %rbp, %rdx
subq %rsi, %rdx
movq %rbx, %rdi
callq 0x21f0
addq $-0x4, 0x8(%r14)
cmpq %rbp, %rbx
jne 0x4c88
movl $0xe, %edx
movq 0xd402(%rip), %rdi      # 0x11ff0
leaq 0x893d(%rip), %rsi      # 0xd532
callq 0x21a0
movq 0xd3ef(%rip), %rdi      # 0x11ff0
movl 0xc(%rsp), %esi
callq 0x2210
movq %rax, %rbx
movl $0xe, %edx
movq %rax, %rdi
leaq 0x8939(%rip), %rsi      # 0xd555
callq 0x21a0
movq %rbx, %rdi
movl %r13d, %esi
callq 0x2210
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x8912(%rip), %rsi      # 0xd550
callq 0x21a0
shlq $0x3, %r12
movq 0x20(%rsp), %rax
addq 0x90(%rax), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3ad7
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 0x14(%rsp), %eax
movl %eax, 0x4(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x8(%rsp)
leaq 0x4(%rsp), %rbx
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
movq %rbx, %rdx
callq 0x5b5e
movq 0x20(%rsp), %r14
movq %r14, %rdi
movl %eax, %esi
movl %r13d, %edx
callq 0x2b0c
addq $0x4, %r15
cmpq 0x28(%rsp), %r15
jne 0x4b7f
movq 0x90(%r14), %rax
movq 0x38(%rsp), %rcx
movq (%rax,%rcx,8), %r15
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %r15
je 0x4e4c
movq 0x18(%rsp), %rax
decl %eax
movq %rax, 0x18(%rsp)
leaq 0x4(%rsp), %rbx
movslq (%r15), %r13
movq 0x78(%r14), %r14
leaq (,%r13,2), %r12
addq %r13, %r12
movl 0xc(%rsp), %eax
movl %eax, 0x4(%rsp)
movq (%r14,%r12,8), %rdi
movq 0x8(%r14,%r12,8), %rsi
movq %rbx, %rdx
callq 0x3d83
movq %rax, %rbx
leaq (%r14,%r12,8), %r14
movq 0x8(%r14), %rbp
cmpq %rbp, %rax
je 0x4d62
leaq 0x4(%rbx), %rsi
cmpq %rbp, %rsi
je 0x4d54
movq %rbp, %rdx
subq %rsi, %rdx
movq %rbx, %rdi
callq 0x21f0
addq $-0x4, 0x8(%r14)
cmpq %rbp, %rbx
jne 0x4e05
movl $0xe, %edx
movq 0xd282(%rip), %rdi      # 0x11ff0
leaq 0x87bd(%rip), %rsi      # 0xd532
callq 0x21a0
movq 0xd26f(%rip), %rdi      # 0x11ff0
movl 0xc(%rsp), %esi
callq 0x2210
movq %rax, %rbx
movl $0xc, %edx
movq %rax, %rdi
leaq 0x87c8(%rip), %rsi      # 0xd564
callq 0x21a0
movq %rbx, %rdi
movl %r13d, %esi
callq 0x2210
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x8792(%rip), %rsi      # 0xd550
callq 0x21a0
shlq $0x3, %r12
movq 0x20(%rsp), %rax
addq 0x78(%rax), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3ad7
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 0x14(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x18(%rsp), %rax
movl %eax, 0x8(%rsp)
leaq 0x4(%rsp), %rbx
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
movq %rbx, %rdx
callq 0x5b5e
movq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
callq 0x2b0c
addq $0x4, %r15
cmpq 0x28(%rsp), %r15
jne 0x4d02
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x4e5b
callq 0x2150
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x22f6
jmp 0x4e5b
jmp 0x4e83
jmp 0x4e83
jmp 0x4e83
jmp 0x4e83
jmp 0x4e83
jmp 0x4e83
jmp 0x4e83
jmp 0x4e83
jmp 0x4e83
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x4e95
callq 0x2150
movq %rbx, %rdi
callq 0x2220
nop